diff options
| -rw-r--r-- | lisp/ChangeLog | 8 | ||||
| -rw-r--r-- | lisp/mail/rmail.el | 85 |
2 files changed, 38 insertions, 55 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 8bf75bf1a61..dca9e23a67f 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,11 @@ | |||
| 1 | 2011-08-31 Richard Stallman <rms@gnu.org> | ||
| 2 | |||
| 3 | * mail/rmail.el (rmail-epa-decrypt): Rewrite to take account | ||
| 4 | of the separation of rmail-view-buffer from rmail-buffer. | ||
| 5 | If you say no to "replace original", the decrypt is in the | ||
| 6 | view buffer. If you say yes, the decrypt goes into the | ||
| 7 | rmail buffer also. | ||
| 8 | |||
| 1 | 2011-08-31 Martin Rudalics <rudalics@gmx.at> | 9 | 2011-08-31 Martin Rudalics <rudalics@gmx.at> |
| 2 | 10 | ||
| 3 | * window.el (display-buffer-window): Rewrite doc-string. | 11 | * window.el (display-buffer-window): Rewrite doc-string. |
diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el index 9b4bbf91823..252fb112a5d 100644 --- a/lisp/mail/rmail.el +++ b/lisp/mail/rmail.el | |||
| @@ -4308,7 +4308,7 @@ encoded string (and the same mask) will decode the string." | |||
| 4308 | ;; change it in one of the calls to `epa-decrypt-region'. | 4308 | ;; change it in one of the calls to `epa-decrypt-region'. |
| 4309 | 4309 | ||
| 4310 | (save-excursion | 4310 | (save-excursion |
| 4311 | (let (new-buffer not-first-armor) | 4311 | (let (decrypts) |
| 4312 | (goto-char (point-min)) | 4312 | (goto-char (point-min)) |
| 4313 | 4313 | ||
| 4314 | ;; In case the encrypted data is inside a mime attachment, | 4314 | ;; In case the encrypted data is inside a mime attachment, |
| @@ -4324,8 +4324,8 @@ encoded string (and the same mask) will decode the string." | |||
| 4324 | ;; and decrypt them one by one. | 4324 | ;; and decrypt them one by one. |
| 4325 | (goto-char (point-min)) | 4325 | (goto-char (point-min)) |
| 4326 | (while (re-search-forward "-----BEGIN PGP MESSAGE-----$" nil t) | 4326 | (while (re-search-forward "-----BEGIN PGP MESSAGE-----$" nil t) |
| 4327 | (let (armor-start armor-end | 4327 | (let ((coding-system-for-read coding-system-for-read) |
| 4328 | (coding-system-for-read coding-system-for-read)) | 4328 | armor-start armor-end after-end) |
| 4329 | (setq armor-start (match-beginning 0) | 4329 | (setq armor-start (match-beginning 0) |
| 4330 | armor-end (re-search-forward "^-----END PGP MESSAGE-----$" | 4330 | armor-end (re-search-forward "^-----END PGP MESSAGE-----$" |
| 4331 | nil t)) | 4331 | nil t)) |
| @@ -4345,64 +4345,39 @@ encoded string (and the same mask) will decode the string." | |||
| 4345 | 4345 | ||
| 4346 | ;; Advance over this armor. | 4346 | ;; Advance over this armor. |
| 4347 | (goto-char armor-end) | 4347 | (goto-char armor-end) |
| 4348 | (setq after-end (- (point-max) armor-end)) | ||
| 4348 | 4349 | ||
| 4349 | ;; Decrypt it, maybe in place, maybe making new buffer. | 4350 | ;; Decrypt it, maybe in place, maybe making new buffer. |
| 4350 | (epa-decrypt-region | 4351 | (epa-decrypt-region |
| 4351 | armor-start armor-end | 4352 | armor-start armor-end |
| 4352 | ;; Call back this function to prepare the output. | 4353 | ;; Call back this function to prepare the output. |
| 4353 | (lambda () | 4354 | (lambda () |
| 4354 | (if (or not-first-armor | 4355 | (let ((inhibit-read-only t)) |
| 4355 | (y-or-n-p "Replace the original message? ")) | 4356 | (delete-region armor-start armor-end) |
| 4356 | ;; User wants to decrypt in place, | 4357 | (goto-char armor-start) |
| 4357 | ;; or this isn't the first armor. | 4358 | (current-buffer)))) |
| 4358 | ;; We only ask the question for the first armor. | 4359 | |
| 4359 | (let ((inhibit-read-only t)) | 4360 | (push (list armor-start (- (point-max) after-end)) |
| 4360 | (delete-region armor-start armor-end) | 4361 | decrypts))) |
| 4361 | (goto-char armor-start) | 4362 | |
| 4362 | (current-buffer)) | 4363 | (when (and decrypts (rmail-buffers-swapped-p)) |
| 4363 | ;; User says not to replace the original text. | 4364 | (when (y-or-n-p "Replace the original message? ") |
| 4364 | (or new-buffer | 4365 | (setq decrypts (nreverse decrypts)) |
| 4365 | (let ((from-buffer | 4366 | (let ((beg (rmail-msgbeg rmail-current-message)) |
| 4366 | (if (rmail-buffers-swapped-p) | 4367 | (end (rmail-msgend rmail-current-message)) |
| 4367 | rmail-view-buffer rmail-buffer)) | 4368 | (from-buffer (current-buffer))) |
| 4368 | (from-pruned (rmail-msg-is-pruned)) | 4369 | (with-current-buffer rmail-view-buffer |
| 4369 | (beg (rmail-msgbeg rmail-current-message)) | 4370 | (narrow-to-region beg end) |
| 4370 | (end (rmail-msgend rmail-current-message))) | 4371 | (goto-char (point-min)) |
| 4371 | (with-current-buffer (generate-new-buffer "*Decrypt*") | 4372 | (dolist (d decrypts) |
| 4372 | (setq buffer-read-only nil) | 4373 | (if (re-search-forward "-----BEGIN PGP MESSAGE-----$" nil t) |
| 4373 | (insert-buffer-substring from-buffer beg end) | 4374 | (let (armor-start armor-end) |
| 4374 | (rmail-mode) | 4375 | (setq armor-start (match-beginning 0) |
| 4375 | ;; This should be pruned if the original message was. | 4376 | armor-end (re-search-forward "^-----END PGP MESSAGE-----$" |
| 4376 | (unless from-pruned (rmail-toggle-header)) | 4377 | nil t)) |
| 4377 | (goto-char (point-min)) | 4378 | (when armor-end |
| 4378 | 4379 | (delete-region armor-start armor-end) | |
| 4379 | ;; Find the first armor in the text we just copied. | 4380 | (insert-buffer-substring from-buffer (nth 0 d) (nth 1 d))))))))))))) |
| 4380 | ;; What we copied may not be identical | ||
| 4381 | ;; to the initial text. | ||
| 4382 | (re-search-forward "-----BEGIN PGP MESSAGE-----$") | ||
| 4383 | (setq armor-start (match-beginning 0)) | ||
| 4384 | (re-search-forward "^-----END PGP MESSAGE-----$") | ||
| 4385 | (setq armor-end (point)) | ||
| 4386 | ;; Delete it and put point there. | ||
| 4387 | (let ((inhibit-read-only t)) | ||
| 4388 | (delete-region armor-start armor-end)) | ||
| 4389 | (goto-char armor-start) | ||
| 4390 | (setq new-buffer (current-buffer)) | ||
| 4391 | ;; Return; epa-decrypt-region will insert plaintext. | ||
| 4392 | )))))) | ||
| 4393 | |||
| 4394 | (setq not-first-armor t) | ||
| 4395 | |||
| 4396 | ;; If we copied the buffer, switch to the copy | ||
| 4397 | ;; for the rest of this loop. | ||
| 4398 | ;; Point is the only buffer pointer that is live here, | ||
| 4399 | ;; and it was properly set in NEW-BUFFER by `epa-decrypt-region' | ||
| 4400 | ;; when it inserted the decrypted epa | ||
| 4401 | (if new-buffer (set-buffer new-buffer)))) | ||
| 4402 | |||
| 4403 | ;; If we decrypted into a new buffer, show it. | ||
| 4404 | (if new-buffer | ||
| 4405 | (display-buffer new-buffer))))) | ||
| 4406 | 4381 | ||
| 4407 | ;;;; Desktop support | 4382 | ;;;; Desktop support |
| 4408 | 4383 | ||