From 126291993f8986171774e37e904db5edb563b16b Mon Sep 17 00:00:00 2001 From: Lars Magne Ingebrigtsen Date: Thu, 30 Sep 2010 22:07:11 +0200 Subject: [PATCH] netrc.el: Return the value of the "default" entry. --- lisp/ChangeLog | 4 ++++ lisp/netrc.el | 32 +++++++++++++++++++------------- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 4f387ccdd..9a1c08055 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,9 @@ 2010-09-30 Lars Magne Ingebrigtsen + * netrc.el (netrc-credentials): Return the value of the "default" + entry. + (netrc-machine): Ditto. + * nnimap.el (nnimap-find-article-by-message-id): Really return the article number. (nnimap-split-fancy): New variable. diff --git a/lisp/netrc.el b/lisp/netrc.el index d76b8cf3a..ff0b52c2b 100644 --- a/lisp/netrc.el +++ b/lisp/netrc.el @@ -131,19 +131,23 @@ Entries without port tokens default to DEFAULTPORT." ;; No machine name matches, so we look for default entries. (while rest (when (assoc "default" (car rest)) - (push (car rest) result)) + (let ((elem (car rest))) + (setq elem (delete (assoc "default" elem) elem)) + (push elem result))) (pop rest))) (when result (setq result (nreverse result)) - (while (and result - (not (netrc-port-equal - (or port defaultport "nntp") - ;; when port is not given in the netrc file, - ;; it should mean "any port" - (or (netrc-get (car result) "port") - defaultport port)))) - (pop result)) - (car result)))) + (if (not port) + (car result) + (while (and result + (not (netrc-port-equal + (or port defaultport "nntp") + ;; when port is not given in the netrc file, + ;; it should mean "any port" + (or (netrc-get (car result) "port") + defaultport port)))) + (pop result)) + (car result))))) (defun netrc-machine-user-or-password (mode authinfo-file-or-list machines ports defaults) "Get the user name or password according to MODE from AUTHINFO-FILE-OR-LIST. @@ -238,9 +242,11 @@ Port specifications will be prioritised in the order they are listed in the PORTS list." (let ((list (netrc-parse)) found) - (while (and ports - (not found)) - (setq found (netrc-machine list machine (pop ports)))) + (if (not ports) + (setq found (netrc-machine list machine)) + (while (and ports + (not found)) + (setq found (netrc-machine list machine (pop ports))))) (when found (list (cdr (assoc "login" found)) (cdr (assoc "password" found)))))) -- 2.25.1