bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#18732: [PATCH] whitespace-mode: add 'many-tabs style highlighting mu


From: Michal Nazarewicz
Subject: bug#18732: [PATCH] whitespace-mode: add 'many-tabs style highlighting multiple TABs
Date: Wed, 15 Oct 2014 14:14:06 +0200
User-agent: Notmuch/0.17+15~gb65ca8e (http://notmuchmail.org) Emacs/24.4.50.1 (x86_64-unknown-linux-gnu)

Add a 'many-tabs style to `whitespace-mode' designed to be used
in conjunction with 'tab style to indicate when indention level
is getting too big.  By default, four TABs are considered many
but `whitespace-many-tabs-regexp' can be configured to change
that.
---
 etc/NEWS           |  6 ++++++
 lisp/ChangeLog     |  8 ++++++++
 lisp/whitespace.el | 43 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 57 insertions(+)

diff --git a/etc/NEWS b/etc/NEWS
index e336ff5..a1da2065 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -238,6 +238,12 @@ name patterns (e.x. all "FOR_DOXYGEN_ONLY_*") to be 
excluded.
 *** New custom variable `tex-print-file-extension' to help users who
 use PDF instead of DVI.
 
+** whitespace-mode: new 'many-tabs style highlighting sequences of multiple
+TAB characters.  Designed to be used in conjunction with 'tab style to
+indicate when indention level is getting too big.  By default, four
+TABs are considered many but `whitespace-many-tabs-regexp' can be
+configured to change that.
+
 ** Obsolete packages
 
 ---
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 6916143..e00e77b 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
+2014-10-15  Michal Nazarewicz  <mina86@mina86.com>
+
+       * whitespace.el: Add 'many-tabs style highlighting sequences of
+       multiple TAB characters.  Designed to be used in conjunction with
+       'tab style to indicate when indention level is getting too big.
+       By default, four TABs are considered many but
+       `whitespace-many-tabs-regexp' can be configured to change that.
+
 2014-10-15  Eli Zaretskii  <eliz@gnu.org>
 
        * emacs-lisp/tabulated-list.el (tabulated-list-mode): Force
diff --git a/lisp/whitespace.el b/lisp/whitespace.el
index 917f043..9fa3f95 100644
--- a/lisp/whitespace.el
+++ b/lisp/whitespace.el
@@ -252,6 +252,8 @@
 ;;
 ;; `whitespace-tab'            Face used to visualize TAB.
 ;;
+;; `whitespace-many-tabs'      Face used to visualize sequences of many TABs.
+;;
 ;; `whitespace-newline'                Face used to visualize NEWLINE char
 ;;                             mapping.
 ;;
@@ -278,6 +280,8 @@
 ;;
 ;; `whitespace-tab-regexp'     Specify TAB characters regexp.
 ;;
+;; `whitespace-tab-regexp'     Specify many TAB characters regexp.
+;;
 ;; `whitespace-trailing-regexp'        Specify trailing characters regexp.
 ;;
 ;; `whitespace-space-before-tab-regexp'        Specify SPACEs before TAB
@@ -402,6 +406,11 @@ It's a list containing some or all of the following values:
                        It has effect only if `face' (see above)
                        is present in `whitespace-style'.
 
+   many-tabs           Sequence of multiple TABs (at least 4 by
+                        default) are visualized via faces.
+                       It has effect only if `face' (see above)
+                       is present in `whitespace-style'.
+
    spaces              SPACEs and HARD SPACEs are visualized via
                        faces.
                        It has effect only if `face' (see above)
@@ -538,6 +547,7 @@ See also `whitespace-display-mappings' for documentation."
                         (const :tag "(Face) SPACEs and HARD SPACEs"
                                spaces)
                         (const :tag "(Face) TABs" tabs)
+                        (const :tag "(Face) Many TABs" many-tabs)
                         (const :tag "(Face) Lines" lines)
                         (const :tag "(Face) SPACEs before TAB"
                                space-before-tab)
@@ -599,6 +609,15 @@ Used when `whitespace-style' includes the value `tabs'.")
   "Face used to visualize TAB."
   :group 'whitespace)
 
+(defface whitespace-many-tabs
+  '((((class color) (background dark))
+     :background "grey32" :foreground "darkgray")
+    (((class color) (background light))
+     :background "wheat"  :foreground "lightgray")
+    (t :inverse-video t))
+  "Face used to visualize sequence of several TABs in a row."
+  :group 'whitespace)
+
 
 (defvar whitespace-newline 'whitespace-newline
   "Symbol face used to visualize NEWLINE char mapping.
@@ -765,6 +784,19 @@ Used when `whitespace-style' includes `tabs'."
   :type '(regexp :tag "TAB Chars")
   :group 'whitespace)
 
+(defcustom whitespace-many-tabs-regexp "\\(\t\\{4,\\}\\)"
+  "Specify many TAB characters regexp.
+
+If you're using `mule' package, there may be other characters
+besides \"\\t\" that should be considered TAB.
+
+NOTE: Enclose always by \\\\( and \\\\) the elements to highlight.
+      Use exactly one pair of enclosing \\\\( and \\\\).
+
+Used when `whitespace-style' includes `many-tabs'."
+  :type '(regexp :tag "TAB Chars")
+  :group 'whitespace)
+
 
 (defcustom whitespace-trailing-regexp
   "\\([\t \u00A0]+\\)$"
@@ -1132,6 +1164,7 @@ See also `whitespace-newline' and 
`whitespace-display-mappings'."
 (defconst whitespace-style-value-list
   '(face
     tabs
+    many-tabs
     spaces
     trailing
     lines
@@ -1158,6 +1191,7 @@ See also `whitespace-newline' and 
`whitespace-display-mappings'."
 (defconst whitespace-toggle-option-alist
   '((?f    . face)
     (?t    . tabs)
+    (?\C-t . many-tabs)
     (?s    . spaces)
     (?r    . trailing)
     (?l    . lines)
@@ -1241,6 +1275,7 @@ Interactively, it reads one of the following chars:
   (VIA FACES)
    f   toggle face visualization
    t   toggle TAB visualization
+   C-t toggle many TABs visualization
    s   toggle SPACE and HARD SPACE visualization
    r   toggle trailing blanks visualization
    l   toggle \"long lines\" visualization
@@ -1270,6 +1305,7 @@ The valid symbols are:
 
    face                        toggle face visualization
    tabs                        toggle TAB visualization
+   many-tabs           toggle many TABs visualization
    spaces              toggle SPACE and HARD SPACE visualization
    trailing            toggle trailing blanks visualization
    lines               toggle \"long lines\" visualization
@@ -1320,6 +1356,7 @@ Interactively, it accepts one of the following chars:
   (VIA FACES)
    f   toggle face visualization
    t   toggle TAB visualization
+   C-t toggle many TABs visualization
    s   toggle SPACE and HARD SPACE visualization
    r   toggle trailing blanks visualization
    l   toggle \"long lines\" visualization
@@ -1349,6 +1386,7 @@ The valid symbols are:
 
    face                        toggle face visualization
    tabs                        toggle TAB visualization
+   many-tabs           toggle many TABs visualization
    spaces              toggle SPACE and HARD SPACE visualization
    trailing            toggle trailing blanks visualization
    lines               toggle \"long lines\" visualization
@@ -1847,6 +1885,7 @@ cleaning up these problems."
  FACES                                      \\__________________________/
  []  f   - toggle face visualization
  []  t   - toggle TAB visualization
+ []  C-t - toggle many TABs visualization
  []  s   - toggle SPACE and HARD SPACE visualization
  []  r   - toggle trailing blanks visualization
  []  l   - toggle \"long lines\" visualization
@@ -2100,6 +2139,7 @@ resultant list will be returned."
   "Return t if there is some visualization via face."
   (and (memq 'face whitespace-active-style)
        (or (memq 'tabs                    whitespace-active-style)
+           (memq 'many-tabs               whitespace-active-style)
           (memq 'spaces                  whitespace-active-style)
           (memq 'trailing                whitespace-active-style)
           (memq 'lines                   whitespace-active-style)
@@ -2149,6 +2189,9 @@ resultant list will be returned."
        ,@(when (memq 'tabs whitespace-active-style)
            ;; Show TABs.
            `((,whitespace-tab-regexp 1 whitespace-tab t)))
+       ,@(when (memq 'many-tabs whitespace-active-style)
+           ;; Show many TABs.
+           `((,whitespace-many-tabs-regexp 1 'whitespace-many-tabs t)))
        ,@(when (memq 'trailing whitespace-active-style)
            ;; Show trailing blanks.
            `((,#'whitespace-trailing-regexp 1 whitespace-trailing t)))






reply via email to

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