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, 13 May 2023 12:21:10 +0200 Message-ID: <877ctc8rc9.fsf@betli.tmit.bme.hu> 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> <87ttwpbpaj.fsf@betli.tmit.bme.hu> <875y93arek.fsf@betli.tmit.bme.hu> <87h6sla14k.fsf@betli.tmit.bme.hu> <871qjm5pzk.fsf@gmail.com> 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="15218"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) Cc: sebastian.poeplau@mailbox.org, adonovan@google.com, 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 Sat May 13 12:22:26 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 1pxmOP-0003p2-4L for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 13 May 2023 12:22:25 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pxmO3-00066L-Kg; Sat, 13 May 2023 06:22:03 -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 1pxmO2-000669-LO for bug-gnu-emacs@gnu.org; Sat, 13 May 2023 06:22: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 1pxmO2-0006uD-DU for bug-gnu-emacs@gnu.org; Sat, 13 May 2023 06:22:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pxmO1-0004VW-RC for bug-gnu-emacs@gnu.org; Sat, 13 May 2023 06:22:01 -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, 13 May 2023 10:22: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.168397328117278 (code B ref 62116); Sat, 13 May 2023 10:22:01 +0000 Original-Received: (at 62116) by debbugs.gnu.org; 13 May 2023 10:21:21 +0000 Original-Received: from localhost ([127.0.0.1]:36029 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pxmNM-0004Uc-VE for submit@debbugs.gnu.org; Sat, 13 May 2023 06:21:21 -0400 Original-Received: from mail-wm1-f47.google.com ([209.85.128.47]:44114) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pxmNK-0004UO-JN for 62116@debbugs.gnu.org; Sat, 13 May 2023 06:21:19 -0400 Original-Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-3f4449fa085so31395785e9.0 for <62116@debbugs.gnu.org>; Sat, 13 May 2023 03:21:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1683973273; x=1686565273; h=content-transfer-encoding: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=mZCXghrod0nt/EKhL8bSglC8Fm6uUVL5FgwNxPVe08Y=; b=N3MS5PXA2t+rIJRapymC4W+Ygpl86ULq5qtZFMnr5+kiX+fHqQUx9U2Xrs3trerOFO bm2hruAXKwy1ZQvsqOHXu4J8mmI/zZN3tpj1BjqnA2njz/soXf0pUjjTIQE9oc+VFpC5 dZf+sbzRi4eQAannUYm5vhtKtbEHf3vn9///23puawsiSai9gS7edyc6EkbuWxxXQasi DS6q+xNeTrenrOxqbA7s+qJ+tcl2u5xgu9dcBfmU9VlErJ+ZtHton8yyliTGVfpbafwm QaXOZnNPmUvUebqksn0UT/uhliS2nP7pWHihEsK0S32FXmGLJby2p6fFB7BarJ0Aaa+W gNCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683973273; x=1686565273; h=content-transfer-encoding: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=mZCXghrod0nt/EKhL8bSglC8Fm6uUVL5FgwNxPVe08Y=; b=DCSJn81+F7OUlQRbchbGqa9n7AEuk57G+hssKJg5e7kGQaXEHZ4aVd8KfoTRbdUyYk C8VdTIdryFe/oZ2dh3r45VGtJDWVSVckE3ECSJ1iDjgGbYMx+uz06KELPFwlmleZmjwM Oo5tSINnZS+Z29p68rTAnAxHmr5qoAhGtw6vpIKEwjHeGO4fggcn9IXTlSCwUJd06yO0 wYQLRUngT8+njxl/tYuzjB5f79Hb/9PcJWIWG2UOmXJYjNN5g55UAfe/vylqPCZYiKm+ YSBHJY3CpZxKuy7EbojIbdYgEdQoAxQA/6T5F9EdS15kCexvNZ0tUmvw3oUCd6o539mK KJ5g== X-Gm-Message-State: AC+VfDynfYkiL2DfL8WLrR/ob9/BMtFsR5yiZ7kvl55wBZ/zt9DFBBYY 7lnVVOv4uzMIZ5yRhKvNjJM= X-Google-Smtp-Source: ACHHUZ5IX0J1Is9Fds1HD+qGB3I8yuqr0z1VS6p6f8ytP9PuSOewQ0/fGNJxapCAo3bN3XjrX5vg/Q== X-Received: by 2002:a1c:7406:0:b0:3f4:2e01:83fa with SMTP id p6-20020a1c7406000000b003f42e0183famr10556798wmc.26.1683973272550; Sat, 13 May 2023 03:21:12 -0700 (PDT) Original-Received: from betli.gmail.com (catv-89-134-210-182.catv.fixed.vodafone.hu. [89.134.210.182]) by smtp.gmail.com with ESMTPSA id o19-20020a1c7513000000b003f31cb7a203sm30907196wmc.14.2023.05.13.03.21.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 May 2023 03:21:11 -0700 (PDT) In-Reply-To: <871qjm5pzk.fsf@gmail.com> ("=?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?="'s message of "Fri, 12 May 2023 01:54:07 +0100") Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAFVBMVEUMBwgHAgMFAAGPjY7/ //80MDHq6eqJt3pKAAABr0lEQVQ4jX2UzZKDIAzHqR177q7TPbtx2HMr6guQcrbY9txZ0fd/hA0f onXazcEJ/CD8E4Js8/HS9mwjXtqeMRxHXJkakTEm4b4GPVQW8PU8ov4fQCqeThlF60MBWdo1IXzd 2nEEZE7CEAZLwI0N/gJAhTj7ESQAX4gPgO8lyI+cvgViSVPlNomAj2M9gW40eg7VWY3cATjUcyiO Z+i03cFruGLYoUR7VyU3HihdmCEVhoDN65FXkpbSxkomOzsTQN/gySaodGb9Gdi1oSRXP46gdBWh LcUKJNdeGCWac74GKakmne0aHCFvyqJPYLsCFAVlhRTvGdzMdLHqtgRyUulyXIAH7CYQ3AB0Nody JQhAkq/qtOnbjhxdzYDkXPxlH5y4WdUAeUcX1NVJ6GR7UQEYPGWoAnA36OQNn5lRRp38vHTAp9Br LoTmvlPPDoRCKzpjG1SXT89AaT5l456BamJuMcs+NIOMzJ/s5dI6yUVcrARlruwOebfdv6gunTn4 ww3+QjGBEn5suVyLHoSGvAqREuDLN+iqZ+VcFg+HBbsJUU9+FZthbez9T+bdb+kPv2Ls6ct3hTkA AAAASUVORK5CYII= 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:261675 Archived-At: Jo=C3=A3o T=C3=A1vora writes: > I've now followed Alan's recipe and played around a bit with this. > Starting from your version, I came up with this simpler patch. > > I was about to push it, but let's hear your opinions first It is great, and I'd be happy if it went in as is. Thank you. However, ... > +(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* (;; requests run with a let-bound `eglot--cached-server', > + ;; but when finding files from handlers, this fools > + ;; `eglot--maybe-activate-editing-mode'. > + (eglot--cached-server nil)) (I don't understand this part.) > + (with-current-buffer (find-file-noselect (eglot--uri-to-path uri)) > + (cond (takeFocus > + (pop-to-buffer (current-buffer)) Somehow switch-to-buffer feels more natural to me. But pop-to-buffer is probably a better choice. > + (select-frame-set-input-focus (selected-frame))) > + ((display-buffer (current-buffer)))) Even when takeFous is nil, shouldn't we still at least raise the frame? Otherwise Emacs might not show the document. > + (when selection > + (eglot--widening > + (pcase-let ((`(,beg . ,end) (eglot--range-region selection))) > + (goto-char beg) > + (pulse-momentary-highlight-region beg end 'highlight))))))) This is a nice detail. > + '(:success t)) Regarding Alan's problem, one could argue that it can also be fixed on the server-side. However, there might be a general, but complex fix on Emacs' side as well: imenu can be modified to asynchronously generate its index when it just wants to show it in the menu (and not to users' direct request). Then the request of :textDocument/documentSymbol can be non-blocking as well. A simpler fix is to delay the opening of the file.