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: Fri, 25 Jun 2010 22:59:03 +0300 Organization: JURTA Message-ID: <87aaqiq3y0.fsf@mail.jurta.org> References: <185018306ABA436BB6313CD88A023B70@us.oracle.com> <87k4pob1i6.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 1277499396 18663 80.91.229.12 (25 Jun 2010 20:56:36 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 25 Jun 2010 20:56:36 +0000 (UTC) Cc: emacs-devel@gnu.org To: "Drew Adams" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Jun 25 22:56:30 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 1OSFwp-0002Og-TJ for ged-emacs-devel@m.gmane.org; Fri, 25 Jun 2010 22:56:28 +0200 Original-Received: from localhost ([127.0.0.1]:53502 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OSFwp-0003dD-AH for ged-emacs-devel@m.gmane.org; Fri, 25 Jun 2010 16:56:27 -0400 Original-Received: from [140.186.70.92] (port=40708 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OSFwZ-0003ZH-DV for emacs-devel@gnu.org; Fri, 25 Jun 2010 16:56:16 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OSFwX-0008Kf-9Z for emacs-devel@gnu.org; Fri, 25 Jun 2010 16:56:11 -0400 Original-Received: from smtp-out2.starman.ee ([85.253.0.4]:34277 helo=mx2.starman.ee) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OSFwX-0008KP-0b for emacs-devel@gnu.org; Fri, 25 Jun 2010 16:56:09 -0400 X-Virus-Scanned: by Amavisd-New at mx2.starman.ee Original-Received: from mail.starman.ee (62.65.210.19.cable.starman.ee [62.65.210.19]) by mx2.starman.ee (Postfix) with ESMTP id 9D9303F40A5; Fri, 25 Jun 2010 23:56:04 +0300 (EEST) In-Reply-To: (Drew Adams's message of "Thu, 24 Jun 2010 15:23:44 -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:126399 Archived-At: > 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/