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: 30.0.50; ERC >5.5: Stop requiring erc-goodies in erc.el Date: Sat, 21 Jan 2023 07:03:11 -0800 Message-ID: <87edroj5g0.fsf__31448.491841887$1674313463$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="10534"; 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 Sat Jan 21 16:04:15 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 1pJFPj-0002Y0-8l for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 21 Jan 2023 16:04:15 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pJFPZ-000892-2x; Sat, 21 Jan 2023 10:04:05 -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 1pJFPX-00088r-Bc for bug-gnu-emacs@gnu.org; Sat, 21 Jan 2023 10:04:03 -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 1pJFPW-0006aa-47 for bug-gnu-emacs@gnu.org; Sat, 21 Jan 2023 10:04:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pJFPV-0003Qn-NW for bug-gnu-emacs@gnu.org; Sat, 21 Jan 2023 10:04:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: "J.P." Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 21 Jan 2023 15:04:01 +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.167431340813129 (code B ref 60954); Sat, 21 Jan 2023 15:04:01 +0000 Original-Received: (at 60954) by debbugs.gnu.org; 21 Jan 2023 15:03:28 +0000 Original-Received: from localhost ([127.0.0.1]:49473 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pJFOx-0003Pg-0j for submit@debbugs.gnu.org; Sat, 21 Jan 2023 10:03:28 -0500 Original-Received: from mail-108-mta23.mxroute.com ([136.175.108.23]:41689) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pJFOu-0003PM-Jz for 60954@debbugs.gnu.org; Sat, 21 Jan 2023 10:03:26 -0500 Original-Received: from mail-111-mta2.mxroute.com ([136.175.111.2] filter006.mxroute.com) (Authenticated sender: mN4UYu2MZsgR) by mail-108-mta23.mxroute.com (ZoneMTA) with ESMTPSA id 185d4daec9c000011e.001 for <60954@debbugs.gnu.org> (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES128-GCM-SHA256); Sat, 21 Jan 2023 15:03:15 +0000 X-Zone-Loop: db5dd2ca3073a3a21cb7bf466ce859938439d2aadcf8 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=0Robr0/lJCEZXnbt3RykUEkYxjbKc6zeDPV9hzJLJME=; b=C1xCC3JCHdP1CDZHcTScayV4le MN9HGZ63z2crdzwBg6J/i5bfYtvV3Bc29rY7Cr2CK629ruIbFov9ZBU+DMX2rg2FHJLO7EbQUqV1L brwd7Wcc7W4gu+kIj2SDRnPm3ZDjCcGt4ajirdk7MaldqojQKXsthTVgV08tWB/u8Byb02+LigGF1 q5OzU4qG0dxD5QCShZCMvQOYqfTxHZWOse1wugRYcIZaaARLyh+ANSW+q1spYar+6gT9Hwu6ukB4b JWOKd8MZz+iKTwpynT434mQFtBkmuDd2XyHEDWyPkKyco20eSp/FgsYl7x0b5FjWDFQABwiK4Hf1X VD7Hs/oA==; 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:253868 Archived-At: --=-=-= Content-Type: text/plain "J.P." writes: > diff --git a/lisp/erc/erc-goodies.el b/lisp/erc/erc-goodies.el > index 05a21019042..0bf4bb9537c 100644 > --- a/lisp/erc/erc-goodies.el > +++ b/lisp/erc/erc-goodies.el > @@ -38,9 +38,10 @@ erc-controls-highlight-regexp > [...] > (declare-function erc-buffer-list "erc" (&optional predicate proc)) > (declare-function erc-error "erc" (&rest args)) > @@ -384,9 +385,11 @@ erc-get-fg-color-face > (define-erc-module irccontrols nil > "This mode enables the interpretation of IRC control chars." > ((add-hook 'erc-insert-modify-hook #'erc-controls-highlight) > - (add-hook 'erc-send-modify-hook #'erc-controls-highlight)) > + (add-hook 'erc-send-modify-hook #'erc-controls-highlight) > + (define-key erc-mode-map "\C-c\C-c" #'erc-toggle-interpret-controls)) > ((remove-hook 'erc-insert-modify-hook #'erc-controls-highlight) > - (remove-hook 'erc-send-modify-hook #'erc-controls-highlight))) > + (remove-hook 'erc-send-modify-hook #'erc-controls-highlight) > + (erc-compat-call define-key erc-mode-map "\C-c\C-c" nil t))) Actually, messing with `erc-mode-map' like this is sure to break configs. Snippets like (with-eval-after-load 'erc (define-key erc-mode-map (kbd "RET") nil) (define-key erc-mode-map (kbd "C-c C-c") #'erc-send-current-line)) are fairly common [1]. Of course, mutating `erc-mode-map' is prevalent throughout ERC [2], but we probably shouldn't perpetuate the practice. If this were a brand new module, we could just give it its own minor-mode map. But doing so now might just serve to confuse. Here are two possibilities that seem relatively benign: 1. Leave the original binding in `erc-mode-map' but autoload its command, `erc-toggle-interpret-controls', and make it smart enough to enable `erc-irccontrols-mode' when necessary and maybe print a message explaining why. 2. Mutate the local map when the module's loaded, but only do so conditionally, by first checking to see if the key is taken (locally or in `erc-mode-map'). Likewise, only remove the binding if it's set to `erc-toggle-interpret-controls' locally. Door #1 is more conservative because it introduces zero churn, AFAICT. But without any plan for deprecation, it's tantamount to kicking the can down the road. Door #2 keeps things more compartmentalized and walled off (ERC does tout itself as being modular, after all), but there's a nonzero chance of churn in some cases, for example, when - someone sets a binding for `erc-mode-map' after the module is loaded - some map depends on `erc-mode-map' as a parent Otherwise, conditionally updating the current local map seems to have the same functional effect here as using a minor-mode map and conditionally overriding that in all ERC buffers (since this is a global module). The main downside I see for #2 is that it adds yet another facet of complexity to an already cluttered landscape, seeing as minor-mode maps are likely to become more common with the introduction of local modules. Perhaps of less concern is that there's no precedent for it (in ERC). That said, if we were to go bold and convert all `erc-mode-map' mutations across all ERC libraries, it would at least offer some sense of consistency and predictability going forward. (I suspect there may be other downsides I've not yet considered, though, so if you're privy to any, please do share.) Because #1 is pretty easy to visualize, I've gone ahead and provided a POC of #2 (for the `irccontrols' module only) in the third patch below. Anyone interested, please have a look. Thanks. [1] See (info "(erc) Sample Configuration"). [2] See `erc-button-setup' and the modules toggles for `erc-sound' and `erc-ring' and top-level forms in erc-match.el and erc-log.el. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0000-v1-v2.diff >From a8bd3a2964babe131cb6c04dd14d7b537e1a90b2 Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Sat, 21 Jan 2023 06:35:53 -0800 Subject: [PATCH 0/4] *** NOT A PATCH *** *** BLURB HERE *** F. Jason Park (4): Don't load erc-goodies atop erc.el [5.6] Copy over upstream Compat macros to erc-compat [5.6] Don't require erc-goodies in erc.el [5.6] Convert ERC's Imenu integration into proper module lisp/erc/erc-backend.el | 2 +- lisp/erc/erc-common.el | 10 ++++++++- lisp/erc/erc-compat.el | 49 +++++++++++++++++++++++++++++++++-------- lisp/erc/erc-goodies.el | 31 ++++++++++++++++---------- lisp/erc/erc-imenu.el | 19 ++++++++++++++++ lisp/erc/erc.el | 13 +++++++---- 6 files changed, 97 insertions(+), 27 deletions(-) Interdiff: diff --git a/lisp/erc/erc-goodies.el b/lisp/erc/erc-goodies.el index f6c1376bb58..01e51df0481 100644 --- a/lisp/erc/erc-goodies.el +++ b/lisp/erc/erc-goodies.el @@ -378,10 +378,22 @@ irccontrols "This mode enables the interpretation of IRC control chars." ((add-hook 'erc-insert-modify-hook #'erc-controls-highlight) (add-hook 'erc-send-modify-hook #'erc-controls-highlight) - (define-key erc-mode-map "\C-c\C-c" #'erc-toggle-interpret-controls)) + (add-hook 'erc-mode-hook #'erc--irccontrols-on-major-mode)) ((remove-hook 'erc-insert-modify-hook #'erc-controls-highlight) (remove-hook 'erc-send-modify-hook #'erc-controls-highlight) - (erc-compat-call define-key erc-mode-map "\C-c\C-c" nil t))) + (remove-hook 'erc-mode-hook #'erc--irccontrols-on-major-mode) + (erc-with-all-buffers-of-server nil nil + (erc--irccontrols-on-major-mode)))) + +(defun erc--irccontrols-on-major-mode () + ;; FIXME all these keymap-* functions require Compat 29 + (if erc-irccontrols-mode + ;; Interrogate composed view of local map and `erc-mode-map' + (unless (keymap-lookup (current-local-map) "C-c C-c") + (keymap-local-set "C-c C-c" #'erc-toggle-interpret-controls)) + (when (eq (keymap-local-lookup "C-c C-c") + #'erc-toggle-interpret-controls) + (keymap-local-unset "C-c C-c" t)))) (defun erc-controls-interpret (str) "Return a copy of STR after dealing with IRC control characters. -- 2.38.1 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Don-t-load-erc-goodies-atop-erc.el.patch >From 22e2577f4cd461d866254959572d85831715f61f Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Thu, 19 Jan 2023 20:19:40 -0800 Subject: [PATCH 1/4] Don't load erc-goodies atop erc.el * lisp/erc/erc.el: Commit c2d657e7c4fd9685591f2120007eabf78745919d "Move ERC's core dependencies to a separate file" ironed out ERC's interwoven dependencies for the better but didn't cleanly sidestep the goodies interdependency, specifically with regard to custom options. This reverts the tiny portion impacting this aspect by once again requiring `erc-goodies' at the very end of ERC's main library. Special thanks to Libera.Chat user jrm for reporting this bug. --- lisp/erc/erc.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index 7f51b7bfb2e..ff1820cfaf2 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el @@ -61,7 +61,6 @@ (load "erc-loaddefs" 'noerror 'nomessage) (require 'erc-networks) -(require 'erc-goodies) (require 'erc-backend) (require 'cl-lib) (require 'format-spec) @@ -7386,4 +7385,6 @@ erc-handle-irc-url (provide 'erc) +;; FIXME this is a temporary stopgap for Emacs 29. +(require 'erc-goodies) ;;; erc.el ends here -- 2.38.1 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0002-5.6-Copy-over-upstream-Compat-macros-to-erc-compat.patch >From 2d4dce2e09890ad28edf056df0bc23d818ace185 Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Thu, 19 Jan 2023 20:52:47 -0800 Subject: [PATCH 2/4] [5.6] Copy over upstream Compat macros to erc-compat * lisp/erc/erc-backend: (erc--get-isupport-entry): Replace call to `erc-compat--with-memoization' with the built-in `with-memoization'. * lisp/erc/erc-compat.el: (erc-compat-function, erc-compat-call): Add new macros from Compat 29.1.2.0. (erc-compat--with-memoization): Remove because it's now provided by Compat. --- lisp/erc/erc-backend.el | 2 +- lisp/erc/erc-compat.el | 49 +++++++++++++++++++++++++++++++++-------- 2 files changed, 41 insertions(+), 10 deletions(-) diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el index 1da701aebc4..f00c8b2841a 100644 --- a/lisp/erc/erc-backend.el +++ b/lisp/erc/erc-backend.el @@ -1878,7 +1878,7 @@ erc--get-isupport-entry primitive value." (if-let* ((table (or erc--isupport-params (erc-with-server-buffer erc--isupport-params))) - (value (erc-compat--with-memoization (gethash key table) + (value (with-memoization (gethash key table) (when-let ((v (assoc (symbol-name key) erc-server-parameters))) (if (cdr v) diff --git a/lisp/erc/erc-compat.el b/lisp/erc/erc-compat.el index 5601ede27a5..fb354a1d3f7 100644 --- a/lisp/erc/erc-compat.el +++ b/lisp/erc/erc-compat.el @@ -34,6 +34,46 @@ (require 'compat nil 'noerror) (eval-when-compile (require 'cl-lib) (require 'url-parse)) +;; Except for the "erc-" namespacing, these two definitions should be +;; continuously updated to match the latest upstream ones verbatim. +;; Although they're pretty simple, it's likely not worth checking for +;; and possibly deferring to the non-prefixed versions. +;; +;; BEGIN Compat macros + +;;;; Macros for explicit compatibility function calls + +(defmacro erc-compat-function (fun) + "Return compatibility function symbol for FUN. + +If the Emacs version provides a sufficiently recent version of +FUN, the symbol FUN is returned itself. Otherwise the macro +returns the symbol of a compatibility function which supports the +behavior and calling convention of the current stable Emacs +version. For example Compat 29.1 will provide compatibility +functions which implement the behavior and calling convention of +Emacs 29.1. + +An example is the function `plist-get' which got an additional +predicate argument in Emacs 29. The compatibility function, +which supports this additional argument can be obtained +via (compat-function plist-get) and called with the additional +predicate argument via (compat-call plist-get plist prop +predicate). It is not possible to directly call (plist-get plist +prop predicate), since the function does not yet support the +predicate argument on older Emacs versions and the Compat library +does not override existing functions." + (let ((compat (intern (format "compat--%s" fun)))) + `#',(if (fboundp compat) compat fun))) + +(defmacro erc-compat-call (fun &rest args) + "Call compatibility function or macro FUN with ARGS. +See `compat-function' for details." + (let ((compat (intern (format "compat--%s" fun)))) + `(,(if (fboundp compat) compat fun) ,@args))) + +;; END Compat macros + ;;;###autoload(autoload 'erc-define-minor-mode "erc-compat") (define-obsolete-function-alias 'erc-define-minor-mode #'define-minor-mode "28.1") @@ -368,15 +408,6 @@ erc-compat--29-sasl-scram--client-final-message ;;;; Misc 29.1 -(defmacro erc-compat--with-memoization (table &rest forms) - (declare (indent defun)) - (cond - ((fboundp 'with-memoization) - `(with-memoization ,table ,@forms)) ; 29.1 - ((fboundp 'cl--generic-with-memoization) - `(cl--generic-with-memoization ,table ,@forms)) - (t `(progn ,@forms)))) - (defvar url-irc-function) (defun erc-compat--29-browse-url-irc (string &rest _) -- 2.38.1 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0003-5.6-Don-t-require-erc-goodies-in-erc.el.patch >From 1bf40a08fbc49b5cadc856f8717cec642be1f06b Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Thu, 19 Jan 2023 21:07:27 -0800 Subject: [PATCH 3/4] [5.6] Don't require erc-goodies in erc.el * lisp/erc/erc-common.el: (erc--features-to-modules): Add mappings from erc-goodies. * lisp/erc/erc-goodies.el: Sort `defvar' forward declarations for maintainability. (erc-irccontrols-mode, erc-enable-irccontrols, erc-disable-irccontrols): Add and remove key for `erc-toggle-interpret-controls' to `erc-mode-map'. * lisp/erc/erc.el: Add some forward declarations from `erc-goodies' and remove the `require' call for `erc-goodies' at the end of the file. (erc-mode-map): Remove C-c C-c binding for `erc-toggle-interpret-controls'. (erc-update-mode-line-buffer): Only strip control chars when `erc-irccontrols-mode' is active. This is arguably a minor breaking change perhaps deserving of a NEWS entry. --- lisp/erc/erc-common.el | 10 +++++++++- lisp/erc/erc-goodies.el | 23 +++++++++++++++++++---- lisp/erc/erc.el | 10 ++++++---- 3 files changed, 34 insertions(+), 9 deletions(-) diff --git a/lisp/erc/erc-common.el b/lisp/erc/erc-common.el index 994555acecf..e567a108191 100644 --- a/lisp/erc/erc-common.el +++ b/lisp/erc/erc-common.el @@ -96,7 +96,15 @@ erc--features-to-modules (erc-page page ctcp-page) (erc-sound sound ctcp-sound) (erc-stamp stamp timestamp) - (erc-services services nickserv)) + (erc-services services nickserv) + (erc-goodies scrolltobottom) + (erc-goodies readonly) + (erc-goodies move-to-prompt) + (erc-goodies keep-place) + (erc-goodies noncommands) + (erc-goodies irccontrols) + (erc-goodies smiley) + (erc-goodies unmorse)) "Migration alist mapping a library feature to module names. Keys need not be unique: a library may define more than one module. Sometimes a module's downcased alias will be its diff --git a/lisp/erc/erc-goodies.el b/lisp/erc/erc-goodies.el index 05a21019042..801c3276499 100644 --- a/lisp/erc/erc-goodies.el +++ b/lisp/erc/erc-goodies.el @@ -38,9 +38,10 @@ erc-controls-highlight-regexp (defvar erc-controls-remove-regexp) (defvar erc-input-marker) (defvar erc-insert-marker) -(defvar erc-server-process) -(defvar erc-modules) (defvar erc-log-p) +(defvar erc-mode-map) +(defvar erc-modules) +(defvar erc-server-process) (declare-function erc-buffer-list "erc" (&optional predicate proc)) (declare-function erc-error "erc" (&rest args)) @@ -384,9 +385,23 @@ erc-get-fg-color-face (define-erc-module irccontrols nil "This mode enables the interpretation of IRC control chars." ((add-hook 'erc-insert-modify-hook #'erc-controls-highlight) - (add-hook 'erc-send-modify-hook #'erc-controls-highlight)) + (add-hook 'erc-send-modify-hook #'erc-controls-highlight) + (add-hook 'erc-mode-hook #'erc--irccontrols-on-major-mode)) ((remove-hook 'erc-insert-modify-hook #'erc-controls-highlight) - (remove-hook 'erc-send-modify-hook #'erc-controls-highlight))) + (remove-hook 'erc-send-modify-hook #'erc-controls-highlight) + (remove-hook 'erc-mode-hook #'erc--irccontrols-on-major-mode) + (erc-with-all-buffers-of-server nil nil + (erc--irccontrols-on-major-mode)))) + +(defun erc--irccontrols-on-major-mode () + ;; FIXME all these keymap-* functions require Compat 29 + (if erc-irccontrols-mode + ;; Interrogate composed view of local map and `erc-mode-map' + (unless (keymap-lookup (current-local-map) "C-c C-c") + (keymap-local-set "C-c C-c" #'erc-toggle-interpret-controls)) + (when (eq (keymap-local-lookup "C-c C-c") + #'erc-toggle-interpret-controls) + (keymap-local-unset "C-c C-c" t)))) (defun erc-controls-interpret (str) "Return a copy of STR after dealing with IRC control characters. diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index ff1820cfaf2..007f70b8671 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el @@ -134,11 +134,14 @@ erc-scripts ;; Forward declarations (defvar erc-message-parsed) +(defvar erc-irccontrols-mode) (defvar tabbar--local-hlf) (defvar motif-version-string) (defvar gtk-version-string) +(declare-function erc-controls-strip "erc-goodies" (str)) + ;; tunable connection and authentication parameters (defcustom erc-server nil @@ -1188,7 +1191,6 @@ erc-mode-map (define-key map [home] #'erc-bol) (define-key map "\C-c\C-a" #'erc-bol) (define-key map "\C-c\C-b" #'erc-switch-to-buffer) - (define-key map "\C-c\C-c" #'erc-toggle-interpret-controls) (define-key map "\C-c\C-d" #'erc-input-action) (define-key map "\C-c\C-e" #'erc-toggle-ctcp-autoresponse) (define-key map "\C-c\C-f" #'erc-toggle-flood-control) @@ -6847,7 +6849,9 @@ erc-update-mode-line-buffer (?m . ,(erc-format-channel-modes)) (?n . ,(or (erc-current-nick) "")) (?N . ,(erc-format-network)) - (?o . ,(or (erc-controls-strip erc-channel-topic) "")) + (?o . ,(or (and erc-irccontrols-mode + (erc-controls-strip erc-channel-topic)) + "")) (?p . ,(erc-port-to-string erc-session-port)) (?s . ,(erc-format-target-and/or-server)) (?S . ,(erc-format-target-and/or-network)) @@ -7385,6 +7389,4 @@ erc-handle-irc-url (provide 'erc) -;; FIXME this is a temporary stopgap for Emacs 29. -(require 'erc-goodies) ;;; erc.el ends here -- 2.38.1 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0004-5.6-Convert-ERC-s-Imenu-integration-into-proper-modu.patch >From a8bd3a2964babe131cb6c04dd14d7b537e1a90b2 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 801c3276499..01e51df0481 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 --=-=-=--