* [PATCH 1/2] Fix vi-rev-repeat-find after vi-find-*-char-skip @ 2012-08-12 18:00 Aaron Schrab 2012-08-12 18:00 ` [PATCH 2/2] Make vi-repeat-find more vim-like Aaron Schrab 0 siblings, 1 reply; 4+ messages in thread From: Aaron Schrab @ 2012-08-12 18:00 UTC (permalink / raw) To: zsh-workers When vi-rev-repeat-find (,) is used to repeat either vi-find-next-char-skip (t) or vi-find-prev-char-skip (T), the direction in which the final cursor location will be adjusted needs to be reversed along with the direction of the search. If this is not done, the reverse find will go past the desired character rather than stopping before it. Examples of behaviour ([] indicates cursor position): Previously: Completion/Un[i]x/Command/_ls t/ Completion/Uni[x]/Command/_ls , Completio[n]/Unix/Command/_ls Completion/Un[i]x/Command/_ls T/ Completion/[U]nix/Command/_ls , Completion/Unix/[C]ommand/_ls Now: Completion/Un[i]x/Command/_ls t/ Completion/Uni[x]/Command/_ls , Completion/[U]nix/Command/_ls Completion/Un[i]x/Command/_ls T/ Completion/[U]nix/Command/_ls , Completion/Uni[x]/Command/_ls --- Src/Zle/zle_move.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Src/Zle/zle_move.c b/Src/Zle/zle_move.c index 0e940bc..284a863 100644 --- a/Src/Zle/zle_move.c +++ b/Src/Zle/zle_move.c @@ -770,9 +770,11 @@ virevrepeatfind(char **args) zmult = -zmult; return ret; } + tailadd = -tailadd; vfinddir = -vfinddir; ret = virepeatfind(args); vfinddir = -vfinddir; + tailadd = -tailadd; return ret; } -- 1.7.10.4 ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/2] Make vi-repeat-find more vim-like 2012-08-12 18:00 [PATCH 1/2] Fix vi-rev-repeat-find after vi-find-*-char-skip Aaron Schrab @ 2012-08-12 18:00 ` Aaron Schrab 2012-08-12 21:04 ` Bart Schaefer 0 siblings, 1 reply; 4+ messages in thread From: Aaron Schrab @ 2012-08-12 18:00 UTC (permalink / raw) To: zsh-workers Change vi-repeat-find (;) and vi-rev-repeat-find (,) to ignore a match at the first character checked if repeating a vi-find-next-char-skip (t) or vi-find-prev-char-skip (T), as vim does (when cpoptions doesn't contain ;). The standard vi behaviour makes immediately repeating one of these searches useless, since the first character checked will always match resulting in no movement of the cursor. --- Src/Zle/zle_move.c | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/Src/Zle/zle_move.c b/Src/Zle/zle_move.c index 284a863..d5f464c 100644 --- a/Src/Zle/zle_move.c +++ b/Src/Zle/zle_move.c @@ -679,7 +679,7 @@ vifindnextchar(char **args) if ((vfindchar = vigetkey()) != ZLEEOF) { vfinddir = 1; tailadd = 0; - return virepeatfind(args); + return vifindchar(0, args); } return 1; } @@ -691,7 +691,7 @@ vifindprevchar(char **args) if ((vfindchar = vigetkey()) != ZLEEOF) { vfinddir = -1; tailadd = 0; - return virepeatfind(args); + return vifindchar(0, args); } return 1; } @@ -703,7 +703,7 @@ vifindnextcharskip(char **args) if ((vfindchar = vigetkey()) != ZLEEOF) { vfinddir = 1; tailadd = -1; - return virepeatfind(args); + return vifindchar(0, args); } return 1; } @@ -715,14 +715,14 @@ vifindprevcharskip(char **args) if ((vfindchar = vigetkey()) != ZLEEOF) { vfinddir = -1; tailadd = 1; - return virepeatfind(args); + return vifindchar(0, args); } return 1; } /**/ int -virepeatfind(char **args) +vifindchar(int repeat, char **args) { int ocs = zlecs, n = zmult; @@ -735,6 +735,16 @@ virepeatfind(char **args) zmult = n; return ret; } + if (repeat && tailadd != 0) { + if (vfinddir > 0) { + if(zlecs < zlell && (ZLE_INT_T)zleline[zlecs+1] == vfindchar) + INCCS(); + } + else { + if(zlecs > 0 && (ZLE_INT_T)zleline[zlecs-1] == vfindchar) + DECCS(); + } + } while (n--) { do { if (vfinddir > 0) @@ -760,19 +770,26 @@ virepeatfind(char **args) /**/ int +virepeatfind(char **args) +{ + return vifindchar(1, args); +} + +/**/ +int virevrepeatfind(char **args) { int ret; if (zmult < 0) { zmult = -zmult; - ret = virepeatfind(args); + ret = vifindchar(1, args); zmult = -zmult; return ret; } tailadd = -tailadd; vfinddir = -vfinddir; - ret = virepeatfind(args); + ret = vifindchar(1, args); vfinddir = -vfinddir; tailadd = -tailadd; return ret; -- 1.7.10.4 ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] Make vi-repeat-find more vim-like 2012-08-12 18:00 ` [PATCH 2/2] Make vi-repeat-find more vim-like Aaron Schrab @ 2012-08-12 21:04 ` Bart Schaefer 2012-08-12 21:32 ` Aaron Schrab 0 siblings, 1 reply; 4+ messages in thread From: Bart Schaefer @ 2012-08-12 21:04 UTC (permalink / raw) To: zsh-workers On Aug 12, 2:00pm, Aaron Schrab wrote: } Subject: [PATCH 2/2] Make vi-repeat-find more vim-like In the past we've rejected this sort of patch on the grounds that zsh is emulating vi, not emulating vim. On the one hand there are things about vim that seriously annoy me. On the other hand, http://xkcd.com/1093/. ("The original code for vi was written by Bill Joy in 1976 ...") ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] Make vi-repeat-find more vim-like 2012-08-12 21:04 ` Bart Schaefer @ 2012-08-12 21:32 ` Aaron Schrab 0 siblings, 0 replies; 4+ messages in thread From: Aaron Schrab @ 2012-08-12 21:32 UTC (permalink / raw) To: zsh-workers At 14:04 -0700 12 Aug 2012, Bart Schaefer <schaefer@brasslantern.com> wrote: >On Aug 12, 2:00pm, Aaron Schrab wrote: >} Subject: [PATCH 2/2] Make vi-repeat-find more vim-like > >In the past we've rejected this sort of patch on the grounds that zsh >is emulating vi, not emulating vim. Right, but is it worth it to be strict about that? Even if it's unlikely that the emulation will be complete in any case? Here, I think the vi behaviour is quite stupid and useless; while the vim behaviour can be really nice. Also, I want to make sure it's understood that the first patch in this series fixes a behaviour to match what would happen in both vi and vim. I just happened to notice that problem while testing out the changes for the second patch. ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-08-12 21:33 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2012-08-12 18:00 [PATCH 1/2] Fix vi-rev-repeat-find after vi-find-*-char-skip Aaron Schrab 2012-08-12 18:00 ` [PATCH 2/2] Make vi-repeat-find more vim-like Aaron Schrab 2012-08-12 21:04 ` Bart Schaefer 2012-08-12 21:32 ` Aaron Schrab
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).