summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard M. Stallman <rms@gnu.org>1996-06-16 18:23:28 +0000
committerRichard M. Stallman <rms@gnu.org>1996-06-16 18:23:28 +0000
commitb309919e3e6a4265d500d3b9222d469baf688bc5 (patch)
tree5fbe9d99e0fc1288099c337d720626264a25457c
parentd69128b0ccfc511861c786e82db0b8df716a6f38 (diff)
downloademacs-b309919e3e6a4265d500d3b9222d469baf688bc5.tar.gz
(unforward-rmail-message): In summary buffer,
switch temporarily to Rmail buffer.
-rw-r--r--lisp/mail/undigest.el73
1 files changed, 41 insertions, 32 deletions
diff --git a/lisp/mail/undigest.el b/lisp/mail/undigest.el
index 80c7b3cfb39..c2d2414394a 100644
--- a/lisp/mail/undigest.el
+++ b/lisp/mail/undigest.el
@@ -137,37 +137,46 @@ Leaves original message, deleted, before the undigestified messages."
This puts the forwarded message into a separate rmail message
following the containing message."
(interactive)
- (narrow-to-region (rmail-msgbeg rmail-current-message)
- (rmail-msgend rmail-current-message))
- (goto-char (point-min))
- (let (beg end (buffer-read-only nil) msg-string who-forwarded-it)
- (setq who-forwarded-it (mail-fetch-field "From"))
- (if (re-search-forward "^----" nil t)
- nil
- (error "No forwarded message"))
- (forward-line 1)
- (setq beg (point))
- (if (re-search-forward "^----" nil t)
- (setq end (match-beginning 0))
- (error "No terminator for forwarded message"))
- (widen)
- (setq msg-string (buffer-substring beg end))
- (goto-char (rmail-msgend rmail-current-message))
- (narrow-to-region (point) (point))
- (insert "\^_\^L\n0, unseen,,\n*** EOOH ***\n")
- (narrow-to-region (point) (point))
- (insert "Forwarded-by: " who-forwarded-it "\n")
- (insert msg-string)
- (goto-char (point-min))
- (while (not (eobp))
- (if (looking-at "- ")
- (delete-region (point) (+ 2 (point))))
- (forward-line 1))
- (let ((n rmail-current-message))
- (rmail-forget-messages)
- (rmail-show-message n)
- (if (rmail-summary-exists)
- (rmail-select-summary
- (rmail-update-summary))))))
+ ;; Don't use save-excursion because we don't want to restore point
+ ;; in the case where we do not switch buffers.
+ (let ((obuf (current-buffer)))
+ (unwind-protect
+ (progn
+ ;; If we are in a summary buffer, switch to the Rmail buffer.
+ (if (local-variable-p 'rmail-buffer)
+ (set-buffer rmail-buffer))
+ (narrow-to-region (rmail-msgbeg rmail-current-message)
+ (rmail-msgend rmail-current-message))
+ (goto-char (point-min))
+ (let (beg end (buffer-read-only nil) msg-string who-forwarded-it)
+ (setq who-forwarded-it (mail-fetch-field "From"))
+ (if (re-search-forward "^----" nil t)
+ nil
+ (error "No forwarded message"))
+ (forward-line 1)
+ (setq beg (point))
+ (if (re-search-forward "^----" nil t)
+ (setq end (match-beginning 0))
+ (error "No terminator for forwarded message"))
+ (widen)
+ (setq msg-string (buffer-substring beg end))
+ (goto-char (rmail-msgend rmail-current-message))
+ (narrow-to-region (point) (point))
+ (insert "\^_\^L\n0, unseen,,\n*** EOOH ***\n")
+ (narrow-to-region (point) (point))
+ (insert "Forwarded-by: " who-forwarded-it "\n")
+ (insert msg-string)
+ (goto-char (point-min))
+ (while (not (eobp))
+ (if (looking-at "- ")
+ (delete-region (point) (+ 2 (point))))
+ (forward-line 1))
+ (let ((n rmail-current-message))
+ (rmail-forget-messages)
+ (rmail-show-message n)
+ (if (rmail-summary-exists)
+ (rmail-select-summary
+ (rmail-update-summary))))))
+ (set-buffer obuf))))
;;; undigest.el ends here