diff src/minibuf.c @ 66114:13abee3a9bc6

* message.el (message-expand-group): Pass the common prefix substring of completion to `display-completion-list'. * mh-comp.el (mh-complete-word): Pass the common prefix substring of completion to `display-completion-list'. * dabbrev.el (dabbrev-completion): Pass the common prefix substring of completion to `display-completion-list'. * filecache.el (file-cache-minibuffer-complete) (file-cache-complete): Ditto. * tempo.el (tempo-display-completions): Ditto. * wid-edit.el (widget-file-complete, widget-color-complete): Ditto. * emacs-lisp/lisp.el (lisp-complete-symbol): Ditto. * eshell/em-hist.el (eshell-list-history): Ditto. * mail/mailabbrev.el (mail-abbrev-complete-alias): Ditto. * progmodes/etags.el (complete-tag): Ditto. * progmodes/make-mode.el (makefile-complete): Ditto. * progmodes/meta-mode.el (meta-complete-symbol): Ditto. * progmodes/octave-mod.el (octave-complete-symbol): Ditto. * progmodes/pascal.el (pascal-complete-word) (pascal-show-completions): Ditto. * textmodes/bibtex.el (bibtex-complete-internal): Ditto. * simple.el (completion-common-substring): New variable. (completion-setup-function): Use `completion-common-substring' to put faces. * minibuf.c (Fdisplay_completion_list): Add new optional argument COMMON_SUBSTRING. Bind `completion-common-substring' to the optional argument during running `completion-setup-hook'.
author Masatake YAMATO <jet@gyve.org>
date Sun, 16 Oct 2005 09:31:48 +0000
parents 028c8f536edb
children a75cbd554fc1 db4e74787e6f
line wrap: on
line diff
--- a/src/minibuf.c	Sun Oct 16 03:24:54 2005 +0000
+++ b/src/minibuf.c	Sun Oct 16 09:31:48 2005 +0000
@@ -2351,7 +2351,7 @@
 }
 
 DEFUN ("display-completion-list", Fdisplay_completion_list, Sdisplay_completion_list,
-       1, 1, 0,
+       1, 2, 0,
        doc: /* Display the list of completions, COMPLETIONS, using `standard-output'.
 Each element may be just a symbol or string
 or may be a list of two strings to be printed as if concatenated.
@@ -2361,14 +2361,23 @@
 The actual completion alternatives, as inserted, are given `mouse-face'
 properties of `highlight'.
 At the end, this runs the normal hook `completion-setup-hook'.
-It can find the completion buffer in `standard-output'.  */)
-     (completions)
+It can find the completion buffer in `standard-output'.  
+The optional second arg COMMON-SUBSTRING is a string. 
+It is used to put faces, `completions-first-difference` and
+`completions-common-part' on the completion bufffer. The
+`completions-common-part' face is put on the common substring
+specified by COMMON-SUBSTRING. If COMMON-SUBSTRING is nil,
+the faces are not put. 
+Internally, COMMON-SUBSTRING is bound to `completion-common-substring' 
+during running `completion-setup-hook'. */)
+     (completions, common_substring)
      Lisp_Object completions;
+     Lisp_Object common_substring;
 {
   Lisp_Object tail, elt;
   register int i;
   int column = 0;
-  struct gcpro gcpro1, gcpro2;
+  struct gcpro gcpro1, gcpro2, gcpro3;
   struct buffer *old = current_buffer;
   int first = 1;
 
@@ -2377,7 +2386,7 @@
      except for ELT.  ELT can be pointing to a string
      when terpri or Findent_to calls a change hook.  */
   elt = Qnil;
-  GCPRO2 (completions, elt);
+  GCPRO3 (completions, elt, common_substring);
 
   if (BUFFERP (Vstandard_output))
     set_buffer_internal (XBUFFER (Vstandard_output));
@@ -2526,13 +2535,20 @@
 	}
     }
 
-  UNGCPRO;
-
   if (BUFFERP (Vstandard_output))
     set_buffer_internal (old);
 
   if (!NILP (Vrun_hooks))
-    call1 (Vrun_hooks, intern ("completion-setup-hook"));
+    {
+      int count1 = SPECPDL_INDEX ();
+
+      specbind (intern ("completion-common-substring"), common_substring);
+      call1 (Vrun_hooks, intern ("completion-setup-hook"));
+      
+      unbind_to (count1, Qnil);
+    }
+
+  UNGCPRO;
 
   return Qnil;
 }