Mercurial > emacs
annotate lisp/gnus/nnheader.el @ 77447:9ce8bfb2f686
* display.texi (Highlight Interactively): Correct description of
hi-lock-file-patterns-policy.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Mon, 23 Apr 2007 14:39:16 +0000 |
parents | e3694f1cb928 |
children | 24202b793a08 95d0cdf160ea |
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 |
64754
fafd692d1e40
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64085
diff
changeset
|
3 ;; Copyright (C) 1987, 1988, 1989, 1990, 1993, 1994, |
fafd692d1e40
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64085
diff
changeset
|
4 ;; 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2003, |
75347 | 5 ;; 2004, 2005, 2006, 2007 Free Software Foundation, Inc. |
17493 | 6 |
7 ;; Author: Masanobu UMEDA <umerin@flab.flab.fujitsu.junet> | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
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 | |
64085 | 25 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
26 ;; Boston, MA 02110-1301, USA. | |
17493 | 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)) |
35486
9be4b357b53a
(toplevel): Don't require `gnus-util' at
Gerd Moellmann <gerd@gnu.org>
parents:
35463
diff
changeset
|
33 |
65282
fccd842711b5
(nnmail-extra-headers): Add defvar.
Juanma Barranquero <lekktu@gmail.com>
parents:
64754
diff
changeset
|
34 (defvar nnmail-extra-headers) |
fccd842711b5
(nnmail-extra-headers): Add defvar.
Juanma Barranquero <lekktu@gmail.com>
parents:
64754
diff
changeset
|
35 |
35486
9be4b357b53a
(toplevel): Don't require `gnus-util' at
Gerd Moellmann <gerd@gnu.org>
parents:
35463
diff
changeset
|
36 ;; Requiring `gnus-util' at compile time creates a circular |
9be4b357b53a
(toplevel): Don't require `gnus-util' at
Gerd Moellmann <gerd@gnu.org>
parents:
35463
diff
changeset
|
37 ;; dependency between nnheader.el and gnus-util.el. |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
38 ;;(eval-when-compile (require 'gnus-util)) |
19493
8d840c4548c0
Require cl at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
17493
diff
changeset
|
39 |
17493 | 40 (require 'mail-utils) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
41 (require 'mm-util) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
42 (require 'gnus-util) |
33300
cae923af5a5d
Wrap subst-char-in-string def in eval-and-compile.
Dave Love <fx@gnu.org>
parents:
32972
diff
changeset
|
43 (eval-and-compile |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
44 (autoload 'gnus-sorted-intersection "gnus-range") |
33300
cae923af5a5d
Wrap subst-char-in-string def in eval-and-compile.
Dave Love <fx@gnu.org>
parents:
32972
diff
changeset
|
45 (autoload 'gnus-intersection "gnus-range") |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
46 (autoload 'gnus-sorted-complement "gnus-range") |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
47 (autoload 'gnus-sorted-difference "gnus-range")) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
48 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
49 (defcustom gnus-verbose-backends 7 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
50 "Integer that says how verbose the Gnus backends should be. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
51 The higher the number, the more messages the Gnus backends will flash |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
52 to say what it's doing. At zero, the Gnus backends will be totally |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
53 mute; at five, they will display most important messages; and at ten, |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
54 they will keep on jabbering all the time." |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
55 :group 'gnus-start |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
56 :type 'integer) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
57 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
58 (defcustom gnus-nov-is-evil nil |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
59 "If non-nil, Gnus backends will never output headers in the NOV format." |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
60 :group 'gnus-server |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
61 :type 'boolean) |
17493 | 62 |
57243
c5e16264557d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-575
Miles Bader <miles@gnu.org>
parents:
56927
diff
changeset
|
63 (defvar nnheader-max-head-length 8192 |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
64 "*Max length of the head of articles. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
65 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
66 Value is an integer, nil, or t. nil means read in chunks of a file |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
67 indefinitely until a complete head is found\; t means always read the |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
68 entire file immediately, disregarding `nnheader-head-chop-length'. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
69 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
70 Integer values will in effect be rounded up to the nearest multiple of |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
71 `nnheader-head-chop-length'.") |
17493 | 72 |
73 (defvar nnheader-head-chop-length 2048 | |
74 "*Length of each read operation when trying to fetch HEAD headers.") | |
75 | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
76 (defvar nnheader-read-timeout |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
77 (if (string-match "windows-nt\\|os/2\\|emx\\|cygwin" |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
78 (symbol-name system-type)) |
57442
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
57243
diff
changeset
|
79 ;; http://thread.gmane.org/v9655t3pjo.fsf@marauder.physik.uni-ulm.de |
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
57243
diff
changeset
|
80 ;; |
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
57243
diff
changeset
|
81 ;; IIRC, values lower than 1.0 didn't/don't work on Windows/DOS. |
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
57243
diff
changeset
|
82 ;; |
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
57243
diff
changeset
|
83 ;; There should probably be a runtime test to determine the timing |
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
57243
diff
changeset
|
84 ;; resolution, or a primitive to report it. I don't know off-hand |
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
57243
diff
changeset
|
85 ;; what's possible. Perhaps better, maybe the Windows/DOS primitive |
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
57243
diff
changeset
|
86 ;; could round up non-zero timeouts to a minimum of 1.0? |
2d9a1d1ac73d
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-610
Miles Bader <miles@gnu.org>
parents:
57243
diff
changeset
|
87 1.0 |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
88 0.1) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
89 "How long nntp should wait between checking for the end of output. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
90 Shorter values mean quicker response, but are more CPU intensive.") |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
91 |
49549
99be3a1e2589
Cygwin support patch.
Juanma Barranquero <lekktu@gmail.com>
parents:
49274
diff
changeset
|
92 (defvar nnheader-file-name-translation-alist |
45956
963ff40e6512
* nnheader.el (nnheader-file-name-translation-alist): Set the
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
38284
diff
changeset
|
93 (let ((case-fold-search t)) |
963ff40e6512
* nnheader.el (nnheader-file-name-translation-alist): Set the
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
38284
diff
changeset
|
94 (cond |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
95 ((string-match "windows-nt\\|os/2\\|emx\\|cygwin" |
45956
963ff40e6512
* nnheader.el (nnheader-file-name-translation-alist): Set the
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
38284
diff
changeset
|
96 (symbol-name system-type)) |
963ff40e6512
* nnheader.el (nnheader-file-name-translation-alist): Set the
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
38284
diff
changeset
|
97 (append (mapcar (lambda (c) (cons c ?_)) |
963ff40e6512
* nnheader.el (nnheader-file-name-translation-alist): Set the
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
38284
diff
changeset
|
98 '(?: ?* ?\" ?< ?> ??)) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
99 (if (string-match "windows-nt\\|cygwin" |
45956
963ff40e6512
* nnheader.el (nnheader-file-name-translation-alist): Set the
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
38284
diff
changeset
|
100 (symbol-name system-type)) |
963ff40e6512
* nnheader.el (nnheader-file-name-translation-alist): Set the
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
38284
diff
changeset
|
101 nil |
963ff40e6512
* nnheader.el (nnheader-file-name-translation-alist): Set the
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
38284
diff
changeset
|
102 '((?+ . ?-))))) |
963ff40e6512
* nnheader.el (nnheader-file-name-translation-alist): Set the
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
38284
diff
changeset
|
103 (t nil))) |
17493 | 104 "*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
|
105 For instance, if \":\" is invalid as a file character in file names |
17493 | 106 on your system, you could say something like: |
107 | |
108 \(setq nnheader-file-name-translation-alist '((?: . ?_)))") | |
109 | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
110 (defvar nnheader-directory-separator-character |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
111 (string-to-char (substring (file-name-as-directory ".") -1)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
112 "*A character used to a directory separator.") |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
113 |
17493 | 114 (eval-and-compile |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
115 (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
|
116 (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
|
117 (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
|
118 (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
|
119 (autoload 'gnus-buffer-live-p "gnus-util")) |
17493 | 120 |
121 ;;; Header access macros. | |
122 | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
123 ;; 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
|
124 ;; 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
|
125 ;; 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
|
126 ;; 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
|
127 ;; |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
128 ;; 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
|
129 ;; [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
|
130 ;; |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
131 ;; (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
|
132 ;; 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
|
133 |
17493 | 134 (defmacro mail-header-number (header) |
135 "Return article number in HEADER." | |
136 `(aref ,header 0)) | |
137 | |
138 (defmacro mail-header-set-number (header number) | |
139 "Set article number of HEADER to NUMBER." | |
140 `(aset ,header 0 ,number)) | |
141 | |
142 (defmacro mail-header-subject (header) | |
143 "Return subject string in HEADER." | |
144 `(aref ,header 1)) | |
145 | |
146 (defmacro mail-header-set-subject (header subject) | |
147 "Set article subject of HEADER to SUBJECT." | |
148 `(aset ,header 1 ,subject)) | |
149 | |
150 (defmacro mail-header-from (header) | |
151 "Return author string in HEADER." | |
152 `(aref ,header 2)) | |
153 | |
154 (defmacro mail-header-set-from (header from) | |
155 "Set article author of HEADER to FROM." | |
156 `(aset ,header 2 ,from)) | |
157 | |
158 (defmacro mail-header-date (header) | |
159 "Return date in HEADER." | |
160 `(aref ,header 3)) | |
161 | |
162 (defmacro mail-header-set-date (header date) | |
163 "Set article date of HEADER to DATE." | |
164 `(aset ,header 3 ,date)) | |
165 | |
166 (defalias 'mail-header-message-id 'mail-header-id) | |
167 (defmacro mail-header-id (header) | |
168 "Return Id in HEADER." | |
169 `(aref ,header 4)) | |
170 | |
171 (defalias 'mail-header-set-message-id 'mail-header-set-id) | |
172 (defmacro mail-header-set-id (header id) | |
173 "Set article Id of HEADER to ID." | |
174 `(aset ,header 4 ,id)) | |
175 | |
176 (defmacro mail-header-references (header) | |
177 "Return references in HEADER." | |
178 `(aref ,header 5)) | |
179 | |
180 (defmacro mail-header-set-references (header ref) | |
181 "Set article references of HEADER to REF." | |
182 `(aset ,header 5 ,ref)) | |
183 | |
184 (defmacro mail-header-chars (header) | |
185 "Return number of chars of article in HEADER." | |
186 `(aref ,header 6)) | |
187 | |
188 (defmacro mail-header-set-chars (header chars) | |
189 "Set number of chars in article of HEADER to CHARS." | |
190 `(aset ,header 6 ,chars)) | |
191 | |
192 (defmacro mail-header-lines (header) | |
193 "Return lines in HEADER." | |
194 `(aref ,header 7)) | |
195 | |
196 (defmacro mail-header-set-lines (header lines) | |
197 "Set article lines of HEADER to LINES." | |
198 `(aset ,header 7 ,lines)) | |
199 | |
200 (defmacro mail-header-xref (header) | |
201 "Return xref string in HEADER." | |
202 `(aref ,header 8)) | |
203 | |
204 (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
|
205 "Set article XREF of HEADER to xref." |
17493 | 206 `(aset ,header 8 ,xref)) |
207 | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
208 (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
|
209 "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
|
210 `(aref ,header 9)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
211 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
212 (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
|
213 "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
|
214 `(aset ,header 9 ',extra)) |
17493 | 215 |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
216 (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
|
217 "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
|
218 (make-vector 10 init)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
219 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
220 (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
|
221 references chars lines xref |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
222 extra) |
17493 | 223 "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
|
224 (vector number subject from date id references chars lines xref extra)) |
17493 | 225 |
226 ;; fake message-ids: generation and detection | |
227 | |
228 (defvar nnheader-fake-message-id 1) | |
229 | |
230 (defsubst nnheader-generate-fake-message-id () | |
231 (concat "fake+none+" (int-to-string (incf nnheader-fake-message-id)))) | |
232 | |
233 (defsubst nnheader-fake-message-id-p (id) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
234 (save-match-data ; regular message-id's are <.*> |
17493 | 235 (string-match "\\`fake\\+none\\+[0-9]+\\'" id))) |
236 | |
237 ;; Parsing headers and NOV lines. | |
238 | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
239 (defsubst nnheader-remove-cr-followed-by-lf () |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
240 (goto-char (point-max)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
241 (while (search-backward "\r\n" nil t) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
242 (delete-char 1))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
243 |
17493 | 244 (defsubst nnheader-header-value () |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
245 (skip-chars-forward " \t") |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
246 (buffer-substring (point) (gnus-point-at-eol))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
247 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
248 (defun nnheader-parse-naked-head (&optional number) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
249 ;; This function unfolds continuation lines in this buffer |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
250 ;; destructively. When this side effect is unwanted, use |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
251 ;; `nnheader-parse-head' instead of this function. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
252 (let ((case-fold-search t) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
253 (buffer-read-only nil) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
254 (cur (current-buffer)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
255 (p (point-min)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
256 in-reply-to lines ref) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
257 (nnheader-remove-cr-followed-by-lf) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
258 (ietf-drums-unfold-fws) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
259 (subst-char-in-region (point-min) (point-max) ?\t ? ) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
260 (goto-char p) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
261 (insert "\n") |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
262 (prog1 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
263 ;; This implementation of this function, with nine |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
264 ;; search-forwards instead of the one re-search-forward and a |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
265 ;; case (which basically was the old function) is actually |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
266 ;; about twice as fast, even though it looks messier. You |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
267 ;; can't have everything, I guess. Speed and elegance don't |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
268 ;; always go hand in hand. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
269 (vector |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
270 ;; Number. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
271 (or number 0) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
272 ;; Subject. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
273 (progn |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
274 (goto-char p) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
275 (if (search-forward "\nsubject:" nil t) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
276 (nnheader-header-value) "(none)")) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
277 ;; From. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
278 (progn |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
279 (goto-char p) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
280 (if (search-forward "\nfrom:" nil t) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
281 (nnheader-header-value) "(nobody)")) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
282 ;; Date. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
283 (progn |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
284 (goto-char p) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
285 (if (search-forward "\ndate:" nil t) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
286 (nnheader-header-value) "")) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
287 ;; Message-ID. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
288 (progn |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
289 (goto-char p) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
290 (if (search-forward "\nmessage-id:" nil t) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
291 (buffer-substring |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
292 (1- (or (search-forward "<" (gnus-point-at-eol) t) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
293 (point))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
294 (or (search-forward ">" (gnus-point-at-eol) t) (point))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
295 ;; If there was no message-id, we just fake one to make |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
296 ;; subsequent routines simpler. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
297 (nnheader-generate-fake-message-id))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
298 ;; References. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
299 (progn |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
300 (goto-char p) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
301 (if (search-forward "\nreferences:" nil t) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
302 (nnheader-header-value) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
303 ;; Get the references from the in-reply-to header if |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
304 ;; there were no references and the in-reply-to header |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
305 ;; looks promising. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
306 (if (and (search-forward "\nin-reply-to:" nil t) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
307 (setq in-reply-to (nnheader-header-value)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
308 (string-match "<[^\n>]+>" in-reply-to)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
309 (let (ref2) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
310 (setq ref (substring in-reply-to (match-beginning 0) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
311 (match-end 0))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
312 (while (string-match "<[^\n>]+>" |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
313 in-reply-to (match-end 0)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
314 (setq ref2 (substring in-reply-to (match-beginning 0) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
315 (match-end 0))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
316 (when (> (length ref2) (length ref)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
317 (setq ref ref2))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
318 ref) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
319 nil))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
320 ;; Chars. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
321 0 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
322 ;; Lines. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
323 (progn |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
324 (goto-char p) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
325 (if (search-forward "\nlines: " nil t) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
326 (if (numberp (setq lines (read cur))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
327 lines 0) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
328 0)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
329 ;; Xref. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
330 (progn |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
331 (goto-char p) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
332 (and (search-forward "\nxref:" nil t) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
333 (nnheader-header-value))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
334 ;; Extra. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
335 (when nnmail-extra-headers |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
336 (let ((extra nnmail-extra-headers) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
337 out) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
338 (while extra |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
339 (goto-char p) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
340 (when (search-forward |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
341 (concat "\n" (symbol-name (car extra)) ":") nil t) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
342 (push (cons (car extra) (nnheader-header-value)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
343 out)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
344 (pop extra)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
345 out))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
346 (goto-char p) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
347 (delete-char 1)))) |
17493 | 348 |
349 (defun nnheader-parse-head (&optional naked) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
350 (let ((cur (current-buffer)) num beg end) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
351 (when (if naked |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
352 (setq num 0 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
353 beg (point-min) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
354 end (point-max)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
355 (goto-char (point-min)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
356 ;; Search to the beginning of the next header. Error |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
357 ;; messages do not begin with 2 or 3. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
358 (when (re-search-forward "^[23][0-9]+ " nil t) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
359 (end-of-line) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
360 (setq num (read cur) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
361 beg (point) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
362 end (if (search-forward "\n.\n" nil t) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
363 (- (point) 2) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
364 (point))))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
365 (with-temp-buffer |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
366 (insert-buffer-substring cur beg end) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
367 (nnheader-parse-naked-head num))))) |
17493 | 368 |
369 (defmacro nnheader-nov-skip-field () | |
370 '(search-forward "\t" eol 'move)) | |
371 | |
372 (defmacro nnheader-nov-field () | |
373 '(buffer-substring (point) (if (nnheader-nov-skip-field) (1- (point)) eol))) | |
374 | |
375 (defmacro nnheader-nov-read-integer () | |
376 '(prog1 | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
377 (if (eq (char-after) ?\t) |
17493 | 378 0 |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
379 (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
|
380 (read (current-buffer)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
381 (error nil)))) |
17493 | 382 (if (numberp num) num 0))) |
383 (or (eobp) (forward-char 1)))) | |
384 | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
385 (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
|
386 '(let (out string) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
387 (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
|
388 (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
|
389 (when (string-match "^\\([^ :]+\\): " string) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
390 (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
|
391 (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
|
392 out))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
393 out)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
394 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
395 (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
|
396 '(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
|
397 (if (string-match "^<[^>]+>$" id) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
398 id |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
399 (nnheader-generate-fake-message-id)))) |
17493 | 400 |
401 (defun nnheader-parse-nov () | |
402 (let ((eol (gnus-point-at-eol))) | |
403 (vector | |
404 (nnheader-nov-read-integer) ; number | |
405 (nnheader-nov-field) ; subject | |
406 (nnheader-nov-field) ; from | |
407 (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
|
408 (nnheader-nov-read-message-id) ; id |
17493 | 409 (nnheader-nov-field) ; refs |
410 (nnheader-nov-read-integer) ; chars | |
411 (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
|
412 (if (eq (char-after) ?\n) |
17493 | 413 nil |
31785 | 414 (if (looking-at "Xref: ") |
415 (goto-char (match-end 0))) | |
416 (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
|
417 (nnheader-nov-parse-extra)))) ; extra |
17493 | 418 |
419 (defun nnheader-insert-nov (header) | |
420 (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
|
421 (let ((p (point))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
422 (insert |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
423 "\t" |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
424 (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
|
425 (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
|
426 (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
|
427 (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
|
428 (nnmail-message-id)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
429 "\t" |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
430 (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
|
431 (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
|
432 (insert "\t") |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
433 (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
|
434 (insert "\t") |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
435 (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
|
436 (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
|
437 (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
|
438 (mail-header-extra header)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
439 (insert "\t")) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
440 (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
|
441 (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
|
442 (while extra |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
443 (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
|
444 ": " (cdar extra) "\t") |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
445 (pop extra)))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
446 (insert "\n") |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
447 (backward-char 1) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
448 (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
|
449 (delete-char 1)) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
450 (forward-line 1))) |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
451 |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
452 (defun nnheader-parse-overview-file (file) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
453 "Parse FILE and return a list of headers." |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
454 (mm-with-unibyte-buffer |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
455 (nnheader-insert-file-contents file) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
456 (goto-char (point-min)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
457 (let (headers) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
458 (while (not (eobp)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
459 (push (nnheader-parse-nov) headers) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
460 (forward-line 1)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
461 (nreverse headers)))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
462 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
463 (defun nnheader-write-overview-file (file headers) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
464 "Write HEADERS to FILE." |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
465 (with-temp-file file |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
466 (mapcar 'nnheader-insert-nov headers))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
467 |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
468 (defun nnheader-insert-header (header) |
17493 | 469 (insert |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
470 "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
|
471 "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
|
472 "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
|
473 "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
|
474 "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
|
475 "Lines: ") |
17493 | 476 (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
|
477 (insert "\n\n")) |
17493 | 478 |
479 (defun nnheader-insert-article-line (article) | |
480 (goto-char (point-min)) | |
481 (insert "220 ") | |
482 (princ article (current-buffer)) | |
483 (insert " Article retrieved.\n") | |
484 (search-forward "\n\n" nil 'move) | |
485 (delete-region (point) (point-max)) | |
486 (forward-char -1) | |
487 (insert ".")) | |
488 | |
489 (defun nnheader-nov-delete-outside-range (beg end) | |
490 "Delete all NOV lines that lie outside the BEG to END range." | |
491 ;; First we find the first wanted line. | |
492 (nnheader-find-nov-line beg) | |
493 (delete-region (point-min) (point)) | |
494 ;; Then we find the last wanted line. | |
495 (when (nnheader-find-nov-line end) | |
496 (forward-line 1)) | |
497 (delete-region (point) (point-max))) | |
498 | |
499 (defun nnheader-find-nov-line (article) | |
500 "Put point at the NOV line that start with ARTICLE. | |
501 If ARTICLE doesn't exist, put point where that line | |
502 would have been. The function will return non-nil if | |
503 the line could be found." | |
504 ;; This function basically does a binary search. | |
505 (let ((max (point-max)) | |
506 (min (goto-char (point-min))) | |
507 (cur (current-buffer)) | |
508 (prev (point-min)) | |
509 num found) | |
510 (while (not found) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
511 (goto-char (+ min (/ (- max min) 2))) |
17493 | 512 (beginning-of-line) |
513 (if (or (= (point) prev) | |
514 (eobp)) | |
515 (setq found t) | |
516 (setq prev (point)) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
517 (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
|
518 (not (eobp))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
519 (gnus-delete-line)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
520 (cond ((> num article) |
17493 | 521 (setq max (point))) |
522 ((< num article) | |
523 (setq min (point))) | |
524 (t | |
525 (setq found 'yes))))) | |
526 ;; We may be at the first line. | |
527 (when (and (not num) | |
528 (not (eobp))) | |
529 (setq num (read cur))) | |
530 ;; Now we may have found the article we're looking for, or we | |
531 ;; may be somewhere near it. | |
532 (when (and (not (eq found 'yes)) | |
533 (not (eq num article))) | |
534 (setq found (point)) | |
535 (while (and (< (point) max) | |
536 (or (not (numberp num)) | |
537 (< num article))) | |
538 (forward-line 1) | |
539 (setq found (point)) | |
540 (or (eobp) | |
541 (= (setq num (read cur)) article))) | |
542 (unless (eq num article) | |
543 (goto-char found))) | |
544 (beginning-of-line) | |
545 (eq num article))) | |
546 | |
547 ;; Various cruft the backends and Gnus need to communicate. | |
548 | |
549 (defvar nntp-server-buffer nil) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
550 (defvar nntp-process-response nil) |
17493 | 551 (defvar news-reply-yank-from nil) |
552 (defvar news-reply-yank-message-id nil) | |
553 | |
554 (defvar nnheader-callback-function nil) | |
555 | |
556 (defun nnheader-init-server-buffer () | |
557 "Initialize the Gnus-backend communication buffer." | |
558 (save-excursion | |
559 (unless (gnus-buffer-live-p nntp-server-buffer) | |
560 (setq nntp-server-buffer (get-buffer-create " *nntpd*"))) | |
38284
9fd6579b27ec
(nnheader-init-server-buffer): Make sure the
Gerd Moellmann <gerd@gnu.org>
parents:
35486
diff
changeset
|
561 (set-buffer nntp-server-buffer) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
562 (mm-enable-multibyte) |
17493 | 563 (erase-buffer) |
564 (kill-all-local-variables) | |
565 (setq case-fold-search t) ;Should ignore case. | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
566 (set (make-local-variable 'nntp-process-response) nil) |
17493 | 567 t)) |
568 | |
569 ;;; Various functions the backends use. | |
570 | |
571 (defun nnheader-file-error (file) | |
572 "Return a string that says what is wrong with FILE." | |
573 (format | |
574 (cond | |
575 ((not (file-exists-p file)) | |
576 "%s does not exist") | |
577 ((file-directory-p file) | |
578 "%s is a directory") | |
579 ((not (file-readable-p file)) | |
580 "%s is not readable")) | |
581 file)) | |
582 | |
583 (defun nnheader-insert-head (file) | |
584 "Insert the head of the article." | |
585 (when (file-exists-p file) | |
586 (if (eq nnheader-max-head-length t) | |
587 ;; Just read the entire file. | |
588 (nnheader-insert-file-contents file) | |
72203 | 589 ;; Read blocks of the size specified by `nnheader-head-chop-length' |
590 ;; until we find a separator. | |
17493 | 591 (let ((beg 0) |
72203 | 592 (start (point)) |
593 ;; Use `binary' to prevent the contents from being decoded, | |
594 ;; or it will change the number of characters that | |
595 ;; `insert-file-contents' returns. | |
596 (coding-system-for-read 'binary)) | |
17493 | 597 (while (and (eq nnheader-head-chop-length |
72203 | 598 (nth 1 (mm-insert-file-contents |
17493 | 599 file nil beg |
600 (incf beg nnheader-head-chop-length)))) | |
72425 | 601 ;; CRLF or CR might be used for the line-break code. |
72203 | 602 (prog1 (not (re-search-forward "\n\r?\n\\|\r\r" nil t)) |
17493 | 603 (goto-char (point-max))) |
604 (or (null nnheader-max-head-length) | |
72203 | 605 (< beg nnheader-max-head-length)))) |
606 ;; Finally decode the contents. | |
607 (when (mm-coding-system-p nnheader-file-coding-system) | |
608 (mm-decode-coding-region start (point-max) | |
609 nnheader-file-coding-system)))) | |
17493 | 610 t)) |
611 | |
612 (defun nnheader-article-p () | |
613 "Say whether the current buffer looks like an article." | |
614 (goto-char (point-min)) | |
615 (if (not (search-forward "\n\n" nil t)) | |
616 nil | |
617 (narrow-to-region (point-min) (1- (point))) | |
618 (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
|
619 (while (looking-at "[a-zA-Z][^ \t]+:.*\n\\([ \t].*\n\\)*\\|From .*\n") |
17493 | 620 (goto-char (match-end 0))) |
621 (prog1 | |
622 (eobp) | |
623 (widen)))) | |
624 | |
625 (defun nnheader-insert-references (references message-id) | |
626 "Insert a References header based on REFERENCES and MESSAGE-ID." | |
627 (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
|
628 ;; 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
|
629 () |
17493 | 630 (mail-position-on-field "References") |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
631 (let ((begin (gnus-point-at-bol)) |
17493 | 632 (fill-column 78) |
633 (fill-prefix "\t")) | |
634 (when references | |
635 (insert references)) | |
636 (when (and references message-id) | |
637 (insert " ")) | |
638 (when message-id | |
639 (insert message-id)) | |
640 ;; Fold long References lines to conform to RFC1036 (sort of). | |
641 ;; The region must end with a newline to fill the region | |
642 ;; without inserting extra newline. | |
643 (fill-region-as-paragraph begin (1+ (point)))))) | |
644 | |
645 (defun nnheader-replace-header (header new-value) | |
646 "Remove HEADER and insert the NEW-VALUE." | |
647 (save-excursion | |
648 (save-restriction | |
649 (nnheader-narrow-to-headers) | |
650 (prog1 | |
651 (message-remove-header header) | |
652 (goto-char (point-max)) | |
653 (insert header ": " new-value "\n"))))) | |
654 | |
655 (defun nnheader-narrow-to-headers () | |
656 "Narrow to the head of an article." | |
657 (widen) | |
658 (narrow-to-region | |
659 (goto-char (point-min)) | |
660 (if (search-forward "\n\n" nil t) | |
661 (1- (point)) | |
662 (point-max))) | |
663 (goto-char (point-min))) | |
664 | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
665 (defun nnheader-remove-body () |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
666 "Remove the body from an article in this current buffer." |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
667 (goto-char (point-min)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
668 (when (re-search-forward "\n\r?\n" nil t) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
669 (delete-region (point) (point-max)))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
670 |
17493 | 671 (defun nnheader-set-temp-buffer (name &optional noerase) |
672 "Set-buffer to an empty (possibly new) buffer called NAME with undo disabled." | |
673 (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
|
674 (buffer-disable-undo) |
17493 | 675 (unless noerase |
676 (erase-buffer)) | |
677 (current-buffer)) | |
678 | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
679 (eval-when-compile (defvar jka-compr-compression-info-list)) |
17493 | 680 (defvar nnheader-numerical-files |
681 (if (boundp 'jka-compr-compression-info-list) | |
682 (concat "\\([0-9]+\\)\\(" | |
683 (mapconcat (lambda (i) (aref i 0)) | |
684 jka-compr-compression-info-list "\\|") | |
685 "\\)?") | |
686 "[0-9]+$") | |
687 "Regexp that match numerical files.") | |
688 | |
689 (defvar nnheader-numerical-short-files (concat "^" nnheader-numerical-files) | |
690 "Regexp that matches numerical file names.") | |
691 | |
692 (defvar nnheader-numerical-full-files (concat "/" nnheader-numerical-files) | |
49274
eb2699620e9c
* gnus-agent.el: Don't use `path'.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
45956
diff
changeset
|
693 "Regexp that matches numerical full file names.") |
17493 | 694 |
695 (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
|
696 "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
|
697 (if (string= nnheader-numerical-short-files "^[0-9]+$") |
62907
88db2adda4b7
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-339
Miles Bader <miles@gnu.org>
parents:
60239
diff
changeset
|
698 (string-to-number file) |
17493 | 699 (string-match nnheader-numerical-short-files file) |
62907
88db2adda4b7
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-339
Miles Bader <miles@gnu.org>
parents:
60239
diff
changeset
|
700 (string-to-number (match-string 0 file)))) |
17493 | 701 |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
702 (defvar nnheader-directory-files-is-safe |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
703 (or (eq system-type 'windows-nt) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
704 (and (not (featurep 'xemacs)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
705 (> emacs-major-version 20))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
706 "If non-nil, Gnus believes `directory-files' is safe. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
707 It has been reported numerous times that `directory-files' fails with |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
708 an alarming frequency on NFS mounted file systems. If it is nil, |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
709 `nnheader-directory-files-safe' is used.") |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
710 |
17493 | 711 (defun nnheader-directory-files-safe (&rest args) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
712 "Execute `directory-files' twice and returns the longer result." |
17493 | 713 (let ((first (apply 'directory-files args)) |
714 (second (apply 'directory-files args))) | |
715 (if (> (length first) (length second)) | |
716 first | |
717 second))) | |
718 | |
719 (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
|
720 "Return a list of all article files in directory DIR." |
17493 | 721 (mapcar 'nnheader-file-to-number |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
722 (if nnheader-directory-files-is-safe |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
723 (directory-files |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
724 dir nil nnheader-numerical-short-files t) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
725 (nnheader-directory-files-safe |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
726 dir nil nnheader-numerical-short-files t)))) |
17493 | 727 |
728 (defun nnheader-article-to-file-alist (dir) | |
729 "Return an alist of article/file pairs in DIR." | |
730 (mapcar (lambda (file) (cons (nnheader-file-to-number file) file)) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
731 (if nnheader-directory-files-is-safe |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
732 (directory-files |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
733 dir nil nnheader-numerical-short-files t) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
734 (nnheader-directory-files-safe |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
735 dir nil nnheader-numerical-short-files t)))) |
17493 | 736 |
737 (defun nnheader-fold-continuation-lines () | |
738 "Fold continuation lines in the current buffer." | |
739 (nnheader-replace-regexp "\\(\r?\n[ \t]+\\)+" " ")) | |
740 | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
741 (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
|
742 "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
|
743 If FULL, translate everything." |
17493 | 744 (if (null nnheader-file-name-translation-alist) |
745 ;; No translation is necessary. | |
746 file | |
747 (let* ((i 0) | |
748 trans leaf path len) | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
749 (if full |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
750 ;; Do complete translation. |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
751 (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
|
752 path "" |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
753 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
|
754 2 0)) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
755 ;; 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
|
756 ;; alone. |
32972
a51631f90704
2000-09-24 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31785
diff
changeset
|
757 (if (and (featurep 'xemacs) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
758 (memq system-type '(cygwin32 win32 w32 mswindows windows-nt |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
759 cygwin))) |
32972
a51631f90704
2000-09-24 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31785
diff
changeset
|
760 ;; 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
|
761 ;; 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
|
762 ;; file names, containing ':', e.g. |
a51631f90704
2000-09-24 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31785
diff
changeset
|
763 ;; "d:\\Work\\News\\nntp+news.fido7.ru:fido7.ru.gnu.SCORE" |
49549
99be3a1e2589
Cygwin support patch.
Juanma Barranquero <lekktu@gmail.com>
parents:
49274
diff
changeset
|
764 ;; |
32972
a51631f90704
2000-09-24 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31785
diff
changeset
|
765 ;; 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
|
766 ;; "d:file.name" -> "a:" "file.name" |
a51631f90704
2000-09-24 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31785
diff
changeset
|
767 ;; "aaa:bbb.ccc" -> "" "aaa:bbb.ccc" |
a51631f90704
2000-09-24 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31785
diff
changeset
|
768 ;; "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
|
769 ;; etc. |
a51631f90704
2000-09-24 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31785
diff
changeset
|
770 ;; 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
|
771 (progn |
a51631f90704
2000-09-24 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31785
diff
changeset
|
772 (setq leaf file |
a51631f90704
2000-09-24 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31785
diff
changeset
|
773 path "") |
a51631f90704
2000-09-24 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31785
diff
changeset
|
774 (if (string-match "\\(^\\w:\\|[/\\]\\)\\([^/\\]+\\)$" file) |
a51631f90704
2000-09-24 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31785
diff
changeset
|
775 (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
|
776 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
|
777 ;; Emacs DTRT, says andrewi. |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
778 (setq leaf (file-name-nondirectory file) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
779 path (file-name-directory file)))) |
17493 | 780 (setq len (length leaf)) |
781 (while (< i len) | |
782 (when (setq trans (cdr (assq (aref leaf i) | |
783 nnheader-file-name-translation-alist))) | |
784 (aset leaf i trans)) | |
785 (incf i)) | |
786 (concat path leaf)))) | |
787 | |
788 (defun nnheader-report (backend &rest args) | |
789 "Report an error from the BACKEND. | |
790 The first string in ARGS can be a format string." | |
791 (set (intern (format "%s-status-string" backend)) | |
792 (if (< (length args) 2) | |
793 (car args) | |
794 (apply 'format args))) | |
795 nil) | |
796 | |
797 (defun nnheader-get-report (backend) | |
798 "Get the most recent report from BACKEND." | |
799 (condition-case () | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
800 (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
|
801 backend)))) |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
802 (error (nnheader-message 5 "")))) |
17493 | 803 |
804 (defun nnheader-insert (format &rest args) | |
805 "Clear the communication buffer and insert FORMAT and ARGS into the buffer. | |
806 If FORMAT isn't a format string, it and all ARGS will be inserted | |
807 without formatting." | |
808 (save-excursion | |
809 (set-buffer nntp-server-buffer) | |
810 (erase-buffer) | |
811 (if (string-match "%" format) | |
812 (insert (apply 'format format args)) | |
813 (apply 'insert format args)) | |
814 t)) | |
815 | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
816 (defsubst nnheader-replace-chars-in-string (string from to) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
817 (mm-subst-char-in-string from to string)) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
818 |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
819 (defun nnheader-replace-duplicate-chars-in-string (string from to) |
17493 | 820 "Replace characters in STRING from FROM to TO." |
821 (let ((string (substring string 0)) ;Copy string. | |
822 (len (length string)) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
823 (idx 0) prev i) |
17493 | 824 ;; Replace all occurrences of FROM with TO. |
825 (while (< idx len) | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
826 (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
|
827 (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
|
828 (aset string (1- idx) to) |
17493 | 829 (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
|
830 (setq prev i) |
17493 | 831 (setq idx (1+ idx))) |
832 string)) | |
833 | |
834 (defun nnheader-file-to-group (file &optional top) | |
835 "Return a group name based on FILE and TOP." | |
836 (nnheader-replace-chars-in-string | |
837 (if (not top) | |
838 file | |
839 (condition-case () | |
840 (substring (expand-file-name file) | |
841 (length | |
842 (expand-file-name | |
843 (file-name-as-directory top)))) | |
844 (error ""))) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
845 nnheader-directory-separator-character ?.)) |
17493 | 846 |
847 (defun nnheader-message (level &rest args) | |
848 "Message if the Gnus backends are talkative." | |
849 (if (or (not (numberp gnus-verbose-backends)) | |
850 (<= level gnus-verbose-backends)) | |
851 (apply 'message args) | |
852 (apply 'format args))) | |
853 | |
854 (defun nnheader-be-verbose (level) | |
855 "Return whether the backends should be verbose on LEVEL." | |
856 (or (not (numberp gnus-verbose-backends)) | |
857 (<= level gnus-verbose-backends))) | |
858 | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
859 (defvar nnheader-pathname-coding-system 'iso-8859-1 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
860 "*Coding system for file name.") |
19596
33877efba398
(nnheader-pathname-coding-system): New variable.
Kenichi Handa <handa@m17n.org>
parents:
19493
diff
changeset
|
861 |
17493 | 862 (defun nnheader-group-pathname (group dir &optional file) |
49274
eb2699620e9c
* gnus-agent.el: Don't use `path'.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents:
45956
diff
changeset
|
863 "Make file name for GROUP." |
17493 | 864 (concat |
865 (let ((dir (file-name-as-directory (expand-file-name dir)))) | |
866 ;; 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
|
867 (file-name-as-directory |
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
868 (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
|
869 (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
|
870 ;; 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
|
871 (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
|
872 (nnheader-replace-chars-in-string group ?. ?/) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
873 nnheader-pathname-coding-system) |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
874 dir)))) |
17493 | 875 (cond ((null file) "") |
876 ((numberp file) (int-to-string file)) | |
877 (t file)))) | |
878 | |
879 (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
|
880 "Concat DIR as directory to FILES." |
17493 | 881 (apply 'concat (file-name-as-directory dir) files)) |
882 | |
883 (defun nnheader-ms-strip-cr () | |
884 "Strip ^M from the end of all lines." | |
885 (save-excursion | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
886 (nnheader-remove-cr-followed-by-lf))) |
17493 | 887 |
888 (defun nnheader-file-size (file) | |
889 "Return the file size of FILE or 0." | |
890 (or (nth 7 (file-attributes file)) 0)) | |
891 | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
892 (defun nnheader-find-etc-directory (package &optional file first) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
893 "Go through `load-path' and find the \"../etc/PACKAGE\" directory. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
894 This function will look in the parent directory of each `load-path' |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
895 entry, and look for the \"etc\" directory there. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
896 If FILE, find the \".../etc/PACKAGE\" file instead. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
897 If FIRST is non-nil, return the directory or the file found at the |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
898 first. Otherwise, find the newest one, though it may take a time." |
17493 | 899 (let ((path load-path) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
900 dir results) |
17493 | 901 ;; We try to find the dir by looking at the load path, |
902 ;; stripping away the last component and adding "etc/". | |
903 (while path | |
904 (if (and (car path) | |
905 (file-exists-p | |
906 (setq dir (concat | |
907 (file-name-directory | |
908 (directory-file-name (car path))) | |
909 "etc/" package | |
910 (if file "" "/")))) | |
911 (or file (file-directory-p dir))) | |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
912 (progn |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
913 (or (member dir results) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
914 (push dir results)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
915 (setq path (if first nil (cdr path)))) |
17493 | 916 (setq path (cdr path)))) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
917 (if (or first (not (cdr results))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
918 (car results) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
919 (car (sort results 'file-newer-than-file-p))))) |
17493 | 920 |
33301
c1c373a70748
Put some defvars in eval-when-compile.
Dave Love <fx@gnu.org>
parents:
33300
diff
changeset
|
921 (eval-when-compile |
c1c373a70748
Put some defvars in eval-when-compile.
Dave Love <fx@gnu.org>
parents:
33300
diff
changeset
|
922 (defvar ange-ftp-path-format) |
c1c373a70748
Put some defvars in eval-when-compile.
Dave Love <fx@gnu.org>
parents:
33300
diff
changeset
|
923 (defvar efs-path-regexp)) |
17493 | 924 (defun nnheader-re-read-dir (path) |
925 "Re-read directory PATH if PATH is on a remote system." | |
926 (if (and (fboundp 'efs-re-read-dir) (boundp 'efs-path-regexp)) | |
927 (when (string-match efs-path-regexp path) | |
928 (efs-re-read-dir path)) | |
929 (when (and (fboundp 'ange-ftp-re-read-dir) (boundp 'ange-ftp-path-format)) | |
930 (when (string-match (car ange-ftp-path-format) path) | |
931 (ange-ftp-re-read-dir path))))) | |
932 | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
933 (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
|
934 "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
|
935 |
17493 | 936 (defun nnheader-insert-file-contents (filename &optional visit beg end replace) |
937 "Like `insert-file-contents', q.v., but only reads in the file. | |
938 A buffer may be modified in several ways after reading into the buffer due | |
939 to advanced Emacs features, such as file-name-handlers, format decoding, | |
940 find-file-hooks, etc. | |
941 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
|
942 (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
|
943 (mm-insert-file-contents filename visit beg end replace))) |
17493 | 944 |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
945 (defun nnheader-insert-nov-file (file first) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
946 (let ((size (nth 7 (file-attributes file))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
947 (cutoff (* 32 1024))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
948 (when size |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
949 (if (< size cutoff) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
950 ;; If the file is small, we just load it. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
951 (nnheader-insert-file-contents file) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
952 ;; We start on the assumption that FIRST is pretty recent. If |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
953 ;; not, we just insert the rest of the file as well. |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
954 (let (current) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
955 (nnheader-insert-file-contents file nil (- size cutoff) size) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
956 (goto-char (point-min)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
957 (delete-region (point) (or (search-forward "\n" nil 'move) (point))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
958 (setq current (ignore-errors (read (current-buffer)))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
959 (if (and (numberp current) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
960 (< current first)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
961 t |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
962 (delete-region (point-min) (point-max)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
963 (nnheader-insert-file-contents file))))))) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
964 |
17493 | 965 (defun nnheader-find-file-noselect (&rest args) |
60239
bbe4bd573f0c
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-128
Miles Bader <miles@gnu.org>
parents:
57442
diff
changeset
|
966 "Open a file with some variables bound. |
bbe4bd573f0c
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-128
Miles Bader <miles@gnu.org>
parents:
57442
diff
changeset
|
967 See `find-file-noselect' for the arguments." |
62943
11d53dd5abd9
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents:
62907
diff
changeset
|
968 (let* ((format-alist nil) |
11d53dd5abd9
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents:
62907
diff
changeset
|
969 (auto-mode-alist (mm-auto-mode-alist)) |
11d53dd5abd9
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents:
62907
diff
changeset
|
970 (default-major-mode 'fundamental-mode) |
11d53dd5abd9
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents:
62907
diff
changeset
|
971 (enable-local-variables nil) |
11d53dd5abd9
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents:
62907
diff
changeset
|
972 (after-insert-file-functions nil) |
11d53dd5abd9
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents:
62907
diff
changeset
|
973 (enable-local-eval nil) |
11d53dd5abd9
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents:
62907
diff
changeset
|
974 (coding-system-for-read nnheader-file-coding-system) |
11d53dd5abd9
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents:
62907
diff
changeset
|
975 (ffh (if (boundp 'find-file-hook) |
11d53dd5abd9
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents:
62907
diff
changeset
|
976 'find-file-hook |
11d53dd5abd9
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents:
62907
diff
changeset
|
977 'find-file-hooks)) |
11d53dd5abd9
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents:
62907
diff
changeset
|
978 (val (symbol-value ffh))) |
11d53dd5abd9
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents:
62907
diff
changeset
|
979 (set ffh nil) |
11d53dd5abd9
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents:
62907
diff
changeset
|
980 (unwind-protect |
11d53dd5abd9
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents:
62907
diff
changeset
|
981 (apply 'find-file-noselect args) |
11d53dd5abd9
Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-345
Miles Bader <miles@gnu.org>
parents:
62907
diff
changeset
|
982 (set ffh val)))) |
17493 | 983 |
984 (defun nnheader-directory-regular-files (dir) | |
985 "Return a list of all regular files in DIR." | |
986 (let ((files (directory-files dir t)) | |
987 out) | |
988 (while files | |
989 (when (file-regular-p (car files)) | |
990 (push (car files) out)) | |
991 (pop files)) | |
992 (nreverse out))) | |
993 | |
24357
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
994 (defun nnheader-directory-files (&rest args) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
995 "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
|
996 (let ((files (apply 'directory-files args)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
997 out) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
998 (while files |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
999 (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
|
1000 (push (car files) out)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
1001 (pop files)) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
1002 (nreverse out))) |
15fc6acbae7a
Upgrading to Gnus 5.7; see ChangeLog
Lars Magne Ingebrigtsen <larsi@gnus.org>
parents:
19969
diff
changeset
|
1003 |
17493 | 1004 (defmacro nnheader-skeleton-replace (from &optional to regexp) |
1005 `(let ((new (generate-new-buffer " *nnheader replace*")) | |
1006 (cur (current-buffer)) | |
1007 (start (point-min))) | |
1008 (set-buffer cur) | |
1009 (goto-char (point-min)) | |
1010 (while (,(if regexp 're-search-forward 'search-forward) | |
1011 ,from nil t) | |
1012 (insert-buffer-substring | |
1013 cur start (prog1 (match-beginning 0) (set-buffer new))) | |
1014 (goto-char (point-max)) | |
1015 ,(when to `(insert ,to)) | |
1016 (set-buffer cur) | |
1017 (setq start (point))) | |
1018 (insert-buffer-substring | |
1019 cur start (prog1 (point-max) (set-buffer new))) | |
1020 (copy-to-buffer cur (point-min) (point-max)) | |
1021 (kill-buffer (current-buffer)) | |
1022 (set-buffer cur))) | |
1023 | |
1024 (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
|
1025 "Do a fast replacement of FROM to TO from point to `point-max'." |
17493 | 1026 (nnheader-skeleton-replace from to)) |
1027 | |
1028 (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
|
1029 "Do a fast regexp replacement of FROM to TO from point to `point-max'." |
17493 | 1030 (nnheader-skeleton-replace from to t)) |
1031 | |
1032 (defun nnheader-strip-cr () | |
1033 "Strip all \r's from the current buffer." | |
1034 (nnheader-skeleton-replace "\r")) | |
1035 | |
31716
9968f55ad26e
Update to emacs-21-branch of the Gnus CVS repository.
Gerd Moellmann <gerd@gnu.org>
parents:
24357
diff
changeset
|
1036 (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
|
1037 (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
|
1038 (defalias 'nnheader-cancel-function-timers 'cancel-function-timers) |
56927
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
1039 (defalias 'nnheader-string-as-multibyte 'string-as-multibyte) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
1040 |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
1041 (defun nnheader-accept-process-output (process) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
1042 (accept-process-output |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
1043 process |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
1044 (truncate nnheader-read-timeout) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
1045 (truncate (* (- nnheader-read-timeout |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
1046 (truncate nnheader-read-timeout)) |
55fd4f77387a
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents:
52401
diff
changeset
|
1047 1000)))) |
17493 | 1048 |
32972
a51631f90704
2000-09-24 Simon Josefsson <simon@josefsson.org>
Dave Love <fx@gnu.org>
parents:
31785
diff
changeset
|
1049 (when (featurep 'xemacs) |
17493 | 1050 (require 'nnheaderxm)) |
1051 | |
1052 (run-hooks 'nnheader-load-hook) | |
1053 | |
1054 (provide 'nnheader) | |
1055 | |
52401 | 1056 ;;; arch-tag: a9c4b7d9-52ae-4ec9-b196-dfd93124d202 |
17493 | 1057 ;;; nnheader.el ends here |