1 ;;; pcvs-defs.el --- variable definitions for PCL-CVS
3 ;; Copyright (C) 1991-2014 Free Software Foundation, Inc.
5 ;; Author: Stefan Monnier <monnier@iro.umontreal.ca>
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 3 of the License, or
14 ;; (at your option) 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. If not, see <http://www.gnu.org/licenses/>.
31 ;;;; -------------------------------------------------------
32 ;;;; START OF THINGS TO CHECK WHEN INSTALLING
34 (defvar cvs-program
"cvs"
35 "Name or full path of the cvs executable.")
38 ;; With the divergence of the CVSNT codebase and version numbers, this is
39 ;; not really good any more.
42 (call-process cvs-program nil t nil
"-v")
43 (goto-char (point-min))
44 (when (re-search-forward "(CVS\\(NT\\)?) \\([0-9]+\\)\\.\\([0-9]+\\)"
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 ;;;; User configuration variables:
63 "Special support for the CVS versioning system."
72 (defcustom cvs-cvsrc-file
(convert-standard-filename "~/.cvsrc")
73 "Path to your cvsrc file."
77 (defvar cvs-shared-start
4
78 "Index of the first shared flag.
79 If set to 4, for instance, a numeric argument smaller than 4 will
80 select a non-shared flag, while a numeric argument greater than 3
81 will select a shared-flag.")
83 (defvar cvs-shared-flags
(make-list cvs-shared-start nil
)
84 "List of flags whose settings is shared among several commands.")
86 (defvar cvs-cvsroot nil
87 "Specifies where the (current) cvs master repository is.
88 Overrides the environment variable $CVSROOT by sending \" -d dir\" to
89 all CVS commands. This switch is useful if you have multiple CVS
90 repositories. It can be set interactively with \\[cvs-change-cvsroot.]
91 There is no need to set this if $CVSROOT is set to a correct value.")
93 (defcustom cvs-auto-remove-handled nil
94 "If up-to-date files should be acknowledged automatically.
95 If t, they will be removed from the *cvs* buffer after every command.
96 If `delayed', they will be removed from the *cvs* buffer before every command.
97 If `status', they will only be removed after a `cvs-mode-status' command.
98 Else, they will never be automatically removed from the *cvs* buffer."
100 :type
'(choice (const nil
) (const status
) (const delayed
) (const t
)))
102 (defcustom cvs-auto-remove-directories
'handled
103 "If `all', directory entries will never be shown.
104 If `handled', only non-handled directories will be shown.
105 If `empty', only non-empty directories will be shown."
107 :type
'(choice (const :tag
"No" nil
) (const all
) (const handled
) (const empty
)))
109 (defcustom cvs-auto-revert t
110 "Non-nil if changed files should automatically be reverted."
114 (defcustom cvs-sort-ignore-file t
115 "Non-nil if `cvs-mode-ignore' should sort the .cvsignore automatically."
119 (defcustom cvs-force-dir-tag t
120 "If non-nil, tagging can only be applied to directories.
121 Tagging should generally be applied a directory at a time, but sometimes it is
122 useful to be able to tag a single file. The normal way to do that is to use
123 `cvs-mode-force-command' so as to temporarily override the restrictions,"
127 (defcustom cvs-default-ignore-marks nil
128 "Non-nil if cvs mode commands should ignore any marked files.
129 Normally they run on the files that are marked (with `cvs-mode-mark'),
130 or the file under the cursor if no files are marked. If this variable
131 is set to a non-nil value they will by default run on the file on the
132 current line. See also `cvs-invert-ignore-marks'."
136 (defcustom cvs-invert-ignore-marks
138 (unless (equal cvs-default-ignore-marks t
)
140 (when (and cvs-force-dir-tag
(not cvs-default-ignore-marks
))
143 "List of cvs commands that invert the default ignore-mark behavior.
144 Commands in this set will use the opposite default from the one set
145 in `cvs-default-ignore-marks'."
147 :type
'(set (const "diff")
151 (defcustom cvs-confirm-removals t
152 "Ask for confirmation before removing files.
153 Non-nil means that PCL-CVS will ask confirmation before removing files
154 except for files whose content can readily be recovered from the repository.
155 A value of `list' means that the list of files to be deleted will be
156 displayed when asking for confirmation."
158 :type
'(choice (const list
)
162 (defcustom cvs-add-default-message nil
163 "Default message to use when adding files.
164 If set to nil, `cvs-mode-add' will always prompt for a message."
166 :type
'(choice (const :tag
"Prompt" nil
)
169 (defcustom cvs-find-file-and-jump nil
170 "Jump to the modified area when finding a file.
171 If non-nil, `cvs-mode-find-file' will place the cursor at the beginning of
172 the modified area. If the file is not locally modified, this will obviously
177 (defcustom cvs-buffer-name-alist
178 '(("diff" "*cvs-diff*" diff-mode
)
179 ("status" "*cvs-info*" cvs-status-mode
)
180 ("tree" "*cvs-info*" cvs-status-mode
)
181 ("message" "*cvs-commit*" nil log-edit
)
182 ("log" "*cvs-info*" log-view-mode
))
183 "Buffer name and mode to be used for each command.
184 This is a list of elements of the form
186 (CMD BUFNAME MODE &optional POSTPROC)
188 CMD is the name of the command.
189 BUFNAME is an expression that should evaluate to a string used as
190 a buffer name. It can use the variable CMD if it wants to.
191 MODE is the command to use to setup the buffer.
192 POSTPROC is a function that should be executed when the command terminates
194 The CMD used for `cvs-mode-commit' is \"message\". For that special
195 case, POSTPROC is called just after MODE with special arguments."
198 (list (choice (const "diff")
204 (choice (const "*vc-diff*")
206 (const "*cvs-commit*")
207 (const (expand-file-name "*cvs-commit*"))
208 (const (format "*cvs-%s*" cmd
))
209 (const (expand-file-name (format "*cvs-%s*" cmd
)))
210 (sexp :value
"my-cvs-info-buffer")
212 (choice (function-item diff-mode
)
213 (function-item cvs-edit-mode
)
214 (function-item cvs-status-mode
)
218 (choice (function-item cvs-status-cvstrees
)
219 (function-item cvs-status-trees
)
222 (defvar cvs-buffer-name
'(expand-file-name "*cvs*" dir
) ;; "*cvs*"
223 "Name of the cvs buffer.
224 This expression will be evaluated in an environment where DIR is set to
225 the directory name of the cvs buffer.")
227 (defvar cvs-temp-buffer-name
228 ;; Was '(expand-file-name " *cvs-tmp*" dir), but that causes them to
229 ;; become non-hidden if uniquification is done `forward'.
231 "Name of the cvs temporary buffer.
232 Output from cvs is placed here for asynchronous commands.")
234 (defcustom cvs-idiff-imerge-handlers
236 '(cvs-ediff-diff . cvs-ediff-merge
)
237 '(cvs-emerge-diff . cvs-emerge-merge
))
238 "Pair of functions to be used for resp. diff'ing and merg'ing interactively."
240 :type
'(choice (const :tag
"Ediff" (cvs-ediff-diff . cvs-ediff-merge
))
241 (const :tag
"Emerge" (cvs-emerge-diff . cvs-emerge-merge
))))
243 (defvar cvs-mode-hook nil
244 "Run after `cvs-mode' was setup.")
248 ;;;; Internal variables for the *cvs* buffer.
251 (defcustom cvs-reuse-cvs-buffer
'subdir
252 "When to reuse an existing cvs buffer.
254 `current': just reuse the current buffer if it is a cvs buffer
255 `samedir': reuse any cvs buffer displaying the same directory
256 `subdir': or reuse any cvs buffer displaying any sub- or super- directory
257 `always': reuse any cvs buffer."
259 :type
'(choice (const always
) (const subdir
) (const samedir
) (const current
)))
261 (defvar cvs-temp-buffer nil
262 "(Buffer local) The temporary buffer associated with this *cvs* buffer.")
264 (defvar cvs-lock-file nil
265 "Full path to a lock file that CVS is waiting for (or was waiting for).
266 This variable is buffer local and only used in the *cvs* buffer.")
268 (defvar cvs-lock-file-regexp
"^#cvs\\.\\([trw]fl\\.[-.a-z0-9]+\\|lock\\)\\'"
269 "Regexp matching the possible names of locks in the CVS repository.")
271 (defconst cvs-cursor-column
22
272 "Column to position cursor in in `cvs-mode'.")
275 ;;;; Global internal variables
278 (defconst cvs-vendor-branch
"1.1.1"
279 "The default branch used by CVS for vendor code.")
281 (easy-mmode-defmap cvs-mode-diff-map
282 '(("E" "imerge" . cvs-mode-imerge
)
283 ("=" . cvs-mode-diff
)
284 ("e" "idiff" . cvs-mode-idiff
)
285 ("2" "other" . cvs-mode-idiff-other
)
286 ("d" "diff" . cvs-mode-diff
)
287 ("b" "backup" . cvs-mode-diff-backup
)
288 ("h" "head" . cvs-mode-diff-head
)
289 ("r" "repository" . cvs-mode-diff-repository
)
290 ("y" "yesterday" . cvs-mode-diff-yesterday
)
291 ("v" "vendor" . cvs-mode-diff-vendor
))
292 "Keymap for diff-related operations in `cvs-mode'."
294 ;; This is necessary to allow correct handling of \\[cvs-mode-diff-map]
295 ;; in substitute-command-keys.
296 (fset 'cvs-mode-diff-map cvs-mode-diff-map
)
298 (easy-mmode-defmap cvs-mode-map
299 ;;(define-prefix-command 'cvs-mode-map-diff-prefix)
300 ;;(define-prefix-command 'cvs-mode-map-control-c-prefix)
302 ;; (undo . cvs-mode-undo)
305 ("q" . cvs-bury-buffer
)
306 ("z" . kill-this-buffer
)
307 ("F" . cvs-mode-set-flags
)
308 ;; ("\M-f" . cvs-mode-force-command)
309 ("!" . cvs-mode-force-command
)
310 ("\C-c\C-c" . cvs-mode-kill-process
)
312 ("m" . cvs-mode-mark
)
313 ("M" . cvs-mode-mark-all-files
)
314 ("S" . cvs-mode-mark-on-state
)
315 ("u" . cvs-mode-unmark
)
316 ("\C-?". cvs-mode-unmark-up
)
317 ("%" . cvs-mode-mark-matching-files
)
318 ("T" . cvs-mode-toggle-marks
)
319 ("\M-\C-?" . cvs-mode-unmark-all-files
)
321 (" " . cvs-mode-next-line
)
322 ("n" . cvs-mode-next-line
)
323 ("p" . cvs-mode-previous-line
)
324 ("\t" . cvs-mode-next-line
)
325 ([backtab] . cvs-mode-previous-line)
326 ;; M- keys are usually those that operate on modules
327 ;;("\M-C". cvs-mode-rcs2log) ; i.e. "Create a ChangeLog"
330 ("\M-c". cvs-checkout)
331 ("\M-e". cvs-examine)
332 ("g" . cvs-mode-revert-buffer)
336 ("=" . cvs-mode-diff)
337 ("d" . cvs-mode-diff-map)
338 ;; keys that operate on individual files
339 ("\C-k" . cvs-mode-acknowledge)
340 ("A" . cvs-mode-add-change-log-entry-other-window)
341 ;;("B" . cvs-mode-byte-compile-files)
342 ("C" . cvs-mode-commit-setup)
343 ("O" . cvs-mode-update)
344 ("U" . cvs-mode-undo)
345 ("I" . cvs-mode-insert)
347 ("b" . cvs-set-branch-prefix)
348 ("B" . cvs-set-secondary-branch-prefix)
349 ("c" . cvs-mode-commit)
350 ("e" . cvs-mode-examine)
351 ("f" . cvs-mode-find-file)
352 ("\C-m" . cvs-mode-find-file)
353 ("i" . cvs-mode-ignore)
355 ("o" . cvs-mode-find-file-other-window)
356 ("r" . cvs-mode-remove)
357 ("s" . cvs-mode-status)
359 ("v" . cvs-mode-view-file)
360 ("x" . cvs-mode-remove-handled)
362 ("+" . cvs-mode-tree)
364 ([mouse-2] . cvs-mode-find-file)
365 ([follow-link] . (lambda (pos)
366 (if (eq (get-char-property pos 'face) 'cvs-filename) t)))
367 ([(down-mouse-3)] . cvs-menu)
368 ;; dired-like bindings
369 ("\C-o" . cvs-mode-display-file)
371 ;;([tool-bar item1] . (menu-item "Examine" cvs-examine :image (image :file "/usr/share/icons/xpaint.xpm" :type xpm)))
372 ;;([tool-bar item2] . (menu-item "Update" cvs-update :image (image :file "/usr/share/icons/mail1.xpm" :type xpm)))
374 "Keymap for `cvs-mode'."
378 (fset 'cvs-mode-map cvs-mode-map)
380 (easy-menu-define cvs-menu cvs-mode-map "Menu used in `cvs-mode'."
382 ["Open file" cvs-mode-find-file t]
383 ["Open in other window" cvs-mode-find-file-other-window t]
384 ["Display in other window" cvs-mode-display-file t]
385 ["Interactive merge" cvs-mode-imerge t]
387 ["Interactive diff" cvs-mode-idiff t]
388 ["Current diff" cvs-mode-diff t]
389 ["Diff with head" cvs-mode-diff-head t]
390 ["Diff with vendor" cvs-mode-diff-vendor t]
391 ["Diff against yesterday" cvs-mode-diff-yesterday t]
392 ["Diff with backup" cvs-mode-diff-backup t])
393 ["View log" cvs-mode-log t]
394 ["View status" cvs-mode-status t]
395 ["View tag tree" cvs-mode-tree t]
397 ["Insert" cvs-mode-insert]
398 ["Update" cvs-mode-update (cvs-enabledp 'update)]
399 ["Re-examine" cvs-mode-examine t]
400 ["Commit" cvs-mode-commit-setup (cvs-enabledp 'commit)]
401 ["Tag" cvs-mode-tag (cvs-enabledp (when cvs-force-dir-tag 'tag))]
402 ["Undo changes" cvs-mode-undo (cvs-enabledp 'undo)]
403 ["Add" cvs-mode-add (cvs-enabledp 'add)]
404 ["Remove" cvs-mode-remove (cvs-enabledp 'remove)]
405 ["Ignore" cvs-mode-ignore (cvs-enabledp 'ignore)]
406 ["Add ChangeLog" cvs-mode-add-change-log-entry-other-window t]
408 ["Mark" cvs-mode-mark t]
409 ["Mark all" cvs-mode-mark-all-files t]
410 ["Mark by regexp..." cvs-mode-mark-matching-files t]
411 ["Mark by state..." cvs-mode-mark-on-state t]
412 ["Unmark" cvs-mode-unmark t]
413 ["Unmark all" cvs-mode-unmark-all-files t]
414 ["Hide handled" cvs-mode-remove-handled t]
416 ["PCL-CVS Manual" (lambda () (interactive)
417 (info "(pcl-cvs)Top")) t]
419 ["Quit" cvs-mode-quit t]))
425 (defcustom cvs-minor-mode-prefix "\C-xc"
426 "Prefix key for the `cvs-mode' bindings in `cvs-minor-mode'."
430 (easy-mmode-defmap cvs-minor-mode-map
431 `((,cvs-minor-mode-prefix . cvs-mode-map)
432 ("e" . (menu-item nil cvs-mode-edit-log
433 :filter (lambda (x) (if (derived-mode-p 'log-view-mode) x)))))
434 "Keymap for `cvs-minor-mode', used in buffers related to PCL-CVS.")
436 (defvar cvs-buffer nil
437 "(Buffer local) The *cvs* buffer associated with this buffer.")
438 (put 'cvs-buffer 'permanent-local t)
439 ;;(make-variable-buffer-local 'cvs-buffer)
441 (defvar cvs-minor-wrap-function nil
442 "Function to call when switching to the *cvs* buffer.
445 - a zero-arg function which is guaranteed not to switch buffer.
446 It is expected to call the function.")
447 ;;(make-variable-buffer-local 'cvs-minor-wrap-function)
449 (defvar cvs-minor-current-files)
450 ;;"Current files in a `cvs-minor-mode' buffer."
451 ;; This should stay `void' because we want to be able to tell the difference
452 ;; between an empty list and no list at all.
454 (defconst cvs-pcl-cvs-dirchange-re "^pcl-cvs: descending directory \\(.*\\)$")
457 ;;;; autoload the global menu
461 (defvar cvs-global-menu
462 (let ((m (make-sparse-keymap "PCL-CVS")))
463 (define-key m [status]
464 `(menu-item ,(purecopy "Directory Status") cvs-status
465 :help ,(purecopy "A more verbose status of a workarea")))
466 (define-key m [checkout]
467 `(menu-item ,(purecopy "Checkout Module") cvs-checkout
468 :help ,(purecopy "Check out a module from the repository")))
469 (define-key m [update]
470 `(menu-item ,(purecopy "Update Directory") cvs-update
471 :help ,(purecopy "Fetch updates from the repository")))
472 (define-key m [examine]
473 `(menu-item ,(purecopy "Examine Directory") cvs-examine
474 :help ,(purecopy "Examine the current state of a workarea")))
475 (fset 'cvs-global-menu m))
476 "Global menu used by PCL-CVS.")
479 ;; cvs-1.10 and above can take file arguments in other directories
480 ;; while others need to be executed once per directory
481 (defvar cvs-execute-single-dir
482 (if (or (null cvs-version)
483 (or (>= (cdr cvs-version) 10) (> (car cvs-version) 1)))
484 ;; Supposedly some recent versions of CVS output some directory info
485 ;; as they recurse down the tree, but it's not good enough in the case
486 ;; where we run "cvs status foo bar/foo".
489 "Whether cvs commands should be executed a directory at a time.
490 If a list, specifies for which commands the single-dir mode should be used.
491 If t, single-dir mode should be used for all operations.
493 CVS versions before 1.10 did not allow passing them arguments in different
494 directories, so PCL-CVS checks what version you're using to determine
495 whether to use the new feature or not.
496 Sadly, even with a new cvs executable, if you connect to an older cvs server
497 \(typically a cvs-1.9 on the server), the old restriction applies. In such
498 a case the sanity check made by PCL-CVS fails and you will have to manually
499 set this variable to t (until the cvs server is upgraded).
500 When the above problem occurs, PCL-CVS should (hopefully) catch cvs' error
501 message and replace it with a message telling you to change this variable.")
506 ;;; pcvs-defs.el ends here