Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Getting completion to tell the user what to do
- X-seq: zsh-users 2453
- From: Sven Wischnowsky <wischnow@xxxxxxxxxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxxxxxx
- Subject: Re: Getting completion to tell the user what to do
- Date: Tue, 20 Jul 1999 09:08:24 +0200 (MET DST)
- In-reply-to: "Bart Schaefer"'s message of Mon, 19 Jul 1999 17:38:13 +0000
- Mailing-list: contact zsh-users-help@xxxxxxxxxxxxxx; run by ezmlm
Bart Schaefer wrote:
> This ought to be an easy one in the new 3.1.6 completion system, but I just
> can't get it to work.
>
> I'm trying to complete "subject string goes here" as in
>
> mail -s "subject string goes here"
>
> What I want is to offer no completions at all, because the subject is free-
> form text, but print a hint to the user as to what he's supposed to type.
>
> The following almost works (inside a completion function the rest of which
> is not interesting):
>
> compadd -S '' -X 'Please enter the subject of the message' ''
>
> but because there's a unique completion, the explanation is printed only
> when the user types ^D, and there's no beep to let him know why tab isn't
> doing anything. OK, I thought, I can force a listing:
>
> compadd -S '' -X 'Please enter the subject of the message' ''
> compstate[list]=list
> compstate[force_list]=yes
> compstate[restore]=no
>
> but that doesn't work -- there's still no explanation printed.
>
> What obvious thing have I forgotten/overlooked here? Is there an entirely
> better alternative to using compadd -X ?
Time for dirty tricks:
compadd -UX 'Please...' -n ''
compstate[insert]=''
compstate[list]=list
compstate[force_list]=yes
You need the -U because otherwise the empty string never matches
what's on the line (not even the empty string on the line). Then we
can switch of insertion completely.
If you want the string to be listed only on a TAB with an empty string
you can do `compadd -X "Please..." -n dummy' -- i.e. add a string with
matching.
The -n, of course, is just to be sure that the matches are not visible.
Is that good enough?
Bye
Sven
--
Sven Wischnowsky wischnow@xxxxxxxxxxxxxxxxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author