From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Newsgroups: gmane.emacs.bugs Subject: bug#62157: More control over the mouse behaviour in eglot Date: Mon, 13 Mar 2023 15:47:38 +0000 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7893"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 62157@debbugs.gnu.org To: Pedro Andres Aranda Gutierrez Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Mar 13 16:48:32 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pbkPY-0001pT-KZ for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 13 Mar 2023 16:48:32 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pbkP8-0003ec-1O; Mon, 13 Mar 2023 11:48:06 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pbkP5-0003dZ-2L for bug-gnu-emacs@gnu.org; Mon, 13 Mar 2023 11:48:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pbkP4-0006sD-IM for bug-gnu-emacs@gnu.org; Mon, 13 Mar 2023 11:48:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pbkP3-0003Nk-UE for bug-gnu-emacs@gnu.org; Mon, 13 Mar 2023 11:48:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 13 Mar 2023 15:48:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62157 X-GNU-PR-Package: emacs Original-Received: via spool by 62157-submit@debbugs.gnu.org id=B62157.167872247712964 (code B ref 62157); Mon, 13 Mar 2023 15:48:01 +0000 Original-Received: (at 62157) by debbugs.gnu.org; 13 Mar 2023 15:47:57 +0000 Original-Received: from localhost ([127.0.0.1]:35451 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pbkOz-0003N0-3i for submit@debbugs.gnu.org; Mon, 13 Mar 2023 11:47:57 -0400 Original-Received: from mail-oa1-f52.google.com ([209.85.160.52]:38842) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pbkOx-0003M8-Li for 62157@debbugs.gnu.org; Mon, 13 Mar 2023 11:47:55 -0400 Original-Received: by mail-oa1-f52.google.com with SMTP id 586e51a60fabf-176d1a112bfso14194477fac.5 for <62157@debbugs.gnu.org>; Mon, 13 Mar 2023 08:47:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678722470; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=WpXBpghD+BmcSovFoIwsvcbcERM8SXZYVKBEzMKA9PU=; b=WCaUbtP5178VhahvjKjXqdJUayE8Uij9Dj4RLJZFQBRwyJCAMUSXku5Pp9TFNeJ6ZM SfYKTPJEbeW0zklCcZbP0f/1ilZIcAD8zOGjRtgLeCqfU5D9UTYT6m8O+wv+Zoc2PvuG p0aIZdvkDHOlpzxszfx5aWaYw5poe44X2vvLqm3NqB8Ja6jsSRmxTTHmL/gqQ0/Ge396 H314nYOmFBQffGHiCEezSsNPNsoEuTvbbW9QSJcK+L+4/IzqPio3Cag54vBAASfscjlw kj+0X2YywDHRwVNzxbBUid4OKpuz6aHlepM5qBklcn4WwJ8C1vl5dlmw9j8N/wrkYwCu qKVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678722470; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WpXBpghD+BmcSovFoIwsvcbcERM8SXZYVKBEzMKA9PU=; b=0/OR3C6HHavtozAUMdCTQ5wA0oP7ZYr5IkTmnBSdhC7Kqds31qfjlPaPyZHa4yW+RF VwmYAqQHWz57RccOBmxGneP+dC/2Js4egvAtyEP8HJoBg7MtwzuD3Yj68ceQi/XnSECR QuyP3of6SlKGlnSKwfZs6gXFKtX+okcSyu2pDY2DCqD045bnDyozPyOu2Bdmp2xyXa8c 31sO3GbfhJhdkXDyH2J+DUHL2EypRu/s1UbOAAXLqKqm09boJxdTWHNZYD94swT/yyma 63H1pd/zk9hH5Slk73gU21cLsXKN19xCWxZ9ZJ5/H1DQtVGUtzpQPraBEB+wanYecYZb P41Q== X-Gm-Message-State: AO0yUKVKme60PhsaBu13tgmc3RITN/74DXhrfhh+9so+Ubriaq86kUas 1hWTRKJueP/t0XHRSR28cCtKj41te857XglAYqI= X-Google-Smtp-Source: AK7set+miJxT/mbHu6mnnS2YIseJIjTmDj+pku12+7EoAsbkfm+TvQ+7sItq3IJf11FbWHPF8w3Rwk7JRBpjKXeOOQM= X-Received: by 2002:a05:6870:7729:b0:176:3897:6928 with SMTP id dw41-20020a056870772900b0017638976928mr12535887oab.5.1678722469844; Mon, 13 Mar 2023 08:47:49 -0700 (PDT) In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:257910 Archived-At: On Mon, Mar 13, 2023 at 7:22=E2=80=AFAM Pedro Andres Aranda Gutierrez 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-acti= ons) + "Like `eglot-code-actions', but intended for mouse events.") + (defun eglot--read-execute-code-action (actions server &optional action-ki= nd) "Helper for interactive calls to `eglot-code-actions'." (let* ((menu-items Jo=C3=A3o