From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: dick Newsgroups: gmane.emacs.bugs Subject: bug#36736: patch Date: Fri, 19 Jul 2019 21:45:28 -0400 Message-ID: <87a7d9iimf.fsf@dick.i-did-not-set--mail-host-address--so-tickle-me> Mime-Version: 1.0 Content-Type: text/x-diff Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="120218"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) To: 36736@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Jul 20 06:58:11 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hohRj-000VCQ-3h for geb-bug-gnu-emacs@m.gmane.org; Sat, 20 Jul 2019 06:58:11 +0200 Original-Received: from localhost ([::1]:49654 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hohRh-0003qp-5b for geb-bug-gnu-emacs@m.gmane.org; Sat, 20 Jul 2019 00:58:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:43894) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hohRd-0003nX-1K for bug-gnu-emacs@gnu.org; Sat, 20 Jul 2019 00:58:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hohRb-0006mv-Or for bug-gnu-emacs@gnu.org; Sat, 20 Jul 2019 00:58:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:47903) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hohRb-0006mr-LI for bug-gnu-emacs@gnu.org; Sat, 20 Jul 2019 00:58:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hohRb-0001L2-GA for bug-gnu-emacs@gnu.org; Sat, 20 Jul 2019 00:58:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: dick Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 20 Jul 2019 04:58:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 36736 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.15635986535094 (code B ref -1); Sat, 20 Jul 2019 04:58:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 20 Jul 2019 04:57:33 +0000 Original-Received: from localhost ([127.0.0.1]:56722 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hohR7-0001K5-5H for submit@debbugs.gnu.org; Sat, 20 Jul 2019 00:57:33 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:52581) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hoeRN-0005H2-KK for submit@debbugs.gnu.org; Fri, 19 Jul 2019 21:45:39 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:46038) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hoeRM-0001sW-BY for bug-gnu-emacs@gnu.org; Fri, 19 Jul 2019 21:45:37 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hoeRL-0005sH-2u for bug-gnu-emacs@gnu.org; Fri, 19 Jul 2019 21:45:36 -0400 Original-Received: from mail-qt1-x834.google.com ([2607:f8b0:4864:20::834]:36512) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hoeRK-0005s7-Sk for bug-gnu-emacs@gnu.org; Fri, 19 Jul 2019 21:45:35 -0400 Original-Received: by mail-qt1-x834.google.com with SMTP id z4so33053778qtc.3 for ; Fri, 19 Jul 2019 18:45:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:user-agent:mime-version :content-disposition:content-description; bh=L1lRZuCNIGp4KyGf3/zJF1P814+TLwvYIzX8QYEb5n8=; b=XZnnr5aGHXoG/Osm9vcBaUwcheV5H3JdxyilQvHRcIb5XDYICNILd8L+QyWyMT61Ta WZOWJnvMUtktkpOU1W/mj3CvT2FLYySmZyDWFxNCpDOB2cDO2YcSjivz5wfGUVEl7FJK JaM/zlBpgD5QR4kyO8L+8s7TP2quW7Pha08nu8Nfkf3EqJ/mWLcnbwxJ9586lI/1UR/r romdsv1R15sU+hYQxsziKkW1tjOCRELWPpRgL5kUTa7/Fbna1R1sv5LkidaM+uvjZcFf 71ohc/uA46K1bqbM4D0+vurJE/OHOaFn7j9R4sbK7zdg/K8jkDZbyYtWLq3f1QAfakin ePVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:user-agent :mime-version:content-disposition:content-description; bh=L1lRZuCNIGp4KyGf3/zJF1P814+TLwvYIzX8QYEb5n8=; b=eJ9IaUX832TBKXdw1SHMEytWbtUGLX4zKyEGTgvzoInZlgKCMmRGnytgkW11AqcYB+ lxArUO5RX9w/agwcouc60hxMuK/p9hyFpBrtr+iAIZzLb4i5SjWCA5GbVlRqJD4zRMWn 0egTJmFW68j/yTUEmxk65WIOTf0oNxV0+PZmT6eOKr0CIjOar3yp/6cieAcUCNVrEJum UwTTW4ceDw9e++7PRjet/2mvSR2ioCcU2rprh3cYmaczVNNI7KizXNOQuiFs75HSoiCA iaqmTtrEyzI3zkQUdP00OvBFpmqMZVe6uC2x8aEWOImqTTu8Avfzusc2lKoVK1aRD1w1 dH3g== X-Gm-Message-State: APjAAAXtdYq2R+C+03HuMc5uhKPDnqzF2VWvLJM5vFh0zjbEXXqE5waa ErjZUq8p/89hMysL1hnkMvG5xkAJ X-Google-Smtp-Source: APXvYqyYJNXG5w51n0GOXgPSmpbsOQunCTLChmTUQ7lwcVatloJQOkFoVKGxHIJ37F+SBZAniRK8ug== X-Received: by 2002:a0c:81f0:: with SMTP id 45mr41439187qve.13.1563587133750; Fri, 19 Jul 2019 18:45:33 -0700 (PDT) Original-Received: from localhost ([100.33.98.8]) by smtp.gmail.com with ESMTPSA id z5sm13957481qti.80.2019.07.19.18.45.32 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 19 Jul 2019 18:45:32 -0700 (PDT) X-Google-Original-From: dick Content-Disposition: inline; filename=0001-Avoid-clobbering-gnus-group-change-level-function.patch Content-Description: patch X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Mailman-Approved-At: Sat, 20 Jul 2019 00:57:31 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:163441 Archived-At: >From b8da0de6541fa5a966c30306c1f135bc60590ff0 Mon Sep 17 00:00:00 2001 From: dickmao 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