[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 3521efc 1/2: Improve Rmail Subject normalization wh
From: |
Eli Zaretskii |
Subject: |
[Emacs-diffs] master 3521efc 1/2: Improve Rmail Subject normalization when replying |
Date: |
Fri, 22 Dec 2017 08:50:03 -0500 (EST) |
branch: master
commit 3521efce1a9c3094e9911445a7db23f87cd3e5f4
Author: Francesco Potortì <address@hidden>
Commit: Eli Zaretskii <address@hidden>
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)
---
lisp/mail/rmail.el | 22 ++++++++--------------
1 file changed, 8 insertions(+), 14 deletions(-)
diff --git a/lisp/mail/rmail.el b/lisp/mail/rmail.el
index 994570e..c32f000 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."
(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,
-and typical reply prefixes such as Re:."
- (let ((subject (or (rmail-get-header "Subject" msgnum) "")))
+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,3\\}:\\|\\[[^]]+]\\)[ \t\n]+\\)*"))
(setq subject (rfc2047-decode-string subject))
- (if (string-match "\\`[ \t]+" subject)
- (setq subject (substring subject (match-end 0))))
- (if (string-match rmail-reply-regexp subject)
- (setq subject (substring subject (match-end 0))))
- (if (string-match "[ \t]+\\'" subject)
- (setq subject (substring subject 0 (match-beginning 0))))
- ;; If Subject is long, mailers will break it into several lines at
- ;; arbitrary places, so normalize whitespace by replacing every
- ;; run of whitespace characters with a single space.
- (setq subject (replace-regexp-in-string "[ \t\n]+" " " subject))
- subject))
+ (setq subject (replace-regexp-in-string regexp "" subject))
+ (replace-regexp-in-string "[ \t\n]+" " " subject)))
(defun rmail-simplified-subject-regexp ()
"Return a regular expression matching the current simplified subject.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master 3521efc 1/2: Improve Rmail Subject normalization when replying,
Eli Zaretskii <=