forked from startup-class/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwhitespace.el
2467 lines (2051 loc) · 79.9 KB
/
whitespace.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;;; whitespace.el --- minor mode to visualize TAB, (HARD) SPACE, NEWLINE
;; Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
;; Free Software Foundation, Inc.
;; Author: Vinicius Jose Latorre <[email protected]>
;; Maintainer: Vinicius Jose Latorre <[email protected]>
;; Keywords: data, wp
;; Version: 11.2.2
;; X-URL: http://www.emacswiki.org/cgi-bin/wiki/ViniciusJoseLatorre
;; This file is part of GNU Emacs.
;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Introduction
;; ------------
;;
;; This package is a minor mode to visualize blanks (TAB, (HARD) SPACE
;; and NEWLINE).
;;
;; whitespace uses two ways to visualize blanks: faces and display
;; table.
;;
;; * Faces are used to highlight the background with a color.
;; whitespace uses font-lock to highlight blank characters.
;;
;; * Display table changes the way a character is displayed, that is,
;; it provides a visual mark for characters, for example, at the end
;; of line (?\xB6), at SPACEs (?\xB7) and at TABs (?\xBB).
;;
;; The `whitespace-style' variable selects which way blanks are
;; visualized.
;;
;; Note that when whitespace is turned on, whitespace saves the
;; font-lock state, that is, if font-lock is on or off. And
;; whitespace restores the font-lock state when it is turned off. So,
;; if whitespace is turned on and font-lock is off, whitespace also
;; turns on the font-lock to highlight blanks, but the font-lock will
;; be turned off when whitespace is turned off. Thus, turn on
;; font-lock before whitespace is on, if you want that font-lock
;; continues on after whitespace is turned off.
;;
;; When whitespace is on, it takes care of highlighting some special
;; characters over the default mechanism of `nobreak-char-display'
;; (which see) and `show-trailing-whitespace' (which see).
;;
;; There are two ways of using whitespace: local and global.
;;
;; * Local whitespace affects only the current buffer.
;;
;; * Global whitespace affects all current and future buffers. That
;; is, if you turn on global whitespace and then create a new
;; buffer, the new buffer will also have whitespace on. The
;; `whitespace-global-modes' variable controls which major-mode will
;; be automagically turned on.
;;
;; You can mix the local and global usage without any conflict. But
;; local whitespace has priority over global whitespace. Whitespace
;; mode is active in a buffer if you have enabled it in that buffer or
;; if you have enabled it globally.
;;
;; When global and local whitespace are on:
;;
;; * if local whitespace is turned off, whitespace is turned off for
;; the current buffer only.
;;
;; * if global whitespace is turned off, whitespace continues on only
;; in the buffers in which local whitespace is on.
;;
;; To use whitespace, insert in your ~/.emacs:
;;
;; (require 'whitespace-mode)
;;
;; Or autoload at least one of the commands`whitespace-mode',
;; `whitespace-toggle-options', `global-whitespace-mode' or
;; `global-whitespace-toggle-options'. For example:
;;
;; (autoload 'whitespace-mode "whitespace"
;; "Toggle whitespace visualization." t)
;; (autoload 'whitespace-toggle-options "whitespace"
;; "Toggle local `whitespace-mode' options." t)
;;
;; whitespace was inspired by:
;;
;; whitespace.el Rajesh Vaidheeswarran <[email protected]>
;; Warn about and clean bogus whitespaces in the file
;; (inspired the idea to warn and clean some blanks)
;; This was the original `whitespace.el' which was replaced by
;; `blank-mode.el'. And later `blank-mode.el' was renamed to
;; `whitespace.el'.
;;
;; show-whitespace-mode.el Aurelien Tisne <[email protected]>
;; Simple mode to highlight whitespaces
;; (inspired the idea to use font-lock)
;;
;; whitespace-mode.el Lawrence Mitchell <[email protected]>
;; Major mode for editing Whitespace
;; (inspired the idea to use display table)
;;
;; visws.el Miles Bader <[email protected]>
;; Make whitespace visible
;; (handle display table, his code was modified, but the main
;; idea was kept)
;;
;;
;; Using whitespace
;; ----------------
;;
;; There is no problem if you mix local and global minor mode usage.
;;
;; * LOCAL whitespace:
;; + To toggle whitespace options locally, type:
;;
;; M-x whitespace-toggle-options RET
;;
;; + To activate whitespace locally, type:
;;
;; C-u 1 M-x whitespace-mode RET
;;
;; + To deactivate whitespace locally, type:
;;
;; C-u 0 M-x whitespace-mode RET
;;
;; + To toggle whitespace locally, type:
;;
;; M-x whitespace-mode RET
;;
;; * GLOBAL whitespace:
;; + To toggle whitespace options globally, type:
;;
;; M-x global-whitespace-toggle-options RET
;;
;; + To activate whitespace globally, type:
;;
;; C-u 1 M-x global-whitespace-mode RET
;;
;; + To deactivate whitespace globally, type:
;;
;; C-u 0 M-x global-whitespace-mode RET
;;
;; + To toggle whitespace globally, type:
;;
;; M-x global-whitespace-mode RET
;;
;; There are also the following useful commands:
;;
;; `whitespace-newline-mode'
;; Toggle NEWLINE minor mode visualization ("nl" on modeline).
;;
;; `global-whitespace-newline-mode'
;; Toggle NEWLINE global minor mode visualization ("NL" on modeline).
;;
;; `whitespace-report'
;; Report some blank problems in buffer.
;;
;; `whitespace-report-region'
;; Report some blank problems in a region.
;;
;; `whitespace-cleanup'
;; Cleanup some blank problems in all buffer or at region.
;;
;; `whitespace-cleanup-region'
;; Cleanup some blank problems at region.
;;
;; The problems, which are cleaned up, are:
;;
;; 1. empty lines at beginning of buffer.
;; 2. empty lines at end of buffer.
;; If `whitespace-style' includes the value `empty', remove all
;; empty lines at beginning and/or end of buffer.
;;
;; 3. 8 or more SPACEs at beginning of line.
;; If `whitespace-style' includes the value `indentation':
;; replace 8 or more SPACEs at beginning of line by TABs, if
;; `indent-tabs-mode' is non-nil; otherwise, replace TABs by
;; SPACEs.
;; If `whitespace-style' includes the value `indentation::tab',
;; replace 8 or more SPACEs at beginning of line by TABs.
;; If `whitespace-style' includes the value `indentation::space',
;; replace TABs by SPACEs.
;;
;; 4. SPACEs before TAB.
;; If `whitespace-style' includes the value `space-before-tab':
;; replace SPACEs by TABs, if `indent-tabs-mode' is non-nil;
;; otherwise, replace TABs by SPACEs.
;; If `whitespace-style' includes the value
;; `space-before-tab::tab', replace SPACEs by TABs.
;; If `whitespace-style' includes the value
;; `space-before-tab::space', replace TABs by SPACEs.
;;
;; 5. SPACEs or TABs at end of line.
;; If `whitespace-style' includes the value `trailing', remove all
;; SPACEs or TABs at end of line.
;;
;; 6. 8 or more SPACEs after TAB.
;; If `whitespace-style' includes the value `space-after-tab':
;; replace SPACEs by TABs, if `indent-tabs-mode' is non-nil;
;; otherwise, replace TABs by SPACEs.
;; If `whitespace-style' includes the value `space-after-tab::tab',
;; replace SPACEs by TABs.
;; If `whitespace-style' includes the value
;; `space-after-tab::space', replace TABs by SPACEs.
;;
;;
;; Hooks
;; -----
;;
;; whitespace has the following hook variables:
;;
;; `whitespace-mode-hook'
;; It is evaluated always when whitespace is turned on locally.
;;
;; `global-whitespace-mode-hook'
;; It is evaluated always when whitespace is turned on globally.
;;
;; `whitespace-load-hook'
;; It is evaluated after whitespace package is loaded.
;;
;;
;; Options
;; -------
;;
;; Below it's shown a brief description of whitespace options, please,
;; see the options declaration in the code for a long documentation.
;;
;; `whitespace-style' Specify which kind of blank is
;; visualized.
;;
;; `whitespace-space' Face used to visualize SPACE.
;;
;; `whitespace-hspace' Face used to visualize HARD SPACE.
;;
;; `whitespace-tab' Face used to visualize TAB.
;;
;; `whitespace-newline' Face used to visualize NEWLINE char
;; mapping.
;;
;; `whitespace-trailing' Face used to visualize trailing
;; blanks.
;;
;; `whitespace-line' Face used to visualize "long" lines.
;;
;; `whitespace-space-before-tab' Face used to visualize SPACEs
;; before TAB.
;;
;; `whitespace-indentation' Face used to visualize 8 or more
;; SPACEs at beginning of line.
;;
;; `whitespace-empty' Face used to visualize empty lines at
;; beginning and/or end of buffer.
;;
;; `whitespace-space-after-tab' Face used to visualize 8 or more
;; SPACEs after TAB.
;;
;; `whitespace-space-regexp' Specify SPACE characters regexp.
;;
;; `whitespace-hspace-regexp' Specify HARD SPACE characters regexp.
;;
;; `whitespace-tab-regexp' Specify TAB characters regexp.
;;
;; `whitespace-trailing-regexp' Specify trailing characters regexp.
;;
;; `whitespace-space-before-tab-regexp' Specify SPACEs before TAB
;; regexp.
;;
;; `whitespace-indentation-regexp' Specify regexp for 8 or more
;; SPACEs at beginning of line.
;;
;; `whitespace-empty-at-bob-regexp' Specify regexp for empty lines
;; at beginning of buffer.
;;
;; `whitespace-empty-at-eob-regexp' Specify regexp for empty lines
;; at end of buffer.
;;
;; `whitespace-space-after-tab-regexp' Specify regexp for 8 or more
;; SPACEs after TAB.
;;
;; `whitespace-line-column' Specify column beyond which the line
;; is highlighted.
;;
;; `whitespace-display-mappings' Specify an alist of mappings
;; for displaying characters.
;;
;; `whitespace-global-modes' Modes for which global
;; `whitespace-mode' is automagically
;; turned on.
;;
;; `whitespace-action' Specify which action is taken when a
;; buffer is visited or written.
;;
;;
;; Acknowledgements
;; ----------------
;;
;; Thanks to David Reitter <[email protected]> for suggesting a
;; `whitespace-newline' initialization with low contrast relative to
;; the background color.
;;
;; Thanks to Stephen Deasey <[email protected]> for the
;; `indent-tabs-mode' usage suggestion.
;;
;; Thanks to Eric Cooper <[email protected]> for the suggestion to have hook
;; actions when buffer is written as the original whitespace package
;; had.
;;
;; Thanks to nschum (EmacsWiki) for the idea about highlight "long"
;; lines tail. See EightyColumnRule (EmacsWiki).
;;
;; Thanks to Juri Linkov <[email protected]> for suggesting:
;; * `define-minor-mode'.
;; * `global-whitespace-*' name for global commands.
;;
;; Thanks to Robert J. Chassell <[email protected]> for doc fix and testing.
;;
;; Thanks to Drew Adams <[email protected]> for toggle commands
;; suggestion.
;;
;; Thanks to Antti Kaihola <[email protected]> for
;; helping to fix `find-file-hooks' reference.
;;
;; Thanks to Andreas Roehler <[email protected]> for
;; indicating defface byte-compilation warnings.
;;
;; Thanks to TimOCallaghan (EmacsWiki) for the idea about highlight
;; "long" lines. See EightyColumnRule (EmacsWiki).
;;
;; Thanks to Yanghui Bian <[email protected]> for indicating a new
;; NEWLINE character mapping.
;;
;; Thanks to Pete Forman <[email protected]> for indicating
;; whitespace-mode.el on XEmacs.
;;
;; Thanks to Miles Bader <[email protected]> for handling display table via
;; visws.el (his code was modified, but the main idea was kept).
;;
;; Thanks to:
;; Rajesh Vaidheeswarran <[email protected]> (original) whitespace.el
;; Aurelien Tisne <[email protected]> show-whitespace-mode.el
;; Lawrence Mitchell <[email protected]> whitespace-mode.el
;; Miles Bader <[email protected]> visws.el
;; And to all people who contributed with them.
;;
;;
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; User Variables:
;;; Interface to the command system
(defgroup whitespace nil
"Visualize blanks (TAB, (HARD) SPACE and NEWLINE)."
:link '(emacs-library-link :tag "Source Lisp File" "whitespace.el")
:version "23.1"
:group 'wp
:group 'data)
(defcustom whitespace-style
'(tabs spaces trailing lines space-before-tab newline
indentation empty space-after-tab
space-mark tab-mark newline-mark)
"*Specify which kind of blank is visualized.
It's a list containing some or all of the following values:
trailing trailing blanks are visualized via faces.
tabs TABs are visualized via faces.
spaces SPACEs and HARD SPACEs are visualized via
faces.
lines lines whose have columns beyond
`whitespace-line-column' are highlighted via
faces .
Whole line is highlighted.
It has precedence over `lines-tail' (see
below).
lines-tail lines whose have columns beyond
`whitespace-line-column' are highlighted via
faces.
But only the part of line which goes
beyond `whitespace-line-column' column.
It has effect only if `lines' (see above)
is not present in `whitespace-style'.
newline NEWLINEs are visualized via faces.
empty empty lines at beginning and/or end of buffer
are visualized via faces.
indentation::tab 8 or more SPACEs at beginning of line are
visualized via faces.
indentation::space TABs at beginning of line are visualized via
faces.
indentation 8 or more SPACEs at beginning of line are
visualized, if `indent-tabs-mode' (which see)
is non-nil; otherwise, TABs at beginning of
line are visualized via faces.
space-after-tab::tab 8 or more SPACEs after a TAB are
visualized via faces.
space-after-tab::space TABs are visualized when occurs 8 or
more SPACEs after a TAB via faces.
space-after-tab 8 or more SPACEs after a TAB are
visualized, if `indent-tabs-mode'
(which see) is non-nil; otherwise,
the TABs are visualized via faces.
space-before-tab::tab SPACEs before TAB are visualized via
faces.
space-before-tab::space TABs are visualized when occurs SPACEs
before TAB via faces.
space-before-tab SPACEs before TAB are visualized, if
`indent-tabs-mode' (which see) is
non-nil; otherwise, the TABs are
visualized via faces.
space-mark SPACEs and HARD SPACEs are visualized via
display table.
tab-mark TABs are visualized via display table.
newline-mark NEWLINEs are visualized via display table.
Any other value is ignored.
If nil, don't visualize TABs, (HARD) SPACEs and NEWLINEs via faces and
via display table.
There is an evaluation order for some values, if some values are
included in `whitespace-style' list. For example, if
indentation, indentation::tab and/or indentation::space are
included in `whitespace-style' list. The evaluation order for
these values is:
* For indentation:
1. indentation
2. indentation::tab
3. indentation::space
* For SPACEs after TABs:
1. space-after-tab
2. space-after-tab::tab
3. space-after-tab::space
* For SPACEs before TABs:
1. space-before-tab
2. space-before-tab::tab
3. space-before-tab::space
So, for example, if indentation and indentation::space are
included in `whitespace-style' list, the indentation value is
evaluated instead of indentation::space value.
See also `whitespace-display-mappings' for documentation."
:type '(repeat :tag "Kind of Blank"
(choice :tag "Kind of Blank Face"
(const :tag "(Face) Trailing TABs, SPACEs and HARD SPACEs"
trailing)
(const :tag "(Face) SPACEs and HARD SPACEs"
spaces)
(const :tag "(Face) TABs" tabs)
(const :tag "(Face) Lines" lines)
(const :tag "(Face) SPACEs before TAB"
space-before-tab)
(const :tag "(Face) NEWLINEs" newline)
(const :tag "(Face) Indentation SPACEs"
indentation)
(const :tag "(Face) Empty Lines At BOB And/Or EOB"
empty)
(const :tag "(Face) SPACEs after TAB"
space-after-tab)
(const :tag "(Mark) SPACEs and HARD SPACEs"
space-mark)
(const :tag "(Mark) TABs" tab-mark)
(const :tag "(Mark) NEWLINEs" newline-mark)))
:group 'whitespace)
(defcustom whitespace-space 'whitespace-space
"*Symbol face used to visualize SPACE.
Used when `whitespace-style' includes the value `spaces'."
:type 'face
:group 'whitespace)
(defface whitespace-space
'((((class color) (background dark))
(:background "grey20" :foreground "aquamarine3"))
(((class color) (background light))
(:background "LightYellow" :foreground "aquamarine3"))
(t (:inverse-video t)))
"Face used to visualize SPACE."
:group 'whitespace)
(defcustom whitespace-hspace 'whitespace-hspace
"*Symbol face used to visualize HARD SPACE.
Used when `whitespace-style' includes the value `spaces'."
:type 'face
:group 'whitespace)
(defface whitespace-hspace ; 'nobreak-space
'((((class color) (background dark))
(:background "grey24" :foreground "aquamarine3"))
(((class color) (background light))
(:background "LemonChiffon3" :foreground "aquamarine3"))
(t (:inverse-video t)))
"Face used to visualize HARD SPACE."
:group 'whitespace)
(defcustom whitespace-tab 'whitespace-tab
"*Symbol face used to visualize TAB.
Used when `whitespace-style' includes the value `tabs'."
:type 'face
:group 'whitespace)
(defface whitespace-tab
'((((class color) (background dark))
(:background "grey22" :foreground "aquamarine3"))
(((class color) (background light))
(:background "beige" :foreground "aquamarine3"))
(t (:inverse-video t)))
"Face used to visualize TAB."
:group 'whitespace)
(defcustom whitespace-newline 'whitespace-newline
"*Symbol face used to visualize NEWLINE char mapping.
See `whitespace-display-mappings'.
Used when `whitespace-style' includes the values `newline-mark'
and `newline'."
:type 'face
:group 'whitespace)
(defface whitespace-newline
'((((class color) (background dark))
(:foreground "darkgray" :bold nil))
(((class color) (background light))
(:foreground "lightgray" :bold nil))
(t (:underline t :bold nil)))
"Face used to visualize NEWLINE char mapping.
See `whitespace-display-mappings'."
:group 'whitespace)
(defcustom whitespace-trailing 'whitespace-trailing
"*Symbol face used to visualize trailing blanks.
Used when `whitespace-style' includes the value `trailing'."
:type 'face
:group 'whitespace)
(defface whitespace-trailing ; 'trailing-whitespace
'((((class mono)) (:inverse-video t :bold t :underline t))
(t (:background "red1" :foreground "yellow" :bold t)))
"Face used to visualize trailing blanks."
:group 'whitespace)
(defcustom whitespace-line 'whitespace-line
"*Symbol face used to visualize \"long\" lines.
See `whitespace-line-column'.
Used when `whitespace-style' includes the value `line'."
:type 'face
:group 'whitespace)
(defface whitespace-line
'((((class mono)) (:inverse-video t :bold t :underline t))
(t (:background "gray20" :foreground "violet")))
"Face used to visualize \"long\" lines.
See `whitespace-line-column'."
:group 'whitespace)
(defcustom whitespace-space-before-tab 'whitespace-space-before-tab
"*Symbol face used to visualize SPACEs before TAB.
Used when `whitespace-style' includes the value `space-before-tab'."
:type 'face
:group 'whitespace)
(defface whitespace-space-before-tab
'((((class mono)) (:inverse-video t :bold t :underline t))
(t (:background "DarkOrange" :foreground "firebrick")))
"Face used to visualize SPACEs before TAB."
:group 'whitespace)
(defcustom whitespace-indentation 'whitespace-indentation
"*Symbol face used to visualize 8 or more SPACEs at beginning of line.
Used when `whitespace-style' includes the value `indentation'."
:type 'face
:group 'whitespace)
(defface whitespace-indentation
'((((class mono)) (:inverse-video t :bold t :underline t))
(t (:background "yellow" :foreground "firebrick")))
"Face used to visualize 8 or more SPACEs at beginning of line."
:group 'whitespace)
(defcustom whitespace-empty 'whitespace-empty
"*Symbol face used to visualize empty lines at beginning and/or end of buffer.
Used when `whitespace-style' includes the value `empty'."
:type 'face
:group 'whitespace)
(defface whitespace-empty
'((((class mono)) (:inverse-video t :bold t :underline t))
(t (:background "yellow" :foreground "firebrick")))
"Face used to visualize empty lines at beginning and/or end of buffer."
:group 'whitespace)
(defcustom whitespace-space-after-tab 'whitespace-space-after-tab
"*Symbol face used to visualize 8 or more SPACEs after TAB.
Used when `whitespace-style' includes the value `space-after-tab'."
:type 'face
:group 'whitespace)
(defface whitespace-space-after-tab
'((((class mono)) (:inverse-video t :bold t :underline t))
(t (:background "yellow" :foreground "firebrick")))
"Face used to visualize 8 or more SPACEs after TAB."
:group 'whitespace)
(defcustom whitespace-hspace-regexp
"\\(\\(\xA0\\|\x8A0\\|\x920\\|\xE20\\|\xF20\\)+\\)"
"*Specify HARD SPACE characters regexp.
If you're using `mule' package, there may be other characters besides:
\"\\xA0\" \"\\x8A0\" \"\\x920\" \"\\xE20\" \"\\xF20\"
that should be considered HARD SPACE.
Here are some examples:
\"\\\\(^\\xA0+\\\\)\" \
visualize only leading HARD SPACEs.
\"\\\\(\\xA0+$\\\\)\" \
visualize only trailing HARD SPACEs.
\"\\\\(^\\xA0+\\\\|\\xA0+$\\\\)\" \
visualize leading and/or trailing HARD SPACEs.
\"\\t\\\\(\\xA0+\\\\)\\t\" \
visualize only HARD SPACEs between TABs.
NOTE: Enclose always by \\\\( and \\\\) the elements to highlight.
Use exactly one pair of enclosing \\\\( and \\\\).
Used when `whitespace-style' includes `spaces'."
:type '(regexp :tag "HARD SPACE Chars")
:group 'whitespace)
(defcustom whitespace-space-regexp "\\( +\\)"
"*Specify SPACE characters regexp.
If you're using `mule' package, there may be other characters
besides \" \" that should be considered SPACE.
Here are some examples:
\"\\\\(^ +\\\\)\" visualize only leading SPACEs.
\"\\\\( +$\\\\)\" visualize only trailing SPACEs.
\"\\\\(^ +\\\\| +$\\\\)\" \
visualize leading and/or trailing SPACEs.
\"\\t\\\\( +\\\\)\\t\" visualize only SPACEs between TABs.
NOTE: Enclose always by \\\\( and \\\\) the elements to highlight.
Use exactly one pair of enclosing \\\\( and \\\\).
Used when `whitespace-style' includes `spaces'."
:type '(regexp :tag "SPACE Chars")
:group 'whitespace)
(defcustom whitespace-tab-regexp "\\(\t+\\)"
"*Specify TAB characters regexp.
If you're using `mule' package, there may be other characters
besides \"\\t\" that should be considered TAB.
Here are some examples:
\"\\\\(^\\t+\\\\)\" visualize only leading TABs.
\"\\\\(\\t+$\\\\)\" visualize only trailing TABs.
\"\\\\(^\\t+\\\\|\\t+$\\\\)\" \
visualize leading and/or trailing TABs.
\" \\\\(\\t+\\\\) \" visualize only TABs between SPACEs.
NOTE: Enclose always by \\\\( and \\\\) the elements to highlight.
Use exactly one pair of enclosing \\\\( and \\\\).
Used when `whitespace-style' includes `tabs'."
:type '(regexp :tag "TAB Chars")
:group 'whitespace)
(defcustom whitespace-trailing-regexp
"\\(\\(\t\\| \\|\xA0\\|\x8A0\\|\x920\\|\xE20\\|\xF20\\)+\\)$"
"*Specify trailing characters regexp.
If you're using `mule' package, there may be other characters besides:
\" \" \"\\t\" \"\\xA0\" \"\\x8A0\" \"\\x920\" \"\\xE20\" \
\"\\xF20\"
that should be considered blank.
NOTE: Enclose always by \"\\\\(\" and \"\\\\)$\" the elements to highlight.
Use exactly one pair of enclosing elements above.
Used when `whitespace-style' includes `trailing'."
:type '(regexp :tag "Trailing Chars")
:group 'whitespace)
(defcustom whitespace-space-before-tab-regexp "\\( +\\)\\(\t+\\)"
"*Specify SPACEs before TAB regexp.
If you're using `mule' package, there may be other characters besides:
\" \" \"\\t\" \"\\xA0\" \"\\x8A0\" \"\\x920\" \"\\xE20\" \
\"\\xF20\"
that should be considered blank.
Used when `whitespace-style' includes `space-before-tab',
`space-before-tab::tab' or `space-before-tab::space'."
:type '(regexp :tag "SPACEs Before TAB")
:group 'whitespace)
(defcustom whitespace-indentation-regexp
'("^\t*\\(\\( \\{%d\\}\\)+\\)[^\n\t]"
. "^ *\\(\t+\\)[^\n]")
"*Specify regexp for 8 or more SPACEs at beginning of line.
It is a cons where the cons car is used for SPACEs visualization
and the cons cdr is used for TABs visualization.
If you're using `mule' package, there may be other characters besides:
\" \" \"\\t\" \"\\xA0\" \"\\x8A0\" \"\\x920\" \"\\xE20\" \
\"\\xF20\"
that should be considered blank.
Used when `whitespace-style' includes `indentation',
`indentation::tab' or `indentation::space'."
:type '(cons (regexp :tag "Indentation SPACEs")
(regexp :tag "Indentation TABs"))
:group 'whitespace)
(defcustom whitespace-empty-at-bob-regexp "\\`\\(\\([ \t]*\n\\)+\\)"
"*Specify regexp for empty lines at beginning of buffer.
If you're using `mule' package, there may be other characters besides:
\" \" \"\\t\" \"\\xA0\" \"\\x8A0\" \"\\x920\" \"\\xE20\" \
\"\\xF20\"
that should be considered blank.
Used when `whitespace-style' includes `empty'."
:type '(regexp :tag "Empty Lines At Beginning Of Buffer")
:group 'whitespace)
(defcustom whitespace-empty-at-eob-regexp "^\\([ \t\n]+\\)\\'"
"*Specify regexp for empty lines at end of buffer.
If you're using `mule' package, there may be other characters besides:
\" \" \"\\t\" \"\\xA0\" \"\\x8A0\" \"\\x920\" \"\\xE20\" \
\"\\xF20\"
that should be considered blank.
Used when `whitespace-style' includes `empty'."
:type '(regexp :tag "Empty Lines At End Of Buffer")
:group 'whitespace)
(defcustom whitespace-space-after-tab-regexp
'("\t+\\(\\( \\{%d\\}\\)+\\)"
. "\\(\t+\\) +")
"*Specify regexp for 8 or more SPACEs after TAB.
It is a cons where the cons car is used for SPACEs visualization
and the cons cdr is used for TABs visualization.
If you're using `mule' package, there may be other characters besides:
\" \" \"\\t\" \"\\xA0\" \"\\x8A0\" \"\\x920\" \"\\xE20\" \
\"\\xF20\"
that should be considered blank.
Used when `whitespace-style' includes `space-after-tab',
`space-after-tab::tab' or `space-after-tab::space'."
:type '(regexp :tag "SPACEs After TAB")
:group 'whitespace)
(defcustom whitespace-line-column 80
"*Specify column beyond which the line is highlighted.
Used when `whitespace-style' includes `lines' or `lines-tail'."
:type '(integer :tag "Line Length")
:group 'whitespace)
;; Hacked from `visible-whitespace-mappings' in visws.el
(defcustom whitespace-display-mappings
(if (>= emacs-major-version 23)
;; Emacs 23 and higher:
'(
(space-mark ?\ [?\xB7] [?.]) ; space - centered dot
(space-mark ?\xA0 [?\xA4] [?_]) ; hard space - currency
(space-mark ?\x8A0 [?\x8A4] [?_]) ; hard space - currency
(space-mark ?\x920 [?\x924] [?_]) ; hard space - currency
(space-mark ?\xE20 [?\xE24] [?_]) ; hard space - currency
(space-mark ?\xF20 [?\xF24] [?_]) ; hard space - currency
;; NEWLINE is displayed using the face `whitespace-newline'
(newline-mark ?\n [?$ ?\n]) ; eol - dollar sign
;; (newline-mark ?\n [?\u21B5 ?\n] [?$ ?\n]) ; eol - downwards arrow
;; (newline-mark ?\n [?\xB6 ?\n] [?$ ?\n]) ; eol - pilcrow
;; (newline-mark ?\n [?\x8AF ?\n] [?$ ?\n]) ; eol - overscore
;; (newline-mark ?\n [?\x8AC ?\n] [?$ ?\n]) ; eol - negation
;; (newline-mark ?\n [?\x8B0 ?\n] [?$ ?\n]) ; eol - grade
;;
;; WARNING: the mapping below has a problem.
;; When a TAB occupies exactly one column, it will display the
;; character ?\xBB at that column followed by a TAB which goes to
;; the next TAB column.
;; If this is a problem for you, please, comment the line below.
(tab-mark ?\t [?\xBB ?\t] [?\\ ?\t]) ; tab - left quote mark
)
;; Emacs 21 and 22:
;; Due to limitations of glyph representation, the char code can not
;; be above ?\x1FFFF. Probably, this will be fixed after Emacs
;; unicode merging.
'(
(space-mark ?\ [?\xB7] [?.]) ; space - centered dot
(space-mark ?\xA0 [?\xA4] [?_]) ; hard space - currency
(space-mark ?\x8A0 [?\x8A4] [?_]) ; hard space - currency
(space-mark ?\x920 [?\x924] [?_]) ; hard space - currency
(space-mark ?\xE20 [?\xE24] [?_]) ; hard space - currency
(space-mark ?\xF20 [?\xF24] [?_]) ; hard space - currency
;; NEWLINE is displayed using the face `whitespace-newline'
(newline-mark ?\n [?$ ?\n]) ; eol - dollar sign
;; (newline-mark ?\n [?\u21B5 ?\n] [?$ ?\n]) ; eol - downwards arrow
;; (newline-mark ?\n [?\xB6 ?\n] [?$ ?\n]) ; eol - pilcrow
;; (newline-mark ?\n [?\x8AF ?\n] [?$ ?\n]) ; eol - overscore
;; (newline-mark ?\n [?\x8AC ?\n] [?$ ?\n]) ; eol - negation
;; (newline-mark ?\n [?\x8B0 ?\n] [?$ ?\n]) ; eol - grade
;;
;; WARNING: the mapping below has a problem.
;; When a TAB occupies exactly one column, it will display the
;; character ?\xBB at that column followed by a TAB which goes to
;; the next TAB column.
;; If this is a problem for you, please, comment the line below.
(tab-mark ?\t [?\xBB ?\t] [?\\ ?\t]) ; tab - left quote mark
))
"*Specify an alist of mappings for displaying characters.
Each element has the following form:
(KIND CHAR VECTOR...)
Where:
KIND is the kind of character.
It can be one of the following symbols:
tab-mark for TAB character
space-mark for SPACE or HARD SPACE character
newline-mark for NEWLINE character
CHAR is the character to be mapped.
VECTOR is a vector of characters to be displayed in place of CHAR.
The first display vector that can be displayed is used;
if no display vector for a mapping can be displayed, then
that character is displayed unmodified.
The NEWLINE character is displayed using the face given by
`whitespace-newline' variable.
Used when `whitespace-style' includes `tab-mark', `space-mark' or
`newline-mark'."
:type '(repeat
(list :tag "Character Mapping"
(choice :tag "Char Kind"
(const :tag "Tab" tab-mark)
(const :tag "Space" space-mark)
(const :tag "Newline" newline-mark))
(character :tag "Char")
(repeat :inline t :tag "Vector List"
(vector :tag ""
(repeat :inline t
:tag "Vector Characters"
(character :tag "Char"))))))
:group 'whitespace)
(defcustom whitespace-global-modes t
"*Modes for which global `whitespace-mode' is automagically turned on.
Global `whitespace-mode' is controlled by the command
`global-whitespace-mode'.
If nil, means no modes have `whitespace-mode' automatically
turned on.
If t, all modes that support `whitespace-mode' have it
automatically turned on.
Else it should be a list of `major-mode' symbol names for which
`whitespace-mode' should be automatically turned on. The sense
of the list is negated if it begins with `not'. For example:
(c-mode c++-mode)
means that `whitespace-mode' is turned on for buffers in C and
C++ modes only."
:type '(choice :tag "Global Modes"
(const :tag "None" nil)
(const :tag "All" t)
(set :menu-tag "Mode Specific" :tag "Modes"
:value (not)
(const :tag "Except" not)
(repeat :inline t
(symbol :tag "Mode"))))
:group 'whitespace)
(defcustom whitespace-action nil
"*Specify which action is taken when a buffer is visited or written.
It's a list containing some or all of the following values: