]> code.delx.au - gnu-emacs/blob - lisp/pcvs-defs.el
Merge from emacs--rel--22
[gnu-emacs] / lisp / pcvs-defs.el
1 ;;; pcvs-defs.el --- variable definitions for PCL-CVS
2
3 ;; Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
4 ;; 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
5 ;; Free Software Foundation, Inc.
6
7 ;; Author: Stefan Monnier <monnier@iro.umontreal.ca>
8 ;; Keywords: pcl-cvs
9
10 ;; This file is part of GNU Emacs.
11
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 3, or (at your option)
15 ;; any later version.
16
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
21
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25 ;; Boston, MA 02110-1301, USA.
26
27 ;;; Commentary:
28
29
30 ;;; Code:
31
32 (eval-when-compile (require 'cl))
33 (require 'pcvs-util)
34
35 ;;;; -------------------------------------------------------
36 ;;;; START OF THINGS TO CHECK WHEN INSTALLING
37
38 (defvar cvs-program "cvs"
39 "*Name or full path of the cvs executable.")
40
41 (defvar cvs-version
42 ;; With the divergence of the CVSNT codebase and version numbers, this is
43 ;; not really good any more.
44 (ignore-errors
45 (with-temp-buffer
46 (call-process cvs-program nil t nil "-v")
47 (goto-char (point-min))
48 (when (re-search-forward "(CVS\\(NT\\)?) \\([0-9]+\\)\\.\\([0-9]+\\)"
49 nil t)
50 (cons (string-to-number (match-string 1))
51 (string-to-number (match-string 2))))))
52 "*Version of `cvs' installed on your system.
53 It must be in the (MAJOR . MINOR) format.")
54
55 ;; FIXME: this is only used by cvs-mode-diff-backup
56 (defvar cvs-diff-program (or (and (boundp 'diff-command) diff-command) "diff")
57 "*Name or full path of the best diff program you've got.
58 NOTE: there are some nasty bugs in the context diff variants of some vendor
59 versions, such as the one in SunOS-4.")
60
61 ;;;; END OF THINGS TO CHECK WHEN INSTALLING
62 ;;;; --------------------------------------------------------
63
64 ;;;;
65 ;;;; User configuration variables:
66 ;;;;
67 ;;;; NOTE: these should be set in your ~/.emacs (or site-lisp/default.el) file.
68 ;;;;
69
70 (defgroup pcl-cvs nil
71 "Special support for the CVS versioning system."
72 :version "21.1"
73 :group 'tools
74 :prefix "cvs-")
75
76 ;;
77 ;; cvsrc options
78 ;;
79
80 (defcustom cvs-cvsrc-file "~/.cvsrc"
81 "Path to your cvsrc file."
82 :group 'pcl-cvs
83 :type '(file))
84
85 (defvar cvs-shared-start 4
86 "Index of the first shared flag.
87 If set to 4, for instance, a numeric argument smaller than 4 will
88 select a non-shared flag, while a numeric argument greater than 3
89 will select a shared-flag.")
90
91 (defvar cvs-shared-flags (make-list cvs-shared-start nil)
92 "List of flags whose settings is shared among several commands.")
93
94 (defvar cvs-cvsroot nil
95 "*Specifies where the (current) cvs master repository is.
96 Overrides the environment variable $CVSROOT by sending \" -d dir\" to
97 all CVS commands. This switch is useful if you have multiple CVS
98 repositories. It can be set interactively with \\[cvs-change-cvsroot.]
99 There is no need to set this if $CVSROOT is set to a correct value.")
100
101 (defcustom cvs-auto-remove-handled nil
102 "If up-to-date files should be acknowledged automatically.
103 If T, they will be removed from the *cvs* buffer after every command.
104 If DELAYED, they will be removed from the *cvs* buffer before every command.
105 If STATUS, they will only be removed after a `cvs-mode-status' command.
106 Else, they will never be automatically removed from the *cvs* buffer."
107 :group 'pcl-cvs
108 :type '(choice (const nil) (const status) (const delayed) (const t)))
109
110 (defcustom cvs-auto-remove-directories 'handled
111 "If ALL, directory entries will never be shown.
112 If HANDLED, only non-handled directories will be shown.
113 If EMPTY, only non-empty directories will be shown."
114 :group 'pcl-cvs
115 :type '(choice (const :tag "No" nil) (const all) (const handled) (const empty)))
116
117 (defcustom cvs-auto-revert t
118 "Non-nil if changed files should automatically be reverted."
119 :group 'pcl-cvs
120 :type '(boolean))
121
122 (defcustom cvs-sort-ignore-file t
123 "Non-nil if `cvs-mode-ignore' should sort the .cvsignore automatically."
124 :group 'pcl-cvs
125 :type '(boolean))
126
127 (defcustom cvs-force-dir-tag t
128 "If non-nil, tagging can only be applied to directories.
129 Tagging should generally be applied a directory at a time, but sometimes it is
130 useful to be able to tag a single file. The normal way to do that is to use
131 `cvs-mode-force-command' so as to temporarily override the restrictions,"
132 :group 'pcl-cvs
133 :type '(boolean))
134
135 (defcustom cvs-default-ignore-marks nil
136 "Non-nil if cvs mode commands should ignore any marked files.
137 Normally they run on the files that are marked (with `cvs-mode-mark'),
138 or the file under the cursor if no files are marked. If this variable
139 is set to a non-nil value they will by default run on the file on the
140 current line. See also `cvs-invert-ignore-marks'"
141 :group 'pcl-cvs
142 :type '(boolean))
143
144 (defvar cvs-diff-ignore-marks t)
145 (make-obsolete-variable 'cvs-diff-ignore-marks
146 'cvs-invert-ignore-marks
147 "21.1")
148
149 (defcustom cvs-invert-ignore-marks
150 (let ((l ()))
151 (unless (equal cvs-diff-ignore-marks cvs-default-ignore-marks)
152 (push "diff" l))
153 (when (and cvs-force-dir-tag (not cvs-default-ignore-marks))
154 (push "tag" l))
155 l)
156 "List of cvs commands that invert the default ignore-mark behavior.
157 Commands in this set will use the opposite default from the one set
158 in `cvs-default-ignore-marks'."
159 :group 'pcl-cvs
160 :type '(set (const "diff")
161 (const "tag")
162 (const "ignore")))
163
164 (defcustom cvs-confirm-removals t
165 "Ask for confirmation before removing files.
166 Non-nil means that PCL-CVS will ask confirmation before removing files
167 except for files whose content can readily be recovered from the repository.
168 A value of `list' means that the list of files to be deleted will be
169 displayed when asking for confirmation."
170 :group 'pcl-cvs
171 :type '(choice (const list)
172 (const t)
173 (const nil)))
174
175 (defcustom cvs-add-default-message nil
176 "Default message to use when adding files.
177 If set to nil, `cvs-mode-add' will always prompt for a message."
178 :group 'pcl-cvs
179 :type '(choice (const :tag "Prompt" nil)
180 (string)))
181
182 (defvar cvs-diff-buffer-name "*cvs-diff*")
183 (make-obsolete-variable 'cvs-diff-buffer-name
184 'cvs-buffer-name-alist
185 "21.1")
186
187 (defcustom cvs-find-file-and-jump nil
188 "Jump to the modified area when finding a file.
189 If non-nil, `cvs-mode-file-file' will place the cursor at the beginning of
190 the modified area. If the file is not locally modified, this will obviously
191 have no effect."
192 :group 'pcl-cvs
193 :type '(boolean))
194
195 (defcustom cvs-buffer-name-alist
196 '(("diff" cvs-diff-buffer-name diff-mode)
197 ("status" "*cvs-info*" cvs-status-mode)
198 ("tree" "*cvs-info*" cvs-status-mode)
199 ("message" "*cvs-commit*" nil log-edit)
200 ("log" "*cvs-info*" log-view-mode))
201 "Buffer name and mode to be used for each command.
202 This is a list of elements of the form
203
204 (CMD BUFNAME MODE &optional POSTPROC)
205
206 CMD is the name of the command.
207 BUFNAME is an expression that should evaluate to a string used as
208 a buffer name. It can use the variable CMD if it wants to.
209 MODE is the command to use to setup the buffer.
210 POSTPROC is a function that should be executed when the command terminates
211
212 The CMD used for `cvs-mode-commit' is \"message\". For that special
213 case, POSTPROC is called just after MODE with special arguments."
214 :group 'pcl-cvs
215 :type '(repeat
216 (list (choice (const "diff")
217 (const "status")
218 (const "tree")
219 (const "message")
220 (const "log")
221 (string))
222 (choice (const "*vc-diff*")
223 (const "*cvs-info*")
224 (const "*cvs-commit*")
225 (const (expand-file-name "*cvs-commit*"))
226 (const (format "*cvs-%s*" cmd))
227 (const (expand-file-name (format "*cvs-%s*" cmd)))
228 (sexp :value "my-cvs-info-buffer")
229 (const nil))
230 (choice (function-item diff-mode)
231 (function-item cvs-edit-mode)
232 (function-item cvs-status-mode)
233 function
234 (const nil))
235 (set :inline t
236 (choice (function-item cvs-status-cvstrees)
237 (function-item cvs-status-trees)
238 function)))))
239
240 (defvar cvs-buffer-name '(expand-file-name "*cvs*" dir) ;; "*cvs*"
241 "Name of the cvs buffer.
242 This expression will be evaluated in an environment where DIR is set to
243 the directory name of the cvs buffer.")
244
245 (defvar cvs-temp-buffer-name
246 ;; Was '(expand-file-name " *cvs-tmp*" dir), but that causes them to
247 ;; become non-hidden if uniquification is done `forward'.
248 " *cvs-tmp*"
249 "*Name of the cvs temporary buffer.
250 Output from cvs is placed here for asynchronous commands.")
251
252 (defcustom cvs-idiff-imerge-handlers
253 (if (fboundp 'ediff)
254 '(cvs-ediff-diff . cvs-ediff-merge)
255 '(cvs-emerge-diff . cvs-emerge-merge))
256 "Pair of functions to be used for resp. diff'ing and merg'ing interactively."
257 :group 'pcl-cvs
258 :type '(choice (const :tag "Ediff" (cvs-ediff-diff . cvs-ediff-merge))
259 (const :tag "Emerge" (cvs-emerge-diff . cvs-emerge-merge))))
260
261 (defvar cvs-mode-hook nil
262 "Run after `cvs-mode' was setup.")
263
264 \f
265 ;;;;
266 ;;;; Internal variables, used in the process buffer.
267 ;;;;
268
269 (defvar cvs-postprocess nil
270 "(Buffer local) what to do once the process exits.")
271
272 ;;;;
273 ;;;; Internal variables for the *cvs* buffer.
274 ;;;;
275
276 (defcustom cvs-reuse-cvs-buffer 'subdir
277 "When to reuse an existing cvs buffer.
278 Alternatives are:
279 CURRENT: just reuse the current buffer if it is a cvs buffer
280 SAMEDIR: reuse any cvs buffer displaying the same directory
281 SUBDIR: or reuse any cvs buffer displaying any sub- or super- directory
282 ALWAYS: reuse any cvs buffer."
283 :group 'pcl-cvs
284 :type '(choice (const always) (const subdir) (const samedir) (const current)))
285
286 (defvar cvs-temp-buffer nil
287 "(Buffer local) The temporary buffer associated with this *cvs* buffer.")
288
289 (defvar cvs-lock-file nil
290 "Full path to a lock file that CVS is waiting for (or was waiting for).
291 This variable is buffer local and only used in the *cvs* buffer.")
292
293 (defvar cvs-lock-file-regexp "^#cvs\\.\\([trw]fl\\.[-.a-z0-9]+\\|lock\\)\\'"
294 "Regexp matching the possible names of locks in the CVS repository.")
295
296 (defconst cvs-cursor-column 22
297 "Column to position cursor in in `cvs-mode'.")
298
299 ;;;;
300 ;;;; Global internal variables
301 ;;;;
302
303 (defconst cvs-vendor-branch "1.1.1"
304 "The default branch used by CVS for vendor code.")
305
306 (easy-mmode-defmap cvs-mode-diff-map
307 '(("E" "imerge" . cvs-mode-imerge)
308 ("=" . cvs-mode-diff)
309 ("e" "idiff" . cvs-mode-idiff)
310 ("2" "other" . cvs-mode-idiff-other)
311 ("d" "diff" . cvs-mode-diff)
312 ("b" "backup" . cvs-mode-diff-backup)
313 ("h" "head" . cvs-mode-diff-head)
314 ("r" "repository" . cvs-mode-diff-repository)
315 ("y" "yesterday" . cvs-mode-diff-yesterday)
316 ("v" "vendor" . cvs-mode-diff-vendor))
317 "Keymap for diff-related operations in `cvs-mode'."
318 :name "Diff")
319 ;; This is necessary to allow correct handling of \\[cvs-mode-diff-map]
320 ;; in substitute-command-keys.
321 (fset 'cvs-mode-diff-map cvs-mode-diff-map)
322
323 (easy-mmode-defmap cvs-mode-map
324 ;;(define-prefix-command 'cvs-mode-map-diff-prefix)
325 ;;(define-prefix-command 'cvs-mode-map-control-c-prefix)
326 '(;; various
327 ;; (undo . cvs-mode-undo)
328 ("?" . cvs-help)
329 ("h" . cvs-help)
330 ("q" . cvs-bury-buffer)
331 ("z" . kill-this-buffer)
332 ("F" . cvs-mode-set-flags)
333 ;; ("\M-f" . cvs-mode-force-command)
334 ("!" . cvs-mode-force-command)
335 ("\C-c\C-c" . cvs-mode-kill-process)
336 ;; marking
337 ("m" . cvs-mode-mark)
338 ("M" . cvs-mode-mark-all-files)
339 ("S" . cvs-mode-mark-on-state)
340 ("u" . cvs-mode-unmark)
341 ("\C-?". cvs-mode-unmark-up)
342 ("%" . cvs-mode-mark-matching-files)
343 ("T" . cvs-mode-toggle-marks)
344 ("\M-\C-?" . cvs-mode-unmark-all-files)
345 ;; navigation keys
346 (" " . cvs-mode-next-line)
347 ("n" . cvs-mode-next-line)
348 ("p" . cvs-mode-previous-line)
349 ("\t" . cvs-mode-next-line)
350 ([backtab] . cvs-mode-previous-line)
351 ;; M- keys are usually those that operate on modules
352 ;;("\M-C". cvs-mode-rcs2log) ; i.e. "Create a ChangeLog"
353 ;;("\M-t". cvs-rtag)
354 ;;("\M-l". cvs-rlog)
355 ("\M-c". cvs-checkout)
356 ("\M-e". cvs-examine)
357 ("g" . cvs-mode-revert-buffer)
358 ("\M-u". cvs-update)
359 ("\M-s". cvs-status)
360 ;; diff commands
361 ("=" . cvs-mode-diff)
362 ("d" . cvs-mode-diff-map)
363 ;; keys that operate on individual files
364 ("\C-k" . cvs-mode-acknowledge)
365 ("A" . cvs-mode-add-change-log-entry-other-window)
366 ;;("B" . cvs-mode-byte-compile-files)
367 ("C" . cvs-mode-commit-setup)
368 ("O" . cvs-mode-update)
369 ("U" . cvs-mode-undo)
370 ("I" . cvs-mode-insert)
371 ("a" . cvs-mode-add)
372 ("b" . cvs-set-branch-prefix)
373 ("B" . cvs-set-secondary-branch-prefix)
374 ("c" . cvs-mode-commit)
375 ("e" . cvs-mode-examine)
376 ("f" . cvs-mode-find-file)
377 ("\C-m" . cvs-mode-find-file)
378 ("i" . cvs-mode-ignore)
379 ("l" . cvs-mode-log)
380 ("o" . cvs-mode-find-file-other-window)
381 ("r" . cvs-mode-remove)
382 ("s" . cvs-mode-status)
383 ("t" . cvs-mode-tag)
384 ("v" . cvs-mode-view-file)
385 ("x" . cvs-mode-remove-handled)
386 ;; cvstree bindings
387 ("+" . cvs-mode-tree)
388 ;; mouse bindings
389 ([mouse-2] . cvs-mode-find-file)
390 ([follow-link] . (lambda (pos)
391 (if (eq (get-char-property pos 'face) 'cvs-filename) t)))
392 ([(down-mouse-3)] . cvs-menu)
393 ;; dired-like bindings
394 ("\C-o" . cvs-mode-display-file)
395 ;; Emacs-21 toolbar
396 ;;([tool-bar item1] . (menu-item "Examine" cvs-examine :image (image :file "/usr/share/icons/xpaint.xpm" :type xpm)))
397 ;;([tool-bar item2] . (menu-item "Update" cvs-update :image (image :file "/usr/share/icons/mail1.xpm" :type xpm)))
398 )
399 "Keymap for `cvs-mode'."
400 :dense t
401 :suppress t)
402
403 (fset 'cvs-mode-map cvs-mode-map)
404
405 (easy-menu-define cvs-menu cvs-mode-map "Menu used in `cvs-mode'."
406 '("CVS"
407 ["Open file" cvs-mode-find-file t]
408 ["Open in other window" cvs-mode-find-file-other-window t]
409 ["Display in other window" cvs-mode-display-file t]
410 ["Interactive merge" cvs-mode-imerge t]
411 ("View diff"
412 ["Interactive diff" cvs-mode-idiff t]
413 ["Current diff" cvs-mode-diff t]
414 ["Diff with head" cvs-mode-diff-head t]
415 ["Diff with vendor" cvs-mode-diff-vendor t]
416 ["Diff against yesterday" cvs-mode-diff-yesterday t]
417 ["Diff with backup" cvs-mode-diff-backup t])
418 ["View log" cvs-mode-log t]
419 ["View status" cvs-mode-status t]
420 ["View tag tree" cvs-mode-tree t]
421 "----"
422 ["Insert" cvs-mode-insert]
423 ["Update" cvs-mode-update (cvs-enabledp 'update)]
424 ["Re-examine" cvs-mode-examine t]
425 ["Commit" cvs-mode-commit-setup (cvs-enabledp 'commit)]
426 ["Tag" cvs-mode-tag (cvs-enabledp (when cvs-force-dir-tag 'tag))]
427 ["Undo changes" cvs-mode-undo (cvs-enabledp 'undo)]
428 ["Add" cvs-mode-add (cvs-enabledp 'add)]
429 ["Remove" cvs-mode-remove (cvs-enabledp 'remove)]
430 ["Ignore" cvs-mode-ignore (cvs-enabledp 'ignore)]
431 ["Add ChangeLog" cvs-mode-add-change-log-entry-other-window t]
432 "----"
433 ["Mark" cvs-mode-mark t]
434 ["Mark all" cvs-mode-mark-all-files t]
435 ["Mark by regexp..." cvs-mode-mark-matching-files t]
436 ["Mark by state..." cvs-mode-mark-on-state t]
437 ["Unmark" cvs-mode-unmark t]
438 ["Unmark all" cvs-mode-unmark-all-files t]
439 ["Hide handled" cvs-mode-remove-handled t]
440 "----"
441 ["PCL-CVS Manual" (lambda () (interactive)
442 (info "(pcl-cvs)Top")) t]
443 "----"
444 ["Quit" cvs-mode-quit t]))
445
446 ;;;;
447 ;;;; CVS-Minor mode
448 ;;;;
449
450 (defcustom cvs-minor-mode-prefix "\C-xc"
451 "Prefix key for the `cvs-mode' bindings in `cvs-minor-mode'."
452 :group 'pcl-cvs)
453
454 (easy-mmode-defmap cvs-minor-mode-map
455 `((,cvs-minor-mode-prefix . cvs-mode-map)
456 ("e" . (menu-item nil cvs-mode-edit-log
457 :filter (lambda (x) (if (derived-mode-p 'log-view-mode) x)))))
458 "Keymap for `cvs-minor-mode', used in buffers related to PCL-CVS.")
459
460 (defvar cvs-buffer nil
461 "(Buffer local) The *cvs* buffer associated with this buffer.")
462 (put 'cvs-buffer 'permanent-local t)
463 ;;(make-variable-buffer-local 'cvs-buffer)
464
465 (defvar cvs-minor-wrap-function nil
466 "Function to call when switching to the *cvs* buffer.
467 Takes two arguments:
468 - a *cvs* buffer.
469 - a zero-arg function which is guaranteed not to switch buffer.
470 It is expected to call the function.")
471 ;;(make-variable-buffer-local 'cvs-minor-wrap-function)
472
473 (defvar cvs-minor-current-files)
474 ;;"Current files in a `cvs-minor-mode' buffer."
475 ;; This should stay `void' because we want to be able to tell the difference
476 ;; between an empty list and no list at all.
477
478 (defconst cvs-pcl-cvs-dirchange-re "^pcl-cvs: descending directory \\(.*\\)$")
479
480 ;;;;
481 ;;;; autoload the global menu
482 ;;;;
483
484 ;;;###autoload
485 (defvar cvs-global-menu
486 (let ((m (make-sparse-keymap "PCL-CVS")))
487 (define-key m [status]
488 '(menu-item "Directory Status" cvs-status
489 :help "A more verbose status of a workarea"))
490 (define-key m [checkout]
491 '(menu-item "Checkout Module" cvs-checkout
492 :help "Check out a module from the repository"))
493 (define-key m [update]
494 '(menu-item "Update Directory" cvs-update
495 :help "Fetch updates from the repository"))
496 (define-key m [examine]
497 '(menu-item "Examine Directory" cvs-examine
498 :help "Examine the current state of a workarea"))
499 (fset 'cvs-global-menu m)))
500
501
502 ;; cvs-1.10 and above can take file arguments in other directories
503 ;; while others need to be executed once per directory
504 (defvar cvs-execute-single-dir
505 (if (or (null cvs-version)
506 (or (>= (cdr cvs-version) 10) (> (car cvs-version) 1)))
507 ;; Supposedly some recent versions of CVS output some directory info
508 ;; as they recurse downthe tree, but it's not good enough in the case
509 ;; where we run "cvs status foo bar/foo".
510 '("status")
511 t)
512 "Whether cvs commands should be executed a directory at a time.
513 If a list, specifies for which commands the single-dir mode should be used.
514 If T, single-dir mode should be used for all operations.
515
516 CVS versions before 1.10 did not allow passing them arguments in different
517 directories, so pcl-cvs checks what version you're using to determine
518 whether to use the new feature or not.
519 Sadly, even with a new cvs executable, if you connect to an older cvs server
520 \(typically a cvs-1.9 on the server), the old restriction applies. In such
521 a case the sanity check made by pcl-cvs fails and you will have to manually
522 set this variable to t (until the cvs server is upgraded).
523 When the above problem occurs, pcl-cvs should (hopefully) catch cvs' error
524 message and replace it with a message telling you to change this variable.")
525
526 ;;
527 (provide 'pcvs-defs)
528
529 ;; arch-tag: c7c701d0-d1d4-4aa9-a302-007bb03aca5e
530 ;;; pcvs-defs.el ends here