zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Marc Weber <marco-oweber@gmx.de>, zsh-workers <zsh-workers@zsh.org>
Subject: Re: select item from list in modify-current-argument?
Date: Sat, 04 Jun 2011 11:32:41 -0700	[thread overview]
Message-ID: <110604113241.ZM19723@torch.brasslantern.com> (raw)
In-Reply-To: <1307144249-sup-4787@nixos>

On Jun 4,  1:41am, Marc Weber wrote:
}
} select-one first uses echo to show the alternatives, then read to get
} the item index from the user.
} 
} However because echo shows many lines the code copied from
} modify-current-argument get's confused.

I'd probably just do this:

_my_quickpath() {
    [[ -z "${words[CURRENT]}" ]] && (( CURRENT > 0 && --CURRENT ))
    compadd -Q -U $($HQUICKFILE --echo "${words[CURRENT]}")
}
compdef -k _my_quickpath menu-select ^g

I'm not entirely sure about the --CURRENT part but you get the idea.

If you insist on doing it yourself without using a completion widget,
then you need to replace line 24-25 of select-one with something along
the lines of

    local -a replies
    for i ({1..$#@}) { replies+=( "$i: ${${@[$i]}#$strip}" ) }
    read-from-minibuffer "$(print -c "${replies[@]}")"$'\n'

And then replace other calls to "read $opt" with a similar call to
read-from-minibuffer.  (Oh, it needs to be autoloaded first.)

This of course renders select-one unusuable outside of ZLE, so you'll
have to make a new function out out it if you want select-one for any
other purpose.


      reply	other threads:[~2011-06-04 18:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-03 23:41 Marc Weber
2011-06-04 18:32 ` Bart Schaefer [this message]

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=110604113241.ZM19723@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=marco-oweber@gmx.de \
    --cc=zsh-workers@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).