1 ;;; pcvs.el --- a front-end to CVS
3 ;; Copyright (C) 1991,92,93,94,95,95,97,98,99,2000,2002
4 ;; Free Software Foundation, Inc.
6 ;; Author: (The PCL-CVS Trust) pcl-cvs@cyclic.com
7 ;; (Per Cederqvist) ceder@lysator.liu.se
8 ;; (Greg A. Woods) woods@weird.com
9 ;; (Jim Blandy) jimb@cyclic.com
10 ;; (Karl Fogel) kfogel@floss.red-bean.com
11 ;; (Jim Kingdon) kingdon@cyclic.com
12 ;; (Stefan Monnier) monnier@cs.yale.edu
13 ;; (Greg Klanderman) greg@alphatech.com
14 ;; (Jari Aalto+mail.emacs) jari.aalto@poboxes.com
15 ;; Maintainer: (Stefan Monnier) monnier+lists/cvs/pcl@flint.cs.yale.edu
16 ;; Keywords: CVS, version control, release management
17 ;; Revision: $Id: pcvs.el,v 1.45 2002/11/18 20:53:24 rost Exp $
19 ;; This file is part of GNU Emacs.
21 ;; GNU Emacs is free software; you can redistribute it and/or modify
22 ;; it under the terms of the GNU General Public License as published by
23 ;; the Free Software Foundation; either version 2, or (at your option)
26 ;; GNU Emacs is distributed in the hope that it will be useful,
27 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
28 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 ;; GNU General Public License for more details.
31 ;; You should have received a copy of the GNU General Public License
32 ;; along with GNU Emacs; see the file COPYING. If not, write to the
33 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
34 ;; Boston, MA 02111-1307, USA.
38 ;; PCL-CVS is a front-end to the CVS version control system. For people
39 ;; familiar with VC, it is somewhat like VC-dired: it presents the status of
40 ;; all the files in your working area and allows you to commit/update several
41 ;; of them at a time. Compared to VC-dired, it is considerably better and
42 ;; faster (but only for CVS).
44 ;; PCL-CVS was originally written by Per Cederqvist many years ago. This
45 ;; version derives from the XEmacs-21 version, itself based on the 2.0b2
46 ;; version (last release from Per). It is a thorough rework.
48 ;; Contrary to what you'd expect, PCL-CVS is not a replacement for VC but only
49 ;; for VC-dired. As such, I've tried to make PCL-CVS and VC interoperate
50 ;; seamlessly (I also use VC).
52 ;; To use PCL-CVS just use `M-x cvs-examine RET <dir> RET'.
53 ;; There is a TeXinfo manual, which can be helpful to get started.
57 ;; - Extracting an old version seems not to recognize encoding correctly.
58 ;; That's probably because it's done via a process rather than a file.
62 ;; ******** FIX THE DOCUMENTATION *********
64 ;; - rework the displaying of error messages.
65 ;; - allow to flush messages only
66 ;; - allow to protect files like ChangeLog from flushing
67 ;; - automatically cvs-mode-insert files from find-file-hook
68 ;; (and don't flush them as long as they are visited)
69 ;; - query the user for cvs-get-marked (for some cmds or if nothing's selected)
70 ;; - don't return the first (resp last) FI if the cursor is before
72 ;; - allow cvs-confirm-removals to force always confirmation.
73 ;; - cvs-checkout should ask for a revision (with completion).
74 ;; - removal confirmation should allow specifying another file name.
76 ;; - hide fileinfos without getting rid of them (will require ewok work).
77 ;; - add toolbar entries
79 ;; marking directories should jump to just after the dir.
80 ;; allow (un)marking directories at a time with the mouse.
81 ;; allow cvs-cmd-do to either clear the marks or not.
82 ;; add a "marks active" notion, like transient-mark-mode does.
83 ;; - liveness indicator
84 ;; - indicate in docstring if the cmd understands the `b' prefix(es).
85 ;; - call smerge-mode when opening CONFLICT files.
86 ;; - have vc-checkin delegate to cvs-mode-commit when applicable
87 ;; - higher-level CVS operations
90 ;; - module-level commands
91 ;; add support for parsing 'modules' file ("cvs co -c")
96 ;; C-u M-x cvs-checkout should ask for a cvsroot
97 ;; cvs-mode-handle-new-vendor-version
98 ;; - checks out module, or alternately does update join
99 ;; - does "cvs -n tag LAST_VENDOR" to find old files into *cvs*
101 ;; (with completion on tag names and hooks to help generate full releases)
102 ;; - display stickiness information. And current CVS/Tag as well.
103 ;; - write 'cvs-mode-admin' to do arbitrary 'cvs admin' commands
104 ;; Most interesting would be version removal and log message replacement.
105 ;; The last one would be neat when called from log-view-mode.
106 ;; - cvs-mode-incorporate
107 ;; It would merge in the status from one *cvs* buffer into another.
108 ;; This would be used to populate such a buffer that had been created with
109 ;; a `cvs {update,status,checkout} -l'.
110 ;; - cvs-mode-(i)diff-other-{file,buffer,cvs-buffer}
111 ;; - offer the choice to kill the process when the user kills the cvs buffer.
112 ;; right now, it's killed without further ado.
113 ;; - make `cvs-mode-ignore' allow manually entering a pattern.
114 ;; to which dir should it apply ?
115 ;; - cvs-mode-ignore should try to remove duplicate entries.
116 ;; - maybe poll/check CVS/Entries files to react to external `cvs' commands ?
117 ;; - some kind of `cvs annotate' support ?
118 ;; but vc-annotate can be used instead.
119 ;; - proper `g' that passes safe args and uses either cvs-status or cvs-examine
120 ;; maybe also use cvs-update depending on I-don't-know-what.
121 ;; - add message-levels so that we can hide some levels of messages
125 (eval-when-compile (require 'cl
))
126 (require 'ewoc
) ;Ewoc was once cookie
129 (require 'pcvs-parse
)
137 (defvar cvs-cookies
) ;;nil
138 ;;"Handle for the cookie structure that is displayed in the *cvs* buffer.")
139 ;;(make-variable-buffer-local 'cvs-cookies)
142 ;;;; Dynamically scoped variables
145 (defvar cvs-from-vc nil
"Bound to t inside VC advice.")
151 (defun cvs-defaults (&rest defs
)
152 (let ((defs (cvs-first defs cvs-shared-start
)))
154 (make-list (- cvs-shared-start
(length defs
)) (car defs
))
157 ;; For cvs flags, we need to add "-f" to override the cvsrc settings
158 ;; we also want to evict the annoying -q and -Q options that hide useful
159 ;; information from pcl-cvs.
160 (cvs-flags-define cvs-cvs-flags
'(("-f")))
162 (cvs-flags-define cvs-checkout-flags
(cvs-defaults '("-P")))
163 (cvs-flags-define cvs-status-flags
(cvs-defaults '("-v") nil
))
164 (cvs-flags-define cvs-log-flags
(cvs-defaults nil
))
165 (cvs-flags-define cvs-diff-flags
(cvs-defaults '("-u" "-N") '("-c" "-N") '("-u" "-b")))
166 (cvs-flags-define cvs-tag-flags
(cvs-defaults nil
))
167 (cvs-flags-define cvs-add-flags
(cvs-defaults nil
))
168 (cvs-flags-define cvs-commit-flags
(cvs-defaults nil
))
169 (cvs-flags-define cvs-remove-flags
(cvs-defaults nil
))
170 ;;(cvs-flags-define cvs-undo-flags (cvs-defaults nil))
171 (cvs-flags-define cvs-update-flags
(cvs-defaults '("-d" "-P")))
173 (defun cvs-reread-cvsrc ()
174 "Reset the default arguments to those in the `cvs-cvsrc-file'."
178 (insert-file-contents cvs-cvsrc-file
)
180 (dolist (cmd '("cvs" "checkout" "status" "log" "diff" "tag"
181 "add" "commit" "remove" "update"))
182 (goto-char (point-min))
183 (when (re-search-forward
184 (concat "^" cmd
"\\(\\s-+\\(.*\\)\\)?$") nil t
)
185 (let* ((sym (intern (concat "cvs-" cmd
"-flags")))
186 (val (cvs-string->strings
(or (match-string 2) ""))))
187 (cvs-flags-set sym
0 val
))))
188 ;; ensure that cvs doesn't have -q or -Q
189 (cvs-flags-set 'cvs-cvs-flags
0
192 (lambda (x) (member x
'("-q" "-Q" "-f")))
193 (cvs-flags-query 'cvs-cvs-flags
197 ;; initialize to cvsrc's default values
202 ;;;; Mouse bindings and mode motion
206 "Popup the CVS menu."
208 (let ((cvs-minor-current-files
209 (list (ewoc-data (ewoc-locate
210 cvs-cookies
(posn-point (event-end e
)))))))
211 (popup-menu cvs-menu e
)))
213 (defvar cvs-mode-line-process nil
214 "Mode-line control for displaying info on cvs process status.")
218 ;;;; Query-Type-Descriptor for Tags
221 (autoload 'cvs-status-get-tags
"cvs-status")
222 (defun cvs-tags-list ()
223 "Return a list of acceptable tags, ready for completions."
224 (assert (cvs-buffer-p))
225 (let ((marked (cvs-get-marked)))
226 (list* '("BASE") '("HEAD")
229 (call-process cvs-program
231 t
;output to current-buffer
232 nil
;don't update display while running
235 (cvs-fileinfo->full-path
(car marked
)))
236 (goto-char (point-min))
237 (let ((tags (cvs-status-get-tags)))
238 (when (listp tags
) tags
)))))))
240 (defvar cvs-tag-history nil
)
241 (defconst cvs-qtypedesc-tag
242 (cvs-qtypedesc-create 'identity
'identity
'cvs-tags-list
'cvs-tag-history
))
246 (defun cvs-mode! (&optional -cvs-mode
!-fun -cvs-mode
!-noerror
)
247 "Switch to the *cvs* buffer.
248 If -CVS-MODE!-FUN is provided, it is executed *cvs* being the current buffer
249 and with its window selected. Else, the *cvs* buffer is simply selected.
250 If -CVS-MODE!-NOERROR is non-nil, then failure to find a *cvs* buffer does
251 not generate an error and the current buffer is kept selected.
252 -CVS-MODE!-FUN is called interactively if applicable and else with no argument."
253 (let* ((-cvs-mode!-buf
(current-buffer))
254 (cvsbuf (cond ((cvs-buffer-p) (current-buffer))
255 ((and cvs-buffer
(cvs-buffer-p cvs-buffer
)) cvs-buffer
)
256 (-cvs-mode!-noerror
(current-buffer))
257 (t (error "can't find the *cvs* buffer"))))
258 (-cvs-mode!-wrapper cvs-minor-wrap-function
)
259 (-cvs-mode!-cont
(lambda ()
261 (if (commandp -cvs-mode
!-fun
)
262 (call-interactively -cvs-mode
!-fun
)
263 (funcall -cvs-mode
!-fun
))))))
264 (if (not -cvs-mode
!-fun
) (set-buffer cvsbuf
)
265 (let ((cvs-mode!-buf
(current-buffer))
266 (cvs-mode!-owin
(selected-window))
267 (cvs-mode!-nwin
(get-buffer-window cvsbuf
'visible
)))
271 (when cvs-mode
!-nwin
(select-window cvs-mode
!-nwin
))
272 (if -cvs-mode
!-wrapper
273 (funcall -cvs-mode
!-wrapper -cvs-mode
!-buf -cvs-mode
!-cont
)
274 (funcall -cvs-mode
!-cont
)))
275 (set-buffer cvs-mode
!-buf
)
276 (when (and cvs-mode
!-nwin
(eq cvs-mode
!-nwin
(selected-window)))
277 ;; the selected window has not been changed by FUN
278 (select-window cvs-mode
!-owin
)))))))
284 (defvar cvs-branches
(list cvs-vendor-branch
"HEAD" "HEAD"))
285 (cvs-prefix-define cvs-branch-prefix
286 "Current selected branch."
288 (cons cvs-vendor-branch cvs-branches
)
291 (defun cvs-set-branch-prefix (arg)
292 "Set the branch prefix to take action at the next command.
293 See `cvs-prefix-set' for a further the description of the behavior.
294 \\[universal-argument] 1 selects the vendor branch
295 and \\[universal-argument] 2 selects the HEAD."
298 (cvs-prefix-set 'cvs-branch-prefix arg
))
300 (defun cvs-add-branch-prefix (flags &optional arg
)
301 "Add branch selection argument if the branch prefix was set.
302 The argument is added (or not) to the list of FLAGS and is constructed
303 by appending the branch to ARG which defaults to \"-r\"."
304 (let ((branch (cvs-prefix-get 'cvs-branch-prefix
)))
305 ;; deactivate the secondary prefix, even if not used.
306 (cvs-prefix-get 'cvs-secondary-branch-prefix
)
307 (if branch
(cons (concat (or arg
"-r") branch
) flags
) flags
)))
309 (cvs-prefix-define cvs-secondary-branch-prefix
310 "Current secondary selected branch."
312 (cons cvs-vendor-branch cvs-branches
)
315 (defun cvs-set-secondary-branch-prefix (arg)
316 "Set the branch prefix to take action at the next command.
317 See `cvs-prefix-set' for a further the description of the behavior.
318 \\[universal-argument] 1 selects the vendor branch
319 and \\[universal-argument] 2 selects the HEAD."
322 (cvs-prefix-set 'cvs-secondary-branch-prefix arg
))
324 (defun cvs-add-secondary-branch-prefix (flags &optional arg
)
325 "Add branch selection argument if the secondary branch prefix was set.
326 The argument is added (or not) to the list of FLAGS and is constructed
327 by appending the branch to ARG which defaults to \"-r\".
328 Since the `cvs-secondary-branch-prefix' is only active if the primary
329 prefix is active, it is important to read the secondary prefix before
330 the primay since reading the primary can deactivate it."
331 (let ((branch (and (cvs-prefix-get 'cvs-branch-prefix
'read-only
)
332 (cvs-prefix-get 'cvs-secondary-branch-prefix
))))
333 (if branch
(cons (concat (or arg
"-r") branch
) flags
) flags
)))
337 (define-minor-mode cvs-minor-mode
338 "This mode is used for buffers related to a main *cvs* buffer.
339 All the `cvs-mode' buffer operations are simply rebound under
340 the \\[cvs-mode-map] prefix."
343 (put 'cvs-minor-mode
'permanent-local t
)
346 (defvar cvs-temp-buffers nil
)
347 (defun cvs-temp-buffer (&optional cmd normal nosetup
)
348 "Create a temporary buffer to run CMD in.
349 If CMD is a string, use it to lookup `cvs-buffer-name-alist' to find
350 the buffer name to be used and its `major-mode'.
352 The selected window will not be changed. The new buffer will not maintain undo
353 information and will be read-only unless NORMAL is non-nil. It will be emptied
354 \(unless NOSETUP is non-nil\) and its `default-directory' will be inherited
355 from the current buffer."
356 (let* ((cvs-buf (current-buffer))
357 (info (cdr (assoc cmd cvs-buffer-name-alist
)))
358 (name (eval (nth 0 info
)))
360 (dir default-directory
)
362 (name (cvs-get-buffer-create name
))
363 ((and (bufferp cvs-temp-buffer
) (buffer-name cvs-temp-buffer
))
366 (set (make-local-variable 'cvs-temp-buffer
)
367 (cvs-get-buffer-create
368 (eval cvs-temp-buffer-name
) 'noreuse
))))))
370 ;; handle the potential pre-existing process
371 (let ((proc (get-buffer-process buf
)))
372 (when (and (not normal
) (processp proc
)
373 (memq (process-status proc
) '(run stop
)))
374 (error "Can not run two cvs processes simultaneously")))
376 (if (not name
) (kill-local-variable 'other-window-scroll-buffer
)
377 ;; Strangely, if no window is created, `display-buffer' ends up
378 ;; doing a `switch-to-buffer' which does a `set-buffer', hence
379 ;; the need for `save-excursion'.
380 (unless nosetup
(save-excursion (display-buffer buf
)))
381 ;; FIXME: this doesn't do the right thing if the user later on
382 ;; does a `find-file-other-window' and `scroll-other-window'
383 (set (make-local-variable 'other-window-scroll-buffer
) buf
))
385 (add-to-list 'cvs-temp-buffers buf
)
387 (with-current-buffer buf
388 (setq buffer-read-only nil
)
389 (setq default-directory dir
)
390 (unless nosetup
(erase-buffer))
391 (set (make-local-variable 'cvs-buffer
) cvs-buf
)
393 (let ((lbd list-buffers-directory
))
394 (if (fboundp mode
) (funcall mode
) (fundamental-mode))
395 (when lbd
(set (make-local-variable 'list-buffers-directory
) lbd
)))
397 ;;(set (make-local-variable 'cvs-buffer) cvs-buf)
399 (setq buffer-read-only t
)
400 (buffer-disable-undo))
403 (defun cvs-mode-kill-buffers ()
404 "Kill all the \"temporary\" buffers created by the *cvs* buffer."
406 (dolist (buf cvs-temp-buffers
) (ignore-errors (kill-buffer buf
))))
408 (defun cvs-make-cvs-buffer (dir &optional new
)
409 "Create the *cvs* buffer for directory DIR.
410 If non-nil, NEW means to create a new buffer no matter what."
411 ;; the real cvs-buffer creation
412 (setq dir
(cvs-expand-dir-name dir
))
413 (let* ((buffer-name (eval cvs-buffer-name
))
416 (eq cvs-reuse-cvs-buffer
'current
)
417 (cvs-buffer-p) ;reuse the current buffer if possible
419 ;; look for another cvs buffer visiting the same directory
422 (dolist (buffer (cons (current-buffer) (buffer-list)))
425 (case cvs-reuse-cvs-buffer
428 (or (cvs-string-prefix-p default-directory dir
)
429 (cvs-string-prefix-p dir default-directory
)))
430 (samedir (string= default-directory dir
)))
432 ;; we really have to create a new buffer:
433 ;; we temporarily bind cwd to "" to prevent
434 ;; create-file-buffer from using directory info
435 ;; unless it is explicitly in the cvs-buffer-name.
436 (cvs-get-buffer-create buffer-name new
))))
437 (with-current-buffer buffer
439 (and (string= dir default-directory
) (cvs-buffer-p)
442 (cvs-cleanup-collection cvs-cookies nil nil t
)
444 ;; setup from scratch
446 (setq default-directory dir
)
447 (setq buffer-read-only nil
)
450 Repository : " (directory-file-name (cvs-get-cvsroot)) "
451 Module : " (cvs-get-module) "
452 Working dir: " (abbreviate-file-name dir
) "
455 (setq buffer-read-only t
)
457 (set (make-local-variable 'list-buffers-directory
) buffer-name
)
458 ;;(set (make-local-variable 'cvs-temp-buffer) (cvs-temp-buffer))
459 (let ((cookies (ewoc-create 'cvs-fileinfo-pp
"\n" "")))
460 (set (make-local-variable 'cvs-cookies
) cookies
)
461 (add-hook 'kill-buffer-hook
463 (ignore-errors (kill-buffer cvs-temp-buffer
)))
468 (defun* cvs-cmd-do
(cmd dir flags fis new
469 &key cvsargs noexist dont-change-disc noshow
)
470 (let* ((dir (file-name-as-directory
471 (abbreviate-file-name (expand-file-name dir
))))
472 (cvsbuf (cvs-make-cvs-buffer dir new
)))
473 ;; Check that dir is under CVS control.
474 (unless (file-directory-p dir
)
475 (error "%s is not a directory" dir
))
476 (unless (or noexist
(file-directory-p (expand-file-name "CVS" dir
))
477 (file-expand-wildcards (expand-file-name "*/CVS" dir
)))
478 (error "%s does not contain CVS controlled files" dir
))
481 (cvs-mode-run cmd flags fis
482 :cvsargs cvsargs
:dont-change-disc dont-change-disc
)
485 (let ((pop-up-windows nil
)) (pop-to-buffer cvsbuf
)))))
486 ;; (funcall (if (and (boundp 'pop-up-frames) pop-up-frames)
487 ;; 'pop-to-buffer 'switch-to-buffer)
490 (defun cvs-run-process (args fis postprocess
&optional single-dir
)
491 (assert (cvs-buffer-p cvs-buffer
))
493 (let ((procbuf (current-buffer))
495 (single-dir (or single-dir
(eq cvs-execute-single-dir t
))))
498 (goto-char (point-max))
499 (unless (bolp) (let ((inhibit-read-only t
)) (insert "\n")))
500 ;; find the set of files we'll process in this round
501 (let* ((dir+files
+rest
502 (if (or (null fis
) (not single-dir
))
503 ;; not single-dir mode: just process the whole thing
504 (list "" (mapcar 'cvs-fileinfo-
>full-path fis
) nil
)
505 ;; single-dir mode: extract the same-dir-elements
506 (let ((dir (cvs-fileinfo->dir
(car fis
))))
507 ;; output the concerned dir so the parser can translate paths
508 (let ((inhibit-read-only t
))
509 (insert "pcl-cvs: descending directory " dir
"\n"))
510 ;; loop to find the same-dir-elems
511 (do* ((files () (cons (cvs-fileinfo->file fi
) files
))
513 (fi (car fis
) (car fis
)))
514 ((not (and fis
(string= dir
(cvs-fileinfo->dir fi
))))
515 (list dir files fis
))))))
516 (dir (nth 0 dir
+files
+rest
))
517 (files (nth 1 dir
+files
+rest
))
518 (rest (nth 2 dir
+files
+rest
)))
520 ;; setup the (current) process buffer
521 (set (make-local-variable 'cvs-postprocess
)
523 ;; this is the last invocation
525 ;; else, we have to register ourselves to be rerun on the rest
526 `(cvs-run-process ',args
',rest
',postprocess
',single-dir
)))
527 (add-hook 'kill-buffer-hook
529 (let ((proc (get-buffer-process (current-buffer))))
530 (when (processp proc
)
531 (set-process-filter proc nil
)
532 (set-process-sentinel proc nil
)
533 (delete-process proc
))))
536 ;; create the new process and setup the procbuffer correspondingly
537 (let* ((args (append (cvs-flags-query 'cvs-cvs-flags nil
'noquery
)
538 (if cvs-cvsroot
(list "-d" cvs-cvsroot
))
541 ;; If process-connection-type is nil and the repository
542 ;; is accessed via SSH, a bad interaction between libc,
543 ;; CVS and SSH can lead to garbled output.
544 ;; It might be a glibc-specific problem.
545 ;; Until the problem is cleared, we'll use a pty rather than
547 ;; (process-connection-type nil) ; Use a pipe, not a pty.
549 ;; the process will be run in the selected dir
550 (let ((default-directory (cvs-expand-dir-name dir
)))
551 (apply 'start-process
"cvs" procbuf cvs-program args
))))
552 (set-process-sentinel process
'cvs-sentinel
)
553 (set-process-filter process
'cvs-update-filter
)
554 (set-marker (process-mark process
) (point-max))
555 (ignore-errors (process-send-eof process
)) ;close its stdin to avoid hangs
557 ;; now finish setting up the cvs-buffer
559 (setq cvs-mode-line-process
(symbol-name (process-status process
)))
560 (force-mode-line-update)))))
562 ;; The following line is said to improve display updates on some
563 ;; emacsen. It shouldn't be needed, but it does no harm.
566 (defun cvs-update-header (args fis
) ; inline
568 (args (mapcar (lambda (arg)
570 ;; filter out the largish commit message
571 ((and (eq lastarg nil
) (string= arg
"commit"))
572 (setq lastarg
'commit
) arg
)
573 ((and (eq lastarg
'commit
) (string= arg
"-m"))
574 (setq lastarg
'-m
) arg
)
576 (setq lastarg
'done
) "<log message>")
577 ;; filter out the largish `admin -mrev:msg' message
578 ((and (eq lastarg nil
) (string= arg
"admin"))
579 (setq lastarg
'admin
) arg
)
580 ((and (eq lastarg
'admin
)
581 (string-match "\\`-m[^:]*:" arg
))
583 (concat (match-string 0 arg
) "<log message>"))
584 ;; Keep the rest as is.
587 ;; turn them into a string
588 (arg (cvs-strings->string
589 (append (cvs-flags-query 'cvs-cvs-flags nil
'noquery
)
590 (if cvs-cvsroot
(list "-d" cvs-cvsroot
))
592 (mapcar 'cvs-fileinfo-
>full-path fis
))))
593 (str (if args
(concat "-- Running " cvs-program
" " arg
" ...\n")
595 (if nil
(insert str
) ;inline
596 ;;(with-current-buffer cvs-buffer
597 (let* ((prev-msg (car (ewoc-get-hf cvs-cookies
)))
598 (tin (ewoc-nth cvs-cookies
0)))
599 ;; look for the first *real* fileinfo (to determine emptyness)
602 (memq (cvs-fileinfo->type
(ewoc-data tin
))
603 '(MESSAGE DIRCHANGE
)))
604 (setq tin
(ewoc-next cvs-cookies tin
)))
605 ;; cleanup the prev-msg
606 (when (string-match "Running \\(.*\\) ...\n" prev-msg
)
610 (match-string 1 prev-msg
)
612 ;; set the new header and footer
613 (ewoc-set-hf cvs-cookies
614 str
(concat "\n--------------------- "
615 (if tin
"End" "Empty")
616 " ---------------------\n"
620 (defun cvs-sentinel (proc msg
)
621 "Sentinel for the cvs update process.
622 This is responsible for parsing the output from the cvs update when
624 (when (memq (process-status proc
) '(signal exit
))
625 (if (null (buffer-name (process-buffer proc
)))
626 ;;(set-process-buffer proc nil)
627 (error "cvs' process buffer was killed")
628 (let* ((obuf (current-buffer))
629 (procbuffer (process-buffer proc
)))
630 (set-buffer (with-current-buffer procbuffer cvs-buffer
))
631 (setq cvs-mode-line-process
(symbol-name (process-status proc
)))
632 (force-mode-line-update)
633 (set-buffer procbuffer
)
634 (let ((cvs-postproc cvs-postprocess
))
635 ;; Since the buffer and mode line will show that the
636 ;; process is dead, we can delete it now. Otherwise it
637 ;; will stay around until M-x list-processes.
638 (delete-process proc
)
639 (setq cvs-postprocess nil
)
640 ;; do the postprocessing like parsing and such
641 (save-excursion (eval cvs-postproc
))
642 ;; check whether something is left
643 (unless cvs-postprocess
644 ;; IIRC, we enable undo again once the process is finished
645 ;; for cases where the output was inserted in *vc-diff* or
646 ;; in a file-like buffer. -stef
648 (with-current-buffer cvs-buffer
649 (cvs-update-header nil nil
) ;FIXME: might need to be inline
650 (message "CVS process has completed in %s" (buffer-name)))))
651 ;; This might not even be necessary
652 (set-buffer obuf
)))))
654 (defun cvs-parse-process (dcd &optional subdir old-fis
)
655 "Parse the output of a cvs process.
656 DCD is the `dont-change-disc' flag to use when parsing that output.
657 SUBDIR is the subdirectory (if any) where this command was run.
658 OLD-FIS is the list of fileinfos on which the cvs command was applied and
659 which should be considered up-to-date if they are missing from the output."
660 (let* ((fileinfos (cvs-parse-buffer 'cvs-parse-table dcd subdir
))
662 (with-current-buffer cvs-buffer
663 ;; Expand OLD-FIS to actual files.
666 (setq fis
(if (eq (cvs-fileinfo->type fi
) 'DIRCHANGE
)
667 (nconc (ewoc-collect cvs-cookies
'cvs-dir-member-p
668 (cvs-fileinfo->dir fi
))
672 ;; Drop OLD-FIS which were already up-to-date.
675 (unless (eq (cvs-fileinfo->type fi
) 'UP-TO-DATE
) (push fi fis
)))
677 ;; Add the new fileinfos to the ewoc.
678 (dolist (fi fileinfos
)
679 (setq last
(cvs-addto-collection cvs-cookies fi last
))
680 ;; This FI was in the output, so remove it from OLD-FIS.
681 (setq old-fis
(delq (ewoc-data last
) old-fis
)))
682 ;; Process the "silent output" (i.e. absence means up-to-date).
684 (setf (cvs-fileinfo->type fi
) 'UP-TO-DATE
)
685 (setq last
(cvs-addto-collection cvs-cookies fi last
)))
686 (setq fileinfos
(nconc old-fis fileinfos
))
687 ;; Clean up the ewoc as requested by the user.
688 (cvs-cleanup-collection cvs-cookies
689 (eq cvs-auto-remove-handled t
)
690 cvs-auto-remove-directories
692 ;; Revert buffers if necessary.
693 (when (and cvs-auto-revert
(not dcd
) (not cvs-from-vc
))
694 (cvs-revert-if-needed fileinfos
)))))
696 (defmacro defun-cvs-mode
(fun args docstring interact
&rest body
)
697 "Define a function to be used in a *cvs* buffer.
698 This will look for a *cvs* buffer and execute BODY in it.
699 Since the interactive arguments might need to be queried after
700 switching to the *cvs* buffer, the generic code is rather ugly,
701 but luckily we can often use simpler alternatives.
703 FUN can be either a symbol (i.e. STYLE is nil) or a cons (FUN . STYLE).
704 ARGS and DOCSTRING are the normal argument list.
705 INTERACT is the interactive specification or nil for non-commands.
707 STYLE can be either SIMPLE, NOARGS or DOUBLE. It's an error for it
708 to have any other value, unless other details of the function make it
709 clear what alternative to use.
710 - SIMPLE will get all the interactive arguments from the original buffer.
711 - NOARGS will get all the arguments from the *cvs* buffer and will
712 always behave as if called interactively.
713 - DOUBLE is the generic case."
714 (declare (debug (&define sexp lambda-list stringp
("interactive" interactive
) def-body
)))
715 (let ((style (cvs-cdr fun
))
718 ;; a trivial interaction, no need to move it
719 ((or (eq style
'SIMPLE
)
720 (null (nth 1 interact
))
721 (stringp (nth 1 interact
)))
722 `(defun ,fun
,args
,docstring
,interact
723 (cvs-mode! (lambda () ,@body
))))
725 ;; fun is only called interactively: move all the args to the inner fun
727 `(defun ,fun
() ,docstring
(interactive)
728 (cvs-mode! (lambda ,args
,interact
,@body
))))
732 (string-match ".*" docstring
)
733 (let ((line1 (match-string 0 docstring
))
734 (restdoc (substring docstring
(match-end 0)))
735 (fun-1 (intern (concat (symbol-name fun
) "-1"))))
738 ,(concat docstring
"\nThis function only works within a *cvs* buffer.
739 For interactive use, use `" (symbol-name fun
) "' instead.")
743 ,(concat line1
"\nWrapper function that switches to a *cvs* buffer
744 before calling the real function `" (symbol-name fun-1
) "'.\n")
746 (cvs-mode! ',fun-1
)))))
748 (t (error "unknown style %s in `defun-cvs-mode'" style
)))))
750 (defun-cvs-mode cvs-mode-kill-process
()
751 "Kill the temporary buffer and associated process."
753 (when (and (bufferp cvs-temp-buffer
) (buffer-name cvs-temp-buffer
))
754 (let ((proc (get-buffer-process cvs-temp-buffer
)))
755 (when proc
(delete-process proc
)))))
758 ;; Maintaining the collection in the face of updates
761 (defun cvs-addto-collection (c fi
&optional tin
)
762 "Add FI to C and return FI's corresponding tin.
763 FI is inserted in its proper place or maybe even merged with a preexisting
764 fileinfo if applicable.
765 TIN specifies an optional starting point."
766 (unless tin
(setq tin
(ewoc-nth c
0)))
767 (while (and tin
(cvs-fileinfo< fi
(ewoc-data tin
)))
768 (setq tin
(ewoc-prev c tin
)))
769 (if (null tin
) (ewoc-enter-first c fi
) ;empty collection
770 (assert (not (cvs-fileinfo< fi
(ewoc-data tin
))))
771 (let ((next-tin (ewoc-next c tin
)))
772 (while (not (or (null next-tin
)
773 (cvs-fileinfo< fi
(ewoc-data next-tin
))))
774 (setq tin next-tin next-tin
(ewoc-next c next-tin
)))
775 (if (or (cvs-fileinfo< (ewoc-data tin
) fi
)
776 (eq (cvs-fileinfo->type fi
) 'MESSAGE
))
777 ;; tin < fi < next-tin
778 (ewoc-enter-after c tin fi
)
780 (cvs-fileinfo-update (ewoc-data tin
) fi
)
781 (ewoc-invalidate c tin
)
782 ;; Move cursor back to where it belongs.
783 (when (bolp) (cvs-move-to-goal-column))
786 (defcustom cvs-cleanup-functions nil
787 "Functions to tweak the cleanup process.
788 The functions are called with a single argument (a FILEINFO) and should
789 return a non-nil value if that fileinfo should be removed."
791 :type
'(hook :options
(cvs-cleanup-removed)))
793 (defun cvs-cleanup-removed (fi)
794 "Non-nil if FI has been cvs-removed but still exists.
795 This is intended for use on `cvs-cleanup-functions' when you have cvs-removed
796 automatically generated files (which should hence not be under CVS control)
797 but can't commit the removal because the repository's owner doesn't understand
799 (and (or (eq (cvs-fileinfo->type fi
) 'REMOVED
)
800 (and (eq (cvs-fileinfo->type fi
) 'CONFLICT
)
801 (eq (cvs-fileinfo->subtype fi
) 'REMOVED
)))
802 (file-exists-p (cvs-fileinfo->full-path fi
))))
804 ;; called at the following times:
805 ;; - postparse ((eq cvs-auto-remove-handled t) cvs-auto-remove-directories nil)
806 ;; - pre-run ((eq cvs-auto-remove-handled 'delayed) nil t)
807 ;; - remove-handled (t (or cvs-auto-remove-directories 'handled) t)
808 ;; - cvs-cmd-do (nil nil t)
809 ;; - post-ignore (nil nil nil)
810 ;; - acknowledge (nil nil nil)
811 ;; - remove (nil nil nil)
812 (defun cvs-cleanup-collection (c rm-handled rm-dirs rm-msgs
)
813 "Remove undesired entries.
815 RM-HANDLED if non-nil means remove handled entries.
816 RM-DIRS behaves like `cvs-auto-remove-directories'.
817 RM-MSGS if non-nil means remove messages."
818 (let (last-fi first-dir
(rerun t
))
822 (setq last-fi
(cvs-create-fileinfo 'DEAD
"../" "" "")) ;place-holder
825 (let* ((type (cvs-fileinfo->type fi
))
826 (subtype (cvs-fileinfo->subtype fi
))
829 ;; remove temp messages and keep the others
830 (MESSAGE (not (or rm-msgs
(eq subtype
'TEMP
))))
834 (UP-TO-DATE (not rm-handled
))
836 (t (not (run-hook-with-args-until-success
837 'cvs-cleanup-functions fi
))))))
839 ;; mark dirs for removal
840 (when (and keep rm-dirs
841 (eq (cvs-fileinfo->type last-fi
) 'DIRCHANGE
)
842 (not (when first-dir
(setq first-dir nil
) t
))
843 (or (eq rm-dirs
'all
)
844 (not (cvs-string-prefix-p
845 (cvs-fileinfo->dir last-fi
)
846 (cvs-fileinfo->dir fi
)))
847 (and (eq type
'DIRCHANGE
) (eq rm-dirs
'empty
))
848 (eq subtype
'FOOTER
)))
849 (setf (cvs-fileinfo->type last-fi
) 'DEAD
)
851 (when keep
(setq last-fi fi
)))))
852 ;; remove empty last dir
855 (eq (cvs-fileinfo->type last-fi
) 'DIRCHANGE
))
856 (setf (cvs-fileinfo->type last-fi
) 'DEAD
)
859 (defun cvs-get-cvsroot ()
860 "Gets the CVSROOT for DIR."
861 (let ((cvs-cvsroot-file (expand-file-name "Root" "CVS")))
862 (or (cvs-file-to-string cvs-cvsroot-file t
)
867 (defun cvs-get-module ()
868 "Return the current CVS module.
869 This usually doesn't really work but is a handy initval in a prompt."
870 (let* ((repfile (expand-file-name "Repository" "CVS"))
871 (rep (cvs-file-to-string repfile t
)))
874 ((not (file-name-absolute-p rep
)) rep
)
876 (let* ((root (cvs-get-cvsroot))
877 (str (concat (file-name-as-directory (or root
"/")) " || " rep
)))
878 (if (and root
(string-match "\\(.*\\) || \\1\\(.*\\)\\'" str
))
880 (file-name-nondirectory rep
)))))))
885 ;;;; running a "cvs checkout".
889 (defun cvs-checkout (modules dir flags
)
890 "Run a 'cvs checkout MODULES' in DIR.
891 Feed the output to a *cvs* buffer, display it in the current window,
892 and run `cvs-mode' on it.
894 With a prefix argument, prompt for cvs FLAGS to use."
896 (list (cvs-string->strings
(read-string "Module(s): " (cvs-get-module)))
897 (read-directory-name "CVS Checkout Directory: "
898 nil default-directory nil
)
899 (cvs-add-branch-prefix
900 (cvs-flags-query 'cvs-checkout-flags
"cvs checkout flags"))))
902 (setf flags
(cvs-flags-query 'cvs-checkout-flags nil
'noquery
)))
903 (cvs-cmd-do "checkout" (or dir default-directory
)
904 (append flags modules
) nil
'new
909 ;;;; The code for running a "cvs update" and friends in various ways.
912 (defun-cvs-mode (cvs-mode-revert-buffer . SIMPLE
)
913 (&optional ignore-auto noconfirm
)
914 "Rerun `cvs-examine' on the current directory with the default flags."
916 (cvs-examine default-directory t
))
918 (defun cvs-query-directory (msg)
919 ;; last-command-char = ?\r hints that the command was run via M-x
920 (if (and (cvs-buffer-p)
921 (not current-prefix-arg
)
922 (not (eq last-command-char ?
\r)))
924 (read-directory-name msg nil default-directory nil
)))
927 (defun cvs-quickdir (dir &optional flags noshow
)
928 "Open a *cvs* buffer on DIR without running cvs.
929 With a prefix argument, prompt for a directory to use.
930 A prefix arg >8 (ex: \\[universal-argument] \\[universal-argument]),
931 prevents reuse of an existing *cvs* buffer.
932 Optional argument NOSHOW if non-nil means not to display the buffer.
934 (interactive (list (cvs-query-directory "CVS quickdir (directory): ")))
935 ;; FIXME: code duplication with cvs-cmd-do and cvs-parse-process
936 (let* ((dir (file-name-as-directory
937 (abbreviate-file-name (expand-file-name dir
))))
938 (new (> (prefix-numeric-value current-prefix-arg
) 8))
939 (cvsbuf (cvs-make-cvs-buffer dir new
))
941 ;; Check that dir is under CVS control.
942 (unless (file-directory-p dir
)
943 (error "%s is not a directory" dir
))
944 (unless (file-directory-p (expand-file-name "CVS" dir
))
945 (error "%s does not contain CVS controlled files" dir
))
947 (dolist (fi (cvs-fileinfo-from-entries ""))
948 (setq last
(cvs-addto-collection cvs-cookies fi last
)))
949 (cvs-cleanup-collection cvs-cookies
950 (eq cvs-auto-remove-handled t
)
951 cvs-auto-remove-directories
954 (let ((pop-up-windows nil
)) (pop-to-buffer cvsbuf
)))))
957 (defun cvs-examine (directory flags
&optional noshow
)
958 "Run a `cvs -n update' in the specified DIRECTORY.
959 That is, check what needs to be done, but don't change the disc.
960 Feed the output to a *cvs* buffer and run `cvs-mode' on it.
961 With a prefix argument, prompt for a directory and cvs FLAGS to use.
962 A prefix arg >8 (ex: \\[universal-argument] \\[universal-argument]),
963 prevents reuse of an existing *cvs* buffer.
964 Optional argument NOSHOW if non-nil means not to display the buffer."
965 (interactive (list (cvs-query-directory "CVS Examine (directory): ")
966 (cvs-flags-query 'cvs-update-flags
"cvs -n update flags")))
968 (setf flags
(cvs-flags-query 'cvs-update-flags nil
'noquery
)))
969 (cvs-cmd-do "update" directory flags nil
970 (> (prefix-numeric-value current-prefix-arg
) 8)
973 :dont-change-disc t
))
977 (defun cvs-update (directory flags
)
978 "Run a `cvs update' in the current working DIRECTORY.
979 Feed the output to a *cvs* buffer and run `cvs-mode' on it.
980 With a \\[universal-argument] prefix argument, prompt for a directory to use.
981 A prefix arg >8 (ex: \\[universal-argument] \\[universal-argument]),
982 prevents reuse of an existing *cvs* buffer.
983 The prefix is also passed to `cvs-flags-query' to select the FLAGS
985 (interactive (list (cvs-query-directory "CVS Update (directory): ")
986 (cvs-flags-query 'cvs-update-flags
"cvs update flags")))
988 (setf flags
(cvs-flags-query 'cvs-update-flags nil
'noquery
)))
989 (cvs-cmd-do "update" directory flags nil
990 (> (prefix-numeric-value current-prefix-arg
) 8)))
994 (defun cvs-status (directory flags
&optional noshow
)
995 "Run a `cvs status' in the current working DIRECTORY.
996 Feed the output to a *cvs* buffer and run `cvs-mode' on it.
997 With a prefix argument, prompt for a directory and cvs FLAGS to use.
998 A prefix arg >8 (ex: \\[universal-argument] \\[universal-argument]),
999 prevents reuse of an existing *cvs* buffer.
1000 Optional argument NOSHOW if non-nil means not to display the buffer."
1001 (interactive (list (cvs-query-directory "CVS Status (directory): ")
1002 (cvs-flags-query 'cvs-status-flags
"cvs status flags")))
1004 (setf flags
(cvs-flags-query 'cvs-status-flags nil
'noquery
)))
1005 (cvs-cmd-do "status" directory flags nil
1006 (> (prefix-numeric-value current-prefix-arg
) 8)
1007 :noshow noshow
:dont-change-disc t
))
1009 (defun cvs-update-filter (proc string
)
1010 "Filter function for pcl-cvs.
1011 This function gets the output that CVS sends to stdout. It inserts
1012 the STRING into (process-buffer PROC) but it also checks if CVS is waiting
1013 for a lock file. If so, it inserts a message cookie in the *cvs* buffer."
1015 (with-current-buffer (process-buffer proc
)
1016 (let ((inhibit-read-only t
))
1018 ;; Insert the text, moving the process-marker.
1019 (goto-char (process-mark proc
))
1021 (set-marker (process-mark proc
) (point))
1022 ;; FIXME: Delete any old lock message
1023 ;;(if (tin-nth cookies 1)
1024 ;; (tin-delete cookies
1025 ;; (tin-nth cookies 1)))
1026 ;; Check if CVS is waiting for a lock.
1027 (beginning-of-line 0) ;Move to beginning of last complete line.
1028 (when (looking-at "^[ a-z]+: \\(.*waiting for .*lock in \\(.*\\)\\)$")
1029 (let ((msg (match-string 1))
1030 (lock (match-string 2)))
1031 (with-current-buffer cvs-buffer
1032 (set (make-local-variable 'cvs-lock-file
) lock
)
1033 ;; display the lock situation in the *cvs* buffer:
1036 (cvs-create-fileinfo
1039 (when (file-exists-p lock
)
1040 (substitute-command-keys
1041 "\n\t(type \\[cvs-mode-delete-lock] to delete it)")))
1043 (pop-to-buffer (current-buffer))
1044 (goto-char (point-max))
1049 ;;;; The cvs-mode and its associated commands.
1052 (cvs-prefix-define cvs-force-command
"" "" '("/F") cvs-qtypedesc-string1
)
1053 (defun-cvs-mode cvs-mode-force-command
(arg)
1054 "Force the next cvs command to operate on all the selected files.
1055 By default, cvs commands only operate on files on which the command
1056 \"makes sense\". This overrides the safety feature on the next cvs command.
1057 It actually behaves as a toggle. If prefixed by \\[universal-argument] \\[universal-argument],
1058 the override will persist until the next toggle."
1060 (cvs-prefix-set 'cvs-force-command arg
))
1062 (put 'cvs-mode
'mode-class
'special
)
1063 (define-derived-mode cvs-mode fundamental-mode
"CVS"
1064 "Mode used for PCL-CVS, a frontend to CVS.
1065 Full documentation is in the Texinfo file."
1066 (setq mode-line-process
1067 '("" cvs-force-command cvs-ignore-marks-modif
1068 ":" (cvs-branch-prefix
1069 ("" cvs-branch-prefix
(cvs-secondary-branch-prefix
1070 ("->" cvs-secondary-branch-prefix
))))
1071 " " cvs-mode-line-process
))
1072 (buffer-disable-undo)
1073 ;;(set (make-local-variable 'goal-column) cvs-cursor-column)
1074 (set (make-local-variable 'revert-buffer-function
) 'cvs-mode-revert-buffer
)
1075 (setq truncate-lines t
)
1076 (cvs-prefix-make-local 'cvs-branch-prefix
)
1077 (cvs-prefix-make-local 'cvs-secondary-branch-prefix
)
1078 (cvs-prefix-make-local 'cvs-force-command
)
1079 (cvs-prefix-make-local 'cvs-ignore-marks-modif
)
1080 (make-local-variable 'cvs-mode-line-process
)
1081 (make-local-variable 'cvs-temp-buffers
))
1084 (defun cvs-buffer-p (&optional buffer
)
1085 "Return whether the (by default current) BUFFER is a `cvs-mode' buffer."
1087 (if buffer
(set-buffer buffer
))
1088 (and (eq major-mode
'cvs-mode
))))
1090 (defun cvs-buffer-check ()
1091 "Check that the current buffer follows cvs-buffer's conventions."
1092 (let ((buf (current-buffer))
1094 (or (and (setq check
'collection
)
1095 (eq (ewoc-buffer cvs-cookies
) buf
)
1096 (setq check
'cvs-temp-buffer
)
1097 (or (null cvs-temp-buffer
)
1098 (null (buffer-name cvs-temp-buffer
))
1099 (and (eq (with-current-buffer cvs-temp-buffer cvs-buffer
) buf
)
1100 (equal (with-current-buffer cvs-temp-buffer
1102 default-directory
)))
1104 (error "Inconsistent %s in buffer %s" check
(buffer-name buf
)))))
1107 (defun cvs-mode-quit ()
1108 "Quit PCL-CVS, killing the *cvs* buffer."
1110 (and (y-or-n-p "Quit pcl-cvs? ") (kill-buffer (current-buffer))))
1115 "Display help for various PCL-CVS commands."
1117 (if (eq last-command
'cvs-help
)
1118 (describe-function 'cvs-mode
) ; would need minor-mode for log-edit-mode
1120 (substitute-command-keys
1121 "`\\[cvs-help]':help `\\[cvs-mode-add]':add `\\[cvs-mode-commit]':commit \
1122 `\\[cvs-mode-diff-map]':diff* `\\[cvs-mode-log]':log \
1123 `\\[cvs-mode-remove]':remove `\\[cvs-mode-status]':status \
1124 `\\[cvs-mode-undo]':undo"))))
1126 ;; Move around in the buffer
1128 (defun cvs-move-to-goal-column ()
1129 (let* ((eol (line-end-position))
1130 (fpos (next-single-property-change (point) 'cvs-goal-column nil eol
)))
1134 (defun-cvs-mode cvs-mode-previous-line
(arg)
1135 "Go to the previous line.
1136 If a prefix argument is given, move by that many lines."
1138 (ewoc-goto-prev cvs-cookies arg
)
1139 (cvs-move-to-goal-column))
1141 (defun-cvs-mode cvs-mode-next-line
(arg)
1142 "Go to the next line.
1143 If a prefix argument is given, move by that many lines."
1145 (ewoc-goto-next cvs-cookies arg
)
1146 (cvs-move-to-goal-column))
1152 (defun-cvs-mode cvs-mode-mark
(&optional arg
)
1153 "Mark the fileinfo on the current line.
1154 If the fileinfo is a directory, all the contents of that directory are
1155 marked instead. A directory can never be marked."
1157 (let* ((tin (ewoc-locate cvs-cookies
))
1158 (fi (ewoc-data tin
)))
1159 (if (eq (cvs-fileinfo->type fi
) 'DIRCHANGE
)
1160 ;; it's a directory: let's mark all files inside
1163 (when (cvs-dir-member-p f dir
)
1164 (setf (cvs-fileinfo->marked f
)
1165 (not (if (eq arg
'toggle
) (cvs-fileinfo->marked f
) arg
)))
1166 t
)) ;Tell cookie to redisplay this cookie.
1168 (cvs-fileinfo->dir fi
))
1169 ;; not a directory: just do the obvious
1170 (setf (cvs-fileinfo->marked fi
)
1171 (not (if (eq arg
'toggle
) (cvs-fileinfo->marked fi
) arg
)))
1172 (ewoc-invalidate cvs-cookies tin
)
1173 (cvs-mode-next-line 1))))
1175 (defun cvs-mouse-toggle-mark (e)
1176 "Toggle the mark of the entry under the mouse."
1180 (cvs-mode-mark 'toggle
)))
1182 (defun-cvs-mode cvs-mode-unmark
()
1183 "Unmark the fileinfo on the current line."
1187 (defun-cvs-mode cvs-mode-mark-all-files
()
1190 (ewoc-map (lambda (cookie)
1191 (unless (eq (cvs-fileinfo->type cookie
) 'DIRCHANGE
)
1192 (setf (cvs-fileinfo->marked cookie
) t
)))
1195 (defun-cvs-mode (cvs-mode-mark-on-state . SIMPLE
) (state)
1196 "Mark all files in state STATE."
1204 (cvs-mode-marked nil nil
:read-only t
:one t
:noquery t
))))
1210 "Mark files in state" (if default
(concat " [" default
"]")) ": ")
1212 (list (downcase (symbol-name (car x
)))))
1214 nil t nil nil default
))))))
1215 (ewoc-map (lambda (fi)
1216 (when (eq (cvs-fileinfo->type fi
) state
)
1217 (setf (cvs-fileinfo->marked fi
) t
)))
1220 (defun-cvs-mode cvs-mode-mark-matching-files
(regex)
1221 "Mark all files matching REGEX."
1222 (interactive "sMark files matching: ")
1223 (ewoc-map (lambda (cookie)
1224 (when (and (not (eq (cvs-fileinfo->type cookie
) 'DIRCHANGE
))
1225 (string-match regex
(cvs-fileinfo->file cookie
)))
1226 (setf (cvs-fileinfo->marked cookie
) t
)))
1229 (defun-cvs-mode cvs-mode-unmark-all-files
()
1231 Directories are also unmarked, but that doesn't matter, since
1232 they should always be unmarked."
1234 (ewoc-map (lambda (cookie)
1235 (setf (cvs-fileinfo->marked cookie
) nil
)
1239 (defun-cvs-mode cvs-mode-unmark-up
()
1240 "Unmark the file on the previous line."
1242 (let ((tin (ewoc-goto-prev cvs-cookies
1)))
1244 (setf (cvs-fileinfo->marked
(ewoc-data tin
)) nil
)
1245 (ewoc-invalidate cvs-cookies tin
))))
1247 (defconst cvs-ignore-marks-alternatives
1248 '(("toggle-marks" .
"/TM")
1249 ("force-marks" .
"/FM")
1250 ("ignore-marks" .
"/IM")))
1252 (cvs-prefix-define cvs-ignore-marks-modif
1253 "Prefix to decide whether to ignore marks or not."
1255 (mapcar 'cdr cvs-ignore-marks-alternatives
)
1256 (cvs-qtypedesc-create
1257 (lambda (str) (cdr (assoc str cvs-ignore-marks-alternatives
)))
1258 (lambda (obj) (car (rassoc obj cvs-ignore-marks-alternatives
)))
1259 (lambda () cvs-ignore-marks-alternatives
)
1262 (defun-cvs-mode cvs-mode-toggle-marks
(arg)
1263 "Toggle whether the next CVS command uses marks.
1264 See `cvs-prefix-set' for further description of the behavior.
1265 \\[universal-argument] 1 selects `force-marks',
1266 \\[universal-argument] 2 selects `ignore-marks',
1267 \\[universal-argument] 3 selects `toggle-marks'."
1269 (cvs-prefix-set 'cvs-ignore-marks-modif arg
))
1271 (defun cvs-ignore-marks-p (cmd &optional read-only
)
1272 (let ((default (if (member cmd cvs-invert-ignore-marks
)
1273 (not cvs-default-ignore-marks
)
1274 cvs-default-ignore-marks
))
1275 (modif (cvs-prefix-get 'cvs-ignore-marks-modif read-only
)))
1277 ((equal modif
"/IM") t
)
1278 ((equal modif
"/TM") (not default
))
1279 ((equal modif
"/FM") nil
)
1282 (defun cvs-mode-mark-get-modif (cmd)
1283 (if (cvs-ignore-marks-p cmd
'read-only
) "/IM" "/FM"))
1285 (defvar cvs-minor-current-files
)
1286 (defun cvs-get-marked (&optional ignore-marks ignore-contents
)
1287 "Return a list of all selected fileinfos.
1288 If there are any marked tins, and IGNORE-MARKS is nil, return them.
1289 Otherwise, if the cursor selects a directory, and IGNORE-CONTENTS is
1290 nil, return all files in it, else return just the directory.
1291 Otherwise return (a list containing) the file the cursor points to, or
1292 an empty list if it doesn't point to a file at all.
1294 Args: &optional IGNORE-MARKS IGNORE-CONTENTS."
1297 (dolist (fi (if (and (boundp 'cvs-minor-current-files
)
1298 (consp cvs-minor-current-files
))
1301 (if (cvs-fileinfo-p f
) f
1302 (let ((f (file-relative-name f
)))
1303 (if (file-directory-p f
)
1304 (cvs-create-fileinfo
1305 'DIRCHANGE
(file-name-as-directory f
) "." "")
1306 (let ((dir (file-name-directory f
))
1307 (file (file-name-nondirectory f
)))
1308 (cvs-create-fileinfo
1309 'UNKNOWN
(or dir
"") file
""))))))
1310 cvs-minor-current-files
)
1311 (or (and (not ignore-marks
)
1312 (ewoc-collect cvs-cookies
'cvs-fileinfo-
>marked
))
1313 (list (ewoc-data (ewoc-locate cvs-cookies
))))))
1315 (if (or ignore-contents
(not (eq (cvs-fileinfo->type fi
) 'DIRCHANGE
)))
1317 ;; If a directory is selected, return members, if any.
1319 (append (ewoc-collect
1320 cvs-cookies
'cvs-dir-member-p
(cvs-fileinfo->dir fi
))
1324 (defun* cvs-mode-marked
(filter &optional cmd
1325 &key read-only one file noquery
)
1326 "Get the list of marked FIS.
1327 CMD is used to determine whether to use the marks or not.
1328 Only files for which FILTER is applicable are returned.
1329 If READ-ONLY is non-nil, the current toggling is left intact.
1330 If ONE is non-nil, marks are ignored and a single FI is returned.
1331 If FILE is non-nil, directory entries won't be selected."
1332 (unless cmd
(setq cmd
(symbol-name filter
)))
1333 (let* ((fis (cvs-get-marked (or one
(cvs-ignore-marks-p cmd read-only
))
1335 (cvs-applicable-p 'DIRCHANGE filter
))))
1336 (force (cvs-prefix-get 'cvs-force-command
))
1337 (fis (car (cvs-partition
1338 (lambda (fi) (cvs-applicable-p fi
(and (not force
) filter
)))
1340 (when (and (or (null fis
) (and one
(cdr fis
))) (not noquery
))
1341 (message (if (null fis
)
1342 "`%s' is not applicable to any of the selected files."
1343 "`%s' is only applicable to a single file.") cmd
)
1345 (setq fis
(list (cvs-insert-file
1346 (read-file-name (format "File to %s: " cmd
))))))
1347 (if one
(car fis
) fis
)))
1349 (defun cvs-enabledp (filter)
1350 "Determine whether FILTER applies to at least one of the selected files."
1351 (ignore-errors (cvs-mode-marked filter nil
:read-only t
:noquery t
)))
1353 (defun cvs-mode-files (&rest -cvs-mode-files-args
)
1356 (mapcar 'cvs-fileinfo-
>full-path
1357 (apply 'cvs-mode-marked -cvs-mode-files-args
)))))
1360 ;; Interface between Log-Edit and PCL-CVS
1363 (defun cvs-mode-commit-setup ()
1364 "Run `cvs-mode-commit' with setup."
1366 (cvs-mode-commit 'force
))
1368 (defcustom cvs-mode-commit-hook nil
1369 "Hook run after setting up the commit buffer."
1371 :options
'(cvs-mode-diff)
1374 (defun cvs-mode-commit (setup)
1375 "Check in all marked files, or the current file.
1376 The user will be asked for a log message in a buffer.
1377 The buffer's mode and name is determined by the \"message\" setting
1378 of `cvs-buffer-name-alist'.
1379 The POSTPROC specified there (typically `log-edit') is then called,
1380 passing it the SETUP argument."
1382 ;; It seems that the save-excursion that happens if I use the better
1383 ;; form of `(cvs-mode! (lambda ...))' screws up a couple things which
1384 ;; end up being rather annoying (like log-edit-mode's message being
1385 ;; displayed in the wrong minibuffer).
1387 (let ((buf (cvs-temp-buffer "message" 'normal
'nosetup
))
1388 (lbd list-buffers-directory
)
1389 (setupfun (or (nth 2 (cdr (assoc "message" cvs-buffer-name-alist
)))
1391 (funcall setupfun
'cvs-do-commit setup
'cvs-commit-filelist buf
)
1392 (set (make-local-variable 'cvs-minor-wrap-function
) 'cvs-commit-minor-wrap
)
1393 (set (make-local-variable 'list-buffers-directory
) lbd
)
1394 (run-hooks 'cvs-mode-commit-hook
)))
1396 (defun cvs-commit-minor-wrap (buf f
)
1397 (let ((cvs-ignore-marks-modif (cvs-mode-mark-get-modif "commit")))
1400 (defun cvs-commit-filelist ()
1401 (cvs-mode-files 'commit nil
:read-only t
:file t
:noquery t
))
1403 (defun cvs-do-commit (flags)
1404 "Do the actual commit, using the current buffer as the log message."
1405 (interactive (list (cvs-flags-query 'cvs-commit-flags
"cvs commit flags")))
1406 (let ((msg (buffer-substring-no-properties (point-min) (point-max))))
1408 ;;(pop-to-buffer cvs-buffer)
1409 (cvs-mode-do "commit" (list* "-m" msg flags
) 'commit
)))
1412 ;;;; Editing existing commit log messages.
1414 (defun cvs-edit-log-text-at-point ()
1417 (when (re-search-backward "^revision " nil t
)
1419 (if (looking-at "date:") (forward-line 1))
1420 (if (looking-at "branches:") (forward-line 1))
1423 (if (re-search-forward
1424 "^\\(-\\{28\\}\\|=\\{77\\}\\|revision [.0-9]+\\)$"
1429 (defun cvs-mode-edit-log (rev &optional text
)
1430 "Edit the log message at point.
1431 This is best called from a `log-view-mode' buffer."
1434 (or (cvs-mode! (lambda () (cvs-prefix-get 'cvs-branch-prefix
)))
1435 (read-string "Revision to edit: "))
1436 (cvs-edit-log-text-at-point)))
1437 ;; It seems that the save-excursion that happens if I use the better
1438 ;; form of `(cvs-mode! (lambda ...))' screws up a couple things which
1439 ;; end up being rather annoying (like log-edit-mode's message being
1440 ;; displayed in the wrong minibuffer).
1442 (let ((buf (cvs-temp-buffer "message" 'normal
'nosetup
))
1443 (lbd list-buffers-directory
)
1444 (setupfun (or (nth 2 (cdr (assoc "message" cvs-buffer-name-alist
)))
1446 (funcall setupfun
'cvs-do-edit-log nil
'cvs-edit-log-filelist buf
)
1447 (when text
(erase-buffer) (insert text
))
1448 (set (make-local-variable 'cvs-edit-log-revision
) rev
)
1449 (set (make-local-variable 'cvs-minor-wrap-function
) 'cvs-edit-log-minor-wrap
)
1450 (set (make-local-variable 'list-buffers-directory
) lbd
)
1451 ;; (run-hooks 'cvs-mode-commit-hook)
1454 (defun cvs-edit-log-minor-wrap (buf f
)
1455 (let ((cvs-ignore-marks-modif (cvs-mode-mark-get-modif "commit")))
1458 (defun cvs-edit-log-filelist ()
1459 (cvs-mode-files nil nil
:read-only t
:file t
:noquery t
))
1461 (defun cvs-do-edit-log (rev)
1462 "Do the actual commit, using the current buffer as the log message."
1463 (interactive (list cvs-edit-log-revision
))
1464 (let ((msg (buffer-substring-no-properties (point-min) (point-max))))
1466 (cvs-mode-do "admin" (list (concat "-m" rev
":" msg
)) nil
)))
1470 ;;;; CVS Mode commands
1473 (defun-cvs-mode (cvs-mode-insert . NOARGS
) (file)
1474 "Insert an entry for a specific file into the current listing.
1475 This is typically used if the file is up-to-date (or has been added
1476 outside of PCL-CVS) and one wants to do some operation on it."
1478 (list (read-file-name
1480 ;; Can't use ignore-errors here because interactive
1481 ;; specs aren't byte-compiled.
1483 (file-name-as-directory
1486 (cvs-mode-marked nil nil
:read-only t
:one t
:noquery t
))))
1488 (cvs-insert-file file
))
1490 (defun cvs-insert-file (file)
1491 "Insert FILE (and its contents if it's a dir) and return its FI."
1492 (let ((file (file-relative-name (directory-file-name file
))) last
)
1493 (dolist (fi (cvs-fileinfo-from-entries file
))
1494 (setq last
(cvs-addto-collection cvs-cookies fi last
)))
1495 ;; There should have been at least one entry.
1496 (goto-char (ewoc-location last
))
1499 (defun cvs-mark-fis-dead (fis)
1500 ;; Helper function, introduced because of the need for macro-expansion.
1502 (setf (cvs-fileinfo->type fi
) 'DEAD
)))
1504 (defun-cvs-mode (cvs-mode-add . SIMPLE
) (flags)
1505 "Add marked files to the cvs repository.
1506 With prefix argument, prompt for cvs flags."
1507 (interactive (list (cvs-flags-query 'cvs-add-flags
"cvs add flags")))
1508 (let ((fis (cvs-mode-marked 'add
))
1509 (needdesc nil
) (dirs nil
))
1510 ;; find directories and look for fis needing a description
1513 ((file-directory-p (cvs-fileinfo->full-path fi
)) (push fi dirs
))
1514 ((eq (cvs-fileinfo->type fi
) 'UNKNOWN
) (setq needdesc t
))))
1515 ;; prompt for description if necessary
1516 (let* ((msg (if (and needdesc
1517 (or current-prefix-arg
(not cvs-add-default-message
)))
1518 (read-from-minibuffer "Enter description: ")
1519 (or cvs-add-default-message
"")))
1520 (flags (list* "-m" msg flags
))
1522 ;; setup postprocessing for the directory entries
1524 `((cvs-run-process (list "-n" "update")
1526 '(cvs-parse-process t
))
1527 (cvs-mark-fis-dead ',dirs
)))))
1528 (cvs-mode-run "add" flags fis
:postproc postproc
))))
1530 (defun-cvs-mode (cvs-mode-diff . DOUBLE
) (flags)
1531 "Diff the selected files against the repository.
1532 This command compares the files in your working area against the
1533 revision which they are based upon."
1535 (list (cvs-add-branch-prefix
1536 (cvs-add-secondary-branch-prefix
1537 (cvs-flags-query 'cvs-diff-flags
"cvs diff flags")))))
1538 (cvs-mode-do "diff" flags
'diff
1539 :show t
)) ;; :ignore-exit t
1541 (defun-cvs-mode (cvs-mode-diff-head . SIMPLE
) (flags)
1542 "Diff the selected files against the head of the current branch.
1543 See ``cvs-mode-diff'' for more info."
1544 (interactive (list (cvs-flags-query 'cvs-diff-flags
"cvs diff flags")))
1545 (cvs-mode-diff-1 (cons "-rHEAD" flags
)))
1547 (defun-cvs-mode (cvs-mode-diff-vendor . SIMPLE
) (flags)
1548 "Diff the selected files against the head of the vendor branch.
1549 See ``cvs-mode-diff'' for more info."
1550 (interactive (list (cvs-flags-query 'cvs-diff-flags
"cvs diff flags")))
1551 (cvs-mode-diff-1 (cons (concat "-r" cvs-vendor-branch
) flags
)))
1553 ;; sadly, this is not provided by cvs, so we have to roll our own
1554 (defun-cvs-mode (cvs-mode-diff-backup . SIMPLE
) (flags)
1555 "Diff the files against the backup file.
1556 This command can be used on files that are marked with \"Merged\"
1557 or \"Conflict\" in the *cvs* buffer."
1558 (interactive (list (cvs-flags-query 'cvs-diff-flags
"diff flags")))
1559 (unless (listp flags
) (error "flags should be a list of strings"))
1561 (let* ((filter 'diff
)
1562 (marked (cvs-get-marked (cvs-ignore-marks-p "diff")))
1563 ;;(tins (cvs-filter-applicable filter marked))
1564 (fis (car (cvs-partition 'cvs-fileinfo-
>backup-file marked
))))
1566 (error "No files with a backup file selected!"))
1567 ;; let's extract some info into the environment for `buffer-name'
1568 (let* ((dir (cvs-fileinfo->dir
(car fis
)))
1569 (file (cvs-fileinfo->file
(car fis
))))
1570 (set-buffer (cvs-temp-buffer "diff")))
1571 (message "cvs diff backup...")
1572 (cvs-execute-single-file-list fis
'cvs-diff-backup-extractor
1573 cvs-diff-program flags
))
1574 (message "cvs diff backup... Done."))
1576 (defun cvs-diff-backup-extractor (fileinfo)
1577 "Return the filename and the name of the backup file as a list.
1578 Signal an error if there is no backup file."
1579 (let ((backup-file (cvs-fileinfo->backup-file fileinfo
)))
1581 (error "%s has no backup file" (cvs-fileinfo->full-path fileinfo
)))
1582 (list backup-file
(cvs-fileinfo->full-path fileinfo
))))
1587 (defun cvs-emerge-diff (b1 b2
) (emerge-buffers b1 b2 b1
))
1588 (defun cvs-emerge-merge (b1 b2 base out
)
1589 (emerge-buffers-with-ancestor b1 b2 base
(find-file-noselect out
)))
1595 (defvar ediff-after-quit-destination-buffer
)
1596 (defvar cvs-transient-buffers
)
1597 (defun cvs-ediff-startup-hook ()
1598 (add-hook 'ediff-after-quit-hook-internal
1600 (cvs-ediff-exit-hook
1601 ',ediff-after-quit-destination-buffer
',cvs-transient-buffers
))
1604 (defun cvs-ediff-exit-hook (cvs-buf tmp-bufs
)
1605 ;; kill the temp buffers (and their associated windows)
1606 (dolist (tb tmp-bufs
)
1607 (when (and tb
(buffer-live-p tb
) (not (buffer-modified-p tb
)))
1608 (let ((win (get-buffer-window tb t
)))
1610 (when (window-live-p win
) (ignore-errors (delete-window win
))))))
1611 ;; switch back to the *cvs* buffer
1612 (when (and cvs-buf
(buffer-live-p cvs-buf
)
1613 (not (get-buffer-window cvs-buf t
)))
1614 (ignore-errors (switch-to-buffer cvs-buf
))))
1616 (defun cvs-ediff-diff (b1 b2
)
1617 (let ((ediff-after-quit-destination-buffer (current-buffer))
1618 (startup-hook '(cvs-ediff-startup-hook)))
1619 (ediff-buffers b1 b2 startup-hook
'ediff-revision
)))
1621 (defun cvs-ediff-merge (b1 b2 base out
)
1622 (let ((ediff-after-quit-destination-buffer (current-buffer))
1623 (startup-hook '(cvs-ediff-startup-hook)))
1624 (ediff-merge-buffers-with-ancestor
1625 b1 b2 base startup-hook
1626 'ediff-merge-revisions-with-ancestor
1630 ;; Interactive merge/diff support.
1633 (defun cvs-retrieve-revision (fileinfo rev
)
1634 "Retrieve the given REVision of the file in FILEINFO into a new buffer."
1635 (let* ((file (cvs-fileinfo->full-path fileinfo
))
1636 (buffile (concat file
"." rev
)))
1637 (or (find-buffer-visiting buffile
)
1638 (with-current-buffer (create-file-buffer buffile
)
1639 (message "Retrieving revision %s..." rev
)
1640 (let ((res (call-process cvs-program nil t nil
1641 "-q" "update" "-p" "-r" rev file
)))
1642 (when (and res
(not (and (equal 0 res
))))
1643 (error "Something went wrong retrieving revision %s: %s" rev res
))
1644 (set-buffer-modified-p nil
)
1645 (let ((buffer-file-name (expand-file-name file
)))
1647 (toggle-read-only 1)
1648 (message "Retrieving revision %s... Done" rev
)
1649 (current-buffer))))))
1651 (eval-and-compile (autoload 'smerge-ediff
"smerge-mode"))
1653 ;; FIXME: The user should be able to specify ancestor/head/backup and we should
1654 ;; provide sensible defaults when merge info is unavailable (rather than rely
1655 ;; on smerge-ediff). Also provide sane defaults for need-merge files.
1656 (defun-cvs-mode cvs-mode-imerge
()
1657 "Merge interactively appropriate revisions of the selected file."
1659 (let ((fi (cvs-mode-marked 'merge nil
:one t
:file t
)))
1660 (let ((merge (cvs-fileinfo->merge fi
))
1661 (file (cvs-fileinfo->full-path fi
))
1662 (backup-file (cvs-fileinfo->backup-file fi
)))
1663 (if (not (and merge backup-file
))
1664 (let ((buf (find-file-noselect file
)))
1665 (message "Missing merge info or backup file, using VC.")
1666 (with-current-buffer buf
1668 (let* ((ancestor-buf (cvs-retrieve-revision fi
(car merge
)))
1669 (head-buf (cvs-retrieve-revision fi
(cdr merge
)))
1670 (backup-buf (let ((auto-mode-alist nil
))
1671 (find-file-noselect backup-file
)))
1672 ;; this binding is used by cvs-ediff-startup-hook
1673 (cvs-transient-buffers (list ancestor-buf backup-buf head-buf
)))
1674 (with-current-buffer backup-buf
1675 (let ((buffer-file-name (expand-file-name file
)))
1677 (funcall (cdr cvs-idiff-imerge-handlers
)
1678 backup-buf head-buf ancestor-buf file
))))))
1680 (cvs-flags-define cvs-idiff-version
1681 (list "BASE" cvs-vendor-branch cvs-vendor-branch
"BASE" "BASE")
1682 "version: " cvs-qtypedesc-tag
)
1684 (defun-cvs-mode (cvs-mode-idiff . NOARGS
) (&optional rev1 rev2
)
1685 "Diff interactively current file to revisions."
1687 (let* ((rev1 (cvs-prefix-get 'cvs-branch-prefix
))
1688 (rev2 (and rev1
(cvs-prefix-get 'cvs-secondary-branch-prefix
))))
1689 (list (or rev1
(cvs-flags-query 'cvs-idiff-version
))
1691 (let ((fi (cvs-mode-marked 'diff
"idiff" :one t
:file t
)))
1692 (let* ((file (cvs-fileinfo->full-path fi
))
1693 (rev1-buf (cvs-retrieve-revision fi
(or rev1
"BASE")))
1694 (rev2-buf (if rev2
(cvs-retrieve-revision fi rev2
)))
1695 ;; this binding is used by cvs-ediff-startup-hook
1696 (cvs-transient-buffers (list rev1-buf rev2-buf
)))
1697 (funcall (car cvs-idiff-imerge-handlers
)
1698 rev1-buf
(or rev2-buf
(find-file-noselect file
))))))
1700 (defun-cvs-mode (cvs-mode-idiff-other . NOARGS
) ()
1701 "Diff interactively current file to revisions."
1703 (let* ((rev1 (cvs-prefix-get 'cvs-branch-prefix
))
1704 (rev2 (and rev1
(cvs-prefix-get 'cvs-secondary-branch-prefix
)))
1705 (fis (cvs-mode-marked 'diff
"idiff" :file t
)))
1706 (when (> (length fis
) 2)
1707 (error "idiff-other cannot be applied to more than 2 files at a time"))
1708 (let* ((fi1 (car fis
))
1709 (rev1-buf (if rev1
(cvs-retrieve-revision fi1 rev1
)
1710 (find-file-noselect (cvs-fileinfo->full-path fi1
))))
1713 (let ((fi2 (nth 1 fis
)))
1715 (if rev2
(cvs-retrieve-revision fi2 rev2
)
1716 (find-file-noselect (cvs-fileinfo->full-path fi2
)))))
1717 (error "idiff-other doesn't know what other file/buffer to use"))
1718 (let* (;; this binding is used by cvs-ediff-startup-hook
1719 (cvs-transient-buffers (list rev1-buf rev2-buf
)))
1720 (funcall (car cvs-idiff-imerge-handlers
)
1721 rev1-buf rev2-buf
)))))
1724 (defun cvs-is-within-p (fis dir
)
1725 "Non-nil is buffer is inside one of FIS (in DIR)."
1726 (when (stringp buffer-file-name
)
1727 (setq buffer-file-name
(expand-file-name buffer-file-name
))
1729 (dolist (fi (or fis
(list (cvs-create-fileinfo 'DIRCHANGE
"" "." ""))))
1730 (when (cvs-string-prefix-p
1731 (expand-file-name (cvs-fileinfo->full-path fi
) dir
)
1736 (defun* cvs-mode-run
(cmd flags fis
1737 &key
(buf (cvs-temp-buffer))
1738 dont-change-disc cvsargs postproc
)
1739 "Generic cvs-mode-<foo> function.
1740 Executes `cvs CVSARGS CMD FLAGS FIS'.
1741 BUF is the buffer to be used for cvs' output.
1742 DONT-CHANGE-DISC non-nil indicates that the command will not change the
1743 contents of files. This is only used by the parser.
1744 POSTPROC is a list of expressions to be evaluated at the very end (after
1745 parsing if applicable). It will be prepended with `progn' is necessary."
1746 (let ((def-dir default-directory
))
1747 ;; Save the relevant buffers
1748 (save-some-buffers nil
(lambda () (cvs-is-within-p fis def-dir
))))
1749 (unless (listp flags
) (error "flags should be a list of strings"))
1750 ;; Some w32 versions of CVS don't like an explicit . too much.
1751 (when (and (car fis
) (null (cdr fis
))
1752 (eq (cvs-fileinfo->type
(car fis
)) 'DIRCHANGE
)
1753 ;; (equal (cvs-fileinfo->file (car fis)) ".")
1754 (equal (cvs-fileinfo->dir
(car fis
)) ""))
1756 (let* ((cvs-buf (current-buffer))
1757 (single-dir (or (not (listp cvs-execute-single-dir
))
1758 (member cmd cvs-execute-single-dir
)))
1759 (parse (member cmd cvs-parse-known-commands
))
1760 (args (append cvsargs
(list cmd
) flags
))
1761 (after-mode (nth 2 (cdr (assoc cmd cvs-buffer-name-alist
)))))
1762 (cvs-cleanup-collection cvs-cookies
;cleanup remaining messages
1763 (eq cvs-auto-remove-handled
'delayed
) nil t
)
1764 (when (fboundp after-mode
)
1765 (setq postproc
(append postproc
`((,after-mode
)))))
1768 (when (member cmd
'("status" "update")) ;FIXME: Yuck!!
1769 ;; absence of `cvs update' output has a specific meaning.
1770 (or fis
(list (cvs-create-fileinfo 'DIRCHANGE
"" "." ""))))))
1771 (push `(cvs-parse-process ',dont-change-disc nil
',old-fis
) postproc
)))
1772 (setq postproc
(if (cdr postproc
) (cons 'progn postproc
) (car postproc
)))
1773 (cvs-update-header args fis
)
1774 (with-current-buffer buf
1775 ;;(set (make-local-variable 'cvs-buffer) cvs-buf)
1776 (let ((inhibit-read-only t
)) (erase-buffer))
1777 (message "Running cvs %s ..." cmd
)
1778 (cvs-run-process args fis postproc single-dir
))))
1781 (defun* cvs-mode-do
(cmd flags filter
1782 &key show dont-change-disc parse cvsargs postproc
)
1783 "Generic cvs-mode-<foo> function.
1784 Executes `cvs CVSARGS CMD FLAGS' on the selected files.
1785 FILTER is passed to `cvs-applicable-p' to only apply the command to
1786 files for which it makes sense.
1787 SHOW indicates that CMD should be not be run in the default temp buffer and
1788 should be shown to the user. The buffer and mode to be used is determined
1789 by `cvs-buffer-name-alist'.
1790 DONT-CHANGE-DISC non-nil indicates that the command will not change the
1791 contents of files. This is only used by the parser."
1792 (cvs-mode-run cmd flags
(cvs-mode-marked filter cmd
)
1793 :buf
(cvs-temp-buffer (when show cmd
))
1794 :dont-change-disc dont-change-disc
1796 :postproc postproc
))
1798 (defun-cvs-mode (cvs-mode-status . SIMPLE
) (flags)
1799 "Show cvs status for all marked files.
1800 With prefix argument, prompt for cvs flags."
1801 (interactive (list (cvs-flags-query 'cvs-status-flags
"cvs status flags")))
1802 (cvs-mode-do "status" flags nil
:dont-change-disc t
:show t
1803 :postproc
(when (eq cvs-auto-remove-handled
'status
)
1804 '((with-current-buffer ,(current-buffer)
1805 (cvs-mode-remove-handled))))))
1807 (defun-cvs-mode (cvs-mode-tree . SIMPLE
) (flags)
1808 "Call cvstree using the file under the point as a keyfile."
1809 (interactive (list (cvs-flags-query 'cvs-status-flags
"cvs status flags")))
1810 (cvs-mode-run "status" (cons "-v" flags
) (cvs-mode-marked nil
"status")
1811 :buf
(cvs-temp-buffer "tree")
1813 :postproc
'((cvs-status-cvstrees))))
1817 (defun-cvs-mode (cvs-mode-log . NOARGS
) (flags)
1818 "Display the cvs log of all selected files.
1819 With prefix argument, prompt for cvs flags."
1820 (interactive (list (cvs-add-branch-prefix
1821 (cvs-flags-query 'cvs-log-flags
"cvs log flags"))))
1822 (cvs-mode-do "log" flags nil
:show t
))
1825 (defun-cvs-mode (cvs-mode-update . NOARGS
) (flags)
1826 "Update all marked files.
1827 With a prefix argument, prompt for cvs flags."
1829 (list (cvs-add-branch-prefix
1830 (cvs-add-secondary-branch-prefix
1831 (cvs-flags-query 'cvs-update-flags
"cvs update flags")
1833 (cvs-mode-do "update" flags
'update
))
1836 (defun-cvs-mode (cvs-mode-examine . NOARGS
) (flags)
1837 "Re-examine all marked files.
1838 With a prefix argument, prompt for cvs flags."
1840 (list (cvs-add-branch-prefix
1841 (cvs-add-secondary-branch-prefix
1842 (cvs-flags-query 'cvs-update-flags
"cvs -n update flags")
1844 (cvs-mode-do "update" flags nil
:cvsargs
'("-n") :dont-change-disc t
))
1847 (defun-cvs-mode cvs-mode-ignore
(&optional pattern
)
1848 "Arrange so that CVS ignores the selected files.
1849 This command ignores files that are not flagged as `Unknown'."
1851 (dolist (fi (cvs-mode-marked 'ignore
))
1852 (cvs-append-to-ignore (cvs-fileinfo->dir fi
) (cvs-fileinfo->file fi
))
1853 (setf (cvs-fileinfo->type fi
) 'DEAD
))
1854 (cvs-cleanup-collection cvs-cookies nil nil nil
))
1857 (defun cvs-append-to-ignore (dir str
)
1858 "Add STR to the .cvsignore file in DIR."
1859 (save-window-excursion
1860 (set-buffer (find-file-noselect (expand-file-name ".cvsignore" dir
)))
1861 (when (ignore-errors
1862 (and buffer-read-only
1863 (eq 'CVS
(vc-backend buffer-file-name
))
1864 (not (vc-editable-p buffer-file-name
))))
1865 ;; CVSREAD=on special case
1866 (vc-toggle-read-only))
1867 (goto-char (point-max))
1868 (unless (zerop (current-column)) (insert "\n"))
1870 (if cvs-sort-ignore-file
(sort-lines nil
(point-min) (point-max)))
1874 (defun cvs-mode-find-file-other-window (e)
1875 "Select a buffer containing the file in another window."
1876 (interactive (list last-input-event
))
1877 (cvs-mode-find-file e t
))
1880 (defun cvs-mode-display-file (e)
1881 "Show a buffer containing the file in another window."
1882 (interactive (list last-input-event
))
1883 (cvs-mode-find-file e
'dont-select
))
1886 (defun cvs-find-modif (fi)
1888 (call-process cvs-program nil
(current-buffer) nil
1889 "-f" "diff" (cvs-fileinfo->file fi
))
1890 (goto-char (point-min))
1891 (if (re-search-forward "^\\([0-9]+\\)" nil t
)
1892 (string-to-number (match-string 1))
1896 (defun cvs-mode-find-file (e &optional other
)
1897 "Select a buffer containing the file.
1898 With a prefix, opens the buffer in an OTHER window."
1899 (interactive (list last-input-event current-prefix-arg
))
1900 (when (ignore-errors (mouse-set-point e
) t
) ;for invocation via the mouse
1901 (unless (memq (get-text-property (1- (line-end-position)) 'font-lock-face
)
1902 '(cvs-header-face cvs-filename-face
))
1903 (error "Not a file name")))
1905 (lambda (&optional rev
)
1906 (interactive (list (cvs-prefix-get 'cvs-branch-prefix
)))
1907 (let* ((cvs-buf (current-buffer))
1908 (fi (cvs-mode-marked nil nil
:one t
)))
1909 (if (eq (cvs-fileinfo->type fi
) 'DIRCHANGE
)
1910 (let ((odir default-directory
))
1911 (setq default-directory
1912 (cvs-expand-dir-name (cvs-fileinfo->dir fi
)))
1913 (cond ((eq other
'dont-select
)
1914 (display-buffer (find-file-noselect default-directory
)))
1915 (other (dired-other-window default-directory
))
1916 (t (dired default-directory
)))
1917 (set-buffer cvs-buf
)
1918 (setq default-directory odir
))
1919 (let ((buf (if rev
(cvs-retrieve-revision fi rev
)
1920 (find-file-noselect (cvs-fileinfo->full-path fi
)))))
1921 (funcall (cond ((eq other
'dont-select
) 'display-buffer
)
1922 (other 'switch-to-buffer-other-window
)
1923 (t 'switch-to-buffer
))
1925 (when (and cvs-find-file-and-jump
(cvs-applicable-p fi
'diff-base
))
1926 (goto-line (cvs-find-modif fi
)))
1930 (defun-cvs-mode (cvs-mode-undo . SIMPLE
) (flags)
1931 "Undo local changes to all marked files.
1932 The file is removed and `cvs update FILE' is run."
1933 ;;"With prefix argument, prompt for cvs FLAGS."
1934 (interactive (list nil
));; (cvs-flags-query 'cvs-undo-flags "undo flags")
1935 (if current-prefix-arg
(call-interactively 'cvs-mode-revert-to-rev
)
1936 (let* ((fis (cvs-do-removal 'undo
"update" 'all
))
1937 (removedp (lambda (fi)
1938 (or (eq (cvs-fileinfo->type fi
) 'REMOVED
)
1939 (and (eq (cvs-fileinfo->type fi
) 'CONFLICT
)
1940 (eq (cvs-fileinfo->subtype fi
) 'REMOVED
)))))
1941 (fis-split (cvs-partition removedp fis
))
1942 (fis-removed (car fis-split
))
1943 (fis-other (cdr fis-split
)))
1944 (if (null fis-other
)
1945 (when fis-removed
(cvs-mode-run "add" nil fis-removed
))
1946 (cvs-mode-run "update" flags fis-other
1949 `((with-current-buffer ,(current-buffer)
1950 (cvs-mode-run "add" nil
',fis-removed
)))))))))
1953 (defun-cvs-mode (cvs-mode-revert-to-rev . NOARGS
) (rev)
1954 "Revert the selected files to an old revision."
1956 (list (or (cvs-prefix-get 'cvs-branch-prefix
)
1957 (let ((current-prefix-arg '(4)))
1958 (cvs-flags-query 'cvs-idiff-version
)))))
1959 (let* ((fis (cvs-mode-marked 'revert
"revert" :file t
))
1960 (tag (concat "tmp_pcl_tag_" (make-temp-name "")))
1961 (untag `((with-current-buffer ,(current-buffer)
1962 (cvs-mode-run "tag" (list "-d" ',tag
) ',fis
))))
1963 (update `((with-current-buffer ,(current-buffer)
1964 (cvs-mode-run "update" (list "-j" ',tag
"-j" ',rev
) ',fis
1965 :postproc
',untag
)))))
1966 (cvs-mode-run "tag" (list tag
) fis
:postproc update
)))
1969 (defun-cvs-mode cvs-mode-delete-lock
()
1970 "Delete the lock file that CVS is waiting for.
1971 Note that this can be dangerous. You should only do this
1972 if you are convinced that the process that created the lock is dead."
1974 (let* ((default-directory (cvs-expand-dir-name cvs-lock-file
))
1975 (locks (directory-files default-directory nil cvs-lock-file-regexp
)))
1977 ((not locks
) (error "No lock files found"))
1978 ((yes-or-no-p (concat "Really delete locks in " cvs-lock-file
"? "))
1979 (dolist (lock locks
)
1980 (cond ((file-directory-p lock
) (delete-directory lock
))
1981 ((file-exists-p lock
) (delete-file lock
))))))))
1984 (defun-cvs-mode cvs-mode-remove-handled
()
1985 "Remove all lines that are handled.
1986 Empty directories are removed."
1988 (cvs-cleanup-collection cvs-cookies
1989 t
(or cvs-auto-remove-directories
'handled
) t
))
1992 (defun-cvs-mode cvs-mode-acknowledge
()
1993 "Remove all marked files from the buffer."
1995 (dolist (fi (cvs-get-marked (cvs-ignore-marks-p "acknowledge") t
))
1996 (setf (cvs-fileinfo->type fi
) 'DEAD
))
1997 (cvs-cleanup-collection cvs-cookies nil nil nil
))
1999 (defun cvs-do-removal (filter &optional cmd all
)
2001 Returns a list of FIS that should be `cvs remove'd."
2002 (let* ((files (cvs-mode-marked filter cmd
:file t
:read-only t
))
2003 (fis (cdr (cvs-partition (lambda (fi)
2004 (eq (cvs-fileinfo->type fi
) 'UNKNOWN
))
2005 (cvs-mode-marked filter cmd
))))
2006 (silent (or (not cvs-confirm-removals
)
2007 (cvs-every (lambda (fi)
2008 (or (not (file-exists-p
2009 (cvs-fileinfo->full-path fi
)))
2010 (cvs-applicable-p fi
'safe-rm
)))
2012 (tmpbuf (cvs-temp-buffer)))
2013 (when (and (not silent
) (equal cvs-confirm-removals
'list
))
2014 (with-current-buffer tmpbuf
2015 (let ((inhibit-read-only t
))
2016 (cvs-insert-strings (mapcar 'cvs-fileinfo-
>full-path fis
))
2017 (cvs-pop-to-buffer-same-frame (current-buffer))
2018 (shrink-window-if-larger-than-buffer))))
2021 (yes-or-no-p (format "Delete %d files? " (length files
)))
2022 (cvs-bury-buffer tmpbuf cvs-buffer
))))
2023 (progn (message "Aborting") nil
)
2025 (let* ((type (cvs-fileinfo->type fi
))
2026 (file (cvs-fileinfo->full-path fi
)))
2027 (when (or all
(eq type
'UNKNOWN
))
2028 (when (file-exists-p file
) (delete-file file
))
2029 (unless all
(setf (cvs-fileinfo->type fi
) 'DEAD
) t
))))
2032 (defun-cvs-mode (cvs-mode-remove . SIMPLE
) (flags)
2033 "Remove all marked files.
2034 With prefix argument, prompt for cvs flags."
2035 (interactive (list (cvs-flags-query 'cvs-remove-flags
"cvs remove flags")))
2036 (let ((fis (cvs-do-removal 'remove
)))
2037 (if fis
(cvs-mode-run "remove" (cons "-f" flags
) fis
)
2038 (cvs-cleanup-collection cvs-cookies nil nil nil
))))
2041 (defvar cvs-tag-name
"")
2042 (defun-cvs-mode (cvs-mode-tag . SIMPLE
) (tag &optional flags
)
2043 "Run `cvs tag TAG' on all selected files.
2044 With prefix argument, prompt for cvs flags."
2046 (list (setq cvs-tag-name
2047 (cvs-query-read cvs-tag-name
"Tag name: " cvs-qtypedesc-tag
))
2048 (cvs-flags-query 'cvs-tag-flags
"tag flags")))
2049 (cvs-mode-do "tag" (append flags
(list tag
))
2050 (when cvs-force-dir-tag
'tag
)))
2052 (defun-cvs-mode (cvs-mode-untag . SIMPLE
) (tag &optional flags
)
2053 "Run `cvs tag -d TAG' on all selected files.
2054 With prefix argument, prompt for cvs flags."
2056 (list (setq cvs-tag-name
2057 (cvs-query-read cvs-tag-name
"Tag to delete: " cvs-qtypedesc-tag
))
2058 (cvs-flags-query 'cvs-tag-flags
"tag flags")))
2059 (cvs-mode-do "tag" (append '("-d") flags
(list tag
))
2060 (when cvs-force-dir-tag
'tag
)))
2063 ;; Byte compile files.
2065 (defun-cvs-mode cvs-mode-byte-compile-files
()
2066 "Run byte-compile-file on all selected files that end in '.el'."
2068 (let ((marked (cvs-get-marked (cvs-ignore-marks-p "byte-compile"))))
2070 (let ((filename (cvs-fileinfo->full-path fi
)))
2071 (when (string-match "\\.el\\'" filename
)
2072 (byte-compile-file filename
))))))
2074 ;; ChangeLog support.
2076 (defun-cvs-mode cvs-mode-add-change-log-entry-other-window
()
2077 "Add a ChangeLog entry in the ChangeLog of the current directory."
2079 (dolist (fi (cvs-mode-marked nil nil
))
2080 (let ((default-directory (cvs-expand-dir-name (cvs-fileinfo->dir fi
)))
2081 (buffer-file-name (expand-file-name (cvs-fileinfo->file fi
))))
2082 (kill-local-variable 'change-log-default-name
)
2083 (save-excursion (add-change-log-entry-other-window)))))
2085 ;; interactive commands to set optional flags
2087 (defun cvs-mode-set-flags (flag)
2088 "Ask for new setting of cvs-FLAG-flags."
2090 (list (completing-read
2092 '("cvs" "diff" "update" "status" "log" "tag" ;"rtag"
2093 "commit" "remove" "undo" "checkout")
2095 (let* ((sym (intern (concat "cvs-" flag
"-flags"))))
2096 (let ((current-prefix-arg '(16)))
2097 (cvs-flags-query sym
(concat flag
" flags")))))
2101 ;;;; Utilities for the *cvs* buffer
2104 (defun cvs-dir-member-p (fileinfo dir
)
2105 "Return true if FILEINFO represents a file in directory DIR."
2106 (and (not (eq (cvs-fileinfo->type fileinfo
) 'DIRCHANGE
))
2107 (cvs-string-prefix-p dir
(cvs-fileinfo->dir fileinfo
))))
2109 (defun cvs-execute-single-file (fi extractor program constant-args
)
2110 "Internal function for `cvs-execute-single-file-list'."
2111 (let* ((arg-list (funcall extractor fi
))
2112 (inhibit-read-only t
))
2114 ;; Execute the command unless extractor returned t.
2115 (when (listp arg-list
)
2116 (let* ((args (append constant-args arg-list
)))
2118 (insert (format "=== %s %s\n\n"
2119 program
(cvs-strings->string args
)))
2121 ;; FIXME: return the exit status?
2122 (apply 'call-process program nil t t args
)
2123 (goto-char (point-max))))))
2125 ;; FIXME: make this run in the background ala cvs-run-process...
2126 (defun cvs-execute-single-file-list (fis extractor program constant-args
)
2127 "Run PROGRAM on all elements on FIS.
2128 CONSTANT-ARGS is a list of strings to pass as arguments to PROGRAM.
2129 The arguments given to the program will be CONSTANT-ARGS followed by
2130 the list that EXTRACTOR returns.
2132 EXTRACTOR will be called once for each file on FIS. It is given
2133 one argument, the cvs-fileinfo. It can return t, which means ignore
2134 this file, or a list of arguments to send to the program."
2136 (cvs-execute-single-file fi extractor program constant-args
)))
2139 (defun cvs-revert-if-needed (fis)
2140 (dolist (fileinfo fis
)
2141 (let* ((file (cvs-fileinfo->full-path fileinfo
))
2142 (buffer (find-buffer-visiting file
)))
2143 ;; For a revert to happen the user must be editing the file...
2144 (unless (or (null buffer
)
2145 (eq (cvs-fileinfo->type fileinfo
) 'MESSAGE
)
2146 ;; FIXME: check whether revert is really needed.
2147 ;; `(verify-visited-file-modtime buffer)' doesn't cut it
2148 ;; because it only looks at the time stamp (it ignores
2149 ;; read-write changes) which is not changed by `commit'.
2150 (buffer-modified-p buffer
))
2151 (with-current-buffer buffer
2153 (revert-buffer 'ignore-auto
'dont-ask
'preserve-modes
)
2154 ;; `preserve-modes' avoids changing the (minor) modes. But we
2155 ;; do want to reset the mode for VC, so we do it explicitly.
2157 (when (eq (cvs-fileinfo->type fileinfo
) 'CONFLICT
)
2158 (smerge-mode 1))))))))
2161 (defun cvs-change-cvsroot (newroot)
2162 "Change the cvsroot."
2163 (interactive "DNew repository: ")
2164 (if (or (file-directory-p (expand-file-name "CVSROOT" newroot
))
2165 (y-or-n-p (concat "Warning: no CVSROOT found inside repository."
2166 " Change cvs-cvsroot anyhow?")))
2167 (setq cvs-cvsroot newroot
)))
2170 ;;;; useful global settings
2174 (add-to-list 'completion-ignored-extensions
"CVS/")
2177 ;; Hook to allow calling PCL-CVS by visiting the /CVS subdirectory
2181 (defcustom cvs-dired-action
'cvs-quickdir
2182 "The action to be performed when opening a CVS directory.
2183 Sensible values are `cvs-examine', `cvs-status' and `cvs-quickdir'."
2185 :type
'(choice (const cvs-examine
) (const cvs-status
) (const cvs-quickdir
)))
2188 (defcustom cvs-dired-use-hook
'(4)
2189 "Whether or not opening a CVS directory should run PCL-CVS.
2190 nil means never do it.
2191 ALWAYS means to always do it unless a prefix argument is given to the
2192 command that prompted the opening of the directory.
2193 Anything else means to do it only if the prefix arg is equal to this value."
2195 :type
'(choice (const :tag
"Never" nil
)
2196 (const :tag
"Always" always
)
2197 (const :tag
"Prefix" (4))))
2200 (progn (defun cvs-dired-noselect (dir)
2201 "Run `cvs-examine' if DIR is a CVS administrative directory.
2202 The exact behavior is determined also by `cvs-dired-use-hook'."
2204 (setq dir
(directory-file-name dir
))
2205 (when (and (string= "CVS" (file-name-nondirectory dir
))
2206 (file-readable-p (expand-file-name "Entries" dir
))
2208 (if (eq cvs-dired-use-hook
'always
)
2209 (not current-prefix-arg
)
2210 (equal current-prefix-arg cvs-dired-use-hook
)))
2212 (funcall cvs-dired-action
(file-name-directory dir
) t t
))))))
2218 (add-hook 'vc-post-command-functions
'cvs-vc-command-advice
)
2220 (defun cvs-vc-command-advice (command file flags
)
2221 (when (and (equal command
"cvs")
2223 (while (and (stringp (car flags
))
2224 (string-match "\\`-" (car flags
)))
2226 ;; don't parse output we don't understand.
2227 (member (car flags
) cvs-parse-known-commands
)))
2228 (save-current-buffer
2229 (let ((buffer (current-buffer))
2230 (dir default-directory
)
2232 (dolist (cvs-buf (buffer-list))
2233 (set-buffer cvs-buf
)
2234 ;; look for a corresponding pcl-cvs buffer
2235 (when (and (eq major-mode
'cvs-mode
)
2236 (cvs-string-prefix-p default-directory dir
))
2237 (let ((subdir (substring dir
(length default-directory
))))
2239 (set (make-local-variable 'cvs-buffer
) cvs-buf
)
2240 ;; `cvs -q add file' produces no useful output :-(
2241 (when (and (equal (car flags
) "add")
2242 (goto-char (point-min))
2243 (looking-at ".*to add this file permanently\n\\'"))
2244 (insert "cvs add: scheduling file `"
2245 (file-name-nondirectory file
)
2246 "' for addition\n"))
2247 ;; VC never (?) does `cvs -n update' so dcd=nil
2248 ;; should probably always be the right choice.
2249 (cvs-parse-process nil subdir
))))))))
2252 ;; Hook into write-buffer
2255 (defun cvs-mark-buffer-changed ()
2256 (let* ((file (expand-file-name buffer-file-name
))
2257 (version (and (fboundp 'vc-backend
)
2258 (eq (vc-backend file
) 'CVS
)
2259 (vc-workfile-version file
))))
2262 (dolist (cvs-buf (buffer-list))
2263 (set-buffer cvs-buf
)
2264 ;; look for a corresponding pcl-cvs buffer
2265 (when (and (eq major-mode
'cvs-mode
)
2266 (cvs-string-prefix-p default-directory file
))
2267 (let* ((file (substring file
(length default-directory
)))
2268 (fi (cvs-create-fileinfo
2269 (if (string= "0" version
)
2271 (or (file-name-directory file
) "")
2272 (file-name-nondirectory file
)
2273 "cvs-mark-buffer-changed")))
2274 (cvs-addto-collection cvs-cookies fi
))))))))
2276 (add-hook 'after-save-hook
'cvs-mark-buffer-changed
)
2281 ;;; pcvs.el ends here