Subject: Re: bug#36697: 27.0.50; gnus: some articles with score 0 are killed

From: Sam Steingold <[email-masked]>
Date: Thu, 23 Jul 2020 16:04:35 -0400

> * Lars Ingebrigtsen <[email-masked]> [2020-07-23 15:56:08 +0200]:
>
> Sam Steingold <[email-masked]> writes:
>
>> If you tell me something like "function foo should return A in your
>> case, figure out why it returns B", I am more than willing to debug.
>
> The scoring that the "Y-" stuff is coming from is done in the
> `gnus-score-headers' function.

Thanks.
Here is my investigation:

`*Headers*` buffer:
--8<---------------cut here---------------start------------->8---
Цитата #462135
Цитата #462136
Цитата #462137
Цитата #462138
--8<---------------cut here---------------end--------------->8---

Here is the score rule:

--8<---------------cut here---------------start------------->8---
(("subject"
  ;; many non-lower-case chars is a bad sign
  ("[^a-z]\\{50\\}" -100 nil R)
  ("[^a-z]\\{100\\}" -300 nil R)
  ("[^a-z]\\{150\\}" -1000 nil R)
 ...))
--8<---------------cut here---------------end--------------->8---

`gnus-score-string' is called from `gnus-score-headers',
`search-func` is `re-search-backward'
It is called on line 2148 on `match' which is "[^a-z]\\{50\\}".
So, it matches for _all_ subjects - _before_ the last 3 - because it
searches _across_ lines!

So, the problem is that search-func is applied to the whole *Headers*
instead of it being narrowed to the current subject.

In fact, if would seem to make sense to pass a list of headers instead
of using a buffer and then narrowing to each string in that buffer.
I can probably fix it along these lines - unless you would prefer to do
it yourself.

Thank you very much for your patience and help!

PS. The code in gnus-score.el seems to avoid modern Emacs-Lisp features
like `dolist' and `when'.  Is there a (non-historical) reason for that?
Also, the functions are very long and thus hard to edebug.
I had to extract some loops into separate functions to speed up stepping.
Is it okay to commit?

-- 
Sam Steingold (http://sds.podval.org/) on darwin Ns 10.3.1894
http://childpsy.net http://calmchildstories.com http://steingoldpsychology.com
https://thereligionofpeace.com https://camera.org https://iris.org.il
If I had a $ for every time I was rejected, I would no longer be rejected.