@title Configuring Gnus for reading news
+
+
@node Setting up the news server name and port number
@variable server :string (gnus-getenv-nntpserver)
@variable port :number 119
As a guess, the name of the server might be news.yourisp.com.
-The server name is @variable{server}; port number @variable{port}.
+Server name: @variable{server}
+Port number: @variable{port}
+@end text
+@next t "User name and password"
+
+@node User name and password
+@variable user-name :string (user-login-name)
+@variable password :password (or (assistant-authinfo-data server port 'password) "")
+@validate "... lots of code ..."
+@result ... er... put stuff in .authinfo, I guess
+@text
+Some news servers require that you enter a user name and
+a password.
+
+@if (password-required-p)
+It looks like your news server is one of those.
+@else
+It doesn't look like your news server requires passwords.
+@endif
+
+User name: @variable{user-name}
+Password: @variable{password}
@end text
2004-05-23 Lars Magne Ingebrigtsen <larsi@gnus.org>
+ * assistant.el (assistant-authinfo-data): New function.
+ (assistant-eval): Eval for entire assistant.
+
+ * netrc.el (netrc-services-file): New variable.
+ (netrc-parse-services): New function.
+ (netrc-find-service-name): New function.
+ (netrc-find-service-number): New function.
+ (netrc-port-equal): New function.
+ (netrc-machine): Use it.
+
+ * nnimap.el (nnimap-open-connection): Use netrc.
+
+ * gnus-util.el (gnus-netrc-get): Remove aliases.
+
* gnus-sum.el (gnus-auto-center-summary): Change default to 2.
* assistant.el (wid-edit): Fix compilation.
(when (or (eq (nth 3 variable) 'default)
forcep)
(setcar (nthcdr 3 variable)
- (eval (nth 2 variable))))))
+ (assistant-eval (nth 2 variable))))))
(defun assistant-get-variable (node variable)
(let ((variables (assistant-get-list node "variable"))
result)
(assistant-validate-types node)
(when validation
- (when (setq result (assistant-eval validation node))
+ (when (setq result (assistant-eval validation))
(unless (y-or-n-p (format "Error: %s. Continue? " result))
(error "%s" result))))
(assistant-set node "save" t)))
(let* ((node (assistant-find-node assistant-current-node))
(nexts (assistant-get-list node "next"))
next elem)
- (while (and (setq elem (pop nexts))
+ (while (and (setq elem (cadr (pop nexts)))
(not next))
- (when (assistant-eval (car elem) node)
+ (when (assistant-eval (car elem))
(setq next (cadr elem))))
next))
-
-(defun assistant-eval (form node)
+
+(defun assistant-get-all-variables ()
+ (let ((variables nil))
+ (dolist (node (cdr assistant-data))
+ (setq variables
+ (append (assistant-get-list node "variable")
+ variables)))
+ variables))
+
+(defun assistant-eval (form)
(let ((bindings nil))
- (dolist (variable (assistant-get-list node "variable"))
+ (dolist (variable (assistant-get-all-variables))
(setq variable (cadr variable))
- (push (list (car variable) (nth 3 variable))
+ (push (list (car variable) (if (eq (nth 3 variable) 'default)
+ nil
+ (nth 3 variable)))
bindings))
(eval
`(let ,bindings
(when (assistant-get node "save")
(setq result (assistant-get node "result"))
(push (list (car result)
- (assistant-eval (cadr result) node))
+ (assistant-eval (cadr result)))
results)))
(message "Results: %s"
(nreverse results))))
nil)
error)))
+(defun assistant-authinfo-data (server port type)
+ (when (file-exists-p "~/.authinfo")
+ (netrc-get (netrc-machine (netrc-parse "~/.authinfo")
+ server port)
+ (if (eq type 'user)
+ "login"
+ "password"))))
+
(provide 'assistant)
;;; arch-tag: 0404bfa2-9226-4611-8d3f-335c2416175b
(defun gnus-replace-in-string (string regexp newtext &optional literal)
(replace-regexp-in-string regexp newtext string nil literal)))))
-;;; bring in the netrc functions as aliases
-(defalias 'gnus-netrc-get 'netrc-get)
-(defalias 'gnus-netrc-machine 'netrc-machine)
-(defalias 'gnus-parse-netrc 'netrc-parse)
-
(defun gnus-boundp (variable)
"Return non-nil if VARIABLE is bound and non-nil."
(and (boundp variable)
(const :tag "openssl is not installed" nil))
:group 'netrc)
+(defvar netrc-services-file "/etc/services"
+ "The name of the services file.")
+
(defun netrc-encrypt (plain-file encrypted-file)
(interactive "fPlain File: \nFEncrypted File: ")
"Encrypt FILE to ENCRYPTED-FILE with netrc-encrypting-method cipher."
(when result
(setq result (nreverse result))
(while (and result
- (not (equal (or port defaultport "nntp")
- (or (netrc-get (car result) "port")
- defaultport "nntp"))))
+ (not (netrc-port-equal
+ (or port defaultport "nntp")
+ (or (netrc-get (car result) "port")
+ defaultport "nntp"))))
(pop result))
(car result))))
"Return the value of token TYPE from ALIST."
(cdr (assoc type alist)))
+(defun netrc-port-equal (port1 port2)
+ (when (numberp port1)
+ (setq port1 (or (netrc-find-service-name port1) port1)))
+ (when (numberp port2)
+ (setq port2 (or (netrc-find-service-name port2) port2)))
+ (equal port1 port2))
+
+(defun netrc-parse-services ()
+ (when (file-exists-p netrc-services-file)
+ (let ((services nil))
+ (with-temp-buffer
+ (insert-file-contents netrc-services-file)
+ (while (search-forward "#" nil t)
+ (delete-region (1- (point)) (line-end-position)))
+ (goto-char (point-min))
+ (while (re-search-forward
+ "^ *\\([^ \n\t]+\\)[ \t]+\\([0-9]+\\)/\\([^ \t\n]+\\)" nil t)
+ (push (list (match-string 1) (string-to-number (match-string 2))
+ (intern (downcase (match-string 3))))
+ services))
+ (nreverse services)))))
+
+(defun netrc-find-service-name (number &optional type)
+ (let ((services (netrc-parse-services))
+ service)
+ (setq type (or type 'tcp))
+ (while (and (setq service (pop services))
+ (not (and (= number (cadr service))
+ (eq type (caddr service)))))
+ )
+ (car service)))
+
+(defun netrc-find-service-number (name &optional type)
+ (let ((services (netrc-parse-services))
+ service)
+ (setq type (or type 'tcp))
+ (while (and (setq service (pop services))
+ (not (and (string= name (car service))
+ (eq type (caddr service)))))
+ )
+ (cadr service)))
+
(provide 'netrc)
;;; netrc.el ends here
(imap-capability 'IMAP4rev1 nnimap-server-buffer))
(imap-close nnimap-server-buffer)
(nnheader-report 'nnimap "Server %s is not IMAP4 compliant" server))
- (let* ((list (gnus-parse-netrc nnimap-authinfo-file))
+ (let* ((list (netrc-parse nnimap-authinfo-file))
(port (if nnimap-server-port
(int-to-string nnimap-server-port)
"imap"))
- (alist (or (gnus-netrc-machine list server port "imap")
- (gnus-netrc-machine list
- (or nnimap-server-address
- nnimap-address)
- port "imap")))
- (user (gnus-netrc-get alist "login"))
- (passwd (gnus-netrc-get alist "password")))
+ (alist (or (netrc-machine list server port "imap")
+ (netrc-machine list
+ (or nnimap-server-address
+ nnimap-address)
+ port "imap")))
+ (user (netrc-get alist "login"))
+ (passwd (netrc-get alist "password")))
(if (imap-authenticate user passwd nnimap-server-buffer)
(prog1
(push (list server nnimap-server-buffer)
If SEND-IF-FORCE, only send authinfo to the server if the
.authinfo file has the FORCE token."
- (let* ((list (gnus-parse-netrc nntp-authinfo-file))
- (alist (gnus-netrc-machine list nntp-address "nntp"))
- (force (gnus-netrc-get alist "force"))
- (user (or (gnus-netrc-get alist "login") nntp-authinfo-user))
- (passwd (gnus-netrc-get alist "password")))
+ (let* ((list (netrc-parse nntp-authinfo-file))
+ (alist (netrc-machine list nntp-address "nntp"))
+ (force (netrc-get alist "force"))
+ (user (or (netrc-get alist "login") nntp-authinfo-user))
+ (passwd (netrc-get alist "password")))
(when (or (not send-if-force)
force)
(unless user