zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: 3.1.6-test-1: expansion return status
@ 1999-07-13 15:31 Peter Stephenson
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Stephenson @ 1999-07-13 15:31 UTC (permalink / raw)
  To: Zsh hackers list

The standard expansion widgets (^X*, ^Xg) don't get the status right, and
hence feep too often.  This seems to fix the problem by counting the number
of matches.  Probably _expand works OK, but I haven't been using that.
(Hey, look, I wrote a completion patch!)

What I haven't attempted to get right is that the list should also be
cleared if there are no matches.

--- Src/Zle/zle_tricky.c.exp	Tue Jul 13 10:33:14 1999
+++ Src/Zle/zle_tricky.c	Tue Jul 13 17:23:40 1999
@@ -1017,7 +1017,7 @@
 	    int ocs = cs, ne = noerrs;
 
 	    noerrs = 1;
-	    doexpansion(s, lst, olst, lincmd);
+	    ret = doexpansion(s, lst, olst, lincmd);
 	    lastambig = 0;
 	    noerrs = ne;
 
@@ -1043,8 +1043,7 @@
 			}
 		}
 		ret = docompletion(s, lst, lincmd);
-	    } else
-		ret = !strcmp(ol, (char *) line);
+	    }
 	} else
 	    /* Just do completion. */
 	    ret = docompletion(s, lst, lincmd);
@@ -1736,9 +1735,10 @@
 /* Expand the current word. */
 
 /**/
-static void
+static int
 doexpansion(char *s, int lst, int olst, int explincmd)
 {
+    int ret = 1;
     LinkList vl;
     char *ss;
 
@@ -1775,7 +1775,7 @@
 	}
 	if (lst == COMP_LIST_EXPAND) {
 	    /* Only the list of expansions was requested. */
-	    listlist(vl);
+	    ret = listlist(vl);
 	    showinglist = 0;
 	    goto end;
 	}
@@ -1783,6 +1783,7 @@
 	cs = wb;
 	foredel(we - wb);
 	while ((ss = (char *)ugetnode(vl))) {
+	    ret = 0;
 	    untokenize(ss);
 	    ss = quotename(ss, NULL);
 	    inststr(ss);
@@ -1801,6 +1802,8 @@
       end:
 	popheap();
     } LASTALLOC;
+
+    return ret;
 }
 
 /* This is called from the lexer to give us word positions. */
@@ -8179,7 +8182,7 @@
 /* This is used to print expansions. */
 
 /**/
-void
+int
 listlist(LinkList l)
 {
     struct cmgroup dg;
@@ -8202,6 +8205,8 @@
     validlist = vl;
     smatches = sm;
     complastprompt = oclp;
+
+    return !dg.lcount;
 }
 
 /* Expand the history references. */

-- 
Peter Stephenson <pws@ibmth.df.unipi.it>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: PATCH: 3.1.6-test-1: expansion return status
@ 1999-07-14  7:57 Sven Wischnowsky
  0 siblings, 0 replies; 2+ messages in thread
From: Sven Wischnowsky @ 1999-07-14  7:57 UTC (permalink / raw)
  To: zsh-workers


Peter Stephenson wrote:

> What I haven't attempted to get right is that the list should also be
> cleared if there are no matches.

It should be as simple as this -- or am I missing something?

Bye
 Sven

diff -u os/Zle/zle_tricky.c Src/Zle/zle_tricky.c
--- os/Zle/zle_tricky.c	Wed Jul 14 09:21:07 1999
+++ Src/Zle/zle_tricky.c	Wed Jul 14 09:51:49 1999
@@ -1043,7 +1043,8 @@
 			}
 		}
 		ret = docompletion(s, lst, lincmd);
-	    }
+	    } else if (ret)
+		clearlist = 1;
 	} else
 	    /* Just do completion. */
 	    ret = docompletion(s, lst, lincmd);

--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1999-07-14  7:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-07-13 15:31 PATCH: 3.1.6-test-1: expansion return status Peter Stephenson
1999-07-14  7:57 Sven Wischnowsky

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).