guix-devel
[Top][All Lists]
Advanced

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

Re: .dir-locals.el vs. guix-devel-mode


From: Ludovic Courtès
Subject: Re: .dir-locals.el vs. guix-devel-mode
Date: Tue, 29 Sep 2015 21:16:15 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Alex Kost <address@hidden> skribis:

> Ludovic Courtès (2015-09-27 23:29 +0300) wrote:
>
>> Alex Kost <address@hidden> skribis:
>>
> [...]
>>> The following code may be used to handle this indentation:
>>>
>>> (defun guix-devel-package-indent (state indent-point normal-indent)
>>>   (let ((count (if (and (ignore-errors (down-list) t)
>>>                         (looking-at "inherit\\>"))
>>>                    1
>>>                  0)))
>>>     (lisp-indent-specform count state indent-point normal-indent)))
>>>
>>> (put 'package 'scheme-indent-function 'guix-devel-package-indent)
>>
>> Nice!  I like it, I think it would be a nice addition.
>>
>> At the same time I wonder if defining sophisticated indentation rules is
>> a good idea in general.  (Though this one was already defined anyway.)
>
> I agree that it's better to avoid unusual indentation rules.
>
> Actually I don't like that ‘inherit’ field is treated specially, I would
> leave it as usual:

Yeah I ended up doing that quite often lately.

> But since the inherited packages have the form:
>
> (package (inherit foo)
>   (name "foo")
>   ...)
>
> I thought this is an existing rule, so I came up with that indentation
> function.

It is, but until now scheme-mode wouldn’t DTRT.  :-)

>> Good question.  .dir-locals.el includes a bunch of internal rules that
>> do not make sense outside.
>>
>> For those who do make sense outside, such as rules for ‘package’, I
>> think having them in .dir-locals.el has the advantage that Emacs users
>> cannot escape them inadvertently.  With guix-devel.el, there’s a greater
>> chance of people not loading it.
>>
>> Unless .dir-locals.el has something like:
>>
>>    (eval . (load "emacs/guix-devel.el")) ;…
>>
>> ?
>
> I am against this.  At first it is ugly; besides don't forget that it
> means "guix-devel.el" will be loaded *each time* you open a scheme file
> from the guix git directory.
>
> More generally, I'm strongly against using "eval" in .dir-locals.  IMO
> this file should be used only to set local variables, and ideally it
> shouldn't evaluate an arbitrary code.
>
>> Thoughts?
>
> So I think .dir-locals.el is not the proper place for indentation rules.
> IMHO they should be moved to "guix-devel.el" and the manual should
> recommend using 'guix-devel-mode' for editing guix package files as it
> provides the proper indenting, highlighting and some useful key
> bindings.

Yes, but I agree with Taylan: a passerby should get a reasonable setup
in place automatically.  That’s what I like about .dir-locals.el: it
allows you to make sure that a minimum set of rules is in place, which
in turn means that patches are more likely to come out right, which
means less frustration and increased happiness.

Using eval + load in .dir-locals.el is indeed ugly though.  So, for lack
of a better solution, I’m fine having some of the rules duplicated.
Specifically, rules for ‘package’, ‘origin’, ‘operating-system’,
‘substitute*’, ‘with-store’, ‘with-monad’, ‘run-with-store’,
‘run-with-state’, and ‘m…’.

How does that sound?

Ludo’.



reply via email to

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