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

Re: How to activate a given GPG key through a macro...



Thank you for taking the time to explain...

On Sun, Sep 23, 2007 at 10:35:39PM -0500, Kyle Wheeler wrote:

> Here's how you'd set it in a macro:
> 
> macro index m '<enter-command>set pgp_sign_as=0x31577172<enter><mail>'
>
> I can mix that into your existing send-mail macro if you include 
> that in your message.

Here's what I currently have:

macro generic "<esc>2" "<enter-command>set from=promulgato@xxxxxxxx 
hostname=yahoo.de realname=<enter><enter-command>my_hdr Bcc: 
<promulgato@xxxxxxxx><enter><enter-command> my_hdr X-PGP-Key:"

which, following your suggestion, would become:

macro generic "<esc>2" "<enter-command>set pgp_sign_as=0x31577172<enter>
<promulgato@xxxxxxxx><enter-command>set from=promulgato@xxxxxxxx 
hostname=yahoo.de realname=<enter><enter-command>my_hdr Bcc: 
<promulgato@xxxxxxxx><enter><enter-command> my_hdr X-PGP-Key:"

Is this correct?

Now, the code "set pgp --encrypt-to=0x31577172" occurs twice in the
pgp section of my .muttrc. Within this scheme, do I need to include 
that too in the macro??
 
> Many mutt string variables that support formatting strings (such as 
> %a) also support conditional formatting strings. Generally, if you 
> include %a in a pgp command variable, it will be replaced by the 
> sender of the email (e.g. you@xxxxxxxxxxxxxx, or whatever you've 
> configured your pgp_sign_as to be). Thus, if you always set 
> pgp_sign_as to something, you can put "-u %a" into your pgp command 
> string (according to the gpg manual, -u means "sign as this user") and 
> when "-u %a" is parsed by mutt, it becomes "-u you@xxxxxxxxxxxxxx", or 
> something similar. Now then, to be generic, to take care of situations 
> when pgp_sign_as may not be set to anything, we have a conditional. A 
> conditional format string is in the format "%? formatletter ? iftrue ?", 
> in other words, the string "%?a?foo?" means "if %a would produce 
> anything, then use 'foo', otherwise ignore this". So, "%?a?-u %a?" 
> means "if %a is would produce anything, then use '-u %a'".
> 
> Does that make sense?

It makes perfect sense, thanks again for explaining it so clearly.
Fantastic, then, so I just need to replace "0x31577172" at each
occurrence in the .muttrc with "%?a?-u %a?"... with no further need 
to modify the macro sequences, as this string automatically points 
to the correct gpg key belonging to the current user (which user is
selected as needed through the old macro sequences, unmodified...)

Correct? If affirmative, it is an extremely elegant fix indeed...

Franz

Attachment: pgpER8dT53zNM.pgp
Description: PGP signature