From c9dff4e359c9c4ee65794c3c820fce6c9f5db9e4 Mon Sep 17 00:00:00 2001 From: Vinicius Jose Latorre Date: Thu, 31 Jan 2008 16:08:29 +0000 Subject: [PATCH] Rename blank-mode.el to whitespace.el and obsolete/whitespace.el to obsolete/old-whitespace.el --- lisp/ChangeLog | 14 +- .../{whitespace.el => old-whitespace.el} | 0 lisp/{blank-mode.el => whitespace.el} | 1094 +++++++++-------- 3 files changed, 577 insertions(+), 531 deletions(-) rename lisp/obsolete/{whitespace.el => old-whitespace.el} (100%) rename lisp/{blank-mode.el => whitespace.el} (56%) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 4a76265d293..1dc4eed7365 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2008-01-31 Vinicius Jose Latorre + + * blank-mode.el: Renamed to whitespace.el. + + * obsolete/whitespace.el: Renamed to obsolete/old-whitespace.el. + 2008-01-31 Stefan Monnier * net/rcompile.el (remote-compile): Remove broken code. @@ -6,16 +12,16 @@ * term/w32-win.el (image-library-alist): Prefer libxpm.dll. +2008-01-31 Juanma Barranquero + + * linum.el (linum-unload-function): New function. + 2008-01-30 Nick Roberts * progmodes/gdb-ui.el (gdb-var-set-format-regexp): New constant. (gdb-var-set-format-handler): New function. (gdb-var-set-format): Use it. -2008-01-31 Juanma Barranquero - - * linum.el (linum-unload-function): New function. - 2008-01-30 Juanma Barranquero * emacs-lisp/check-declare.el (check-declare-directory): diff --git a/lisp/obsolete/whitespace.el b/lisp/obsolete/old-whitespace.el similarity index 100% rename from lisp/obsolete/whitespace.el rename to lisp/obsolete/old-whitespace.el diff --git a/lisp/blank-mode.el b/lisp/whitespace.el similarity index 56% rename from lisp/blank-mode.el rename to lisp/whitespace.el index 8956e95ac1e..d7603ddbb38 100644 --- a/lisp/blank-mode.el +++ b/lisp/whitespace.el @@ -1,4 +1,4 @@ -;;; blank-mode.el --- minor mode to visualize TAB, (HARD) SPACE, NEWLINE +;;; whitespace.el --- minor mode to visualize TAB, (HARD) SPACE, NEWLINE ;; Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 ;; Free Software Foundation, Inc. @@ -36,73 +36,76 @@ ;; This package is a minor mode to visualize blanks (TAB, (HARD) SPACE ;; and NEWLINE). ;; -;; blank-mode uses two ways to visualize blanks: faces and display +;; whitespace uses two ways to visualize blanks: faces and display ;; table. ;; ;; * Faces are used to highlight the background with a color. -;; blank-mode uses font-lock to highlight blank characters. +;; whitespace uses font-lock to highlight blank characters. ;; ;; * Display table changes the way a character is displayed, that is, ;; it provides a visual mark for characters, for example, at the end ;; 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 visualize blanks. +;; The `whitespace-style' and `whitespace-chars' variables are used to +;; select which way should be used to visualize blanks. ;; -;; Note that when blank-mode is turned on, blank-mode saves the +;; Note that when whitespace is turned on, whitespace saves the ;; font-lock state, that is, if font-lock is on or off. And -;; blank-mode restores the font-lock state when it is turned off. So, -;; if blank-mode is turned on and font-lock is off, blank-mode also +;; whitespace restores the font-lock state when it is turned off. So, +;; if whitespace is turned on and font-lock is off, whitespace also ;; turns on the font-lock to highlight blanks, but the font-lock will -;; be turned off when blank-mode is turned off. Thus, turn on -;; font-lock before blank-mode is on, if you want that font-lock -;; continues on after blank-mode is turned off. +;; be turned off when whitespace is turned off. Thus, turn on +;; font-lock before whitespace is on, if you want that font-lock +;; continues on after whitespace is turned off. ;; -;; When blank-mode is on, it takes care of highlighting some special +;; When whitespace is on, it takes care of highlighting some special ;; characters over the default mechanism of `nobreak-char-display' ;; (which see) and `show-trailing-whitespace' (which see). ;; -;; There are two ways of using blank-mode: local and global. +;; There are two ways of using whitespace: local and global. ;; -;; * Local blank-mode affects only the current buffer. +;; * Local whitespace affects only the current buffer. ;; -;; * Global blank-mode affects all current and future buffers. That -;; is, if you turn on global blank-mode and then create a new -;; buffer, the new buffer will also have blank-mode on. The -;; `blank-global-modes' variable controls which major-mode will be -;; automagically turned on. +;; * Global whitespace affects all current and future buffers. That +;; is, if you turn on global whitespace and then create a new +;; buffer, the new buffer will also have whitespace on. The +;; `whitespace-global-modes' variable controls which major-mode will +;; be automagically turned on. ;; ;; You can mix the local and global usage without any conflict. But -;; local blank-mode has priority over global blank-mode. Blank mode -;; is active in a buffer if you have enabled it in that buffer or if -;; you have enabled it globally. +;; local whitespace has priority over global whitespace. Whitespace +;; mode is active in a buffer if you have enabled it in that buffer or +;; if you have enabled it globally. ;; -;; When global and local blank-mode are on: +;; When global and local whitespace are on: ;; -;; * if local blank-mode is turned off, blank-mode is turned off for +;; * if local whitespace is turned off, whitespace is turned off for ;; the current buffer only. ;; -;; * if global blank-mode is turned off, blank-mode continues on only -;; in the buffers in which local blank-mode is on. +;; * if global whitespace is turned off, whitespace continues on only +;; in the buffers in which local whitespace is on. ;; -;; To use blank-mode, insert in your ~/.emacs: +;; To use whitespace, insert in your ~/.emacs: ;; -;; (require 'blank-mode) +;; (require 'whitespace-mode) ;; -;; Or autoload at least one of the commands`blank-mode', -;; `blank-toggle-options', `global-blank-mode' or -;; `global-blank-toggle-options'. For example: +;; Or autoload at least one of the commands`whitespace-mode', +;; `whitespace-toggle-options', `global-whitespace-mode' or +;; `global-whitespace-toggle-options'. For example: ;; -;; (autoload 'blank-mode "blank-mode" -;; "Toggle blank visualization." t) -;; (autoload 'blank-toggle-options "blank-mode" -;; "Toggle local `blank-mode' options." t) +;; (autoload 'whitespace-mode "whitespace" +;; "Toggle whitespace visualization." t) +;; (autoload 'whitespace-toggle-options "whitespace" +;; "Toggle local `whitespace-mode' options." t) ;; -;; blank-mode was inspired by: +;; whitespace was inspired by: ;; ;; whitespace.el Rajesh Vaidheeswarran ;; Warn about and clean bogus whitespaces in the file ;; (inspired the idea to warn and clean some blanks) +;; This was the original `whitespace.el' which was replaced by +;; `blank-mode.el'. And later `blank-mode.el' was renamed to +;; `whitespace.el'. ;; ;; show-whitespace-mode.el Aurelien Tisne ;; Simple mode to highlight whitespaces @@ -118,159 +121,162 @@ ;; idea was kept) ;; ;; -;; Using blank-mode +;; Using whitespace ;; ---------------- ;; ;; There is no problem if you mix local and global minor mode usage. ;; -;; * LOCAL blank-mode: -;; + To toggle blank-mode options locally, type: +;; * LOCAL whitespace: +;; + To toggle whitespace options locally, type: ;; -;; M-x blank-toggle-options RET +;; M-x whitespace-toggle-options RET ;; -;; + To activate blank-mode locally, type: +;; + To activate whitespace locally, type: ;; -;; C-u 1 M-x blank-mode RET +;; C-u 1 M-x whitespace-mode RET ;; -;; + To deactivate blank-mode locally, type: +;; + To deactivate whitespace locally, type: ;; -;; C-u 0 M-x blank-mode RET +;; C-u 0 M-x whitespace-mode RET ;; -;; + To toggle blank-mode locally, type: +;; + To toggle whitespace locally, type: ;; -;; M-x blank-mode RET +;; M-x whitespace-mode RET ;; -;; * GLOBAL blank-mode: -;; + To toggle blank-mode options globally, type: +;; * GLOBAL whitespace: +;; + To toggle whitespace options globally, type: ;; -;; M-x global-blank-toggle-options RET +;; M-x global-whitespace-toggle-options RET ;; -;; + To activate blank-mode globally, type: +;; + To activate whitespace globally, type: ;; -;; C-u 1 M-x global-blank-mode RET +;; C-u 1 M-x global-whitespace-mode RET ;; -;; + To deactivate blank-mode globally, type: +;; + To deactivate whitespace globally, type: ;; -;; C-u 0 M-x global-blank-mode RET +;; C-u 0 M-x global-whitespace-mode RET ;; -;; + To toggle blank-mode globally, type: +;; + To toggle whitespace globally, type: ;; -;; M-x global-blank-mode RET +;; M-x global-whitespace-mode RET ;; ;; There are also the following useful commands: ;; -;; `blank-cleanup' +;; `whitespace-cleanup' ;; Cleanup some blank problems in all buffer or at region. ;; -;; `blank-cleanup-region' +;; `whitespace-cleanup-region' ;; Cleanup some blank problems at region. ;; +;; `whitespace-buffer' +;; Turn on `whitespace-mode' forcing some settings. +;; ;; The problems, which are cleaned up, are: ;; ;; 1. empty lines at beginning of buffer. ;; 2. empty lines at end of buffer. -;; If `blank-chars' has `empty' as an element, remove all empty -;; lines at beginning and/or end of buffer. +;; If `whitespace-chars' has `empty' as an element, remove all +;; empty lines at beginning and/or end of buffer. ;; ;; 3. 8 or more SPACEs at beginning of line. -;; If `blank-chars' has `indentation' as an element, replace 8 or -;; more SPACEs at beginning of line by TABs. +;; If `whitespace-chars' has `indentation' as an element, replace 8 +;; or more SPACEs at beginning of line by TABs. ;; ;; 4. SPACEs before TAB. -;; If `blank-chars' has `space-before-tab' as an element, replace -;; SPACEs by TABs. +;; If `whitespace-chars' has `space-before-tab' as an element, +;; replace SPACEs by TABs. ;; ;; 5. SPACEs or TABs at end of line. -;; If `blank-chars' has `trailing' as an element, remove all +;; If `whitespace-chars' has `trailing' as an element, remove all ;; SPACEs or TABs at end of line." ;; ;; 6. 8 or more SPACEs after TAB. -;; If `blank-chars' has `space-after-tab' as an element, replace -;; SPACEs by TABs. +;; If `whitespace-chars' has `space-after-tab' as an element, +;; replace SPACEs by TABs. ;; ;; ;; Hooks ;; ----- ;; -;; blank-mode has the following hook variables: +;; whitespace has the following hook variables: ;; -;; `blank-mode-hook' -;; It is evaluated always when blank-mode is turned on locally. +;; `whitespace-mode-hook' +;; It is evaluated always when whitespace is turned on locally. ;; -;; `global-blank-mode-hook' -;; It is evaluated always when blank-mode is turned on globally. +;; `global-whitespace-mode-hook' +;; It is evaluated always when whitespace is turned on globally. ;; -;; `blank-load-hook' -;; It is evaluated after blank-mode package is loaded. +;; `whitespace-load-hook' +;; It is evaluated after whitespace package is loaded. ;; ;; ;; Options ;; ------- ;; -;; Below it's shown a brief description of blank-mode options, please, +;; Below it's shown a brief description of whitespace options, please, ;; see the options declaration in the code for a long documentation. ;; -;; `blank-style' Specify the visualization style. +;; `whitespace-style' Specify the visualization style. ;; -;; `blank-chars' Specify which kind of blank is +;; `whitespace-chars' Specify which kind of blank is ;; visualized. ;; -;; `blank-space' Face used to visualize SPACE. +;; `whitespace-space' Face used to visualize SPACE. ;; -;; `blank-hspace' Face used to visualize HARD SPACE. +;; `whitespace-hspace' Face used to visualize HARD SPACE. ;; -;; `blank-tab' Face used to visualize TAB. +;; `whitespace-tab' Face used to visualize TAB. ;; -;; `blank-newline' Face used to visualize NEWLINE char +;; `whitespace-newline' Face used to visualize NEWLINE char ;; mapping. ;; -;; `blank-trailing' Face used to visualize trailing +;; `whitespace-trailing' Face used to visualize trailing ;; blanks. ;; -;; `blank-line' Face used to visualize "long" lines. +;; `whitespace-line' Face used to visualize "long" lines. ;; -;; `blank-space-before-tab' Face used to visualize SPACEs before -;; TAB. +;; `whitespace-space-before-tab' Face used to visualize SPACEs +;; before TAB. ;; -;; `blank-indentation' Face used to visualize 8 or more +;; `whitespace-indentation' Face used to visualize 8 or more ;; SPACEs at beginning of line. ;; -;; `blank-empty' Face used to visualize empty lines at +;; `whitespace-empty' Face used to visualize empty lines at ;; beginning and/or end of buffer. ;; -;; `blank-space-after-tab' Face used to visualize 8 or more +;; `whitespace-space-after-tab' Face used to visualize 8 or more ;; SPACEs after TAB. ;; -;; `blank-space-regexp' Specify SPACE characters regexp. +;; `whitespace-space-regexp' Specify SPACE characters regexp. ;; -;; `blank-hspace-regexp' Specify HARD SPACE characters regexp. +;; `whitespace-hspace-regexp' Specify HARD SPACE characters regexp. ;; -;; `blank-tab-regexp' Specify TAB characters regexp. +;; `whitespace-tab-regexp' Specify TAB characters regexp. ;; -;; `blank-trailing-regexp' Specify trailing characters regexp. +;; `whitespace-trailing-regexp' Specify trailing characters regexp. ;; -;; `blank-space-before-tab-regexp' Specify SPACEs before TAB +;; `whitespace-space-before-tab-regexp' Specify SPACEs before TAB ;; regexp. ;; -;; `blank-indentation-regexp' Specify regexp for 8 or more SPACEs at -;; beginning of line. +;; `whitespace-indentation-regexp' Specify regexp for 8 or more +;; SPACEs at beginning of line. ;; -;; `blank-empty-at-bob-regexp' Specify regexp for empty lines at -;; beginning of buffer. +;; `whitespace-empty-at-bob-regexp' Specify regexp for empty lines +;; at beginning of buffer. ;; -;; `blank-empty-at-eob-regexp' Specify regexp for empty lines at end -;; of buffer. +;; `whitespace-empty-at-eob-regexp' Specify regexp for empty lines +;; at end of buffer. ;; -;; `blank-space-after-tab-regexp' Specify regexp for 8 or more +;; `whitespace-space-after-tab-regexp' Specify regexp for 8 or more ;; SPACEs after TAB. ;; -;; `blank-line-column' Specify column beyond which the line +;; `whitespace-line-column' Specify column beyond which the line ;; is highlighted. ;; -;; `blank-display-mappings' Specify an alist of mappings for -;; displaying characters. +;; `whitespace-display-mappings' Specify an alist of mappings +;; for displaying characters. ;; -;; `blank-global-modes' Modes for which global `blank-mode' is +;; `whitespace-global-modes' Modes for which global `whitespace-mode' is ;; automagically turned on. ;; ;; @@ -282,7 +288,7 @@ ;; ;; Thanks to Juri Linkov for suggesting: ;; * `define-minor-mode'. -;; * `global-blank-*' name for global commands. +;; * `global-whitespace-*' name for global commands. ;; ;; Thanks to Robert J. Chassell for doc fix and testing. ;; @@ -302,13 +308,13 @@ ;; newline character mapping. ;; ;; Thanks to Pete Forman for indicating -;; whitespace-mode on XEmacs. +;; whitespace-mode.el on XEmacs. ;; ;; Thanks to Miles Bader for handling display table via ;; visws.el (his code was modified, but the main idea was kept). ;; ;; Thanks to: -;; Rajesh Vaidheeswarran whitespace.el +;; Rajesh Vaidheeswarran (original) whitespace.el ;; Aurelien Tisne show-whitespace-mode.el ;; Lawrence Mitchell whitespace-mode.el ;; Miles Bader visws.el @@ -327,15 +333,15 @@ ;;; Interface to the command system -(defgroup blank nil +(defgroup whitespace nil "Visualize blanks (TAB, (HARD) SPACE and NEWLINE)." - :link '(emacs-library-link :tag "Source Lisp File" "blank-mode.el") + :link '(emacs-library-link :tag "Source Lisp File" "whitespace.el") :version "22.2" :group 'wp :group 'data) -(defcustom blank-style '(mark color) +(defcustom whitespace-style '(mark color) "*Specify the visualization style. It's a list which element value can be: @@ -348,15 +354,15 @@ Any other value is ignored. If nil, don't visualize TABs, (HARD) SPACEs and NEWLINEs. -See also `blank-display-mappings' for documentation." +See also `whitespace-display-mappings' for documentation." :type '(repeat :tag "Style of Blank" (choice :tag "Style of Blank" (const :tag "Display Table" mark) (const :tag "Faces" color))) - :group 'blank) + :group 'whitespace) -(defcustom blank-chars +(defcustom whitespace-chars '(tabs spaces trailing lines space-before-tab newline indentation empty space-after-tab) "*Specify which kind of blank is visualized. @@ -370,17 +376,17 @@ It's a list which element value can be: spaces SPACEs and HARD SPACEs are visualized. lines lines whose have columns beyond - `blank-line-column' are highlighted. + `whitespace-line-column' are highlighted. Whole line is highlighted. It has precedence over `lines-tail' (see below). lines-tail lines whose have columns beyond - `blank-line-column' are highlighted. + `whitespace-line-column' are highlighted. But only the part of line which goes - beyond `blank-line-column' column. + beyond `whitespace-line-column' column. It has effect only if `lines' (see above) - is not present in `blank-chars'. + is not present in `whitespace-chars'. space-before-tab SPACEs before TAB are visualized. @@ -398,9 +404,9 @@ Any other value is ignored. 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' -has `mark' as an element." +Used when `whitespace-style' has `color' as an element. +Used also when `whitespace-chars' has `newline' as an element and +`whitespace-style' has `mark' as an element." :type '(repeat :tag "Kind of Blank" (choice :tag "Kind of Blank" (const :tag "Trailing TABs, SPACEs and HARD SPACEs" @@ -416,75 +422,75 @@ has `mark' as an element." empty) (const :tag "SPACEs after TAB" space-after-tab))) - :group 'blank) + :group 'whitespace) -(defcustom blank-space 'blank-space +(defcustom whitespace-space 'whitespace-space "*Symbol face used to visualize SPACE. -Used when `blank-style' has `color' as an element." +Used when `whitespace-style' has `color' as an element." :type 'face - :group 'blank) + :group 'whitespace) -(defface blank-space +(defface whitespace-space '((((class color) (background dark)) (:background "grey20" :foreground "aquamarine3")) (((class color) (background light)) (:background "LightYellow" :foreground "aquamarine3")) (t (:inverse-video t))) "Face used to visualize SPACE." - :group 'blank) + :group 'whitespace) -(defcustom blank-hspace 'blank-hspace +(defcustom whitespace-hspace 'whitespace-hspace "*Symbol face used to visualize HARD SPACE. -Used when `blank-style' has `color' as an element." +Used when `whitespace-style' has `color' as an element." :type 'face - :group 'blank) + :group 'whitespace) -(defface blank-hspace ; 'nobreak-space +(defface whitespace-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 visualize HARD SPACE." - :group 'blank) + :group 'whitespace) -(defcustom blank-tab 'blank-tab +(defcustom whitespace-tab 'whitespace-tab "*Symbol face used to visualize TAB. -Used when `blank-style' has `color' as an element." +Used when `whitespace-style' has `color' as an element." :type 'face - :group 'blank) + :group 'whitespace) -(defface blank-tab +(defface whitespace-tab '((((class color) (background dark)) (:background "grey22" :foreground "aquamarine3")) (((class color) (background light)) (:background "beige" :foreground "aquamarine3")) (t (:inverse-video t))) "Face used to visualize TAB." - :group 'blank) + :group 'whitespace) -(defcustom blank-newline 'blank-newline +(defcustom whitespace-newline 'whitespace-newline "*Symbol face used to visualize NEWLINE char mapping. -See `blank-display-mappings'. +See `whitespace-display-mappings'. -Used when `blank-style' has `mark' and `color' as elements -and `blank-chars' has `newline' as an element." +Used when `whitespace-style' has `mark' and `color' as elements +and `whitespace-chars' has `newline' as an element." :type 'face - :group 'blank) + :group 'whitespace) -(defface blank-newline +(defface whitespace-newline '((((class color) (background dark)) (:background "grey26" :foreground "aquamarine3" :bold t)) (((class color) (background light)) @@ -492,105 +498,105 @@ and `blank-chars' has `newline' as an element." (t (:bold t :underline t))) "Face used to visualize NEWLINE char mapping. -See `blank-display-mappings'." - :group 'blank) +See `whitespace-display-mappings'." + :group 'whitespace) -(defcustom blank-trailing 'blank-trailing +(defcustom whitespace-trailing 'whitespace-trailing "*Symbol face used to visualize traling blanks. -Used when `blank-style' has `color' as an element." +Used when `whitespace-style' has `color' as an element." :type 'face - :group 'blank) + :group 'whitespace) -(defface blank-trailing ; 'trailing-whitespace +(defface whitespace-trailing ; 'trailing-whitespace '((((class mono)) (:inverse-video t :bold t :underline t)) (t (:background "red1" :foreground "yellow" :bold t))) "Face used to visualize trailing blanks." - :group 'blank) + :group 'whitespace) -(defcustom blank-line 'blank-line +(defcustom whitespace-line 'whitespace-line "*Symbol face used to visualize \"long\" lines. -See `blank-line-column'. +See `whitespace-line-column'. -Used when `blank-style' has `color' as an element." +Used when `whitespace-style' has `color' as an element." :type 'face - :group 'blank) + :group 'whitespace) -(defface blank-line +(defface whitespace-line '((((class mono)) (:inverse-video t :bold t :underline t)) (t (:background "gray20" :foreground "violet"))) "Face used to visualize \"long\" lines. -See `blank-line-column'." - :group 'blank) +See `whitespace-line-column'." + :group 'whitespace) -(defcustom blank-space-before-tab 'blank-space-before-tab +(defcustom whitespace-space-before-tab 'whitespace-space-before-tab "*Symbol face used to visualize SPACEs before TAB. -Used when `blank-style' has `color' as an element." +Used when `whitespace-style' has `color' as an element." :type 'face - :group 'blank) + :group 'whitespace) -(defface blank-space-before-tab +(defface whitespace-space-before-tab '((((class mono)) (:inverse-video t :bold t :underline t)) (t (:background "DarkOrange" :foreground "firebrick"))) "Face used to visualize SPACEs before TAB." - :group 'blank) + :group 'whitespace) -(defcustom blank-indentation 'blank-indentation +(defcustom whitespace-indentation 'whitespace-indentation "*Symbol face used to visualize 8 or more SPACEs at beginning of line. -Used when `blank-style' has `color' as an element." +Used when `whitespace-style' has `color' as an element." :type 'face - :group 'blank) + :group 'whitespace) -(defface blank-indentation +(defface whitespace-indentation '((((class mono)) (:inverse-video t :bold t :underline t)) (t (:background "yellow" :foreground "firebrick"))) "Face used to visualize 8 or more SPACEs at beginning of line." - :group 'blank) + :group 'whitespace) -(defcustom blank-empty 'blank-empty +(defcustom whitespace-empty 'whitespace-empty "*Symbol face used to visualize empty lines at beginning and/or end of buffer. -Used when `blank-style' has `color' as an element." +Used when `whitespace-style' has `color' as an element." :type 'face - :group 'blank) + :group 'whitespace) -(defface blank-empty +(defface whitespace-empty '((((class mono)) (:inverse-video t :bold t :underline t)) (t (:background "yellow" :foreground "firebrick"))) "Face used to visualize empty lines at beginning and/or end of buffer." - :group 'blank) + :group 'whitespace) -(defcustom blank-space-after-tab 'blank-space-after-tab +(defcustom whitespace-space-after-tab 'whitespace-space-after-tab "*Symbol face used to visualize 8 or more SPACEs after TAB. -Used when `blank-style' has `color' as an element." +Used when `whitespace-style' has `color' as an element." :type 'face - :group 'blank) + :group 'whitespace) -(defface blank-space-after-tab +(defface whitespace-space-after-tab '((((class mono)) (:inverse-video t :bold t :underline t)) (t (:background "yellow" :foreground "firebrick"))) "Face used to visualize 8 or more SPACEs after TAB." - :group 'blank) + :group 'whitespace) -(defcustom blank-hspace-regexp +(defcustom whitespace-hspace-regexp "\\(\\(\xA0\\|\x8A0\\|\x920\\|\xE20\\|\xF20\\)+\\)" "*Specify HARD SPACE characters regexp. @@ -614,13 +620,13 @@ visualize only HARD SPACEs between TABs. NOTE: Enclose always by \\\\( and \\\\) the elements to highlight. Use exactly one pair of enclosing \\\\( and \\\\). -Used when `blank-style' has `color' as an element, and -`blank-chars' has `spaces' as an element." +Used when `whitespace-style' has `color' as an element, and +`whitespace-chars' has `spaces' as an element." :type '(regexp :tag "HARD SPACE Chars") - :group 'blank) + :group 'whitespace) -(defcustom blank-space-regexp "\\( +\\)" +(defcustom whitespace-space-regexp "\\( +\\)" "*Specify SPACE characters regexp. If you're using `mule' package, it may exist other characters @@ -637,13 +643,13 @@ visualize leading and/or trailing SPACEs. NOTE: Enclose always by \\\\( and \\\\) the elements to highlight. Use exactly one pair of enclosing \\\\( and \\\\). -Used when `blank-style' has `color' as an element, and -`blank-chars' has `spaces' as an element." +Used when `whitespace-style' has `color' as an element, and +`whitespace-chars' has `spaces' as an element." :type '(regexp :tag "SPACE Chars") - :group 'blank) + :group 'whitespace) -(defcustom blank-tab-regexp "\\(\t+\\)" +(defcustom whitespace-tab-regexp "\\(\t+\\)" "*Specify TAB characters regexp. If you're using `mule' package, it may exist other characters @@ -660,13 +666,13 @@ visualize leading and/or trailing TABs. NOTE: Enclose always by \\\\( and \\\\) the elements to highlight. Use exactly one pair of enclosing \\\\( and \\\\). -Used when `blank-style' has `color' as an element, and -`blank-chars' has `tabs' as an element." +Used when `whitespace-style' has `color' as an element, and +`whitespace-chars' has `tabs' as an element." :type '(regexp :tag "TAB Chars") - :group 'blank) + :group 'whitespace) -(defcustom blank-trailing-regexp +(defcustom whitespace-trailing-regexp "\t\\| \\|\xA0\\|\x8A0\\|\x920\\|\xE20\\|\xF20" "*Specify trailing characters regexp. @@ -678,16 +684,16 @@ If you're using `mule' package, it may exist other characters besides: that should be considered blank. NOTE: DO NOT enclose by \\\\( and \\\\) the elements to highlight. - `blank-mode' surrounds this regexp by \"\\\\(\\\\(\" and + `whitespace-mode' surrounds this regexp by \"\\\\(\\\\(\" and \"\\\\)+\\\\)$\". -Used when `blank-style' has `color' as an element, and -`blank-chars' has `trailing' as an element." +Used when `whitespace-style' has `color' as an element, and +`whitespace-chars' has `trailing' as an element." :type '(regexp :tag "Trailing Chars") - :group 'blank) + :group 'whitespace) -(defcustom blank-space-before-tab-regexp "\\( +\\)\t" +(defcustom whitespace-space-before-tab-regexp "\\( +\\)\t" "*Specify SPACEs before TAB regexp. If you're using `mule' package, it may exist other characters besides: @@ -697,13 +703,14 @@ If you're using `mule' package, it may exist other characters besides: that should be considered blank. -Used when `blank-style' has `color' as an element, and -`blank-chars' has `space-before-tab' as an element." +Used when `whitespace-style' has `color' as an element, and +`whitespace-chars' has `space-before-tab' as an element." :type '(regexp :tag "SPACEs Before TAB") - :group 'blank) + :group 'whitespace) -(defcustom blank-indentation-regexp "^\t*\\(\\( \\{8\\}\\)+\\)[^\n\t]" +(defcustom whitespace-indentation-regexp + "^\t*\\(\\( \\{8\\}\\)+\\)[^\n\t]" "*Specify regexp for 8 or more SPACEs at beginning of line. If you're using `mule' package, it may exist other characters besides: @@ -713,13 +720,13 @@ If you're using `mule' package, it may exist other characters besides: that should be considered blank. -Used when `blank-style' has `color' as an element, and -`blank-chars' has `indentation' as an element." +Used when `whitespace-style' has `color' as an element, and +`whitespace-chars' has `indentation' as an element." :type '(regexp :tag "Indentation SPACEs") - :group 'blank) + :group 'whitespace) -(defcustom blank-empty-at-bob-regexp "\\`\\(\\([ \t]*\n\\)+\\)" +(defcustom whitespace-empty-at-bob-regexp "\\`\\(\\([ \t]*\n\\)+\\)" "*Specify regexp for empty lines at beginning of buffer. If you're using `mule' package, it may exist other characters besides: @@ -729,13 +736,13 @@ If you're using `mule' package, it may exist other characters besides: that should be considered blank. -Used when `blank-style' has `color' as an element, and -`blank-chars' has `empty' as an element." +Used when `whitespace-style' has `color' as an element, and +`whitespace-chars' has `empty' as an element." :type '(regexp :tag "Empty Lines At Beginning Of Buffer") - :group 'blank) + :group 'whitespace) -(defcustom blank-empty-at-eob-regexp "^\\([ \t\n]+\\)\\'" +(defcustom whitespace-empty-at-eob-regexp "^\\([ \t\n]+\\)\\'" "*Specify regexp for empty lines at end of buffer. If you're using `mule' package, it may exist other characters besides: @@ -745,13 +752,13 @@ If you're using `mule' package, it may exist other characters besides: that should be considered blank. -Used when `blank-style' has `color' as an element, and -`blank-chars' has `empty' as an element." +Used when `whitespace-style' has `color' as an element, and +`whitespace-chars' has `empty' as an element." :type '(regexp :tag "Empty Lines At End Of Buffer") - :group 'blank) + :group 'whitespace) -(defcustom blank-space-after-tab-regexp "\t\\(\\( \\{8\\}\\)+\\)" +(defcustom whitespace-space-after-tab-regexp "\t\\(\\( \\{8\\}\\)+\\)" "*Specify regexp for 8 or more SPACEs after TAB. If you're using `mule' package, it may exist other characters besides: @@ -761,23 +768,23 @@ If you're using `mule' package, it may exist other characters besides: that should be considered blank. -Used when `blank-style' has `color' as an element, and -`blank-chars' has `space-after-tab' as an element." +Used when `whitespace-style' has `color' as an element, and +`whitespace-chars' has `space-after-tab' as an element." :type '(regexp :tag "SPACEs After TAB") - :group 'blank) + :group 'whitespace) -(defcustom blank-line-column 80 +(defcustom whitespace-line-column 80 "*Specify column beyond which the line is highlighted. -Used when `blank-style' has `color' as an element, and -`blank-chars' has `lines' or `lines-tail' as an element." +Used when `whitespace-style' has `color' as an element, and +`whitespace-chars' has `lines' or `lines-tail' as an element." :type '(integer :tag "Line Length") - :group 'blank) + :group 'whitespace) ;; Hacked from `visible-whitespace-mappings' in visws.el -(defcustom blank-display-mappings +(defcustom whitespace-display-mappings ;; Due to limitations of glyph representation, the char code can not ;; be above ?\x1FFFF. Probably, this will be fixed after Emacs ;; unicode merging. @@ -788,7 +795,7 @@ Used when `blank-style' has `color' as an element, and (?\x920 [?\x924] [?_]) ; hard space - currency (?\xE20 [?\xE24] [?_]) ; hard space - currency (?\xF20 [?\xF24] [?_]) ; hard space - currency - ;; NEWLINE is displayed using the face `blank-newline' + ;; NEWLINE is displayed using the face `whitespace-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 @@ -819,11 +826,11 @@ VECTOR is a vector of characters to be displayed in place of CHAR. that character is displayed unmodified. The NEWLINE character is displayed using the face given by -`blank-newline' variable. The characters in the vector to be -displayed will not have this face applied if the character code -is above #x1FFFF. +`whitespace-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." +Used when `whitespace-style' has `mark' as an element." :type '(repeat (list :tag "Character Mapping" (character :tag "Char") @@ -832,25 +839,29 @@ Used when `blank-style' has `mark' as an element." (repeat :inline t :tag "Vector Characters" (character :tag "Char")))))) - :group 'blank) + :group 'whitespace) -(defcustom blank-global-modes t - "*Modes for which global `blank-mode' is automagically turned on. +(defcustom whitespace-global-modes t + "*Modes for which global `whitespace-mode' is automagically turned on. -Global `blank-mode' is controlled by the command `global-blank-mode'. +Global `whitespace-mode' is controlled by the command +`global-whitespace-mode'. -If nil, means no modes have `blank-mode' automatically turned on. -If t, all modes that support `blank-mode' have it automatically +If nil, means no modes have `whitespace-mode' automatically turned on. -Else it should be a list of `major-mode' symbol names for -which `blank-mode' should be automatically turned on. The sense + +If t, all modes that support `whitespace-mode' have it +automatically turned on. + +Else it should be a list of `major-mode' symbol names for which +`whitespace-mode' should be automatically turned on. The sense of the list is negated if it begins with `not'. For example: (c-mode c++-mode) -means that `blank-mode' is turned on for buffers in C and C++ -modes only." +means that `whitespace-mode' is turned on for buffers in C and +C++ modes only." :type '(choice (const :tag "None" nil) (const :tag "All" t) (set :menu-tag "Mode Specific" :tag "Modes" @@ -858,7 +869,7 @@ modes only." (const :tag "Except" not) (repeat :inline t (symbol :tag "Mode")))) - :group 'blank) + :group 'whitespace) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -866,74 +877,74 @@ modes only." ;;;###autoload -(define-minor-mode blank-mode - "Toggle blank minor mode visualization (\"bl\" on modeline). +(define-minor-mode whitespace-mode + "Toggle whitespace minor mode visualization (\"ws\" on modeline). -If ARG is null, toggle blank visualization. +If ARG is null, toggle whitespace visualization. If ARG is a number greater than zero, turn on visualization; otherwise, turn off visualization. Only useful with a windowing system." - :lighter " bl" + :lighter " ws" :init-value nil :global nil - :group 'blank + :group 'whitespace (cond (noninteractive ; running a batch job - (setq blank-mode nil)) - (blank-mode ; blank-mode on - (blank-turn-on)) - (t ; blank-mode off - (blank-turn-off)))) + (setq whitespace-mode nil)) + (whitespace-mode ; whitespace-mode on + (whitespace-turn-on)) + (t ; whitespace-mode off + (whitespace-turn-off)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; User commands - Global mode -(define-minor-mode global-blank-mode - "Toggle blank global minor mode visualization (\"BL\" on modeline). +(define-minor-mode global-whitespace-mode + "Toggle whitespace global minor mode visualization (\"WS\" on modeline). -If ARG is null, toggle blank visualization. +If ARG is null, toggle whitespace 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 :global t - :group 'blank + :group 'whitespace (cond (noninteractive ; running a batch job - (setq global-blank-mode nil)) - (global-blank-mode ; global-blank-mode on + (setq global-whitespace-mode nil)) + (global-whitespace-mode ; global-whitespace-mode on (save-excursion (if (boundp 'find-file-hook) - (add-hook 'find-file-hook 'blank-turn-on-if-enabled t) - (add-hook 'find-file-hooks 'blank-turn-on-if-enabled t)) + (add-hook 'find-file-hook 'whitespace-turn-on-if-enabled t) + (add-hook 'find-file-hooks 'whitespace-turn-on-if-enabled t)) (dolist (buffer (buffer-list)) ; adjust all local mode (set-buffer buffer) - (unless blank-mode - (blank-turn-on-if-enabled))))) - (t ; global-blank-mode off + (unless whitespace-mode + (whitespace-turn-on-if-enabled))))) + (t ; global-whitespace-mode off (save-excursion (if (boundp 'find-file-hook) - (remove-hook 'find-file-hook 'blank-turn-on-if-enabled) - (remove-hook 'find-file-hooks 'blank-turn-on-if-enabled)) + (remove-hook 'find-file-hook 'whitespace-turn-on-if-enabled) + (remove-hook 'find-file-hooks 'whitespace-turn-on-if-enabled)) (dolist (buffer (buffer-list)) ; adjust all local mode (set-buffer buffer) - (unless blank-mode - (blank-turn-off))))))) + (unless whitespace-mode + (whitespace-turn-off))))))) -(defun blank-turn-on-if-enabled () +(defun whitespace-turn-on-if-enabled () (when (cond - ((eq blank-global-modes t)) - ((listp blank-global-modes) - (if (eq (car-safe blank-global-modes) 'not) - (not (memq major-mode (cdr blank-global-modes))) - (memq major-mode blank-global-modes))) + ((eq whitespace-global-modes t)) + ((listp whitespace-global-modes) + (if (eq (car-safe whitespace-global-modes) 'not) + (not (memq major-mode (cdr whitespace-global-modes))) + (memq major-mode whitespace-global-modes))) (t nil)) (let (inhibit-quit) - ;; Don't turn on blank mode if... + ;; Don't turn on whitespace mode if... (or ;; ...we don't have a display (we're running a batch job) noninteractive @@ -943,15 +954,15 @@ Only useful with a windowing system." (and (eq (aref (buffer-name) 0) ?*) ;; except the scratch buffer. (not (string= (buffer-name) "*scratch*"))) - ;; Otherwise, turn on blank mode. - (blank-turn-on))))) + ;; Otherwise, turn on whitespace mode. + (whitespace-turn-on))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; User commands - Toggle -(defconst blank-chars-value-list +(defconst whitespace-chars-value-list '(tabs spaces trailing @@ -963,17 +974,17 @@ Only useful with a windowing system." empty space-after-tab ) - "List of valid `blank-chars' values.") + "List of valid `whitespace-chars' values.") -(defconst blank-style-value-list +(defconst whitespace-style-value-list '(color mark ) - "List of valid `blank-style' values.") + "List of valid `whitespace-style' values.") -(defconst blank-toggle-option-alist +(defconst whitespace-toggle-option-alist '((?t . tabs) (?s . spaces) (?r . trailing) @@ -986,8 +997,8 @@ Only useful with a windowing system." (?a . space-after-tab) (?c . color) (?m . mark) - (?x . blank-chars) - (?z . blank-style) + (?x . whitespace-chars) + (?z . whitespace-style) ) "Alist of toggle options. @@ -1000,27 +1011,28 @@ Where: CHAR is a char which the user will have to type. SYMBOL is a valid symbol associated with CHAR. - See `blank-chars-value-list' and `blank-style-value-list'.") + See `whitespace-chars-value-list' and + `whitespace-style-value-list'.") -(defvar blank-active-chars nil - "Used to save locally `blank-chars' value.") -(make-variable-buffer-local 'blank-active-chars) +(defvar whitespace-active-chars nil + "Used to save locally `whitespace-chars' value.") +(make-variable-buffer-local 'whitespace-active-chars) -(defvar blank-active-style nil - "Used to save locally `blank-style' value.") -(make-variable-buffer-local 'blank-active-style) +(defvar whitespace-active-style nil + "Used to save locally `whitespace-style' value.") +(make-variable-buffer-local 'whitespace-active-style) ;;;###autoload -(defun blank-toggle-options (arg) - "Toggle local `blank-mode' options. +(defun whitespace-toggle-options (arg) + "Toggle local `whitespace-mode' options. -If local blank-mode is off, toggle the option given by ARG and -turn on local blank-mode. +If local whitespace-mode is off, toggle the option given by ARG +and turn on local whitespace-mode. -If local blank-mode is on, toggle the option given by ARG and -restart local blank-mode. +If local whitespace-mode is on, toggle the option given by ARG +and restart local whitespace-mode. Interactively, it reads one of the following chars: @@ -1037,8 +1049,8 @@ Interactively, it reads one of the following chars: a toggle SPACEs after TAB visualization c toggle color faces m toggle visual mark - x restore `blank-chars' value - z restore `blank-style' value + x restore `whitespace-chars' value + z restore `whitespace-style' value ? display brief help Non-interactively, ARG should be a symbol or a list of symbols. @@ -1056,36 +1068,38 @@ The valid symbols are: space-after-tab toggle SPACEs after TAB visualization color toggle color faces mark toggle visual mark - blank-chars restore `blank-chars' value - blank-style restore `blank-style' value + whitespace-chars restore `whitespace-chars' value + whitespace-style restore `whitespace-style' value Only useful with a windowing system." - (interactive (blank-interactive-char t)) - (let ((blank-chars - (blank-toggle-list t arg blank-active-chars blank-chars - 'blank-chars blank-chars-value-list)) - (blank-style - (blank-toggle-list t arg blank-active-style blank-style - 'blank-style blank-style-value-list))) - (blank-mode 0) - (blank-mode 1))) + (interactive (whitespace-interactive-char t)) + (let ((whitespace-chars + (whitespace-toggle-list + t arg whitespace-active-chars whitespace-chars + 'whitespace-chars whitespace-chars-value-list)) + (whitespace-style + (whitespace-toggle-list + t arg whitespace-active-style whitespace-style + 'whitespace-style whitespace-style-value-list))) + (whitespace-mode 0) + (whitespace-mode 1))) -(defvar blank-toggle-chars nil - "Used to toggle the global `blank-chars' value.") -(defvar blank-toggle-style nil - "Used to toggle the global `blank-style' value.") +(defvar whitespace-toggle-chars nil + "Used to toggle the global `whitespace-chars' value.") +(defvar whitespace-toggle-style nil + "Used to toggle the global `whitespace-style' value.") ;;;###autoload -(defun global-blank-toggle-options (arg) - "Toggle global `blank-mode' options. +(defun global-whitespace-toggle-options (arg) + "Toggle global `whitespace-mode' options. -If global blank-mode is off, toggle the option given by ARG and -turn on global blank-mode. +If global whitespace-mode is off, toggle the option given by ARG +and turn on global whitespace-mode. -If global blank-mode is on, toggle the option given by ARG and -restart global blank-mode. +If global whitespace-mode is on, toggle the option given by ARG +and restart global whitespace-mode. Interactively, it reads one of the following chars: @@ -1102,8 +1116,8 @@ Interactively, it reads one of the following chars: a toggle SPACEs after TAB visualization c toggle color faces m toggle visual mark - x restore `blank-chars' value - z restore `blank-style' value + x restore `whitespace-chars' value + z restore `whitespace-style' value ? display brief help Non-interactively, ARG should be a symbol or a list of symbols. @@ -1121,21 +1135,23 @@ The valid symbols are: space-after-tab toggle SPACEs after TAB visualization color toggle color faces mark toggle visual mark - blank-chars restore `blank-chars' value - blank-style restore `blank-style' value + whitespace-chars restore `whitespace-chars' value + whitespace-style restore `whitespace-style' value Only useful with a windowing system." - (interactive (blank-interactive-char nil)) - (let ((blank-chars - (blank-toggle-list nil arg blank-toggle-chars blank-chars - 'blank-chars blank-chars-value-list)) - (blank-style - (blank-toggle-list nil arg blank-toggle-style blank-style - 'blank-style blank-style-value-list))) - (setq blank-toggle-chars blank-chars - blank-toggle-style blank-style) - (global-blank-mode 0) - (global-blank-mode 1))) + (interactive (whitespace-interactive-char nil)) + (let ((whitespace-chars + (whitespace-toggle-list + nil arg whitespace-toggle-chars whitespace-chars + 'whitespace-chars whitespace-chars-value-list)) + (whitespace-style + (whitespace-toggle-list + nil arg whitespace-toggle-style whitespace-style + 'whitespace-style whitespace-style-value-list))) + (setq whitespace-toggle-chars whitespace-chars + whitespace-toggle-style whitespace-style) + (global-whitespace-mode 0) + (global-whitespace-mode 1))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -1143,39 +1159,39 @@ Only useful with a windowing system." ;;;###autoload -(defun blank-cleanup () +(defun whitespace-cleanup () "Cleanup some blank problems in all buffer or at region. It usually applies to the whole buffer, but in transient mark mode when the mark is active, it applies to the region. It also applies to the region when it is not in transiente mark mode, the mark is active and it was pressed `C-u' just before calling -`blank-cleanup' interactively. +`whitespace-cleanup' interactively. -See also `blank-cleanup-region'. +See also `whitespace-cleanup-region'. The problems, which are cleaned up, are: 1. empty lines at beginning of buffer. 2. empty lines at end of buffer. - If `blank-chars' has `empty' as an element, remove all empty - lines at beginning and/or end of buffer. + If `whitespace-chars' has `empty' as an element, remove all + empty lines at beginning and/or end of buffer. 3. 8 or more SPACEs at beginning of line. - If `blank-chars' has `indentation' as an element, replace 8 or - more SPACEs at beginning of line by TABs. + If `whitespace-chars' has `indentation' as an element, replace + 8 or more SPACEs at beginning of line by TABs. 4. SPACEs before TAB. - If `blank-chars' has `space-before-tab' as an element, replace - SPACEs by TABs. + If `whitespace-chars' has `space-before-tab' as an element, + replace SPACEs by TABs. 5. SPACEs or TABs at end of line. - If `blank-chars' has `trailing' as an element, remove all + If `whitespace-chars' has `trailing' as an element, remove all SPACEs or TABs at end of line. 6. 8 or more SPACEs after TAB. - If `blank-chars' has `space-after-tab' as an element, replace - SPACEs by TABs." + If `whitespace-chars' has `space-after-tab' as an element, + replace SPACEs by TABs." (interactive "@*") (if (and (or transient-mark-mode current-prefix-arg) @@ -1186,48 +1202,50 @@ The problems, which are cleaned up, are: ;; problem 4: SPACEs before TAB ;; problem 5: SPACEs or TABs at eol ;; problem 6: 8 or more SPACEs after TAB - (blank-cleanup-region (region-beginning) (region-end)) + (whitespace-cleanup-region (region-beginning) (region-end)) ;; whole buffer (save-excursion (save-match-data ;; 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 blank-chars) + (when (memq 'empty whitespace-chars) (let (overwrite-mode) ; enforce no overwrite (goto-char (point-min)) - (when (re-search-forward blank-empty-at-bob-regexp nil t) + (when (re-search-forward + whitespace-empty-at-bob-regexp nil t) (delete-region (match-beginning 1) (match-end 1))) - (when (re-search-forward blank-empty-at-eob-regexp nil t) + (when (re-search-forward + whitespace-empty-at-eob-regexp nil t) (delete-region (match-beginning 1) (match-end 1))))))) ;; problem 3: 8 or more SPACEs at bol ;; problem 4: SPACEs before TAB ;; problem 5: SPACEs or TABs at eol ;; problem 6: 8 or more SPACEs after TAB - (blank-cleanup-region (point-min) (point-max)))) + (whitespace-cleanup-region (point-min) (point-max)))) ;;;###autoload -(defun blank-cleanup-region (start end) +(defun whitespace-cleanup-region (start end) "Cleanup some blank problems at region. The problems, which are cleaned up, are: 1. 8 or more SPACEs at beginning of line. - If `blank-chars' has `indentation' as an element, replace 8 or - more SPACEs at beginning of line by TABs. + If `whitespace-chars' has `indentation' as an element, replace + 8 or more SPACEs at beginning of line by TABs. 2. SPACEs before TAB. - If `blank-chars' has `space-before-tab' as an element, replace - SPACEs by TABs. + If `whitespace-chars' has `space-before-tab' as an element, + replace SPACEs by TABs. 3. SPACEs or TABs at end of line. - If `blank-chars' has `trailing' as an element, remove all + If `whitespace-chars' has `trailing' as an element, remove all SPACEs or TABs at end of line. 4. 8 or more SPACEs after TAB. - If `blank-chars' has `space-after-tab' as an element, replace - SPACEs by TABs." + If `whitespace-chars' has `space-after-tab' as an element, + replace SPACEs by TABs." (interactive "@*r") (let ((rstart (min start end)) (rend (copy-marker (max start end))) @@ -1239,35 +1257,36 @@ The problems, which are cleaned up, are: (save-match-data ;; problem 1: 8 or more SPACEs at bol ;; action: replace 8 or more SPACEs at bol by TABs - (when (memq 'indentation blank-chars) + (when (memq 'indentation whitespace-chars) (goto-char rstart) - (while (re-search-forward blank-indentation-regexp rend t) + (while (re-search-forward + whitespace-indentation-regexp rend t) (setq tmp (current-indentation)) (delete-horizontal-space) (unless (eolp) (indent-to tmp)))) ;; problem 3: SPACEs or TABs at eol ;; action: remove all SPACEs or TABs at eol - (when (memq 'trailing blank-chars) - (let ((regexp (concat "\\(\\(" blank-trailing-regexp + (when (memq 'trailing whitespace-chars) + (let ((regexp (concat "\\(\\(" whitespace-trailing-regexp "\\)+\\)$"))) (goto-char rstart) (while (re-search-forward regexp rend t) (delete-region (match-beginning 1) (match-end 1))))) ;; problem 4: 8 or more SPACEs after TAB ;; action: replace 8 or more SPACEs by TABs - (when (memq 'space-after-tab blank-chars) - (blank-replace-spaces-by-tabs - rstart rend blank-space-after-tab-regexp)) + (when (memq 'space-after-tab whitespace-chars) + (whitespace-replace-spaces-by-tabs + rstart rend whitespace-space-after-tab-regexp)) ;; problem 2: SPACEs before TAB ;; action: replace SPACEs before TAB by TABs - (when (memq 'space-before-tab blank-chars) - (blank-replace-spaces-by-tabs - rstart rend blank-space-before-tab-regexp)))) + (when (memq 'space-before-tab whitespace-chars) + (whitespace-replace-spaces-by-tabs + rstart rend whitespace-space-before-tab-regexp)))) (set-marker rend nil))) ; point marker to nowhere -(defun blank-replace-spaces-by-tabs (rstart rend regexp) +(defun whitespace-replace-spaces-by-tabs (rstart rend regexp) "Replace all SPACEs by TABs matched by REGEXP between RSTART and REND." (goto-char rstart) (while (re-search-forward regexp rend t) @@ -1278,31 +1297,78 @@ The problems, which are cleaned up, are: (current-column)))) (delete-region (match-beginning 1) (match-end 1)) (insert-char ?\t - (/ (- (- ecol (% ecol 8)) ; prev end col - (- scol (% scol 8))) ; prev start col + (/ (- (- ecol (% ecol 8)) ; prev end col + (- scol (% scol 8))) ; prev start col 8))))) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;; User command - old whitespace compatibility + + +;;;###autoload +(defun whitespace-buffer () + "Turn on `whitespace-mode' forcing some settings. + +It forces `whitespace-style' to have `color'. + +It also forces `whitespace-chars' to have: + + trailing + indentation + space-before-tab + empty + space-after-tab + +So, it is possible to visualize the following problems: + + empty 1. empty lines at beginning of buffer. + empty 2. empty lines at end of buffer. + indentation 3. 8 or more SPACEs at beginning of line. + space-before-tab 4. SPACEs before TAB. + trailing 5. SPACEs or TABs at end of line. + space-after-tab 6. 8 or more SPACEs after TAB. + +See `whitespace-chars' and `whitespace-style' for documentation. +See also `whitespace-cleanup' and `whitespace-cleanup-region' for +cleaning up these problems." + (interactive) + (whitespace-mode 0) ; assure is off + ;; keep original values + (let ((whitespace-style (copy-sequence whitespace-style)) + (whitespace-chars (copy-sequence whitespace-chars))) + ;; adjust options for whitespace bogus blanks + (add-to-list 'whitespace-style 'color) + (mapc #'(lambda (option) + (add-to-list 'whitespace-chars option)) + '(trailing + indentation + space-before-tab + empty + space-after-tab)) + (whitespace-mode 1))) ; turn on + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; Internal functions -(defvar blank-font-lock-mode nil +(defvar whitespace-font-lock-mode nil "Used to remember whether a buffer had font lock mode on or not.") -(make-variable-buffer-local 'blank-font-lock-mode) +(make-variable-buffer-local 'whitespace-font-lock-mode) -(defvar blank-font-lock nil +(defvar whitespace-font-lock nil "Used to remember whether a buffer initially had font lock on or not.") -(make-variable-buffer-local 'blank-font-lock) +(make-variable-buffer-local 'whitespace-font-lock) -(defvar blank-font-lock-keywords nil +(defvar whitespace-font-lock-keywords nil "Used to save locally `font-lock-keywords' value.") -(make-variable-buffer-local 'blank-font-lock-keywords) +(make-variable-buffer-local 'whitespace-font-lock-keywords) -(defconst blank-help-text +(defconst whitespace-help-text "\ - blank-mode toggle options: + whitespace-mode toggle options: [] t - toggle TAB visualization [] s - toggle SPACE and HARD SPACE visualization @@ -1318,18 +1384,18 @@ The problems, which are cleaned up, are: [] c - toggle color faces [] m - toggle visual mark - x - restore `blank-chars' value - z - restore `blank-style' value + x - restore `whitespace-chars' value + z - restore `whitespace-style' value ? - display this text\n\n" - "Text for blank toggle options.") + "Text for whitespace toggle options.") -(defconst blank-help-buffer-name "*Blank Toggle Options*" - "The buffer name for blank toggle options.") +(defconst whitespace-help-buffer-name "*Whitespace Toggle Options*" + "The buffer name for whitespace toggle options.") -(defun blank-insert-option-mark (the-list the-value) +(defun whitespace-insert-option-mark (the-list the-value) "Insert the option mark ('X' or ' ') in toggle options buffer." (forward-line 1) (dolist (sym the-list) @@ -1338,39 +1404,42 @@ The problems, which are cleaned up, are: (insert (if (memq sym the-value) "X" " ")))) -(defun blank-help-on (chars style) - "Display the blank toggle options." - (unless (get-buffer blank-help-buffer-name) +(defun whitespace-help-on (chars style) + "Display the whitespace toggle options." + (unless (get-buffer whitespace-help-buffer-name) (delete-other-windows) - (let ((buffer (get-buffer-create blank-help-buffer-name))) + (let ((buffer (get-buffer-create whitespace-help-buffer-name))) (save-excursion (set-buffer buffer) (erase-buffer) - (insert blank-help-text) + (insert whitespace-help-text) (goto-char (point-min)) - (blank-insert-option-mark blank-chars-value-list chars) - (blank-insert-option-mark blank-style-value-list style) + (whitespace-insert-option-mark + whitespace-chars-value-list chars) + (whitespace-insert-option-mark + whitespace-style-value-list style) (goto-char (point-min)) (set-buffer-modified-p nil) (let ((size (- (window-height) (max window-min-height - (1+ (count-lines (point-min) (point-max))))))) + (1+ (count-lines (point-min) + (point-max))))))) (when (<= size 0) (kill-buffer buffer) (error "Frame height is too small; \ -can't split window to display blank toggle options")) +can't split window to display whitespace toggle options")) (set-window-buffer (split-window nil size) buffer)))))) -(defun blank-help-off () - "Remove the buffer and window of the blank toggle options." - (let ((buffer (get-buffer blank-help-buffer-name))) +(defun whitespace-help-off () + "Remove the buffer and window of the whitespace toggle options." + (let ((buffer (get-buffer whitespace-help-buffer-name))) (when buffer (delete-windows-on buffer) (kill-buffer buffer)))) -(defun blank-interactive-char (local-p) +(defun whitespace-interactive-char (local-p) "Interactive function to read a char and return a symbol. If LOCAL-P is non-nil, it uses a local context; otherwise, it @@ -1391,20 +1460,22 @@ It reads one of the following chars: a toggle SPACEs after TAB visualization c toggle color faces m toggle visual mark - x restore `blank-chars' value - z restore `blank-style' value + x restore `whitespace-chars' value + z restore `whitespace-style' value ? display brief help -See also `blank-toggle-option-alist'." - (let* ((is-off (not (if local-p blank-mode global-blank-mode))) - (chars (cond (is-off blank-chars) ; use default value - (local-p blank-active-chars) - (t blank-toggle-chars))) - (style (cond (is-off blank-style) ; use default value - (local-p blank-active-style) - (t blank-toggle-style))) +See also `whitespace-toggle-option-alist'." + (let* ((is-off (not (if local-p + whitespace-mode + global-whitespace-mode))) + (chars (cond (is-off whitespace-chars) ; use default value + (local-p whitespace-active-chars) + (t whitespace-toggle-chars))) + (style (cond (is-off whitespace-style) ; use default value + (local-p whitespace-active-style) + (t whitespace-toggle-style))) (prompt - (format "Blank Toggle %s (type ? for further options)-" + (format "Whitespace Toggle %s (type ? for further options)-" (if local-p "Local" "Global"))) ch sym) ;; read a valid option and get the corresponding symbol @@ -1417,22 +1488,23 @@ See also `blank-toggle-option-alist'." (setq ch (read-char prompt)) (not (setq sym - (cdr (assq ch blank-toggle-option-alist))))) + (cdr + (assq ch whitespace-toggle-option-alist))))) ;; while body (if (eq ch ?\?) - (blank-help-on chars style) + (whitespace-help-on chars style) (ding))) - (blank-help-off) + (whitespace-help-off) (message " ")) ; clean echo area ;; handler ((quit error) - (blank-help-off) + (whitespace-help-off) (error (error-message-string data))))) (list sym))) ; return the apropriate symbol -(defun blank-toggle-list (local-p arg the-list default-list - sym-restore sym-list) +(defun whitespace-toggle-list (local-p arg the-list default-list + sym-restore sym-list) "Toggle options in THE-LIST based on list ARG. If LOCAL-P is non-nil, it uses a local context; otherwise, it @@ -1451,7 +1523,7 @@ in THE-LIST. SYM-LIST is a list of valid options, used to check if the ARG's options are valid." - (unless (if local-p blank-mode global-blank-mode) + (unless (if local-p whitespace-mode global-whitespace-mode) (setq the-list default-list)) (setq the-list (copy-sequence the-list)) ; keep original list (dolist (sym (if (listp arg) arg (list arg))) @@ -1467,65 +1539,65 @@ options are valid." the-list) -(defun blank-turn-on () - "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))) - (when (memq 'color blank-active-style) - (blank-color-on)) - (when (memq 'mark blank-active-style) - (blank-display-char-on))) +(defun whitespace-turn-on () + "Turn on whitespace visualization." + (setq whitespace-active-style (if (listp whitespace-style) + whitespace-style + (list whitespace-style))) + (setq whitespace-active-chars (if (listp whitespace-chars) + whitespace-chars + (list whitespace-chars))) + (when (memq 'color whitespace-active-style) + (whitespace-color-on)) + (when (memq 'mark whitespace-active-style) + (whitespace-display-char-on))) -(defun blank-turn-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 whitespace-turn-off () + "Turn off whitesapce visualization." + (when (memq 'color whitespace-active-style) + (whitespace-color-off)) + (when (memq 'mark whitespace-active-style) + (whitespace-display-char-off))) -(defun blank-color-on () +(defun whitespace-color-on () "Turn on color visualization." - (when blank-active-chars - (unless blank-font-lock - (setq blank-font-lock t - blank-font-lock-keywords + (when whitespace-active-chars + (unless whitespace-font-lock + (setq whitespace-font-lock t + whitespace-font-lock-keywords (copy-sequence font-lock-keywords))) ;; turn off font lock - (setq blank-font-lock-mode font-lock-mode) + (setq whitespace-font-lock-mode font-lock-mode) (font-lock-mode 0) - ;; add blank-mode color into font lock - (when (memq 'spaces blank-active-chars) + ;; add whitespace-mode color into font lock + (when (memq 'spaces whitespace-active-chars) (font-lock-add-keywords nil (list ;; Show SPACEs - (list blank-space-regexp 1 blank-space t) + (list whitespace-space-regexp 1 whitespace-space t) ;; Show HARD SPACEs - (list blank-hspace-regexp 1 blank-hspace t)) + (list whitespace-hspace-regexp 1 whitespace-hspace t)) t)) - (when (memq 'tabs blank-active-chars) + (when (memq 'tabs whitespace-active-chars) (font-lock-add-keywords nil (list ;; Show TABs - (list blank-tab-regexp 1 blank-tab t)) + (list whitespace-tab-regexp 1 whitespace-tab t)) t)) - (when (memq 'trailing blank-active-chars) + (when (memq 'trailing whitespace-active-chars) (font-lock-add-keywords nil (list ;; Show trailing blanks - (list (concat "\\(\\(" blank-trailing-regexp "\\)+\\)$") - 1 blank-trailing t)) + (list (concat "\\(\\(" whitespace-trailing-regexp "\\)+\\)$") + 1 whitespace-trailing t)) t)) - (when (or (memq 'lines blank-active-chars) - (memq 'lines-tail blank-active-chars)) + (when (or (memq 'lines whitespace-active-chars) + (memq 'lines-tail whitespace-active-chars)) (font-lock-add-keywords nil (list @@ -1534,115 +1606,115 @@ options are valid." (format "^\\([^\t\n]\\{%s\\}\\|[^\t\n]\\{0,%s\\}\t\\)\\{%d\\}%s\\(.+\\)$" tab-width (1- tab-width) - (/ blank-line-column tab-width) - (let ((rem (% blank-line-column tab-width))) + (/ whitespace-line-column tab-width) + (let ((rem (% whitespace-line-column tab-width))) (if (zerop rem) "" (format ".\\{%d\\}" rem)))) - (if (memq 'lines blank-active-chars) + (if (memq 'lines whitespace-active-chars) 0 ; whole line 2) ; line tail - blank-line t)) + whitespace-line t)) t)) - (when (memq 'space-before-tab blank-active-chars) + (when (memq 'space-before-tab whitespace-active-chars) (font-lock-add-keywords nil (list ;; Show SPACEs before TAB - (list blank-space-before-tab-regexp - 1 blank-space-before-tab t)) + (list whitespace-space-before-tab-regexp + 1 whitespace-space-before-tab t)) t)) - (when (memq 'indentation blank-active-chars) + (when (memq 'indentation whitespace-active-chars) (font-lock-add-keywords nil (list ;; Show indentation SPACEs - (list blank-indentation-regexp - 1 blank-indentation t)) + (list whitespace-indentation-regexp + 1 whitespace-indentation t)) t)) - (when (memq 'empty blank-active-chars) + (when (memq 'empty whitespace-active-chars) (font-lock-add-keywords nil (list ;; Show empty lines at beginning of buffer - (list blank-empty-at-bob-regexp - 1 blank-empty t)) + (list whitespace-empty-at-bob-regexp + 1 whitespace-empty t)) t) (font-lock-add-keywords nil (list ;; Show empty lines at end of buffer - (list blank-empty-at-eob-regexp - 1 blank-empty t)) + (list whitespace-empty-at-eob-regexp + 1 whitespace-empty t)) t)) - (when (memq 'space-after-tab blank-active-chars) + (when (memq 'space-after-tab whitespace-active-chars) (font-lock-add-keywords nil (list ;; Show SPACEs after TAB - (list blank-space-after-tab-regexp - 1 blank-space-after-tab t)) + (list whitespace-space-after-tab-regexp + 1 whitespace-space-after-tab t)) t)) ;; now turn on font lock and highlight blanks (font-lock-mode 1))) -(defun blank-color-off () +(defun whitespace-color-off () "Turn off color visualization." - (when blank-active-chars + (when whitespace-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)) + (when whitespace-font-lock + (setq whitespace-font-lock nil + font-lock-keywords whitespace-font-lock-keywords)) ;; restore original font lock state - (font-lock-mode blank-font-lock-mode))) + (font-lock-mode whitespace-font-lock-mode))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; Hacked from visws.el (Miles Bader ) -(defvar blank-display-table nil +(defvar whitespace-display-table nil "Used to save a local display table.") -(make-variable-buffer-local 'blank-display-table) +(make-variable-buffer-local 'whitespace-display-table) -(defvar blank-display-table-was-local nil - "Used to remember whether a buffer initially had a local display table or not.") -(make-variable-buffer-local 'blank-display-table-was-local) +(defvar whitespace-display-table-was-local nil + "Used to remember whether a buffer initially had a local display table.") +(make-variable-buffer-local 'whitespace-display-table-was-local) -(defsubst blank-char-valid-p (char) +(defsubst whitespace-char-valid-p (char) ;; This check should be improved!!! (or (< char 256) (char-valid-p char))) -(defun blank-legal-display-vector-p (vec) +(defun whitespace-display-vector-p (vec) "Return true if every character in vector VEC can be displayed." (let ((i (length vec))) (when (> i 0) (while (and (>= (setq i (1- i)) 0) - (blank-char-valid-p (aref vec i)))) + (whitespace-char-valid-p (aref vec i)))) (< i 0)))) -(defun blank-display-char-on () +(defun whitespace-display-char-on () "Turn on character display mapping." - (when blank-display-mappings + (when whitespace-display-mappings (let (vecs vec) ;; Remember whether a buffer has a local display table. - (unless blank-display-table-was-local - (setq blank-display-table-was-local t - blank-display-table + (unless whitespace-display-table-was-local + (setq whitespace-display-table-was-local t + whitespace-display-table (copy-sequence buffer-display-table))) (unless buffer-display-table (setq buffer-display-table (make-display-table))) - (dolist (entry blank-display-mappings) + (dolist (entry whitespace-display-mappings) (setq vecs (cdr entry)) ;; Get a displayable mapping. (while (and vecs - (not (blank-legal-display-vector-p (car vecs)))) + (not (whitespace-display-vector-p (car vecs)))) (setq vecs (cdr vecs))) ;; Display a valid mapping. (when vecs @@ -1652,19 +1724,20 @@ options are valid." ((not (eq (car entry) ?\n)) (aset buffer-display-table (car entry) vec)) ;; Newline char - display it - ((memq 'newline blank-active-chars) + ((memq 'newline whitespace-active-chars) ;; Only insert face bits on NEWLINE char mapping to avoid ;; obstruction of other faces like TABs and (HARD) SPACEs ;; faces, font-lock faces, etc. - (when (memq 'color blank-active-style) + (when (memq 'color whitespace-active-style) (dotimes (i (length vec)) ;; Due to limitations of glyph representation, the char ;; code can not be above ?\x1FFFF. Probably, this will ;; be fixed after Emacs unicode merging. (or (eq (aref vec i) ?\n) (> (aref vec i) #x1FFFF) - (aset vec i (make-glyph-code (aref vec i) - blank-newline))))) + (aset vec i + (make-glyph-code (aref vec i) + whitespace-newline))))) ;; Display mapping (aset buffer-display-table (car entry) vec)) ;; Newline char - don't display it @@ -1673,54 +1746,21 @@ options are valid." ))))))) -(defun blank-display-char-off () +(defun whitespace-display-char-off () "Turn off character display mapping." - (and blank-display-mappings - blank-display-table-was-local - (setq blank-display-table-was-local nil - buffer-display-table blank-display-table))) - - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;; Aliases for whitespace compatibility - - -;;;###autoload -(defun whitespace-buffer () - (interactive) - (blank-mode 0) ; assure is off - ;; keep original values - (let ((blank-style (copy-sequence blank-style)) - (blank-chars (copy-sequence blank-chars))) - ;; adjust options for whitespace bogus blanks - (add-to-list 'blank-style 'color) - (mapc #'(lambda (option) - (add-to-list 'blank-chars option)) - '(trailing - indentation - space-before-tab - empty - space-after-tab)) - (blank-mode 1))) - -;;;###autoload -(defalias 'whitespace-region 'whitespace-buffer) ; there is no `blank-region' - -;;;###autoload -(defalias 'whitespace-cleanup 'blank-cleanup) - -;;;###autoload -(defalias 'whitespace-cleanup-region 'blank-cleanup-region) + (and whitespace-display-mappings + whitespace-display-table-was-local + (setq whitespace-display-table-was-local nil + buffer-display-table whitespace-display-table))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(provide 'blank-mode) +(provide 'whitespace) -(run-hooks 'blank-load-hook) +(run-hooks 'whitespace-load-hook) -;; arch-tag: 1b1e2500-dbd4-4a26-8f7a-5a5edfd3c97e -;;; blank-mode.el ends here +;;; whitespace.el ends here -- 2.39.5