* nnmairix.el: Remove old documentation in the commentary block.
[gnus] / lisp / nndb.el
index 5c2645c..6d033eb 100644 (file)
@@ -1,6 +1,7 @@
 ;;; nndb.el --- nndb access for Gnus
 
-;; Copyright (C) 1997, 1998, 2000 Free Software Foundation, Inc.
+;; Copyright (C) 1997, 1998, 2000, 2002, 2003, 2004, 2005, 2006, 2007,
+;;   2008, 2009  Free Software Foundation, Inc.
 
 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
 ;;         Kai Grossjohann <grossjohann@ls6.informatik.uni-dortmund.de>
@@ -8,12 +9,12 @@
 ;;         David Blacka <davidb@rwhois.net>
 ;; Keywords: news
 
-;; This file is NOT part of GNU Emacs.
+;; This file is part of GNU Emacs.
 
-;; GNU Emacs is free software; you can redistribute it and/or modify
+;; GNU Emacs is free software: you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
-;; any later version.
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -21,9 +22,7 @@
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 
 ;; * make the backend TOUCH an article when marked as expireable (will
 ;;   make article expire 'expiry' days after that moment).
 
+;;; Code:
+
+;; For Emacs < 22.2.
+(eval-and-compile
+  (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
+
 ;;-
 ;; Register nndb with known select methods.
 
-(gnus-declare-backend "nndb" 'mail 'respool 'address 'prompt-address)
-
-;;; Code:
+(require 'gnus-start)
+(unless (assoc "nndb" gnus-valid-select-methods)
+  (gnus-declare-backend "nndb" 'mail 'respool 'address 'prompt-address))
 
 (require 'nnmail)
 (require 'nnheader)
 (require 'nntp)
 (eval-when-compile (require 'cl))
 
-(eval-and-compile
-  (unless (fboundp 'open-network-stream)
-    (require 'tcp)))
-
-(eval-when-compile (require 'cl))
-
-(eval-and-compile
-  (autoload 'news-setup "rnewspost")
-  (autoload 'news-reply-mode "rnewspost")
-  (autoload 'cancel-timer "timer")
-  (autoload 'telnet "telnet" nil t)
-  (autoload 'telnet-send-input "telnet" nil t)
-  (autoload 'gnus-declare-backend "gnus-start"))
-
 ;; Declare nndb as derived from nntp
 
 (nnoo-declare nndb nntp)
@@ -175,7 +166,7 @@ article was posted to nndb")
       (nntp-send-command "^\\([23]\\|^423\\).*\n" "X-DATE" art)
       (setq msg (nndb-status-message))
       (if (string-match "^423" msg)
-          ()
+         ()
        (or (string-match "'\\(.+\\)'" msg)
            (error "Not a valid response for X-DATE command: %s"
                   msg))
@@ -202,12 +193,12 @@ article was posted to nndb")
     (set-buffer nntp-server-buffer)
     (goto-char (point-min))
     (if (looking-at "^[34]")
-       ;; x-expire returned error--presume no articles were expirable)
+       ;; x-expire returned error--presume no articles were expirable)
        (setq list nil)
       ;; otherwise, pull all of the following numbers into the list
       (re-search-forward "follows\r?\n?" nil t)
       (while (re-search-forward "^[0-9]+$" nil t)
-       (push (string-to-int (match-string 0)) list)))
+      (push (string-to-number (match-string 0)) list)))
     list))
 
 (defun nndb-request-expire-articles-remote
@@ -219,15 +210,15 @@ article was posted to nndb")
     ;; first calculate the wait period in days
     (setq days (or (and nnmail-expiry-wait-function
                        (funcall nnmail-expiry-wait-function group))
-                  nnmail-expiry-wait))
+    nnmail-expiry-wait))
     ;; now handle the special cases
     (cond (force
-          (setq days 0))
+    (setq days 0))
          ((eq days 'never)
           ;; This isn't an expirable group.
-          (setq days -1))
+         (setq days -1))
          ((eq days 'immediate)
-          (setq days 0)))
+         (setq days 0)))
 
 
     ;; build article string
@@ -251,8 +242,11 @@ expiry mechanism."
       (nndb-request-expire-articles-remote articles group server force)
     (nndb-request-expire-articles-local articles group server force)))
 
+;; _Something_ defines it...
+(declare-function nndb-request-article "nndb" t t)
+
 (deffoo nndb-request-move-article
-    (article group server accept-form &optional last)
+    (article group server accept-form &optional last move-is-internal)
   "Move ARTICLE (a number) from GROUP on SERVER.
 Evals ACCEPT-FORM in current buffer, where the article is.
 Optional LAST is ignored."
@@ -268,19 +262,19 @@ Optional LAST is ignored."
          (cons new-group article))
       ;; else move normally
       (let ((artbuf (get-buffer-create " *nndb move*")))
-       (and
-        (nndb-request-article article group server artbuf)
-        (save-excursion
-          (set-buffer artbuf)
-          (insert-buffer-substring nntp-server-buffer)
-          (setq result (eval accept-form))
-          (kill-buffer (current-buffer))
-          result)
-        (nndb-request-expire-articles (list article)
-                                      group
-                                      server
-                                      t))
-       result)
+      (and
+       (nndb-request-article article group server artbuf)
+       (save-excursion
+        (set-buffer artbuf)
+        (insert-buffer-substring nntp-server-buffer)
+        (setq result (eval accept-form))
+        (kill-buffer (current-buffer))
+        result)
+       (nndb-request-expire-articles (list article)
+                                    group
+                                    server
+                                    t))
+      result)
       )))
 
 (deffoo nndb-request-accept-article (group server &optional last)
@@ -292,7 +286,7 @@ Optional LAST is ignored."
       (nntp-send-buffer "^[23].*\n"))
 
     (set-buffer nntp-server-buffer)
-    (setq msg (buffer-substring (point-min) (point-max)))
+    (setq msg (buffer-string))
     (or (string-match "^\\([0-9]+\\)" msg)
        (error "nndb: %s" msg))
     (setq art (substring msg (match-beginning 1) (match-end 1)))
@@ -307,18 +301,18 @@ Optional LAST is ignored."
     (nntp-send-buffer "^[23.*\n")
     (list (int-to-string article))))
 
-; nndb-request-delete-group does not exist
-; todo -- maybe later
+                           ; nndb-request-delete-group does not exist
+                                       ; todo -- maybe later
 
-; nndb-request-rename-group does not exist
-; todo -- maybe later
+                           ; nndb-request-rename-group does not exist
+                                       ; todo -- maybe later
 
-;; -- standard compatability functions
+;; -- standard compatibility functions
 
 (deffoo nndb-status-message (&optional server)
   "Return server status as a string."
   (set-buffer nntp-server-buffer)
-  (buffer-substring (point-min) (point-max)))
+  (buffer-string))
 
 ;; Import stuff from nntp
 
@@ -327,4 +321,5 @@ Optional LAST is ignored."
 
 (provide 'nndb)
 
+;; arch-tag: 83bd6fb4-58d9-4fed-a901-c6c625ad5f8a
 ;;; nndb.el ends here