* facemenu.el (facemenu-read-color): Use a completion function

that accepts any defined color, such as RGB triplets (Bug#3677).
This commit is contained in:
Chong Yidong
2009-08-16 05:25:21 +00:00
parent 2ec536de94
commit daad00fc06
2 changed files with 14 additions and 5 deletions

View File

@@ -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).

View File

@@ -460,11 +460,17 @@ These special properties include `invisible', `intangible' and `read-only'."
(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)))