unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#40520: 28.0.50; Prevent duplicate thread titles in Gnus
@ 2020-04-09  9:27 Kévin Le Gouguec
  2020-06-25 20:45 ` Kévin Le Gouguec
  2020-07-19  2:35 ` Lars Ingebrigtsen
  0 siblings, 2 replies; 4+ messages in thread
From: Kévin Le Gouguec @ 2020-04-09  9:27 UTC (permalink / raw)
  To: 40520

[-- Attachment #1: Type: text/plain, Size: 1676 bytes --]

Hello,

After tweaking gnus-sum-thread-tree-* options and messing with
gnus-summary-make-false-root before settling for 'dummy, I found a setup
I am mostly satisfied with for displaying loose threads:

(example from bug-gnu-emacs)
                     ┌◈                          bug#40337: 28.0.50; Enable case-fold-search in hi-lock
    02:08            ├► Juri Linkov
    05:33            ╰► Stefan Monnier

Yet sometimes I end up with threads where both the dummy line and the
first article show the title:

(example from emacs-devel)
                     ┌◈                          Re: Emacs's set-frame-size can not work well with gnome-shell?
    10:32            ├► martin rudalics          Re: Emacs's set-frame-size can not work well with gnome-shell?
    16:04            │╰► Eli Zaretskii
    10:33            ├► martin rudalics
    15:19            │╰► Dmitry Gutov
    10:33            ╰► martin rudalics

Ideally, I would like for loose threads to show the subject only once,
on the dummy root line.  IIUC, "%S" in gnus-summary-dummy-line-format
and "%s" in gnus-summary-line-format should get me that; quoting the
latter's docstring:

> %S          Subject (string)
> %s          Subject if it is at the root of a thread, and ""
>             otherwise (string)

I don't know if the duplicate subject I see is due to me misconfiguring
something[1], if this is a corner case that needs to be addressed in
Gnus, or if I am misreading the docstring, i.e. "at the root of a
thread" means "at the non-dummy root of a thread".

In case it's a corner case, here is my stab at fixing it:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Simplify-dummy-root-subject-before-comparing-it-to-t.patch --]
[-- Type: text/x-patch, Size: 1186 bytes --]

From 5c45214e42322ff84a9f2fa8e28616898e77ea2a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?K=C3=A9vin=20Le=20Gouguec?= <kevin.legouguec@gmail.com>
Date: Thu, 9 Apr 2020 11:05:39 +0200
Subject: [PATCH] Simplify dummy root subject before comparing it to the
 current article

* lisp/gnus/gnus-sum.el (gnus-summary-prepare-threads): Simplify both
the dummy root and the following article before comparing them,
otherwise both the former and the latter might display the thread's
subject even when gnus-summary-line-format contains "%s".
---
 lisp/gnus/gnus-sum.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el
index a47e657623..3251ee5974 100644
--- a/lisp/gnus/gnus-sum.el
+++ b/lisp/gnus/gnus-sum.el
@@ -5352,7 +5352,7 @@ gnus-summary-prepare-threads
 	      ;; We remember that we probably want to output a dummy
 	      ;; root.
 	      (setq gnus-tmp-dummy-line gnus-tmp-header)
-	      (setq gnus-tmp-prev-subject gnus-tmp-header))
+	      (setq gnus-tmp-prev-subject (gnus-simplify-subject-fully gnus-tmp-header)))
 	     (t
 	      ;; We do not make a root for the gathered
 	      ;; sub-threads at all.
-- 
2.26.0


[-- Attachment #3: Type: text/plain, Size: 4760 bytes --]


AFAIU gnus-tmp-prev-subject is only used for comparison with
simp-subject, which as its name implies is obtained with
gnus-simplify-subject-fully.  So from my naive POV it seems sound to
apply gnus-simplify-subject-fully to gnus-tmp-prev-subject… at least it
seems to get me what I want: only the dummy root shows the subject, in
every situation I could test[2].

WDYT?  Let me know if this report needs more details.  I admit I did not
dig very deep before submitting this patch; it's entirely possible that
there is an issue somewhere else (something in my configuration, some
bug in the thread gathering code…), or, as I said, that it's all normal
and dummy roots should not cause "%s" to elide subsequent subjects
(though I'd prefer if they did, FWIW).

Thank you for your time.


[1] Full .gnus configuration here:

https://gitlab.com/peniblec/dotfiles/raw/master/.gnus

Relevant snippet:

#+begin_src elisp
(setq gnus-select-method
      '(nnimap "gmail"
               (nnimap-address "imap.gmail.com")
               (nnimap-server-port 993)
               (nnmail-expiry-target "nnimap+gmail:[Gmail]/Trash")
               (nnmail-expiry-wait immediate))
      gnus-secondary-select-methods
      '((nntp "archive.lwn.net")
        (nntp "news.gmane.io"))
      gnus-summary-line-format "%*%U%R  %-16,16&user-date; %B%-23,23n  %s\n"
      gnus-summary-dummy-line-format "                     ┌◈                          %S\n"
      gnus-summary-make-false-root 'dummy
      gnus-sum-thread-tree-root "┌◈ "
      gnus-sum-thread-tree-false-root "┄┐ "
      gnus-sum-thread-tree-single-indent " ◈ "
      gnus-sum-thread-tree-indent " "
      gnus-sum-thread-tree-single-leaf "╰► "
      gnus-sum-thread-tree-leaf-with-other "├► "
      gnus-sum-thread-tree-vertical "│"
      gnus-thread-sort-functions
      '(gnus-thread-sort-by-number
        (not gnus-thread-sort-by-most-recent-number))
      gnus-treat-display-smileys nil
      gnus-user-date-format-alist '(((gnus-seconds-today)
                                     . "%H:%M")
                                    ((+ 86400 (gnus-seconds-today))
                                     . "Yesterday %H:%M")
                                    (604800
                                     . "%a %H:%M")
                                    ((gnus-seconds-month)
                                     . "%a %d")
                                    ((gnus-seconds-year)
                                     . "%b %d")
                                    (t
                                     . "%F")))
#+end_src

Relevant history of thread settings:

https://gitlab.com/peniblec/dotfiles/-/commit/d560753f64fc87e9377608bc7e3b1b7c2d2b5aca.patch
https://gitlab.com/peniblec/dotfiles/-/commit/41fecec385e15c3447c1aab4c0840d60a1e2e7af.patch
https://gitlab.com/peniblec/dotfiles/-/commit/0730a1177d43edadf7aa54e46c952fb5a561687a.patch
https://gitlab.com/peniblec/dotfiles/-/commit/ed713fdae47c1207b0efbe0692e2ef74713ba77c.patch
https://gitlab.com/peniblec/dotfiles/-/commit/e1d0940289e061b84876f33b4fb7f8c5a442412a.patch
https://gitlab.com/peniblec/dotfiles/-/commit/3de2177a110e987fa04f6792ad7f9b1d198335be.patch
https://gitlab.com/peniblec/dotfiles/-/commit/d3a52e8c77c588a190714767f5f607ab7270bfec.patch

[2] BTW I'd love to provide a test case for this, as it would make
    reproduction easier for both me and patch reviewers; I have no idea
    how to cook up an ERT test for Gnus though.  The tests under
    test/lisp/gnus do not really cover thread formatting AFAICT; maybe I
    should look into Eric's gnus-mock ELPA package?

    Ideally, I'd like to 1. dump a thread (or all the articles in a
    summary buffer if that's simpler) to some format, then 2. ask Gnus
    to read this dump into a summary buffer.  Afterward crude string
    comparisons would be enough to check whatever needs to be checked.



In GNU Emacs 28.0.50 (build 10, x86_64-pc-linux-gnu, GTK+ Version 3.24.14, cairo version 1.16.0)
 of 2020-03-31 built on my-little-tumbleweed
Repository revision: 05cab7ad06efabae18ee94e3b609ea10ae2f60be
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12007000
System Description: openSUSE Tumbleweed

Configured features:
XPM JPEG TIFF GIF PNG RSVG CAIRO SOUND GPM DBUS GSETTINGS GLIB NOTIFY
INOTIFY ACL LIBSELINUX GNUTLS LIBXML2 FREETYPE HARFBUZZ M17N_FLT LIBOTF
ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM MODULES THREADS XWIDGETS JSON
PDUMPER LCMS2 GMP

Important settings:
  value of $LC_CTYPE: en_US.UTF-8
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=local
  locale-coding-system: utf-8-unix

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

* bug#40520: 28.0.50; Prevent duplicate thread titles in Gnus
  2020-04-09  9:27 bug#40520: 28.0.50; Prevent duplicate thread titles in Gnus Kévin Le Gouguec
@ 2020-06-25 20:45 ` Kévin Le Gouguec
  2020-07-19  2:35 ` Lars Ingebrigtsen
  1 sibling, 0 replies; 4+ messages in thread
From: Kévin Le Gouguec @ 2020-06-25 20:45 UTC (permalink / raw)
  To: 40520; +Cc: Eric Abrahamsen

[-- Attachment #1: Type: text/plain, Size: 1557 bytes --]

Hello again,

I'd like to bump this report, if only because I've finally taken the
time to try out Eric Abrahamsen's gnus-mock package on GNU ELPA.  This
allowed me to make a reproducible test case with this simple config:

> (setq gnus-summary-make-false-root 'dummy)

I've attached an example .mbox saved from gnu-emacs-help; you can
reproduce my issue by saving it somewhere, then evaluating this in the
same directory:

#+begin_src elisp
(let ((gnus-mock-init-file (expand-file-name "gnus-dummy-init.el"))
      (gnus-mock-emacs-program (expand-file-name "src/emacs" source-directory))
      (mbox (expand-file-name "gnu-emacs-help.mbox" default-directory))
      (init-template "
(setq gnus-summary-make-false-root 'dummy)
(gnus)
(gnus-group-make-doc-group \"%s\" nil)
(gnus-group-select-group)
"))
  (with-temp-buffer
    (insert (format init-template mbox))
    (write-file "gnus-dummy-init.el"))
  (package-initialize)
  (gnus-mock-start))
#+end_src

Right now, Gnus produces this:

   :                             : Re: How to get the actual face attribute?
 .     [  67: Yuan Fu                ] Re: How to get the actual face attribute?
 .     [  28: Yuan Fu                ] 

With my patch (re-attached, with bug number for convenience), Gnus
produces this:

   :                             : Re: How to get the actual face attribute?
 .     [  67: Yuan Fu                ] 
 .     [  28: Yuan Fu                ] 


Let me know if there's anything wrong with the patch, or with my
understanding of the situation.

Thank you for your time.



[-- Attachment #2: gnu-emacs-help.mbox --]
[-- Type: application/mbox, Size: 14363 bytes --]

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0001-Simplify-dummy-root-subject-before-comparing-it-to-t.patch --]
[-- Type: text/x-patch, Size: 1198 bytes --]

From 271ff9c3287e25a71b82f9e47418a66c28f8553a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?K=C3=A9vin=20Le=20Gouguec?= <kevin.legouguec@gmail.com>
Date: Thu, 9 Apr 2020 11:05:39 +0200
Subject: [PATCH] Simplify dummy root subject before comparing it to the
 current article

* lisp/gnus/gnus-sum.el (gnus-summary-prepare-threads): Simplify both
the dummy root and the following article before comparing them,
otherwise both the former and the latter might display the thread's
subject even when gnus-summary-line-format contains "%s" (bug#40520).
---
 lisp/gnus/gnus-sum.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el
index 341f04ad77..e4f4114b6c 100644
--- a/lisp/gnus/gnus-sum.el
+++ b/lisp/gnus/gnus-sum.el
@@ -5352,7 +5352,7 @@ gnus-summary-prepare-threads
 	      ;; We remember that we probably want to output a dummy
 	      ;; root.
 	      (setq gnus-tmp-dummy-line gnus-tmp-header)
-	      (setq gnus-tmp-prev-subject gnus-tmp-header))
+	      (setq gnus-tmp-prev-subject (gnus-simplify-subject-fully gnus-tmp-header)))
 	     (t
 	      ;; We do not make a root for the gathered
 	      ;; sub-threads at all.
-- 
2.27.0


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

* bug#40520: 28.0.50; Prevent duplicate thread titles in Gnus
  2020-04-09  9:27 bug#40520: 28.0.50; Prevent duplicate thread titles in Gnus Kévin Le Gouguec
  2020-06-25 20:45 ` Kévin Le Gouguec
@ 2020-07-19  2:35 ` Lars Ingebrigtsen
  2020-07-19  9:48   ` Kévin Le Gouguec
  1 sibling, 1 reply; 4+ messages in thread
From: Lars Ingebrigtsen @ 2020-07-19  2:35 UTC (permalink / raw)
  To: Kévin Le Gouguec; +Cc: 40520

Kévin Le Gouguec <kevin.legouguec@gmail.com> writes:

> Ideally, I would like for loose threads to show the subject only once,
> on the dummy root line.  IIUC, "%S" in gnus-summary-dummy-line-format
> and "%s" in gnus-summary-line-format should get me that; quoting the
> latter's docstring:

[...]

> -	      (setq gnus-tmp-prev-subject gnus-tmp-header))
> +	      (setq gnus-tmp-prev-subject (gnus-simplify-subject-fully gnus-tmp-header)))

Looks good to me; applied to Emacs 28.1.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





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

* bug#40520: 28.0.50; Prevent duplicate thread titles in Gnus
  2020-07-19  2:35 ` Lars Ingebrigtsen
@ 2020-07-19  9:48   ` Kévin Le Gouguec
  0 siblings, 0 replies; 4+ messages in thread
From: Kévin Le Gouguec @ 2020-07-19  9:48 UTC (permalink / raw)
  To: Lars Ingebrigtsen; +Cc: 40520

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Looks good to me; applied to Emacs 28.1.

Thanks!





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

end of thread, other threads:[~2020-07-19  9:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-09  9:27 bug#40520: 28.0.50; Prevent duplicate thread titles in Gnus Kévin Le Gouguec
2020-06-25 20:45 ` Kévin Le Gouguec
2020-07-19  2:35 ` Lars Ingebrigtsen
2020-07-19  9:48   ` Kévin Le Gouguec

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).