Commit 80068231 authored by Alex Schroeder's avatar Alex Schroeder
Browse files

(rmail-current-subject): New function.

(rmail-current-subject-regexp): New function.
(rmail-next-same-subject): Use it.
parent 7d897818
...@@ -11,6 +11,14 @@ ...@@ -11,6 +11,14 @@
   
2006-01-07 Alex Schroeder <alex@gnu.org> 2006-01-07 Alex Schroeder <alex@gnu.org>
   
* mail/rmail.el (rmail-current-subject): New function.
(rmail-current-subject-regexp): New function.
(rmail-next-same-subject): Use it.
* mail/rmailsum.el (rmail-summary-by-topic): Use
rmail-current-subject and rmail-current-subject-regexp.
(rmail-summary-next-same-subject): Ditto.
* net/rcirc.el (rcirc-send-input): No longer check whether the * net/rcirc.el (rcirc-send-input): No longer check whether the
process is open, since not all commands need an open process. process is open, since not all commands need an open process.
(rcirc-send-string): Check whether the process is open before (rcirc-send-string): Check whether the process is open before
......
...@@ -3143,30 +3143,52 @@ Interactively, empty argument means use same regexp used last time." ...@@ -3143,30 +3143,52 @@ Interactively, empty argument means use same regexp used last time."
;; (rmail-show-message found)) ;; (rmail-show-message found))
found)) found))
(defun rmail-next-same-subject (n) (defun rmail-current-subject ()
"Go to the next mail message having the same subject header. "Return the current subject.
With prefix argument N, do this N times. The subject is stripped of leading and trailing whitespace, and
If N is negative, go backwards instead." of typical reply prefixes such as Re:."
(interactive "p") (let ((subject (or (mail-fetch-field "Subject") "")))
(let ((subject (mail-fetch-field "Subject"))
(forward (> n 0))
(i rmail-current-message)
(case-fold-search t)
search-regexp found)
(if (string-match "\\`[ \t]+" subject) (if (string-match "\\`[ \t]+" subject)
(setq subject (substring subject (match-end 0)))) (setq subject (substring subject (match-end 0))))
(if (string-match "\\`\\(Re:[ \t]*\\)+" subject) (if (string-match rmail-reply-regexp subject)
(setq subject (substring subject (match-end 0)))) (setq subject (substring subject (match-end 0))))
(if (string-match "[ \t]+\\'" subject) (if (string-match "[ \t]+\\'" subject)
(setq subject (substring subject 0 (match-beginning 0)))) (setq subject (substring subject 0 (match-beginning 0))))
subject))
(defun rmail-current-subject-regexp ()
"Return a regular expression matching the current subject.
The regular expression matches the subject header line of
messages about the same subject. The subject itself is stripped
of leading and trailing whitespace, of typical reply prefixes
such as Re: and whitespace within the subject is replaced by a
regular expression matching whitespace in general in order to
take into account that subject header lines may include newlines
and more whitespace. The returned regular expressions contains
`rmail-reply-regexp' and ends with a newline."
(let ((subject (rmail-current-subject)))
;; If Subject is long, mailers will break it into several lines at ;; If Subject is long, mailers will break it into several lines at
;; arbitrary places, so replace whitespace with a regexp that will ;; arbitrary places, so replace whitespace with a regexp that will
;; match any sequence of spaces, TABs, and newlines. ;; match any sequence of spaces, TABs, and newlines.
(setq subject (regexp-quote subject)) (setq subject (regexp-quote subject))
(setq subject (setq subject
(replace-regexp-in-string "[ \t\n]+" "[ \t\n]+" subject t t)) (replace-regexp-in-string "[ \t\n]+" "[ \t\n]+" subject t t))
(setq search-regexp (concat "^Subject: *\\(Re:[ \t]*\\)*" (concat "^Subject: "
subject "[ \t]*\n")) (if (string= "\\`" (substring rmail-reply-regexp 0 2))
(substring rmail-reply-regexp 2)
rmail-reply-regexp)
subject "[ \t]*\n")))
(defun rmail-next-same-subject (n)
"Go to the next mail message having the same subject header.
With prefix argument N, do this N times.
If N is negative, go backwards instead."
(interactive "p")
(let ((search-regexp (rmail-current-subject-regexp))
(forward (> n 0))
(i rmail-current-message)
(case-fold-search t)
found)
(save-excursion (save-excursion
(save-restriction (save-restriction
(widen) (widen)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment