[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/jarchive 0733e1fcb3 07/33: Use find-buffer-visiting ins
From: |
ELPA Syncer |
Subject: |
[elpa] externals/jarchive 0733e1fcb3 07/33: Use find-buffer-visiting instead of local var check |
Date: |
Sat, 12 Nov 2022 17:57:56 -0500 (EST) |
branch: externals/jarchive
commit 0733e1fcb31af0a38cb0b5a8c2807b29c55ee471
Author: dannyfreeman <danny@dfreeman.email>
Commit: dannyfreeman <danny@dfreeman.email>
Use find-buffer-visiting instead of local var check
find-buffer-visiting was causing an infinite loop of calls to
get-file-buffer when I tried it in previous attempts to implement this,
but this recursion is broken when jarchive--file-name-handler is
inhibited.
---
jarchive.el | 41 ++++++++++++++++++++++-------------------
1 file changed, 22 insertions(+), 19 deletions(-)
diff --git a/jarchive.el b/jarchive.el
index d0599e9b41..d387cc62a4 100644
--- a/jarchive.el
+++ b/jarchive.el
@@ -24,6 +24,14 @@ Delimited by `!' or `::'")
(defvar-local jarchive--managed-buffer nil
"This value is t when a buffer is managed by jarchive.")
+(defmacro jarchive--inhibit (op &rest body)
+ "Run BODY with `jarchive--file-name-handler' inhibited for OP."
+ `(let ((inhibit-file-name-handlers (cons (quote jarchive--file-name-handler)
+ (and (eq
inhibit-file-name-operation ,op)
+ inhibit-file-name-handlers)))
+ (inhibit-file-name-operation ,op))
+ ,@body))
+
(defun jarchive--file-name-handler (op &rest args)
"A `file-name-handler-alist' handler for opening files located in jars.
OP is a `(elisp)Magic File Names' operation and ARGS are any extra argument
@@ -34,25 +42,20 @@ provided when calling OP."
(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))))
- (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-offer-save nil)
- (setq buffer-read-only t)
- (set-auto-mode)
- (goto-char 0)
- (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)))))
-
+ (or (jarchive--inhibit op (find-buffer-visiting file))
+ (with-current-buffer (create-file-buffer file)
+ (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-offer-save nil)
+ (setq buffer-read-only t)
+ (set-auto-mode)
+ (goto-char 0)
+ (set-buffer-modified-p nil)
+ (current-buffer)))))
+ (t (jarchive--inhibit op (apply op args)))))
(defun jarchive-setup ()
(interactive)
- [elpa] externals/jarchive 149f37507e 31/33: Separate Eglot patching process to be invoked manually by the user, (continued)
- [elpa] externals/jarchive 149f37507e 31/33: Separate Eglot patching process to be invoked manually by the user, ELPA Syncer, 2022/11/12
- [elpa] externals/jarchive d209394a47 08/33: Set a different buffer name that doesn't match the jarchive-regex, ELPA Syncer, 2022/11/12
- [elpa] externals/jarchive b226bfd66c 09/33: Helper functions for matching parts of the jar/file path, ELPA Syncer, 2022/11/12
- [elpa] externals/jarchive ec1da7f538 14/33: Allow user to relocate extracted files to the previous project., ELPA Syncer, 2022/11/12
- [elpa] externals/jarchive d8fa586e1c 21/33: Also work with "zipfile" scheme URIs from clojure-lsp, ELPA Syncer, 2022/11/12
- [elpa] externals/jarchive 72465b705a 30/33: Address checkdoc feedback, ELPA Syncer, 2022/11/12
- [elpa] externals/jarchive 4aa2e5d394 13/33: Add section to readme for mailing list, ELPA Syncer, 2022/11/12
- [elpa] externals/jarchive a4505a4784 32/33: Add FSF as copyright holder, ELPA Syncer, 2022/11/12
- [elpa] externals/jarchive b93da9f976 17/33: Do NOT implement file-attributes, ELPA Syncer, 2022/11/12
- [elpa] externals/jarchive 3ff89ae9cb 05/33: Update doc string, ELPA Syncer, 2022/11/12
- [elpa] externals/jarchive 0733e1fcb3 07/33: Use find-buffer-visiting instead of local var check,
ELPA Syncer <=
- [elpa] externals/jarchive c9fdbe909d 19/33: Cleanup docstring, and ensure var is set after eglot loads, ELPA Syncer, 2022/11/12
- [elpa] externals/jarchive 050436241e 27/33: Update README now that this includes hacks to fix legacy eglot, ELPA Syncer, 2022/11/12
- [elpa] externals/jarchive 2c182b3cf9 06/33: Make setup function interactive for convenience, ELPA Syncer, 2022/11/12
- [elpa] externals/jarchive 82ff9f791f 12/33: Remove unnecessary local variable, ELPA Syncer, 2022/11/12
- [elpa] externals/jarchive a5ab89db3f 15/33: Do not set default-directory, and manually set buffer-file-name, ELPA Syncer, 2022/11/12
- [elpa] externals/jarchive 5736d46d33 24/33: Include hack to work with legacy versions of eglot., ELPA Syncer, 2022/11/12
- [elpa] externals/jarchive c8c12f1c9b 25/33: Update file preamble, ELPA Syncer, 2022/11/12
- [elpa] externals/jarchive bfcc201cca 33/33: Bump to version 0.1.0 was 0.3.0, ELPA Syncer, 2022/11/12