Revert arch-tagline change
[bpt/emacs.git] / lisp / pcvs-defs.el
CommitLineData
5b467bf4
SM
1;;; pcvs-defs.el --- variable definitions for PCL-CVS
2
98337d2b 3;; Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
94d5c876 4;; 2000, 2003, 2004, 2005 Free Software Foundation, Inc.
5b467bf4
SM
5
6;; Author: Stefan Monnier <monnier@cs.yale.edu>
7;; Keywords: pcl-cvs
5b467bf4
SM
8
9;; This file is part of GNU Emacs.
10
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.
15
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.
20
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.
25
26;;; Commentary:
27
28
29;;; Code:
30
5b467bf4
SM
31(eval-when-compile (require 'cl))
32(require 'pcvs-util)
33
34;;;; -------------------------------------------------------
35;;;; START OF THINGS TO CHECK WHEN INSTALLING
36
37(defvar cvs-program "cvs"
38 "*Name or full path of the cvs executable.")
39
40(defvar cvs-version
41 (ignore-errors
42 (with-temp-buffer
6cfbaf46 43 (call-process cvs-program nil t nil "-v")
5b467bf4
SM
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.
49It must be in the (MAJOR . MINOR) format.")
50
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.
54NOTE: there are some nasty bugs in the context diff variants of some vendor
55versions, such as the one in SunOS-4.")
56
57;;;; END OF THINGS TO CHECK WHEN INSTALLING
58;;;; --------------------------------------------------------
59
60;;;;
61;;;; User configuration variables:
62;;;;
63;;;; NOTE: these should be set in your ~/.emacs (or site-lisp/default.el) file.
64;;;;
65
66(defgroup pcl-cvs nil
67 "Special support for the CVS versioning system."
f4fbc2ff 68 :version "21.1"
5b467bf4
SM
69 :group 'tools
70 :prefix "cvs-")
71
72;;
73;; cvsrc options
74;;
75
76(defcustom cvs-cvsrc-file "~/.cvsrc"
77 "Path to your cvsrc file."
78 :group 'pcl-cvs
79 :type '(file))
80
81(defvar cvs-shared-start 4
82 "Index of the first shared flag.
83If set to 4, for instance, a numeric argument smaller than 4 will
84select a non-shared flag, while a numeric argument greater than 3
85will select a shared-flag.")
86
87(defvar cvs-shared-flags (make-list cvs-shared-start nil)
88 "List of flags whose settings is shared among several commands.")
89
90(defvar cvs-cvsroot nil
91 "*Specifies where the (current) cvs master repository is.
92Overrides the environment variable $CVSROOT by sending \" -d dir\" to
93all CVS commands. This switch is useful if you have multiple CVS
94repositories. It can be set interactively with \\[cvs-change-cvsroot.]
95There is no need to set this if $CVSROOT is set to a correct value.")
96
97(defcustom cvs-auto-remove-handled nil
98 "*If up-to-date files should be acknowledged automatically.
99If T, they will be removed from the *cvs* buffer after every command.
100If DELAYED, they will be removed from the *cvs* buffer before every command.
101If STATUS, they will only be removed after a `cvs-mode-status' command.
102Else, 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)))
105
106(defcustom cvs-auto-remove-directories 'handled
107 "*If ALL, directory entries will never be shown.
7980ab49 108If HANDLED, only non-handled directories will be shown.
5b467bf4
SM
109If 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)))
112
113(defcustom cvs-auto-revert t
114 "*Non-nil if changed files should automatically be reverted."
115 :group 'pcl-cvs
116 :type '(boolean))
117
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))
122
123(defcustom cvs-force-dir-tag t
124 "*If non-nil, tagging can only be applied to directories.
125Tagging should generally be applied a directory at a time, but sometimes it is
126useful 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))
130
131(defcustom cvs-default-ignore-marks nil
132 "*Non-nil if cvs mode commands should ignore any marked files.
133Normally they run on the files that are marked (with `cvs-mode-mark'),
134or the file under the cursor if no files are marked. If this variable
135is set to a non-nil value they will by default run on the file on the
2c0ec709 136current line. See also `cvs-invert-ignore-marks'"
5b467bf4
SM
137 :group 'pcl-cvs
138 :type '(boolean))
139
17874c4e
JB
140(defvar cvs-diff-ignore-marks t)
141(make-obsolete-variable 'cvs-diff-ignore-marks
142 'cvs-invert-ignore-marks)
5b467bf4
SM
143
144(defcustom cvs-invert-ignore-marks
145 (let ((l ()))
146 (unless (equal cvs-diff-ignore-marks cvs-default-ignore-marks)
147 (push "diff" l))
148 (when (and cvs-force-dir-tag (not cvs-default-ignore-marks))
149 (push "tag" l))
150 l)
151 "*List of cvs commands that invert the default ignore-mark behavior.
152Commands in this set will use the opposite default from the one set
153in `cvs-default-ignore-marks'."
154 :group 'pcl-cvs
155 :type '(set (const "diff")
156 (const "tag")
157 (const "ignore")))
158
159(defcustom cvs-confirm-removals t
160 "*Ask for confirmation before removing files.
161Non-nil means that PCL-CVS will ask confirmation before removing files
162except for files whose content can readily be recovered from the repository.
138e1bd0 163A value of `list' means that the list of files to be deleted will be
5b467bf4
SM
164displayed when asking for confirmation."
165 :group 'pcl-cvs
166 :type '(choice (const list)
167 (const t)
168 (const nil)))
169
170(defcustom cvs-add-default-message nil
171 "*Default message to use when adding files.
0ff9b955 172If set to nil, `cvs-mode-add' will always prompt for a message."
5b467bf4
SM
173 :group 'pcl-cvs
174 :type '(choice (const :tag "Prompt" nil)
175 (string)))
176
17874c4e
JB
177(defvar cvs-diff-buffer-name "*cvs-diff*")
178(make-obsolete-variable 'cvs-diff-buffer-name
179 'cvs-buffer-name-alist)
5b467bf4 180
2c0ec709 181(defcustom cvs-find-file-and-jump nil
5b467bf4
SM
182 "Jump to the modified area when finding a file.
183If non-nil, `cvs-mode-file-file' will place the cursor at the beginning of
184the modified area. If the file is not locally modified, this will obviously
185have no effect."
186 :group 'pcl-cvs
187 :type '(boolean))
188
189(defcustom cvs-buffer-name-alist
190 '(("diff" cvs-diff-buffer-name diff-mode)
191 ("status" "*cvs-info*" cvs-status-mode)
619d6bfc 192 ("tree" "*cvs-info*" cvs-status-mode)
5b467bf4
SM
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.
196This is a list of elements of the form
197
198 (CMD BUFNAME MODE &optional POSTPROC)
199
200CMD is the name of the command.
201BUFNAME 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.
203MODE is the command to use to setup the buffer.
204POSTPROC is a function that should be executed when the command terminates
205
206The 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)))))
233
234(defvar cvs-buffer-name '(expand-file-name "*cvs*" dir) ;; "*cvs*"
235 "Name of the cvs buffer.
236This expression will be evaluated in an environment where DIR is set to
237the directory name of the cvs buffer.")
238
239(defvar cvs-temp-buffer-name '(expand-file-name " *cvs-tmp*" dir)
240 "*Name of the cvs temporary buffer.
241Output from cvs is placed here for asynchronous commands.")
242
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))))
251
5b467bf4
SM
252(defvar cvs-mode-hook nil
253 "Run after `cvs-mode' was setup.")
254
255\f
256;;;;
257;;;; Internal variables, used in the process buffer.
258;;;;
259
260(defvar cvs-postprocess nil
261 "(Buffer local) what to do once the process exits.")
262
263;;;;
264;;;; Internal variables for the *cvs* buffer.
265;;;;
266
267(defcustom cvs-reuse-cvs-buffer 'subdir
268 "When to reuse an existing cvs buffer.
269Alternatives are:
270 CURRENT: just reuse the current buffer if it is a cvs buffer
271 SAMEDIR: reuse any cvs buffer displaying the same directory
272 SUBDIR: or reuse any cvs buffer displaying any sub- or super- directory
273 ALWAYS: reuse any cvs buffer."
274 :group 'pcl-cvs
275 :type '(choice (const always) (const subdir) (const samedir) (const current)))
276
277(defvar cvs-temp-buffer nil
278 "(Buffer local) The temporary buffer associated with this *cvs* buffer.")
279
280(defvar cvs-lock-file nil
281 "Full path to a lock file that CVS is waiting for (or was waiting for).
282This variable is buffer local and only used in the *cvs* buffer.")
283
284(defvar cvs-lock-file-regexp "^#cvs\\.\\([trw]fl\\.[-.a-z0-9]+\\|lock\\)\\'"
285 "Regexp matching the possible names of locks in the CVS repository.")
286
287(defconst cvs-cursor-column 22
288 "Column to position cursor in in `cvs-mode'.")
289
290;;;;
291;;;; Global internal variables
292;;;;
293
5b467bf4
SM
294(defconst cvs-vendor-branch "1.1.1"
295 "The default branch used by CVS for vendor code.")
296
5b467bf4 297(easy-mmode-defmap cvs-mode-diff-map
4f5a9d2b
SM
298 '(("E" "imerge" . cvs-mode-imerge)
299 ("=" . cvs-mode-diff)
300 ("e" "idiff" . cvs-mode-idiff)
301 ("2" "other" . cvs-mode-idiff-other)
302 ("d" "diff" . cvs-mode-diff)
303 ("b" "backup" . cvs-mode-diff-backup)
304 ("h" "head" . cvs-mode-diff-head)
a4bdfaf9 305 ("r" "repository" . cvs-mode-diff-repository)
34ffe043 306 ("y" "yesterday" . cvs-mode-diff-yesterday)
4f5a9d2b
SM
307 ("v" "vendor" . cvs-mode-diff-vendor))
308 "Keymap for diff-related operations in `cvs-mode'."
309 :name "Diff")
ef55aa6c 310;; This is necessary to allow correct handling of \\[cvs-mode-diff-map]
2c0ec709
SM
311;; in substitute-command-keys.
312(fset 'cvs-mode-diff-map cvs-mode-diff-map)
5b467bf4
SM
313
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)
fa443ddf 317 '(;; simulate `suppress-keymap'
5b467bf4
SM
318 (self-insert-command . undefined)
319 (("0" "1" "2" "3" "4" "5" "6" "7" "8" "9") . digit-argument)
320 ("-" . negative-argument)
321 ;; various
fa443ddf 322 ;; (undo . cvs-mode-undo)
5b467bf4
SM
323 ("?" . cvs-help)
324 ("h" . cvs-help)
325 ("q" . cvs-bury-buffer)
ef55aa6c 326 ("z" . kill-this-buffer)
5b467bf4 327 ("F" . cvs-mode-set-flags)
213a58ae 328 ;; ("\M-f" . cvs-mode-force-command)
7980ab49 329 ("!" . cvs-mode-force-command)
5b467bf4
SM
330 ("\C-c\C-c" . cvs-mode-kill-process)
331 ;; marking
332 ("m" . cvs-mode-mark)
333 ("M" . cvs-mode-mark-all-files)
28037ecf 334 ("S" . cvs-mode-mark-on-state)
5b467bf4
SM
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)
2c0ec709 355 ("d" . cvs-mode-diff-map)
5b467bf4 356 ;; keys that operate on individual files
02f7be41 357 ("\C-k" . cvs-mode-acknowledge)
5b467bf4
SM
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)
02f7be41 370 ("\C-m" . cvs-mode-find-file)
5b467bf4
SM
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)
9d2475ef 377 ("v" . cvs-mode-view-file)
5b467bf4
SM
378 ("x" . cvs-mode-remove-handled)
379 ;; cvstree bindings
380 ("+" . cvs-mode-tree)
381 ;; mouse bindings
2c0ec709 382 ([mouse-2] . cvs-mode-find-file)
d086b1a2 383 ([follow-link] . (lambda (pos)
94d5c876 384 (if (eq (get-char-property pos 'face) 'cvs-filename) t)))
5b467bf4 385 ([(down-mouse-3)] . cvs-menu)
28037ecf
SM
386 ;; dired-like bindings
387 ("\C-o" . cvs-mode-display-file)
5b467bf4
SM
388 ;; Emacs-21 toolbar
389 ;;([tool-bar item1] . (menu-item "Examine" cvs-examine :image (image :file "/usr/share/icons/xpaint.xpm" :type xpm)))
390 ;;([tool-bar item2] . (menu-item "Update" cvs-update :image (image :file "/usr/share/icons/mail1.xpm" :type xpm)))
391 )
392 "Keymap for `cvs-mode'."
393 :dense t)
394
395(fset 'cvs-mode-map cvs-mode-map)
396
8e41e2e5
SM
397(easy-menu-define cvs-menu cvs-mode-map "Menu used in `cvs-mode'."
398 '("CVS"
399 ["Open file.." cvs-mode-find-file t]
400 [" ..other window" cvs-mode-find-file-other-window t]
28037ecf 401 ["Display in other window" cvs-mode-display-file t]
8e41e2e5
SM
402 ["Interactive merge" cvs-mode-imerge t]
403 ("View diff"
404 ["Interactive diff" cvs-mode-idiff t]
405 ["Current diff" cvs-mode-diff t]
406 ["Diff with head" cvs-mode-diff-head t]
407 ["Diff with vendor" cvs-mode-diff-vendor t]
408 ["Diff with backup" cvs-mode-diff-backup t])
409 ["View log" cvs-mode-log t]
410 ["View status" cvs-mode-status t]
411 ["View tag tree" cvs-mode-tree t]
412 "----"
413 ["Insert" cvs-mode-insert]
414 ["Update" cvs-mode-update (cvs-enabledp 'update)]
415 ["Re-examine" cvs-mode-examine t]
416 ["Commit" cvs-mode-commit-setup (cvs-enabledp 'commit)]
5fe50228 417 ["Tag" cvs-mode-tag (cvs-enabledp (when cvs-force-dir-tag 'tag))]
8e41e2e5
SM
418 ["Undo changes" cvs-mode-undo (cvs-enabledp 'undo)]
419 ["Add" cvs-mode-add (cvs-enabledp 'add)]
420 ["Remove" cvs-mode-remove (cvs-enabledp 'remove)]
421 ["Ignore" cvs-mode-ignore (cvs-enabledp 'ignore)]
422 ["Add ChangeLog" cvs-mode-add-change-log-entry-other-window t]
423 "----"
424 ["Mark all" cvs-mode-mark-all-files t]
28037ecf
SM
425 ["Mark by regexp..." cvs-mode-mark-matching-files t]
426 ["Mark by state..." cvs-mode-mark-on-state t]
8e41e2e5
SM
427 ["Unmark all" cvs-mode-unmark-all-files t]
428 ["Hide handled" cvs-mode-remove-handled t]
429 "----"
430 ["Quit" cvs-mode-quit t]))
5b467bf4 431
ef55aa6c 432;;;;
5b467bf4 433;;;; CVS-Minor mode
ef55aa6c 434;;;;
5b467bf4
SM
435
436(defcustom cvs-minor-mode-prefix "\C-xc"
437 "Prefix key for the `cvs-mode' bindings in `cvs-minor-mode'."
438 :group 'pcl-cvs)
439
440(easy-mmode-defmap cvs-minor-mode-map
213a58ae
SM
441 `((,cvs-minor-mode-prefix . cvs-mode-map)
442 ("e" . (menu-item nil cvs-mode-edit-log
443 :filter (lambda (x) (if (derived-mode-p 'log-view-mode) x)))))
4f5a9d2b 444 "Keymap for `cvs-minor-mode', used in buffers related to PCL-CVS.")
5b467bf4
SM
445
446(defvar cvs-buffer nil
447 "(Buffer local) The *cvs* buffer associated with this buffer.")
448(put 'cvs-buffer 'permanent-local t)
449;;(make-variable-buffer-local 'cvs-buffer)
450
451(defvar cvs-minor-wrap-function nil
452 "Function to call when switching to the *cvs* buffer.
453Takes two arguments:
454- a *cvs* buffer.
455- a zero-arg function which is guaranteed not to switch buffer.
456It is expected to call the function.")
457;;(make-variable-buffer-local 'cvs-minor-wrap-function)
458
459(defvar cvs-minor-current-files)
460;;"Current files in a `cvs-minor-mode' buffer."
461;; This should stay `void' because we want to be able to tell the difference
462;; between an empty list and no list at all.
463
464(defconst cvs-pcl-cvs-dirchange-re "^pcl-cvs: descending directory \\(.*\\)$")
465
ef55aa6c 466;;;;
cb3430a1 467;;;; autoload the global menu
ef55aa6c 468;;;;
5b467bf4 469
cb3430a1
SM
470;;;###autoload
471(defvar cvs-global-menu
472 (let ((m (make-sparse-keymap "PCL-CVS")))
473 (define-key m [status]
474 '(menu-item "Directory Status" cvs-status
475 :help "A more verbose status of a workarea"))
476 (define-key m [checkout]
477 '(menu-item "Checkout Module" cvs-checkout
478 :help "Check out a module from the repository"))
479 (define-key m [update]
480 '(menu-item "Update Directory" cvs-update
481 :help "Fetch updates from the repository"))
482 (define-key m [examine]
483 '(menu-item "Examine Directory" cvs-examine
484 :help "Examine the current state of a workarea"))
648a3c0c 485 (fset 'cvs-global-menu m)))
5b467bf4
SM
486
487
488;; cvs-1.10 and above can take file arguments in other directories
489;; while others need to be executed once per directory
490(defvar cvs-execute-single-dir
491 (if (and (consp cvs-version)
492 (or (>= (cdr cvs-version) 10) (> (car cvs-version) 1)))
493 '("status")
494 t)
495 "Whether cvs commands should be executed a directory at a time.
496If a list, specifies for which commands the single-dir mode should be used.
497If T, single-dir mode should be used for all operations.
498
499CVS versions before 1.10 did not allow passing them arguments in different
500directories, so pcl-cvs checks what version you're using to determine
501whether to use the new feature or not.
502Sadly, even with a new cvs executable, if you connect to an older cvs server
503\(typically a cvs-1.9 on the server), the old restriction applies. In such
504a case the sanity check made by pcl-cvs fails and you will have to manually
0ff9b955 505set this variable to t (until the cvs server is upgraded).
5b467bf4
SM
506When the above problem occurs, pcl-cvs should (hopefully) catch cvs' error
507message and replace it with a message tell you to change this variable.")
508
509;;
510(provide 'pcvs-defs)
511
98337d2b 512;; arch-tag: c7c701d0-d1d4-4aa9-a302-007bb03aca5e
3afbc435 513;;; pcvs-defs.el ends here