*** empty log message ***
[bpt/emacs.git] / src / minibuf.c
index 19835f1..0a1d737 100644 (file)
@@ -7,7 +7,7 @@ This file is part of GNU Emacs.
 
 GNU Emacs is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 
 GNU Emacs is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
+the Free Software Foundation; either version 3, or (at your option)
 any later version.
 
 GNU Emacs is distributed in the hope that it will be useful,
 any later version.
 
 GNU Emacs is distributed in the hope that it will be useful,
@@ -386,7 +386,7 @@ Return (point-min) if current buffer is not a minibuffer.  */)
 DEFUN ("minibuffer-contents", Fminibuffer_contents,
        Sminibuffer_contents, 0, 0, 0,
        doc: /* Return the user input in a minibuffer as a string.
 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 ());
      ()
 {
   int prompt_end = XINT (Fminibuffer_prompt_end ());
@@ -396,7 +396,7 @@ The current buffer must be a minibuffer.  */)
 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.
 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 ());
      ()
 {
   int prompt_end = XINT (Fminibuffer_prompt_end ());
@@ -407,7 +407,7 @@ DEFUN ("minibuffer-completion-contents", Fminibuffer_completion_contents,
        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.
        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 ());
      ()
 {
   int prompt_end = XINT (Fminibuffer_prompt_end ());
@@ -419,7 +419,7 @@ The current buffer must be a minibuffer.  */)
 DEFUN ("delete-minibuffer-contents", Fdelete_minibuffer_contents,
        Sdelete_minibuffer_contents, 0, 0, 0,
        doc: /* Delete all user input in a minibuffer.
 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 ());
      ()
 {
   int prompt_end = XINT (Fminibuffer_prompt_end ());
@@ -700,26 +700,26 @@ read_minibuf (map, initial, prompt, backup_n, expflag,
     specbind (Qinhibit_read_only, Qt);
     specbind (Qinhibit_modification_hooks, Qt);
     Ferase_buffer ();
     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 */
 
 
   minibuf_prompt_width = (int) current_column (); /* iftc */
 
@@ -1483,6 +1483,10 @@ is used to further constrain the set of candidates.  */)
                matchcount++;
              bestmatchsize = matchsize;
              if (matchsize <= SCHARS (string)
                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;
                  && matchcount > 1)
                /* No need to look any further.  */
                break;
@@ -2073,9 +2077,10 @@ do_completion ()
 /* Like assoc but assumes KEY is a string, and ignores case if appropriate.  */
 
 DEFUN ("assoc-string", Fassoc_string, Sassoc_string, 2, 3, 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)
 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)
@@ -2084,12 +2089,17 @@ string rather than a cons cell whose car is a string.  */)
 {
   register Lisp_Object tail;
 
 {
   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;
   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,
        continue;
       tem = Fcompare_strings (thiscar, make_number (0), Qnil,
                              key, make_number (0), Qnil,