From a5841b196f12894df4c1bb073f28ddadb6faa3cf Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Mon, 28 Mar 2022 12:02:23 +0200 Subject: [PATCH] Do not register Tramp file name handlers twice * lisp/net/tramp.el (tramp-register-autoload-file-name-handlers): * lisp/net/tramp-archive.el (tramp-register-archive-file-name-handler): Check, whether the real file name handler is already registered. --- lisp/net/tramp-archive.el | 4 +++- lisp/net/tramp.el | 9 +++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lisp/net/tramp-archive.el b/lisp/net/tramp-archive.el index 788e4573679..890c8dbb755 100644 --- a/lisp/net/tramp-archive.el +++ b/lisp/net/tramp-archive.el @@ -374,7 +374,9 @@ arguments to pass to the OPERATION." ;;;###autoload (progn (defun tramp-register-archive-file-name-handler () "Add archive file name handler to `file-name-handler-alist'." - (when tramp-archive-enabled + (when (and tramp-archive-enabled + (not + (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)) diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 0192a63a104..580cfea1f85 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -2756,10 +2756,11 @@ Falls back to normal file name handler if no Tramp file name handler exists." ;;;###autoload (progn (defun tramp-register-autoload-file-name-handlers () "Add Tramp file name handlers to `file-name-handler-alist' during autoload." - (add-to-list 'file-name-handler-alist - (cons tramp-autoload-file-name-regexp - #'tramp-autoload-file-name-handler)) - (put #'tramp-autoload-file-name-handler 'safe-magic t))) + (unless (rassq #'tramp-file-name-handler file-name-handler-alist) + (add-to-list 'file-name-handler-alist + (cons tramp-autoload-file-name-regexp + #'tramp-autoload-file-name-handler)) + (put #'tramp-autoload-file-name-handler 'safe-magic t)))) (put #'tramp-register-autoload-file-name-handlers 'tramp-autoload t) ;;;###autoload (tramp-register-autoload-file-name-handlers) -- 2.39.2