changeset 101817:47b9194b4a87

(rmail-duplicate-message): Make it work.
author Glenn Morris <rgm@gnu.org>
date Thu, 05 Feb 2009 07:38:56 +0000
parents 5e57e0473132
children 86b3f8ddbaee
files lisp/ChangeLog lisp/mail/rmail.el
diffstat 2 files changed, 23 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Thu Feb 05 07:12:27 2009 +0000
+++ b/lisp/ChangeLog	Thu Feb 05 07:38:56 2009 +0000
@@ -12,7 +12,8 @@
 
 2009-02-05  Glenn Morris  <rgm@gnu.org>
 
-	* mail/rmail.el (rmail-what-message): Unbreak it.
+	* mail/rmail.el (rmail-what-message, rmail-duplicate-message):
+	Make these functions work.
 
 	* net/mairix.el (rmail-buffer): Remove unneeded eval-when-compile.
 	(rmail-narrow-to-non-pruned-header): Remove autoload.
--- a/lisp/mail/rmail.el	Thu Feb 05 07:12:27 2009 +0000
+++ b/lisp/mail/rmail.el	Thu Feb 05 07:38:56 2009 +0000
@@ -1442,16 +1442,27 @@
 The duplicate copy goes into the Rmail file just after the
 original copy."
   (interactive)
-  (widen)
-  (let ((buffer-read-only nil)
-	(number rmail-current-message)
-	(string (buffer-substring (rmail-msgbeg rmail-current-message)
-				  (rmail-msgend rmail-current-message))))
-    (goto-char (rmail-msgend rmail-current-message))
-    (insert string)
-    (rmail-forget-messages)
-    (rmail-show-message-maybe number)
-    (message "Message duplicated")))
+  ;; If we are in a summary buffer, switch to the Rmail buffer.
+  (set-buffer rmail-buffer)
+  (let ((buff (current-buffer))
+        (n rmail-current-message)
+        (beg (rmail-msgbeg rmail-current-message))
+        (end (rmail-msgend rmail-current-message)))
+    (if (rmail-buffers-swapped-p) (set-buffer rmail-view-buffer))
+    (widen)
+    (let ((buffer-read-only nil)
+          (string (buffer-substring-no-properties beg end)))
+      (goto-char end)
+      (insert string))
+    (set-buffer buff)
+    (rmail-swap-buffers-maybe)
+    (goto-char (point-max))
+    (rmail-set-message-counters)
+    (set-buffer-modified-p t)
+    (rmail-show-message n))
+  (if (rmail-summary-exists)
+      (rmail-select-summary (rmail-update-summary)))
+  (message "Message duplicated"))
 
 ;;;###autoload
 (defun rmail-input (filename)