Function: rmail-header-summary
rmail-header-summary is a byte-compiled function defined in
rmailsum.el.gz.
Signature
(rmail-header-summary)
Documentation
Return a message summary based on the message headers.
The value is a list of two strings, the first and second parts of the summary.
The current buffer must already be narrowed to the message headers for the message being processed.
Source Code
;; Defined in /usr/src/emacs/lisp/mail/rmailsum.el.gz
(defun rmail-header-summary ()
"Return a message summary based on the message headers.
The value is a list of two strings, the first and second parts of the summary.
The current buffer must already be narrowed to the message headers for
the message being processed."
(goto-char (point-min))
(list
(concat (save-excursion
(if (not (re-search-forward "^Date:" nil t))
" "
;; Match month names case-insensitively
(cond ((let ((case-fold-search t))
(re-search-forward "\\([^0-9:]\\)\\([0-3]?[0-9]\\)\\([- \t_]+\\)\\([adfjmnos][aceopu][bcglnprtvy]\\)"
(line-end-position) t))
(format "%2d-%3s"
(string-to-number (buffer-substring
(match-beginning 2)
(match-end 2)))
(buffer-substring
(match-beginning 4) (match-end 4))))
((let ((case-fold-search t))
(re-search-forward "\\([^a-z]\\)\\([adfjmnos][acepou][bcglnprtvy]\\)\\([-a-z \t_]*\\)\\([0-9][0-9]?\\)"
(line-end-position) t))
(format "%2d-%3s"
(string-to-number (buffer-substring
(match-beginning 4)
(match-end 4)))
(buffer-substring
(match-beginning 2) (match-end 2))))
((re-search-forward "\\(19\\|20\\)\\([0-9][0-9]\\)-\\([01][0-9]\\)-\\([0-3][0-9]\\)"
(line-end-position) t)
(format "%2s%2s%2s"
(buffer-substring
(match-beginning 2) (match-end 2))
(buffer-substring
(match-beginning 3) (match-end 3))
(buffer-substring
(match-beginning 4) (match-end 4))))
(t "??????"))))
" "
(save-excursion
(let* ((from (and (re-search-forward "^From:[ \t]*" nil t)
(mail-strip-quoted-names
(buffer-substring
(1- (point))
;; Get all the lines of the From field
;; so that we get a whole comment if there is one,
;; so that mail-strip-quoted-names can discard it.
(progn
(while (progn (forward-line 1)
(looking-at "[ \t]")))
;; Back up over newline, then trailing spaces or tabs
(forward-char -1)
(skip-chars-backward " \t")
(point))))))
len mch lo newline)
;; If there are multiple lines in FROM,
;; discard up to the last newline in it.
(while (and (stringp from)
(setq newline (string-search "\n" from)))
(setq from (substring from (1+ newline))))
(if (or (null from)
(string-match
(or rmail-user-mail-address-regexp
(concat "^\\("
(regexp-quote (user-login-name))
"\\($\\|@\\)\\|"
(regexp-quote user-mail-address)
"\\>\\)"))
from))
;; No From field, or it's this user.
(save-excursion
(goto-char (point-min))
(if (not (re-search-forward "^To:[ \t]*" nil t))
nil
(setq from
(concat "to: "
(mail-strip-quoted-names
(buffer-substring
(point)
(progn (end-of-line)
(skip-chars-backward " \t")
(point)))))))))
(if (null from)
" "
;; We are going to return only 25 characters of the
;; address, so make sure it is RFC2047 decoded before
;; taking its substring. This is important when the address is not on the same line as the name, e.g.:
;; To: =?UTF-8?Q?=C5=A0t=C4=9Bp=C3=A1n_?= =?UTF-8?Q?N=C4=9Bmec?=
;; <stepnem@gmail.com>
(setq from (rfc2047-decode-string from))
;; We cannot tolerate any leftover newlines in From,
;; as that disrupts the rmail-summary display.
;; Newlines can be left in From if it was malformed,
;; e.g. had unbalanced quotes.
(setq from (replace-regexp-in-string "\n+" " " from))
(setq len (length from))
(setq mch (string-match "[@%]" from))
(format "%25s"
(if (or (not mch) (<= len 25))
(substring from (max 0 (- len 25)))
(substring from
(setq lo (cond ((< (- mch 14) 0) 0)
((< len (+ mch 11))
(- len 25))
(t (- mch 14))))
(min len (+ lo 25)))))))))
(concat (if (re-search-forward "^Subject:" nil t)
(let (pos str)
(skip-chars-forward " \t")
(setq pos (point))
(forward-line 1)
(setq str (buffer-substring pos (1- (point))))
(while (looking-at "[ \t]")
(setq str (concat str " "
(buffer-substring (match-end 0)
(line-end-position))))
(forward-line 1))
str)
(re-search-forward "[\n][\n]+" nil t)
(buffer-substring (point) (progn (end-of-line) (point))))
"\n")))