> Felicián, can you show your full patch again, perhaps with a unit test > using the ada language server? I've attached the patch. However, I failed to write a unit test. At the end of eglot-handle-request buffer-name shows the expected main.adb, but at the end of the my ert-deftest it is the old, incorrect value. This puzzles my, because if I interactively repeat the test steps, everything is OK. I copy the test code at the end of the email. > Also, can you comment on why you think Alan Donovan's patch has that > non-synchronous find-file mechanism? Since Alan, doesn't reply, what do > you conjecture is the reason his patch goes through this trouble? > > I'd also like someone to address my comments of that patch, which is > similar to yours: > https://debbugs.gnu.org/cgi/bugreport.cgi?bug=62116#10. Among others > > 1. if you think the Emacs frame should be raised and/or focused when a > window.showDocument comes in. I always use Emacs in single frame, so I have no experience in this area, but I don't understand why x-focus-frame is necessary. The showDocument request should not come out of the blue, and if the user is actively working on a source file, the frame is already in focus. > 2. if browse-url should be used for non-file: urls (it might open a > browser window outside of Emacs, which IMO is fine.) My original patch used browse-url as well. browse-url is highly customizable, and I think it is right thing to use here. Users can customize it to relay the URL to eww, firefox, etc even for specific URLs. If I understand it correctly, you argued that if takeFocus is false, Eglot should still show the requested file, but the point should remain were it was. I think you're right, but I haven't updated my patch yet. Alan's patch also contains a recenter call, which I think is unnecessary and would probably annoy me, when the target point was already visible before the showDocument request. On the other hand, if the showDocument request contains a selection, both patches could be enhanced to better visualize this selection. Because of the timers, Alan's eglot-handle-request returns success even if the inner lambda fails. It should probably check if filename exists before calling run-with-idle-timer. However, I don't like approach of using timers. I think a better alterative is to put a modified lambda function in an event queue, and Eglot should process the queue after it sent its reply to the client request. Finally, I think Alan's copyright status is still unclear. And this is the my failed attempt at writing a test: (ert-deftest eglot-test-window/showDocument () "Test handling a window/showDocument server request." (skip-unless (executable-find "ada_language_server")) (let (server) (eglot--with-fixture '(("project" . (("project.gpr" . "Project P is\n for Main use (\"main.adb\");\nend P;") ("main.ads" . "procedure Main;") ("main.adb" . "procedure Main is null;")))) (with-current-buffer (eglot--find-file-noselect "project/main.ads") (eglot--sniffing (:server-requests s-requests :server-replies s-replies :client-requests c-requests :client-replies c-replies) (should (setq server (eglot--tests-connect))) (eglot-execute-command server "als-other-file" (vector (eglot--TextDocumentIdentifier))) (let (cmd-id show-doc-id) (eglot--wait-for (c-requests 2) (&key id method &allow-other-keys) (setq cmd-id id) (string= method "workspace/executeCommand")) (eglot--wait-for (s-requests 2) (&key id method &allow-other-keys) (setq show-doc-id id) (string= method "window/showDocument")) (eglot--wait-for (c-replies 1) (&key id error &allow-other-keys) (and (eq id show-doc-id) (null error))) (eglot--wait-for (s-replies 1) (&key id &allow-other-keys) (eq id cmd-id)))) (should (string-equal (buffer-name) "main.adb"))))))