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

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

[elpa] externals/jarchive b226bfd66c 09/33: Helper functions for matchin


From: ELPA Syncer
Subject: [elpa] externals/jarchive b226bfd66c 09/33: Helper functions for matching parts of the jar/file path
Date: Sat, 12 Nov 2022 17:57:56 -0500 (EST)

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

    Helper functions for matching parts of the jar/file path
---
 jarchive.el | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/jarchive.el b/jarchive.el
index 09d35e16ef..66b1bca79e 100644
--- a/jarchive.el
+++ b/jarchive.el
@@ -21,7 +21,15 @@
   "A regex for matching paths to a jar file and a file path into the jar file.
 Delimited by `!' or `::'")
 
-(defvar-local jarchive--managed-buffer nil
+(defun jarchive--match-jar (hybrid-filename)
+  (string-match jarchive--hybrid-path-regex hybrid-filename)
+  (substring hybrid-filename (match-beginning 1) (match-end 1)))
+
+(defun jarchive--match-file (hybrid-filename)
+  (string-match jarchive--hybrid-path-regex hybrid-filename)
+  (substring hybrid-filename (match-beginning 2) (match-end 2)))
+
+(defvar-local jarchive--managed-buffer nil ;; consider making a minor mode
   "This value is t when a buffer is managed by jarchive.")
 
 (defmacro jarchive--inhibit (op &rest body)
@@ -39,13 +47,13 @@ provided when calling OP."
   (cond
    ((eq op 'get-file-buffer)
     (let* ((file  (car args))
-           (match (string-match jarchive--hybrid-path-regex file))
-           (jar (substring file (match-beginning 1) (match-end 1)))
-           (file-in-jar (substring file (match-beginning 2)))
+           (jar (jarchive--match-jar file))
+           (file-in-jar  (jarchive--match-file file))
+           ;; Use a different filename that doesn't match 
`jarchive--hybrid-path-regex'
+           ;; so that this handler will not deal with existing open buffers.
            (buffer-file (concat jar ":" file-in-jar)))
       (or (find-buffer-visiting buffer-file)
           (with-current-buffer (create-file-buffer buffer-file)
-            (message "jarchive: writing buffer %s " args)
             (setq-local jarchive--managed-buffer t)
             (archive-zip-extract jar file-in-jar)
             (goto-char 0)



reply via email to

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