From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "J.P." Newsgroups: gmane.emacs.bugs Subject: bug#60954: 29.0.60; ERC 5.4.1: loading ERC clobbers customizations to erc-mode-hook Date: Fri, 20 Jan 2023 06:15:29 -0800 Message-ID: <874jsluwam.fsf__36790.1456587546$1674224182$gmane$org@neverwas.me> References: <87pmb9wyz6.fsf@neverwas.me> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7970"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: emacs-erc@gnu.org To: 60954@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jan 20 15:16:13 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pIsBg-0001qd-I3 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 20 Jan 2023 15:16:12 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pIsBa-0004pO-Io; Fri, 20 Jan 2023 09:16:06 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pIsBW-0004ng-Mk for bug-gnu-emacs@gnu.org; Fri, 20 Jan 2023 09:16:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pIsBW-00052h-FN for bug-gnu-emacs@gnu.org; Fri, 20 Jan 2023 09:16:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pIsBW-0001RT-7v for bug-gnu-emacs@gnu.org; Fri, 20 Jan 2023 09:16:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: "J.P." Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 20 Jan 2023 14:16:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60954 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 60954-submit@debbugs.gnu.org id=B60954.16742241435513 (code B ref 60954); Fri, 20 Jan 2023 14:16:02 +0000 Original-Received: (at 60954) by debbugs.gnu.org; 20 Jan 2023 14:15:43 +0000 Original-Received: from localhost ([127.0.0.1]:45969 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pIsBD-0001Qq-6R for submit@debbugs.gnu.org; Fri, 20 Jan 2023 09:15:43 -0500 Original-Received: from mail-108-mta91.mxroute.com ([136.175.108.91]:43739) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pIsBB-0001Qc-Co for 60954@debbugs.gnu.org; Fri, 20 Jan 2023 09:15:42 -0500 Original-Received: from mail-111-mta2.mxroute.com ([136.175.111.2] filter006.mxroute.com) (Authenticated sender: mN4UYu2MZsgR) by mail-108-mta91.mxroute.com (ZoneMTA) with ESMTPSA id 185cf88e1c9000011e.001 for <60954@debbugs.gnu.org> (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES128-GCM-SHA256); Fri, 20 Jan 2023 14:15:32 +0000 X-Zone-Loop: 9069294e83579e1c475c6c88a424c82b9d8079ca8477 X-Originating-IP: [136.175.111.2] DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=neverwas.me ; s=x; h=Content-Type:MIME-Version:Message-ID:Date:References:In-Reply-To: Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=D8o6Qb1ueuIOEqE2b11XIcaEXtGir3gI4PhmDDRDUxM=; b=Hhl8eAwGwwNkw9aNQ16qGRG6F8 XJX/r7Y2N/5+EDARFd+iLZceL8yabd1oCVtdqPNtylWc+aezdfd0cz6LC80+OWCXeoZH7jMWpd/ox ndybO1+yznI1oW3T54NJxNRwb8wGUM5XgsEyJQmCL1B2BPKOBVv9dNtltM5Pn27+o23+kvmT0omau FqEyPVBZWyZAjMvw6Ae36SmpbEQSv+YfZ06sAVee1q3q5559JXQSEiNEhF1UYj44NHmlmlwZIxUQv YzWq6xXFnhldM5CmH/JO1lK6VrpA53ykr2aEKx6rp94Wmgb9S2aAUvnwpoQ9UAIWL4WUiXYut/taT wq+YHJow==; In-Reply-To: <87pmb9wyz6.fsf@neverwas.me> (J. P.'s message of "Thu, 19 Jan 2023 21:34:37 -0800") X-Authenticated-Id: masked@neverwas.me X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:253777 Archived-At: --=-=-= Content-Type: text/plain "J.P." writes: > I see two basic avenues of attack here. The first is a pretty safe > stopgap and the second a slightly riskier comprehensive approach that > should have been on the books the moment that bug was closed: > > hack: partially revert a tiny hunk from the commit above > > fix: don't require goodies at all and instead update the module > mapping data and add all necessary autoloads and forward > declarations Under "fix," I forgot to mention also couching any top-level `add-hook' calls in module-setup and teardown functions. Of particular concern are those that mutate user options. Attached is an addition to the (5.6 portion of the) patch set that does this for the Imenu integration. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0004-5.6-Convert-ERC-s-Imenu-integration-into-proper-modu.patch >From e7507ed0777a1b346e0161399b077bc0904f1c80 Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Thu, 19 Jan 2023 21:07:27 -0800 Subject: [PATCH 4/4] [5.6] Convert ERC's Imenu integration into proper module TODO: add news item once a section for 5.6 has been added. * lisp/erc/erc-goodies.el: Don't add Imenu hooks to `erc-mode-hook' at top level. Remove autoload for `erc-create-imenu-index' because it already exists in the `erc-imenu' library. (erc-imenu-setup) Move to erc-imenu. * lisp/erc/erc-imenu.el (erc-imenu-setup): Move here from goodies. (erc-imenu-mode, erc-imenu-enable, erc-imenu-disable): Create new ERC module for Imenu. * lisp/erc/erc.el (erc-modules): Add `imenu' to default value and create menu item. Update package-version. --- lisp/erc/erc-goodies.el | 8 -------- lisp/erc/erc-imenu.el | 19 +++++++++++++++++++ lisp/erc/erc.el | 4 +++- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/lisp/erc/erc-goodies.el b/lisp/erc/erc-goodies.el index 0bf4bb9537c..f6c1376bb58 100644 --- a/lisp/erc/erc-goodies.el +++ b/lisp/erc/erc-goodies.el @@ -29,8 +29,6 @@ ;;; Code: -;;; Imenu support - (eval-when-compile (require 'cl-lib)) (require 'erc-common) @@ -48,12 +46,6 @@ erc-server-process (declare-function erc-extract-command-from-line "erc" (line)) (declare-function erc-beg-of-input-line "erc" nil) -(defun erc-imenu-setup () - "Setup Imenu support in an ERC buffer." - (setq-local imenu-create-index-function #'erc-create-imenu-index)) - -(add-hook 'erc-mode-hook #'erc-imenu-setup) -(autoload 'erc-create-imenu-index "erc-imenu" "Imenu index creation function") ;;; Automatically scroll to bottom (defcustom erc-input-line-position nil diff --git a/lisp/erc/erc-imenu.el b/lisp/erc/erc-imenu.el index 6223cd3d06f..2514ffcc4d3 100644 --- a/lisp/erc/erc-imenu.el +++ b/lisp/erc/erc-imenu.el @@ -124,6 +124,25 @@ erc-create-imenu-index index-alist)) index-alist)) +(defvar-local erc-imenu--create-index-function nil + "Previous local value of `imenu-create-index-function', if any.") + +(defun erc-imenu-setup () + "Wire up support for Imenu in an ERC buffer." + (when (and (local-variable-p 'imenu-create-index-function) + imenu-create-index-function) + (setq erc-imenu--create-index-function imenu-create-index-function)) + (setq-local imenu-create-index-function #'erc-create-imenu-index)) + +(define-erc-module imenu nil + "Simple Imenu integration for ERC." + ((add-hook 'erc-mode-hook #'erc-imenu-setup)) + ((remove-hook 'erc-mode-hook #'erc-imenu-setup) + (erc-with-all-buffers-of-server erc-server-process nil + (when erc-imenu--create-index-function + (setq imenu-create-index-function erc-imenu--create-index-function) + (kill-local-variable 'erc-imenu--create-index-function))))) + (provide 'erc-imenu) ;;; erc-imenu.el ends here diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index 007f70b8671..0d6634d38a9 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el @@ -1819,7 +1819,7 @@ erc-migrate-modules (defcustom erc-modules '(netsplit fill button match track completion readonly networks ring autojoin noncommands irccontrols - move-to-prompt stamp menu list) + move-to-prompt stamp menu list imenu) "A list of modules which ERC should enable. If you set the value of this without using `customize' remember to call \(erc-update-modules) after you change it. When using `customize', modules @@ -1864,6 +1864,7 @@ erc-modules (const :tag "identd: Launch an identd server on port 8113" identd) (const :tag "irccontrols: Highlight or remove IRC control characters" irccontrols) + (const :tag "imenu: A simple Imenu integration" imenu) (const :tag "keep-place: Leave point above un-viewed text" keep-place) (const :tag "list: List channels in a separate buffer" list) (const :tag "log: Save buffers in logs" log) @@ -1899,6 +1900,7 @@ erc-modules (const :tag "unmorse: Translate morse code in messages" unmorse) (const :tag "xdcc: Act as an XDCC file-server" xdcc) (repeat :tag "Others" :inline t symbol)) + :package-version '(ERC . "5.5") ; FIXME sync on release :group 'erc) (defun erc-update-modules () -- 2.38.1 --=-=-=--