all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#72532: [PATCH] ; lisp/progmodes/which-func.el (which-function-mode): check buffer
@ 2024-08-08 19:48 Raffael Stocker
  2024-08-09  5:27 ` Eli Zaretskii
  2024-08-09  9:45 ` Stefan Kangas
  0 siblings, 2 replies; 7+ messages in thread
From: Raffael Stocker @ 2024-08-08 19:48 UTC (permalink / raw)
  To: 72532

[-- Attachment #1: Type: text/plain, Size: 945 bytes --]

Tags: patch

Hi Emacs,

I have been getting "Selecting deleted buffer" errors recently when
opening files.  This is due to ‘which-function-mode’ (in my
prog-mode-hook) walking through (buffer-list) without checking for live
buffers.

I have not been able to reproduce with ‘emacs -Q’, but it seems 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=/opt/emacs --with-native-compilation=aot'


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-lisp-progmodes-which-func.el-which-function-mode-che.patch --]
[-- Type: text/patch, Size: 1125 bytes --]

From cd8b170f2c716cf67623c4ffc4ae38dc63c49496 Mon Sep 17 00:00:00 2001
From: Raffael Stocker <r.stocker@mnet-mail.de>
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


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-08-15  8:36 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-08 19:48 bug#72532: [PATCH] ; lisp/progmodes/which-func.el (which-function-mode): check buffer Raffael Stocker
2024-08-09  5:27 ` Eli Zaretskii
2024-08-09 17:35   ` Raffael Stocker
2024-08-09  9:45 ` Stefan Kangas
2024-08-09 17:39   ` Raffael Stocker
2024-08-09 19:59     ` Raffael Stocker
2024-08-15  8:36       ` Eli Zaretskii

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.