Mercurial > emacs
annotate lisp/whitespace.el @ 33723:374860c66241
*** empty log message ***
author | Miles Bader <miles@gnu.org> |
---|---|
date | Wed, 22 Nov 2000 01:20:31 +0000 |
parents | 616755d12f93 |
children | dd613770eb0f |
rev | line source |
---|---|
25582 | 1 ;;; whitespace.el --- Warn about and clean bogus whitespaces in the file. |
2 | |
29499
a293ec8516e0
Update whitespace.el - comment out the :version string, since it
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
29333
diff
changeset
|
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 | |
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: | |
26 | |
27 ;; Whitespace.el URL: http://www.dsmit.com/lisp/ | |
28 | |
29 ;; Exported functions: | |
30 | |
31 ;; `whitespace-buffer' - To check the current buffer for whitespace problems. | |
32 ;; `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
|
33 ;; `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
|
34 ;; problems. |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
35 ;; `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
|
36 ;; 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
|
37 ;; `whitespace-describe' - A simple introduction to the library. |
25582 | 38 |
39 ;;; Code: | |
40 | |
26253
3bb622df1c52
(whitespace-version): Update to 2.8
Gerd Moellmann <gerd@gnu.org>
parents:
26245
diff
changeset
|
41 (defvar whitespace-version "2.8" "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
|
42 |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
43 (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
|
44 "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
|
45 |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
46 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
|
47 visited by the buffers.") |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
48 |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
49 (defvar whitespace-rescan-timer nil |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
50 "Timer object used to rescan the files in buffers that have been modified.") |
25582 | 51 |
26245
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
52 ;; 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
|
53 (defvar whitespace-mode nil |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
54 "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
|
55 (make-variable-buffer-local 'whitespace-mode) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
56 (put 'whitespace-mode 'permanent-local nil) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
57 |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
58 (defvar whitespace-mode-line nil |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
59 "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
|
60 (make-variable-buffer-local 'whitespace-mode-line) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
61 (put 'whitespace-mode-line 'permanent-local nil) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
62 |
26253
3bb622df1c52
(whitespace-version): Update to 2.8
Gerd Moellmann <gerd@gnu.org>
parents:
26245
diff
changeset
|
63 ;; 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
|
64 (eval-when-compile |
26253
3bb622df1c52
(whitespace-version): Update to 2.8
Gerd Moellmann <gerd@gnu.org>
parents:
26245
diff
changeset
|
65 (if (not (fboundp 'defgroup)) |
3bb622df1c52
(whitespace-version): Update to 2.8
Gerd Moellmann <gerd@gnu.org>
parents:
26245
diff
changeset
|
66 (defmacro defgroup (sym memb doc &rest args) |
3bb622df1c52
(whitespace-version): Update to 2.8
Gerd Moellmann <gerd@gnu.org>
parents:
26245
diff
changeset
|
67 "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
|
68 defgroup" |
3bb622df1c52
(whitespace-version): Update to 2.8
Gerd Moellmann <gerd@gnu.org>
parents:
26245
diff
changeset
|
69 t)) |
3bb622df1c52
(whitespace-version): Update to 2.8
Gerd Moellmann <gerd@gnu.org>
parents:
26245
diff
changeset
|
70 (if (not (fboundp 'defcustom)) |
3bb622df1c52
(whitespace-version): Update to 2.8
Gerd Moellmann <gerd@gnu.org>
parents:
26245
diff
changeset
|
71 (defmacro defcustom (sym val doc &rest args) |
3bb622df1c52
(whitespace-version): Update to 2.8
Gerd Moellmann <gerd@gnu.org>
parents:
26245
diff
changeset
|
72 "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
|
73 don't define defcustom" |
3bb622df1c52
(whitespace-version): Update to 2.8
Gerd Moellmann <gerd@gnu.org>
parents:
26245
diff
changeset
|
74 `(defvar ,sym ,val ,doc)))) |
25582 | 75 |
32501 | 76 (if (featurep 'xemacs) |
25582 | 77 (defgroup whitespace nil |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
78 "Check for and fix five different types of whitespaces in source code." |
25582 | 79 ;; Since XEmacs doesn't have a 'convenience group, use the next best group |
80 ;; which is 'editing? | |
32501 | 81 :group 'editing) |
82 (defgroup whitespace nil | |
83 "Check for and fix five different types of whitespaces in source code." | |
84 :version "21.1" | |
85 :group 'convenience)) | |
25582 | 86 |
25724
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
87 (defcustom whitespace-check-leading-whitespace t |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
88 "Flag to check leading whitespace." |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
89 :type 'boolean |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
90 :group 'whitespace) |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
91 |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
92 (defcustom whitespace-check-trailing-whitespace t |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
93 "Flag to check trailing whitespace." |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
94 :type 'boolean |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
95 :group 'whitespace) |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
96 |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
97 (defcustom whitespace-check-spacetab-whitespace t |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
98 "Flag to check space followed by a TAB." |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
99 :type 'boolean |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
100 :group 'whitespace) |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
101 |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
102 (defcustom whitespace-spacetab-regexp " \t" |
25724
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
103 "Regexp to match a space followed by a TAB." |
32501 | 104 :type 'regexp |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
105 :group 'whitespace) |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
106 |
25724
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
107 (defcustom whitespace-check-indent-whitespace t |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
108 "Flag to check indentation whitespace." |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
109 :type 'boolean |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
110 :group 'whitespace) |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
111 |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
112 (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
|
113 "Regexp to match (any TABS followed by) 8/more whitespaces at start of line." |
32501 | 114 :type 'regexp |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
115 :group 'whitespace) |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
116 |
25724
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
117 (defcustom whitespace-check-ateol-whitespace t |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
118 "Flag to check end-of-line whitespace." |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
119 :type 'boolean |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
120 :group 'whitespace) |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
121 |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
122 (defcustom whitespace-ateol-regexp "[ \t]$" |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
123 "Regexp to match a TAB or a space at the EOL." |
32501 | 124 :type 'regexp |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
125 :group 'whitespace) |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
126 |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
127 (defcustom whitespace-errbuf "*Whitespace Errors*" |
32501 | 128 "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
|
129 :type 'string |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
130 :group 'whitespace) |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
131 |
25582 | 132 (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
|
133 "Cleanup a buffer automatically on finding it whitespace unclean." |
25582 | 134 :type 'boolean |
135 :group 'whitespace) | |
136 | |
137 (defcustom whitespace-silent nil | |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
138 "All whitespace errors will be shown only in the modeline when t. |
25582 | 139 |
140 Note that setting this may cause all whitespaces introduced in a file to go | |
141 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
|
142 Errors*' buffer before opening (or closing) another file." |
25582 | 143 :type 'boolean |
144 :group 'whitespace) | |
145 | |
146 (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
|
147 c-mode c++-mode cc-mode |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
148 change-log-mode cperl-mode |
25582 | 149 electric-nroff-mode emacs-lisp-mode |
150 f90-mode fortran-mode html-mode | |
151 html3-mode java-mode jde-mode | |
152 ksh-mode latex-mode LaTeX-mode | |
153 lisp-mode m4-mode makefile-mode | |
154 modula-2-mode nroff-mode objc-mode | |
155 pascal-mode perl-mode prolog-mode | |
156 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
|
157 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
|
158 tcl-mode tex-mode texinfo-mode |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
159 vrml-mode xml-mode) |
25582 | 160 |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
161 "Major Modes in which we turn on whitespace checking. |
25582 | 162 |
32501 | 163 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
|
164 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
|
165 following to your `.emacs': |
25582 | 166 |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
167 \(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
|
168 whitespace-modes))\) |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
169 |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
170 Or, alternately, you can use the Emacs `customize' command to set this." |
32501 | 171 :type '(repeat symbol) |
25582 | 172 :group 'whitespace) |
173 | |
29333
189f70e66cab
Update whitespace.el with a more tolerable timer scan time.
Rajesh Vaidheeswarran <rv@gnu.org>
parents:
27583
diff
changeset
|
174 (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
|
175 "Period in seconds to rescan modified buffers for whitespace creep. |
25582 | 176 |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
177 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
|
178 `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
|
179 modified buffers. |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
180 |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
181 To disable timer scans, set this to zero." |
25582 | 182 :type 'integer |
183 :group 'whitespace) | |
184 | |
26245
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
185 (defcustom whitespace-display-in-modeline t |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
186 "Display whitespace errors on the modeline." |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
187 :type 'boolean |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
188 :group 'whitespace) |
25582 | 189 |
190 (if (not (assoc 'whitespace-mode minor-mode-alist)) | |
191 (setq minor-mode-alist (cons '(whitespace-mode whitespace-mode-line) | |
192 minor-mode-alist))) | |
193 | |
194 (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
|
195 "Test and set the whitespace-mode in qualifying buffers." |
25582 | 196 (if (null whitespace-mode) |
197 (setq whitespace-mode | |
198 (if (or arg (member major-mode whitespace-modes)) | |
199 t | |
200 nil)))) | |
201 | |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
202 ;;;###autoload |
25582 | 203 (defun whitespace-buffer (&optional quiet) |
32501 | 204 "Find five different types of white spaces in buffer. |
205 These are: | |
25582 | 206 1. Leading space \(empty lines at the top of a file\). |
207 2. Trailing space \(empty lines at the end of a file\). | |
208 3. Indentation space \(8 or more spaces, that should be replaced with TABS\). | |
209 4. Spaces followed by a TAB. \(Almost always, we never want that\). | |
210 5. Spaces or TABS at the end of a line. | |
211 | |
212 Check for whitespace only if this buffer really contains a non-empty file | |
213 and: | |
214 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
|
215 2. `whitespace-buffer' was explicitly called with a prefix argument." |
25582 | 216 (interactive) |
26245
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
217 (let ((whitespace-error nil)) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
218 (whitespace-check-whitespace-mode current-prefix-arg) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
219 (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
|
220 (progn |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
221 (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
|
222 (whitespace-tickle-timer) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
223 (if whitespace-auto-cleanup |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
224 (if buffer-read-only |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
225 (if (not quiet) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
226 (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
|
227 (whitespace-cleanup)) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
228 (let ((whitespace-leading (if whitespace-check-leading-whitespace |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
229 (whitespace-buffer-leading) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
230 nil)) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
231 (whitespace-trailing (if whitespace-check-trailing-whitespace |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
232 (whitespace-buffer-trailing) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
233 nil)) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
234 (whitespace-indent (if whitespace-check-indent-whitespace |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
235 (whitespace-buffer-search |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
236 whitespace-indent-regexp) |
25724
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
237 nil)) |
26245
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
238 (whitespace-spacetab (if whitespace-check-spacetab-whitespace |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
239 (whitespace-buffer-search |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
240 whitespace-spacetab-regexp) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
241 nil)) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
242 (whitespace-ateol (if whitespace-check-ateol-whitespace |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
243 (whitespace-buffer-search |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
244 whitespace-ateol-regexp) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
245 nil)) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
246 (whitespace-errmsg nil) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
247 (whitespace-filename buffer-file-name) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
248 (whitespace-this-modeline "")) |
25582 | 249 |
26245
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
250 ;; 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
|
251 (setq whitespace-error (or whitespace-leading whitespace-indent |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
252 whitespace-spacetab whitespace-ateol |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
253 whitespace-trailing)) |
25582 | 254 |
26245
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
255 (if whitespace-error |
25582 | 256 (progn |
26245
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
257 (setq whitespace-errmsg |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
258 (concat whitespace-filename " contains:\n" |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
259 (if whitespace-leading |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
260 "Leading whitespace\n") |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
261 (if whitespace-indent |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
262 (concat "Indentation whitespace" |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
263 whitespace-indent "\n")) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
264 (if whitespace-spacetab |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
265 (concat "Space followed by Tab" |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
266 whitespace-spacetab "\n")) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
267 (if whitespace-ateol |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
268 (concat "End-of-line whitespace" |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
269 whitespace-ateol "\n")) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
270 (if whitespace-trailing |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
271 "Trailing whitespace\n") |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
272 "\ntype `M-x whitespace-cleanup' to " |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
273 "cleanup the file.")) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
274 (setq whitespace-this-modeline |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
275 (concat (if whitespace-ateol "e") |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
276 (if whitespace-indent "i") |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
277 (if whitespace-leading "l") |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
278 (if whitespace-spacetab "s") |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
279 (if whitespace-trailing "t"))))) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
280 (whitespace-update-modeline whitespace-this-modeline) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
281 (save-excursion |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
282 (get-buffer-create whitespace-errbuf) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
283 (kill-buffer whitespace-errbuf) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
284 (get-buffer-create whitespace-errbuf) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
285 (set-buffer whitespace-errbuf) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
286 (if whitespace-errmsg |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
287 (progn |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
288 (insert whitespace-errmsg) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
289 (if (not (or quiet whitespace-silent)) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
290 (display-buffer whitespace-errbuf t)) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
291 (if (not quiet) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
292 (message "Whitespaces: [%s%s] in %s" |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
293 whitespace-this-modeline |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
294 (let ((whitespace-unchecked |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
295 (whitespace-unchecked-whitespaces))) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
296 (if whitespace-unchecked |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
297 (concat "!" whitespace-unchecked) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
298 "")) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
299 whitespace-filename))) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
300 (if (not quiet) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
301 (message "%s clean" whitespace-filename)))))))) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
302 (if whitespace-error |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
303 t |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
304 nil))) |
25582 | 305 |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
306 ;;;###autoload |
25582 | 307 (defun whitespace-region (s e) |
32501 | 308 "Check the region for whitespace errors." |
25582 | 309 (interactive "r") |
310 (save-excursion | |
311 (save-restriction | |
312 (narrow-to-region s e) | |
313 (whitespace-buffer)))) | |
314 | |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
315 ;;;###autoload |
25582 | 316 (defun whitespace-cleanup () |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
317 "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
|
318 |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
319 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
|
320 whitespace problems." |
25582 | 321 (interactive) |
322 ;; If this buffer really contains a file, then run, else quit. | |
323 (whitespace-check-whitespace-mode current-prefix-arg) | |
324 (if (and buffer-file-name whitespace-mode) | |
325 (let ((whitespace-any nil) | |
326 (whitespace-tabwith 8) | |
327 (whitespace-tabwith-saved tab-width)) | |
328 | |
329 ;; since all printable TABS should be 8, irrespective of how | |
330 ;; they are displayed. | |
331 (setq tab-width whitespace-tabwith) | |
332 | |
25724
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
333 (if (and whitespace-check-leading-whitespace |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
334 (whitespace-buffer-leading)) |
25582 | 335 (progn |
336 (whitespace-buffer-leading-cleanup) | |
337 (setq whitespace-any t))) | |
338 | |
25724
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
339 (if (and whitespace-check-trailing-whitespace |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
340 (whitespace-buffer-trailing)) |
25582 | 341 (progn |
342 (whitespace-buffer-trailing-cleanup) | |
343 (setq whitespace-any t))) | |
344 | |
25724
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
345 (if (and whitespace-check-indent-whitespace |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
346 (whitespace-buffer-search whitespace-indent-regexp)) |
25582 | 347 (progn |
348 (whitespace-indent-cleanup) | |
349 (setq whitespace-any t))) | |
350 | |
25724
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
351 (if (and whitespace-check-spacetab-whitespace |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
352 (whitespace-buffer-search whitespace-spacetab-regexp)) |
25582 | 353 (progn |
354 (whitespace-buffer-cleanup whitespace-spacetab-regexp "\t") | |
355 (setq whitespace-any t))) | |
356 | |
25724
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
357 (if (and whitespace-check-ateol-whitespace |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
358 (whitespace-buffer-search whitespace-ateol-regexp)) |
25582 | 359 (progn |
360 (whitespace-buffer-cleanup whitespace-ateol-regexp "") | |
361 (setq whitespace-any t))) | |
362 | |
363 ;; 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
|
364 (if whitespace-any |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
365 (whitespace-cleanup) |
25582 | 366 (progn |
367 (message "%s clean" buffer-file-name) | |
26245
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
368 (whitespace-update-modeline))) |
25582 | 369 (setq tab-width whitespace-tabwith-saved)))) |
370 | |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
371 ;;;###autoload |
25582 | 372 (defun whitespace-cleanup-region (s e) |
32501 | 373 "Whitespace cleanup on the region." |
25582 | 374 (interactive "r") |
375 (save-excursion | |
376 (save-restriction | |
377 (narrow-to-region s e) | |
378 (whitespace-cleanup)) | |
379 (whitespace-buffer t))) | |
380 | |
381 (defun whitespace-buffer-leading () | |
382 "Check to see if there are any empty lines at the top of the file." | |
383 (save-excursion | |
384 (let ((pmin nil) | |
385 (pmax nil)) | |
386 (goto-char (point-min)) | |
387 (beginning-of-line) | |
388 (setq pmin (point)) | |
389 (end-of-line) | |
390 (setq pmax (point)) | |
391 (if (equal pmin pmax) | |
392 t | |
393 nil)))) | |
394 | |
395 (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
|
396 "Remove any empty lines at the top of the file." |
25582 | 397 (save-excursion |
398 (let ((pmin nil) | |
399 (pmax nil)) | |
400 (goto-char (point-min)) | |
401 (beginning-of-line) | |
402 (setq pmin (point)) | |
403 (end-of-line) | |
404 (setq pmax (point)) | |
405 (if (equal pmin pmax) | |
406 (progn | |
407 (kill-line) | |
408 (whitespace-buffer-leading-cleanup)))))) | |
409 | |
410 (defun whitespace-buffer-trailing () | |
411 "Check to see if are is more than one empty line at the bottom." | |
412 (save-excursion | |
413 (let ((pmin nil) | |
414 (pmax nil)) | |
415 (goto-char (point-max)) | |
416 (beginning-of-line) | |
417 (setq pmin (point)) | |
418 (end-of-line) | |
419 (setq pmax (point)) | |
420 (if (equal pmin pmax) | |
421 (progn | |
422 (goto-char (- (point) 1)) | |
423 (beginning-of-line) | |
424 (setq pmin (point)) | |
425 (end-of-line) | |
426 (setq pmax (point)) | |
427 (if (equal pmin pmax) | |
428 t | |
429 nil)) | |
430 nil)))) | |
431 | |
432 (defun whitespace-buffer-trailing-cleanup () | |
433 "Delete all the empty lines at the bottom." | |
434 (save-excursion | |
435 (let ((pmin nil) | |
436 (pmax nil)) | |
437 (goto-char (point-max)) | |
438 (beginning-of-line) | |
439 (setq pmin (point)) | |
440 (end-of-line) | |
441 (setq pmax (point)) | |
442 (if (equal pmin pmax) | |
443 (progn | |
444 (goto-char (1- pmin)) | |
445 (beginning-of-line) | |
446 (setq pmin (point)) | |
447 (end-of-line) | |
448 (setq pmax (point)) | |
449 (if (equal pmin pmax) | |
450 (progn | |
451 (goto-char (1- (point-max))) | |
452 (beginning-of-line) | |
453 (kill-line) | |
454 (whitespace-buffer-trailing-cleanup)))))))) | |
455 | |
456 (defun whitespace-buffer-search (regexp) | |
457 "Search for any given whitespace REGEXP." | |
458 (let ((whitespace-retval "")) | |
459 (save-excursion | |
460 (goto-char (point-min)) | |
461 (while (re-search-forward regexp nil t) | |
462 (setq whitespace-retval (format "%s %s " whitespace-retval | |
463 (match-beginning 0)))) | |
464 (if (equal "" whitespace-retval) | |
465 nil | |
466 whitespace-retval)))) | |
467 | |
468 (defun whitespace-buffer-cleanup (regexp newregexp) | |
469 "Search for any given whitespace REGEXP and replace it with the NEWREGEXP." | |
470 (save-excursion | |
471 (goto-char (point-min)) | |
472 (while (re-search-forward regexp nil t) | |
473 (replace-match newregexp)))) | |
474 | |
475 (defun whitespace-indent-cleanup () | |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
476 "Search for 8/more spaces at the start of a line and replace it with tabs." |
25582 | 477 (save-excursion |
478 (goto-char (point-min)) | |
479 (while (re-search-forward whitespace-indent-regexp nil t) | |
480 (let ((column (current-column)) | |
481 (indent-tabs-mode t)) | |
482 (delete-region (match-beginning 0) (point)) | |
483 (indent-to column))))) | |
484 | |
26245
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
485 (defun whitespace-unchecked-whitespaces () |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
486 "Return the list of whitespaces whose testing has been suppressed." |
25724
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
487 (let ((whitespace-this-modeline |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
488 (concat (if (not whitespace-check-ateol-whitespace) "e") |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
489 (if (not whitespace-check-indent-whitespace) "i") |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
490 (if (not whitespace-check-leading-whitespace) "l") |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
491 (if (not whitespace-check-spacetab-whitespace) "s") |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
492 (if (not whitespace-check-trailing-whitespace) "t")))) |
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
493 (if (not (equal whitespace-this-modeline "")) |
26245
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
494 whitespace-this-modeline |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
495 nil))) |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
496 |
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
497 (defun whitespace-update-modeline (&optional whitespace-err) |
32501 | 498 "Update modeline with whitespace errors. |
499 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
|
500 (if whitespace-display-in-modeline |
26259
912b004387d9
(whitespace-update-modeline): Bugfix to ensure
Gerd Moellmann <gerd@gnu.org>
parents:
26253
diff
changeset
|
501 (progn |
912b004387d9
(whitespace-update-modeline): Bugfix to ensure
Gerd Moellmann <gerd@gnu.org>
parents:
26253
diff
changeset
|
502 (setq whitespace-mode-line nil) |
912b004387d9
(whitespace-update-modeline): Bugfix to ensure
Gerd Moellmann <gerd@gnu.org>
parents:
26253
diff
changeset
|
503 ;; Whitespace errors |
912b004387d9
(whitespace-update-modeline): Bugfix to ensure
Gerd Moellmann <gerd@gnu.org>
parents:
26253
diff
changeset
|
504 (if (and whitespace-err (not (equal whitespace-err ""))) |
912b004387d9
(whitespace-update-modeline): Bugfix to ensure
Gerd Moellmann <gerd@gnu.org>
parents:
26253
diff
changeset
|
505 (setq whitespace-mode-line whitespace-err)) |
912b004387d9
(whitespace-update-modeline): Bugfix to ensure
Gerd Moellmann <gerd@gnu.org>
parents:
26253
diff
changeset
|
506 ;; Whitespace suppressed errors |
912b004387d9
(whitespace-update-modeline): Bugfix to ensure
Gerd Moellmann <gerd@gnu.org>
parents:
26253
diff
changeset
|
507 (let ((whitespace-unchecked (whitespace-unchecked-whitespaces))) |
912b004387d9
(whitespace-update-modeline): Bugfix to ensure
Gerd Moellmann <gerd@gnu.org>
parents:
26253
diff
changeset
|
508 (if whitespace-unchecked |
912b004387d9
(whitespace-update-modeline): Bugfix to ensure
Gerd Moellmann <gerd@gnu.org>
parents:
26253
diff
changeset
|
509 (setq whitespace-mode-line |
912b004387d9
(whitespace-update-modeline): Bugfix to ensure
Gerd Moellmann <gerd@gnu.org>
parents:
26253
diff
changeset
|
510 (concat whitespace-mode-line "!" whitespace-unchecked)))) |
912b004387d9
(whitespace-update-modeline): Bugfix to ensure
Gerd Moellmann <gerd@gnu.org>
parents:
26253
diff
changeset
|
511 ;; Add the whitespace modeline prefix |
912b004387d9
(whitespace-update-modeline): Bugfix to ensure
Gerd Moellmann <gerd@gnu.org>
parents:
26253
diff
changeset
|
512 (setq whitespace-mode-line (if whitespace-mode-line |
912b004387d9
(whitespace-update-modeline): Bugfix to ensure
Gerd Moellmann <gerd@gnu.org>
parents:
26253
diff
changeset
|
513 (concat " W:" whitespace-mode-line) |
912b004387d9
(whitespace-update-modeline): Bugfix to ensure
Gerd Moellmann <gerd@gnu.org>
parents:
26253
diff
changeset
|
514 nil)) |
912b004387d9
(whitespace-update-modeline): Bugfix to ensure
Gerd Moellmann <gerd@gnu.org>
parents:
26253
diff
changeset
|
515 (whitespace-force-mode-line-update)))) |
25724
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
516 |
25582 | 517 ;; Force mode line updation for different Emacs versions |
518 (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
|
519 "Force the mode line update for different flavors of Emacs." |
32501 | 520 (if (fboundp 'redraw-modeline) |
521 (redraw-modeline) ; XEmacs | |
522 (force-mode-line-update))) ; Emacs | |
25582 | 523 |
524 (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
|
525 "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
|
526 |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
527 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
|
528 periodically for whitespace." |
25582 | 529 (if (and whitespace-mode (not (member (list buf-file buf-name) |
530 whitespace-all-buffer-files))) | |
531 (add-to-list 'whitespace-all-buffer-files (list buf-file buf-name)))) | |
532 | |
533 (defun whitespace-tickle-timer () | |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
534 "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
|
535 |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
536 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
|
537 `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
|
538 `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
|
539 (if (and whitespace-rescan-timer-time (not whitespace-rescan-timer)) |
25582 | 540 (setq whitespace-rescan-timer |
32501 | 541 (add-timeout whitespace-rescan-timer-time |
542 'whitespace-rescan-files-in-buffers nil | |
543 whitespace-rescan-timer-time)))) | |
25582 | 544 |
545 (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
|
546 "Check monitored files for whitespace creep since last scan." |
25582 | 547 (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
|
548 buffile bufname thiselt buf) |
25582 | 549 (if (not whitespace-all-my-files) |
550 (progn | |
32501 | 551 (disable-timeout whitespace-rescan-timer) |
25582 | 552 (setq whitespace-rescan-timer nil)) |
553 (while whitespace-all-my-files | |
554 (setq thiselt (car whitespace-all-my-files)) | |
555 (setq whitespace-all-my-files (cdr whitespace-all-my-files)) | |
556 (setq buffile (car thiselt)) | |
557 (setq bufname (cadr thiselt)) | |
558 (setq buf (get-buffer bufname)) | |
559 (if (buffer-live-p buf) | |
560 (save-excursion | |
561 ;;(message "buffer %s live" bufname) | |
562 (set-buffer bufname) | |
563 (if whitespace-mode | |
564 (progn | |
565 ;;(message "checking for whitespace in %s" bufname) | |
566 (if whitespace-auto-cleanup | |
567 (progn | |
568 ;;(message "cleaning up whitespace in %s" bufname) | |
569 (whitespace-cleanup)) | |
570 (progn | |
571 ;;(message "whitespace-buffer %s." (buffer-name)) | |
572 (whitespace-buffer t)))) | |
573 ;;(message "Removing %s from refresh list" bufname) | |
574 (whitespace-refresh-rescan-list buffile bufname))) | |
575 ;;(message "Removing %s from refresh list" bufname) | |
576 (whitespace-refresh-rescan-list buffile bufname)))))) | |
577 | |
578 (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
|
579 "Refresh the list of files to be rescaned for whitespace creep." |
25582 | 580 (if whitespace-all-buffer-files |
32501 | 581 (setq whitespace-all-buffer-files |
582 (delete (list buffile bufname) whitespace-all-buffer-files)) | |
583 (when whitespace-rescan-timer | |
584 (disable-timeout whitespace-rescan-timer) | |
585 (setq whitespace-rescan-timer nil)))) | |
586 | |
587 ;;;###autoload | |
588 (defcustom whitespace-global-mode nil | |
589 "Toggle global Whitespace mode. | |
590 | |
591 Setting this variable directly does not take effect; | |
592 use either \\[customize] or the function `whitespace-global-mode' | |
593 \(which see)." | |
594 :set (lambda (sym val) | |
595 (whitespace-global-mode (or value 0))) | |
596 :initialize 'custom-initialize-default | |
597 :type 'boolean | |
598 :group 'whitespace | |
599 :require 'whitespace) | |
600 | |
601 (defun whitespace-global-mode (&optional arg) | |
602 "Toggle using Whitespace mode in new buffers. | |
603 With ARG, turn the mode on if and only iff ARG is positive. | |
604 | |
605 When this mode is active, `whitespace-buffer' is added to | |
606 `find-file-hooks' and `kill-buffer-hook'." | |
607 (interactive "P") | |
608 (setq arg (if arg | |
609 (> (prefix-numeric-value arg) 0) | |
610 (not whitespace-global-mode))) | |
611 (if arg | |
25582 | 612 (progn |
32501 | 613 (add-hook 'find-file-hooks 'whitespace-buffer) |
614 (add-hook 'kill-buffer-hook 'whitespace-buffer)) | |
615 (remove-hook 'find-file-hooks 'whitespace-buffer) | |
616 (remove-hook 'kill-buffer-hook 'whitespace-buffer))) | |
25582 | 617 |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
618 ;;;###autoload |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
619 (defun whitespace-describe () |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
620 "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
|
621 |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
622 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
|
623 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
|
624 |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
625 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
|
626 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
|
627 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
|
628 replaced with TABS). |
32501 | 629 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
|
630 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
|
631 |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
632 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
|
633 |
26245
2dbd5efce8ee
(whitespace-version): Update to 2.6
Gerd Moellmann <gerd@gnu.org>
parents:
25732
diff
changeset
|
634 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
|
635 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
|
636 |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
637 e - End-of-Line whitespace. |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
638 i - Indentation whitespace. |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
639 l - Leading whitespace. |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
640 s - Space followed by Tab. |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
641 t - Trailing whitespace. |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
642 |
25724
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
643 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
|
644 !<y>. |
25724
6664d8f25ea5
(whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents:
25625
diff
changeset
|
645 |
25625
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
646 (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
|
647 terminal drivers and printer drivers have TAB configured or even |
32501 | 648 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
|
649 always they default to 8.) |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
650 |
32501 | 651 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
|
652 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
|
653 even print it. |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
654 |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
655 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
|
656 c-basic-offset or perl-indent-level) to configure the offset, so you |
32501 | 657 should never have to set your `tab-width' to be other than 8 in all these |
658 modes. In fact, with an indent level of say, 4, 2 TABS will cause Emacs | |
659 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
|
660 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
|
661 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
|
662 to set smarttab.) |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
663 |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
664 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
|
665 merge problems. |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
666 |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
667 whitespace.el will complain if it detects whitespaces on opening a file, and |
32501 | 668 warn you on closing a file also (in case you had inserted any |
669 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
|
670 (interactive) |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
671 (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
|
672 whitespace-version)) |
c0e27d3ce645
Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents:
25582
diff
changeset
|
673 |
32501 | 674 (defun whitespace-unload-hook () |
675 (remove-hook 'find-file-hooks 'whitespace-buffer) | |
676 (remove-hook 'kill-buffer-hook 'whitespace-buffer)) | |
677 | |
25582 | 678 (provide 'whitespace) |
679 | |
680 ;;; whitespace.el ends here |