X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=lisp%2Fnntp.el;h=3f1c00fb7c396f46b5f8508ce72115c0f7ed64b0;hb=49e6091148fad026ec5a2324eaff06c145506235;hp=5b6545f0697981d59234e423d18eee4b3617cd45;hpb=09ce75ba898863f981b4706df3f1cc6a501d25fc;p=elisp%2Fgnus.git- diff --git a/lisp/nntp.el b/lisp/nntp.el index 5b6545f..3f1c00f 100644 --- a/lisp/nntp.el +++ b/lisp/nntp.el @@ -30,10 +30,6 @@ (nnoo-declare nntp) -(eval-and-compile - (unless (fboundp 'open-network-stream) - (require 'tcp))) - (eval-when-compile (require 'cl)) (defvoo nntp-address nil @@ -179,6 +175,10 @@ server there that you can connect to. See also +(defvoo nntp-connection-timeout nil + "*Number of seconds to wait before an nntp connection times out. +If this variable is nil, which is the default, no timers are set.") + ;;; Internal variables. (defvar nntp-record-commands nil @@ -396,11 +396,11 @@ server there that you can connect to. See also (cond ;; A result that starts with a 2xx code is terminated by ;; a line with only a "." on it. - ((eq (following-char) ?2) + ((eq (char-after) ?2) (if (re-search-forward "\n\\.\r?\n" nil t) t nil)) - ;; A result that startx with a 3xx or 4xx code is terminated + ;; A result that starts with a 3xx or 4xx code is terminated ;; by a newline. ((looking-at "[34]") (if (search-forward "\n" nil t) @@ -545,7 +545,7 @@ server there that you can connect to. See also (nntp-inhibit-erase t) (map (apply 'vector articles)) (point 1) - article alist) + article) (set-buffer buf) (erase-buffer) ;; Send ARTICLE command. @@ -585,7 +585,7 @@ server there that you can connect to. See also (nnheader-message 6 "NNTP: Receiving articles...done")) ;; Now we have all the responses. We go through the results, - ;; washes it and copies it over to the server buffer. + ;; wash it and copy it over to the server buffer. (set-buffer nntp-server-buffer) (erase-buffer) (setq last-point (point-min)) @@ -684,6 +684,10 @@ server there that you can connect to. See also (ignore-errors (nntp-send-string process "QUIT") (unless (eq nntp-open-connection-function 'nntp-open-network-stream) + ;; Ok, this is evil, but when using telnet and stuff + ;; as the connection method, it's important that the + ;; QUIT command actually is sent out before we kill + ;; the process. (sleep-for 1)))) (when (buffer-name (process-buffer process)) (kill-buffer (process-buffer process))) @@ -720,7 +724,7 @@ server there that you can connect to. See also (prog1 (nntp-send-command "^\\.\r?\n" "NEWGROUPS" - (format-time-string "%y%m%d %H%M%S" (nnmail-date-to-time date))) + (format-time-string "%y%m%d %H%M%S" (date-to-time date))) (nntp-decode-text)))) (deffoo nntp-request-post (&optional server) @@ -788,7 +792,7 @@ If SEND-IF-FORCE, only send authinfo to the server if the The authinfo login name is taken from the user's login name and the password contained in '~/.nntp-authinfo'." (when (file-exists-p "~/.nntp-authinfo") - (nnheader-temp-write nil + (with-temp-buffer (insert-file-contents "~/.nntp-authinfo") (goto-char (point-min)) (nntp-send-command "^3.*\r?\n" "AUTHINFO USER" (user-login-name)) @@ -817,7 +821,6 @@ password contained in '~/.nntp-authinfo'." (format " *server %s %s %s*" nntp-address nntp-port-number (gnus-buffer-exists-p buffer)))) - (buffer-disable-undo (current-buffer)) (set (make-local-variable 'after-change-functions) nil) (set (make-local-variable 'nntp-process-wait-for) nil) (set (make-local-variable 'nntp-process-callback) nil) @@ -830,6 +833,13 @@ password contained in '~/.nntp-authinfo'." "Open a connection to PORT on ADDRESS delivering output to BUFFER." (run-hooks 'nntp-prepare-server-hook) (let* ((pbuffer (nntp-make-process-buffer buffer)) + (timer + (and nntp-connection-timeout + (nnheader-run-at-time + nntp-connection-timeout nil + `(lambda () + (when (buffer-name ,pbuffer) + (kill-buffer ,pbuffer)))))) (process (condition-case () (let ((coding-system-for-read nntp-coding-system-for-read) @@ -837,7 +847,10 @@ password contained in '~/.nntp-authinfo'." (funcall nntp-open-connection-function pbuffer)) (error nil) (quit nil)))) - (when process + (when timer + (nnheader-cancel-timer timer)) + (when (and (buffer-name pbuffer) + process) (process-kill-without-query process) (nntp-wait-for process "^.*\n" buffer nil t) (if (memq (process-status process) '(open run)) @@ -1001,10 +1014,7 @@ password contained in '~/.nntp-authinfo'." (while (not (eobp)) (end-of-line) (delete-char 1) - (insert nntp-end-of-line)) - (forward-char -1) - (unless (eq (char-after (1- (point))) ?\r) - (insert "\r")))) + (insert nntp-end-of-line)))) (defun nntp-retrieve-headers-with-xover (articles &optional fetch-old) (set-buffer nntp-server-buffer)