1 ;;; gnus-art.el --- article mode commands for Semi-gnus
2 ;; Copyright (C) 1996,97,98,99 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
5 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
6 ;; Katsumi Yamaoka <yamaoka@jpl.org>
7 ;; Keywords: mail, news, MIME
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
30 (eval-when-compile (require 'cl))
41 ;; Avoid byte-compile warnings.
43 (defvar gnus-article-decoded-p)
44 (defvar gnus-article-mime-handles)
53 (defgroup gnus-article nil
55 :link '(custom-manual "(gnus)The Article Buffer")
58 (defgroup gnus-article-treat nil
59 "Treating article parts."
60 :link '(custom-manual "(gnus)Article Hiding")
63 (defgroup gnus-article-hiding nil
64 "Hiding article parts."
65 :link '(custom-manual "(gnus)Article Hiding")
68 (defgroup gnus-article-highlight nil
69 "Article highlighting."
70 :link '(custom-manual "(gnus)Article Highlighting")
74 (defgroup gnus-article-signature nil
76 :link '(custom-manual "(gnus)Article Signature")
79 (defgroup gnus-article-headers nil
81 :link '(custom-manual "(gnus)Hiding Headers")
84 (defgroup gnus-article-washing nil
85 "Special commands on articles."
86 :link '(custom-manual "(gnus)Article Washing")
89 (defgroup gnus-article-emphasis nil
90 "Fontisizing articles."
91 :link '(custom-manual "(gnus)Article Fontisizing")
94 (defgroup gnus-article-saving nil
96 :link '(custom-manual "(gnus)Saving Articles")
99 (defgroup gnus-article-mime nil
100 "Worshiping the MIME wonder."
101 :link '(custom-manual "(gnus)Using MIME")
102 :group 'gnus-article)
104 (defgroup gnus-article-buttons nil
105 "Pushable buttons in the article buffer."
106 :link '(custom-manual "(gnus)Article Buttons")
107 :group 'gnus-article)
109 (defgroup gnus-article-various nil
110 "Other article options."
111 :link '(custom-manual "(gnus)Misc Article")
112 :group 'gnus-article)
114 (defcustom gnus-ignored-headers
115 '("^Path:" "^Expires:" "^Date-Received:" "^References:" "^Xref:" "^Lines:"
116 "^Relay-Version:" "^Message-ID:" "^Approved:" "^Sender:" "^Received:"
117 "^X-UIDL:" "^MIME-Version:" "^Return-Path:" "^In-Reply-To:"
118 "^Content-Type:" "^Content-Transfer-Encoding:" "^X-WebTV-Signature:"
119 "^X-MimeOLE:" "^X-MSMail-Priority:" "^X-Priority:" "^X-Loop:"
120 "^X-Authentication-Warning:" "^X-MIME-Autoconverted:" "^X-Face:"
121 "^X-Attribution:" "^X-Originating-IP:" "^Delivered-To:"
122 "^NNTP-[-A-Za-z]+:" "^Distribution:" "^X-no-archive:" "^X-Trace:"
123 "^X-Complaints-To:" "^X-NNTP-Posting-Host:" "^X-Orig.*:"
124 "^Abuse-Reports-To:" "^Cache-Post-Path:" "^X-Article-Creation-Date:"
125 "^X-Poster:" "^X-Mail2News-Path:" "^X-Server-Date:" "^X-Cache:"
126 "^Originator:" "^X-Problems-To:" "^X-Auth-User:" "^X-Post-Time:"
127 "^X-Admin:" "^X-UID:" "^Resent-[-A-Za-z]+:" "^X-Mailing-List:"
128 "^Precedence:" "^Original-[-A-Za-z]+:" "^X-filename:" "^X-Orcpt:"
129 "^Old-Received:" "^X-Pgp-Fingerprint:" "^X-Pgp-Key-Id:"
130 "^X-Pgp-Public-Key-Url:" "^X-Auth:" "^X-From-Line:"
131 "^X-Gnus-Article-Number:" "^X-Majordomo:" "^X-Url:" "^X-Sender:"
132 "^X-Mailing-List:" "^MBOX-Line" "^Priority:" "^X-Pgp" "^X400-[-A-Za-z]+:"
133 "^Status:" "^X-Gnus-Mail-Source:" "^Cancel-Lock:")
134 "*All headers that start with this regexp will be hidden.
135 This variable can also be a list of regexps of headers to be ignored.
136 If `gnus-visible-headers' is non-nil, this variable will be ignored."
137 :type '(choice :custom-show nil
140 :group 'gnus-article-hiding)
142 (defcustom gnus-visible-headers
143 "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^[BGF]?Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-From:\\|^X-Sent:"
144 "*All headers that do not match this regexp will be hidden.
145 This variable can also be a list of regexp of headers to remain visible.
146 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
147 :type '(repeat :value-to-internal (lambda (widget value)
148 (custom-split-regexp-maybe value))
149 :match (lambda (widget value)
151 (widget-editable-list-match widget value)))
153 :group 'gnus-article-hiding)
155 (defcustom gnus-sorted-header-list
156 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
157 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
158 "*This variable is a list of regular expressions.
159 If it is non-nil, headers that match the regular expressions will
160 be placed first in the article buffer in the sequence specified by
162 :type '(repeat regexp)
163 :group 'gnus-article-hiding)
165 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
166 "Headers that are only to be displayed if they have interesting data.
167 Possible values in this list are `empty', `newsgroups', `followup-to',
168 `reply-to', `date', `long-to', and `many-to'."
169 :type '(set (const :tag "Headers with no content." empty)
170 (const :tag "Newsgroups with only one group." newsgroups)
171 (const :tag "Followup-to identical to newsgroups." followup-to)
172 (const :tag "Reply-to identical to from." reply-to)
173 (const :tag "Date less than four days old." date)
174 (const :tag "Very long To header." long-to)
175 (const :tag "Multiple To headers." many-to))
176 :group 'gnus-article-hiding)
178 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
179 "Regexp matching signature separator.
180 This can also be a list of regexps. In that case, it will be checked
181 from head to tail looking for a separator. Searches will be done from
182 the end of the buffer."
183 :type '(repeat string)
184 :group 'gnus-article-signature)
186 (defcustom gnus-signature-limit nil
187 "Provide a limit to what is considered a signature.
188 If it is a number, no signature may not be longer (in characters) than
189 that number. If it is a floating point number, no signature may be
190 longer (in lines) than that number. If it is a function, the function
191 will be called without any parameters, and if it returns nil, there is
192 no signature in the buffer. If it is a string, it will be used as a
193 regexp. If it matches, the text in question is not a signature."
194 :type '(choice (integer :value 200)
196 (function :value fun)
197 (regexp :value ".*"))
198 :group 'gnus-article-signature)
200 (defcustom gnus-hidden-properties '(invisible t intangible t)
201 "Property list to use for hiding text."
203 :group 'gnus-article-hiding)
205 (defcustom gnus-article-x-face-command
206 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | display -"
207 "*String or function to be executed to display an X-Face header.
208 If it is a string, the command will be executed in a sub-shell
209 asynchronously. The compressed face will be piped to this command."
210 :type 'string ;Leave function case to Lisp.
211 :group 'gnus-article-washing)
213 (defcustom gnus-article-x-face-too-ugly nil
214 "Regexp matching posters whose face shouldn't be shown automatically."
215 :type '(choice regexp (const nil))
216 :group 'gnus-article-washing)
218 (defcustom gnus-emphasis-alist
220 "\\(\\s-\\|^\\|[-\"]\\|\\s(\\|\\s)\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\s-\\|[-?!.,;:\"]\\|\\s(\\|\\s)\\)")
222 '(("_" "_" underline)
225 ("_/" "/_" underline-italic)
226 ("_\\*" "\\*_" underline-bold)
227 ("\\*/" "/\\*" bold-italic)
228 ("_\\*/" "/\\*_" underline-bold-italic))))
229 `(("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
230 2 3 gnus-emphasis-underline)
234 (format format (car spec) (cadr spec))
235 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
237 "*Alist that says how to fontify certain phrases.
238 Each item looks like this:
240 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
242 The first element is a regular expression to be matched. The second
243 is a number that says what regular expression grouping used to find
244 the entire emphasized word. The third is a number that says what
245 regexp grouping should be displayed and highlighted. The fourth
246 is the face used for highlighting."
247 :type '(repeat (list :value ("" 0 0 default)
249 (integer :tag "Match group")
250 (integer :tag "Emphasize group")
252 :group 'gnus-article-emphasis)
254 (defface gnus-emphasis-bold '((t (:bold t)))
255 "Face used for displaying strong emphasized text (*word*)."
256 :group 'gnus-article-emphasis)
258 (defface gnus-emphasis-italic '((t (:italic t)))
259 "Face used for displaying italic emphasized text (/word/)."
260 :group 'gnus-article-emphasis)
262 (defface gnus-emphasis-underline '((t (:underline t)))
263 "Face used for displaying underlined emphasized text (_word_)."
264 :group 'gnus-article-emphasis)
266 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
267 "Face used for displaying underlined bold emphasized text (_*word*_)."
268 :group 'gnus-article-emphasis)
270 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
271 "Face used for displaying underlined italic emphasized text (_*word*_)."
272 :group 'gnus-article-emphasis)
274 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
275 "Face used for displaying bold italic emphasized text (/*word*/)."
276 :group 'gnus-article-emphasis)
278 (defface gnus-emphasis-underline-bold-italic
279 '((t (:bold t :italic t :underline t)))
280 "Face used for displaying underlined bold italic emphasized text.
281 Esample: (_/*word*/_)."
282 :group 'gnus-article-emphasis)
284 (defface gnus-emphasis-highlight-words
285 '((t (:background "black" :foreground "yellow")))
286 "Face used for displaying highlighted words."
287 :group 'gnus-article-emphasis)
289 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
290 "Format for display of Date headers in article bodies.
291 See `format-time-string' for the possible values.
293 The variable can also be function, which should return a complete Date
294 header. The function is called with one argument, the time, which can
295 be fed to `format-time-string'."
296 :type '(choice string symbol)
297 :link '(custom-manual "(gnus)Article Date")
298 :group 'gnus-article-washing)
301 (autoload 'mail-extract-address-components "mail-extr"))
303 (defcustom gnus-save-all-headers t
304 "*If non-nil, don't remove any headers before saving."
305 :group 'gnus-article-saving
308 (defcustom gnus-prompt-before-saving 'always
309 "*This variable says how much prompting is to be done when saving articles.
310 If it is nil, no prompting will be done, and the articles will be
311 saved to the default files. If this variable is `always', each and
312 every article that is saved will be preceded by a prompt, even when
313 saving large batches of articles. If this variable is neither nil not
314 `always', there the user will be prompted once for a file name for
315 each invocation of the saving commands."
316 :group 'gnus-article-saving
317 :type '(choice (item always)
318 (item :tag "never" nil)
319 (sexp :tag "once" :format "%t\n" :value t)))
321 (defcustom gnus-saved-headers gnus-visible-headers
322 "Headers to keep if `gnus-save-all-headers' is nil.
323 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
324 If that variable is nil, however, all headers that match this regexp
325 will be kept while the rest will be deleted before saving."
326 :group 'gnus-article-saving
329 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
330 "A function to save articles in your favourite format.
331 The function must be interactively callable (in other words, it must
332 be an Emacs command).
334 Gnus provides the following functions:
336 * gnus-summary-save-in-rmail (Rmail format)
337 * gnus-summary-save-in-mail (Unix mail format)
338 * gnus-summary-save-in-folder (MH folder)
339 * gnus-summary-save-in-file (article format)
340 * gnus-summary-save-in-vm (use VM's folder format)
341 * gnus-summary-write-to-file (article format -- overwrite)."
342 :group 'gnus-article-saving
343 :type '(radio (function-item gnus-summary-save-in-rmail)
344 (function-item gnus-summary-save-in-mail)
345 (function-item gnus-summary-save-in-folder)
346 (function-item gnus-summary-save-in-file)
347 (function-item gnus-summary-save-in-vm)
348 (function-item gnus-summary-write-to-file)))
350 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
351 "A function generating a file name to save articles in Rmail format.
352 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
353 :group 'gnus-article-saving
356 (defcustom gnus-mail-save-name 'gnus-plain-save-name
357 "A function generating a file name to save articles in Unix mail format.
358 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
359 :group 'gnus-article-saving
362 (defcustom gnus-folder-save-name 'gnus-folder-save-name
363 "A function generating a file name to save articles in MH folder.
364 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
365 :group 'gnus-article-saving
368 (defcustom gnus-file-save-name 'gnus-numeric-save-name
369 "A function generating a file name to save articles in article format.
370 The function is called with NEWSGROUP, HEADERS, and optional
372 :group 'gnus-article-saving
375 (defcustom gnus-split-methods
376 '((gnus-article-archive-name)
377 (gnus-article-nndoc-name))
378 "*Variable used to suggest where articles are to be saved.
379 For instance, if you would like to save articles related to Gnus in
380 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
381 you could set this variable to something like:
383 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
384 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
386 This variable is an alist where the where the key is the match and the
387 value is a list of possible files to save in if the match is non-nil.
389 If the match is a string, it is used as a regexp match on the
390 article. If the match is a symbol, that symbol will be funcalled
391 from the buffer of the article to be saved with the newsgroup as the
392 parameter. If it is a list, it will be evaled in the same buffer.
394 If this form or function returns a string, this string will be used as
395 a possible file name; and if it returns a non-nil list, that list will
396 be used as possible file names."
397 :group 'gnus-article-saving
398 :type '(repeat (choice (list :value (fun) function)
399 (cons :value ("" "") regexp (repeat string))
402 (defcustom gnus-article-display-method-for-mime
403 'gnus-article-display-mime-message
404 "Function to display a MIME message.
405 The function is called from the article buffer."
406 :group 'gnus-article-mime
409 (defcustom gnus-article-display-method-for-traditional
410 'gnus-article-display-traditional-message
411 "*Function to display a traditional message.
412 The function is called from the article buffer."
413 :group 'gnus-article-mime
416 (defcustom gnus-page-delimiter "^\^L"
417 "*Regexp describing what to use as article page delimiters.
418 The default value is \"^\^L\", which is a form linefeed at the
419 beginning of a line."
421 :group 'gnus-article-various)
423 (defcustom gnus-article-mode-line-format "Gnus: %g %S%m"
424 "*The format specification for the article mode line.
425 See `gnus-summary-mode-line-format' for a closer description.
427 The following additional specs are available:
429 %w The article washing status.
430 %m The number of MIME parts in the article."
432 :group 'gnus-article-various)
434 (defcustom gnus-article-mode-hook nil
435 "*A hook for Gnus article mode."
437 :group 'gnus-article-various)
439 (defcustom gnus-article-menu-hook nil
440 "*Hook run after the creation of the article mode menu."
442 :group 'gnus-article-various)
444 (defcustom gnus-article-prepare-hook nil
445 "*A hook called after an article has been prepared in the article buffer."
447 :group 'gnus-article-various)
449 (defcustom gnus-article-hide-pgp-hook nil
450 "*A hook called after successfully hiding a PGP signature."
452 :group 'gnus-article-various)
454 (defcustom gnus-article-button-face 'bold
455 "Face used for highlighting buttons in the article buffer.
457 An article button is a piece of text that you can activate by pressing
458 `RET' or `mouse-2' above it."
460 :group 'gnus-article-buttons)
462 (defcustom gnus-article-mouse-face 'highlight
463 "Face used for mouse highlighting in the article buffer.
465 Article buttons will be displayed in this face when the cursor is
468 :group 'gnus-article-buttons)
470 (defcustom gnus-signature-face 'gnus-signature-face
471 "Face used for highlighting a signature in the article buffer.
472 Obsolete; use the face `gnus-signature-face' for customizations instead."
474 :group 'gnus-article-highlight
475 :group 'gnus-article-signature)
477 (defface gnus-signature-face
480 "Face used for highlighting a signature in the article buffer."
481 :group 'gnus-article-highlight
482 :group 'gnus-article-signature)
484 (defface gnus-header-from-face
487 (:foreground "spring green"))
490 (:foreground "red3"))
493 "Face used for displaying from headers."
494 :group 'gnus-article-headers
495 :group 'gnus-article-highlight)
497 (defface gnus-header-subject-face
500 (:foreground "SeaGreen3"))
503 (:foreground "red4"))
505 (:bold t :italic t)))
506 "Face used for displaying subject headers."
507 :group 'gnus-article-headers
508 :group 'gnus-article-highlight)
510 (defface gnus-header-newsgroups-face
513 (:foreground "yellow" :italic t))
516 (:foreground "MidnightBlue" :italic t))
519 "Face used for displaying newsgroups headers."
520 :group 'gnus-article-headers
521 :group 'gnus-article-highlight)
523 (defface gnus-header-name-face
526 (:foreground "SeaGreen"))
529 (:foreground "maroon"))
532 "Face used for displaying header names."
533 :group 'gnus-article-headers
534 :group 'gnus-article-highlight)
536 (defface gnus-header-content-face
539 (:foreground "forest green" :italic t))
542 (:foreground "indianred4" :italic t))
544 (:italic t))) "Face used for displaying header content."
545 :group 'gnus-article-headers
546 :group 'gnus-article-highlight)
548 (defcustom gnus-header-face-alist
549 '(("From" nil gnus-header-from-face)
550 ("Subject" nil gnus-header-subject-face)
551 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
552 ("" gnus-header-name-face gnus-header-content-face))
553 "*Controls highlighting of article header.
555 An alist of the form (HEADER NAME CONTENT).
557 HEADER is a regular expression which should match the name of an
558 header header and NAME and CONTENT are either face names or nil.
560 The name of each header field will be displayed using the face
561 specified by the first element in the list where HEADER match the
562 header name and NAME is non-nil. Similarly, the content will be
563 displayed by the first non-nil matching CONTENT face."
564 :group 'gnus-article-headers
565 :group 'gnus-article-highlight
566 :type '(repeat (list (regexp :tag "Header")
568 (item :tag "skip" nil)
569 (face :value default))
570 (choice :tag "Content"
571 (item :tag "skip" nil)
572 (face :value default)))))
574 (defcustom gnus-article-decode-hook nil
575 "*Hook run to decode charsets in articles."
576 :group 'gnus-article-headers
579 (defcustom gnus-display-mime-function 'gnus-display-mime
580 "Function to display MIME articles."
581 :group 'gnus-article-mime
584 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
585 "Function used to decode headers.")
587 (defvar gnus-article-dumbquotes-map
605 "Table for MS-to-Latin1 translation.")
607 (defcustom gnus-ignored-mime-types nil
608 "List of MIME types that should be ignored by Gnus."
609 :group 'gnus-article-mime
610 :type '(repeat regexp))
612 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
613 "List of MIME types that should not be given buttons when rendered."
614 :group 'gnus-article-mime
615 :type '(repeat regexp))
617 (defcustom gnus-article-mime-part-function nil
618 "Function called with a MIME handle as the argument.
619 This is meant for people who want to do something automatic based
620 on parts -- for instance, adding Vcard info to a database."
621 :group 'gnus-article-mime
624 (defcustom gnus-mime-multipart-functions nil
625 "An alist of MIME types to functions to display them.")
627 (defcustom gnus-article-date-lapsed-new-header nil
628 "Whether the X-Sent and Date headers can coexist.
629 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
630 either replace the old \"Date:\" header (if this variable is nil), or
631 be added below it (otherwise)."
632 :group 'gnus-article-headers
636 ;;; The treatment variables
639 (defvar gnus-part-display-hook nil
640 "Hook called on parts that are to receive treatment.")
642 (defvar gnus-article-treat-custom
643 '(choice (const :tag "Off" nil)
645 (const :tag "Header" head)
646 (const :tag "Last" last)
647 (integer :tag "Less")
648 (repeat :tag "Groups" regexp)
649 (sexp :tag "Predicate")))
651 (defvar gnus-article-treat-head-custom
652 '(choice (const :tag "Off" nil)
653 (const :tag "Header" head)))
655 (defvar gnus-article-treat-types '("text/plain")
658 (defvar gnus-inhibit-treatment nil
659 "Whether to inhibit treatment.")
661 (defcustom gnus-treat-highlight-signature '(or last (typep "text/x-vcard"))
662 "Highlight the signature.
663 Valid values are nil, t, `head', `last', an integer or a predicate.
664 See the manual for details."
665 :group 'gnus-article-treat
666 :type gnus-article-treat-custom)
667 (put 'gnus-treat-highlight-signature 'highlight t)
669 (defcustom gnus-treat-buttonize t
671 Valid values are nil, t, `head', `last', an integer or a predicate.
672 See the manual for details."
673 :group 'gnus-article-treat
674 :type gnus-article-treat-custom)
675 (put 'gnus-treat-buttonize 'highlight t)
677 (defcustom gnus-treat-buttonize-head 'head
678 "Add buttons to the head.
679 Valid values are nil, t, `head', `last', an integer or a predicate.
680 See the manual for details."
681 :group 'gnus-article-treat
682 :type gnus-article-treat-head-custom)
683 (put 'gnus-treat-buttonize-head 'highlight t)
685 (defcustom gnus-treat-emphasize t
687 Valid values are nil, t, `head', `last', an integer or a predicate.
688 See the manual for details."
689 :group 'gnus-article-treat
690 :type gnus-article-treat-custom)
691 (put 'gnus-treat-emphasize 'highlight t)
693 (defcustom gnus-treat-strip-cr nil
694 "Remove carriage returns.
695 Valid values are nil, t, `head', `last', an integer or a predicate.
696 See the manual for details."
697 :group 'gnus-article-treat
698 :type gnus-article-treat-custom)
700 (defcustom gnus-treat-hide-headers 'head
702 Valid values are nil, t, `head', `last', an integer or a predicate.
703 See the manual for details."
704 :group 'gnus-article-treat
705 :type gnus-article-treat-head-custom)
707 (defcustom gnus-treat-hide-boring-headers nil
708 "Hide boring headers.
709 Valid values are nil, t, `head', `last', an integer or a predicate.
710 See the manual for details."
711 :group 'gnus-article-treat
712 :type gnus-article-treat-head-custom)
714 (defcustom gnus-treat-hide-signature nil
716 Valid values are nil, t, `head', `last', an integer or a predicate.
717 See the manual for details."
718 :group 'gnus-article-treat
719 :type gnus-article-treat-custom)
721 (defcustom gnus-treat-fill-article nil
723 Valid values are nil, t, `head', `last', an integer or a predicate.
724 See the manual for details."
725 :group 'gnus-article-treat
726 :type gnus-article-treat-custom)
728 (defcustom gnus-treat-hide-citation nil
730 Valid values are nil, t, `head', `last', an integer or a predicate.
731 See the manual for details."
732 :group 'gnus-article-treat
733 :type gnus-article-treat-custom)
735 (defcustom gnus-treat-strip-pgp t
736 "Strip PGP signatures.
737 Valid values are nil, t, `head', `last', an integer or a predicate.
738 See the manual for details."
739 :group 'gnus-article-treat
740 :type gnus-article-treat-custom)
742 (defcustom gnus-treat-strip-pem nil
743 "Strip PEM signatures.
744 Valid values are nil, t, `head', `last', an integer or a predicate.
745 See the manual for details."
746 :group 'gnus-article-treat
747 :type gnus-article-treat-custom)
749 (defcustom gnus-treat-strip-banner t
750 "Strip banners from articles.
751 The banner to be stripped is specified in the `banner' group parameter.
752 Valid values are nil, t, `head', `last', an integer or a predicate.
753 See the manual for details."
754 :group 'gnus-article-treat
755 :type gnus-article-treat-custom)
757 (defcustom gnus-treat-highlight-headers 'head
758 "Highlight the headers.
759 Valid values are nil, t, `head', `last', an integer or a predicate.
760 See the manual for details."
761 :group 'gnus-article-treat
762 :type gnus-article-treat-head-custom)
763 (put 'gnus-treat-highlight-headers 'highlight t)
765 (defcustom gnus-treat-highlight-citation t
766 "Highlight cited text.
767 Valid values are nil, t, `head', `last', an integer or a predicate.
768 See the manual for details."
769 :group 'gnus-article-treat
770 :type gnus-article-treat-custom)
771 (put 'gnus-treat-highlight-citation 'highlight t)
773 (defcustom gnus-treat-date-ut nil
774 "Display the Date in UT (GMT).
775 Valid values are nil, t, `head', `last', an integer or a predicate.
776 See the manual for details."
777 :group 'gnus-article-treat
778 :type gnus-article-treat-head-custom)
780 (defcustom gnus-treat-date-local nil
781 "Display the Date in the local timezone.
782 Valid values are nil, t, `head', `last', an integer or a predicate.
783 See the manual for details."
784 :group 'gnus-article-treat
785 :type gnus-article-treat-head-custom)
787 (defcustom gnus-treat-date-lapsed nil
788 "Display the Date header in a way that says how much time has elapsed.
789 Valid values are nil, t, `head', `last', an integer or a predicate.
790 See the manual for details."
791 :group 'gnus-article-treat
792 :type gnus-article-treat-head-custom)
794 (defcustom gnus-treat-date-original nil
795 "Display the date in the original timezone.
796 Valid values are nil, t, `head', `last', an integer or a predicate.
797 See the manual for details."
798 :group 'gnus-article-treat
799 :type gnus-article-treat-head-custom)
801 (defcustom gnus-treat-date-iso8601 nil
802 "Display the date in the ISO8601 format.
803 Valid values are nil, t, `head', `last', an integer or a predicate.
804 See the manual for details."
805 :group 'gnus-article-treat
806 :type gnus-article-treat-head-custom)
808 (defcustom gnus-treat-date-user-defined nil
809 "Display the date in a user-defined format.
810 The format is defined by the `gnus-article-time-format' variable.
811 Valid values are nil, t, `head', `last', an integer or a predicate.
812 See the manual for details."
813 :group 'gnus-article-treat
814 :type gnus-article-treat-head-custom)
816 (defcustom gnus-treat-strip-headers-in-body t
817 "Strip the X-No-Archive header line from the beginning of the body.
818 Valid values are nil, t, `head', `last', an integer or a predicate.
819 See the manual for details."
820 :group 'gnus-article-treat
821 :type gnus-article-treat-custom)
823 (defcustom gnus-treat-strip-trailing-blank-lines nil
824 "Strip trailing blank lines.
825 Valid values are nil, t, `head', `last', an integer or a predicate.
826 See the manual for details."
827 :group 'gnus-article-treat
828 :type gnus-article-treat-custom)
830 (defcustom gnus-treat-strip-leading-blank-lines nil
831 "Strip leading blank lines.
832 Valid values are nil, t, `head', `last', an integer or a predicate.
833 See the manual for details."
834 :group 'gnus-article-treat
835 :type gnus-article-treat-custom)
837 (defcustom gnus-treat-strip-multiple-blank-lines nil
838 "Strip multiple blank lines.
839 Valid values are nil, t, `head', `last', an integer or a predicate.
840 See the manual for details."
841 :group 'gnus-article-treat
842 :type gnus-article-treat-custom)
844 (defcustom gnus-treat-strip-blank-lines nil
845 "Strip all blank lines.
846 Valid values are nil, t, `head', `last', an integer or a predicate.
847 See the manual for details."
848 :group 'gnus-article-treat
849 :type gnus-article-treat-custom)
851 (defcustom gnus-treat-overstrike t
852 "Treat overstrike highlighting.
853 Valid values are nil, t, `head', `last', an integer or a predicate.
854 See the manual for details."
855 :group 'gnus-article-treat
856 :type gnus-article-treat-custom)
857 (put 'gnus-treat-overstrike 'highlight t)
859 (defcustom gnus-treat-display-xface (if (and gnus-xemacs (featurep 'xface))
861 "Display X-Face headers.
862 Valid values are nil, t, `head', `last', an integer or a predicate.
863 See the manual for details."
864 :group 'gnus-article-treat
865 :type gnus-article-treat-head-custom)
866 (put 'gnus-treat-display-xface 'highlight t)
868 (defcustom gnus-treat-display-smileys (if (and gnus-xemacs
872 Valid values are nil, t, `head', `last', an integer or a predicate.
873 See the manual for details."
874 :group 'gnus-article-treat
875 :type gnus-article-treat-custom)
876 (put 'gnus-treat-display-smileys 'highlight t)
878 (defcustom gnus-treat-display-picons (if gnus-xemacs 'head nil)
880 Valid values are nil, t, `head', `last', an integer or a predicate.
881 See the manual for details."
882 :group 'gnus-article-treat
883 :type gnus-article-treat-head-custom)
884 (put 'gnus-treat-display-picons 'highlight t)
886 (defcustom gnus-treat-capitalize-sentences nil
887 "Capitalize sentence-starting words.
888 Valid values are nil, t, `head', `last', an integer or a predicate.
889 See the manual for details."
890 :group 'gnus-article-treat
891 :type gnus-article-treat-custom)
893 (defcustom gnus-treat-fill-long-lines nil
895 Valid values are nil, t, `head', `last', an integer or a predicate.
896 See the manual for details."
897 :group 'gnus-article-treat
898 :type gnus-article-treat-custom)
900 (defcustom gnus-treat-play-sounds nil
902 Valid values are nil, t, `head', `last', an integer or a predicate.
903 See the manual for details."
904 :group 'gnus-article-treat
905 :type gnus-article-treat-custom)
907 (defcustom gnus-treat-decode-article-as-default-mime-charset nil
908 "Decode an article as `default-mime-charset'. For instance, if you want to
909 attempt to decode an article even if the value of `gnus-show-mime' is nil,
910 you could set this variable to something like: nil for don't decode, t for
911 decode the body, '(or header t) for the whole article, etc."
912 :group 'gnus-article-treat
913 :type '(radio (const :tag "Off" nil)
914 (const :tag "Decode body" t)
915 (const :tag "Decode all" (or head t))))
917 (defcustom gnus-treat-translate nil
918 "Translate articles from one language to another.
919 Valid values are nil, t, `head', `last', an integer or a predicate.
920 See the manual for details."
921 :group 'gnus-article-treat
922 :type gnus-article-treat-custom)
924 ;;; Internal variables
926 (defvar article-goto-body-goes-to-point-min-p nil)
927 (defvar gnus-article-wash-types nil)
929 (defvar gnus-article-mime-handle-alist-1 nil)
930 (defvar gnus-treatment-function-alist
931 '((gnus-treat-strip-banner gnus-article-strip-banner)
932 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
933 (gnus-treat-buttonize gnus-article-add-buttons)
934 (gnus-treat-fill-article gnus-article-fill-cited-article)
935 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
936 (gnus-treat-strip-cr gnus-article-remove-cr)
937 (gnus-treat-emphasize gnus-article-emphasize)
938 (gnus-treat-display-xface gnus-article-display-x-face)
939 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
940 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
941 (gnus-treat-hide-signature gnus-article-hide-signature)
942 (gnus-treat-hide-citation gnus-article-hide-citation)
943 (gnus-treat-strip-pgp gnus-article-hide-pgp)
944 (gnus-treat-strip-pem gnus-article-hide-pem)
945 (gnus-treat-highlight-headers gnus-article-highlight-headers)
946 (gnus-treat-highlight-citation gnus-article-highlight-citation)
947 (gnus-treat-highlight-signature gnus-article-highlight-signature)
948 (gnus-treat-date-ut gnus-article-date-ut)
949 (gnus-treat-date-local gnus-article-date-local)
950 (gnus-treat-date-lapsed gnus-article-date-lapsed)
951 (gnus-treat-date-original gnus-article-date-original)
952 (gnus-treat-date-user-defined gnus-article-date-user)
953 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
954 (gnus-treat-strip-trailing-blank-lines
955 gnus-article-remove-trailing-blank-lines)
956 (gnus-treat-strip-leading-blank-lines
957 gnus-article-strip-leading-blank-lines)
958 (gnus-treat-strip-multiple-blank-lines
959 gnus-article-strip-multiple-blank-lines)
960 (gnus-treat-strip-blank-lines gnus-article-strip-blank-lines)
961 (gnus-treat-overstrike gnus-article-treat-overstrike)
962 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
963 (gnus-treat-display-smileys gnus-smiley-display)
964 (gnus-treat-display-picons gnus-article-display-picons)
965 (gnus-treat-play-sounds gnus-earcon-display)
966 (gnus-treat-decode-article-as-default-mime-charset
967 gnus-article-decode-article-as-default-mime-charset)))
969 (defvar gnus-article-mime-handle-alist nil)
970 (defvar article-lapsed-timer nil)
971 (defvar gnus-article-current-summary nil)
973 (defvar gnus-article-mode-syntax-table
974 (let ((table (copy-syntax-table text-mode-syntax-table)))
975 (modify-syntax-entry ?- "w" table)
976 (modify-syntax-entry ?> ")" table)
977 (modify-syntax-entry ?< "(" table)
979 "Syntax table used in article mode buffers.
980 Initialized from `text-mode-syntax-table.")
982 (defvar gnus-save-article-buffer nil)
984 (defvar gnus-article-mode-line-format-alist
985 (nconc '((?w (gnus-article-wash-status) ?s)
986 (?m (gnus-article-mime-part-status) ?s))
987 gnus-summary-mode-line-format-alist))
989 (defvar gnus-number-of-articles-to-be-saved nil)
991 (defvar gnus-inhibit-hiding nil)
993 (defsubst gnus-article-hide-text (b e props)
994 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
995 (add-text-properties b e props)
996 (when (memq 'intangible props)
998 (max (1- b) (point-min))
999 b 'intangible (cddr (memq 'intangible props)))))
1000 (defsubst gnus-article-unhide-text (b e)
1001 "Remove hidden text properties from region between B and E."
1002 (remove-text-properties b e gnus-hidden-properties)
1003 (when (memq 'intangible gnus-hidden-properties)
1004 (put-text-property (max (1- b) (point-min))
1005 b 'intangible nil)))
1007 (defun gnus-article-hide-text-type (b e type)
1008 "Hide text of TYPE between B and E."
1009 (push type gnus-article-wash-types)
1010 (gnus-article-hide-text
1011 b e (cons 'article-type (cons type gnus-hidden-properties))))
1013 (defun gnus-article-unhide-text-type (b e type)
1014 "Unhide text of TYPE between B and E."
1015 (setq gnus-article-wash-types
1016 (delq type gnus-article-wash-types))
1017 (remove-text-properties
1018 b e (cons 'article-type (cons type gnus-hidden-properties)))
1019 (when (memq 'intangible gnus-hidden-properties)
1020 (put-text-property (max (1- b) (point-min))
1021 b 'intangible nil)))
1023 (defun gnus-article-hide-text-of-type (type)
1024 "Hide text of TYPE in the current buffer."
1026 (let ((b (point-min))
1028 (while (setq b (text-property-any b e 'article-type type))
1029 (add-text-properties b (incf b) gnus-hidden-properties)))))
1031 (defun gnus-article-delete-text-of-type (type)
1032 "Delete text of TYPE in the current buffer."
1034 (let ((b (point-min)))
1035 (while (setq b (text-property-any b (point-max) 'article-type type))
1037 b (or (text-property-not-all b (point-max) 'article-type type)
1040 (defun gnus-article-delete-invisible-text ()
1041 "Delete all invisible text in the current buffer."
1043 (let ((b (point-min)))
1044 (while (setq b (text-property-any b (point-max) 'invisible t))
1046 b (or (text-property-not-all b (point-max) 'invisible t)
1049 (defun gnus-article-text-type-exists-p (type)
1050 "Say whether any text of type TYPE exists in the buffer."
1051 (text-property-any (point-min) (point-max) 'article-type type))
1053 (defsubst gnus-article-header-rank ()
1054 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1055 (let ((list gnus-sorted-header-list)
1058 (when (looking-at (car list))
1060 (setq list (cdr list))
1064 (defun article-hide-headers (&optional arg delete)
1065 "Hide unwanted headers and possibly sort them as well."
1066 (interactive (gnus-article-hidden-arg))
1067 ;; Lars said that this function might be inhibited.
1068 (if (gnus-article-check-hidden-text 'headers arg)
1070 ;; Show boring headers as well.
1071 (gnus-article-show-hidden-text 'boring-headers)
1072 (when (eq 1 (point-min))
1073 (set-window-start (get-buffer-window (current-buffer)) 1)))
1074 (unless gnus-inhibit-hiding
1077 (let ((buffer-read-only nil)
1078 (inhibit-read-only t)
1079 (case-fold-search t)
1080 (max (1+ (length gnus-sorted-header-list)))
1081 (ignored (when (not gnus-visible-headers)
1082 (cond ((stringp gnus-ignored-headers)
1083 gnus-ignored-headers)
1084 ((listp gnus-ignored-headers)
1085 (mapconcat 'identity gnus-ignored-headers
1088 (cond ((stringp gnus-visible-headers)
1089 gnus-visible-headers)
1090 ((and gnus-visible-headers
1091 (listp gnus-visible-headers))
1092 (mapconcat 'identity gnus-visible-headers "\\|"))))
1093 (inhibit-point-motion-hooks t)
1095 ;; First we narrow to just the headers.
1096 (article-narrow-to-head)
1097 ;; Hide any "From " lines at the beginning of (mail) articles.
1098 (while (looking-at "From ")
1102 (delete-region (point-min) (point))
1103 (gnus-article-hide-text (point-min) (point)
1104 (nconc (list 'article-type 'headers)
1105 gnus-hidden-properties))))
1106 ;; Then treat the rest of the header lines.
1107 ;; Then we use the two regular expressions
1108 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1109 ;; select which header lines is to remain visible in the
1111 (while (re-search-forward "^[^ \t]*:" nil t)
1113 ;; Mark the rank of the header.
1115 (point) (1+ (point)) 'message-rank
1116 (if (or (and visible (looking-at visible))
1118 (not (looking-at ignored))))
1119 (gnus-article-header-rank)
1122 (message-sort-headers-1)
1123 (when (setq beg (text-property-any
1124 (point-min) (point-max) 'message-rank (+ 2 max)))
1125 ;; We delete or make invisible the unwanted headers.
1128 (add-text-properties
1129 (point-min) (+ 5 (point-min))
1130 '(article-type headers dummy-invisible t))
1131 (delete-region beg (point-max)))
1132 (gnus-article-hide-text-type beg (point-max) 'headers))))))))
1135 (defun article-hide-boring-headers (&optional arg)
1136 "Toggle hiding of headers that aren't very interesting.
1137 If given a negative prefix, always show; if given a positive prefix,
1139 (interactive (gnus-article-hidden-arg))
1140 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1141 (not gnus-show-all-headers))
1144 (let ((buffer-read-only nil)
1145 (list gnus-boring-article-headers)
1146 (inhibit-point-motion-hooks t)
1148 (article-narrow-to-head)
1150 (setq elem (pop list))
1151 (goto-char (point-min))
1153 ;; Hide empty headers.
1155 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1157 (gnus-article-hide-text-type
1158 (progn (beginning-of-line) (point))
1161 (if (re-search-forward "^[^ \t]" nil t)
1165 ;; Hide boring Newsgroups header.
1166 ((eq elem 'newsgroups)
1167 (when (equal (gnus-fetch-field "newsgroups")
1168 (gnus-group-real-name
1169 (if (boundp 'gnus-newsgroup-name)
1172 (gnus-article-hide-header "newsgroups")))
1173 ((eq elem 'followup-to)
1174 (when (equal (message-fetch-field "followup-to")
1175 (message-fetch-field "newsgroups"))
1176 (gnus-article-hide-header "followup-to")))
1177 ((eq elem 'reply-to)
1178 (let ((from (message-fetch-field "from"))
1179 (reply-to (message-fetch-field "reply-to")))
1184 (nth 1 (funcall gnus-extract-address-components from))
1185 (nth 1 (funcall gnus-extract-address-components reply-to)))))
1186 (gnus-article-hide-header "reply-to"))))
1188 (let ((date (message-fetch-field "date")))
1190 (< (days-between (current-time-string) date)
1192 (gnus-article-hide-header "date"))))
1194 (let ((to (message-fetch-field "to")))
1195 (when (> (length to) 1024)
1196 (gnus-article-hide-header "to"))))
1199 (goto-char (point-min))
1200 (while (re-search-forward "^to:" nil t)
1201 (setq to-count (1+ to-count)))
1202 (when (> to-count 1)
1203 (while (> to-count 0)
1204 (goto-char (point-min))
1206 (re-search-forward "^to:" nil nil to-count)
1208 (narrow-to-region (point) (point-max))
1209 (gnus-article-hide-header "to"))
1210 (setq to-count (1- to-count)))))))))))))
1212 (defun gnus-article-hide-header (header)
1214 (goto-char (point-min))
1215 (when (re-search-forward (concat "^" header ":") nil t)
1216 (gnus-article-hide-text-type
1217 (progn (beginning-of-line) (point))
1220 (if (re-search-forward "^[^ \t]" nil t)
1225 (defun article-toggle-headers (&optional arg)
1226 "Toggle hiding of headers. If given a negative prefix, always show;
1227 if given a positive prefix, always hide."
1228 (interactive (gnus-article-hidden-arg))
1229 (let ((force (when (numberp arg)
1230 (cond ((> arg 0) 'always-hide)
1231 ((< arg 0) 'always-show))))
1232 (window (get-buffer-window gnus-article-buffer))
1233 (header-end (point-min))
1234 header-start field-end field-start
1235 (inhibit-point-motion-hooks t)
1236 (inhibit-read-only t)
1240 (while (and (setq header-start
1241 (text-property-any header-end (point-max)
1242 'article-treated-header t))
1244 (text-property-not-all header-start (point-max)
1245 'article-treated-header t)))
1246 (setq field-end header-start)
1248 (;; Hide exposed invisible fields.
1249 (and (not (eq 'always-show force))
1251 (text-property-any field-end header-end
1252 'exposed-invisible-field t)))
1253 (while (and field-start
1254 (setq field-end (text-property-not-all
1255 field-start header-end
1256 'exposed-invisible-field t)))
1257 (add-text-properties field-start field-end gnus-hidden-properties)
1258 (setq field-start (text-property-any field-end header-end
1259 'exposed-invisible-field t)))
1260 (put-text-property header-start header-end
1261 'exposed-invisible-field nil))
1262 (;; Expose invisible fields.
1263 (and (not (eq 'always-hide force))
1265 (text-property-any field-end header-end 'invisible t)))
1266 (while (and field-start
1267 (setq field-end (text-property-not-all
1268 field-start header-end
1270 ;; If the invisible text is not terminated with newline, we
1271 ;; won't expose it. Because it may be created by x-face-mule.
1272 ;; BTW, XEmacs sometimes fail in putting a invisible text
1273 ;; property with `gnus-article-hide-text' (really?). In that
1274 ;; case, the invisible text might be started from the middle of
1275 ;; a line so we will expose the sort of thing.
1276 (when (or (not (or (eq header-start field-start)
1277 (eq ?\n (char-before field-start))))
1278 (eq ?\n (char-before field-end)))
1279 (remove-text-properties field-start field-end
1280 gnus-hidden-properties)
1281 (put-text-property field-start field-end
1282 'exposed-invisible-field t))
1283 (setq field-start (text-property-any field-end header-end
1286 (not (eq 'always-show force))
1287 (narrow-to-region header-start header-end)
1288 (article-hide-headers)
1289 ;; Re-display X-Face image under XEmacs.
1290 (when (and (featurep 'xemacs)
1291 (gnus-functionp gnus-article-x-face-command))
1292 (let ((func (cadr (assq 'gnus-treat-display-xface
1293 gnus-treatment-function-alist)))
1296 (gnus-treat-predicate gnus-treat-display-xface))
1298 (put-text-property header-start header-end 'read-only nil))))
1301 (goto-char (point-min))
1303 (set-window-start window (point-min))))))
1305 (defvar gnus-article-normalized-header-length 40
1306 "Length of normalized headers.")
1308 (defun article-normalize-headers ()
1309 "Make all header lines 40 characters long."
1311 (let ((buffer-read-only nil)
1315 (article-narrow-to-head)
1318 ((< (setq column (- (gnus-point-at-eol) (point)))
1319 gnus-article-normalized-header-length)
1321 (insert (make-string
1322 (- gnus-article-normalized-header-length column)
1324 ((> column gnus-article-normalized-header-length)
1325 (gnus-put-text-property
1327 (forward-char gnus-article-normalized-header-length)
1334 (forward-line 1))))))
1336 (defun article-treat-dumbquotes ()
1337 "Translate M******** sm*rtq**t*s into proper text.
1338 Note that this function guesses whether a character is a sm*rtq**t* or
1339 not, so it should only be used interactively."
1341 (article-translate-strings gnus-article-dumbquotes-map))
1343 (defun article-translate-characters (from to)
1344 "Translate all characters in the body of the article according to FROM and TO.
1345 FROM is a string of characters to translate from; to is a string of
1346 characters to translate to."
1348 (when (article-goto-body)
1349 (let ((buffer-read-only nil)
1350 (x (make-string 225 ?x))
1352 (while (< (incf i) (length x))
1355 (while (< i (length from))
1356 (aset x (aref from i) (aref to i))
1358 (translate-region (point) (point-max) x)))))
1360 (defun article-translate-strings (map)
1361 "Translate all string in the body of the article according to MAP.
1362 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1364 (when (article-goto-body)
1365 (let ((buffer-read-only nil)
1367 (while (setq elem (pop map))
1369 (while (search-forward (car elem) nil t)
1370 (replace-match (cadr elem)))))))))
1372 (defun article-treat-overstrike ()
1373 "Translate overstrikes into bold text."
1376 (when (article-goto-body)
1377 (let ((buffer-read-only nil))
1378 (while (search-forward "\b" nil t)
1379 (let ((next (char-after))
1380 (previous (char-after (- (point) 2))))
1381 ;; We do the boldification/underlining by hiding the
1382 ;; overstrikes and putting the proper text property
1386 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1387 (put-text-property (point) (1+ (point)) 'face 'bold))
1389 (gnus-article-hide-text-type
1390 (1- (point)) (1+ (point)) 'overstrike)
1392 (- (point) 2) (1- (point)) 'face 'underline))
1394 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1396 (point) (1+ (point)) 'face 'underline)))))))))
1398 (defun article-fill-long-lines ()
1399 "Fill lines that are wider than the window width."
1402 (let ((buffer-read-only nil)
1403 (width (window-width (get-buffer-window (current-buffer)))))
1406 (let ((adaptive-fill-mode nil))
1409 (when (>= (current-column) (min fill-column width))
1410 (narrow-to-region (point) (gnus-point-at-bol))
1411 (fill-paragraph nil)
1412 (goto-char (point-max))
1414 (forward-line 1)))))))
1416 (defun article-capitalize-sentences ()
1417 "Capitalize the first word in each sentence."
1420 (let ((buffer-read-only nil)
1421 (paragraph-start "^[\n\^L]"))
1425 (forward-sentence)))))
1427 (defun article-remove-cr ()
1428 "Remove trailing CRs and then translate remaining CRs into LFs."
1431 (let ((buffer-read-only nil))
1432 (goto-char (point-min))
1433 (while (re-search-forward "\r+$" nil t)
1434 (replace-match "" t t))
1435 (goto-char (point-min))
1436 (while (search-forward "\r" nil t)
1437 (replace-match "\n" t t)))))
1439 (defun article-remove-trailing-blank-lines ()
1440 "Remove all trailing blank lines from the article."
1443 (let ((buffer-read-only nil))
1444 (goto-char (point-max))
1448 (while (and (not (bobp))
1449 (looking-at "^[ \t]*$")
1450 (not (gnus-annotation-in-region-p
1451 (point) (gnus-point-at-eol))))
1456 (defun article-display-x-face (&optional force)
1457 "Look for an X-Face header and display it if present."
1458 (interactive (list 'force))
1460 ;; Delete the old process, if any.
1461 (when (process-status "article-x-face")
1462 (delete-process "article-x-face"))
1463 (let ((inhibit-point-motion-hooks t)
1464 (case-fold-search t)
1467 (article-narrow-to-head)
1468 (goto-char (point-min))
1469 (setq from (message-fetch-field "from"))
1470 (goto-char (point-min))
1471 (while (and gnus-article-x-face-command
1474 ;; Check whether this face is censored.
1475 (not gnus-article-x-face-too-ugly)
1476 (and gnus-article-x-face-too-ugly from
1477 (not (string-match gnus-article-x-face-too-ugly
1479 ;; Has to be present.
1480 (re-search-forward "^X-Face: " nil t))
1481 ;; This used to try to do multiple faces (`while' instead of
1482 ;; `when' above), but (a) sending multiple EOFs to xv doesn't
1483 ;; work (b) it can crash some versions of Emacs (c) are
1484 ;; multiple faces really something to encourage?
1485 (when (stringp gnus-article-x-face-command)
1487 ;; We now have the area of the buffer where the X-Face is stored.
1490 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
1491 ;; We display the face.
1492 (if (symbolp gnus-article-x-face-command)
1493 ;; The command is a lisp function, so we call it.
1494 (if (gnus-functionp gnus-article-x-face-command)
1495 (funcall gnus-article-x-face-command beg end)
1496 (error "%s is not a function" gnus-article-x-face-command))
1497 ;; The command is a string, so we interpret the command
1498 ;; as a, well, command, and fork it off.
1499 (let ((process-connection-type nil))
1500 (process-kill-without-query
1502 "article-x-face" nil shell-file-name shell-command-switch
1503 gnus-article-x-face-command))
1504 (process-send-region "article-x-face" beg end)
1505 (process-send-eof "article-x-face"))))))))))
1507 (defun article-decode-mime-words ()
1508 "Decode all MIME-encoded words in the article."
1511 (set-buffer gnus-article-buffer)
1512 (let ((inhibit-point-motion-hooks t)
1514 (mail-parse-charset gnus-newsgroup-charset))
1515 (mail-decode-encoded-word-region (point-min) (point-max)))))
1517 (defun article-decode-charset (&optional prompt)
1518 "Decode charset-encoded text in the article.
1519 If PROMPT (the prefix), prompt for a coding system to use."
1523 (article-narrow-to-head)
1524 (let* ((inhibit-point-motion-hooks t)
1525 (case-fold-search t)
1526 (ct (message-fetch-field "Content-Type" t))
1527 (cte (message-fetch-field "Content-Transfer-Encoding" t))
1528 (ctl (and ct (ignore-errors
1529 (mail-header-parse-content-type ct))))
1532 (mm-read-coding-system "Charset to decode: "))
1534 (mail-content-type-get ctl 'charset))))
1535 (mail-parse-charset gnus-newsgroup-charset)
1537 (when (memq charset gnus-newsgroup-ignored-charsets)
1539 (goto-char (point-max))
1542 (narrow-to-region (point) (point-max))
1543 (when (and (or (not ctl)
1544 (equal (car ctl) "text/plain"))
1547 charset (and cte (intern (downcase
1548 (gnus-strip-whitespace cte))))
1551 (defun article-decode-encoded-words ()
1552 "Remove encoded-word encoding from headers."
1553 (let (buffer-read-only)
1554 (let ((charset (save-excursion
1555 (set-buffer gnus-summary-buffer)
1556 default-mime-charset)))
1557 (mime-decode-header-in-buffer charset)
1560 (defun article-de-quoted-unreadable (&optional force)
1561 "Translate a quoted-printable-encoded article.
1562 If FORCE, decode the article whether it is marked as quoted-printable
1564 (interactive (list 'force))
1566 (let ((buffer-read-only nil)
1567 (type (gnus-fetch-field "content-transfer-encoding"))
1568 (charset gnus-newsgroup-charset))
1570 (and type (string-match "quoted-printable" (downcase type))))
1573 (narrow-to-region (point) (point-max))
1574 (quoted-printable-decode-region (point-min) (point-max))
1576 (mm-decode-body charset)))))))
1578 (defun article-hide-pgp ()
1579 "Remove any PGP headers and signatures in the current article."
1583 (let ((inhibit-point-motion-hooks t)
1584 buffer-read-only beg end)
1586 ;; Hide the "header".
1587 (when (re-search-forward "^-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
1588 (push 'pgp gnus-article-wash-types)
1589 (delete-region (match-beginning 0) (match-end 0))
1590 ;; PGP 5 and GNU PG add a `Hash: <>' comment, hide that too
1591 (when (looking-at "Hash:.*$")
1592 (delete-region (point) (1+ (gnus-point-at-eol))))
1594 ;; Hide the actual signature.
1595 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
1596 (setq end (1+ (match-beginning 0)))
1599 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
1601 ;; Perhaps we shouldn't hide to the end of the buffer
1602 ;; if there is no end to the signature?
1604 ;; Hide "- " PGP quotation markers.
1606 (narrow-to-region beg end)
1607 (goto-char (point-min))
1608 (while (re-search-forward "^- " nil t)
1610 (match-beginning 0) (match-end 0)))
1612 (gnus-run-hooks 'gnus-article-hide-pgp-hook))))))
1614 (defun article-hide-pem (&optional arg)
1615 "Toggle hiding of any PEM headers and signatures in the current article.
1616 If given a negative prefix, always show; if given a positive prefix,
1618 (interactive (gnus-article-hidden-arg))
1619 (unless (gnus-article-check-hidden-text 'pem arg)
1621 (let (buffer-read-only end)
1622 (goto-char (point-min))
1623 ;; Hide the horrendously ugly "header".
1624 (when (and (search-forward
1625 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
1627 (setq end (1+ (match-beginning 0))))
1628 (push 'pem gnus-article-wash-types)
1629 (gnus-article-hide-text-type
1631 (if (search-forward "\n\n" nil t)
1635 ;; Hide the trailer as well
1636 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
1638 (gnus-article-hide-text-type
1639 (match-beginning 0) (match-end 0) 'pem)))))))
1641 (defun article-strip-banner ()
1642 "Strip the banner specified by the `banner' group parameter."
1646 (let ((inhibit-point-motion-hooks t)
1647 (banner (gnus-group-get-parameter gnus-newsgroup-name 'banner))
1648 (gnus-signature-limit nil)
1649 buffer-read-only beg end)
1653 ((eq banner 'signature)
1654 (when (gnus-article-narrow-to-signature)
1657 (delete-region (point) (point-max))))
1659 (while (re-search-forward banner nil t)
1660 (delete-region (match-beginning 0) (match-end 0))))))))))
1662 (defun article-babel-prompt ()
1663 "Prompt for a babel translation."
1665 (completing-read "Translate from: "
1666 babel-translations nil t
1667 (car (car babel-translations))
1670 (defun article-babel (translation)
1671 "Translate article according to TRANSLATION using babelfish."
1672 (interactive (list (article-babel-prompt)))
1675 (set-buffer gnus-article-buffer)
1676 (when (article-goto-body)
1677 (let* ((buffer-read-only nil)
1680 (msg (buffer-substring start end)))
1682 (narrow-to-region start end)
1683 (delete-region start end)
1684 (babel-fetch msg (cdr (assoc translation babel-translations)))
1686 (narrow-to-region start (point-max))
1689 (defun article-hide-signature (&optional arg)
1690 "Hide the signature in the current article.
1691 If given a negative prefix, always show; if given a positive prefix,
1693 (interactive (gnus-article-hidden-arg))
1694 (unless (gnus-article-check-hidden-text 'signature arg)
1697 (let ((buffer-read-only nil))
1698 (when (gnus-article-narrow-to-signature)
1699 (gnus-article-hide-text-type
1700 (point-min) (point-max) 'signature)))))))
1702 (defun article-strip-headers-in-body ()
1703 "Strip offensive headers from bodies."
1707 (let ((case-fold-search t))
1708 (when (looking-at "x-no-archive:")
1709 (gnus-delete-line)))))
1711 (defun article-strip-leading-blank-lines ()
1712 "Remove all blank lines from the beginning of the article."
1715 (let ((inhibit-point-motion-hooks t)
1717 (when (article-goto-body)
1718 (while (and (not (eobp))
1719 (looking-at "[ \t]*$"))
1720 (gnus-delete-line))))))
1722 (defun article-narrow-to-head ()
1723 "Narrow the buffer to the head of the message.
1724 Point is left at the beginning of the narrowed-to region."
1726 (goto-char (point-min))
1727 (if (search-forward "\n\n" nil 1)
1730 (goto-char (point-min)))
1732 (defun article-goto-body ()
1733 "Place point at the start of the body."
1734 (goto-char (point-min))
1736 ;; This variable is only bound when dealing with separate
1738 (article-goto-body-goes-to-point-min-p
1740 ((search-forward "\n\n" nil t)
1743 (goto-char (point-max))
1746 (defun article-strip-multiple-blank-lines ()
1747 "Replace consecutive blank lines with one empty line."
1750 (let ((inhibit-point-motion-hooks t)
1752 ;; First make all blank lines empty.
1754 (while (re-search-forward "^[ \t]+$" nil t)
1755 (unless (gnus-annotation-in-region-p
1756 (match-beginning 0) (match-end 0))
1757 (replace-match "" nil t)))
1758 ;; Then replace multiple empty lines with a single empty line.
1760 (while (re-search-forward "\n\n\n+" nil t)
1761 (unless (gnus-annotation-in-region-p
1762 (match-beginning 0) (match-end 0))
1763 (replace-match "\n\n" t t))))))
1765 (defun article-strip-leading-space ()
1766 "Remove all white space from the beginning of the lines in the article."
1769 (let ((inhibit-point-motion-hooks t)
1772 (while (re-search-forward "^[ \t]+" nil t)
1773 (replace-match "" t t)))))
1775 (defun article-strip-trailing-space ()
1776 "Remove all white space from the end of the lines in the article."
1779 (let ((inhibit-point-motion-hooks t)
1782 (while (re-search-forward "[ \t]+$" nil t)
1783 (replace-match "" t t)))))
1785 (defun article-strip-blank-lines ()
1786 "Strip leading, trailing and multiple blank lines."
1788 (article-strip-leading-blank-lines)
1789 (article-remove-trailing-blank-lines)
1790 (article-strip-multiple-blank-lines))
1792 (defun article-strip-all-blank-lines ()
1793 "Strip all blank lines."
1796 (let ((inhibit-point-motion-hooks t)
1799 (while (re-search-forward "^[ \t]*\n" nil t)
1800 (replace-match "" t t)))))
1802 (defun gnus-article-narrow-to-signature ()
1803 "Narrow to the signature; return t if a signature is found, else nil."
1804 (let ((inhibit-point-motion-hooks t))
1805 (when (gnus-article-search-signature)
1807 ;; Check whether we have some limits to what we consider
1808 ;; to be a signature.
1809 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
1810 (list gnus-signature-limit)))
1812 (while (setq limit (pop limits))
1813 (if (or (and (integerp limit)
1814 (< (- (point-max) (point)) limit))
1816 (< (count-lines (point) (point-max)) limit))
1817 (and (gnus-functionp limit)
1819 (and (stringp limit)
1820 (not (re-search-forward limit nil t))))
1821 () ; This limit did not succeed.
1825 (narrow-to-region (point) (point-max))
1828 (defun gnus-article-search-signature ()
1829 "Search the current buffer for the signature separator.
1830 Put point at the beginning of the signature separator."
1831 (let ((cur (point)))
1832 (goto-char (point-max))
1833 (if (if (stringp gnus-signature-separator)
1834 (re-search-backward gnus-signature-separator nil t)
1835 (let ((seps gnus-signature-separator))
1837 (not (re-search-backward (car seps) nil t)))
1844 (defun gnus-article-hidden-arg ()
1845 "Return the current prefix arg as a number, or 0 if no prefix."
1846 (list (if current-prefix-arg
1847 (prefix-numeric-value current-prefix-arg)
1850 (defun gnus-article-check-hidden-text (type arg)
1851 "Return nil if hiding is necessary.
1852 Arg can be nil or a number. Nil and positive means hide, negative
1853 means show, 0 means toggle."
1856 (let ((hide (gnus-article-hidden-text-p type)))
1862 (gnus-article-show-hidden-text type))
1864 (if (eq hide 'hidden)
1865 (gnus-article-show-hidden-text type)
1868 (defun gnus-article-hidden-text-p (type)
1869 "Say whether the current buffer contains hidden text of type TYPE."
1870 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
1872 (not (get-text-property pos 'invisible))
1873 (not (get-text-property pos 'dummy-invisible)))
1875 (text-property-any (1+ pos) (point-max) 'article-type type)))
1880 (defun gnus-article-show-hidden-text (type &optional hide)
1881 "Show all hidden text of type TYPE.
1882 If HIDE, hide the text instead."
1884 (let ((buffer-read-only nil)
1885 (inhibit-point-motion-hooks t)
1888 (while (setq beg (text-property-any end (point-max) 'article-type type))
1891 (text-property-not-all beg (point-max) 'article-type type)
1894 (gnus-article-hide-text beg end gnus-hidden-properties)
1895 (gnus-article-unhide-text beg end))
1899 (defconst article-time-units
1900 `((year . ,(* 365.25 24 60 60))
1901 (week . ,(* 7 24 60 60))
1902 (day . ,(* 24 60 60))
1906 "Mapping from time units to seconds.")
1908 (defun article-date-ut (&optional type highlight header)
1909 "Convert DATE date to universal time in the current article.
1910 If TYPE is `local', convert to local time; if it is `lapsed', output
1911 how much time has lapsed since DATE. For `lapsed', the value of
1912 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
1913 should replace the \"Date:\" one, or should be added below it."
1914 (interactive (list 'ut t))
1915 (let* ((header (or header
1916 (and (eq 1 (point-min))
1917 (mail-header-date (save-excursion
1918 (set-buffer gnus-summary-buffer)
1919 gnus-current-headers)))
1920 (message-fetch-field "date")
1922 (date (if (vectorp header) (mail-header-date header)
1924 (inhibit-point-motion-hooks t)
1925 bface eface date-pos)
1926 (when (and date (not (string= date "")))
1929 (article-narrow-to-head)
1930 (when (or (and (eq type 'lapsed)
1931 gnus-article-date-lapsed-new-header
1932 ;; Attempt to get the face of X-Sent first.
1933 (re-search-forward "^X-Sent:[ \t]" nil t))
1934 (re-search-forward "^Date:[ \t]" nil t)
1935 ;; If Date is missing, try again for X-Sent.
1936 (re-search-forward "^X-Sent:[ \t]" nil t))
1937 (setq bface (get-text-property (gnus-point-at-bol) 'face)
1938 eface (get-text-property (1- (gnus-point-at-eol))
1940 (let ((buffer-read-only nil))
1941 ;; Delete any old X-Sent headers.
1942 (when (setq date-pos
1943 (text-property-any (point-min) (point-max)
1944 'article-date-lapsed t))
1945 (goto-char (setq date-pos (set-marker (make-marker) date-pos)))
1946 (delete-region (match-beginning 0)
1947 (progn (forward-line 1) (point))))
1948 (goto-char (point-min))
1949 ;; Delete any old Date headers.
1950 (while (re-search-forward "^Date:[ \t]" nil t)
1952 (setq date-pos (match-beginning 0)))
1953 (unless (and (eq type 'lapsed)
1954 gnus-article-date-lapsed-new-header)
1955 (delete-region (match-beginning 0)
1956 (progn (message-next-header) (point)))))
1959 (goto-char date-pos)
1961 ;; Possibly, Date has been deleted.
1963 (when (and (eq type 'lapsed)
1964 gnus-article-date-lapsed-new-header
1965 (looking-at "Date:"))
1967 (goto-char (point-min)))
1968 (insert (article-make-date-line date type))
1969 (when (eq type 'lapsed)
1970 (put-text-property (gnus-point-at-bol) (point)
1971 'article-date-lapsed t))
1975 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
1976 (put-text-property (match-beginning 1) (1+ (match-end 1))
1978 (put-text-property (match-beginning 2) (match-end 2)
1981 (defun article-make-date-line (date type)
1982 "Return a DATE line of TYPE."
1983 (let ((time (condition-case ()
1987 ;; Convert to the local timezone. We have to slap a
1988 ;; `condition-case' round the calls to the timezone
1989 ;; functions since they aren't particularly resistant to
1992 (let ((tz (car (current-time-zone))))
1993 (format "Date: %s %s%04d" (current-time-string time)
1994 (if (> tz 0) "+" "-") (abs (/ tz 36)))))
1995 ;; Convert to Universal Time.
1998 (current-time-string
1999 (let* ((e (parse-time-string date))
2000 (tm (apply 'encode-time e))
2002 (ls (- (cadr tm) (car (current-time-zone)))))
2003 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2004 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2007 ;; Get the original date from the article.
2008 ((eq type 'original)
2009 (concat "Date: " (if (string-match "\n+$" date)
2010 (substring date 0 (match-beginning 0))
2012 ;; Let the user define the format.
2014 (if (gnus-functionp gnus-article-time-format)
2015 (funcall gnus-article-time-format time)
2018 (format-time-string gnus-article-time-format time))))
2023 (format-time-string "%Y%m%dT%H%M%S" time)))
2024 ;; Do an X-Sent lapsed format.
2026 ;; If the date is seriously mangled, the timezone functions are
2027 ;; liable to bug out, so we ignore all errors.
2028 (let* ((now (current-time))
2029 (real-time (subtract-time now time))
2030 (real-sec (and real-time
2031 (+ (* (float (car real-time)) 65536)
2033 (sec (and real-time (abs real-sec)))
2043 ;; This is a bit convoluted, but basically we go
2044 ;; through the time units for years, weeks, etc,
2045 ;; and divide things to see whether that results
2046 ;; in positive answers.
2049 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2050 ;; The (remaining) seconds are too few to
2051 ;; be divided into this time unit.
2053 ;; It's big enough, so we output it.
2054 (setq sec (- sec (* num (cdr unit))))
2056 (concat (if prev ", " "") (int-to-string
2058 " " (symbol-name (car unit))
2059 (if (> num 1) "s" ""))
2061 article-time-units "")
2062 ;; If dates are odd, then it might appear like the
2063 ;; article was sent in the future.
2066 " in the future"))))))
2068 (error "Unknown conversion type: %s" type)))))
2070 (defun article-date-local (&optional highlight)
2071 "Convert the current article date to the local timezone."
2072 (interactive (list t))
2073 (article-date-ut 'local highlight))
2075 (defun article-date-original (&optional highlight)
2076 "Convert the current article date to what it was originally.
2077 This is only useful if you have used some other date conversion
2078 function and want to see what the date was before converting."
2079 (interactive (list t))
2080 (article-date-ut 'original highlight))
2082 (defun article-date-lapsed (&optional highlight)
2083 "Convert the current article date to time lapsed since it was sent."
2084 (interactive (list t))
2085 (article-date-ut 'lapsed highlight))
2087 (defun article-update-date-lapsed ()
2088 "Function to be run from a timer to update the lapsed time line."
2089 (let (deactivate-mark)
2094 (set-buffer (window-buffer w))
2095 (when (eq major-mode 'gnus-article-mode)
2096 (goto-char (point-min))
2097 (when (re-search-forward "^X-Sent:" nil t)
2098 (article-date-lapsed t))))
2101 (defun gnus-start-date-timer (&optional n)
2102 "Start a timer to update the X-Sent header in the article buffers.
2103 The numerical prefix says how frequently (in seconds) the function
2108 (gnus-stop-date-timer)
2109 (setq article-lapsed-timer
2110 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2112 (defun gnus-stop-date-timer ()
2113 "Stop the X-Sent timer."
2115 (when article-lapsed-timer
2116 (nnheader-cancel-timer article-lapsed-timer)
2117 (setq article-lapsed-timer nil)))
2119 (defun article-date-user (&optional highlight)
2120 "Convert the current article date to the user-defined format.
2121 This format is defined by the `gnus-article-time-format' variable."
2122 (interactive (list t))
2123 (article-date-ut 'user highlight))
2125 (defun article-date-iso8601 (&optional highlight)
2126 "Convert the current article date to ISO8601."
2127 (interactive (list t))
2128 (article-date-ut 'iso8601 highlight))
2130 (defun article-show-all ()
2131 "Show all hidden text in the article buffer."
2134 (let ((buffer-read-only nil))
2135 (gnus-article-unhide-text (point-min) (point-max)))))
2137 (defun article-emphasize (&optional arg)
2138 "Emphasize text according to `gnus-emphasis-alist'."
2139 (interactive (gnus-article-hidden-arg))
2140 (unless (gnus-article-check-hidden-text 'emphasis arg)
2142 (let ((alist (or gnus-newsgroup-emphasis-alist gnus-emphasis-alist))
2143 (buffer-read-only nil)
2144 (props (append '(article-type emphasis)
2145 gnus-hidden-properties))
2146 regexp elem beg invisible visible face)
2149 (while (setq elem (pop alist))
2151 (setq regexp (car elem)
2152 invisible (nth 1 elem)
2153 visible (nth 2 elem)
2155 (while (re-search-forward regexp nil t)
2156 (when (and (match-beginning visible) (match-beginning invisible))
2157 (gnus-article-hide-text
2158 (match-beginning invisible) (match-end invisible) props)
2159 (gnus-article-unhide-text-type
2160 (match-beginning visible) (match-end visible) 'emphasis)
2161 (gnus-put-text-property-excluding-newlines
2162 (match-beginning visible) (match-end visible) 'face face)
2163 (goto-char (match-end invisible)))))))))
2165 (defvar gnus-summary-article-menu)
2166 (defvar gnus-summary-post-menu)
2168 ;;; Saving functions.
2170 (defun gnus-article-save (save-buffer file &optional num)
2171 "Save the currently selected article."
2172 (unless gnus-save-all-headers
2173 ;; Remove headers according to `gnus-saved-headers'.
2174 (let ((gnus-visible-headers
2175 (or gnus-saved-headers gnus-visible-headers))
2176 (gnus-article-buffer save-buffer))
2178 (set-buffer save-buffer)
2179 (article-hide-headers 1 t))))
2180 (save-window-excursion
2181 (if (not gnus-default-article-saver)
2182 (error "No default saver is defined")
2183 ;; !!! Magic! The saving functions all save
2184 ;; `gnus-save-article-buffer' (or so they think), but we
2185 ;; bind that variable to our save-buffer.
2186 (set-buffer gnus-article-buffer)
2187 (let* ((gnus-save-article-buffer save-buffer)
2190 ((not gnus-prompt-before-saving) 'default)
2191 ((eq gnus-prompt-before-saving 'always) nil)
2193 (gnus-number-of-articles-to-be-saved
2194 (when (eq gnus-prompt-before-saving t)
2196 (set-buffer gnus-article-current-summary)
2197 (funcall gnus-default-article-saver filename)))))
2199 (defun gnus-read-save-file-name (prompt &optional filename
2200 function group headers variable)
2202 (funcall function group headers (symbol-value variable)))
2207 ((eq filename 'default)
2213 (let* ((split-name (gnus-get-split-value gnus-split-methods))
2216 (if (and gnus-number-of-articles-to-be-saved
2217 (> gnus-number-of-articles-to-be-saved 1))
2218 (format "these %d articles"
2219 gnus-number-of-articles-to-be-saved)
2222 ;; Let the split methods have their say.
2224 ;; No split name was found.
2227 (concat prompt " (default "
2228 (file-name-nondirectory default-name) ") ")
2229 (file-name-directory default-name)
2231 ;; A single group name is returned.
2232 ((stringp split-name)
2234 (funcall function split-name headers
2235 (symbol-value variable)))
2237 (concat prompt " (default "
2238 (file-name-nondirectory default-name) ") ")
2239 (file-name-directory default-name)
2241 ;; A single split name was found
2242 ((= 1 (length split-name))
2243 (let* ((name (expand-file-name
2244 (car split-name) gnus-article-save-directory))
2245 (dir (cond ((file-directory-p name)
2246 (file-name-as-directory name))
2247 ((file-exists-p name) name)
2248 (t gnus-article-save-directory))))
2250 (concat prompt " (default " name ") ")
2252 ;; A list of splits was found.
2254 (setq split-name (nreverse split-name))
2256 (let ((file-name-history
2257 (nconc split-name file-name-history)))
2261 (concat prompt " (`M-p' for defaults) ")
2262 gnus-article-save-directory
2264 gnus-article-save-directory)))
2265 (car (push result file-name-history)))))))
2266 ;; Create the directory.
2267 (gnus-make-directory (file-name-directory file))
2268 ;; If we have read a directory, we append the default file name.
2269 (when (file-directory-p file)
2270 (setq file (concat (file-name-as-directory file)
2271 (file-name-nondirectory default-name))))
2272 ;; Possibly translate some characters.
2273 (nnheader-translate-file-chars file)))))
2274 (gnus-make-directory (file-name-directory result))
2275 (set variable result)))
2277 (defun gnus-article-archive-name (group)
2278 "Return the first instance of an \"Archive-name\" in the current buffer."
2279 (let ((case-fold-search t))
2280 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
2281 (nnheader-concat gnus-article-save-directory
2282 (match-string 1)))))
2284 (defun gnus-article-nndoc-name (group)
2285 "If GROUP is an nndoc group, return the name of the parent group."
2286 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
2287 (gnus-group-get-parameter group 'save-article-group)))
2289 (defun gnus-summary-save-in-rmail (&optional filename)
2290 "Append this article to Rmail file.
2291 Optional argument FILENAME specifies file name.
2292 Directory to save to is default to `gnus-article-save-directory'."
2293 (setq filename (gnus-read-save-file-name
2294 "Save %s in rmail file:" filename
2295 gnus-rmail-save-name gnus-newsgroup-name
2296 gnus-current-headers 'gnus-newsgroup-last-rmail))
2297 (gnus-eval-in-buffer-window gnus-save-article-buffer
2301 (gnus-output-to-rmail filename))))
2304 (defun gnus-summary-save-in-mail (&optional filename)
2305 "Append this article to Unix mail file.
2306 Optional argument FILENAME specifies file name.
2307 Directory to save to is default to `gnus-article-save-directory'."
2308 (setq filename (gnus-read-save-file-name
2309 "Save %s in Unix mail file:" filename
2310 gnus-mail-save-name gnus-newsgroup-name
2311 gnus-current-headers 'gnus-newsgroup-last-mail))
2312 (gnus-eval-in-buffer-window gnus-save-article-buffer
2316 (if (and (file-readable-p filename)
2317 (mail-file-babyl-p filename))
2318 (rmail-output-to-rmail-file filename t)
2319 (gnus-output-to-mail filename)))))
2322 (defun gnus-summary-save-in-file (&optional filename overwrite)
2323 "Append this article to file.
2324 Optional argument FILENAME specifies file name.
2325 Directory to save to is default to `gnus-article-save-directory'."
2326 (setq filename (gnus-read-save-file-name
2327 "Save %s in file:" filename
2328 gnus-file-save-name gnus-newsgroup-name
2329 gnus-current-headers 'gnus-newsgroup-last-file))
2330 (gnus-eval-in-buffer-window gnus-save-article-buffer
2334 (when (and overwrite
2335 (file-exists-p filename))
2336 (delete-file filename))
2337 (gnus-output-to-file filename))))
2340 (defun gnus-summary-write-to-file (&optional filename)
2341 "Write this article to a file.
2342 Optional argument FILENAME specifies file name.
2343 The directory to save in defaults to `gnus-article-save-directory'."
2344 (gnus-summary-save-in-file nil t))
2346 (defun gnus-summary-save-body-in-file (&optional filename)
2347 "Append this article body to a file.
2348 Optional argument FILENAME specifies file name.
2349 The directory to save in defaults to `gnus-article-save-directory'."
2350 (setq filename (gnus-read-save-file-name
2351 "Save %s body in file:" filename
2352 gnus-file-save-name gnus-newsgroup-name
2353 gnus-current-headers 'gnus-newsgroup-last-file))
2354 (gnus-eval-in-buffer-window gnus-save-article-buffer
2358 (when (article-goto-body)
2359 (narrow-to-region (point) (point-max)))
2360 (gnus-output-to-file filename))))
2363 (defun gnus-summary-save-in-pipe (&optional command)
2364 "Pipe this article to subprocess."
2366 (cond ((and (eq command 'default)
2367 gnus-last-shell-command)
2368 gnus-last-shell-command)
2372 "Shell command on %s: "
2373 (if (and gnus-number-of-articles-to-be-saved
2374 (> gnus-number-of-articles-to-be-saved 1))
2375 (format "these %d articles"
2376 gnus-number-of-articles-to-be-saved)
2378 gnus-last-shell-command))))
2379 (when (string-equal command "")
2380 (setq command gnus-last-shell-command))
2381 (gnus-eval-in-buffer-window gnus-article-buffer
2384 (shell-command-on-region (point-min) (point-max) command nil)))
2385 (setq gnus-last-shell-command command))
2387 ;;; Article file names when saving.
2389 (defun gnus-capitalize-newsgroup (newsgroup)
2390 "Capitalize NEWSGROUP name."
2391 (when (not (zerop (length newsgroup)))
2392 (concat (char-to-string (upcase (aref newsgroup 0)))
2393 (substring newsgroup 1))))
2395 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2396 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2397 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
2398 Otherwise, it is like ~/News/news/group/num."
2401 (concat (if (gnus-use-long-file-name 'not-save)
2402 (gnus-capitalize-newsgroup newsgroup)
2403 (gnus-newsgroup-directory-form newsgroup))
2404 "/" (int-to-string (mail-header-number headers)))
2405 gnus-article-save-directory)))
2407 (string-equal (file-name-directory default)
2408 (file-name-directory last-file))
2409 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2411 (or last-file default))))
2413 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2414 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2415 If variable `gnus-use-long-file-name' is non-nil, it is
2416 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2419 (concat (if (gnus-use-long-file-name 'not-save)
2421 (gnus-newsgroup-directory-form newsgroup))
2422 "/" (int-to-string (mail-header-number headers)))
2423 gnus-article-save-directory)))
2425 (string-equal (file-name-directory default)
2426 (file-name-directory last-file))
2427 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2429 (or last-file default))))
2431 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
2432 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2433 If variable `gnus-use-long-file-name' is non-nil, it is
2434 ~/News/News.group. Otherwise, it is like ~/News/news/group/news."
2437 (if (gnus-use-long-file-name 'not-save)
2438 (gnus-capitalize-newsgroup newsgroup)
2439 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2440 gnus-article-save-directory)))
2442 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2443 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2444 If variable `gnus-use-long-file-name' is non-nil, it is
2445 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2448 (if (gnus-use-long-file-name 'not-save)
2450 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2451 gnus-article-save-directory)))
2458 (setq afunc (car func)
2461 gfunc (intern (format "gnus-%s" func))))
2463 (if (not (fboundp afunc))
2465 `(lambda (&optional interactive &rest args)
2466 ,(documentation afunc t)
2467 (interactive (list t))
2469 (set-buffer gnus-article-buffer)
2471 (call-interactively ',afunc)
2472 (apply ',afunc args))))))))
2473 '(article-hide-headers
2474 article-hide-boring-headers
2475 article-toggle-headers
2476 article-treat-overstrike
2477 article-fill-long-lines
2478 article-capitalize-sentences
2480 article-display-x-face
2481 article-de-quoted-unreadable
2483 article-strip-banner
2486 article-hide-signature
2487 article-strip-headers-in-body
2488 article-remove-trailing-blank-lines
2489 article-strip-leading-blank-lines
2490 article-strip-multiple-blank-lines
2491 article-strip-leading-space
2492 article-strip-trailing-space
2493 article-strip-blank-lines
2494 article-strip-all-blank-lines
2496 article-date-iso8601
2497 article-date-original
2499 article-decode-mime-words
2500 article-decode-charset
2501 article-decode-encoded-words
2505 article-treat-dumbquotes
2506 article-normalize-headers
2507 (article-show-all . gnus-article-show-all-headers))))
2510 ;;; Gnus article mode
2513 (put 'gnus-article-mode 'mode-class 'special)
2515 (gnus-define-keys gnus-article-mode-map
2516 " " gnus-article-goto-next-page
2517 "\177" gnus-article-goto-prev-page
2518 [delete] gnus-article-goto-prev-page
2519 [backspace] gnus-article-goto-prev-page
2520 "\C-c^" gnus-article-refer-article
2521 "h" gnus-article-show-summary
2522 "s" gnus-article-show-summary
2523 "\C-c\C-m" gnus-article-mail
2524 "?" gnus-article-describe-briefly
2525 gnus-mouse-2 gnus-article-push-button
2526 "\r" gnus-article-press-button
2527 "\t" gnus-article-next-button
2528 "\M-\t" gnus-article-prev-button
2529 "e" gnus-article-edit
2530 "<" beginning-of-buffer
2532 "\C-c\C-i" gnus-info-find-node
2535 "\C-d" gnus-article-read-summary-keys
2536 "\M-*" gnus-article-read-summary-keys
2537 "\M-#" gnus-article-read-summary-keys
2538 "\M-^" gnus-article-read-summary-keys
2539 "\M-g" gnus-article-read-summary-keys)
2541 ;; Define almost undefined keys to `gnus-article-read-summary-keys'.
2544 (unless (lookup-key gnus-article-mode-map key)
2545 (define-key gnus-article-mode-map key
2546 'gnus-article-read-summary-keys)))
2551 (let ((key (car elt)))
2552 (and (> (length key) 0)
2553 (not (eq 'menu-bar (aref key 0)))
2554 (symbolp (lookup-key gnus-summary-mode-map key))
2556 (accessible-keymaps gnus-summary-mode-map))
2560 (push (char-to-string c) keys)
2564 (defun gnus-article-make-menu-bar ()
2565 (gnus-turn-off-edit-menu 'article)
2566 (unless (boundp 'gnus-article-article-menu)
2568 gnus-article-article-menu gnus-article-mode-map ""
2570 ["Scroll forwards" gnus-article-goto-next-page t]
2571 ["Scroll backwards" gnus-article-goto-prev-page t]
2572 ["Show summary" gnus-article-show-summary t]
2573 ["Fetch Message-ID at point" gnus-article-refer-article t]
2574 ["Mail to address at point" gnus-article-mail t]
2575 ["Send a bug report" gnus-bug t]))
2578 gnus-article-treatment-menu gnus-article-mode-map ""
2580 ["Hide headers" gnus-article-toggle-headers t]
2581 ["Hide signature" gnus-article-hide-signature t]
2582 ["Hide citation" gnus-article-hide-citation t]
2583 ["Treat overstrike" gnus-article-treat-overstrike t]
2584 ["Remove carriage return" gnus-article-remove-cr t]))
2586 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
2588 (when (boundp 'gnus-summary-post-menu)
2589 (define-key gnus-article-mode-map [menu-bar post]
2590 (cons "Post" gnus-summary-post-menu)))
2592 (gnus-run-hooks 'gnus-article-menu-hook)))
2594 (defun gnus-article-mode ()
2595 "Major mode for displaying an article.
2597 All normal editing commands are switched off.
2599 The following commands are available in addition to all summary mode
2601 \\<gnus-article-mode-map>
2602 \\[gnus-article-next-page]\t Scroll the article one page forwards
2603 \\[gnus-article-prev-page]\t Scroll the article one page backwards
2604 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
2605 \\[gnus-article-show-summary]\t Display the summary buffer
2606 \\[gnus-article-mail]\t Send a reply to the address near point
2607 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
2608 \\[gnus-info-find-node]\t Go to the Gnus info node"
2610 (when (gnus-visual-p 'article-menu 'menu)
2611 (gnus-article-make-menu-bar))
2612 (gnus-simplify-mode-line)
2613 (setq mode-name "Article")
2614 (setq major-mode 'gnus-article-mode)
2615 (make-local-variable 'minor-mode-alist)
2616 (unless (assq 'gnus-show-mime minor-mode-alist)
2617 (push (list 'gnus-show-mime " MIME") minor-mode-alist))
2618 (use-local-map gnus-article-mode-map)
2619 (gnus-update-format-specifications nil 'article-mode)
2620 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
2621 (make-local-variable 'gnus-page-broken)
2622 (make-local-variable 'gnus-button-marker-list)
2623 (make-local-variable 'gnus-article-current-summary)
2624 (make-local-variable 'gnus-article-mime-handles)
2625 (make-local-variable 'gnus-article-decoded-p)
2626 (make-local-variable 'gnus-article-mime-handle-alist)
2627 (make-local-variable 'gnus-article-washed-types)
2628 (gnus-set-default-directory)
2629 (buffer-disable-undo)
2630 (setq buffer-read-only t)
2631 (set-syntax-table gnus-article-mode-syntax-table)
2632 (gnus-run-hooks 'gnus-article-mode-hook))
2634 (defun gnus-article-setup-buffer ()
2635 "Initialize the article buffer."
2636 (let* ((name (if gnus-single-article-buffer "*Article*"
2637 (concat "*Article " gnus-newsgroup-name "*")))
2639 (progn (string-match "\\*Article" name)
2640 (concat " *Original Article"
2641 (substring name (match-end 0))))))
2642 (setq gnus-article-buffer name)
2643 (setq gnus-original-article-buffer original)
2644 (setq gnus-article-mime-handle-alist nil)
2645 ;; This might be a variable local to the summary buffer.
2646 (unless gnus-single-article-buffer
2648 (set-buffer gnus-summary-buffer)
2649 (setq gnus-article-buffer name)
2650 (setq gnus-original-article-buffer original)
2651 (gnus-set-global-variables)))
2652 ;; Init original article buffer.
2654 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
2655 (setq major-mode 'gnus-original-article-mode)
2656 (make-local-variable 'gnus-original-article))
2657 (if (get-buffer name)
2660 (buffer-disable-undo)
2661 (setq buffer-read-only t)
2662 (unless (eq major-mode 'gnus-article-mode)
2663 (gnus-article-mode))
2666 (set-buffer (gnus-get-buffer-create name))
2668 (make-local-variable 'gnus-summary-buffer)
2669 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2670 (current-buffer)))))
2672 ;; Set article window start at LINE, where LINE is the number of lines
2673 ;; from the head of the article.
2674 (defun gnus-article-set-window-start (&optional line)
2676 (get-buffer-window gnus-article-buffer t)
2678 (set-buffer gnus-article-buffer)
2679 (goto-char (point-min))
2682 (gnus-message 6 "Moved to bookmark")
2683 (search-forward "\n\n" nil t)
2687 ;;; @@ article filters
2690 (defun gnus-article-display-mime-message ()
2691 "Article display method for MIME message."
2692 ;; called from `gnus-original-article-buffer'.
2693 (let (charset all-headers)
2694 (with-current-buffer gnus-summary-buffer
2695 (setq charset default-mime-charset
2696 all-headers gnus-have-all-headers))
2697 (make-local-variable 'default-mime-charset)
2698 (setq default-mime-charset charset)
2699 (with-current-buffer (get-buffer-create gnus-article-buffer)
2700 (make-local-variable 'default-mime-charset)
2701 (setq default-mime-charset charset))
2702 (mime-display-message mime-message-structure
2703 gnus-article-buffer nil gnus-article-mode-map)
2705 (gnus-article-hide-headers nil -1))
2707 ;; `mime-display-message' changes current buffer to `gnus-article-buffer'.
2708 (make-local-variable 'mime-button-mother-dispatcher)
2709 (setq mime-button-mother-dispatcher
2710 (function gnus-article-push-button))
2711 (run-hooks 'gnus-mime-article-prepare-hook))
2713 (defun gnus-article-display-traditional-message ()
2714 "Article display method for traditional message."
2715 (set-buffer gnus-article-buffer)
2716 (let (buffer-read-only)
2718 (insert-buffer-substring gnus-original-article-buffer)))
2720 (defun gnus-article-make-full-mail-header (&optional number charset)
2721 "Create a new mail header structure in a raw article buffer."
2722 (unless (and number charset)
2723 (save-current-buffer
2724 (set-buffer gnus-summary-buffer)
2726 (setq number (or (cdr gnus-article-current) 0)))
2728 (setq charset (or default-mime-charset 'x-ctext)))))
2729 (goto-char (point-min))
2730 (let ((header-end (if (search-forward "\n\n" nil t)
2732 (goto-char (point-max))))
2733 (chars (- (point-max) (point)))
2734 (lines (count-lines (point) (point-max)))
2735 (default-mime-charset charset)
2737 (narrow-to-region (point-min) header-end)
2738 (setq xref (std11-fetch-field "xref"))
2740 (make-full-mail-header
2742 (std11-fetch-field "subject")
2743 (std11-fetch-field "from")
2744 (std11-fetch-field "date")
2745 (std11-fetch-field "message-id")
2746 (std11-fetch-field "references")
2749 (when xref (concat "Xref: " xref)))
2752 (defun gnus-article-prepare (article &optional all-headers header)
2753 "Prepare ARTICLE in article mode buffer.
2754 ARTICLE should either be an article number or a Message-ID.
2755 If ARTICLE is an id, HEADER should be the article headers.
2756 If ALL-HEADERS is non-nil, no headers are hidden."
2758 ;; Make sure we start in a summary buffer.
2759 (unless (eq major-mode 'gnus-summary-mode)
2760 (set-buffer gnus-summary-buffer))
2761 (setq gnus-summary-buffer (current-buffer))
2762 (let* ((gnus-article (if header (mail-header-number header) article))
2763 (summary-buffer (current-buffer))
2764 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
2765 (group gnus-newsgroup-name)
2768 (gnus-article-setup-buffer)
2769 (set-buffer gnus-original-article-buffer)
2770 ;; Deactivate active regions.
2771 (when (and (boundp 'transient-mark-mode)
2772 transient-mark-mode)
2773 (setq mark-active nil))
2774 (if (not (setq result (let ((buffer-read-only nil))
2775 (gnus-request-article-this-buffer
2777 ;; There is no such article.
2779 (when (and (numberp article)
2780 (not (memq article gnus-newsgroup-sparse)))
2781 (setq gnus-article-current
2782 (cons gnus-newsgroup-name article))
2783 (set-buffer gnus-summary-buffer)
2784 (setq gnus-current-article article)
2785 (if (eq (gnus-article-mark article) gnus-undownloaded-mark)
2787 (gnus-summary-set-agent-mark article)
2788 (message "Message marked for downloading"))
2789 (gnus-summary-mark-article article gnus-canceled-mark)
2790 (unless (memq article gnus-newsgroup-sparse)
2792 "No such article (may have expired or been canceled)")))))
2793 (if (or (eq result 'pseudo)
2794 (eq result 'nneething))
2797 (set-buffer summary-buffer)
2798 (push article gnus-newsgroup-history)
2799 (setq gnus-last-article gnus-current-article
2800 gnus-current-article 0
2801 gnus-current-headers nil
2802 gnus-article-current nil)
2803 (if (eq result 'nneething)
2804 (gnus-configure-windows 'summary)
2805 (gnus-configure-windows 'article))
2806 (gnus-set-global-variables))
2807 (let ((gnus-article-mime-handle-alist-1
2808 gnus-article-mime-handle-alist))
2809 (gnus-set-mode-line 'article)))
2810 ;; The result from the `request' was an actual article -
2811 ;; or at least some text that is now displayed in the
2813 (when (and (numberp article)
2814 (not (eq article gnus-current-article)))
2815 ;; Seems like a new article has been selected.
2816 ;; `gnus-current-article' must be an article number.
2818 (set-buffer summary-buffer)
2819 (push article gnus-newsgroup-history)
2820 (setq gnus-last-article gnus-current-article
2821 gnus-current-article article
2822 gnus-current-headers
2823 (gnus-summary-article-header gnus-current-article)
2824 gnus-article-current
2825 (cons gnus-newsgroup-name gnus-current-article))
2826 (unless (vectorp gnus-current-headers)
2827 (setq gnus-current-headers nil))
2828 (gnus-summary-goto-subject gnus-current-article)
2829 (when (gnus-summary-show-thread)
2830 ;; If the summary buffer really was folded, the
2831 ;; previous goto may not actually have gone to
2832 ;; the right article, but the thread root instead.
2834 (gnus-summary-goto-subject gnus-current-article))
2835 (gnus-run-hooks 'gnus-mark-article-hook)
2836 (gnus-set-mode-line 'summary)
2837 (when (gnus-visual-p 'article-highlight 'highlight)
2838 (gnus-run-hooks 'gnus-visual-mark-article-hook))
2839 ;; Set the global newsgroup variables here.
2840 (gnus-set-global-variables)
2841 (setq gnus-have-all-headers
2842 (or all-headers gnus-show-all-headers))))
2843 (when (or (numberp article)
2845 (gnus-article-prepare-display)
2847 (goto-char (point-min))
2848 (setq gnus-page-broken
2849 (when gnus-break-pages
2850 (gnus-narrow-to-page)
2852 (let ((gnus-article-mime-handle-alist-1
2853 gnus-article-mime-handle-alist))
2854 (gnus-set-mode-line 'article))
2856 (set-window-point (get-buffer-window (current-buffer)) (point))
2857 (gnus-configure-windows 'article)
2860 (defun gnus-article-prepare-mime-display (&optional number)
2861 (goto-char (point-min))
2862 (when (re-search-forward "^[^\t ]+:" nil t)
2863 (goto-char (match-beginning 0)))
2864 (let* ((entity (if (eq 1 (point-min))
2865 (get-text-property 1 'mime-view-entity)
2866 (get-text-property (point) 'mime-view-entity)))
2867 (number (or number 0))
2870 (narrow-to-region (point)
2871 (if (search-forward "\n\n" nil t)
2874 (gnus-treat-article 'head)
2875 (put-text-property (point-min) (point-max) 'article-treated-header t)
2876 (goto-char (point-max)))
2877 (while (and (not (eobp))
2879 (setq next (next-single-property-change (point)
2880 'mime-view-entity)))
2881 (setq type (mime-entity-content-type entity)
2882 type (format "%s/%s"
2883 (mime-content-type-primary-type type)
2884 (mime-content-type-subtype type)))
2885 (if (string-equal type "message/rfc822")
2887 (narrow-to-region (point) (point-max))
2888 (gnus-article-prepare-mime-display number)
2889 (goto-char (point-max)))
2890 (setq ids (length (mime-entity-node-id entity))
2891 entity (get-text-property next 'mime-view-entity)
2894 (narrow-to-region (point) next)
2895 (if (or (null entity)
2896 (< (length (mime-entity-node-id entity)) ids))
2897 (gnus-treat-article 'last number number type)
2898 (gnus-treat-article t number nil type))
2899 (goto-char (point-max)))))
2902 (narrow-to-region (point) (point-max))
2905 (setq type (mime-entity-content-type entity)
2906 type (format "%s/%s"
2907 (mime-content-type-primary-type type)
2908 (mime-content-type-subtype type)))
2909 (if (string-equal type "message/rfc822")
2910 (gnus-article-prepare-mime-display number)
2912 (gnus-treat-article 'last number number type)))
2913 (gnus-treat-article t))))))
2916 (defun gnus-article-prepare-display ()
2917 "Make the current buffer look like a nice article."
2918 (gnus-run-hooks 'gnus-tmp-internal-hook)
2919 (gnus-run-hooks 'gnus-article-prepare-hook)
2921 (let (mime-display-header-hook)
2922 (funcall (if gnus-show-mime
2924 (setq mime-message-structure gnus-current-headers)
2925 gnus-article-display-method-for-mime)
2926 gnus-article-display-method-for-traditional)))
2927 ;; Associate this article with the current summary buffer.
2928 (setq gnus-article-current-summary gnus-summary-buffer)
2929 ;; Call the treatment functions.
2930 (let ((inhibit-read-only t)
2935 (gnus-article-prepare-mime-display)
2936 (narrow-to-region (goto-char (point-min))
2937 (if (search-forward "\n\n" nil t)
2940 (gnus-treat-article 'head)
2941 (put-text-property (point-min) (point-max) 'article-treated-header t)
2942 (goto-char (point-max))
2944 (narrow-to-region (point) (point-max))
2945 (gnus-treat-article t))
2946 (put-text-property (point-min) (point-max) 'read-only nil)))
2947 ;; Perform the article display hooks. Incidentally, this hook is
2948 ;; an obsolete variable by now.
2949 (gnus-run-hooks 'gnus-article-display-hook))
2951 (defun gnus-article-decode-article-as-default-mime-charset ()
2952 "Decode an article as `default-mime-charset'. It won't work if the
2953 value of the variable `gnus-show-mime' is non-nil."
2954 (unless gnus-show-mime
2955 (decode-mime-charset-region (point-min) (point-max)
2956 (with-current-buffer gnus-summary-buffer
2957 default-mime-charset))))
2959 ;; The following procedures will be abolished in the future.
2960 (autoload 'x-face-mule-x-face-decode-message-header "x-face-mule")
2961 (defvar x-face-mule-version-number)
2962 (defun gnus-article-display-x-face-with-x-face-mule (&rest args)
2963 "Decode and show X-Face with the function
2964 `x-face-mule-x-face-decode-message-header'. The buffer is expected to be
2965 narrowed to just the headers of the article."
2966 (when (featurep 'xemacs)
2967 (error "`%s' won't work under XEmacs."
2968 'gnus-article-display-x-face-with-x-face-mule))
2970 (when (and (boundp 'x-face-mule-version-number)
2971 (> (string-to-number x-face-mule-version-number) 0.24)
2972 (not (gnus-buffer-live-p "*X-Face-Mule WARNING*")))
2973 (let ((buffer (generate-new-buffer "*X-Face-Mule WARNING*")))
2974 (save-window-excursion
2975 (pop-to-buffer buffer)
2978 `%s' is an obsolete function.
2979 You have no use for setting the variable `%s',
2980 however, it will be set suitably by X-Face-Mule %s.
2982 'gnus-article-display-x-face-with-x-face-mule
2983 'gnus-article-x-face-command
2984 x-face-mule-version-number))
2985 (let ((inhibit-quit t) (echo-keystrokes 0) cursor-in-echo-area)
2986 (read-char-exclusive))
2988 (delete-region (point) (point-max)))))
2990 (x-face-mule-x-face-decode-message-header)
2992 (if (featurep 'x-face-mule)
2993 "Please install x-face-mule 0.25 or later."
2997 ;;; Gnus MIME viewing functions
3000 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3001 "The following specs can be used:
3003 %T MIME type, along with additional info
3004 %n The `name' parameter
3005 %d The description, if any
3006 %l The length of the encoded part
3007 %p The part identifier number
3008 %e Dots if the part isn't displayed")
3010 (defvar gnus-mime-button-line-format-alist
3011 '((?t gnus-tmp-type ?s)
3012 (?T gnus-tmp-type-long ?s)
3013 (?n gnus-tmp-name ?s)
3014 (?d gnus-tmp-description ?s)
3016 (?l gnus-tmp-length ?d)
3017 (?e gnus-tmp-dots ?s)))
3019 (defvar gnus-mime-button-commands
3020 '((gnus-article-press-button "\r" "Toggle Display")
3021 (gnus-mime-view-part "v" "View Interactively...")
3022 (gnus-mime-save-part "o" "Save...")
3023 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
3024 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
3025 (gnus-mime-internalize-part "E" "View Internally")
3026 (gnus-mime-externalize-part "e" "View Externally")
3027 (gnus-mime-pipe-part "|" "Pipe To Command...")))
3029 (defun gnus-article-mime-part-status ()
3030 (if gnus-article-mime-handle-alist-1
3031 (format " (%d parts)" (length gnus-article-mime-handle-alist-1))
3034 (defvar gnus-mime-button-map nil)
3035 (unless gnus-mime-button-map
3036 (setq gnus-mime-button-map (make-sparse-keymap))
3037 (set-keymap-parent gnus-mime-button-map gnus-article-mode-map)
3038 (define-key gnus-mime-button-map gnus-mouse-2 'gnus-article-push-button)
3039 (define-key gnus-mime-button-map gnus-down-mouse-3 'gnus-mime-button-menu)
3041 (define-key gnus-mime-button-map (cadr c) (car c)))
3042 gnus-mime-button-commands))
3044 (defun gnus-mime-button-menu (event)
3045 "Construct a context-sensitive menu of MIME commands."
3048 (let ((pos (event-start event)))
3049 (set-buffer (window-buffer (posn-window pos)))
3050 (goto-char (posn-point pos))
3051 (gnus-article-check-buffer)
3052 (let ((response (x-popup-menu
3054 ("" ,@(mapcar (lambda (c)
3055 (cons (caddr c) (car c)))
3056 gnus-mime-button-commands))))))
3058 (funcall response))))))
3060 (defun gnus-mime-view-all-parts (&optional handles)
3061 "View all the MIME parts."
3063 (save-current-buffer
3064 (set-buffer gnus-article-buffer)
3065 (let ((handles (or handles gnus-article-mime-handles))
3066 (mail-parse-charset gnus-newsgroup-charset))
3067 (if (stringp (car handles))
3068 (gnus-mime-view-all-parts (cdr handles))
3069 (mapcar 'mm-display-part handles)))))
3071 (defun gnus-mime-save-part ()
3072 "Save the MIME part under point."
3074 (gnus-article-check-buffer)
3075 (let ((data (get-text-property (point) 'gnus-data)))
3076 (mm-save-part data)))
3078 (defun gnus-mime-pipe-part ()
3079 "Pipe the MIME part under point to a process."
3081 (gnus-article-check-buffer)
3082 (let ((data (get-text-property (point) 'gnus-data)))
3083 (mm-pipe-part data)))
3085 (defun gnus-mime-view-part ()
3086 "Interactively choose a view method for the MIME part under point."
3088 (gnus-article-check-buffer)
3089 (let ((data (get-text-property (point) 'gnus-data)))
3090 (mm-interactively-view-part data)))
3092 (defun gnus-mime-copy-part (&optional handle)
3093 "Put the the MIME part under point into a new buffer."
3095 (gnus-article-check-buffer)
3096 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3097 (contents (mm-get-part handle))|
3098 (base (file-name-nondirectory
3100 (mail-content-type-get (mm-handle-type handle) 'name)
3101 (mail-content-type-get (mm-handle-type handle)
3104 (buffer (generate-new-buffer base)))
3105 (switch-to-buffer buffer)
3107 ;; We do it this way to make `normal-mode' set the appropriate mode.
3110 (setq buffer-file-name (expand-file-name base))
3112 (setq buffer-file-name nil))
3113 (goto-char (point-min))))
3115 (defun gnus-mime-inline-part (&optional handle)
3116 "Insert the MIME part under point into the current buffer."
3118 (gnus-article-check-buffer)
3119 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3123 (if (mm-handle-undisplayer handle)
3124 (mm-remove-part handle)
3125 (setq contents (mm-get-part handle))
3127 (mm-insert-inline handle contents)
3130 (defun gnus-mime-externalize-part (&optional handle)
3131 "View the MIME part under point with an external viewer."
3133 (gnus-article-check-buffer)
3134 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3135 (mm-user-display-methods nil)
3136 (mm-all-images-fit t)
3137 (mail-parse-charset gnus-newsgroup-charset))
3138 (if (mm-handle-undisplayer handle)
3139 (mm-remove-part handle)
3140 (mm-display-part handle))))
3142 (defun gnus-mime-internalize-part (&optional handle)
3143 "View the MIME part under point with an internal viewer."
3145 (gnus-article-check-buffer)
3146 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3147 (mm-user-display-methods '((".*" . inline)))
3148 (mm-all-images-fit t)
3149 (mail-parse-charset gnus-newsgroup-charset))
3150 (if (mm-handle-undisplayer handle)
3151 (mm-remove-part handle)
3152 (mm-display-part handle))))
3154 (defun gnus-article-part-wrapper (n function)
3155 (save-current-buffer
3156 (set-buffer gnus-article-buffer)
3157 (when (> n (length gnus-article-mime-handle-alist))
3158 (error "No such part"))
3159 (gnus-article-goto-part n)
3160 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
3161 (funcall function handle))))
3163 (defun gnus-article-pipe-part (n)
3164 "Pipe MIME part N, which is the numerical prefix."
3166 (gnus-article-part-wrapper n 'mm-pipe-part))
3168 (defun gnus-article-save-part (n)
3169 "Save MIME part N, which is the numerical prefix."
3171 (gnus-article-part-wrapper n 'mm-save-part))
3173 (defun gnus-article-interactively-view-part (n)
3174 "View MIME part N interactively, which is the numerical prefix."
3176 (gnus-article-part-wrapper n 'mm-interactively-view-part))
3178 (defun gnus-article-copy-part (n)
3179 "Copy MIME part N, which is the numerical prefix."
3181 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
3183 (defun gnus-article-externalize-part (n)
3184 "View MIME part N externally, which is the numerical prefix."
3186 (gnus-article-part-wrapper n 'gnus-mime-externalize-part))
3188 (defun gnus-article-inline-part (n)
3189 "Inline MIME part N, which is the numerical prefix."
3191 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
3193 (defun gnus-article-view-part (n)
3194 "View MIME part N, which is the numerical prefix."
3196 (save-current-buffer
3197 (set-buffer gnus-article-buffer)
3198 (when (> n (length gnus-article-mime-handle-alist))
3199 (error "No such part"))
3200 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
3201 (when (gnus-article-goto-part n)
3202 (if (equal (car handle) "multipart/alternative")
3203 (gnus-article-press-button)
3204 (when (eq (gnus-mm-display-part handle) 'internal)
3205 (gnus-set-window-start)))))))
3207 (defun gnus-mm-display-part (handle)
3208 "Display HANDLE and fix MIME button."
3209 (let ((id (get-text-property (point) 'gnus-part))
3214 (let ((window (selected-window))
3215 (mail-parse-charset gnus-newsgroup-charset))
3218 (let ((win (get-buffer-window (current-buffer) t))
3221 (select-window win))
3224 (if (mm-handle-displayed-p handle)
3225 ;; This will remove the part.
3226 (mm-display-part handle)
3228 (narrow-to-region (point) (1+ (point)))
3229 (mm-display-part handle)
3230 ;; We narrow to the part itself and
3231 ;; then call the treatment functions.
3232 (goto-char (point-min))
3234 (narrow-to-region (point) (point-max))
3237 (1- (length gnus-article-mime-handles))
3238 (car (mm-handle-type handle))))))
3239 (select-window window))))
3241 (delete-region (gnus-point-at-bol) (progn (forward-line 1) (point)))
3242 (gnus-insert-mime-button
3243 handle id (list (mm-handle-displayed-p handle)))
3244 (goto-char point))))
3246 (defun gnus-article-goto-part (n)
3247 "Go to MIME part N."
3248 (let ((point (text-property-any (point-min) (point-max) 'gnus-part n)))
3250 (goto-char point))))
3252 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
3253 (let ((gnus-tmp-name
3254 (or (mail-content-type-get (mm-handle-type handle)
3256 (mail-content-type-get (mm-handle-disposition handle)
3259 (gnus-tmp-type (car (mm-handle-type handle)))
3260 (gnus-tmp-description
3261 (mail-decode-encoded-word-string (or (mm-handle-description handle)
3264 (if (if displayed (car displayed)
3265 (mm-handle-displayed-p handle))
3267 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
3269 gnus-tmp-type-long b e)
3270 (when (string-match ".*/" gnus-tmp-name)
3271 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
3272 (setq gnus-tmp-type-long (concat gnus-tmp-type
3273 (and (not (equal gnus-tmp-name ""))
3274 (concat "; " gnus-tmp-name))))
3275 (or (equal gnus-tmp-description "")
3276 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
3281 gnus-mime-button-line-format gnus-mime-button-line-format-alist
3282 `(local-map ,gnus-mime-button-map
3283 keymap ,gnus-mime-button-map
3284 gnus-callback gnus-mm-display-part
3285 gnus-part ,gnus-tmp-id
3286 article-type annotation
3289 (widget-convert-button 'link b e
3291 :action 'gnus-widget-press-button
3292 :button-keymap gnus-mime-button-map
3295 ;; Needed to properly clear the message
3296 ;; due to a bug in wid-edit
3297 (setq help-echo-owns-message t)
3299 "Click to %s the MIME part; %s for more options"
3300 (if (mm-handle-displayed-p
3301 (widget-get widget :mime-handle))
3303 (if gnus-xemacs "button3" "mouse-3"))))))
3305 (defun gnus-widget-press-button (elems el)
3306 (goto-char (widget-get elems :from))
3307 (gnus-article-press-button))
3309 (defvar gnus-displaying-mime nil)
3311 (defun gnus-display-mime (&optional ihandles)
3312 "Display the MIME parts."
3314 (save-selected-window
3315 (let ((window (get-buffer-window gnus-article-buffer))
3318 (select-window window)
3319 ;; We have to do this since selecting the window
3320 ;; may change the point. So we set the window point.
3321 (set-window-point window point)))
3322 (let* ((handles (or ihandles (mm-dissect-buffer) (mm-uu-dissect)))
3323 buffer-read-only handle name type b e display)
3324 (when (and (not ihandles)
3325 (not gnus-displaying-mime))
3326 ;; Top-level call; we clean up.
3327 (mm-destroy-parts gnus-article-mime-handles)
3328 (setq gnus-article-mime-handles handles
3329 gnus-article-mime-handle-alist nil)
3330 ;; We allow users to glean info from the handles.
3331 (when gnus-article-mime-part-function
3332 (gnus-mime-part-function handles)))
3334 (or (not (stringp (car handles)))
3337 (when (and (not ihandles)
3338 (not gnus-displaying-mime))
3339 ;; Clean up for mime parts.
3341 (delete-region (point) (point-max)))
3342 (let ((gnus-displaying-mime t))
3343 (gnus-mime-display-part handles)))
3346 (narrow-to-region (point) (point-max))
3347 (gnus-treat-article nil 1 1)
3349 ;; Highlight the headers.
3353 (narrow-to-region (point-min) (point))
3354 (gnus-treat-article 'head)))))))
3356 (defvar gnus-mime-display-multipart-as-mixed nil)
3358 (defun gnus-mime-display-part (handle)
3361 ((not (stringp (car handle)))
3362 (gnus-mime-display-single handle))
3363 ;; User-defined multipart
3364 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
3365 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
3367 ;; multipart/alternative
3368 ((and (equal (car handle) "multipart/alternative")
3369 (not gnus-mime-display-multipart-as-mixed))
3370 (let ((id (1+ (length gnus-article-mime-handle-alist))))
3371 (push (cons id handle) gnus-article-mime-handle-alist)
3372 (gnus-mime-display-alternative (cdr handle) nil nil id)))
3373 ;; multipart/related
3374 ((and (equal (car handle) "multipart/related")
3375 (not gnus-mime-display-multipart-as-mixed))
3376 ;;;!!!We should find the start part, but we just default
3377 ;;;!!!to the first part.
3378 (gnus-mime-display-part (cadr handle)))
3379 ;; Other multiparts are handled like multipart/mixed.
3381 (gnus-mime-display-mixed (cdr handle)))))
3383 (defun gnus-mime-part-function (handles)
3384 (if (stringp (car handles))
3385 (mapcar 'gnus-mime-part-function (cdr handles))
3386 (funcall gnus-article-mime-part-function handles)))
3388 (defun gnus-mime-display-mixed (handles)
3389 (mapcar 'gnus-mime-display-part handles))
3391 (defun gnus-mime-display-single (handle)
3392 (let ((type (car (mm-handle-type handle)))
3393 (ignored gnus-ignored-mime-types)
3400 (when (string-match (pop ignored) type)
3401 (throw 'ignored nil)))
3402 (if (and (setq not-attachment
3403 (or (not (mm-handle-disposition handle))
3404 (equal (car (mm-handle-disposition handle))
3406 (mm-attachment-override-p type)))
3407 (mm-automatic-display-p type)
3408 (or (mm-inlinable-part-p type)
3409 (mm-automatic-external-display-p type)))
3411 (when (equal (car (split-string type "/"))
3414 (let ((id (1+ (length gnus-article-mime-handle-alist))))
3415 (push (cons id handle) gnus-article-mime-handle-alist)
3416 (when (or (not display)
3417 (not (gnus-unbuttonized-mime-type-p type)))
3418 (gnus-article-insert-newline)
3419 (gnus-insert-mime-button
3420 handle id (list (or display (and not-attachment text))))
3421 (gnus-article-insert-newline)
3422 (gnus-article-insert-newline)
3424 (let ((beg (point)))
3429 (let ((mail-parse-charset gnus-newsgroup-charset))
3430 (mm-display-part handle t))
3431 (goto-char (point-max)))
3432 ((and text not-attachment)
3435 (gnus-article-insert-newline)
3436 (mm-insert-inline handle (mm-get-part handle))
3437 (goto-char (point-max))))
3441 (narrow-to-region beg (point))
3443 nil (length gnus-article-mime-handle-alist)
3444 (1- (length gnus-article-mime-handles))
3445 (car (mm-handle-type handle))))))))))
3447 (defun gnus-unbuttonized-mime-type-p (type)
3448 "Say whether TYPE is to be unbuttonized."
3449 (unless gnus-inhibit-mime-unbuttonizing
3451 (let ((types gnus-unbuttonized-mime-types))
3453 (when (string-match (pop types) type)
3454 (throw 'found t)))))))
3456 (defun gnus-article-insert-newline ()
3457 "Insert a newline, but mark it as undeletable."
3458 (gnus-put-text-property
3459 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
3461 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
3462 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
3465 handle buffer-read-only from props begend not-pref)
3466 (save-window-excursion
3469 (narrow-to-region (car ibegend)
3472 (goto-char (car ibegend))
3475 (delete-region (point-min) (point-max))
3476 (mm-remove-parts handles))
3477 (setq begend (list (point-marker)))
3479 (unless (setq not-pref (cadr (member preferred ihandles)))
3480 (setq not-pref (car ihandles)))
3482 (not (gnus-unbuttonized-mime-type-p
3483 "multipart/alternative")))
3484 (gnus-add-text-properties
3487 (insert (format "%d. " id))
3491 (unless ,(not ibegend)
3492 (setq gnus-article-mime-handle-alist
3493 ',gnus-article-mime-handle-alist))
3494 (gnus-mime-display-alternative
3495 ',ihandles ',not-pref ',begend ,id))
3496 local-map ,gnus-mime-button-map
3497 ,gnus-mouse-face-prop ,gnus-article-mouse-face
3498 face ,gnus-article-button-face
3499 keymap ,gnus-mime-button-map
3502 (widget-convert-button 'link from (point)
3503 :action 'gnus-widget-press-button
3504 :button-keymap gnus-widget-button-keymap)
3506 (while (setq handle (pop handles))
3507 (gnus-add-text-properties
3510 (insert (format "(%c) %-18s"
3511 (if (equal handle preferred) ?* ? )
3512 (if (stringp (car handle))
3514 (car (mm-handle-type handle)))))
3518 (unless ,(not ibegend)
3519 (setq gnus-article-mime-handle-alist
3520 ',gnus-article-mime-handle-alist))
3521 (gnus-mime-display-alternative
3522 ',ihandles ',handle ',begend ,id))
3523 local-map ,gnus-mime-button-map
3524 ,gnus-mouse-face-prop ,gnus-article-mouse-face
3525 face ,gnus-article-button-face
3526 keymap ,gnus-mime-button-map
3529 (widget-convert-button 'link from (point)
3530 :action 'gnus-widget-press-button
3531 :button-keymap gnus-widget-button-keymap)
3535 (if (stringp (car preferred))
3536 (gnus-display-mime preferred)
3537 (let ((mail-parse-charset gnus-newsgroup-charset))
3538 (mm-display-part preferred)))
3539 (goto-char (point-max))
3540 (setcdr begend (point-marker)))))
3542 (goto-char point))))
3544 (defun gnus-article-wash-status ()
3545 "Return a string which display status of article washing."
3547 (set-buffer gnus-article-buffer)
3548 (let ((cite (gnus-article-hidden-text-p 'cite))
3549 (headers (gnus-article-hidden-text-p 'headers))
3550 (boring (gnus-article-hidden-text-p 'boring-headers))
3551 (pgp (gnus-article-hidden-text-p 'pgp))
3552 (pem (gnus-article-hidden-text-p 'pem))
3553 (signature (gnus-article-hidden-text-p 'signature))
3554 (overstrike (gnus-article-hidden-text-p 'overstrike))
3555 (emphasis (gnus-article-hidden-text-p 'emphasis))
3556 (mime gnus-show-mime))
3557 (format "%c%c%c%c%c%c%c"
3559 (if (or headers boring) ?h ? )
3560 (if (or pgp pem) ?p ? )
3561 (if signature ?s ? )
3562 (if overstrike ?o ? )
3564 (if emphasis ?e ? )))))
3566 (fset 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
3568 (defun gnus-article-maybe-hide-headers ()
3569 "Hide unwanted headers if `gnus-have-all-headers' is nil.
3570 Provided for backwards compatibility."
3571 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
3572 (not (save-excursion (set-buffer gnus-summary-buffer)
3573 gnus-have-all-headers)))
3574 (not gnus-inhibit-hiding))
3575 (gnus-article-hide-headers)))
3579 (defun gnus-output-to-file (file-name)
3580 "Append the current article to a file named FILE-NAME."
3581 (let ((artbuf (current-buffer)))
3583 (insert-buffer-substring artbuf)
3584 ;; Append newline at end of the buffer as separator, and then
3586 (goto-char (point-max))
3588 (append-to-file (point-min) (point-max) file-name)
3591 (defun gnus-narrow-to-page (&optional arg)
3592 "Narrow the article buffer to a page.
3593 If given a numerical ARG, move forward ARG pages."
3595 (setq arg (if arg (prefix-numeric-value arg) 0))
3597 (set-buffer gnus-article-buffer)
3598 (goto-char (point-min))
3600 ;; Remove any old next/prev buttons.
3601 (when (gnus-visual-p 'page-marker)
3602 (let ((buffer-read-only nil))
3603 (gnus-remove-text-with-property 'gnus-prev)
3604 (gnus-remove-text-with-property 'gnus-next)))
3607 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
3609 (re-search-forward page-delimiter nil 'move arg)))
3610 (goto-char (match-end 0)))
3613 (if (re-search-forward page-delimiter nil 'move)
3616 (when (and (gnus-visual-p 'page-marker)
3617 (not (= (point-min) 1)))
3619 (goto-char (point-min))
3620 (gnus-insert-prev-page-button)))
3621 (when (and (gnus-visual-p 'page-marker)
3622 (< (+ (point-max) 2) (buffer-size)))
3624 (goto-char (point-max))
3625 (gnus-insert-next-page-button)))))
3627 ;; Article mode commands
3629 (defun gnus-article-goto-next-page ()
3630 "Show the next page of the article."
3632 (when (gnus-article-next-page)
3633 (goto-char (point-min))
3634 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
3636 (defun gnus-article-goto-prev-page ()
3637 "Show the next page of the article."
3639 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
3640 (gnus-article-prev-page nil)))
3642 (defun gnus-article-next-page (&optional lines)
3643 "Show the next page of the current article.
3644 If end of article, return non-nil. Otherwise return nil.
3645 Argument LINES specifies lines to be scrolled up."
3647 (move-to-window-line -1)
3650 (and (pos-visible-in-window-p) ;Not continuation line.
3652 ;; Nothing in this page.
3653 (if (or (not gnus-page-broken)
3656 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
3658 (gnus-narrow-to-page 1) ;Go to next page.
3660 ;; More in this page.
3661 (let ((scroll-in-place nil))
3665 ;; Long lines may cause an end-of-buffer error.
3666 (goto-char (point-max)))))
3667 (move-to-window-line 0)
3670 (defun gnus-article-prev-page (&optional lines)
3671 "Show previous page of current article.
3672 Argument LINES specifies lines to be scrolled down."
3674 (move-to-window-line 0)
3675 (if (and gnus-page-broken
3677 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
3679 (gnus-narrow-to-page -1) ;Go to previous page.
3680 (goto-char (point-max))
3682 (let ((scroll-in-place nil))
3686 (beginning-of-buffer
3687 (goto-char (point-min))))
3688 (move-to-window-line 0)))))
3690 (defun gnus-article-refer-article ()
3691 "Read article specified by message-id around point."
3693 (let ((point (point)))
3694 (search-forward ">" nil t) ;Move point to end of "<....>".
3695 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
3696 (let ((message-id (match-string 1)))
3698 (set-buffer gnus-summary-buffer)
3699 (gnus-summary-refer-article message-id))
3701 (error "No references around point"))))
3703 (defun gnus-article-show-summary ()
3704 "Reconfigure windows to show summary buffer."
3706 (if (not (gnus-buffer-live-p gnus-summary-buffer))
3707 (error "There is no summary buffer for this article buffer")
3708 (gnus-article-set-globals)
3709 (gnus-configure-windows 'article)
3710 (gnus-summary-goto-subject gnus-current-article)
3711 (gnus-summary-position-point)))
3713 (defun gnus-article-describe-briefly ()
3714 "Describe article mode commands briefly."
3716 (gnus-message 6 (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")))
3718 (defun gnus-article-summary-command ()
3719 "Execute the last keystroke in the summary buffer."
3721 (let ((obuf (current-buffer))
3722 (owin (current-window-configuration))
3724 (switch-to-buffer gnus-article-current-summary 'norecord)
3725 (setq func (lookup-key (current-local-map) (this-command-keys)))
3726 (call-interactively func)
3728 (set-window-configuration owin)
3729 (set-window-point (get-buffer-window (current-buffer)) (point))))
3731 (defun gnus-article-summary-command-nosave ()
3732 "Execute the last keystroke in the summary buffer."
3735 (pop-to-buffer gnus-article-current-summary 'norecord)
3736 (setq func (lookup-key (current-local-map) (this-command-keys)))
3737 (call-interactively func)))
3739 (defun gnus-article-check-buffer ()
3740 "Beep if not in an article buffer."
3741 (unless (eq (get-buffer gnus-article-buffer) (current-buffer))
3742 (error "Command invoked outside of a Gnus article buffer")))
3744 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
3745 "Read a summary buffer key sequence and execute it from the article buffer."
3747 (gnus-article-check-buffer)
3749 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
3750 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
3751 "=" "^" "\M-^" "|"))
3757 '("n" "Gn" "p" "Gp"))
3760 (set-buffer gnus-article-current-summary)
3761 (let (gnus-pick-mode)
3762 (push (or key last-command-event) unread-command-events)
3763 (setq keys (read-key-sequence nil))))
3766 (if (or (member keys nosaves)
3767 (member keys nosave-but-article)
3768 (member keys nosave-in-article))
3770 (save-window-excursion
3771 (pop-to-buffer gnus-article-current-summary 'norecord)
3772 ;; We disable the pick minor mode commands.
3773 (let (gnus-pick-mode)
3774 (setq func (lookup-key (current-local-map) keys))))
3777 (unless (member keys nosave-in-article)
3778 (set-buffer gnus-article-current-summary))
3779 (call-interactively func)
3780 (setq new-sum-point (point)))
3781 (when (member keys nosave-but-article)
3782 (pop-to-buffer gnus-article-buffer 'norecord)))
3783 ;; These commands should restore window configuration.
3784 (let ((obuf (current-buffer))
3785 (owin (current-window-configuration))
3787 (summary gnus-article-current-summary)
3788 func in-buffer selected)
3789 (if not-restore-window
3790 (pop-to-buffer summary 'norecord)
3791 (switch-to-buffer summary 'norecord))
3792 (setq in-buffer (current-buffer))
3793 ;; We disable the pick minor mode commands.
3794 (if (setq func (let (gnus-pick-mode)
3795 (lookup-key (current-local-map) keys)))
3797 (call-interactively func)
3798 (setq new-sum-point (point)))
3800 (when (eq in-buffer (current-buffer))
3801 (setq selected (gnus-summary-select-article))
3803 (unless not-restore-window
3804 (set-window-configuration owin))
3805 (when (eq selected 'old)
3807 (set-window-start (get-buffer-window (current-buffer))
3809 (set-window-point (get-buffer-window (current-buffer))
3811 (let ((win (get-buffer-window gnus-article-current-summary)))
3813 (set-window-point win new-sum-point))))))))
3815 (defun gnus-article-hide (&optional arg force)
3816 "Hide all the gruft in the current article.
3817 This means that PGP stuff, signatures, cited text and (some)
3818 headers will be hidden.
3819 If given a prefix, show the hidden text instead."
3820 (interactive (append (gnus-article-hidden-arg) (list 'force)))
3821 (gnus-article-hide-headers arg)
3822 (gnus-article-hide-pgp arg)
3823 (gnus-article-hide-citation-maybe arg force)
3824 (gnus-article-hide-signature arg))
3826 (defun gnus-article-maybe-highlight ()
3827 "Do some article highlighting if article highlighting is requested."
3828 (when (gnus-visual-p 'article-highlight 'highlight)
3829 (gnus-article-highlight-some)))
3831 (defun gnus-check-group-server ()
3832 ;; Make sure the connection to the server is alive.
3833 (unless (gnus-server-opened
3834 (gnus-find-method-for-group gnus-newsgroup-name))
3835 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
3836 (gnus-request-group gnus-newsgroup-name t)))
3838 (defun gnus-request-article-this-buffer (article group)
3839 "Get an article and insert it into this buffer."
3840 (let (do-update-line sparse-header)
3844 (gnus-kill-all-overlays)
3845 (setq group (or group gnus-newsgroup-name))
3847 ;; Using `gnus-request-article' directly will insert the article into
3848 ;; `nntp-server-buffer' - so we'll save some time by not having to
3849 ;; copy it from the server buffer into the article buffer.
3851 ;; We only request an article by message-id when we do not have the
3852 ;; headers for it, so we'll have to get those.
3853 (when (stringp article)
3854 (let ((gnus-override-method gnus-refer-article-method))
3855 (gnus-read-header article)))
3857 ;; If the article number is negative, that means that this article
3858 ;; doesn't belong in this newsgroup (possibly), so we find its
3859 ;; message-id and request it by id instead of number.
3860 (when (and (numberp article)
3862 (get-buffer gnus-summary-buffer)
3863 (gnus-buffer-exists-p gnus-summary-buffer))
3865 (set-buffer gnus-summary-buffer)
3866 (let ((header (gnus-summary-article-header article)))
3869 ((memq article gnus-newsgroup-sparse)
3870 ;; This is a sparse gap article.
3871 (setq do-update-line article)
3872 (setq article (mail-header-id header))
3873 (let ((gnus-override-method gnus-refer-article-method))
3874 (setq sparse-header (gnus-read-header article)))
3875 (setq gnus-newsgroup-sparse
3876 (delq article gnus-newsgroup-sparse)))
3878 ;; It's a real article.
3879 (setq article (mail-header-id header)))
3881 ;; It is an extracted pseudo-article.
3882 (setq article 'pseudo)
3883 (gnus-request-pseudo-article header))))
3885 (let ((method (gnus-find-method-for-group
3886 gnus-newsgroup-name)))
3887 (when (and (eq (car method) 'nneething)
3890 (file-name-as-directory
3891 (or (cadr (assq 'nneething-address method))
3893 (mail-header-subject header))))
3894 (when (file-directory-p dir)
3895 (setq article 'nneething)
3896 (gnus-group-enter-directory dir))))))))
3899 ;; Refuse to select canceled articles.
3900 ((and (numberp article)
3902 (get-buffer gnus-summary-buffer)
3903 (gnus-buffer-exists-p gnus-summary-buffer)
3904 (eq (cdr (save-excursion
3905 (set-buffer gnus-summary-buffer)
3906 (assq article gnus-newsgroup-reads)))
3907 gnus-canceled-mark))
3909 ;; Check the backlog.
3910 ((and gnus-keep-backlog
3911 (gnus-backlog-request-article group article (current-buffer)))
3913 ;; Check asynchronous pre-fetch.
3914 ((gnus-async-request-fetched-article group article (current-buffer))
3915 (gnus-async-prefetch-next group article gnus-summary-buffer)
3916 (when (and (numberp article) gnus-keep-backlog)
3917 (gnus-backlog-enter-article group article (current-buffer)))
3920 ((and gnus-use-cache
3922 (gnus-cache-request-article article group))
3924 ;; Get the article and put into the article buffer.
3925 ((or (stringp article) (numberp article))
3926 (let ((gnus-override-method
3927 (and (stringp article) gnus-refer-article-method))
3928 (buffer-read-only nil))
3930 (gnus-kill-all-overlays)
3931 (gnus-check-group-server)
3932 (when (gnus-request-article article group (current-buffer))
3933 (when (numberp article)
3934 (gnus-async-prefetch-next group article gnus-summary-buffer)
3935 (when gnus-keep-backlog
3936 (gnus-backlog-enter-article
3937 group article (current-buffer))))
3942 ;; Associate this article with the current summary buffer.
3943 (setq gnus-article-current-summary gnus-summary-buffer)
3945 ;; Take the article from the original article buffer
3946 ;; and place it in the buffer it's supposed to be in.
3947 (when (and (get-buffer gnus-article-buffer)
3948 (equal (buffer-name (current-buffer))
3949 (buffer-name (get-buffer gnus-article-buffer))))
3951 (if (get-buffer gnus-original-article-buffer)
3952 (set-buffer gnus-original-article-buffer)
3953 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3954 (buffer-disable-undo)
3955 (setq major-mode 'gnus-original-article-mode)
3956 (setq buffer-read-only t))
3957 (let (buffer-read-only)
3959 (insert-buffer-substring gnus-article-buffer))
3960 (setq gnus-original-article (cons group article)))
3963 (run-hooks 'gnus-article-decode-hook)
3964 ;; Mark article as decoded or not.
3965 (setq gnus-article-decoded-p gnus-article-decode-hook))
3967 ;; Update sparse articles.
3968 (when (and do-update-line
3969 (or (numberp article)
3971 (let ((buf (current-buffer)))
3972 (set-buffer gnus-summary-buffer)
3973 (gnus-summary-update-article do-update-line sparse-header)
3974 (gnus-summary-goto-subject do-update-line nil t)
3975 (set-window-point (get-buffer-window (current-buffer) t)
3977 (set-buffer buf))))))
3983 (defcustom gnus-article-edit-mode-hook nil
3984 "Hook run in article edit mode buffers."
3985 :group 'gnus-article-various
3988 (defcustom gnus-article-edit-article-setup-function
3989 'gnus-article-mime-edit-article-setup
3990 "Function called to setup an editing article buffer."
3991 :group 'gnus-article-various
3994 (defvar gnus-article-edit-done-function nil)
3996 (defvar gnus-article-edit-mode-map nil)
3998 ;; Should we be using derived.el for this?
3999 (unless gnus-article-edit-mode-map
4000 (setq gnus-article-edit-mode-map (make-sparse-keymap))
4001 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
4003 (gnus-define-keys gnus-article-edit-mode-map
4004 "\C-c\C-c" gnus-article-edit-done
4005 "\C-c\C-k" gnus-article-edit-exit)
4007 (gnus-define-keys (gnus-article-edit-wash-map
4008 "\C-c\C-w" gnus-article-edit-mode-map)
4009 "f" gnus-article-edit-full-stops))
4011 (defun gnus-article-edit-mode ()
4012 "Major mode for editing articles.
4013 This is an extended text-mode.
4015 \\{gnus-article-edit-mode-map}"
4017 (setq major-mode 'gnus-article-edit-mode)
4018 (setq mode-name "Article Edit")
4019 (use-local-map gnus-article-edit-mode-map)
4020 (make-local-variable 'gnus-article-edit-done-function)
4021 (make-local-variable 'gnus-prev-winconf)
4022 (setq buffer-read-only nil)
4023 (buffer-enable-undo)
4025 (gnus-run-hooks 'text-mode-hook 'gnus-article-edit-mode-hook))
4027 (defun gnus-article-edit (&optional force)
4028 "Edit the current article.
4029 This will have permanent effect only in mail groups.
4030 If FORCE is non-nil, allow editing of articles even in read-only
4033 (when (and (not force)
4034 (gnus-group-read-only-p))
4035 (error "The current newsgroup does not support article editing"))
4036 (gnus-article-date-original)
4037 (gnus-article-edit-article
4039 `(lambda (no-highlight)
4041 (gnus-summary-edit-article-done
4042 ,(or (mail-header-references gnus-current-headers) "")
4043 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
4045 (defun gnus-article-edit-article (start-func exit-func)
4046 "Start editing the contents of the current article buffer."
4047 (let ((winconf (current-window-configuration)))
4048 (set-buffer gnus-article-buffer)
4049 (gnus-article-edit-mode)
4050 (funcall start-func)
4051 ;;(gnus-article-delete-text-of-type 'annotation)
4052 ;;(gnus-set-text-properties (point-min) (point-max) nil)
4053 (gnus-configure-windows 'edit-article)
4054 (setq gnus-article-edit-done-function exit-func)
4055 (setq gnus-prev-winconf winconf)
4056 (when gnus-article-edit-article-setup-function
4057 (funcall gnus-article-edit-article-setup-function))
4058 (gnus-message 6 "C-c C-c to end edits")))
4060 (defun gnus-article-edit-done (&optional arg)
4061 "Update the article edits and exit."
4066 (when (article-goto-body)
4067 (let ((lines (count-lines (point) (point-max)))
4068 (length (- (point-max) (point)))
4069 (case-fold-search t)
4070 (body (copy-marker (point))))
4071 (goto-char (point-min))
4072 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
4073 (delete-region (match-beginning 1) (match-end 1))
4074 (insert (number-to-string length)))
4075 (goto-char (point-min))
4076 (when (re-search-forward
4077 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
4078 (delete-region (match-beginning 1) (match-end 1))
4079 (insert (number-to-string length)))
4080 (goto-char (point-min))
4081 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
4082 (delete-region (match-beginning 1) (match-end 1))
4083 (insert (number-to-string lines)))))))
4084 (let ((func gnus-article-edit-done-function)
4085 (buf (current-buffer))
4086 (start (window-start)))
4087 (remove-hook 'gnus-article-mode-hook
4088 'gnus-article-mime-edit-article-unwind)
4089 (gnus-article-edit-exit)
4092 (let ((buffer-read-only nil))
4094 ;; The cache and backlog have to be flushed somewhat.
4095 (when gnus-keep-backlog
4096 (gnus-backlog-remove-article
4097 (car gnus-article-current) (cdr gnus-article-current)))
4098 ;; Flush original article as well.
4100 (when (get-buffer gnus-original-article-buffer)
4101 (set-buffer gnus-original-article-buffer)
4102 (setq gnus-original-article nil)))
4103 (when gnus-use-cache
4104 (gnus-cache-update-article
4105 (car gnus-article-current) (cdr gnus-article-current))))
4107 (set-window-start (get-buffer-window buf) start)
4108 (set-window-point (get-buffer-window buf) (point))))
4110 (defun gnus-article-edit-exit ()
4111 "Exit the article editing without updating."
4113 ;; We remove all text props from the article buffer.
4114 (let ((buf (format "%s" (buffer-string)))
4115 (curbuf (current-buffer))
4117 (window-start (window-start)))
4120 (let ((winconf gnus-prev-winconf))
4122 (set-window-configuration winconf)
4123 ;; Tippy-toe some to make sure that point remains where it was.
4124 (save-current-buffer
4126 (set-window-start (get-buffer-window (current-buffer)) window-start)
4129 (defun gnus-article-edit-full-stops ()
4130 "Interactively repair spacing at end of sentences."
4133 (goto-char (point-min))
4134 (search-forward-regexp "^$" nil t)
4135 (let ((case-fold-search nil))
4136 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
4139 ;;; Article editing with MIME-Edit
4142 (defcustom gnus-article-mime-edit-article-setup-hook nil
4143 "Hook run after setting up a MIME editing article buffer."
4144 :group 'gnus-article-various
4147 (defun gnus-article-mime-edit-article-unwind ()
4148 "Unwind `gnus-article-buffer' if article editing was given up."
4149 (remove-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
4150 (when mime-edit-mode-flag
4151 (mime-edit-exit 'nomime 'no-error)
4153 (when (featurep 'font-lock)
4154 (setq font-lock-defaults nil)
4155 (font-lock-mode 0)))
4157 (defun gnus-article-mime-edit-article-setup ()
4158 "Convert current buffer to MIME-Edit buffer and turn on MIME-Edit mode
4159 after replacing with the original article."
4160 (setq gnus-show-mime t)
4161 (setq gnus-article-edit-done-function
4162 `(lambda (&rest args)
4163 (when mime-edit-mode-flag
4166 (goto-char (point-min))
4167 (let (case-fold-search)
4168 (when (re-search-forward
4169 (format "^%s$" (regexp-quote mail-header-separator))
4171 (replace-match "")))
4172 (when (featurep 'font-lock)
4173 (setq font-lock-defaults nil)
4175 (apply ,gnus-article-edit-done-function args)
4176 (set-buffer gnus-original-article-buffer)
4178 (insert-buffer gnus-article-buffer)
4179 (setq gnus-current-headers (gnus-article-make-full-mail-header))
4180 (gnus-article-prepare-display)))
4181 (substitute-key-definition
4182 'gnus-article-edit-exit 'gnus-article-mime-edit-exit
4183 gnus-article-edit-mode-map)
4185 (insert-buffer gnus-original-article-buffer)
4187 (when (featurep 'font-lock)
4188 (set (make-local-variable 'font-lock-defaults)
4189 '(message-font-lock-keywords t))
4190 (font-lock-set-defaults)
4191 (turn-on-font-lock))
4192 (add-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
4193 (gnus-run-hooks 'gnus-article-mime-edit-article-setup-hook))
4195 (defun gnus-article-mime-edit-exit ()
4196 "Exit the article MIME editing without updating."
4198 (let ((winconf gnus-prev-winconf)
4200 (when mime-edit-mode-flag
4203 (goto-char (point-min))
4204 (let (case-fold-search)
4205 (when (re-search-forward
4206 (format "^%s$" (regexp-quote mail-header-separator)) nil t)
4207 (replace-match "")))
4208 (when (featurep 'font-lock)
4209 (setq font-lock-defaults nil)
4211 ;; We remove all text props from the article buffer.
4212 (setq buf (format "%s" (buffer-string)))
4213 (set-buffer (get-buffer-create gnus-original-article-buffer))
4216 (setq gnus-current-headers (gnus-article-make-full-mail-header))
4217 (gnus-article-prepare-display)
4218 (set-window-configuration winconf)))
4221 ;;; Article highlights
4224 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
4226 ;;; Internal Variables:
4228 (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\\)"
4229 "Regular expression that matches URLs."
4230 :group 'gnus-article-buttons
4233 (defcustom gnus-button-alist
4234 `(("<\\(url:[>\n\t ]*?\\)?news:[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
4235 0 t gnus-button-message-id 2)
4236 ("\\bnews:\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t gnus-button-message-id 1)
4237 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
4239 gnus-button-fetch-group 4)
4240 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
4241 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
4242 t gnus-button-message-id 3)
4243 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
4244 ("mailto:\\([-a-zA-Z.@_+0-9%]+\\)" 0 t gnus-url-mailto 1)
4245 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
4246 ;; This is how URLs _should_ be embedded in text...
4247 ("<URL: *\\([^>]*\\)>" 0 t gnus-button-embedded-url 1)
4249 (,gnus-button-url-regexp 0 t gnus-button-url 0))
4250 "*Alist of regexps matching buttons in article bodies.
4252 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
4253 REGEXP: is the string matching text around the button,
4254 BUTTON: is the number of the regexp grouping actually matching the button,
4255 FORM: is a lisp expression which must eval to true for the button to
4257 CALLBACK: is the function to call when the user push this button, and each
4258 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
4260 CALLBACK can also be a variable, in that case the value of that
4261 variable it the real callback function."
4262 :group 'gnus-article-buttons
4263 :type '(repeat (list regexp
4264 (integer :tag "Button")
4266 (function :tag "Callback")
4269 (integer :tag "Regexp group")))))
4271 (defcustom gnus-header-button-alist
4272 `(("^\\(References\\|Message-I[Dd]\\):" "<[^>]+>"
4273 0 t gnus-button-message-id 0)
4274 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
4275 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
4276 0 t gnus-button-mailto 0)
4277 ("^X-[Uu][Rr][Ll]:" ,gnus-button-url-regexp 0 t gnus-button-url 0)
4278 ("^Subject:" ,gnus-button-url-regexp 0 t gnus-button-url 0)
4279 ("^[^:]+:" ,gnus-button-url-regexp 0 t gnus-button-url 0)
4280 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
4281 gnus-button-message-id 3))
4282 "*Alist of headers and regexps to match buttons in article heads.
4284 This alist is very similar to `gnus-button-alist', except that each
4285 alist has an additional HEADER element first in each entry:
4287 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
4289 HEADER is a regexp to match a header. For a fuller explanation, see
4290 `gnus-button-alist'."
4291 :group 'gnus-article-buttons
4292 :group 'gnus-article-headers
4293 :type '(repeat (list (regexp :tag "Header")
4295 (integer :tag "Button")
4297 (function :tag "Callback")
4300 (integer :tag "Regexp group")))))
4302 (defvar gnus-button-regexp nil)
4303 (defvar gnus-button-marker-list nil)
4304 ;; Regexp matching any of the regexps from `gnus-button-alist'.
4306 (defvar gnus-button-last nil)
4307 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
4311 (defun gnus-article-push-button (event)
4312 "Check text under the mouse pointer for a callback function.
4313 If the text under the mouse pointer has a `gnus-callback' property,
4314 call it with the value of the `gnus-data' text property."
4316 (set-buffer (window-buffer (posn-window (event-start event))))
4317 (let* ((pos (posn-point (event-start event)))
4318 (data (get-text-property pos 'gnus-data))
4319 (fun (get-text-property pos 'gnus-callback)))
4322 (funcall fun data))))
4324 (defun gnus-article-press-button ()
4325 "Check text at point for a callback function.
4326 If the text at point has a `gnus-callback' property,
4327 call it with the value of the `gnus-data' text property."
4329 (let* ((data (get-text-property (point) 'gnus-data))
4330 (fun (get-text-property (point) 'gnus-callback)))
4332 (funcall fun data))))
4334 (defun gnus-article-prev-button (n)
4335 "Move point to N buttons backward.
4336 If N is negative, move forward instead."
4338 (gnus-article-next-button (- n)))
4340 (defun gnus-article-next-button (n)
4341 "Move point to N buttons forward.
4342 If N is negative, move backward instead."
4344 (let ((function (if (< n 0) 'previous-single-property-change
4345 'next-single-property-change))
4346 (inhibit-point-motion-hooks t)
4348 (limit (if (< n 0) (point-min) (point-max))))
4350 (while (and (not (= limit (point)))
4352 ;; Skip past the current button.
4353 (when (get-text-property (point) 'gnus-callback)
4354 (goto-char (funcall function (point) 'gnus-callback nil limit)))
4355 ;; Go to the next (or previous) button.
4356 (gnus-goto-char (funcall function (point) 'gnus-callback nil limit))
4357 ;; Put point at the start of the button.
4358 (when (and backward (not (get-text-property (point) 'gnus-callback)))
4359 (goto-char (funcall function (point) 'gnus-callback nil limit)))
4360 ;; Skip past intangible buttons.
4361 (when (get-text-property (point) 'intangible)
4365 (gnus-message 5 "No more buttons"))
4368 (defun gnus-article-highlight (&optional force)
4369 "Highlight current article.
4370 This function calls `gnus-article-highlight-headers',
4371 `gnus-article-highlight-citation',
4372 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
4373 do the highlighting. See the documentation for those functions."
4374 (interactive (list 'force))
4375 (gnus-article-highlight-headers)
4376 (gnus-article-highlight-citation force)
4377 (gnus-article-highlight-signature)
4378 (gnus-article-add-buttons force)
4379 (gnus-article-add-buttons-to-head))
4381 (defun gnus-article-highlight-some (&optional force)
4382 "Highlight current article.
4383 This function calls `gnus-article-highlight-headers',
4384 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
4385 do the highlighting. See the documentation for those functions."
4386 (interactive (list 'force))
4387 (gnus-article-highlight-headers)
4388 (gnus-article-highlight-signature)
4389 (gnus-article-add-buttons))
4391 (defun gnus-article-highlight-headers ()
4392 "Highlight article headers as specified by `gnus-header-face-alist'."
4395 (set-buffer gnus-article-buffer)
4397 (let ((alist gnus-header-face-alist)
4398 (buffer-read-only nil)
4399 (case-fold-search t)
4400 (inhibit-point-motion-hooks t)
4401 entry regexp header-face field-face from hpoints fpoints)
4402 (article-narrow-to-head)
4403 (while (setq entry (pop alist))
4404 (goto-char (point-min))
4405 (setq regexp (concat "^\\("
4406 (if (string-equal "" (nth 0 entry))
4410 header-face (nth 1 entry)
4411 field-face (nth 2 entry))
4412 (while (and (re-search-forward regexp nil t)
4416 (unless (search-forward ":" nil t)
4418 (when (and header-face
4419 (not (memq (point) hpoints)))
4420 (push (point) hpoints)
4421 (gnus-put-text-property from (point) 'face header-face))
4422 (when (and field-face
4423 (not (memq (setq from (point)) fpoints)))
4425 (if (re-search-forward "^[^ \t]" nil t)
4427 (goto-char (point-max)))
4428 (gnus-put-text-property from (point) 'face field-face))))))))
4430 (defun gnus-article-highlight-signature ()
4431 "Highlight the signature in an article.
4432 It does this by highlighting everything after
4433 `gnus-signature-separator' using `gnus-signature-face'."
4436 (set-buffer gnus-article-buffer)
4437 (let ((buffer-read-only nil)
4438 (inhibit-point-motion-hooks t))
4440 (when (and gnus-signature-face
4441 (gnus-article-narrow-to-signature))
4442 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
4443 'face gnus-signature-face)
4445 (gnus-article-search-signature)
4446 (let ((start (match-beginning 0))
4447 (end (set-marker (make-marker) (1+ (match-end 0)))))
4448 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
4451 (defun gnus-button-in-region-p (b e prop)
4452 "Say whether PROP exists in the region."
4453 (text-property-not-all b e prop nil))
4455 (defun gnus-article-add-buttons (&optional force)
4456 "Find external references in the article and make buttons of them.
4457 \"External references\" are things like Message-IDs and URLs, as
4458 specified by `gnus-button-alist'."
4459 (interactive (list 'force))
4461 (set-buffer gnus-article-buffer)
4462 (let ((buffer-read-only nil)
4463 (inhibit-point-motion-hooks t)
4464 (case-fold-search t)
4465 (alist gnus-button-alist)
4467 ;; Remove all old markers.
4469 (while (setq marker (pop gnus-button-marker-list))
4471 (when (setq entry (gnus-button-entry))
4472 (put-text-property (match-beginning (nth 1 entry))
4473 (match-end (nth 1 entry))
4474 'gnus-callback nil))
4475 (set-marker marker nil)))
4476 ;; We skip the headers.
4479 (while (setq entry (pop alist))
4480 (setq regexp (car entry))
4482 (while (re-search-forward regexp nil t)
4483 (let* ((start (and entry (match-beginning (nth 1 entry))))
4484 (end (and entry (match-end (nth 1 entry))))
4485 (from (match-beginning 0)))
4486 (when (and (or (eq t (nth 2 entry))
4487 (eval (nth 2 entry)))
4488 (not (gnus-button-in-region-p
4489 start end 'gnus-callback)))
4490 ;; That optional form returned non-nil, so we add the
4492 (gnus-article-add-button
4493 start end 'gnus-button-push
4494 (car (push (set-marker (make-marker) from)
4495 gnus-button-marker-list))))))))))
4497 ;; Add buttons to the head of an article.
4498 (defun gnus-article-add-buttons-to-head ()
4499 "Add buttons to the head of the article."
4502 (set-buffer gnus-article-buffer)
4504 (let ((buffer-read-only nil)
4505 (inhibit-point-motion-hooks t)
4506 (case-fold-search t)
4507 (alist gnus-header-button-alist)
4509 (article-narrow-to-head)
4511 ;; Each alist entry.
4512 (setq entry (car alist)
4514 (goto-char (point-min))
4515 (while (re-search-forward (car entry) nil t)
4516 ;; Each header matching the entry.
4517 (setq beg (match-beginning 0))
4518 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
4519 (match-beginning 0))
4522 (while (re-search-forward (nth 1 entry) end t)
4523 ;; Each match within a header.
4524 (let* ((entry (cdr entry))
4525 (start (match-beginning (nth 1 entry)))
4526 (end (match-end (nth 1 entry)))
4527 (form (nth 2 entry)))
4528 (goto-char (match-end 0))
4530 (gnus-article-add-button
4531 start end (nth 3 entry)
4532 (buffer-substring (match-beginning (nth 4 entry))
4533 (match-end (nth 4 entry)))))))
4534 (goto-char end)))))))
4536 ;;; External functions:
4538 (defun gnus-article-add-button (from to fun &optional data)
4539 "Create a button between FROM and TO with callback FUN and data DATA."
4540 (when gnus-article-button-face
4541 (gnus-overlay-put (gnus-make-overlay from to)
4542 'face gnus-article-button-face))
4543 (gnus-add-text-properties
4545 (nconc (and gnus-article-mouse-face
4546 (list gnus-mouse-face-prop gnus-article-mouse-face))
4547 (list 'gnus-callback fun)
4548 (and data (list 'gnus-data data)))))
4550 ;;; Internal functions:
4552 (defun gnus-article-set-globals ()
4554 (set-buffer gnus-summary-buffer)
4555 (gnus-set-global-variables)))
4557 (defun gnus-signature-toggle (end)
4559 (set-buffer gnus-article-buffer)
4560 (let ((buffer-read-only nil)
4561 (inhibit-point-motion-hooks t))
4562 (if (get-text-property end 'invisible)
4563 (gnus-article-unhide-text end (point-max))
4564 (gnus-article-hide-text end (point-max) gnus-hidden-properties)))))
4566 (defun gnus-button-entry ()
4567 ;; Return the first entry in `gnus-button-alist' matching this place.
4568 (let ((alist gnus-button-alist)
4571 (setq entry (pop alist))
4572 (if (looking-at (car entry))
4577 (defun gnus-button-push (marker)
4578 ;; Push button starting at MARKER.
4581 (let* ((entry (gnus-button-entry))
4582 (inhibit-point-motion-hooks t)
4584 (args (mapcar (lambda (group)
4585 (let ((string (match-string group)))
4586 (gnus-set-text-properties
4587 0 (length string) nil string)
4594 (fboundp (symbol-value fun)))
4595 (apply (symbol-value fun) args))
4597 (gnus-message 1 "You must define `%S' to use this button"
4598 (cons fun args)))))))
4600 (defun gnus-button-message-id (message-id)
4603 (set-buffer gnus-summary-buffer)
4604 (gnus-summary-refer-article message-id)))
4606 (defun gnus-button-fetch-group (address)
4607 "Fetch GROUP specified by ADDRESS."
4608 (if (not (string-match "[:/]" address))
4609 ;; This is just a simple group url.
4610 (gnus-group-read-ephemeral-group address gnus-select-method)
4611 (if (not (string-match "^\\([^:/]+\\)\\(:\\([^/]+\\)/\\)?\\(.*\\)$"
4613 (error "Can't parse %s" address)
4614 (gnus-group-read-ephemeral-group
4615 (match-string 4 address)
4616 `(nntp ,(match-string 1 address)
4617 (nntp-address ,(match-string 1 address))
4618 (nntp-port-number ,(if (match-end 3)
4619 (match-string 3 address)
4622 (defun gnus-url-parse-query-string (query &optional downcase)
4623 (let (retval pairs cur key val)
4624 (setq pairs (split-string query "&"))
4626 (setq cur (car pairs)
4628 (if (not (string-match "=" cur))
4630 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
4631 val (gnus-url-unhex-string (substring cur (match-end 0) nil)))
4633 (setq key (downcase key)))
4634 (setq cur (assoc key retval))
4636 (setcdr cur (cons val (cdr cur)))
4637 (setq retval (cons (list key val) retval)))))
4640 (defun gnus-url-unhex (x)
4647 (defun gnus-url-unhex-string (str &optional allow-newlines)
4648 "Remove %XXX embedded spaces, etc in a url.
4649 If optional second argument ALLOW-NEWLINES is non-nil, then allow the
4650 decoding of carriage returns and line feeds in the string, which is normally
4651 forbidden in URL encoding."
4652 (setq str (or str ""))
4654 (case-fold-search t))
4655 (while (string-match "%[0-9a-f][0-9a-f]" str)
4656 (let* ((start (match-beginning 0))
4657 (ch1 (gnus-url-unhex (elt str (+ start 1))))
4659 (gnus-url-unhex (elt str (+ start 2))))))
4661 tmp (substring str 0 start)
4664 (char-to-string code))
4665 ((or (= code ?\n) (= code ?\r))
4667 (t (char-to-string code))))
4668 str (substring str (match-end 0)))))
4669 (setq tmp (concat tmp str))
4672 (defun gnus-url-mailto (url)
4673 ;; Send mail to someone
4674 (when (string-match "mailto:/*\\(.*\\)" url)
4675 (setq url (substring url (match-beginning 1) nil)))
4676 (let (to args subject func)
4677 (if (string-match (regexp-quote "?") url)
4678 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
4679 args (gnus-url-parse-query-string
4680 (substring url (match-end 0) nil) t))
4681 (setq to (gnus-url-unhex-string url)))
4682 (setq args (cons (list "to" to) args)
4683 subject (cdr-safe (assoc "subject" args)))
4684 (gnus-setup-message 'reply
4687 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
4690 (message-position-on-field (caar args)))
4691 (insert (mapconcat 'identity (cdar args) ", "))
4692 (setq args (cdr args)))
4695 (message-goto-subject)))))
4697 (defun gnus-button-mailto (address)
4699 (set-buffer (gnus-copy-article-buffer))
4700 (gnus-setup-message 'reply
4701 (message-reply address)))
4703 (defun gnus-button-reply (address)
4704 ;; Reply to ADDRESS.
4705 (gnus-setup-message 'reply
4706 (message-reply address)))
4708 (defun gnus-button-url (address)
4710 ;; In Emacs 20, `browse-url-browser-function' may be an alist.
4711 (if (listp browse-url-browser-function)
4712 (browse-url address)
4713 (funcall browse-url-browser-function address)))
4715 (defun gnus-button-embedded-url (address)
4717 ;; In Emacs 20, `browse-url-browser-function' may be an alist.
4718 (if (listp browse-url-browser-function)
4719 (browse-url (gnus-strip-whitespace address))
4720 (funcall browse-url-browser-function (gnus-strip-whitespace address))))
4722 ;;; Next/prev buttons in the article buffer.
4724 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
4725 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
4727 (defvar gnus-prev-page-map nil)
4728 (unless gnus-prev-page-map
4729 (setq gnus-prev-page-map (make-sparse-keymap))
4730 (define-key gnus-prev-page-map gnus-mouse-2 'gnus-button-prev-page)
4731 (define-key gnus-prev-page-map "\r" 'gnus-button-prev-page))
4733 (defun gnus-insert-prev-page-button ()
4734 (let ((buffer-read-only nil))
4736 gnus-prev-page-line-format nil
4737 `(gnus-prev t local-map ,gnus-prev-page-map
4738 gnus-callback gnus-article-button-prev-page
4739 article-type annotation))))
4741 (defvar gnus-next-page-map nil)
4742 (unless gnus-next-page-map
4743 (setq gnus-next-page-map (make-keymap))
4744 (suppress-keymap gnus-prev-page-map)
4745 (define-key gnus-next-page-map gnus-mouse-2 'gnus-button-next-page)
4746 (define-key gnus-next-page-map "\r" 'gnus-button-next-page))
4748 (defun gnus-button-next-page ()
4749 "Go to the next page."
4751 (let ((win (selected-window)))
4752 (select-window (get-buffer-window gnus-article-buffer t))
4753 (gnus-article-next-page)
4754 (select-window win)))
4756 (defun gnus-button-prev-page ()
4757 "Go to the prev page."
4759 (let ((win (selected-window)))
4760 (select-window (get-buffer-window gnus-article-buffer t))
4761 (gnus-article-prev-page)
4762 (select-window win)))
4764 (defun gnus-insert-next-page-button ()
4765 (let ((buffer-read-only nil))
4766 (gnus-eval-format gnus-next-page-line-format nil
4768 t local-map ,gnus-next-page-map
4769 gnus-callback gnus-article-button-next-page
4770 article-type annotation))))
4772 (defun gnus-article-button-next-page (arg)
4773 "Go to the next page."
4775 (let ((win (selected-window)))
4776 (select-window (get-buffer-window gnus-article-buffer t))
4777 (gnus-article-next-page)
4778 (select-window win)))
4780 (defun gnus-article-button-prev-page (arg)
4781 "Go to the prev page."
4783 (let ((win (selected-window)))
4784 (select-window (get-buffer-window gnus-article-buffer t))
4785 (gnus-article-prev-page)
4786 (select-window win)))
4788 (defvar gnus-decode-header-methods
4789 '(mail-decode-encoded-word-region)
4790 "List of methods used to decode headers.
4792 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item is
4793 FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
4794 (REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
4795 whose names match REGEXP.
4798 ((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
4799 mail-decode-encoded-word-region
4800 (\"chinese\" . rfc1843-decode-region))
4803 (defvar gnus-decode-header-methods-cache nil)
4805 (defun gnus-multi-decode-header (start end)
4806 "Apply the functions from `gnus-encoded-word-methods' that match."
4807 (unless (and gnus-decode-header-methods-cache
4808 (eq gnus-newsgroup-name
4809 (car gnus-decode-header-methods-cache)))
4810 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
4813 (nconc gnus-decode-header-methods-cache (list x))
4814 (if (and gnus-newsgroup-name
4815 (string-match (car x) gnus-newsgroup-name))
4816 (nconc gnus-decode-header-methods-cache
4818 gnus-decode-header-methods))
4819 (let ((xlist gnus-decode-header-methods-cache))
4822 (narrow-to-region start end)
4824 (funcall (pop xlist) (point-min) (point-max))))))
4827 ;;; Treatment top-level handling.
4830 (defun gnus-treat-article (condition &optional part-number total-parts type)
4831 (let ((length (- (point-max) (point-min)))
4832 (alist gnus-treatment-function-alist)
4833 (article-goto-body-goes-to-point-min-p t)
4837 (let ((list gnus-article-treat-types))
4839 (when (string-match (pop list) type)
4840 (throw 'found t)))))))
4841 (highlightp (gnus-visual-p 'article-highlight 'highlight))
4843 (gnus-run-hooks 'gnus-part-display-hook)
4844 (while (setq elem (pop alist))
4845 (setq val (symbol-value (car elem)))
4846 (when (and (or (consp val)
4848 (gnus-treat-predicate val)
4849 (or (not (get (car elem) 'highlight))
4852 (funcall (cadr elem)))))))
4854 ;; Dynamic variables.
4855 (defvar part-number)
4856 (defvar total-parts)
4860 (defun gnus-treat-predicate (val)
4863 (not (not gnus-show-mime)))
4867 (let ((pred (pop val)))
4870 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
4872 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
4874 (not (gnus-treat-predicate val)))
4876 (equal (cadr val) type))
4878 (gnus-treat-predicate pred)))))
4886 (eq part-number total-parts))
4890 (stringp (car val)))
4891 (apply 'gnus-or (mapcar `(lambda (s)
4892 (string-match s ,(or gnus-newsgroup-name "")))
4895 (error "%S is not a valid value" val))))
4901 (defun gnus-article-header-presentation-method (entity situation)
4902 (mime-insert-header entity)
4905 (set-alist 'mime-header-presentation-method-alist
4906 'gnus-original-article-mode
4907 #'gnus-article-header-presentation-method)
4909 (defun gnus-mime-preview-quitting-method ()
4910 (mime-preview-kill-buffer)
4911 (delete-other-windows)
4912 (gnus-article-show-summary)
4913 (gnus-summary-select-article gnus-show-all-headers t))
4915 (set-alist 'mime-preview-quitting-method-alist
4916 'gnus-original-article-mode #'gnus-mime-preview-quitting-method)
4918 (defun gnus-following-method (buf)
4921 (message-yank-original)
4923 (goto-char (point-min))
4926 (set-alist 'mime-preview-following-method-alist
4927 'gnus-original-article-mode #'gnus-following-method)
4929 (set-alist 'mime-preview-over-to-previous-method-alist
4930 'gnus-original-article-mode
4932 (gnus-article-read-summary-keys
4933 nil (gnus-character-to-event ?P))))
4935 (set-alist 'mime-preview-over-to-next-method-alist
4936 'gnus-original-article-mode'
4938 (gnus-article-read-summary-keys
4939 nil (gnus-character-to-event ?N))))
4949 (run-hooks 'gnus-art-load-hook)
4951 ;;; gnus-art.el ends here