Article View: gnu.emacs.bug
Article #98725Re: Patch for minibuf.c (do-completion) bombs..
From: Chip Webb
Date: Tue, 19 Mar 1991 16:55
Date: Tue, 19 Mar 1991 16:55
214 lines
7513 bytes
7513 bytes
RMS> Received: by att.att.com; Sun Mar 17 23:50:43 EST 1991
RMS> Received: by mole.ai.mit.edu (5.65/3.3)
RMS> id <AA11278@mole.ai.mit.edu>; Sun, 17 Mar 91 23:50:45 -0500
RMS> Message-Id: <9103180450.AA11278@mole.ai.mit.edu>
RMS> From: rms@mole.ai.mit.edu (Richard Stallman)
RMS> To: Dan_Jacobson@att.com
RMS> Subject: manual info menu tangle
RMS> Date: Sun, 17 Mar 91 23:50:45 -0500
RMS> In-Reply-To: Dan_Jacobson@att.com's message of Sun, 17 Mar 91 19:28 CST <9103180302.AA07083@life.ai.mit.edu>
RMS>
RMS> Please try this replacement for the existing text of do_completion in
RMS> minibuf.c.
RMS> [actual code elided, context diffs provided below....]
The code won't compile.... (yet!) There are some undefined symbols....
----------------------------------------------------------------------------
make -f xmakefile all
cc -O2 -Bstatic -Demacs -target sun4 -c minibuf.c
"minibuf.c", line 688: prev_echo_area_contents undefined
"minibuf.c", line 761: thiscar undefined
*** Error code 1
make: Fatal error: Command failed for target `minibuf.o'
----------------------------------------------------------------------------
Here are the diffs between the old and the new versions of minibuf.c:
(I #ifndef - ed out the old code and inserted the new stuff...)
----------------------------------------------------------------------------
*** minibuf.c.OLD Tue Mar 19 00:45:42 1991
--- minibuf.c Tue Mar 19 00:10:13 1991
***************
*** 661,666 ****
--- 661,670 ----
Lisp_Object Fminibuffer_completion_help ();
+ #ifndef OLD_STYLE_COMPLETION
+
+ Lisp_Object assoc_for_completion ();
+
/* returns:
* 0 no possible completion
* 1 was already an exact and unique completion
***************
*** 680,685 ****
--- 684,691 ----
if (NULL (completion))
{
bell ();
+ /* Clearing this prevents sit-for from leaving the message up. */
+ prev_echo_area_contents = 0;
temp_echo_area_contents (" [No match]");
return 0;
}
***************
*** 698,703 ****
--- 704,814 ----
/* It did find a match. Do we match some possibility exactly now? */
if (CONSP (Vminibuffer_completion_table)
|| NULL (Vminibuffer_completion_table))
+ tem = assoc_for_completion (Fbuffer_string (), Vminibuffer_completion_table);
+ else if (XTYPE (Vminibuffer_completion_table) == Lisp_Vector)
+ {
+ /* the primitive used by Fintern_soft */
+ extern Lisp_Object oblookup ();
+
+ tem = Fbuffer_string ();
+ /* Bypass intern-soft as that loses for nil */
+ tem = oblookup (Vminibuffer_completion_table,
+ XSTRING (tem)->data, XSTRING (tem)->size);
+ if (XTYPE (tem) != Lisp_Symbol)
+ tem = Qnil;
+ else if (!NULL (Vminibuffer_completion_predicate))
+ tem = call1 (Vminibuffer_completion_predicate, tem);
+ else
+ tem = Qt;
+ }
+ else
+ tem = call3 (Vminibuffer_completion_table,
+ Fbuffer_string (),
+ Vminibuffer_completion_predicate,
+ Qlambda);
+
+ if (NULL (tem))
+ { /* not an exact match */
+ if (completedp)
+ return 5;
+ else if (completion_auto_help)
+ Fminibuffer_completion_help ();
+ else
+ temp_echo_area_contents (" [Next char not unique]");
+ return 6;
+ }
+ else
+ return (completedp ? 4 : 3);
+ }
+
+ /* Like assoc but assumes KEY is a string, and ignores case if appropriate. */
+
+ Lisp_Object
+ assoc_for_completion (key, list)
+ register Lisp_Object key;
+ Lisp_Object list;
+ {
+ register Lisp_Object tail;
+
+ if (completion_ignore_case)
+ key = Fupcase (key);
+
+ for (tail = list; !NULL (tail); tail = Fcdr (tail))
+ {
+ register Lisp_Object elt, tem;
+ elt = Fcar (tail);
+ if (!CONSP (elt)) continue;
+ thiscar = Fcar (elt);
+ if (XTYPE (thiscar) != Lisp_String)
+ continue;
+ if (completion_ignore_case)
+ thiscar = Fupcase (thiscar);
+ tem = Fequal (thiscar, key);
+ if (!NULL (tem)) return elt;
+ QUIT;
+ }
+ return Qnil;
+ }
+
+ #else
+
+ /* returns:
+ * 0 no possible completion
+ * 1 was already an exact and unique completion
+ * 3 was already an exact completion
+ * 4 completed to an exact completion
+ * 5 some completion happened
+ * 6 no completion happened
+ */
+ int
+ do_completion ()
+ {
+ Lisp_Object completion, tem;
+ int completedp;
+
+ completion = Ftry_completion (Fbuffer_string (), Vminibuffer_completion_table,
+ Vminibuffer_completion_predicate);
+ if (NULL (completion))
+ {
+ bell ();
+ temp_echo_area_contents (" [No match]");
+ return 0;
+ }
+
+ if (EQ (completion, Qt)) /* exact and unique match */
+ return 1;
+
+ /* compiler bug */
+ tem = Fstring_equal (completion, Fbuffer_string());
+ if (completedp = NULL (tem))
+ {
+ Ferase_buffer (); /* Some completion happened */
+ Finsert (1, &completion);
+ }
+
+ /* It did find a match. Do we match some possibility exactly now? */
+ if (CONSP (Vminibuffer_completion_table)
+ || NULL (Vminibuffer_completion_table))
tem = Fassoc (Fbuffer_string (), Vminibuffer_completion_table);
else if (XTYPE (Vminibuffer_completion_table) == Lisp_Vector)
{
***************
*** 734,739 ****
--- 845,852 ----
else
return (completedp ? 4 : 3);
}
+
+ #endif
DEFUN ("minibuffer-complete", Fminibuffer_complete, Sminibuffer_complete, 0, 0, "",
----------------------------------------------------------------------------
ERROR #1:
"minibuf.c", line 688: prev_echo_area_contents undefined
----------------------------------------------------------------------------
bell7:cwebb grep prev_echo_area_contents *.c
minibuf.c: prev_echo_area_contents = 0;
xdisp.c:char *prev_echo_area_contents;
xdisp.c: prev_echo_area_contents = echo_area_contents;
xdisp.c: if (echo_area_contents != 0 || prev_echo_area_contents != 0)
xdisp.c: if (echo_area_contents == 0 && prev_echo_area_contents != 0)
xdisp.c: echo_area_contents = prev_echo_area_contents;
xdisp.c: prev_echo_area_contents = 0;
----------------------------------------------------------------------------
ERROR #2:
"minibuf.c", line 761: thiscar undefined
----------------------------------------------------------------------------
bell7:cwebb grep thiscar *.c
minibuf.c: thiscar = Fcar (elt);
minibuf.c: if (XTYPE (thiscar) != Lisp_String)
minibuf.c: thiscar = Fupcase (thiscar);
minibuf.c: tem = Fequal (thiscar, key);
----------------------------------------------------------------------------
Chip Webb
cwebb@allegra.att.com
/
Technical Details
Message-ID:
<9103191658.AA23164@life.ai.mit.edu>Path:
arc1-ca.pugleaf.net!gmdzi!unido!fauern!ira.uka.de!sol.ctr.columbia.edu!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!tut.cis.ohio-state.edu!unreplyable!garbageShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fb2f1,5c2f9eefac6c4519,start X-Google-Attributes: gidfb2f1,public X-Google-ArrivalTime: 1991-03-19 08:55:32 PST Path: arc1-ca.pugleaf.net!gmdzi!unido!fauern!ira.uka.de!sol.ctr.columbia.edu!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!tut.cis.ohio-state.edu!unreplyable!garbage From: cwebb@allegra.att.com (Chip Webb) Newsgroups: gnu.emacs.bug Subject: Re: Patch for minibuf.c (do-completion) bombs.. Message-ID: <9103191658.AA23164@life.ai.mit.edu> Date: 19 Mar 91 16:55:32 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 214 Approved: bug-gnu-emacs@prep.ai.mit.edu