aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVinicius Jose Latorre2008-01-25 14:10:35 +0000
committerVinicius Jose Latorre2008-01-25 14:10:35 +0000
commit0feb2f35d3748400f297f6c608809018bb2b9da1 (patch)
treee73bd5b205bcaab11d49df62a237571424e6c7a9
parenta981bee972f9c0382aaeff9f6c7c0a55433bda88 (diff)
downloademacs-0feb2f35d3748400f297f6c608809018bb2b9da1.tar.gz
emacs-0feb2f35d3748400f297f6c608809018bb2b9da1.zip
New commands for cleaning up some blank problems like trailing blanks.
-rw-r--r--lisp/ChangeLog15
-rw-r--r--lisp/blank-mode.el395
2 files changed, 403 insertions, 7 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index b620ff1e667..47e983862b7 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,18 @@
12008-01-25 Vinicius Jose Latorre <viniciusjl@ig.com.br>
2
3 * blank-mode.el: New version 9.0. New commands to clean up some blank
4 problems like trailing blanks. New faces and regexp for visualizing
5 the blank problems. Doc fix.
6 (blank-chars, blank-global-modes, blank-chars-value-list)
7 (blank-toggle-option-alist, blank-help-text): Initialization fix.
8 (blank-indentation, blank-empty, blank-space-after-tab): New faces.
9 (blank-indentation, blank-empty, blank-space-after-tab)
10 (blank-indentation-regexp, blank-empty-at-bob-regexp)
11 (blank-empty-at-eob-regexp, blank-space-after-tab-regexp): New
12 options.
13 (blank-cleanup, blank-cleanup-region): New commands.
14 (blank-color-on): Code fix.
15
12008-01-25 Sven Joachim <svenjoac@gmx.de> 162008-01-25 Sven Joachim <svenjoac@gmx.de>
2 17
3 * view.el (kill-buffer-if-not-modified): Don't pass t to 18 * view.el (kill-buffer-if-not-modified): Don't pass t to
diff --git a/lisp/blank-mode.el b/lisp/blank-mode.el
index 9d36ebde6ae..315ac99ea7b 100644
--- a/lisp/blank-mode.el
+++ b/lisp/blank-mode.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: 8.1 9;; Version: 9.0
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.
@@ -100,6 +100,10 @@
100;; 100;;
101;; blank-mode was inspired by: 101;; blank-mode was inspired by:
102;; 102;;
103;; whitespace.el Rajesh Vaidheeswarran <rv@gnu.org>
104;; Warn about and clean bogus whitespaces in the file
105;; (inspired the idea to warn and clean some blanks)
106;;
103;; show-whitespace-mode.el Aurelien Tisne <aurelien.tisne@free.fr> 107;; show-whitespace-mode.el Aurelien Tisne <aurelien.tisne@free.fr>
104;; Simple mode to highlight whitespaces 108;; Simple mode to highlight whitespaces
105;; (inspired the idea to use font-lock) 109;; (inspired the idea to use font-lock)
@@ -153,6 +157,37 @@
153;; 157;;
154;; M-x global-blank-mode RET 158;; M-x global-blank-mode RET
155;; 159;;
160;; There are also the following useful commands:
161;;
162;; `blank-cleanup'
163;; Cleanup some blank problems in all buffer or at region.
164;;
165;; `blank-cleanup-region'
166;; Cleanup some blank problems at region.
167;;
168;; The problems, which are cleaned up, are:
169;;
170;; 1. empty lines at beginning of buffer.
171;; 2. empty lines at end of buffer.
172;; If `blank-chars' has `empty' as an element, remove all empty
173;; lines at beginning and/or end of buffer.
174;;
175;; 3. 8 or more SPACEs at beginning of line.
176;; If `blank-chars' has `indentation' as an element, replace 8 or
177;; more SPACEs at beginning of line by TABs.
178;;
179;; 4. SPACEs before TAB.
180;; If `blank-chars' has `space-before-tab' as an element, replace
181;; SPACEs by TABs.
182;;
183;; 5. SPACEs or TABs at end of line.
184;; If `blank-chars' has `trailing' as an element, remove all
185;; SPACEs or TABs at end of line."
186;;
187;; 6. 8 or more SPACEs after TAB.
188;; If `blank-chars' has `space-after-tab' as an element, replace
189;; SPACEs by TABs.
190;;
156;; 191;;
157;; Hooks 192;; Hooks
158;; ----- 193;; -----
@@ -197,6 +232,15 @@
197;; `blank-space-before-tab' Face used to visualize SPACEs before 232;; `blank-space-before-tab' Face used to visualize SPACEs before
198;; TAB. 233;; TAB.
199;; 234;;
235;; `blank-indentation' Face used to visualize 8 or more
236;; SPACEs at beginning of line.
237;;
238;; `blank-empty' Face used to visualize empty lines at
239;; beginning and/or end of buffer.
240;;
241;; `blank-space-after-tab' Face used to visualize 8 or more
242;; SPACEs after TAB.
243;;
200;; `blank-space-regexp' Specify SPACE characters regexp. 244;; `blank-space-regexp' Specify SPACE characters regexp.
201;; 245;;
202;; `blank-hspace-regexp' Specify HARD SPACE characters regexp. 246;; `blank-hspace-regexp' Specify HARD SPACE characters regexp.
@@ -208,6 +252,18 @@
208;; `blank-space-before-tab-regexp' Specify SPACEs before TAB 252;; `blank-space-before-tab-regexp' Specify SPACEs before TAB
209;; regexp. 253;; regexp.
210;; 254;;
255;; `blank-indentation-regexp' Specify regexp for 8 or more SPACEs at
256;; beginning of line.
257;;
258;; `blank-empty-at-bob-regexp' Specify regexp for empty lines at
259;; beginning of buffer.
260;;
261;; `blank-empty-at-eob-regexp' Specify regexp for empty lines at end
262;; of buffer.
263;;
264;; `blank-space-after-tab-regexp' Specify regexp for 8 or more
265;; SPACEs after TAB.
266;;
211;; `blank-line-length' Specify length beyond which the line 267;; `blank-line-length' Specify length beyond which the line
212;; is highlighted. 268;; is highlighted.
213;; 269;;
@@ -249,6 +305,7 @@
249;; visws.el (his code was modified, but the main idea was kept). 305;; visws.el (his code was modified, but the main idea was kept).
250;; 306;;
251;; Thanks to: 307;; Thanks to:
308;; Rajesh Vaidheeswarran <rv@gnu.org> whitespace.el
252;; Aurelien Tisne <aurelien.tisne@free.fr> show-whitespace-mode.el 309;; Aurelien Tisne <aurelien.tisne@free.fr> show-whitespace-mode.el
253;; Lawrence Mitchell <wence@gmx.li> whitespace-mode.el 310;; Lawrence Mitchell <wence@gmx.li> whitespace-mode.el
254;; Miles Bader <miles@gnu.org> visws.el 311;; Miles Bader <miles@gnu.org> visws.el
@@ -297,7 +354,8 @@ See also `blank-display-mappings' for documentation."
297 354
298 355
299(defcustom blank-chars 356(defcustom blank-chars
300 '(tabs spaces trailing lines space-before-tab newline) 357 '(tabs spaces trailing lines space-before-tab newline
358 indentation empty space-after-tab)
301 "*Specify which kind of blank is visualized. 359 "*Specify which kind of blank is visualized.
302 360
303It's a list which element value can be: 361It's a list which element value can be:
@@ -315,6 +373,14 @@ It's a list which element value can be:
315 373
316 newline NEWLINEs are visualized. 374 newline NEWLINEs are visualized.
317 375
376 indentation 8 or more SPACEs at beginning of line are
377 visualized.
378
379 empty empty lines at beginning and/or end of buffer
380 are visualized.
381
382 space-after-tab 8 or more SPACEs after a TAB are visualized.
383
318Any other value is ignored. 384Any other value is ignored.
319 385
320If nil, don't visualize TABs, (HARD) SPACEs and NEWLINEs. 386If nil, don't visualize TABs, (HARD) SPACEs and NEWLINEs.
@@ -331,7 +397,12 @@ has `mark' as an element."
331 (const :tag "Lines" lines) 397 (const :tag "Lines" lines)
332 (const :tag "SPACEs before TAB" 398 (const :tag "SPACEs before TAB"
333 space-before-tab) 399 space-before-tab)
334 (const :tag "NEWLINEs" newline))) 400 (const :tag "NEWLINEs" newline)
401 (const :tag "Indentation SPACEs" indentation)
402 (const :tag "Empty Lines At BOB And/Or EOB"
403 empty)
404 (const :tag "SPACEs after TAB"
405 space-after-tab)))
335 :group 'blank) 406 :group 'blank)
336 407
337 408
@@ -461,6 +532,51 @@ Used when `blank-style' has `color' as an element."
461 :group 'blank) 532 :group 'blank)
462 533
463 534
535(defcustom blank-indentation 'blank-indentation
536 "*Symbol face used to visualize 8 or more SPACEs at beginning of line.
537
538Used when `blank-style' has `color' as an element."
539 :type 'face
540 :group 'blank)
541
542
543(defface blank-indentation
544 '((((class mono)) (:inverse-video t :bold t :underline t))
545 (t (:background "yellow" :foreground "firebrick")))
546 "Face used to visualize 8 or more SPACEs at beginning of line."
547 :group 'blank)
548
549
550(defcustom blank-empty 'blank-empty
551 "*Symbol face used to visualize empty lines at beginning and/or end of buffer.
552
553Used when `blank-style' has `color' as an element."
554 :type 'face
555 :group 'blank)
556
557
558(defface blank-empty
559 '((((class mono)) (:inverse-video t :bold t :underline t))
560 (t (:background "yellow" :foreground "firebrick")))
561 "Face used to visualize empty lines at beginning and/or end of buffer."
562 :group 'blank)
563
564
565(defcustom blank-space-after-tab 'blank-space-after-tab
566 "*Symbol face used to visualize 8 or more SPACEs after TAB.
567
568Used when `blank-style' has `color' as an element."
569 :type 'face
570 :group 'blank)
571
572
573(defface blank-space-after-tab
574 '((((class mono)) (:inverse-video t :bold t :underline t))
575 (t (:background "yellow" :foreground "firebrick")))
576 "Face used to visualize 8 or more SPACEs after TAB."
577 :group 'blank)
578
579
464(defcustom blank-hspace-regexp 580(defcustom blank-hspace-regexp
465 "\\(\\(\xA0\\|\x8A0\\|\x920\\|\xE20\\|\xF20\\)+\\)" 581 "\\(\\(\xA0\\|\x8A0\\|\x920\\|\xE20\\|\xF20\\)+\\)"
466 "*Specify HARD SPACE characters regexp. 582 "*Specify HARD SPACE characters regexp.
@@ -574,6 +690,70 @@ Used when `blank-style' has `color' as an element, and
574 :group 'blank) 690 :group 'blank)
575 691
576 692
693(defcustom blank-indentation-regexp "^\t*\\(\\( \\{8\\}\\)+\\)[^\n\t]"
694 "*Specify regexp for 8 or more SPACEs at beginning of line.
695
696If you're using `mule' package, it may exist other characters besides:
697
698 \" \" \"\\t\" \"\\xA0\" \"\\x8A0\" \"\\x920\" \"\\xE20\" \
699\"\\xF20\"
700
701that should be considered blank.
702
703Used when `blank-style' has `color' as an element, and
704`blank-chars' has `indentation' as an element."
705 :type '(regexp :tag "Indentation SPACEs")
706 :group 'blank)
707
708
709(defcustom blank-empty-at-bob-regexp "\\`\\(\\([ \t]*\n\\)+\\)"
710 "*Specify regexp for empty lines at beginning of buffer.
711
712If you're using `mule' package, it may exist other characters besides:
713
714 \" \" \"\\t\" \"\\xA0\" \"\\x8A0\" \"\\x920\" \"\\xE20\" \
715\"\\xF20\"
716
717that should be considered blank.
718
719Used when `blank-style' has `color' as an element, and
720`blank-chars' has `empty' as an element."
721 :type '(regexp :tag "Empty Lines At Beginning Of Buffer")
722 :group 'blank)
723
724
725(defcustom blank-empty-at-eob-regexp "^\\([ \t\n]+\\)\\'"
726 "*Specify regexp for empty lines at end of buffer.
727
728If you're using `mule' package, it may exist other characters besides:
729
730 \" \" \"\\t\" \"\\xA0\" \"\\x8A0\" \"\\x920\" \"\\xE20\" \
731\"\\xF20\"
732
733that should be considered blank.
734
735Used when `blank-style' has `color' as an element, and
736`blank-chars' has `empty' as an element."
737 :type '(regexp :tag "Empty Lines At End Of Buffer")
738 :group 'blank)
739
740
741(defcustom blank-space-after-tab-regexp "\t\\(\\( \\{8\\}\\)+\\)"
742 "*Specify regexp for 8 or more SPACEs after TAB.
743
744If you're using `mule' package, it may exist other characters besides:
745
746 \" \" \"\\t\" \"\\xA0\" \"\\x8A0\" \"\\x920\" \"\\xE20\" \
747\"\\xF20\"
748
749that should be considered blank.
750
751Used when `blank-style' has `color' as an element, and
752`blank-chars' has `space-after-tab' as an element."
753 :type '(regexp :tag "SPACEs After TAB")
754 :group 'blank)
755
756
577(defcustom blank-line-length 80 757(defcustom blank-line-length 80
578 "*Specify length beyond which the line is highlighted. 758 "*Specify length beyond which the line is highlighted.
579 759
@@ -658,13 +838,13 @@ of the list is negated if it begins with `not'. For example:
658 838
659means that `blank-mode' is turned on for buffers in C and C++ 839means that `blank-mode' is turned on for buffers in C and C++
660modes only." 840modes only."
661 :type '(choice (const :tag "none" nil) 841 :type '(choice (const :tag "None" nil)
662 (const :tag "all" t) 842 (const :tag "All" t)
663 (set :menu-tag "mode specific" :tag "modes" 843 (set :menu-tag "Mode Specific" :tag "Modes"
664 :value (not) 844 :value (not)
665 (const :tag "Except" not) 845 (const :tag "Except" not)
666 (repeat :inline t 846 (repeat :inline t
667 (symbol :tag "mode")))) 847 (symbol :tag "Mode"))))
668 :group 'blank) 848 :group 'blank)
669 849
670 850
@@ -765,6 +945,9 @@ Only useful with a windowing system."
765 space-before-tab 945 space-before-tab
766 lines 946 lines
767 newline 947 newline
948 indentation
949 empty
950 space-after-tab
768 ) 951 )
769 "List of valid `blank-chars' values.") 952 "List of valid `blank-chars' values.")
770 953
@@ -783,6 +966,9 @@ Only useful with a windowing system."
783 (?b . space-before-tab) 966 (?b . space-before-tab)
784 (?l . lines) 967 (?l . lines)
785 (?n . newline) 968 (?n . newline)
969 (?i . indentation)
970 (?e . empty)
971 (?a . space-after-tab)
786 (?c . color) 972 (?c . color)
787 (?m . mark) 973 (?m . mark)
788 (?x . blank-chars) 974 (?x . blank-chars)
@@ -830,6 +1016,9 @@ Interactively, it reads one of the following chars:
830 b toggle SPACEs before TAB visualization 1016 b toggle SPACEs before TAB visualization
831 l toggle \"long lines\" visualization 1017 l toggle \"long lines\" visualization
832 n toggle NEWLINE visualization 1018 n toggle NEWLINE visualization
1019 i toggle indentation SPACEs visualization
1020 e toggle empty line at bob and/or eob visualization
1021 a toggle SPACEs after TAB visualization
833 c toggle color faces 1022 c toggle color faces
834 m toggle visual mark 1023 m toggle visual mark
835 x restore `blank-chars' value 1024 x restore `blank-chars' value
@@ -845,6 +1034,9 @@ The valid symbols are:
845 space-before-tab toggle SPACEs before TAB visualization 1034 space-before-tab toggle SPACEs before TAB visualization
846 lines toggle \"long lines\" visualization 1035 lines toggle \"long lines\" visualization
847 newline toggle NEWLINE visualization 1036 newline toggle NEWLINE visualization
1037 indentation toggle indentation SPACEs visualization
1038 empty toggle empty line at bob and/or eob visualization
1039 space-after-tab toggle SPACEs after TAB visualization
848 color toggle color faces 1040 color toggle color faces
849 mark toggle visual mark 1041 mark toggle visual mark
850 blank-chars restore `blank-chars' value 1042 blank-chars restore `blank-chars' value
@@ -887,6 +1079,9 @@ Interactively, it reads one of the following chars:
887 b toggle SPACEs before TAB visualization 1079 b toggle SPACEs before TAB visualization
888 l toggle \"long lines\" visualization 1080 l toggle \"long lines\" visualization
889 n toggle NEWLINE visualization 1081 n toggle NEWLINE visualization
1082 i toggle indentation SPACEs visualization
1083 e toggle empty line at bob and/or eob visualization
1084 a toggle SPACEs after TAB visualization
890 c toggle color faces 1085 c toggle color faces
891 m toggle visual mark 1086 m toggle visual mark
892 x restore `blank-chars' value 1087 x restore `blank-chars' value
@@ -902,6 +1097,9 @@ The valid symbols are:
902 space-before-tab toggle SPACEs before TAB visualization 1097 space-before-tab toggle SPACEs before TAB visualization
903 lines toggle \"long lines\" visualization 1098 lines toggle \"long lines\" visualization
904 newline toggle NEWLINE visualization 1099 newline toggle NEWLINE visualization
1100 indentation toggle indentation SPACEs visualization
1101 empty toggle empty line at bob and/or eob visualization
1102 space-after-tab toggle SPACEs after TAB visualization
905 color toggle color faces 1103 color toggle color faces
906 mark toggle visual mark 1104 mark toggle visual mark
907 blank-chars restore `blank-chars' value 1105 blank-chars restore `blank-chars' value
@@ -922,6 +1120,152 @@ Only useful with a windowing system."
922 1120
923 1121
924;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 1122;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1123;;;; User commands - Cleanup
1124
1125
1126;;;###autoload
1127(defun blank-cleanup ()
1128 "Cleanup some blank problems in all buffer or at region.
1129
1130It usually applies to the whole buffer, but in transient mark
1131mode when the mark is active, it applies to the region. It also
1132applies to the region when it is not in transiente mark mode, the
1133mark is active and it was pressed `C-u' just before calling
1134`blank-cleanup' interactively.
1135
1136See also `blank-cleanup-region'.
1137
1138The problems, which are cleaned up, are:
1139
11401. empty lines at beginning of buffer.
11412. empty lines at end of buffer.
1142 If `blank-chars' has `empty' as an element, remove all empty
1143 lines at beginning and/or end of buffer.
1144
11453. 8 or more SPACEs at beginning of line.
1146 If `blank-chars' has `indentation' as an element, replace 8 or
1147 more SPACEs at beginning of line by TABs.
1148
11494. SPACEs before TAB.
1150 If `blank-chars' has `space-before-tab' as an element, replace
1151 SPACEs by TABs.
1152
11535. SPACEs or TABs at end of line.
1154 If `blank-chars' has `trailing' as an element, remove all
1155 SPACEs or TABs at end of line.
1156
11576. 8 or more SPACEs after TAB.
1158 If `blank-chars' has `space-after-tab' as an element, replace
1159 SPACEs by TABs."
1160 (interactive "@*")
1161 (if (and (or transient-mark-mode
1162 current-prefix-arg)
1163 mark-active)
1164 ;; region active
1165 ;; problems 1 and 2 are not handled in region
1166 ;; problem 3: 8 or more SPACEs at bol
1167 ;; problem 4: SPACEs before TAB
1168 ;; problem 5: SPACEs or TABs at eol
1169 ;; problem 6: 8 or more SPACEs after TAB
1170 (blank-cleanup-region (region-beginning) (region-end))
1171 ;; whole buffer
1172 (save-excursion
1173 ;; problem 1: empty lines at bob
1174 ;; problem 2: empty lines at eob
1175 ;; action: remove all empty lines at bob and/or eob
1176 (when (memq 'empty blank-chars)
1177 (let (overwrite-mode) ; enforce no overwrite
1178 (goto-char (point-min))
1179 (when (re-search-forward blank-empty-at-bob-regexp nil t)
1180 (delete-region (match-beginning 1) (match-end 1)))
1181 (when (re-search-forward blank-empty-at-eob-regexp nil t)
1182 (delete-region (match-beginning 1) (match-end 1)))))
1183 ;; problem 3: 8 or more SPACEs at bol
1184 ;; problem 4: SPACEs before TAB
1185 ;; problem 5: SPACEs or TABs at eol
1186 ;; problem 6: 8 or more SPACEs after TAB
1187 (blank-cleanup-region (point-min) (point-max)))))
1188
1189
1190;;;###autoload
1191(defun blank-cleanup-region (start end)
1192 "Cleanup some blank problems at region.
1193
1194The problems, which are cleaned up, are:
1195
11961. 8 or more SPACEs at beginning of line.
1197 If `blank-chars' has `indentation' as an element, replace 8 or
1198 more SPACEs at beginning of line by TABs.
1199
12002. SPACEs before TAB.
1201 If `blank-chars' has `space-before-tab' as an element, replace
1202 SPACEs by TABs.
1203
12043. SPACEs or TABs at end of line.
1205 If `blank-chars' has `trailing' as an element, remove all
1206 SPACEs or TABs at end of line.
1207
12084. 8 or more SPACEs after TAB.
1209 If `blank-chars' has `space-after-tab' as an element, replace
1210 SPACEs by TABs."
1211 (interactive "@*r")
1212 (let ((rstart (min start end))
1213 (rend (copy-marker (max start end)))
1214 (tab-width 8) ; assure TAB width
1215 (indent-tabs-mode t) ; always insert TABs
1216 overwrite-mode ; enforce no overwrite
1217 tmp)
1218 (save-excursion
1219 ;; problem 1: 8 or more SPACEs at bol
1220 ;; action: replace 8 or more SPACEs at bol by TABs
1221 (when (memq 'indentation blank-chars)
1222 (goto-char rstart)
1223 (while (re-search-forward blank-indentation-regexp rend t)
1224 (setq tmp (current-indentation))
1225 (delete-horizontal-space)
1226 (unless (eolp)
1227 (indent-to tmp))))
1228 ;; problem 3: SPACEs or TABs at eol
1229 ;; action: remove all SPACEs or TABs at eol
1230 (when (memq 'trailing blank-chars)
1231 (let ((regexp
1232 (concat "\\(\\(" blank-trailing-regexp "\\)+\\)$")))
1233 (goto-char rstart)
1234 (while (re-search-forward regexp rend t)
1235 (delete-region (match-beginning 1) (match-end 1)))))
1236 ;; problem 4: 8 or more SPACEs after TAB
1237 ;; action: replace 8 or more SPACEs by TABs
1238 (when (memq 'space-after-tab blank-chars)
1239 (goto-char rstart)
1240 (while (re-search-forward blank-space-after-tab-regexp rend t)
1241 (goto-char (match-beginning 1))
1242 (let ((scol (current-column))
1243 (ecol (save-excursion
1244 (goto-char (match-end 1))
1245 (current-column))))
1246 (delete-region (match-beginning 1) (match-end 1))
1247 (insert-char ?\t (/ (- ecol scol) 8)))))
1248 ;; problem 2: SPACEs before TAB
1249 ;; action: replace SPACEs before TAB by TABs
1250 (when (memq 'space-before-tab blank-chars)
1251 (goto-char rstart)
1252 (while (re-search-forward blank-space-before-tab-regexp rend t)
1253 (goto-char (match-beginning 1))
1254 (let* ((scol (current-column))
1255 (ecol (save-excursion
1256 (goto-char (match-end 1))
1257 (current-column)))
1258 (next-tab-col (* (/ (+ scol 8) 8) 8)))
1259 (delete-region (match-beginning 1) (match-end 1))
1260 (when (<= next-tab-col ecol)
1261 (insert-char ?\t
1262 (/ (- (- ecol (% ecol 8)) ; prev end col
1263 (- scol (% scol 8))) ; prev start col
1264 8)))))))
1265 (set-marker rend nil))) ; point marker to nowhere
1266
1267
1268;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
925;;;; Internal functions 1269;;;; Internal functions
926 1270
927 1271
@@ -948,6 +1292,9 @@ Only useful with a windowing system."
948 [] b - toggle SPACEs before TAB visualization 1292 [] b - toggle SPACEs before TAB visualization
949 [] l - toggle \"long lines\" visualization 1293 [] l - toggle \"long lines\" visualization
950 [] n - toggle NEWLINE visualization 1294 [] n - toggle NEWLINE visualization
1295 [] i - toggle indentation SPACEs visualization
1296 [] e - toggle empty line at bob and/or eob visualization
1297 [] a - toggle SPACEs after TAB visualization
951 1298
952 [] c - toggle color faces 1299 [] c - toggle color faces
953 [] m - toggle visual mark 1300 [] m - toggle visual mark
@@ -1019,6 +1366,9 @@ It reads one of the following chars:
1019 b toggle SPACEs before TAB visualization 1366 b toggle SPACEs before TAB visualization
1020 l toggle \"long lines\" visualization 1367 l toggle \"long lines\" visualization
1021 n toggle NEWLINE visualization 1368 n toggle NEWLINE visualization
1369 i toggle indentation SPACEs visualization
1370 e toggle empty line at bob and/or eob visualization
1371 a toggle SPACEs after TAB visualization
1022 c toggle color faces 1372 c toggle color faces
1023 m toggle visual mark 1373 m toggle visual mark
1024 x restore `blank-chars' value 1374 x restore `blank-chars' value
@@ -1171,6 +1521,37 @@ options are valid."
1171 (list blank-space-before-tab-regexp 1521 (list blank-space-before-tab-regexp
1172 1 blank-space-before-tab t)) 1522 1 blank-space-before-tab t))
1173 t)) 1523 t))
1524 (when (memq 'indentation blank-active-chars)
1525 (font-lock-add-keywords
1526 nil
1527 (list
1528 ;; Show indentation SPACEs
1529 (list blank-indentation-regexp
1530 1 blank-indentation t))
1531 t))
1532 (when (memq 'empty blank-active-chars)
1533 (font-lock-add-keywords
1534 nil
1535 (list
1536 ;; Show empty lines at beginning of buffer
1537 (list blank-empty-at-bob-regexp
1538 1 blank-empty t))
1539 t)
1540 (font-lock-add-keywords
1541 nil
1542 (list
1543 ;; Show empty lines at end of buffer
1544 (list blank-empty-at-eob-regexp
1545 1 blank-empty t))
1546 t))
1547 (when (memq 'space-after-tab blank-active-chars)
1548 (font-lock-add-keywords
1549 nil
1550 (list
1551 ;; Show SPACEs after TAB
1552 (list blank-space-after-tab-regexp
1553 1 blank-space-after-tab t))
1554 t))
1174 ;; now turn on font lock and highlight blanks 1555 ;; now turn on font lock and highlight blanks
1175 (font-lock-mode 1))) 1556 (font-lock-mode 1)))
1176 1557