Re: accidently viewing attachments repeatedly
On 2009-03-20, Hein Zelle <hein@xxxxxxxxxxx> wrote:
> Dear Mutt users,
>
> when viewing attachments in external programs (notably openoffice), I
> often have a terminal sit "unused" for a while as I'm reading the
> attachment. What happens often is that I hit a key or enter in that
> terminal (which is showing just the last "$ mutt" command line).
>
> After closing the external program, mutt will then pick up the "enter"
> key that was pressed, and open the attachment again. And again, and
> again, until all accidently pressed enters have been processed. The
> same can happen while editing a message in an external emacs window.
> In this case it will just view the message text in mutt after you're
> done editing, which is much less annoying.
>
> Is there a way to have mutt flush the keyboard buffer directly after
> returning from an external program, either attachment viewer or
> editor? I can't think of any situations where you would actually
> _want_ such keypresses to be remembered, but I'm sure there are some.
I can think of a couple of ways to handle this. For the case of
viewing attachments, you can put the attachment viewer in the
background so that mutt immediately resumes running a taking input
from the keyboard. If you're concerned about typing the wrong thing
into that window, you can move the cursor or change menus so that an
inadvertent enter won't do anything destructive or time-consuming.
You can find more about running viewers in the background here:
http://www.spocom.com/users/gjohnson/mutt/#background
You can't very well do that with emacs, though, since you want mutt
to wait until you're done editing. For that case, you might try
setting your editor variable to this or to a script that implements
something like this:
gvim -f; while read -t1; do continue; done
I'm using gvim for concreteness and so that I could test it; I don't
have ready access to emacs. Not all shells support the -t option to
read. Bash and some versions of ksh do.
That command consumes any keys typed into the terminal while the
editor is running and for 1 second after the editor terminates.
There's no need, in principle, for the 1-second timeout, but I
couldn't find a way to set the timeout to 0 using bash.
That approach will work for the attachment viewer problem as well,
but I think putting the viewer in the background is a better
solution.
HTH,
Gary