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