GNU bug report logs - #36737
gnus-topic-mode clobbers gnus-group-change-level-function

Previous Next

Package: emacs;

Reported by: dick <priapushk <at> gmail.com>

Date: Sat, 20 Jul 2019 04:58:04 UTC

Severity: normal

Tags: wontfix

Merged with 36735

Found in version 25.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 36737 in the body.
You can then email your comments to 36737 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#36737; Package emacs. (Sat, 20 Jul 2019 04:58:04 GMT) Full text and rfc822 format available.

Acknowledgement sent to dick <priapushk <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 20 Jul 2019 04:58:04 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: dick <priapushk <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: patch
Date: Fri, 19 Jul 2019 21:47:31 -0400
[Message part 1 (text/plain, inline)]
Duplicate of preceding patch from priapushk <at> gmail.com
[0001-Avoid-clobbering-gnus-group-change-level-function.patch (text/x-diff, inline)]
From b8da0de6541fa5a966c30306c1f135bc60590ff0 Mon Sep 17 00:00:00 2001
From: dickmao <none>
Date: Fri, 19 Jul 2019 18:18:31 -0400
Subject: [PATCH] Avoid clobbering gnus-group-change-level-function

Gnus backends may add additional hooks via
`gnus-group-change-level-functions' but should not modify
`gnus-group-change-level-function'.
* lisp/gnus/gnus-group.el (gnus-group-kill-group): run-hook-with-args
  on `gnus-group-change-level-functions'.
* lisp/gnus/gnus-srvr.el (gnus-server-kill-server): run-hook-with-args
  on `gnus-group-change-level-functions'.
* lisp/gnus/gnus-start.el (gnus-group-change-level): run-hook-with-args
  on `gnus-group-change-level-functions'.
* lisp/gnus/gnus-topic.el (gnus-topic-mode): avoid clobbering
  `gnus-group-change-level-function'.  Mirror LOCAL flag in `add-hook'
  to `remove-hook' for `gnus-check-bogus-groups-hook'.
* lisp/gnus/gnus.el (gnus-group-change-level-function): define abnormal
  hook variable `gnus-group-change-level-functions'.
---
 lisp/gnus/gnus-group.el |  5 ++---
 lisp/gnus/gnus-srvr.el  |  5 ++---
 lisp/gnus/gnus-start.el |  5 ++---
 lisp/gnus/gnus-topic.el |  8 ++++----
 lisp/gnus/gnus.el       | 13 +++++++++++--
 5 files changed, 21 insertions(+), 15 deletions(-)

diff --git a/lisp/gnus/gnus-group.el b/lisp/gnus/gnus-group.el
index 299ebdec50..d95aa1ad8c 100644
--- a/lisp/gnus/gnus-group.el
+++ b/lisp/gnus/gnus-group.el
@@ -3919,9 +3919,8 @@ gnus-group-kill-group
 	(setq gnus-newsrc-alist
 	      (delq (assoc group gnus-newsrc-alist)
 		    gnus-newsrc-alist))
-	(when gnus-group-change-level-function
-	  (funcall gnus-group-change-level-function
-		   group gnus-level-killed 3))
+	(run-hook-with-args 'gnus-group-change-level-functions
+                            group gnus-level-killed 3)
 	(cond
 	 ((setq entry (gnus-group-entry group))
 	  (push (cons (car entry) (nth 1 entry))
diff --git a/lisp/gnus/gnus-srvr.el b/lisp/gnus/gnus-srvr.el
index 972ff28e63..8d0b36298f 100644
--- a/lisp/gnus/gnus-srvr.el
+++ b/lisp/gnus/gnus-srvr.el
@@ -432,9 +432,8 @@ gnus-server-kill-server
 	(setq gnus-newsrc-alist
 	      (delq (assoc group gnus-newsrc-alist)
 		    gnus-newsrc-alist))
-	(when gnus-group-change-level-function
-	  (funcall gnus-group-change-level-function
-		   group gnus-level-killed 3)))))
+        (run-hook-with-args 'gnus-group-change-level-functions
+                            group gnus-level-killed 3))))
   (gnus-server-position-point))
 
 (defun gnus-server-yank-server ()
diff --git a/lisp/gnus/gnus-start.el b/lisp/gnus/gnus-start.el
index d726ee5aab..f5ded7a4fa 100644
--- a/lisp/gnus/gnus-start.el
+++ b/lisp/gnus/gnus-start.el
@@ -1351,9 +1351,8 @@ gnus-group-change-level
 	  (gnus-dribble-enter
 	   (format "(gnus-group-set-info '%S)" info)
 	   (concat "^(gnus-group-set-info '(\"" (regexp-quote group) "\"")))))
-      (when gnus-group-change-level-function
-	(funcall gnus-group-change-level-function
-		 group level oldlevel previous)))))
+      (run-hook-with-args 'gnus-group-change-level-functions
+                          group level oldlevel previous))))
 
 (defun gnus-check-bogus-newsgroups (&optional confirm)
   "Remove bogus newsgroups.
diff --git a/lisp/gnus/gnus-topic.el b/lisp/gnus/gnus-topic.el
index e2c728df8f..1daee1dcfb 100644
--- a/lisp/gnus/gnus-topic.el
+++ b/lisp/gnus/gnus-topic.el
@@ -1143,7 +1143,7 @@ gnus-topic-mode
 	   'gnus-topic-update-topics-containing-group)
       (set (make-local-variable 'gnus-group-sort-alist-function)
 	   'gnus-group-sort-topic)
-      (setq gnus-group-change-level-function 'gnus-topic-change-level)
+      (add-hook 'gnus-group-change-level-functions 'gnus-topic-change-level nil 'local)
       (setq gnus-goto-missing-group-function 'gnus-topic-goto-missing-group)
       (add-hook 'gnus-check-bogus-groups-hook 'gnus-topic-clean-alist
 		nil 'local)
@@ -1154,8 +1154,8 @@ gnus-topic-mode
     ;; Remove topic infestation.
     (unless gnus-topic-mode
       (remove-hook 'gnus-summary-exit-hook 'gnus-topic-update-topic)
-      (setq gnus-group-change-level-function nil)
-      (remove-hook 'gnus-check-bogus-groups-hook 'gnus-topic-clean-alist)
+      (remove-hook 'gnus-group-change-level-functions 'gnus-topic-change-level 'local)
+      (remove-hook 'gnus-check-bogus-groups-hook 'gnus-topic-clean-alist 'local)
       (setq gnus-group-prepare-function 'gnus-group-prepare-flat)
       (setq gnus-group-sort-alist-function 'gnus-group-sort-flat))
     (when (called-interactively-p 'any)
@@ -1741,7 +1741,7 @@ gnus-topic-move
 
 (defun gnus-subscribe-topics (newsgroup)
   (catch 'end
-    (let (match gnus-group-change-level-function)
+    (let (match gnus-group-change-level-functions)
       (dolist (topic (gnus-topic-list))
 	(when (and (setq match (cdr (assq 'subscribe
 					  (gnus-topic-parameters topic))))
diff --git a/lisp/gnus/gnus.el b/lisp/gnus/gnus.el
index 9ee7db9e20..abb8b7c9f8 100644
--- a/lisp/gnus/gnus.el
+++ b/lisp/gnus/gnus.el
@@ -2112,10 +2112,19 @@ gnus-apply-kill-hook
 
 (defcustom gnus-group-change-level-function nil
   "Function run when a group level is changed.
-It is called with three parameters -- GROUP, LEVEL and OLDLEVEL."
+It is called with four parameters -- GROUP, LEVEL, OLDLEVEL, and optionally PREVIOUS"
   :group 'gnus-group-levels
   :type '(choice (const nil)
-		 function))
+		 function)
+  :set (lambda (symbol value)
+         (set-default symbol value)
+         (when value
+           (set-default 'gnus-group-change-level-functions (list value)))))
+
+(defvar gnus-group-change-level-functions nil
+  "\"Abnormal\" hook run when a group level is changed.
+Each function element is called with three parameters -- GROUP, LEVEL, OLDLEVEL, and optionally PREVIOUS.
+Its default value is determined by the :set method of `gnus-group-change-level-function'")
 
 ;;; Face thingies.
 
-- 
2.22.0


Merged 36735 36736 36737. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Sat, 20 Jul 2019 05:32:02 GMT) Full text and rfc822 format available.

Changed bug title to 'gnus-topic-mode clobbers gnus-group-change-level-function' from 'patch' Request was from Noam Postavsky <npostavs <at> gmail.com> to control <at> debbugs.gnu.org. (Mon, 22 Jul 2019 14:38:01 GMT) Full text and rfc822 format available.

Disconnected #36735 from all other report(s). Request was from dick <dick.r.chiang <at> gmail.com> to control <at> debbugs.gnu.org. (Tue, 23 Jul 2019 19:44:02 GMT) Full text and rfc822 format available.

Disconnected #36736 from all other report(s). Request was from dick <dick.r.chiang <at> gmail.com> to control <at> debbugs.gnu.org. (Tue, 23 Jul 2019 22:21:02 GMT) Full text and rfc822 format available.

Merged 36735 36737. Request was from dick <dick.r.chiang <at> gmail.com> to control <at> debbugs.gnu.org. (Tue, 23 Jul 2019 22:21:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#36737; Package emacs. (Mon, 23 Sep 2019 22:48:02 GMT) Full text and rfc822 format available.

Message #18 received at 36737 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: dick <priapushk <at> gmail.com>
Cc: 36735 <at> debbugs.gnu.org, 36737 <at> debbugs.gnu.org
Subject: Re: bug#36737: patch
Date: Tue, 24 Sep 2019 00:47:28 +0200
dick <priapushk <at> gmail.com> writes:

> Gnus backends may add additional hooks via
> `gnus-group-change-level-functions' but should not modify
> `gnus-group-change-level-function'.

I'm not sure what this is trying to fix?  What's the problem here?

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




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#36737; Package emacs. (Mon, 23 Sep 2019 23:04:02 GMT) Full text and rfc822 format available.

Message #21 received at 36737 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: 36737 <at> debbugs.gnu.org
Subject: [priapushk <at> gmail.com] Re: bug#36737: patch
Date: Tue, 24 Sep 2019 01:03:38 +0200
-------------------- Start of forwarded message --------------------
From: priapushk <at> gmail.com
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Subject: Re: bug#36737: patch
Date: Mon, 23 Sep 2019 18:59:28 -0400

Hi.

I customize gnus-group-change-level-function but gnus-topic-mode overrides it.
-------------------- End of forwarded message --------------------

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





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#36737; Package emacs. (Tue, 24 Sep 2019 06:48:01 GMT) Full text and rfc822 format available.

Message #24 received at 36737 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: priapushk <at> gmail.com
Cc: 36737 <at> debbugs.gnu.org
Subject: Re: bug#36737: [priapushk <at> gmail.com] Re: bug#36737: patch
Date: Tue, 24 Sep 2019 08:47:09 +0200
> From: priapushk <at> gmail.com
> Subject: Re: bug#36737: patch
> To: Lars Ingebrigtsen <larsi <at> gnus.org>
> Date: Mon, 23 Sep 2019 18:59:28 -0400 (7 hours, 42 minutes, 52 seconds ago)
>
> Hi.
>
> I customize gnus-group-change-level-function but gnus-topic-mode overrides it.

(Please leave the debbugs address in the Cc headers, otherwise the bug
tracker won't see it.)

Right.  However, I think this is pretty obscure functionality, so I
don't think it warrants this sort of scaffolding.  You can set
gnus-group-change-level-function to whatever (after gnus-topic-mode has
done its stuff), and if you want your function to do both the topic mode
stuff and your own stuff, you can do that from your own function.

So I'm closing this bug report.

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




Added tag(s) wontfix. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Tue, 24 Sep 2019 06:48:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 36737 <at> debbugs.gnu.org and dick <priapushk <at> gmail.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Tue, 24 Sep 2019 06:48:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 22 Oct 2019 11:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 181 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.