Announcements and discussions for Gnus, the GNU Emacs Usenet newsreader
 help / color / mirror / Atom feed
From: Klaus Uhl <news@u-h-l.de>
Subject: Re: Automatically sign/encrypt messages
Date: Wed, 04 Feb 2004 17:51:50 +0100	[thread overview]
Message-ID: <87ptcu23fd.fsf@ulm.my.lan> (raw)
In-Reply-To: <8765emerej.fsf@pc70-23.unine.ch>

[-- Attachment #1: Type: text/plain, Size: 1732 bytes --]

Eric Simon <erik.simon@unine.ch> writes:

> Nice indeed. Been using it today. Then I noticed sometimes it's not able
> to find the key in my ring or on the server because (message-fetch-field
> "To") returns the whole header. There is a function to parse a string
> and get a pair email/name: mail-header-parse-address, so I thought
> getting only the actual address would be better.
>
> So below is a slightly modified version that's been working nice for me
> for the past... 2 hours or so? Oh, not exactly, one friend had a public
> key published but didn't use encryption anymore and didn't have the
> secret counterpart, so he complained I was using cryptography with
> him...
>
>    (let* ((recipient (message-fetch-field "To"))
> 	  (recid (if (not (null recipient)) 
> 		     (car (mail-header-parse-address recipient)))))

You should probably set recid to nil if recipient is nil and use recid
instead of recipient in the cond below.

>      (cond ((and (not (null recipient))

I rewrote the hook this way and changed the variable names to name
what they actually hold:

(add-hook
 'message-send-hook
 (lambda ()
   (let* ((to-header (message-fetch-field "To"))
	  (recipient (if (null to-header)
			 nil
		       (car (mail-header-parse-address to-header)))))
     (cond ((and (not (null recipient))
		 (or (pgg-lookup-key recipient)
		     (pgg-fetch-key pgg-default-keyserver-address recipient)))
	    (mml-secure-message-encrypt-pgpmime))
	   (t
	    (mml-secure-message-sign-pgpmime))))))

Klaus

-- 

                 God is real ...
\|/ ____ \|/     ... unless declared integer.
"@'/ ,. \`@"     
\_| \__/ |_/     Mail me : news@u-h-l.de
   \__U_/        WWW     : www.u-h-l.de
                 PGP     : 0x128F9DEC

[-- Attachment #2: Type: application/pgp-signature, Size: 188 bytes --]

  reply	other threads:[~2004-02-04 16:51 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-01-29 17:31 Klaus Uhl
2004-01-30 19:06 ` Ted Zlatanov
     [not found]   ` <87ptd0jsqv.fsf@u-h-l.de>
2004-02-02 20:27     ` Ted Zlatanov
2014-05-15 21:41       ` Peter Münster
2004-02-04 16:33 ` Eric Simon
2004-02-04 16:51   ` Klaus Uhl [this message]
     [not found]     ` <87znby7oby.fsf@pc70-23.unine.ch>
     [not found]       ` <87r7xar7i9.fsf@ulm.my.lan>
2004-02-05 18:37         ` Eric Simon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ptcu23fd.fsf@ulm.my.lan \
    --to=news@u-h-l.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).