Mercurial > emacs
annotate lisp/gnus/gnus-art.el @ 19860:c17fd465ea95 libc-970911 libc-970912 libc-970913 libc-970914 libc-970915 libc-970916 libc-970917 libc-970918 libc-970919 libc-970920 libc-970921 libc-970922 libc-970923 libc-970924 libc-970925 libc-970926 libc-970927 libc-970928 libc-970929 libc-970930 libc-971001 libc-971018 libc-971019 libc-971020 libc-971021 libc-971022 libc-971023 libc-971024 libc-971025 libc-971026 libc-971027 libc-971028 libc-971029 libc-971030 libc-971031 libc-971101 libc-971102 libc-971103 libc-971104 libc-971105 libc-971106 libc-971107 libc-971108 libc-971109 libc-971110 libc-971111 libc-971112 libc-971113 libc-971114 libc-971115 libc-971116 libc-971117 libc-971118 libc-971120 libc-971121 libc-971122 libc-971123 libc-971124 libc-971125 libc-971126 libc-971127 libc-971128 libc-971129 libc-971130 libc-971201 libc-971203 libc-971204 libc-971205 libc-971206 libc-971207 libc-971208 libc-971209 libc-971210 libc-971211 libc-971212 libc-971213 libc-971214 libc-971217 libc-971218 libc-971219 libc-971220 libc-971221 libc-971222 libc-971223 libc-971224 libc-971225 libc-971226 libc-971227 libc-971228 libc-971229 libc-971230 libc-971231 libc-980103 libc-980104 libc-980105 libc-980106 libc-980107 libc-980108 libc-980109 libc-980110 libc-980111 libc-980112 libc-980114 libc-980115 libc-980116 libc-980117 libc-980118 libc-980119 libc-980120 libc-980121 libc-980122 libc-980123 libc-980124 libc-980125 libc-980126 libc-980127 libc-980128
typos.
author | Jeff Law <law@redhat.com> |
---|---|
date | Wed, 10 Sep 1997 21:16:20 +0000 |
parents | 2a7342ecf59d |
children | 5f1ab3dd344d |
rev | line source |
---|---|
17493 | 1 ;;; gnus-art.el --- article mode commands for Gnus |
2 ;; Copyright (C) 1996,97 Free Software Foundation, Inc. | |
3 | |
4 ;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no> | |
5 ;; Keywords: news | |
6 | |
7 ;; This file is part of GNU Emacs. | |
8 | |
9 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
10 ;; it under the terms of the GNU General Public License as published by | |
11 ;; the Free Software Foundation; either version 2, or (at your option) | |
12 ;; any later version. | |
13 | |
14 ;; GNU Emacs is distributed in the hope that it will be useful, | |
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 ;; GNU General Public License for more details. | |
18 | |
19 ;; You should have received a copy of the GNU General Public License | |
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
22 ;; Boston, MA 02111-1307, USA. | |
23 | |
24 ;;; Commentary: | |
25 | |
26 ;;; Code: | |
27 | |
19521
6f6cf9184e93
Require cl at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
17493
diff
changeset
|
28 (eval-when-compile (require 'cl)) |
6f6cf9184e93
Require cl at compile time.
Richard M. Stallman <rms@gnu.org>
parents:
17493
diff
changeset
|
29 |
17493 | 30 (require 'custom) |
31 (require 'gnus) | |
32 (require 'gnus-sum) | |
33 (require 'gnus-spec) | |
34 (require 'gnus-int) | |
35 (require 'browse-url) | |
36 | |
37 (defgroup gnus-article nil | |
38 "Article display." | |
39 :link '(custom-manual "(gnus)The Article Buffer") | |
40 :group 'gnus) | |
41 | |
42 (defgroup gnus-article-hiding nil | |
43 "Hiding article parts." | |
44 :link '(custom-manual "(gnus)Article Hiding") | |
45 :group 'gnus-article) | |
46 | |
47 (defgroup gnus-article-highlight nil | |
48 "Article highlighting." | |
49 :link '(custom-manual "(gnus)Article Highlighting") | |
50 :group 'gnus-article | |
51 :group 'gnus-visual) | |
52 | |
53 (defgroup gnus-article-signature nil | |
54 "Article signatures." | |
55 :link '(custom-manual "(gnus)Article Signature") | |
56 :group 'gnus-article) | |
57 | |
58 (defgroup gnus-article-headers nil | |
59 "Article headers." | |
60 :link '(custom-manual "(gnus)Hiding Headers") | |
61 :group 'gnus-article) | |
62 | |
63 (defgroup gnus-article-washing nil | |
64 "Special commands on articles." | |
65 :link '(custom-manual "(gnus)Article Washing") | |
66 :group 'gnus-article) | |
67 | |
68 (defgroup gnus-article-emphasis nil | |
69 "Fontisizing articles." | |
70 :link '(custom-manual "(gnus)Article Fontisizing") | |
71 :group 'gnus-article) | |
72 | |
73 (defgroup gnus-article-saving nil | |
74 "Saving articles." | |
75 :link '(custom-manual "(gnus)Saving Articles") | |
76 :group 'gnus-article) | |
77 | |
78 (defgroup gnus-article-mime nil | |
79 "Worshiping the MIME wonder." | |
80 :link '(custom-manual "(gnus)Using MIME") | |
81 :group 'gnus-article) | |
82 | |
83 (defgroup gnus-article-buttons nil | |
84 "Pushable buttons in the article buffer." | |
85 :link '(custom-manual "(gnus)Article Buttons") | |
86 :group 'gnus-article) | |
87 | |
88 (defgroup gnus-article-various nil | |
89 "Other article options." | |
90 :link '(custom-manual "(gnus)Misc Article") | |
91 :group 'gnus-article) | |
92 | |
93 (defcustom gnus-ignored-headers | |
94 '("^Path:" "^Posting-Version:" "^Article-I.D.:" "^Expires:" | |
95 "^Date-Received:" "^References:" "^Control:" "^Xref:" "^Lines:" | |
96 "^Posted:" "^Relay-Version:" "^Message-ID:" "^Nf-ID:" "^Nf-From:" | |
97 "^Approved:" "^Sender:" "^Received:" "^Mail-from:") | |
98 "All headers that match this regexp will be hidden. | |
99 This variable can also be a list of regexps of headers to be ignored. | |
100 If `gnus-visible-headers' is non-nil, this variable will be ignored." | |
101 :type '(choice :custom-show nil | |
102 regexp | |
103 (repeat regexp)) | |
104 :group 'gnus-article-hiding) | |
105 | |
106 (defcustom gnus-visible-headers | |
107 "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-From" | |
108 "All headers that do not match this regexp will be hidden. | |
109 This variable can also be a list of regexp of headers to remain visible. | |
110 If this variable is non-nil, `gnus-ignored-headers' will be ignored." | |
111 :type '(repeat :value-to-internal (lambda (widget value) | |
112 (custom-split-regexp-maybe value)) | |
113 :match (lambda (widget value) | |
114 (or (stringp value) | |
115 (widget-editable-list-match widget value))) | |
116 regexp) | |
117 :group 'gnus-article-hiding) | |
118 | |
119 (defcustom gnus-sorted-header-list | |
120 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:" | |
121 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:") | |
122 "This variable is a list of regular expressions. | |
123 If it is non-nil, headers that match the regular expressions will | |
124 be placed first in the article buffer in the sequence specified by | |
125 this list." | |
126 :type '(repeat regexp) | |
127 :group 'gnus-article-hiding) | |
128 | |
129 (defcustom gnus-boring-article-headers '(empty followup-to reply-to) | |
130 "Headers that are only to be displayed if they have interesting data. | |
131 Possible values in this list are `empty', `newsgroups', `followup-to', | |
132 `reply-to', and `date'." | |
133 :type '(set (const :tag "Headers with no content." empty) | |
134 (const :tag "Newsgroups with only one group." newsgroups) | |
135 (const :tag "Followup-to identical to newsgroups." followup-to) | |
136 (const :tag "Reply-to identical to from." reply-to) | |
137 (const :tag "Date less than four days old." date)) | |
138 :group 'gnus-article-hiding) | |
139 | |
140 (defcustom gnus-signature-separator '("^-- $" "^-- *$") | |
141 "Regexp matching signature separator. | |
142 This can also be a list of regexps. In that case, it will be checked | |
143 from head to tail looking for a separator. Searches will be done from | |
144 the end of the buffer." | |
145 :type '(repeat string) | |
146 :group 'gnus-article-signature) | |
147 | |
148 (defcustom gnus-signature-limit nil | |
149 "Provide a limit to what is considered a signature. | |
150 If it is a number, no signature may not be longer (in characters) than | |
151 that number. If it is a floating point number, no signature may be | |
152 longer (in lines) than that number. If it is a function, the function | |
153 will be called without any parameters, and if it returns nil, there is | |
154 no signature in the buffer. If it is a string, it will be used as a | |
155 regexp. If it matches, the text in question is not a signature." | |
156 :type '(choice integer number function regexp) | |
157 :group 'gnus-article-signature) | |
158 | |
159 (defcustom gnus-hidden-properties '(invisible t intangible t) | |
160 "Property list to use for hiding text." | |
161 :type 'sexp | |
162 :group 'gnus-article-hiding) | |
163 | |
164 (defcustom gnus-article-x-face-command | |
165 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | xv -quit -" | |
166 "String or function to be executed to display an X-Face header. | |
167 If it is a string, the command will be executed in a sub-shell | |
168 asynchronously. The compressed face will be piped to this command." | |
169 :type 'string ;Leave function case to Lisp. | |
170 :group 'gnus-article-washing) | |
171 | |
172 (defcustom gnus-article-x-face-too-ugly nil | |
173 "Regexp matching posters whose face shouldn't be shown automatically." | |
174 :type 'regexp | |
175 :group 'gnus-article-washing) | |
176 | |
177 (defcustom gnus-emphasis-alist | |
178 (let ((format | |
179 "\\(\\s-\\|^\\|[-\"]\\|\\s(\\|\\s)\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\s-\\|[-?!.,;:\"]\\|\\s(\\|\\s)\\)") | |
180 (types | |
181 '(("_" "_" underline) | |
182 ("/" "/" italic) | |
183 ("\\*" "\\*" bold) | |
184 ("_/" "/_" underline-italic) | |
185 ("_\\*" "\\*_" underline-bold) | |
186 ("\\*/" "/\\*" bold-italic) | |
187 ("_\\*/" "/\\*_" underline-bold-italic)))) | |
188 `(("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)" | |
189 2 3 gnus-emphasis-underline) | |
190 ,@(mapcar | |
191 (lambda (spec) | |
192 (list | |
193 (format format (car spec) (cadr spec)) | |
19537
2a7342ecf59d
(gnus-emphasis-alist): Don't use caddr.
Richard M. Stallman <rms@gnu.org>
parents:
19521
diff
changeset
|
194 2 3 (intern (format "gnus-emphasis-%s" (car (cddr spec)))))) |
17493 | 195 types))) |
196 "Alist that says how to fontify certain phrases. | |
197 Each item looks like this: | |
198 | |
199 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline) | |
200 | |
201 The first element is a regular expression to be matched. The second | |
202 is a number that says what regular expression grouping used to find | |
203 the entire emphasized word. The third is a number that says what | |
204 regexp grouping should be displayed and highlighted. The fourth | |
205 is the face used for highlighting." | |
206 :type '(repeat (list :value ("" 0 0 default) | |
207 regexp | |
208 (integer :tag "Match group") | |
209 (integer :tag "Emphasize group") | |
210 face)) | |
211 :group 'gnus-article-emphasis) | |
212 | |
213 (defface gnus-emphasis-bold '((t (:bold t))) | |
214 "Face used for displaying strong emphasized text (*word*)." | |
215 :group 'gnus-article-emphasis) | |
216 | |
217 (defface gnus-emphasis-italic '((t (:italic t))) | |
218 "Face used for displaying italic emphasized text (/word/)." | |
219 :group 'gnus-article-emphasis) | |
220 | |
221 (defface gnus-emphasis-underline '((t (:underline t))) | |
222 "Face used for displaying underlined emphasized text (_word_)." | |
223 :group 'gnus-article-emphasis) | |
224 | |
225 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t))) | |
226 "Face used for displaying underlined bold emphasized text (_*word*_)." | |
227 :group 'gnus-article-emphasis) | |
228 | |
229 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t))) | |
230 "Face used for displaying underlined italic emphasized text (_*word*_)." | |
231 :group 'gnus-article-emphasis) | |
232 | |
233 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t))) | |
234 "Face used for displaying bold italic emphasized text (/*word*/)." | |
235 :group 'gnus-article-emphasis) | |
236 | |
237 (defface gnus-emphasis-underline-bold-italic | |
238 '((t (:bold t :italic t :underline t))) | |
239 "Face used for displaying underlined bold italic emphasized text. | |
240 Esample: (_/*word*/_)." | |
241 :group 'gnus-article-emphasis) | |
242 | |
243 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z" | |
244 "Format for display of Date headers in article bodies. | |
245 See `format-time-zone' for the possible values." | |
246 :type 'string | |
247 :link '(custom-manual "(gnus)Article Date") | |
248 :group 'gnus-article-washing) | |
249 | |
250 (eval-and-compile | |
251 (autoload 'hexl-hex-string-to-integer "hexl") | |
252 (autoload 'timezone-make-date-arpa-standard "timezone") | |
253 (autoload 'mail-extract-address-components "mail-extr")) | |
254 | |
255 (defcustom gnus-save-all-headers t | |
256 "*If non-nil, don't remove any headers before saving." | |
257 :group 'gnus-article-saving | |
258 :type 'boolean) | |
259 | |
260 (defcustom gnus-prompt-before-saving 'always | |
261 "*This variable says how much prompting is to be done when saving articles. | |
262 If it is nil, no prompting will be done, and the articles will be | |
263 saved to the default files. If this variable is `always', each and | |
264 every article that is saved will be preceded by a prompt, even when | |
265 saving large batches of articles. If this variable is neither nil not | |
266 `always', there the user will be prompted once for a file name for | |
267 each invocation of the saving commands." | |
268 :group 'gnus-article-saving | |
269 :type '(choice (item always) | |
270 (item :tag "never" nil) | |
271 (sexp :tag "once" :format "%t"))) | |
272 | |
273 (defcustom gnus-saved-headers gnus-visible-headers | |
274 "Headers to keep if `gnus-save-all-headers' is nil. | |
275 If `gnus-save-all-headers' is non-nil, this variable will be ignored. | |
276 If that variable is nil, however, all headers that match this regexp | |
277 will be kept while the rest will be deleted before saving." | |
278 :group 'gnus-article-saving | |
279 :type '(repeat string)) | |
280 | |
281 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail | |
282 "A function to save articles in your favourite format. | |
283 The function must be interactively callable (in other words, it must | |
284 be an Emacs command). | |
285 | |
286 Gnus provides the following functions: | |
287 | |
288 * gnus-summary-save-in-rmail (Rmail format) | |
289 * gnus-summary-save-in-mail (Unix mail format) | |
290 * gnus-summary-save-in-folder (MH folder) | |
291 * gnus-summary-save-in-file (article format) | |
292 * gnus-summary-save-in-vm (use VM's folder format) | |
293 * gnus-summary-write-to-file (article format -- overwrite)." | |
294 :group 'gnus-article-saving | |
295 :type '(radio (function-item gnus-summary-save-in-rmail) | |
296 (function-item gnus-summary-save-in-mail) | |
297 (function-item gnus-summary-save-in-folder) | |
298 (function-item gnus-summary-save-in-file) | |
299 (function-item gnus-summary-save-in-vm) | |
300 (function-item gnus-summary-write-to-file))) | |
301 | |
302 (defcustom gnus-rmail-save-name 'gnus-plain-save-name | |
303 "A function generating a file name to save articles in Rmail format. | |
304 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE." | |
305 :group 'gnus-article-saving | |
306 :type 'function) | |
307 | |
308 (defcustom gnus-mail-save-name 'gnus-plain-save-name | |
309 "A function generating a file name to save articles in Unix mail format. | |
310 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE." | |
311 :group 'gnus-article-saving | |
312 :type 'function) | |
313 | |
314 (defcustom gnus-folder-save-name 'gnus-folder-save-name | |
315 "A function generating a file name to save articles in MH folder. | |
316 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER." | |
317 :group 'gnus-article-saving | |
318 :type 'function) | |
319 | |
320 (defcustom gnus-file-save-name 'gnus-numeric-save-name | |
321 "A function generating a file name to save articles in article format. | |
322 The function is called with NEWSGROUP, HEADERS, and optional | |
323 LAST-FILE." | |
324 :group 'gnus-article-saving | |
325 :type 'function) | |
326 | |
327 (defcustom gnus-split-methods | |
328 '((gnus-article-archive-name) | |
329 (gnus-article-nndoc-name)) | |
330 "Variable used to suggest where articles are to be saved. | |
331 For instance, if you would like to save articles related to Gnus in | |
332 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\", | |
333 you could set this variable to something like: | |
334 | |
335 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\") | |
336 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\")) | |
337 | |
338 This variable is an alist where the where the key is the match and the | |
339 value is a list of possible files to save in if the match is non-nil. | |
340 | |
341 If the match is a string, it is used as a regexp match on the | |
342 article. If the match is a symbol, that symbol will be funcalled | |
343 from the buffer of the article to be saved with the newsgroup as the | |
344 parameter. If it is a list, it will be evaled in the same buffer. | |
345 | |
346 If this form or function returns a string, this string will be used as | |
347 a possible file name; and if it returns a non-nil list, that list will | |
348 be used as possible file names." | |
349 :group 'gnus-article-saving | |
350 :type '(repeat (choice (list function) | |
351 (cons regexp (repeat string)) | |
352 sexp))) | |
353 | |
354 (defcustom gnus-strict-mime t | |
355 "*If nil, MIME-decode even if there is no Mime-Version header." | |
356 :group 'gnus-article-mime | |
357 :type 'boolean) | |
358 | |
359 (defcustom gnus-show-mime-method 'metamail-buffer | |
360 "Function to process a MIME message. | |
361 The function is called from the article buffer." | |
362 :group 'gnus-article-mime | |
363 :type 'function) | |
364 | |
365 (defcustom gnus-decode-encoded-word-method 'gnus-article-de-quoted-unreadable | |
366 "*Function to decode MIME encoded words. | |
367 The function is called from the article buffer." | |
368 :group 'gnus-article-mime | |
369 :type 'function) | |
370 | |
371 (defcustom gnus-page-delimiter "^\^L" | |
372 "*Regexp describing what to use as article page delimiters. | |
373 The default value is \"^\^L\", which is a form linefeed at the | |
374 beginning of a line." | |
375 :type 'regexp | |
376 :group 'gnus-article-various) | |
377 | |
378 (defcustom gnus-article-mode-line-format "Gnus: %%b %S" | |
379 "*The format specification for the article mode line. | |
380 See `gnus-summary-mode-line-format' for a closer description." | |
381 :type 'string | |
382 :group 'gnus-article-various) | |
383 | |
384 (defcustom gnus-article-mode-hook nil | |
385 "*A hook for Gnus article mode." | |
386 :type 'hook | |
387 :group 'gnus-article-various) | |
388 | |
389 (defcustom gnus-article-menu-hook nil | |
390 "*Hook run after the creation of the article mode menu." | |
391 :type 'hook | |
392 :group 'gnus-article-various) | |
393 | |
394 (defcustom gnus-article-prepare-hook nil | |
395 "*A hook called after an article has been prepared in the article buffer. | |
396 If you want to run a special decoding program like nkf, use this hook." | |
397 :type 'hook | |
398 :group 'gnus-article-various) | |
399 | |
400 (defcustom gnus-article-button-face 'bold | |
401 "Face used for highlighting buttons in the article buffer. | |
402 | |
403 An article button is a piece of text that you can activate by pressing | |
404 `RET' or `mouse-2' above it." | |
405 :type 'face | |
406 :group 'gnus-article-buttons) | |
407 | |
408 (defcustom gnus-article-mouse-face 'highlight | |
409 "Face used for mouse highlighting in the article buffer. | |
410 | |
411 Article buttons will be displayed in this face when the cursor is | |
412 above them." | |
413 :type 'face | |
414 :group 'gnus-article-buttons) | |
415 | |
416 (defcustom gnus-signature-face 'italic | |
417 "Face used for highlighting a signature in the article buffer." | |
418 :type 'face | |
419 :group 'gnus-article-highlight | |
420 :group 'gnus-article-signature) | |
421 | |
422 (defface gnus-header-from-face | |
423 '((((class color) | |
424 (background dark)) | |
425 (:foreground "spring green" :bold t)) | |
426 (((class color) | |
427 (background light)) | |
428 (:foreground "red3" :bold t)) | |
429 (t | |
430 (:bold t :italic t))) | |
431 "Face used for displaying from headers." | |
432 :group 'gnus-article-headers | |
433 :group 'gnus-article-highlight) | |
434 | |
435 (defface gnus-header-subject-face | |
436 '((((class color) | |
437 (background dark)) | |
438 (:foreground "SeaGreen3" :bold t)) | |
439 (((class color) | |
440 (background light)) | |
441 (:foreground "red4" :bold t)) | |
442 (t | |
443 (:bold t :italic t))) | |
444 "Face used for displaying subject headers." | |
445 :group 'gnus-article-headers | |
446 :group 'gnus-article-highlight) | |
447 | |
448 (defface gnus-header-newsgroups-face | |
449 '((((class color) | |
450 (background dark)) | |
451 (:foreground "yellow" :bold t :italic t)) | |
452 (((class color) | |
453 (background light)) | |
454 (:foreground "MidnightBlue" :bold t :italic t)) | |
455 (t | |
456 (:bold t :italic t))) | |
457 "Face used for displaying newsgroups headers." | |
458 :group 'gnus-article-headers | |
459 :group 'gnus-article-highlight) | |
460 | |
461 (defface gnus-header-name-face | |
462 '((((class color) | |
463 (background dark)) | |
464 (:foreground "SeaGreen")) | |
465 (((class color) | |
466 (background light)) | |
467 (:foreground "maroon")) | |
468 (t | |
469 (:bold t))) | |
470 "Face used for displaying header names." | |
471 :group 'gnus-article-headers | |
472 :group 'gnus-article-highlight) | |
473 | |
474 (defface gnus-header-content-face | |
475 '((((class color) | |
476 (background dark)) | |
477 (:foreground "forest green" :italic t)) | |
478 (((class color) | |
479 (background light)) | |
480 (:foreground "indianred4" :italic t)) | |
481 (t | |
482 (:italic t))) "Face used for displaying header content." | |
483 :group 'gnus-article-headers | |
484 :group 'gnus-article-highlight) | |
485 | |
486 (defcustom gnus-header-face-alist | |
487 '(("From" nil gnus-header-from-face) | |
488 ("Subject" nil gnus-header-subject-face) | |
489 ("Newsgroups:.*," nil gnus-header-newsgroups-face) | |
490 ("" gnus-header-name-face gnus-header-content-face)) | |
491 "Controls highlighting of article header. | |
492 | |
493 An alist of the form (HEADER NAME CONTENT). | |
494 | |
495 HEADER is a regular expression which should match the name of an | |
496 header header and NAME and CONTENT are either face names or nil. | |
497 | |
498 The name of each header field will be displayed using the face | |
499 specified by the first element in the list where HEADER match the | |
500 header name and NAME is non-nil. Similarly, the content will be | |
501 displayed by the first non-nil matching CONTENT face." | |
502 :group 'gnus-article-headers | |
503 :group 'gnus-article-highlight | |
504 :type '(repeat (list (regexp :tag "Header") | |
505 (choice :tag "Name" | |
506 (item :tag "skip" nil) | |
507 (face :value default)) | |
508 (choice :tag "Content" | |
509 (item :tag "skip" nil) | |
510 (face :value default))))) | |
511 | |
512 ;;; Internal variables | |
513 | |
514 (defvar gnus-article-mode-syntax-table | |
515 (let ((table (copy-syntax-table text-mode-syntax-table))) | |
516 (modify-syntax-entry ?- "w" table) | |
517 (modify-syntax-entry ?> ")" table) | |
518 (modify-syntax-entry ?< "(" table) | |
519 table) | |
520 "Syntax table used in article mode buffers. | |
521 Initialized from `text-mode-syntax-table.") | |
522 | |
523 (defvar gnus-save-article-buffer nil) | |
524 | |
525 (defvar gnus-article-mode-line-format-alist | |
526 (nconc '((?w (gnus-article-wash-status) ?s)) | |
527 gnus-summary-mode-line-format-alist)) | |
528 | |
529 (defvar gnus-number-of-articles-to-be-saved nil) | |
530 | |
531 (defvar gnus-inhibit-hiding nil) | |
532 | |
533 (defsubst gnus-article-hide-text (b e props) | |
534 "Set text PROPS on the B to E region, extending `intangible' 1 past B." | |
535 (add-text-properties b e props) | |
536 (when (memq 'intangible props) | |
537 (put-text-property | |
538 (max (1- b) (point-min)) | |
539 b 'intangible (cddr (memq 'intangible props))))) | |
540 | |
541 (defsubst gnus-article-unhide-text (b e) | |
542 "Remove hidden text properties from region between B and E." | |
543 (remove-text-properties b e gnus-hidden-properties) | |
544 (when (memq 'intangible gnus-hidden-properties) | |
545 (put-text-property (max (1- b) (point-min)) | |
546 b 'intangible nil))) | |
547 | |
548 (defun gnus-article-hide-text-type (b e type) | |
549 "Hide text of TYPE between B and E." | |
550 (gnus-article-hide-text | |
551 b e (cons 'article-type (cons type gnus-hidden-properties)))) | |
552 | |
553 (defun gnus-article-unhide-text-type (b e type) | |
554 "Hide text of TYPE between B and E." | |
555 (remove-text-properties | |
556 b e (cons 'article-type (cons type gnus-hidden-properties))) | |
557 (when (memq 'intangible gnus-hidden-properties) | |
558 (put-text-property (max (1- b) (point-min)) | |
559 b 'intangible nil))) | |
560 | |
561 (defun gnus-article-hide-text-of-type (type) | |
562 "Hide text of TYPE in the current buffer." | |
563 (save-excursion | |
564 (let ((b (point-min)) | |
565 (e (point-max))) | |
566 (while (setq b (text-property-any b e 'article-type type)) | |
567 (add-text-properties b (incf b) gnus-hidden-properties))))) | |
568 | |
569 (defun gnus-article-delete-text-of-type (type) | |
570 "Delete text of TYPE in the current buffer." | |
571 (save-excursion | |
572 (let ((e (point-min)) | |
573 b) | |
574 (while (setq b (text-property-any e (point-max) 'article-type type)) | |
575 (setq e (text-property-not-all b (point-max) 'article-type type)) | |
576 (delete-region b e))))) | |
577 | |
578 (defun gnus-article-delete-invisible-text () | |
579 "Delete all invisible text in the current buffer." | |
580 (save-excursion | |
581 (let ((e (point-min)) | |
582 b) | |
583 (while (setq b (text-property-any e (point-max) 'invisible t)) | |
584 (setq e (text-property-not-all b (point-max) 'invisible t)) | |
585 (delete-region b e))))) | |
586 | |
587 (defun gnus-article-text-type-exists-p (type) | |
588 "Say whether any text of type TYPE exists in the buffer." | |
589 (text-property-any (point-min) (point-max) 'article-type type)) | |
590 | |
591 (defsubst gnus-article-header-rank () | |
592 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'." | |
593 (let ((list gnus-sorted-header-list) | |
594 (i 0)) | |
595 (while list | |
596 (when (looking-at (car list)) | |
597 (setq list nil)) | |
598 (setq list (cdr list)) | |
599 (incf i)) | |
600 i)) | |
601 | |
602 (defun article-hide-headers (&optional arg delete) | |
603 "Toggle whether to hide unwanted headers and possibly sort them as well. | |
604 If given a negative prefix, always show; if given a positive prefix, | |
605 always hide." | |
606 (interactive (gnus-article-hidden-arg)) | |
607 (if (gnus-article-check-hidden-text 'headers arg) | |
608 ;; Show boring headers as well. | |
609 (gnus-article-show-hidden-text 'boring-headers) | |
610 ;; This function might be inhibited. | |
611 (unless gnus-inhibit-hiding | |
612 (save-excursion | |
613 (save-restriction | |
614 (let ((buffer-read-only nil) | |
615 (props (nconc (list 'article-type 'headers) | |
616 gnus-hidden-properties)) | |
617 (max (1+ (length gnus-sorted-header-list))) | |
618 (ignored (when (not gnus-visible-headers) | |
619 (cond ((stringp gnus-ignored-headers) | |
620 gnus-ignored-headers) | |
621 ((listp gnus-ignored-headers) | |
622 (mapconcat 'identity gnus-ignored-headers | |
623 "\\|"))))) | |
624 (visible | |
625 (cond ((stringp gnus-visible-headers) | |
626 gnus-visible-headers) | |
627 ((and gnus-visible-headers | |
628 (listp gnus-visible-headers)) | |
629 (mapconcat 'identity gnus-visible-headers "\\|")))) | |
630 (inhibit-point-motion-hooks t) | |
631 want-list beg) | |
632 ;; First we narrow to just the headers. | |
633 (widen) | |
634 (goto-char (point-min)) | |
635 ;; Hide any "From " lines at the beginning of (mail) articles. | |
636 (while (looking-at "From ") | |
637 (forward-line 1)) | |
638 (unless (bobp) | |
639 (if delete | |
640 (delete-region (point-min) (point)) | |
641 (gnus-article-hide-text (point-min) (point) props))) | |
642 ;; Then treat the rest of the header lines. | |
643 (narrow-to-region | |
644 (point) | |
645 (if (search-forward "\n\n" nil t) ; if there's a body | |
646 (progn (forward-line -1) (point)) | |
647 (point-max))) | |
648 ;; Then we use the two regular expressions | |
649 ;; `gnus-ignored-headers' and `gnus-visible-headers' to | |
650 ;; select which header lines is to remain visible in the | |
651 ;; article buffer. | |
652 (goto-char (point-min)) | |
653 (while (re-search-forward "^[^ \t]*:" nil t) | |
654 (beginning-of-line) | |
655 ;; Mark the rank of the header. | |
656 (put-text-property | |
657 (point) (1+ (point)) 'message-rank | |
658 (if (or (and visible (looking-at visible)) | |
659 (and ignored | |
660 (not (looking-at ignored)))) | |
661 (gnus-article-header-rank) | |
662 (+ 2 max))) | |
663 (forward-line 1)) | |
664 (message-sort-headers-1) | |
665 (when (setq beg (text-property-any | |
666 (point-min) (point-max) 'message-rank (+ 2 max))) | |
667 ;; We make the unwanted headers invisible. | |
668 (if delete | |
669 (delete-region beg (point-max)) | |
670 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>. | |
671 (gnus-article-hide-text-type beg (point-max) 'headers)) | |
672 ;; Work around XEmacs lossage. | |
673 (put-text-property (point-min) beg 'invisible nil)))))))) | |
674 | |
675 (defun article-hide-boring-headers (&optional arg) | |
676 "Toggle hiding of headers that aren't very interesting. | |
677 If given a negative prefix, always show; if given a positive prefix, | |
678 always hide." | |
679 (interactive (gnus-article-hidden-arg)) | |
680 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg)) | |
681 (not gnus-show-all-headers)) | |
682 (save-excursion | |
683 (save-restriction | |
684 (let ((buffer-read-only nil) | |
685 (list gnus-boring-article-headers) | |
686 (inhibit-point-motion-hooks t) | |
687 elem) | |
688 (nnheader-narrow-to-headers) | |
689 (while list | |
690 (setq elem (pop list)) | |
691 (goto-char (point-min)) | |
692 (cond | |
693 ;; Hide empty headers. | |
694 ((eq elem 'empty) | |
695 (while (re-search-forward "^[^:]+:[ \t]*\n[^ \t]" nil t) | |
696 (forward-line -1) | |
697 (gnus-article-hide-text-type | |
698 (progn (beginning-of-line) (point)) | |
699 (progn | |
700 (end-of-line) | |
701 (if (re-search-forward "^[^ \t]" nil t) | |
702 (match-beginning 0) | |
703 (point-max))) | |
704 'boring-headers))) | |
705 ;; Hide boring Newsgroups header. | |
706 ((eq elem 'newsgroups) | |
707 (when (equal (gnus-fetch-field "newsgroups") | |
708 (gnus-group-real-name | |
709 (if (boundp 'gnus-newsgroup-name) | |
710 gnus-newsgroup-name | |
711 ""))) | |
712 (gnus-article-hide-header "newsgroups"))) | |
713 ((eq elem 'followup-to) | |
714 (when (equal (message-fetch-field "followup-to") | |
715 (message-fetch-field "newsgroups")) | |
716 (gnus-article-hide-header "followup-to"))) | |
717 ((eq elem 'reply-to) | |
718 (let ((from (message-fetch-field "from")) | |
719 (reply-to (message-fetch-field "reply-to"))) | |
720 (when (and | |
721 from reply-to | |
722 (ignore-errors | |
723 (equal | |
724 (nth 1 (mail-extract-address-components from)) | |
725 (nth 1 (mail-extract-address-components reply-to))))) | |
726 (gnus-article-hide-header "reply-to")))) | |
727 ((eq elem 'date) | |
728 (let ((date (message-fetch-field "date"))) | |
729 (when (and date | |
730 (< (gnus-days-between (current-time-string) date) | |
731 4)) | |
732 (gnus-article-hide-header "date"))))))))))) | |
733 | |
734 (defun gnus-article-hide-header (header) | |
735 (save-excursion | |
736 (goto-char (point-min)) | |
737 (when (re-search-forward (concat "^" header ":") nil t) | |
738 (gnus-article-hide-text-type | |
739 (progn (beginning-of-line) (point)) | |
740 (progn | |
741 (end-of-line) | |
742 (if (re-search-forward "^[^ \t]" nil t) | |
743 (match-beginning 0) | |
744 (point-max))) | |
745 'boring-headers)))) | |
746 | |
747 ;; Written by Per Abrahamsen <amanda@iesd.auc.dk>. | |
748 (defun article-treat-overstrike () | |
749 "Translate overstrikes into bold text." | |
750 (interactive) | |
751 (save-excursion | |
752 (goto-char (point-min)) | |
753 (when (search-forward "\n\n" nil t) | |
754 (let ((buffer-read-only nil)) | |
755 (while (search-forward "\b" nil t) | |
756 (let ((next (following-char)) | |
757 (previous (char-after (- (point) 2)))) | |
758 ;; We do the boldification/underlining by hiding the | |
759 ;; overstrikes and putting the proper text property | |
760 ;; on the letters. | |
761 (cond | |
762 ((eq next previous) | |
763 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike) | |
764 (put-text-property (point) (1+ (point)) 'face 'bold)) | |
765 ((eq next ?_) | |
766 (gnus-article-hide-text-type | |
767 (1- (point)) (1+ (point)) 'overstrike) | |
768 (put-text-property | |
769 (- (point) 2) (1- (point)) 'face 'underline)) | |
770 ((eq previous ?_) | |
771 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike) | |
772 (put-text-property | |
773 (point) (1+ (point)) 'face 'underline))))))))) | |
774 | |
775 (defun article-fill () | |
776 "Format too long lines." | |
777 (interactive) | |
778 (save-excursion | |
779 (let ((buffer-read-only nil)) | |
780 (widen) | |
781 (goto-char (point-min)) | |
782 (search-forward "\n\n" nil t) | |
783 (end-of-line 1) | |
784 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$") | |
785 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?") | |
786 (adaptive-fill-mode t)) | |
787 (while (not (eobp)) | |
788 (and (>= (current-column) (min fill-column (window-width))) | |
789 (/= (preceding-char) ?:) | |
790 (fill-paragraph nil)) | |
791 (end-of-line 2)))))) | |
792 | |
793 (defun article-remove-cr () | |
794 "Remove carriage returns from an article." | |
795 (interactive) | |
796 (save-excursion | |
797 (let ((buffer-read-only nil)) | |
798 (goto-char (point-min)) | |
799 (while (search-forward "\r" nil t) | |
800 (replace-match "" t t))))) | |
801 | |
802 (defun article-remove-trailing-blank-lines () | |
803 "Remove all trailing blank lines from the article." | |
804 (interactive) | |
805 (save-excursion | |
806 (let ((buffer-read-only nil)) | |
807 (goto-char (point-max)) | |
808 (delete-region | |
809 (point) | |
810 (progn | |
811 (while (and (not (bobp)) | |
812 (looking-at "^[ \t]*$")) | |
813 (forward-line -1)) | |
814 (forward-line 1) | |
815 (point)))))) | |
816 | |
817 (defun article-display-x-face (&optional force) | |
818 "Look for an X-Face header and display it if present." | |
819 (interactive (list 'force)) | |
820 (save-excursion | |
821 ;; Delete the old process, if any. | |
822 (when (process-status "article-x-face") | |
823 (delete-process "article-x-face")) | |
824 (let ((inhibit-point-motion-hooks t) | |
825 (case-fold-search nil) | |
826 from) | |
827 (save-restriction | |
828 (nnheader-narrow-to-headers) | |
829 (setq from (message-fetch-field "from")) | |
830 (goto-char (point-min)) | |
831 (when (and gnus-article-x-face-command | |
832 (or force | |
833 ;; Check whether this face is censored. | |
834 (not gnus-article-x-face-too-ugly) | |
835 (and gnus-article-x-face-too-ugly from | |
836 (not (string-match gnus-article-x-face-too-ugly | |
837 from)))) | |
838 ;; Has to be present. | |
839 (re-search-forward "^X-Face: " nil t)) | |
840 ;; We now have the area of the buffer where the X-Face is stored. | |
841 (let ((beg (point)) | |
842 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t)))) | |
843 ;; We display the face. | |
844 (if (symbolp gnus-article-x-face-command) | |
845 ;; The command is a lisp function, so we call it. | |
846 (if (gnus-functionp gnus-article-x-face-command) | |
847 (funcall gnus-article-x-face-command beg end) | |
848 (error "%s is not a function" gnus-article-x-face-command)) | |
849 ;; The command is a string, so we interpret the command | |
850 ;; as a, well, command, and fork it off. | |
851 (let ((process-connection-type nil)) | |
852 (process-kill-without-query | |
853 (start-process | |
854 "article-x-face" nil shell-file-name shell-command-switch | |
855 gnus-article-x-face-command)) | |
856 (process-send-region "article-x-face" beg end) | |
857 (process-send-eof "article-x-face"))))))))) | |
858 | |
859 (defalias 'gnus-decode-rfc1522 'article-decode-rfc1522) | |
860 (defalias 'gnus-article-decode-rfc1522 'article-decode-rfc1522) | |
861 (defun article-decode-rfc1522 () | |
862 "Hack to remove QP encoding from headers." | |
863 (let ((case-fold-search t) | |
864 (inhibit-point-motion-hooks t) | |
865 (buffer-read-only nil) | |
866 string) | |
867 (save-restriction | |
868 (narrow-to-region | |
869 (goto-char (point-min)) | |
870 (or (search-forward "\n\n" nil t) (point-max))) | |
871 (goto-char (point-min)) | |
872 (while (re-search-forward | |
873 "=\\?iso-8859-1\\?q\\?\\([^?\t\n]*\\)\\?=" nil t) | |
874 (setq string (match-string 1)) | |
875 (save-restriction | |
876 (narrow-to-region (match-beginning 0) (match-end 0)) | |
877 (delete-region (point-min) (point-max)) | |
878 (insert string) | |
879 (article-mime-decode-quoted-printable | |
880 (goto-char (point-min)) (point-max)) | |
881 (subst-char-in-region (point-min) (point-max) ?_ ? ) | |
882 (goto-char (point-max))) | |
883 (goto-char (point-min)))))) | |
884 | |
885 (defun article-de-quoted-unreadable (&optional force) | |
886 "Do a naive translation of a quoted-printable-encoded article. | |
887 This is in no way, shape or form meant as a replacement for real MIME | |
888 processing, but is simply a stop-gap measure until MIME support is | |
889 written. | |
890 If FORCE, decode the article whether it is marked as quoted-printable | |
891 or not." | |
892 (interactive (list 'force)) | |
893 (save-excursion | |
894 (let ((case-fold-search t) | |
895 (buffer-read-only nil) | |
896 (type (gnus-fetch-field "content-transfer-encoding"))) | |
897 (gnus-article-decode-rfc1522) | |
898 (when (or force | |
899 (and type (string-match "quoted-printable" (downcase type)))) | |
900 (goto-char (point-min)) | |
901 (search-forward "\n\n" nil 'move) | |
902 (article-mime-decode-quoted-printable (point) (point-max)))))) | |
903 | |
904 (defun article-mime-decode-quoted-printable-buffer () | |
905 "Decode Quoted-Printable in the current buffer." | |
906 (article-mime-decode-quoted-printable (point-min) (point-max))) | |
907 | |
908 (defun article-mime-decode-quoted-printable (from to) | |
909 "Decode Quoted-Printable in the region between FROM and TO." | |
910 (interactive "r") | |
911 (goto-char from) | |
912 (while (search-forward "=" to t) | |
913 (cond ((eq (following-char) ?\n) | |
914 (delete-char -1) | |
915 (delete-char 1)) | |
916 ((looking-at "[0-9A-F][0-9A-F]") | |
917 (subst-char-in-region | |
918 (1- (point)) (point) ?= | |
919 (hexl-hex-string-to-integer | |
920 (buffer-substring (point) (+ 2 (point))))) | |
921 (delete-char 2)) | |
922 ((looking-at "=") | |
923 (delete-char 1)) | |
924 ((gnus-message 3 "Malformed MIME quoted-printable message"))))) | |
925 | |
926 (defun article-hide-pgp (&optional arg) | |
927 "Toggle hiding of any PGP headers and signatures in the current article. | |
928 If given a negative prefix, always show; if given a positive prefix, | |
929 always hide." | |
930 (interactive (gnus-article-hidden-arg)) | |
931 (unless (gnus-article-check-hidden-text 'pgp arg) | |
932 (save-excursion | |
933 (let ((inhibit-point-motion-hooks t) | |
934 buffer-read-only beg end) | |
935 (widen) | |
936 (goto-char (point-min)) | |
937 ;; Hide the "header". | |
938 (when (search-forward "\n-----BEGIN PGP SIGNED MESSAGE-----\n" nil t) | |
939 (gnus-article-hide-text-type (1+ (match-beginning 0)) | |
940 (match-end 0) 'pgp)) | |
941 (setq beg (point)) | |
942 ;; Hide the actual signature. | |
943 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t) | |
944 (setq end (1+ (match-beginning 0))) | |
945 (gnus-article-hide-text-type | |
946 end | |
947 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t) | |
948 (match-end 0) | |
949 ;; Perhaps we shouldn't hide to the end of the buffer | |
950 ;; if there is no end to the signature? | |
951 (point-max)) | |
952 'pgp)) | |
953 ;; Hide "- " PGP quotation markers. | |
954 (when (and beg end) | |
955 (narrow-to-region beg end) | |
956 (goto-char (point-min)) | |
957 (while (re-search-forward "^- " nil t) | |
958 (gnus-article-hide-text-type | |
959 (match-beginning 0) (match-end 0) 'pgp)) | |
960 (widen)))))) | |
961 | |
962 (defun article-hide-pem (&optional arg) | |
963 "Toggle hiding of any PEM headers and signatures in the current article. | |
964 If given a negative prefix, always show; if given a positive prefix, | |
965 always hide." | |
966 (interactive (gnus-article-hidden-arg)) | |
967 (unless (gnus-article-check-hidden-text 'pem arg) | |
968 (save-excursion | |
969 (let (buffer-read-only end) | |
970 (widen) | |
971 (goto-char (point-min)) | |
972 ;; hide the horrendously ugly "header". | |
973 (and (search-forward "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n" | |
974 nil | |
975 t) | |
976 (setq end (1+ (match-beginning 0))) | |
977 (gnus-article-hide-text-type | |
978 end | |
979 (if (search-forward "\n\n" nil t) | |
980 (match-end 0) | |
981 (point-max)) | |
982 'pem)) | |
983 ;; hide the trailer as well | |
984 (and (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n" | |
985 nil | |
986 t) | |
987 (gnus-article-hide-text-type | |
988 (match-beginning 0) (match-end 0) 'pem)))))) | |
989 | |
990 (defun article-hide-signature (&optional arg) | |
991 "Hide the signature in the current article. | |
992 If given a negative prefix, always show; if given a positive prefix, | |
993 always hide." | |
994 (interactive (gnus-article-hidden-arg)) | |
995 (unless (gnus-article-check-hidden-text 'signature arg) | |
996 (save-excursion | |
997 (save-restriction | |
998 (let ((buffer-read-only nil)) | |
999 (when (gnus-article-narrow-to-signature) | |
1000 (gnus-article-hide-text-type | |
1001 (point-min) (point-max) 'signature))))))) | |
1002 | |
1003 (defun article-strip-leading-blank-lines () | |
1004 "Remove all blank lines from the beginning of the article." | |
1005 (interactive) | |
1006 (save-excursion | |
1007 (let ((inhibit-point-motion-hooks t) | |
1008 buffer-read-only) | |
1009 (goto-char (point-min)) | |
1010 (when (search-forward "\n\n" nil t) | |
1011 (while (and (not (eobp)) | |
1012 (looking-at "[ \t]*$")) | |
1013 (gnus-delete-line)))))) | |
1014 | |
1015 (defun article-strip-multiple-blank-lines () | |
1016 "Replace consecutive blank lines with one empty line." | |
1017 (interactive) | |
1018 (save-excursion | |
1019 (let ((inhibit-point-motion-hooks t) | |
1020 buffer-read-only) | |
1021 ;; First make all blank lines empty. | |
1022 (goto-char (point-min)) | |
1023 (search-forward "\n\n" nil t) | |
1024 (while (re-search-forward "^[ \t]+$" nil t) | |
1025 (replace-match "" nil t)) | |
1026 ;; Then replace multiple empty lines with a single empty line. | |
1027 (goto-char (point-min)) | |
1028 (search-forward "\n\n" nil t) | |
1029 (while (re-search-forward "\n\n\n+" nil t) | |
1030 (replace-match "\n\n" t t))))) | |
1031 | |
1032 (defun article-strip-leading-space () | |
1033 "Remove all white space from the beginning of the lines in the article." | |
1034 (interactive) | |
1035 (save-excursion | |
1036 (let ((inhibit-point-motion-hooks t) | |
1037 buffer-read-only) | |
1038 (goto-char (point-min)) | |
1039 (search-forward "\n\n" nil t) | |
1040 (while (re-search-forward "^[ \t]+" nil t) | |
1041 (replace-match "" t t))))) | |
1042 | |
1043 (defun article-strip-blank-lines () | |
1044 "Strip leading, trailing and multiple blank lines." | |
1045 (interactive) | |
1046 (article-strip-leading-blank-lines) | |
1047 (article-remove-trailing-blank-lines) | |
1048 (article-strip-multiple-blank-lines)) | |
1049 | |
1050 (defvar mime::preview/content-list) | |
1051 (defvar mime::preview-content-info/point-min) | |
1052 (defun gnus-article-narrow-to-signature () | |
1053 "Narrow to the signature; return t if a signature is found, else nil." | |
1054 (widen) | |
1055 (when (and (boundp 'mime::preview/content-list) | |
1056 mime::preview/content-list) | |
1057 ;; We have a MIMEish article, so we use the MIME data to narrow. | |
1058 (let ((pcinfo (car (last mime::preview/content-list)))) | |
1059 (ignore-errors | |
1060 (narrow-to-region | |
1061 (funcall (intern "mime::preview-content-info/point-min") pcinfo) | |
1062 (point-max))))) | |
1063 | |
1064 (when (gnus-article-search-signature) | |
1065 (forward-line 1) | |
1066 ;; Check whether we have some limits to what we consider | |
1067 ;; to be a signature. | |
1068 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit | |
1069 (list gnus-signature-limit))) | |
1070 limit limited) | |
1071 (while (setq limit (pop limits)) | |
1072 (if (or (and (integerp limit) | |
1073 (< (- (point-max) (point)) limit)) | |
1074 (and (floatp limit) | |
1075 (< (count-lines (point) (point-max)) limit)) | |
1076 (and (gnus-functionp limit) | |
1077 (funcall limit)) | |
1078 (and (stringp limit) | |
1079 (not (re-search-forward limit nil t)))) | |
1080 () ; This limit did not succeed. | |
1081 (setq limited t | |
1082 limits nil))) | |
1083 (unless limited | |
1084 (narrow-to-region (point) (point-max)) | |
1085 t)))) | |
1086 | |
1087 (defun gnus-article-search-signature () | |
1088 "Search the current buffer for the signature separator. | |
1089 Put point at the beginning of the signature separator." | |
1090 (let ((cur (point))) | |
1091 (goto-char (point-max)) | |
1092 (if (if (stringp gnus-signature-separator) | |
1093 (re-search-backward gnus-signature-separator nil t) | |
1094 (let ((seps gnus-signature-separator)) | |
1095 (while (and seps | |
1096 (not (re-search-backward (car seps) nil t))) | |
1097 (pop seps)) | |
1098 seps)) | |
1099 t | |
1100 (goto-char cur) | |
1101 nil))) | |
1102 | |
1103 (eval-and-compile | |
1104 (autoload 'w3-parse-buffer "w3-parse")) | |
1105 | |
1106 (defun gnus-article-treat-html () | |
1107 "Render HTML." | |
1108 (interactive) | |
1109 (let ((cbuf (current-buffer))) | |
1110 (set-buffer gnus-article-buffer) | |
1111 (let (buf buffer-read-only b e) | |
1112 (goto-char (point-min)) | |
1113 (narrow-to-region | |
1114 (if (search-forward "\n\n" nil t) | |
1115 (setq b (point)) | |
1116 (point-max)) | |
1117 (setq e (point-max))) | |
1118 (nnheader-temp-write nil | |
1119 (insert-buffer-substring gnus-article-buffer b e) | |
1120 (save-window-excursion | |
1121 (setq buf (car (w3-parse-buffer (current-buffer)))))) | |
1122 (when buf | |
1123 (delete-region (point-min) (point-max)) | |
1124 (insert-buffer-substring buf) | |
1125 (kill-buffer buf)) | |
1126 (widen) | |
1127 (goto-char (point-min)) | |
1128 (set-window-start (get-buffer-window (current-buffer)) (point-min)) | |
1129 (set-buffer cbuf)))) | |
1130 | |
1131 (defun gnus-article-hidden-arg () | |
1132 "Return the current prefix arg as a number, or 0 if no prefix." | |
1133 (list (if current-prefix-arg | |
1134 (prefix-numeric-value current-prefix-arg) | |
1135 0))) | |
1136 | |
1137 (defun gnus-article-check-hidden-text (type arg) | |
1138 "Return nil if hiding is necessary. | |
1139 Arg can be nil or a number. Nil and positive means hide, negative | |
1140 means show, 0 means toggle." | |
1141 (save-excursion | |
1142 (save-restriction | |
1143 (widen) | |
1144 (let ((hide (gnus-article-hidden-text-p type))) | |
1145 (cond | |
1146 ((or (null arg) | |
1147 (> arg 0)) | |
1148 nil) | |
1149 ((< arg 0) | |
1150 (gnus-article-show-hidden-text type)) | |
1151 (t | |
1152 (if (eq hide 'hidden) | |
1153 (gnus-article-show-hidden-text type) | |
1154 nil))))))) | |
1155 | |
1156 (defun gnus-article-hidden-text-p (type) | |
1157 "Say whether the current buffer contains hidden text of type TYPE." | |
1158 (let ((start (point-min)) | |
1159 (pos (text-property-any (point-min) (point-max) 'article-type type))) | |
1160 (while (and pos | |
1161 (not (get-text-property pos 'invisible))) | |
1162 (setq pos | |
1163 (text-property-any (1+ pos) (point-max) 'article-type type))) | |
1164 (if pos | |
1165 'hidden | |
1166 'shown))) | |
1167 | |
1168 (defun gnus-article-show-hidden-text (type &optional hide) | |
1169 "Show all hidden text of type TYPE. | |
1170 If HIDE, hide the text instead." | |
1171 (save-excursion | |
1172 (let ((buffer-read-only nil) | |
1173 (inhibit-point-motion-hooks t) | |
1174 (end (point-min)) | |
1175 beg) | |
1176 (while (setq beg (text-property-any end (point-max) 'article-type type)) | |
1177 (goto-char beg) | |
1178 (setq end (or | |
1179 (text-property-not-all beg (point-max) 'article-type type) | |
1180 (point-max))) | |
1181 (if hide | |
1182 (gnus-article-hide-text beg end gnus-hidden-properties) | |
1183 (gnus-article-unhide-text beg end)) | |
1184 (goto-char end)) | |
1185 t))) | |
1186 | |
1187 (defconst article-time-units | |
1188 `((year . ,(* 365.25 24 60 60)) | |
1189 (week . ,(* 7 24 60 60)) | |
1190 (day . ,(* 24 60 60)) | |
1191 (hour . ,(* 60 60)) | |
1192 (minute . 60) | |
1193 (second . 1)) | |
1194 "Mapping from time units to seconds.") | |
1195 | |
1196 (defun article-date-ut (&optional type highlight header) | |
1197 "Convert DATE date to universal time in the current article. | |
1198 If TYPE is `local', convert to local time; if it is `lapsed', output | |
1199 how much time has lapsed since DATE." | |
1200 (interactive (list 'ut t)) | |
1201 (let* ((header (or header | |
1202 (mail-header-date gnus-current-headers) | |
1203 (message-fetch-field "date") | |
1204 "")) | |
1205 (date (if (vectorp header) (mail-header-date header) | |
1206 header)) | |
1207 (date-regexp "^Date:[ \t]\\|^X-Sent:[ \t]") | |
1208 (inhibit-point-motion-hooks t) | |
1209 bface eface) | |
1210 (when (and date (not (string= date ""))) | |
1211 (save-excursion | |
1212 (save-restriction | |
1213 (nnheader-narrow-to-headers) | |
1214 (let ((buffer-read-only nil)) | |
1215 ;; Delete any old Date headers. | |
1216 (if (re-search-forward date-regexp nil t) | |
1217 (progn | |
1218 (setq bface (get-text-property (gnus-point-at-bol) 'face) | |
1219 eface (get-text-property (1- (gnus-point-at-eol)) | |
1220 'face)) | |
1221 (message-remove-header date-regexp t) | |
1222 (beginning-of-line)) | |
1223 (goto-char (point-max))) | |
1224 (insert (article-make-date-line date type)) | |
1225 ;; Do highlighting. | |
1226 (forward-line -1) | |
1227 (when (looking-at "\\([^:]+\\): *\\(.*\\)$") | |
1228 (put-text-property (match-beginning 1) (match-end 1) | |
1229 'face bface) | |
1230 (put-text-property (match-beginning 2) (match-end 2) | |
1231 'face eface)))))))) | |
1232 | |
1233 (defun article-make-date-line (date type) | |
1234 "Return a DATE line of TYPE." | |
1235 (cond | |
1236 ;; Convert to the local timezone. We have to slap a | |
1237 ;; `condition-case' round the calls to the timezone | |
1238 ;; functions since they aren't particularly resistant to | |
1239 ;; buggy dates. | |
1240 ((eq type 'local) | |
1241 (concat "Date: " (condition-case () | |
1242 (timezone-make-date-arpa-standard date) | |
1243 (error date)) | |
1244 "\n")) | |
1245 ;; Convert to Universal Time. | |
1246 ((eq type 'ut) | |
1247 (concat "Date: " | |
1248 (condition-case () | |
1249 (timezone-make-date-arpa-standard date nil "UT") | |
1250 (error date)) | |
1251 "\n")) | |
1252 ;; Get the original date from the article. | |
1253 ((eq type 'original) | |
1254 (concat "Date: " date "\n")) | |
1255 ;; Let the user define the format. | |
1256 ((eq type 'user) | |
1257 (concat | |
1258 "Date: " | |
1259 (format-time-string gnus-article-time-format | |
1260 (ignore-errors | |
1261 (gnus-encode-date | |
1262 (timezone-make-date-arpa-standard | |
1263 date nil "UT")))) | |
1264 "\n")) | |
1265 ;; Do an X-Sent lapsed format. | |
1266 ((eq type 'lapsed) | |
1267 ;; If the date is seriously mangled, the timezone functions are | |
1268 ;; liable to bug out, so we ignore all errors. | |
1269 (let* ((now (current-time)) | |
1270 (real-time | |
1271 (ignore-errors | |
1272 (gnus-time-minus | |
1273 (gnus-encode-date | |
1274 (timezone-make-date-arpa-standard | |
1275 (current-time-string now) | |
1276 (current-time-zone now) "UT")) | |
1277 (gnus-encode-date | |
1278 (timezone-make-date-arpa-standard | |
1279 date nil "UT"))))) | |
1280 (real-sec (and real-time | |
1281 (+ (* (float (car real-time)) 65536) | |
1282 (cadr real-time)))) | |
1283 (sec (and real-time (abs real-sec))) | |
1284 num prev) | |
1285 (cond | |
1286 ((null real-time) | |
1287 "X-Sent: Unknown\n") | |
1288 ((zerop sec) | |
1289 "X-Sent: Now\n") | |
1290 (t | |
1291 (concat | |
1292 "X-Sent: " | |
1293 ;; This is a bit convoluted, but basically we go | |
1294 ;; through the time units for years, weeks, etc, | |
1295 ;; and divide things to see whether that results | |
1296 ;; in positive answers. | |
1297 (mapconcat | |
1298 (lambda (unit) | |
1299 (if (zerop (setq num (ffloor (/ sec (cdr unit))))) | |
1300 ;; The (remaining) seconds are too few to | |
1301 ;; be divided into this time unit. | |
1302 "" | |
1303 ;; It's big enough, so we output it. | |
1304 (setq sec (- sec (* num (cdr unit)))) | |
1305 (prog1 | |
1306 (concat (if prev ", " "") (int-to-string | |
1307 (floor num)) | |
1308 " " (symbol-name (car unit)) | |
1309 (if (> num 1) "s" "")) | |
1310 (setq prev t)))) | |
1311 article-time-units "") | |
1312 ;; If dates are odd, then it might appear like the | |
1313 ;; article was sent in the future. | |
1314 (if (> real-sec 0) | |
1315 " ago\n" | |
1316 " in the future\n")))))) | |
1317 (t | |
1318 (error "Unknown conversion type: %s" type)))) | |
1319 | |
1320 (defun article-date-local (&optional highlight) | |
1321 "Convert the current article date to the local timezone." | |
1322 (interactive (list t)) | |
1323 (article-date-ut 'local highlight)) | |
1324 | |
1325 (defun article-date-original (&optional highlight) | |
1326 "Convert the current article date to what it was originally. | |
1327 This is only useful if you have used some other date conversion | |
1328 function and want to see what the date was before converting." | |
1329 (interactive (list t)) | |
1330 (article-date-ut 'original highlight)) | |
1331 | |
1332 (defun article-date-lapsed (&optional highlight) | |
1333 "Convert the current article date to time lapsed since it was sent." | |
1334 (interactive (list t)) | |
1335 (article-date-ut 'lapsed highlight)) | |
1336 | |
1337 (defun article-date-user (&optional highlight) | |
1338 "Convert the current article date to the user-defined format. | |
1339 This format is defined by the `gnus-article-time-format' variable." | |
1340 (interactive (list t)) | |
1341 (article-date-ut 'user highlight)) | |
1342 | |
1343 (defun article-show-all () | |
1344 "Show all hidden text in the article buffer." | |
1345 (interactive) | |
1346 (save-excursion | |
1347 (let ((buffer-read-only nil)) | |
1348 (gnus-article-unhide-text (point-min) (point-max))))) | |
1349 | |
1350 (defun article-emphasize (&optional arg) | |
1351 "Emphasize text according to `gnus-emphasis-alist'." | |
1352 (interactive (gnus-article-hidden-arg)) | |
1353 (unless (gnus-article-check-hidden-text 'emphasis arg) | |
1354 (save-excursion | |
1355 (let ((alist gnus-emphasis-alist) | |
1356 (buffer-read-only nil) | |
1357 (props (append '(article-type emphasis) | |
1358 gnus-hidden-properties)) | |
1359 regexp elem beg invisible visible face) | |
1360 (goto-char (point-min)) | |
1361 (search-forward "\n\n" nil t) | |
1362 (setq beg (point)) | |
1363 (while (setq elem (pop alist)) | |
1364 (goto-char beg) | |
1365 (setq regexp (car elem) | |
1366 invisible (nth 1 elem) | |
1367 visible (nth 2 elem) | |
1368 face (nth 3 elem)) | |
1369 (while (re-search-forward regexp nil t) | |
1370 (when (and (match-beginning visible) (match-beginning invisible)) | |
1371 (gnus-article-hide-text | |
1372 (match-beginning invisible) (match-end invisible) props) | |
1373 (gnus-article-unhide-text-type | |
1374 (match-beginning visible) (match-end visible) 'emphasis) | |
1375 (gnus-put-text-property-excluding-newlines | |
1376 (match-beginning visible) (match-end visible) 'face face) | |
1377 (goto-char (match-end invisible))))))))) | |
1378 | |
1379 (defvar gnus-summary-article-menu) | |
1380 (defvar gnus-summary-post-menu) | |
1381 | |
1382 ;;; Saving functions. | |
1383 | |
1384 (defun gnus-article-save (save-buffer file &optional num) | |
1385 "Save the currently selected article." | |
1386 (unless gnus-save-all-headers | |
1387 ;; Remove headers according to `gnus-saved-headers'. | |
1388 (let ((gnus-visible-headers | |
1389 (or gnus-saved-headers gnus-visible-headers)) | |
1390 (gnus-article-buffer save-buffer)) | |
1391 (gnus-article-hide-headers 1 t))) | |
1392 (save-window-excursion | |
1393 (if (not gnus-default-article-saver) | |
1394 (error "No default saver is defined.") | |
1395 ;; !!! Magic! The saving functions all save | |
1396 ;; `gnus-original-article-buffer' (or so they think), but we | |
1397 ;; bind that variable to our save-buffer. | |
1398 (set-buffer gnus-article-buffer) | |
1399 (let* ((gnus-save-article-buffer save-buffer) | |
1400 (filename | |
1401 (cond | |
1402 ((not gnus-prompt-before-saving) 'default) | |
1403 ((eq gnus-prompt-before-saving 'always) nil) | |
1404 (t file))) | |
1405 (gnus-number-of-articles-to-be-saved | |
1406 (when (eq gnus-prompt-before-saving t) | |
1407 num))) ; Magic | |
1408 (set-buffer gnus-summary-buffer) | |
1409 (funcall gnus-default-article-saver filename))))) | |
1410 | |
1411 (defun gnus-read-save-file-name (prompt &optional filename | |
1412 function group headers variable) | |
1413 (let ((default-name | |
1414 (funcall function group headers (symbol-value variable))) | |
1415 result) | |
1416 (setq | |
1417 result | |
1418 (cond | |
1419 ((eq filename 'default) | |
1420 default-name) | |
1421 ((eq filename t) | |
1422 default-name) | |
1423 (filename filename) | |
1424 (t | |
1425 (let* ((split-name (gnus-get-split-value gnus-split-methods)) | |
1426 (prompt | |
1427 (format prompt | |
1428 (if (and gnus-number-of-articles-to-be-saved | |
1429 (> gnus-number-of-articles-to-be-saved 1)) | |
1430 (format "these %d articles" | |
1431 gnus-number-of-articles-to-be-saved) | |
1432 "this article"))) | |
1433 (file | |
1434 ;; Let the split methods have their say. | |
1435 (cond | |
1436 ;; No split name was found. | |
1437 ((null split-name) | |
1438 (read-file-name | |
1439 (concat prompt " (default " | |
1440 (file-name-nondirectory default-name) ") ") | |
1441 (file-name-directory default-name) | |
1442 default-name)) | |
1443 ;; A single group name is returned. | |
1444 ((stringp split-name) | |
1445 (setq default-name | |
1446 (funcall function split-name headers | |
1447 (symbol-value variable))) | |
1448 (read-file-name | |
1449 (concat prompt " (default " | |
1450 (file-name-nondirectory default-name) ") ") | |
1451 (file-name-directory default-name) | |
1452 default-name)) | |
1453 ;; A single split name was found | |
1454 ((= 1 (length split-name)) | |
1455 (let* ((name (car split-name)) | |
1456 (dir (cond ((file-directory-p name) | |
1457 (file-name-as-directory name)) | |
1458 ((file-exists-p name) name) | |
1459 (t gnus-article-save-directory)))) | |
1460 (read-file-name | |
1461 (concat prompt " (default " name ") ") | |
1462 dir name))) | |
1463 ;; A list of splits was found. | |
1464 (t | |
1465 (setq split-name (nreverse split-name)) | |
1466 (let (result) | |
1467 (let ((file-name-history | |
1468 (nconc split-name file-name-history))) | |
1469 (setq result | |
1470 (expand-file-name | |
1471 (read-file-name | |
1472 (concat prompt " (`M-p' for defaults) ") | |
1473 gnus-article-save-directory | |
1474 (car split-name)) | |
1475 gnus-article-save-directory))) | |
1476 (car (push result file-name-history))))))) | |
1477 ;; Create the directory. | |
1478 (gnus-make-directory (file-name-directory file)) | |
1479 ;; If we have read a directory, we append the default file name. | |
1480 (when (file-directory-p file) | |
1481 (setq file (concat (file-name-as-directory file) | |
1482 (file-name-nondirectory default-name)))) | |
1483 ;; Possibly translate some characters. | |
1484 (nnheader-translate-file-chars file))))) | |
1485 (gnus-make-directory (file-name-directory result)) | |
1486 (set variable result))) | |
1487 | |
1488 (defun gnus-article-archive-name (group) | |
1489 "Return the first instance of an \"Archive-name\" in the current buffer." | |
1490 (let ((case-fold-search t)) | |
1491 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t) | |
1492 (nnheader-concat gnus-article-save-directory | |
1493 (match-string 1))))) | |
1494 | |
1495 (defun gnus-article-nndoc-name (group) | |
1496 "If GROUP is an nndoc group, return the name of the parent group." | |
1497 (when (eq (car (gnus-find-method-for-group group)) 'nndoc) | |
1498 (gnus-group-get-parameter group 'save-article-group))) | |
1499 | |
1500 (defun gnus-summary-save-in-rmail (&optional filename) | |
1501 "Append this article to Rmail file. | |
1502 Optional argument FILENAME specifies file name. | |
1503 Directory to save to is default to `gnus-article-save-directory'." | |
1504 (interactive) | |
1505 (gnus-set-global-variables) | |
1506 (setq filename (gnus-read-save-file-name | |
1507 "Save %s in rmail file:" filename | |
1508 gnus-rmail-save-name gnus-newsgroup-name | |
1509 gnus-current-headers 'gnus-newsgroup-last-rmail)) | |
1510 (gnus-eval-in-buffer-window gnus-save-article-buffer | |
1511 (save-excursion | |
1512 (save-restriction | |
1513 (widen) | |
1514 (gnus-output-to-rmail filename))))) | |
1515 | |
1516 (defun gnus-summary-save-in-mail (&optional filename) | |
1517 "Append this article to Unix mail file. | |
1518 Optional argument FILENAME specifies file name. | |
1519 Directory to save to is default to `gnus-article-save-directory'." | |
1520 (interactive) | |
1521 (gnus-set-global-variables) | |
1522 (setq filename (gnus-read-save-file-name | |
1523 "Save %s in Unix mail file:" filename | |
1524 gnus-mail-save-name gnus-newsgroup-name | |
1525 gnus-current-headers 'gnus-newsgroup-last-mail)) | |
1526 (gnus-eval-in-buffer-window gnus-save-article-buffer | |
1527 (save-excursion | |
1528 (save-restriction | |
1529 (widen) | |
1530 (if (and (file-readable-p filename) | |
1531 (mail-file-babyl-p filename)) | |
1532 (gnus-output-to-rmail filename t) | |
1533 (gnus-output-to-mail filename)))))) | |
1534 | |
1535 (defun gnus-summary-save-in-file (&optional filename overwrite) | |
1536 "Append this article to file. | |
1537 Optional argument FILENAME specifies file name. | |
1538 Directory to save to is default to `gnus-article-save-directory'." | |
1539 (interactive) | |
1540 (gnus-set-global-variables) | |
1541 (setq filename (gnus-read-save-file-name | |
1542 "Save %s in file:" filename | |
1543 gnus-file-save-name gnus-newsgroup-name | |
1544 gnus-current-headers 'gnus-newsgroup-last-file)) | |
1545 (gnus-eval-in-buffer-window gnus-save-article-buffer | |
1546 (save-excursion | |
1547 (save-restriction | |
1548 (widen) | |
1549 (when (and overwrite | |
1550 (file-exists-p filename)) | |
1551 (delete-file filename)) | |
1552 (gnus-output-to-file filename))))) | |
1553 | |
1554 (defun gnus-summary-write-to-file (&optional filename) | |
1555 "Write this article to a file. | |
1556 Optional argument FILENAME specifies file name. | |
1557 The directory to save in defaults to `gnus-article-save-directory'." | |
1558 (interactive) | |
1559 (gnus-summary-save-in-file nil t)) | |
1560 | |
1561 (defun gnus-summary-save-body-in-file (&optional filename) | |
1562 "Append this article body to a file. | |
1563 Optional argument FILENAME specifies file name. | |
1564 The directory to save in defaults to `gnus-article-save-directory'." | |
1565 (interactive) | |
1566 (gnus-set-global-variables) | |
1567 (setq filename (gnus-read-save-file-name | |
1568 "Save %s body in file:" filename | |
1569 gnus-file-save-name gnus-newsgroup-name | |
1570 gnus-current-headers 'gnus-newsgroup-last-file)) | |
1571 (gnus-eval-in-buffer-window gnus-save-article-buffer | |
1572 (save-excursion | |
1573 (save-restriction | |
1574 (widen) | |
1575 (goto-char (point-min)) | |
1576 (when (search-forward "\n\n" nil t) | |
1577 (narrow-to-region (point) (point-max))) | |
1578 (gnus-output-to-file filename))))) | |
1579 | |
1580 (defun gnus-summary-save-in-pipe (&optional command) | |
1581 "Pipe this article to subprocess." | |
1582 (interactive) | |
1583 (gnus-set-global-variables) | |
1584 (setq command | |
1585 (cond ((eq command 'default) | |
1586 gnus-last-shell-command) | |
1587 (command command) | |
1588 (t (read-string | |
1589 (format | |
1590 "Shell command on %s: " | |
1591 (if (and gnus-number-of-articles-to-be-saved | |
1592 (> gnus-number-of-articles-to-be-saved 1)) | |
1593 (format "these %d articles" | |
1594 gnus-number-of-articles-to-be-saved) | |
1595 "this article")) | |
1596 gnus-last-shell-command)))) | |
1597 (when (string-equal command "") | |
1598 (setq command gnus-last-shell-command)) | |
1599 (gnus-eval-in-buffer-window gnus-article-buffer | |
1600 (save-restriction | |
1601 (widen) | |
1602 (shell-command-on-region (point-min) (point-max) command nil))) | |
1603 (setq gnus-last-shell-command command)) | |
1604 | |
1605 ;;; Article file names when saving. | |
1606 | |
1607 (defun gnus-capitalize-newsgroup (newsgroup) | |
1608 "Capitalize NEWSGROUP name." | |
1609 (when (not (zerop (length newsgroup))) | |
1610 (concat (char-to-string (upcase (aref newsgroup 0))) | |
1611 (substring newsgroup 1)))) | |
1612 | |
1613 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file) | |
1614 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE. | |
1615 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num. | |
1616 Otherwise, it is like ~/News/news/group/num." | |
1617 (let ((default | |
1618 (expand-file-name | |
1619 (concat (if (gnus-use-long-file-name 'not-save) | |
1620 (gnus-capitalize-newsgroup newsgroup) | |
1621 (gnus-newsgroup-directory-form newsgroup)) | |
1622 "/" (int-to-string (mail-header-number headers))) | |
1623 gnus-article-save-directory))) | |
1624 (if (and last-file | |
1625 (string-equal (file-name-directory default) | |
1626 (file-name-directory last-file)) | |
1627 (string-match "^[0-9]+$" (file-name-nondirectory last-file))) | |
1628 default | |
1629 (or last-file default)))) | |
1630 | |
1631 (defun gnus-numeric-save-name (newsgroup headers &optional last-file) | |
1632 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE. | |
1633 If variable `gnus-use-long-file-name' is non-nil, it is | |
1634 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num." | |
1635 (let ((default | |
1636 (expand-file-name | |
1637 (concat (if (gnus-use-long-file-name 'not-save) | |
1638 newsgroup | |
1639 (gnus-newsgroup-directory-form newsgroup)) | |
1640 "/" (int-to-string (mail-header-number headers))) | |
1641 gnus-article-save-directory))) | |
1642 (if (and last-file | |
1643 (string-equal (file-name-directory default) | |
1644 (file-name-directory last-file)) | |
1645 (string-match "^[0-9]+$" (file-name-nondirectory last-file))) | |
1646 default | |
1647 (or last-file default)))) | |
1648 | |
1649 (defun gnus-Plain-save-name (newsgroup headers &optional last-file) | |
1650 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE. | |
1651 If variable `gnus-use-long-file-name' is non-nil, it is | |
1652 ~/News/News.group. Otherwise, it is like ~/News/news/group/news." | |
1653 (or last-file | |
1654 (expand-file-name | |
1655 (if (gnus-use-long-file-name 'not-save) | |
1656 (gnus-capitalize-newsgroup newsgroup) | |
1657 (concat (gnus-newsgroup-directory-form newsgroup) "/news")) | |
1658 gnus-article-save-directory))) | |
1659 | |
1660 (defun gnus-plain-save-name (newsgroup headers &optional last-file) | |
1661 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE. | |
1662 If variable `gnus-use-long-file-name' is non-nil, it is | |
1663 ~/News/news.group. Otherwise, it is like ~/News/news/group/news." | |
1664 (or last-file | |
1665 (expand-file-name | |
1666 (if (gnus-use-long-file-name 'not-save) | |
1667 newsgroup | |
1668 (concat (gnus-newsgroup-directory-form newsgroup) "/news")) | |
1669 gnus-article-save-directory))) | |
1670 | |
1671 (eval-and-compile | |
1672 (mapcar | |
1673 (lambda (func) | |
1674 (let (afunc gfunc) | |
1675 (if (consp func) | |
1676 (setq afunc (car func) | |
1677 gfunc (cdr func)) | |
1678 (setq afunc func | |
1679 gfunc (intern (format "gnus-%s" func)))) | |
1680 (fset gfunc | |
1681 (if (not (fboundp afunc)) | |
1682 nil | |
1683 `(lambda (&optional interactive &rest args) | |
1684 ,(documentation afunc t) | |
1685 (interactive (list t)) | |
1686 (save-excursion | |
1687 (set-buffer gnus-article-buffer) | |
1688 (if interactive | |
1689 (call-interactively ',afunc) | |
1690 (apply ',afunc args)))))))) | |
1691 '(article-hide-headers | |
1692 article-hide-boring-headers | |
1693 article-treat-overstrike | |
1694 (article-fill . gnus-article-word-wrap) | |
1695 article-remove-cr | |
1696 article-display-x-face | |
1697 article-de-quoted-unreadable | |
1698 article-mime-decode-quoted-printable | |
1699 article-hide-pgp | |
1700 article-hide-pem | |
1701 article-hide-signature | |
1702 article-remove-trailing-blank-lines | |
1703 article-strip-leading-blank-lines | |
1704 article-strip-multiple-blank-lines | |
1705 article-strip-leading-space | |
1706 article-strip-blank-lines | |
1707 article-date-local | |
1708 article-date-original | |
1709 article-date-ut | |
1710 article-date-user | |
1711 article-date-lapsed | |
1712 article-emphasize | |
1713 (article-show-all . gnus-article-show-all-headers)))) | |
1714 | |
1715 ;;; | |
1716 ;;; Gnus article mode | |
1717 ;;; | |
1718 | |
1719 (put 'gnus-article-mode 'mode-class 'special) | |
1720 | |
1721 (when t | |
1722 (gnus-define-keys gnus-article-mode-map | |
1723 " " gnus-article-goto-next-page | |
1724 "\177" gnus-article-goto-prev-page | |
1725 [delete] gnus-article-goto-prev-page | |
1726 "\C-c^" gnus-article-refer-article | |
1727 "h" gnus-article-show-summary | |
1728 "s" gnus-article-show-summary | |
1729 "\C-c\C-m" gnus-article-mail | |
1730 "?" gnus-article-describe-briefly | |
1731 gnus-mouse-2 gnus-article-push-button | |
1732 "\r" gnus-article-press-button | |
1733 "\t" gnus-article-next-button | |
1734 "\M-\t" gnus-article-prev-button | |
1735 "e" gnus-article-edit | |
1736 "<" beginning-of-buffer | |
1737 ">" end-of-buffer | |
1738 "\C-c\C-i" gnus-info-find-node | |
1739 "\C-c\C-b" gnus-bug | |
1740 | |
1741 "\C-d" gnus-article-read-summary-keys | |
1742 "\M-*" gnus-article-read-summary-keys | |
1743 "\M-#" gnus-article-read-summary-keys | |
1744 "\M-^" gnus-article-read-summary-keys | |
1745 "\M-g" gnus-article-read-summary-keys) | |
1746 | |
1747 (substitute-key-definition | |
1748 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)) | |
1749 | |
1750 (defun gnus-article-make-menu-bar () | |
1751 (gnus-turn-off-edit-menu 'article) | |
1752 (unless (boundp 'gnus-article-article-menu) | |
1753 (easy-menu-define | |
1754 gnus-article-article-menu gnus-article-mode-map "" | |
1755 '("Article" | |
1756 ["Scroll forwards" gnus-article-goto-next-page t] | |
1757 ["Scroll backwards" gnus-article-goto-prev-page t] | |
1758 ["Show summary" gnus-article-show-summary t] | |
1759 ["Fetch Message-ID at point" gnus-article-refer-article t] | |
1760 ["Mail to address at point" gnus-article-mail t])) | |
1761 | |
1762 (easy-menu-define | |
1763 gnus-article-treatment-menu gnus-article-mode-map "" | |
1764 '("Treatment" | |
1765 ["Hide headers" gnus-article-hide-headers t] | |
1766 ["Hide signature" gnus-article-hide-signature t] | |
1767 ["Hide citation" gnus-article-hide-citation t] | |
1768 ["Treat overstrike" gnus-article-treat-overstrike t] | |
1769 ["Remove carriage return" gnus-article-remove-cr t] | |
1770 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t])) | |
1771 | |
1772 (when nil | |
1773 (when (boundp 'gnus-summary-article-menu) | |
1774 (define-key gnus-article-mode-map [menu-bar commands] | |
1775 (cons "Commands" gnus-summary-article-menu)))) | |
1776 | |
1777 (when (boundp 'gnus-summary-post-menu) | |
1778 (define-key gnus-article-mode-map [menu-bar post] | |
1779 (cons "Post" gnus-summary-post-menu))) | |
1780 | |
1781 (run-hooks 'gnus-article-menu-hook))) | |
1782 | |
1783 (defun gnus-article-mode () | |
1784 "Major mode for displaying an article. | |
1785 | |
1786 All normal editing commands are switched off. | |
1787 | |
1788 The following commands are available in addition to all summary mode | |
1789 commands: | |
1790 \\<gnus-article-mode-map> | |
1791 \\[gnus-article-next-page]\t Scroll the article one page forwards | |
1792 \\[gnus-article-prev-page]\t Scroll the article one page backwards | |
1793 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point | |
1794 \\[gnus-article-show-summary]\t Display the summary buffer | |
1795 \\[gnus-article-mail]\t Send a reply to the address near point | |
1796 \\[gnus-article-describe-briefly]\t Describe the current mode briefly | |
1797 \\[gnus-info-find-node]\t Go to the Gnus info node" | |
1798 (interactive) | |
1799 (when (gnus-visual-p 'article-menu 'menu) | |
1800 (gnus-article-make-menu-bar)) | |
1801 (kill-all-local-variables) | |
1802 (gnus-simplify-mode-line) | |
1803 (setq mode-name "Article") | |
1804 (setq major-mode 'gnus-article-mode) | |
1805 (make-local-variable 'minor-mode-alist) | |
1806 (unless (assq 'gnus-show-mime minor-mode-alist) | |
1807 (push (list 'gnus-show-mime " MIME") minor-mode-alist)) | |
1808 (use-local-map gnus-article-mode-map) | |
1809 (gnus-update-format-specifications nil 'article-mode) | |
1810 (set (make-local-variable 'page-delimiter) gnus-page-delimiter) | |
1811 (set (make-local-variable 'gnus-page-broken) nil) | |
1812 (set (make-local-variable 'gnus-button-marker-list) nil) | |
1813 (gnus-set-default-directory) | |
1814 (buffer-disable-undo (current-buffer)) | |
1815 (setq buffer-read-only t) | |
1816 (set-syntax-table gnus-article-mode-syntax-table) | |
1817 (run-hooks 'gnus-article-mode-hook)) | |
1818 | |
1819 (defun gnus-article-setup-buffer () | |
1820 "Initialize the article buffer." | |
1821 (let* ((name (if gnus-single-article-buffer "*Article*" | |
1822 (concat "*Article " gnus-newsgroup-name "*"))) | |
1823 (original | |
1824 (progn (string-match "\\*Article" name) | |
1825 (concat " *Original Article" | |
1826 (substring name (match-end 0)))))) | |
1827 (setq gnus-article-buffer name) | |
1828 (setq gnus-original-article-buffer original) | |
1829 ;; This might be a variable local to the summary buffer. | |
1830 (unless gnus-single-article-buffer | |
1831 (save-excursion | |
1832 (set-buffer gnus-summary-buffer) | |
1833 (setq gnus-article-buffer name) | |
1834 (setq gnus-original-article-buffer original) | |
1835 (gnus-set-global-variables))) | |
1836 ;; Init original article buffer. | |
1837 (save-excursion | |
1838 (set-buffer (get-buffer-create gnus-original-article-buffer)) | |
1839 (buffer-disable-undo (current-buffer)) | |
1840 (setq major-mode 'gnus-original-article-mode) | |
1841 (gnus-add-current-to-buffer-list) | |
1842 (make-local-variable 'gnus-original-article)) | |
1843 (if (get-buffer name) | |
1844 (save-excursion | |
1845 (set-buffer name) | |
1846 (buffer-disable-undo (current-buffer)) | |
1847 (setq buffer-read-only t) | |
1848 (gnus-add-current-to-buffer-list) | |
1849 (unless (eq major-mode 'gnus-article-mode) | |
1850 (gnus-article-mode)) | |
1851 (current-buffer)) | |
1852 (save-excursion | |
1853 (set-buffer (get-buffer-create name)) | |
1854 (gnus-add-current-to-buffer-list) | |
1855 (gnus-article-mode) | |
1856 (make-local-variable 'gnus-summary-buffer) | |
1857 (current-buffer))))) | |
1858 | |
1859 ;; Set article window start at LINE, where LINE is the number of lines | |
1860 ;; from the head of the article. | |
1861 (defun gnus-article-set-window-start (&optional line) | |
1862 (set-window-start | |
1863 (get-buffer-window gnus-article-buffer t) | |
1864 (save-excursion | |
1865 (set-buffer gnus-article-buffer) | |
1866 (goto-char (point-min)) | |
1867 (if (not line) | |
1868 (point-min) | |
1869 (gnus-message 6 "Moved to bookmark") | |
1870 (search-forward "\n\n" nil t) | |
1871 (forward-line line) | |
1872 (point))))) | |
1873 | |
1874 (defun gnus-article-prepare (article &optional all-headers header) | |
1875 "Prepare ARTICLE in article mode buffer. | |
1876 ARTICLE should either be an article number or a Message-ID. | |
1877 If ARTICLE is an id, HEADER should be the article headers. | |
1878 If ALL-HEADERS is non-nil, no headers are hidden." | |
1879 (save-excursion | |
1880 ;; Make sure we start in a summary buffer. | |
1881 (unless (eq major-mode 'gnus-summary-mode) | |
1882 (set-buffer gnus-summary-buffer)) | |
1883 (setq gnus-summary-buffer (current-buffer)) | |
1884 ;; Make sure the connection to the server is alive. | |
1885 (unless (gnus-server-opened | |
1886 (gnus-find-method-for-group gnus-newsgroup-name)) | |
1887 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name)) | |
1888 (gnus-request-group gnus-newsgroup-name t)) | |
1889 (let* ((gnus-article (if header (mail-header-number header) article)) | |
1890 (summary-buffer (current-buffer)) | |
1891 (internal-hook gnus-article-internal-prepare-hook) | |
1892 (group gnus-newsgroup-name) | |
1893 result) | |
1894 (save-excursion | |
1895 (gnus-article-setup-buffer) | |
1896 (set-buffer gnus-article-buffer) | |
1897 ;; Deactivate active regions. | |
1898 (when (and (boundp 'transient-mark-mode) | |
1899 transient-mark-mode) | |
1900 (setq mark-active nil)) | |
1901 (if (not (setq result (let ((buffer-read-only nil)) | |
1902 (gnus-request-article-this-buffer | |
1903 article group)))) | |
1904 ;; There is no such article. | |
1905 (save-excursion | |
1906 (when (and (numberp article) | |
1907 (not (memq article gnus-newsgroup-sparse))) | |
1908 (setq gnus-article-current | |
1909 (cons gnus-newsgroup-name article)) | |
1910 (set-buffer gnus-summary-buffer) | |
1911 (setq gnus-current-article article) | |
1912 (gnus-summary-mark-article article gnus-canceled-mark)) | |
1913 (unless (memq article gnus-newsgroup-sparse) | |
1914 (gnus-error | |
1915 1 "No such article (may have expired or been canceled)"))) | |
1916 (if (or (eq result 'pseudo) (eq result 'nneething)) | |
1917 (progn | |
1918 (save-excursion | |
1919 (set-buffer summary-buffer) | |
1920 (setq gnus-last-article gnus-current-article | |
1921 gnus-newsgroup-history (cons gnus-current-article | |
1922 gnus-newsgroup-history) | |
1923 gnus-current-article 0 | |
1924 gnus-current-headers nil | |
1925 gnus-article-current nil) | |
1926 (if (eq result 'nneething) | |
1927 (gnus-configure-windows 'summary) | |
1928 (gnus-configure-windows 'article)) | |
1929 (gnus-set-global-variables)) | |
1930 (gnus-set-mode-line 'article)) | |
1931 ;; The result from the `request' was an actual article - | |
1932 ;; or at least some text that is now displayed in the | |
1933 ;; article buffer. | |
1934 (when (and (numberp article) | |
1935 (not (eq article gnus-current-article))) | |
1936 ;; Seems like a new article has been selected. | |
1937 ;; `gnus-current-article' must be an article number. | |
1938 (save-excursion | |
1939 (set-buffer summary-buffer) | |
1940 (setq gnus-last-article gnus-current-article | |
1941 gnus-newsgroup-history (cons gnus-current-article | |
1942 gnus-newsgroup-history) | |
1943 gnus-current-article article | |
1944 gnus-current-headers | |
1945 (gnus-summary-article-header gnus-current-article) | |
1946 gnus-article-current | |
1947 (cons gnus-newsgroup-name gnus-current-article)) | |
1948 (unless (vectorp gnus-current-headers) | |
1949 (setq gnus-current-headers nil)) | |
1950 (gnus-summary-show-thread) | |
1951 (run-hooks 'gnus-mark-article-hook) | |
1952 (gnus-set-mode-line 'summary) | |
1953 (when (gnus-visual-p 'article-highlight 'highlight) | |
1954 (run-hooks 'gnus-visual-mark-article-hook)) | |
1955 ;; Set the global newsgroup variables here. | |
1956 ;; Suggested by Jim Sisolak | |
1957 ;; <sisolak@trans4.neep.wisc.edu>. | |
1958 (gnus-set-global-variables) | |
1959 (setq gnus-have-all-headers | |
1960 (or all-headers gnus-show-all-headers)) | |
1961 (and gnus-use-cache | |
1962 (vectorp (gnus-summary-article-header article)) | |
1963 (gnus-cache-possibly-enter-article | |
1964 group article | |
1965 (gnus-summary-article-header article) | |
1966 (memq article gnus-newsgroup-marked) | |
1967 (memq article gnus-newsgroup-dormant) | |
1968 (memq article gnus-newsgroup-unreads))))) | |
1969 (when (or (numberp article) | |
1970 (stringp article)) | |
1971 ;; Hooks for getting information from the article. | |
1972 ;; This hook must be called before being narrowed. | |
1973 (let (buffer-read-only) | |
1974 (run-hooks 'internal-hook) | |
1975 (run-hooks 'gnus-article-prepare-hook) | |
1976 ;; Decode MIME message. | |
1977 (when gnus-show-mime | |
1978 (if (or (not gnus-strict-mime) | |
1979 (gnus-fetch-field "Mime-Version")) | |
1980 (funcall gnus-show-mime-method) | |
1981 (funcall gnus-decode-encoded-word-method))) | |
1982 ;; Perform the article display hooks. | |
1983 (run-hooks 'gnus-article-display-hook)) | |
1984 ;; Do page break. | |
1985 (goto-char (point-min)) | |
1986 (setq gnus-page-broken | |
1987 (when gnus-break-pages | |
1988 (gnus-narrow-to-page) | |
1989 t))) | |
1990 (gnus-set-mode-line 'article) | |
1991 (gnus-configure-windows 'article) | |
1992 (goto-char (point-min)) | |
1993 t)))))) | |
1994 | |
1995 (defun gnus-article-wash-status () | |
1996 "Return a string which display status of article washing." | |
1997 (save-excursion | |
1998 (set-buffer gnus-article-buffer) | |
1999 (let ((cite (gnus-article-hidden-text-p 'cite)) | |
2000 (headers (gnus-article-hidden-text-p 'headers)) | |
2001 (boring (gnus-article-hidden-text-p 'boring-headers)) | |
2002 (pgp (gnus-article-hidden-text-p 'pgp)) | |
2003 (pem (gnus-article-hidden-text-p 'pem)) | |
2004 (signature (gnus-article-hidden-text-p 'signature)) | |
2005 (overstrike (gnus-article-hidden-text-p 'overstrike)) | |
2006 (emphasis (gnus-article-hidden-text-p 'emphasis)) | |
2007 (mime gnus-show-mime)) | |
2008 (format "%c%c%c%c%c%c%c" | |
2009 (if cite ?c ? ) | |
2010 (if (or headers boring) ?h ? ) | |
2011 (if (or pgp pem) ?p ? ) | |
2012 (if signature ?s ? ) | |
2013 (if overstrike ?o ? ) | |
2014 (if mime ?m ? ) | |
2015 (if emphasis ?e ? ))))) | |
2016 | |
2017 (defun gnus-article-hide-headers-if-wanted () | |
2018 "Hide unwanted headers if `gnus-have-all-headers' is nil. | |
2019 Provided for backwards compatibility." | |
2020 (or (save-excursion (set-buffer gnus-summary-buffer) gnus-have-all-headers) | |
2021 gnus-inhibit-hiding | |
2022 (gnus-article-hide-headers))) | |
2023 | |
2024 ;;; Article savers. | |
2025 | |
2026 (defun gnus-output-to-file (file-name) | |
2027 "Append the current article to a file named FILE-NAME." | |
2028 (let ((artbuf (current-buffer))) | |
2029 (nnheader-temp-write nil | |
2030 (insert-buffer-substring artbuf) | |
2031 ;; Append newline at end of the buffer as separator, and then | |
2032 ;; save it to file. | |
2033 (goto-char (point-max)) | |
2034 (insert "\n") | |
2035 (append-to-file (point-min) (point-max) file-name)))) | |
2036 | |
2037 (defun gnus-narrow-to-page (&optional arg) | |
2038 "Narrow the article buffer to a page. | |
2039 If given a numerical ARG, move forward ARG pages." | |
2040 (interactive "P") | |
2041 (setq arg (if arg (prefix-numeric-value arg) 0)) | |
2042 (save-excursion | |
2043 (set-buffer gnus-article-buffer) | |
2044 (goto-char (point-min)) | |
2045 (widen) | |
2046 ;; Remove any old next/prev buttons. | |
2047 (when (gnus-visual-p 'page-marker) | |
2048 (let ((buffer-read-only nil)) | |
2049 (gnus-remove-text-with-property 'gnus-prev) | |
2050 (gnus-remove-text-with-property 'gnus-next))) | |
2051 (when | |
2052 (cond ((< arg 0) | |
2053 (re-search-backward page-delimiter nil 'move (1+ (abs arg)))) | |
2054 ((> arg 0) | |
2055 (re-search-forward page-delimiter nil 'move arg))) | |
2056 (goto-char (match-end 0))) | |
2057 (narrow-to-region | |
2058 (point) | |
2059 (if (re-search-forward page-delimiter nil 'move) | |
2060 (match-beginning 0) | |
2061 (point))) | |
2062 (when (and (gnus-visual-p 'page-marker) | |
2063 (not (= (point-min) 1))) | |
2064 (save-excursion | |
2065 (goto-char (point-min)) | |
2066 (gnus-insert-prev-page-button))) | |
2067 (when (and (gnus-visual-p 'page-marker) | |
2068 (< (+ (point-max) 2) (buffer-size))) | |
2069 (save-excursion | |
2070 (goto-char (point-max)) | |
2071 (gnus-insert-next-page-button))))) | |
2072 | |
2073 ;; Article mode commands | |
2074 | |
2075 (defun gnus-article-goto-next-page () | |
2076 "Show the next page of the article." | |
2077 (interactive) | |
2078 (when (gnus-article-next-page) | |
2079 (goto-char (point-min)) | |
2080 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n)))) | |
2081 | |
2082 (defun gnus-article-goto-prev-page () | |
2083 "Show the next page of the article." | |
2084 (interactive) | |
2085 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?p)) | |
2086 (gnus-article-prev-page nil))) | |
2087 | |
2088 (defun gnus-article-next-page (&optional lines) | |
2089 "Show the next page of the current article. | |
2090 If end of article, return non-nil. Otherwise return nil. | |
2091 Argument LINES specifies lines to be scrolled up." | |
2092 (interactive "p") | |
2093 (move-to-window-line -1) | |
2094 (if (save-excursion | |
2095 (end-of-line) | |
2096 (and (pos-visible-in-window-p) ;Not continuation line. | |
2097 (eobp))) | |
2098 ;; Nothing in this page. | |
2099 (if (or (not gnus-page-broken) | |
2100 (save-excursion | |
2101 (save-restriction | |
2102 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer? | |
2103 t ;Nothing more. | |
2104 (gnus-narrow-to-page 1) ;Go to next page. | |
2105 nil) | |
2106 ;; More in this page. | |
2107 (let ((scroll-in-place nil)) | |
2108 (condition-case () | |
2109 (scroll-up lines) | |
2110 (end-of-buffer | |
2111 ;; Long lines may cause an end-of-buffer error. | |
2112 (goto-char (point-max))))) | |
2113 (move-to-window-line 0) | |
2114 nil)) | |
2115 | |
2116 (defun gnus-article-prev-page (&optional lines) | |
2117 "Show previous page of current article. | |
2118 Argument LINES specifies lines to be scrolled down." | |
2119 (interactive "p") | |
2120 (move-to-window-line 0) | |
2121 (if (and gnus-page-broken | |
2122 (bobp) | |
2123 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer? | |
2124 (progn | |
2125 (gnus-narrow-to-page -1) ;Go to previous page. | |
2126 (goto-char (point-max)) | |
2127 (recenter -1)) | |
2128 (let ((scroll-in-place nil)) | |
2129 (prog1 | |
2130 (condition-case () | |
2131 (scroll-down lines) | |
2132 (beginning-of-buffer | |
2133 (goto-char (point-min)))) | |
2134 (move-to-window-line 0))))) | |
2135 | |
2136 (defun gnus-article-refer-article () | |
2137 "Read article specified by message-id around point." | |
2138 (interactive) | |
2139 (let ((point (point))) | |
2140 (search-forward ">" nil t) ;Move point to end of "<....>". | |
2141 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t) | |
2142 (let ((message-id (match-string 1))) | |
2143 (goto-char point) | |
2144 (set-buffer gnus-summary-buffer) | |
2145 (gnus-summary-refer-article message-id)) | |
2146 (goto-char (point)) | |
2147 (error "No references around point")))) | |
2148 | |
2149 (defun gnus-article-show-summary () | |
2150 "Reconfigure windows to show summary buffer." | |
2151 (interactive) | |
2152 (if (not (gnus-buffer-live-p gnus-summary-buffer)) | |
2153 (error "There is no summary buffer for this article buffer") | |
2154 (gnus-configure-windows 'article) | |
2155 (gnus-summary-goto-subject gnus-current-article))) | |
2156 | |
2157 (defun gnus-article-describe-briefly () | |
2158 "Describe article mode commands briefly." | |
2159 (interactive) | |
2160 (gnus-message 6 | |
2161 (substitute-command-keys "\\<gnus-article-mode-map>\\[gnus-article-goto-next-page]:Next page \\[gnus-article-goto-prev-page]:Prev page \\[gnus-article-show-summary]:Show summary \\[gnus-info-find-node]:Run Info \\[gnus-article-describe-briefly]:This help"))) | |
2162 | |
2163 (defun gnus-article-summary-command () | |
2164 "Execute the last keystroke in the summary buffer." | |
2165 (interactive) | |
2166 (let ((obuf (current-buffer)) | |
2167 (owin (current-window-configuration)) | |
2168 func) | |
2169 (switch-to-buffer gnus-summary-buffer 'norecord) | |
2170 (setq func (lookup-key (current-local-map) (this-command-keys))) | |
2171 (call-interactively func) | |
2172 (set-buffer obuf) | |
2173 (set-window-configuration owin) | |
2174 (set-window-point (get-buffer-window (current-buffer)) (point)))) | |
2175 | |
2176 (defun gnus-article-summary-command-nosave () | |
2177 "Execute the last keystroke in the summary buffer." | |
2178 (interactive) | |
2179 (let (func) | |
2180 (pop-to-buffer gnus-summary-buffer 'norecord) | |
2181 (setq func (lookup-key (current-local-map) (this-command-keys))) | |
2182 (call-interactively func))) | |
2183 | |
2184 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window) | |
2185 "Read a summary buffer key sequence and execute it from the article buffer." | |
2186 (interactive "P") | |
2187 (let ((nosaves | |
2188 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F" | |
2189 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP" | |
2190 "=" "^" "\M-^" "|")) | |
2191 (nosave-but-article | |
2192 '("A\r")) | |
2193 (nosave-in-article | |
2194 '("\C-d")) | |
2195 keys) | |
2196 (save-excursion | |
2197 (set-buffer gnus-summary-buffer) | |
2198 (let (gnus-pick-mode) | |
2199 (push (or key last-command-event) unread-command-events) | |
2200 (setq keys (read-key-sequence nil)))) | |
2201 (message "") | |
2202 | |
2203 (if (or (member keys nosaves) | |
2204 (member keys nosave-but-article) | |
2205 (member keys nosave-in-article)) | |
2206 (let (func) | |
2207 (save-window-excursion | |
2208 (pop-to-buffer gnus-summary-buffer 'norecord) | |
2209 ;; We disable the pick minor mode commands. | |
2210 (let (gnus-pick-mode) | |
2211 (setq func (lookup-key (current-local-map) keys)))) | |
2212 (if (not func) | |
2213 (ding) | |
2214 (unless (member keys nosave-in-article) | |
2215 (set-buffer gnus-summary-buffer)) | |
2216 (call-interactively func)) | |
2217 (when (member keys nosave-but-article) | |
2218 (pop-to-buffer gnus-article-buffer 'norecord))) | |
2219 ;; These commands should restore window configuration. | |
2220 (let ((obuf (current-buffer)) | |
2221 (owin (current-window-configuration)) | |
2222 (opoint (point)) | |
2223 func in-buffer) | |
2224 (if not-restore-window | |
2225 (pop-to-buffer gnus-summary-buffer 'norecord) | |
2226 (switch-to-buffer gnus-summary-buffer 'norecord)) | |
2227 (setq in-buffer (current-buffer)) | |
2228 ;; We disable the pick minor mode commands. | |
2229 (if (setq func (let (gnus-pick-mode) | |
2230 (lookup-key (current-local-map) keys))) | |
2231 (call-interactively func) | |
2232 (ding)) | |
2233 (when (eq in-buffer (current-buffer)) | |
2234 (set-buffer obuf) | |
2235 (unless not-restore-window | |
2236 (set-window-configuration owin)) | |
2237 (set-window-point (get-buffer-window (current-buffer)) opoint)))))) | |
2238 | |
2239 (defun gnus-article-hide (&optional arg force) | |
2240 "Hide all the gruft in the current article. | |
2241 This means that PGP stuff, signatures, cited text and (some) | |
2242 headers will be hidden. | |
2243 If given a prefix, show the hidden text instead." | |
2244 (interactive (list current-prefix-arg 'force)) | |
2245 (gnus-article-hide-headers arg) | |
2246 (gnus-article-hide-pgp arg) | |
2247 (gnus-article-hide-citation-maybe arg force) | |
2248 (gnus-article-hide-signature arg)) | |
2249 | |
2250 (defun gnus-article-maybe-highlight () | |
2251 "Do some article highlighting if `article-visual' is non-nil." | |
2252 (when (gnus-visual-p 'article-highlight 'highlight) | |
2253 (gnus-article-highlight-some))) | |
2254 | |
2255 (defun gnus-request-article-this-buffer (article group) | |
2256 "Get an article and insert it into this buffer." | |
2257 (let (do-update-line) | |
2258 (prog1 | |
2259 (save-excursion | |
2260 (erase-buffer) | |
2261 (gnus-kill-all-overlays) | |
2262 (setq group (or group gnus-newsgroup-name)) | |
2263 | |
2264 ;; Open server if it has closed. | |
2265 (gnus-check-server (gnus-find-method-for-group group)) | |
2266 | |
2267 ;; Using `gnus-request-article' directly will insert the article into | |
2268 ;; `nntp-server-buffer' - so we'll save some time by not having to | |
2269 ;; copy it from the server buffer into the article buffer. | |
2270 | |
2271 ;; We only request an article by message-id when we do not have the | |
2272 ;; headers for it, so we'll have to get those. | |
2273 (when (stringp article) | |
2274 (let ((gnus-override-method gnus-refer-article-method)) | |
2275 (gnus-read-header article))) | |
2276 | |
2277 ;; If the article number is negative, that means that this article | |
2278 ;; doesn't belong in this newsgroup (possibly), so we find its | |
2279 ;; message-id and request it by id instead of number. | |
2280 (when (and (numberp article) | |
2281 gnus-summary-buffer | |
2282 (get-buffer gnus-summary-buffer) | |
2283 (buffer-name (get-buffer gnus-summary-buffer))) | |
2284 (save-excursion | |
2285 (set-buffer gnus-summary-buffer) | |
2286 (let ((header (gnus-summary-article-header article))) | |
2287 (when (< article 0) | |
2288 (cond | |
2289 ((memq article gnus-newsgroup-sparse) | |
2290 ;; This is a sparse gap article. | |
2291 (setq do-update-line article) | |
2292 (setq article (mail-header-id header)) | |
2293 (let ((gnus-override-method gnus-refer-article-method)) | |
2294 (gnus-read-header article)) | |
2295 (setq gnus-newsgroup-sparse | |
2296 (delq article gnus-newsgroup-sparse))) | |
2297 ((vectorp header) | |
2298 ;; It's a real article. | |
2299 (setq article (mail-header-id header))) | |
2300 (t | |
2301 ;; It is an extracted pseudo-article. | |
2302 (setq article 'pseudo) | |
2303 (gnus-request-pseudo-article header)))) | |
2304 | |
2305 (let ((method (gnus-find-method-for-group | |
2306 gnus-newsgroup-name))) | |
2307 (if (not (eq (car method) 'nneething)) | |
2308 () | |
2309 (let ((dir (concat (file-name-as-directory (nth 1 method)) | |
2310 (mail-header-subject header)))) | |
2311 (when (file-directory-p dir) | |
2312 (setq article 'nneething) | |
2313 (gnus-group-enter-directory dir)))))))) | |
2314 | |
2315 (cond | |
2316 ;; Refuse to select canceled articles. | |
2317 ((and (numberp article) | |
2318 gnus-summary-buffer | |
2319 (get-buffer gnus-summary-buffer) | |
2320 (buffer-name (get-buffer gnus-summary-buffer)) | |
2321 (eq (cdr (save-excursion | |
2322 (set-buffer gnus-summary-buffer) | |
2323 (assq article gnus-newsgroup-reads))) | |
2324 gnus-canceled-mark)) | |
2325 nil) | |
2326 ;; We first check `gnus-original-article-buffer'. | |
2327 ((and (get-buffer gnus-original-article-buffer) | |
2328 (numberp article) | |
2329 (save-excursion | |
2330 (set-buffer gnus-original-article-buffer) | |
2331 (and (equal (car gnus-original-article) group) | |
2332 (eq (cdr gnus-original-article) article)))) | |
2333 (insert-buffer-substring gnus-original-article-buffer) | |
2334 'article) | |
2335 ;; Check the backlog. | |
2336 ((and gnus-keep-backlog | |
2337 (gnus-backlog-request-article group article (current-buffer))) | |
2338 'article) | |
2339 ;; Check asynchronous pre-fetch. | |
2340 ((gnus-async-request-fetched-article group article (current-buffer)) | |
2341 (gnus-async-prefetch-next group article gnus-summary-buffer) | |
2342 'article) | |
2343 ;; Check the cache. | |
2344 ((and gnus-use-cache | |
2345 (numberp article) | |
2346 (gnus-cache-request-article article group)) | |
2347 'article) | |
2348 ;; Get the article and put into the article buffer. | |
2349 ((or (stringp article) (numberp article)) | |
2350 (let ((gnus-override-method | |
2351 (and (stringp article) gnus-refer-article-method)) | |
2352 (buffer-read-only nil)) | |
2353 (erase-buffer) | |
2354 (gnus-kill-all-overlays) | |
2355 (when (gnus-request-article article group (current-buffer)) | |
2356 (when (numberp article) | |
2357 (gnus-async-prefetch-next group article gnus-summary-buffer) | |
2358 (when gnus-keep-backlog | |
2359 (gnus-backlog-enter-article | |
2360 group article (current-buffer)))) | |
2361 'article))) | |
2362 ;; It was a pseudo. | |
2363 (t article))) | |
2364 | |
2365 ;; Take the article from the original article buffer | |
2366 ;; and place it in the buffer it's supposed to be in. | |
2367 (when (and (get-buffer gnus-article-buffer) | |
2368 ;;(numberp article) | |
2369 (equal (buffer-name (current-buffer)) | |
2370 (buffer-name (get-buffer gnus-article-buffer)))) | |
2371 (save-excursion | |
2372 (if (get-buffer gnus-original-article-buffer) | |
2373 (set-buffer (get-buffer gnus-original-article-buffer)) | |
2374 (set-buffer (get-buffer-create gnus-original-article-buffer)) | |
2375 (buffer-disable-undo (current-buffer)) | |
2376 (setq major-mode 'gnus-original-article-mode) | |
2377 (setq buffer-read-only t) | |
2378 (gnus-add-current-to-buffer-list)) | |
2379 (let (buffer-read-only) | |
2380 (erase-buffer) | |
2381 (insert-buffer-substring gnus-article-buffer)) | |
2382 (setq gnus-original-article (cons group article)))) | |
2383 | |
2384 ;; Update sparse articles. | |
2385 (when (and do-update-line | |
2386 (or (numberp article) | |
2387 (stringp article))) | |
2388 (let ((buf (current-buffer))) | |
2389 (set-buffer gnus-summary-buffer) | |
2390 (gnus-summary-update-article do-update-line) | |
2391 (gnus-summary-goto-subject do-update-line nil t) | |
2392 (set-window-point (get-buffer-window (current-buffer) t) | |
2393 (point)) | |
2394 (set-buffer buf)))))) | |
2395 | |
2396 ;;; | |
2397 ;;; Article editing | |
2398 ;;; | |
2399 | |
2400 (defcustom gnus-article-edit-mode-hook nil | |
2401 "Hook run in article edit mode buffers." | |
2402 :group 'gnus-article-various | |
2403 :type 'hook) | |
2404 | |
2405 (defvar gnus-article-edit-done-function nil) | |
2406 | |
2407 (defvar gnus-article-edit-mode-map nil) | |
2408 | |
2409 (unless gnus-article-edit-mode-map | |
2410 (setq gnus-article-edit-mode-map (copy-keymap text-mode-map)) | |
2411 | |
2412 (gnus-define-keys gnus-article-edit-mode-map | |
2413 "\C-c\C-c" gnus-article-edit-done | |
2414 "\C-c\C-k" gnus-article-edit-exit) | |
2415 | |
2416 (gnus-define-keys (gnus-article-edit-wash-map | |
2417 "\C-c\C-w" gnus-article-edit-mode-map) | |
2418 "f" gnus-article-edit-full-stops)) | |
2419 | |
2420 (defun gnus-article-edit-mode () | |
2421 "Major mode for editing articles. | |
2422 This is an extended text-mode. | |
2423 | |
2424 \\{gnus-article-edit-mode-map}" | |
2425 (interactive) | |
2426 (kill-all-local-variables) | |
2427 (setq major-mode 'gnus-article-edit-mode) | |
2428 (setq mode-name "Article Edit") | |
2429 (use-local-map gnus-article-edit-mode-map) | |
2430 (make-local-variable 'gnus-article-edit-done-function) | |
2431 (make-local-variable 'gnus-prev-winconf) | |
2432 (setq buffer-read-only nil) | |
2433 (buffer-enable-undo) | |
2434 (widen) | |
2435 (run-hooks 'text-mode 'gnus-article-edit-mode-hook)) | |
2436 | |
2437 (defun gnus-article-edit (&optional force) | |
2438 "Edit the current article. | |
2439 This will have permanent effect only in mail groups. | |
2440 If FORCE is non-nil, allow editing of articles even in read-only | |
2441 groups." | |
2442 (interactive "P") | |
2443 (when (and (not force) | |
2444 (gnus-group-read-only-p)) | |
2445 (error "The current newsgroup does not support article editing.")) | |
2446 (gnus-article-edit-article | |
2447 `(lambda () | |
2448 (gnus-summary-edit-article-done | |
2449 ,(or (mail-header-references gnus-current-headers) "") | |
2450 ,(gnus-group-read-only-p) ,gnus-summary-buffer)))) | |
2451 | |
2452 (defun gnus-article-edit-article (exit-func) | |
2453 "Start editing the contents of the current article buffer." | |
2454 (let ((winconf (current-window-configuration))) | |
2455 (set-buffer gnus-article-buffer) | |
2456 (gnus-article-edit-mode) | |
2457 (set-text-properties (point-min) (point-max) nil) | |
2458 (gnus-configure-windows 'edit-article) | |
2459 (setq gnus-article-edit-done-function exit-func) | |
2460 (setq gnus-prev-winconf winconf) | |
2461 (gnus-message 6 "C-c C-c to end edits"))) | |
2462 | |
2463 (defun gnus-article-edit-done () | |
2464 "Update the article edits and exit." | |
2465 (interactive) | |
2466 (let ((func gnus-article-edit-done-function) | |
2467 (buf (current-buffer)) | |
2468 (start (window-start))) | |
2469 (gnus-article-edit-exit) | |
2470 (save-excursion | |
2471 (set-buffer buf) | |
2472 (let ((buffer-read-only nil)) | |
2473 (funcall func))) | |
2474 (set-buffer buf) | |
2475 (set-window-start (get-buffer-window buf) start) | |
2476 (set-window-point (get-buffer-window buf) (point)))) | |
2477 | |
2478 (defun gnus-article-edit-exit () | |
2479 "Exit the article editing without updating." | |
2480 (interactive) | |
2481 ;; We remove all text props from the article buffer. | |
2482 (let ((buf (format "%s" (buffer-string))) | |
2483 (curbuf (current-buffer)) | |
2484 (p (point)) | |
2485 (window-start (window-start))) | |
2486 (erase-buffer) | |
2487 (insert buf) | |
2488 (let ((winconf gnus-prev-winconf)) | |
2489 (gnus-article-mode) | |
2490 ;; The cache and backlog have to be flushed somewhat. | |
2491 (when gnus-use-cache | |
2492 (gnus-cache-update-article | |
2493 (car gnus-article-current) (cdr gnus-article-current))) | |
2494 (when gnus-keep-backlog | |
2495 (gnus-backlog-remove-article | |
2496 (car gnus-article-current) (cdr gnus-article-current))) | |
2497 ;; Flush original article as well. | |
2498 (save-excursion | |
2499 (when (get-buffer gnus-original-article-buffer) | |
2500 (set-buffer gnus-original-article-buffer) | |
2501 (setq gnus-original-article nil))) | |
2502 (set-window-configuration winconf) | |
2503 ;; Tippy-toe some to make sure that point remains where it was. | |
2504 (let ((buf (current-buffer))) | |
2505 (set-buffer curbuf) | |
2506 (set-window-start (get-buffer-window (current-buffer)) window-start) | |
2507 (goto-char p) | |
2508 (set-buffer buf))))) | |
2509 | |
2510 (defun gnus-article-edit-full-stops () | |
2511 "Interactively repair spacing at end of sentences." | |
2512 (interactive) | |
2513 (save-excursion | |
2514 (goto-char (point-min)) | |
2515 (search-forward-regexp "^$" nil t) | |
2516 (let ((case-fold-search nil)) | |
2517 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2")))) | |
2518 | |
2519 ;;; | |
2520 ;;; Article highlights | |
2521 ;;; | |
2522 | |
2523 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>. | |
2524 | |
2525 ;;; Internal Variables: | |
2526 | |
2527 (defcustom gnus-button-url-regexp "\\b\\(s?https?\\|ftp\\|file\\|gopher\\|news\\|telnet\\|wais\\|mailto\\):\\(//[-a-zA-Z0-9_.]+:[0-9]*\\)?\\([-a-zA-Z0-9_=!?#$@~`%&*+|\\/:;.,]\\|\\w\\)+\\([-a-zA-Z0-9_=#$@~`%&*+|\\/]\\|\\w\\)" | |
2528 "Regular expression that matches URLs." | |
2529 :group 'gnus-article-buttons | |
2530 :type 'regexp) | |
2531 | |
2532 (defcustom gnus-button-alist | |
2533 `(("<\\(url: ?\\)?news:\\([^>\n\t ]*@[^>\n\t ]*\\)>" 0 t | |
2534 gnus-button-message-id 2) | |
2535 ("\\bnews:\\([^>\n\t ]*@[^>\n\t ]*+\\)" 0 t gnus-button-message-id 1) | |
2536 ("\\(\\b<\\(url: ?\\)?news:\\(//\\)?\\([^>\n\t ]*\\)>\\)" 1 t | |
2537 gnus-button-fetch-group 4) | |
2538 ("\\bnews:\\(//\\)?\\([^>\n\t ]+\\)" 0 t gnus-button-fetch-group 2) | |
2539 ("\\bin\\( +article\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2 | |
2540 t gnus-button-message-id 3) | |
2541 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 1) | |
2542 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 2) | |
2543 ;; This is how URLs _should_ be embedded in text... | |
2544 ("<URL: *\\([^>]*\\)>" 0 t gnus-button-embedded-url 1) | |
2545 ;; Raw URLs. | |
2546 (,gnus-button-url-regexp 0 t gnus-button-url 0)) | |
2547 "Alist of regexps matching buttons in article bodies. | |
2548 | |
2549 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where | |
2550 REGEXP: is the string matching text around the button, | |
2551 BUTTON: is the number of the regexp grouping actually matching the button, | |
2552 FORM: is a lisp expression which must eval to true for the button to | |
2553 be added, | |
2554 CALLBACK: is the function to call when the user push this button, and each | |
2555 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK. | |
2556 | |
2557 CALLBACK can also be a variable, in that case the value of that | |
2558 variable it the real callback function." | |
2559 :group 'gnus-article-buttons | |
2560 :type '(repeat (list regexp | |
2561 (integer :tag "Button") | |
2562 (sexp :tag "Form") | |
2563 (function :tag "Callback") | |
2564 (repeat :tag "Par" | |
2565 :inline t | |
2566 (integer :tag "Regexp group"))))) | |
2567 | |
2568 (defcustom gnus-header-button-alist | |
2569 `(("^\\(References\\|Message-I[Dd]\\):" "<[^>]+>" | |
2570 0 t gnus-button-message-id 0) | |
2571 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1) | |
2572 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+" | |
2573 0 t gnus-button-mailto 0) | |
2574 ("^X-[Uu][Rr][Ll]:" ,gnus-button-url-regexp 0 t gnus-button-url 0) | |
2575 ("^[^:]+:" ,gnus-button-url-regexp 0 t gnus-button-url 0) | |
2576 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t | |
2577 gnus-button-message-id 3)) | |
2578 "Alist of headers and regexps to match buttons in article heads. | |
2579 | |
2580 This alist is very similar to `gnus-button-alist', except that each | |
2581 alist has an additional HEADER element first in each entry: | |
2582 | |
2583 \(HEADER REGEXP BUTTON FORM CALLBACK PAR) | |
2584 | |
2585 HEADER is a regexp to match a header. For a fuller explanation, see | |
2586 `gnus-button-alist'." | |
2587 :group 'gnus-article-buttons | |
2588 :group 'gnus-article-headers | |
2589 :type '(repeat (list (regexp :tag "Header") | |
2590 regexp | |
2591 (integer :tag "Button") | |
2592 (sexp :tag "Form") | |
2593 (function :tag "Callback") | |
2594 (repeat :tag "Par" | |
2595 :inline t | |
2596 (integer :tag "Regexp group"))))) | |
2597 | |
2598 (defvar gnus-button-regexp nil) | |
2599 (defvar gnus-button-marker-list nil) | |
2600 ;; Regexp matching any of the regexps from `gnus-button-alist'. | |
2601 | |
2602 (defvar gnus-button-last nil) | |
2603 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build. | |
2604 | |
2605 ;;; Commands: | |
2606 | |
2607 (defun gnus-article-push-button (event) | |
2608 "Check text under the mouse pointer for a callback function. | |
2609 If the text under the mouse pointer has a `gnus-callback' property, | |
2610 call it with the value of the `gnus-data' text property." | |
2611 (interactive "e") | |
2612 (set-buffer (window-buffer (posn-window (event-start event)))) | |
2613 (let* ((pos (posn-point (event-start event))) | |
2614 (data (get-text-property pos 'gnus-data)) | |
2615 (fun (get-text-property pos 'gnus-callback))) | |
2616 (when fun | |
2617 (funcall fun data)))) | |
2618 | |
2619 (defun gnus-article-press-button () | |
2620 "Check text at point for a callback function. | |
2621 If the text at point has a `gnus-callback' property, | |
2622 call it with the value of the `gnus-data' text property." | |
2623 (interactive) | |
2624 (let* ((data (get-text-property (point) 'gnus-data)) | |
2625 (fun (get-text-property (point) 'gnus-callback))) | |
2626 (when fun | |
2627 (funcall fun data)))) | |
2628 | |
2629 (defun gnus-article-prev-button (n) | |
2630 "Move point to N buttons backward. | |
2631 If N is negative, move forward instead." | |
2632 (interactive "p") | |
2633 (gnus-article-next-button (- n))) | |
2634 | |
2635 (defun gnus-article-next-button (n) | |
2636 "Move point to N buttons forward. | |
2637 If N is negative, move backward instead." | |
2638 (interactive "p") | |
2639 (let ((function (if (< n 0) 'previous-single-property-change | |
2640 'next-single-property-change)) | |
2641 (inhibit-point-motion-hooks t) | |
2642 (backward (< n 0)) | |
2643 (limit (if (< n 0) (point-min) (point-max)))) | |
2644 (setq n (abs n)) | |
2645 (while (and (not (= limit (point))) | |
2646 (> n 0)) | |
2647 ;; Skip past the current button. | |
2648 (when (get-text-property (point) 'gnus-callback) | |
2649 (goto-char (funcall function (point) 'gnus-callback nil limit))) | |
2650 ;; Go to the next (or previous) button. | |
2651 (gnus-goto-char (funcall function (point) 'gnus-callback nil limit)) | |
2652 ;; Put point at the start of the button. | |
2653 (when (and backward (not (get-text-property (point) 'gnus-callback))) | |
2654 (goto-char (funcall function (point) 'gnus-callback nil limit))) | |
2655 ;; Skip past intangible buttons. | |
2656 (when (get-text-property (point) 'intangible) | |
2657 (incf n)) | |
2658 (decf n)) | |
2659 (unless (zerop n) | |
2660 (gnus-message 5 "No more buttons")) | |
2661 n)) | |
2662 | |
2663 (defun gnus-article-highlight (&optional force) | |
2664 "Highlight current article. | |
2665 This function calls `gnus-article-highlight-headers', | |
2666 `gnus-article-highlight-citation', | |
2667 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to | |
2668 do the highlighting. See the documentation for those functions." | |
2669 (interactive (list 'force)) | |
2670 (gnus-article-highlight-headers) | |
2671 (gnus-article-highlight-citation force) | |
2672 (gnus-article-highlight-signature) | |
2673 (gnus-article-add-buttons force) | |
2674 (gnus-article-add-buttons-to-head)) | |
2675 | |
2676 (defun gnus-article-highlight-some (&optional force) | |
2677 "Highlight current article. | |
2678 This function calls `gnus-article-highlight-headers', | |
2679 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to | |
2680 do the highlighting. See the documentation for those functions." | |
2681 (interactive (list 'force)) | |
2682 (gnus-article-highlight-headers) | |
2683 (gnus-article-highlight-signature) | |
2684 (gnus-article-add-buttons)) | |
2685 | |
2686 (defun gnus-article-highlight-headers () | |
2687 "Highlight article headers as specified by `gnus-header-face-alist'." | |
2688 (interactive) | |
2689 (save-excursion | |
2690 (set-buffer gnus-article-buffer) | |
2691 (save-restriction | |
2692 (let ((alist gnus-header-face-alist) | |
2693 (buffer-read-only nil) | |
2694 (case-fold-search t) | |
2695 (inhibit-point-motion-hooks t) | |
2696 entry regexp header-face field-face from hpoints fpoints) | |
2697 (message-narrow-to-head) | |
2698 (while (setq entry (pop alist)) | |
2699 (goto-char (point-min)) | |
2700 (setq regexp (concat "^\\(" | |
2701 (if (string-equal "" (nth 0 entry)) | |
2702 "[^\t ]" | |
2703 (nth 0 entry)) | |
2704 "\\)") | |
2705 header-face (nth 1 entry) | |
2706 field-face (nth 2 entry)) | |
2707 (while (and (re-search-forward regexp nil t) | |
2708 (not (eobp))) | |
2709 (beginning-of-line) | |
2710 (setq from (point)) | |
2711 (unless (search-forward ":" nil t) | |
2712 (forward-char 1)) | |
2713 (when (and header-face | |
2714 (not (memq (point) hpoints))) | |
2715 (push (point) hpoints) | |
2716 (gnus-put-text-property from (point) 'face header-face)) | |
2717 (when (and field-face | |
2718 (not (memq (setq from (point)) fpoints))) | |
2719 (push from fpoints) | |
2720 (if (re-search-forward "^[^ \t]" nil t) | |
2721 (forward-char -2) | |
2722 (goto-char (point-max))) | |
2723 (gnus-put-text-property from (point) 'face field-face)))))))) | |
2724 | |
2725 (defun gnus-article-highlight-signature () | |
2726 "Highlight the signature in an article. | |
2727 It does this by highlighting everything after | |
2728 `gnus-signature-separator' using `gnus-signature-face'." | |
2729 (interactive) | |
2730 (save-excursion | |
2731 (set-buffer gnus-article-buffer) | |
2732 (let ((buffer-read-only nil) | |
2733 (inhibit-point-motion-hooks t)) | |
2734 (save-restriction | |
2735 (when (and gnus-signature-face | |
2736 (gnus-article-narrow-to-signature)) | |
2737 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max)) | |
2738 'face gnus-signature-face) | |
2739 (widen) | |
2740 (gnus-article-search-signature) | |
2741 (let ((start (match-beginning 0)) | |
2742 (end (set-marker (make-marker) (1+ (match-end 0))))) | |
2743 (gnus-article-add-button start (1- end) 'gnus-signature-toggle | |
2744 end))))))) | |
2745 | |
2746 (defun gnus-button-in-region-p (b e prop) | |
2747 "Say whether PROP exists in the region." | |
2748 (text-property-not-all b e prop nil)) | |
2749 | |
2750 (defun gnus-article-add-buttons (&optional force) | |
2751 "Find external references in the article and make buttons of them. | |
2752 \"External references\" are things like Message-IDs and URLs, as | |
2753 specified by `gnus-button-alist'." | |
2754 (interactive (list 'force)) | |
2755 (save-excursion | |
2756 (set-buffer gnus-article-buffer) | |
2757 (let ((buffer-read-only nil) | |
2758 (inhibit-point-motion-hooks t) | |
2759 (case-fold-search t) | |
2760 (alist gnus-button-alist) | |
2761 beg entry regexp) | |
2762 ;; Remove all old markers. | |
2763 (let (marker entry) | |
2764 (while (setq marker (pop gnus-button-marker-list)) | |
2765 (goto-char marker) | |
2766 (when (setq entry (gnus-button-entry)) | |
2767 (put-text-property (match-beginning (nth 1 entry)) | |
2768 (match-end (nth 1 entry)) | |
2769 'gnus-callback nil)) | |
2770 (set-marker marker nil))) | |
2771 ;; We skip the headers. | |
2772 (goto-char (point-min)) | |
2773 (unless (search-forward "\n\n" nil t) | |
2774 (goto-char (point-max))) | |
2775 (setq beg (point)) | |
2776 (while (setq entry (pop alist)) | |
2777 (setq regexp (car entry)) | |
2778 (goto-char beg) | |
2779 (while (re-search-forward regexp nil t) | |
2780 (let* ((start (and entry (match-beginning (nth 1 entry)))) | |
2781 (end (and entry (match-end (nth 1 entry)))) | |
2782 (from (match-beginning 0))) | |
2783 (when (and (or (eq t (nth 2 entry)) | |
2784 (eval (nth 2 entry))) | |
2785 (not (gnus-button-in-region-p | |
2786 start end 'gnus-callback))) | |
2787 ;; That optional form returned non-nil, so we add the | |
2788 ;; button. | |
2789 (gnus-article-add-button | |
2790 start end 'gnus-button-push | |
2791 (car (push (set-marker (make-marker) from) | |
2792 gnus-button-marker-list)))))))))) | |
2793 | |
2794 ;; Add buttons to the head of an article. | |
2795 (defun gnus-article-add-buttons-to-head () | |
2796 "Add buttons to the head of the article." | |
2797 (interactive) | |
2798 (save-excursion | |
2799 (set-buffer gnus-article-buffer) | |
2800 (let ((buffer-read-only nil) | |
2801 (inhibit-point-motion-hooks t) | |
2802 (case-fold-search t) | |
2803 (alist gnus-header-button-alist) | |
2804 entry beg end) | |
2805 (nnheader-narrow-to-headers) | |
2806 (while alist | |
2807 ;; Each alist entry. | |
2808 (setq entry (car alist) | |
2809 alist (cdr alist)) | |
2810 (goto-char (point-min)) | |
2811 (while (re-search-forward (car entry) nil t) | |
2812 ;; Each header matching the entry. | |
2813 (setq beg (match-beginning 0)) | |
2814 (setq end (or (and (re-search-forward "^[^ \t]" nil t) | |
2815 (match-beginning 0)) | |
2816 (point-max))) | |
2817 (goto-char beg) | |
2818 (while (re-search-forward (nth 1 entry) end t) | |
2819 ;; Each match within a header. | |
2820 (let* ((entry (cdr entry)) | |
2821 (start (match-beginning (nth 1 entry))) | |
2822 (end (match-end (nth 1 entry))) | |
2823 (form (nth 2 entry))) | |
2824 (goto-char (match-end 0)) | |
2825 (when (eval form) | |
2826 (gnus-article-add-button | |
2827 start end (nth 3 entry) | |
2828 (buffer-substring (match-beginning (nth 4 entry)) | |
2829 (match-end (nth 4 entry))))))) | |
2830 (goto-char end)))) | |
2831 (widen))) | |
2832 | |
2833 ;;; External functions: | |
2834 | |
2835 (defun gnus-article-add-button (from to fun &optional data) | |
2836 "Create a button between FROM and TO with callback FUN and data DATA." | |
2837 (when gnus-article-button-face | |
2838 (gnus-overlay-put (gnus-make-overlay from to) | |
2839 'face gnus-article-button-face)) | |
2840 (gnus-add-text-properties | |
2841 from to | |
2842 (nconc (and gnus-article-mouse-face | |
2843 (list gnus-mouse-face-prop gnus-article-mouse-face)) | |
2844 (list 'gnus-callback fun) | |
2845 (and data (list 'gnus-data data))))) | |
2846 | |
2847 ;;; Internal functions: | |
2848 | |
2849 (defun gnus-signature-toggle (end) | |
2850 (save-excursion | |
2851 (set-buffer gnus-article-buffer) | |
2852 (let ((buffer-read-only nil) | |
2853 (inhibit-point-motion-hooks t)) | |
2854 (if (get-text-property end 'invisible) | |
2855 (gnus-article-unhide-text end (point-max)) | |
2856 (gnus-article-hide-text end (point-max) gnus-hidden-properties))))) | |
2857 | |
2858 (defun gnus-button-entry () | |
2859 ;; Return the first entry in `gnus-button-alist' matching this place. | |
2860 (let ((alist gnus-button-alist) | |
2861 (entry nil)) | |
2862 (while alist | |
2863 (setq entry (pop alist)) | |
2864 (if (looking-at (car entry)) | |
2865 (setq alist nil) | |
2866 (setq entry nil))) | |
2867 entry)) | |
2868 | |
2869 (defun gnus-button-push (marker) | |
2870 ;; Push button starting at MARKER. | |
2871 (save-excursion | |
2872 (set-buffer gnus-article-buffer) | |
2873 (goto-char marker) | |
2874 (let* ((entry (gnus-button-entry)) | |
2875 (inhibit-point-motion-hooks t) | |
2876 (fun (nth 3 entry)) | |
2877 (args (mapcar (lambda (group) | |
2878 (let ((string (match-string group))) | |
2879 (gnus-set-text-properties | |
2880 0 (length string) nil string) | |
2881 string)) | |
2882 (nthcdr 4 entry)))) | |
2883 (cond | |
2884 ((fboundp fun) | |
2885 (apply fun args)) | |
2886 ((and (boundp fun) | |
2887 (fboundp (symbol-value fun))) | |
2888 (apply (symbol-value fun) args)) | |
2889 (t | |
2890 (gnus-message 1 "You must define `%S' to use this button" | |
2891 (cons fun args))))))) | |
2892 | |
2893 (defun gnus-button-message-id (message-id) | |
2894 "Fetch MESSAGE-ID." | |
2895 (save-excursion | |
2896 (set-buffer gnus-summary-buffer) | |
2897 (gnus-summary-refer-article message-id))) | |
2898 | |
2899 (defun gnus-button-fetch-group (address) | |
2900 "Fetch GROUP specified by ADDRESS." | |
2901 (if (not (string-match "[:/]" address)) | |
2902 ;; This is just a simple group url. | |
2903 (gnus-group-read-ephemeral-group address gnus-select-method) | |
2904 (if (not (string-match "^\\([^:/]+\\)\\(:\\([^/]+\\)/\\)?\\(.*\\)$" | |
2905 address)) | |
2906 (error "Can't parse %s" address) | |
2907 (gnus-group-read-ephemeral-group | |
2908 (match-string 4 address) | |
2909 `(nntp ,(match-string 1 address) | |
2910 (nntp-address ,(match-string 1 address)) | |
2911 (nntp-port-number ,(if (match-end 3) | |
2912 (match-string 3 address) | |
2913 "nntp"))))))) | |
2914 | |
2915 (defun gnus-split-string (string pattern) | |
2916 "Return a list of substrings of STRING which are separated by PATTERN." | |
2917 (let (parts (start 0)) | |
2918 (while (string-match pattern string start) | |
2919 (setq parts (cons (substring string start (match-beginning 0)) parts) | |
2920 start (match-end 0))) | |
2921 (nreverse (cons (substring string start) parts)))) | |
2922 | |
2923 (defun gnus-url-parse-query-string (query &optional downcase) | |
2924 (let (retval pairs cur key val) | |
2925 (setq pairs (gnus-split-string query "&")) | |
2926 (while pairs | |
2927 (setq cur (car pairs) | |
2928 pairs (cdr pairs)) | |
2929 (if (not (string-match "=" cur)) | |
2930 nil ; Grace | |
2931 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0))) | |
2932 val (gnus-url-unhex-string (substring cur (match-end 0) nil))) | |
2933 (if downcase | |
2934 (setq key (downcase key))) | |
2935 (setq cur (assoc key retval)) | |
2936 (if cur | |
2937 (setcdr cur (cons val (cdr cur))) | |
2938 (setq retval (cons (list key val) retval))))) | |
2939 retval)) | |
2940 | |
2941 (defun gnus-url-unhex (x) | |
2942 (if (> x ?9) | |
2943 (if (>= x ?a) | |
2944 (+ 10 (- x ?a)) | |
2945 (+ 10 (- x ?A))) | |
2946 (- x ?0))) | |
2947 | |
2948 (defun gnus-url-unhex-string (str &optional allow-newlines) | |
2949 "Remove %XXX embedded spaces, etc in a url. | |
2950 If optional second argument ALLOW-NEWLINES is non-nil, then allow the | |
2951 decoding of carriage returns and line feeds in the string, which is normally | |
2952 forbidden in URL encoding." | |
2953 (setq str (or str "")) | |
2954 (let ((tmp "") | |
2955 (case-fold-search t)) | |
2956 (while (string-match "%[0-9a-f][0-9a-f]" str) | |
2957 (let* ((start (match-beginning 0)) | |
2958 (ch1 (gnus-url-unhex (elt str (+ start 1)))) | |
2959 (code (+ (* 16 ch1) | |
2960 (gnus-url-unhex (elt str (+ start 2)))))) | |
2961 (setq tmp (concat | |
2962 tmp (substring str 0 start) | |
2963 (cond | |
2964 (allow-newlines | |
2965 (char-to-string code)) | |
2966 ((or (= code ?\n) (= code ?\r)) | |
2967 " ") | |
2968 (t (char-to-string code)))) | |
2969 str (substring str (match-end 0))))) | |
2970 (setq tmp (concat tmp str)) | |
2971 tmp)) | |
2972 | |
2973 (defun gnus-url-mailto (url) | |
2974 ;; Send mail to someone | |
2975 (when (string-match "mailto:/*\\(.*\\)" url) | |
2976 (setq url (substring url (match-beginning 1) nil))) | |
2977 (let (to args source-url subject func) | |
2978 (if (string-match (regexp-quote "?") url) | |
2979 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0))) | |
2980 args (gnus-url-parse-query-string | |
2981 (substring url (match-end 0) nil) t)) | |
2982 (setq to (gnus-url-unhex-string url))) | |
2983 (setq args (cons (list "to" to) args) | |
2984 subject (cdr-safe (assoc "subject" args))) | |
2985 (message-mail) | |
2986 (while args | |
2987 (setq func (intern-soft (concat "message-goto-" (downcase (caar args))))) | |
2988 (if (fboundp func) | |
2989 (funcall func) | |
2990 (message-position-on-field (caar args))) | |
2991 (insert (mapconcat 'identity (cdar args) ", ")) | |
2992 (setq args (cdr args))) | |
2993 (if subject | |
2994 (message-goto-body) | |
2995 (message-goto-subject)))) | |
2996 | |
2997 (defun gnus-button-mailto (address) | |
2998 ;; Mail to ADDRESS. | |
2999 (set-buffer (gnus-copy-article-buffer)) | |
3000 (message-reply address)) | |
3001 | |
3002 (defun gnus-button-reply (address) | |
3003 ;; Reply to ADDRESS. | |
3004 (message-reply address)) | |
3005 | |
3006 (defun gnus-button-url (address) | |
3007 "Browse ADDRESS." | |
3008 (funcall browse-url-browser-function address)) | |
3009 | |
3010 (defun gnus-button-embedded-url (address) | |
3011 "Browse ADDRESS." | |
3012 (funcall browse-url-browser-function (gnus-strip-whitespace address))) | |
3013 | |
3014 ;;; Next/prev buttons in the article buffer. | |
3015 | |
3016 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n") | |
3017 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n") | |
3018 | |
3019 (defvar gnus-prev-page-map nil) | |
3020 (unless gnus-prev-page-map | |
3021 (setq gnus-prev-page-map (make-sparse-keymap)) | |
3022 (define-key gnus-prev-page-map gnus-mouse-2 'gnus-button-prev-page) | |
3023 (define-key gnus-prev-page-map "\r" 'gnus-button-prev-page)) | |
3024 | |
3025 (defun gnus-insert-prev-page-button () | |
3026 (let ((buffer-read-only nil)) | |
3027 (gnus-eval-format | |
3028 gnus-prev-page-line-format nil | |
3029 `(gnus-prev t local-map ,gnus-prev-page-map | |
3030 gnus-callback gnus-article-button-prev-page)))) | |
3031 | |
3032 (defvar gnus-next-page-map nil) | |
3033 (unless gnus-next-page-map | |
3034 (setq gnus-next-page-map (make-keymap)) | |
3035 (suppress-keymap gnus-prev-page-map) | |
3036 (define-key gnus-next-page-map gnus-mouse-2 'gnus-button-next-page) | |
3037 (define-key gnus-next-page-map "\r" 'gnus-button-next-page)) | |
3038 | |
3039 (defun gnus-button-next-page () | |
3040 "Go to the next page." | |
3041 (interactive) | |
3042 (let ((win (selected-window))) | |
3043 (select-window (get-buffer-window gnus-article-buffer t)) | |
3044 (gnus-article-next-page) | |
3045 (select-window win))) | |
3046 | |
3047 (defun gnus-button-prev-page () | |
3048 "Go to the prev page." | |
3049 (interactive) | |
3050 (let ((win (selected-window))) | |
3051 (select-window (get-buffer-window gnus-article-buffer t)) | |
3052 (gnus-article-prev-page) | |
3053 (select-window win))) | |
3054 | |
3055 (defun gnus-insert-next-page-button () | |
3056 (let ((buffer-read-only nil)) | |
3057 (gnus-eval-format gnus-next-page-line-format nil | |
3058 `(gnus-next t local-map ,gnus-next-page-map | |
3059 gnus-callback | |
3060 gnus-article-button-next-page)))) | |
3061 | |
3062 (defun gnus-article-button-next-page (arg) | |
3063 "Go to the next page." | |
3064 (interactive "P") | |
3065 (let ((win (selected-window))) | |
3066 (select-window (get-buffer-window gnus-article-buffer t)) | |
3067 (gnus-article-next-page) | |
3068 (select-window win))) | |
3069 | |
3070 (defun gnus-article-button-prev-page (arg) | |
3071 "Go to the prev page." | |
3072 (interactive "P") | |
3073 (let ((win (selected-window))) | |
3074 (select-window (get-buffer-window gnus-article-buffer t)) | |
3075 (gnus-article-prev-page) | |
3076 (select-window win))) | |
3077 | |
3078 (gnus-ems-redefine) | |
3079 | |
3080 (provide 'gnus-art) | |
3081 | |
3082 (run-hooks 'gnus-art-load-hook) | |
3083 | |
3084 ;;; gnus-art.el ends here |