summaryrefslogtreecommitdiff
path: root/lisp/vc-dispatcher.el
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2008-05-09 15:30:47 +0000
committerStefan Monnier <monnier@iro.umontreal.ca>2008-05-09 15:30:47 +0000
commit8243c746a5fd409f6790cd12a6ccd3e8e7e28afa (patch)
tree5fd84f5e2ae5216094d7fb9e727457c7409f3c9a /lisp/vc-dispatcher.el
parentee7a2e7a9b72ff8a6868096132f1085e2fbc523d (diff)
downloademacs-8243c746a5fd409f6790cd12a6ccd3e8e7e28afa.tar.gz
(vc-dispatcher-browsing): Use derived-mode-p.
(vc-dir-prepare-status-buffer): Use vc-dispatcher-browsing. (vc-dispatcher-in-fileset-p): New fun. (vc-dispatcher-selection-set): Use it to properly handle directories.
Diffstat (limited to 'lisp/vc-dispatcher.el')
-rw-r--r--lisp/vc-dispatcher.el44
1 files changed, 18 insertions, 26 deletions
diff --git a/lisp/vc-dispatcher.el b/lisp/vc-dispatcher.el
index 002ac5438e6..2970854c019 100644
--- a/lisp/vc-dispatcher.el
+++ b/lisp/vc-dispatcher.el
@@ -671,7 +671,7 @@ See `run-hooks'."
(unless create-new
(dolist (buffer (buffer-list))
(set-buffer buffer)
- (when (and (eq major-mode 'vc-dir-mode)
+ (when (and (vc-dispatcher-browsing)
(string= (expand-file-name default-directory) dir))
(return buffer)))))))
(or buf
@@ -1326,7 +1326,17 @@ NOT-URGENT means it is ok to continue if the user says not to save."
(defun vc-dispatcher-browsing ()
"Are we in a directory browser buffer?"
- (eq major-mode 'vc-dir-mode))
+ (derived-mode-p 'vc-dir-mode))
+
+(defun vc-dispatcher-in-fileset-p (fileset)
+ (let ((member nil))
+ (while (and (not member) fileset)
+ (let ((elem (pop fileset)))
+ (if (if (file-directory-p elem)
+ (eq t (compare-strings buffer-file-name nil (length elem)
+ elem nil nil))
+ (eq (current-buffer) (get-file-buffer elem)))
+ (setq member t))))))
(defun vc-dispatcher-selection-set ()
"Deduce a set of files to which to apply an operation. Return the fileset.
@@ -1350,31 +1360,13 @@ containing that file. Otherwise, throw an error."
(vc-dispatcher-selection-set)))
;; No good set here, throw error
(t (error "No fileset is available here.")))))
- ;; 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
+ ;; 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.
- (dolist (file files)
- (let ((visited (get-file-buffer file)))
- (when visited
- (if (vc-dispatcher-browsing)
- (switch-to-buffer-other-window visited)
- (set-buffer visited))
- ;; Check relation of buffer and file, and make sure
- ;; user knows what he's doing. First, finding the file
- ;; will check whether the file on disk is newer.
- ;; Ignore buffer-read-only during this test, and
- ;; preserve find-file-literally.
- (let ((buffer-read-only (not (file-writable-p file))))
- (find-file-noselect file nil find-file-literally))
- (if (not (verify-visited-file-modtime (current-buffer)))
- (if (yes-or-no-p (format "Replace %s on disk with buffer contents? " file))
- (write-file buffer-file-name)
- (error "Aborted"))
- ;; Now, check if we have unsaved changes.
- (vc-buffer-sync t)
- (when (buffer-modified-p)
- (or (y-or-n-p (message "Use %s on disk, keeping modified buffer? " file))
- (error "Aborted")))))))
+ ;; 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 fileset)))
files))
;; arch-tag: 7d08b17f-5470-4799-914b-bfb9fcf6a246