diff options
| author | Karl Heuer | 1998-06-04 06:25:21 +0000 |
|---|---|---|
| committer | Karl Heuer | 1998-06-04 06:25:21 +0000 |
| commit | 6a91b84a41870d33e83013178561f1515516afca (patch) | |
| tree | b9f82ea66e4d81e6b12abce78ade74c8b8e41684 | |
| parent | b9edcafb519bac258c0f3b269fa5163fd861c6ad (diff) | |
| download | emacs-6a91b84a41870d33e83013178561f1515516afca.tar.gz emacs-6a91b84a41870d33e83013178561f1515516afca.zip | |
(rmail-toggle-header): Redo previous change;
don't move point if possible.
(rmail-count-screen-lines): Add.
| -rw-r--r-- | lisp/mail/rmail.el | 93 |
1 files changed, 58 insertions, 35 deletions
diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el index b94f4657c6f..0f3063769a8 100644 --- a/lisp/mail/rmail.el +++ b/lisp/mail/rmail.el | |||
| @@ -1780,42 +1780,65 @@ Otherwise, delete all header fields whose names match `rmail-ignored-headers'." | |||
| 1780 | With argument ARG, show the message header pruned if ARG is greater than zero; | 1780 | With argument ARG, show the message header pruned if ARG is greater than zero; |
| 1781 | otherwise, show it in full." | 1781 | otherwise, show it in full." |
| 1782 | (interactive "P") | 1782 | (interactive "P") |
| 1783 | (let* ((buffer-read-only nil) | ||
| 1784 | (pruned (rmail-msg-is-pruned)) | ||
| 1785 | (prune (if arg | ||
| 1786 | (> (prefix-numeric-value arg) 0) | ||
| 1787 | (not pruned)))) | ||
| 1788 | (if (eq pruned prune) | ||
| 1789 | t | ||
| 1790 | (rmail-maybe-set-message-counters) | ||
| 1791 | (let ((at-point-min (= (point) (point-min))) | ||
| 1792 | (all-headers-visible (= (window-start) (point-min))) | ||
| 1793 | (on-header (save-excursion | ||
| 1794 | (and (not (search-backward "\n\n" nil t)) | ||
| 1795 | (progn | ||
| 1796 | (end-of-line) | ||
| 1797 | (re-search-backward "^[-A-Za-z0-9]+:" nil t)) | ||
| 1798 | (match-string 0)))) | ||
| 1799 | (old-screen-line (rmail-count-screen-lines (window-start) (point)))) | ||
| 1800 | (save-excursion | ||
| 1801 | (narrow-to-region (rmail-msgbeg rmail-current-message) (point-max)) | ||
| 1802 | (if pruned | ||
| 1803 | (progn (goto-char (point-min)) | ||
| 1804 | (forward-line 1) | ||
| 1805 | (delete-char 1) | ||
| 1806 | (insert ?0) | ||
| 1807 | (forward-line 1) | ||
| 1808 | (let ((case-fold-search t)) | ||
| 1809 | (while (looking-at "Summary-Line:\\|Mail-From:") | ||
| 1810 | (forward-line 1))) | ||
| 1811 | (insert "*** EOOH ***\n") | ||
| 1812 | (forward-char -1) | ||
| 1813 | (search-forward "\n*** EOOH ***\n") | ||
| 1814 | (narrow-to-region (point) (point-max))) | ||
| 1815 | (rmail-reformat-message (point-min) (point-max)))) | ||
| 1816 | (cond (at-point-min | ||
| 1817 | (goto-char (point-min))) | ||
| 1818 | (on-header | ||
| 1819 | (goto-char (point-min)) | ||
| 1820 | (search-forward "\n\n") | ||
| 1821 | (or (re-search-backward (concat "^" (regexp-quote on-header)) nil t) | ||
| 1822 | (goto-char (point-min)))) | ||
| 1823 | (t | ||
| 1824 | (recenter old-screen-line) | ||
| 1825 | (if (and all-headers-visible | ||
| 1826 | (not (= (window-start) (point-min)))) | ||
| 1827 | (let ((lines-offscreen (rmail-count-screen-lines | ||
| 1828 | (point-min) (window-start)))) | ||
| 1829 | (recenter (min (+ old-screen-line lines-offscreen) | ||
| 1830 | ;; last line of window | ||
| 1831 | (- (window-height) 2)))))))) | ||
| 1832 | (rmail-highlight-headers)))) | ||
| 1833 | |||
| 1834 | ;; Lifted from repos-count-screen-lines. | ||
| 1835 | ;; Return number of screen lines between START and END. | ||
| 1836 | (defun rmail-count-screen-lines (start end) | ||
| 1783 | (save-excursion | 1837 | (save-excursion |
| 1784 | (let* ((buffer-read-only nil) | 1838 | (save-restriction |
| 1785 | (pruned (rmail-msg-is-pruned)) | 1839 | (narrow-to-region start end) |
| 1786 | (prune (if arg | 1840 | (goto-char (point-min)) |
| 1787 | (> (prefix-numeric-value arg) 0) | 1841 | (vertical-motion (- (point-max) (point-min)))))) |
| 1788 | (not pruned)))) | ||
| 1789 | (if (eq pruned prune) | ||
| 1790 | t | ||
| 1791 | (rmail-maybe-set-message-counters) | ||
| 1792 | (narrow-to-region (rmail-msgbeg rmail-current-message) (point-max)) | ||
| 1793 | (if pruned | ||
| 1794 | (let (window-at-top) | ||
| 1795 | (goto-char (point-min)) | ||
| 1796 | (forward-line 1) | ||
| 1797 | (delete-char 1) | ||
| 1798 | (insert ?0) | ||
| 1799 | (forward-line 1) | ||
| 1800 | (let ((case-fold-search t)) | ||
| 1801 | (while (looking-at "Summary-Line:\\|Mail-From:") | ||
| 1802 | (forward-line 1))) | ||
| 1803 | (insert "*** EOOH ***\n") | ||
| 1804 | (forward-char -1) | ||
| 1805 | (search-forward "\n*** EOOH ***\n") | ||
| 1806 | (forward-line -1) | ||
| 1807 | (let ((temp (point))) | ||
| 1808 | (when (search-forward "\n\n" nil t) | ||
| 1809 | (if (< (window-start) (point)) | ||
| 1810 | (setq window-at-top t)) | ||
| 1811 | (delete-region temp (point)))) | ||
| 1812 | (goto-char (point-min)) | ||
| 1813 | (search-forward "\n*** EOOH ***\n") | ||
| 1814 | (if window-at-top | ||
| 1815 | (set-window-start (selected-window) (point) t)) | ||
| 1816 | (narrow-to-region (point) (point-max))) | ||
| 1817 | (rmail-reformat-message (point-min) (point-max))) | ||
| 1818 | (rmail-highlight-headers))))) | ||
| 1819 | 1842 | ||
| 1820 | ;;;; *** Rmail Attributes and Keywords *** | 1843 | ;;;; *** Rmail Attributes and Keywords *** |
| 1821 | 1844 | ||