* vicmd bindings
@ 2000-12-15 22:20 Clint Adams
2000-12-16 16:20 ` PATCH: " Clint Adams
2000-12-16 18:08 ` Bart Schaefer
0 siblings, 2 replies; 9+ messages in thread
From: Clint Adams @ 2000-12-15 22:20 UTC (permalink / raw)
To: zsh-workers
Any reason that
"j" down-line-or-history
"k" up-line-or-history
aren't vi-down-line-or-history &al. by default?
^ permalink raw reply [flat|nested] 9+ messages in thread
* PATCH: Re: vicmd bindings
2000-12-15 22:20 vicmd bindings Clint Adams
@ 2000-12-16 16:20 ` Clint Adams
2000-12-18 0:27 ` Zefram
2000-12-16 18:08 ` Bart Schaefer
1 sibling, 1 reply; 9+ messages in thread
From: Clint Adams @ 2000-12-16 16:20 UTC (permalink / raw)
To: zsh-workers
> Any reason that
>
> "j" down-line-or-history
> "k" up-line-or-history
>
> aren't vi-down-line-or-history &al. by default?
I'll commit this patch. It should be trivial to reverse should
there actually be a reason for the original behavior.
Index: Src/Zle/zle_bindings.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_bindings.c,v
retrieving revision 1.1.1.3
diff -u -r1.1.1.3 zle_bindings.c
--- Src/Zle/zle_bindings.c 1999/12/01 18:36:09 1.1.1.3
+++ Src/Zle/zle_bindings.c 2000/12/16 16:16:30
@@ -396,8 +396,8 @@
/* g */ z_undefinedkey,
/* h */ z_vibackwardchar,
/* i */ z_viinsert,
- /* j */ z_downlineorhistory,
- /* k */ z_uplineorhistory,
+ /* j */ z_vidownlineorhistory,
+ /* k */ z_viuplineorhistory,
/* l */ z_viforwardchar,
/* m */ z_visetmark,
/* n */ z_virepeatsearch,
Index: Src/Zle/zle_keymap.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_keymap.c,v
retrieving revision 1.1.1.10
diff -u -r1.1.1.10 zle_keymap.c
--- Src/Zle/zle_keymap.c 1999/12/01 18:36:09 1.1.1.10
+++ Src/Zle/zle_keymap.c 2000/12/16 16:16:30
@@ -1067,12 +1067,12 @@
* Both standard and keypad modes are supported. */
/* vi command mode: arrow keys */
- bindkey(amap, "\33[A", refthingy(t_uplineorhistory), NULL);
- bindkey(amap, "\33[B", refthingy(t_downlineorhistory), NULL);
+ bindkey(amap, "\33[A", refthingy(t_viuplineorhistory), NULL);
+ bindkey(amap, "\33[B", refthingy(t_vidownlineorhistory), NULL);
bindkey(amap, "\33[C", refthingy(t_viforwardchar), NULL);
bindkey(amap, "\33[D", refthingy(t_vibackwardchar), NULL);
- bindkey(amap, "\33OA", refthingy(t_uplineorhistory), NULL);
- bindkey(amap, "\33OB", refthingy(t_downlineorhistory), NULL);
+ bindkey(amap, "\33OA", refthingy(t_viuplineorhistory), NULL);
+ bindkey(amap, "\33OB", refthingy(t_vidownlineorhistory), NULL);
bindkey(amap, "\33OC", refthingy(t_viforwardchar), NULL);
bindkey(amap, "\33OD", refthingy(t_vibackwardchar), NULL);
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: vicmd bindings
2000-12-15 22:20 vicmd bindings Clint Adams
2000-12-16 16:20 ` PATCH: " Clint Adams
@ 2000-12-16 18:08 ` Bart Schaefer
2000-12-20 1:57 ` Clint Adams
1 sibling, 1 reply; 9+ messages in thread
From: Bart Schaefer @ 2000-12-16 18:08 UTC (permalink / raw)
To: zsh-workers
On Dec 15, 5:20pm, Clint Adams wrote:
}
} Any reason that
}
} "j" down-line-or-history
} "k" up-line-or-history
}
} aren't vi-down-line-or-history &al. by default?
The most likely answer is that ksh's vi emulation is imperfect, and zsh
intentionally emulated ksh rather than emulating the real vi.
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: PATCH: Re: vicmd bindings
2000-12-16 16:20 ` PATCH: " Clint Adams
@ 2000-12-18 0:27 ` Zefram
2000-12-18 17:02 ` Clint Adams
0 siblings, 1 reply; 9+ messages in thread
From: Zefram @ 2000-12-18 0:27 UTC (permalink / raw)
To: Clint Adams; +Cc: zsh-workers
Clint Adams wrote:
>> Any reason that
>>
>> "j" down-line-or-history
>> "k" up-line-or-history
>>
>> aren't vi-down-line-or-history &al. by default?
The names are misleading: the vi- versions do something quite
different from the unprefixed versions, it's not just a question
of vi and Emacs doing something differently. You'll notice that
vi-{up,down}-line-or-history are bound to "-" and "+" by default --
vi has both types of line movement. (The difference is that the "-"/"+"
versions -- the "vi-"-prefixed widgets -- move the cursor to the beginning
of the target line, rather than leaving it at the same column.)
>I'll commit this patch. It should be trivial to reverse should
>there actually be a reason for the original behavior.
Your patch is wrong and should be reversed. (I have bandwidth issues
right now so I can't reverse it myself.) Without the patch, zle
accurately imitates vi in this respect.
-zefram
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: PATCH: Re: vicmd bindings
2000-12-18 0:27 ` Zefram
@ 2000-12-18 17:02 ` Clint Adams
2000-12-20 18:09 ` Zefram
0 siblings, 1 reply; 9+ messages in thread
From: Clint Adams @ 2000-12-18 17:02 UTC (permalink / raw)
To: Zefram; +Cc: zsh-workers
> Your patch is wrong and should be reversed. (I have bandwidth issues
> right now so I can't reverse it myself.) Without the patch, zle
> accurately imitates vi in this respect.
It doesn't appear to do so here. up-line-or-history leaves the cursor
at the end of the line rather than the same column.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: vicmd bindings
2000-12-16 18:08 ` Bart Schaefer
@ 2000-12-20 1:57 ` Clint Adams
0 siblings, 0 replies; 9+ messages in thread
From: Clint Adams @ 2000-12-20 1:57 UTC (permalink / raw)
To: Bart Schaefer; +Cc: zsh-workers
> 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;
}
/**/
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: PATCH: Re: vicmd bindings
2000-12-18 17:02 ` Clint Adams
@ 2000-12-20 18:09 ` Zefram
2000-12-21 13:28 ` Clint Adams
0 siblings, 1 reply; 9+ messages in thread
From: Zefram @ 2000-12-20 18:09 UTC (permalink / raw)
To: Clint Adams; +Cc: Zefram, zsh-workers
Clint Adams wrote:
>It doesn't appear to do so here. up-line-or-history leaves the cursor
>at the end of the line rather than the same column.
up-line-or-history leaves the cursor in the same column, as vi does,
when moving between lines within a single command. When it moves to
a prior history entry it does move to the end of the line; I'm in two
minds as to whether that should be changed.
-zefram
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: PATCH: Re: vicmd bindings
2000-12-20 18:09 ` Zefram
@ 2000-12-21 13:28 ` Clint Adams
2000-12-22 19:27 ` Zefram
0 siblings, 1 reply; 9+ messages in thread
From: Clint Adams @ 2000-12-21 13:28 UTC (permalink / raw)
To: Zefram; +Cc: zsh-workers
> up-line-or-history leaves the cursor in the same column, as vi does,
> when moving between lines within a single command. When it moves to
> a prior history entry it does move to the end of the line; I'm in two
> minds as to whether that should be changed.
Based on what factors?
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: PATCH: Re: vicmd bindings
2000-12-21 13:28 ` Clint Adams
@ 2000-12-22 19:27 ` Zefram
0 siblings, 0 replies; 9+ messages in thread
From: Zefram @ 2000-12-22 19:27 UTC (permalink / raw)
To: Clint Adams; +Cc: Zefram, zsh-workers
Clint Adams wrote:
>Based on what factors?
It seems vaguely sensible to move to the end of the line when going to
an separate history entry, which is effectively a new file to edit.
However, on reflection I've decided that it makes more sense for the
`-line-or-history' commands to place the cursor on the target line in
a consistent manner.
-zefram
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2000-12-22 19:28 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-12-15 22:20 vicmd bindings Clint Adams
2000-12-16 16:20 ` PATCH: " Clint Adams
2000-12-18 0:27 ` Zefram
2000-12-18 17:02 ` Clint Adams
2000-12-20 18:09 ` Zefram
2000-12-21 13:28 ` Clint Adams
2000-12-22 19:27 ` Zefram
2000-12-16 18:08 ` Bart Schaefer
2000-12-20 1:57 ` Clint Adams
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).