From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Raffael Stocker Newsgroups: gmane.emacs.bugs Subject: bug#72532: [PATCH] ; lisp/progmodes/which-func.el (which-function-mode): check buffer Date: Thu, 08 Aug 2024 21:48:45 +0200 Message-ID: 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="39206"; mail-complaints-to="usenet@ciao.gmane.io" To: 72532@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Aug 08 21:50:15 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 1sc99K-000A3M-Uv for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 08 Aug 2024 21:50:15 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sc98m-0007vL-11; Thu, 08 Aug 2024 15:49:40 -0400 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 1sc98h-0007uW-MK for bug-gnu-emacs@gnu.org; Thu, 08 Aug 2024 15:49:35 -0400 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 1sc98h-0005L8-Du for bug-gnu-emacs@gnu.org; Thu, 08 Aug 2024 15:49:35 -0400 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:From:To:Subject; bh=+dndHJVKrrM7G0yMM/k+Ia22Rr5Fcm/imEqMxzlefL4=; b=H9qv2mM2edy+XtrDd3A/RkpBx9rgU9ytHjlsOQwc/U+jVdXOI/rmUg4nyE2d760ONH8TN7xjdZeddap5vWn81njn3DjKl5wXbNUui01HWoxdvgKozRSyR+jegCHdFHNUahfHewef80jLjQ9foJdia51DIZ1CrSHulOWJwuqeK9MwviWYMwP6a4z8O9Ab9xmBvyw9s63rg1SPDVkf/lvz0FVEZOTF01xR2QLd/VzttqozXw9+tfTDU377MF/9IIUayrEAvxyfI/ACgPgZhLLoB6BppUZdRJX2ivMYtgsjGK83eaa6Kyzsgl68wXShpx99//JdkNM+R6LRuUK+g60Dbw==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sc998-0004t2-B4 for bug-gnu-emacs@gnu.org; Thu, 08 Aug 2024 15:50:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Raffael Stocker Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 08 Aug 2024 19:50:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 72532 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.172314658018742 (code B ref -1); Thu, 08 Aug 2024 19:50:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 8 Aug 2024 19:49:40 +0000 Original-Received: from localhost ([127.0.0.1]:37243 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sc98m-0004sE-6h for submit@debbugs.gnu.org; Thu, 08 Aug 2024 15:49:40 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:34350) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sc98k-0004s6-9l for submit@debbugs.gnu.org; Thu, 08 Aug 2024 15:49:38 -0400 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 1sc98J-0007rJ-0T for bug-gnu-emacs@gnu.org; Thu, 08 Aug 2024 15:49:11 -0400 Original-Received: from mail-out.m-online.net ([212.18.0.9]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sc98G-0005ID-EE for bug-gnu-emacs@gnu.org; Thu, 08 Aug 2024 15:49:10 -0400 Original-Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4WfyKW4lDbz1qtqm for ; Thu, 8 Aug 2024 21:49:03 +0200 (CEST) Original-Received: from localhost (dynscan1.mnet-online.de [192.168.6.68]) by mail.m-online.net (Postfix) with ESMTP id 4WfyKW3jlgz1qqlS for ; Thu, 8 Aug 2024 21:49:03 +0200 (CEST) X-Virus-Scanned: amavis at mnet-online.de Original-Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.68]) (amavis, port 10024) with ESMTP id C8yocDoAwL-y for ; Thu, 8 Aug 2024 21:48:50 +0200 (CEST) X-Auth-Info: rQs44ruBZu4GtQibELLzGtIU1V9ZNed7DFk/vmIqgwieHF6oLT9C+3VljT99/ML2 Original-Received: from Whiteflame (aftr-62-216-207-53.dynamic.mnet-online.de [62.216.207.53]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA for ; Thu, 8 Aug 2024 21:48:50 +0200 (CEST) Received-SPF: pass client-ip=212.18.0.9; envelope-from=r.stocker@mnet-mail.de; helo=mail-out.m-online.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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:289953 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Tags: patch Hi Emacs, I have been getting "Selecting deleted buffer" errors recently when opening files. This is due to =E2=80=98which-function-mode=E2=80=99 (in my prog-mode-hook) walking through (buffer-list) without checking for live buffers. I have not been able to reproduce with =E2=80=98emacs -Q=E2=80=99, but it s= eems to be connected to eglot, as I see the problem only with eglot enabled. Nevertheless, I would like to suggest the attached patch, if only to make which-function-mode more robust. Regards, Raffael In GNU Emacs 30.0.60 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.43, cairo version 1.18.0) of 2024-08-06 built on Whiteflame Repository revision: fb642d9cf546f52a11cdfef479447ce2e8fa3ec8 Repository branch: emacs-30 Windowing system distributor 'The X.Org Foundation', version 11.0.12101013 System Description: Arch Linux Configured using: 'configure --prefix=3D/opt/emacs --with-native-compilation=3Daot' --=-=-= Content-Type: text/patch Content-Disposition: attachment; filename=0001-lisp-progmodes-which-func.el-which-function-mode-che.patch >From cd8b170f2c716cf67623c4ffc4ae38dc63c49496 Mon Sep 17 00:00:00 2001 From: Raffael Stocker Date: Thu, 8 Aug 2024 21:38:14 +0200 Subject: [PATCH] ; lisp/progmodes/which-func.el (which-function-mode): check buffer Ensure we are not selecting a deleted buffer. --- lisp/progmodes/which-func.el | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lisp/progmodes/which-func.el b/lisp/progmodes/which-func.el index 28aacd335ba..5326be5e877 100644 --- a/lisp/progmodes/which-func.el +++ b/lisp/progmodes/which-func.el @@ -309,9 +309,10 @@ which-function-mode (setq which-func-update-timer (run-with-idle-timer which-func-update-delay t #'which-func-update))) (dolist (buf (buffer-list)) - (with-current-buffer buf - (which-func--header-line-remove) - (which-func-ff-hook)))) + (when (buffer-live-p buf) + (with-current-buffer buf + (which-func--header-line-remove) + (which-func-ff-hook))))) (defvar which-function-imenu-failed nil "Locally t in a buffer if `imenu--make-index-alist' found nothing there.") -- 2.46.0 --=-=-=--