From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5919 invoked from network); 20 Dec 2000 01:58:43 -0000 Received: from sunsite.dk (HELO sunsite.auc.dk) (130.225.51.30) by ns1.primenet.com.au with SMTP; 20 Dec 2000 01:58:43 -0000 Received: (qmail 24300 invoked by alias); 20 Dec 2000 01:58:35 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 13299 Received: (qmail 24293 invoked from network); 20 Dec 2000 01:58:35 -0000 Date: Tue, 19 Dec 2000 20:57:22 -0500 From: Clint Adams To: Bart Schaefer Cc: zsh-workers@sunsite.auc.dk Subject: Re: vicmd bindings Message-ID: <20001219205722.A9115@dman.com> References: <20001215172049.A10187@dman.com> <1001216180852.ZM18391@candle.brasslantern.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <1001216180852.ZM18391@candle.brasslantern.com>; from schaefer@candle.brasslantern.com on Sat, Dec 16, 2000 at 06:08:52PM +0000 > The most likely answer is that ksh's vi emulation is imperfect, and zsh > intentionally emulated ksh rather than emulating the real vi. I've tried a few kshes and they all behave exactly like bash. That is, ESC-j and -k move the cursor to the very beginning of the line. However, I think that matching vi's behavior would be more useful, and this patch aims toward that. Unresolved problems include a poor choice in widget nomenclature and a failure to keep the value of what cs should be across whatever it is that determines cursor state boundaries. I'll leave this uncommitted for a bit. Index: Src/Zle/iwidgets.list =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Zle/iwidgets.list,v retrieving revision 1.3 diff -u -r1.3 iwidgets.list --- Src/Zle/iwidgets.list 2000/04/12 08:24:16 1.3 +++ Src/Zle/iwidgets.list 2000/12/20 01:45:35 @@ -121,6 +121,7 @@ "vi-delete-char", videletechar, ZLE_KEEPSUFFIX "vi-digit-or-beginning-of-line", vidigitorbeginningofline, 0 "vi-down-line-or-history", vidownlineorhistory, ZLE_LINEMOVE +"vi-j-down-line-or-history", vijdownlineorhistory, ZLE_LINEMOVE "vi-end-of-line", viendofline, ZLE_LASTCOL "vi-fetch-history", vifetchhistory, 0 "vi-find-next-char", vifindnextchar, 0 @@ -166,6 +167,7 @@ "vi-undo-change", viundochange, ZLE_KEEPSUFFIX "vi-unindent", viunindent, 0 "vi-up-line-or-history", viuplineorhistory, ZLE_LINEMOVE +"vi-k-up-line-or-history", vikuplineorhistory, ZLE_LINEMOVE "vi-yank", viyank, 0 "vi-yank-eol", viyankeol, 0 "vi-yank-whole-line", viyankwholeline, 0 Index: Src/Zle/zle_bindings.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_bindings.c,v retrieving revision 1.3 diff -u -r1.3 zle_bindings.c --- Src/Zle/zle_bindings.c 2000/12/18 02:14:57 1.3 +++ Src/Zle/zle_bindings.c 2000/12/20 01:46:11 @@ -396,8 +396,8 @@ /* g */ z_undefinedkey, /* h */ z_vibackwardchar, /* i */ z_viinsert, - /* j */ z_downlineorhistory, - /* k */ z_uplineorhistory, + /* j */ z_vijdownlineorhistory, + /* k */ z_vikuplineorhistory, /* l */ z_viforwardchar, /* m */ z_visetmark, /* n */ z_virepeatsearch, Index: Src/Zle/zle_hist.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_hist.c,v retrieving revision 1.1.1.14 diff -u -r1.1.1.14 zle_hist.c --- Src/Zle/zle_hist.c 2000/02/23 15:18:49 1.1.1.14 +++ Src/Zle/zle_hist.c 2000/12/20 01:46:14 @@ -142,6 +142,17 @@ /**/ int +vikuplineorhistory(char **args) +{ + int col = lastcol, oldcs = cs; + uplineorhistory(args); + lastcol = col; + cs = (oldcs > findeol()) ? findeol() : oldcs; + return 0; +} + +/**/ +int uplineorsearch(char **args) { int ocs = cs; @@ -222,6 +233,17 @@ downlineorhistory(args); lastcol = col; return vifirstnonblank(zlenoargs); +} + +/**/ +int +vijdownlineorhistory(char **args) +{ + int col = lastcol, oldcs = cs; + downlineorhistory(args); + lastcol = col; + cs = (oldcs > findeol()) ? findeol() : oldcs; + return 0; } /**/