diff options
| author | Stefan Monnier | 2008-03-12 19:56:09 +0000 |
|---|---|---|
| committer | Stefan Monnier | 2008-03-12 19:56:09 +0000 |
| commit | ed075cb4ea51a597169a5c0cab847abacc3e9739 (patch) | |
| tree | 9b20240c33406b86abdc0310078ac0f868ea4f14 | |
| parent | f15a9fec25936a9e45b08776747a7320b04ad3ef (diff) | |
| download | emacs-ed075cb4ea51a597169a5c0cab847abacc3e9739.tar.gz emacs-ed075cb4ea51a597169a5c0cab847abacc3e9739.zip | |
Use with-current-buffer.
(nntp-send-buffer): Just set the buffer to unibyte rather than use the
dubious mm-with-unibyte-current-buffer.
(nntp-with-open-group-function): New function extracted from
nntp-with-open-group macro.
(nntp-with-open-group): Use the function, so it's easier to debug.
Add indentation and debugging info.
(nntp-open-telnet-stream, nntp-open-via-rlogin-and-telnet): Recommend the
use of the netcat alternatives.
| -rw-r--r-- | lisp/gnus/ChangeLog | 10 | ||||
| -rw-r--r-- | lisp/gnus/nntp.el | 192 |
2 files changed, 105 insertions, 97 deletions
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog index 3e18bdd9c1f..6b4371d6543 100644 --- a/lisp/gnus/ChangeLog +++ b/lisp/gnus/ChangeLog | |||
| @@ -1,5 +1,15 @@ | |||
| 1 | 2008-03-12 Stefan Monnier <monnier@iro.umontreal.ca> | 1 | 2008-03-12 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 2 | ||
| 3 | * nntp.el: Use with-current-buffer. | ||
| 4 | (nntp-send-buffer): Just set the buffer to unibyte rather than use the | ||
| 5 | dubious mm-with-unibyte-current-buffer. | ||
| 6 | (nntp-with-open-group-function): New function extracted from | ||
| 7 | nntp-with-open-group macro. | ||
| 8 | (nntp-with-open-group): Use the function, so it's easier to debug. | ||
| 9 | Add indentation and debugging info. | ||
| 10 | (nntp-open-telnet-stream, nntp-open-via-rlogin-and-telnet): Recommend the | ||
| 11 | use of the netcat alternatives. | ||
| 12 | |||
| 3 | * rfc2047.el (rfc2047-decode-string): Don't use `m'. | 13 | * rfc2047.el (rfc2047-decode-string): Don't use `m'. |
| 4 | Avoid mm-string-as-multibyte as well. | 14 | Avoid mm-string-as-multibyte as well. |
| 5 | 15 | ||
diff --git a/lisp/gnus/nntp.el b/lisp/gnus/nntp.el index 9b32f7c95ec..f318ee303f0 100644 --- a/lisp/gnus/nntp.el +++ b/lisp/gnus/nntp.el | |||
| @@ -335,8 +335,7 @@ backend doesn't catch this error.") | |||
| 335 | 335 | ||
| 336 | (defun nntp-record-command (string) | 336 | (defun nntp-record-command (string) |
| 337 | "Record the command STRING." | 337 | "Record the command STRING." |
| 338 | (save-excursion | 338 | (with-current-buffer (get-buffer-create "*nntp-log*") |
| 339 | (set-buffer (get-buffer-create "*nntp-log*")) | ||
| 340 | (goto-char (point-max)) | 339 | (goto-char (point-max)) |
| 341 | (let ((time (current-time))) | 340 | (let ((time (current-time))) |
| 342 | (insert (format-time-string "%Y%m%dT%H%M%S" time) | 341 | (insert (format-time-string "%Y%m%dT%H%M%S" time) |
| @@ -393,8 +392,7 @@ be restored and the command retried." | |||
| 393 | (defsubst nntp-wait-for (process wait-for buffer &optional decode discard) | 392 | (defsubst nntp-wait-for (process wait-for buffer &optional decode discard) |
| 394 | "Wait for WAIT-FOR to arrive from PROCESS." | 393 | "Wait for WAIT-FOR to arrive from PROCESS." |
| 395 | 394 | ||
| 396 | (save-excursion | 395 | (with-current-buffer (process-buffer process) |
| 397 | (set-buffer (process-buffer process)) | ||
| 398 | (goto-char (point-min)) | 396 | (goto-char (point-min)) |
| 399 | 397 | ||
| 400 | (while (and (or (not (memq (char-after (point)) '(?2 ?3 ?4 ?5))) | 398 | (while (and (or (not (memq (char-after (point)) '(?2 ?3 ?4 ?5))) |
| @@ -432,8 +430,7 @@ be restored and the command retried." | |||
| 432 | (setq nntp-process-response response))) | 430 | (setq nntp-process-response response))) |
| 433 | (nntp-decode-text (not decode)) | 431 | (nntp-decode-text (not decode)) |
| 434 | (unless discard | 432 | (unless discard |
| 435 | (save-excursion | 433 | (with-current-buffer buffer |
| 436 | (set-buffer buffer) | ||
| 437 | (goto-char (point-max)) | 434 | (goto-char (point-max)) |
| 438 | (nntp-insert-buffer-substring (process-buffer process)) | 435 | (nntp-insert-buffer-substring (process-buffer process)) |
| 439 | ;; Nix out "nntp reading...." message. | 436 | ;; Nix out "nntp reading...." message. |
| @@ -539,8 +536,7 @@ be restored and the command retried." | |||
| 539 | nntp-open-connection-function | 536 | nntp-open-connection-function |
| 540 | nntp-open-connection-functions-never-echo-commands)) | 537 | nntp-open-connection-functions-never-echo-commands)) |
| 541 | (nntp-accept-response) | 538 | (nntp-accept-response) |
| 542 | (save-excursion | 539 | (with-current-buffer buffer |
| 543 | (set-buffer buffer) | ||
| 544 | (goto-char pos) | 540 | (goto-char pos) |
| 545 | (if (looking-at (regexp-quote command)) | 541 | (if (looking-at (regexp-quote command)) |
| 546 | (delete-region pos (progn (forward-line 1) | 542 | (delete-region pos (progn (forward-line 1) |
| @@ -563,8 +559,7 @@ be restored and the command retried." | |||
| 563 | ;; If nothing to wait for, still remove possibly echo'ed commands | 559 | ;; If nothing to wait for, still remove possibly echo'ed commands |
| 564 | (unless wait-for | 560 | (unless wait-for |
| 565 | (nntp-accept-response) | 561 | (nntp-accept-response) |
| 566 | (save-excursion | 562 | (with-current-buffer buffer |
| 567 | (set-buffer buffer) | ||
| 568 | (goto-char pos) | 563 | (goto-char pos) |
| 569 | (if (looking-at (regexp-quote command)) | 564 | (if (looking-at (regexp-quote command)) |
| 570 | (delete-region pos (progn (forward-line 1) | 565 | (delete-region pos (progn (forward-line 1) |
| @@ -590,8 +585,7 @@ be restored and the command retried." | |||
| 590 | ;; If nothing to wait for, still remove possibly echo'ed commands | 585 | ;; If nothing to wait for, still remove possibly echo'ed commands |
| 591 | (unless wait-for | 586 | (unless wait-for |
| 592 | (nntp-accept-response) | 587 | (nntp-accept-response) |
| 593 | (save-excursion | 588 | (with-current-buffer buffer |
| 594 | (set-buffer buffer) | ||
| 595 | (goto-char pos) | 589 | (goto-char pos) |
| 596 | (if (looking-at (regexp-quote command)) | 590 | (if (looking-at (regexp-quote command)) |
| 597 | (delete-region pos (progn (forward-line 1) (point-at-bol)))) | 591 | (delete-region pos (progn (forward-line 1) (point-at-bol)))) |
| @@ -607,10 +601,12 @@ be restored and the command retried." | |||
| 607 | (nntp-erase-buffer | 601 | (nntp-erase-buffer |
| 608 | (nntp-find-connection-buffer nntp-server-buffer))) | 602 | (nntp-find-connection-buffer nntp-server-buffer))) |
| 609 | (nntp-encode-text) | 603 | (nntp-encode-text) |
| 610 | (mm-with-unibyte-current-buffer | 604 | ;; Make sure we did not forget to encode some of the content. |
| 611 | ;; Some encoded unicode text contains character 0x80-0x9f e.g. Euro. | 605 | (assert (save-excursion (goto-char (point-min)) |
| 612 | (process-send-region (nntp-find-connection nntp-server-buffer) | 606 | (not (re-search-forward "[^\000-\377]" nil t)))) |
| 613 | (point-min) (point-max))) | 607 | (mm-disable-multibyte) |
| 608 | (process-send-region (nntp-find-connection nntp-server-buffer) | ||
| 609 | (point-min) (point-max)) | ||
| 614 | (nntp-retrieve-data | 610 | (nntp-retrieve-data |
| 615 | nil nntp-address nntp-port-number nntp-server-buffer | 611 | nil nntp-address nntp-port-number nntp-server-buffer |
| 616 | wait-for nnheader-callback-function)) | 612 | wait-for nnheader-callback-function)) |
| @@ -648,67 +644,79 @@ be restored and the command retried." | |||
| 648 | (defvar nntp-with-open-group-internal nil) | 644 | (defvar nntp-with-open-group-internal nil) |
| 649 | (defvar nntp-report-n nil)) | 645 | (defvar nntp-report-n nil)) |
| 650 | 646 | ||
| 647 | (defun nntp-with-open-group-function (-group -server -connectionless -bodyfun) | ||
| 648 | "Protect against servers that don't like clients that keep idle connections opens. | ||
| 649 | The problem being that these servers may either close a connection or | ||
| 650 | simply ignore any further requests on a connection. Closed | ||
| 651 | connections are not detected until `accept-process-output' has updated | ||
| 652 | the `process-status'. Dropped connections are not detected until the | ||
| 653 | connection timeouts (which may be several minutes) or | ||
| 654 | `nntp-connection-timeout' has expired. When these occur | ||
| 655 | `nntp-with-open-group', opens a new connection then re-issues the NNTP | ||
| 656 | command whose response triggered the error." | ||
| 657 | (letf ((nntp-report-n (symbol-function 'nntp-report)) | ||
| 658 | ((symbol-function 'nntp-report) (symbol-function 'nntp-report-1)) | ||
| 659 | (nntp-with-open-group-internal nil)) | ||
| 660 | (while (catch 'nntp-with-open-group-error | ||
| 661 | ;; Open the connection to the server | ||
| 662 | ;; NOTE: Existing connections are NOT tested. | ||
| 663 | (nntp-possibly-change-group -group -server -connectionless) | ||
| 664 | |||
| 665 | (let ((-timer | ||
| 666 | (and nntp-connection-timeout | ||
| 667 | (run-at-time | ||
| 668 | nntp-connection-timeout nil | ||
| 669 | (lambda () | ||
| 670 | (let* ((-process (nntp-find-connection | ||
| 671 | nntp-server-buffer)) | ||
| 672 | (-buffer (and -process | ||
| 673 | (process-buffer -process)))) | ||
| 674 | ;; When I an able to identify the | ||
| 675 | ;; connection to the server AND I've | ||
| 676 | ;; received NO reponse for | ||
| 677 | ;; nntp-connection-timeout seconds. | ||
| 678 | (when (and -buffer (eq 0 (buffer-size -buffer))) | ||
| 679 | ;; Close the connection. Take no | ||
| 680 | ;; other action as the accept input | ||
| 681 | ;; code will handle the closed | ||
| 682 | ;; connection. | ||
| 683 | (nntp-kill-buffer -buffer)))))))) | ||
| 684 | (unwind-protect | ||
| 685 | (setq nntp-with-open-group-internal | ||
| 686 | (condition-case nil | ||
| 687 | (funcall -bodyfun) | ||
| 688 | (quit | ||
| 689 | (unless debug-on-quit | ||
| 690 | (nntp-close-server)) | ||
| 691 | (signal 'quit nil)))) | ||
| 692 | (when -timer | ||
| 693 | (nnheader-cancel-timer -timer))) | ||
| 694 | nil)) | ||
| 695 | (setf (symbol-function 'nntp-report) nntp-report-n)) | ||
| 696 | nntp-with-open-group-internal)) | ||
| 697 | |||
| 651 | (defmacro nntp-with-open-group (group server &optional connectionless &rest forms) | 698 | (defmacro nntp-with-open-group (group server &optional connectionless &rest forms) |
| 652 | "Protect against servers that don't like clients that keep idle connections opens. | 699 | "Protect against servers that don't like clients that keep idle connections opens. |
| 653 | The problem being that these servers may either close a connection or | 700 | The problem being that these servers may either close a connection or |
| 654 | simply ignore any further requests on a connection. Closed | 701 | simply ignore any further requests on a connection. Closed |
| 655 | connections are not detected until accept-process-output has updated | 702 | connections are not detected until `accept-process-output' has updated |
| 656 | the process-status. Dropped connections are not detected until the | 703 | the `process-status'. Dropped connections are not detected until the |
| 657 | connection timeouts (which may be several minutes) or | 704 | connection timeouts (which may be several minutes) or |
| 658 | nntp-connection-timeout has expired. When these occur | 705 | `nntp-connection-timeout' has expired. When these occur |
| 659 | nntp-with-open-group, opens a new connection then re-issues the NNTP | 706 | `nntp-with-open-group', opens a new connection then re-issues the NNTP |
| 660 | command whose response triggered the error." | 707 | command whose response triggered the error." |
| 708 | (declare (indent 2) (debug (form form [&optional symbolp] def-body))) | ||
| 661 | (when (and (listp connectionless) | 709 | (when (and (listp connectionless) |
| 662 | (not (eq connectionless nil))) | 710 | (not (eq connectionless nil))) |
| 663 | (setq forms (cons connectionless forms) | 711 | (setq forms (cons connectionless forms) |
| 664 | connectionless nil)) | 712 | connectionless nil)) |
| 665 | `(letf ((nntp-report-n (symbol-function 'nntp-report)) | 713 | `(nntp-with-open-group-function ,group ,server ,connectionless (lambda () ,@forms))) |
| 666 | ((symbol-function 'nntp-report) (symbol-function 'nntp-report-1)) | ||
| 667 | (nntp-with-open-group-internal nil)) | ||
| 668 | (while (catch 'nntp-with-open-group-error | ||
| 669 | ;; Open the connection to the server | ||
| 670 | ;; NOTE: Existing connections are NOT tested. | ||
| 671 | (nntp-possibly-change-group ,group ,server ,connectionless) | ||
| 672 | |||
| 673 | (let ((timer | ||
| 674 | (and nntp-connection-timeout | ||
| 675 | (run-at-time | ||
| 676 | nntp-connection-timeout nil | ||
| 677 | '(lambda () | ||
| 678 | (let ((process (nntp-find-connection | ||
| 679 | nntp-server-buffer)) | ||
| 680 | (buffer (and process | ||
| 681 | (process-buffer process)))) | ||
| 682 | ;; When I am able to identify the | ||
| 683 | ;; connection to the server AND I've | ||
| 684 | ;; received NO reponse for | ||
| 685 | ;; nntp-connection-timeout seconds. | ||
| 686 | (when (and buffer (eq 0 (buffer-size buffer))) | ||
| 687 | ;; Close the connection. Take no | ||
| 688 | ;; other action as the accept input | ||
| 689 | ;; code will handle the closed | ||
| 690 | ;; connection. | ||
| 691 | (nntp-kill-buffer buffer)))))))) | ||
| 692 | (unwind-protect | ||
| 693 | (setq nntp-with-open-group-internal | ||
| 694 | (condition-case nil | ||
| 695 | (progn ,@forms) | ||
| 696 | (quit | ||
| 697 | (unless debug-on-quit | ||
| 698 | (nntp-close-server)) | ||
| 699 | (signal 'quit nil)))) | ||
| 700 | (when timer | ||
| 701 | (nnheader-cancel-timer timer))) | ||
| 702 | nil)) | ||
| 703 | (setf (symbol-function 'nntp-report) nntp-report-n)) | ||
| 704 | nntp-with-open-group-internal)) | ||
| 705 | 714 | ||
| 706 | (deffoo nntp-retrieve-headers (articles &optional group server fetch-old) | 715 | (deffoo nntp-retrieve-headers (articles &optional group server fetch-old) |
| 707 | "Retrieve the headers of ARTICLES." | 716 | "Retrieve the headers of ARTICLES." |
| 708 | (nntp-with-open-group | 717 | (nntp-with-open-group |
| 709 | group server | 718 | group server |
| 710 | (save-excursion | 719 | (with-current-buffer (nntp-find-connection-buffer nntp-server-buffer) |
| 711 | (set-buffer (nntp-find-connection-buffer nntp-server-buffer)) | ||
| 712 | (erase-buffer) | 720 | (erase-buffer) |
| 713 | (if (and (not gnus-nov-is-evil) | 721 | (if (and (not gnus-nov-is-evil) |
| 714 | (not nntp-nov-is-evil) | 722 | (not nntp-nov-is-evil) |
| @@ -930,8 +938,7 @@ command whose response triggered the error." | |||
| 930 | 938 | ||
| 931 | (defun nntp-try-list-active (group) | 939 | (defun nntp-try-list-active (group) |
| 932 | (nntp-list-active-group group) | 940 | (nntp-list-active-group group) |
| 933 | (save-excursion | 941 | (with-current-buffer nntp-server-buffer |
| 934 | (set-buffer nntp-server-buffer) | ||
| 935 | (goto-char (point-min)) | 942 | (goto-char (point-min)) |
| 936 | (cond ((or (eobp) | 943 | (cond ((or (eobp) |
| 937 | (looking-at "5[0-9]+")) | 944 | (looking-at "5[0-9]+")) |
| @@ -959,8 +966,7 @@ command whose response triggered the error." | |||
| 959 | (if (numberp article) (int-to-string article) article)) | 966 | (if (numberp article) (int-to-string article) article)) |
| 960 | (if (and buffer | 967 | (if (and buffer |
| 961 | (not (equal buffer nntp-server-buffer))) | 968 | (not (equal buffer nntp-server-buffer))) |
| 962 | (save-excursion | 969 | (with-current-buffer nntp-server-buffer |
| 963 | (set-buffer nntp-server-buffer) | ||
| 964 | (copy-to-buffer buffer (point-min) (point-max)) | 970 | (copy-to-buffer buffer (point-min) (point-max)) |
| 965 | (nntp-find-group-and-number group)) | 971 | (nntp-find-group-and-number group)) |
| 966 | (nntp-find-group-and-number group))))) | 972 | (nntp-find-group-and-number group))))) |
| @@ -1057,8 +1063,7 @@ command whose response triggered the error." | |||
| 1057 | (deffoo nntp-request-newgroups (date &optional server) | 1063 | (deffoo nntp-request-newgroups (date &optional server) |
| 1058 | (nntp-with-open-group | 1064 | (nntp-with-open-group |
| 1059 | nil server | 1065 | nil server |
| 1060 | (save-excursion | 1066 | (with-current-buffer nntp-server-buffer |
| 1061 | (set-buffer nntp-server-buffer) | ||
| 1062 | (let* ((time (date-to-time date)) | 1067 | (let* ((time (date-to-time date)) |
| 1063 | (ls (- (cadr time) (nth 8 (decode-time time))))) | 1068 | (ls (- (cadr time) (nth 8 (decode-time time))))) |
| 1064 | (cond ((< ls 0) | 1069 | (cond ((< ls 0) |
| @@ -1227,12 +1232,11 @@ password contained in '~/.nntp-authinfo'." | |||
| 1227 | 1232 | ||
| 1228 | (defun nntp-make-process-buffer (buffer) | 1233 | (defun nntp-make-process-buffer (buffer) |
| 1229 | "Create a new, fresh buffer usable for nntp process connections." | 1234 | "Create a new, fresh buffer usable for nntp process connections." |
| 1230 | (save-excursion | 1235 | (with-current-buffer |
| 1231 | (set-buffer | 1236 | (generate-new-buffer |
| 1232 | (generate-new-buffer | 1237 | (format " *server %s %s %s*" |
| 1233 | (format " *server %s %s %s*" | 1238 | nntp-address nntp-port-number |
| 1234 | nntp-address nntp-port-number | 1239 | (gnus-buffer-exists-p buffer))) |
| 1235 | (gnus-buffer-exists-p buffer)))) | ||
| 1236 | (mm-disable-multibyte) | 1240 | (mm-disable-multibyte) |
| 1237 | (set (make-local-variable 'after-change-functions) nil) | 1241 | (set (make-local-variable 'after-change-functions) nil) |
| 1238 | (set (make-local-variable 'nntp-process-wait-for) nil) | 1242 | (set (make-local-variable 'nntp-process-wait-for) nil) |
| @@ -1275,8 +1279,7 @@ password contained in '~/.nntp-authinfo'." | |||
| 1275 | (prog1 | 1279 | (prog1 |
| 1276 | (caar (push (list process buffer nil) nntp-connection-alist)) | 1280 | (caar (push (list process buffer nil) nntp-connection-alist)) |
| 1277 | (push process nntp-connection-list) | 1281 | (push process nntp-connection-list) |
| 1278 | (save-excursion | 1282 | (with-current-buffer pbuffer |
| 1279 | (set-buffer pbuffer) | ||
| 1280 | (nntp-read-server-type) | 1283 | (nntp-read-server-type) |
| 1281 | (erase-buffer) | 1284 | (erase-buffer) |
| 1282 | (set-buffer nntp-server-buffer) | 1285 | (set-buffer nntp-server-buffer) |
| @@ -1304,8 +1307,7 @@ password contained in '~/.nntp-authinfo'." | |||
| 1304 | ?s nntp-address | 1307 | ?s nntp-address |
| 1305 | ?p nntp-port-number))))) | 1308 | ?p nntp-port-number))))) |
| 1306 | (gnus-set-process-query-on-exit-flag proc nil) | 1309 | (gnus-set-process-query-on-exit-flag proc nil) |
| 1307 | (save-excursion | 1310 | (with-current-buffer buffer |
| 1308 | (set-buffer buffer) | ||
| 1309 | (let ((nntp-connection-alist (list proc buffer nil))) | 1311 | (let ((nntp-connection-alist (list proc buffer nil))) |
| 1310 | (nntp-wait-for-string "^\r*20[01]")) | 1312 | (nntp-wait-for-string "^\r*20[01]")) |
| 1311 | (beginning-of-line) | 1313 | (beginning-of-line) |
| @@ -1315,8 +1317,7 @@ password contained in '~/.nntp-authinfo'." | |||
| 1315 | (defun nntp-open-tls-stream (buffer) | 1317 | (defun nntp-open-tls-stream (buffer) |
| 1316 | (let ((proc (open-tls-stream "nntpd" buffer nntp-address nntp-port-number))) | 1318 | (let ((proc (open-tls-stream "nntpd" buffer nntp-address nntp-port-number))) |
| 1317 | (gnus-set-process-query-on-exit-flag proc nil) | 1319 | (gnus-set-process-query-on-exit-flag proc nil) |
| 1318 | (save-excursion | 1320 | (with-current-buffer buffer |
| 1319 | (set-buffer buffer) | ||
| 1320 | (let ((nntp-connection-alist (list proc buffer nil))) | 1321 | (let ((nntp-connection-alist (list proc buffer nil))) |
| 1321 | (nntp-wait-for-string "^\r*20[01]")) | 1322 | (nntp-wait-for-string "^\r*20[01]")) |
| 1322 | (beginning-of-line) | 1323 | (beginning-of-line) |
| @@ -1337,8 +1338,7 @@ password contained in '~/.nntp-authinfo'." | |||
| 1337 | (funcall (cadr entry))))))) | 1338 | (funcall (cadr entry))))))) |
| 1338 | 1339 | ||
| 1339 | (defun nntp-async-wait (process wait-for buffer decode callback) | 1340 | (defun nntp-async-wait (process wait-for buffer decode callback) |
| 1340 | (save-excursion | 1341 | (with-current-buffer (process-buffer process) |
| 1341 | (set-buffer (process-buffer process)) | ||
| 1342 | (unless nntp-inside-change-function | 1342 | (unless nntp-inside-change-function |
| 1343 | (erase-buffer)) | 1343 | (erase-buffer)) |
| 1344 | (setq nntp-process-wait-for wait-for | 1344 | (setq nntp-process-wait-for wait-for |
| @@ -1386,8 +1386,7 @@ password contained in '~/.nntp-authinfo'." | |||
| 1386 | (setq after-change-functions '(nntp-after-change-function))))) | 1386 | (setq after-change-functions '(nntp-after-change-function))))) |
| 1387 | 1387 | ||
| 1388 | (defun nntp-async-trigger (process) | 1388 | (defun nntp-async-trigger (process) |
| 1389 | (save-excursion | 1389 | (with-current-buffer (process-buffer process) |
| 1390 | (set-buffer (process-buffer process)) | ||
| 1391 | (when nntp-process-callback | 1390 | (when nntp-process-callback |
| 1392 | ;; do we have an error message? | 1391 | ;; do we have an error message? |
| 1393 | (goto-char nntp-process-start-point) | 1392 | (goto-char nntp-process-start-point) |
| @@ -1412,8 +1411,7 @@ password contained in '~/.nntp-authinfo'." | |||
| 1412 | (let ((buf (current-buffer)) | 1411 | (let ((buf (current-buffer)) |
| 1413 | (start nntp-process-start-point) | 1412 | (start nntp-process-start-point) |
| 1414 | (decode nntp-process-decode)) | 1413 | (decode nntp-process-decode)) |
| 1415 | (save-excursion | 1414 | (with-current-buffer nntp-process-to-buffer |
| 1416 | (set-buffer nntp-process-to-buffer) | ||
| 1417 | (goto-char (point-max)) | 1415 | (goto-char (point-max)) |
| 1418 | (save-restriction | 1416 | (save-restriction |
| 1419 | (narrow-to-region (point) (point)) | 1417 | (narrow-to-region (point) (point)) |
| @@ -1477,8 +1475,7 @@ password contained in '~/.nntp-authinfo'." | |||
| 1477 | (cond ((not entry) | 1475 | (cond ((not entry) |
| 1478 | (nntp-report "Server closed connection")) | 1476 | (nntp-report "Server closed connection")) |
| 1479 | ((not (equal group (caddr entry))) | 1477 | ((not (equal group (caddr entry))) |
| 1480 | (save-excursion | 1478 | (with-current-buffer (process-buffer (car entry)) |
| 1481 | (set-buffer (process-buffer (car entry))) | ||
| 1482 | (erase-buffer) | 1479 | (erase-buffer) |
| 1483 | (nntp-send-command "^[245].*\n" "GROUP" group) | 1480 | (nntp-send-command "^[245].*\n" "GROUP" group) |
| 1484 | (setcar (cddr entry) group) | 1481 | (setcar (cddr entry) group) |
| @@ -1678,8 +1675,7 @@ password contained in '~/.nntp-authinfo'." | |||
| 1678 | ;; We try them all until we get at positive response. | 1675 | ;; We try them all until we get at positive response. |
| 1679 | (while (and commands (eq nntp-server-xover 'try)) | 1676 | (while (and commands (eq nntp-server-xover 'try)) |
| 1680 | (nntp-send-command-nodelete "\r?\n\\.\r?\n" (car commands) range) | 1677 | (nntp-send-command-nodelete "\r?\n\\.\r?\n" (car commands) range) |
| 1681 | (save-excursion | 1678 | (with-current-buffer nntp-server-buffer |
| 1682 | (set-buffer nntp-server-buffer) | ||
| 1683 | (goto-char (point-min)) | 1679 | (goto-char (point-min)) |
| 1684 | (and (looking-at "[23]") ; No error message. | 1680 | (and (looking-at "[23]") ; No error message. |
| 1685 | ;; We also have to look at the lines. Some buggy | 1681 | ;; We also have to look at the lines. Some buggy |
| @@ -1700,6 +1696,7 @@ password contained in '~/.nntp-authinfo'." | |||
| 1700 | (defun nntp-find-group-and-number (&optional group) | 1696 | (defun nntp-find-group-and-number (&optional group) |
| 1701 | (save-excursion | 1697 | (save-excursion |
| 1702 | (save-restriction | 1698 | (save-restriction |
| 1699 | ;; FIXME: This is REALLY FISHY: set-buffer after save-restriction?!? | ||
| 1703 | (set-buffer nntp-server-buffer) | 1700 | (set-buffer nntp-server-buffer) |
| 1704 | (narrow-to-region (goto-char (point-min)) | 1701 | (narrow-to-region (goto-char (point-min)) |
| 1705 | (or (search-forward "\n\n" nil t) (point-max))) | 1702 | (or (search-forward "\n\n" nil t) (point-max))) |
| @@ -1876,6 +1873,8 @@ via telnet.") | |||
| 1876 | 1873 | ||
| 1877 | (defun nntp-open-telnet-stream (buffer) | 1874 | (defun nntp-open-telnet-stream (buffer) |
| 1878 | "Open a nntp connection by telnet'ing the news server. | 1875 | "Open a nntp connection by telnet'ing the news server. |
| 1876 | `nntp-open-via-netcat' is recommended in place of this function | ||
| 1877 | because it is more reliable. | ||
| 1879 | 1878 | ||
| 1880 | Please refer to the following variables to customize the connection: | 1879 | Please refer to the following variables to customize the connection: |
| 1881 | - `nntp-pre-command', | 1880 | - `nntp-pre-command', |
| @@ -1891,8 +1890,7 @@ Please refer to the following variables to customize the connection: | |||
| 1891 | (and nntp-pre-command | 1890 | (and nntp-pre-command |
| 1892 | (push nntp-pre-command command)) | 1891 | (push nntp-pre-command command)) |
| 1893 | (setq proc (apply 'start-process "nntpd" buffer command)) | 1892 | (setq proc (apply 'start-process "nntpd" buffer command)) |
| 1894 | (save-excursion | 1893 | (with-current-buffer buffer |
| 1895 | (set-buffer buffer) | ||
| 1896 | (nntp-wait-for-string "^\r*20[01]") | 1894 | (nntp-wait-for-string "^\r*20[01]") |
| 1897 | (beginning-of-line) | 1895 | (beginning-of-line) |
| 1898 | (delete-region (point-min) (point)) | 1896 | (delete-region (point-min) (point)) |
| @@ -1902,6 +1900,8 @@ Please refer to the following variables to customize the connection: | |||
| 1902 | "Open a connection to an nntp server through an intermediate host. | 1900 | "Open a connection to an nntp server through an intermediate host. |
| 1903 | First rlogin to the remote host, and then telnet the real news server | 1901 | First rlogin to the remote host, and then telnet the real news server |
| 1904 | from there. | 1902 | from there. |
| 1903 | `nntp-open-via-rlogin-and-netcat' is recommended in place of this function | ||
| 1904 | because it is more reliable. | ||
| 1905 | 1905 | ||
| 1906 | Please refer to the following variables to customize the connection: | 1906 | Please refer to the following variables to customize the connection: |
| 1907 | - `nntp-pre-command', | 1907 | - `nntp-pre-command', |
| @@ -1926,8 +1926,7 @@ Please refer to the following variables to customize the connection: | |||
| 1926 | (and nntp-pre-command | 1926 | (and nntp-pre-command |
| 1927 | (push nntp-pre-command command)) | 1927 | (push nntp-pre-command command)) |
| 1928 | (setq proc (apply 'start-process "nntpd" buffer command)) | 1928 | (setq proc (apply 'start-process "nntpd" buffer command)) |
| 1929 | (save-excursion | 1929 | (with-current-buffer buffer |
| 1930 | (set-buffer buffer) | ||
| 1931 | (nntp-wait-for-string "^r?telnet") | 1930 | (nntp-wait-for-string "^r?telnet") |
| 1932 | (process-send-string proc (concat "open " nntp-address | 1931 | (process-send-string proc (concat "open " nntp-address |
| 1933 | " " nntp-port-number "\n")) | 1932 | " " nntp-port-number "\n")) |
| @@ -1993,8 +1992,7 @@ Please refer to the following variables to customize the connection: | |||
| 1993 | - `nntp-address', | 1992 | - `nntp-address', |
| 1994 | - `nntp-port-number', | 1993 | - `nntp-port-number', |
| 1995 | - `nntp-end-of-line'." | 1994 | - `nntp-end-of-line'." |
| 1996 | (save-excursion | 1995 | (with-current-buffer buffer |
| 1997 | (set-buffer buffer) | ||
| 1998 | (erase-buffer) | 1996 | (erase-buffer) |
| 1999 | (let ((command `(,nntp-via-telnet-command ,@nntp-via-telnet-switches)) | 1997 | (let ((command `(,nntp-via-telnet-command ,@nntp-via-telnet-switches)) |
| 2000 | (case-fold-search t) | 1998 | (case-fold-search t) |
| @@ -2141,5 +2139,5 @@ Please refer to the following variables to customize the connection: | |||
| 2141 | 2139 | ||
| 2142 | (provide 'nntp) | 2140 | (provide 'nntp) |
| 2143 | 2141 | ||
| 2144 | ;;; arch-tag: 8655466a-b1b5-4929-9c45-7b1b2e767271 | 2142 | ;; arch-tag: 8655466a-b1b5-4929-9c45-7b1b2e767271 |
| 2145 | ;;; nntp.el ends here | 2143 | ;;; nntp.el ends here |