zsh-workers
 help / color / mirror / code / Atom feed
From: Mikael Magnusson <mikachu@gmail.com>
To: zsh-workers@zsh.org
Subject: PATCH: Add SHORT_KEYBIND_DISCARD option
Date: Sun,  3 Apr 2016 06:41:54 +0200	[thread overview]
Message-ID: <1459658514-24610-1-git-send-email-mikachu@gmail.com> (raw)

Not sure how popular this option would be, but I'm fine with keeping
it local too. Basically when we encounter an undefined key, instead
of discarding the entire common prefix, we discard only one byte and
try again. In most particular, it means if you happen to press escape
or ctrl-x before pasting, we still properly detect the bracketed-paste
starting code.

---
 Src/Zle/zle_keymap.c | 8 ++++++--
 Src/options.c        | 1 +
 Src/zsh.h            | 1 +
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/Src/Zle/zle_keymap.c b/Src/Zle/zle_keymap.c
index 7b11933..e8de0cd 100644
--- a/Src/Zle/zle_keymap.c
+++ b/Src/Zle/zle_keymap.c
@@ -1610,8 +1610,12 @@ getkeymapcmd(Keymap km, Thingy *funcp, char **strp)
 	if (!ispfx)
 	    break;
     }
-    if(!lastlen && keybuflen)
-	lastlen = keybuflen;
+    if(!lastlen && keybuflen) {
+	if (isset(SHORTKEYBINDDISCARD))
+	    lastlen = 1;
+	else
+	    lastlen = keybuflen;
+    }
     else
 	lastchar = lastc;
     if(lastlen != keybuflen) {
diff --git a/Src/options.c b/Src/options.c
index 008ebf1..fa20eb9 100644
--- a/Src/options.c
+++ b/Src/options.c
@@ -248,6 +248,7 @@ static struct optname optns[] = {
 {{NULL, "shinstdin",	      OPT_SPECIAL},		 SHINSTDIN},
 {{NULL, "shnullcmd",          OPT_EMULATE|OPT_BOURNE},	 SHNULLCMD},
 {{NULL, "shoptionletters",    OPT_EMULATE|OPT_BOURNE},	 SHOPTIONLETTERS},
+{{NULL, "shortkeybinddiscard",0},                        SHORTKEYBINDDISCARD},
 {{NULL, "shortloops",	      OPT_EMULATE|OPT_NONBOURNE},SHORTLOOPS},
 {{NULL, "shwordsplit",	      OPT_EMULATE|OPT_BOURNE},	 SHWORDSPLIT},
 {{NULL, "singlecommand",      OPT_SPECIAL},		 SINGLECOMMAND},
diff --git a/Src/zsh.h b/Src/zsh.h
index cbaa351..0dc3248 100644
--- a/Src/zsh.h
+++ b/Src/zsh.h
@@ -2358,6 +2358,7 @@ enum {
     SHNULLCMD,
     SHOPTIONLETTERS,
     SHORTLOOPS,
+    SHORTKEYBINDDISCARD,
     SHWORDSPLIT,
     SINGLECOMMAND,
     SINGLELINEZLE,
-- 
2.6.1


             reply	other threads:[~2016-04-03  4:42 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-03  4:41 Mikael Magnusson [this message]
2016-04-06 14:33 ` Oliver Kiddle
2016-04-06 18:06   ` Mikael Magnusson
2016-04-06 19:25     ` Bart Schaefer
2016-04-07 15:25     ` Oliver Kiddle
2016-04-07 16:07       ` Mikael Magnusson

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=1459658514-24610-1-git-send-email-mikachu@gmail.com \
    --to=mikachu@gmail.com \
    --cc=zsh-workers@zsh.org \
    /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).