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

Re: zsh-3.1.5-pws-5: mixing "old" and "new" completions?



"Bart Schaefer" wrote:
> Could somebody who's managed to keep track of all this stuff (Sven?  Peter?)
> please post a complete summary for _both_ zle -c and zle -C of
> 
>   * the new commands (compadd, complist, compcall, etc.)
>   * the new variables (what's in them and when they're available)
>   * the parameters passed to a user's shell functions in each case

I'd better leave zle -c to Sven, since I haven't had much time to look
at all the details.  I mentioned some time ago I was unhappy about the
setting/unsetting of the existing zle parameters like $BUFFER, which
still needs looking at, I don't know if it applies to Sven's new ones.

I'm increasingly of the opinion we can do without zle -C.  All the
uses I have for it can be replaced; I've just quickly converted my
current list of zle -C's into (this uses the new glob
sorting/selecting mechanism, too):

  zle -c history-complete-word complete-word __history_complete_word
  __history_complete_word() { complist -Q -H 0 ''; }
  bindkey "\e/" history-complete-word
  bindkey "\M-/" history-complete-word

  zle -c most-recent-file complete-word __most_recent_file
  __most_recent_file() {
    local match
    if [[ $PREFIX = *\** ]]; then
      match=(${~PREFIX}${~SUFFIX}(Om[1]))
    else
      match=(${~PREFIX}*${~SUFFIX}(Om[1]))
    fi
    [[ -n $match ]] && compadd -p ${match:h}/ -f ${match:t}
  }
  bindkey "\C-x." most-recent-file

  zle -c complete-filename complete-word __complete_filename
  __complete_filename() { complist -f; }
  bindkey "\C-xf" complete-filename

  zle -c complete-directory complete-word __complete_directory
  __complete_directory() { complist -/; }
  bindkey "\C-x\C-d" complete-directory

So I would propose simply removing zle -C, and being ready to document
various how-to's in the compctl manual when the new stuff becomes
fixed.  It hasn't been in any archived version, so I hope there won't
be many cries of woe.

By the way: I stumbled on compadd -p ${match:h}/ -f ${match:t}
to get the listing to work the way it normally does for files.  Is
this the approved way, or is the something better?

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



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