Mercurial > emacs
diff lisp/blank-mode.el @ 87878:3f6dc5290b26
Fix problem with cleanning blank faces when turniing off blank-mode. Eliminate -face suffix.
author | Vinicius Jose Latorre <viniciusjl@ig.com.br> |
---|---|
date | Mon, 21 Jan 2008 12:45:58 +0000 |
parents | 2427d974638e |
children | 10a88d763b88 |
line wrap: on
line diff
--- a/lisp/blank-mode.el Mon Jan 21 12:06:59 2008 +0000 +++ b/lisp/blank-mode.el Mon Jan 21 12:45:58 2008 +0000 @@ -1,4 +1,4 @@ -;;; blank-mode.el --- minor mode to visualise TAB, (HARD) SPACE, NEWLINE +;;; blank-mode.el --- minor mode to visualize TAB, (HARD) SPACE, NEWLINE ;; Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 ;; Free Software Foundation, Inc. @@ -6,7 +6,7 @@ ;; Author: Vinicius Jose Latorre <viniciusjl@ig.com.br> ;; Maintainer: Vinicius Jose Latorre <viniciusjl@ig.com.br> ;; Keywords: data, wp -;; Version: 8.0 +;; Version: 8.1 ;; X-URL: http://www.emacswiki.org/cgi-bin/wiki/ViniciusJoseLatorre ;; This file is part of GNU Emacs. @@ -33,10 +33,10 @@ ;; Introduction ;; ------------ ;; -;; This package is a minor mode to visualise blanks (TAB, (HARD) SPACE +;; This package is a minor mode to visualize blanks (TAB, (HARD) SPACE ;; and NEWLINE). ;; -;; blank-mode uses two ways to visualise blanks: faces and display +;; blank-mode uses two ways to visualize blanks: faces and display ;; table. ;; ;; * Faces are used to highlight the background with a color. @@ -47,7 +47,7 @@ ;; of line (?\xB6), at SPACEs (?\xB7) and at TABs (?\xBB). ;; ;; The `blank-style' and `blank-chars' variables are used to select -;; which way should be used to visualise blanks. +;; which way should be used to visualize blanks. ;; ;; Note that when blank-mode is turned on, blank-mode saves the ;; font-lock state, that is, if font-lock is on or off. And @@ -94,7 +94,7 @@ ;; `global-blank-toggle-options'. For example: ;; ;; (autoload 'blank-mode "blank-mode" -;; "Toggle blank visualisation." t) +;; "Toggle blank visualization." t) ;; (autoload 'blank-toggle-options "blank-mode" ;; "Toggle local `blank-mode' options." t) ;; @@ -175,27 +175,27 @@ ;; Below it's shown a brief description of blank-mode options, please, ;; see the options declaration in the code for a long documentation. ;; -;; `blank-style' Specify the visualisation style. +;; `blank-style' Specify the visualization style. ;; ;; `blank-chars' Specify which kind of blank is -;; visualised. +;; visualized. ;; -;; `blank-space-face' Face used to visualise SPACE. +;; `blank-space' Face used to visualize SPACE. ;; -;; `blank-hspace-face' Face used to visualise HARD SPACE. +;; `blank-hspace' Face used to visualize HARD SPACE. ;; -;; `blank-tab-face' Face used to visualise TAB. +;; `blank-tab' Face used to visualize TAB. ;; -;; `blank-newline-face' Face used to visualise NEWLINE char +;; `blank-newline' Face used to visualize NEWLINE char ;; mapping. ;; -;; `blank-trailing-face' Face used to visualise trailing +;; `blank-trailing' Face used to visualize trailing ;; blanks. ;; -;; `blank-line-face' Face used to visualise "long" lines. +;; `blank-line' Face used to visualize "long" lines. ;; -;; `blank-space-before-tab-face' Face used to visualise SPACEs -;; before TAB. +;; `blank-space-before-tab' Face used to visualize SPACEs before +;; TAB. ;; ;; `blank-space-regexp' Specify SPACE characters regexp. ;; @@ -268,7 +268,7 @@ (defgroup blank nil - "Visualise blanks (TAB, (HARD) SPACE and NEWLINE)." + "Visualize blanks (TAB, (HARD) SPACE and NEWLINE)." :link '(emacs-library-link :tag "Source Lisp File" "blank-mode.el") :version "22.2" :group 'wp @@ -276,17 +276,17 @@ (defcustom blank-style '(mark color) - "*Specify the visualisation style. + "*Specify the visualization style. It's a list which element value can be: - mark display mappings are visualised. + mark display mappings are visualized. - color faces are visualised. + color faces are visualized. Any other value is ignored. -If it's nil, don't visualise TABs, (HARD) SPACEs and NEWLINEs. +If nil, don't visualize TABs, (HARD) SPACEs and NEWLINEs. See also `blank-display-mappings' for documentation." :type '(repeat :tag "Style of Blank" @@ -298,26 +298,26 @@ (defcustom blank-chars '(tabs spaces trailing lines space-before-tab newline) - "*Specify which kind of blank is visualised. + "*Specify which kind of blank is visualized. It's a list which element value can be: - trailing trailing blanks are visualised. + trailing trailing blanks are visualized. - tabs TABs are visualised. + tabs TABs are visualized. - spaces SPACEs and HARD SPACEs are visualised. + spaces SPACEs and HARD SPACEs are visualized. lines lines whose length is greater than `blank-line-length' are highlighted. - space-before-tab SPACEs before TAB are visualised. + space-before-tab SPACEs before TAB are visualized. - newline NEWLINEs are visualised. + newline NEWLINEs are visualized. -Any other element value is ignored. +Any other value is ignored. -If it's nil, don't visualise TABs, (HARD) SPACEs and NEWLINEs. +If nil, don't visualize TABs, (HARD) SPACEs and NEWLINEs. Used when `blank-style' has `color' as an element. If `blank-chars' has `newline' as an element, used when `blank-style' @@ -335,62 +335,62 @@ :group 'blank) -(defcustom blank-space-face 'blank-space-face - "*Symbol face used to visualise SPACE. +(defcustom blank-space 'blank-space + "*Symbol face used to visualize SPACE. Used when `blank-style' has `color' as an element." :type 'face :group 'blank) -(defface blank-space-face +(defface blank-space '((((class color) (background dark)) (:background "grey20" :foreground "aquamarine3")) (((class color) (background light)) (:background "LightYellow" :foreground "aquamarine3")) (t (:inverse-video t))) - "Face used to visualise SPACE." + "Face used to visualize SPACE." :group 'blank) -(defcustom blank-hspace-face 'blank-hspace-face - "*Symbol face used to visualise HARD SPACE. +(defcustom blank-hspace 'blank-hspace + "*Symbol face used to visualize HARD SPACE. Used when `blank-style' has `color' as an element." :type 'face :group 'blank) -(defface blank-hspace-face ; 'nobreak-space +(defface blank-hspace ; 'nobreak-space '((((class color) (background dark)) (:background "grey24" :foreground "aquamarine3")) (((class color) (background light)) (:background "LemonChiffon3" :foreground "aquamarine3")) (t (:inverse-video t))) - "Face used to visualise HARD SPACE." + "Face used to visualize HARD SPACE." :group 'blank) -(defcustom blank-tab-face 'blank-tab-face - "*Symbol face used to visualise TAB. +(defcustom blank-tab 'blank-tab + "*Symbol face used to visualize TAB. Used when `blank-style' has `color' as an element." :type 'face :group 'blank) -(defface blank-tab-face +(defface blank-tab '((((class color) (background dark)) (:background "grey22" :foreground "aquamarine3")) (((class color) (background light)) (:background "beige" :foreground "aquamarine3")) (t (:inverse-video t))) - "Face used to visualise TAB." + "Face used to visualize TAB." :group 'blank) -(defcustom blank-newline-face 'blank-newline-face - "*Symbol face used to visualise NEWLINE char mapping. +(defcustom blank-newline 'blank-newline + "*Symbol face used to visualize NEWLINE char mapping. See `blank-display-mappings'. @@ -400,64 +400,64 @@ :group 'blank) -(defface blank-newline-face +(defface blank-newline '((((class color) (background dark)) (:background "grey26" :foreground "aquamarine3" :bold t)) (((class color) (background light)) (:background "linen" :foreground "aquamarine3" :bold t)) (t (:bold t :underline t))) - "Face used to visualise NEWLINE char mapping. + "Face used to visualize NEWLINE char mapping. See `blank-display-mappings'." :group 'blank) -(defcustom blank-trailing-face 'blank-trailing-face - "*Symbol face used to visualise traling blanks. +(defcustom blank-trailing 'blank-trailing + "*Symbol face used to visualize traling blanks. Used when `blank-style' has `color' as an element." :type 'face :group 'blank) -(defface blank-trailing-face ; 'trailing-whitespace +(defface blank-trailing ; 'trailing-whitespace '((((class mono)) (:inverse-video t :bold t :underline t)) (t (:background "red1" :foreground "yellow" :bold t))) - "Face used to visualise trailing blanks." + "Face used to visualize trailing blanks." :group 'blank) -(defcustom blank-line-face 'blank-line-face - "*Symbol face used to visualise \"long\" lines. +(defcustom blank-line 'blank-line + "*Symbol face used to visualize \"long\" lines. -See `blank-line-legnth'. +See `blank-line-length'. Used when `blank-style' has `color' as an element." :type 'face :group 'blank) -(defface blank-line-face +(defface blank-line '((((class mono)) (:inverse-video t :bold t :underline t)) (t (:background "gray20" :foreground "violet"))) - "Face used to visualise \"long\" lines. + "Face used to visualize \"long\" lines. See `blank-line-length'." :group 'blank) -(defcustom blank-space-before-tab-face 'blank-space-before-tab-face - "*Symbol face used to visualise SPACEs before TAB. +(defcustom blank-space-before-tab 'blank-space-before-tab + "*Symbol face used to visualize SPACEs before TAB. Used when `blank-style' has `color' as an element." :type 'face :group 'blank) -(defface blank-space-before-tab-face +(defface blank-space-before-tab '((((class mono)) (:inverse-video t :bold t :underline t)) (t (:background "DarkOrange" :foreground "firebrick"))) - "Face used to visualise SPACEs before TAB." + "Face used to visualize SPACEs before TAB." :group 'blank) @@ -469,18 +469,18 @@ \"\\xA0\" \"\\x8A0\" \"\\x920\" \"\\xE20\" \"\\xF20\" -that it should be considered HARD SPACE. +that should be considered HARD SPACE. Here are some examples: \"\\\\(^\\xA0+\\\\)\" \ -visualise only leading HARD SPACEs. +visualize only leading HARD SPACEs. \"\\\\(\\xA0+$\\\\)\" \ -visualise only trailing HARD SPACEs. +visualize only trailing HARD SPACEs. \"\\\\(^\\xA0+\\\\|\\xA0+$\\\\)\" \ -visualise leading and/or trailing HARD SPACEs. +visualize leading and/or trailing HARD SPACEs. \"\\t\\\\(\\xA0+\\\\)\\t\" \ -visualise only HARD SPACEs between TABs. +visualize only HARD SPACEs between TABs. NOTE: Enclose always by \\\\( and \\\\) the elements to highlight. Use exactly one pair of enclosing \\\\( and \\\\). @@ -495,15 +495,15 @@ "*Specify SPACE characters regexp. If you're using `mule' package, it may exist other characters -besides \" \" that it should be considered SPACE. +besides \" \" that should be considered SPACE. Here are some examples: - \"\\\\(^ +\\\\)\" visualise only leading SPACEs. - \"\\\\( +$\\\\)\" visualise only trailing SPACEs. + \"\\\\(^ +\\\\)\" visualize only leading SPACEs. + \"\\\\( +$\\\\)\" visualize only trailing SPACEs. \"\\\\(^ +\\\\| +$\\\\)\" \ -visualise leading and/or trailing SPACEs. - \"\\t\\\\( +\\\\)\\t\" visualise only SPACEs between TABs. +visualize leading and/or trailing SPACEs. + \"\\t\\\\( +\\\\)\\t\" visualize only SPACEs between TABs. NOTE: Enclose always by \\\\( and \\\\) the elements to highlight. Use exactly one pair of enclosing \\\\( and \\\\). @@ -518,15 +518,15 @@ "*Specify TAB characters regexp. If you're using `mule' package, it may exist other characters -besides \"\\t\" that it should be considered TAB. +besides \"\\t\" that should be considered TAB. Here are some examples: - \"\\\\(^\\t+\\\\)\" visualise only leading TABs. - \"\\\\(\\t+$\\\\)\" visualise only trailing TABs. + \"\\\\(^\\t+\\\\)\" visualize only leading TABs. + \"\\\\(\\t+$\\\\)\" visualize only trailing TABs. \"\\\\(^\\t+\\\\|\\t+$\\\\)\" \ -visualise leading and/or trailing TABs. - \" \\\\(\\t+\\\\) \" visualise only TABs between SPACEs. +visualize leading and/or trailing TABs. + \" \\\\(\\t+\\\\) \" visualize only TABs between SPACEs. NOTE: Enclose always by \\\\( and \\\\) the elements to highlight. Use exactly one pair of enclosing \\\\( and \\\\). @@ -546,9 +546,9 @@ \" \" \"\\t\" \"\\xA0\" \"\\x8A0\" \"\\x920\" \"\\xE20\" \ \"\\xF20\" -that it should be considered blank. +that should be considered blank. -NOTE: DOES NOT enclose by \\\\( and \\\\) the elements to highlight. +NOTE: DO NOT enclose by \\\\( and \\\\) the elements to highlight. `blank-mode' surrounds this regexp by \"\\\\(\\\\(\" and \"\\\\)+\\\\)$\". @@ -566,7 +566,7 @@ \" \" \"\\t\" \"\\xA0\" \"\\x8A0\" \"\\x920\" \"\\xE20\" \ \"\\xF20\" -that it should be considered blank. +that should be considered blank. Used when `blank-style' has `color' as an element, and `blank-chars' has `space-before-tab' as an element." @@ -595,7 +595,7 @@ (?\x920 [?\x924] [?_]) ; hard space - currency (?\xE20 [?\xE24] [?_]) ; hard space - currency (?\xF20 [?\xF24] [?_]) ; hard space - currency - ;; NEWLINE is displayed using the face `blank-newline-face' + ;; NEWLINE is displayed using the face `blank-newline' (?\n [?$ ?\n]) ; end-of-line - dollar sign ;; (?\n [?\u21B5 ?\n] [?$ ?\n]) ; end-of-line - downwards arrow ;; (?\n [?\xB6 ?\n] [?$ ?\n]) ; end-of-line - pilcrow @@ -626,9 +626,9 @@ that character is displayed unmodified. The NEWLINE character is displayed using the face given by -`blank-newline-face' variable. The characters in the vector to be -displayed will not have applied this face if the character code is -above #x1FFFF. +`blank-newline' variable. The characters in the vector to be +displayed will not have this face applied if the character code +is above #x1FFFF. Used when `blank-style' has `mark' as an element." :type '(repeat @@ -650,7 +650,7 @@ If nil, means no modes have `blank-mode' automatically turned on. If t, all modes that support `blank-mode' have it automatically turned on. -If a list, it should be a list of `major-mode' symbol names for +Else it should be a list of `major-mode' symbol names for which `blank-mode' should be automatically turned on. The sense of the list is negated if it begins with `not'. For example: @@ -674,11 +674,11 @@ ;;;###autoload (define-minor-mode blank-mode - "Toggle blank minor mode visualisation (bl on modeline). + "Toggle blank minor mode visualization (\"bl\" on modeline). -If ARG is null, toggle blank visualisation. -If ARG is a number and is greater than zero, turn on -visualisation; otherwise, turn off visualisation. +If ARG is null, toggle blank visualization. +If ARG is a number greater than zero, turn on visualization; +otherwise, turn off visualization. Only useful with a windowing system." :lighter " bl" :init-value nil @@ -698,11 +698,11 @@ (define-minor-mode global-blank-mode - "Toggle blank global minor mode visualisation (BL on modeline). + "Toggle blank global minor mode visualization (\"BL\" on modeline). -If ARG is null, toggle blank visualisation. -If ARG is a number and is greater than zero, turn on -visualisation; otherwise, turn off visualisation. +If ARG is null, toggle blank visualization. +If ARG is a number greater than zero, turn on visualization; +otherwise, turn off visualization. Only useful with a windowing system." :lighter " BL" :init-value nil @@ -766,14 +766,14 @@ lines newline ) - "List of valid `blank-chars' value.") + "List of valid `blank-chars' values.") (defconst blank-style-value-list '(color mark ) - "List of valid `blank-style' value.") + "List of valid `blank-style' values.") (defconst blank-toggle-option-alist @@ -824,27 +824,27 @@ Interactively, it reads one of the following chars: CHAR MEANING - t toggle TAB visualisation - s toggle SPACE and HARD SPACE visualisation - r toggle trailing blanks visualisation - b toggle SPACEs before TAB visualisation - l toggle \"long lines\" visualisation - n toggle NEWLINE visualisation + t toggle TAB visualization + s toggle SPACE and HARD SPACE visualization + r toggle trailing blanks visualization + b toggle SPACEs before TAB visualization + l toggle \"long lines\" visualization + n toggle NEWLINE visualization c toggle color faces m toggle visual mark x restore `blank-chars' value z restore `blank-style' value ? display brief help -Non-interactively, ARG should be a symbol or a list of symbol. +Non-interactively, ARG should be a symbol or a list of symbols. The valid symbols are: - tabs toggle TAB visualisation - spaces toggle SPACE and HARD SPACE visualisation - trailing toggle trailing blanks visualisation - space-before-tab toggle SPACEs before TAB visualisation - lines toggle \"long lines\" visualisation - newline toggle NEWLINE visualisation + tabs toggle TAB visualization + spaces toggle SPACE and HARD SPACE visualization + trailing toggle trailing blanks visualization + space-before-tab toggle SPACEs before TAB visualization + lines toggle \"long lines\" visualization + newline toggle NEWLINE visualization color toggle color faces mark toggle visual mark blank-chars restore `blank-chars' value @@ -881,27 +881,27 @@ Interactively, it reads one of the following chars: CHAR MEANING - t toggle TAB visualisation - s toggle SPACE and HARD SPACE visualisation - r toggle trailing blanks visualisation - b toggle SPACEs before TAB visualisation - l toggle \"long lines\" visualisation - n toggle NEWLINE visualisation + t toggle TAB visualization + s toggle SPACE and HARD SPACE visualization + r toggle trailing blanks visualization + b toggle SPACEs before TAB visualization + l toggle \"long lines\" visualization + n toggle NEWLINE visualization c toggle color faces m toggle visual mark x restore `blank-chars' value z restore `blank-style' value ? display brief help -Non-interactively, ARG should be a symbol or a list of symbol. +Non-interactively, ARG should be a symbol or a list of symbols. The valid symbols are: - tabs toggle TAB visualisation - spaces toggle SPACE and HARD SPACE visualisation - trailing toggle trailing blanks visualisation - space-before-tab toggle SPACEs before TAB visualisation - lines toggle \"long lines\" visualisation - newline toggle NEWLINE visualisation + tabs toggle TAB visualization + spaces toggle SPACE and HARD SPACE visualization + trailing toggle trailing blanks visualization + space-before-tab toggle SPACEs before TAB visualization + lines toggle \"long lines\" visualization + newline toggle NEWLINE visualization color toggle color faces mark toggle visual mark blank-chars restore `blank-chars' value @@ -942,12 +942,12 @@ "\ blank-mode toggle options: - [] t - toggle TAB visualisation - [] s - toggle SPACE and HARD SPACE visualisation - [] r - toggle trailing blanks visualisation - [] b - toggle SPACEs before TAB visualisation - [] l - toggle \"long lines\" visualisation - [] n - toggle NEWLINE visualisation + [] t - toggle TAB visualization + [] s - toggle SPACE and HARD SPACE visualization + [] r - toggle trailing blanks visualization + [] b - toggle SPACEs before TAB visualization + [] l - toggle \"long lines\" visualization + [] n - toggle NEWLINE visualization [] c - toggle color faces [] m - toggle visual mark @@ -1013,12 +1013,12 @@ It reads one of the following chars: CHAR MEANING - t toggle TAB visualisation - s toggle SPACE and HARD SPACE visualisation - r toggle trailing blanks visualisation - b toggle SPACEs before TAB visualisation - l toggle \"long lines\" visualisation - n toggle NEWLINE visualisation + t toggle TAB visualization + s toggle SPACE and HARD SPACE visualization + r toggle trailing blanks visualization + b toggle SPACEs before TAB visualization + l toggle \"long lines\" visualization + n toggle NEWLINE visualization c toggle color faces m toggle visual mark x restore `blank-chars' value @@ -1098,29 +1098,29 @@ (defun blank-turn-on () - "Turn on blank visualisation." + "Turn on blank visualization." (setq blank-active-style (if (listp blank-style) blank-style (list blank-style))) (setq blank-active-chars (if (listp blank-chars) blank-chars (list blank-chars))) - (and (memq 'color blank-active-style) - (blank-color-on)) - (and (memq 'mark blank-active-style) - (blank-display-char-on))) + (when (memq 'color blank-active-style) + (blank-color-on)) + (when (memq 'mark blank-active-style) + (blank-display-char-on))) (defun blank-turn-off () - "Turn off blank visualisation." - (and (memq 'color blank-active-style) - (blank-color-off)) - (and (memq 'mark blank-active-style) - (blank-display-char-off))) + "Turn off blank visualization." + (when (memq 'color blank-active-style) + (blank-color-off)) + (when (memq 'mark blank-active-style) + (blank-display-char-off))) (defun blank-color-on () - "Turn on color visualisation." + "Turn on color visualization." (when blank-active-chars (unless blank-font-lock (setq blank-font-lock t @@ -1135,16 +1135,16 @@ nil (list ;; Show SPACEs - (list blank-space-regexp 1 blank-space-face t) + (list blank-space-regexp 1 blank-space t) ;; Show HARD SPACEs - (list blank-hspace-regexp 1 blank-hspace-face t)) + (list blank-hspace-regexp 1 blank-hspace t)) t)) (when (memq 'tabs blank-active-chars) (font-lock-add-keywords nil (list ;; Show TABs - (list blank-tab-regexp 1 blank-tab-face t)) + (list blank-tab-regexp 1 blank-tab t)) t)) (when (memq 'trailing blank-active-chars) (font-lock-add-keywords @@ -1152,7 +1152,7 @@ (list ;; Show trailing blanks (list (concat "\\(\\(" blank-trailing-regexp "\\)+\\)$") - 1 blank-trailing-face t)) + 1 blank-trailing t)) t)) (when (memq 'lines blank-active-chars) (font-lock-add-keywords @@ -1161,7 +1161,7 @@ ;; Show "long" lines (list (concat "^\\(.\\{" (int-to-string blank-line-length) ",\\}\\)$") - 1 blank-line-face t)) + 1 blank-line t)) t)) (when (memq 'space-before-tab blank-active-chars) (font-lock-add-keywords @@ -1169,20 +1169,20 @@ (list ;; Show SPACEs before TAB (list blank-space-before-tab-regexp - 1 blank-space-before-tab-face t)) + 1 blank-space-before-tab t)) t)) ;; now turn on font lock and highlight blanks (font-lock-mode 1))) (defun blank-color-off () - "Turn off color visualisation." + "Turn off color visualization." (when blank-active-chars + ;; turn off font lock + (font-lock-mode 0) (when blank-font-lock (setq blank-font-lock nil font-lock-keywords blank-font-lock-keywords)) - ;; turn off font lock - (font-lock-mode 0) ;; restore original font lock state (font-lock-mode blank-font-lock-mode))) @@ -1252,7 +1252,7 @@ (or (eq (aref vec i) ?\n) (> (aref vec i) #x1FFFF) (aset vec i (make-glyph-code (aref vec i) - blank-newline-face))))) + blank-newline))))) ;; Display mapping (aset buffer-display-table (car entry) vec)) ;; Newline char - don't display it