home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 31 / CDASC_31_1996_juillet_aout.iso / vrac_os2 / e31el3.zip / EMACS / 19.31 / LISP / NNDIR.EL < prev    next >
Lisp/Scheme  |  1996-01-20  |  4KB  |  144 lines

  1. ;;; nndir.el --- single directory newsgroup access for Gnus
  2.  
  3. ;; Copyright (C) 1995 Free Software Foundation, Inc.
  4.  
  5. ;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
  6. ;;     Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
  7. ;; Keywords: news
  8.  
  9. ;; This file is part of GNU Emacs.
  10.  
  11. ;; GNU Emacs is free software; you can redistribute it and/or modify
  12. ;; it under the terms of the GNU General Public License as published by
  13. ;; the Free Software Foundation; either version 2, or (at your option)
  14. ;; any later version.
  15.  
  16. ;; GNU Emacs is distributed in the hope that it will be useful,
  17. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  19. ;; GNU General Public License for more details.
  20.  
  21. ;; You should have received a copy of the GNU General Public License
  22. ;; along with GNU Emacs; see the file COPYING.  If not, write to the
  23. ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  24. ;; Boston, MA 02111-1307, USA.
  25.  
  26. ;;; Commentary:
  27.  
  28. ;;; Code:
  29.  
  30. (require 'nnheader)
  31. (require 'nnmh)
  32. (require 'nnml)
  33.  
  34. (eval-and-compile
  35.   (autoload 'mail-send-and-exit "sendmail"))
  36.  
  37.  
  38.  
  39. (defconst nndir-version "nndir 1.0")
  40.  
  41. (defvar nndir-current-directory nil
  42.   "Current news group directory.")
  43.  
  44. (defvar nndir-status-string "")
  45.  
  46. (defvar nndir-nov-is-evil nil
  47.   "*Non-nil means that nndir will never retrieve NOV headers.")
  48.  
  49.  
  50.  
  51. ;;; Interface functions.
  52.  
  53.  
  54. (defun nndir-retrieve-headers (sequence &optional newsgroup server)
  55.   (nndir-execute-nnml-command
  56.    '(nnml-retrieve-headers sequence group server) server))
  57.  
  58. (defun nndir-open-server (host &optional service)
  59.   "Open nndir backend."
  60.   (setq nndir-status-string "")
  61.   (nnheader-init-server-buffer))
  62.  
  63. (defun nndir-close-server (&optional server)
  64.   "Close news server."
  65.   t)
  66.  
  67. (defun nndir-server-opened (&optional server)
  68.   "Return server process status, T or NIL.
  69. If the stream is opened, return T, otherwise return NIL."
  70.   (and nntp-server-buffer
  71.        (get-buffer nntp-server-buffer)))
  72.  
  73. (defun nndir-status-message (&optional server)
  74.   "Return server status response as string."
  75.   nndir-status-string)
  76.  
  77. (defun nndir-request-article (id &optional newsgroup server buffer)
  78.   (nndir-execute-nnmh-command
  79.    '(nnmh-request-article id group server buffer) server))
  80.  
  81. (defun nndir-request-group (group &optional server dont-check)
  82.   "Select news GROUP."
  83.   (nndir-execute-nnmh-command
  84.    '(nnmh-request-group group "" dont-check) server))
  85.  
  86. (defun nndir-request-list (&optional server dir)
  87.   "Get list of active articles in all newsgroups."
  88.   (nndir-execute-nnmh-command
  89.    '(nnmh-request-list nil dir) server))
  90.  
  91. (defun nndir-request-newgroups (date &optional server)
  92.   (nndir-execute-nnmh-command
  93.    '(nnmh-request-newgroups date server) server))
  94.  
  95. (defun nndir-request-post (&optional server)
  96.   "Post a new news in current buffer."
  97.   (mail-send-and-exit nil))
  98.  
  99. (defalias 'nndir-request-post-buffer 'nnmail-request-post-buffer)
  100.  
  101. (defun nndir-request-expire-articles (articles newsgroup &optional server force)
  102.   "Expire all articles in the ARTICLES list in group GROUP."
  103.   (setq nndir-status-string "nndir: expire not possible")
  104.   nil)
  105.  
  106. (defun nndir-close-group (group &optional server)
  107.   t)
  108.  
  109. (defun nndir-request-move-article (article group server accept-form)
  110.   (setq nndir-status-string "nndir: move not possible")
  111.   nil)
  112.  
  113. (defun nndir-request-accept-article (group)
  114.   (setq nndir-status-string "nndir: accept not possible")
  115.   nil)
  116.  
  117.  
  118. ;;; Low-Level Interface
  119.  
  120. (defun nndir-execute-nnmh-command (command server)
  121.   (let ((dir (expand-file-name server)))
  122.     (and (string-match "/$" dir)
  123.      (setq dir (substring dir 0 (match-beginning 0))))
  124.     (string-match "/[^/]+$" dir)
  125.     (let ((group (substring dir (1+ (match-beginning 0))))
  126.       (nnmh-directory (substring dir 0 (1+ (match-beginning 0))))
  127.       (nnmh-get-new-mail nil))
  128.       (eval command))))
  129.  
  130. (defun nndir-execute-nnml-command (command server)
  131.   (let ((dir (expand-file-name server)))
  132.     (and (string-match "/$" dir)
  133.      (setq dir (substring dir 0 (match-beginning 0))))
  134.     (string-match "/[^/]+$" dir)
  135.     (let ((group (substring dir (1+ (match-beginning 0))))
  136.       (nnml-directory (substring dir 0 (1+ (match-beginning 0))))
  137.       (nnml-nov-is-evil nndir-nov-is-evil)
  138.       (nnml-get-new-mail nil))
  139.       (eval command))))
  140.  
  141. (provide 'nndir)
  142.  
  143. ;;; nndir.el ends here
  144.