1 ;;; gnus-art.el --- article mode commands for Semi-gnus
2 ;; Copyright (C) 1996,97,98 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
5 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
6 ;; Keywords: mail, news, MIME
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval-when-compile (require 'cl))
40 (defgroup gnus-article nil
42 :link '(custom-manual "(gnus)The Article Buffer")
45 (defgroup gnus-article-hiding nil
46 "Hiding article parts."
47 :link '(custom-manual "(gnus)Article Hiding")
50 (defgroup gnus-article-highlight nil
51 "Article highlighting."
52 :link '(custom-manual "(gnus)Article Highlighting")
56 (defgroup gnus-article-signature nil
58 :link '(custom-manual "(gnus)Article Signature")
61 (defgroup gnus-article-headers nil
63 :link '(custom-manual "(gnus)Hiding Headers")
66 (defgroup gnus-article-washing nil
67 "Special commands on articles."
68 :link '(custom-manual "(gnus)Article Washing")
71 (defgroup gnus-article-emphasis nil
72 "Fontisizing articles."
73 :link '(custom-manual "(gnus)Article Fontisizing")
76 (defgroup gnus-article-saving nil
78 :link '(custom-manual "(gnus)Saving Articles")
81 (defgroup gnus-article-mime nil
82 "Worshiping the MIME wonder."
83 :link '(custom-manual "(gnus)Using MIME")
86 (defgroup gnus-article-buttons nil
87 "Pushable buttons in the article buffer."
88 :link '(custom-manual "(gnus)Article Buttons")
91 (defgroup gnus-article-various nil
92 "Other article options."
93 :link '(custom-manual "(gnus)Misc Article")
96 (defcustom gnus-ignored-headers
97 '("^Path:" "^Expires:" "^Date-Received:" "^References:" "^Xref:" "^Lines:"
98 "^Relay-Version:" "^Message-ID:" "^Approved:" "^Sender:" "^Received:"
99 "^X-UIDL:" "^MIME-Version:" "^Return-Path:" "^In-Reply-To:"
100 "^Content-Type:" "^Content-Transfer-Encoding:" "^X-WebTV-Signature:"
101 "^X-MimeOLE:" "^X-MSMail-Priority:" "^X-Priority:" "^X-Loop:"
102 "^X-Authentication-Warning:" "^X-MIME-Autoconverted:" "^X-Face:"
103 "^X-Attribution:" "^X-Originating-IP:" "^Delivered-To:"
104 "^NNTP-[-A-Za-z]+:" "^Distribution:" "^X-no-archive:" "^X-Trace:"
105 "^X-Complaints-To:" "^X-NNTP-Posting-Host:" "^X-Orig.*:"
106 "^Abuse-Reports-To:" "^Cache-Post-Path:" "^X-Article-Creation-Date:"
107 "^X-Poster:" "^X-Mail2News-Path:" "^X-Server-Date:" "^X-Cache:"
108 "^Originator:" "^X-Problems-To:" "^X-Auth-User:" "^X-Post-Time:"
109 "^X-Admin:" "^X-UID:" "^Resent-[-A-Za-z]+:" "^X-Mailing-List:"
110 "^Precedence:" "^Original-[-A-Za-z]+:" "^X-filename:" "^X-Orcpt:"
111 "^Old-Received:" "^X-Pgp-Fingerprint:" "^X-Pgp-Key-Id:"
112 "^X-Pgp-Public-Key-Url:" "^X-Auth:" "^X-From-Line:"
113 "^X-Gnus-Article-Number:" "^X-Majordomo:" "^X-Url:" "^X-Sender:"
114 "^X-Mailing-List:" "^MBOX-Line" "^Priority:" "^X-Pgp" "^X400-[-A-Za-z]+:"
116 "*All headers that start with this regexp will be hidden.
117 This variable can also be a list of regexps of headers to be ignored.
118 If `gnus-visible-headers' is non-nil, this variable will be ignored."
119 :type '(choice :custom-show nil
122 :group 'gnus-article-hiding)
124 (defcustom gnus-visible-headers
125 "From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^\\(Mail-\\)?Followup-To:\\|^\\(Mail-\\)?Reply-To:\\|^Mail-Copies-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^Cc:\\|^Posted-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-From:\\|X-Sent:"
126 "*All headers that do not match this regexp will be hidden.
127 This variable can also be a list of regexp of headers to remain visible.
128 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
129 :type '(repeat :value-to-internal (lambda (widget value)
130 (custom-split-regexp-maybe value))
131 :match (lambda (widget value)
133 (widget-editable-list-match widget value)))
135 :group 'gnus-article-hiding)
137 (defcustom gnus-sorted-header-list
138 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
139 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
140 "*This variable is a list of regular expressions.
141 If it is non-nil, headers that match the regular expressions will
142 be placed first in the article buffer in the sequence specified by
144 :type '(repeat regexp)
145 :group 'gnus-article-hiding)
147 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
148 "Headers that are only to be displayed if they have interesting data.
149 Possible values in this list are `empty', `newsgroups', `followup-to',
150 `reply-to', `date', `long-to', and `many-to'."
151 :type '(set (const :tag "Headers with no content." empty)
152 (const :tag "Newsgroups with only one group." newsgroups)
153 (const :tag "Followup-to identical to newsgroups." followup-to)
154 (const :tag "Reply-to identical to from." reply-to)
155 (const :tag "Date less than four days old." date)
156 (const :tag "Very long To header." long-to)
157 (const :tag "Multiple To headers." many-to))
158 :group 'gnus-article-hiding)
160 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
161 "Regexp matching signature separator.
162 This can also be a list of regexps. In that case, it will be checked
163 from head to tail looking for a separator. Searches will be done from
164 the end of the buffer."
165 :type '(repeat string)
166 :group 'gnus-article-signature)
168 (defcustom gnus-signature-limit nil
169 "Provide a limit to what is considered a signature.
170 If it is a number, no signature may not be longer (in characters) than
171 that number. If it is a floating point number, no signature may be
172 longer (in lines) than that number. If it is a function, the function
173 will be called without any parameters, and if it returns nil, there is
174 no signature in the buffer. If it is a string, it will be used as a
175 regexp. If it matches, the text in question is not a signature."
176 :type '(choice (integer :value 200)
178 (function :value fun)
179 (regexp :value ".*"))
180 :group 'gnus-article-signature)
182 (defcustom gnus-hidden-properties '(invisible t intangible t)
183 "Property list to use for hiding text."
185 :group 'gnus-article-hiding)
187 (defcustom gnus-article-x-face-command
188 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | xv -quit -"
189 "*String or function to be executed to display an X-Face header.
190 If it is a string, the command will be executed in a sub-shell
191 asynchronously. The compressed face will be piped to this command."
192 :type 'string ;Leave function case to Lisp.
193 :group 'gnus-article-washing)
195 (defcustom gnus-article-x-face-too-ugly nil
196 "Regexp matching posters whose face shouldn't be shown automatically."
197 :type '(choice regexp (const nil))
198 :group 'gnus-article-washing)
200 (defcustom gnus-emphasis-alist
202 "\\(\\s-\\|^\\|[-\"]\\|\\s(\\|\\s)\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\s-\\|[-?!.,;:\"]\\|\\s(\\|\\s)\\)")
204 '(("_" "_" underline)
207 ("_/" "/_" underline-italic)
208 ("_\\*" "\\*_" underline-bold)
209 ("\\*/" "/\\*" bold-italic)
210 ("_\\*/" "/\\*_" underline-bold-italic))))
211 `(("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
212 2 3 gnus-emphasis-underline)
216 (format format (car spec) (cadr spec))
217 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
219 "*Alist that says how to fontify certain phrases.
220 Each item looks like this:
222 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
224 The first element is a regular expression to be matched. The second
225 is a number that says what regular expression grouping used to find
226 the entire emphasized word. The third is a number that says what
227 regexp grouping should be displayed and highlighted. The fourth
228 is the face used for highlighting."
229 :type '(repeat (list :value ("" 0 0 default)
231 (integer :tag "Match group")
232 (integer :tag "Emphasize group")
234 :group 'gnus-article-emphasis)
236 (defface gnus-emphasis-bold '((t (:bold t)))
237 "Face used for displaying strong emphasized text (*word*)."
238 :group 'gnus-article-emphasis)
240 (defface gnus-emphasis-italic '((t (:italic t)))
241 "Face used for displaying italic emphasized text (/word/)."
242 :group 'gnus-article-emphasis)
244 (defface gnus-emphasis-underline '((t (:underline t)))
245 "Face used for displaying underlined emphasized text (_word_)."
246 :group 'gnus-article-emphasis)
248 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
249 "Face used for displaying underlined bold emphasized text (_*word*_)."
250 :group 'gnus-article-emphasis)
252 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
253 "Face used for displaying underlined italic emphasized text (_*word*_)."
254 :group 'gnus-article-emphasis)
256 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
257 "Face used for displaying bold italic emphasized text (/*word*/)."
258 :group 'gnus-article-emphasis)
260 (defface gnus-emphasis-underline-bold-italic
261 '((t (:bold t :italic t :underline t)))
262 "Face used for displaying underlined bold italic emphasized text.
263 Esample: (_/*word*/_)."
264 :group 'gnus-article-emphasis)
266 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
267 "Format for display of Date headers in article bodies.
268 See `format-time-string' for the possible values.
270 The variable can also be function, which should return a complete Date
271 header. The function is called with one argument, the time, which can
272 be fed to `format-time-string'."
273 :type '(choice string symbol)
274 :link '(custom-manual "(gnus)Article Date")
275 :group 'gnus-article-washing)
278 (autoload 'mail-extract-address-components "mail-extr"))
280 (defcustom gnus-save-all-headers t
281 "*If non-nil, don't remove any headers before saving."
282 :group 'gnus-article-saving
285 (defcustom gnus-prompt-before-saving 'always
286 "*This variable says how much prompting is to be done when saving articles.
287 If it is nil, no prompting will be done, and the articles will be
288 saved to the default files. If this variable is `always', each and
289 every article that is saved will be preceded by a prompt, even when
290 saving large batches of articles. If this variable is neither nil not
291 `always', there the user will be prompted once for a file name for
292 each invocation of the saving commands."
293 :group 'gnus-article-saving
294 :type '(choice (item always)
295 (item :tag "never" nil)
296 (sexp :tag "once" :format "%t\n" :value t)))
298 (defcustom gnus-saved-headers gnus-visible-headers
299 "Headers to keep if `gnus-save-all-headers' is nil.
300 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
301 If that variable is nil, however, all headers that match this regexp
302 will be kept while the rest will be deleted before saving."
303 :group 'gnus-article-saving
306 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
307 "A function to save articles in your favourite format.
308 The function must be interactively callable (in other words, it must
309 be an Emacs command).
311 Gnus provides the following functions:
313 * gnus-summary-save-in-rmail (Rmail format)
314 * gnus-summary-save-in-mail (Unix mail format)
315 * gnus-summary-save-in-folder (MH folder)
316 * gnus-summary-save-in-file (article format)
317 * gnus-summary-save-in-vm (use VM's folder format)
318 * gnus-summary-write-to-file (article format -- overwrite)."
319 :group 'gnus-article-saving
320 :type '(radio (function-item gnus-summary-save-in-rmail)
321 (function-item gnus-summary-save-in-mail)
322 (function-item gnus-summary-save-in-folder)
323 (function-item gnus-summary-save-in-file)
324 (function-item gnus-summary-save-in-vm)
325 (function-item gnus-summary-write-to-file)))
327 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
328 "A function generating a file name to save articles in Rmail format.
329 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
330 :group 'gnus-article-saving
333 (defcustom gnus-mail-save-name 'gnus-plain-save-name
334 "A function generating a file name to save articles in Unix mail format.
335 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
336 :group 'gnus-article-saving
339 (defcustom gnus-folder-save-name 'gnus-folder-save-name
340 "A function generating a file name to save articles in MH folder.
341 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
342 :group 'gnus-article-saving
345 (defcustom gnus-file-save-name 'gnus-numeric-save-name
346 "A function generating a file name to save articles in article format.
347 The function is called with NEWSGROUP, HEADERS, and optional
349 :group 'gnus-article-saving
352 (defcustom gnus-split-methods
353 '((gnus-article-archive-name)
354 (gnus-article-nndoc-name))
355 "*Variable used to suggest where articles are to be saved.
356 For instance, if you would like to save articles related to Gnus in
357 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
358 you could set this variable to something like:
360 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
361 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
363 This variable is an alist where the where the key is the match and the
364 value is a list of possible files to save in if the match is non-nil.
366 If the match is a string, it is used as a regexp match on the
367 article. If the match is a symbol, that symbol will be funcalled
368 from the buffer of the article to be saved with the newsgroup as the
369 parameter. If it is a list, it will be evaled in the same buffer.
371 If this form or function returns a string, this string will be used as
372 a possible file name; and if it returns a non-nil list, that list will
373 be used as possible file names."
374 :group 'gnus-article-saving
375 :type '(repeat (choice (list :value (fun) function)
376 (cons :value ("" "") regexp (repeat string))
379 (defcustom gnus-article-display-method-for-mime
380 'gnus-article-display-mime-message
381 "Function to display a MIME message.
382 The function is called from the article buffer."
383 :group 'gnus-article-mime
386 (defcustom gnus-article-display-method-for-encoded-word
387 'gnus-article-display-message-with-encoded-word
388 "*Function to display a message with MIME encoded-words.
389 The function is called from the article buffer."
390 :group 'gnus-article-mime
393 (defcustom gnus-article-display-method-for-traditional
394 'gnus-article-display-traditional-message
395 "*Function to display a traditional message.
396 The function is called from the article buffer."
397 :group 'gnus-article-mime
400 (defcustom gnus-page-delimiter "^\^L"
401 "*Regexp describing what to use as article page delimiters.
402 The default value is \"^\^L\", which is a form linefeed at the
403 beginning of a line."
405 :group 'gnus-article-various)
407 (defcustom gnus-article-mode-line-format "Gnus: %g %S"
408 "*The format specification for the article mode line.
409 See `gnus-summary-mode-line-format' for a closer description."
411 :group 'gnus-article-various)
413 (defcustom gnus-article-mode-hook nil
414 "*A hook for Gnus article mode."
416 :group 'gnus-article-various)
418 (defcustom gnus-article-menu-hook nil
419 "*Hook run after the creation of the article mode menu."
421 :group 'gnus-article-various)
423 (defcustom gnus-article-prepare-hook nil
424 "*A hook called after an article has been prepared in the article buffer.
425 If you want to run a special decoding program like nkf, use this hook."
427 :group 'gnus-article-various)
429 (defcustom gnus-article-hide-pgp-hook nil
430 "*A hook called after successfully hiding a PGP signature."
432 :group 'gnus-article-various)
434 (defcustom gnus-article-button-face 'bold
435 "Face used for highlighting buttons in the article buffer.
437 An article button is a piece of text that you can activate by pressing
438 `RET' or `mouse-2' above it."
440 :group 'gnus-article-buttons)
442 (defcustom gnus-article-mouse-face 'highlight
443 "Face used for mouse highlighting in the article buffer.
445 Article buttons will be displayed in this face when the cursor is
448 :group 'gnus-article-buttons)
450 (defcustom gnus-signature-face 'gnus-signature-face
451 "Face used for highlighting a signature in the article buffer.
452 Obsolete; use the face `gnus-signature-face' for customizations instead."
454 :group 'gnus-article-highlight
455 :group 'gnus-article-signature)
457 (defface gnus-signature-face
460 "Face used for highlighting a signature in the article buffer."
461 :group 'gnus-article-highlight
462 :group 'gnus-article-signature)
464 (defface gnus-header-from-face
467 (:foreground "spring green"))
470 (:foreground "red3"))
473 "Face used for displaying from headers."
474 :group 'gnus-article-headers
475 :group 'gnus-article-highlight)
477 (defface gnus-header-subject-face
480 (:foreground "SeaGreen3"))
483 (:foreground "red4"))
485 (:bold t :italic t)))
486 "Face used for displaying subject headers."
487 :group 'gnus-article-headers
488 :group 'gnus-article-highlight)
490 (defface gnus-header-newsgroups-face
493 (:foreground "yellow" :italic t))
496 (:foreground "MidnightBlue" :italic t))
499 "Face used for displaying newsgroups headers."
500 :group 'gnus-article-headers
501 :group 'gnus-article-highlight)
503 (defface gnus-header-name-face
506 (:foreground "SeaGreen"))
509 (:foreground "maroon"))
512 "Face used for displaying header names."
513 :group 'gnus-article-headers
514 :group 'gnus-article-highlight)
516 (defface gnus-header-content-face
519 (:foreground "forest green" :italic t))
522 (:foreground "indianred4" :italic t))
524 (:italic t))) "Face used for displaying header content."
525 :group 'gnus-article-headers
526 :group 'gnus-article-highlight)
528 (defcustom gnus-header-face-alist
529 '(("From" nil gnus-header-from-face)
530 ("Subject" nil gnus-header-subject-face)
531 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
532 ("" gnus-header-name-face gnus-header-content-face))
533 "*Controls highlighting of article header.
535 An alist of the form (HEADER NAME CONTENT).
537 HEADER is a regular expression which should match the name of an
538 header header and NAME and CONTENT are either face names or nil.
540 The name of each header field will be displayed using the face
541 specified by the first element in the list where HEADER match the
542 header name and NAME is non-nil. Similarly, the content will be
543 displayed by the first non-nil matching CONTENT face."
544 :group 'gnus-article-headers
545 :group 'gnus-article-highlight
546 :type '(repeat (list (regexp :tag "Header")
548 (item :tag "skip" nil)
549 (face :value default))
550 (choice :tag "Content"
551 (item :tag "skip" nil)
552 (face :value default)))))
554 (defcustom gnus-article-decode-hook nil
555 "*Hook run to decode charsets in articles."
556 :group 'gnus-article-headers
559 (defcustom gnus-display-mime-function 'gnus-display-mime
560 "Function to display MIME articles."
561 :group 'gnus-article-headers
564 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
565 "Function used to decode headers.")
567 ;;; Internal variables
569 (defvar article-lapsed-timer nil)
570 (defvar gnus-article-current-summary nil)
572 (defvar gnus-article-mode-syntax-table
573 (let ((table (copy-syntax-table text-mode-syntax-table)))
574 (modify-syntax-entry ?- "w" table)
575 (modify-syntax-entry ?> ")" table)
576 (modify-syntax-entry ?< "(" table)
578 "Syntax table used in article mode buffers.
579 Initialized from `text-mode-syntax-table.")
581 (defvar gnus-save-article-buffer nil)
583 (defvar gnus-article-mode-line-format-alist
584 (nconc '((?w (gnus-article-wash-status) ?s))
585 gnus-summary-mode-line-format-alist))
587 (defvar gnus-number-of-articles-to-be-saved nil)
589 (defvar gnus-inhibit-hiding nil)
591 (defsubst gnus-article-hide-text (b e props)
592 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
593 (add-text-properties b e props)
594 (when (memq 'intangible props)
596 (max (1- b) (point-min))
597 b 'intangible (cddr (memq 'intangible props)))))
599 (defsubst gnus-article-unhide-text (b e)
600 "Remove hidden text properties from region between B and E."
601 (remove-text-properties b e gnus-hidden-properties)
602 (when (memq 'intangible gnus-hidden-properties)
603 (put-text-property (max (1- b) (point-min))
606 (defun gnus-article-hide-text-type (b e type)
607 "Hide text of TYPE between B and E."
608 (gnus-article-hide-text
609 b e (cons 'article-type (cons type gnus-hidden-properties))))
611 (defun gnus-article-unhide-text-type (b e type)
612 "Unhide text of TYPE between B and E."
613 (remove-text-properties
614 b e (cons 'article-type (cons type gnus-hidden-properties)))
615 (when (memq 'intangible gnus-hidden-properties)
616 (put-text-property (max (1- b) (point-min))
619 (defun gnus-article-hide-text-of-type (type)
620 "Hide text of TYPE in the current buffer."
622 (let ((b (point-min))
624 (while (setq b (text-property-any b e 'article-type type))
625 (add-text-properties b (incf b) gnus-hidden-properties)))))
627 (defun gnus-article-delete-text-of-type (type)
628 "Delete text of TYPE in the current buffer."
630 (let ((b (point-min)))
631 (while (setq b (text-property-any b (point-max) 'article-type type))
633 b (or (text-property-not-all b (point-max) 'article-type type)
636 (defun gnus-article-delete-invisible-text ()
637 "Delete all invisible text in the current buffer."
639 (let ((b (point-min)))
640 (while (setq b (text-property-any b (point-max) 'invisible t))
642 b (or (text-property-not-all b (point-max) 'invisible t)
645 (defun gnus-article-text-type-exists-p (type)
646 "Say whether any text of type TYPE exists in the buffer."
647 (text-property-any (point-min) (point-max) 'article-type type))
649 (defsubst gnus-article-header-rank ()
650 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
651 (let ((list gnus-sorted-header-list)
654 (when (looking-at (car list))
656 (setq list (cdr list))
660 (defun article-hide-headers (&optional arg delete)
661 "Toggle whether to hide unwanted headers and possibly sort them as well.
662 If given a negative prefix, always show; if given a positive prefix,
664 (interactive (gnus-article-hidden-arg))
666 (if (gnus-article-check-hidden-text 'headers arg)
667 ;; Show boring headers as well.
668 (gnus-article-show-hidden-text 'boring-headers)
669 ;; This function might be inhibited.
670 (unless gnus-inhibit-hiding
673 (let ((buffer-read-only nil)
675 (props (nconc (list 'article-type 'headers)
676 gnus-hidden-properties))
677 (max (1+ (length gnus-sorted-header-list)))
678 (ignored (when (not gnus-visible-headers)
679 (cond ((stringp gnus-ignored-headers)
680 gnus-ignored-headers)
681 ((listp gnus-ignored-headers)
682 (mapconcat 'identity gnus-ignored-headers
685 (cond ((stringp gnus-visible-headers)
686 gnus-visible-headers)
687 ((and gnus-visible-headers
688 (listp gnus-visible-headers))
689 (mapconcat 'identity gnus-visible-headers "\\|"))))
690 (inhibit-point-motion-hooks t)
692 ;; First we narrow to just the headers.
694 (goto-char (point-min))
695 ;; Hide any "From " lines at the beginning of (mail) articles.
696 (while (looking-at "From ")
700 (delete-region (point-min) (point))
701 (gnus-article-hide-text (point-min) (point) props)))
702 ;; Then treat the rest of the header lines.
705 (if (search-forward "\n\n" nil t) ; if there's a body
706 (progn (forward-line -1) (point))
708 ;; Then we use the two regular expressions
709 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
710 ;; select which header lines is to remain visible in the
712 (goto-char (point-min))
713 (while (re-search-forward "^[^ \t]*:" nil t)
715 ;; Mark the rank of the header.
717 (point) (1+ (point)) 'message-rank
718 (if (or (and visible (looking-at visible))
720 (not (looking-at ignored))))
721 (gnus-article-header-rank)
724 (message-sort-headers-1)
725 (when (setq beg (text-property-any
726 (point-min) (point-max) 'message-rank (+ 2 max)))
727 ;; We make the unwanted headers invisible.
729 (delete-region beg (point-max))
730 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
731 (gnus-article-hide-text-type beg (point-max) 'headers))
732 ;; Work around XEmacs lossage.
733 (put-text-property (point-min) beg 'invisible nil))))))))
735 (defun article-hide-boring-headers (&optional arg)
736 "Toggle hiding of headers that aren't very interesting.
737 If given a negative prefix, always show; if given a positive prefix,
739 (interactive (gnus-article-hidden-arg))
740 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
741 (not gnus-show-all-headers))
744 (let ((buffer-read-only nil)
745 (list gnus-boring-article-headers)
746 (inhibit-point-motion-hooks t)
748 (nnheader-narrow-to-headers)
750 (setq elem (pop list))
751 (goto-char (point-min))
753 ;; Hide empty headers.
755 (while (re-search-forward "^[^:]+:[ \t]*\n[^ \t]" nil t)
757 (gnus-article-hide-text-type
758 (progn (beginning-of-line) (point))
761 (if (re-search-forward "^[^ \t]" nil t)
765 ;; Hide boring Newsgroups header.
766 ((eq elem 'newsgroups)
767 (when (equal (gnus-fetch-field "newsgroups")
768 (gnus-group-real-name
769 (if (boundp 'gnus-newsgroup-name)
772 (gnus-article-hide-header "newsgroups")))
773 ((eq elem 'followup-to)
774 (when (equal (message-fetch-field "followup-to")
775 (message-fetch-field "newsgroups"))
776 (gnus-article-hide-header "followup-to")))
778 (let ((from (message-fetch-field "from"))
779 (reply-to (message-fetch-field "reply-to")))
784 (nth 1 (funcall gnus-extract-address-components from))
785 (nth 1 (funcall gnus-extract-address-components reply-to)))))
786 (gnus-article-hide-header "reply-to"))))
788 (let ((date (message-fetch-field "date")))
790 (< (days-between (current-time-string) date)
792 (gnus-article-hide-header "date"))))
794 (let ((to (message-fetch-field "to")))
795 (when (> (length to) 1024)
796 (gnus-article-hide-header "to"))))
799 (goto-char (point-min))
800 (while (re-search-forward "^to:" nil t)
801 (setq to-count (1+ to-count)))
803 (while (> to-count 0)
804 (goto-char (point-min))
806 (re-search-forward "^to:" nil nil to-count)
808 (narrow-to-region (point) (point-max))
809 (gnus-article-hide-header "to"))
810 (setq to-count (1- to-count)))))))))))))
812 (defun gnus-article-hide-header (header)
814 (goto-char (point-min))
815 (when (re-search-forward (concat "^" header ":") nil t)
816 (gnus-article-hide-text-type
817 (progn (beginning-of-line) (point))
820 (if (re-search-forward "^[^ \t]" nil t)
825 (defun article-treat-dumbquotes ()
826 "Translate M******** sm*rtq**t*s into proper text."
828 (article-translate-characters "\221\222\223\224" "`'\"\""))
830 (defun article-translate-characters (from to)
831 "Translate all characters in the body of the article according to FROM and TO.
832 FROM is a string of characters to translate from; to is a string of
833 characters to translate to."
835 (goto-char (point-min))
836 (when (search-forward "\n\n" nil t)
837 (let ((buffer-read-only nil)
838 (x (make-string 225 ?x))
840 (while (< (incf i) (length x))
843 (while (< i (length from))
844 (aset x (aref from i) (aref to i))
846 (translate-region (point) (point-max) x)))))
848 (defun article-treat-overstrike ()
849 "Translate overstrikes into bold text."
852 (goto-char (point-min))
853 (when (search-forward "\n\n" nil t)
854 (let ((buffer-read-only nil))
855 (while (search-forward "\b" nil t)
856 (let ((next (following-char))
857 (previous (char-after (- (point) 2))))
858 ;; We do the boldification/underlining by hiding the
859 ;; overstrikes and putting the proper text property
863 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
864 (put-text-property (point) (1+ (point)) 'face 'bold))
866 (gnus-article-hide-text-type
867 (1- (point)) (1+ (point)) 'overstrike)
869 (- (point) 2) (1- (point)) 'face 'underline))
871 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
873 (point) (1+ (point)) 'face 'underline)))))))))
875 (defun article-fill ()
876 "Format too long lines."
879 (let ((buffer-read-only nil))
881 (goto-char (point-min))
882 (search-forward "\n\n" nil t)
884 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$")
885 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?")
886 (adaptive-fill-mode t))
888 (and (>= (current-column) (min fill-column (window-width)))
889 (/= (preceding-char) ?:)
890 (fill-paragraph nil))
893 (defun article-remove-cr ()
894 "Remove carriage returns from an article."
897 (let ((buffer-read-only nil))
898 (goto-char (point-min))
899 (while (search-forward "\r" nil t)
900 (replace-match "" t t)))))
902 (defun article-remove-trailing-blank-lines ()
903 "Remove all trailing blank lines from the article."
906 (let ((buffer-read-only nil))
907 (goto-char (point-max))
911 (while (and (not (bobp))
912 (looking-at "^[ \t]*$")
913 (not (gnus-annotation-in-region-p
914 (point) (gnus-point-at-eol))))
919 (defun article-display-x-face (&optional force)
920 "Look for an X-Face header and display it if present."
921 (interactive (list 'force))
923 ;; Delete the old process, if any.
924 (when (process-status "article-x-face")
925 (delete-process "article-x-face"))
926 (let ((inhibit-point-motion-hooks t)
930 (nnheader-narrow-to-headers)
931 (setq from (message-fetch-field "from"))
932 (goto-char (point-min))
933 (while (and gnus-article-x-face-command
936 ;; Check whether this face is censored.
937 (not gnus-article-x-face-too-ugly)
938 (and gnus-article-x-face-too-ugly from
939 (not (string-match gnus-article-x-face-too-ugly
941 ;; Has to be present.
942 (re-search-forward "^X-Face: " nil t))
943 ;; This used to try to do multiple faces (`while' instead of
944 ;; `when' above), but (a) sending multiple EOFs to xv doesn't
945 ;; work (b) it can crash some versions of Emacs (c) are
946 ;; multiple faces really something to encourage?
947 (when (stringp gnus-article-x-face-command)
949 ;; We now have the area of the buffer where the X-Face is stored.
952 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
953 ;; We display the face.
954 (if (symbolp gnus-article-x-face-command)
955 ;; The command is a lisp function, so we call it.
956 (if (gnus-functionp gnus-article-x-face-command)
957 (funcall gnus-article-x-face-command beg end)
958 (error "%s is not a function" gnus-article-x-face-command))
959 ;; The command is a string, so we interpret the command
960 ;; as a, well, command, and fork it off.
961 (let ((process-connection-type nil))
962 (process-kill-without-query
964 "article-x-face" nil shell-file-name shell-command-switch
965 gnus-article-x-face-command))
966 (process-send-region "article-x-face" beg end)
967 (process-send-eof "article-x-face"))))))))))
969 (defun article-decode-mime-words ()
970 "Decode all MIME-encoded words in the article."
973 (set-buffer gnus-article-buffer)
974 (let ((inhibit-point-motion-hooks t)
976 (mail-decode-encoded-word-region (point-min) (point-max)))))
978 (defun article-decode-charset (&optional prompt)
979 "Decode charset-encoded text in the article.
980 If PROMPT (the prefix), prompt for a coding system to use."
984 (message-narrow-to-head)
985 (let* ((inhibit-point-motion-hooks t)
987 (ct (message-fetch-field "Content-Type" t))
988 (cte (message-fetch-field "Content-Transfer-Encoding" t))
989 (ctl (and ct (condition-case ()
990 (mail-header-parse-content-type ct)
994 (mm-read-coding-system "Charset to decode: "))
996 (mail-content-type-get ctl 'charset))
998 (gnus-group-find-parameter
999 gnus-newsgroup-name 'charset))))
1001 (goto-char (point-max))
1004 (narrow-to-region (point) (point-max))
1006 (equal (car ctl) "text/plain"))
1008 charset (and cte (intern (downcase
1009 (gnus-strip-whitespace cte))))))))))
1011 (defun article-decode-encoded-words ()
1012 "Remove encoded-word encoding from headers."
1013 (let (buffer-read-only)
1014 (let ((charset (save-excursion
1015 (set-buffer gnus-summary-buffer)
1016 default-mime-charset)))
1017 (eword-decode-header charset)
1020 (defun article-de-quoted-unreadable (&optional force)
1021 "Translate a quoted-printable-encoded article.
1022 If FORCE, decode the article whether it is marked as quoted-printable
1024 (interactive (list 'force))
1026 (let ((buffer-read-only nil)
1027 (type (gnus-fetch-field "content-transfer-encoding")))
1029 (and type (string-match "quoted-printable" (downcase type))))
1030 (goto-char (point-min))
1031 (search-forward "\n\n" nil 'move)
1032 (quoted-printable-decode-region (point) (point-max))))))
1034 (defun article-mime-decode-quoted-printable-buffer ()
1035 "Decode Quoted-Printable in the current buffer."
1036 (quoted-printable-decode-region (point-min) (point-max)))
1038 (defun article-hide-pgp (&optional arg)
1039 "Toggle hiding of any PGP headers and signatures in the current article.
1040 If given a negative prefix, always show; if given a positive prefix,
1042 (interactive (gnus-article-hidden-arg))
1043 (unless (gnus-article-check-hidden-text 'pgp arg)
1045 (let ((inhibit-point-motion-hooks t)
1046 buffer-read-only beg end)
1048 (goto-char (point-min))
1049 ;; Hide the "header".
1050 (when (search-forward "\n-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
1051 (delete-region (1+ (match-beginning 0)) (match-end 0))
1053 ;; Hide the actual signature.
1054 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
1055 (setq end (1+ (match-beginning 0)))
1058 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
1060 ;; Perhaps we shouldn't hide to the end of the buffer
1061 ;; if there is no end to the signature?
1063 ;; Hide "- " PGP quotation markers.
1065 (narrow-to-region beg end)
1066 (goto-char (point-min))
1067 (while (re-search-forward "^- " nil t)
1069 (match-beginning 0) (match-end 0)))
1071 (gnus-run-hooks 'gnus-article-hide-pgp-hook))))))
1073 (defun article-hide-pem (&optional arg)
1074 "Toggle hiding of any PEM headers and signatures in the current article.
1075 If given a negative prefix, always show; if given a positive prefix,
1077 (interactive (gnus-article-hidden-arg))
1078 (unless (gnus-article-check-hidden-text 'pem arg)
1080 (let (buffer-read-only end)
1082 (goto-char (point-min))
1083 ;; hide the horrendously ugly "header".
1084 (and (search-forward "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
1087 (setq end (1+ (match-beginning 0)))
1088 (gnus-article-hide-text-type
1090 (if (search-forward "\n\n" nil t)
1094 ;; hide the trailer as well
1095 (and (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
1098 (gnus-article-hide-text-type
1099 (match-beginning 0) (match-end 0) 'pem))))))
1101 (defun article-hide-signature (&optional arg)
1102 "Hide the signature in the current article.
1103 If given a negative prefix, always show; if given a positive prefix,
1105 (interactive (gnus-article-hidden-arg))
1106 (unless (gnus-article-check-hidden-text 'signature arg)
1109 (let ((buffer-read-only nil))
1110 (when (gnus-article-narrow-to-signature)
1111 (gnus-article-hide-text-type
1112 (point-min) (point-max) 'signature)))))))
1114 (defun article-strip-leading-blank-lines ()
1115 "Remove all blank lines from the beginning of the article."
1118 (let ((inhibit-point-motion-hooks t)
1120 (goto-char (point-min))
1121 (when (search-forward "\n\n" nil t)
1122 (while (and (not (eobp))
1123 (looking-at "[ \t]*$"))
1124 (gnus-delete-line))))))
1126 (defun article-strip-multiple-blank-lines ()
1127 "Replace consecutive blank lines with one empty line."
1130 (let ((inhibit-point-motion-hooks t)
1132 ;; First make all blank lines empty.
1133 (goto-char (point-min))
1134 (search-forward "\n\n" nil t)
1135 (while (re-search-forward "^[ \t]+$" nil t)
1136 (unless (gnus-annotation-in-region-p
1137 (match-beginning 0) (match-end 0))
1138 (replace-match "" nil t)))
1139 ;; Then replace multiple empty lines with a single empty line.
1140 (goto-char (point-min))
1141 (search-forward "\n\n" nil t)
1142 (while (re-search-forward "\n\n\n+" nil t)
1143 (unless (gnus-annotation-in-region-p
1144 (match-beginning 0) (match-end 0))
1145 (replace-match "\n\n" t t))))))
1147 (defun article-strip-leading-space ()
1148 "Remove all white space from the beginning of the lines in the article."
1151 (let ((inhibit-point-motion-hooks t)
1153 (goto-char (point-min))
1154 (search-forward "\n\n" nil t)
1155 (while (re-search-forward "^[ \t]+" nil t)
1156 (replace-match "" t t)))))
1158 (defun article-strip-blank-lines ()
1159 "Strip leading, trailing and multiple blank lines."
1161 (article-strip-leading-blank-lines)
1162 (article-remove-trailing-blank-lines)
1163 (article-strip-multiple-blank-lines))
1165 (defun article-strip-all-blank-lines ()
1166 "Strip all blank lines."
1169 (let ((inhibit-point-motion-hooks t)
1171 (goto-char (point-min))
1172 (search-forward "\n\n" nil t)
1173 (while (re-search-forward "^[ \t]*\n" nil t)
1174 (replace-match "" t t)))))
1176 (defun gnus-article-narrow-to-signature ()
1177 "Narrow to the signature; return t if a signature is found, else nil."
1179 (let ((inhibit-point-motion-hooks t))
1180 (when (gnus-article-search-signature)
1182 ;; Check whether we have some limits to what we consider
1183 ;; to be a signature.
1184 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
1185 (list gnus-signature-limit)))
1187 (while (setq limit (pop limits))
1188 (if (or (and (integerp limit)
1189 (< (- (point-max) (point)) limit))
1191 (< (count-lines (point) (point-max)) limit))
1192 (and (gnus-functionp limit)
1194 (and (stringp limit)
1195 (not (re-search-forward limit nil t))))
1196 () ; This limit did not succeed.
1200 (narrow-to-region (point) (point-max))
1203 (defun gnus-article-search-signature ()
1204 "Search the current buffer for the signature separator.
1205 Put point at the beginning of the signature separator."
1206 (let ((cur (point)))
1207 (goto-char (point-max))
1208 (if (if (stringp gnus-signature-separator)
1209 (re-search-backward gnus-signature-separator nil t)
1210 (let ((seps gnus-signature-separator))
1212 (not (re-search-backward (car seps) nil t)))
1220 (autoload 'w3-display "w3-parse")
1221 (autoload 'w3-do-setup "w3" "" t)
1222 (autoload 'w3-region "w3-display" "" t))
1224 (defun gnus-article-treat-html ()
1227 (let ((cbuf (current-buffer)))
1228 (set-buffer gnus-article-buffer)
1229 (let (buf buffer-read-only b e)
1231 (goto-char (point-min))
1233 (if (search-forward "\n\n" nil t)
1236 (setq e (point-max)))
1238 (insert-buffer-substring gnus-article-buffer b e)
1240 (save-window-excursion
1241 (w3-region (point-min) (point-max))
1242 (setq buf (buffer-substring-no-properties (point-min) (point-max)))))
1244 (delete-region (point-min) (point-max))
1247 (goto-char (point-min))
1248 (set-window-start (get-buffer-window (current-buffer)) (point-min))
1249 (set-buffer cbuf))))
1251 (defun gnus-article-hidden-arg ()
1252 "Return the current prefix arg as a number, or 0 if no prefix."
1253 (list (if current-prefix-arg
1254 (prefix-numeric-value current-prefix-arg)
1257 (defun gnus-article-check-hidden-text (type arg)
1258 "Return nil if hiding is necessary.
1259 Arg can be nil or a number. Nil and positive means hide, negative
1260 means show, 0 means toggle."
1264 (let ((hide (gnus-article-hidden-text-p type)))
1270 (gnus-article-show-hidden-text type))
1272 (if (eq hide 'hidden)
1273 (gnus-article-show-hidden-text type)
1276 (defun gnus-article-hidden-text-p (type)
1277 "Say whether the current buffer contains hidden text of type TYPE."
1278 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
1280 (not (get-text-property pos 'invisible)))
1282 (text-property-any (1+ pos) (point-max) 'article-type type)))
1287 (defun gnus-article-show-hidden-text (type &optional hide)
1288 "Show all hidden text of type TYPE.
1289 If HIDE, hide the text instead."
1291 (let ((buffer-read-only nil)
1292 (inhibit-point-motion-hooks t)
1295 (while (setq beg (text-property-any end (point-max) 'article-type type))
1298 (text-property-not-all beg (point-max) 'article-type type)
1301 (gnus-article-hide-text beg end gnus-hidden-properties)
1302 (gnus-article-unhide-text beg end))
1306 (defconst article-time-units
1307 `((year . ,(* 365.25 24 60 60))
1308 (week . ,(* 7 24 60 60))
1309 (day . ,(* 24 60 60))
1313 "Mapping from time units to seconds.")
1315 (defun article-date-ut (&optional type highlight header)
1316 "Convert DATE date to universal time in the current article.
1317 If TYPE is `local', convert to local time; if it is `lapsed', output
1318 how much time has lapsed since DATE."
1319 (interactive (list 'ut t))
1320 (let* ((header (or header
1321 (mail-header-date gnus-current-headers)
1322 (message-fetch-field "date")
1324 (date (if (vectorp header) (mail-header-date header)
1326 (date-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
1327 (inhibit-point-motion-hooks t)
1328 bface eface newline)
1329 (when (and date (not (string= date "")))
1332 (nnheader-narrow-to-headers)
1333 (let ((buffer-read-only nil))
1334 ;; Delete any old Date headers.
1335 (if (re-search-forward date-regexp nil t)
1337 (setq bface (get-text-property (gnus-point-at-bol) 'face)
1338 eface (get-text-property (1- (gnus-point-at-eol))
1340 (delete-region (progn (beginning-of-line) (point))
1341 (progn (end-of-line) (point)))
1342 (beginning-of-line))
1343 (goto-char (point-max))
1345 (insert (article-make-date-line date type))
1348 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
1349 (put-text-property (match-beginning 1) (1+ (match-end 1))
1351 (put-text-property (match-beginning 2) (match-end 2)
1355 (insert "\n"))))))))
1357 (defun article-make-date-line (date type)
1358 "Return a DATE line of TYPE."
1359 (let ((time (condition-case ()
1363 ;; Convert to the local timezone. We have to slap a
1364 ;; `condition-case' round the calls to the timezone
1365 ;; functions since they aren't particularly resistant to
1368 (let ((tz (car (current-time-zone))))
1369 (format "Date: %s %s%04d" (current-time-string time)
1370 (if (> tz 0) "+" "-") (abs (/ tz 36)))))
1371 ;; Convert to Universal Time.
1374 (current-time-string
1375 (let* ((e (parse-time-string date))
1376 (tm (apply 'encode-time e))
1378 (ls (- (cadr tm) (car (current-time-zone)))))
1379 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
1380 ((> ls 65535) (list (1+ ms) (- ls 65536)))
1383 ;; Get the original date from the article.
1384 ((eq type 'original)
1385 (concat "Date: " (if (string-match "\n+$" date)
1386 (substring date 0 (match-beginning 0))
1388 ;; Let the user define the format.
1390 (if (gnus-functionp gnus-article-time-format)
1391 (funcall gnus-article-time-format time)
1394 (format-time-string gnus-article-time-format time))))
1399 (format-time-string "%Y%M%DT%h%m%s" time)))
1400 ;; Do an X-Sent lapsed format.
1402 ;; If the date is seriously mangled, the timezone functions are
1403 ;; liable to bug out, so we ignore all errors.
1404 (let* ((now (current-time))
1405 (real-time (subtract-time now time))
1406 (real-sec (and real-time
1407 (+ (* (float (car real-time)) 65536)
1409 (sec (and real-time (abs real-sec)))
1419 ;; This is a bit convoluted, but basically we go
1420 ;; through the time units for years, weeks, etc,
1421 ;; and divide things to see whether that results
1422 ;; in positive answers.
1425 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
1426 ;; The (remaining) seconds are too few to
1427 ;; be divided into this time unit.
1429 ;; It's big enough, so we output it.
1430 (setq sec (- sec (* num (cdr unit))))
1432 (concat (if prev ", " "") (int-to-string
1434 " " (symbol-name (car unit))
1435 (if (> num 1) "s" ""))
1437 article-time-units "")
1438 ;; If dates are odd, then it might appear like the
1439 ;; article was sent in the future.
1442 " in the future"))))))
1444 (error "Unknown conversion type: %s" type)))))
1446 (defun article-date-local (&optional highlight)
1447 "Convert the current article date to the local timezone."
1448 (interactive (list t))
1449 (article-date-ut 'local highlight))
1451 (defun article-date-original (&optional highlight)
1452 "Convert the current article date to what it was originally.
1453 This is only useful if you have used some other date conversion
1454 function and want to see what the date was before converting."
1455 (interactive (list t))
1456 (article-date-ut 'original highlight))
1458 (defun article-date-lapsed (&optional highlight)
1459 "Convert the current article date to time lapsed since it was sent."
1460 (interactive (list t))
1461 (article-date-ut 'lapsed highlight))
1463 (defun article-update-date-lapsed ()
1464 "Function to be run from a timer to update the lapsed time line."
1465 (let (deactivate-mark)
1468 (when (and (gnus-buffer-live-p gnus-article-buffer)
1469 (get-buffer-window gnus-article-buffer))
1470 (set-buffer gnus-article-buffer)
1471 (goto-char (point-min))
1472 (when (re-search-forward "^X-Sent:" nil t)
1473 (article-date-lapsed t)))))))
1475 (defun gnus-start-date-timer (&optional n)
1476 "Start a timer to update the X-Sent header in the article buffers.
1477 The numerical prefix says how frequently (in seconds) the function
1482 (gnus-stop-date-timer)
1483 (setq article-lapsed-timer
1484 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
1486 (defun gnus-stop-date-timer ()
1487 "Stop the X-Sent timer."
1489 (when article-lapsed-timer
1490 (nnheader-cancel-timer article-lapsed-timer)
1491 (setq article-lapsed-timer nil)))
1493 (defun article-date-user (&optional highlight)
1494 "Convert the current article date to the user-defined format.
1495 This format is defined by the `gnus-article-time-format' variable."
1496 (interactive (list t))
1497 (article-date-ut 'user highlight))
1499 (defun article-date-iso8601 (&optional highlight)
1500 "Convert the current article date to ISO8601."
1501 (interactive (list t))
1502 (article-date-ut 'iso8601 highlight))
1504 (defun article-show-all ()
1505 "Show all hidden text in the article buffer."
1508 (let ((buffer-read-only nil))
1509 (gnus-article-unhide-text (point-min) (point-max)))))
1511 (defun article-emphasize (&optional arg)
1512 "Emphasize text according to `gnus-emphasis-alist'."
1513 (interactive (gnus-article-hidden-arg))
1514 (unless (gnus-article-check-hidden-text 'emphasis arg)
1516 (let ((alist gnus-emphasis-alist)
1517 (buffer-read-only nil)
1518 (props (append '(article-type emphasis)
1519 gnus-hidden-properties))
1520 regexp elem beg invisible visible face)
1521 (goto-char (point-min))
1522 (search-forward "\n\n" nil t)
1524 (while (setq elem (pop alist))
1526 (setq regexp (car elem)
1527 invisible (nth 1 elem)
1528 visible (nth 2 elem)
1530 (while (re-search-forward regexp nil t)
1531 (when (and (match-beginning visible) (match-beginning invisible))
1532 (gnus-article-hide-text
1533 (match-beginning invisible) (match-end invisible) props)
1534 (gnus-article-unhide-text-type
1535 (match-beginning visible) (match-end visible) 'emphasis)
1536 (gnus-put-text-property-excluding-newlines
1537 (match-beginning visible) (match-end visible) 'face face)
1538 (goto-char (match-end invisible)))))))))
1540 (defvar gnus-summary-article-menu)
1541 (defvar gnus-summary-post-menu)
1543 ;;; Saving functions.
1545 (defun gnus-article-save (save-buffer file &optional num)
1546 "Save the currently selected article."
1547 (unless gnus-save-all-headers
1548 ;; Remove headers according to `gnus-saved-headers'.
1549 (let ((gnus-visible-headers
1550 (or gnus-saved-headers gnus-visible-headers))
1551 (gnus-article-buffer save-buffer))
1553 (set-buffer save-buffer)
1554 (article-hide-headers 1 t))))
1555 (save-window-excursion
1556 (if (not gnus-default-article-saver)
1557 (error "No default saver is defined")
1558 ;; !!! Magic! The saving functions all save
1559 ;; `gnus-save-article-buffer' (or so they think), but we
1560 ;; bind that variable to our save-buffer.
1561 (set-buffer gnus-article-buffer)
1562 (let* ((gnus-save-article-buffer save-buffer)
1565 ((not gnus-prompt-before-saving) 'default)
1566 ((eq gnus-prompt-before-saving 'always) nil)
1568 (gnus-number-of-articles-to-be-saved
1569 (when (eq gnus-prompt-before-saving t)
1571 (set-buffer gnus-article-current-summary)
1572 (funcall gnus-default-article-saver filename)))))
1574 (defun gnus-read-save-file-name (prompt &optional filename
1575 function group headers variable)
1577 (funcall function group headers (symbol-value variable)))
1582 ((eq filename 'default)
1588 (let* ((split-name (gnus-get-split-value gnus-split-methods))
1591 (if (and gnus-number-of-articles-to-be-saved
1592 (> gnus-number-of-articles-to-be-saved 1))
1593 (format "these %d articles"
1594 gnus-number-of-articles-to-be-saved)
1597 ;; Let the split methods have their say.
1599 ;; No split name was found.
1602 (concat prompt " (default "
1603 (file-name-nondirectory default-name) ") ")
1604 (file-name-directory default-name)
1606 ;; A single group name is returned.
1607 ((stringp split-name)
1609 (funcall function split-name headers
1610 (symbol-value variable)))
1612 (concat prompt " (default "
1613 (file-name-nondirectory default-name) ") ")
1614 (file-name-directory default-name)
1616 ;; A single split name was found
1617 ((= 1 (length split-name))
1618 (let* ((name (expand-file-name
1619 (car split-name) gnus-article-save-directory))
1620 (dir (cond ((file-directory-p name)
1621 (file-name-as-directory name))
1622 ((file-exists-p name) name)
1623 (t gnus-article-save-directory))))
1625 (concat prompt " (default " name ") ")
1627 ;; A list of splits was found.
1629 (setq split-name (nreverse split-name))
1631 (let ((file-name-history
1632 (nconc split-name file-name-history)))
1636 (concat prompt " (`M-p' for defaults) ")
1637 gnus-article-save-directory
1639 gnus-article-save-directory)))
1640 (car (push result file-name-history)))))))
1641 ;; Create the directory.
1642 (gnus-make-directory (file-name-directory file))
1643 ;; If we have read a directory, we append the default file name.
1644 (when (file-directory-p file)
1645 (setq file (concat (file-name-as-directory file)
1646 (file-name-nondirectory default-name))))
1647 ;; Possibly translate some characters.
1648 (nnheader-translate-file-chars file)))))
1649 (gnus-make-directory (file-name-directory result))
1650 (set variable result)))
1652 (defun gnus-article-archive-name (group)
1653 "Return the first instance of an \"Archive-name\" in the current buffer."
1654 (let ((case-fold-search t))
1655 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
1656 (nnheader-concat gnus-article-save-directory
1657 (match-string 1)))))
1659 (defun gnus-article-nndoc-name (group)
1660 "If GROUP is an nndoc group, return the name of the parent group."
1661 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
1662 (gnus-group-get-parameter group 'save-article-group)))
1664 (defun gnus-summary-save-in-rmail (&optional filename)
1665 "Append this article to Rmail file.
1666 Optional argument FILENAME specifies file name.
1667 Directory to save to is default to `gnus-article-save-directory'."
1668 (setq filename (gnus-read-save-file-name
1669 "Save %s in rmail file:" filename
1670 gnus-rmail-save-name gnus-newsgroup-name
1671 gnus-current-headers 'gnus-newsgroup-last-rmail))
1672 (gnus-eval-in-buffer-window gnus-save-article-buffer
1676 (rmail-output-to-rmail-file filename))))
1679 (defun gnus-summary-save-in-mail (&optional filename)
1680 "Append this article to Unix mail file.
1681 Optional argument FILENAME specifies file name.
1682 Directory to save to is default to `gnus-article-save-directory'."
1683 (setq filename (gnus-read-save-file-name
1684 "Save %s in Unix mail file:" filename
1685 gnus-mail-save-name gnus-newsgroup-name
1686 gnus-current-headers 'gnus-newsgroup-last-mail))
1687 (gnus-eval-in-buffer-window gnus-save-article-buffer
1691 (if (and (file-readable-p filename)
1692 (mail-file-babyl-p filename))
1693 (rmail-output-to-rmail-file filename t)
1694 (gnus-output-to-mail filename)))))
1697 (defun gnus-summary-save-in-file (&optional filename overwrite)
1698 "Append this article to file.
1699 Optional argument FILENAME specifies file name.
1700 Directory to save to is default to `gnus-article-save-directory'."
1701 (setq filename (gnus-read-save-file-name
1702 "Save %s in file:" filename
1703 gnus-file-save-name gnus-newsgroup-name
1704 gnus-current-headers 'gnus-newsgroup-last-file))
1705 (gnus-eval-in-buffer-window gnus-save-article-buffer
1709 (when (and overwrite
1710 (file-exists-p filename))
1711 (delete-file filename))
1712 (gnus-output-to-file filename))))
1715 (defun gnus-summary-write-to-file (&optional filename)
1716 "Write this article to a file.
1717 Optional argument FILENAME specifies file name.
1718 The directory to save in defaults to `gnus-article-save-directory'."
1719 (gnus-summary-save-in-file nil t))
1721 (defun gnus-summary-save-body-in-file (&optional filename)
1722 "Append this article body to a file.
1723 Optional argument FILENAME specifies file name.
1724 The directory to save in defaults to `gnus-article-save-directory'."
1725 (setq filename (gnus-read-save-file-name
1726 "Save %s body in file:" filename
1727 gnus-file-save-name gnus-newsgroup-name
1728 gnus-current-headers 'gnus-newsgroup-last-file))
1729 (gnus-eval-in-buffer-window gnus-save-article-buffer
1733 (goto-char (point-min))
1734 (when (search-forward "\n\n" nil t)
1735 (narrow-to-region (point) (point-max)))
1736 (gnus-output-to-file filename))))
1739 (defun gnus-summary-save-in-pipe (&optional command)
1740 "Pipe this article to subprocess."
1742 (cond ((eq command 'default)
1743 gnus-last-shell-command)
1747 "Shell command on %s: "
1748 (if (and gnus-number-of-articles-to-be-saved
1749 (> gnus-number-of-articles-to-be-saved 1))
1750 (format "these %d articles"
1751 gnus-number-of-articles-to-be-saved)
1753 gnus-last-shell-command))))
1754 (when (string-equal command "")
1755 (setq command gnus-last-shell-command))
1756 (gnus-eval-in-buffer-window gnus-article-buffer
1759 (shell-command-on-region (point-min) (point-max) command nil)))
1760 (setq gnus-last-shell-command command))
1762 ;;; Article file names when saving.
1764 (defun gnus-capitalize-newsgroup (newsgroup)
1765 "Capitalize NEWSGROUP name."
1766 (when (not (zerop (length newsgroup)))
1767 (concat (char-to-string (upcase (aref newsgroup 0)))
1768 (substring newsgroup 1))))
1770 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
1771 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
1772 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
1773 Otherwise, it is like ~/News/news/group/num."
1776 (concat (if (gnus-use-long-file-name 'not-save)
1777 (gnus-capitalize-newsgroup newsgroup)
1778 (gnus-newsgroup-directory-form newsgroup))
1779 "/" (int-to-string (mail-header-number headers)))
1780 gnus-article-save-directory)))
1782 (string-equal (file-name-directory default)
1783 (file-name-directory last-file))
1784 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
1786 (or last-file default))))
1788 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
1789 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
1790 If variable `gnus-use-long-file-name' is non-nil, it is
1791 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
1794 (concat (if (gnus-use-long-file-name 'not-save)
1796 (gnus-newsgroup-directory-form newsgroup))
1797 "/" (int-to-string (mail-header-number headers)))
1798 gnus-article-save-directory)))
1800 (string-equal (file-name-directory default)
1801 (file-name-directory last-file))
1802 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
1804 (or last-file default))))
1806 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
1807 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
1808 If variable `gnus-use-long-file-name' is non-nil, it is
1809 ~/News/News.group. Otherwise, it is like ~/News/news/group/news."
1812 (if (gnus-use-long-file-name 'not-save)
1813 (gnus-capitalize-newsgroup newsgroup)
1814 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
1815 gnus-article-save-directory)))
1817 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
1818 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
1819 If variable `gnus-use-long-file-name' is non-nil, it is
1820 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
1823 (if (gnus-use-long-file-name 'not-save)
1825 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
1826 gnus-article-save-directory)))
1833 (setq afunc (car func)
1836 gfunc (intern (format "gnus-%s" func))))
1838 (if (not (fboundp afunc))
1840 `(lambda (&optional interactive &rest args)
1841 ,(documentation afunc t)
1842 (interactive (list t))
1844 (set-buffer gnus-article-buffer)
1846 (call-interactively ',afunc)
1847 (apply ',afunc args))))))))
1848 '(article-hide-headers
1849 article-hide-boring-headers
1850 article-treat-overstrike
1851 (article-fill . gnus-article-word-wrap)
1853 article-display-x-face
1856 article-hide-signature
1857 article-remove-trailing-blank-lines
1858 article-strip-leading-blank-lines
1859 article-strip-multiple-blank-lines
1860 article-strip-leading-space
1861 article-strip-blank-lines
1862 article-strip-all-blank-lines
1864 article-date-iso8601
1865 article-date-original
1870 article-treat-dumbquotes
1871 (article-show-all . gnus-article-show-all-headers))))
1874 ;;; Gnus article mode
1877 (put 'gnus-article-mode 'mode-class 'special)
1879 (gnus-define-keys gnus-article-mode-map
1880 " " gnus-article-goto-next-page
1881 "\177" gnus-article-goto-prev-page
1882 [delete] gnus-article-goto-prev-page
1883 "\C-c^" gnus-article-refer-article
1884 "h" gnus-article-show-summary
1885 "s" gnus-article-show-summary
1886 "\C-c\C-m" gnus-article-mail
1887 "?" gnus-article-describe-briefly
1888 gnus-mouse-2 gnus-article-push-button
1889 "\r" gnus-article-press-button
1890 "\t" gnus-article-next-button
1891 "\M-\t" gnus-article-prev-button
1892 "e" gnus-article-edit
1893 "<" beginning-of-buffer
1895 "\C-c\C-i" gnus-info-find-node
1898 gnus-mouse-2 'widget-button-click
1900 "\C-d" gnus-article-read-summary-keys
1901 "\M-*" gnus-article-read-summary-keys
1902 "\M-#" gnus-article-read-summary-keys
1903 "\M-^" gnus-article-read-summary-keys
1904 "\M-g" gnus-article-read-summary-keys)
1906 (substitute-key-definition
1907 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
1909 (defun gnus-article-make-menu-bar ()
1910 (gnus-turn-off-edit-menu 'article)
1911 (unless (boundp 'gnus-article-article-menu)
1913 gnus-article-article-menu gnus-article-mode-map ""
1915 ["Scroll forwards" gnus-article-goto-next-page t]
1916 ["Scroll backwards" gnus-article-goto-prev-page t]
1917 ["Show summary" gnus-article-show-summary t]
1918 ["Fetch Message-ID at point" gnus-article-refer-article t]
1919 ["Mail to address at point" gnus-article-mail t]
1920 ["Send a bug report" gnus-bug t]))
1923 gnus-article-treatment-menu gnus-article-mode-map ""
1925 ["Hide headers" gnus-article-hide-headers t]
1926 ["Hide signature" gnus-article-hide-signature t]
1927 ["Hide citation" gnus-article-hide-citation t]
1928 ["Treat overstrike" gnus-article-treat-overstrike t]
1929 ["Remove carriage return" gnus-article-remove-cr t]))
1931 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
1933 (when (boundp 'gnus-summary-post-menu)
1934 (define-key gnus-article-mode-map [menu-bar post]
1935 (cons "Post" gnus-summary-post-menu)))
1937 (gnus-run-hooks 'gnus-article-menu-hook)))
1939 (defun gnus-article-mode ()
1940 "Major mode for displaying an article.
1942 All normal editing commands are switched off.
1944 The following commands are available in addition to all summary mode
1946 \\<gnus-article-mode-map>
1947 \\[gnus-article-next-page]\t Scroll the article one page forwards
1948 \\[gnus-article-prev-page]\t Scroll the article one page backwards
1949 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
1950 \\[gnus-article-show-summary]\t Display the summary buffer
1951 \\[gnus-article-mail]\t Send a reply to the address near point
1952 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
1953 \\[gnus-info-find-node]\t Go to the Gnus info node"
1955 (when (gnus-visual-p 'article-menu 'menu)
1956 (gnus-article-make-menu-bar))
1957 (gnus-simplify-mode-line)
1958 (setq mode-name "Article")
1959 (setq major-mode 'gnus-article-mode)
1960 (make-local-variable 'minor-mode-alist)
1961 (unless (assq 'gnus-show-mime minor-mode-alist)
1962 (push (list 'gnus-show-mime " MIME") minor-mode-alist))
1963 (use-local-map gnus-article-mode-map)
1964 (gnus-update-format-specifications nil 'article-mode)
1965 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
1966 (make-local-variable 'gnus-page-broken)
1967 (make-local-variable 'gnus-button-marker-list)
1968 (make-local-variable 'gnus-article-current-summary)
1969 (gnus-set-default-directory)
1970 (buffer-disable-undo)
1971 (setq buffer-read-only t)
1972 (set-syntax-table gnus-article-mode-syntax-table)
1973 (gnus-run-hooks 'gnus-article-mode-hook))
1975 (defun gnus-article-setup-buffer ()
1976 "Initialize the article buffer."
1977 (let* ((name (if gnus-single-article-buffer "*Article*"
1978 (concat "*Article " gnus-newsgroup-name "*")))
1980 (progn (string-match "\\*Article" name)
1981 (concat " *Original Article"
1982 (substring name (match-end 0))))))
1983 (setq gnus-article-buffer name)
1984 (setq gnus-original-article-buffer original)
1985 ;; This might be a variable local to the summary buffer.
1986 (unless gnus-single-article-buffer
1988 (set-buffer gnus-summary-buffer)
1989 (setq gnus-article-buffer name)
1990 (setq gnus-original-article-buffer original)
1991 (gnus-set-global-variables)))
1992 ;; Init original article buffer.
1994 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
1995 (setq major-mode 'gnus-original-article-mode)
1996 (make-local-variable 'gnus-original-article))
1997 (if (get-buffer name)
2000 (buffer-disable-undo)
2001 (setq buffer-read-only t)
2002 (unless (eq major-mode 'gnus-article-mode)
2003 (gnus-article-mode))
2006 (set-buffer (gnus-get-buffer-create name))
2008 (make-local-variable 'gnus-summary-buffer)
2009 (current-buffer)))))
2011 ;; Set article window start at LINE, where LINE is the number of lines
2012 ;; from the head of the article.
2013 (defun gnus-article-set-window-start (&optional line)
2015 (get-buffer-window gnus-article-buffer t)
2017 (set-buffer gnus-article-buffer)
2018 (goto-char (point-min))
2021 (gnus-message 6 "Moved to bookmark")
2022 (search-forward "\n\n" nil t)
2026 ;;; @@ article filters
2029 (defun gnus-article-display-mime-message ()
2030 "Article display method for MIME message."
2031 ;; called from `gnus-original-article-buffer'.
2032 (let ((default-mime-charset (save-excursion
2033 (set-buffer gnus-summary-buffer)
2034 default-mime-charset)))
2035 (mime-display-message mime-message-structure
2036 gnus-article-buffer nil gnus-article-mode-map))
2037 ;; `mime-display-message' changes current buffer to `gnus-article-buffer'.
2038 (make-local-variable 'mime-button-mother-dispatcher)
2039 (setq mime-button-mother-dispatcher
2040 (function gnus-article-push-button))
2041 (run-hooks 'gnus-mime-article-prepare-hook))
2043 (defun gnus-article-display-traditional-message ()
2044 "Article display method for traditional message."
2045 (set-buffer gnus-article-buffer)
2046 (let (buffer-read-only)
2048 (insert-buffer-substring gnus-original-article-buffer)))
2050 (defun gnus-article-display-message-with-encoded-word ()
2051 "Article display method for message with encoded-words."
2052 (let ((charset (save-excursion
2053 (set-buffer gnus-summary-buffer)
2054 default-mime-charset)))
2055 (gnus-article-display-traditional-message)
2056 (let (buffer-read-only)
2057 (eword-decode-header charset)
2058 (goto-char (point-min))
2059 (if (search-forward "\n\n" nil t)
2060 (decode-mime-charset-region (match-end 0) (point-max) charset)))
2061 (mime-maybe-hide-echo-buffer))
2062 (gnus-run-hooks 'gnus-mime-article-prepare-hook))
2064 (defun gnus-article-prepare (article &optional all-headers header)
2065 "Prepare ARTICLE in article mode buffer.
2066 ARTICLE should either be an article number or a Message-ID.
2067 If ARTICLE is an id, HEADER should be the article headers.
2068 If ALL-HEADERS is non-nil, no headers are hidden."
2070 ;; Make sure we start in a summary buffer.
2071 (unless (eq major-mode 'gnus-summary-mode)
2072 (set-buffer gnus-summary-buffer))
2073 (setq gnus-summary-buffer (current-buffer))
2074 (let* ((gnus-article (if header (mail-header-number header) article))
2075 (summary-buffer (current-buffer))
2076 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
2077 (group gnus-newsgroup-name)
2080 (gnus-article-setup-buffer)
2081 (set-buffer gnus-original-article-buffer)
2082 ;; Deactivate active regions.
2083 (when (and (boundp 'transient-mark-mode)
2084 transient-mark-mode)
2085 (setq mark-active nil))
2086 (if (not (setq result (let ((buffer-read-only nil))
2087 (gnus-request-article-this-buffer
2089 ;; There is no such article.
2091 (when (and (numberp article)
2092 (not (memq article gnus-newsgroup-sparse)))
2093 (setq gnus-article-current
2094 (cons gnus-newsgroup-name article))
2095 (set-buffer gnus-summary-buffer)
2096 (setq gnus-current-article article)
2097 (if (eq (gnus-article-mark article) gnus-undownloaded-mark)
2099 (gnus-summary-set-agent-mark article)
2100 (message "Message marked for downloading"))
2101 (gnus-summary-mark-article article gnus-canceled-mark)
2102 (unless (memq article gnus-newsgroup-sparse)
2104 "No such article (may have expired or been canceled)")))))
2105 (if (or (eq result 'pseudo)
2106 (eq result 'nneething))
2109 (set-buffer summary-buffer)
2110 (push article gnus-newsgroup-history)
2111 (setq gnus-last-article gnus-current-article
2112 gnus-current-article 0
2113 gnus-current-headers nil
2114 gnus-article-current nil)
2115 (if (eq result 'nneething)
2116 (gnus-configure-windows 'summary)
2117 (gnus-configure-windows 'article))
2118 (gnus-set-global-variables))
2119 (gnus-set-mode-line 'article))
2120 ;; The result from the `request' was an actual article -
2121 ;; or at least some text that is now displayed in the
2123 (when (and (numberp article)
2124 (not (eq article gnus-current-article)))
2125 ;; Seems like a new article has been selected.
2126 ;; `gnus-current-article' must be an article number.
2128 (set-buffer summary-buffer)
2129 (push article gnus-newsgroup-history)
2130 (setq gnus-last-article gnus-current-article
2131 gnus-current-article article
2132 gnus-current-headers
2133 (gnus-summary-article-header gnus-current-article)
2134 gnus-article-current
2135 (cons gnus-newsgroup-name gnus-current-article))
2136 (unless (vectorp gnus-current-headers)
2137 (setq gnus-current-headers nil))
2138 (gnus-summary-goto-subject gnus-current-article)
2139 (when (gnus-summary-show-thread)
2140 ;; If the summary buffer really was folded, the
2141 ;; previous goto may not actually have gone to
2142 ;; the right article, but the thread root instead.
2144 (gnus-summary-goto-subject gnus-current-article))
2145 (gnus-run-hooks 'gnus-mark-article-hook)
2146 (gnus-set-mode-line 'summary)
2147 (when (gnus-visual-p 'article-highlight 'highlight)
2148 (gnus-run-hooks 'gnus-visual-mark-article-hook))
2149 ;; Set the global newsgroup variables here.
2150 ;; Suggested by Jim Sisolak
2151 ;; <sisolak@trans4.neep.wisc.edu>.
2152 (gnus-set-global-variables)
2153 (setq gnus-have-all-headers
2154 (or all-headers gnus-show-all-headers))))
2155 (when (or (numberp article)
2157 (gnus-article-prepare-display)
2159 (goto-char (point-min))
2160 (setq gnus-page-broken
2161 (when gnus-break-pages
2162 (gnus-narrow-to-page)
2164 (gnus-set-mode-line 'article)
2165 (gnus-configure-windows 'article)
2166 (goto-char (point-min))
2167 (search-forward "\n\n" nil t)
2168 (set-window-point (get-buffer-window (current-buffer)) (point))
2171 (defun gnus-article-prepare-display ()
2172 "Make the current buffer look like a nice article."
2173 (let ((method (if gnus-show-mime
2176 gnus-article-display-method-for-mime)
2177 gnus-article-display-method-for-traditional)))
2178 ;; Hooks for getting information from the article.
2179 ;; This hook must be called before being narrowed.
2180 (gnus-run-hooks 'gnus-tmp-internal-hook)
2181 (gnus-run-hooks 'gnus-article-prepare-hook)
2184 ;; Associate this article with the current summary buffer.
2185 (setq gnus-article-current-summary summary-buffer)
2186 ;; Perform the article display hooks.
2187 (gnus-run-hooks 'gnus-article-display-hook)))
2190 ;;; Gnus MIME viewing functions
2193 (defvar gnus-mime-button-line-format "%{%([%t%d%n]%)%}\n"
2194 "The following specs can be used:
2196 %n The `name' parameter
2197 %d The description, if any
2198 %l The length of the encoded part")
2200 (defvar gnus-mime-button-line-format-alist
2201 '((?t gnus-tmp-type ?s)
2202 (?n gnus-tmp-name ?s)
2203 (?d gnus-tmp-description ?s)
2204 (?l gnus-tmp-length ?d)))
2206 (defvar gnus-mime-button-map nil)
2207 (unless gnus-mime-button-map
2208 (setq gnus-mime-button-map (copy-keymap gnus-article-mode-map))
2209 (define-key gnus-mime-button-map gnus-mouse-2 'gnus-article-push-button)
2210 (define-key gnus-mime-button-map "\r" 'gnus-article-press-button)
2211 (define-key gnus-mime-button-map "\M-\r" 'gnus-mime-view-part)
2212 (define-key gnus-mime-button-map "v" 'gnus-mime-view-part)
2213 (define-key gnus-mime-button-map "o" 'gnus-mime-save-part)
2214 (define-key gnus-mime-button-map "c" 'gnus-mime-copy-part)
2215 (define-key gnus-mime-button-map "i" 'gnus-mime-inline-part)
2216 (define-key gnus-mime-button-map "|" 'gnus-mime-pipe-part))
2218 (defun gnus-mime-save-part ()
2219 "Save the MIME part under point."
2221 (let ((data (get-text-property (point) 'gnus-data)))
2222 (mm-save-part data)))
2224 (defun gnus-mime-pipe-part ()
2225 "Pipe the MIME part under point to a process."
2227 (let ((data (get-text-property (point) 'gnus-data)))
2228 (mm-pipe-part data)))
2230 (defun gnus-mime-view-part ()
2231 "Interactively choose a view method for the MIME part under point."
2233 (let ((data (get-text-property (point) 'gnus-data))
2234 (url-standalone-mode (not gnus-plugged)))
2235 (mm-interactively-view-part data)))
2237 (defun gnus-mime-copy-part ()
2238 "Put the the MIME part under point into a new buffer."
2240 (let* ((data (get-text-property (point) 'gnus-data))
2241 (contents (mm-get-part data)))
2242 (switch-to-buffer (generate-new-buffer "*decoded*"))
2244 (goto-char (point-min))))
2246 (defun gnus-mime-inline-part ()
2247 "Insert the MIME part under point into the current buffer."
2249 (let* ((data (get-text-property (point) 'gnus-data))
2250 (contents (mm-get-part data))
2251 (url-standalone-mode (not gnus-plugged))
2254 (if (mm-handle-undisplayer data)
2255 (mm-remove-part data)
2257 (mm-insert-inline data contents)
2260 (defun gnus-insert-mime-button (handle)
2261 (let ((gnus-tmp-name (mail-content-type-get (mm-handle-type handle) 'name))
2262 (gnus-tmp-type (car (mm-handle-type handle)))
2263 (gnus-tmp-description (mm-handle-description handle))
2264 (gnus-tmp-length (with-temp-buffer (mm-handle-buffer handle)
2269 (concat " (" gnus-tmp-name ")")
2271 (setq gnus-tmp-description
2272 (if gnus-tmp-description
2273 (concat " (" gnus-tmp-description ")")
2277 gnus-mime-button-line-format gnus-mime-button-line-format-alist
2278 `(local-map ,gnus-mime-button-map
2279 keymap ,gnus-mime-button-map
2280 gnus-callback mm-display-part
2283 (widget-convert-button 'link from to :action 'gnus-widget-press-button
2284 :button-keymap gnus-widget-button-keymap)))
2286 (defun gnus-widget-press-button (elems el)
2287 (goto-char (widget-get elems :from))
2288 (let ((url-standalone-mode (not gnus-plugged)))
2289 (gnus-article-press-button)))
2291 (defun gnus-display-mime ()
2292 "Insert MIME buttons in the buffer."
2295 (mail-narrow-to-head)
2296 (when (setq ct (mail-fetch-field "content-type"))
2297 (setq ctl (condition-case ()
2298 (mail-header-parse-content-type ct) (error nil)))
2299 (let* ((handles (mm-dissect-buffer))
2300 handle name type b e)
2301 (mapcar 'mm-destroy-part gnus-article-mime-handles)
2302 (setq gnus-article-mime-handles handles)
2304 (goto-char (point-min))
2305 (search-forward "\n\n" nil t)
2306 (delete-region (point) (point-max))
2307 (if (not (equal (car ctl) "multipart/alternative"))
2308 (while (setq handle (pop handles))
2309 (gnus-insert-mime-button handle)
2311 (when (and (mm-automatic-display-p
2312 (car (mm-handle-type handle)))
2313 (or (not (mm-handle-disposition handle))
2314 (equal (car (mm-handle-disposition handle))
2317 (mm-display-part handle t)
2318 (goto-char (point-max))))
2319 ;; Here we have multipart/alternative
2320 (gnus-mime-display-alternative handles))))))))
2322 (defun gnus-mime-display-alternative (handles &optional preferred)
2323 (let* ((preferred (mm-preferred-alternative handles preferred))
2325 handle buffer-read-only)
2326 (goto-char (point-min))
2327 (search-forward "\n\n" nil t)
2328 (delete-region (point) (point-max))
2329 (mapcar 'mm-remove-part gnus-article-mime-handles)
2330 (setq gnus-article-mime-handles handles)
2331 (while (setq handle (pop handles))
2332 (gnus-add-text-properties
2335 (insert (format "[%c] %-18s"
2336 (if (equal handle preferred) ?* ? )
2337 (car (mm-handle-type handle))))
2339 `(local-map ,gnus-mime-button-map
2340 keymap ,gnus-mime-button-map
2343 (gnus-mime-display-alternative
2344 ',ihandles ,(car (mm-handle-type handle))))
2349 (mm-display-part preferred))))
2351 (defun gnus-article-wash-status ()
2352 "Return a string which display status of article washing."
2354 (set-buffer gnus-article-buffer)
2355 (let ((cite (gnus-article-hidden-text-p 'cite))
2356 (headers (gnus-article-hidden-text-p 'headers))
2357 (boring (gnus-article-hidden-text-p 'boring-headers))
2358 (pgp (gnus-article-hidden-text-p 'pgp))
2359 (pem (gnus-article-hidden-text-p 'pem))
2360 (signature (gnus-article-hidden-text-p 'signature))
2361 (overstrike (gnus-article-hidden-text-p 'overstrike))
2362 (emphasis (gnus-article-hidden-text-p 'emphasis))
2363 (mime gnus-show-mime))
2364 (format "%c%c%c%c%c%c%c"
2366 (if (or headers boring) ?h ? )
2367 (if (or pgp pem) ?p ? )
2368 (if signature ?s ? )
2369 (if overstrike ?o ? )
2371 (if emphasis ?e ? )))))
2373 (fset 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
2375 (defun gnus-article-maybe-hide-headers ()
2376 "Hide unwanted headers if `gnus-have-all-headers' is nil.
2377 Provided for backwards compatibility."
2378 (or (save-excursion (set-buffer gnus-summary-buffer) gnus-have-all-headers)
2380 (gnus-article-hide-headers)))
2384 (defun gnus-output-to-file (file-name)
2385 "Append the current article to a file named FILE-NAME."
2386 (let ((artbuf (current-buffer)))
2388 (insert-buffer-substring artbuf)
2389 ;; Append newline at end of the buffer as separator, and then
2391 (goto-char (point-max))
2393 (append-to-file (point-min) (point-max) file-name)
2396 (defun gnus-narrow-to-page (&optional arg)
2397 "Narrow the article buffer to a page.
2398 If given a numerical ARG, move forward ARG pages."
2400 (setq arg (if arg (prefix-numeric-value arg) 0))
2402 (set-buffer gnus-article-buffer)
2403 (goto-char (point-min))
2405 ;; Remove any old next/prev buttons.
2406 (when (gnus-visual-p 'page-marker)
2407 (let ((buffer-read-only nil))
2408 (gnus-remove-text-with-property 'gnus-prev)
2409 (gnus-remove-text-with-property 'gnus-next)))
2412 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
2414 (re-search-forward page-delimiter nil 'move arg)))
2415 (goto-char (match-end 0)))
2418 (if (re-search-forward page-delimiter nil 'move)
2421 (when (and (gnus-visual-p 'page-marker)
2422 (not (= (point-min) 1)))
2424 (goto-char (point-min))
2425 (gnus-insert-prev-page-button)))
2426 (when (and (gnus-visual-p 'page-marker)
2427 (< (+ (point-max) 2) (buffer-size)))
2429 (goto-char (point-max))
2430 (gnus-insert-next-page-button)))))
2432 ;; Article mode commands
2434 (defun gnus-article-goto-next-page ()
2435 "Show the next page of the article."
2437 (when (gnus-article-next-page)
2438 (goto-char (point-min))
2439 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
2441 (defun gnus-article-goto-prev-page ()
2442 "Show the next page of the article."
2444 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
2445 (gnus-article-prev-page nil)))
2447 (defun gnus-article-next-page (&optional lines)
2448 "Show the next page of the current article.
2449 If end of article, return non-nil. Otherwise return nil.
2450 Argument LINES specifies lines to be scrolled up."
2452 (move-to-window-line -1)
2455 (and (pos-visible-in-window-p) ;Not continuation line.
2457 ;; Nothing in this page.
2458 (if (or (not gnus-page-broken)
2461 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
2463 (gnus-narrow-to-page 1) ;Go to next page.
2465 ;; More in this page.
2466 (let ((scroll-in-place nil))
2470 ;; Long lines may cause an end-of-buffer error.
2471 (goto-char (point-max)))))
2472 (move-to-window-line 0)
2475 (defun gnus-article-prev-page (&optional lines)
2476 "Show previous page of current article.
2477 Argument LINES specifies lines to be scrolled down."
2479 (move-to-window-line 0)
2480 (if (and gnus-page-broken
2482 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
2484 (gnus-narrow-to-page -1) ;Go to previous page.
2485 (goto-char (point-max))
2487 (let ((scroll-in-place nil))
2491 (beginning-of-buffer
2492 (goto-char (point-min))))
2493 (move-to-window-line 0)))))
2495 (defun gnus-article-refer-article ()
2496 "Read article specified by message-id around point."
2498 (let ((point (point)))
2499 (search-forward ">" nil t) ;Move point to end of "<....>".
2500 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
2501 (let ((message-id (match-string 1)))
2503 (set-buffer gnus-summary-buffer)
2504 (gnus-summary-refer-article message-id))
2506 (error "No references around point"))))
2508 (defun gnus-article-show-summary ()
2509 "Reconfigure windows to show summary buffer."
2511 (if (not (gnus-buffer-live-p gnus-summary-buffer))
2512 (error "There is no summary buffer for this article buffer")
2513 (gnus-article-set-globals)
2514 (gnus-configure-windows 'article)
2515 (gnus-summary-goto-subject gnus-current-article)
2516 (gnus-summary-position-point)))
2518 (defun gnus-article-describe-briefly ()
2519 "Describe article mode commands briefly."
2522 (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")))
2524 (defun gnus-article-summary-command ()
2525 "Execute the last keystroke in the summary buffer."
2527 (let ((obuf (current-buffer))
2528 (owin (current-window-configuration))
2530 (switch-to-buffer gnus-article-current-summary 'norecord)
2531 (setq func (lookup-key (current-local-map) (this-command-keys)))
2532 (call-interactively func)
2534 (set-window-configuration owin)
2535 (set-window-point (get-buffer-window (current-buffer)) (point))))
2537 (defun gnus-article-summary-command-nosave ()
2538 "Execute the last keystroke in the summary buffer."
2541 (pop-to-buffer gnus-article-current-summary 'norecord)
2542 (setq func (lookup-key (current-local-map) (this-command-keys)))
2543 (call-interactively func)))
2545 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
2546 "Read a summary buffer key sequence and execute it from the article buffer."
2549 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
2550 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
2551 "=" "^" "\M-^" "|"))
2557 '("n" "Gn" "p" "Gp"))
2560 (set-buffer gnus-article-current-summary)
2561 (let (gnus-pick-mode)
2562 (push (or key last-command-event) unread-command-events)
2563 (setq keys (read-key-sequence nil))))
2566 (if (or (member keys nosaves)
2567 (member keys nosave-but-article)
2568 (member keys nosave-in-article))
2570 (save-window-excursion
2571 (pop-to-buffer gnus-article-current-summary 'norecord)
2572 ;; We disable the pick minor mode commands.
2573 (let (gnus-pick-mode)
2574 (setq func (lookup-key (current-local-map) keys))))
2577 (unless (member keys nosave-in-article)
2578 (set-buffer gnus-article-current-summary))
2579 (call-interactively func)
2580 (setq new-sum-point (point)))
2581 (when (member keys nosave-but-article)
2582 (pop-to-buffer gnus-article-buffer 'norecord)))
2583 ;; These commands should restore window configuration.
2584 (let ((obuf (current-buffer))
2585 (owin (current-window-configuration))
2587 (summary gnus-article-current-summary)
2588 func in-buffer selected)
2589 (if not-restore-window
2590 (pop-to-buffer summary 'norecord)
2591 (switch-to-buffer summary 'norecord))
2592 (setq in-buffer (current-buffer))
2593 ;; We disable the pick minor mode commands.
2594 (if (setq func (let (gnus-pick-mode)
2595 (lookup-key (current-local-map) keys)))
2597 (call-interactively func)
2598 (setq new-sum-point (point)))
2600 (when (eq in-buffer (current-buffer))
2601 (setq selected (gnus-summary-select-article))
2603 (unless not-restore-window
2604 (set-window-configuration owin))
2605 (unless (or (not (eq selected 'old)) (member keys up-to-top))
2606 (set-window-point (get-buffer-window (current-buffer))
2608 (let ((win (get-buffer-window gnus-article-current-summary)))
2610 (set-window-point win new-sum-point))))))))
2612 (defun gnus-article-hide (&optional arg force)
2613 "Hide all the gruft in the current article.
2614 This means that PGP stuff, signatures, cited text and (some)
2615 headers will be hidden.
2616 If given a prefix, show the hidden text instead."
2617 (interactive (append (gnus-article-hidden-arg) (list 'force)))
2618 (gnus-article-hide-headers arg)
2619 (gnus-article-hide-pgp arg)
2620 (gnus-article-hide-citation-maybe arg force)
2621 (gnus-article-hide-signature arg))
2623 (defun gnus-article-maybe-highlight ()
2624 "Do some article highlighting if article highlighting is requested."
2625 (when (gnus-visual-p 'article-highlight 'highlight)
2626 (gnus-article-highlight-some)))
2628 (defun gnus-check-group-server ()
2629 ;; Make sure the connection to the server is alive.
2630 (unless (gnus-server-opened
2631 (gnus-find-method-for-group gnus-newsgroup-name))
2632 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
2633 (gnus-request-group gnus-newsgroup-name t)))
2635 (defun gnus-request-article-this-buffer (article group)
2636 "Get an article and insert it into this buffer."
2637 (let (do-update-line sparse-header)
2641 (gnus-kill-all-overlays)
2642 (setq group (or group gnus-newsgroup-name))
2644 ;; Using `gnus-request-article' directly will insert the article into
2645 ;; `nntp-server-buffer' - so we'll save some time by not having to
2646 ;; copy it from the server buffer into the article buffer.
2648 ;; We only request an article by message-id when we do not have the
2649 ;; headers for it, so we'll have to get those.
2650 (when (stringp article)
2651 (let ((gnus-override-method gnus-refer-article-method))
2652 (gnus-read-header article)))
2654 ;; If the article number is negative, that means that this article
2655 ;; doesn't belong in this newsgroup (possibly), so we find its
2656 ;; message-id and request it by id instead of number.
2657 (when (and (numberp article)
2659 (get-buffer gnus-summary-buffer)
2660 (gnus-buffer-exists-p gnus-summary-buffer))
2662 (set-buffer gnus-summary-buffer)
2663 (let ((header (gnus-summary-article-header article)))
2666 ((memq article gnus-newsgroup-sparse)
2667 ;; This is a sparse gap article.
2668 (setq do-update-line article)
2669 (setq article (mail-header-id header))
2670 (let ((gnus-override-method gnus-refer-article-method))
2671 (setq sparse-header (gnus-read-header article)))
2672 (setq gnus-newsgroup-sparse
2673 (delq article gnus-newsgroup-sparse)))
2675 ;; It's a real article.
2676 (setq article (mail-header-id header)))
2678 ;; It is an extracted pseudo-article.
2679 (setq article 'pseudo)
2680 (gnus-request-pseudo-article header))))
2682 (let ((method (gnus-find-method-for-group
2683 gnus-newsgroup-name)))
2684 (when (and (eq (car method) 'nneething)
2687 (file-name-as-directory
2688 (or (cadr (assq 'nneething-address method))
2690 (mail-header-subject header))))
2691 (when (file-directory-p dir)
2692 (setq article 'nneething)
2693 (gnus-group-enter-directory dir))))))))
2696 ;; Refuse to select canceled articles.
2697 ((and (numberp article)
2699 (get-buffer gnus-summary-buffer)
2700 (gnus-buffer-exists-p gnus-summary-buffer)
2701 (eq (cdr (save-excursion
2702 (set-buffer gnus-summary-buffer)
2703 (assq article gnus-newsgroup-reads)))
2704 gnus-canceled-mark))
2706 ;; Check the backlog.
2707 ((and gnus-keep-backlog
2708 (gnus-backlog-request-article group article (current-buffer)))
2710 ;; Check asynchronous pre-fetch.
2711 ((gnus-async-request-fetched-article group article (current-buffer))
2712 (gnus-async-prefetch-next group article gnus-summary-buffer)
2713 (when (and (numberp article) gnus-keep-backlog)
2714 (gnus-backlog-enter-article group article (current-buffer)))
2717 ((and gnus-use-cache
2719 (gnus-cache-request-article article group))
2721 ;; Get the article and put into the article buffer.
2722 ((or (stringp article) (numberp article))
2723 (let ((gnus-override-method
2724 (and (stringp article) gnus-refer-article-method))
2725 (buffer-read-only nil))
2727 (gnus-kill-all-overlays)
2728 (gnus-check-group-server)
2729 (when (gnus-request-article article group (current-buffer))
2730 (when (numberp article)
2731 (gnus-async-prefetch-next group article gnus-summary-buffer)
2732 (when gnus-keep-backlog
2733 (gnus-backlog-enter-article
2734 group article (current-buffer))))
2739 ;; Associate this article with the current summary buffer.
2740 (setq gnus-article-current-summary gnus-summary-buffer)
2742 ;; Take the article from the original article buffer
2743 ;; and place it in the buffer it's supposed to be in.
2744 (when (and (get-buffer gnus-article-buffer)
2745 (equal (buffer-name (current-buffer))
2746 (buffer-name (get-buffer gnus-article-buffer))))
2748 (if (get-buffer gnus-original-article-buffer)
2749 (set-buffer gnus-original-article-buffer)
2750 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
2751 (buffer-disable-undo)
2752 (setq major-mode 'gnus-original-article-mode)
2753 (setq buffer-read-only t))
2754 (let (buffer-read-only)
2756 (insert-buffer-substring gnus-article-buffer))
2757 (setq gnus-original-article (cons group article)))
2760 (run-hooks 'gnus-article-decode-hook)
2761 ;; Mark article as decoded or not.
2762 (setq gnus-article-decoded-p gnus-article-decode-hook))
2764 ;; Update sparse articles.
2765 (when (and do-update-line
2766 (or (numberp article)
2768 (let ((buf (current-buffer)))
2769 (set-buffer gnus-summary-buffer)
2770 (gnus-summary-update-article do-update-line sparse-header)
2771 (gnus-summary-goto-subject do-update-line nil t)
2772 (set-window-point (get-buffer-window (current-buffer) t)
2774 (set-buffer buf))))))
2780 (defcustom gnus-article-edit-mode-hook nil
2781 "Hook run in article edit mode buffers."
2782 :group 'gnus-article-various
2785 (defvar gnus-article-edit-done-function nil)
2787 (defvar gnus-article-edit-mode-map nil)
2789 (unless gnus-article-edit-mode-map
2790 (setq gnus-article-edit-mode-map (copy-keymap text-mode-map))
2792 (gnus-define-keys gnus-article-edit-mode-map
2793 "\C-c\C-c" gnus-article-edit-done
2794 "\C-c\C-k" gnus-article-edit-exit)
2796 (gnus-define-keys (gnus-article-edit-wash-map
2797 "\C-c\C-w" gnus-article-edit-mode-map)
2798 "f" gnus-article-edit-full-stops))
2800 (defun gnus-article-edit-mode ()
2801 "Major mode for editing articles.
2802 This is an extended text-mode.
2804 \\{gnus-article-edit-mode-map}"
2806 (setq major-mode 'gnus-article-edit-mode)
2807 (setq mode-name "Article Edit")
2808 (use-local-map gnus-article-edit-mode-map)
2809 (make-local-variable 'gnus-article-edit-done-function)
2810 (make-local-variable 'gnus-prev-winconf)
2811 (setq buffer-read-only nil)
2812 (buffer-enable-undo)
2814 (gnus-run-hooks 'text-mode-hook 'gnus-article-edit-mode-hook))
2816 (defun gnus-article-edit (&optional force)
2817 "Edit the current article.
2818 This will have permanent effect only in mail groups.
2819 If FORCE is non-nil, allow editing of articles even in read-only
2822 (when (and (not force)
2823 (gnus-group-read-only-p))
2824 (error "The current newsgroup does not support article editing"))
2825 (gnus-article-date-original)
2826 (gnus-article-edit-article
2827 `(lambda (no-highlight)
2828 (gnus-summary-edit-article-done
2829 ,(or (mail-header-references gnus-current-headers) "")
2830 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
2832 (defun gnus-article-edit-article (exit-func)
2833 "Start editing the contents of the current article buffer."
2834 (let ((winconf (current-window-configuration)))
2835 (set-buffer gnus-article-buffer)
2836 (gnus-article-edit-mode)
2837 (gnus-article-delete-text-of-type 'annotation)
2838 (gnus-set-text-properties (point-min) (point-max) nil)
2839 (gnus-configure-windows 'edit-article)
2840 (setq gnus-article-edit-done-function exit-func)
2841 (setq gnus-prev-winconf winconf)
2842 (gnus-message 6 "C-c C-c to end edits")))
2844 (defun gnus-article-edit-done (&optional arg)
2845 "Update the article edits and exit."
2850 (goto-char (point-min))
2851 (when (search-forward "\n\n" nil 1)
2852 (let ((lines (count-lines (point) (point-max)))
2853 (length (- (point-max) (point)))
2854 (case-fold-search t)
2855 (body (copy-marker (point))))
2856 (goto-char (point-min))
2857 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
2858 (delete-region (match-beginning 1) (match-end 1))
2859 (insert (number-to-string length)))
2860 (goto-char (point-min))
2861 (when (re-search-forward
2862 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
2863 (delete-region (match-beginning 1) (match-end 1))
2864 (insert (number-to-string length)))
2865 (goto-char (point-min))
2866 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
2867 (delete-region (match-beginning 1) (match-end 1))
2868 (insert (number-to-string lines)))))))
2869 (let ((func gnus-article-edit-done-function)
2870 (buf (current-buffer))
2871 (start (window-start)))
2872 (gnus-article-edit-exit)
2875 (let ((buffer-read-only nil))
2876 (funcall func arg)))
2878 (set-window-start (get-buffer-window buf) start)
2879 (set-window-point (get-buffer-window buf) (point))))
2881 (defun gnus-article-edit-exit ()
2882 "Exit the article editing without updating."
2884 ;; We remove all text props from the article buffer.
2885 (let ((buf (format "%s" (buffer-string)))
2886 (curbuf (current-buffer))
2888 (window-start (window-start)))
2891 (let ((winconf gnus-prev-winconf))
2893 ;; The cache and backlog have to be flushed somewhat.
2894 (when gnus-use-cache
2895 (gnus-cache-update-article
2896 (car gnus-article-current) (cdr gnus-article-current)))
2897 (when gnus-keep-backlog
2898 (gnus-backlog-remove-article
2899 (car gnus-article-current) (cdr gnus-article-current)))
2900 ;; Flush original article as well.
2902 (when (get-buffer gnus-original-article-buffer)
2903 (set-buffer gnus-original-article-buffer)
2904 (setq gnus-original-article nil)))
2905 (set-window-configuration winconf)
2906 ;; Tippy-toe some to make sure that point remains where it was.
2907 (let ((buf (current-buffer)))
2909 (set-window-start (get-buffer-window (current-buffer)) window-start)
2911 (set-buffer buf)))))
2913 (defun gnus-article-edit-full-stops ()
2914 "Interactively repair spacing at end of sentences."
2917 (goto-char (point-min))
2918 (search-forward-regexp "^$" nil t)
2919 (let ((case-fold-search nil))
2920 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
2923 ;;; Article highlights
2926 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
2928 ;;; Internal Variables:
2930 (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\\)"
2931 "Regular expression that matches URLs."
2932 :group 'gnus-article-buttons
2935 (defcustom gnus-button-alist
2936 `(("<\\(url:[>\n\t ]*?\\)?news:[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>" 0 t
2937 gnus-button-message-id 2)
2938 ("\\bnews:\\([^>\n\t ]*@[^>\n\t ]*\\)" 0 t gnus-button-message-id 1)
2939 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
2941 gnus-button-fetch-group 4)
2942 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
2943 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
2944 t gnus-button-message-id 3)
2945 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
2946 ("mailto:\\([-a-zA-Z.@_+0-9%]+\\)" 0 t gnus-url-mailto 1)
2947 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
2948 ;; This is how URLs _should_ be embedded in text...
2949 ("<URL: *\\([^>]*\\)>" 0 t gnus-button-embedded-url 1)
2951 (,gnus-button-url-regexp 0 t gnus-button-url 0))
2952 "*Alist of regexps matching buttons in article bodies.
2954 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
2955 REGEXP: is the string matching text around the button,
2956 BUTTON: is the number of the regexp grouping actually matching the button,
2957 FORM: is a lisp expression which must eval to true for the button to
2959 CALLBACK: is the function to call when the user push this button, and each
2960 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
2962 CALLBACK can also be a variable, in that case the value of that
2963 variable it the real callback function."
2964 :group 'gnus-article-buttons
2965 :type '(repeat (list regexp
2966 (integer :tag "Button")
2968 (function :tag "Callback")
2971 (integer :tag "Regexp group")))))
2973 (defcustom gnus-header-button-alist
2974 `(("^\\(References\\|Message-I[Dd]\\):" "<[^>]+>"
2975 0 t gnus-button-message-id 0)
2976 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
2977 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
2978 0 t gnus-button-mailto 0)
2979 ("^X-[Uu][Rr][Ll]:" ,gnus-button-url-regexp 0 t gnus-button-url 0)
2980 ("^Subject:" ,gnus-button-url-regexp 0 t gnus-button-url 0)
2981 ("^[^:]+:" ,gnus-button-url-regexp 0 t gnus-button-url 0)
2982 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
2983 gnus-button-message-id 3))
2984 "*Alist of headers and regexps to match buttons in article heads.
2986 This alist is very similar to `gnus-button-alist', except that each
2987 alist has an additional HEADER element first in each entry:
2989 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
2991 HEADER is a regexp to match a header. For a fuller explanation, see
2992 `gnus-button-alist'."
2993 :group 'gnus-article-buttons
2994 :group 'gnus-article-headers
2995 :type '(repeat (list (regexp :tag "Header")
2997 (integer :tag "Button")
2999 (function :tag "Callback")
3002 (integer :tag "Regexp group")))))
3004 (defvar gnus-button-regexp nil)
3005 (defvar gnus-button-marker-list nil)
3006 ;; Regexp matching any of the regexps from `gnus-button-alist'.
3008 (defvar gnus-button-last nil)
3009 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
3013 (defun gnus-article-push-button (event)
3014 "Check text under the mouse pointer for a callback function.
3015 If the text under the mouse pointer has a `gnus-callback' property,
3016 call it with the value of the `gnus-data' text property."
3018 (set-buffer (window-buffer (posn-window (event-start event))))
3019 (let* ((pos (posn-point (event-start event)))
3020 (data (get-text-property pos 'gnus-data))
3021 (fun (get-text-property pos 'gnus-callback)))
3024 (funcall fun data))))
3026 (defun gnus-article-press-button ()
3027 "Check text at point for a callback function.
3028 If the text at point has a `gnus-callback' property,
3029 call it with the value of the `gnus-data' text property."
3031 (let* ((data (get-text-property (point) 'gnus-data))
3032 (fun (get-text-property (point) 'gnus-callback)))
3034 (funcall fun data))))
3036 (defun gnus-article-prev-button (n)
3037 "Move point to N buttons backward.
3038 If N is negative, move forward instead."
3040 (gnus-article-next-button (- n)))
3042 (defun gnus-article-next-button (n)
3043 "Move point to N buttons forward.
3044 If N is negative, move backward instead."
3046 (let ((function (if (< n 0) 'previous-single-property-change
3047 'next-single-property-change))
3048 (inhibit-point-motion-hooks t)
3050 (limit (if (< n 0) (point-min) (point-max))))
3052 (while (and (not (= limit (point)))
3054 ;; Skip past the current button.
3055 (when (get-text-property (point) 'gnus-callback)
3056 (goto-char (funcall function (point) 'gnus-callback nil limit)))
3057 ;; Go to the next (or previous) button.
3058 (gnus-goto-char (funcall function (point) 'gnus-callback nil limit))
3059 ;; Put point at the start of the button.
3060 (when (and backward (not (get-text-property (point) 'gnus-callback)))
3061 (goto-char (funcall function (point) 'gnus-callback nil limit)))
3062 ;; Skip past intangible buttons.
3063 (when (get-text-property (point) 'intangible)
3067 (gnus-message 5 "No more buttons"))
3070 (defun gnus-article-highlight (&optional force)
3071 "Highlight current article.
3072 This function calls `gnus-article-highlight-headers',
3073 `gnus-article-highlight-citation',
3074 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
3075 do the highlighting. See the documentation for those functions."
3076 (interactive (list 'force))
3077 (gnus-article-highlight-headers)
3078 (gnus-article-highlight-citation force)
3079 (gnus-article-highlight-signature)
3080 (gnus-article-add-buttons force)
3081 (gnus-article-add-buttons-to-head))
3083 (defun gnus-article-highlight-some (&optional force)
3084 "Highlight current article.
3085 This function calls `gnus-article-highlight-headers',
3086 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
3087 do the highlighting. See the documentation for those functions."
3088 (interactive (list 'force))
3089 (gnus-article-highlight-headers)
3090 (gnus-article-highlight-signature)
3091 (gnus-article-add-buttons))
3093 (defun gnus-article-highlight-headers ()
3094 "Highlight article headers as specified by `gnus-header-face-alist'."
3097 (set-buffer gnus-article-buffer)
3099 (let ((alist gnus-header-face-alist)
3100 (buffer-read-only nil)
3101 (case-fold-search t)
3102 (inhibit-point-motion-hooks t)
3103 entry regexp header-face field-face from hpoints fpoints)
3104 (message-narrow-to-head)
3105 (while (setq entry (pop alist))
3106 (goto-char (point-min))
3107 (setq regexp (concat "^\\("
3108 (if (string-equal "" (nth 0 entry))
3112 header-face (nth 1 entry)
3113 field-face (nth 2 entry))
3114 (while (and (re-search-forward regexp nil t)
3118 (unless (search-forward ":" nil t)
3120 (when (and header-face
3121 (not (memq (point) hpoints)))
3122 (push (point) hpoints)
3123 (gnus-put-text-property from (point) 'face header-face))
3124 (when (and field-face
3125 (not (memq (setq from (point)) fpoints)))
3127 (if (re-search-forward "^[^ \t]" nil t)
3129 (goto-char (point-max)))
3130 (gnus-put-text-property from (point) 'face field-face))))))))
3132 (defun gnus-article-highlight-signature ()
3133 "Highlight the signature in an article.
3134 It does this by highlighting everything after
3135 `gnus-signature-separator' using `gnus-signature-face'."
3138 (set-buffer gnus-article-buffer)
3139 (let ((buffer-read-only nil)
3140 (inhibit-point-motion-hooks t))
3142 (when (and gnus-signature-face
3143 (gnus-article-narrow-to-signature))
3144 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
3145 'face gnus-signature-face)
3147 (gnus-article-search-signature)
3148 (let ((start (match-beginning 0))
3149 (end (set-marker (make-marker) (1+ (match-end 0)))))
3150 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
3153 (defun gnus-button-in-region-p (b e prop)
3154 "Say whether PROP exists in the region."
3155 (text-property-not-all b e prop nil))
3157 (defun gnus-article-add-buttons (&optional force)
3158 "Find external references in the article and make buttons of them.
3159 \"External references\" are things like Message-IDs and URLs, as
3160 specified by `gnus-button-alist'."
3161 (interactive (list 'force))
3163 (set-buffer gnus-article-buffer)
3164 (let ((buffer-read-only nil)
3165 (inhibit-point-motion-hooks t)
3166 (case-fold-search t)
3167 (alist gnus-button-alist)
3169 ;; Remove all old markers.
3171 (while (setq marker (pop gnus-button-marker-list))
3173 (when (setq entry (gnus-button-entry))
3174 (put-text-property (match-beginning (nth 1 entry))
3175 (match-end (nth 1 entry))
3176 'gnus-callback nil))
3177 (set-marker marker nil)))
3178 ;; We skip the headers.
3179 (goto-char (point-min))
3180 (unless (search-forward "\n\n" nil t)
3181 (goto-char (point-max)))
3183 (while (setq entry (pop alist))
3184 (setq regexp (car entry))
3186 (while (re-search-forward regexp nil t)
3187 (let* ((start (and entry (match-beginning (nth 1 entry))))
3188 (end (and entry (match-end (nth 1 entry))))
3189 (from (match-beginning 0)))
3190 (when (and (or (eq t (nth 2 entry))
3191 (eval (nth 2 entry)))
3192 (not (gnus-button-in-region-p
3193 start end 'gnus-callback)))
3194 ;; That optional form returned non-nil, so we add the
3196 (gnus-article-add-button
3197 start end 'gnus-button-push
3198 (car (push (set-marker (make-marker) from)
3199 gnus-button-marker-list))))))))))
3201 ;; Add buttons to the head of an article.
3202 (defun gnus-article-add-buttons-to-head ()
3203 "Add buttons to the head of the article."
3206 (set-buffer gnus-article-buffer)
3207 (let ((buffer-read-only nil)
3208 (inhibit-point-motion-hooks t)
3209 (case-fold-search t)
3210 (alist gnus-header-button-alist)
3212 (nnheader-narrow-to-headers)
3214 ;; Each alist entry.
3215 (setq entry (car alist)
3217 (goto-char (point-min))
3218 (while (re-search-forward (car entry) nil t)
3219 ;; Each header matching the entry.
3220 (setq beg (match-beginning 0))
3221 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
3222 (match-beginning 0))
3225 (while (re-search-forward (nth 1 entry) end t)
3226 ;; Each match within a header.
3227 (let* ((entry (cdr entry))
3228 (start (match-beginning (nth 1 entry)))
3229 (end (match-end (nth 1 entry)))
3230 (form (nth 2 entry)))
3231 (goto-char (match-end 0))
3233 (gnus-article-add-button
3234 start end (nth 3 entry)
3235 (buffer-substring (match-beginning (nth 4 entry))
3236 (match-end (nth 4 entry)))))))
3240 ;;; External functions:
3242 (defun gnus-article-add-button (from to fun &optional data)
3243 "Create a button between FROM and TO with callback FUN and data DATA."
3244 (when gnus-article-button-face
3245 (gnus-overlay-put (gnus-make-overlay from to)
3246 'face gnus-article-button-face))
3247 (gnus-add-text-properties
3249 (nconc (and gnus-article-mouse-face
3250 (list gnus-mouse-face-prop gnus-article-mouse-face))
3251 (list 'gnus-callback fun)
3252 (and data (list 'gnus-data data)))))
3254 ;;; Internal functions:
3256 (defun gnus-article-set-globals ()
3258 (set-buffer gnus-summary-buffer)
3259 (gnus-set-global-variables)))
3261 (defun gnus-signature-toggle (end)
3263 (set-buffer gnus-article-buffer)
3264 (let ((buffer-read-only nil)
3265 (inhibit-point-motion-hooks t))
3266 (if (get-text-property end 'invisible)
3267 (gnus-article-unhide-text end (point-max))
3268 (gnus-article-hide-text end (point-max) gnus-hidden-properties)))))
3270 (defun gnus-button-entry ()
3271 ;; Return the first entry in `gnus-button-alist' matching this place.
3272 (let ((alist gnus-button-alist)
3275 (setq entry (pop alist))
3276 (if (looking-at (car entry))
3281 (defun gnus-button-push (marker)
3282 ;; Push button starting at MARKER.
3284 (set-buffer gnus-article-buffer)
3286 (let* ((entry (gnus-button-entry))
3287 (inhibit-point-motion-hooks t)
3289 (args (mapcar (lambda (group)
3290 (let ((string (match-string group)))
3291 (gnus-set-text-properties
3292 0 (length string) nil string)
3299 (fboundp (symbol-value fun)))
3300 (apply (symbol-value fun) args))
3302 (gnus-message 1 "You must define `%S' to use this button"
3303 (cons fun args)))))))
3305 (defun gnus-button-message-id (message-id)
3308 (set-buffer gnus-summary-buffer)
3309 (gnus-summary-refer-article message-id)))
3311 (defun gnus-button-fetch-group (address)
3312 "Fetch GROUP specified by ADDRESS."
3313 (if (not (string-match "[:/]" address))
3314 ;; This is just a simple group url.
3315 (gnus-group-read-ephemeral-group address gnus-select-method)
3316 (if (not (string-match "^\\([^:/]+\\)\\(:\\([^/]+\\)/\\)?\\(.*\\)$"
3318 (error "Can't parse %s" address)
3319 (gnus-group-read-ephemeral-group
3320 (match-string 4 address)
3321 `(nntp ,(match-string 1 address)
3322 (nntp-address ,(match-string 1 address))
3323 (nntp-port-number ,(if (match-end 3)
3324 (match-string 3 address)
3327 (defun gnus-url-parse-query-string (query &optional downcase)
3328 (let (retval pairs cur key val)
3329 (setq pairs (split-string query "&"))
3331 (setq cur (car pairs)
3333 (if (not (string-match "=" cur))
3335 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
3336 val (gnus-url-unhex-string (substring cur (match-end 0) nil)))
3338 (setq key (downcase key)))
3339 (setq cur (assoc key retval))
3341 (setcdr cur (cons val (cdr cur)))
3342 (setq retval (cons (list key val) retval)))))
3345 (defun gnus-url-unhex (x)
3352 (defun gnus-url-unhex-string (str &optional allow-newlines)
3353 "Remove %XXX embedded spaces, etc in a url.
3354 If optional second argument ALLOW-NEWLINES is non-nil, then allow the
3355 decoding of carriage returns and line feeds in the string, which is normally
3356 forbidden in URL encoding."
3357 (setq str (or str ""))
3359 (case-fold-search t))
3360 (while (string-match "%[0-9a-f][0-9a-f]" str)
3361 (let* ((start (match-beginning 0))
3362 (ch1 (gnus-url-unhex (elt str (+ start 1))))
3364 (gnus-url-unhex (elt str (+ start 2))))))
3366 tmp (substring str 0 start)
3369 (char-to-string code))
3370 ((or (= code ?\n) (= code ?\r))
3372 (t (char-to-string code))))
3373 str (substring str (match-end 0)))))
3374 (setq tmp (concat tmp str))
3377 (defun gnus-url-mailto (url)
3378 ;; Send mail to someone
3379 (when (string-match "mailto:/*\\(.*\\)" url)
3380 (setq url (substring url (match-beginning 1) nil)))
3381 (let (to args subject func)
3382 (if (string-match (regexp-quote "?") url)
3383 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
3384 args (gnus-url-parse-query-string
3385 (substring url (match-end 0) nil) t))
3386 (setq to (gnus-url-unhex-string url)))
3387 (setq args (cons (list "to" to) args)
3388 subject (cdr-safe (assoc "subject" args)))
3389 (gnus-setup-message 'reply
3392 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
3395 (message-position-on-field (caar args)))
3396 (insert (mapconcat 'identity (cdar args) ", "))
3397 (setq args (cdr args)))
3400 (message-goto-subject)))))
3402 (defun gnus-button-mailto (address)
3404 (set-buffer (gnus-copy-article-buffer))
3405 (gnus-setup-message 'reply
3406 (message-reply address)))
3408 (defun gnus-button-reply (address)
3409 ;; Reply to ADDRESS.
3410 (gnus-setup-message 'reply
3411 (message-reply address)))
3413 (defun gnus-button-url (address)
3415 ;; In Emacs 20, `browse-url-browser-function' may be an alist.
3416 (if (listp browse-url-browser-function)
3417 (browse-url address)
3418 (funcall browse-url-browser-function address)))
3420 (defun gnus-button-embedded-url (address)
3422 ;; In Emacs 20, `browse-url-browser-function' may be an alist.
3423 (if (listp browse-url-browser-function)
3424 (browse-url (gnus-strip-whitespace address))
3425 (funcall browse-url-browser-function (gnus-strip-whitespace address))))
3427 ;;; Next/prev buttons in the article buffer.
3429 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
3430 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
3432 (defvar gnus-prev-page-map nil)
3433 (unless gnus-prev-page-map
3434 (setq gnus-prev-page-map (make-sparse-keymap))
3435 (define-key gnus-prev-page-map gnus-mouse-2 'gnus-button-prev-page)
3436 (define-key gnus-prev-page-map "\r" 'gnus-button-prev-page))
3438 (defun gnus-insert-prev-page-button ()
3439 (let ((buffer-read-only nil))
3441 gnus-prev-page-line-format nil
3442 `(gnus-prev t local-map ,gnus-prev-page-map
3443 gnus-callback gnus-article-button-prev-page
3444 gnus-type annotation))))
3446 (defvar gnus-next-page-map nil)
3447 (unless gnus-next-page-map
3448 (setq gnus-next-page-map (make-keymap))
3449 (suppress-keymap gnus-prev-page-map)
3450 (define-key gnus-next-page-map gnus-mouse-2 'gnus-button-next-page)
3451 (define-key gnus-next-page-map "\r" 'gnus-button-next-page))
3453 (defun gnus-button-next-page ()
3454 "Go to the next page."
3456 (let ((win (selected-window)))
3457 (select-window (get-buffer-window gnus-article-buffer t))
3458 (gnus-article-next-page)
3459 (select-window win)))
3461 (defun gnus-button-prev-page ()
3462 "Go to the prev page."
3464 (let ((win (selected-window)))
3465 (select-window (get-buffer-window gnus-article-buffer t))
3466 (gnus-article-prev-page)
3467 (select-window win)))
3469 (defun gnus-insert-next-page-button ()
3470 (let ((buffer-read-only nil))
3471 (gnus-eval-format gnus-next-page-line-format nil
3473 t local-map ,gnus-next-page-map
3474 gnus-callback gnus-article-button-next-page
3475 gnus-type annotation))))
3477 (defun gnus-article-button-next-page (arg)
3478 "Go to the next page."
3480 (let ((win (selected-window)))
3481 (select-window (get-buffer-window gnus-article-buffer t))
3482 (gnus-article-next-page)
3483 (select-window win)))
3485 (defun gnus-article-button-prev-page (arg)
3486 "Go to the prev page."
3488 (let ((win (selected-window)))
3489 (select-window (get-buffer-window gnus-article-buffer t))
3490 (gnus-article-prev-page)
3491 (select-window win)))
3497 (defun gnus-article-header-presentation-method (entity situation)
3498 (mime-insert-decoded-header entity)
3501 (set-alist 'mime-header-presentation-method-alist
3502 'gnus-original-article-mode
3503 #'gnus-article-header-presentation-method)
3505 (defun gnus-mime-preview-quitting-method ()
3507 (gnus-article-show-summary)
3508 (mime-preview-kill-buffer)
3509 (delete-other-windows)
3510 (gnus-article-show-summary)
3511 (gnus-summary-select-article nil t)
3514 (set-alist 'mime-preview-quitting-method-alist
3515 'gnus-original-article-mode #'gnus-mime-preview-quitting-method)
3517 (defun gnus-following-method (buf)
3520 (message-yank-original)
3522 (goto-char (point-min))
3525 (set-alist 'mime-preview-following-method-alist
3526 'gnus-original-article-mode #'gnus-following-method)
3536 (run-hooks 'gnus-art-load-hook)
3538 ;;; gnus-art.el ends here