aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Moellmann2001-06-26 10:34:27 +0000
committerGerd Moellmann2001-06-26 10:34:27 +0000
commit157521c55e8a8443894d386a86e39eed85aa982b (patch)
tree03afa86e7ea965f9594ef11c4d6bac7d190e4f25
parent5a08cbaf3b02a0d036790cbdacdb4695c63e6084 (diff)
downloademacs-157521c55e8a8443894d386a86e39eed85aa982b.tar.gz
emacs-157521c55e8a8443894d386a86e39eed85aa982b.zip
(rmail-msg-restore-non-pruned-header): New
function. (rmail-msg-prune-header): Likewise. (rmail-toggle-header): Use `rmail-msg-restore-non-pruned-header' and `rmail-msg-prune-header'.
-rw-r--r--lisp/mail/rmail.el135
1 files changed, 75 insertions, 60 deletions
diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el
index 4a130311566..a69ac40ae5c 100644
--- a/lisp/mail/rmail.el
+++ b/lisp/mail/rmail.el
@@ -1946,78 +1946,93 @@ Otherwise, delete all header fields whose names match `rmail-ignored-headers'."
1946 (forward-line 1) 1946 (forward-line 1)
1947 (= (following-char) ?1)))) 1947 (= (following-char) ?1))))
1948 1948
1949(defun rmail-msg-restore-non-pruned-header ()
1950 (save-excursion
1951 (narrow-to-region (rmail-msgbeg rmail-current-message) (point-max))
1952 (let (new-start)
1953 (goto-char (point-min))
1954 (forward-line 1)
1955 ;; Change 1 to 0.
1956 (delete-char 1)
1957 (insert ?0)
1958 ;; Insert new EOOH line at the proper place.
1959 (forward-line 1)
1960 (let ((case-fold-search t))
1961 (while (looking-at "Summary-Line:\\|Mail-From:")
1962 (forward-line 1)))
1963 (insert "*** EOOH ***\n")
1964 (setq new-start (point))
1965 ;; Delete the old reformatted header.
1966 (forward-char -1)
1967 (search-forward "\n*** EOOH ***\n")
1968 (forward-line -1)
1969 (let ((start (point)))
1970 (search-forward "\n\n")
1971 (delete-region start (point)))
1972 ;; Narrow to after the new EOOH line.
1973 (narrow-to-region new-start (point-max)))))
1974
1975(defun rmail-msg-prune-header ()
1976 (save-excursion
1977 (narrow-to-region (rmail-msgbeg rmail-current-message) (point-max))
1978 (rmail-reformat-message (point-min) (point-max))))
1979
1949(defun rmail-toggle-header (&optional arg) 1980(defun rmail-toggle-header (&optional arg)
1950 "Show original message header if pruned header currently shown, or vice versa. 1981 "Show original message header if pruned header currently shown, or vice versa.
1951With argument ARG, show the message header pruned if ARG is greater than zero; 1982With argument ARG, show the message header pruned if ARG is greater than zero;
1952otherwise, show it in full." 1983otherwise, show it in full."
1953 (interactive "P") 1984 (interactive "P")
1954 (switch-to-buffer rmail-buffer) 1985 (let* ((pruned (with-current-buffer rmail-buffer
1955 (let* ((buffer-read-only nil) 1986 (rmail-msg-is-pruned)))
1956 (pruned (rmail-msg-is-pruned))
1957 (prune (if arg 1987 (prune (if arg
1958 (> (prefix-numeric-value arg) 0) 1988 (> (prefix-numeric-value arg) 0)
1959 (not pruned)))) 1989 (not pruned))))
1960 (if (eq pruned prune) 1990 (if (eq pruned prune)
1961 t 1991 t
1992 (set-buffer rmail-buffer)
1962 (rmail-maybe-set-message-counters) 1993 (rmail-maybe-set-message-counters)
1963 (let* ((window (get-buffer-window (current-buffer))) 1994 (if rmail-enable-mime
1964 (at-point-min (= (point) (point-min))) 1995 (let ((buffer-read-only nil))
1965 (all-headers-visible (= (window-start window) (point-min))) 1996 (if pruned
1966 (on-header (save-excursion 1997 (rmail-msg-restore-non-pruned-header)
1967 (and (not (search-backward "\n\n" nil t)) 1998 (rmail-msg-prune-header))
1968 (progn 1999 (funcall rmail-show-mime-function))
1969 (end-of-line) 2000 (let* ((buffer-read-only nil)
1970 (re-search-backward "^[-A-Za-z0-9]+:" nil t)) 2001 (window (get-buffer-window (current-buffer)))
1971 (match-string 0)))) 2002 (at-point-min (= (point) (point-min)))
1972 (old-screen-line 2003 (all-headers-visible (= (window-start window) (point-min)))
1973 (rmail-count-screen-lines (window-start window) (point)))) 2004 (on-header
1974 (save-excursion 2005 (save-excursion
1975 (narrow-to-region (rmail-msgbeg rmail-current-message) (point-max)) 2006 (and (not (search-backward "\n\n" nil t))
2007 (progn
2008 (end-of-line)
2009 (re-search-backward "^[-A-Za-z0-9]+:" nil t))
2010 (match-string 0))))
2011 (old-screen-line
2012 (rmail-count-screen-lines (window-start window) (point))))
1976 (if pruned 2013 (if pruned
1977 (let (new-start) 2014 (rmail-msg-restore-non-pruned-header)
1978 (goto-char (point-min)) 2015 (rmail-msg-prune-header))
1979 (forward-line 1) 2016 (cond (at-point-min
1980 ;; Change 1 to 0. 2017 (goto-char (point-min)))
1981 (delete-char 1) 2018 (on-header
1982 (insert ?0) 2019 (goto-char (point-min))
1983 ;; Insert new EOOH line at the proper place. 2020 (search-forward "\n\n")
1984 (forward-line 1) 2021 (or (re-search-backward
1985 (let ((case-fold-search t)) 2022 (concat "^" (regexp-quote on-header)) nil t)
1986 (while (looking-at "Summary-Line:\\|Mail-From:") 2023 (goto-char (point-min))))
1987 (forward-line 1))) 2024 (t
1988 (insert "*** EOOH ***\n") 2025 (save-selected-window
1989 (setq new-start (point)) 2026 (select-window window)
1990 ;; Delete the old reformatted header. 2027 (recenter old-screen-line)
1991 (forward-char -1) 2028 (if (and all-headers-visible
1992 (search-forward "\n*** EOOH ***\n") 2029 (not (= (window-start) (point-min))))
1993 (forward-line -1) 2030 (let ((lines-offscreen (rmail-count-screen-lines
1994 (let ((start (point))) 2031 (point-min)
1995 (search-forward "\n\n") 2032 (window-start window))))
1996 (delete-region start (point))) 2033 (recenter (min (+ old-screen-line lines-offscreen)
1997 ;; Narrow to after the new EOOH line. 2034 ;; last line of window
1998 (narrow-to-region new-start (point-max))) 2035 (- (window-height) 2))))))))))
1999 (rmail-reformat-message (point-min) (point-max))))
2000 (cond (rmail-enable-mime
2001 (funcall rmail-show-mime-function))
2002 (at-point-min
2003 (goto-char (point-min)))
2004 (on-header
2005 (goto-char (point-min))
2006 (search-forward "\n\n")
2007 (or (re-search-backward (concat "^" (regexp-quote on-header)) nil t)
2008 (goto-char (point-min))))
2009 (t
2010 (save-selected-window
2011 (select-window window)
2012 (recenter old-screen-line)
2013 (if (and all-headers-visible
2014 (not (= (window-start) (point-min))))
2015 (let ((lines-offscreen (rmail-count-screen-lines
2016 (point-min)
2017 (window-start window))))
2018 (recenter (min (+ old-screen-line lines-offscreen)
2019 ;; last line of window
2020 (- (window-height) 2)))))))))
2021 (rmail-highlight-headers)))) 2036 (rmail-highlight-headers))))
2022 2037
2023;; Lifted from repos-count-screen-lines. 2038;; Lifted from repos-count-screen-lines.