zsh-workers
 help / color / mirror / code / Atom feed
From: Oliver Kiddle <opk@u.genie.co.uk>
To: zsh-workers@sunsite.auc.dk
Subject: completing history words
Date: Wed, 05 Jul 2000 15:10:10 +0100	[thread overview]
Message-ID: <396341C2.C823423F@u.genie.co.uk> (raw)

I'm a little bit mystified by the way _history_complete_word is
implemented as it seems to re-implement menu-completion while not
offering non-menu completion. Why does it not just complete history
words and rely on separate completers based on different builtin
widgets (menu-complete, complete-word etc)? I wanted to be able to
complete history in a fairly normal way but it behaves in a slightly
strange way, doing things like inserting a match for ambiguous
completions.

I created a small function (_complete_history) containing just the
line:
compadd -Q -a 'historywords[2,-1]'

Then, I defined three completion widgets based on it:
zle -C history-complete complete-word _complete_history
zle -C history-menu menu-complete _complete_history
zle -C history-reverse-menu reverse-menu-complete _complete_history

As far as I can tell, the latter two behave largely like
_history_complete_older and _history_complete_newer. The first one
provides roughly the behaviour which I wanted.

I just needed a few key bindings and it was all working:

bindkey '\e,' history-complete
bindkey '\e.' history-menu
bindkey '\e/' history-reverse-menu
bindkey -M menuselect '\e,' complete-word
bindkey -M menuselect '\e.'  menu-complete
bindkey -M menuselect '\e/' reverse-menu-complete

It actually seems to have a problem with strange characters (e.g.
'$') not being considered part of the word being completed but other
than that, it is fine.

Obviously, my _complete_history function could be much improved with
styles for sorting and to manipulate compstate so listing etc can be
turned off but this way of doing it seems better to me. It is much
simpler and configuration of it will be more similar to configuring for
other completion widgets. Can anyone please explain why it is currently
done differently?

Oliver


             reply	other threads:[~2000-07-05 14:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-07-05 14:10 Oliver Kiddle [this message]
2000-07-05 14:36 Sven Wischnowsky

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=396341C2.C823423F@u.genie.co.uk \
    --to=opk@u.genie.co.uk \
    --cc=zsh-workers@sunsite.auc.dk \
    /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).