* cua-base.el, cua-gmrk.el: Fix use of `filter-buffer-substring'.
[bpt/emacs.git] / lisp / pcvs-defs.el
... / ...
CommitLineData
1;;; pcvs-defs.el --- variable definitions for PCL-CVS
2
3;; Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
4;; 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
5;; Free Software Foundation, Inc.
6
7;; Author: Stefan Monnier <monnier@iro.umontreal.ca>
8;; Keywords: pcl-cvs
9
10;; This file is part of GNU Emacs.
11
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 3 of the License, or
15;; (at your option) any later version.
16
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.
21
22;; You should have received a copy of the GNU General Public License
23;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
24
25;;; Commentary:
26
27
28;;; Code:
29
30(eval-when-compile (require 'cl))
31(require 'pcvs-util)
32
33;;;; -------------------------------------------------------
34;;;; START OF THINGS TO CHECK WHEN INSTALLING
35
36(defvar cvs-program "cvs"
37 "*Name or full path of the cvs executable.")
38
39(defvar cvs-version
40 ;; With the divergence of the CVSNT codebase and version numbers, this is
41 ;; not really good any more.
42 (ignore-errors
43 (with-temp-buffer
44 (call-process cvs-program nil t nil "-v")
45 (goto-char (point-min))
46 (when (re-search-forward "(CVS\\(NT\\)?) \\([0-9]+\\)\\.\\([0-9]+\\)"
47 nil t)
48 (cons (string-to-number (match-string 1))
49 (string-to-number (match-string 2))))))
50 "*Version of `cvs' installed on your system.
51It must be in the (MAJOR . MINOR) format.")
52
53;; FIXME: this is only used by cvs-mode-diff-backup
54(defvar cvs-diff-program (or (and (boundp 'diff-command) diff-command) "diff")
55 "*Name or full path of the best diff program you've got.
56NOTE: there are some nasty bugs in the context diff variants of some vendor
57versions, such as the one in SunOS-4.")
58
59;;;; END OF THINGS TO CHECK WHEN INSTALLING
60;;;; --------------------------------------------------------
61
62;;;;
63;;;; User configuration variables:
64;;;;
65;;;; NOTE: these should be set in your ~/.emacs (or site-lisp/default.el) file.
66;;;;
67
68(defgroup pcl-cvs nil
69 "Special support for the CVS versioning system."
70 :version "21.1"
71 :group 'tools
72 :prefix "cvs-")
73
74;;
75;; cvsrc options
76;;
77
78(defcustom cvs-cvsrc-file (convert-standard-filename "~/.cvsrc")
79 "Path to your cvsrc file."
80 :group 'pcl-cvs
81 :type '(file))
82
83(defvar cvs-shared-start 4
84 "Index of the first shared flag.
85If set to 4, for instance, a numeric argument smaller than 4 will
86select a non-shared flag, while a numeric argument greater than 3
87will select a shared-flag.")
88
89(defvar cvs-shared-flags (make-list cvs-shared-start nil)
90 "List of flags whose settings is shared among several commands.")
91
92(defvar cvs-cvsroot nil
93 "*Specifies where the (current) cvs master repository is.
94Overrides the environment variable $CVSROOT by sending \" -d dir\" to
95all CVS commands. This switch is useful if you have multiple CVS
96repositories. It can be set interactively with \\[cvs-change-cvsroot.]
97There is no need to set this if $CVSROOT is set to a correct value.")
98
99(defcustom cvs-auto-remove-handled nil
100 "If up-to-date files should be acknowledged automatically.
101If T, they will be removed from the *cvs* buffer after every command.
102If DELAYED, they will be removed from the *cvs* buffer before every command.
103If STATUS, they will only be removed after a `cvs-mode-status' command.
104Else, they will never be automatically removed from the *cvs* buffer."
105 :group 'pcl-cvs
106 :type '(choice (const nil) (const status) (const delayed) (const t)))
107
108(defcustom cvs-auto-remove-directories 'handled
109 "If ALL, directory entries will never be shown.
110If HANDLED, only non-handled directories will be shown.
111If EMPTY, only non-empty directories will be shown."
112 :group 'pcl-cvs
113 :type '(choice (const :tag "No" nil) (const all) (const handled) (const empty)))
114
115(defcustom cvs-auto-revert t
116 "Non-nil if changed files should automatically be reverted."
117 :group 'pcl-cvs
118 :type '(boolean))
119
120(defcustom cvs-sort-ignore-file t
121 "Non-nil if `cvs-mode-ignore' should sort the .cvsignore automatically."
122 :group 'pcl-cvs
123 :type '(boolean))
124
125(defcustom cvs-force-dir-tag t
126 "If non-nil, tagging can only be applied to directories.
127Tagging should generally be applied a directory at a time, but sometimes it is
128useful to be able to tag a single file. The normal way to do that is to use
129`cvs-mode-force-command' so as to temporarily override the restrictions,"
130 :group 'pcl-cvs
131 :type '(boolean))
132
133(defcustom cvs-default-ignore-marks nil
134 "Non-nil if cvs mode commands should ignore any marked files.
135Normally they run on the files that are marked (with `cvs-mode-mark'),
136or the file under the cursor if no files are marked. If this variable
137is set to a non-nil value they will by default run on the file on the
138current line. See also `cvs-invert-ignore-marks'"
139 :group 'pcl-cvs
140 :type '(boolean))
141
142(defvar cvs-diff-ignore-marks t)
143(make-obsolete-variable 'cvs-diff-ignore-marks
144 'cvs-invert-ignore-marks
145 "21.1")
146
147(defcustom cvs-invert-ignore-marks
148 (let ((l ()))
149 (unless (equal cvs-diff-ignore-marks cvs-default-ignore-marks)
150 (push "diff" l))
151 (when (and cvs-force-dir-tag (not cvs-default-ignore-marks))
152 (push "tag" l))
153 l)
154 "List of cvs commands that invert the default ignore-mark behavior.
155Commands in this set will use the opposite default from the one set
156in `cvs-default-ignore-marks'."
157 :group 'pcl-cvs
158 :type '(set (const "diff")
159 (const "tag")
160 (const "ignore")))
161
162(defcustom cvs-confirm-removals t
163 "Ask for confirmation before removing files.
164Non-nil means that PCL-CVS will ask confirmation before removing files
165except for files whose content can readily be recovered from the repository.
166A value of `list' means that the list of files to be deleted will be
167displayed when asking for confirmation."
168 :group 'pcl-cvs
169 :type '(choice (const list)
170 (const t)
171 (const nil)))
172
173(defcustom cvs-add-default-message nil
174 "Default message to use when adding files.
175If set to nil, `cvs-mode-add' will always prompt for a message."
176 :group 'pcl-cvs
177 :type '(choice (const :tag "Prompt" nil)
178 (string)))
179
180(defvar cvs-diff-buffer-name "*cvs-diff*")
181(make-obsolete-variable 'cvs-diff-buffer-name
182 'cvs-buffer-name-alist
183 "21.1")
184
185(defcustom cvs-find-file-and-jump nil
186 "Jump to the modified area when finding a file.
187If non-nil, `cvs-mode-file-file' will place the cursor at the beginning of
188the modified area. If the file is not locally modified, this will obviously
189have no effect."
190 :group 'pcl-cvs
191 :type '(boolean))
192
193(defcustom cvs-buffer-name-alist
194 '(("diff" cvs-diff-buffer-name diff-mode)
195 ("status" "*cvs-info*" cvs-status-mode)
196 ("tree" "*cvs-info*" cvs-status-mode)
197 ("message" "*cvs-commit*" nil log-edit)
198 ("log" "*cvs-info*" log-view-mode))
199 "Buffer name and mode to be used for each command.
200This is a list of elements of the form
201
202 (CMD BUFNAME MODE &optional POSTPROC)
203
204CMD is the name of the command.
205BUFNAME is an expression that should evaluate to a string used as
206 a buffer name. It can use the variable CMD if it wants to.
207MODE is the command to use to setup the buffer.
208POSTPROC is a function that should be executed when the command terminates
209
210The CMD used for `cvs-mode-commit' is \"message\". For that special
211 case, POSTPROC is called just after MODE with special arguments."
212 :group 'pcl-cvs
213 :type '(repeat
214 (list (choice (const "diff")
215 (const "status")
216 (const "tree")
217 (const "message")
218 (const "log")
219 (string))
220 (choice (const "*vc-diff*")
221 (const "*cvs-info*")
222 (const "*cvs-commit*")
223 (const (expand-file-name "*cvs-commit*"))
224 (const (format "*cvs-%s*" cmd))
225 (const (expand-file-name (format "*cvs-%s*" cmd)))
226 (sexp :value "my-cvs-info-buffer")
227 (const nil))
228 (choice (function-item diff-mode)
229 (function-item cvs-edit-mode)
230 (function-item cvs-status-mode)
231 function
232 (const nil))
233 (set :inline t
234 (choice (function-item cvs-status-cvstrees)
235 (function-item cvs-status-trees)
236 function)))))
237
238(defvar cvs-buffer-name '(expand-file-name "*cvs*" dir) ;; "*cvs*"
239 "Name of the cvs buffer.
240This expression will be evaluated in an environment where DIR is set to
241the directory name of the cvs buffer.")
242
243(defvar cvs-temp-buffer-name
244 ;; Was '(expand-file-name " *cvs-tmp*" dir), but that causes them to
245 ;; become non-hidden if uniquification is done `forward'.
246 " *cvs-tmp*"
247 "*Name of the cvs temporary buffer.
248Output from cvs is placed here for asynchronous commands.")
249
250(defcustom cvs-idiff-imerge-handlers
251 (if (fboundp 'ediff)
252 '(cvs-ediff-diff . cvs-ediff-merge)
253 '(cvs-emerge-diff . cvs-emerge-merge))
254 "Pair of functions to be used for resp. diff'ing and merg'ing interactively."
255 :group 'pcl-cvs
256 :type '(choice (const :tag "Ediff" (cvs-ediff-diff . cvs-ediff-merge))
257 (const :tag "Emerge" (cvs-emerge-diff . cvs-emerge-merge))))
258
259(defvar cvs-mode-hook nil
260 "Run after `cvs-mode' was setup.")
261
262\f
263;;;;
264;;;; Internal variables, used in the process buffer.
265;;;;
266
267(defvar cvs-postprocess nil
268 "(Buffer local) what to do once the process exits.")
269
270;;;;
271;;;; Internal variables for the *cvs* buffer.
272;;;;
273
274(defcustom cvs-reuse-cvs-buffer 'subdir
275 "When to reuse an existing cvs buffer.
276Alternatives are:
277 CURRENT: just reuse the current buffer if it is a cvs buffer
278 SAMEDIR: reuse any cvs buffer displaying the same directory
279 SUBDIR: or reuse any cvs buffer displaying any sub- or super- directory
280 ALWAYS: reuse any cvs buffer."
281 :group 'pcl-cvs
282 :type '(choice (const always) (const subdir) (const samedir) (const current)))
283
284(defvar cvs-temp-buffer nil
285 "(Buffer local) The temporary buffer associated with this *cvs* buffer.")
286
287(defvar cvs-lock-file nil
288 "Full path to a lock file that CVS is waiting for (or was waiting for).
289This variable is buffer local and only used in the *cvs* buffer.")
290
291(defvar cvs-lock-file-regexp "^#cvs\\.\\([trw]fl\\.[-.a-z0-9]+\\|lock\\)\\'"
292 "Regexp matching the possible names of locks in the CVS repository.")
293
294(defconst cvs-cursor-column 22
295 "Column to position cursor in in `cvs-mode'.")
296
297;;;;
298;;;; Global internal variables
299;;;;
300
301(defconst cvs-vendor-branch "1.1.1"
302 "The default branch used by CVS for vendor code.")
303
304(easy-mmode-defmap cvs-mode-diff-map
305 '(("E" "imerge" . cvs-mode-imerge)
306 ("=" . cvs-mode-diff)
307 ("e" "idiff" . cvs-mode-idiff)
308 ("2" "other" . cvs-mode-idiff-other)
309 ("d" "diff" . cvs-mode-diff)
310 ("b" "backup" . cvs-mode-diff-backup)
311 ("h" "head" . cvs-mode-diff-head)
312 ("r" "repository" . cvs-mode-diff-repository)
313 ("y" "yesterday" . cvs-mode-diff-yesterday)
314 ("v" "vendor" . cvs-mode-diff-vendor))
315 "Keymap for diff-related operations in `cvs-mode'."
316 :name "Diff")
317;; This is necessary to allow correct handling of \\[cvs-mode-diff-map]
318;; in substitute-command-keys.
319(fset 'cvs-mode-diff-map cvs-mode-diff-map)
320
321(easy-mmode-defmap cvs-mode-map
322 ;;(define-prefix-command 'cvs-mode-map-diff-prefix)
323 ;;(define-prefix-command 'cvs-mode-map-control-c-prefix)
324 '(;; various
325 ;; (undo . cvs-mode-undo)
326 ("?" . cvs-help)
327 ("h" . cvs-help)
328 ("q" . cvs-bury-buffer)
329 ("z" . kill-this-buffer)
330 ("F" . cvs-mode-set-flags)
331 ;; ("\M-f" . cvs-mode-force-command)
332 ("!" . cvs-mode-force-command)
333 ("\C-c\C-c" . cvs-mode-kill-process)
334 ;; marking
335 ("m" . cvs-mode-mark)
336 ("M" . cvs-mode-mark-all-files)
337 ("S" . cvs-mode-mark-on-state)
338 ("u" . cvs-mode-unmark)
339 ("\C-?". cvs-mode-unmark-up)
340 ("%" . cvs-mode-mark-matching-files)
341 ("T" . cvs-mode-toggle-marks)
342 ("\M-\C-?" . cvs-mode-unmark-all-files)
343 ;; navigation keys
344 (" " . cvs-mode-next-line)
345 ("n" . cvs-mode-next-line)
346 ("p" . cvs-mode-previous-line)
347 ("\t" . cvs-mode-next-line)
348 ([backtab] . cvs-mode-previous-line)
349 ;; M- keys are usually those that operate on modules
350 ;;("\M-C". cvs-mode-rcs2log) ; i.e. "Create a ChangeLog"
351 ;;("\M-t". cvs-rtag)
352 ;;("\M-l". cvs-rlog)
353 ("\M-c". cvs-checkout)
354 ("\M-e". cvs-examine)
355 ("g" . cvs-mode-revert-buffer)
356 ("\M-u". cvs-update)
357 ("\M-s". cvs-status)
358 ;; diff commands
359 ("=" . cvs-mode-diff)
360 ("d" . cvs-mode-diff-map)
361 ;; keys that operate on individual files
362 ("\C-k" . cvs-mode-acknowledge)
363 ("A" . cvs-mode-add-change-log-entry-other-window)
364 ;;("B" . cvs-mode-byte-compile-files)
365 ("C" . cvs-mode-commit-setup)
366 ("O" . cvs-mode-update)
367 ("U" . cvs-mode-undo)
368 ("I" . cvs-mode-insert)
369 ("a" . cvs-mode-add)
370 ("b" . cvs-set-branch-prefix)
371 ("B" . cvs-set-secondary-branch-prefix)
372 ("c" . cvs-mode-commit)
373 ("e" . cvs-mode-examine)
374 ("f" . cvs-mode-find-file)
375 ("\C-m" . cvs-mode-find-file)
376 ("i" . cvs-mode-ignore)
377 ("l" . cvs-mode-log)
378 ("o" . cvs-mode-find-file-other-window)
379 ("r" . cvs-mode-remove)
380 ("s" . cvs-mode-status)
381 ("t" . cvs-mode-tag)
382 ("v" . cvs-mode-view-file)
383 ("x" . cvs-mode-remove-handled)
384 ;; cvstree bindings
385 ("+" . cvs-mode-tree)
386 ;; mouse bindings
387 ([mouse-2] . cvs-mode-find-file)
388 ([follow-link] . (lambda (pos)
389 (if (eq (get-char-property pos 'face) 'cvs-filename) t)))
390 ([(down-mouse-3)] . cvs-menu)
391 ;; dired-like bindings
392 ("\C-o" . cvs-mode-display-file)
393 ;; Emacs-21 toolbar
394 ;;([tool-bar item1] . (menu-item "Examine" cvs-examine :image (image :file "/usr/share/icons/xpaint.xpm" :type xpm)))
395 ;;([tool-bar item2] . (menu-item "Update" cvs-update :image (image :file "/usr/share/icons/mail1.xpm" :type xpm)))
396 )
397 "Keymap for `cvs-mode'."
398 :dense t
399 :suppress t)
400
401(fset 'cvs-mode-map cvs-mode-map)
402
403(easy-menu-define cvs-menu cvs-mode-map "Menu used in `cvs-mode'."
404 '("CVS"
405 ["Open file" cvs-mode-find-file t]
406 ["Open in other window" cvs-mode-find-file-other-window t]
407 ["Display in other window" cvs-mode-display-file t]
408 ["Interactive merge" cvs-mode-imerge t]
409 ("View diff"
410 ["Interactive diff" cvs-mode-idiff t]
411 ["Current diff" cvs-mode-diff t]
412 ["Diff with head" cvs-mode-diff-head t]
413 ["Diff with vendor" cvs-mode-diff-vendor t]
414 ["Diff against yesterday" cvs-mode-diff-yesterday t]
415 ["Diff with backup" cvs-mode-diff-backup t])
416 ["View log" cvs-mode-log t]
417 ["View status" cvs-mode-status t]
418 ["View tag tree" cvs-mode-tree t]
419 "----"
420 ["Insert" cvs-mode-insert]
421 ["Update" cvs-mode-update (cvs-enabledp 'update)]
422 ["Re-examine" cvs-mode-examine t]
423 ["Commit" cvs-mode-commit-setup (cvs-enabledp 'commit)]
424 ["Tag" cvs-mode-tag (cvs-enabledp (when cvs-force-dir-tag 'tag))]
425 ["Undo changes" cvs-mode-undo (cvs-enabledp 'undo)]
426 ["Add" cvs-mode-add (cvs-enabledp 'add)]
427 ["Remove" cvs-mode-remove (cvs-enabledp 'remove)]
428 ["Ignore" cvs-mode-ignore (cvs-enabledp 'ignore)]
429 ["Add ChangeLog" cvs-mode-add-change-log-entry-other-window t]
430 "----"
431 ["Mark" cvs-mode-mark t]
432 ["Mark all" cvs-mode-mark-all-files t]
433 ["Mark by regexp..." cvs-mode-mark-matching-files t]
434 ["Mark by state..." cvs-mode-mark-on-state t]
435 ["Unmark" cvs-mode-unmark t]
436 ["Unmark all" cvs-mode-unmark-all-files t]
437 ["Hide handled" cvs-mode-remove-handled t]
438 "----"
439 ["PCL-CVS Manual" (lambda () (interactive)
440 (info "(pcl-cvs)Top")) t]
441 "----"
442 ["Quit" cvs-mode-quit t]))
443
444;;;;
445;;;; CVS-Minor mode
446;;;;
447
448(defcustom cvs-minor-mode-prefix "\C-xc"
449 "Prefix key for the `cvs-mode' bindings in `cvs-minor-mode'."
450 :group 'pcl-cvs)
451
452(easy-mmode-defmap cvs-minor-mode-map
453 `((,cvs-minor-mode-prefix . cvs-mode-map)
454 ("e" . (menu-item nil cvs-mode-edit-log
455 :filter (lambda (x) (if (derived-mode-p 'log-view-mode) x)))))
456 "Keymap for `cvs-minor-mode', used in buffers related to PCL-CVS.")
457
458(defvar cvs-buffer nil
459 "(Buffer local) The *cvs* buffer associated with this buffer.")
460(put 'cvs-buffer 'permanent-local t)
461;;(make-variable-buffer-local 'cvs-buffer)
462
463(defvar cvs-minor-wrap-function nil
464 "Function to call when switching to the *cvs* buffer.
465Takes two arguments:
466- a *cvs* buffer.
467- a zero-arg function which is guaranteed not to switch buffer.
468It is expected to call the function.")
469;;(make-variable-buffer-local 'cvs-minor-wrap-function)
470
471(defvar cvs-minor-current-files)
472;;"Current files in a `cvs-minor-mode' buffer."
473;; This should stay `void' because we want to be able to tell the difference
474;; between an empty list and no list at all.
475
476(defconst cvs-pcl-cvs-dirchange-re "^pcl-cvs: descending directory \\(.*\\)$")
477
478;;;;
479;;;; autoload the global menu
480;;;;
481
482;;;###autoload
483(defvar cvs-global-menu
484 (let ((m (make-sparse-keymap "PCL-CVS")))
485 (define-key m [status]
486 `(menu-item ,(purecopy "Directory Status") cvs-status
487 :help ,(purecopy "A more verbose status of a workarea")))
488 (define-key m [checkout]
489 `(menu-item ,(purecopy "Checkout Module") cvs-checkout
490 :help ,(purecopy "Check out a module from the repository")))
491 (define-key m [update]
492 `(menu-item ,(purecopy "Update Directory") cvs-update
493 :help ,(purecopy "Fetch updates from the repository")))
494 (define-key m [examine]
495 `(menu-item ,(purecopy "Examine Directory") cvs-examine
496 :help ,(purecopy "Examine the current state of a workarea")))
497 (fset 'cvs-global-menu m)))
498
499
500;; cvs-1.10 and above can take file arguments in other directories
501;; while others need to be executed once per directory
502(defvar cvs-execute-single-dir
503 (if (or (null cvs-version)
504 (or (>= (cdr cvs-version) 10) (> (car cvs-version) 1)))
505 ;; Supposedly some recent versions of CVS output some directory info
506 ;; as they recurse downthe tree, but it's not good enough in the case
507 ;; where we run "cvs status foo bar/foo".
508 '("status")
509 t)
510 "Whether cvs commands should be executed a directory at a time.
511If a list, specifies for which commands the single-dir mode should be used.
512If T, single-dir mode should be used for all operations.
513
514CVS versions before 1.10 did not allow passing them arguments in different
515directories, so pcl-cvs checks what version you're using to determine
516whether to use the new feature or not.
517Sadly, even with a new cvs executable, if you connect to an older cvs server
518\(typically a cvs-1.9 on the server), the old restriction applies. In such
519a case the sanity check made by pcl-cvs fails and you will have to manually
520set this variable to t (until the cvs server is upgraded).
521When the above problem occurs, pcl-cvs should (hopefully) catch cvs' error
522message and replace it with a message telling you to change this variable.")
523
524;;
525(provide 'pcvs-defs)
526
527;; arch-tag: c7c701d0-d1d4-4aa9-a302-007bb03aca5e
528;;; pcvs-defs.el ends here