# HG changeset patch # User Eric S. Raymond # Date 1210364270 0 # Node ID 5b364ab2654bbe4fee67a34bb5ee4416b39c6313 # Parent aa24238f32740834bb8a597773ddafd36185f091 Dupport an use an observer flag in (vc-dispatcher-selection-set). diff -r aa24238f3274 -r 5b364ab2654b lisp/ChangeLog --- a/lisp/ChangeLog Fri May 09 20:07:01 2008 +0000 +++ b/lisp/ChangeLog Fri May 09 20:17:50 2008 +0000 @@ -2,9 +2,14 @@ * vc.el (vc-dir), vc-hooks.el: Tweak the VC directory bindings. These are now documented in the manual. - * vc-dispatcher.el (vc-dir-update, vc-dir-parent-marked-p, + * vc-dispatcher.el (vc-dir-update, vc-dir-parent-marked-p, vc-dir-children-marked-p): Remove the vc-dir-insert-directories global. + * vc-dispatcher.el (vc-dispatcher-selection-set): Allow callers to + pass in an observer flag that says no buffer sync is required. + * vc.el (vc-deduce-fileset, vc-print-log, vc-version-diff): Use + the observer flag. + 2008-05-09 Michael Albinus * simple.el (start-file-process): Clarify docstring. diff -r aa24238f3274 -r 5b364ab2654b lisp/vc-dispatcher.el --- a/lisp/vc-dispatcher.el Fri May 09 20:07:01 2008 +0000 +++ b/lisp/vc-dispatcher.el Fri May 09 20:17:50 2008 +0000 @@ -1270,16 +1270,6 @@ (put 'vc-dir-mode 'mode-class 'special) -(defun vc-buffer-sync (&optional not-urgent) - "Make sure the current buffer and its working file are in sync. -NOT-URGENT means it is ok to continue if the user says not to save." - (when (buffer-modified-p) - (if (or vc-suppress-confirm - (y-or-n-p (format "Buffer %s modified; save it? " (buffer-name)))) - (save-buffer) - (unless not-urgent - (error "Aborted"))))) - (defun vc-dispatcher-browsing () "Are we in a directory browser buffer?" (derived-mode-p 'vc-dir-mode)) @@ -1295,7 +1285,7 @@ (setq member t)))) member)) -(defun vc-dispatcher-selection-set () +(defun vc-dispatcher-selection-set (&optional observer) "Deduce a set of files to which to apply an operation. Return the fileset. If we're in a directory display, the fileset is the list of marked files (if there is one) else the file on the curreent line. If not in a directory @@ -1320,10 +1310,9 @@ ;; We assume, in order to avoid unpleasant surprises to the user, ;; that a fileset is not in good shape to be handed to the user if the ;; buffers visiting the fileset don't match the on-disk contents. - ;; This is actually untrue for operations like `print-log' (or `diff' - ;; between two revisions), so maybe this should be moved elsewhere. - (save-some-buffers - nil (lambda () (vc-dispatcher-in-fileset-p files))) + (if (not observer) + (save-some-buffers + nil (lambda () (vc-dispatcher-in-fileset-p files)))) files)) ;; arch-tag: 7d08b17f-5470-4799-914b-bfb9fcf6a246 diff -r aa24238f3274 -r 5b364ab2654b lisp/vc.el --- a/lisp/vc.el Fri May 09 20:07:01 2008 +0000 +++ b/lisp/vc.el Fri May 09 20:17:50 2008 +0000 @@ -1002,10 +1002,10 @@ node (lambda (f) (when (vc-backend f) (push f flattened))))) (nreverse flattened))) -(defun vc-deduce-fileset () +(defun vc-deduce-fileset (&optional observer) "Deduce a set of files and a backend to which to apply an operation and the common state of the fileset. Return (BACKEND . FILESET)." - (let* ((fileset (vc-dispatcher-selection-set)) + (let* ((fileset (vc-dispatcher-selection-set observer)) ;; FIXME: Store the backend in a buffer-local variable. (backend (if (derived-mode-p 'vc-dir-mode) (vc-responsible-backend default-directory) @@ -1031,6 +1031,16 @@ (unless (vc-backend buffer-file-name) (error "File %s is not under version control" buffer-file-name)))))) +(defun vc-buffer-sync (&optional not-urgent) + "Make sure the current buffer and its working file are in sync. +NOT-URGENT means it is ok to continue if the user says not to save." + (when (buffer-modified-p) + (if (or vc-suppress-confirm + (y-or-n-p (format "Buffer %s modified; save it? " (buffer-name)))) + (save-buffer) + (unless not-urgent + (error "Aborted"))))) + ;;; Support for the C-x v v command. ;; This is where all the single-file-oriented code from before the fileset ;; rewrite lives. @@ -1561,7 +1571,7 @@ (defun vc-version-diff (files rev1 rev2) "Report diffs between revisions of the fileset in the repository history." (interactive - (let* ((vc-fileset (vc-deduce-fileset)) + (let* ((vc-fileset (vc-deduce-fileset t)) (files (cdr vc-fileset)) (backend (car vc-fileset)) (first (car files)) @@ -2123,7 +2133,7 @@ "List the change log of the current fileset in a window. If WORKING-REVISION is non-nil, leave the point at that revision." (interactive) - (let* ((vc-fileset (vc-deduce-fileset)) + (let* ((vc-fileset (vc-deduce-fileset t)) (backend (car vc-fileset)) (files (cdr vc-fileset)) (working-revision (or working-revision (vc-working-revision (car files)))))