From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Alan Donovan via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#62116: RFE: eglot: support window.showDocument LSP RPC Date: Fri, 5 May 2023 13:35:49 -0400 Message-ID: References: <87jzznxx8f.fsf@gmail.com> <83fsabwhpg.fsf@gnu.org> <87v8j7vy48.fsf@gmail.com> <83r0tuv62t.fsf@gnu.org> <874jp8gu8a.fsf@betli.tmit.bme.hu> <838re3jowg.fsf@gnu.org> <87ttwqsow9.fsf@gmail.com> <87pm7esnl0.fsf@gmail.com> Reply-To: Alan Donovan 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="13962"; mail-complaints-to="usenet@ciao.gmane.io" Cc: sebastian.poeplau@mailbox.org, Felician Nemeth , 62116@debbugs.gnu.org To: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri May 05 19:37:18 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 1puzMr-0003Rj-WC for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 05 May 2023 19:37:18 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1puzMe-0006m0-BG; Fri, 05 May 2023 13:37:04 -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 1puzMc-0006lr-NX for bug-gnu-emacs@gnu.org; Fri, 05 May 2023 13:37:02 -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 1puzMc-0000BU-FA for bug-gnu-emacs@gnu.org; Fri, 05 May 2023 13:37:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1puzMb-0007Zn-Uh for bug-gnu-emacs@gnu.org; Fri, 05 May 2023 13:37:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Donovan Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 05 May 2023 17:37:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62116 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 62116-submit@debbugs.gnu.org id=B62116.168330817029054 (code B ref 62116); Fri, 05 May 2023 17:37:01 +0000 Original-Received: (at 62116) by debbugs.gnu.org; 5 May 2023 17:36:10 +0000 Original-Received: from localhost ([127.0.0.1]:57376 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1puzLm-0007YY-55 for submit@debbugs.gnu.org; Fri, 05 May 2023 13:36:10 -0400 Original-Received: from mail-pl1-f182.google.com ([209.85.214.182]:37335) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1puzLi-0007Xz-H4 for 62116@debbugs.gnu.org; Fri, 05 May 2023 13:36:09 -0400 Original-Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-1aae90f5ebcso610655ad.1 for <62116@debbugs.gnu.org>; Fri, 05 May 2023 10:36:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1683308161; x=1685900161; 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=9LKXfXZKS6XfHWVol50zRC0ePR/XTxKdKmAlfazSwDA=; b=UW+SVOOI+XA5+4TJ1hlVdjMJdWiUNrlaHlE9T2x4tFRPrKuVkRG9lQFdeh0eZCFCEZ oE5pMFoDmPXLlKy1CCZTcV1Rj5IF7UQWgP6Lee8NAo7pB5Khm56sPDNAM0vQcfWaH0QZ DD8jfaYVDJDnaa0cwPoVMH4v82uMHsgUPR9dVokhSymJ+nopzluEXbbSAR8ehx/xwvut q8QvtgtheUBd+msighjaUNoktNbVgVgvORN/NBx29HW1bZiAANWIbogqk7aWZuQKOAJh cuVdp2av4X5tMZ2j35HCbla4cIet1STzJm3bSFNRJl0+4rz59rceqJ1w4xIb5pVrlMM1 iBFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683308161; x=1685900161; 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=9LKXfXZKS6XfHWVol50zRC0ePR/XTxKdKmAlfazSwDA=; b=d+hDdxldVPUIbdHklwiEGOssVdTV3kXo3EtLiI+PKGstLpERFCkWg3/PtSIEQ1LAIc X84S1+K0nHgRtklpmx7mMqBugtMWN+OXM2zONdcyOKGSbxgkizftKUW8s6rhhBZJdjJm pwmXpTRIP2SJAZVwrDousZXbNFTS3uRYHZt5e/HHIOMy+K+3dSfdaIi/Mqi719IcbXMp 2ZU5IPAS/OQYgQve0FmfkYdj3LPPZqhcpIL5oEZgX6yXxtBD7pJNUb11V3vyLin5es1G GvOD5Sud83Ib03u2LsHXWkMM7hUU7ojtMIXY8PUZofydY5LDbwDafFmyFFFClnJnTshk 9qnw== X-Gm-Message-State: AC+VfDzWWNd8cuXhz4jg0AOeZ2rOL3AxFuhkI+Pre1qItQwNOihjse7j 7vjTp996gnPqSwyzReyAvovZGG2arT8zklaHu3Efsw== X-Google-Smtp-Source: ACHHUZ72fcIJ/khdyC0dkTPwh+HqjomQc5AiRAE2HBUYRdjoeFDB7fuxY7KFBLcpMwc7eG4A/80y0aYR9ttVkPNyAqM= X-Received: by 2002:a17:903:32c6:b0:1a6:b0e4:e102 with SMTP id i6-20020a17090332c600b001a6b0e4e102mr13663plr.18.1683308160560; Fri, 05 May 2023 10:36:00 -0700 (PDT) In-Reply-To: <87pm7esnl0.fsf@gmail.com> 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:261127 Archived-At: On Fri, 5 May 2023 at 13:17, Jo=C3=A3o T=C3=A1vora w= rote: > Yes, but I don't really think this is a design problem with gopls. Or > at least I don't think Eglot should not make these nested calls in the > first place. So I would like to understand how this nested RPC requests > takes place. From my reading of the eglot.el's code, there aren't any --= that > is, with Emacs -Q -- at least. > > So I would like to reproduce this situation to analyse what can be done. > > I have gopls on my archlinux machine, though I seldom program in Go. > How does one go about setting up gopls in terms of workspace > configuration, command line options, etc so that the feature is > exercised? Also, can I somehow make use of this feature with any small > hello world project or do I need something bigger? In that case can you > point me to a git repository that I can download, or attach that > project? Sure. You can reproduce the experimental setup like so: 1. git clone golang.org/x/tools 2. Download and checkout this commit: https://go-review.git.corp.google.com/c/tools/+/474735 (It's a stack of 2 messy CLs on top of an old master, but it works.) 3. (cd gopls && go install) This puts gopls on your $PATH. 4. killall gopls So that eglot uses the new executable. 5. Load the definition of the eglot-handle-request window/showDocument hand= ler. 6. Also load this function. (defun gopls--package-docs () "Open the documentation for this Go package in a browser." (interactive) (save-excursion ;; TODO(adonovan): We currently cram this functionality into the ;; textDocument/definition RPC applied to the "package" keyword. ;; Do something more principled. (goto-char 0) (re-search-forward "^package ") (beginning-of-line) (xref-find-definitions 'package))) 7. Visit a Go file, e.g. go/analysis/analysis.go. Move cursor to the "package" keyword. 8. Run the gopls--package-docs command. This sends an "definitions" RPC request for the package keyword. The server has been modified to interpret this as a (strange) request to open a web page of package documentation. The server sends a showDocument request (http://localhost...) to the client. The client handler eglot-handle-request opens a browser. You should see a page full of links to source declarations. 9. Click on one of these links. This causes the web server (gopls) to send another showDocument request, this time for file://..., to the client, which causes gopls to open the file containing the declaration and move to the correct position. Removing the asynchrony causes the file:// downcall to get stuck because it makes an upcall to gopls while the server is still waiting for the showDocument downcall to finish. > My main curiosity is where does this "click" happen in the first > place... (that's related to my lack of hands-on experience with this > feature, as described above) See above. > >> 2. if browse-url should be used for non-file: urls (it might open a br= owser window outside of Emacs, which IMO is fine.) > > > > What's the alternative? The very purpose of the operation is to open a > > URL in a browser. > > Not always, IIUC. Sometimes it's just to open a file. I think "file:" URLs should be opened by find-file in Emacs, and all other URLs should go to browse-url (and thence Chrome, etc). cheers alan