summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Albinus <michael.albinus@gmx.de>2022-11-20 17:58:34 +0100
committerMichael Albinus <michael.albinus@gmx.de>2022-11-20 17:58:34 +0100
commit7ad6104a17d2cff0be24fecb9eae58a8b41d5139 (patch)
tree5bf0b169faa9465f005cb5b5a80fc93069590a30
parent8874cd908c0ea0e2200f6f4f596bf645e76a0c0c (diff)
downloademacs-7ad6104a17d2cff0be24fecb9eae58a8b41d5139.tar.gz
Rework tramp-archive autoloads
* lisp/net/tramp-archive.el (tramp-archive-autoload-file-name-regexp): Use `tramp-compat-rx'. Protect `tramp-archive-suffixes' and `tramp-archive-compression-suffixes'. (tramp-archive-file-name-handler): Don't autoload. (tramp-register-archive-autoload-file-name-handler): Rename from `tramp-register-archive-file-name-handler'. Adapt callees.
-rw-r--r--lisp/net/tramp-archive.el24
1 files changed, 11 insertions, 13 deletions
diff --git a/lisp/net/tramp-archive.el b/lisp/net/tramp-archive.el
index 646ae864526..5b2af7c6b21 100644
--- a/lisp/net/tramp-archive.el
+++ b/lisp/net/tramp-archive.el
@@ -183,18 +183,20 @@ It must be supported by libarchive(3).")
;; The definition of `tramp-archive-file-name-regexp' contains calls
;; to `regexp-opt', which cannot be autoloaded while loading
;; loaddefs.el. So we use a macro, which is evaluated only when needed.
+;; When tramp-archive.el is unloaded and reloaded, it gripes about
+;; missing `tramp-archive{-compression]-suffixes'. We protect this.
;;;###autoload
(progn (defmacro tramp-archive-autoload-file-name-regexp ()
"Regular expression matching archive file names."
- `(rx
+ `(tramp-compat-rx
bos
;; This group is used in `tramp-archive-file-name-archive'.
(group
(+ nonl)
;; Default suffixes ...
- "." ,(cons '| tramp-archive-suffixes)
+ "." ,(cons '| (bound-and-true-p tramp-archive-suffixes))
;; ... with compression.
- (? "." ,(cons '| tramp-archive-compression-suffixes)))
+ (? "." ,(cons '| (bound-and-true-p tramp-archive-compression-suffixes))))
;; This group is used in `tramp-archive-file-name-localname'.
(group "/" (* nonl))
eos)))
@@ -330,10 +332,6 @@ arguments to pass to the OPERATION."
(inhibit-file-name-operation operation))
(apply operation args))))
-;; Starting with Emacs 29, `tramp-archive-file-name-handler' is
-;; autoloaded. But it must still be in tramp-loaddefs.el for older
-;; versions of Emacs.
-;;;###autoload(autoload 'tramp-archive-file-name-handler "tramp-archive")
;;;###tramp-autoload
(defun tramp-archive-file-name-handler (operation &rest args)
"Invoke the file archive related OPERATION.
@@ -396,30 +394,30 @@ arguments to pass to the OPERATION."
(put #'tramp-archive-autoload-file-name-handler 'tramp-autoload t)
;;;###autoload
-(progn (defun tramp-register-archive-file-name-handler ()
+(progn (defun tramp-register-archive-autoload-file-name-handler ()
"Add archive file name handler to `file-name-handler-alist'."
(when (and tramp-archive-enabled
(not
- (rassq #'tramp-archive-file-name-handler file-name-handler-alist)))
+ (rassq 'tramp-archive-file-name-handler file-name-handler-alist)))
(add-to-list 'file-name-handler-alist
(cons (tramp-archive-autoload-file-name-regexp)
#'tramp-archive-autoload-file-name-handler))
(put #'tramp-archive-autoload-file-name-handler 'safe-magic t))))
-(put #'tramp-register-archive-file-name-handler 'tramp-autoload t)
+(put #'tramp-register-archive-autoload-file-name-handler 'tramp-autoload t)
;;;###autoload
(progn
- (add-hook 'after-init-hook #'tramp-register-archive-file-name-handler)
+ (add-hook 'after-init-hook #'tramp-register-archive-autoload-file-name-handler)
(add-hook
'tramp-archive-unload-hook
(lambda ()
(remove-hook
- 'after-init-hook #'tramp-register-archive-file-name-handler))))
+ 'after-init-hook #'tramp-register-archive-autoload-file-name-handler))))
;; In older Emacsen (prior 27.1), the autoload above does not exist.
;; So we call it again; it doesn't hurt.
-(tramp-register-archive-file-name-handler)
+(tramp-register-archive-autoload-file-name-handler)
;; Mark `operations' the handler is responsible for.
(put #'tramp-archive-file-name-handler 'operations