unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#50417: 27.2; Unintuitive behavior with gnus-group-use-permanent-levels and g
@ 2021-09-06  0:19 Allen Li
  2021-09-06  9:01 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 2+ messages in thread
From: Allen Li @ 2021-09-06  0:19 UTC (permalink / raw)
  To: 50417

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

gnus-group-use-permanent-levels does not work as expected with g
(gnus-group-get-new-news).

The problem is with these two lines:

  (defun gnus-group-get-new-news (&optional arg one-level)
    "Get newly arrived articles.
  If ARG is a number, it specifies which levels you are interested in
  re-scanning.  If ARG is non-nil and not a number, this will force
  \"hard\" re-reading of the active files from all servers.
  If ONE-LEVEL is not nil, then re-scan only the specified level,
  otherwise all levels below ARG will be scanned too."
    (interactive "P")
    (require 'nnmail)
    (let ((gnus-inhibit-demon t)
          ;; Binding this variable will inhibit multiple fetchings
          ;; of the same mail source.
          (nnmail-fetched-sources (list t)))
      (gnus-run-hooks 'gnus-get-top-new-news-hook)
      (gnus-run-hooks 'gnus-get-new-news-hook)

      ;; Read any slave files.
      (unless gnus-slave
        (gnus-master-read-slave-newsrc))

=>    (gnus-get-unread-articles (gnus-group-default-level arg t)
                                nil one-level)

      ;; If the user wants it, we scan for new groups.
      (when (eq gnus-check-new-newsgroups 'always)
        (gnus-find-new-newsgroups))

      (gnus-check-reasonable-setup)
      (gnus-run-hooks 'gnus-after-getting-new-news-hook)
=>    (gnus-group-list-groups (and (numberp arg)
                                   (max (car gnus-group-list-mode) arg)))))

The gnus-get-unread-articles call uses the provided ARG and sets the
permament level (via gnus-group-default-level) as expected.  However,
gnus-group-list-groups gets the max of ARG and the list level ((car
gnus-group-list-mode)), and gnus-group-list-groups also calls
gnus-group-default-level which sets the permanent level.

Example:

1. User presses M-5 l, which sets both the permanent level and the list
level to 5.
2. User presses M-1 g.
2a. First, this sets the permanent level to 1 in gnus-get-unread-articles.
2b. Next, this uses the list level (5) to call gnus-group-list-groups
which sets the permanent level back to 5.

Expected:

After the M-1 g, the user expects that the permanent level is set to 1.

I think the best way to fix this is to not implicitly set
gnus-group-use-permanent-levels in gnus-group-default-level and instead
explicitly set the permanent level at the end of gnus-group-list-groups
and gnus-group-get-new-news.

I have attached an untested patch to that effect.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Set-gnus-group-use-permanent-levels-explicitly.patch --]
[-- Type: text/x-patch, Size: 2348 bytes --]

From dd4daa067c329de8bf57ca440b959992a1456239 Mon Sep 17 00:00:00 2001
From: Allen Li <darkfeline@felesatra.moe>
Date: Sun, 5 Sep 2021 17:17:34 -0700
Subject: [PATCH] Set gnus-group-use-permanent-levels explicitly

* lisp/gnus/gnus-group.el (gnus-group-default-level): Removed implicit
setting of gnus-group-use-permanent-levels.
(gnus-group-list-groups): Set gnus-group-use-permanent-levels explicitly.
(gnus-group-get-new-news): Set gnus-group-use-permanent-levels explicitly.
---
 lisp/gnus/gnus-group.el | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/lisp/gnus/gnus-group.el b/lisp/gnus/gnus-group.el
index b1134397e5..5baf232ce0 100644
--- a/lisp/gnus/gnus-group.el
+++ b/lisp/gnus/gnus-group.el
@@ -1176,11 +1176,10 @@ gnus-group-default-list-level
 (defun gnus-group-default-level (&optional level number-or-nil)
   (cond
    (gnus-group-use-permanent-levels
-    (or (setq gnus-group-use-permanent-levels
-	      (or level (if (numberp gnus-group-use-permanent-levels)
-			    gnus-group-use-permanent-levels
-			  (or (gnus-group-default-list-level)
-			      gnus-level-subscribed))))
+    (or (or level (if (numberp gnus-group-use-permanent-levels)
+		      gnus-group-use-permanent-levels
+		    (or (gnus-group-default-list-level)
+			gnus-level-subscribed)))
 	(gnus-group-default-list-level) gnus-level-subscribed))
    (number-or-nil
     level)
@@ -1288,7 +1287,9 @@ gnus-group-list-groups
 	      (goto-char (point-max))
 	      (forward-line -1)))))))
     ;; Adjust cursor point.
-    (gnus-group-position-point)))
+    (gnus-group-position-point)
+    (when gnus-group-use-permanent-levels
+      (setq gnus-group-use-permanent-levels level))))
 
 (defun gnus-group-list-level (level &optional all)
   "List groups on LEVEL.
@@ -4206,7 +4207,9 @@ gnus-group-get-new-news
     (gnus-check-reasonable-setup)
     (gnus-run-hooks 'gnus-after-getting-new-news-hook)
     (gnus-group-list-groups (and (numberp arg)
-				 (max (car gnus-group-list-mode) arg)))))
+				 (max (car gnus-group-list-mode) arg)))
+    (when gnus-group-use-permanent-levels
+      (setq gnus-group-use-permanent-levels (gnus-group-default-level arg)))))
 
 (defun gnus-group-get-new-news-this-group (&optional n dont-scan)
   "Check for newly arrived news in the current group (and the N-1 next groups).
-- 
2.33.0


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


In GNU Emacs 27.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.27, cairo version 1.17.4)
 of 2021-03-26 built on juergen
Windowing system distributor 'The X.Org Foundation', version 11.0.12013000
System Description: Arch Linux

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

* bug#50417: 27.2; Unintuitive behavior with gnus-group-use-permanent-levels and g
  2021-09-06  0:19 bug#50417: 27.2; Unintuitive behavior with gnus-group-use-permanent-levels and g Allen Li
@ 2021-09-06  9:01 ` Lars Ingebrigtsen
  0 siblings, 0 replies; 2+ messages in thread
From: Lars Ingebrigtsen @ 2021-09-06  9:01 UTC (permalink / raw)
  To: Allen Li; +Cc: 50417

Allen Li <darkfeline@felesatra.moe> writes:

> I have attached an untested patch to that effect.

Thanks -- it didn't quite work (because `gnus-group-list-groups' just
set the level back to the max again), but I tweaked it a bit and pushed
to Emacs 28, and it seems to work for me now.

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





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

end of thread, other threads:[~2021-09-06  9:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-06  0:19 bug#50417: 27.2; Unintuitive behavior with gnus-group-use-permanent-levels and g Allen Li
2021-09-06  9:01 ` Lars Ingebrigtsen

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