Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: key bindings, fixes, docs, tests for vi stuff
- X-seq: zsh-workers 33956
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: "zsh-workers@xxxxxxx" <zsh-workers@xxxxxxx>
- Subject: Re: PATCH: key bindings, fixes, docs, tests for vi stuff
- Date: Fri, 12 Dec 2014 17:47:21 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1418402843; bh=EPvUSH68ZA6Wto/KofbEgcukfgRZ69yMfBUcruKwgk0=; h=In-reply-to:From:References:To:Subject:Date:From:Subject; b=sE6ZHO3HVzzp2pRz7/9yTq/TOpgNZ578OLthG5gkd7UKgNnCHXQIeHSEoGufnIpgDj4k3hw3/Th6t6uYSIafO2LoCJd6ZzOarJr4CYuzkcadJfOPOUHeaKirzFk9/nZPMKqkgFiFOiwn2BzXAdlA3l6zHFDFco12h7m46bvkxVTdK5kVUEXFmllHM1ZF07oXVn7zo1DBY3o02vR8SBt2BYqyOWI2tREqIdUuMS6ZVVVLGfoesRqbjBpmrxXnC44r+FpkIzIcDNmsMT/IoBPAanxK84D/zA8CWekChaJHiLz2hlpr4XamMpC93kfJRLtF7W5esvC9Qg6oerGcC8UuJQ==
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s2048; d=yahoo.co.uk; b=kHButeRpiACL9GM1CHbnPQHkp9bKoefseq8bn1/Ey198jq4iyrUKcPtpmCeCZRsyTomY/iCKjJoQZ7UsYDXH1E3Dsc5qWOSx6D44dutCMiJ7DuovmBc1izcBaeHdWcF1RKfFobnF8hlCcS6i4Y/5/5QzLLbBBhNy4MbWlrDKH1KJz2sHKEiogKHuyUEDgVzvLPhVZLHVPJlJoDa8fw8esPOLWTHZKvJwHmRxQl5D3zXWHsaC74WBAXg89QIQ9WNSIIsd5Iu2GOg9qc4x7t8DN5c1YdKEJ1DaAif/pT++jTuPt9/DOlpmh2eOUwJE0Bml5Q+WU+UCUstSapvawKztMg==;
- In-reply-to: <141121225957.ZM13909@torch.brasslantern.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <930.1416260160@thecus.kiddle.eu> <42F4E5F2-97E7-4803-87CB-B1C67CD943B2@kba.biglobe.ne.jp> <15511.1416528068@thecus.kiddle.eu> <141120164942.ZM3953@torch.brasslantern.com> <18016.1416566150@thecus.kiddle.eu> <141121225957.ZM13909@torch.brasslantern.com>
On 21 Nov, Bart wrote:
> But it shouldn't be that difficult to have the modules check for the
> existence of the keymap, skip re-creating it it if it's already there,
> and then only add bindings that don't conflict?
That won't work where people remove bindings. Maybe that's not too
common though I do it. Actually, looking at what I remove, I think
we should change the default binding of ^X in viins to be undefined
instead of self-insert. This is because the completion system adds a
bunch of widgets with a ^X prefix. Furthermore, vim uses ^X as a prefix
to mostly completion commands.
Coming back to the original question, it might be possible to make
keymaps a feature that causes module autoloading. If that doesn't work,
merging the defaults should be ok.
> } I also wonder if we could make it possible for shell function widgets
> } to specify some sort of default key binding much as is possible for
> } completion widgets.
>
> The widgets don't really specify their key binding, that's all done by
> compinit when it scans $fpath for #compdef lines. We could easily have
> another such script that looks for a different #something. There is
> already #autoload but it doesn't do bindings.
Somehow, I had thought compinit only looked at files named comp* or
_* but apparently not. I still would have considered #autoload as
implying the function was completion related. It seems a bit wasteful
to have two scripts scanning the whole of $fpath and generating caches.
Perhaps we should squeeze it into compinit and accept that it leaves
compinit badly named. Or is it better to somehow factor out that step
and share the results. An alternative might be to have separate *init
functions containing hardcoded lists of widget names so you might have a
zleviminit that would autoload a fixed list of widgets.
The patch below contains documentation to the vi default keys change I
proposed before. I've added in the removal of ^X in viins and the g~~
binding. It took me by surprise to see that redo is not bound by default
in emacs mode. Seems you have to reverse the direction of undo in emacs,
right? I can't remember any complaints about the lack of strict emacs
compatibility leading to lost changes there. I'm inclined to go ahead
with the vi mode undo change: vim converts probably outnumber vi purists
among zsh vi mode users.
Oliver
diff --git a/Doc/Zsh/zle.yo b/Doc/Zsh/zle.yo
index d49c720..dd8e628 100644
--- a/Doc/Zsh/zle.yo
+++ b/Doc/Zsh/zle.yo
@@ -1073,7 +1073,7 @@ Move backward one word, where a word is defined as a series of
non-blank characters.
)
tindex(vi-backward-blank-word-end)
-item(tt(vi-backward-blank-word-end) (unbound) (unbound) (unbound))(
+item(tt(vi-backward-blank-word-end) (unbound) (gE) (unbound))(
Move to the end of the previous word, where a word is defined as a
series of non-blank characters.
)
@@ -1098,7 +1098,7 @@ item(tt(vi-backward-word) (unbound) (b) (unbound))(
Move to the beginning of the previous word, vi-style.
)
tindex(vi-backward-word-end)
-item(tt(vi-backward-word-end) (unbound) (unbound) (unbound))(
+item(tt(vi-backward-word-end) (unbound) (ge) (unbound))(
Move to the end of the previous word, vi-style.
)
tindex(beginning-of-line)
@@ -1215,7 +1215,7 @@ texinode(History Control)(Modifying Text)(Movement)(Zle Widgets)
subsect(History Control)
startitem()
tindex(beginning-of-buffer-or-history)
-item(tt(beginning-of-buffer-or-history) (ESC-<) (unbound) (unbound))(
+item(tt(beginning-of-buffer-or-history) (ESC-<) (gg) (unbound))(
Move to the beginning of the buffer, or if already there,
move to the first event in the history list.
)
@@ -1728,7 +1728,7 @@ item(tt(vi-open-line-below) (unbound) (o) (unbound))(
Open a line below the cursor and enter insert mode.
)
tindex(vi-oper-swap-case)
-item(tt(vi-oper-swap-case))(
+item(tt(vi-oper-swap-case) (unbound) (g~) (unbound))(
Read a movement command from the keyboard, and swap
the case of all characters
from the cursor position to the endpoint of the movement.
@@ -2286,7 +2286,7 @@ This command is executed when a key sequence that is not bound to any
command is typed. By default it beeps.
)
tindex(undo)
-item(tt(undo) (^_ ^Xu ^X^U) (unbound) (unbound))(
+item(tt(undo) (^_ ^Xu ^X^U) (u) (unbound))(
Incrementally undo the last text modification. When called from a
user-defined widget, takes an optional argument indicating a previous state
of the undo history as returned by the tt(UNDO_CHANGE_NO) variable;
@@ -2297,11 +2297,11 @@ insert mode is reverted, the changes having been merged when command mode was
selected.
)
tindex(redo)
-item(tt(redo))(
+item(tt(redo) (unbound) (^R) (unbound))(
Incrementally redo undone text modifications.
)
tindex(vi-undo-change)
-item(tt(vi-undo-change) (unbound) (u) (unbound))(
+item(tt(vi-undo-change) (unbound) (unbound) (unbound))(
Undo the last text modification.
If repeated, redo the modification.
)
@@ -2320,7 +2320,7 @@ following an operator, it forces the subsequent movement command to be
treated as a line-wise movement.
)
tindex(what-cursor-position)
-item(tt(what-cursor-position) (^X=) (unbound) (unbound))(
+item(tt(what-cursor-position) (^X=) (ga) (unbound))(
Print the character under the cursor, its code as an octal, decimal and
hexadecimal number, the current cursor position within the buffer and the
column of the cursor in the current line.
diff --git a/Src/Zle/zle_bindings.c b/Src/Zle/zle_bindings.c
index e3337d0..2ae8c87 100644
--- a/Src/Zle/zle_bindings.c
+++ b/Src/Zle/zle_bindings.c
@@ -278,7 +278,7 @@ int viinsbind[32] = {
/* ^U */ z_vikillline,
/* ^V */ z_viquotedinsert,
/* ^W */ z_vibackwardkillword,
- /* ^X */ z_selfinsert,
+ /* ^X */ z_undefinedkey,
/* ^Y */ z_selfinsert,
/* ^Z */ z_selfinsert,
/* ^[ */ z_vicmdmode,
diff --git a/Src/Zle/zle_keymap.c b/Src/Zle/zle_keymap.c
index afba592..be02f3a 100644
--- a/Src/Zle/zle_keymap.c
+++ b/Src/Zle/zle_keymap.c
@@ -1373,6 +1373,7 @@ default_bindings(void)
bindkey(amap, "gE", refthingy(t_vibackwardblankwordend), NULL);
bindkey(amap, "gg", refthingy(t_beginningofbufferorhistory), NULL);
bindkey(amap, "g~", refthingy(t_vioperswapcase), NULL);
+ bindkey(amap, "g~~", NULL, "g~g~");
/* emacs mode: arrow keys */
add_cursor_key(emap, TCUPCURSOR, t_uplineorhistory, 'A');
- References:
- PATCH: key bindings, fixes, docs, tests for vi stuff
- Re: PATCH: key bindings, fixes, docs, tests for vi stuff
- Re: PATCH: key bindings, fixes, docs, tests for vi stuff
- Re: PATCH: key bindings, fixes, docs, tests for vi stuff
- Re: PATCH: key bindings, fixes, docs, tests for vi stuff
- Re: PATCH: key bindings, fixes, docs, tests for vi stuff
Messages sorted by:
Reverse Date,
Date,
Thread,
Author