1 ;;; gnus-art.el --- article mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
7 ;; This file is part of GNU Emacs.
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
28 (eval-when-compile (require 'cl))
41 (defgroup gnus-article nil
43 :link '(custom-manual "(gnus)The Article Buffer")
46 (defgroup gnus-article-treat nil
47 "Treating article parts."
48 :link '(custom-manual "(gnus)Article Hiding")
51 (defgroup gnus-article-hiding nil
52 "Hiding article parts."
53 :link '(custom-manual "(gnus)Article Hiding")
56 (defgroup gnus-article-highlight nil
57 "Article highlighting."
58 :link '(custom-manual "(gnus)Article Highlighting")
62 (defgroup gnus-article-signature nil
64 :link '(custom-manual "(gnus)Article Signature")
67 (defgroup gnus-article-headers nil
69 :link '(custom-manual "(gnus)Hiding Headers")
72 (defgroup gnus-article-washing nil
73 "Special commands on articles."
74 :link '(custom-manual "(gnus)Article Washing")
77 (defgroup gnus-article-emphasis nil
78 "Fontisizing articles."
79 :link '(custom-manual "(gnus)Article Fontisizing")
82 (defgroup gnus-article-saving nil
84 :link '(custom-manual "(gnus)Saving Articles")
87 (defgroup gnus-article-mime nil
88 "Worshiping the MIME wonder."
89 :link '(custom-manual "(gnus)Using MIME")
92 (defgroup gnus-article-buttons nil
93 "Pushable buttons in the article buffer."
94 :link '(custom-manual "(gnus)Article Buttons")
97 (defgroup gnus-article-various nil
98 "Other article options."
99 :link '(custom-manual "(gnus)Misc Article")
100 :group 'gnus-article)
102 (defcustom gnus-ignored-headers
103 '("^Path:" "^Expires:" "^Date-Received:" "^References:" "^Xref:" "^Lines:"
104 "^Relay-Version:" "^Message-ID:" "^Approved:" "^Sender:" "^Received:"
105 "^X-UIDL:" "^MIME-Version:" "^Return-Path:" "^In-Reply-To:"
106 "^Content-Type:" "^Content-Transfer-Encoding:" "^X-WebTV-Signature:"
107 "^X-MimeOLE:" "^X-MSMail-Priority:" "^X-Priority:" "^X-Loop:"
108 "^X-Authentication-Warning:" "^X-MIME-Autoconverted:" "^X-Face:"
109 "^X-Attribution:" "^X-Originating-IP:" "^Delivered-To:"
110 "^NNTP-[-A-Za-z]+:" "^Distribution:" "^X-no-archive:" "^X-Trace:"
111 "^X-Complaints-To:" "^X-NNTP-Posting-Host:" "^X-Orig.*:"
112 "^Abuse-Reports-To:" "^Cache-Post-Path:" "^X-Article-Creation-Date:"
113 "^X-Poster:" "^X-Mail2News-Path:" "^X-Server-Date:" "^X-Cache:"
114 "^Originator:" "^X-Problems-To:" "^X-Auth-User:" "^X-Post-Time:"
115 "^X-Admin:" "^X-UID:" "^Resent-[-A-Za-z]+:" "^X-Mailing-List:"
116 "^Precedence:" "^Original-[-A-Za-z]+:" "^X-filename:" "^X-Orcpt:"
117 "^Old-Received:" "^X-Pgp" "^X-Auth:" "^X-From-Line:"
118 "^X-Gnus-Article-Number:" "^X-Majordomo:" "^X-Url:" "^X-Sender:"
119 "^MBOX-Line" "^Priority:" "^X-Pgp" "^X400-[-A-Za-z]+:"
120 "^Status:" "^X-Gnus-Mail-Source:" "^Cancel-Lock:"
121 "^X-FTN" "^X-EXP32-SerialNo:" "^Encoding:" "^Importance:"
122 "^Autoforwarded:" "^Original-Encoded-Information-Types:" "^X-Ya-Pop3:"
123 "^X-Face-Version:" "^X-Vms-To:" "^X-ML-NAME:" "^X-ML-COUNT:"
124 "^Mailing-List:" "^X-finfo:" "^X-md5sum:" "^X-md5sum-Origin:"
125 "^X-Sun-Charset:" "^X-Accept-Language:" "^X-Envelope-Sender:"
126 "^List-[A-Za-z]+:" "^X-Listprocessor-Version:"
127 "^X-Received:" "^X-Distribute:" "^X-Sequence:" "^X-Juno-Line-Breaks:"
128 "^X-Notes-Item:" "^X-MS-TNEF-Correlator:" "^x-uunet-gateway:"
129 "^X-Received:" "^Content-length:" "X-precedence:")
130 "*All headers that start with this regexp will be hidden.
131 This variable can also be a list of regexps of headers to be ignored.
132 If `gnus-visible-headers' is non-nil, this variable will be ignored."
133 :type '(choice :custom-show nil
136 :group 'gnus-article-hiding)
138 (defcustom gnus-visible-headers
139 "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^[BGF]?Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Mail-Followup-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-From:\\|^X-Sent:"
140 "*All headers that do not match this regexp will be hidden.
141 This variable can also be a list of regexp of headers to remain visible.
142 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
143 :type '(repeat :value-to-internal (lambda (widget value)
144 (custom-split-regexp-maybe value))
145 :match (lambda (widget value)
147 (widget-editable-list-match widget value)))
149 :group 'gnus-article-hiding)
151 (defcustom gnus-sorted-header-list
152 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
153 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
154 "*This variable is a list of regular expressions.
155 If it is non-nil, headers that match the regular expressions will
156 be placed first in the article buffer in the sequence specified by
158 :type '(repeat regexp)
159 :group 'gnus-article-hiding)
161 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
162 "Headers that are only to be displayed if they have interesting data.
163 Possible values in this list are `empty', `newsgroups', `followup-to',
164 `reply-to', `date', `long-to', and `many-to'."
165 :type '(set (const :tag "Headers with no content." empty)
166 (const :tag "Newsgroups with only one group." newsgroups)
167 (const :tag "Followup-to identical to newsgroups." followup-to)
168 (const :tag "Reply-to identical to from." reply-to)
169 (const :tag "Date less than four days old." date)
170 (const :tag "Very long To and/or Cc header." long-to)
171 (const :tag "Multiple To and/or Cc headers." many-to))
172 :group 'gnus-article-hiding)
174 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
175 "Regexp matching signature separator.
176 This can also be a list of regexps. In that case, it will be checked
177 from head to tail looking for a separator. Searches will be done from
178 the end of the buffer."
179 :type '(repeat string)
180 :group 'gnus-article-signature)
182 (defcustom gnus-signature-limit nil
183 "Provide a limit to what is considered a signature.
184 If it is a number, no signature may not be longer (in characters) than
185 that number. If it is a floating point number, no signature may be
186 longer (in lines) than that number. If it is a function, the function
187 will be called without any parameters, and if it returns nil, there is
188 no signature in the buffer. If it is a string, it will be used as a
189 regexp. If it matches, the text in question is not a signature."
190 :type '(choice (integer :value 200)
192 (function :value fun)
193 (regexp :value ".*"))
194 :group 'gnus-article-signature)
196 (defcustom gnus-hidden-properties '(invisible t intangible t)
197 "Property list to use for hiding text."
199 :group 'gnus-article-hiding)
201 ;; Fixme: This isn't the right thing for mixed graphical and and
202 ;; non-graphical frames in a session.
203 ;; gnus-xmas.el overrides this for XEmacs.
204 (defcustom gnus-article-x-face-command
205 (if (and (fboundp 'image-type-available-p)
206 (image-type-available-p 'xbm))
207 'gnus-article-display-xface
208 (if gnus-article-compface-xbm
209 "{ echo '/* Width=48, Height=48 */'; uncompface; } | display -"
210 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
212 "*String or function to be executed to display an X-Face header.
213 If it is a string, the command will be executed in a sub-shell
214 asynchronously. The compressed face will be piped to this command."
215 :type '(choice string
216 (function-item gnus-article-display-xface)
218 :group 'gnus-article-washing)
220 (defcustom gnus-article-x-face-too-ugly nil
221 "Regexp matching posters whose face shouldn't be shown automatically."
222 :type '(choice regexp (const nil))
223 :group 'gnus-article-washing)
225 (defcustom gnus-article-banner-alist nil
226 "Banner alist for stripping.
228 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( eGroups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
229 :type '(repeat (cons symbol regexp))
230 :group 'gnus-article-washing)
232 (defcustom gnus-emphasis-alist
234 "\\(\\s-\\|^\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\s-\\|[-,;:\"]\\s-\\|[?!.]+\\s-\\|\\s)\\)")
236 '(("_" "_" underline)
239 ("_/" "/_" underline-italic)
240 ("_\\*" "\\*_" underline-bold)
241 ("\\*/" "/\\*" bold-italic)
242 ("_\\*/" "/\\*_" underline-bold-italic))))
243 `(("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
244 2 3 gnus-emphasis-underline)
248 (format format (car spec) (cadr spec))
249 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
251 "*Alist that says how to fontify certain phrases.
252 Each item looks like this:
254 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
256 The first element is a regular expression to be matched. The second
257 is a number that says what regular expression grouping used to find
258 the entire emphasized word. The third is a number that says what
259 regexp grouping should be displayed and highlighted. The fourth
260 is the face used for highlighting."
261 :type '(repeat (list :value ("" 0 0 default)
263 (integer :tag "Match group")
264 (integer :tag "Emphasize group")
266 :group 'gnus-article-emphasis)
268 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
269 "A regexp to describe whitespace which should not be emphasized.
270 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
271 The former avoids underlining of leading and trailing whitespace,
272 and the latter avoids underlining any whitespace at all."
273 :group 'gnus-article-emphasis
276 (defface gnus-emphasis-bold '((t (:bold t)))
277 "Face used for displaying strong emphasized text (*word*)."
278 :group 'gnus-article-emphasis)
280 (defface gnus-emphasis-italic '((t (:italic t)))
281 "Face used for displaying italic emphasized text (/word/)."
282 :group 'gnus-article-emphasis)
284 (defface gnus-emphasis-underline '((t (:underline t)))
285 "Face used for displaying underlined emphasized text (_word_)."
286 :group 'gnus-article-emphasis)
288 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
289 "Face used for displaying underlined bold emphasized text (_*word*_)."
290 :group 'gnus-article-emphasis)
292 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
293 "Face used for displaying underlined italic emphasized text (_/word/_)."
294 :group 'gnus-article-emphasis)
296 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
297 "Face used for displaying bold italic emphasized text (/*word*/)."
298 :group 'gnus-article-emphasis)
300 (defface gnus-emphasis-underline-bold-italic
301 '((t (:bold t :italic t :underline t)))
302 "Face used for displaying underlined bold italic emphasized text.
303 Esample: (_/*word*/_)."
304 :group 'gnus-article-emphasis)
306 (defface gnus-emphasis-highlight-words
307 '((t (:background "black" :foreground "yellow")))
308 "Face used for displaying highlighted words."
309 :group 'gnus-article-emphasis)
311 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
312 "Format for display of Date headers in article bodies.
313 See `format-time-string' for the possible values.
315 The variable can also be function, which should return a complete Date
316 header. The function is called with one argument, the time, which can
317 be fed to `format-time-string'."
318 :type '(choice string symbol)
319 :link '(custom-manual "(gnus)Article Date")
320 :group 'gnus-article-washing)
323 (autoload 'mail-extract-address-components "mail-extr"))
325 (defcustom gnus-save-all-headers t
326 "*If non-nil, don't remove any headers before saving."
327 :group 'gnus-article-saving
330 (defcustom gnus-prompt-before-saving 'always
331 "*This variable says how much prompting is to be done when saving articles.
332 If it is nil, no prompting will be done, and the articles will be
333 saved to the default files. If this variable is `always', each and
334 every article that is saved will be preceded by a prompt, even when
335 saving large batches of articles. If this variable is neither nil not
336 `always', there the user will be prompted once for a file name for
337 each invocation of the saving commands."
338 :group 'gnus-article-saving
339 :type '(choice (item always)
340 (item :tag "never" nil)
341 (sexp :tag "once" :format "%t\n" :value t)))
343 (defcustom gnus-saved-headers gnus-visible-headers
344 "Headers to keep if `gnus-save-all-headers' is nil.
345 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
346 If that variable is nil, however, all headers that match this regexp
347 will be kept while the rest will be deleted before saving."
348 :group 'gnus-article-saving
351 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
352 "A function to save articles in your favourite format.
353 The function must be interactively callable (in other words, it must
354 be an Emacs command).
356 Gnus provides the following functions:
358 * gnus-summary-save-in-rmail (Rmail format)
359 * gnus-summary-save-in-mail (Unix mail format)
360 * gnus-summary-save-in-folder (MH folder)
361 * gnus-summary-save-in-file (article format)
362 * gnus-summary-save-in-vm (use VM's folder format)
363 * gnus-summary-write-to-file (article format -- overwrite)."
364 :group 'gnus-article-saving
365 :type '(radio (function-item gnus-summary-save-in-rmail)
366 (function-item gnus-summary-save-in-mail)
367 (function-item gnus-summary-save-in-folder)
368 (function-item gnus-summary-save-in-file)
369 (function-item gnus-summary-save-in-vm)
370 (function-item gnus-summary-write-to-file)))
372 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
373 "A function generating a file name to save articles in Rmail format.
374 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
375 :group 'gnus-article-saving
378 (defcustom gnus-mail-save-name 'gnus-plain-save-name
379 "A function generating a file name to save articles in Unix mail format.
380 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
381 :group 'gnus-article-saving
384 (defcustom gnus-folder-save-name 'gnus-folder-save-name
385 "A function generating a file name to save articles in MH folder.
386 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
387 :group 'gnus-article-saving
390 (defcustom gnus-file-save-name 'gnus-numeric-save-name
391 "A function generating a file name to save articles in article format.
392 The function is called with NEWSGROUP, HEADERS, and optional
394 :group 'gnus-article-saving
397 (defcustom gnus-split-methods
398 '((gnus-article-archive-name)
399 (gnus-article-nndoc-name))
400 "*Variable used to suggest where articles are to be saved.
401 For instance, if you would like to save articles related to Gnus in
402 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
403 you could set this variable to something like:
405 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
406 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
408 This variable is an alist where the where the key is the match and the
409 value is a list of possible files to save in if the match is non-nil.
411 If the match is a string, it is used as a regexp match on the
412 article. If the match is a symbol, that symbol will be funcalled
413 from the buffer of the article to be saved with the newsgroup as the
414 parameter. If it is a list, it will be evaled in the same buffer.
416 If this form or function returns a string, this string will be used as
417 a possible file name; and if it returns a non-nil list, that list will
418 be used as possible file names."
419 :group 'gnus-article-saving
420 :type '(repeat (choice (list :value (fun) function)
421 (cons :value ("" "") regexp (repeat string))
424 (defcustom gnus-page-delimiter "^\^L"
425 "*Regexp describing what to use as article page delimiters.
426 The default value is \"^\^L\", which is a form linefeed at the
427 beginning of a line."
429 :group 'gnus-article-various)
431 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
432 "*The format specification for the article mode line.
433 See `gnus-summary-mode-line-format' for a closer description.
435 The following additional specs are available:
437 %w The article washing status.
438 %m The number of MIME parts in the article."
440 :group 'gnus-article-various)
442 (defcustom gnus-article-mode-hook nil
443 "*A hook for Gnus article mode."
445 :group 'gnus-article-various)
447 (defcustom gnus-article-menu-hook nil
448 "*Hook run after the creation of the article mode menu."
450 :group 'gnus-article-various)
452 (defcustom gnus-article-prepare-hook nil
453 "*A hook called after an article has been prepared in the article buffer."
455 :group 'gnus-article-various)
457 (defcustom gnus-article-hide-pgp-hook nil
458 "*A hook called after successfully hiding a PGP signature."
460 :group 'gnus-article-various)
462 (defcustom gnus-article-button-face 'bold
463 "Face used for highlighting buttons in the article buffer.
465 An article button is a piece of text that you can activate by pressing
466 `RET' or `mouse-2' above it."
468 :group 'gnus-article-buttons)
470 (defcustom gnus-article-mouse-face 'highlight
471 "Face used for mouse highlighting in the article buffer.
473 Article buttons will be displayed in this face when the cursor is
476 :group 'gnus-article-buttons)
478 (defcustom gnus-signature-face 'gnus-signature-face
479 "Face used for highlighting a signature in the article buffer.
480 Obsolete; use the face `gnus-signature-face' for customizations instead."
482 :group 'gnus-article-highlight
483 :group 'gnus-article-signature)
485 (defface gnus-signature-face
488 "Face used for highlighting a signature in the article buffer."
489 :group 'gnus-article-highlight
490 :group 'gnus-article-signature)
492 (defface gnus-header-from-face
495 (:foreground "spring green"))
498 (:foreground "red3"))
501 "Face used for displaying from headers."
502 :group 'gnus-article-headers
503 :group 'gnus-article-highlight)
505 (defface gnus-header-subject-face
508 (:foreground "SeaGreen3"))
511 (:foreground "red4"))
513 (:bold t :italic t)))
514 "Face used for displaying subject headers."
515 :group 'gnus-article-headers
516 :group 'gnus-article-highlight)
518 (defface gnus-header-newsgroups-face
521 (:foreground "yellow" :italic t))
524 (:foreground "MidnightBlue" :italic t))
527 "Face used for displaying newsgroups headers."
528 :group 'gnus-article-headers
529 :group 'gnus-article-highlight)
531 (defface gnus-header-name-face
534 (:foreground "SeaGreen"))
537 (:foreground "maroon"))
540 "Face used for displaying header names."
541 :group 'gnus-article-headers
542 :group 'gnus-article-highlight)
544 (defface gnus-header-content-face
547 (:foreground "forest green" :italic t))
550 (:foreground "indianred4" :italic t))
552 (:italic t))) "Face used for displaying header content."
553 :group 'gnus-article-headers
554 :group 'gnus-article-highlight)
556 (defcustom gnus-header-face-alist
557 '(("From" nil gnus-header-from-face)
558 ("Subject" nil gnus-header-subject-face)
559 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
560 ("" gnus-header-name-face gnus-header-content-face))
561 "*Controls highlighting of article header.
563 An alist of the form (HEADER NAME CONTENT).
565 HEADER is a regular expression which should match the name of an
566 header header and NAME and CONTENT are either face names or nil.
568 The name of each header field will be displayed using the face
569 specified by the first element in the list where HEADER match the
570 header name and NAME is non-nil. Similarly, the content will be
571 displayed by the first non-nil matching CONTENT face."
572 :group 'gnus-article-headers
573 :group 'gnus-article-highlight
574 :type '(repeat (list (regexp :tag "Header")
576 (item :tag "skip" nil)
577 (face :value default))
578 (choice :tag "Content"
579 (item :tag "skip" nil)
580 (face :value default)))))
582 (defcustom gnus-article-decode-hook
583 '(article-decode-charset article-decode-encoded-words)
584 "*Hook run to decode charsets in articles."
585 :group 'gnus-article-headers
588 (defcustom gnus-display-mime-function 'gnus-display-mime
589 "Function to display MIME articles."
590 :group 'gnus-article-mime
593 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
594 "Function used to decode headers.")
596 (defvar gnus-article-dumbquotes-map
614 "Table for MS-to-Latin1 translation.")
616 (defcustom gnus-ignored-mime-types nil
617 "List of MIME types that should be ignored by Gnus."
618 :group 'gnus-article-mime
619 :type '(repeat regexp))
621 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
622 "List of MIME types that should not be given buttons when rendered inline."
623 :group 'gnus-article-mime
624 :type '(repeat regexp))
626 (defcustom gnus-article-mime-part-function nil
627 "Function called with a MIME handle as the argument.
628 This is meant for people who want to do something automatic based
629 on parts -- for instance, adding Vcard info to a database."
630 :group 'gnus-article-mime
633 (defcustom gnus-mime-multipart-functions nil
634 "An alist of MIME types to functions to display them.")
636 (defcustom gnus-article-date-lapsed-new-header nil
637 "Whether the X-Sent and Date headers can coexist.
638 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
639 either replace the old \"Date:\" header (if this variable is nil), or
640 be added below it (otherwise)."
641 :group 'gnus-article-headers
644 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
645 "Function called with a MIME handle as the argument.
646 This is meant for people who want to view first matched part.
647 For `undisplayed-alternative' (default), the first undisplayed
648 part or alternative part is used. For `undisplayed', the first
649 undisplayed part is used. For a function, the first part which
650 the function return `t' is used. For `nil', the first part is
652 :group 'gnus-article-mime
654 (item :tag "first" :value nil)
655 (item :tag "undisplayed" :value undisplayed)
656 (item :tag "undisplayed or alternative"
657 :value undisplayed-alternative)
660 (defcustom gnus-mime-action-alist
661 '(("save to file" . gnus-mime-save-part)
662 ("save and strip" . gnus-mime-save-part-and-strip)
663 ("display as text" . gnus-mime-inline-part)
664 ("view the part" . gnus-mime-view-part)
665 ("pipe to command" . gnus-mime-pipe-part)
666 ("toggle display" . gnus-article-press-button)
667 ("view as type" . gnus-mime-view-part-as-type)
668 ("internalize type" . gnus-mime-internalize-part)
669 ("externalize type" . gnus-mime-externalize-part))
670 "An alist of actions that run on the MIME attachment."
671 :group 'gnus-article-mime
672 :type '(repeat (cons (string :tag "name")
676 ;;; The treatment variables
679 (defvar gnus-part-display-hook nil
680 "Hook called on parts that are to receive treatment.")
682 (defvar gnus-article-treat-custom
683 '(choice (const :tag "Off" nil)
685 (const :tag "Header" head)
686 (const :tag "Last" last)
687 (integer :tag "Less")
688 (repeat :tag "Groups" regexp)
689 (sexp :tag "Predicate")))
691 (defvar gnus-article-treat-head-custom
692 '(choice (const :tag "Off" nil)
693 (const :tag "Header" head)))
695 (defvar gnus-article-treat-types '("text/plain")
698 (defvar gnus-inhibit-treatment nil
699 "Whether to inhibit treatment.")
701 (defcustom gnus-treat-highlight-signature '(or last (typep "text/x-vcard"))
702 "Highlight the signature.
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-custom)
707 (put 'gnus-treat-highlight-signature 'highlight t)
709 (defcustom gnus-treat-buttonize 100000
711 Valid values are nil, t, `head', `last', an integer or a predicate.
712 See the manual for details."
713 :group 'gnus-article-treat
714 :type gnus-article-treat-custom)
715 (put 'gnus-treat-buttonize 'highlight t)
717 (defcustom gnus-treat-buttonize-head 'head
718 "Add buttons to the head.
719 Valid values are nil, t, `head', `last', an integer or a predicate.
720 See the manual for details."
721 :group 'gnus-article-treat
722 :type gnus-article-treat-head-custom)
723 (put 'gnus-treat-buttonize-head 'highlight t)
725 (defcustom gnus-treat-emphasize 50000
727 Valid values are nil, t, `head', `last', an integer or a predicate.
728 See the manual for details."
729 :group 'gnus-article-treat
730 :type gnus-article-treat-custom)
731 (put 'gnus-treat-emphasize 'highlight t)
733 (defcustom gnus-treat-strip-cr nil
734 "Remove carriage returns.
735 Valid values are nil, t, `head', `last', an integer or a predicate.
736 See the manual for details."
737 :group 'gnus-article-treat
738 :type gnus-article-treat-custom)
740 (defcustom gnus-treat-hide-headers 'head
742 Valid values are nil, t, `head', `last', an integer or a predicate.
743 See the manual for details."
744 :group 'gnus-article-treat
745 :type gnus-article-treat-head-custom)
747 (defcustom gnus-treat-hide-boring-headers nil
748 "Hide boring headers.
749 Valid values are nil, t, `head', `last', an integer or a predicate.
750 See the manual for details."
751 :group 'gnus-article-treat
752 :type gnus-article-treat-head-custom)
754 (defcustom gnus-treat-hide-signature nil
756 Valid values are nil, t, `head', `last', an integer or a predicate.
757 See the manual for details."
758 :group 'gnus-article-treat
759 :type gnus-article-treat-custom)
761 (defcustom gnus-treat-fill-article nil
763 Valid values are nil, t, `head', `last', an integer or a predicate.
764 See the manual for details."
765 :group 'gnus-article-treat
766 :type gnus-article-treat-custom)
768 (defcustom gnus-treat-hide-citation nil
770 Valid values are nil, t, `head', `last', an integer or a predicate.
771 See the manual for details."
772 :group 'gnus-article-treat
773 :type gnus-article-treat-custom)
775 (defcustom gnus-treat-hide-citation-maybe nil
777 Valid values are nil, t, `head', `last', an integer or a predicate.
778 See the manual for details."
779 :group 'gnus-article-treat
780 :type gnus-article-treat-custom)
782 (defcustom gnus-treat-strip-list-identifiers 'head
783 "Strip list identifiers from `gnus-list-identifiers`.
784 Valid values are nil, t, `head', `last', an integer or a predicate.
785 See the manual for details."
786 :group 'gnus-article-treat
787 :type gnus-article-treat-custom)
789 (defcustom gnus-treat-strip-pgp t
790 "Strip PGP signatures.
791 Valid values are nil, t, `head', `last', an integer or a predicate.
792 See the manual for details."
793 :group 'gnus-article-treat
794 :type gnus-article-treat-custom)
796 (defcustom gnus-treat-strip-pem nil
797 "Strip PEM signatures.
798 Valid values are nil, t, `head', `last', an integer or a predicate.
799 See the manual for details."
800 :group 'gnus-article-treat
801 :type gnus-article-treat-custom)
803 (defcustom gnus-treat-strip-banner t
804 "Strip banners from articles.
805 The banner to be stripped is specified in the `banner' group parameter.
806 Valid values are nil, t, `head', `last', an integer or a predicate.
807 See the manual for details."
808 :group 'gnus-article-treat
809 :type gnus-article-treat-custom)
811 (defcustom gnus-treat-highlight-headers 'head
812 "Highlight the headers.
813 Valid values are nil, t, `head', `last', an integer or a predicate.
814 See the manual for details."
815 :group 'gnus-article-treat
816 :type gnus-article-treat-head-custom)
817 (put 'gnus-treat-highlight-headers 'highlight t)
819 (defcustom gnus-treat-highlight-citation t
820 "Highlight cited text.
821 Valid values are nil, t, `head', `last', an integer or a predicate.
822 See the manual for details."
823 :group 'gnus-article-treat
824 :type gnus-article-treat-custom)
825 (put 'gnus-treat-highlight-citation 'highlight t)
827 (defcustom gnus-treat-date-ut nil
828 "Display the Date in UT (GMT).
829 Valid values are nil, t, `head', `last', an integer or a predicate.
830 See the manual for details."
831 :group 'gnus-article-treat
832 :type gnus-article-treat-head-custom)
834 (defcustom gnus-treat-date-local nil
835 "Display the Date in the local timezone.
836 Valid values are nil, t, `head', `last', an integer or a predicate.
837 See the manual for details."
838 :group 'gnus-article-treat
839 :type gnus-article-treat-head-custom)
841 (defcustom gnus-treat-date-lapsed nil
842 "Display the Date header in a way that says how much time has elapsed.
843 Valid values are nil, t, `head', `last', an integer or a predicate.
844 See the manual for details."
845 :group 'gnus-article-treat
846 :type gnus-article-treat-head-custom)
848 (defcustom gnus-treat-date-original nil
849 "Display the date in the original timezone.
850 Valid values are nil, t, `head', `last', an integer or a predicate.
851 See the manual for details."
852 :group 'gnus-article-treat
853 :type gnus-article-treat-head-custom)
855 (defcustom gnus-treat-date-iso8601 nil
856 "Display the date in the ISO8601 format.
857 Valid values are nil, t, `head', `last', an integer or a predicate.
858 See the manual for details."
859 :group 'gnus-article-treat
860 :type gnus-article-treat-head-custom)
862 (defcustom gnus-treat-date-user-defined nil
863 "Display the date in a user-defined format.
864 The format is defined by the `gnus-article-time-format' variable.
865 Valid values are nil, t, `head', `last', an integer or a predicate.
866 See the manual for details."
867 :group 'gnus-article-treat
868 :type gnus-article-treat-head-custom)
870 (defcustom gnus-treat-strip-headers-in-body t
871 "Strip the X-No-Archive header line from the beginning of the body.
872 Valid values are nil, t, `head', `last', an integer or a predicate.
873 See the manual for details."
874 :group 'gnus-article-treat
875 :type gnus-article-treat-custom)
877 (defcustom gnus-treat-strip-trailing-blank-lines nil
878 "Strip trailing blank lines.
879 Valid values are nil, t, `head', `last', an integer or a predicate.
880 See the manual for details."
881 :group 'gnus-article-treat
882 :type gnus-article-treat-custom)
884 (defcustom gnus-treat-strip-leading-blank-lines nil
885 "Strip leading blank lines.
886 Valid values are nil, t, `head', `last', an integer or a predicate.
887 See the manual for details."
888 :group 'gnus-article-treat
889 :type gnus-article-treat-custom)
891 (defcustom gnus-treat-strip-multiple-blank-lines nil
892 "Strip multiple blank lines.
893 Valid values are nil, t, `head', `last', an integer or a predicate.
894 See the manual for details."
895 :group 'gnus-article-treat
896 :type gnus-article-treat-custom)
898 (defcustom gnus-treat-overstrike t
899 "Treat overstrike highlighting.
900 Valid values are nil, t, `head', `last', an integer or a predicate.
901 See the manual for details."
902 :group 'gnus-article-treat
903 :type gnus-article-treat-custom)
904 (put 'gnus-treat-overstrike 'highlight t)
906 (defcustom gnus-treat-display-xface
907 (and (or (and (fboundp 'image-type-available-p)
908 (image-type-available-p 'xbm)
909 (string-match "^0x" (shell-command-to-string "uncompface")))
910 (and (featurep 'xemacs) (featurep 'xface)))
912 "Display X-Face headers.
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-head-custom)
917 (put 'gnus-treat-display-xface 'highlight t)
919 (defcustom gnus-treat-display-smileys
920 (if (or (and (featurep 'xemacs)
922 (and (fboundp 'image-type-available-p)
923 (image-type-available-p 'pbm)))
926 Valid values are nil, t, `head', `last', an integer or a predicate.
927 See the manual for details."
928 :group 'gnus-article-treat
929 :type gnus-article-treat-custom)
930 (put 'gnus-treat-display-smileys 'highlight t)
932 (defcustom gnus-treat-display-picons (if (featurep 'xemacs) 'head nil)
934 Valid values are nil, t, `head', `last', an integer or a predicate.
935 See the manual for details."
936 :group 'gnus-article-treat
937 :type gnus-article-treat-head-custom)
938 (put 'gnus-treat-display-picons 'highlight t)
940 (defcustom gnus-treat-capitalize-sentences nil
941 "Capitalize sentence-starting words.
942 Valid values are nil, t, `head', `last', an integer or a predicate.
943 See the manual for details."
944 :group 'gnus-article-treat
945 :type gnus-article-treat-custom)
947 (defcustom gnus-treat-fill-long-lines nil
949 Valid values are nil, t, `head', `last', an integer or a predicate.
950 See the manual for details."
951 :group 'gnus-article-treat
952 :type gnus-article-treat-custom)
954 (defcustom gnus-treat-play-sounds nil
956 Valid values are nil, t, `head', `last', an integer or a predicate.
957 See the manual for details."
958 :group 'gnus-article-treat
959 :type gnus-article-treat-custom)
961 (defcustom gnus-treat-translate nil
962 "Translate articles from one language to another.
963 Valid values are nil, t, `head', `last', an integer or a predicate.
964 See the manual for details."
965 :group 'gnus-article-treat
966 :type gnus-article-treat-custom)
968 ;;; Internal variables
970 (defvar article-goto-body-goes-to-point-min-p nil)
971 (defvar gnus-article-wash-types nil)
972 (defvar gnus-article-emphasis-alist nil)
974 (defvar gnus-article-mime-handle-alist-1 nil)
975 (defvar gnus-treatment-function-alist
976 '((gnus-treat-strip-banner gnus-article-strip-banner)
977 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
978 (gnus-treat-highlight-signature gnus-article-highlight-signature)
979 (gnus-treat-buttonize gnus-article-add-buttons)
980 (gnus-treat-fill-article gnus-article-fill-cited-article)
981 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
982 (gnus-treat-strip-cr gnus-article-remove-cr)
983 (gnus-treat-emphasize gnus-article-emphasize)
984 (gnus-treat-display-xface gnus-article-display-x-face)
985 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
986 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
987 (gnus-treat-hide-signature gnus-article-hide-signature)
988 (gnus-treat-hide-citation gnus-article-hide-citation)
989 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
990 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
991 (gnus-treat-strip-pgp gnus-article-hide-pgp)
992 (gnus-treat-strip-pem gnus-article-hide-pem)
993 (gnus-treat-highlight-headers gnus-article-highlight-headers)
994 (gnus-treat-highlight-citation gnus-article-highlight-citation)
995 (gnus-treat-highlight-signature gnus-article-highlight-signature)
996 (gnus-treat-date-ut gnus-article-date-ut)
997 (gnus-treat-date-local gnus-article-date-local)
998 (gnus-treat-date-lapsed gnus-article-date-lapsed)
999 (gnus-treat-date-original gnus-article-date-original)
1000 (gnus-treat-date-user-defined gnus-article-date-user)
1001 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1002 (gnus-treat-strip-trailing-blank-lines
1003 gnus-article-remove-trailing-blank-lines)
1004 (gnus-treat-strip-leading-blank-lines
1005 gnus-article-strip-leading-blank-lines)
1006 (gnus-treat-strip-multiple-blank-lines
1007 gnus-article-strip-multiple-blank-lines)
1008 (gnus-treat-overstrike gnus-article-treat-overstrike)
1009 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1010 (gnus-treat-display-smileys gnus-smiley-display)
1011 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1012 (gnus-treat-display-picons gnus-article-display-picons)
1013 (gnus-treat-play-sounds gnus-earcon-display)))
1015 (defvar gnus-article-mime-handle-alist nil)
1016 (defvar article-lapsed-timer nil)
1017 (defvar gnus-article-current-summary nil)
1019 (defvar gnus-article-mode-syntax-table
1020 (let ((table (copy-syntax-table text-mode-syntax-table)))
1021 (modify-syntax-entry ?- "w" table)
1022 (modify-syntax-entry ?> ")" table)
1023 (modify-syntax-entry ?< "(" table)
1025 "Syntax table used in article mode buffers.
1026 Initialized from `text-mode-syntax-table.")
1028 (defvar gnus-save-article-buffer nil)
1030 (defvar gnus-article-mode-line-format-alist
1031 (nconc '((?w (gnus-article-wash-status) ?s)
1032 (?m (gnus-article-mime-part-status) ?s))
1033 gnus-summary-mode-line-format-alist))
1035 (defvar gnus-number-of-articles-to-be-saved nil)
1037 (defvar gnus-inhibit-hiding nil)
1039 (defsubst gnus-article-hide-text (b e props)
1040 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1041 (add-text-properties b e props)
1042 (when (memq 'intangible props)
1044 (max (1- b) (point-min))
1045 b 'intangible (cddr (memq 'intangible props)))))
1046 (defsubst gnus-article-unhide-text (b e)
1047 "Remove hidden text properties from region between B and E."
1048 (remove-text-properties b e gnus-hidden-properties)
1049 (when (memq 'intangible gnus-hidden-properties)
1050 (put-text-property (max (1- b) (point-min))
1051 b 'intangible nil)))
1053 (defun gnus-article-hide-text-type (b e type)
1054 "Hide text of TYPE between B and E."
1055 (push type gnus-article-wash-types)
1056 (gnus-article-hide-text
1057 b e (cons 'article-type (cons type gnus-hidden-properties))))
1059 (defun gnus-article-unhide-text-type (b e type)
1060 "Unhide text of TYPE between B and E."
1061 (setq gnus-article-wash-types
1062 (delq type gnus-article-wash-types))
1063 (remove-text-properties
1064 b e (cons 'article-type (cons type gnus-hidden-properties)))
1065 (when (memq 'intangible gnus-hidden-properties)
1066 (put-text-property (max (1- b) (point-min))
1067 b 'intangible nil)))
1069 (defun gnus-article-hide-text-of-type (type)
1070 "Hide text of TYPE in the current buffer."
1072 (let ((b (point-min))
1074 (while (setq b (text-property-any b e 'article-type type))
1075 (add-text-properties b (incf b) gnus-hidden-properties)))))
1077 (defun gnus-article-delete-text-of-type (type)
1078 "Delete text of TYPE in the current buffer."
1080 (let ((b (point-min)))
1081 (while (setq b (text-property-any b (point-max) 'article-type type))
1083 b (or (text-property-not-all b (point-max) 'article-type type)
1086 (defun gnus-article-delete-invisible-text ()
1087 "Delete all invisible text in the current buffer."
1089 (let ((b (point-min)))
1090 (while (setq b (text-property-any b (point-max) 'invisible t))
1092 b (or (text-property-not-all b (point-max) 'invisible t)
1095 (defun gnus-article-text-type-exists-p (type)
1096 "Say whether any text of type TYPE exists in the buffer."
1097 (text-property-any (point-min) (point-max) 'article-type type))
1099 (defsubst gnus-article-header-rank ()
1100 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1101 (let ((list gnus-sorted-header-list)
1104 (when (looking-at (car list))
1106 (setq list (cdr list))
1110 (defun article-hide-headers (&optional arg delete)
1111 "Hide unwanted headers and possibly sort them as well."
1113 ;; This function might be inhibited.
1114 (unless gnus-inhibit-hiding
1117 (let ((buffer-read-only nil)
1118 (case-fold-search t)
1119 (max (1+ (length gnus-sorted-header-list)))
1120 (ignored (when (not gnus-visible-headers)
1121 (cond ((stringp gnus-ignored-headers)
1122 gnus-ignored-headers)
1123 ((listp gnus-ignored-headers)
1124 (mapconcat 'identity gnus-ignored-headers
1127 (cond ((stringp gnus-visible-headers)
1128 gnus-visible-headers)
1129 ((and gnus-visible-headers
1130 (listp gnus-visible-headers))
1131 (mapconcat 'identity gnus-visible-headers "\\|"))))
1132 (inhibit-point-motion-hooks t)
1134 ;; First we narrow to just the headers.
1135 (article-narrow-to-head)
1136 ;; Hide any "From " lines at the beginning of (mail) articles.
1137 (while (looking-at "From ")
1140 (delete-region (point-min) (point)))
1141 ;; Then treat the rest of the header lines.
1142 ;; Then we use the two regular expressions
1143 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1144 ;; select which header lines is to remain visible in the
1146 (while (re-search-forward "^[^ \t]*:" nil t)
1148 ;; Mark the rank of the header.
1150 (point) (1+ (point)) 'message-rank
1151 (if (or (and visible (looking-at visible))
1153 (not (looking-at ignored))))
1154 (gnus-article-header-rank)
1157 (message-sort-headers-1)
1158 (when (setq beg (text-property-any
1159 (point-min) (point-max) 'message-rank (+ 2 max)))
1160 ;; We delete the unwanted headers.
1161 (push 'headers gnus-article-wash-types)
1162 (add-text-properties (point-min) (+ 5 (point-min))
1163 '(article-type headers dummy-invisible t))
1164 (delete-region beg (point-max))))))))
1166 (defun article-hide-boring-headers (&optional arg)
1167 "Toggle hiding of headers that aren't very interesting.
1168 If given a negative prefix, always show; if given a positive prefix,
1170 (interactive (gnus-article-hidden-arg))
1171 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1172 (not gnus-show-all-headers))
1175 (let ((buffer-read-only nil)
1176 (list gnus-boring-article-headers)
1177 (inhibit-point-motion-hooks t)
1179 (article-narrow-to-head)
1181 (setq elem (pop list))
1182 (goto-char (point-min))
1184 ;; Hide empty headers.
1186 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1188 (gnus-article-hide-text-type
1189 (progn (beginning-of-line) (point))
1192 (if (re-search-forward "^[^ \t]" nil t)
1196 ;; Hide boring Newsgroups header.
1197 ((eq elem 'newsgroups)
1198 (when (equal (gnus-fetch-field "newsgroups")
1199 (gnus-group-real-name
1200 (if (boundp 'gnus-newsgroup-name)
1203 (gnus-article-hide-header "newsgroups")))
1204 ((eq elem 'followup-to)
1205 (when (equal (message-fetch-field "followup-to")
1206 (message-fetch-field "newsgroups"))
1207 (gnus-article-hide-header "followup-to")))
1208 ((eq elem 'reply-to)
1209 (let ((from (message-fetch-field "from"))
1210 (reply-to (message-fetch-field "reply-to")))
1215 (nth 1 (mail-extract-address-components from))
1216 (nth 1 (mail-extract-address-components reply-to)))))
1217 (gnus-article-hide-header "reply-to"))))
1219 (let ((date (message-fetch-field "date")))
1221 (< (days-between (current-time-string) date)
1223 (gnus-article-hide-header "date"))))
1225 (let ((to (message-fetch-field "to"))
1226 (cc (message-fetch-field "cc")))
1227 (when (> (length to) 1024)
1228 (gnus-article-hide-header "to"))
1229 (when (> (length cc) 1024)
1230 (gnus-article-hide-header "cc"))))
1234 (goto-char (point-min))
1235 (while (re-search-forward "^to:" nil t)
1236 (setq to-count (1+ to-count)))
1237 (when (> to-count 1)
1238 (while (> to-count 0)
1239 (goto-char (point-min))
1241 (re-search-forward "^to:" nil nil to-count)
1243 (narrow-to-region (point) (point-max))
1244 (gnus-article-hide-header "to"))
1245 (setq to-count (1- to-count))))
1246 (goto-char (point-min))
1247 (while (re-search-forward "^cc:" nil t)
1248 (setq cc-count (1+ cc-count)))
1249 (when (> cc-count 1)
1250 (while (> cc-count 0)
1251 (goto-char (point-min))
1253 (re-search-forward "^cc:" nil nil cc-count)
1255 (narrow-to-region (point) (point-max))
1256 (gnus-article-hide-header "cc"))
1257 (setq cc-count (1- cc-count)))))))))))))
1259 (defun gnus-article-hide-header (header)
1261 (goto-char (point-min))
1262 (when (re-search-forward (concat "^" header ":") nil t)
1263 (gnus-article-hide-text-type
1264 (progn (beginning-of-line) (point))
1267 (if (re-search-forward "^[^ \t]" nil t)
1272 (defvar gnus-article-normalized-header-length 40
1273 "Length of normalized headers.")
1275 (defun article-normalize-headers ()
1276 "Make all header lines 40 characters long."
1278 (let ((buffer-read-only nil)
1282 (article-narrow-to-head)
1285 ((< (setq column (- (gnus-point-at-eol) (point)))
1286 gnus-article-normalized-header-length)
1288 (insert (make-string
1289 (- gnus-article-normalized-header-length column)
1291 ((> column gnus-article-normalized-header-length)
1292 (gnus-put-text-property
1294 (forward-char gnus-article-normalized-header-length)
1301 (forward-line 1))))))
1303 (defun article-treat-dumbquotes ()
1304 "Translate M******** sm*rtq**t*s into proper text.
1305 Note that this function guesses whether a character is a sm*rtq**t* or
1306 not, so it should only be used interactively."
1308 (article-translate-strings gnus-article-dumbquotes-map))
1310 (defun article-translate-characters (from to)
1311 "Translate all characters in the body of the article according to FROM and TO.
1312 FROM is a string of characters to translate from; to is a string of
1313 characters to translate to."
1315 (when (article-goto-body)
1316 (let ((buffer-read-only nil)
1317 (x (make-string 225 ?x))
1319 (while (< (incf i) (length x))
1322 (while (< i (length from))
1323 (aset x (aref from i) (aref to i))
1325 (translate-region (point) (point-max) x)))))
1327 (defun article-translate-strings (map)
1328 "Translate all string in the body of the article according to MAP.
1329 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1331 (when (article-goto-body)
1332 (let ((buffer-read-only nil)
1334 (while (setq elem (pop map))
1336 (while (search-forward (car elem) nil t)
1337 (replace-match (cadr elem)))))))))
1339 (defun article-treat-overstrike ()
1340 "Translate overstrikes into bold text."
1343 (when (article-goto-body)
1344 (let ((buffer-read-only nil))
1345 (while (search-forward "\b" nil t)
1346 (let ((next (char-after))
1347 (previous (char-after (- (point) 2))))
1348 ;; We do the boldification/underlining by hiding the
1349 ;; overstrikes and putting the proper text property
1353 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1354 (put-text-property (point) (1+ (point)) 'face 'bold))
1356 (gnus-article-hide-text-type
1357 (1- (point)) (1+ (point)) 'overstrike)
1359 (- (point) 2) (1- (point)) 'face 'underline))
1361 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1363 (point) (1+ (point)) 'face 'underline)))))))))
1365 (defun article-fill-long-lines ()
1366 "Fill lines that are wider than the window width."
1369 (let ((buffer-read-only nil)
1370 (width (window-width (get-buffer-window (current-buffer)))))
1373 (let ((adaptive-fill-mode nil))
1376 (when (>= (current-column) (min fill-column width))
1377 (narrow-to-region (point) (gnus-point-at-bol))
1378 (fill-paragraph nil)
1379 (goto-char (point-max))
1381 (forward-line 1)))))))
1383 (defun article-capitalize-sentences ()
1384 "Capitalize the first word in each sentence."
1387 (let ((buffer-read-only nil)
1388 (paragraph-start "^[\n\^L]"))
1392 (forward-sentence)))))
1394 (defun article-remove-cr ()
1395 "Remove trailing CRs and then translate remaining CRs into LFs."
1398 (let ((buffer-read-only nil))
1399 (goto-char (point-min))
1400 (while (re-search-forward "\r+$" nil t)
1401 (replace-match "" t t))
1402 (goto-char (point-min))
1403 (while (search-forward "\r" nil t)
1404 (replace-match "\n" t t)))))
1406 (defun article-remove-trailing-blank-lines ()
1407 "Remove all trailing blank lines from the article."
1410 (let ((buffer-read-only nil))
1411 (goto-char (point-max))
1415 (while (and (not (bobp))
1416 (looking-at "^[ \t]*$")
1417 (not (gnus-annotation-in-region-p
1418 (point) (gnus-point-at-eol))))
1423 (defun article-display-x-face (&optional force)
1424 "Look for an X-Face header and display it if present."
1425 (interactive (list 'force))
1427 ;; Delete the old process, if any.
1428 (when (process-status "article-x-face")
1429 (delete-process "article-x-face"))
1430 (let ((inhibit-point-motion-hooks t)
1431 (case-fold-search t)
1434 (article-narrow-to-head)
1435 (goto-char (point-min))
1436 (setq from (message-fetch-field "from"))
1437 (goto-char (point-min))
1438 (while (and gnus-article-x-face-command
1441 ;; Check whether this face is censored.
1442 (not gnus-article-x-face-too-ugly)
1443 (and gnus-article-x-face-too-ugly from
1444 (not (string-match gnus-article-x-face-too-ugly
1446 ;; Has to be present.
1447 (re-search-forward "^X-Face: " nil t))
1448 ;; This used to try to do multiple faces (`while' instead of
1449 ;; `when' above), but (a) sending multiple EOFs to xv doesn't
1450 ;; work (b) it can crash some versions of Emacs (c) are
1451 ;; multiple faces really something to encourage?
1452 (when (stringp gnus-article-x-face-command)
1454 ;; We now have the area of the buffer where the X-Face is stored.
1457 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
1458 ;; We display the face.
1459 (if (symbolp gnus-article-x-face-command)
1460 ;; The command is a lisp function, so we call it.
1461 (if (gnus-functionp gnus-article-x-face-command)
1462 (funcall gnus-article-x-face-command beg end)
1463 (error "%s is not a function" gnus-article-x-face-command))
1464 ;; The command is a string, so we interpret the command
1465 ;; as a, well, command, and fork it off.
1466 (let ((process-connection-type nil))
1467 (process-kill-without-query
1469 "article-x-face" nil shell-file-name shell-command-switch
1470 gnus-article-x-face-command))
1471 (process-send-region "article-x-face" beg end)
1472 (process-send-eof "article-x-face"))))))))))
1474 (defun article-decode-mime-words ()
1475 "Decode all MIME-encoded words in the article."
1478 (set-buffer gnus-article-buffer)
1479 (let ((inhibit-point-motion-hooks t)
1481 (mail-parse-charset gnus-newsgroup-charset)
1482 (mail-parse-ignored-charsets
1483 (save-excursion (set-buffer gnus-summary-buffer)
1484 gnus-newsgroup-ignored-charsets)))
1485 (mail-decode-encoded-word-region (point-min) (point-max)))))
1487 (defun article-decode-charset (&optional prompt)
1488 "Decode charset-encoded text in the article.
1489 If PROMPT (the prefix), prompt for a coding system to use."
1491 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
1493 (mail-parse-charset gnus-newsgroup-charset)
1494 (mail-parse-ignored-charsets
1495 (save-excursion (condition-case nil
1496 (set-buffer gnus-summary-buffer)
1498 gnus-newsgroup-ignored-charsets))
1499 ct cte ctl charset format)
1502 (article-narrow-to-head)
1503 (setq ct (message-fetch-field "Content-Type" t)
1504 cte (message-fetch-field "Content-Transfer-Encoding" t)
1505 ctl (and ct (ignore-errors
1506 (mail-header-parse-content-type ct)))
1509 (mm-read-coding-system "Charset to decode: "))
1511 (mail-content-type-get ctl 'charset)))
1512 format (and ctl (mail-content-type-get ctl 'format)))
1514 (setq cte (mail-header-strip cte)))
1515 (if (and ctl (not (string-match "/" (car ctl))))
1517 (goto-char (point-max)))
1520 (narrow-to-region (point) (point-max))
1521 (when (and (eq mail-parse-charset 'gnus-decoded)
1522 (eq (mm-body-7-or-8) '8bit))
1523 ;; The text code could have been decoded.
1524 (setq charset mail-parse-charset))
1525 (when (and (or (not ctl)
1526 (equal (car ctl) "text/plain"))
1527 (not format)) ;; article with format will decode later.
1529 charset (and cte (intern (downcase
1530 (gnus-strip-whitespace cte))))
1533 (defun article-decode-encoded-words ()
1534 "Remove encoded-word encoding from headers."
1535 (let ((inhibit-point-motion-hooks t)
1536 (mail-parse-charset gnus-newsgroup-charset)
1537 (mail-parse-ignored-charsets
1538 (save-excursion (condition-case nil
1539 (set-buffer gnus-summary-buffer)
1541 gnus-newsgroup-ignored-charsets))
1544 (article-narrow-to-head)
1545 (funcall gnus-decode-header-function (point-min) (point-max)))))
1547 (defun article-de-quoted-unreadable (&optional force)
1548 "Translate a quoted-printable-encoded article.
1549 If FORCE, decode the article whether it is marked as quoted-printable
1551 (interactive (list 'force))
1553 (let ((buffer-read-only nil) type charset)
1554 (if (gnus-buffer-live-p gnus-original-article-buffer)
1555 (with-current-buffer gnus-original-article-buffer
1557 (gnus-fetch-field "content-transfer-encoding"))
1558 (let* ((ct (gnus-fetch-field "content-type"))
1561 (mail-header-parse-content-type ct)))))
1562 (setq charset (and ctl
1563 (mail-content-type-get ctl 'charset)))
1564 (if (stringp charset)
1565 (setq charset (intern (downcase charset)))))))
1567 (setq charset gnus-newsgroup-charset))
1569 (and type (let ((case-fold-search t))
1570 (string-match "quoted-printable" type))))
1572 (quoted-printable-decode-region
1573 (point) (point-max) (mm-charset-to-coding-system charset))))))
1575 (defun article-de-base64-unreadable (&optional force)
1576 "Translate a base64 article.
1577 If FORCE, decode the article whether it is marked as base64 not."
1578 (interactive (list 'force))
1580 (let ((buffer-read-only nil) type charset)
1581 (if (gnus-buffer-live-p gnus-original-article-buffer)
1582 (with-current-buffer gnus-original-article-buffer
1584 (gnus-fetch-field "content-transfer-encoding"))
1585 (let* ((ct (gnus-fetch-field "content-type"))
1588 (mail-header-parse-content-type ct)))))
1589 (setq charset (and ctl
1590 (mail-content-type-get ctl 'charset)))
1591 (if (stringp charset)
1592 (setq charset (intern (downcase charset)))))))
1594 (setq charset gnus-newsgroup-charset))
1596 (and type (let ((case-fold-search t))
1597 (string-match "base64" type))))
1600 (narrow-to-region (point) (point-max))
1601 (base64-decode-region (point-min) (point-max))
1602 (mm-decode-coding-region
1603 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
1608 (defun article-decode-HZ ()
1609 "Translate a HZ-encoded article."
1613 (let ((buffer-read-only nil))
1614 (rfc1843-decode-region (point-min) (point-max)))))
1616 (defun article-wash-html ()
1617 "Format an html article."
1620 (let ((buffer-read-only nil)
1622 (if (gnus-buffer-live-p gnus-original-article-buffer)
1623 (with-current-buffer gnus-original-article-buffer
1624 (let* ((ct (gnus-fetch-field "content-type"))
1627 (mail-header-parse-content-type ct)))))
1628 (setq charset (and ctl
1629 (mail-content-type-get ctl 'charset)))
1630 (if (stringp charset)
1631 (setq charset (intern (downcase charset)))))))
1633 (setq charset gnus-newsgroup-charset))
1635 (save-window-excursion
1637 (narrow-to-region (point) (point-max))
1639 (let ((w3-strict-width (window-width))
1640 (url-standalone-mode t))
1642 (w3-region (point-min) (point-max))
1645 (defun article-hide-list-identifiers ()
1646 "Remove list identifies from the Subject header.
1647 The `gnus-list-identifiers' variable specifies what to do."
1651 (let ((inhibit-point-motion-hooks t)
1653 (article-narrow-to-head)
1654 (let ((regexp (if (stringp gnus-list-identifiers) gnus-list-identifiers
1655 (mapconcat 'identity gnus-list-identifiers " *\\|"))))
1657 (goto-char (point-min))
1658 (when (re-search-forward
1659 (concat "^Subject: +\\(\\(\\(Re: +\\)?\\(" regexp
1660 " *\\)\\)+\\(Re: +\\)?\\)")
1662 (let ((s (or (match-string 3) (match-string 5))))
1663 (delete-region (match-beginning 1) (match-end 1))
1665 (goto-char (match-beginning 1))
1668 (defun article-hide-pgp ()
1669 "Remove any PGP headers and signatures in the current article."
1673 (let ((inhibit-point-motion-hooks t)
1674 buffer-read-only beg end)
1676 ;; Hide the "header".
1677 (when (re-search-forward "^-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
1678 (push 'pgp gnus-article-wash-types)
1679 (delete-region (match-beginning 0) (match-end 0))
1680 ;; Remove armor headers (rfc2440 6.2)
1681 (delete-region (point) (or (re-search-forward "^[ \t]*\n" nil t)
1684 ;; Hide the actual signature.
1685 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
1686 (setq end (1+ (match-beginning 0)))
1689 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
1691 ;; Perhaps we shouldn't hide to the end of the buffer
1692 ;; if there is no end to the signature?
1694 ;; Hide "- " PGP quotation markers.
1696 (narrow-to-region beg end)
1697 (goto-char (point-min))
1698 (while (re-search-forward "^- " nil t)
1700 (match-beginning 0) (match-end 0)))
1702 (gnus-run-hooks 'gnus-article-hide-pgp-hook))))))
1704 (defun article-hide-pem (&optional arg)
1705 "Toggle hiding of any PEM headers and signatures in the current article.
1706 If given a negative prefix, always show; if given a positive prefix,
1708 (interactive (gnus-article-hidden-arg))
1709 (unless (gnus-article-check-hidden-text 'pem arg)
1711 (let (buffer-read-only end)
1712 (goto-char (point-min))
1713 ;; Hide the horrendously ugly "header".
1714 (when (and (search-forward
1715 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
1717 (setq end (1+ (match-beginning 0))))
1718 (push 'pem gnus-article-wash-types)
1719 (gnus-article-hide-text-type
1721 (if (search-forward "\n\n" nil t)
1725 ;; Hide the trailer as well
1726 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
1728 (gnus-article-hide-text-type
1729 (match-beginning 0) (match-end 0) 'pem)))))))
1731 (defun article-strip-banner ()
1732 "Strip the banner specified by the `banner' group parameter."
1736 (let ((inhibit-point-motion-hooks t)
1737 (banner (gnus-group-find-parameter gnus-newsgroup-name 'banner))
1738 (gnus-signature-limit nil)
1739 buffer-read-only beg end)
1743 ((eq banner 'signature)
1744 (when (gnus-article-narrow-to-signature)
1747 (delete-region (point) (point-max))))
1749 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
1750 (while (re-search-forward banner nil t)
1751 (delete-region (match-beginning 0) (match-end 0)))))
1753 (while (re-search-forward banner nil t)
1754 (delete-region (match-beginning 0) (match-end 0))))))))))
1756 (defun article-babel ()
1757 "Translate article using an online translation service."
1761 (set-buffer gnus-article-buffer)
1762 (when (article-goto-body)
1763 (let* ((buffer-read-only nil)
1766 (orig (buffer-substring start end))
1767 (trans (babel-as-string orig)))
1769 (narrow-to-region start end)
1770 (delete-region start end)
1773 (defun article-hide-signature (&optional arg)
1774 "Hide the signature in the current article.
1775 If given a negative prefix, always show; if given a positive prefix,
1777 (interactive (gnus-article-hidden-arg))
1778 (unless (gnus-article-check-hidden-text 'signature arg)
1781 (let ((buffer-read-only nil))
1782 (when (gnus-article-narrow-to-signature)
1783 (gnus-article-hide-text-type
1784 (point-min) (point-max) 'signature)))))))
1786 (defun article-strip-headers-in-body ()
1787 "Strip offensive headers from bodies."
1791 (let ((case-fold-search t))
1792 (when (looking-at "x-no-archive:")
1793 (gnus-delete-line)))))
1795 (defun article-strip-leading-blank-lines ()
1796 "Remove all blank lines from the beginning of the article."
1799 (let ((inhibit-point-motion-hooks t)
1801 (when (article-goto-body)
1802 (while (and (not (eobp))
1803 (looking-at "[ \t]*$"))
1804 (gnus-delete-line))))))
1806 (defun article-narrow-to-head ()
1807 "Narrow the buffer to the head of the message.
1808 Point is left at the beginning of the narrowed-to region."
1810 (goto-char (point-min))
1811 (if (search-forward "\n\n" nil 1)
1814 (goto-char (point-min)))
1816 (defun article-goto-body ()
1817 "Place point at the start of the body."
1818 (goto-char (point-min))
1820 ;; This variable is only bound when dealing with separate
1822 (article-goto-body-goes-to-point-min-p
1824 ((search-forward "\n\n" nil t)
1827 (goto-char (point-max))
1830 (defun article-strip-multiple-blank-lines ()
1831 "Replace consecutive blank lines with one empty line."
1834 (let ((inhibit-point-motion-hooks t)
1836 ;; First make all blank lines empty.
1838 (while (re-search-forward "^[ \t]+$" nil t)
1839 (unless (gnus-annotation-in-region-p
1840 (match-beginning 0) (match-end 0))
1841 (replace-match "" nil t)))
1842 ;; Then replace multiple empty lines with a single empty line.
1844 (while (re-search-forward "\n\n\n+" nil t)
1845 (unless (gnus-annotation-in-region-p
1846 (match-beginning 0) (match-end 0))
1847 (replace-match "\n\n" t t))))))
1849 (defun article-strip-leading-space ()
1850 "Remove all white space from the beginning of the lines in the article."
1853 (let ((inhibit-point-motion-hooks t)
1856 (while (re-search-forward "^[ \t]+" nil t)
1857 (replace-match "" t t)))))
1859 (defun article-strip-trailing-space ()
1860 "Remove all white space from the end of the lines in the article."
1863 (let ((inhibit-point-motion-hooks t)
1866 (while (re-search-forward "[ \t]+$" nil t)
1867 (replace-match "" t t)))))
1869 (defun article-strip-blank-lines ()
1870 "Strip leading, trailing and multiple blank lines."
1872 (article-strip-leading-blank-lines)
1873 (article-remove-trailing-blank-lines)
1874 (article-strip-multiple-blank-lines))
1876 (defun article-strip-all-blank-lines ()
1877 "Strip all blank lines."
1880 (let ((inhibit-point-motion-hooks t)
1883 (while (re-search-forward "^[ \t]*\n" nil t)
1884 (replace-match "" t t)))))
1886 (defun gnus-article-narrow-to-signature ()
1887 "Narrow to the signature; return t if a signature is found, else nil."
1888 (let ((inhibit-point-motion-hooks t))
1889 (when (gnus-article-search-signature)
1891 ;; Check whether we have some limits to what we consider
1892 ;; to be a signature.
1893 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
1894 (list gnus-signature-limit)))
1896 (while (setq limit (pop limits))
1897 (if (or (and (integerp limit)
1898 (< (- (point-max) (point)) limit))
1900 (< (count-lines (point) (point-max)) limit))
1901 (and (gnus-functionp limit)
1903 (and (stringp limit)
1904 (not (re-search-forward limit nil t))))
1905 () ; This limit did not succeed.
1909 (narrow-to-region (point) (point-max))
1912 (defun gnus-article-search-signature ()
1913 "Search the current buffer for the signature separator.
1914 Put point at the beginning of the signature separator."
1915 (let ((cur (point)))
1916 (goto-char (point-max))
1917 (if (if (stringp gnus-signature-separator)
1918 (re-search-backward gnus-signature-separator nil t)
1919 (let ((seps gnus-signature-separator))
1921 (not (re-search-backward (car seps) nil t)))
1928 (defun gnus-article-hidden-arg ()
1929 "Return the current prefix arg as a number, or 0 if no prefix."
1930 (list (if current-prefix-arg
1931 (prefix-numeric-value current-prefix-arg)
1934 (defun gnus-article-check-hidden-text (type arg)
1935 "Return nil if hiding is necessary.
1936 Arg can be nil or a number. Nil and positive means hide, negative
1937 means show, 0 means toggle."
1940 (let ((hide (gnus-article-hidden-text-p type)))
1946 (gnus-article-show-hidden-text type))
1948 (if (eq hide 'hidden)
1949 (gnus-article-show-hidden-text type)
1952 (defun gnus-article-hidden-text-p (type)
1953 "Say whether the current buffer contains hidden text of type TYPE."
1954 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
1956 (not (get-text-property pos 'invisible))
1957 (not (get-text-property pos 'dummy-invisible)))
1959 (text-property-any (1+ pos) (point-max) 'article-type type)))
1964 (defun gnus-article-show-hidden-text (type &optional hide)
1965 "Show all hidden text of type TYPE.
1966 If HIDE, hide the text instead."
1968 (let ((buffer-read-only nil)
1969 (inhibit-point-motion-hooks t)
1972 (while (setq beg (text-property-any end (point-max) 'article-type type))
1975 (text-property-not-all beg (point-max) 'article-type type)
1978 (gnus-article-hide-text beg end gnus-hidden-properties)
1979 (gnus-article-unhide-text beg end))
1983 (defconst article-time-units
1984 `((year . ,(* 365.25 24 60 60))
1985 (week . ,(* 7 24 60 60))
1986 (day . ,(* 24 60 60))
1990 "Mapping from time units to seconds.")
1992 (defun article-date-ut (&optional type highlight header)
1993 "Convert DATE date to universal time in the current article.
1994 If TYPE is `local', convert to local time; if it is `lapsed', output
1995 how much time has lapsed since DATE. For `lapsed', the value of
1996 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
1997 should replace the \"Date:\" one, or should be added below it."
1998 (interactive (list 'ut t))
1999 (let* ((header (or header
2000 (message-fetch-field "date")
2002 (tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2005 ((not gnus-article-date-lapsed-new-header)
2011 (date (if (vectorp header) (mail-header-date header)
2013 (inhibit-point-motion-hooks t)
2018 (article-narrow-to-head)
2019 (when (re-search-forward tdate-regexp nil t)
2020 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2021 date (or (get-text-property (gnus-point-at-bol)
2024 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
2026 (when (and date (not (string= date "")))
2027 (goto-char (point-min))
2028 (let ((buffer-read-only nil))
2029 ;; Delete any old Date headers.
2030 (while (re-search-forward date-regexp nil t)
2032 (delete-region (progn (beginning-of-line) (point))
2033 (progn (forward-line 1) (point)))
2034 (delete-region (progn (beginning-of-line) (point))
2035 (progn (end-of-line) (point)))
2036 (setq pos (point))))
2037 (when (and (not pos) (re-search-forward tdate-regexp nil t))
2039 (if pos (goto-char pos))
2040 (insert (article-make-date-line date (or type 'ut)))
2046 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2047 (put-text-property (match-beginning 1) (1+ (match-end 1))
2048 'original-date date)
2049 (put-text-property (match-beginning 1) (1+ (match-end 1))
2051 (put-text-property (match-beginning 2) (match-end 2)
2054 (defun article-make-date-line (date type)
2055 "Return a DATE line of TYPE."
2056 (let ((time (condition-case ()
2060 ;; Convert to the local timezone. We have to slap a
2061 ;; `condition-case' round the calls to the timezone
2062 ;; functions since they aren't particularly resistant to
2065 (let ((tz (car (current-time-zone time))))
2066 (format "Date: %s %s%02d%02d" (current-time-string time)
2067 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2068 (/ (% (abs tz) 3600) 60))))
2069 ;; Convert to Universal Time.
2072 (current-time-string
2073 (let* ((e (parse-time-string date))
2074 (tm (apply 'encode-time e))
2076 (ls (- (cadr tm) (car (current-time-zone time)))))
2077 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2078 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2081 ;; Get the original date from the article.
2082 ((eq type 'original)
2083 (concat "Date: " (if (string-match "\n+$" date)
2084 (substring date 0 (match-beginning 0))
2086 ;; Let the user define the format.
2088 (if (gnus-functionp gnus-article-time-format)
2089 (funcall gnus-article-time-format time)
2092 (format-time-string gnus-article-time-format time))))
2095 (let ((tz (car (current-time-zone time))))
2098 (format-time-string "%Y%m%dT%H%M%S" time)
2099 (format "%s%02d%02d"
2100 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2101 (/ (% (abs tz) 3600) 60)))))
2102 ;; Do an X-Sent lapsed format.
2104 ;; If the date is seriously mangled, the timezone functions are
2105 ;; liable to bug out, so we ignore all errors.
2106 (let* ((now (current-time))
2107 (real-time (subtract-time now time))
2108 (real-sec (and real-time
2109 (+ (* (float (car real-time)) 65536)
2111 (sec (and real-time (abs real-sec)))
2121 ;; This is a bit convoluted, but basically we go
2122 ;; through the time units for years, weeks, etc,
2123 ;; and divide things to see whether that results
2124 ;; in positive answers.
2127 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2128 ;; The (remaining) seconds are too few to
2129 ;; be divided into this time unit.
2131 ;; It's big enough, so we output it.
2132 (setq sec (- sec (* num (cdr unit))))
2134 (concat (if prev ", " "") (int-to-string
2136 " " (symbol-name (car unit))
2137 (if (> num 1) "s" ""))
2139 article-time-units "")
2140 ;; If dates are odd, then it might appear like the
2141 ;; article was sent in the future.
2144 " in the future"))))))
2146 (error "Unknown conversion type: %s" type)))))
2148 (defun article-date-local (&optional highlight)
2149 "Convert the current article date to the local timezone."
2150 (interactive (list t))
2151 (article-date-ut 'local highlight))
2153 (defun article-date-original (&optional highlight)
2154 "Convert the current article date to what it was originally.
2155 This is only useful if you have used some other date conversion
2156 function and want to see what the date was before converting."
2157 (interactive (list t))
2158 (article-date-ut 'original highlight))
2160 (defun article-date-lapsed (&optional highlight)
2161 "Convert the current article date to time lapsed since it was sent."
2162 (interactive (list t))
2163 (article-date-ut 'lapsed highlight))
2165 (defun article-update-date-lapsed ()
2166 "Function to be run from a timer to update the lapsed time line."
2167 (let (deactivate-mark)
2172 (set-buffer (window-buffer w))
2173 (when (eq major-mode 'gnus-article-mode)
2174 (goto-char (point-min))
2175 (when (re-search-forward "^X-Sent:" nil t)
2176 (article-date-lapsed t))))
2179 (defun gnus-start-date-timer (&optional n)
2180 "Start a timer to update the X-Sent header in the article buffers.
2181 The numerical prefix says how frequently (in seconds) the function
2186 (gnus-stop-date-timer)
2187 (setq article-lapsed-timer
2188 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2190 (defun gnus-stop-date-timer ()
2191 "Stop the X-Sent timer."
2193 (when article-lapsed-timer
2194 (nnheader-cancel-timer article-lapsed-timer)
2195 (setq article-lapsed-timer nil)))
2197 (defun article-date-user (&optional highlight)
2198 "Convert the current article date to the user-defined format.
2199 This format is defined by the `gnus-article-time-format' variable."
2200 (interactive (list t))
2201 (article-date-ut 'user highlight))
2203 (defun article-date-iso8601 (&optional highlight)
2204 "Convert the current article date to ISO8601."
2205 (interactive (list t))
2206 (article-date-ut 'iso8601 highlight))
2208 (defun article-show-all ()
2209 "Show all hidden text in the article buffer."
2212 (let ((buffer-read-only nil))
2213 (gnus-article-unhide-text (point-min) (point-max)))))
2215 (defun article-emphasize (&optional arg)
2216 "Emphasize text according to `gnus-emphasis-alist'."
2217 (interactive (gnus-article-hidden-arg))
2218 (unless (gnus-article-check-hidden-text 'emphasis arg)
2222 (with-current-buffer gnus-summary-buffer
2223 gnus-article-emphasis-alist)
2225 gnus-emphasis-alist))
2226 (buffer-read-only nil)
2227 (props (append '(article-type emphasis)
2228 gnus-hidden-properties))
2229 regexp elem beg invisible visible face)
2232 (while (setq elem (pop alist))
2234 (setq regexp (car elem)
2235 invisible (nth 1 elem)
2236 visible (nth 2 elem)
2238 (while (re-search-forward regexp nil t)
2239 (when (and (match-beginning visible) (match-beginning invisible))
2240 (push 'emphasis gnus-article-wash-types)
2241 (gnus-article-hide-text
2242 (match-beginning invisible) (match-end invisible) props)
2243 (gnus-article-unhide-text-type
2244 (match-beginning visible) (match-end visible) 'emphasis)
2245 (gnus-put-text-property-excluding-newlines
2246 (match-beginning visible) (match-end visible) 'face face)
2247 (goto-char (match-end invisible)))))))))
2249 (defun gnus-article-setup-highlight-words (&optional highlight-words)
2250 "Setup newsgroup emphasis alist."
2251 (unless gnus-article-emphasis-alist
2252 (let ((name (and gnus-newsgroup-name
2253 (gnus-group-real-name gnus-newsgroup-name))))
2254 (make-local-variable 'gnus-article-emphasis-alist)
2255 (setq gnus-article-emphasis-alist
2257 (let ((alist gnus-group-highlight-words-alist) elem highlight)
2258 (while (setq elem (pop alist))
2259 (when (and name (string-match (car elem) name))
2261 highlight (copy-sequence (cdr elem)))))
2263 (copy-sequence highlight-words)
2264 (if gnus-newsgroup-name
2265 (copy-sequence (gnus-group-find-parameter
2266 gnus-newsgroup-name 'highlight-words t)))
2267 gnus-emphasis-alist)))))
2269 (defvar gnus-summary-article-menu)
2270 (defvar gnus-summary-post-menu)
2272 ;;; Saving functions.
2274 (defun gnus-article-save (save-buffer file &optional num)
2275 "Save the currently selected article."
2276 (unless gnus-save-all-headers
2277 ;; Remove headers according to `gnus-saved-headers'.
2278 (let ((gnus-visible-headers
2279 (or gnus-saved-headers gnus-visible-headers))
2280 (gnus-article-buffer save-buffer))
2282 (set-buffer save-buffer)
2283 (article-hide-headers 1 t))))
2284 (save-window-excursion
2285 (if (not gnus-default-article-saver)
2286 (error "No default saver is defined")
2287 ;; !!! Magic! The saving functions all save
2288 ;; `gnus-save-article-buffer' (or so they think), but we
2289 ;; bind that variable to our save-buffer.
2290 (set-buffer gnus-article-buffer)
2291 (let* ((gnus-save-article-buffer save-buffer)
2294 ((not gnus-prompt-before-saving) 'default)
2295 ((eq gnus-prompt-before-saving 'always) nil)
2297 (gnus-number-of-articles-to-be-saved
2298 (when (eq gnus-prompt-before-saving t)
2300 (set-buffer gnus-article-current-summary)
2301 (funcall gnus-default-article-saver filename)))))
2303 (defun gnus-read-save-file-name (prompt &optional filename
2304 function group headers variable)
2306 (funcall function group headers (symbol-value variable)))
2311 ((eq filename 'default)
2317 (let* ((split-name (gnus-get-split-value gnus-split-methods))
2320 (if (and gnus-number-of-articles-to-be-saved
2321 (> gnus-number-of-articles-to-be-saved 1))
2322 (format "these %d articles"
2323 gnus-number-of-articles-to-be-saved)
2326 ;; Let the split methods have their say.
2328 ;; No split name was found.
2331 (concat prompt " (default "
2332 (file-name-nondirectory default-name) ") ")
2333 (file-name-directory default-name)
2335 ;; A single group name is returned.
2336 ((stringp split-name)
2338 (funcall function split-name headers
2339 (symbol-value variable)))
2341 (concat prompt " (default "
2342 (file-name-nondirectory default-name) ") ")
2343 (file-name-directory default-name)
2345 ;; A single split name was found
2346 ((= 1 (length split-name))
2347 (let* ((name (expand-file-name
2349 gnus-article-save-directory))
2350 (dir (cond ((file-directory-p name)
2351 (file-name-as-directory name))
2352 ((file-exists-p name) name)
2353 (t gnus-article-save-directory))))
2355 (concat prompt " (default " name ") ")
2357 ;; A list of splits was found.
2359 (setq split-name (nreverse split-name))
2361 (let ((file-name-history
2362 (nconc split-name file-name-history)))
2366 (concat prompt " (`M-p' for defaults) ")
2367 gnus-article-save-directory
2369 gnus-article-save-directory)))
2370 (car (push result file-name-history)))))))
2371 ;; Create the directory.
2372 (gnus-make-directory (file-name-directory file))
2373 ;; If we have read a directory, we append the default file name.
2374 (when (file-directory-p file)
2375 (setq file (expand-file-name (file-name-nondirectory
2377 (file-name-as-directory file))))
2378 ;; Possibly translate some characters.
2379 (nnheader-translate-file-chars file))))))
2380 (gnus-make-directory (file-name-directory result))
2381 (set variable result)))
2383 (defun gnus-article-archive-name (group)
2384 "Return the first instance of an \"Archive-name\" in the current buffer."
2385 (let ((case-fold-search t))
2386 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
2387 (nnheader-concat gnus-article-save-directory
2388 (match-string 1)))))
2390 (defun gnus-article-nndoc-name (group)
2391 "If GROUP is an nndoc group, return the name of the parent group."
2392 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
2393 (gnus-group-get-parameter group 'save-article-group)))
2395 (defun gnus-summary-save-in-rmail (&optional filename)
2396 "Append this article to Rmail file.
2397 Optional argument FILENAME specifies file name.
2398 Directory to save to is default to `gnus-article-save-directory'."
2399 (setq filename (gnus-read-save-file-name
2400 "Save %s in rmail file:" filename
2401 gnus-rmail-save-name gnus-newsgroup-name
2402 gnus-current-headers 'gnus-newsgroup-last-rmail))
2403 (gnus-eval-in-buffer-window gnus-save-article-buffer
2407 (gnus-output-to-rmail filename))))
2410 (defun gnus-summary-save-in-mail (&optional filename)
2411 "Append this article to Unix mail file.
2412 Optional argument FILENAME specifies file name.
2413 Directory to save to is default to `gnus-article-save-directory'."
2414 (setq filename (gnus-read-save-file-name
2415 "Save %s in Unix mail file:" filename
2416 gnus-mail-save-name gnus-newsgroup-name
2417 gnus-current-headers 'gnus-newsgroup-last-mail))
2418 (gnus-eval-in-buffer-window gnus-save-article-buffer
2422 (if (and (file-readable-p filename)
2423 (mail-file-babyl-p filename))
2424 (rmail-output-to-rmail-file filename t)
2425 (gnus-output-to-mail filename)))))
2428 (defun gnus-summary-save-in-file (&optional filename overwrite)
2429 "Append this article to file.
2430 Optional argument FILENAME specifies file name.
2431 Directory to save to is default to `gnus-article-save-directory'."
2432 (setq filename (gnus-read-save-file-name
2433 "Save %s in file:" filename
2434 gnus-file-save-name gnus-newsgroup-name
2435 gnus-current-headers 'gnus-newsgroup-last-file))
2436 (gnus-eval-in-buffer-window gnus-save-article-buffer
2440 (when (and overwrite
2441 (file-exists-p filename))
2442 (delete-file filename))
2443 (gnus-output-to-file filename))))
2446 (defun gnus-summary-write-to-file (&optional filename)
2447 "Write this article to a file.
2448 Optional argument FILENAME specifies file name.
2449 The directory to save in defaults to `gnus-article-save-directory'."
2450 (gnus-summary-save-in-file nil t))
2452 (defun gnus-summary-save-body-in-file (&optional filename)
2453 "Append this article body to a file.
2454 Optional argument FILENAME specifies file name.
2455 The directory to save in defaults to `gnus-article-save-directory'."
2456 (setq filename (gnus-read-save-file-name
2457 "Save %s body in file:" filename
2458 gnus-file-save-name gnus-newsgroup-name
2459 gnus-current-headers 'gnus-newsgroup-last-file))
2460 (gnus-eval-in-buffer-window gnus-save-article-buffer
2464 (when (article-goto-body)
2465 (narrow-to-region (point) (point-max)))
2466 (gnus-output-to-file filename))))
2469 (defun gnus-summary-save-in-pipe (&optional command)
2470 "Pipe this article to subprocess."
2472 (cond ((and (eq command 'default)
2473 gnus-last-shell-command)
2474 gnus-last-shell-command)
2478 "Shell command on %s: "
2479 (if (and gnus-number-of-articles-to-be-saved
2480 (> gnus-number-of-articles-to-be-saved 1))
2481 (format "these %d articles"
2482 gnus-number-of-articles-to-be-saved)
2484 gnus-last-shell-command))))
2485 (when (string-equal command "")
2486 (setq command gnus-last-shell-command))
2487 (gnus-eval-in-buffer-window gnus-article-buffer
2490 (shell-command-on-region (point-min) (point-max) command nil)))
2491 (setq gnus-last-shell-command command))
2493 ;;; Article file names when saving.
2495 (defun gnus-capitalize-newsgroup (newsgroup)
2496 "Capitalize NEWSGROUP name."
2497 (when (not (zerop (length newsgroup)))
2498 (concat (char-to-string (upcase (aref newsgroup 0)))
2499 (substring newsgroup 1))))
2501 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2502 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2503 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
2504 Otherwise, it is like ~/News/news/group/num."
2507 (concat (if (gnus-use-long-file-name 'not-save)
2508 (gnus-capitalize-newsgroup newsgroup)
2509 (gnus-newsgroup-directory-form newsgroup))
2510 "/" (int-to-string (mail-header-number headers)))
2511 gnus-article-save-directory)))
2513 (string-equal (file-name-directory default)
2514 (file-name-directory last-file))
2515 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2517 (or last-file default))))
2519 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2520 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2521 If variable `gnus-use-long-file-name' is non-nil, it is
2522 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2525 (concat (if (gnus-use-long-file-name 'not-save)
2527 (gnus-newsgroup-directory-form newsgroup))
2528 "/" (int-to-string (mail-header-number headers)))
2529 gnus-article-save-directory)))
2531 (string-equal (file-name-directory default)
2532 (file-name-directory last-file))
2533 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2535 (or last-file default))))
2537 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2538 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2539 If variable `gnus-use-long-file-name' is non-nil, it is
2540 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2543 (if (gnus-use-long-file-name 'not-save)
2545 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup)))
2546 gnus-article-save-directory)))
2553 (setq afunc (car func)
2556 gfunc (intern (format "gnus-%s" func))))
2559 `(lambda (&optional interactive &rest args)
2560 ,(documentation afunc t)
2561 (interactive (list t))
2563 (set-buffer gnus-article-buffer)
2565 (call-interactively ',afunc)
2566 (apply ',afunc args))))))))
2567 '(article-hide-headers
2568 article-hide-boring-headers
2569 article-treat-overstrike
2570 article-fill-long-lines
2571 article-capitalize-sentences
2573 article-display-x-face
2574 article-de-quoted-unreadable
2575 article-de-base64-unreadable
2578 article-hide-list-identifiers
2580 article-strip-banner
2583 article-hide-signature
2584 article-strip-headers-in-body
2585 article-remove-trailing-blank-lines
2586 article-strip-leading-blank-lines
2587 article-strip-multiple-blank-lines
2588 article-strip-leading-space
2589 article-strip-trailing-space
2590 article-strip-blank-lines
2591 article-strip-all-blank-lines
2593 article-date-iso8601
2594 article-date-original
2596 article-decode-mime-words
2597 article-decode-charset
2598 article-decode-encoded-words
2602 article-treat-dumbquotes
2603 article-normalize-headers
2604 (article-show-all . gnus-article-show-all-headers))))
2607 ;;; Gnus article mode
2610 (put 'gnus-article-mode 'mode-class 'special)
2612 (set-keymap-parent gnus-article-mode-map widget-keymap)
2614 (gnus-define-keys gnus-article-mode-map
2615 " " gnus-article-goto-next-page
2616 "\177" gnus-article-goto-prev-page
2617 [delete] gnus-article-goto-prev-page
2618 [backspace] gnus-article-goto-prev-page
2619 "\C-c^" gnus-article-refer-article
2620 "h" gnus-article-show-summary
2621 "s" gnus-article-show-summary
2622 "\C-c\C-m" gnus-article-mail
2623 "?" gnus-article-describe-briefly
2624 "e" gnus-summary-edit-article
2625 "<" beginning-of-buffer
2627 "\C-c\C-i" gnus-info-find-node
2630 "\C-d" gnus-article-read-summary-keys
2631 "\M-*" gnus-article-read-summary-keys
2632 "\M-#" gnus-article-read-summary-keys
2633 "\M-^" gnus-article-read-summary-keys
2634 "\M-g" gnus-article-read-summary-keys)
2636 (substitute-key-definition
2637 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
2639 (defun gnus-article-make-menu-bar ()
2640 (gnus-turn-off-edit-menu 'article)
2641 (unless (boundp 'gnus-article-article-menu)
2643 gnus-article-article-menu gnus-article-mode-map ""
2645 ["Scroll forwards" gnus-article-goto-next-page t]
2646 ["Scroll backwards" gnus-article-goto-prev-page t]
2647 ["Show summary" gnus-article-show-summary t]
2648 ["Fetch Message-ID at point" gnus-article-refer-article t]
2649 ["Mail to address at point" gnus-article-mail t]
2650 ["Send a bug report" gnus-bug t]))
2653 gnus-article-treatment-menu gnus-article-mode-map ""
2655 ["Hide headers" gnus-article-hide-headers t]
2656 ["Hide signature" gnus-article-hide-signature t]
2657 ["Hide citation" gnus-article-hide-citation t]
2658 ["Treat overstrike" gnus-article-treat-overstrike t]
2659 ["Remove carriage return" gnus-article-remove-cr t]
2660 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
2661 ["Remove base64" gnus-article-de-base64-unreadable t]
2662 ["Treat html" gnus-article-wash-html t]
2663 ["Decode HZ" gnus-article-decode-HZ t]))
2665 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
2667 (when (boundp 'gnus-summary-post-menu)
2668 (define-key gnus-article-mode-map [menu-bar post]
2669 (cons "Post" gnus-summary-post-menu)))
2671 (gnus-run-hooks 'gnus-article-menu-hook)))
2673 (defun gnus-article-mode ()
2674 "Major mode for displaying an article.
2676 All normal editing commands are switched off.
2678 The following commands are available in addition to all summary mode
2680 \\<gnus-article-mode-map>
2681 \\[gnus-article-next-page]\t Scroll the article one page forwards
2682 \\[gnus-article-prev-page]\t Scroll the article one page backwards
2683 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
2684 \\[gnus-article-show-summary]\t Display the summary buffer
2685 \\[gnus-article-mail]\t Send a reply to the address near point
2686 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
2687 \\[gnus-info-find-node]\t Go to the Gnus info node"
2689 (when (gnus-visual-p 'article-menu 'menu)
2690 (gnus-article-make-menu-bar))
2691 (gnus-simplify-mode-line)
2692 (setq mode-name "Article")
2693 (setq major-mode 'gnus-article-mode)
2694 (make-local-variable 'minor-mode-alist)
2695 (use-local-map gnus-article-mode-map)
2696 (gnus-update-format-specifications nil 'article-mode)
2697 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
2698 (make-local-variable 'gnus-page-broken)
2699 (make-local-variable 'gnus-button-marker-list)
2700 (make-local-variable 'gnus-article-current-summary)
2701 (make-local-variable 'gnus-article-mime-handles)
2702 (make-local-variable 'gnus-article-decoded-p)
2703 (make-local-variable 'gnus-article-mime-handle-alist)
2704 (make-local-variable 'gnus-article-wash-types)
2705 (make-local-variable 'gnus-article-charset)
2706 (make-local-variable 'gnus-article-ignored-charsets)
2707 (gnus-set-default-directory)
2708 (buffer-disable-undo)
2709 (setq buffer-read-only t)
2710 (set-syntax-table gnus-article-mode-syntax-table)
2711 (mm-enable-multibyte)
2712 (gnus-run-hooks 'gnus-article-mode-hook))
2714 (defun gnus-article-setup-buffer ()
2715 "Initialize the article buffer."
2716 (let* ((name (if gnus-single-article-buffer "*Article*"
2717 (concat "*Article " gnus-newsgroup-name "*")))
2719 (progn (string-match "\\*Article" name)
2720 (concat " *Original Article"
2721 (substring name (match-end 0))))))
2722 (setq gnus-article-buffer name)
2723 (setq gnus-original-article-buffer original)
2724 (setq gnus-article-mime-handle-alist nil)
2725 ;; This might be a variable local to the summary buffer.
2726 (unless gnus-single-article-buffer
2728 (set-buffer gnus-summary-buffer)
2729 (setq gnus-article-buffer name)
2730 (setq gnus-original-article-buffer original)
2731 (gnus-set-global-variables)))
2732 (gnus-article-setup-highlight-words)
2733 ;; Init original article buffer.
2735 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
2736 (mm-enable-multibyte)
2737 (setq major-mode 'gnus-original-article-mode)
2738 (make-local-variable 'gnus-original-article))
2739 (if (get-buffer name)
2742 (when gnus-article-mime-handles
2743 (mm-destroy-parts gnus-article-mime-handles)
2744 (setq gnus-article-mime-handles nil))
2745 ;; Set it to nil in article-buffer!
2746 (setq gnus-article-mime-handle-alist nil)
2747 (buffer-disable-undo)
2748 (setq buffer-read-only t)
2749 (unless (eq major-mode 'gnus-article-mode)
2750 (gnus-article-mode))
2753 (set-buffer (gnus-get-buffer-create name))
2755 (make-local-variable 'gnus-summary-buffer)
2756 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2757 (current-buffer)))))
2759 ;; Set article window start at LINE, where LINE is the number of lines
2760 ;; from the head of the article.
2761 (defun gnus-article-set-window-start (&optional line)
2763 (get-buffer-window gnus-article-buffer t)
2765 (set-buffer gnus-article-buffer)
2766 (goto-char (point-min))
2769 (gnus-message 6 "Moved to bookmark")
2770 (search-forward "\n\n" nil t)
2774 (defun gnus-article-prepare (article &optional all-headers header)
2775 "Prepare ARTICLE in article mode buffer.
2776 ARTICLE should either be an article number or a Message-ID.
2777 If ARTICLE is an id, HEADER should be the article headers.
2778 If ALL-HEADERS is non-nil, no headers are hidden."
2780 ;; Make sure we start in a summary buffer.
2781 (unless (eq major-mode 'gnus-summary-mode)
2782 (set-buffer gnus-summary-buffer))
2783 (setq gnus-summary-buffer (current-buffer))
2784 (let* ((gnus-article (if header (mail-header-number header) article))
2785 (summary-buffer (current-buffer))
2786 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
2787 (group gnus-newsgroup-name)
2790 (gnus-article-setup-buffer)
2791 (set-buffer gnus-article-buffer)
2792 ;; Deactivate active regions.
2793 (when (and (boundp 'transient-mark-mode)
2794 transient-mark-mode)
2795 (setq mark-active nil))
2796 (if (not (setq result (let ((buffer-read-only nil))
2797 (gnus-request-article-this-buffer
2799 ;; There is no such article.
2801 (when (and (numberp article)
2802 (not (memq article gnus-newsgroup-sparse)))
2803 (setq gnus-article-current
2804 (cons gnus-newsgroup-name article))
2805 (set-buffer gnus-summary-buffer)
2806 (setq gnus-current-article article)
2807 (if (eq (gnus-article-mark article) gnus-undownloaded-mark)
2809 (gnus-summary-set-agent-mark article)
2810 (message "Message marked for downloading"))
2811 (gnus-summary-mark-article article gnus-canceled-mark)
2812 (unless (memq article gnus-newsgroup-sparse)
2813 (gnus-error 1 "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))))
2865 (gnus-configure-windows 'article))
2866 (when (or (numberp article)
2868 (gnus-article-prepare-display)
2870 (goto-char (point-min))
2871 (setq gnus-page-broken
2872 (when gnus-break-pages
2873 (gnus-narrow-to-page)
2875 (let ((gnus-article-mime-handle-alist-1
2876 gnus-article-mime-handle-alist))
2877 (gnus-set-mode-line 'article))
2879 (set-window-point (get-buffer-window (current-buffer)) (point))
2880 (gnus-configure-windows 'article)
2884 (defun gnus-article-prepare-display ()
2885 "Make the current buffer look like a nice article."
2886 ;; Hooks for getting information from the article.
2887 ;; This hook must be called before being narrowed.
2888 (let ((gnus-article-buffer (current-buffer))
2890 (unless (eq major-mode 'gnus-article-mode)
2891 (gnus-article-mode))
2892 (setq buffer-read-only nil
2893 gnus-article-wash-types nil)
2894 (gnus-run-hooks 'gnus-tmp-internal-hook)
2895 (when gnus-display-mime-function
2896 (funcall gnus-display-mime-function))
2897 (gnus-run-hooks 'gnus-article-prepare-hook)))
2900 ;;; Gnus MIME viewing functions
2903 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
2904 "The following specs can be used:
2906 %T MIME type, along with additional info
2907 %n The `name' parameter
2908 %d The description, if any
2909 %l The length of the encoded part
2910 %p The part identifier number
2911 %e Dots if the part isn't displayed")
2913 (defvar gnus-mime-button-line-format-alist
2914 '((?t gnus-tmp-type ?s)
2915 (?T gnus-tmp-type-long ?s)
2916 (?n gnus-tmp-name ?s)
2917 (?d gnus-tmp-description ?s)
2919 (?l gnus-tmp-length ?d)
2920 (?e gnus-tmp-dots ?s)))
2922 (defvar gnus-mime-button-commands
2923 '((gnus-article-press-button "\r" "Toggle Display")
2924 (gnus-mime-view-part "v" "View Interactively...")
2925 (gnus-mime-view-part-as-type "t" "View As Type...")
2926 (gnus-mime-save-part "o" "Save...")
2927 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
2928 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
2929 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
2930 (gnus-mime-internalize-part "E" "View Internally")
2931 (gnus-mime-externalize-part "e" "View Externally")
2932 (gnus-mime-pipe-part "|" "Pipe To Command...")
2933 (gnus-mime-action-on-part "." "Take action on the part")))
2935 (defun gnus-article-mime-part-status ()
2936 (if gnus-article-mime-handle-alist-1
2937 (format " (%d parts)" (length gnus-article-mime-handle-alist-1))
2940 (defvar gnus-mime-button-map
2941 (let ((map (make-sparse-keymap)))
2942 (set-keymap-parent map gnus-article-mode-map)
2943 (define-key map gnus-mouse-2 'gnus-article-push-button)
2944 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
2945 (dolist (c gnus-mime-button-commands)
2946 (define-key map (cadr c) (car c)))
2949 (defun gnus-mime-button-menu (event)
2950 "Construct a context-sensitive menu of MIME commands."
2953 (let ((pos (event-start event)))
2954 (set-buffer (window-buffer (posn-window pos)))
2955 (goto-char (posn-point pos))
2956 (gnus-article-check-buffer)
2957 (let ((response (x-popup-menu
2959 ("" ,@(mapcar (lambda (c)
2960 (cons (caddr c) (car c)))
2961 gnus-mime-button-commands))))))
2963 (call-interactively response))))))
2965 (defun gnus-mime-view-all-parts (&optional handles)
2966 "View all the MIME parts."
2968 (save-current-buffer
2969 (set-buffer gnus-article-buffer)
2970 (let ((handles (or handles gnus-article-mime-handles))
2971 (mail-parse-charset gnus-newsgroup-charset)
2972 (mail-parse-ignored-charsets
2973 (save-excursion (set-buffer gnus-summary-buffer)
2974 gnus-newsgroup-ignored-charsets)))
2975 (if (stringp (car handles))
2976 (gnus-mime-view-all-parts (cdr handles))
2977 (mapcar 'mm-display-part handles)))))
2979 (defun gnus-mime-save-part-and-strip ()
2980 "Save the MIME part under point then replace it with an external body."
2982 (gnus-article-check-buffer)
2983 (let* ((data (get-text-property (point) 'gnus-data))
2984 (file (mm-save-part data))
2987 (with-current-buffer (mm-handle-buffer data)
2989 (insert "Content-Type: " (mm-handle-media-type data))
2990 (mml-insert-parameter-string (cdr (mm-handle-type data))
2993 (insert "Content-ID: " (message-make-message-id) "\n")
2994 (insert "Content-Transfer-Encoding: binary\n")
2997 (cdr (mm-make-handle nil
2998 `("message/external-body"
2999 (access-type . "LOCAL-FILE")
3001 (set-buffer gnus-summary-buffer)
3002 (gnus-article-edit-article
3005 (let ((mail-parse-charset (or gnus-article-charset
3006 ',gnus-newsgroup-charset))
3007 (mail-parse-ignored-charsets
3008 (or gnus-article-ignored-charsets
3009 ',gnus-newsgroup-ignored-charsets))
3010 (mbl mml-buffer-list))
3011 (insert-buffer gnus-original-article-buffer)
3013 (message-narrow-to-head)
3014 (message-remove-header "Content-Type")
3015 (message-remove-header "MIME-Version")
3016 (message-remove-header "Content-Transfer-Encoding")
3017 (mail-decode-encoded-word-region (point-min) (point-max))
3018 (goto-char (point-max)))
3020 (delete-region (point) (point-max))
3021 (setq mml-buffer-list nil)
3022 (if (stringp (car gnus-article-mime-handles))
3023 (mml-insert-mime gnus-article-mime-handles)
3024 (mml-insert-mime gnus-article-mime-handles t))
3025 (mm-destroy-parts gnus-article-mime-handles)
3026 (setq gnus-article-mime-handles nil)
3027 (make-local-hook 'kill-buffer-hook)
3028 (let ((mbl1 mml-buffer-list))
3029 (setq mml-buffer-list mbl)
3030 (set (make-local-variable 'mml-buffer-list) mbl1))
3031 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
3032 `(lambda (no-highlight)
3033 (let ((mail-parse-charset (or gnus-article-charset
3034 ',gnus-newsgroup-charset))
3035 (message-options message-options)
3036 (message-options-set-recipient)
3037 (mail-parse-ignored-charsets
3038 (or gnus-article-ignored-charsets
3039 ',gnus-newsgroup-ignored-charsets)))
3041 (mml-destroy-buffers)
3042 (remove-hook 'kill-buffer-hook
3043 'mml-destroy-buffers t)
3044 (kill-local-variable 'mml-buffer-list))
3045 (gnus-summary-edit-article-done
3046 ,(or (mail-header-references gnus-current-headers) "")
3047 ,(gnus-group-read-only-p)
3048 ,gnus-summary-buffer no-highlight))))))
3050 (defun gnus-mime-save-part ()
3051 "Save the MIME part under point."
3053 (gnus-article-check-buffer)
3054 (let ((data (get-text-property (point) 'gnus-data)))
3055 (mm-save-part data)))
3057 (defun gnus-mime-pipe-part ()
3058 "Pipe the MIME part under point to a process."
3060 (gnus-article-check-buffer)
3061 (let ((data (get-text-property (point) 'gnus-data)))
3062 (mm-pipe-part data)))
3064 (defun gnus-mime-view-part ()
3065 "Interactively choose a viewing method for the MIME part under point."
3067 (gnus-article-check-buffer)
3068 (let ((data (get-text-property (point) 'gnus-data)))
3069 (mm-interactively-view-part data)))
3071 (defun gnus-mime-view-part-as-type-internal ()
3072 (gnus-article-check-buffer)
3073 (let* ((name (mail-content-type-get
3074 (mm-handle-type (get-text-property (point) 'gnus-data))
3076 (def-type (and name (mm-default-file-encoding name))))
3077 (and def-type (cons def-type 0))))
3079 (defun gnus-mime-view-part-as-type (mime-type)
3080 "Choose a MIME media type, and view the part as such."
3082 (list (completing-read
3083 "View as MIME type: "
3084 (mapcar #'list (mailcap-mime-types))
3086 (gnus-mime-view-part-as-type-internal))))
3087 (gnus-article-check-buffer)
3088 (let ((handle (get-text-property (point) 'gnus-data)))
3089 (gnus-mm-display-part
3090 (mm-make-handle (mm-handle-buffer handle)
3091 (cons mime-type (cdr (mm-handle-type handle)))
3092 (mm-handle-encoding handle)
3093 (mm-handle-undisplayer handle)
3094 (mm-handle-disposition handle)
3095 (mm-handle-description handle)
3096 (mm-handle-cache handle)
3097 (mm-handle-id handle)))))
3099 (defun gnus-mime-copy-part (&optional handle)
3100 "Put the the MIME part under point into a new buffer."
3102 (gnus-article-check-buffer)
3103 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3104 (contents (mm-get-part handle))|
3105 (base (file-name-nondirectory
3107 (mail-content-type-get (mm-handle-type handle) 'name)
3108 (mail-content-type-get (mm-handle-type handle)
3111 (buffer (generate-new-buffer base)))
3112 (switch-to-buffer buffer)
3114 ;; We do it this way to make `normal-mode' set the appropriate mode.
3117 (setq buffer-file-name (expand-file-name base))
3119 (setq buffer-file-name nil))
3120 (goto-char (point-min))))
3122 (defun gnus-mime-inline-part (&optional handle arg)
3123 "Insert the MIME part under point into the current buffer."
3124 (interactive (list nil current-prefix-arg))
3125 (gnus-article-check-buffer)
3126 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3130 (if (mm-handle-undisplayer handle)
3131 (mm-remove-part handle)
3132 (setq contents (mm-get-part handle))
3135 (setq charset (or (mail-content-type-get
3136 (mm-handle-type handle) 'charset)
3137 gnus-newsgroup-charset)))
3141 gnus-summary-show-article-charset-alist))
3142 (read-coding-system "Charset: ")))))
3144 (mm-insert-inline handle
3146 (setq charset (mm-charset-to-coding-system
3148 (not (eq charset 'ascii)))
3149 (mm-decode-coding-string contents charset)
3153 (defun gnus-mime-externalize-part (&optional handle)
3154 "View the MIME part under point with an external viewer."
3156 (gnus-article-check-buffer)
3157 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3158 (mm-user-display-methods nil)
3159 (mm-inlined-types nil)
3160 (mail-parse-charset gnus-newsgroup-charset)
3161 (mail-parse-ignored-charsets
3162 (save-excursion (set-buffer gnus-summary-buffer)
3163 gnus-newsgroup-ignored-charsets)))
3164 (if (mm-handle-undisplayer handle)
3165 (mm-remove-part handle)
3166 (mm-display-part handle))))
3168 (defun gnus-mime-internalize-part (&optional handle)
3169 "View the MIME part under point with an internal viewer.
3170 In no internal viewer is available, use an external viewer."
3172 (gnus-article-check-buffer)
3173 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3174 (mm-inlined-types '(".*"))
3175 (mm-inline-large-images t)
3176 (mail-parse-charset gnus-newsgroup-charset)
3177 (mail-parse-ignored-charsets
3178 (save-excursion (set-buffer gnus-summary-buffer)
3179 gnus-newsgroup-ignored-charsets)))
3180 (if (mm-handle-undisplayer handle)
3181 (mm-remove-part handle)
3182 (mm-display-part handle))))
3184 (defun gnus-mime-action-on-part (&optional action)
3185 "Do something with the MIME attachment at \(point\)."
3187 (list (completing-read "Action: " gnus-mime-action-alist)))
3188 (gnus-article-check-buffer)
3189 (let ((action-pair (assoc action gnus-mime-action-alist)))
3191 (funcall (cdr action-pair)))))
3194 (defun gnus-article-part-wrapper (n function)
3195 (save-current-buffer
3196 (set-buffer gnus-article-buffer)
3197 (when (> n (length gnus-article-mime-handle-alist))
3198 (error "No such part"))
3199 (gnus-article-goto-part n)
3200 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
3201 (funcall function handle))))
3203 (defun gnus-article-pipe-part (n)
3204 "Pipe MIME part N, which is the numerical prefix."
3206 (gnus-article-part-wrapper n 'mm-pipe-part))
3208 (defun gnus-article-save-part (n)
3209 "Save MIME part N, which is the numerical prefix."
3211 (gnus-article-part-wrapper n 'mm-save-part))
3213 (defun gnus-article-interactively-view-part (n)
3214 "View MIME part N interactively, which is the numerical prefix."
3216 (gnus-article-part-wrapper n 'mm-interactively-view-part))
3218 (defun gnus-article-copy-part (n)
3219 "Copy MIME part N, which is the numerical prefix."
3221 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
3223 (defun gnus-article-externalize-part (n)
3224 "View MIME part N externally, which is the numerical prefix."
3226 (gnus-article-part-wrapper n 'gnus-mime-externalize-part))
3228 (defun gnus-article-inline-part (n)
3229 "Inline MIME part N, which is the numerical prefix."
3231 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
3233 (defun gnus-article-mime-match-handle-first (condition)
3235 (let ((alist gnus-article-mime-handle-alist) ihandle n)
3236 (while (setq ihandle (pop alist))
3238 ((functionp condition)
3239 (funcall condition (cdr ihandle)))
3240 ((eq condition 'undisplayed)
3241 (not (or (mm-handle-undisplayer (cdr ihandle))
3242 (equal (mm-handle-media-type (cdr ihandle))
3243 "multipart/alternative"))))
3244 ((eq condition 'undisplayed-alternative)
3245 (not (mm-handle-undisplayer (cdr ihandle))))
3247 (gnus-article-goto-part (car ihandle))
3248 (or (not n) (< (car ihandle) n)))
3249 (setq n (car ihandle))))
3253 (defun gnus-article-view-part (&optional n)
3254 "View MIME part N, which is the numerical prefix."
3256 (save-current-buffer
3257 (set-buffer gnus-article-buffer)
3258 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
3259 gnus-article-mime-match-handle-function)))
3260 (when (> n (length gnus-article-mime-handle-alist))
3261 (error "No such part"))
3262 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
3263 (when (gnus-article-goto-part n)
3264 (if (equal (car handle) "multipart/alternative")
3265 (gnus-article-press-button)
3266 (when (eq (gnus-mm-display-part handle) 'internal)
3267 (gnus-set-window-start)))))))
3269 (defsubst gnus-article-mime-total-parts ()
3270 (if (bufferp (car gnus-article-mime-handles))
3272 (1- (length gnus-article-mime-handles))))
3274 (defun gnus-mm-display-part (handle)
3275 "Display HANDLE and fix MIME button."
3276 (let ((id (get-text-property (point) 'gnus-part))
3281 (let ((window (selected-window))
3282 (mail-parse-charset gnus-newsgroup-charset)
3283 (mail-parse-ignored-charsets
3284 (save-excursion (set-buffer gnus-summary-buffer)
3285 gnus-newsgroup-ignored-charsets)))
3288 (let ((win (get-buffer-window (current-buffer) t))
3291 (select-window win))
3294 (if (mm-handle-displayed-p handle)
3295 ;; This will remove the part.
3296 (mm-display-part handle)
3298 (narrow-to-region (point) (1+ (point)))
3299 (mm-display-part handle)
3300 ;; We narrow to the part itself and
3301 ;; then call the treatment functions.
3302 (goto-char (point-min))
3304 (narrow-to-region (point) (point-max))
3307 (gnus-article-mime-total-parts)
3308 (mm-handle-media-type handle)))))
3309 (select-window window))))
3311 (delete-region (gnus-point-at-bol) (progn (forward-line 1) (point)))
3312 (gnus-insert-mime-button
3313 handle id (list (mm-handle-displayed-p handle)))
3314 (goto-char point))))
3316 (defun gnus-article-goto-part (n)
3317 "Go to MIME part N."
3318 (let ((point (text-property-any (point-min) (point-max) 'gnus-part n)))
3320 (goto-char point))))
3322 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
3323 (let ((gnus-tmp-name
3324 (or (mail-content-type-get (mm-handle-type handle)
3326 (mail-content-type-get (mm-handle-disposition handle)
3328 (mail-content-type-get (mm-handle-type handle)
3331 (gnus-tmp-type (mm-handle-media-type handle))
3332 (gnus-tmp-description
3333 (mail-decode-encoded-word-string (or (mm-handle-description handle)
3336 (if (if displayed (car displayed)
3337 (mm-handle-displayed-p handle))
3339 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
3341 gnus-tmp-type-long b e)
3342 (when (string-match ".*/" gnus-tmp-name)
3343 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
3344 (setq gnus-tmp-type-long (concat gnus-tmp-type
3345 (and (not (equal gnus-tmp-name ""))
3346 (concat "; " gnus-tmp-name))))
3347 (or (equal gnus-tmp-description "")
3348 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
3353 gnus-mime-button-line-format gnus-mime-button-line-format-alist
3354 `(local-map ,gnus-mime-button-map
3355 keymap ,gnus-mime-button-map
3356 gnus-callback gnus-mm-display-part
3357 gnus-part ,gnus-tmp-id
3358 article-type annotation
3361 (widget-convert-button
3364 :action 'gnus-widget-press-button
3365 :button-keymap gnus-mime-button-map
3367 (lambda (widget/window &optional overlay pos)
3368 ;; Needed to properly clear the message due to a bug in
3369 ;; wid-edit (XEmacs only).
3370 (if (boundp 'help-echo-owns-message)
3371 (setq help-echo-owns-message t))
3373 "%S: %s the MIME part; %S: more options"
3374 (aref gnus-mouse-2 0)
3375 ;; XEmacs will get a single widget arg; Emacs 21 will get
3376 ;; window, overlay, position.
3377 (if (mm-handle-displayed-p
3379 (with-current-buffer (gnus-overlay-buffer overlay)
3380 (widget-get (widget-at (gnus-overlay-start overlay))
3382 (widget-get widget/window :mime-handle)))
3384 (aref gnus-down-mouse-3 0))))))
3386 (defun gnus-widget-press-button (elems el)
3387 (goto-char (widget-get elems :from))
3388 (gnus-article-press-button))
3390 (defvar gnus-displaying-mime nil)
3392 (defun gnus-display-mime (&optional ihandles)
3393 "Display the MIME parts."
3395 (save-selected-window
3396 (let ((window (get-buffer-window gnus-article-buffer))
3399 (select-window window)
3400 ;; We have to do this since selecting the window
3401 ;; may change the point. So we set the window point.
3402 (set-window-point window point)))
3403 (let* ((handles (or ihandles (mm-dissect-buffer) (mm-uu-dissect)))
3404 buffer-read-only handle name type b e display)
3405 (when (and (not ihandles)
3406 (not gnus-displaying-mime))
3407 ;; Top-level call; we clean up.
3408 (when gnus-article-mime-handles
3409 (mm-destroy-parts gnus-article-mime-handles)
3410 (setq gnus-article-mime-handle-alist nil));; A trick.
3411 (setq gnus-article-mime-handles handles)
3412 ;; We allow users to glean info from the handles.
3413 (when gnus-article-mime-part-function
3414 (gnus-mime-part-function handles)))
3416 (or (not (stringp (car handles)))
3419 (when (and (not ihandles)
3420 (not gnus-displaying-mime))
3421 ;; Clean up for mime parts.
3423 (delete-region (point) (point-max)))
3424 (let ((gnus-displaying-mime t))
3425 (gnus-mime-display-part handles)))
3428 (narrow-to-region (point) (point-max))
3429 (gnus-treat-article nil 1 1)
3432 ;; Highlight the headers.
3436 (narrow-to-region (point-min) (point))
3437 (gnus-treat-article 'head))))))))
3439 (defvar gnus-mime-display-multipart-as-mixed nil)
3441 (defun gnus-mime-display-part (handle)
3444 ((not (stringp (car handle)))
3445 (gnus-mime-display-single handle))
3446 ;; User-defined multipart
3447 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
3448 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
3450 ;; multipart/alternative
3451 ((and (equal (car handle) "multipart/alternative")
3452 (not gnus-mime-display-multipart-as-mixed))
3453 (let ((id (1+ (length gnus-article-mime-handle-alist))))
3454 (push (cons id handle) gnus-article-mime-handle-alist)
3455 (gnus-mime-display-alternative (cdr handle) nil nil id)))
3456 ;; multipart/related
3457 ((and (equal (car handle) "multipart/related")
3458 (not gnus-mime-display-multipart-as-mixed))
3459 ;;;!!!We should find the start part, but we just default
3460 ;;;!!!to the first part.
3461 (gnus-mime-display-part (cadr handle)))
3462 ;; Other multiparts are handled like multipart/mixed.
3463 ((equal (car handle) "multipart/signed")
3464 (or (memq 'signed gnus-article-wash-types)
3465 (push 'signed gnus-article-wash-types))
3466 (gnus-mime-display-mixed (cdr handle)))
3467 ((equal (car handle) "multipart/encrypted")
3468 (or (memq 'encrypted gnus-article-wash-types)
3469 (push 'encrypted gnus-article-wash-types))
3470 (gnus-mime-display-mixed (cdr handle)))
3472 (gnus-mime-display-mixed (cdr handle)))))
3474 (defun gnus-mime-part-function (handles)
3475 (if (stringp (car handles))
3476 (mapcar 'gnus-mime-part-function (cdr handles))
3477 (funcall gnus-article-mime-part-function handles)))
3479 (defun gnus-mime-display-mixed (handles)
3480 (mapcar 'gnus-mime-display-part handles))
3482 (defun gnus-mime-display-single (handle)
3483 (let ((type (mm-handle-media-type handle))
3484 (ignored gnus-ignored-mime-types)
3491 (when (string-match (pop ignored) type)
3492 (throw 'ignored nil)))
3493 (if (and (setq not-attachment
3494 (and (not (mm-inline-override-p handle))
3495 (or (not (mm-handle-disposition handle))
3496 (equal (car (mm-handle-disposition handle))
3498 (mm-attachment-override-p handle))))
3499 (mm-automatic-display-p handle)
3500 (or (mm-inlined-p handle)
3501 (mm-automatic-external-display-p type)))
3503 (when (equal (mm-handle-media-supertype handle) "text")
3505 (let ((id (1+ (length gnus-article-mime-handle-alist)))
3507 (push (cons id handle) gnus-article-mime-handle-alist)
3508 (when (or (not display)
3509 (not (gnus-unbuttonized-mime-type-p type)))
3510 ;(gnus-article-insert-newline)
3511 (gnus-insert-mime-button
3512 handle id (list (or display (and not-attachment text))))
3513 (gnus-article-insert-newline)
3514 ;(gnus-article-insert-newline)
3515 ;; Remember modify the number of forward lines.
3523 (let ((mail-parse-charset gnus-newsgroup-charset)
3524 (mail-parse-ignored-charsets
3525 (save-excursion (condition-case ()
3526 (set-buffer gnus-summary-buffer)
3528 gnus-newsgroup-ignored-charsets)))
3529 (mm-display-part handle t))
3530 (goto-char (point-max)))
3531 ((and text not-attachment)
3535 (gnus-article-insert-newline)
3536 (mm-insert-inline handle (mm-get-part handle))
3537 (goto-char (point-max))))
3541 (narrow-to-region beg (point))
3544 (gnus-article-mime-total-parts)
3545 (mm-handle-media-type handle)))))))))
3547 (defun gnus-unbuttonized-mime-type-p (type)
3548 "Say whether TYPE is to be unbuttonized."
3549 (unless gnus-inhibit-mime-unbuttonizing
3551 (let ((types gnus-unbuttonized-mime-types))
3553 (when (string-match (pop types) type)
3554 (throw 'found t)))))))
3556 (defun gnus-article-insert-newline ()
3557 "Insert a newline, but mark it as undeletable."
3558 (gnus-put-text-property
3559 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
3561 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
3562 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
3565 handle buffer-read-only from props begend not-pref)
3566 (save-window-excursion
3569 (narrow-to-region (car ibegend)
3572 (goto-char (car ibegend))
3575 (delete-region (point-min) (point-max))
3576 (mm-remove-parts handles))
3577 (setq begend (list (point-marker)))
3579 (unless (setq not-pref (cadr (member preferred ihandles)))
3580 (setq not-pref (car ihandles)))
3582 (not (gnus-unbuttonized-mime-type-p
3583 "multipart/alternative")))
3584 (gnus-add-text-properties
3587 (insert (format "%d. " id))
3591 (unless ,(not ibegend)
3592 (setq gnus-article-mime-handle-alist
3593 ',gnus-article-mime-handle-alist))
3594 (gnus-mime-display-alternative
3595 ',ihandles ',not-pref ',begend ,id))
3596 local-map ,gnus-mime-button-map
3597 ,gnus-mouse-face-prop ,gnus-article-mouse-face
3598 face ,gnus-article-button-face
3599 keymap ,gnus-mime-button-map
3602 (widget-convert-button 'link from (point)
3603 :action 'gnus-widget-press-button
3604 :button-keymap gnus-widget-button-keymap)
3606 (while (setq handle (pop handles))
3607 (gnus-add-text-properties
3610 (insert (format "(%c) %-18s"
3611 (if (equal handle preferred) ?* ? )
3612 (mm-handle-media-type handle)))
3616 (unless ,(not ibegend)
3617 (setq gnus-article-mime-handle-alist
3618 ',gnus-article-mime-handle-alist))
3619 (gnus-mime-display-alternative
3620 ',ihandles ',handle ',begend ,id))
3621 local-map ,gnus-mime-button-map
3622 ,gnus-mouse-face-prop ,gnus-article-mouse-face
3623 face ,gnus-article-button-face
3624 keymap ,gnus-mime-button-map
3627 (widget-convert-button 'link from (point)
3628 :action 'gnus-widget-press-button
3629 :button-keymap gnus-widget-button-keymap)
3633 (if (stringp (car preferred))
3634 (gnus-display-mime preferred)
3635 (let ((mail-parse-charset gnus-newsgroup-charset)
3636 (mail-parse-ignored-charsets
3637 (save-excursion (set-buffer gnus-summary-buffer)
3638 gnus-newsgroup-ignored-charsets)))
3639 (mm-display-part preferred)
3643 (narrow-to-region (car begend) (point-max))
3645 nil (length gnus-article-mime-handle-alist)
3646 (gnus-article-mime-total-parts)
3647 (mm-handle-media-type handle))))))
3648 (goto-char (point-max))
3649 (setcdr begend (point-marker)))))
3651 (goto-char point))))
3653 (defun gnus-article-wash-status ()
3654 "Return a string which display status of article washing."
3656 (set-buffer gnus-article-buffer)
3657 (let ((cite (memq 'cite gnus-article-wash-types))
3658 (headers (memq 'headers gnus-article-wash-types))
3659 (boring (memq 'boring-headers gnus-article-wash-types))
3660 (pgp (memq 'pgp gnus-article-wash-types))
3661 (pem (memq 'pem gnus-article-wash-types))
3662 (signed (memq 'signed gnus-article-wash-types))
3663 (encrypted (memq 'encrypted gnus-article-wash-types))
3664 (signature (memq 'signature gnus-article-wash-types))
3665 (overstrike (memq 'overstrike gnus-article-wash-types))
3666 (emphasis (memq 'emphasis gnus-article-wash-types)))
3667 (format "%c%c%c%c%c%c"
3669 (if (or headers boring) ?h ? )
3670 (if (or pgp pem signed encrypted) ?p ? )
3671 (if signature ?s ? )
3672 (if overstrike ?o ? )
3673 (if emphasis ?e ? )))))
3675 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
3677 (defun gnus-article-maybe-hide-headers ()
3678 "Hide unwanted headers if `gnus-have-all-headers' is nil.
3679 Provided for backwards compatibility."
3680 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
3681 (not (save-excursion (set-buffer gnus-summary-buffer)
3682 gnus-have-all-headers)))
3683 (not gnus-inhibit-hiding))
3684 (gnus-article-hide-headers)))
3688 (defun gnus-output-to-file (file-name)
3689 "Append the current article to a file named FILE-NAME."
3690 (let ((artbuf (current-buffer)))
3692 (insert-buffer-substring artbuf)
3693 ;; Append newline at end of the buffer as separator, and then
3695 (goto-char (point-max))
3697 (mm-append-to-file (point-min) (point-max) file-name)
3700 (defun gnus-narrow-to-page (&optional arg)
3701 "Narrow the article buffer to a page.
3702 If given a numerical ARG, move forward ARG pages."
3704 (setq arg (if arg (prefix-numeric-value arg) 0))
3706 (set-buffer gnus-article-buffer)
3707 (goto-char (point-min))
3709 ;; Remove any old next/prev buttons.
3710 (when (gnus-visual-p 'page-marker)
3711 (let ((buffer-read-only nil))
3712 (gnus-remove-text-with-property 'gnus-prev)
3713 (gnus-remove-text-with-property 'gnus-next)))
3716 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
3718 (re-search-forward page-delimiter nil 'move arg)))
3719 (goto-char (match-end 0)))
3722 (if (re-search-forward page-delimiter nil 'move)
3725 (when (and (gnus-visual-p 'page-marker)
3726 (not (= (point-min) 1)))
3728 (goto-char (point-min))
3729 (gnus-insert-prev-page-button)))
3730 (when (and (gnus-visual-p 'page-marker)
3731 (< (+ (point-max) 2) (buffer-size)))
3733 (goto-char (point-max))
3734 (gnus-insert-next-page-button)))))
3736 ;; Article mode commands
3738 (defun gnus-article-goto-next-page ()
3739 "Show the next page of the article."
3741 (when (gnus-article-next-page)
3742 (goto-char (point-min))
3743 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
3745 (defun gnus-article-goto-prev-page ()
3746 "Show the next page of the article."
3748 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
3749 (gnus-article-prev-page nil)))
3751 (defun gnus-article-next-page (&optional lines)
3752 "Show the next page of the current article.
3753 If end of article, return non-nil. Otherwise return nil.
3754 Argument LINES specifies lines to be scrolled up."
3756 (move-to-window-line -1)
3759 (and (pos-visible-in-window-p) ;Not continuation line.
3761 ;; Nothing in this page.
3762 (if (or (not gnus-page-broken)
3765 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
3767 (gnus-narrow-to-page 1) ;Go to next page.
3769 ;; More in this page.
3770 (let ((scroll-in-place nil))
3774 ;; Long lines may cause an end-of-buffer error.
3775 (goto-char (point-max)))))
3776 (move-to-window-line 0)
3779 (defun gnus-article-prev-page (&optional lines)
3780 "Show previous page of current article.
3781 Argument LINES specifies lines to be scrolled down."
3783 (move-to-window-line 0)
3784 (if (and gnus-page-broken
3786 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
3788 (gnus-narrow-to-page -1) ;Go to previous page.
3789 (goto-char (point-max))
3791 (let ((scroll-in-place nil))
3795 (beginning-of-buffer
3796 (goto-char (point-min))))
3797 (move-to-window-line 0)))))
3799 (defun gnus-article-refer-article ()
3800 "Read article specified by message-id around point."
3802 (let ((point (point)))
3803 (search-forward ">" nil t) ;Move point to end of "<....>".
3804 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
3805 (let ((message-id (match-string 1)))
3807 (set-buffer gnus-summary-buffer)
3808 (gnus-summary-refer-article message-id))
3810 (error "No references around point"))))
3812 (defun gnus-article-show-summary ()
3813 "Reconfigure windows to show summary buffer."
3815 (if (not (gnus-buffer-live-p gnus-summary-buffer))
3816 (error "There is no summary buffer for this article buffer")
3817 (gnus-article-set-globals)
3818 (gnus-configure-windows 'article)
3819 (gnus-summary-goto-subject gnus-current-article)
3820 (gnus-summary-position-point)))
3822 (defun gnus-article-describe-briefly ()
3823 "Describe article mode commands briefly."
3825 (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")))
3827 (defun gnus-article-summary-command ()
3828 "Execute the last keystroke in the summary buffer."
3830 (let ((obuf (current-buffer))
3831 (owin (current-window-configuration))
3833 (switch-to-buffer gnus-article-current-summary 'norecord)
3834 (setq func (lookup-key (current-local-map) (this-command-keys)))
3835 (call-interactively func)
3837 (set-window-configuration owin)
3838 (set-window-point (get-buffer-window (current-buffer)) (point))))
3840 (defun gnus-article-summary-command-nosave ()
3841 "Execute the last keystroke in the summary buffer."
3844 (pop-to-buffer gnus-article-current-summary 'norecord)
3845 (setq func (lookup-key (current-local-map) (this-command-keys)))
3846 (call-interactively func)))
3848 (defun gnus-article-check-buffer ()
3849 "Beep if not in an article buffer."
3850 (unless (equal major-mode 'gnus-article-mode)
3851 (error "Command invoked outside of a Gnus article buffer")))
3853 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
3854 "Read a summary buffer key sequence and execute it from the article buffer."
3856 (gnus-article-check-buffer)
3858 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
3859 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
3860 "=" "^" "\M-^" "|"))
3866 '("n" "Gn" "p" "Gp"))
3869 (set-buffer gnus-article-current-summary)
3870 (let (gnus-pick-mode)
3871 (push (or key last-command-event) unread-command-events)
3872 (setq keys (if (featurep 'xemacs)
3873 (events-to-keys (read-key-sequence nil))
3874 (read-key-sequence nil)))))
3878 (if (or (member keys nosaves)
3879 (member keys nosave-but-article)
3880 (member keys nosave-in-article))
3882 (save-window-excursion
3883 (pop-to-buffer gnus-article-current-summary 'norecord)
3884 ;; We disable the pick minor mode commands.
3885 (let (gnus-pick-mode)
3886 (setq func (lookup-key (current-local-map) keys))))
3890 (unless (member keys nosave-in-article)
3891 (set-buffer gnus-article-current-summary))
3892 (call-interactively func)
3893 (setq new-sum-point (point)))
3894 (when (member keys nosave-but-article)
3895 (pop-to-buffer gnus-article-buffer 'norecord)))
3896 ;; These commands should restore window configuration.
3897 (let ((obuf (current-buffer))
3898 (owin (current-window-configuration))
3900 (summary gnus-article-current-summary)
3901 func in-buffer selected)
3902 (if not-restore-window
3903 (pop-to-buffer summary 'norecord)
3904 (switch-to-buffer summary 'norecord))
3905 (setq in-buffer (current-buffer))
3906 ;; We disable the pick minor mode commands.
3907 (if (setq func (let (gnus-pick-mode)
3908 (lookup-key (current-local-map) keys)))
3910 (call-interactively func)
3911 (setq new-sum-point (point)))
3913 (when (eq in-buffer (current-buffer))
3914 (setq selected (gnus-summary-select-article))
3916 (unless not-restore-window
3917 (set-window-configuration owin))
3918 (when (eq selected 'old)
3920 (set-window-start (get-buffer-window (current-buffer))
3922 (set-window-point (get-buffer-window (current-buffer))
3924 (let ((win (get-buffer-window gnus-article-current-summary)))
3926 (set-window-point win new-sum-point))))))))
3928 (defun gnus-article-hide (&optional arg force)
3929 "Hide all the gruft in the current article.
3930 This means that PGP stuff, signatures, cited text and (some)
3931 headers will be hidden.
3932 If given a prefix, show the hidden text instead."
3933 (interactive (append (gnus-article-hidden-arg) (list 'force)))
3934 (gnus-article-hide-headers arg)
3935 (gnus-article-hide-list-identifiers arg)
3936 (gnus-article-hide-pgp arg)
3937 (gnus-article-hide-citation-maybe arg force)
3938 (gnus-article-hide-signature arg))
3940 (defun gnus-article-maybe-highlight ()
3941 "Do some article highlighting if article highlighting is requested."
3942 (when (gnus-visual-p 'article-highlight 'highlight)
3943 (gnus-article-highlight-some)))
3945 (defun gnus-check-group-server ()
3946 ;; Make sure the connection to the server is alive.
3947 (unless (gnus-server-opened
3948 (gnus-find-method-for-group gnus-newsgroup-name))
3949 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
3950 (gnus-request-group gnus-newsgroup-name t)))
3952 (defun gnus-request-article-this-buffer (article group)
3953 "Get an article and insert it into this buffer."
3954 (let (do-update-line sparse-header)
3958 (gnus-kill-all-overlays)
3959 (setq group (or group gnus-newsgroup-name))
3961 ;; Using `gnus-request-article' directly will insert the article into
3962 ;; `nntp-server-buffer' - so we'll save some time by not having to
3963 ;; copy it from the server buffer into the article buffer.
3965 ;; We only request an article by message-id when we do not have the
3966 ;; headers for it, so we'll have to get those.
3967 (when (stringp article)
3968 (gnus-read-header article))
3970 ;; If the article number is negative, that means that this article
3971 ;; doesn't belong in this newsgroup (possibly), so we find its
3972 ;; message-id and request it by id instead of number.
3973 (when (and (numberp article)
3975 (get-buffer gnus-summary-buffer)
3976 (gnus-buffer-exists-p gnus-summary-buffer))
3978 (set-buffer gnus-summary-buffer)
3979 (let ((header (gnus-summary-article-header article)))
3982 ((memq article gnus-newsgroup-sparse)
3983 ;; This is a sparse gap article.
3984 (setq do-update-line article)
3985 (setq article (mail-header-id header))
3986 (setq sparse-header (gnus-read-header article))
3987 (setq gnus-newsgroup-sparse
3988 (delq article gnus-newsgroup-sparse)))
3990 ;; It's a real article.
3991 (setq article (mail-header-id header)))
3993 ;; It is an extracted pseudo-article.
3994 (setq article 'pseudo)
3995 (gnus-request-pseudo-article header))))
3997 (let ((method (gnus-find-method-for-group
3998 gnus-newsgroup-name)))
3999 (when (and (eq (car method) 'nneething)
4001 (let ((dir (expand-file-name
4002 (mail-header-subject header)
4003 (file-name-as-directory
4004 (or (cadr (assq 'nneething-address method))
4006 (when (file-directory-p dir)
4007 (setq article 'nneething)
4008 (gnus-group-enter-directory dir))))))))
4011 ;; Refuse to select canceled articles.
4012 ((and (numberp article)
4014 (get-buffer gnus-summary-buffer)
4015 (gnus-buffer-exists-p gnus-summary-buffer)
4016 (eq (cdr (save-excursion
4017 (set-buffer gnus-summary-buffer)
4018 (assq article gnus-newsgroup-reads)))
4019 gnus-canceled-mark))
4021 ;; We first check `gnus-original-article-buffer'.
4022 ((and (get-buffer gnus-original-article-buffer)
4025 (set-buffer gnus-original-article-buffer)
4026 (and (equal (car gnus-original-article) group)
4027 (eq (cdr gnus-original-article) article))))
4028 (insert-buffer-substring gnus-original-article-buffer)
4030 ;; Check the backlog.
4031 ((and gnus-keep-backlog
4032 (gnus-backlog-request-article group article (current-buffer)))
4034 ;; Check asynchronous pre-fetch.
4035 ((gnus-async-request-fetched-article group article (current-buffer))
4036 (gnus-async-prefetch-next group article gnus-summary-buffer)
4037 (when (and (numberp article) gnus-keep-backlog)
4038 (gnus-backlog-enter-article group article (current-buffer)))
4041 ((and gnus-use-cache
4043 (gnus-cache-request-article article group))
4045 ;; Get the article and put into the article buffer.
4046 ((or (stringp article)
4048 (let ((gnus-override-method gnus-override-method)
4049 (methods (and (stringp article)
4050 gnus-refer-article-method))
4052 (buffer-read-only nil))
4053 (if (or (not (listp methods))
4054 (and (symbolp (car methods))
4055 (assq (car methods) nnoo-definition-alist)))
4056 (setq methods (list methods)))
4057 (when (and (null gnus-override-method)
4059 (setq gnus-override-method (pop methods)))
4061 (when (eq gnus-override-method 'current)
4062 (setq gnus-override-method gnus-current-select-method))
4064 (gnus-kill-all-overlays)
4065 (let ((gnus-newsgroup-name group))
4066 (gnus-check-group-server))
4067 (when (gnus-request-article article group (current-buffer))
4068 (when (numberp article)
4069 (gnus-async-prefetch-next group article
4070 gnus-summary-buffer)
4071 (when gnus-keep-backlog
4072 (gnus-backlog-enter-article
4073 group article (current-buffer))))
4074 (setq result 'article))
4077 (setq gnus-override-method (pop methods))
4078 (setq result 'done))))
4079 (and (eq result 'article) 'article)))
4083 ;; Associate this article with the current summary buffer.
4084 (setq gnus-article-current-summary gnus-summary-buffer)
4086 ;; Take the article from the original article buffer
4087 ;; and place it in the buffer it's supposed to be in.
4088 (when (and (get-buffer gnus-article-buffer)
4089 (equal (buffer-name (current-buffer))
4090 (buffer-name (get-buffer gnus-article-buffer))))
4092 (if (get-buffer gnus-original-article-buffer)
4093 (set-buffer gnus-original-article-buffer)
4094 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
4095 (buffer-disable-undo)
4096 (setq major-mode 'gnus-original-article-mode)
4097 (setq buffer-read-only t))
4098 (let (buffer-read-only)
4100 (insert-buffer-substring gnus-article-buffer))
4101 (setq gnus-original-article (cons group article)))
4104 (run-hooks 'gnus-article-decode-hook)
4105 ;; Mark article as decoded or not.
4106 (setq gnus-article-decoded-p gnus-article-decode-hook))
4108 ;; Update sparse articles.
4109 (when (and do-update-line
4110 (or (numberp article)
4112 (let ((buf (current-buffer)))
4113 (set-buffer gnus-summary-buffer)
4114 (gnus-summary-update-article do-update-line sparse-header)
4115 (gnus-summary-goto-subject do-update-line nil t)
4116 (set-window-point (get-buffer-window (current-buffer) t)
4118 (set-buffer buf))))))
4124 (defcustom gnus-article-edit-mode-hook nil
4125 "Hook run in article edit mode buffers."
4126 :group 'gnus-article-various
4129 (defvar gnus-article-edit-done-function nil)
4131 (defvar gnus-article-edit-mode-map nil)
4133 ;; Should we be using derived.el for this?
4134 (unless gnus-article-edit-mode-map
4135 (setq gnus-article-edit-mode-map (make-sparse-keymap))
4136 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
4138 (gnus-define-keys gnus-article-edit-mode-map
4139 "\C-c\C-c" gnus-article-edit-done
4140 "\C-c\C-k" gnus-article-edit-exit)
4142 (gnus-define-keys (gnus-article-edit-wash-map
4143 "\C-c\C-w" gnus-article-edit-mode-map)
4144 "f" gnus-article-edit-full-stops))
4146 (defun gnus-article-edit-mode ()
4147 "Major mode for editing articles.
4148 This is an extended text-mode.
4150 \\{gnus-article-edit-mode-map}"
4152 (setq major-mode 'gnus-article-edit-mode)
4153 (setq mode-name "Article Edit")
4154 (use-local-map gnus-article-edit-mode-map)
4155 (make-local-variable 'gnus-article-edit-done-function)
4156 (make-local-variable 'gnus-prev-winconf)
4157 (setq buffer-read-only nil)
4158 (buffer-enable-undo)
4160 (gnus-run-hooks 'text-mode-hook 'gnus-article-edit-mode-hook))
4162 (defun gnus-article-edit (&optional force)
4163 "Edit the current article.
4164 This will have permanent effect only in mail groups.
4165 If FORCE is non-nil, allow editing of articles even in read-only
4168 (when (and (not force)
4169 (gnus-group-read-only-p))
4170 (error "The current newsgroup does not support article editing"))
4171 (gnus-article-date-original)
4172 (gnus-article-edit-article
4174 `(lambda (no-highlight)
4176 (gnus-summary-edit-article-done
4177 ,(or (mail-header-references gnus-current-headers) "")
4178 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
4180 (defun gnus-article-edit-article (start-func exit-func)
4181 "Start editing the contents of the current article buffer."
4182 (let ((winconf (current-window-configuration)))
4183 (set-buffer gnus-article-buffer)
4184 (gnus-article-edit-mode)
4185 (funcall start-func)
4186 (gnus-configure-windows 'edit-article)
4187 (setq gnus-article-edit-done-function exit-func)
4188 (setq gnus-prev-winconf winconf)
4189 (gnus-message 6 "C-c C-c to end edits")))
4191 (defun gnus-article-edit-done (&optional arg)
4192 "Update the article edits and exit."
4194 (let ((func gnus-article-edit-done-function)
4195 (buf (current-buffer))
4196 (start (window-start)))
4197 (gnus-article-edit-exit)
4200 (let ((buffer-read-only nil))
4202 ;; The cache and backlog have to be flushed somewhat.
4203 (when gnus-keep-backlog
4204 (gnus-backlog-remove-article
4205 (car gnus-article-current) (cdr gnus-article-current)))
4206 ;; Flush original article as well.
4208 (when (get-buffer gnus-original-article-buffer)
4209 (set-buffer gnus-original-article-buffer)
4210 (setq gnus-original-article nil)))
4211 (when gnus-use-cache
4212 (gnus-cache-update-article
4213 (car gnus-article-current) (cdr gnus-article-current))))
4215 (set-window-start (get-buffer-window buf) start)
4216 (set-window-point (get-buffer-window buf) (point))))
4218 (defun gnus-article-edit-exit ()
4219 "Exit the article editing without updating."
4221 ;; We remove all text props from the article buffer.
4222 (let ((buf (buffer-substring-no-properties (point-min) (point-max)))
4223 (curbuf (current-buffer))
4225 (window-start (window-start)))
4228 (let ((winconf gnus-prev-winconf))
4230 (set-window-configuration winconf)
4231 ;; Tippy-toe some to make sure that point remains where it was.
4232 (save-current-buffer
4234 (set-window-start (get-buffer-window (current-buffer)) window-start)
4237 (defun gnus-article-edit-full-stops ()
4238 "Interactively repair spacing at end of sentences."
4241 (goto-char (point-min))
4242 (search-forward-regexp "^$" nil t)
4243 (let ((case-fold-search nil))
4244 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
4247 ;;; Article highlights
4250 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
4252 ;;; Internal Variables:
4254 (defcustom gnus-button-url-regexp "\\b\\(\\(www\\.\\|\\(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 browse-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 browse-url 0)
4304 ("^Subject:" ,gnus-button-url-regexp 0 t browse-url 0)
4305 ("^[^:]+:" ,gnus-button-url-regexp 0 t browse-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-highlight (&optional force)
4361 "Highlight current article.
4362 This function calls `gnus-article-highlight-headers',
4363 `gnus-article-highlight-citation',
4364 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
4365 do the highlighting. See the documentation for those functions."
4366 (interactive (list 'force))
4367 (gnus-article-highlight-headers)
4368 (gnus-article-highlight-citation force)
4369 (gnus-article-highlight-signature)
4370 (gnus-article-add-buttons force)
4371 (gnus-article-add-buttons-to-head))
4373 (defun gnus-article-highlight-some (&optional force)
4374 "Highlight current article.
4375 This function calls `gnus-article-highlight-headers',
4376 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
4377 do the highlighting. See the documentation for those functions."
4378 (interactive (list 'force))
4379 (gnus-article-highlight-headers)
4380 (gnus-article-highlight-signature)
4381 (gnus-article-add-buttons))
4383 (defun gnus-article-highlight-headers ()
4384 "Highlight article headers as specified by `gnus-header-face-alist'."
4387 (set-buffer gnus-article-buffer)
4389 (let ((alist gnus-header-face-alist)
4390 (buffer-read-only nil)
4391 (case-fold-search t)
4392 (inhibit-point-motion-hooks t)
4393 entry regexp header-face field-face from hpoints fpoints)
4394 (article-narrow-to-head)
4395 (while (setq entry (pop alist))
4396 (goto-char (point-min))
4397 (setq regexp (concat "^\\("
4398 (if (string-equal "" (nth 0 entry))
4402 header-face (nth 1 entry)
4403 field-face (nth 2 entry))
4404 (while (and (re-search-forward regexp nil t)
4408 (unless (search-forward ":" nil t)
4410 (when (and header-face
4411 (not (memq (point) hpoints)))
4412 (push (point) hpoints)
4413 (gnus-put-text-property from (point) 'face header-face))
4414 (when (and field-face
4415 (not (memq (setq from (point)) fpoints)))
4417 (if (re-search-forward "^[^ \t]" nil t)
4419 (goto-char (point-max)))
4420 (gnus-put-text-property from (point) 'face field-face))))))))
4422 (defun gnus-article-highlight-signature ()
4423 "Highlight the signature in an article.
4424 It does this by highlighting everything after
4425 `gnus-signature-separator' using `gnus-signature-face'."
4428 (set-buffer gnus-article-buffer)
4429 (let ((buffer-read-only nil)
4430 (inhibit-point-motion-hooks t))
4432 (when (and gnus-signature-face
4433 (gnus-article-narrow-to-signature))
4434 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
4435 'face gnus-signature-face)
4437 (gnus-article-search-signature)
4438 (let ((start (match-beginning 0))
4439 (end (set-marker (make-marker) (1+ (match-end 0)))))
4440 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
4443 (defun gnus-button-in-region-p (b e prop)
4444 "Say whether PROP exists in the region."
4445 (text-property-not-all b e prop nil))
4447 (defun gnus-article-add-buttons (&optional force)
4448 "Find external references in the article and make buttons of them.
4449 \"External references\" are things like Message-IDs and URLs, as
4450 specified by `gnus-button-alist'."
4451 (interactive (list 'force))
4453 (set-buffer gnus-article-buffer)
4454 (let ((buffer-read-only nil)
4455 (inhibit-point-motion-hooks t)
4456 (case-fold-search t)
4457 (alist gnus-button-alist)
4459 ;; Remove all old markers.
4460 (let (marker entry new-list)
4461 (while (setq marker (pop gnus-button-marker-list))
4462 (if (or (< marker (point-min)) (>= marker (point-max)))
4463 (push marker new-list)
4465 (when (setq entry (gnus-button-entry))
4466 (put-text-property (match-beginning (nth 1 entry))
4467 (match-end (nth 1 entry))
4468 'gnus-callback nil))
4469 (set-marker marker nil)))
4470 (setq gnus-button-marker-list new-list))
4471 ;; We skip the headers.
4474 (while (setq entry (pop alist))
4475 (setq regexp (car entry))
4477 (while (re-search-forward regexp nil t)
4478 (let* ((start (and entry (match-beginning (nth 1 entry))))
4479 (end (and entry (match-end (nth 1 entry))))
4480 (from (match-beginning 0)))
4481 (when (and (or (eq t (nth 2 entry))
4482 (eval (nth 2 entry)))
4483 (not (gnus-button-in-region-p
4484 start end 'gnus-callback)))
4485 ;; That optional form returned non-nil, so we add the
4487 (gnus-article-add-button
4488 start end 'gnus-button-push
4489 (car (push (set-marker (make-marker) from)
4490 gnus-button-marker-list))))))))))
4492 ;; Add buttons to the head of an article.
4493 (defun gnus-article-add-buttons-to-head ()
4494 "Add buttons to the head of the article."
4497 (set-buffer gnus-article-buffer)
4499 (let ((buffer-read-only nil)
4500 (inhibit-point-motion-hooks t)
4501 (case-fold-search t)
4502 (alist gnus-header-button-alist)
4504 (article-narrow-to-head)
4506 ;; Each alist entry.
4507 (setq entry (car alist)
4509 (goto-char (point-min))
4510 (while (re-search-forward (car entry) nil t)
4511 ;; Each header matching the entry.
4512 (setq beg (match-beginning 0))
4513 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
4514 (match-beginning 0))
4517 (while (re-search-forward (nth 1 entry) end t)
4518 ;; Each match within a header.
4519 (let* ((entry (cdr entry))
4520 (start (match-beginning (nth 1 entry)))
4521 (end (match-end (nth 1 entry)))
4522 (form (nth 2 entry)))
4523 (goto-char (match-end 0))
4525 (gnus-article-add-button
4526 start end (nth 3 entry)
4527 (buffer-substring (match-beginning (nth 4 entry))
4528 (match-end (nth 4 entry)))))))
4529 (goto-char end)))))))
4531 ;;; External functions:
4533 (defun gnus-article-add-button (from to fun &optional data)
4534 "Create a button between FROM and TO with callback FUN and data DATA."
4535 (when gnus-article-button-face
4536 (gnus-overlay-put (gnus-make-overlay from to)
4537 'face gnus-article-button-face))
4538 (gnus-add-text-properties
4540 (nconc (and gnus-article-mouse-face
4541 (list gnus-mouse-face-prop gnus-article-mouse-face))
4542 (list 'gnus-callback fun)
4543 (and data (list 'gnus-data data))))
4544 (widget-convert-button 'link from to :action 'gnus-widget-press-button
4545 :button-keymap gnus-widget-button-keymap))
4547 ;;; Internal functions:
4549 (defun gnus-article-set-globals ()
4551 (set-buffer gnus-summary-buffer)
4552 (gnus-set-global-variables)))
4554 (defun gnus-signature-toggle (end)
4556 (set-buffer gnus-article-buffer)
4557 (let ((buffer-read-only nil)
4558 (inhibit-point-motion-hooks t))
4559 (if (get-text-property end 'invisible)
4560 (gnus-article-unhide-text end (point-max))
4561 (gnus-article-hide-text end (point-max) gnus-hidden-properties)))))
4563 (defun gnus-button-entry ()
4564 ;; Return the first entry in `gnus-button-alist' matching this place.
4565 (let ((alist gnus-button-alist)
4568 (setq entry (pop alist))
4569 (if (looking-at (car entry))
4574 (defun gnus-button-push (marker)
4575 ;; Push button starting at MARKER.
4578 (let* ((entry (gnus-button-entry))
4579 (inhibit-point-motion-hooks t)
4581 (args (mapcar (lambda (group)
4582 (let ((string (match-string group)))
4583 (gnus-set-text-properties
4584 0 (length string) nil string)
4591 (fboundp (symbol-value fun)))
4592 (apply (symbol-value fun) args))
4594 (gnus-message 1 "You must define `%S' to use this button"
4595 (cons fun args)))))))
4597 (defun gnus-button-message-id (message-id)
4600 (set-buffer gnus-summary-buffer)
4601 (gnus-summary-refer-article message-id)))
4603 (defun gnus-button-fetch-group (address)
4604 "Fetch GROUP specified by ADDRESS."
4605 (if (not (string-match "[:/]" address))
4606 ;; This is just a simple group url.
4607 (gnus-group-read-ephemeral-group address gnus-select-method)
4608 (if (not (string-match "^\\([^:/]+\\)\\(:\\([^/]+\\)/\\)?\\(.*\\)$"
4610 (error "Can't parse %s" address)
4611 (gnus-group-read-ephemeral-group
4612 (match-string 4 address)
4613 `(nntp ,(match-string 1 address)
4614 (nntp-address ,(match-string 1 address))
4615 (nntp-port-number ,(if (match-end 3)
4616 (match-string 3 address)
4619 (defun gnus-url-parse-query-string (query &optional downcase)
4620 (let (retval pairs cur key val)
4621 (setq pairs (split-string query "&"))
4623 (setq cur (car pairs)
4625 (if (not (string-match "=" cur))
4627 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
4628 val (gnus-url-unhex-string (substring cur (match-end 0) nil)))
4630 (setq key (downcase key)))
4631 (setq cur (assoc key retval))
4633 (setcdr cur (cons val (cdr cur)))
4634 (setq retval (cons (list key val) retval)))))
4637 (defun gnus-url-unhex (x)
4644 (defun gnus-url-unhex-string (str &optional allow-newlines)
4645 "Remove %XXX embedded spaces, etc in a url.
4646 If optional second argument ALLOW-NEWLINES is non-nil, then allow the
4647 decoding of carriage returns and line feeds in the string, which is normally
4648 forbidden in URL encoding."
4649 (setq str (or str ""))
4651 (case-fold-search t))
4652 (while (string-match "%[0-9a-f][0-9a-f]" str)
4653 (let* ((start (match-beginning 0))
4654 (ch1 (gnus-url-unhex (elt str (+ start 1))))
4656 (gnus-url-unhex (elt str (+ start 2))))))
4658 tmp (substring str 0 start)
4661 (char-to-string code))
4662 ((or (= code ?\n) (= code ?\r))
4664 (t (char-to-string code))))
4665 str (substring str (match-end 0)))))
4666 (setq tmp (concat tmp str))
4669 (defun gnus-url-mailto (url)
4670 ;; Send mail to someone
4671 (when (string-match "mailto:/*\\(.*\\)" url)
4672 (setq url (substring url (match-beginning 1) nil)))
4673 (let (to args subject func)
4674 (if (string-match (regexp-quote "?") url)
4675 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
4676 args (gnus-url-parse-query-string
4677 (substring url (match-end 0) nil) t))
4678 (setq to (gnus-url-unhex-string url)))
4679 (setq args (cons (list "to" to) args)
4680 subject (cdr-safe (assoc "subject" args)))
4683 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
4686 (message-position-on-field (caar args)))
4687 (insert (mapconcat 'identity (cdar args) ", "))
4688 (setq args (cdr args)))
4691 (message-goto-subject))))
4693 (defun gnus-button-mailto (address)
4695 (set-buffer (gnus-copy-article-buffer))
4696 (message-reply address))
4698 (defalias 'gnus-button-reply 'message-reply)
4700 (defun gnus-button-embedded-url (address)
4701 "Activate ADDRESS with `browse-url'."
4702 (browse-url (gnus-strip-whitespace address)))
4704 ;;; Next/prev buttons in the article buffer.
4706 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
4707 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
4709 (defvar gnus-prev-page-map nil)
4710 (unless gnus-prev-page-map
4711 (setq gnus-prev-page-map (make-sparse-keymap))
4712 (define-key gnus-prev-page-map gnus-mouse-2 'gnus-button-prev-page)
4713 (define-key gnus-prev-page-map "\r" 'gnus-button-prev-page))
4715 (defun gnus-insert-prev-page-button ()
4716 (let ((buffer-read-only nil))
4718 gnus-prev-page-line-format nil
4719 `(gnus-prev t local-map ,gnus-prev-page-map
4720 gnus-callback gnus-article-button-prev-page
4721 article-type annotation))))
4723 (defvar gnus-next-page-map nil)
4724 (unless gnus-next-page-map
4725 (setq gnus-next-page-map (make-keymap))
4726 (suppress-keymap gnus-prev-page-map)
4727 (define-key gnus-next-page-map gnus-mouse-2 'gnus-button-next-page)
4728 (define-key gnus-next-page-map "\r" 'gnus-button-next-page))
4730 (defun gnus-button-next-page ()
4731 "Go to the next page."
4733 (let ((win (selected-window)))
4734 (select-window (get-buffer-window gnus-article-buffer t))
4735 (gnus-article-next-page)
4736 (select-window win)))
4738 (defun gnus-button-prev-page ()
4739 "Go to the prev page."
4741 (let ((win (selected-window)))
4742 (select-window (get-buffer-window gnus-article-buffer t))
4743 (gnus-article-prev-page)
4744 (select-window win)))
4746 (defun gnus-insert-next-page-button ()
4747 (let ((buffer-read-only nil))
4748 (gnus-eval-format gnus-next-page-line-format nil
4750 t local-map ,gnus-next-page-map
4751 gnus-callback gnus-article-button-next-page
4752 article-type annotation))))
4754 (defun gnus-article-button-next-page (arg)
4755 "Go to the next page."
4757 (let ((win (selected-window)))
4758 (select-window (get-buffer-window gnus-article-buffer t))
4759 (gnus-article-next-page)
4760 (select-window win)))
4762 (defun gnus-article-button-prev-page (arg)
4763 "Go to the prev page."
4765 (let ((win (selected-window)))
4766 (select-window (get-buffer-window gnus-article-buffer t))
4767 (gnus-article-prev-page)
4768 (select-window win)))
4770 (defvar gnus-decode-header-methods
4771 '(mail-decode-encoded-word-region)
4772 "List of methods used to decode headers.
4774 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
4775 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
4776 (REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
4777 whose names match REGEXP.
4780 ((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
4781 mail-decode-encoded-word-region
4782 (\"chinese\" . rfc1843-decode-region))
4785 (defvar gnus-decode-header-methods-cache nil)
4787 (defun gnus-multi-decode-header (start end)
4788 "Apply the functions from `gnus-encoded-word-methods' that match."
4789 (unless (and gnus-decode-header-methods-cache
4790 (eq gnus-newsgroup-name
4791 (car gnus-decode-header-methods-cache)))
4792 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
4795 (nconc gnus-decode-header-methods-cache (list x))
4796 (if (and gnus-newsgroup-name
4797 (string-match (car x) gnus-newsgroup-name))
4798 (nconc gnus-decode-header-methods-cache
4800 gnus-decode-header-methods))
4801 (let ((xlist gnus-decode-header-methods-cache))
4804 (narrow-to-region start end)
4806 (funcall (pop xlist) (point-min) (point-max))))))
4809 ;;; Treatment top-level handling.
4812 (defun gnus-treat-article (condition &optional part-number total-parts type)
4813 (let ((length (- (point-max) (point-min)))
4814 (alist gnus-treatment-function-alist)
4815 (article-goto-body-goes-to-point-min-p t)
4819 (let ((list gnus-article-treat-types))
4821 (when (string-match (pop list) type)
4822 (throw 'found t)))))))
4823 (highlightp (gnus-visual-p 'article-highlight 'highlight))
4825 (gnus-run-hooks 'gnus-part-display-hook)
4826 (while (setq elem (pop alist))
4829 (if (gnus-buffer-live-p gnus-summary-buffer)
4830 (set-buffer gnus-summary-buffer))
4831 (symbol-value (car elem))))
4832 (when (and (or (consp val)
4834 (gnus-treat-predicate val)
4835 (or (not (get (car elem) 'highlight))
4838 (funcall (cadr elem)))))))
4840 ;; Dynamic variables.
4842 (defvar part-number)
4843 (defvar total-parts)
4848 (defun gnus-treat-predicate (val)
4853 (stringp (car val)))
4854 (apply 'gnus-or (mapcar `(lambda (s)
4855 (string-match s ,(or gnus-newsgroup-name "")))
4858 (let ((pred (pop val)))
4861 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
4863 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
4865 (not (gnus-treat-predicate (car val))))
4867 (equal (car val) type))
4869 (error "%S is not a valid predicate" pred)))))
4877 (eq part-number total-parts))
4881 (error "%S is not a valid value" val))))
4887 (run-hooks 'gnus-art-load-hook)
4889 ;;; gnus-art.el ends here