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: Wed, 30 Jun 2010 11:09:30 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (x86_64-pc-linux-gnu)

> FWIW, anytime the default value is put into the prompt it should probably be
> quoted: `...'.  At the very least, that increases clarity in cases like this 
> and
> when the value is a string with spaces (or a trailing colon or...).
>
> In this case that would give "Describe face (default `default'):" which seems
> clear in the context of choosing a face name.

I agree that the default value quoted in the prompt is better.
So with the patch below we get:

  Describe face (default `default'):

  Customize face (default `all faces'):

=== modified file 'lisp/faces.el'
--- lisp/faces.el       2010-03-24 00:17:31 +0000
+++ lisp/faces.el       2010-06-30 08:07:21 +0000
@@ -915,13 +915,14 @@ (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
+unless DEFAULT is a string (in which case nil is returned).
 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 +961,10 @@ (defun read-face-name (prompt &optional 
     (let* ((input
            ;; Read the input.
            (completing-read-multiple
-            (if (or faces string-describing-default)
-                (format "%s (default %s): " prompt
+            (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 +972,7 @@ (defun read-face-name (prompt &optional 
           ;; Canonicalize the output.
           (output
            (cond ((or (equal input "") (equal input '("")))
-                  faces)
+                  (or faces (unless (stringp default) default)))
                  ((stringp input)
                   (mapcar 'intern (split-string input ", *" t)))
                  ((listp input)
@@ -1334,7 +1335,7 @@ (defun describe-face (face &optional fra
 If the optional argument FRAME is given, report on face FACE in that frame.
 If FRAME is t, report on the defaults for face FACE (for new frames).
 If FRAME is omitted or nil, use the selected frame."
-  (interactive (list (read-face-name "Describe face" "= `default' face" t)))
+  (interactive (list (read-face-name "Describe face" 'default t)))
   (let* ((attrs '((:family . "Family")
                  (:foundry . "Foundry")
                  (:width . "Width")

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



reply via email to

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