From: "Eric Schulte" <schulte.eric@gmail.com>
To: emacs-devel@gnu.org
Subject: Re: .dir-locals.el
Date: Thu, 08 Jan 2009 16:30:33 -0800 [thread overview]
Message-ID: <8763kpz5g6.fsf@gmail.com> (raw)
In-Reply-To: jwvmye1g46t.fsf-monnier+emacs@gnu.org
Stefan Monnier <monnier@iro.umontreal.ca> writes:
> If you do
>
> (defadvice cd (after dir-locals-on-cd activate)
> (let ((buffer-file-name default-directory))
> (hack-dir-local-variables)))
>
This generates errors for me which look like.
Args out of range: "~/src/foo/", 23, 10
However when I actually replace (buffer-file-name) with
default-directory in the function it works fine.
>
> it might get you a bit further. But note that it still won't do what
> you want: it'll only give you file-local-variables-alist, which you then
> have to apply to the buffer.
>
> Furthermore, before applying it, you'll need to un-apply those settings
> you had applied earlier and which were relevant to the directory in
> which you were before `cd'.
>
> So you'll want something like (100% guaranteed untested)
>
[...]
>
Thanks for this suggestion, using a slightly altered version [1] of what
you suggested I was able to get the behavior I expected. It's certainly
not pretty, but it seems to work. Note: most of the code below is just
a copy of hack-dir-local-variables with all calls to buffer-file-name
removed.
Thanks, I'll be using this moving forward -- Eric
[1]
,----
| (defadvice cd (around dir-locals-on-cd activate)
| "Apply the variables defined in .dir-locals.el when changing
| into and outof a directory in eshell."
| ;; clean up old variables
| (while file-local-variables-alist
| (let ((x (pop file-local-variables-alist)))
| (kill-local-variable x)))
| ;; cd
| ad-do-it
| ;; run hack-dir-local-variables w/o buffer-file-name
| (let ((variables-file (dir-locals-find-file default-directory))
| (class nil)
| (dir-name nil))
| (cond
| ((stringp variables-file)
| (setq dir-name (file-name-directory default-directory))
| (setq class (dir-locals-read-from-file variables-file)))
| ((consp variables-file)
| (setq dir-name (car variables-file))
| (setq class (cdr variables-file))))
| (when class
| (let ((variables
| (dir-locals-collect-variables
| (dir-locals-get-class-variables class) dir-name nil)))
| (when variables
| (hack-local-variables-filter variables dir-name)))))
| ;; apply file-local-variables to buffer
| (while file-local-variables-alist
| (let ((x (pop file-local-variables-alist)))
| (if (consp x)
| (set (car x) (cdr x))
| (kill-local-variable x)))))
`----
prev parent reply other threads:[~2009-01-09 0:30 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-26 15:18 .dir-locals.el Eli Zaretskii
2008-12-26 16:04 ` .dir-locals.el Eli Zaretskii
2008-12-27 2:39 ` .dir-locals.el Miles Bader
2008-12-27 9:33 ` .dir-locals.el Eli Zaretskii
2008-12-27 16:43 ` .dir-locals.el Juanma Barranquero
2008-12-27 17:13 ` .dir-locals.el Dan Nicolaescu
2008-12-27 19:04 ` .dir-locals.el Eli Zaretskii
2009-01-08 0:08 ` .dir-locals.el Eric Schulte
2009-01-08 3:04 ` .dir-locals.el Kevin Rodgers
2009-01-08 5:53 ` .dir-locals.el Eric Schulte
2009-01-08 16:30 ` .dir-locals.el Stefan Monnier
2009-01-08 22:45 ` .dir-locals.el Juri Linkov
2009-01-09 3:14 ` .dir-locals.el Stefan Monnier
2009-01-09 0:30 ` Eric Schulte [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8763kpz5g6.fsf@gmail.com \
--to=schulte.eric@gmail.com \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.