summaryrefslogtreecommitdiff
path: root/lisp/net/netrc.el
diff options
context:
space:
mode:
authorLars Magne Ingebrigtsen <larsi@gnus.org>2010-09-11 00:36:27 +0000
committerKatsumi Yamaoka <yamaoka@jpl.org>2010-09-11 00:36:27 +0000
commita9ec34f4c483f5d501c2f6db16e3423b22385cc9 (patch)
treeacd5321b814d4e0df9cc358239808bbbde62b93e /lisp/net/netrc.el
parentcf38dd429888fc992408716922ecab1c39242944 (diff)
downloademacs-a9ec34f4c483f5d501c2f6db16e3423b22385cc9.tar.gz
Merge changes made in Gnus trunk.
gnus-sum.el: Avoid calling a hook function per summary line; Call `gnus-summary-highlight-line' directly from all places that used to call it indirectly. netrc.el (netrc-credentials): New conveniency function. gnus-start.el (gnus-read-active-file-1): If gnus-agent isn't set, then do request scans from the backends.
Diffstat (limited to 'lisp/net/netrc.el')
-rw-r--r--lisp/net/netrc.el22
1 files changed, 21 insertions, 1 deletions
diff --git a/lisp/net/netrc.el b/lisp/net/netrc.el
index 2306927f080..408eca9bac7 100644
--- a/lisp/net/netrc.el
+++ b/lisp/net/netrc.el
@@ -54,12 +54,19 @@
"Netrc configuration."
:group 'comm)
+(defcustom netrc-file "~/.authinfo"
+ "File where user credentials are stored."
+ :type 'file
+ :group 'netrc)
+
(defvar netrc-services-file "/etc/services"
"The name of the services file.")
-(defun netrc-parse (file)
+(defun netrc-parse (&optional file)
(interactive "fFile to Parse: ")
"Parse FILE and return a list of all entries in the file."
+ (unless file
+ (setq file netrc-file))
(if (listp file)
file
(when (file-exists-p file)
@@ -221,6 +228,19 @@ MODE can be \"login\" or \"password\", suitable for passing to
(eq type (car (cddr service)))))))
(cadr service)))
+(defun netrc-credentials (machine &rest ports)
+ "Return a user name/password pair.
+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))))
+ (when found
+ (list (cdr (assoc "login" found))
+ (cdr (assoc "password" found))))))
+
(provide 'netrc)
;;; netrc.el ends here