From e2ff77052da91e662bbd3cb19a742604db742d32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20T=C3=A1vora?= Date: Wed, 29 Jan 2025 08:33:54 +0000 Subject: [PATCH] Eglot: in eglot-code-action-indications, make 'margin' interactive Didn't know it was possible, thanks to Ergus 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. --- lisp/progmodes/eglot.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 48b1d785d8e..e7b50d25bb5 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -595,7 +595,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))))))) @@ -2459,6 +2458,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.")