[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 4064985b807 2/7: Fix speedbar help-echo in erc-nickbar-mode
From: |
F. Jason Park |
Subject: |
master 4064985b807 2/7: Fix speedbar help-echo in erc-nickbar-mode |
Date: |
Fri, 24 Nov 2023 16:43:02 -0500 (EST) |
branch: master
commit 4064985b807e00432775543798180e7b81eb5ea9
Author: F. Jason Park <jp@neverwas.me>
Commit: F. Jason Park <jp@neverwas.me>
Fix speedbar help-echo in erc-nickbar-mode
* lisp/erc/erc-speedbar.el (erc-speedbar-buttons): "Spoof"
`dframe-help-echo-function' in channel buffers to get around the fact
that we're not using the real speedbar frame.
(erc-speedbar--fmt-sentinel): New variable.
(erc-speedbar-expand-channel): Use cached channel-mode string for mode
item. Use button chars to mark mode and topic items and move verbose
labels into mouse-hover text. Also set face for mode and topic.
(erc-speedbar-item-info): Look for `speedbar-token' as a fallback even
when the primary pattern doesn't match. If the value's contents are
structured like a `format' function call, use them.
(erc-speedbar--emulate-sidebar): Add comment about speedbar setting
everything globally in older Emacsen. (Bug#63595)
---
lisp/erc/erc-speedbar.el | 53 +++++++++++++++++++++++++-----------------------
1 file changed, 28 insertions(+), 25 deletions(-)
diff --git a/lisp/erc/erc-speedbar.el b/lisp/erc/erc-speedbar.el
index ab06de6a42c..93be7b9f074 100644
--- a/lisp/erc/erc-speedbar.el
+++ b/lisp/erc/erc-speedbar.el
@@ -135,6 +135,14 @@ This will add a speedbar major display mode."
(erase-buffer)
(let (serverp chanp queryp)
(with-current-buffer buffer
+ ;; The function `dframe-help-echo' checks the default value of
+ ;; `dframe-help-echo-function' when deciding whether to visit
+ ;; the buffer and fire the callback. This works in normal
+ ;; speedbar frames because the event handler runs in the
+ ;; `window-buffer' of the active frame. But in our hacked
+ ;; version, where the frame is hidden, `speedbar-item-info'
+ ;; never runs without this workaround.
+ (setq-local dframe-help-echo-function #'ignore)
(setq serverp (erc--server-buffer-p))
(setq chanp (erc-channel-p (erc-default-target)))
(setq queryp (erc-query-buffer-p)))
@@ -212,6 +220,11 @@ This will add a speedbar major display mode."
(buffer-name buffer) 'erc-speedbar-goto-buffer buffer nil
depth)))
+(defconst erc-speedbar--fmt-sentinel (gensym "erc-speedbar-")
+ "Symbol for identifying a nonstandard `speedbar-token' text property.
+When encountered, ERC assumes the value's tail contains
+`format'-compatible args.")
+
(defun erc-speedbar-expand-channel (text channel indent)
"For the line matching TEXT, in CHANNEL, expand or contract a line.
INDENT is the current indentation level."
@@ -221,35 +234,17 @@ INDENT is the current indentation level."
(speedbar-with-writable
(save-excursion
(end-of-line) (forward-char 1)
- (let ((modes (with-current-buffer channel
- (concat (apply #'concat
- erc-channel-modes)
- (cond
- ((and erc-channel-user-limit
- erc-channel-key)
- (if erc-show-channel-key-p
- (format "lk %.0f %s"
- erc-channel-user-limit
- erc-channel-key)
- (format "kl %.0f" erc-channel-user-limit)))
- (erc-channel-user-limit
- ;; Emacs has no bignums
- (format "l %.0f" erc-channel-user-limit))
- (erc-channel-key
- (if erc-show-channel-key-p
- (format "k %s" erc-channel-key)
- "k"))
- (t "")))))
+ (let ((modes (buffer-local-value 'erc--mode-line-mode-string channel))
(topic (erc-controls-interpret
(with-current-buffer channel erc-channel-topic))))
- (speedbar-make-tag-line
- 'angle ?i nil nil
- (concat "Modes: +" modes) nil nil nil
- (1+ indent))
+ (when modes
+ (speedbar-make-tag-line
+ 'angle ?m nil (list erc-speedbar--fmt-sentinel "Mode: %s" modes)
+ modes nil nil 'erc-notice-face (1+ indent)))
(unless (string= topic "")
(speedbar-make-tag-line
- 'angle ?i nil nil
- (concat "Topic: " topic) nil nil nil
+ 'angle ?t nil (list erc-speedbar--fmt-sentinel "Topic: %s" topic)
+ topic nil nil 'erc-notice-face
(1+ indent)))
(unless (pcase erc-speedbar-hide-mode-topic
('nil 'show)
@@ -428,6 +423,13 @@ The INDENT level is ignored."
(message "%s: %s" txt (car data)))
((bufferp data)
(message "Channel: %s" txt))
+ ;; Print help if line has a non-standard ([-+?=]) button
+ ;; char and a `speedbar-token' property with a known CAR.
+ ((and-let* ((p (text-property-not-all (pos-bol) (pos-eol)
+ 'speedbar-token nil))
+ (v (get-text-property p 'speedbar-token))
+ ((eq erc-speedbar--fmt-sentinel (car v))))
+ (apply #'message (cdr v))))
(t
(message "%s" txt)))))
@@ -469,6 +471,7 @@ The INDENT level is ignored."
(cl-assert (eq speedbar-buffer (current-buffer)))
(cl-assert (eq speedbar-frame (selected-frame)))
(setq erc-speedbar--hidden-speedbar-frame speedbar-frame
+ ;; In Emacs 27, this is not `local-variable-if-set-p'.
dframe-controlled #'erc-speedbar--dframe-controlled)
(add-hook 'window-configuration-change-hook
#'erc-speedbar--emulate-sidebar-set-window-preserve-size nil t)
- master updated (2fca889cfb4 -> 2ed9c9f1b32), F. Jason Park, 2023/11/24
- master 3c9cba9df3d 3/7: Don't inherit properties when refreshing ERC's prompt, F. Jason Park, 2023/11/24
- master 2ed9c9f1b32 7/7: Optionally allow substitution patterns in erc-prompt, F. Jason Park, 2023/11/24
- master 5bc84a0c9e4 1/7: Cache UI string for channel modes in ERC, F. Jason Park, 2023/11/24
- master 4064985b807 2/7: Fix speedbar help-echo in erc-nickbar-mode,
F. Jason Park <=
- master 0d6c8d41ab7 4/7: Use overlay instead of text prop to hide ERC's prompt, F. Jason Park, 2023/11/24
- master 8bb68a522f3 5/7: Optionally align prompt to prefix in erc-fill-wrap, F. Jason Park, 2023/11/24
- master 7cbe6ae7124 6/7: Add merged-message indicator option for erc-fill-wrap, F. Jason Park, 2023/11/24