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: Patch: Follow convention for reading with the minibuffer. Date: Thu, 08 Sep 2005 09:54:47 +0300 Organization: JURTA Message-ID: <87ek80cat2.fsf@jurta.org> References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1126164351 29146 80.91.229.2 (8 Sep 2005 07:25:51 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 8 Sep 2005 07:25:51 +0000 (UTC) Cc: monnier@iro.umontreal.ca, eclig@gmx.net, emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Sep 08 09:25:45 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1EDGku-0003KI-QF for ged-emacs-devel@m.gmane.org; Thu, 08 Sep 2005 09:23:33 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EDGkt-0006xh-UG for ged-emacs-devel@m.gmane.org; Thu, 08 Sep 2005 03:23:32 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1EDGfh-0005jT-0O for emacs-devel@gnu.org; Thu, 08 Sep 2005 03:18:09 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1EDGfW-0005hC-J0 for emacs-devel@gnu.org; Thu, 08 Sep 2005 03:18:02 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EDGfU-0005UI-S7 for emacs-devel@gnu.org; Thu, 08 Sep 2005 03:17:56 -0400 Original-Received: from [194.126.101.123] (helo=mail.neti.ee) by monty-python.gnu.org with esmtp (Exim 4.34) id 1EDGQE-0006NX-6F; Thu, 08 Sep 2005 03:02:10 -0400 Original-Received: from mail.neti.ee (80-235-34-189-dsl.mus.estpak.ee [80.235.34.189]) by Relayhost1.neti.ee (Postfix) with ESMTP id DCAB41EB1; Thu, 8 Sep 2005 09:57:42 +0300 (EEST) Original-To: rms@gnu.org In-Reply-To: (Richard M. Stallman's message of "Wed, 07 Sep 2005 22:42:02 -0400") User-Agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux) X-Virus-Scanned: by amavisd-new-2.2.1 (20041222) (Debian) at neti.ee 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:42744 Archived-At: > Putting the colon at the end is definitely better. Can someone fix > C-x b to work that way? I guess the current format of the default buffer prompt was easier to implement. Finding an appropriate place in the given prompt to insert the default value is not a trivial task to do in C. As users can provide an arbitrary prompt (e.g. the example in the Emacs Lisp manual suggest using the question mark: "Buffer name? ", where the right place for the default value is just before the question mark: "Buffer name (default foo)? "), a heuristics should be used to parse the prompt and to find a place to insert the default value. Ideally, there should exist a special prompt-formatting function with two arguments: `prompt' and `default'. For example, the default function and format value would look like: (defvar prompt-default-format " (default %s): ") (defun format-prompt-default (prompt default) ;; If there is no default yet in the prompt (if (not (string-match (replace-regexp-in-string "%s" ".*" prompt-default-format nil t) prompt)) (setq prompt (replace-regexp-in-string " *\\W? *$" (format prompt-default-format default) prompt))) prompt) > PS: Actually I even prefer > > Enter the answer [42]: > > because minibuffer width is limited. > > Now that the minibuffer prompt can be continued, saving space there is > less important than it would have been before. And the word "default" > will serve to explain to new users. With the special formatting function and the format variable this would be easy to customize: (setq prompt-default-format " [%s]: ") (read-buffer "Buffer name: " "foo" t) will display the prompt: Buffer name [foo]: -- Juri Linkov http://www.jurta.org/emacs/