From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/68440 Path: news.gmane.org!not-for-mail From: Daniel Dehennin Newsgroups: gmane.emacs.gnus.general Subject: [PATCH] Only one sender. Date: Mon, 13 Apr 2009 22:32:58 +0200 Message-ID: <87tz4s5m6d.fsf@hati.baby-gnu.org> References: <87ljsv3agx.fsf@hati.baby-gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1239654802 13432 80.91.229.12 (13 Apr 2009 20:33:22 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 13 Apr 2009 20:33:22 +0000 (UTC) To: ding@gnus.org Original-X-From: ding-owner+M16875@lists.math.uh.edu Mon Apr 13 22:34:41 2009 Return-path: Envelope-to: ding-account@gmane.org Original-Received: from util0.math.uh.edu ([129.7.128.18]) by lo.gmane.org with esmtp (Exim 4.50) id 1LtSrV-0003Kc-RS for ding-account@gmane.org; Mon, 13 Apr 2009 22:34:38 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by util0.math.uh.edu with smtp (Exim 4.63) (envelope-from ) id 1LtSq5-0002Gj-5U; Mon, 13 Apr 2009 15:33:09 -0500 Original-Received: from mx2.math.uh.edu ([129.7.128.33]) by util0.math.uh.edu with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63) (envelope-from ) id 1LtSq2-0002FM-Fz for ding@lists.math.uh.edu; Mon, 13 Apr 2009 15:33:06 -0500 Original-Received: from quimby.gnus.org ([80.91.231.51]) by mx2.math.uh.edu with esmtp (Exim 4.69) (envelope-from ) id 1LtSpw-0000T5-7i for ding@lists.math.uh.edu; Mon, 13 Apr 2009 15:33:06 -0500 Original-Received: from zion.asgardr.info ([82.233.222.74]) by quimby.gnus.org with esmtp (Exim 3.36 #1 (Debian)) id 1LtSqL-00064s-00 for ; Mon, 13 Apr 2009 22:33:25 +0200 Original-Received: from hati.asgardr.info ([192.168.1.2] helo=hati.baby-gnu.org) by zion.asgardr.info with esmtp (Exim 4.69) (envelope-from ) id 1LtSpu-00015p-VI for ding@gnus.org; Mon, 13 Apr 2009 22:32:58 +0200 Original-Received: from dad by hati.baby-gnu.org with local (Exim 4.69) (envelope-from ) id 1LtSpu-0005Jo-Uo for ding@gnus.org; Mon, 13 Apr 2009 22:32:58 +0200 Organisation: Dark Church of Emacs User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.0.92 (gnu/linux) X-Spam-Score: -1.7 (-) List-ID: Precedence: bulk Xref: news.gmane.org gmane.emacs.gnus.general:68440 Archived-At: --=-=-= ------------------------------------------------------------ revno: 138 committer: Daniel Dehennin branch nick: mml2015 timestamp: Mon 2009-04-13 20:25:42 +0200 message: Only one sender. * lisp/mml2015.el (mml2015-epg-sign): From header should have only one sender address. Split it and fetch only the first one. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=Gnus-mm2015-138.patch # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: daniel.dehennin@baby-gnu.org-20090413182542-\ # i9jzkccgc9e1365g # target_branch: ../../gnus.head # testament_sha1: 8a13d89d874f9f0a56ce806e2856ec109d4ffa0c # timestamp: 2009-04-13 21:00:07 +0200 # source_branch: . # base_revision_id: daniel.dehennin@baby-gnu.org-20090412231027-\ # rhtvglq3r87nljez # # Begin patch === modified file 'lisp/mml2015.el' --- lisp/mml2015.el 2009-01-22 07:02:15 +0000 +++ lisp/mml2015.el 2009-04-13 18:25:42 +0000 @@ -1025,6 +1025,43 @@ (setq pointer (cdr pointer)))) (setq keys (cdr keys))))) +(defun mml2015-epg-split-addresses (config addresses) + "Split a string of addresses delimited by [ \f\t\n\r\v,]+." + (apply #'nconc + (mapcar + (lambda (recipient) + (or (epg-expand-group config recipient) + (list (concat "<" recipient ">")))) + (split-string + (or addresses + (read-string "Addresses: ")) + "[ \f\t\n\r\v,]+")))) + +(defun mml2015-epg-prompt-select-keys (context &optional names usage) + "Return a key matching NAME. +USAGE is nil or encrypt to search private keyring. +USAGE is t or sign to search secret keyring. +Mostly a wrapper around epa-select-keys." + (let ((action (cond + ((memq usage '(t sign)) "signing") + ((memq usage '(nil encrypt)) "encryption") + (t "encryption"))) + (key-type (cond + ((memq usage '(t sign)) 'secret) + ((memq usage '(nil encrypt)) 'public) + (t 'public))) + (no-selection (cond + ((memq usage '(t sign)) "default secret key is used") + ((memq usage '(nil encrypt)) "symmetric encryption will be performed") + (t "symmetric encryption will be performed")))) + (epa-select-keys context + (format "\ +Select a key for %s. +If no one is selected, %s +If more than one is select, first one is used. " + action no-selection) + names key-type))) + (defun mml2015-epg-decrypt (handle ctl) (catch 'error (let ((inhibit-redisplay t) @@ -1182,17 +1219,18 @@ (let* ((inhibit-redisplay t) (context (epg-make-context)) (boundary (mml-compute-boundary cont)) + (config (epg-configuration)) + (sender (car (mml2015-epg-split-addresses + config + (message-options-get 'message-sender)))) signer-key (signers (or (message-options-get 'mml2015-epg-signers) (message-options-set 'mml2015-epg-signers (if mml2015-verbose - (epa-select-keys context "\ -Select keys for signing. -If no one is selected, default secret key is used. " - mml2015-signers t) - (if mml2015-signers + (mml2015-epg-prompt-select-keys context (cons sender mml2015-signers) 'sign) + (if (or sender mml2015-signers) (delq nil (mapcar (lambda (signer) @@ -1206,7 +1244,7 @@ signer))) (error "No secret key for %s" signer)) signer-key) - mml2015-signers))))))) + (cons sender mml2015-signers)))))))) signature micalg) (epg-context-set-armor context t) (epg-context-set-textmode context t) @@ -1249,32 +1287,23 @@ (let ((inhibit-redisplay t) (context (epg-make-context)) (config (epg-configuration)) + (sender (message-options-get 'message-sender)) (recipients (message-options-get 'mml2015-epg-recipients)) cipher signers (boundary (mml-compute-boundary cont)) recipient-key signer-key) (unless recipients (setq recipients - (apply #'nconc - (mapcar - (lambda (recipient) - (or (epg-expand-group config recipient) - (list (concat "<" recipient ">")))) - (split-string - (or (message-options-get 'message-recipients) - (message-options-set 'message-recipients - (read-string "Recipients: "))) - "[ \f\t\n\r\v,]+")))) + (mml2015-epg-split-addresses + config + (message-options-get 'message-recipients))) (when mml2015-encrypt-to-self - (unless mml2015-signers - (error "mml2015-signers not set")) - (setq recipients (nconc recipients mml2015-signers))) + (unless (or sender mml2015-signers) + (error "Message sender and mml2015-signers not set")) + (setq recipients (nconc recipients (cons sender mml2015-signers)))) (if mml2015-verbose (setq recipients - (epa-select-keys context "\ -Select recipients for encryption. -If no one is selected, symmetric encryption will be performed. " - recipients)) + (mml2015-epg-prompt-select-keys context recipients 'encrypt)) (setq recipients (delq nil (mapcar @@ -1298,11 +1327,8 @@ (message-options-set 'mml2015-epg-signers (if mml2015-verbose - (epa-select-keys context "\ -Select keys for signing. -If no one is selected, default secret key is used. " - mml2015-signers t) - (if mml2015-signers + (mml2015-epg-prompt-select-keys context (cons sender mml2015-signers) 'sign) + (if (or sender mml2015-signers) (delq nil (mapcar (lambda (signer) @@ -1316,7 +1342,7 @@ signer))) (error "No secret key for %s" signer)) signer-key) - mml2015-signers))))))) + (cons sender mml2015-signers)))))))) (epg-context-set-signers context signers)) (epg-context-set-armor context t) (epg-context-set-textmode context t) --=-=-=--