Function: rmail-simplified-subject

rmail-simplified-subject is a byte-compiled function defined in rmail.el.gz.

Signature

(rmail-simplified-subject &optional MSGNUM)

Documentation

Return the simplified subject of message MSGNUM (or current message).

Simplifying the subject means stripping leading and trailing whitespace, replacing whitespace runs with a single space and removing prefixes such as Re:, Fwd: and so on and mailing list tags such as [tag].

Source Code

;; Defined in /usr/src/emacs/lisp/mail/rmail.el.gz
(defun rmail-simplified-subject (&optional msgnum)
  "Return the simplified subject of message MSGNUM (or current message).
Simplifying the subject means stripping leading and trailing
whitespace, replacing whitespace runs with a single space and
removing prefixes such as Re:, Fwd: and so on and mailing list
tags such as [tag]."
  (let ((subject (or (rmail-get-header "Subject" msgnum) ""))
	(regexp "\\`[ \t\n]*\\(\\(\\w\\{1,4\\}\u00a0*[::]\\|\\[[^]]+]\\)[ \t\n]+\\)*"))
    (setq subject (rfc2047-decode-string subject))
    ;; Corporate mailing systems sometimes add `[External] :'; if that happened,
    ;; delete everything up thru there.  Empirically, that deletion makes
    ;; the Subject match the other messages in the thread.
    (if (string-match "\\[external][ \t\n]*:" subject)
        (setq subject (substring subject (match-end 0))))
    (setq subject (replace-regexp-in-string regexp "" subject))
    (replace-regexp-in-string "[ \t\n]+" " " subject)))