Mercurial > emacs
annotate lisp/gnus/nnheader.el @ 34395:2f4a4d355834
(time-stamp-old-format-warn): reorder custom
choices to match documentation string.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Sat, 09 Dec 2000 13:22:51 +0000 |
parents | e06db3b8e558 |
children | 3279d2b52568 |
rev | line source |
---|---|
17493 | 1 ;;; nnheader.el --- header access macros for Gnus and its backends |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
2 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
3 ;; Copyright (C) 1987, 1988, 1989, 1990, 1993, 1994, 1995, 1996, |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
4 ;; 1997, 1998, 2000 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
5 ;; Free Software Foundation, Inc. |
17493 | 6 |
7 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet> | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
8 ;; Lars Magne Ingebrigtsen <larsi@gnus.org> |
17493 | 9 ;; Keywords: news |
10 | |
11 ;; This file is part of GNU Emacs. | |
12 | |
13 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
14 ;; it under the terms of the GNU General Public License as published by | |
15 ;; the Free Software Foundation; either version 2, or (at your option) | |
16 ;; any later version. | |
17 | |
18 ;; GNU Emacs is distributed in the hope that it will be useful, | |
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
21 ;; GNU General Public License for more details. | |
22 | |
23 ;; You should have received a copy of the GNU General Public License | |
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
26 ;; Boston, MA 02111-1307, USA. | |
27 | |
28 ;;; Commentary: | |
29 | |
30 ;;; Code: | |
31 | |
19493
8d840c4548c0
Require cl at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
17493
diff
changeset
|
32 (eval-when-compile (require 'cl)) |
8d840c4548c0
Require cl at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
17493
diff
changeset
|
33 |
17493 | 34 (require 'mail-utils) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
35 (require 'mm-util) |
33300
cae923af5a5d
Wrap subst-char-in-string def in eval-and-compile.
Dave Love <fx@gnu.org>
parents:
32972
diff
changeset
|
36 (eval-and-compile |
cae923af5a5d
Wrap subst-char-in-string def in eval-and-compile.
Dave Love <fx@gnu.org>
parents:
32972
diff
changeset
|
37 (autoload 'gnus-intersection "gnus-range") |
cae923af5a5d
Wrap subst-char-in-string def in eval-and-compile.
Dave Love <fx@gnu.org>
parents:
32972
diff
changeset
|
38 (autoload 'gnus-sorted-complement "gnus-range")) |
17493 | 39 |
40 (defvar nnheader-max-head-length 4096 | |
41 "*Max length of the head of articles.") | |
42 | |
43 (defvar nnheader-head-chop-length 2048 | |
44 "*Length of each read operation when trying to fetch HEAD headers.") | |
45 | |
46 (defvar nnheader-file-name-translation-alist nil | |
47 "*Alist that says how to translate characters in file names. | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
48 For instance, if \":\" is invalid as a file character in file names |
17493 | 49 on your system, you could say something like: |
50 | |
51 \(setq nnheader-file-name-translation-alist '((?: . ?_)))") | |
52 | |
53 (eval-and-compile | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
54 (autoload 'nnmail-message-id "nnmail") |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
55 (autoload 'mail-position-on-field "sendmail") |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
56 (autoload 'message-remove-header "message") |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
57 (autoload 'gnus-point-at-eol "gnus-util") |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
58 (autoload 'gnus-delete-line "gnus-util") |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
59 (autoload 'gnus-buffer-live-p "gnus-util")) |
17493 | 60 |
61 ;;; Header access macros. | |
62 | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
63 ;; These macros may look very much like the ones in GNUS 4.1. They |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
64 ;; are, in a way, but you should note that the indices they use have |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
65 ;; been changed from the internal GNUS format to the NOV format. The |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
66 ;; makes it possible to read headers from XOVER much faster. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
67 ;; |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
68 ;; The format of a header is now: |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
69 ;; [number subject from date id references chars lines xref extra] |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
70 ;; |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
71 ;; (That next-to-last entry is defined as "misc" in the NOV format, |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
72 ;; but Gnus uses it for xrefs.) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
73 |
17493 | 74 (defmacro mail-header-number (header) |
75 "Return article number in HEADER." | |
76 `(aref ,header 0)) | |
77 | |
78 (defmacro mail-header-set-number (header number) | |
79 "Set article number of HEADER to NUMBER." | |
80 `(aset ,header 0 ,number)) | |
81 | |
82 (defmacro mail-header-subject (header) | |
83 "Return subject string in HEADER." | |
84 `(aref ,header 1)) | |
85 | |
86 (defmacro mail-header-set-subject (header subject) | |
87 "Set article subject of HEADER to SUBJECT." | |
88 `(aset ,header 1 ,subject)) | |
89 | |
90 (defmacro mail-header-from (header) | |
91 "Return author string in HEADER." | |
92 `(aref ,header 2)) | |
93 | |
94 (defmacro mail-header-set-from (header from) | |
95 "Set article author of HEADER to FROM." | |
96 `(aset ,header 2 ,from)) | |
97 | |
98 (defmacro mail-header-date (header) | |
99 "Return date in HEADER." | |
100 `(aref ,header 3)) | |
101 | |
102 (defmacro mail-header-set-date (header date) | |
103 "Set article date of HEADER to DATE." | |
104 `(aset ,header 3 ,date)) | |
105 | |
106 (defalias 'mail-header-message-id 'mail-header-id) | |
107 (defmacro mail-header-id (header) | |
108 "Return Id in HEADER." | |
109 `(aref ,header 4)) | |
110 | |
111 (defalias 'mail-header-set-message-id 'mail-header-set-id) | |
112 (defmacro mail-header-set-id (header id) | |
113 "Set article Id of HEADER to ID." | |
114 `(aset ,header 4 ,id)) | |
115 | |
116 (defmacro mail-header-references (header) | |
117 "Return references in HEADER." | |
118 `(aref ,header 5)) | |
119 | |
120 (defmacro mail-header-set-references (header ref) | |
121 "Set article references of HEADER to REF." | |
122 `(aset ,header 5 ,ref)) | |
123 | |
124 (defmacro mail-header-chars (header) | |
125 "Return number of chars of article in HEADER." | |
126 `(aref ,header 6)) | |
127 | |
128 (defmacro mail-header-set-chars (header chars) | |
129 "Set number of chars in article of HEADER to CHARS." | |
130 `(aset ,header 6 ,chars)) | |
131 | |
132 (defmacro mail-header-lines (header) | |
133 "Return lines in HEADER." | |
134 `(aref ,header 7)) | |
135 | |
136 (defmacro mail-header-set-lines (header lines) | |
137 "Set article lines of HEADER to LINES." | |
138 `(aset ,header 7 ,lines)) | |
139 | |
140 (defmacro mail-header-xref (header) | |
141 "Return xref string in HEADER." | |
142 `(aref ,header 8)) | |
143 | |
144 (defmacro mail-header-set-xref (header xref) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
145 "Set article XREF of HEADER to xref." |
17493 | 146 `(aset ,header 8 ,xref)) |
147 | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
148 (defmacro mail-header-extra (header) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
149 "Return the extra headers in HEADER." |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
150 `(aref ,header 9)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
151 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
152 (defmacro mail-header-set-extra (header extra) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
153 "Set the extra headers in HEADER to EXTRA." |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
154 `(aset ,header 9 ',extra)) |
17493 | 155 |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
156 (defsubst make-mail-header (&optional init) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
157 "Create a new mail header structure initialized with INIT." |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
158 (make-vector 10 init)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
159 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
160 (defsubst make-full-mail-header (&optional number subject from date id |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
161 references chars lines xref |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
162 extra) |
17493 | 163 "Create a new mail header structure initialized with the parameters given." |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
164 (vector number subject from date id references chars lines xref extra)) |
17493 | 165 |
166 ;; fake message-ids: generation and detection | |
167 | |
168 (defvar nnheader-fake-message-id 1) | |
169 | |
170 (defsubst nnheader-generate-fake-message-id () | |
171 (concat "fake+none+" (int-to-string (incf nnheader-fake-message-id)))) | |
172 | |
173 (defsubst nnheader-fake-message-id-p (id) | |
174 (save-match-data ; regular message-id's are <.*> | |
175 (string-match "\\`fake\\+none\\+[0-9]+\\'" id))) | |
176 | |
177 ;; Parsing headers and NOV lines. | |
178 | |
179 (defsubst nnheader-header-value () | |
180 (buffer-substring (match-end 0) (gnus-point-at-eol))) | |
181 | |
182 (defun nnheader-parse-head (&optional naked) | |
183 (let ((case-fold-search t) | |
184 (cur (current-buffer)) | |
185 (buffer-read-only nil) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
186 in-reply-to lines p ref) |
17493 | 187 (goto-char (point-min)) |
188 (when naked | |
189 (insert "\n")) | |
190 ;; Search to the beginning of the next header. Error messages | |
191 ;; do not begin with 2 or 3. | |
192 (prog1 | |
193 (when (or naked (re-search-forward "^[23][0-9]+ " nil t)) | |
194 ;; This implementation of this function, with nine | |
195 ;; search-forwards instead of the one re-search-forward and | |
196 ;; a case (which basically was the old function) is actually | |
197 ;; about twice as fast, even though it looks messier. You | |
198 ;; can't have everything, I guess. Speed and elegance | |
199 ;; don't always go hand in hand. | |
200 (vector | |
201 ;; Number. | |
202 (if naked | |
203 (progn | |
204 (setq p (point-min)) | |
205 0) | |
206 (prog1 | |
207 (read cur) | |
208 (end-of-line) | |
209 (setq p (point)) | |
210 (narrow-to-region (point) | |
211 (or (and (search-forward "\n.\n" nil t) | |
212 (- (point) 2)) | |
213 (point))))) | |
214 ;; Subject. | |
215 (progn | |
216 (goto-char p) | |
217 (if (search-forward "\nsubject: " nil t) | |
218 (nnheader-header-value) "(none)")) | |
219 ;; From. | |
220 (progn | |
221 (goto-char p) | |
32972
a51631f90704
2000-09-24 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31785
diff
changeset
|
222 (if (or (search-forward "\nfrom: " nil t) |
a51631f90704
2000-09-24 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31785
diff
changeset
|
223 (search-forward "\nfrom:" nil t)) |
17493 | 224 (nnheader-header-value) "(nobody)")) |
225 ;; Date. | |
226 (progn | |
227 (goto-char p) | |
228 (if (search-forward "\ndate: " nil t) | |
229 (nnheader-header-value) "")) | |
230 ;; Message-ID. | |
231 (progn | |
232 (goto-char p) | |
233 (if (search-forward "\nmessage-id:" nil t) | |
234 (buffer-substring | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
235 (1- (or (search-forward "<" (gnus-point-at-eol) t) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
236 (point))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
237 (or (search-forward ">" (gnus-point-at-eol) t) (point))) |
17493 | 238 ;; If there was no message-id, we just fake one to make |
239 ;; subsequent routines simpler. | |
240 (nnheader-generate-fake-message-id))) | |
241 ;; References. | |
242 (progn | |
243 (goto-char p) | |
244 (if (search-forward "\nreferences: " nil t) | |
245 (nnheader-header-value) | |
246 ;; Get the references from the in-reply-to header if there | |
247 ;; were no references and the in-reply-to header looks | |
248 ;; promising. | |
249 (if (and (search-forward "\nin-reply-to: " nil t) | |
250 (setq in-reply-to (nnheader-header-value)) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
251 (string-match "<[^\n>]+>" in-reply-to)) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
252 (let (ref2) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
253 (setq ref (substring in-reply-to (match-beginning 0) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
254 (match-end 0))) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
255 (while (string-match "<[^\n>]+>" |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
256 in-reply-to (match-end 0)) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
257 (setq ref2 (substring in-reply-to (match-beginning 0) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
258 (match-end 0))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
259 (when (> (length ref2) (length ref)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
260 (setq ref ref2))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
261 ref) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
262 nil))) |
17493 | 263 ;; Chars. |
264 0 | |
265 ;; Lines. | |
266 (progn | |
267 (goto-char p) | |
268 (if (search-forward "\nlines: " nil t) | |
269 (if (numberp (setq lines (read cur))) | |
270 lines 0) | |
271 0)) | |
272 ;; Xref. | |
273 (progn | |
274 (goto-char p) | |
275 (and (search-forward "\nxref: " nil t) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
276 (nnheader-header-value))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
277 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
278 ;; Extra. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
279 (when nnmail-extra-headers |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
280 (let ((extra nnmail-extra-headers) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
281 out) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
282 (while extra |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
283 (goto-char p) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
284 (when (search-forward |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
285 (concat "\n" (symbol-name (car extra)) ": ") nil t) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
286 (push (cons (car extra) (nnheader-header-value)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
287 out)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
288 (pop extra)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
289 out)))) |
17493 | 290 (when naked |
291 (goto-char (point-min)) | |
292 (delete-char 1))))) | |
293 | |
294 (defmacro nnheader-nov-skip-field () | |
295 '(search-forward "\t" eol 'move)) | |
296 | |
297 (defmacro nnheader-nov-field () | |
298 '(buffer-substring (point) (if (nnheader-nov-skip-field) (1- (point)) eol))) | |
299 | |
300 (defmacro nnheader-nov-read-integer () | |
301 '(prog1 | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
302 (if (eq (char-after) ?\t) |
17493 | 303 0 |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
304 (let ((num (condition-case nil |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
305 (read (current-buffer)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
306 (error nil)))) |
17493 | 307 (if (numberp num) num 0))) |
308 (or (eobp) (forward-char 1)))) | |
309 | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
310 (defmacro nnheader-nov-parse-extra () |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
311 '(let (out string) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
312 (while (not (memq (char-after) '(?\n nil))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
313 (setq string (nnheader-nov-field)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
314 (when (string-match "^\\([^ :]+\\): " string) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
315 (push (cons (intern (match-string 1 string)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
316 (substring string (match-end 0))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
317 out))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
318 out)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
319 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
320 (defmacro nnheader-nov-read-message-id () |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
321 '(let ((id (nnheader-nov-field))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
322 (if (string-match "^<[^>]+>$" id) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
323 id |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
324 (nnheader-generate-fake-message-id)))) |
17493 | 325 |
326 (defun nnheader-parse-nov () | |
327 (let ((eol (gnus-point-at-eol))) | |
328 (vector | |
329 (nnheader-nov-read-integer) ; number | |
330 (nnheader-nov-field) ; subject | |
331 (nnheader-nov-field) ; from | |
332 (nnheader-nov-field) ; date | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
333 (nnheader-nov-read-message-id) ; id |
17493 | 334 (nnheader-nov-field) ; refs |
335 (nnheader-nov-read-integer) ; chars | |
336 (nnheader-nov-read-integer) ; lines | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
337 (if (eq (char-after) ?\n) |
17493 | 338 nil |
31785 | 339 (if (looking-at "Xref: ") |
340 (goto-char (match-end 0))) | |
341 (nnheader-nov-field)) ; Xref | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
342 (nnheader-nov-parse-extra)))) ; extra |
17493 | 343 |
344 (defun nnheader-insert-nov (header) | |
345 (princ (mail-header-number header) (current-buffer)) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
346 (let ((p (point))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
347 (insert |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
348 "\t" |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
349 (or (mail-header-subject header) "(none)") "\t" |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
350 (or (mail-header-from header) "(nobody)") "\t" |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
351 (or (mail-header-date header) "") "\t" |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
352 (or (mail-header-id header) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
353 (nnmail-message-id)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
354 "\t" |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
355 (or (mail-header-references header) "") "\t") |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
356 (princ (or (mail-header-chars header) 0) (current-buffer)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
357 (insert "\t") |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
358 (princ (or (mail-header-lines header) 0) (current-buffer)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
359 (insert "\t") |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
360 (when (mail-header-xref header) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
361 (insert "Xref: " (mail-header-xref header))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
362 (when (or (mail-header-xref header) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
363 (mail-header-extra header)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
364 (insert "\t")) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
365 (when (mail-header-extra header) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
366 (let ((extra (mail-header-extra header))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
367 (while extra |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
368 (insert (symbol-name (caar extra)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
369 ": " (cdar extra) "\t") |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
370 (pop extra)))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
371 (insert "\n") |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
372 (backward-char 1) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
373 (while (search-backward "\n" p t) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
374 (delete-char 1)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
375 (forward-line 1))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
376 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
377 (defun nnheader-insert-header (header) |
17493 | 378 (insert |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
379 "Subject: " (or (mail-header-subject header) "(none)") "\n" |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
380 "From: " (or (mail-header-from header) "(nobody)") "\n" |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
381 "Date: " (or (mail-header-date header) "") "\n" |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
382 "Message-ID: " (or (mail-header-id header) (nnmail-message-id)) "\n" |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
383 "References: " (or (mail-header-references header) "") "\n" |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
384 "Lines: ") |
17493 | 385 (princ (or (mail-header-lines header) 0) (current-buffer)) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
386 (insert "\n\n")) |
17493 | 387 |
388 (defun nnheader-insert-article-line (article) | |
389 (goto-char (point-min)) | |
390 (insert "220 ") | |
391 (princ article (current-buffer)) | |
392 (insert " Article retrieved.\n") | |
393 (search-forward "\n\n" nil 'move) | |
394 (delete-region (point) (point-max)) | |
395 (forward-char -1) | |
396 (insert ".")) | |
397 | |
398 (defun nnheader-nov-delete-outside-range (beg end) | |
399 "Delete all NOV lines that lie outside the BEG to END range." | |
400 ;; First we find the first wanted line. | |
401 (nnheader-find-nov-line beg) | |
402 (delete-region (point-min) (point)) | |
403 ;; Then we find the last wanted line. | |
404 (when (nnheader-find-nov-line end) | |
405 (forward-line 1)) | |
406 (delete-region (point) (point-max))) | |
407 | |
408 (defun nnheader-find-nov-line (article) | |
409 "Put point at the NOV line that start with ARTICLE. | |
410 If ARTICLE doesn't exist, put point where that line | |
411 would have been. The function will return non-nil if | |
412 the line could be found." | |
413 ;; This function basically does a binary search. | |
414 (let ((max (point-max)) | |
415 (min (goto-char (point-min))) | |
416 (cur (current-buffer)) | |
417 (prev (point-min)) | |
418 num found) | |
419 (while (not found) | |
420 (goto-char (/ (+ max min) 2)) | |
421 (beginning-of-line) | |
422 (if (or (= (point) prev) | |
423 (eobp)) | |
424 (setq found t) | |
425 (setq prev (point)) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
426 (while (and (not (numberp (setq num (read cur)))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
427 (not (eobp))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
428 (gnus-delete-line)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
429 (cond ((> num article) |
17493 | 430 (setq max (point))) |
431 ((< num article) | |
432 (setq min (point))) | |
433 (t | |
434 (setq found 'yes))))) | |
435 ;; We may be at the first line. | |
436 (when (and (not num) | |
437 (not (eobp))) | |
438 (setq num (read cur))) | |
439 ;; Now we may have found the article we're looking for, or we | |
440 ;; may be somewhere near it. | |
441 (when (and (not (eq found 'yes)) | |
442 (not (eq num article))) | |
443 (setq found (point)) | |
444 (while (and (< (point) max) | |
445 (or (not (numberp num)) | |
446 (< num article))) | |
447 (forward-line 1) | |
448 (setq found (point)) | |
449 (or (eobp) | |
450 (= (setq num (read cur)) article))) | |
451 (unless (eq num article) | |
452 (goto-char found))) | |
453 (beginning-of-line) | |
454 (eq num article))) | |
455 | |
456 ;; Various cruft the backends and Gnus need to communicate. | |
457 | |
458 (defvar nntp-server-buffer nil) | |
459 (defvar gnus-verbose-backends 7 | |
460 "*A number that says how talkative the Gnus backends should be.") | |
461 (defvar gnus-nov-is-evil nil | |
462 "If non-nil, Gnus backends will never output headers in the NOV format.") | |
463 (defvar news-reply-yank-from nil) | |
464 (defvar news-reply-yank-message-id nil) | |
465 | |
466 (defvar nnheader-callback-function nil) | |
467 | |
468 (defun nnheader-init-server-buffer () | |
469 "Initialize the Gnus-backend communication buffer." | |
470 (save-excursion | |
471 (unless (gnus-buffer-live-p nntp-server-buffer) | |
472 (setq nntp-server-buffer (get-buffer-create " *nntpd*"))) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
473 (mm-enable-multibyte) |
17493 | 474 (set-buffer nntp-server-buffer) |
475 (erase-buffer) | |
476 (kill-all-local-variables) | |
477 (setq case-fold-search t) ;Should ignore case. | |
478 t)) | |
479 | |
480 ;;; Various functions the backends use. | |
481 | |
482 (defun nnheader-file-error (file) | |
483 "Return a string that says what is wrong with FILE." | |
484 (format | |
485 (cond | |
486 ((not (file-exists-p file)) | |
487 "%s does not exist") | |
488 ((file-directory-p file) | |
489 "%s is a directory") | |
490 ((not (file-readable-p file)) | |
491 "%s is not readable")) | |
492 file)) | |
493 | |
494 (defun nnheader-insert-head (file) | |
495 "Insert the head of the article." | |
496 (when (file-exists-p file) | |
497 (if (eq nnheader-max-head-length t) | |
498 ;; Just read the entire file. | |
499 (nnheader-insert-file-contents file) | |
500 ;; Read 1K blocks until we find a separator. | |
501 (let ((beg 0) | |
502 format-alist) | |
503 (while (and (eq nnheader-head-chop-length | |
504 (nth 1 (nnheader-insert-file-contents | |
505 file nil beg | |
506 (incf beg nnheader-head-chop-length)))) | |
507 (prog1 (not (search-forward "\n\n" nil t)) | |
508 (goto-char (point-max))) | |
509 (or (null nnheader-max-head-length) | |
510 (< beg nnheader-max-head-length)))))) | |
511 t)) | |
512 | |
513 (defun nnheader-article-p () | |
514 "Say whether the current buffer looks like an article." | |
515 (goto-char (point-min)) | |
516 (if (not (search-forward "\n\n" nil t)) | |
517 nil | |
518 (narrow-to-region (point-min) (1- (point))) | |
519 (goto-char (point-min)) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
520 (while (looking-at "[a-zA-Z][^ \t]+:.*\n\\([ \t].*\n\\)*\\|From .*\n") |
17493 | 521 (goto-char (match-end 0))) |
522 (prog1 | |
523 (eobp) | |
524 (widen)))) | |
525 | |
526 (defun nnheader-insert-references (references message-id) | |
527 "Insert a References header based on REFERENCES and MESSAGE-ID." | |
528 (if (and (not references) (not message-id)) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
529 ;; This is invalid, but not all articles have Message-IDs. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
530 () |
17493 | 531 (mail-position-on-field "References") |
532 (let ((begin (save-excursion (beginning-of-line) (point))) | |
533 (fill-column 78) | |
534 (fill-prefix "\t")) | |
535 (when references | |
536 (insert references)) | |
537 (when (and references message-id) | |
538 (insert " ")) | |
539 (when message-id | |
540 (insert message-id)) | |
541 ;; Fold long References lines to conform to RFC1036 (sort of). | |
542 ;; The region must end with a newline to fill the region | |
543 ;; without inserting extra newline. | |
544 (fill-region-as-paragraph begin (1+ (point)))))) | |
545 | |
546 (defun nnheader-replace-header (header new-value) | |
547 "Remove HEADER and insert the NEW-VALUE." | |
548 (save-excursion | |
549 (save-restriction | |
550 (nnheader-narrow-to-headers) | |
551 (prog1 | |
552 (message-remove-header header) | |
553 (goto-char (point-max)) | |
554 (insert header ": " new-value "\n"))))) | |
555 | |
556 (defun nnheader-narrow-to-headers () | |
557 "Narrow to the head of an article." | |
558 (widen) | |
559 (narrow-to-region | |
560 (goto-char (point-min)) | |
561 (if (search-forward "\n\n" nil t) | |
562 (1- (point)) | |
563 (point-max))) | |
564 (goto-char (point-min))) | |
565 | |
566 (defun nnheader-set-temp-buffer (name &optional noerase) | |
567 "Set-buffer to an empty (possibly new) buffer called NAME with undo disabled." | |
568 (set-buffer (get-buffer-create name)) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
569 (buffer-disable-undo) |
17493 | 570 (unless noerase |
571 (erase-buffer)) | |
572 (current-buffer)) | |
573 | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
574 (eval-when-compile (defvar jka-compr-compression-info-list)) |
17493 | 575 (defvar nnheader-numerical-files |
576 (if (boundp 'jka-compr-compression-info-list) | |
577 (concat "\\([0-9]+\\)\\(" | |
578 (mapconcat (lambda (i) (aref i 0)) | |
579 jka-compr-compression-info-list "\\|") | |
580 "\\)?") | |
581 "[0-9]+$") | |
582 "Regexp that match numerical files.") | |
583 | |
584 (defvar nnheader-numerical-short-files (concat "^" nnheader-numerical-files) | |
585 "Regexp that matches numerical file names.") | |
586 | |
587 (defvar nnheader-numerical-full-files (concat "/" nnheader-numerical-files) | |
588 "Regexp that matches numerical full file paths.") | |
589 | |
590 (defsubst nnheader-file-to-number (file) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
591 "Take a FILE name and return the article number." |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
592 (if (string= nnheader-numerical-short-files "^[0-9]+$") |
17493 | 593 (string-to-int file) |
594 (string-match nnheader-numerical-short-files file) | |
595 (string-to-int (match-string 0 file)))) | |
596 | |
597 (defun nnheader-directory-files-safe (&rest args) | |
598 ;; It has been reported numerous times that `directory-files' | |
599 ;; fails with an alarming frequency on NFS mounted file systems. | |
600 ;; This function executes that function twice and returns | |
601 ;; the longest result. | |
602 (let ((first (apply 'directory-files args)) | |
603 (second (apply 'directory-files args))) | |
604 (if (> (length first) (length second)) | |
605 first | |
606 second))) | |
607 | |
608 (defun nnheader-directory-articles (dir) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
609 "Return a list of all article files in directory DIR." |
17493 | 610 (mapcar 'nnheader-file-to-number |
611 (nnheader-directory-files-safe | |
612 dir nil nnheader-numerical-short-files t))) | |
613 | |
614 (defun nnheader-article-to-file-alist (dir) | |
615 "Return an alist of article/file pairs in DIR." | |
616 (mapcar (lambda (file) (cons (nnheader-file-to-number file) file)) | |
617 (nnheader-directory-files-safe | |
618 dir nil nnheader-numerical-short-files t))) | |
619 | |
620 (defun nnheader-fold-continuation-lines () | |
621 "Fold continuation lines in the current buffer." | |
622 (nnheader-replace-regexp "\\(\r?\n[ \t]+\\)+" " ")) | |
623 | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
624 (defun nnheader-translate-file-chars (file &optional full) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
625 "Translate FILE into something that can be a file name. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
626 If FULL, translate everything." |
17493 | 627 (if (null nnheader-file-name-translation-alist) |
628 ;; No translation is necessary. | |
629 file | |
630 (let* ((i 0) | |
631 trans leaf path len) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
632 (if full |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
633 ;; Do complete translation. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
634 (setq leaf (copy-sequence file) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
635 path "" |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
636 i (if (and (< 1 (length leaf)) (eq ?: (aref leaf 1))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
637 2 0)) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
638 ;; We translate -- but only the file name. We leave the directory |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
639 ;; alone. |
32972
a51631f90704
2000-09-24 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31785
diff
changeset
|
640 (if (and (featurep 'xemacs) |
a51631f90704
2000-09-24 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31785
diff
changeset
|
641 (memq system-type '(win32 w32 mswindows windows-nt))) |
a51631f90704
2000-09-24 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31785
diff
changeset
|
642 ;; This is needed on NT and stuff, because |
a51631f90704
2000-09-24 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31785
diff
changeset
|
643 ;; file-name-nondirectory is not enough to split |
a51631f90704
2000-09-24 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31785
diff
changeset
|
644 ;; file names, containing ':', e.g. |
a51631f90704
2000-09-24 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31785
diff
changeset
|
645 ;; "d:\\Work\\News\\nntp+news.fido7.ru:fido7.ru.gnu.SCORE" |
a51631f90704
2000-09-24 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31785
diff
changeset
|
646 ;; |
a51631f90704
2000-09-24 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31785
diff
changeset
|
647 ;; we are trying to correctly split such names: |
a51631f90704
2000-09-24 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31785
diff
changeset
|
648 ;; "d:file.name" -> "a:" "file.name" |
a51631f90704
2000-09-24 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31785
diff
changeset
|
649 ;; "aaa:bbb.ccc" -> "" "aaa:bbb.ccc" |
a51631f90704
2000-09-24 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31785
diff
changeset
|
650 ;; "d:aaa\\bbb:ccc" -> "d:aaa\\" "bbb:ccc" |
a51631f90704
2000-09-24 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31785
diff
changeset
|
651 ;; etc. |
a51631f90704
2000-09-24 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31785
diff
changeset
|
652 ;; to translate then only the file name part. |
a51631f90704
2000-09-24 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31785
diff
changeset
|
653 (progn |
a51631f90704
2000-09-24 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31785
diff
changeset
|
654 (setq leaf file |
a51631f90704
2000-09-24 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31785
diff
changeset
|
655 path "") |
a51631f90704
2000-09-24 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31785
diff
changeset
|
656 (if (string-match "\\(^\\w:\\|[/\\]\\)\\([^/\\]+\\)$" file) |
a51631f90704
2000-09-24 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31785
diff
changeset
|
657 (setq leaf (substring file (match-beginning 2)) |
a51631f90704
2000-09-24 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31785
diff
changeset
|
658 path (substring file 0 (match-beginning 2))))) |
a51631f90704
2000-09-24 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31785
diff
changeset
|
659 ;; Emacs DTRT, says andrewi. |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
660 (setq leaf (file-name-nondirectory file) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
661 path (file-name-directory file)))) |
17493 | 662 (setq len (length leaf)) |
663 (while (< i len) | |
664 (when (setq trans (cdr (assq (aref leaf i) | |
665 nnheader-file-name-translation-alist))) | |
666 (aset leaf i trans)) | |
667 (incf i)) | |
668 (concat path leaf)))) | |
669 | |
670 (defun nnheader-report (backend &rest args) | |
671 "Report an error from the BACKEND. | |
672 The first string in ARGS can be a format string." | |
673 (set (intern (format "%s-status-string" backend)) | |
674 (if (< (length args) 2) | |
675 (car args) | |
676 (apply 'format args))) | |
677 nil) | |
678 | |
679 (defun nnheader-get-report (backend) | |
680 "Get the most recent report from BACKEND." | |
681 (condition-case () | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
682 (nnheader-message 5 "%s" (symbol-value (intern (format "%s-status-string" |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
683 backend)))) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
684 (error (nnheader-message 5 "")))) |
17493 | 685 |
686 (defun nnheader-insert (format &rest args) | |
687 "Clear the communication buffer and insert FORMAT and ARGS into the buffer. | |
688 If FORMAT isn't a format string, it and all ARGS will be inserted | |
689 without formatting." | |
690 (save-excursion | |
691 (set-buffer nntp-server-buffer) | |
692 (erase-buffer) | |
693 (if (string-match "%" format) | |
694 (insert (apply 'format format args)) | |
695 (apply 'insert format args)) | |
696 t)) | |
697 | |
33300
cae923af5a5d
Wrap subst-char-in-string def in eval-and-compile.
Dave Love <fx@gnu.org>
parents:
32972
diff
changeset
|
698 (eval-and-compile |
cae923af5a5d
Wrap subst-char-in-string def in eval-and-compile.
Dave Love <fx@gnu.org>
parents:
32972
diff
changeset
|
699 (if (fboundp 'subst-char-in-string) |
cae923af5a5d
Wrap subst-char-in-string def in eval-and-compile.
Dave Love <fx@gnu.org>
parents:
32972
diff
changeset
|
700 (defsubst nnheader-replace-chars-in-string (string from to) |
cae923af5a5d
Wrap subst-char-in-string def in eval-and-compile.
Dave Love <fx@gnu.org>
parents:
32972
diff
changeset
|
701 (subst-char-in-string from to string)) |
cae923af5a5d
Wrap subst-char-in-string def in eval-and-compile.
Dave Love <fx@gnu.org>
parents:
32972
diff
changeset
|
702 (defun nnheader-replace-chars-in-string (string from to) |
cae923af5a5d
Wrap subst-char-in-string def in eval-and-compile.
Dave Love <fx@gnu.org>
parents:
32972
diff
changeset
|
703 "Replace characters in STRING from FROM to TO." |
cae923af5a5d
Wrap subst-char-in-string def in eval-and-compile.
Dave Love <fx@gnu.org>
parents:
32972
diff
changeset
|
704 (let ((string (substring string 0)) ;Copy string. |
cae923af5a5d
Wrap subst-char-in-string def in eval-and-compile.
Dave Love <fx@gnu.org>
parents:
32972
diff
changeset
|
705 (len (length string)) |
cae923af5a5d
Wrap subst-char-in-string def in eval-and-compile.
Dave Love <fx@gnu.org>
parents:
32972
diff
changeset
|
706 (idx 0)) |
cae923af5a5d
Wrap subst-char-in-string def in eval-and-compile.
Dave Love <fx@gnu.org>
parents:
32972
diff
changeset
|
707 ;; Replace all occurrences of FROM with TO. |
cae923af5a5d
Wrap subst-char-in-string def in eval-and-compile.
Dave Love <fx@gnu.org>
parents:
32972
diff
changeset
|
708 (while (< idx len) |
cae923af5a5d
Wrap subst-char-in-string def in eval-and-compile.
Dave Love <fx@gnu.org>
parents:
32972
diff
changeset
|
709 (when (= (aref string idx) from) |
cae923af5a5d
Wrap subst-char-in-string def in eval-and-compile.
Dave Love <fx@gnu.org>
parents:
32972
diff
changeset
|
710 (aset string idx to)) |
cae923af5a5d
Wrap subst-char-in-string def in eval-and-compile.
Dave Love <fx@gnu.org>
parents:
32972
diff
changeset
|
711 (setq idx (1+ idx))) |
cae923af5a5d
Wrap subst-char-in-string def in eval-and-compile.
Dave Love <fx@gnu.org>
parents:
32972
diff
changeset
|
712 string)))) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
713 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
714 (defun nnheader-replace-duplicate-chars-in-string (string from to) |
17493 | 715 "Replace characters in STRING from FROM to TO." |
716 (let ((string (substring string 0)) ;Copy string. | |
717 (len (length string)) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
718 (idx 0) prev i) |
17493 | 719 ;; Replace all occurrences of FROM with TO. |
720 (while (< idx len) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
721 (setq i (aref string idx)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
722 (when (and (eq prev from) (= i from)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
723 (aset string (1- idx) to) |
17493 | 724 (aset string idx to)) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
725 (setq prev i) |
17493 | 726 (setq idx (1+ idx))) |
727 string)) | |
728 | |
729 (defun nnheader-file-to-group (file &optional top) | |
730 "Return a group name based on FILE and TOP." | |
731 (nnheader-replace-chars-in-string | |
732 (if (not top) | |
733 file | |
734 (condition-case () | |
735 (substring (expand-file-name file) | |
736 (length | |
737 (expand-file-name | |
738 (file-name-as-directory top)))) | |
739 (error ""))) | |
740 ?/ ?.)) | |
741 | |
742 (defun nnheader-message (level &rest args) | |
743 "Message if the Gnus backends are talkative." | |
744 (if (or (not (numberp gnus-verbose-backends)) | |
745 (<= level gnus-verbose-backends)) | |
746 (apply 'message args) | |
747 (apply 'format args))) | |
748 | |
749 (defun nnheader-be-verbose (level) | |
750 "Return whether the backends should be verbose on LEVEL." | |
751 (or (not (numberp gnus-verbose-backends)) | |
752 (<= level gnus-verbose-backends))) | |
753 | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
754 (defvar nnheader-pathname-coding-system 'binary |
19596
33877efba398
(nnheader-pathname-coding-system): New variable.
Kenichi Handa <handa@m17n.org>
parents:
19493
diff
changeset
|
755 "*Coding system for pathname.") |
33877efba398
(nnheader-pathname-coding-system): New variable.
Kenichi Handa <handa@m17n.org>
parents:
19493
diff
changeset
|
756 |
17493 | 757 (defun nnheader-group-pathname (group dir &optional file) |
758 "Make pathname for GROUP." | |
759 (concat | |
760 (let ((dir (file-name-as-directory (expand-file-name dir)))) | |
761 ;; If this directory exists, we use it directly. | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
762 (file-name-as-directory |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
763 (if (file-directory-p (concat dir group)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
764 (expand-file-name group dir) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
765 ;; If not, we translate dots into slashes. |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
766 (expand-file-name (mm-encode-coding-string |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
767 (nnheader-replace-chars-in-string group ?. ?/) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
768 nnheader-pathname-coding-system) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
769 dir)))) |
17493 | 770 (cond ((null file) "") |
771 ((numberp file) (int-to-string file)) | |
772 (t file)))) | |
773 | |
774 (defun nnheader-functionp (form) | |
775 "Return non-nil if FORM is funcallable." | |
776 (or (and (symbolp form) (fboundp form)) | |
777 (and (listp form) (eq (car form) 'lambda)))) | |
778 | |
779 (defun nnheader-concat (dir &rest files) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
780 "Concat DIR as directory to FILES." |
17493 | 781 (apply 'concat (file-name-as-directory dir) files)) |
782 | |
783 (defun nnheader-ms-strip-cr () | |
784 "Strip ^M from the end of all lines." | |
785 (save-excursion | |
786 (goto-char (point-min)) | |
787 (while (re-search-forward "\r$" nil t) | |
788 (delete-backward-char 1)))) | |
789 | |
790 (defun nnheader-file-size (file) | |
791 "Return the file size of FILE or 0." | |
792 (or (nth 7 (file-attributes file)) 0)) | |
793 | |
794 (defun nnheader-find-etc-directory (package &optional file) | |
795 "Go through the path and find the \".../etc/PACKAGE\" directory. | |
796 If FILE, find the \".../etc/PACKAGE\" file instead." | |
797 (let ((path load-path) | |
798 dir result) | |
799 ;; We try to find the dir by looking at the load path, | |
800 ;; stripping away the last component and adding "etc/". | |
801 (while path | |
802 (if (and (car path) | |
803 (file-exists-p | |
804 (setq dir (concat | |
805 (file-name-directory | |
806 (directory-file-name (car path))) | |
807 "etc/" package | |
808 (if file "" "/")))) | |
809 (or file (file-directory-p dir))) | |
810 (setq result dir | |
811 path nil) | |
812 (setq path (cdr path)))) | |
813 result)) | |
814 | |
33301
c1c373a70748
Put some defvars in eval-when-compile.
Dave Love <fx@gnu.org>
parents:
33300
diff
changeset
|
815 (eval-when-compile |
c1c373a70748
Put some defvars in eval-when-compile.
Dave Love <fx@gnu.org>
parents:
33300
diff
changeset
|
816 (defvar ange-ftp-path-format) |
c1c373a70748
Put some defvars in eval-when-compile.
Dave Love <fx@gnu.org>
parents:
33300
diff
changeset
|
817 (defvar efs-path-regexp)) |
17493 | 818 (defun nnheader-re-read-dir (path) |
819 "Re-read directory PATH if PATH is on a remote system." | |
820 (if (and (fboundp 'efs-re-read-dir) (boundp 'efs-path-regexp)) | |
821 (when (string-match efs-path-regexp path) | |
822 (efs-re-read-dir path)) | |
823 (when (and (fboundp 'ange-ftp-re-read-dir) (boundp 'ange-ftp-path-format)) | |
824 (when (string-match (car ange-ftp-path-format) path) | |
825 (ange-ftp-re-read-dir path))))) | |
826 | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
827 (defvar nnheader-file-coding-system 'raw-text |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
828 "Coding system used in file backends of Gnus.") |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
829 |
17493 | 830 (defun nnheader-insert-file-contents (filename &optional visit beg end replace) |
831 "Like `insert-file-contents', q.v., but only reads in the file. | |
832 A buffer may be modified in several ways after reading into the buffer due | |
833 to advanced Emacs features, such as file-name-handlers, format decoding, | |
834 find-file-hooks, etc. | |
835 This function ensures that none of these modifications will take place." | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
836 (let ((coding-system-for-read nnheader-file-coding-system)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
837 (mm-insert-file-contents filename visit beg end replace))) |
17493 | 838 |
839 (defun nnheader-find-file-noselect (&rest args) | |
840 (let ((format-alist nil) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
841 (auto-mode-alist (mm-auto-mode-alist)) |
17493 | 842 (default-major-mode 'fundamental-mode) |
843 (enable-local-variables nil) | |
19596
33877efba398
(nnheader-pathname-coding-system): New variable.
Kenichi Handa <handa@m17n.org>
parents:
19493
diff
changeset
|
844 (after-insert-file-functions nil) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
845 (enable-local-eval nil) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
846 (find-file-hooks nil) |
19596
33877efba398
(nnheader-pathname-coding-system): New variable.
Kenichi Handa <handa@m17n.org>
parents:
19493
diff
changeset
|
847 (coding-system-for-read nnheader-file-coding-system)) |
17493 | 848 (apply 'find-file-noselect args))) |
849 | |
850 (defun nnheader-directory-regular-files (dir) | |
851 "Return a list of all regular files in DIR." | |
852 (let ((files (directory-files dir t)) | |
853 out) | |
854 (while files | |
855 (when (file-regular-p (car files)) | |
856 (push (car files) out)) | |
857 (pop files)) | |
858 (nreverse out))) | |
859 | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
860 (defun nnheader-directory-files (&rest args) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
861 "Same as `directory-files', but prune \".\" and \"..\"." |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
862 (let ((files (apply 'directory-files args)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
863 out) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
864 (while files |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
865 (unless (member (file-name-nondirectory (car files)) '("." "..")) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
866 (push (car files) out)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
867 (pop files)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
868 (nreverse out))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
869 |
17493 | 870 (defmacro nnheader-skeleton-replace (from &optional to regexp) |
871 `(let ((new (generate-new-buffer " *nnheader replace*")) | |
872 (cur (current-buffer)) | |
873 (start (point-min))) | |
874 (set-buffer cur) | |
875 (goto-char (point-min)) | |
876 (while (,(if regexp 're-search-forward 'search-forward) | |
877 ,from nil t) | |
878 (insert-buffer-substring | |
879 cur start (prog1 (match-beginning 0) (set-buffer new))) | |
880 (goto-char (point-max)) | |
881 ,(when to `(insert ,to)) | |
882 (set-buffer cur) | |
883 (setq start (point))) | |
884 (insert-buffer-substring | |
885 cur start (prog1 (point-max) (set-buffer new))) | |
886 (copy-to-buffer cur (point-min) (point-max)) | |
887 (kill-buffer (current-buffer)) | |
888 (set-buffer cur))) | |
889 | |
890 (defun nnheader-replace-string (from to) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
891 "Do a fast replacement of FROM to TO from point to `point-max'." |
17493 | 892 (nnheader-skeleton-replace from to)) |
893 | |
894 (defun nnheader-replace-regexp (from to) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
895 "Do a fast regexp replacement of FROM to TO from point to `point-max'." |
17493 | 896 (nnheader-skeleton-replace from to t)) |
897 | |
898 (defun nnheader-strip-cr () | |
899 "Strip all \r's from the current buffer." | |
900 (nnheader-skeleton-replace "\r")) | |
901 | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
902 (defalias 'nnheader-run-at-time 'run-at-time) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
903 (defalias 'nnheader-cancel-timer 'cancel-timer) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
904 (defalias 'nnheader-cancel-function-timers 'cancel-function-timers) |
17493 | 905 |
32972
a51631f90704
2000-09-24 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31785
diff
changeset
|
906 (when (featurep 'xemacs) |
17493 | 907 (require 'nnheaderxm)) |
908 | |
909 (run-hooks 'nnheader-load-hook) | |
910 | |
911 (provide 'nnheader) | |
912 | |
913 ;;; nnheader.el ends here |