emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master a08dd087e9: Adapt Tramp for backward compatibility


From: Michael Albinus
Subject: master a08dd087e9: Adapt Tramp for backward compatibility
Date: Thu, 4 Aug 2022 13:27:59 -0400 (EDT)

branch: master
commit a08dd087e9460322cc39aa387a8bb2bf70ec1abd
Author: Michael Albinus <michael.albinus@gmx.de>
Commit: Michael Albinus <michael.albinus@gmx.de>

    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 e813533270..b83f9f0724 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 a35b9baaa8..dcc8c632f9 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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]