Tweak interface of buffer-face-mode functions

Revision: emacs@sv.gnu.org/emacs--devo--0--patch-1262
This commit is contained in:
Miles Bader 2008-06-20 08:55:22 +00:00
parent 174ba8c7d1
commit cece37cf09
2 changed files with 54 additions and 22 deletions

View file

@ -1,3 +1,12 @@
2008-06-20 Miles Bader <miles@gnu.org>
* face-remap.el (face-remap-add-relative, face-remap-set-base):
Strip unnecessary list levels from SPECS.
(buffer-face-set, buffer-face-toggle):
Change argument from FACE to &rest SPECS, and strip unnecessary
list levels from SPECS.
(buffer-face-mode-invoke): Change argument from FACE to SPECS.
2008-06-20 Jason Rumney <jasonr@gnu.org> 2008-06-20 Jason Rumney <jasonr@gnu.org>
* international/fontset.el (setup-default-fontset): Specify script * international/fontset.el (setup-default-fontset): Specify script

View file

@ -3,7 +3,7 @@
;; Copyright (C) 2008 Free Software Foundation, Inc. ;; Copyright (C) 2008 Free Software Foundation, Inc.
;; ;;
;; Author: Miles Bader <miles@gnu.org> ;; Author: Miles Bader <miles@gnu.org>
;; Keywords: faces face display user commands ;; Keywords: faces face remapping display user commands
;; ;;
;; This file is part of GNU Emacs. ;; This file is part of GNU Emacs.
;; ;;
@ -121,6 +121,8 @@ after entries with absolute face-attributes.
The base (lowest priority) remapping may be set to a specific The base (lowest priority) remapping may be set to a specific
value, instead of the default of the global face definition, value, instead of the default of the global face definition,
using `face-remap-set-base'." using `face-remap-set-base'."
(while (and (consp specs) (null (cdr specs)))
(setq specs (car specs)))
(make-local-variable 'face-remapping-alist) (make-local-variable 'face-remapping-alist)
(let ((entry (assq face face-remapping-alist))) (let ((entry (assq face face-remapping-alist)))
(when (null entry) (when (null entry)
@ -165,6 +167,8 @@ If SPECS is empty, the default base remapping is restored, which
inherits from the global definition of FACE; note that this is inherits from the global definition of FACE; note that this is
different from SPECS containing a single value `nil', which does different from SPECS containing a single value `nil', which does
not inherit from the global definition of FACE." not inherit from the global definition of FACE."
(while (and (consp specs) (not (null (car specs))) (null (cdr specs)))
(setq specs (car specs)))
(if (or (null specs) (if (or (null specs)
(and (eq (car specs) face) (null (cdr specs)))) ; default (and (eq (car specs) face) (null (cdr specs)))) ; default
;; Set entry back to default ;; Set entry back to default
@ -325,39 +329,58 @@ When enabled, the face specified by the variable
(force-window-update (current-buffer))) (force-window-update (current-buffer)))
;;;###autoload ;;;###autoload
(defun buffer-face-set (face) (defun buffer-face-set (&rest specs)
"Enable `buffer-face-mode', using the face FACE. "Enable `buffer-face-mode', using face specs SPECS.
If FACE is nil, then `buffer-face-mode' is disabled. This SPECS can be any value suitable for the `face' text property,
function will make the variable `buffer-face-mode-face' buffer including a face name, a list of face names, or a face-attribute
local, and set it to FACE." If SPECS is nil, then `buffer-face-mode' is disabled.
This function will make the variable `buffer-face-mode-face'
buffer local, and set it to FACE."
(interactive (list (read-face-name "Set buffer face"))) (interactive (list (read-face-name "Set buffer face")))
(if (null face) (while (and (consp specs) (null (cdr specs)))
(setq specs (car specs)))
(if (null specs)
(buffer-face-mode 0) (buffer-face-mode 0)
(set (make-local-variable 'buffer-face-mode-face) face) (set (make-local-variable 'buffer-face-mode-face) specs)
(buffer-face-mode t))) (buffer-face-mode t)))
;;;###autoload ;;;###autoload
(defun buffer-face-toggle (face) (defun buffer-face-toggle (&rest specs)
"Toggle `buffer-face-mode', using the face FACE. "Toggle `buffer-face-mode', using face specs SPECS.
SPECS can be any value suitable for the `face' text property,
including a face name, a list of face names, or a face-attribute
If `buffer-face-mode' is already enabled, and is currently using If `buffer-face-mode' is already enabled, and is currently using
the face FACE, then it is disabled; if buffer-face-mode is the face specs SPECS, then it is disabled; if buffer-face-mode is
disabled, or is enabled and currently displaying some other face, disabled, or is enabled and currently displaying some other face,
then is left enabled, but the face changed to FACE. This then is left enabled, but the face changed to reflect SPECS.
function will make the variable `buffer-face-mode-face' buffer
local, and set it to FACE." This function will make the variable `buffer-face-mode-face'
buffer local, and set it to SPECS."
(interactive (list buffer-face-mode-face)) (interactive (list buffer-face-mode-face))
(if (or (null face) (while (and (consp specs) (null (cdr specs)))
(and buffer-face-mode (equal buffer-face-mode-face face))) (setq specs (car specs)))
(if (or (null specs)
(and buffer-face-mode (equal buffer-face-mode-face specs)))
(buffer-face-mode 0) (buffer-face-mode 0)
(set (make-local-variable 'buffer-face-mode-face) face) (set (make-local-variable 'buffer-face-mode-face) specs)
(buffer-face-mode t))) (buffer-face-mode t)))
(defun buffer-face-mode-invoke (face arg &optional interactive) (defun buffer-face-mode-invoke (specs arg &optional interactive)
"Enable or disable `buffer-face-mode' using the face FACE, and argument ARG. "Enable or disable `buffer-face-mode' using face specs SPECS, and argument ARG.
ARG is interpreted in the usual manner for minor-mode commands. ARG controls whether the mode is enabled or disabled, and is
Besides the choice of face, this is the same as the `buffer-face-mode' command. interpreted in the usual manner for minor-mode commands.
If INTERACTIVE is non-nil, a message will be displayed describing the result."
SPECS can be any value suitable for the `face' text property,
including a face name, a list of face names, or a face-attribute
If INTERACTIVE is non-nil, a message will be displayed describing the result.
This is a wrapper function which calls just `buffer-face-set' or
`buffer-face-toggle' (depending on ARG), and prints a status
message in the echo area. In many cases one of those functions
may be more appropriate."
(let ((last-message (current-message))) (let ((last-message (current-message)))
(if (or (eq arg 'toggle) (not arg)) (if (or (eq arg 'toggle) (not arg))
(buffer-face-toggle face) (buffer-face-toggle face)