bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#29659: 25.2; better rmail-summary-by-topic


From: Francesco Potortì
Subject: bug#29659: 25.2; better rmail-summary-by-topic
Date: Mon, 11 Dec 2017 16:50:14 +0100

>> Date: Mon, 11 Dec 2017 13:28:12 +0100
>> From: Francesco Potortì <address@hidden>
>> 
>> rmail-summary-by-topic functionality can be easily improved by this
>> piece of advice:
>> 
>> (defun rmail-simplified-subject--strip-all (subject)
>>   "Strip all prefixes like Re:, Fwd: and similar ones"
>>   (let ((search-spaces-regexp "[ \t\n]"))
>>     (string-match " *\\(\\(\\w\\{1,3\\}:\\|\\[.+]\\) +\\)*" subject)
>>     (replace-match "" t t subject))
>>   )
>> (advice-add 'rmail-simplified-subject :filter-return 
>> #'rmail-simplified-subject--strip-all)
>> 
>> 
>> Maybe this can be simply incorporated into rmail-simplified-subject: it
>> is able to remove prefixes like
>> 
>> Re: [Topic] Fwd: Re: Fwd:
>> 
>> and in practice I find it very useful

>Indeed, and so I wonder why did you need the advice?  Which prefixes
>does rmail-simplified-subject not handle correctly?

It is much more primitive, it only removes a single Re: prefix.  This
means that repeated prefixes and localised prefixes are left as they
are, as you can see:

(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) "")))
    (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))





reply via email to

[Prev in Thread] Current Thread [Next in Thread]