Subject: bug#62116: RFE: eglot: support window.showDocument LSP RPC

From: Felician Nemeth <[email-masked]>
Date: Tue, 09 May 2023 19:03:07 +0200

João Távora <[email-masked]> writes:

>> Since it advances the status quo, can this be merged?  If not, how
>> should we proceed?
>
> Haven't looked at it, but I'd say yes.  However, Alan Donovan
> has replied recently, with a recipe showcasing his particular
> use case.  I dont' have time to try it right now, but if you
> could try his recipe/use case with your solution, it would be
> great.

It requires to patch and recompile gopls, which would be too much effort
for me, unfortunately.

> One note that I didn't yet reply to is that IMO (likely in Alan's
> opinion too), it does make sense to raise the frame.  The
> showDocument may indeed come from somewhere else which is not
> Emacs at all.  I used to work with Common Lisp IDEs like that
> allowed the application being developed to issue requests to
> the editor and pop it up to the user.  It was extremely convenient.

I've looked into this.  The docstring of x-focus-frame says "If there is
no window system support, this function does nothing."  However, this
command

    emacs -Q -nw --eval "(x-focus-frame nil)"

errors out instead of doing nothing.  But supporting the frame raising
feature is approximately as simple as

    (let ((frame (window-frame (get-buffer-window buf t))))
      (raise-frame frame)
      (x-focus-frame frame))

However, I don't work with multiple frames, so I don't know whether the
all-frames parameter of the get-buffer-window should really be t.  I
hope the latest patch can be merged as is, and someone with more
experience with multiple frames can later step in and provide an
additional patch for this extra feature.

Thanks.