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