aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrancesco Potortì2017-12-22 15:48:19 +0200
committerEli Zaretskii2017-12-22 15:48:19 +0200
commit3521efce1a9c3094e9911445a7db23f87cd3e5f4 (patch)
tree574bb846c1bc12ebd0ec7c3d22383cc11b93b8a8
parente92f5537a8222187525ef5066dba051211db5290 (diff)
downloademacs-3521efce1a9c3094e9911445a7db23f87cd3e5f4.tar.gz
emacs-3521efce1a9c3094e9911445a7db23f87cd3e5f4.zip
Improve Rmail Subject normalization when replying
* lisp/mail/rmail.el (rmail-simplified-subject): A more thorough implementation which removes more prefixes from Subject. (Bug#29659)
-rw-r--r--lisp/mail/rmail.el22
1 files changed, 8 insertions, 14 deletions
diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el
index 994570edcb2..c32f000d306 100644
--- a/lisp/mail/rmail.el
+++ b/lisp/mail/rmail.el
@@ -3399,21 +3399,15 @@ Interactively, empty argument means use same regexp used last time."
3399 3399
3400(defun rmail-simplified-subject (&optional msgnum) 3400(defun rmail-simplified-subject (&optional msgnum)
3401 "Return the simplified subject of message MSGNUM (or current message). 3401 "Return the simplified subject of message MSGNUM (or current message).
3402Simplifying the subject means stripping leading and trailing whitespace, 3402Simplifying the subject means stripping leading and trailing
3403and typical reply prefixes such as Re:." 3403whitespace, replacing whitespace runs with a single space and
3404 (let ((subject (or (rmail-get-header "Subject" msgnum) ""))) 3404removing prefixes such as Re:, Fwd: and so on and mailing list
3405tags such as [tag]."
3406 (let ((subject (or (rmail-get-header "Subject" msgnum) ""))
3407 (regexp "\`[ \t\n]*\\(\\(\\w\\{1,3\\}:\\|\\[[^]]+]\\)[ \t\n]+\\)*"))
3405 (setq subject (rfc2047-decode-string subject)) 3408 (setq subject (rfc2047-decode-string subject))
3406 (if (string-match "\\`[ \t]+" subject) 3409 (setq subject (replace-regexp-in-string regexp "" subject))
3407 (setq subject (substring subject (match-end 0)))) 3410 (replace-regexp-in-string "[ \t\n]+" " " subject)))
3408 (if (string-match rmail-reply-regexp subject)
3409 (setq subject (substring subject (match-end 0))))
3410 (if (string-match "[ \t]+\\'" subject)
3411 (setq subject (substring subject 0 (match-beginning 0))))
3412 ;; If Subject is long, mailers will break it into several lines at
3413 ;; arbitrary places, so normalize whitespace by replacing every
3414 ;; run of whitespace characters with a single space.
3415 (setq subject (replace-regexp-in-string "[ \t\n]+" " " subject))
3416 subject))
3417 3411
3418(defun rmail-simplified-subject-regexp () 3412(defun rmail-simplified-subject-regexp ()
3419 "Return a regular expression matching the current simplified subject. 3413 "Return a regular expression matching the current simplified subject.