diff options
| author | Lars Ingebrigtsen | 2016-04-29 17:38:26 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2016-04-29 17:38:26 +0200 |
| commit | b01dac19fba2e018100051c7b80b633727db555e (patch) | |
| tree | 232a085a7d1d885bce0980fb58f6d7ec68ed5069 | |
| parent | 0c035a742f4298b8a924de70756df730be2de989 (diff) | |
| download | emacs-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.el | 44 |
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. |
| 980 | PROMPT should not end in a space or a colon. | 980 | PROMPT should not end in a space or a colon. |
| 981 | 981 | ||
| 982 | Return DEFAULT if the user enters the empty string. | 982 | If DEFAULT is non-nil, it should be a face (a symbol) or a face |
| 983 | If DEFAULT is non-nil, it should be a single face or a list of face names | 983 | name (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). | 985 | If MULTIPLE is non-nil, the return value from this function is a |
| 986 | 986 | list of faces. Otherwise a single face is returned. | |
| 987 | If MULTIPLE is non-nil, this function uses `completing-read-multiple' | 987 | |
| 988 | to read multiple faces with \"[ \\t]*,[ \\t]*\" as the separator regexp | 988 | If the user enter the empty string at the prompt, DEFAULT is |
| 989 | and it returns a list of face names. Otherwise, it reads and returns | 989 | returned after a possible transformation according to MULTIPLE. |
| 990 | a single face name." | 990 | That is, if DEFAULT is a list and MULTIPLE is nil, the first |
| 991 | (if (and default (not (stringp default))) | 991 | element of DEFAULT is returned. If DEFAULT isn't a list, but |
| 992 | (setq default | 992 | MULTIPLE is non-nil, a one-element list containing DEFAULT is |
| 993 | (cond ((symbolp default) | 993 | returned. 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' |