Mailing List Archive

style(9), dir-locals.el and emacs-foo
Hello all,

I'm writing in the hope that someone will be better versed in emacs-lisp
than I am.

For a while we've had a very simple .dir-locals.el at the root of the
project directory, which goes a long way towards automating fulfillment
of style(9) for Emacs users, but doesn't quite make it.

((nil . ((indent-tabs-mode . t)))
(c-mode . ((c-file-style . "BSD"))))

I've only noticed one style(9) error that I and other Emacs users have
made consistently -- indentation of a list of function parameters (both
declaration and invocation) after the line with the open paren. Emacs
wants to do this:

myfunction(foo, bar, baz,
quux)

It lines up the parameter on the second line in the column after the
open paren.

style(9) wants it this way:

myfunction(foo, bar, baz,
quux)

As I understand it, the second line should be indented four spaces (in
addition to the current indent): "Long parameter lists are wrapped with
a normal four space indent."

I suspect that this should be easy enough to automate with a
modification of .dir-locals.el, but my elisp-foo isn't good enough and
I'm struggling with it.

It seems to me that we want to set arglist-cont-nonempty to 4:

https://www.gnu.org/software/emacs/manual/html_node/ccmode/Paren-List-Symbols.html

So I tried changing .dir-locals.el to:

((nil . ((indent-tabs-mode . t)))
(c-mode . ((c-file-style . "BSD")
(c-file-offsets
(arglist-cont-nonempty . 4)))))

... which sets the offset as a file local variable. But if we have that,
then at least the first time you open a .c or .h file, emacs pops up a
warning that the setting of c-file-offsets may not be safe, and asks for
confirmation:

https://www.gnu.org/software/emacs/manual/html_node/emacs/Safe-File-Variables.html

I don't think it's tolerable to have to do that every time for the rest
of our lives while working on Varnish.

I have tried declaring 4 as a safe value for the variable in
.dir-locals.el as follows, but I still get the warning:

((nil . ((indent-tabs-mode . t)
(eval . (add-to-list 'safe-local-variable-values
'(arglist-cont-nonempty . 4)))))
(c-mode . ((c-file-style . "BSD")
(c-file-offsets
(arglist-cont-nonempty . 4)))))

This is getting beyond my abilities, I'm not an elisp programmer. And
the failed attempt is already getting too complicated for my comfort
level -- just changing one offset feels like it should be a simple
problem to solve, say one extra line of code. So I suspect that I'm
going at it the wrong way.

Is there someone out there with a better mastery of elisp, who knows the
right magic spell?


Thanks,
Geoff
--
** * * UPLEX - Nils Goroll Systemoptimierung

Scheffelstraße 32
22301 Hamburg

Tel +49 40 2880 5731
Mob +49 176 636 90917
Fax +49 40 42949753

http://uplex.de
Re: style(9), dir-locals.el and emacs-foo [ In reply to ]
--------
In message <16b46047-10bf-af78-6cd6-a7bc75088ae1@uplex.de>, Geoff Simmons writes:

>I'm writing in the hope that someone will be better versed in emacs-lisp
>than I am.

My best suggestion is to look here:

https://www.freebsd.org/doc/en/books/developers-handbook/emacs.html

--
Poul-Henning Kamp | UNIX since Zilog Zeus 3.20
phk@FreeBSD.ORG | TCP/IP since RFC 956
FreeBSD committer | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.
_______________________________________________
varnish-dev mailing list
varnish-dev@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-dev
Re: style(9), dir-locals.el and emacs-foo [ In reply to ]
Try this github - https://github.com/hogand/openbsd-knf-emacs


On Tue, Oct 9, 2018 at 11:34 AM Poul-Henning Kamp <phk@phk.freebsd.dk>
wrote:

> --------
> In message <16b46047-10bf-af78-6cd6-a7bc75088ae1@uplex.de>, Geoff Simmons
> writes:
>
> >I'm writing in the hope that someone will be better versed in emacs-lisp
> >than I am.
>
> My best suggestion is to look here:
>
>
> https://www.freebsd.org/doc/en/books/developers-handbook/emacs.html
>
> --
> Poul-Henning Kamp | UNIX since Zilog Zeus 3.20
> phk@FreeBSD.ORG | TCP/IP since RFC 956
> FreeBSD committer | BSD since 4.3-tahoe
> Never attribute to malice what can adequately be explained by incompetence.
> _______________________________________________
> varnish-dev mailing list
> varnish-dev@varnish-cache.org
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-dev
>