diff options
| author | Vinicius Jose Latorre | 2009-09-25 02:23:51 +0000 |
|---|---|---|
| committer | Vinicius Jose Latorre | 2009-09-25 02:23:51 +0000 |
| commit | 32a9841cadfc99536874e807f3530cdd5d259fb5 (patch) | |
| tree | 254b10f2affbe3b2353d770ce5add148e5fff89c | |
| parent | fb652bb5c38ab92605d38829bf1c5cecb7ea2b33 (diff) | |
| download | emacs-32a9841cadfc99536874e807f3530cdd5d259fb5.tar.gz emacs-32a9841cadfc99536874e807f3530cdd5d259fb5.zip | |
New version 12. Bug#4177
| -rw-r--r-- | lisp/ChangeLog | 14 | ||||
| -rw-r--r-- | lisp/whitespace.el | 84 |
2 files changed, 87 insertions, 11 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 0e1a547425b..e9685a08fcb 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -2,6 +2,20 @@ | |||
| 2 | 2 | ||
| 3 | * progmodes/hideshow.el (hs-show-block): Run `hs-show-hook'. (Bug#4548) | 3 | * progmodes/hideshow.el (hs-show-block): Run `hs-show-hook'. (Bug#4548) |
| 4 | 4 | ||
| 5 | 2009-09-24 Vinicius Jose Latorre <viniciusjl@ig.com.br> | ||
| 6 | |||
| 7 | * whitespace.el: Does not highlight trailing spaces While point is | ||
| 8 | at end of line. Does not highligt spaces at beginning of buffer | ||
| 9 | while point is at beginning of buffer. Does not highlight spaces | ||
| 10 | at end of buffer while point is at end of buffer. (Bug#4177) | ||
| 11 | New version 12.0. | ||
| 12 | (whitespace-display-mappings): Adjust initialization. | ||
| 13 | (whitespace-point, whitespace-font-lock-refontify): New vars. | ||
| 14 | (whitespace-color-on, whitespace-color-off): Adjust code. | ||
| 15 | (whitespace-trailing-regexp, whitespace-empty-at-bob-regexp) | ||
| 16 | (whitespace-empty-at-eob-regexp, whitespace-space-regexp) | ||
| 17 | (whitespace-tab-regexp, whitespace-post-command-hook): New funs. | ||
| 18 | |||
| 5 | 2009-09-24 Chong Yidong <cyd@stupidchicken.com> | 19 | 2009-09-24 Chong Yidong <cyd@stupidchicken.com> |
| 6 | 20 | ||
| 7 | * nxml/nxml-mode.el: Alias xml-mode to nxml-mode. | 21 | * nxml/nxml-mode.el: Alias xml-mode to nxml-mode. |
diff --git a/lisp/whitespace.el b/lisp/whitespace.el index 7360ccad92c..030d5f7473e 100644 --- a/lisp/whitespace.el +++ b/lisp/whitespace.el | |||
| @@ -6,7 +6,7 @@ | |||
| 6 | ;; Author: Vinicius Jose Latorre <viniciusjl@ig.com.br> | 6 | ;; Author: Vinicius Jose Latorre <viniciusjl@ig.com.br> |
| 7 | ;; Maintainer: Vinicius Jose Latorre <viniciusjl@ig.com.br> | 7 | ;; Maintainer: Vinicius Jose Latorre <viniciusjl@ig.com.br> |
| 8 | ;; Keywords: data, wp | 8 | ;; Keywords: data, wp |
| 9 | ;; Version: 11.2.2 | 9 | ;; Version: 12 |
| 10 | ;; X-URL: http://www.emacswiki.org/cgi-bin/wiki/ViniciusJoseLatorre | 10 | ;; X-URL: http://www.emacswiki.org/cgi-bin/wiki/ViniciusJoseLatorre |
| 11 | 11 | ||
| 12 | ;; This file is part of GNU Emacs. | 12 | ;; This file is part of GNU Emacs. |
| @@ -870,8 +870,8 @@ Used when `whitespace-style' includes `lines' or `lines-tail'." | |||
| 870 | ;; Hacked from `visible-whitespace-mappings' in visws.el | 870 | ;; Hacked from `visible-whitespace-mappings' in visws.el |
| 871 | (defcustom whitespace-display-mappings | 871 | (defcustom whitespace-display-mappings |
| 872 | '( | 872 | '( |
| 873 | (space-mark ?\ [?\xB7] [?.]) ; space - centered dot | 873 | (space-mark ?\ [?\u00B7] [?.]) ; space - centered dot |
| 874 | (space-mark ?\xA0 [?\xA4] [?_]) ; hard space - currency | 874 | (space-mark ?\xA0 [?\u00A4] [?_]) ; hard space - currency |
| 875 | (space-mark ?\x8A0 [?\x8A4] [?_]) ; hard space - currency | 875 | (space-mark ?\x8A0 [?\x8A4] [?_]) ; hard space - currency |
| 876 | (space-mark ?\x920 [?\x924] [?_]) ; hard space - currency | 876 | (space-mark ?\x920 [?\x924] [?_]) ; hard space - currency |
| 877 | (space-mark ?\xE20 [?\xE24] [?_]) ; hard space - currency | 877 | (space-mark ?\xE20 [?\xE24] [?_]) ; hard space - currency |
| @@ -879,7 +879,7 @@ Used when `whitespace-style' includes `lines' or `lines-tail'." | |||
| 879 | ;; NEWLINE is displayed using the face `whitespace-newline' | 879 | ;; NEWLINE is displayed using the face `whitespace-newline' |
| 880 | (newline-mark ?\n [?$ ?\n]) ; eol - dollar sign | 880 | (newline-mark ?\n [?$ ?\n]) ; eol - dollar sign |
| 881 | ;; (newline-mark ?\n [?\u21B5 ?\n] [?$ ?\n]) ; eol - downwards arrow | 881 | ;; (newline-mark ?\n [?\u21B5 ?\n] [?$ ?\n]) ; eol - downwards arrow |
| 882 | ;; (newline-mark ?\n [?\xB6 ?\n] [?$ ?\n]) ; eol - pilcrow | 882 | ;; (newline-mark ?\n [?\u00B6 ?\n] [?$ ?\n]) ; eol - pilcrow |
| 883 | ;; (newline-mark ?\n [?\x8AF ?\n] [?$ ?\n]) ; eol - overscore | 883 | ;; (newline-mark ?\n [?\x8AF ?\n] [?$ ?\n]) ; eol - overscore |
| 884 | ;; (newline-mark ?\n [?\x8AC ?\n] [?$ ?\n]) ; eol - negation | 884 | ;; (newline-mark ?\n [?\x8AC ?\n] [?$ ?\n]) ; eol - negation |
| 885 | ;; (newline-mark ?\n [?\x8B0 ?\n] [?$ ?\n]) ; eol - grade | 885 | ;; (newline-mark ?\n [?\x8B0 ?\n] [?$ ?\n]) ; eol - grade |
| @@ -889,7 +889,7 @@ Used when `whitespace-style' includes `lines' or `lines-tail'." | |||
| 889 | ;; character ?\xBB at that column followed by a TAB which goes to | 889 | ;; character ?\xBB at that column followed by a TAB which goes to |
| 890 | ;; the next TAB column. | 890 | ;; the next TAB column. |
| 891 | ;; If this is a problem for you, please, comment the line below. | 891 | ;; If this is a problem for you, please, comment the line below. |
| 892 | (tab-mark ?\t [?\xBB ?\t] [?\\ ?\t]) ; tab - left quote mark | 892 | (tab-mark ?\t [?\u00BB ?\t] [?\\ ?\t]) ; tab - left quote mark |
| 893 | ) | 893 | ) |
| 894 | "Specify an alist of mappings for displaying characters. | 894 | "Specify an alist of mappings for displaying characters. |
| 895 | 895 | ||
| @@ -1220,6 +1220,14 @@ SYMBOL is a valid symbol associated with CHAR. | |||
| 1220 | (defvar whitespace-tab-width tab-width | 1220 | (defvar whitespace-tab-width tab-width |
| 1221 | "Used to save locally `tab-width' value.") | 1221 | "Used to save locally `tab-width' value.") |
| 1222 | 1222 | ||
| 1223 | (defvar whitespace-point (point) | ||
| 1224 | "Used to save locally current point value. | ||
| 1225 | Used by `whitespace-trailing-regexp' function (which see).") | ||
| 1226 | |||
| 1227 | (defvar whitespace-font-lock-refontify nil | ||
| 1228 | "Used to save locally the font-lock refontify state. | ||
| 1229 | Used by `whitespace-post-command-hook' function (which see).") | ||
| 1230 | |||
| 1223 | 1231 | ||
| 1224 | ;;;###autoload | 1232 | ;;;###autoload |
| 1225 | (defun whitespace-toggle-options (arg) | 1233 | (defun whitespace-toggle-options (arg) |
| @@ -2139,6 +2147,12 @@ resultant list will be returned." | |||
| 2139 | (setq whitespace-font-lock t | 2147 | (setq whitespace-font-lock t |
| 2140 | whitespace-font-lock-keywords | 2148 | whitespace-font-lock-keywords |
| 2141 | (copy-sequence font-lock-keywords))) | 2149 | (copy-sequence font-lock-keywords))) |
| 2150 | ;; save current point and refontify when necessary | ||
| 2151 | (set (make-local-variable 'whitespace-point) | ||
| 2152 | (point)) | ||
| 2153 | (set (make-local-variable 'whitespace-font-lock-refontify) | ||
| 2154 | nil) | ||
| 2155 | (add-hook 'post-command-hook #'whitespace-post-command-hook nil t) | ||
| 2142 | ;; turn off font lock | 2156 | ;; turn off font lock |
| 2143 | (set (make-local-variable 'whitespace-font-lock-mode) | 2157 | (set (make-local-variable 'whitespace-font-lock-mode) |
| 2144 | font-lock-mode) | 2158 | font-lock-mode) |
| @@ -2149,7 +2163,7 @@ resultant list will be returned." | |||
| 2149 | nil | 2163 | nil |
| 2150 | (list | 2164 | (list |
| 2151 | ;; Show SPACEs | 2165 | ;; Show SPACEs |
| 2152 | (list whitespace-space-regexp 1 whitespace-space t) | 2166 | (list #'whitespace-space-regexp 1 whitespace-space t) |
| 2153 | ;; Show HARD SPACEs | 2167 | ;; Show HARD SPACEs |
| 2154 | (list whitespace-hspace-regexp 1 whitespace-hspace t)) | 2168 | (list whitespace-hspace-regexp 1 whitespace-hspace t)) |
| 2155 | t)) | 2169 | t)) |
| @@ -2158,14 +2172,14 @@ resultant list will be returned." | |||
| 2158 | nil | 2172 | nil |
| 2159 | (list | 2173 | (list |
| 2160 | ;; Show TABs | 2174 | ;; Show TABs |
| 2161 | (list whitespace-tab-regexp 1 whitespace-tab t)) | 2175 | (list #'whitespace-tab-regexp 1 whitespace-tab t)) |
| 2162 | t)) | 2176 | t)) |
| 2163 | (when (memq 'trailing whitespace-active-style) | 2177 | (when (memq 'trailing whitespace-active-style) |
| 2164 | (font-lock-add-keywords | 2178 | (font-lock-add-keywords |
| 2165 | nil | 2179 | nil |
| 2166 | (list | 2180 | (list |
| 2167 | ;; Show trailing blanks | 2181 | ;; Show trailing blanks |
| 2168 | (list whitespace-trailing-regexp 1 whitespace-trailing t)) | 2182 | (list #'whitespace-trailing-regexp 1 whitespace-trailing t)) |
| 2169 | t)) | 2183 | t)) |
| 2170 | (when (or (memq 'lines whitespace-active-style) | 2184 | (when (or (memq 'lines whitespace-active-style) |
| 2171 | (memq 'lines-tail whitespace-active-style)) | 2185 | (memq 'lines-tail whitespace-active-style)) |
| @@ -2177,7 +2191,7 @@ resultant list will be returned." | |||
| 2177 | (format | 2191 | (format |
| 2178 | "^\\([^\t\n]\\{%s\\}\\|[^\t\n]\\{0,%s\\}\t\\)\\{%d\\}%s\\(.+\\)$" | 2192 | "^\\([^\t\n]\\{%s\\}\\|[^\t\n]\\{0,%s\\}\t\\)\\{%d\\}%s\\(.+\\)$" |
| 2179 | whitespace-tab-width (1- whitespace-tab-width) | 2193 | whitespace-tab-width (1- whitespace-tab-width) |
| 2180 | (/ whitespace-line-column tab-width) | 2194 | (/ whitespace-line-column whitespace-tab-width) |
| 2181 | (let ((rem (% whitespace-line-column whitespace-tab-width))) | 2195 | (let ((rem (% whitespace-line-column whitespace-tab-width))) |
| 2182 | (if (zerop rem) | 2196 | (if (zerop rem) |
| 2183 | "" | 2197 | "" |
| @@ -2243,14 +2257,14 @@ resultant list will be returned." | |||
| 2243 | nil | 2257 | nil |
| 2244 | (list | 2258 | (list |
| 2245 | ;; Show empty lines at beginning of buffer | 2259 | ;; Show empty lines at beginning of buffer |
| 2246 | (list whitespace-empty-at-bob-regexp | 2260 | (list #'whitespace-empty-at-bob-regexp |
| 2247 | 1 whitespace-empty t)) | 2261 | 1 whitespace-empty t)) |
| 2248 | t) | 2262 | t) |
| 2249 | (font-lock-add-keywords | 2263 | (font-lock-add-keywords |
| 2250 | nil | 2264 | nil |
| 2251 | (list | 2265 | (list |
| 2252 | ;; Show empty lines at end of buffer | 2266 | ;; Show empty lines at end of buffer |
| 2253 | (list whitespace-empty-at-eob-regexp | 2267 | (list #'whitespace-empty-at-eob-regexp |
| 2254 | 1 whitespace-empty t)) | 2268 | 1 whitespace-empty t)) |
| 2255 | t)) | 2269 | t)) |
| 2256 | (cond | 2270 | (cond |
| @@ -2287,12 +2301,60 @@ resultant list will be returned." | |||
| 2287 | ;; turn off font lock | 2301 | ;; turn off font lock |
| 2288 | (when (whitespace-style-face-p) | 2302 | (when (whitespace-style-face-p) |
| 2289 | (font-lock-mode 0) | 2303 | (font-lock-mode 0) |
| 2304 | (remove-hook 'post-command-hook #'whitespace-post-command-hook) | ||
| 2290 | (when whitespace-font-lock | 2305 | (when whitespace-font-lock |
| 2291 | (setq whitespace-font-lock nil | 2306 | (setq whitespace-font-lock nil |
| 2292 | font-lock-keywords whitespace-font-lock-keywords)) | 2307 | font-lock-keywords whitespace-font-lock-keywords)) |
| 2293 | ;; restore original font lock state | 2308 | ;; restore original font lock state |
| 2294 | (font-lock-mode whitespace-font-lock-mode))) | 2309 | (font-lock-mode whitespace-font-lock-mode))) |
| 2295 | 2310 | ||
| 2311 | |||
| 2312 | (defun whitespace-trailing-regexp (limit) | ||
| 2313 | "Match trailing spaces which does not contain the point at end of line." | ||
| 2314 | (let ((status t)) | ||
| 2315 | (while (if (re-search-forward whitespace-trailing-regexp limit t) | ||
| 2316 | (save-match-data | ||
| 2317 | (= whitespace-point (match-end 1))) ;; loop if point at eol | ||
| 2318 | (setq status nil))) ;; end of buffer | ||
| 2319 | status)) | ||
| 2320 | |||
| 2321 | |||
| 2322 | (defun whitespace-empty-at-bob-regexp (limit) | ||
| 2323 | "Match spaces at beginning of buffer which does not contain the point at \ | ||
| 2324 | beginning of buffer." | ||
| 2325 | (and (/= whitespace-point 1) | ||
| 2326 | (re-search-forward whitespace-empty-at-bob-regexp limit t))) | ||
| 2327 | |||
| 2328 | |||
| 2329 | (defun whitespace-empty-at-eob-regexp (limit) | ||
| 2330 | "Match spaces at end of buffer which does not contain the point at end of \ | ||
| 2331 | buffer." | ||
| 2332 | (and (/= whitespace-point (1+ (buffer-size))) | ||
| 2333 | (re-search-forward whitespace-empty-at-eob-regexp limit t))) | ||
| 2334 | |||
| 2335 | |||
| 2336 | (defun whitespace-space-regexp (limit) | ||
| 2337 | "Match spaces." | ||
| 2338 | (setq whitespace-font-lock-refontify t) | ||
| 2339 | (re-search-forward whitespace-space-regexp limit t)) | ||
| 2340 | |||
| 2341 | |||
| 2342 | (defun whitespace-tab-regexp (limit) | ||
| 2343 | "Match tabs." | ||
| 2344 | (setq whitespace-font-lock-refontify t) | ||
| 2345 | (re-search-forward whitespace-tab-regexp limit t)) | ||
| 2346 | |||
| 2347 | |||
| 2348 | (defun whitespace-post-command-hook () | ||
| 2349 | "Save current point into `whitespace-point' variable. | ||
| 2350 | Also refontify when necessary." | ||
| 2351 | (setq whitespace-point (point)) | ||
| 2352 | (let ((refontify (or (eolp) ; end of line | ||
| 2353 | (= whitespace-point 1)))) ; beginning of buffer | ||
| 2354 | (when (or whitespace-font-lock-refontify refontify) | ||
| 2355 | (setq whitespace-font-lock-refontify refontify) | ||
| 2356 | (jit-lock-refontify)))) | ||
| 2357 | |||
| 2296 | 2358 | ||
| 2297 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 2359 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 2298 | ;;;; Hacked from visws.el (Miles Bader <miles@gnu.org>) | 2360 | ;;;; Hacked from visws.el (Miles Bader <miles@gnu.org>) |