zsh-users
 help / color / mirror / code / Atom feed
From: "Jesper Nygårds" <jesper.nygards@gmail.com>
To: Zsh Users <zsh-users@zsh.org>
Subject: Re: Three questions about a completer
Date: Wed, 14 Sep 2016 09:22:16 +0200	[thread overview]
Message-ID: <CABZhJg-GPxn87gHX4+z-Md2kN7Wq4Ay=6db_uW762-4PQ9dKsA@mail.gmail.com> (raw)
In-Reply-To: <160913195916.ZM30431@torch.brasslantern.com>

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

Thank you for all your help, Bart and Oliver!

I am getting closer: the problem with numeric is now solved with your
suggestions, as well as turning off the listing of alternatives. However I
still have trouble reversing the menu completion direction.

I'll explain what it is I want. I believe you've already understood, but
just to make sure: say that I have files A, B and C in my home directory. I
type "print <alt-e>", and "A" is put on the line. I then hit "<alt-e>"
again, and the "A" is replaced by "B".

If I start over and type "print <alt-E>", "C" is put on the line. Another
"<alt-E>" gives me "B". So the two keybindings work independently:
"<alt-e>" gives the list from the beginning, "<alt-E>" from the end.

However, this is what is NOT working: I type "print <alt-e>", and get "A".
I hit "<alt-e>" again, and get "B". Now, I hit "<alt-E>" to go back in the
list. I expected to get "A" again, but instead "B" remains on the line.
It's as though the only thing matching is what's right now on the line.

Below is the entirety of my ~/.zshrc when I experiment with this. It's
Bart's solution with n-rev-list-comp added (and the compinit activation).

autoload -U compinit
compinit

zle -C list-comp menu-complete _generic
zle -C rev-list-comp reverse-menu-complete _generic

n-list-comp() {
    local -a dirs=( $HOME /etc /bin )
    local __lsdir=${dirs[${NUMERIC:-1}]}
    zle list-comp -w -n 1
}

n-rev-list-comp() {
    local -a dirs=( $HOME /etc /bin )
    local __lsdir=${dirs[${NUMERIC:-1}]}
    zle rev-list-comp -w -n 1
}

zle -N n-list-comp
zle -N n-rev-list-comp

bindkey '\ee' n-list-comp
bindkey '\eE' n-rev-list-comp

_list-result() {
    compadd -M 'l:|=* m:{[:lower:]}={[:upper:]}' -f ${__lsdir:-HOME}/*
    compstate[list]=''
}

zstyle ':completion:*list-comp::::' completer _list-result

  reply	other threads:[~2016-09-14  7:22 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-12 11:38 Jesper Nygårds
2016-09-12 20:53 ` Oliver Kiddle
2016-09-13 16:16   ` Jesper Nygårds
2016-09-13 19:18     ` Jesper Nygårds
2016-09-14  2:59       ` Bart Schaefer
2016-09-14  7:22         ` Jesper Nygårds [this message]
2016-09-14 16:39           ` Bart Schaefer
2016-09-14 20:32             ` Jesper Nygårds
2016-09-15  4:49               ` Bart Schaefer
2016-09-15  6:01               ` Jesper Nygårds

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='CABZhJg-GPxn87gHX4+z-Md2kN7Wq4Ay=6db_uW762-4PQ9dKsA@mail.gmail.com' \
    --to=jesper.nygards@gmail.com \
    --cc=zsh-users@zsh.org \
    /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).