GNU bug report logs - #78106
[Feature Request] EGLOT: Optionally make code action indications use mouse clicks

Previous Next

Package: emacs;

Reported by: João Távora <joaotavora <at> gmail.com>

Date: Mon, 28 Apr 2025 07:22:01 UTC

Severity: wishlist

Done: João Távora <joaotavora <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


Message #26 received at 78106 <at> debbugs.gnu.org (full text, mbox):

From: Elijah Gabe Pérez <eg642616 <at> gmail.com>
To: João Távora <joaotavora <at> gmail.com>
Cc: 78106 <at> debbugs.gnu.org
Subject: Re: bug#78106: [Feature Request] EGLOT: Optionally make code action
 indications use mouse clicks
Date: Thu, 01 May 2025 18:04:26 -0600
[Message part 1 (text/plain, inline)]
João Távora <joaotavora <at> gmail.com> writes:

> Elijah Gabe Pérez <eg642616 <at> gmail.com> writes:
> Your ideas are good, but did you test your patch thoroughly?  I did, see
> comments below.
>
>>                 (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")))
>
> This removes the face from the mode-line indication and uses 'help-echo.
> Probably should be eglot-code-action-indicator-face.

Oops, sorry, I thought that function was a kind of `propertize'.

> Also the blurb looks like.
>
>    Execute code actions at point. mouse-1: extract subexpression to variable
>
> Maybe it should be:
>
>    mouse-1: execute code actions at point
>
> since your second sentence is misleading, as it will actually pop a
> menu, not execute the actual action right away.

I agree, fixed.

>>  (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"
>
> This isn't right, did you test this?  The second part shows the user
> instructions that when followed do not do what they say they do.  For me
> it says:
>
>    <f2> or M-x eglot-code-actions-at-mouse: extract subexpression to variable
>
> I have M-x eglot-code-actions bound to <f2> of course.  In my case it
> should say 'mouse-2' as that is the (default) button that pops up a
> menu.  So it should be
>
>   <f2>: extract subexpression to variable, mouse-2: execute code actions
>   at point
>
> Needless to say if I press 'M-x eglot-code-actions-at-mouse' it doesn't
> work, and I get an error saying there is no mouse event when invoking
> the command.  So substitute-command-keys might not be a solution here,
> as you can't easily get it to be aware of the special map and not say
> anything if nothing is bound there.
>
> Even more problematic is the fact that it shows the changed blurb in the
> ElDoc area, in situations where the mouse (if there even is one!) is not
> hovering on the margin or fringe (if there even are fringes).
>
> So this isn't a straightforward problem to solve, which probably
> explains why I left this minor detail out.
>
> I also feel that if the code to do this grows too complicated, it's
> better to add generic utility to Emacs to solve these problems and
> conditionally use it in eglot.el with a 'fboundp' check.

A way I found for achieve this is only (re)propertizing the blurb
help-echo for `margin' and `nearby' options (like the patch below).
This let eldoc area unchanged (i tested it).

I used `substitute-command-keys' only for get the mouse-1/2/3 button for
margin, but since i see this is problematic, I've changed it to only
display `mouse-2'.

The help-echo for `margin' and `nearby' now should be displayed as:
"M-x eglot-code-actions: remove #include directive (and 1 more actions),
mouse-2: execute code actions at point"

and for the mode-line: "mouse-1: Execute code actions at point."

[0001-Add-keybinding-to-eglot-code-actions-help-echo.patch (text/x-patch, attachment)]
[Message part 3 (text/plain, inline)]
-- 
                                          - E.G via GNU Emacs and Org.

This bug report was last modified 14 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.