Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: documentation on keymap selection
On Fri, 3 Sep 2010 23:06:10 +0100
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx> wrote:
> Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx> wrote:
> > It doesn't address the issue that "bindkey -lL" lies about aliased
> > keymaps.
>
> This does.
While I'm at it, this seems a natural extension.
Index: Doc/Zsh/zle.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/zle.yo,v
retrieving revision 1.85
diff -p -u -r1.85 zle.yo
--- Doc/Zsh/zle.yo 5 Sep 2010 19:24:44 -0000 1.85
+++ Doc/Zsh/zle.yo 5 Sep 2010 19:39:50 -0000
@@ -139,7 +139,7 @@ cindex(rebinding keys)
cindex(keys, binding)
cindex(binding keys)
cindex(keymaps)
-xitem(tt(bindkey) [ var(options) ] tt(-l))
+xitem(tt(bindkey) [ var(options) ] tt(-l) [ tt(-l) ] [ var(keymap) ... ])
xitem(tt(bindkey) [ var(options) ] tt(-d))
xitem(tt(bindkey) [ var(options) ] tt(-D) var(keymap) ...)
xitem(tt(bindkey) [ var(options) ] tt(-A) var(old-keymap new-keymap))
@@ -179,10 +179,13 @@ selected, namely:
startitem()
item(tt(-l))(
-List all existing keymap names. If the tt(-L)
-option is also used, list in the form of tt(bindkey)
-commands to create the keymaps; this combination also shows
-which keymap is linked to `tt(main)', if any.
+List all existing keymap names; if any arguments are given, list just
+those keymaps.
+
+If the tt(-L) option is also used, list in the form of tt(bindkey)
+commands to create or link the keymaps. `tt(bindkey -lL
+main)' shows which keymap is linked to `tt(main)', if any, and hence if
+the standard emacs or vi emulation is in effect.
)
item(tt(-d))(
Delete all existing keymaps and reset to the default state.
Index: Src/Zle/zle_keymap.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_keymap.c,v
retrieving revision 1.33
diff -p -u -r1.33 zle_keymap.c
--- Src/Zle/zle_keymap.c 5 Sep 2010 19:24:49 -0000 1.33
+++ Src/Zle/zle_keymap.c 5 Sep 2010 19:39:50 -0000
@@ -724,7 +724,7 @@ bin_bindkey(char *name, char **argv, Opt
int (*func) _((char *, char *, Keymap, char **, Options, char));
int min, max;
} const opns[] = {
- { 'l', 0, bin_bindkey_lsmaps, 0, 0 },
+ { 'l', 0, bin_bindkey_lsmaps, 0, -1 },
{ 'd', 0, bin_bindkey_delall, 0, 0 },
{ 'D', 0, bin_bindkey_del, 1, -1 },
{ 'A', 0, bin_bindkey_link, 2, 2 },
@@ -807,10 +807,24 @@ bin_bindkey(char *name, char **argv, Opt
/**/
static int
-bin_bindkey_lsmaps(UNUSED(char *name), UNUSED(char *kmname), UNUSED(Keymap km), UNUSED(char **argv), Options ops, UNUSED(char func))
+bin_bindkey_lsmaps(char *name, UNUSED(char *kmname), UNUSED(Keymap km), char **argv, Options ops, UNUSED(char func))
{
- scanhashtable(keymapnamtab, 1, 0, 0, scanlistmaps, OPT_ISSET(ops,'L'));
- return 0;
+ int ret = 0;
+ if (*argv) {
+ for (; *argv; argv++) {
+ KeymapName kmn = (KeymapName)
+ keymapnamtab->getnode(keymapnamtab, *argv);
+ if (!kmn) {
+ zwarnnam(name, "no such keymap: `%s'", *argv);
+ ret = 1;
+ } else {
+ scanlistmaps((HashNode)kmn, OPT_ISSET(ops,'L'));
+ }
+ }
+ } else {
+ scanhashtable(keymapnamtab, 1, 0, 0, scanlistmaps, OPT_ISSET(ops,'L'));
+ }
+ return ret;
}
/**/
--
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/
Messages sorted by:
Reverse Date,
Date,
Thread,
Author