bug#81561: 31.0.91; speedbar-window-mode creates stale idle timers
Vincenzo Pupillo <[email protected]>
| Newsgroups | gmane.emacs.bugs |
|---|---|
| Message-ID | <[email protected]> |
Ciao, I wasn’t able to reproduce the problem reported by Daniel. The only way was to kill the 'speedbar-buffer' process. So I added a 'kill-buffer-hook' to handle this event. I also eliminated a few other causes of stale idle timers. @Daniel, could you please try this patch? Thanks. V. In data martedì 11 agosto 2026 13:32:02 Ora legale dell’Europa centrale, Daniel Mendler ha scritto: > Eli Zaretskii <[email protected]> writes: > >> From: Daniel Mendler <[email protected]> > >> Cc: [email protected], [email protected] > >> Date: Tue, 11 Aug 2026 11:45:28 +0200 > >> > >> Eli Zaretskii <[email protected]> writes: > >> >> From: Daniel Mendler <[email protected]> > >> >> Cc: Eli Zaretskii <[email protected]>, [email protected] > >> >> Date: Sun, 09 Aug 2026 17:01:57 +0200 > >> >> > >> >> Ciao Vincenzo! > >> >> > >> >> Vincenzo Pupillo <[email protected]> writes: > >> >> > Ciao, sorry for the delay—I'm on vacation. The attached patch should > >> >> > fix the bug. It's partly due to an incorrect condition in > >> >> > 'dframe-set-timer' that doesn't follow what's written in the > >> >> > comment. This fix also resolves an issue with > >> >> > 'speedbar-frame-mode,' which wasn't clearing the timer even when > >> >> > 'speedbar-buffer' was killed. > >> >> > > >> >> > @Daniel, can you please check to see if the patch fixes the problem? > >> >> > >> >> Yes, thank you! The patch fixes the problem. The stale timers are gone > >> >> when the speedbar is closed. > >> >> > >> >> Eli, can you please apply this to emacs-31, since it fixes an issue, > >> >> which has been newly introduced via the new speedbar-window-mode? > >> > > >> > Thanks, done, and closing the bug. > >> > >> Eli, can you please reopen the bug since it is not fully fixed. See my > >> last mail. The problem is less pronounced, but occasionally stale timers > >> are still around. They even cause dframe error messages when they run > >> while the speedbar window is closed. > > > > I can reopen the bug, as can you. But it's actually not very > > important, because I've seen your report about the left-overs, and am > > still tracking this issue. Don't worry. > > Okay, thanks.
0001-Handle-speedbar-buffer-kill-when-in-speedbar-window-.patch
(text/x-patch, 4.8 KB)
From 58645345683859284310a5e1d6623b9a56c536f8 Mon Sep 17 00:00:00 2001 From: Vincenzo Pupillo <[email protected]> Date: Wed, 12 Aug 2026 18:11:25 +0200 Subject: [PATCH] Handle 'speedbar-buffer' kill when in 'speedbar-window-mode'. This patch handle the DFRAME TIMER ERROR reported by Daniel Mendler (bug#81561). In addition, it eliminates other causes of stale idle timers. * lisp/speedbar.el (speedbar-window-mode): Added a 'kill-buffer' handler. Removed a unnecessary 'speedbar-mode' invocation. (speedbar-window--close): New optional parameter used bye the 'kill-buffer' handler for 'speedbar-buffer'. (speedbar-refresh): Make sure that 'speedbar-set-timer' is called in 'speedbar-buffer'. (speedbar--speedbar-live-p): Make sure that 'speedbar-buffer' is still live. (speedbar-find-file) (speedbar-dir-follow) (speedbar-directory-buttons-follow) (speedbar-tag-find): Make sure that 'speedbar-set-timer' is called in 'speedbar-buffer'. --- lisp/speedbar.el | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/lisp/speedbar.el b/lisp/speedbar.el index 3e965d4286c..7edd3003d5f 100644 --- a/lisp/speedbar.el +++ b/lisp/speedbar.el @@ -1083,7 +1083,6 @@ speedbar-window-mode speedbar-last-selected-file nil) (set-buffer speedbar-buffer) - (speedbar-mode) ;; let's create the window (setq speedbar--window @@ -1102,14 +1101,19 @@ speedbar-window-mode (speedbar-update-contents) (speedbar-set-timer dframe-update-speed) + ;; handle kill-buffer + (add-hook 'kill-buffer-hook (lambda () (speedbar-window--close t)) nil t) + ;; hscroll (setq-local auto-hscroll-mode nil) ;; reset the selection variable (setq speedbar-last-selected-file nil) (select-window current-window)))) -(defun speedbar-window--close () - "Close `speedbar-window'." +(defun speedbar-window--close (&optional no-kill-buffer) + "Close `speedbar-window'. +When NO-KILL-BUFFER is not nil, close window without killing +'speedbar-buffer', which is useful for 'kill-buffer-hook'." (when (speedbar-window--live-p) (let ((current-window (selected-window))) ;; store the current window width @@ -1125,7 +1129,8 @@ speedbar-window--close dframe-attached-frame nil) (with-current-buffer speedbar-buffer (speedbar-set-timer nil)) - (kill-buffer speedbar-buffer) + (unless no-kill-buffer + (kill-buffer speedbar-buffer)) (setq speedbar-buffer nil) (when (and current-window (window-live-p current-window)) (select-window current-window))))) @@ -1518,7 +1523,8 @@ speedbar-refresh (speedbar-update-contents) (speedbar-stealthy-updates) ;; Reset the timer in case it got really hosed for some reason... - (speedbar-set-timer dframe-update-speed) + (with-current-buffer speedbar-buffer + (speedbar-set-timer dframe-update-speed)) (if (<= 1 speedbar-verbosity-level) (dframe-message "Refreshing speedbar...done")))) @@ -2740,7 +2746,7 @@ speedbar--speedbar-live-p ((and (speedbar-current-frame) (frame-live-p (speedbar-current-frame))) t) - ((speedbar-window--window-live-p) t) + ((speedbar-window--live-p) t) (t nil))) (defun speedbar-timer-fn () @@ -3440,7 +3446,8 @@ speedbar-find-file ;; Reset the timer with a new timeout when clicking a file ;; in case the user was navigating directories, we can cancel ;; that other timer. - (speedbar-set-timer dframe-update-speed)) + (with-current-buffer speedbar-buffer + (speedbar-set-timer dframe-update-speed))) (dframe-maybee-jump-to-attached-frame)) (defun speedbar-dir-follow (text _token indent) @@ -3457,7 +3464,8 @@ speedbar-dir-follow ;; in case. (let ((speedbar-smart-directory-expand-flag nil)) (speedbar-update-contents)) - (speedbar-set-timer dframe-update-speed) + (with-current-buffer speedbar-buffer + (speedbar-set-timer dframe-update-speed)) (setq speedbar-last-selected-file nil) (speedbar-stealthy-updates)) @@ -3520,7 +3528,8 @@ speedbar-directory-buttons-follow ;; update contents will change directory without ;; having to touch the attached frame. (speedbar-update-contents) - (speedbar-set-timer dframe-update-speed)) + (with-current-buffer speedbar-buffer + (speedbar-set-timer dframe-update-speed))) (defun speedbar-tag-file (text token indent) "Expand tags in file given by TOKEN when button TEXT was clicked. @@ -3558,7 +3567,8 @@ speedbar-tag-find ;; Reset the timer with a new timeout when clicking a file ;; in case the user was navigating directories, we can cancel ;; that other timer. - (speedbar-set-timer dframe-update-speed) + (with-current-buffer speedbar-buffer + (speedbar-set-timer dframe-update-speed)) (goto-char token) (run-hooks 'speedbar-visiting-tag-hook) (dframe-maybee-jump-to-attached-frame) -- 2.55.0