Remove CVS merge cookie left in.
[emacs.git] / lisp / pcvs-defs.el
blob51262372a331a4c41b080c653e5770e970c8f254
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.4 2000/06/11 22:35:19 monnier 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 :version "21.1"
72 :group 'tools
73 :prefix "cvs-")
76 ;; cvsrc options
79 (defcustom cvs-cvsrc-file "~/.cvsrc"
80 "Path to your cvsrc file."
81 :group 'pcl-cvs
82 :type '(file))
84 (defvar cvs-shared-start 4
85 "Index of the first shared flag.
86 If set to 4, for instance, a numeric argument smaller than 4 will
87 select a non-shared flag, while a numeric argument greater than 3
88 will select a shared-flag.")
90 (defvar cvs-shared-flags (make-list cvs-shared-start nil)
91 "List of flags whose settings is shared among several commands.")
93 (defvar cvs-cvsroot nil
94 "*Specifies where the (current) cvs master repository is.
95 Overrides the environment variable $CVSROOT by sending \" -d dir\" to
96 all CVS commands. This switch is useful if you have multiple CVS
97 repositories. It can be set interactively with \\[cvs-change-cvsroot.]
98 There is no need to set this if $CVSROOT is set to a correct value.")
100 (defcustom cvs-auto-remove-handled nil
101 "*If up-to-date files should be acknowledged automatically.
102 If T, they will be removed from the *cvs* buffer after every command.
103 If DELAYED, they will be removed from the *cvs* buffer before every command.
104 If STATUS, they will only be removed after a `cvs-mode-status' command.
105 Else, they will never be automatically removed from the *cvs* buffer."
106 :group 'pcl-cvs
107 :type '(choice (const nil) (const status) (const delayed) (const t)))
109 (defcustom cvs-auto-remove-directories 'handled
110 "*If ALL, directory entries will never be shown.
111 If HANLDED, only non-handled directories will be shown.
112 If EMPTY, only non-empty directories will be shown."
113 :group 'pcl-cvs
114 :type '(choice (const :tag "No" nil) (const all) (const handled) (const empty)))
116 (defcustom cvs-auto-revert t
117 "*Non-nil if changed files should automatically be reverted."
118 :group 'pcl-cvs
119 :type '(boolean))
121 (defcustom cvs-sort-ignore-file t
122 "*Non-nil if `cvs-mode-ignore' should sort the .cvsignore automatically."
123 :group 'pcl-cvs
124 :type '(boolean))
126 (defcustom cvs-force-dir-tag t
127 "*If non-nil, tagging can only be applied to directories.
128 Tagging should generally be applied a directory at a time, but sometimes it is
129 useful to be able to tag a single file. The normal way to do that is to use
130 `cvs-mode-force-command' so as to temporarily override the restrictions,"
131 :group 'pcl-cvs
132 :type '(boolean))
134 (defcustom cvs-default-ignore-marks nil
135 "*Non-nil if cvs mode commands should ignore any marked files.
136 Normally they run on the files that are marked (with `cvs-mode-mark'),
137 or the file under the cursor if no files are marked. If this variable
138 is set to a non-nil value they will by default run on the file on the
139 current line. See also `cvs-invert-ignore-marks'"
140 :group 'pcl-cvs
141 :type '(boolean))
143 (defvar cvs-diff-ignore-marks t
144 "Obsolete: use `cvs-invert-ignore-marks' instead.")
146 (defcustom cvs-invert-ignore-marks
147 (let ((l ()))
148 (unless (equal cvs-diff-ignore-marks cvs-default-ignore-marks)
149 (push "diff" l))
150 (when (and cvs-force-dir-tag (not cvs-default-ignore-marks))
151 (push "tag" l))
153 "*List of cvs commands that invert the default ignore-mark behavior.
154 Commands in this set will use the opposite default from the one set
155 in `cvs-default-ignore-marks'."
156 :group 'pcl-cvs
157 :type '(set (const "diff")
158 (const "tag")
159 (const "ignore")))
161 (defcustom cvs-confirm-removals t
162 "*Ask for confirmation before removing files.
163 Non-nil means that PCL-CVS will ask confirmation before removing files
164 except for files whose content can readily be recovered from the repository.
165 A value of LIST means that the list of files to be deleted will be
166 displayed when asking for confirmation."
167 :group 'pcl-cvs
168 :type '(choice (const list)
169 (const t)
170 (const nil)))
172 (defcustom cvs-add-default-message nil
173 "*Default message to use when adding files.
174 If set to NIL, `cvs-mode-add' will always prompt for a message."
175 :group 'pcl-cvs
176 :type '(choice (const :tag "Prompt" nil)
177 (string)))
179 (defvar cvs-diff-buffer-name "*cvs-diff*"
180 "Obsolete variable: use `cvs-buffer-name-alist' instead.")
182 (defcustom cvs-find-file-and-jump nil
183 "Jump to the modified area when finding a file.
184 If non-nil, `cvs-mode-file-file' will place the cursor at the beginning of
185 the modified area. If the file is not locally modified, this will obviously
186 have no effect."
187 :group 'pcl-cvs
188 :type '(boolean))
190 (defcustom cvs-buffer-name-alist
191 '(("diff" cvs-diff-buffer-name diff-mode)
192 ("status" "*cvs-info*" cvs-status-mode)
193 ("tree" (format "*cvs-%s*" cmd) cvs-status-mode)
194 ("message" "*cvs-commit*" nil log-edit)
195 ("log" "*cvs-info*" log-view-mode))
196 "*Buffer name and mode to be used for each command.
197 This is a list of elements of the form
199 (CMD BUFNAME MODE &optional POSTPROC)
201 CMD is the name of the command.
202 BUFNAME is an expression that should evaluate to a string used as
203 a buffer name. It can use the variable CMD if it wants to.
204 MODE is the command to use to setup the buffer.
205 POSTPROC is a function that should be executed when the command terminates
207 The CMD used for `cvs-mode-commit' is \"message\". For that special
208 case, POSTPROC is called just after MODE with special arguments."
209 :group 'pcl-cvs
210 :type '(repeat
211 (list (choice (const "diff")
212 (const "status")
213 (const "tree")
214 (const "message")
215 (const "log")
216 (string))
217 (choice (const "*vc-diff*")
218 (const "*cvs-info*")
219 (const "*cvs-commit*")
220 (const (expand-file-name "*cvs-commit*"))
221 (const (format "*cvs-%s*" cmd))
222 (const (expand-file-name (format "*cvs-%s*" cmd)))
223 (sexp :value "my-cvs-info-buffer")
224 (const nil))
225 (choice (function-item diff-mode)
226 (function-item cvs-edit-mode)
227 (function-item cvs-status-mode)
228 function
229 (const nil))
230 (set :inline t
231 (choice (function-item cvs-status-cvstrees)
232 (function-item cvs-status-trees)
233 function)))))
235 (defvar cvs-buffer-name '(expand-file-name "*cvs*" dir) ;; "*cvs*"
236 "Name of the cvs buffer.
237 This expression will be evaluated in an environment where DIR is set to
238 the directory name of the cvs buffer.")
240 (defvar cvs-temp-buffer-name '(expand-file-name " *cvs-tmp*" dir)
241 "*Name of the cvs temporary buffer.
242 Output from cvs is placed here for asynchronous commands.")
244 (defcustom cvs-idiff-imerge-handlers
245 (if (fboundp 'ediff)
246 '(cvs-ediff-diff . cvs-ediff-merge)
247 '(cvs-emerge-diff . cvs-emerge-merge))
248 "*Pair of functions to be used for resp. diff'ing and merg'ing interactively."
249 :group 'pcl-cvs
250 :type '(choice (const :tag "Ediff" (cvs-ediff-diff . cvs-ediff-merge))
251 (const :tag "Emerge" (cvs-emerge-diff . cvs-emerge-merge))))
253 (defvar pcl-cvs-load-hook nil
254 "Run after loading pcl-cvs.")
256 (defvar cvs-mode-hook nil
257 "Run after `cvs-mode' was setup.")
260 ;;;;
261 ;;;; Internal variables, used in the process buffer.
262 ;;;;
264 (defvar cvs-postprocess nil
265 "(Buffer local) what to do once the process exits.")
267 ;;;;
268 ;;;; Internal variables for the *cvs* buffer.
269 ;;;;
271 (defcustom cvs-reuse-cvs-buffer 'subdir
272 "When to reuse an existing cvs buffer.
273 Alternatives are:
274 CURRENT: just reuse the current buffer if it is a cvs buffer
275 SAMEDIR: reuse any cvs buffer displaying the same directory
276 SUBDIR: or reuse any cvs buffer displaying any sub- or super- directory
277 ALWAYS: reuse any cvs buffer."
278 :group 'pcl-cvs
279 :type '(choice (const always) (const subdir) (const samedir) (const current)))
281 (defvar cvs-temp-buffer nil
282 "(Buffer local) The temporary buffer associated with this *cvs* buffer.")
284 (defvar cvs-lock-file nil
285 "Full path to a lock file that CVS is waiting for (or was waiting for).
286 This variable is buffer local and only used in the *cvs* buffer.")
288 (defvar cvs-lock-file-regexp "^#cvs\\.\\([trw]fl\\.[-.a-z0-9]+\\|lock\\)\\'"
289 "Regexp matching the possible names of locks in the CVS repository.")
291 (defconst cvs-cursor-column 22
292 "Column to position cursor in in `cvs-mode'.")
294 ;;;;
295 ;;;; Global internal variables
296 ;;;;
298 (defconst cvs-vendor-branch "1.1.1"
299 "The default branch used by CVS for vendor code.")
301 (defvar cvs-menu
302 '("CVS"
303 ["Open File.." cvs-mode-find-file t]
304 [" ..Other Window" cvs-mode-find-file-other-window t]
305 ["Interactive Merge" cvs-mode-imerge t]
306 ["Interactive Diff" cvs-mode-idiff t]
307 ["View Diff" cvs-mode-diff (cvs-enabledp 'diff)]
308 ["Diff with Vendor" cvs-mode-diff-vendor t]
309 ["Diff with Backup" cvs-mode-diff-backup t]
310 ["View Log" cvs-mode-log t]
311 ["View Status" cvs-mode-status t]
312 "----"
313 ["Update" cvs-mode-update (cvs-enabledp 'update)]
314 ["Re-Examine" cvs-mode-examine t]
315 ["Commit" cvs-mode-commit-setup (cvs-enabledp 'commit)]
316 ["Undo Changes" cvs-mode-undo (cvs-enabledp 'undo)]
317 ["Add" cvs-mode-add (cvs-enabledp 'add)]
318 ["Remove" cvs-mode-remove (cvs-enabledp 'remove)]
319 ["Ignore" cvs-mode-ignore (cvs-enabledp 'ignore)]
320 ["Add ChangeLog" cvs-mode-add-change-log-entry-other-window t]
321 "----"
322 ["Mark All" cvs-mode-mark-all-files t]
323 ["Unmark All" cvs-mode-unmark-all-files t]
324 ["Hide Handled" cvs-mode-remove-handled t]
325 "----"
326 ;; ["Update Directory" cvs-update t]
327 ;; ["Examine Directory" cvs-examine t]
328 ;; ["Status Directory" cvs-status t]
329 ;; ["Checkout Module" cvs-checkout t]
330 ;; "----"
331 ["Quit" cvs-mode-quit t]
334 (easy-mmode-defmap cvs-mode-diff-map
335 '(("=" . cvs-mode-diff)
336 ("b" . cvs-mode-diff-backup)
337 ("2" . cvs-mode-idiff-other)
338 ("h" . cvs-mode-diff-head)
339 ("v" . cvs-mode-diff-vendor)
340 ("?" . cvs-mode-diff-help)
341 ("e" . cvs-mode-idiff)
342 ("E" . cvs-mode-imerge))
343 "Keymap for diff-related operations in `cvs-mode'.")
344 ;; This is necessary to allow correct handling of \\[cvs-mode-diff-map]
345 ;; in substitute-command-keys.
346 (fset 'cvs-mode-diff-map cvs-mode-diff-map)
348 (easy-mmode-defmap cvs-mode-map
349 ;;(define-prefix-command 'cvs-mode-map-diff-prefix)
350 ;;(define-prefix-command 'cvs-mode-map-control-c-prefix)
351 `(;; simulate `suppress-keymap'
352 (self-insert-command . undefined)
353 (("0" "1" "2" "3" "4" "5" "6" "7" "8" "9") . digit-argument)
354 ("-" . negative-argument)
355 ;; various
356 (undo . cvs-mode-undo)
357 ("?" . cvs-help)
358 ("h" . cvs-help)
359 ("q" . cvs-bury-buffer)
360 ;;("Q" . kill-buffer)
361 ("F" . cvs-mode-set-flags)
362 ("\M-f" . cvs-mode-force-command)
363 ("\C-c\C-c" . cvs-mode-kill-process)
364 ;; marking
365 ("m" . cvs-mode-mark)
366 ("M" . cvs-mode-mark-all-files)
367 ("u" . cvs-mode-unmark)
368 ("\C-?". cvs-mode-unmark-up)
369 ("%" . cvs-mode-mark-matching-files)
370 ("T" . cvs-mode-toggle-marks)
371 ("\M-\C-?" . cvs-mode-unmark-all-files)
372 ;; navigation keys
373 (" " . cvs-mode-next-line)
374 ("n" . cvs-mode-next-line)
375 ("p" . cvs-mode-previous-line)
376 ;; M- keys are usually those that operate on modules
377 ;;("\M-C". cvs-mode-rcs2log) ; i.e. "Create a ChangeLog"
378 ;;("\M-t". cvs-rtag)
379 ;;("\M-l". cvs-rlog)
380 ("\M-c". cvs-checkout)
381 ("\M-e". cvs-examine)
382 ("g" . cvs-mode-revert-buffer)
383 ("\M-u". cvs-update)
384 ("\M-s". cvs-status)
385 ;; diff commands
386 ("=" . cvs-mode-diff)
387 ("d" . cvs-mode-diff-map)
388 ;; keys that operate on individual files
389 ("\C-k". cvs-mode-acknowledge)
390 ("A" . cvs-mode-add-change-log-entry-other-window)
391 ;;("B" . cvs-mode-byte-compile-files)
392 ("C" . cvs-mode-commit-setup)
393 ("O" . cvs-mode-update)
394 ("U" . cvs-mode-undo)
395 ("I" . cvs-mode-insert)
396 ("a" . cvs-mode-add)
397 ("b" . cvs-set-branch-prefix)
398 ("B" . cvs-set-secondary-branch-prefix)
399 ("c" . cvs-mode-commit)
400 ("e" . cvs-mode-examine)
401 ("f" . cvs-mode-find-file)
402 ("i" . cvs-mode-ignore)
403 ("l" . cvs-mode-log)
404 ("o" . cvs-mode-find-file-other-window)
405 ("r" . cvs-mode-remove)
406 ("s" . cvs-mode-status)
407 ("t" . cvs-mode-tag)
408 ;;("v" . cvs-mode-diff-vendor)
409 ("x" . cvs-mode-remove-handled)
410 ;; cvstree bindings
411 ("+" . cvs-mode-tree)
412 ;; mouse bindings
413 ([mouse-2] . cvs-mode-find-file)
414 ([(down-mouse-3)] . cvs-menu)
415 ;; Emacs-21 toolbar
416 ;;([tool-bar item1] . (menu-item "Examine" cvs-examine :image (image :file "/usr/share/icons/xpaint.xpm" :type xpm)))
417 ;;([tool-bar item2] . (menu-item "Update" cvs-update :image (image :file "/usr/share/icons/mail1.xpm" :type xpm)))
419 "Keymap for `cvs-mode'."
420 :dense t)
422 (fset 'cvs-mode-map cvs-mode-map)
424 ;; add the cvs-menu to the map so it's added whenever we are in cvs-mode
425 (when (ignore-errors (require 'easymenu))
426 (easy-menu-define cvs-menu-map
427 cvs-mode-map
428 "Menu used in cvs-mode."
429 cvs-menu))
431 ;;;;
432 ;;;; CVS-Minor mode
433 ;;;;
435 (defcustom cvs-minor-mode-prefix "\C-xc"
436 "Prefix key for the `cvs-mode' bindings in `cvs-minor-mode'."
437 :group 'pcl-cvs)
439 (easy-mmode-defmap cvs-minor-mode-map
440 `((,cvs-minor-mode-prefix . cvs-mode-map))
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 ;;; pcl-cvs-defs.el ends here