Changes committed gnus/lisp (ChangeLog auth-source.el)

"Ted Zlatanov" <[email protected]>
Newsgroups gmane.emacs.gnus.commits
Message-ID <[email protected]>
Modified: ChangeLog auth-source.el

Added docs.
(auth-sources): Modified format to support server.
(auth-source-pick, auth-source-user-or-password)
(auth-source-user-or-password-imap)
(auth-source-user-or-password-pop3, auth-source-user-or-password-ssh)
(auth-source-user-or-password-sftp)
(auth-source-user-or-password-smtp): Add server parameter.


Index: ChangeLog
diff -u gnus/lisp/ChangeLog:7.1824 gnus/lisp/ChangeLog:7.1825
--- ChangeLog:7.1824	Tue Apr  8 23:17:29 2008
+++ ChangeLog	Wed Apr  9 22:16:17 2008
@@ -1,3 +1,13 @@
+2008-04-09  Teodor Zlatanov  <[email protected]>
+
+	* auth-source.el: Added docs.
+	(auth-sources): Modified format to support server.
+	(auth-source-pick, auth-source-user-or-password)
+	(auth-source-user-or-password-imap)
+	(auth-source-user-or-password-pop3, auth-source-user-or-password-ssh)
+	(auth-source-user-or-password-sftp)
+	(auth-source-user-or-password-smtp): Add server parameter.
+
 2008-04-08  Teodor Zlatanov  <[email protected]>
 
 	* gnus-registry.el: Initialize the registry when gnus-registry-install
Index: auth-source.el
diff -u gnus/lisp/auth-source.el:7.4 gnus/lisp/auth-source.el:7.5
--- auth-source.el:7.4	Thu Mar 13 10:58:46 2008
+++ auth-source.el	Wed Apr  9 22:16:17 2008
@@ -28,6 +28,19 @@
 ;; authenticate in a single place.  Simplicity is the goal.  Instead
 ;; of providing 5000 options, we'll stick to simple, easy to
 ;; understand options.
+
+;; Easy setup:
+;; (require 'auth-source)
+;; (customize-variable 'auth-sources) ;; optional
+
+;; now, whatever sources you've defined for password have to be available
+
+;; if you want encrypted sources, which is strongly recommended, do
+;; (require 'epa-file)
+;; (epa-file-mode)
+
+;; before you put some data in ~/.authinfo.gpg (the default place)
+
 ;;; Code:
 
 (eval-when-compile (require 'cl))
@@ -73,10 +86,15 @@
 		 (list :tag "Source definition"
 		       (const :format "" :value :source)
 		       (string :tag "Authentication Source")
+		       (const :format "" :value :server)
+		       (choice :tag "Server (logical name) choice"
+			       (const :tag "Any" t)
+			       (regexp :tag "Server regular expression (TODO)")
+			       (const :tag "Fallback" nil))
 		       (const :format "" :value :host)
-		       (choice :tag "Host choice"
+		       (choice :tag "Host (machine) choice"
 			       (const :tag "Any" t)
-			       (regexp :tag "Host regular expression (TODO)")
+			       (regexp :tag "Host (machine) regular expression (TODO)")
 			       (const :tag "Fallback" nil))
 		       (const :format "" :value :protocol)
 		       (choice :tag "Protocol"
@@ -100,16 +118,20 @@
 ;; (auth-source-user-or-password-imap "password" "imap.myhost.com")
 ;; (auth-source-protocol-defaults 'imap)
 
-(defun auth-source-pick (host protocol &optional fallback)
-  "Parse `auth-sources' for HOST and PROTOCOL matches.
+(defun auth-source-pick (server host protocol &optional fallback)
+  "Parse `auth-sources' for SERVER, HOST, and PROTOCOL matches.
 
-Returns fallback choices (where PROTOCOL or HOST are nil) with FALLBACK t."
+Returns fallback choices (where SERVER. PROTOCOL or HOST are nil) with FALLBACK t."
   (interactive "sHost: \nsProtocol: \n") ;for testing
   (let (choices)
     (dolist (choice auth-sources)
-      (let ((h (plist-get choice :host))
+      (let ((s (plist-get choice :server))
+	    (h (plist-get choice :host))
 	    (p (plist-get choice :protocol)))
 	(when (and
+	       (or (equal t s)
+		   (and (stringp s) (string-match s server))
+		   (and fallback (equal s nil)))
 	       (or (equal t h)
 		   (and (stringp h) (string-match h host))
 		   (and fallback (equal h nil)))
@@ -120,12 +142,12 @@
     (if choices
 	choices
       (unless fallback
-	(auth-source-pick host protocol t)))))
+	(auth-source-pick server host protocol t)))))
 
-(defun auth-source-user-or-password (mode host protocol)
-  "Find user or password (from the string MODE) matching HOST and PROTOCOL."
+(defun auth-source-user-or-password (mode server host protocol)
+  "Find user or password (from the string MODE) matching SERVER, HOST, and PROTOCOL."
   (let (found)
-    (dolist (choice (auth-source-pick host protocol))
+    (dolist (choice (auth-source-pick server host protocol))
       (setq found (netrc-machine-user-or-password 
 		   mode
 		   (plist-get choice :source)
@@ -139,20 +161,20 @@
   "Return a list of default ports and names for PROTOCOL."
   (cdr-safe (assoc protocol auth-source-protocols)))
 
-(defun auth-source-user-or-password-imap (mode host)
-  (auth-source-user-or-password mode host 'imap))
+(defun auth-source-user-or-password-imap (mode server host)
+  (auth-source-user-or-password mode server host 'imap))
 
-(defun auth-source-user-or-password-pop3 (mode host)
-  (auth-source-user-or-password mode host 'pop3))
+(defun auth-source-user-or-password-pop3 (mode server host)
+  (auth-source-user-or-password mode server host 'pop3))
 
-(defun auth-source-user-or-password-ssh (mode host)
-  (auth-source-user-or-password mode host 'ssh))
+(defun auth-source-user-or-password-ssh (mode server host)
+  (auth-source-user-or-password mode server host 'ssh))
 
-(defun auth-source-user-or-password-sftp (mode host)
-  (auth-source-user-or-password mode host 'sftp))
+(defun auth-source-user-or-password-sftp (mode server host)
+  (auth-source-user-or-password mode server host 'sftp))
 
-(defun auth-source-user-or-password-smtp (mode host)
-  (auth-source-user-or-password mode host 'smtp))
+(defun auth-source-user-or-password-smtp (mode server host)
+  (auth-source-user-or-password mode server host 'smtp))
 
 (provide 'auth-source)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.