[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#25983: 25.2; set dired-directory in vc-dir mode
From: |
Tom Tromey |
Subject: |
bug#25983: 25.2; set dired-directory in vc-dir mode |
Date: |
Sun, 05 Mar 2017 17:04:44 -0700 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) |
>>>>> "GM" == Glenn Morris <rgm@gnu.org> 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.
The basic problem is that I don't think there's a good way to indicate:
"this buffer is associated with this directory, but isn't visiting a
file". dired-directory is the only one I know of.
default-directory seems almost right but it's a bit random for some
buffers; like *shell* or *compilation*.
There's list-buffer-directory but it is just a random string, not
actually a directory name.
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)
(interactive "DKill buffers under: ")
(setq under (concat "^" (expand-file-name under)))
(mapc
(lambda (buf)
(let ((path
(or (buffer-file-name buf)
(progn
(set-buffer buf)
(and dired-directory
(expand-file-name dired-directory)) )) ))
;;(message "checking %S: %S vs |%s|" buf path under)
(and path (string-match under path)
(progn
(message "Killing buffer %s" (buffer-name buf))
(kill-buffer buf))) ))
(buffer-list)))
... 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?
Tom