Update docstrings and comments to use "init file" terminology.
[emacs.git] / lisp / vc / pcvs-defs.el
blobfc65d62c67d927c50ac87836223d46086a08d574
1 ;;; pcvs-defs.el --- variable definitions for PCL-CVS
3 ;; Copyright (C) 1991-2012 Free Software Foundation, Inc.
5 ;; Author: Stefan Monnier <monnier@iro.umontreal.ca>
6 ;; Keywords: pcl-cvs
7 ;; Package: pcvs
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/>.
24 ;;; Commentary:
27 ;;; Code:
29 (require 'pcvs-util)
31 ;;;; -------------------------------------------------------
32 ;;;; START OF THINGS TO CHECK WHEN INSTALLING
34 (defvar cvs-program "cvs"
35 "Name or full path of the cvs executable.")
37 (defvar cvs-version
38 ;; With the divergence of the CVSNT codebase and version numbers, this is
39 ;; not really good any more.
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\\(NT\\)?) \\([0-9]+\\)\\.\\([0-9]+\\)"
45 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 ;;;; User configuration variables:
62 (defgroup pcl-cvs nil
63 "Special support for the CVS versioning system."
64 :version "21.1"
65 :group 'tools
66 :prefix "cvs-")
69 ;; cvsrc options
72 (defcustom cvs-cvsrc-file (convert-standard-filename "~/.cvsrc")
73 "Path to your cvsrc file."
74 :group 'pcl-cvs
75 :type '(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."
99 :group 'pcl-cvs
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."
106 :group 'pcl-cvs
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."
111 :group 'pcl-cvs
112 :type '(boolean))
114 (defcustom cvs-sort-ignore-file t
115 "Non-nil if `cvs-mode-ignore' should sort the .cvsignore automatically."
116 :group 'pcl-cvs
117 :type '(boolean))
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,"
124 :group 'pcl-cvs
125 :type '(boolean))
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'"
133 :group 'pcl-cvs
134 :type '(boolean))
136 (defvar cvs-diff-ignore-marks t)
137 (make-obsolete-variable 'cvs-diff-ignore-marks
138 'cvs-invert-ignore-marks
139 "21.1")
141 (defcustom cvs-invert-ignore-marks
142 (let ((l ()))
143 (unless (equal cvs-diff-ignore-marks cvs-default-ignore-marks)
144 (push "diff" l))
145 (when (and cvs-force-dir-tag (not cvs-default-ignore-marks))
146 (push "tag" l))
148 "List of cvs commands that invert the default ignore-mark behavior.
149 Commands in this set will use the opposite default from the one set
150 in `cvs-default-ignore-marks'."
151 :group 'pcl-cvs
152 :type '(set (const "diff")
153 (const "tag")
154 (const "ignore")))
156 (defcustom cvs-confirm-removals t
157 "Ask for confirmation before removing files.
158 Non-nil means that PCL-CVS will ask confirmation before removing files
159 except for files whose content can readily be recovered from the repository.
160 A value of `list' means that the list of files to be deleted will be
161 displayed when asking for confirmation."
162 :group 'pcl-cvs
163 :type '(choice (const list)
164 (const t)
165 (const nil)))
167 (defcustom cvs-add-default-message nil
168 "Default message to use when adding files.
169 If set to nil, `cvs-mode-add' will always prompt for a message."
170 :group 'pcl-cvs
171 :type '(choice (const :tag "Prompt" nil)
172 (string)))
174 (defvar cvs-diff-buffer-name "*cvs-diff*")
175 (make-obsolete-variable 'cvs-diff-buffer-name
176 'cvs-buffer-name-alist
177 "21.1")
179 (defcustom cvs-find-file-and-jump nil
180 "Jump to the modified area when finding a file.
181 If non-nil, `cvs-mode-find-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" "*cvs-info*" 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
238 ;; Was '(expand-file-name " *cvs-tmp*" dir), but that causes them to
239 ;; become non-hidden if uniquification is done `forward'.
240 " *cvs-tmp*"
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 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 ("r" "repository" . cvs-mode-diff-repository)
307 ("y" "yesterday" . cvs-mode-diff-yesterday)
308 ("v" "vendor" . cvs-mode-diff-vendor))
309 "Keymap for diff-related operations in `cvs-mode'."
310 :name "Diff")
311 ;; This is necessary to allow correct handling of \\[cvs-mode-diff-map]
312 ;; in substitute-command-keys.
313 (fset 'cvs-mode-diff-map cvs-mode-diff-map)
315 (easy-mmode-defmap cvs-mode-map
316 ;;(define-prefix-command 'cvs-mode-map-diff-prefix)
317 ;;(define-prefix-command 'cvs-mode-map-control-c-prefix)
318 '(;; various
319 ;; (undo . cvs-mode-undo)
320 ("?" . cvs-help)
321 ("h" . cvs-help)
322 ("q" . cvs-bury-buffer)
323 ("z" . kill-this-buffer)
324 ("F" . cvs-mode-set-flags)
325 ;; ("\M-f" . cvs-mode-force-command)
326 ("!" . cvs-mode-force-command)
327 ("\C-c\C-c" . cvs-mode-kill-process)
328 ;; marking
329 ("m" . cvs-mode-mark)
330 ("M" . cvs-mode-mark-all-files)
331 ("S" . cvs-mode-mark-on-state)
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 ("\t" . cvs-mode-next-line)
342 ([backtab] . cvs-mode-previous-line)
343 ;; M- keys are usually those that operate on modules
344 ;;("\M-C". cvs-mode-rcs2log) ; i.e. "Create a ChangeLog"
345 ;;("\M-t". cvs-rtag)
346 ;;("\M-l". cvs-rlog)
347 ("\M-c". cvs-checkout)
348 ("\M-e". cvs-examine)
349 ("g" . cvs-mode-revert-buffer)
350 ("\M-u". cvs-update)
351 ("\M-s". cvs-status)
352 ;; diff commands
353 ("=" . cvs-mode-diff)
354 ("d" . cvs-mode-diff-map)
355 ;; keys that operate on individual files
356 ("\C-k" . cvs-mode-acknowledge)
357 ("A" . cvs-mode-add-change-log-entry-other-window)
358 ;;("B" . cvs-mode-byte-compile-files)
359 ("C" . cvs-mode-commit-setup)
360 ("O" . cvs-mode-update)
361 ("U" . cvs-mode-undo)
362 ("I" . cvs-mode-insert)
363 ("a" . cvs-mode-add)
364 ("b" . cvs-set-branch-prefix)
365 ("B" . cvs-set-secondary-branch-prefix)
366 ("c" . cvs-mode-commit)
367 ("e" . cvs-mode-examine)
368 ("f" . cvs-mode-find-file)
369 ("\C-m" . cvs-mode-find-file)
370 ("i" . cvs-mode-ignore)
371 ("l" . cvs-mode-log)
372 ("o" . cvs-mode-find-file-other-window)
373 ("r" . cvs-mode-remove)
374 ("s" . cvs-mode-status)
375 ("t" . cvs-mode-tag)
376 ("v" . cvs-mode-view-file)
377 ("x" . cvs-mode-remove-handled)
378 ;; cvstree bindings
379 ("+" . cvs-mode-tree)
380 ;; mouse bindings
381 ([mouse-2] . cvs-mode-find-file)
382 ([follow-link] . (lambda (pos)
383 (if (eq (get-char-property pos 'face) 'cvs-filename) t)))
384 ([(down-mouse-3)] . cvs-menu)
385 ;; dired-like bindings
386 ("\C-o" . cvs-mode-display-file)
387 ;; Emacs-21 toolbar
388 ;;([tool-bar item1] . (menu-item "Examine" cvs-examine :image (image :file "/usr/share/icons/xpaint.xpm" :type xpm)))
389 ;;([tool-bar item2] . (menu-item "Update" cvs-update :image (image :file "/usr/share/icons/mail1.xpm" :type xpm)))
391 "Keymap for `cvs-mode'."
392 :dense t
393 :suppress t)
395 (fset 'cvs-mode-map cvs-mode-map)
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 ["Open in other window" cvs-mode-find-file-other-window t]
401 ["Display in other window" cvs-mode-display-file t]
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 against yesterday" cvs-mode-diff-yesterday t]
409 ["Diff with backup" cvs-mode-diff-backup t])
410 ["View log" cvs-mode-log t]
411 ["View status" cvs-mode-status t]
412 ["View tag tree" cvs-mode-tree t]
413 "----"
414 ["Insert" cvs-mode-insert]
415 ["Update" cvs-mode-update (cvs-enabledp 'update)]
416 ["Re-examine" cvs-mode-examine t]
417 ["Commit" cvs-mode-commit-setup (cvs-enabledp 'commit)]
418 ["Tag" cvs-mode-tag (cvs-enabledp (when cvs-force-dir-tag 'tag))]
419 ["Undo changes" cvs-mode-undo (cvs-enabledp 'undo)]
420 ["Add" cvs-mode-add (cvs-enabledp 'add)]
421 ["Remove" cvs-mode-remove (cvs-enabledp 'remove)]
422 ["Ignore" cvs-mode-ignore (cvs-enabledp 'ignore)]
423 ["Add ChangeLog" cvs-mode-add-change-log-entry-other-window t]
424 "----"
425 ["Mark" cvs-mode-mark t]
426 ["Mark all" cvs-mode-mark-all-files t]
427 ["Mark by regexp..." cvs-mode-mark-matching-files t]
428 ["Mark by state..." cvs-mode-mark-on-state t]
429 ["Unmark" cvs-mode-unmark t]
430 ["Unmark all" cvs-mode-unmark-all-files t]
431 ["Hide handled" cvs-mode-remove-handled t]
432 "----"
433 ["PCL-CVS Manual" (lambda () (interactive)
434 (info "(pcl-cvs)Top")) t]
435 "----"
436 ["Quit" cvs-mode-quit t]))
438 ;;;;
439 ;;;; CVS-Minor mode
440 ;;;;
442 (defcustom cvs-minor-mode-prefix "\C-xc"
443 "Prefix key for the `cvs-mode' bindings in `cvs-minor-mode'."
444 :group 'pcl-cvs)
446 (easy-mmode-defmap cvs-minor-mode-map
447 `((,cvs-minor-mode-prefix . cvs-mode-map)
448 ("e" . (menu-item nil cvs-mode-edit-log
449 :filter (lambda (x) (if (derived-mode-p 'log-view-mode) x)))))
450 "Keymap for `cvs-minor-mode', used in buffers related to PCL-CVS.")
452 (defvar cvs-buffer nil
453 "(Buffer local) The *cvs* buffer associated with this buffer.")
454 (put 'cvs-buffer 'permanent-local t)
455 ;;(make-variable-buffer-local 'cvs-buffer)
457 (defvar cvs-minor-wrap-function nil
458 "Function to call when switching to the *cvs* buffer.
459 Takes two arguments:
460 - a *cvs* buffer.
461 - a zero-arg function which is guaranteed not to switch buffer.
462 It is expected to call the function.")
463 ;;(make-variable-buffer-local 'cvs-minor-wrap-function)
465 (defvar cvs-minor-current-files)
466 ;;"Current files in a `cvs-minor-mode' buffer."
467 ;; This should stay `void' because we want to be able to tell the difference
468 ;; between an empty list and no list at all.
470 (defconst cvs-pcl-cvs-dirchange-re "^pcl-cvs: descending directory \\(.*\\)$")
472 ;;;;
473 ;;;; autoload the global menu
474 ;;;;
476 ;;;###autoload
477 (defvar cvs-global-menu
478 (let ((m (make-sparse-keymap "PCL-CVS")))
479 (define-key m [status]
480 `(menu-item ,(purecopy "Directory Status") cvs-status
481 :help ,(purecopy "A more verbose status of a workarea")))
482 (define-key m [checkout]
483 `(menu-item ,(purecopy "Checkout Module") cvs-checkout
484 :help ,(purecopy "Check out a module from the repository")))
485 (define-key m [update]
486 `(menu-item ,(purecopy "Update Directory") cvs-update
487 :help ,(purecopy "Fetch updates from the repository")))
488 (define-key m [examine]
489 `(menu-item ,(purecopy "Examine Directory") cvs-examine
490 :help ,(purecopy "Examine the current state of a workarea")))
491 (fset 'cvs-global-menu m))
492 "Global menu used by PCL-CVS.")
495 ;; cvs-1.10 and above can take file arguments in other directories
496 ;; while others need to be executed once per directory
497 (defvar cvs-execute-single-dir
498 (if (or (null cvs-version)
499 (or (>= (cdr cvs-version) 10) (> (car cvs-version) 1)))
500 ;; Supposedly some recent versions of CVS output some directory info
501 ;; as they recurse down the tree, but it's not good enough in the case
502 ;; where we run "cvs status foo bar/foo".
503 '("status")
505 "Whether cvs commands should be executed a directory at a time.
506 If a list, specifies for which commands the single-dir mode should be used.
507 If T, single-dir mode should be used for all operations.
509 CVS versions before 1.10 did not allow passing them arguments in different
510 directories, so pcl-cvs checks what version you're using to determine
511 whether to use the new feature or not.
512 Sadly, even with a new cvs executable, if you connect to an older cvs server
513 \(typically a cvs-1.9 on the server), the old restriction applies. In such
514 a case the sanity check made by pcl-cvs fails and you will have to manually
515 set this variable to t (until the cvs server is upgraded).
516 When the above problem occurs, pcl-cvs should (hopefully) catch cvs' error
517 message and replace it with a message telling you to change this variable.")
520 (provide 'pcvs-defs)
522 ;;; pcvs-defs.el ends here