Mercurial > emacs
annotate lisp/whitespace.el @ 74493:817f7407b88f
** christopher.ian.moore@gmail.com, Nov 30: too much recursion in
gnus-sort-threads-1.
Fixed.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Fri, 08 Dec 2006 16:26:50 +0000 |
parents | b2e5081b9320 |
children | e3694f1cb928 17e0dd217877 f1d13e615070 |
rev | line source |
---|---|
38436
b174db545cfd
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
36945
diff
changeset
|
1 ;;; whitespace.el --- warn about and clean bogus whitespaces in the file |
25582 | 2 |
74442 | 3 ;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, |
68651
3bd95f4f2941
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
66327
diff
changeset
|
4 ;; 2005, 2006 Free Software Foundation, Inc. |
25582 | 5 |
29333
189f70e66cab
Update whitespace.el with a more tolerable timer scan time.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
27583
diff
changeset
|
6 ;; Author: Rajesh Vaidheeswarran <rv@gnu.org> |
25582 | 7 ;; Keywords: convenience |
8 | |
9 ;; This file is part of GNU Emacs. | |
10 | |
11 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
12 ;; it under the terms of the GNU General Public License as published by | |
13 ;; the Free Software Foundation; either version 2, or (at your option) | |
14 ;; any later version. | |
15 | |
16 ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
64091 | 23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
24 ;; Boston, MA 02110-1301, USA. | |
25582 | 25 |
26 ;;; Commentary: | |
51542 | 27 ;; |
28 ;; URL: http://www.dsmit.com/lisp/ | |
29 ;; | |
47420
b7a8fec8113c
(whitespace-global-mode): Use define-minor-mode. Use the new file hook names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42013
diff
changeset
|
30 ;; The whitespace library is intended to find and help fix five different types |
b7a8fec8113c
(whitespace-global-mode): Use define-minor-mode. Use the new file hook names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42013
diff
changeset
|
31 ;; of whitespace problems that commonly exist in source code. |
51542 | 32 ;; |
47420
b7a8fec8113c
(whitespace-global-mode): Use define-minor-mode. Use the new file hook names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42013
diff
changeset
|
33 ;; 1. Leading space (empty lines at the top of a file). |
b7a8fec8113c
(whitespace-global-mode): Use define-minor-mode. Use the new file hook names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42013
diff
changeset
|
34 ;; 2. Trailing space (empty lines at the end of a file). |
b7a8fec8113c
(whitespace-global-mode): Use define-minor-mode. Use the new file hook names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42013
diff
changeset
|
35 ;; 3. Indentation space (8 or more spaces at beginning of line, that should be |
52672
d4d213cfb340
whitespace.el now takes user customizable variable to display cleanliness of
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
52401
diff
changeset
|
36 ;; replaced with TABS). |
47420
b7a8fec8113c
(whitespace-global-mode): Use define-minor-mode. Use the new file hook names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42013
diff
changeset
|
37 ;; 4. Spaces followed by a TAB. (Almost always, we never want that). |
b7a8fec8113c
(whitespace-global-mode): Use define-minor-mode. Use the new file hook names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42013
diff
changeset
|
38 ;; 5. Spaces or TABS at the end of a line. |
51542 | 39 ;; |
47420
b7a8fec8113c
(whitespace-global-mode): Use define-minor-mode. Use the new file hook names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42013
diff
changeset
|
40 ;; Whitespace errors are reported in a buffer, and on the modeline. |
51542 | 41 ;; |
47420
b7a8fec8113c
(whitespace-global-mode): Use define-minor-mode. Use the new file hook names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42013
diff
changeset
|
42 ;; Modeline will show a W:<x>!<y> to denote a particular type of whitespace, |
b7a8fec8113c
(whitespace-global-mode): Use define-minor-mode. Use the new file hook names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42013
diff
changeset
|
43 ;; where `x' and `y' can be one (or more) of: |
51542 | 44 ;; |
47420
b7a8fec8113c
(whitespace-global-mode): Use define-minor-mode. Use the new file hook names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42013
diff
changeset
|
45 ;; e - End-of-Line whitespace. |
b7a8fec8113c
(whitespace-global-mode): Use define-minor-mode. Use the new file hook names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42013
diff
changeset
|
46 ;; i - Indentation whitespace. |
b7a8fec8113c
(whitespace-global-mode): Use define-minor-mode. Use the new file hook names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42013
diff
changeset
|
47 ;; l - Leading whitespace. |
b7a8fec8113c
(whitespace-global-mode): Use define-minor-mode. Use the new file hook names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42013
diff
changeset
|
48 ;; s - Space followed by Tab. |
b7a8fec8113c
(whitespace-global-mode): Use define-minor-mode. Use the new file hook names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42013
diff
changeset
|
49 ;; t - Trailing whitespace. |
51542 | 50 ;; |
47420
b7a8fec8113c
(whitespace-global-mode): Use define-minor-mode. Use the new file hook names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42013
diff
changeset
|
51 ;; If any of the whitespace checks is turned off, the modeline will display a |
b7a8fec8113c
(whitespace-global-mode): Use define-minor-mode. Use the new file hook names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42013
diff
changeset
|
52 ;; !<y>. |
51542 | 53 ;; |
47420
b7a8fec8113c
(whitespace-global-mode): Use define-minor-mode. Use the new file hook names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42013
diff
changeset
|
54 ;; (since (3) is the most controversial one, here is the rationale: Most |
b7a8fec8113c
(whitespace-global-mode): Use define-minor-mode. Use the new file hook names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42013
diff
changeset
|
55 ;; terminal drivers and printer drivers have TAB configured or even |
b7a8fec8113c
(whitespace-global-mode): Use define-minor-mode. Use the new file hook names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42013
diff
changeset
|
56 ;; hardcoded to be 8 spaces. (Some of them allow configuration, but almost |
b7a8fec8113c
(whitespace-global-mode): Use define-minor-mode. Use the new file hook names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42013
diff
changeset
|
57 ;; always they default to 8.) |
51542 | 58 ;; |
47420
b7a8fec8113c
(whitespace-global-mode): Use define-minor-mode. Use the new file hook names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42013
diff
changeset
|
59 ;; Changing `tab-width' to other than 8 and editing will cause your code to |
b7a8fec8113c
(whitespace-global-mode): Use define-minor-mode. Use the new file hook names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42013
diff
changeset
|
60 ;; look different from within Emacs, and say, if you cat it or more it, or |
b7a8fec8113c
(whitespace-global-mode): Use define-minor-mode. Use the new file hook names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42013
diff
changeset
|
61 ;; even print it. |
51542 | 62 ;; |
47420
b7a8fec8113c
(whitespace-global-mode): Use define-minor-mode. Use the new file hook names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42013
diff
changeset
|
63 ;; Almost all the popular programming modes let you define an offset (like |
b7a8fec8113c
(whitespace-global-mode): Use define-minor-mode. Use the new file hook names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42013
diff
changeset
|
64 ;; c-basic-offset or perl-indent-level) to configure the offset, so you |
b7a8fec8113c
(whitespace-global-mode): Use define-minor-mode. Use the new file hook names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42013
diff
changeset
|
65 ;; should never have to set your `tab-width' to be other than 8 in all |
b7a8fec8113c
(whitespace-global-mode): Use define-minor-mode. Use the new file hook names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42013
diff
changeset
|
66 ;; these modes. In fact, with an indent level of say, 4, 2 TABS will cause |
b7a8fec8113c
(whitespace-global-mode): Use define-minor-mode. Use the new file hook names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42013
diff
changeset
|
67 ;; Emacs to replace your 8 spaces with one \t (try it). If vi users in |
b7a8fec8113c
(whitespace-global-mode): Use define-minor-mode. Use the new file hook names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42013
diff
changeset
|
68 ;; your office complain, tell them to use vim, which distinguishes between |
b7a8fec8113c
(whitespace-global-mode): Use define-minor-mode. Use the new file hook names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42013
diff
changeset
|
69 ;; tabstop and shiftwidth (vi equivalent of our offsets), and also ask them |
b7a8fec8113c
(whitespace-global-mode): Use define-minor-mode. Use the new file hook names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42013
diff
changeset
|
70 ;; to set smarttab.) |
51542 | 71 ;; |
47420
b7a8fec8113c
(whitespace-global-mode): Use define-minor-mode. Use the new file hook names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42013
diff
changeset
|
72 ;; All the above have caused (and will cause) unwanted codeline integration and |
b7a8fec8113c
(whitespace-global-mode): Use define-minor-mode. Use the new file hook names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42013
diff
changeset
|
73 ;; merge problems. |
51542 | 74 ;; |
47420
b7a8fec8113c
(whitespace-global-mode): Use define-minor-mode. Use the new file hook names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42013
diff
changeset
|
75 ;; whitespace.el will complain if it detects whitespaces on opening a file, and |
b7a8fec8113c
(whitespace-global-mode): Use define-minor-mode. Use the new file hook names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42013
diff
changeset
|
76 ;; warn you on closing a file also (in case you had inserted any |
b7a8fec8113c
(whitespace-global-mode): Use define-minor-mode. Use the new file hook names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42013
diff
changeset
|
77 ;; whitespaces during the process of your editing). |
51542 | 78 ;; |
25582 | 79 ;; Exported functions: |
51542 | 80 ;; |
25582 | 81 ;; `whitespace-buffer' - To check the current buffer for whitespace problems. |
82 ;; `whitespace-cleanup' - To cleanup all whitespaces in the current buffer. | |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
83 ;; `whitespace-region' - To check between point and mark for whitespace |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
84 ;; problems. |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
85 ;; `whitespace-cleanup-region' - To cleanup all whitespaces between point |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
86 ;; and mark in the current buffer. |
25582 | 87 |
88 ;;; Code: | |
89 | |
61488
230af31ce843
whitespace.el - fix higlighting test and bump rev
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
61471
diff
changeset
|
90 (defvar whitespace-version "3.5" "Version of the whitespace library.") |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
91 |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
92 (defvar whitespace-all-buffer-files nil |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
93 "An associated list of buffers and files checked for whitespace cleanliness. |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
94 |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
95 This is to enable periodic checking of whitespace cleanliness in the files |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
96 visited by the buffers.") |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
97 |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
98 (defvar whitespace-rescan-timer nil |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
99 "Timer object used to rescan the files in buffers that have been modified.") |
25582 | 100 |
26245
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
101 ;; Tell Emacs about this new kind of minor mode |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
102 (defvar whitespace-mode nil |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
103 "Non-nil when Whitespace mode (a minor mode) is enabled.") |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
104 (make-variable-buffer-local 'whitespace-mode) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
105 (put 'whitespace-mode 'permanent-local nil) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
106 |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
107 (defvar whitespace-mode-line nil |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
108 "String to display in the mode line for Whitespace mode.") |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
109 (make-variable-buffer-local 'whitespace-mode-line) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
110 (put 'whitespace-mode-line 'permanent-local nil) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
111 |
36944
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
112 (defvar whitespace-check-buffer-leading nil |
64286
f44bd79f483b
(whitespace-check-buffer-leading, whitespace-check-buffer-trailing,
Juanma Barranquero <lekktu@gmail.com>
parents:
64178
diff
changeset
|
113 "Test leading whitespace for file in current buffer if t.") |
36944
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
114 (make-variable-buffer-local 'whitespace-check-buffer-leading) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
115 (put 'whitespace-check-buffer-leading 'permanent-local nil) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
116 |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
117 (defvar whitespace-check-buffer-trailing nil |
64286
f44bd79f483b
(whitespace-check-buffer-leading, whitespace-check-buffer-trailing,
Juanma Barranquero <lekktu@gmail.com>
parents:
64178
diff
changeset
|
118 "Test trailing whitespace for file in current buffer if t.") |
36944
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
119 (make-variable-buffer-local 'whitespace-check-buffer-trailing) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
120 (put 'whitespace-check-buffer-trailing 'permanent-local nil) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
121 |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
122 (defvar whitespace-check-buffer-indent nil |
64286
f44bd79f483b
(whitespace-check-buffer-leading, whitespace-check-buffer-trailing,
Juanma Barranquero <lekktu@gmail.com>
parents:
64178
diff
changeset
|
123 "Test indentation whitespace for file in current buffer if t.") |
36944
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
124 (make-variable-buffer-local 'whitespace-check-buffer-indent) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
125 (put 'whitespace-check-buffer-indent 'permanent-local nil) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
126 |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
127 (defvar whitespace-check-buffer-spacetab nil |
64286
f44bd79f483b
(whitespace-check-buffer-leading, whitespace-check-buffer-trailing,
Juanma Barranquero <lekktu@gmail.com>
parents:
64178
diff
changeset
|
128 "Test Space-followed-by-TABS whitespace for file in current buffer if t.") |
36944
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
129 (make-variable-buffer-local 'whitespace-check-buffer-spacetab) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
130 (put 'whitespace-check-buffer-spacetab 'permanent-local nil) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
131 |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
132 (defvar whitespace-check-buffer-ateol nil |
64286
f44bd79f483b
(whitespace-check-buffer-leading, whitespace-check-buffer-trailing,
Juanma Barranquero <lekktu@gmail.com>
parents:
64178
diff
changeset
|
133 "Test end-of-line whitespace for file in current buffer if t.") |
36944
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
134 (make-variable-buffer-local 'whitespace-check-buffer-ateol) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
135 (put 'whitespace-check-buffer-ateol 'permanent-local nil) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
136 |
42013
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
137 (defvar whitespace-highlighted-space nil |
64286
f44bd79f483b
(whitespace-check-buffer-leading, whitespace-check-buffer-trailing,
Juanma Barranquero <lekktu@gmail.com>
parents:
64178
diff
changeset
|
138 "The variable to store the extent to highlight.") |
42013
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
139 (make-variable-buffer-local 'whitespace-highlighted-space) |
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
140 (put 'whitespace-highlighted-space 'permanent-local nil) |
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
141 |
26253
3bb622df1c52
(whitespace-version): Update to 2.8
Gerd Moellmann <gerd@gnu.org>
parents:
26245
diff
changeset
|
142 ;; For flavors of Emacs which don't define `defgroup' and `defcustom'. |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
143 (eval-when-compile |
26253
3bb622df1c52
(whitespace-version): Update to 2.8
Gerd Moellmann <gerd@gnu.org>
parents:
26245
diff
changeset
|
144 (if (not (fboundp 'defgroup)) |
3bb622df1c52
(whitespace-version): Update to 2.8
Gerd Moellmann <gerd@gnu.org>
parents:
26245
diff
changeset
|
145 (defmacro defgroup (sym memb doc &rest args) |
64286
f44bd79f483b
(whitespace-check-buffer-leading, whitespace-check-buffer-trailing,
Juanma Barranquero <lekktu@gmail.com>
parents:
64178
diff
changeset
|
146 "Null macro for `defgroup' in all versions of Emacs that don't define it." |
26253
3bb622df1c52
(whitespace-version): Update to 2.8
Gerd Moellmann <gerd@gnu.org>
parents:
26245
diff
changeset
|
147 t)) |
3bb622df1c52
(whitespace-version): Update to 2.8
Gerd Moellmann <gerd@gnu.org>
parents:
26245
diff
changeset
|
148 (if (not (fboundp 'defcustom)) |
3bb622df1c52
(whitespace-version): Update to 2.8
Gerd Moellmann <gerd@gnu.org>
parents:
26245
diff
changeset
|
149 (defmacro defcustom (sym val doc &rest args) |
64286
f44bd79f483b
(whitespace-check-buffer-leading, whitespace-check-buffer-trailing,
Juanma Barranquero <lekktu@gmail.com>
parents:
64178
diff
changeset
|
150 "Macro to alias `defcustom' to `defvar' in all versions of Emacs that |
f44bd79f483b
(whitespace-check-buffer-leading, whitespace-check-buffer-trailing,
Juanma Barranquero <lekktu@gmail.com>
parents:
64178
diff
changeset
|
151 don't define it." |
26253
3bb622df1c52
(whitespace-version): Update to 2.8
Gerd Moellmann <gerd@gnu.org>
parents:
26245
diff
changeset
|
152 `(defvar ,sym ,val ,doc)))) |
25582 | 153 |
64378
89982901a9ad
(whitespace-make-overlay)
Richard M. Stallman <rms@gnu.org>
parents:
64286
diff
changeset
|
154 (defalias 'whitespace-make-overlay |
89982901a9ad
(whitespace-make-overlay)
Richard M. Stallman <rms@gnu.org>
parents:
64286
diff
changeset
|
155 (if (featurep 'xemacs) 'make-extent 'make-overlay)) |
89982901a9ad
(whitespace-make-overlay)
Richard M. Stallman <rms@gnu.org>
parents:
64286
diff
changeset
|
156 (defalias 'whitespace-overlay-put |
89982901a9ad
(whitespace-make-overlay)
Richard M. Stallman <rms@gnu.org>
parents:
64286
diff
changeset
|
157 (if (featurep 'xemacs) 'set-extent-property 'overlay-put)) |
89982901a9ad
(whitespace-make-overlay)
Richard M. Stallman <rms@gnu.org>
parents:
64286
diff
changeset
|
158 (defalias 'whitespace-delete-overlay |
89982901a9ad
(whitespace-make-overlay)
Richard M. Stallman <rms@gnu.org>
parents:
64286
diff
changeset
|
159 (if (featurep 'xemacs) 'delete-extent 'delete-overlay)) |
89982901a9ad
(whitespace-make-overlay)
Richard M. Stallman <rms@gnu.org>
parents:
64286
diff
changeset
|
160 (defalias 'whitespace-overlay-start |
89982901a9ad
(whitespace-make-overlay)
Richard M. Stallman <rms@gnu.org>
parents:
64286
diff
changeset
|
161 (if (featurep 'xemacs) 'extent-start 'overlay-start)) |
89982901a9ad
(whitespace-make-overlay)
Richard M. Stallman <rms@gnu.org>
parents:
64286
diff
changeset
|
162 (defalias 'whitespace-overlay-end |
89982901a9ad
(whitespace-make-overlay)
Richard M. Stallman <rms@gnu.org>
parents:
64286
diff
changeset
|
163 (if (featurep 'xemacs) 'extent-end 'overlay-end)) |
89982901a9ad
(whitespace-make-overlay)
Richard M. Stallman <rms@gnu.org>
parents:
64286
diff
changeset
|
164 (defalias 'whitespace-mode-line-update |
89982901a9ad
(whitespace-make-overlay)
Richard M. Stallman <rms@gnu.org>
parents:
64286
diff
changeset
|
165 (if (featurep 'xemacs) 'redraw-modeline 'force-mode-line-update)) |
42013
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
166 |
32501 | 167 (defgroup whitespace nil |
168 "Check for and fix five different types of whitespaces in source code." | |
169 :version "21.1" | |
51542 | 170 :link '(emacs-commentary-link "whitespace.el") |
64378
89982901a9ad
(whitespace-make-overlay)
Richard M. Stallman <rms@gnu.org>
parents:
64286
diff
changeset
|
171 ;; Since XEmacs doesn't have a 'convenience group, use the next best group |
89982901a9ad
(whitespace-make-overlay)
Richard M. Stallman <rms@gnu.org>
parents:
64286
diff
changeset
|
172 ;; which is 'editing? |
89982901a9ad
(whitespace-make-overlay)
Richard M. Stallman <rms@gnu.org>
parents:
64286
diff
changeset
|
173 :group (if (featurep 'xemacs) 'editing 'convenience)) |
25582 | 174 |
25724
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
175 (defcustom whitespace-check-leading-whitespace t |
64286
f44bd79f483b
(whitespace-check-buffer-leading, whitespace-check-buffer-trailing,
Juanma Barranquero <lekktu@gmail.com>
parents:
64178
diff
changeset
|
176 "Flag to check leading whitespace. This is the global for the system. |
36944
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
177 It can be overriden by setting a buffer local variable |
64286
f44bd79f483b
(whitespace-check-buffer-leading, whitespace-check-buffer-trailing,
Juanma Barranquero <lekktu@gmail.com>
parents:
64178
diff
changeset
|
178 `whitespace-check-buffer-leading'." |
25724
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
179 :type 'boolean |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
180 :group 'whitespace) |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
181 |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
182 (defcustom whitespace-check-trailing-whitespace t |
64286
f44bd79f483b
(whitespace-check-buffer-leading, whitespace-check-buffer-trailing,
Juanma Barranquero <lekktu@gmail.com>
parents:
64178
diff
changeset
|
183 "Flag to check trailing whitespace. This is the global for the system. |
36944
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
184 It can be overriden by setting a buffer local variable |
64286
f44bd79f483b
(whitespace-check-buffer-leading, whitespace-check-buffer-trailing,
Juanma Barranquero <lekktu@gmail.com>
parents:
64178
diff
changeset
|
185 `whitespace-check-buffer-trailing'." |
25724
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
186 :type 'boolean |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
187 :group 'whitespace) |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
188 |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
189 (defcustom whitespace-check-spacetab-whitespace t |
64286
f44bd79f483b
(whitespace-check-buffer-leading, whitespace-check-buffer-trailing,
Juanma Barranquero <lekktu@gmail.com>
parents:
64178
diff
changeset
|
190 "Flag to check space followed by a TAB. This is the global for the system. |
36944
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
191 It can be overriden by setting a buffer local variable |
64286
f44bd79f483b
(whitespace-check-buffer-leading, whitespace-check-buffer-trailing,
Juanma Barranquero <lekktu@gmail.com>
parents:
64178
diff
changeset
|
192 `whitespace-check-buffer-spacetab'." |
25724
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
193 :type 'boolean |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
194 :group 'whitespace) |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
195 |
42013
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
196 (defcustom whitespace-spacetab-regexp "[ ]+\t" |
73666
b0f398ac4cbd
(whitespace-indent-regexp): Make this match any multiples of eight spaces near
Eli Zaretskii <eliz@gnu.org>
parents:
72472
diff
changeset
|
197 "Regexp to match one or more spaces followed by a TAB." |
32501 | 198 :type 'regexp |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
199 :group 'whitespace) |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
200 |
38882 | 201 (defcustom whitespace-check-indent-whitespace indent-tabs-mode |
64286
f44bd79f483b
(whitespace-check-buffer-leading, whitespace-check-buffer-trailing,
Juanma Barranquero <lekktu@gmail.com>
parents:
64178
diff
changeset
|
202 "Flag to check indentation whitespace. This is the global for the system. |
36944
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
203 It can be overriden by setting a buffer local variable |
64286
f44bd79f483b
(whitespace-check-buffer-leading, whitespace-check-buffer-trailing,
Juanma Barranquero <lekktu@gmail.com>
parents:
64178
diff
changeset
|
204 `whitespace-check-buffer-indent'." |
25724
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
205 :type 'boolean |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
206 :group 'whitespace) |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
207 |
73666
b0f398ac4cbd
(whitespace-indent-regexp): Make this match any multiples of eight spaces near
Eli Zaretskii <eliz@gnu.org>
parents:
72472
diff
changeset
|
208 (defcustom whitespace-indent-regexp "^\t*\\( \\)+" |
b0f398ac4cbd
(whitespace-indent-regexp): Make this match any multiples of eight spaces near
Eli Zaretskii <eliz@gnu.org>
parents:
72472
diff
changeset
|
209 "Regexp to match multiples of eight spaces near line beginnings. |
b0f398ac4cbd
(whitespace-indent-regexp): Make this match any multiples of eight spaces near
Eli Zaretskii <eliz@gnu.org>
parents:
72472
diff
changeset
|
210 The default value ignores leading TABs." |
32501 | 211 :type 'regexp |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
212 :group 'whitespace) |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
213 |
25724
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
214 (defcustom whitespace-check-ateol-whitespace t |
64286
f44bd79f483b
(whitespace-check-buffer-leading, whitespace-check-buffer-trailing,
Juanma Barranquero <lekktu@gmail.com>
parents:
64178
diff
changeset
|
215 "Flag to check end-of-line whitespace. This is the global for the system. |
36944
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
216 It can be overriden by setting a buffer local variable |
64286
f44bd79f483b
(whitespace-check-buffer-leading, whitespace-check-buffer-trailing,
Juanma Barranquero <lekktu@gmail.com>
parents:
64178
diff
changeset
|
217 `whitespace-check-buffer-ateol'." |
25724
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
218 :type 'boolean |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
219 :group 'whitespace) |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
220 |
42013
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
221 (defcustom whitespace-ateol-regexp "[ \t]+$" |
73666
b0f398ac4cbd
(whitespace-indent-regexp): Make this match any multiples of eight spaces near
Eli Zaretskii <eliz@gnu.org>
parents:
72472
diff
changeset
|
222 "Regexp to match one or more TABs or spaces at line ends." |
32501 | 223 :type 'regexp |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
224 :group 'whitespace) |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
225 |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
226 (defcustom whitespace-errbuf "*Whitespace Errors*" |
32501 | 227 "The name of the buffer where whitespace related messages will be logged." |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
228 :type 'string |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
229 :group 'whitespace) |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
230 |
52672
d4d213cfb340
whitespace.el now takes user customizable variable to display cleanliness of
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
52401
diff
changeset
|
231 (defcustom whitespace-clean-msg "clean." |
d4d213cfb340
whitespace.el now takes user customizable variable to display cleanliness of
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
52401
diff
changeset
|
232 "If non-nil, this message will be displayed after a whitespace check |
d4d213cfb340
whitespace.el now takes user customizable variable to display cleanliness of
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
52401
diff
changeset
|
233 determines a file to be clean." |
d4d213cfb340
whitespace.el now takes user customizable variable to display cleanliness of
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
52401
diff
changeset
|
234 :type 'string |
d4d213cfb340
whitespace.el now takes user customizable variable to display cleanliness of
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
52401
diff
changeset
|
235 :group 'whitespace) |
d4d213cfb340
whitespace.el now takes user customizable variable to display cleanliness of
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
52401
diff
changeset
|
236 |
38882 | 237 (defcustom whitespace-abort-on-error nil |
64286
f44bd79f483b
(whitespace-check-buffer-leading, whitespace-check-buffer-trailing,
Juanma Barranquero <lekktu@gmail.com>
parents:
64178
diff
changeset
|
238 "While writing a file, abort if the file is unclean. |
f44bd79f483b
(whitespace-check-buffer-leading, whitespace-check-buffer-trailing,
Juanma Barranquero <lekktu@gmail.com>
parents:
64178
diff
changeset
|
239 If `whitespace-auto-cleanup' is set, that takes precedence over |
f44bd79f483b
(whitespace-check-buffer-leading, whitespace-check-buffer-trailing,
Juanma Barranquero <lekktu@gmail.com>
parents:
64178
diff
changeset
|
240 this variable." |
38882 | 241 :type 'boolean |
242 :group 'whitespace) | |
243 | |
25582 | 244 (defcustom whitespace-auto-cleanup nil |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
245 "Cleanup a buffer automatically on finding it whitespace unclean." |
25582 | 246 :type 'boolean |
247 :group 'whitespace) | |
248 | |
249 (defcustom whitespace-silent nil | |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
250 "All whitespace errors will be shown only in the modeline when t. |
25582 | 251 |
252 Note that setting this may cause all whitespaces introduced in a file to go | |
253 unnoticed when the buffer is killed, unless the user visits the `*Whitespace | |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
254 Errors*' buffer before opening (or closing) another file." |
25582 | 255 :type 'boolean |
256 :group 'whitespace) | |
257 | |
258 (defcustom whitespace-modes '(ada-mode asm-mode autoconf-mode awk-mode | |
25724
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
259 c-mode c++-mode cc-mode |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
260 change-log-mode cperl-mode |
25582 | 261 electric-nroff-mode emacs-lisp-mode |
262 f90-mode fortran-mode html-mode | |
263 html3-mode java-mode jde-mode | |
264 ksh-mode latex-mode LaTeX-mode | |
265 lisp-mode m4-mode makefile-mode | |
266 modula-2-mode nroff-mode objc-mode | |
267 pascal-mode perl-mode prolog-mode | |
268 python-mode scheme-mode sgml-mode | |
25724
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
269 sh-mode shell-script-mode simula-mode |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
270 tcl-mode tex-mode texinfo-mode |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
271 vrml-mode xml-mode) |
25582 | 272 |
64286
f44bd79f483b
(whitespace-check-buffer-leading, whitespace-check-buffer-trailing,
Juanma Barranquero <lekktu@gmail.com>
parents:
64178
diff
changeset
|
273 "Major modes in which we turn on whitespace checking. |
25582 | 274 |
32501 | 275 These are mostly programming and documentation modes. But you may add other |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
276 modes that you want whitespaces checked in by adding something like the |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
277 following to your `.emacs': |
25582 | 278 |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
279 \(setq whitespace-modes (cons 'my-mode (cons 'my-other-mode |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
280 whitespace-modes))\) |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
281 |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
282 Or, alternately, you can use the Emacs `customize' command to set this." |
32501 | 283 :type '(repeat symbol) |
25582 | 284 :group 'whitespace) |
285 | |
29333
189f70e66cab
Update whitespace.el with a more tolerable timer scan time.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
27583
diff
changeset
|
286 (defcustom whitespace-rescan-timer-time 600 |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
287 "Period in seconds to rescan modified buffers for whitespace creep. |
25582 | 288 |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
289 This is the period after which the timer will fire causing |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
290 `whitespace-rescan-files-in-buffers' to check for whitespace creep in |
25724
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
291 modified buffers. |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
292 |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
293 To disable timer scans, set this to zero." |
25582 | 294 :type 'integer |
295 :group 'whitespace) | |
296 | |
26245
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
297 (defcustom whitespace-display-in-modeline t |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
298 "Display whitespace errors on the modeline." |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
299 :type 'boolean |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
300 :group 'whitespace) |
25582 | 301 |
42013
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
302 (defcustom whitespace-display-spaces-in-color t |
63200
eef21c221eff
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-371
Miles Bader <miles@gnu.org>
parents:
61492
diff
changeset
|
303 "Display the bogus whitespaces by coloring them with the face |
eef21c221eff
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-371
Miles Bader <miles@gnu.org>
parents:
61492
diff
changeset
|
304 `whitespace-highlight'." |
42013
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
305 :type 'boolean |
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
306 :group 'whitespace) |
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
307 |
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
308 (defgroup whitespace-faces nil |
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
309 "Faces used in whitespace." |
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
310 :prefix "whitespace-" |
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
311 :group 'whitespace |
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
312 :group 'faces) |
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
313 |
63200
eef21c221eff
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-371
Miles Bader <miles@gnu.org>
parents:
61492
diff
changeset
|
314 (defface whitespace-highlight '((((class color) (background light)) |
eef21c221eff
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-371
Miles Bader <miles@gnu.org>
parents:
61492
diff
changeset
|
315 (:background "green1")) |
eef21c221eff
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-371
Miles Bader <miles@gnu.org>
parents:
61492
diff
changeset
|
316 (((class color) (background dark)) |
eef21c221eff
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-371
Miles Bader <miles@gnu.org>
parents:
61492
diff
changeset
|
317 (:background "sea green")) |
eef21c221eff
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-371
Miles Bader <miles@gnu.org>
parents:
61492
diff
changeset
|
318 (((class grayscale mono) |
eef21c221eff
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-371
Miles Bader <miles@gnu.org>
parents:
61492
diff
changeset
|
319 (background light)) |
eef21c221eff
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-371
Miles Bader <miles@gnu.org>
parents:
61492
diff
changeset
|
320 (:background "black")) |
eef21c221eff
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-371
Miles Bader <miles@gnu.org>
parents:
61492
diff
changeset
|
321 (((class grayscale mono) |
eef21c221eff
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-371
Miles Bader <miles@gnu.org>
parents:
61492
diff
changeset
|
322 (background dark)) |
eef21c221eff
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-371
Miles Bader <miles@gnu.org>
parents:
61492
diff
changeset
|
323 (:background "white"))) |
42013
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
324 "Face used for highlighting the bogus whitespaces that exist in the buffer." |
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
325 :group 'whitespace-faces) |
63200
eef21c221eff
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-371
Miles Bader <miles@gnu.org>
parents:
61492
diff
changeset
|
326 ;; backward-compatibility alias |
eef21c221eff
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-371
Miles Bader <miles@gnu.org>
parents:
61492
diff
changeset
|
327 (put 'whitespace-highlight-face 'face-alias 'whitespace-highlight) |
42013
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
328 |
25582 | 329 (if (not (assoc 'whitespace-mode minor-mode-alist)) |
330 (setq minor-mode-alist (cons '(whitespace-mode whitespace-mode-line) | |
331 minor-mode-alist))) | |
332 | |
36944
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
333 (set-default 'whitespace-check-buffer-leading |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
334 whitespace-check-leading-whitespace) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
335 (set-default 'whitespace-check-buffer-trailing |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
336 whitespace-check-trailing-whitespace) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
337 (set-default 'whitespace-check-buffer-indent |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
338 whitespace-check-indent-whitespace) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
339 (set-default 'whitespace-check-buffer-spacetab |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
340 whitespace-check-spacetab-whitespace) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
341 (set-default 'whitespace-check-buffer-ateol |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
342 whitespace-check-ateol-whitespace) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
343 |
25582 | 344 (defun whitespace-check-whitespace-mode (&optional arg) |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
345 "Test and set the whitespace-mode in qualifying buffers." |
25582 | 346 (if (null whitespace-mode) |
347 (setq whitespace-mode | |
348 (if (or arg (member major-mode whitespace-modes)) | |
349 t | |
350 nil)))) | |
351 | |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
352 ;;;###autoload |
36944
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
353 (defun whitespace-toggle-leading-check () |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
354 "Toggle the check for leading space in the local buffer." |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
355 (interactive) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
356 (let ((current-val whitespace-check-buffer-leading)) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
357 (setq whitespace-check-buffer-leading (not current-val)) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
358 (message "Will%s check for leading space in buffer." |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
359 (if whitespace-check-buffer-leading "" " not")) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
360 (if whitespace-check-buffer-leading (whitespace-buffer-leading)))) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
361 |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
362 ;;;###autoload |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
363 (defun whitespace-toggle-trailing-check () |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
364 "Toggle the check for trailing space in the local buffer." |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
365 (interactive) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
366 (let ((current-val whitespace-check-buffer-trailing)) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
367 (setq whitespace-check-buffer-trailing (not current-val)) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
368 (message "Will%s check for trailing space in buffer." |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
369 (if whitespace-check-buffer-trailing "" " not")) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
370 (if whitespace-check-buffer-trailing (whitespace-buffer-trailing)))) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
371 |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
372 ;;;###autoload |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
373 (defun whitespace-toggle-indent-check () |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
374 "Toggle the check for indentation space in the local buffer." |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
375 (interactive) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
376 (let ((current-val whitespace-check-buffer-indent)) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
377 (setq whitespace-check-buffer-indent (not current-val)) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
378 (message "Will%s check for indentation space in buffer." |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
379 (if whitespace-check-buffer-indent "" " not")) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
380 (if whitespace-check-buffer-indent |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
381 (whitespace-buffer-search whitespace-indent-regexp)))) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
382 |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
383 ;;;###autoload |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
384 (defun whitespace-toggle-spacetab-check () |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
385 "Toggle the check for space-followed-by-TABs in the local buffer." |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
386 (interactive) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
387 (let ((current-val whitespace-check-buffer-spacetab)) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
388 (setq whitespace-check-buffer-spacetab (not current-val)) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
389 (message "Will%s check for space-followed-by-TABs in buffer." |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
390 (if whitespace-check-buffer-spacetab "" " not")) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
391 (if whitespace-check-buffer-spacetab |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
392 (whitespace-buffer-search whitespace-spacetab-regexp)))) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
393 |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
394 |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
395 ;;;###autoload |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
396 (defun whitespace-toggle-ateol-check () |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
397 "Toggle the check for end-of-line space in the local buffer." |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
398 (interactive) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
399 (let ((current-val whitespace-check-buffer-ateol)) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
400 (setq whitespace-check-buffer-ateol (not current-val)) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
401 (message "Will%s check for end-of-line space in buffer." |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
402 (if whitespace-check-buffer-ateol "" " not")) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
403 (if whitespace-check-buffer-ateol |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
404 (whitespace-buffer-search whitespace-ateol-regexp)))) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
405 |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
406 |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
407 ;;;###autoload |
25582 | 408 (defun whitespace-buffer (&optional quiet) |
32501 | 409 "Find five different types of white spaces in buffer. |
410 These are: | |
25582 | 411 1. Leading space \(empty lines at the top of a file\). |
412 2. Trailing space \(empty lines at the end of a file\). | |
413 3. Indentation space \(8 or more spaces, that should be replaced with TABS\). | |
414 4. Spaces followed by a TAB. \(Almost always, we never want that\). | |
415 5. Spaces or TABS at the end of a line. | |
416 | |
417 Check for whitespace only if this buffer really contains a non-empty file | |
418 and: | |
419 1. the major mode is one of the whitespace-modes, or | |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
420 2. `whitespace-buffer' was explicitly called with a prefix argument." |
25582 | 421 (interactive) |
26245
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
422 (let ((whitespace-error nil)) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
423 (whitespace-check-whitespace-mode current-prefix-arg) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
424 (if (and buffer-file-name (> (buffer-size) 0) whitespace-mode) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
425 (progn |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
426 (whitespace-check-buffer-list (buffer-name) buffer-file-name) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
427 (whitespace-tickle-timer) |
73812
75af8d959739
(whitespace-buffer): Call remove-overlays after overlay-recenter for
Chong Yidong <cyd@stupidchicken.com>
parents:
73666
diff
changeset
|
428 (overlay-recenter (point-max)) |
73666
b0f398ac4cbd
(whitespace-indent-regexp): Make this match any multiples of eight spaces near
Eli Zaretskii <eliz@gnu.org>
parents:
72472
diff
changeset
|
429 (remove-overlays nil nil 'face 'whitespace-highlight) |
26245
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
430 (if whitespace-auto-cleanup |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
431 (if buffer-read-only |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
432 (if (not quiet) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
433 (message "Can't cleanup: %s is read-only" (buffer-name))) |
70927
1d492927a08d
whitespace.el - make whitesspace-cleanup use the current active regoin, if there is one.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
68651
diff
changeset
|
434 (whitespace-cleanup-internal)) |
36944
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
435 (let ((whitespace-leading (if whitespace-check-buffer-leading |
26245
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
436 (whitespace-buffer-leading) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
437 nil)) |
36944
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
438 (whitespace-trailing (if whitespace-check-buffer-trailing |
26245
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
439 (whitespace-buffer-trailing) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
440 nil)) |
36944
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
441 (whitespace-indent (if whitespace-check-buffer-indent |
26245
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
442 (whitespace-buffer-search |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
443 whitespace-indent-regexp) |
25724
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
444 nil)) |
36944
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
445 (whitespace-spacetab (if whitespace-check-buffer-spacetab |
26245
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
446 (whitespace-buffer-search |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
447 whitespace-spacetab-regexp) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
448 nil)) |
36944
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
449 (whitespace-ateol (if whitespace-check-buffer-ateol |
26245
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
450 (whitespace-buffer-search |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
451 whitespace-ateol-regexp) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
452 nil)) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
453 (whitespace-errmsg nil) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
454 (whitespace-filename buffer-file-name) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
455 (whitespace-this-modeline "")) |
25582 | 456 |
26245
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
457 ;; Now let's complain if we found any of the above. |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
458 (setq whitespace-error (or whitespace-leading whitespace-indent |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
459 whitespace-spacetab whitespace-ateol |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
460 whitespace-trailing)) |
25582 | 461 |
26245
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
462 (if whitespace-error |
25582 | 463 (progn |
26245
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
464 (setq whitespace-errmsg |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
465 (concat whitespace-filename " contains:\n" |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
466 (if whitespace-leading |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
467 "Leading whitespace\n") |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
468 (if whitespace-indent |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
469 (concat "Indentation whitespace" |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
470 whitespace-indent "\n")) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
471 (if whitespace-spacetab |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
472 (concat "Space followed by Tab" |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
473 whitespace-spacetab "\n")) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
474 (if whitespace-ateol |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
475 (concat "End-of-line whitespace" |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
476 whitespace-ateol "\n")) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
477 (if whitespace-trailing |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
478 "Trailing whitespace\n") |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
479 "\ntype `M-x whitespace-cleanup' to " |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
480 "cleanup the file.")) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
481 (setq whitespace-this-modeline |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
482 (concat (if whitespace-ateol "e") |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
483 (if whitespace-indent "i") |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
484 (if whitespace-leading "l") |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
485 (if whitespace-spacetab "s") |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
486 (if whitespace-trailing "t"))))) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
487 (whitespace-update-modeline whitespace-this-modeline) |
61395
21f8452c722e
(whitespace-highlight-the-space): Put the same overlay
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
61394
diff
changeset
|
488 (if (get-buffer whitespace-errbuf) |
21f8452c722e
(whitespace-highlight-the-space): Put the same overlay
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
61394
diff
changeset
|
489 (kill-buffer whitespace-errbuf)) |
21f8452c722e
(whitespace-highlight-the-space): Put the same overlay
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
61394
diff
changeset
|
490 (with-current-buffer (get-buffer-create whitespace-errbuf) |
26245
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
491 (if whitespace-errmsg |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
492 (progn |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
493 (insert whitespace-errmsg) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
494 (if (not (or quiet whitespace-silent)) |
61395
21f8452c722e
(whitespace-highlight-the-space): Put the same overlay
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
61394
diff
changeset
|
495 (display-buffer (current-buffer) t)) |
26245
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
496 (if (not quiet) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
497 (message "Whitespaces: [%s%s] in %s" |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
498 whitespace-this-modeline |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
499 (let ((whitespace-unchecked |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
500 (whitespace-unchecked-whitespaces))) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
501 (if whitespace-unchecked |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
502 (concat "!" whitespace-unchecked) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
503 "")) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
504 whitespace-filename))) |
52672
d4d213cfb340
whitespace.el now takes user customizable variable to display cleanliness of
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
52401
diff
changeset
|
505 (if (and (not quiet) (not (equal whitespace-clean-msg ""))) |
d4d213cfb340
whitespace.el now takes user customizable variable to display cleanliness of
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
52401
diff
changeset
|
506 (message "%s %s" whitespace-filename |
d4d213cfb340
whitespace.el now takes user customizable variable to display cleanliness of
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
52401
diff
changeset
|
507 whitespace-clean-msg)))))))) |
61395
21f8452c722e
(whitespace-highlight-the-space): Put the same overlay
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
61394
diff
changeset
|
508 whitespace-error)) |
25582 | 509 |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
510 ;;;###autoload |
25582 | 511 (defun whitespace-region (s e) |
32501 | 512 "Check the region for whitespace errors." |
25582 | 513 (interactive "r") |
514 (save-excursion | |
515 (save-restriction | |
516 (narrow-to-region s e) | |
517 (whitespace-buffer)))) | |
518 | |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
519 ;;;###autoload |
25582 | 520 (defun whitespace-cleanup () |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
521 "Cleanup the five different kinds of whitespace problems. |
72472
1f82c3397a43
(whitespace-cleanup): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
72442
diff
changeset
|
522 It normally applies to the whole buffer, but in Transient Mark mode |
1f82c3397a43
(whitespace-cleanup): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
72442
diff
changeset
|
523 when the mark is active it applies to the region. |
66327
63c0efccff42
(whitespace-cleanup): Doc fix.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64762
diff
changeset
|
524 See `whitespace-buffer' docstring for a summary of the problems." |
25582 | 525 (interactive) |
70927
1d492927a08d
whitespace.el - make whitesspace-cleanup use the current active regoin, if there is one.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
68651
diff
changeset
|
526 (if (and transient-mark-mode mark-active) |
1d492927a08d
whitespace.el - make whitesspace-cleanup use the current active regoin, if there is one.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
68651
diff
changeset
|
527 (whitespace-cleanup-region (region-beginning) (region-end)) |
1d492927a08d
whitespace.el - make whitesspace-cleanup use the current active regoin, if there is one.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
68651
diff
changeset
|
528 (whitespace-cleanup-internal))) |
1d492927a08d
whitespace.el - make whitesspace-cleanup use the current active regoin, if there is one.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
68651
diff
changeset
|
529 |
72442
384cd9b2e977
(whitespace-cleanup-internal): New optional arg REGION-ONLY. If it's non-nil,
Eli Zaretskii <eliz@gnu.org>
parents:
70927
diff
changeset
|
530 (defun whitespace-cleanup-internal (&optional region-only) |
25582 | 531 ;; If this buffer really contains a file, then run, else quit. |
532 (whitespace-check-whitespace-mode current-prefix-arg) | |
533 (if (and buffer-file-name whitespace-mode) | |
534 (let ((whitespace-any nil) | |
535 (whitespace-tabwith 8) | |
536 (whitespace-tabwith-saved tab-width)) | |
537 | |
538 ;; since all printable TABS should be 8, irrespective of how | |
539 ;; they are displayed. | |
540 (setq tab-width whitespace-tabwith) | |
541 | |
36944
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
542 (if (and whitespace-check-buffer-leading |
25724
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
543 (whitespace-buffer-leading)) |
25582 | 544 (progn |
545 (whitespace-buffer-leading-cleanup) | |
546 (setq whitespace-any t))) | |
547 | |
36944
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
548 (if (and whitespace-check-buffer-trailing |
25724
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
549 (whitespace-buffer-trailing)) |
25582 | 550 (progn |
551 (whitespace-buffer-trailing-cleanup) | |
552 (setq whitespace-any t))) | |
553 | |
36944
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
554 (if (and whitespace-check-buffer-indent |
25724
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
555 (whitespace-buffer-search whitespace-indent-regexp)) |
25582 | 556 (progn |
557 (whitespace-indent-cleanup) | |
558 (setq whitespace-any t))) | |
559 | |
36944
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
560 (if (and whitespace-check-buffer-spacetab |
25724
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
561 (whitespace-buffer-search whitespace-spacetab-regexp)) |
25582 | 562 (progn |
563 (whitespace-buffer-cleanup whitespace-spacetab-regexp "\t") | |
564 (setq whitespace-any t))) | |
565 | |
36944
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
566 (if (and whitespace-check-buffer-ateol |
25724
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
567 (whitespace-buffer-search whitespace-ateol-regexp)) |
25582 | 568 (progn |
569 (whitespace-buffer-cleanup whitespace-ateol-regexp "") | |
570 (setq whitespace-any t))) | |
571 | |
572 ;; Call this recursively till everything is taken care of | |
25724
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
573 (if whitespace-any |
74396
ee60f0fe10d6
(whitespace-cleanup-internal): Use current
Dan Nicolaescu <dann@ics.uci.edu>
parents:
73812
diff
changeset
|
574 (whitespace-cleanup-internal region-only) |
72442
384cd9b2e977
(whitespace-cleanup-internal): New optional arg REGION-ONLY. If it's non-nil,
Eli Zaretskii <eliz@gnu.org>
parents:
70927
diff
changeset
|
575 ;; if we are done, talk to the user |
25582 | 576 (progn |
72442
384cd9b2e977
(whitespace-cleanup-internal): New optional arg REGION-ONLY. If it's non-nil,
Eli Zaretskii <eliz@gnu.org>
parents:
70927
diff
changeset
|
577 (unless whitespace-silent |
384cd9b2e977
(whitespace-cleanup-internal): New optional arg REGION-ONLY. If it's non-nil,
Eli Zaretskii <eliz@gnu.org>
parents:
70927
diff
changeset
|
578 (if region-only |
384cd9b2e977
(whitespace-cleanup-internal): New optional arg REGION-ONLY. If it's non-nil,
Eli Zaretskii <eliz@gnu.org>
parents:
70927
diff
changeset
|
579 (message "The region is now clean") |
384cd9b2e977
(whitespace-cleanup-internal): New optional arg REGION-ONLY. If it's non-nil,
Eli Zaretskii <eliz@gnu.org>
parents:
70927
diff
changeset
|
580 (message "%s is now clean" buffer-file-name))) |
26245
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
581 (whitespace-update-modeline))) |
25582 | 582 (setq tab-width whitespace-tabwith-saved)))) |
583 | |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
584 ;;;###autoload |
25582 | 585 (defun whitespace-cleanup-region (s e) |
32501 | 586 "Whitespace cleanup on the region." |
25582 | 587 (interactive "r") |
588 (save-excursion | |
589 (save-restriction | |
590 (narrow-to-region s e) | |
72442
384cd9b2e977
(whitespace-cleanup-internal): New optional arg REGION-ONLY. If it's non-nil,
Eli Zaretskii <eliz@gnu.org>
parents:
70927
diff
changeset
|
591 (whitespace-cleanup-internal t)) |
25582 | 592 (whitespace-buffer t))) |
593 | |
594 (defun whitespace-buffer-leading () | |
73666
b0f398ac4cbd
(whitespace-indent-regexp): Make this match any multiples of eight spaces near
Eli Zaretskii <eliz@gnu.org>
parents:
72472
diff
changeset
|
595 "Return t if the current buffer has leading newline characters. |
b0f398ac4cbd
(whitespace-indent-regexp): Make this match any multiples of eight spaces near
Eli Zaretskii <eliz@gnu.org>
parents:
72472
diff
changeset
|
596 If highlighting is enabled, highlight these characters." |
25582 | 597 (save-excursion |
73666
b0f398ac4cbd
(whitespace-indent-regexp): Make this match any multiples of eight spaces near
Eli Zaretskii <eliz@gnu.org>
parents:
72472
diff
changeset
|
598 (goto-char (point-min)) |
b0f398ac4cbd
(whitespace-indent-regexp): Make this match any multiples of eight spaces near
Eli Zaretskii <eliz@gnu.org>
parents:
72472
diff
changeset
|
599 (skip-chars-forward "\n") |
b0f398ac4cbd
(whitespace-indent-regexp): Make this match any multiples of eight spaces near
Eli Zaretskii <eliz@gnu.org>
parents:
72472
diff
changeset
|
600 (unless (bobp) |
b0f398ac4cbd
(whitespace-indent-regexp): Make this match any multiples of eight spaces near
Eli Zaretskii <eliz@gnu.org>
parents:
72472
diff
changeset
|
601 (whitespace-highlight-the-space (point-min) (point)) |
b0f398ac4cbd
(whitespace-indent-regexp): Make this match any multiples of eight spaces near
Eli Zaretskii <eliz@gnu.org>
parents:
72472
diff
changeset
|
602 t))) |
25582 | 603 |
604 (defun whitespace-buffer-leading-cleanup () | |
73666
b0f398ac4cbd
(whitespace-indent-regexp): Make this match any multiples of eight spaces near
Eli Zaretskii <eliz@gnu.org>
parents:
72472
diff
changeset
|
605 "Remove any leading newline characters from current buffer." |
25582 | 606 (save-excursion |
64178
0b1f11faf0b2
(whitespace-buffer-leading-cleanup): Simplify w/ skip-chars-forward.
Richard M. Stallman <rms@gnu.org>
parents:
64091
diff
changeset
|
607 (goto-char (point-min)) |
0b1f11faf0b2
(whitespace-buffer-leading-cleanup): Simplify w/ skip-chars-forward.
Richard M. Stallman <rms@gnu.org>
parents:
64091
diff
changeset
|
608 (skip-chars-forward "\n") |
0b1f11faf0b2
(whitespace-buffer-leading-cleanup): Simplify w/ skip-chars-forward.
Richard M. Stallman <rms@gnu.org>
parents:
64091
diff
changeset
|
609 (delete-region (point-min) (point)))) |
25582 | 610 |
611 (defun whitespace-buffer-trailing () | |
73666
b0f398ac4cbd
(whitespace-indent-regexp): Make this match any multiples of eight spaces near
Eli Zaretskii <eliz@gnu.org>
parents:
72472
diff
changeset
|
612 "Return t if the current buffer has extra trailing newline characters. |
b0f398ac4cbd
(whitespace-indent-regexp): Make this match any multiples of eight spaces near
Eli Zaretskii <eliz@gnu.org>
parents:
72472
diff
changeset
|
613 If highlighting is enabled, highlight these characters." |
25582 | 614 (save-excursion |
73666
b0f398ac4cbd
(whitespace-indent-regexp): Make this match any multiples of eight spaces near
Eli Zaretskii <eliz@gnu.org>
parents:
72472
diff
changeset
|
615 (goto-char (point-max)) |
b0f398ac4cbd
(whitespace-indent-regexp): Make this match any multiples of eight spaces near
Eli Zaretskii <eliz@gnu.org>
parents:
72472
diff
changeset
|
616 (skip-chars-backward "\n") |
b0f398ac4cbd
(whitespace-indent-regexp): Make this match any multiples of eight spaces near
Eli Zaretskii <eliz@gnu.org>
parents:
72472
diff
changeset
|
617 (forward-line) |
b0f398ac4cbd
(whitespace-indent-regexp): Make this match any multiples of eight spaces near
Eli Zaretskii <eliz@gnu.org>
parents:
72472
diff
changeset
|
618 (unless (eobp) |
b0f398ac4cbd
(whitespace-indent-regexp): Make this match any multiples of eight spaces near
Eli Zaretskii <eliz@gnu.org>
parents:
72472
diff
changeset
|
619 (whitespace-highlight-the-space (point) (point-max)) |
b0f398ac4cbd
(whitespace-indent-regexp): Make this match any multiples of eight spaces near
Eli Zaretskii <eliz@gnu.org>
parents:
72472
diff
changeset
|
620 t))) |
25582 | 621 |
622 (defun whitespace-buffer-trailing-cleanup () | |
73666
b0f398ac4cbd
(whitespace-indent-regexp): Make this match any multiples of eight spaces near
Eli Zaretskii <eliz@gnu.org>
parents:
72472
diff
changeset
|
623 "Remove extra trailing newline characters from current buffer." |
25582 | 624 (save-excursion |
64178
0b1f11faf0b2
(whitespace-buffer-leading-cleanup): Simplify w/ skip-chars-forward.
Richard M. Stallman <rms@gnu.org>
parents:
64091
diff
changeset
|
625 (goto-char (point-max)) |
0b1f11faf0b2
(whitespace-buffer-leading-cleanup): Simplify w/ skip-chars-forward.
Richard M. Stallman <rms@gnu.org>
parents:
64091
diff
changeset
|
626 (skip-chars-backward "\n") |
73666
b0f398ac4cbd
(whitespace-indent-regexp): Make this match any multiples of eight spaces near
Eli Zaretskii <eliz@gnu.org>
parents:
72472
diff
changeset
|
627 (unless (eobp) |
b0f398ac4cbd
(whitespace-indent-regexp): Make this match any multiples of eight spaces near
Eli Zaretskii <eliz@gnu.org>
parents:
72472
diff
changeset
|
628 (forward-line) |
b0f398ac4cbd
(whitespace-indent-regexp): Make this match any multiples of eight spaces near
Eli Zaretskii <eliz@gnu.org>
parents:
72472
diff
changeset
|
629 (delete-region (point) (point-max))))) |
25582 | 630 |
631 (defun whitespace-buffer-search (regexp) | |
632 "Search for any given whitespace REGEXP." | |
73666
b0f398ac4cbd
(whitespace-indent-regexp): Make this match any multiples of eight spaces near
Eli Zaretskii <eliz@gnu.org>
parents:
72472
diff
changeset
|
633 (with-local-quit |
b0f398ac4cbd
(whitespace-indent-regexp): Make this match any multiples of eight spaces near
Eli Zaretskii <eliz@gnu.org>
parents:
72472
diff
changeset
|
634 (let (whitespace-retval) |
b0f398ac4cbd
(whitespace-indent-regexp): Make this match any multiples of eight spaces near
Eli Zaretskii <eliz@gnu.org>
parents:
72472
diff
changeset
|
635 (save-excursion |
b0f398ac4cbd
(whitespace-indent-regexp): Make this match any multiples of eight spaces near
Eli Zaretskii <eliz@gnu.org>
parents:
72472
diff
changeset
|
636 (goto-char (point-min)) |
b0f398ac4cbd
(whitespace-indent-regexp): Make this match any multiples of eight spaces near
Eli Zaretskii <eliz@gnu.org>
parents:
72472
diff
changeset
|
637 (while (re-search-forward regexp nil t) |
b0f398ac4cbd
(whitespace-indent-regexp): Make this match any multiples of eight spaces near
Eli Zaretskii <eliz@gnu.org>
parents:
72472
diff
changeset
|
638 (whitespace-highlight-the-space (match-beginning 0) (match-end 0)) |
b0f398ac4cbd
(whitespace-indent-regexp): Make this match any multiples of eight spaces near
Eli Zaretskii <eliz@gnu.org>
parents:
72472
diff
changeset
|
639 (push (match-beginning 0) whitespace-retval))) |
b0f398ac4cbd
(whitespace-indent-regexp): Make this match any multiples of eight spaces near
Eli Zaretskii <eliz@gnu.org>
parents:
72472
diff
changeset
|
640 (when whitespace-retval |
b0f398ac4cbd
(whitespace-indent-regexp): Make this match any multiples of eight spaces near
Eli Zaretskii <eliz@gnu.org>
parents:
72472
diff
changeset
|
641 (format " %s" (nreverse whitespace-retval)))))) |
25582 | 642 |
643 (defun whitespace-buffer-cleanup (regexp newregexp) | |
644 "Search for any given whitespace REGEXP and replace it with the NEWREGEXP." | |
645 (save-excursion | |
646 (goto-char (point-min)) | |
647 (while (re-search-forward regexp nil t) | |
648 (replace-match newregexp)))) | |
649 | |
650 (defun whitespace-indent-cleanup () | |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
651 "Search for 8/more spaces at the start of a line and replace it with tabs." |
25582 | 652 (save-excursion |
653 (goto-char (point-min)) | |
654 (while (re-search-forward whitespace-indent-regexp nil t) | |
655 (let ((column (current-column)) | |
656 (indent-tabs-mode t)) | |
657 (delete-region (match-beginning 0) (point)) | |
658 (indent-to column))))) | |
659 | |
26245
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
660 (defun whitespace-unchecked-whitespaces () |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
661 "Return the list of whitespaces whose testing has been suppressed." |
36944
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
662 (let ((unchecked-spaces |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
663 (concat (if (not whitespace-check-buffer-ateol) "e") |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
664 (if (not whitespace-check-buffer-indent) "i") |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
665 (if (not whitespace-check-buffer-leading) "l") |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
666 (if (not whitespace-check-buffer-spacetab) "s") |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
667 (if (not whitespace-check-buffer-trailing) "t")))) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
668 (if (not (equal unchecked-spaces "")) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
669 unchecked-spaces |
26245
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
670 nil))) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
671 |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
672 (defun whitespace-update-modeline (&optional whitespace-err) |
32501 | 673 "Update modeline with whitespace errors. |
674 Also with whitespaces whose testing has been turned off." | |
26245
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
675 (if whitespace-display-in-modeline |
26259
912b004387d9
(whitespace-update-modeline): Bugfix to ensure
Gerd Moellmann <gerd@gnu.org>
parents:
26253
diff
changeset
|
676 (progn |
912b004387d9
(whitespace-update-modeline): Bugfix to ensure
Gerd Moellmann <gerd@gnu.org>
parents:
26253
diff
changeset
|
677 (setq whitespace-mode-line nil) |
912b004387d9
(whitespace-update-modeline): Bugfix to ensure
Gerd Moellmann <gerd@gnu.org>
parents:
26253
diff
changeset
|
678 ;; Whitespace errors |
912b004387d9
(whitespace-update-modeline): Bugfix to ensure
Gerd Moellmann <gerd@gnu.org>
parents:
26253
diff
changeset
|
679 (if (and whitespace-err (not (equal whitespace-err ""))) |
912b004387d9
(whitespace-update-modeline): Bugfix to ensure
Gerd Moellmann <gerd@gnu.org>
parents:
26253
diff
changeset
|
680 (setq whitespace-mode-line whitespace-err)) |
912b004387d9
(whitespace-update-modeline): Bugfix to ensure
Gerd Moellmann <gerd@gnu.org>
parents:
26253
diff
changeset
|
681 ;; Whitespace suppressed errors |
912b004387d9
(whitespace-update-modeline): Bugfix to ensure
Gerd Moellmann <gerd@gnu.org>
parents:
26253
diff
changeset
|
682 (let ((whitespace-unchecked (whitespace-unchecked-whitespaces))) |
912b004387d9
(whitespace-update-modeline): Bugfix to ensure
Gerd Moellmann <gerd@gnu.org>
parents:
26253
diff
changeset
|
683 (if whitespace-unchecked |
912b004387d9
(whitespace-update-modeline): Bugfix to ensure
Gerd Moellmann <gerd@gnu.org>
parents:
26253
diff
changeset
|
684 (setq whitespace-mode-line |
912b004387d9
(whitespace-update-modeline): Bugfix to ensure
Gerd Moellmann <gerd@gnu.org>
parents:
26253
diff
changeset
|
685 (concat whitespace-mode-line "!" whitespace-unchecked)))) |
912b004387d9
(whitespace-update-modeline): Bugfix to ensure
Gerd Moellmann <gerd@gnu.org>
parents:
26253
diff
changeset
|
686 ;; Add the whitespace modeline prefix |
912b004387d9
(whitespace-update-modeline): Bugfix to ensure
Gerd Moellmann <gerd@gnu.org>
parents:
26253
diff
changeset
|
687 (setq whitespace-mode-line (if whitespace-mode-line |
912b004387d9
(whitespace-update-modeline): Bugfix to ensure
Gerd Moellmann <gerd@gnu.org>
parents:
26253
diff
changeset
|
688 (concat " W:" whitespace-mode-line) |
912b004387d9
(whitespace-update-modeline): Bugfix to ensure
Gerd Moellmann <gerd@gnu.org>
parents:
26253
diff
changeset
|
689 nil)) |
42013
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
690 (whitespace-mode-line-update)))) |
25724
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
691 |
42013
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
692 (defun whitespace-highlight-the-space (b e) |
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
693 "Highlight the current line, unhighlighting a previously jumped to line." |
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
694 (if whitespace-display-spaces-in-color |
61395
21f8452c722e
(whitespace-highlight-the-space): Put the same overlay
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
61394
diff
changeset
|
695 (let ((ol (whitespace-make-overlay b e))) |
63200
eef21c221eff
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-371
Miles Bader <miles@gnu.org>
parents:
61492
diff
changeset
|
696 (whitespace-overlay-put ol 'face 'whitespace-highlight)))) |
42013
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
697 |
61471
c85ac0c1b8e9
(whitespace-highlight-the-space):
Richard M. Stallman <rms@gnu.org>
parents:
61395
diff
changeset
|
698 (defun whitespace-unhighlight-the-space() |
42013
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
699 "Unhighlight the currently highlight line." |
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
700 (if (and whitespace-display-spaces-in-color whitespace-highlighted-space) |
61395
21f8452c722e
(whitespace-highlight-the-space): Put the same overlay
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
61394
diff
changeset
|
701 (progn |
21f8452c722e
(whitespace-highlight-the-space): Put the same overlay
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
61394
diff
changeset
|
702 (mapc 'whitespace-delete-overlay whitespace-highlighted-space) |
73666
b0f398ac4cbd
(whitespace-indent-regexp): Make this match any multiples of eight spaces near
Eli Zaretskii <eliz@gnu.org>
parents:
72472
diff
changeset
|
703 (setq whitespace-highlighted-space nil)))) |
25582 | 704 |
705 (defun whitespace-check-buffer-list (buf-name buf-file) | |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
706 "Add a buffer and its file to the whitespace monitor list. |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
707 |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
708 The buffer named BUF-NAME and its associated file BUF-FILE are now monitored |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
709 periodically for whitespace." |
25582 | 710 (if (and whitespace-mode (not (member (list buf-file buf-name) |
711 whitespace-all-buffer-files))) | |
712 (add-to-list 'whitespace-all-buffer-files (list buf-file buf-name)))) | |
713 | |
714 (defun whitespace-tickle-timer () | |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
715 "Tickle timer to periodically to scan qualifying files for whitespace creep. |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
716 |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
717 If timer is not set, then set it to scan the files in |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
718 `whitespace-all-buffer-files' periodically (defined by |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
719 `whitespace-rescan-timer-time') for whitespace creep." |
25724
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
720 (if (and whitespace-rescan-timer-time (not whitespace-rescan-timer)) |
25582 | 721 (setq whitespace-rescan-timer |
32501 | 722 (add-timeout whitespace-rescan-timer-time |
723 'whitespace-rescan-files-in-buffers nil | |
724 whitespace-rescan-timer-time)))) | |
25582 | 725 |
726 (defun whitespace-rescan-files-in-buffers (&optional arg) | |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
727 "Check monitored files for whitespace creep since last scan." |
25582 | 728 (let ((whitespace-all-my-files whitespace-all-buffer-files) |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
729 buffile bufname thiselt buf) |
25582 | 730 (if (not whitespace-all-my-files) |
731 (progn | |
32501 | 732 (disable-timeout whitespace-rescan-timer) |
25582 | 733 (setq whitespace-rescan-timer nil)) |
734 (while whitespace-all-my-files | |
735 (setq thiselt (car whitespace-all-my-files)) | |
736 (setq whitespace-all-my-files (cdr whitespace-all-my-files)) | |
737 (setq buffile (car thiselt)) | |
738 (setq bufname (cadr thiselt)) | |
739 (setq buf (get-buffer bufname)) | |
740 (if (buffer-live-p buf) | |
741 (save-excursion | |
742 ;;(message "buffer %s live" bufname) | |
743 (set-buffer bufname) | |
744 (if whitespace-mode | |
745 (progn | |
746 ;;(message "checking for whitespace in %s" bufname) | |
747 (if whitespace-auto-cleanup | |
748 (progn | |
749 ;;(message "cleaning up whitespace in %s" bufname) | |
70927
1d492927a08d
whitespace.el - make whitesspace-cleanup use the current active regoin, if there is one.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
68651
diff
changeset
|
750 (whitespace-cleanup-internal)) |
25582 | 751 (progn |
752 ;;(message "whitespace-buffer %s." (buffer-name)) | |
753 (whitespace-buffer t)))) | |
754 ;;(message "Removing %s from refresh list" bufname) | |
755 (whitespace-refresh-rescan-list buffile bufname))) | |
756 ;;(message "Removing %s from refresh list" bufname) | |
757 (whitespace-refresh-rescan-list buffile bufname)))))) | |
758 | |
759 (defun whitespace-refresh-rescan-list (buffile bufname) | |
73666
b0f398ac4cbd
(whitespace-indent-regexp): Make this match any multiples of eight spaces near
Eli Zaretskii <eliz@gnu.org>
parents:
72472
diff
changeset
|
760 "Refresh the list of files to be rescanned for whitespace creep." |
25582 | 761 (if whitespace-all-buffer-files |
32501 | 762 (setq whitespace-all-buffer-files |
763 (delete (list buffile bufname) whitespace-all-buffer-files)) | |
764 (when whitespace-rescan-timer | |
765 (disable-timeout whitespace-rescan-timer) | |
766 (setq whitespace-rescan-timer nil)))) | |
767 | |
768 ;;;###autoload | |
56763
e9a8ab6f16fc
(global-whitespace-mode): New alias for whitespace-global-mode.
Richard M. Stallman <rms@gnu.org>
parents:
54770
diff
changeset
|
769 (defalias 'global-whitespace-mode 'whitespace-global-mode) |
e9a8ab6f16fc
(global-whitespace-mode): New alias for whitespace-global-mode.
Richard M. Stallman <rms@gnu.org>
parents:
54770
diff
changeset
|
770 |
e9a8ab6f16fc
(global-whitespace-mode): New alias for whitespace-global-mode.
Richard M. Stallman <rms@gnu.org>
parents:
54770
diff
changeset
|
771 ;;;###autoload |
47420
b7a8fec8113c
(whitespace-global-mode): Use define-minor-mode. Use the new file hook names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42013
diff
changeset
|
772 (define-minor-mode whitespace-global-mode |
32501 | 773 "Toggle using Whitespace mode in new buffers. |
52672
d4d213cfb340
whitespace.el now takes user customizable variable to display cleanliness of
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
52401
diff
changeset
|
774 With ARG, turn the mode on iff ARG is positive. |
32501 | 775 |
776 When this mode is active, `whitespace-buffer' is added to | |
47420
b7a8fec8113c
(whitespace-global-mode): Use define-minor-mode. Use the new file hook names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42013
diff
changeset
|
777 `find-file-hook' and `kill-buffer-hook'." |
50964
d5b5bbb27b2f
Add :link to commentary section
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
48631
diff
changeset
|
778 :global t |
d5b5bbb27b2f
Add :link to commentary section
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
48631
diff
changeset
|
779 :group 'whitespace |
47420
b7a8fec8113c
(whitespace-global-mode): Use define-minor-mode. Use the new file hook names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42013
diff
changeset
|
780 (if whitespace-global-mode |
25582 | 781 (progn |
47420
b7a8fec8113c
(whitespace-global-mode): Use define-minor-mode. Use the new file hook names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42013
diff
changeset
|
782 (add-hook 'find-file-hook 'whitespace-buffer) |
b7a8fec8113c
(whitespace-global-mode): Use define-minor-mode. Use the new file hook names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42013
diff
changeset
|
783 (add-hook 'write-file-functions 'whitespace-write-file-hook nil t) |
32501 | 784 (add-hook 'kill-buffer-hook 'whitespace-buffer)) |
47420
b7a8fec8113c
(whitespace-global-mode): Use define-minor-mode. Use the new file hook names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42013
diff
changeset
|
785 (remove-hook 'find-file-hook 'whitespace-buffer) |
b7a8fec8113c
(whitespace-global-mode): Use define-minor-mode. Use the new file hook names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42013
diff
changeset
|
786 (remove-hook 'write-file-functions 'whitespace-write-file-hook t) |
32501 | 787 (remove-hook 'kill-buffer-hook 'whitespace-buffer))) |
25582 | 788 |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
789 ;;;###autoload |
38882 | 790 (defun whitespace-write-file-hook () |
47420
b7a8fec8113c
(whitespace-global-mode): Use define-minor-mode. Use the new file hook names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42013
diff
changeset
|
791 "Hook function to be called on the buffer when whitespace check is enabled. |
b7a8fec8113c
(whitespace-global-mode): Use define-minor-mode. Use the new file hook names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42013
diff
changeset
|
792 This is meant to be added buffer-locally to `write-file-functions'." |
38882 | 793 (interactive) |
794 (let ((werr nil)) | |
795 (if whitespace-auto-cleanup | |
70927
1d492927a08d
whitespace.el - make whitesspace-cleanup use the current active regoin, if there is one.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
68651
diff
changeset
|
796 (whitespace-cleanup-internal) |
38882 | 797 (setq werr (whitespace-buffer))) |
798 (if (and whitespace-abort-on-error werr) | |
799 (error (concat "Abort write due to whitespaces in " | |
800 buffer-file-name)))) | |
801 nil) | |
802 | |
32501 | 803 (defun whitespace-unload-hook () |
47420
b7a8fec8113c
(whitespace-global-mode): Use define-minor-mode. Use the new file hook names.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
42013
diff
changeset
|
804 (remove-hook 'find-file-hook 'whitespace-buffer) |
47454
cf95d79a66c4
(whitespace-unload-hook): Call `remove-hook' with three arguments, not four.
Juanma Barranquero <lekktu@gmail.com>
parents:
47420
diff
changeset
|
805 (remove-hook 'write-file-functions 'whitespace-write-file-hook t) |
32501 | 806 (remove-hook 'kill-buffer-hook 'whitespace-buffer)) |
807 | |
57522
3f7aa44cf697
(whitespace-unload-hook): Set the variable.
Richard M. Stallman <rms@gnu.org>
parents:
56763
diff
changeset
|
808 (add-hook 'whitespace-unload-hook 'whitespace-unload-hook) |
3f7aa44cf697
(whitespace-unload-hook): Set the variable.
Richard M. Stallman <rms@gnu.org>
parents:
56763
diff
changeset
|
809 |
25582 | 810 (provide 'whitespace) |
52401 | 811 |
61395
21f8452c722e
(whitespace-highlight-the-space): Put the same overlay
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
61394
diff
changeset
|
812 ;; arch-tag: 4ff44e87-b63c-402d-95a6-15e51e58bd0c |
25582 | 813 ;;; whitespace.el ends here |