[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/jarchive 642573149f 03/33: Try not to manage a collecti
From: |
ELPA Syncer |
Subject: |
[elpa] externals/jarchive 642573149f 03/33: Try not to manage a collection of open buffers. |
Date: |
Sat, 12 Nov 2022 17:57:55 -0500 (EST) |
branch: externals/jarchive
commit 642573149fd79809db388905cede49e84a598617
Author: dannyfreeman <danny@dfreeman.email>
Commit: dannyfreeman <danny@dfreeman.email>
Try not to manage a collection of open buffers.
The buffer is re-opened after it is killed while eglot is running.
It should be disabled in the buffer I think.
---
jarchive.el | 48 +++++++++++++++++++-----------------------------
1 file changed, 19 insertions(+), 29 deletions(-)
diff --git a/jarchive.el b/jarchive.el
index 4d36e43019..dfb0f0340c 100644
--- a/jarchive.el
+++ b/jarchive.el
@@ -18,19 +18,10 @@
;; match group 2, the file within the archive
(group (* not-newline) "." (+ alphanumeric))
line-end)
- "A regex for matching jar files to be opened by eglot and clojure-lsp")
+ "A regex for matching jar files to be opened by eglot and clojure-lsp.")
-(defvar jarchive--file->buffer
- (make-hash-table :test 'equal)
- "A hash table mapping a file name to a buffer.")
-
-;; Maybe I can use find-buffer-visiting, but right now it creates an infinite
loop
-(defun jarchive--find-buffer-visiting (file)
- (when-let ((existing-buffer (gethash file jarchive--file->buffer)))
- (if (buffer-live-p existing-buffer)
- existing-buffer
- (remhash file jarchive--file->buffer)
- nil)))
+(defvar-local jarchive--managed-buffer nil
+ "This value is t when a buffer is managed by jarchive.")
(defun jarchive--file-name-handler (op &rest args)
"A `file-name-handler-alist' handler for opening files located in jars.
@@ -40,35 +31,34 @@ provided when calling OP."
((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)))
- (source-file (substring file (match-beginning 2))))
- (if-let ((existing-buffer (jarchive--find-buffer-visiting file)))
- existing-buffer
- ;; Can I do this with generate-new-buffer
- (with-current-buffer (create-file-buffer file)
- (message "Unzipping %s to show %s" jar source-file)
- (archive-zip-extract jar source-file)
- (puthash file (current-buffer) jarchive--file->buffer)
+ (jar (substring file (match-beginning 1) (match-end 1)))
+ (file-in-jar (substring file (match-beginning 2))))
+ (with-current-buffer (get-buffer-create file)
+ (unless (or buffer-read-only jarchive--managed-buffer)
+ (message "jarchive: writing buffer %s " args)
+ (setq-local jarchive--managed-buffer t)
+ (archive-zip-extract jar file-in-jar)
(setq-local buffer-file-name file)
(setq-local default-directory (file-name-directory jar))
- (setq-local buffer-read-only t)
(setq-local buffer-offer-save nil)
+ (setq buffer-read-only t)
(set-auto-mode)
- (set-buffer-modified-p nil)
(goto-char 0)
- (current-buffer)))))
+ (set-buffer-modified-p nil))
+ (current-buffer))))
(t (let ((inhibit-file-name-handlers (cons 'jarchive--file-name-handler
(and (eq
inhibit-file-name-operation op)
inhibit-file-name-handlers)))
(inhibit-file-name-operation op))
(apply op args)))))
-(defun jarchive--kill-buffer (file)
- (kill-buffer (jarchive--find-buffer-visiting file))
- (remhash file jarchive--file->buffer))
+(defvar test-file
"/home/user/.m2/repository/hiccup/hiccup/1.0.5/hiccup-1.0.5.jar!/hiccup/page.clj")
+
+(defmacro comment (&rest body) nil)
-;;(find-file
"/home/user/.m2/repository/hiccup/hiccup/1.0.5/hiccup-1.0.5.jar!hiccup/page.clj")
-;;(jarchive--kill-buffer
"/home/user/.m2/repository/hiccup/hiccup/1.0.5/hiccup-1.0.5.jar!hiccup/page.clj")
+(comment
+ (find-file test-file)
+ )
(defun jarchive-setup ()
(add-to-list 'file-name-handler-alist (cons jarchive--hybrid-path-regex
#'jarchive--file-name-handler)))
- [elpa] branch externals/jarchive created (now bfcc201cca), ELPA Syncer, 2022/11/12
- [elpa] externals/jarchive 3cbfeea812 01/33: Add readme and license, ELPA Syncer, 2022/11/12
- [elpa] externals/jarchive f2875659a8 02/33: Initial code, copied from my personal emacs config, ELPA Syncer, 2022/11/12
- [elpa] externals/jarchive 642573149f 03/33: Try not to manage a collection of open buffers.,
ELPA Syncer <=
- [elpa] externals/jarchive f4a7953b4f 04/33: reorganize testing code, ELPA Syncer, 2022/11/12
- [elpa] externals/jarchive bb2467f8f9 10/33: Add warning to readme, ELPA Syncer, 2022/11/12
- [elpa] externals/jarchive 3a2b3096cd 11/33: Add autoload directive to jarchive-setup function, ELPA Syncer, 2022/11/12
- [elpa] externals/jarchive 059efdf37c 16/33: Make eglot-extend-to-xref work, breaking support for `zipfile:` uris, ELPA Syncer, 2022/11/12
- [elpa] externals/jarchive 9148ed7ada 18/33: WIP eglot setting to control jar URI parsing, ELPA Syncer, 2022/11/12
- [elpa] externals/jarchive 81c4b345bf 20/33: Set dependency-scheme to "jar" on clojure-lsp initialization, ELPA Syncer, 2022/11/12
- [elpa] externals/jarchive 214a7db52f 22/33: Update readme with better examples and explanations, ELPA Syncer, 2022/11/12
- [elpa] externals/jarchive 305dbc947a 23/33: Don't for jar dependency scheme, just use whatever works., ELPA Syncer, 2022/11/12
- [elpa] externals/jarchive 8b738ec31b 26/33: Add changelog, ELPA Syncer, 2022/11/12
- [elpa] externals/jarchive abea8e79ec 28/33: Typo, ELPA Syncer, 2022/11/12