From: Michael Albinus Date: Thu, 4 Aug 2022 17:27:49 +0000 (+0200) Subject: Adapt Tramp for backward compatibility X-Git-Tag: emacs-29.0.90~1447^2~433 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=a08dd087e9460322cc39aa387a8bb2bf70ec1abd;p=emacs.git 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) --- 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.