zsh-workers
 help / color / mirror / code / Atom feed
* Troublesome Key Bindings
@ 2001-03-14  9:05 Zvi Har'El
  2001-03-14 10:44 ` Peter Stephenson
  0 siblings, 1 reply; 6+ messages in thread
From: Zvi Har'El @ 2001-03-14  9:05 UTC (permalink / raw)
  To: Zsh hackers list

Dear Friends,

I am using zsh in vi insert mode (being an fanatic ViM user). After doing
compinit, which introduced many new key binding, I started having troubles in
history searches: Although most of the new bindings have the prefix ^X, there
are three with a prefix ^[, i.e., the escape character. These are

	"^[," _history-complete-newer
	"^[/" _history-complete-older
	"^[~" _bash_complete-word

The second of this trio is ***very troublesome***, to say the least!!! To
search the history in vi mode, I have to hit the escape character - to switch
to vi command mode, and then the slash character. Since I have done that for
quite some time now, I find it quite difficult to pause methodically between
the two characters! And the result is that I get into the
_history-complete-older booby trap! The zsh man page says:

	     As  some  of  these  bindings
              clash  with  standard  zsh bindings, only `\e~' and
              `^X~' are bound by default.  To add the  rest,  the
              following  should be added to .zshrc 

etc. I added the line

	bindkey -r \\e/

to my .zshrc right after the compinit invocation, but I think the correct
default behavior should be the one stated in the man page.

Best,

Zvi.
-- 
Dr. Zvi Har'El     mailto:rl@math.technion.ac.il     Department of Mathematics
tel:+972-54-227607                   Technion - Israel Institute of Technology
fax:+972-4-8324654 http://www.math.technion.ac.il/~rl/     Haifa 32000, ISRAEL
"If you can't say somethin' nice, don't say nothin' at all." -- Thumper (1942)
                               Wednesday, 19 Adar 5761, 14 March 2001, 10:08AM



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

* Re: Troublesome Key Bindings
  2001-03-14  9:05 Troublesome Key Bindings Zvi Har'El
@ 2001-03-14 10:44 ` Peter Stephenson
  2001-03-14 11:09   ` Andrej Borsenkow
  2001-03-14 17:33   ` Bart Schaefer
  0 siblings, 2 replies; 6+ messages in thread
From: Peter Stephenson @ 2001-03-14 10:44 UTC (permalink / raw)
  To: Zsh hackers list

"Zvi Har'El" <rl@math.technion.ac.il> wrote:
> I am using zsh in vi insert mode (being an fanatic ViM user). After doing
> compinit, which introduced many new key binding, I started having troubles in
> history searches: Although most of the new bindings have the prefix ^X, there
> are three with a prefix ^[, i.e., the escape character. These are
> 
> 	"^[," _history-complete-newer
> 	"^[/" _history-complete-older
> 	"^[~" _bash_complete-word
> 
> The second of this trio is ***very troublesome***, to say the least!!! To
> search the history in vi mode, I have to hit the escape character - to switch
> to vi command mode, and then the slash character.

It's only the _bash* functions that depend on the particular binding ---
and that's only to make it easy to set things up like bash; they actually
do basic completion things which can be managed other ways (they weren't
intended to be anything more than a simple trick for compatibility).

So for the first two, you can simply use bindkey to map them to something
else straight away:
  bindkey '^X/' _history-complete-older
If you need any of the non-contextual bash-style completions, you can look
in the function _bash_completions and pick out the ones you want.  This
could be as simple as

_complete_users() {
  setopt localoptions ${_comp_options[@]}

  _main_complete _users
}
zle -C _complete_users .complete-word _complete_users
bindkey '<your-binding>' _complete_users

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Unit 300, Science Park, Milton Road,
Cambridge, CB4 0XL, UK                          Tel: +44 (0)1223 392070


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

* RE: Troublesome Key Bindings
  2001-03-14 10:44 ` Peter Stephenson
@ 2001-03-14 11:09   ` Andrej Borsenkow
  2001-03-14 11:12     ` Andrej Borsenkow
  2001-03-14 17:33   ` Bart Schaefer
  1 sibling, 1 reply; 6+ messages in thread
From: Andrej Borsenkow @ 2001-03-14 11:09 UTC (permalink / raw)
  To: Zsh hackers list

[I believe, it's more for zsh-users actually]


>
> "Zvi Har'El" <rl@math.technion.ac.il> wrote:
> > I am using zsh in vi insert mode (being an fanatic ViM user). After doing
> > compinit, which introduced many new key binding, I started having
> troubles in
> > history searches: Although most of the new bindings have the
> prefix ^X, there
> > are three with a prefix ^[, i.e., the escape character. These are
> >
> > 	"^[," _history-complete-newer
> > 	"^[/" _history-complete-older
> > 	"^[~" _bash_complete-word
> >
> > The second of this trio is ***very troublesome***, to say the least!!! To
> > search the history in vi mode, I have to hit the escape character
> - to switch
> > to vi command mode, and then the slash character.
>
> It's only the _bash* functions that depend on the particular binding ---
> and that's only to make it easy to set things up like bash; they actually
> do basic completion things which can be managed other ways (they weren't
> intended to be anything more than a simple trick for compatibility).
>

The point is, these bindings clash with standard vi usage. Dead-heart vi'ers
do many things automatically; ESC-/ is one of them - and here the above
bindings cut in.

Zsh just tries bind too much by default; probably, compinit should just
redefine standard context-sensitive completion bindings leaving everything
else to user choice. But then we need some simple framework to selectively
activate additional bindings.

The problem is, most people on this list seem to use emacs mode; I was the
last one but switched to emacs as well (in part because of subtle rpoblems
with new completion in emacs mode).

-andrej


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

* RE: Troublesome Key Bindings
  2001-03-14 11:09   ` Andrej Borsenkow
@ 2001-03-14 11:12     ` Andrej Borsenkow
  2001-03-14 11:30       ` Peter Stephenson
  0 siblings, 1 reply; 6+ messages in thread
From: Andrej Borsenkow @ 2001-03-14 11:12 UTC (permalink / raw)
  To: Zsh hackers list


> The problem is, most people on this list seem to use emacs mode; I was the
> last one but switched to emacs as well (in part because of subtle rpoblems
> with new completion in emacs mode).
> 

It was "... in vi mode" of course.


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

* Re: Troublesome Key Bindings
  2001-03-14 11:12     ` Andrej Borsenkow
@ 2001-03-14 11:30       ` Peter Stephenson
  0 siblings, 0 replies; 6+ messages in thread
From: Peter Stephenson @ 2001-03-14 11:30 UTC (permalink / raw)
  To: Zsh hackers list

> 
> > The problem is, most people on this list seem to use emacs mode; I was the
> > last one but switched to emacs as well (in part because of subtle rpoblems
> > with new completion in emacs mode).
> > 
> 
> It was "... in vi mode" of course.

It would be nice to get rid of subtle problems, anyway.  As in the other
key binding thread, people still want to use vi mode...

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Unit 300, Science Park, Milton Road,
Cambridge, CB4 0XL, UK                          Tel: +44 (0)1223 392070


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

* Re: Troublesome Key Bindings
  2001-03-14 10:44 ` Peter Stephenson
  2001-03-14 11:09   ` Andrej Borsenkow
@ 2001-03-14 17:33   ` Bart Schaefer
  1 sibling, 0 replies; 6+ messages in thread
From: Bart Schaefer @ 2001-03-14 17:33 UTC (permalink / raw)
  To: Zsh hackers list

On Mar 14, 10:44am, Peter Stephenson wrote:
} Subject: Re: Troublesome Key Bindings
}
} "Zvi Har'El" <rl@math.technion.ac.il> wrote:
} > I am using zsh in vi insert mode (being an fanatic ViM user). After
} > doing compinit, which introduced many new key binding, I started
} > having troubles in history searches: Although most of the new
} > bindings have the prefix ^X, there are three with a prefix ^[, i.e.,
} > the escape character. These are
} > 
} > 	"^[," _history-complete-newer
} > 	"^[/" _history-complete-older

These two bindings come from the #compdef line in _history_complete_word.
I don't recall why those keystrokes were chosen, but they're certainly
bad for vi mode.

There are a number of things we could do ... the most obvious would be to
simply remove the #compdef from _history_complete_word (replace it with
#autoload).  Better perhaps would be to add -e and -v options to compdef 
to specify the keymap in which the binding is to take place, but it might
be hard to come up with an unambiguous syntax for specifying different
bindings in the two modes with the same #compdef.

} So for the first two, you can simply use bindkey to map them to something
} else straight away:
}   bindkey '^X/' _history-complete-older

Of course you also need to "bindkey -r" the old binding, as you're already
doing.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


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

end of thread, other threads:[~2001-03-14 17:34 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-03-14  9:05 Troublesome Key Bindings Zvi Har'El
2001-03-14 10:44 ` Peter Stephenson
2001-03-14 11:09   ` Andrej Borsenkow
2001-03-14 11:12     ` Andrej Borsenkow
2001-03-14 11:30       ` Peter Stephenson
2001-03-14 17:33   ` 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).