Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Bad bindkey mojo in 3.1.5



"Bart Schaefer" wrote:
> Take a look at this:
> 
> zagzig<106> bindkey | grep back
> "^B" backward-char
> "^H" backward-delete-char
> "^W" "^W" "^W" "^W" "^W" "^W" "^W" "^W" backward-kill-word
> "^X^P" history-beginning-search-backward
> "^Xr" history-incremental-search-backward
> (etc.)
> 
> Looks like "zed" tickles the bug:

The problem is in zed rather than the shell.  It doesn't occur with
the zed supplied with 3.1.5, but obviously I'm using the same one as
you (or similar, anyway), though I can't remember who altered it last.
In zsh 3.1, `bindkey '^w'' produces something like

"^W" kill-region

then when this gets restored, the call is in effect

bindkey "^W" "\"^W\" kill-region"

which is obviously wrong.  Zsh didn't used to print the "^W" when you
asked for just one binding, hence the difference.

The following fixes it under the assumption that everything up to and
including 3.0.x doesn't print the key string and doesn't have -L, and
conversely from then on.  Restoring bindkeys is better taken care of
in the zed supplied with the source, but that's specific to 3.1.
I didn't put PATCH: at the top since it doesn't patch any official
version of the source.

It wouldn't be beyond the wit of man, err, person, to implement a
.zedrc which could have arbitrary bindings in it.

*** /home/user2/pws/bin/fns/zed.cw	Wed Dec  3 13:35:57 1997
--- /home/user2/pws/bin/fns/zed	Mon Nov  2 10:45:02 1998
***************
*** 8,14 ****
  # Completion: use
  # compctl -f -x 'w[1,-f]' -F -- zed
  
! local var fun ctrl_W_bind="$(bindkey '^W')" oldcompctl hist
  # We do not want timeout while we are editing a file
  integer TMOUT=0
  
--- 8,19 ----
  # Completion: use
  # compctl -f -x 'w[1,-f]' -F -- zed
  
! local var fun oldcompctl ctrl_W_bind hist
! if [[ -z $ZSH_VERSION || $ZSH_VERSION = 3.0* ]]; then
!   ctrl_W_bind="bindkey '^W' \"$(bindkey '^W')\""
! else
!   ctrl_W_bind="$(bindkey -L '^W')"
! fi
  # We do not want timeout while we are editing a file
  integer TMOUT=0
  
***************
*** 33,39 ****
  cleanup () {
    bindkey "^M" accept-line
    bindkey "^X^W" undefined-key
!   bindkey "^W" "$ctrl_W_bind"
    [[ -n $oldcompctl ]] && eval $oldcompctl
    unfunction cleanup
    [[ -z $ZSH_VERSION ]] && unsetopt nobanghist
--- 38,44 ----
  cleanup () {
    bindkey "^M" accept-line
    bindkey "^X^W" undefined-key
!   eval $ctrl_W_bind
    [[ -n $oldcompctl ]] && eval $oldcompctl
    unfunction cleanup
    [[ -z $ZSH_VERSION ]] && unsetopt nobanghist

-- 
Peter Stephenson <pws@xxxxxxxxxxxxxxxxx>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarotti 2, 56100 Pisa, Italy



Messages sorted by: Reverse Date, Date, Thread, Author