annotate lisp/=mhspool.el @ 18845:a64fd9cec691

(c-initialize-builtin-style): Use copy-sequence instead of c-copy-tree. (c-copy-tree): Function deleted.
author Richard M. Stallman <rms@gnu.org>
date Fri, 18 Jul 1997 02:12:00 +0000
parents 507f64624555
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
659
505130d1ddf8 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 584
diff changeset
1 ;;; mhspool.el --- MH folder access using NNTP for GNU Emacs
505130d1ddf8 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 584
diff changeset
2
2843
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
3 ;; Copyright (C) 1988, 1989, 1990, 1993 Free Software Foundation, Inc.
840
113281b361ec *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 811
diff changeset
4
791
203c23c9f22c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 659
diff changeset
5 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet>
203c23c9f22c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 659
diff changeset
6 ;; Maintainer: FSF
811
e694e0879463 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 791
diff changeset
7 ;; Keywords: mail, news
791
203c23c9f22c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 659
diff changeset
8
87
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
10
896
7e4999005da1 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 853
diff changeset
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
7e4999005da1 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 853
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
7e4999005da1 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 853
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
7e4999005da1 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 853
diff changeset
14 ;; any later version.
87
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
15
896
7e4999005da1 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 853
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
7e4999005da1 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 853
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
7e4999005da1 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 853
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7e4999005da1 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 853
diff changeset
19 ;; GNU General Public License for more details.
7e4999005da1 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 853
diff changeset
20
7e4999005da1 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 853
diff changeset
21 ;; You should have received a copy of the GNU General Public License
7e4999005da1 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 853
diff changeset
22 ;; along with GNU Emacs; see the file COPYING. If not, write to
7e4999005da1 entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 853
diff changeset
23 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
87
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
24
2232
4f9d60f7de9d Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 896
diff changeset
25 ;;; Commentary:
87
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
26
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
27 ;; This package enables you to read mail or articles in MH folders, or
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
28 ;; articles saved by GNUS. In any case, the file names of mail or
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
29 ;; articles must consist of only numeric letters.
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
30
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
31 ;; Before using this package, you have to create a server specific
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
32 ;; startup file according to the directory which you want to read. For
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
33 ;; example, if you want to read mail under the directory named
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
34 ;; `~/Mail', the file must be a file named `.newsrc-:Mail'. (There is
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
35 ;; no way to specify hierarchical directory now.) In this case, the
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
36 ;; name of the NNTP server passed to GNUS must be `:Mail'.
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
37
2232
4f9d60f7de9d Add standard library headers.
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 896
diff changeset
38 ;;; Code:
791
203c23c9f22c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 659
diff changeset
39
203c23c9f22c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 659
diff changeset
40 (require 'nntp)
203c23c9f22c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 659
diff changeset
41
2843
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
42 (defvar mhspool-list-folders-method
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
43 (function mhspool-list-folders-using-sh)
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
44 "*Function to list files in folders.
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
45 The function should accept a directory as its argument, and fill the
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
46 current buffer with file and directory names. The output format must
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
47 be the same as that of 'ls -R1'. Two functions
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
48 mhspool-list-folders-using-ls and mhspool-list-folders-using-sh are
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
49 provided now. I suppose the later is faster.")
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
50
87
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
51 (defvar mhspool-list-directory-switches '("-R")
3591
507f64624555 Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents: 2843
diff changeset
52 "*Switches for mhspool-list-folders-using-ls to pass to `ls' for getting file lists.
87
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
53 One entry should appear on one line. You may need to add `-1' option.")
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
54
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
55
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
56
2843
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
57 (defconst mhspool-version "MHSPOOL 1.8"
87
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
58 "Version numbers of this version of MHSPOOL.")
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
59
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
60 (defvar mhspool-spool-directory "~/Mail"
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
61 "Private mail directory.")
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
62
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
63 (defvar mhspool-current-directory nil
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
64 "Current news group directory.")
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
65
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
66 ;;;
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
67 ;;; Replacement of Extended Command for retrieving many headers.
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
68 ;;;
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
69
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
70 (defun mhspool-retrieve-headers (sequence)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
71 "Return list of article headers specified by SEQUENCE of article id.
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
72 The format of list is
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
73 `([NUMBER SUBJECT FROM XREF LINES DATE MESSAGE-ID REFERENCES] ...)'.
2843
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
74 If there is no References: field, In-Reply-To: field is used instead.
87
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
75 Reader macros for the vector are defined as `nntp-header-FIELD'.
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
76 Writer macros for the vector are defined as `nntp-set-header-FIELD'.
2843
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
77 Newsgroup must be selected before calling this."
87
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
78 (save-excursion
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
79 (set-buffer nntp-server-buffer)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
80 ;;(erase-buffer)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
81 (let ((file nil)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
82 (number (length sequence))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
83 (count 0)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
84 (headers nil) ;Result list.
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
85 (article 0)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
86 (subject nil)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
87 (message-id nil)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
88 (from nil)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
89 (xref nil)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
90 (lines 0)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
91 (date nil)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
92 (references nil))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
93 (while sequence
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
94 ;;(nntp-send-strings-to-server "HEAD" (car sequence))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
95 (setq article (car sequence))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
96 (setq file
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
97 (concat mhspool-current-directory (prin1-to-string article)))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
98 (if (and (file-exists-p file)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
99 (not (file-directory-p file)))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
100 (progn
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
101 (erase-buffer)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
102 (insert-file-contents file)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
103 ;; Make message body invisible.
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
104 (goto-char (point-min))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
105 (search-forward "\n\n" nil 'move)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
106 (narrow-to-region (point-min) (point))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
107 ;; Fold continuation lines.
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
108 (goto-char (point-min))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
109 (while (re-search-forward "\\(\r?\n[ \t]+\\)+" nil t)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
110 (replace-match " " t t))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
111 ;; Make it possible to search for `\nFIELD'.
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
112 (goto-char (point-min))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
113 (insert "\n")
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
114 ;; Extract From:
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
115 (goto-char (point-min))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
116 (if (search-forward "\nFrom: " nil t)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
117 (setq from (buffer-substring
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
118 (point)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
119 (save-excursion (end-of-line) (point))))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
120 (setq from "(Unknown User)"))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
121 ;; Extract Subject:
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
122 (goto-char (point-min))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
123 (if (search-forward "\nSubject: " nil t)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
124 (setq subject (buffer-substring
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
125 (point)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
126 (save-excursion (end-of-line) (point))))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
127 (setq subject "(None)"))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
128 ;; Extract Message-ID:
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
129 (goto-char (point-min))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
130 (if (search-forward "\nMessage-ID: " nil t)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
131 (setq message-id (buffer-substring
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
132 (point)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
133 (save-excursion (end-of-line) (point))))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
134 (setq message-id nil))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
135 ;; Extract Date:
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
136 (goto-char (point-min))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
137 (if (search-forward "\nDate: " nil t)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
138 (setq date (buffer-substring
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
139 (point)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
140 (save-excursion (end-of-line) (point))))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
141 (setq date nil))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
142 ;; Extract Lines:
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
143 (goto-char (point-min))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
144 (if (search-forward "\nLines: " nil t)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
145 (setq lines (string-to-int
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
146 (buffer-substring
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
147 (point)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
148 (save-excursion (end-of-line) (point)))))
2843
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
149 ;; Count lines since there is no lines field in most cases.
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
150 (setq lines
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
151 (save-restriction
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
152 (goto-char (point-max))
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
153 (widen)
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
154 (count-lines (point) (point-max)))))
87
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
155 ;; Extract Xref:
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
156 (goto-char (point-min))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
157 (if (search-forward "\nXref: " nil t)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
158 (setq xref (buffer-substring
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
159 (point)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
160 (save-excursion (end-of-line) (point))))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
161 (setq xref nil))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
162 ;; Extract References:
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
163 ;; If no References: field, use In-Reply-To: field instead.
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
164 ;; Suggested by tanaka@flab.fujitsu.co.jp (Hiroshi TANAKA).
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
165 (goto-char (point-min))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
166 (if (or (search-forward "\nReferences: " nil t)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
167 (search-forward "\nIn-Reply-To: " nil t))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
168 (setq references (buffer-substring
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
169 (point)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
170 (save-excursion (end-of-line) (point))))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
171 (setq references nil))
2843
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
172 ;; Collect valid article only.
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
173 (and article
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
174 message-id
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
175 (setq headers
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
176 (cons (vector article subject from
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
177 xref lines date
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
178 message-id references) headers)))
87
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
179 ))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
180 (setq sequence (cdr sequence))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
181 (setq count (1+ count))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
182 (and (numberp nntp-large-newsgroup)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
183 (> number nntp-large-newsgroup)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
184 (zerop (% count 20))
2843
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
185 (message "MHSPOOL: Receiving headers... %d%%"
87
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
186 (/ (* count 100) number)))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
187 )
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
188 (and (numberp nntp-large-newsgroup)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
189 (> number nntp-large-newsgroup)
2843
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
190 (message "MHSPOOL: Receiving headers... done"))
87
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
191 (nreverse headers)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
192 )))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
193
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
194
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
195 ;;;
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
196 ;;; Replacement of NNTP Raw Interface.
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
197 ;;;
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
198
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
199 (defun mhspool-open-server (host &optional service)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
200 "Open news server on HOST.
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
201 If HOST is nil, use value of environment variable `NNTPSERVER'.
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
202 If optional argument SERVICE is non-nil, open by the service name."
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
203 (let ((host (or host (getenv "NNTPSERVER")))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
204 (status nil))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
205 ;; Get directory name from HOST name.
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
206 (if (string-match ":\\(.+\\)$" host)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
207 (progn
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
208 (setq mhspool-spool-directory
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
209 (file-name-as-directory
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
210 (expand-file-name
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
211 (substring host (match-beginning 1) (match-end 1))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
212 (expand-file-name "~/" nil))))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
213 (setq host (system-name)))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
214 (setq mhspool-spool-directory nil))
2843
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
215 (setq nntp-status-string "")
87
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
216 (cond ((and (stringp host)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
217 (stringp mhspool-spool-directory)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
218 (file-directory-p mhspool-spool-directory)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
219 (string-equal host (system-name)))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
220 (setq status (mhspool-open-server-internal host service)))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
221 ((string-equal host (system-name))
2843
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
222 (setq nntp-status-string
87
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
223 (format "No such directory: %s. Goodbye."
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
224 mhspool-spool-directory)))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
225 ((null host)
2843
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
226 (setq nntp-status-string "NNTP server is not specified."))
87
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
227 (t
2843
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
228 (setq nntp-status-string
87
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
229 (format "MHSPOOL: cannot talk to %s." host)))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
230 )
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
231 status
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
232 ))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
233
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
234 (defun mhspool-close-server ()
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
235 "Close news server."
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
236 (mhspool-close-server-internal))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
237
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
238 (fset 'mhspool-request-quit (symbol-function 'mhspool-close-server))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
239
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
240 (defun mhspool-server-opened ()
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
241 "Return server process status, T or NIL.
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
242 If the stream is opened, return T, otherwise return NIL."
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
243 (and nntp-server-buffer
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
244 (get-buffer nntp-server-buffer)))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
245
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
246 (defun mhspool-status-message ()
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
247 "Return server status response as string."
2843
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
248 nntp-status-string
87
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
249 )
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
250
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
251 (defun mhspool-request-article (id)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
252 "Select article by message ID (or number)."
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
253 (let ((file (concat mhspool-current-directory (prin1-to-string id))))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
254 (if (and (stringp file)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
255 (file-exists-p file)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
256 (not (file-directory-p file)))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
257 (save-excursion
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
258 (mhspool-find-file file)))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
259 ))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
260
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
261 (defun mhspool-request-body (id)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
262 "Select article body by message ID (or number)."
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
263 (if (mhspool-request-article id)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
264 (save-excursion
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
265 (set-buffer nntp-server-buffer)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
266 (goto-char (point-min))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
267 (if (search-forward "\n\n" nil t)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
268 (delete-region (point-min) (point)))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
269 t
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
270 )
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
271 ))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
272
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
273 (defun mhspool-request-head (id)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
274 "Select article head by message ID (or number)."
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
275 (if (mhspool-request-article id)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
276 (save-excursion
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
277 (set-buffer nntp-server-buffer)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
278 (goto-char (point-min))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
279 (if (search-forward "\n\n" nil t)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
280 (delete-region (1- (point)) (point-max)))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
281 t
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
282 )
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
283 ))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
284
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
285 (defun mhspool-request-stat (id)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
286 "Select article by message ID (or number)."
2843
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
287 (setq nntp-status-string "MHSPOOL: STAT is not implemented.")
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
288 nil
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
289 )
87
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
290
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
291 (defun mhspool-request-group (group)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
292 "Select news GROUP."
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
293 (cond ((file-directory-p
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
294 (mhspool-article-pathname group))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
295 ;; Mail/NEWS.GROUP/N
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
296 (setq mhspool-current-directory
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
297 (mhspool-article-pathname group)))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
298 ((file-directory-p
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
299 (mhspool-article-pathname
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
300 (mhspool-replace-chars-in-string group ?. ?/)))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
301 ;; Mail/NEWS/GROUP/N
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
302 (setq mhspool-current-directory
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
303 (mhspool-article-pathname
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
304 (mhspool-replace-chars-in-string group ?. ?/))))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
305 ))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
306
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
307 (defun mhspool-request-list ()
2843
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
308 "List active newsgoups."
87
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
309 (save-excursion
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
310 (let* ((newsgroup nil)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
311 (articles nil)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
312 (directory (file-name-as-directory
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
313 (expand-file-name mhspool-spool-directory nil)))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
314 (folder-regexp (concat "^" (regexp-quote directory) "\\(.+\\):$"))
2843
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
315 (buffer (get-buffer-create " *MHSPOOL File List*")))
87
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
316 (set-buffer nntp-server-buffer)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
317 (erase-buffer)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
318 (set-buffer buffer)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
319 (erase-buffer)
2843
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
320 ;; (apply 'call-process
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
321 ;; "ls" nil t nil
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
322 ;; (append mhspool-list-directory-switches (list directory)))
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
323 (funcall mhspool-list-folders-method directory)
87
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
324 (goto-char (point-min))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
325 (while (re-search-forward folder-regexp nil t)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
326 (setq newsgroup
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
327 (mhspool-replace-chars-in-string
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
328 (buffer-substring (match-beginning 1) (match-end 1)) ?/ ?.))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
329 (setq articles nil)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
330 (forward-line 1) ;(beginning-of-line)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
331 ;; Thank nobu@flab.fujitsu.junet for his bug fixes.
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
332 (while (and (not (eobp))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
333 (not (looking-at "^$")))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
334 (if (looking-at "^[0-9]+$")
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
335 (setq articles
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
336 (cons (string-to-int
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
337 (buffer-substring
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
338 (match-beginning 0) (match-end 0)))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
339 articles)))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
340 (forward-line 1))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
341 (if articles
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
342 (princ (format "%s %d %d n\n" newsgroup
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
343 (apply (function max) articles)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
344 (apply (function min) articles))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
345 nntp-server-buffer))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
346 )
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
347 (kill-buffer buffer)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
348 (set-buffer nntp-server-buffer)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
349 (buffer-size)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
350 )))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
351
2843
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
352 (defun mhspool-request-list-newsgroups ()
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
353 "List newsgoups (defined in NNTP2)."
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
354 (setq nntp-status-string "MHSPOOL: LIST NEWSGROUPS is not implemented.")
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
355 nil
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
356 )
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
357
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
358 (defun mhspool-request-list-distributions ()
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
359 "List distributions (defined in NNTP2)."
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
360 (setq nntp-status-string "MHSPOOL: LIST DISTRIBUTIONS is not implemented.")
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
361 nil
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
362 )
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
363
87
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
364 (defun mhspool-request-last ()
2843
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
365 "Set current article pointer to the previous article
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
366 in the current news group."
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
367 (setq nntp-status-string "MHSPOOL: LAST is not implemented.")
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
368 nil
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
369 )
87
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
370
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
371 (defun mhspool-request-next ()
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
372 "Advance current article pointer."
2843
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
373 (setq nntp-status-string "MHSPOOL: NEXT is not implemented.")
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
374 nil
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
375 )
87
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
376
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
377 (defun mhspool-request-post ()
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
378 "Post a new news in current buffer."
2843
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
379 (setq nntp-status-string "MHSPOOL: POST: what do you mean?")
87
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
380 nil
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
381 )
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
382
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
383
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
384 ;;;
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
385 ;;; Replacement of Low-Level Interface to NNTP Server.
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
386 ;;;
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
387
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
388 (defun mhspool-open-server-internal (host &optional service)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
389 "Open connection to news server on HOST by SERVICE (default is nntp)."
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
390 (save-excursion
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
391 (if (not (string-equal host (system-name)))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
392 (error "MHSPOOL: cannot talk to %s." host))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
393 ;; Initialize communication buffer.
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
394 (setq nntp-server-buffer (get-buffer-create " *nntpd*"))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
395 (set-buffer nntp-server-buffer)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
396 (buffer-flush-undo (current-buffer))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
397 (erase-buffer)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
398 (kill-all-local-variables)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
399 (setq case-fold-search t) ;Should ignore case.
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
400 (setq nntp-server-process nil)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
401 (setq nntp-server-name host)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
402 ;; It is possible to change kanji-fileio-code in this hook.
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
403 (run-hooks 'nntp-server-hook)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
404 t
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
405 ))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
406
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
407 (defun mhspool-close-server-internal ()
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
408 "Close connection to news server."
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
409 (if nntp-server-buffer
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
410 (kill-buffer nntp-server-buffer))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
411 (setq nntp-server-buffer nil)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
412 (setq nntp-server-process nil))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
413
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
414 (defun mhspool-find-file (file)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
415 "Insert FILE in server buffer safely."
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
416 (set-buffer nntp-server-buffer)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
417 (erase-buffer)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
418 (condition-case ()
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
419 (progn
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
420 (insert-file-contents file)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
421 (goto-char (point-min))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
422 ;; If there is no body, `^L' appears at end of file. Special
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
423 ;; hack for MH folder.
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
424 (and (search-forward "\n\n" nil t)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
425 (string-equal (buffer-substring (point) (point-max)) "\^L")
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
426 (delete-char 1))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
427 t
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
428 )
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
429 (file-error nil)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
430 ))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
431
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
432 (defun mhspool-article-pathname (group)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
433 "Make pathname for GROUP."
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
434 (concat (file-name-as-directory mhspool-spool-directory) group "/"))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
435
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
436 (defun mhspool-replace-chars-in-string (string from to)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
437 "Replace characters in STRING from FROM to TO."
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
438 (let ((string (substring string 0)) ;Copy string.
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
439 (len (length string))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
440 (idx 0))
3591
507f64624555 Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents: 2843
diff changeset
441 ;; Replace all occurrences of FROM with TO.
87
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
442 (while (< idx len)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
443 (if (= (aref string idx) from)
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
444 (aset string idx to))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
445 (setq idx (1+ idx)))
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
446 string
d39407c00c09 Initial revision
root <root>
parents:
diff changeset
447 ))
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 227
diff changeset
448
2843
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
449
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
450 ;; Methods for listing files in folders.
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
451
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
452 (defun mhspool-list-folders-using-ls (directory)
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
453 "List files in folders under DIRECTORY using 'ls'."
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
454 (apply 'call-process
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
455 "ls" nil t nil
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
456 (append mhspool-list-directory-switches (list directory))))
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
457
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
458 ;; Basic ideas by tanaka@flab.fujitsu.co.jp (Hiroshi TANAKA)
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
459
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
460 (defun mhspool-list-folders-using-sh (directory)
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
461 "List files in folders under DIRECTORY using '/bin/sh'."
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
462 (let ((buffer (current-buffer))
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
463 (script (get-buffer-create " *MHSPOOL Shell Script Buffer*")))
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
464 (save-excursion
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
465 (save-restriction
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
466 (set-buffer script)
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
467 (erase-buffer)
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
468 ;; /bin/sh script which does 'ls -R'.
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
469 (insert
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
470 "PS2=
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
471 ffind() {
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
472 cd $1; echo $1:
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
473 ls -1
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
474 echo
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
475 for j in `echo *[a-zA-Z]*`
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
476 do
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
477 if [ -d $1/$j ]; then
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
478 ffind $1/$j
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
479 fi
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
480 done
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
481 }
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
482 cd " directory "; ffind `pwd`; exit 0\n")
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
483 (call-process-region (point-min) (point-max) "sh" nil buffer nil)
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
484 ))
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
485 (kill-buffer script)
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
486 ))
cd90d49526ae Version 3.15 from Umeda.
Richard M. Stallman <rms@gnu.org>
parents: 2232
diff changeset
487
584
4cd7543be581 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 227
diff changeset
488 (provide 'mhspool)
659
505130d1ddf8 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 584
diff changeset
489
505130d1ddf8 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 584
diff changeset
490 ;;; mhspool.el ends here