* pcvs.el: Add a minimal leading commentary.
[emacs.git] / lisp / pcvs-defs.el
blob37aa13acc4542a09b9e3c312e7ba9921a4905da8
1 ;;; pcvs-defs.el --- variable definitions for PCL-CVS
3 ;; Copyright (C) 1991-2000 Free Software Foundation, Inc.
5 ;; Author: Stefan Monnier <monnier@cs.yale.edu>
6 ;; Keywords: pcl-cvs
7 ;; Version: $Name: $
8 ;; Revision: $Id: pcvs-defs.el,v 1.2 2000/03/15 21:28:58 gerd Exp $
10 ;; This file is part of GNU Emacs.
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 2, or (at your option)
15 ;; any later version.
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.
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., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
27 ;;; Commentary:
30 ;;; Code:
32 (defconst pcl-cvs-version "$Name: $")
34 (eval-when-compile (require 'cl))
35 (require 'pcvs-util)
37 ;;;; -------------------------------------------------------
38 ;;;; START OF THINGS TO CHECK WHEN INSTALLING
40 (defvar cvs-program "cvs"
41 "*Name or full path of the cvs executable.")
43 (defvar cvs-version
44 (ignore-errors
45 (with-temp-buffer
46 (call-process "cvs" nil t nil "-v")
47 (goto-char (point-min))
48 (when (re-search-forward "(CVS) \\([0-9]+\\)\\.\\([0-9]+\\)" nil t)
49 (cons (string-to-number (match-string 1))
50 (string-to-number (match-string 2))))))
51 "*Version of `cvs' installed on your system.
52 It must be in the (MAJOR . MINOR) format.")
54 ;; FIXME: this is only used by cvs-mode-diff-backup
55 (defvar cvs-diff-program (or (and (boundp 'diff-command) diff-command) "diff")
56 "*Name or full path of the best diff program you've got.
57 NOTE: there are some nasty bugs in the context diff variants of some vendor
58 versions, such as the one in SunOS-4.")
60 ;;;; END OF THINGS TO CHECK WHEN INSTALLING
61 ;;;; --------------------------------------------------------
63 ;;;;
64 ;;;; User configuration variables:
65 ;;;;
66 ;;;; NOTE: these should be set in your ~/.emacs (or site-lisp/default.el) file.
67 ;;;;
69 (defgroup pcl-cvs nil
70 "Special support for the CVS versioning system."
71 :group 'tools
72 :prefix "cvs-")
75 ;; cvsrc options
78 (defcustom cvs-cvsrc-file "~/.cvsrc"
79 "Path to your cvsrc file."
80 :group 'pcl-cvs
81 :type '(file))
83 (defvar cvs-shared-start 4
84 "Index of the first shared flag.
85 If set to 4, for instance, a numeric argument smaller than 4 will
86 select a non-shared flag, while a numeric argument greater than 3
87 will select a shared-flag.")
89 (defvar cvs-shared-flags (make-list cvs-shared-start nil)
90 "List of flags whose settings is shared among several commands.")
92 (defvar cvs-cvsroot nil
93 "*Specifies where the (current) cvs master repository is.
94 Overrides the environment variable $CVSROOT by sending \" -d dir\" to
95 all CVS commands. This switch is useful if you have multiple CVS
96 repositories. It can be set interactively with \\[cvs-change-cvsroot.]
97 There is no need to set this if $CVSROOT is set to a correct value.")
99 (defcustom cvs-auto-remove-handled nil
100 "*If up-to-date files should be acknowledged automatically.
101 If T, they will be removed from the *cvs* buffer after every command.
102 If DELAYED, they will be removed from the *cvs* buffer before every command.
103 If STATUS, they will only be removed after a `cvs-mode-status' command.
104 Else, they will never be automatically removed from the *cvs* buffer."
105 :group 'pcl-cvs
106 :type '(choice (const nil) (const status) (const delayed) (const t)))
108 (defcustom cvs-auto-remove-directories 'handled
109 "*If ALL, directory entries will never be shown.
110 If HANLDED, only non-handled directories will be shown.
111 If EMPTY, only non-empty directories will be shown."
112 :group 'pcl-cvs
113 :type '(choice (const :tag "No" nil) (const all) (const handled) (const empty)))
115 (defcustom cvs-auto-revert t
116 "*Non-nil if changed files should automatically be reverted."
117 :group 'pcl-cvs
118 :type '(boolean))
120 (defcustom cvs-sort-ignore-file t
121 "*Non-nil if `cvs-mode-ignore' should sort the .cvsignore automatically."
122 :group 'pcl-cvs
123 :type '(boolean))
125 (defcustom cvs-force-dir-tag t
126 "*If non-nil, tagging can only be applied to directories.
127 Tagging should generally be applied a directory at a time, but sometimes it is
128 useful to be able to tag a single file. The normal way to do that is to use
129 `cvs-mode-force-command' so as to temporarily override the restrictions,"
130 :group 'pcl-cvs
131 :type '(boolean))
133 (defcustom cvs-default-ignore-marks nil
134 "*Non-nil if cvs mode commands should ignore any marked files.
135 Normally they run on the files that are marked (with `cvs-mode-mark'),
136 or the file under the cursor if no files are marked. If this variable
137 is set to a non-nil value they will by default run on the file on the
138 current line. See also `cvs-ignore-marks'"
139 :group 'pcl-cvs
140 :type '(boolean))
142 (defvar cvs-diff-ignore-marks t
143 "Obsolete variable: use cvs-ignore-marks instead.")
145 (defcustom cvs-invert-ignore-marks
146 (let ((l ()))
147 (unless (equal cvs-diff-ignore-marks cvs-default-ignore-marks)
148 (push "diff" l))
149 (when (and cvs-force-dir-tag (not cvs-default-ignore-marks))
150 (push "tag" l))
152 "*List of cvs commands that invert the default ignore-mark behavior.
153 Commands in this set will use the opposite default from the one set
154 in `cvs-default-ignore-marks'."
155 :group 'pcl-cvs
156 :type '(set (const "diff")
157 (const "tag")
158 (const "ignore")))
160 (defcustom cvs-confirm-removals t
161 "*Ask for confirmation before removing files.
162 Non-nil means that PCL-CVS will ask confirmation before removing files
163 except for files whose content can readily be recovered from the repository.
164 A value of LIST means that the list of files to be deleted will be
165 displayed when asking for confirmation."
166 :group 'pcl-cvs
167 :type '(choice (const list)
168 (const t)
169 (const nil)))
171 (defcustom cvs-add-default-message nil
172 "*Default message to use when adding files.
173 If set to NIL, `cvs-mode-add' will always prompt for a message."
174 :group 'pcl-cvs
175 :type '(choice (const :tag "Prompt" nil)
176 (string)))
178 (defvar cvs-diff-buffer-name "*cvs-diff*"
179 "Obsolete variable: use `cvs-buffer-name-alist' instead.")
181 (defcustom cvs-find-file-and-jump t
182 "Jump to the modified area when finding a file.
183 If non-nil, `cvs-mode-file-file' will place the cursor at the beginning of
184 the modified area. If the file is not locally modified, this will obviously
185 have no effect."
186 :group 'pcl-cvs
187 :type '(boolean))
189 (defcustom cvs-buffer-name-alist
190 '(("diff" cvs-diff-buffer-name diff-mode)
191 ("status" "*cvs-info*" cvs-status-mode)
192 ("tree" (format "*cvs-%s*" cmd) cvs-status-mode)
193 ("message" "*cvs-commit*" nil log-edit)
194 ("log" "*cvs-info*" log-view-mode))
195 "*Buffer name and mode to be used for each command.
196 This is a list of elements of the form
198 (CMD BUFNAME MODE &optional POSTPROC)
200 CMD is the name of the command.
201 BUFNAME is an expression that should evaluate to a string used as
202 a buffer name. It can use the variable CMD if it wants to.
203 MODE is the command to use to setup the buffer.
204 POSTPROC is a function that should be executed when the command terminates
206 The CMD used for `cvs-mode-commit' is \"message\". For that special
207 case, POSTPROC is called just after MODE with special arguments."
208 :group 'pcl-cvs
209 :type '(repeat
210 (list (choice (const "diff")
211 (const "status")
212 (const "tree")
213 (const "message")
214 (const "log")
215 (string))
216 (choice (const "*vc-diff*")
217 (const "*cvs-info*")
218 (const "*cvs-commit*")
219 (const (expand-file-name "*cvs-commit*"))
220 (const (format "*cvs-%s*" cmd))
221 (const (expand-file-name (format "*cvs-%s*" cmd)))
222 (sexp :value "my-cvs-info-buffer")
223 (const nil))
224 (choice (function-item diff-mode)
225 (function-item cvs-edit-mode)
226 (function-item cvs-status-mode)
227 function
228 (const nil))
229 (set :inline t
230 (choice (function-item cvs-status-cvstrees)
231 (function-item cvs-status-trees)
232 function)))))
234 (defvar cvs-buffer-name '(expand-file-name "*cvs*" dir) ;; "*cvs*"
235 "Name of the cvs buffer.
236 This expression will be evaluated in an environment where DIR is set to
237 the directory name of the cvs buffer.")
239 (defvar cvs-temp-buffer-name '(expand-file-name " *cvs-tmp*" dir)
240 "*Name of the cvs temporary buffer.
241 Output from cvs is placed here for asynchronous commands.")
243 (defcustom cvs-idiff-imerge-handlers
244 (if (fboundp 'ediff)
245 '(cvs-ediff-diff . cvs-ediff-merge)
246 '(cvs-emerge-diff . cvs-emerge-merge))
247 "*Pair of functions to be used for resp. diff'ing and merg'ing interactively."
248 :group 'pcl-cvs
249 :type '(choice (const :tag "Ediff" (cvs-ediff-diff . cvs-ediff-merge))
250 (const :tag "Emerge" (cvs-emerge-diff . cvs-emerge-merge))))
252 (defvar pcl-cvs-load-hook nil
253 "Run after loading pcl-cvs.")
255 (defvar cvs-mode-hook nil
256 "Run after `cvs-mode' was setup.")
259 ;;;;
260 ;;;; Internal variables, used in the process buffer.
261 ;;;;
263 (defvar cvs-postprocess nil
264 "(Buffer local) what to do once the process exits.")
266 ;;;;
267 ;;;; Internal variables for the *cvs* buffer.
268 ;;;;
270 (defcustom cvs-reuse-cvs-buffer 'subdir
271 "When to reuse an existing cvs buffer.
272 Alternatives are:
273 CURRENT: just reuse the current buffer if it is a cvs buffer
274 SAMEDIR: reuse any cvs buffer displaying the same directory
275 SUBDIR: or reuse any cvs buffer displaying any sub- or super- directory
276 ALWAYS: reuse any cvs buffer."
277 :group 'pcl-cvs
278 :type '(choice (const always) (const subdir) (const samedir) (const current)))
280 (defvar cvs-temp-buffer nil
281 "(Buffer local) The temporary buffer associated with this *cvs* buffer.")
283 (defvar cvs-lock-file nil
284 "Full path to a lock file that CVS is waiting for (or was waiting for).
285 This variable is buffer local and only used in the *cvs* buffer.")
287 (defvar cvs-lock-file-regexp "^#cvs\\.\\([trw]fl\\.[-.a-z0-9]+\\|lock\\)\\'"
288 "Regexp matching the possible names of locks in the CVS repository.")
290 (defconst cvs-cursor-column 22
291 "Column to position cursor in in `cvs-mode'.")
293 ;;;;
294 ;;;; Global internal variables
295 ;;;;
297 (defconst cvs-vendor-branch "1.1.1"
298 "The default branch used by CVS for vendor code.")
300 (defvar cvs-menu
301 '("CVS"
302 ["Open File.." cvs-mode-find-file t]
303 [" ..Other Window" cvs-mode-find-file-other-window t]
304 ["Interactive Merge" cvs-mode-imerge t]
305 ["Interactive Diff" cvs-mode-idiff t]
306 ["View Diff" cvs-mode-diff (cvs-enabledp 'diff)]
307 ["Diff with Vendor" cvs-mode-diff-vendor t]
308 ["Diff with Backup" cvs-mode-diff-backup t]
309 ["View Log" cvs-mode-log t]
310 ["View Status" cvs-mode-status t]
311 "----"
312 ["Update" cvs-mode-update (cvs-enabledp 'update)]
313 ["Re-Examine" cvs-mode-examine t]
314 ["Commit" cvs-mode-commit-setup (cvs-enabledp 'commit)]
315 ["Undo Changes" cvs-mode-undo (cvs-enabledp 'undo)]
316 ["Add" cvs-mode-add (cvs-enabledp 'add)]
317 ["Remove" cvs-mode-remove (cvs-enabledp 'remove)]
318 ["Ignore" cvs-mode-ignore (cvs-enabledp 'ignore)]
319 ["Add ChangeLog" cvs-mode-add-change-log-entry-other-window t]
320 "----"
321 ["Mark All" cvs-mode-mark-all-files t]
322 ["Unmark All" cvs-mode-unmark-all-files t]
323 ["Hide Handled" cvs-mode-remove-handled t]
324 "----"
325 ;; ["Update Directory" cvs-update t]
326 ;; ["Examine Directory" cvs-examine t]
327 ;; ["Status Directory" cvs-status t]
328 ;; ["Checkout Module" cvs-checkout t]
329 ;; "----"
330 ["Quit" cvs-mode-quit t]
333 (easy-mmode-defmap cvs-mode-diff-map
334 '(("=" . cvs-mode-diff)
335 ("b" . cvs-mode-diff-backup)
336 ("2" . cvs-mode-idiff-other)
337 ("h" . cvs-mode-diff-head)
338 ("v" . cvs-mode-diff-vendor)
339 ("?" . cvs-mode-diff-help)
340 ("e" . cvs-mode-idiff)
341 ("E" . cvs-mode-imerge))
342 "Keymap for diff-related operations in `cvs-mode'.")
344 (easy-mmode-defmap cvs-mode-map
345 ;;(define-prefix-command 'cvs-mode-map-diff-prefix)
346 ;;(define-prefix-command 'cvs-mode-map-control-c-prefix)
347 `(;; simulate `suppress-keymap'
348 (self-insert-command . undefined)
349 (("0" "1" "2" "3" "4" "5" "6" "7" "8" "9") . digit-argument)
350 ("-" . negative-argument)
351 ;; various
352 (undo . cvs-mode-undo)
353 ("?" . cvs-help)
354 ("h" . cvs-help)
355 ("q" . cvs-bury-buffer)
356 ;;("Q" . kill-buffer)
357 ("F" . cvs-mode-set-flags)
358 ("\M-f" . cvs-mode-force-command)
359 ("\C-c\C-c" . cvs-mode-kill-process)
360 ;; marking
361 ("m" . cvs-mode-mark)
362 ("M" . cvs-mode-mark-all-files)
363 ("u" . cvs-mode-unmark)
364 ("\C-?". cvs-mode-unmark-up)
365 ("%" . cvs-mode-mark-matching-files)
366 ("T" . cvs-mode-toggle-marks)
367 ("\M-\C-?" . cvs-mode-unmark-all-files)
368 ;; navigation keys
369 (" " . cvs-mode-next-line)
370 ("n" . cvs-mode-next-line)
371 ("p" . cvs-mode-previous-line)
372 ;; M- keys are usually those that operate on modules
373 ;;("\M-C". cvs-mode-rcs2log) ; i.e. "Create a ChangeLog"
374 ;;("\M-t". cvs-rtag)
375 ;;("\M-l". cvs-rlog)
376 ("\M-c". cvs-checkout)
377 ("\M-e". cvs-examine)
378 ("g" . cvs-mode-revert-buffer)
379 ("\M-u". cvs-update)
380 ("\M-s". cvs-status)
381 ;; diff commands
382 ("=" . cvs-mode-diff)
383 ("d" . ,cvs-mode-diff-map)
384 ;; keys that operate on individual files
385 ("\C-k". cvs-mode-acknowledge)
386 ("A" . cvs-mode-add-change-log-entry-other-window)
387 ;;("B" . cvs-mode-byte-compile-files)
388 ("C" . cvs-mode-commit-setup)
389 ("O" . cvs-mode-update)
390 ("U" . cvs-mode-undo)
391 ("I" . cvs-mode-insert)
392 ("a" . cvs-mode-add)
393 ("b" . cvs-set-branch-prefix)
394 ("B" . cvs-set-secondary-branch-prefix)
395 ("c" . cvs-mode-commit)
396 ("e" . cvs-mode-examine)
397 ("f" . cvs-mode-find-file)
398 ("i" . cvs-mode-ignore)
399 ("l" . cvs-mode-log)
400 ("o" . cvs-mode-find-file-other-window)
401 ("r" . cvs-mode-remove)
402 ("s" . cvs-mode-status)
403 ("t" . cvs-mode-tag)
404 ;;("v" . cvs-mode-diff-vendor)
405 ("x" . cvs-mode-remove-handled)
406 ;; cvstree bindings
407 ("+" . cvs-mode-tree)
408 ;; mouse bindings
409 ([(down-mouse-3)] . cvs-menu)
410 ;; Emacs-21 toolbar
411 ;;([tool-bar item1] . (menu-item "Examine" cvs-examine :image (image :file "/usr/share/icons/xpaint.xpm" :type xpm)))
412 ;;([tool-bar item2] . (menu-item "Update" cvs-update :image (image :file "/usr/share/icons/mail1.xpm" :type xpm)))
414 "Keymap for `cvs-mode'."
415 :dense t)
417 (fset 'cvs-mode-map cvs-mode-map)
419 ;; add the cvs-menu to the map so it's added whenever we are in cvs-mode
420 (when (ignore-errors (require 'easymenu))
421 (easy-menu-define cvs-menu-map
422 cvs-mode-map
423 "Menu used in cvs-mode."
424 cvs-menu))
426 ;;;;
427 ;;;; CVS-Minor mode
428 ;;;;
430 (defcustom cvs-minor-mode-prefix "\C-xc"
431 "Prefix key for the `cvs-mode' bindings in `cvs-minor-mode'."
432 :group 'pcl-cvs)
434 (easy-mmode-defmap cvs-minor-mode-map
435 `((,cvs-minor-mode-prefix . cvs-mode-map))
436 "Keymap for `cvs-minor-mode', used in buffers related to pcl-cvs.")
438 (defvar cvs-buffer nil
439 "(Buffer local) The *cvs* buffer associated with this buffer.")
440 (put 'cvs-buffer 'permanent-local t)
441 ;;(make-variable-buffer-local 'cvs-buffer)
443 (defvar cvs-minor-wrap-function nil
444 "Function to call when switching to the *cvs* buffer.
445 Takes two arguments:
446 - a *cvs* buffer.
447 - a zero-arg function which is guaranteed not to switch buffer.
448 It is expected to call the function.")
449 ;;(make-variable-buffer-local 'cvs-minor-wrap-function)
451 (defvar cvs-minor-current-files)
452 ;;"Current files in a `cvs-minor-mode' buffer."
453 ;; This should stay `void' because we want to be able to tell the difference
454 ;; between an empty list and no list at all.
456 (defconst cvs-pcl-cvs-dirchange-re "^pcl-cvs: descending directory \\(.*\\)$")
458 ;;;;
459 ;;;; autoload the global menu
460 ;;;;
462 ;;;###autoload
463 (defvar cvs-global-menu
464 (let ((m (make-sparse-keymap "PCL-CVS")))
465 (define-key m [status]
466 '(menu-item "Directory Status" cvs-status
467 :help "A more verbose status of a workarea"))
468 (define-key m [checkout]
469 '(menu-item "Checkout Module" cvs-checkout
470 :help "Check out a module from the repository"))
471 (define-key m [update]
472 '(menu-item "Update Directory" cvs-update
473 :help "Fetch updates from the repository"))
474 (define-key m [examine]
475 '(menu-item "Examine Directory" cvs-examine
476 :help "Examine the current state of a workarea"))
480 ;; cvs-1.10 and above can take file arguments in other directories
481 ;; while others need to be executed once per directory
482 (defvar cvs-execute-single-dir
483 (if (and (consp cvs-version)
484 (or (>= (cdr cvs-version) 10) (> (car cvs-version) 1)))
485 '("status")
487 "Whether cvs commands should be executed a directory at a time.
488 If a list, specifies for which commands the single-dir mode should be used.
489 If T, single-dir mode should be used for all operations.
491 CVS versions before 1.10 did not allow passing them arguments in different
492 directories, so pcl-cvs checks what version you're using to determine
493 whether to use the new feature or not.
494 Sadly, even with a new cvs executable, if you connect to an older cvs server
495 \(typically a cvs-1.9 on the server), the old restriction applies. In such
496 a case the sanity check made by pcl-cvs fails and you will have to manually
497 set this variable to T (until the cvs server is upgraded).
498 When the above problem occurs, pcl-cvs should (hopefully) catch cvs' error
499 message and replace it with a message tell you to change this variable.")
502 (provide 'pcvs-defs)
504 ;;; pcl-cvs-defs.el ends here