Re: Difference between 'push' and 'exec', is there any?
- To: mutt-users@xxxxxxxx
- Subject: Re: Difference between 'push' and 'exec', is there any?
- From: Kyle Wheeler <kyle-mutt@xxxxxxxxxxxxxx>
- Date: Wed, 8 Aug 2007 13:16:07 -0500
- Comment: DomainKeys? See http://domainkeys.sourceforge.net/
- Dkim-signature: v=0.5; a=rsa-sha1; c=relaxed; d=memoryhole.net; h=received:date:from:to:subject:message-id:mail-followup-to:references:mime-version:content-type:content-disposition:in-reply-to:user-agent; q=dns/txt; s=default; bh=fMFJ/Jj4iRKU4U49Ws/FLPyES4w=; b=J2SbzMwmUFyPtdLQq/3TRZK+eF5Yxy7EVIq4Z8acfM2mxLvP3wE4cpPdZXQLregAb0z0r26QtUADbbr+UtTdVDs7yQE2flQ3BbiDMszDTpuw4GGDdRtKcb2iS4iXsbzAyGoR7ruCFx8rpg65Yd4LTJRDnEek3GdFWDxugwAenVU=
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=memoryhole.net; b=OopRDf6MwIb/OJ8vybS7N3Nk8Guni+sAkHN6/X64gbMJUWHSmeTtnSLZfGEUbjDrjQgJROReZsLiEtMRt6Jrf0nMb9su+FrPw77To4AoLGz/8/7svwX4G3DO6WpXmZ+EsypClDZ0PkCQctlXAT7Bf5VmF0MtD5Z/JRpf+40auTc=; h=Received:Date:From:To:Subject:Message-ID:Mail-Followup-To:References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To:User-Agent;
- In-reply-to: <20070808173833.GA90795@xxxxxxxxxxxxxxxxxxx>
- List-post: <mailto:mutt-users@mutt.org>
- List-unsubscribe: send mail to majordomo@mutt.org, body only "unsubscribe mutt-users"
- Mail-followup-to: mutt-users@xxxxxxxx
- References: <20070808173833.GA90795@xxxxxxxxxxxxxxxxxxx>
- Sender: owner-mutt-users@xxxxxxxx
- User-agent: Mutt/1.5.13 (2006-08-11)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Wednesday, August 8 at 06:38 PM, quoth Chris G:
>Is there any actual difference between the 'push' and 'exec' commands?
Yes.
Push queues up characters to be read in *as if you'd typed them*
(though, confusingly, it also accepts function calls). Exec can only
execute function calls. To quote the manual
(http://www.mutt.org/doc/devel/manual.html):
``exec function'' is equivalent to ``push <function>''.
So, I can 'push <save-message>' and I can 'exec save-message'.
However, I can 'push <save-message>=Drafts<enter>' but I can't exec
that.
Both functions are generally meant to be done at *runtime* rather than
in your muttrc.
>Also, if I source something like the following:-
>
> set mbox_type=maildir
> exec save-message
> set mbox_type=mbox
>
>It doesn't do what I expect as the message *doesn't* get saved in
>maildir format. Presumably this is something to do with the order in
>which mutt executes the things it finds in a file which is sourced.
>Is there any information on this anywhere?
Repeat after me: A muttrc file is *not* a script.
It may have some behaviors that seem similar to a script, but it is
NOT A SCRIPT. A muttrc is interpreted, in its entirety, before
consequences of those commands are felt (with the exception of
changing config_charset). Anything that is "source"'d is treated as an
"initialization file", so settings all take effect more or less
concurrently. Calls to exec and push will only be resolved once mutt
is back in it's usual runtime loop.
In addition, save-message requires user input, and so can only happen
when mutt is back in it's usual runtime loop, not in the middle of
reading a file or executing a macro.
>Would a sourced file containing a series of 'push' commands execute
>them in the order expected (i.e. sort of backwards). For example if I
>source the following:-
>
> push ":set mbox_type=mbox"
> push save-message
> push ":set mbox_type=maildir"
>
>Will it switch to maildir, save a message and then switch back to
>mbox?
No. What will happens is that you'll switch to maildir, and then mutt
will ask you where you would like to save the message, and then it
will think you typed in ":set mbox_type=maildir" as the name of the
mailbox to save it in.
push != exec. Push adds things to the input buffer. Mutt cannot read
input from the keyboard when there's already input in there (i.e. the
last push's text is in the input stream ahead of whatever you might
type on the keyboard). There is currently no way to "wait for function
X that requires user input to complete, then do Y" as you are
attempting to do here, in part because mutt only has a single queue of
"user input".
The only way I can think of to do kinda what you want is to create a
script that uses safecat and asks you for a filename (e.g. with an
ncurses dialog box, such as dialog or lxdialog).
~Kyle
- --
To bathe a cat takes brute force, perseverance, courage of
conviction---and a cat. The last ingredient is usually hardest to come
by.
-- Stephen Baker
-----BEGIN PGP SIGNATURE-----
Comment: Thank you for using encryption!
iD8DBQFGughnBkIOoMqOI14RApeoAKDqFb92ChtgZv5DLyVZQ75YfYsf7wCg/7Jm
NE1A1juLTnB372VeCo61K1E=
=yhxu
-----END PGP SIGNATURE-----