annotate lisp/modes/whitespace-mode.el @ 161:28f395d8dc7a r20-3b7

Import from CVS: tag r20-3b7
author cvs
date Mon, 13 Aug 2007 09:42:26 +0200
parents 34a5b81f86ba
children 6075d714658b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
1 ;;; whitespace-mode.el -- minor mode for making whitespace visible
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
2
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
3 ;; Copyright (C) 1994, 1995, 1996 Heiko Muenkel
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
4
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
5 ;; Author: Heiko Muenkel <muenkel@tnt.uni-hannover.de>
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
6 ;; Keywords: modes, extensions
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
7
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
8 ;; This file is part of XEmacs.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
9
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
10 ;; XEmacs is free software; you can redistribute it and/or modify it
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
11 ;; under the terms of the GNU General Public License as published by
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
13 ;; option) any later version.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
14
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
15 ;; XEmacs is distributed in the hope that it will be useful, but
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
18 ;; General Public License for more details.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
19
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
21 ;; along with XEmacs; if not, write to the Free Software
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
22 ;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
23 ;; 02111-1307, USA.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
24
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
25 ;;; Synched up with: FSF 19.34.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
26
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
27 ;;; Commentary:
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
28
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 100
diff changeset
29 ;; $Id: whitespace-mode.el,v 1.3 1997/04/19 23:21:05 steve Exp $
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
30 ;; Description:
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
31 ;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
32 ;; This is a minor mode, which highlights whitespaces (blanks and
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
33 ;; tabs) with different faces, so that it is easier to
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
34 ;; distinguish between them.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
35 ;; Toggle the mode with: M-x whitespace-mode
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
36 ;; or with: M-x whitespace-incremental-mode
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
37 ;; The second one should be used in big files.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
38 ;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
39 ;; If you want to know how the whitespaces are highlighted then
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
40 ;; type: M-x whitespace-show-faces
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
41 ;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
42 ;; There are 2 hook variables `whitespace-incremental-mode-hook'
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
43 ;; and `whitespace-mode-hook' to customize the mode.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
44 ;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
45 ;; Look at the variable `whitespace-chars', if you only want to
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
46 ;; highlight tabs or blanks and not both.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
47 ;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
48 ;; Set `whitespace-install-toolbar-icon' to t, if you want a
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
49 ;; toolbar icon for this mode.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
50 ;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
51 ;; Set `whitespace-install-submenu' to t, if you want a submenu
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
52 ;; for this mode. Sorry, at the moment there is no menu for the
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
53 ;; Emacs 19.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
54 ;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
55 ;; Thanks to Mike Scheidler for the toolbar icon code.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
56 ;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
57 ;; Installation:
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
58 ;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
59 ;; Put the files whitespace-mode.el and adapt.el in one of your
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
60 ;; load-path directories and the following lines (without the
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
61 ;; comment signs) in your .emacs (adapt.el is already in the
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
62 ;; XEmacs 19.12).
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
63 ;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
64 ;; (autoload 'whitespace-mode "whitespace-mode"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
65 ;; "Toggle whitespace mode.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
66 ;; With arg, turn whitespace mode on iff arg is positive.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
67 ;; In whitespace mode the different whitespaces (tab, blank return)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
68 ;; are highlighted with different faces. The faces are:
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
69 ;; `whitespace-blank-face', `whitespace-tab-face' and
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
70 ;; `whitespace-return-face'."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
71 ;; t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
72 ;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
73 ;; (autoload 'whitespace-incremental-mode "whitespace-mode"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
74 ;; "Toggle whitespace incremental mode.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
75 ;; With arg, turn whitespace incremental mode on iff arg is positive.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
76 ;; In whitespace incremental mode the different whitespaces (tab and
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
77 ;; blank) are highlighted with different faces. The faces are:
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
78 ;; `whitespace-blank-face' and `whitespace-tab-face'.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
79 ;; Use the command `whitespace-show-faces' to show their values.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
80 ;; In this mode only these tabs and blanks are highlighted, which are in
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
81 ;; the region from (point) - (window-heigh) to (point) + (window-heigh)."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
82
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
83 ;;; Code:
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
84
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
85 (provide 'whitespace-mode)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
86 (require 'adapt)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
87
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
88 ;;; variables:
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
89
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 100
diff changeset
90 (defgroup whitespace nil
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 100
diff changeset
91 "Minor mode for making whitespace visible"
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 100
diff changeset
92 :group 'outlines
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 100
diff changeset
93 :group 'matching)
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 100
diff changeset
94
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 100
diff changeset
95
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 100
diff changeset
96 (defcustom whitespace-chars 'tabs-and-blanks
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
97 "*Determines, which whitespaces are highlighted.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
98 Valid values are:
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
99 'tabs-and-blanks => tabs and blanks are highlighted;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
100 'tabs => only tabs are highlighted;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
101 'blanks => only blanks are highlighted;.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
102
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
103 Changing this variable during the whitespace-*-mode is active could lead
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 100
diff changeset
104 to wrong highlighted whitespaces."
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 100
diff changeset
105 :type '(radio (const tabs-and-blanks)
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 100
diff changeset
106 (const tabs)
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 100
diff changeset
107 (const blanks))
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 100
diff changeset
108 :group 'whitespace)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
109
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
110 (make-variable-buffer-local 'whitespace-chars)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
111
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 100
diff changeset
112 (defcustom whitespace-mode-hook nil
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 100
diff changeset
113 "*Run after the `whitespace-mode' is switched on."
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 100
diff changeset
114 :type 'hook
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 100
diff changeset
115 :group 'whitespace)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
116
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 100
diff changeset
117 (defcustom whitespace-incremental-mode-hook nil
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 100
diff changeset
118 "*Run after the `whitespace-incremental-mode' is switched on."
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 100
diff changeset
119 :type 'hook
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 100
diff changeset
120 :group 'whitespace)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
121
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
122
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
123 (if (adapt-xemacsp)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
124 (progn
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
125
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 100
diff changeset
126 (defcustom whitespace-install-toolbar-icon nil
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
127 "Set it to t, if a toolbar icon should be installed during loading this file.
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 100
diff changeset
128 The icon calls the function 'whitespace-toolbar-function'."
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 100
diff changeset
129 :type 'boolean
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 100
diff changeset
130 :group 'whitespace)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
131
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 100
diff changeset
132 (defcustom whitespace-install-submenu nil
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 100
diff changeset
133 "Set it to t, if a submenu should be installed during loading this file."
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 100
diff changeset
134 :type 'boolean
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 100
diff changeset
135 :group 'whitespace)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
136
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
137 ))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
138
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
139
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 100
diff changeset
140 (defcustom whitespace-toolbar-function 'whitespace-incremental-mode
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
141 "*The toolbar icon for the whitespace mode calls this function.
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 100
diff changeset
142 Valid values are: 'whitespace--mode and 'whitespace-incremental-mode."
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 100
diff changeset
143 :type 'function
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 100
diff changeset
144 :group 'whitespace)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
145
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 100
diff changeset
146 (defcustom whitespace-blank-and-tab-search-string "\\( \\)\\|\\(\t\\)"
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 100
diff changeset
147 "The regexp used to search for tabs and blanks."
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 100
diff changeset
148 :type 'regexp
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 100
diff changeset
149 :group 'whitespace)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
150
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 100
diff changeset
151 (defcustom whitespace-tab-search-string "\t"
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 100
diff changeset
152 "The search string used to find tabs."
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 100
diff changeset
153 :type 'string
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 100
diff changeset
154 :group 'whitespace)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
155
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 100
diff changeset
156 (defcustom whitespace-blank-search-string " "
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 100
diff changeset
157 "The search string used to find blanks."
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 100
diff changeset
158 :type 'string
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 100
diff changeset
159 :group 'whitespace)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
160
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 100
diff changeset
161 (defface whitespace-blank-face
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 100
diff changeset
162 '((t
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 100
diff changeset
163 (:background "LightBlue1")))
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 100
diff changeset
164 "Face to show blanks with"
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 100
diff changeset
165 :group 'whitespace)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
166
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 100
diff changeset
167 (defface whitespace-tab-face
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 100
diff changeset
168 '((t
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 100
diff changeset
169 (:background "yellow" :underline t)))
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 100
diff changeset
170 "Face to show TABs with"
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 100
diff changeset
171 :group 'whitespace)
100
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
172
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
173 (defun whitespace-show-faces ()
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
174 "Shows the faces used by the `whitespace-mode'."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
175 (interactive)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
176 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
177 (let ((actual-buffer-name (buffer-name (current-buffer)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
178 (actual-whitespace-chars whitespace-chars)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
179 (whitespace-mode-active (or whitespace-mode
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
180 whitespace-incremental-mode))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
181 (buffer (get-buffer-create "*Help*")))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
182 (set-buffer buffer)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
183 (setq whitespace-chars actual-whitespace-chars)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
184 (delete-region (point-min) (point-max))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
185 (insert "In the whitespace minor mode\n"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
186 " this \" ")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
187 (whitespace-highlight-region (1- (point)) (point))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
188 (insert "\" is a blank, highlighted with `whitespace-blank-face' and\n"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
189 " this \"\t")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
190 (whitespace-highlight-region (1- (point)) (point))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
191 (insert "\" is a tab, highlighted with `whitespace-tab-face'.")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
192
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
193 (newline 2)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
194 (if (eq whitespace-chars 'blanks)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
195 (insert
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
196 "The highlighting of tabs is switched off.\n")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
197 (if (eq whitespace-chars 'tabs)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
198 (insert
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
199 "The highlighting of blanks is switched off.\n")))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
200 (newline)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
201 (if whitespace-mode-active
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
202 (insert "A whitespace minor mode is active in the buffer\n "
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
203 actual-buffer-name
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
204 ".\n")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
205 (insert "No whitespace minor mode is active in the buffer\n "
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
206 actual-buffer-name
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
207 ".\n"))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
208 (show-temp-buffer-in-current-frame buffer)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
209 )))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
210
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
211 ;;;
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
212 (defun whitespace-highlight-chars-in-region (char-string from to face)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
213 "Highlights the CHAR-STRING in the region from FROM to TO with the FACE."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
214 (while (search-forward char-string end t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
215 (let ((extent))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
216 (cond ((match-beginning 0)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
217 (setq extent (make-extent (match-beginning 0) (match-end 0)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
218 (set-extent-face extent face)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
219 ))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
220 (set-extent-property extent 'start-open t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
221 (set-extent-property extent 'end-open t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
222 )))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
223
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
224 (defun whitespace-highlight-region (from to)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
225 "Highlights the whitespaces in the region from FROM to TO."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
226 (let ((start (min from to))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
227 (end (max from to)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
228 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
229 ;; (message "Highlighting tabs and blanks...")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
230 (goto-char start)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
231 (cond ((eq whitespace-chars 'tabs-and-blanks)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
232 (while (search-forward-regexp
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
233 whitespace-blank-and-tab-search-string end t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
234 (let ((extent))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
235 (cond ((match-beginning 1) ; blanks ?
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
236 (setq extent (make-extent (match-beginning 1)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
237 (match-end 1)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
238 (set-extent-face extent 'whitespace-blank-face)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
239 )
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
240 ((match-beginning 2) ; tabs ?
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
241 (setq extent (make-extent (match-beginning 2)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
242 (match-end 2)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
243 (set-extent-face extent 'whitespace-tab-face)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
244 )
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
245 )
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
246 (set-extent-property extent 'start-open t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
247 (set-extent-property extent 'end-open t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
248 )))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
249 ((eq whitespace-chars 'tabs)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
250 (whitespace-highlight-chars-in-region whitespace-tab-search-string
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
251 from
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
252 to
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
253 'whitespace-tab-face))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
254 ((eq whitespace-chars 'blanks)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
255 (whitespace-highlight-chars-in-region
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
256 whitespace-blank-search-string
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
257 from
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
258 to
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
259 'whitespace-blank-face))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
260 (t (error "ERROR: Bad value of whitespace-highlight-char")))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
261 ;; (message "")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
262 )))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
263
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
264 (defun whitespace-highlight-buffer ()
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
265 "Highlights the whitespaces in the current buffer."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
266 (whitespace-highlight-region (point-min) (point-max))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
267 )
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
268
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
269 (defsubst whitespace-find-next-highlighted-region (from to)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
270 "Returns nil or the next highlighted region."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
271 (map-extents '(lambda (extent dummy)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
272 (if (extent-property extent 'whitespace-highlighted-region)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
273 extent))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
274 nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
275 from
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
276 to))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
277
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
278 (defun whitespace-incremental-highlight (from to)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
279 "Highligthts the region from FROM to TO incremental."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
280 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
281 (goto-char from)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
282 (let ((extent (extent-at (point) nil 'whitespace-highlighted-region))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
283 (next-extent nil)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
284 (start nil))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
285 (while (< (point) to)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
286 (if extent
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
287 (goto-char (extent-end-position extent)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
288 (if (< (point) to)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
289 (progn
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
290 (setq start (point))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
291
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
292 (setq next-extent (whitespace-find-next-highlighted-region
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
293 start
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
294 to))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
295 (if extent
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
296 (if next-extent
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
297 (progn
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
298 (set-extent-endpoints extent
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
299 (extent-start-position extent)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
300 (extent-end-position next-extent)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
301 )
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
302 (whitespace-highlight-region start
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
303 (1-
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
304 (extent-start-position
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
305 next-extent)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
306 (delete-extent next-extent))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
307 (set-extent-endpoints extent
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
308 (extent-start-position extent)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
309 to)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
310 (whitespace-highlight-region start to))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
311 (if next-extent
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
312 (progn
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
313 (setq extent next-extent)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
314 (whitespace-highlight-region start
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
315 (1- (extent-start-position
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
316 next-extent)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
317 (set-extent-endpoints extent
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
318 start
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
319 (extent-end-position next-extent)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
320 (setq extent (make-extent start to))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
321 (set-extent-property extent 'whitespace-highlighted-region t)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
322 (whitespace-highlight-region start to)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
323 ))))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
324
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
325
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
326 (defun whitespace-highlight-window ()
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
327 "Highlights the whitespaces in the current window."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
328 (whitespace-incremental-highlight (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
329 (forward-line (- (window-height)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
330 (point))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
331 (save-excursion
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
332 (forward-line (window-height))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
333 (point))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
334
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
335 (defun whitespace-dehighlight-region (start end)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
336 "Dehighlights the whitespaces in the region from START to END."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
337 (map-extents '(lambda (extent dummy)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
338 (if (or (eq (extent-face extent) 'whitespace-blank-face)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
339 (eq (extent-face extent) 'whitespace-tab-face)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
340 (extent-property extent
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
341 'whitespace-highlighted-region))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
342 (progn
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
343 (delete-extent extent)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
344 nil)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
345 nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
346 start
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
347 end
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
348 )
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
349 )
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
350
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
351 (defun whitespace-dehighlight-buffer ()
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
352 "Dehighlights the whitespaces in the current buffer."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
353 (whitespace-dehighlight-region (point-min) (point-max))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
354 )
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
355
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
356 (defun whitespace-highlight-after-change-function (beg end old-len)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
357 "Called, when any modification is made to buffer text. Highlights
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
358 the whitespaces (blanks and tabs) in the region from BEG to
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
359 END. OLD-LEN isn't used, but provided from the after-change hook."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
360 (if (or (eq beg end)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
361 (null whitespace-mode))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
362 nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
363 (whitespace-dehighlight-region beg end)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
364 (whitespace-highlight-region beg end)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
365
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
366 (defvar whitespace-mode nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
367 "Non-nil, if the `whitespace-mode' is active.")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
368
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
369 (make-variable-buffer-local 'whitespace-mode)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
370
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
371 (defun whitespace-mode (&optional arg)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
372 "Toggle whitespace mode.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
373 With arg, turn whitespace mode on iff arg is positive.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
374 In whitespace mode the different whitespaces (tab and blank)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
375 are highlighted with different faces. The faces are:
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
376 `whitespace-blank-face' and `whitespace-tab-face'.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
377 Use the command `whitespace-show-faces' to show their values."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
378 (interactive "P")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
379 (setq whitespace-mode
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
380 (if (null arg) (not whitespace-mode)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
381 (> (prefix-numeric-value arg) 0)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
382 (if (and whitespace-mode whitespace-incremental-mode)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
383 (progn
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
384 (whitespace-incremental-highlight (point-min) (point-max))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
385 (setq whitespace-incremental-mode nil)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
386 (remove-hook 'post-command-hook 'whitespace-highlight-window)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
387 (run-hooks 'whitespace-mode-hook)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
388 )
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
389 (setq whitespace-incremental-mode nil)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
390 (remove-hook 'post-command-hook 'whitespace-highlight-window)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
391 (redraw-modeline) ;(force-mode-line-update)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
392 (if whitespace-mode
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
393 (progn
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
394 (whitespace-highlight-buffer)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
395 (make-local-variable 'after-change-functions)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
396 (add-hook 'after-change-functions
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
397 'whitespace-highlight-after-change-function)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
398 (run-hooks 'whitespace-mode-hook))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
399 (whitespace-dehighlight-buffer)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
400 (remove-hook 'after-change-functions
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
401 'whitespace-highlight-after-change-function)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
402 (remove-hook 'post-command-hook 'whitespace-highlight-window)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
403 )))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
404
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
405 (defvar whitespace-incremental-mode nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
406 "Non-nil, if the `whitespace-incremental-mode' is active.")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
407
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
408 (make-variable-buffer-local 'whitespace-incremental-mode)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
409
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
410 (defun whitespace-incremental-mode (&optional arg)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
411 "Toggle whitespace incremental mode.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
412 With arg, turn whitespace incremental mode on iff arg is positive.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
413 In whitespace incremental mode the different whitespaces (tab and blank)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
414 are highlighted with different faces. The faces are:
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
415 `whitespace-blank-face' and `whitespace-tab-face'.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
416 Use the command `whitespace-show-faces' to show their values.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
417 In this mode only these tabs and blanks are highlighted, which are in
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
418 the region from (point) - (window-heigh) to (point) + (window-heigh)."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
419 (interactive "P")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
420 (setq whitespace-incremental-mode
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
421 (if (null arg) (not whitespace-incremental-mode)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
422 (> (prefix-numeric-value arg) 0)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
423 (if (and whitespace-mode whitespace-incremental-mode)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
424 (set-extent-property (make-extent (point-min) (point-max))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
425 'whitespace-highlighted-region
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
426 t))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
427 (setq whitespace-mode nil)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
428 (redraw-modeline) ;(force-mode-line-update)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
429 ;(set-buffer-modified-p (buffer-modified-p)) ;No-op, but updates mode line.
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
430 (if whitespace-incremental-mode
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
431 (progn
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
432 (whitespace-highlight-window)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
433 (make-local-variable 'post-command-hook)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
434 (add-hook 'post-command-hook 'whitespace-highlight-window)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
435 (make-local-variable 'after-change-functions)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
436 (add-hook 'after-change-functions
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
437 'whitespace-highlight-after-change-function)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
438 (run-hooks 'whitespace-incremental-mode-hook))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
439 (whitespace-dehighlight-buffer)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
440 (remove-hook 'after-change-functions
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
441 'whitespace-highlight-after-change-function)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
442 (remove-hook 'post-command-hook 'whitespace-highlight-window)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
443 ))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
444
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
445
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
446 ;;; Add whitespace-mode and whitespace-incremental-mode to the minor-mode-alist
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
447
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
448 (or (assq 'whitespace-mode minor-mode-alist)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
449 (setq minor-mode-alist
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
450 (cons '(whitespace-mode " WSP") minor-mode-alist)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
451
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
452 (or (assq 'whitespace-incremental-mode minor-mode-alist)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
453 (setq minor-mode-alist
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
454 (cons '(whitespace-incremental-mode " WSPI") minor-mode-alist)))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
455
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
456
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
457 ;;; Menu for the whitespace mode
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
458
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
459 (defun whitespace-set-whitespace-chars (new-whitespace-chars)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
460 "Sets the variable `whitespace-chars' and activates the change."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
461 (interactive (list (read (completing-read "Whitespaces to highlight: "
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
462 '(("tabs-and-blanks")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
463 ("tabs")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
464 ("blanks"))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
465 nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
466 t
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
467 (symbol-name 'whitespace-chars)))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
468 (if (eq whitespace-chars new-whitespace-chars)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
469 nil ; nothing to do
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
470 (setq whitespace-chars new-whitespace-chars)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
471 (setq-default whitespace-chars new-whitespace-chars)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
472 (cond (whitespace-mode (whitespace-mode)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
473 (whitespace-mode))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
474 (whitespace-incremental-mode (whitespace-incremental-mode)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
475 (whitespace-incremental-mode))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
476 )))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
477
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
478 (defvar whitespace-menu nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
479 "A menu for the whitespace minor mode.")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
480
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
481 (setq whitespace-menu
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
482 '("Whitespace Menu"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
483 ["Highlight Whitespaces"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
484 whitespace-mode
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
485 :style toggle
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
486 :selected whitespace-mode]
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
487 ["Incremental Highlighting"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
488 whitespace-incremental-mode
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
489 :style toggle
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
490 :selected whitespace-incremental-mode
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
491 ]
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
492 "---"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
493 ["Show Whitespace Faces" whitespace-show-faces t]
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
494 "---"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
495 ["Highlight Tabs & Blanks"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
496 (whitespace-set-whitespace-chars 'tabs-and-blanks)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
497 :style radio
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
498 :selected (eq whitespace-chars 'tabs-and-blanks)]
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
499 ["Highlight Only Tabs"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
500 (whitespace-set-whitespace-chars 'tabs)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
501 :style radio
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
502 :selected (eq whitespace-chars 'tabs)]
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
503 ["Highlight Only Blanks"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
504 (whitespace-set-whitespace-chars 'blanks)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
505 :style radio
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
506 :selected (eq whitespace-chars 'blanks)]
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
507 ))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
508
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
509 (if (and (boundp 'whitespace-install-submenu) whitespace-install-submenu)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
510 (add-submenu '("Apps") whitespace-menu))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
511
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
512 ;;; Toolbar icon for the XEmacs
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
513
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
514 (if (featurep 'toolbar)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
515
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
516 (defvar toolbar-wspace-icon
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
517 (toolbar-make-button-list
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
518 "/* XPM */
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
519 static char * whitespace[] = {
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
520 \"28 28 4 1\",
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
521 \" c Gray75 s backgroundToolBarColor\",
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
522 \". c black\",
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
523 \"X c Gray60\",
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
524 \"o c white\",
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
525 \" \",
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
526 \" \",
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
527 \" \",
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
528 \" \",
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
529 \" .. . \",
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
530 \" XXX.XXXXXX . \",
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
531 \" Xoo.oooooXX . \",
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
532 \" .. .. ..o.o..oo..X... .. \",
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
533 \" . . X.o..o.ooX. X. . . \",
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
534 \" . . .oo.oo.ooX.XX. .... \",
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
535 \" ... .oo.oo.ooo.oo. . \",
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
536 \" . .Xoo.oo.ooo.oo. . . \",
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
537 \" . .Xo...o..o...o.. .. \",
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
538 \" XooooooooooooX \",
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
539 \" XooooooooooooX \",
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
540 \" .... ....ooo...ooo... .. \",
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
541 \" . . .oo.o.oo.oo.oX. . . \",
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
542 \" . .oo.ooo..oo.oX .... \",
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
543 \" .. .oo.o..o.oo.oX . \",
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
544 \" . . .oo.o.oo.oo.oX. . . \",
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
545 \" .... ...oo.....oo.. .. \",
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
546 \" .ooooooooooooX \",
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
547 \" .XXXXXXXXXXXXX \",
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
548 \" . \",
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
549 \" ... \",
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
550 \" \",
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
551 \" \",
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
552 \" \"
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
553 };")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
554 "A whitespace icon.")
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
555 )
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
556
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
557 (defun whitespace-toolbar-function ()
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
558 "Calls the function determined by `whitespace-toolbar-function'."
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
559 (interactive)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
560 (call-interactively whitespace-toolbar-function))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
561
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
562 (if (and (adapt-xemacsp)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
563 whitespace-install-toolbar-icon
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
564 (featurep 'toolbar)
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
565 (eq (device-type (selected-device)) 'x))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
566 (add-spec-list-to-specifier
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
567 default-toolbar
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
568 '((global
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
569 (nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
570 [toolbar-file-icon find-file t "Open a file" ]
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
571 [toolbar-folder-icon dired t "View directory"]
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
572 [toolbar-disk-icon save-buffer t "Save buffer" ]
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
573 [toolbar-printer-icon print-buffer t "Print buffer" ]
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
574 [toolbar-cut-icon x-kill-primary-selection t "Kill region"]
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
575 [toolbar-copy-icon x-copy-primary-selection t "Copy region"]
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
576 [toolbar-paste-icon
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
577 x-yank-clipboard-selection t "Paste from clipboard"]
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
578 [toolbar-undo-icon undo t "Undo edit" ]
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
579 [toolbar-replace-icon query-replace t "Replace text" ]
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
580 [toolbar-wspace-icon
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
581 whitespace-toolbar-function t "Toggle whitespace mode"]
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
582 nil
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
583 [toolbar-compile-icon toolbar-compile t "Compile" ]
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
584 [toolbar-debug-icon toolbar-debug t "Debug" ]
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
585 [toolbar-spell-icon toolbar-ispell t "Spellcheck" ]
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
586 [toolbar-mail-icon toolbar-mail t "Mail" ]
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
587 [toolbar-news-icon toolbar-news t "News" ]
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
588 [toolbar-info-icon toolbar-info t "Information" ]
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
589 )))))
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
590
4be1180a9e89 Import from CVS: tag r20-1b2
cvs
parents:
diff changeset
591 ;;; whitespace-mode.el ends here