]> git.eshelyaron.com Git - emacs.git/commitdiff
(unforward-rmail-message): In summary buffer,
authorRichard M. Stallman <rms@gnu.org>
Sun, 16 Jun 1996 18:23:28 +0000 (18:23 +0000)
committerRichard M. Stallman <rms@gnu.org>
Sun, 16 Jun 1996 18:23:28 +0000 (18:23 +0000)
switch temporarily to Rmail buffer.

lisp/mail/undigest.el

index 80c7b3cfb391de5763514ee13a9270ec54248ec9..c2d2414394a1d0f41fb764184bd5148ab8158865 100644 (file)
@@ -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