Subject: bug#33653: 27.0.50; Change Gnus obarrays-as-hash-tables into real hash tables

From: Eric Abrahamsen <[email-masked]>
Date: Tue, 26 Mar 2019 12:49:08 -0700

Andy Moreton <[email-masked]> writes:

> On Sat 23 Mar 2019, Andy Moreton wrote:
>
>> On Fri 22 Mar 2019, Eric Abrahamsen wrote:
>>
>>> Eli Zaretskii <[email-masked]> writes:
>>>
>>>>> From: Eric Abrahamsen <[email-masked]>
>>>>> Date: Fri, 22 Mar 2019 12:54:54 -0700
>>>>> 
>>>>> is there anything to be done besides warning people on the mailing
>>>>> lists?
>>>>
>>>> A warning would be nice, yes.
>>>
>>> Okay, I'll do that. I've already gotten a bug report :(
>>
>> After bootstrapping, I observe that the summary buffer does not update
>> the faces correctly for nntp articles that have been read: they still
>> have an unread face.
>
> After more debugging, I have found the problem.
>
> Updating summary lines is handled in `gnus-summary-insert-line':
>     (condition-case ()
> 	(put-text-property
> 	 (point)
> 	 (progn (eval gnus-summary-line-format-spec) (point))
> 	 'gnus-number gnus-tmp-number)
>       (error (gnus-message 5 "Error updating the summary line")))
>
> In my setup, `gnus-summary-line-format' used starts with "%U%R%u&score;"
> to use a user format function for printing score info. That results in
> calls to my user function to display summary lines:
>
>   (defun gnus-user-format-function-score (header)
>     (let* ((article (mail-header-number header))
>            (thread  (gnus-id-to-thread (mail-header-id header)))
>            ...
>
> This now fails because `gnus-id-to-thread' sometimes throws an error,
> because `gnus-newsgroup-dependencies' is nil when it is called. This
> usage worked in emacs-26 and in master before your changes.
>
> I've fixed this in my user format function with:
>
>   (defun gnus-user-format-function-score (header)
>     (let* ((article (mail-header-number header))
>            (thread  (and gnus-newsgroup-dependencies
>                          (gnus-id-to-thread (mail-header-id header))))
>            ...
>
> After that change, the marks are displayed correctly in the summary
> buffer. I'm not sure if that is something that only worked by chance in
> old code, or if it is a regression, but it is a change of behaviour.

Yes, the format spec is eval'ed twice (to set summary buffer positions)
before the threads are actually built, and `gnus-newsgroup-dependencies'
is nil at that point. Back when this was a call to `intern', it would
just silently return nil, now it errors. Your fix works, but I could
also have `gnus-id-to-thread' return nil if
`gnus-newsgroup-dependencies' is nil. That would mimic Gnus' previous
behavior.

Thanks,
Eric