Lisp_Object Vminibuffer_list;
-/* Data to remember during recursive minibuffer invocations */
+/* Data to remember during recursive minibuffer invocations. */
static Lisp_Object minibuf_save_list;
static Lisp_Object Qhistory_length;
-/* Fread_minibuffer leaves the input here as a string. */
+/* Fread_minibuffer leaves the input here as a string. */
Lisp_Object last_minibuf_string;
return Qnil;
}
+DEFUN ("active-minibuffer-window", Factive_minibuffer_window,
+ Sactive_minibuffer_window, 0, 0, 0,
+ doc: /* Return the currently active minibuffer window, or nil if none. */)
+ (void)
+{
+ return minibuf_level ? minibuf_window : Qnil;
+}
+
DEFUN ("set-minibuffer-window", Fset_minibuffer_window,
Sset_minibuffer_window, 1, 1, 0,
doc: /* Specify which minibuffer window to use for the minibuffer.
}
\f
-/* Actual minibuffer invocation. */
+/* Actual minibuffer invocation. */
static Lisp_Object read_minibuf_unwind (Lisp_Object);
static Lisp_Object run_exit_minibuf_hook (Lisp_Object);
len == size - 1 && line[len - 1] != '\n'))
{
if ((size_t) -1 / 2 < size)
- memory_full ();
+ memory_full (SIZE_MAX);
size *= 2;
line = (char *) xrealloc (line, size);
}
error ("Error reading from stdin");
}
- /* If Lisp form desired instead of string, parse it. */
+ /* If Lisp form desired instead of string, parse it. */
if (expflag)
val = string_to_object (val, CONSP (defalt) ? XCAR (defalt) : defalt);
/* Empty out the minibuffers of all frames other than the one
where we are going to display one now.
Set them to point to ` *Minibuf-0*', which is always empty. */
- empty_minibuf = Fget_buffer (build_string (" *Minibuf-0*"));
+ empty_minibuf = get_minibuffer (0);
FOR_EACH_FRAME (dummy, frame)
{
}
}
- /* If Lisp form desired instead of string, parse it. */
+ /* If Lisp form desired instead of string, parse it. */
if (expflag)
val = string_to_object (val, defalt);
/* Return a buffer to be used as the minibuffer at depth `depth'.
depth = 0 is the lowest allowed argument, and that is the value
- used for nonrecursive minibuffer invocations */
+ used for nonrecursive minibuffer invocations. */
Lisp_Object
get_minibuffer (int depth)
reset_buffer (XBUFFER (buf));
record_unwind_protect (Fset_buffer, Fcurrent_buffer ());
Fset_buffer (buf);
- Fkill_all_local_variables ();
+ if (!NILP (Ffboundp (intern ("minibuffer-inactive-mode"))))
+ call0 (intern ("minibuffer-inactive-mode"));
+ else
+ Fkill_all_local_variables ();
unbind_to (count, Qnil);
}
}
/* This function is called on exiting minibuffer, whether normally or
- not, and it restores the current window, buffer, etc. */
+ not, and it restores the current window, buffer, etc. */
static Lisp_Object
read_minibuf_unwind (Lisp_Object data)
windows_or_buffers_changed++;
XSETFASTINT (XWINDOW (window)->last_modified, 0);
XSETFASTINT (XWINDOW (window)->last_overlay_modified, 0);
+
+ /* In case the previous minibuffer displayed in this miniwindow is
+ dead, we may keep displaying this buffer (tho it's inactive), so reset it,
+ to make sure we don't leave around bindings and stuff which only
+ made sense during the read_minibuf invocation. */
+ call0 (intern ("minibuffer-inactive-mode"));
return Qnil;
}
\f
Qnil);
}
-/* Functions that use the minibuffer to read various things. */
+/* Functions that use the minibuffer to read various things. */
DEFUN ("read-string", Fread_string, Sread_string, 1, 5, 0,
doc: /* Read a string from the minibuffer, prompting with string PROMPT.
}
result = Fcompleting_read (prompt, intern ("internal-complete-buffer"),
- Qnil, require_match, Qnil, Qbuffer_name_history,
- def, Qnil);
+ Qnil, require_match, Qnil,
+ Qbuffer_name_history, def, Qnil);
}
else
{
args[1] = prompt;
args[2] = def;
args[3] = require_match;
- result = Ffuncall(4, args);
+ result = Ffuncall (4, args);
}
return unbind_to (count, result);
}
&& (!SYMBOLP (XCAR (collection))
|| NILP (XCAR (collection)))))
? list_table : function_table));
- int idx = 0, obsize = 0;
+ EMACS_INT idx = 0, obsize = 0;
int matchcount = 0;
int bindcount = -1;
Lisp_Object bucket, zero, end, tem;
while (1)
{
- /* Get the next element of the alist, obarray, or hash-table. */
- /* Exit the loop if the elements are all used up. */
+ /* Get the next element of the alist, obarray, or hash-table. */
+ /* Exit the loop if the elements are all used up. */
/* elt gets the alist element or symbol.
- eltstring gets the name to check as a completion. */
+ eltstring gets the name to check as a completion. */
if (type == list_table)
{
elt = eltstring = HASH_KEY (XHASH_TABLE (collection), idx++);
}
- /* Is this element a possible completion? */
+ /* Is this element a possible completion? */
if (SYMBOLP (eltstring))
eltstring = Fsymbol_name (eltstring);
completion_ignore_case ? Qt : Qnil),
EQ (Qt, tem)))
{
- /* Yes. */
+ /* Yes. */
Lisp_Object regexps;
/* Ignore this element if it fails to match all the regexps. */
}
/* Ignore this element if there is a predicate
- and the predicate doesn't like it. */
+ and the predicate doesn't like it. */
if (!NILP (predicate))
{
}
if (NILP (bestmatch))
- return Qnil; /* No completions found */
+ return Qnil; /* No completions found. */
/* If we are ignoring case, and there is no exact match,
and no additional text was supplied,
don't change the case of what the user typed. */
return Qt;
XSETFASTINT (zero, 0); /* Else extract the part in which */
- XSETFASTINT (end, bestmatchsize); /* all completions agree */
+ XSETFASTINT (end, bestmatchsize); /* all completions agree. */
return Fsubstring (bestmatch, zero, end);
}
\f
: NILP (collection) || (CONSP (collection)
&& (!SYMBOLP (XCAR (collection))
|| NILP (XCAR (collection))));
- int idx = 0, obsize = 0;
+ EMACS_INT idx = 0, obsize = 0;
int bindcount = -1;
Lisp_Object bucket, tem, zero;
struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
while (1)
{
- /* Get the next element of the alist, obarray, or hash-table. */
- /* Exit the loop if the elements are all used up. */
+ /* Get the next element of the alist, obarray, or hash-table. */
+ /* Exit the loop if the elements are all used up. */
/* elt gets the alist element or symbol.
- eltstring gets the name to check as a completion. */
+ eltstring gets the name to check as a completion. */
if (type == 1)
{
elt = eltstring = HASH_KEY (XHASH_TABLE (collection), idx++);
}
- /* Is this element a possible completion? */
+ /* Is this element a possible completion? */
if (SYMBOLP (eltstring))
eltstring = Fsymbol_name (eltstring);
completion_ignore_case ? Qt : Qnil),
EQ (Qt, tem)))
{
- /* Yes. */
+ /* Yes. */
Lisp_Object regexps;
/* Ignore this element if it fails to match all the regexps. */
}
/* Ignore this element if there is a predicate
- and the predicate doesn't like it. */
+ and the predicate doesn't like it. */
if (!NILP (predicate))
{
}
if (NILP (tem)) continue;
}
- /* Ok => put it on the list. */
+ /* Ok => put it on the list. */
allmatches = Fcons (eltstring, allmatches);
}
}
(Lisp_Object string, Lisp_Object collection, Lisp_Object predicate)
{
Lisp_Object regexps, tail, tem = Qnil;
- int i = 0;
+ EMACS_INT i = 0;
CHECK_STRING (string);
if (SYMBOLP (tail))
while (1)
{
- if (EQ((Fcompare_strings (string, make_number (0), Qnil,
+ if (EQ (Fcompare_strings (string, make_number (0), Qnil,
Fsymbol_name (tail),
- make_number (0) , Qnil, Qt)),
+ make_number (0) , Qnil, Qt),
Qt))
{
tem = tail;
tem = HASH_KEY (h, i);
else
for (i = 0; i < HASH_TABLE_SIZE (h); ++i)
- if (!NILP (HASH_HASH (h, i)) &&
- EQ (Fcompare_strings (string, make_number (0), Qnil,
- HASH_KEY (h, i), make_number (0) , Qnil,
- completion_ignore_case ? Qt : Qnil),
- Qt))
+ if (!NILP (HASH_HASH (h, i))
+ && EQ (Fcompare_strings (string, make_number (0), Qnil,
+ HASH_KEY (h, i), make_number (0) , Qnil,
+ completion_ignore_case ? Qt : Qnil),
+ Qt))
{
tem = HASH_KEY (h, i);
break;
return Qt;
}
+static Lisp_Object Qmetadata;
+extern Lisp_Object Qbuffer;
+
DEFUN ("internal-complete-buffer", Finternal_complete_buffer, Sinternal_complete_buffer, 3, 3, 0,
doc: /* Perform completion on buffer names.
If the argument FLAG is nil, invoke `try-completion', if it's t, invoke
`all-completions', otherwise invoke `test-completion'.
The arguments STRING and PREDICATE are as in `try-completion',
-`all-completions', and `test-completion'. */)
+`all-completions', and `test-completion'. */)
(Lisp_Object string, Lisp_Object predicate, Lisp_Object flag)
{
if (NILP (flag))
return res;
}
}
- else /* assume `lambda' */
+ else if (EQ (flag, Qlambda))
return Ftest_completion (string, Vbuffer_alist, predicate);
+ else if (EQ (flag, Qmetadata))
+ return Fcons (Qmetadata, Fcons (Fcons (Qcategory, Qbuffer), Qnil));
+ else
+ return Qnil;
}
/* Like assoc but assumes KEY is a string, and ignores case if appropriate. */
minibuf_save_list = Qnil;
staticpro (&minibuf_save_list);
- Qcompleting_read_default = intern_c_string ("completing-read-default");
- staticpro (&Qcompleting_read_default);
-
- Qcompletion_ignore_case = intern_c_string ("completion-ignore-case");
- staticpro (&Qcompletion_ignore_case);
-
- Qread_file_name_internal = intern_c_string ("read-file-name-internal");
- staticpro (&Qread_file_name_internal);
-
- Qminibuffer_default = intern_c_string ("minibuffer-default");
- staticpro (&Qminibuffer_default);
+ DEFSYM (Qcompleting_read_default, "completing-read-default");
+ DEFSYM (Qcompletion_ignore_case, "completion-ignore-case");
+ DEFSYM (Qread_file_name_internal, "read-file-name-internal");
+ DEFSYM (Qminibuffer_default, "minibuffer-default");
Fset (Qminibuffer_default, Qnil);
- Qminibuffer_completion_table = intern_c_string ("minibuffer-completion-table");
- staticpro (&Qminibuffer_completion_table);
-
- Qminibuffer_completion_confirm = intern_c_string ("minibuffer-completion-confirm");
- staticpro (&Qminibuffer_completion_confirm);
-
- Qminibuffer_completion_predicate = intern_c_string ("minibuffer-completion-predicate");
- staticpro (&Qminibuffer_completion_predicate);
+ DEFSYM (Qminibuffer_completion_table, "minibuffer-completion-table");
+ DEFSYM (Qminibuffer_completion_confirm, "minibuffer-completion-confirm");
+ DEFSYM (Qminibuffer_completion_predicate, "minibuffer-completion-predicate");
staticpro (&last_minibuf_string);
last_minibuf_string = Qnil;
- Quser_variable_p = intern_c_string ("user-variable-p");
- staticpro (&Quser_variable_p);
-
- Qminibuffer_history = intern_c_string ("minibuffer-history");
- staticpro (&Qminibuffer_history);
-
- Qbuffer_name_history = intern_c_string ("buffer-name-history");
- staticpro (&Qbuffer_name_history);
+ DEFSYM (Quser_variable_p, "user-variable-p");
+ DEFSYM (Qminibuffer_history, "minibuffer-history");
+ DEFSYM (Qbuffer_name_history, "buffer-name-history");
Fset (Qbuffer_name_history, Qnil);
- Qminibuffer_setup_hook = intern_c_string ("minibuffer-setup-hook");
- staticpro (&Qminibuffer_setup_hook);
-
- Qminibuffer_exit_hook = intern_c_string ("minibuffer-exit-hook");
- staticpro (&Qminibuffer_exit_hook);
-
- Qhistory_length = intern_c_string ("history-length");
- staticpro (&Qhistory_length);
-
- Qcurrent_input_method = intern_c_string ("current-input-method");
- staticpro (&Qcurrent_input_method);
-
- Qactivate_input_method = intern_c_string ("activate-input-method");
- staticpro (&Qactivate_input_method);
-
- Qcase_fold_search = intern_c_string ("case-fold-search");
- staticpro (&Qcase_fold_search);
+ DEFSYM (Qminibuffer_setup_hook, "minibuffer-setup-hook");
+ DEFSYM (Qminibuffer_exit_hook, "minibuffer-exit-hook");
+ DEFSYM (Qhistory_length, "history-length");
+ DEFSYM (Qcurrent_input_method, "current-input-method");
+ DEFSYM (Qactivate_input_method, "activate-input-method");
+ DEFSYM (Qcase_fold_search, "case-fold-search");
+ DEFSYM (Qmetadata, "metadata");
DEFVAR_LISP ("read-expression-history", Vread_expression_history,
doc: /* A history list for arguments that are Lisp expressions to evaluate.
For example, `eval-expression' uses this. */);
Vread_expression_history = Qnil;
- Qread_expression_history = intern_c_string ("read-expression-history");
- staticpro (&Qread_expression_history);
+ DEFSYM (Qread_expression_history, "read-expression-history");
DEFVAR_LISP ("read-buffer-function", Vread_buffer_function,
doc: /* If this is non-nil, `read-buffer' does its work by calling this function.
doc: /* Minibuffer keymap used for reading Lisp expressions. */);
Vread_expression_map = Qnil;
+ defsubr (&Sactive_minibuffer_window);
defsubr (&Sset_minibuffer_window);
defsubr (&Sread_from_minibuffer);
defsubr (&Seval_minibuffer);