Re: unable to use send2-hook / group pattern for automatic
- To: mutt-users@xxxxxxxx
- Subject: Re: unable to use send2-hook / group pattern for automatic
- From: Kyle Wheeler <kyle-mutt@xxxxxxxxxxxxxx>
- Date: Mon, 5 Nov 2007 10:40:48 -0600
- Comment: DomainKeys? See http://domainkeys.sourceforge.net/
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed; d=memoryhole.net; h=date:from:to:subject:message-id:references:mime-version:content-type:in-reply-to; q=dns/txt; s=default; bh=BqjgQ63EBmt2i6P+lZ4K94XHi3U=; b=iTomosDUyuqfajO1v1XKsMASvQJsbF+Yls4JkU9ARn26C7+BJN9xhOjkeUA3TczzzESNDyN567H2vkiZUlANivh87lY3XwqLS4T05xRNLF7DWF31jZ82H0WzfenEm9euLLIhMqJLVGUws1RjNSY7YMIpGtjdg/UKMtBnK67azIc=
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=memoryhole.net; b=gWpHh7QB5A2f+Mf5ibGtH4VApLFymS22nXmykjE+ar5SNOdTSIlDacz20yAbGCkekVJAWeXPZvoflvD7cTnWcj1yqM8gcDmdlI44V1OnXVapK5pg6FU4swvsQABgct+4JMayMVOgzoEBm3+W1HDPHnMVh8odfxmrL/0t75vNocg=; h=Received: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: <20071105160125.GA16375@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
- 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: <20071105160125.GA16375@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Sender: owner-mutt-users@xxxxxxxx
- User-agent: Mutt/1.5.16 (2007-10-18)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Monday, November 5 at 05:01 PM, quoth Gregor Zattler:
> I want to use this group feature to switch encryption on and off
> depending on emailaddresses:
:) I do that a lot myself.
> send2-hook "." "set crypt_autosign=no"
> send2-hook "." "set crypt_autoencrypt=no"
> send2-hook "^%Cgpg-full" "set crypt_autosign=yes"
> send2-hook "^%Cgpg-full" "set crypt_autoencrypt=yes"
These are bad hooks for several reasons.
> The manual states: "send2-hook is matched every time a message is
> changed, either by editing it, or by using the compose menu to
> change its recipients or subject."
Other changes trigger a send2-hook as well, such as every time a
message's encryption status is changed. If the action you've specified
did what you thought it did, you'd have essentially put mutt into an
infinite loop.
> Therefore the encryption status should be evaluated every time I
> edit the email.
Wrong. Configuration variables are ONLY consulted when setting up an
email for the first time. You can think of them as defaults. Changing
their value from the compose menu does not affect the message you are
sending. The way to change whether a message is going to be encrypted
or not from the compose menu is to use the pgp-menu that's right there
in the middle of the screen rather than by changing configuration
variables.
As an example, this would be more effective (DO NOT USE THIS HOOK! YOU
WILL CREATE AN INFINITE LOOP IN MUTT!):
send2-hook '^%C gpg-full' 'push <pgp-menu>s'
Now, since we are actually getting something to happen now, the real
question becomes: how do we avoid the infinite loop? Well, that's
easy! Don't trigger the hook except on messages that are not already
signed/encrypted:
send2-hook '!~g !~G ^%C gpg-full' 'push <pgp-menu>b'
Then, of course, you want to disable things if you have other non-pgp
recipients, so you need another hook:
send2-hook '(~G|~g) !~%C gpg-full' 'push <pgp-menu>f'
Exactly what you do, of course, depends on the behavior you want. For
example, I prefer to sign *ALL* of my messages just to subtly
encourage people to use encryption, but I only want to encrypt
messages to people that do use encryption. Thus, I use the following
hooks:
# note that this works because it triggers before $crypt_autoencrypt
# is consulted by mutt
send-hook '!~G ^%C pgp' 'set crypt_autoencrypt=yes'
# this one makes the above a little more active
send2-hook '((~g !~G)|(~G !~g)) ^%C pgp' 'push <pgp-menu>b'
# this one makes sure that people who can't read it won't get
# encrypted mail
send2-hook '~G !^%C pgp' 'push <pgp-menu>s'
But that's relatively easy. The REALLY fancy stuff comes when you have
friends who are pine users and thus CANNOT use PGP-MIME and so require
*inline* pgp all the dang time. This is tough to do in mutt because
there's no pattern to match messages that use inline pgp signatures,
but it can be done. Any guesses how it's done? ;)
(hint: think $my_* variables)
~Kyle
- --
A man cannot be held responsible for what his mind does while he's
asleep.
-- Jean Luc Picard
-----BEGIN PGP SIGNATURE-----
Comment: Thank you for using encryption!
iD8DBQFHL0eQBkIOoMqOI14RAkHYAKDwLp1pEIEHWTza9ZPMmy+jmc6AygCghP4Z
6n/HKx5qKUdBo3ODF+TNahQ=
=1q7y
-----END PGP SIGNATURE-----