Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

execute-named-cmd fixes



-----BEGIN PGP SIGNED MESSAGE-----

The patch below changes some of the logic in getkeycmd(), so that (I
think) *all* commands now work with execute-named-cmd.  Previously,
execute-named-cmd, execute-last-named-cmd and
vi-digit-or-beginning-of-line didn't work, and send-string caused a
core dump.  There is also a little fix for vi-forward-char.

 -zefram

      *** 1.7	1995/07/22 20:24:09
      --- Src/zle_main.c	1995/07/23 17:39:55
      ***************
      *** 539,551 ****
        	zfree(buf, buflen);
            } else
        	ungetok = 1;		/* for doisearch() */
      !     if (ret == z_vidigitorbeginningofline)
      ! 	ret = (lastcmd & ZLE_DIGIT) ? z_digitargument : z_vibeginningofline;
      !     else if (ret == z_executenamedcmd && !statusline)
      ! 	ret = executenamedcommand("execute: ");
      !     else if (ret == z_executelastnamedcmd)
        	ret = lastnamed;
      !     else if (ret == z_sendstring) {
        #define MAXHOPS 20
        	if (++hops == MAXHOPS) {
        	    zerr("string inserting another one too many times", NULL, 0);
      --- 539,555 ----
        	zfree(buf, buflen);
            } else
        	ungetok = 1;		/* for doisearch() */
      !     if (ret == z_executenamedcmd && !statusline) {
      ! 	while(ret == z_executenamedcmd)
      ! 	    ret = executenamedcommand("execute: ");
      ! 	if(ret == -1)
      ! 	    ret = z_undefinedkey;
      ! 	else if(ret != z_executelastnamedcmd)
      ! 	    lastnamed = ret;
      !     }
      !     if (ret == z_executelastnamedcmd)
        	ret = lastnamed;
      !     if (ret == z_sendstring) {
        #define MAXHOPS 20
        	if (++hops == MAXHOPS) {
        	    zerr("string inserting another one too many times", NULL, 0);
      ***************
      *** 554,559 ****
      --- 558,565 ----
        	}
            } else
        	hops = 0;
      +     if (ret == z_vidigitorbeginningofline)
      + 	ret = (lastcmd & ZLE_DIGIT) ? z_digitargument : z_vibeginningofline;
            return ret;
        }
        
      ***************
      *** 568,574 ****
        	buf[1] = '\0';
        	cky = (Key) keybindtab->getnode(keybindtab, buf);
            }
      !     ungetkeys(cky->str, cky->len);
        }
        
        /**/
      --- 574,583 ----
        	buf[1] = '\0';
        	cky = (Key) keybindtab->getnode(keybindtab, buf);
            }
      !     if(cky)
      ! 	ungetkeys(cky->str, cky->len);
      !     else
      ! 	feep();
        }
        
        /**/
      ***************
      *** 1098,1111 ****
        {
            int i;
        
      !     if ((func = executenamedcommand("Where is: ")) == z_undefinedkey)
        	return;
            funcfound = 0;
            trashzle();
            clearflag = (isset(USEZLE) && termok &&
        		 (isset(ALWAYSLASTPROMPT) && mult == 1)) ||
        	(unset(ALWAYSLASTPROMPT) && mult != 1);
      !     if (func == z_selfinsert)
        	fprintf(shout, "%s is on many keys", zlecmds[func].name);
            else {
        	fprintf(shout, "%s is", zlecmds[func].name);
      --- 1107,1120 ----
        {
            int i;
        
      !     if ((func = executenamedcommand("Where is: ")) == -1)
        	return;
            funcfound = 0;
            trashzle();
            clearflag = (isset(USEZLE) && termok &&
        		 (isset(ALWAYSLASTPROMPT) && mult == 1)) ||
        	(unset(ALWAYSLASTPROMPT) && mult != 1);
      !     if (func == z_selfinsert || func == z_undefinedkey)
        	fprintf(shout, "%s is on many keys", zlecmds[func].name);
            else {
        	fprintf(shout, "%s is", zlecmds[func].name);
      *** 1.9	1995/07/23 04:21:39
      --- Src/zle_misc.c	1995/07/23 17:34:35
      ***************
      *** 580,586 ****
        	if ((cmd = getkeycmd()) < 0 || cmd == z_sendbreak) {
        	    statusline = NULL;
        	    bindtab = obindtab;
      ! 	    return z_undefinedkey;
        	}
        	switch (cmd) {
        	case z_sendstring:
      --- 580,586 ----
        	if ((cmd = getkeycmd()) < 0 || cmd == z_sendbreak) {
        	    statusline = NULL;
        	    bindtab = obindtab;
      ! 	    return -1;
        	}
        	switch (cmd) {
        	case z_sendstring:
      ***************
      *** 631,637 ****
        		if (!strcmp(buf, zlecmds[t0].name))
        		    break;
        	    if (t0 != ZLECMDCOUNT) {
      - 		lastnamed = t0;
        		statusline = NULL;
        		bindtab = obindtab;
        		return t0;
      --- 631,636 ----
      *** 1.3	1995/07/22 18:39:21
      --- Src/zle_move.c	1995/07/23 17:42:24
      ***************
      *** 257,267 ****
        	vibackwardchar();
        	return;
            }
      !     if (cs == lim) {
        	feep();
        	return;
            }
      !     while (mult-- && cs != lim)
        	cs++;
        }
        
      --- 257,267 ----
        	vibackwardchar();
        	return;
            }
      !     if (cs >= lim) {
        	feep();
        	return;
            }
      !     while (mult-- && cs < lim)
        	cs++;
        }
        

-----BEGIN PGP SIGNATURE-----
Version: 2.6.i

iQBVAgUBMBKLnWWJ8JfKi+e9AQEyrQIAtutyoos5d62Zs6gLbMydoEsfScH30Wyj
uKVs+/hrz1nqfJPmtV2jVwxX/Wlsxzx411Q6oaXjQm7ptYugFuS0ew==
=HdB9
-----END PGP SIGNATURE-----



Messages sorted by: Reverse Date, Date, Thread, Author