1 ;;; gnus-art.el --- article mode commands for Gnus
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001
4 ;; Free Software Foundation, Inc.
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
30 (eval-when-compile (require 'cl))
43 (defgroup gnus-article nil
45 :link '(custom-manual "(gnus)The Article Buffer")
48 (defgroup gnus-article-treat nil
49 "Treating article parts."
50 :link '(custom-manual "(gnus)Article Hiding")
53 (defgroup gnus-article-hiding nil
54 "Hiding article parts."
55 :link '(custom-manual "(gnus)Article Hiding")
58 (defgroup gnus-article-highlight nil
59 "Article highlighting."
60 :link '(custom-manual "(gnus)Article Highlighting")
64 (defgroup gnus-article-signature nil
66 :link '(custom-manual "(gnus)Article Signature")
69 (defgroup gnus-article-headers nil
71 :link '(custom-manual "(gnus)Hiding Headers")
74 (defgroup gnus-article-washing nil
75 "Special commands on articles."
76 :link '(custom-manual "(gnus)Article Washing")
79 (defgroup gnus-article-emphasis nil
80 "Fontisizing articles."
81 :link '(custom-manual "(gnus)Article Fontisizing")
84 (defgroup gnus-article-saving nil
86 :link '(custom-manual "(gnus)Saving Articles")
89 (defgroup gnus-article-mime nil
90 "Worshiping the MIME wonder."
91 :link '(custom-manual "(gnus)Using MIME")
94 (defgroup gnus-article-buttons nil
95 "Pushable buttons in the article buffer."
96 :link '(custom-manual "(gnus)Article Buttons")
99 (defgroup gnus-article-various nil
100 "Other article options."
101 :link '(custom-manual "(gnus)Misc Article")
102 :group 'gnus-article)
104 (defcustom gnus-ignored-headers
105 '("^Path:" "^Expires:" "^Date-Received:" "^References:" "^Xref:" "^Lines:"
106 "^Relay-Version:" "^Message-ID:" "^Approved:" "^Sender:" "^Received:"
107 "^X-UIDL:" "^MIME-Version:" "^Return-Path:" "^In-Reply-To:"
108 "^Content-Type:" "^Content-Transfer-Encoding:" "^X-WebTV-Signature:"
109 "^X-MimeOLE:" "^X-MSMail-Priority:" "^X-Priority:" "^X-Loop:"
110 "^X-Authentication-Warning:" "^X-MIME-Autoconverted:" "^X-Face:"
111 "^X-Attribution:" "^X-Originating-IP:" "^Delivered-To:"
112 "^NNTP-[-A-Za-z]+:" "^Distribution:" "^X-no-archive:" "^X-Trace:"
113 "^X-Complaints-To:" "^X-NNTP-Posting-Host:" "^X-Orig.*:"
114 "^Abuse-Reports-To:" "^Cache-Post-Path:" "^X-Article-Creation-Date:"
115 "^X-Poster:" "^X-Mail2News-Path:" "^X-Server-Date:" "^X-Cache:"
116 "^Originator:" "^X-Problems-To:" "^X-Auth-User:" "^X-Post-Time:"
117 "^X-Admin:" "^X-UID:" "^Resent-[-A-Za-z]+:" "^X-Mailing-List:"
118 "^Precedence:" "^Original-[-A-Za-z]+:" "^X-filename:" "^X-Orcpt:"
119 "^Old-Received:" "^X-Pgp" "^X-Auth:" "^X-From-Line:"
120 "^X-Gnus-Article-Number:" "^X-Majordomo:" "^X-Url:" "^X-Sender:"
121 "^MBOX-Line" "^Priority:" "^X-Pgp" "^X400-[-A-Za-z]+:"
122 "^Status:" "^X-Gnus-Mail-Source:" "^Cancel-Lock:"
123 "^X-FTN" "^X-EXP32-SerialNo:" "^Encoding:" "^Importance:"
124 "^Autoforwarded:" "^Original-Encoded-Information-Types:" "^X-Ya-Pop3:"
125 "^X-Face-Version:" "^X-Vms-To:" "^X-ML-NAME:" "^X-ML-COUNT:"
126 "^Mailing-List:" "^X-finfo:" "^X-md5sum:" "^X-md5sum-Origin:"
127 "^X-Sun-Charset:" "^X-Accept-Language:" "^X-Envelope-Sender:"
128 "^List-[A-Za-z]+:" "^X-Listprocessor-Version:"
129 "^X-Received:" "^X-Distribute:" "^X-Sequence:" "^X-Juno-Line-Breaks:"
130 "^X-Notes-Item:" "^X-MS-TNEF-Correlator:" "^x-uunet-gateway:"
131 "^X-Received:" "^Content-length:" "X-precedence:")
132 "*All headers that start with this regexp will be hidden.
133 This variable can also be a list of regexps of headers to be ignored.
134 If `gnus-visible-headers' is non-nil, this variable will be ignored."
135 :type '(choice :custom-show nil
138 :group 'gnus-article-hiding)
140 (defcustom gnus-visible-headers
141 "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^[BGF]?Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-From:\\|^X-Sent:"
142 "*All headers that do not match this regexp will be hidden.
143 This variable can also be a list of regexp of headers to remain visible.
144 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
145 :type '(repeat :value-to-internal (lambda (widget value)
146 (custom-split-regexp-maybe value))
147 :match (lambda (widget value)
149 (widget-editable-list-match widget value)))
151 :group 'gnus-article-hiding)
153 (defcustom gnus-sorted-header-list
154 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
155 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
156 "*This variable is a list of regular expressions.
157 If it is non-nil, headers that match the regular expressions will
158 be placed first in the article buffer in the sequence specified by
160 :type '(repeat regexp)
161 :group 'gnus-article-hiding)
163 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
164 "Headers that are only to be displayed if they have interesting data.
165 Possible values in this list are `empty', `newsgroups', `followup-to',
166 `reply-to', `date', `long-to', and `many-to'."
167 :type '(set (const :tag "Headers with no content." empty)
168 (const :tag "Newsgroups with only one group." newsgroups)
169 (const :tag "Followup-to identical to newsgroups." followup-to)
170 (const :tag "Reply-to identical to from." reply-to)
171 (const :tag "Date less than four days old." date)
172 (const :tag "Very long To and/or Cc header." long-to)
173 (const :tag "Multiple To and/or Cc headers." many-to))
174 :group 'gnus-article-hiding)
176 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
177 "Regexp matching signature separator.
178 This can also be a list of regexps. In that case, it will be checked
179 from head to tail looking for a separator. Searches will be done from
180 the end of the buffer."
181 :type '(repeat string)
182 :group 'gnus-article-signature)
184 (defcustom gnus-signature-limit nil
185 "Provide a limit to what is considered a signature.
186 If it is a number, no signature may not be longer (in characters) than
187 that number. If it is a floating point number, no signature may be
188 longer (in lines) than that number. If it is a function, the function
189 will be called without any parameters, and if it returns nil, there is
190 no signature in the buffer. If it is a string, it will be used as a
191 regexp. If it matches, the text in question is not a signature."
192 :type '(choice (integer :value 200)
194 (function :value fun)
195 (regexp :value ".*"))
196 :group 'gnus-article-signature)
198 (defcustom gnus-hidden-properties '(invisible t intangible t)
199 "Property list to use for hiding text."
201 :group 'gnus-article-hiding)
203 ;; Fixme: This isn't the right thing for mixed graphical and and
204 ;; non-graphical frames in a session.
205 ;; gnus-xmas.el overrides this for XEmacs.
206 (defcustom gnus-article-x-face-command
207 (if (and (fboundp 'image-type-available-p)
208 (image-type-available-p 'xbm))
209 'gnus-article-display-xface
210 (if gnus-article-compface-xbm
211 "{ echo '/* Width=48, Height=48 */'; uncompface; } | display -"
212 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
214 "*String or function to be executed to display an X-Face header.
215 If it is a string, the command will be executed in a sub-shell
216 asynchronously. The compressed face will be piped to this command."
217 :type '(choice string
218 (function-item gnus-article-display-xface)
221 :group 'gnus-article-washing)
223 (defcustom gnus-article-x-face-too-ugly nil
224 "Regexp matching posters whose face shouldn't be shown automatically."
225 :type '(choice regexp (const nil))
226 :group 'gnus-article-washing)
228 (defcustom gnus-article-banner-alist nil
229 "Banner alist for stripping.
231 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( eGroups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
233 :type '(repeat (cons symbol regexp))
234 :group 'gnus-article-washing)
236 (defcustom gnus-emphasis-alist
238 "\\(\\s-\\|^\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\s-\\|[-,;:\"]\\s-\\|[?!.]+\\s-\\|\\s)\\)")
240 '(("_" "_" underline)
243 ("_/" "/_" underline-italic)
244 ("_\\*" "\\*_" underline-bold)
245 ("\\*/" "/\\*" bold-italic)
246 ("_\\*/" "/\\*_" underline-bold-italic))))
247 `(("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
248 2 3 gnus-emphasis-underline)
252 (format format (car spec) (cadr spec))
253 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
255 "*Alist that says how to fontify certain phrases.
256 Each item looks like this:
258 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
260 The first element is a regular expression to be matched. The second
261 is a number that says what regular expression grouping used to find
262 the entire emphasized word. The third is a number that says what
263 regexp grouping should be displayed and highlighted. The fourth
264 is the face used for highlighting."
265 :type '(repeat (list :value ("" 0 0 default)
267 (integer :tag "Match group")
268 (integer :tag "Emphasize group")
270 :group 'gnus-article-emphasis)
272 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
273 "A regexp to describe whitespace which should not be emphasized.
274 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
275 The former avoids underlining of leading and trailing whitespace,
276 and the latter avoids underlining any whitespace at all."
278 :group 'gnus-article-emphasis
281 (defface gnus-emphasis-bold '((t (:bold t)))
282 "Face used for displaying strong emphasized text (*word*)."
283 :group 'gnus-article-emphasis)
285 (defface gnus-emphasis-italic '((t (:italic t)))
286 "Face used for displaying italic emphasized text (/word/)."
287 :group 'gnus-article-emphasis)
289 (defface gnus-emphasis-underline '((t (:underline t)))
290 "Face used for displaying underlined emphasized text (_word_)."
291 :group 'gnus-article-emphasis)
293 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
294 "Face used for displaying underlined bold emphasized text (_*word*_)."
295 :group 'gnus-article-emphasis)
297 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
298 "Face used for displaying underlined italic emphasized text (_/word/_)."
299 :group 'gnus-article-emphasis)
301 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
302 "Face used for displaying bold italic emphasized text (/*word*/)."
303 :group 'gnus-article-emphasis)
305 (defface gnus-emphasis-underline-bold-italic
306 '((t (:bold t :italic t :underline t)))
307 "Face used for displaying underlined bold italic emphasized text.
308 Esample: (_/*word*/_)."
309 :group 'gnus-article-emphasis)
311 (defface gnus-emphasis-highlight-words
312 '((t (:background "black" :foreground "yellow")))
313 "Face used for displaying highlighted words."
314 :group 'gnus-article-emphasis)
316 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
317 "Format for display of Date headers in article bodies.
318 See `format-time-string' for the possible values.
320 The variable can also be function, which should return a complete Date
321 header. The function is called with one argument, the time, which can
322 be fed to `format-time-string'."
323 :type '(choice string symbol)
324 :link '(custom-manual "(gnus)Article Date")
325 :group 'gnus-article-washing)
328 (autoload 'mail-extract-address-components "mail-extr"))
330 (defcustom gnus-save-all-headers t
331 "*If non-nil, don't remove any headers before saving."
332 :group 'gnus-article-saving
335 (defcustom gnus-prompt-before-saving 'always
336 "*This variable says how much prompting is to be done when saving articles.
337 If it is nil, no prompting will be done, and the articles will be
338 saved to the default files. If this variable is `always', each and
339 every article that is saved will be preceded by a prompt, even when
340 saving large batches of articles. If this variable is neither nil not
341 `always', there the user will be prompted once for a file name for
342 each invocation of the saving commands."
343 :group 'gnus-article-saving
344 :type '(choice (item always)
345 (item :tag "never" nil)
346 (sexp :tag "once" :format "%t\n" :value t)))
348 (defcustom gnus-saved-headers gnus-visible-headers
349 "Headers to keep if `gnus-save-all-headers' is nil.
350 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
351 If that variable is nil, however, all headers that match this regexp
352 will be kept while the rest will be deleted before saving."
353 :group 'gnus-article-saving
356 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
357 "A function to save articles in your favourite format.
358 The function must be interactively callable (in other words, it must
359 be an Emacs command).
361 Gnus provides the following functions:
363 * gnus-summary-save-in-rmail (Rmail format)
364 * gnus-summary-save-in-mail (Unix mail format)
365 * gnus-summary-save-in-folder (MH folder)
366 * gnus-summary-save-in-file (article format)
367 * gnus-summary-save-in-vm (use VM's folder format)
368 * gnus-summary-write-to-file (article format -- overwrite)."
369 :group 'gnus-article-saving
370 :type '(radio (function-item gnus-summary-save-in-rmail)
371 (function-item gnus-summary-save-in-mail)
372 (function-item gnus-summary-save-in-folder)
373 (function-item gnus-summary-save-in-file)
374 (function-item gnus-summary-save-in-vm)
375 (function-item gnus-summary-write-to-file)))
377 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
378 "A function generating a file name to save articles in Rmail format.
379 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
380 :group 'gnus-article-saving
383 (defcustom gnus-mail-save-name 'gnus-plain-save-name
384 "A function generating a file name to save articles in Unix mail format.
385 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
386 :group 'gnus-article-saving
389 (defcustom gnus-folder-save-name 'gnus-folder-save-name
390 "A function generating a file name to save articles in MH folder.
391 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
392 :group 'gnus-article-saving
395 (defcustom gnus-file-save-name 'gnus-numeric-save-name
396 "A function generating a file name to save articles in article format.
397 The function is called with NEWSGROUP, HEADERS, and optional
399 :group 'gnus-article-saving
402 (defcustom gnus-split-methods
403 '((gnus-article-archive-name)
404 (gnus-article-nndoc-name))
405 "*Variable used to suggest where articles are to be saved.
406 For instance, if you would like to save articles related to Gnus in
407 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
408 you could set this variable to something like:
410 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
411 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
413 This variable is an alist where the where the key is the match and the
414 value is a list of possible files to save in if the match is non-nil.
416 If the match is a string, it is used as a regexp match on the
417 article. If the match is a symbol, that symbol will be funcalled
418 from the buffer of the article to be saved with the newsgroup as the
419 parameter. If it is a list, it will be evaled in the same buffer.
421 If this form or function returns a string, this string will be used as
422 a possible file name; and if it returns a non-nil list, that list will
423 be used as possible file names."
424 :group 'gnus-article-saving
425 :type '(repeat (choice (list :value (fun) function)
426 (cons :value ("" "") regexp (repeat string))
429 (defcustom gnus-page-delimiter "^\^L"
430 "*Regexp describing what to use as article page delimiters.
431 The default value is \"^\^L\", which is a form linefeed at the
432 beginning of a line."
434 :group 'gnus-article-various)
436 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
437 "*The format specification for the article mode line.
438 See `gnus-summary-mode-line-format' for a closer description.
440 The following additional specs are available:
442 %w The article washing status.
443 %m The number of MIME parts in the article."
445 :group 'gnus-article-various)
447 (defcustom gnus-article-mode-hook nil
448 "*A hook for Gnus article mode."
450 :group 'gnus-article-various)
452 (defcustom gnus-article-menu-hook nil
453 "*Hook run after the creation of the article mode menu."
455 :group 'gnus-article-various)
457 (defcustom gnus-article-prepare-hook nil
458 "*A hook called after an article has been prepared in the article buffer."
460 :group 'gnus-article-various)
462 (defcustom gnus-article-hide-pgp-hook nil
463 "*A hook called after successfully hiding a PGP signature."
465 :group 'gnus-article-various)
467 (defcustom gnus-article-button-face 'bold
468 "Face used for highlighting buttons in the article buffer.
470 An article button is a piece of text that you can activate by pressing
471 `RET' or `mouse-2' above it."
473 :group 'gnus-article-buttons)
475 (defcustom gnus-article-mouse-face 'highlight
476 "Face used for mouse highlighting in the article buffer.
478 Article buttons will be displayed in this face when the cursor is
481 :group 'gnus-article-buttons)
483 (defcustom gnus-signature-face 'gnus-signature-face
484 "Face used for highlighting a signature in the article buffer.
485 Obsolete; use the face `gnus-signature-face' for customizations instead."
487 :group 'gnus-article-highlight
488 :group 'gnus-article-signature)
490 (defface gnus-signature-face
493 "Face used for highlighting a signature in the article buffer."
494 :group 'gnus-article-highlight
495 :group 'gnus-article-signature)
497 (defface gnus-header-from-face
500 (:foreground "spring green"))
503 (:foreground "red3"))
506 "Face used for displaying from headers."
507 :group 'gnus-article-headers
508 :group 'gnus-article-highlight)
510 (defface gnus-header-subject-face
513 (:foreground "SeaGreen3"))
516 (:foreground "red4"))
518 (:bold t :italic t)))
519 "Face used for displaying subject headers."
520 :group 'gnus-article-headers
521 :group 'gnus-article-highlight)
523 (defface gnus-header-newsgroups-face
526 (:foreground "yellow" :italic t))
529 (:foreground "MidnightBlue" :italic t))
532 "Face used for displaying newsgroups headers."
533 :group 'gnus-article-headers
534 :group 'gnus-article-highlight)
536 (defface gnus-header-name-face
539 (:foreground "SeaGreen"))
542 (:foreground "maroon"))
545 "Face used for displaying header names."
546 :group 'gnus-article-headers
547 :group 'gnus-article-highlight)
549 (defface gnus-header-content-face
552 (:foreground "forest green" :italic t))
555 (:foreground "indianred4" :italic t))
557 (:italic t))) "Face used for displaying header content."
558 :group 'gnus-article-headers
559 :group 'gnus-article-highlight)
561 (defcustom gnus-header-face-alist
562 '(("From" nil gnus-header-from-face)
563 ("Subject" nil gnus-header-subject-face)
564 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
565 ("" gnus-header-name-face gnus-header-content-face))
566 "*Controls highlighting of article header.
568 An alist of the form (HEADER NAME CONTENT).
570 HEADER is a regular expression which should match the name of an
571 header header and NAME and CONTENT are either face names or nil.
573 The name of each header field will be displayed using the face
574 specified by the first element in the list where HEADER match the
575 header name and NAME is non-nil. Similarly, the content will be
576 displayed by the first non-nil matching CONTENT face."
577 :group 'gnus-article-headers
578 :group 'gnus-article-highlight
579 :type '(repeat (list (regexp :tag "Header")
581 (item :tag "skip" nil)
582 (face :value default))
583 (choice :tag "Content"
584 (item :tag "skip" nil)
585 (face :value default)))))
587 (defcustom gnus-article-decode-hook
588 '(article-decode-charset article-decode-encoded-words)
589 "*Hook run to decode charsets in articles."
590 :group 'gnus-article-headers
593 (defcustom gnus-display-mime-function 'gnus-display-mime
594 "Function to display MIME articles."
595 :group 'gnus-article-mime
598 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
599 "Function used to decode headers.")
601 (defvar gnus-article-dumbquotes-map
619 "Table for MS-to-Latin1 translation.")
621 (defcustom gnus-ignored-mime-types nil
622 "List of MIME types that should be ignored by Gnus."
624 :group 'gnus-article-mime
625 :type '(repeat regexp))
627 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
628 "List of MIME types that should not be given buttons when rendered inline."
630 :group 'gnus-article-mime
631 :type '(repeat regexp))
633 (defcustom gnus-article-mime-part-function nil
634 "Function called with a MIME handle as the argument.
635 This is meant for people who want to do something automatic based
636 on parts -- for instance, adding Vcard info to a database."
637 :group 'gnus-article-mime
640 (defcustom gnus-mime-multipart-functions nil
641 "An alist of MIME types to functions to display them."
643 :group 'gnus-article-mime
646 (defcustom gnus-article-date-lapsed-new-header nil
647 "Whether the X-Sent and Date headers can coexist.
648 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
649 either replace the old \"Date:\" header (if this variable is nil), or
650 be added below it (otherwise)."
652 :group 'gnus-article-headers
655 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
656 "Function called with a MIME handle as the argument.
657 This is meant for people who want to view first matched part.
658 For `undisplayed-alternative' (default), the first undisplayed
659 part or alternative part is used. For `undisplayed', the first
660 undisplayed part is used. For a function, the first part which
661 the function return `t' is used. For `nil', the first part is
664 :group 'gnus-article-mime
666 (item :tag "first" :value nil)
667 (item :tag "undisplayed" :value undisplayed)
668 (item :tag "undisplayed or alternative"
669 :value undisplayed-alternative)
672 (defcustom gnus-mime-action-alist
673 '(("save to file" . gnus-mime-save-part)
674 ("display as text" . gnus-mime-inline-part)
675 ("view the part" . gnus-mime-view-part)
676 ("pipe to command" . gnus-mime-pipe-part)
677 ("toggle display" . gnus-article-press-button)
678 ("view as type" . gnus-mime-view-part-as-type)
679 ("internalize type" . gnus-mime-internalize-part)
680 ("externalize type" . gnus-mime-externalize-part))
681 "An alist of actions that run on the MIME attachment."
683 :group 'gnus-article-mime
684 :type '(repeat (cons (string :tag "name")
688 ;;; The treatment variables
691 (defvar gnus-part-display-hook nil
692 "Hook called on parts that are to receive treatment.")
694 (defvar gnus-article-treat-custom
695 '(choice (const :tag "Off" nil)
697 (const :tag "Header" head)
698 (const :tag "Last" last)
699 (integer :tag "Less")
700 (repeat :tag "Groups" regexp)
701 (sexp :tag "Predicate")))
703 (defvar gnus-article-treat-head-custom
704 '(choice (const :tag "Off" nil)
705 (const :tag "Header" head)))
707 (defvar gnus-article-treat-types '("text/plain")
710 (defvar gnus-inhibit-treatment nil
711 "Whether to inhibit treatment.")
713 (defcustom gnus-treat-highlight-signature '(or last (typep "text/x-vcard"))
714 "Highlight the signature.
715 Valid values are nil, t, `head', `last', an integer or a predicate.
716 See the manual for details."
717 :group 'gnus-article-treat
718 :type gnus-article-treat-custom)
719 (put 'gnus-treat-highlight-signature 'highlight t)
721 (defcustom gnus-treat-buttonize 100000
723 Valid values are nil, t, `head', `last', an integer or a predicate.
724 See the manual for details."
725 :group 'gnus-article-treat
726 :type gnus-article-treat-custom)
727 (put 'gnus-treat-buttonize 'highlight t)
729 (defcustom gnus-treat-buttonize-head 'head
730 "Add buttons to the head.
731 Valid values are nil, t, `head', `last', an integer or a predicate.
732 See the manual for details."
733 :group 'gnus-article-treat
734 :type gnus-article-treat-head-custom)
735 (put 'gnus-treat-buttonize-head 'highlight t)
737 (defcustom gnus-treat-emphasize
738 (and (or window-system
740 (>= (string-to-number emacs-version) 21))
743 Valid values are nil, t, `head', `last', an integer or a predicate.
744 See the manual for details."
745 :group 'gnus-article-treat
746 :type gnus-article-treat-custom)
747 (put 'gnus-treat-emphasize 'highlight t)
749 (defcustom gnus-treat-strip-cr nil
750 "Remove carriage returns.
751 Valid values are nil, t, `head', `last', an integer or a predicate.
752 See the manual for details."
753 :group 'gnus-article-treat
754 :type gnus-article-treat-custom)
756 (defcustom gnus-treat-hide-headers 'head
758 Valid values are nil, t, `head', `last', an integer or a predicate.
759 See the manual for details."
760 :group 'gnus-article-treat
761 :type gnus-article-treat-head-custom)
763 (defcustom gnus-treat-hide-boring-headers nil
764 "Hide boring headers.
765 Valid values are nil, t, `head', `last', an integer or a predicate.
766 See the manual for details."
767 :group 'gnus-article-treat
768 :type gnus-article-treat-head-custom)
770 (defcustom gnus-treat-hide-signature nil
772 Valid values are nil, t, `head', `last', an integer or a predicate.
773 See the manual for details."
774 :group 'gnus-article-treat
775 :type gnus-article-treat-custom)
777 (defcustom gnus-treat-fill-article nil
779 Valid values are nil, t, `head', `last', an integer or a predicate.
780 See the manual for details."
781 :group 'gnus-article-treat
782 :type gnus-article-treat-custom)
784 (defcustom gnus-treat-hide-citation nil
786 Valid values are nil, t, `head', `last', an integer or a predicate.
787 See the manual for details."
788 :group 'gnus-article-treat
789 :type gnus-article-treat-custom)
791 (defcustom gnus-treat-hide-citation-maybe nil
793 Valid values are nil, t, `head', `last', an integer or a predicate.
794 See the manual for details."
795 :group 'gnus-article-treat
796 :type gnus-article-treat-custom)
798 (defcustom gnus-treat-strip-list-identifiers 'head
799 "Strip list identifiers from `gnus-list-identifiers`.
800 Valid values are nil, t, `head', `last', an integer or a predicate.
801 See the manual for details."
803 :group 'gnus-article-treat
804 :type gnus-article-treat-custom)
806 (defcustom gnus-treat-strip-pgp t
807 "Strip PGP signatures.
808 Valid values are nil, t, `head', `last', an integer or a predicate.
809 See the manual for details."
810 :group 'gnus-article-treat
811 :type gnus-article-treat-custom)
813 (defcustom gnus-treat-strip-pem nil
814 "Strip PEM signatures.
815 Valid values are nil, t, `head', `last', an integer or a predicate.
816 See the manual for details."
817 :group 'gnus-article-treat
818 :type gnus-article-treat-custom)
820 (defcustom gnus-treat-strip-banner t
821 "Strip banners from articles.
822 The banner to be stripped is specified in the `banner' group parameter.
823 Valid values are nil, t, `head', `last', an integer or a predicate.
824 See the manual for details."
825 :group 'gnus-article-treat
826 :type gnus-article-treat-custom)
828 (defcustom gnus-treat-highlight-headers 'head
829 "Highlight the headers.
830 Valid values are nil, t, `head', `last', an integer or a predicate.
831 See the manual for details."
832 :group 'gnus-article-treat
833 :type gnus-article-treat-head-custom)
834 (put 'gnus-treat-highlight-headers 'highlight t)
836 (defcustom gnus-treat-highlight-citation t
837 "Highlight cited text.
838 Valid values are nil, t, `head', `last', an integer or a predicate.
839 See the manual for details."
840 :group 'gnus-article-treat
841 :type gnus-article-treat-custom)
842 (put 'gnus-treat-highlight-citation 'highlight t)
844 (defcustom gnus-treat-date-ut nil
845 "Display the Date in UT (GMT).
846 Valid values are nil, t, `head', `last', an integer or a predicate.
847 See the manual for details."
848 :group 'gnus-article-treat
849 :type gnus-article-treat-head-custom)
851 (defcustom gnus-treat-date-local nil
852 "Display the Date in the local timezone.
853 Valid values are nil, t, `head', `last', an integer or a predicate.
854 See the manual for details."
855 :group 'gnus-article-treat
856 :type gnus-article-treat-head-custom)
858 (defcustom gnus-treat-date-lapsed nil
859 "Display the Date header in a way that says how much time has elapsed.
860 Valid values are nil, t, `head', `last', an integer or a predicate.
861 See the manual for details."
862 :group 'gnus-article-treat
863 :type gnus-article-treat-head-custom)
865 (defcustom gnus-treat-date-original nil
866 "Display the date in the original timezone.
867 Valid values are nil, t, `head', `last', an integer or a predicate.
868 See the manual for details."
869 :group 'gnus-article-treat
870 :type gnus-article-treat-head-custom)
872 (defcustom gnus-treat-date-iso8601 nil
873 "Display the date in the ISO8601 format.
874 Valid values are nil, t, `head', `last', an integer or a predicate.
875 See the manual for details."
877 :group 'gnus-article-treat
878 :type gnus-article-treat-head-custom)
880 (defcustom gnus-treat-date-user-defined nil
881 "Display the date in a user-defined format.
882 The format is defined by the `gnus-article-time-format' variable.
883 Valid values are nil, t, `head', `last', an integer or a predicate.
884 See the manual for details."
885 :group 'gnus-article-treat
886 :type gnus-article-treat-head-custom)
888 (defcustom gnus-treat-strip-headers-in-body t
889 "Strip the X-No-Archive header line from the beginning of the body.
890 Valid values are nil, t, `head', `last', an integer or a predicate.
891 See the manual for details."
893 :group 'gnus-article-treat
894 :type gnus-article-treat-custom)
896 (defcustom gnus-treat-strip-trailing-blank-lines nil
897 "Strip trailing blank lines.
898 Valid values are nil, t, `head', `last', an integer or a predicate.
899 See the manual for details."
900 :group 'gnus-article-treat
901 :type gnus-article-treat-custom)
903 (defcustom gnus-treat-strip-leading-blank-lines nil
904 "Strip leading blank lines.
905 Valid values are nil, t, `head', `last', an integer or a predicate.
906 See the manual for details."
907 :group 'gnus-article-treat
908 :type gnus-article-treat-custom)
910 (defcustom gnus-treat-strip-multiple-blank-lines nil
911 "Strip multiple blank lines.
912 Valid values are nil, t, `head', `last', an integer or a predicate.
913 See the manual for details."
914 :group 'gnus-article-treat
915 :type gnus-article-treat-custom)
917 (defcustom gnus-treat-overstrike t
918 "Treat overstrike highlighting.
919 Valid values are nil, t, `head', `last', an integer or a predicate.
920 See the manual for details."
921 :group 'gnus-article-treat
922 :type gnus-article-treat-custom)
923 (put 'gnus-treat-overstrike 'highlight t)
925 (defcustom gnus-treat-display-xface
926 (and (or (and (fboundp 'image-type-available-p)
927 (image-type-available-p 'xbm)
928 (string-match "^0x" (shell-command-to-string "uncompface")))
929 (and (featurep 'xemacs) (featurep 'xface)))
931 "Display X-Face headers.
932 Valid values are nil, t, `head', `last', an integer or a predicate.
933 See the manual for details."
934 :group 'gnus-article-treat
936 :type gnus-article-treat-head-custom)
937 (put 'gnus-treat-display-xface 'highlight t)
939 (defcustom gnus-treat-display-smileys
940 (if (or (and (featurep 'xemacs)
942 (and (fboundp 'image-type-available-p)
943 (image-type-available-p 'pbm)))
946 Valid values are nil, t, `head', `last', an integer or a predicate.
947 See the manual for details."
948 :group 'gnus-article-treat
950 :type gnus-article-treat-custom)
951 (put 'gnus-treat-display-smileys 'highlight t)
953 (defcustom gnus-treat-display-picons (if (featurep 'xemacs) 'head nil)
955 Valid values are nil, t, `head', `last', an integer or a predicate.
956 See the manual for details."
957 :group 'gnus-article-treat
958 :type gnus-article-treat-head-custom)
959 (put 'gnus-treat-display-picons 'highlight t)
961 (defcustom gnus-treat-capitalize-sentences nil
962 "Capitalize sentence-starting words.
963 Valid values are nil, t, `head', `last', an integer or a predicate.
964 See the manual for details."
966 :group 'gnus-article-treat
967 :type gnus-article-treat-custom)
969 (defcustom gnus-treat-fill-long-lines nil
971 Valid values are nil, t, `head', `last', an integer or a predicate.
972 See the manual for details."
973 :group 'gnus-article-treat
974 :type gnus-article-treat-custom)
976 (defcustom gnus-treat-play-sounds nil
978 Valid values are nil, t, `head', `last', an integer or a predicate.
979 See the manual for details."
981 :group 'gnus-article-treat
982 :type gnus-article-treat-custom)
984 (defcustom gnus-treat-translate nil
985 "Translate articles from one language to another.
986 Valid values are nil, t, `head', `last', an integer or a predicate.
987 See the manual for details."
989 :group 'gnus-article-treat
990 :type gnus-article-treat-custom)
992 ;;; Internal variables
994 (defvar article-goto-body-goes-to-point-min-p nil)
995 (defvar gnus-article-wash-types nil)
996 (defvar gnus-article-emphasis-alist nil)
998 (defvar gnus-article-mime-handle-alist-1 nil)
999 (defvar gnus-treatment-function-alist
1000 '((gnus-treat-strip-banner gnus-article-strip-banner)
1001 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1002 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1003 (gnus-treat-buttonize gnus-article-add-buttons)
1004 (gnus-treat-fill-article gnus-article-fill-cited-article)
1005 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1006 (gnus-treat-strip-cr gnus-article-remove-cr)
1007 (gnus-treat-emphasize gnus-article-emphasize)
1008 (gnus-treat-display-xface gnus-article-display-x-face)
1009 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1010 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1011 (gnus-treat-hide-signature gnus-article-hide-signature)
1012 (gnus-treat-hide-citation gnus-article-hide-citation)
1013 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1014 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1015 (gnus-treat-strip-pgp gnus-article-hide-pgp)
1016 (gnus-treat-strip-pem gnus-article-hide-pem)
1017 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1018 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1019 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1020 (gnus-treat-date-ut gnus-article-date-ut)
1021 (gnus-treat-date-local gnus-article-date-local)
1022 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1023 (gnus-treat-date-original gnus-article-date-original)
1024 (gnus-treat-date-user-defined gnus-article-date-user)
1025 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1026 (gnus-treat-strip-trailing-blank-lines
1027 gnus-article-remove-trailing-blank-lines)
1028 (gnus-treat-strip-leading-blank-lines
1029 gnus-article-strip-leading-blank-lines)
1030 (gnus-treat-strip-multiple-blank-lines
1031 gnus-article-strip-multiple-blank-lines)
1032 (gnus-treat-overstrike gnus-article-treat-overstrike)
1033 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1034 (gnus-treat-display-smileys gnus-smiley-display)
1035 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1036 (gnus-treat-display-picons gnus-article-display-picons)
1037 (gnus-treat-play-sounds gnus-earcon-display)))
1039 (defvar gnus-article-mime-handle-alist nil)
1040 (defvar article-lapsed-timer nil)
1041 (defvar gnus-article-current-summary nil)
1043 (defvar gnus-article-mode-syntax-table
1044 (let ((table (copy-syntax-table text-mode-syntax-table)))
1045 (modify-syntax-entry ?- "w" table)
1046 (modify-syntax-entry ?> ")" table)
1047 (modify-syntax-entry ?< "(" table)
1049 "Syntax table used in article mode buffers.
1050 Initialized from `text-mode-syntax-table.")
1052 (defvar gnus-save-article-buffer nil)
1054 (defvar gnus-article-mode-line-format-alist
1055 (nconc '((?w (gnus-article-wash-status) ?s)
1056 (?m (gnus-article-mime-part-status) ?s))
1057 gnus-summary-mode-line-format-alist))
1059 (defvar gnus-number-of-articles-to-be-saved nil)
1061 (defvar gnus-inhibit-hiding nil)
1063 (defsubst gnus-article-hide-text (b e props)
1064 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1065 (gnus-add-text-properties-when 'article-type nil b e props)
1066 (when (memq 'intangible props)
1068 (max (1- b) (point-min))
1069 b 'intangible (cddr (memq 'intangible props)))))
1071 (defsubst gnus-article-unhide-text (b e)
1072 "Remove hidden text properties from region between B and E."
1073 (remove-text-properties b e gnus-hidden-properties)
1074 (when (memq 'intangible gnus-hidden-properties)
1075 (put-text-property (max (1- b) (point-min))
1076 b 'intangible nil)))
1078 (defun gnus-article-hide-text-type (b e type)
1079 "Hide text of TYPE between B and E."
1080 (push type gnus-article-wash-types)
1081 (gnus-article-hide-text
1082 b e (cons 'article-type (cons type gnus-hidden-properties))))
1084 (defun gnus-article-unhide-text-type (b e type)
1085 "Unhide text of TYPE between B and E."
1086 (setq gnus-article-wash-types
1087 (delq type gnus-article-wash-types))
1088 (remove-text-properties
1089 b e (cons 'article-type (cons type gnus-hidden-properties)))
1090 (when (memq 'intangible gnus-hidden-properties)
1091 (put-text-property (max (1- b) (point-min))
1092 b 'intangible nil)))
1094 (defun gnus-article-hide-text-of-type (type)
1095 "Hide text of TYPE in the current buffer."
1097 (let ((b (point-min))
1099 (while (setq b (text-property-any b e 'article-type type))
1100 (add-text-properties b (incf b) gnus-hidden-properties)))))
1102 (defun gnus-article-delete-text-of-type (type)
1103 "Delete text of TYPE in the current buffer."
1105 (let ((b (point-min)))
1106 (while (setq b (text-property-any b (point-max) 'article-type type))
1108 b (or (text-property-not-all b (point-max) 'article-type type)
1111 (defun gnus-article-delete-invisible-text ()
1112 "Delete all invisible text in the current buffer."
1114 (let ((b (point-min)))
1115 (while (setq b (text-property-any b (point-max) 'invisible t))
1117 b (or (text-property-not-all b (point-max) 'invisible t)
1120 (defun gnus-article-text-type-exists-p (type)
1121 "Say whether any text of type TYPE exists in the buffer."
1122 (text-property-any (point-min) (point-max) 'article-type type))
1124 (defsubst gnus-article-header-rank ()
1125 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1126 (let ((list gnus-sorted-header-list)
1129 (when (looking-at (car list))
1131 (setq list (cdr list))
1135 (defun article-hide-headers (&optional arg delete)
1136 "Hide unwanted headers and possibly sort them as well."
1138 ;; This function might be inhibited.
1139 (unless gnus-inhibit-hiding
1142 (let ((buffer-read-only nil)
1143 (case-fold-search t)
1144 (max (1+ (length gnus-sorted-header-list)))
1145 (ignored (when (not gnus-visible-headers)
1146 (cond ((stringp gnus-ignored-headers)
1147 gnus-ignored-headers)
1148 ((listp gnus-ignored-headers)
1149 (mapconcat 'identity gnus-ignored-headers
1152 (cond ((stringp gnus-visible-headers)
1153 gnus-visible-headers)
1154 ((and gnus-visible-headers
1155 (listp gnus-visible-headers))
1156 (mapconcat 'identity gnus-visible-headers "\\|"))))
1157 (inhibit-point-motion-hooks t)
1159 ;; First we narrow to just the headers.
1160 (article-narrow-to-head)
1161 ;; Hide any "From " lines at the beginning of (mail) articles.
1162 (while (looking-at "From ")
1165 (delete-region (point-min) (point)))
1166 ;; Then treat the rest of the header lines.
1167 ;; Then we use the two regular expressions
1168 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1169 ;; select which header lines is to remain visible in the
1171 (while (re-search-forward "^[^ \t]*:" nil t)
1173 ;; Mark the rank of the header.
1175 (point) (1+ (point)) 'message-rank
1176 (if (or (and visible (looking-at visible))
1178 (not (looking-at ignored))))
1179 (gnus-article-header-rank)
1182 (message-sort-headers-1)
1183 (when (setq beg (text-property-any
1184 (point-min) (point-max) 'message-rank (+ 2 max)))
1185 ;; We delete the unwanted headers.
1186 (push 'headers gnus-article-wash-types)
1187 (add-text-properties (point-min) (+ 5 (point-min))
1188 '(article-type headers dummy-invisible t))
1189 (delete-region beg (point-max))))))))
1191 (defun article-hide-boring-headers (&optional arg)
1192 "Toggle hiding of headers that aren't very interesting.
1193 If given a negative prefix, always show; if given a positive prefix,
1195 (interactive (gnus-article-hidden-arg))
1196 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1197 (not gnus-show-all-headers))
1200 (let ((buffer-read-only nil)
1201 (list gnus-boring-article-headers)
1202 (inhibit-point-motion-hooks t)
1204 (article-narrow-to-head)
1206 (setq elem (pop list))
1207 (goto-char (point-min))
1209 ;; Hide empty headers.
1211 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1213 (gnus-article-hide-text-type
1214 (progn (beginning-of-line) (point))
1217 (if (re-search-forward "^[^ \t]" nil t)
1221 ;; Hide boring Newsgroups header.
1222 ((eq elem 'newsgroups)
1223 (when (equal (gnus-fetch-field "newsgroups")
1224 (gnus-group-real-name
1225 (if (boundp 'gnus-newsgroup-name)
1228 (gnus-article-hide-header "newsgroups")))
1229 ((eq elem 'followup-to)
1230 (when (equal (message-fetch-field "followup-to")
1231 (message-fetch-field "newsgroups"))
1232 (gnus-article-hide-header "followup-to")))
1233 ((eq elem 'reply-to)
1234 (let ((from (message-fetch-field "from"))
1235 (reply-to (message-fetch-field "reply-to")))
1240 (nth 1 (mail-extract-address-components from))
1241 (nth 1 (mail-extract-address-components reply-to)))))
1242 (gnus-article-hide-header "reply-to"))))
1244 (let ((date (message-fetch-field "date")))
1246 (< (days-between (current-time-string) date)
1248 (gnus-article-hide-header "date"))))
1250 (let ((to (message-fetch-field "to"))
1251 (cc (message-fetch-field "cc")))
1252 (when (> (length to) 1024)
1253 (gnus-article-hide-header "to"))
1254 (when (> (length cc) 1024)
1255 (gnus-article-hide-header "cc"))))
1259 (goto-char (point-min))
1260 (while (re-search-forward "^to:" nil t)
1261 (setq to-count (1+ to-count)))
1262 (when (> to-count 1)
1263 (while (> to-count 0)
1264 (goto-char (point-min))
1266 (re-search-forward "^to:" nil nil to-count)
1268 (narrow-to-region (point) (point-max))
1269 (gnus-article-hide-header "to"))
1270 (setq to-count (1- to-count))))
1271 (goto-char (point-min))
1272 (while (re-search-forward "^cc:" nil t)
1273 (setq cc-count (1+ cc-count)))
1274 (when (> cc-count 1)
1275 (while (> cc-count 0)
1276 (goto-char (point-min))
1278 (re-search-forward "^cc:" nil nil cc-count)
1280 (narrow-to-region (point) (point-max))
1281 (gnus-article-hide-header "cc"))
1282 (setq cc-count (1- cc-count)))))))))))))
1284 (defun gnus-article-hide-header (header)
1286 (goto-char (point-min))
1287 (when (re-search-forward (concat "^" header ":") nil t)
1288 (gnus-article-hide-text-type
1289 (progn (beginning-of-line) (point))
1292 (if (re-search-forward "^[^ \t]" nil t)
1297 (defvar gnus-article-normalized-header-length 40
1298 "Length of normalized headers.")
1300 (defun article-normalize-headers ()
1301 "Make all header lines 40 characters long."
1303 (let ((buffer-read-only nil)
1307 (article-narrow-to-head)
1310 ((< (setq column (- (gnus-point-at-eol) (point)))
1311 gnus-article-normalized-header-length)
1313 (insert (make-string
1314 (- gnus-article-normalized-header-length column)
1316 ((> column gnus-article-normalized-header-length)
1317 (gnus-put-text-property
1319 (forward-char gnus-article-normalized-header-length)
1326 (forward-line 1))))))
1328 (defun article-treat-dumbquotes ()
1329 "Translate M****s*** sm*rtq**t*s into proper text.
1330 Note that this function guesses whether a character is a sm*rtq**t* or
1331 not, so it should only be used interactively.
1333 Sm*rtq**t*s are M****s***'s unilateral extension to the character map
1334 in an attempt to provide more quoting characters. If you see
1335 something like \\222 or \\264 where you're expecting some kind of
1336 apostrophe or quotation mark, then try this wash."
1338 (article-translate-strings gnus-article-dumbquotes-map))
1340 (defun article-translate-characters (from to)
1341 "Translate all characters in the body of the article according to FROM and TO.
1342 FROM is a string of characters to translate from; to is a string of
1343 characters to translate to."
1345 (when (article-goto-body)
1346 (let ((buffer-read-only nil)
1347 (x (make-string 225 ?x))
1349 (while (< (incf i) (length x))
1352 (while (< i (length from))
1353 (aset x (aref from i) (aref to i))
1355 (translate-region (point) (point-max) x)))))
1357 (defun article-translate-strings (map)
1358 "Translate all string in the body of the article according to MAP.
1359 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1361 (when (article-goto-body)
1362 (let ((buffer-read-only nil)
1364 (while (setq elem (pop map))
1366 (while (search-forward (car elem) nil t)
1367 (replace-match (cadr elem)))))))))
1369 (defun article-treat-overstrike ()
1370 "Translate overstrikes into bold text."
1373 (when (article-goto-body)
1374 (let ((buffer-read-only nil))
1375 (while (search-forward "\b" nil t)
1376 (let ((next (char-after))
1377 (previous (char-after (- (point) 2))))
1378 ;; We do the boldification/underlining by hiding the
1379 ;; overstrikes and putting the proper text property
1383 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1384 (put-text-property (point) (1+ (point)) 'face 'bold))
1386 (gnus-article-hide-text-type
1387 (1- (point)) (1+ (point)) 'overstrike)
1389 (- (point) 2) (1- (point)) 'face 'underline))
1391 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1393 (point) (1+ (point)) 'face 'underline)))))))))
1395 (defun article-fill-long-lines ()
1396 "Fill lines that are wider than the window width."
1399 (let ((buffer-read-only nil)
1400 (width (window-width (get-buffer-window (current-buffer)))))
1403 (let ((adaptive-fill-mode nil))
1406 (when (>= (current-column) (min fill-column width))
1407 (narrow-to-region (point) (gnus-point-at-bol))
1408 (fill-paragraph nil)
1409 (goto-char (point-max))
1411 (forward-line 1)))))))
1413 (defun article-capitalize-sentences ()
1414 "Capitalize the first word in each sentence."
1417 (let ((buffer-read-only nil)
1418 (paragraph-start "^[\n\^L]"))
1422 (forward-sentence)))))
1424 (defun article-remove-cr ()
1425 "Remove trailing CRs and then translate remaining CRs into LFs."
1428 (let ((buffer-read-only nil))
1429 (goto-char (point-min))
1430 (while (re-search-forward "\r+$" nil t)
1431 (replace-match "" t t))
1432 (goto-char (point-min))
1433 (while (search-forward "\r" nil t)
1434 (replace-match "\n" t t)))))
1436 (defun article-remove-trailing-blank-lines ()
1437 "Remove all trailing blank lines from the article."
1440 (let ((buffer-read-only nil))
1441 (goto-char (point-max))
1445 (while (and (not (bobp))
1446 (looking-at "^[ \t]*$")
1447 (not (gnus-annotation-in-region-p
1448 (point) (gnus-point-at-eol))))
1453 (defun article-display-x-face (&optional force)
1454 "Look for an X-Face header and display it if present."
1455 (interactive (list 'force))
1457 ;; Delete the old process, if any.
1458 (when (process-status "article-x-face")
1459 (delete-process "article-x-face"))
1460 (let ((inhibit-point-motion-hooks t)
1461 (case-fold-search t)
1464 (article-narrow-to-head)
1465 (goto-char (point-min))
1466 (setq from (message-fetch-field "from"))
1467 (goto-char (point-min))
1468 (while (and gnus-article-x-face-command
1471 ;; Check whether this face is censored.
1472 (not gnus-article-x-face-too-ugly)
1473 (and gnus-article-x-face-too-ugly from
1474 (not (string-match gnus-article-x-face-too-ugly
1476 ;; Has to be present.
1477 (re-search-forward "^X-Face: " nil t))
1478 ;; This used to try to do multiple faces (`while' instead of
1479 ;; `when' above), but (a) sending multiple EOFs to xv doesn't
1480 ;; work (b) it can crash some versions of Emacs (c) are
1481 ;; multiple faces really something to encourage?
1482 (when (stringp gnus-article-x-face-command)
1484 ;; We now have the area of the buffer where the X-Face is stored.
1487 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
1488 ;; We display the face.
1489 (if (symbolp gnus-article-x-face-command)
1490 ;; The command is a lisp function, so we call it.
1491 (if (gnus-functionp gnus-article-x-face-command)
1492 (funcall gnus-article-x-face-command beg end)
1493 (error "%s is not a function" gnus-article-x-face-command))
1494 ;; The command is a string, so we interpret the command
1495 ;; as a, well, command, and fork it off.
1496 (let ((process-connection-type nil))
1497 (process-kill-without-query
1499 "article-x-face" nil shell-file-name shell-command-switch
1500 gnus-article-x-face-command))
1501 (process-send-region "article-x-face" beg end)
1502 (process-send-eof "article-x-face"))))))))))
1504 (defun article-decode-mime-words ()
1505 "Decode all MIME-encoded words in the article."
1508 (set-buffer gnus-article-buffer)
1509 (let ((inhibit-point-motion-hooks t)
1511 (mail-parse-charset gnus-newsgroup-charset)
1512 (mail-parse-ignored-charsets
1513 (save-excursion (set-buffer gnus-summary-buffer)
1514 gnus-newsgroup-ignored-charsets)))
1515 (mail-decode-encoded-word-region (point-min) (point-max)))))
1517 (defun article-decode-charset (&optional prompt)
1518 "Decode charset-encoded text in the article.
1519 If PROMPT (the prefix), prompt for a coding system to use."
1521 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
1523 (mail-parse-charset gnus-newsgroup-charset)
1524 (mail-parse-ignored-charsets
1525 (save-excursion (condition-case nil
1526 (set-buffer gnus-summary-buffer)
1528 gnus-newsgroup-ignored-charsets))
1529 ct cte ctl charset format)
1532 (article-narrow-to-head)
1533 (setq ct (message-fetch-field "Content-Type" t)
1534 cte (message-fetch-field "Content-Transfer-Encoding" t)
1535 ctl (and ct (ignore-errors
1536 (mail-header-parse-content-type ct)))
1539 (mm-read-coding-system "Charset to decode: "))
1541 (mail-content-type-get ctl 'charset)))
1542 format (and ctl (mail-content-type-get ctl 'format)))
1544 (setq cte (mail-header-strip cte)))
1545 (if (and ctl (not (string-match "/" (car ctl))))
1547 (goto-char (point-max)))
1550 (narrow-to-region (point) (point-max))
1551 (when (and (eq mail-parse-charset 'gnus-decoded)
1552 (eq (mm-body-7-or-8) '8bit))
1553 ;; The text code could have been decoded.
1554 (setq charset mail-parse-charset))
1555 (when (and (or (not ctl)
1556 (equal (car ctl) "text/plain"))
1557 (not format)) ;; article with format will decode later.
1559 charset (and cte (intern (downcase
1560 (gnus-strip-whitespace cte))))
1563 (defun article-decode-encoded-words ()
1564 "Remove encoded-word encoding from headers."
1565 (let ((inhibit-point-motion-hooks t)
1566 (mail-parse-charset gnus-newsgroup-charset)
1567 (mail-parse-ignored-charsets
1568 (save-excursion (condition-case nil
1569 (set-buffer gnus-summary-buffer)
1571 gnus-newsgroup-ignored-charsets))
1574 (article-narrow-to-head)
1575 (funcall gnus-decode-header-function (point-min) (point-max)))))
1577 (defun article-de-quoted-unreadable (&optional force)
1578 "Translate a quoted-printable-encoded article.
1579 If FORCE, decode the article whether it is marked as quoted-printable
1581 (interactive (list 'force))
1583 (let ((buffer-read-only nil) type charset)
1584 (if (gnus-buffer-live-p gnus-original-article-buffer)
1585 (with-current-buffer gnus-original-article-buffer
1587 (gnus-fetch-field "content-transfer-encoding"))
1588 (let* ((ct (gnus-fetch-field "content-type"))
1591 (mail-header-parse-content-type ct)))))
1592 (setq charset (and ctl
1593 (mail-content-type-get ctl 'charset)))
1594 (if (stringp charset)
1595 (setq charset (intern (downcase charset)))))))
1597 (setq charset gnus-newsgroup-charset))
1599 (and type (let ((case-fold-search t))
1600 (string-match "quoted-printable" type))))
1602 (quoted-printable-decode-region
1603 (point) (point-max) (mm-charset-to-coding-system charset))))))
1605 (defun article-de-base64-unreadable (&optional force)
1606 "Translate a base64 article.
1607 If FORCE, decode the article whether it is marked as base64 not."
1608 (interactive (list 'force))
1610 (let ((buffer-read-only nil) type charset)
1611 (if (gnus-buffer-live-p gnus-original-article-buffer)
1612 (with-current-buffer gnus-original-article-buffer
1614 (gnus-fetch-field "content-transfer-encoding"))
1615 (let* ((ct (gnus-fetch-field "content-type"))
1618 (mail-header-parse-content-type ct)))))
1619 (setq charset (and ctl
1620 (mail-content-type-get ctl 'charset)))
1621 (if (stringp charset)
1622 (setq charset (intern (downcase charset)))))))
1624 (setq charset gnus-newsgroup-charset))
1626 (and type (let ((case-fold-search t))
1627 (string-match "base64" type))))
1630 (narrow-to-region (point) (point-max))
1631 (base64-decode-region (point-min) (point-max))
1632 (mm-decode-coding-region
1633 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
1638 (defun article-decode-HZ ()
1639 "Translate a HZ-encoded article."
1643 (let ((buffer-read-only nil))
1644 (rfc1843-decode-region (point-min) (point-max)))))
1646 (defun article-wash-html ()
1647 "Format an html article."
1650 (let ((buffer-read-only nil)
1652 (if (gnus-buffer-live-p gnus-original-article-buffer)
1653 (with-current-buffer gnus-original-article-buffer
1654 (let* ((ct (gnus-fetch-field "content-type"))
1657 (mail-header-parse-content-type ct)))))
1658 (setq charset (and ctl
1659 (mail-content-type-get ctl 'charset)))
1660 (if (stringp charset)
1661 (setq charset (intern (downcase charset)))))))
1663 (setq charset gnus-newsgroup-charset))
1665 (save-window-excursion
1667 (narrow-to-region (point) (point-max))
1669 (let ((w3-strict-width (window-width))
1670 (url-standalone-mode t))
1672 (w3-region (point-min) (point-max))
1675 (defun article-hide-list-identifiers ()
1676 "Remove list identifies from the Subject header.
1677 The `gnus-list-identifiers' variable specifies what to do."
1681 (let ((inhibit-point-motion-hooks t)
1683 (article-narrow-to-head)
1684 (let ((regexp (if (stringp gnus-list-identifiers) gnus-list-identifiers
1685 (mapconcat 'identity gnus-list-identifiers " *\\|"))))
1687 (goto-char (point-min))
1688 (when (re-search-forward
1689 (concat "^Subject: +\\(\\(\\(Re: +\\)?\\(" regexp
1690 " *\\)\\)+\\(Re: +\\)?\\)")
1692 (let ((s (or (match-string 3) (match-string 5))))
1693 (delete-region (match-beginning 1) (match-end 1))
1695 (goto-char (match-beginning 1))
1698 (defun article-hide-pgp ()
1699 "Remove any PGP headers and signatures in the current article."
1703 (let ((inhibit-point-motion-hooks t)
1704 buffer-read-only beg end)
1706 ;; Hide the "header".
1707 (when (re-search-forward "^-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
1708 (push 'pgp gnus-article-wash-types)
1709 (delete-region (match-beginning 0) (match-end 0))
1710 ;; Remove armor headers (rfc2440 6.2)
1711 (delete-region (point) (or (re-search-forward "^[ \t]*\n" nil t)
1714 ;; Hide the actual signature.
1715 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
1716 (setq end (1+ (match-beginning 0)))
1719 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
1721 ;; Perhaps we shouldn't hide to the end of the buffer
1722 ;; if there is no end to the signature?
1724 ;; Hide "- " PGP quotation markers.
1726 (narrow-to-region beg end)
1727 (goto-char (point-min))
1728 (while (re-search-forward "^- " nil t)
1730 (match-beginning 0) (match-end 0)))
1732 (gnus-run-hooks 'gnus-article-hide-pgp-hook))))))
1734 (defun article-hide-pem (&optional arg)
1735 "Toggle hiding of any PEM headers and signatures in the current article.
1736 If given a negative prefix, always show; if given a positive prefix,
1738 (interactive (gnus-article-hidden-arg))
1739 (unless (gnus-article-check-hidden-text 'pem arg)
1741 (let (buffer-read-only end)
1742 (goto-char (point-min))
1743 ;; Hide the horrendously ugly "header".
1744 (when (and (search-forward
1745 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
1747 (setq end (1+ (match-beginning 0))))
1748 (push 'pem gnus-article-wash-types)
1749 (gnus-article-hide-text-type
1751 (if (search-forward "\n\n" nil t)
1755 ;; Hide the trailer as well
1756 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
1758 (gnus-article-hide-text-type
1759 (match-beginning 0) (match-end 0) 'pem)))))))
1761 (defun article-strip-banner ()
1762 "Strip the banner specified by the `banner' group parameter."
1766 (let ((inhibit-point-motion-hooks t)
1767 (banner (gnus-group-find-parameter gnus-newsgroup-name 'banner))
1768 (gnus-signature-limit nil)
1769 buffer-read-only beg end)
1773 ((eq banner 'signature)
1774 (when (gnus-article-narrow-to-signature)
1777 (delete-region (point) (point-max))))
1779 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
1780 (while (re-search-forward banner nil t)
1781 (delete-region (match-beginning 0) (match-end 0)))))
1783 (while (re-search-forward banner nil t)
1784 (delete-region (match-beginning 0) (match-end 0))))))))))
1786 (defun article-babel ()
1787 "Translate article using an online translation service."
1791 (set-buffer gnus-article-buffer)
1792 (when (article-goto-body)
1793 (let* ((buffer-read-only nil)
1796 (orig (buffer-substring start end))
1797 (trans (babel-as-string orig)))
1799 (narrow-to-region start end)
1800 (delete-region start end)
1803 (defun article-hide-signature (&optional arg)
1804 "Hide the signature in the current article.
1805 If given a negative prefix, always show; if given a positive prefix,
1807 (interactive (gnus-article-hidden-arg))
1808 (unless (gnus-article-check-hidden-text 'signature arg)
1811 (let ((buffer-read-only nil))
1812 (when (gnus-article-narrow-to-signature)
1813 (gnus-article-hide-text-type
1814 (point-min) (point-max) 'signature)))))))
1816 (defun article-strip-headers-in-body ()
1817 "Strip offensive headers from bodies."
1821 (let ((case-fold-search t))
1822 (when (looking-at "x-no-archive:")
1823 (gnus-delete-line)))))
1825 (defun article-strip-leading-blank-lines ()
1826 "Remove all blank lines from the beginning of the article."
1829 (let ((inhibit-point-motion-hooks t)
1831 (when (article-goto-body)
1832 (while (and (not (eobp))
1833 (looking-at "[ \t]*$"))
1834 (gnus-delete-line))))))
1836 (defun article-narrow-to-head ()
1837 "Narrow the buffer to the head of the message.
1838 Point is left at the beginning of the narrowed-to region."
1840 (goto-char (point-min))
1841 (if (search-forward "\n\n" nil 1)
1844 (goto-char (point-min)))
1846 (defun article-goto-body ()
1847 "Place point at the start of the body."
1848 (goto-char (point-min))
1850 ;; This variable is only bound when dealing with separate
1852 (article-goto-body-goes-to-point-min-p
1854 ((search-forward "\n\n" nil t)
1857 (goto-char (point-max))
1860 (defun article-strip-multiple-blank-lines ()
1861 "Replace consecutive blank lines with one empty line."
1864 (let ((inhibit-point-motion-hooks t)
1866 ;; First make all blank lines empty.
1868 (while (re-search-forward "^[ \t]+$" nil t)
1869 (unless (gnus-annotation-in-region-p
1870 (match-beginning 0) (match-end 0))
1871 (replace-match "" nil t)))
1872 ;; Then replace multiple empty lines with a single empty line.
1874 (while (re-search-forward "\n\n\n+" nil t)
1875 (unless (gnus-annotation-in-region-p
1876 (match-beginning 0) (match-end 0))
1877 (replace-match "\n\n" t t))))))
1879 (defun article-strip-leading-space ()
1880 "Remove all white space from the beginning of the lines in the article."
1883 (let ((inhibit-point-motion-hooks t)
1886 (while (re-search-forward "^[ \t]+" nil t)
1887 (replace-match "" t t)))))
1889 (defun article-strip-trailing-space ()
1890 "Remove all white space from the end of the lines in the article."
1893 (let ((inhibit-point-motion-hooks t)
1896 (while (re-search-forward "[ \t]+$" nil t)
1897 (replace-match "" t t)))))
1899 (defun article-strip-blank-lines ()
1900 "Strip leading, trailing and multiple blank lines."
1902 (article-strip-leading-blank-lines)
1903 (article-remove-trailing-blank-lines)
1904 (article-strip-multiple-blank-lines))
1906 (defun article-strip-all-blank-lines ()
1907 "Strip all blank lines."
1910 (let ((inhibit-point-motion-hooks t)
1913 (while (re-search-forward "^[ \t]*\n" nil t)
1914 (replace-match "" t t)))))
1916 (defun gnus-article-narrow-to-signature ()
1917 "Narrow to the signature; return t if a signature is found, else nil."
1918 (let ((inhibit-point-motion-hooks t))
1919 (when (gnus-article-search-signature)
1921 ;; Check whether we have some limits to what we consider
1922 ;; to be a signature.
1923 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
1924 (list gnus-signature-limit)))
1926 (while (setq limit (pop limits))
1927 (if (or (and (integerp limit)
1928 (< (- (point-max) (point)) limit))
1930 (< (count-lines (point) (point-max)) limit))
1931 (and (gnus-functionp limit)
1933 (and (stringp limit)
1934 (not (re-search-forward limit nil t))))
1935 () ; This limit did not succeed.
1939 (narrow-to-region (point) (point-max))
1942 (defun gnus-article-search-signature ()
1943 "Search the current buffer for the signature separator.
1944 Put point at the beginning of the signature separator."
1945 (let ((cur (point)))
1946 (goto-char (point-max))
1947 (if (if (stringp gnus-signature-separator)
1948 (re-search-backward gnus-signature-separator nil t)
1949 (let ((seps gnus-signature-separator))
1951 (not (re-search-backward (car seps) nil t)))
1958 (defun gnus-article-hidden-arg ()
1959 "Return the current prefix arg as a number, or 0 if no prefix."
1960 (list (if current-prefix-arg
1961 (prefix-numeric-value current-prefix-arg)
1964 (defun gnus-article-check-hidden-text (type arg)
1965 "Return nil if hiding is necessary.
1966 Arg can be nil or a number. Nil and positive means hide, negative
1967 means show, 0 means toggle."
1970 (let ((hide (gnus-article-hidden-text-p type)))
1976 (gnus-article-show-hidden-text type)
1979 (if (eq hide 'hidden)
1981 (gnus-article-show-hidden-text type)
1985 (defun gnus-article-hidden-text-p (type)
1986 "Say whether the current buffer contains hidden text of type TYPE."
1987 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
1989 (not (get-text-property pos 'invisible))
1990 (not (get-text-property pos 'dummy-invisible)))
1992 (text-property-any (1+ pos) (point-max) 'article-type type)))
1997 (defun gnus-article-show-hidden-text (type &optional dummy)
1998 "Show all hidden text of type TYPE.
1999 Originally it is hide instead of DUMMY."
2000 (let ((buffer-read-only nil)
2001 (inhibit-point-motion-hooks t))
2002 (gnus-remove-text-properties-when
2004 (point-min) (point-max)
2005 (cons 'article-type (cons type
2006 gnus-hidden-properties)))))
2008 (defconst article-time-units
2009 `((year . ,(* 365.25 24 60 60))
2010 (week . ,(* 7 24 60 60))
2011 (day . ,(* 24 60 60))
2015 "Mapping from time units to seconds.")
2017 (defun article-date-ut (&optional type highlight header)
2018 "Convert DATE date to universal time in the current article.
2019 If TYPE is `local', convert to local time; if it is `lapsed', output
2020 how much time has lapsed since DATE. For `lapsed', the value of
2021 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2022 should replace the \"Date:\" one, or should be added below it."
2023 (interactive (list 'ut t))
2024 (let* ((header (or header
2025 (message-fetch-field "date")
2027 (tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2030 ((not gnus-article-date-lapsed-new-header)
2036 (date (if (vectorp header) (mail-header-date header)
2038 (inhibit-point-motion-hooks t)
2043 (article-narrow-to-head)
2044 (when (re-search-forward tdate-regexp nil t)
2045 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2046 date (or (get-text-property (gnus-point-at-bol)
2049 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
2051 (when (and date (not (string= date "")))
2052 (goto-char (point-min))
2053 (let ((buffer-read-only nil))
2054 ;; Delete any old Date headers.
2055 (while (re-search-forward date-regexp nil t)
2057 (delete-region (progn (beginning-of-line) (point))
2058 (progn (forward-line 1) (point)))
2059 (delete-region (progn (beginning-of-line) (point))
2060 (progn (end-of-line) (point)))
2061 (setq pos (point))))
2062 (when (and (not pos) (re-search-forward tdate-regexp nil t))
2064 (if pos (goto-char pos))
2065 (insert (article-make-date-line date (or type 'ut)))
2071 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2072 (put-text-property (match-beginning 1) (1+ (match-end 1))
2073 'original-date date)
2074 (put-text-property (match-beginning 1) (1+ (match-end 1))
2076 (put-text-property (match-beginning 2) (match-end 2)
2079 (defun article-make-date-line (date type)
2080 "Return a DATE line of TYPE."
2081 (let ((time (condition-case ()
2085 ;; Convert to the local timezone. We have to slap a
2086 ;; `condition-case' round the calls to the timezone
2087 ;; functions since they aren't particularly resistant to
2090 (let ((tz (car (current-time-zone time))))
2091 (format "Date: %s %s%02d%02d" (current-time-string time)
2092 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2093 (/ (% (abs tz) 3600) 60))))
2094 ;; Convert to Universal Time.
2097 (current-time-string
2098 (let* ((e (parse-time-string date))
2099 (tm (apply 'encode-time e))
2101 (ls (- (cadr tm) (car (current-time-zone time)))))
2102 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2103 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2106 ;; Get the original date from the article.
2107 ((eq type 'original)
2108 (concat "Date: " (if (string-match "\n+$" date)
2109 (substring date 0 (match-beginning 0))
2111 ;; Let the user define the format.
2113 (if (gnus-functionp gnus-article-time-format)
2114 (funcall gnus-article-time-format time)
2117 (format-time-string gnus-article-time-format time))))
2120 (let ((tz (car (current-time-zone time))))
2123 (format-time-string "%Y%m%dT%H%M%S" time)
2124 (format "%s%02d%02d"
2125 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2126 (/ (% (abs tz) 3600) 60)))))
2127 ;; Do an X-Sent lapsed format.
2129 ;; If the date is seriously mangled, the timezone functions are
2130 ;; liable to bug out, so we ignore all errors.
2131 (let* ((now (current-time))
2132 (real-time (subtract-time now time))
2133 (real-sec (and real-time
2134 (+ (* (float (car real-time)) 65536)
2136 (sec (and real-time (abs real-sec)))
2146 ;; This is a bit convoluted, but basically we go
2147 ;; through the time units for years, weeks, etc,
2148 ;; and divide things to see whether that results
2149 ;; in positive answers.
2152 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2153 ;; The (remaining) seconds are too few to
2154 ;; be divided into this time unit.
2156 ;; It's big enough, so we output it.
2157 (setq sec (- sec (* num (cdr unit))))
2159 (concat (if prev ", " "") (int-to-string
2161 " " (symbol-name (car unit))
2162 (if (> num 1) "s" ""))
2164 article-time-units "")
2165 ;; If dates are odd, then it might appear like the
2166 ;; article was sent in the future.
2169 " in the future"))))))
2171 (error "Unknown conversion type: %s" type)))))
2173 (defun article-date-local (&optional highlight)
2174 "Convert the current article date to the local timezone."
2175 (interactive (list t))
2176 (article-date-ut 'local highlight))
2178 (defun article-date-original (&optional highlight)
2179 "Convert the current article date to what it was originally.
2180 This is only useful if you have used some other date conversion
2181 function and want to see what the date was before converting."
2182 (interactive (list t))
2183 (article-date-ut 'original highlight))
2185 (defun article-date-lapsed (&optional highlight)
2186 "Convert the current article date to time lapsed since it was sent."
2187 (interactive (list t))
2188 (article-date-ut 'lapsed highlight))
2190 (defun article-update-date-lapsed ()
2191 "Function to be run from a timer to update the lapsed time line."
2192 (let (deactivate-mark)
2197 (set-buffer (window-buffer w))
2198 (when (eq major-mode 'gnus-article-mode)
2199 (goto-char (point-min))
2200 (when (re-search-forward "^X-Sent:" nil t)
2201 (article-date-lapsed t))))
2204 (defun gnus-start-date-timer (&optional n)
2205 "Start a timer to update the X-Sent header in the article buffers.
2206 The numerical prefix says how frequently (in seconds) the function
2211 (gnus-stop-date-timer)
2212 (setq article-lapsed-timer
2213 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2215 (defun gnus-stop-date-timer ()
2216 "Stop the X-Sent timer."
2218 (when article-lapsed-timer
2219 (nnheader-cancel-timer article-lapsed-timer)
2220 (setq article-lapsed-timer nil)))
2222 (defun article-date-user (&optional highlight)
2223 "Convert the current article date to the user-defined format.
2224 This format is defined by the `gnus-article-time-format' variable."
2225 (interactive (list t))
2226 (article-date-ut 'user highlight))
2228 (defun article-date-iso8601 (&optional highlight)
2229 "Convert the current article date to ISO8601."
2230 (interactive (list t))
2231 (article-date-ut 'iso8601 highlight))
2233 (defun article-show-all ()
2234 "Show all hidden text in the article buffer."
2237 (let ((buffer-read-only nil))
2238 (gnus-article-unhide-text (point-min) (point-max)))))
2240 (defun article-emphasize (&optional arg)
2241 "Emphasize text according to `gnus-emphasis-alist'."
2242 (interactive (gnus-article-hidden-arg))
2243 (unless (gnus-article-check-hidden-text 'emphasis arg)
2247 (with-current-buffer gnus-summary-buffer
2248 gnus-article-emphasis-alist)
2250 gnus-emphasis-alist))
2251 (buffer-read-only nil)
2252 (props (append '(article-type emphasis)
2253 gnus-hidden-properties))
2254 regexp elem beg invisible visible face)
2257 (while (setq elem (pop alist))
2259 (setq regexp (car elem)
2260 invisible (nth 1 elem)
2261 visible (nth 2 elem)
2263 (while (re-search-forward regexp nil t)
2264 (when (and (match-beginning visible) (match-beginning invisible))
2265 (push 'emphasis gnus-article-wash-types)
2266 (gnus-article-hide-text
2267 (match-beginning invisible) (match-end invisible) props)
2268 (gnus-article-unhide-text-type
2269 (match-beginning visible) (match-end visible) 'emphasis)
2270 (gnus-put-text-property-excluding-newlines
2271 (match-beginning visible) (match-end visible) 'face face)
2272 (goto-char (match-end invisible)))))))))
2274 (defun gnus-article-setup-highlight-words (&optional highlight-words)
2275 "Setup newsgroup emphasis alist."
2276 (unless gnus-article-emphasis-alist
2277 (let ((name (and gnus-newsgroup-name
2278 (gnus-group-real-name gnus-newsgroup-name))))
2279 (make-local-variable 'gnus-article-emphasis-alist)
2280 (setq gnus-article-emphasis-alist
2282 (let ((alist gnus-group-highlight-words-alist) elem highlight)
2283 (while (setq elem (pop alist))
2284 (when (and name (string-match (car elem) name))
2286 highlight (copy-sequence (cdr elem)))))
2288 (copy-sequence highlight-words)
2289 (if gnus-newsgroup-name
2290 (copy-sequence (gnus-group-find-parameter
2291 gnus-newsgroup-name 'highlight-words t)))
2292 gnus-emphasis-alist)))))
2295 (defvar gnus-summary-article-menu)
2296 (defvar gnus-summary-post-menu))
2298 ;;; Saving functions.
2300 (defun gnus-article-save (save-buffer file &optional num)
2301 "Save the currently selected article."
2302 (unless gnus-save-all-headers
2303 ;; Remove headers according to `gnus-saved-headers'.
2304 (let ((gnus-visible-headers
2305 (or gnus-saved-headers gnus-visible-headers))
2306 (gnus-article-buffer save-buffer))
2308 (set-buffer save-buffer)
2309 (article-hide-headers 1 t))))
2310 (save-window-excursion
2311 (if (not gnus-default-article-saver)
2312 (error "No default saver is defined")
2313 ;; !!! Magic! The saving functions all save
2314 ;; `gnus-save-article-buffer' (or so they think), but we
2315 ;; bind that variable to our save-buffer.
2316 (set-buffer gnus-article-buffer)
2317 (let* ((gnus-save-article-buffer save-buffer)
2320 ((not gnus-prompt-before-saving) 'default)
2321 ((eq gnus-prompt-before-saving 'always) nil)
2323 (gnus-number-of-articles-to-be-saved
2324 (when (eq gnus-prompt-before-saving t)
2326 (set-buffer gnus-article-current-summary)
2327 (funcall gnus-default-article-saver filename)))))
2329 (defun gnus-read-save-file-name (prompt &optional filename
2330 function group headers variable)
2332 (funcall function group headers (symbol-value variable)))
2337 ((eq filename 'default)
2343 (let* ((split-name (gnus-get-split-value gnus-split-methods))
2346 (if (and gnus-number-of-articles-to-be-saved
2347 (> gnus-number-of-articles-to-be-saved 1))
2348 (format "these %d articles"
2349 gnus-number-of-articles-to-be-saved)
2352 ;; Let the split methods have their say.
2354 ;; No split name was found.
2357 (concat prompt " (default "
2358 (file-name-nondirectory default-name) ") ")
2359 (file-name-directory default-name)
2361 ;; A single group name is returned.
2362 ((stringp split-name)
2364 (funcall function split-name headers
2365 (symbol-value variable)))
2367 (concat prompt " (default "
2368 (file-name-nondirectory default-name) ") ")
2369 (file-name-directory default-name)
2371 ;; A single split name was found
2372 ((= 1 (length split-name))
2373 (let* ((name (expand-file-name
2374 (car split-name) gnus-article-save-directory))
2375 (dir (cond ((file-directory-p name)
2376 (file-name-as-directory name))
2377 ((file-exists-p name) name)
2378 (t gnus-article-save-directory))))
2380 (concat prompt " (default " name ") ")
2382 ;; A list of splits was found.
2384 (setq split-name (nreverse split-name))
2386 (let ((file-name-history
2387 (nconc split-name file-name-history)))
2391 (concat prompt " (`M-p' for defaults) ")
2392 gnus-article-save-directory
2394 gnus-article-save-directory)))
2395 (car (push result file-name-history)))))))
2396 ;; Create the directory.
2397 (gnus-make-directory (file-name-directory file))
2398 ;; If we have read a directory, we append the default file name.
2399 (when (file-directory-p file)
2400 (setq file (expand-file-name (file-name-nondirectory default-name)
2401 (file-name-as-directory file))))
2402 ;; Possibly translate some characters.
2403 (nnheader-translate-file-chars file))))))
2404 (gnus-make-directory (file-name-directory result))
2405 (set variable result)))
2407 (defun gnus-article-archive-name (group)
2408 "Return the first instance of an \"Archive-name\" in the current buffer."
2409 (let ((case-fold-search t))
2410 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
2411 (nnheader-concat gnus-article-save-directory
2412 (match-string 1)))))
2414 (defun gnus-article-nndoc-name (group)
2415 "If GROUP is an nndoc group, return the name of the parent group."
2416 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
2417 (gnus-group-get-parameter group 'save-article-group)))
2419 (defun gnus-summary-save-in-rmail (&optional filename)
2420 "Append this article to Rmail file.
2421 Optional argument FILENAME specifies file name.
2422 Directory to save to is default to `gnus-article-save-directory'."
2423 (setq filename (gnus-read-save-file-name
2424 "Save %s in rmail file:" filename
2425 gnus-rmail-save-name gnus-newsgroup-name
2426 gnus-current-headers 'gnus-newsgroup-last-rmail))
2427 (gnus-eval-in-buffer-window gnus-save-article-buffer
2431 (gnus-output-to-rmail filename))))
2434 (defun gnus-summary-save-in-mail (&optional filename)
2435 "Append this article to Unix mail file.
2436 Optional argument FILENAME specifies file name.
2437 Directory to save to is default to `gnus-article-save-directory'."
2438 (setq filename (gnus-read-save-file-name
2439 "Save %s in Unix mail file:" filename
2440 gnus-mail-save-name gnus-newsgroup-name
2441 gnus-current-headers 'gnus-newsgroup-last-mail))
2442 (gnus-eval-in-buffer-window gnus-save-article-buffer
2446 (if (and (file-readable-p filename)
2447 (mail-file-babyl-p filename))
2448 (rmail-output-to-rmail-file filename t)
2449 (gnus-output-to-mail filename)))))
2452 (defun gnus-summary-save-in-file (&optional filename overwrite)
2453 "Append this article to file.
2454 Optional argument FILENAME specifies file name.
2455 Directory to save to is default to `gnus-article-save-directory'."
2456 (setq filename (gnus-read-save-file-name
2457 "Save %s 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 (and overwrite
2465 (file-exists-p filename))
2466 (delete-file filename))
2467 (gnus-output-to-file filename))))
2470 (defun gnus-summary-write-to-file (&optional filename)
2471 "Write this article to a file.
2472 Optional argument FILENAME specifies file name.
2473 The directory to save in defaults to `gnus-article-save-directory'."
2474 (gnus-summary-save-in-file nil t))
2476 (defun gnus-summary-save-body-in-file (&optional filename)
2477 "Append this article body to a file.
2478 Optional argument FILENAME specifies file name.
2479 The directory to save in defaults to `gnus-article-save-directory'."
2480 (setq filename (gnus-read-save-file-name
2481 "Save %s body in file:" filename
2482 gnus-file-save-name gnus-newsgroup-name
2483 gnus-current-headers 'gnus-newsgroup-last-file))
2484 (gnus-eval-in-buffer-window gnus-save-article-buffer
2488 (when (article-goto-body)
2489 (narrow-to-region (point) (point-max)))
2490 (gnus-output-to-file filename))))
2493 (defun gnus-summary-save-in-pipe (&optional command)
2494 "Pipe this article to subprocess."
2496 (cond ((and (eq command 'default)
2497 gnus-last-shell-command)
2498 gnus-last-shell-command)
2503 "Shell command on %s: "
2504 (if (and gnus-number-of-articles-to-be-saved
2505 (> gnus-number-of-articles-to-be-saved 1))
2506 (format "these %d articles"
2507 gnus-number-of-articles-to-be-saved)
2509 gnus-last-shell-command))))
2510 (when (string-equal command "")
2511 (if gnus-last-shell-command
2512 (setq command gnus-last-shell-command)
2513 (error "A command is required")))
2514 (gnus-eval-in-buffer-window gnus-article-buffer
2517 (shell-command-on-region (point-min) (point-max) command nil)))
2518 (setq gnus-last-shell-command command))
2520 ;;; Article file names when saving.
2522 (defun gnus-capitalize-newsgroup (newsgroup)
2523 "Capitalize NEWSGROUP name."
2524 (when (not (zerop (length newsgroup)))
2525 (concat (char-to-string (upcase (aref newsgroup 0)))
2526 (substring newsgroup 1))))
2528 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2529 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2530 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
2531 Otherwise, it is like ~/News/news/group/num."
2534 (concat (if (gnus-use-long-file-name 'not-save)
2535 (gnus-capitalize-newsgroup newsgroup)
2536 (gnus-newsgroup-directory-form newsgroup))
2537 "/" (int-to-string (mail-header-number headers)))
2538 gnus-article-save-directory)))
2540 (string-equal (file-name-directory default)
2541 (file-name-directory last-file))
2542 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2544 (or last-file default))))
2546 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2547 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2548 If variable `gnus-use-long-file-name' is non-nil, it is
2549 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2552 (concat (if (gnus-use-long-file-name 'not-save)
2554 (gnus-newsgroup-directory-form newsgroup))
2555 "/" (int-to-string (mail-header-number headers)))
2556 gnus-article-save-directory)))
2558 (string-equal (file-name-directory default)
2559 (file-name-directory last-file))
2560 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2562 (or last-file default))))
2564 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2565 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2566 If variable `gnus-use-long-file-name' is non-nil, it is
2567 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2570 (if (gnus-use-long-file-name 'not-save)
2572 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup)))
2573 gnus-article-save-directory)))
2580 (setq afunc (car func)
2583 gfunc (intern (format "gnus-%s" func))))
2586 `(lambda (&optional interactive &rest args)
2587 ,(documentation afunc t)
2588 (interactive (list t))
2590 (set-buffer gnus-article-buffer)
2592 (call-interactively ',afunc)
2593 (apply ',afunc args))))))))
2594 '(article-hide-headers
2595 article-hide-boring-headers
2596 article-treat-overstrike
2597 article-fill-long-lines
2598 article-capitalize-sentences
2600 article-display-x-face
2601 article-de-quoted-unreadable
2602 article-de-base64-unreadable
2605 article-hide-list-identifiers
2607 article-strip-banner
2610 article-hide-signature
2611 article-strip-headers-in-body
2612 article-remove-trailing-blank-lines
2613 article-strip-leading-blank-lines
2614 article-strip-multiple-blank-lines
2615 article-strip-leading-space
2616 article-strip-trailing-space
2617 article-strip-blank-lines
2618 article-strip-all-blank-lines
2620 article-date-iso8601
2621 article-date-original
2623 article-decode-mime-words
2624 article-decode-charset
2625 article-decode-encoded-words
2629 article-treat-dumbquotes
2630 article-normalize-headers
2631 (article-show-all . gnus-article-show-all-headers))))
2634 ;;; Gnus article mode
2637 (put 'gnus-article-mode 'mode-class 'special)
2639 (set-keymap-parent gnus-article-mode-map widget-keymap)
2641 (gnus-define-keys gnus-article-mode-map
2642 " " gnus-article-goto-next-page
2643 "\177" gnus-article-goto-prev-page
2644 [delete] gnus-article-goto-prev-page
2645 [backspace] gnus-article-goto-prev-page
2646 "\C-c^" gnus-article-refer-article
2647 "h" gnus-article-show-summary
2648 "s" gnus-article-show-summary
2649 "\C-c\C-m" gnus-article-mail
2650 "?" gnus-article-describe-briefly
2651 "e" gnus-summary-edit-article
2652 "<" beginning-of-buffer
2654 "\C-c\C-i" gnus-info-find-node
2656 "\C-hk" gnus-article-describe-key
2657 "\C-hc" gnus-article-describe-key-briefly
2659 "\C-d" gnus-article-read-summary-keys
2660 "\M-*" gnus-article-read-summary-keys
2661 "\M-#" gnus-article-read-summary-keys
2662 "\M-^" gnus-article-read-summary-keys
2663 "\M-g" gnus-article-read-summary-keys)
2665 (substitute-key-definition
2666 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
2668 (defvar gnus-article-post-menu nil)
2670 (defun gnus-article-make-menu-bar ()
2671 (gnus-turn-off-edit-menu 'article)
2672 (unless (boundp 'gnus-article-article-menu)
2674 gnus-article-article-menu gnus-article-mode-map ""
2676 ["Scroll forwards" gnus-article-goto-next-page t]
2677 ["Scroll backwards" gnus-article-goto-prev-page t]
2678 ["Show summary" gnus-article-show-summary t]
2679 ["Fetch Message-ID at point" gnus-article-refer-article t]
2680 ["Mail to address at point" gnus-article-mail t]
2681 ["Send a bug report" gnus-bug t]))
2684 gnus-article-treatment-menu gnus-article-mode-map ""
2685 ;; Fixme: this should use :active (and maybe :visible).
2687 ["Hide headers" gnus-article-hide-headers t]
2688 ["Hide signature" gnus-article-hide-signature t]
2689 ["Hide citation" gnus-article-hide-citation t]
2690 ["Treat overstrike" gnus-article-treat-overstrike t]
2691 ["Remove carriage return" gnus-article-remove-cr t]
2692 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
2693 ["Remove base64" gnus-article-de-base64-unreadable t]
2694 ["Treat html" gnus-article-wash-html t]
2695 ["Decode HZ" gnus-article-decode-HZ t]))
2697 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
2699 (when (boundp 'gnus-summary-post-menu)
2701 ((not (keymapp gnus-summary-post-menu))
2702 (setq gnus-article-post-menu gnus-summary-post-menu))
2703 ((not gnus-article-post-menu)
2704 ;; Don't share post menu.
2705 (setq gnus-article-post-menu
2706 (copy-keymap gnus-summary-post-menu))))
2707 (define-key gnus-article-mode-map [menu-bar post]
2708 (cons "Post" gnus-article-post-menu)))
2710 (gnus-run-hooks 'gnus-article-menu-hook)))
2712 ;; Fixme: do something for the Emacs tool bar in Article mode a la
2715 (defun gnus-article-mode ()
2716 "Major mode for displaying an article.
2718 All normal editing commands are switched off.
2720 The following commands are available in addition to all summary mode
2722 \\<gnus-article-mode-map>
2723 \\[gnus-article-next-page]\t Scroll the article one page forwards
2724 \\[gnus-article-prev-page]\t Scroll the article one page backwards
2725 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
2726 \\[gnus-article-show-summary]\t Display the summary buffer
2727 \\[gnus-article-mail]\t Send a reply to the address near point
2728 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
2729 \\[gnus-info-find-node]\t Go to the Gnus info node"
2731 (gnus-simplify-mode-line)
2732 (setq mode-name "Article")
2733 (setq major-mode 'gnus-article-mode)
2734 (make-local-variable 'minor-mode-alist)
2735 (use-local-map gnus-article-mode-map)
2736 (when (gnus-visual-p 'article-menu 'menu)
2737 (gnus-article-make-menu-bar))
2738 (gnus-update-format-specifications nil 'article-mode)
2739 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
2740 (make-local-variable 'gnus-page-broken)
2741 (make-local-variable 'gnus-button-marker-list)
2742 (make-local-variable 'gnus-article-current-summary)
2743 (make-local-variable 'gnus-article-mime-handles)
2744 (make-local-variable 'gnus-article-decoded-p)
2745 (make-local-variable 'gnus-article-mime-handle-alist)
2746 (make-local-variable 'gnus-article-wash-types)
2747 (gnus-set-default-directory)
2748 (buffer-disable-undo)
2749 (setq buffer-read-only t)
2750 (set-syntax-table gnus-article-mode-syntax-table)
2751 (mm-enable-multibyte)
2752 (gnus-run-hooks 'gnus-article-mode-hook))
2754 (defun gnus-article-setup-buffer ()
2755 "Initialize the article buffer."
2756 (let* ((name (if gnus-single-article-buffer "*Article*"
2757 (concat "*Article " gnus-newsgroup-name "*")))
2759 (progn (string-match "\\*Article" name)
2760 (concat " *Original Article"
2761 (substring name (match-end 0))))))
2762 (setq gnus-article-buffer name)
2763 (setq gnus-original-article-buffer original)
2764 (setq gnus-article-mime-handle-alist nil)
2765 ;; This might be a variable local to the summary buffer.
2766 (unless gnus-single-article-buffer
2768 (set-buffer gnus-summary-buffer)
2769 (setq gnus-article-buffer name)
2770 (setq gnus-original-article-buffer original)
2771 (gnus-set-global-variables)))
2772 (gnus-article-setup-highlight-words)
2773 ;; Init original article buffer.
2775 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
2776 (mm-enable-multibyte)
2777 (setq major-mode 'gnus-original-article-mode)
2778 (make-local-variable 'gnus-original-article))
2779 (if (get-buffer name)
2782 (when gnus-article-mime-handles
2783 (mm-destroy-parts gnus-article-mime-handles)
2784 (setq gnus-article-mime-handles nil))
2785 ;; Set it to nil in article-buffer!
2786 (setq gnus-article-mime-handle-alist nil)
2787 (buffer-disable-undo)
2788 (setq buffer-read-only t)
2789 (unless (eq major-mode 'gnus-article-mode)
2790 (gnus-article-mode))
2793 (set-buffer (gnus-get-buffer-create name))
2795 (make-local-variable 'gnus-summary-buffer)
2796 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2797 (current-buffer)))))
2799 ;; Set article window start at LINE, where LINE is the number of lines
2800 ;; from the head of the article.
2801 (defun gnus-article-set-window-start (&optional line)
2803 (get-buffer-window gnus-article-buffer t)
2805 (set-buffer gnus-article-buffer)
2806 (goto-char (point-min))
2809 (gnus-message 6 "Moved to bookmark")
2810 (search-forward "\n\n" nil t)
2814 (defun gnus-article-prepare (article &optional all-headers header)
2815 "Prepare ARTICLE in article mode buffer.
2816 ARTICLE should either be an article number or a Message-ID.
2817 If ARTICLE is an id, HEADER should be the article headers.
2818 If ALL-HEADERS is non-nil, no headers are hidden."
2820 ;; Make sure we start in a summary buffer.
2821 (unless (eq major-mode 'gnus-summary-mode)
2822 (set-buffer gnus-summary-buffer))
2823 (setq gnus-summary-buffer (current-buffer))
2824 (let* ((gnus-article (if header (mail-header-number header) article))
2825 (summary-buffer (current-buffer))
2826 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
2827 (group gnus-newsgroup-name)
2830 (gnus-article-setup-buffer)
2831 (set-buffer gnus-article-buffer)
2832 ;; Deactivate active regions.
2833 (when (and (boundp 'transient-mark-mode)
2834 transient-mark-mode)
2835 (setq mark-active nil))
2836 (if (not (setq result (let ((buffer-read-only nil))
2837 (gnus-request-article-this-buffer
2839 ;; There is no such article.
2841 (when (and (numberp article)
2842 (not (memq article gnus-newsgroup-sparse)))
2843 (setq gnus-article-current
2844 (cons gnus-newsgroup-name article))
2845 (set-buffer gnus-summary-buffer)
2846 (setq gnus-current-article article)
2847 (if (eq (gnus-article-mark article) gnus-undownloaded-mark)
2849 (gnus-summary-set-agent-mark article)
2850 (message "Message marked for downloading"))
2851 (gnus-summary-mark-article article gnus-canceled-mark)
2852 (unless (memq article gnus-newsgroup-sparse)
2853 (gnus-error 1 "No such article (may have expired or been canceled)")))))
2854 (if (or (eq result 'pseudo)
2855 (eq result 'nneething))
2858 (set-buffer summary-buffer)
2859 (push article gnus-newsgroup-history)
2860 (setq gnus-last-article gnus-current-article
2861 gnus-current-article 0
2862 gnus-current-headers nil
2863 gnus-article-current nil)
2864 (if (eq result 'nneething)
2865 (gnus-configure-windows 'summary)
2866 (gnus-configure-windows 'article))
2867 (gnus-set-global-variables))
2868 (let ((gnus-article-mime-handle-alist-1
2869 gnus-article-mime-handle-alist))
2870 (gnus-set-mode-line 'article)))
2871 ;; The result from the `request' was an actual article -
2872 ;; or at least some text that is now displayed in the
2874 (when (and (numberp article)
2875 (not (eq article gnus-current-article)))
2876 ;; Seems like a new article has been selected.
2877 ;; `gnus-current-article' must be an article number.
2879 (set-buffer summary-buffer)
2880 (push article gnus-newsgroup-history)
2881 (setq gnus-last-article gnus-current-article
2882 gnus-current-article article
2883 gnus-current-headers
2884 (gnus-summary-article-header gnus-current-article)
2885 gnus-article-current
2886 (cons gnus-newsgroup-name gnus-current-article))
2887 (unless (vectorp gnus-current-headers)
2888 (setq gnus-current-headers nil))
2889 (gnus-summary-goto-subject gnus-current-article)
2890 (when (gnus-summary-show-thread)
2891 ;; If the summary buffer really was folded, the
2892 ;; previous goto may not actually have gone to
2893 ;; the right article, but the thread root instead.
2895 (gnus-summary-goto-subject gnus-current-article))
2896 (gnus-run-hooks 'gnus-mark-article-hook)
2897 (gnus-set-mode-line 'summary)
2898 (when (gnus-visual-p 'article-highlight 'highlight)
2899 (gnus-run-hooks 'gnus-visual-mark-article-hook))
2900 ;; Set the global newsgroup variables here.
2901 (gnus-set-global-variables)
2902 (setq gnus-have-all-headers
2903 (or all-headers gnus-show-all-headers))))
2905 (gnus-configure-windows 'article))
2906 (when (or (numberp article)
2908 (gnus-article-prepare-display)
2910 (goto-char (point-min))
2911 (setq gnus-page-broken
2912 (when gnus-break-pages
2913 (gnus-narrow-to-page)
2915 (let ((gnus-article-mime-handle-alist-1
2916 gnus-article-mime-handle-alist))
2917 (gnus-set-mode-line 'article))
2919 (set-window-point (get-buffer-window (current-buffer)) (point))
2920 (gnus-configure-windows 'article)
2924 (defun gnus-article-prepare-display ()
2925 "Make the current buffer look like a nice article."
2926 ;; Hooks for getting information from the article.
2927 ;; This hook must be called before being narrowed.
2928 (let ((gnus-article-buffer (current-buffer))
2930 (unless (eq major-mode 'gnus-article-mode)
2931 (gnus-article-mode))
2932 (setq buffer-read-only nil
2933 gnus-article-wash-types nil)
2934 (gnus-run-hooks 'gnus-tmp-internal-hook)
2935 (when gnus-display-mime-function
2936 (funcall gnus-display-mime-function))
2937 (gnus-run-hooks 'gnus-article-prepare-hook)))
2940 ;;; Gnus MIME viewing functions
2943 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
2944 "The following specs can be used:
2946 %T MIME type, along with additional info
2947 %n The `name' parameter
2948 %d The description, if any
2949 %l The length of the encoded part
2950 %p The part identifier number
2951 %e Dots if the part isn't displayed")
2953 (defvar gnus-mime-button-line-format-alist
2954 '((?t gnus-tmp-type ?s)
2955 (?T gnus-tmp-type-long ?s)
2956 (?n gnus-tmp-name ?s)
2957 (?d gnus-tmp-description ?s)
2959 (?l gnus-tmp-length ?d)
2960 (?e gnus-tmp-dots ?s)))
2962 (defvar gnus-mime-button-commands
2963 '((gnus-article-press-button "\r" "Toggle Display")
2964 (gnus-mime-view-part "v" "View Interactively...")
2965 (gnus-mime-view-part-as-type "t" "View As Type...")
2966 (gnus-mime-save-part "o" "Save...")
2967 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
2968 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
2969 (gnus-mime-internalize-part "E" "View Internally")
2970 (gnus-mime-externalize-part "e" "View Externally")
2971 (gnus-mime-pipe-part "|" "Pipe To Command...")
2972 (gnus-mime-action-on-part "." "Take action on the part")))
2974 (defun gnus-article-mime-part-status ()
2975 (if gnus-article-mime-handle-alist-1
2976 (format " (%d parts)" (length gnus-article-mime-handle-alist-1))
2979 (defvar gnus-mime-button-map
2980 (let ((map (make-sparse-keymap)))
2981 ;; Not for Emacs 21: fixme better.
2982 ;; (set-keymap-parent map gnus-article-mode-map)
2983 (define-key map gnus-mouse-2 'gnus-article-push-button)
2984 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
2985 (dolist (c gnus-mime-button-commands)
2986 (define-key map (cadr c) (car c)))
2989 (defun gnus-mime-button-menu (event)
2990 "Construct a context-sensitive menu of MIME commands."
2993 (mouse-set-point event)
2994 (gnus-article-check-buffer)
2995 (let ((response (x-popup-menu
2997 ("" ,@(mapcar (lambda (c)
2998 (cons (caddr c) (car c)))
2999 gnus-mime-button-commands))))))
3001 (call-interactively response)))))
3003 (defun gnus-mime-view-all-parts (&optional handles)
3004 "View all the MIME parts."
3006 (save-current-buffer
3007 (set-buffer gnus-article-buffer)
3008 (let ((handles (or handles gnus-article-mime-handles))
3009 (mail-parse-charset gnus-newsgroup-charset)
3010 (mail-parse-ignored-charsets
3011 (save-excursion (set-buffer gnus-summary-buffer)
3012 gnus-newsgroup-ignored-charsets)))
3013 (if (stringp (car handles))
3014 (gnus-mime-view-all-parts (cdr handles))
3015 (mapcar 'mm-display-part handles)))))
3017 (defun gnus-mime-save-part ()
3018 "Save the MIME part under point."
3020 (gnus-article-check-buffer)
3021 (let ((data (get-text-property (point) 'gnus-data)))
3022 (mm-save-part data)))
3024 (defun gnus-mime-pipe-part ()
3025 "Pipe the MIME part under point to a process."
3027 (gnus-article-check-buffer)
3028 (let ((data (get-text-property (point) 'gnus-data)))
3029 (mm-pipe-part data)))
3031 (defun gnus-mime-view-part ()
3032 "Interactively choose a viewing method for the MIME part under point."
3034 (gnus-article-check-buffer)
3035 (let ((data (get-text-property (point) 'gnus-data)))
3036 (push (setq data (copy-sequence data)) gnus-article-mime-handles)
3037 (mm-interactively-view-part data)))
3039 (defun gnus-mime-view-part-as-type-internal ()
3040 (gnus-article-check-buffer)
3041 (let* ((name (mail-content-type-get
3042 (mm-handle-type (get-text-property (point) 'gnus-data))
3044 (def-type (and name (mm-default-file-encoding name))))
3045 (and def-type (cons def-type 0))))
3047 (defun gnus-mime-view-part-as-type (mime-type)
3048 "Choose a MIME media type, and view the part as such."
3050 (list (completing-read
3051 "View as MIME type: "
3052 (mapcar #'list (mailcap-mime-types))
3054 (gnus-mime-view-part-as-type-internal))))
3055 (gnus-article-check-buffer)
3056 (let ((handle (get-text-property (point) 'gnus-data)))
3057 (gnus-mm-display-part
3058 (mm-make-handle (mm-handle-buffer handle)
3059 (cons mime-type (cdr (mm-handle-type handle)))
3060 (mm-handle-encoding handle)
3061 (mm-handle-undisplayer handle)
3062 (mm-handle-disposition handle)
3063 (mm-handle-description handle)
3064 (mm-handle-cache handle)
3065 (mm-handle-id handle)))))
3067 (defun gnus-mime-copy-part (&optional handle)
3068 "Put the the MIME part under point into a new buffer."
3070 (gnus-article-check-buffer)
3071 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3072 (contents (mm-get-part handle))
3073 (base (file-name-nondirectory
3075 (mail-content-type-get (mm-handle-type handle) 'name)
3076 (mail-content-type-get (mm-handle-type handle)
3079 (buffer (generate-new-buffer base)))
3080 (switch-to-buffer buffer)
3082 ;; We do it this way to make `normal-mode' set the appropriate mode.
3085 (setq buffer-file-name (expand-file-name base))
3087 (setq buffer-file-name nil))
3088 (goto-char (point-min))))
3090 (defun gnus-mime-inline-part (&optional handle arg)
3091 "Insert the MIME part under point into the current buffer."
3092 (interactive (list nil current-prefix-arg))
3093 (gnus-article-check-buffer)
3094 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3098 (if (mm-handle-undisplayer handle)
3099 (mm-remove-part handle)
3100 (setq contents (mm-get-part handle))
3103 (setq charset (or (mail-content-type-get
3104 (mm-handle-type handle) 'charset)
3105 gnus-newsgroup-charset)))
3109 gnus-summary-show-article-charset-alist))
3110 (read-coding-system "Charset: ")))))
3112 (mm-insert-inline handle
3114 (setq charset (mm-charset-to-coding-system
3116 (not (eq charset 'ascii)))
3117 (mm-decode-coding-string contents charset)
3121 (defun gnus-mime-externalize-part (&optional handle)
3122 "View the MIME part under point with an external viewer."
3124 (gnus-article-check-buffer)
3125 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3126 (mm-user-display-methods nil)
3127 (mm-inlined-types nil)
3128 (mail-parse-charset gnus-newsgroup-charset)
3129 (mail-parse-ignored-charsets
3130 (save-excursion (set-buffer gnus-summary-buffer)
3131 gnus-newsgroup-ignored-charsets)))
3132 (if (mm-handle-undisplayer handle)
3133 (mm-remove-part handle)
3134 (mm-display-part handle))))
3136 (defun gnus-mime-internalize-part (&optional handle)
3137 "View the MIME part under point with an internal viewer.
3138 In no internal viewer is available, use an external viewer."
3140 (gnus-article-check-buffer)
3141 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3142 (mm-inlined-types '(".*"))
3143 (mm-inline-large-images t)
3144 (mail-parse-charset gnus-newsgroup-charset)
3145 (mail-parse-ignored-charsets
3146 (save-excursion (set-buffer gnus-summary-buffer)
3147 gnus-newsgroup-ignored-charsets)))
3148 (if (mm-handle-undisplayer handle)
3149 (mm-remove-part handle)
3150 (mm-display-part handle))))
3152 (defun gnus-mime-action-on-part (&optional action)
3153 "Do something with the MIME attachment at \(point\)."
3155 (list (completing-read "Action: " gnus-mime-action-alist)))
3156 (gnus-article-check-buffer)
3157 (let ((action-pair (assoc action gnus-mime-action-alist)))
3159 (funcall (cdr action-pair)))))
3162 (defun gnus-article-part-wrapper (n function)
3163 (save-current-buffer
3164 (set-buffer gnus-article-buffer)
3165 (when (> n (length gnus-article-mime-handle-alist))
3166 (error "No such part"))
3167 (gnus-article-goto-part n)
3168 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
3169 (funcall function handle))))
3171 (defun gnus-article-pipe-part (n)
3172 "Pipe MIME part N, which is the numerical prefix."
3174 (gnus-article-part-wrapper n 'mm-pipe-part))
3176 (defun gnus-article-save-part (n)
3177 "Save MIME part N, which is the numerical prefix."
3179 (gnus-article-part-wrapper n 'mm-save-part))
3181 (defun gnus-article-interactively-view-part (n)
3182 "View MIME part N interactively, which is the numerical prefix."
3184 (gnus-article-part-wrapper n 'mm-interactively-view-part))
3186 (defun gnus-article-copy-part (n)
3187 "Copy MIME part N, which is the numerical prefix."
3189 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
3191 (defun gnus-article-externalize-part (n)
3192 "View MIME part N externally, which is the numerical prefix."
3194 (gnus-article-part-wrapper n 'gnus-mime-externalize-part))
3196 (defun gnus-article-inline-part (n)
3197 "Inline MIME part N, which is the numerical prefix."
3199 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
3201 (defun gnus-article-mime-match-handle-first (condition)
3203 (let ((alist gnus-article-mime-handle-alist) ihandle n)
3204 (while (setq ihandle (pop alist))
3206 ((functionp condition)
3207 (funcall condition (cdr ihandle)))
3208 ((eq condition 'undisplayed)
3209 (not (or (mm-handle-undisplayer (cdr ihandle))
3210 (equal (mm-handle-media-type (cdr ihandle))
3211 "multipart/alternative"))))
3212 ((eq condition 'undisplayed-alternative)
3213 (not (mm-handle-undisplayer (cdr ihandle))))
3215 (gnus-article-goto-part (car ihandle))
3216 (or (not n) (< (car ihandle) n)))
3217 (setq n (car ihandle))))
3221 (defun gnus-article-view-part (&optional n)
3222 "View MIME part N, which is the numerical prefix."
3224 (save-current-buffer
3225 (set-buffer gnus-article-buffer)
3226 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
3227 gnus-article-mime-match-handle-function)))
3228 (when (> n (length gnus-article-mime-handle-alist))
3229 (error "No such part"))
3230 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
3231 (when (gnus-article-goto-part n)
3232 (if (equal (car handle) "multipart/alternative")
3233 (gnus-article-press-button)
3234 (when (eq (gnus-mm-display-part handle) 'internal)
3235 (gnus-set-window-start)))))))
3237 (defsubst gnus-article-mime-total-parts ()
3238 (if (bufferp (car gnus-article-mime-handles))
3240 (1- (length gnus-article-mime-handles))))
3242 (defun gnus-mm-display-part (handle)
3243 "Display HANDLE and fix MIME button."
3244 (let ((id (get-text-property (point) 'gnus-part))
3249 (let ((window (selected-window))
3250 (mail-parse-charset gnus-newsgroup-charset)
3251 (mail-parse-ignored-charsets
3252 (save-excursion (set-buffer gnus-summary-buffer)
3253 gnus-newsgroup-ignored-charsets)))
3256 (let ((win (get-buffer-window (current-buffer) t))
3259 (select-window win))
3262 (if (mm-handle-displayed-p handle)
3263 ;; This will remove the part.
3264 (mm-display-part handle)
3266 (narrow-to-region (point) (1+ (point)))
3267 (mm-display-part handle)
3268 ;; We narrow to the part itself and
3269 ;; then call the treatment functions.
3270 (goto-char (point-min))
3272 (narrow-to-region (point) (point-max))
3275 (gnus-article-mime-total-parts)
3276 (mm-handle-media-type handle)))))
3277 (select-window window))))
3279 (delete-region (gnus-point-at-bol) (progn (forward-line 1) (point)))
3280 (gnus-insert-mime-button
3281 handle id (list (mm-handle-displayed-p handle)))
3282 (goto-char point))))
3284 (defun gnus-article-goto-part (n)
3285 "Go to MIME part N."
3286 (let ((point (text-property-any (point-min) (point-max) 'gnus-part n)))
3288 (goto-char point))))
3290 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
3291 (let ((gnus-tmp-name
3292 (or (mail-content-type-get (mm-handle-type handle)
3294 (mail-content-type-get (mm-handle-disposition handle)
3297 (gnus-tmp-type (mm-handle-media-type handle))
3298 (gnus-tmp-description
3299 (mail-decode-encoded-word-string (or (mm-handle-description handle)
3302 (if (if displayed (car displayed)
3303 (mm-handle-displayed-p handle))
3305 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
3307 gnus-tmp-type-long b e)
3308 (when (string-match ".*/" gnus-tmp-name)
3309 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
3310 (setq gnus-tmp-type-long (concat gnus-tmp-type
3311 (and (not (equal gnus-tmp-name ""))
3312 (concat "; " gnus-tmp-name))))
3313 (or (equal gnus-tmp-description "")
3314 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
3319 gnus-mime-button-line-format gnus-mime-button-line-format-alist
3320 `(keymap ,gnus-mime-button-map
3321 ;; Not for Emacs 21: fixme better.
3322 ;; local-map ,gnus-mime-button-map
3323 gnus-callback gnus-mm-display-part
3324 gnus-part ,gnus-tmp-id
3325 article-type annotation
3328 (widget-convert-button
3331 :action 'gnus-widget-press-button
3332 :button-keymap gnus-mime-button-map
3334 (lambda (widget/window &optional overlay pos)
3335 ;; Needed to properly clear the message due to a bug in
3336 ;; wid-edit (XEmacs only).
3337 (if (boundp 'help-echo-owns-message)
3338 (setq help-echo-owns-message t))
3340 "%S: %s the MIME part; %S: more options"
3341 (aref gnus-mouse-2 0)
3342 ;; XEmacs will get a single widget arg; Emacs 21 will get
3343 ;; window, overlay, position.
3344 (if (mm-handle-displayed-p
3346 (with-current-buffer (gnus-overlay-buffer overlay)
3347 (widget-get (widget-at (gnus-overlay-start overlay))
3349 (widget-get widget/window :mime-handle)))
3351 (aref gnus-down-mouse-3 0))))))
3353 (defun gnus-widget-press-button (elems el)
3354 (goto-char (widget-get elems :from))
3355 (gnus-article-press-button))
3357 (defvar gnus-displaying-mime nil)
3359 (defun gnus-display-mime (&optional ihandles)
3360 "Display the MIME parts."
3362 (save-selected-window
3363 (let ((window (get-buffer-window gnus-article-buffer))
3366 (select-window window)
3367 ;; We have to do this since selecting the window
3368 ;; may change the point. So we set the window point.
3369 (set-window-point window point)))
3370 (let* ((handles (or ihandles (mm-dissect-buffer) (mm-uu-dissect)))
3371 buffer-read-only handle name type b e display)
3372 (when (and (not ihandles)
3373 (not gnus-displaying-mime))
3374 ;; Top-level call; we clean up.
3375 (when gnus-article-mime-handles
3376 (mm-destroy-parts gnus-article-mime-handles)
3377 (setq gnus-article-mime-handle-alist nil));; A trick.
3378 (setq gnus-article-mime-handles handles)
3379 ;; We allow users to glean info from the handles.
3380 (when gnus-article-mime-part-function
3381 (gnus-mime-part-function handles)))
3383 (or (not (stringp (car handles)))
3386 (when (and (not ihandles)
3387 (not gnus-displaying-mime))
3388 ;; Clean up for mime parts.
3390 (delete-region (point) (point-max)))
3391 (let ((gnus-displaying-mime t))
3392 (gnus-mime-display-part handles)))
3395 (narrow-to-region (point) (point-max))
3396 (gnus-treat-article nil 1 1)
3399 ;; Highlight the headers.
3403 (narrow-to-region (point-min) (point))
3404 (gnus-treat-article 'head))))))))
3406 (defvar gnus-mime-display-multipart-as-mixed nil)
3408 (defun gnus-mime-display-part (handle)
3411 ((not (stringp (car handle)))
3412 (gnus-mime-display-single handle))
3413 ;; User-defined multipart
3414 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
3415 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
3417 ;; multipart/alternative
3418 ((and (equal (car handle) "multipart/alternative")
3419 (not gnus-mime-display-multipart-as-mixed))
3420 (let ((id (1+ (length gnus-article-mime-handle-alist))))
3421 (push (cons id handle) gnus-article-mime-handle-alist)
3422 (gnus-mime-display-alternative (cdr handle) nil nil id)))
3423 ;; multipart/related
3424 ((and (equal (car handle) "multipart/related")
3425 (not gnus-mime-display-multipart-as-mixed))
3426 ;;;!!!We should find the start part, but we just default
3427 ;;;!!!to the first part.
3428 (gnus-mime-display-part (cadr handle)))
3429 ;; Other multiparts are handled like multipart/mixed.
3431 (gnus-mime-display-mixed (cdr handle)))))
3433 (defun gnus-mime-part-function (handles)
3434 (if (stringp (car handles))
3435 (mapcar 'gnus-mime-part-function (cdr handles))
3436 (funcall gnus-article-mime-part-function handles)))
3438 (defun gnus-mime-display-mixed (handles)
3439 (mapcar 'gnus-mime-display-part handles))
3441 (defun gnus-mime-display-single (handle)
3442 (let ((type (mm-handle-media-type handle))
3443 (ignored gnus-ignored-mime-types)
3450 (when (string-match (pop ignored) type)
3451 (throw 'ignored nil)))
3452 (if (and (setq not-attachment
3453 (and (not (mm-inline-override-p handle))
3454 (or (not (mm-handle-disposition handle))
3455 (equal (car (mm-handle-disposition handle))
3457 (mm-attachment-override-p handle))))
3458 (mm-automatic-display-p handle)
3459 (or (mm-inlined-p handle)
3460 (mm-automatic-external-display-p type)))
3462 (when (equal (mm-handle-media-supertype handle) "text")
3464 (let ((id (1+ (length gnus-article-mime-handle-alist)))
3466 (push (cons id handle) gnus-article-mime-handle-alist)
3467 (when (or (not display)
3468 (not (gnus-unbuttonized-mime-type-p type)))
3469 ;(gnus-article-insert-newline)
3470 (gnus-insert-mime-button
3471 handle id (list (or display (and not-attachment text))))
3472 (gnus-article-insert-newline)
3473 ;(gnus-article-insert-newline)
3481 (let ((mail-parse-charset gnus-newsgroup-charset)
3482 (mail-parse-ignored-charsets
3483 (save-excursion (condition-case ()
3484 (set-buffer gnus-summary-buffer)
3486 gnus-newsgroup-ignored-charsets)))
3487 (mm-display-part handle t))
3488 (goto-char (point-max)))
3489 ((and text not-attachment)
3493 (gnus-article-insert-newline)
3494 (mm-insert-inline handle (mm-get-part handle))
3495 (goto-char (point-max))))
3499 (narrow-to-region beg (point))
3502 (gnus-article-mime-total-parts)
3503 (mm-handle-media-type handle)))))))))
3505 (defun gnus-unbuttonized-mime-type-p (type)
3506 "Say whether TYPE is to be unbuttonized."
3507 (unless gnus-inhibit-mime-unbuttonizing
3509 (let ((types gnus-unbuttonized-mime-types))
3511 (when (string-match (pop types) type)
3512 (throw 'found t)))))))
3514 (defun gnus-article-insert-newline ()
3515 "Insert a newline, but mark it as undeletable."
3516 (gnus-put-text-property
3517 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
3519 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
3520 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
3523 handle buffer-read-only from props begend not-pref)
3524 (save-window-excursion
3527 (narrow-to-region (car ibegend)
3530 (goto-char (car ibegend))
3533 (delete-region (point-min) (point-max))
3534 (mm-remove-parts handles))
3535 (setq begend (list (point-marker)))
3537 (unless (setq not-pref (cadr (member preferred ihandles)))
3538 (setq not-pref (car ihandles)))
3540 (not (gnus-unbuttonized-mime-type-p
3541 "multipart/alternative")))
3542 (gnus-add-text-properties
3545 (insert (format "%d. " id))
3549 (unless ,(not ibegend)
3550 (setq gnus-article-mime-handle-alist
3551 ',gnus-article-mime-handle-alist))
3552 (gnus-mime-display-alternative
3553 ',ihandles ',not-pref ',begend ,id))
3554 ;; Not for Emacs 21: fixme better.
3555 ;; local-map ,gnus-mime-button-map
3556 ,gnus-mouse-face-prop ,gnus-article-mouse-face
3557 face ,gnus-article-button-face
3558 keymap ,gnus-mime-button-map
3561 (widget-convert-button 'link from (point)
3562 :action 'gnus-widget-press-button
3563 :button-keymap gnus-widget-button-keymap)
3565 (while (setq handle (pop handles))
3566 (gnus-add-text-properties
3569 (insert (format "(%c) %-18s"
3570 (if (equal handle preferred) ?* ? )
3571 (mm-handle-media-type handle)))
3575 (unless ,(not ibegend)
3576 (setq gnus-article-mime-handle-alist
3577 ',gnus-article-mime-handle-alist))
3578 (gnus-mime-display-alternative
3579 ',ihandles ',handle ',begend ,id))
3580 ;; Not for Emacs 21: fixme better.
3581 ;; local-map ,gnus-mime-button-map
3582 ,gnus-mouse-face-prop ,gnus-article-mouse-face
3583 face ,gnus-article-button-face
3584 keymap ,gnus-mime-button-map
3587 (widget-convert-button 'link from (point)
3588 :action 'gnus-widget-press-button
3589 :button-keymap gnus-widget-button-keymap)
3593 (if (stringp (car preferred))
3594 (gnus-display-mime preferred)
3595 (let ((mail-parse-charset gnus-newsgroup-charset)
3596 (mail-parse-ignored-charsets
3597 (save-excursion (set-buffer gnus-summary-buffer)
3598 gnus-newsgroup-ignored-charsets)))
3599 (mm-display-part preferred)
3603 (narrow-to-region (car begend) (point-max))
3605 nil (length gnus-article-mime-handle-alist)
3606 (gnus-article-mime-total-parts)
3607 (mm-handle-media-type handle))))))
3608 (goto-char (point-max))
3609 (setcdr begend (point-marker)))))
3611 (goto-char point))))
3613 (defun gnus-article-wash-status ()
3614 "Return a string which display status of article washing."
3616 (set-buffer gnus-article-buffer)
3617 (let ((cite (memq 'cite gnus-article-wash-types))
3618 (headers (memq 'headers gnus-article-wash-types))
3619 (boring (memq 'boring-headers gnus-article-wash-types))
3620 (pgp (memq 'pgp gnus-article-wash-types))
3621 (pem (memq 'pem gnus-article-wash-types))
3622 (signature (memq 'signature gnus-article-wash-types))
3623 (overstrike (memq 'overstrike gnus-article-wash-types))
3624 (emphasis (memq 'emphasis gnus-article-wash-types)))
3625 (format "%c%c%c%c%c%c"
3627 (if (or headers boring) ?h ? )
3628 (if (or pgp pem) ?p ? )
3629 (if signature ?s ? )
3630 (if overstrike ?o ? )
3631 (if emphasis ?e ? )))))
3633 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
3635 (defun gnus-article-maybe-hide-headers ()
3636 "Hide unwanted headers if `gnus-have-all-headers' is nil.
3637 Provided for backwards compatibility."
3638 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
3639 (not (save-excursion (set-buffer gnus-summary-buffer)
3640 gnus-have-all-headers)))
3641 (not gnus-inhibit-hiding))
3642 (gnus-article-hide-headers)))
3646 (defun gnus-output-to-file (file-name)
3647 "Append the current article to a file named FILE-NAME."
3648 (let ((artbuf (current-buffer)))
3650 (insert-buffer-substring artbuf)
3651 ;; Append newline at end of the buffer as separator, and then
3653 (goto-char (point-max))
3655 (let ((file-name-coding-system nnmail-pathname-coding-system))
3656 (mm-append-to-file (point-min) (point-max) file-name))
3659 (defun gnus-narrow-to-page (&optional arg)
3660 "Narrow the article buffer to a page.
3661 If given a numerical ARG, move forward ARG pages."
3663 (setq arg (if arg (prefix-numeric-value arg) 0))
3665 (set-buffer gnus-article-buffer)
3666 (goto-char (point-min))
3668 ;; Remove any old next/prev buttons.
3669 (when (gnus-visual-p 'page-marker)
3670 (let ((buffer-read-only nil))
3671 (gnus-remove-text-with-property 'gnus-prev)
3672 (gnus-remove-text-with-property 'gnus-next)))
3675 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
3677 (re-search-forward page-delimiter nil 'move arg)))
3678 (goto-char (match-end 0)))
3681 (if (re-search-forward page-delimiter nil 'move)
3684 (when (and (gnus-visual-p 'page-marker)
3685 (not (= (point-min) 1)))
3687 (goto-char (point-min))
3688 (gnus-insert-prev-page-button)))
3689 (when (and (gnus-visual-p 'page-marker)
3690 (< (+ (point-max) 2) (buffer-size)))
3692 (goto-char (point-max))
3693 (gnus-insert-next-page-button)))))
3695 ;; Article mode commands
3697 (defun gnus-article-goto-next-page ()
3698 "Show the next page of the article."
3700 (when (gnus-article-next-page)
3701 (goto-char (point-min))
3702 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
3704 (defun gnus-article-goto-prev-page ()
3705 "Show the next page of the article."
3707 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
3708 (gnus-article-prev-page nil)))
3710 (defun gnus-article-next-page (&optional lines)
3711 "Show the next page of the current article.
3712 If end of article, return non-nil. Otherwise return nil.
3713 Argument LINES specifies lines to be scrolled up."
3715 (move-to-window-line -1)
3718 (and (pos-visible-in-window-p) ;Not continuation line.
3720 ;; Nothing in this page.
3721 (if (or (not gnus-page-broken)
3724 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
3726 (gnus-narrow-to-page 1) ;Go to next page.
3728 ;; More in this page.
3729 (let ((scroll-in-place nil))
3733 ;; Long lines may cause an end-of-buffer error.
3734 (goto-char (point-max)))))
3735 (move-to-window-line 0)
3738 (defun gnus-article-prev-page (&optional lines)
3739 "Show previous page of current article.
3740 Argument LINES specifies lines to be scrolled down."
3742 (move-to-window-line 0)
3743 (if (and gnus-page-broken
3745 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
3747 (gnus-narrow-to-page -1) ;Go to previous page.
3748 (goto-char (point-max))
3750 (let ((scroll-in-place nil))
3754 (beginning-of-buffer
3755 (goto-char (point-min))))
3756 (move-to-window-line 0)))))
3758 (defun gnus-article-refer-article ()
3759 "Read article specified by message-id around point."
3761 (let ((point (point)))
3762 (search-forward ">" nil t) ;Move point to end of "<....>".
3763 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
3764 (let ((message-id (match-string 1)))
3766 (set-buffer gnus-summary-buffer)
3767 (gnus-summary-refer-article message-id))
3769 (error "No references around point"))))
3771 (defun gnus-article-show-summary ()
3772 "Reconfigure windows to show summary buffer."
3774 (if (not (gnus-buffer-live-p gnus-summary-buffer))
3775 (error "There is no summary buffer for this article buffer")
3776 (gnus-article-set-globals)
3777 (gnus-configure-windows 'article)
3778 (gnus-summary-goto-subject gnus-current-article)
3779 (gnus-summary-position-point)))
3781 (defun gnus-article-describe-briefly ()
3782 "Describe article mode commands briefly."
3784 (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")))
3786 (defun gnus-article-summary-command ()
3787 "Execute the last keystroke in the summary buffer."
3789 (let ((obuf (current-buffer))
3790 (owin (current-window-configuration))
3792 (switch-to-buffer gnus-article-current-summary 'norecord)
3793 (setq func (lookup-key (current-local-map) (this-command-keys)))
3794 (call-interactively func)
3796 (set-window-configuration owin)
3797 (set-window-point (get-buffer-window (current-buffer)) (point))))
3799 (defun gnus-article-summary-command-nosave ()
3800 "Execute the last keystroke in the summary buffer."
3803 (pop-to-buffer gnus-article-current-summary 'norecord)
3804 (setq func (lookup-key (current-local-map) (this-command-keys)))
3805 (call-interactively func)))
3807 (defun gnus-article-check-buffer ()
3808 "Beep if not in an article buffer."
3809 (unless (equal major-mode 'gnus-article-mode)
3810 (error "Command invoked outside of a Gnus article buffer")))
3812 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
3813 "Read a summary buffer key sequence and execute it from the article buffer."
3815 (gnus-article-check-buffer)
3817 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
3818 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
3819 "=" "^" "\M-^" "|"))
3825 '("n" "Gn" "p" "Gp"))
3828 (set-buffer gnus-article-current-summary)
3829 (let (gnus-pick-mode)
3830 (push (or key last-command-event) unread-command-events)
3831 (setq keys (if (featurep 'xemacs)
3832 (events-to-keys (read-key-sequence nil))
3833 (read-key-sequence nil)))))
3837 (if (or (member keys nosaves)
3838 (member keys nosave-but-article)
3839 (member keys nosave-in-article))
3841 (save-window-excursion
3842 (pop-to-buffer gnus-article-current-summary 'norecord)
3843 ;; We disable the pick minor mode commands.
3844 (let (gnus-pick-mode)
3845 (setq func (lookup-key (current-local-map) keys))))
3849 (unless (member keys nosave-in-article)
3850 (set-buffer gnus-article-current-summary))
3851 (call-interactively func)
3852 (setq new-sum-point (point)))
3853 (when (member keys nosave-but-article)
3854 (pop-to-buffer gnus-article-buffer 'norecord)))
3855 ;; These commands should restore window configuration.
3856 (let ((obuf (current-buffer))
3857 (owin (current-window-configuration))
3859 (summary gnus-article-current-summary)
3860 func in-buffer selected)
3861 (if not-restore-window
3862 (pop-to-buffer summary 'norecord)
3863 (switch-to-buffer summary 'norecord))
3864 (setq in-buffer (current-buffer))
3865 ;; We disable the pick minor mode commands.
3866 (if (and (setq func (let (gnus-pick-mode)
3867 (lookup-key (current-local-map) keys)))
3870 (call-interactively func)
3871 (setq new-sum-point (point))
3872 (when (eq in-buffer (current-buffer))
3873 (setq selected (gnus-summary-select-article))
3875 (unless not-restore-window
3876 (set-window-configuration owin))
3877 (when (eq selected 'old)
3879 (set-window-start (get-buffer-window (current-buffer))
3881 (set-window-point (get-buffer-window (current-buffer))
3883 (let ((win (get-buffer-window gnus-article-current-summary)))
3885 (set-window-point win new-sum-point)))) )
3886 (switch-to-buffer gnus-article-buffer)
3889 (defun gnus-article-describe-key (key)
3890 "Display documentation of the function invoked by KEY. KEY is a string."
3891 (interactive "kDescribe key: ")
3892 (gnus-article-check-buffer)
3893 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
3895 (set-buffer gnus-article-current-summary)
3896 (let (gnus-pick-mode)
3897 (push (elt key 0) unread-command-events)
3898 (setq key (if (featurep 'xemacs)
3899 (events-to-keys (read-key-sequence "Describe key: "))
3900 (read-key-sequence "Describe key: "))))
3902 (describe-key key)))
3904 (defun gnus-article-describe-key-briefly (key &optional insert)
3905 "Display documentation of the function invoked by KEY. KEY is a string."
3906 (interactive "kDescribe key: \nP")
3907 (gnus-article-check-buffer)
3908 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
3910 (set-buffer gnus-article-current-summary)
3911 (let (gnus-pick-mode)
3912 (push (elt key 0) unread-command-events)
3913 (setq key (if (featurep 'xemacs)
3914 (events-to-keys (read-key-sequence "Describe key: "))
3915 (read-key-sequence "Describe key: "))))
3916 (describe-key-briefly key insert))
3917 (describe-key-briefly key insert)))
3919 (defun gnus-article-hide (&optional arg force)
3920 "Hide all the gruft in the current article.
3921 This means that PGP stuff, signatures, cited text and (some)
3922 headers will be hidden.
3923 If given a prefix, show the hidden text instead."
3924 (interactive (append (gnus-article-hidden-arg) (list 'force)))
3925 (gnus-article-hide-headers arg)
3926 (gnus-article-hide-list-identifiers arg)
3927 (gnus-article-hide-pgp arg)
3928 (gnus-article-hide-citation-maybe arg force)
3929 (gnus-article-hide-signature arg))
3931 (defun gnus-article-maybe-highlight ()
3932 "Do some article highlighting if article highlighting is requested."
3933 (when (gnus-visual-p 'article-highlight 'highlight)
3934 (gnus-article-highlight-some)))
3936 (defun gnus-check-group-server ()
3937 ;; Make sure the connection to the server is alive.
3938 (unless (gnus-server-opened
3939 (gnus-find-method-for-group gnus-newsgroup-name))
3940 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
3941 (gnus-request-group gnus-newsgroup-name t)))
3943 (defun gnus-request-article-this-buffer (article group)
3944 "Get an article and insert it into this buffer."
3945 (let (do-update-line sparse-header)
3949 (gnus-kill-all-overlays)
3950 (setq group (or group gnus-newsgroup-name))
3952 ;; Using `gnus-request-article' directly will insert the article into
3953 ;; `nntp-server-buffer' - so we'll save some time by not having to
3954 ;; copy it from the server buffer into the article buffer.
3956 ;; We only request an article by message-id when we do not have the
3957 ;; headers for it, so we'll have to get those.
3958 (when (stringp article)
3959 (gnus-read-header article))
3961 ;; If the article number is negative, that means that this article
3962 ;; doesn't belong in this newsgroup (possibly), so we find its
3963 ;; message-id and request it by id instead of number.
3964 (when (and (numberp article)
3966 (get-buffer gnus-summary-buffer)
3967 (gnus-buffer-exists-p gnus-summary-buffer))
3969 (set-buffer gnus-summary-buffer)
3970 (let ((header (gnus-summary-article-header article)))
3973 ((memq article gnus-newsgroup-sparse)
3974 ;; This is a sparse gap article.
3975 (setq do-update-line article)
3976 (setq article (mail-header-id header))
3977 (setq sparse-header (gnus-read-header article))
3978 (setq gnus-newsgroup-sparse
3979 (delq article gnus-newsgroup-sparse)))
3981 ;; It's a real article.
3982 (setq article (mail-header-id header)))
3984 ;; It is an extracted pseudo-article.
3985 (setq article 'pseudo)
3986 (gnus-request-pseudo-article header))))
3988 (let ((method (gnus-find-method-for-group
3989 gnus-newsgroup-name)))
3990 (when (and (eq (car method) 'nneething)
3992 (let ((dir (expand-file-name
3993 (mail-header-subject header)
3994 (file-name-as-directory
3995 (or (cadr (assq 'nneething-address method))
3997 (when (file-directory-p dir)
3998 (setq article 'nneething)
3999 (gnus-group-enter-directory dir))))))))
4002 ;; Refuse to select canceled articles.
4003 ((and (numberp article)
4005 (get-buffer gnus-summary-buffer)
4006 (gnus-buffer-exists-p gnus-summary-buffer)
4007 (eq (cdr (save-excursion
4008 (set-buffer gnus-summary-buffer)
4009 (assq article gnus-newsgroup-reads)))
4010 gnus-canceled-mark))
4012 ;; We first check `gnus-original-article-buffer'.
4013 ((and (get-buffer gnus-original-article-buffer)
4016 (set-buffer gnus-original-article-buffer)
4017 (and (equal (car gnus-original-article) group)
4018 (eq (cdr gnus-original-article) article))))
4019 (insert-buffer-substring gnus-original-article-buffer)
4021 ;; Check the backlog.
4022 ((and gnus-keep-backlog
4023 (gnus-backlog-request-article group article (current-buffer)))
4025 ;; Check asynchronous pre-fetch.
4026 ((gnus-async-request-fetched-article group article (current-buffer))
4027 (gnus-async-prefetch-next group article gnus-summary-buffer)
4028 (when (and (numberp article) gnus-keep-backlog)
4029 (gnus-backlog-enter-article group article (current-buffer)))
4032 ((and gnus-use-cache
4034 (gnus-cache-request-article article group))
4036 ;; Get the article and put into the article buffer.
4037 ((or (stringp article)
4039 (let ((gnus-override-method gnus-override-method)
4040 (methods (and (stringp article)
4041 gnus-refer-article-method))
4043 (buffer-read-only nil))
4044 (if (or (not (listp methods))
4045 (and (symbolp (car methods))
4046 (assq (car methods) nnoo-definition-alist)))
4047 (setq methods (list methods)))
4048 (when (and (null gnus-override-method)
4050 (setq gnus-override-method (pop methods)))
4052 (when (eq gnus-override-method 'current)
4053 (setq gnus-override-method
4054 (with-current-buffer gnus-summary-buffer
4055 gnus-current-select-method)))
4057 (gnus-kill-all-overlays)
4058 (let ((gnus-newsgroup-name group))
4059 (gnus-check-group-server))
4060 (when (gnus-request-article article group (current-buffer))
4061 (when (numberp article)
4062 (gnus-async-prefetch-next group article
4063 gnus-summary-buffer)
4064 (when gnus-keep-backlog
4065 (gnus-backlog-enter-article
4066 group article (current-buffer))))
4067 (setq result 'article))
4070 (setq gnus-override-method (pop methods))
4071 (setq result 'done))))
4072 (and (eq result 'article) 'article)))
4076 ;; Associate this article with the current summary buffer.
4077 (setq gnus-article-current-summary gnus-summary-buffer)
4079 ;; Take the article from the original article buffer
4080 ;; and place it in the buffer it's supposed to be in.
4081 (when (and (get-buffer gnus-article-buffer)
4082 (equal (buffer-name (current-buffer))
4083 (buffer-name (get-buffer gnus-article-buffer))))
4085 (if (get-buffer gnus-original-article-buffer)
4086 (set-buffer gnus-original-article-buffer)
4087 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
4088 (buffer-disable-undo)
4089 (setq major-mode 'gnus-original-article-mode)
4090 (setq buffer-read-only t))
4091 (let (buffer-read-only)
4093 (insert-buffer-substring gnus-article-buffer))
4094 (setq gnus-original-article (cons group article)))
4097 (run-hooks 'gnus-article-decode-hook)
4098 ;; Mark article as decoded or not.
4099 (setq gnus-article-decoded-p gnus-article-decode-hook))
4101 ;; Update sparse articles.
4102 (when (and do-update-line
4103 (or (numberp article)
4105 (let ((buf (current-buffer)))
4106 (set-buffer gnus-summary-buffer)
4107 (gnus-summary-update-article do-update-line sparse-header)
4108 (gnus-summary-goto-subject do-update-line nil t)
4109 (set-window-point (get-buffer-window (current-buffer) t)
4111 (set-buffer buf))))))
4117 (defcustom gnus-article-edit-mode-hook nil
4118 "Hook run in article edit mode buffers."
4119 :group 'gnus-article-various
4122 (defvar gnus-article-edit-done-function nil)
4124 (defvar gnus-article-edit-mode-map nil)
4126 ;; Should we be using derived.el for this?
4127 (unless gnus-article-edit-mode-map
4128 (setq gnus-article-edit-mode-map (make-sparse-keymap))
4129 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
4131 (gnus-define-keys gnus-article-edit-mode-map
4132 "\C-c\C-c" gnus-article-edit-done
4133 "\C-c\C-k" gnus-article-edit-exit)
4135 (gnus-define-keys (gnus-article-edit-wash-map
4136 "\C-c\C-w" gnus-article-edit-mode-map)
4137 "f" gnus-article-edit-full-stops))
4139 (defun gnus-article-edit-mode ()
4140 "Major mode for editing articles.
4141 This is an extended text-mode.
4143 \\{gnus-article-edit-mode-map}"
4145 (setq major-mode 'gnus-article-edit-mode)
4146 (setq mode-name "Article Edit")
4147 (use-local-map gnus-article-edit-mode-map)
4148 (make-local-variable 'gnus-article-edit-done-function)
4149 (make-local-variable 'gnus-prev-winconf)
4150 (setq buffer-read-only nil)
4151 (buffer-enable-undo)
4153 (gnus-run-hooks 'text-mode-hook 'gnus-article-edit-mode-hook))
4155 (defun gnus-article-edit (&optional force)
4156 "Edit the current article.
4157 This will have permanent effect only in mail groups.
4158 If FORCE is non-nil, allow editing of articles even in read-only
4161 (when (and (not force)
4162 (gnus-group-read-only-p))
4163 (error "The current newsgroup does not support article editing"))
4164 (gnus-article-date-original)
4165 (gnus-article-edit-article
4167 `(lambda (no-highlight)
4169 (gnus-summary-edit-article-done
4170 ,(or (mail-header-references gnus-current-headers) "")
4171 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
4173 (defun gnus-article-edit-article (start-func exit-func)
4174 "Start editing the contents of the current article buffer."
4175 (let ((winconf (current-window-configuration)))
4176 (set-buffer gnus-article-buffer)
4177 (gnus-article-edit-mode)
4178 (funcall start-func)
4179 (gnus-configure-windows 'edit-article)
4180 (setq gnus-article-edit-done-function exit-func)
4181 (setq gnus-prev-winconf winconf)
4182 (gnus-message 6 "C-c C-c to end edits")))
4184 (defun gnus-article-edit-done (&optional arg)
4185 "Update the article edits and exit."
4190 (when (article-goto-body)
4191 (let ((lines (count-lines (point) (point-max)))
4192 (length (- (point-max) (point)))
4193 (case-fold-search t)
4194 (body (copy-marker (point))))
4195 (goto-char (point-min))
4196 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
4197 (delete-region (match-beginning 1) (match-end 1))
4198 (insert (number-to-string length)))
4199 (goto-char (point-min))
4200 (when (re-search-forward
4201 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
4202 (delete-region (match-beginning 1) (match-end 1))
4203 (insert (number-to-string length)))
4204 (goto-char (point-min))
4205 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
4206 (delete-region (match-beginning 1) (match-end 1))
4207 (insert (number-to-string lines)))))))
4208 (let ((func gnus-article-edit-done-function)
4209 (buf (current-buffer))
4210 (start (window-start)))
4211 (gnus-article-edit-exit)
4214 (let ((buffer-read-only nil))
4216 ;; The cache and backlog have to be flushed somewhat.
4217 (when gnus-keep-backlog
4218 (gnus-backlog-remove-article
4219 (car gnus-article-current) (cdr gnus-article-current)))
4220 ;; Flush original article as well.
4222 (when (get-buffer gnus-original-article-buffer)
4223 (set-buffer gnus-original-article-buffer)
4224 (setq gnus-original-article nil)))
4225 (when gnus-use-cache
4226 (gnus-cache-update-article
4227 (car gnus-article-current) (cdr gnus-article-current))))
4229 (set-window-start (get-buffer-window buf) start)
4230 (set-window-point (get-buffer-window buf) (point))))
4232 (defun gnus-article-edit-exit ()
4233 "Exit the article editing without updating."
4235 ;; We remove all text props from the article buffer.
4236 (let ((buf (buffer-substring-no-properties (point-min) (point-max)))
4237 (curbuf (current-buffer))
4239 (window-start (window-start)))
4242 (let ((winconf gnus-prev-winconf))
4244 (set-window-configuration winconf)
4245 ;; Tippy-toe some to make sure that point remains where it was.
4246 (save-current-buffer
4248 (set-window-start (get-buffer-window (current-buffer)) window-start)
4251 (defun gnus-article-edit-full-stops ()
4252 "Interactively repair spacing at end of sentences."
4255 (goto-char (point-min))
4256 (search-forward-regexp "^$" nil t)
4257 (let ((case-fold-search nil))
4258 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
4261 ;;; Article highlights
4264 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
4266 ;;; Internal Variables:
4268 (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\\)\\)"
4269 "Regular expression that matches URLs."
4270 :group 'gnus-article-buttons
4273 (defcustom gnus-button-alist
4274 `(("<\\(url:[>\n\t ]*?\\)?news:[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
4275 0 t gnus-button-message-id 2)
4276 ("\\bnews:\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t gnus-button-message-id 1)
4277 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
4279 gnus-button-fetch-group 4)
4280 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
4281 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
4282 t gnus-button-message-id 3)
4283 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
4284 ("mailto:\\([-a-zA-Z.@_+0-9%]+\\)" 0 t gnus-url-mailto 1)
4285 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
4286 ;; This is how URLs _should_ be embedded in text...
4287 ("<URL: *\\([^<>]*\\)>" 0 t gnus-button-embedded-url 1)
4289 (,gnus-button-url-regexp 0 t browse-url 0))
4290 "*Alist of regexps matching buttons in article bodies.
4292 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
4293 REGEXP: is the string matching text around the button,
4294 BUTTON: is the number of the regexp grouping actually matching the button,
4295 FORM: is a lisp expression which must eval to true for the button to
4297 CALLBACK: is the function to call when the user push this button, and each
4298 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
4300 CALLBACK can also be a variable, in that case the value of that
4301 variable it the real callback function."
4302 :group 'gnus-article-buttons
4303 :type '(repeat (list regexp
4304 (integer :tag "Button")
4306 (function :tag "Callback")
4309 (integer :tag "Regexp group")))))
4311 (defcustom gnus-header-button-alist
4312 `(("^\\(References\\|Message-I[Dd]\\):" "<[^>]+>"
4313 0 t gnus-button-message-id 0)
4314 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
4315 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
4316 0 t gnus-button-mailto 0)
4317 ("^X-[Uu][Rr][Ll]:" ,gnus-button-url-regexp 0 t browse-url 0)
4318 ("^Subject:" ,gnus-button-url-regexp 0 t browse-url 0)
4319 ("^[^:]+:" ,gnus-button-url-regexp 0 t browse-url 0)
4320 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
4321 gnus-button-message-id 3))
4322 "*Alist of headers and regexps to match buttons in article heads.
4324 This alist is very similar to `gnus-button-alist', except that each
4325 alist has an additional HEADER element first in each entry:
4327 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
4329 HEADER is a regexp to match a header. For a fuller explanation, see
4330 `gnus-button-alist'."
4331 :group 'gnus-article-buttons
4332 :group 'gnus-article-headers
4333 :type '(repeat (list (regexp :tag "Header")
4335 (integer :tag "Button")
4337 (function :tag "Callback")
4340 (integer :tag "Regexp group")))))
4342 (defvar gnus-button-regexp nil)
4343 (defvar gnus-button-marker-list nil)
4344 ;; Regexp matching any of the regexps from `gnus-button-alist'.
4346 (defvar gnus-button-last nil)
4347 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
4351 (defun gnus-article-push-button (event)
4352 "Check text under the mouse pointer for a callback function.
4353 If the text under the mouse pointer has a `gnus-callback' property,
4354 call it with the value of the `gnus-data' text property."
4356 (set-buffer (window-buffer (posn-window (event-start event))))
4357 (let* ((pos (posn-point (event-start event)))
4358 (data (get-text-property pos 'gnus-data))
4359 (fun (get-text-property pos 'gnus-callback)))
4362 (funcall fun data))))
4364 (defun gnus-article-press-button ()
4365 "Check text at point for a callback function.
4366 If the text at point has a `gnus-callback' property,
4367 call it with the value of the `gnus-data' text property."
4369 (let* ((data (get-text-property (point) 'gnus-data))
4370 (fun (get-text-property (point) 'gnus-callback)))
4372 (funcall fun data))))
4374 (defun gnus-article-highlight (&optional force)
4375 "Highlight current article.
4376 This function calls `gnus-article-highlight-headers',
4377 `gnus-article-highlight-citation',
4378 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
4379 do the highlighting. See the documentation for those functions."
4380 (interactive (list 'force))
4381 (gnus-article-highlight-headers)
4382 (gnus-article-highlight-citation force)
4383 (gnus-article-highlight-signature)
4384 (gnus-article-add-buttons force)
4385 (gnus-article-add-buttons-to-head))
4387 (defun gnus-article-highlight-some (&optional force)
4388 "Highlight current article.
4389 This function calls `gnus-article-highlight-headers',
4390 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
4391 do the highlighting. See the documentation for those functions."
4392 (interactive (list 'force))
4393 (gnus-article-highlight-headers)
4394 (gnus-article-highlight-signature)
4395 (gnus-article-add-buttons))
4397 (defun gnus-article-highlight-headers ()
4398 "Highlight article headers as specified by `gnus-header-face-alist'."
4401 (set-buffer gnus-article-buffer)
4403 (let ((alist gnus-header-face-alist)
4404 (buffer-read-only nil)
4405 (case-fold-search t)
4406 (inhibit-point-motion-hooks t)
4407 entry regexp header-face field-face from hpoints fpoints)
4408 (article-narrow-to-head)
4409 (while (setq entry (pop alist))
4410 (goto-char (point-min))
4411 (setq regexp (concat "^\\("
4412 (if (string-equal "" (nth 0 entry))
4416 header-face (nth 1 entry)
4417 field-face (nth 2 entry))
4418 (while (and (re-search-forward regexp nil t)
4422 (unless (search-forward ":" nil t)
4424 (when (and header-face
4425 (not (memq (point) hpoints)))
4426 (push (point) hpoints)
4427 (gnus-put-text-property from (point) 'face header-face))
4428 (when (and field-face
4429 (not (memq (setq from (point)) fpoints)))
4431 (if (re-search-forward "^[^ \t]" nil t)
4433 (goto-char (point-max)))
4434 (gnus-put-text-property from (point) 'face field-face))))))))
4436 (defun gnus-article-highlight-signature ()
4437 "Highlight the signature in an article.
4438 It does this by highlighting everything after
4439 `gnus-signature-separator' using `gnus-signature-face'."
4442 (set-buffer gnus-article-buffer)
4443 (let ((buffer-read-only nil)
4444 (inhibit-point-motion-hooks t))
4446 (when (and gnus-signature-face
4447 (gnus-article-narrow-to-signature))
4448 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
4449 'face gnus-signature-face)
4451 (gnus-article-search-signature)
4452 (let ((start (match-beginning 0))
4453 (end (set-marker (make-marker) (1+ (match-end 0)))))
4454 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
4457 (defun gnus-button-in-region-p (b e prop)
4458 "Say whether PROP exists in the region."
4459 (text-property-not-all b e prop nil))
4461 (defun gnus-article-add-buttons (&optional force)
4462 "Find external references in the article and make buttons of them.
4463 \"External references\" are things like Message-IDs and URLs, as
4464 specified by `gnus-button-alist'."
4465 (interactive (list 'force))
4467 (set-buffer gnus-article-buffer)
4468 (let ((buffer-read-only nil)
4469 (inhibit-point-motion-hooks t)
4470 (case-fold-search t)
4471 (alist gnus-button-alist)
4473 ;; Remove all old markers.
4474 (let (marker entry new-list)
4475 (while (setq marker (pop gnus-button-marker-list))
4476 (if (or (< marker (point-min)) (>= marker (point-max)))
4477 (push marker new-list)
4479 (when (setq entry (gnus-button-entry))
4480 (put-text-property (match-beginning (nth 1 entry))
4481 (match-end (nth 1 entry))
4482 'gnus-callback nil))
4483 (set-marker marker nil)))
4484 (setq gnus-button-marker-list new-list))
4485 ;; We skip the headers.
4488 (while (setq entry (pop alist))
4489 (setq regexp (car entry))
4491 (while (re-search-forward regexp nil t)
4492 (let* ((start (and entry (match-beginning (nth 1 entry))))
4493 (end (and entry (match-end (nth 1 entry))))
4494 (from (match-beginning 0)))
4495 (when (and (or (eq t (nth 2 entry))
4496 (eval (nth 2 entry)))
4497 (not (gnus-button-in-region-p
4498 start end 'gnus-callback)))
4499 ;; That optional form returned non-nil, so we add the
4501 (gnus-article-add-button
4502 start end 'gnus-button-push
4503 (car (push (set-marker (make-marker) from)
4504 gnus-button-marker-list))))))))))
4506 ;; Add buttons to the head of an article.
4507 (defun gnus-article-add-buttons-to-head ()
4508 "Add buttons to the head of the article."
4511 (set-buffer gnus-article-buffer)
4513 (let ((buffer-read-only nil)
4514 (inhibit-point-motion-hooks t)
4515 (case-fold-search t)
4516 (alist gnus-header-button-alist)
4518 (article-narrow-to-head)
4520 ;; Each alist entry.
4521 (setq entry (car alist)
4523 (goto-char (point-min))
4524 (while (re-search-forward (car entry) nil t)
4525 ;; Each header matching the entry.
4526 (setq beg (match-beginning 0))
4527 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
4528 (match-beginning 0))
4531 (while (re-search-forward (nth 1 entry) end t)
4532 ;; Each match within a header.
4533 (let* ((entry (cdr entry))
4534 (start (match-beginning (nth 1 entry)))
4535 (end (match-end (nth 1 entry)))
4536 (form (nth 2 entry)))
4537 (goto-char (match-end 0))
4539 (gnus-article-add-button
4540 start end (nth 3 entry)
4541 (buffer-substring (match-beginning (nth 4 entry))
4542 (match-end (nth 4 entry)))))))
4543 (goto-char end)))))))
4545 ;;; External functions:
4547 (defun gnus-article-add-button (from to fun &optional data)
4548 "Create a button between FROM and TO with callback FUN and data DATA."
4549 (when gnus-article-button-face
4550 (gnus-overlay-put (gnus-make-overlay from to)
4551 'face gnus-article-button-face))
4552 (gnus-add-text-properties
4554 (nconc (and gnus-article-mouse-face
4555 (list gnus-mouse-face-prop gnus-article-mouse-face))
4556 (list 'gnus-callback fun)
4557 (and data (list 'gnus-data data))))
4558 (widget-convert-button 'link from to :action 'gnus-widget-press-button
4559 :button-keymap gnus-widget-button-keymap))
4561 ;;; Internal functions:
4563 (defun gnus-article-set-globals ()
4565 (set-buffer gnus-summary-buffer)
4566 (gnus-set-global-variables)))
4568 (defun gnus-signature-toggle (end)
4570 (set-buffer gnus-article-buffer)
4571 (let ((buffer-read-only nil)
4572 (inhibit-point-motion-hooks t))
4573 (if (text-property-any end (point-max) 'article-type 'signature)
4574 (gnus-remove-text-properties-when
4575 'article-type 'signature end (point-max)
4576 (cons 'article-type (cons 'signature
4577 gnus-hidden-properties)))
4578 (gnus-add-text-properties-when
4579 'article-type nil end (point-max)
4580 (cons 'article-type (cons 'signature
4581 gnus-hidden-properties)))))))
4583 (defun gnus-button-entry ()
4584 ;; Return the first entry in `gnus-button-alist' matching this place.
4585 (let ((alist gnus-button-alist)
4588 (setq entry (pop alist))
4589 (if (looking-at (car entry))
4594 (defun gnus-button-push (marker)
4595 ;; Push button starting at MARKER.
4598 (let* ((entry (gnus-button-entry))
4599 (inhibit-point-motion-hooks t)
4601 (args (mapcar (lambda (group)
4602 (let ((string (match-string group)))
4603 (gnus-set-text-properties
4604 0 (length string) nil string)
4611 (fboundp (symbol-value fun)))
4612 (apply (symbol-value fun) args))
4614 (gnus-message 1 "You must define `%S' to use this button"
4615 (cons fun args)))))))
4617 (defun gnus-button-message-id (message-id)
4620 (set-buffer gnus-summary-buffer)
4621 (gnus-summary-refer-article message-id)))
4623 (defun gnus-button-fetch-group (address)
4624 "Fetch GROUP specified by ADDRESS."
4625 (if (not (string-match "[:/]" address))
4626 ;; This is just a simple group url.
4627 (gnus-group-read-ephemeral-group address gnus-select-method)
4628 (if (not (string-match "^\\([^:/]+\\)\\(:\\([^/]+\\)/\\)?\\(.*\\)$"
4630 (error "Can't parse %s" address)
4631 (gnus-group-read-ephemeral-group
4632 (match-string 4 address)
4633 `(nntp ,(match-string 1 address)
4634 (nntp-address ,(match-string 1 address))
4635 (nntp-port-number ,(if (match-end 3)
4636 (match-string 3 address)
4639 (defun gnus-url-parse-query-string (query &optional downcase)
4640 (let (retval pairs cur key val)
4641 (setq pairs (split-string query "&"))
4643 (setq cur (car pairs)
4645 (if (not (string-match "=" cur))
4647 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
4648 val (gnus-url-unhex-string (substring cur (match-end 0) nil)))
4650 (setq key (downcase key)))
4651 (setq cur (assoc key retval))
4653 (setcdr cur (cons val (cdr cur)))
4654 (setq retval (cons (list key val) retval)))))
4657 (defun gnus-url-unhex (x)
4664 (defun gnus-url-unhex-string (str &optional allow-newlines)
4665 "Remove %XXX embedded spaces, etc in a url.
4666 If optional second argument ALLOW-NEWLINES is non-nil, then allow the
4667 decoding of carriage returns and line feeds in the string, which is normally
4668 forbidden in URL encoding."
4669 (setq str (or str ""))
4671 (case-fold-search t))
4672 (while (string-match "%[0-9a-f][0-9a-f]" str)
4673 (let* ((start (match-beginning 0))
4674 (ch1 (gnus-url-unhex (elt str (+ start 1))))
4676 (gnus-url-unhex (elt str (+ start 2))))))
4678 tmp (substring str 0 start)
4681 (char-to-string code))
4682 ((or (= code ?\n) (= code ?\r))
4684 (t (char-to-string code))))
4685 str (substring str (match-end 0)))))
4686 (setq tmp (concat tmp str))
4689 (defun gnus-url-mailto (url)
4690 ;; Send mail to someone
4691 (when (string-match "mailto:/*\\(.*\\)" url)
4692 (setq url (substring url (match-beginning 1) nil)))
4693 (let (to args subject func)
4694 (if (string-match (regexp-quote "?") url)
4695 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
4696 args (gnus-url-parse-query-string
4697 (substring url (match-end 0) nil) t))
4698 (setq to (gnus-url-unhex-string url)))
4699 (setq args (cons (list "to" to) args)
4700 subject (cdr-safe (assoc "subject" args)))
4703 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
4706 (message-position-on-field (caar args)))
4707 (insert (mapconcat 'identity (cdar args) ", "))
4708 (setq args (cdr args)))
4711 (message-goto-subject))))
4713 (defun gnus-button-mailto (address)
4715 (set-buffer (gnus-copy-article-buffer))
4716 (message-reply address))
4718 (defalias 'gnus-button-reply 'message-reply)
4720 (defun gnus-button-embedded-url (address)
4721 "Activate ADDRESS with `browse-url'."
4722 (browse-url (gnus-strip-whitespace address)))
4724 ;;; Next/prev buttons in the article buffer.
4726 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
4727 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
4729 (defvar gnus-prev-page-map nil)
4730 (unless gnus-prev-page-map
4731 (setq gnus-prev-page-map (make-sparse-keymap))
4732 (define-key gnus-prev-page-map gnus-mouse-2 'gnus-button-prev-page)
4733 (define-key gnus-prev-page-map "\r" 'gnus-button-prev-page))
4735 (defun gnus-insert-prev-page-button ()
4736 (let ((buffer-read-only nil))
4738 gnus-prev-page-line-format nil
4739 `(gnus-prev t local-map ,gnus-prev-page-map
4740 gnus-callback gnus-article-button-prev-page
4741 article-type annotation))))
4743 (defvar gnus-next-page-map nil)
4744 (unless gnus-next-page-map
4745 (setq gnus-next-page-map (make-keymap))
4746 (suppress-keymap gnus-prev-page-map)
4747 (define-key gnus-next-page-map gnus-mouse-2 'gnus-button-next-page)
4748 (define-key gnus-next-page-map "\r" 'gnus-button-next-page))
4750 (defun gnus-button-next-page ()
4751 "Go to the next page."
4753 (let ((win (selected-window)))
4754 (select-window (get-buffer-window gnus-article-buffer t))
4755 (gnus-article-next-page)
4756 (select-window win)))
4758 (defun gnus-button-prev-page ()
4759 "Go to the prev page."
4761 (let ((win (selected-window)))
4762 (select-window (get-buffer-window gnus-article-buffer t))
4763 (gnus-article-prev-page)
4764 (select-window win)))
4766 (defun gnus-insert-next-page-button ()
4767 (let ((buffer-read-only nil))
4768 (gnus-eval-format gnus-next-page-line-format nil
4770 t local-map ,gnus-next-page-map
4771 gnus-callback gnus-article-button-next-page
4772 article-type annotation))))
4774 (defun gnus-article-button-next-page (arg)
4775 "Go to the next page."
4777 (let ((win (selected-window)))
4778 (select-window (get-buffer-window gnus-article-buffer t))
4779 (gnus-article-next-page)
4780 (select-window win)))
4782 (defun gnus-article-button-prev-page (arg)
4783 "Go to the prev page."
4785 (let ((win (selected-window)))
4786 (select-window (get-buffer-window gnus-article-buffer t))
4787 (gnus-article-prev-page)
4788 (select-window win)))
4790 (defvar gnus-decode-header-methods
4791 '(mail-decode-encoded-word-region)
4792 "List of methods used to decode headers.
4794 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
4795 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
4796 (REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
4797 whose names match REGEXP.
4800 ((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
4801 mail-decode-encoded-word-region
4802 (\"chinese\" . rfc1843-decode-region))
4805 (defvar gnus-decode-header-methods-cache nil)
4807 (defun gnus-multi-decode-header (start end)
4808 "Apply the functions from `gnus-encoded-word-methods' that match."
4809 (unless (and gnus-decode-header-methods-cache
4810 (eq gnus-newsgroup-name
4811 (car gnus-decode-header-methods-cache)))
4812 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
4815 (nconc gnus-decode-header-methods-cache (list x))
4816 (if (and gnus-newsgroup-name
4817 (string-match (car x) gnus-newsgroup-name))
4818 (nconc gnus-decode-header-methods-cache
4820 gnus-decode-header-methods))
4821 (let ((xlist gnus-decode-header-methods-cache))
4824 (narrow-to-region start end)
4826 (funcall (pop xlist) (point-min) (point-max))))))
4829 ;;; Treatment top-level handling.
4832 (defun gnus-treat-article (condition &optional part-number total-parts type)
4833 (let ((length (- (point-max) (point-min)))
4834 (alist gnus-treatment-function-alist)
4835 (article-goto-body-goes-to-point-min-p t)
4839 (let ((list gnus-article-treat-types))
4841 (when (string-match (pop list) type)
4842 (throw 'found t)))))))
4843 (highlightp (gnus-visual-p 'article-highlight 'highlight))
4845 (gnus-run-hooks 'gnus-part-display-hook)
4846 (while (setq elem (pop alist))
4849 (if (gnus-buffer-live-p gnus-summary-buffer)
4850 (set-buffer gnus-summary-buffer))
4851 (symbol-value (car elem))))
4852 (when (and (or (consp val)
4854 (gnus-treat-predicate val)
4855 (or (not (get (car elem) 'highlight))
4858 (funcall (cadr elem)))))))
4860 ;; Dynamic variables.
4862 (defvar part-number)
4863 (defvar total-parts)
4868 (defun gnus-treat-predicate (val)
4873 (stringp (car val)))
4874 (apply 'gnus-or (mapcar `(lambda (s)
4875 (string-match s ,(or gnus-newsgroup-name "")))
4878 (let ((pred (pop val)))
4881 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
4883 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
4885 (not (gnus-treat-predicate (car val))))
4887 (equal (car val) type))
4889 (error "%S is not a valid predicate" pred)))))
4897 (eq part-number total-parts))
4901 (error "%S is not a valid value" val))))
4907 (run-hooks 'gnus-art-load-hook)
4909 ;;; gnus-art.el ends here