Mercurial > emacs
annotate lisp/whitespace.el @ 40958:4b4504c5aa56
* vc.el (vc-print-log): Bind `inhibit-read-only' to t before and
set-buffer-modified-p to nil after `vc-exec-after'.
* log-view.el (log-view-mode-map): Bind "q", "z", "m" and "d".
(log-view-mode): Make read-only.
(log-view-current-file): Do final `expand-file-name' in the
current `default-directory'.
(log-view-current-tag): Take an optional `where' arg.
(log-view-diff): New user command.
author | Sam Steingold <sds@gnu.org> |
---|---|
date | Mon, 12 Nov 2001 23:01:17 +0000 |
parents | ceec599316a4 |
children | 0ad4d3e3bfe6 |
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 |
34304 | 3 ;; Copyright (C) 1999, 2000 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 | |
38882 | 8 ;; $Id: whitespace.el,v 1.17 2001/08/20 10:05:03 gerd Exp $ |
25582 | 9 ;; This file is part of GNU Emacs. |
10 | |
11 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
12 ;; it under the terms of the GNU General Public License as published by | |
13 ;; the Free Software Foundation; either version 2, or (at your option) | |
14 ;; any later version. | |
15 | |
16 ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
24 ;; Boston, MA 02111-1307, USA. | |
25 | |
26 ;;; Commentary: | |
27 | |
28 ;; Whitespace.el URL: http://www.dsmit.com/lisp/ | |
29 | |
30 ;; Exported functions: | |
31 | |
32 ;; `whitespace-buffer' - To check the current buffer for whitespace problems. | |
33 ;; `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
|
34 ;; `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
|
35 ;; problems. |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
36 ;; `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
|
37 ;; and mark in the current buffer. |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
38 ;; `whitespace-describe' - A simple introduction to the library. |
25582 | 39 |
40 ;;; Code: | |
41 | |
38882 | 42 (defvar whitespace-version "3.1" "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
|
43 |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
44 (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
|
45 "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
|
46 |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
47 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
|
48 visited by the buffers.") |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
49 |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
50 (defvar whitespace-rescan-timer nil |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
51 "Timer object used to rescan the files in buffers that have been modified.") |
25582 | 52 |
26245
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
53 ;; 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
|
54 (defvar whitespace-mode nil |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
55 "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
|
56 (make-variable-buffer-local 'whitespace-mode) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
57 (put 'whitespace-mode 'permanent-local nil) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
58 |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
59 (defvar whitespace-mode-line nil |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
60 "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
|
61 (make-variable-buffer-local 'whitespace-mode-line) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
62 (put 'whitespace-mode-line 'permanent-local nil) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
63 |
36944
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
64 (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
|
65 "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
|
66 (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
|
67 (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
|
68 |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
69 (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
|
70 "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
|
71 (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
|
72 (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
|
73 |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
74 (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
|
75 "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
|
76 (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
|
77 (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
|
78 |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
79 (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
|
80 "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
|
81 (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
|
82 (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
|
83 |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
84 (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
|
85 "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
|
86 (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
|
87 (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
|
88 |
26253
3bb622df1c52
(whitespace-version): Update to 2.8
Gerd Moellmann <gerd@gnu.org>
parents:
26245
diff
changeset
|
89 ;; 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
|
90 (eval-when-compile |
26253
3bb622df1c52
(whitespace-version): Update to 2.8
Gerd Moellmann <gerd@gnu.org>
parents:
26245
diff
changeset
|
91 (if (not (fboundp 'defgroup)) |
3bb622df1c52
(whitespace-version): Update to 2.8
Gerd Moellmann <gerd@gnu.org>
parents:
26245
diff
changeset
|
92 (defmacro defgroup (sym memb doc &rest args) |
3bb622df1c52
(whitespace-version): Update to 2.8
Gerd Moellmann <gerd@gnu.org>
parents:
26245
diff
changeset
|
93 "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
|
94 defgroup" |
3bb622df1c52
(whitespace-version): Update to 2.8
Gerd Moellmann <gerd@gnu.org>
parents:
26245
diff
changeset
|
95 t)) |
3bb622df1c52
(whitespace-version): Update to 2.8
Gerd Moellmann <gerd@gnu.org>
parents:
26245
diff
changeset
|
96 (if (not (fboundp 'defcustom)) |
3bb622df1c52
(whitespace-version): Update to 2.8
Gerd Moellmann <gerd@gnu.org>
parents:
26245
diff
changeset
|
97 (defmacro defcustom (sym val doc &rest args) |
3bb622df1c52
(whitespace-version): Update to 2.8
Gerd Moellmann <gerd@gnu.org>
parents:
26245
diff
changeset
|
98 "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
|
99 don't define defcustom" |
3bb622df1c52
(whitespace-version): Update to 2.8
Gerd Moellmann <gerd@gnu.org>
parents:
26245
diff
changeset
|
100 `(defvar ,sym ,val ,doc)))) |
25582 | 101 |
32501 | 102 (if (featurep 'xemacs) |
25582 | 103 (defgroup whitespace nil |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
104 "Check for and fix five different types of whitespaces in source code." |
25582 | 105 ;; Since XEmacs doesn't have a 'convenience group, use the next best group |
106 ;; which is 'editing? | |
32501 | 107 :group 'editing) |
108 (defgroup whitespace nil | |
109 "Check for and fix five different types of whitespaces in source code." | |
110 :version "21.1" | |
111 :group 'convenience)) | |
25582 | 112 |
25724
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
113 (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
|
114 "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
|
115 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
|
116 `whitespace-check-buffer-leading'" |
25724
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
117 :type 'boolean |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
118 :group 'whitespace) |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
119 |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
120 (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
|
121 "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
|
122 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
|
123 `whitespace-check-buffer-trailing'" |
25724
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
124 :type 'boolean |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
125 :group 'whitespace) |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
126 |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
127 (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
|
128 "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
|
129 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
|
130 `whitespace-check-buffer-spacetab'" |
25724
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
131 :type 'boolean |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
132 :group 'whitespace) |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
133 |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
134 (defcustom whitespace-spacetab-regexp " \t" |
25724
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
135 "Regexp to match a space followed by a TAB." |
32501 | 136 :type 'regexp |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
137 :group 'whitespace) |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
138 |
38882 | 139 (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
|
140 "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
|
141 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
|
142 `whitespace-check-buffer-indent'" |
25724
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
143 :type 'boolean |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
144 :group 'whitespace) |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
145 |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
146 (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
|
147 "Regexp to match (any TABS followed by) 8/more whitespaces at start of line." |
32501 | 148 :type 'regexp |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
149 :group 'whitespace) |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
150 |
25724
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
151 (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
|
152 "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
|
153 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
|
154 `whitespace-check-buffer-ateol'" |
25724
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
155 :type 'boolean |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
156 :group 'whitespace) |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
157 |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
158 (defcustom whitespace-ateol-regexp "[ \t]$" |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
159 "Regexp to match a TAB or a space at the EOL." |
32501 | 160 :type 'regexp |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
161 :group 'whitespace) |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
162 |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
163 (defcustom whitespace-errbuf "*Whitespace Errors*" |
32501 | 164 "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
|
165 :type 'string |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
166 :group 'whitespace) |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
167 |
38882 | 168 (defcustom whitespace-abort-on-error nil |
169 "While writing a file, abort if the file is unclean. If | |
170 `whitespace-auto-cleanup' is set, that takes precedence over this | |
171 variable." | |
172 :type 'boolean | |
173 :group 'whitespace) | |
174 | |
25582 | 175 (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
|
176 "Cleanup a buffer automatically on finding it whitespace unclean." |
25582 | 177 :type 'boolean |
178 :group 'whitespace) | |
179 | |
180 (defcustom whitespace-silent nil | |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
181 "All whitespace errors will be shown only in the modeline when t. |
25582 | 182 |
183 Note that setting this may cause all whitespaces introduced in a file to go | |
184 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
|
185 Errors*' buffer before opening (or closing) another file." |
25582 | 186 :type 'boolean |
187 :group 'whitespace) | |
188 | |
189 (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
|
190 c-mode c++-mode cc-mode |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
191 change-log-mode cperl-mode |
25582 | 192 electric-nroff-mode emacs-lisp-mode |
193 f90-mode fortran-mode html-mode | |
194 html3-mode java-mode jde-mode | |
195 ksh-mode latex-mode LaTeX-mode | |
196 lisp-mode m4-mode makefile-mode | |
197 modula-2-mode nroff-mode objc-mode | |
198 pascal-mode perl-mode prolog-mode | |
199 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
|
200 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
|
201 tcl-mode tex-mode texinfo-mode |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
202 vrml-mode xml-mode) |
25582 | 203 |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
204 "Major Modes in which we turn on whitespace checking. |
25582 | 205 |
32501 | 206 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
|
207 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
|
208 following to your `.emacs': |
25582 | 209 |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
210 \(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
|
211 whitespace-modes))\) |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
212 |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
213 Or, alternately, you can use the Emacs `customize' command to set this." |
32501 | 214 :type '(repeat symbol) |
25582 | 215 :group 'whitespace) |
216 | |
29333
189f70e66cab
Update whitespace.el with a more tolerable timer scan time.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
27583
diff
changeset
|
217 (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
|
218 "Period in seconds to rescan modified buffers for whitespace creep. |
25582 | 219 |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
220 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
|
221 `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
|
222 modified buffers. |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
223 |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
224 To disable timer scans, set this to zero." |
25582 | 225 :type 'integer |
226 :group 'whitespace) | |
227 | |
26245
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
228 (defcustom whitespace-display-in-modeline t |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
229 "Display whitespace errors on the modeline." |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
230 :type 'boolean |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
231 :group 'whitespace) |
25582 | 232 |
233 (if (not (assoc 'whitespace-mode minor-mode-alist)) | |
234 (setq minor-mode-alist (cons '(whitespace-mode whitespace-mode-line) | |
235 minor-mode-alist))) | |
236 | |
36944
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
237 (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
|
238 whitespace-check-leading-whitespace) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
239 (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
|
240 whitespace-check-trailing-whitespace) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
241 (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
|
242 whitespace-check-indent-whitespace) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
243 (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
|
244 whitespace-check-spacetab-whitespace) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
245 (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
|
246 whitespace-check-ateol-whitespace) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
247 |
25582 | 248 (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
|
249 "Test and set the whitespace-mode in qualifying buffers." |
25582 | 250 (if (null whitespace-mode) |
251 (setq whitespace-mode | |
252 (if (or arg (member major-mode whitespace-modes)) | |
253 t | |
254 nil)))) | |
255 | |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
256 ;;;###autoload |
36944
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
257 (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
|
258 "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
|
259 (interactive) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
260 (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
|
261 (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
|
262 (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
|
263 (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
|
264 (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
|
265 |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
266 ;;;###autoload |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
267 (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
|
268 "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
|
269 (interactive) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
270 (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
|
271 (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
|
272 (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
|
273 (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
|
274 (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
|
275 |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
276 ;;;###autoload |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
277 (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
|
278 "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
|
279 (interactive) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
280 (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
|
281 (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
|
282 (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
|
283 (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
|
284 (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
|
285 (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
|
286 |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
287 ;;;###autoload |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
288 (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
|
289 "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
|
290 (interactive) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
291 (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
|
292 (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
|
293 (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
|
294 (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
|
295 (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
|
296 (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
|
297 |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
298 |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
299 ;;;###autoload |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
300 (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
|
301 "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
|
302 (interactive) |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
303 (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
|
304 (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
|
305 (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
|
306 (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
|
307 (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
|
308 (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
|
309 |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
310 |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
311 ;;;###autoload |
25582 | 312 (defun whitespace-buffer (&optional quiet) |
32501 | 313 "Find five different types of white spaces in buffer. |
314 These are: | |
25582 | 315 1. Leading space \(empty lines at the top of a file\). |
316 2. Trailing space \(empty lines at the end of a file\). | |
317 3. Indentation space \(8 or more spaces, that should be replaced with TABS\). | |
318 4. Spaces followed by a TAB. \(Almost always, we never want that\). | |
319 5. Spaces or TABS at the end of a line. | |
320 | |
321 Check for whitespace only if this buffer really contains a non-empty file | |
322 and: | |
323 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
|
324 2. `whitespace-buffer' was explicitly called with a prefix argument." |
25582 | 325 (interactive) |
26245
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
326 (let ((whitespace-error nil)) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
327 (whitespace-check-whitespace-mode current-prefix-arg) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
328 (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
|
329 (progn |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
330 (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
|
331 (whitespace-tickle-timer) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
332 (if whitespace-auto-cleanup |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
333 (if buffer-read-only |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
334 (if (not quiet) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
335 (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
|
336 (whitespace-cleanup)) |
36944
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
337 (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
|
338 (whitespace-buffer-leading) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
339 nil)) |
36944
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
340 (whitespace-trailing (if whitespace-check-buffer-trailing |
26245
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
341 (whitespace-buffer-trailing) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
342 nil)) |
36944
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
343 (whitespace-indent (if whitespace-check-buffer-indent |
26245
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
344 (whitespace-buffer-search |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
345 whitespace-indent-regexp) |
25724
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
346 nil)) |
36944
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
347 (whitespace-spacetab (if whitespace-check-buffer-spacetab |
26245
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
348 (whitespace-buffer-search |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
349 whitespace-spacetab-regexp) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
350 nil)) |
36944
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
351 (whitespace-ateol (if whitespace-check-buffer-ateol |
26245
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
352 (whitespace-buffer-search |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
353 whitespace-ateol-regexp) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
354 nil)) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
355 (whitespace-errmsg nil) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
356 (whitespace-filename buffer-file-name) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
357 (whitespace-this-modeline "")) |
25582 | 358 |
26245
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
359 ;; 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
|
360 (setq whitespace-error (or whitespace-leading whitespace-indent |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
361 whitespace-spacetab whitespace-ateol |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
362 whitespace-trailing)) |
25582 | 363 |
26245
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
364 (if whitespace-error |
25582 | 365 (progn |
26245
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
366 (setq whitespace-errmsg |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
367 (concat whitespace-filename " contains:\n" |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
368 (if whitespace-leading |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
369 "Leading whitespace\n") |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
370 (if whitespace-indent |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
371 (concat "Indentation whitespace" |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
372 whitespace-indent "\n")) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
373 (if whitespace-spacetab |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
374 (concat "Space followed by Tab" |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
375 whitespace-spacetab "\n")) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
376 (if whitespace-ateol |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
377 (concat "End-of-line whitespace" |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
378 whitespace-ateol "\n")) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
379 (if whitespace-trailing |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
380 "Trailing whitespace\n") |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
381 "\ntype `M-x whitespace-cleanup' to " |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
382 "cleanup the file.")) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
383 (setq whitespace-this-modeline |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
384 (concat (if whitespace-ateol "e") |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
385 (if whitespace-indent "i") |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
386 (if whitespace-leading "l") |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
387 (if whitespace-spacetab "s") |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
388 (if whitespace-trailing "t"))))) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
389 (whitespace-update-modeline whitespace-this-modeline) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
390 (save-excursion |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
391 (get-buffer-create whitespace-errbuf) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
392 (kill-buffer whitespace-errbuf) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
393 (get-buffer-create whitespace-errbuf) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
394 (set-buffer whitespace-errbuf) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
395 (if whitespace-errmsg |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
396 (progn |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
397 (insert whitespace-errmsg) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
398 (if (not (or quiet whitespace-silent)) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
399 (display-buffer whitespace-errbuf t)) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
400 (if (not quiet) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
401 (message "Whitespaces: [%s%s] in %s" |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
402 whitespace-this-modeline |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
403 (let ((whitespace-unchecked |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
404 (whitespace-unchecked-whitespaces))) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
405 (if whitespace-unchecked |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
406 (concat "!" whitespace-unchecked) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
407 "")) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
408 whitespace-filename))) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
409 (if (not quiet) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
410 (message "%s clean" whitespace-filename)))))))) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
411 (if whitespace-error |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
412 t |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
413 nil))) |
25582 | 414 |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
415 ;;;###autoload |
25582 | 416 (defun whitespace-region (s e) |
32501 | 417 "Check the region for whitespace errors." |
25582 | 418 (interactive "r") |
419 (save-excursion | |
420 (save-restriction | |
421 (narrow-to-region s e) | |
422 (whitespace-buffer)))) | |
423 | |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
424 ;;;###autoload |
25582 | 425 (defun whitespace-cleanup () |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
426 "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
|
427 |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
428 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
|
429 whitespace problems." |
25582 | 430 (interactive) |
431 ;; If this buffer really contains a file, then run, else quit. | |
432 (whitespace-check-whitespace-mode current-prefix-arg) | |
433 (if (and buffer-file-name whitespace-mode) | |
434 (let ((whitespace-any nil) | |
435 (whitespace-tabwith 8) | |
436 (whitespace-tabwith-saved tab-width)) | |
437 | |
438 ;; since all printable TABS should be 8, irrespective of how | |
439 ;; they are displayed. | |
440 (setq tab-width whitespace-tabwith) | |
441 | |
36944
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
442 (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
|
443 (whitespace-buffer-leading)) |
25582 | 444 (progn |
445 (whitespace-buffer-leading-cleanup) | |
446 (setq whitespace-any t))) | |
447 | |
36944
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
448 (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
|
449 (whitespace-buffer-trailing)) |
25582 | 450 (progn |
451 (whitespace-buffer-trailing-cleanup) | |
452 (setq whitespace-any t))) | |
453 | |
36944
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
454 (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
|
455 (whitespace-buffer-search whitespace-indent-regexp)) |
25582 | 456 (progn |
457 (whitespace-indent-cleanup) | |
458 (setq whitespace-any t))) | |
459 | |
36944
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
460 (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
|
461 (whitespace-buffer-search whitespace-spacetab-regexp)) |
25582 | 462 (progn |
463 (whitespace-buffer-cleanup whitespace-spacetab-regexp "\t") | |
464 (setq whitespace-any t))) | |
465 | |
36944
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
466 (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
|
467 (whitespace-buffer-search whitespace-ateol-regexp)) |
25582 | 468 (progn |
469 (whitespace-buffer-cleanup whitespace-ateol-regexp "") | |
470 (setq whitespace-any t))) | |
471 | |
472 ;; 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
|
473 (if whitespace-any |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
474 (whitespace-cleanup) |
25582 | 475 (progn |
476 (message "%s clean" buffer-file-name) | |
26245
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
477 (whitespace-update-modeline))) |
25582 | 478 (setq tab-width whitespace-tabwith-saved)))) |
479 | |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
480 ;;;###autoload |
25582 | 481 (defun whitespace-cleanup-region (s e) |
32501 | 482 "Whitespace cleanup on the region." |
25582 | 483 (interactive "r") |
484 (save-excursion | |
485 (save-restriction | |
486 (narrow-to-region s e) | |
487 (whitespace-cleanup)) | |
488 (whitespace-buffer t))) | |
489 | |
490 (defun whitespace-buffer-leading () | |
491 "Check to see if there are any empty lines at the top of the file." | |
492 (save-excursion | |
493 (let ((pmin nil) | |
494 (pmax nil)) | |
495 (goto-char (point-min)) | |
496 (beginning-of-line) | |
497 (setq pmin (point)) | |
498 (end-of-line) | |
499 (setq pmax (point)) | |
500 (if (equal pmin pmax) | |
501 t | |
502 nil)))) | |
503 | |
504 (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
|
505 "Remove any empty lines at the top of the file." |
25582 | 506 (save-excursion |
507 (let ((pmin nil) | |
508 (pmax nil)) | |
509 (goto-char (point-min)) | |
510 (beginning-of-line) | |
511 (setq pmin (point)) | |
512 (end-of-line) | |
513 (setq pmax (point)) | |
514 (if (equal pmin pmax) | |
515 (progn | |
516 (kill-line) | |
517 (whitespace-buffer-leading-cleanup)))))) | |
518 | |
519 (defun whitespace-buffer-trailing () | |
520 "Check to see if are is more than one empty line at the bottom." | |
521 (save-excursion | |
522 (let ((pmin nil) | |
523 (pmax nil)) | |
524 (goto-char (point-max)) | |
525 (beginning-of-line) | |
526 (setq pmin (point)) | |
527 (end-of-line) | |
528 (setq pmax (point)) | |
529 (if (equal pmin pmax) | |
530 (progn | |
531 (goto-char (- (point) 1)) | |
532 (beginning-of-line) | |
533 (setq pmin (point)) | |
534 (end-of-line) | |
535 (setq pmax (point)) | |
536 (if (equal pmin pmax) | |
537 t | |
538 nil)) | |
539 nil)))) | |
540 | |
541 (defun whitespace-buffer-trailing-cleanup () | |
542 "Delete all the empty lines at the bottom." | |
543 (save-excursion | |
544 (let ((pmin nil) | |
545 (pmax nil)) | |
546 (goto-char (point-max)) | |
547 (beginning-of-line) | |
548 (setq pmin (point)) | |
549 (end-of-line) | |
550 (setq pmax (point)) | |
551 (if (equal pmin pmax) | |
552 (progn | |
553 (goto-char (1- pmin)) | |
554 (beginning-of-line) | |
555 (setq pmin (point)) | |
556 (end-of-line) | |
557 (setq pmax (point)) | |
558 (if (equal pmin pmax) | |
559 (progn | |
560 (goto-char (1- (point-max))) | |
561 (beginning-of-line) | |
562 (kill-line) | |
563 (whitespace-buffer-trailing-cleanup)))))))) | |
564 | |
565 (defun whitespace-buffer-search (regexp) | |
566 "Search for any given whitespace REGEXP." | |
567 (let ((whitespace-retval "")) | |
568 (save-excursion | |
569 (goto-char (point-min)) | |
570 (while (re-search-forward regexp nil t) | |
38882 | 571 (setq whitespace-retval (format "%s %s" whitespace-retval |
25582 | 572 (match-beginning 0)))) |
573 (if (equal "" whitespace-retval) | |
574 nil | |
575 whitespace-retval)))) | |
576 | |
577 (defun whitespace-buffer-cleanup (regexp newregexp) | |
578 "Search for any given whitespace REGEXP and replace it with the NEWREGEXP." | |
579 (save-excursion | |
580 (goto-char (point-min)) | |
581 (while (re-search-forward regexp nil t) | |
582 (replace-match newregexp)))) | |
583 | |
584 (defun whitespace-indent-cleanup () | |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
585 "Search for 8/more spaces at the start of a line and replace it with tabs." |
25582 | 586 (save-excursion |
587 (goto-char (point-min)) | |
588 (while (re-search-forward whitespace-indent-regexp nil t) | |
589 (let ((column (current-column)) | |
590 (indent-tabs-mode t)) | |
591 (delete-region (match-beginning 0) (point)) | |
592 (indent-to column))))) | |
593 | |
26245
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
594 (defun whitespace-unchecked-whitespaces () |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
595 "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
|
596 (let ((unchecked-spaces |
4d294c5bb2ac
whitespace.el version 3.0 with buffer local toggle capability.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
35050
diff
changeset
|
597 (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
|
598 (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
|
599 (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
|
600 (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
|
601 (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
|
602 (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
|
603 unchecked-spaces |
26245
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
604 nil))) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
605 |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
606 (defun whitespace-update-modeline (&optional whitespace-err) |
32501 | 607 "Update modeline with whitespace errors. |
608 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
|
609 (if whitespace-display-in-modeline |
26259
912b004387d9
(whitespace-update-modeline): Bugfix to ensure
Gerd Moellmann <gerd@gnu.org>
parents:
26253
diff
changeset
|
610 (progn |
912b004387d9
(whitespace-update-modeline): Bugfix to ensure
Gerd Moellmann <gerd@gnu.org>
parents:
26253
diff
changeset
|
611 (setq whitespace-mode-line nil) |
912b004387d9
(whitespace-update-modeline): Bugfix to ensure
Gerd Moellmann <gerd@gnu.org>
parents:
26253
diff
changeset
|
612 ;; Whitespace errors |
912b004387d9
(whitespace-update-modeline): Bugfix to ensure
Gerd Moellmann <gerd@gnu.org>
parents:
26253
diff
changeset
|
613 (if (and whitespace-err (not (equal whitespace-err ""))) |
912b004387d9
(whitespace-update-modeline): Bugfix to ensure
Gerd Moellmann <gerd@gnu.org>
parents:
26253
diff
changeset
|
614 (setq whitespace-mode-line whitespace-err)) |
912b004387d9
(whitespace-update-modeline): Bugfix to ensure
Gerd Moellmann <gerd@gnu.org>
parents:
26253
diff
changeset
|
615 ;; Whitespace suppressed errors |
912b004387d9
(whitespace-update-modeline): Bugfix to ensure
Gerd Moellmann <gerd@gnu.org>
parents:
26253
diff
changeset
|
616 (let ((whitespace-unchecked (whitespace-unchecked-whitespaces))) |
912b004387d9
(whitespace-update-modeline): Bugfix to ensure
Gerd Moellmann <gerd@gnu.org>
parents:
26253
diff
changeset
|
617 (if whitespace-unchecked |
912b004387d9
(whitespace-update-modeline): Bugfix to ensure
Gerd Moellmann <gerd@gnu.org>
parents:
26253
diff
changeset
|
618 (setq whitespace-mode-line |
912b004387d9
(whitespace-update-modeline): Bugfix to ensure
Gerd Moellmann <gerd@gnu.org>
parents:
26253
diff
changeset
|
619 (concat whitespace-mode-line "!" whitespace-unchecked)))) |
912b004387d9
(whitespace-update-modeline): Bugfix to ensure
Gerd Moellmann <gerd@gnu.org>
parents:
26253
diff
changeset
|
620 ;; Add the whitespace modeline prefix |
912b004387d9
(whitespace-update-modeline): Bugfix to ensure
Gerd Moellmann <gerd@gnu.org>
parents:
26253
diff
changeset
|
621 (setq whitespace-mode-line (if whitespace-mode-line |
912b004387d9
(whitespace-update-modeline): Bugfix to ensure
Gerd Moellmann <gerd@gnu.org>
parents:
26253
diff
changeset
|
622 (concat " W:" whitespace-mode-line) |
912b004387d9
(whitespace-update-modeline): Bugfix to ensure
Gerd Moellmann <gerd@gnu.org>
parents:
26253
diff
changeset
|
623 nil)) |
912b004387d9
(whitespace-update-modeline): Bugfix to ensure
Gerd Moellmann <gerd@gnu.org>
parents:
26253
diff
changeset
|
624 (whitespace-force-mode-line-update)))) |
25724
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
625 |
25582 | 626 ;; Force mode line updation for different Emacs versions |
627 (defun whitespace-force-mode-line-update () | |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
628 "Force the mode line update for different flavors of Emacs." |
32501 | 629 (if (fboundp 'redraw-modeline) |
630 (redraw-modeline) ; XEmacs | |
631 (force-mode-line-update))) ; Emacs | |
25582 | 632 |
633 (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
|
634 "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
|
635 |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
636 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
|
637 periodically for whitespace." |
25582 | 638 (if (and whitespace-mode (not (member (list buf-file buf-name) |
639 whitespace-all-buffer-files))) | |
640 (add-to-list 'whitespace-all-buffer-files (list buf-file buf-name)))) | |
641 | |
642 (defun whitespace-tickle-timer () | |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
643 "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
|
644 |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
645 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
|
646 `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
|
647 `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
|
648 (if (and whitespace-rescan-timer-time (not whitespace-rescan-timer)) |
25582 | 649 (setq whitespace-rescan-timer |
32501 | 650 (add-timeout whitespace-rescan-timer-time |
651 'whitespace-rescan-files-in-buffers nil | |
652 whitespace-rescan-timer-time)))) | |
25582 | 653 |
654 (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
|
655 "Check monitored files for whitespace creep since last scan." |
25582 | 656 (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
|
657 buffile bufname thiselt buf) |
25582 | 658 (if (not whitespace-all-my-files) |
659 (progn | |
32501 | 660 (disable-timeout whitespace-rescan-timer) |
25582 | 661 (setq whitespace-rescan-timer nil)) |
662 (while whitespace-all-my-files | |
663 (setq thiselt (car whitespace-all-my-files)) | |
664 (setq whitespace-all-my-files (cdr whitespace-all-my-files)) | |
665 (setq buffile (car thiselt)) | |
666 (setq bufname (cadr thiselt)) | |
667 (setq buf (get-buffer bufname)) | |
668 (if (buffer-live-p buf) | |
669 (save-excursion | |
670 ;;(message "buffer %s live" bufname) | |
671 (set-buffer bufname) | |
672 (if whitespace-mode | |
673 (progn | |
674 ;;(message "checking for whitespace in %s" bufname) | |
675 (if whitespace-auto-cleanup | |
676 (progn | |
677 ;;(message "cleaning up whitespace in %s" bufname) | |
678 (whitespace-cleanup)) | |
679 (progn | |
680 ;;(message "whitespace-buffer %s." (buffer-name)) | |
681 (whitespace-buffer t)))) | |
682 ;;(message "Removing %s from refresh list" bufname) | |
683 (whitespace-refresh-rescan-list buffile bufname))) | |
684 ;;(message "Removing %s from refresh list" bufname) | |
685 (whitespace-refresh-rescan-list buffile bufname)))))) | |
686 | |
687 (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
|
688 "Refresh the list of files to be rescaned for whitespace creep." |
25582 | 689 (if whitespace-all-buffer-files |
32501 | 690 (setq whitespace-all-buffer-files |
691 (delete (list buffile bufname) whitespace-all-buffer-files)) | |
692 (when whitespace-rescan-timer | |
693 (disable-timeout whitespace-rescan-timer) | |
694 (setq whitespace-rescan-timer nil)))) | |
695 | |
696 ;;;###autoload | |
697 (defcustom whitespace-global-mode nil | |
698 "Toggle global Whitespace mode. | |
699 | |
700 Setting this variable directly does not take effect; | |
701 use either \\[customize] or the function `whitespace-global-mode' | |
702 \(which see)." | |
703 :set (lambda (sym val) | |
35050
eeb50448541d
(whitespace-global-mode): Fix typo.
Dave Love <fx@gnu.org>
parents:
34304
diff
changeset
|
704 (whitespace-global-mode (or val 0))) |
32501 | 705 :initialize 'custom-initialize-default |
706 :type 'boolean | |
707 :group 'whitespace | |
708 :require 'whitespace) | |
709 | |
38874
a1db1537c80f
(whitespace-global-mode): Add autoload cookie.
Gerd Moellmann <gerd@gnu.org>
parents:
38436
diff
changeset
|
710 ;;;###autoload |
32501 | 711 (defun whitespace-global-mode (&optional arg) |
712 "Toggle using Whitespace mode in new buffers. | |
713 With ARG, turn the mode on if and only iff ARG is positive. | |
714 | |
715 When this mode is active, `whitespace-buffer' is added to | |
716 `find-file-hooks' and `kill-buffer-hook'." | |
717 (interactive "P") | |
718 (setq arg (if arg | |
719 (> (prefix-numeric-value arg) 0) | |
720 (not whitespace-global-mode))) | |
721 (if arg | |
25582 | 722 (progn |
32501 | 723 (add-hook 'find-file-hooks 'whitespace-buffer) |
38882 | 724 (add-hook 'local-write-file-hooks 'whitespace-write-file-hook) |
32501 | 725 (add-hook 'kill-buffer-hook 'whitespace-buffer)) |
726 (remove-hook 'find-file-hooks 'whitespace-buffer) | |
38882 | 727 (remove-hook 'local-write-file-hooks 'whitespace-write-file-hook) |
32501 | 728 (remove-hook 'kill-buffer-hook 'whitespace-buffer))) |
25582 | 729 |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
730 ;;;###autoload |
38882 | 731 (defun whitespace-write-file-hook () |
732 "The local-write-file-hook to be called on the buffer when | |
733 whitespace check is enabled." | |
734 (interactive) | |
735 (let ((werr nil)) | |
736 (if whitespace-auto-cleanup | |
737 (whitespace-cleanup) | |
738 (setq werr (whitespace-buffer))) | |
739 (if (and whitespace-abort-on-error werr) | |
740 (error (concat "Abort write due to whitespaces in " | |
741 buffer-file-name)))) | |
742 nil) | |
743 | |
744 ;;;###autoload | |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
745 (defun whitespace-describe () |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
746 "A summary of whitespaces and what this library can do about them. |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
747 |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
748 The whitespace library is intended to find and help fix five different types |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
749 of whitespace problems that commonly exist in source code. |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
750 |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
751 1. Leading space (empty lines at the top of a file). |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
752 2. Trailing space (empty lines at the end of a file). |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
753 3. Indentation space (8 or more spaces at beginning of line, that should be |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
754 replaced with TABS). |
32501 | 755 4. Spaces followed by a TAB. (Almost always, we never want that). |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
756 5. Spaces or TABS at the end of a line. |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
757 |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
758 Whitespace errors are reported in a buffer, and on the modeline. |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
759 |
26245
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
760 Modeline will show a W:<x>!<y> to denote a particular type of whitespace, |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
761 where `x' and `y' can be one (or more) of: |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
762 |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
763 e - End-of-Line whitespace. |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
764 i - Indentation whitespace. |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
765 l - Leading whitespace. |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
766 s - Space followed by Tab. |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
767 t - Trailing whitespace. |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
768 |
25724
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
769 If any of the whitespace checks is turned off, the modeline will display a |
26245
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
770 !<y>. |
25724
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
771 |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
772 (since (3) is the most controversial one, here is the rationale: Most |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
773 terminal drivers and printer drivers have TAB configured or even |
32501 | 774 hardcoded to be 8 spaces. (Some of them allow configuration, but almost |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
775 always they default to 8.) |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
776 |
32501 | 777 Changing `tab-width' to other than 8 and editing will cause your code to |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
778 look different from within Emacs, and say, if you cat it or more it, or |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
779 even print it. |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
780 |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
781 Almost all the popular programming modes let you define an offset (like |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
782 c-basic-offset or perl-indent-level) to configure the offset, so you |
32501 | 783 should never have to set your `tab-width' to be other than 8 in all these |
784 modes. In fact, with an indent level of say, 4, 2 TABS will cause Emacs | |
785 to replace your 8 spaces with one \t (try it). If vi users in your | |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
786 office complain, tell them to use vim, which distinguishes between |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
787 tabstop and shiftwidth (vi equivalent of our offsets), and also ask them |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
788 to set smarttab.) |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
789 |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
790 All the above have caused (and will cause) unwanted codeline integration and |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
791 merge problems. |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
792 |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
793 whitespace.el will complain if it detects whitespaces on opening a file, and |
32501 | 794 warn you on closing a file also (in case you had inserted any |
795 whitespaces during the process of your editing)." | |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
796 (interactive) |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
797 (message "Use C-h f whitespace-describe to read about whitespace.el v%s." |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
798 whitespace-version)) |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
799 |
32501 | 800 (defun whitespace-unload-hook () |
801 (remove-hook 'find-file-hooks 'whitespace-buffer) | |
38882 | 802 (remove-hook 'local-write-file-hooks 'whitespace-write-file-hook) |
32501 | 803 (remove-hook 'kill-buffer-hook 'whitespace-buffer)) |
804 | |
25582 | 805 (provide 'whitespace) |
806 | |
807 ;;; whitespace.el ends here |