* PATCH: customisable menu selection keymap
@ 2007-04-07 23:16 Pete Hollobon
0 siblings, 0 replies; only message in thread
From: Pete Hollobon @ 2007-04-07 23:16 UTC (permalink / raw)
To: zsh-workers
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2007-04-07 23:17 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-04-07 23:16 PATCH: customisable menu selection keymap Pete Hollobon
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).