emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: .dir-locals.el


From: Eric Schulte
Subject: Re: .dir-locals.el
Date: Wed, 07 Jan 2009 21:53:49 -0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

Kevin Rodgers <address@hidden> writes:

> Eric Schulte wrote:
>> Is there a good way to apply the variables set in .dir-locals.el when
>> changing into and out of a directory in eshell (or I suppose in other
>> Emacs shells as well)?
>>
>> I've tried setting eshell as a mode in the .dir-locals.el file but with
>> no success.  I've also tried to define after-advice on the `cd' function
>> in eshell, but there doesn't appear to be any means for applying local
>> variables to a buffer which doesn't have a file-name.
>>
>> (defadvice cd (after dir-locals-on-cd activate)
>>   "Apply the variables defined in .dir-locals.el when changing
>> into and outof a directory in eshell."
>>   (hack-dir-local-variables))
[...]
> I don't know.  But you should be able to get your advice to work by
> let-binding buffer-file-name to default-directory around the call to
> hack-dir-local-variables.
>
> Or perhaps to (expand-file-name "foo").

Thanks for the suggestion, by replacing (buffer-file-name) in
hack-dir-local-variables with default-directory I was able to save the
values specified in .dir-locals.el to the `file-local-variables-alist'.
Unfortunately it looks as though the values of the
`file-local-variables-alist' are only applied when the current buffer is
visiting a file.  Namely the resulting occurs in eshell

  ~ $ (message (format "%S" foo-foo-foo))
  nil
  ~ $ (message (format "%S" file-local-variables-alist))
  nil
  ~ $ cd src/mep/
  ~/src/mep $ cat .dir-locals.el 
  ((nil . ((foo-foo-foo . "eschulte"))))
  ~/src/mep $ (message (format "%S" file-local-variables-alist))
  ((foo-foo-foo . "eschulte"))
  ~/src/mep $ (message (format "%S" foo-foo-foo))
  nil
  ~/src/mep $ 

Either I'm missing something (more than likely) or given the current
implementation it does not make sense to try to use .dir-locals.el for
setting variables inside of an eshell buffer.

Best -- Eric




reply via email to

[Prev in Thread] Current Thread [Next in Thread]