changeset 104294:6ee860194ef5

* facemenu.el (facemenu-read-color): Use a completion function that accepts any defined color, such as RGB triplets (Bug#3677).
author Chong Yidong <cyd@stupidchicken.com>
date Sun, 16 Aug 2009 05:25:21 +0000
parents 012ded1c9caf
children f03494acbd1b
files lisp/ChangeLog lisp/facemenu.el
diffstat 2 files changed, 14 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Sun Aug 16 03:16:33 2009 +0000
+++ b/lisp/ChangeLog	Sun Aug 16 05:25:21 2009 +0000
@@ -1,5 +1,8 @@
 2009-08-16  Chong Yidong  <cyd@stupidchicken.com>
 
+	* facemenu.el (facemenu-read-color): Use a completion function
+	that accepts any defined color, such as RGB triplets (Bug#3677).
+
 	* files.el (get-free-disk-space): Change fallback default
 	directory to /.  Expand DIR argument before switching to fallback.
 	Suggested by Kevin Ryde (Bug#2631, Bug#3911).
--- a/lisp/facemenu.el	Sun Aug 16 03:16:33 2009 +0000
+++ b/lisp/facemenu.el	Sun Aug 16 05:25:21 2009 +0000
@@ -460,11 +460,17 @@
 (defun facemenu-read-color (&optional prompt)
   "Read a color using the minibuffer."
   (let* ((completion-ignore-case t)
-	 (require-match (not (eq window-system 'ns)))
-	 (col (completing-read (or prompt "Color: ")
-			       (or facemenu-color-alist
-				   (defined-colors))
-			       nil require-match)))
+	 (color-list (or facemenu-color-alist (defined-colors)))
+	 (completer
+	  (lambda (string pred all-completions)
+	    (if all-completions
+		(or (all-completions string color-list pred)
+		    (if (color-defined-p string)
+			(list string)))
+	      (or (try-completion string color-list pred)
+		  (if (color-defined-p string)
+		      string)))))
+	 (col (completing-read (or prompt "Color: ") completer nil t)))
     (if (equal "" col)
 	nil
       col)))