changeset 15438:fb91eb76bead

(unforward-rmail-message): In summary buffer, switch temporarily to Rmail buffer.
author Richard M. Stallman <rms@gnu.org>
date Sun, 16 Jun 1996 18:23:28 +0000
parents 43b1f8a3af53
children b549210f6989
files lisp/mail/undigest.el
diffstat 1 files changed, 41 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- 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