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 ());
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)
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;
/* Some completion happened */
if (! NILP (Vminibuffer_completing_file_name)
- && ! EQ (Vminibuffer_completing_file_name, Qlambda)
&& SREF (completion, SBYTES (completion) - 1) == '/'
&& PT < ZV
&& FETCH_CHAR (PT_BYTE) == '/')
/* 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,
GCPRO2 (completion, tem);
/* If reading a file name,
expand any $ENVVAR refs in the buffer and in TEM. */
- if (! NILP (Vminibuffer_completing_file_name)
- && ! EQ (Vminibuffer_completing_file_name, Qlambda))
+ if (! NILP (Vminibuffer_completing_file_name))
{
Lisp_Object substituted;
substituted = Fsubstitute_in_file_name (tem);
/* Otherwise insert in minibuffer the chars we got */
if (! NILP (Vminibuffer_completing_file_name)
- && ! EQ (Vminibuffer_completing_file_name, Qlambda)
&& SREF (completion, SBYTES (completion) - 1) == '/'
&& PT < ZV
&& FETCH_CHAR (PT_BYTE) == '/')