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

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

[elpa] externals/jarchive 0a9833aa1d 1/3: Allow jarchive to be disabled


From: ELPA Syncer
Subject: [elpa] externals/jarchive 0a9833aa1d 1/3: Allow jarchive to be disabled by controlling it with a minor mode
Date: Thu, 5 Oct 2023 00:58:25 -0400 (EDT)

branch: externals/jarchive
commit 0a9833aa1d5244de3e7c2ca055ce90eb0985d1eb
Author: Danny Freeman <danny@dfreeman.email>
Commit: Danny Freeman <danny@dfreeman.email>

    Allow jarchive to be disabled by controlling it with a minor mode
---
 jarchive.el | 28 ++++++++++++++++++++++------
 1 file changed, 22 insertions(+), 6 deletions(-)

diff --git a/jarchive.el b/jarchive.el
index 73d8ae7715..9df48ae811 100644
--- a/jarchive.el
+++ b/jarchive.el
@@ -172,13 +172,29 @@ handle it. If it is not a jar call ORIGINAL-FN."
     (advice-add 'eglot--uri-to-path :around 
#'jarchive--wrap-legacy-eglot--uri-to-path)
     (message "[jarchive] Eglot successfully patched.")))
 
+(defvar jarchive--file-name-handler
+  (cons jarchive--uri-regex #'jarchive--file-name-handler))
+
+;;;###autoload
+(define-minor-mode jarchive-mode
+  "Teach Emacs to work with jar URIs.
+Opening a jar URI via Emacs functions like `find-file' will
+automatically extract the contents of a file contained in the jar
+and open them in a buffer."
+  :global t
+  :lighter " Jar"
+  (if jarchive-mode
+      (progn
+        (add-to-list 'file-name-handler-alist jarchive--file-name-handler)
+        (add-to-list 'find-file-not-found-functions 
#'jarchive--find-file-not-found))
+    (setq file-name-handler-alist
+          (remove jarchive--file-name-handler file-name-handler-alist)
+          find-file-not-found-functions
+          (remove #'jarchive--find-file-not-found 
find-file-not-found-functions))))
+
 ;;;###autoload
-(defun jarchive-setup ()
-  "Setup jarchive, enabling Emacs to open files inside jar archives.
-the files can be identified with the `jar' uri scheme."
-  (interactive)
-  (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))
+(define-obsolete-function-alias
+  'jarchive-setup 'jarchive-mode "0.11.0" "Obsolete. Set up Jarchive to open 
jar URIs.")
 
 (provide 'jarchive)
 ;;; jarchive.el ends here



reply via email to

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