From: plugd Date: Wed, 28 Jul 2021 16:49:59 +0000 (+0200) Subject: Added clickable contexts. X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?a=commitdiff_plain;h=056830a869c9320dc05ac53b223f546f243f68c6;p=lurk.git Added clickable contexts. --- diff --git a/lurk.el b/lurk.el index 447f5f5..535b990 100644 --- a/lurk.el +++ b/lurk.el @@ -321,14 +321,13 @@ portion of the source component of the message, as LURK doesn't use this.") (defun lurk-set-current-context (context) (setq lurk-current-context context) (lurk-highlight-context context) + (lurk-render-prompt) (if lurk-zoomed (lurk-zoom-in lurk-current-context))) (defun lurk-cycle-contexts (&optional rev) (if lurk-current-context - (progn - (lurk-set-current-context (lurk-get-next-context rev)) - (lurk-render-prompt)) + (lurk-set-current-context (lurk-get-next-context rev)) (lurk-display-error "No channels joined."))) @@ -464,6 +463,17 @@ portion of the source component of the message, as LURK doesn't use this.") (with-selected-window window (recenter -1)))))) +(defun lurk-make-context-button (context &optional label) + (with-temp-buffer + (insert-text-button (or label context) + 'action #'lurk--context-button-action + 'follow-link t + 'help-echo "Switch context.") + (buffer-string))) + +(defun lurk--context-button-action (button) + (lurk-set-current-context (button-get button 'context))) + (defun lurk-display-string (context prefix &rest strings) (with-current-buffer "*lurk*" (save-excursion @@ -503,8 +513,10 @@ portion of the source component of the message, as LURK doesn't use this.") context (propertize (pcase (lurk-get-context-type to) - ('channel (concat to " <" from ">")) - ('nick (concat "[" from " -> " to "]")) + ('channel (concat + (lurk-make-context-button to) + " <" from ">")) + ('nick (lurk-make-context-button context (concat "[" from " -> " to "]"))) (_ (error "Unsupported context type"))) 'face (lurk-get-context-facelist context)) @@ -517,7 +529,7 @@ portion of the source component of the message, as LURK doesn't use this.") (lurk-display-string context (propertize - (concat context " * " from) + (concat (lurk-make-context-button context) " * " from) 'face (lurk-get-context-facelist context)) action-text)))