Mercurial > emacs
annotate lisp/whitespace.el @ 63475:69bb366fab26
*** empty log message ***
author | Kim F. Storm <storm@cua.dk> |
---|---|
date | Wed, 15 Jun 2005 22:43:46 +0000 |
parents | eef21c221eff |
children | 6fb026ad601f e58cb448e07c a1b34dec1104 |
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 |
61394
31aa9a390538
* mh-customize.el (mh-speedbar-selected-folder-face): Special case
Dan Nicolaescu <dann@ics.uci.edu>
parents:
57522
diff
changeset
|
3 ;; Copyright (C) 1999, 2000, 2005 Free Software Foundation, Inc. |
25582 | 4 |
29333
189f70e66cab
Update whitespace.el with a more tolerable timer scan time.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
27583
diff
changeset
|
5 ;; Author: Rajesh Vaidheeswarran <rv@gnu.org> |
25582 | 6 ;; Keywords: convenience |
7 | |
8 ;; This file is part of GNU Emacs. | |
9 | |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
12 ;; the Free Software Foundation; either version 2, or (at your option) | |
13 ;; any later version. | |
14 | |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 ;; Boston, MA 02111-1307, USA. | |
24 | |
25 ;;; Commentary: | |
51542 | 26 ;; |
27 ;; URL: http://www.dsmit.com/lisp/ | |
28 ;; | |
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
|
29 ;; 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
|
30 ;; of whitespace problems that commonly exist in source code. |
51542 | 31 ;; |
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
|
32 ;; 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
|
33 ;; 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
|
34 ;; 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
|
35 ;; 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
|
36 ;; 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
|
37 ;; 5. Spaces or TABS at the end of a line. |
51542 | 38 ;; |
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
|
39 ;; Whitespace errors are reported in a buffer, and on the modeline. |
51542 | 40 ;; |
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
|
41 ;; 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
|
42 ;; where `x' and `y' can be one (or more) of: |
51542 | 43 ;; |
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
|
44 ;; 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
|
45 ;; 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
|
46 ;; 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
|
47 ;; 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
|
48 ;; t - Trailing whitespace. |
51542 | 49 ;; |
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
|
50 ;; 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
|
51 ;; !<y>. |
51542 | 52 ;; |
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
|
53 ;; (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
|
54 ;; 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
|
55 ;; 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
|
56 ;; always they default to 8.) |
51542 | 57 ;; |
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
|
58 ;; 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
|
59 ;; 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
|
60 ;; even print it. |
51542 | 61 ;; |
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
|
62 ;; 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
|
63 ;; 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
|
64 ;; 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
|
65 ;; 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
|
66 ;; 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
|
67 ;; 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
|
68 ;; 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
|
69 ;; to set smarttab.) |
51542 | 70 ;; |
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
|
71 ;; 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
|
72 ;; merge problems. |
51542 | 73 ;; |
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
|
74 ;; 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
|
75 ;; 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
|
76 ;; whitespaces during the process of your editing). |
51542 | 77 ;; |
25582 | 78 ;; Exported functions: |
51542 | 79 ;; |
25582 | 80 ;; `whitespace-buffer' - To check the current buffer for whitespace problems. |
81 ;; `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
|
82 ;; `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
|
83 ;; problems. |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
84 ;; `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
|
85 ;; and mark in the current buffer. |
25582 | 86 |
87 ;;; Code: | |
88 | |
61488
230af31ce843
whitespace.el - fix higlighting test and bump rev
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
61471
diff
changeset
|
89 (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
|
90 |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
91 (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
|
92 "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
|
93 |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
94 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
|
95 visited by the buffers.") |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
96 |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
97 (defvar whitespace-rescan-timer nil |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
98 "Timer object used to rescan the files in buffers that have been modified.") |
25582 | 99 |
26245
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
100 ;; 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
|
101 (defvar whitespace-mode nil |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
102 "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
|
103 (make-variable-buffer-local 'whitespace-mode) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
104 (put 'whitespace-mode 'permanent-local nil) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
105 |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
106 (defvar whitespace-mode-line nil |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
107 "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
|
108 (make-variable-buffer-local 'whitespace-mode-line) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
109 (put 'whitespace-mode-line 'permanent-local nil) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
110 |
36944
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
111 (defvar whitespace-check-buffer-leading nil |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
112 "Test leading whitespace for file in current buffer if t") |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
113 (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
|
114 (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
|
115 |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
116 (defvar whitespace-check-buffer-trailing nil |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
117 "Test trailing whitespace for file in current buffer if t") |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
118 (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
|
119 (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
|
120 |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
121 (defvar whitespace-check-buffer-indent nil |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
122 "Test indentation whitespace for file in current buffer if t") |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
123 (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
|
124 (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
|
125 |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
126 (defvar whitespace-check-buffer-spacetab nil |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
127 "Test Space-followed-by-TABS whitespace for file in current buffer if t") |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
128 (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
|
129 (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
|
130 |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
131 (defvar whitespace-check-buffer-ateol nil |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
132 "Test end-of-line whitespace for file in current buffer if t") |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
133 (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
|
134 (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
|
135 |
42013
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
136 (defvar whitespace-highlighted-space nil |
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
137 "The variable to store the extent to highlight") |
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
138 (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
|
139 (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
|
140 |
26253
3bb622df1c52
(whitespace-version): Update to 2.8
Gerd Moellmann <gerd@gnu.org>
parents:
26245
diff
changeset
|
141 ;; 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
|
142 (eval-when-compile |
26253
3bb622df1c52
(whitespace-version): Update to 2.8
Gerd Moellmann <gerd@gnu.org>
parents:
26245
diff
changeset
|
143 (if (not (fboundp 'defgroup)) |
3bb622df1c52
(whitespace-version): Update to 2.8
Gerd Moellmann <gerd@gnu.org>
parents:
26245
diff
changeset
|
144 (defmacro defgroup (sym memb doc &rest args) |
3bb622df1c52
(whitespace-version): Update to 2.8
Gerd Moellmann <gerd@gnu.org>
parents:
26245
diff
changeset
|
145 "Null macro for defgroup in all versions of Emacs that don't define |
3bb622df1c52
(whitespace-version): Update to 2.8
Gerd Moellmann <gerd@gnu.org>
parents:
26245
diff
changeset
|
146 defgroup" |
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) |
3bb622df1c52
(whitespace-version): Update to 2.8
Gerd Moellmann <gerd@gnu.org>
parents:
26245
diff
changeset
|
150 "Macro to alias defcustom to defvar in all versions of Emacs that |
3bb622df1c52
(whitespace-version): Update to 2.8
Gerd Moellmann <gerd@gnu.org>
parents:
26245
diff
changeset
|
151 don't define defcustom" |
3bb622df1c52
(whitespace-version): Update to 2.8
Gerd Moellmann <gerd@gnu.org>
parents:
26245
diff
changeset
|
152 `(defvar ,sym ,val ,doc)))) |
25582 | 153 |
42013
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
154 (if (fboundp 'make-overlay) |
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
155 (progn |
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
156 (defalias 'whitespace-make-overlay 'make-overlay) |
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
157 (defalias 'whitespace-overlay-put 'overlay-put) |
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
158 (defalias 'whitespace-delete-overlay 'delete-overlay) |
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
159 (defalias 'whitespace-overlay-start 'overlay-start) |
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
160 (defalias 'whitespace-overlay-end 'overlay-end) |
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
161 (defalias 'whitespace-mode-line-update 'force-mode-line-update)) |
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
162 (defalias 'whitespace-make-overlay 'make-extent) |
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
163 (defalias 'whitespace-overlay-put 'set-extent-property) |
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
164 (defalias 'whitespace-delete-overlay 'delete-extent) |
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
165 (defalias 'whitespace-overlay-start 'extent-start) |
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
166 (defalias 'whitespace-overlay-end 'extent-end) |
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
167 (defalias 'whitespace-mode-line-update 'redraw-modeline)) |
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
168 |
32501 | 169 (if (featurep 'xemacs) |
25582 | 170 (defgroup whitespace nil |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
171 "Check for and fix five different types of whitespaces in source code." |
25582 | 172 ;; Since XEmacs doesn't have a 'convenience group, use the next best group |
173 ;; which is 'editing? | |
51542 | 174 :link '(emacs-commentary-link "whitespace.el") |
32501 | 175 :group 'editing) |
176 (defgroup whitespace nil | |
177 "Check for and fix five different types of whitespaces in source code." | |
178 :version "21.1" | |
51542 | 179 :link '(emacs-commentary-link "whitespace.el") |
32501 | 180 :group 'convenience)) |
25582 | 181 |
25724
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
182 (defcustom whitespace-check-leading-whitespace t |
36944
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
183 "Flag to check leading whitespace. This is the global for the system. |
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 |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
185 `whitespace-check-buffer-leading'" |
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-trailing-whitespace t |
36944
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
190 "Flag to check trailing whitespace. This is the global for the system. |
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 |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
192 `whitespace-check-buffer-trailing'" |
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 |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
196 (defcustom whitespace-check-spacetab-whitespace t |
36944
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
197 "Flag to check space followed by a TAB. This is the global for the system. |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
198 It can be overriden by setting a buffer local variable |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
199 `whitespace-check-buffer-spacetab'" |
25724
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
200 :type 'boolean |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
201 :group 'whitespace) |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
202 |
42013
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
203 (defcustom whitespace-spacetab-regexp "[ ]+\t" |
25724
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
204 "Regexp to match a space followed by a TAB." |
32501 | 205 :type 'regexp |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
206 :group 'whitespace) |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
207 |
38882 | 208 (defcustom whitespace-check-indent-whitespace indent-tabs-mode |
36944
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
209 "Flag to check indentation whitespace. This is the global for the system. |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
210 It can be overriden by setting a buffer local variable |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
211 `whitespace-check-buffer-indent'" |
25724
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
212 :type 'boolean |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
213 :group 'whitespace) |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
214 |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
215 (defcustom whitespace-indent-regexp (concat "^\\(\t*\\) " " ") |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
216 "Regexp to match (any TABS followed by) 8/more whitespaces at start of line." |
32501 | 217 :type 'regexp |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
218 :group 'whitespace) |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
219 |
25724
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
220 (defcustom whitespace-check-ateol-whitespace t |
36944
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
221 "Flag to check end-of-line whitespace. This is the global for the system. |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
222 It can be overriden by setting a buffer local variable |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
223 `whitespace-check-buffer-ateol'" |
25724
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
224 :type 'boolean |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
225 :group 'whitespace) |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
226 |
42013
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
227 ;; (defcustom whitespace-ateol-regexp "[ \t]$" |
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
228 (defcustom whitespace-ateol-regexp "[ \t]+$" |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
229 "Regexp to match a TAB or a space at the EOL." |
32501 | 230 :type 'regexp |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
231 :group 'whitespace) |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
232 |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
233 (defcustom whitespace-errbuf "*Whitespace Errors*" |
32501 | 234 "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
|
235 :type 'string |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
236 :group 'whitespace) |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
237 |
52672
d4d213cfb340
whitespace.el now takes user customizable variable to display cleanliness of
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
52401
diff
changeset
|
238 (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
|
239 "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
|
240 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
|
241 :type 'string |
d4d213cfb340
whitespace.el now takes user customizable variable to display cleanliness of
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
52401
diff
changeset
|
242 :group 'whitespace) |
d4d213cfb340
whitespace.el now takes user customizable variable to display cleanliness of
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
52401
diff
changeset
|
243 |
38882 | 244 (defcustom whitespace-abort-on-error nil |
245 "While writing a file, abort if the file is unclean. If | |
246 `whitespace-auto-cleanup' is set, that takes precedence over this | |
247 variable." | |
248 :type 'boolean | |
249 :group 'whitespace) | |
250 | |
25582 | 251 (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
|
252 "Cleanup a buffer automatically on finding it whitespace unclean." |
25582 | 253 :type 'boolean |
254 :group 'whitespace) | |
255 | |
256 (defcustom whitespace-silent nil | |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
257 "All whitespace errors will be shown only in the modeline when t. |
25582 | 258 |
259 Note that setting this may cause all whitespaces introduced in a file to go | |
260 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
|
261 Errors*' buffer before opening (or closing) another file." |
25582 | 262 :type 'boolean |
263 :group 'whitespace) | |
264 | |
265 (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
|
266 c-mode c++-mode cc-mode |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
267 change-log-mode cperl-mode |
25582 | 268 electric-nroff-mode emacs-lisp-mode |
269 f90-mode fortran-mode html-mode | |
270 html3-mode java-mode jde-mode | |
271 ksh-mode latex-mode LaTeX-mode | |
272 lisp-mode m4-mode makefile-mode | |
273 modula-2-mode nroff-mode objc-mode | |
274 pascal-mode perl-mode prolog-mode | |
275 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
|
276 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
|
277 tcl-mode tex-mode texinfo-mode |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
278 vrml-mode xml-mode) |
25582 | 279 |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
280 "Major Modes in which we turn on whitespace checking. |
25582 | 281 |
32501 | 282 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
|
283 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
|
284 following to your `.emacs': |
25582 | 285 |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
286 \(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
|
287 whitespace-modes))\) |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
288 |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
289 Or, alternately, you can use the Emacs `customize' command to set this." |
32501 | 290 :type '(repeat symbol) |
25582 | 291 :group 'whitespace) |
292 | |
29333
189f70e66cab
Update whitespace.el with a more tolerable timer scan time.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
27583
diff
changeset
|
293 (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
|
294 "Period in seconds to rescan modified buffers for whitespace creep. |
25582 | 295 |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
296 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
|
297 `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
|
298 modified buffers. |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
299 |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
300 To disable timer scans, set this to zero." |
25582 | 301 :type 'integer |
302 :group 'whitespace) | |
303 | |
26245
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
304 (defcustom whitespace-display-in-modeline t |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
305 "Display whitespace errors on the modeline." |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
306 :type 'boolean |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
307 :group 'whitespace) |
25582 | 308 |
42013
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
309 (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
|
310 "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
|
311 `whitespace-highlight'." |
42013
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
312 :type 'boolean |
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
313 :group 'whitespace) |
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
314 |
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
315 (defgroup whitespace-faces nil |
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
316 "Faces used in whitespace." |
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
317 :prefix "whitespace-" |
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
318 :group 'whitespace |
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
319 :group 'faces) |
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
320 |
63200
eef21c221eff
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-371
Miles Bader <miles@gnu.org>
parents:
61492
diff
changeset
|
321 (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
|
322 (:background "green1")) |
eef21c221eff
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-371
Miles Bader <miles@gnu.org>
parents:
61492
diff
changeset
|
323 (((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
|
324 (: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
|
325 (((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
|
326 (background light)) |
eef21c221eff
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-371
Miles Bader <miles@gnu.org>
parents:
61492
diff
changeset
|
327 (:background "black")) |
eef21c221eff
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-371
Miles Bader <miles@gnu.org>
parents:
61492
diff
changeset
|
328 (((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
|
329 (background dark)) |
eef21c221eff
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-371
Miles Bader <miles@gnu.org>
parents:
61492
diff
changeset
|
330 (:background "white"))) |
42013
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
331 "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
|
332 :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
|
333 ;; 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
|
334 (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
|
335 |
25582 | 336 (if (not (assoc 'whitespace-mode minor-mode-alist)) |
337 (setq minor-mode-alist (cons '(whitespace-mode whitespace-mode-line) | |
338 minor-mode-alist))) | |
339 | |
36944
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
340 (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
|
341 whitespace-check-leading-whitespace) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
342 (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
|
343 whitespace-check-trailing-whitespace) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
344 (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
|
345 whitespace-check-indent-whitespace) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
346 (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
|
347 whitespace-check-spacetab-whitespace) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
348 (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
|
349 whitespace-check-ateol-whitespace) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
350 |
25582 | 351 (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
|
352 "Test and set the whitespace-mode in qualifying buffers." |
25582 | 353 (if (null whitespace-mode) |
354 (setq whitespace-mode | |
355 (if (or arg (member major-mode whitespace-modes)) | |
356 t | |
357 nil)))) | |
358 | |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
359 ;;;###autoload |
36944
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
360 (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
|
361 "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
|
362 (interactive) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
363 (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
|
364 (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
|
365 (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
|
366 (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
|
367 (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
|
368 |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
369 ;;;###autoload |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
370 (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
|
371 "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
|
372 (interactive) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
373 (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
|
374 (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
|
375 (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
|
376 (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
|
377 (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
|
378 |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
379 ;;;###autoload |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
380 (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
|
381 "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
|
382 (interactive) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
383 (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
|
384 (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
|
385 (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
|
386 (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
|
387 (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
|
388 (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
|
389 |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
390 ;;;###autoload |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
391 (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
|
392 "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
|
393 (interactive) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
394 (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
|
395 (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
|
396 (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
|
397 (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
|
398 (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
|
399 (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
|
400 |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
401 |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
402 ;;;###autoload |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
403 (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
|
404 "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
|
405 (interactive) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
406 (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
|
407 (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
|
408 (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
|
409 (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
|
410 (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
|
411 (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
|
412 |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
413 |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
414 ;;;###autoload |
25582 | 415 (defun whitespace-buffer (&optional quiet) |
32501 | 416 "Find five different types of white spaces in buffer. |
417 These are: | |
25582 | 418 1. Leading space \(empty lines at the top of a file\). |
419 2. Trailing space \(empty lines at the end of a file\). | |
420 3. Indentation space \(8 or more spaces, that should be replaced with TABS\). | |
421 4. Spaces followed by a TAB. \(Almost always, we never want that\). | |
422 5. Spaces or TABS at the end of a line. | |
423 | |
424 Check for whitespace only if this buffer really contains a non-empty file | |
425 and: | |
426 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
|
427 2. `whitespace-buffer' was explicitly called with a prefix argument." |
25582 | 428 (interactive) |
26245
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
429 (let ((whitespace-error nil)) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
430 (whitespace-check-whitespace-mode current-prefix-arg) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
431 (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
|
432 (progn |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
433 (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
|
434 (whitespace-tickle-timer) |
42013
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
435 (whitespace-unhighlight-the-space) |
26245
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
436 (if whitespace-auto-cleanup |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
437 (if buffer-read-only |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
438 (if (not quiet) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
439 (message "Can't cleanup: %s is read-only" (buffer-name))) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
440 (whitespace-cleanup)) |
36944
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
441 (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
|
442 (whitespace-buffer-leading) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
443 nil)) |
36944
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
444 (whitespace-trailing (if whitespace-check-buffer-trailing |
26245
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
445 (whitespace-buffer-trailing) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
446 nil)) |
36944
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
447 (whitespace-indent (if whitespace-check-buffer-indent |
26245
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
448 (whitespace-buffer-search |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
449 whitespace-indent-regexp) |
25724
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
450 nil)) |
36944
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
451 (whitespace-spacetab (if whitespace-check-buffer-spacetab |
26245
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
452 (whitespace-buffer-search |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
453 whitespace-spacetab-regexp) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
454 nil)) |
36944
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
455 (whitespace-ateol (if whitespace-check-buffer-ateol |
26245
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
456 (whitespace-buffer-search |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
457 whitespace-ateol-regexp) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
458 nil)) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
459 (whitespace-errmsg nil) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
460 (whitespace-filename buffer-file-name) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
461 (whitespace-this-modeline "")) |
25582 | 462 |
26245
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
463 ;; 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
|
464 (setq whitespace-error (or whitespace-leading whitespace-indent |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
465 whitespace-spacetab whitespace-ateol |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
466 whitespace-trailing)) |
25582 | 467 |
26245
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
468 (if whitespace-error |
25582 | 469 (progn |
26245
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
470 (setq whitespace-errmsg |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
471 (concat whitespace-filename " contains:\n" |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
472 (if whitespace-leading |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
473 "Leading whitespace\n") |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
474 (if whitespace-indent |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
475 (concat "Indentation whitespace" |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
476 whitespace-indent "\n")) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
477 (if whitespace-spacetab |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
478 (concat "Space followed by Tab" |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
479 whitespace-spacetab "\n")) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
480 (if whitespace-ateol |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
481 (concat "End-of-line whitespace" |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
482 whitespace-ateol "\n")) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
483 (if whitespace-trailing |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
484 "Trailing whitespace\n") |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
485 "\ntype `M-x whitespace-cleanup' to " |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
486 "cleanup the file.")) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
487 (setq whitespace-this-modeline |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
488 (concat (if whitespace-ateol "e") |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
489 (if whitespace-indent "i") |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
490 (if whitespace-leading "l") |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
491 (if whitespace-spacetab "s") |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
492 (if whitespace-trailing "t"))))) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
493 (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
|
494 (if (get-buffer whitespace-errbuf) |
21f8452c722e
(whitespace-highlight-the-space): Put the same overlay
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
61394
diff
changeset
|
495 (kill-buffer whitespace-errbuf)) |
21f8452c722e
(whitespace-highlight-the-space): Put the same overlay
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
61394
diff
changeset
|
496 (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
|
497 (if whitespace-errmsg |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
498 (progn |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
499 (insert whitespace-errmsg) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
500 (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
|
501 (display-buffer (current-buffer) t)) |
26245
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
502 (if (not quiet) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
503 (message "Whitespaces: [%s%s] in %s" |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
504 whitespace-this-modeline |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
505 (let ((whitespace-unchecked |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
506 (whitespace-unchecked-whitespaces))) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
507 (if whitespace-unchecked |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
508 (concat "!" whitespace-unchecked) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
509 "")) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
510 whitespace-filename))) |
52672
d4d213cfb340
whitespace.el now takes user customizable variable to display cleanliness of
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
52401
diff
changeset
|
511 (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
|
512 (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
|
513 whitespace-clean-msg)))))))) |
61395
21f8452c722e
(whitespace-highlight-the-space): Put the same overlay
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
61394
diff
changeset
|
514 whitespace-error)) |
25582 | 515 |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
516 ;;;###autoload |
25582 | 517 (defun whitespace-region (s e) |
32501 | 518 "Check the region for whitespace errors." |
25582 | 519 (interactive "r") |
520 (save-excursion | |
521 (save-restriction | |
522 (narrow-to-region s e) | |
523 (whitespace-buffer)))) | |
524 | |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
525 ;;;###autoload |
25582 | 526 (defun whitespace-cleanup () |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
527 "Cleanup the five different kinds of whitespace problems. |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
528 |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
529 Use \\[describe-function] whitespace-describe to read a summary of the |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
530 whitespace problems." |
25582 | 531 (interactive) |
532 ;; If this buffer really contains a file, then run, else quit. | |
533 (whitespace-check-whitespace-mode current-prefix-arg) | |
534 (if (and buffer-file-name whitespace-mode) | |
535 (let ((whitespace-any nil) | |
536 (whitespace-tabwith 8) | |
537 (whitespace-tabwith-saved tab-width)) | |
538 | |
539 ;; since all printable TABS should be 8, irrespective of how | |
540 ;; they are displayed. | |
541 (setq tab-width whitespace-tabwith) | |
542 | |
36944
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
543 (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
|
544 (whitespace-buffer-leading)) |
25582 | 545 (progn |
546 (whitespace-buffer-leading-cleanup) | |
547 (setq whitespace-any t))) | |
548 | |
36944
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
549 (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
|
550 (whitespace-buffer-trailing)) |
25582 | 551 (progn |
552 (whitespace-buffer-trailing-cleanup) | |
553 (setq whitespace-any t))) | |
554 | |
36944
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
555 (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
|
556 (whitespace-buffer-search whitespace-indent-regexp)) |
25582 | 557 (progn |
558 (whitespace-indent-cleanup) | |
559 (setq whitespace-any t))) | |
560 | |
36944
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
561 (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
|
562 (whitespace-buffer-search whitespace-spacetab-regexp)) |
25582 | 563 (progn |
564 (whitespace-buffer-cleanup whitespace-spacetab-regexp "\t") | |
565 (setq whitespace-any t))) | |
566 | |
36944
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
567 (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
|
568 (whitespace-buffer-search whitespace-ateol-regexp)) |
25582 | 569 (progn |
570 (whitespace-buffer-cleanup whitespace-ateol-regexp "") | |
571 (setq whitespace-any t))) | |
572 | |
573 ;; 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
|
574 (if whitespace-any |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
575 (whitespace-cleanup) |
25582 | 576 (progn |
51543
38c9480b767a
Respect user preference
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
51542
diff
changeset
|
577 (if (not whitespace-silent) |
38c9480b767a
Respect user preference
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
51542
diff
changeset
|
578 (message "%s clean" buffer-file-name)) |
26245
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
579 (whitespace-update-modeline))) |
25582 | 580 (setq tab-width whitespace-tabwith-saved)))) |
581 | |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
582 ;;;###autoload |
25582 | 583 (defun whitespace-cleanup-region (s e) |
32501 | 584 "Whitespace cleanup on the region." |
25582 | 585 (interactive "r") |
586 (save-excursion | |
587 (save-restriction | |
588 (narrow-to-region s e) | |
589 (whitespace-cleanup)) | |
590 (whitespace-buffer t))) | |
591 | |
592 (defun whitespace-buffer-leading () | |
593 "Check to see if there are any empty lines at the top of the file." | |
594 (save-excursion | |
595 (let ((pmin nil) | |
596 (pmax nil)) | |
597 (goto-char (point-min)) | |
598 (beginning-of-line) | |
599 (setq pmin (point)) | |
600 (end-of-line) | |
601 (setq pmax (point)) | |
61492
875507693e78
whitespace.el - revert hasty fix, fix highlight area for leading and trailing space.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
61488
diff
changeset
|
602 (if (equal pmin pmax) |
42013
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
603 (progn |
61492
875507693e78
whitespace.el - revert hasty fix, fix highlight area for leading and trailing space.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
61488
diff
changeset
|
604 (whitespace-highlight-the-space pmin (1+ pmax)) |
42013
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
605 t) |
25582 | 606 nil)))) |
607 | |
608 (defun whitespace-buffer-leading-cleanup () | |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
609 "Remove any empty lines at the top of the file." |
25582 | 610 (save-excursion |
611 (let ((pmin nil) | |
612 (pmax nil)) | |
613 (goto-char (point-min)) | |
614 (beginning-of-line) | |
615 (setq pmin (point)) | |
616 (end-of-line) | |
617 (setq pmax (point)) | |
618 (if (equal pmin pmax) | |
619 (progn | |
620 (kill-line) | |
621 (whitespace-buffer-leading-cleanup)))))) | |
622 | |
623 (defun whitespace-buffer-trailing () | |
624 "Check to see if are is more than one empty line at the bottom." | |
625 (save-excursion | |
626 (let ((pmin nil) | |
627 (pmax nil)) | |
628 (goto-char (point-max)) | |
629 (beginning-of-line) | |
630 (setq pmin (point)) | |
631 (end-of-line) | |
632 (setq pmax (point)) | |
633 (if (equal pmin pmax) | |
634 (progn | |
635 (goto-char (- (point) 1)) | |
636 (beginning-of-line) | |
637 (setq pmin (point)) | |
638 (end-of-line) | |
639 (setq pmax (point)) | |
61492
875507693e78
whitespace.el - revert hasty fix, fix highlight area for leading and trailing space.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
61488
diff
changeset
|
640 (if (equal pmin pmax) |
42013
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
641 (progn |
61492
875507693e78
whitespace.el - revert hasty fix, fix highlight area for leading and trailing space.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
61488
diff
changeset
|
642 (whitespace-highlight-the-space (- pmin 1) pmax) |
42013
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
643 t) |
25582 | 644 nil)) |
645 nil)))) | |
646 | |
647 (defun whitespace-buffer-trailing-cleanup () | |
648 "Delete all the empty lines at the bottom." | |
649 (save-excursion | |
650 (let ((pmin nil) | |
651 (pmax nil)) | |
652 (goto-char (point-max)) | |
653 (beginning-of-line) | |
654 (setq pmin (point)) | |
655 (end-of-line) | |
656 (setq pmax (point)) | |
657 (if (equal pmin pmax) | |
658 (progn | |
659 (goto-char (1- pmin)) | |
660 (beginning-of-line) | |
661 (setq pmin (point)) | |
662 (end-of-line) | |
663 (setq pmax (point)) | |
664 (if (equal pmin pmax) | |
665 (progn | |
666 (goto-char (1- (point-max))) | |
667 (beginning-of-line) | |
668 (kill-line) | |
669 (whitespace-buffer-trailing-cleanup)))))))) | |
670 | |
671 (defun whitespace-buffer-search (regexp) | |
672 "Search for any given whitespace REGEXP." | |
673 (let ((whitespace-retval "")) | |
674 (save-excursion | |
675 (goto-char (point-min)) | |
676 (while (re-search-forward regexp nil t) | |
42013
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
677 (progn |
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
678 (setq whitespace-retval (format "%s %s" whitespace-retval |
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
679 (match-beginning 0))) |
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
680 (whitespace-highlight-the-space (match-beginning 0) (match-end 0)))) |
25582 | 681 (if (equal "" whitespace-retval) |
682 nil | |
683 whitespace-retval)))) | |
684 | |
685 (defun whitespace-buffer-cleanup (regexp newregexp) | |
686 "Search for any given whitespace REGEXP and replace it with the NEWREGEXP." | |
687 (save-excursion | |
688 (goto-char (point-min)) | |
689 (while (re-search-forward regexp nil t) | |
690 (replace-match newregexp)))) | |
691 | |
692 (defun whitespace-indent-cleanup () | |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
693 "Search for 8/more spaces at the start of a line and replace it with tabs." |
25582 | 694 (save-excursion |
695 (goto-char (point-min)) | |
696 (while (re-search-forward whitespace-indent-regexp nil t) | |
697 (let ((column (current-column)) | |
698 (indent-tabs-mode t)) | |
699 (delete-region (match-beginning 0) (point)) | |
700 (indent-to column))))) | |
701 | |
26245
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
702 (defun whitespace-unchecked-whitespaces () |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
703 "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
|
704 (let ((unchecked-spaces |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
705 (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
|
706 (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
|
707 (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
|
708 (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
|
709 (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
|
710 (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
|
711 unchecked-spaces |
26245
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
712 nil))) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
713 |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
714 (defun whitespace-update-modeline (&optional whitespace-err) |
32501 | 715 "Update modeline with whitespace errors. |
716 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
|
717 (if whitespace-display-in-modeline |
26259
912b004387d9
(whitespace-update-modeline): Bugfix to ensure
Gerd Moellmann <gerd@gnu.org>
parents:
26253
diff
changeset
|
718 (progn |
912b004387d9
(whitespace-update-modeline): Bugfix to ensure
Gerd Moellmann <gerd@gnu.org>
parents:
26253
diff
changeset
|
719 (setq whitespace-mode-line nil) |
912b004387d9
(whitespace-update-modeline): Bugfix to ensure
Gerd Moellmann <gerd@gnu.org>
parents:
26253
diff
changeset
|
720 ;; Whitespace errors |
912b004387d9
(whitespace-update-modeline): Bugfix to ensure
Gerd Moellmann <gerd@gnu.org>
parents:
26253
diff
changeset
|
721 (if (and whitespace-err (not (equal whitespace-err ""))) |
912b004387d9
(whitespace-update-modeline): Bugfix to ensure
Gerd Moellmann <gerd@gnu.org>
parents:
26253
diff
changeset
|
722 (setq whitespace-mode-line whitespace-err)) |
912b004387d9
(whitespace-update-modeline): Bugfix to ensure
Gerd Moellmann <gerd@gnu.org>
parents:
26253
diff
changeset
|
723 ;; Whitespace suppressed errors |
912b004387d9
(whitespace-update-modeline): Bugfix to ensure
Gerd Moellmann <gerd@gnu.org>
parents:
26253
diff
changeset
|
724 (let ((whitespace-unchecked (whitespace-unchecked-whitespaces))) |
912b004387d9
(whitespace-update-modeline): Bugfix to ensure
Gerd Moellmann <gerd@gnu.org>
parents:
26253
diff
changeset
|
725 (if whitespace-unchecked |
912b004387d9
(whitespace-update-modeline): Bugfix to ensure
Gerd Moellmann <gerd@gnu.org>
parents:
26253
diff
changeset
|
726 (setq whitespace-mode-line |
912b004387d9
(whitespace-update-modeline): Bugfix to ensure
Gerd Moellmann <gerd@gnu.org>
parents:
26253
diff
changeset
|
727 (concat whitespace-mode-line "!" whitespace-unchecked)))) |
912b004387d9
(whitespace-update-modeline): Bugfix to ensure
Gerd Moellmann <gerd@gnu.org>
parents:
26253
diff
changeset
|
728 ;; Add the whitespace modeline prefix |
912b004387d9
(whitespace-update-modeline): Bugfix to ensure
Gerd Moellmann <gerd@gnu.org>
parents:
26253
diff
changeset
|
729 (setq whitespace-mode-line (if whitespace-mode-line |
912b004387d9
(whitespace-update-modeline): Bugfix to ensure
Gerd Moellmann <gerd@gnu.org>
parents:
26253
diff
changeset
|
730 (concat " W:" whitespace-mode-line) |
912b004387d9
(whitespace-update-modeline): Bugfix to ensure
Gerd Moellmann <gerd@gnu.org>
parents:
26253
diff
changeset
|
731 nil)) |
42013
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
732 (whitespace-mode-line-update)))) |
25724
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
733 |
42013
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
734 (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
|
735 "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
|
736 (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
|
737 (let ((ol (whitespace-make-overlay b e))) |
21f8452c722e
(whitespace-highlight-the-space): Put the same overlay
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
61394
diff
changeset
|
738 (push ol whitespace-highlighted-space) |
63200
eef21c221eff
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-371
Miles Bader <miles@gnu.org>
parents:
61492
diff
changeset
|
739 (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
|
740 ;; (add-hook 'pre-command-hook 'whitespace-unhighlight-the-space)) |
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
741 |
61471
c85ac0c1b8e9
(whitespace-highlight-the-space):
Richard M. Stallman <rms@gnu.org>
parents:
61395
diff
changeset
|
742 (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
|
743 "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
|
744 (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
|
745 (progn |
21f8452c722e
(whitespace-highlight-the-space): Put the same overlay
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
61394
diff
changeset
|
746 (mapc 'whitespace-delete-overlay whitespace-highlighted-space) |
42013
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
747 (setq whitespace-highlighted-space nil)) |
0ad4d3e3bfe6
Whitespace.el v3.2 for colorized display of bogus whitespaces.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
38882
diff
changeset
|
748 (remove-hook 'pre-command-hook 'whitespace-unhighlight-the-space))) |
25582 | 749 |
750 (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
|
751 "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
|
752 |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
753 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
|
754 periodically for whitespace." |
25582 | 755 (if (and whitespace-mode (not (member (list buf-file buf-name) |
756 whitespace-all-buffer-files))) | |
757 (add-to-list 'whitespace-all-buffer-files (list buf-file buf-name)))) | |
758 | |
759 (defun whitespace-tickle-timer () | |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
760 "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
|
761 |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
762 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
|
763 `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
|
764 `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
|
765 (if (and whitespace-rescan-timer-time (not whitespace-rescan-timer)) |
25582 | 766 (setq whitespace-rescan-timer |
32501 | 767 (add-timeout whitespace-rescan-timer-time |
768 'whitespace-rescan-files-in-buffers nil | |
769 whitespace-rescan-timer-time)))) | |
25582 | 770 |
771 (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
|
772 "Check monitored files for whitespace creep since last scan." |
25582 | 773 (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
|
774 buffile bufname thiselt buf) |
25582 | 775 (if (not whitespace-all-my-files) |
776 (progn | |
32501 | 777 (disable-timeout whitespace-rescan-timer) |
25582 | 778 (setq whitespace-rescan-timer nil)) |
779 (while whitespace-all-my-files | |
780 (setq thiselt (car whitespace-all-my-files)) | |
781 (setq whitespace-all-my-files (cdr whitespace-all-my-files)) | |
782 (setq buffile (car thiselt)) | |
783 (setq bufname (cadr thiselt)) | |
784 (setq buf (get-buffer bufname)) | |
785 (if (buffer-live-p buf) | |
786 (save-excursion | |
787 ;;(message "buffer %s live" bufname) | |
788 (set-buffer bufname) | |
789 (if whitespace-mode | |
790 (progn | |
791 ;;(message "checking for whitespace in %s" bufname) | |
792 (if whitespace-auto-cleanup | |
793 (progn | |
794 ;;(message "cleaning up whitespace in %s" bufname) | |
795 (whitespace-cleanup)) | |
796 (progn | |
797 ;;(message "whitespace-buffer %s." (buffer-name)) | |
798 (whitespace-buffer t)))) | |
799 ;;(message "Removing %s from refresh list" bufname) | |
800 (whitespace-refresh-rescan-list buffile bufname))) | |
801 ;;(message "Removing %s from refresh list" bufname) | |
802 (whitespace-refresh-rescan-list buffile bufname)))))) | |
803 | |
804 (defun whitespace-refresh-rescan-list (buffile bufname) | |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
805 "Refresh the list of files to be rescaned for whitespace creep." |
25582 | 806 (if whitespace-all-buffer-files |
32501 | 807 (setq whitespace-all-buffer-files |
808 (delete (list buffile bufname) whitespace-all-buffer-files)) | |
809 (when whitespace-rescan-timer | |
810 (disable-timeout whitespace-rescan-timer) | |
811 (setq whitespace-rescan-timer nil)))) | |
812 | |
813 ;;;###autoload | |
56763
e9a8ab6f16fc
(global-whitespace-mode): New alias for whitespace-global-mode.
Richard M. Stallman <rms@gnu.org>
parents:
54770
diff
changeset
|
814 (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
|
815 |
e9a8ab6f16fc
(global-whitespace-mode): New alias for whitespace-global-mode.
Richard M. Stallman <rms@gnu.org>
parents:
54770
diff
changeset
|
816 ;;;###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
|
817 (define-minor-mode whitespace-global-mode |
32501 | 818 "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
|
819 With ARG, turn the mode on iff ARG is positive. |
32501 | 820 |
821 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
|
822 `find-file-hook' and `kill-buffer-hook'." |
50964
d5b5bbb27b2f
Add :link to commentary section
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
48631
diff
changeset
|
823 :global t |
d5b5bbb27b2f
Add :link to commentary section
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
48631
diff
changeset
|
824 :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
|
825 (if whitespace-global-mode |
25582 | 826 (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
|
827 (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
|
828 (add-hook 'write-file-functions 'whitespace-write-file-hook nil t) |
32501 | 829 (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
|
830 (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
|
831 (remove-hook 'write-file-functions 'whitespace-write-file-hook t) |
32501 | 832 (remove-hook 'kill-buffer-hook 'whitespace-buffer))) |
25582 | 833 |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
834 ;;;###autoload |
38882 | 835 (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
|
836 "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
|
837 This is meant to be added buffer-locally to `write-file-functions'." |
38882 | 838 (interactive) |
839 (let ((werr nil)) | |
840 (if whitespace-auto-cleanup | |
841 (whitespace-cleanup) | |
842 (setq werr (whitespace-buffer))) | |
843 (if (and whitespace-abort-on-error werr) | |
844 (error (concat "Abort write due to whitespaces in " | |
845 buffer-file-name)))) | |
846 nil) | |
847 | |
32501 | 848 (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
|
849 (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
|
850 (remove-hook 'write-file-functions 'whitespace-write-file-hook t) |
32501 | 851 (remove-hook 'kill-buffer-hook 'whitespace-buffer)) |
852 | |
57522
3f7aa44cf697
(whitespace-unload-hook): Set the variable.
Richard M. Stallman <rms@gnu.org>
parents:
56763
diff
changeset
|
853 (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
|
854 |
25582 | 855 (provide 'whitespace) |
52401 | 856 |
61395
21f8452c722e
(whitespace-highlight-the-space): Put the same overlay
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
61394
diff
changeset
|
857 ;; arch-tag: 4ff44e87-b63c-402d-95a6-15e51e58bd0c |
25582 | 858 ;;; whitespace.el ends here |