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#74934: 30.0.92; Unexpected behavior by which-function-mode in erc-mode buffers Date: Tue, 17 Dec 2024 18:24:02 -0800 Message-ID: <87seqlhgot.fsf__30205.4567424179$1734488736$gmane$org@neverwas.me> References: <87y10des6w.fsf@gnu.org> 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="10839"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: emacs-erc@gnu.org, 74934@debbugs.gnu.org To: Anush V Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Dec 18 03:25:30 2024 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 1tNjkf-0002ge-G4 for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 18 Dec 2024 03:25:29 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tNjkI-0004BP-Qw; Tue, 17 Dec 2024 21:25: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 1tNjkG-00049f-Ku for bug-gnu-emacs@gnu.org; Tue, 17 Dec 2024 21:25:04 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tNjkG-0007Ze-B3 for bug-gnu-emacs@gnu.org; Tue, 17 Dec 2024 21:25:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=auMpTQfhaCLMEGVTVowGLBoR2VEg2mnfm0OMo5jKjdg=; b=SQ8uwIaZ0TR7YoQdh9GpddyndMfnDkwkvGSTdn/MUlKzaI/LtjjlvpxpPWXqDK/pS8/rnPnjEahMUsKnLgFyTVs1Du79IIian2USUAzSOsKCuypG0P3nfjcRKAMMkUCl16vg8RbQVY35drmLpxwZILgDbwJ0N3QK3cN/9kn97Yk2ChQ/6lrVjcWTvuTzkoUbr7a5fh/DSB4aPTjmEasEnfD393gUeOqggtd3morbUhl0jPGVp92g22wWljm82dSXGRjshXwgifYQePUhzgiddV3V009WyLb7b4WCyRHFewhMhoD73RY/eywQwgZycScoQjINrkkDjTeTFp/gQQ5LHg==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tNjkD-0004HX-W8 for bug-gnu-emacs@gnu.org; Tue, 17 Dec 2024 21:25: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: Wed, 18 Dec 2024 02:25:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74934 X-GNU-PR-Package: emacs Original-Received: via spool by 74934-submit@debbugs.gnu.org id=B74934.173448865716362 (code B ref 74934); Wed, 18 Dec 2024 02:25:01 +0000 Original-Received: (at 74934) by debbugs.gnu.org; 18 Dec 2024 02:24:17 +0000 Original-Received: from localhost ([127.0.0.1]:60962 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tNjjR-0004Fm-5r for submit@debbugs.gnu.org; Tue, 17 Dec 2024 21:24:16 -0500 Original-Received: from mail-108-mta64.mxroute.com ([136.175.108.64]:46261) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tNjjO-0004FZ-N7 for 74934@debbugs.gnu.org; Tue, 17 Dec 2024 21:24:11 -0500 Original-Received: from filter006.mxroute.com ([136.175.111.3] filter006.mxroute.com) (Authenticated sender: mN4UYu2MZsgR) by mail-108-mta64.mxroute.com (ZoneMTA) with ESMTPSA id 193d794606f000310e.001 for <74934@debbugs.gnu.org> (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Wed, 18 Dec 2024 02:24:05 +0000 X-Zone-Loop: b5b24c194c36e8c4cdac79e5bb9a3ba2ae0a92666a2f X-Originating-IP: [136.175.111.3] 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=auMpTQfhaCLMEGVTVowGLBoR2VEg2mnfm0OMo5jKjdg=; b=BPp9TdxtrFbZUpoHBOlHH3PuSD /9ZH28gnKXJX6GHiknv3ciKesyN7jEiOtEQk2rzBJhc7ZOrD4np2toaNy4nqcan+jlJIL71W/z/9o KMW+nCn5Y/qbBwOumkmcd0XvNVosa9Msq13bkLFCWovvhPbNhuQEpRgB+eI7SCeBzJwPO1ePtgGXz Q7uEcvfWfvbVO62Q57KjqeSq74mm8qQvb36wNOBxw25rxtAaPhGnqDpl3ZgSMoGLuhdmdZRRaT0QV xRwWBwCPxRZX/xGaOwfzvgvxPVC9HXDfxC8cdPPwt+r9ngfp4KwzMy+BDjN4lYlrwE7L7ez+HO37o FtO+oE/g==; In-Reply-To: <87y10des6w.fsf@gnu.org> (Anush V.'s message of "Tue, 17 Dec 2024 19:43:51 -0500") 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:297324 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi Anush, Appreciate you reporting this. Anush V writes: > steps to reproduce: > emacs --no-init > M-x erc > ;; join some channel. > M-x which-function-mode > > Current behavior: > In erc buffers, which-function-mode displays either "[n/a]" or a string b= ased on > the chat history in the mode line. FTR, I'm able to reproduce it. > Expected behavior: > which-function-mode shouldn=E2=80=99t be adding any string to mode line i= n erc buffers The first of the attached patches should hopefully address the issue. Thanks, J.P. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-5.6.1-Disable-which-func-mode-in-erc-imenu-buffers.patch >From 76eab2b23f46c885051f2bcb985ab15c3e851033 Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Tue, 17 Dec 2024 17:53:34 -0800 Subject: [PATCH 1/2] [5.6.1] Disable which-func-mode in erc-imenu buffers * lisp/erc/erc-imenu.el (erc-imenu-setup): Move after module definition so the variable `erc-imenu-mode' is defined. Run teardown code when module is deactivated. Set `which-func-mode' to nil locally. (erc-imenu-mode, erc-imenu-enable, erc-imenu-disable): Manage membership of `erc-imenu--disable-which-func' in `which-function-mode-hook'. (erc-imenu--disable-which-func): New function. (Bug#74934) --- lisp/erc/erc-imenu.el | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/lisp/erc/erc-imenu.el b/lisp/erc/erc-imenu.el index 4c9cbfc1580..68c7895e2dd 100644 --- a/lisp/erc/erc-imenu.el +++ b/lisp/erc/erc-imenu.el @@ -132,23 +132,36 @@ erc-create-imenu-index (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 imenu-create-index-function #'erc-create-imenu-index)) - ;;;###autoload(autoload 'erc-imenu-mode "erc-imenu" nil t) (define-erc-module imenu nil "Simple Imenu integration for ERC." ((add-hook 'erc-mode-hook #'erc-imenu-setup) + (add-hook 'which-function-mode-hook #'erc-imenu--disable-which-func) (unless erc--updating-modules-p (erc-buffer-do #'erc-imenu-setup))) ((remove-hook 'erc-mode-hook #'erc-imenu-setup) - (erc-with-all-buffers-of-server nil 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))))) + (remove-hook 'which-function-mode-hook #'erc-imenu--disable-which-func) + (erc-buffer-do #'erc-imenu-setup))) + +(defun erc-imenu-setup () + "Set up or tear down Imenu integration." + (if erc-imenu-mode + (progn + (when (and (local-variable-p 'imenu-create-index-function) + imenu-create-index-function) + (setq erc-imenu--create-index-function imenu-create-index-function)) + (setq imenu-create-index-function #'erc-create-imenu-index) + (when (boundp 'which-func-mode) + (setq which-func-mode 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) + (kill-local-variable 'which-func-mode))) + +(defun erc-imenu--disable-which-func () + "Silence `which-function-mode' in ERC buffers." + (defvar which-func-mode) + (erc-with-all-buffers-of-server nil nil + (setq which-func-mode nil))) (provide 'erc-imenu) -- 2.47.1 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0002-5.6.1-Add-lisp-imenu-generic-expression-for-ERC-hack.patch >From 6b331f127a7c4f1c4085521ea74c68f644f93cce Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Mon, 22 Apr 2024 18:11:24 -0700 Subject: [PATCH 2/2] [5.6.1] Add lisp-imenu-generic-expression for ERC hacking * lisp/erc/erc-backend.el (define-erc-response-handler): Add `doc-string' to `declare' specification. * lisp/erc/erc-imenu.el (erc-imenu-add-devel-patterns(): Add locally autoloaded function for defining `imenu' patterns when hacking on ERC. --- lisp/erc/erc-backend.el | 1 + lisp/erc/erc-imenu.el | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el index e72fa036f17..311e3a624e6 100644 --- a/lisp/erc/erc-backend.el +++ b/lisp/erc/erc-backend.el @@ -1662,6 +1662,7 @@ define-erc-response-handler ([&or integerp symbolp] &rest [&or integerp symbolp])] &optional sexp sexp def-body)) + (doc-string 2) (indent defun)) (if (numberp name) (setq name (intern (format "%03i" name)))) (setq aliases (mapcar (lambda (a) diff --git a/lisp/erc/erc-imenu.el b/lisp/erc/erc-imenu.el index 68c7895e2dd..c6cb5655e2d 100644 --- a/lisp/erc/erc-imenu.el +++ b/lisp/erc/erc-imenu.el @@ -163,6 +163,29 @@ erc-imenu--disable-which-func (erc-with-all-buffers-of-server nil nil (setq which-func-mode nil))) +;;;###autoload +(defun erc-imenu-add-devel-patterns () + "Tell `imenu' about ERC-defined macros." + ;; This currently produces results like "ERC response FOO BAR". I'd + ;; obviously be nicer to end up with "erc-response-FOO" and + ;; "erc-response-BAR", possibly as separate items. Likewise for + ;; modules: "erc-foo-mode" instead of "ERC module foo". + (cl-pushnew `("ERC response" + ,(rx bol (* (syntax whitespace)) + "(define-erc-response-handler (" (group (+ nonl)) ")") + 1) + lisp-imenu-generic-expression + :test #'equal) + (cl-pushnew `("ERC module" + ,(rx bol (* (syntax whitespace)) + ;; Lisp-mode-symbol. + "(define-erc-module " (group (+ (| (syntax word) + (syntax symbol) + (: "\\" nonl))))) + 1) + lisp-imenu-generic-expression + :test #'equal)) + (provide 'erc-imenu) ;;; erc-imenu.el ends here -- 2.47.1 --=-=-=--