diff options
author | Richard Stallman <rms@gnu.org> | 2024-01-02 09:45:45 -0500 |
---|---|---|
committer | Richard Stallman <rms@gnu.org> | 2024-01-02 09:45:45 -0500 |
commit | b37676642679a9ec3cd3b995cd14a4af3567cf80 (patch) | |
tree | 789863f7810bdeb71286cf0a2867cbc88d385381 | |
parent | 7c6e44e5ccb009a63da30fbc468c924dd383b521 (diff) | |
download | emacs-b37676642679a9ec3cd3b995cd14a4af3567cf80.tar.gz |
Fix non-permenent decryption to show up temperarily.
In a decrypted mime part, replace CRLF with newline,
* lisp/mail/rmail.el (rmail-epa-decrypt-1): If NOT descrypting permanently,
put the decrypts into the view buffer.
(rmail-epa-decrypt, rmail-epa-decrypt-1):
In a decrypted mime part, replace CRLF with newline,
-rw-r--r-- | lisp/mail/rmail.el | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el index 6366a9fddcb..a9a56e35573 100644 --- a/lisp/mail/rmail.el +++ b/lisp/mail/rmail.el @@ -4611,6 +4611,16 @@ Argument MIME is non-nil if this is a mime message." ;; Decode any base64-encoded material in what we just decrypted. (rmail-epa-decode armor-start after-end) + ;; If this is in a MIME part, convert CRLF into just LF (newline) + (when mime + (save-restriction + (narrow-to-region armor-start (- (point-max) after-end)) + (goto-char (point-min)) + (let ((inhibit-read-only t)) + (while (search-forward "\r\n" nil t) + (delete-region (- (point) 2) (- (point) 1))))) + ) + (list armor-start (- (point-max) after-end) mime armor-end-regexp (buffer-substring armor-start (- (point-max) after-end))))) @@ -4654,7 +4664,33 @@ Argument MIME is non-nil if this is a mime message." (push (rmail-epa-decrypt-1 mime) decrypts)))) (when (and decrypts (rmail-buffers-swapped-p)) - (when (y-or-n-p "Replace the original message? ") + (if (not (y-or-n-p "Replace the original message? ")) + ;; User wants to decrypt only temporarily. + ;; Find, in the view buffer, the armors + ;; that we made decrypts for, and replace each one + ;; with its decrypt. In a mime part, replace CRLF with NL. + (dolist (d decrypts) + (if (re-search-forward "-----BEGIN PGP MESSAGE-----$" nil t) + (let (armor-start armor-end armor-end-regexp) + (setq armor-start (match-beginning 0) + armor-end-regexp (nth 3 d) + armor-end (re-search-forward + armor-end-regexp + nil t)) + + ;; Found as expected -- now replace it with the decrypt. + (when armor-end + (if (null (nth 2 d)) + nil + ;; In a mime part -- + ;; replace CRLF with NL in it. + (save-restriction + (narrow-to-region armor-start armor-end) + (goto-char (point-min)) + (while (search-forward "\r\n" nil t) + (delete-region (- (point) 2) (- (point) 1)))))) + ))) + ;; User wants to decrypt the message perenently. (when (eq major-mode 'rmail-mode) (rmail-add-label "decrypt")) (setq decrypts (nreverse decrypts)) |