diff options
| author | Miles Bader | 2008-06-20 08:55:22 +0000 |
|---|---|---|
| committer | Miles Bader | 2008-06-20 08:55:22 +0000 |
| commit | cece37cf09de977a55c0577e006043e91fd44592 (patch) | |
| tree | 52fe8c64647a82f709bd28d5a9a0b5f19f0a4c12 | |
| parent | 174ba8c7d1444ee3d81f98e13f4eaddcc3a1c113 (diff) | |
| download | emacs-cece37cf09de977a55c0577e006043e91fd44592.tar.gz emacs-cece37cf09de977a55c0577e006043e91fd44592.zip | |
Tweak interface of buffer-face-mode functions
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-1262
| -rw-r--r-- | lisp/ChangeLog | 9 | ||||
| -rw-r--r-- | lisp/face-remap.el | 67 |
2 files changed, 54 insertions, 22 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index d51b093aaf8..c434c9e0b41 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,12 @@ | |||
| 1 | 2008-06-20 Miles Bader <miles@gnu.org> | ||
| 2 | |||
| 3 | * face-remap.el (face-remap-add-relative, face-remap-set-base): | ||
| 4 | Strip unnecessary list levels from SPECS. | ||
| 5 | (buffer-face-set, buffer-face-toggle): | ||
| 6 | Change argument from FACE to &rest SPECS, and strip unnecessary | ||
| 7 | list levels from SPECS. | ||
| 8 | (buffer-face-mode-invoke): Change argument from FACE to SPECS. | ||
| 9 | |||
| 1 | 2008-06-20 Jason Rumney <jasonr@gnu.org> | 10 | 2008-06-20 Jason Rumney <jasonr@gnu.org> |
| 2 | 11 | ||
| 3 | * international/fontset.el (setup-default-fontset): Specify script | 12 | * international/fontset.el (setup-default-fontset): Specify script |
diff --git a/lisp/face-remap.el b/lisp/face-remap.el index ddc9f22ddfa..961f0ae034c 100644 --- a/lisp/face-remap.el +++ b/lisp/face-remap.el | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | ;; Copyright (C) 2008 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 2008 Free Software Foundation, Inc. |
| 4 | ;; | 4 | ;; |
| 5 | ;; Author: Miles Bader <miles@gnu.org> | 5 | ;; Author: Miles Bader <miles@gnu.org> |
| 6 | ;; Keywords: faces face display user commands | 6 | ;; Keywords: faces face remapping display user commands |
| 7 | ;; | 7 | ;; |
| 8 | ;; This file is part of GNU Emacs. | 8 | ;; This file is part of GNU Emacs. |
| 9 | ;; | 9 | ;; |
| @@ -121,6 +121,8 @@ after entries with absolute face-attributes. | |||
| 121 | The base (lowest priority) remapping may be set to a specific | 121 | The base (lowest priority) remapping may be set to a specific |
| 122 | value, instead of the default of the global face definition, | 122 | value, instead of the default of the global face definition, |
| 123 | using `face-remap-set-base'." | 123 | using `face-remap-set-base'." |
| 124 | (while (and (consp specs) (null (cdr specs))) | ||
| 125 | (setq specs (car specs))) | ||
| 124 | (make-local-variable 'face-remapping-alist) | 126 | (make-local-variable 'face-remapping-alist) |
| 125 | (let ((entry (assq face face-remapping-alist))) | 127 | (let ((entry (assq face face-remapping-alist))) |
| 126 | (when (null entry) | 128 | (when (null entry) |
| @@ -165,6 +167,8 @@ If SPECS is empty, the default base remapping is restored, which | |||
| 165 | inherits from the global definition of FACE; note that this is | 167 | inherits from the global definition of FACE; note that this is |
| 166 | different from SPECS containing a single value `nil', which does | 168 | different from SPECS containing a single value `nil', which does |
| 167 | not inherit from the global definition of FACE." | 169 | not inherit from the global definition of FACE." |
| 170 | (while (and (consp specs) (not (null (car specs))) (null (cdr specs))) | ||
| 171 | (setq specs (car specs))) | ||
| 168 | (if (or (null specs) | 172 | (if (or (null specs) |
| 169 | (and (eq (car specs) face) (null (cdr specs)))) ; default | 173 | (and (eq (car specs) face) (null (cdr specs)))) ; default |
| 170 | ;; Set entry back to default | 174 | ;; Set entry back to default |
| @@ -325,39 +329,58 @@ When enabled, the face specified by the variable | |||
| 325 | (force-window-update (current-buffer))) | 329 | (force-window-update (current-buffer))) |
| 326 | 330 | ||
| 327 | ;;;###autoload | 331 | ;;;###autoload |
| 328 | (defun buffer-face-set (face) | 332 | (defun buffer-face-set (&rest specs) |
| 329 | "Enable `buffer-face-mode', using the face FACE. | 333 | "Enable `buffer-face-mode', using face specs SPECS. |
| 330 | If FACE is nil, then `buffer-face-mode' is disabled. This | 334 | SPECS can be any value suitable for the `face' text property, |
| 331 | function will make the variable `buffer-face-mode-face' buffer | 335 | including a face name, a list of face names, or a face-attribute |
| 332 | local, and set it to FACE." | 336 | If SPECS is nil, then `buffer-face-mode' is disabled. |
| 337 | |||
| 338 | This function will make the variable `buffer-face-mode-face' | ||
| 339 | buffer local, and set it to FACE." | ||
| 333 | (interactive (list (read-face-name "Set buffer face"))) | 340 | (interactive (list (read-face-name "Set buffer face"))) |
| 334 | (if (null face) | 341 | (while (and (consp specs) (null (cdr specs))) |
| 342 | (setq specs (car specs))) | ||
| 343 | (if (null specs) | ||
| 335 | (buffer-face-mode 0) | 344 | (buffer-face-mode 0) |
| 336 | (set (make-local-variable 'buffer-face-mode-face) face) | 345 | (set (make-local-variable 'buffer-face-mode-face) specs) |
| 337 | (buffer-face-mode t))) | 346 | (buffer-face-mode t))) |
| 338 | 347 | ||
| 339 | ;;;###autoload | 348 | ;;;###autoload |
| 340 | (defun buffer-face-toggle (face) | 349 | (defun buffer-face-toggle (&rest specs) |
| 341 | "Toggle `buffer-face-mode', using the face FACE. | 350 | "Toggle `buffer-face-mode', using face specs SPECS. |
| 351 | SPECS can be any value suitable for the `face' text property, | ||
| 352 | including a face name, a list of face names, or a face-attribute | ||
| 342 | 353 | ||
| 343 | If `buffer-face-mode' is already enabled, and is currently using | 354 | If `buffer-face-mode' is already enabled, and is currently using |
| 344 | the face FACE, then it is disabled; if buffer-face-mode is | 355 | the face specs SPECS, then it is disabled; if buffer-face-mode is |
| 345 | disabled, or is enabled and currently displaying some other face, | 356 | disabled, or is enabled and currently displaying some other face, |
| 346 | then is left enabled, but the face changed to FACE. This | 357 | then is left enabled, but the face changed to reflect SPECS. |
| 347 | function will make the variable `buffer-face-mode-face' buffer | 358 | |
| 348 | local, and set it to FACE." | 359 | This function will make the variable `buffer-face-mode-face' |
| 360 | buffer local, and set it to SPECS." | ||
| 349 | (interactive (list buffer-face-mode-face)) | 361 | (interactive (list buffer-face-mode-face)) |
| 350 | (if (or (null face) | 362 | (while (and (consp specs) (null (cdr specs))) |
| 351 | (and buffer-face-mode (equal buffer-face-mode-face face))) | 363 | (setq specs (car specs))) |
| 364 | (if (or (null specs) | ||
| 365 | (and buffer-face-mode (equal buffer-face-mode-face specs))) | ||
| 352 | (buffer-face-mode 0) | 366 | (buffer-face-mode 0) |
| 353 | (set (make-local-variable 'buffer-face-mode-face) face) | 367 | (set (make-local-variable 'buffer-face-mode-face) specs) |
| 354 | (buffer-face-mode t))) | 368 | (buffer-face-mode t))) |
| 355 | 369 | ||
| 356 | (defun buffer-face-mode-invoke (face arg &optional interactive) | 370 | (defun buffer-face-mode-invoke (specs arg &optional interactive) |
| 357 | "Enable or disable `buffer-face-mode' using the face FACE, and argument ARG. | 371 | "Enable or disable `buffer-face-mode' using face specs SPECS, and argument ARG. |
| 358 | ARG is interpreted in the usual manner for minor-mode commands. | 372 | ARG controls whether the mode is enabled or disabled, and is |
| 359 | Besides the choice of face, this is the same as the `buffer-face-mode' command. | 373 | interpreted in the usual manner for minor-mode commands. |
| 360 | If INTERACTIVE is non-nil, a message will be displayed describing the result." | 374 | |
| 375 | SPECS can be any value suitable for the `face' text property, | ||
| 376 | including a face name, a list of face names, or a face-attribute | ||
| 377 | |||
| 378 | If INTERACTIVE is non-nil, a message will be displayed describing the result. | ||
| 379 | |||
| 380 | This is a wrapper function which calls just `buffer-face-set' or | ||
| 381 | `buffer-face-toggle' (depending on ARG), and prints a status | ||
| 382 | message in the echo area. In many cases one of those functions | ||
| 383 | may be more appropriate." | ||
| 361 | (let ((last-message (current-message))) | 384 | (let ((last-message (current-message))) |
| 362 | (if (or (eq arg 'toggle) (not arg)) | 385 | (if (or (eq arg 'toggle) (not arg)) |
| 363 | (buffer-face-toggle face) | 386 | (buffer-face-toggle face) |