;; Author: Vinicius Jose Latorre <viniciusjl@ig.com.br>
;; Maintainer: Vinicius Jose Latorre <viniciusjl@ig.com.br>
;; Keywords: data, wp
-;; Version: 10.0
+;; Version: 11.0
;; X-URL: http://www.emacswiki.org/cgi-bin/wiki/ViniciusJoseLatorre
;; This file is part of GNU Emacs.
;; it provides a visual mark for characters, for example, at the end
;; of line (?\xB6), at SPACEs (?\xB7) and at TABs (?\xBB).
;;
-;; The `whitespace-style-mark' and `whitespace-style-color' variables
-;; are used to select which way should be used to visualize blanks.
+;; The `whitespace-style' variable is used to select which way should
+;; be used to visualize blanks.
;;
;; Note that when whitespace is turned on, whitespace saves the
;; font-lock state, that is, if font-lock is on or off. And
;;
;; 1. empty lines at beginning of buffer.
;; 2. empty lines at end of buffer.
-;; If `whitespace-style-color' includes the value `empty', remove
-;; all empty lines at beginning and/or end of buffer.
+;; If `whitespace-style' includes the value `empty', remove all
+;; empty lines at beginning and/or end of buffer.
;;
;; 3. 8 or more SPACEs at beginning of line.
-;; If `whitespace-style-color' includes the value `indentation':
+;; If `whitespace-style' includes the value `indentation':
;; replace 8 or more SPACEs at beginning of line by TABs, if
;; `indent-tabs-mode' is non-nil; otherwise, replace TABs by
;; SPACEs.
-;; If `whitespace-style-color' includes the value
-;; `indentation::tab', replace 8 or more SPACEs at beginning of line
-;; by TABs.
-;; If `whitespace-style-color' includes the value
-;; `indentation::space', replace TABs by SPACEs.
+;; If `whitespace-style' includes the value `indentation::tab',
+;; replace 8 or more SPACEs at beginning of line by TABs.
+;; If `whitespace-style' includes the value `indentation::space',
+;; replace TABs by SPACEs.
;;
;; 4. SPACEs before TAB.
-;; If `whitespace-style-color' includes the value
-;; `space-before-tab': replace SPACEs by TABs, if
-;; `indent-tabs-mode' is non-nil; otherwise, replace TABs by
-;; SPACEs.
-;; If `whitespace-style-color' includes the value
+;; If `whitespace-style' includes the value `space-before-tab':
+;; replace SPACEs by TABs, if `indent-tabs-mode' is non-nil;
+;; otherwise, replace TABs by SPACEs.
+;; If `whitespace-style' includes the value
;; `space-before-tab::tab', replace SPACEs by TABs.
-;; If `whitespace-style-color' includes the value
+;; If `whitespace-style' includes the value
;; `space-before-tab::space', replace TABs by SPACEs.
;;
;; 5. SPACEs or TABs at end of line.
-;; If `whitespace-style-color' includes the value `trailing',
-;; remove all SPACEs or TABs at end of line.
+;; If `whitespace-style' includes the value `trailing', remove all
+;; SPACEs or TABs at end of line.
;;
;; 6. 8 or more SPACEs after TAB.
-;; If `whitespace-style-color' includes the value
-;; `space-after-tab': replace SPACEs by TABs, if `indent-tabs-mode'
-;; is non-nil; otherwise, replace TABs by SPACEs.
-;; If `whitespace-style-color' includes the value
-;; `space-after-tab::tab', replace SPACEs by TABs.
-;; If `whitespace-style-color' includes the value
+;; If `whitespace-style' includes the value `space-after-tab':
+;; replace SPACEs by TABs, if `indent-tabs-mode' is non-nil;
+;; otherwise, replace TABs by SPACEs.
+;; If `whitespace-style' includes the value `space-after-tab::tab',
+;; replace SPACEs by TABs.
+;; If `whitespace-style' includes the value
;; `space-after-tab::space', replace TABs by SPACEs.
;;
;;
;; Below it's shown a brief description of whitespace options, please,
;; see the options declaration in the code for a long documentation.
;;
-;; `whitespace-style-mark' Specify which kind of blank is
-;; visualized via display table.
-;;
-;; `whitespace-style-color' Specify which kind of blank is
-;; visualized via faces.
+;; `whitespace-style' Specify which kind of blank is
+;; visualized.
;;
;; `whitespace-space' Face used to visualize SPACE.
;;
:group 'data)
-(defcustom whitespace-style-mark '(space-mark tab-mark newline-mark)
- "*Specify which kind of blank is visualized via display table.
-
-It's a list containing some or all of the following values:
-
- space-mark SPACEs and HARD SPACEs are visualized.
-
- tab-mark TABs are visualized.
-
- newline-mark NEWLINEs are visualized.
-
-Any other value is ignored.
-
-If nil, don't visualize TABs, (HARD) SPACEs and NEWLINEs via display
-table.
-
-See also `whitespace-display-mappings' for documentation."
- :type '(repeat :tag "Kind of Blank Mark"
- (choice :tag "Kind of Blank Mark"
- (const :tag "SPACEs and HARD SPACEs"
- space-mark)
- (const :tag "TABs" tab-mark)
- (const :tag "NEWLINEs" newline-mark)))
- :group 'whitespace)
-
-
-(defcustom whitespace-style-color
+(defcustom whitespace-style
'(tabs spaces trailing lines space-before-tab newline
- indentation empty space-after-tab)
- "*Specify which kind of blank is visualized via faces.
+ indentation empty space-after-tab
+ space-mark tab-mark newline-mark)
+ "*Specify which kind of blank is visualized.
It's a list containing some or all of the following values:
- trailing trailing blanks are visualized.
+ trailing trailing blanks are visualized via faces.
- tabs TABs are visualized.
+ tabs TABs are visualized via faces.
- spaces SPACEs and HARD SPACEs are visualized.
+ spaces SPACEs and HARD SPACEs are visualized via
+ faces.
lines lines whose have columns beyond
- `whitespace-line-column' are highlighted.
+ `whitespace-line-column' are highlighted via
+ faces .
Whole line is highlighted.
- It has precedence over
- `lines-tail' (see below).
+ It has precedence over `lines-tail' (see
+ below).
lines-tail lines whose have columns beyond
- `whitespace-line-column' are highlighted.
+ `whitespace-line-column' are highlighted via
+ faces.
But only the part of line which goes
beyond `whitespace-line-column' column.
It has effect only if `lines' (see above)
- is not present in `whitespace-style-color'.
+ is not present in `whitespace-style'.
- newline NEWLINEs are visualized.
+ newline NEWLINEs are visualized via faces.
empty empty lines at beginning and/or end of buffer
- are visualized.
+ are visualized via faces.
indentation::tab 8 or more SPACEs at beginning of line are
- visualized.
+ visualized via faces.
- indentation::space TABs at beginning of line are visualized.
+ indentation::space TABs at beginning of line are visualized via
+ faces.
indentation 8 or more SPACEs at beginning of line are
visualized, if `indent-tabs-mode' (which see)
is non-nil; otherwise, TABs at beginning of
- line are visualized.
+ line are visualized via faces.
space-after-tab::tab 8 or more SPACEs after a TAB are
- visualized.
+ visualized via faces.
space-after-tab::space TABs are visualized when occurs 8 or
- more SPACEs after a TAB.
+ more SPACEs after a TAB via faces.
space-after-tab 8 or more SPACEs after a TAB are
visualized, if `indent-tabs-mode'
(which see) is non-nil; otherwise,
- the TABs are visualized.
+ the TABs are visualized via faces.
- space-before-tab::tab SPACEs before TAB are visualized.
+ space-before-tab::tab SPACEs before TAB are visualized via
+ faces.
space-before-tab::space TABs are visualized when occurs SPACEs
- before TAB.
+ before TAB via faces.
space-before-tab SPACEs before TAB are visualized, if
`indent-tabs-mode' (which see) is
non-nil; otherwise, the TABs are
- visualized.
+ visualized via faces.
+
+ space-mark SPACEs and HARD SPACEs are visualized via
+ display table.
+
+ tab-mark TABs are visualized via display table.
+
+ newline-mark NEWLINEs are visualized via display table.
Any other value is ignored.
-If nil, don't visualize TABs, (HARD) SPACEs and NEWLINEs via faces.
+If nil, don't visualize TABs, (HARD) SPACEs and NEWLINEs via faces and
+via display table.
There is an evaluation order for some values, if some values are
-included in `whitespace-style-color' list. For example, if
+included in `whitespace-style' list. For example, if
indentation, indentation::tab and/or indentation::space are
-included in `whitespace-style-color' list. The evaluation order
-for these values is:
+included in `whitespace-style' list. The evaluation order for
+these values is:
* For indentation:
1. indentation
3. space-before-tab::space
So, for example, if indentation and indentation::space are
-included in `whitespace-style-color' list, the indentation value
-is evaluated instead of indentation::space value."
- :type '(repeat :tag "Kind of Blank Face"
+included in `whitespace-style' list, the indentation value is
+evaluated instead of indentation::space value.
+
+See also `whitespace-display-mappings' for documentation."
+ :type '(repeat :tag "Kind of Blank"
(choice :tag "Kind of Blank Face"
- (const :tag "Trailing TABs, SPACEs and HARD SPACEs"
+ (const :tag "(Face) Trailing TABs, SPACEs and HARD SPACEs"
trailing)
- (const :tag "SPACEs and HARD SPACEs" spaces)
- (const :tag "TABs" tabs)
- (const :tag "Lines" lines)
- (const :tag "SPACEs before TAB"
+ (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 "NEWLINEs" newline)
- (const :tag "Indentation SPACEs" indentation)
- (const :tag "Empty Lines At BOB And/Or EOB"
+ (const :tag "(Face) NEWLINEs" newline)
+ (const :tag "(Face) Indentation SPACEs"
+ indentation)
+ (const :tag "(Face) Empty Lines At BOB And/Or EOB"
empty)
- (const :tag "SPACEs after TAB"
- space-after-tab)))
+ (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)))
:group 'whitespace)
(defcustom whitespace-space 'whitespace-space
"*Symbol face used to visualize SPACE.
-Used when `whitespace-style-color' includes the value `spaces'."
+Used when `whitespace-style' includes the value `spaces'."
:type 'face
:group 'whitespace)
(defcustom whitespace-hspace 'whitespace-hspace
"*Symbol face used to visualize HARD SPACE.
-Used when `whitespace-style-color' includes the value `spaces'."
+Used when `whitespace-style' includes the value `spaces'."
:type 'face
:group 'whitespace)
(defcustom whitespace-tab 'whitespace-tab
"*Symbol face used to visualize TAB.
-Used when `whitespace-style-color' includes the value `tabs'."
+Used when `whitespace-style' includes the value `tabs'."
:type 'face
:group 'whitespace)
See `whitespace-display-mappings'.
-Used when `whitespace-style-mark' includes the values `newline-mark'
-and `whitespace-style-color' includes `newline'."
+Used when `whitespace-style' includes the values `newline-mark'
+and `newline'."
:type 'face
:group 'whitespace)
(defcustom whitespace-trailing 'whitespace-trailing
"*Symbol face used to visualize traling blanks.
-Used when `whitespace-style-color' includes the value `trailing'."
+Used when `whitespace-style' includes the value `trailing'."
:type 'face
:group 'whitespace)
See `whitespace-line-column'.
-Used when `whitespace-style-color' includes the value `line'."
+Used when `whitespace-style' includes the value `line'."
:type 'face
:group 'whitespace)
(defcustom whitespace-space-before-tab 'whitespace-space-before-tab
"*Symbol face used to visualize SPACEs before TAB.
-Used when `whitespace-style-color' includes the value `space-before-tab'."
+Used when `whitespace-style' includes the value `space-before-tab'."
:type 'face
:group 'whitespace)
(defcustom whitespace-indentation 'whitespace-indentation
"*Symbol face used to visualize 8 or more SPACEs at beginning of line.
-Used when `whitespace-style-color' includes the value `indentation'."
+Used when `whitespace-style' includes the value `indentation'."
:type 'face
:group 'whitespace)
(defcustom whitespace-empty 'whitespace-empty
"*Symbol face used to visualize empty lines at beginning and/or end of buffer.
-Used when `whitespace-style-color' includes the value `empty'."
+Used when `whitespace-style' includes the value `empty'."
:type 'face
:group 'whitespace)
(defcustom whitespace-space-after-tab 'whitespace-space-after-tab
"*Symbol face used to visualize 8 or more SPACEs after TAB.
-Used when `whitespace-style-color' includes the value `space-after-tab'."
+Used when `whitespace-style' includes the value `space-after-tab'."
:type 'face
:group 'whitespace)
NOTE: Enclose always by \\\\( and \\\\) the elements to highlight.
Use exactly one pair of enclosing \\\\( and \\\\).
-Used when `whitespace-style-color' includes `spaces'."
+Used when `whitespace-style' includes `spaces'."
:type '(regexp :tag "HARD SPACE Chars")
:group 'whitespace)
NOTE: Enclose always by \\\\( and \\\\) the elements to highlight.
Use exactly one pair of enclosing \\\\( and \\\\).
-Used when `whitespace-style-color' includes `spaces'."
+Used when `whitespace-style' includes `spaces'."
:type '(regexp :tag "SPACE Chars")
:group 'whitespace)
NOTE: Enclose always by \\\\( and \\\\) the elements to highlight.
Use exactly one pair of enclosing \\\\( and \\\\).
-Used when `whitespace-style-color' includes `tabs'."
+Used when `whitespace-style' includes `tabs'."
:type '(regexp :tag "TAB Chars")
:group 'whitespace)
`whitespace-mode' surrounds this regexp by \"\\\\(\\\\(\" and
\"\\\\)+\\\\)$\".
-Used when `whitespace-style-color' includes `trailing'."
+Used when `whitespace-style' includes `trailing'."
:type '(regexp :tag "Trailing Chars")
:group 'whitespace)
that should be considered blank.
-Used when `whitespace-style-color' includes `space-before-tab',
+Used when `whitespace-style' includes `space-before-tab',
`space-before-tab::tab' or `space-before-tab::space'."
:type '(regexp :tag "SPACEs Before TAB")
:group 'whitespace)
that should be considered blank.
-Used when `whitespace-style-color' includes `indentation',
+Used when `whitespace-style' includes `indentation',
`indentation::tab' or `indentation::space'."
:type '(cons (regexp :tag "Indentation SPACEs")
(regexp :tag "Indentation TABs"))
that should be considered blank.
-Used when `whitespace-style-color' includes `empty'."
+Used when `whitespace-style' includes `empty'."
:type '(regexp :tag "Empty Lines At Beginning Of Buffer")
:group 'whitespace)
that should be considered blank.
-Used when `whitespace-style-color' includes `empty'."
+Used when `whitespace-style' includes `empty'."
:type '(regexp :tag "Empty Lines At End Of Buffer")
:group 'whitespace)
that should be considered blank.
-Used when `whitespace-style-color' includes `space-after-tab',
+Used when `whitespace-style' includes `space-after-tab',
`space-after-tab::tab' or `space-after-tab::space'."
:type '(regexp :tag "SPACEs After TAB")
:group 'whitespace)
(defcustom whitespace-line-column 80
"*Specify column beyond which the line is highlighted.
-Used when `whitespace-style-color' includes `lines' or `lines-tail'."
+Used when `whitespace-style' includes `lines' or `lines-tail'."
:type '(integer :tag "Line Length")
:group 'whitespace)
The NEWLINE character is displayed using the face given by
`whitespace-newline' variable.
-Used when `whitespace-style-mark' is non-nil."
+Used when `whitespace-style' includes `tab-mark', `space-mark' or
+`newline-mark'."
:type '(repeat
(list :tag "Character Mapping"
(choice :tag "Char Kind"
when local whitespace is turned on.
auto-cleanup cleanup any bogus whitespace when buffer is
- written or killed.
+ written or killed.
See `whitespace-cleanup' and
`whitespace-cleanup-region'.
;;;; User commands - Toggle
-(defconst whitespace-color-value-list
+(defconst whitespace-style-value-list
'(tabs
spaces
trailing
space-before-tab
space-before-tab::tab
space-before-tab::space
- )
- "List of valid `whitespace-style-color' values.")
-
-
-(defconst whitespace-mark-value-list
- '(tab-mark
+ help-newline ; value used by `whitespace-insert-option-mark'
+ tab-mark
space-mark
newline-mark
)
- "List of valid `whitespace-style-mark' values.")
+ "List of valid `whitespace-style' values.")
(defconst whitespace-toggle-option-alist
- '( ;; `whitespace-color-value-list' values
- (?t . tabs)
+ '((?t . tabs)
(?s . spaces)
(?r . trailing)
(?l . lines)
(?\C-b . space-before-tab)
(?B . space-before-tab::tab)
(?b . space-before-tab::space)
- ;; `whitespace-mark-value-list' values
(?T . tab-mark)
(?S . space-mark)
(?N . newline-mark)
- ;; restore values
- (?x . whitespace-style-color)
- (?z . whitespace-style-mark)
+ (?x . whitespace-style)
)
"Alist of toggle options.
CHAR is a char which the user will have to type.
SYMBOL is a valid symbol associated with CHAR.
- See `whitespace-color-value-list' and
- `whitespace-mark-value-list'.")
-
+ See `whitespace-style-value-list'.")
-(defvar whitespace-active-color nil
- "Used to save locally `whitespace-style-color' value.")
-(defvar whitespace-active-mark nil
- "Used to save locally `whitespace-style-mark' value.")
+(defvar whitespace-active-style nil
+ "Used to save locally `whitespace-style' value.")
(defvar whitespace-indent-tabs-mode indent-tabs-mode
"Used to save locally `indent-tabs-mode' value.")
S toggle SPACEs before TAB visualization
N toggle NEWLINE visualization
- x restore `whitespace-style-color' value
- z restore `whitespace-style-mark' value
+ x restore `whitespace-style' value
? display brief help
Non-interactively, ARG should be a symbol or a list of symbols.
space-mark toggle SPACEs before TAB visualization
newline-mark toggle NEWLINE visualization
- whitespace-style-color restore `whitespace-style-color' value
- whitespace-style-mark restore `whitespace-style-mark' value
+ whitespace-style restore `whitespace-style' value
Only useful with a windowing system.
-See `whitespace-style-color', `whitespace-style-mark' and
-`indent-tabs-mode' for documentation."
+See `whitespace-style' and `indent-tabs-mode' for documentation."
(interactive (whitespace-interactive-char t))
- (let ((whitespace-style-color
- (whitespace-toggle-list
- t arg whitespace-active-color whitespace-style-color
- 'whitespace-style-color whitespace-color-value-list))
- (whitespace-style-mark
- (whitespace-toggle-list
- t arg whitespace-active-mark whitespace-style-mark
- 'whitespace-style-mark whitespace-mark-value-list)))
+ (let ((whitespace-style
+ (whitespace-toggle-list t arg whitespace-active-style)))
(whitespace-mode 0)
(whitespace-mode 1)))
-(defvar whitespace-toggle-color nil
- "Used to toggle the global `whitespace-style-color' value.")
-(defvar whitespace-toggle-mark nil
- "Used to toggle the global `whitespace-style-mark' value.")
+(defvar whitespace-toggle-style nil
+ "Used to toggle the global `whitespace-style' value.")
;;;###autoload
S toggle SPACEs before TAB visualization
N toggle NEWLINE visualization
- x restore `whitespace-style-color' value
- z restore `whitespace-style-mark' value
+ x restore `whitespace-style' value
? display brief help
Non-interactively, ARG should be a symbol or a list of symbols.
space-mark toggle SPACEs before TAB visualization
newline-mark toggle NEWLINE visualization
- whitespace-style-color restore `whitespace-style-color' value
- whitespace-style-mark restore `whitespace-style-mark' value
+ whitespace-style restore `whitespace-style' value
Only useful with a windowing system.
-See `whitespace-style-color', `whitespace-style-mark' and
-`indent-tabs-mode' for documentation."
+See `whitespace-style' and `indent-tabs-mode' for documentation."
(interactive (whitespace-interactive-char nil))
- (let ((whitespace-style-color
- (whitespace-toggle-list
- nil arg whitespace-toggle-color whitespace-style-color
- 'whitespace-style-color whitespace-color-value-list))
- (whitespace-style-mark
- (whitespace-toggle-list
- nil arg whitespace-toggle-mark whitespace-style-mark
- 'whitespace-style-mark whitespace-mark-value-list)))
- (setq whitespace-toggle-color whitespace-style-color
- whitespace-toggle-mark whitespace-style-mark)
+ (let ((whitespace-style
+ (whitespace-toggle-list nil arg whitespace-toggle-style)))
+ (setq whitespace-toggle-style whitespace-style)
(global-whitespace-mode 0)
(global-whitespace-mode 1)))
1. empty lines at beginning of buffer.
2. empty lines at end of buffer.
- If `whitespace-style-color' includes the value `empty', remove all
+ If `whitespace-style' includes the value `empty', remove all
empty lines at beginning and/or end of buffer.
3. 8 or more SPACEs at beginning of line.
- If `whitespace-style-color' includes the value `indentation':
+ If `whitespace-style' includes the value `indentation':
replace 8 or more SPACEs at beginning of line by TABs, if
`indent-tabs-mode' is non-nil; otherwise, replace TABs by
SPACEs.
- If `whitespace-style-color' includes the value
- `indentation::tab', replace 8 or more SPACEs at beginning of
- line by TABs.
- If `whitespace-style-color' includes the value
- `indentation::space', replace TABs by SPACEs.
+ If `whitespace-style' includes the value `indentation::tab',
+ replace 8 or more SPACEs at beginning of line by TABs.
+ If `whitespace-style' includes the value `indentation::space',
+ replace TABs by SPACEs.
4. SPACEs before TAB.
- If `whitespace-style-color' includes the value `space-before-tab':
+ If `whitespace-style' includes the value `space-before-tab':
replace SPACEs by TABs, if `indent-tabs-mode' is non-nil;
otherwise, replace TABs by SPACEs.
- If `whitespace-style-color' includes the value
+ If `whitespace-style' includes the value
`space-before-tab::tab', replace SPACEs by TABs.
- If `whitespace-style-color' includes the value
+ If `whitespace-style' includes the value
`space-before-tab::space', replace TABs by SPACEs.
5. SPACEs or TABs at end of line.
- If `whitespace-style-color' includes the value `trailing', remove
+ If `whitespace-style' includes the value `trailing', remove
all SPACEs or TABs at end of line.
6. 8 or more SPACEs after TAB.
- If `whitespace-style-color' includes the value `space-after-tab':
+ If `whitespace-style' includes the value `space-after-tab':
replace SPACEs by TABs, if `indent-tabs-mode' is non-nil;
otherwise, replace TABs by SPACEs.
- If `whitespace-style-color' includes the value
+ If `whitespace-style' includes the value
`space-after-tab::tab', replace SPACEs by TABs.
- If `whitespace-style-color' includes the value
+ If `whitespace-style' includes the value
`space-after-tab::space', replace TABs by SPACEs.
-See `whitespace-style-color', `indent-tabs-mode' and `tab-width'
-for documentation."
+See `whitespace-style', `indent-tabs-mode' and `tab-width' for
+documentation."
(interactive "@*")
(if (and (or transient-mark-mode
current-prefix-arg)
;; PROBLEM 1: empty lines at bob
;; PROBLEM 2: empty lines at eob
;; ACTION: remove all empty lines at bob and/or eob
- (when (memq 'empty whitespace-style-color)
+ (when (memq 'empty whitespace-style)
(let (overwrite-mode) ; enforce no overwrite
(goto-char (point-min))
(when (re-search-forward
The problems cleaned up are:
1. 8 or more SPACEs at beginning of line.
- If `whitespace-style-color' includes the value `indentation':
+ If `whitespace-style' includes the value `indentation':
replace 8 or more SPACEs at beginning of line by TABs, if
`indent-tabs-mode' is non-nil; otherwise, replace TABs by
SPACEs.
- If `whitespace-style-color' includes the value
- `indentation::tab', replace 8 or more SPACEs at beginning of
- line by TABs.
- If `whitespace-style-color' includes the value
- `indentation::space', replace TABs by SPACEs.
+ If `whitespace-style' includes the value `indentation::tab',
+ replace 8 or more SPACEs at beginning of line by TABs.
+ If `whitespace-style' includes the value `indentation::space',
+ replace TABs by SPACEs.
2. SPACEs before TAB.
- If `whitespace-style-color' includes the value `space-before-tab':
+ If `whitespace-style' includes the value `space-before-tab':
replace SPACEs by TABs, if `indent-tabs-mode' is non-nil;
otherwise, replace TABs by SPACEs.
- If `whitespace-style-color' includes the value
+ If `whitespace-style' includes the value
`space-before-tab::tab', replace SPACEs by TABs.
- If `whitespace-style-color' includes the value
+ If `whitespace-style' includes the value
`space-before-tab::space', replace TABs by SPACEs.
3. SPACEs or TABs at end of line.
- If `whitespace-style-color' includes the value `trailing', remove
+ If `whitespace-style' includes the value `trailing', remove
all SPACEs or TABs at end of line.
4. 8 or more SPACEs after TAB.
- If `whitespace-style-color' includes the value `space-after-tab':
+ If `whitespace-style' includes the value `space-after-tab':
replace SPACEs by TABs, if `indent-tabs-mode' is non-nil;
otherwise, replace TABs by SPACEs.
- If `whitespace-style-color' includes the value
+ If `whitespace-style' includes the value
`space-after-tab::tab', replace SPACEs by TABs.
- If `whitespace-style-color' includes the value
+ If `whitespace-style' includes the value
`space-after-tab::space', replace TABs by SPACEs.
-See `whitespace-style-color', `indent-tabs-mode' and `tab-width'
-for documentation."
+See `whitespace-style', `indent-tabs-mode' and `tab-width' for
+documentation."
(interactive "@*r")
(let ((rstart (min start end))
(rend (copy-marker (max start end)))
;; ACTION: replace 8 or more SPACEs at bol by TABs, if
;; `indent-tabs-mode' is non-nil; otherwise, replace TABs by
;; SPACEs.
- ((memq 'indentation whitespace-style-color)
+ ((memq 'indentation whitespace-style)
(let ((regexp (whitespace-indentation-regexp)))
(goto-char rstart)
(while (re-search-forward regexp rend t)
(unless (eolp)
(indent-to tmp)))))
;; ACTION: replace 8 or more SPACEs at bol by TABs.
- ((memq 'indentation::tab whitespace-style-color)
+ ((memq 'indentation::tab whitespace-style)
(whitespace-replace-action
'tabify rstart rend
(whitespace-indentation-regexp 'tab) 0))
;; ACTION: replace TABs by SPACEs.
- ((memq 'indentation::space whitespace-style-color)
+ ((memq 'indentation::space whitespace-style)
(whitespace-replace-action
'untabify rstart rend
(whitespace-indentation-regexp 'space) 0)))
;; PROBLEM 3: SPACEs or TABs at eol
;; ACTION: remove all SPACEs or TABs at eol
- (when (memq 'trailing whitespace-style-color)
+ (when (memq 'trailing whitespace-style)
(whitespace-replace-action
'delete-region rstart rend
(whitespace-trailing-regexp) 1))
;; ACTION: replace 8 or more SPACEs by TABs, if
;; `indent-tabs-mode' is non-nil; otherwise, replace TABs by
;; SPACEs.
- ((memq 'space-after-tab whitespace-style-color)
+ ((memq 'space-after-tab whitespace-style)
(whitespace-replace-action
(if whitespace-indent-tabs-mode 'tabify 'untabify)
rstart rend (whitespace-space-after-tab-regexp) 1))
;; ACTION: replace 8 or more SPACEs by TABs.
- ((memq 'space-after-tab::tab whitespace-style-color)
+ ((memq 'space-after-tab::tab whitespace-style)
(whitespace-replace-action
'tabify rstart rend
(whitespace-space-after-tab-regexp 'tab) 1))
;; ACTION: replace TABs by SPACEs.
- ((memq 'space-after-tab::space whitespace-style-color)
+ ((memq 'space-after-tab::space whitespace-style)
(whitespace-replace-action
'untabify rstart rend
(whitespace-space-after-tab-regexp 'space) 1)))
;; ACTION: replace SPACEs before TAB by TABs, if
;; `indent-tabs-mode' is non-nil; otherwise, replace TABs by
;; SPACEs.
- ((memq 'space-before-tab whitespace-style-color)
+ ((memq 'space-before-tab whitespace-style)
(whitespace-replace-action
(if whitespace-indent-tabs-mode 'tabify 'untabify)
rstart rend whitespace-space-before-tab-regexp
(if whitespace-indent-tabs-mode 1 2)))
;; ACTION: replace SPACEs before TAB by TABs.
- ((memq 'space-before-tab::tab whitespace-style-color)
+ ((memq 'space-before-tab::tab whitespace-style)
(whitespace-replace-action
'tabify rstart rend
whitespace-space-before-tab-regexp 1))
;; ACTION: replace TABs by SPACEs.
- ((memq 'space-before-tab::space whitespace-style-color)
+ ((memq 'space-before-tab::space whitespace-style)
(whitespace-replace-action
'untabify rstart rend
whitespace-space-before-tab-regexp 2)))))
If FORCE is non-nil or \\[universal-argument] was pressed just
before calling `whitespace-report' interactively, it forces
-`whitespace-style-color' to have:
+`whitespace-style' to have:
empty
trailing
space-before-tab 5. SPACEs before TAB.
space-after-tab 6. 8 or more SPACEs after TAB.
-See `whitespace-style-color' and `whitespace-style-mark' for
-documentation.
+See `whitespace-style' for documentation.
See also `whitespace-cleanup' and `whitespace-cleanup-region' for
cleaning up these problems."
(interactive (list current-prefix-arg))
If FORCE is non-nil or \\[universal-argument] was pressed just
before calling `whitespace-report-region' interactively, it
-forces `whitespace-style-color' to have:
+forces `whitespace-style' to have:
empty
indentation
space-before-tab 5. SPACEs before TAB.
space-after-tab 6. 8 or more SPACEs after TAB.
-See `whitespace-style-color' and `whitespace-style-mark' for
-documentation.
+See `whitespace-style' for documentation.
See also `whitespace-cleanup' and `whitespace-cleanup-region' for
cleaning up these problems."
(interactive "r")
(mapcar
#'(lambda (option)
(when force
- (add-to-list 'whitespace-style-color
- (car option)))
+ (add-to-list 'whitespace-style (car option)))
(goto-char rstart)
(let ((regexp
(cond
(dolist (option whitespace-report-list)
(forward-line 1)
(whitespace-mark-x
- 27 (memq (car option) whitespace-style-color))
+ 27 (memq (car option) whitespace-style))
(whitespace-mark-x 7 (car bogus-list))
(setq bogus-list (cdr bogus-list)))
(forward-line 1)
[] S - toggle SPACE and HARD SPACE visualization
[] N - toggle NEWLINE visualization
- x - restore `whitespace-style-color' value
- z - restore `whitespace-style-mark' value
+ x - restore `whitespace-style' value
? - display this text\n\n"
"Text for whitespace toggle options.")
(defun whitespace-insert-option-mark (the-list the-value)
"Insert the option mark ('X' or ' ') in toggle options buffer."
+ (goto-char (point-min))
(forward-line 2)
(dolist (sym the-list)
- (forward-line 1)
- (whitespace-mark-x 2 (memq sym the-value))))
+ (if (eq sym 'help-newline)
+ (forward-line 2)
+ (forward-line 1)
+ (whitespace-mark-x 2 (memq sym the-value)))))
-(defun whitespace-help-on (chars style)
+(defun whitespace-help-on (style)
"Display the whitespace toggle options."
(unless (get-buffer whitespace-help-buffer-name)
(delete-other-windows)
(set-buffer buffer)
(erase-buffer)
(insert whitespace-help-text)
- (goto-char (point-min))
(whitespace-insert-option-mark
- whitespace-color-value-list chars)
- (whitespace-insert-option-mark
- whitespace-mark-value-list style)
+ whitespace-style-value-list style)
(whitespace-display-window buffer)))))
S toggle SPACE and HARD SPACE visualization
N toggle NEWLINE visualization
- x restore `whitespace-style-color' value
- z restore `whitespace-style-mark' value
+ x restore `whitespace-style' value
? display brief help
See also `whitespace-toggle-option-alist'."
(let* ((is-off (not (if local-p
whitespace-mode
global-whitespace-mode)))
- (chars (cond (is-off whitespace-style-color) ; use default value
- (local-p whitespace-active-color)
- (t whitespace-toggle-color)))
- (style (cond (is-off whitespace-style-mark) ; use default value
- (local-p whitespace-active-mark)
- (t whitespace-toggle-mark)))
+ (style (cond (is-off whitespace-style) ; use default value
+ (local-p whitespace-active-style)
+ (t whitespace-toggle-style)))
(prompt
(format "Whitespace Toggle %s (type ? for further options)-"
(if local-p "Local" "Global")))
(assq ch whitespace-toggle-option-alist)))))
;; while body
(if (eq ch ?\?)
- (whitespace-help-on chars style)
+ (whitespace-help-on style)
(ding)))
(whitespace-help-off)
(message " ")) ; clean echo area
(list sym))) ; return the apropriate symbol
-(defun whitespace-toggle-list (local-p arg the-list default-list
- sym-restore sym-list)
+(defun whitespace-toggle-list (local-p arg the-list)
"Toggle options in THE-LIST based on list ARG.
If LOCAL-P is non-nil, it uses a local context; otherwise, it
ARG is a list of options to be toggled.
THE-LIST is a list of options. This list will be toggled and the
-resultant list will be returned.
-
-DEFAULT-LIST is the default list of options. It is used to
-restore the options in THE-LIST.
-
-SYM-RESTORE is the symbol which indicates to restore the options
-in THE-LIST.
-
-SYM-LIST is a list of valid options, used to check if the ARG's
-options are valid."
+resultant list will be returned."
(unless (if local-p whitespace-mode global-whitespace-mode)
- (setq the-list default-list))
+ (setq the-list whitespace-style))
(setq the-list (copy-sequence the-list)) ; keep original list
(dolist (sym (if (listp arg) arg (list arg)))
(cond
+ ;; ignore help value
+ ((eq sym 'help-newline))
;; restore default values
- ((eq sym sym-restore)
- (setq the-list default-list))
+ ((eq sym 'whitespace-style)
+ (setq the-list whitespace-style))
;; toggle valid values
- ((memq sym sym-list)
+ ((memq sym whitespace-style-value-list)
(setq the-list (if (memq sym the-list)
(delq sym the-list)
(cons sym the-list))))))
the-list)
+
(defvar whitespace-display-table nil
"Used to save a local display table.")
(defvar whitespace-display-table-was-local nil
"Used to remember whether a buffer initially had a local display table.")
+
(defun whitespace-turn-on ()
"Turn on whitespace visualization."
;; prepare local hooks
(set (make-local-variable 'whitespace-font-lock-keywords) nil)
(set (make-local-variable 'whitespace-display-table) nil)
(set (make-local-variable 'whitespace-display-table-was-local) nil)
- (set (make-local-variable 'whitespace-active-mark)
- (if (listp whitespace-style-mark)
- whitespace-style-mark
- (list whitespace-style-mark)))
- (set (make-local-variable 'whitespace-active-color)
- (if (listp whitespace-style-color)
- whitespace-style-color
- (list whitespace-style-color)))
+ (set (make-local-variable 'whitespace-active-style)
+ (if (listp whitespace-style)
+ whitespace-style
+ (list whitespace-style)))
(set (make-local-variable 'whitespace-indent-tabs-mode)
indent-tabs-mode)
(set (make-local-variable 'whitespace-tab-width)
tab-width)
;; turn on whitespace
- (when whitespace-active-color
- (whitespace-color-on))
- (when whitespace-active-mark
+ (when whitespace-active-style
+ (whitespace-color-on)
(whitespace-display-char-on)))
(defun whitespace-turn-off ()
"Turn off whitespace visualization."
(whitespace-remove-local-hook)
- (when whitespace-active-color
- (whitespace-color-off))
- (when whitespace-active-mark
+ (when whitespace-active-style
+ (whitespace-color-off)
(whitespace-display-char-off)))
+(defun whitespace-style-face-p ()
+ "Return t if there is some visualization via face."
+ (or (memq 'tabs whitespace-active-style)
+ (memq 'spaces whitespace-active-style)
+ (memq 'trailing whitespace-active-style)
+ (memq 'lines whitespace-active-style)
+ (memq 'lines-tail whitespace-active-style)
+ (memq 'newline whitespace-active-style)
+ (memq 'empty whitespace-active-style)
+ (memq 'indentation whitespace-active-style)
+ (memq 'indentation::tab whitespace-active-style)
+ (memq 'indentation::space 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)
+ (memq 'space-before-tab whitespace-active-style)
+ (memq 'space-before-tab::tab whitespace-active-style)
+ (memq 'space-before-tab::space whitespace-active-style)))
+
+
(defun whitespace-color-on ()
"Turn on color visualization."
- (when whitespace-active-color
+ (when (whitespace-style-face-p)
(unless whitespace-font-lock
(setq whitespace-font-lock t
whitespace-font-lock-keywords
font-lock-mode)
(font-lock-mode 0)
;; add whitespace-mode color into font lock
- (when (memq 'spaces whitespace-active-color)
+ (when (memq 'spaces whitespace-active-style)
(font-lock-add-keywords
nil
(list
;; Show HARD SPACEs
(list whitespace-hspace-regexp 1 whitespace-hspace t))
t))
- (when (memq 'tabs whitespace-active-color)
+ (when (memq 'tabs whitespace-active-style)
(font-lock-add-keywords
nil
(list
;; Show TABs
(list whitespace-tab-regexp 1 whitespace-tab t))
t))
- (when (memq 'trailing whitespace-active-color)
+ (when (memq 'trailing whitespace-active-style)
(font-lock-add-keywords
nil
(list
;; Show trailing blanks
(list (whitespace-trailing-regexp) 1 whitespace-trailing t))
t))
- (when (or (memq 'lines whitespace-active-color)
- (memq 'lines-tail whitespace-active-color))
+ (when (or (memq 'lines whitespace-active-style)
+ (memq 'lines-tail whitespace-active-style))
(font-lock-add-keywords
nil
(list
(if (zerop rem)
""
(format ".\\{%d\\}" rem))))
- (if (memq 'lines whitespace-active-color)
+ (if (memq 'lines whitespace-active-style)
0 ; whole line
2) ; line tail
whitespace-line t))
t))
(cond
- ((memq 'space-before-tab whitespace-active-color)
+ ((memq 'space-before-tab whitespace-active-style)
(font-lock-add-keywords
nil
(list
(if whitespace-indent-tabs-mode 1 2)
whitespace-space-before-tab t))
t))
- ((memq 'space-before-tab::tab whitespace-active-color)
+ ((memq 'space-before-tab::tab whitespace-active-style)
(font-lock-add-keywords
nil
(list
(list whitespace-space-before-tab-regexp
1 whitespace-space-before-tab t))
t))
- ((memq 'space-before-tab::space whitespace-active-color)
+ ((memq 'space-before-tab::space whitespace-active-style)
(font-lock-add-keywords
nil
(list
2 whitespace-space-before-tab t))
t)))
(cond
- ((memq 'indentation whitespace-active-color)
+ ((memq 'indentation whitespace-active-style)
(font-lock-add-keywords
nil
(list
(list (whitespace-indentation-regexp)
1 whitespace-indentation t))
t))
- ((memq 'indentation::tab whitespace-active-color)
+ ((memq 'indentation::tab whitespace-active-style)
(font-lock-add-keywords
nil
(list
(list (whitespace-indentation-regexp 'tab)
1 whitespace-indentation t))
t))
- ((memq 'indentation::space whitespace-active-color)
+ ((memq 'indentation::space whitespace-active-style)
(font-lock-add-keywords
nil
(list
(list (whitespace-indentation-regexp 'space)
1 whitespace-indentation t))
t)))
- (when (memq 'empty whitespace-active-color)
+ (when (memq 'empty whitespace-active-style)
(font-lock-add-keywords
nil
(list
1 whitespace-empty t))
t))
(cond
- ((memq 'space-after-tab whitespace-active-color)
+ ((memq 'space-after-tab whitespace-active-style)
(font-lock-add-keywords
nil
(list
(list (whitespace-space-after-tab-regexp)
1 whitespace-space-after-tab t))
t))
- ((memq 'space-after-tab::tab whitespace-active-color)
+ ((memq 'space-after-tab::tab whitespace-active-style)
(font-lock-add-keywords
nil
(list
(list (whitespace-space-after-tab-regexp 'tab)
1 whitespace-space-after-tab t))
t))
- ((memq 'space-after-tab::space whitespace-active-color)
+ ((memq 'space-after-tab::space whitespace-active-style)
(font-lock-add-keywords
nil
(list
(defun whitespace-color-off ()
"Turn off color visualization."
- (when whitespace-active-color
- ;; turn off font lock
+ ;; turn off font lock
+ (when (whitespace-style-face-p)
(font-lock-mode 0)
(when whitespace-font-lock
(setq whitespace-font-lock nil
;;;; Hacked from visws.el (Miles Bader <miles@gnu.org>)
+(defun whitespace-style-mark-p ()
+ "Return t if there is some visualization via display table."
+ (or (memq 'tab-mark whitespace-active-style)
+ (memq 'space-mark whitespace-active-style)
+ (memq 'newline-mark whitespace-active-style)))
+
+
(defsubst whitespace-char-valid-p (char)
;; This check should be improved!!!
(or (< char 256)
(defun whitespace-display-char-on ()
"Turn on character display mapping."
- (when whitespace-display-mappings
+ (when (and whitespace-display-mappings
+ (whitespace-style-mark-p))
(let (vecs vec)
;; Remember whether a buffer has a local display table.
(unless whitespace-display-table-was-local
(setq buffer-display-table (make-display-table)))
(dolist (entry whitespace-display-mappings)
;; check if it is to display this mark
- (when (memq (car entry) whitespace-style-mark)
+ (when (memq (car entry) whitespace-style)
;; Get a displayable mapping.
(setq vecs (cddr entry))
(while (and vecs
(setq vec (copy-sequence (car vecs)))
;; NEWLINE char
(when (and (eq (cadr entry) ?\n)
- (memq 'newline whitespace-active-color))
+ (memq 'newline whitespace-active-style))
;; Only insert face bits on NEWLINE char mapping to avoid
;; obstruction of other faces like TABs and (HARD) SPACEs
;; faces, font-lock faces, etc.
(defun whitespace-display-char-off ()
"Turn off character display mapping."
(and whitespace-display-mappings
+ (whitespace-style-mark-p)
whitespace-display-table-was-local
(setq whitespace-display-table-was-local nil
buffer-display-table whitespace-display-table)))