comparison lisp/modes/whitespace-mode.el @ 134:34a5b81f86ba r20-2b1

Import from CVS: tag r20-2b1
author cvs
date Mon, 13 Aug 2007 09:30:11 +0200
parents 4be1180a9e89
children 6075d714658b
comparison
equal deleted inserted replaced
133:b27e67717092 134:34a5b81f86ba
24 24
25 ;;; Synched up with: FSF 19.34. 25 ;;; Synched up with: FSF 19.34.
26 26
27 ;;; Commentary: 27 ;;; Commentary:
28 28
29 ;; $Id: whitespace-mode.el,v 1.2 1997/02/24 01:13:44 steve Exp $ 29 ;; $Id: whitespace-mode.el,v 1.3 1997/04/19 23:21:05 steve Exp $
30 ;; Description: 30 ;; Description:
31 ;; 31 ;;
32 ;; This is a minor mode, which highlights whitespaces (blanks and 32 ;; This is a minor mode, which highlights whitespaces (blanks and
33 ;; tabs) with different faces, so that it is easier to 33 ;; tabs) with different faces, so that it is easier to
34 ;; distinguish between them. 34 ;; distinguish between them.
85 (provide 'whitespace-mode) 85 (provide 'whitespace-mode)
86 (require 'adapt) 86 (require 'adapt)
87 87
88 ;;; variables: 88 ;;; variables:
89 89
90 (defvar whitespace-chars 'tabs-and-blanks 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
91 "*Determines, which whitespaces are highlighted. 97 "*Determines, which whitespaces are highlighted.
92 Valid values are: 98 Valid values are:
93 'tabs-and-blanks => tabs and blanks are highlighted; 99 'tabs-and-blanks => tabs and blanks are highlighted;
94 'tabs => only tabs are highlighted; 100 'tabs => only tabs are highlighted;
95 'blanks => only blanks are highlighted;. 101 'blanks => only blanks are highlighted;.
96 102
97 Changing this variable during the whitespace-*-mode is active could lead 103 Changing this variable during the whitespace-*-mode is active could lead
98 to wrong highlighted whitespaces.") 104 to wrong highlighted whitespaces."
105 :type '(radio (const tabs-and-blanks)
106 (const tabs)
107 (const blanks))
108 :group 'whitespace)
99 109
100 (make-variable-buffer-local 'whitespace-chars) 110 (make-variable-buffer-local 'whitespace-chars)
101 111
102 (defvar whitespace-mode-hook nil 112 (defcustom whitespace-mode-hook nil
103 "*Run after the `whitespace-mode' is switched on.") 113 "*Run after the `whitespace-mode' is switched on."
104 114 :type 'hook
105 (defvar whitespace-incremental-mode-hook nil 115 :group 'whitespace)
106 "*Run after the `whitespace-incremental-mode' is switched on.") 116
117 (defcustom whitespace-incremental-mode-hook nil
118 "*Run after the `whitespace-incremental-mode' is switched on."
119 :type 'hook
120 :group 'whitespace)
107 121
108 122
109 (if (adapt-xemacsp) 123 (if (adapt-xemacsp)
110 (progn 124 (progn
111 125
112 (defvar whitespace-install-toolbar-icon nil 126 (defcustom whitespace-install-toolbar-icon nil
113 "Set it to t, if a toolbar icon should be installed during loading this file. 127 "Set it to t, if a toolbar icon should be installed during loading this file.
114 The icon calls the function 'whitespace-toolbar-function'.") 128 The icon calls the function 'whitespace-toolbar-function'."
115 129 :type 'boolean
116 (defvar whitespace-install-submenu nil 130 :group 'whitespace)
117 "Set it to t, if a submenu should be installed during loading this file.") 131
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)
118 136
119 )) 137 ))
120 138
121 139
122 (defvar whitespace-toolbar-function 'whitespace-incremental-mode 140 (defcustom whitespace-toolbar-function 'whitespace-incremental-mode
123 "*The toolbar icon for the whitespace mode calls this function. 141 "*The toolbar icon for the whitespace mode calls this function.
124 Valid values are: 'whitespace--mode and 'whitespace-incremental-mode.") 142 Valid values are: 'whitespace--mode and 'whitespace-incremental-mode."
125 143 :type 'function
126 (defvar whitespace-blank-and-tab-search-string "\\( \\)\\|\\(\t\\)" 144 :group 'whitespace)
127 "The regexp used to search for tabs and blanks.") 145
128 146 (defcustom whitespace-blank-and-tab-search-string "\\( \\)\\|\\(\t\\)"
129 (defvar whitespace-tab-search-string "\t" 147 "The regexp used to search for tabs and blanks."
130 "The search string used to find tabs.") 148 :type 'regexp
131 149 :group 'whitespace)
132 (defvar whitespace-blank-search-string " " 150
133 "The search string used to find blanks.") 151 (defcustom whitespace-tab-search-string "\t"
134 152 "The search string used to find tabs."
135 ;;; Defining faces 153 :type 'string
136 (if (facep 'whitespace-blank-face) 154 :group 'whitespace)
137 nil 155
138 (make-face 'whitespace-blank-face) 156 (defcustom whitespace-blank-search-string " "
139 (set-face-background 'whitespace-blank-face "LightBlue1")) 157 "The search string used to find blanks."
140 158 :type 'string
141 (if (facep 'whitespace-tab-face) 159 :group 'whitespace)
142 nil 160
143 (make-face 'whitespace-tab-face) 161 (defface whitespace-blank-face
144 (set-face-background 'whitespace-tab-face "yellow") 162 '((t
145 (set-face-underline-p 'whitespace-tab-face t)) 163 (:background "LightBlue1")))
164 "Face to show blanks with"
165 :group 'whitespace)
166
167 (defface whitespace-tab-face
168 '((t
169 (:background "yellow" :underline t)))
170 "Face to show TABs with"
171 :group 'whitespace)
146 172
147 (defun whitespace-show-faces () 173 (defun whitespace-show-faces ()
148 "Shows the faces used by the `whitespace-mode'." 174 "Shows the faces used by the `whitespace-mode'."
149 (interactive) 175 (interactive)
150 (save-excursion 176 (save-excursion