zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@csr.com>
To: zsh-workers@sunsite.dk (Zsh hackers list)
Subject: Re: Problem with motion commands defined using match-word-by-style used with vi-delete
Date: Tue, 25 Apr 2006 15:52:27 +0100	[thread overview]
Message-ID: <EXCHANGE03DSDDsvJd90000acd1@exchange03.csr.com> (raw)
In-Reply-To: <060425072847.ZM1813@torch.brasslantern.com>

Bart Schaefer wrote:
> So ... shouldn't getvirange() do this part too?  What harm could it be?
> 
> } +    bindk = t;
> }      ret = execzlefunc(t, args);
> } +    bindk = savbindk;

It depends:  is it useful to know that the motion commands are running
as part of a vi command?  Changing it would make it more consistent with
Nicholas' proposed use.

The following patch makes this feature an argument to execzlefunc(); it
looks like it would be sensible to use this for stand-alone widgets that
aren't run directly by the user, too.

Index: Src/Zle/zle_main.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_main.c,v
retrieving revision 1.84
diff -u -r1.84 zle_main.c
--- Src/Zle/zle_main.c	7 Mar 2006 21:31:43 -0000	1.84
+++ Src/Zle/zle_main.c	25 Apr 2006 14:48:10 -0000
@@ -862,7 +862,7 @@
 		eofsent = 1;
 		break;
 	    }
-	    if (execzlefunc(bindk, zlenoargs)) {
+	    if (execzlefunc(bindk, zlenoargs, 0)) {
 		handlefeep(zlenoargs);
 		if (eofsent)
 		    break;
@@ -1011,7 +1011,7 @@
 	char *args[2];
 	args[0] = initthingy->nam;
 	args[1] = NULL;
-	execzlefunc(initthingy, args);
+	execzlefunc(initthingy, args, 1);
 	unrefthingy(initthingy);
 	errflag = retflag = 0;
     }
@@ -1040,14 +1040,22 @@
     return s;
 }
 
-/* execute a widget */
+/*
+ * Execute a widget.  The third argument indicates that the global
+ * variable bindk should be set temporarily so that WIDGET etc.
+ * reflect the command being executed.
+ */
 
 /**/
 int
-execzlefunc(Thingy func, char **args)
+execzlefunc(Thingy func, char **args, int set_bindk)
 {
     int r = 0, ret = 0;
     Widget w;
+    Thingy save_bindk = bindk;
+
+    if (set_bindk)
+	bindk = func;
 
     if(func->flags & DISABLED) {
 	/* this thingy is not the name of a widget */
@@ -1143,6 +1151,8 @@
 	refthingy(func);
 	lbindk = func;
     }
+    if (set_bindk)
+	bindk = save_bindk;
     return ret;
 }
 
Index: Src/Zle/zle_thingy.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_thingy.c,v
retrieving revision 1.27
diff -u -r1.27 zle_thingy.c
--- Src/Zle/zle_thingy.c	25 Apr 2006 10:10:51 -0000	1.27
+++ Src/Zle/zle_thingy.c	25 Apr 2006 14:48:11 -0000
@@ -639,7 +639,7 @@
 static int
 bin_zle_call(char *name, char **args, UNUSED(Options ops), UNUSED(char func))
 {
-    Thingy t, savbindk = bindk;
+    Thingy t;
     struct modifier modsave = zmod;
     int ret, saveflag = 0, setbindk = 0;
     char *wname = *args++, *keymap_restore = NULL, *keymap_tmp;
@@ -704,10 +704,7 @@
     }
 
     t = rthingy(wname);
-    if (setbindk)
-	bindk = t;
-    ret = execzlefunc(t, args);
-    bindk = savbindk;
+    ret = execzlefunc(t, args, setbindk);
     unrefthingy(t);
     if (saveflag)
 	zmod = modsave;
Index: Src/Zle/zle_vi.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_vi.c,v
retrieving revision 1.13
diff -u -r1.13 zle_vi.c
--- Src/Zle/zle_vi.c	1 Nov 2005 02:50:30 -0000	1.13
+++ Src/Zle/zle_vi.c	25 Apr 2006 14:48:12 -0000
@@ -181,7 +181,7 @@
 	 * a number of lines is used.  If the function used
 	 * returns 1, we fail.
 	 */
-	if ((k2 == bindk) ? dovilinerange() : execzlefunc(k2, zlenoargs))
+	if ((k2 == bindk) ? dovilinerange() : execzlefunc(k2, zlenoargs, 1))
 	    ret = -1;
 	if(vichgrepeat)
 	    zmult = mult1;

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


To access the latest news from CSR copy this link into a web browser:  http://www.csr.com/email_sig.php


      reply	other threads:[~2006-04-25 14:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <060423085310.ZM31491@torch.brasslantern.com>
     [not found] ` <200604232308.k3NN8Wtj004945@pwslaptop.csr.com>
     [not found]   ` <dbfc82860604241239q34ee602an680fd20611d52018@mail.gmail.com>
     [not found]     ` <060424200611.ZM996@torch.brasslantern.com>
2006-04-25  9:58       ` Peter Stephenson
2006-04-25 11:19         ` Nikolai Weibull
2006-04-25 14:28         ` Bart Schaefer
2006-04-25 14:52           ` Peter Stephenson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=EXCHANGE03DSDDsvJd90000acd1@exchange03.csr.com \
    --to=pws@csr.com \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).