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