unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* how to use an external dir-locals file?
@ 2013-03-20 18:06 Ted Zlatanov
  2013-03-20 22:13 ` Stefan Monnier
  0 siblings, 1 reply; 6+ messages in thread
From: Ted Zlatanov @ 2013-03-20 18:06 UTC (permalink / raw)
  To: emacs-devel

I have a dir-locals file which I don't want to call .dir-locals.el (it
should not be the default, I just use it for reindenting code in a
particular way).  How can I specify it when loading a file if it's not
even in the same directory?

I looked at the current code but `hack-local-variables' and friends do
not seem to offer a consistent interface to do the above.

Thanks
Ted




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

* Re: how to use an external dir-locals file?
  2013-03-20 18:06 how to use an external dir-locals file? Ted Zlatanov
@ 2013-03-20 22:13 ` Stefan Monnier
  2013-03-21 14:02   ` Ted Zlatanov
  0 siblings, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2013-03-20 22:13 UTC (permalink / raw)
  To: emacs-devel

> I have a dir-locals file which I don't want to call .dir-locals.el (it
> should not be the default, I just use it for reindenting code in a
> particular way).  How can I specify it when loading a file if it's not
> even in the same directory?

There's no such thing.  You might like to M-x report-emacs-bug the
feature request, but please describe more precisely what it should look
like (e.g. I could imagine a special file-local setting which says "use
the settings from dir-locals file <foo>", but I'm not sure if having to
add a file-local setting is good enough for you).


        Stefan



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

* Re: how to use an external dir-locals file?
  2013-03-20 22:13 ` Stefan Monnier
@ 2013-03-21 14:02   ` Ted Zlatanov
  2013-03-26  0:46     ` Stefan Monnier
  0 siblings, 1 reply; 6+ messages in thread
From: Ted Zlatanov @ 2013-03-21 14:02 UTC (permalink / raw)
  To: emacs-devel

On Wed, 20 Mar 2013 18:13:42 -0400 Stefan Monnier <monnier@iro.umontreal.ca> wrote: 

>> I have a dir-locals file which I don't want to call .dir-locals.el (it
>> should not be the default, I just use it for reindenting code in a
>> particular way).  How can I specify it when loading a file if it's not
>> even in the same directory?

SM> There's no such thing.  You might like to M-x report-emacs-bug the
SM> feature request, but please describe more precisely what it should look
SM> like (e.g. I could imagine a special file-local setting which says "use
SM> the settings from dir-locals file <foo>", but I'm not sure if having to
SM> add a file-local setting is good enough for you).

I can implement it, no need for a bug report.

I imagined simply doing a dynamic let-bind around the call initially,
but if it's going to be a feature, then I could make it easier to
associate a dir-locals override with a file (matched by name).  When
there's a match and the override file exists, we just short-circuit the
search for .dir-locals.el and look at the override file instead.  When
the override file doesn't exist, I think we should not look at
.dir-locals.el, but behave as if none were found.

Does that makes sense?  If yes I'll do it.  Or would you rather just see
a let-bind of `dir-locals-file-override' for example?  That would
certainly be easier to implement.

To answer the second question--we want to *reindent* with dir-locals,
but not make them active for everyone by default, as file-locals or in
`.dir-locals.el'.

Ted




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

* Re: how to use an external dir-locals file?
  2013-03-21 14:02   ` Ted Zlatanov
@ 2013-03-26  0:46     ` Stefan Monnier
  2013-03-26  9:22       ` Ted Zlatanov
  0 siblings, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2013-03-26  0:46 UTC (permalink / raw)
  To: emacs-devel

> I imagined simply doing a dynamic let-bind around the call initially,
> but if it's going to be a feature, then I could make it easier to
> associate a dir-locals override with a file (matched by name).

Hmm... I think I misunderstood the intended usage.
Could you give more details about your use-case?
E.g. why not do something like

   (let ((tmp-foo-setting (lambda () (setq-local foo-indent 5))))
     (unwind-protect
         (progn
           (add-hook 'foo-mode-hook tmp-foo-setting)
           <doit>)
       (remove-hook 'foo-mode-hook tmp-foo-setting)))


-- Stefan



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

* Re: how to use an external dir-locals file?
  2013-03-26  0:46     ` Stefan Monnier
@ 2013-03-26  9:22       ` Ted Zlatanov
  2013-03-27 20:00         ` Stefan Monnier
  0 siblings, 1 reply; 6+ messages in thread
From: Ted Zlatanov @ 2013-03-26  9:22 UTC (permalink / raw)
  To: emacs-devel

On Mon, 25 Mar 2013 20:46:33 -0400 Stefan Monnier <monnier@iro.umontreal.ca> wrote: 

>> I imagined simply doing a dynamic let-bind around the call initially,
>> but if it's going to be a feature, then I could make it easier to
>> associate a dir-locals override with a file (matched by name).

SM> Hmm... I think I misunderstood the intended usage.
SM> Could you give more details about your use-case?
SM> E.g. why not do something like

SM>    (let ((tmp-foo-setting (lambda () (setq-local foo-indent 5))))
SM>      (unwind-protect
SM>          (progn
SM>            (add-hook 'foo-mode-hook tmp-foo-setting)
SM>            <doit>)
SM>        (remove-hook 'foo-mode-hook tmp-foo-setting)))

In this project, based on guidance from the owner, I want the settings
to be in CHECKOUT_ROOT/contrib/dir-locals.el (note no leading dot) that we use for
indentation, and which the user can optionally link to
CHECKOUT_ROOT/.dir-locals.el for general use.  The project owner does
not want CHECKOUT_ROOT/.dir-locals.el to exist.

In general, it's really nice to hold *reindentation* (not regular
indentation) settings in a .el file, even if it's not used as
.dir-locals.el, instead of file-local variables or custom ELisp hooks
and functions.  I just want a way to override the default choice of "the
nearest .dir-locals.el".  This may be related to the other discussion
about project roots a little bit, but for my purposes a dynamic
let-binding override is more than sufficient.

Ted




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

* Re: how to use an external dir-locals file?
  2013-03-26  9:22       ` Ted Zlatanov
@ 2013-03-27 20:00         ` Stefan Monnier
  0 siblings, 0 replies; 6+ messages in thread
From: Stefan Monnier @ 2013-03-27 20:00 UTC (permalink / raw)
  To: emacs-devel

> In general, it's really nice to hold *reindentation* (not regular
> indentation) settings in a .el file, even if it's not used as

That doesn't really help me understand your use-case, because I don't
know what's the difference between reindentation and indentation, nor
why you'd want them to behave differently.

> I just want a way to override the default choice of "the
> nearest .dir-locals.el".

Have you tried to let-bind dir-locals-file?  It should "just work" AFAICT.


        Stefan



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

end of thread, other threads:[~2013-03-27 20:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-20 18:06 how to use an external dir-locals file? Ted Zlatanov
2013-03-20 22:13 ` Stefan Monnier
2013-03-21 14:02   ` Ted Zlatanov
2013-03-26  0:46     ` Stefan Monnier
2013-03-26  9:22       ` Ted Zlatanov
2013-03-27 20:00         ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).