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))
43 ;; Avoid byte-compile warnings.
44 (defvar gnus-article-decoded-p)
45 (defvar gnus-article-mime-handles)
54 (defgroup gnus-article nil
56 :link '(custom-manual "(gnus)The Article Buffer")
59 (defgroup gnus-article-treat nil
60 "Treating article parts."
61 :link '(custom-manual "(gnus)Article Hiding")
64 (defgroup gnus-article-hiding nil
65 "Hiding article parts."
66 :link '(custom-manual "(gnus)Article Hiding")
69 (defgroup gnus-article-highlight nil
70 "Article highlighting."
71 :link '(custom-manual "(gnus)Article Highlighting")
75 (defgroup gnus-article-signature nil
77 :link '(custom-manual "(gnus)Article Signature")
80 (defgroup gnus-article-headers nil
82 :link '(custom-manual "(gnus)Hiding Headers")
85 (defgroup gnus-article-washing nil
86 "Special commands on articles."
87 :link '(custom-manual "(gnus)Article Washing")
90 (defgroup gnus-article-emphasis nil
91 "Fontisizing articles."
92 :link '(custom-manual "(gnus)Article Fontisizing")
95 (defgroup gnus-article-saving nil
97 :link '(custom-manual "(gnus)Saving Articles")
100 (defgroup gnus-article-mime nil
101 "Worshiping the MIME wonder."
102 :link '(custom-manual "(gnus)Using MIME")
103 :group 'gnus-article)
105 (defgroup gnus-article-buttons nil
106 "Pushable buttons in the article buffer."
107 :link '(custom-manual "(gnus)Article Buttons")
108 :group 'gnus-article)
110 (defgroup gnus-article-various nil
111 "Other article options."
112 :link '(custom-manual "(gnus)Misc Article")
113 :group 'gnus-article)
115 (defcustom gnus-ignored-headers
116 '("^Path:" "^Expires:" "^Date-Received:" "^References:" "^Xref:" "^Lines:"
117 "^Relay-Version:" "^Message-ID:" "^Approved:" "^Sender:" "^Received:"
118 "^X-UIDL:" "^MIME-Version:" "^Return-Path:" "^In-Reply-To:"
119 "^Content-Type:" "^Content-Transfer-Encoding:" "^X-WebTV-Signature:"
120 "^X-MimeOLE:" "^X-MSMail-Priority:" "^X-Priority:" "^X-Loop:"
121 "^X-Authentication-Warning:" "^X-MIME-Autoconverted:" "^X-Face:"
122 "^X-Attribution:" "^X-Originating-IP:" "^Delivered-To:"
123 "^NNTP-[-A-Za-z]+:" "^Distribution:" "^X-no-archive:" "^X-Trace:"
124 "^X-Complaints-To:" "^X-NNTP-Posting-Host:" "^X-Orig.*:"
125 "^Abuse-Reports-To:" "^Cache-Post-Path:" "^X-Article-Creation-Date:"
126 "^X-Poster:" "^X-Mail2News-Path:" "^X-Server-Date:" "^X-Cache:"
127 "^Originator:" "^X-Problems-To:" "^X-Auth-User:" "^X-Post-Time:"
128 "^X-Admin:" "^X-UID:" "^Resent-[-A-Za-z]+:" "^X-Mailing-List:"
129 "^Precedence:" "^Original-[-A-Za-z]+:" "^X-filename:" "^X-Orcpt:"
130 "^Old-Received:" "^X-Pgp-Fingerprint:" "^X-Pgp-Key-Id:"
131 "^X-Pgp-Public-Key-Url:" "^X-Auth:" "^X-From-Line:"
132 "^X-Gnus-Article-Number:" "^X-Majordomo:" "^X-Url:" "^X-Sender:"
133 "^X-Mailing-List:" "^MBOX-Line" "^Priority:" "^X-Pgp" "^X400-[-A-Za-z]+:"
134 "^Status:" "^X-Gnus-Mail-Source:" "^Cancel-Lock:")
135 "*All headers that start with this regexp will be hidden.
136 This variable can also be a list of regexps of headers to be ignored.
137 If `gnus-visible-headers' is non-nil, this variable will be ignored."
138 :type '(choice :custom-show nil
141 :group 'gnus-article-hiding)
143 (defcustom gnus-visible-headers
144 "^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:"
145 "*All headers that do not match this regexp will be hidden.
146 This variable can also be a list of regexp of headers to remain visible.
147 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
148 :type '(repeat :value-to-internal (lambda (widget value)
149 (custom-split-regexp-maybe value))
150 :match (lambda (widget value)
152 (widget-editable-list-match widget value)))
154 :group 'gnus-article-hiding)
156 (defcustom gnus-sorted-header-list
157 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
158 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
159 "*This variable is a list of regular expressions.
160 If it is non-nil, headers that match the regular expressions will
161 be placed first in the article buffer in the sequence specified by
163 :type '(repeat regexp)
164 :group 'gnus-article-hiding)
166 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
167 "Headers that are only to be displayed if they have interesting data.
168 Possible values in this list are `empty', `newsgroups', `followup-to',
169 `reply-to', `date', `long-to', and `many-to'."
170 :type '(set (const :tag "Headers with no content." empty)
171 (const :tag "Newsgroups with only one group." newsgroups)
172 (const :tag "Followup-to identical to newsgroups." followup-to)
173 (const :tag "Reply-to identical to from." reply-to)
174 (const :tag "Date less than four days old." date)
175 (const :tag "Very long To header." long-to)
176 (const :tag "Multiple To headers." many-to))
177 :group 'gnus-article-hiding)
179 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
180 "Regexp matching signature separator.
181 This can also be a list of regexps. In that case, it will be checked
182 from head to tail looking for a separator. Searches will be done from
183 the end of the buffer."
184 :type '(repeat string)
185 :group 'gnus-article-signature)
187 (defcustom gnus-signature-limit nil
188 "Provide a limit to what is considered a signature.
189 If it is a number, no signature may not be longer (in characters) than
190 that number. If it is a floating point number, no signature may be
191 longer (in lines) than that number. If it is a function, the function
192 will be called without any parameters, and if it returns nil, there is
193 no signature in the buffer. If it is a string, it will be used as a
194 regexp. If it matches, the text in question is not a signature."
195 :type '(choice (integer :value 200)
197 (function :value fun)
198 (regexp :value ".*"))
199 :group 'gnus-article-signature)
201 (defcustom gnus-hidden-properties '(invisible t intangible t)
202 "Property list to use for hiding text."
204 :group 'gnus-article-hiding)
206 (defcustom gnus-article-x-face-command
207 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | display -"
208 "*String or function to be executed to display an X-Face header.
209 If it is a string, the command will be executed in a sub-shell
210 asynchronously. The compressed face will be piped to this command."
211 :type 'string ;Leave function case to Lisp.
212 :group 'gnus-article-washing)
214 (defcustom gnus-article-x-face-too-ugly nil
215 "Regexp matching posters whose face shouldn't be shown automatically."
216 :type '(choice regexp (const nil))
217 :group 'gnus-article-washing)
219 (defcustom gnus-emphasis-alist
221 "\\(\\s-\\|^\\|[-\"]\\|\\s(\\|\\s)\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\s-\\|[-?!.,;:\"]\\|\\s(\\|\\s)\\)")
223 '(("_" "_" underline)
226 ("_/" "/_" underline-italic)
227 ("_\\*" "\\*_" underline-bold)
228 ("\\*/" "/\\*" bold-italic)
229 ("_\\*/" "/\\*_" underline-bold-italic))))
230 `(("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
231 2 3 gnus-emphasis-underline)
235 (format format (car spec) (cadr spec))
236 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
238 "*Alist that says how to fontify certain phrases.
239 Each item looks like this:
241 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
243 The first element is a regular expression to be matched. The second
244 is a number that says what regular expression grouping used to find
245 the entire emphasized word. The third is a number that says what
246 regexp grouping should be displayed and highlighted. The fourth
247 is the face used for highlighting."
248 :type '(repeat (list :value ("" 0 0 default)
250 (integer :tag "Match group")
251 (integer :tag "Emphasize group")
253 :group 'gnus-article-emphasis)
255 (defface gnus-emphasis-bold '((t (:bold t)))
256 "Face used for displaying strong emphasized text (*word*)."
257 :group 'gnus-article-emphasis)
259 (defface gnus-emphasis-italic '((t (:italic t)))
260 "Face used for displaying italic emphasized text (/word/)."
261 :group 'gnus-article-emphasis)
263 (defface gnus-emphasis-underline '((t (:underline t)))
264 "Face used for displaying underlined emphasized text (_word_)."
265 :group 'gnus-article-emphasis)
267 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
268 "Face used for displaying underlined bold emphasized text (_*word*_)."
269 :group 'gnus-article-emphasis)
271 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
272 "Face used for displaying underlined italic emphasized text (_*word*_)."
273 :group 'gnus-article-emphasis)
275 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
276 "Face used for displaying bold italic emphasized text (/*word*/)."
277 :group 'gnus-article-emphasis)
279 (defface gnus-emphasis-underline-bold-italic
280 '((t (:bold t :italic t :underline t)))
281 "Face used for displaying underlined bold italic emphasized text.
282 Esample: (_/*word*/_)."
283 :group 'gnus-article-emphasis)
285 (defface gnus-emphasis-highlight-words
286 '((t (:background "black" :foreground "yellow")))
287 "Face used for displaying highlighted words."
288 :group 'gnus-article-emphasis)
290 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
291 "Format for display of Date headers in article bodies.
292 See `format-time-string' for the possible values.
294 The variable can also be function, which should return a complete Date
295 header. The function is called with one argument, the time, which can
296 be fed to `format-time-string'."
297 :type '(choice string symbol)
298 :link '(custom-manual "(gnus)Article Date")
299 :group 'gnus-article-washing)
302 (autoload 'mail-extract-address-components "mail-extr"))
304 (defcustom gnus-save-all-headers t
305 "*If non-nil, don't remove any headers before saving."
306 :group 'gnus-article-saving
309 (defcustom gnus-prompt-before-saving 'always
310 "*This variable says how much prompting is to be done when saving articles.
311 If it is nil, no prompting will be done, and the articles will be
312 saved to the default files. If this variable is `always', each and
313 every article that is saved will be preceded by a prompt, even when
314 saving large batches of articles. If this variable is neither nil not
315 `always', there the user will be prompted once for a file name for
316 each invocation of the saving commands."
317 :group 'gnus-article-saving
318 :type '(choice (item always)
319 (item :tag "never" nil)
320 (sexp :tag "once" :format "%t\n" :value t)))
322 (defcustom gnus-saved-headers gnus-visible-headers
323 "Headers to keep if `gnus-save-all-headers' is nil.
324 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
325 If that variable is nil, however, all headers that match this regexp
326 will be kept while the rest will be deleted before saving."
327 :group 'gnus-article-saving
330 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
331 "A function to save articles in your favourite format.
332 The function must be interactively callable (in other words, it must
333 be an Emacs command).
335 Gnus provides the following functions:
337 * gnus-summary-save-in-rmail (Rmail format)
338 * gnus-summary-save-in-mail (Unix mail format)
339 * gnus-summary-save-in-folder (MH folder)
340 * gnus-summary-save-in-file (article format)
341 * gnus-summary-save-in-vm (use VM's folder format)
342 * gnus-summary-write-to-file (article format -- overwrite)."
343 :group 'gnus-article-saving
344 :type '(radio (function-item gnus-summary-save-in-rmail)
345 (function-item gnus-summary-save-in-mail)
346 (function-item gnus-summary-save-in-folder)
347 (function-item gnus-summary-save-in-file)
348 (function-item gnus-summary-save-in-vm)
349 (function-item gnus-summary-write-to-file)))
351 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
352 "A function generating a file name to save articles in Rmail format.
353 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
354 :group 'gnus-article-saving
357 (defcustom gnus-mail-save-name 'gnus-plain-save-name
358 "A function generating a file name to save articles in Unix mail format.
359 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
360 :group 'gnus-article-saving
363 (defcustom gnus-folder-save-name 'gnus-folder-save-name
364 "A function generating a file name to save articles in MH folder.
365 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
366 :group 'gnus-article-saving
369 (defcustom gnus-file-save-name 'gnus-numeric-save-name
370 "A function generating a file name to save articles in article format.
371 The function is called with NEWSGROUP, HEADERS, and optional
373 :group 'gnus-article-saving
376 (defcustom gnus-split-methods
377 '((gnus-article-archive-name)
378 (gnus-article-nndoc-name))
379 "*Variable used to suggest where articles are to be saved.
380 For instance, if you would like to save articles related to Gnus in
381 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
382 you could set this variable to something like:
384 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
385 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
387 This variable is an alist where the where the key is the match and the
388 value is a list of possible files to save in if the match is non-nil.
390 If the match is a string, it is used as a regexp match on the
391 article. If the match is a symbol, that symbol will be funcalled
392 from the buffer of the article to be saved with the newsgroup as the
393 parameter. If it is a list, it will be evaled in the same buffer.
395 If this form or function returns a string, this string will be used as
396 a possible file name; and if it returns a non-nil list, that list will
397 be used as possible file names."
398 :group 'gnus-article-saving
399 :type '(repeat (choice (list :value (fun) function)
400 (cons :value ("" "") regexp (repeat string))
403 (defcustom gnus-article-display-method-for-mime
404 'gnus-article-display-mime-message
405 "Function to display a MIME message.
406 The function is called from the article buffer."
407 :group 'gnus-article-mime
410 (defcustom gnus-article-display-method-for-traditional
411 'gnus-article-display-traditional-message
412 "*Function to display a traditional message.
413 The function is called from the article buffer."
414 :group 'gnus-article-mime
417 (defcustom gnus-page-delimiter "^\^L"
418 "*Regexp describing what to use as article page delimiters.
419 The default value is \"^\^L\", which is a form linefeed at the
420 beginning of a line."
422 :group 'gnus-article-various)
424 (defcustom gnus-article-mode-line-format "Gnus: %g %S%m"
425 "*The format specification for the article mode line.
426 See `gnus-summary-mode-line-format' for a closer description.
428 The following additional specs are available:
430 %w The article washing status.
431 %m The number of MIME parts in the article."
433 :group 'gnus-article-various)
435 (defcustom gnus-article-mode-hook nil
436 "*A hook for Gnus article mode."
438 :group 'gnus-article-various)
440 (defcustom gnus-article-menu-hook nil
441 "*Hook run after the creation of the article mode menu."
443 :group 'gnus-article-various)
445 (defcustom gnus-article-prepare-hook nil
446 "*A hook called after an article has been prepared in the article buffer."
448 :group 'gnus-article-various)
450 (defcustom gnus-article-hide-pgp-hook nil
451 "*A hook called after successfully hiding a PGP signature."
453 :group 'gnus-article-various)
455 (defcustom gnus-article-button-face 'bold
456 "Face used for highlighting buttons in the article buffer.
458 An article button is a piece of text that you can activate by pressing
459 `RET' or `mouse-2' above it."
461 :group 'gnus-article-buttons)
463 (defcustom gnus-article-mouse-face 'highlight
464 "Face used for mouse highlighting in the article buffer.
466 Article buttons will be displayed in this face when the cursor is
469 :group 'gnus-article-buttons)
471 (defcustom gnus-signature-face 'gnus-signature-face
472 "Face used for highlighting a signature in the article buffer.
473 Obsolete; use the face `gnus-signature-face' for customizations instead."
475 :group 'gnus-article-highlight
476 :group 'gnus-article-signature)
478 (defface gnus-signature-face
481 "Face used for highlighting a signature in the article buffer."
482 :group 'gnus-article-highlight
483 :group 'gnus-article-signature)
485 (defface gnus-header-from-face
488 (:foreground "spring green"))
491 (:foreground "red3"))
494 "Face used for displaying from headers."
495 :group 'gnus-article-headers
496 :group 'gnus-article-highlight)
498 (defface gnus-header-subject-face
501 (:foreground "SeaGreen3"))
504 (:foreground "red4"))
506 (:bold t :italic t)))
507 "Face used for displaying subject headers."
508 :group 'gnus-article-headers
509 :group 'gnus-article-highlight)
511 (defface gnus-header-newsgroups-face
514 (:foreground "yellow" :italic t))
517 (:foreground "MidnightBlue" :italic t))
520 "Face used for displaying newsgroups headers."
521 :group 'gnus-article-headers
522 :group 'gnus-article-highlight)
524 (defface gnus-header-name-face
527 (:foreground "SeaGreen"))
530 (:foreground "maroon"))
533 "Face used for displaying header names."
534 :group 'gnus-article-headers
535 :group 'gnus-article-highlight)
537 (defface gnus-header-content-face
540 (:foreground "forest green" :italic t))
543 (:foreground "indianred4" :italic t))
545 (:italic t))) "Face used for displaying header content."
546 :group 'gnus-article-headers
547 :group 'gnus-article-highlight)
549 (defcustom gnus-header-face-alist
550 '(("From" nil gnus-header-from-face)
551 ("Subject" nil gnus-header-subject-face)
552 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
553 ("" gnus-header-name-face gnus-header-content-face))
554 "*Controls highlighting of article header.
556 An alist of the form (HEADER NAME CONTENT).
558 HEADER is a regular expression which should match the name of an
559 header header and NAME and CONTENT are either face names or nil.
561 The name of each header field will be displayed using the face
562 specified by the first element in the list where HEADER match the
563 header name and NAME is non-nil. Similarly, the content will be
564 displayed by the first non-nil matching CONTENT face."
565 :group 'gnus-article-headers
566 :group 'gnus-article-highlight
567 :type '(repeat (list (regexp :tag "Header")
569 (item :tag "skip" nil)
570 (face :value default))
571 (choice :tag "Content"
572 (item :tag "skip" nil)
573 (face :value default)))))
575 (defcustom gnus-article-decode-hook nil
576 "*Hook run to decode charsets in articles."
577 :group 'gnus-article-headers
580 (defcustom gnus-display-mime-function 'gnus-display-mime
581 "Function to display MIME articles."
582 :group 'gnus-article-mime
585 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
586 "Function used to decode headers.")
588 (defvar gnus-article-dumbquotes-map
606 "Table for MS-to-Latin1 translation.")
608 (defcustom gnus-ignored-mime-types nil
609 "List of MIME types that should be ignored by Gnus."
610 :group 'gnus-article-mime
611 :type '(repeat regexp))
613 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
614 "List of MIME types that should not be given buttons when rendered."
615 :group 'gnus-article-mime
616 :type '(repeat regexp))
618 (defcustom gnus-article-mime-part-function nil
619 "Function called with a MIME handle as the argument.
620 This is meant for people who want to do something automatic based
621 on parts -- for instance, adding Vcard info to a database."
622 :group 'gnus-article-mime
625 (defcustom gnus-mime-multipart-functions nil
626 "An alist of MIME types to functions to display them.")
628 (defcustom gnus-article-date-lapsed-new-header nil
629 "Whether the X-Sent and Date headers can coexist.
630 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
631 either replace the old \"Date:\" header (if this variable is nil), or
632 be added below it (otherwise)."
633 :group 'gnus-article-headers
637 ;;; The treatment variables
640 (defvar gnus-part-display-hook nil
641 "Hook called on parts that are to receive treatment.")
643 (defvar gnus-article-treat-custom
644 '(choice (const :tag "Off" nil)
646 (const :tag "Header" head)
647 (const :tag "Last" last)
648 (integer :tag "Less")
649 (repeat :tag "Groups" regexp)
650 (sexp :tag "Predicate")))
652 (defvar gnus-article-treat-head-custom
653 '(choice (const :tag "Off" nil)
654 (const :tag "Header" head)))
656 (defvar gnus-article-treat-types '("text/plain")
659 (defvar gnus-inhibit-treatment nil
660 "Whether to inhibit treatment.")
662 (defcustom gnus-treat-highlight-signature '(or last (typep "text/x-vcard"))
663 "Highlight the signature.
664 Valid values are nil, t, `head', `last', an integer or a predicate.
665 See the manual for details."
666 :group 'gnus-article-treat
667 :type gnus-article-treat-custom)
668 (put 'gnus-treat-highlight-signature 'highlight t)
670 (defcustom gnus-treat-buttonize t
672 Valid values are nil, t, `head', `last', an integer or a predicate.
673 See the manual for details."
674 :group 'gnus-article-treat
675 :type gnus-article-treat-custom)
676 (put 'gnus-treat-buttonize 'highlight t)
678 (defcustom gnus-treat-buttonize-head 'head
679 "Add buttons to the head.
680 Valid values are nil, t, `head', `last', an integer or a predicate.
681 See the manual for details."
682 :group 'gnus-article-treat
683 :type gnus-article-treat-head-custom)
684 (put 'gnus-treat-buttonize-head 'highlight t)
686 (defcustom gnus-treat-emphasize t
688 Valid values are nil, t, `head', `last', an integer or a predicate.
689 See the manual for details."
690 :group 'gnus-article-treat
691 :type gnus-article-treat-custom)
692 (put 'gnus-treat-emphasize 'highlight t)
694 (defcustom gnus-treat-strip-cr nil
695 "Remove carriage returns.
696 Valid values are nil, t, `head', `last', an integer or a predicate.
697 See the manual for details."
698 :group 'gnus-article-treat
699 :type gnus-article-treat-custom)
701 (defcustom gnus-treat-hide-headers 'head
703 Valid values are nil, t, `head', `last', an integer or a predicate.
704 See the manual for details."
705 :group 'gnus-article-treat
706 :type gnus-article-treat-head-custom)
708 (defcustom gnus-treat-hide-boring-headers nil
709 "Hide boring headers.
710 Valid values are nil, t, `head', `last', an integer or a predicate.
711 See the manual for details."
712 :group 'gnus-article-treat
713 :type gnus-article-treat-head-custom)
715 (defcustom gnus-treat-hide-signature nil
717 Valid values are nil, t, `head', `last', an integer or a predicate.
718 See the manual for details."
719 :group 'gnus-article-treat
720 :type gnus-article-treat-custom)
722 (defcustom gnus-treat-fill-article nil
724 Valid values are nil, t, `head', `last', an integer or a predicate.
725 See the manual for details."
726 :group 'gnus-article-treat
727 :type gnus-article-treat-custom)
729 (defcustom gnus-treat-hide-citation nil
731 Valid values are nil, t, `head', `last', an integer or a predicate.
732 See the manual for details."
733 :group 'gnus-article-treat
734 :type gnus-article-treat-custom)
736 (defcustom gnus-treat-strip-pgp t
737 "Strip PGP signatures.
738 Valid values are nil, t, `head', `last', an integer or a predicate.
739 See the manual for details."
740 :group 'gnus-article-treat
741 :type gnus-article-treat-custom)
743 (defcustom gnus-treat-strip-pem nil
744 "Strip PEM signatures.
745 Valid values are nil, t, `head', `last', an integer or a predicate.
746 See the manual for details."
747 :group 'gnus-article-treat
748 :type gnus-article-treat-custom)
750 (defcustom gnus-treat-strip-banner t
751 "Strip banners from articles.
752 The banner to be stripped is specified in the `banner' group parameter.
753 Valid values are nil, t, `head', `last', an integer or a predicate.
754 See the manual for details."
755 :group 'gnus-article-treat
756 :type gnus-article-treat-custom)
758 (defcustom gnus-treat-highlight-headers 'head
759 "Highlight the headers.
760 Valid values are nil, t, `head', `last', an integer or a predicate.
761 See the manual for details."
762 :group 'gnus-article-treat
763 :type gnus-article-treat-head-custom)
764 (put 'gnus-treat-highlight-headers 'highlight t)
766 (defcustom gnus-treat-highlight-citation t
767 "Highlight cited text.
768 Valid values are nil, t, `head', `last', an integer or a predicate.
769 See the manual for details."
770 :group 'gnus-article-treat
771 :type gnus-article-treat-custom)
772 (put 'gnus-treat-highlight-citation 'highlight t)
774 (defcustom gnus-treat-date-ut nil
775 "Display the Date in UT (GMT).
776 Valid values are nil, t, `head', `last', an integer or a predicate.
777 See the manual for details."
778 :group 'gnus-article-treat
779 :type gnus-article-treat-head-custom)
781 (defcustom gnus-treat-date-local nil
782 "Display the Date in the local timezone.
783 Valid values are nil, t, `head', `last', an integer or a predicate.
784 See the manual for details."
785 :group 'gnus-article-treat
786 :type gnus-article-treat-head-custom)
788 (defcustom gnus-treat-date-lapsed nil
789 "Display the Date header in a way that says how much time has elapsed.
790 Valid values are nil, t, `head', `last', an integer or a predicate.
791 See the manual for details."
792 :group 'gnus-article-treat
793 :type gnus-article-treat-head-custom)
795 (defcustom gnus-treat-date-original nil
796 "Display the date in the original timezone.
797 Valid values are nil, t, `head', `last', an integer or a predicate.
798 See the manual for details."
799 :group 'gnus-article-treat
800 :type gnus-article-treat-head-custom)
802 (defcustom gnus-treat-date-iso8601 nil
803 "Display the date in the ISO8601 format.
804 Valid values are nil, t, `head', `last', an integer or a predicate.
805 See the manual for details."
806 :group 'gnus-article-treat
807 :type gnus-article-treat-head-custom)
809 (defcustom gnus-treat-date-user-defined nil
810 "Display the date in a user-defined format.
811 The format is defined by the `gnus-article-time-format' variable.
812 Valid values are nil, t, `head', `last', an integer or a predicate.
813 See the manual for details."
814 :group 'gnus-article-treat
815 :type gnus-article-treat-head-custom)
817 (defcustom gnus-treat-strip-headers-in-body t
818 "Strip the X-No-Archive header line from the beginning of the body.
819 Valid values are nil, t, `head', `last', an integer or a predicate.
820 See the manual for details."
821 :group 'gnus-article-treat
822 :type gnus-article-treat-custom)
824 (defcustom gnus-treat-strip-trailing-blank-lines nil
825 "Strip trailing blank lines.
826 Valid values are nil, t, `head', `last', an integer or a predicate.
827 See the manual for details."
828 :group 'gnus-article-treat
829 :type gnus-article-treat-custom)
831 (defcustom gnus-treat-strip-leading-blank-lines nil
832 "Strip leading blank lines.
833 Valid values are nil, t, `head', `last', an integer or a predicate.
834 See the manual for details."
835 :group 'gnus-article-treat
836 :type gnus-article-treat-custom)
838 (defcustom gnus-treat-strip-multiple-blank-lines nil
839 "Strip multiple blank lines.
840 Valid values are nil, t, `head', `last', an integer or a predicate.
841 See the manual for details."
842 :group 'gnus-article-treat
843 :type gnus-article-treat-custom)
845 (defcustom gnus-treat-overstrike t
846 "Treat overstrike highlighting.
847 Valid values are nil, t, `head', `last', an integer or a predicate.
848 See the manual for details."
849 :group 'gnus-article-treat
850 :type gnus-article-treat-custom)
851 (put 'gnus-treat-overstrike 'highlight t)
853 (defcustom gnus-treat-display-xface (if (and gnus-xemacs (featurep 'xface))
855 "Display X-Face headers.
856 Valid values are nil, t, `head', `last', an integer or a predicate.
857 See the manual for details."
858 :group 'gnus-article-treat
859 :type gnus-article-treat-head-custom)
860 (put 'gnus-treat-display-xface 'highlight t)
862 (defcustom gnus-treat-display-smileys (if (and gnus-xemacs
866 Valid values are nil, t, `head', `last', an integer or a predicate.
867 See the manual for details."
868 :group 'gnus-article-treat
869 :type gnus-article-treat-custom)
870 (put 'gnus-treat-display-smileys 'highlight t)
872 (defcustom gnus-treat-display-picons (if gnus-xemacs 'head nil)
874 Valid values are nil, t, `head', `last', an integer or a predicate.
875 See the manual for details."
876 :group 'gnus-article-treat
877 :type gnus-article-treat-head-custom)
878 (put 'gnus-treat-display-picons 'highlight t)
880 (defcustom gnus-treat-capitalize-sentences nil
881 "Capitalize sentence-starting words.
882 Valid values are nil, t, `head', `last', an integer or a predicate.
883 See the manual for details."
884 :group 'gnus-article-treat
885 :type gnus-article-treat-custom)
887 (defcustom gnus-treat-fill-long-lines nil
889 Valid values are nil, t, `head', `last', an integer or a predicate.
890 See the manual for details."
891 :group 'gnus-article-treat
892 :type gnus-article-treat-custom)
894 (defcustom gnus-treat-play-sounds nil
896 Valid values are nil, t, `head', `last', an integer or a predicate.
897 See the manual for details."
898 :group 'gnus-article-treat
899 :type gnus-article-treat-custom)
901 (defcustom gnus-treat-decode-article-as-default-mime-charset nil
902 "Decode an article as `default-mime-charset'. For instance, if you want to
903 attempt to decode an article even if the value of `gnus-show-mime' is nil,
904 you could set this variable to something like: nil for don't decode, t for
905 decode the body, '(or header t) for the whole article, etc."
906 :group 'gnus-article-treat
907 :type '(radio (const :tag "Off" nil)
908 (const :tag "Decode body" t)
909 (const :tag "Decode all" (or head t))))
911 (defcustom gnus-treat-translate nil
912 "Translate articles from one language to another.
913 Valid values are nil, t, `head', `last', an integer or a predicate.
914 See the manual for details."
915 :group 'gnus-article-treat
916 :type gnus-article-treat-custom)
918 ;;; Internal variables
920 (defvar article-goto-body-goes-to-point-min-p nil)
921 (defvar gnus-article-wash-types nil)
922 (defvar gnus-article-emphasis-alist nil)
924 (defvar gnus-article-mime-handle-alist-1 nil)
925 (defvar gnus-treatment-function-alist
926 '((gnus-treat-strip-banner gnus-article-strip-banner)
927 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
928 (gnus-treat-buttonize gnus-article-add-buttons)
929 (gnus-treat-fill-article gnus-article-fill-cited-article)
930 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
931 (gnus-treat-strip-cr gnus-article-remove-cr)
932 (gnus-treat-emphasize gnus-article-emphasize)
933 (gnus-treat-display-xface gnus-article-display-x-face)
934 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
935 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
936 (gnus-treat-hide-signature gnus-article-hide-signature)
937 (gnus-treat-hide-citation gnus-article-hide-citation)
938 (gnus-treat-strip-pgp gnus-article-hide-pgp)
939 (gnus-treat-strip-pem gnus-article-hide-pem)
940 (gnus-treat-highlight-headers gnus-article-highlight-headers)
941 (gnus-treat-highlight-citation gnus-article-highlight-citation)
942 (gnus-treat-highlight-signature gnus-article-highlight-signature)
943 (gnus-treat-date-ut gnus-article-date-ut)
944 (gnus-treat-date-local gnus-article-date-local)
945 (gnus-treat-date-lapsed gnus-article-date-lapsed)
946 (gnus-treat-date-original gnus-article-date-original)
947 (gnus-treat-date-user-defined gnus-article-date-user)
948 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
949 (gnus-treat-strip-trailing-blank-lines
950 gnus-article-remove-trailing-blank-lines)
951 (gnus-treat-strip-leading-blank-lines
952 gnus-article-strip-leading-blank-lines)
953 (gnus-treat-strip-multiple-blank-lines
954 gnus-article-strip-multiple-blank-lines)
955 (gnus-treat-overstrike gnus-article-treat-overstrike)
956 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
957 (gnus-treat-display-smileys gnus-smiley-display)
958 (gnus-treat-display-picons gnus-article-display-picons)
959 (gnus-treat-play-sounds gnus-earcon-display)
960 (gnus-treat-decode-article-as-default-mime-charset
961 gnus-article-decode-article-as-default-mime-charset)))
963 (defvar gnus-article-mime-handle-alist nil)
964 (defvar article-lapsed-timer nil)
965 (defvar gnus-article-current-summary nil)
967 (defvar gnus-article-mode-syntax-table
968 (let ((table (copy-syntax-table text-mode-syntax-table)))
969 (modify-syntax-entry ?- "w" table)
970 (modify-syntax-entry ?> ")" table)
971 (modify-syntax-entry ?< "(" table)
973 "Syntax table used in article mode buffers.
974 Initialized from `text-mode-syntax-table.")
976 (defvar gnus-save-article-buffer nil)
978 (defvar gnus-article-mode-line-format-alist
979 (nconc '((?w (gnus-article-wash-status) ?s)
980 (?m (gnus-article-mime-part-status) ?s))
981 gnus-summary-mode-line-format-alist))
983 (defvar gnus-number-of-articles-to-be-saved nil)
985 (defvar gnus-inhibit-hiding nil)
987 (defsubst gnus-article-hide-text (b e props)
988 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
989 (add-text-properties b e props)
990 (when (memq 'intangible props)
992 (max (1- b) (point-min))
993 b 'intangible (cddr (memq 'intangible props)))))
994 (defsubst gnus-article-unhide-text (b e)
995 "Remove hidden text properties from region between B and E."
996 (remove-text-properties b e gnus-hidden-properties)
997 (when (memq 'intangible gnus-hidden-properties)
998 (put-text-property (max (1- b) (point-min))
1001 (defun gnus-article-hide-text-type (b e type)
1002 "Hide text of TYPE between B and E."
1003 (push type gnus-article-wash-types)
1004 (gnus-article-hide-text
1005 b e (cons 'article-type (cons type gnus-hidden-properties))))
1007 (defun gnus-article-unhide-text-type (b e type)
1008 "Unhide text of TYPE between B and E."
1009 (setq gnus-article-wash-types
1010 (delq type gnus-article-wash-types))
1011 (remove-text-properties
1012 b e (cons 'article-type (cons type gnus-hidden-properties)))
1013 (when (memq 'intangible gnus-hidden-properties)
1014 (put-text-property (max (1- b) (point-min))
1015 b 'intangible nil)))
1017 (defun gnus-article-hide-text-of-type (type)
1018 "Hide text of TYPE in the current buffer."
1020 (let ((b (point-min))
1022 (while (setq b (text-property-any b e 'article-type type))
1023 (add-text-properties b (incf b) gnus-hidden-properties)))))
1025 (defun gnus-article-delete-text-of-type (type)
1026 "Delete text of TYPE in the current buffer."
1028 (let ((b (point-min)))
1029 (while (setq b (text-property-any b (point-max) 'article-type type))
1031 b (or (text-property-not-all b (point-max) 'article-type type)
1034 (defun gnus-article-delete-invisible-text ()
1035 "Delete all invisible text in the current buffer."
1037 (let ((b (point-min)))
1038 (while (setq b (text-property-any b (point-max) 'invisible t))
1040 b (or (text-property-not-all b (point-max) 'invisible t)
1043 (defun gnus-article-text-type-exists-p (type)
1044 "Say whether any text of type TYPE exists in the buffer."
1045 (text-property-any (point-min) (point-max) 'article-type type))
1047 (defsubst gnus-article-header-rank ()
1048 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1049 (let ((list gnus-sorted-header-list)
1052 (when (looking-at (car list))
1054 (setq list (cdr list))
1058 (defun article-hide-headers (&optional arg delete)
1059 "Hide unwanted headers and possibly sort them as well."
1060 (interactive (gnus-article-hidden-arg))
1061 ;; Lars said that this function might be inhibited.
1062 (if (gnus-article-check-hidden-text 'headers arg)
1064 ;; Show boring headers as well.
1065 (gnus-article-show-hidden-text 'boring-headers)
1066 (when (eq 1 (point-min))
1067 (set-window-start (get-buffer-window (current-buffer)) 1)))
1068 (unless gnus-inhibit-hiding
1071 (let ((buffer-read-only nil)
1072 (inhibit-read-only t)
1073 (case-fold-search t)
1074 (max (1+ (length gnus-sorted-header-list)))
1075 (ignored (when (not gnus-visible-headers)
1076 (cond ((stringp gnus-ignored-headers)
1077 gnus-ignored-headers)
1078 ((listp gnus-ignored-headers)
1079 (mapconcat 'identity gnus-ignored-headers
1082 (cond ((stringp gnus-visible-headers)
1083 gnus-visible-headers)
1084 ((and gnus-visible-headers
1085 (listp gnus-visible-headers))
1086 (mapconcat 'identity gnus-visible-headers "\\|"))))
1087 (inhibit-point-motion-hooks t)
1089 ;; First we narrow to just the headers.
1090 (article-narrow-to-head)
1091 ;; Hide any "From " lines at the beginning of (mail) articles.
1092 (while (looking-at "From ")
1096 (delete-region (point-min) (point))
1097 (gnus-article-hide-text (point-min) (point)
1098 (nconc (list 'article-type 'headers)
1099 gnus-hidden-properties))))
1100 ;; Then treat the rest of the header lines.
1101 ;; Then we use the two regular expressions
1102 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1103 ;; select which header lines is to remain visible in the
1105 (while (re-search-forward "^[^ \t]*:" nil t)
1107 ;; Mark the rank of the header.
1109 (point) (1+ (point)) 'message-rank
1110 (if (or (and visible (looking-at visible))
1112 (not (looking-at ignored))))
1113 (gnus-article-header-rank)
1116 (message-sort-headers-1)
1117 (when (setq beg (text-property-any
1118 (point-min) (point-max) 'message-rank (+ 2 max)))
1119 ;; We delete or make invisible the unwanted headers.
1122 (add-text-properties
1123 (point-min) (+ 5 (point-min))
1124 '(article-type headers dummy-invisible t))
1125 (delete-region beg (point-max)))
1126 (gnus-article-hide-text-type beg (point-max) 'headers))))))))
1129 (defun article-hide-boring-headers (&optional arg)
1130 "Toggle hiding of headers that aren't very interesting.
1131 If given a negative prefix, always show; if given a positive prefix,
1133 (interactive (gnus-article-hidden-arg))
1134 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1135 (not gnus-show-all-headers))
1138 (let ((buffer-read-only nil)
1139 (list gnus-boring-article-headers)
1140 (inhibit-point-motion-hooks t)
1142 (article-narrow-to-head)
1144 (setq elem (pop list))
1145 (goto-char (point-min))
1147 ;; Hide empty headers.
1149 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1151 (gnus-article-hide-text-type
1152 (progn (beginning-of-line) (point))
1155 (if (re-search-forward "^[^ \t]" nil t)
1159 ;; Hide boring Newsgroups header.
1160 ((eq elem 'newsgroups)
1161 (when (equal (gnus-fetch-field "newsgroups")
1162 (gnus-group-real-name
1163 (if (boundp 'gnus-newsgroup-name)
1166 (gnus-article-hide-header "newsgroups")))
1167 ((eq elem 'followup-to)
1168 (when (equal (message-fetch-field "followup-to")
1169 (message-fetch-field "newsgroups"))
1170 (gnus-article-hide-header "followup-to")))
1171 ((eq elem 'reply-to)
1172 (let ((from (message-fetch-field "from"))
1173 (reply-to (message-fetch-field "reply-to")))
1178 (nth 1 (funcall gnus-extract-address-components from))
1179 (nth 1 (funcall gnus-extract-address-components reply-to)))))
1180 (gnus-article-hide-header "reply-to"))))
1182 (let ((date (message-fetch-field "date")))
1184 (< (days-between (current-time-string) date)
1186 (gnus-article-hide-header "date"))))
1188 (let ((to (message-fetch-field "to")))
1189 (when (> (length to) 1024)
1190 (gnus-article-hide-header "to"))))
1193 (goto-char (point-min))
1194 (while (re-search-forward "^to:" nil t)
1195 (setq to-count (1+ to-count)))
1196 (when (> to-count 1)
1197 (while (> to-count 0)
1198 (goto-char (point-min))
1200 (re-search-forward "^to:" nil nil to-count)
1202 (narrow-to-region (point) (point-max))
1203 (gnus-article-hide-header "to"))
1204 (setq to-count (1- to-count)))))))))))))
1206 (defun gnus-article-hide-header (header)
1208 (goto-char (point-min))
1209 (when (re-search-forward (concat "^" header ":") nil t)
1210 (gnus-article-hide-text-type
1211 (progn (beginning-of-line) (point))
1214 (if (re-search-forward "^[^ \t]" nil t)
1219 (defun article-toggle-headers (&optional arg)
1220 "Toggle hiding of headers. If given a negative prefix, always show;
1221 if given a positive prefix, always hide."
1222 (interactive (gnus-article-hidden-arg))
1223 (let ((force (when (numberp arg)
1224 (cond ((> arg 0) 'always-hide)
1225 ((< arg 0) 'always-show))))
1226 (window (get-buffer-window gnus-article-buffer))
1227 (header-end (point-min))
1228 header-start field-end field-start
1229 (inhibit-point-motion-hooks t)
1230 (inhibit-read-only t)
1234 (while (and (setq header-start
1235 (text-property-any header-end (point-max)
1236 'article-treated-header t))
1238 (text-property-not-all header-start (point-max)
1239 'article-treated-header t)))
1240 (setq field-end header-start)
1242 (;; Hide exposed invisible fields.
1243 (and (not (eq 'always-show force))
1245 (text-property-any field-end header-end
1246 'exposed-invisible-field t)))
1247 (while (and field-start
1248 (setq field-end (text-property-not-all
1249 field-start header-end
1250 'exposed-invisible-field t)))
1251 (add-text-properties field-start field-end gnus-hidden-properties)
1252 (setq field-start (text-property-any field-end header-end
1253 'exposed-invisible-field t)))
1254 (put-text-property header-start header-end
1255 'exposed-invisible-field nil))
1256 (;; Expose invisible fields.
1257 (and (not (eq 'always-hide force))
1259 (text-property-any field-end header-end 'invisible t)))
1260 (while (and field-start
1261 (setq field-end (text-property-not-all
1262 field-start header-end
1264 ;; If the invisible text is not terminated with newline, we
1265 ;; won't expose it. Because it may be created by x-face-mule.
1266 ;; BTW, XEmacs sometimes fail in putting a invisible text
1267 ;; property with `gnus-article-hide-text' (really?). In that
1268 ;; case, the invisible text might be started from the middle of
1269 ;; a line so we will expose the sort of thing.
1270 (when (or (not (or (eq header-start field-start)
1271 (eq ?\n (char-before field-start))))
1272 (eq ?\n (char-before field-end)))
1273 (remove-text-properties field-start field-end
1274 gnus-hidden-properties)
1275 (put-text-property field-start field-end
1276 'exposed-invisible-field t))
1277 (setq field-start (text-property-any field-end header-end
1280 (not (eq 'always-show force))
1281 (narrow-to-region header-start header-end)
1282 (article-hide-headers)
1283 ;; Re-display X-Face image under XEmacs.
1284 (when (and gnus-xemacs
1285 (gnus-functionp gnus-article-x-face-command))
1286 (let ((func (cadr (assq 'gnus-treat-display-xface
1287 gnus-treatment-function-alist)))
1290 (gnus-treat-predicate gnus-treat-display-xface))
1292 (put-text-property header-start header-end 'read-only nil))))
1295 (goto-char (point-min))
1297 (set-window-start window (point-min))))))
1299 (defvar gnus-article-normalized-header-length 40
1300 "Length of normalized headers.")
1302 (defun article-normalize-headers ()
1303 "Make all header lines 40 characters long."
1305 (let ((buffer-read-only nil)
1309 (article-narrow-to-head)
1312 ((< (setq column (- (gnus-point-at-eol) (point)))
1313 gnus-article-normalized-header-length)
1315 (insert (make-string
1316 (- gnus-article-normalized-header-length column)
1318 ((> column gnus-article-normalized-header-length)
1319 (gnus-put-text-property
1321 (forward-char gnus-article-normalized-header-length)
1328 (forward-line 1))))))
1330 (defun article-treat-dumbquotes ()
1331 "Translate M******** sm*rtq**t*s into proper text.
1332 Note that this function guesses whether a character is a sm*rtq**t* or
1333 not, so it should only be used interactively."
1335 (article-translate-strings gnus-article-dumbquotes-map))
1337 (defun article-translate-characters (from to)
1338 "Translate all characters in the body of the article according to FROM and TO.
1339 FROM is a string of characters to translate from; to is a string of
1340 characters to translate to."
1342 (when (article-goto-body)
1343 (let ((buffer-read-only nil)
1344 (x (make-string 225 ?x))
1346 (while (< (incf i) (length x))
1349 (while (< i (length from))
1350 (aset x (aref from i) (aref to i))
1352 (translate-region (point) (point-max) x)))))
1354 (defun article-translate-strings (map)
1355 "Translate all string in the body of the article according to MAP.
1356 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1358 (when (article-goto-body)
1359 (let ((buffer-read-only nil)
1361 (while (setq elem (pop map))
1363 (while (search-forward (car elem) nil t)
1364 (replace-match (cadr elem)))))))))
1366 (defun article-treat-overstrike ()
1367 "Translate overstrikes into bold text."
1370 (when (article-goto-body)
1371 (let ((buffer-read-only nil))
1372 (while (search-forward "\b" nil t)
1373 (let ((next (char-after))
1374 (previous (char-after (- (point) 2))))
1375 ;; We do the boldification/underlining by hiding the
1376 ;; overstrikes and putting the proper text property
1380 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1381 (put-text-property (point) (1+ (point)) 'face 'bold))
1383 (gnus-article-hide-text-type
1384 (1- (point)) (1+ (point)) 'overstrike)
1386 (- (point) 2) (1- (point)) 'face 'underline))
1388 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1390 (point) (1+ (point)) 'face 'underline)))))))))
1392 (defun article-fill-long-lines ()
1393 "Fill lines that are wider than the window width."
1396 (let ((buffer-read-only nil)
1397 (width (window-width (get-buffer-window (current-buffer)))))
1400 (let ((adaptive-fill-mode nil))
1403 (when (>= (current-column) (min fill-column width))
1404 (narrow-to-region (point) (gnus-point-at-bol))
1405 (fill-paragraph nil)
1406 (goto-char (point-max))
1408 (forward-line 1)))))))
1410 (defun article-capitalize-sentences ()
1411 "Capitalize the first word in each sentence."
1414 (let ((buffer-read-only nil)
1415 (paragraph-start "^[\n\^L]"))
1419 (forward-sentence)))))
1421 (defun article-remove-cr ()
1422 "Remove trailing CRs and then translate remaining CRs into LFs."
1425 (let ((buffer-read-only nil))
1426 (goto-char (point-min))
1427 (while (re-search-forward "\r+$" nil t)
1428 (replace-match "" t t))
1429 (goto-char (point-min))
1430 (while (search-forward "\r" nil t)
1431 (replace-match "\n" t t)))))
1433 (defun article-remove-trailing-blank-lines ()
1434 "Remove all trailing blank lines from the article."
1437 (let ((buffer-read-only nil))
1438 (goto-char (point-max))
1442 (while (and (not (bobp))
1443 (looking-at "^[ \t]*$")
1444 (not (gnus-annotation-in-region-p
1445 (point) (gnus-point-at-eol))))
1450 (defun article-display-x-face (&optional force)
1451 "Look for an X-Face header and display it if present."
1452 (interactive (list 'force))
1454 ;; Delete the old process, if any.
1455 (when (process-status "article-x-face")
1456 (delete-process "article-x-face"))
1457 (let ((inhibit-point-motion-hooks t)
1458 (case-fold-search t)
1461 (article-narrow-to-head)
1462 (goto-char (point-min))
1463 (setq from (message-fetch-field "from"))
1464 (goto-char (point-min))
1465 (while (and gnus-article-x-face-command
1468 ;; Check whether this face is censored.
1469 (not gnus-article-x-face-too-ugly)
1470 (and gnus-article-x-face-too-ugly from
1471 (not (string-match gnus-article-x-face-too-ugly
1473 ;; Has to be present.
1474 (re-search-forward "^X-Face: " nil t))
1475 ;; This used to try to do multiple faces (`while' instead of
1476 ;; `when' above), but (a) sending multiple EOFs to xv doesn't
1477 ;; work (b) it can crash some versions of Emacs (c) are
1478 ;; multiple faces really something to encourage?
1479 (when (stringp gnus-article-x-face-command)
1481 ;; We now have the area of the buffer where the X-Face is stored.
1484 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
1485 ;; We display the face.
1486 (if (symbolp gnus-article-x-face-command)
1487 ;; The command is a lisp function, so we call it.
1488 (if (gnus-functionp gnus-article-x-face-command)
1489 (funcall gnus-article-x-face-command beg end)
1490 (error "%s is not a function" gnus-article-x-face-command))
1491 ;; The command is a string, so we interpret the command
1492 ;; as a, well, command, and fork it off.
1493 (let ((process-connection-type nil))
1494 (process-kill-without-query
1496 "article-x-face" nil shell-file-name shell-command-switch
1497 gnus-article-x-face-command))
1498 (process-send-region "article-x-face" beg end)
1499 (process-send-eof "article-x-face"))))))))))
1501 (defun article-decode-mime-words ()
1502 "Decode all MIME-encoded words in the article."
1505 (set-buffer gnus-article-buffer)
1506 (let ((inhibit-point-motion-hooks t)
1508 (mail-parse-charset gnus-newsgroup-charset)
1509 (mail-parse-ignored-charsets
1510 (save-excursion (set-buffer gnus-summary-buffer)
1511 gnus-newsgroup-ignored-charsets)))
1512 (mail-decode-encoded-word-region (point-min) (point-max)))))
1514 (defun article-decode-charset (&optional prompt)
1515 "Decode charset-encoded text in the article.
1516 If PROMPT (the prefix), prompt for a coding system to use."
1520 (article-narrow-to-head)
1521 (let* ((inhibit-point-motion-hooks t)
1522 (case-fold-search t)
1523 (ct (message-fetch-field "Content-Type" t))
1524 (cte (message-fetch-field "Content-Transfer-Encoding" t))
1525 (ctl (and ct (ignore-errors
1526 (mail-header-parse-content-type ct))))
1529 (mm-read-coding-system "Charset to decode: "))
1531 (mail-content-type-get ctl 'charset))))
1532 (mail-parse-charset gnus-newsgroup-charset)
1533 (mail-parse-ignored-charsets
1534 (save-excursion (set-buffer gnus-summary-buffer)
1535 gnus-newsgroup-ignored-charsets))
1537 (goto-char (point-max))
1540 (narrow-to-region (point) (point-max))
1541 (when (and (or (not ctl)
1542 (equal (car ctl) "text/plain"))
1545 charset (and cte (intern (downcase
1546 (gnus-strip-whitespace cte))))
1549 (defun article-decode-encoded-words ()
1550 "Remove encoded-word encoding from headers."
1551 (let (buffer-read-only)
1552 (let ((charset (save-excursion
1553 (set-buffer gnus-summary-buffer)
1554 default-mime-charset)))
1555 (mime-decode-header-in-buffer charset)
1558 (defun article-de-quoted-unreadable (&optional force)
1559 "Translate a quoted-printable-encoded article.
1560 If FORCE, decode the article whether it is marked as quoted-printable
1562 (interactive (list 'force))
1564 (let ((buffer-read-only nil)
1565 (type (gnus-fetch-field "content-transfer-encoding"))
1566 (charset gnus-newsgroup-charset))
1568 (and type (string-match "quoted-printable" (downcase type))))
1571 (narrow-to-region (point) (point-max))
1572 (quoted-printable-decode-region (point-min) (point-max))
1574 (mm-decode-body charset)))))))
1576 (defun article-hide-pgp ()
1577 "Remove any PGP headers and signatures in the current article."
1581 (let ((inhibit-point-motion-hooks t)
1582 buffer-read-only beg end)
1584 ;; Hide the "header".
1585 (when (re-search-forward "^-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
1586 (push 'pgp gnus-article-wash-types)
1587 (delete-region (match-beginning 0) (match-end 0))
1588 ;; PGP 5 and GNU PG add a `Hash: <>' comment, hide that too
1589 (when (looking-at "Hash:.*$")
1590 (delete-region (point) (1+ (gnus-point-at-eol))))
1592 ;; Hide the actual signature.
1593 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
1594 (setq end (1+ (match-beginning 0)))
1597 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
1599 ;; Perhaps we shouldn't hide to the end of the buffer
1600 ;; if there is no end to the signature?
1602 ;; Hide "- " PGP quotation markers.
1604 (narrow-to-region beg end)
1605 (goto-char (point-min))
1606 (while (re-search-forward "^- " nil t)
1608 (match-beginning 0) (match-end 0)))
1610 (gnus-run-hooks 'gnus-article-hide-pgp-hook))))))
1612 (defun article-hide-pem (&optional arg)
1613 "Toggle hiding of any PEM headers and signatures in the current article.
1614 If given a negative prefix, always show; if given a positive prefix,
1616 (interactive (gnus-article-hidden-arg))
1617 (unless (gnus-article-check-hidden-text 'pem arg)
1619 (let (buffer-read-only end)
1620 (goto-char (point-min))
1621 ;; Hide the horrendously ugly "header".
1622 (when (and (search-forward
1623 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
1625 (setq end (1+ (match-beginning 0))))
1626 (push 'pem gnus-article-wash-types)
1627 (gnus-article-hide-text-type
1629 (if (search-forward "\n\n" nil t)
1633 ;; Hide the trailer as well
1634 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
1636 (gnus-article-hide-text-type
1637 (match-beginning 0) (match-end 0) 'pem)))))))
1639 (defun article-strip-banner ()
1640 "Strip the banner specified by the `banner' group parameter."
1644 (let ((inhibit-point-motion-hooks t)
1645 (banner (gnus-group-get-parameter gnus-newsgroup-name 'banner))
1646 (gnus-signature-limit nil)
1647 buffer-read-only beg end)
1651 ((eq banner 'signature)
1652 (when (gnus-article-narrow-to-signature)
1655 (delete-region (point) (point-max))))
1657 (while (re-search-forward banner nil t)
1658 (delete-region (match-beginning 0) (match-end 0))))))))))
1660 (defun article-babel-prompt ()
1661 "Prompt for a babel translation."
1663 (completing-read "Translate from: "
1664 babel-translations nil t
1665 (car (car babel-translations))
1668 (defun article-babel (translation)
1669 "Translate article according to TRANSLATION using babelfish."
1670 (interactive (list (article-babel-prompt)))
1673 (set-buffer gnus-article-buffer)
1674 (when (article-goto-body)
1675 (let* ((buffer-read-only nil)
1678 (msg (buffer-substring start end)))
1680 (narrow-to-region start end)
1681 (delete-region start end)
1682 (babel-fetch msg (cdr (assoc translation babel-translations)))
1684 (narrow-to-region start (point-max))
1687 (defun article-hide-signature (&optional arg)
1688 "Hide the signature in the current article.
1689 If given a negative prefix, always show; if given a positive prefix,
1691 (interactive (gnus-article-hidden-arg))
1692 (unless (gnus-article-check-hidden-text 'signature arg)
1695 (let ((buffer-read-only nil))
1696 (when (gnus-article-narrow-to-signature)
1697 (gnus-article-hide-text-type
1698 (point-min) (point-max) 'signature)))))))
1700 (defun article-strip-headers-in-body ()
1701 "Strip offensive headers from bodies."
1705 (let ((case-fold-search t))
1706 (when (looking-at "x-no-archive:")
1707 (gnus-delete-line)))))
1709 (defun article-strip-leading-blank-lines ()
1710 "Remove all blank lines from the beginning of the article."
1713 (let ((inhibit-point-motion-hooks t)
1715 (when (article-goto-body)
1716 (while (and (not (eobp))
1717 (looking-at "[ \t]*$"))
1718 (gnus-delete-line))))))
1720 (defun article-narrow-to-head ()
1721 "Narrow the buffer to the head of the message.
1722 Point is left at the beginning of the narrowed-to region."
1724 (goto-char (point-min))
1725 (if (search-forward "\n\n" nil 1)
1728 (goto-char (point-min)))
1730 (defun article-goto-body ()
1731 "Place point at the start of the body."
1732 (goto-char (point-min))
1734 ;; This variable is only bound when dealing with separate
1736 (article-goto-body-goes-to-point-min-p
1738 ((search-forward "\n\n" nil t)
1741 (goto-char (point-max))
1744 (defun article-strip-multiple-blank-lines ()
1745 "Replace consecutive blank lines with one empty line."
1748 (let ((inhibit-point-motion-hooks t)
1750 ;; First make all blank lines empty.
1752 (while (re-search-forward "^[ \t]+$" nil t)
1753 (unless (gnus-annotation-in-region-p
1754 (match-beginning 0) (match-end 0))
1755 (replace-match "" nil t)))
1756 ;; Then replace multiple empty lines with a single empty line.
1758 (while (re-search-forward "\n\n\n+" nil t)
1759 (unless (gnus-annotation-in-region-p
1760 (match-beginning 0) (match-end 0))
1761 (replace-match "\n\n" t t))))))
1763 (defun article-strip-leading-space ()
1764 "Remove all white space from the beginning of the lines in the article."
1767 (let ((inhibit-point-motion-hooks t)
1770 (while (re-search-forward "^[ \t]+" nil t)
1771 (replace-match "" t t)))))
1773 (defun article-strip-trailing-space ()
1774 "Remove all white space from the end of the lines in the article."
1777 (let ((inhibit-point-motion-hooks t)
1780 (while (re-search-forward "[ \t]+$" nil t)
1781 (replace-match "" t t)))))
1783 (defun article-strip-blank-lines ()
1784 "Strip leading, trailing and multiple blank lines."
1786 (article-strip-leading-blank-lines)
1787 (article-remove-trailing-blank-lines)
1788 (article-strip-multiple-blank-lines))
1790 (defun article-strip-all-blank-lines ()
1791 "Strip all blank lines."
1794 (let ((inhibit-point-motion-hooks t)
1797 (while (re-search-forward "^[ \t]*\n" nil t)
1798 (replace-match "" t t)))))
1800 (defun gnus-article-narrow-to-signature ()
1801 "Narrow to the signature; return t if a signature is found, else nil."
1802 (let ((inhibit-point-motion-hooks t))
1803 (when (gnus-article-search-signature)
1805 ;; Check whether we have some limits to what we consider
1806 ;; to be a signature.
1807 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
1808 (list gnus-signature-limit)))
1810 (while (setq limit (pop limits))
1811 (if (or (and (integerp limit)
1812 (< (- (point-max) (point)) limit))
1814 (< (count-lines (point) (point-max)) limit))
1815 (and (gnus-functionp limit)
1817 (and (stringp limit)
1818 (not (re-search-forward limit nil t))))
1819 () ; This limit did not succeed.
1823 (narrow-to-region (point) (point-max))
1826 (defun gnus-article-search-signature ()
1827 "Search the current buffer for the signature separator.
1828 Put point at the beginning of the signature separator."
1829 (let ((cur (point)))
1830 (goto-char (point-max))
1831 (if (if (stringp gnus-signature-separator)
1832 (re-search-backward gnus-signature-separator nil t)
1833 (let ((seps gnus-signature-separator))
1835 (not (re-search-backward (car seps) nil t)))
1842 (defun gnus-article-hidden-arg ()
1843 "Return the current prefix arg as a number, or 0 if no prefix."
1844 (list (if current-prefix-arg
1845 (prefix-numeric-value current-prefix-arg)
1848 (defun gnus-article-check-hidden-text (type arg)
1849 "Return nil if hiding is necessary.
1850 Arg can be nil or a number. Nil and positive means hide, negative
1851 means show, 0 means toggle."
1854 (let ((hide (gnus-article-hidden-text-p type)))
1860 (gnus-article-show-hidden-text type))
1862 (if (eq hide 'hidden)
1863 (gnus-article-show-hidden-text type)
1866 (defun gnus-article-hidden-text-p (type)
1867 "Say whether the current buffer contains hidden text of type TYPE."
1868 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
1870 (not (get-text-property pos 'invisible))
1871 (not (get-text-property pos 'dummy-invisible)))
1873 (text-property-any (1+ pos) (point-max) 'article-type type)))
1878 (defun gnus-article-show-hidden-text (type &optional hide)
1879 "Show all hidden text of type TYPE.
1880 If HIDE, hide the text instead."
1882 (let ((buffer-read-only nil)
1883 (inhibit-point-motion-hooks t)
1886 (while (setq beg (text-property-any end (point-max) 'article-type type))
1889 (text-property-not-all beg (point-max) 'article-type type)
1892 (gnus-article-hide-text beg end gnus-hidden-properties)
1893 (gnus-article-unhide-text beg end))
1897 (defconst article-time-units
1898 `((year . ,(* 365.25 24 60 60))
1899 (week . ,(* 7 24 60 60))
1900 (day . ,(* 24 60 60))
1904 "Mapping from time units to seconds.")
1906 (defun article-date-ut (&optional type highlight header)
1907 "Convert DATE date to universal time in the current article.
1908 If TYPE is `local', convert to local time; if it is `lapsed', output
1909 how much time has lapsed since DATE. For `lapsed', the value of
1910 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
1911 should replace the \"Date:\" one, or should be added below it."
1912 (interactive (list 'ut t))
1913 (let* ((header (or header
1914 (and (eq 1 (point-min))
1915 (mail-header-date (save-excursion
1916 (set-buffer gnus-summary-buffer)
1917 gnus-current-headers)))
1918 (message-fetch-field "date")
1920 (date (if (vectorp header) (mail-header-date header)
1922 (inhibit-point-motion-hooks t)
1923 bface eface date-pos)
1924 (when (and date (not (string= date "")))
1927 (article-narrow-to-head)
1928 (when (or (and (eq type 'lapsed)
1929 gnus-article-date-lapsed-new-header
1930 ;; Attempt to get the face of X-Sent first.
1931 (re-search-forward "^X-Sent:[ \t]" nil t))
1932 (re-search-forward "^Date:[ \t]" nil t)
1933 ;; If Date is missing, try again for X-Sent.
1934 (re-search-forward "^X-Sent:[ \t]" nil t))
1935 (setq bface (get-text-property (gnus-point-at-bol) 'face)
1936 eface (get-text-property (1- (gnus-point-at-eol))
1938 (let ((buffer-read-only nil))
1939 ;; Delete any old X-Sent headers.
1940 (when (setq date-pos
1941 (text-property-any (point-min) (point-max)
1942 'article-date-lapsed t))
1943 (goto-char (setq date-pos (set-marker (make-marker) date-pos)))
1944 (delete-region (match-beginning 0)
1945 (progn (forward-line 1) (point))))
1946 (goto-char (point-min))
1947 ;; Delete any old Date headers.
1948 (while (re-search-forward "^Date:[ \t]" nil t)
1950 (setq date-pos (match-beginning 0)))
1951 (unless (and (eq type 'lapsed)
1952 gnus-article-date-lapsed-new-header)
1953 (delete-region (match-beginning 0)
1954 (progn (message-next-header) (point)))))
1957 (goto-char date-pos)
1959 ;; Possibly, Date has been deleted.
1961 (when (and (eq type 'lapsed)
1962 gnus-article-date-lapsed-new-header
1963 (looking-at "Date:"))
1965 (goto-char (point-min)))
1966 (insert (article-make-date-line date type))
1967 (when (eq type 'lapsed)
1968 (put-text-property (gnus-point-at-bol) (point)
1969 'article-date-lapsed t))
1973 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
1974 (put-text-property (match-beginning 1) (1+ (match-end 1))
1976 (put-text-property (match-beginning 2) (match-end 2)
1979 (defun article-make-date-line (date type)
1980 "Return a DATE line of TYPE."
1981 (let ((time (condition-case ()
1985 ;; Convert to the local timezone. We have to slap a
1986 ;; `condition-case' round the calls to the timezone
1987 ;; functions since they aren't particularly resistant to
1990 (let ((tz (car (current-time-zone))))
1991 (format "Date: %s %s%02d%02d" (current-time-string time)
1992 (if (> tz 0) "+" "-") (/ tz 3600) (/ (% tz 3600) 60))))
1993 ;; Convert to Universal Time.
1996 (current-time-string
1997 (let* ((e (parse-time-string date))
1998 (tm (apply 'encode-time e))
2000 (ls (- (cadr tm) (car (current-time-zone)))))
2001 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2002 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2005 ;; Get the original date from the article.
2006 ((eq type 'original)
2007 (concat "Date: " (if (string-match "\n+$" date)
2008 (substring date 0 (match-beginning 0))
2010 ;; Let the user define the format.
2012 (if (gnus-functionp gnus-article-time-format)
2013 (funcall gnus-article-time-format time)
2016 (format-time-string gnus-article-time-format time))))
2021 (format-time-string "%Y%m%dT%H%M%S" time)))
2022 ;; Do an X-Sent lapsed format.
2024 ;; If the date is seriously mangled, the timezone functions are
2025 ;; liable to bug out, so we ignore all errors.
2026 (let* ((now (current-time))
2027 (real-time (subtract-time now time))
2028 (real-sec (and real-time
2029 (+ (* (float (car real-time)) 65536)
2031 (sec (and real-time (abs real-sec)))
2041 ;; This is a bit convoluted, but basically we go
2042 ;; through the time units for years, weeks, etc,
2043 ;; and divide things to see whether that results
2044 ;; in positive answers.
2047 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2048 ;; The (remaining) seconds are too few to
2049 ;; be divided into this time unit.
2051 ;; It's big enough, so we output it.
2052 (setq sec (- sec (* num (cdr unit))))
2054 (concat (if prev ", " "") (int-to-string
2056 " " (symbol-name (car unit))
2057 (if (> num 1) "s" ""))
2059 article-time-units "")
2060 ;; If dates are odd, then it might appear like the
2061 ;; article was sent in the future.
2064 " in the future"))))))
2066 (error "Unknown conversion type: %s" type)))))
2068 (defun article-date-local (&optional highlight)
2069 "Convert the current article date to the local timezone."
2070 (interactive (list t))
2071 (article-date-ut 'local highlight))
2073 (defun article-date-original (&optional highlight)
2074 "Convert the current article date to what it was originally.
2075 This is only useful if you have used some other date conversion
2076 function and want to see what the date was before converting."
2077 (interactive (list t))
2078 (article-date-ut 'original highlight))
2080 (defun article-date-lapsed (&optional highlight)
2081 "Convert the current article date to time lapsed since it was sent."
2082 (interactive (list t))
2083 (article-date-ut 'lapsed highlight))
2085 (defun article-update-date-lapsed ()
2086 "Function to be run from a timer to update the lapsed time line."
2087 (let (deactivate-mark)
2092 (set-buffer (window-buffer w))
2093 (when (eq major-mode 'gnus-article-mode)
2094 (goto-char (point-min))
2095 (when (re-search-forward "^X-Sent:" nil t)
2096 (article-date-lapsed t))))
2099 (defun gnus-start-date-timer (&optional n)
2100 "Start a timer to update the X-Sent header in the article buffers.
2101 The numerical prefix says how frequently (in seconds) the function
2106 (gnus-stop-date-timer)
2107 (setq article-lapsed-timer
2108 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2110 (defun gnus-stop-date-timer ()
2111 "Stop the X-Sent timer."
2113 (when article-lapsed-timer
2114 (nnheader-cancel-timer article-lapsed-timer)
2115 (setq article-lapsed-timer nil)))
2117 (defun article-date-user (&optional highlight)
2118 "Convert the current article date to the user-defined format.
2119 This format is defined by the `gnus-article-time-format' variable."
2120 (interactive (list t))
2121 (article-date-ut 'user highlight))
2123 (defun article-date-iso8601 (&optional highlight)
2124 "Convert the current article date to ISO8601."
2125 (interactive (list t))
2126 (article-date-ut 'iso8601 highlight))
2128 (defun article-show-all ()
2129 "Show all hidden text in the article buffer."
2132 (let ((buffer-read-only nil))
2133 (gnus-article-unhide-text (point-min) (point-max)))))
2135 (defun article-emphasize (&optional arg)
2136 "Emphasize text according to `gnus-emphasis-alist'."
2137 (interactive (gnus-article-hidden-arg))
2138 (unless (gnus-article-check-hidden-text 'emphasis arg)
2140 (let ((alist (or (with-current-buffer gnus-summary-buffer
2141 gnus-article-emphasis-alist)
2142 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 (defun gnus-article-setup-highlight-words (&optional highlight-words)
2166 "Setup newsgroup emphasis alist."
2167 (unless gnus-article-emphasis-alist
2168 (let ((name (and gnus-newsgroup-name
2169 (gnus-group-real-name gnus-newsgroup-name))))
2170 (make-local-variable 'gnus-article-emphasis-alist)
2171 (setq gnus-article-emphasis-alist
2173 (let ((alist gnus-group-highlight-words-alist) elem highlight)
2174 (while (setq elem (pop alist))
2175 (when (and name (string-match (car elem) name))
2177 highlight (copy-list (cdr elem)))))
2179 (copy-list highlight-words)
2180 (if gnus-newsgroup-name
2181 (copy-list (gnus-group-find-parameter
2182 gnus-newsgroup-name 'highlight-words t)))
2183 gnus-emphasis-alist)))))
2185 (defvar gnus-summary-article-menu)
2186 (defvar gnus-summary-post-menu)
2188 ;;; Saving functions.
2190 (defun gnus-article-save (save-buffer file &optional num)
2191 "Save the currently selected article."
2192 (unless gnus-save-all-headers
2193 ;; Remove headers according to `gnus-saved-headers'.
2194 (let ((gnus-visible-headers
2195 (or gnus-saved-headers gnus-visible-headers))
2196 (gnus-article-buffer save-buffer))
2198 (set-buffer save-buffer)
2199 (article-hide-headers 1 t))))
2200 (save-window-excursion
2201 (if (not gnus-default-article-saver)
2202 (error "No default saver is defined")
2203 ;; !!! Magic! The saving functions all save
2204 ;; `gnus-save-article-buffer' (or so they think), but we
2205 ;; bind that variable to our save-buffer.
2206 (set-buffer gnus-article-buffer)
2207 (let* ((gnus-save-article-buffer save-buffer)
2210 ((not gnus-prompt-before-saving) 'default)
2211 ((eq gnus-prompt-before-saving 'always) nil)
2213 (gnus-number-of-articles-to-be-saved
2214 (when (eq gnus-prompt-before-saving t)
2216 (set-buffer gnus-article-current-summary)
2217 (funcall gnus-default-article-saver filename)))))
2219 (defun gnus-read-save-file-name (prompt &optional filename
2220 function group headers variable)
2222 (funcall function group headers (symbol-value variable)))
2227 ((eq filename 'default)
2233 (let* ((split-name (gnus-get-split-value gnus-split-methods))
2236 (if (and gnus-number-of-articles-to-be-saved
2237 (> gnus-number-of-articles-to-be-saved 1))
2238 (format "these %d articles"
2239 gnus-number-of-articles-to-be-saved)
2242 ;; Let the split methods have their say.
2244 ;; No split name was found.
2247 (concat prompt " (default "
2248 (file-name-nondirectory default-name) ") ")
2249 (file-name-directory default-name)
2251 ;; A single group name is returned.
2252 ((stringp split-name)
2254 (funcall function split-name headers
2255 (symbol-value variable)))
2257 (concat prompt " (default "
2258 (file-name-nondirectory default-name) ") ")
2259 (file-name-directory default-name)
2261 ;; A single split name was found
2262 ((= 1 (length split-name))
2263 (let* ((name (expand-file-name
2264 (car split-name) gnus-article-save-directory))
2265 (dir (cond ((file-directory-p name)
2266 (file-name-as-directory name))
2267 ((file-exists-p name) name)
2268 (t gnus-article-save-directory))))
2270 (concat prompt " (default " name ") ")
2272 ;; A list of splits was found.
2274 (setq split-name (nreverse split-name))
2276 (let ((file-name-history
2277 (nconc split-name file-name-history)))
2281 (concat prompt " (`M-p' for defaults) ")
2282 gnus-article-save-directory
2284 gnus-article-save-directory)))
2285 (car (push result file-name-history)))))))
2286 ;; Create the directory.
2287 (gnus-make-directory (file-name-directory file))
2288 ;; If we have read a directory, we append the default file name.
2289 (when (file-directory-p file)
2290 (setq file (concat (file-name-as-directory file)
2291 (file-name-nondirectory default-name))))
2292 ;; Possibly translate some characters.
2293 (nnheader-translate-file-chars file)))))
2294 (gnus-make-directory (file-name-directory result))
2295 (set variable result)))
2297 (defun gnus-article-archive-name (group)
2298 "Return the first instance of an \"Archive-name\" in the current buffer."
2299 (let ((case-fold-search t))
2300 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
2301 (nnheader-concat gnus-article-save-directory
2302 (match-string 1)))))
2304 (defun gnus-article-nndoc-name (group)
2305 "If GROUP is an nndoc group, return the name of the parent group."
2306 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
2307 (gnus-group-get-parameter group 'save-article-group)))
2309 (defun gnus-summary-save-in-rmail (&optional filename)
2310 "Append this article to Rmail file.
2311 Optional argument FILENAME specifies file name.
2312 Directory to save to is default to `gnus-article-save-directory'."
2313 (setq filename (gnus-read-save-file-name
2314 "Save %s in rmail file:" filename
2315 gnus-rmail-save-name gnus-newsgroup-name
2316 gnus-current-headers 'gnus-newsgroup-last-rmail))
2317 (gnus-eval-in-buffer-window gnus-save-article-buffer
2321 (gnus-output-to-rmail filename))))
2324 (defun gnus-summary-save-in-mail (&optional filename)
2325 "Append this article to Unix mail file.
2326 Optional argument FILENAME specifies file name.
2327 Directory to save to is default to `gnus-article-save-directory'."
2328 (setq filename (gnus-read-save-file-name
2329 "Save %s in Unix mail file:" filename
2330 gnus-mail-save-name gnus-newsgroup-name
2331 gnus-current-headers 'gnus-newsgroup-last-mail))
2332 (gnus-eval-in-buffer-window gnus-save-article-buffer
2336 (if (and (file-readable-p filename)
2337 (mail-file-babyl-p filename))
2338 (rmail-output-to-rmail-file filename t)
2339 (gnus-output-to-mail filename)))))
2342 (defun gnus-summary-save-in-file (&optional filename overwrite)
2343 "Append this article to file.
2344 Optional argument FILENAME specifies file name.
2345 Directory to save to is default to `gnus-article-save-directory'."
2346 (setq filename (gnus-read-save-file-name
2347 "Save %s in file:" filename
2348 gnus-file-save-name gnus-newsgroup-name
2349 gnus-current-headers 'gnus-newsgroup-last-file))
2350 (gnus-eval-in-buffer-window gnus-save-article-buffer
2354 (when (and overwrite
2355 (file-exists-p filename))
2356 (delete-file filename))
2357 (gnus-output-to-file filename))))
2360 (defun gnus-summary-write-to-file (&optional filename)
2361 "Write this article to a file.
2362 Optional argument FILENAME specifies file name.
2363 The directory to save in defaults to `gnus-article-save-directory'."
2364 (gnus-summary-save-in-file nil t))
2366 (defun gnus-summary-save-body-in-file (&optional filename)
2367 "Append this article body to a file.
2368 Optional argument FILENAME specifies file name.
2369 The directory to save in defaults to `gnus-article-save-directory'."
2370 (setq filename (gnus-read-save-file-name
2371 "Save %s body in file:" filename
2372 gnus-file-save-name gnus-newsgroup-name
2373 gnus-current-headers 'gnus-newsgroup-last-file))
2374 (gnus-eval-in-buffer-window gnus-save-article-buffer
2378 (when (article-goto-body)
2379 (narrow-to-region (point) (point-max)))
2380 (gnus-output-to-file filename))))
2383 (defun gnus-summary-save-in-pipe (&optional command)
2384 "Pipe this article to subprocess."
2386 (cond ((and (eq command 'default)
2387 gnus-last-shell-command)
2388 gnus-last-shell-command)
2392 "Shell command on %s: "
2393 (if (and gnus-number-of-articles-to-be-saved
2394 (> gnus-number-of-articles-to-be-saved 1))
2395 (format "these %d articles"
2396 gnus-number-of-articles-to-be-saved)
2398 gnus-last-shell-command))))
2399 (when (string-equal command "")
2400 (setq command gnus-last-shell-command))
2401 (gnus-eval-in-buffer-window gnus-article-buffer
2404 (shell-command-on-region (point-min) (point-max) command nil)))
2405 (setq gnus-last-shell-command command))
2407 ;;; Article file names when saving.
2409 (defun gnus-capitalize-newsgroup (newsgroup)
2410 "Capitalize NEWSGROUP name."
2411 (when (not (zerop (length newsgroup)))
2412 (concat (char-to-string (upcase (aref newsgroup 0)))
2413 (substring newsgroup 1))))
2415 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2416 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2417 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
2418 Otherwise, it is like ~/News/news/group/num."
2421 (concat (if (gnus-use-long-file-name 'not-save)
2422 (gnus-capitalize-newsgroup newsgroup)
2423 (gnus-newsgroup-directory-form newsgroup))
2424 "/" (int-to-string (mail-header-number headers)))
2425 gnus-article-save-directory)))
2427 (string-equal (file-name-directory default)
2428 (file-name-directory last-file))
2429 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2431 (or last-file default))))
2433 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2434 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2435 If variable `gnus-use-long-file-name' is non-nil, it is
2436 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2439 (concat (if (gnus-use-long-file-name 'not-save)
2441 (gnus-newsgroup-directory-form newsgroup))
2442 "/" (int-to-string (mail-header-number headers)))
2443 gnus-article-save-directory)))
2445 (string-equal (file-name-directory default)
2446 (file-name-directory last-file))
2447 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2449 (or last-file default))))
2451 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
2452 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2453 If variable `gnus-use-long-file-name' is non-nil, it is
2454 ~/News/News.group. Otherwise, it is like ~/News/news/group/news."
2457 (if (gnus-use-long-file-name 'not-save)
2458 (gnus-capitalize-newsgroup newsgroup)
2459 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2460 gnus-article-save-directory)))
2462 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2463 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2464 If variable `gnus-use-long-file-name' is non-nil, it is
2465 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2468 (if (gnus-use-long-file-name 'not-save)
2470 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2471 gnus-article-save-directory)))
2478 (setq afunc (car func)
2481 gfunc (intern (format "gnus-%s" func))))
2483 (if (not (fboundp afunc))
2485 `(lambda (&optional interactive &rest args)
2486 ,(documentation afunc t)
2487 (interactive (list t))
2489 (set-buffer gnus-article-buffer)
2491 (call-interactively ',afunc)
2492 (apply ',afunc args))))))))
2493 '(article-hide-headers
2494 article-hide-boring-headers
2495 article-toggle-headers
2496 article-treat-overstrike
2497 article-fill-long-lines
2498 article-capitalize-sentences
2500 article-display-x-face
2501 article-de-quoted-unreadable
2503 article-strip-banner
2506 article-hide-signature
2507 article-strip-headers-in-body
2508 article-remove-trailing-blank-lines
2509 article-strip-leading-blank-lines
2510 article-strip-multiple-blank-lines
2511 article-strip-leading-space
2512 article-strip-trailing-space
2513 article-strip-blank-lines
2514 article-strip-all-blank-lines
2516 article-date-iso8601
2517 article-date-original
2519 article-decode-mime-words
2520 article-decode-charset
2521 article-decode-encoded-words
2525 article-treat-dumbquotes
2526 article-normalize-headers
2527 (article-show-all . gnus-article-show-all-headers))))
2530 ;;; Gnus article mode
2533 (put 'gnus-article-mode 'mode-class 'special)
2535 (gnus-define-keys gnus-article-mode-map
2536 " " gnus-article-goto-next-page
2537 "\177" gnus-article-goto-prev-page
2538 [delete] gnus-article-goto-prev-page
2539 [backspace] gnus-article-goto-prev-page
2540 "\C-c^" gnus-article-refer-article
2541 "h" gnus-article-show-summary
2542 "s" gnus-article-show-summary
2543 "\C-c\C-m" gnus-article-mail
2544 "?" gnus-article-describe-briefly
2545 gnus-mouse-2 gnus-article-push-button
2546 "\r" gnus-article-press-button
2547 "\t" gnus-article-next-button
2548 "\M-\t" gnus-article-prev-button
2549 "e" gnus-article-edit
2550 "<" beginning-of-buffer
2552 "\C-c\C-i" gnus-info-find-node
2555 "\C-d" gnus-article-read-summary-keys
2556 "\M-*" gnus-article-read-summary-keys
2557 "\M-#" gnus-article-read-summary-keys
2558 "\M-^" gnus-article-read-summary-keys
2559 "\M-g" gnus-article-read-summary-keys)
2561 ;; Define almost undefined keys to `gnus-article-read-summary-keys'.
2564 (unless (lookup-key gnus-article-mode-map key)
2565 (define-key gnus-article-mode-map key
2566 'gnus-article-read-summary-keys)))
2571 (let ((key (car elt)))
2572 (and (> (length key) 0)
2573 (not (eq 'menu-bar (aref key 0)))
2574 (symbolp (lookup-key gnus-summary-mode-map key))
2576 (accessible-keymaps gnus-summary-mode-map))
2580 (push (char-to-string c) keys)
2584 (defun gnus-article-make-menu-bar ()
2585 (gnus-turn-off-edit-menu 'article)
2586 (unless (boundp 'gnus-article-article-menu)
2588 gnus-article-article-menu gnus-article-mode-map ""
2590 ["Scroll forwards" gnus-article-goto-next-page t]
2591 ["Scroll backwards" gnus-article-goto-prev-page t]
2592 ["Show summary" gnus-article-show-summary t]
2593 ["Fetch Message-ID at point" gnus-article-refer-article t]
2594 ["Mail to address at point" gnus-article-mail t]
2595 ["Send a bug report" gnus-bug t]))
2598 gnus-article-treatment-menu gnus-article-mode-map ""
2600 ["Hide headers" gnus-article-toggle-headers t]
2601 ["Hide signature" gnus-article-hide-signature t]
2602 ["Hide citation" gnus-article-hide-citation t]
2603 ["Treat overstrike" gnus-article-treat-overstrike t]
2604 ["Remove carriage return" gnus-article-remove-cr t]))
2606 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
2608 (when (boundp 'gnus-summary-post-menu)
2609 (define-key gnus-article-mode-map [menu-bar post]
2610 (cons "Post" gnus-summary-post-menu)))
2612 (gnus-run-hooks 'gnus-article-menu-hook)))
2614 (defun gnus-article-mode ()
2615 "Major mode for displaying an article.
2617 All normal editing commands are switched off.
2619 The following commands are available in addition to all summary mode
2621 \\<gnus-article-mode-map>
2622 \\[gnus-article-next-page]\t Scroll the article one page forwards
2623 \\[gnus-article-prev-page]\t Scroll the article one page backwards
2624 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
2625 \\[gnus-article-show-summary]\t Display the summary buffer
2626 \\[gnus-article-mail]\t Send a reply to the address near point
2627 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
2628 \\[gnus-info-find-node]\t Go to the Gnus info node"
2630 (when (gnus-visual-p 'article-menu 'menu)
2631 (gnus-article-make-menu-bar))
2632 (gnus-simplify-mode-line)
2633 (setq mode-name "Article")
2634 (setq major-mode 'gnus-article-mode)
2635 (make-local-variable 'minor-mode-alist)
2636 (unless (assq 'gnus-show-mime minor-mode-alist)
2637 (push (list 'gnus-show-mime " MIME") minor-mode-alist))
2638 (use-local-map gnus-article-mode-map)
2639 (gnus-update-format-specifications nil 'article-mode)
2640 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
2641 (make-local-variable 'gnus-page-broken)
2642 (make-local-variable 'gnus-button-marker-list)
2643 (make-local-variable 'gnus-article-current-summary)
2644 (make-local-variable 'gnus-article-mime-handles)
2645 (make-local-variable 'gnus-article-decoded-p)
2646 (make-local-variable 'gnus-article-mime-handle-alist)
2647 (make-local-variable 'gnus-article-washed-types)
2648 (gnus-set-default-directory)
2649 (buffer-disable-undo)
2650 (setq buffer-read-only t)
2651 (set-syntax-table gnus-article-mode-syntax-table)
2652 (gnus-run-hooks 'gnus-article-mode-hook))
2654 (defun gnus-article-setup-buffer ()
2655 "Initialize the article buffer."
2656 (let* ((name (if gnus-single-article-buffer "*Article*"
2657 (concat "*Article " gnus-newsgroup-name "*")))
2659 (progn (string-match "\\*Article" name)
2660 (concat " *Original Article"
2661 (substring name (match-end 0))))))
2662 (setq gnus-article-buffer name)
2663 (setq gnus-original-article-buffer original)
2664 (setq gnus-article-mime-handle-alist nil)
2665 ;; This might be a variable local to the summary buffer.
2666 (unless gnus-single-article-buffer
2668 (set-buffer gnus-summary-buffer)
2669 (setq gnus-article-buffer name)
2670 (setq gnus-original-article-buffer original)
2671 (gnus-set-global-variables)))
2672 (gnus-article-setup-highlight-words)
2673 ;; Init original article buffer.
2675 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
2676 (setq major-mode 'gnus-original-article-mode)
2677 (make-local-variable 'gnus-original-article))
2678 (if (get-buffer name)
2681 (buffer-disable-undo)
2682 (setq buffer-read-only t)
2683 (unless (eq major-mode 'gnus-article-mode)
2684 (gnus-article-mode))
2687 (set-buffer (gnus-get-buffer-create name))
2689 (make-local-variable 'gnus-summary-buffer)
2690 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2691 (current-buffer)))))
2693 ;; Set article window start at LINE, where LINE is the number of lines
2694 ;; from the head of the article.
2695 (defun gnus-article-set-window-start (&optional line)
2697 (get-buffer-window gnus-article-buffer t)
2699 (set-buffer gnus-article-buffer)
2700 (goto-char (point-min))
2703 (gnus-message 6 "Moved to bookmark")
2704 (search-forward "\n\n" nil t)
2708 ;;; @@ article filters
2711 (defun gnus-article-display-mime-message ()
2712 "Article display method for MIME message."
2713 ;; called from `gnus-original-article-buffer'.
2714 (let (charset all-headers)
2715 (with-current-buffer gnus-summary-buffer
2716 (setq charset default-mime-charset
2717 all-headers gnus-have-all-headers))
2718 (make-local-variable 'default-mime-charset)
2719 (setq default-mime-charset charset)
2720 (with-current-buffer (get-buffer-create gnus-article-buffer)
2721 (make-local-variable 'default-mime-charset)
2722 (setq default-mime-charset charset))
2723 (mime-display-message mime-message-structure
2724 gnus-article-buffer nil gnus-article-mode-map)
2726 (gnus-article-hide-headers nil -1))
2728 ;; `mime-display-message' changes current buffer to `gnus-article-buffer'.
2729 (make-local-variable 'mime-button-mother-dispatcher)
2730 (setq mime-button-mother-dispatcher
2731 (function gnus-article-push-button))
2732 (run-hooks 'gnus-mime-article-prepare-hook))
2734 (defun gnus-article-display-traditional-message ()
2735 "Article display method for traditional message."
2736 (set-buffer gnus-article-buffer)
2737 (let (buffer-read-only)
2739 (insert-buffer-substring gnus-original-article-buffer)))
2741 (defun gnus-article-make-full-mail-header (&optional number charset)
2742 "Create a new mail header structure in a raw article buffer."
2743 (unless (and number charset)
2744 (save-current-buffer
2745 (set-buffer gnus-summary-buffer)
2747 (setq number (or (cdr gnus-article-current) 0)))
2749 (setq charset (or default-mime-charset 'x-ctext)))))
2750 (goto-char (point-min))
2751 (let ((header-end (if (search-forward "\n\n" nil t)
2753 (goto-char (point-max))))
2754 (chars (- (point-max) (point)))
2755 (lines (count-lines (point) (point-max)))
2756 (default-mime-charset charset)
2758 (narrow-to-region (point-min) header-end)
2759 (setq xref (std11-fetch-field "xref"))
2761 (make-full-mail-header
2763 (std11-fetch-field "subject")
2764 (std11-fetch-field "from")
2765 (std11-fetch-field "date")
2766 (std11-fetch-field "message-id")
2767 (std11-fetch-field "references")
2770 (when xref (concat "Xref: " xref)))
2773 (defun gnus-article-prepare (article &optional all-headers header)
2774 "Prepare ARTICLE in article mode buffer.
2775 ARTICLE should either be an article number or a Message-ID.
2776 If ARTICLE is an id, HEADER should be the article headers.
2777 If ALL-HEADERS is non-nil, no headers are hidden."
2779 ;; Make sure we start in a summary buffer.
2780 (unless (eq major-mode 'gnus-summary-mode)
2781 (set-buffer gnus-summary-buffer))
2782 (setq gnus-summary-buffer (current-buffer))
2783 (let* ((gnus-article (if header (mail-header-number header) article))
2784 (summary-buffer (current-buffer))
2785 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
2786 (group gnus-newsgroup-name)
2789 (gnus-article-setup-buffer)
2790 (set-buffer gnus-original-article-buffer)
2791 ;; Deactivate active regions.
2792 (when (and (boundp 'transient-mark-mode)
2793 transient-mark-mode)
2794 (setq mark-active nil))
2795 (if (not (setq result (let ((buffer-read-only nil))
2796 (gnus-request-article-this-buffer
2798 ;; There is no such article.
2800 (when (and (numberp article)
2801 (not (memq article gnus-newsgroup-sparse)))
2802 (setq gnus-article-current
2803 (cons gnus-newsgroup-name article))
2804 (set-buffer gnus-summary-buffer)
2805 (setq gnus-current-article article)
2806 (if (eq (gnus-article-mark article) gnus-undownloaded-mark)
2808 (gnus-summary-set-agent-mark article)
2809 (message "Message marked for downloading"))
2810 (gnus-summary-mark-article article gnus-canceled-mark)
2811 (unless (memq article gnus-newsgroup-sparse)
2813 "No such article (may have expired or been canceled)")))))
2814 (if (or (eq result 'pseudo)
2815 (eq result 'nneething))
2818 (set-buffer summary-buffer)
2819 (push article gnus-newsgroup-history)
2820 (setq gnus-last-article gnus-current-article
2821 gnus-current-article 0
2822 gnus-current-headers nil
2823 gnus-article-current nil)
2824 (if (eq result 'nneething)
2825 (gnus-configure-windows 'summary)
2826 (gnus-configure-windows 'article))
2827 (gnus-set-global-variables))
2828 (let ((gnus-article-mime-handle-alist-1
2829 gnus-article-mime-handle-alist))
2830 (gnus-set-mode-line 'article)))
2831 ;; The result from the `request' was an actual article -
2832 ;; or at least some text that is now displayed in the
2834 (when (and (numberp article)
2835 (not (eq article gnus-current-article)))
2836 ;; Seems like a new article has been selected.
2837 ;; `gnus-current-article' must be an article number.
2839 (set-buffer summary-buffer)
2840 (push article gnus-newsgroup-history)
2841 (setq gnus-last-article gnus-current-article
2842 gnus-current-article article
2843 gnus-current-headers
2844 (gnus-summary-article-header gnus-current-article)
2845 gnus-article-current
2846 (cons gnus-newsgroup-name gnus-current-article))
2847 (unless (vectorp gnus-current-headers)
2848 (setq gnus-current-headers nil))
2849 (gnus-summary-goto-subject gnus-current-article)
2850 (when (gnus-summary-show-thread)
2851 ;; If the summary buffer really was folded, the
2852 ;; previous goto may not actually have gone to
2853 ;; the right article, but the thread root instead.
2855 (gnus-summary-goto-subject gnus-current-article))
2856 (gnus-run-hooks 'gnus-mark-article-hook)
2857 (gnus-set-mode-line 'summary)
2858 (when (gnus-visual-p 'article-highlight 'highlight)
2859 (gnus-run-hooks 'gnus-visual-mark-article-hook))
2860 ;; Set the global newsgroup variables here.
2861 (gnus-set-global-variables)
2862 (setq gnus-have-all-headers
2863 (or all-headers gnus-show-all-headers))))
2864 (when (or (numberp article)
2866 (gnus-article-prepare-display)
2868 (goto-char (point-min))
2869 (setq gnus-page-broken
2870 (when gnus-break-pages
2871 (gnus-narrow-to-page)
2873 (let ((gnus-article-mime-handle-alist-1
2874 gnus-article-mime-handle-alist))
2875 (gnus-set-mode-line 'article))
2877 (set-window-point (get-buffer-window (current-buffer)) (point))
2878 (gnus-configure-windows 'article)
2881 (defun gnus-article-prepare-mime-display (&optional number)
2882 (goto-char (point-min))
2883 (when (re-search-forward "^[^\t ]+:" nil t)
2884 (goto-char (match-beginning 0)))
2885 (let* ((entity (if (eq 1 (point-min))
2886 (get-text-property 1 'mime-view-entity)
2887 (get-text-property (point) 'mime-view-entity)))
2888 (number (or number 0))
2891 (narrow-to-region (point)
2892 (if (search-forward "\n\n" nil t)
2895 (gnus-treat-article 'head)
2896 (put-text-property (point-min) (point-max) 'article-treated-header t)
2897 (goto-char (point-max)))
2898 (while (and (not (eobp))
2900 (setq next (next-single-property-change (point)
2901 'mime-view-entity)))
2902 (setq type (mime-entity-content-type entity)
2903 type (format "%s/%s"
2904 (mime-content-type-primary-type type)
2905 (mime-content-type-subtype type)))
2906 (if (string-equal type "message/rfc822")
2908 (narrow-to-region (point) (point-max))
2909 (gnus-article-prepare-mime-display number)
2910 (goto-char (point-max)))
2911 (setq ids (length (mime-entity-node-id entity))
2912 entity (get-text-property next 'mime-view-entity)
2915 (narrow-to-region (point) next)
2916 (if (or (null entity)
2917 (< (length (mime-entity-node-id entity)) ids))
2918 (gnus-treat-article 'last number number type)
2919 (gnus-treat-article t number nil type))
2920 (goto-char (point-max)))))
2923 (narrow-to-region (point) (point-max))
2926 (setq type (mime-entity-content-type entity)
2927 type (format "%s/%s"
2928 (mime-content-type-primary-type type)
2929 (mime-content-type-subtype type)))
2930 (if (string-equal type "message/rfc822")
2931 (gnus-article-prepare-mime-display number)
2933 (gnus-treat-article 'last number number type)))
2934 (gnus-treat-article t))))))
2937 (defun gnus-article-prepare-display ()
2938 "Make the current buffer look like a nice article."
2939 (gnus-run-hooks 'gnus-tmp-internal-hook)
2940 (gnus-run-hooks 'gnus-article-prepare-hook)
2942 (let (mime-display-header-hook)
2943 (funcall (if gnus-show-mime
2945 (setq mime-message-structure gnus-current-headers)
2946 (mime-buffer-entity-set-buffer-internal
2947 mime-message-structure
2948 gnus-original-article-buffer)
2949 (mime-entity-set-representation-type-internal
2950 mime-message-structure 'mime-buffer-entity)
2951 (luna-send mime-message-structure
2952 'initialize-instance
2953 mime-message-structure)
2954 gnus-article-display-method-for-mime)
2955 gnus-article-display-method-for-traditional)))
2956 ;; Associate this article with the current summary buffer.
2957 (setq gnus-article-current-summary gnus-summary-buffer)
2958 ;; Call the treatment functions.
2959 (let ((inhibit-read-only t)
2964 (gnus-article-prepare-mime-display)
2965 (narrow-to-region (goto-char (point-min))
2966 (if (search-forward "\n\n" nil t)
2969 (gnus-treat-article 'head)
2970 (put-text-property (point-min) (point-max) 'article-treated-header t)
2971 (goto-char (point-max))
2973 (narrow-to-region (point) (point-max))
2974 (gnus-treat-article t))
2975 (put-text-property (point-min) (point-max) 'read-only nil)))
2976 ;; Perform the article display hooks. Incidentally, this hook is
2977 ;; an obsolete variable by now.
2978 (gnus-run-hooks 'gnus-article-display-hook))
2980 (defun gnus-article-decode-article-as-default-mime-charset ()
2981 "Decode an article as `default-mime-charset'. It won't work if the
2982 value of the variable `gnus-show-mime' is non-nil."
2983 (unless gnus-show-mime
2984 (decode-mime-charset-region (point-min) (point-max)
2985 (with-current-buffer gnus-summary-buffer
2986 default-mime-charset))))
2989 ;;; Gnus MIME viewing functions
2992 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
2993 "The following specs can be used:
2995 %T MIME type, along with additional info
2996 %n The `name' parameter
2997 %d The description, if any
2998 %l The length of the encoded part
2999 %p The part identifier number
3000 %e Dots if the part isn't displayed")
3002 (defvar gnus-mime-button-line-format-alist
3003 '((?t gnus-tmp-type ?s)
3004 (?T gnus-tmp-type-long ?s)
3005 (?n gnus-tmp-name ?s)
3006 (?d gnus-tmp-description ?s)
3008 (?l gnus-tmp-length ?d)
3009 (?e gnus-tmp-dots ?s)))
3011 (defvar gnus-mime-button-commands
3012 '((gnus-article-press-button "\r" "Toggle Display")
3013 (gnus-mime-view-part "v" "View Interactively...")
3014 (gnus-mime-view-part-as-type "t" "View As Type...")
3015 (gnus-mime-save-part "o" "Save...")
3016 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
3017 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
3018 (gnus-mime-internalize-part "E" "View Internally")
3019 (gnus-mime-externalize-part "e" "View Externally")
3020 (gnus-mime-pipe-part "|" "Pipe To Command...")))
3022 (defun gnus-article-mime-part-status ()
3023 (if gnus-article-mime-handle-alist-1
3024 (format " (%d parts)" (length gnus-article-mime-handle-alist-1))
3027 (defvar gnus-mime-button-map nil)
3028 (unless gnus-mime-button-map
3029 (setq gnus-mime-button-map (make-sparse-keymap))
3030 (set-keymap-parent gnus-mime-button-map gnus-article-mode-map)
3031 (define-key gnus-mime-button-map gnus-mouse-2 'gnus-article-push-button)
3032 (define-key gnus-mime-button-map gnus-down-mouse-3 'gnus-mime-button-menu)
3034 (define-key gnus-mime-button-map (cadr c) (car c)))
3035 gnus-mime-button-commands))
3037 (defun gnus-mime-button-menu (event)
3038 "Construct a context-sensitive menu of MIME commands."
3041 (let ((pos (event-start event)))
3042 (set-buffer (window-buffer (posn-window pos)))
3043 (goto-char (posn-point pos))
3044 (gnus-article-check-buffer)
3045 (let ((response (x-popup-menu
3047 ("" ,@(mapcar (lambda (c)
3048 (cons (caddr c) (car c)))
3049 gnus-mime-button-commands))))))
3051 (funcall response))))))
3053 (defun gnus-mime-view-all-parts (&optional handles)
3054 "View all the MIME parts."
3056 (save-current-buffer
3057 (set-buffer gnus-article-buffer)
3058 (let ((handles (or handles gnus-article-mime-handles))
3059 (mail-parse-charset gnus-newsgroup-charset)
3060 (mail-parse-ignored-charsets
3061 (save-excursion (set-buffer gnus-summary-buffer)
3062 gnus-newsgroup-ignored-charsets)))
3063 (if (stringp (car handles))
3064 (gnus-mime-view-all-parts (cdr handles))
3065 (mapcar 'mm-display-part handles)))))
3067 (defun gnus-mime-save-part ()
3068 "Save the MIME part under point."
3070 (gnus-article-check-buffer)
3071 (let ((data (get-text-property (point) 'gnus-data)))
3072 (mm-save-part data)))
3074 (defun gnus-mime-pipe-part ()
3075 "Pipe the MIME part under point to a process."
3077 (gnus-article-check-buffer)
3078 (let ((data (get-text-property (point) 'gnus-data)))
3079 (mm-pipe-part data)))
3081 (defun gnus-mime-view-part ()
3082 "Interactively choose a viewing method for the MIME part under point."
3084 (gnus-article-check-buffer)
3085 (let ((data (get-text-property (point) 'gnus-data)))
3086 (mm-interactively-view-part data)))
3088 (defun gnus-mime-view-part-as-media ()
3089 "Choose a MIME media type, and view the part as such."
3091 (list (completing-read "View as MIME type: " mailcap-mime-types)))
3092 (gnus-article-check-buffer)
3093 (let ((handle (get-text-property (point) 'gnus-data)))
3094 (gnus-mm-display-part handle)))
3096 (defun gnus-mime-copy-part (&optional handle)
3097 "Put the the MIME part under point into a new buffer."
3099 (gnus-article-check-buffer)
3100 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3101 (contents (mm-get-part handle))|
3102 (base (file-name-nondirectory
3104 (mail-content-type-get (mm-handle-type handle) 'name)
3105 (mail-content-type-get (mm-handle-type handle)
3108 (buffer (generate-new-buffer base)))
3109 (switch-to-buffer buffer)
3111 ;; We do it this way to make `normal-mode' set the appropriate mode.
3114 (setq buffer-file-name (expand-file-name base))
3116 (setq buffer-file-name nil))
3117 (goto-char (point-min))))
3119 (defun gnus-mime-inline-part (&optional handle)
3120 "Insert the MIME part under point into the current buffer."
3122 (gnus-article-check-buffer)
3123 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3127 (if (mm-handle-undisplayer handle)
3128 (mm-remove-part handle)
3129 (setq contents (mm-get-part handle))
3131 (mm-insert-inline handle contents)
3134 (defun gnus-mime-externalize-part (&optional handle)
3135 "View the MIME part under point with an external viewer."
3137 (gnus-article-check-buffer)
3138 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3139 (mm-user-display-methods nil)
3140 (mm-inline-large-images nil)
3141 (mail-parse-charset gnus-newsgroup-charset)
3142 (mail-parse-ignored-charsets
3143 (save-excursion (set-buffer gnus-summary-buffer)
3144 gnus-newsgroup-ignored-charsets)))
3145 (if (mm-handle-undisplayer handle)
3146 (mm-remove-part handle)
3147 (mm-display-part handle))))
3149 (defun gnus-mime-internalize-part (&optional handle)
3150 "View the MIME part under point with an internal viewer."
3152 (gnus-article-check-buffer)
3153 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3154 (mm-user-display-methods '((".*" . inline)))
3155 (mm-inline-large-images t)
3156 (mail-parse-charset gnus-newsgroup-charset)
3157 (mail-parse-ignored-charsets
3158 (save-excursion (set-buffer gnus-summary-buffer)
3159 gnus-newsgroup-ignored-charsets)))
3160 (if (mm-handle-undisplayer handle)
3161 (mm-remove-part handle)
3162 (mm-display-part handle))))
3164 (defun gnus-article-part-wrapper (n function)
3165 (save-current-buffer
3166 (set-buffer gnus-article-buffer)
3167 (when (> n (length gnus-article-mime-handle-alist))
3168 (error "No such part"))
3169 (gnus-article-goto-part n)
3170 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
3171 (funcall function handle))))
3173 (defun gnus-article-pipe-part (n)
3174 "Pipe MIME part N, which is the numerical prefix."
3176 (gnus-article-part-wrapper n 'mm-pipe-part))
3178 (defun gnus-article-save-part (n)
3179 "Save MIME part N, which is the numerical prefix."
3181 (gnus-article-part-wrapper n 'mm-save-part))
3183 (defun gnus-article-interactively-view-part (n)
3184 "View MIME part N interactively, which is the numerical prefix."
3186 (gnus-article-part-wrapper n 'mm-interactively-view-part))
3188 (defun gnus-article-copy-part (n)
3189 "Copy MIME part N, which is the numerical prefix."
3191 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
3193 (defun gnus-article-externalize-part (n)
3194 "View MIME part N externally, which is the numerical prefix."
3196 (gnus-article-part-wrapper n 'gnus-mime-externalize-part))
3198 (defun gnus-article-inline-part (n)
3199 "Inline MIME part N, which is the numerical prefix."
3201 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
3203 (defun gnus-article-view-part (n)
3204 "View MIME part N, which is the numerical prefix."
3206 (save-current-buffer
3207 (set-buffer gnus-article-buffer)
3208 (when (> n (length gnus-article-mime-handle-alist))
3209 (error "No such part"))
3210 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
3211 (when (gnus-article-goto-part n)
3212 (if (equal (car handle) "multipart/alternative")
3213 (gnus-article-press-button)
3214 (when (eq (gnus-mm-display-part handle) 'internal)
3215 (gnus-set-window-start)))))))
3217 (defun gnus-mm-display-part (handle)
3218 "Display HANDLE and fix MIME button."
3219 (let ((id (get-text-property (point) 'gnus-part))
3224 (let ((window (selected-window))
3225 (mail-parse-charset gnus-newsgroup-charset)
3226 (mail-parse-ignored-charsets
3227 (save-excursion (set-buffer gnus-summary-buffer)
3228 gnus-newsgroup-ignored-charsets)))
3231 (let ((win (get-buffer-window (current-buffer) t))
3234 (select-window win))
3237 (if (mm-handle-displayed-p handle)
3238 ;; This will remove the part.
3239 (mm-display-part handle)
3241 (narrow-to-region (point) (1+ (point)))
3242 (mm-display-part handle)
3243 ;; We narrow to the part itself and
3244 ;; then call the treatment functions.
3245 (goto-char (point-min))
3247 (narrow-to-region (point) (point-max))
3250 (1- (length gnus-article-mime-handles))
3251 (mm-handle-media-type handle)))))
3252 (select-window window))))
3254 (delete-region (gnus-point-at-bol) (progn (forward-line 1) (point)))
3255 (gnus-insert-mime-button
3256 handle id (list (mm-handle-displayed-p handle)))
3257 (goto-char point))))
3259 (defun gnus-article-goto-part (n)
3260 "Go to MIME part N."
3261 (let ((point (text-property-any (point-min) (point-max) 'gnus-part n)))
3263 (goto-char point))))
3265 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
3266 (let ((gnus-tmp-name
3267 (or (mail-content-type-get (mm-handle-type handle)
3269 (mail-content-type-get (mm-handle-disposition handle)
3272 (gnus-tmp-type (mm-handle-media-type handle))
3273 (gnus-tmp-description
3274 (mail-decode-encoded-word-string (or (mm-handle-description handle)
3277 (if (if displayed (car displayed)
3278 (mm-handle-displayed-p handle))
3280 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
3282 gnus-tmp-type-long b e)
3283 (when (string-match ".*/" gnus-tmp-name)
3284 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
3285 (setq gnus-tmp-type-long (concat gnus-tmp-type
3286 (and (not (equal gnus-tmp-name ""))
3287 (concat "; " gnus-tmp-name))))
3288 (or (equal gnus-tmp-description "")
3289 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
3294 gnus-mime-button-line-format gnus-mime-button-line-format-alist
3295 `(local-map ,gnus-mime-button-map
3296 keymap ,gnus-mime-button-map
3297 gnus-callback gnus-mm-display-part
3298 gnus-part ,gnus-tmp-id
3299 article-type annotation
3302 (widget-convert-button 'link b e
3304 :action 'gnus-widget-press-button
3305 :button-keymap gnus-mime-button-map
3308 ;; Needed to properly clear the message
3309 ;; due to a bug in wid-edit
3310 (setq help-echo-owns-message t)
3312 "Click to %s the MIME part; %s for more options"
3313 (if (mm-handle-displayed-p
3314 (widget-get widget :mime-handle))
3316 (if gnus-xemacs "button3" "mouse-3"))))))
3318 (defun gnus-widget-press-button (elems el)
3319 (goto-char (widget-get elems :from))
3320 (gnus-article-press-button))
3322 (defvar gnus-displaying-mime nil)
3324 (defun gnus-display-mime (&optional ihandles)
3325 "Display the MIME parts."
3327 (save-selected-window
3328 (let ((window (get-buffer-window gnus-article-buffer))
3331 (select-window window)
3332 ;; We have to do this since selecting the window
3333 ;; may change the point. So we set the window point.
3334 (set-window-point window point)))
3335 (let* ((handles (or ihandles (mm-dissect-buffer) (mm-uu-dissect)))
3336 buffer-read-only handle name type b e display)
3337 (when (and (not ihandles)
3338 (not gnus-displaying-mime))
3339 ;; Top-level call; we clean up.
3340 (when gnus-article-mime-handles
3341 (mm-destroy-parts gnus-article-mime-handles)
3342 (setq gnus-article-mime-handle-alist nil)) ;; A trick.
3343 (setq gnus-article-mime-handles handles)
3344 ;; We allow users to glean info from the handles.
3345 (when gnus-article-mime-part-function
3346 (gnus-mime-part-function handles)))
3348 (or (not (stringp (car handles)))
3351 (when (and (not ihandles)
3352 (not gnus-displaying-mime))
3353 ;; Clean up for mime parts.
3355 (delete-region (point) (point-max)))
3356 (let ((gnus-displaying-mime t))
3357 (gnus-mime-display-part handles)))
3360 (narrow-to-region (point) (point-max))
3361 (gnus-treat-article nil 1 1)
3364 ;; Highlight the headers.
3368 (narrow-to-region (point-min) (point))
3369 (gnus-treat-article 'head))))))))
3371 (defvar gnus-mime-display-multipart-as-mixed nil)
3373 (defun gnus-mime-display-part (handle)
3376 ((not (stringp (car handle)))
3377 (gnus-mime-display-single handle))
3378 ;; User-defined multipart
3379 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
3380 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
3382 ;; multipart/alternative
3383 ((and (equal (car handle) "multipart/alternative")
3384 (not gnus-mime-display-multipart-as-mixed))
3385 (let ((id (1+ (length gnus-article-mime-handle-alist))))
3386 (push (cons id handle) gnus-article-mime-handle-alist)
3387 (gnus-mime-display-alternative (cdr handle) nil nil id)))
3388 ;; multipart/related
3389 ((and (equal (car handle) "multipart/related")
3390 (not gnus-mime-display-multipart-as-mixed))
3391 ;;;!!!We should find the start part, but we just default
3392 ;;;!!!to the first part.
3393 (gnus-mime-display-part (cadr handle)))
3394 ;; Other multiparts are handled like multipart/mixed.
3396 (gnus-mime-display-mixed (cdr handle)))))
3398 (defun gnus-mime-part-function (handles)
3399 (if (stringp (car handles))
3400 (mapcar 'gnus-mime-part-function (cdr handles))
3401 (funcall gnus-article-mime-part-function handles)))
3403 (defun gnus-mime-display-mixed (handles)
3404 (mapcar 'gnus-mime-display-part handles))
3406 (defun gnus-mime-display-single (handle)
3407 (let ((type (mm-handle-media-type handle))
3408 (ignored gnus-ignored-mime-types)
3415 (when (string-match (pop ignored) type)
3416 (throw 'ignored nil)))
3417 (if (and (setq not-attachment
3418 (or (not (mm-handle-disposition handle))
3419 (equal (car (mm-handle-disposition handle))
3421 (mm-attachment-override-p handle)))
3422 (mm-automatic-display-p handle)
3423 (or (mm-inlined-p handle)
3424 (mm-automatic-external-display-p type)))
3426 (when (equal (mm-handle-media-supertype handle) "text")
3428 (let ((id (1+ (length gnus-article-mime-handle-alist))))
3429 (push (cons id handle) gnus-article-mime-handle-alist)
3430 (when (or (not display)
3431 (not (gnus-unbuttonized-mime-type-p type)))
3432 (gnus-article-insert-newline)
3433 (gnus-insert-mime-button
3434 handle id (list (or display (and not-attachment text))))
3435 (gnus-article-insert-newline)
3436 (gnus-article-insert-newline)
3438 (let ((beg (point)))
3443 (let ((mail-parse-charset gnus-newsgroup-charset)
3444 (mail-parse-ignored-charsets
3445 (save-excursion (set-buffer gnus-summary-buffer)
3446 gnus-newsgroup-ignored-charsets)))
3447 (mm-display-part handle t))
3448 (goto-char (point-max)))
3449 ((and text not-attachment)
3452 (gnus-article-insert-newline)
3453 (mm-insert-inline handle (mm-get-part handle))
3454 (goto-char (point-max))))
3458 (narrow-to-region beg (point))
3460 nil (length gnus-article-mime-handle-alist)
3461 (1- (length gnus-article-mime-handles))
3462 (mm-handle-media-type handle)))))))))
3464 (defun gnus-unbuttonized-mime-type-p (type)
3465 "Say whether TYPE is to be unbuttonized."
3466 (unless gnus-inhibit-mime-unbuttonizing
3468 (let ((types gnus-unbuttonized-mime-types))
3470 (when (string-match (pop types) type)
3471 (throw 'found t)))))))
3473 (defun gnus-article-insert-newline ()
3474 "Insert a newline, but mark it as undeletable."
3475 (gnus-put-text-property
3476 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
3478 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
3479 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
3482 handle buffer-read-only from props begend not-pref)
3483 (save-window-excursion
3486 (narrow-to-region (car ibegend)
3489 (goto-char (car ibegend))
3492 (delete-region (point-min) (point-max))
3493 (mm-remove-parts handles))
3494 (setq begend (list (point-marker)))
3496 (unless (setq not-pref (cadr (member preferred ihandles)))
3497 (setq not-pref (car ihandles)))
3499 (not (gnus-unbuttonized-mime-type-p
3500 "multipart/alternative")))
3501 (gnus-add-text-properties
3504 (insert (format "%d. " id))
3508 (unless ,(not ibegend)
3509 (setq gnus-article-mime-handle-alist
3510 ',gnus-article-mime-handle-alist))
3511 (gnus-mime-display-alternative
3512 ',ihandles ',not-pref ',begend ,id))
3513 local-map ,gnus-mime-button-map
3514 ,gnus-mouse-face-prop ,gnus-article-mouse-face
3515 face ,gnus-article-button-face
3516 keymap ,gnus-mime-button-map
3519 (widget-convert-button 'link from (point)
3520 :action 'gnus-widget-press-button
3521 :button-keymap gnus-widget-button-keymap)
3523 (while (setq handle (pop handles))
3524 (gnus-add-text-properties
3527 (insert (format "(%c) %-18s"
3528 (if (equal handle preferred) ?* ? )
3529 (mm-handle-media-type handle)))
3533 (unless ,(not ibegend)
3534 (setq gnus-article-mime-handle-alist
3535 ',gnus-article-mime-handle-alist))
3536 (gnus-mime-display-alternative
3537 ',ihandles ',handle ',begend ,id))
3538 local-map ,gnus-mime-button-map
3539 ,gnus-mouse-face-prop ,gnus-article-mouse-face
3540 face ,gnus-article-button-face
3541 keymap ,gnus-mime-button-map
3544 (widget-convert-button 'link from (point)
3545 :action 'gnus-widget-press-button
3546 :button-keymap gnus-widget-button-keymap)
3550 (if (stringp (car preferred))
3551 (gnus-display-mime preferred)
3552 (let ((mail-parse-charset gnus-newsgroup-charset)
3553 (mail-parse-ignored-charsets
3554 (save-excursion (set-buffer gnus-summary-buffer)
3555 gnus-newsgroup-ignored-charsets)))
3556 (mm-display-part preferred)
3560 (narrow-to-region (car begend) (point-max))
3562 nil (length gnus-article-mime-handle-alist)
3563 (1- (length gnus-article-mime-handles))
3564 (mm-handle-media-type handle))))))
3565 (goto-char (point-max))
3566 (setcdr begend (point-marker)))))
3568 (goto-char point))))
3570 (defun gnus-article-wash-status ()
3571 "Return a string which display status of article washing."
3573 (set-buffer gnus-article-buffer)
3574 (let ((cite (gnus-article-hidden-text-p 'cite))
3575 (headers (gnus-article-hidden-text-p 'headers))
3576 (boring (gnus-article-hidden-text-p 'boring-headers))
3577 (pgp (gnus-article-hidden-text-p 'pgp))
3578 (pem (gnus-article-hidden-text-p 'pem))
3579 (signature (gnus-article-hidden-text-p 'signature))
3580 (overstrike (gnus-article-hidden-text-p 'overstrike))
3581 (emphasis (gnus-article-hidden-text-p 'emphasis))
3582 (mime gnus-show-mime))
3583 (format "%c%c%c%c%c%c%c"
3585 (if (or headers boring) ?h ? )
3586 (if (or pgp pem) ?p ? )
3587 (if signature ?s ? )
3588 (if overstrike ?o ? )
3590 (if emphasis ?e ? )))))
3592 (fset 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
3594 (defun gnus-article-maybe-hide-headers ()
3595 "Hide unwanted headers if `gnus-have-all-headers' is nil.
3596 Provided for backwards compatibility."
3597 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
3598 (not (save-excursion (set-buffer gnus-summary-buffer)
3599 gnus-have-all-headers)))
3600 (not gnus-inhibit-hiding))
3601 (gnus-article-hide-headers)))
3605 (defun gnus-output-to-file (file-name)
3606 "Append the current article to a file named FILE-NAME."
3607 (let ((artbuf (current-buffer)))
3609 (insert-buffer-substring artbuf)
3610 ;; Append newline at end of the buffer as separator, and then
3612 (goto-char (point-max))
3614 (append-to-file (point-min) (point-max) file-name)
3617 (defun gnus-narrow-to-page (&optional arg)
3618 "Narrow the article buffer to a page.
3619 If given a numerical ARG, move forward ARG pages."
3621 (setq arg (if arg (prefix-numeric-value arg) 0))
3623 (set-buffer gnus-article-buffer)
3624 (goto-char (point-min))
3626 ;; Remove any old next/prev buttons.
3627 (when (gnus-visual-p 'page-marker)
3628 (let ((buffer-read-only nil))
3629 (gnus-remove-text-with-property 'gnus-prev)
3630 (gnus-remove-text-with-property 'gnus-next)))
3633 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
3635 (re-search-forward page-delimiter nil 'move arg)))
3636 (goto-char (match-end 0)))
3639 (if (re-search-forward page-delimiter nil 'move)
3642 (when (and (gnus-visual-p 'page-marker)
3643 (not (= (point-min) 1)))
3645 (goto-char (point-min))
3646 (gnus-insert-prev-page-button)))
3647 (when (and (gnus-visual-p 'page-marker)
3648 (< (+ (point-max) 2) (buffer-size)))
3650 (goto-char (point-max))
3651 (gnus-insert-next-page-button)))))
3653 ;; Article mode commands
3655 (defun gnus-article-goto-next-page ()
3656 "Show the next page of the article."
3658 (when (gnus-article-next-page)
3659 (goto-char (point-min))
3660 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
3662 (defun gnus-article-goto-prev-page ()
3663 "Show the next page of the article."
3665 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
3666 (gnus-article-prev-page nil)))
3668 (defun gnus-article-next-page (&optional lines)
3669 "Show the next page of the current article.
3670 If end of article, return non-nil. Otherwise return nil.
3671 Argument LINES specifies lines to be scrolled up."
3673 (move-to-window-line -1)
3676 (and (pos-visible-in-window-p) ;Not continuation line.
3678 ;; Nothing in this page.
3679 (if (or (not gnus-page-broken)
3682 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
3684 (gnus-narrow-to-page 1) ;Go to next page.
3686 ;; More in this page.
3687 (let ((scroll-in-place nil))
3691 ;; Long lines may cause an end-of-buffer error.
3692 (goto-char (point-max)))))
3693 (move-to-window-line 0)
3696 (defun gnus-article-prev-page (&optional lines)
3697 "Show previous page of current article.
3698 Argument LINES specifies lines to be scrolled down."
3700 (move-to-window-line 0)
3701 (if (and gnus-page-broken
3703 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
3705 (gnus-narrow-to-page -1) ;Go to previous page.
3706 (goto-char (point-max))
3708 (let ((scroll-in-place nil))
3712 (beginning-of-buffer
3713 (goto-char (point-min))))
3714 (move-to-window-line 0)))))
3716 (defun gnus-article-refer-article ()
3717 "Read article specified by message-id around point."
3719 (let ((point (point)))
3720 (search-forward ">" nil t) ;Move point to end of "<....>".
3721 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
3722 (let ((message-id (match-string 1)))
3724 (set-buffer gnus-summary-buffer)
3725 (gnus-summary-refer-article message-id))
3727 (error "No references around point"))))
3729 (defun gnus-article-show-summary ()
3730 "Reconfigure windows to show summary buffer."
3732 (if (not (gnus-buffer-live-p gnus-summary-buffer))
3733 (error "There is no summary buffer for this article buffer")
3734 (gnus-article-set-globals)
3735 (gnus-configure-windows 'article)
3736 (gnus-summary-goto-subject gnus-current-article)
3737 (gnus-summary-position-point)))
3739 (defun gnus-article-describe-briefly ()
3740 "Describe article mode commands briefly."
3742 (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")))
3744 (defun gnus-article-summary-command ()
3745 "Execute the last keystroke in the summary buffer."
3747 (let ((obuf (current-buffer))
3748 (owin (current-window-configuration))
3750 (switch-to-buffer gnus-article-current-summary 'norecord)
3751 (setq func (lookup-key (current-local-map) (this-command-keys)))
3752 (call-interactively func)
3754 (set-window-configuration owin)
3755 (set-window-point (get-buffer-window (current-buffer)) (point))))
3757 (defun gnus-article-summary-command-nosave ()
3758 "Execute the last keystroke in the summary buffer."
3761 (pop-to-buffer gnus-article-current-summary 'norecord)
3762 (setq func (lookup-key (current-local-map) (this-command-keys)))
3763 (call-interactively func)))
3765 (defun gnus-article-check-buffer ()
3766 "Beep if not in an article buffer."
3767 (unless (eq (get-buffer gnus-article-buffer) (current-buffer))
3768 (error "Command invoked outside of a Gnus article buffer")))
3770 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
3771 "Read a summary buffer key sequence and execute it from the article buffer."
3773 (gnus-article-check-buffer)
3775 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
3776 "Zc" "ZC" "ZE" "ZJ" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
3777 "=" "^" "\M-^" "|"))
3783 '("n" "Gn" "p" "Gp"))
3786 (set-buffer gnus-article-current-summary)
3787 (let (gnus-pick-mode)
3788 (push (or key last-command-event) unread-command-events)
3789 (setq keys (static-if (featurep 'xemacs)
3790 (events-to-keys (read-key-sequence nil))
3791 (read-key-sequence nil)))))
3794 (if (or (member keys nosaves)
3795 (member keys nosave-but-article)
3796 (member keys nosave-in-article))
3798 (save-window-excursion
3799 (pop-to-buffer gnus-article-current-summary 'norecord)
3800 ;; We disable the pick minor mode commands.
3801 (let (gnus-pick-mode)
3802 (setq func (lookup-key (current-local-map) keys))))
3805 (unless (member keys nosave-in-article)
3806 (set-buffer gnus-article-current-summary))
3807 (call-interactively func)
3808 (setq new-sum-point (point)))
3809 (when (member keys nosave-but-article)
3810 (pop-to-buffer gnus-article-buffer 'norecord)))
3811 ;; These commands should restore window configuration.
3812 (let ((obuf (current-buffer))
3813 (owin (current-window-configuration))
3815 (summary gnus-article-current-summary)
3816 func in-buffer selected)
3817 (if not-restore-window
3818 (pop-to-buffer summary 'norecord)
3819 (switch-to-buffer summary 'norecord))
3820 (setq in-buffer (current-buffer))
3821 ;; We disable the pick minor mode commands.
3822 (if (setq func (let (gnus-pick-mode)
3823 (lookup-key (current-local-map) keys)))
3825 (call-interactively func)
3826 (setq new-sum-point (point)))
3828 (when (eq in-buffer (current-buffer))
3829 (setq selected (gnus-summary-select-article))
3831 (unless not-restore-window
3832 (set-window-configuration owin))
3833 (when (eq selected 'old)
3835 (set-window-start (get-buffer-window (current-buffer))
3837 (set-window-point (get-buffer-window (current-buffer))
3839 (let ((win (get-buffer-window gnus-article-current-summary)))
3841 (set-window-point win new-sum-point))))))))
3843 (defun gnus-article-hide (&optional arg force)
3844 "Hide all the gruft in the current article.
3845 This means that PGP stuff, signatures, cited text and (some)
3846 headers will be hidden.
3847 If given a prefix, show the hidden text instead."
3848 (interactive (append (gnus-article-hidden-arg) (list 'force)))
3849 (gnus-article-hide-headers arg)
3850 (gnus-article-hide-pgp arg)
3851 (gnus-article-hide-citation-maybe arg force)
3852 (gnus-article-hide-signature arg))
3854 (defun gnus-article-maybe-highlight ()
3855 "Do some article highlighting if article highlighting is requested."
3856 (when (gnus-visual-p 'article-highlight 'highlight)
3857 (gnus-article-highlight-some)))
3859 (defun gnus-check-group-server ()
3860 ;; Make sure the connection to the server is alive.
3861 (unless (gnus-server-opened
3862 (gnus-find-method-for-group gnus-newsgroup-name))
3863 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
3864 (gnus-request-group gnus-newsgroup-name t)))
3866 (defun gnus-request-article-this-buffer (article group)
3867 "Get an article and insert it into this buffer."
3868 (let (do-update-line sparse-header)
3872 (gnus-kill-all-overlays)
3873 (setq group (or group gnus-newsgroup-name))
3875 ;; Using `gnus-request-article' directly will insert the article into
3876 ;; `nntp-server-buffer' - so we'll save some time by not having to
3877 ;; copy it from the server buffer into the article buffer.
3879 ;; We only request an article by message-id when we do not have the
3880 ;; headers for it, so we'll have to get those.
3881 (when (stringp article)
3882 (let ((gnus-override-method gnus-refer-article-method))
3883 (gnus-read-header article)))
3885 ;; If the article number is negative, that means that this article
3886 ;; doesn't belong in this newsgroup (possibly), so we find its
3887 ;; message-id and request it by id instead of number.
3888 (when (and (numberp article)
3890 (get-buffer gnus-summary-buffer)
3891 (gnus-buffer-exists-p gnus-summary-buffer))
3893 (set-buffer gnus-summary-buffer)
3894 (let ((header (gnus-summary-article-header article)))
3897 ((memq article gnus-newsgroup-sparse)
3898 ;; This is a sparse gap article.
3899 (setq do-update-line article)
3900 (setq article (mail-header-id header))
3901 (let ((gnus-override-method gnus-refer-article-method))
3902 (setq sparse-header (gnus-read-header article)))
3903 (setq gnus-newsgroup-sparse
3904 (delq article gnus-newsgroup-sparse)))
3906 ;; It's a real article.
3907 (setq article (mail-header-id header)))
3909 ;; It is an extracted pseudo-article.
3910 (setq article 'pseudo)
3911 (gnus-request-pseudo-article header))))
3913 (let ((method (gnus-find-method-for-group
3914 gnus-newsgroup-name)))
3915 (when (and (eq (car method) 'nneething)
3918 (file-name-as-directory
3919 (or (cadr (assq 'nneething-address method))
3921 (mail-header-subject header))))
3922 (when (file-directory-p dir)
3923 (setq article 'nneething)
3924 (gnus-group-enter-directory dir))))))))
3927 ;; Refuse to select canceled articles.
3928 ((and (numberp article)
3930 (get-buffer gnus-summary-buffer)
3931 (gnus-buffer-exists-p gnus-summary-buffer)
3932 (eq (cdr (save-excursion
3933 (set-buffer gnus-summary-buffer)
3934 (assq article gnus-newsgroup-reads)))
3935 gnus-canceled-mark))
3937 ;; Check the backlog.
3938 ((and gnus-keep-backlog
3939 (gnus-backlog-request-article group article (current-buffer)))
3941 ;; Check asynchronous pre-fetch.
3942 ((gnus-async-request-fetched-article group article (current-buffer))
3943 (gnus-async-prefetch-next group article gnus-summary-buffer)
3944 (when (and (numberp article) gnus-keep-backlog)
3945 (gnus-backlog-enter-article group article (current-buffer)))
3948 ((and gnus-use-cache
3950 (gnus-cache-request-article article group))
3952 ;; Get the article and put into the article buffer.
3953 ((or (stringp article) (numberp article))
3954 (let ((gnus-override-method
3955 (and (stringp article) gnus-refer-article-method))
3956 (buffer-read-only nil))
3958 (gnus-kill-all-overlays)
3959 (gnus-check-group-server)
3960 (when (gnus-request-article article group (current-buffer))
3961 (when (numberp article)
3962 (gnus-async-prefetch-next group article gnus-summary-buffer)
3963 (when gnus-keep-backlog
3964 (gnus-backlog-enter-article
3965 group article (current-buffer))))
3970 ;; Associate this article with the current summary buffer.
3971 (setq gnus-article-current-summary gnus-summary-buffer)
3973 ;; Take the article from the original article buffer
3974 ;; and place it in the buffer it's supposed to be in.
3975 (when (and (get-buffer gnus-article-buffer)
3976 (equal (buffer-name (current-buffer))
3977 (buffer-name (get-buffer gnus-article-buffer))))
3979 (if (get-buffer gnus-original-article-buffer)
3980 (set-buffer gnus-original-article-buffer)
3981 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3982 (buffer-disable-undo)
3983 (setq major-mode 'gnus-original-article-mode)
3984 (setq buffer-read-only t))
3985 (let (buffer-read-only)
3987 (insert-buffer-substring gnus-article-buffer))
3988 (setq gnus-original-article (cons group article)))
3991 (run-hooks 'gnus-article-decode-hook)
3992 ;; Mark article as decoded or not.
3993 (setq gnus-article-decoded-p gnus-article-decode-hook))
3995 ;; Update sparse articles.
3996 (when (and do-update-line
3997 (or (numberp article)
3999 (let ((buf (current-buffer)))
4000 (set-buffer gnus-summary-buffer)
4001 (gnus-summary-update-article do-update-line sparse-header)
4002 (gnus-summary-goto-subject do-update-line nil t)
4003 (set-window-point (get-buffer-window (current-buffer) t)
4005 (set-buffer buf))))))
4011 (defcustom gnus-article-edit-mode-hook nil
4012 "Hook run in article edit mode buffers."
4013 :group 'gnus-article-various
4016 (defcustom gnus-article-edit-article-setup-function
4017 'gnus-article-mime-edit-article-setup
4018 "Function called to setup an editing article buffer."
4019 :group 'gnus-article-various
4022 (defvar gnus-article-edit-done-function nil)
4024 (defvar gnus-article-edit-mode-map nil)
4026 ;; Should we be using derived.el for this?
4027 (unless gnus-article-edit-mode-map
4028 (setq gnus-article-edit-mode-map (make-sparse-keymap))
4029 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
4031 (gnus-define-keys gnus-article-edit-mode-map
4032 "\C-c\C-c" gnus-article-edit-done
4033 "\C-c\C-k" gnus-article-edit-exit)
4035 (gnus-define-keys (gnus-article-edit-wash-map
4036 "\C-c\C-w" gnus-article-edit-mode-map)
4037 "f" gnus-article-edit-full-stops))
4039 (defun gnus-article-edit-mode ()
4040 "Major mode for editing articles.
4041 This is an extended text-mode.
4043 \\{gnus-article-edit-mode-map}"
4045 (setq major-mode 'gnus-article-edit-mode)
4046 (setq mode-name "Article Edit")
4047 (use-local-map gnus-article-edit-mode-map)
4048 (make-local-variable 'gnus-article-edit-done-function)
4049 (make-local-variable 'gnus-prev-winconf)
4050 (setq buffer-read-only nil)
4051 (buffer-enable-undo)
4053 (gnus-run-hooks 'text-mode-hook 'gnus-article-edit-mode-hook))
4055 (defun gnus-article-edit (&optional force)
4056 "Edit the current article.
4057 This will have permanent effect only in mail groups.
4058 If FORCE is non-nil, allow editing of articles even in read-only
4061 (when (and (not force)
4062 (gnus-group-read-only-p))
4063 (error "The current newsgroup does not support article editing"))
4064 (gnus-article-date-original)
4065 (gnus-article-edit-article
4067 `(lambda (no-highlight)
4069 (gnus-summary-edit-article-done
4070 ,(or (mail-header-references gnus-current-headers) "")
4071 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
4073 (defun gnus-article-edit-article (start-func exit-func)
4074 "Start editing the contents of the current article buffer."
4075 (let ((winconf (current-window-configuration)))
4076 (set-buffer gnus-article-buffer)
4077 (gnus-article-edit-mode)
4078 (funcall start-func)
4079 (gnus-configure-windows 'edit-article)
4080 (setq gnus-article-edit-done-function exit-func)
4081 (setq gnus-prev-winconf winconf)
4082 (when gnus-article-edit-article-setup-function
4083 (funcall gnus-article-edit-article-setup-function))
4084 (gnus-message 6 "C-c C-c to end edits")))
4086 (defun gnus-article-edit-done (&optional arg)
4087 "Update the article edits and exit."
4092 (when (article-goto-body)
4093 (let ((lines (count-lines (point) (point-max)))
4094 (length (- (point-max) (point)))
4095 (case-fold-search t)
4096 (body (copy-marker (point))))
4097 (goto-char (point-min))
4098 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
4099 (delete-region (match-beginning 1) (match-end 1))
4100 (insert (number-to-string length)))
4101 (goto-char (point-min))
4102 (when (re-search-forward
4103 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
4104 (delete-region (match-beginning 1) (match-end 1))
4105 (insert (number-to-string length)))
4106 (goto-char (point-min))
4107 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
4108 (delete-region (match-beginning 1) (match-end 1))
4109 (insert (number-to-string lines)))))))
4110 (let ((func gnus-article-edit-done-function)
4111 (buf (current-buffer))
4112 (start (window-start)))
4113 (remove-hook 'gnus-article-mode-hook
4114 'gnus-article-mime-edit-article-unwind)
4115 (gnus-article-edit-exit)
4118 (let ((buffer-read-only nil))
4120 ;; The cache and backlog have to be flushed somewhat.
4121 (when gnus-keep-backlog
4122 (gnus-backlog-remove-article
4123 (car gnus-article-current) (cdr gnus-article-current)))
4124 ;; Flush original article as well.
4126 (when (get-buffer gnus-original-article-buffer)
4127 (set-buffer gnus-original-article-buffer)
4128 (setq gnus-original-article nil)))
4129 (when gnus-use-cache
4130 (gnus-cache-update-article
4131 (car gnus-article-current) (cdr gnus-article-current))))
4133 (set-window-start (get-buffer-window buf) start)
4134 (set-window-point (get-buffer-window buf) (point))))
4136 (defun gnus-article-edit-exit ()
4137 "Exit the article editing without updating."
4139 ;; We remove all text props from the article buffer.
4140 (let ((buf (format "%s" (buffer-string)))
4141 (curbuf (current-buffer))
4143 (window-start (window-start)))
4146 (let ((winconf gnus-prev-winconf))
4148 (set-window-configuration winconf)
4149 ;; Tippy-toe some to make sure that point remains where it was.
4150 (save-current-buffer
4152 (set-window-start (get-buffer-window (current-buffer)) window-start)
4155 (defun gnus-article-edit-full-stops ()
4156 "Interactively repair spacing at end of sentences."
4159 (goto-char (point-min))
4160 (search-forward-regexp "^$" nil t)
4161 (let ((case-fold-search nil))
4162 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
4165 ;;; Article editing with MIME-Edit
4168 (defcustom gnus-article-mime-edit-article-setup-hook nil
4169 "Hook run after setting up a MIME editing article buffer."
4170 :group 'gnus-article-various
4173 (defun gnus-article-mime-edit-article-unwind ()
4174 "Unwind `gnus-article-buffer' if article editing was given up."
4175 (remove-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
4176 (when mime-edit-mode-flag
4177 (mime-edit-exit 'nomime 'no-error)
4179 (when (featurep 'font-lock)
4180 (setq font-lock-defaults nil)
4181 (font-lock-mode 0)))
4183 (defun gnus-article-mime-edit-article-setup ()
4184 "Convert current buffer to MIME-Edit buffer and turn on MIME-Edit mode
4185 after replacing with the original article."
4186 (setq gnus-show-mime t)
4187 (setq gnus-article-edit-done-function
4188 `(lambda (&rest args)
4189 (when mime-edit-mode-flag
4192 (goto-char (point-min))
4193 (let (case-fold-search)
4194 (when (re-search-forward
4195 (format "^%s$" (regexp-quote mail-header-separator))
4197 (replace-match "")))
4198 (when (featurep 'font-lock)
4199 (setq font-lock-defaults nil)
4201 (apply ,gnus-article-edit-done-function args)
4202 (set-buffer gnus-original-article-buffer)
4204 (insert-buffer gnus-article-buffer)
4205 (setq gnus-current-headers (gnus-article-make-full-mail-header))
4206 (gnus-article-prepare-display)))
4207 (substitute-key-definition
4208 'gnus-article-edit-exit 'gnus-article-mime-edit-exit
4209 gnus-article-edit-mode-map)
4211 (insert-buffer gnus-original-article-buffer)
4213 (when (featurep 'font-lock)
4214 (set (make-local-variable 'font-lock-defaults)
4215 '(message-font-lock-keywords t))
4216 (font-lock-set-defaults)
4217 (turn-on-font-lock))
4218 (add-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
4219 (gnus-run-hooks 'gnus-article-mime-edit-article-setup-hook))
4221 (defun gnus-article-mime-edit-exit ()
4222 "Exit the article MIME editing without updating."
4224 (let ((winconf gnus-prev-winconf)
4226 (when mime-edit-mode-flag
4229 (goto-char (point-min))
4230 (let (case-fold-search)
4231 (when (re-search-forward
4232 (format "^%s$" (regexp-quote mail-header-separator)) nil t)
4233 (replace-match "")))
4234 (when (featurep 'font-lock)
4235 (setq font-lock-defaults nil)
4237 ;; We remove all text props from the article buffer.
4238 (setq buf (format "%s" (buffer-string)))
4239 (set-buffer (get-buffer-create gnus-original-article-buffer))
4242 (setq gnus-current-headers (gnus-article-make-full-mail-header))
4243 (gnus-article-prepare-display)
4244 (set-window-configuration winconf)))
4247 ;;; Article highlights
4250 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
4252 ;;; Internal Variables:
4254 (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\\)"
4255 "Regular expression that matches URLs."
4256 :group 'gnus-article-buttons
4259 (defcustom gnus-button-alist
4260 `(("<\\(url:[>\n\t ]*?\\)?news:[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
4261 0 t gnus-button-message-id 2)
4262 ("\\bnews:\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t gnus-button-message-id 1)
4263 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
4265 gnus-button-fetch-group 4)
4266 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
4267 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
4268 t gnus-button-message-id 3)
4269 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
4270 ("mailto:\\([-a-zA-Z.@_+0-9%]+\\)" 0 t gnus-url-mailto 1)
4271 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
4272 ;; This is how URLs _should_ be embedded in text...
4273 ("<URL: *\\([^>]*\\)>" 0 t gnus-button-embedded-url 1)
4275 (,gnus-button-url-regexp 0 t gnus-button-url 0))
4276 "*Alist of regexps matching buttons in article bodies.
4278 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
4279 REGEXP: is the string matching text around the button,
4280 BUTTON: is the number of the regexp grouping actually matching the button,
4281 FORM: is a lisp expression which must eval to true for the button to
4283 CALLBACK: is the function to call when the user push this button, and each
4284 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
4286 CALLBACK can also be a variable, in that case the value of that
4287 variable it the real callback function."
4288 :group 'gnus-article-buttons
4289 :type '(repeat (list regexp
4290 (integer :tag "Button")
4292 (function :tag "Callback")
4295 (integer :tag "Regexp group")))))
4297 (defcustom gnus-header-button-alist
4298 `(("^\\(References\\|Message-I[Dd]\\):" "<[^>]+>"
4299 0 t gnus-button-message-id 0)
4300 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
4301 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
4302 0 t gnus-button-mailto 0)
4303 ("^X-[Uu][Rr][Ll]:" ,gnus-button-url-regexp 0 t gnus-button-url 0)
4304 ("^Subject:" ,gnus-button-url-regexp 0 t gnus-button-url 0)
4305 ("^[^:]+:" ,gnus-button-url-regexp 0 t gnus-button-url 0)
4306 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
4307 gnus-button-message-id 3))
4308 "*Alist of headers and regexps to match buttons in article heads.
4310 This alist is very similar to `gnus-button-alist', except that each
4311 alist has an additional HEADER element first in each entry:
4313 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
4315 HEADER is a regexp to match a header. For a fuller explanation, see
4316 `gnus-button-alist'."
4317 :group 'gnus-article-buttons
4318 :group 'gnus-article-headers
4319 :type '(repeat (list (regexp :tag "Header")
4321 (integer :tag "Button")
4323 (function :tag "Callback")
4326 (integer :tag "Regexp group")))))
4328 (defvar gnus-button-regexp nil)
4329 (defvar gnus-button-marker-list nil)
4330 ;; Regexp matching any of the regexps from `gnus-button-alist'.
4332 (defvar gnus-button-last nil)
4333 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
4337 (defun gnus-article-push-button (event)
4338 "Check text under the mouse pointer for a callback function.
4339 If the text under the mouse pointer has a `gnus-callback' property,
4340 call it with the value of the `gnus-data' text property."
4342 (set-buffer (window-buffer (posn-window (event-start event))))
4343 (let* ((pos (posn-point (event-start event)))
4344 (data (get-text-property pos 'gnus-data))
4345 (fun (get-text-property pos 'gnus-callback)))
4348 (funcall fun data))))
4350 (defun gnus-article-press-button ()
4351 "Check text at point for a callback function.
4352 If the text at point has a `gnus-callback' property,
4353 call it with the value of the `gnus-data' text property."
4355 (let* ((data (get-text-property (point) 'gnus-data))
4356 (fun (get-text-property (point) 'gnus-callback)))
4358 (funcall fun data))))
4360 (defun gnus-article-prev-button (n)
4361 "Move point to N buttons backward.
4362 If N is negative, move forward instead."
4364 (gnus-article-next-button (- n)))
4366 (defun gnus-article-next-button (n)
4367 "Move point to N buttons forward.
4368 If N is negative, move backward instead."
4370 (let ((function (if (< n 0) 'previous-single-property-change
4371 'next-single-property-change))
4372 (inhibit-point-motion-hooks t)
4374 (limit (if (< n 0) (point-min) (point-max))))
4376 (while (and (not (= limit (point)))
4378 ;; Skip past the current button.
4379 (when (get-text-property (point) 'gnus-callback)
4380 (goto-char (funcall function (point) 'gnus-callback nil limit)))
4381 ;; Go to the next (or previous) button.
4382 (gnus-goto-char (funcall function (point) 'gnus-callback nil limit))
4383 ;; Put point at the start of the button.
4384 (when (and backward (not (get-text-property (point) 'gnus-callback)))
4385 (goto-char (funcall function (point) 'gnus-callback nil limit)))
4386 ;; Skip past intangible buttons.
4387 (when (get-text-property (point) 'intangible)
4391 (gnus-message 5 "No more buttons"))
4394 (defun gnus-article-highlight (&optional force)
4395 "Highlight current article.
4396 This function calls `gnus-article-highlight-headers',
4397 `gnus-article-highlight-citation',
4398 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
4399 do the highlighting. See the documentation for those functions."
4400 (interactive (list 'force))
4401 (gnus-article-highlight-headers)
4402 (gnus-article-highlight-citation force)
4403 (gnus-article-highlight-signature)
4404 (gnus-article-add-buttons force)
4405 (gnus-article-add-buttons-to-head))
4407 (defun gnus-article-highlight-some (&optional force)
4408 "Highlight current article.
4409 This function calls `gnus-article-highlight-headers',
4410 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
4411 do the highlighting. See the documentation for those functions."
4412 (interactive (list 'force))
4413 (gnus-article-highlight-headers)
4414 (gnus-article-highlight-signature)
4415 (gnus-article-add-buttons))
4417 (defun gnus-article-highlight-headers ()
4418 "Highlight article headers as specified by `gnus-header-face-alist'."
4421 (set-buffer gnus-article-buffer)
4423 (let ((alist gnus-header-face-alist)
4424 (buffer-read-only nil)
4425 (case-fold-search t)
4426 (inhibit-point-motion-hooks t)
4427 entry regexp header-face field-face from hpoints fpoints)
4428 (article-narrow-to-head)
4429 (while (setq entry (pop alist))
4430 (goto-char (point-min))
4431 (setq regexp (concat "^\\("
4432 (if (string-equal "" (nth 0 entry))
4436 header-face (nth 1 entry)
4437 field-face (nth 2 entry))
4438 (while (and (re-search-forward regexp nil t)
4442 (unless (search-forward ":" nil t)
4444 (when (and header-face
4445 (not (memq (point) hpoints)))
4446 (push (point) hpoints)
4447 (gnus-put-text-property from (point) 'face header-face))
4448 (when (and field-face
4449 (not (memq (setq from (point)) fpoints)))
4451 (if (re-search-forward "^[^ \t]" nil t)
4453 (goto-char (point-max)))
4454 (gnus-put-text-property from (point) 'face field-face))))))))
4456 (defun gnus-article-highlight-signature ()
4457 "Highlight the signature in an article.
4458 It does this by highlighting everything after
4459 `gnus-signature-separator' using `gnus-signature-face'."
4462 (set-buffer gnus-article-buffer)
4463 (let ((buffer-read-only nil)
4464 (inhibit-point-motion-hooks t))
4466 (when (and gnus-signature-face
4467 (gnus-article-narrow-to-signature))
4468 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
4469 'face gnus-signature-face)
4471 (gnus-article-search-signature)
4472 (let ((start (match-beginning 0))
4473 (end (set-marker (make-marker) (1+ (match-end 0)))))
4474 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
4477 (defun gnus-button-in-region-p (b e prop)
4478 "Say whether PROP exists in the region."
4479 (text-property-not-all b e prop nil))
4481 (defun gnus-article-add-buttons (&optional force)
4482 "Find external references in the article and make buttons of them.
4483 \"External references\" are things like Message-IDs and URLs, as
4484 specified by `gnus-button-alist'."
4485 (interactive (list 'force))
4487 (set-buffer gnus-article-buffer)
4488 (let ((buffer-read-only nil)
4489 (inhibit-point-motion-hooks t)
4490 (case-fold-search t)
4491 (alist gnus-button-alist)
4493 ;; Remove all old markers.
4495 (while (setq marker (pop gnus-button-marker-list))
4497 (when (setq entry (gnus-button-entry))
4498 (put-text-property (match-beginning (nth 1 entry))
4499 (match-end (nth 1 entry))
4500 'gnus-callback nil))
4501 (set-marker marker nil)))
4502 ;; We skip the headers.
4505 (while (setq entry (pop alist))
4506 (setq regexp (car entry))
4508 (while (re-search-forward regexp nil t)
4509 (let* ((start (and entry (match-beginning (nth 1 entry))))
4510 (end (and entry (match-end (nth 1 entry))))
4511 (from (match-beginning 0)))
4512 (when (and (or (eq t (nth 2 entry))
4513 (eval (nth 2 entry)))
4514 (not (gnus-button-in-region-p
4515 start end 'gnus-callback)))
4516 ;; That optional form returned non-nil, so we add the
4518 (gnus-article-add-button
4519 start end 'gnus-button-push
4520 (car (push (set-marker (make-marker) from)
4521 gnus-button-marker-list))))))))))
4523 ;; Add buttons to the head of an article.
4524 (defun gnus-article-add-buttons-to-head ()
4525 "Add buttons to the head of the article."
4528 (set-buffer gnus-article-buffer)
4530 (let ((buffer-read-only nil)
4531 (inhibit-point-motion-hooks t)
4532 (case-fold-search t)
4533 (alist gnus-header-button-alist)
4535 (article-narrow-to-head)
4537 ;; Each alist entry.
4538 (setq entry (car alist)
4540 (goto-char (point-min))
4541 (while (re-search-forward (car entry) nil t)
4542 ;; Each header matching the entry.
4543 (setq beg (match-beginning 0))
4544 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
4545 (match-beginning 0))
4548 (while (re-search-forward (nth 1 entry) end t)
4549 ;; Each match within a header.
4550 (let* ((entry (cdr entry))
4551 (start (match-beginning (nth 1 entry)))
4552 (end (match-end (nth 1 entry)))
4553 (form (nth 2 entry)))
4554 (goto-char (match-end 0))
4556 (gnus-article-add-button
4557 start end (nth 3 entry)
4558 (buffer-substring (match-beginning (nth 4 entry))
4559 (match-end (nth 4 entry)))))))
4560 (goto-char end)))))))
4562 ;;; External functions:
4564 (defun gnus-article-add-button (from to fun &optional data)
4565 "Create a button between FROM and TO with callback FUN and data DATA."
4566 (when gnus-article-button-face
4567 (gnus-overlay-put (gnus-make-overlay from to)
4568 'face gnus-article-button-face))
4569 (gnus-add-text-properties
4571 (nconc (and gnus-article-mouse-face
4572 (list gnus-mouse-face-prop gnus-article-mouse-face))
4573 (list 'gnus-callback fun)
4574 (and data (list 'gnus-data data)))))
4576 ;;; Internal functions:
4578 (defun gnus-article-set-globals ()
4580 (set-buffer gnus-summary-buffer)
4581 (gnus-set-global-variables)))
4583 (defun gnus-signature-toggle (end)
4585 (set-buffer gnus-article-buffer)
4586 (let ((buffer-read-only nil)
4587 (inhibit-point-motion-hooks t))
4588 (if (get-text-property end 'invisible)
4589 (gnus-article-unhide-text end (point-max))
4590 (gnus-article-hide-text end (point-max) gnus-hidden-properties)))))
4592 (defun gnus-button-entry ()
4593 ;; Return the first entry in `gnus-button-alist' matching this place.
4594 (let ((alist gnus-button-alist)
4597 (setq entry (pop alist))
4598 (if (looking-at (car entry))
4603 (defun gnus-button-push (marker)
4604 ;; Push button starting at MARKER.
4607 (let* ((entry (gnus-button-entry))
4608 (inhibit-point-motion-hooks t)
4610 (args (mapcar (lambda (group)
4611 (let ((string (match-string group)))
4612 (gnus-set-text-properties
4613 0 (length string) nil string)
4620 (fboundp (symbol-value fun)))
4621 (apply (symbol-value fun) args))
4623 (gnus-message 1 "You must define `%S' to use this button"
4624 (cons fun args)))))))
4626 (defun gnus-button-message-id (message-id)
4629 (set-buffer gnus-summary-buffer)
4630 (gnus-summary-refer-article message-id)))
4632 (defun gnus-button-fetch-group (address)
4633 "Fetch GROUP specified by ADDRESS."
4634 (if (not (string-match "[:/]" address))
4635 ;; This is just a simple group url.
4636 (gnus-group-read-ephemeral-group address gnus-select-method)
4637 (if (not (string-match "^\\([^:/]+\\)\\(:\\([^/]+\\)/\\)?\\(.*\\)$"
4639 (error "Can't parse %s" address)
4640 (gnus-group-read-ephemeral-group
4641 (match-string 4 address)
4642 `(nntp ,(match-string 1 address)
4643 (nntp-address ,(match-string 1 address))
4644 (nntp-port-number ,(if (match-end 3)
4645 (match-string 3 address)
4648 (defun gnus-url-parse-query-string (query &optional downcase)
4649 (let (retval pairs cur key val)
4650 (setq pairs (split-string query "&"))
4652 (setq cur (car pairs)
4654 (if (not (string-match "=" cur))
4656 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
4657 val (gnus-url-unhex-string (substring cur (match-end 0) nil)))
4659 (setq key (downcase key)))
4660 (setq cur (assoc key retval))
4662 (setcdr cur (cons val (cdr cur)))
4663 (setq retval (cons (list key val) retval)))))
4666 (defun gnus-url-unhex (x)
4673 (defun gnus-url-unhex-string (str &optional allow-newlines)
4674 "Remove %XXX embedded spaces, etc in a url.
4675 If optional second argument ALLOW-NEWLINES is non-nil, then allow the
4676 decoding of carriage returns and line feeds in the string, which is normally
4677 forbidden in URL encoding."
4678 (setq str (or str ""))
4680 (case-fold-search t))
4681 (while (string-match "%[0-9a-f][0-9a-f]" str)
4682 (let* ((start (match-beginning 0))
4683 (ch1 (gnus-url-unhex (elt str (+ start 1))))
4685 (gnus-url-unhex (elt str (+ start 2))))))
4687 tmp (substring str 0 start)
4690 (char-to-string code))
4691 ((or (= code ?\n) (= code ?\r))
4693 (t (char-to-string code))))
4694 str (substring str (match-end 0)))))
4695 (setq tmp (concat tmp str))
4698 (defun gnus-url-mailto (url)
4699 ;; Send mail to someone
4700 (when (string-match "mailto:/*\\(.*\\)" url)
4701 (setq url (substring url (match-beginning 1) nil)))
4702 (let (to args subject func)
4703 (if (string-match (regexp-quote "?") url)
4704 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
4705 args (gnus-url-parse-query-string
4706 (substring url (match-end 0) nil) t))
4707 (setq to (gnus-url-unhex-string url)))
4708 (setq args (cons (list "to" to) args)
4709 subject (cdr-safe (assoc "subject" args)))
4710 (gnus-setup-message 'reply
4713 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
4716 (message-position-on-field (caar args)))
4717 (insert (mapconcat 'identity (cdar args) ", "))
4718 (setq args (cdr args)))
4721 (message-goto-subject)))))
4723 (defun gnus-button-mailto (address)
4725 (set-buffer (gnus-copy-article-buffer))
4726 (gnus-setup-message 'reply
4727 (message-reply address)))
4729 (defun gnus-button-reply (address)
4730 ;; Reply to ADDRESS.
4731 (gnus-setup-message 'reply
4732 (message-reply address)))
4734 (defun gnus-button-url (address)
4736 ;; In Emacs 20, `browse-url-browser-function' may be an alist.
4737 (if (listp browse-url-browser-function)
4738 (browse-url address)
4739 (funcall browse-url-browser-function address)))
4741 (defun gnus-button-embedded-url (address)
4743 ;; In Emacs 20, `browse-url-browser-function' may be an alist.
4744 (if (listp browse-url-browser-function)
4745 (browse-url (gnus-strip-whitespace address))
4746 (funcall browse-url-browser-function (gnus-strip-whitespace address))))
4748 ;;; Next/prev buttons in the article buffer.
4750 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
4751 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
4753 (defvar gnus-prev-page-map nil)
4754 (unless gnus-prev-page-map
4755 (setq gnus-prev-page-map (make-sparse-keymap))
4756 (define-key gnus-prev-page-map gnus-mouse-2 'gnus-button-prev-page)
4757 (define-key gnus-prev-page-map "\r" 'gnus-button-prev-page))
4759 (static-if (featurep 'xemacs)
4760 (defun gnus-insert-prev-page-button ()
4761 (let ((buffer-read-only nil))
4763 gnus-prev-page-line-format nil
4764 `(gnus-prev t local-map ,gnus-prev-page-map
4765 gnus-callback gnus-article-button-prev-page
4766 article-type annotation))))
4767 (defun gnus-insert-prev-page-button ()
4768 (let ((buffer-read-only nil)
4769 (situation (get-text-property (point-min) 'mime-view-situation)))
4770 (set-keymap-parent gnus-prev-page-map (current-local-map))
4772 gnus-prev-page-line-format nil
4773 `(gnus-prev t local-map ,gnus-prev-page-map
4774 gnus-callback gnus-article-button-prev-page
4775 article-type annotation
4776 mime-view-situation ,situation))))
4779 (defvar gnus-next-page-map nil)
4780 (unless gnus-next-page-map
4781 (setq gnus-next-page-map (make-sparse-keymap))
4782 (define-key gnus-next-page-map gnus-mouse-2 'gnus-button-next-page)
4783 (define-key gnus-next-page-map "\r" 'gnus-button-next-page))
4785 (defun gnus-button-next-page ()
4786 "Go to the next page."
4788 (let ((win (selected-window)))
4789 (select-window (get-buffer-window gnus-article-buffer t))
4790 (gnus-article-next-page)
4791 (select-window win)))
4793 (defun gnus-button-prev-page ()
4794 "Go to the prev page."
4796 (let ((win (selected-window)))
4797 (select-window (get-buffer-window gnus-article-buffer t))
4798 (gnus-article-prev-page)
4799 (select-window win)))
4801 (static-if (featurep 'xemacs)
4802 (defun gnus-insert-next-page-button ()
4803 (let ((buffer-read-only nil))
4804 (gnus-eval-format gnus-next-page-line-format nil
4806 t local-map ,gnus-next-page-map
4807 gnus-callback gnus-article-button-next-page
4808 article-type annotation))))
4809 (defun gnus-insert-next-page-button ()
4810 (let ((buffer-read-only nil)
4811 (situation (get-text-property (point-min) 'mime-view-situation)))
4812 (set-keymap-parent gnus-next-page-map (current-local-map))
4813 (gnus-eval-format gnus-next-page-line-format nil
4815 t local-map ,gnus-next-page-map
4816 gnus-callback gnus-article-button-next-page
4817 article-type annotation
4818 mime-view-situation ,situation))))
4821 (defun gnus-article-button-next-page (arg)
4822 "Go to the next page."
4824 (let ((win (selected-window)))
4825 (select-window (get-buffer-window gnus-article-buffer t))
4826 (gnus-article-next-page)
4827 (select-window win)))
4829 (defun gnus-article-button-prev-page (arg)
4830 "Go to the prev page."
4832 (let ((win (selected-window)))
4833 (select-window (get-buffer-window gnus-article-buffer t))
4834 (gnus-article-prev-page)
4835 (select-window win)))
4837 (defvar gnus-decode-header-methods
4838 '(mail-decode-encoded-word-region)
4839 "List of methods used to decode headers.
4841 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item is
4842 FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
4843 (REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
4844 whose names match REGEXP.
4847 ((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
4848 mail-decode-encoded-word-region
4849 (\"chinese\" . rfc1843-decode-region))
4852 (defvar gnus-decode-header-methods-cache nil)
4854 (defun gnus-multi-decode-header (start end)
4855 "Apply the functions from `gnus-encoded-word-methods' that match."
4856 (unless (and gnus-decode-header-methods-cache
4857 (eq gnus-newsgroup-name
4858 (car gnus-decode-header-methods-cache)))
4859 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
4862 (nconc gnus-decode-header-methods-cache (list x))
4863 (if (and gnus-newsgroup-name
4864 (string-match (car x) gnus-newsgroup-name))
4865 (nconc gnus-decode-header-methods-cache
4867 gnus-decode-header-methods))
4868 (let ((xlist gnus-decode-header-methods-cache))
4871 (narrow-to-region start end)
4873 (funcall (pop xlist) (point-min) (point-max))))))
4876 ;;; Treatment top-level handling.
4879 (defun gnus-treat-article (condition &optional part-number total-parts type)
4880 (let ((length (- (point-max) (point-min)))
4881 (alist gnus-treatment-function-alist)
4882 (article-goto-body-goes-to-point-min-p t)
4886 (let ((list gnus-article-treat-types))
4888 (when (string-match (pop list) type)
4889 (throw 'found t)))))))
4890 (highlightp (gnus-visual-p 'article-highlight 'highlight))
4892 (gnus-run-hooks 'gnus-part-display-hook)
4893 (while (setq elem (pop alist))
4894 (setq val (symbol-value (car elem)))
4895 (when (and (or (consp val)
4897 (gnus-treat-predicate val)
4898 (or (not (get (car elem) 'highlight))
4901 (funcall (cadr elem)))))))
4903 ;; Dynamic variables.
4904 (defvar part-number)
4905 (defvar total-parts)
4909 (defun gnus-treat-predicate (val)
4912 (not (not gnus-show-mime)))
4916 (let ((pred (pop val)))
4919 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
4921 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
4923 (not (gnus-treat-predicate val)))
4925 (equal (cadr val) type))
4927 (gnus-treat-predicate pred)))))
4935 (eq part-number total-parts))
4939 (stringp (car val)))
4940 (apply 'gnus-or (mapcar `(lambda (s)
4941 (string-match s ,(or gnus-newsgroup-name "")))
4944 (error "%S is not a valid value" val))))
4950 (defun gnus-article-header-presentation-method (entity situation)
4951 (mime-insert-header entity)
4954 (set-alist 'mime-header-presentation-method-alist
4955 'gnus-original-article-mode
4956 #'gnus-article-header-presentation-method)
4958 (defun gnus-mime-preview-quitting-method ()
4959 (mime-preview-kill-buffer)
4960 (delete-other-windows)
4961 (gnus-article-show-summary)
4962 (gnus-summary-select-article gnus-show-all-headers t))
4964 (set-alist 'mime-preview-quitting-method-alist
4965 'gnus-original-article-mode #'gnus-mime-preview-quitting-method)
4967 (defun gnus-following-method (buf)
4970 (message-yank-original)
4972 (goto-char (point-min))
4975 (set-alist 'mime-preview-following-method-alist
4976 'gnus-original-article-mode #'gnus-following-method)
4978 (set-alist 'mime-preview-over-to-previous-method-alist
4979 'gnus-original-article-mode
4981 (if (> (point-min) 1)
4982 (gnus-article-prev-page)
4983 (gnus-article-read-summary-keys
4984 nil (gnus-character-to-event ?P)))))
4986 (set-alist 'mime-preview-over-to-next-method-alist
4987 'gnus-original-article-mode'
4989 (if (< (point-max) (buffer-size))
4990 (gnus-article-next-page)
4991 (gnus-article-read-summary-keys
4992 nil (gnus-character-to-event ?N)))))
5002 (run-hooks 'gnus-art-load-hook)
5004 ;;; gnus-art.el ends here