X-Git-Url: https://cgit.sxemacs.org/?a=blobdiff_plain;f=lisp%2Fnndb.el;h=6617b77910965c4da4abe425bb60efee29d312a1;hb=ad491df0b4f1a9a23a574e3c00a539802359b93b;hp=5244cb5108fb6da8d2c638090457088ed895d95f;hpb=270af910f44a6418d5a43bbcb544e2e52b865320;p=gnus diff --git a/lisp/nndb.el b/lisp/nndb.el index 5244cb510..6617b7791 100644 --- a/lisp/nndb.el +++ b/lisp/nndb.el @@ -1,5 +1,7 @@ ;;; nndb.el --- nndb access for Gnus -;; Copyright (C) 1997,98 Free Software Foundation, Inc. + +;; Copyright (C) 1997, 1998, 2000, 2002, 2003, 2004, +;; 2005 Free Software Foundation, Inc. ;; Author: Masanobu UMEDA ;; Kai Grossjohann @@ -7,7 +9,7 @@ ;; David Blacka ;; 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 ;; it under the terms of the GNU General Public License as published by @@ -21,8 +23,8 @@ ;; 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. +;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301, USA. ;;; Commentary: @@ -49,7 +51,9 @@ ;;- ;; Register nndb with known select methods. -(gnus-declare-backend "nndb" 'mail 'respool 'address 'prompt-address) +(require 'gnus-start) +(unless (assoc "nndb" gnus-valid-select-methods) + (gnus-declare-backend "nndb" 'mail 'respool 'address 'prompt-address)) ;;; Code: @@ -58,20 +62,6 @@ (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) @@ -83,13 +73,13 @@ "*The program used to put a message in an NNDB group.") (defvoo nndb-server-side-expiry nil - "If t, expiry calculation will occur on the server side") + "If t, expiry calculation will occur on the server side.") (defvoo nndb-set-expire-date-on-mark nil "If t, the expiry date for a given article will be set to the time it was marked as expireable; otherwise the date will be the time the article was posted to nndb") - + ;; Variables copied from nntp (defvoo nndb-server-opened-hook '(nntp-send-authinfo-from-file) @@ -139,7 +129,7 @@ article was posted to nndb") (push art rest))) rest)) - + ;; (deffoo nndb-request-type (group &optional article) nndb-article-type) @@ -152,7 +142,7 @@ article was posted to nndb") (nntp-send-command nil "X-TOUCH" article)) (deffoo nndb-request-update-mark - (group article mark) + (group article mark) "Sets the expiry date for ARTICLE in GROUP to now, if the mark is 'E'" (if (and nndb-set-expire-date-on-mark (string-equal mark "E")) (nndb-touch-article group article)) @@ -174,7 +164,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)) @@ -187,12 +177,12 @@ article was posted to nndb") (setq num-delete (1+ num-delete))) (push art rest)))) (if (> (length delete-list) 0) - (progn + (progn (nnheader-message 5 "Deleting %s article(s) from %s" (int-to-string num-delete) group) (nntp-send-command "^[23].*\n" "X-DELETE" delete-list)) ) - + (nnheader-message 5 "") (nconc rest articles))) @@ -201,12 +191,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 @@ -214,25 +204,25 @@ article was posted to nndb") "Let the nndb backend expire articles" (let (days art-string delete-list (num-delete 0)) (nntp-possibly-change-group group server) - + ;; 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 (setq art-string (concat days " " (nndb-build-article-string articles))) (nntp-send-command "^\.\r?\n\\|^[345].*\n" "X-EXPIRE" art-string) - + (setq delete-list (nndb-get-remote-expire-response)) (setq num-delete (length delete-list)) (if (> num-delete 0) @@ -251,7 +241,7 @@ expiry mechanism." (nndb-request-expire-articles-local articles group server force))) (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." @@ -259,7 +249,7 @@ Optional LAST is ignored." ;; which it will be for nndb, which is all that matters anyway (let ((new-group (nth 1 accept-form)) result) (nntp-possibly-change-group group server) - + ;; use the move command for nndb-to-nndb moves (if (string-match "^nndb" new-group) (let ((new-group-name (gnus-group-real-name new-group))) @@ -267,21 +257,21 @@ 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) "The article in the current buffer is put into GROUP." (nntp-possibly-change-group group server) @@ -289,9 +279,9 @@ Optional LAST is ignored." (when (nntp-send-command "^[23].*\r?\n" "ACCEPT" group) (nnheader-insert "") (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))) @@ -299,26 +289,25 @@ Optional LAST is ignored." (list art))) (deffoo nndb-request-replace-article (article group buffer) - "ARTICLE is the number of the article in GROUP to be replaced -with the contents of the BUFFER." + "ARTICLE is the number of the article in GROUP to be replaced with the contents of the BUFFER." (set-buffer buffer) (when (nntp-send-command "^[23].*\r?\n" "X-REPLACE" (int-to-string article)) (nnheader-insert "") (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 (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,5 +316,5 @@ with the contents of the BUFFER." (provide 'nndb) - - +;;; arch-tag: 83bd6fb4-58d9-4fed-a901-c6c625ad5f8a +;;; nndb.el ends here