mirror of
https://git.savannah.gnu.org/git/emacs.git
synced 2024-12-26 10:49:33 +00:00
Re-enable mime processing after decryption. Add 'decrypt' keyword.
* rmail.el (rmail-epa-decrypt-1): New subroutine. (rmail-epa-decrypt): rmail-epa-decrypt-1 broken out. In a mime message, reenable Mime and show the parts that were shown before. Add keyword "decrypt" if anything decrypted.
This commit is contained in:
parent
472addd6f2
commit
503058a1d6
@ -4508,38 +4508,17 @@ encoded string (and the same mask) will decode the string."
|
||||
(setq i (1+ i)))
|
||||
(concat string-vector)))
|
||||
|
||||
;; Should this have a key-binding, or be in a menu?
|
||||
;; There doesn't really seem to be an appropriate menu.
|
||||
;; Eg the edit command is not in a menu either.
|
||||
(defun rmail-epa-decrypt ()
|
||||
"Decrypt GnuPG or OpenPGP armors in current message."
|
||||
(interactive)
|
||||
|
||||
;; Save the current buffer here for cleanliness, in case we
|
||||
;; change it in one of the calls to `epa-decrypt-region'.
|
||||
|
||||
(save-excursion
|
||||
(let (decrypts (mime (rmail-mime-message-p)))
|
||||
(goto-char (point-min))
|
||||
|
||||
;; Turn off mime processing.
|
||||
(when (and mime
|
||||
(not (get-text-property (point-min) 'rmail-mime-hidden)))
|
||||
(rmail-mime))
|
||||
|
||||
;; Now find all armored messages in the buffer
|
||||
;; and decrypt them one by one.
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward "-----BEGIN PGP MESSAGE-----$" nil t)
|
||||
(let ((coding-system-for-read coding-system-for-read)
|
||||
(case-fold-search t)
|
||||
unquote
|
||||
armor-start armor-prefix armor-end-regexp armor-end after-end)
|
||||
|
||||
(setq armor-start (match-beginning 0)
|
||||
armor-prefix (buffer-substring
|
||||
(defun rmail-epa-decrypt-1 (mime)
|
||||
"Decrypt a single GnuPG encrypted text in a message.
|
||||
The starting string of the encrypted text should have just been regexp-matched.
|
||||
Argument MIME is non-nil if this is a mime message."
|
||||
(let* ((armor-start (match-beginning 0))
|
||||
(armor-prefix (buffer-substring
|
||||
(line-beginning-position)
|
||||
armor-start))
|
||||
(armor-end-regexp)
|
||||
armor-end after-end
|
||||
unquote)
|
||||
(if (string-match "<pre>\\'" armor-prefix)
|
||||
(setq armor-prefix ""))
|
||||
|
||||
@ -4594,12 +4573,42 @@ encoded string (and the same mask) will decode the string."
|
||||
(goto-char armor-start)
|
||||
(current-buffer))))
|
||||
|
||||
(push (list armor-start (- (point-max) after-end) mime
|
||||
armor-end-regexp)
|
||||
decrypts)))
|
||||
(list armor-start (- (point-max) after-end) mime
|
||||
armor-end-regexp)))
|
||||
|
||||
(unless decrypts
|
||||
(error "Nothing to decrypt"))
|
||||
;; Should this have a key-binding, or be in a menu?
|
||||
;; There doesn't really seem to be an appropriate menu.
|
||||
;; Eg the edit command is not in a menu either.
|
||||
|
||||
(defun rmail-epa-decrypt ()
|
||||
"Decrypt GnuPG or OpenPGP armors in current message."
|
||||
(interactive)
|
||||
|
||||
;; Save the current buffer here for cleanliness, in case we
|
||||
;; change it in one of the calls to `epa-decrypt-region'.
|
||||
|
||||
(save-excursion
|
||||
(let (decrypts (mime (rmail-mime-message-p))
|
||||
mime-disabled)
|
||||
(goto-char (point-min))
|
||||
|
||||
;; Turn off mime processing.
|
||||
(when (and mime
|
||||
(not (get-text-property (point-min) 'rmail-mime-hidden)))
|
||||
(setq mime-disabled t)
|
||||
(rmail-mime))
|
||||
|
||||
;; Now find all armored messages in the buffer
|
||||
;; and decrypt them one by one.
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward "-----BEGIN PGP MESSAGE-----$" nil t)
|
||||
(let ((coding-system-for-read coding-system-for-read)
|
||||
(case-fold-search t))
|
||||
|
||||
(push (rmail-epa-decrypt-1 mime) decrypts)))
|
||||
|
||||
(when (and decrypts (eq major-mode 'rmail-mode))
|
||||
(rmail-add-label "decrypt"))
|
||||
|
||||
(when (and decrypts (rmail-buffers-swapped-p))
|
||||
(when (y-or-n-p "Replace the original message? ")
|
||||
@ -4639,7 +4648,30 @@ encoded string (and the same mask) will decode the string."
|
||||
(let ((value (match-string 0)))
|
||||
(unless (member value '("text/plain" "text/html"))
|
||||
(replace-match "text/plain"))))))))
|
||||
))))))))))
|
||||
)))))))
|
||||
|
||||
(when (and (null decrypts)
|
||||
mime mime-disabled)
|
||||
;; Re-enable mime processinjg
|
||||
(rmail-mime)
|
||||
;; Find each Show button and show that part.
|
||||
(while (search-forward " Show " nil t)
|
||||
(forward-char -2)
|
||||
(let ((rmail-mime-render-html-function nil)
|
||||
(entity (get-text-property (point) 'rmail-mime-entity)))
|
||||
(unless (and (not (stringp entity))
|
||||
(rmail-mime-entity-truncated entity))
|
||||
(push-button))))
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward "-----BEGIN PGP MESSAGE-----$" nil t)
|
||||
(let ((coding-system-for-read coding-system-for-read)
|
||||
(case-fold-search t))
|
||||
(push (rmail-epa-decrypt-1 mime) decrypts)))
|
||||
|
||||
)
|
||||
|
||||
(unless decrypts
|
||||
(error "Nothing to decrypt")))))
|
||||
|
||||
|
||||
;;;; Desktop support
|
||||
|
Loading…
Reference in New Issue
Block a user