* bug#32596: 27.0.50; Support VC single file operations from Dired
@ 2018-08-30 22:02 Juri Linkov
2018-11-07 22:53 ` Juri Linkov
0 siblings, 1 reply; 2+ messages in thread
From: Juri Linkov @ 2018-08-30 22:02 UTC (permalink / raw)
To: 32596
[-- Attachment #1: Type: text/plain, Size: 691 bytes --]
Both vc-dir-mode and dired-mode are supported in vc-deduce-fileset,
but only vc-dir-mode is supported in vc-ensure-vc-buffer.
This patch prepares a VC-controlled file buffer from Dired as well.
Error-checking is moved outside of the last branch of cond,
because in addition to dired-mode, it's also needed for vc-dir-mode
to avoid the failure with a backtrace when a single-file operation
is executed in vc-dir-mode on a directory.
Also I noticed that the check ‘(unless backend (error "Directory not under VC"))’
is not needed anymore because now vc-responsible-backend raises the same error.
There are more such useless checks in vc.el that could be removed as well.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: vc-ensure-vc-buffer.1.patch --]
[-- Type: text/x-diff, Size: 1748 bytes --]
diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index b2bedfae93..ea1ba63f8f 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -1055,27 +1055,27 @@ vc-deduce-fileset
(t (error "File is not under version control")))))
(defun vc-dired-deduce-fileset ()
- (let ((backend (vc-responsible-backend default-directory)))
- (unless backend (error "Directory not under VC"))
- (list backend
- (dired-map-over-marks (dired-get-filename nil t) nil))))
+ (list (vc-responsible-backend default-directory)
+ (dired-map-over-marks (dired-get-filename nil t) nil)))
(defun vc-ensure-vc-buffer ()
"Make sure that the current buffer visits a version-controlled file."
(cond
((derived-mode-p 'vc-dir-mode)
(set-buffer (find-file-noselect (vc-dir-current-file))))
+ ((derived-mode-p 'dired-mode)
+ (set-buffer (find-file-noselect (dired-get-filename))))
(t
(while (and vc-parent-buffer
(buffer-live-p vc-parent-buffer)
;; Avoid infinite looping when vc-parent-buffer and
;; current buffer are the same buffer.
(not (eq vc-parent-buffer (current-buffer))))
- (set-buffer vc-parent-buffer))
- (if (not buffer-file-name)
- (error "Buffer %s is not associated with a file" (buffer-name))
- (unless (vc-backend buffer-file-name)
- (error "File %s is not under version control" buffer-file-name))))))
+ (set-buffer vc-parent-buffer))))
+ (if (not buffer-file-name)
+ (error "Buffer %s is not associated with a file" (buffer-name))
+ (unless (vc-backend buffer-file-name)
+ (error "File %s is not under version control" buffer-file-name))))
;;; Support for the C-x v v command.
;; This is where all the single-file-oriented code from before the fileset
^ permalink raw reply related [flat|nested] 2+ messages in thread
* bug#32596: 27.0.50; Support VC single file operations from Dired
2018-08-30 22:02 bug#32596: 27.0.50; Support VC single file operations from Dired Juri Linkov
@ 2018-11-07 22:53 ` Juri Linkov
0 siblings, 0 replies; 2+ messages in thread
From: Juri Linkov @ 2018-11-07 22:53 UTC (permalink / raw)
To: 32596-done
> Both vc-dir-mode and dired-mode are supported in vc-deduce-fileset,
> but only vc-dir-mode is supported in vc-ensure-vc-buffer.
>
> This patch prepares a VC-controlled file buffer from Dired as well.
>
> Error-checking is moved outside of the last branch of cond,
> because in addition to dired-mode, it's also needed for vc-dir-mode
> to avoid the failure with a backtrace when a single-file operation
> is executed in vc-dir-mode on a directory.
Done.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-11-07 22:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-30 22:02 bug#32596: 27.0.50; Support VC single file operations from Dired Juri Linkov
2018-11-07 22:53 ` Juri Linkov
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.