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

Re: A question about macros, how to handle user input (if



> > > E.g. I want a macro which does something, then does a s[ave]
> > > command (to which the user responds) and then does some more
> > > things after the save.

This is not a complete or flawless answer, just a quick example of
one way to do this.  And it's untested.

macro index = "<do-something><enter-command>source 'mutt-prompt \"save as\" 
\"push \<save>%s\<enter>\" |'<enter><do-something-else>"

If I didn't screw up quoting, this (1) does something, (2) enters the
command
        source 'mutt-prompt "save as" "push <save>%s<enter>" |'
then (3) does something else.

In stage 2, mutt-prompt (a) issues the prompt
        save as: 
(b) accepts input, then (c) echoes out "<save>[your input here]<enter>".

Because of the | at the end of the source command, mutt executes the
commands echoed in (c), then proceeds to (3).

Horrific, no?  Mutt-prompt is attached.  It's very straightforward.

-- 
 -D.    dgc@xxxxxxxxxxxx    NSIT    University of Chicago
#!/bin/sh
##
## usage: mutt-prompt "prompt text" "mutt commands"
## "mutt commands" should contain a %s, which will be replaced by
## the user's response to the prompt.
##

printf "$1: "
read answer </dev/tty
printf "$2" "$answer"