annotate lisp/whitespace.el @ 25732:5e14fd494b83

(whitespace-mode, whitespace-mode-line): Add defvars.
author Richard M. Stallman <rms@gnu.org>
date Wed, 15 Sep 1999 23:46:29 +0000
parents 6664d8f25ea5
children 2dbd5efce8ee
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
25582
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
1 ;;; whitespace.el --- Warn about and clean bogus whitespaces in the file.
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
2
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
3 ;; Copyright (C) 1999 Free Software Foundation, Inc.
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
4
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
5 ;; Author: Rajesh Vaidheeswarran <rv@dsmit.com>
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
6 ;; Keywords: convenience
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
7
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
9
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
13 ;; any later version.
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
14
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
18 ;; GNU General Public License for more details.
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
19
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
23 ;; Boston, MA 02111-1307, USA.
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
24
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
25 ;;; Commentary:
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
26
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
27 ;; Whitespace.el URL: http://www.dsmit.com/lisp/
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
28
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
29 ;; Exported functions:
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
30
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
31 ;; `whitespace-buffer' - To check the current buffer for whitespace problems.
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
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
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
38
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
39 ;;; Code:
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
40
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
41 ;; add a hook to find-file-hooks and kill-buffer-hook
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
42 (add-hook 'find-file-hooks 'whitespace-buffer)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
43 (add-hook 'kill-buffer-hook 'whitespace-buffer)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
44
25625
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
45 (defvar whitespace-version "2.3" "Version of the whitespace library.")
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
46 ;; Find out what type of Emacs we are running in.
25582
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
47 (defvar whitespace-running-emacs (if (string-match "XEmacs\\|Lucid"
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
48 emacs-version) nil t)
25625
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
49 "If this is Emacs, not XEmacs, this is t.")
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
50
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
51 (if whitespace-running-emacs (require 'timer))
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
52
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
53 (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
54 "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
55
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
56 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
57 visited by the buffers.")
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
58
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
59 (defvar whitespace-rescan-timer nil
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
60 "Timer object used to rescan the files in buffers that have been modified.")
25582
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
61
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
62 ;; For users of Emacs 19.x, defgroup and defcustom are not defined.
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
63
25625
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
64 (eval-when-compile
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
65 (if (< (string-to-int emacs-version) 20)
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
66 (progn
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
67 (defmacro defgroup (sym memb doc &rest args)
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
68 "Null macro for defgroup in all versions of Emacs < 20.x"
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
69 t)
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
70 (defmacro defcustom (sym val doc &rest args)
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
71 "Macro to alias defcustom to defvar in all versions of Emacs < 20.x"
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
72 `(defvar ,sym ,val ,doc)))))
25582
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
73
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
74 (defgroup whitespace nil
25625
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
75 "Check for and fix five different types of whitespaces in source code."
25582
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
76 ;; Since XEmacs doesn't have a 'convenience group, use the next best group
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
77 ;; which is 'editing?
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
78 :group (if whitespace-running-emacs 'convenience 'editing))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
79
25724
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
80 (defcustom whitespace-check-leading-whitespace t
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
81 "Flag to check leading whitespace."
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
82 :type 'boolean
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
83 :group 'whitespace)
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
84
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
85 (defcustom whitespace-check-trailing-whitespace t
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
86 "Flag to check trailing whitespace."
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
87 :type 'boolean
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
88 :group 'whitespace)
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
89
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
90 (defcustom whitespace-check-spacetab-whitespace t
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
91 "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
92 :type 'boolean
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
93 :group 'whitespace)
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
94
25625
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
95 (defcustom whitespace-spacetab-regexp " \t"
25724
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
96 "Regexp to match a space followed by a TAB."
25625
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
97 :type 'string
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
98 :group 'whitespace)
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
99
25724
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
100 (defcustom whitespace-check-indent-whitespace t
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
101 "Flag to check indentation whitespace."
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
102 :type 'boolean
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
103 :group 'whitespace)
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
104
25625
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
105 (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
106 "Regexp to match (any TABS followed by) 8/more whitespaces at start of line."
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
107 :type 'string
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
108 :group 'whitespace)
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
109
25724
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
110 (defcustom whitespace-check-ateol-whitespace t
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
111 "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
112 :type 'boolean
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
113 :group 'whitespace)
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
114
25625
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
115 (defcustom whitespace-ateol-regexp "[ \t]$"
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
116 "Regexp to match a TAB or a space at the EOL."
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
117 :type 'string
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
118 :group 'whitespace)
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
119
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
120 (defcustom whitespace-errbuf "*Whitespace Errors*"
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
121 "The buffer where whitespace related messages will be logged."
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
122 :type 'string
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
123 :group 'whitespace)
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
124
25582
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
125 (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
126 "Cleanup a buffer automatically on finding it whitespace unclean."
25582
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
127 :type 'boolean
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
128 :group 'whitespace)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
129
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
130 (defcustom whitespace-silent nil
25625
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
131 "All whitespace errors will be shown only in the modeline when t.
25582
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
132
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
133 Note that setting this may cause all whitespaces introduced in a file to go
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
134 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
135 Errors*' buffer before opening (or closing) another file."
25582
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
136 :type 'boolean
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
137 :group 'whitespace)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
138
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
139 (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
140 c-mode c++-mode cc-mode
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
141 change-log-mode cperl-mode
25582
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
142 electric-nroff-mode emacs-lisp-mode
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
143 f90-mode fortran-mode html-mode
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
144 html3-mode java-mode jde-mode
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
145 ksh-mode latex-mode LaTeX-mode
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
146 lisp-mode m4-mode makefile-mode
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
147 modula-2-mode nroff-mode objc-mode
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
148 pascal-mode perl-mode prolog-mode
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
149 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
150 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
151 tcl-mode tex-mode texinfo-mode
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
152 vrml-mode xml-mode)
25582
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
153
25625
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
154 "Major Modes in which we turn on whitespace checking.
25582
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
155
25625
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
156 These are mostly programming and documentation modes. But you may add other
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
157 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
158 following to your `.emacs':
25582
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
159
25625
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
160 \(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
161 whitespace-modes))\)
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 Or, alternately, you can use the Emacs `customize' command to set this."
25582
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
164 :group 'whitespace)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
165
25625
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
166 (defcustom whitespace-rescan-timer-time 60
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
167 "Period in seconds to rescan modified buffers for whitespace creep.
25582
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
168
25625
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
169 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
170 `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
171 modified buffers.
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
172
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
173 To disable timer scans, set this to zero."
25582
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
174 :type 'integer
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
175 :group 'whitespace)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
176
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
177 ;; Tell Emacs about this new kind of minor mode
25732
5e14fd494b83 (whitespace-mode, whitespace-mode-line): Add defvars.
Richard M. Stallman <rms@gnu.org>
parents: 25724
diff changeset
178 (defvar whitespace-mode nil
5e14fd494b83 (whitespace-mode, whitespace-mode-line): Add defvars.
Richard M. Stallman <rms@gnu.org>
parents: 25724
diff changeset
179 "Non-nil when Whitespace mode (a minor mode) is enabled.")
25582
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
180 (make-variable-buffer-local 'whitespace-mode)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
181 (put 'whitespace-mode 'permanent-local nil)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
182
25732
5e14fd494b83 (whitespace-mode, whitespace-mode-line): Add defvars.
Richard M. Stallman <rms@gnu.org>
parents: 25724
diff changeset
183 (defvar whitespace-mode-line nil
5e14fd494b83 (whitespace-mode, whitespace-mode-line): Add defvars.
Richard M. Stallman <rms@gnu.org>
parents: 25724
diff changeset
184 "String to display in the mode line for Whitespace mode.")
25582
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
185 (make-variable-buffer-local 'whitespace-mode-line)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
186 (put 'whitespace-mode-line 'permanent-local nil)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
187
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
188 (if (not (assoc 'whitespace-mode minor-mode-alist))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
189 (setq minor-mode-alist (cons '(whitespace-mode whitespace-mode-line)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
190 minor-mode-alist)))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
191
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
192 (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
193 "Test and set the whitespace-mode in qualifying buffers."
25582
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
194 (if (null whitespace-mode)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
195 (setq whitespace-mode
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
196 (if (or arg (member major-mode whitespace-modes))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
197 t
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
198 nil))))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
199
25625
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
200 ;;;###autoload
25582
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
201 (defun whitespace-buffer (&optional quiet)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
202 "Find five different types of white spaces in buffer:
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
203
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
204 1. Leading space \(empty lines at the top of a file\).
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
205 2. Trailing space \(empty lines at the end of a file\).
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
206 3. Indentation space \(8 or more spaces, that should be replaced with TABS\).
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
207 4. Spaces followed by a TAB. \(Almost always, we never want that\).
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
208 5. Spaces or TABS at the end of a line.
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
209
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
210 Check for whitespace only if this buffer really contains a non-empty file
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
211 and:
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
212 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
213 2. `whitespace-buffer' was explicitly called with a prefix argument."
25582
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
214 (interactive)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
215 (whitespace-check-whitespace-mode current-prefix-arg)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
216 (if (and buffer-file-name (> (buffer-size) 0) whitespace-mode)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
217 (progn
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
218 (whitespace-check-buffer-list (buffer-name) buffer-file-name)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
219 (whitespace-tickle-timer)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
220 (if whitespace-auto-cleanup
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
221 (if (and (not quiet) buffer-read-only)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
222 (message "Can't Cleanup: %s is read-only." (buffer-name))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
223 (whitespace-cleanup))
25724
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
224 (let ((whitespace-leading (if whitespace-check-leading-whitespace
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
225 (whitespace-buffer-leading)
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
226 nil))
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
227 (whitespace-trailing (if whitespace-check-trailing-whitespace
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
228 (whitespace-buffer-trailing)
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
229 nil))
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
230 (whitespace-indent (if whitespace-check-indent-whitespace
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
231 (whitespace-buffer-search
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
232 whitespace-indent-regexp)
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
233 nil))
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
234 (whitespace-spacetab (if whitespace-check-spacetab-whitespace
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
235 (whitespace-buffer-search
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
236 whitespace-spacetab-regexp)
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
237 nil))
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
238 (whitespace-ateol (if whitespace-check-ateol-whitespace
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
239 (whitespace-buffer-search
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
240 whitespace-ateol-regexp)
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
241 nil))
25582
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
242 (whitespace-errmsg nil)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
243 (whitespace-error nil)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
244 (whitespace-filename buffer-file-name)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
245 (whitespace-this-modeline ""))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
246
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
247 ;; Now let's complain if we found any of the above.
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
248 (setq whitespace-error (or whitespace-leading whitespace-indent
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
249 whitespace-spacetab whitespace-ateol
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
250 whitespace-trailing))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
251
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
252 (if whitespace-error
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
253 (progn
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
254 (setq whitespace-errmsg
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
255 (concat whitespace-filename " contains:\n"
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
256 (if whitespace-leading "Leading whitespace\n")
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
257 (if whitespace-indent
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
258 (concat "Indentation whitespace"
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
259 whitespace-indent "\n"))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
260 (if whitespace-spacetab
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
261 (concat "Space followed by Tab"
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
262 whitespace-spacetab "\n"))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
263 (if whitespace-ateol
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
264 (concat "End-of-line whitespace"
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
265 whitespace-ateol "\n"))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
266 (if whitespace-trailing
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
267 "Trailing whitespace.\n")
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
268 "\ntype "
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
269 "`whitespace-cleanup' to cleanup the file."))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
270 (setq whitespace-this-modeline
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
271 (concat (if whitespace-ateol "e")
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
272 (if whitespace-indent "i")
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
273 (if whitespace-leading "l")
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
274 (if whitespace-spacetab "s")
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
275 (if whitespace-trailing "t")))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
276 (setq whitespace-mode-line
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
277 (concat " W:" whitespace-this-modeline))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
278 (whitespace-force-mode-line-update)))
25724
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
279
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
280 ;; Now test and set the whitespaces that are not checked.
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
281 (whitespace-display-unchecked-whitespaces
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
282 (if whitespace-error
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
283 (concat " W:" whitespace-this-modeline)))
25582
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
284 (save-excursion
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
285 (get-buffer-create whitespace-errbuf)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
286 (kill-buffer whitespace-errbuf)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
287 (get-buffer-create whitespace-errbuf)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
288 (set-buffer whitespace-errbuf)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
289 (if whitespace-errmsg
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
290 (progn
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
291 (insert whitespace-errmsg)
25625
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
292 (if (not (or quiet whitespace-silent))
25582
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
293 (display-buffer whitespace-errbuf t))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
294 (if (not quiet)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
295 (message "Whitespaces: [%s] in %s"
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
296 whitespace-this-modeline
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
297 whitespace-filename)))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
298 (if (not quiet)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
299 (message "%s clean" whitespace-filename)))))))))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
300
25625
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
301 ;;;###autoload
25582
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
302 (defun whitespace-region (s e)
25625
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
303 "Check a region specified by point and mark for whitespace errors."
25582
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
304 (interactive "r")
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
305 (save-excursion
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
306 (save-restriction
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
307 (narrow-to-region s e)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
308 (whitespace-buffer))))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
309
25625
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
310 ;;;###autoload
25582
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
311 (defun whitespace-cleanup ()
25625
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
312 "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
313
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
314 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
315 whitespace problems."
25582
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
316 (interactive)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
317 ;; If this buffer really contains a file, then run, else quit.
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
318 (whitespace-check-whitespace-mode current-prefix-arg)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
319 (if (and buffer-file-name whitespace-mode)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
320 (let ((whitespace-any nil)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
321 (whitespace-tabwith 8)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
322 (whitespace-tabwith-saved tab-width))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
323
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
324 ;; since all printable TABS should be 8, irrespective of how
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
325 ;; they are displayed.
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
326 (setq tab-width whitespace-tabwith)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
327
25724
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
328 (if (and whitespace-check-leading-whitespace
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
329 (whitespace-buffer-leading))
25582
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
330 (progn
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
331 (whitespace-buffer-leading-cleanup)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
332 (setq whitespace-any t)))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
333
25724
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
334 (if (and whitespace-check-trailing-whitespace
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
335 (whitespace-buffer-trailing))
25582
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
336 (progn
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
337 (whitespace-buffer-trailing-cleanup)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
338 (setq whitespace-any t)))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
339
25724
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
340 (if (and whitespace-check-indent-whitespace
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
341 (whitespace-buffer-search whitespace-indent-regexp))
25582
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
342 (progn
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
343 (whitespace-indent-cleanup)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
344 (setq whitespace-any t)))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
345
25724
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
346 (if (and whitespace-check-spacetab-whitespace
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
347 (whitespace-buffer-search whitespace-spacetab-regexp))
25582
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
348 (progn
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
349 (whitespace-buffer-cleanup whitespace-spacetab-regexp "\t")
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
350 (setq whitespace-any t)))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
351
25724
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
352 (if (and whitespace-check-ateol-whitespace
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
353 (whitespace-buffer-search whitespace-ateol-regexp))
25582
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
354 (progn
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
355 (whitespace-buffer-cleanup whitespace-ateol-regexp "")
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
356 (setq whitespace-any t)))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
357
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
358 ;; 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
359 (if whitespace-any
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
360 (whitespace-cleanup)
25582
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
361 (progn
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
362 (message "%s clean" buffer-file-name)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
363 (setq whitespace-mode-line nil)
25724
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
364 (whitespace-force-mode-line-update)
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
365 (whitespace-display-unchecked-whitespaces)))
25582
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
366 (setq tab-width whitespace-tabwith-saved))))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
367
25625
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
368 ;;;###autoload
25582
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
369 (defun whitespace-cleanup-region (s e)
25625
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
370 "Whitespace cleanup on a region specified by point and mark."
25582
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
371 (interactive "r")
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
372 (save-excursion
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
373 (save-restriction
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
374 (narrow-to-region s e)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
375 (whitespace-cleanup))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
376 (whitespace-buffer t)))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
377
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
378 (defun whitespace-buffer-leading ()
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
379 "Check to see if there are any empty lines at the top of the file."
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
380 (save-excursion
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
381 (let ((pmin nil)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
382 (pmax nil))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
383 (goto-char (point-min))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
384 (beginning-of-line)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
385 (setq pmin (point))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
386 (end-of-line)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
387 (setq pmax (point))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
388 (if (equal pmin pmax)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
389 t
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
390 nil))))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
391
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
392 (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
393 "Remove any empty lines at the top of the file."
25582
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
394 (save-excursion
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
395 (let ((pmin nil)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
396 (pmax nil))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
397 (goto-char (point-min))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
398 (beginning-of-line)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
399 (setq pmin (point))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
400 (end-of-line)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
401 (setq pmax (point))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
402 (if (equal pmin pmax)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
403 (progn
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
404 (kill-line)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
405 (whitespace-buffer-leading-cleanup))))))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
406
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
407 (defun whitespace-buffer-trailing ()
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
408 "Check to see if are is more than one empty line at the bottom."
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
409 (save-excursion
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
410 (let ((pmin nil)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
411 (pmax nil))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
412 (goto-char (point-max))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
413 (beginning-of-line)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
414 (setq pmin (point))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
415 (end-of-line)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
416 (setq pmax (point))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
417 (if (equal pmin pmax)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
418 (progn
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
419 (goto-char (- (point) 1))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
420 (beginning-of-line)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
421 (setq pmin (point))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
422 (end-of-line)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
423 (setq pmax (point))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
424 (if (equal pmin pmax)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
425 t
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
426 nil))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
427 nil))))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
428
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
429 (defun whitespace-buffer-trailing-cleanup ()
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
430 "Delete all the empty lines at the bottom."
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
431 (save-excursion
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
432 (let ((pmin nil)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
433 (pmax nil))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
434 (goto-char (point-max))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
435 (beginning-of-line)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
436 (setq pmin (point))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
437 (end-of-line)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
438 (setq pmax (point))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
439 (if (equal pmin pmax)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
440 (progn
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
441 (goto-char (1- pmin))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
442 (beginning-of-line)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
443 (setq pmin (point))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
444 (end-of-line)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
445 (setq pmax (point))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
446 (if (equal pmin pmax)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
447 (progn
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
448 (goto-char (1- (point-max)))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
449 (beginning-of-line)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
450 (kill-line)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
451 (whitespace-buffer-trailing-cleanup))))))))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
452
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
453 (defun whitespace-buffer-search (regexp)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
454 "Search for any given whitespace REGEXP."
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
455 (let ((whitespace-retval ""))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
456 (save-excursion
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
457 (goto-char (point-min))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
458 (while (re-search-forward regexp nil t)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
459 (setq whitespace-retval (format "%s %s " whitespace-retval
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
460 (match-beginning 0))))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
461 (if (equal "" whitespace-retval)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
462 nil
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
463 whitespace-retval))))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
464
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
465 (defun whitespace-buffer-cleanup (regexp newregexp)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
466 "Search for any given whitespace REGEXP and replace it with the NEWREGEXP."
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
467 (save-excursion
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
468 (goto-char (point-min))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
469 (while (re-search-forward regexp nil t)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
470 (replace-match newregexp))))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
471
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
472 (defun whitespace-indent-cleanup ()
25625
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
473 "Search for 8/more spaces at the start of a line and replace it with tabs."
25582
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
474 (save-excursion
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
475 (goto-char (point-min))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
476 (while (re-search-forward whitespace-indent-regexp nil t)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
477 (let ((column (current-column))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
478 (indent-tabs-mode t))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
479 (delete-region (match-beginning 0) (point))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
480 (indent-to column)))))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
481
25724
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
482 (defun whitespace-display-unchecked-whitespaces (&optional whitespace-str)
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
483 "Update modeline with whitespaces whose testing has been turned off."
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
484 (let ((whitespace-this-modeline
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
485 (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
486 (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
487 (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
488 (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
489 (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
490 (setq whitespace-mode-line whitespace-str)
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
491 (if (not (equal whitespace-this-modeline ""))
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
492 (setq whitespace-mode-line
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
493 (concat whitespace-str " Woff:" whitespace-this-modeline)))
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
494 (whitespace-force-mode-line-update)))
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
495
25582
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
496 ;; Force mode line updation for different Emacs versions
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
497 (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
498 "Force the mode line update for different flavors of Emacs."
25582
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
499 (if whitespace-running-emacs
25625
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
500 (force-mode-line-update) ; Emacs
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
501 (redraw-modeline))) ; XEmacs
25582
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
502
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
503 (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
504 "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
505
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
506 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
507 periodically for whitespace."
25582
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
508 (if (and whitespace-mode (not (member (list buf-file buf-name)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
509 whitespace-all-buffer-files)))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
510 (add-to-list 'whitespace-all-buffer-files (list buf-file buf-name))))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
511
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
512 (defun whitespace-tickle-timer ()
25625
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
513 "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
514
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
515 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
516 `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
517 `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
518 (if (and whitespace-rescan-timer-time (not whitespace-rescan-timer))
25582
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
519 (setq whitespace-rescan-timer
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
520 (if whitespace-running-emacs
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
521 (run-at-time nil whitespace-rescan-timer-time
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
522 'whitespace-rescan-files-in-buffers)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
523 (add-timeout whitespace-rescan-timer-time
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
524 'whitespace-rescan-files-in-buffers nil
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
525 whitespace-rescan-timer-time)))))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
526
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
527 (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
528 "Check monitored files for whitespace creep since last scan."
25582
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
529 (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
530 buffile bufname thiselt buf)
25582
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
531 (if (not whitespace-all-my-files)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
532 (progn
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
533 (if whitespace-running-emacs
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
534 (cancel-timer whitespace-rescan-timer)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
535 (disable-timeout whitespace-rescan-timer))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
536 (setq whitespace-rescan-timer nil))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
537 (while whitespace-all-my-files
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
538 (setq thiselt (car whitespace-all-my-files))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
539 (setq whitespace-all-my-files (cdr whitespace-all-my-files))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
540 (setq buffile (car thiselt))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
541 (setq bufname (cadr thiselt))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
542 (setq buf (get-buffer bufname))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
543 (if (buffer-live-p buf)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
544 (save-excursion
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
545 ;;(message "buffer %s live" bufname)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
546 (set-buffer bufname)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
547 (if whitespace-mode
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
548 (progn
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
549 ;;(message "checking for whitespace in %s" bufname)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
550 (if whitespace-auto-cleanup
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
551 (progn
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
552 ;;(message "cleaning up whitespace in %s" bufname)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
553 (whitespace-cleanup))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
554 (progn
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
555 ;;(message "whitespace-buffer %s." (buffer-name))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
556 (whitespace-buffer t))))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
557 ;;(message "Removing %s from refresh list" bufname)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
558 (whitespace-refresh-rescan-list buffile bufname)))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
559 ;;(message "Removing %s from refresh list" bufname)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
560 (whitespace-refresh-rescan-list buffile bufname))))))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
561
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
562 (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
563 "Refresh the list of files to be rescaned for whitespace creep."
25582
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
564 (if whitespace-all-buffer-files
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
565 (progn
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
566 (setq whitespace-all-buffer-files
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
567 (delete (list buffile bufname) whitespace-all-buffer-files)))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
568 (progn
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
569 (if (and whitespace-running-emacs (timerp whitespace-rescan-timer))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
570 (cancel-timer whitespace-rescan-timer))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
571 (if (and (not whitespace-running-emacs) whitespace-rescan-timer)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
572 (disable-timeout whitespace-rescan-timer))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
573 (if whitespace-rescan-timer
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
574 (setq whitespace-rescan-timer nil)))))
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
575
25625
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
576 ;;;###autoload
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
577 (defun whitespace-describe ()
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
578 "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
579
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
580 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
581 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
582
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
583 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
584 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
585 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
586 replaced with TABS).
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
587 4. Spaces followed by a TAB. (Almost always, we never want that).
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
588 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
589
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
590 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
591
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
592 Modeline will show a W:<x> to denote a particular type of whitespace, where
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
593 `x' can be one (or more) of:
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
594
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
595 e - End-of-Line whitespace.
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
596 i - Indentation whitespace.
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
597 l - Leading whitespace.
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
598 s - Space followed by Tab.
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
599 t - Trailing whitespace.
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
600
25724
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
601 If any of the whitespace checks is turned off, the modeline will display a
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
602 Woff:<x>, where `x' can be one (or more) of the above.
6664d8f25ea5 (whitespace-version): Update version to 2.4
Richard M. Stallman <rms@gnu.org>
parents: 25625
diff changeset
603
25625
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
604 (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
605 terminal drivers and printer drivers have TAB configured or even
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
606 hardcoded to be 8 spaces. (Some of them allow configuration, but almost
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
607 always they default to 8.)
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
608
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
609 Changing tab-width to other than 8 and editing will cause your code to
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
610 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
611 even print it.
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
612
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
613 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
614 c-basic-offset or perl-indent-level) to configure the offset, so you
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
615 should never have to set your tab-width to be other than 8 in all these
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
616 modes. In fact, with an indent level of say, 4, 2 TABS will cause Emacs
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
617 to replace your 8 spaces with one \t (try it). If vi users in your
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
618 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
619 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
620 to set smarttab.)
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 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
623 merge problems.
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 whitespace.el will complain if it detects whitespaces on opening a file, and
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
626 warn you on closing a file also. (if in case you had inserted any
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
627 whitespaces during the process of your editing.)"
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
628 (interactive)
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
629 (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
630 whitespace-version))
c0e27d3ce645 Finish making it fit Emacs conventions. Add autoloads.
Richard M. Stallman <rms@gnu.org>
parents: 25582
diff changeset
631
25582
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
632 (provide 'whitespace)
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
633
e8428725fec3 Initial revision
Dave Love <fx@gnu.org>
parents:
diff changeset
634 ;;; whitespace.el ends here