changeset 22330:6d28f2670ebe

(rmail-toggle-header): Preserve point and window-start (more or less) when reverting to original header.
author Karl Heuer <kwzh@gnu.org>
date Tue, 02 Jun 1998 06:54:40 +0000
parents 4786b00d2973
children fcc3db2d9778
files lisp/mail/rmail.el
diffstat 1 files changed, 36 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/mail/rmail.el	Tue Jun 02 03:54:18 1998 +0000
+++ b/lisp/mail/rmail.el	Tue Jun 02 06:54:40 1998 +0000
@@ -1780,36 +1780,42 @@
 With argument ARG, show the message header pruned if ARG is greater than zero;
 otherwise, show it in full."
   (interactive "P")
-  (let* ((buffer-read-only nil)
-	 (pruned (rmail-msg-is-pruned))
-	 (prune (if arg
-		    (> (prefix-numeric-value arg) 0)
-		  (not pruned))))
-    (if (eq pruned prune)
-	t
-      (rmail-maybe-set-message-counters)
-      (narrow-to-region (rmail-msgbeg rmail-current-message) (point-max))
-      (if pruned
-	  (progn (goto-char (point-min))
-		 (forward-line 1)
-		 (delete-char 1)
-		 (insert ?0)
-		 (forward-line 1)
-		 (let ((case-fold-search t))
-		   (while (looking-at "Summary-Line:\\|Mail-From:")
-		     (forward-line 1)))
-		 (insert "*** EOOH ***\n")
-		 (forward-char -1)
-		 (search-forward "\n*** EOOH ***\n")
-		 (forward-line -1)
-		 (let ((temp (point)))
-		   (and (search-forward "\n\n" nil t)
-			(delete-region temp (point))))
-		 (goto-char (point-min))
-		 (search-forward "\n*** EOOH ***\n")
-		 (narrow-to-region (point) (point-max)))
-	(rmail-reformat-message (point-min) (point-max)))
-      (rmail-highlight-headers))))
+  (save-excursion
+    (let* ((buffer-read-only nil)
+	   (pruned (rmail-msg-is-pruned))
+	   (prune (if arg
+		      (> (prefix-numeric-value arg) 0)
+		    (not pruned))))
+      (if (eq pruned prune)
+	  t
+	(rmail-maybe-set-message-counters)
+	(narrow-to-region (rmail-msgbeg rmail-current-message) (point-max))
+	(if pruned
+	    (let (window-at-top)
+	      (goto-char (point-min))
+	      (forward-line 1)
+	      (delete-char 1)
+	      (insert ?0)
+	      (forward-line 1)
+	      (let ((case-fold-search t))
+		(while (looking-at "Summary-Line:\\|Mail-From:")
+		  (forward-line 1)))
+	      (insert "*** EOOH ***\n")
+	      (forward-char -1)
+	      (search-forward "\n*** EOOH ***\n")
+	      (forward-line -1)
+	      (let ((temp (point)))
+		(when (search-forward "\n\n" nil t)
+		  (if (< (window-start) (point))
+		      (setq window-at-top t))
+		  (delete-region temp (point))))
+	      (goto-char (point-min))
+	      (search-forward "\n*** EOOH ***\n")
+	      (if window-at-top
+		  (set-window-start (selected-window) (point) t))
+	      (narrow-to-region (point) (point-max)))
+	  (rmail-reformat-message (point-min) (point-max)))
+	(rmail-highlight-headers)))))
 
 ;;;; *** Rmail Attributes and Keywords ***