Hrvoje Niksic <hniksic(a)iskon.hr> writes:
Jan Vroonhof <vroonhof(a)math.ethz.ch> writes:
> Hrvoje Niksic <hniksic(a)iskon.hr> writes:
>
> > Recording zero-length input makes sense in the situations where what
> > you record really is a zero-length string. It does not make sense and
> > is annoying in the situations where just typing RET activates a
> > default.
>
> In that case typing RET to activate a default should maybe put that
> default value in the history?
Yes, that would be very very nice.
Then this would satisfy everyone.
Note with this patch applied, read-from-minibuffer returns
default value when it is given and user enters an empty
string. FSF version returns empty string instead.
Right now there's no code using this argument and XEmacs has
extra argument ABBREV-TABLE, I don't think this will raise
a compatibility problem.
1999-11-26 Yoshiki Hayashi <t90553(a)mail.ecc.u-tokyo.ac.jp>
* minibuf.el (read-from-minibuffer): Add optional argument
DEFAULT to have better mini-buffer history support.
(completing-read): Pass default to read-from-minibuffer.
(read-buffer): Pass default to completing-read.
Index: minibuf.el
===================================================================
RCS file: /usr/CVSroot/XEmacs/xemacs/lisp/minibuf.el,v
retrieving revision 1.14.2.9
diff -u -r1.14.2.9 minibuf.el
--- minibuf.el 1999/11/22 10:19:08 1.14.2.9
+++ minibuf.el 1999/11/26 08:53:27
@@ -344,7 +344,8 @@
keymap
readp
history
- abbrev-table)
+ abbrev-table
+ default)
"Read a string from the minibuffer, prompting with string PROMPT.
If optional second arg INITIAL-CONTENTS is non-nil, it is a string
to be inserted into the minibuffer before reading input.
@@ -366,6 +367,8 @@
Positions are counted starting from 1 at the beginning of the list.
Sixth arg ABBREV-TABLE, if non-nil, becomes the value of `local-abbrev-table'
in the minibuffer.
+Seventh arg DEFAULT, if non-nil, will be returned when user enters
+ an empty string.
See also the variable completion-highlight-first-word-only for control over
completion display."
@@ -490,8 +493,13 @@
(let* ((val (progn (set-buffer buffer)
(if minibuffer-exit-hook
(run-hooks 'minibuffer-exit-hook))
- (buffer-string)))
- (histval val)
+ (if (and (eq (char-after (point-min)) nil)
+ default)
+ default
+ (buffer-string))))
+ (histval (if (and default (string= val ""))
+ default
+ val))
(err nil))
(if readp
(condition-case e
@@ -784,7 +792,9 @@
minibuffer-local-completion-map
minibuffer-local-must-match-map)
nil
- history))
+ history
+ nil
+ default))
(if (and (string= ret "")
default)
default
@@ -1434,7 +1444,8 @@
result)
(while (progn
(setq result (completing-read prompt alist nil require-match
- nil 'buffer-history))
+ nil 'buffer-history
+ (if default (buffer-name default))))
(cond ((not (equal result ""))
nil)
((not require-match)
--
Yoshiki Hayashi