emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/jarchive 5736d46d33 24/33: Include hack to work with le


From: ELPA Syncer
Subject: [elpa] externals/jarchive 5736d46d33 24/33: Include hack to work with legacy versions of eglot.
Date: Sat, 12 Nov 2022 17:57:57 -0500 (EST)

branch: externals/jarchive
commit 5736d46d33945a92e74182947b5a04c582ac27fe
Author: dannyfreeman <danny@dfreeman.email>
Commit: dannyfreeman <danny@dfreeman.email>

    Include hack to work with legacy versions of eglot.
    
    When eglot is updated to match the Emacs master branch version of eglot,
    this code can be removed.
---
 jarchive.el | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/jarchive.el b/jarchive.el
index 2ee4377d6b..89590ebc20 100644
--- a/jarchive.el
+++ b/jarchive.el
@@ -7,6 +7,7 @@
 (require 'arc-mode)
 (require 'cl-macs)
 (require 'seq)
+(require 'url-parse)
 
 (defconst jarchive--uri-regex
   (rx
@@ -106,6 +107,22 @@ TODO: this might be unnecessary, try to remove"
   (and (string-match-p jarchive--uri-regex buffer-file-name)
        t))
 
+(defun jarchive--wrap-legacy-eglot--path-to-uri (original-fn &rest args)
+  "Hack until eglot is updated.
+If path is a jar URI, don't parse. If it is not a jar call original impl."
+  (let ((path (file-truename (car args))))
+    (if (equal "jar" (url-type (url-generic-parse-url path)))
+        path
+      (apply 'funcall original-fn args))))
+
+(defun jarchive--wrap-legacy-eglot--uri-to-path (original-fn &rest args)
+  "Hack until eglot is updated.
+If URI is a jar URI, don't parse and let the `jarchive--file-name-handler' 
handle it.
+If it is not a jar call original impl."
+  (let ((uri (car args)))
+    (if (string= "file" (url-type (url-generic-parse-url uri)))
+        (apply 'funcall original-fn args)
+      uri)))
 
 ;;;###autoload
 (defun jarchive-setup ()
@@ -113,6 +130,10 @@ TODO: this might be unnecessary, try to remove"
 the files can be identified with the `jar' uri scheme."
   (interactive)
   (with-eval-after-load 'eglot
+    (when (version< emacs-version "29") ;; TODO, remove when eglot is updated 
in melpa
+      (advice-add 'eglot--path-to-uri :around 
#'jarchive--wrap-legacy-eglot--path-to-uri)
+      (advice-add 'eglot--uri-to-path :around 
#'jarchive--wrap-legacy-eglot--uri-to-path)))
+
   (add-to-list 'file-name-handler-alist (cons jarchive--uri-regex 
#'jarchive--file-name-handler))
   (add-to-list 'find-file-not-found-functions #'jarchive--find-file-not-found))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]