Re: [PATCH] Documentation/CodingStyle: Use directory-local variables for emacs

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

 



On Friday, January 4, 2019 10:08:33 PM CET Bart Van Assche wrote:
> In emacs 23.1 support for directory-local variables was added (see also
> https://lists.gnu.org/archive/html/info-gnu-emacs/2009-07/msg00000.html).
> Simplify the settings in coding-style.rst by using that feature.
> Additionally, do not inherit any settings from emacs' linux coding style
> to minimize dependencies on the version of emacs that is being used.
> 
> I have verified with several large and nontrivial kernel source files
> that the new settings format code according to what checkpatch expects.
> 
> Signed-off-by: Bart Van Assche <bvanassche@xxxxxxx>
> Cc: Matthew Wilcox <willy@xxxxxxxxxxxxx>
> Cc: Geyslan G. Bem <geyslan@xxxxxxxxx>
> Cc: Tiago Natel de Moura <tiago4orion@xxxxxxxxx>
> Cc: Alison Chaiken <alison@xxxxxxxxxxxxx>
> Cc: Joe Perches <joe@xxxxxxxxxxx>
> Cc: Federico Vaga <federico.vaga@xxxxxxxxxx>
> Cc: Li Yang <leo@xxxxxxxxxxxxx>
> ---
>  Documentation/process/coding-style.rst | 57 +++++++++++++++++---------
>  1 file changed, 37 insertions(+), 20 deletions(-)
> 
> Changes compared to v1:
> - Removed top-level .dir-locals.el file again and updated coding-style.rst
> instead. - Restored the humourous paragraph about emacs.
> - Left out Italian and Chinese translations.

Since now there are only code changes, I think you can apply them on both 
Italian and Chinese translations.

As a general comment, I personally think that it worth to mention the fact 
that the user can take this code (actually part of it) and put it in a .dir-
locals.el file in the top-level directory.

> diff --git a/Documentation/process/coding-style.rst
> b/Documentation/process/coding-style.rst index 277c113376a6..5013883aec8e
> 100644
> --- a/Documentation/process/coding-style.rst
> +++ b/Documentation/process/coding-style.rst
> @@ -592,26 +592,43 @@ values.  To do the latter, you can stick the following
> in your .emacs file: (* (max steps 1)
>           c-basic-offset)))
> 
> -  (add-hook 'c-mode-common-hook
> -            (lambda ()
> -              ;; Add kernel style
> -              (c-add-style
> -               "linux-tabs-only"
> -               '("linux" (c-offsets-alist
> -                          (arglist-cont-nonempty
> -                           c-lineup-gcc-asm-reg
> -                           c-lineup-arglist-tabs-only))))))
> -
> -  (add-hook 'c-mode-hook
> -            (lambda ()
> -              (let ((filename (buffer-file-name)))
> -                ;; Enable kernel mode for the appropriate files
> -                (when (and filename
> -                           (string-match (expand-file-name
> "~/src/linux-trees") -                                         filename))
> -                  (setq indent-tabs-mode t)
> -                  (setq show-trailing-whitespace t)
> -                  (c-set-style "linux-tabs-only")))))
> +  (dir-locals-set-class-variables
> +   'linux-kernel
> +   '((c-mode . (
> +          (c-basic-offset . 8)
> +          (c-label-minimum-indentation . 0)
> +          (c-offsets-alist . (
> +                  (arglist-close         . c-lineup-arglist-tabs-only)
> +                  (arglist-cont-nonempty .
> +		      (c-lineup-gcc-asm-reg c-lineup-arglist-tabs-only))
> +                  (arglist-intro         . +)
> +                  (brace-list-intro      . +)
> +                  (c                     . c-lineup-C-comments)
> +                  (case-label            . 0)
> +                  (comment-intro         . c-lineup-comment)
> +                  (cpp-define-intro      . +)
> +                  (cpp-macro             . -1000)
> +                  (cpp-macro-cont        . +)
> +                  (defun-block-intro     . +)
> +                  (else-clause           . 0)
> +                  (func-decl-cont        . +)
> +                  (inclass               . +)
> +                  (inher-cont            . c-lineup-multi-inher)
> +                  (knr-argdecl-intro     . 0)
> +                  (label                 . -1000)
> +                  (statement             . 0)
> +                  (statement-block-intro . +)
> +                  (statement-case-intro  . +)
> +                  (statement-cont        . +)
> +                  (substatement          . +)
> +                  ))
> +          (indent-tabs-mode . t)
> +          (show-trailing-whitespace . t)
> +          ))))
> +
> +  (dir-locals-set-directory-class
> +   (expand-file-name "~/src/linux-trees")
> +   'linux-kernel)
> 
>  This will make emacs go better with the kernel coding style for C
>  files below ``~/src/linux-trees``.







[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux