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#65578: Eglot with mouse Date: Mon, 28 Aug 2023 10:20:12 +0100 Message-ID: <875y4zbk1f.fsf@gmail.com> References: <86zg2beibp.fsf@mail.linkov.net> 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="23132"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: dmitry@gutov.dev, 65578@debbugs.gnu.org To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Aug 28 11:18:12 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 1qaYNw-0005oi-6A for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 28 Aug 2023 11:18:12 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qaYNl-0000JU-7y; Mon, 28 Aug 2023 05:18:01 -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 1qaYNg-0000HW-J2 for bug-gnu-emacs@gnu.org; Mon, 28 Aug 2023 05:17:57 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qaYNg-0005o3-6f for bug-gnu-emacs@gnu.org; Mon, 28 Aug 2023 05:17:56 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qaYNm-00049Q-F0 for bug-gnu-emacs@gnu.org; Mon, 28 Aug 2023 05:18:02 -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, 28 Aug 2023 09:18:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65578 X-GNU-PR-Package: emacs Original-Received: via spool by 65578-submit@debbugs.gnu.org id=B65578.169321426615935 (code B ref 65578); Mon, 28 Aug 2023 09:18:02 +0000 Original-Received: (at 65578) by debbugs.gnu.org; 28 Aug 2023 09:17:46 +0000 Original-Received: from localhost ([127.0.0.1]:46985 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qaYNW-00048x-2O for submit@debbugs.gnu.org; Mon, 28 Aug 2023 05:17:46 -0400 Original-Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]:44495) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qaYNT-00048h-Rx for 65578@debbugs.gnu.org; Mon, 28 Aug 2023 05:17:44 -0400 Original-Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-3fee600dce6so27938175e9.1 for <65578@debbugs.gnu.org>; Mon, 28 Aug 2023 02:17:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693214250; x=1693819050; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=CJlKhfMU64Rjy+kkHugSVpnoxvCYyplHAas7+SNOG6w=; b=DvJBCgiOLuXjBc/snD/ZZoPej+sPwO5DCgUgXf3W0ZjFHTqwMNZZj4gpCltomdWqPB 5c7fkYkgXRWsdvh9tOyDtgW7IBhsszYEwL+vGs7Ux2IxLMX1zwz+WtBIZ98eiwYv5Geq McooXgHgFnj5jZnuDQ8u6f0HKfa/VL+SWukaVFzntF52wVaCCSIrPsxVgx1Xj9+QjmrU qAn0Psrw1UftrU1qD7ES4LJ4OuQ1bysN3WNQt/uH/hd4wcly1hOS9VGzs5TXrAY5MRz0 5r3m7coZ7OTl6kAzXtgXg0KvoQYnOh7T8B6M5+zL/MfaoCe+skEA/LbnV9TkNS88TwCJ oe3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693214250; x=1693819050; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=CJlKhfMU64Rjy+kkHugSVpnoxvCYyplHAas7+SNOG6w=; b=ch1y0PWRAnotEz6aIEsW5SvbQSn4m/RCpFzn2Hp/8YOOIHfK5IdsZscomit50ymXTz 2sTj30LAhzuUOrg7/vE/wSTnmusA7NWPrrrd1r5wYe0tnkmziCjwpuJV32eZB3NELJj5 ZyVCbiEo3tYbjqeNJkm0DW6xBLy+IPheU16BFiQttTIJjLEO+YlQ3fNA+RyIZniCm09+ eGfoLso5T1W/Kz6HXmsA11oACsunlhG2XvF++2XTLr6Skrtj+H7eaDrloyqzQ8lm5j/t XL1k+MEmftNt3ds4S1ZJbbHLHhnAzieWG1P5FaZzR0na6G6F4CpEh1NJnc+Vr+mO88D+ drVQ== X-Gm-Message-State: AOJu0YyPFSi2isMKIDGu1NMOPHQbARw3ayicrbouXuYCQ4Eegc5NM4qt inpfP0a9bSpahu4z3/Z1X9kEnLgR/rh+pg== X-Google-Smtp-Source: AGHT+IHSiOHd1VSLNyE5vSmQKNMFxA6JEGibkgngTEe+XX3NkIQosNo9tnRJ67FTUhQCh0Hdkvt9rw== X-Received: by 2002:a05:600c:ace:b0:401:4c61:90ac with SMTP id c14-20020a05600c0ace00b004014c6190acmr8864896wmr.11.1693214250388; Mon, 28 Aug 2023 02:17:30 -0700 (PDT) Original-Received: from krug ([87.196.73.66]) by smtp.gmail.com with ESMTPSA id r9-20020adff709000000b0031ad5a54bedsm10081205wrp.9.2023.08.28.02.17.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Aug 2023 02:17:30 -0700 (PDT) In-Reply-To: <86zg2beibp.fsf@mail.linkov.net> (Juri Linkov's message of "Mon, 28 Aug 2023 10:13:58 +0300") 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:268610 Archived-At: Juri Linkov writes: > X-Debbugs-CC: Jo=C3=A3o T=C3=A1vora > > 0. emacs -Q > 1. enable context-menu-mode > 2. enable eglot in a suitable buffer > 3. move point to one identifier > 4. click the right mouse button on another identifier > 5. in the context menu click "Find Definition" > > The problem is that a wrong identifier is visited. > > Whereas 'xref-find-definitions-at-mouse' takes care > about getting the right identifier at the clicked position, > Eglot returns a fictitious identifier "LSP identifier at point" > that can't be used to find the identifier at the mouse click. I don't think the name Eglot gives to the identifier matters here. What matters is that the LSP request is made with the correct buffer position (where the user clicked). So if 'xref-find-definitions-at-mouse' already has logic to protect that, it should work. > xref-find-definitions-at-mouse uses save-excursion with > mouse-set-point before calling xref-backend-identifier-at-point. > But the same save-excursion with mouse-set-point can't be added > around xref-find-definitions because save-excursion will restore > the original position after visiting the found identifier. Alas, somehow, the position obtained when mouse is in the correct spot in the first step must be recorded somehow and survive until the second step. Else, with LSP, it just won't work, not in the near future at least. I'd say this is something to be changed in Xref. > Also tried to add xref-find-definitions-at-mouse to the list > xref-prompt-for-identifier, no effect. > > Then tried to remove '(xref--prompt-p this-command)' > from 'xref-backend-identifier-at-point ((_backend (eql eglot)))'. > This fixed xref-find-definitions-at-mouse, but still > doesn't work for xref-find-references-at-mouse. > Also removing '(xref--prompt-p this-command)' has such a strange effect > that it started to find approximate fuzzy matches that sound like > the original identifier. I don't think any of this is the solution. This is a more-or-less typical case where the workhorse function non-mouse function called by the mouse function does too much. An elegant (perhaps verbose) solution would separate the definition-requesting from the definition-visiting parts of the former, and then the mouse function would use the two parts separately. But in practice I think something like a variable shared set in the interactive spec and read in the function body. Or maybe a text property in the dummy "LSP Identifier at point" string. Let's see what Dmitry has to say. Jo=C3=A3o