diff options
| -rw-r--r-- | lisp/ChangeLog | 14 | ||||
| -rw-r--r-- | lisp/obsolete/old-whitespace.el (renamed from lisp/obsolete/whitespace.el) | 0 | ||||
| -rw-r--r-- | lisp/whitespace.el (renamed from lisp/blank-mode.el) | 1094 |
3 files changed, 577 insertions, 531 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 4a76265d293..1dc4eed7365 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2008-01-31 Vinicius Jose Latorre <viniciusjl@ig.com.br> | ||
| 2 | |||
| 3 | * blank-mode.el: Renamed to whitespace.el. | ||
| 4 | |||
| 5 | * obsolete/whitespace.el: Renamed to obsolete/old-whitespace.el. | ||
| 6 | |||
| 1 | 2008-01-31 Stefan Monnier <monnier@iro.umontreal.ca> | 7 | 2008-01-31 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 8 | ||
| 3 | * net/rcompile.el (remote-compile): Remove broken code. | 9 | * net/rcompile.el (remote-compile): Remove broken code. |
| @@ -6,16 +12,16 @@ | |||
| 6 | 12 | ||
| 7 | * term/w32-win.el (image-library-alist): Prefer libxpm.dll. | 13 | * term/w32-win.el (image-library-alist): Prefer libxpm.dll. |
| 8 | 14 | ||
| 15 | 2008-01-31 Juanma Barranquero <lekktu@gmail.com> | ||
| 16 | |||
| 17 | * linum.el (linum-unload-function): New function. | ||
| 18 | |||
| 9 | 2008-01-30 Nick Roberts <nickrob@snap.net.nz> | 19 | 2008-01-30 Nick Roberts <nickrob@snap.net.nz> |
| 10 | 20 | ||
| 11 | * progmodes/gdb-ui.el (gdb-var-set-format-regexp): New constant. | 21 | * progmodes/gdb-ui.el (gdb-var-set-format-regexp): New constant. |
| 12 | (gdb-var-set-format-handler): New function. | 22 | (gdb-var-set-format-handler): New function. |
| 13 | (gdb-var-set-format): Use it. | 23 | (gdb-var-set-format): Use it. |
| 14 | 24 | ||
| 15 | 2008-01-31 Juanma Barranquero <lekktu@gmail.com> | ||
| 16 | |||
| 17 | * linum.el (linum-unload-function): New function. | ||
| 18 | |||
| 19 | 2008-01-30 Juanma Barranquero <lekktu@gmail.com> | 25 | 2008-01-30 Juanma Barranquero <lekktu@gmail.com> |
| 20 | 26 | ||
| 21 | * emacs-lisp/check-declare.el (check-declare-directory): | 27 | * emacs-lisp/check-declare.el (check-declare-directory): |
diff --git a/lisp/obsolete/whitespace.el b/lisp/obsolete/old-whitespace.el index b2ef06c9584..b2ef06c9584 100644 --- a/lisp/obsolete/whitespace.el +++ b/lisp/obsolete/old-whitespace.el | |||
diff --git a/lisp/blank-mode.el b/lisp/whitespace.el index 8956e95ac1e..d7603ddbb38 100644 --- a/lisp/blank-mode.el +++ b/lisp/whitespace.el | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | ;;; blank-mode.el --- minor mode to visualize TAB, (HARD) SPACE, NEWLINE | 1 | ;;; whitespace.el --- minor mode to visualize TAB, (HARD) SPACE, NEWLINE |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 | 3 | ;; Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 |
| 4 | ;; Free Software Foundation, Inc. | 4 | ;; Free Software Foundation, Inc. |
| @@ -36,73 +36,76 @@ | |||
| 36 | ;; This package is a minor mode to visualize blanks (TAB, (HARD) SPACE | 36 | ;; This package is a minor mode to visualize blanks (TAB, (HARD) SPACE |
| 37 | ;; and NEWLINE). | 37 | ;; and NEWLINE). |
| 38 | ;; | 38 | ;; |
| 39 | ;; blank-mode uses two ways to visualize blanks: faces and display | 39 | ;; whitespace uses two ways to visualize blanks: faces and display |
| 40 | ;; table. | 40 | ;; table. |
| 41 | ;; | 41 | ;; |
| 42 | ;; * Faces are used to highlight the background with a color. | 42 | ;; * Faces are used to highlight the background with a color. |
| 43 | ;; blank-mode uses font-lock to highlight blank characters. | 43 | ;; whitespace uses font-lock to highlight blank characters. |
| 44 | ;; | 44 | ;; |
| 45 | ;; * Display table changes the way a character is displayed, that is, | 45 | ;; * Display table changes the way a character is displayed, that is, |
| 46 | ;; it provides a visual mark for characters, for example, at the end | 46 | ;; it provides a visual mark for characters, for example, at the end |
| 47 | ;; of line (?\xB6), at SPACEs (?\xB7) and at TABs (?\xBB). | 47 | ;; of line (?\xB6), at SPACEs (?\xB7) and at TABs (?\xBB). |
| 48 | ;; | 48 | ;; |
| 49 | ;; The `blank-style' and `blank-chars' variables are used to select | 49 | ;; The `whitespace-style' and `whitespace-chars' variables are used to |
| 50 | ;; which way should be used to visualize blanks. | 50 | ;; select which way should be used to visualize blanks. |
| 51 | ;; | 51 | ;; |
| 52 | ;; Note that when blank-mode is turned on, blank-mode saves the | 52 | ;; Note that when whitespace is turned on, whitespace saves the |
| 53 | ;; font-lock state, that is, if font-lock is on or off. And | 53 | ;; font-lock state, that is, if font-lock is on or off. And |
| 54 | ;; blank-mode restores the font-lock state when it is turned off. So, | 54 | ;; whitespace restores the font-lock state when it is turned off. So, |
| 55 | ;; if blank-mode is turned on and font-lock is off, blank-mode also | 55 | ;; if whitespace is turned on and font-lock is off, whitespace also |
| 56 | ;; turns on the font-lock to highlight blanks, but the font-lock will | 56 | ;; turns on the font-lock to highlight blanks, but the font-lock will |
| 57 | ;; be turned off when blank-mode is turned off. Thus, turn on | 57 | ;; be turned off when whitespace is turned off. Thus, turn on |
| 58 | ;; font-lock before blank-mode is on, if you want that font-lock | 58 | ;; font-lock before whitespace is on, if you want that font-lock |
| 59 | ;; continues on after blank-mode is turned off. | 59 | ;; continues on after whitespace is turned off. |
| 60 | ;; | 60 | ;; |
| 61 | ;; When blank-mode is on, it takes care of highlighting some special | 61 | ;; When whitespace is on, it takes care of highlighting some special |
| 62 | ;; characters over the default mechanism of `nobreak-char-display' | 62 | ;; characters over the default mechanism of `nobreak-char-display' |
| 63 | ;; (which see) and `show-trailing-whitespace' (which see). | 63 | ;; (which see) and `show-trailing-whitespace' (which see). |
| 64 | ;; | 64 | ;; |
| 65 | ;; There are two ways of using blank-mode: local and global. | 65 | ;; There are two ways of using whitespace: local and global. |
| 66 | ;; | 66 | ;; |
| 67 | ;; * Local blank-mode affects only the current buffer. | 67 | ;; * Local whitespace affects only the current buffer. |
| 68 | ;; | 68 | ;; |
| 69 | ;; * Global blank-mode affects all current and future buffers. That | 69 | ;; * Global whitespace affects all current and future buffers. That |
| 70 | ;; is, if you turn on global blank-mode and then create a new | 70 | ;; is, if you turn on global whitespace and then create a new |
| 71 | ;; buffer, the new buffer will also have blank-mode on. The | 71 | ;; buffer, the new buffer will also have whitespace on. The |
| 72 | ;; `blank-global-modes' variable controls which major-mode will be | 72 | ;; `whitespace-global-modes' variable controls which major-mode will |
| 73 | ;; automagically turned on. | 73 | ;; be automagically turned on. |
| 74 | ;; | 74 | ;; |
| 75 | ;; You can mix the local and global usage without any conflict. But | 75 | ;; You can mix the local and global usage without any conflict. But |
| 76 | ;; local blank-mode has priority over global blank-mode. Blank mode | 76 | ;; local whitespace has priority over global whitespace. Whitespace |
| 77 | ;; is active in a buffer if you have enabled it in that buffer or if | 77 | ;; mode is active in a buffer if you have enabled it in that buffer or |
| 78 | ;; you have enabled it globally. | 78 | ;; if you have enabled it globally. |
| 79 | ;; | 79 | ;; |
| 80 | ;; When global and local blank-mode are on: | 80 | ;; When global and local whitespace are on: |
| 81 | ;; | 81 | ;; |
| 82 | ;; * if local blank-mode is turned off, blank-mode is turned off for | 82 | ;; * if local whitespace is turned off, whitespace is turned off for |
| 83 | ;; the current buffer only. | 83 | ;; the current buffer only. |
| 84 | ;; | 84 | ;; |
| 85 | ;; * if global blank-mode is turned off, blank-mode continues on only | 85 | ;; * if global whitespace is turned off, whitespace continues on only |
| 86 | ;; in the buffers in which local blank-mode is on. | 86 | ;; in the buffers in which local whitespace is on. |
| 87 | ;; | 87 | ;; |
| 88 | ;; To use blank-mode, insert in your ~/.emacs: | 88 | ;; To use whitespace, insert in your ~/.emacs: |
| 89 | ;; | 89 | ;; |
| 90 | ;; (require 'blank-mode) | 90 | ;; (require 'whitespace-mode) |
| 91 | ;; | 91 | ;; |
| 92 | ;; Or autoload at least one of the commands`blank-mode', | 92 | ;; Or autoload at least one of the commands`whitespace-mode', |
| 93 | ;; `blank-toggle-options', `global-blank-mode' or | 93 | ;; `whitespace-toggle-options', `global-whitespace-mode' or |
| 94 | ;; `global-blank-toggle-options'. For example: | 94 | ;; `global-whitespace-toggle-options'. For example: |
| 95 | ;; | 95 | ;; |
| 96 | ;; (autoload 'blank-mode "blank-mode" | 96 | ;; (autoload 'whitespace-mode "whitespace" |
| 97 | ;; "Toggle blank visualization." t) | 97 | ;; "Toggle whitespace visualization." t) |
| 98 | ;; (autoload 'blank-toggle-options "blank-mode" | 98 | ;; (autoload 'whitespace-toggle-options "whitespace" |
| 99 | ;; "Toggle local `blank-mode' options." t) | 99 | ;; "Toggle local `whitespace-mode' options." t) |
| 100 | ;; | 100 | ;; |
| 101 | ;; blank-mode was inspired by: | 101 | ;; whitespace was inspired by: |
| 102 | ;; | 102 | ;; |
| 103 | ;; whitespace.el Rajesh Vaidheeswarran <rv@gnu.org> | 103 | ;; whitespace.el Rajesh Vaidheeswarran <rv@gnu.org> |
| 104 | ;; Warn about and clean bogus whitespaces in the file | 104 | ;; Warn about and clean bogus whitespaces in the file |
| 105 | ;; (inspired the idea to warn and clean some blanks) | 105 | ;; (inspired the idea to warn and clean some blanks) |
| 106 | ;; This was the original `whitespace.el' which was replaced by | ||
| 107 | ;; `blank-mode.el'. And later `blank-mode.el' was renamed to | ||
| 108 | ;; `whitespace.el'. | ||
| 106 | ;; | 109 | ;; |
| 107 | ;; show-whitespace-mode.el Aurelien Tisne <aurelien.tisne@free.fr> | 110 | ;; show-whitespace-mode.el Aurelien Tisne <aurelien.tisne@free.fr> |
| 108 | ;; Simple mode to highlight whitespaces | 111 | ;; Simple mode to highlight whitespaces |
| @@ -118,159 +121,162 @@ | |||
| 118 | ;; idea was kept) | 121 | ;; idea was kept) |
| 119 | ;; | 122 | ;; |
| 120 | ;; | 123 | ;; |
| 121 | ;; Using blank-mode | 124 | ;; Using whitespace |
| 122 | ;; ---------------- | 125 | ;; ---------------- |
| 123 | ;; | 126 | ;; |
| 124 | ;; There is no problem if you mix local and global minor mode usage. | 127 | ;; There is no problem if you mix local and global minor mode usage. |
| 125 | ;; | 128 | ;; |
| 126 | ;; * LOCAL blank-mode: | 129 | ;; * LOCAL whitespace: |
| 127 | ;; + To toggle blank-mode options locally, type: | 130 | ;; + To toggle whitespace options locally, type: |
| 128 | ;; | 131 | ;; |
| 129 | ;; M-x blank-toggle-options RET | 132 | ;; M-x whitespace-toggle-options RET |
| 130 | ;; | 133 | ;; |
| 131 | ;; + To activate blank-mode locally, type: | 134 | ;; + To activate whitespace locally, type: |
| 132 | ;; | 135 | ;; |
| 133 | ;; C-u 1 M-x blank-mode RET | 136 | ;; C-u 1 M-x whitespace-mode RET |
| 134 | ;; | 137 | ;; |
| 135 | ;; + To deactivate blank-mode locally, type: | 138 | ;; + To deactivate whitespace locally, type: |
| 136 | ;; | 139 | ;; |
| 137 | ;; C-u 0 M-x blank-mode RET | 140 | ;; C-u 0 M-x whitespace-mode RET |
| 138 | ;; | 141 | ;; |
| 139 | ;; + To toggle blank-mode locally, type: | 142 | ;; + To toggle whitespace locally, type: |
| 140 | ;; | 143 | ;; |
| 141 | ;; M-x blank-mode RET | 144 | ;; M-x whitespace-mode RET |
| 142 | ;; | 145 | ;; |
| 143 | ;; * GLOBAL blank-mode: | 146 | ;; * GLOBAL whitespace: |
| 144 | ;; + To toggle blank-mode options globally, type: | 147 | ;; + To toggle whitespace options globally, type: |
| 145 | ;; | 148 | ;; |
| 146 | ;; M-x global-blank-toggle-options RET | 149 | ;; M-x global-whitespace-toggle-options RET |
| 147 | ;; | 150 | ;; |
| 148 | ;; + To activate blank-mode globally, type: | 151 | ;; + To activate whitespace globally, type: |
| 149 | ;; | 152 | ;; |
| 150 | ;; C-u 1 M-x global-blank-mode RET | 153 | ;; C-u 1 M-x global-whitespace-mode RET |
| 151 | ;; | 154 | ;; |
| 152 | ;; + To deactivate blank-mode globally, type: | 155 | ;; + To deactivate whitespace globally, type: |
| 153 | ;; | 156 | ;; |
| 154 | ;; C-u 0 M-x global-blank-mode RET | 157 | ;; C-u 0 M-x global-whitespace-mode RET |
| 155 | ;; | 158 | ;; |
| 156 | ;; + To toggle blank-mode globally, type: | 159 | ;; + To toggle whitespace globally, type: |
| 157 | ;; | 160 | ;; |
| 158 | ;; M-x global-blank-mode RET | 161 | ;; M-x global-whitespace-mode RET |
| 159 | ;; | 162 | ;; |
| 160 | ;; There are also the following useful commands: | 163 | ;; There are also the following useful commands: |
| 161 | ;; | 164 | ;; |
| 162 | ;; `blank-cleanup' | 165 | ;; `whitespace-cleanup' |
| 163 | ;; Cleanup some blank problems in all buffer or at region. | 166 | ;; Cleanup some blank problems in all buffer or at region. |
| 164 | ;; | 167 | ;; |
| 165 | ;; `blank-cleanup-region' | 168 | ;; `whitespace-cleanup-region' |
| 166 | ;; Cleanup some blank problems at region. | 169 | ;; Cleanup some blank problems at region. |
| 167 | ;; | 170 | ;; |
| 171 | ;; `whitespace-buffer' | ||
| 172 | ;; Turn on `whitespace-mode' forcing some settings. | ||
| 173 | ;; | ||
| 168 | ;; The problems, which are cleaned up, are: | 174 | ;; The problems, which are cleaned up, are: |
| 169 | ;; | 175 | ;; |
| 170 | ;; 1. empty lines at beginning of buffer. | 176 | ;; 1. empty lines at beginning of buffer. |
| 171 | ;; 2. empty lines at end of buffer. | 177 | ;; 2. empty lines at end of buffer. |
| 172 | ;; If `blank-chars' has `empty' as an element, remove all empty | 178 | ;; If `whitespace-chars' has `empty' as an element, remove all |
| 173 | ;; lines at beginning and/or end of buffer. | 179 | ;; empty lines at beginning and/or end of buffer. |
| 174 | ;; | 180 | ;; |
| 175 | ;; 3. 8 or more SPACEs at beginning of line. | 181 | ;; 3. 8 or more SPACEs at beginning of line. |
| 176 | ;; If `blank-chars' has `indentation' as an element, replace 8 or | 182 | ;; If `whitespace-chars' has `indentation' as an element, replace 8 |
| 177 | ;; more SPACEs at beginning of line by TABs. | 183 | ;; or more SPACEs at beginning of line by TABs. |
| 178 | ;; | 184 | ;; |
| 179 | ;; 4. SPACEs before TAB. | 185 | ;; 4. SPACEs before TAB. |
| 180 | ;; If `blank-chars' has `space-before-tab' as an element, replace | 186 | ;; If `whitespace-chars' has `space-before-tab' as an element, |
| 181 | ;; SPACEs by TABs. | 187 | ;; replace SPACEs by TABs. |
| 182 | ;; | 188 | ;; |
| 183 | ;; 5. SPACEs or TABs at end of line. | 189 | ;; 5. SPACEs or TABs at end of line. |
| 184 | ;; If `blank-chars' has `trailing' as an element, remove all | 190 | ;; If `whitespace-chars' has `trailing' as an element, remove all |
| 185 | ;; SPACEs or TABs at end of line." | 191 | ;; SPACEs or TABs at end of line." |
| 186 | ;; | 192 | ;; |
| 187 | ;; 6. 8 or more SPACEs after TAB. | 193 | ;; 6. 8 or more SPACEs after TAB. |
| 188 | ;; If `blank-chars' has `space-after-tab' as an element, replace | 194 | ;; If `whitespace-chars' has `space-after-tab' as an element, |
| 189 | ;; SPACEs by TABs. | 195 | ;; replace SPACEs by TABs. |
| 190 | ;; | 196 | ;; |
| 191 | ;; | 197 | ;; |
| 192 | ;; Hooks | 198 | ;; Hooks |
| 193 | ;; ----- | 199 | ;; ----- |
| 194 | ;; | 200 | ;; |
| 195 | ;; blank-mode has the following hook variables: | 201 | ;; whitespace has the following hook variables: |
| 196 | ;; | 202 | ;; |
| 197 | ;; `blank-mode-hook' | 203 | ;; `whitespace-mode-hook' |
| 198 | ;; It is evaluated always when blank-mode is turned on locally. | 204 | ;; It is evaluated always when whitespace is turned on locally. |
| 199 | ;; | 205 | ;; |
| 200 | ;; `global-blank-mode-hook' | 206 | ;; `global-whitespace-mode-hook' |
| 201 | ;; It is evaluated always when blank-mode is turned on globally. | 207 | ;; It is evaluated always when whitespace is turned on globally. |
| 202 | ;; | 208 | ;; |
| 203 | ;; `blank-load-hook' | 209 | ;; `whitespace-load-hook' |
| 204 | ;; It is evaluated after blank-mode package is loaded. | 210 | ;; It is evaluated after whitespace package is loaded. |
| 205 | ;; | 211 | ;; |
| 206 | ;; | 212 | ;; |
| 207 | ;; Options | 213 | ;; Options |
| 208 | ;; ------- | 214 | ;; ------- |
| 209 | ;; | 215 | ;; |
| 210 | ;; Below it's shown a brief description of blank-mode options, please, | 216 | ;; Below it's shown a brief description of whitespace options, please, |
| 211 | ;; see the options declaration in the code for a long documentation. | 217 | ;; see the options declaration in the code for a long documentation. |
| 212 | ;; | 218 | ;; |
| 213 | ;; `blank-style' Specify the visualization style. | 219 | ;; `whitespace-style' Specify the visualization style. |
| 214 | ;; | 220 | ;; |
| 215 | ;; `blank-chars' Specify which kind of blank is | 221 | ;; `whitespace-chars' Specify which kind of blank is |
| 216 | ;; visualized. | 222 | ;; visualized. |
| 217 | ;; | 223 | ;; |
| 218 | ;; `blank-space' Face used to visualize SPACE. | 224 | ;; `whitespace-space' Face used to visualize SPACE. |
| 219 | ;; | 225 | ;; |
| 220 | ;; `blank-hspace' Face used to visualize HARD SPACE. | 226 | ;; `whitespace-hspace' Face used to visualize HARD SPACE. |
| 221 | ;; | 227 | ;; |
| 222 | ;; `blank-tab' Face used to visualize TAB. | 228 | ;; `whitespace-tab' Face used to visualize TAB. |
| 223 | ;; | 229 | ;; |
| 224 | ;; `blank-newline' Face used to visualize NEWLINE char | 230 | ;; `whitespace-newline' Face used to visualize NEWLINE char |
| 225 | ;; mapping. | 231 | ;; mapping. |
| 226 | ;; | 232 | ;; |
| 227 | ;; `blank-trailing' Face used to visualize trailing | 233 | ;; `whitespace-trailing' Face used to visualize trailing |
| 228 | ;; blanks. | 234 | ;; blanks. |
| 229 | ;; | 235 | ;; |
| 230 | ;; `blank-line' Face used to visualize "long" lines. | 236 | ;; `whitespace-line' Face used to visualize "long" lines. |
| 231 | ;; | 237 | ;; |
| 232 | ;; `blank-space-before-tab' Face used to visualize SPACEs before | 238 | ;; `whitespace-space-before-tab' Face used to visualize SPACEs |
| 233 | ;; TAB. | 239 | ;; before TAB. |
| 234 | ;; | 240 | ;; |
| 235 | ;; `blank-indentation' Face used to visualize 8 or more | 241 | ;; `whitespace-indentation' Face used to visualize 8 or more |
| 236 | ;; SPACEs at beginning of line. | 242 | ;; SPACEs at beginning of line. |
| 237 | ;; | 243 | ;; |
| 238 | ;; `blank-empty' Face used to visualize empty lines at | 244 | ;; `whitespace-empty' Face used to visualize empty lines at |
| 239 | ;; beginning and/or end of buffer. | 245 | ;; beginning and/or end of buffer. |
| 240 | ;; | 246 | ;; |
| 241 | ;; `blank-space-after-tab' Face used to visualize 8 or more | 247 | ;; `whitespace-space-after-tab' Face used to visualize 8 or more |
| 242 | ;; SPACEs after TAB. | 248 | ;; SPACEs after TAB. |
| 243 | ;; | 249 | ;; |
| 244 | ;; `blank-space-regexp' Specify SPACE characters regexp. | 250 | ;; `whitespace-space-regexp' Specify SPACE characters regexp. |
| 245 | ;; | 251 | ;; |
| 246 | ;; `blank-hspace-regexp' Specify HARD SPACE characters regexp. | 252 | ;; `whitespace-hspace-regexp' Specify HARD SPACE characters regexp. |
| 247 | ;; | 253 | ;; |
| 248 | ;; `blank-tab-regexp' Specify TAB characters regexp. | 254 | ;; `whitespace-tab-regexp' Specify TAB characters regexp. |
| 249 | ;; | 255 | ;; |
| 250 | ;; `blank-trailing-regexp' Specify trailing characters regexp. | 256 | ;; `whitespace-trailing-regexp' Specify trailing characters regexp. |
| 251 | ;; | 257 | ;; |
| 252 | ;; `blank-space-before-tab-regexp' Specify SPACEs before TAB | 258 | ;; `whitespace-space-before-tab-regexp' Specify SPACEs before TAB |
| 253 | ;; regexp. | 259 | ;; regexp. |
| 254 | ;; | 260 | ;; |
| 255 | ;; `blank-indentation-regexp' Specify regexp for 8 or more SPACEs at | 261 | ;; `whitespace-indentation-regexp' Specify regexp for 8 or more |
| 256 | ;; beginning of line. | 262 | ;; SPACEs at beginning of line. |
| 257 | ;; | 263 | ;; |
| 258 | ;; `blank-empty-at-bob-regexp' Specify regexp for empty lines at | 264 | ;; `whitespace-empty-at-bob-regexp' Specify regexp for empty lines |
| 259 | ;; beginning of buffer. | 265 | ;; at beginning of buffer. |
| 260 | ;; | 266 | ;; |
| 261 | ;; `blank-empty-at-eob-regexp' Specify regexp for empty lines at end | 267 | ;; `whitespace-empty-at-eob-regexp' Specify regexp for empty lines |
| 262 | ;; of buffer. | 268 | ;; at end of buffer. |
| 263 | ;; | 269 | ;; |
| 264 | ;; `blank-space-after-tab-regexp' Specify regexp for 8 or more | 270 | ;; `whitespace-space-after-tab-regexp' Specify regexp for 8 or more |
| 265 | ;; SPACEs after TAB. | 271 | ;; SPACEs after TAB. |
| 266 | ;; | 272 | ;; |
| 267 | ;; `blank-line-column' Specify column beyond which the line | 273 | ;; `whitespace-line-column' Specify column beyond which the line |
| 268 | ;; is highlighted. | 274 | ;; is highlighted. |
| 269 | ;; | 275 | ;; |
| 270 | ;; `blank-display-mappings' Specify an alist of mappings for | 276 | ;; `whitespace-display-mappings' Specify an alist of mappings |
| 271 | ;; displaying characters. | 277 | ;; for displaying characters. |
| 272 | ;; | 278 | ;; |
| 273 | ;; `blank-global-modes' Modes for which global `blank-mode' is | 279 | ;; `whitespace-global-modes' Modes for which global `whitespace-mode' is |
| 274 | ;; automagically turned on. | 280 | ;; automagically turned on. |
| 275 | ;; | 281 | ;; |
| 276 | ;; | 282 | ;; |
| @@ -282,7 +288,7 @@ | |||
| 282 | ;; | 288 | ;; |
| 283 | ;; Thanks to Juri Linkov <juri@jurta.org> for suggesting: | 289 | ;; Thanks to Juri Linkov <juri@jurta.org> for suggesting: |
| 284 | ;; * `define-minor-mode'. | 290 | ;; * `define-minor-mode'. |
| 285 | ;; * `global-blank-*' name for global commands. | 291 | ;; * `global-whitespace-*' name for global commands. |
| 286 | ;; | 292 | ;; |
| 287 | ;; Thanks to Robert J. Chassell <bob@gnu.org> for doc fix and testing. | 293 | ;; Thanks to Robert J. Chassell <bob@gnu.org> for doc fix and testing. |
| 288 | ;; | 294 | ;; |
| @@ -302,13 +308,13 @@ | |||
| 302 | ;; newline character mapping. | 308 | ;; newline character mapping. |
| 303 | ;; | 309 | ;; |
| 304 | ;; Thanks to Pete Forman <pete.forman@westgeo.com> for indicating | 310 | ;; Thanks to Pete Forman <pete.forman@westgeo.com> for indicating |
| 305 | ;; whitespace-mode on XEmacs. | 311 | ;; whitespace-mode.el on XEmacs. |
| 306 | ;; | 312 | ;; |
| 307 | ;; Thanks to Miles Bader <miles@gnu.org> for handling display table via | 313 | ;; Thanks to Miles Bader <miles@gnu.org> for handling display table via |
| 308 | ;; visws.el (his code was modified, but the main idea was kept). | 314 | ;; visws.el (his code was modified, but the main idea was kept). |
| 309 | ;; | 315 | ;; |
| 310 | ;; Thanks to: | 316 | ;; Thanks to: |
| 311 | ;; Rajesh Vaidheeswarran <rv@gnu.org> whitespace.el | 317 | ;; Rajesh Vaidheeswarran <rv@gnu.org> (original) whitespace.el |
| 312 | ;; Aurelien Tisne <aurelien.tisne@free.fr> show-whitespace-mode.el | 318 | ;; Aurelien Tisne <aurelien.tisne@free.fr> show-whitespace-mode.el |
| 313 | ;; Lawrence Mitchell <wence@gmx.li> whitespace-mode.el | 319 | ;; Lawrence Mitchell <wence@gmx.li> whitespace-mode.el |
| 314 | ;; Miles Bader <miles@gnu.org> visws.el | 320 | ;; Miles Bader <miles@gnu.org> visws.el |
| @@ -327,15 +333,15 @@ | |||
| 327 | ;;; Interface to the command system | 333 | ;;; Interface to the command system |
| 328 | 334 | ||
| 329 | 335 | ||
| 330 | (defgroup blank nil | 336 | (defgroup whitespace nil |
| 331 | "Visualize blanks (TAB, (HARD) SPACE and NEWLINE)." | 337 | "Visualize blanks (TAB, (HARD) SPACE and NEWLINE)." |
| 332 | :link '(emacs-library-link :tag "Source Lisp File" "blank-mode.el") | 338 | :link '(emacs-library-link :tag "Source Lisp File" "whitespace.el") |
| 333 | :version "22.2" | 339 | :version "22.2" |
| 334 | :group 'wp | 340 | :group 'wp |
| 335 | :group 'data) | 341 | :group 'data) |
| 336 | 342 | ||
| 337 | 343 | ||
| 338 | (defcustom blank-style '(mark color) | 344 | (defcustom whitespace-style '(mark color) |
| 339 | "*Specify the visualization style. | 345 | "*Specify the visualization style. |
| 340 | 346 | ||
| 341 | It's a list which element value can be: | 347 | It's a list which element value can be: |
| @@ -348,15 +354,15 @@ Any other value is ignored. | |||
| 348 | 354 | ||
| 349 | If nil, don't visualize TABs, (HARD) SPACEs and NEWLINEs. | 355 | If nil, don't visualize TABs, (HARD) SPACEs and NEWLINEs. |
| 350 | 356 | ||
| 351 | See also `blank-display-mappings' for documentation." | 357 | See also `whitespace-display-mappings' for documentation." |
| 352 | :type '(repeat :tag "Style of Blank" | 358 | :type '(repeat :tag "Style of Blank" |
| 353 | (choice :tag "Style of Blank" | 359 | (choice :tag "Style of Blank" |
| 354 | (const :tag "Display Table" mark) | 360 | (const :tag "Display Table" mark) |
| 355 | (const :tag "Faces" color))) | 361 | (const :tag "Faces" color))) |
| 356 | :group 'blank) | 362 | :group 'whitespace) |
| 357 | 363 | ||
| 358 | 364 | ||
| 359 | (defcustom blank-chars | 365 | (defcustom whitespace-chars |
| 360 | '(tabs spaces trailing lines space-before-tab newline | 366 | '(tabs spaces trailing lines space-before-tab newline |
| 361 | indentation empty space-after-tab) | 367 | indentation empty space-after-tab) |
| 362 | "*Specify which kind of blank is visualized. | 368 | "*Specify which kind of blank is visualized. |
| @@ -370,17 +376,17 @@ It's a list which element value can be: | |||
| 370 | spaces SPACEs and HARD SPACEs are visualized. | 376 | spaces SPACEs and HARD SPACEs are visualized. |
| 371 | 377 | ||
| 372 | lines lines whose have columns beyond | 378 | lines lines whose have columns beyond |
| 373 | `blank-line-column' are highlighted. | 379 | `whitespace-line-column' are highlighted. |
| 374 | Whole line is highlighted. | 380 | Whole line is highlighted. |
| 375 | It has precedence over | 381 | It has precedence over |
| 376 | `lines-tail' (see below). | 382 | `lines-tail' (see below). |
| 377 | 383 | ||
| 378 | lines-tail lines whose have columns beyond | 384 | lines-tail lines whose have columns beyond |
| 379 | `blank-line-column' are highlighted. | 385 | `whitespace-line-column' are highlighted. |
| 380 | But only the part of line which goes | 386 | But only the part of line which goes |
| 381 | beyond `blank-line-column' column. | 387 | beyond `whitespace-line-column' column. |
| 382 | It has effect only if `lines' (see above) | 388 | It has effect only if `lines' (see above) |
| 383 | is not present in `blank-chars'. | 389 | is not present in `whitespace-chars'. |
| 384 | 390 | ||
| 385 | space-before-tab SPACEs before TAB are visualized. | 391 | space-before-tab SPACEs before TAB are visualized. |
| 386 | 392 | ||
| @@ -398,9 +404,9 @@ Any other value is ignored. | |||
| 398 | 404 | ||
| 399 | If nil, don't visualize TABs, (HARD) SPACEs and NEWLINEs. | 405 | If nil, don't visualize TABs, (HARD) SPACEs and NEWLINEs. |
| 400 | 406 | ||
| 401 | Used when `blank-style' has `color' as an element. | 407 | Used when `whitespace-style' has `color' as an element. |
| 402 | If `blank-chars' has `newline' as an element, used when `blank-style' | 408 | Used also when `whitespace-chars' has `newline' as an element and |
| 403 | has `mark' as an element." | 409 | `whitespace-style' has `mark' as an element." |
| 404 | :type '(repeat :tag "Kind of Blank" | 410 | :type '(repeat :tag "Kind of Blank" |
| 405 | (choice :tag "Kind of Blank" | 411 | (choice :tag "Kind of Blank" |
| 406 | (const :tag "Trailing TABs, SPACEs and HARD SPACEs" | 412 | (const :tag "Trailing TABs, SPACEs and HARD SPACEs" |
| @@ -416,75 +422,75 @@ has `mark' as an element." | |||
| 416 | empty) | 422 | empty) |
| 417 | (const :tag "SPACEs after TAB" | 423 | (const :tag "SPACEs after TAB" |
| 418 | space-after-tab))) | 424 | space-after-tab))) |
| 419 | :group 'blank) | 425 | :group 'whitespace) |
| 420 | 426 | ||
| 421 | 427 | ||
| 422 | (defcustom blank-space 'blank-space | 428 | (defcustom whitespace-space 'whitespace-space |
| 423 | "*Symbol face used to visualize SPACE. | 429 | "*Symbol face used to visualize SPACE. |
| 424 | 430 | ||
| 425 | Used when `blank-style' has `color' as an element." | 431 | Used when `whitespace-style' has `color' as an element." |
| 426 | :type 'face | 432 | :type 'face |
| 427 | :group 'blank) | 433 | :group 'whitespace) |
| 428 | 434 | ||
| 429 | 435 | ||
| 430 | (defface blank-space | 436 | (defface whitespace-space |
| 431 | '((((class color) (background dark)) | 437 | '((((class color) (background dark)) |
| 432 | (:background "grey20" :foreground "aquamarine3")) | 438 | (:background "grey20" :foreground "aquamarine3")) |
| 433 | (((class color) (background light)) | 439 | (((class color) (background light)) |
| 434 | (:background "LightYellow" :foreground "aquamarine3")) | 440 | (:background "LightYellow" :foreground "aquamarine3")) |
| 435 | (t (:inverse-video t))) | 441 | (t (:inverse-video t))) |
| 436 | "Face used to visualize SPACE." | 442 | "Face used to visualize SPACE." |
| 437 | :group 'blank) | 443 | :group 'whitespace) |
| 438 | 444 | ||
| 439 | 445 | ||
| 440 | (defcustom blank-hspace 'blank-hspace | 446 | (defcustom whitespace-hspace 'whitespace-hspace |
| 441 | "*Symbol face used to visualize HARD SPACE. | 447 | "*Symbol face used to visualize HARD SPACE. |
| 442 | 448 | ||
| 443 | Used when `blank-style' has `color' as an element." | 449 | Used when `whitespace-style' has `color' as an element." |
| 444 | :type 'face | 450 | :type 'face |
| 445 | :group 'blank) | 451 | :group 'whitespace) |
| 446 | 452 | ||
| 447 | 453 | ||
| 448 | (defface blank-hspace ; 'nobreak-space | 454 | (defface whitespace-hspace ; 'nobreak-space |
| 449 | '((((class color) (background dark)) | 455 | '((((class color) (background dark)) |
| 450 | (:background "grey24" :foreground "aquamarine3")) | 456 | (:background "grey24" :foreground "aquamarine3")) |
| 451 | (((class color) (background light)) | 457 | (((class color) (background light)) |
| 452 | (:background "LemonChiffon3" :foreground "aquamarine3")) | 458 | (:background "LemonChiffon3" :foreground "aquamarine3")) |
| 453 | (t (:inverse-video t))) | 459 | (t (:inverse-video t))) |
| 454 | "Face used to visualize HARD SPACE." | 460 | "Face used to visualize HARD SPACE." |
| 455 | :group 'blank) | 461 | :group 'whitespace) |
| 456 | 462 | ||
| 457 | 463 | ||
| 458 | (defcustom blank-tab 'blank-tab | 464 | (defcustom whitespace-tab 'whitespace-tab |
| 459 | "*Symbol face used to visualize TAB. | 465 | "*Symbol face used to visualize TAB. |
| 460 | 466 | ||
| 461 | Used when `blank-style' has `color' as an element." | 467 | Used when `whitespace-style' has `color' as an element." |
| 462 | :type 'face | 468 | :type 'face |
| 463 | :group 'blank) | 469 | :group 'whitespace) |
| 464 | 470 | ||
| 465 | 471 | ||
| 466 | (defface blank-tab | 472 | (defface whitespace-tab |
| 467 | '((((class color) (background dark)) | 473 | '((((class color) (background dark)) |
| 468 | (:background "grey22" :foreground "aquamarine3")) | 474 | (:background "grey22" :foreground "aquamarine3")) |
| 469 | (((class color) (background light)) | 475 | (((class color) (background light)) |
| 470 | (:background "beige" :foreground "aquamarine3")) | 476 | (:background "beige" :foreground "aquamarine3")) |
| 471 | (t (:inverse-video t))) | 477 | (t (:inverse-video t))) |
| 472 | "Face used to visualize TAB." | 478 | "Face used to visualize TAB." |
| 473 | :group 'blank) | 479 | :group 'whitespace) |
| 474 | 480 | ||
| 475 | 481 | ||
| 476 | (defcustom blank-newline 'blank-newline | 482 | (defcustom whitespace-newline 'whitespace-newline |
| 477 | "*Symbol face used to visualize NEWLINE char mapping. | 483 | "*Symbol face used to visualize NEWLINE char mapping. |
| 478 | 484 | ||
| 479 | See `blank-display-mappings'. | 485 | See `whitespace-display-mappings'. |
| 480 | 486 | ||
| 481 | Used when `blank-style' has `mark' and `color' as elements | 487 | Used when `whitespace-style' has `mark' and `color' as elements |
| 482 | and `blank-chars' has `newline' as an element." | 488 | and `whitespace-chars' has `newline' as an element." |
| 483 | :type 'face | 489 | :type 'face |
| 484 | :group 'blank) | 490 | :group 'whitespace) |
| 485 | 491 | ||
| 486 | 492 | ||
| 487 | (defface blank-newline | 493 | (defface whitespace-newline |
| 488 | '((((class color) (background dark)) | 494 | '((((class color) (background dark)) |
| 489 | (:background "grey26" :foreground "aquamarine3" :bold t)) | 495 | (:background "grey26" :foreground "aquamarine3" :bold t)) |
| 490 | (((class color) (background light)) | 496 | (((class color) (background light)) |
| @@ -492,105 +498,105 @@ and `blank-chars' has `newline' as an element." | |||
| 492 | (t (:bold t :underline t))) | 498 | (t (:bold t :underline t))) |
| 493 | "Face used to visualize NEWLINE char mapping. | 499 | "Face used to visualize NEWLINE char mapping. |
| 494 | 500 | ||
| 495 | See `blank-display-mappings'." | 501 | See `whitespace-display-mappings'." |
| 496 | :group 'blank) | 502 | :group 'whitespace) |
| 497 | 503 | ||
| 498 | 504 | ||
| 499 | (defcustom blank-trailing 'blank-trailing | 505 | (defcustom whitespace-trailing 'whitespace-trailing |
| 500 | "*Symbol face used to visualize traling blanks. | 506 | "*Symbol face used to visualize traling blanks. |
| 501 | 507 | ||
| 502 | Used when `blank-style' has `color' as an element." | 508 | Used when `whitespace-style' has `color' as an element." |
| 503 | :type 'face | 509 | :type 'face |
| 504 | :group 'blank) | 510 | :group 'whitespace) |
| 505 | 511 | ||
| 506 | 512 | ||
| 507 | (defface blank-trailing ; 'trailing-whitespace | 513 | (defface whitespace-trailing ; 'trailing-whitespace |
| 508 | '((((class mono)) (:inverse-video t :bold t :underline t)) | 514 | '((((class mono)) (:inverse-video t :bold t :underline t)) |
| 509 | (t (:background "red1" :foreground "yellow" :bold t))) | 515 | (t (:background "red1" :foreground "yellow" :bold t))) |
| 510 | "Face used to visualize trailing blanks." | 516 | "Face used to visualize trailing blanks." |
| 511 | :group 'blank) | 517 | :group 'whitespace) |
| 512 | 518 | ||
| 513 | 519 | ||
| 514 | (defcustom blank-line 'blank-line | 520 | (defcustom whitespace-line 'whitespace-line |
| 515 | "*Symbol face used to visualize \"long\" lines. | 521 | "*Symbol face used to visualize \"long\" lines. |
| 516 | 522 | ||
| 517 | See `blank-line-column'. | 523 | See `whitespace-line-column'. |
| 518 | 524 | ||
| 519 | Used when `blank-style' has `color' as an element." | 525 | Used when `whitespace-style' has `color' as an element." |
| 520 | :type 'face | 526 | :type 'face |
| 521 | :group 'blank) | 527 | :group 'whitespace) |
| 522 | 528 | ||
| 523 | 529 | ||
| 524 | (defface blank-line | 530 | (defface whitespace-line |
| 525 | '((((class mono)) (:inverse-video t :bold t :underline t)) | 531 | '((((class mono)) (:inverse-video t :bold t :underline t)) |
| 526 | (t (:background "gray20" :foreground "violet"))) | 532 | (t (:background "gray20" :foreground "violet"))) |
| 527 | "Face used to visualize \"long\" lines. | 533 | "Face used to visualize \"long\" lines. |
| 528 | 534 | ||
| 529 | See `blank-line-column'." | 535 | See `whitespace-line-column'." |
| 530 | :group 'blank) | 536 | :group 'whitespace) |
| 531 | 537 | ||
| 532 | 538 | ||
| 533 | (defcustom blank-space-before-tab 'blank-space-before-tab | 539 | (defcustom whitespace-space-before-tab 'whitespace-space-before-tab |
| 534 | "*Symbol face used to visualize SPACEs before TAB. | 540 | "*Symbol face used to visualize SPACEs before TAB. |
| 535 | 541 | ||
| 536 | Used when `blank-style' has `color' as an element." | 542 | Used when `whitespace-style' has `color' as an element." |
| 537 | :type 'face | 543 | :type 'face |
| 538 | :group 'blank) | 544 | :group 'whitespace) |
| 539 | 545 | ||
| 540 | 546 | ||
| 541 | (defface blank-space-before-tab | 547 | (defface whitespace-space-before-tab |
| 542 | '((((class mono)) (:inverse-video t :bold t :underline t)) | 548 | '((((class mono)) (:inverse-video t :bold t :underline t)) |
| 543 | (t (:background "DarkOrange" :foreground "firebrick"))) | 549 | (t (:background "DarkOrange" :foreground "firebrick"))) |
| 544 | "Face used to visualize SPACEs before TAB." | 550 | "Face used to visualize SPACEs before TAB." |
| 545 | :group 'blank) | 551 | :group 'whitespace) |
| 546 | 552 | ||
| 547 | 553 | ||
| 548 | (defcustom blank-indentation 'blank-indentation | 554 | (defcustom whitespace-indentation 'whitespace-indentation |
| 549 | "*Symbol face used to visualize 8 or more SPACEs at beginning of line. | 555 | "*Symbol face used to visualize 8 or more SPACEs at beginning of line. |
| 550 | 556 | ||
| 551 | Used when `blank-style' has `color' as an element." | 557 | Used when `whitespace-style' has `color' as an element." |
| 552 | :type 'face | 558 | :type 'face |
| 553 | :group 'blank) | 559 | :group 'whitespace) |
| 554 | 560 | ||
| 555 | 561 | ||
| 556 | (defface blank-indentation | 562 | (defface whitespace-indentation |
| 557 | '((((class mono)) (:inverse-video t :bold t :underline t)) | 563 | '((((class mono)) (:inverse-video t :bold t :underline t)) |
| 558 | (t (:background "yellow" :foreground "firebrick"))) | 564 | (t (:background "yellow" :foreground "firebrick"))) |
| 559 | "Face used to visualize 8 or more SPACEs at beginning of line." | 565 | "Face used to visualize 8 or more SPACEs at beginning of line." |
| 560 | :group 'blank) | 566 | :group 'whitespace) |
| 561 | 567 | ||
| 562 | 568 | ||
| 563 | (defcustom blank-empty 'blank-empty | 569 | (defcustom whitespace-empty 'whitespace-empty |
| 564 | "*Symbol face used to visualize empty lines at beginning and/or end of buffer. | 570 | "*Symbol face used to visualize empty lines at beginning and/or end of buffer. |
| 565 | 571 | ||
| 566 | Used when `blank-style' has `color' as an element." | 572 | Used when `whitespace-style' has `color' as an element." |
| 567 | :type 'face | 573 | :type 'face |
| 568 | :group 'blank) | 574 | :group 'whitespace) |
| 569 | 575 | ||
| 570 | 576 | ||
| 571 | (defface blank-empty | 577 | (defface whitespace-empty |
| 572 | '((((class mono)) (:inverse-video t :bold t :underline t)) | 578 | '((((class mono)) (:inverse-video t :bold t :underline t)) |
| 573 | (t (:background "yellow" :foreground "firebrick"))) | 579 | (t (:background "yellow" :foreground "firebrick"))) |
| 574 | "Face used to visualize empty lines at beginning and/or end of buffer." | 580 | "Face used to visualize empty lines at beginning and/or end of buffer." |
| 575 | :group 'blank) | 581 | :group 'whitespace) |
| 576 | 582 | ||
| 577 | 583 | ||
| 578 | (defcustom blank-space-after-tab 'blank-space-after-tab | 584 | (defcustom whitespace-space-after-tab 'whitespace-space-after-tab |
| 579 | "*Symbol face used to visualize 8 or more SPACEs after TAB. | 585 | "*Symbol face used to visualize 8 or more SPACEs after TAB. |
| 580 | 586 | ||
| 581 | Used when `blank-style' has `color' as an element." | 587 | Used when `whitespace-style' has `color' as an element." |
| 582 | :type 'face | 588 | :type 'face |
| 583 | :group 'blank) | 589 | :group 'whitespace) |
| 584 | 590 | ||
| 585 | 591 | ||
| 586 | (defface blank-space-after-tab | 592 | (defface whitespace-space-after-tab |
| 587 | '((((class mono)) (:inverse-video t :bold t :underline t)) | 593 | '((((class mono)) (:inverse-video t :bold t :underline t)) |
| 588 | (t (:background "yellow" :foreground "firebrick"))) | 594 | (t (:background "yellow" :foreground "firebrick"))) |
| 589 | "Face used to visualize 8 or more SPACEs after TAB." | 595 | "Face used to visualize 8 or more SPACEs after TAB." |
| 590 | :group 'blank) | 596 | :group 'whitespace) |
| 591 | 597 | ||
| 592 | 598 | ||
| 593 | (defcustom blank-hspace-regexp | 599 | (defcustom whitespace-hspace-regexp |
| 594 | "\\(\\(\xA0\\|\x8A0\\|\x920\\|\xE20\\|\xF20\\)+\\)" | 600 | "\\(\\(\xA0\\|\x8A0\\|\x920\\|\xE20\\|\xF20\\)+\\)" |
| 595 | "*Specify HARD SPACE characters regexp. | 601 | "*Specify HARD SPACE characters regexp. |
| 596 | 602 | ||
| @@ -614,13 +620,13 @@ visualize only HARD SPACEs between TABs. | |||
| 614 | NOTE: Enclose always by \\\\( and \\\\) the elements to highlight. | 620 | NOTE: Enclose always by \\\\( and \\\\) the elements to highlight. |
| 615 | Use exactly one pair of enclosing \\\\( and \\\\). | 621 | Use exactly one pair of enclosing \\\\( and \\\\). |
| 616 | 622 | ||
| 617 | Used when `blank-style' has `color' as an element, and | 623 | Used when `whitespace-style' has `color' as an element, and |
| 618 | `blank-chars' has `spaces' as an element." | 624 | `whitespace-chars' has `spaces' as an element." |
| 619 | :type '(regexp :tag "HARD SPACE Chars") | 625 | :type '(regexp :tag "HARD SPACE Chars") |
| 620 | :group 'blank) | 626 | :group 'whitespace) |
| 621 | 627 | ||
| 622 | 628 | ||
| 623 | (defcustom blank-space-regexp "\\( +\\)" | 629 | (defcustom whitespace-space-regexp "\\( +\\)" |
| 624 | "*Specify SPACE characters regexp. | 630 | "*Specify SPACE characters regexp. |
| 625 | 631 | ||
| 626 | If you're using `mule' package, it may exist other characters | 632 | If you're using `mule' package, it may exist other characters |
| @@ -637,13 +643,13 @@ visualize leading and/or trailing SPACEs. | |||
| 637 | NOTE: Enclose always by \\\\( and \\\\) the elements to highlight. | 643 | NOTE: Enclose always by \\\\( and \\\\) the elements to highlight. |
| 638 | Use exactly one pair of enclosing \\\\( and \\\\). | 644 | Use exactly one pair of enclosing \\\\( and \\\\). |
| 639 | 645 | ||
| 640 | Used when `blank-style' has `color' as an element, and | 646 | Used when `whitespace-style' has `color' as an element, and |
| 641 | `blank-chars' has `spaces' as an element." | 647 | `whitespace-chars' has `spaces' as an element." |
| 642 | :type '(regexp :tag "SPACE Chars") | 648 | :type '(regexp :tag "SPACE Chars") |
| 643 | :group 'blank) | 649 | :group 'whitespace) |
| 644 | 650 | ||
| 645 | 651 | ||
| 646 | (defcustom blank-tab-regexp "\\(\t+\\)" | 652 | (defcustom whitespace-tab-regexp "\\(\t+\\)" |
| 647 | "*Specify TAB characters regexp. | 653 | "*Specify TAB characters regexp. |
| 648 | 654 | ||
| 649 | If you're using `mule' package, it may exist other characters | 655 | If you're using `mule' package, it may exist other characters |
| @@ -660,13 +666,13 @@ visualize leading and/or trailing TABs. | |||
| 660 | NOTE: Enclose always by \\\\( and \\\\) the elements to highlight. | 666 | NOTE: Enclose always by \\\\( and \\\\) the elements to highlight. |
| 661 | Use exactly one pair of enclosing \\\\( and \\\\). | 667 | Use exactly one pair of enclosing \\\\( and \\\\). |
| 662 | 668 | ||
| 663 | Used when `blank-style' has `color' as an element, and | 669 | Used when `whitespace-style' has `color' as an element, and |
| 664 | `blank-chars' has `tabs' as an element." | 670 | `whitespace-chars' has `tabs' as an element." |
| 665 | :type '(regexp :tag "TAB Chars") | 671 | :type '(regexp :tag "TAB Chars") |
| 666 | :group 'blank) | 672 | :group 'whitespace) |
| 667 | 673 | ||
| 668 | 674 | ||
| 669 | (defcustom blank-trailing-regexp | 675 | (defcustom whitespace-trailing-regexp |
| 670 | "\t\\| \\|\xA0\\|\x8A0\\|\x920\\|\xE20\\|\xF20" | 676 | "\t\\| \\|\xA0\\|\x8A0\\|\x920\\|\xE20\\|\xF20" |
| 671 | "*Specify trailing characters regexp. | 677 | "*Specify trailing characters regexp. |
| 672 | 678 | ||
| @@ -678,16 +684,16 @@ If you're using `mule' package, it may exist other characters besides: | |||
| 678 | that should be considered blank. | 684 | that should be considered blank. |
| 679 | 685 | ||
| 680 | NOTE: DO NOT enclose by \\\\( and \\\\) the elements to highlight. | 686 | NOTE: DO NOT enclose by \\\\( and \\\\) the elements to highlight. |
| 681 | `blank-mode' surrounds this regexp by \"\\\\(\\\\(\" and | 687 | `whitespace-mode' surrounds this regexp by \"\\\\(\\\\(\" and |
| 682 | \"\\\\)+\\\\)$\". | 688 | \"\\\\)+\\\\)$\". |
| 683 | 689 | ||
| 684 | Used when `blank-style' has `color' as an element, and | 690 | Used when `whitespace-style' has `color' as an element, and |
| 685 | `blank-chars' has `trailing' as an element." | 691 | `whitespace-chars' has `trailing' as an element." |
| 686 | :type '(regexp :tag "Trailing Chars") | 692 | :type '(regexp :tag "Trailing Chars") |
| 687 | :group 'blank) | 693 | :group 'whitespace) |
| 688 | 694 | ||
| 689 | 695 | ||
| 690 | (defcustom blank-space-before-tab-regexp "\\( +\\)\t" | 696 | (defcustom whitespace-space-before-tab-regexp "\\( +\\)\t" |
| 691 | "*Specify SPACEs before TAB regexp. | 697 | "*Specify SPACEs before TAB regexp. |
| 692 | 698 | ||
| 693 | If you're using `mule' package, it may exist other characters besides: | 699 | 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: | |||
| 697 | 703 | ||
| 698 | that should be considered blank. | 704 | that should be considered blank. |
| 699 | 705 | ||
| 700 | Used when `blank-style' has `color' as an element, and | 706 | Used when `whitespace-style' has `color' as an element, and |
| 701 | `blank-chars' has `space-before-tab' as an element." | 707 | `whitespace-chars' has `space-before-tab' as an element." |
| 702 | :type '(regexp :tag "SPACEs Before TAB") | 708 | :type '(regexp :tag "SPACEs Before TAB") |
| 703 | :group 'blank) | 709 | :group 'whitespace) |
| 704 | 710 | ||
| 705 | 711 | ||
| 706 | (defcustom blank-indentation-regexp "^\t*\\(\\( \\{8\\}\\)+\\)[^\n\t]" | 712 | (defcustom whitespace-indentation-regexp |
| 713 | "^\t*\\(\\( \\{8\\}\\)+\\)[^\n\t]" | ||
| 707 | "*Specify regexp for 8 or more SPACEs at beginning of line. | 714 | "*Specify regexp for 8 or more SPACEs at beginning of line. |
| 708 | 715 | ||
| 709 | If you're using `mule' package, it may exist other characters besides: | 716 | 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: | |||
| 713 | 720 | ||
| 714 | that should be considered blank. | 721 | that should be considered blank. |
| 715 | 722 | ||
| 716 | Used when `blank-style' has `color' as an element, and | 723 | Used when `whitespace-style' has `color' as an element, and |
| 717 | `blank-chars' has `indentation' as an element." | 724 | `whitespace-chars' has `indentation' as an element." |
| 718 | :type '(regexp :tag "Indentation SPACEs") | 725 | :type '(regexp :tag "Indentation SPACEs") |
| 719 | :group 'blank) | 726 | :group 'whitespace) |
| 720 | 727 | ||
| 721 | 728 | ||
| 722 | (defcustom blank-empty-at-bob-regexp "\\`\\(\\([ \t]*\n\\)+\\)" | 729 | (defcustom whitespace-empty-at-bob-regexp "\\`\\(\\([ \t]*\n\\)+\\)" |
| 723 | "*Specify regexp for empty lines at beginning of buffer. | 730 | "*Specify regexp for empty lines at beginning of buffer. |
| 724 | 731 | ||
| 725 | If you're using `mule' package, it may exist other characters besides: | 732 | 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: | |||
| 729 | 736 | ||
| 730 | that should be considered blank. | 737 | that should be considered blank. |
| 731 | 738 | ||
| 732 | Used when `blank-style' has `color' as an element, and | 739 | Used when `whitespace-style' has `color' as an element, and |
| 733 | `blank-chars' has `empty' as an element." | 740 | `whitespace-chars' has `empty' as an element." |
| 734 | :type '(regexp :tag "Empty Lines At Beginning Of Buffer") | 741 | :type '(regexp :tag "Empty Lines At Beginning Of Buffer") |
| 735 | :group 'blank) | 742 | :group 'whitespace) |
| 736 | 743 | ||
| 737 | 744 | ||
| 738 | (defcustom blank-empty-at-eob-regexp "^\\([ \t\n]+\\)\\'" | 745 | (defcustom whitespace-empty-at-eob-regexp "^\\([ \t\n]+\\)\\'" |
| 739 | "*Specify regexp for empty lines at end of buffer. | 746 | "*Specify regexp for empty lines at end of buffer. |
| 740 | 747 | ||
| 741 | If you're using `mule' package, it may exist other characters besides: | 748 | 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: | |||
| 745 | 752 | ||
| 746 | that should be considered blank. | 753 | that should be considered blank. |
| 747 | 754 | ||
| 748 | Used when `blank-style' has `color' as an element, and | 755 | Used when `whitespace-style' has `color' as an element, and |
| 749 | `blank-chars' has `empty' as an element." | 756 | `whitespace-chars' has `empty' as an element." |
| 750 | :type '(regexp :tag "Empty Lines At End Of Buffer") | 757 | :type '(regexp :tag "Empty Lines At End Of Buffer") |
| 751 | :group 'blank) | 758 | :group 'whitespace) |
| 752 | 759 | ||
| 753 | 760 | ||
| 754 | (defcustom blank-space-after-tab-regexp "\t\\(\\( \\{8\\}\\)+\\)" | 761 | (defcustom whitespace-space-after-tab-regexp "\t\\(\\( \\{8\\}\\)+\\)" |
| 755 | "*Specify regexp for 8 or more SPACEs after TAB. | 762 | "*Specify regexp for 8 or more SPACEs after TAB. |
| 756 | 763 | ||
| 757 | If you're using `mule' package, it may exist other characters besides: | 764 | 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: | |||
| 761 | 768 | ||
| 762 | that should be considered blank. | 769 | that should be considered blank. |
| 763 | 770 | ||
| 764 | Used when `blank-style' has `color' as an element, and | 771 | Used when `whitespace-style' has `color' as an element, and |
| 765 | `blank-chars' has `space-after-tab' as an element." | 772 | `whitespace-chars' has `space-after-tab' as an element." |
| 766 | :type '(regexp :tag "SPACEs After TAB") | 773 | :type '(regexp :tag "SPACEs After TAB") |
| 767 | :group 'blank) | 774 | :group 'whitespace) |
| 768 | 775 | ||
| 769 | 776 | ||
| 770 | (defcustom blank-line-column 80 | 777 | (defcustom whitespace-line-column 80 |
| 771 | "*Specify column beyond which the line is highlighted. | 778 | "*Specify column beyond which the line is highlighted. |
| 772 | 779 | ||
| 773 | Used when `blank-style' has `color' as an element, and | 780 | Used when `whitespace-style' has `color' as an element, and |
| 774 | `blank-chars' has `lines' or `lines-tail' as an element." | 781 | `whitespace-chars' has `lines' or `lines-tail' as an element." |
| 775 | :type '(integer :tag "Line Length") | 782 | :type '(integer :tag "Line Length") |
| 776 | :group 'blank) | 783 | :group 'whitespace) |
| 777 | 784 | ||
| 778 | 785 | ||
| 779 | ;; Hacked from `visible-whitespace-mappings' in visws.el | 786 | ;; Hacked from `visible-whitespace-mappings' in visws.el |
| 780 | (defcustom blank-display-mappings | 787 | (defcustom whitespace-display-mappings |
| 781 | ;; Due to limitations of glyph representation, the char code can not | 788 | ;; Due to limitations of glyph representation, the char code can not |
| 782 | ;; be above ?\x1FFFF. Probably, this will be fixed after Emacs | 789 | ;; be above ?\x1FFFF. Probably, this will be fixed after Emacs |
| 783 | ;; unicode merging. | 790 | ;; unicode merging. |
| @@ -788,7 +795,7 @@ Used when `blank-style' has `color' as an element, and | |||
| 788 | (?\x920 [?\x924] [?_]) ; hard space - currency | 795 | (?\x920 [?\x924] [?_]) ; hard space - currency |
| 789 | (?\xE20 [?\xE24] [?_]) ; hard space - currency | 796 | (?\xE20 [?\xE24] [?_]) ; hard space - currency |
| 790 | (?\xF20 [?\xF24] [?_]) ; hard space - currency | 797 | (?\xF20 [?\xF24] [?_]) ; hard space - currency |
| 791 | ;; NEWLINE is displayed using the face `blank-newline' | 798 | ;; NEWLINE is displayed using the face `whitespace-newline' |
| 792 | (?\n [?$ ?\n]) ; end-of-line - dollar sign | 799 | (?\n [?$ ?\n]) ; end-of-line - dollar sign |
| 793 | ;; (?\n [?\u21B5 ?\n] [?$ ?\n]) ; end-of-line - downwards arrow | 800 | ;; (?\n [?\u21B5 ?\n] [?$ ?\n]) ; end-of-line - downwards arrow |
| 794 | ;; (?\n [?\xB6 ?\n] [?$ ?\n]) ; end-of-line - pilcrow | 801 | ;; (?\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. | |||
| 819 | that character is displayed unmodified. | 826 | that character is displayed unmodified. |
| 820 | 827 | ||
| 821 | The NEWLINE character is displayed using the face given by | 828 | The NEWLINE character is displayed using the face given by |
| 822 | `blank-newline' variable. The characters in the vector to be | 829 | `whitespace-newline' variable. The characters in the vector to |
| 823 | displayed will not have this face applied if the character code | 830 | be displayed will not have this face applied if the character |
| 824 | is above #x1FFFF. | 831 | code is above #x1FFFF. |
| 825 | 832 | ||
| 826 | Used when `blank-style' has `mark' as an element." | 833 | Used when `whitespace-style' has `mark' as an element." |
| 827 | :type '(repeat | 834 | :type '(repeat |
| 828 | (list :tag "Character Mapping" | 835 | (list :tag "Character Mapping" |
| 829 | (character :tag "Char") | 836 | (character :tag "Char") |
| @@ -832,25 +839,29 @@ Used when `blank-style' has `mark' as an element." | |||
| 832 | (repeat :inline t | 839 | (repeat :inline t |
| 833 | :tag "Vector Characters" | 840 | :tag "Vector Characters" |
| 834 | (character :tag "Char")))))) | 841 | (character :tag "Char")))))) |
| 835 | :group 'blank) | 842 | :group 'whitespace) |
| 836 | 843 | ||
| 837 | 844 | ||
| 838 | (defcustom blank-global-modes t | 845 | (defcustom whitespace-global-modes t |
| 839 | "*Modes for which global `blank-mode' is automagically turned on. | 846 | "*Modes for which global `whitespace-mode' is automagically turned on. |
| 840 | 847 | ||
| 841 | Global `blank-mode' is controlled by the command `global-blank-mode'. | 848 | Global `whitespace-mode' is controlled by the command |
| 849 | `global-whitespace-mode'. | ||
| 842 | 850 | ||
| 843 | If nil, means no modes have `blank-mode' automatically turned on. | 851 | If nil, means no modes have `whitespace-mode' automatically |
| 844 | If t, all modes that support `blank-mode' have it automatically | ||
| 845 | turned on. | 852 | turned on. |
| 846 | Else it should be a list of `major-mode' symbol names for | 853 | |
| 847 | which `blank-mode' should be automatically turned on. The sense | 854 | If t, all modes that support `whitespace-mode' have it |
| 855 | automatically turned on. | ||
| 856 | |||
| 857 | Else it should be a list of `major-mode' symbol names for which | ||
| 858 | `whitespace-mode' should be automatically turned on. The sense | ||
| 848 | of the list is negated if it begins with `not'. For example: | 859 | of the list is negated if it begins with `not'. For example: |
| 849 | 860 | ||
| 850 | (c-mode c++-mode) | 861 | (c-mode c++-mode) |
| 851 | 862 | ||
| 852 | means that `blank-mode' is turned on for buffers in C and C++ | 863 | means that `whitespace-mode' is turned on for buffers in C and |
| 853 | modes only." | 864 | C++ modes only." |
| 854 | :type '(choice (const :tag "None" nil) | 865 | :type '(choice (const :tag "None" nil) |
| 855 | (const :tag "All" t) | 866 | (const :tag "All" t) |
| 856 | (set :menu-tag "Mode Specific" :tag "Modes" | 867 | (set :menu-tag "Mode Specific" :tag "Modes" |
| @@ -858,7 +869,7 @@ modes only." | |||
| 858 | (const :tag "Except" not) | 869 | (const :tag "Except" not) |
| 859 | (repeat :inline t | 870 | (repeat :inline t |
| 860 | (symbol :tag "Mode")))) | 871 | (symbol :tag "Mode")))) |
| 861 | :group 'blank) | 872 | :group 'whitespace) |
| 862 | 873 | ||
| 863 | 874 | ||
| 864 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 875 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| @@ -866,74 +877,74 @@ modes only." | |||
| 866 | 877 | ||
| 867 | 878 | ||
| 868 | ;;;###autoload | 879 | ;;;###autoload |
| 869 | (define-minor-mode blank-mode | 880 | (define-minor-mode whitespace-mode |
| 870 | "Toggle blank minor mode visualization (\"bl\" on modeline). | 881 | "Toggle whitespace minor mode visualization (\"ws\" on modeline). |
| 871 | 882 | ||
| 872 | If ARG is null, toggle blank visualization. | 883 | If ARG is null, toggle whitespace visualization. |
| 873 | If ARG is a number greater than zero, turn on visualization; | 884 | If ARG is a number greater than zero, turn on visualization; |
| 874 | otherwise, turn off visualization. | 885 | otherwise, turn off visualization. |
| 875 | Only useful with a windowing system." | 886 | Only useful with a windowing system." |
| 876 | :lighter " bl" | 887 | :lighter " ws" |
| 877 | :init-value nil | 888 | :init-value nil |
| 878 | :global nil | 889 | :global nil |
| 879 | :group 'blank | 890 | :group 'whitespace |
| 880 | (cond | 891 | (cond |
| 881 | (noninteractive ; running a batch job | 892 | (noninteractive ; running a batch job |
| 882 | (setq blank-mode nil)) | 893 | (setq whitespace-mode nil)) |
| 883 | (blank-mode ; blank-mode on | 894 | (whitespace-mode ; whitespace-mode on |
| 884 | (blank-turn-on)) | 895 | (whitespace-turn-on)) |
| 885 | (t ; blank-mode off | 896 | (t ; whitespace-mode off |
| 886 | (blank-turn-off)))) | 897 | (whitespace-turn-off)))) |
| 887 | 898 | ||
| 888 | 899 | ||
| 889 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 900 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 890 | ;;;; User commands - Global mode | 901 | ;;;; User commands - Global mode |
| 891 | 902 | ||
| 892 | 903 | ||
| 893 | (define-minor-mode global-blank-mode | 904 | (define-minor-mode global-whitespace-mode |
| 894 | "Toggle blank global minor mode visualization (\"BL\" on modeline). | 905 | "Toggle whitespace global minor mode visualization (\"WS\" on modeline). |
| 895 | 906 | ||
| 896 | If ARG is null, toggle blank visualization. | 907 | If ARG is null, toggle whitespace visualization. |
| 897 | If ARG is a number greater than zero, turn on visualization; | 908 | If ARG is a number greater than zero, turn on visualization; |
| 898 | otherwise, turn off visualization. | 909 | otherwise, turn off visualization. |
| 899 | Only useful with a windowing system." | 910 | Only useful with a windowing system." |
| 900 | :lighter " BL" | 911 | :lighter " BL" |
| 901 | :init-value nil | 912 | :init-value nil |
| 902 | :global t | 913 | :global t |
| 903 | :group 'blank | 914 | :group 'whitespace |
| 904 | (cond | 915 | (cond |
| 905 | (noninteractive ; running a batch job | 916 | (noninteractive ; running a batch job |
| 906 | (setq global-blank-mode nil)) | 917 | (setq global-whitespace-mode nil)) |
| 907 | (global-blank-mode ; global-blank-mode on | 918 | (global-whitespace-mode ; global-whitespace-mode on |
| 908 | (save-excursion | 919 | (save-excursion |
| 909 | (if (boundp 'find-file-hook) | 920 | (if (boundp 'find-file-hook) |
| 910 | (add-hook 'find-file-hook 'blank-turn-on-if-enabled t) | 921 | (add-hook 'find-file-hook 'whitespace-turn-on-if-enabled t) |
| 911 | (add-hook 'find-file-hooks 'blank-turn-on-if-enabled t)) | 922 | (add-hook 'find-file-hooks 'whitespace-turn-on-if-enabled t)) |
| 912 | (dolist (buffer (buffer-list)) ; adjust all local mode | 923 | (dolist (buffer (buffer-list)) ; adjust all local mode |
| 913 | (set-buffer buffer) | 924 | (set-buffer buffer) |
| 914 | (unless blank-mode | 925 | (unless whitespace-mode |
| 915 | (blank-turn-on-if-enabled))))) | 926 | (whitespace-turn-on-if-enabled))))) |
| 916 | (t ; global-blank-mode off | 927 | (t ; global-whitespace-mode off |
| 917 | (save-excursion | 928 | (save-excursion |
| 918 | (if (boundp 'find-file-hook) | 929 | (if (boundp 'find-file-hook) |
| 919 | (remove-hook 'find-file-hook 'blank-turn-on-if-enabled) | 930 | (remove-hook 'find-file-hook 'whitespace-turn-on-if-enabled) |
| 920 | (remove-hook 'find-file-hooks 'blank-turn-on-if-enabled)) | 931 | (remove-hook 'find-file-hooks 'whitespace-turn-on-if-enabled)) |
| 921 | (dolist (buffer (buffer-list)) ; adjust all local mode | 932 | (dolist (buffer (buffer-list)) ; adjust all local mode |
| 922 | (set-buffer buffer) | 933 | (set-buffer buffer) |
| 923 | (unless blank-mode | 934 | (unless whitespace-mode |
| 924 | (blank-turn-off))))))) | 935 | (whitespace-turn-off))))))) |
| 925 | 936 | ||
| 926 | 937 | ||
| 927 | (defun blank-turn-on-if-enabled () | 938 | (defun whitespace-turn-on-if-enabled () |
| 928 | (when (cond | 939 | (when (cond |
| 929 | ((eq blank-global-modes t)) | 940 | ((eq whitespace-global-modes t)) |
| 930 | ((listp blank-global-modes) | 941 | ((listp whitespace-global-modes) |
| 931 | (if (eq (car-safe blank-global-modes) 'not) | 942 | (if (eq (car-safe whitespace-global-modes) 'not) |
| 932 | (not (memq major-mode (cdr blank-global-modes))) | 943 | (not (memq major-mode (cdr whitespace-global-modes))) |
| 933 | (memq major-mode blank-global-modes))) | 944 | (memq major-mode whitespace-global-modes))) |
| 934 | (t nil)) | 945 | (t nil)) |
| 935 | (let (inhibit-quit) | 946 | (let (inhibit-quit) |
| 936 | ;; Don't turn on blank mode if... | 947 | ;; Don't turn on whitespace mode if... |
| 937 | (or | 948 | (or |
| 938 | ;; ...we don't have a display (we're running a batch job) | 949 | ;; ...we don't have a display (we're running a batch job) |
| 939 | noninteractive | 950 | noninteractive |
| @@ -943,15 +954,15 @@ Only useful with a windowing system." | |||
| 943 | (and (eq (aref (buffer-name) 0) ?*) | 954 | (and (eq (aref (buffer-name) 0) ?*) |
| 944 | ;; except the scratch buffer. | 955 | ;; except the scratch buffer. |
| 945 | (not (string= (buffer-name) "*scratch*"))) | 956 | (not (string= (buffer-name) "*scratch*"))) |
| 946 | ;; Otherwise, turn on blank mode. | 957 | ;; Otherwise, turn on whitespace mode. |
| 947 | (blank-turn-on))))) | 958 | (whitespace-turn-on))))) |
| 948 | 959 | ||
| 949 | 960 | ||
| 950 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 961 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 951 | ;;;; User commands - Toggle | 962 | ;;;; User commands - Toggle |
| 952 | 963 | ||
| 953 | 964 | ||
| 954 | (defconst blank-chars-value-list | 965 | (defconst whitespace-chars-value-list |
| 955 | '(tabs | 966 | '(tabs |
| 956 | spaces | 967 | spaces |
| 957 | trailing | 968 | trailing |
| @@ -963,17 +974,17 @@ Only useful with a windowing system." | |||
| 963 | empty | 974 | empty |
| 964 | space-after-tab | 975 | space-after-tab |
| 965 | ) | 976 | ) |
| 966 | "List of valid `blank-chars' values.") | 977 | "List of valid `whitespace-chars' values.") |
| 967 | 978 | ||
| 968 | 979 | ||
| 969 | (defconst blank-style-value-list | 980 | (defconst whitespace-style-value-list |
| 970 | '(color | 981 | '(color |
| 971 | mark | 982 | mark |
| 972 | ) | 983 | ) |
| 973 | "List of valid `blank-style' values.") | 984 | "List of valid `whitespace-style' values.") |
| 974 | 985 | ||
| 975 | 986 | ||
| 976 | (defconst blank-toggle-option-alist | 987 | (defconst whitespace-toggle-option-alist |
| 977 | '((?t . tabs) | 988 | '((?t . tabs) |
| 978 | (?s . spaces) | 989 | (?s . spaces) |
| 979 | (?r . trailing) | 990 | (?r . trailing) |
| @@ -986,8 +997,8 @@ Only useful with a windowing system." | |||
| 986 | (?a . space-after-tab) | 997 | (?a . space-after-tab) |
| 987 | (?c . color) | 998 | (?c . color) |
| 988 | (?m . mark) | 999 | (?m . mark) |
| 989 | (?x . blank-chars) | 1000 | (?x . whitespace-chars) |
| 990 | (?z . blank-style) | 1001 | (?z . whitespace-style) |
| 991 | ) | 1002 | ) |
| 992 | "Alist of toggle options. | 1003 | "Alist of toggle options. |
| 993 | 1004 | ||
| @@ -1000,27 +1011,28 @@ Where: | |||
| 1000 | CHAR is a char which the user will have to type. | 1011 | CHAR is a char which the user will have to type. |
| 1001 | 1012 | ||
| 1002 | SYMBOL is a valid symbol associated with CHAR. | 1013 | SYMBOL is a valid symbol associated with CHAR. |
| 1003 | See `blank-chars-value-list' and `blank-style-value-list'.") | 1014 | See `whitespace-chars-value-list' and |
| 1015 | `whitespace-style-value-list'.") | ||
| 1004 | 1016 | ||
| 1005 | 1017 | ||
| 1006 | (defvar blank-active-chars nil | 1018 | (defvar whitespace-active-chars nil |
| 1007 | "Used to save locally `blank-chars' value.") | 1019 | "Used to save locally `whitespace-chars' value.") |
| 1008 | (make-variable-buffer-local 'blank-active-chars) | 1020 | (make-variable-buffer-local 'whitespace-active-chars) |
| 1009 | 1021 | ||
| 1010 | (defvar blank-active-style nil | 1022 | (defvar whitespace-active-style nil |
| 1011 | "Used to save locally `blank-style' value.") | 1023 | "Used to save locally `whitespace-style' value.") |
| 1012 | (make-variable-buffer-local 'blank-active-style) | 1024 | (make-variable-buffer-local 'whitespace-active-style) |
| 1013 | 1025 | ||
| 1014 | 1026 | ||
| 1015 | ;;;###autoload | 1027 | ;;;###autoload |
| 1016 | (defun blank-toggle-options (arg) | 1028 | (defun whitespace-toggle-options (arg) |
| 1017 | "Toggle local `blank-mode' options. | 1029 | "Toggle local `whitespace-mode' options. |
| 1018 | 1030 | ||
| 1019 | If local blank-mode is off, toggle the option given by ARG and | 1031 | If local whitespace-mode is off, toggle the option given by ARG |
| 1020 | turn on local blank-mode. | 1032 | and turn on local whitespace-mode. |
| 1021 | 1033 | ||
| 1022 | If local blank-mode is on, toggle the option given by ARG and | 1034 | If local whitespace-mode is on, toggle the option given by ARG |
| 1023 | restart local blank-mode. | 1035 | and restart local whitespace-mode. |
| 1024 | 1036 | ||
| 1025 | Interactively, it reads one of the following chars: | 1037 | Interactively, it reads one of the following chars: |
| 1026 | 1038 | ||
| @@ -1037,8 +1049,8 @@ Interactively, it reads one of the following chars: | |||
| 1037 | a toggle SPACEs after TAB visualization | 1049 | a toggle SPACEs after TAB visualization |
| 1038 | c toggle color faces | 1050 | c toggle color faces |
| 1039 | m toggle visual mark | 1051 | m toggle visual mark |
| 1040 | x restore `blank-chars' value | 1052 | x restore `whitespace-chars' value |
| 1041 | z restore `blank-style' value | 1053 | z restore `whitespace-style' value |
| 1042 | ? display brief help | 1054 | ? display brief help |
| 1043 | 1055 | ||
| 1044 | Non-interactively, ARG should be a symbol or a list of symbols. | 1056 | Non-interactively, ARG should be a symbol or a list of symbols. |
| @@ -1056,36 +1068,38 @@ The valid symbols are: | |||
| 1056 | space-after-tab toggle SPACEs after TAB visualization | 1068 | space-after-tab toggle SPACEs after TAB visualization |
| 1057 | color toggle color faces | 1069 | color toggle color faces |
| 1058 | mark toggle visual mark | 1070 | mark toggle visual mark |
| 1059 | blank-chars restore `blank-chars' value | 1071 | whitespace-chars restore `whitespace-chars' value |
| 1060 | blank-style restore `blank-style' value | 1072 | whitespace-style restore `whitespace-style' value |
| 1061 | 1073 | ||
| 1062 | Only useful with a windowing system." | 1074 | Only useful with a windowing system." |
| 1063 | (interactive (blank-interactive-char t)) | 1075 | (interactive (whitespace-interactive-char t)) |
| 1064 | (let ((blank-chars | 1076 | (let ((whitespace-chars |
| 1065 | (blank-toggle-list t arg blank-active-chars blank-chars | 1077 | (whitespace-toggle-list |
| 1066 | 'blank-chars blank-chars-value-list)) | 1078 | t arg whitespace-active-chars whitespace-chars |
| 1067 | (blank-style | 1079 | 'whitespace-chars whitespace-chars-value-list)) |
| 1068 | (blank-toggle-list t arg blank-active-style blank-style | 1080 | (whitespace-style |
| 1069 | 'blank-style blank-style-value-list))) | 1081 | (whitespace-toggle-list |
| 1070 | (blank-mode 0) | 1082 | t arg whitespace-active-style whitespace-style |
| 1071 | (blank-mode 1))) | 1083 | 'whitespace-style whitespace-style-value-list))) |
| 1084 | (whitespace-mode 0) | ||
| 1085 | (whitespace-mode 1))) | ||
| 1072 | 1086 | ||
| 1073 | 1087 | ||
| 1074 | (defvar blank-toggle-chars nil | 1088 | (defvar whitespace-toggle-chars nil |
| 1075 | "Used to toggle the global `blank-chars' value.") | 1089 | "Used to toggle the global `whitespace-chars' value.") |
| 1076 | (defvar blank-toggle-style nil | 1090 | (defvar whitespace-toggle-style nil |
| 1077 | "Used to toggle the global `blank-style' value.") | 1091 | "Used to toggle the global `whitespace-style' value.") |
| 1078 | 1092 | ||
| 1079 | 1093 | ||
| 1080 | ;;;###autoload | 1094 | ;;;###autoload |
| 1081 | (defun global-blank-toggle-options (arg) | 1095 | (defun global-whitespace-toggle-options (arg) |
| 1082 | "Toggle global `blank-mode' options. | 1096 | "Toggle global `whitespace-mode' options. |
| 1083 | 1097 | ||
| 1084 | If global blank-mode is off, toggle the option given by ARG and | 1098 | If global whitespace-mode is off, toggle the option given by ARG |
| 1085 | turn on global blank-mode. | 1099 | and turn on global whitespace-mode. |
| 1086 | 1100 | ||
| 1087 | If global blank-mode is on, toggle the option given by ARG and | 1101 | If global whitespace-mode is on, toggle the option given by ARG |
| 1088 | restart global blank-mode. | 1102 | and restart global whitespace-mode. |
| 1089 | 1103 | ||
| 1090 | Interactively, it reads one of the following chars: | 1104 | Interactively, it reads one of the following chars: |
| 1091 | 1105 | ||
| @@ -1102,8 +1116,8 @@ Interactively, it reads one of the following chars: | |||
| 1102 | a toggle SPACEs after TAB visualization | 1116 | a toggle SPACEs after TAB visualization |
| 1103 | c toggle color faces | 1117 | c toggle color faces |
| 1104 | m toggle visual mark | 1118 | m toggle visual mark |
| 1105 | x restore `blank-chars' value | 1119 | x restore `whitespace-chars' value |
| 1106 | z restore `blank-style' value | 1120 | z restore `whitespace-style' value |
| 1107 | ? display brief help | 1121 | ? display brief help |
| 1108 | 1122 | ||
| 1109 | Non-interactively, ARG should be a symbol or a list of symbols. | 1123 | Non-interactively, ARG should be a symbol or a list of symbols. |
| @@ -1121,21 +1135,23 @@ The valid symbols are: | |||
| 1121 | space-after-tab toggle SPACEs after TAB visualization | 1135 | space-after-tab toggle SPACEs after TAB visualization |
| 1122 | color toggle color faces | 1136 | color toggle color faces |
| 1123 | mark toggle visual mark | 1137 | mark toggle visual mark |
| 1124 | blank-chars restore `blank-chars' value | 1138 | whitespace-chars restore `whitespace-chars' value |
| 1125 | blank-style restore `blank-style' value | 1139 | whitespace-style restore `whitespace-style' value |
| 1126 | 1140 | ||
| 1127 | Only useful with a windowing system." | 1141 | Only useful with a windowing system." |
| 1128 | (interactive (blank-interactive-char nil)) | 1142 | (interactive (whitespace-interactive-char nil)) |
| 1129 | (let ((blank-chars | 1143 | (let ((whitespace-chars |
| 1130 | (blank-toggle-list nil arg blank-toggle-chars blank-chars | 1144 | (whitespace-toggle-list |
| 1131 | 'blank-chars blank-chars-value-list)) | 1145 | nil arg whitespace-toggle-chars whitespace-chars |
| 1132 | (blank-style | 1146 | 'whitespace-chars whitespace-chars-value-list)) |
| 1133 | (blank-toggle-list nil arg blank-toggle-style blank-style | 1147 | (whitespace-style |
| 1134 | 'blank-style blank-style-value-list))) | 1148 | (whitespace-toggle-list |
| 1135 | (setq blank-toggle-chars blank-chars | 1149 | nil arg whitespace-toggle-style whitespace-style |
| 1136 | blank-toggle-style blank-style) | 1150 | 'whitespace-style whitespace-style-value-list))) |
| 1137 | (global-blank-mode 0) | 1151 | (setq whitespace-toggle-chars whitespace-chars |
| 1138 | (global-blank-mode 1))) | 1152 | whitespace-toggle-style whitespace-style) |
| 1153 | (global-whitespace-mode 0) | ||
| 1154 | (global-whitespace-mode 1))) | ||
| 1139 | 1155 | ||
| 1140 | 1156 | ||
| 1141 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 1157 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| @@ -1143,39 +1159,39 @@ Only useful with a windowing system." | |||
| 1143 | 1159 | ||
| 1144 | 1160 | ||
| 1145 | ;;;###autoload | 1161 | ;;;###autoload |
| 1146 | (defun blank-cleanup () | 1162 | (defun whitespace-cleanup () |
| 1147 | "Cleanup some blank problems in all buffer or at region. | 1163 | "Cleanup some blank problems in all buffer or at region. |
| 1148 | 1164 | ||
| 1149 | It usually applies to the whole buffer, but in transient mark | 1165 | It usually applies to the whole buffer, but in transient mark |
| 1150 | mode when the mark is active, it applies to the region. It also | 1166 | mode when the mark is active, it applies to the region. It also |
| 1151 | applies to the region when it is not in transiente mark mode, the | 1167 | applies to the region when it is not in transiente mark mode, the |
| 1152 | mark is active and it was pressed `C-u' just before calling | 1168 | mark is active and it was pressed `C-u' just before calling |
| 1153 | `blank-cleanup' interactively. | 1169 | `whitespace-cleanup' interactively. |
| 1154 | 1170 | ||
| 1155 | See also `blank-cleanup-region'. | 1171 | See also `whitespace-cleanup-region'. |
| 1156 | 1172 | ||
| 1157 | The problems, which are cleaned up, are: | 1173 | The problems, which are cleaned up, are: |
| 1158 | 1174 | ||
| 1159 | 1. empty lines at beginning of buffer. | 1175 | 1. empty lines at beginning of buffer. |
| 1160 | 2. empty lines at end of buffer. | 1176 | 2. empty lines at end of buffer. |
| 1161 | If `blank-chars' has `empty' as an element, remove all empty | 1177 | If `whitespace-chars' has `empty' as an element, remove all |
| 1162 | lines at beginning and/or end of buffer. | 1178 | empty lines at beginning and/or end of buffer. |
| 1163 | 1179 | ||
| 1164 | 3. 8 or more SPACEs at beginning of line. | 1180 | 3. 8 or more SPACEs at beginning of line. |
| 1165 | If `blank-chars' has `indentation' as an element, replace 8 or | 1181 | If `whitespace-chars' has `indentation' as an element, replace |
| 1166 | more SPACEs at beginning of line by TABs. | 1182 | 8 or more SPACEs at beginning of line by TABs. |
| 1167 | 1183 | ||
| 1168 | 4. SPACEs before TAB. | 1184 | 4. SPACEs before TAB. |
| 1169 | If `blank-chars' has `space-before-tab' as an element, replace | 1185 | If `whitespace-chars' has `space-before-tab' as an element, |
| 1170 | SPACEs by TABs. | 1186 | replace SPACEs by TABs. |
| 1171 | 1187 | ||
| 1172 | 5. SPACEs or TABs at end of line. | 1188 | 5. SPACEs or TABs at end of line. |
| 1173 | If `blank-chars' has `trailing' as an element, remove all | 1189 | If `whitespace-chars' has `trailing' as an element, remove all |
| 1174 | SPACEs or TABs at end of line. | 1190 | SPACEs or TABs at end of line. |
| 1175 | 1191 | ||
| 1176 | 6. 8 or more SPACEs after TAB. | 1192 | 6. 8 or more SPACEs after TAB. |
| 1177 | If `blank-chars' has `space-after-tab' as an element, replace | 1193 | If `whitespace-chars' has `space-after-tab' as an element, |
| 1178 | SPACEs by TABs." | 1194 | replace SPACEs by TABs." |
| 1179 | (interactive "@*") | 1195 | (interactive "@*") |
| 1180 | (if (and (or transient-mark-mode | 1196 | (if (and (or transient-mark-mode |
| 1181 | current-prefix-arg) | 1197 | current-prefix-arg) |
| @@ -1186,48 +1202,50 @@ The problems, which are cleaned up, are: | |||
| 1186 | ;; problem 4: SPACEs before TAB | 1202 | ;; problem 4: SPACEs before TAB |
| 1187 | ;; problem 5: SPACEs or TABs at eol | 1203 | ;; problem 5: SPACEs or TABs at eol |
| 1188 | ;; problem 6: 8 or more SPACEs after TAB | 1204 | ;; problem 6: 8 or more SPACEs after TAB |
| 1189 | (blank-cleanup-region (region-beginning) (region-end)) | 1205 | (whitespace-cleanup-region (region-beginning) (region-end)) |
| 1190 | ;; whole buffer | 1206 | ;; whole buffer |
| 1191 | (save-excursion | 1207 | (save-excursion |
| 1192 | (save-match-data | 1208 | (save-match-data |
| 1193 | ;; problem 1: empty lines at bob | 1209 | ;; problem 1: empty lines at bob |
| 1194 | ;; problem 2: empty lines at eob | 1210 | ;; problem 2: empty lines at eob |
| 1195 | ;; action: remove all empty lines at bob and/or eob | 1211 | ;; action: remove all empty lines at bob and/or eob |
| 1196 | (when (memq 'empty blank-chars) | 1212 | (when (memq 'empty whitespace-chars) |
| 1197 | (let (overwrite-mode) ; enforce no overwrite | 1213 | (let (overwrite-mode) ; enforce no overwrite |
| 1198 | (goto-char (point-min)) | 1214 | (goto-char (point-min)) |
| 1199 | (when (re-search-forward blank-empty-at-bob-regexp nil t) | 1215 | (when (re-search-forward |
| 1216 | whitespace-empty-at-bob-regexp nil t) | ||
| 1200 | (delete-region (match-beginning 1) (match-end 1))) | 1217 | (delete-region (match-beginning 1) (match-end 1))) |
| 1201 | (when (re-search-forward blank-empty-at-eob-regexp nil t) | 1218 | (when (re-search-forward |
| 1219 | whitespace-empty-at-eob-regexp nil t) | ||
| 1202 | (delete-region (match-beginning 1) (match-end 1))))))) | 1220 | (delete-region (match-beginning 1) (match-end 1))))))) |
| 1203 | ;; problem 3: 8 or more SPACEs at bol | 1221 | ;; problem 3: 8 or more SPACEs at bol |
| 1204 | ;; problem 4: SPACEs before TAB | 1222 | ;; problem 4: SPACEs before TAB |
| 1205 | ;; problem 5: SPACEs or TABs at eol | 1223 | ;; problem 5: SPACEs or TABs at eol |
| 1206 | ;; problem 6: 8 or more SPACEs after TAB | 1224 | ;; problem 6: 8 or more SPACEs after TAB |
| 1207 | (blank-cleanup-region (point-min) (point-max)))) | 1225 | (whitespace-cleanup-region (point-min) (point-max)))) |
| 1208 | 1226 | ||
| 1209 | 1227 | ||
| 1210 | ;;;###autoload | 1228 | ;;;###autoload |
| 1211 | (defun blank-cleanup-region (start end) | 1229 | (defun whitespace-cleanup-region (start end) |
| 1212 | "Cleanup some blank problems at region. | 1230 | "Cleanup some blank problems at region. |
| 1213 | 1231 | ||
| 1214 | The problems, which are cleaned up, are: | 1232 | The problems, which are cleaned up, are: |
| 1215 | 1233 | ||
| 1216 | 1. 8 or more SPACEs at beginning of line. | 1234 | 1. 8 or more SPACEs at beginning of line. |
| 1217 | If `blank-chars' has `indentation' as an element, replace 8 or | 1235 | If `whitespace-chars' has `indentation' as an element, replace |
| 1218 | more SPACEs at beginning of line by TABs. | 1236 | 8 or more SPACEs at beginning of line by TABs. |
| 1219 | 1237 | ||
| 1220 | 2. SPACEs before TAB. | 1238 | 2. SPACEs before TAB. |
| 1221 | If `blank-chars' has `space-before-tab' as an element, replace | 1239 | If `whitespace-chars' has `space-before-tab' as an element, |
| 1222 | SPACEs by TABs. | 1240 | replace SPACEs by TABs. |
| 1223 | 1241 | ||
| 1224 | 3. SPACEs or TABs at end of line. | 1242 | 3. SPACEs or TABs at end of line. |
| 1225 | If `blank-chars' has `trailing' as an element, remove all | 1243 | If `whitespace-chars' has `trailing' as an element, remove all |
| 1226 | SPACEs or TABs at end of line. | 1244 | SPACEs or TABs at end of line. |
| 1227 | 1245 | ||
| 1228 | 4. 8 or more SPACEs after TAB. | 1246 | 4. 8 or more SPACEs after TAB. |
| 1229 | If `blank-chars' has `space-after-tab' as an element, replace | 1247 | If `whitespace-chars' has `space-after-tab' as an element, |
| 1230 | SPACEs by TABs." | 1248 | replace SPACEs by TABs." |
| 1231 | (interactive "@*r") | 1249 | (interactive "@*r") |
| 1232 | (let ((rstart (min start end)) | 1250 | (let ((rstart (min start end)) |
| 1233 | (rend (copy-marker (max start end))) | 1251 | (rend (copy-marker (max start end))) |
| @@ -1239,35 +1257,36 @@ The problems, which are cleaned up, are: | |||
| 1239 | (save-match-data | 1257 | (save-match-data |
| 1240 | ;; problem 1: 8 or more SPACEs at bol | 1258 | ;; problem 1: 8 or more SPACEs at bol |
| 1241 | ;; action: replace 8 or more SPACEs at bol by TABs | 1259 | ;; action: replace 8 or more SPACEs at bol by TABs |
| 1242 | (when (memq 'indentation blank-chars) | 1260 | (when (memq 'indentation whitespace-chars) |
| 1243 | (goto-char rstart) | 1261 | (goto-char rstart) |
| 1244 | (while (re-search-forward blank-indentation-regexp rend t) | 1262 | (while (re-search-forward |
| 1263 | whitespace-indentation-regexp rend t) | ||
| 1245 | (setq tmp (current-indentation)) | 1264 | (setq tmp (current-indentation)) |
| 1246 | (delete-horizontal-space) | 1265 | (delete-horizontal-space) |
| 1247 | (unless (eolp) | 1266 | (unless (eolp) |
| 1248 | (indent-to tmp)))) | 1267 | (indent-to tmp)))) |
| 1249 | ;; problem 3: SPACEs or TABs at eol | 1268 | ;; problem 3: SPACEs or TABs at eol |
| 1250 | ;; action: remove all SPACEs or TABs at eol | 1269 | ;; action: remove all SPACEs or TABs at eol |
| 1251 | (when (memq 'trailing blank-chars) | 1270 | (when (memq 'trailing whitespace-chars) |
| 1252 | (let ((regexp (concat "\\(\\(" blank-trailing-regexp | 1271 | (let ((regexp (concat "\\(\\(" whitespace-trailing-regexp |
| 1253 | "\\)+\\)$"))) | 1272 | "\\)+\\)$"))) |
| 1254 | (goto-char rstart) | 1273 | (goto-char rstart) |
| 1255 | (while (re-search-forward regexp rend t) | 1274 | (while (re-search-forward regexp rend t) |
| 1256 | (delete-region (match-beginning 1) (match-end 1))))) | 1275 | (delete-region (match-beginning 1) (match-end 1))))) |
| 1257 | ;; problem 4: 8 or more SPACEs after TAB | 1276 | ;; problem 4: 8 or more SPACEs after TAB |
| 1258 | ;; action: replace 8 or more SPACEs by TABs | 1277 | ;; action: replace 8 or more SPACEs by TABs |
| 1259 | (when (memq 'space-after-tab blank-chars) | 1278 | (when (memq 'space-after-tab whitespace-chars) |
| 1260 | (blank-replace-spaces-by-tabs | 1279 | (whitespace-replace-spaces-by-tabs |
| 1261 | rstart rend blank-space-after-tab-regexp)) | 1280 | rstart rend whitespace-space-after-tab-regexp)) |
| 1262 | ;; problem 2: SPACEs before TAB | 1281 | ;; problem 2: SPACEs before TAB |
| 1263 | ;; action: replace SPACEs before TAB by TABs | 1282 | ;; action: replace SPACEs before TAB by TABs |
| 1264 | (when (memq 'space-before-tab blank-chars) | 1283 | (when (memq 'space-before-tab whitespace-chars) |
| 1265 | (blank-replace-spaces-by-tabs | 1284 | (whitespace-replace-spaces-by-tabs |
| 1266 | rstart rend blank-space-before-tab-regexp)))) | 1285 | rstart rend whitespace-space-before-tab-regexp)))) |
| 1267 | (set-marker rend nil))) ; point marker to nowhere | 1286 | (set-marker rend nil))) ; point marker to nowhere |
| 1268 | 1287 | ||
| 1269 | 1288 | ||
| 1270 | (defun blank-replace-spaces-by-tabs (rstart rend regexp) | 1289 | (defun whitespace-replace-spaces-by-tabs (rstart rend regexp) |
| 1271 | "Replace all SPACEs by TABs matched by REGEXP between RSTART and REND." | 1290 | "Replace all SPACEs by TABs matched by REGEXP between RSTART and REND." |
| 1272 | (goto-char rstart) | 1291 | (goto-char rstart) |
| 1273 | (while (re-search-forward regexp rend t) | 1292 | (while (re-search-forward regexp rend t) |
| @@ -1278,31 +1297,78 @@ The problems, which are cleaned up, are: | |||
| 1278 | (current-column)))) | 1297 | (current-column)))) |
| 1279 | (delete-region (match-beginning 1) (match-end 1)) | 1298 | (delete-region (match-beginning 1) (match-end 1)) |
| 1280 | (insert-char ?\t | 1299 | (insert-char ?\t |
| 1281 | (/ (- (- ecol (% ecol 8)) ; prev end col | 1300 | (/ (- (- ecol (% ecol 8)) ; prev end col |
| 1282 | (- scol (% scol 8))) ; prev start col | 1301 | (- scol (% scol 8))) ; prev start col |
| 1283 | 8))))) | 1302 | 8))))) |
| 1284 | 1303 | ||
| 1285 | 1304 | ||
| 1286 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 1305 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 1306 | ;;;; User command - old whitespace compatibility | ||
| 1307 | |||
| 1308 | |||
| 1309 | ;;;###autoload | ||
| 1310 | (defun whitespace-buffer () | ||
| 1311 | "Turn on `whitespace-mode' forcing some settings. | ||
| 1312 | |||
| 1313 | It forces `whitespace-style' to have `color'. | ||
| 1314 | |||
| 1315 | It also forces `whitespace-chars' to have: | ||
| 1316 | |||
| 1317 | trailing | ||
| 1318 | indentation | ||
| 1319 | space-before-tab | ||
| 1320 | empty | ||
| 1321 | space-after-tab | ||
| 1322 | |||
| 1323 | So, it is possible to visualize the following problems: | ||
| 1324 | |||
| 1325 | empty 1. empty lines at beginning of buffer. | ||
| 1326 | empty 2. empty lines at end of buffer. | ||
| 1327 | indentation 3. 8 or more SPACEs at beginning of line. | ||
| 1328 | space-before-tab 4. SPACEs before TAB. | ||
| 1329 | trailing 5. SPACEs or TABs at end of line. | ||
| 1330 | space-after-tab 6. 8 or more SPACEs after TAB. | ||
| 1331 | |||
| 1332 | See `whitespace-chars' and `whitespace-style' for documentation. | ||
| 1333 | See also `whitespace-cleanup' and `whitespace-cleanup-region' for | ||
| 1334 | cleaning up these problems." | ||
| 1335 | (interactive) | ||
| 1336 | (whitespace-mode 0) ; assure is off | ||
| 1337 | ;; keep original values | ||
| 1338 | (let ((whitespace-style (copy-sequence whitespace-style)) | ||
| 1339 | (whitespace-chars (copy-sequence whitespace-chars))) | ||
| 1340 | ;; adjust options for whitespace bogus blanks | ||
| 1341 | (add-to-list 'whitespace-style 'color) | ||
| 1342 | (mapc #'(lambda (option) | ||
| 1343 | (add-to-list 'whitespace-chars option)) | ||
| 1344 | '(trailing | ||
| 1345 | indentation | ||
| 1346 | space-before-tab | ||
| 1347 | empty | ||
| 1348 | space-after-tab)) | ||
| 1349 | (whitespace-mode 1))) ; turn on | ||
| 1350 | |||
| 1351 | |||
| 1352 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
| 1287 | ;;;; Internal functions | 1353 | ;;;; Internal functions |
| 1288 | 1354 | ||
| 1289 | 1355 | ||
| 1290 | (defvar blank-font-lock-mode nil | 1356 | (defvar whitespace-font-lock-mode nil |
| 1291 | "Used to remember whether a buffer had font lock mode on or not.") | 1357 | "Used to remember whether a buffer had font lock mode on or not.") |
| 1292 | (make-variable-buffer-local 'blank-font-lock-mode) | 1358 | (make-variable-buffer-local 'whitespace-font-lock-mode) |
| 1293 | 1359 | ||
| 1294 | (defvar blank-font-lock nil | 1360 | (defvar whitespace-font-lock nil |
| 1295 | "Used to remember whether a buffer initially had font lock on or not.") | 1361 | "Used to remember whether a buffer initially had font lock on or not.") |
| 1296 | (make-variable-buffer-local 'blank-font-lock) | 1362 | (make-variable-buffer-local 'whitespace-font-lock) |
| 1297 | 1363 | ||
| 1298 | (defvar blank-font-lock-keywords nil | 1364 | (defvar whitespace-font-lock-keywords nil |
| 1299 | "Used to save locally `font-lock-keywords' value.") | 1365 | "Used to save locally `font-lock-keywords' value.") |
| 1300 | (make-variable-buffer-local 'blank-font-lock-keywords) | 1366 | (make-variable-buffer-local 'whitespace-font-lock-keywords) |
| 1301 | 1367 | ||
| 1302 | 1368 | ||
| 1303 | (defconst blank-help-text | 1369 | (defconst whitespace-help-text |
| 1304 | "\ | 1370 | "\ |
| 1305 | blank-mode toggle options: | 1371 | whitespace-mode toggle options: |
| 1306 | 1372 | ||
| 1307 | [] t - toggle TAB visualization | 1373 | [] t - toggle TAB visualization |
| 1308 | [] s - toggle SPACE and HARD SPACE visualization | 1374 | [] s - toggle SPACE and HARD SPACE visualization |
| @@ -1318,18 +1384,18 @@ The problems, which are cleaned up, are: | |||
| 1318 | [] c - toggle color faces | 1384 | [] c - toggle color faces |
| 1319 | [] m - toggle visual mark | 1385 | [] m - toggle visual mark |
| 1320 | 1386 | ||
| 1321 | x - restore `blank-chars' value | 1387 | x - restore `whitespace-chars' value |
| 1322 | z - restore `blank-style' value | 1388 | z - restore `whitespace-style' value |
| 1323 | 1389 | ||
| 1324 | ? - display this text\n\n" | 1390 | ? - display this text\n\n" |
| 1325 | "Text for blank toggle options.") | 1391 | "Text for whitespace toggle options.") |
| 1326 | 1392 | ||
| 1327 | 1393 | ||
| 1328 | (defconst blank-help-buffer-name "*Blank Toggle Options*" | 1394 | (defconst whitespace-help-buffer-name "*Whitespace Toggle Options*" |
| 1329 | "The buffer name for blank toggle options.") | 1395 | "The buffer name for whitespace toggle options.") |
| 1330 | 1396 | ||
| 1331 | 1397 | ||
| 1332 | (defun blank-insert-option-mark (the-list the-value) | 1398 | (defun whitespace-insert-option-mark (the-list the-value) |
| 1333 | "Insert the option mark ('X' or ' ') in toggle options buffer." | 1399 | "Insert the option mark ('X' or ' ') in toggle options buffer." |
| 1334 | (forward-line 1) | 1400 | (forward-line 1) |
| 1335 | (dolist (sym the-list) | 1401 | (dolist (sym the-list) |
| @@ -1338,39 +1404,42 @@ The problems, which are cleaned up, are: | |||
| 1338 | (insert (if (memq sym the-value) "X" " ")))) | 1404 | (insert (if (memq sym the-value) "X" " ")))) |
| 1339 | 1405 | ||
| 1340 | 1406 | ||
| 1341 | (defun blank-help-on (chars style) | 1407 | (defun whitespace-help-on (chars style) |
| 1342 | "Display the blank toggle options." | 1408 | "Display the whitespace toggle options." |
| 1343 | (unless (get-buffer blank-help-buffer-name) | 1409 | (unless (get-buffer whitespace-help-buffer-name) |
| 1344 | (delete-other-windows) | 1410 | (delete-other-windows) |
| 1345 | (let ((buffer (get-buffer-create blank-help-buffer-name))) | 1411 | (let ((buffer (get-buffer-create whitespace-help-buffer-name))) |
| 1346 | (save-excursion | 1412 | (save-excursion |
| 1347 | (set-buffer buffer) | 1413 | (set-buffer buffer) |
| 1348 | (erase-buffer) | 1414 | (erase-buffer) |
| 1349 | (insert blank-help-text) | 1415 | (insert whitespace-help-text) |
| 1350 | (goto-char (point-min)) | 1416 | (goto-char (point-min)) |
| 1351 | (blank-insert-option-mark blank-chars-value-list chars) | 1417 | (whitespace-insert-option-mark |
| 1352 | (blank-insert-option-mark blank-style-value-list style) | 1418 | whitespace-chars-value-list chars) |
| 1419 | (whitespace-insert-option-mark | ||
| 1420 | whitespace-style-value-list style) | ||
| 1353 | (goto-char (point-min)) | 1421 | (goto-char (point-min)) |
| 1354 | (set-buffer-modified-p nil) | 1422 | (set-buffer-modified-p nil) |
| 1355 | (let ((size (- (window-height) | 1423 | (let ((size (- (window-height) |
| 1356 | (max window-min-height | 1424 | (max window-min-height |
| 1357 | (1+ (count-lines (point-min) (point-max))))))) | 1425 | (1+ (count-lines (point-min) |
| 1426 | (point-max))))))) | ||
| 1358 | (when (<= size 0) | 1427 | (when (<= size 0) |
| 1359 | (kill-buffer buffer) | 1428 | (kill-buffer buffer) |
| 1360 | (error "Frame height is too small; \ | 1429 | (error "Frame height is too small; \ |
| 1361 | can't split window to display blank toggle options")) | 1430 | can't split window to display whitespace toggle options")) |
| 1362 | (set-window-buffer (split-window nil size) buffer)))))) | 1431 | (set-window-buffer (split-window nil size) buffer)))))) |
| 1363 | 1432 | ||
| 1364 | 1433 | ||
| 1365 | (defun blank-help-off () | 1434 | (defun whitespace-help-off () |
| 1366 | "Remove the buffer and window of the blank toggle options." | 1435 | "Remove the buffer and window of the whitespace toggle options." |
| 1367 | (let ((buffer (get-buffer blank-help-buffer-name))) | 1436 | (let ((buffer (get-buffer whitespace-help-buffer-name))) |
| 1368 | (when buffer | 1437 | (when buffer |
| 1369 | (delete-windows-on buffer) | 1438 | (delete-windows-on buffer) |
| 1370 | (kill-buffer buffer)))) | 1439 | (kill-buffer buffer)))) |
| 1371 | 1440 | ||
| 1372 | 1441 | ||
| 1373 | (defun blank-interactive-char (local-p) | 1442 | (defun whitespace-interactive-char (local-p) |
| 1374 | "Interactive function to read a char and return a symbol. | 1443 | "Interactive function to read a char and return a symbol. |
| 1375 | 1444 | ||
| 1376 | If LOCAL-P is non-nil, it uses a local context; otherwise, it | 1445 | If LOCAL-P is non-nil, it uses a local context; otherwise, it |
| @@ -1391,20 +1460,22 @@ It reads one of the following chars: | |||
| 1391 | a toggle SPACEs after TAB visualization | 1460 | a toggle SPACEs after TAB visualization |
| 1392 | c toggle color faces | 1461 | c toggle color faces |
| 1393 | m toggle visual mark | 1462 | m toggle visual mark |
| 1394 | x restore `blank-chars' value | 1463 | x restore `whitespace-chars' value |
| 1395 | z restore `blank-style' value | 1464 | z restore `whitespace-style' value |
| 1396 | ? display brief help | 1465 | ? display brief help |
| 1397 | 1466 | ||
| 1398 | See also `blank-toggle-option-alist'." | 1467 | See also `whitespace-toggle-option-alist'." |
| 1399 | (let* ((is-off (not (if local-p blank-mode global-blank-mode))) | 1468 | (let* ((is-off (not (if local-p |
| 1400 | (chars (cond (is-off blank-chars) ; use default value | 1469 | whitespace-mode |
| 1401 | (local-p blank-active-chars) | 1470 | global-whitespace-mode))) |
| 1402 | (t blank-toggle-chars))) | 1471 | (chars (cond (is-off whitespace-chars) ; use default value |
| 1403 | (style (cond (is-off blank-style) ; use default value | 1472 | (local-p whitespace-active-chars) |
| 1404 | (local-p blank-active-style) | 1473 | (t whitespace-toggle-chars))) |
| 1405 | (t blank-toggle-style))) | 1474 | (style (cond (is-off whitespace-style) ; use default value |
| 1475 | (local-p whitespace-active-style) | ||
| 1476 | (t whitespace-toggle-style))) | ||
| 1406 | (prompt | 1477 | (prompt |
| 1407 | (format "Blank Toggle %s (type ? for further options)-" | 1478 | (format "Whitespace Toggle %s (type ? for further options)-" |
| 1408 | (if local-p "Local" "Global"))) | 1479 | (if local-p "Local" "Global"))) |
| 1409 | ch sym) | 1480 | ch sym) |
| 1410 | ;; read a valid option and get the corresponding symbol | 1481 | ;; read a valid option and get the corresponding symbol |
| @@ -1417,22 +1488,23 @@ See also `blank-toggle-option-alist'." | |||
| 1417 | (setq ch (read-char prompt)) | 1488 | (setq ch (read-char prompt)) |
| 1418 | (not | 1489 | (not |
| 1419 | (setq sym | 1490 | (setq sym |
| 1420 | (cdr (assq ch blank-toggle-option-alist))))) | 1491 | (cdr |
| 1492 | (assq ch whitespace-toggle-option-alist))))) | ||
| 1421 | ;; while body | 1493 | ;; while body |
| 1422 | (if (eq ch ?\?) | 1494 | (if (eq ch ?\?) |
| 1423 | (blank-help-on chars style) | 1495 | (whitespace-help-on chars style) |
| 1424 | (ding))) | 1496 | (ding))) |
| 1425 | (blank-help-off) | 1497 | (whitespace-help-off) |
| 1426 | (message " ")) ; clean echo area | 1498 | (message " ")) ; clean echo area |
| 1427 | ;; handler | 1499 | ;; handler |
| 1428 | ((quit error) | 1500 | ((quit error) |
| 1429 | (blank-help-off) | 1501 | (whitespace-help-off) |
| 1430 | (error (error-message-string data))))) | 1502 | (error (error-message-string data))))) |
| 1431 | (list sym))) ; return the apropriate symbol | 1503 | (list sym))) ; return the apropriate symbol |
| 1432 | 1504 | ||
| 1433 | 1505 | ||
| 1434 | (defun blank-toggle-list (local-p arg the-list default-list | 1506 | (defun whitespace-toggle-list (local-p arg the-list default-list |
| 1435 | sym-restore sym-list) | 1507 | sym-restore sym-list) |
| 1436 | "Toggle options in THE-LIST based on list ARG. | 1508 | "Toggle options in THE-LIST based on list ARG. |
| 1437 | 1509 | ||
| 1438 | If LOCAL-P is non-nil, it uses a local context; otherwise, it | 1510 | If LOCAL-P is non-nil, it uses a local context; otherwise, it |
| @@ -1451,7 +1523,7 @@ in THE-LIST. | |||
| 1451 | 1523 | ||
| 1452 | SYM-LIST is a list of valid options, used to check if the ARG's | 1524 | SYM-LIST is a list of valid options, used to check if the ARG's |
| 1453 | options are valid." | 1525 | options are valid." |
| 1454 | (unless (if local-p blank-mode global-blank-mode) | 1526 | (unless (if local-p whitespace-mode global-whitespace-mode) |
| 1455 | (setq the-list default-list)) | 1527 | (setq the-list default-list)) |
| 1456 | (setq the-list (copy-sequence the-list)) ; keep original list | 1528 | (setq the-list (copy-sequence the-list)) ; keep original list |
| 1457 | (dolist (sym (if (listp arg) arg (list arg))) | 1529 | (dolist (sym (if (listp arg) arg (list arg))) |
| @@ -1467,65 +1539,65 @@ options are valid." | |||
| 1467 | the-list) | 1539 | the-list) |
| 1468 | 1540 | ||
| 1469 | 1541 | ||
| 1470 | (defun blank-turn-on () | 1542 | (defun whitespace-turn-on () |
| 1471 | "Turn on blank visualization." | 1543 | "Turn on whitespace visualization." |
| 1472 | (setq blank-active-style (if (listp blank-style) | 1544 | (setq whitespace-active-style (if (listp whitespace-style) |
| 1473 | blank-style | 1545 | whitespace-style |
| 1474 | (list blank-style))) | 1546 | (list whitespace-style))) |
| 1475 | (setq blank-active-chars (if (listp blank-chars) | 1547 | (setq whitespace-active-chars (if (listp whitespace-chars) |
| 1476 | blank-chars | 1548 | whitespace-chars |
| 1477 | (list blank-chars))) | 1549 | (list whitespace-chars))) |
| 1478 | (when (memq 'color blank-active-style) | 1550 | (when (memq 'color whitespace-active-style) |
| 1479 | (blank-color-on)) | 1551 | (whitespace-color-on)) |
| 1480 | (when (memq 'mark blank-active-style) | 1552 | (when (memq 'mark whitespace-active-style) |
| 1481 | (blank-display-char-on))) | 1553 | (whitespace-display-char-on))) |
| 1482 | 1554 | ||
| 1483 | 1555 | ||
| 1484 | (defun blank-turn-off () | 1556 | (defun whitespace-turn-off () |
| 1485 | "Turn off blank visualization." | 1557 | "Turn off whitesapce visualization." |
| 1486 | (when (memq 'color blank-active-style) | 1558 | (when (memq 'color whitespace-active-style) |
| 1487 | (blank-color-off)) | 1559 | (whitespace-color-off)) |
| 1488 | (when (memq 'mark blank-active-style) | 1560 | (when (memq 'mark whitespace-active-style) |
| 1489 | (blank-display-char-off))) | 1561 | (whitespace-display-char-off))) |
| 1490 | 1562 | ||
| 1491 | 1563 | ||
| 1492 | (defun blank-color-on () | 1564 | (defun whitespace-color-on () |
| 1493 | "Turn on color visualization." | 1565 | "Turn on color visualization." |
| 1494 | (when blank-active-chars | 1566 | (when whitespace-active-chars |
| 1495 | (unless blank-font-lock | 1567 | (unless whitespace-font-lock |
| 1496 | (setq blank-font-lock t | 1568 | (setq whitespace-font-lock t |
| 1497 | blank-font-lock-keywords | 1569 | whitespace-font-lock-keywords |
| 1498 | (copy-sequence font-lock-keywords))) | 1570 | (copy-sequence font-lock-keywords))) |
| 1499 | ;; turn off font lock | 1571 | ;; turn off font lock |
| 1500 | (setq blank-font-lock-mode font-lock-mode) | 1572 | (setq whitespace-font-lock-mode font-lock-mode) |
| 1501 | (font-lock-mode 0) | 1573 | (font-lock-mode 0) |
| 1502 | ;; add blank-mode color into font lock | 1574 | ;; add whitespace-mode color into font lock |
| 1503 | (when (memq 'spaces blank-active-chars) | 1575 | (when (memq 'spaces whitespace-active-chars) |
| 1504 | (font-lock-add-keywords | 1576 | (font-lock-add-keywords |
| 1505 | nil | 1577 | nil |
| 1506 | (list | 1578 | (list |
| 1507 | ;; Show SPACEs | 1579 | ;; Show SPACEs |
| 1508 | (list blank-space-regexp 1 blank-space t) | 1580 | (list whitespace-space-regexp 1 whitespace-space t) |
| 1509 | ;; Show HARD SPACEs | 1581 | ;; Show HARD SPACEs |
| 1510 | (list blank-hspace-regexp 1 blank-hspace t)) | 1582 | (list whitespace-hspace-regexp 1 whitespace-hspace t)) |
| 1511 | t)) | 1583 | t)) |
| 1512 | (when (memq 'tabs blank-active-chars) | 1584 | (when (memq 'tabs whitespace-active-chars) |
| 1513 | (font-lock-add-keywords | 1585 | (font-lock-add-keywords |
| 1514 | nil | 1586 | nil |
| 1515 | (list | 1587 | (list |
| 1516 | ;; Show TABs | 1588 | ;; Show TABs |
| 1517 | (list blank-tab-regexp 1 blank-tab t)) | 1589 | (list whitespace-tab-regexp 1 whitespace-tab t)) |
| 1518 | t)) | 1590 | t)) |
| 1519 | (when (memq 'trailing blank-active-chars) | 1591 | (when (memq 'trailing whitespace-active-chars) |
| 1520 | (font-lock-add-keywords | 1592 | (font-lock-add-keywords |
| 1521 | nil | 1593 | nil |
| 1522 | (list | 1594 | (list |
| 1523 | ;; Show trailing blanks | 1595 | ;; Show trailing blanks |
| 1524 | (list (concat "\\(\\(" blank-trailing-regexp "\\)+\\)$") | 1596 | (list (concat "\\(\\(" whitespace-trailing-regexp "\\)+\\)$") |
| 1525 | 1 blank-trailing t)) | 1597 | 1 whitespace-trailing t)) |
| 1526 | t)) | 1598 | t)) |
| 1527 | (when (or (memq 'lines blank-active-chars) | 1599 | (when (or (memq 'lines whitespace-active-chars) |
| 1528 | (memq 'lines-tail blank-active-chars)) | 1600 | (memq 'lines-tail whitespace-active-chars)) |
| 1529 | (font-lock-add-keywords | 1601 | (font-lock-add-keywords |
| 1530 | nil | 1602 | nil |
| 1531 | (list | 1603 | (list |
| @@ -1534,115 +1606,115 @@ options are valid." | |||
| 1534 | (format | 1606 | (format |
| 1535 | "^\\([^\t\n]\\{%s\\}\\|[^\t\n]\\{0,%s\\}\t\\)\\{%d\\}%s\\(.+\\)$" | 1607 | "^\\([^\t\n]\\{%s\\}\\|[^\t\n]\\{0,%s\\}\t\\)\\{%d\\}%s\\(.+\\)$" |
| 1536 | tab-width (1- tab-width) | 1608 | tab-width (1- tab-width) |
| 1537 | (/ blank-line-column tab-width) | 1609 | (/ whitespace-line-column tab-width) |
| 1538 | (let ((rem (% blank-line-column tab-width))) | 1610 | (let ((rem (% whitespace-line-column tab-width))) |
| 1539 | (if (zerop rem) | 1611 | (if (zerop rem) |
| 1540 | "" | 1612 | "" |
| 1541 | (format ".\\{%d\\}" rem)))) | 1613 | (format ".\\{%d\\}" rem)))) |
| 1542 | (if (memq 'lines blank-active-chars) | 1614 | (if (memq 'lines whitespace-active-chars) |
| 1543 | 0 ; whole line | 1615 | 0 ; whole line |
| 1544 | 2) ; line tail | 1616 | 2) ; line tail |
| 1545 | blank-line t)) | 1617 | whitespace-line t)) |
| 1546 | t)) | 1618 | t)) |
| 1547 | (when (memq 'space-before-tab blank-active-chars) | 1619 | (when (memq 'space-before-tab whitespace-active-chars) |
| 1548 | (font-lock-add-keywords | 1620 | (font-lock-add-keywords |
| 1549 | nil | 1621 | nil |
| 1550 | (list | 1622 | (list |
| 1551 | ;; Show SPACEs before TAB | 1623 | ;; Show SPACEs before TAB |
| 1552 | (list blank-space-before-tab-regexp | 1624 | (list whitespace-space-before-tab-regexp |
| 1553 | 1 blank-space-before-tab t)) | 1625 | 1 whitespace-space-before-tab t)) |
| 1554 | t)) | 1626 | t)) |
| 1555 | (when (memq 'indentation blank-active-chars) | 1627 | (when (memq 'indentation whitespace-active-chars) |
| 1556 | (font-lock-add-keywords | 1628 | (font-lock-add-keywords |
| 1557 | nil | 1629 | nil |
| 1558 | (list | 1630 | (list |
| 1559 | ;; Show indentation SPACEs | 1631 | ;; Show indentation SPACEs |
| 1560 | (list blank-indentation-regexp | 1632 | (list whitespace-indentation-regexp |
| 1561 | 1 blank-indentation t)) | 1633 | 1 whitespace-indentation t)) |
| 1562 | t)) | 1634 | t)) |
| 1563 | (when (memq 'empty blank-active-chars) | 1635 | (when (memq 'empty whitespace-active-chars) |
| 1564 | (font-lock-add-keywords | 1636 | (font-lock-add-keywords |
| 1565 | nil | 1637 | nil |
| 1566 | (list | 1638 | (list |
| 1567 | ;; Show empty lines at beginning of buffer | 1639 | ;; Show empty lines at beginning of buffer |
| 1568 | (list blank-empty-at-bob-regexp | 1640 | (list whitespace-empty-at-bob-regexp |
| 1569 | 1 blank-empty t)) | 1641 | 1 whitespace-empty t)) |
| 1570 | t) | 1642 | t) |
| 1571 | (font-lock-add-keywords | 1643 | (font-lock-add-keywords |
| 1572 | nil | 1644 | nil |
| 1573 | (list | 1645 | (list |
| 1574 | ;; Show empty lines at end of buffer | 1646 | ;; Show empty lines at end of buffer |
| 1575 | (list blank-empty-at-eob-regexp | 1647 | (list whitespace-empty-at-eob-regexp |
| 1576 | 1 blank-empty t)) | 1648 | 1 whitespace-empty t)) |
| 1577 | t)) | 1649 | t)) |
| 1578 | (when (memq 'space-after-tab blank-active-chars) | 1650 | (when (memq 'space-after-tab whitespace-active-chars) |
| 1579 | (font-lock-add-keywords | 1651 | (font-lock-add-keywords |
| 1580 | nil | 1652 | nil |
| 1581 | (list | 1653 | (list |
| 1582 | ;; Show SPACEs after TAB | 1654 | ;; Show SPACEs after TAB |
| 1583 | (list blank-space-after-tab-regexp | 1655 | (list whitespace-space-after-tab-regexp |
| 1584 | 1 blank-space-after-tab t)) | 1656 | 1 whitespace-space-after-tab t)) |
| 1585 | t)) | 1657 | t)) |
| 1586 | ;; now turn on font lock and highlight blanks | 1658 | ;; now turn on font lock and highlight blanks |
| 1587 | (font-lock-mode 1))) | 1659 | (font-lock-mode 1))) |
| 1588 | 1660 | ||
| 1589 | 1661 | ||
| 1590 | (defun blank-color-off () | 1662 | (defun whitespace-color-off () |
| 1591 | "Turn off color visualization." | 1663 | "Turn off color visualization." |
| 1592 | (when blank-active-chars | 1664 | (when whitespace-active-chars |
| 1593 | ;; turn off font lock | 1665 | ;; turn off font lock |
| 1594 | (font-lock-mode 0) | 1666 | (font-lock-mode 0) |
| 1595 | (when blank-font-lock | 1667 | (when whitespace-font-lock |
| 1596 | (setq blank-font-lock nil | 1668 | (setq whitespace-font-lock nil |
| 1597 | font-lock-keywords blank-font-lock-keywords)) | 1669 | font-lock-keywords whitespace-font-lock-keywords)) |
| 1598 | ;; restore original font lock state | 1670 | ;; restore original font lock state |
| 1599 | (font-lock-mode blank-font-lock-mode))) | 1671 | (font-lock-mode whitespace-font-lock-mode))) |
| 1600 | 1672 | ||
| 1601 | 1673 | ||
| 1602 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 1674 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 1603 | ;;;; Hacked from visws.el (Miles Bader <miles@gnu.org>) | 1675 | ;;;; Hacked from visws.el (Miles Bader <miles@gnu.org>) |
| 1604 | 1676 | ||
| 1605 | 1677 | ||
| 1606 | (defvar blank-display-table nil | 1678 | (defvar whitespace-display-table nil |
| 1607 | "Used to save a local display table.") | 1679 | "Used to save a local display table.") |
| 1608 | (make-variable-buffer-local 'blank-display-table) | 1680 | (make-variable-buffer-local 'whitespace-display-table) |
| 1609 | 1681 | ||
| 1610 | (defvar blank-display-table-was-local nil | 1682 | (defvar whitespace-display-table-was-local nil |
| 1611 | "Used to remember whether a buffer initially had a local display table or not.") | 1683 | "Used to remember whether a buffer initially had a local display table.") |
| 1612 | (make-variable-buffer-local 'blank-display-table-was-local) | 1684 | (make-variable-buffer-local 'whitespace-display-table-was-local) |
| 1613 | 1685 | ||
| 1614 | 1686 | ||
| 1615 | (defsubst blank-char-valid-p (char) | 1687 | (defsubst whitespace-char-valid-p (char) |
| 1616 | ;; This check should be improved!!! | 1688 | ;; This check should be improved!!! |
| 1617 | (or (< char 256) | 1689 | (or (< char 256) |
| 1618 | (char-valid-p char))) | 1690 | (char-valid-p char))) |
| 1619 | 1691 | ||
| 1620 | 1692 | ||
| 1621 | (defun blank-legal-display-vector-p (vec) | 1693 | (defun whitespace-display-vector-p (vec) |
| 1622 | "Return true if every character in vector VEC can be displayed." | 1694 | "Return true if every character in vector VEC can be displayed." |
| 1623 | (let ((i (length vec))) | 1695 | (let ((i (length vec))) |
| 1624 | (when (> i 0) | 1696 | (when (> i 0) |
| 1625 | (while (and (>= (setq i (1- i)) 0) | 1697 | (while (and (>= (setq i (1- i)) 0) |
| 1626 | (blank-char-valid-p (aref vec i)))) | 1698 | (whitespace-char-valid-p (aref vec i)))) |
| 1627 | (< i 0)))) | 1699 | (< i 0)))) |
| 1628 | 1700 | ||
| 1629 | 1701 | ||
| 1630 | (defun blank-display-char-on () | 1702 | (defun whitespace-display-char-on () |
| 1631 | "Turn on character display mapping." | 1703 | "Turn on character display mapping." |
| 1632 | (when blank-display-mappings | 1704 | (when whitespace-display-mappings |
| 1633 | (let (vecs vec) | 1705 | (let (vecs vec) |
| 1634 | ;; Remember whether a buffer has a local display table. | 1706 | ;; Remember whether a buffer has a local display table. |
| 1635 | (unless blank-display-table-was-local | 1707 | (unless whitespace-display-table-was-local |
| 1636 | (setq blank-display-table-was-local t | 1708 | (setq whitespace-display-table-was-local t |
| 1637 | blank-display-table | 1709 | whitespace-display-table |
| 1638 | (copy-sequence buffer-display-table))) | 1710 | (copy-sequence buffer-display-table))) |
| 1639 | (unless buffer-display-table | 1711 | (unless buffer-display-table |
| 1640 | (setq buffer-display-table (make-display-table))) | 1712 | (setq buffer-display-table (make-display-table))) |
| 1641 | (dolist (entry blank-display-mappings) | 1713 | (dolist (entry whitespace-display-mappings) |
| 1642 | (setq vecs (cdr entry)) | 1714 | (setq vecs (cdr entry)) |
| 1643 | ;; Get a displayable mapping. | 1715 | ;; Get a displayable mapping. |
| 1644 | (while (and vecs | 1716 | (while (and vecs |
| 1645 | (not (blank-legal-display-vector-p (car vecs)))) | 1717 | (not (whitespace-display-vector-p (car vecs)))) |
| 1646 | (setq vecs (cdr vecs))) | 1718 | (setq vecs (cdr vecs))) |
| 1647 | ;; Display a valid mapping. | 1719 | ;; Display a valid mapping. |
| 1648 | (when vecs | 1720 | (when vecs |
| @@ -1652,19 +1724,20 @@ options are valid." | |||
| 1652 | ((not (eq (car entry) ?\n)) | 1724 | ((not (eq (car entry) ?\n)) |
| 1653 | (aset buffer-display-table (car entry) vec)) | 1725 | (aset buffer-display-table (car entry) vec)) |
| 1654 | ;; Newline char - display it | 1726 | ;; Newline char - display it |
| 1655 | ((memq 'newline blank-active-chars) | 1727 | ((memq 'newline whitespace-active-chars) |
| 1656 | ;; Only insert face bits on NEWLINE char mapping to avoid | 1728 | ;; Only insert face bits on NEWLINE char mapping to avoid |
| 1657 | ;; obstruction of other faces like TABs and (HARD) SPACEs | 1729 | ;; obstruction of other faces like TABs and (HARD) SPACEs |
| 1658 | ;; faces, font-lock faces, etc. | 1730 | ;; faces, font-lock faces, etc. |
| 1659 | (when (memq 'color blank-active-style) | 1731 | (when (memq 'color whitespace-active-style) |
| 1660 | (dotimes (i (length vec)) | 1732 | (dotimes (i (length vec)) |
| 1661 | ;; Due to limitations of glyph representation, the char | 1733 | ;; Due to limitations of glyph representation, the char |
| 1662 | ;; code can not be above ?\x1FFFF. Probably, this will | 1734 | ;; code can not be above ?\x1FFFF. Probably, this will |
| 1663 | ;; be fixed after Emacs unicode merging. | 1735 | ;; be fixed after Emacs unicode merging. |
| 1664 | (or (eq (aref vec i) ?\n) | 1736 | (or (eq (aref vec i) ?\n) |
| 1665 | (> (aref vec i) #x1FFFF) | 1737 | (> (aref vec i) #x1FFFF) |
| 1666 | (aset vec i (make-glyph-code (aref vec i) | 1738 | (aset vec i |
| 1667 | blank-newline))))) | 1739 | (make-glyph-code (aref vec i) |
| 1740 | whitespace-newline))))) | ||
| 1668 | ;; Display mapping | 1741 | ;; Display mapping |
| 1669 | (aset buffer-display-table (car entry) vec)) | 1742 | (aset buffer-display-table (car entry) vec)) |
| 1670 | ;; Newline char - don't display it | 1743 | ;; Newline char - don't display it |
| @@ -1673,54 +1746,21 @@ options are valid." | |||
| 1673 | ))))))) | 1746 | ))))))) |
| 1674 | 1747 | ||
| 1675 | 1748 | ||
| 1676 | (defun blank-display-char-off () | 1749 | (defun whitespace-display-char-off () |
| 1677 | "Turn off character display mapping." | 1750 | "Turn off character display mapping." |
| 1678 | (and blank-display-mappings | 1751 | (and whitespace-display-mappings |
| 1679 | blank-display-table-was-local | 1752 | whitespace-display-table-was-local |
| 1680 | (setq blank-display-table-was-local nil | 1753 | (setq whitespace-display-table-was-local nil |
| 1681 | buffer-display-table blank-display-table))) | 1754 | buffer-display-table whitespace-display-table))) |
| 1682 | |||
| 1683 | |||
| 1684 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
| 1685 | ;;;; Aliases for whitespace compatibility | ||
| 1686 | |||
| 1687 | |||
| 1688 | ;;;###autoload | ||
| 1689 | (defun whitespace-buffer () | ||
| 1690 | (interactive) | ||
| 1691 | (blank-mode 0) ; assure is off | ||
| 1692 | ;; keep original values | ||
| 1693 | (let ((blank-style (copy-sequence blank-style)) | ||
| 1694 | (blank-chars (copy-sequence blank-chars))) | ||
| 1695 | ;; adjust options for whitespace bogus blanks | ||
| 1696 | (add-to-list 'blank-style 'color) | ||
| 1697 | (mapc #'(lambda (option) | ||
| 1698 | (add-to-list 'blank-chars option)) | ||
| 1699 | '(trailing | ||
| 1700 | indentation | ||
| 1701 | space-before-tab | ||
| 1702 | empty | ||
| 1703 | space-after-tab)) | ||
| 1704 | (blank-mode 1))) | ||
| 1705 | |||
| 1706 | ;;;###autoload | ||
| 1707 | (defalias 'whitespace-region 'whitespace-buffer) ; there is no `blank-region' | ||
| 1708 | |||
| 1709 | ;;;###autoload | ||
| 1710 | (defalias 'whitespace-cleanup 'blank-cleanup) | ||
| 1711 | |||
| 1712 | ;;;###autoload | ||
| 1713 | (defalias 'whitespace-cleanup-region 'blank-cleanup-region) | ||
| 1714 | 1755 | ||
| 1715 | 1756 | ||
| 1716 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 1757 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 1717 | 1758 | ||
| 1718 | 1759 | ||
| 1719 | (provide 'blank-mode) | 1760 | (provide 'whitespace) |
| 1720 | 1761 | ||
| 1721 | 1762 | ||
| 1722 | (run-hooks 'blank-load-hook) | 1763 | (run-hooks 'whitespace-load-hook) |
| 1723 | 1764 | ||
| 1724 | 1765 | ||
| 1725 | ;; arch-tag: 1b1e2500-dbd4-4a26-8f7a-5a5edfd3c97e | 1766 | ;;; whitespace.el ends here |
| 1726 | ;;; blank-mode.el ends here | ||