]> code.delx.au - gnu-emacs/blobdiff - lisp/whitespace.el
Add a couple cells to lisp-prettify-symbols-alist
[gnu-emacs] / lisp / whitespace.el
index 917f0432ef2b11475c9b99affc54d67916392461..af906bab38fda4d35cc838f2a7568e0a590d411e 100644 (file)
@@ -1,6 +1,6 @@
 ;;; whitespace.el --- minor mode to visualize TAB, (HARD) SPACE, NEWLINE
 
-;; Copyright (C) 2000-2014 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2016 Free Software Foundation, Inc.
 
 ;; Author: Vinicius Jose Latorre <viniciusjl@ig.com.br>
 ;; Maintainer: Vinicius Jose Latorre <viniciusjl@ig.com.br>
 ;; `whitespace-indentation'    Face used to visualize 8 or more
 ;;                             SPACEs at beginning of line.
 ;;
+;; `whitespace-big-indent'     Face used to visualize big indentation.
+;;
 ;; `whitespace-empty'          Face used to visualize empty lines at
 ;;                             beginning and/or end of buffer.
 ;;
 ;; `whitespace-indentation-regexp'     Specify regexp for 8 or more
 ;;                                     SPACEs at beginning of line.
 ;;
+;; `whitespace-big-indent-regexp'      Specify big indentation at beginning of line
+;;                                     regexp.
+;;
 ;; `whitespace-empty-at-bob-regexp'    Specify regexp for empty lines
 ;;                                     at beginning of buffer.
 ;;
@@ -452,6 +457,10 @@ 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'.
 
+   big-indent          Big indentations are visualized via faces.
+                       It has effect only if `face' (see above)
+                       is present in `whitespace-style'.
+
    space-after-tab::tab                8 or more SPACEs after a TAB are
                                visualized via faces.
                                It has effect only if `face' (see above)
@@ -519,39 +528,44 @@ these values is:
    2. space-before-tab::tab
    3. space-before-tab::space
 
-So, for example, if indentation and indentation::space are
-included in `whitespace-style' list, the indentation value is
-evaluated instead of indentation::space value.
+For example, if `indentation' and `indentation::space' are
+included in `whitespace-style', the `indentation' value is used
+instead of the `indentation::space' value.
 
-One reason for not visualize spaces via faces (if `face' is not
-included in `whitespace-style') is to use exclusively for
-cleaning up a buffer.  See `whitespace-cleanup' and
-`whitespace-cleanup-region' for documentation.
+One reason to not use faces to visualize spaces (i.e., not
+include `face' in `whitespace-style') is to use `whitespace-mode'
+only for cleaning up a buffer.  See `whitespace-cleanup' and
+`whitespace-cleanup-region'.
 
 See also `whitespace-display-mappings' for documentation."
-  :type '(repeat :tag "Kind of Blank"
-                (choice :tag "Kind of Blank Face"
-                        (const :tag "(Face) Face visualization"
-                               face)
-                        (const :tag "(Face) Trailing TABs, SPACEs and HARD SPACEs"
-                               trailing)
-                        (const :tag "(Face) SPACEs and HARD SPACEs"
-                               spaces)
-                        (const :tag "(Face) TABs" tabs)
-                        (const :tag "(Face) Lines" lines)
-                        (const :tag "(Face) SPACEs before TAB"
-                               space-before-tab)
-                        (const :tag "(Face) NEWLINEs" newline)
-                        (const :tag "(Face) Indentation SPACEs"
-                               indentation)
-                        (const :tag "(Face) Empty Lines At BOB And/Or EOB"
-                               empty)
-                        (const :tag "(Face) SPACEs after TAB"
-                               space-after-tab)
-                        (const :tag "(Mark) SPACEs and HARD SPACEs"
-                               space-mark)
-                        (const :tag "(Mark) TABs" tab-mark)
-                        (const :tag "(Mark) NEWLINEs" newline-mark)))
+  :type '(set :tag "Kind of Blank"
+              (const :tag "(Face) Face visualization" face)
+              (const :tag "(Face) Trailing TABs, SPACEs and HARD SPACEs"
+                     trailing)
+              (const :tag "(Face) TABs" tabs)
+              (const :tag "(Face) SPACEs and HARD SPACEs" spaces)
+              (const :tag "(Face) Lines" lines)
+              (const :tag "(Face) Lines, only overlong part" lines-tail)
+              (const :tag "(Face) NEWLINEs" newline)
+              (const :tag "(Face) Empty Lines At BOB And/Or EOB" empty)
+              (const :tag "(Face) Indentation SPACEs" indentation::tab)
+              (const :tag "(Face) Indentation TABs"
+                     indentation::space)
+              (const :tag "(Face) Indentation TABs or SPACEs" indentation)
+              (const :tag "(Face) Too much line indentation" big-indent)
+              (const :tag "(Face) SPACEs after TAB: SPACEs"
+                     space-after-tab::tab)
+              (const :tag "(Face) SPACEs after TAB: TABs"
+                     space-after-tab::space)
+              (const :tag "(Face) SPACEs after TAB" space-after-tab)
+              (const :tag "(Face) SPACEs before TAB: SPACEs"
+                     space-before-tab::tab)
+              (const :tag "(Face) SPACEs before TAB: TABs"
+                     space-before-tab::space)
+              (const :tag "(Face) SPACEs before TAB" space-before-tab)
+              (const :tag "(Mark) SPACEs and HARD SPACEs" space-mark)
+              (const :tag "(Mark) TABs" tab-mark)
+              (const :tag "(Mark) NEWLINEs" newline-mark))
   :group 'whitespace)
 
 (defvar whitespace-space 'whitespace-space
@@ -673,6 +687,12 @@ Used when `whitespace-style' includes the value `indentation'.")
   "Face used to visualize 8 or more SPACEs at beginning of line."
   :group 'whitespace)
 
+(defface whitespace-big-indent
+  '((((class mono)) :inverse-video t :weight bold :underline t)
+    (t :background "red" :foreground "firebrick"))
+  "Face used to visualize big indentation."
+  :group 'whitespace)
+
 
 (defvar whitespace-empty 'whitespace-empty
   "Symbol face used to visualize empty lines at beginning and/or end of buffer.
@@ -838,6 +858,21 @@ Used when `whitespace-style' includes `space-after-tab',
               string)
   :group 'whitespace)
 
+(defcustom whitespace-big-indent-regexp
+  "^\\(\\(?:\t\\{4,\\}\\| \\{32,\\}\\)[\t ]*\\)"
+  "Specify big indentation 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 `big-indent'."
+  :version "25.1"
+  :type '(regexp :tag "Detect too much indentation at the beginning of a line")
+  :group 'whitespace)
+
 
 (defcustom whitespace-line-column 80
   "Specify column beyond which the line is highlighted.
@@ -849,28 +884,29 @@ Used when `whitespace-style' includes `lines' or `lines-tail'."
   :type '(choice :tag "Line Length Limit"
                 (integer :tag "Line Length")
                 (const :tag "Use fill-column" nil))
+  :safe  'integerp
   :group 'whitespace)
 
 
 ;; Hacked from `visible-whitespace-mappings' in visws.el
 (defcustom whitespace-display-mappings
   '(
-    (space-mark   ?\     [?\u00B7]     [?.])           ; space - centered dot
-    (space-mark   ?\xA0  [?\u00A4]     [?_])           ; hard space - currency
+    (space-mark   ?\     [?·]     [?.])               ; space - middle dot
+    (space-mark   ?\xA0  [?¤]     [?_])               ; hard space - currency sign
     ;; NEWLINE is displayed using the face `whitespace-newline'
     (newline-mark ?\n    [?$ ?\n])                     ; eol - dollar sign
-    ;; (newline-mark ?\n    [?\u21B5 ?\n] [?$ ?\n])    ; eol - downwards arrow
-    ;; (newline-mark ?\n    [?\u00B6 ?\n] [?$ ?\n])    ; eol - pilcrow
-    ;; (newline-mark ?\n    [?\u00AF ?\n]  [?$ ?\n])   ; eol - overscore
-    ;; (newline-mark ?\n    [?\u00AC ?\n]  [?$ ?\n])   ; eol - negation
-    ;; (newline-mark ?\n    [?\u00B0 ?\n]  [?$ ?\n])   ; eol - degrees
+    ;; (newline-mark ?\n    [?↵ ?\n] [?$ ?\n])       ; eol - downwards arrow
+    ;; (newline-mark ?\n    [?¶ ?\n] [?$ ?\n])        ; eol - pilcrow
+    ;; (newline-mark ?\n    [?¯ ?\n]  [?$ ?\n])       ; eol - overscore
+    ;; (newline-mark ?\n    [?¬ ?\n]  [?$ ?\n])       ; eol - negation
+    ;; (newline-mark ?\n    [?° ?\n]  [?$ ?\n])       ; eol - degrees
     ;;
     ;; WARNING: the mapping below has a problem.
     ;; When a TAB occupies exactly one column, it will display the
     ;; character ?\xBB at that column followed by a TAB which goes to
     ;; the next TAB column.
     ;; If this is a problem for you, please, comment the line below.
-    (tab-mark     ?\t    [?\u00BB ?\t] [?\\ ?\t])      ; tab - left quote mark
+    (tab-mark     ?\t    [?» ?\t] [?\\ ?\t])  ; tab - right guillemet
     )
   "Specify an alist of mappings for displaying characters.
 
@@ -1141,6 +1177,7 @@ See also `whitespace-newline' and `whitespace-display-mappings'."
     indentation
     indentation::tab
     indentation::space
+    big-indent
     space-after-tab
     space-after-tab::tab
     space-after-tab::space
@@ -1167,6 +1204,7 @@ See also `whitespace-newline' and `whitespace-display-mappings'."
     (?\C-i . indentation)
     (?I    . indentation::tab)
     (?i    . indentation::space)
+    (?\C-t . big-indent)
     (?\C-a . space-after-tab)
     (?A    . space-after-tab::tab)
     (?a    . space-after-tab::space)
@@ -1250,6 +1288,7 @@ Interactively, it reads one of the following chars:
    C-i toggle indentation SPACEs visualization (via `indent-tabs-mode')
    I   toggle indentation SPACEs visualization
    i   toggle indentation TABs visualization
+   C-t toggle big indentation visualization
    C-a toggle SPACEs after TAB visualization (via `indent-tabs-mode')
    A   toggle SPACEs after TAB: SPACEs visualization
    a   toggle SPACEs after TAB: TABs visualization
@@ -1279,6 +1318,7 @@ The valid symbols are:
    indentation         toggle indentation SPACEs visualization
    indentation::tab    toggle indentation SPACEs visualization
    indentation::space  toggle indentation TABs visualization
+   big-indent          toggle big indentation visualization
    space-after-tab             toggle SPACEs after TAB visualization
    space-after-tab::tab                toggle SPACEs after TAB: SPACEs visualization
    space-after-tab::space      toggle SPACEs after TAB: TABs visualization
@@ -1329,6 +1369,7 @@ Interactively, it accepts one of the following chars:
    C-i toggle indentation SPACEs visualization (via `indent-tabs-mode')
    I   toggle indentation SPACEs visualization
    i   toggle indentation TABs visualization
+   C-t toggle big indentation visualization
    C-a toggle SPACEs after TAB visualization (via `indent-tabs-mode')
    A   toggle SPACEs after TAB: SPACEs visualization
    a   toggle SPACEs after TAB: TABs visualization
@@ -1358,6 +1399,7 @@ The valid symbols are:
    indentation         toggle indentation SPACEs visualization
    indentation::tab    toggle indentation SPACEs visualization
    indentation::space  toggle indentation TABs visualization
+   big-indent          toggle big indentation visualization
    space-after-tab             toggle SPACEs after TAB visualization
    space-after-tab::tab                toggle SPACEs after TAB: SPACEs visualization
    space-after-tab::space      toggle SPACEs after TAB: TABs visualization
@@ -1824,9 +1866,11 @@ cleaning up these problems."
              (whitespace-insert-value ws-tab-width)
              (when has-bogus
                (goto-char (point-max))
-               (insert " Type `M-x whitespace-cleanup'"
+               (insert (substitute-command-keys
+                         " Type `\\[whitespace-cleanup]'")
                        " to cleanup the buffer.\n\n"
-                       " Type `M-x whitespace-cleanup-region'"
+                       (substitute-command-keys
+                         " Type `\\[whitespace-cleanup-region]'")
                        " to cleanup a region.\n\n"))
              (whitespace-display-window (current-buffer)))))
        has-bogus))))
@@ -1856,6 +1900,7 @@ cleaning up these problems."
  []  C-i - toggle indentation SPACEs visualization (via `indent-tabs-mode')
  []  I   - toggle indentation SPACEs visualization
  []  i   - toggle indentation TABs visualization
+ []  C-t - toggle big indentation visualization
  []  C-a - toggle SPACEs after TAB visualization (via `indent-tabs-mode')
  []  A   - toggle SPACEs after TAB: SPACEs visualization
  []  a   - toggle SPACEs after TAB: TABs visualization
@@ -1886,13 +1931,13 @@ cleaning up these problems."
 
 
 (defun whitespace-mark-x (nchars condition)
-  "Insert the mark ('X' or ' ') after NCHARS depending on CONDITION."
+  "Insert the mark (`X' or ` ') after NCHARS depending on CONDITION."
   (forward-char nchars)
   (insert (if condition "X" " ")))
 
 
 (defun whitespace-insert-option-mark (the-list the-value)
-  "Insert the option mark ('X' or ' ') in toggle options buffer."
+  "Insert the option mark (`X' or ` ') in toggle options buffer."
   (goto-char (point-min))
   (forward-line 2)
   (dolist (sym  the-list)
@@ -2109,6 +2154,7 @@ resultant list will be returned."
           (memq 'indentation             whitespace-active-style)
           (memq 'indentation::tab        whitespace-active-style)
           (memq 'indentation::space      whitespace-active-style)
+          (memq 'big-indent              whitespace-active-style)
           (memq 'space-after-tab         whitespace-active-style)
           (memq 'space-after-tab::tab    whitespace-active-style)
           (memq 'space-after-tab::space  whitespace-active-style)
@@ -2196,6 +2242,9 @@ resultant list will be returned."
                  ;; Show indentation SPACEs (TABs).
                  (whitespace-indentation-regexp 'space)))
               1 whitespace-indentation t)))
+       ,@(when (memq 'big-indent whitespace-active-style)
+           ;; Show big indentation.
+           `((,whitespace-big-indent-regexp 1 'whitespace-big-indent t)))
        ,@(when (memq 'empty whitespace-active-style)
            ;; Show empty lines at beginning of buffer.
            `((,#'whitespace-empty-at-bob-regexp