From a08dd087e9460322cc39aa387a8bb2bf70ec1abd Mon Sep 17 00:00:00 2001 From: Michael Albinus Date: Thu, 4 Aug 2022 19:27:49 +0200 Subject: [PATCH] Adapt Tramp for backward compatibility * lisp/net/tramp-compat.el (tramp-compat-auth-source-netrc-parse-all): New defalias. * lisp/net/tramp.el (tramp-parse-netrc): Use it. (Bug#56976) --- lisp/net/tramp-compat.el | 10 ++++++++++ lisp/net/tramp.el | 4 +--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/lisp/net/tramp-compat.el b/lisp/net/tramp-compat.el index e8135332700..b83f9f0724e 100644 --- a/lisp/net/tramp-compat.el +++ b/lisp/net/tramp-compat.el @@ -320,6 +320,16 @@ CONDITION can also be a list of error conditions." (lambda (string1 string2) (eq t (compare-strings string1 nil nil string2 nil nil t))))) +;; Function `auth-source-netrc-parse-all' is new in Emacs 29.1. +;; `netrc-parse' has been obsoleted in parallel. +(defalias 'tramp-compat-auth-source-netrc-parse-all + (if (fboundp 'auth-source-netrc-parse-all) + #'auth-source-netrc-parse-all + (lambda (&optional file) + (declare-function netrc-parse "netrc") + (autoload 'netrc-parse "netrc") + (netrc-parse file)))) + (dolist (elt (all-completions "tramp-compat-" obarray 'functionp)) (put (intern elt) 'tramp-suppress-trace t)) diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index a35b9baaa8c..dcc8c632f91 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -3340,13 +3340,11 @@ Host is always \"localhost\"." (defun tramp-parse-netrc (filename) "Return a list of (user host) tuples allowed to access. User may be nil." - ;; The declaration is not sufficient at runtime, because netrc.el is - ;; not autoloaded. (mapcar (lambda (item) (and (assoc "machine" item) `(,(cdr (assoc "login" item)) ,(cdr (assoc "machine" item))))) - (auth-source-netrc-parse-all filename))) + (tramp-compat-auth-source-netrc-parse-all filename))) (defun tramp-parse-putty (registry-or-dirname) "Return a list of (user host) tuples allowed to access. -- 2.39.2