From: João Távora Date: Thu, 17 May 2018 13:03:20 +0000 (+0100) Subject: Make it work on windows X-Git-Tag: emacs-29.0.90~1616^2~524^2~4^2~562 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=04da3b6abdcddebdaf899a1f2f0de511f4174146;p=emacs.git Make it work on windows Apparently passing :coding 'no-conversion to make-process on windows is essential to receive any text at all in the process filter. Also needed to tweak uri-to-path and path-to-uri. Thanks to lsp-mode.el for these hints * eglot.el (eglot--make-process): Pass :coding 'no-conversion to make-process. (eglot--path-to-uri): Add a forward slash if windows-nt. (eglot--uri-to-path): Remove a forward slash if windows-nt. (eglot--server-textDocument/publishDiagnostics): Simplify and use eglot--uri-to-path. --- diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 01a6b5d47f1..08c2f55dbe7 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -195,6 +195,7 @@ CONTACT is as `eglot--contact'. Returns a process object." (make-process :name readable-name :buffer buffer :command contact + :coding 'no-conversion :connection-type 'pipe :stderr (get-buffer-create (format "*%s stderr*" name)))))) @@ -756,14 +757,16 @@ DEFERRED is passed to `eglot--async-request', which see." (point))) (defun eglot--path-to-uri (path) - "Urify PATH." - (url-hexify-string (concat "file://" (file-truename path)) - url-path-allowed-chars)) + "URIfy PATH." + (url-hexify-string + (concat "file://" (if (eq system-type 'windows-nt) "/") (file-truename path)) + url-path-allowed-chars)) (defun eglot--uri-to-path (uri) "Convert URI to a file path." (when (keywordp uri) (setq uri (substring (symbol-name uri) 1))) - (url-filename (url-generic-parse-url (url-unhex-string uri)))) + (let ((retval (url-filename (url-generic-parse-url (url-unhex-string uri))))) + (if (eq system-type 'windows-nt) (substring retval 1) retval))) (defconst eglot--kind-names `((1 . "Text") (2 . "Method") (3 . "Function") (4 . "Constructor") @@ -989,11 +992,7 @@ called interactively." (cl-defun eglot--server-textDocument/publishDiagnostics (_process &key uri diagnostics) "Handle notification publishDiagnostics" - (let* ((obj (url-generic-parse-url uri)) - (filename (car (url-path-and-query obj))) - (buffer (find-buffer-visiting filename))) - (cond - (buffer + (if-let ((buffer (find-buffer-visiting (eglot--uri-to-path uri)))) (with-current-buffer buffer (cl-loop for diag-spec across diagnostics @@ -1012,9 +1011,8 @@ called interactively." (funcall eglot--current-flymake-report-fn diags) (setq eglot--unreported-diagnostics nil)) (t - (setq eglot--unreported-diagnostics diags)))))) - (t - (eglot--message "OK so %s isn't visited" filename))))) + (setq eglot--unreported-diagnostics diags))))) + (eglot--warn "Diagnostics received for unvisited %s" uri))) (cl-defun eglot--register-unregister (proc jsonrpc-id things how) "Helper for `eglot--server-client/registerCapability'.