0

I want to set dired-actual-switches for the directory /path/to/data, but not for data's subdirectories. So I generated the following .dir-locals.el file in /path/to/data:

;;; Directory Local Variables
;;; For more information see (info "(emacs) Directory Variables")

((dired-mode .
  ((dired-actual-switches . "-laht")
   (subdirs . nil))))

And as I hope for, when I call dired on the directory /path/to/data it is listed by date. However when I open a dired buffer for /path/to/data/sub the directory listing for sub is in date order as well - despite the subdirs . nil entry in .dir-locals.el.

How do I achieve that dired-actual-switches is only set for the directory the .dir-locals.el file sits in?

  • I would hazard a guess that the subdirs behaviour is tied to buffer-file-name (which isn't populated in dired buffers). – phils Oct 9 '17 at 4:11
  • So it's kind of a bug? – halloleo Oct 9 '17 at 8:43
  • 1
    Well my guess was wrong -- dired-mode calls hack-dir-local-variables-non-file-buffer which is based on default-directory which is set. That's not to say there isn't a bug, though. I'm not going to dig into it right now, but if it's a reliably repeatable issue then you can M-x report-emacs-bug with a recipe starting from running emacs -Q – phils Oct 9 '17 at 10:04
  • What @phils said. If you can repeat it starting Emacs using emacs -Q then please consider reporting it as a bug. – Drew Oct 9 '17 at 14:21
  • @phils Have tried it with a vanilla emacs -Q and then it behaves correctly!!! So it must be something with my setup... – halloleo Oct 11 '17 at 7:35
0

As it turns out this seems to be a bug in GNU Emacs 25.2.1.

The dired-actual-switches setting in .dir-locals.el is applied to a sub directory under the directory with the .dir-locals.el file.

Furthermore the application of the directory variable seem to happen after the dired buffer is created for the first time in an emacs session. This means when you create the dired buffer with the directory for the first time the variable is not applied whatsoever and when you create the buffer again it is applied - in both cases: the directory and sub directory.

I'm filing a bug report.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.