unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#29659: 25.2; better rmail-summary-by-topic
@ 2017-12-11 12:28 Francesco Potortì
  2017-12-11 15:35 ` Eli Zaretskii
  2018-01-24 12:00 ` bug#29659: Fwd: " Francesco Potortì
  0 siblings, 2 replies; 10+ messages in thread
From: Francesco Potortì @ 2017-12-11 12:28 UTC (permalink / raw)
  To: 29659

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





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#29659: 25.2; better rmail-summary-by-topic
  2017-12-11 12:28 bug#29659: 25.2; better rmail-summary-by-topic Francesco Potortì
@ 2017-12-11 15:35 ` Eli Zaretskii
  2017-12-11 15:50   ` Francesco Potortì
  2018-01-24 12:00 ` bug#29659: Fwd: " Francesco Potortì
  1 sibling, 1 reply; 10+ messages in thread
From: Eli Zaretskii @ 2017-12-11 15:35 UTC (permalink / raw)
  To: Francesco Potortì; +Cc: 29659

> Date: Mon, 11 Dec 2017 13:28:12 +0100
> From: Francesco Potortì <pot@gnu.org>
> 
> 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?

Thanks.





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#29659: 25.2; better rmail-summary-by-topic
  2017-12-11 15:35 ` Eli Zaretskii
@ 2017-12-11 15:50   ` Francesco Potortì
  2017-12-11 17:37     ` Eli Zaretskii
  0 siblings, 1 reply; 10+ messages in thread
From: Francesco Potortì @ 2017-12-11 15:50 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 29659

>> Date: Mon, 11 Dec 2017 13:28:12 +0100
>> From: Francesco Potortì <pot@gnu.org>
>> 
>> 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))





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#29659: 25.2; better rmail-summary-by-topic
  2017-12-11 15:50   ` Francesco Potortì
@ 2017-12-11 17:37     ` Eli Zaretskii
  2017-12-11 17:47       ` Francesco Potortì
  0 siblings, 1 reply; 10+ messages in thread
From: Eli Zaretskii @ 2017-12-11 17:37 UTC (permalink / raw)
  To: Francesco Potortì; +Cc: 29659

> Date: Mon, 11 Dec 2017 16:50:14 +0100
> From: Francesco Potortì <pot@gnu.org>
> Cc: 29659@debbugs.gnu.org
> 
> >> 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.

So you are saying that we need to convert an 'if' to a 'while', and
then Bob'll be our uncle?





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#29659: 25.2; better rmail-summary-by-topic
  2017-12-11 17:37     ` Eli Zaretskii
@ 2017-12-11 17:47       ` Francesco Potortì
  2017-12-11 18:08         ` Eli Zaretskii
  0 siblings, 1 reply; 10+ messages in thread
From: Francesco Potortì @ 2017-12-11 17:47 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 29659

>
>> Date: Mon, 11 Dec 2017 16:50:14 +0100
>> From: Francesco Potortì <pot@gnu.org>
>> Cc: 29659@debbugs.gnu.org
>> 
>> >> 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.
>
>So you are saying that we need to convert an 'if' to a 'while', and
>then Bob'll be our uncle?

It's simpler than that: just use the RE that I used in my advice rather
than the 'if' series that's in rmail-simplified-subject.

I can test and provide a patch, if someone is interested in installing it.





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#29659: 25.2; better rmail-summary-by-topic
  2017-12-11 17:47       ` Francesco Potortì
@ 2017-12-11 18:08         ` Eli Zaretskii
  2017-12-12 17:49           ` Francesco Potortì
  0 siblings, 1 reply; 10+ messages in thread
From: Eli Zaretskii @ 2017-12-11 18:08 UTC (permalink / raw)
  To: Francesco Potortì; +Cc: 29659

> Date: Mon, 11 Dec 2017 18:47:47 +0100
> From: Francesco Potortì <pot@gnu.org>
> Cc: 29659@debbugs.gnu.org
> 
> It's simpler than that: just use the RE that I used in my advice rather
> than the 'if' series that's in rmail-simplified-subject.
> 
> I can test and provide a patch, if someone is interested in installing it.

Please do.  I use Rmail all the time, and am interested in improving
it.

Thanks.





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#29659: 25.2; better rmail-summary-by-topic
  2017-12-11 18:08         ` Eli Zaretskii
@ 2017-12-12 17:49           ` Francesco Potortì
  2017-12-22 13:50             ` Eli Zaretskii
  0 siblings, 1 reply; 10+ messages in thread
From: Francesco Potortì @ 2017-12-12 17:49 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 29659

This is my current attempt, seems to work, please give it a try.

(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, 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))
    (setq subject (replace-regexp-in-string regexp "" subject))
    (replace-regexp-in-string "[ \t\n]+" " " subject)))





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#29659: 25.2; better rmail-summary-by-topic
  2017-12-12 17:49           ` Francesco Potortì
@ 2017-12-22 13:50             ` Eli Zaretskii
  0 siblings, 0 replies; 10+ messages in thread
From: Eli Zaretskii @ 2017-12-22 13:50 UTC (permalink / raw)
  To: Francesco Potortì; +Cc: 29659-done

> Date: Tue, 12 Dec 2017 18:49:20 +0100
> From: Francesco Potortì <pot@gnu.org>
> Cc: 29659@debbugs.gnu.org
> 
> This is my current attempt, seems to work, please give it a try.

Thanks, pushed to the master branch.





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#29659: Fwd: Re: bug#29659: 25.2; better rmail-summary-by-topic
  2017-12-11 12:28 bug#29659: 25.2; better rmail-summary-by-topic Francesco Potortì
  2017-12-11 15:35 ` Eli Zaretskii
@ 2018-01-24 12:00 ` Francesco Potortì
  2018-01-26 14:12   ` Eli Zaretskii
  1 sibling, 1 reply; 10+ messages in thread
From: Francesco Potortì @ 2018-01-24 12:00 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 29659

(resending after reopening the bug)

There is an obvious error in the following code, which for some reason
did work for me but works no more after an Emacs restart.

The regexp variable should start with a double backslash:
	(regexp "\\`[ \t\n]*\\(\\(\\w\\{1,3\\}:\\|\\[[^]]+]\\)[ \t\n]+\\)*"))

rather than
	(regexp "\`[ \t\n]*\\(\\(\\w\\{1,3\\}:\\|\\[[^]]+]\\)[ \t\n]+\\)*"))


------- Start of forwarded message -------
From: "Francesco Potortì" <pot@gnu.org>
Date: Tue, 12 Dec 2017 18:49:20 +0100
To: Eli Zaretskii <eliz@gnu.org>
CC: 29659@debbugs.gnu.org
In-reply-to: <83o9n5rvco.fsf@gnu.org> (eliz@gnu.org)
Subject: Re: bug#29659: 25.2; better rmail-summary-by-topic

This is my current attempt, seems to work, please give it a try.

(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, 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))
    (setq subject (replace-regexp-in-string regexp "" subject))
    (replace-regexp-in-string "[ \t\n]+" " " subject)))
------- End of forwarded message -------





^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#29659: Fwd: Re: bug#29659: 25.2; better rmail-summary-by-topic
  2018-01-24 12:00 ` bug#29659: Fwd: " Francesco Potortì
@ 2018-01-26 14:12   ` Eli Zaretskii
  0 siblings, 0 replies; 10+ messages in thread
From: Eli Zaretskii @ 2018-01-26 14:12 UTC (permalink / raw)
  To: Francesco Potortì; +Cc: 29659-done

> Date: Wed, 24 Jan 2018 13:00:59 +0100
> From: Francesco Potortì <pot@gnu.org>
> Cc: 29659@debbugs.gnu.org
> 
> (resending after reopening the bug)
> 
> There is an obvious error in the following code, which for some reason
> did work for me but works no more after an Emacs restart.
> 
> The regexp variable should start with a double backslash:
> 	(regexp "\\`[ \t\n]*\\(\\(\\w\\{1,3\\}:\\|\\[[^]]+]\\)[ \t\n]+\\)*"))
> 
> rather than
> 	(regexp "\`[ \t\n]*\\(\\(\\w\\{1,3\\}:\\|\\[[^]]+]\\)[ \t\n]+\\)*"))

Thanks, fixed.





^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2018-01-26 14:12 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-11 12:28 bug#29659: 25.2; better rmail-summary-by-topic Francesco Potortì
2017-12-11 15:35 ` Eli Zaretskii
2017-12-11 15:50   ` Francesco Potortì
2017-12-11 17:37     ` Eli Zaretskii
2017-12-11 17:47       ` Francesco Potortì
2017-12-11 18:08         ` Eli Zaretskii
2017-12-12 17:49           ` Francesco Potortì
2017-12-22 13:50             ` Eli Zaretskii
2018-01-24 12:00 ` bug#29659: Fwd: " Francesco Potortì
2018-01-26 14:12   ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).