about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2010-09-05 20:39:08 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2010-09-05 20:39:08 +0000
commitff955f61b4ae277fa82ff0097d47047198aeaefc (patch)
treefcdf65dd77629a20d9f9c3b14274e1277d9c1918
parent17dee17e4e5ab99cd50e6ee3a21a8d6faa4aac96 (diff)
downloadzsh-ff955f61b4ae277fa82ff0097d47047198aeaefc.tar.gz
zsh-ff955f61b4ae277fa82ff0097d47047198aeaefc.tar.xz
zsh-ff955f61b4ae277fa82ff0097d47047198aeaefc.zip
28229: can list individual keymaps
-rw-r--r--ChangeLog7
-rw-r--r--Doc/Zsh/zle.yo13
-rw-r--r--Src/Zle/zle_keymap.c22
3 files changed, 30 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index fec8ce11e..87108093f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,8 @@
 2010-09-05  Peter Stephenson  <p.w.stephenson@ntlworld.com>
 
-	* 28226: Doc/Zsh/zle.yo, Src/Zle/zle_keymap.c: "bindkey -lL" now
-	lists aliased keymaps in a more useful way.
+	* 28226, 28229: Doc/Zsh/zle.yo, Src/Zle/zle_keymap.c: "bindkey
+	-lL" now lists aliased keymaps in a more useful way; can list
+	individual keymaps.
 
 	* 28227: Doc/Zsh/zle.yo: a few remarks on the question of
 	keymaps.
@@ -13599,5 +13600,5 @@
 
 *****************************************************
 * This is used by the shell to define $ZSH_PATCHLEVEL
-* $Revision: 1.5069 $
+* $Revision: 1.5070 $
 *****************************************************
diff --git a/Doc/Zsh/zle.yo b/Doc/Zsh/zle.yo
index 64012fd2f..f85f63f26 100644
--- a/Doc/Zsh/zle.yo
+++ b/Doc/Zsh/zle.yo
@@ -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.
diff --git a/Src/Zle/zle_keymap.c b/Src/Zle/zle_keymap.c
index 0d250c585..8fa8e9883 100644
--- a/Src/Zle/zle_keymap.c
+++ b/Src/Zle/zle_keymap.c
@@ -724,7 +724,7 @@ bin_bindkey(char *name, char **argv, Options ops, UNUSED(int func))
 	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, Options ops, UNUSED(int func))
 
 /**/
 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;
 }
 
 /**/