/* Minibuffer input and completion.
- Copyright (C) 1985, 1986, 1992 Free Software Foundation, Inc.
+ Copyright (C) 1985, 1986, 1993 Free Software Foundation, Inc.
This file is part of GNU Emacs.
Lisp_Object map;
Lisp_Object initial;
Lisp_Object prompt;
- int backup_n;
+ Lisp_Object backup_n;
int expflag;
Lisp_Object histvar;
Lisp_Object histpos;
{
register Lisp_Object val;
int count = specpdl_ptr - specpdl;
- Lisp_Object mini_frame = WINDOW_FRAME (XWINDOW (minibuf_window));
+ Lisp_Object mini_frame;
struct gcpro gcpro1, gcpro2;
if (XTYPE (prompt) != Lisp_String)
/* If the minibuffer window is on a different frame, save that
frame's configuration too. */
+#ifdef MULTI_FRAME
+ XSET (mini_frame, Lisp_Frame, WINDOW_FRAME (XWINDOW (minibuf_window)));
if (XFRAME (mini_frame) != selected_frame)
- {
- record_unwind_protect (Fset_window_configuration,
- Fcurrent_window_configuration (mini_frame));
- }
+ record_unwind_protect (Fset_window_configuration,
+ Fcurrent_window_configuration (mini_frame));
+#endif
val = current_buffer->directory;
Fset_buffer (get_minibuffer (minibuf_level));
- current_buffer->directory = val;
- Fmake_local_variable (Qprint_escape_newlines);
- print_escape_newlines = 1;
-#ifdef MULTI_FRAME
- /* If the minibuffer window is on another frame, shift this frame's
- focus to that window, and arrange to put it back later. */
- if (XFRAME (WINDOW_FRAME (XWINDOW (minibuf_window)))
- != selected_frame)
+ /* The current buffer's default directory is usually the right thing
+ for our minibuffer here. However, if you're typing a command at
+ a minibuffer-only frame when minibuf_level is zero, then buf IS
+ the current_buffer, so reset_buffer leaves buf's default
+ directory unchanged. This is a bummer when you've just started
+ up Emacs and buf's default directory is Qnil. Here's a hack; can
+ you think of something better to do? Find another buffer with a
+ better directory, and use that one instead. */
+ if (XTYPE (val) == Lisp_String)
+ current_buffer->directory = val;
+ else
{
- record_unwind_protect (read_minibuf_unwind,
- Fcons (Fselected_frame (),
- FRAME_FOCUS_FRAME (selected_frame)));
+ Lisp_Object buf_list;
- Fredirect_frame_focus (Fselected_frame (), mini_frame);
+ for (buf_list = Vbuffer_alist;
+ CONSP (buf_list);
+ buf_list = XCONS (buf_list)->cdr)
+ {
+ Lisp_Object other_buf = XCONS (XCONS (buf_list)->car)->cdr;
+
+ if (XTYPE (XBUFFER (other_buf)->directory) == Lisp_String)
+ {
+ current_buffer->directory = XBUFFER (other_buf)->directory;
+ break;
+ }
+ }
}
- else
- record_unwind_protect (read_minibuf_unwind, Qnil);
-#else
- record_unwind_protect (read_minibuf_unwind, Qnil);
+
+#ifdef MULTI_FRAME
+ Fredirect_frame_focus (Fselected_frame (), mini_frame);
#endif
+ Fmake_local_variable (Qprint_escape_newlines);
+ print_escape_newlines = 1;
+
+ record_unwind_protect (read_minibuf_unwind, Qnil);
Vminibuf_scroll_window = selected_window;
Fset_window_buffer (minibuf_window, Fcurrent_buffer ());
/* Add the value to the appropriate history list. */
if (XTYPE (Vminibuffer_history_variable) == Lisp_Symbol
- && XSYMBOL (Vminibuffer_history_variable)->value != Qunbound)
+ && ! EQ (XSYMBOL (Vminibuffer_history_variable)->value, Qunbound))
Fset (Vminibuffer_history_variable,
Fcons (val, Fsymbol_value (Vminibuffer_history_variable)));
{
sprintf (name, " *Minibuf-%d*", depth);
buf = Fget_buffer_create (build_string (name));
+
+ /* Although the buffer's name starts with a space, undo should be
+ enabled in it. */
+ Fbuffer_enable_undo (buf);
+
XCONS (tail)->car = buf;
}
else
reset_buffer (XBUFFER (buf));
+
return buf;
}
= minibuf_save_vector[minibuf_level].history_position;
Vminibuffer_history_variable
= minibuf_save_vector[minibuf_level].history_variable;
-
-#ifdef MULTI_FRAME
- /* Redirect the focus of the frame that called the minibuffer. */
- if (CONSP (data))
- Fredirect_frame_focus (XCONS (data)->car, XCONS (data)->cdr);
-#endif
}
\f
+
+/* This comment supplies the doc string for read-from-minibuffer,
+ for make-docfile to see. We cannot put this in the real DEFUN
+ due to limits in the Unix cpp.
+
DEFUN ("read-from-minibuffer", Fread_from_minibuffer, Sread_from_minibuffer, 1, 5, 0,
"Read a string from the minibuffer, prompting with string PROMPT.\n\
If optional second arg INITIAL-CONTENTS is non-nil, it is a string\n\
In that case, HISTVAR is the history list variable to use,\n\
and HISTPOS is the initial position (the position in the list\n\
which INITIAL-CONTENTS corresponds to).\n\
- Positions are counted starting from 1 at the beginning of the list.")
+ Positions are counted starting from 1 at the beginning of the list."
+*/
+
+DEFUN ("read-from-minibuffer", Fread_from_minibuffer, Sread_from_minibuffer, 1, 5, 0,
+ 0 /* See immediately above */)
(prompt, initial_input, keymap, read, hist)
Lisp_Object prompt, initial_input, keymap, read, hist;
{
Lisp_Object Vminibuffer_completion_predicate, Qminibuffer_completion_predicate;
Lisp_Object Vminibuffer_completion_confirm, Qminibuffer_completion_confirm;
+/* This comment supplies the doc string for completing-read,
+ for make-docfile to see. We cannot put this in the real DEFUN
+ due to limits in the Unix cpp.
+
DEFUN ("completing-read", Fcompleting_read, Scompleting_read, 2, 6, 0,
"Read a string in the minibuffer, with completion.\n\
Args: PROMPT, TABLE, PREDICATE, REQUIRE-MATCH, INITIAL-INPUT, HIST.\n\
which INITIAL-CONTENTS corresponds to).\n\
Positions are counted starting from 1 at the beginning of the list.\n\
Completion ignores case if the ambient value of\n\
- `completion-ignore-case' is non-nil.")
+ `completion-ignore-case' is non-nil."
+*/
+DEFUN ("completing-read", Fcompleting_read, Scompleting_read, 2, 6, 0,
+ 0 /* See immediately above */)
(prompt, table, pred, require_match, init, hist)
Lisp_Object prompt, table, pred, require_match, init, hist;
{
{
CHECK_NUMBER (position, 0);
/* Convert to distance from end of input. */
- pos = XINT (position) - 1 - XSTRING (init)->size;
+ pos = XINT (position) - XSTRING (init)->size;
}
}
temp_echo_area_glyphs (m)
char *m;
{
- /* It's not very modular to do things this way, but then it seems
- to me that the whole echo_area_glyphs thing is a hack anyway. */
- extern char *previous_echo_glyphs;
-
int osize = ZV;
Lisp_Object oinhibit;
oinhibit = Vinhibit_quit;
- /* Clear out any old echo-area message to make way for our new
- thing. */
- echo_area_glyphs = previous_echo_glyphs = 0;
+ /* Clear out any old echo-area message to make way for our new thing. */
+ message (0);
SET_PT (osize);
insert_string (m);
if (!NILP (Vquit_flag))
{
Vquit_flag = Qnil;
- unread_command_char = Ctl ('g');
+ unread_command_events = Fcons (make_number (Ctl ('g')), Qnil);
}
Vinhibit_quit = oinhibit;
}
if (XTYPE (Vstandard_output) != Lisp_Buffer)
{
Lisp_Object tem;
- tem = Flength (elt, Qt);
+ tem = Flength (elt);
column += XINT (tem);
}
Fprinc (elt, Qnil);