dir-locals.el: Adds White Space support

Submitted by Andres Gomez on Nov. 9, 2016, 4:29 p.m.

Details

Message ID 20161109162937.20249-1-agomez@igalia.com
State Accepted
Headers show
Series "dir-locals.el: whitespace support" ( rev: 4 ) in Piglit

Not browsing as part of any series.

Commit Message

Andres Gomez Nov. 9, 2016, 4:29 p.m.
The White Space package, which is available since GNU Emacs 22, is
loaded and activated locally in prog-mode and cmake-mode.

Also, using White Space variables, we set highlighting through faces
on wrong indentation and the maximum length of a coding line.

Notice that:
 - The highlighting for the characters beyond the set length of a
   coding line is not activated by default, only for wrong
   indentations.
 - If the White Space package is not available, errors on loading or
   activation are ignored.
 - If the White Space mode is not activated the set variables would
   not have any effect.

v2: python-mode inherits from prog-mode
v3: Removed too long lines trail highlighting, as suggested by Ilia
    Mirkin.

Signed-off-by: Andres Gomez <agomez@igalia.com>
---
 .dir-locals.el | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

Patch hide | download patch | download mbox

diff --git a/.dir-locals.el b/.dir-locals.el
index 3bdca17..2a37aaf 100644
--- a/.dir-locals.el
+++ b/.dir-locals.el
@@ -1,11 +1,20 @@ 
 ((nil . ((indent-tabs-mode . t)
 	 (tab-width . 8)
-	 (show-trailing-whitespace . t)))
+	 (show-trailing-whitespace . t)
+	 (whitespace-style face indentation)
+	 (whitespace-line-column . 79)))
  (prog-mode .
-	    ((c-file-style . "linux")))
+	    ((c-file-style . "linux")
+	     (eval ignore-errors
+		   (require 'whitespace)
+		   (whitespace-mode 1))))
  (cmake-mode .
-	     ((cmake-tab-width . 8)))
+	     ((cmake-tab-width . 8)
+	      (eval ignore-errors
+		    (require 'whitespace)
+		    (whitespace-mode 1))))
  (python-mode .
 	      ((indent-tabs-mode . nil)
-	       (tab-width . 4)))
+	       (tab-width . 4)
+	       (whitespace-line-column . 80)))
  )

Comments

Acked-by: Ilia Mirkin <imirkin@alum.mit.edu>

I won't bother asking why one whitespace-line-column is set to 79 and
the other to 80. I'm sure the answer would just disappoint me.

On Wed, Nov 9, 2016 at 11:29 AM, Andres Gomez <agomez@igalia.com> wrote:
> The White Space package, which is available since GNU Emacs 22, is
> loaded and activated locally in prog-mode and cmake-mode.
>
> Also, using White Space variables, we set highlighting through faces
> on wrong indentation and the maximum length of a coding line.
>
> Notice that:
>  - The highlighting for the characters beyond the set length of a
>    coding line is not activated by default, only for wrong
>    indentations.
>  - If the White Space package is not available, errors on loading or
>    activation are ignored.
>  - If the White Space mode is not activated the set variables would
>    not have any effect.
>
> v2: python-mode inherits from prog-mode
> v3: Removed too long lines trail highlighting, as suggested by Ilia
>     Mirkin.
>
> Signed-off-by: Andres Gomez <agomez@igalia.com>
> ---
>  .dir-locals.el | 17 +++++++++++++----
>  1 file changed, 13 insertions(+), 4 deletions(-)
>
> diff --git a/.dir-locals.el b/.dir-locals.el
> index 3bdca17..2a37aaf 100644
> --- a/.dir-locals.el
> +++ b/.dir-locals.el
> @@ -1,11 +1,20 @@
>  ((nil . ((indent-tabs-mode . t)
>          (tab-width . 8)
> -        (show-trailing-whitespace . t)))
> +        (show-trailing-whitespace . t)
> +        (whitespace-style face indentation)
> +        (whitespace-line-column . 79)))
>   (prog-mode .
> -           ((c-file-style . "linux")))
> +           ((c-file-style . "linux")
> +            (eval ignore-errors
> +                  (require 'whitespace)
> +                  (whitespace-mode 1))))
>   (cmake-mode .
> -            ((cmake-tab-width . 8)))
> +            ((cmake-tab-width . 8)
> +             (eval ignore-errors
> +                   (require 'whitespace)
> +                   (whitespace-mode 1))))
>   (python-mode .
>               ((indent-tabs-mode . nil)
> -              (tab-width . 4)))
> +              (tab-width . 4)
> +              (whitespace-line-column . 80)))
>   )
> --
> 2.9.3
>