changeset 63984:37ff9b4c3659

(read-face-name): Put the code for getting a face name from the buffer before adding the faces from the `face' property. Use `completing-read-multiple' instead of `completing-read'. Require `crm'. Add default value and post-process the returned list of faces.
author Juri Linkov <juri@jurta.org>
date Mon, 04 Jul 2005 01:03:23 +0000
parents 23c6b2acce05
children 0dc94b891de0
files lisp/faces.el
diffstat 1 files changed, 17 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/faces.el	Mon Jul 04 00:59:56 2005 +0000
+++ b/lisp/faces.el	Mon Jul 04 01:03:23 2005 +0000
@@ -869,7 +869,10 @@
         (aliasfaces nil)
         (nonaliasfaces nil)
 	faces)
-    ;; Make a list of the named faces that the `face' property uses.
+    ;; Try to get a face name from the buffer.
+    (if (memq (intern-soft (thing-at-point 'symbol)) (face-list))
+	(setq faces (list (intern-soft (thing-at-point 'symbol)))))
+    ;; Add the named faces that the `face' property uses.
     (if (and (listp faceprop)
 	     ;; Don't treat an attribute spec as a list of faces.
 	     (not (keywordp (car faceprop)))
@@ -879,10 +882,6 @@
 	      (push f faces)))
       (if (symbolp faceprop)
 	  (push faceprop faces)))
-    ;; If there are none, try to get a face name from the buffer.
-    (if (and (null faces)
-	     (memq (intern-soft (thing-at-point 'symbol)) (face-list)))
-	(setq faces (list (intern-soft (thing-at-point 'symbol)))))
 
     ;; Build up the completion tables.
     (mapatoms (lambda (s)
@@ -896,22 +895,27 @@
     (unless multiple
       (if faces
 	  (setq faces (list (car faces)))))
+    (require 'crm)
     (let* ((input
 	    ;; Read the input.
-	    (completing-read
+	    (completing-read-multiple
 	     (if (or faces string-describing-default)
 		 (format "%s (default %s): " prompt
-			 (if faces (mapconcat 'symbol-name faces ", ")
+			 (if faces (mapconcat 'symbol-name faces ",")
 			   string-describing-default))
 	       (format "%s: " prompt))
-	     (complete-in-turn nonaliasfaces aliasfaces) nil t))
+	     (complete-in-turn nonaliasfaces aliasfaces)
+	     nil t nil nil
+	     (if faces (mapconcat 'symbol-name faces ","))))
 	   ;; Canonicalize the output.
 	   (output
-	    (if (equal input "")
-		faces
-	      (if (stringp input)
-		  (list (intern input))
-		input))))
+	    (cond ((or (equal input "") (equal input '("")))
+		   faces)
+		  ((stringp input)
+		   (mapcar 'intern (split-string input ", *" t)))
+		  ((listp input)
+		   (mapcar 'intern input))
+		  (input))))
       ;; Return either a list of faces or just one face.
       (if multiple
 	  output