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