bug#25983: 25.2; set dired-directory in vc-dir mode
I'd find it handy if vc-dir buffers had dired-directory set.
This can serve as an indication that the buffer is associated with some
directory, even though it's not visiting a file.
I've appended the patch I would like to apply.
Let me know what you think.
diff --git a/lisp/vc/vc-dir.el b/lisp/vc/vc-dir.el
index 0363aab..2281333 100644
@@ -1016,6 +1016,7 @@ vc-dir-mode
(set (make-local-variable 'vc-ewoc) (ewoc-create #'vc-dir-printer))
(set (make-local-variable 'revert-buffer-function)
+ (setq dired-directory default-directory)
(setq list-buffers-directory (expand-file-name "*vc-dir*" default-directory))
(add-to-list 'vc-dir-buffers (current-buffer))
;; Make sure that if the directory buffer is killed, the update
In GNU Emacs 25.2.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.22.8)
of 2017-03-02 built on bapiya
Repository revision: 6e788ef0e262fafc014c21f4ad52cc5dc9f1715b
Windowing system distributor 'Fedora Project', version 11.0.11901000
System Description: Fedora release 25 (Twenty Five)
value of $LANG: en_US.utf8
value of $XMODIFIERS: @im=ibus
Major mode: VC dir
Minor modes in effect:
Mark set [2 times]
Mark set [2 times]
Sending via mail...
Type C-x 1 to delete the help window. [2 times]
Sending email done
a is undefined
Scanning for dabbrevs...done
>>>>>> "GM" == Glenn Morris <[hidden email]> writes:
> GM> Is dired-directory not basically an internal dired variable that should
> GM> only be set in Dired mode, and modes derived from it, which vc-dir is not?
> Various bits of code (and some other code I have seen, not part of
> Emacs) seem to examine it. And vc-dir seems dired-like.
Hm... Well, there's a bunch of buffers that are kinda-sorta dired-like
(like `M-x grep'), so adding this just to vc-dir seems a bit odd to me.
> The backstory for this bug is that I have this handy bit of code I got
> from someone on #emacs:
> ;; From fledermaus
> (defun kill-buffers-under (under)
> ... and I'd rather not add a special hack just for vc-dir, and then for
> whatever other modes crop up.
> I guess I'm being a bit lazy trying to avoid introducing a new variable.
> But maybe I should?
All buffers have a default-directory, but you want to make a function
that kills are buffers that are "like" dired (in that they display a
buffer pointing to a directory, and there are things you can do there)?
I don't think you'll be able to find a definition of what's "like" dired
enough that this would make sense... especially when the use case
doesn't seem that ... comprehensible? That is, I think only the user
that writes a function like this knows what buffer types they want to
consider killing. Finding a general solution here doesn't seem very
likely, so I'm closing this bug report.