bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#62157: More control over the mouse behaviour in eglot


From: João Távora
Subject: bug#62157: More control over the mouse behaviour in eglot
Date: Mon, 13 Mar 2023 15:47:38 +0000

On Mon, Mar 13, 2023 at 7:22 AM Pedro Andres Aranda Gutierrez
<paaguti@gmail.com> wrote:
>
> When I edit Python with eglot,  mouse-1-down opens the eglot code
> actions menu when over a place where there is a possible action. I'd
> like to be able to define the mouse event to open the menu myself. In
> the same line, I'd like to control the items on the code actions mouse
> menu.

These are two separate requests.  I'll focus on the first one,
as the second one is obscure.  It probablyneeds its own separate
issue describing a reproducible observable example of what "item
control" is desired.

So, having mouse-1 for the binding to get code actions in diagnostics
is indeed not good, because it prevents point from being put on
a certain character using mouse-1, which should really nothappen.

Currently, to configure it, the user must place a certain property on
the symbols eglot-note eglot-warning eglot-error, which is not
easy at all.

Can you try this patch?  It also changes the default binding to
[mouse-2].

diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index 2491c86ea5b..256b4cd93ba 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -2084,15 +2084,18 @@ eglot--mode-line-format
 (defalias 'eglot--make-diag 'flymake-make-diagnostic)
 (defalias 'eglot--diag-data 'flymake-diagnostic-data)

+(defvar eglot-diagnostics-map
+  "Map active in Eglot-backed Flymake diagnostic overlays."
+  (let ((map (make-sparse-keymap)))
+    (define-key map [mouse-1] 'eglot-code-actions-at-mouse)
+    map))
+
 (cl-loop for i from 1
          for type in '(eglot-note eglot-warning eglot-error)
          do (put type 'flymake-overlay-control
                  `((mouse-face . highlight)
                    (priority . ,(+ 50 i))
-                   (keymap . ,(let ((map (make-sparse-keymap)))
-                                (define-key map [mouse-1]
-                                            (eglot--mouse-call
'eglot-code-actions))
-                                map)))))
+                   (keymap . ,eglot-diagnostics-map))))


 ;;; Protocol implementation (Requests, notifications, etc)
@@ -3335,6 +3338,9 @@ eglot-code-actions
         (eglot--read-execute-code-action actions server action-kind)
       actions)))

+(defalias 'eglot-code-actions-at-mouse (eglot--mouse-call 'eglot-code-actions)
+  "Like `eglot-code-actions', but intended for mouse events.")
+
 (defun eglot--read-execute-code-action (actions server &optional action-kind)
   "Helper for interactive calls to `eglot-code-actions'."
   (let* ((menu-items

João





reply via email to

[Prev in Thread] Current Thread [Next in Thread]