From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: .dir-locals.el vs. guix-devel-mode Date: Tue, 29 Sep 2015 21:16:15 +0200 Message-ID: <87r3lhxchs.fsf@gnu.org> References: <871tdm6i0i.fsf@gmail.com> <8737y28fss.fsf@gnu.org> <87d1x57yhg.fsf@gmail.com> <87si5zwqqu.fsf@gnu.org> <878u7qybjn.fsf_-_@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:45543) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zh0Ny-0000th-VR for guix-devel@gnu.org; Tue, 29 Sep 2015 15:16:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zh0Nx-0008U6-U0 for guix-devel@gnu.org; Tue, 29 Sep 2015 15:16:22 -0400 In-Reply-To: <878u7qybjn.fsf_-_@gmail.com> (Alex Kost's message of "Mon, 28 Sep 2015 15:26:52 +0300") List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: Alex Kost Cc: guix-devel@gnu.org Alex Kost skribis: > Ludovic Court=C3=A8s (2015-09-27 23:29 +0300) wrote: > >> Alex Kost 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 =E2=80=98inherit=E2=80=99 field is treated spe= cially, 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=E2=80=99t 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 =E2=80=98package= =E2=80=99, I >> think having them in .dir-locals.el has the advantage that Emacs users >> cannot escape them inadvertently. With guix-devel.el, there=E2=80=99s a= greater >> chance of people not loading it. >> >> Unless .dir-locals.el has something like: >> >> (eval . (load "emacs/guix-devel.el")) ;=E2=80=A6 >> >> ? > > 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=E2=80=99s 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=E2=80=99m fine having some of the rules duplicated. Specifically, rules for =E2=80=98package=E2=80=99, =E2=80=98origin=E2=80=99= , =E2=80=98operating-system=E2=80=99, =E2=80=98substitute*=E2=80=99, =E2=80=98with-store=E2=80=99, =E2=80=98with-= monad=E2=80=99, =E2=80=98run-with-store=E2=80=99, =E2=80=98run-with-state=E2=80=99, and =E2=80=98m=E2=80=A6=E2=80=99. How does that sound? Ludo=E2=80=99.