zsh-workers
 help / color / mirror / code / Atom feed
* More on getkeycmd()
@ 2005-09-27 14:53 Bart Schaefer
  2005-09-27 15:01 ` Peter Stephenson
  2014-11-03  8:45 ` PATCH: give precedence to local keymaps (was Re: More on getkeycmd()) Oliver Kiddle
  0 siblings, 2 replies; 7+ messages in thread
From: Bart Schaefer @ 2005-09-27 14:53 UTC (permalink / raw)
  To: zsh-workers

It occurred to me that the patch I posted in 21760 causes longer bindings
in the local map to hide prefixes in the global map.  That's probably not
the desired behavior; the change would be as follows.  Should this get
committed also?

Index: Src/Zle/zle_keymap.c
===================================================================
diff -c -r1.11 zle_keymap.c
--- Src/Zle/zle_keymap.c	27 Sep 2005 14:40:38 -0000	1.11
+++ Src/Zle/zle_keymap.c	27 Sep 2005 14:47:10 -0000
@@ -1300,10 +1300,9 @@
 	    loc = ((f = keybind(localkeymap, keybuf, &s)) != t_undefinedkey);
 	    ispfx = keyisprefix(localkeymap, keybuf);
 	}
-	if (!loc && !ispfx) {
+	if (!loc)
 	    f = keybind(km, keybuf, &s);
-	    ispfx = keyisprefix(km, keybuf);
-	}
+	ispfx |= keyisprefix(km, keybuf);
 
 	if (f != t_undefinedkey) {
 	    lastlen = keybuflen;


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: More on getkeycmd()
  2005-09-27 14:53 More on getkeycmd() Bart Schaefer
@ 2005-09-27 15:01 ` Peter Stephenson
  2005-09-27 15:43   ` Bart Schaefer
  2014-11-03  8:45 ` PATCH: give precedence to local keymaps (was Re: More on getkeycmd()) Oliver Kiddle
  1 sibling, 1 reply; 7+ messages in thread
From: Peter Stephenson @ 2005-09-27 15:01 UTC (permalink / raw)
  To: zsh-workers

Bart Schaefer <schaefer@brasslantern.com> wrote:
> It occurred to me that the patch I posted in 21760 causes longer bindings
> in the local map to hide prefixes in the global map.  That's probably not
> the desired behavior; the change would be as follows.  Should this get
> committed also?

I suppose you mean a key binding XYA in the local map hides XC or XYB in the
global map.  I would think that's bad.

pws


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

**********************************************************************


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: More on getkeycmd()
  2005-09-27 15:01 ` Peter Stephenson
@ 2005-09-27 15:43   ` Bart Schaefer
  0 siblings, 0 replies; 7+ messages in thread
From: Bart Schaefer @ 2005-09-27 15:43 UTC (permalink / raw)
  To: zsh-workers

On Sep 27,  4:01pm, Peter Stephenson wrote:
}
} I suppose you mean a key binding XYA in the local map hides XC or XYB in the
} global map.

No, I mean local binding XYA hides global bindings X or XY.  XC or XYB would
still work.

} I would think that's bad.

Clearly the XC or XYB scenario would be, but (notably in the case of menu-
selection) I'm not as certain about X and XY.  However, I'll go ahead and
commit 21770.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* PATCH: give precedence to local keymaps (was Re: More on getkeycmd())
  2005-09-27 14:53 More on getkeycmd() Bart Schaefer
  2005-09-27 15:01 ` Peter Stephenson
@ 2014-11-03  8:45 ` Oliver Kiddle
  2014-11-03  9:33   ` Bart Schaefer
  1 sibling, 1 reply; 7+ messages in thread
From: Oliver Kiddle @ 2014-11-03  8:45 UTC (permalink / raw)
  To: Zsh workers

I'd like to back out the change in 21770:

At the time, on 27 Sep 2005, Bart wrote:
> It occurred to me that the patch I posted in 21760 causes longer bindings
> in the local map to hide prefixes in the global map.  That's probably not
> the desired behavior; the change would be as follows.  Should this get
> committed also?

I find in practice that this hiding is my desired behaviour. The
alternative is shorter bindings in the global map hiding longer ones in
the local map. If you want to preserve the global binding, simply don't
bind longer ones in the local map. The other way around tends to be less
possible because the global map has a wider purpose.

Oliver

diff --git a/Src/Zle/zle_keymap.c b/Src/Zle/zle_keymap.c
index 2e54e7f..e21e769 100644
--- a/Src/Zle/zle_keymap.c
+++ b/Src/Zle/zle_keymap.c
@@ -1435,10 +1435,9 @@ getkeymapcmd(Keymap km, Thingy *funcp, char **strp)
 	    loc = ((f = keybind(localkeymap, keybuf, &s)) != t_undefinedkey);
 	    ispfx = keyisprefix(localkeymap, keybuf);
 	}
-	if (!loc && !ispfx) {
+	if (!loc)
 	    f = keybind(km, keybuf, &s);
-	    ispfx = keyisprefix(km, keybuf);
-	}
+	ispfx |= keyisprefix(km, keybuf);
 
 	if (f != t_undefinedkey) {
 	    lastlen = keybuflen;


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: PATCH: give precedence to local keymaps (was Re: More on getkeycmd())
  2014-11-03  8:45 ` PATCH: give precedence to local keymaps (was Re: More on getkeycmd()) Oliver Kiddle
@ 2014-11-03  9:33   ` Bart Schaefer
  2014-11-03 16:30     ` Oliver Kiddle
  0 siblings, 1 reply; 7+ messages in thread
From: Bart Schaefer @ 2014-11-03  9:33 UTC (permalink / raw)
  To: Zsh hackers list

[-- Attachment #1: Type: text/plain, Size: 263 bytes --]

On Nov 3, 2014 12:51 AM, "Oliver Kiddle" <okiddle@yahoo.co.uk> wrote:
>
> I'd like to back out the change in 21770:

I don't particularly object, though of course the ideal behavior would be
that the prefix would be treated as such whenever the two maps overlap.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: PATCH: give precedence to local keymaps (was Re: More on getkeycmd())
  2014-11-03  9:33   ` Bart Schaefer
@ 2014-11-03 16:30     ` Oliver Kiddle
  2014-11-04  3:58       ` Bart Schaefer
  0 siblings, 1 reply; 7+ messages in thread
From: Oliver Kiddle @ 2014-11-03 16:30 UTC (permalink / raw)
  To: Zsh hackers list

Bart wrote:
> 
> I don't particularly object, though of course the ideal behavior would be
> that the prefix would be treated as such whenever the two maps overlap.

Well, no: I don't want to treat the key as a prefix when the global
binding is a prefix of the local binding because then I'm forced to
type the local binding faster than $KEYTIMEOUT. I use a fairly short
$KEYTIMEOUT having had problems with escape followed by vi commands
being interpreted as a key sequence.

How about the following patch? This does hiding in the case I mention
above but not for the converse: a local binding that is a prefix of a
global binding won't hide the longer global binding: you might not want
the small $KEYTIMEOUT delay but that's harmless compared to having to
type your keys faster than it.

Oliver

diff --git a/Src/Zle/zle_keymap.c b/Src/Zle/zle_keymap.c
index e21e769..6a71076 100644
--- a/Src/Zle/zle_keymap.c
+++ b/Src/Zle/zle_keymap.c
@@ -1435,7 +1435,7 @@ getkeymapcmd(Keymap km, Thingy *funcp, char **strp)
 	    loc = ((f = keybind(localkeymap, keybuf, &s)) != t_undefinedkey);
 	    ispfx = keyisprefix(localkeymap, keybuf);
 	}
-	if (!loc)
+	if (!loc && !ispfx)
 	    f = keybind(km, keybuf, &s);
 	ispfx |= keyisprefix(km, keybuf);
 


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: PATCH: give precedence to local keymaps (was Re: More on getkeycmd())
  2014-11-03 16:30     ` Oliver Kiddle
@ 2014-11-04  3:58       ` Bart Schaefer
  0 siblings, 0 replies; 7+ messages in thread
From: Bart Schaefer @ 2014-11-04  3:58 UTC (permalink / raw)
  To: Zsh hackers list

On Nov 3,  5:30pm, Oliver Kiddle wrote:
} Subject: Re: PATCH: give precedence to local keymaps (was Re: More on getk
}
} Bart wrote:
} > 
} > I don't particularly object, though of course the ideal behavior would be
} > that the prefix would be treated as such whenever the two maps overlap.
} 
} Well, no: I don't want to treat the key as a prefix when the global
} binding is a prefix of the local binding because then I'm forced to
} type the local binding faster than $KEYTIMEOUT.

Hmm, I can see where that might be an issue for vi-mode.  I'm strictly
an emacs-mode person when in the shell (although I'm editing this
message in vim) and the behavior I described is similar to the way
keymaps work in emacs.

} How about the following patch? This does hiding in the case I mention
} above but not for the converse: a local binding that is a prefix of a
} global binding won't hide the longer global binding

That's probably quite sufficient.


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-11-04  3:58 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-27 14:53 More on getkeycmd() Bart Schaefer
2005-09-27 15:01 ` Peter Stephenson
2005-09-27 15:43   ` Bart Schaefer
2014-11-03  8:45 ` PATCH: give precedence to local keymaps (was Re: More on getkeycmd()) Oliver Kiddle
2014-11-03  9:33   ` Bart Schaefer
2014-11-03 16:30     ` Oliver Kiddle
2014-11-04  3:58       ` Bart Schaefer

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).