Subject: Re: bug#78106: [Feature Request] EGLOT: Optionally make code action indications use mouse clicks

From: Elijah Gabe Pérez <[email-masked]>
Date: Wed, 30 Apr 2025 13:40:19 -0600

João Távora <[email-masked]> writes:

> Good ideas. Patches welcome, the shorter the better, of course.

Done:

>From f295ce56b91ba0bde4e711a740bdf0db11ed5cd5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?El=C3=ADas=20Gabriel=20P=C3=A9rez?= <[email-masked]>
Date: Wed, 30 Apr 2025 13:21:29 -0600
Subject: [PATCH] Add keybinding to eglot code actions help-echo.

* lisp/progmodes/eglot.el (eglot-mode-line-action-suggestion):
Allow mouse-clicks in mode line for code actions.
(eglot-code-action-suggestion): Add
`eglot-code-actions-at-mouse' keybinding to help-echo.
---
 lisp/progmodes/eglot.el | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index 530fd4aa5b8..ea01859425a 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -2531,7 +2531,13 @@ eglot-mode-line-action-suggestion
   '(:eval
     (when (and (memq 'mode-line eglot-code-action-indications)
                (overlay-buffer eglot--suggestion-overlay))
-      (overlay-get eglot--suggestion-overlay 'eglot--suggestion-tooltip)))
+      (eglot--mode-line-props
+       eglot-code-action-indicator
+       'help-echo
+       `((mouse-1
+          eglot-code-actions-at-mouse
+          ,(plist-get (aref (overlay-get eglot--suggestion-overlay 'eglot--actions) 0) :title)))
+       "Execute code actions at point\n")))
   "Eglot mode line construct for at-point code actions.")
 
 (add-to-list
@@ -4130,7 +4136,7 @@ eglot-code-action-suggestion
            (when (cl-plusp (length actions))
              (setq blurb
                    (substitute-command-keys
-                    (eglot--format "\\[eglot-code-actions]: %s"
+                    (eglot--format "\\[eglot-code-actions] or \\[eglot-code-actions-at-mouse]: %s"
                                    (plist-get (aref actions 0) :title))))
              (if (>= (length actions) 2)
                  (setq blurb (concat blurb (format " (and %s more actions)"
-- 
2.49.0

-- 
                                          - E.G via GNU Emacs and Org.