From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.user/3472 Path: news.gmane.org!not-for-mail From: Klaus Uhl Newsgroups: gmane.emacs.gnus.user Subject: Re: Automatically sign/encrypt messages Date: Wed, 04 Feb 2004 17:51:50 +0100 Message-ID: <87ptcu23fd.fsf@ulm.my.lan> References: <87n086ach0.fsf@ulm.my.lan> <8765emerej.fsf@pc70-23.unine.ch> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" X-Trace: sea.gmane.org 1138669580 19111 80.91.229.2 (31 Jan 2006 01:06:20 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 31 Jan 2006 01:06:20 +0000 (UTC) Original-X-From: nobody Tue Jan 17 17:32:16 2006 Original-Path: quimby.gnus.org!newsfeed1.e.nsc.no!nsc.no!nextra.com!news.tele.dk!news.tele.dk!small.news.tele.dk!fu-berlin.de!uni-berlin.de!p5088ef34.dip0.t-ipconnect.DE!not-for-mail Original-Newsgroups: gnu.emacs.gnus Original-NNTP-Posting-Host: p5088ef34.dip0.t-ipconnect.de (80.136.239.52) Original-X-Trace: news.uni-berlin.de 1075913495 33526643 80.136.239.52 ([99401]) User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) Cancel-Lock: sha1:5o+8HeaTBTcrmiAQy5iJRxCzq/Y= Original-Xref: bridgekeeper.physik.uni-ulm.de gnus-emacs-gnus:3613 Original-Lines: 64 X-Gnus-Article-Number: 3613 Tue Jan 17 17:32:16 2006 Xref: news.gmane.org gmane.emacs.gnus.user:3472 Archived-At: --=-=-= Eric Simon 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 --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) iD8DBQBAISMpyaizchKPnewRAgaRAJ45+KFcsSkHrG8q6PwvjGt9mJoH+wCePTXl IPymJeOdctv6ZdHjWSFCgPc= =AIEP -----END PGP SIGNATURE----- --=-=-=--