all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#17205: 24.3.50; dired and directory variables
@ 2014-04-06 12:55 Michael Heerdegen
  2021-01-23 22:12 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 6+ messages in thread
From: Michael Heerdegen @ 2014-04-06 12:55 UTC (permalink / raw)
  To: 17205


Hello,

dired doesn't play well with directory local variables.  The manual
(info "(emacs) Directory Variables") seems to say that they would work
with dired, but I found several problems with that (all this in emacs
-Q):


1.  In dired, they (sometimes?) take effect only in subdirectories, but
not in the directory where they are specified.

Example:  In my ~, I create a .dir-locals.el with the content

((nil . ((a .  "hallo"))))

When I now open a dired buffer of ~, `a' is undefined.  When I open any
file below ~, `a' is bound as expected.


2.  Being able to use use `dired-listing-switches' as a directory
variable would obviously be very useful.  But it has no effect, even not
in subdirectories.  OTOH, using `dired-actual-switches' has an effect,
it leads to a sorting as expected, even (contrary to 1.) in the
directory that contains the dir locals file.


3.  `dir-locals-collect-variables' "destroys" any (subdirs . nil)
specification:

I change the .dir-locals.el in my ~ to the following content:

((nil . ((a .  "hallo")
         (subdirs . nil))))

and restart Emacs.

Now I dired ~.  After that, I visit any file somewhere under ~ (this can
be a regular file or a directory).  `a' will be bound in that buffer.

This doesn't happen if I don't dired ~ before.  The cause seems to be
this line in `dir-locals-collect-variables':

  (setq alist (delq subdirs alist))

which modifies the cached alist sturcture destructively (permanently!).
The `delq' should be a `remq', I guess.


Many thanks,

Michael.



In GNU Emacs 24.3.50.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.10.7)
 of 2014-03-28 on drachen
Windowing system distributor `The X.Org Foundation', version 11.0.11500000
System Description:	Debian GNU/Linux testing (jessie)






^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#17205: 24.3.50; dired and directory variables
  2014-04-06 12:55 bug#17205: 24.3.50; dired and directory variables Michael Heerdegen
@ 2021-01-23 22:12 ` Lars Ingebrigtsen
  2021-01-24 19:37   ` Michael Heerdegen
  0 siblings, 1 reply; 6+ messages in thread
From: Lars Ingebrigtsen @ 2021-01-23 22:12 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: 17205

Michael Heerdegen <michael_heerdegen@web.de> writes:

> dired doesn't play well with directory local variables.  The manual
> (info "(emacs) Directory Variables") seems to say that they would work
> with dired, but I found several problems with that (all this in emacs
> -Q):
>
> 1.  In dired, they (sometimes?) take effect only in subdirectories, but
> not in the directory where they are specified.
>
> Example:  In my ~, I create a .dir-locals.el with the content
>
> ((nil . ((a .  "hallo"))))
>
> When I now open a dired buffer of ~, `a' is undefined.  When I open any
> file below ~, `a' is bound as expected.

(I'm going through old bug reports that unfortunately got no response at
the time.)

I'm unable to reproduce this in Emacs 28 -- if I put that into
~/.dir-locals.el, then the `a' variable is set (after some prompting
about the safety).

> 2.  Being able to use use `dired-listing-switches' as a directory
> variable would obviously be very useful.  But it has no effect, even not
> in subdirectories.  OTOH, using `dired-actual-switches' has an effect,
> it leads to a sorting as expected, even (contrary to 1.) in the
> directory that contains the dir locals file.

This also seems to work for me in Emacs 28 with a file of

((nil . ((a .  "hallo") (dired-listing-switches "-l"))))

> 3.  `dir-locals-collect-variables' "destroys" any (subdirs . nil)
> specification:
>
> I change the .dir-locals.el in my ~ to the following content:
>
> ((nil . ((a .  "hallo")
>          (subdirs . nil))))
>
> and restart Emacs.
>
> Now I dired ~.  After that, I visit any file somewhere under ~ (this can
> be a regular file or a directory).  `a' will be bound in that buffer.
>
> This doesn't happen if I don't dired ~ before.  The cause seems to be
> this line in `dir-locals-collect-variables':
>
>   (setq alist (delq subdirs alist))
>
> which modifies the cached alist sturcture destructively (permanently!).
> The `delq' should be a `remq', I guess.

I am able to reproduce this bit, though, and indeed, changing the delq
to remq fixes this problem.

Do all these cases work for you, too, in Emacs 28?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#17205: 24.3.50; dired and directory variables
  2021-01-23 22:12 ` Lars Ingebrigtsen
@ 2021-01-24 19:37   ` Michael Heerdegen
  2021-01-25 12:50     ` Michael Heerdegen
  2021-01-26  0:14     ` Lars Ingebrigtsen
  0 siblings, 2 replies; 6+ messages in thread
From: Michael Heerdegen @ 2021-01-24 19:37 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 17205

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Do all these cases work for you, too, in Emacs 28?

All of my reported issues seem to be fixed indeed, thanks!  But a tiny
thing remains: in the

((nil . ((a .  "hallo")
         (subdirs . nil))))

scenario, the variable `a' is not bound in the dired buffer for the
directory the .dir-locals.el file lives in.  I would expect it to be.


TIA, Michael.





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#17205: 24.3.50; dired and directory variables
  2021-01-24 19:37   ` Michael Heerdegen
@ 2021-01-25 12:50     ` Michael Heerdegen
  2021-01-26  0:14     ` Lars Ingebrigtsen
  1 sibling, 0 replies; 6+ messages in thread
From: Michael Heerdegen @ 2021-01-25 12:50 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 17205

Michael Heerdegen <michael_heerdegen@web.de> writes:

> Lars Ingebrigtsen <larsi@gnus.org> writes:
>
> > Do all these cases work for you, too, in Emacs 28?
>
> All of my reported issues seem to be fixed indeed, thanks!  But a tiny
> thing remains: in the
>
> ((nil . ((a .  "hallo")
>          (subdirs . nil))))
>
> scenario, the variable `a' is not bound in the dired buffer for the
> directory the .dir-locals.el file lives in.

Seems that in this case this test (unexpectedly) fails:

  (equal root default-directory)

where in my case root --> /home/micha/ and default-directory --> "~/".


Regards,

Michael.





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#17205: 24.3.50; dired and directory variables
  2021-01-24 19:37   ` Michael Heerdegen
  2021-01-25 12:50     ` Michael Heerdegen
@ 2021-01-26  0:14     ` Lars Ingebrigtsen
  2021-01-26 12:22       ` Michael Heerdegen
  1 sibling, 1 reply; 6+ messages in thread
From: Lars Ingebrigtsen @ 2021-01-26  0:14 UTC (permalink / raw)
  To: Michael Heerdegen; +Cc: 17205

Michael Heerdegen <michael_heerdegen@web.de> writes:

>> Do all these cases work for you, too, in Emacs 28?
>
> All of my reported issues seem to be fixed indeed, thanks!  But a tiny
> thing remains: in the
>
> ((nil . ((a .  "hallo")
>          (subdirs . nil))))
>
> scenario, the variable `a' is not bound in the dired buffer for the
> directory the .dir-locals.el file lives in.  I would expect it to be.

[...]

> Seems that in this case this test (unexpectedly) fails:
>
>   (equal root default-directory)
>
> where in my case root --> /home/micha/ and default-directory --> "~/".

Yup; I was able to reproduce that, too, and slapping an expand-file-name
on default-directory fixed this.  So I think that's all in this bug
report (it doesn't sound like subdirs in .dir-locals.el is used a lot,
does it?), and I'm closing this bug report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#17205: 24.3.50; dired and directory variables
  2021-01-26  0:14     ` Lars Ingebrigtsen
@ 2021-01-26 12:22       ` Michael Heerdegen
  0 siblings, 0 replies; 6+ messages in thread
From: Michael Heerdegen @ 2021-01-26 12:22 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 17205

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Yup; I was able to reproduce that, too, and slapping an expand-file-name
> on default-directory fixed this.  So I think that's all in this bug
> report (it doesn't sound like subdirs in .dir-locals.el is used a lot,
> does it?),

Yes, I think so, and also dir locals in dired.  More generally,
directory local variables have some more potential that isn't used so
far, in my opinion.

> and I'm closing this bug report.

Thanks for your work, Lars!

Regards,

Michael.





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-01-26 12:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-06 12:55 bug#17205: 24.3.50; dired and directory variables Michael Heerdegen
2021-01-23 22:12 ` Lars Ingebrigtsen
2021-01-24 19:37   ` Michael Heerdegen
2021-01-25 12:50     ` Michael Heerdegen
2021-01-26  0:14     ` Lars Ingebrigtsen
2021-01-26 12:22       ` Michael Heerdegen

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.