2 ;;; gnus-art.el --- article mode commands for Gnus
3 ;; Copyright (C) 1996,97,98,99 Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval-when-compile (require 'cl))
44 (defgroup gnus-article nil
46 :link '(custom-manual "(gnus)The Article Buffer")
49 (defgroup gnus-article-treat nil
50 "Treating article parts."
51 :link '(custom-manual "(gnus)Article Hiding")
54 (defgroup gnus-article-hiding nil
55 "Hiding article parts."
56 :link '(custom-manual "(gnus)Article Hiding")
59 (defgroup gnus-article-highlight nil
60 "Article highlighting."
61 :link '(custom-manual "(gnus)Article Highlighting")
65 (defgroup gnus-article-signature nil
67 :link '(custom-manual "(gnus)Article Signature")
70 (defgroup gnus-article-headers nil
72 :link '(custom-manual "(gnus)Hiding Headers")
75 (defgroup gnus-article-washing nil
76 "Special commands on articles."
77 :link '(custom-manual "(gnus)Article Washing")
80 (defgroup gnus-article-emphasis nil
81 "Fontisizing articles."
82 :link '(custom-manual "(gnus)Article Fontisizing")
85 (defgroup gnus-article-saving nil
87 :link '(custom-manual "(gnus)Saving Articles")
90 (defgroup gnus-article-mime nil
91 "Worshiping the MIME wonder."
92 :link '(custom-manual "(gnus)Using MIME")
95 (defgroup gnus-article-buttons nil
96 "Pushable buttons in the article buffer."
97 :link '(custom-manual "(gnus)Article Buttons")
100 (defgroup gnus-article-various nil
101 "Other article options."
102 :link '(custom-manual "(gnus)Misc Article")
103 :group 'gnus-article)
105 (defcustom gnus-ignored-headers
106 '("^Path:" "^Expires:" "^Date-Received:" "^References:" "^Xref:" "^Lines:"
107 "^Relay-Version:" "^Message-ID:" "^Approved:" "^Sender:" "^Received:"
108 "^X-UIDL:" "^MIME-Version:" "^Return-Path:" "^In-Reply-To:"
109 "^Content-Type:" "^Content-Transfer-Encoding:" "^X-WebTV-Signature:"
110 "^X-MimeOLE:" "^X-MSMail-Priority:" "^X-Priority:" "^X-Loop:"
111 "^X-Authentication-Warning:" "^X-MIME-Autoconverted:" "^X-Face:"
112 "^X-Attribution:" "^X-Originating-IP:" "^Delivered-To:"
113 "^NNTP-[-A-Za-z]+:" "^Distribution:" "^X-no-archive:" "^X-Trace:"
114 "^X-Complaints-To:" "^X-NNTP-Posting-Host:" "^X-Orig.*:"
115 "^Abuse-Reports-To:" "^Cache-Post-Path:" "^X-Article-Creation-Date:"
116 "^X-Poster:" "^X-Mail2News-Path:" "^X-Server-Date:" "^X-Cache:"
117 "^Originator:" "^X-Problems-To:" "^X-Auth-User:" "^X-Post-Time:"
118 "^X-Admin:" "^X-UID:" "^Resent-[-A-Za-z]+:" "^X-Mailing-List:"
119 "^Precedence:" "^Original-[-A-Za-z]+:" "^X-filename:" "^X-Orcpt:"
120 "^Old-Received:" "^X-Pgp-Fingerprint:" "^X-Pgp-Key-Id:"
121 "^X-Pgp-Public-Key-Url:" "^X-Auth:" "^X-From-Line:"
122 "^X-Gnus-Article-Number:" "^X-Majordomo:" "^X-Url:" "^X-Sender:"
123 "^X-Mailing-List:" "^MBOX-Line" "^Priority:" "^X-Pgp" "^X400-[-A-Za-z]+:"
125 "*All headers that start with this regexp will be hidden.
126 This variable can also be a list of regexps of headers to be ignored.
127 If `gnus-visible-headers' is non-nil, this variable will be ignored."
128 :type '(choice :custom-show nil
131 :group 'gnus-article-hiding)
133 (defcustom gnus-visible-headers
134 "^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:"
135 "*All headers that do not match this regexp will be hidden.
136 This variable can also be a list of regexp of headers to remain visible.
137 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
138 :type '(repeat :value-to-internal (lambda (widget value)
139 (custom-split-regexp-maybe value))
140 :match (lambda (widget value)
142 (widget-editable-list-match widget value)))
144 :group 'gnus-article-hiding)
146 (defcustom gnus-sorted-header-list
147 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
148 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
149 "*This variable is a list of regular expressions.
150 If it is non-nil, headers that match the regular expressions will
151 be placed first in the article buffer in the sequence specified by
153 :type '(repeat regexp)
154 :group 'gnus-article-hiding)
156 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
157 "Headers that are only to be displayed if they have interesting data.
158 Possible values in this list are `empty', `newsgroups', `followup-to',
159 `reply-to', `date', `long-to', and `many-to'."
160 :type '(set (const :tag "Headers with no content." empty)
161 (const :tag "Newsgroups with only one group." newsgroups)
162 (const :tag "Followup-to identical to newsgroups." followup-to)
163 (const :tag "Reply-to identical to from." reply-to)
164 (const :tag "Date less than four days old." date)
165 (const :tag "Very long To header." long-to)
166 (const :tag "Multiple To headers." many-to))
167 :group 'gnus-article-hiding)
169 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
170 "Regexp matching signature separator.
171 This can also be a list of regexps. In that case, it will be checked
172 from head to tail looking for a separator. Searches will be done from
173 the end of the buffer."
174 :type '(repeat string)
175 :group 'gnus-article-signature)
177 (defcustom gnus-signature-limit nil
178 "Provide a limit to what is considered a signature.
179 If it is a number, no signature may not be longer (in characters) than
180 that number. If it is a floating point number, no signature may be
181 longer (in lines) than that number. If it is a function, the function
182 will be called without any parameters, and if it returns nil, there is
183 no signature in the buffer. If it is a string, it will be used as a
184 regexp. If it matches, the text in question is not a signature."
185 :type '(choice (integer :value 200)
187 (function :value fun)
188 (regexp :value ".*"))
189 :group 'gnus-article-signature)
191 (defcustom gnus-hidden-properties '(invisible t intangible t)
192 "Property list to use for hiding text."
194 :group 'gnus-article-hiding)
196 (defcustom gnus-article-x-face-command
197 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | xv -quit -"
198 "*String or function to be executed to display an X-Face header.
199 If it is a string, the command will be executed in a sub-shell
200 asynchronously. The compressed face will be piped to this command."
201 :type 'string ;Leave function case to Lisp.
202 :group 'gnus-article-washing)
204 (defcustom gnus-article-x-face-too-ugly nil
205 "Regexp matching posters whose face shouldn't be shown automatically."
206 :type '(choice regexp (const nil))
207 :group 'gnus-article-washing)
209 (defcustom gnus-emphasis-alist
211 "\\(\\s-\\|^\\|[-\"]\\|\\s(\\|\\s)\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\s-\\|[-?!.,;:\"]\\|\\s(\\|\\s)\\)")
213 '(("_" "_" underline)
216 ("_/" "/_" underline-italic)
217 ("_\\*" "\\*_" underline-bold)
218 ("\\*/" "/\\*" bold-italic)
219 ("_\\*/" "/\\*_" underline-bold-italic))))
220 `(("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
221 2 3 gnus-emphasis-underline)
225 (format format (car spec) (cadr spec))
226 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
228 "*Alist that says how to fontify certain phrases.
229 Each item looks like this:
231 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
233 The first element is a regular expression to be matched. The second
234 is a number that says what regular expression grouping used to find
235 the entire emphasized word. The third is a number that says what
236 regexp grouping should be displayed and highlighted. The fourth
237 is the face used for highlighting."
238 :type '(repeat (list :value ("" 0 0 default)
240 (integer :tag "Match group")
241 (integer :tag "Emphasize group")
243 :group 'gnus-article-emphasis)
245 (defface gnus-emphasis-bold '((t (:bold t)))
246 "Face used for displaying strong emphasized text (*word*)."
247 :group 'gnus-article-emphasis)
249 (defface gnus-emphasis-italic '((t (:italic t)))
250 "Face used for displaying italic emphasized text (/word/)."
251 :group 'gnus-article-emphasis)
253 (defface gnus-emphasis-underline '((t (:underline t)))
254 "Face used for displaying underlined emphasized text (_word_)."
255 :group 'gnus-article-emphasis)
257 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
258 "Face used for displaying underlined bold emphasized text (_*word*_)."
259 :group 'gnus-article-emphasis)
261 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
262 "Face used for displaying underlined italic emphasized text (_*word*_)."
263 :group 'gnus-article-emphasis)
265 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
266 "Face used for displaying bold italic emphasized text (/*word*/)."
267 :group 'gnus-article-emphasis)
269 (defface gnus-emphasis-underline-bold-italic
270 '((t (:bold t :italic t :underline t)))
271 "Face used for displaying underlined bold italic emphasized text.
272 Esample: (_/*word*/_)."
273 :group 'gnus-article-emphasis)
275 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
276 "Format for display of Date headers in article bodies.
277 See `format-time-string' for the possible values.
279 The variable can also be function, which should return a complete Date
280 header. The function is called with one argument, the time, which can
281 be fed to `format-time-string'."
282 :type '(choice string symbol)
283 :link '(custom-manual "(gnus)Article Date")
284 :group 'gnus-article-washing)
287 (autoload 'mail-extract-address-components "mail-extr"))
289 (defcustom gnus-save-all-headers t
290 "*If non-nil, don't remove any headers before saving."
291 :group 'gnus-article-saving
294 (defcustom gnus-prompt-before-saving 'always
295 "*This variable says how much prompting is to be done when saving articles.
296 If it is nil, no prompting will be done, and the articles will be
297 saved to the default files. If this variable is `always', each and
298 every article that is saved will be preceded by a prompt, even when
299 saving large batches of articles. If this variable is neither nil not
300 `always', there the user will be prompted once for a file name for
301 each invocation of the saving commands."
302 :group 'gnus-article-saving
303 :type '(choice (item always)
304 (item :tag "never" nil)
305 (sexp :tag "once" :format "%t\n" :value t)))
307 (defcustom gnus-saved-headers gnus-visible-headers
308 "Headers to keep if `gnus-save-all-headers' is nil.
309 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
310 If that variable is nil, however, all headers that match this regexp
311 will be kept while the rest will be deleted before saving."
312 :group 'gnus-article-saving
315 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
316 "A function to save articles in your favourite format.
317 The function must be interactively callable (in other words, it must
318 be an Emacs command).
320 Gnus provides the following functions:
322 * gnus-summary-save-in-rmail (Rmail format)
323 * gnus-summary-save-in-mail (Unix mail format)
324 * gnus-summary-save-in-folder (MH folder)
325 * gnus-summary-save-in-file (article format)
326 * gnus-summary-save-in-vm (use VM's folder format)
327 * gnus-summary-write-to-file (article format -- overwrite)."
328 :group 'gnus-article-saving
329 :type '(radio (function-item gnus-summary-save-in-rmail)
330 (function-item gnus-summary-save-in-mail)
331 (function-item gnus-summary-save-in-folder)
332 (function-item gnus-summary-save-in-file)
333 (function-item gnus-summary-save-in-vm)
334 (function-item gnus-summary-write-to-file)))
336 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
337 "A function generating a file name to save articles in Rmail format.
338 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
339 :group 'gnus-article-saving
342 (defcustom gnus-mail-save-name 'gnus-plain-save-name
343 "A function generating a file name to save articles in Unix mail format.
344 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
345 :group 'gnus-article-saving
348 (defcustom gnus-folder-save-name 'gnus-folder-save-name
349 "A function generating a file name to save articles in MH folder.
350 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
351 :group 'gnus-article-saving
354 (defcustom gnus-file-save-name 'gnus-numeric-save-name
355 "A function generating a file name to save articles in article format.
356 The function is called with NEWSGROUP, HEADERS, and optional
358 :group 'gnus-article-saving
361 (defcustom gnus-split-methods
362 '((gnus-article-archive-name)
363 (gnus-article-nndoc-name))
364 "*Variable used to suggest where articles are to be saved.
365 For instance, if you would like to save articles related to Gnus in
366 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
367 you could set this variable to something like:
369 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
370 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
372 This variable is an alist where the where the key is the match and the
373 value is a list of possible files to save in if the match is non-nil.
375 If the match is a string, it is used as a regexp match on the
376 article. If the match is a symbol, that symbol will be funcalled
377 from the buffer of the article to be saved with the newsgroup as the
378 parameter. If it is a list, it will be evaled in the same buffer.
380 If this form or function returns a string, this string will be used as
381 a possible file name; and if it returns a non-nil list, that list will
382 be used as possible file names."
383 :group 'gnus-article-saving
384 :type '(repeat (choice (list :value (fun) function)
385 (cons :value ("" "") regexp (repeat string))
388 (defcustom gnus-page-delimiter "^\^L"
389 "*Regexp describing what to use as article page delimiters.
390 The default value is \"^\^L\", which is a form linefeed at the
391 beginning of a line."
393 :group 'gnus-article-various)
395 (defcustom gnus-article-mode-line-format "Gnus: %g %S%m"
396 "*The format specification for the article mode line.
397 See `gnus-summary-mode-line-format' for a closer description.
399 The following additional specs are available:
401 %w The article washing status.
402 %m The number of MIME parts in the article."
404 :group 'gnus-article-various)
406 (defcustom gnus-article-mode-hook nil
407 "*A hook for Gnus article mode."
409 :group 'gnus-article-various)
411 (defcustom gnus-article-menu-hook nil
412 "*Hook run after the creation of the article mode menu."
414 :group 'gnus-article-various)
416 (defcustom gnus-article-prepare-hook nil
417 "*A hook called after an article has been prepared in the article buffer."
419 :group 'gnus-article-various)
421 (defcustom gnus-article-hide-pgp-hook nil
422 "*A hook called after successfully hiding a PGP signature."
424 :group 'gnus-article-various)
426 (defcustom gnus-article-button-face 'bold
427 "Face used for highlighting buttons in the article buffer.
429 An article button is a piece of text that you can activate by pressing
430 `RET' or `mouse-2' above it."
432 :group 'gnus-article-buttons)
434 (defcustom gnus-article-mouse-face 'highlight
435 "Face used for mouse highlighting in the article buffer.
437 Article buttons will be displayed in this face when the cursor is
440 :group 'gnus-article-buttons)
442 (defcustom gnus-signature-face 'gnus-signature-face
443 "Face used for highlighting a signature in the article buffer.
444 Obsolete; use the face `gnus-signature-face' for customizations instead."
446 :group 'gnus-article-highlight
447 :group 'gnus-article-signature)
449 (defface gnus-signature-face
452 "Face used for highlighting a signature in the article buffer."
453 :group 'gnus-article-highlight
454 :group 'gnus-article-signature)
456 (defface gnus-header-from-face
459 (:foreground "spring green"))
462 (:foreground "red3"))
465 "Face used for displaying from headers."
466 :group 'gnus-article-headers
467 :group 'gnus-article-highlight)
469 (defface gnus-header-subject-face
472 (:foreground "SeaGreen3"))
475 (:foreground "red4"))
477 (:bold t :italic t)))
478 "Face used for displaying subject headers."
479 :group 'gnus-article-headers
480 :group 'gnus-article-highlight)
482 (defface gnus-header-newsgroups-face
485 (:foreground "yellow" :italic t))
488 (:foreground "MidnightBlue" :italic t))
491 "Face used for displaying newsgroups headers."
492 :group 'gnus-article-headers
493 :group 'gnus-article-highlight)
495 (defface gnus-header-name-face
498 (:foreground "SeaGreen"))
501 (:foreground "maroon"))
504 "Face used for displaying header names."
505 :group 'gnus-article-headers
506 :group 'gnus-article-highlight)
508 (defface gnus-header-content-face
511 (:foreground "forest green" :italic t))
514 (:foreground "indianred4" :italic t))
516 (:italic t))) "Face used for displaying header content."
517 :group 'gnus-article-headers
518 :group 'gnus-article-highlight)
520 (defcustom gnus-header-face-alist
521 '(("From" nil gnus-header-from-face)
522 ("Subject" nil gnus-header-subject-face)
523 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
524 ("" gnus-header-name-face gnus-header-content-face))
525 "*Controls highlighting of article header.
527 An alist of the form (HEADER NAME CONTENT).
529 HEADER is a regular expression which should match the name of an
530 header header and NAME and CONTENT are either face names or nil.
532 The name of each header field will be displayed using the face
533 specified by the first element in the list where HEADER match the
534 header name and NAME is non-nil. Similarly, the content will be
535 displayed by the first non-nil matching CONTENT face."
536 :group 'gnus-article-headers
537 :group 'gnus-article-highlight
538 :type '(repeat (list (regexp :tag "Header")
540 (item :tag "skip" nil)
541 (face :value default))
542 (choice :tag "Content"
543 (item :tag "skip" nil)
544 (face :value default)))))
546 (defcustom gnus-article-decode-hook
547 '(article-decode-charset article-decode-encoded-words)
548 "*Hook run to decode charsets in articles."
549 :group 'gnus-article-headers
552 (defcustom gnus-display-mime-function 'gnus-display-mime
553 "Function to display MIME articles."
554 :group 'gnus-article-mime
557 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
558 "Function used to decode headers.")
560 (defvar gnus-article-dumbquotes-map
578 "Table for MS-to-Latin1 translation.")
580 (defcustom gnus-ignored-mime-types nil
581 "List of MIME types that should be ignored by Gnus."
582 :group 'gnus-article-mime
583 :type '(repeat regexp))
585 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
586 "List of MIME types that should not be given buttons when rendered."
587 :group 'gnus-article-mime
588 :type '(repeat regexp))
590 (defcustom gnus-article-mime-part-function nil
591 "Function called with a MIME handle as the argument.
592 This is meant for people who want to do something automatic based
593 on parts -- for instance, adding Vcard info to a database."
594 :group 'gnus-article-mime
598 ;;; The treatment variables
601 (defvar gnus-part-display-hook nil
602 "Hook called on parts that are to receive treatment.")
604 (defvar gnus-article-treat-custom
605 '(choice (const :tag "Off" nil)
607 (const :tag "Header" head)
608 (const :tag "Last" last)
609 (integer :tag "Less")
610 (sexp :tag "Predicate")))
612 (defvar gnus-article-treat-types '("text/plain")
615 (defvar gnus-inhibit-treatment nil
616 "Whether to inhibit treatment.")
618 (defcustom gnus-treat-highlight-signature '(or last (typep "text/x-vcard"))
619 "Highlight the signature."
620 :group 'gnus-article-treat
621 :type gnus-article-treat-custom)
623 (defcustom gnus-treat-buttonize t
625 :group 'gnus-article-treat
626 :type gnus-article-treat-custom)
628 (defcustom gnus-treat-buttonize-head 'head
629 "Add buttons to the head."
630 :group 'gnus-article-treat
631 :type gnus-article-treat-custom)
633 (defcustom gnus-treat-emphasize t
635 :group 'gnus-article-treat
636 :type gnus-article-treat-custom)
638 (defcustom gnus-treat-strip-cr nil
639 "Remove carriage returns."
640 :group 'gnus-article-treat
641 :type gnus-article-treat-custom)
643 (defcustom gnus-treat-hide-headers 'head
645 :group 'gnus-article-treat
646 :type gnus-article-treat-custom)
648 (defcustom gnus-treat-hide-boring-headers nil
649 "Hide boring headers."
650 :group 'gnus-article-treat
651 :type gnus-article-treat-custom)
653 (defcustom gnus-treat-hide-signature nil
654 "Hide the signature."
655 :group 'gnus-article-treat
656 :type gnus-article-treat-custom)
658 (defcustom gnus-treat-fill-article nil
660 :group 'gnus-article-treat
661 :type gnus-article-treat-custom)
663 (defcustom gnus-treat-hide-citation nil
665 :group 'gnus-article-treat
666 :type gnus-article-treat-custom)
668 (defcustom gnus-treat-strip-pgp t
669 "Strip PGP signatures."
670 :group 'gnus-article-treat
671 :type gnus-article-treat-custom)
673 (defcustom gnus-treat-strip-pem nil
674 "Strip PEM signatures."
675 :group 'gnus-article-treat
676 :type gnus-article-treat-custom)
678 (defcustom gnus-treat-strip-banner t
679 "Strip banners from articles.
680 The banner to be stripped is specified in the `banner' group parameter."
681 :group 'gnus-article-treat
682 :type gnus-article-treat-custom)
684 (defcustom gnus-treat-highlight-headers 'head
685 "Highlight the headers."
686 :group 'gnus-article-treat
687 :type gnus-article-treat-custom)
689 (defcustom gnus-treat-highlight-citation t
690 "Highlight cited text."
691 :group 'gnus-article-treat
692 :type gnus-article-treat-custom)
694 (defcustom gnus-treat-date-ut nil
695 "Display the Date in UT (GMT)."
696 :group 'gnus-article-treat
697 :type gnus-article-treat-custom)
699 (defcustom gnus-treat-date-local nil
700 "Display the Date in the local timezone."
701 :group 'gnus-article-treat
702 :type gnus-article-treat-custom)
704 (defcustom gnus-treat-date-lapsed nil
705 "Display the Date header in a way that says how much time has elapsed."
706 :group 'gnus-article-treat
707 :type gnus-article-treat-custom)
709 (defcustom gnus-treat-date-original nil
710 "Display the date in the original timezone."
711 :group 'gnus-article-treat
712 :type gnus-article-treat-custom)
714 (defcustom gnus-treat-date-iso8601 nil
715 "Display the date in the ISO8601 format."
716 :group 'gnus-article-treat
717 :type gnus-article-treat-custom)
719 (defcustom gnus-treat-date-user-defined nil
720 "Display the date in a user-defined format.
721 The format is defined by the `gnus-article-time-format' variable."
722 :group 'gnus-article-treat
723 :type gnus-article-treat-custom)
725 (defcustom gnus-treat-strip-trailing-blank-lines nil
726 "Strip trailing blank lines."
727 :group 'gnus-article-treat
728 :type gnus-article-treat-custom)
730 (defcustom gnus-treat-strip-leading-blank-lines nil
731 "Strip leading blank lines."
732 :group 'gnus-article-treat
733 :type gnus-article-treat-custom)
735 (defcustom gnus-treat-strip-multiple-blank-lines nil
736 "Strip multiple blank lines."
737 :group 'gnus-article-treat
738 :type gnus-article-treat-custom)
740 (defcustom gnus-treat-strip-blank-lines nil
741 "Strip all blank lines."
742 :group 'gnus-article-treat
743 :type gnus-article-treat-custom)
745 (defcustom gnus-treat-overstrike t
746 "Treat overstrike highlighting."
747 :group 'gnus-article-treat
748 :type gnus-article-treat-custom)
750 (defcustom gnus-treat-display-xface (if (and gnus-xemacs (featurep 'xface))
752 "Display X-Face headers."
753 :group 'gnus-article-treat
754 :type gnus-article-treat-custom)
756 (defcustom gnus-treat-display-smileys (if (and gnus-xemacs
760 :group 'gnus-article-treat
761 :type gnus-article-treat-custom)
763 (defcustom gnus-treat-display-picons (if gnus-xemacs 'head nil)
765 :group 'gnus-article-treat
766 :type gnus-article-treat-custom)
768 (defcustom gnus-treat-capitalize-sentences nil
769 "Capitalize sentence-starting words."
770 :group 'gnus-article-treat
771 :type gnus-article-treat-custom)
773 (defcustom gnus-treat-fill-long-lines nil
775 :group 'gnus-article-treat
776 :type gnus-article-treat-custom)
778 (defcustom gnus-treat-play-sounds nil
780 :group 'gnus-article-treat
781 :type gnus-article-treat-custom)
783 ;;; Internal variables
785 (defvar article-goto-body-goes-to-point-min-p nil)
786 (defvar gnus-article-wash-types nil)
788 (defvar gnus-article-mime-handle-alist-1 nil)
789 (defvar gnus-treatment-function-alist
790 '((gnus-treat-strip-banner gnus-article-strip-banner)
791 (gnus-treat-highlight-signature gnus-article-highlight-signature)
792 (gnus-treat-buttonize gnus-article-add-buttons)
793 (gnus-treat-fill-article gnus-article-fill-cited-article)
794 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
795 (gnus-treat-strip-cr gnus-article-remove-cr)
796 (gnus-treat-hide-headers gnus-article-hide-headers)
797 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
798 (gnus-treat-hide-signature gnus-article-hide-signature)
799 (gnus-treat-hide-citation gnus-article-hide-citation)
800 (gnus-treat-strip-pgp gnus-article-hide-pgp)
801 (gnus-treat-strip-pem gnus-article-hide-pem)
802 (gnus-treat-highlight-headers gnus-article-highlight-headers)
803 (gnus-treat-highlight-citation gnus-article-highlight-citation)
804 (gnus-treat-highlight-signature gnus-article-highlight-signature)
805 (gnus-treat-emphasize gnus-article-emphasize)
806 (gnus-treat-date-ut gnus-article-date-ut)
807 (gnus-treat-date-local gnus-article-date-local)
808 (gnus-treat-date-lapsed gnus-article-date-lapsed)
809 (gnus-treat-date-original gnus-article-date-original)
810 (gnus-treat-date-user-defined gnus-article-date-user)
811 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
812 (gnus-treat-strip-trailing-blank-lines
813 gnus-article-remove-trailing-blank-lines)
814 (gnus-treat-strip-leading-blank-lines
815 gnus-article-strip-leading-blank-lines)
816 (gnus-treat-strip-multiple-blank-lines
817 gnus-article-strip-multiple-blank-lines)
818 (gnus-treat-strip-blank-lines gnus-article-strip-blank-lines)
819 (gnus-treat-overstrike gnus-article-treat-overstrike)
820 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
821 (gnus-treat-display-xface gnus-article-display-x-face)
822 (gnus-treat-display-smileys gnus-smiley-display)
823 (gnus-treat-display-picons gnus-article-display-picons)
824 (gnus-treat-play-sounds gnus-earcon-display)))
826 (defvar gnus-article-mime-handle-alist nil)
827 (defvar article-lapsed-timer nil)
828 (defvar gnus-article-current-summary nil)
830 (defvar gnus-article-mode-syntax-table
831 (let ((table (copy-syntax-table text-mode-syntax-table)))
832 (modify-syntax-entry ?- "w" table)
833 (modify-syntax-entry ?> ")" table)
834 (modify-syntax-entry ?< "(" table)
836 "Syntax table used in article mode buffers.
837 Initialized from `text-mode-syntax-table.")
839 (defvar gnus-save-article-buffer nil)
841 (defvar gnus-article-mode-line-format-alist
842 (nconc '((?w (gnus-article-wash-status) ?s)
843 (?m (gnus-article-mime-part-status) ?s))
844 gnus-summary-mode-line-format-alist))
846 (defvar gnus-number-of-articles-to-be-saved nil)
848 (defvar gnus-inhibit-hiding nil)
850 (defsubst gnus-article-hide-text (b e props)
851 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
852 (add-text-properties b e props)
853 (when (memq 'intangible props)
855 (max (1- b) (point-min))
856 b 'intangible (cddr (memq 'intangible props)))))
858 (defmacro gnus-with-article (article &rest forms)
859 "Select ARTICLE and perform FORMS in the original article buffer.
860 Then replace the article with the result."
862 ;; We don't want the article to be marked as read.
863 (let (gnus-mark-article-hook)
864 (gnus-summary-select-article t t nil ,article))
865 (set-buffer gnus-original-article-buffer)
867 (if (not (gnus-check-backend-function
868 'request-replace-article (car gnus-article-current)))
869 (gnus-message 5 "Read-only group; not replacing")
870 (unless (gnus-request-replace-article
871 ,article (car gnus-article-current)
873 (error "Couldn't replace article")))
874 ;; The cache and backlog have to be flushed somewhat.
875 (when gnus-keep-backlog
876 (gnus-backlog-remove-article
877 (car gnus-article-current) (cdr gnus-article-current)))
879 (gnus-cache-update-article
880 (car gnus-article-current) (cdr gnus-article-current)))))
882 (put 'gnus-with-article 'lisp-indent-function 1)
883 (put 'gnus-with-article 'edebug-form-spec '(form body))
885 (defsubst gnus-article-unhide-text (b e)
886 "Remove hidden text properties from region between B and E."
887 (remove-text-properties b e gnus-hidden-properties)
888 (when (memq 'intangible gnus-hidden-properties)
889 (put-text-property (max (1- b) (point-min))
892 (defun gnus-article-hide-text-type (b e type)
893 "Hide text of TYPE between B and E."
894 (push type gnus-article-wash-types)
895 (gnus-article-hide-text
896 b e (cons 'article-type (cons type gnus-hidden-properties))))
898 (defun gnus-article-unhide-text-type (b e type)
899 "Unhide text of TYPE between B and E."
900 (setq gnus-article-wash-types
901 (delq type gnus-article-wash-types))
902 (remove-text-properties
903 b e (cons 'article-type (cons type gnus-hidden-properties)))
904 (when (memq 'intangible gnus-hidden-properties)
905 (put-text-property (max (1- b) (point-min))
908 (defun gnus-article-hide-text-of-type (type)
909 "Hide text of TYPE in the current buffer."
911 (let ((b (point-min))
913 (while (setq b (text-property-any b e 'article-type type))
914 (add-text-properties b (incf b) gnus-hidden-properties)))))
916 (defun gnus-article-delete-text-of-type (type)
917 "Delete text of TYPE in the current buffer."
919 (let ((b (point-min)))
920 (while (setq b (text-property-any b (point-max) 'article-type type))
922 b (or (text-property-not-all b (point-max) 'article-type type)
925 (defun gnus-article-delete-invisible-text ()
926 "Delete all invisible text in the current buffer."
928 (let ((b (point-min)))
929 (while (setq b (text-property-any b (point-max) 'invisible t))
931 b (or (text-property-not-all b (point-max) 'invisible t)
934 (defun gnus-article-text-type-exists-p (type)
935 "Say whether any text of type TYPE exists in the buffer."
936 (text-property-any (point-min) (point-max) 'article-type type))
938 (defsubst gnus-article-header-rank ()
939 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
940 (let ((list gnus-sorted-header-list)
943 (when (looking-at (car list))
945 (setq list (cdr list))
949 (defun article-hide-headers (&optional arg delete)
950 "Toggle whether to hide unwanted headers and possibly sort them as well.
951 If given a negative prefix, always show; if given a positive prefix,
953 (interactive (gnus-article-hidden-arg))
955 (if (gnus-article-check-hidden-text 'headers arg)
956 ;; Show boring headers as well.
957 (gnus-article-show-hidden-text 'boring-headers)
958 ;; This function might be inhibited.
959 (unless gnus-inhibit-hiding
962 (let ((buffer-read-only nil)
964 (props (nconc (list 'article-type 'headers)
965 gnus-hidden-properties))
966 (max (1+ (length gnus-sorted-header-list)))
967 (ignored (when (not gnus-visible-headers)
968 (cond ((stringp gnus-ignored-headers)
969 gnus-ignored-headers)
970 ((listp gnus-ignored-headers)
971 (mapconcat 'identity gnus-ignored-headers
974 (cond ((stringp gnus-visible-headers)
975 gnus-visible-headers)
976 ((and gnus-visible-headers
977 (listp gnus-visible-headers))
978 (mapconcat 'identity gnus-visible-headers "\\|"))))
979 (inhibit-point-motion-hooks t)
981 ;; First we narrow to just the headers.
982 (goto-char (point-min))
983 ;; Hide any "From " lines at the beginning of (mail) articles.
984 (while (looking-at "From ")
988 (delete-region (point-min) (point))
989 (gnus-article-hide-text (point-min) (point) props)))
990 ;; Then treat the rest of the header lines.
993 (if (search-forward "\n\n" nil t) ; if there's a body
994 (progn (forward-line -1) (point))
996 ;; Then we use the two regular expressions
997 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
998 ;; select which header lines is to remain visible in the
1000 (goto-char (point-min))
1001 (while (re-search-forward "^[^ \t]*:" nil t)
1003 ;; Mark the rank of the header.
1005 (point) (1+ (point)) 'message-rank
1006 (if (or (and visible (looking-at visible))
1008 (not (looking-at ignored))))
1009 (gnus-article-header-rank)
1012 (message-sort-headers-1)
1013 (when (setq beg (text-property-any
1014 (point-min) (point-max) 'message-rank (+ 2 max)))
1015 ;; We make the unwanted headers invisible.
1017 (delete-region beg (point-max))
1018 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
1019 (gnus-article-hide-text-type beg (point-max) 'headers))
1020 ;; Work around XEmacs lossage.
1021 (put-text-property (point-min) beg 'invisible nil))))))))
1023 (defun article-hide-boring-headers (&optional arg)
1024 "Toggle hiding of headers that aren't very interesting.
1025 If given a negative prefix, always show; if given a positive prefix,
1027 (interactive (gnus-article-hidden-arg))
1028 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1029 (not gnus-show-all-headers))
1032 (let ((buffer-read-only nil)
1033 (list gnus-boring-article-headers)
1034 (inhibit-point-motion-hooks t)
1036 (article-narrow-to-head)
1038 (setq elem (pop list))
1039 (goto-char (point-min))
1041 ;; Hide empty headers.
1043 (while (re-search-forward "^[^:]+:[ \t]*\n[^ \t]" nil t)
1045 (gnus-article-hide-text-type
1046 (progn (beginning-of-line) (point))
1049 (if (re-search-forward "^[^ \t]" nil t)
1053 ;; Hide boring Newsgroups header.
1054 ((eq elem 'newsgroups)
1055 (when (equal (gnus-fetch-field "newsgroups")
1056 (gnus-group-real-name
1057 (if (boundp 'gnus-newsgroup-name)
1060 (gnus-article-hide-header "newsgroups")))
1061 ((eq elem 'followup-to)
1062 (when (equal (message-fetch-field "followup-to")
1063 (message-fetch-field "newsgroups"))
1064 (gnus-article-hide-header "followup-to")))
1065 ((eq elem 'reply-to)
1066 (let ((from (message-fetch-field "from"))
1067 (reply-to (message-fetch-field "reply-to")))
1072 (nth 1 (mail-extract-address-components from))
1073 (nth 1 (mail-extract-address-components reply-to)))))
1074 (gnus-article-hide-header "reply-to"))))
1076 (let ((date (message-fetch-field "date")))
1078 (< (days-between (current-time-string) date)
1080 (gnus-article-hide-header "date"))))
1082 (let ((to (message-fetch-field "to")))
1083 (when (> (length to) 1024)
1084 (gnus-article-hide-header "to"))))
1087 (goto-char (point-min))
1088 (while (re-search-forward "^to:" nil t)
1089 (setq to-count (1+ to-count)))
1090 (when (> to-count 1)
1091 (while (> to-count 0)
1092 (goto-char (point-min))
1094 (re-search-forward "^to:" nil nil to-count)
1096 (narrow-to-region (point) (point-max))
1097 (gnus-article-hide-header "to"))
1098 (setq to-count (1- to-count)))))))))))))
1100 (defun gnus-article-hide-header (header)
1102 (goto-char (point-min))
1103 (when (re-search-forward (concat "^" header ":") nil t)
1104 (gnus-article-hide-text-type
1105 (progn (beginning-of-line) (point))
1108 (if (re-search-forward "^[^ \t]" nil t)
1113 (defvar gnus-article-normalized-header-length 40
1114 "Length of normalized headers.")
1116 (defun article-normalize-headers ()
1117 "Make all header lines 40 characters long."
1119 (let ((buffer-read-only nil)
1123 (article-narrow-to-head)
1126 ((< (setq column (- (gnus-point-at-eol) (point)))
1127 gnus-article-normalized-header-length)
1129 (insert (make-string
1130 (- gnus-article-normalized-header-length column)
1132 ((> column gnus-article-normalized-header-length)
1133 (gnus-put-text-property
1135 (forward-char gnus-article-normalized-header-length)
1142 (forward-line 1))))))
1144 (defun article-treat-dumbquotes ()
1145 "Translate M******** sm*rtq**t*s into proper text.
1146 Note that this function guesses whether a character is a sm*rtq**t* or
1147 not, so it should only be used interactively."
1149 (article-translate-strings gnus-article-dumbquotes-map))
1151 (defun article-translate-characters (from to)
1152 "Translate all characters in the body of the article according to FROM and TO.
1153 FROM is a string of characters to translate from; to is a string of
1154 characters to translate to."
1156 (when (article-goto-body)
1157 (let ((buffer-read-only nil)
1158 (x (make-string 225 ?x))
1160 (while (< (incf i) (length x))
1163 (while (< i (length from))
1164 (aset x (aref from i) (aref to i))
1166 (translate-region (point) (point-max) x)))))
1168 (defun article-translate-strings (map)
1169 "Translate all string in the body of the article according to MAP.
1170 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1172 (when (article-goto-body)
1173 (let ((buffer-read-only nil)
1175 (while (setq elem (pop map))
1177 (while (search-forward (car elem) nil t)
1178 (replace-match (cadr elem)))))))))
1180 (defun article-treat-overstrike ()
1181 "Translate overstrikes into bold text."
1184 (when (article-goto-body)
1185 (let ((buffer-read-only nil))
1186 (while (search-forward "\b" nil t)
1187 (let ((next (char-after))
1188 (previous (char-after (- (point) 2))))
1189 ;; We do the boldification/underlining by hiding the
1190 ;; overstrikes and putting the proper text property
1194 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1195 (put-text-property (point) (1+ (point)) 'face 'bold))
1197 (gnus-article-hide-text-type
1198 (1- (point)) (1+ (point)) 'overstrike)
1200 (- (point) 2) (1- (point)) 'face 'underline))
1202 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1204 (point) (1+ (point)) 'face 'underline)))))))))
1206 (defun article-fill-long-lines ()
1207 "Fill lines that are wider than the window width."
1210 (let ((buffer-read-only nil)
1211 (width (window-width (get-buffer-window (current-buffer)))))
1214 (let ((adaptive-fill-mode nil))
1217 (when (>= (current-column) (min fill-column width))
1218 (narrow-to-region (point) (gnus-point-at-bol))
1219 (fill-paragraph nil)
1220 (goto-char (point-max))
1222 (forward-line 1)))))))
1224 (defun article-capitalize-sentences ()
1225 "Capitalize the first word in each sentence."
1228 (let ((buffer-read-only nil)
1229 (paragraph-start "^[\n\^L]"))
1233 (forward-sentence)))))
1235 (defun article-remove-cr ()
1236 "Translate CRLF pairs into LF, and then CR into LF.."
1239 (let ((buffer-read-only nil))
1240 (goto-char (point-min))
1241 (while (search-forward "\r$" nil t)
1242 (replace-match "" t t))
1243 (goto-char (point-min))
1244 (while (search-forward "\r" nil t)
1245 (replace-match "\n" t t)))))
1247 (defun article-remove-trailing-blank-lines ()
1248 "Remove all trailing blank lines from the article."
1251 (let ((buffer-read-only nil))
1252 (goto-char (point-max))
1256 (while (and (not (bobp))
1257 (looking-at "^[ \t]*$")
1258 (not (gnus-annotation-in-region-p
1259 (point) (gnus-point-at-eol))))
1264 (defun article-display-x-face (&optional force)
1265 "Look for an X-Face header and display it if present."
1266 (interactive (list 'force))
1268 ;; Delete the old process, if any.
1269 (when (process-status "article-x-face")
1270 (delete-process "article-x-face"))
1271 (let ((inhibit-point-motion-hooks t)
1272 (case-fold-search t)
1275 (article-narrow-to-head)
1276 (goto-char (point-min))
1277 (setq from (message-fetch-field "from"))
1278 (goto-char (point-min))
1279 (while (and gnus-article-x-face-command
1282 ;; Check whether this face is censored.
1283 (not gnus-article-x-face-too-ugly)
1284 (and gnus-article-x-face-too-ugly from
1285 (not (string-match gnus-article-x-face-too-ugly
1287 ;; Has to be present.
1288 (re-search-forward "^X-Face: " nil t))
1289 ;; This used to try to do multiple faces (`while' instead of
1290 ;; `when' above), but (a) sending multiple EOFs to xv doesn't
1291 ;; work (b) it can crash some versions of Emacs (c) are
1292 ;; multiple faces really something to encourage?
1293 (when (stringp gnus-article-x-face-command)
1295 ;; We now have the area of the buffer where the X-Face is stored.
1298 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
1299 ;; We display the face.
1300 (if (symbolp gnus-article-x-face-command)
1301 ;; The command is a lisp function, so we call it.
1302 (if (gnus-functionp gnus-article-x-face-command)
1303 (funcall gnus-article-x-face-command beg end)
1304 (error "%s is not a function" gnus-article-x-face-command))
1305 ;; The command is a string, so we interpret the command
1306 ;; as a, well, command, and fork it off.
1307 (let ((process-connection-type nil))
1308 (process-kill-without-query
1310 "article-x-face" nil shell-file-name shell-command-switch
1311 gnus-article-x-face-command))
1312 (process-send-region "article-x-face" beg end)
1313 (process-send-eof "article-x-face"))))))))))
1315 (defun article-decode-mime-words ()
1316 "Decode all MIME-encoded words in the article."
1319 (set-buffer gnus-article-buffer)
1320 (let ((inhibit-point-motion-hooks t)
1322 (mail-parse-charset gnus-newsgroup-charset))
1323 (mail-decode-encoded-word-region (point-min) (point-max)))))
1325 (defun article-decode-charset (&optional prompt)
1326 "Decode charset-encoded text in the article.
1327 If PROMPT (the prefix), prompt for a coding system to use."
1331 (article-narrow-to-head)
1332 (let* ((inhibit-point-motion-hooks t)
1333 (case-fold-search t)
1334 (ct (message-fetch-field "Content-Type" t))
1335 (cte (message-fetch-field "Content-Transfer-Encoding" t))
1336 (ctl (and ct (ignore-errors
1337 (mail-header-parse-content-type ct))))
1340 (mm-read-coding-system "Charset to decode: "))
1342 (mail-content-type-get ctl 'charset))))
1343 (mail-parse-charset gnus-newsgroup-charset)
1345 (when (memq charset gnus-newsgroup-ignored-charsets)
1347 (goto-char (point-max))
1350 (narrow-to-region (point) (point-max))
1351 (when (and (or (not ctl)
1352 (equal (car ctl) "text/plain"))
1355 charset (and cte (intern (downcase
1356 (gnus-strip-whitespace cte))))
1359 (defun article-decode-encoded-words ()
1360 "Remove encoded-word encoding from headers."
1361 (let ((inhibit-point-motion-hooks t)
1362 (mail-parse-charset gnus-newsgroup-charset)
1365 (article-narrow-to-head)
1366 (funcall gnus-decode-header-function (point-min) (point-max)))))
1368 (defun article-de-quoted-unreadable (&optional force)
1369 "Translate a quoted-printable-encoded article.
1370 If FORCE, decode the article whether it is marked as quoted-printable
1372 (interactive (list 'force))
1374 (let ((buffer-read-only nil)
1375 (type (gnus-fetch-field "content-transfer-encoding"))
1376 (charset gnus-newsgroup-charset))
1378 (and type (string-match "quoted-printable" (downcase type))))
1381 (narrow-to-region (point) (point-max))
1382 (quoted-printable-decode-region (point-min) (point-max))
1384 (mm-decode-body charset)))))))
1386 (defun article-hide-pgp ()
1387 "Remove any PGP headers and signatures in the current article."
1391 (let ((inhibit-point-motion-hooks t)
1392 buffer-read-only beg end)
1394 ;; Hide the "header".
1395 (when (re-search-forward "^-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
1396 (push 'pgp gnus-article-wash-types)
1397 (delete-region (match-beginning 0) (match-end 0))
1398 ;; PGP 5 and GNU PG add a `Hash: <>' comment, hide that too
1399 (when (looking-at "Hash:.*$")
1400 (delete-region (point) (1+ (gnus-point-at-eol))))
1402 ;; Hide the actual signature.
1403 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
1404 (setq end (1+ (match-beginning 0)))
1407 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
1409 ;; Perhaps we shouldn't hide to the end of the buffer
1410 ;; if there is no end to the signature?
1412 ;; Hide "- " PGP quotation markers.
1414 (narrow-to-region beg end)
1415 (goto-char (point-min))
1416 (while (re-search-forward "^- " nil t)
1418 (match-beginning 0) (match-end 0)))
1420 (gnus-run-hooks 'gnus-article-hide-pgp-hook))))))
1422 (defun article-hide-pem (&optional arg)
1423 "Toggle hiding of any PEM headers and signatures in the current article.
1424 If given a negative prefix, always show; if given a positive prefix,
1426 (interactive (gnus-article-hidden-arg))
1427 (unless (gnus-article-check-hidden-text 'pem arg)
1429 (let (buffer-read-only end)
1430 (goto-char (point-min))
1431 ;; Hide the horrendously ugly "header".
1432 (when (and (search-forward
1433 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
1435 (setq end (1+ (match-beginning 0))))
1436 (push 'pem gnus-article-wash-types)
1437 (gnus-article-hide-text-type
1439 (if (search-forward "\n\n" nil t)
1443 ;; Hide the trailer as well
1444 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
1446 (gnus-article-hide-text-type
1447 (match-beginning 0) (match-end 0) 'pem)))))))
1449 (defun article-strip-banner ()
1450 "Strip the banner specified by the `banner' group parameter."
1454 (let ((inhibit-point-motion-hooks t)
1455 (banner (gnus-group-get-parameter gnus-newsgroup-name 'banner))
1456 (gnus-signature-limit nil)
1457 buffer-read-only beg end)
1461 ((eq banner 'signature)
1462 (when (gnus-article-narrow-to-signature)
1465 (delete-region (point) (point-max))))
1467 (while (re-search-forward banner nil t)
1468 (delete-region (match-beginning 0) (match-end 0))))))))))
1470 (defun article-hide-signature (&optional arg)
1471 "Hide the signature in the current article.
1472 If given a negative prefix, always show; if given a positive prefix,
1474 (interactive (gnus-article-hidden-arg))
1475 (unless (gnus-article-check-hidden-text 'signature arg)
1478 (let ((buffer-read-only nil))
1479 (when (gnus-article-narrow-to-signature)
1480 (gnus-article-hide-text-type
1481 (point-min) (point-max) 'signature)))))))
1483 (defun article-strip-leading-blank-lines ()
1484 "Remove all blank lines from the beginning of the article."
1487 (let ((inhibit-point-motion-hooks t)
1489 (when (article-goto-body)
1490 (while (and (not (eobp))
1491 (looking-at "[ \t]*$"))
1492 (gnus-delete-line))))))
1494 (defun article-narrow-to-head ()
1495 "Narrow the buffer to the head of the message.
1496 Point is left at the beginning of the narrowed-to region."
1498 (goto-char (point-min))
1499 (if (search-forward "\n\n" nil 1)
1502 (goto-char (point-min)))
1504 (defun article-goto-body ()
1505 "Place point at the start of the body."
1506 (goto-char (point-min))
1508 ;; This variable is only bound when dealing with separate
1510 (article-goto-body-goes-to-point-min-p
1512 ((search-forward "\n\n" nil t)
1515 (goto-char (point-max))
1518 (defun article-strip-multiple-blank-lines ()
1519 "Replace consecutive blank lines with one empty line."
1522 (let ((inhibit-point-motion-hooks t)
1524 ;; First make all blank lines empty.
1526 (while (re-search-forward "^[ \t]+$" nil t)
1527 (unless (gnus-annotation-in-region-p
1528 (match-beginning 0) (match-end 0))
1529 (replace-match "" nil t)))
1530 ;; Then replace multiple empty lines with a single empty line.
1532 (while (re-search-forward "\n\n\n+" nil t)
1533 (unless (gnus-annotation-in-region-p
1534 (match-beginning 0) (match-end 0))
1535 (replace-match "\n\n" t t))))))
1537 (defun article-strip-leading-space ()
1538 "Remove all white space from the beginning of the lines in the article."
1541 (let ((inhibit-point-motion-hooks t)
1544 (while (re-search-forward "^[ \t]+" nil t)
1545 (replace-match "" t t)))))
1547 (defun article-strip-trailing-space ()
1548 "Remove all white space from the end of the lines in the article."
1551 (let ((inhibit-point-motion-hooks t)
1554 (while (re-search-forward "[ \t]+$" nil t)
1555 (replace-match "" t t)))))
1557 (defun article-strip-blank-lines ()
1558 "Strip leading, trailing and multiple blank lines."
1560 (article-strip-leading-blank-lines)
1561 (article-remove-trailing-blank-lines)
1562 (article-strip-multiple-blank-lines))
1564 (defun article-strip-all-blank-lines ()
1565 "Strip all blank lines."
1568 (let ((inhibit-point-motion-hooks t)
1571 (while (re-search-forward "^[ \t]*\n" nil t)
1572 (replace-match "" t t)))))
1574 (defun gnus-article-narrow-to-signature ()
1575 "Narrow to the signature; return t if a signature is found, else nil."
1576 (let ((inhibit-point-motion-hooks t))
1577 (when (gnus-article-search-signature)
1579 ;; Check whether we have some limits to what we consider
1580 ;; to be a signature.
1581 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
1582 (list gnus-signature-limit)))
1584 (while (setq limit (pop limits))
1585 (if (or (and (integerp limit)
1586 (< (- (point-max) (point)) limit))
1588 (< (count-lines (point) (point-max)) limit))
1589 (and (gnus-functionp limit)
1591 (and (stringp limit)
1592 (not (re-search-forward limit nil t))))
1593 () ; This limit did not succeed.
1597 (narrow-to-region (point) (point-max))
1600 (defun gnus-article-search-signature ()
1601 "Search the current buffer for the signature separator.
1602 Put point at the beginning of the signature separator."
1603 (let ((cur (point)))
1604 (goto-char (point-max))
1605 (if (if (stringp gnus-signature-separator)
1606 (re-search-backward gnus-signature-separator nil t)
1607 (let ((seps gnus-signature-separator))
1609 (not (re-search-backward (car seps) nil t)))
1616 (defun gnus-article-hidden-arg ()
1617 "Return the current prefix arg as a number, or 0 if no prefix."
1618 (list (if current-prefix-arg
1619 (prefix-numeric-value current-prefix-arg)
1622 (defun gnus-article-check-hidden-text (type arg)
1623 "Return nil if hiding is necessary.
1624 Arg can be nil or a number. Nil and positive means hide, negative
1625 means show, 0 means toggle."
1628 (let ((hide (gnus-article-hidden-text-p type)))
1634 (gnus-article-show-hidden-text type))
1636 (if (eq hide 'hidden)
1637 (gnus-article-show-hidden-text type)
1640 (defun gnus-article-hidden-text-p (type)
1641 "Say whether the current buffer contains hidden text of type TYPE."
1642 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
1644 (not (get-text-property pos 'invisible)))
1646 (text-property-any (1+ pos) (point-max) 'article-type type)))
1651 (defun gnus-article-show-hidden-text (type &optional hide)
1652 "Show all hidden text of type TYPE.
1653 If HIDE, hide the text instead."
1655 (let ((buffer-read-only nil)
1656 (inhibit-point-motion-hooks t)
1659 (while (setq beg (text-property-any end (point-max) 'article-type type))
1662 (text-property-not-all beg (point-max) 'article-type type)
1665 (gnus-article-hide-text beg end gnus-hidden-properties)
1666 (gnus-article-unhide-text beg end))
1670 (defconst article-time-units
1671 `((year . ,(* 365.25 24 60 60))
1672 (week . ,(* 7 24 60 60))
1673 (day . ,(* 24 60 60))
1677 "Mapping from time units to seconds.")
1679 (defun article-date-ut (&optional type highlight header)
1680 "Convert DATE date to universal time in the current article.
1681 If TYPE is `local', convert to local time; if it is `lapsed', output
1682 how much time has lapsed since DATE."
1683 (interactive (list 'ut t))
1684 (let* ((header (or header
1685 (mail-header-date (save-excursion
1686 (set-buffer gnus-summary-buffer)
1687 gnus-current-headers))
1688 (message-fetch-field "date")
1690 (date (if (vectorp header) (mail-header-date header)
1692 (date-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
1693 (inhibit-point-motion-hooks t)
1694 bface eface newline)
1695 (when (and date (not (string= date "")))
1698 (article-narrow-to-head)
1699 (let ((buffer-read-only nil))
1700 ;; Delete any old Date headers.
1701 (if (re-search-forward date-regexp nil t)
1703 (setq bface (get-text-property (gnus-point-at-bol) 'face)
1704 eface (get-text-property (1- (gnus-point-at-eol))
1706 (delete-region (progn (beginning-of-line) (point))
1707 (progn (end-of-line) (point)))
1708 (beginning-of-line))
1709 (goto-char (point-max))
1711 (insert (article-make-date-line date type))
1714 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
1715 (put-text-property (match-beginning 1) (1+ (match-end 1))
1717 (put-text-property (match-beginning 2) (match-end 2)
1721 (insert "\n"))))))))
1723 (defun article-make-date-line (date type)
1724 "Return a DATE line of TYPE."
1725 (let ((time (condition-case ()
1729 ;; Convert to the local timezone. We have to slap a
1730 ;; `condition-case' round the calls to the timezone
1731 ;; functions since they aren't particularly resistant to
1734 (let ((tz (car (current-time-zone))))
1735 (format "Date: %s %s%04d" (current-time-string time)
1736 (if (> tz 0) "+" "-") (abs (/ tz 36)))))
1737 ;; Convert to Universal Time.
1740 (current-time-string
1741 (let* ((e (parse-time-string date))
1742 (tm (apply 'encode-time e))
1744 (ls (- (cadr tm) (car (current-time-zone)))))
1745 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
1746 ((> ls 65535) (list (1+ ms) (- ls 65536)))
1749 ;; Get the original date from the article.
1750 ((eq type 'original)
1751 (concat "Date: " (if (string-match "\n+$" date)
1752 (substring date 0 (match-beginning 0))
1754 ;; Let the user define the format.
1756 (if (gnus-functionp gnus-article-time-format)
1757 (funcall gnus-article-time-format time)
1760 (format-time-string gnus-article-time-format time))))
1765 (format-time-string "%Y%m%dT%H%M%S" time)))
1766 ;; Do an X-Sent lapsed format.
1768 ;; If the date is seriously mangled, the timezone functions are
1769 ;; liable to bug out, so we ignore all errors.
1770 (let* ((now (current-time))
1771 (real-time (subtract-time now time))
1772 (real-sec (and real-time
1773 (+ (* (float (car real-time)) 65536)
1775 (sec (and real-time (abs real-sec)))
1785 ;; This is a bit convoluted, but basically we go
1786 ;; through the time units for years, weeks, etc,
1787 ;; and divide things to see whether that results
1788 ;; in positive answers.
1791 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
1792 ;; The (remaining) seconds are too few to
1793 ;; be divided into this time unit.
1795 ;; It's big enough, so we output it.
1796 (setq sec (- sec (* num (cdr unit))))
1798 (concat (if prev ", " "") (int-to-string
1800 " " (symbol-name (car unit))
1801 (if (> num 1) "s" ""))
1803 article-time-units "")
1804 ;; If dates are odd, then it might appear like the
1805 ;; article was sent in the future.
1808 " in the future"))))))
1810 (error "Unknown conversion type: %s" type)))))
1812 (defun article-date-local (&optional highlight)
1813 "Convert the current article date to the local timezone."
1814 (interactive (list t))
1815 (article-date-ut 'local highlight))
1817 (defun article-date-original (&optional highlight)
1818 "Convert the current article date to what it was originally.
1819 This is only useful if you have used some other date conversion
1820 function and want to see what the date was before converting."
1821 (interactive (list t))
1822 (article-date-ut 'original highlight))
1824 (defun article-date-lapsed (&optional highlight)
1825 "Convert the current article date to time lapsed since it was sent."
1826 (interactive (list t))
1827 (article-date-ut 'lapsed highlight))
1829 (defun article-update-date-lapsed ()
1830 "Function to be run from a timer to update the lapsed time line."
1831 (let (deactivate-mark)
1836 (set-buffer (window-buffer w))
1837 (when (eq major-mode 'gnus-article-mode)
1838 (goto-char (point-min))
1839 (when (re-search-forward "^X-Sent:" nil t)
1840 (article-date-lapsed t))))
1843 (defun gnus-start-date-timer (&optional n)
1844 "Start a timer to update the X-Sent header in the article buffers.
1845 The numerical prefix says how frequently (in seconds) the function
1850 (gnus-stop-date-timer)
1851 (setq article-lapsed-timer
1852 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
1854 (defun gnus-stop-date-timer ()
1855 "Stop the X-Sent timer."
1857 (when article-lapsed-timer
1858 (nnheader-cancel-timer article-lapsed-timer)
1859 (setq article-lapsed-timer nil)))
1861 (defun article-date-user (&optional highlight)
1862 "Convert the current article date to the user-defined format.
1863 This format is defined by the `gnus-article-time-format' variable."
1864 (interactive (list t))
1865 (article-date-ut 'user highlight))
1867 (defun article-date-iso8601 (&optional highlight)
1868 "Convert the current article date to ISO8601."
1869 (interactive (list t))
1870 (article-date-ut 'iso8601 highlight))
1872 (defun article-show-all ()
1873 "Show all hidden text in the article buffer."
1876 (let ((buffer-read-only nil))
1877 (gnus-article-unhide-text (point-min) (point-max)))))
1879 (defun article-emphasize (&optional arg)
1880 "Emphasize text according to `gnus-emphasis-alist'."
1881 (interactive (gnus-article-hidden-arg))
1882 (unless (gnus-article-check-hidden-text 'emphasis arg)
1884 (let ((alist gnus-emphasis-alist)
1885 (buffer-read-only nil)
1886 (props (append '(article-type emphasis)
1887 gnus-hidden-properties))
1888 regexp elem beg invisible visible face)
1891 (while (setq elem (pop alist))
1893 (setq regexp (car elem)
1894 invisible (nth 1 elem)
1895 visible (nth 2 elem)
1897 (while (re-search-forward regexp nil t)
1898 (when (and (match-beginning visible) (match-beginning invisible))
1899 (gnus-article-hide-text
1900 (match-beginning invisible) (match-end invisible) props)
1901 (gnus-article-unhide-text-type
1902 (match-beginning visible) (match-end visible) 'emphasis)
1903 (gnus-put-text-property-excluding-newlines
1904 (match-beginning visible) (match-end visible) 'face face)
1905 (goto-char (match-end invisible)))))))))
1907 (defvar gnus-summary-article-menu)
1908 (defvar gnus-summary-post-menu)
1910 ;;; Saving functions.
1912 (defun gnus-article-save (save-buffer file &optional num)
1913 "Save the currently selected article."
1914 (unless gnus-save-all-headers
1915 ;; Remove headers according to `gnus-saved-headers'.
1916 (let ((gnus-visible-headers
1917 (or gnus-saved-headers gnus-visible-headers))
1918 (gnus-article-buffer save-buffer))
1920 (set-buffer save-buffer)
1921 (article-hide-headers 1 t))))
1922 (save-window-excursion
1923 (if (not gnus-default-article-saver)
1924 (error "No default saver is defined")
1925 ;; !!! Magic! The saving functions all save
1926 ;; `gnus-save-article-buffer' (or so they think), but we
1927 ;; bind that variable to our save-buffer.
1928 (set-buffer gnus-article-buffer)
1929 (let* ((gnus-save-article-buffer save-buffer)
1932 ((not gnus-prompt-before-saving) 'default)
1933 ((eq gnus-prompt-before-saving 'always) nil)
1935 (gnus-number-of-articles-to-be-saved
1936 (when (eq gnus-prompt-before-saving t)
1938 (set-buffer gnus-article-current-summary)
1939 (funcall gnus-default-article-saver filename)))))
1941 (defun gnus-read-save-file-name (prompt &optional filename
1942 function group headers variable)
1944 (funcall function group headers (symbol-value variable)))
1949 ((eq filename 'default)
1955 (let* ((split-name (gnus-get-split-value gnus-split-methods))
1958 (if (and gnus-number-of-articles-to-be-saved
1959 (> gnus-number-of-articles-to-be-saved 1))
1960 (format "these %d articles"
1961 gnus-number-of-articles-to-be-saved)
1964 ;; Let the split methods have their say.
1966 ;; No split name was found.
1969 (concat prompt " (default "
1970 (file-name-nondirectory default-name) ") ")
1971 (file-name-directory default-name)
1973 ;; A single group name is returned.
1974 ((stringp split-name)
1976 (funcall function split-name headers
1977 (symbol-value variable)))
1979 (concat prompt " (default "
1980 (file-name-nondirectory default-name) ") ")
1981 (file-name-directory default-name)
1983 ;; A single split name was found
1984 ((= 1 (length split-name))
1985 (let* ((name (expand-file-name
1986 (car split-name) gnus-article-save-directory))
1987 (dir (cond ((file-directory-p name)
1988 (file-name-as-directory name))
1989 ((file-exists-p name) name)
1990 (t gnus-article-save-directory))))
1992 (concat prompt " (default " name ") ")
1994 ;; A list of splits was found.
1996 (setq split-name (nreverse split-name))
1998 (let ((file-name-history
1999 (nconc split-name file-name-history)))
2003 (concat prompt " (`M-p' for defaults) ")
2004 gnus-article-save-directory
2006 gnus-article-save-directory)))
2007 (car (push result file-name-history)))))))
2008 ;; Create the directory.
2009 (gnus-make-directory (file-name-directory file))
2010 ;; If we have read a directory, we append the default file name.
2011 (when (file-directory-p file)
2012 (setq file (concat (file-name-as-directory file)
2013 (file-name-nondirectory default-name))))
2014 ;; Possibly translate some characters.
2015 (nnheader-translate-file-chars file)))))
2016 (gnus-make-directory (file-name-directory result))
2017 (set variable result)))
2019 (defun gnus-article-archive-name (group)
2020 "Return the first instance of an \"Archive-name\" in the current buffer."
2021 (let ((case-fold-search t))
2022 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
2023 (nnheader-concat gnus-article-save-directory
2024 (match-string 1)))))
2026 (defun gnus-article-nndoc-name (group)
2027 "If GROUP is an nndoc group, return the name of the parent group."
2028 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
2029 (gnus-group-get-parameter group 'save-article-group)))
2031 (defun gnus-summary-save-in-rmail (&optional filename)
2032 "Append this article to Rmail file.
2033 Optional argument FILENAME specifies file name.
2034 Directory to save to is default to `gnus-article-save-directory'."
2035 (setq filename (gnus-read-save-file-name
2036 "Save %s in rmail file:" filename
2037 gnus-rmail-save-name gnus-newsgroup-name
2038 gnus-current-headers 'gnus-newsgroup-last-rmail))
2039 (gnus-eval-in-buffer-window gnus-save-article-buffer
2043 (gnus-output-to-rmail filename))))
2046 (defun gnus-summary-save-in-mail (&optional filename)
2047 "Append this article to Unix mail file.
2048 Optional argument FILENAME specifies file name.
2049 Directory to save to is default to `gnus-article-save-directory'."
2050 (setq filename (gnus-read-save-file-name
2051 "Save %s in Unix mail file:" filename
2052 gnus-mail-save-name gnus-newsgroup-name
2053 gnus-current-headers 'gnus-newsgroup-last-mail))
2054 (gnus-eval-in-buffer-window gnus-save-article-buffer
2058 (if (and (file-readable-p filename)
2059 (mail-file-babyl-p filename))
2060 (rmail-output-to-rmail-file filename t)
2061 (gnus-output-to-mail filename)))))
2064 (defun gnus-summary-save-in-file (&optional filename overwrite)
2065 "Append this article to file.
2066 Optional argument FILENAME specifies file name.
2067 Directory to save to is default to `gnus-article-save-directory'."
2068 (setq filename (gnus-read-save-file-name
2069 "Save %s in file:" filename
2070 gnus-file-save-name gnus-newsgroup-name
2071 gnus-current-headers 'gnus-newsgroup-last-file))
2072 (gnus-eval-in-buffer-window gnus-save-article-buffer
2076 (when (and overwrite
2077 (file-exists-p filename))
2078 (delete-file filename))
2079 (gnus-output-to-file filename))))
2082 (defun gnus-summary-write-to-file (&optional filename)
2083 "Write this article to a file.
2084 Optional argument FILENAME specifies file name.
2085 The directory to save in defaults to `gnus-article-save-directory'."
2086 (gnus-summary-save-in-file nil t))
2088 (defun gnus-summary-save-body-in-file (&optional filename)
2089 "Append this article body to a file.
2090 Optional argument FILENAME specifies file name.
2091 The directory to save in defaults to `gnus-article-save-directory'."
2092 (setq filename (gnus-read-save-file-name
2093 "Save %s body in file:" filename
2094 gnus-file-save-name gnus-newsgroup-name
2095 gnus-current-headers 'gnus-newsgroup-last-file))
2096 (gnus-eval-in-buffer-window gnus-save-article-buffer
2100 (when (article-goto-body)
2101 (narrow-to-region (point) (point-max)))
2102 (gnus-output-to-file filename))))
2105 (defun gnus-summary-save-in-pipe (&optional command)
2106 "Pipe this article to subprocess."
2108 (cond ((and (eq command 'default)
2109 gnus-last-shell-command)
2110 gnus-last-shell-command)
2114 "Shell command on %s: "
2115 (if (and gnus-number-of-articles-to-be-saved
2116 (> gnus-number-of-articles-to-be-saved 1))
2117 (format "these %d articles"
2118 gnus-number-of-articles-to-be-saved)
2120 gnus-last-shell-command))))
2121 (when (string-equal command "")
2122 (setq command gnus-last-shell-command))
2123 (gnus-eval-in-buffer-window gnus-article-buffer
2126 (shell-command-on-region (point-min) (point-max) command nil)))
2127 (setq gnus-last-shell-command command))
2129 ;;; Article file names when saving.
2131 (defun gnus-capitalize-newsgroup (newsgroup)
2132 "Capitalize NEWSGROUP name."
2133 (when (not (zerop (length newsgroup)))
2134 (concat (char-to-string (upcase (aref newsgroup 0)))
2135 (substring newsgroup 1))))
2137 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2138 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2139 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
2140 Otherwise, it is like ~/News/news/group/num."
2143 (concat (if (gnus-use-long-file-name 'not-save)
2144 (gnus-capitalize-newsgroup newsgroup)
2145 (gnus-newsgroup-directory-form newsgroup))
2146 "/" (int-to-string (mail-header-number headers)))
2147 gnus-article-save-directory)))
2149 (string-equal (file-name-directory default)
2150 (file-name-directory last-file))
2151 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2153 (or last-file default))))
2155 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2156 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2157 If variable `gnus-use-long-file-name' is non-nil, it is
2158 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2161 (concat (if (gnus-use-long-file-name 'not-save)
2163 (gnus-newsgroup-directory-form newsgroup))
2164 "/" (int-to-string (mail-header-number headers)))
2165 gnus-article-save-directory)))
2167 (string-equal (file-name-directory default)
2168 (file-name-directory last-file))
2169 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2171 (or last-file default))))
2173 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
2174 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2175 If variable `gnus-use-long-file-name' is non-nil, it is
2176 ~/News/News.group. Otherwise, it is like ~/News/news/group/news."
2179 (if (gnus-use-long-file-name 'not-save)
2180 (gnus-capitalize-newsgroup newsgroup)
2181 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2182 gnus-article-save-directory)))
2184 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2185 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2186 If variable `gnus-use-long-file-name' is non-nil, it is
2187 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2190 (if (gnus-use-long-file-name 'not-save)
2192 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2193 gnus-article-save-directory)))
2200 (setq afunc (car func)
2203 gfunc (intern (format "gnus-%s" func))))
2205 (if (not (fboundp afunc))
2207 `(lambda (&optional interactive &rest args)
2208 ,(documentation afunc t)
2209 (interactive (list t))
2211 (set-buffer gnus-article-buffer)
2213 (call-interactively ',afunc)
2214 (apply ',afunc args))))))))
2215 '(article-hide-headers
2216 article-hide-boring-headers
2217 article-treat-overstrike
2218 article-fill-long-lines
2219 article-capitalize-sentences
2221 article-display-x-face
2222 article-de-quoted-unreadable
2223 article-mime-decode-quoted-printable
2225 article-strip-banner
2227 article-hide-signature
2228 article-remove-trailing-blank-lines
2229 article-strip-leading-blank-lines
2230 article-strip-multiple-blank-lines
2231 article-strip-leading-space
2232 article-strip-trailing-space
2233 article-strip-blank-lines
2234 article-strip-all-blank-lines
2236 article-date-iso8601
2237 article-date-original
2239 article-decode-mime-words
2240 article-decode-charset
2241 article-decode-encoded-words
2245 article-treat-dumbquotes
2246 article-normalize-headers
2247 (article-show-all . gnus-article-show-all-headers))))
2250 ;;; Gnus article mode
2253 (put 'gnus-article-mode 'mode-class 'special)
2255 (set-keymap-parent gnus-article-mode-map widget-keymap)
2257 (gnus-define-keys gnus-article-mode-map
2258 " " gnus-article-goto-next-page
2259 "\177" gnus-article-goto-prev-page
2260 [delete] gnus-article-goto-prev-page
2261 [backspace] gnus-article-goto-prev-page
2262 "\C-c^" gnus-article-refer-article
2263 "h" gnus-article-show-summary
2264 "s" gnus-article-show-summary
2265 "\C-c\C-m" gnus-article-mail
2266 "?" gnus-article-describe-briefly
2267 "e" gnus-article-edit
2268 "<" beginning-of-buffer
2270 "\C-c\C-i" gnus-info-find-node
2273 "\C-d" gnus-article-read-summary-keys
2274 "\M-*" gnus-article-read-summary-keys
2275 "\M-#" gnus-article-read-summary-keys
2276 "\M-^" gnus-article-read-summary-keys
2277 "\M-g" gnus-article-read-summary-keys)
2279 (substitute-key-definition
2280 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
2282 (defun gnus-article-make-menu-bar ()
2283 (gnus-turn-off-edit-menu 'article)
2284 (unless (boundp 'gnus-article-article-menu)
2286 gnus-article-article-menu gnus-article-mode-map ""
2288 ["Scroll forwards" gnus-article-goto-next-page t]
2289 ["Scroll backwards" gnus-article-goto-prev-page t]
2290 ["Show summary" gnus-article-show-summary t]
2291 ["Fetch Message-ID at point" gnus-article-refer-article t]
2292 ["Mail to address at point" gnus-article-mail t]
2293 ["Send a bug report" gnus-bug t]))
2296 gnus-article-treatment-menu gnus-article-mode-map ""
2298 ["Hide headers" gnus-article-hide-headers t]
2299 ["Hide signature" gnus-article-hide-signature t]
2300 ["Hide citation" gnus-article-hide-citation t]
2301 ["Treat overstrike" gnus-article-treat-overstrike t]
2302 ["Remove carriage return" gnus-article-remove-cr t]
2303 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]))
2305 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
2307 (when (boundp 'gnus-summary-post-menu)
2308 (define-key gnus-article-mode-map [menu-bar post]
2309 (cons "Post" gnus-summary-post-menu)))
2311 (gnus-run-hooks 'gnus-article-menu-hook)))
2313 (defun gnus-article-mode ()
2314 "Major mode for displaying an article.
2316 All normal editing commands are switched off.
2318 The following commands are available in addition to all summary mode
2320 \\<gnus-article-mode-map>
2321 \\[gnus-article-next-page]\t Scroll the article one page forwards
2322 \\[gnus-article-prev-page]\t Scroll the article one page backwards
2323 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
2324 \\[gnus-article-show-summary]\t Display the summary buffer
2325 \\[gnus-article-mail]\t Send a reply to the address near point
2326 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
2327 \\[gnus-info-find-node]\t Go to the Gnus info node"
2329 (when (gnus-visual-p 'article-menu 'menu)
2330 (gnus-article-make-menu-bar))
2331 (gnus-simplify-mode-line)
2332 (setq mode-name "Article")
2333 (setq major-mode 'gnus-article-mode)
2334 (make-local-variable 'minor-mode-alist)
2335 (use-local-map gnus-article-mode-map)
2336 (gnus-update-format-specifications nil 'article-mode)
2337 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
2338 (make-local-variable 'gnus-page-broken)
2339 (make-local-variable 'gnus-button-marker-list)
2340 (make-local-variable 'gnus-article-current-summary)
2341 (make-local-variable 'gnus-article-mime-handles)
2342 (make-local-variable 'gnus-article-decoded-p)
2343 (make-local-variable 'gnus-article-mime-handle-alist)
2344 (make-local-variable 'gnus-article-washed-types)
2345 (gnus-set-default-directory)
2346 (buffer-disable-undo)
2347 (setq buffer-read-only t)
2348 (set-syntax-table gnus-article-mode-syntax-table)
2349 (mm-enable-multibyte)
2350 (gnus-run-hooks 'gnus-article-mode-hook))
2352 (defun gnus-article-setup-buffer ()
2353 "Initialize the article buffer."
2354 (let* ((name (if gnus-single-article-buffer "*Article*"
2355 (concat "*Article " gnus-newsgroup-name "*")))
2357 (progn (string-match "\\*Article" name)
2358 (concat " *Original Article"
2359 (substring name (match-end 0))))))
2360 (setq gnus-article-buffer name)
2361 (setq gnus-original-article-buffer original)
2362 (setq gnus-article-mime-handle-alist nil)
2363 ;; This might be a variable local to the summary buffer.
2364 (unless gnus-single-article-buffer
2366 (set-buffer gnus-summary-buffer)
2367 (setq gnus-article-buffer name)
2368 (setq gnus-original-article-buffer original)
2369 (gnus-set-global-variables)))
2370 ;; Init original article buffer.
2372 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
2373 (mm-enable-multibyte)
2374 (setq major-mode 'gnus-original-article-mode)
2375 (make-local-variable 'gnus-original-article))
2376 (if (get-buffer name)
2379 (buffer-disable-undo)
2380 (setq buffer-read-only t)
2381 (unless (eq major-mode 'gnus-article-mode)
2382 (gnus-article-mode))
2385 (set-buffer (gnus-get-buffer-create name))
2387 (make-local-variable 'gnus-summary-buffer)
2388 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2389 (current-buffer)))))
2391 ;; Set article window start at LINE, where LINE is the number of lines
2392 ;; from the head of the article.
2393 (defun gnus-article-set-window-start (&optional line)
2395 (get-buffer-window gnus-article-buffer t)
2397 (set-buffer gnus-article-buffer)
2398 (goto-char (point-min))
2401 (gnus-message 6 "Moved to bookmark")
2402 (search-forward "\n\n" nil t)
2406 (defun gnus-article-prepare (article &optional all-headers header)
2407 "Prepare ARTICLE in article mode buffer.
2408 ARTICLE should either be an article number or a Message-ID.
2409 If ARTICLE is an id, HEADER should be the article headers.
2410 If ALL-HEADERS is non-nil, no headers are hidden."
2412 ;; Make sure we start in a summary buffer.
2413 (unless (eq major-mode 'gnus-summary-mode)
2414 (set-buffer gnus-summary-buffer))
2415 (setq gnus-summary-buffer (current-buffer))
2416 (let* ((gnus-article (if header (mail-header-number header) article))
2417 (summary-buffer (current-buffer))
2418 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
2419 (group gnus-newsgroup-name)
2422 (gnus-article-setup-buffer)
2423 (set-buffer gnus-article-buffer)
2424 ;; Deactivate active regions.
2425 (when (and (boundp 'transient-mark-mode)
2426 transient-mark-mode)
2427 (setq mark-active nil))
2428 (if (not (setq result (let ((buffer-read-only nil))
2429 (gnus-request-article-this-buffer
2431 ;; There is no such article.
2433 (when (and (numberp article)
2434 (not (memq article gnus-newsgroup-sparse)))
2435 (setq gnus-article-current
2436 (cons gnus-newsgroup-name article))
2437 (set-buffer gnus-summary-buffer)
2438 (setq gnus-current-article article)
2439 (if (eq (gnus-article-mark article) gnus-undownloaded-mark)
2441 (gnus-summary-set-agent-mark article)
2442 (message "Message marked for downloading"))
2443 (gnus-summary-mark-article article gnus-canceled-mark)
2444 (unless (memq article gnus-newsgroup-sparse)
2446 "No such article (may have expired or been canceled)")))))
2447 (if (or (eq result 'pseudo)
2448 (eq result 'nneething))
2451 (set-buffer summary-buffer)
2452 (push article gnus-newsgroup-history)
2453 (setq gnus-last-article gnus-current-article
2454 gnus-current-article 0
2455 gnus-current-headers nil
2456 gnus-article-current nil)
2457 (if (eq result 'nneething)
2458 (gnus-configure-windows 'summary)
2459 (gnus-configure-windows 'article))
2460 (gnus-set-global-variables))
2461 (let ((gnus-article-mime-handle-alist-1
2462 gnus-article-mime-handle-alist))
2463 (gnus-set-mode-line 'article)))
2464 ;; The result from the `request' was an actual article -
2465 ;; or at least some text that is now displayed in the
2467 (when (and (numberp article)
2468 (not (eq article gnus-current-article)))
2469 ;; Seems like a new article has been selected.
2470 ;; `gnus-current-article' must be an article number.
2472 (set-buffer summary-buffer)
2473 (push article gnus-newsgroup-history)
2474 (setq gnus-last-article gnus-current-article
2475 gnus-current-article article
2476 gnus-current-headers
2477 (gnus-summary-article-header gnus-current-article)
2478 gnus-article-current
2479 (cons gnus-newsgroup-name gnus-current-article))
2480 (unless (vectorp gnus-current-headers)
2481 (setq gnus-current-headers nil))
2482 (gnus-summary-goto-subject gnus-current-article)
2483 (when (gnus-summary-show-thread)
2484 ;; If the summary buffer really was folded, the
2485 ;; previous goto may not actually have gone to
2486 ;; the right article, but the thread root instead.
2488 (gnus-summary-goto-subject gnus-current-article))
2489 (gnus-run-hooks 'gnus-mark-article-hook)
2490 (gnus-set-mode-line 'summary)
2491 (when (gnus-visual-p 'article-highlight 'highlight)
2492 (gnus-run-hooks 'gnus-visual-mark-article-hook))
2493 ;; Set the global newsgroup variables here.
2494 ;; Suggested by Jim Sisolak
2495 ;; <sisolak@trans4.neep.wisc.edu>.
2496 (gnus-set-global-variables)
2497 (setq gnus-have-all-headers
2498 (or all-headers gnus-show-all-headers))))
2499 (when (or (numberp article)
2501 (gnus-article-prepare-display)
2503 (goto-char (point-min))
2504 (setq gnus-page-broken
2505 (when gnus-break-pages
2506 (gnus-narrow-to-page)
2508 (let ((gnus-article-mime-handle-alist-1
2509 gnus-article-mime-handle-alist))
2510 (gnus-set-mode-line 'article))
2512 (set-window-point (get-buffer-window (current-buffer)) (point))
2513 (gnus-configure-windows 'article)
2517 (defun gnus-article-prepare-display ()
2518 "Make the current buffer look like a nice article."
2519 ;; Hooks for getting information from the article.
2520 ;; This hook must be called before being narrowed.
2521 (let ((gnus-article-buffer (current-buffer))
2523 (unless (eq major-mode 'gnus-article-mode)
2524 (gnus-article-mode))
2525 (setq buffer-read-only nil)
2526 (gnus-run-hooks 'gnus-tmp-internal-hook)
2527 (gnus-run-hooks 'gnus-article-prepare-hook)
2528 (when gnus-display-mime-function
2529 (funcall gnus-display-mime-function))))
2532 ;;; Gnus MIME viewing functions
2535 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
2536 "The following specs can be used:
2538 %T MIME type, along with additional info
2539 %n The `name' parameter
2540 %d The description, if any
2541 %l The length of the encoded part
2542 %p The part identifier number
2543 %e Dots if the part isn't displayed")
2545 (defvar gnus-mime-button-line-format-alist
2546 '((?t gnus-tmp-type ?s)
2547 (?T gnus-tmp-type-long ?s)
2548 (?n gnus-tmp-name ?s)
2549 (?d gnus-tmp-description ?s)
2551 (?l gnus-tmp-length ?d)
2552 (?e gnus-tmp-dots ?s)))
2554 (defvar gnus-mime-button-commands
2555 '((gnus-article-press-button "\r" "Toggle Display")
2556 (gnus-mime-view-part "v" "View Interactively...")
2557 (gnus-mime-save-part "o" "Save...")
2558 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
2559 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
2560 (gnus-mime-internalize-part "E" "View Internally")
2561 (gnus-mime-externalize-part "e" "View Externally")
2562 (gnus-mime-pipe-part "|" "Pipe To Command...")))
2564 (defun gnus-article-mime-part-status ()
2565 (if gnus-article-mime-handle-alist-1
2566 (format " (%d parts)" (length gnus-article-mime-handle-alist-1))
2569 (defvar gnus-mime-button-map nil)
2570 (unless gnus-mime-button-map
2571 (setq gnus-mime-button-map (make-sparse-keymap))
2572 (set-keymap-parent gnus-mime-button-map gnus-article-mode-map)
2573 (define-key gnus-mime-button-map gnus-mouse-2 'gnus-article-push-button)
2574 (define-key gnus-mime-button-map gnus-down-mouse-3 'gnus-mime-button-menu)
2576 (define-key gnus-mime-button-map (cadr c) (car c)))
2577 gnus-mime-button-commands))
2579 (defun gnus-mime-button-menu (event)
2580 "Construct a context-sensitive menu of MIME commands."
2583 (let ((pos (event-start event)))
2584 (set-buffer (window-buffer (posn-window pos)))
2585 (goto-char (posn-point pos))
2586 (gnus-article-check-buffer)
2587 (let ((response (x-popup-menu
2589 ("" ,@(mapcar (lambda (c)
2590 (cons (caddr c) (car c)))
2591 gnus-mime-button-commands))))))
2593 (funcall response))))))
2595 (defun gnus-mime-view-all-parts (&optional handles)
2596 "View all the MIME parts."
2598 (save-current-buffer
2599 (set-buffer gnus-article-buffer)
2600 (let ((handles (or handles gnus-article-mime-handles))
2601 (mail-parse-charset gnus-newsgroup-charset))
2602 (if (stringp (car handles))
2603 (gnus-mime-view-all-parts (cdr handles))
2604 (mapcar 'mm-display-part handles)))))
2606 (defun gnus-mime-save-part ()
2607 "Save the MIME part under point."
2609 (gnus-article-check-buffer)
2610 (let ((data (get-text-property (point) 'gnus-data)))
2611 (mm-save-part data)))
2613 (defun gnus-mime-pipe-part ()
2614 "Pipe the MIME part under point to a process."
2616 (gnus-article-check-buffer)
2617 (let ((data (get-text-property (point) 'gnus-data)))
2618 (mm-pipe-part data)))
2620 (defun gnus-mime-view-part ()
2621 "Interactively choose a view method for the MIME part under point."
2623 (gnus-article-check-buffer)
2624 (let ((data (get-text-property (point) 'gnus-data)))
2625 (mm-interactively-view-part data)))
2627 (defun gnus-mime-copy-part (&optional handle)
2628 "Put the the MIME part under point into a new buffer."
2630 (gnus-article-check-buffer)
2631 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
2632 (contents (mm-get-part handle))|
2633 (base (file-name-nondirectory
2635 (mail-content-type-get (mm-handle-type handle) 'name)
2636 (mail-content-type-get (mm-handle-type handle)
2639 (buffer (generate-new-buffer base)))
2640 (switch-to-buffer buffer)
2642 ;; We do it this way to make `normal-mode' set the appropriate mode.
2645 (setq buffer-file-name (expand-file-name base))
2647 (setq buffer-file-name nil))
2648 (goto-char (point-min))))
2650 (defun gnus-mime-inline-part (&optional charset)
2651 "Insert the MIME part under point into the current buffer."
2652 (interactive "P") ; For compatibility reasons we are not using "z".
2653 (gnus-article-check-buffer)
2654 (let* ((data (get-text-property (point) 'gnus-data))
2658 (if (mm-handle-undisplayer data)
2659 (mm-remove-part data)
2660 (setq contents (mm-get-part data))
2663 (unless (symbolp charset)
2664 (setq charset (mm-read-coding-system "Charset: ")))
2665 (setq contents (mm-decode-coding-string contents charset)))
2666 (mm-insert-inline data contents)
2669 (defun gnus-mime-externalize-part (&optional handle)
2670 "View the MIME part under point with an external viewer."
2672 (gnus-article-check-buffer)
2673 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
2674 (mm-user-display-methods nil)
2675 (mm-all-images-fit t)
2676 (mail-parse-charset gnus-newsgroup-charset))
2677 (if (mm-handle-undisplayer handle)
2678 (mm-remove-part handle)
2679 (mm-display-part handle))))
2681 (defun gnus-mime-internalize-part (&optional handle)
2682 "View the MIME part under point with an internal viewer."
2684 (gnus-article-check-buffer)
2685 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
2686 (mm-user-display-methods '((".*" . inline)))
2687 (mm-all-images-fit t)
2688 (mail-parse-charset gnus-newsgroup-charset))
2689 (if (mm-handle-undisplayer handle)
2690 (mm-remove-part handle)
2691 (mm-display-part handle))))
2693 (defun gnus-article-part-wrapper (n function)
2694 (save-current-buffer
2695 (set-buffer gnus-article-buffer)
2696 (when (> n (length gnus-article-mime-handle-alist))
2697 (error "No such part"))
2698 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
2699 (funcall function handle))))
2701 (defun gnus-article-pipe-part (n)
2702 "Pipe MIME part N, which is the numerical prefix."
2704 (gnus-article-part-wrapper n 'mm-pipe-part))
2706 (defun gnus-article-save-part (n)
2707 "Save MIME part N, which is the numerical prefix."
2709 (gnus-article-part-wrapper n 'mm-save-part))
2711 (defun gnus-article-interactively-view-part (n)
2712 "View MIME part N interactively, which is the numerical prefix."
2714 (gnus-article-part-wrapper n 'mm-interactively-view-part))
2716 (defun gnus-article-copy-part (n)
2717 "Copy MIME part N, which is the numerical prefix."
2719 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
2721 (defun gnus-article-externalize-part (n)
2722 "View MIME part N externally, which is the numerical prefix."
2724 (gnus-article-part-wrapper n 'gnus-mime-externalize-part))
2726 (defun gnus-article-inline-part (n)
2727 "Inline MIME part N, which is the numerical prefix."
2729 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
2731 (defun gnus-article-view-part (n)
2732 "View MIME part N, which is the numerical prefix."
2734 (save-current-buffer
2735 (set-buffer gnus-article-buffer)
2736 (when (> n (length gnus-article-mime-handle-alist))
2737 (error "No such part"))
2738 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
2739 (when (gnus-article-goto-part n)
2740 (if (equal (car handle) "multipart/alternative")
2741 (gnus-article-press-button)
2742 (when (eq (gnus-mm-display-part handle) 'internal)
2743 (gnus-set-window-start)))))))
2745 (defun gnus-mm-display-part (handle)
2746 "Display HANDLE and fix MIME button."
2747 (let ((id (get-text-property (point) 'gnus-part))
2752 (let ((window (selected-window))
2753 (mail-parse-charset gnus-newsgroup-charset))
2756 (let ((win (get-buffer-window (current-buffer) t))
2759 (select-window win))
2762 (if (mm-handle-displayed-p handle)
2763 ;; This will remove the part.
2764 (mm-display-part handle)
2766 (narrow-to-region (point) (1+ (point)))
2767 (mm-display-part handle)
2770 (1- (length gnus-article-mime-handles))
2771 (car (mm-handle-type handle))))))
2772 (select-window window))))
2774 (delete-region (gnus-point-at-bol) (progn (forward-line 1) (point)))
2775 (gnus-insert-mime-button
2776 handle id (list (mm-handle-displayed-p handle)))
2777 (goto-char point))))
2779 (defun gnus-article-goto-part (n)
2780 "Go to MIME part N."
2781 (let ((point (text-property-any (point-min) (point-max) 'gnus-part n)))
2783 (goto-char point))))
2785 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
2786 (let ((gnus-tmp-name
2787 (or (mail-content-type-get (mm-handle-type handle)
2789 (mail-content-type-get (mm-handle-disposition handle)
2792 (gnus-tmp-type (car (mm-handle-type handle)))
2793 (gnus-tmp-description
2794 (mail-decode-encoded-word-string (or (mm-handle-description handle)
2797 (if (if displayed (car displayed)
2798 (mm-handle-displayed-p handle))
2800 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
2802 gnus-tmp-type-long b e)
2803 (when (string-match ".*/" gnus-tmp-name)
2804 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
2805 (setq gnus-tmp-type-long (concat gnus-tmp-type
2806 (and (not (equal gnus-tmp-name ""))
2807 (concat "; " gnus-tmp-name))))
2808 (or (equal gnus-tmp-description "")
2809 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
2814 gnus-mime-button-line-format gnus-mime-button-line-format-alist
2815 `(local-map ,gnus-mime-button-map
2816 keymap ,gnus-mime-button-map
2817 gnus-callback gnus-mm-display-part
2818 gnus-part ,gnus-tmp-id
2819 article-type annotation
2822 (widget-convert-button 'link b e
2824 :action 'gnus-widget-press-button
2825 :button-keymap gnus-mime-button-map
2828 ;; Needed to properly clear the message
2829 ;; due to a bug in wid-edit
2830 (setq help-echo-owns-message t)
2832 "Click to %s the MIME part; %s for more options"
2833 (if (mm-handle-displayed-p
2834 (widget-get widget :mime-handle))
2836 (if gnus-xemacs "button3" "mouse-3"))))))
2838 (defun gnus-widget-press-button (elems el)
2839 (goto-char (widget-get elems :from))
2840 (gnus-article-press-button))
2842 (defvar gnus-displaying-mime nil)
2844 (defun gnus-display-mime (&optional ihandles)
2845 "Display the MIME parts."
2847 (save-selected-window
2848 (let ((window (get-buffer-window gnus-article-buffer))
2851 (select-window window)
2852 ;; We have to do this since selecting the window
2853 ;; may change the point. So we set the window point.
2854 (set-window-point window point)))
2855 (let* ((handles (or ihandles (mm-dissect-buffer) (mm-uu-dissect)))
2856 buffer-read-only handle name type b e display)
2857 (when (and (not ihandles)
2858 (not gnus-displaying-mime))
2859 ;; Top-level call; we clean up.
2860 (mm-destroy-parts gnus-article-mime-handles)
2861 (setq gnus-article-mime-handles handles
2862 gnus-article-mime-handle-alist nil)
2863 ;; We allow users to glean info from the handles.
2864 (when gnus-article-mime-part-function
2865 (gnus-mime-part-function handles)))
2867 (or (not (stringp (car handles)))
2870 (when (and (not ihandles)
2871 (not gnus-displaying-mime))
2872 ;; Clean up for mime parts.
2874 (delete-region (point) (point-max)))
2875 (let ((gnus-displaying-mime t))
2876 (gnus-mime-display-part handles)))
2879 (narrow-to-region (point) (point-max))
2880 (gnus-treat-article nil 1 1)
2882 ;; Highlight the headers.
2886 (narrow-to-region (point-min) (point))
2887 (gnus-treat-article 'head)))))))
2889 (defvar gnus-mime-display-multipart-as-mixed nil)
2891 (defun gnus-mime-display-part (handle)
2894 ((not (stringp (car handle)))
2895 (gnus-mime-display-single handle))
2896 ;; multipart/alternative
2897 ((and (equal (car handle) "multipart/alternative")
2898 (not gnus-mime-display-multipart-as-mixed))
2899 (let ((id (1+ (length gnus-article-mime-handle-alist))))
2900 (push (cons id handle) gnus-article-mime-handle-alist)
2901 (gnus-mime-display-alternative (cdr handle) nil nil id)))
2902 ;; multipart/related
2903 ((and (equal (car handle) "multipart/related")
2904 (not gnus-mime-display-multipart-as-mixed))
2905 ;;;!!!We should find the start part, but we just default
2906 ;;;!!!to the first part.
2907 (gnus-mime-display-part (cadr handle)))
2908 ;; Other multiparts are handled like multipart/mixed.
2910 (gnus-mime-display-mixed (cdr handle)))))
2912 (defun gnus-mime-part-function (handles)
2913 (if (stringp (car handles))
2914 (mapcar 'gnus-mime-part-function (cdr handles))
2915 (funcall gnus-article-mime-part-function handles)))
2917 (defun gnus-mime-display-mixed (handles)
2918 (mapcar 'gnus-mime-display-part handles))
2920 (defun gnus-mime-display-single (handle)
2921 (let ((type (car (mm-handle-type handle)))
2922 (ignored gnus-ignored-mime-types)
2929 (when (string-match (pop ignored) type)
2930 (throw 'ignored nil)))
2931 (if (and (setq not-attachment
2932 (or (not (mm-handle-disposition handle))
2933 (equal (car (mm-handle-disposition handle))
2935 (mm-attachment-override-p type)))
2936 (mm-automatic-display-p type)
2937 (or (mm-inlinable-part-p type)
2938 (mm-automatic-external-display-p type)))
2940 (when (equal (car (split-string type "/"))
2943 (let ((id (1+ (length gnus-article-mime-handle-alist))))
2944 (push (cons id handle) gnus-article-mime-handle-alist)
2945 (when (or (not display)
2946 (not (gnus-unbuttonized-mime-type-p type)))
2947 (gnus-article-insert-newline)
2948 (gnus-insert-mime-button
2949 handle id (list (or display (and not-attachment text))))
2950 (gnus-article-insert-newline)
2951 (gnus-article-insert-newline)
2953 (let ((beg (point)))
2958 (let ((mail-parse-charset gnus-newsgroup-charset))
2959 (mm-display-part handle t))
2960 (goto-char (point-max)))
2961 ((and text not-attachment)
2964 (gnus-article-insert-newline)
2965 (mm-insert-inline handle (mm-get-part handle))
2966 (goto-char (point-max))))
2970 (narrow-to-region beg (point))
2972 nil (length gnus-article-mime-handle-alist)
2973 (1- (length gnus-article-mime-handles))
2974 (car (mm-handle-type handle))))))))))
2976 (defun gnus-unbuttonized-mime-type-p (type)
2977 "Say whether TYPE is to be unbuttonized."
2978 (unless gnus-inhibit-mime-unbuttonizing
2980 (let ((types gnus-unbuttonized-mime-types))
2982 (when (string-match (pop types) type)
2983 (throw 'found t)))))))
2985 (defun gnus-article-insert-newline ()
2986 "Insert a newline, but mark it as undeletable."
2987 (gnus-put-text-property
2988 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
2990 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
2991 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
2994 handle buffer-read-only from props begend not-pref)
2995 (save-window-excursion
2998 (narrow-to-region (car ibegend)
3001 (goto-char (car ibegend))
3004 (delete-region (point-min) (point-max))
3005 (mm-remove-parts handles))
3006 (setq begend (list (point-marker)))
3008 (unless (setq not-pref (cadr (member preferred ihandles)))
3009 (setq not-pref (car ihandles)))
3011 (not (gnus-unbuttonized-mime-type-p
3012 "multipart/alternative")))
3013 (gnus-add-text-properties
3016 (insert (format "%d. " id))
3020 (unless ,(not ibegend)
3021 (setq gnus-article-mime-handle-alist
3022 ',gnus-article-mime-handle-alist))
3023 (gnus-mime-display-alternative
3024 ',ihandles ',not-pref ',begend ,id))
3025 local-map ,gnus-mime-button-map
3026 ,gnus-mouse-face-prop ,gnus-article-mouse-face
3027 face ,gnus-article-button-face
3028 keymap ,gnus-mime-button-map
3031 (widget-convert-button 'link from (point)
3032 :action 'gnus-widget-press-button
3033 :button-keymap gnus-widget-button-keymap)
3035 (while (setq handle (pop handles))
3036 (gnus-add-text-properties
3039 (insert (format "(%c) %-18s"
3040 (if (equal handle preferred) ?* ? )
3041 (if (stringp (car handle))
3043 (car (mm-handle-type handle)))))
3047 (unless ,(not ibegend)
3048 (setq gnus-article-mime-handle-alist
3049 ',gnus-article-mime-handle-alist))
3050 (gnus-mime-display-alternative
3051 ',ihandles ',handle ',begend ,id))
3052 local-map ,gnus-mime-button-map
3053 ,gnus-mouse-face-prop ,gnus-article-mouse-face
3054 face ,gnus-article-button-face
3055 keymap ,gnus-mime-button-map
3058 (widget-convert-button 'link from (point)
3059 :action 'gnus-widget-press-button
3060 :button-keymap gnus-widget-button-keymap)
3064 (if (stringp (car preferred))
3065 (gnus-display-mime preferred)
3066 (let ((mail-parse-charset gnus-newsgroup-charset))
3067 (mm-display-part preferred)))
3068 (goto-char (point-max))
3069 (setcdr begend (point-marker)))))
3071 (goto-char point))))
3073 (defun gnus-article-wash-status ()
3074 "Return a string which display status of article washing."
3076 (set-buffer gnus-article-buffer)
3077 (let ((cite (memq 'cite gnus-article-wash-types))
3078 (headers (memq 'headers gnus-article-wash-types))
3079 (boring (memq 'boring-headers gnus-article-wash-types))
3080 (pgp (memq 'pgp gnus-article-wash-types))
3081 (pem (memq 'pem gnus-article-wash-types))
3082 (signature (memq 'signature gnus-article-wash-types))
3083 (overstrike (memq 'overstrike gnus-article-wash-types))
3084 (emphasis (memq 'emphasis gnus-article-wash-types)))
3085 (format "%c%c%c%c%c%c"
3087 (if (or headers boring) ?h ? )
3088 (if (or pgp pem) ?p ? )
3089 (if signature ?s ? )
3090 (if overstrike ?o ? )
3091 (if emphasis ?e ? )))))
3093 (fset 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
3095 (defun gnus-article-maybe-hide-headers ()
3096 "Hide unwanted headers if `gnus-have-all-headers' is nil.
3097 Provided for backwards compatibility."
3098 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
3099 (not (save-excursion (set-buffer gnus-summary-buffer)
3100 gnus-have-all-headers)))
3101 (not gnus-inhibit-hiding))
3102 (gnus-article-hide-headers)))
3106 (defun gnus-output-to-file (file-name)
3107 "Append the current article to a file named FILE-NAME."
3108 (let ((artbuf (current-buffer)))
3110 (insert-buffer-substring artbuf)
3111 ;; Append newline at end of the buffer as separator, and then
3113 (goto-char (point-max))
3115 (append-to-file (point-min) (point-max) file-name)
3118 (defun gnus-narrow-to-page (&optional arg)
3119 "Narrow the article buffer to a page.
3120 If given a numerical ARG, move forward ARG pages."
3122 (setq arg (if arg (prefix-numeric-value arg) 0))
3124 (set-buffer gnus-article-buffer)
3125 (goto-char (point-min))
3126 ;; Remove any old next/prev buttons.
3127 (when (gnus-visual-p 'page-marker)
3128 (let ((buffer-read-only nil))
3129 (gnus-remove-text-with-property 'gnus-prev)
3130 (gnus-remove-text-with-property 'gnus-next)))
3133 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
3135 (re-search-forward page-delimiter nil 'move arg)))
3136 (goto-char (match-end 0)))
3139 (if (re-search-forward page-delimiter nil 'move)
3142 (when (and (gnus-visual-p 'page-marker)
3143 (not (= (point-min) 1)))
3145 (goto-char (point-min))
3146 (gnus-insert-prev-page-button)))
3147 (when (and (gnus-visual-p 'page-marker)
3148 (< (+ (point-max) 2) (buffer-size)))
3150 (goto-char (point-max))
3151 (gnus-insert-next-page-button)))))
3153 ;; Article mode commands
3155 (defun gnus-article-goto-next-page ()
3156 "Show the next page of the article."
3158 (when (gnus-article-next-page)
3159 (goto-char (point-min))
3160 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
3162 (defun gnus-article-goto-prev-page ()
3163 "Show the next page of the article."
3165 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
3166 (gnus-article-prev-page nil)))
3168 (defun gnus-article-next-page (&optional lines)
3169 "Show the next page of the current article.
3170 If end of article, return non-nil. Otherwise return nil.
3171 Argument LINES specifies lines to be scrolled up."
3173 (move-to-window-line -1)
3176 (and (pos-visible-in-window-p) ;Not continuation line.
3178 ;; Nothing in this page.
3179 (if (or (not gnus-page-broken)
3182 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
3184 (gnus-narrow-to-page 1) ;Go to next page.
3186 ;; More in this page.
3187 (let ((scroll-in-place nil))
3191 ;; Long lines may cause an end-of-buffer error.
3192 (goto-char (point-max)))))
3193 (move-to-window-line 0)
3196 (defun gnus-article-prev-page (&optional lines)
3197 "Show previous page of current article.
3198 Argument LINES specifies lines to be scrolled down."
3200 (move-to-window-line 0)
3201 (if (and gnus-page-broken
3203 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
3205 (gnus-narrow-to-page -1) ;Go to previous page.
3206 (goto-char (point-max))
3208 (let ((scroll-in-place nil))
3212 (beginning-of-buffer
3213 (goto-char (point-min))))
3214 (move-to-window-line 0)))))
3216 (defun gnus-article-refer-article ()
3217 "Read article specified by message-id around point."
3219 (let ((point (point)))
3220 (search-forward ">" nil t) ;Move point to end of "<....>".
3221 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
3222 (let ((message-id (match-string 1)))
3224 (set-buffer gnus-summary-buffer)
3225 (gnus-summary-refer-article message-id))
3227 (error "No references around point"))))
3229 (defun gnus-article-show-summary ()
3230 "Reconfigure windows to show summary buffer."
3232 (if (not (gnus-buffer-live-p gnus-summary-buffer))
3233 (error "There is no summary buffer for this article buffer")
3234 (gnus-article-set-globals)
3235 (gnus-configure-windows 'article)
3236 (gnus-summary-goto-subject gnus-current-article)
3237 (gnus-summary-position-point)))
3239 (defun gnus-article-describe-briefly ()
3240 "Describe article mode commands briefly."
3242 (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")))
3244 (defun gnus-article-summary-command ()
3245 "Execute the last keystroke in the summary buffer."
3247 (let ((obuf (current-buffer))
3248 (owin (current-window-configuration))
3250 (switch-to-buffer gnus-article-current-summary 'norecord)
3251 (setq func (lookup-key (current-local-map) (this-command-keys)))
3252 (call-interactively func)
3254 (set-window-configuration owin)
3255 (set-window-point (get-buffer-window (current-buffer)) (point))))
3257 (defun gnus-article-summary-command-nosave ()
3258 "Execute the last keystroke in the summary buffer."
3261 (pop-to-buffer gnus-article-current-summary 'norecord)
3262 (setq func (lookup-key (current-local-map) (this-command-keys)))
3263 (call-interactively func)))
3265 (defun gnus-article-check-buffer ()
3266 "Beep if not in an article buffer."
3267 (unless (equal major-mode 'gnus-article-mode)
3268 (error "Command invoked outside of a Gnus article buffer")))
3270 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
3271 "Read a summary buffer key sequence and execute it from the article buffer."
3273 (gnus-article-check-buffer)
3275 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
3276 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
3277 "=" "^" "\M-^" "|"))
3283 '("n" "Gn" "p" "Gp"))
3286 (set-buffer gnus-article-current-summary)
3287 (let (gnus-pick-mode)
3288 (push (or key last-command-event) unread-command-events)
3289 (setq keys (read-key-sequence nil))))
3292 (if (or (member keys nosaves)
3293 (member keys nosave-but-article)
3294 (member keys nosave-in-article))
3296 (save-window-excursion
3297 (pop-to-buffer gnus-article-current-summary 'norecord)
3298 ;; We disable the pick minor mode commands.
3299 (let (gnus-pick-mode)
3300 (setq func (lookup-key (current-local-map) keys))))
3303 (unless (member keys nosave-in-article)
3304 (set-buffer gnus-article-current-summary))
3305 (call-interactively func)
3306 (setq new-sum-point (point)))
3307 (when (member keys nosave-but-article)
3308 (pop-to-buffer gnus-article-buffer 'norecord)))
3309 ;; These commands should restore window configuration.
3310 (let ((obuf (current-buffer))
3311 (owin (current-window-configuration))
3313 (summary gnus-article-current-summary)
3314 func in-buffer selected)
3315 (if not-restore-window
3316 (pop-to-buffer summary 'norecord)
3317 (switch-to-buffer summary 'norecord))
3318 (setq in-buffer (current-buffer))
3319 ;; We disable the pick minor mode commands.
3320 (if (setq func (let (gnus-pick-mode)
3321 (lookup-key (current-local-map) keys)))
3323 (call-interactively func)
3324 (setq new-sum-point (point)))
3326 (when (eq in-buffer (current-buffer))
3327 (setq selected (gnus-summary-select-article))
3329 (unless not-restore-window
3330 (set-window-configuration owin))
3331 (when (eq selected 'old)
3333 (set-window-start (get-buffer-window (current-buffer))
3335 (set-window-point (get-buffer-window (current-buffer))
3337 (let ((win (get-buffer-window gnus-article-current-summary)))
3339 (set-window-point win new-sum-point))))))))
3341 (defun gnus-article-hide (&optional arg force)
3342 "Hide all the gruft in the current article.
3343 This means that PGP stuff, signatures, cited text and (some)
3344 headers will be hidden.
3345 If given a prefix, show the hidden text instead."
3346 (interactive (append (gnus-article-hidden-arg) (list 'force)))
3347 (gnus-article-hide-headers arg)
3348 (gnus-article-hide-pgp arg)
3349 (gnus-article-hide-citation-maybe arg force)
3350 (gnus-article-hide-signature arg))
3352 (defun gnus-article-maybe-highlight ()
3353 "Do some article highlighting if article highlighting is requested."
3354 (when (gnus-visual-p 'article-highlight 'highlight)
3355 (gnus-article-highlight-some)))
3357 (defun gnus-check-group-server ()
3358 ;; Make sure the connection to the server is alive.
3359 (unless (gnus-server-opened
3360 (gnus-find-method-for-group gnus-newsgroup-name))
3361 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
3362 (gnus-request-group gnus-newsgroup-name t)))
3364 (defun gnus-request-article-this-buffer (article group)
3365 "Get an article and insert it into this buffer."
3366 (let (do-update-line sparse-header)
3370 (gnus-kill-all-overlays)
3371 (setq group (or group gnus-newsgroup-name))
3373 ;; Using `gnus-request-article' directly will insert the article into
3374 ;; `nntp-server-buffer' - so we'll save some time by not having to
3375 ;; copy it from the server buffer into the article buffer.
3377 ;; We only request an article by message-id when we do not have the
3378 ;; headers for it, so we'll have to get those.
3379 (when (stringp article)
3380 (let ((gnus-override-method gnus-refer-article-method))
3381 (gnus-read-header article)))
3383 ;; If the article number is negative, that means that this article
3384 ;; doesn't belong in this newsgroup (possibly), so we find its
3385 ;; message-id and request it by id instead of number.
3386 (when (and (numberp article)
3388 (get-buffer gnus-summary-buffer)
3389 (gnus-buffer-exists-p gnus-summary-buffer))
3391 (set-buffer gnus-summary-buffer)
3392 (let ((header (gnus-summary-article-header article)))
3395 ((memq article gnus-newsgroup-sparse)
3396 ;; This is a sparse gap article.
3397 (setq do-update-line article)
3398 (setq article (mail-header-id header))
3399 (let ((gnus-override-method gnus-refer-article-method))
3400 (setq sparse-header (gnus-read-header article)))
3401 (setq gnus-newsgroup-sparse
3402 (delq article gnus-newsgroup-sparse)))
3404 ;; It's a real article.
3405 (setq article (mail-header-id header)))
3407 ;; It is an extracted pseudo-article.
3408 (setq article 'pseudo)
3409 (gnus-request-pseudo-article header))))
3411 (let ((method (gnus-find-method-for-group
3412 gnus-newsgroup-name)))
3413 (when (and (eq (car method) 'nneething)
3416 (file-name-as-directory
3417 (or (cadr (assq 'nneething-address method))
3419 (mail-header-subject header))))
3420 (when (file-directory-p dir)
3421 (setq article 'nneething)
3422 (gnus-group-enter-directory dir))))))))
3425 ;; Refuse to select canceled articles.
3426 ((and (numberp article)
3428 (get-buffer gnus-summary-buffer)
3429 (gnus-buffer-exists-p gnus-summary-buffer)
3430 (eq (cdr (save-excursion
3431 (set-buffer gnus-summary-buffer)
3432 (assq article gnus-newsgroup-reads)))
3433 gnus-canceled-mark))
3435 ;; We first check `gnus-original-article-buffer'.
3436 ((and (get-buffer gnus-original-article-buffer)
3439 (set-buffer gnus-original-article-buffer)
3440 (and (equal (car gnus-original-article) group)
3441 (eq (cdr gnus-original-article) article))))
3442 (insert-buffer-substring gnus-original-article-buffer)
3444 ;; Check the backlog.
3445 ((and gnus-keep-backlog
3446 (gnus-backlog-request-article group article (current-buffer)))
3448 ;; Check asynchronous pre-fetch.
3449 ((gnus-async-request-fetched-article group article (current-buffer))
3450 (gnus-async-prefetch-next group article gnus-summary-buffer)
3451 (when (and (numberp article) gnus-keep-backlog)
3452 (gnus-backlog-enter-article group article (current-buffer)))
3455 ((and gnus-use-cache
3457 (gnus-cache-request-article article group))
3459 ;; Get the article and put into the article buffer.
3460 ((or (stringp article) (numberp article))
3461 (let ((gnus-override-method
3462 (and (stringp article) gnus-refer-article-method))
3463 (buffer-read-only nil))
3465 (gnus-kill-all-overlays)
3466 (gnus-check-group-server)
3467 (when (gnus-request-article article group (current-buffer))
3468 (when (numberp article)
3469 (gnus-async-prefetch-next group article gnus-summary-buffer)
3470 (when gnus-keep-backlog
3471 (gnus-backlog-enter-article
3472 group article (current-buffer))))
3477 ;; Associate this article with the current summary buffer.
3478 (setq gnus-article-current-summary gnus-summary-buffer)
3480 ;; Take the article from the original article buffer
3481 ;; and place it in the buffer it's supposed to be in.
3482 (when (and (get-buffer gnus-article-buffer)
3483 (equal (buffer-name (current-buffer))
3484 (buffer-name (get-buffer gnus-article-buffer))))
3486 (if (get-buffer gnus-original-article-buffer)
3487 (set-buffer gnus-original-article-buffer)
3488 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3489 (buffer-disable-undo)
3490 (setq major-mode 'gnus-original-article-mode)
3491 (setq buffer-read-only t))
3492 (let (buffer-read-only)
3494 (insert-buffer-substring gnus-article-buffer))
3495 (setq gnus-original-article (cons group article)))
3498 (run-hooks 'gnus-article-decode-hook)
3499 ;; Mark article as decoded or not.
3500 (setq gnus-article-decoded-p gnus-article-decode-hook))
3502 ;; Update sparse articles.
3503 (when (and do-update-line
3504 (or (numberp article)
3506 (let ((buf (current-buffer)))
3507 (set-buffer gnus-summary-buffer)
3508 (gnus-summary-update-article do-update-line sparse-header)
3509 (gnus-summary-goto-subject do-update-line nil t)
3510 (set-window-point (get-buffer-window (current-buffer) t)
3512 (set-buffer buf))))))
3518 (defcustom gnus-article-edit-mode-hook nil
3519 "Hook run in article edit mode buffers."
3520 :group 'gnus-article-various
3523 (defvar gnus-article-edit-done-function nil)
3525 (defvar gnus-article-edit-mode-map nil)
3527 ;; Should we be using derived.el for this?
3528 (unless gnus-article-edit-mode-map
3529 (setq gnus-article-edit-mode-map (make-sparse-keymap))
3530 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
3532 (gnus-define-keys gnus-article-edit-mode-map
3533 "\C-c\C-c" gnus-article-edit-done
3534 "\C-c\C-k" gnus-article-edit-exit)
3536 (gnus-define-keys (gnus-article-edit-wash-map
3537 "\C-c\C-w" gnus-article-edit-mode-map)
3538 "f" gnus-article-edit-full-stops))
3540 (defun gnus-article-edit-mode ()
3541 "Major mode for editing articles.
3542 This is an extended text-mode.
3544 \\{gnus-article-edit-mode-map}"
3546 (setq major-mode 'gnus-article-edit-mode)
3547 (setq mode-name "Article Edit")
3548 (use-local-map gnus-article-edit-mode-map)
3549 (make-local-variable 'gnus-article-edit-done-function)
3550 (make-local-variable 'gnus-prev-winconf)
3551 (setq buffer-read-only nil)
3552 (buffer-enable-undo)
3554 (gnus-run-hooks 'text-mode-hook 'gnus-article-edit-mode-hook))
3556 (defun gnus-article-edit (&optional force)
3557 "Edit the current article.
3558 This will have permanent effect only in mail groups.
3559 If FORCE is non-nil, allow editing of articles even in read-only
3562 (when (and (not force)
3563 (gnus-group-read-only-p))
3564 (error "The current newsgroup does not support article editing"))
3565 (gnus-article-date-original)
3566 (gnus-article-edit-article
3568 `(lambda (no-highlight)
3570 (gnus-summary-edit-article-done
3571 ,(or (mail-header-references gnus-current-headers) "")
3572 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
3574 (defun gnus-article-edit-article (start-func exit-func)
3575 "Start editing the contents of the current article buffer."
3576 (let ((winconf (current-window-configuration)))
3577 (set-buffer gnus-article-buffer)
3578 (gnus-article-edit-mode)
3579 (funcall start-func)
3580 ;;(gnus-article-delete-text-of-type 'annotation)
3581 ;;(gnus-set-text-properties (point-min) (point-max) nil)
3582 (gnus-configure-windows 'edit-article)
3583 (setq gnus-article-edit-done-function exit-func)
3584 (setq gnus-prev-winconf winconf)
3585 (gnus-message 6 "C-c C-c to end edits")))
3587 (defun gnus-article-edit-done (&optional arg)
3588 "Update the article edits and exit."
3593 (when (article-goto-body)
3594 (let ((lines (count-lines (point) (point-max)))
3595 (length (- (point-max) (point)))
3596 (case-fold-search t)
3597 (body (copy-marker (point))))
3598 (goto-char (point-min))
3599 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
3600 (delete-region (match-beginning 1) (match-end 1))
3601 (insert (number-to-string length)))
3602 (goto-char (point-min))
3603 (when (re-search-forward
3604 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
3605 (delete-region (match-beginning 1) (match-end 1))
3606 (insert (number-to-string length)))
3607 (goto-char (point-min))
3608 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
3609 (delete-region (match-beginning 1) (match-end 1))
3610 (insert (number-to-string lines)))))))
3611 (let ((func gnus-article-edit-done-function)
3612 (buf (current-buffer))
3613 (start (window-start)))
3614 (gnus-article-edit-exit)
3617 (let ((buffer-read-only nil))
3619 ;; The cache and backlog have to be flushed somewhat.
3620 (when gnus-keep-backlog
3621 (gnus-backlog-remove-article
3622 (car gnus-article-current) (cdr gnus-article-current)))
3623 ;; Flush original article as well.
3625 (when (get-buffer gnus-original-article-buffer)
3626 (set-buffer gnus-original-article-buffer)
3627 (setq gnus-original-article nil)))
3628 (when gnus-use-cache
3629 (gnus-cache-update-article
3630 (car gnus-article-current) (cdr gnus-article-current))))
3632 (set-window-start (get-buffer-window buf) start)
3633 (set-window-point (get-buffer-window buf) (point))))
3635 (defun gnus-article-edit-exit ()
3636 "Exit the article editing without updating."
3638 ;; We remove all text props from the article buffer.
3639 (let ((buf (format "%s" (buffer-string)))
3640 (curbuf (current-buffer))
3642 (window-start (window-start)))
3645 (let ((winconf gnus-prev-winconf))
3647 (set-window-configuration winconf)
3648 ;; Tippy-toe some to make sure that point remains where it was.
3649 (save-current-buffer
3651 (set-window-start (get-buffer-window (current-buffer)) window-start)
3654 (defun gnus-article-edit-full-stops ()
3655 "Interactively repair spacing at end of sentences."
3658 (goto-char (point-min))
3659 (search-forward-regexp "^$" nil t)
3660 (let ((case-fold-search nil))
3661 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
3664 ;;; Article highlights
3667 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
3669 ;;; Internal Variables:
3671 (defcustom gnus-button-url-regexp "\\b\\(s?https?\\|ftp\\|file\\|gopher\\|news\\|telnet\\|wais\\|mailto\\):\\(//[-a-zA-Z0-9_.]+:[0-9]*\\)?\\([-a-zA-Z0-9_=!?#$@~`%&*+|\\/:;.,]\\|\\w\\)+\\([-a-zA-Z0-9_=#$@~`%&*+|\\/]\\|\\w\\)"
3672 "Regular expression that matches URLs."
3673 :group 'gnus-article-buttons
3676 (defcustom gnus-button-alist
3677 `(("<\\(url:[>\n\t ]*?\\)?news:[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
3678 0 t gnus-button-message-id 2)
3679 ("\\bnews:\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t gnus-button-message-id 1)
3680 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
3682 gnus-button-fetch-group 4)
3683 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
3684 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
3685 t gnus-button-message-id 3)
3686 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
3687 ("mailto:\\([-a-zA-Z.@_+0-9%]+\\)" 0 t gnus-url-mailto 1)
3688 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
3689 ;; This is how URLs _should_ be embedded in text...
3690 ("<URL: *\\([^>]*\\)>" 0 t gnus-button-embedded-url 1)
3692 (,gnus-button-url-regexp 0 t gnus-button-url 0))
3693 "*Alist of regexps matching buttons in article bodies.
3695 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
3696 REGEXP: is the string matching text around the button,
3697 BUTTON: is the number of the regexp grouping actually matching the button,
3698 FORM: is a lisp expression which must eval to true for the button to
3700 CALLBACK: is the function to call when the user push this button, and each
3701 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
3703 CALLBACK can also be a variable, in that case the value of that
3704 variable it the real callback function."
3705 :group 'gnus-article-buttons
3706 :type '(repeat (list regexp
3707 (integer :tag "Button")
3709 (function :tag "Callback")
3712 (integer :tag "Regexp group")))))
3714 (defcustom gnus-header-button-alist
3715 `(("^\\(References\\|Message-I[Dd]\\):" "<[^>]+>"
3716 0 t gnus-button-message-id 0)
3717 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
3718 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
3719 0 t gnus-button-mailto 0)
3720 ("^X-[Uu][Rr][Ll]:" ,gnus-button-url-regexp 0 t gnus-button-url 0)
3721 ("^Subject:" ,gnus-button-url-regexp 0 t gnus-button-url 0)
3722 ("^[^:]+:" ,gnus-button-url-regexp 0 t gnus-button-url 0)
3723 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
3724 gnus-button-message-id 3))
3725 "*Alist of headers and regexps to match buttons in article heads.
3727 This alist is very similar to `gnus-button-alist', except that each
3728 alist has an additional HEADER element first in each entry:
3730 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
3732 HEADER is a regexp to match a header. For a fuller explanation, see
3733 `gnus-button-alist'."
3734 :group 'gnus-article-buttons
3735 :group 'gnus-article-headers
3736 :type '(repeat (list (regexp :tag "Header")
3738 (integer :tag "Button")
3740 (function :tag "Callback")
3743 (integer :tag "Regexp group")))))
3745 (defvar gnus-button-regexp nil)
3746 (defvar gnus-button-marker-list nil)
3747 ;; Regexp matching any of the regexps from `gnus-button-alist'.
3749 (defvar gnus-button-last nil)
3750 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
3754 (defun gnus-article-push-button (event)
3755 "Check text under the mouse pointer for a callback function.
3756 If the text under the mouse pointer has a `gnus-callback' property,
3757 call it with the value of the `gnus-data' text property."
3759 (set-buffer (window-buffer (posn-window (event-start event))))
3760 (let* ((pos (posn-point (event-start event)))
3761 (data (get-text-property pos 'gnus-data))
3762 (fun (get-text-property pos 'gnus-callback)))
3765 (funcall fun data))))
3767 (defun gnus-article-press-button ()
3768 "Check text at point for a callback function.
3769 If the text at point has a `gnus-callback' property,
3770 call it with the value of the `gnus-data' text property."
3772 (let* ((data (get-text-property (point) 'gnus-data))
3773 (fun (get-text-property (point) 'gnus-callback)))
3775 (funcall fun data))))
3777 (defun gnus-article-highlight (&optional force)
3778 "Highlight current article.
3779 This function calls `gnus-article-highlight-headers',
3780 `gnus-article-highlight-citation',
3781 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
3782 do the highlighting. See the documentation for those functions."
3783 (interactive (list 'force))
3784 (gnus-article-highlight-headers)
3785 (gnus-article-highlight-citation force)
3786 (gnus-article-highlight-signature)
3787 (gnus-article-add-buttons force)
3788 (gnus-article-add-buttons-to-head))
3790 (defun gnus-article-highlight-some (&optional force)
3791 "Highlight current article.
3792 This function calls `gnus-article-highlight-headers',
3793 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
3794 do the highlighting. See the documentation for those functions."
3795 (interactive (list 'force))
3796 (gnus-article-highlight-headers)
3797 (gnus-article-highlight-signature)
3798 (gnus-article-add-buttons))
3800 (defun gnus-article-highlight-headers ()
3801 "Highlight article headers as specified by `gnus-header-face-alist'."
3804 (set-buffer gnus-article-buffer)
3806 (let ((alist gnus-header-face-alist)
3807 (buffer-read-only nil)
3808 (case-fold-search t)
3809 (inhibit-point-motion-hooks t)
3810 entry regexp header-face field-face from hpoints fpoints)
3811 (article-narrow-to-head)
3812 (while (setq entry (pop alist))
3813 (goto-char (point-min))
3814 (setq regexp (concat "^\\("
3815 (if (string-equal "" (nth 0 entry))
3819 header-face (nth 1 entry)
3820 field-face (nth 2 entry))
3821 (while (and (re-search-forward regexp nil t)
3825 (unless (search-forward ":" nil t)
3827 (when (and header-face
3828 (not (memq (point) hpoints)))
3829 (push (point) hpoints)
3830 (gnus-put-text-property from (point) 'face header-face))
3831 (when (and field-face
3832 (not (memq (setq from (point)) fpoints)))
3834 (if (re-search-forward "^[^ \t]" nil t)
3836 (goto-char (point-max)))
3837 (gnus-put-text-property from (point) 'face field-face))))))))
3839 (defun gnus-article-highlight-signature ()
3840 "Highlight the signature in an article.
3841 It does this by highlighting everything after
3842 `gnus-signature-separator' using `gnus-signature-face'."
3845 (set-buffer gnus-article-buffer)
3846 (let ((buffer-read-only nil)
3847 (inhibit-point-motion-hooks t))
3849 (when (and gnus-signature-face
3850 (gnus-article-narrow-to-signature))
3851 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
3852 'face gnus-signature-face)
3854 (gnus-article-search-signature)
3855 (let ((start (match-beginning 0))
3856 (end (set-marker (make-marker) (1+ (match-end 0)))))
3857 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
3860 (defun gnus-button-in-region-p (b e prop)
3861 "Say whether PROP exists in the region."
3862 (text-property-not-all b e prop nil))
3864 (defun gnus-article-add-buttons (&optional force)
3865 "Find external references in the article and make buttons of them.
3866 \"External references\" are things like Message-IDs and URLs, as
3867 specified by `gnus-button-alist'."
3868 (interactive (list 'force))
3870 (set-buffer gnus-article-buffer)
3871 (let ((buffer-read-only nil)
3872 (inhibit-point-motion-hooks t)
3873 (case-fold-search t)
3874 (alist gnus-button-alist)
3876 ;; Remove all old markers.
3878 (while (setq marker (pop gnus-button-marker-list))
3880 (when (setq entry (gnus-button-entry))
3881 (put-text-property (match-beginning (nth 1 entry))
3882 (match-end (nth 1 entry))
3883 'gnus-callback nil))
3884 (set-marker marker nil)))
3885 ;; We skip the headers.
3888 (while (setq entry (pop alist))
3889 (setq regexp (car entry))
3891 (while (re-search-forward regexp nil t)
3892 (let* ((start (and entry (match-beginning (nth 1 entry))))
3893 (end (and entry (match-end (nth 1 entry))))
3894 (from (match-beginning 0)))
3895 (when (and (or (eq t (nth 2 entry))
3896 (eval (nth 2 entry)))
3897 (not (gnus-button-in-region-p
3898 start end 'gnus-callback)))
3899 ;; That optional form returned non-nil, so we add the
3901 (gnus-article-add-button
3902 start end 'gnus-button-push
3903 (car (push (set-marker (make-marker) from)
3904 gnus-button-marker-list))))))))))
3906 ;; Add buttons to the head of an article.
3907 (defun gnus-article-add-buttons-to-head ()
3908 "Add buttons to the head of the article."
3911 (set-buffer gnus-article-buffer)
3913 (let ((buffer-read-only nil)
3914 (inhibit-point-motion-hooks t)
3915 (case-fold-search t)
3916 (alist gnus-header-button-alist)
3918 (article-narrow-to-head)
3920 ;; Each alist entry.
3921 (setq entry (car alist)
3923 (goto-char (point-min))
3924 (while (re-search-forward (car entry) nil t)
3925 ;; Each header matching the entry.
3926 (setq beg (match-beginning 0))
3927 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
3928 (match-beginning 0))
3931 (while (re-search-forward (nth 1 entry) end t)
3932 ;; Each match within a header.
3933 (let* ((entry (cdr entry))
3934 (start (match-beginning (nth 1 entry)))
3935 (end (match-end (nth 1 entry)))
3936 (form (nth 2 entry)))
3937 (goto-char (match-end 0))
3939 (gnus-article-add-button
3940 start end (nth 3 entry)
3941 (buffer-substring (match-beginning (nth 4 entry))
3942 (match-end (nth 4 entry)))))))
3943 (goto-char end)))))))
3945 ;;; External functions:
3947 (defun gnus-article-add-button (from to fun &optional data)
3948 "Create a button between FROM and TO with callback FUN and data DATA."
3949 (when gnus-article-button-face
3950 (gnus-overlay-put (gnus-make-overlay from to)
3951 'face gnus-article-button-face))
3952 (gnus-add-text-properties
3954 (nconc (and gnus-article-mouse-face
3955 (list gnus-mouse-face-prop gnus-article-mouse-face))
3956 (list 'gnus-callback fun)
3957 (and data (list 'gnus-data data))))
3958 (widget-convert-button 'link from to :action 'gnus-widget-press-button
3959 :button-keymap gnus-widget-button-keymap))
3961 ;;; Internal functions:
3963 (defun gnus-article-set-globals ()
3965 (set-buffer gnus-summary-buffer)
3966 (gnus-set-global-variables)))
3968 (defun gnus-signature-toggle (end)
3970 (set-buffer gnus-article-buffer)
3971 (let ((buffer-read-only nil)
3972 (inhibit-point-motion-hooks t))
3973 (if (get-text-property end 'invisible)
3974 (gnus-article-unhide-text end (point-max))
3975 (gnus-article-hide-text end (point-max) gnus-hidden-properties)))))
3977 (defun gnus-button-entry ()
3978 ;; Return the first entry in `gnus-button-alist' matching this place.
3979 (let ((alist gnus-button-alist)
3982 (setq entry (pop alist))
3983 (if (looking-at (car entry))
3988 (defun gnus-button-push (marker)
3989 ;; Push button starting at MARKER.
3992 (let* ((entry (gnus-button-entry))
3993 (inhibit-point-motion-hooks t)
3995 (args (mapcar (lambda (group)
3996 (let ((string (match-string group)))
3997 (gnus-set-text-properties
3998 0 (length string) nil string)
4005 (fboundp (symbol-value fun)))
4006 (apply (symbol-value fun) args))
4008 (gnus-message 1 "You must define `%S' to use this button"
4009 (cons fun args)))))))
4011 (defun gnus-button-message-id (message-id)
4014 (set-buffer gnus-summary-buffer)
4015 (gnus-summary-refer-article message-id)))
4017 (defun gnus-button-fetch-group (address)
4018 "Fetch GROUP specified by ADDRESS."
4019 (if (not (string-match "[:/]" address))
4020 ;; This is just a simple group url.
4021 (gnus-group-read-ephemeral-group address gnus-select-method)
4022 (if (not (string-match "^\\([^:/]+\\)\\(:\\([^/]+\\)/\\)?\\(.*\\)$"
4024 (error "Can't parse %s" address)
4025 (gnus-group-read-ephemeral-group
4026 (match-string 4 address)
4027 `(nntp ,(match-string 1 address)
4028 (nntp-address ,(match-string 1 address))
4029 (nntp-port-number ,(if (match-end 3)
4030 (match-string 3 address)
4033 (defun gnus-url-parse-query-string (query &optional downcase)
4034 (let (retval pairs cur key val)
4035 (setq pairs (split-string query "&"))
4037 (setq cur (car pairs)
4039 (if (not (string-match "=" cur))
4041 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
4042 val (gnus-url-unhex-string (substring cur (match-end 0) nil)))
4044 (setq key (downcase key)))
4045 (setq cur (assoc key retval))
4047 (setcdr cur (cons val (cdr cur)))
4048 (setq retval (cons (list key val) retval)))))
4051 (defun gnus-url-unhex (x)
4058 (defun gnus-url-unhex-string (str &optional allow-newlines)
4059 "Remove %XXX embedded spaces, etc in a url.
4060 If optional second argument ALLOW-NEWLINES is non-nil, then allow the
4061 decoding of carriage returns and line feeds in the string, which is normally
4062 forbidden in URL encoding."
4063 (setq str (or str ""))
4065 (case-fold-search t))
4066 (while (string-match "%[0-9a-f][0-9a-f]" str)
4067 (let* ((start (match-beginning 0))
4068 (ch1 (gnus-url-unhex (elt str (+ start 1))))
4070 (gnus-url-unhex (elt str (+ start 2))))))
4072 tmp (substring str 0 start)
4075 (char-to-string code))
4076 ((or (= code ?\n) (= code ?\r))
4078 (t (char-to-string code))))
4079 str (substring str (match-end 0)))))
4080 (setq tmp (concat tmp str))
4083 (defun gnus-url-mailto (url)
4084 ;; Send mail to someone
4085 (when (string-match "mailto:/*\\(.*\\)" url)
4086 (setq url (substring url (match-beginning 1) nil)))
4087 (let (to args subject func)
4088 (if (string-match (regexp-quote "?") url)
4089 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
4090 args (gnus-url-parse-query-string
4091 (substring url (match-end 0) nil) t))
4092 (setq to (gnus-url-unhex-string url)))
4093 (setq args (cons (list "to" to) args)
4094 subject (cdr-safe (assoc "subject" args)))
4097 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
4100 (message-position-on-field (caar args)))
4101 (insert (mapconcat 'identity (cdar args) ", "))
4102 (setq args (cdr args)))
4105 (message-goto-subject))))
4107 (defun gnus-button-mailto (address)
4109 (set-buffer (gnus-copy-article-buffer))
4110 (message-reply address))
4112 (defun gnus-button-reply (address)
4113 ;; Reply to ADDRESS.
4114 (message-reply address))
4116 (defun gnus-button-url (address)
4118 ;; In Emacs 20, `browse-url-browser-function' may be an alist.
4119 (if (listp browse-url-browser-function)
4120 (browse-url address)
4121 (funcall browse-url-browser-function address)))
4123 (defun gnus-button-embedded-url (address)
4125 ;; In Emacs 20, `browse-url-browser-function' may be an alist.
4126 (if (listp browse-url-browser-function)
4127 (browse-url (gnus-strip-whitespace address))
4128 (funcall browse-url-browser-function (gnus-strip-whitespace address))))
4130 ;;; Next/prev buttons in the article buffer.
4132 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
4133 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
4135 (defvar gnus-prev-page-map nil)
4136 (unless gnus-prev-page-map
4137 (setq gnus-prev-page-map (make-sparse-keymap))
4138 (define-key gnus-prev-page-map gnus-mouse-2 'gnus-button-prev-page)
4139 (define-key gnus-prev-page-map "\r" 'gnus-button-prev-page))
4141 (defun gnus-insert-prev-page-button ()
4142 (let ((buffer-read-only nil))
4144 gnus-prev-page-line-format nil
4145 `(gnus-prev t local-map ,gnus-prev-page-map
4146 gnus-callback gnus-article-button-prev-page
4147 article-type annotation))))
4149 (defvar gnus-next-page-map nil)
4150 (unless gnus-next-page-map
4151 (setq gnus-next-page-map (make-keymap))
4152 (suppress-keymap gnus-prev-page-map)
4153 (define-key gnus-next-page-map gnus-mouse-2 'gnus-button-next-page)
4154 (define-key gnus-next-page-map "\r" 'gnus-button-next-page))
4156 (defun gnus-button-next-page ()
4157 "Go to the next page."
4159 (let ((win (selected-window)))
4160 (select-window (get-buffer-window gnus-article-buffer t))
4161 (gnus-article-next-page)
4162 (select-window win)))
4164 (defun gnus-button-prev-page ()
4165 "Go to the prev page."
4167 (let ((win (selected-window)))
4168 (select-window (get-buffer-window gnus-article-buffer t))
4169 (gnus-article-prev-page)
4170 (select-window win)))
4172 (defun gnus-insert-next-page-button ()
4173 (let ((buffer-read-only nil))
4174 (gnus-eval-format gnus-next-page-line-format nil
4176 t local-map ,gnus-next-page-map
4177 gnus-callback gnus-article-button-next-page
4178 article-type annotation))))
4180 (defun gnus-article-button-next-page (arg)
4181 "Go to the next page."
4183 (let ((win (selected-window)))
4184 (select-window (get-buffer-window gnus-article-buffer t))
4185 (gnus-article-next-page)
4186 (select-window win)))
4188 (defun gnus-article-button-prev-page (arg)
4189 "Go to the prev page."
4191 (let ((win (selected-window)))
4192 (select-window (get-buffer-window gnus-article-buffer t))
4193 (gnus-article-prev-page)
4194 (select-window win)))
4196 (defvar gnus-decode-header-methods
4197 '(mail-decode-encoded-word-region)
4198 "List of methods used to decode headers.
4200 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item is
4201 FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
4202 (REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
4203 whose names match REGEXP.
4206 ((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
4207 mail-decode-encoded-word-region
4208 (\"chinese\" . rfc1843-decode-region))
4211 (defvar gnus-decode-header-methods-cache nil)
4213 (defun gnus-multi-decode-header (start end)
4214 "Apply the functions from `gnus-encoded-word-methods' that match."
4215 (unless (and gnus-decode-header-methods-cache
4216 (eq gnus-newsgroup-name
4217 (car gnus-decode-header-methods-cache)))
4218 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
4221 (nconc gnus-decode-header-methods-cache (list x))
4222 (if (and gnus-newsgroup-name
4223 (string-match (car x) gnus-newsgroup-name))
4224 (nconc gnus-decode-header-methods-cache
4226 gnus-decode-header-methods))
4227 (let ((xlist gnus-decode-header-methods-cache))
4230 (narrow-to-region start end)
4232 (funcall (pop xlist) (point-min) (point-max))))))
4235 ;;; Treatment top-level handling.
4238 (defun gnus-treat-article (condition &optional part-number total-parts type)
4239 (let ((length (- (point-max) (point-min)))
4240 (alist gnus-treatment-function-alist)
4241 (article-goto-body-goes-to-point-min-p t)
4245 (let ((list gnus-article-treat-types))
4247 (when (string-match (pop list) type)
4248 (throw 'found t)))))))
4250 (when (gnus-visual-p 'article-highlight 'highlight)
4251 (gnus-run-hooks 'gnus-part-display-hook)
4252 (while (setq elem (pop alist))
4253 (setq val (symbol-value (car elem)))
4254 (when (and (or (consp val)
4256 (gnus-treat-predicate val))
4258 (funcall (cadr elem))))))))
4260 ;; Dynamic variables.
4261 (defvar part-number)
4262 (defvar total-parts)
4266 (defun gnus-treat-predicate (val)
4277 (eq part-number total-parts))
4281 (let ((pred (pop val)))
4284 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
4286 (apply 'gnus-and (mapcar 'gnus-tread-predicate val)))
4288 (not (gnus-treat-predicate val)))
4290 (equal (cadr val) type))
4292 (error "%S is not a valid predicate" pred)))))
4294 (error "%S is not a valid value" val))))
4300 (run-hooks 'gnus-art-load-hook)
4302 ;;; gnus-art.el ends here