Mercurial > emacs
comparison lisp/facemenu.el @ 12014:e4932082046a
(facemenu-special-menu): Use characters, not symbols.
Add Remove Special menu item.
(facemenu-remove-special): New function.
(facemenu-set-face-from-menu): If prefix arg, treat region as inactive.
(facemenu-set-face): Likewise.
(facemenu-keymap, facemenu-foreground-menu, facemenu-background-menu):
Add ... after Other.
(facemenu-menu): Change name to Text Properties.
(facemenu-remove-really-all): New function.
(facemenu-special-menu): Add Remove All menu item.
(facemenu-indentation-menu): Make item names clearer.
Pick new key names too.
(facemenu-menu): Split up definition.
Move `Remove All' item here.
(facemenu-special-menu): Delete `Remove All' item.
(facemenu-remove-all): Renamed from facemenu-remove-really-all.
(facemenu-remove-props): Renamed from facemenu-remove-all.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Tue, 30 May 1995 18:31:00 +0000 |
parents | f92fb9b9e3c8 |
children | 257af4819582 |
comparison
equal
deleted
inserted
replaced
12013:0d5bb768982e | 12014:e4932082046a |
---|---|
146 (defalias 'facemenu-face-menu facemenu-face-menu) | 146 (defalias 'facemenu-face-menu facemenu-face-menu) |
147 | 147 |
148 ;;;###autoload | 148 ;;;###autoload |
149 (defvar facemenu-foreground-menu | 149 (defvar facemenu-foreground-menu |
150 (let ((map (make-sparse-keymap "Foreground Color"))) | 150 (let ((map (make-sparse-keymap "Foreground Color"))) |
151 (define-key map "o" (cons "Other" 'facemenu-set-foreground)) | 151 (define-key map "o" (cons "Other..." 'facemenu-set-foreground)) |
152 map) | 152 map) |
153 "Menu keymap for foreground colors.") | 153 "Menu keymap for foreground colors.") |
154 ;;;###autoload | 154 ;;;###autoload |
155 (defalias 'facemenu-foreground-menu facemenu-foreground-menu) | 155 (defalias 'facemenu-foreground-menu facemenu-foreground-menu) |
156 | 156 |
157 ;;;###autoload | 157 ;;;###autoload |
158 (defvar facemenu-background-menu | 158 (defvar facemenu-background-menu |
159 (let ((map (make-sparse-keymap "Background Color"))) | 159 (let ((map (make-sparse-keymap "Background Color"))) |
160 (define-key map "o" (cons "Other" 'facemenu-set-background)) | 160 (define-key map "o" (cons "Other..." 'facemenu-set-background)) |
161 map) | 161 map) |
162 "Menu keymap for background colors") | 162 "Menu keymap for background colors") |
163 ;;;###autoload | 163 ;;;###autoload |
164 (defalias 'facemenu-background-menu facemenu-background-menu) | 164 (defalias 'facemenu-background-menu facemenu-background-menu) |
165 | 165 |
166 ;;;###autoload | 166 ;;;###autoload |
167 (defvar facemenu-special-menu | 167 (defvar facemenu-special-menu |
168 (let ((map (make-sparse-keymap "Special"))) | 168 (let ((map (make-sparse-keymap "Special"))) |
169 (define-key map [read-only] (cons "Read-Only" 'facemenu-set-read-only)) | 169 (define-key map [?s] (cons "Remove Special" 'facemenu-remove-special)) |
170 (define-key map [invisible] (cons "Invisible" 'facemenu-set-invisible)) | 170 (define-key map [?t] (cons "Intangible" 'facemenu-set-intangible)) |
171 (define-key map [intangible] (cons "Intangible" 'facemenu-set-intangible)) | 171 (define-key map [?v] (cons "Invisible" 'facemenu-set-invisible)) |
172 (define-key map [?r] (cons "Read-Only" 'facemenu-set-read-only)) | |
172 map) | 173 map) |
173 "Menu keymap for non-face text-properties.") | 174 "Menu keymap for non-face text-properties.") |
174 ;;;###autoload | 175 ;;;###autoload |
175 (defalias 'facemenu-special-menu facemenu-special-menu) | 176 (defalias 'facemenu-special-menu facemenu-special-menu) |
176 | 177 |
188 (defalias 'facemenu-justification-menu facemenu-justification-menu) | 189 (defalias 'facemenu-justification-menu facemenu-justification-menu) |
189 | 190 |
190 ;;;###autoload | 191 ;;;###autoload |
191 (defvar facemenu-indentation-menu | 192 (defvar facemenu-indentation-menu |
192 (let ((map (make-sparse-keymap "Indentation"))) | 193 (let ((map (make-sparse-keymap "Indentation"))) |
193 (define-key map [UnIndentRight] | 194 (define-key map [decrease-right-margin] |
194 (cons "UnIndentRight" 'decrease-right-margin)) | 195 (cons "Indent Right Less" 'decrease-right-margin)) |
195 (define-key map [IndentRight] | 196 (define-key map [increase-right-margin] |
196 (cons "IndentRight" 'increase-right-margin)) | 197 (cons "Indent Right More" 'increase-right-margin)) |
197 (define-key map [Unindent] | 198 (define-key map [decrease-left-margin] |
198 (cons "UnIndent" 'decrease-left-margin)) | 199 (cons "Indent Less" 'decrease-left-margin)) |
199 (define-key map [Indent] | 200 (define-key map [increase-left-margin] |
200 (cons "Indent" 'increase-left-margin)) | 201 (cons "Indent More" 'increase-left-margin)) |
201 map) | 202 map) |
202 "Submenu for indentation commands.") | 203 "Submenu for indentation commands.") |
203 ;;;###autoload | 204 ;;;###autoload |
204 (defalias 'facemenu-indentation-menu facemenu-indentation-menu) | 205 (defalias 'facemenu-indentation-menu facemenu-indentation-menu) |
205 | 206 |
206 ;;;###autoload | 207 ;; This is split up to avoid an overlong line in loaddefs.el. |
207 (defvar facemenu-menu | 208 ;;;###autoload |
208 (let ((map (make-sparse-keymap "Face"))) | 209 (defvar facemenu-menu nil |
209 (define-key map [dc] (cons "Display Colors" 'list-colors-display)) | |
210 (define-key map [df] (cons "Display Faces" 'list-faces-display)) | |
211 (define-key map [dp] (cons "List Properties" 'list-text-properties-at)) | |
212 (define-key map [rm] (cons "Remove Properties" 'facemenu-remove-all)) | |
213 (define-key map [s1] (list "-----------------")) | |
214 (define-key map [in] (cons "Indentation" 'facemenu-indentation-menu)) | |
215 (define-key map [ju] (cons "Justification" 'facemenu-justification-menu)) | |
216 (define-key map [s2] (list "-----------------")) | |
217 (define-key map [sp] (cons "Special Props" 'facemenu-special-menu)) | |
218 (define-key map [bg] (cons "Background Color" 'facemenu-background-menu)) | |
219 (define-key map [fg] (cons "Foreground Color" 'facemenu-foreground-menu)) | |
220 (define-key map [fc] (cons "Face" 'facemenu-face-menu)) | |
221 map) | |
222 "Facemenu top-level menu keymap.") | 210 "Facemenu top-level menu keymap.") |
211 ;;;###autoload | |
212 (setq facemenu-menu (make-sparse-keymap "Text Properties")) | |
213 ;;;###autoload | |
214 (let ((map facemenu-menu)) | |
215 (define-key map [dc] (cons "Display Colors" 'list-colors-display)) | |
216 (define-key map [df] (cons "Display Faces" 'list-faces-display)) | |
217 (define-key map [dp] (cons "List Properties" 'list-text-properties-at)) | |
218 (define-key map [ra] (cons "Remove All" 'facemenu-remove-all)) | |
219 (define-key map [rm] (cons "Remove Properties" 'facemenu-remove-props)) | |
220 (define-key map [s1] (list "-----------------"))) | |
221 ;;;###autoload | |
222 (let ((map facemenu-menu)) | |
223 (define-key map [in] (cons "Indentation" 'facemenu-indentation-menu)) | |
224 (define-key map [ju] (cons "Justification" 'facemenu-justification-menu)) | |
225 (define-key map [s2] (list "-----------------")) | |
226 (define-key map [sp] (cons "Special Props" 'facemenu-special-menu)) | |
227 (define-key map [bg] (cons "Background Color" 'facemenu-background-menu)) | |
228 (define-key map [fg] (cons "Foreground Color" 'facemenu-foreground-menu)) | |
229 (define-key map [fc] (cons "Face" 'facemenu-face-menu))) | |
223 ;;;###autoload | 230 ;;;###autoload |
224 (defalias 'facemenu-menu facemenu-menu) | 231 (defalias 'facemenu-menu facemenu-menu) |
225 | 232 |
226 (defvar facemenu-keymap | 233 (defvar facemenu-keymap |
227 (let ((map (make-sparse-keymap "Set face"))) | 234 (let ((map (make-sparse-keymap "Set face"))) |
228 (define-key map "o" (cons "Other" 'facemenu-set-face)) | 235 (define-key map "o" (cons "Other..." 'facemenu-set-face)) |
229 map) | 236 map) |
230 "Keymap for face-changing commands. | 237 "Keymap for face-changing commands. |
231 `Facemenu-update' fills in the keymap according to the bindings | 238 `Facemenu-update' fills in the keymap according to the bindings |
232 requested in `facemenu-keybindings'.") | 239 requested in `facemenu-keybindings'.") |
233 (defalias 'facemenu-keymap facemenu-keymap) | 240 (defalias 'facemenu-keymap facemenu-keymap) |
257 (defun facemenu-set-face (face &optional start end) | 264 (defun facemenu-set-face (face &optional start end) |
258 "Add FACE to the region or next character typed. | 265 "Add FACE to the region or next character typed. |
259 It will be added to the top of the face list; any faces lower on the list that | 266 It will be added to the top of the face list; any faces lower on the list that |
260 will not show through at all will be removed. | 267 will not show through at all will be removed. |
261 | 268 |
262 Interactively, the face to be used is prompted for. | 269 Interactively, the face to be used is read with the minibuffer. |
263 If the region is active, it will be set to the requested face. If | 270 |
264 it is inactive \(even if mark-even-if-inactive is set) the next | 271 If the region is active and there is no prefix argument, |
265 character that is typed \(or otherwise inserted) will be set to | 272 this command sets the region to the requested face. |
266 the selected face. Moving point or switching buffers before | 273 |
267 typing a character cancels the request." | 274 Otherwise, this command specifies the face for the next character |
275 inserted. Moving point or switching buffers before | |
276 typing a character to insert cancels the specification." | |
268 (interactive (list (read-face-name "Use face: "))) | 277 (interactive (list (read-face-name "Use face: "))) |
269 (barf-if-buffer-read-only) | 278 (barf-if-buffer-read-only) |
270 (facemenu-add-new-face face) | 279 (facemenu-add-new-face face) |
271 (if mark-active | 280 (if (and mark-active (not current-prefix-arg)) |
272 (let ((start (or start (region-beginning))) | 281 (let ((start (or start (region-beginning))) |
273 (end (or end (region-end)))) | 282 (end (or end (region-end)))) |
274 (facemenu-add-face face start end)) | 283 (facemenu-add-face face start end)) |
275 (facemenu-self-insert-face face))) | 284 (facemenu-self-insert-face face))) |
276 | 285 |
307 ;;;###autoload | 316 ;;;###autoload |
308 (defun facemenu-set-face-from-menu (face start end) | 317 (defun facemenu-set-face-from-menu (face start end) |
309 "Set the face of the region or next character typed. | 318 "Set the face of the region or next character typed. |
310 This function is designed to be called from a menu; the face to use | 319 This function is designed to be called from a menu; the face to use |
311 is the menu item's name. | 320 is the menu item's name. |
312 If the region is active, it will be set to the requested face. If | 321 |
313 it is inactive \(even if mark-even-if-inactive is set) the next | 322 If the region is active and there is no prefix argument, |
314 character that is typed \(or otherwise inserted) will be set to | 323 this command sets the region to the requested face. |
315 the selected face. Moving point or switching buffers before | 324 |
316 typing a character cancels the request." | 325 Otherwise, this command specifies the face for the next character |
326 inserted. Moving point or switching buffers before | |
327 typing a character to insert cancels the specification." | |
317 (interactive (list last-command-event | 328 (interactive (list last-command-event |
318 (if mark-active (region-beginning)) | 329 (if (and mark-active (not current-prefix-arg)) |
319 (if mark-active (region-end)))) | 330 (region-beginning)) |
331 (if (and mark-active (not current-prefix-arg)) | |
332 (region-end)))) | |
320 (barf-if-buffer-read-only) | 333 (barf-if-buffer-read-only) |
321 (facemenu-get-face face) | 334 (facemenu-get-face face) |
322 (if start | 335 (if start |
323 (facemenu-add-face face start end) | 336 (facemenu-add-face face start end) |
324 (facemenu-self-insert-face face))) | 337 (facemenu-self-insert-face face))) |
333 | 346 |
334 ;;;###autoload | 347 ;;;###autoload |
335 (defun facemenu-set-invisible (start end) | 348 (defun facemenu-set-invisible (start end) |
336 "Make the region invisible. | 349 "Make the region invisible. |
337 This sets the `invisible' text property; it can be undone with | 350 This sets the `invisible' text property; it can be undone with |
338 `facemenu-remove-all'." | 351 `facemenu-remove-special'." |
339 (interactive "r") | 352 (interactive "r") |
340 (put-text-property start end 'invisible t)) | 353 (put-text-property start end 'invisible t)) |
341 | 354 |
342 ;;;###autoload | 355 ;;;###autoload |
343 (defun facemenu-set-intangible (start end) | 356 (defun facemenu-set-intangible (start end) |
344 "Make the region intangible: disallow moving into it. | 357 "Make the region intangible: disallow moving into it. |
345 This sets the `intangible' text property; it can be undone with | 358 This sets the `intangible' text property; it can be undone with |
346 `facemenu-remove-all'." | 359 `facemenu-remove-special'." |
347 (interactive "r") | 360 (interactive "r") |
348 (put-text-property start end 'intangible t)) | 361 (put-text-property start end 'intangible t)) |
349 | 362 |
350 ;;;###autoload | 363 ;;;###autoload |
351 (defun facemenu-set-read-only (start end) | 364 (defun facemenu-set-read-only (start end) |
352 "Make the region unmodifiable. | 365 "Make the region unmodifiable. |
353 This sets the `read-only' text property; it can be undone with | 366 This sets the `read-only' text property; it can be undone with |
354 `facemenu-remove-all'." | 367 `facemenu-remove-special'." |
355 (interactive "r") | 368 (interactive "r") |
356 (put-text-property start end 'read-only t)) | 369 (put-text-property start end 'read-only t)) |
357 | 370 |
358 ;;;###autoload | 371 ;;;###autoload |
359 (defun facemenu-remove-all (start end) | 372 (defun facemenu-remove-props (start end) |
360 "Remove all text properties that facemenu added to region." | 373 "Remove all text properties that facemenu added to region." |
361 (interactive "*r") ; error if buffer is read-only despite the next line. | 374 (interactive "*r") ; error if buffer is read-only despite the next line. |
362 (let ((inhibit-read-only t)) | 375 (let ((inhibit-read-only t)) |
363 (remove-text-properties | 376 (remove-text-properties |
364 start end '(face nil invisible nil intangible nil | 377 start end '(face nil invisible nil intangible nil |
365 read-only nil category nil)))) | 378 read-only nil category nil)))) |
379 | |
380 ;;;###autoload | |
381 (defun facemenu-remove-all (start end) | |
382 "Remove all text properties from the region." | |
383 (interactive "*r") ; error if buffer is read-only despite the next line. | |
384 (let ((inhibit-read-only t)) | |
385 (set-text-properties start end nil))) | |
386 | |
387 ;;;###autoload | |
388 (defun facemenu-remove-special (start end) | |
389 "Remove all the \"special\" text properties from the region. | |
390 These special properties include `invisible', `intangible' and `read-only'." | |
391 (interactive "*r") ; error if buffer is read-only despite the next line. | |
392 (let ((inhibit-read-only t)) | |
393 (remove-text-properties | |
394 start end '(invisible nil intangible nil read-only nil)))) | |
366 | 395 |
367 ;;;###autoload | 396 ;;;###autoload |
368 (defun list-text-properties-at (p) | 397 (defun list-text-properties-at (p) |
369 "Pop up a buffer listing text-properties at LOCATION." | 398 "Pop up a buffer listing text-properties at LOCATION." |
370 (interactive "d") | 399 (interactive "d") |