aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2016-04-29 17:38:26 +0200
committerLars Ingebrigtsen2016-04-29 17:38:26 +0200
commitb01dac19fba2e018100051c7b80b633727db555e (patch)
tree232a085a7d1d885bce0980fb58f6d7ec68ed5069
parent0c035a742f4298b8a924de70756df730be2de989 (diff)
downloademacs-b01dac19fba2e018100051c7b80b633727db555e.tar.gz
emacs-b01dac19fba2e018100051c7b80b633727db555e.zip
Clarify `read-face-name' doc and tweak the code
* lisp/faces.el (read-face-name): Clarify the documentation and allow a mix of faces and faces names in all cases (bug#16483).
-rw-r--r--lisp/faces.el44
1 files changed, 25 insertions, 19 deletions
diff --git a/lisp/faces.el b/lisp/faces.el
index 1b97093a8c4..1ceba483a57 100644
--- a/lisp/faces.el
+++ b/lisp/faces.el
@@ -979,25 +979,31 @@ of the default face. Value is FACE."
979 "Read one or more face names, prompting with PROMPT. 979 "Read one or more face names, prompting with PROMPT.
980PROMPT should not end in a space or a colon. 980PROMPT should not end in a space or a colon.
981 981
982Return DEFAULT if the user enters the empty string. 982If DEFAULT is non-nil, it should be a face (a symbol) or a face
983If DEFAULT is non-nil, it should be a single face or a list of face names 983name (a string). It can also be a list of faces or face names.
984\(symbols or strings). In the latter case, return the `car' of DEFAULT 984
985\(if MULTIPLE is nil, see below), or DEFAULT (if MULTIPLE is non-nil). 985If MULTIPLE is non-nil, the return value from this function is a
986 986list of faces. Otherwise a single face is returned.
987If MULTIPLE is non-nil, this function uses `completing-read-multiple' 987
988to read multiple faces with \"[ \\t]*,[ \\t]*\" as the separator regexp 988If the user enter the empty string at the prompt, DEFAULT is
989and it returns a list of face names. Otherwise, it reads and returns 989returned after a possible transformation according to MULTIPLE.
990a single face name." 990That is, if DEFAULT is a list and MULTIPLE is nil, the first
991 (if (and default (not (stringp default))) 991element of DEFAULT is returned. If DEFAULT isn't a list, but
992 (setq default 992MULTIPLE is non-nil, a one-element list containing DEFAULT is
993 (cond ((symbolp default) 993returned. Otherwise, DEFAULT is returned verbatim."
994 (symbol-name default)) 994 (unless (listp default)
995 (multiple 995 (setq default (list default)))
996 (mapconcat (lambda (f) (if (symbolp f) (symbol-name f) f)) 996 (when default
997 default ", ")) 997 (setq default
998 ;; If we only want one, and the default is more than one, 998 (if multiple
999 ;; discard the unwanted ones. 999 (mapconcat (lambda (f) (if (symbolp f) (symbol-name f) f))
1000 (t (symbol-name (car default)))))) 1000 default ", ")
1001 ;; If we only want one, and the default is more than one,
1002 ;; discard the unwanted ones.
1003 (setq default (car default))
1004 (if (symbolp default)
1005 (symbol-name default)
1006 default))))
1001 (when (and default (not multiple)) 1007 (when (and default (not multiple))
1002 (require 'crm) 1008 (require 'crm)
1003 ;; For compatibility with `completing-read-multiple' use `crm-separator' 1009 ;; For compatibility with `completing-read-multiple' use `crm-separator'