* read-from-minibuffer and friends.
@ 2003-12-13 1:30 Luc Teirlinck
2003-12-13 23:15 ` Richard Stallman
0 siblings, 1 reply; 4+ messages in thread
From: Luc Teirlinck @ 2003-12-13 1:30 UTC (permalink / raw)
I am currently reading minibuf.texi. There is a small inconsistency
between the description of the functions `read-no-blanks-input',
`read-minibuffer' and `eval-minibuffer' in the Elisp manual and their
actual behavior. For all three functions it is claimed that the
optional argument INITIAL behaves exactly like in read-from-minibuffer.
This is incorrect. Hence the claim that these functions are equivalent
to the Elisp code displayed in `(elisp)Text from Minibuffer' and
`(elisp)Object from Minibuffer' is not 100% accurate either. As the
ielm run below shows, INITIAL _has_ to be a string or nil for the
three mentioned functions, but is, in addition, allowed to be a cons
of a string and an integer for `read-from-minibuffer' (and
`read-string').
The "Usage note" in `(elisp)Text from Minibuffer', nearly "deprecates"
INITIAL, so that probably there is no need to conform the three
functions to read-from-minibuffer's behavior. I will point out the
subtlety in the Elisp manual, but first I want to make sure that it
_really_ is the documentation that needs to be changed and not the
code itself.
Ielm run illustrating this:
===File ~/minibuf-ielm======================================
*** Welcome to IELM *** Type (describe-mode) for help.
ELISP> (read-from-minibuffer "Prompt: " '("123456789" . 3))
"123456789"
ELISP> (read-string "Prompt: " '("123456789" . 3))
"123456789"
ELISP> (read-no-blanks-input "Prompt: " '("123456789" . 3))
*** Eval error *** Wrong type argument: stringp, ("123456789" . 3)
ELISP> (read-minibuffer "Prompt: " '("123456789" . 3))
*** Eval error *** Wrong type argument: stringp, ("123456789" . 3)
ELISP> (eval-minibuffer "Prompt: " '("123456789" . 3))
*** Eval error *** Wrong type argument: stringp, ("123456789" . 3)
ELISP> (read-no-blanks-input "Prompt: " "123456789")
"123456789"
ELISP> (read-minibuffer "Prompt: " "123456789")
123456789
ELISP> (eval-minibuffer "Prompt: " "123456789")
123456789
ELISP>
============================================================
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: read-from-minibuffer and friends.
2003-12-13 1:30 read-from-minibuffer and friends Luc Teirlinck
@ 2003-12-13 23:15 ` Richard Stallman
2003-12-14 5:22 ` Luc Teirlinck
2003-12-15 0:23 ` Luc Teirlinck
0 siblings, 2 replies; 4+ messages in thread
From: Richard Stallman @ 2003-12-13 23:15 UTC (permalink / raw)
Cc: emacs-devel
INITIAL is not quite deprecated. It is still used by a few things
and we don't plan to change them.
I think ideally all these functions should handle INITIAL
in the same way. If it is easy to do that, please do it.
I would guess the best way is to move the handling of INITIAL
from Fread_from_minibuffer into read_minibuf.
But that's not worth a lot of work. If that turns out to have snags,
then the fallback is to document the current behavior.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: read-from-minibuffer and friends.
2003-12-13 23:15 ` Richard Stallman
@ 2003-12-14 5:22 ` Luc Teirlinck
2003-12-15 0:23 ` Luc Teirlinck
1 sibling, 0 replies; 4+ messages in thread
From: Luc Teirlinck @ 2003-12-14 5:22 UTC (permalink / raw)
Cc: emacs-devel
Richard Stallman wrote:
I think ideally all these functions should handle INITIAL
in the same way. If it is easy to do that, please do it.
I would guess the best way is to move the handling of INITIAL
from Fread_from_minibuffer into read_minibuf.
I did exactly that. `read_minibuf' only does something different
after my changes in cases where it threw an error before, so there
should be no danger of breaking existing code. I still will check a
few details before sending a patch.
Sincerely,
Luc.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: read-from-minibuffer and friends.
2003-12-13 23:15 ` Richard Stallman
2003-12-14 5:22 ` Luc Teirlinck
@ 2003-12-15 0:23 ` Luc Teirlinck
1 sibling, 0 replies; 4+ messages in thread
From: Luc Teirlinck @ 2003-12-15 0:23 UTC (permalink / raw)
Cc: emacs-devel
Richard Stallman wrote:
I think ideally all these functions should handle INITIAL
in the same way. If it is easy to do that, please do it.
I would guess the best way is to move the handling of INITIAL
from Fread_from_minibuffer into read_minibuf.
Attached is a patch that does exactly that. `read_minibuf' only does
something different after the patch in cases where it threw an error
before, so there should be no danger of breaking existing code. If
the patch seems OK, I could install it as soon as Savannah starts
functioning again.
===File ~/minibuf.c-diff====================================
*** minibuf.c.~1.262.~ Wed Nov 5 22:05:19 2003
--- minibuf.c Sun Dec 14 10:39:56 2003
***************
*** 404,413 ****
return make_buffer_string (prompt_end, PT, 1);
}
\f
! /* Read from the minibuffer using keymap MAP, initial contents INITIAL
! (a string), putting point minus BACKUP_N bytes from the end of INITIAL,
prompting with PROMPT (a string), using history list HISTVAR
! with initial position HISTPOS. (BACKUP_N should be <= 0.)
Normally return the result as a string (the text that was read),
but if EXPFLAG is nonzero, read it and return the object read.
--- 404,418 ----
return make_buffer_string (prompt_end, PT, 1);
}
\f
! /* Read from the minibuffer using keymap MAP and initial contents INITIAL,
! putting point minus BACKUP_N bytes from the end of INITIAL,
prompting with PROMPT (a string), using history list HISTVAR
! with initial position HISTPOS. INITIAL should be a string or a
! cons of a string and an integer. BACKUP_N should be <= 0, or
! Qnil, which is equivalent to 0. If INITIAL is a cons, BACKUP_N is
! ignored and replaced with an integer that puts point N characters
! from the beginning of INITIAL, where N is the CDR of INITIAL, or at
! the beginning of INITIAL if N <= 0.
Normally return the result as a string (the text that was read),
but if EXPFLAG is nonzero, read it and return the object read.
***************
*** 419,425 ****
If ALLOW_PROPS is nonzero, we do not throw away text properties.
! if INHERIT_INPUT_METHOD is nonzeor, the minibuffer inherit the
current input method. */
static Lisp_Object
--- 424,430 ----
If ALLOW_PROPS is nonzero, we do not throw away text properties.
! if INHERIT_INPUT_METHOD is nonzero, the minibuffer inherits the
current input method. */
static Lisp_Object
***************
*** 441,446 ****
--- 446,452 ----
Lisp_Object mini_frame, ambient_dir, minibuffer, input_method;
struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
Lisp_Object enable_multibyte;
+ int pos = INTEGERP (backup_n) ? XINT (backup_n) : 0;
/* String to add to the history. */
Lisp_Object histstring;
***************
*** 456,461 ****
--- 462,488 ----
cancel_hourglass ();
#endif
+ if (!NILP (initial))
+ {
+ if (CONSP (initial))
+ {
+ backup_n = Fcdr (initial);
+ initial = Fcar (initial);
+ CHECK_STRING (initial);
+ if (!NILP (backup_n))
+ {
+ CHECK_NUMBER (backup_n);
+ /* Convert to distance from end of input. */
+ if (XINT (backup_n) < 1)
+ /* A number too small means the beginning of the string. */
+ pos = - SCHARS (initial);
+ else
+ pos = XINT (backup_n) - 1 - SCHARS (initial);
+ }
+ }
+ else
+ CHECK_STRING (initial);
+ }
val = Qnil;
ambient_dir = current_buffer->directory;
input_method = Qnil;
***************
*** 482,488 ****
if (noninteractive)
{
! val = read_minibuf_noninteractive (map, initial, prompt, backup_n,
expflag, histvar, histpos, defalt,
allow_props, inherit_input_method);
UNGCPRO;
--- 509,516 ----
if (noninteractive)
{
! val = read_minibuf_noninteractive (map, initial, prompt,
! make_number (pos),
expflag, histvar, histpos, defalt,
allow_props, inherit_input_method);
UNGCPRO;
***************
*** 633,640 ****
if (!NILP (initial))
{
Finsert (1, &initial);
! if (INTEGERP (backup_n))
! Fforward_char (backup_n);
}
clear_message (1, 1);
--- 661,667 ----
if (!NILP (initial))
{
Finsert (1, &initial);
! Fforward_char (make_number (pos));
}
clear_message (1, 1);
***************
*** 884,891 ****
which INITIAL-CONTENTS corresponds to).
Positions are counted starting from 1 at the beginning of the list.
Sixth arg DEFAULT-VALUE is the default value. If non-nil, it is available
! for history commands; but `read-from-minibuffer' does NOT return DEFAULT-VALUE
! if the user enters empty input! It returns the empty string.
Seventh arg INHERIT-INPUT-METHOD, if non-nil, means the minibuffer inherits
the current input method and the setting of `enable-multibyte-characters'.
If the variable `minibuffer-allow-text-properties' is non-nil,
--- 911,919 ----
which INITIAL-CONTENTS corresponds to).
Positions are counted starting from 1 at the beginning of the list.
Sixth arg DEFAULT-VALUE is the default value. If non-nil, it is available
! for history commands; but, unless READ is non-nil, `read-from-minibuffer'
! does NOT return DEFAULT-VALUE if the user enters empty input! It returns
! the empty string.
Seventh arg INHERIT-INPUT-METHOD, if non-nil, means the minibuffer inherits
the current input method and the setting of `enable-multibyte-characters'.
If the variable `minibuffer-allow-text-properties' is non-nil,
***************
*** 895,927 ****
Lisp_Object prompt, initial_contents, keymap, read, hist, default_value;
Lisp_Object inherit_input_method;
{
- int pos = 0;
Lisp_Object histvar, histpos, position, val;
struct gcpro gcpro1;
- position = Qnil;
-
CHECK_STRING (prompt);
- if (!NILP (initial_contents))
- {
- if (CONSP (initial_contents))
- {
- position = Fcdr (initial_contents);
- initial_contents = Fcar (initial_contents);
- }
- CHECK_STRING (initial_contents);
- if (!NILP (position))
- {
- CHECK_NUMBER (position);
- /* Convert to distance from end of input. */
- if (XINT (position) < 1)
- /* A number too small means the beginning of the string. */
- pos = - SCHARS (initial_contents);
- else
- pos = XINT (position) - 1 - SCHARS (initial_contents);
- }
- }
-
if (NILP (keymap))
keymap = Vminibuffer_local_map;
else
--- 923,932 ----
***************
*** 944,950 ****
GCPRO1 (default_value);
val = read_minibuf (keymap, initial_contents, prompt,
! make_number (pos), !NILP (read),
histvar, histpos, default_value,
minibuffer_allow_text_properties,
!NILP (inherit_input_method));
--- 949,955 ----
GCPRO1 (default_value);
val = read_minibuf (keymap, initial_contents, prompt,
! Qnil, !NILP (read),
histvar, histpos, default_value,
minibuffer_allow_text_properties,
!NILP (inherit_input_method));
***************
*** 960,967 ****
Lisp_Object prompt, initial_contents;
{
CHECK_STRING (prompt);
- if (!NILP (initial_contents))
- CHECK_STRING (initial_contents);
return read_minibuf (Vminibuffer_local_map, initial_contents,
prompt, Qnil, 1, Qminibuffer_history,
make_number (0), Qnil, 0, 0);
--- 965,970 ----
***************
*** 1012,1020 ****
Lisp_Object prompt, initial, inherit_input_method;
{
CHECK_STRING (prompt);
- if (! NILP (initial))
- CHECK_STRING (initial);
-
return read_minibuf (Vminibuffer_local_ns_map, initial, prompt, Qnil,
0, Qminibuffer_history, make_number (0), Qnil, 0,
!NILP (inherit_input_method));
--- 1015,1020 ----
============================================================
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2003-12-15 0:23 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-12-13 1:30 read-from-minibuffer and friends Luc Teirlinck
2003-12-13 23:15 ` Richard Stallman
2003-12-14 5:22 ` Luc Teirlinck
2003-12-15 0:23 ` Luc Teirlinck
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.