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

Re: Getting completion to tell the user what to do



On Jul 20,  9:08am, Sven Wischnowsky wrote:
} Subject: Re: Getting completion to tell the user what to do
}
} Bart Schaefer wrote:
} 
} > What I want is to offer no completions at all [...]
} > but print a hint to the user as to what he's supposed to type.
} > 
} > 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]=''

Oho -- undocumented dirty tricks, no less.  The compstate[insert] doc
doesn't give any hint that it can be set but empty.  Of which case that
is documented is this a degenerate?

}   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).

Really?  When I first tried

	compadd -X 'Please ...' ''

(without the -S) then every time I pressed TAB a single space got inserted
(the suffix).  If the empty string isn't a match, why did that happen?

} Then we can switch off insertion completely.

So that's what compstate[insert]='' means?

} 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.

Presumably then "dummy" should be something that can't possibly match?
Or does that not matter?

} The -n, of course, is just to be sure that the matches are not visible.
} 
} Is that good enough?

It's just marvelous, thanks.  One question, though -- I thought that we
made kill-whole-line erase the completion listing, but it doesn't seem to
do that in this case:

    zagzig% mail -s <TAB><C-u>

leaves me with

    zagzig% 
    Please enter a descriptive subject

which is rather annoying when I start in typing some completely different
command and doing completions for it that don't themselves produce a list.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com



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