Subject: Re: bug#77405: 31.0.50; speedbar-window can't be opened after killing speedbar-buffer

From: Vincenzo Pupillo <[email-masked]>
Date: Mon, 31 Mar 2025 22:19:51 +0200

Ciao, I confirm the bug and also the fix suggested by Rudi. The attached patch 
solves the problem.

Thanks Rudi for the bug report.

Vincenzo

In data lunedì 31 marzo 2025 17:16:55 Ora legale dell’Europa centrale, Eli 
Zaretskii ha scritto:
> > From: Rudi Schlatte <[email-masked]>
> > Date: Mon, 31 Mar 2025 16:35:59 +0200
> > 
> > 
> > Hi, the following recipe leads to a state where speedbar-window cannot
> > be activated anymore.
> > 
> > - M-x speedbar-window RET
> > - Move point into the speedbar side window, e.g., by clicking into the
> > window
> > - C-x k RET (killing the speedbar buffer)
> > - M-x speedbar-window RET
> > 
> > After this, the following can be found in *Messages*:
> > 
> > speedbar-window: Attempt to delete the sole visible or iconified frame
> > DFRAME TIMER ERROR: (error "Selecting deleted buffer")
> > 
> > Adding (buffer-live-p speedbar-buffer) into speedbar-frame-or-window
> > seems to fix this:
> > 
> > (defun speedbar-frame-or-window ()
> > 
> >   "Return `frame' or `window' if one of each are open.
> > 
> > Return nil if both are closed."
> > 
> >   (cond
> >   
> >    ((speedbar-window--live-p)
> >    
> >     'window)
> >    
> >    ((and (frame-live-p (speedbar-current-frame))
> > 	 
> > 	 speedbar-buffer
> > 	 
> >          (buffer-live-p speedbar-buffer) ; <<< HERE
> > 	 
> > 	 (not (speedbar-window--live-p)))
> > 	 
> >     'frame)
> >    
> >    (t nil)))
> 
> Thanks.
> 
> Vincenzo, could you please look into this?

>From 882dc977995a01e19a5bf6c24b9f2ac70b605596 Mon Sep 17 00:00:00 2001
From: Vincenzo Pupillo <[email-masked]>
Date: Mon, 31 Mar 2025 21:49:36 +0200
Subject: [PATCH] Added a check to see if the 'speedbar-buffer' is still alive.

Fix suggested by Rudi Schlatte.

* lisp/speedbar.el (speedbar-frame-or-window): Added an additional check
to see if 'speedbar-buffer' is still alive (bug#77405).
---
 lisp/speedbar.el | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lisp/speedbar.el b/lisp/speedbar.el
index 6ad96c979d6..b1fd141321c 100644
--- a/lisp/speedbar.el
+++ b/lisp/speedbar.el
@@ -1048,7 +1048,8 @@ speedbar-frame-or-window
    ((speedbar-window--live-p)
     'window)
    ((and (frame-live-p (speedbar-current-frame))
-	 speedbar-buffer
+         speedbar-buffer
+	 (buffer-live-p speedbar-buffer)
 	 (not (speedbar-window--live-p)))
     'frame)
    (t nil)))
-- 
2.49.0