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

PATCH: 3.1.2: keyboard macros (2) [needed]



Somehow I forgot to include the zle_keymap.c segment of the last
patch, with the bindkey changes.  This also includes a bugfix: if zle
read a complete key sequence but didn't need it, such as when in
isearch the next sequence wasn't one of the ones specially handled,
you got it twice.

*** Src/Zle/zle_keymap.c.km2	Mon Oct 13 17:18:42 1997
--- Src/Zle/zle_keymap.c	Mon Oct 13 17:24:06 1997
***************
*** 581,586 ****
--- 581,587 ----
  	{ 'A', 0, bin_bindkey_link,   2,  2 },
  	{ 'N', 0, bin_bindkey_new,    1,  2 },
  	{ 'm', 1, bin_bindkey_meta,   0,  0 },
+ 	{ 'k', 1, bin_bindkey_bind,   1,  1 },
  	{ 'r', 1, bin_bindkey_bind,   1, -1 },
  	{ 's', 1, bin_bindkey_bind,   2, -1 },
  	{ 0,   1, bin_bindkey_bind,   0, -1 },
***************
*** 815,821 ****
  	int len;
  	Thingy fn;
  
! 	if(func == 'r') {
  	    fn = refthingy(t_undefinedkey);
  	    str = NULL;
  	} else if(func == 's') {
--- 816,829 ----
  	int len;
  	Thingy fn;
  
! 	if(func == 'k') {
! 	    if (!last_macro) {
! 		zwarnnam(name, "no keyboard macro defined", NULL, 0);
! 		return 1;
! 	    }
! 	    fn = NULL;
! 	    str = metafy(last_macro, last_mlen, META_DUP);
! 	} else if(func == 'r') {
  	    fn = refthingy(t_undefinedkey);
  	    str = NULL;
  	} else if(func == 's') {
***************
*** 1175,1180 ****
--- 1183,1192 ----
  ungetkeycmd(void)
  {
      ungetkeys(keybuf, keybuflen);
+     /* So we don't do this twice when recording a macro, delete the
+      * first occurrence
+      */
+     macro_del(keybuflen);
  }
  
  /* read a command from the current keymap, with widgets */
*** Src/Zle/zle_utils.c.km2	Mon Oct 13 17:20:45 1997
--- Src/Zle/zle_utils.c	Mon Oct 13 17:28:16 1997
***************
*** 653,658 ****
--- 653,670 ----
  
  /**/
  void
+ macro_del(int nc)
+ {
+     if (!macro_record)
+ 	return;
+     if (nc > macro_ptr - cur_macro)
+ 	cur_startseq = macro_ptr = cur_macro;
+     else
+ 	macro_ptr -= nc;
+ }
+ 
+ /**/
+ void
  macro_startseq(void)
  {
      cur_startseq = macro_ptr;

-- 
Peter Stephenson <pws@xxxxxx>       Tel: +49 33762 77366
WWW:  http://www.ifh.de/~pws/       Fax: +49 33762 77413
Deutsches Elektronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen
DESY-IfH, Platanenallee 6, 15738 Zeuthen, Germany.



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