Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: customisable menu selection keymap
- X-seq: zsh-workers 23267
- From: "Pete Hollobon" <pete@xxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxx
- Subject: PATCH: customisable menu selection keymap
- Date: Sun, 8 Apr 2007 00:16:57 +0100
- Dkim-signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition:x-google-sender-auth; b=ZmWJR84/PMHyeNzy5MHUdCWZphGwmxda13pesnKNjjUoW0Uj2r5xDWd4Tm1ySuO9fHUYLeE8nsLSbbYr+4PZOVroqiPzau4fwSRgtEhY/I2ocYcB74H3Ow2rSVYXBNjPrXspHQlX+UtCRHxI9+KXOlrPWxFfzX9zLM3LMJb0BwI=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:sender:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition:x-google-sender-auth; b=JvS/0cnX3B1r5FcnSbjeevdpFEu8tJA7K6oWY62mdkcfbbiV368/Wbqx4RzX4bHOjf232M5Jy6te8sFRqSOmMd5ukAGNJeBoKs20G3rn8JhATaqNuRfWMRexcdZONRzYv01HO94dyBaPgOYF95UOJL4P9GE/dU4VAQz6E6kitRA=
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- Sender: hollobon@xxxxxxxxx
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author