emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: default for read-face-name


From: Juri Linkov
Subject: Re: default for read-face-name
Date: Fri, 25 Jun 2010 22:59:03 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (x86_64-pc-linux-gnu)

> I don't see how that is a problem.  Is such an implementation required?  Can't
> `customize-face' easily be made to use all faces without such a hack?

This is easy to do using the garbage-in/garbage-out principle.
When code will call `read-face-name' with the DEFAULT arg "all faces"
and the user types RET, it will return "all faces" as is.  Then
`customize-face' will compare the returned value with the string
"all faces".

> I would prefer to have two separate parameters, if you insist on
> retaining STRING-DESCRIBING-DEFAULT as it is (for `customize-face').
> In that case, please just add DEFAULT as a normal default value:
> a face name.

This patch changes STRING-DESCRIBING-DEFAULT to a normal default value:

=== modified file 'lisp/faces.el'
--- lisp/faces.el       2010-03-24 00:17:31 +0000
+++ lisp/faces.el       2010-06-25 19:51:14 +0000
@@ -915,13 +915,13 @@ (defun invert-face (face &optional frame
 ;;; Interactively modifying faces.
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
-(defun read-face-name (prompt &optional string-describing-default multiple)
+(defun read-face-name (prompt &optional default multiple)
   "Read a face, defaulting to the face or faces on the char after point.
 If it has the property `read-face-name', that overrides the `face' property.
 PROMPT should be a string that describes what the caller will do with the face;
 it should not end in a space.
-STRING-DESCRIBING-DEFAULT should describe what default the caller will use if
-the user just types RET; you can omit it.
+The optional argument DEFAULT provides the value to display in the
+minibuffer prompt that is returned if the user just types RET.
 If MULTIPLE is non-nil, return a list of faces (possibly only one).
 Otherwise, return a single face."
   (let ((faceprop (or (get-char-property (point) 'read-face-name)
@@ -960,10 +960,10 @@ (defun read-face-name (prompt &optional 
     (let* ((input
            ;; Read the input.
            (completing-read-multiple
-            (if (or faces string-describing-default)
+            (if (or faces default)
                 (format "%s (default %s): " prompt
                         (if faces (mapconcat 'symbol-name faces ",")
-                          string-describing-default))
+                          default))
               (format "%s: " prompt))
             (completion-table-in-turn nonaliasfaces aliasfaces)
             nil t nil 'face-name-history
@@ -971,7 +971,7 @@ (defun read-face-name (prompt &optional 
           ;; Canonicalize the output.
           (output
            (cond ((or (equal input "") (equal input '("")))
-                  faces)
+                  (or faces default))
                  ((stringp input)
                   (mapcar 'intern (split-string input ", *" t)))
                  ((listp input)

=== modified file 'lisp/cus-edit.el'
--- lisp/cus-edit.el    2010-04-20 18:52:07 +0000
+++ lisp/cus-edit.el    2010-06-25 19:51:40 +0000
@@ -1289,7 +1289,7 @@ (defun customize-face (&optional face)
 Interactively, when point is on text which has a face specified,
 suggest to customize that face, if it's customizable."
   (interactive (list (read-face-name "Customize face" "all faces" t)))
-  (if (member face '(nil ""))
+  (if (member face '(nil "" "all faces"))
       (setq face (face-list)))
   (if (and (listp face) (null (cdr face)))
       (setq face (car face)))

-- 
Juri Linkov
http://www.jurta.org/emacs/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]