annotate lisp/obsolete/whitespace.el @ 88071:1fcb6b1de8dc

*** empty log message ***
author Michael Albinus <michael.albinus@gmx.de>
date Tue, 29 Jan 2008 21:13:00 +0000
parents 2e00b91ccbc1
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
88046
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
1 ;;; whitespace.el --- warn about and clean bogus whitespaces in the file
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
2
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
3 ;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004,
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
4 ;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
5
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
6 ;; Author: Rajesh Vaidheeswarran <rv@gnu.org>
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
7 ;; Keywords: convenience
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
8
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
10
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
13 ;; the Free Software Foundation; either version 3, or (at your option)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
14 ;; any later version.
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
15
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
19 ;; GNU General Public License for more details.
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
20
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
24 ;; Boston, MA 02110-1301, USA.
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
25
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
26 ;;; Commentary:
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
27 ;;
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
28 ;; URL: http://www.dsmit.com/lisp/
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
29 ;;
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
30 ;; The whitespace library is intended to find and help fix five different types
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
31 ;; of whitespace problems that commonly exist in source code.
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
32 ;;
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
33 ;; 1. Leading space (empty lines at the top of a file).
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
34 ;; 2. Trailing space (empty lines at the end of a file).
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
35 ;; 3. Indentation space (8 or more spaces at beginning of line, that should be
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
36 ;; replaced with TABS).
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
37 ;; 4. Spaces followed by a TAB. (Almost always, we never want that).
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
38 ;; 5. Spaces or TABS at the end of a line.
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
39 ;;
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
40 ;; Whitespace errors are reported in a buffer, and on the modeline.
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
41 ;;
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
42 ;; Modeline will show a W:<x>!<y> to denote a particular type of whitespace,
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
43 ;; where `x' and `y' can be one (or more) of:
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
44 ;;
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
45 ;; e - End-of-Line whitespace.
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
46 ;; i - Indentation whitespace.
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
47 ;; l - Leading whitespace.
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
48 ;; s - Space followed by Tab.
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
49 ;; t - Trailing whitespace.
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
50 ;;
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
51 ;; If any of the whitespace checks is turned off, the modeline will display a
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
52 ;; !<y>.
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
53 ;;
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
54 ;; (since (3) is the most controversial one, here is the rationale: Most
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
55 ;; terminal drivers and printer drivers have TAB configured or even
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
56 ;; hardcoded to be 8 spaces. (Some of them allow configuration, but almost
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
57 ;; always they default to 8.)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
58 ;;
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
59 ;; Changing `tab-width' to other than 8 and editing will cause your code to
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
60 ;; look different from within Emacs, and say, if you cat it or more it, or
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
61 ;; even print it.
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
62 ;;
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
63 ;; Almost all the popular programming modes let you define an offset (like
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
64 ;; c-basic-offset or perl-indent-level) to configure the offset, so you
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
65 ;; should never have to set your `tab-width' to be other than 8 in all
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
66 ;; these modes. In fact, with an indent level of say, 4, 2 TABS will cause
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
67 ;; Emacs to replace your 8 spaces with one \t (try it). If vi users in
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
68 ;; your office complain, tell them to use vim, which distinguishes between
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
69 ;; tabstop and shiftwidth (vi equivalent of our offsets), and also ask them
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
70 ;; to set smarttab.)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
71 ;;
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
72 ;; All the above have caused (and will cause) unwanted codeline integration and
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
73 ;; merge problems.
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
74 ;;
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
75 ;; whitespace.el will complain if it detects whitespaces on opening a file, and
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
76 ;; warn you on closing a file also (in case you had inserted any
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
77 ;; whitespaces during the process of your editing).
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
78 ;;
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
79 ;; Exported functions:
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
80 ;;
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
81 ;; `whitespace-buffer' - To check the current buffer for whitespace problems.
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
82 ;; `whitespace-cleanup' - To cleanup all whitespaces in the current buffer.
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
83 ;; `whitespace-region' - To check between point and mark for whitespace
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
84 ;; problems.
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
85 ;; `whitespace-cleanup-region' - To cleanup all whitespaces between point
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
86 ;; and mark in the current buffer.
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
87
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
88 ;;; Code:
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
89
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
90 (defvar whitespace-version "3.5" "Version of the whitespace library.")
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
91
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
92 (defvar whitespace-all-buffer-files nil
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
93 "An associated list of buffers and files checked for whitespace cleanliness.
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
94
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
95 This is to enable periodic checking of whitespace cleanliness in the files
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
96 visited by the buffers.")
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
97
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
98 (defvar whitespace-rescan-timer nil
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
99 "Timer object used to rescan the files in buffers that have been modified.")
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
100
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
101 ;; Tell Emacs about this new kind of minor mode
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
102 (defvar whitespace-mode nil
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
103 "Non-nil when Whitespace mode (a minor mode) is enabled.")
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
104 (make-variable-buffer-local 'whitespace-mode)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
105
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
106 (defvar whitespace-mode-line nil
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
107 "String to display in the mode line for Whitespace mode.")
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
108 (make-variable-buffer-local 'whitespace-mode-line)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
109
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
110 (defvar whitespace-check-buffer-leading nil
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
111 "Test leading whitespace for file in current buffer if t.")
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
112 (make-variable-buffer-local 'whitespace-check-buffer-leading)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
113 ;;;###autoload(put 'whitespace-check-buffer-leading 'safe-local-variable 'booleanp)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
114
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
115 (defvar whitespace-check-buffer-trailing nil
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
116 "Test trailing whitespace for file in current buffer if t.")
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
117 (make-variable-buffer-local 'whitespace-check-buffer-trailing)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
118 ;;;###autoload(put 'whitespace-check-buffer-trailing 'safe-local-variable 'booleanp)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
119
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
120 (defvar whitespace-check-buffer-indent nil
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
121 "Test indentation whitespace for file in current buffer if t.")
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
122 (make-variable-buffer-local 'whitespace-check-buffer-indent)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
123 ;;;###autoload(put 'whitespace-check-buffer-indent 'safe-local-variable 'booleanp)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
124
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
125 (defvar whitespace-check-buffer-spacetab nil
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
126 "Test Space-followed-by-TABS whitespace for file in current buffer if t.")
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
127 (make-variable-buffer-local 'whitespace-check-buffer-spacetab)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
128 ;;;###autoload(put 'whitespace-check-buffer-spacetab 'safe-local-variable 'booleanp)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
129
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
130 (defvar whitespace-check-buffer-ateol nil
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
131 "Test end-of-line whitespace for file in current buffer if t.")
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
132 (make-variable-buffer-local 'whitespace-check-buffer-ateol)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
133 ;;;###autoload(put 'whitespace-check-buffer-ateol 'safe-local-variable 'booleanp)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
134
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
135 (defvar whitespace-highlighted-space nil
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
136 "The variable to store the extent to highlight.")
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
137 (make-variable-buffer-local 'whitespace-highlighted-space)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
138
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
139 (defalias 'whitespace-make-overlay
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
140 (if (featurep 'xemacs) 'make-extent 'make-overlay))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
141 (defalias 'whitespace-overlay-put
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
142 (if (featurep 'xemacs) 'set-extent-property 'overlay-put))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
143 (defalias 'whitespace-delete-overlay
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
144 (if (featurep 'xemacs) 'delete-extent 'delete-overlay))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
145 (defalias 'whitespace-overlay-start
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
146 (if (featurep 'xemacs) 'extent-start 'overlay-start))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
147 (defalias 'whitespace-overlay-end
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
148 (if (featurep 'xemacs) 'extent-end 'overlay-end))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
149 (defalias 'whitespace-mode-line-update
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
150 (if (featurep 'xemacs) 'redraw-modeline 'force-mode-line-update))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
151
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
152 (defgroup whitespace nil
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
153 "Check for and fix five different types of whitespaces in source code."
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
154 :version "21.1"
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
155 :link '(emacs-commentary-link "whitespace.el")
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
156 ;; Since XEmacs doesn't have a 'convenience group, use the next best group
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
157 ;; which is 'editing?
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
158 :group (if (featurep 'xemacs) 'editing 'convenience))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
159
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
160 (defcustom whitespace-check-leading-whitespace t
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
161 "Flag to check leading whitespace. This is the global for the system.
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
162 It can be overridden by setting a buffer local variable
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
163 `whitespace-check-buffer-leading'."
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
164 :type 'boolean
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
165 :group 'whitespace)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
166
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
167 (defcustom whitespace-check-trailing-whitespace t
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
168 "Flag to check trailing whitespace. This is the global for the system.
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
169 It can be overridden by setting a buffer local variable
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
170 `whitespace-check-buffer-trailing'."
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
171 :type 'boolean
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
172 :group 'whitespace)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
173
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
174 (defcustom whitespace-check-spacetab-whitespace t
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
175 "Flag to check space followed by a TAB. This is the global for the system.
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
176 It can be overridden by setting a buffer local variable
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
177 `whitespace-check-buffer-spacetab'."
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
178 :type 'boolean
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
179 :group 'whitespace)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
180
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
181 (defcustom whitespace-spacetab-regexp "[ ]+\t"
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
182 "Regexp to match one or more spaces followed by a TAB."
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
183 :type 'regexp
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
184 :group 'whitespace)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
185
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
186 (defcustom whitespace-check-indent-whitespace indent-tabs-mode
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
187 "Flag to check indentation whitespace. This is the global for the system.
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
188 It can be overridden by setting a buffer local variable
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
189 `whitespace-check-buffer-indent'."
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
190 :type 'boolean
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
191 :group 'whitespace)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
192
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
193 (defcustom whitespace-indent-regexp "^\t*\\( \\)+"
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
194 "Regexp to match multiples of eight spaces near line beginnings.
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
195 The default value ignores leading TABs."
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
196 :type 'regexp
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
197 :group 'whitespace)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
198
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
199 (defcustom whitespace-check-ateol-whitespace t
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
200 "Flag to check end-of-line whitespace. This is the global for the system.
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
201 It can be overridden by setting a buffer local variable
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
202 `whitespace-check-buffer-ateol'."
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
203 :type 'boolean
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
204 :group 'whitespace)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
205
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
206 (defcustom whitespace-ateol-regexp "[ \t]+$"
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
207 "Regexp to match one or more TABs or spaces at line ends."
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
208 :type 'regexp
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
209 :group 'whitespace)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
210
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
211 (defcustom whitespace-errbuf "*Whitespace Errors*"
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
212 "The name of the buffer where whitespace related messages will be logged."
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
213 :type 'string
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
214 :group 'whitespace)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
215
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
216 (defcustom whitespace-clean-msg "clean."
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
217 "If non-nil, this message will be displayed after a whitespace check
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
218 determines a file to be clean."
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
219 :type 'string
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
220 :group 'whitespace)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
221
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
222 (defcustom whitespace-abort-on-error nil
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
223 "While writing a file, abort if the file is unclean.
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
224 If `whitespace-auto-cleanup' is set, that takes precedence over
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
225 this variable."
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
226 :type 'boolean
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
227 :group 'whitespace)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
228
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
229 (defcustom whitespace-auto-cleanup nil
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
230 "Cleanup a buffer automatically on finding it whitespace unclean."
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
231 :type 'boolean
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
232 :group 'whitespace)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
233
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
234 (defcustom whitespace-silent nil
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
235 "All whitespace errors will be shown only in the modeline when t.
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
236
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
237 Note that setting this may cause all whitespaces introduced in a file to go
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
238 unnoticed when the buffer is killed, unless the user visits the `*Whitespace
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
239 Errors*' buffer before opening (or closing) another file."
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
240 :type 'boolean
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
241 :group 'whitespace)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
242
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
243 (defcustom whitespace-modes '(ada-mode asm-mode autoconf-mode awk-mode
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
244 c-mode c++-mode cc-mode
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
245 change-log-mode cperl-mode
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
246 electric-nroff-mode emacs-lisp-mode
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
247 f90-mode fortran-mode html-mode
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
248 html3-mode java-mode jde-mode
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
249 ksh-mode latex-mode LaTeX-mode
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
250 lisp-mode m4-mode makefile-mode
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
251 modula-2-mode nroff-mode objc-mode
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
252 pascal-mode perl-mode prolog-mode
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
253 python-mode scheme-mode sgml-mode
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
254 sh-mode shell-script-mode simula-mode
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
255 tcl-mode tex-mode texinfo-mode
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
256 vrml-mode xml-mode)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
257
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
258 "Major modes in which we turn on whitespace checking.
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
259
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
260 These are mostly programming and documentation modes. But you may add other
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
261 modes that you want whitespaces checked in by adding something like the
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
262 following to your `.emacs':
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
263
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
264 \(setq whitespace-modes (cons 'my-mode (cons 'my-other-mode
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
265 whitespace-modes))\)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
266
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
267 Or, alternately, you can use the Emacs `customize' command to set this."
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
268 :type '(repeat symbol)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
269 :group 'whitespace)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
270
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
271 (defcustom whitespace-rescan-timer-time 600
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
272 "Period in seconds to rescan modified buffers for whitespace creep.
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
273
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
274 This is the period after which the timer will fire causing
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
275 `whitespace-rescan-files-in-buffers' to check for whitespace creep in
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
276 modified buffers.
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
277
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
278 To disable timer scans, set this to zero."
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
279 :type 'integer
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
280 :group 'whitespace)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
281
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
282 (defcustom whitespace-display-in-modeline t
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
283 "Display whitespace errors on the modeline."
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
284 :type 'boolean
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
285 :group 'whitespace)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
286
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
287 (defcustom whitespace-display-spaces-in-color t
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
288 "Display the bogus whitespaces by coloring them with the face
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
289 `whitespace-highlight'."
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
290 :type 'boolean
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
291 :group 'whitespace)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
292
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
293 (defgroup whitespace-faces nil
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
294 "Faces used in whitespace."
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
295 :prefix "whitespace-"
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
296 :group 'whitespace
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
297 :group 'faces)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
298
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
299 (defface whitespace-highlight '((((class color) (background light))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
300 (:background "green1"))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
301 (((class color) (background dark))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
302 (:background "sea green"))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
303 (((class grayscale mono)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
304 (background light))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
305 (:background "black"))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
306 (((class grayscale mono)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
307 (background dark))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
308 (:background "white")))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
309 "Face used for highlighting the bogus whitespaces that exist in the buffer."
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
310 :group 'whitespace-faces)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
311 ;; backward-compatibility alias
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
312 (put 'whitespace-highlight-face 'face-alias 'whitespace-highlight)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
313
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
314 (if (not (assoc 'whitespace-mode minor-mode-alist))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
315 (setq minor-mode-alist (cons '(whitespace-mode whitespace-mode-line)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
316 minor-mode-alist)))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
317
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
318 (set-default 'whitespace-check-buffer-leading
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
319 whitespace-check-leading-whitespace)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
320 (set-default 'whitespace-check-buffer-trailing
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
321 whitespace-check-trailing-whitespace)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
322 (set-default 'whitespace-check-buffer-indent
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
323 whitespace-check-indent-whitespace)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
324 (set-default 'whitespace-check-buffer-spacetab
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
325 whitespace-check-spacetab-whitespace)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
326 (set-default 'whitespace-check-buffer-ateol
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
327 whitespace-check-ateol-whitespace)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
328
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
329 (defun whitespace-check-whitespace-mode (&optional arg)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
330 "Test and set the whitespace-mode in qualifying buffers."
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
331 (if (null whitespace-mode)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
332 (setq whitespace-mode
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
333 (if (or arg (member major-mode whitespace-modes))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
334 t
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
335 nil))))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
336
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
337 ;;;###autoload
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
338 (defun whitespace-toggle-leading-check ()
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
339 "Toggle the check for leading space in the local buffer."
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
340 (interactive)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
341 (let ((current-val whitespace-check-buffer-leading))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
342 (setq whitespace-check-buffer-leading (not current-val))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
343 (message "Will%s check for leading space in buffer."
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
344 (if whitespace-check-buffer-leading "" " not"))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
345 (if whitespace-check-buffer-leading (whitespace-buffer-leading))))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
346
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
347 ;;;###autoload
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
348 (defun whitespace-toggle-trailing-check ()
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
349 "Toggle the check for trailing space in the local buffer."
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
350 (interactive)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
351 (let ((current-val whitespace-check-buffer-trailing))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
352 (setq whitespace-check-buffer-trailing (not current-val))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
353 (message "Will%s check for trailing space in buffer."
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
354 (if whitespace-check-buffer-trailing "" " not"))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
355 (if whitespace-check-buffer-trailing (whitespace-buffer-trailing))))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
356
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
357 ;;;###autoload
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
358 (defun whitespace-toggle-indent-check ()
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
359 "Toggle the check for indentation space in the local buffer."
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
360 (interactive)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
361 (let ((current-val whitespace-check-buffer-indent))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
362 (setq whitespace-check-buffer-indent (not current-val))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
363 (message "Will%s check for indentation space in buffer."
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
364 (if whitespace-check-buffer-indent "" " not"))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
365 (if whitespace-check-buffer-indent
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
366 (whitespace-buffer-search whitespace-indent-regexp))))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
367
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
368 ;;;###autoload
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
369 (defun whitespace-toggle-spacetab-check ()
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
370 "Toggle the check for space-followed-by-TABs in the local buffer."
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
371 (interactive)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
372 (let ((current-val whitespace-check-buffer-spacetab))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
373 (setq whitespace-check-buffer-spacetab (not current-val))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
374 (message "Will%s check for space-followed-by-TABs in buffer."
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
375 (if whitespace-check-buffer-spacetab "" " not"))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
376 (if whitespace-check-buffer-spacetab
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
377 (whitespace-buffer-search whitespace-spacetab-regexp))))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
378
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
379
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
380 ;;;###autoload
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
381 (defun whitespace-toggle-ateol-check ()
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
382 "Toggle the check for end-of-line space in the local buffer."
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
383 (interactive)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
384 (let ((current-val whitespace-check-buffer-ateol))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
385 (setq whitespace-check-buffer-ateol (not current-val))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
386 (message "Will%s check for end-of-line space in buffer."
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
387 (if whitespace-check-buffer-ateol "" " not"))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
388 (if whitespace-check-buffer-ateol
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
389 (whitespace-buffer-search whitespace-ateol-regexp))))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
390
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
391
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
392 ;;;###autoload
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
393 (defun whitespace-buffer (&optional quiet)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
394 "Find five different types of white spaces in buffer.
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
395 These are:
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
396 1. Leading space \(empty lines at the top of a file\).
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
397 2. Trailing space \(empty lines at the end of a file\).
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
398 3. Indentation space \(8 or more spaces, that should be replaced with TABS\).
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
399 4. Spaces followed by a TAB. \(Almost always, we never want that\).
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
400 5. Spaces or TABS at the end of a line.
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
401
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
402 Check for whitespace only if this buffer really contains a non-empty file
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
403 and:
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
404 1. the major mode is one of the whitespace-modes, or
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
405 2. `whitespace-buffer' was explicitly called with a prefix argument."
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
406 (interactive)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
407 (let ((whitespace-error nil))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
408 (whitespace-check-whitespace-mode current-prefix-arg)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
409 (if (and buffer-file-name (> (buffer-size) 0) whitespace-mode)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
410 (progn
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
411 (whitespace-check-buffer-list (buffer-name) buffer-file-name)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
412 (whitespace-tickle-timer)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
413 (overlay-recenter (point-max))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
414 (remove-overlays nil nil 'face 'whitespace-highlight)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
415 (if whitespace-auto-cleanup
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
416 (if buffer-read-only
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
417 (if (not quiet)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
418 (message "Can't cleanup: %s is read-only" (buffer-name)))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
419 (whitespace-cleanup-internal))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
420 (let ((whitespace-leading (if whitespace-check-buffer-leading
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
421 (whitespace-buffer-leading)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
422 nil))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
423 (whitespace-trailing (if whitespace-check-buffer-trailing
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
424 (whitespace-buffer-trailing)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
425 nil))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
426 (whitespace-indent (if whitespace-check-buffer-indent
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
427 (whitespace-buffer-search
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
428 whitespace-indent-regexp)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
429 nil))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
430 (whitespace-spacetab (if whitespace-check-buffer-spacetab
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
431 (whitespace-buffer-search
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
432 whitespace-spacetab-regexp)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
433 nil))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
434 (whitespace-ateol (if whitespace-check-buffer-ateol
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
435 (whitespace-buffer-search
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
436 whitespace-ateol-regexp)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
437 nil))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
438 (whitespace-errmsg nil)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
439 (whitespace-filename buffer-file-name)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
440 (whitespace-this-modeline ""))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
441
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
442 ;; Now let's complain if we found any of the above.
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
443 (setq whitespace-error (or whitespace-leading whitespace-indent
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
444 whitespace-spacetab whitespace-ateol
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
445 whitespace-trailing))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
446
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
447 (if whitespace-error
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
448 (progn
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
449 (setq whitespace-errmsg
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
450 (concat whitespace-filename " contains:\n"
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
451 (if whitespace-leading
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
452 "Leading whitespace\n")
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
453 (if whitespace-indent
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
454 (concat "Indentation whitespace"
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
455 whitespace-indent "\n"))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
456 (if whitespace-spacetab
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
457 (concat "Space followed by Tab"
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
458 whitespace-spacetab "\n"))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
459 (if whitespace-ateol
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
460 (concat "End-of-line whitespace"
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
461 whitespace-ateol "\n"))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
462 (if whitespace-trailing
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
463 "Trailing whitespace\n")
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
464 "\ntype `M-x whitespace-cleanup' to "
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
465 "cleanup the file."))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
466 (setq whitespace-this-modeline
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
467 (concat (if whitespace-ateol "e")
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
468 (if whitespace-indent "i")
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
469 (if whitespace-leading "l")
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
470 (if whitespace-spacetab "s")
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
471 (if whitespace-trailing "t")))))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
472 (whitespace-update-modeline whitespace-this-modeline)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
473 (if (get-buffer whitespace-errbuf)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
474 (kill-buffer whitespace-errbuf))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
475 (with-current-buffer (get-buffer-create whitespace-errbuf)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
476 (if whitespace-errmsg
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
477 (progn
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
478 (insert whitespace-errmsg)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
479 (if (not (or quiet whitespace-silent))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
480 (display-buffer (current-buffer) t))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
481 (if (not quiet)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
482 (message "Whitespaces: [%s%s] in %s"
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
483 whitespace-this-modeline
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
484 (let ((whitespace-unchecked
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
485 (whitespace-unchecked-whitespaces)))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
486 (if whitespace-unchecked
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
487 (concat "!" whitespace-unchecked)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
488 ""))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
489 whitespace-filename)))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
490 (if (and (not quiet) (not (equal whitespace-clean-msg "")))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
491 (message "%s %s" whitespace-filename
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
492 whitespace-clean-msg))))))))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
493 whitespace-error))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
494
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
495 ;;;###autoload
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
496 (defun whitespace-region (s e)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
497 "Check the region for whitespace errors."
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
498 (interactive "r")
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
499 (save-excursion
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
500 (save-restriction
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
501 (narrow-to-region s e)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
502 (whitespace-buffer))))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
503
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
504 ;;;###autoload
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
505 (defun whitespace-cleanup ()
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
506 "Cleanup the five different kinds of whitespace problems.
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
507 It normally applies to the whole buffer, but in Transient Mark mode
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
508 when the mark is active it applies to the region.
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
509 See `whitespace-buffer' docstring for a summary of the problems."
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
510 (interactive)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
511 (if (and transient-mark-mode mark-active)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
512 (whitespace-cleanup-region (region-beginning) (region-end))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
513 (whitespace-cleanup-internal)))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
514
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
515 (defun whitespace-cleanup-internal (&optional region-only)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
516 ;; If this buffer really contains a file, then run, else quit.
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
517 (whitespace-check-whitespace-mode current-prefix-arg)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
518 (if (and buffer-file-name whitespace-mode)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
519 (let ((whitespace-any nil)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
520 (whitespace-tabwith 8)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
521 (whitespace-tabwith-saved tab-width))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
522
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
523 ;; since all printable TABS should be 8, irrespective of how
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
524 ;; they are displayed.
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
525 (setq tab-width whitespace-tabwith)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
526
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
527 (if (and whitespace-check-buffer-leading
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
528 (whitespace-buffer-leading))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
529 (progn
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
530 (whitespace-buffer-leading-cleanup)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
531 (setq whitespace-any t)))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
532
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
533 (if (and whitespace-check-buffer-trailing
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
534 (whitespace-buffer-trailing))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
535 (progn
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
536 (whitespace-buffer-trailing-cleanup)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
537 (setq whitespace-any t)))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
538
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
539 (if (and whitespace-check-buffer-indent
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
540 (whitespace-buffer-search whitespace-indent-regexp))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
541 (progn
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
542 (whitespace-indent-cleanup)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
543 (setq whitespace-any t)))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
544
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
545 (if (and whitespace-check-buffer-spacetab
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
546 (whitespace-buffer-search whitespace-spacetab-regexp))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
547 (progn
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
548 (whitespace-buffer-cleanup whitespace-spacetab-regexp "\t")
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
549 (setq whitespace-any t)))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
550
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
551 (if (and whitespace-check-buffer-ateol
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
552 (whitespace-buffer-search whitespace-ateol-regexp))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
553 (progn
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
554 (whitespace-buffer-cleanup whitespace-ateol-regexp "")
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
555 (setq whitespace-any t)))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
556
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
557 ;; Call this recursively till everything is taken care of
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
558 (if whitespace-any
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
559 (whitespace-cleanup-internal region-only)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
560 ;; if we are done, talk to the user
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
561 (progn
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
562 (unless whitespace-silent
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
563 (if region-only
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
564 (message "The region is now clean")
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
565 (message "%s is now clean" buffer-file-name)))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
566 (whitespace-update-modeline)))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
567 (setq tab-width whitespace-tabwith-saved))))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
568
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
569 ;;;###autoload
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
570 (defun whitespace-cleanup-region (s e)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
571 "Whitespace cleanup on the region."
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
572 (interactive "r")
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
573 (save-excursion
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
574 (save-restriction
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
575 (narrow-to-region s e)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
576 (whitespace-cleanup-internal t))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
577 (whitespace-buffer t)))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
578
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
579 (defun whitespace-buffer-leading ()
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
580 "Return t if the current buffer has leading newline characters.
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
581 If highlighting is enabled, highlight these characters."
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
582 (save-excursion
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
583 (goto-char (point-min))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
584 (skip-chars-forward "\n")
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
585 (unless (bobp)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
586 (whitespace-highlight-the-space (point-min) (point))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
587 t)))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
588
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
589 (defun whitespace-buffer-leading-cleanup ()
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
590 "Remove any leading newline characters from current buffer."
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
591 (save-excursion
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
592 (goto-char (point-min))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
593 (skip-chars-forward "\n")
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
594 (delete-region (point-min) (point))))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
595
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
596 (defun whitespace-buffer-trailing ()
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
597 "Return t if the current buffer has extra trailing newline characters.
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
598 If highlighting is enabled, highlight these characters."
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
599 (save-excursion
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
600 (goto-char (point-max))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
601 (skip-chars-backward "\n")
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
602 (forward-line)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
603 (unless (eobp)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
604 (whitespace-highlight-the-space (point) (point-max))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
605 t)))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
606
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
607 (defun whitespace-buffer-trailing-cleanup ()
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
608 "Remove extra trailing newline characters from current buffer."
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
609 (save-excursion
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
610 (goto-char (point-max))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
611 (skip-chars-backward "\n")
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
612 (unless (eobp)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
613 (forward-line)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
614 (delete-region (point) (point-max)))))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
615
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
616 (defun whitespace-buffer-search (regexp)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
617 "Search for any given whitespace REGEXP."
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
618 (with-local-quit
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
619 (let (whitespace-retval)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
620 (save-excursion
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
621 (goto-char (point-min))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
622 (while (re-search-forward regexp nil t)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
623 (whitespace-highlight-the-space (match-beginning 0) (match-end 0))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
624 (push (match-beginning 0) whitespace-retval)))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
625 (when whitespace-retval
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
626 (format " %s" (nreverse whitespace-retval))))))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
627
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
628 (defun whitespace-buffer-cleanup (regexp newregexp)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
629 "Search for any given whitespace REGEXP and replace it with the NEWREGEXP."
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
630 (save-excursion
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
631 (goto-char (point-min))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
632 (while (re-search-forward regexp nil t)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
633 (replace-match newregexp))))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
634
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
635 (defun whitespace-indent-cleanup ()
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
636 "Search for 8/more spaces at the start of a line and replace it with tabs."
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
637 (save-excursion
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
638 (goto-char (point-min))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
639 (while (re-search-forward whitespace-indent-regexp nil t)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
640 (let ((column (current-column))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
641 (indent-tabs-mode t))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
642 (delete-region (match-beginning 0) (point))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
643 (indent-to column)))))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
644
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
645 (defun whitespace-unchecked-whitespaces ()
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
646 "Return the list of whitespaces whose testing has been suppressed."
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
647 (let ((unchecked-spaces
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
648 (concat (if (not whitespace-check-buffer-ateol) "e")
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
649 (if (not whitespace-check-buffer-indent) "i")
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
650 (if (not whitespace-check-buffer-leading) "l")
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
651 (if (not whitespace-check-buffer-spacetab) "s")
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
652 (if (not whitespace-check-buffer-trailing) "t"))))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
653 (if (not (equal unchecked-spaces ""))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
654 unchecked-spaces
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
655 nil)))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
656
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
657 (defun whitespace-update-modeline (&optional whitespace-err)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
658 "Update modeline with whitespace errors.
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
659 Also with whitespaces whose testing has been turned off."
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
660 (if whitespace-display-in-modeline
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
661 (progn
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
662 (setq whitespace-mode-line nil)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
663 ;; Whitespace errors
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
664 (if (and whitespace-err (not (equal whitespace-err "")))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
665 (setq whitespace-mode-line whitespace-err))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
666 ;; Whitespace suppressed errors
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
667 (let ((whitespace-unchecked (whitespace-unchecked-whitespaces)))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
668 (if whitespace-unchecked
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
669 (setq whitespace-mode-line
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
670 (concat whitespace-mode-line "!" whitespace-unchecked))))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
671 ;; Add the whitespace modeline prefix
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
672 (setq whitespace-mode-line (if whitespace-mode-line
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
673 (concat " W:" whitespace-mode-line)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
674 nil))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
675 (whitespace-mode-line-update))))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
676
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
677 (defun whitespace-highlight-the-space (b e)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
678 "Highlight the current line, unhighlighting a previously jumped to line."
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
679 (if whitespace-display-spaces-in-color
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
680 (let ((ol (whitespace-make-overlay b e)))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
681 (whitespace-overlay-put ol 'face 'whitespace-highlight))))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
682
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
683 (defun whitespace-unhighlight-the-space()
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
684 "Unhighlight the currently highlight line."
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
685 (if (and whitespace-display-spaces-in-color whitespace-highlighted-space)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
686 (progn
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
687 (mapc 'whitespace-delete-overlay whitespace-highlighted-space)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
688 (setq whitespace-highlighted-space nil))))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
689
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
690 (defun whitespace-check-buffer-list (buf-name buf-file)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
691 "Add a buffer and its file to the whitespace monitor list.
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
692
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
693 The buffer named BUF-NAME and its associated file BUF-FILE are now monitored
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
694 periodically for whitespace."
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
695 (if (and whitespace-mode (not (member (list buf-file buf-name)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
696 whitespace-all-buffer-files)))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
697 (add-to-list 'whitespace-all-buffer-files (list buf-file buf-name))))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
698
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
699 (defun whitespace-tickle-timer ()
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
700 "Tickle timer to periodically to scan qualifying files for whitespace creep.
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
701
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
702 If timer is not set, then set it to scan the files in
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
703 `whitespace-all-buffer-files' periodically (defined by
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
704 `whitespace-rescan-timer-time') for whitespace creep."
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
705 (if (and whitespace-rescan-timer-time
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
706 (/= whitespace-rescan-timer-time 0)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
707 (not whitespace-rescan-timer))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
708 (setq whitespace-rescan-timer
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
709 (add-timeout whitespace-rescan-timer-time
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
710 'whitespace-rescan-files-in-buffers nil
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
711 whitespace-rescan-timer-time))))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
712
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
713 (defun whitespace-rescan-files-in-buffers (&optional arg)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
714 "Check monitored files for whitespace creep since last scan."
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
715 (let ((whitespace-all-my-files whitespace-all-buffer-files)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
716 buffile bufname thiselt buf)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
717 (if (not whitespace-all-my-files)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
718 (progn
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
719 (disable-timeout whitespace-rescan-timer)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
720 (setq whitespace-rescan-timer nil))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
721 (while whitespace-all-my-files
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
722 (setq thiselt (car whitespace-all-my-files))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
723 (setq whitespace-all-my-files (cdr whitespace-all-my-files))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
724 (setq buffile (car thiselt))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
725 (setq bufname (cadr thiselt))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
726 (setq buf (get-buffer bufname))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
727 (if (buffer-live-p buf)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
728 (save-excursion
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
729 ;;(message "buffer %s live" bufname)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
730 (set-buffer bufname)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
731 (if whitespace-mode
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
732 (progn
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
733 ;;(message "checking for whitespace in %s" bufname)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
734 (if whitespace-auto-cleanup
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
735 (progn
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
736 ;;(message "cleaning up whitespace in %s" bufname)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
737 (whitespace-cleanup-internal))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
738 (progn
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
739 ;;(message "whitespace-buffer %s." (buffer-name))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
740 (whitespace-buffer t))))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
741 ;;(message "Removing %s from refresh list" bufname)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
742 (whitespace-refresh-rescan-list buffile bufname)))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
743 ;;(message "Removing %s from refresh list" bufname)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
744 (whitespace-refresh-rescan-list buffile bufname))))))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
745
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
746 (defun whitespace-refresh-rescan-list (buffile bufname)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
747 "Refresh the list of files to be rescanned for whitespace creep."
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
748 (if whitespace-all-buffer-files
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
749 (setq whitespace-all-buffer-files
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
750 (delete (list buffile bufname) whitespace-all-buffer-files))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
751 (when whitespace-rescan-timer
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
752 (disable-timeout whitespace-rescan-timer)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
753 (setq whitespace-rescan-timer nil))))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
754
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
755 ;;;###autoload
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
756 (defalias 'global-whitespace-mode 'whitespace-global-mode)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
757
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
758 ;;;###autoload
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
759 (define-minor-mode whitespace-global-mode
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
760 "Toggle using Whitespace mode in new buffers.
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
761 With ARG, turn the mode on if ARG is positive, otherwise turn it off.
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
762
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
763 When this mode is active, `whitespace-buffer' is added to
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
764 `find-file-hook' and `kill-buffer-hook'."
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
765 :global t
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
766 :group 'whitespace
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
767 (if whitespace-global-mode
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
768 (progn
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
769 (add-hook 'find-file-hook 'whitespace-buffer)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
770 (add-hook 'write-file-functions 'whitespace-write-file-hook nil t)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
771 (add-hook 'kill-buffer-hook 'whitespace-buffer))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
772 (remove-hook 'find-file-hook 'whitespace-buffer)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
773 (remove-hook 'write-file-functions 'whitespace-write-file-hook t)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
774 (remove-hook 'kill-buffer-hook 'whitespace-buffer)))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
775
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
776 ;;;###autoload
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
777 (defun whitespace-write-file-hook ()
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
778 "Hook function to be called on the buffer when whitespace check is enabled.
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
779 This is meant to be added buffer-locally to `write-file-functions'."
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
780 (let ((werr nil))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
781 (if whitespace-auto-cleanup
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
782 (whitespace-cleanup-internal)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
783 (setq werr (whitespace-buffer)))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
784 (if (and whitespace-abort-on-error werr)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
785 (error "Abort write due to whitespaces in %s"
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
786 buffer-file-name)))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
787 nil)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
788
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
789 (defun whitespace-unload-function ()
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
790 "Unload the whitespace library."
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
791 (if (unintern "whitespace-unload-hook")
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
792 ;; if whitespace-unload-hook is defined, let's get rid of it
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
793 ;; and recursively call `unload-feature'
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
794 (progn (unload-feature 'whitespace) t)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
795 ;; this only happens in the recursive call
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
796 (whitespace-global-mode -1)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
797 (save-current-buffer
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
798 (dolist (buf (buffer-list))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
799 (set-buffer buf)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
800 (remove-hook 'write-file-functions 'whitespace-write-file-hook t)))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
801 ;; continue standard unloading
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
802 nil))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
803
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
804 (defun whitespace-unload-hook ()
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
805 (remove-hook 'find-file-hook 'whitespace-buffer)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
806 (remove-hook 'write-file-functions 'whitespace-write-file-hook t)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
807 (remove-hook 'kill-buffer-hook 'whitespace-buffer))
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
808
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
809 (add-hook 'whitespace-unload-hook 'whitespace-unload-hook)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
810
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
811 (provide 'whitespace)
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
812
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
813 ;; arch-tag: 4ff44e87-b63c-402d-95a6-15e51e58bd0c
2e00b91ccbc1 Move whitespace.el to obsolete dir.:
Vinicius Jose Latorre <viniciusjl@ig.com.br>
parents:
diff changeset
814 ;;; whitespace.el ends here