unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Michal Nazarewicz <mina86@mina86.com>
To: 18732@debbugs.gnu.org
Subject: bug#18732: [PATCH] whitespace-mode: add 'many-tabs style highlighting multiple TABs
Date: Wed, 15 Oct 2014 14:14:06 +0200	[thread overview]
Message-ID: <xa1th9z5lecx.fsf@mina86.com> (raw)

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	other threads:[~2014-10-15 12:14 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-15 12:14 Michal Nazarewicz [this message]
2014-10-16 13:07 ` bug#18732: [PATCH] whitespace-mode: add 'many-tabs style highlighting multiple TABs Ted Zlatanov
2014-10-17  7:39   ` bug#18732: [PATCH] whitespace-mode: add 'big-indent style highlighting big indention Michal Nazarewicz
2014-10-17 12:56     ` Ted Zlatanov
2014-10-17 13:16       ` bug#18732: [PATCHv3] " Michal Nazarewicz
2014-10-17 17:16         ` Ted Zlatanov
2014-10-17 17:18         ` Ted Zlatanov
2014-10-17 18:04           ` Stefan Monnier
2014-10-18  0:25             ` Ted Zlatanov
2014-10-17 17:03       ` bug#18732: [PATCH] " Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xa1th9z5lecx.fsf@mina86.com \
    --to=mina86@mina86.com \
    --cc=18732@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).