mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-10-17 00:31:09 +02:00
Add `bindkey -p'
This commit is contained in:
parent
3052985d1f
commit
19a8356ff1
4 changed files with 30 additions and 2 deletions
|
@ -1,5 +1,9 @@
|
|||
2001-03-28 Peter Stephenson <pws@csr.com>
|
||||
|
||||
* 13818: Doc/Zsh/zle.yo, Src/Zle/zle_keymap,c. Src/Zle/zle_main.c
|
||||
[zle_main hunk got omitted from posted patch, oops]: Add
|
||||
`bindkey -p' to list bindings with a given prefix.
|
||||
|
||||
* unposted: Doc/Zsh/zle.yo, Doc/Zsh/mod_zle.yo: move ZLE builtin
|
||||
documentation from mod_zle.yo to zle.yo.
|
||||
|
||||
|
|
|
@ -195,6 +195,10 @@ if the tt(-e) or tt(-v) option is used alone, the keymap is em(not)
|
|||
displayed - the implicit linking of keymaps is the only thing that
|
||||
happens.)
|
||||
|
||||
When the option tt(-p) is used, the var(in-string) must be present.
|
||||
The listing shows all bindings which have the given key sequence as a
|
||||
prefix, not including any bindings for the key sequence itself.
|
||||
|
||||
When the tt(-L) option is used, the list is in the form of tt(bindkey)
|
||||
commands to create the key bindings.
|
||||
)
|
||||
|
|
|
@ -86,6 +86,8 @@ struct bindstate {
|
|||
char *lastseq;
|
||||
Thingy bind;
|
||||
char *str;
|
||||
char *prefix;
|
||||
int prefixlen;
|
||||
};
|
||||
|
||||
#define BS_LIST (1<<0)
|
||||
|
@ -890,7 +892,7 @@ bin_bindkey_list(char *name, char *kmname, Keymap km, char **argv, char *ops, ch
|
|||
|
||||
bs.flags = ops['L'] ? BS_LIST : 0;
|
||||
bs.kmname = kmname;
|
||||
if(argv[0]) {
|
||||
if(argv[0] && !ops['p']) {
|
||||
int len;
|
||||
char *seq;
|
||||
|
||||
|
@ -899,8 +901,22 @@ bin_bindkey_list(char *name, char *kmname, Keymap km, char **argv, char *ops, ch
|
|||
bs.flags |= BS_ALL;
|
||||
bs.firstseq = bs.lastseq = seq;
|
||||
bs.bind = keybind(km, seq, &bs.str);
|
||||
bs.prefix = NULL;
|
||||
bs.prefixlen = 0;
|
||||
bindlistout(&bs);
|
||||
} else {
|
||||
/* empty prefix is equivalent to no prefix */
|
||||
if (ops['p'] && (!argv[0] || argv[0][0])) {
|
||||
if (!argv[0]) {
|
||||
zwarnnam(name, "option -p requires a prefix string", NULL, 0);
|
||||
return 1;
|
||||
}
|
||||
bs.prefix = getkeystring(argv[0], &bs.prefixlen, 2, NULL);
|
||||
bs.prefix = metafy(bs.prefix, bs.prefixlen, META_HREALLOC);
|
||||
} else {
|
||||
bs.prefix = NULL;
|
||||
bs.prefixlen = 0;
|
||||
}
|
||||
bs.firstseq = ztrdup("");
|
||||
bs.lastseq = ztrdup("");
|
||||
bs.bind = t_undefinedkey;
|
||||
|
@ -919,6 +935,10 @@ scanbindlist(char *seq, Thingy bind, char *str, void *magic)
|
|||
{
|
||||
struct bindstate *bs = magic;
|
||||
|
||||
if (bs->prefixlen &&
|
||||
(strncmp(seq, bs->prefix, bs->prefixlen) || !seq[bs->prefixlen]))
|
||||
return;
|
||||
|
||||
if(bind == bs->bind && (bind || !strcmp(str, bs->str)) &&
|
||||
ztrlen(seq) == 1 && ztrlen(bs->lastseq) == 1) {
|
||||
int l = bs->lastseq[1] ?
|
||||
|
|
|
@ -1091,7 +1091,7 @@ zleaftertrap(Hookdef dummy, void *dat)
|
|||
}
|
||||
|
||||
static struct builtin bintab[] = {
|
||||
BUILTIN("bindkey", 0, bin_bindkey, 0, -1, 0, "evaMldDANmrsLR", NULL),
|
||||
BUILTIN("bindkey", 0, bin_bindkey, 0, -1, 0, "evaMldDANmrsLRp", NULL),
|
||||
BUILTIN("vared", 0, bin_vared, 1, 7, 0, NULL, NULL),
|
||||
BUILTIN("zle", 0, bin_zle, 0, -1, 0, "lDANCLmMgGcRaUI", NULL),
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue