From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Felician Nemeth Newsgroups: gmane.emacs.bugs Subject: bug#62116: RFE: eglot: support window.showDocument LSP RPC Date: Sat, 22 Apr 2023 11:08:05 +0200 Message-ID: <874jp8gu8a.fsf@betli.tmit.bme.hu> References: <87jzznxx8f.fsf@gmail.com> <83fsabwhpg.fsf@gnu.org> <87v8j7vy48.fsf@gmail.com> <83r0tuv62t.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21665"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) Cc: Eli Zaretskii , Sebastian Poeplau , =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= , adonovan@google.com To: 62116@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Apr 22 11:09:15 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 1pq9F5-0005Qd-4O for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 22 Apr 2023 11:09:15 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pq9Ev-00008N-BS; Sat, 22 Apr 2023 05:09:05 -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 1pq9Et-000088-7D for bug-gnu-emacs@gnu.org; Sat, 22 Apr 2023 05:09: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 1pq9Es-0002QI-LF for bug-gnu-emacs@gnu.org; Sat, 22 Apr 2023 05:09:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pq9Es-0000kD-FK for bug-gnu-emacs@gnu.org; Sat, 22 Apr 2023 05:09:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Felician Nemeth Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 22 Apr 2023 09:09:02 +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.16821544952802 (code B ref 62116); Sat, 22 Apr 2023 09:09:02 +0000 Original-Received: (at 62116) by debbugs.gnu.org; 22 Apr 2023 09:08:15 +0000 Original-Received: from localhost ([127.0.0.1]:41686 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pq9E7-0000j8-8A for submit@debbugs.gnu.org; Sat, 22 Apr 2023 05:08:15 -0400 Original-Received: from mail-wm1-f46.google.com ([209.85.128.46]:48406) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pq9E4-0000iv-TG for 62116@debbugs.gnu.org; Sat, 22 Apr 2023 05:08:13 -0400 Original-Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-3f1738d0d4cso16661325e9.1 for <62116@debbugs.gnu.org>; Sat, 22 Apr 2023 02:08:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682154487; x=1684746487; h=mime-version:face:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=6LFKrm7xqFVGa6sOBx94/jOq3pd6+4+0CFN5VL6B4W8=; b=hjwIipYIz+aeyKkCSlGUbXa8NmhTIZ8aZvSY6CCa5UmRQKFK5lZ5Aj+fsoBBr3V6uN ivgVdf4re4wh5dFR1kEPBpnUdqdcNLp5zMh6I9pkfYKinFX43x31ZbO62xJCVaoL/PWF Ej1FmUoPmXr0BjRJTxYqyWtv0zmhWaGNGXiZgWXGqtHUEt7HJxdMXEloywazpxwMpnAw cqpIR4jDmkSWSHonpf2/xVidL9z0LBKJ8HU9fw/PyZMVxICAfY0efxBdWXUoAGexrP08 TZn9JN7nXdLqJsBpIlmmeFP5rGmx/ZIE2LtwZnOszV6oNkWHvNY/zrYwUO9qLTVfcm/N CAlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682154487; x=1684746487; h=mime-version:face:user-agent:message-id:in-reply-to:date:references :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=6LFKrm7xqFVGa6sOBx94/jOq3pd6+4+0CFN5VL6B4W8=; b=lPBAMNjdMmVvQeIPlwqYL57l8RVIj55ey2XeGDpLMpjuZCmUP7a4DZtEwC61CFZAzJ 1D87tOBVfhr/B6XwPFZ5gjPg3L6NcaLI/6WvN1uyvn6bPeCzQ1/9FWoMec0s183QOK4t ClZd+GMKpl6ZZ5hZ1Q55Nuqj3EcNxl/1LC2BGv1MpdLS7xlsx5M5V8pGYwxCdFSPyPZm +lnHoHs0uifgwsLGSqFGneFohFpqCNkPnsS2R/AdH6dEsNGHCWmpT4lplB5gc24ClxN0 Cx8DqtnDTLfG7GQuqZRRlldJYqI3wa5KUsiK4+YrU/gfTXxCkpVMFr9ZmGxiJ0Scvx7J I6lg== X-Gm-Message-State: AAQBX9eCjhA1LLVNy+coE46TKf3Mi9fhCOZJzUuHdlDPuwA7SCKoUUB9 Sx0n/c7d6UF7RJijdfOYTfc= X-Google-Smtp-Source: AKy350b7wY5e4k1rdZvynDb8anJOrrShpLaa4eN2N35qgR6TWnkzcMSDYkOqYkwApMZOj0x0oXWOAg== X-Received: by 2002:adf:e683:0:b0:2f9:cee4:b8e with SMTP id r3-20020adfe683000000b002f9cee40b8emr5095321wrm.68.1682154486735; Sat, 22 Apr 2023 02:08:06 -0700 (PDT) Original-Received: from betli.gmail.com (catv-86-101-66-128.catv.fixed.vodafone.hu. [86.101.66.128]) by smtp.gmail.com with ESMTPSA id q16-20020a7bce90000000b003f09d7b6e20sm6974441wmj.2.2023.04.22.02.08.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Apr 2023 02:08:06 -0700 (PDT) In-Reply-To: <83r0tuv62t.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 12 Mar 2023 08:26:02 +0200") Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAFVBMVEU2EgDVmFNHKAa4dz4q AwCDUSH2zWrE61tmAAACeklEQVQ4jU2UwY7jIAyGEZN5ABSFc9Ytcx6K6DmqmHsD8tyZKrz/I+xv yI6WKlHlj982tomiVckiWrUrgRU5jlqMpJKCkch5W419DQAiQGHDxdrWmm0/2kXCApiUmrZLq20s cjexq3VL25QuxjY7wOcJVEpb+jLeGLAK+OMyaa1hx9rFbkwHFWBVA2y8w1wHaLE7GuDdw5cEuOM5 SLIdrpwBkN0ezwI7nYoiilqthbcYc89KgC5+NnaOHGbZz0T6BCEgOLJ0vmYXuNdPAIXgDZJhF2Yu fjnPNwAsoUTUN/P8q3AAyz4zB/xmifEfiIbvS4jh7b7QqZiSm4MJC5kXNpCRaOsoyQXAMN2XCJfs j94NKfo7ACKUEgKE3y+Sg4jibUZ1A0jgYpxtvYMC3gHaHPq6x32ACeALIZoZxB+l9VrRNIA1ncRg wwC8pvQIvYO+a2yt3VXMVyli6L0VV6aOrJa4CpilVQA+eHt0xavk61akih5BUMay/0BAqu783C5h FifY/3QsAIoWYk6PgpwAzLI652+96e2IfN2cF+BD1uT23F21Ghh5OUl4RlO15oh5A2iv+Zk2wsjZ 2DtB5Sm3A4P0+kyb2vs4iEW7G9ohoN3Stl2kVat6MCkXldo6OKaE8P6GhmrKKxWZXQH1iklhhn+d iVeNf6mDdkV0ltFwApRbp+kXSGBFHGV2aPqnIIyQyzhD5n47khqKI08bIapcas4O+hPkct20NAEv ALRuZFUp3PrnQSAm+4lTdHCsYYZ/nGqQrM5z3NS3zefFxkfFPRFbsjpIfbTlvF3ibpVZQ9nzqv60 F/KXSRLJ1AGappJulZll70N/qz6EfwEOCdYOuTHAzAAAAABJRU5ErkJggg== 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:260444 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable This is a continuation of the thread=20 https://lists.gnu.org/archive/html/emacs-devel/2023-04/msg00206.html , where Jo=C3=A3o suggested we should proceed with my simpler patch until we hear from Alan. This message summarizes the current situation: https://lists.gnu.org/archive/html/emacs-devel/2023-04/msg00339.html I tested my patch with Sebastian's ada example. Thanks. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Eglot-support-window-showDocument-request.patch >From 468a8104183ba46f92d0a194862761c81943c505 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felici=C3=A1n=20N=C3=A9meth?= Date: Sat, 22 Apr 2023 10:49:17 +0200 Subject: [PATCH] Eglot: support window/showDocument request * eglot.el (eglot-client-capabilities): Add showDocument support. (eglot-handle-request window/showDocument): New cl-defmethod. --- lisp/progmodes/eglot.el | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 3134d55fc0..daabb4ff7b 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -830,7 +830,8 @@ eglot-client-capabilities `(:valueSet [,@(mapcar #'car eglot--tag-faces)]))) - :window `(:workDoneProgress t) + :window `(:showDocument (:support t) + :workDoneProgress t) :general (list :positionEncodings ["utf-32" "utf-8" "utf-16"]) :experimental eglot--{}))) @@ -2345,6 +2346,28 @@ eglot-handle-request "Handle server request workspace/workspaceFolders." (eglot-workspace-folders server)) +(cl-defmethod eglot-handle-request + (_server (_method (eql window/showDocument)) &key + uri external takeFocus selection) + "Handle request window/showDocument." + (if (eq external t) + (browse-url uri) + (let ((filename (eglot--uri-to-path uri))) + (if (eq takeFocus t) + (find-file filename) + (find-file-noselect filename)) + (when selection + (with-current-buffer (get-file-buffer filename) + (save-restriction + (widen) + (pcase-let ((`(,beg . ,end) (eglot--range-region selection))) + (if (equal beg end) + (goto-char beg) + (goto-char end) + (set-mark-command nil) + (goto-char beg)))))))) + '(:success t)) + (defun eglot--TextDocumentIdentifier () "Compute TextDocumentIdentifier object for current buffer." `(:uri ,(eglot--path-to-uri (or buffer-file-name -- 2.30.2 --=-=-=--