Gnus development mailing list
 help / color / mirror / Atom feed
* Re: bug#54423: 29.0.50; gnus-fetch-original-field returns nil in digest
       [not found]       ` <87k0cssiaw.fsf@gnus.org>
@ 2022-03-22  0:04         ` Sam Steingold
  2022-03-22 16:49           ` Roland Winkler
  0 siblings, 1 reply; 4+ messages in thread
From: Sam Steingold @ 2022-03-22  0:04 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 54423, ding, bbdb-user

Context (see https://debbugs.gnu.org/cgi/bugreport.cgi?bug=54423):
`bbdb-message-header' calls `gnus-fetch-original-field' which,
for a digest ("nndoc") group, returns nil for every header.

The root of the problem is that `gnus-fetch-original-field' relies on
`gnus-original-article-buffer' which is buffer-local:

--8<---------------cut here---------------start------------->8---
gnus-original-article-buffer is a variable defined in ‘gnus.el’.

Its value is
" *Original Article nndoc:gmane.comp.security.risks-1023*"
Local in buffer *Summary nndoc:gmane.comp.security.risks-1023*; global value is the same.
--8<---------------cut here---------------end--------------->8---

(buffer " *Original Article nndoc:gmane.comp.security.risks-1023*" is _empty_!)
and at the _same_ time (no gnus command executed, just a buffer switch):

--8<---------------cut here---------------start------------->8---
gnus-original-article-buffer is a variable defined in ‘gnus.el’.

Its value is " *Original Article gmane.comp.security.risks*"
Local in buffer *Summary gmane.comp.security.risks*; global value is the same.
--8<---------------cut here---------------end--------------->8---

Lars suggested that I use this:

--8<---------------cut here---------------start------------->8---
(gnus-info-params (gnus-get-info gnus-newsgroup-name))
--8<---------------cut here---------------end--------------->8---

and it appears that the following works:

--8<---------------cut here---------------start------------->8---
diff --git a/lisp/bbdb-mua.el b/lisp/bbdb-mua.el
index f9d141d..ab3863c 100644
--- a/lisp/bbdb-mua.el
+++ b/lisp/bbdb-mua.el
@@ -111,7 +111,17 @@ MIME encoded headers are decoded.  Return nil if HEADER does not exist."
                      ;; `bbdb-select-message' does not get fooled by an apparent
                      ;; absence of some headers.
                      ;; See http://permalink.gmane.org/gmane.emacs.gnus.general/78741
-                     (eq mua 'gnus) (gnus-fetch-original-field header))
+                     (eq mua 'gnus)
+                     (or (gnus-fetch-original-field header)
+                         ;; See https://debbugs.gnu.org/cgi/bugreport.cgi?bug=54423
+                         ;; 'gnus-fetch-original-field' returns nil in nndoc groups
+                         ;; (digests) because the 'qgnus-original-article-buffer' is
+                         ;; empty for the nndoc summary but not for the parent summary.
+                         (and-let* ((i (gnus-get-info gnus-newsgroup-name))
+                                    (p (gnus-info-params i))
+                                    (parent-summary-buffer (cadr (assq 'quit-config p))))
+                           (with-current-buffer parent-summary-buffer
+                             (gnus-fetch-original-field header)))))
                     ((eq mua 'vm) (bbdb/vm-header header))
                     ((eq mua 'rmail)
                      (with-current-buffer rmail-buffer
--8<---------------cut here---------------end--------------->8---

`quit-config' contains the parent summary buffer object.
I would rather use that directly that construct the string
" *Original Article gmane.comp.security.risks*"
(especially since the relevant logic in `gnus-article-setup-buffer' is
moderately convoluted).

The question is whether this is TRT or there is a better way.

Thanks to Lars for his patience, and to everyone else for possible
suggestion.

-- 
Sam Steingold (http://sds.podval.org/) on darwin Ns 10.3.2113
http://childpsy.net http://calmchildstories.com http://steingoldpsychology.com
https://honestreporting.com https://camera.org http://think-israel.org
Money does not bother me at all.  In fact, it calms me down.


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

* Re: bug#54423: 29.0.50; gnus-fetch-original-field returns nil in digest
  2022-03-22  0:04         ` bug#54423: 29.0.50; gnus-fetch-original-field returns nil in digest Sam Steingold
@ 2022-03-22 16:49           ` Roland Winkler
       [not found]             ` <lzbkxxj4nq.fsf@3c22fb11fdab.ant.amazon.com>
  0 siblings, 1 reply; 4+ messages in thread
From: Roland Winkler @ 2022-03-22 16:49 UTC (permalink / raw)
  To: Sam Steingold; +Cc: 54423, ding, bbdb-user, Lars Ingebrigtsen

On Mon, Mar 21 2022, Sam Steingold wrote:
> Lars suggested that I use this:
>
> (gnus-info-params (gnus-get-info gnus-newsgroup-name))
>
> and it appears that the following works:
>
[snip]
> +          (and-let* ((i (gnus-get-info gnus-newsgroup-name))
> +                     (p (gnus-info-params i))
> +                     (parent-summary-buffer (cadr (assq 'quit-config p))))
> +            (with-current-buffer parent-summary-buffer
> +              (gnus-fetch-original-field header)))))

...Is the (and-let*... needed?  Of course, one could wrap all code that
way.  But and-let* is not even part of Emacs 25 that current BBDB is
supposed to support.  Also, if the above code should fail in certain
cases, it might be an indication that the above code is not yet exactly
what is needed so that this should not be swept under the carpet.  So I
feel that
 
  (with-current-buffer (cadr (assq 'quit-config
                                   (gnus-info-params
                                    (gnus-get-info gnus-newsgroup-name))))

is the better way to go.  Am I missing something?

Or: If the corner cases when the code can still fail are known and the
failure is in that sense intentional, this should be made more explicit
in the code.


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

* Re: bug#54423: 29.0.50; gnus-fetch-original-field returns nil in digest
       [not found]             ` <lzbkxxj4nq.fsf@3c22fb11fdab.ant.amazon.com>
@ 2022-03-22 17:27               ` Roland Winkler
  2022-03-22 18:06                 ` Sam Steingold
  0 siblings, 1 reply; 4+ messages in thread
From: Roland Winkler @ 2022-03-22 17:27 UTC (permalink / raw)
  To: Sam Steingold; +Cc: bbdb-user, ding

On Tue, Mar 22 2022, Sam Steingold wrote:
> when the current group is _not_ `nndoc`, there is no `quit-config'
> and `with-current-buffer' will signal an "nil is not a buffer" error.

Do you refer to the possibility that the first `or' clause

  (or (gnus-fetch-original-field header)

fails because a header is absent in an otherwise ordinary message?
Then looking for parent-summary-buffer won't help either.

> +         (let ((parent-summary-buffer
> +                (cadr (assq 'quit-config
> +                            (gnus-info-params
> +                             (gnus-get-info gnus-newsgroup-name))))))
> +           (and parent-summary-buffer
> +                (with-current-buffer parent-summary-buffer
> +                  (gnus-fetch-original-field header))))))

Thanks, I find this much cleaner!


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

* Re: bug#54423: 29.0.50; gnus-fetch-original-field returns nil in digest
  2022-03-22 17:27               ` Roland Winkler
@ 2022-03-22 18:06                 ` Sam Steingold
  0 siblings, 0 replies; 4+ messages in thread
From: Sam Steingold @ 2022-03-22 18:06 UTC (permalink / raw)
  To: Roland Winkler; +Cc: bbdb-user, ding

On Tue, 22 Mar 2022 at 13:27, Roland Winkler <winkler@gnu.org> wrote:
>
> On Tue, Mar 22 2022, Sam Steingold wrote:
> > when the current group is _not_ `nndoc`, there is no `quit-config'
> > and `with-current-buffer' will signal an "nil is not a buffer" error.
>
> Do you refer to the possibility that the first `or' clause
>
>   (or (gnus-fetch-original-field header)
>
> fails because a header is absent in an otherwise ordinary message?

yes. for an ordinary message parent-summary-buffer will be nil.


-- 
Sam Steingold <http://sds.podval.org> <http://www.childpsy.net>
<http://steingoldpsychology.com>


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

end of thread, other threads:[~2022-03-22 19:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <lzr172szfa.fsf@3c22fb11fdab.ant.amazon.com>
     [not found] ` <87ee30vo80.fsf@gnus.org>
     [not found]   ` <87cziku6kv.fsf@gnus.org>
     [not found]     ` <lzmthotxdi.fsf@3c22fb11fdab.ant.amazon.com>
     [not found]       ` <87k0cssiaw.fsf@gnus.org>
2022-03-22  0:04         ` bug#54423: 29.0.50; gnus-fetch-original-field returns nil in digest Sam Steingold
2022-03-22 16:49           ` Roland Winkler
     [not found]             ` <lzbkxxj4nq.fsf@3c22fb11fdab.ant.amazon.com>
2022-03-22 17:27               ` Roland Winkler
2022-03-22 18:06                 ` Sam Steingold

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 NNTP newsgroup(s).