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