emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

proposed patch to enable MH-E usage of GNU + EPG


From: timotheus
Subject: proposed patch to enable MH-E usage of GNU + EPG
Date: Wed, 11 Jul 2007 23:58:56 -0400
User-agent: Gnus/5.110007 (No Gnus v0.7) Emacs/23.0.51 (gnu/linux)

Hi. I would like to make a feature request and also provide the
implementation: that MH-E would support multiple identities using S/MIME
through the most recent GNUs + EasyPG interface. My understanding is
that GNUs 5.11 (cvs) has added support for using EasyPG (library "epg"),
which is eventually to be merged into Emacs CVS.

    http://gnus.org/
    http://www.easypg.org/

In the case of a single identity, installation and configuration of GNUs
5.11 (cvs) to use method 'epg is sufficient.

---- EXAMPLE ----
(setq mml-smime-use 'epg)
(setq mml2015-use 'epg)
(setq pgg-default-scheme 'epg)
---- EXAMPLE ----

The following code will implement MH identity support for this new
epg s/mime functionality without affecting normal GNUs or MML
behavior. It works by use of an identity handler in like fashion to how
MH already supports multiple pgg identities.

My request is that something similar to the following example be added
to `mh-e.el', `mh-mime.el', `mh-identity.el' in the not so distant
future. It is written such that a user could paste it into ~/.emacs and
not have to wait :).

Thanks & regards,
-timotheus

---- EXAMPLE ----
;;;;; MH-E S/MIME identity handling for EasyPG

;;;;; add to mh-e.el
(defvar mh-identity-mml-smime-signers nil
  "Holds list of the S/MIME key ID(s) to be used by mml-smime.el.
This is normally set as part of an Identity in
`mh-identity-list'.")
(make-variable-buffer-local 'mh-identity-mml-smime-signers)

(add-to-list 'mh-identity-handlers
             '(":mml-smime-signers" . mh-identity-handler-smime-identity) t)

;;;;; add to mh-identity.el
(defun mh-identity-handler-smime-identity (field action &optional value)
  "Process header FIELD \":mml-smime-signers\".
The ACTION is one of 'remove or 'add. If 'add, the VALUE is added.
The global variable `mh-identity-mml-smime-signers' is set to
VALUE when action 'add is selected."
  (cond
   ((or (equal action 'remove)
        (not value)
        (string= value ""))
    (setq mh-identity-mml-smime-signers nil))
   ((equal action 'add)
    (setq mh-identity-mml-smime-signers (list value))))
  )

;;;;; add to mh-mime.el

;; this advice would be even better to incorporate directly into
;; `mh-mml-to-mime', and it should be straitforward as how to do that:
;;
;;     (let ((saved-text (buffer-string))
;;           (buffer (current-buffer))
;;   -       (modified-flag (buffer-modified-p)))
;;   +       (modified-flag (buffer-modified-p))
;;   +       (mml-smime-signers mh-identity-mml-smime-signers))
;;   +   (message-options-set 'mml-smime-epg-signers nil)
;;       (condition-case err (mml-to-mime)
;;
;;
;; The line:  (message-options-set 'mml-smime-epg-signers nil)
;; is necessary to force MML to scan keys again now that
;; `mml-smime-signers' has been modified. Probably a GNUs (cvs) bug.
;;

(defadvice mh-mml-to-mime (around ad-smime-signers-mh-mml-to-mime activate)
    "Advise `mh-mml-to-mime' to use the MH identity equivalent of
`mml-smime-signers' when calling `mml-to-mime'."
    (let ((mml-smime-signers mh-identity-mml-smime-signers))
      (message-options-set 'mml-smime-epg-signers nil)
      (setq ad-return-value ad-do-it)))

---- EXAMPLE ----

Attachment: pgpWQxlDAuGsP.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]