From: vitaly Date: Mon, 25 Jan 2010 09:57:49 +0000 (+0000) Subject: Automatically decrypt pgp-encrypted messages in preview mode. X-Git-Tag: semi-1_14-wl-root~6 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=42c7dcbe2b6dbad59f57ce593187d1c3730606c3;p=elisp%2Fsemi.git Automatically decrypt pgp-encrypted messages in preview mode. --- diff --git a/ChangeLog b/ChangeLog index af644f2..daed22d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,11 @@ * mime-edit.el (mime-edit-insert-file): Ask user for MIME type and subtype during interactive file insertion, not only encoding. + * mime-pgp.el (toplevel): New function: + `mime-display-multipart/pgp-encrypted'. + * pgg-def.el (toplevel): New custom: `pgg-decrypt-automatically'. + * semi-setup.el (toplevel): New mime-preview condtion for MIME + type "application/pgp-encrypted". 2010-01-19 Vitaly Mayatskikh diff --git a/mime-pgp.el b/mime-pgp.el index 3a5b655..8f49a2e 100644 --- a/mime-pgp.el +++ b/mime-pgp.el @@ -270,6 +270,17 @@ (setq mime-view-temp-message-buffer message-buf)) (set-window-buffer p-win preview-buffer)))) +(defun mime-display-multipart/pgp-encrypted (entity situation) + (if pgg-decrypt-automatically + (let ((pgp-begin (point))) + (mime-insert-entity entity) + (goto-char pgp-begin) + (when (re-search-forward "^-+BEGIN PGP MESSAGE-+$" nil t) + (pgg-decrypt-region pgp-begin (point-max)) + (delete-region pgp-begin (point-max)) + (mime-display-entity + (mime-parse-buffer pgg-output-buffer)))) + (mime-display-multipart/mixed entity situation))) ;;; @ end ;;; diff --git a/pgg-def.el b/pgg-def.el index 5f8d722..403684f 100644 --- a/pgg-def.el +++ b/pgg-def.el @@ -58,6 +58,11 @@ :group 'pgg :type 'boolean) +(defcustom pgg-decrypt-automatically nil + "*If t, decrypt messages automatically." + :group 'pgg + :type 'boolean) + (defvar pgg-messages-coding-system nil "Coding system used when reading from a PGP external process.") diff --git a/semi-setup.el b/semi-setup.el index 0c1931c..2333877 100644 --- a/semi-setup.el +++ b/semi-setup.el @@ -79,6 +79,8 @@ it is used as hook to set." (if mime-setup-enable-pgp (eval-after-load "mime-view" '(progn + (require 'mime-pgp) + (mime-add-condition 'preview '((type . application)(subtype . pgp) (message-button . visible))) @@ -136,6 +138,12 @@ it is used as hook to set." '((type . application)(subtype . x-pkcs7-mime) (method . mime-view-application/pkcs7-mime)) 'strict "mime-pgp") + + (ctree-set-calist-strictly + 'mime-preview-condition + '((type . multipart) (subtype . encrypted) ("protocol" . "application/pgp-encrypted") + (body . visible) + (body-presentation-method . mime-display-multipart/pgp-encrypted))) )) )