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