From 17c78c992041b5a250e1f44019a3f47d447acc85 Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Sat, 24 Jan 2026 10:15:29 +0100 Subject: [PATCH] ; Tramp code cleanup * lisp/net/tramp-cache.el (tramp-cache-unload-hook): * lisp/net/tramp-cmds.el (tramp-enable-method, tramp-bug): * lisp/net/tramp-compat.el: * test/lisp/net/tramp-tests.el (tramp-test26-interactive-file-name-completion): Simplify retrieving proper function symbols. --- lisp/net/tramp-cache.el | 10 +++------- lisp/net/tramp-cmds.el | 5 ++--- lisp/net/tramp-compat.el | 4 ++-- test/lisp/net/tramp-tests.el | 2 +- 4 files changed, 8 insertions(+), 13 deletions(-) diff --git a/lisp/net/tramp-cache.el b/lisp/net/tramp-cache.el index bb9179630cb..1fc3fb3aeae 100644 --- a/lisp/net/tramp-cache.el +++ b/lisp/net/tramp-cache.el @@ -202,11 +202,6 @@ Return DEFAULT if not set." (set var (1+ val)))) value))) -(add-hook 'tramp-cache-unload-hook - (lambda () - (dolist (var (all-completions "tramp-cache-get-count-" obarray)) - (unintern var obarray)))) - ;;;###tramp-autoload (defun tramp-set-file-property (key file property value) "Set the PROPERTY of FILE to VALUE, in the cache context of KEY. @@ -229,8 +224,9 @@ Return VALUE." (add-hook 'tramp-cache-unload-hook (lambda () - (dolist (var (all-completions "tramp-cache-set-count-" obarray)) - (unintern var obarray)))) + (dolist (var (apropos-internal + (rx bos "tramp-cache-" (| "get" "set") "-count-"))) + (unintern var nil)))) ;;;###tramp-autoload (defun tramp-file-property-p (key file property) diff --git a/lisp/net/tramp-cmds.el b/lisp/net/tramp-cmds.el index 84c1c7ea7f4..95e1c5ecad8 100644 --- a/lisp/net/tramp-cmds.el +++ b/lisp/net/tramp-cmds.el @@ -78,8 +78,7 @@ SYNTAX can be one of the symbols `default' (default), ((not (assoc method tramp-methods)))) method)) ;; All method enabling functions. - (mapcar - #'intern (all-completions "tramp-enable-" obarray #'functionp)))))) + (apropos-internal (rx bos "tramp-enable-") #'functionp))))) (when-let* (((not (assoc method tramp-methods))) (fn (intern (format "tramp-enable-%s-method" method))) @@ -839,7 +838,7 @@ This is needed if there are compatibility problems." (and x (boundp x) (not (get x 'tramp-suppress-trace)) (cons x 'tramp-reporter-dump-variable))) (append - (mapcar #'intern (all-completions "tramp-" obarray #'boundp)) + (apropos-internal (rx bos "tramp-") #'boundp) ;; Non-Tramp variables of interest. '(shell-prompt-pattern backup-by-copying diff --git a/lisp/net/tramp-compat.el b/lisp/net/tramp-compat.el index c9a728e2be1..f975457d4df 100644 --- a/lisp/net/tramp-compat.el +++ b/lisp/net/tramp-compat.el @@ -229,8 +229,8 @@ value is the default binding of the variable." (cdr result) ,variable))))) -(dolist (elt (all-completions "tramp-compat-" obarray #'functionp)) - (function-put (intern elt) 'tramp-suppress-trace t)) +(dolist (elt (apropos-internal (rx bos "tramp-compat-") #'functionp)) + (function-put elt 'tramp-suppress-trace t)) (add-hook 'tramp-unload-hook (lambda () diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index 7391eb56058..20e76e5fe9b 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el @@ -5060,7 +5060,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." (dolist (elt (append - (mapcar #'intern (all-completions "tramp-" obarray #'functionp)) + (apropos-internal (rx bos "tramp-") #'functionp) '(completion-file-name-table read-file-name))) (unless (get elt 'tramp-suppress-trace) (trace-function-background elt))))