* nntp.el (nntp-erase-buffer): New function.
authorJesper Harder <harder@ifa.au.dk>
Thu, 12 Feb 2004 02:01:54 +0000 (02:01 +0000)
committerJesper Harder <harder@ifa.au.dk>
Thu, 12 Feb 2004 02:01:54 +0000 (02:01 +0000)
(nntp-retrieve-data, nntp-send-command)
(nntp-send-buffer, nntp-retrieve-groups, nntp-handle-authinfo)
(nntp-possibly-change-group): Use it.

* nnnil.el (nnnil-retrieve-headers, nnnil-request-list): Use
with-current-buffer.

lisp/ChangeLog
lisp/nnnil.el
lisp/nntp.el

index af4f630..27b9565 100644 (file)
@@ -1,3 +1,13 @@
+2004-02-12  Jesper Harder  <harder@ifa.au.dk>
+
+       * nntp.el (nntp-erase-buffer): New function.
+       (nntp-retrieve-data, nntp-send-command)
+       (nntp-send-buffer, nntp-retrieve-groups, nntp-handle-authinfo)
+       (nntp-possibly-change-group): Use it.
+
+       * nnnil.el (nnnil-retrieve-headers, nnnil-request-list): Use
+       with-current-buffer.
+
 2004-02-12  TAKAI Kousuke  <tak@kmc.gr.jp>
 
        * compface.el: Merge the ELisp-based uncompface program.
index 08a097d..9e26160 100644 (file)
@@ -32,8 +32,7 @@
 (defvar nnnil-status-string "")
 
 (defun nnnil-retrieve-headers (articles &optional group server fetch-old)
-  (save-excursion
-    (set-buffer nntp-server-buffer)
+  (with-current-buffer nntp-server-buffer
     (erase-buffer))
   'nov)
 
@@ -69,8 +68,7 @@
   t)
 
 (defun nnnil-request-list (&optional server)
-  (save-excursion
-    (set-buffer nntp-server-buffer)
+  (with-current-buffer nntp-server-buffer
     (erase-buffer))
   t)
 
index 8576c96..8ff4d2d 100644 (file)
@@ -357,6 +357,11 @@ be restored and the command retried."
     (kill-buffer buffer)
     (nnheader-init-server-buffer)))
 
+(defun nntp-erase-buffer (buffer)
+  "Erase contents of BUFFER."
+  (with-current-buffer buffer
+    (erase-buffer)))
+
 (defsubst nntp-find-connection (buffer)
   "Find the connection delivering to BUFFER."
   (let ((alist nntp-connection-alist)
@@ -391,9 +396,7 @@ be restored and the command retried."
     (if process
         (progn
           (unless (or nntp-inhibit-erase nnheader-callback-function)
-            (save-excursion
-              (set-buffer (process-buffer process))
-              (erase-buffer)))
+           (nntp-erase-buffer (process-buffer process)))
           (condition-case err
               (progn
                 (when command
@@ -420,9 +423,7 @@ be restored and the command retried."
   "Send STRINGS to server and wait until WAIT-FOR returns."
   (when (and (not nnheader-callback-function)
             (not nntp-inhibit-output))
-    (save-excursion
-      (set-buffer nntp-server-buffer)
-      (erase-buffer)))
+    (nntp-erase-buffer nntp-server-buffer))
   (let* ((command (mapconcat 'identity strings " "))
         (process (nntp-find-connection nntp-server-buffer))
         (buffer (and process (process-buffer process)))
@@ -478,9 +479,7 @@ be restored and the command retried."
   "Send STRINGS to server and wait until WAIT-FOR returns."
   (when (and (not nnheader-callback-function)
             (not nntp-inhibit-output))
-    (save-excursion
-      (set-buffer nntp-server-buffer)
-      (erase-buffer)))
+    (nntp-erase-buffer nntp-server-buffer))
   (let* ((command (mapconcat 'identity strings " "))
         (process (nntp-find-connection nntp-server-buffer))
         (buffer (and process (process-buffer process)))
@@ -495,11 +494,11 @@ be restored and the command retried."
          (unless wait-for
            (nntp-accept-response)
            (save-excursion
-         (set-buffer buffer)
-         (goto-char pos)
-         (if (looking-at (regexp-quote command))
-             (delete-region pos (progn (forward-line 1) (point-at-bol))))
-         )))
+             (set-buffer buffer)
+             (goto-char pos)
+             (if (looking-at (regexp-quote command))
+                 (delete-region pos (progn (forward-line 1) (point-at-bol))))
+             )))
       (nnheader-report 'nntp "Couldn't open connection to %s."
                       nntp-address))))
 
@@ -508,9 +507,8 @@ be restored and the command retried."
   "Send the current buffer to server and wait until WAIT-FOR returns."
   (when (and (not nnheader-callback-function)
             (not nntp-inhibit-output))
-    (save-excursion
-      (set-buffer (nntp-find-connection-buffer nntp-server-buffer))
-      (erase-buffer)))
+    (nntp-erase-buffer
+     (nntp-find-connection-buffer nntp-server-buffer)))
   (nntp-encode-text)
   (mm-with-unibyte-current-buffer
     ;; Some encoded unicode text contains character 0x80-0x9f e.g. Euro.
@@ -674,8 +672,7 @@ command whose response triggered the error."
      (catch 'done
        (save-excursion
          ;; Erase nntp-server-buffer before nntp-inhibit-erase.
-         (set-buffer nntp-server-buffer)
-         (erase-buffer)
+        (nntp-erase-buffer nntp-server-buffer)
          (set-buffer (nntp-find-connection-buffer nntp-server-buffer))
          ;; The first time this is run, this variable is `try'.  So we
          ;; try.
@@ -1073,9 +1070,7 @@ password contained in '~/.nntp-authinfo'."
     (funcall nntp-authinfo-function)
     ;; We have to re-send the function that was interrupted by
     ;; the authinfo request.
-    (save-excursion
-      (set-buffer nntp-server-buffer)
-      (erase-buffer))
+    (nntp-erase-buffer nntp-server-buffer)
     (nntp-send-string process last)))
 
 (defun nntp-make-process-buffer (buffer)
@@ -1338,9 +1333,7 @@ password contained in '~/.nntp-authinfo'."
                (nntp-send-command "^[245].*\n" "GROUP" group)
                (setcar (cddr entry) group)
                (erase-buffer)
-               (save-excursion
-                 (set-buffer nntp-server-buffer)
-                 (erase-buffer))))))))
+              (nntp-erase-buffer nntp-server-buffer)))))))
 
 (defun nntp-decode-text (&optional cr-only)
   "Decode the text in the current buffer."
@@ -1549,10 +1542,8 @@ password contained in '~/.nntp-authinfo'."
          (setq commands (cdr commands)))
        ;; If none of the commands worked, we disable XOVER.
        (when (eq nntp-server-xover 'try)
-         (save-excursion
-           (set-buffer nntp-server-buffer)
-           (erase-buffer)
-           (setq nntp-server-xover nil)))
+         (nntp-erase-buffer nntp-server-buffer)
+         (setq nntp-server-xover nil))
         nntp-server-xover))))
 
 (defun nntp-find-group-and-number (&optional group)