Mercurial > emacs
comparison lisp/whitespace.el @ 109971:e49f8c56fca8
Fix some bugs. New version 13.1.
author | Vinicius Jose Latorre <viniciusjl@ig.com.br |
---|---|
date | Tue, 24 Aug 2010 23:27:58 -0300 |
parents | 3ea5c230ba38 |
children | 5eae6917d2e0 |
comparison
equal
deleted
inserted
replaced
109970:77c4a65b9011 | 109971:e49f8c56fca8 |
---|---|
4 ;; Free Software Foundation, Inc. | 4 ;; Free Software Foundation, Inc. |
5 | 5 |
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: 13.0 | 9 ;; Version: 13.1 |
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. |
13 | 13 |
14 ;; GNU Emacs is free software: you can redistribute it and/or modify | 14 ;; GNU Emacs is free software: you can redistribute it and/or modify |
380 :version "23.1" | 380 :version "23.1" |
381 :group 'convenience) | 381 :group 'convenience) |
382 | 382 |
383 | 383 |
384 (defcustom whitespace-style | 384 (defcustom whitespace-style |
385 '(tabs spaces trailing lines space-before-tab newline | 385 '(face |
386 indentation empty space-after-tab | 386 tabs spaces trailing lines space-before-tab newline |
387 space-mark tab-mark newline-mark) | 387 indentation empty space-after-tab |
388 space-mark tab-mark newline-mark) | |
388 "Specify which kind of blank is visualized. | 389 "Specify which kind of blank is visualized. |
389 | 390 |
390 It's a list containing some or all of the following values: | 391 It's a list containing some or all of the following values: |
391 | 392 |
393 face enable all visualization via faces (see below). | |
394 | |
392 trailing trailing blanks are visualized via faces. | 395 trailing trailing blanks are visualized via faces. |
396 It has effect only if `face' (see above) | |
397 is present in `whitespace-style'. | |
393 | 398 |
394 tabs TABs are visualized via faces. | 399 tabs TABs are visualized via faces. |
400 It has effect only if `face' (see above) | |
401 is present in `whitespace-style'. | |
395 | 402 |
396 spaces SPACEs and HARD SPACEs are visualized via | 403 spaces SPACEs and HARD SPACEs are visualized via |
397 faces. | 404 faces. |
405 It has effect only if `face' (see above) | |
406 is present in `whitespace-style'. | |
398 | 407 |
399 lines lines which have columns beyond | 408 lines lines which have columns beyond |
400 `whitespace-line-column' are highlighted via | 409 `whitespace-line-column' are highlighted via |
401 faces. | 410 faces. |
402 Whole line is highlighted. | 411 Whole line is highlighted. |
403 It has precedence over `lines-tail' (see | 412 It has precedence over `lines-tail' (see |
404 below). | 413 below). |
414 It has effect only if `face' (see above) | |
415 is present in `whitespace-style'. | |
405 | 416 |
406 lines-tail lines which have columns beyond | 417 lines-tail lines which have columns beyond |
407 `whitespace-line-column' are highlighted via | 418 `whitespace-line-column' are highlighted via |
408 faces. | 419 faces. |
409 But only the part of line which goes | 420 But only the part of line which goes |
410 beyond `whitespace-line-column' column. | 421 beyond `whitespace-line-column' column. |
411 It has effect only if `lines' (see above) | 422 It has effect only if `lines' (see above) |
412 is not present in `whitespace-style'. | 423 is not present in `whitespace-style' |
424 and if `face' (see above) is present in | |
425 `whitespace-style'. | |
413 | 426 |
414 newline NEWLINEs are visualized via faces. | 427 newline NEWLINEs are visualized via faces. |
428 It has effect only if `face' (see above) | |
429 is present in `whitespace-style'. | |
415 | 430 |
416 empty empty lines at beginning and/or end of buffer | 431 empty empty lines at beginning and/or end of buffer |
417 are visualized via faces. | 432 are visualized via faces. |
433 It has effect only if `face' (see above) | |
434 is present in `whitespace-style'. | |
418 | 435 |
419 indentation::tab 8 or more SPACEs at beginning of line are | 436 indentation::tab 8 or more SPACEs at beginning of line are |
420 visualized via faces. | 437 visualized via faces. |
438 It has effect only if `face' (see above) | |
439 is present in `whitespace-style'. | |
421 | 440 |
422 indentation::space TABs at beginning of line are visualized via | 441 indentation::space TABs at beginning of line are visualized via |
423 faces. | 442 faces. |
443 It has effect only if `face' (see above) | |
444 is present in `whitespace-style'. | |
424 | 445 |
425 indentation 8 or more SPACEs at beginning of line are | 446 indentation 8 or more SPACEs at beginning of line are |
426 visualized, if `indent-tabs-mode' (which see) | 447 visualized, if `indent-tabs-mode' (which see) |
427 is non-nil; otherwise, TABs at beginning of | 448 is non-nil; otherwise, TABs at beginning of |
428 line are visualized via faces. | 449 line are visualized via faces. |
450 It has effect only if `face' (see above) | |
451 is present in `whitespace-style'. | |
429 | 452 |
430 space-after-tab::tab 8 or more SPACEs after a TAB are | 453 space-after-tab::tab 8 or more SPACEs after a TAB are |
431 visualized via faces. | 454 visualized via faces. |
455 It has effect only if `face' (see above) | |
456 is present in `whitespace-style'. | |
432 | 457 |
433 space-after-tab::space TABs are visualized when 8 or more | 458 space-after-tab::space TABs are visualized when 8 or more |
434 SPACEs occur after a TAB, via faces. | 459 SPACEs occur after a TAB, via faces. |
460 It has effect only if `face' (see above) | |
461 is present in `whitespace-style'. | |
435 | 462 |
436 space-after-tab 8 or more SPACEs after a TAB are | 463 space-after-tab 8 or more SPACEs after a TAB are |
437 visualized, if `indent-tabs-mode' | 464 visualized, if `indent-tabs-mode' |
438 (which see) is non-nil; otherwise, | 465 (which see) is non-nil; otherwise, |
439 the TABs are visualized via faces. | 466 the TABs are visualized via faces. |
467 It has effect only if `face' (see above) | |
468 is present in `whitespace-style'. | |
440 | 469 |
441 space-before-tab::tab SPACEs before TAB are visualized via | 470 space-before-tab::tab SPACEs before TAB are visualized via |
442 faces. | 471 faces. |
472 It has effect only if `face' (see above) | |
473 is present in `whitespace-style'. | |
443 | 474 |
444 space-before-tab::space TABs are visualized when SPACEs occur | 475 space-before-tab::space TABs are visualized when SPACEs occur |
445 before TAB, via faces. | 476 before TAB, via faces. |
477 It has effect only if `face' (see above) | |
478 is present in `whitespace-style'. | |
446 | 479 |
447 space-before-tab SPACEs before TAB are visualized, if | 480 space-before-tab SPACEs before TAB are visualized, if |
448 `indent-tabs-mode' (which see) is | 481 `indent-tabs-mode' (which see) is |
449 non-nil; otherwise, the TABs are | 482 non-nil; otherwise, the TABs are |
450 visualized via faces. | 483 visualized via faces. |
484 It has effect only if `face' (see above) | |
485 is present in `whitespace-style'. | |
451 | 486 |
452 space-mark SPACEs and HARD SPACEs are visualized via | 487 space-mark SPACEs and HARD SPACEs are visualized via |
453 display table. | 488 display table. |
454 | 489 |
455 tab-mark TABs are visualized via display table. | 490 tab-mark TABs are visualized via display table. |
483 3. space-before-tab::space | 518 3. space-before-tab::space |
484 | 519 |
485 So, for example, if indentation and indentation::space are | 520 So, for example, if indentation and indentation::space are |
486 included in `whitespace-style' list, the indentation value is | 521 included in `whitespace-style' list, the indentation value is |
487 evaluated instead of indentation::space value. | 522 evaluated instead of indentation::space value. |
523 | |
524 One reason for not visualize spaces via faces (if `face' is not | |
525 included in `whitespace-style') is to use exclusively for | |
526 cleanning up a buffer. See `whitespace-cleanup' and | |
527 `whitespace-cleanup-region' for documentation. | |
488 | 528 |
489 See also `whitespace-display-mappings' for documentation." | 529 See also `whitespace-display-mappings' for documentation." |
490 :type '(repeat :tag "Kind of Blank" | 530 :type '(repeat :tag "Kind of Blank" |
491 (choice :tag "Kind of Blank Face" | 531 (choice :tag "Kind of Blank Face" |
492 (const :tag "(Face) Trailing TABs, SPACEs and HARD SPACEs" | 532 (const :tag "(Face) Trailing TABs, SPACEs and HARD SPACEs" |
519 :group 'whitespace) | 559 :group 'whitespace) |
520 | 560 |
521 | 561 |
522 (defface whitespace-space | 562 (defface whitespace-space |
523 '((((class color) (background dark)) | 563 '((((class color) (background dark)) |
524 (:background "grey20" :foreground "aquamarine3")) | 564 (:background "grey20" :foreground "darkgray")) |
525 (((class color) (background light)) | 565 (((class color) (background light)) |
526 (:background "LightYellow" :foreground "aquamarine3")) | 566 (:background "LightYellow" :foreground "lightgray")) |
527 (t (:inverse-video t))) | 567 (t (:inverse-video t))) |
528 "Face used to visualize SPACE." | 568 "Face used to visualize SPACE." |
529 :group 'whitespace) | 569 :group 'whitespace) |
530 | 570 |
531 | 571 |
537 :group 'whitespace) | 577 :group 'whitespace) |
538 | 578 |
539 | 579 |
540 (defface whitespace-hspace ; 'nobreak-space | 580 (defface whitespace-hspace ; 'nobreak-space |
541 '((((class color) (background dark)) | 581 '((((class color) (background dark)) |
542 (:background "grey24" :foreground "aquamarine3")) | 582 (:background "grey24" :foreground "darkgray")) |
543 (((class color) (background light)) | 583 (((class color) (background light)) |
544 (:background "LemonChiffon3" :foreground "aquamarine3")) | 584 (:background "LemonChiffon3" :foreground "lightgray")) |
545 (t (:inverse-video t))) | 585 (t (:inverse-video t))) |
546 "Face used to visualize HARD SPACE." | 586 "Face used to visualize HARD SPACE." |
547 :group 'whitespace) | 587 :group 'whitespace) |
548 | 588 |
549 | 589 |
555 :group 'whitespace) | 595 :group 'whitespace) |
556 | 596 |
557 | 597 |
558 (defface whitespace-tab | 598 (defface whitespace-tab |
559 '((((class color) (background dark)) | 599 '((((class color) (background dark)) |
560 (:background "grey22" :foreground "aquamarine3")) | 600 (:background "grey22" :foreground "darkgray")) |
561 (((class color) (background light)) | 601 (((class color) (background light)) |
562 (:background "beige" :foreground "aquamarine3")) | 602 (:background "beige" :foreground "lightgray")) |
563 (t (:inverse-video t))) | 603 (t (:inverse-video t))) |
564 "Face used to visualize TAB." | 604 "Face used to visualize TAB." |
565 :group 'whitespace) | 605 :group 'whitespace) |
566 | 606 |
567 | 607 |
864 | 904 |
865 | 905 |
866 (defcustom whitespace-line-column 80 | 906 (defcustom whitespace-line-column 80 |
867 "Specify column beyond which the line is highlighted. | 907 "Specify column beyond which the line is highlighted. |
868 | 908 |
909 It must be an integer or nil. If nil, the `fill-column' variable value is | |
910 used. | |
911 | |
869 Used when `whitespace-style' includes `lines' or `lines-tail'." | 912 Used when `whitespace-style' includes `lines' or `lines-tail'." |
870 :type '(integer :tag "Line Length") | 913 :type '(choice :tag "Line Length Limit" |
914 (integer :tag "Line Length") | |
915 (const :tag "Use fill-column" nil)) | |
871 :group 'whitespace) | 916 :group 'whitespace) |
872 | 917 |
873 | 918 |
874 ;; Hacked from `visible-whitespace-mappings' in visws.el | 919 ;; Hacked from `visible-whitespace-mappings' in visws.el |
875 (defcustom whitespace-display-mappings | 920 (defcustom whitespace-display-mappings |
1149 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 1194 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1150 ;;;; User commands - Toggle | 1195 ;;;; User commands - Toggle |
1151 | 1196 |
1152 | 1197 |
1153 (defconst whitespace-style-value-list | 1198 (defconst whitespace-style-value-list |
1154 '(tabs | 1199 '(face |
1200 tabs | |
1155 spaces | 1201 spaces |
1156 trailing | 1202 trailing |
1157 lines | 1203 lines |
1158 lines-tail | 1204 lines-tail |
1159 newline | 1205 newline |
1174 ) | 1220 ) |
1175 "List of valid `whitespace-style' values.") | 1221 "List of valid `whitespace-style' values.") |
1176 | 1222 |
1177 | 1223 |
1178 (defconst whitespace-toggle-option-alist | 1224 (defconst whitespace-toggle-option-alist |
1179 '((?t . tabs) | 1225 '((?f . face) |
1226 (?t . tabs) | |
1180 (?s . spaces) | 1227 (?s . spaces) |
1181 (?r . trailing) | 1228 (?r . trailing) |
1182 (?l . lines) | 1229 (?l . lines) |
1183 (?L . lines-tail) | 1230 (?L . lines-tail) |
1184 (?n . newline) | 1231 (?n . newline) |
1254 | 1301 |
1255 Interactively, it reads one of the following chars: | 1302 Interactively, it reads one of the following chars: |
1256 | 1303 |
1257 CHAR MEANING | 1304 CHAR MEANING |
1258 (VIA FACES) | 1305 (VIA FACES) |
1306 f toggle face visualization | |
1259 t toggle TAB visualization | 1307 t toggle TAB visualization |
1260 s toggle SPACE and HARD SPACE visualization | 1308 s toggle SPACE and HARD SPACE visualization |
1261 r toggle trailing blanks visualization | 1309 r toggle trailing blanks visualization |
1262 l toggle \"long lines\" visualization | 1310 l toggle \"long lines\" visualization |
1263 L toggle \"long lines\" tail visualization | 1311 L toggle \"long lines\" tail visualization |
1282 ? display brief help | 1330 ? display brief help |
1283 | 1331 |
1284 Non-interactively, ARG should be a symbol or a list of symbols. | 1332 Non-interactively, ARG should be a symbol or a list of symbols. |
1285 The valid symbols are: | 1333 The valid symbols are: |
1286 | 1334 |
1335 face toggle face visualization | |
1287 tabs toggle TAB visualization | 1336 tabs toggle TAB visualization |
1288 spaces toggle SPACE and HARD SPACE visualization | 1337 spaces toggle SPACE and HARD SPACE visualization |
1289 trailing toggle trailing blanks visualization | 1338 trailing toggle trailing blanks visualization |
1290 lines toggle \"long lines\" visualization | 1339 lines toggle \"long lines\" visualization |
1291 lines-tail toggle \"long lines\" tail visualization | 1340 lines-tail toggle \"long lines\" tail visualization |
1331 | 1380 |
1332 Interactively, it accepts one of the following chars: | 1381 Interactively, it accepts one of the following chars: |
1333 | 1382 |
1334 CHAR MEANING | 1383 CHAR MEANING |
1335 (VIA FACES) | 1384 (VIA FACES) |
1385 f toggle face visualization | |
1336 t toggle TAB visualization | 1386 t toggle TAB visualization |
1337 s toggle SPACE and HARD SPACE visualization | 1387 s toggle SPACE and HARD SPACE visualization |
1338 r toggle trailing blanks visualization | 1388 r toggle trailing blanks visualization |
1339 l toggle \"long lines\" visualization | 1389 l toggle \"long lines\" visualization |
1340 L toggle \"long lines\" tail visualization | 1390 L toggle \"long lines\" tail visualization |
1359 ? display brief help | 1409 ? display brief help |
1360 | 1410 |
1361 Non-interactively, ARG should be a symbol or a list of symbols. | 1411 Non-interactively, ARG should be a symbol or a list of symbols. |
1362 The valid symbols are: | 1412 The valid symbols are: |
1363 | 1413 |
1414 face toggle face visualization | |
1364 tabs toggle TAB visualization | 1415 tabs toggle TAB visualization |
1365 spaces toggle SPACE and HARD SPACE visualization | 1416 spaces toggle SPACE and HARD SPACE visualization |
1366 trailing toggle trailing blanks visualization | 1417 trailing toggle trailing blanks visualization |
1367 lines toggle \"long lines\" visualization | 1418 lines toggle \"long lines\" visualization |
1368 lines-tail toggle \"long lines\" tail visualization | 1419 lines-tail toggle \"long lines\" tail visualization |
1888 "Used to save locally `font-lock-keywords' value.") | 1939 "Used to save locally `font-lock-keywords' value.") |
1889 | 1940 |
1890 | 1941 |
1891 (defconst whitespace-help-text | 1942 (defconst whitespace-help-text |
1892 "\ | 1943 "\ |
1893 Whitespace Toggle Options | 1944 Whitespace Toggle Options | scroll up : SPC or > | |
1894 | 1945 | scroll down: M-SPC or < | |
1895 FACES | 1946 FACES \\__________________________/ |
1947 [] f - toggle face visualization | |
1896 [] t - toggle TAB visualization | 1948 [] t - toggle TAB visualization |
1897 [] s - toggle SPACE and HARD SPACE visualization | 1949 [] s - toggle SPACE and HARD SPACE visualization |
1898 [] r - toggle trailing blanks visualization | 1950 [] r - toggle trailing blanks visualization |
1899 [] l - toggle \"long lines\" visualization | 1951 [] l - toggle \"long lines\" visualization |
1900 [] L - toggle \"long lines\" tail visualization | 1952 [] L - toggle \"long lines\" tail visualization |
1964 | 2016 |
1965 (defun whitespace-display-window (buffer) | 2017 (defun whitespace-display-window (buffer) |
1966 "Display BUFFER in a new window." | 2018 "Display BUFFER in a new window." |
1967 (goto-char (point-min)) | 2019 (goto-char (point-min)) |
1968 (set-buffer-modified-p nil) | 2020 (set-buffer-modified-p nil) |
1969 (let ((size (- (window-height) | 2021 (when (< (window-height) (* 2 window-min-height)) |
1970 (max window-min-height | 2022 (kill-buffer buffer) |
1971 (1+ (count-lines (point-min) | 2023 (error "Window height is too small; \ |
1972 (point-max))))))) | |
1973 (when (<= size 0) | |
1974 (kill-buffer buffer) | |
1975 (error "Frame height is too small; \ | |
1976 can't split window to display whitespace toggle options")) | 2024 can't split window to display whitespace toggle options")) |
1977 (set-window-buffer (split-window nil size) buffer))) | 2025 (let ((win (split-window))) |
2026 (set-window-buffer win buffer) | |
2027 (shrink-window-if-larger-than-buffer win))) | |
1978 | 2028 |
1979 | 2029 |
1980 (defun whitespace-kill-buffer (buffer-name) | 2030 (defun whitespace-kill-buffer (buffer-name) |
1981 "Kill buffer BUFFER-NAME and windows related with it." | 2031 "Kill buffer BUFFER-NAME and windows related with it." |
1982 (let ((buffer (get-buffer buffer-name))) | 2032 (let ((buffer (get-buffer buffer-name))) |
1988 (defun whitespace-help-off () | 2038 (defun whitespace-help-off () |
1989 "Remove the buffer and window of the whitespace toggle options." | 2039 "Remove the buffer and window of the whitespace toggle options." |
1990 (whitespace-kill-buffer whitespace-help-buffer-name)) | 2040 (whitespace-kill-buffer whitespace-help-buffer-name)) |
1991 | 2041 |
1992 | 2042 |
2043 (defun whitespace-help-scroll (&optional up) | |
2044 "Scroll help window, if it exists. | |
2045 | |
2046 If UP is non-nil, scroll up; otherwise, scroll down." | |
2047 (condition-case data-help | |
2048 (let ((buffer (get-buffer whitespace-help-buffer-name))) | |
2049 (if buffer | |
2050 (with-selected-window (get-buffer-window buffer) | |
2051 (if up | |
2052 (scroll-up 3) | |
2053 (scroll-down 3))) | |
2054 (ding))) | |
2055 ;; handler | |
2056 ((error) | |
2057 ;; just ignore error | |
2058 ))) | |
2059 | |
2060 | |
1993 (defun whitespace-interactive-char (local-p) | 2061 (defun whitespace-interactive-char (local-p) |
1994 "Interactive function to read a char and return a symbol. | 2062 "Interactive function to read a char and return a symbol. |
1995 | 2063 |
1996 If LOCAL-P is non-nil, it uses a local context; otherwise, it | 2064 If LOCAL-P is non-nil, it uses a local context; otherwise, it |
1997 uses a global context. | 2065 uses a global context. |
1998 | 2066 |
1999 It accepts one of the following chars: | 2067 It accepts one of the following chars: |
2000 | 2068 |
2001 CHAR MEANING | 2069 CHAR MEANING |
2002 (VIA FACES) | 2070 (VIA FACES) |
2071 f toggle face visualization | |
2003 t toggle TAB visualization | 2072 t toggle TAB visualization |
2004 s toggle SPACE and HARD SPACE visualization | 2073 s toggle SPACE and HARD SPACE visualization |
2005 r toggle trailing blanks visualization | 2074 r toggle trailing blanks visualization |
2006 l toggle \"long lines\" visualization | 2075 l toggle \"long lines\" visualization |
2007 L toggle \"long lines\" tail visualization | 2076 L toggle \"long lines\" tail visualization |
2047 (not | 2116 (not |
2048 (setq sym | 2117 (setq sym |
2049 (cdr | 2118 (cdr |
2050 (assq ch whitespace-toggle-option-alist))))) | 2119 (assq ch whitespace-toggle-option-alist))))) |
2051 ;; while body | 2120 ;; while body |
2052 (if (eq ch ?\?) | 2121 (cond |
2053 (whitespace-help-on style) | 2122 ((eq ch ?\?) (whitespace-help-on style)) |
2054 (ding))) | 2123 ((eq ch ?\ ) (whitespace-help-scroll t)) |
2124 ((eq ch ?\M- ) (whitespace-help-scroll)) | |
2125 ((eq ch ?>) (whitespace-help-scroll t)) | |
2126 ((eq ch ?<) (whitespace-help-scroll)) | |
2127 (t (ding)))) | |
2055 (whitespace-help-off) | 2128 (whitespace-help-off) |
2056 (message " ")) ; clean echo area | 2129 (message " ")) ; clean echo area |
2057 ;; handler | 2130 ;; handler |
2058 ((quit error) | 2131 ((quit error) |
2059 (whitespace-help-off) | 2132 (whitespace-help-off) |
2128 (whitespace-display-char-off))) | 2201 (whitespace-display-char-off))) |
2129 | 2202 |
2130 | 2203 |
2131 (defun whitespace-style-face-p () | 2204 (defun whitespace-style-face-p () |
2132 "Return t if there is some visualization via face." | 2205 "Return t if there is some visualization via face." |
2133 (or (memq 'tabs whitespace-active-style) | 2206 (and (memq 'face whitespace-active-style) |
2134 (memq 'spaces whitespace-active-style) | 2207 (or (memq 'tabs whitespace-active-style) |
2135 (memq 'trailing whitespace-active-style) | 2208 (memq 'spaces whitespace-active-style) |
2136 (memq 'lines whitespace-active-style) | 2209 (memq 'trailing whitespace-active-style) |
2137 (memq 'lines-tail whitespace-active-style) | 2210 (memq 'lines whitespace-active-style) |
2138 (memq 'newline whitespace-active-style) | 2211 (memq 'lines-tail whitespace-active-style) |
2139 (memq 'empty whitespace-active-style) | 2212 (memq 'newline whitespace-active-style) |
2140 (memq 'indentation whitespace-active-style) | 2213 (memq 'empty whitespace-active-style) |
2141 (memq 'indentation::tab whitespace-active-style) | 2214 (memq 'indentation whitespace-active-style) |
2142 (memq 'indentation::space whitespace-active-style) | 2215 (memq 'indentation::tab whitespace-active-style) |
2143 (memq 'space-after-tab whitespace-active-style) | 2216 (memq 'indentation::space whitespace-active-style) |
2144 (memq 'space-after-tab::tab whitespace-active-style) | 2217 (memq 'space-after-tab whitespace-active-style) |
2145 (memq 'space-after-tab::space whitespace-active-style) | 2218 (memq 'space-after-tab::tab whitespace-active-style) |
2146 (memq 'space-before-tab whitespace-active-style) | 2219 (memq 'space-after-tab::space whitespace-active-style) |
2147 (memq 'space-before-tab::tab whitespace-active-style) | 2220 (memq 'space-before-tab whitespace-active-style) |
2148 (memq 'space-before-tab::space whitespace-active-style))) | 2221 (memq 'space-before-tab::tab whitespace-active-style) |
2222 (memq 'space-before-tab::space whitespace-active-style)))) | |
2149 | 2223 |
2150 | 2224 |
2151 (defun whitespace-color-on () | 2225 (defun whitespace-color-on () |
2152 "Turn on color visualization." | 2226 "Turn on color visualization." |
2153 (when (whitespace-style-face-p) | 2227 (when (whitespace-style-face-p) |
2201 (font-lock-add-keywords | 2275 (font-lock-add-keywords |
2202 nil | 2276 nil |
2203 (list | 2277 (list |
2204 ;; Show "long" lines | 2278 ;; Show "long" lines |
2205 (list | 2279 (list |
2206 (format | 2280 (let ((line-column (or whitespace-line-column fill-column))) |
2207 "^\\([^\t\n]\\{%s\\}\\|[^\t\n]\\{0,%s\\}\t\\)\\{%d\\}%s\\(.+\\)$" | 2281 (format |
2208 whitespace-tab-width (1- whitespace-tab-width) | 2282 "^\\([^\t\n]\\{%s\\}\\|[^\t\n]\\{0,%s\\}\t\\)\\{%d\\}%s\\(.+\\)$" |
2209 (/ whitespace-line-column whitespace-tab-width) | 2283 whitespace-tab-width |
2210 (let ((rem (% whitespace-line-column whitespace-tab-width))) | 2284 (1- whitespace-tab-width) |
2211 (if (zerop rem) | 2285 (/ line-column whitespace-tab-width) |
2212 "" | 2286 (let ((rem (% line-column whitespace-tab-width))) |
2213 (format ".\\{%d\\}" rem)))) | 2287 (if (zerop rem) |
2288 "" | |
2289 (format ".\\{%d\\}" rem))))) | |
2214 (if (memq 'lines whitespace-active-style) | 2290 (if (memq 'lines whitespace-active-style) |
2215 0 ; whole line | 2291 0 ; whole line |
2216 2) ; line tail | 2292 2) ; line tail |
2217 whitespace-line t)) | 2293 whitespace-line t)) |
2218 t)) | 2294 t)) |