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

Geoff Simmons geoff at
Tue Oct 9 15:12:20 UTC 2018

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,

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,

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:

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

((nil . ((indent-tabs-mode . t)))
 (c-mode . ((c-file-style . "BSD")
	     (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

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")
	     (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?

** * * UPLEX - Nils Goroll Systemoptimierung

Scheffelstraße 32
22301 Hamburg

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <>

More information about the varnish-dev mailing list