diff options
| author | Roland Winkler | 2013-04-27 12:01:17 -0500 |
|---|---|---|
| committer | Roland Winkler | 2013-04-27 12:01:17 -0500 |
| commit | c46da66964f894dd752709bb3b7a6db571a1063d (patch) | |
| tree | 04c61676a3f2e72f74778197cfcc39fafa5d2e70 | |
| parent | a81ee1eb7b6160fe188328e14a4e1239596c6af8 (diff) | |
| download | emacs-c46da66964f894dd752709bb3b7a6db571a1063d.tar.gz emacs-c46da66964f894dd752709bb3b7a6db571a1063d.zip | |
read-face-name: Use completing-read if arg multiple is nil
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/faces.el | 57 |
2 files changed, 36 insertions, 26 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 6ae6e33824c..a90fda0b660 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2013-04-20 Roland Winkler <winkler@gnu.org> | ||
| 2 | |||
| 3 | * faces.el (read-face-name): Use completing-read if arg multiple | ||
| 4 | is nil. | ||
| 5 | |||
| 1 | 2013-04-27 Ingo Lohmar <i.lohmar@gmail.com> (tiny change) | 6 | 2013-04-27 Ingo Lohmar <i.lohmar@gmail.com> (tiny change) |
| 2 | 7 | ||
| 3 | * ls-lisp.el (ls-lisp-insert-directory): If no files are | 8 | * ls-lisp.el (ls-lisp-insert-directory): If no files are |
diff --git a/lisp/faces.el b/lisp/faces.el index 6179ed7dfa7..80f34d4569a 100644 --- a/lisp/faces.el +++ b/lisp/faces.el | |||
| @@ -938,19 +938,14 @@ of the default face. Value is FACE." | |||
| 938 | PROMPT should not end in a space or a colon. | 938 | PROMPT should not end in a space or a colon. |
| 939 | 939 | ||
| 940 | Return DEFAULT if the user enters the empty string. | 940 | Return DEFAULT if the user enters the empty string. |
| 941 | If DEFAULT is non-nil, it should be a list of face names (symbols or strings). | 941 | If DEFAULT is non-nil, it should be a single face or a list of face names |
| 942 | In that case, return the `car' of DEFAULT (if MULTIPLE is non-nil), | 942 | \(symbols or strings). In the latter case, return the `car' of DEFAULT |
| 943 | or DEFAULT (if MULTIPLE is nil). See below for the meaning of MULTIPLE. | 943 | \(if MULTIPLE is nil, see below), or DEFAULT (if MULTIPLE is non-nil). |
| 944 | DEFAULT can also be a single face. | 944 | |
| 945 | 945 | If MULTIPLE is non-nil, this function uses `completing-read-multiple' | |
| 946 | This function uses `completing-read-multiple' with \"[ \\t]*,[ \\t]*\" | 946 | to read multiple faces with \"[ \\t]*,[ \\t]*\" as the separator regexp |
| 947 | as the separator regexp. Thus, the user may enter multiple face names, | 947 | and it returns a list of face names. Otherwise, it reads and returns |
| 948 | separated by commas. | 948 | a single face name." |
| 949 | |||
| 950 | MULTIPLE specifies the form of the return value. If MULTIPLE is non-nil, | ||
| 951 | return a list of face names; if the user entered just one face name, | ||
| 952 | return a list of one face name. Otherwise, return a single face name; | ||
| 953 | if the user entered more than one face name, return only the first one." | ||
| 954 | (if (and default (not (stringp default))) | 949 | (if (and default (not (stringp default))) |
| 955 | (setq default | 950 | (setq default |
| 956 | (cond ((symbolp default) | 951 | (cond ((symbolp default) |
| @@ -961,26 +956,36 @@ if the user entered more than one face name, return only the first one." | |||
| 961 | ;; If we only want one, and the default is more than one, | 956 | ;; If we only want one, and the default is more than one, |
| 962 | ;; discard the unwanted ones. | 957 | ;; discard the unwanted ones. |
| 963 | (t (symbol-name (car default)))))) | 958 | (t (symbol-name (car default)))))) |
| 964 | 959 | (if (and default (not multiple)) | |
| 965 | (let (aliasfaces nonaliasfaces faces) | 960 | ;; For compatibility with `completing-read-multiple' use `crm-separator' |
| 961 | ;; to define DEFAULT if MULTIPLE is nil. | ||
| 962 | (setq default (car (split-string default crm-separator t)))) | ||
| 963 | |||
| 964 | (let ((prompt (if default | ||
| 965 | (format "%s (default `%s'): " prompt default) | ||
| 966 | (format "%s: " prompt))) | ||
| 967 | aliasfaces nonaliasfaces faces) | ||
| 966 | ;; Build up the completion tables. | 968 | ;; Build up the completion tables. |
| 967 | (mapatoms (lambda (s) | 969 | (mapatoms (lambda (s) |
| 968 | (if (facep s) | 970 | (if (facep s) |
| 969 | (if (get s 'face-alias) | 971 | (if (get s 'face-alias) |
| 970 | (push (symbol-name s) aliasfaces) | 972 | (push (symbol-name s) aliasfaces) |
| 971 | (push (symbol-name s) nonaliasfaces))))) | 973 | (push (symbol-name s) nonaliasfaces))))) |
| 972 | (dolist (face (completing-read-multiple | 974 | (if multiple |
| 973 | (if default | 975 | (progn |
| 974 | (format "%s (default `%s'): " prompt default) | 976 | (dolist (face (completing-read-multiple |
| 975 | (format "%s: " prompt)) | 977 | prompt |
| 978 | (completion-table-in-turn nonaliasfaces aliasfaces) | ||
| 979 | nil t nil 'face-name-history default)) | ||
| 980 | ;; Ignore elements that are not faces | ||
| 981 | ;; (for example, because DEFAULT was "all faces") | ||
| 982 | (if (facep face) (push (intern face) faces))) | ||
| 983 | (nreverse faces)) | ||
| 984 | (let ((face (completing-read | ||
| 985 | prompt | ||
| 976 | (completion-table-in-turn nonaliasfaces aliasfaces) | 986 | (completion-table-in-turn nonaliasfaces aliasfaces) |
| 977 | nil t nil 'face-name-history default)) | 987 | nil t nil 'face-name-history default))) |
| 978 | ;; Ignore elements that are not faces | 988 | (if (facep face) (intern face)))))) |
| 979 | ;; (for example, because DEFAULT was "all faces") | ||
| 980 | (if (facep face) (push (intern face) faces))) | ||
| 981 | ;; Return either a list of faces or just one face. | ||
| 982 | (setq faces (nreverse faces)) | ||
| 983 | (if multiple faces (car faces)))) | ||
| 984 | 989 | ||
| 985 | ;; Not defined without X, but behind window-system test. | 990 | ;; Not defined without X, but behind window-system test. |
| 986 | (defvar x-bitmap-file-path) | 991 | (defvar x-bitmap-file-path) |