/* Keymap for reading expressions. */
Lisp_Object Vread_expression_map;
+Lisp_Object Vminibuffer_completion_table, Qminibuffer_completion_table;
+Lisp_Object Vminibuffer_completion_predicate, Qminibuffer_completion_predicate;
+Lisp_Object Vminibuffer_completion_confirm, Qminibuffer_completion_confirm;
+Lisp_Object Vminibuffer_completing_file_name;
+
Lisp_Object Quser_variable_p;
Lisp_Object Qminibuffer_default;
DEFUN ("minibuffer-contents", Fminibuffer_contents,
Sminibuffer_contents, 0, 0, 0,
doc: /* Return the user input in a minibuffer as a string.
-The current buffer must be a minibuffer. */)
+If the current buffer is not a minibuffer, return its entire contents. */)
()
{
int prompt_end = XINT (Fminibuffer_prompt_end ());
DEFUN ("minibuffer-contents-no-properties", Fminibuffer_contents_no_properties,
Sminibuffer_contents_no_properties, 0, 0, 0,
doc: /* Return the user input in a minibuffer as a string, without text-properties.
-The current buffer must be a minibuffer. */)
+If the current buffer is not a minibuffer, return its entire contents. */)
()
{
int prompt_end = XINT (Fminibuffer_prompt_end ());
Sminibuffer_completion_contents, 0, 0, 0,
doc: /* Return the user input in a minibuffer before point as a string.
That is what completion commands operate on.
-The current buffer must be a minibuffer. */)
+If the current buffer is not a minibuffer, return its entire contents. */)
()
{
int prompt_end = XINT (Fminibuffer_prompt_end ());
DEFUN ("delete-minibuffer-contents", Fdelete_minibuffer_contents,
Sdelete_minibuffer_contents, 0, 0, 0,
doc: /* Delete all user input in a minibuffer.
-The current buffer must be a minibuffer. */)
+If the current buffer is not a minibuffer, erase its entire contents. */)
()
{
int prompt_end = XINT (Fminibuffer_prompt_end ());
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;
specbind (Qminibuffer_default, defalt);
+ /* If Vminibuffer_completing_file_name is `lambda' on entry, it was t
+ in previous recursive minibuffer, but was not set explicitly
+ to t for this invocation, so set it to nil in this minibuffer.
+ Save the old value now, before we change it. */
+ specbind (intern ("minibuffer-completing-file-name"), Vminibuffer_completing_file_name);
+ if (EQ (Vminibuffer_completing_file_name, Qlambda))
+ Vminibuffer_completing_file_name = Qnil;
+
single_kboard_state ();
#ifdef HAVE_X_WINDOWS
if (display_hourglass_p)
GCPRO5 (map, initial, val, ambient_dir, input_method);
if (!STRINGP (prompt))
- prompt = empty_string;
+ prompt = empty_unibyte_string;
if (!enable_recursive_minibuffers
&& minibuf_level > 0)
specpdl slots. */
minibuf_save_list
= Fcons (Voverriding_local_map,
- Fcons (minibuf_window, minibuf_save_list));
+ Fcons (minibuf_window,
+ minibuf_save_list));
minibuf_save_list
= Fcons (minibuf_prompt,
Fcons (make_number (minibuf_prompt_width),
Vminibuffer_history_position = histpos;
Vminibuffer_history_variable = histvar;
Vhelp_form = Vminibuffer_help_form;
+ /* If this minibuffer is reading a file name, that doesn't mean
+ recursive ones are. But we cannot set it to nil, because
+ completion code still need to know the minibuffer is completing a
+ file name. So use `lambda' as intermediate value meaning
+ "t" in this minibuffer, but "nil" in next minibuffer. */
+ if (!NILP (Vminibuffer_completing_file_name))
+ Vminibuffer_completing_file_name = Qlambda;
if (inherit_input_method)
{
specbind (Qinhibit_read_only, Qt);
specbind (Qinhibit_modification_hooks, Qt);
Ferase_buffer ();
- unbind_to (count1, Qnil);
- }
- if (!NILP (current_buffer->enable_multibyte_characters)
- && ! STRING_MULTIBYTE (minibuf_prompt))
- minibuf_prompt = Fstring_make_multibyte (minibuf_prompt);
+ if (!NILP (current_buffer->enable_multibyte_characters)
+ && ! STRING_MULTIBYTE (minibuf_prompt))
+ minibuf_prompt = Fstring_make_multibyte (minibuf_prompt);
- /* Insert the prompt, record where it ends. */
- Finsert (1, &minibuf_prompt);
- if (PT > BEG)
- {
- Fput_text_property (make_number (BEG), make_number (PT),
- Qfront_sticky, Qt, Qnil);
- Fput_text_property (make_number (BEG), make_number (PT),
- Qrear_nonsticky, Qt, Qnil);
- Fput_text_property (make_number (BEG), make_number (PT),
- Qfield, Qt, Qnil);
- Fadd_text_properties (make_number (BEG), make_number (PT),
- Vminibuffer_prompt_properties, Qnil);
- }
+ /* Insert the prompt, record where it ends. */
+ Finsert (1, &minibuf_prompt);
+ if (PT > BEG)
+ {
+ Fput_text_property (make_number (BEG), make_number (PT),
+ Qfront_sticky, Qt, Qnil);
+ Fput_text_property (make_number (BEG), make_number (PT),
+ Qrear_nonsticky, Qt, Qnil);
+ Fput_text_property (make_number (BEG), make_number (PT),
+ Qfield, Qt, Qnil);
+ Fadd_text_properties (make_number (BEG), make_number (PT),
+ Vminibuffer_prompt_properties, Qnil);
+ }
+ unbind_to (count1, Qnil);
+ }
minibuf_prompt_width = (int) current_column (); /* iftc */
matchcount++;
bestmatchsize = matchsize;
if (matchsize <= SCHARS (string)
+ /* If completion-ignore-case is non-nil, don't
+ short-circuit because we want to find the best
+ possible match *including* case differences. */
+ && !completion_ignore_case
&& matchcount > 1)
/* No need to look any further. */
break;
return Fnreverse (allmatches);
}
\f
-Lisp_Object Vminibuffer_completion_table, Qminibuffer_completion_table;
-Lisp_Object Vminibuffer_completion_predicate, Qminibuffer_completion_predicate;
-Lisp_Object Vminibuffer_completion_confirm, Qminibuffer_completion_confirm;
-Lisp_Object Vminibuffer_completing_file_name;
-
DEFUN ("completing-read", Fcompleting_read, Scompleting_read, 2, 8, 0,
doc: /* Read a string in the minibuffer, with completion.
PROMPT is a string to prompt with; normally it ends in a colon and a space.
val = read_minibuf (NILP (require_match)
? (NILP (Vminibuffer_completing_file_name)
+ || EQ (Vminibuffer_completing_file_name, Qlambda)
? Vminibuffer_local_completion_map
: Vminibuffer_local_filename_completion_map)
: (NILP (Vminibuffer_completing_file_name)
+ || EQ (Vminibuffer_completing_file_name, Qlambda)
? Vminibuffer_local_must_match_map
: Vminibuffer_local_must_match_filename_map),
init, prompt, make_number (pos), 0,
/* Like assoc but assumes KEY is a string, and ignores case if appropriate. */
DEFUN ("assoc-string", Fassoc_string, Sassoc_string, 2, 3, 0,
- doc: /* Like `assoc' but specifically for strings.
-Unibyte strings are converted to multibyte for comparison.
-And case is ignored if CASE-FOLD is non-nil.
+ doc: /* Like `assoc' but specifically for strings (and symbols).
+Symbols are converted to strings, and unibyte strings are converted to
+multibyte for comparison.
+Case is ignored if optional arg CASE-FOLD is non-nil.
As opposed to `assoc', it will also match an entry consisting of a single
string rather than a cons cell whose car is a string. */)
(key, list, case_fold)
{
register Lisp_Object tail;
+ if (SYMBOLP (key))
+ key = Fsymbol_name (key);
+
for (tail = list; !NILP (tail); tail = Fcdr (tail))
{
register Lisp_Object elt, tem, thiscar;
elt = Fcar (tail);
thiscar = CONSP (elt) ? XCAR (elt) : elt;
- if (!STRINGP (thiscar))
+ if (SYMBOLP (thiscar))
+ thiscar = Fsymbol_name (thiscar);
+ else if (!STRINGP (thiscar))
continue;
tem = Fcompare_strings (thiscar, make_number (0), Qnil,
key, make_number (0), Qnil,
DEFVAR_LISP ("minibuffer-completing-file-name",
&Vminibuffer_completing_file_name,
- doc: /* Non-nil means completing file names. */);
+ doc: /* Non-nil and non-`lambda' means completing file names. */);
Vminibuffer_completing_file_name = Qnil;
DEFVAR_LISP ("minibuffer-help-form", &Vminibuffer_help_form,