pcvs-defs.el 18 KB

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