From: Robert Brown <robert.brown@gmail.com>
To: 58790@debbugs.gnu.org
Subject: bug#58790:
Date: Tue, 8 Nov 2022 19:59:45 -0500 [thread overview]
Message-ID: <CAPNkkpm0qbKOuc3tt3F33ARM+j0Eos+6Oh2TQJTKQBNvR5u-ug@mail.gmail.com> (raw)
In-Reply-To: <cc9a957a-83b5-9c86-ad13-87ecaf44dcb1@dfreeman.email>
[-- Attachment #1: Type: text/plain, Size: 371 bytes --]
I use a Java language server with Eglot that returns "jar:" URIs like
those discussed in this bug thread.
I took Danny's jarchive.el and combined it with the attached patch,
which modifies Eglot so that it does not convert non-file URIs into
file paths.
With this patch and jarchive.el, "goto definition" works as expected
when the Java source code is inside a jar file.
[-- Attachment #2: 0001-Do-not-convert-non-file-URIs-into-file-paths.patch --]
[-- Type: text/x-patch, Size: 3670 bytes --]
From 7a5e9959ca9c1989f4611199710d95a84ac9d26b Mon Sep 17 00:00:00 2001
From: Robert Brown <robert.brown@gmail.com>
Date: Tue, 8 Nov 2022 19:57:50 -0500
Subject: [PATCH] Do not convert non-file URIs into file paths.
---
eglot.el | 57 ++++++++++++++++++++++++++++++++++----------------------
1 file changed, 35 insertions(+), 22 deletions(-)
diff --git a/eglot.el b/eglot.el
index 901bf30..83b47c6 100644
--- a/eglot.el
+++ b/eglot.el
@@ -1483,31 +1483,44 @@ If optional MARKER, return a marker instead"
"Like `url-path-allows-chars' but more restrictive.")
(defun eglot--path-to-uri (path)
- "URIfy PATH."
- (let ((truepath (file-truename path)))
- (concat "file://"
- ;; Add a leading "/" for local MS Windows-style paths.
- (if (and (eq system-type 'windows-nt)
- (not (file-remote-p truepath)))
- "/")
- (url-hexify-string
- ;; Again watch out for trampy paths.
- (directory-file-name (file-local-name truepath))
- eglot--uri-path-allowed-chars))))
+ "When PATH is a file path derived from a file URI, convert it into a URI.
+Otherwise, PATH is already a URI, so just return it."
+ (let ((url (url-generic-parse-url path)))
+ (if (null (url-type url))
+ ;; PATH is a file path. Convert it into a URI.
+ (let ((truepath (file-truename path)))
+ (concat "file://"
+ ;; Add a leading "/" for local MS Windows-style paths.
+ (if (and (eq system-type 'windows-nt)
+ (not (file-remote-p truepath)))
+ "/")
+ (url-hexify-string
+ ;; Again watch out for trampy paths.
+ (directory-file-name (file-local-name truepath))
+ eglot--uri-path-allowed-chars)))
+ ;; PATH is already a URI.
+ path)))
(defun eglot--uri-to-path (uri)
- "Convert URI to file path, helped by `eglot--current-server'."
+ "When URI is a file URI, convert it into a file path, helped by
+`eglot--current-server'. Otherwise, just return the URI unchanged."
(when (keywordp uri) (setq uri (substring (symbol-name uri) 1)))
- (let* ((server (eglot-current-server))
- (remote-prefix (and server (eglot--trampish-p server)))
- (retval (url-unhex-string (url-filename (url-generic-parse-url uri))))
- ;; Remove the leading "/" for local MS Windows-style paths.
- (normalized (if (and (not remote-prefix)
- (eq system-type 'windows-nt)
- (cl-plusp (length retval)))
- (substring retval 1)
- retval)))
- (concat remote-prefix normalized)))
+ (let ((url (url-generic-parse-url uri)))
+ (if (equal (url-type url) "file")
+ ;; Transform a file URI into a file path, which may be a
+ ;; remote tramp path.
+ (let* ((server (eglot-current-server))
+ (remote-prefix (and server (eglot--trampish-p server)))
+ (retval (url-unhex-string (url-filename url)))
+ ;; Remove the leading "/" for local MS Windows-style paths.
+ (normalized (if (and (not remote-prefix)
+ (eq system-type 'windows-nt)
+ (cl-plusp (length retval)))
+ (substring retval 1)
+ retval)))
+ (concat remote-prefix normalized))
+ ;; Non-file URIs are unmodifiled.
+ uri)))
(defun eglot--snippet-expansion-fn ()
"Compute a function to expand snippets.
--
2.25.1
prev parent reply other threads:[~2022-11-09 0:59 UTC|newest]
Thread overview: 61+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-25 21:44 bug#58790: Eglot URI parsing bug when using clojure-lsp server Danny Freeman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-26 6:22 ` Stefan Kangas
2022-10-26 19:50 ` Danny Freeman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-27 15:09 ` João Távora
2022-10-29 1:22 ` Dmitry Gutov
2022-10-29 2:02 ` João Távora
2022-10-29 14:54 ` Dmitry Gutov
2022-10-29 19:35 ` Danny Freeman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-10-31 14:40 ` Danny Freeman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-02 8:09 ` João Távora
2022-11-02 13:15 ` Danny Freeman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-03 17:10 ` Danny Freeman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-10 9:49 ` Eli Zaretskii
2022-11-10 11:00 ` João Távora
2022-11-10 13:47 ` Danny Freeman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-10 15:38 ` Eli Zaretskii
2022-11-10 21:45 ` Danny Freeman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-10 21:59 ` João Távora
2022-11-10 22:22 ` Danny Freeman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-10 22:30 ` João Távora
2022-11-10 22:48 ` Danny Freeman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-10 22:48 ` João Távora
2022-11-10 22:57 ` Danny Freeman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-11 7:29 ` Eli Zaretskii
2022-11-12 17:03 ` Michael Albinus
2022-11-13 21:04 ` Danny Freeman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-15 19:04 ` Michael Albinus
2022-11-15 22:28 ` Danny Freeman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-16 7:53 ` Michael Albinus
2022-11-16 10:21 ` João Távora
2022-11-16 15:45 ` Michael Albinus
2022-11-16 16:20 ` João Távora
2022-11-16 22:59 ` Danny Freeman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-02 16:14 ` Michael Albinus
2022-12-07 18:56 ` Danny Freeman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-08 13:46 ` Michael Albinus
2022-12-08 19:07 ` Danny Freeman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-09 16:04 ` Michael Albinus
2022-12-10 17:21 ` Danny Freeman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-10 17:45 ` Michael Albinus
2022-11-22 14:30 ` Michael Albinus
2022-11-23 11:55 ` Richard Copley
2022-11-23 12:36 ` João Távora
2022-11-23 12:42 ` Arash Esbati
2022-11-23 12:49 ` Richard Copley
2022-11-23 12:54 ` João Távora
2022-11-23 13:33 ` Eli Zaretskii
2022-11-23 13:44 ` João Távora
2022-11-23 14:03 ` Danny Freeman via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-23 19:53 ` João Távora
2022-11-11 8:30 ` Eli Zaretskii
2022-11-11 9:45 ` João Távora
2022-11-11 12:01 ` Eli Zaretskii
2022-11-11 14:02 ` João Távora
2022-11-11 14:45 ` Eli Zaretskii
2022-11-12 9:04 ` João Távora
2022-11-11 7:16 ` Eli Zaretskii
2022-11-01 17:25 ` Juri Linkov
2022-10-29 15:36 ` Felician Nemeth
2022-10-29 17:09 ` João Távora
2022-11-09 0:59 ` Robert Brown [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAPNkkpm0qbKOuc3tt3F33ARM+j0Eos+6Oh2TQJTKQBNvR5u-ug@mail.gmail.com \
--to=robert.brown@gmail.com \
--cc=58790@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).