qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] Add .dir-locals.el file to configure emacs codi


From: Markus Armbruster
Subject: Re: [Qemu-devel] [PATCH] Add .dir-locals.el file to configure emacs coding style
Date: Wed, 03 Jun 2015 09:47:24 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

"Daniel P. Berrange" <address@hidden> writes:

> The default emacs setup indents by 2 spaces and uses tabs
> which is counter to the QEMU coding style rules. Adding a
> .dir-locals.el file in the top level of the GIT repo will
> inform emacs about the QEMU coding style, and so assist
> contributors in avoiding common style mistakes before
> they submit patches.

Yes, please!

> Signed-off-by: Daniel P. Berrange <address@hidden>
> ---
>  .dir-locals.el | 8 ++++++++
>  1 file changed, 8 insertions(+)
>  create mode 100644 .dir-locals.el
>
> diff --git a/.dir-locals.el b/.dir-locals.el
> new file mode 100644
> index 0000000..ddb2fae
> --- /dev/null
> +++ b/.dir-locals.el
> @@ -0,0 +1,8 @@
> +(
> + (c-mode . (
> +            (c-file-style . "K&R")
> +            (indent-tabs-mode . nil)
> +            (c-indent-level . 4)
> +            (c-basic-offset . 4)
> +            ))
> +)

Unidiomatic placement of parenthesis.

The documented style name is "k&r", not "K&R".

This is its definition in my Emacs (23.4.1):

    ("k&r"
     (c-basic-offset . 5)
     (c-comment-only-line-offset . 0)
     (c-offsets-alist . ((statement-block-intro . +)
                         (knr-argdecl-intro . 0)
                         (substatement-open . 0)
                         (substatement-label . 0)
                         (label . 0)
                         (statement-cont . +))))

You overwrite c-basic-offset.  But then you can just as well use style
"stroustrup":

    ("stroustrup"
     (c-basic-offset . 4)
     (c-comment-only-line-offset . 0)
     (c-offsets-alist . ((statement-block-intro . +)
                         (substatement-open . 0)
                         (substatement-label . 0)
                         (label . 0)
                         (statement-cont . +))))

What does c-indent-level do?  Are you sure it's needed?

Does the following .dir-locals.el work for you equally well?

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



reply via email to

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