# HG changeset patch # User Richard M. Stallman # Date 834949408 0 # Node ID fb91eb76bead9a1b36ceffc51fa4783a9dbd7708 # Parent 43b1f8a3af53da66c8cba391551853409d92d6ad (unforward-rmail-message): In summary buffer, switch temporarily to Rmail buffer. diff -r 43b1f8a3af53 -r fb91eb76bead lisp/mail/undigest.el --- a/lisp/mail/undigest.el Sat Jun 15 23:19:40 1996 +0000 +++ b/lisp/mail/undigest.el Sun Jun 16 18:23:28 1996 +0000 @@ -137,37 +137,46 @@ 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