From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: default for read-face-name Date: Wed, 30 Jun 2010 11:09:30 +0300 Organization: JURTA Message-ID: <87bpatndqd.fsf@mail.jurta.org> References: <185018306ABA436BB6313CD88A023B70@us.oracle.com> <87k4pob1i6.fsf@mail.jurta.org> <87aaqiq3y0.fsf@mail.jurta.org> <39B12100D7FD41A68DA1AF78B58274E2@us.oracle.com> <87fx05li7t.fsf@mail.jurta.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1277886398 7165 80.91.229.12 (30 Jun 2010 08:26:38 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 30 Jun 2010 08:26:38 +0000 (UTC) Cc: emacs-devel@gnu.org To: "Drew Adams" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Jun 30 10:26:36 2010 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OTscs-0007Uy-AR for ged-emacs-devel@m.gmane.org; Wed, 30 Jun 2010 10:26:36 +0200 Original-Received: from localhost ([127.0.0.1]:53750 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OTscp-0002hZ-PY for ged-emacs-devel@m.gmane.org; Wed, 30 Jun 2010 04:26:31 -0400 Original-Received: from [140.186.70.92] (port=38333 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OTsc3-0002Of-R2 for emacs-devel@gnu.org; Wed, 30 Jun 2010 04:25:45 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OTsc1-0001fw-Vr for emacs-devel@gnu.org; Wed, 30 Jun 2010 04:25:43 -0400 Original-Received: from smtp-out1.starman.ee ([85.253.0.3]:56997 helo=mx1.starman.ee) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OTsc1-0001fk-JG for emacs-devel@gnu.org; Wed, 30 Jun 2010 04:25:41 -0400 X-Virus-Scanned: by Amavisd-New at mx1.starman.ee Original-Received: from mail.starman.ee (82.131.97.213.cable.starman.ee [82.131.97.213]) by mx1.starman.ee (Postfix) with ESMTP id 017833F40B4; Wed, 30 Jun 2010 11:25:35 +0300 (EEST) In-Reply-To: (Drew Adams's message of "Tue, 29 Jun 2010 13:17:28 -0700") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (x86_64-pc-linux-gnu) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:126527 Archived-At: > 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/