*** empty log message ***
[gnus] / lisp / gnus-int.el
index 50d92ee..1101e46 100644 (file)
@@ -1,5 +1,5 @@
-;;; gnus-int.el --- backend inteface functions for Gnus
-;; Copyright (C) 1996 Free Software Foundation, Inc.
+;;; gnus-int.el --- backend interface functions for Gnus
+;; Copyright (C) 1996,97 Free Software Foundation, Inc.
 
 ;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
 ;; Keywords: news
 
 ;;; Code:
 
-(require 'gnus-load)
 (require 'gnus)
 
-(defvar gnus-open-server-hook nil
-  "*A hook called just before opening connection to the news server.")
+(defcustom gnus-open-server-hook nil
+  "Hook called just before opening connection to the news server."
+  :group 'gnus-start
+  :type 'hook)
 
 ;;;
 ;;; Server Communication
@@ -200,7 +201,7 @@ If it is down, start it up (again)."
   "Check whether a connection to METHOD has been opened."
   (when (stringp method)
     (setq method (gnus-server-to-method method)))
-  (funcall (gnus-get-function method 'server-opened) (nth 1 method)))
+  (funcall (inline (gnus-get-function method 'server-opened)) (nth 1 method)))
 
 (defun gnus-status-message (method)
   "Return the status message from METHOD.
@@ -210,12 +211,18 @@ this group uses will be queried."
                  method)))
     (funcall (gnus-get-function method 'status-message) (nth 1 method))))
 
+(defun gnus-request-regenerate (method)
+  "Request a data generation from METHOD."
+  (when (stringp method)
+    (setq method (gnus-server-to-method method)))
+  (funcall (gnus-get-function method 'request-regenerate) (nth 1 method)))
+
 (defun gnus-request-group (group &optional dont-check method)
   "Request GROUP.  If DONT-CHECK, no information is required."
-  (let ((method (or method (gnus-find-method-for-group group))))
+  (let ((method (or method (inline (gnus-find-method-for-group group)))))
     (when (stringp method)
-      (setq method (gnus-server-to-method method)))
-    (funcall (gnus-get-function method 'request-group)
+      (setq method (inline (gnus-server-to-method method))))
+    (funcall (inline (gnus-get-function method 'request-group))
             (gnus-group-real-name group) (nth 1 method) dont-check)))
 
 (defun gnus-list-active-group (group)
@@ -236,7 +243,7 @@ this group uses will be queried."
 
 (defun gnus-close-group (group)
   "Request the GROUP be closed."
-  (let ((method (gnus-find-method-for-group group)))
+  (let ((method (inline (gnus-find-method-for-group group))))
     (funcall (gnus-get-function method 'close-group)
             (gnus-group-real-name group) (nth 1 method))))
 
@@ -283,18 +290,31 @@ If BUFFER, insert the article in that group."
 (defun gnus-request-head (article group)
   "Request the head of ARTICLE in GROUP."
   (let* ((method (gnus-find-method-for-group group))
-        (head (gnus-get-function method 'request-head t)))
-    (if (fboundp head)
-       (funcall head article (gnus-group-real-name group) (nth 1 method))
-      (let ((res (gnus-request-article article group)))
-       (when res
-         (save-excursion
-           (set-buffer nntp-server-buffer)
-           (goto-char (point-min))
-           (when (search-forward "\n\n" nil t)
-             (delete-region (1- (point)) (point-max)))
-           (nnheader-fold-continuation-lines)))
-       res))))
+        (head (gnus-get-function method 'request-head t))
+        res clean-up)
+    (cond
+     ;; Check the cache.
+     ((and gnus-use-cache
+          (numberp article)
+          (gnus-cache-request-article article group))
+      (setq res (cons group article)
+           clean-up t))
+     ;; Use `head' function.
+     ((fboundp head)
+      (setq res (funcall head article (gnus-group-real-name group)
+                        (nth 1 method))))
+     ;; Use `article' function.
+     (t
+      (setq res (gnus-request-article article group)
+           clean-up t)))
+    (when clean-up
+      (save-excursion
+       (set-buffer nntp-server-buffer)
+       (goto-char (point-min))
+       (when (search-forward "\n\n" nil t)
+         (delete-region (1- (point)) (point-max)))
+       (nnheader-fold-continuation-lines)))
+    res))
 
 (defun gnus-request-body (article group)
   "Request the body of ARTICLE in GROUP."
@@ -311,7 +331,8 @@ If BUFFER, insert the article in that group."
 (defun gnus-request-scan (group method)
   "Request a SCAN being performed in GROUP from METHOD.
 If GROUP is nil, all groups on METHOD are scanned."
-  (let ((method (if group (gnus-find-method-for-group group) method)))
+  (let ((method (if group (gnus-find-method-for-group group) method))
+       (gnus-inhibit-demon t))
     (funcall (gnus-get-function method 'request-scan)
             (and group (gnus-group-real-name group)) (nth 1 method))))
 
@@ -354,7 +375,7 @@ If GROUP is nil, all groups on METHOD are scanned."
             last)))
 
 (defun gnus-request-replace-article (article group buffer)
-  (let ((func (car (gnus-find-method-for-group group))))
+  (let ((func (car (gnus-group-name-to-method group))))
     (funcall (intern (format "%s-request-replace-article" func))
             article (gnus-group-real-name group) buffer)))
 
@@ -369,12 +390,12 @@ If GROUP is nil, all groups on METHOD are scanned."
     (funcall (gnus-get-function method 'request-restore-buffer)
             article (gnus-group-real-name group) (nth 1 method))))
 
-(defun gnus-request-create-group (group &optional method)
+(defun gnus-request-create-group (group &optional method args)
   (when (stringp method)
     (setq method (gnus-server-to-method method)))
   (let ((method (or method (gnus-find-method-for-group group))))
     (funcall (gnus-get-function method 'request-create-group)
-            (gnus-group-real-name group) (nth 1 method))))
+            (gnus-group-real-name group) (nth 1 method) args)))
 
 (defun gnus-request-delete-group (group &optional force)
   (let ((method (gnus-find-method-for-group group)))
@@ -390,6 +411,7 @@ If GROUP is nil, all groups on METHOD are scanned."
 (defun gnus-close-backends ()
   ;; Send a close request to all backends that support such a request.
   (let ((methods gnus-valid-select-methods)
+       (gnus-inhibit-demon t)
        func method)
     (while (setq method (pop methods))
       (when (fboundp (setq func (intern