<<< Date Index >>>     <<< Thread Index >>>

Re: muttquery



On Thu, Dec 25, 2003 at 04:01:51AM -0500, David Yitzchak Cohen wrote:
> On Thu, Dec 25, 2003 at 06:51:12PM +1100, Ricky Buchanan wrote:

> > Anyway,  have situations in OTHER programs where I have to look up email
> > addresses, on occasion, and it'd be REALLY handy if instead of looking
> > up and getting the output like this:
> > 
> > Searching through 475 addresses in pilot address book.
> > frayah@xxxxxxxxxxx  Anne Oberin     
> > rb@xxxxxxxxxxxxxx   Penguin Ricky Buchanan  
> > Colin.Oberin@xxxxxxxxxx     Colin Oberin    Dad Father
> > kase@xxxxxxxx       Hayden Oberin   
> > kaysik@xxxxxxxxxx   Ptolemy Oberin  
> > 
> > Then for cases where there's >1 entry, I'd like mutt's
> > query-answer-choosing program to come up, let me choose the answer, and
> > return it to stdout like, for example
> > 
> > rb@xxxxxxxxxxxxxx
> > 
> > still using the previous example.  And, like with mutt, in the previous
> > example it would automatically choose and return one address if the
> > query program returned only one.
> > 
> > Possible to do/access from the command line?

Well, I got bored, so I made a program to do just that.  The only
thing is, it depends on the dialog program to do the actual work.
(The dialog program is the UI backbone of Slackware's setup system,
and is easily available online.)

The source code may be found here:
http://www.bigfatdave.com/dave/bin/selection_box.c

...and an i686 (glibc 2.3.2) precompiled version is here:
http://www.bigfatdave.com/dave/bin/selection_box

To use it, simply pipe your $query_command into it.  It accepts up to
BUFFERS-1 lines of input, where each line can be of the form "option"
or "option<tab>explanation" and the special case of "option<tab>" is
handled correctly, so the input can easily be autogenerated without you
having to do too many of your own checks.  If you'd like a friendly
message to appear at the top of the menu, make it the only argument
to selection_box.  If no input lines are found, selection_box prints
nothing to stdout.  If one input line is found, it'll print the option
(without the explanation) to stdout without calling dialog.  Otherwise,
it'll call dialog with the appropriate arguments.

Enjoy,
 - Dave

-- 
Uncle Cosmo, why do they call this a word processor?
It's simple, Skyler.  You've seen what food processors do to food, right?

Please visit this link:
http://rotter.net/israel

Attachment: pgpZ6EzVl4NNP.pgp
Description: PGP signature