[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Patch: Follow convention for reading with the minibuffer.
From: |
Juri Linkov |
Subject: |
Re: Patch: Follow convention for reading with the minibuffer. |
Date: |
Thu, 08 Sep 2005 09:54:47 +0300 |
User-agent: |
Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux) |
> 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/
Re: Patch: Follow convention for reading with the minibuffer., Emilio Lopes, 2005/09/11