Subject: bug#63595: 30.0.50; ERC 5.6: Add buffer-list and nick-list modules

From: "J.P." <[email-masked]>
Date: Sun, 31 Mar 2024 18:42:15 -0700

It's been reported that the nickbar (speedbar) window doesn't display
the cursor on at least one user's setup. I've found this to be true by
default on non-graphic displays. The attached patch should fix the
latter regression. As to whether it also fixes the reporter's issue is
TBD.

It's also been reported that the dframe timer can signal a

  (wrong-type-argument window-live-p nil)

which then gets trapped by the

  (with-demoted-errors "DFRAME TIMER ERROR: %S"...)

in `dframe-timer-fn'. Unfortunately, remediation is trickier here
because we've got to inspect calls to `window-live-p' stemming from
`speedbar-timer-fn', possibly via `erc-speedbar-insert-user'. (What we
really need is a backtrace from the bug reporter.)

>From 910b6981da743bdc661241f54e26e9b163f239d1 Mon Sep 17 00:00:00 2001
From: "F. Jason Park" <[email-masked]>
Date: Sun, 31 Mar 2024 16:32:44 -0700
Subject: [PATCH] [5.6] Fix invisible erc-speedbar cursor in text terminals

* lisp/erc/erc-speedbar.el
(erc-speedbar--reset-last-ran-on-timer): Use `with-current-buffer'
instead of `setf' and `buffer-local-value'.
(erc-nickbar-mode, erc-nickbar-enable, erc-nickbar-disable)
(erc-speedbar-toggle-nicknames-window-lock): Revise doc string.
(erc-speedbar-toggle-nicknames-window-lock): Set `cursor-type' in
speedbar buffer.
(erc-nickbar-toggle-nicknames-window-lock): New function alias.  Note
that this name flouts traditional library namespacing conventions.
* lisp/erc/erc-status-sidebar.el (erc-status-sidebar-get-window): Use
`cursor-type' instead of `internal-show-cursor'.
(Bug#63595)
---
 lisp/erc/erc-speedbar.el       | 23 ++++++++++++++---------
 lisp/erc/erc-status-sidebar.el |  2 +-
 2 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/lisp/erc/erc-speedbar.el b/lisp/erc/erc-speedbar.el
index a81a3869436..b156f61d5d9 100644
--- a/lisp/erc/erc-speedbar.el
+++ b/lisp/erc/erc-speedbar.el
@@ -566,9 +566,8 @@ erc-speedbar--run-timer-on-post-insert
 (defun erc-speedbar--reset-last-ran-on-timer ()
   "Reset `erc-speedbar--last-ran'."
   (when speedbar-buffer
-    (with-suppressed-warnings ((obsolete buffer-local-value)) ; <=29
-      (setf (buffer-local-value 'erc-speedbar--last-ran speedbar-buffer)
-            (current-time)))))
+    (with-current-buffer speedbar-buffer
+      (setq erc-speedbar--last-ran (current-time)))))
 
 ;;;###autoload(autoload 'erc-nickbar-mode "erc-speedbar" nil t)
 (define-erc-module nickbar nil
@@ -578,10 +577,12 @@ nickbar
 separate frame.  When disabling, close the window or, with a
 negative prefix arg, destroy the session.
 
-WARNING: this module may produce unwanted side effects, like the
-raising of frames or the stealing of input focus.  If you witness
-such a thing and can reproduce it, please file a bug report with
-\\[erc-bug]."
+For controlling whether the speedbar window is selectable with
+`other-window', see `erc-nickbar-toggle-nicknames-window-lock'.
+Note that during initialization, this module may produce unwanted
+side effects, like the raising of frames or the stealing of input
+focus.  If you witness such a thing and can reproduce it, please
+file a bug report with \\[erc-bug]."
   ((add-hook 'erc--setup-buffer-hook #'erc-speedbar--ensure)
    (add-hook 'erc-insert-post-hook #'erc-speedbar--run-timer-on-post-insert)
    (add-hook 'speedbar-timer-hook #'erc-speedbar--reset-last-ran-on-timer)
@@ -638,8 +639,8 @@ erc-speedbar--dframe-controlled
 
 (defun erc-speedbar-toggle-nicknames-window-lock (arg)
   "Toggle whether nicknames window is selectable with \\[other-window].
-When arg is a number, lock the window if non-negative, otherwise
-unlock."
+When ARG is a number, lock the window if non-negative.  Otherwise,
+unlock the window."
   (interactive "P")
   (unless erc-nickbar-mode
     (user-error "`erc-nickbar-mode' inactive"))
@@ -648,10 +649,14 @@ erc-speedbar-toggle-nicknames-window-lock
                      ((integerp arg) nil)
                      (t (not (window-parameter window
                                                'no-other-window))))))
+      (with-current-buffer speedbar-buffer
+        (setq cursor-type (not val)))
       (set-window-parameter window 'no-other-window val)
       (unless (numberp arg)
         (message "nick-window: %s" (if val "protected" "selectable"))))))
 
+(defalias 'erc-nickbar-toggle-nicknames-window-lock
+  #'erc-speedbar-toggle-nicknames-window-lock)
 
 ;;;; Nicks integration
 
diff --git a/lisp/erc/erc-status-sidebar.el b/lisp/erc/erc-status-sidebar.el
index b7695651e4c..dcdef7cfafc 100644
--- a/lisp/erc/erc-status-sidebar.el
+++ b/lisp/erc/erc-status-sidebar.el
@@ -192,7 +192,7 @@ erc-status-sidebar-get-window
       (set-window-parameter sidebar-window 'no-delete-other-windows t)
       ;; Don't cycle to this window with `other-window'.
       (set-window-parameter sidebar-window 'no-other-window t)
-      (internal-show-cursor sidebar-window nil)
+      (setq cursor-type nil)
       (set-window-fringes sidebar-window 0 0)
       ;; Set a custom display table so the window doesn't show a
       ;; truncation symbol when a channel name is too big.
-- 
2.44.0