From: "Pete Hollobon" <pete@hollobon.com>
To: zsh-workers@sunsite.dk
Subject: PATCH: customisable menu selection keymap
Date: Sun, 8 Apr 2007 00:16:57 +0100 [thread overview]
Message-ID: <2ddaa6ea0704071616t7fe7f5davb48d458cd26bcb22@mail.gmail.com> (raw)
Hi,
I wanted to use a custom keymap for certain menu selections (in
particular with cd - , to choose a directory from the stack and change
to it by pressing enter once rather than twice).
These two patches seem to do the trick:
Index: Src/Zle/complist.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/complist.c,v
retrieving revision 1.102
diff -d -u -w -r1.102 complist.c
--- Src/Zle/complist.c 2 Apr 2007 13:58:19 -0000 1.102
+++ Src/Zle/complist.c 7 Apr 2007 23:12:56 -0000
@@ -2222,6 +2222,8 @@
int nolist = 0, mode = 0, modecs, modell, modelen, wasmeta;
char *s;
char status[MAX_STATUS], *modeline = NULL;
+ char *user_mskeymapname;
+ Keymap user_mskeymap;
msearchstack = NULL;
msearchstr = "";
@@ -2291,6 +2293,10 @@
unqueue_signals();
mhasstat = (mstatus && *mstatus);
fdat = dat;
+ if ((user_mskeymapname = getsparam("MENUKEYMAP")) &&
+ (user_mskeymap = openkeymap(user_mskeymapname)))
+ selectlocalmap(user_mskeymap);
+ else
selectlocalmap(mskeymap);
noselect = 1;
while ((menuacc &&
Index: Completion/Base/Core/_main_complete
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/Core/_main_complete,v
retrieving revision 1.10
diff -d -u -w -r1.10 _main_complete
--- Completion/Base/Core/_main_complete 1 Oct 2004 10:29:21 -0000 1.10
+++ Completion/Base/Core/_main_complete 7 Apr 2007 23:12:26 -0000
@@ -292,6 +292,17 @@
else
unset MENUMODE
fi
+
+ keymap=( "${(@M)_menu_style:#keymap*}" )
+
+ if (( $#keymap )); then
+ for i in "$keymap[@]"; do
+ if [[ "$i" = *\=* ]]; then
+ MENUKEYMAP="${i#*\=}"
+ break
+ fi
+ done
+ fi
fi
fi
elif [[ nm -lt 1 && -n "$_comp_mesg" ]]; then
That then lets me use my special keymap only for directory completion:
bindkey -N pete_menuselect
bindkey -M pete_menuselect '^M' .accept-line
# Use menu selection on directory stack completion
zstyle ":completion:*:directory-stack" menu yes 'select=0'
'keymap=pete_menuselect'
Is this likely to be useful to anyone else?
Thanks,
Pete
reply other threads:[~2007-04-07 23:17 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2ddaa6ea0704071616t7fe7f5davb48d458cd26bcb22@mail.gmail.com \
--to=pete@hollobon.com \
--cc=zsh-workers@sunsite.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).