From: yamaoka Date: Sun, 23 May 2004 22:15:01 +0000 (+0000) Subject: Synch to No Gnus 200405232116. X-Git-Tag: t-gnus-6_17_4-quimby-~904 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=5f9444fa2a348e90897d5aecc1ce2d47a4d7601b;p=elisp%2Fgnus.git- Synch to No Gnus 200405232116. --- diff --git a/etc/gnus/news-server.ast b/etc/gnus/news-server.ast index b62d134..dd98c12 100644 --- a/etc/gnus/news-server.ast +++ b/etc/gnus/news-server.ast @@ -1,4 +1,6 @@ @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 @@ -10,5 +12,26 @@ server. If you don't know the name of this server, contact your ISP. 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 diff --git a/lisp/ChangeLog b/lisp/ChangeLog index bf92fd8..b07d923 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,19 @@ 2004-05-23 Lars Magne Ingebrigtsen + * 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. diff --git a/lisp/assistant.el b/lisp/assistant.el index 92882bc..176d29d 100644 --- a/lisp/assistant.el +++ b/lisp/assistant.el @@ -184,7 +184,7 @@ (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")) @@ -312,7 +312,7 @@ 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))) @@ -321,17 +321,27 @@ (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 @@ -344,7 +354,7 @@ (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)))) @@ -364,6 +374,14 @@ 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 diff --git a/lisp/gnus-util.el b/lisp/gnus-util.el index f3ff20d..c81206d 100644 --- a/lisp/gnus-util.el +++ b/lisp/gnus-util.el @@ -66,11 +66,6 @@ (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) diff --git a/lisp/netrc.el b/lisp/netrc.el index b561885..236af15 100644 --- a/lisp/netrc.el +++ b/lisp/netrc.el @@ -60,6 +60,9 @@ have set netrc-encrypting-method to a non-nil value." (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." @@ -186,9 +189,10 @@ Entries without port tokens default to DEFAULTPORT." (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)))) @@ -196,6 +200,48 @@ Entries without port tokens default to DEFAULTPORT." "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 diff --git a/lisp/nnimap.el b/lisp/nnimap.el index 91a1a2b..0acdd13 100644 --- a/lisp/nnimap.el +++ b/lisp/nnimap.el @@ -754,17 +754,17 @@ If EXAMINE is non-nil the group is selected read-only." (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) diff --git a/lisp/nntp.el b/lisp/nntp.el index 53ce24c..027974e 100644 --- a/lisp/nntp.el +++ b/lisp/nntp.el @@ -1155,11 +1155,11 @@ and a password. 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