]> git.eshelyaron.com Git - emacs.git/commitdiff
Eglot: in eglot-code-action-indications, make 'margin' interactive
authorJoão Távora <joaotavora@gmail.com>
Wed, 29 Jan 2025 08:33:54 +0000 (08:33 +0000)
committerEshel Yaron <me@eshelyaron.com>
Thu, 30 Jan 2025 18:13:17 +0000 (19:13 +0100)
Didn't know it was possible, thanks to Ergus <spacibba@aol.com> for the
tip about binding [left-margin mouse-2] in the keymap.

The technique adopted in 'eglot-mouse-call' possibly still doesn't work
very well if the margin thing we're clicking on is not on the line point
is currently on.  But we don't have that problem (yet?) because LSP
action suggestions function mostly on a "at point" basis.

* lisp/progmodes/eglot.el (eglot-code-action-indications): Adjust docstring.
(eglot--mouse-call): Don't go anywhere except in text area.
(eglot-diagnostics-map): Bind eglot-mouse-actions to left-margin.

(cherry picked from commit e2ff77052da91e662bbd3cb19a742604db742d32)

lisp/progmodes/eglot.el

index 0d60cb972efcd004379b7c524a5f650b145caa00..e94bdc1ce5d05bc4cb1f25cb94eb3458a5009c93 100644 (file)
@@ -593,7 +593,6 @@ Note additionally:
 
 - `margin' and `nearby' are incompatible.  If both are specified,
   the latter takes priority;
-- `margin's indicator is not interactive;
 - `mode-line' only works if `eglot-mode-line-action-suggestion' exists in
   `eglot-mode-line-format' (which see)."
   :type '(set
@@ -2214,8 +2213,8 @@ If it is activated, also signal textDocument/didOpen."
     (interactive "e")
     (let ((start (event-start event))) (with-selected-window (posn-window start)
                                          (save-excursion
-                                           (goto-char (or (posn-point start)
-                                                          (point)))
+                                           (unless (posn-area start)
+                                             (goto-char (posn-point start)))
                                            (call-interactively what)
                                            (when update-mode-line
                                              (force-mode-line-update t)))))))
@@ -2449,6 +2448,7 @@ still unanswered LSP requests to the server\n"))))
 (defvar eglot-diagnostics-map
   (let ((map (make-sparse-keymap)))
     (define-key map [mouse-2] #'eglot-code-actions-at-mouse)
+    (define-key map [left-margin mouse-2] #'eglot-code-actions-at-mouse)
     map)
   "Keymap active in Eglot-backed Flymake diagnostic overlays.")