changeset 67469:b845fff9455c

(rmail-next-same-subject): Handle multiple "Re: " strings and long subject lines that were broken into multiple lines at arbitrary places.
author Eli Zaretskii <eliz@gnu.org>
date Sat, 10 Dec 2005 11:29:53 +0000
parents 4d92860b8e50
children 98e70ddf4e0e
files lisp/mail/rmail.el
diffstat 1 files changed, 9 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/mail/rmail.el	Sat Dec 10 10:29:22 2005 +0000
+++ b/lisp/mail/rmail.el	Sat Dec 10 11:29:53 2005 +0000
@@ -3155,13 +3155,18 @@
 	search-regexp found)
     (if (string-match "\\`[ \t]+" subject)
 	(setq subject (substring subject (match-end 0))))
-    (if (string-match "Re:[ \t]*" subject)
+    (if (string-match "\\`\\(Re:[ \t]*\\)+" subject)
 	(setq subject (substring subject (match-end 0))))
     (if (string-match "[ \t]+\\'" subject)
 	(setq subject (substring subject 0 (match-beginning 0))))
-    (setq search-regexp (concat "^Subject: *\\(Re:[ \t]*\\)?"
-				(regexp-quote subject)
-				"[ \t]*\n"))
+    ;; If Subject is long, mailers will break it into several lines at
+    ;; arbitrary places, so replace whitespace with a regexp that will
+    ;; match any sequence of spaces, TABs, and newlines.
+    (setq subject (regexp-quote subject))
+    (setq subject
+	  (replace-regexp-in-string "[ \t\n]+" "[ \t\n]+" subject t t))
+    (setq search-regexp (concat "^Subject: *\\(Re:[ \t]*\\)*"
+				subject "[ \t]*\n"))
     (save-excursion
       (save-restriction
 	(widen)