1 ;;; gnus-art.el --- article mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
7 ;; This file is part of GNU Emacs.
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
28 (eval-when-compile (require 'cl
))
41 (defgroup gnus-article nil
43 :link
'(custom-manual "(gnus)The Article Buffer")
46 (defgroup gnus-article-treat nil
47 "Treating article parts."
48 :link
'(custom-manual "(gnus)Article Hiding")
51 (defgroup gnus-article-hiding nil
52 "Hiding article parts."
53 :link
'(custom-manual "(gnus)Article Hiding")
56 (defgroup gnus-article-highlight nil
57 "Article highlighting."
58 :link
'(custom-manual "(gnus)Article Highlighting")
62 (defgroup gnus-article-signature nil
64 :link
'(custom-manual "(gnus)Article Signature")
67 (defgroup gnus-article-headers nil
69 :link
'(custom-manual "(gnus)Hiding Headers")
72 (defgroup gnus-article-washing nil
73 "Special commands on articles."
74 :link
'(custom-manual "(gnus)Article Washing")
77 (defgroup gnus-article-emphasis nil
78 "Fontisizing articles."
79 :link
'(custom-manual "(gnus)Article Fontisizing")
82 (defgroup gnus-article-saving nil
84 :link
'(custom-manual "(gnus)Saving Articles")
87 (defgroup gnus-article-mime nil
88 "Worshiping the MIME wonder."
89 :link
'(custom-manual "(gnus)Using MIME")
92 (defgroup gnus-article-buttons nil
93 "Pushable buttons in the article buffer."
94 :link
'(custom-manual "(gnus)Article Buttons")
97 (defgroup gnus-article-various nil
98 "Other article options."
99 :link
'(custom-manual "(gnus)Misc Article")
100 :group
'gnus-article
)
102 (defcustom gnus-ignored-headers
103 '("^Path:" "^Expires:" "^Date-Received:" "^References:" "^Xref:" "^Lines:"
104 "^Relay-Version:" "^Message-ID:" "^Approved:" "^Sender:" "^Received:"
105 "^X-UIDL:" "^MIME-Version:" "^Return-Path:" "^In-Reply-To:"
106 "^Content-Type:" "^Content-Transfer-Encoding:" "^X-WebTV-Signature:"
107 "^X-MimeOLE:" "^X-MSMail-Priority:" "^X-Priority:" "^X-Loop:"
108 "^X-Authentication-Warning:" "^X-MIME-Autoconverted:" "^X-Face:"
109 "^X-Attribution:" "^X-Originating-IP:" "^Delivered-To:"
110 "^NNTP-[-A-Za-z]+:" "^Distribution:" "^X-no-archive:" "^X-Trace:"
111 "^X-Complaints-To:" "^X-NNTP-Posting-Host:" "^X-Orig.*:"
112 "^Abuse-Reports-To:" "^Cache-Post-Path:" "^X-Article-Creation-Date:"
113 "^X-Poster:" "^X-Mail2News-Path:" "^X-Server-Date:" "^X-Cache:"
114 "^Originator:" "^X-Problems-To:" "^X-Auth-User:" "^X-Post-Time:"
115 "^X-Admin:" "^X-UID:" "^Resent-[-A-Za-z]+:" "^X-Mailing-List:"
116 "^Precedence:" "^Original-[-A-Za-z]+:" "^X-filename:" "^X-Orcpt:"
117 "^Old-Received:" "^X-Pgp" "^X-Auth:" "^X-From-Line:"
118 "^X-Gnus-Article-Number:" "^X-Majordomo:" "^X-Url:" "^X-Sender:"
119 "^MBOX-Line" "^Priority:" "^X-Pgp" "^X400-[-A-Za-z]+:"
120 "^Status:" "^X-Gnus-Mail-Source:" "^Cancel-Lock:"
121 "^X-FTN" "^X-EXP32-SerialNo:" "^Encoding:" "^Importance:"
122 "^Autoforwarded:" "^Original-Encoded-Information-Types:" "^X-Ya-Pop3:"
123 "^X-Face-Version:" "^X-Vms-To:" "^X-ML-NAME:" "^X-ML-COUNT:"
124 "^Mailing-List:" "^X-finfo:" "^X-md5sum:" "^X-md5sum-Origin:"
125 "^X-Sun-Charset:" "^X-Accept-Language:" "^X-Envelope-Sender:"
126 "^List-[A-Za-z]+:" "^X-Listprocessor-Version:"
127 "^X-Received:" "^X-Distribute:" "^X-Sequence:" "^X-Juno-Line-Breaks:"
128 "^X-Notes-Item:" "^X-MS-TNEF-Correlator:" "^x-uunet-gateway:"
129 "^X-Received:" "^Content-length:" "X-precedence:")
130 "*All headers that start with this regexp will be hidden.
131 This variable can also be a list of regexps of headers to be ignored.
132 If `gnus-visible-headers' is non-nil, this variable will be ignored."
133 :type
'(choice :custom-show nil
136 :group
'gnus-article-hiding
)
138 (defcustom gnus-visible-headers
139 "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^[BGF]?Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-From:\\|^X-Sent:"
140 "*All headers that do not match this regexp will be hidden.
141 This variable can also be a list of regexp of headers to remain visible.
142 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
143 :type
'(repeat :value-to-internal
(lambda (widget value
)
144 (custom-split-regexp-maybe value
))
145 :match
(lambda (widget value
)
147 (widget-editable-list-match widget value
)))
149 :group
'gnus-article-hiding
)
151 (defcustom gnus-sorted-header-list
152 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
153 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
154 "*This variable is a list of regular expressions.
155 If it is non-nil, headers that match the regular expressions will
156 be placed first in the article buffer in the sequence specified by
158 :type
'(repeat regexp
)
159 :group
'gnus-article-hiding
)
161 (defcustom gnus-boring-article-headers
'(empty followup-to reply-to
)
162 "Headers that are only to be displayed if they have interesting data.
163 Possible values in this list are `empty', `newsgroups', `followup-to',
164 `reply-to', `date', `long-to', and `many-to'."
165 :type
'(set (const :tag
"Headers with no content." empty
)
166 (const :tag
"Newsgroups with only one group." newsgroups
)
167 (const :tag
"Followup-to identical to newsgroups." followup-to
)
168 (const :tag
"Reply-to identical to from." reply-to
)
169 (const :tag
"Date less than four days old." date
)
170 (const :tag
"Very long To and/or Cc header." long-to
)
171 (const :tag
"Multiple To and/or Cc headers." many-to
))
172 :group
'gnus-article-hiding
)
174 (defcustom gnus-signature-separator
'("^-- $" "^-- *$")
175 "Regexp matching signature separator.
176 This can also be a list of regexps. In that case, it will be checked
177 from head to tail looking for a separator. Searches will be done from
178 the end of the buffer."
179 :type
'(repeat string
)
180 :group
'gnus-article-signature
)
182 (defcustom gnus-signature-limit nil
183 "Provide a limit to what is considered a signature.
184 If it is a number, no signature may not be longer (in characters) than
185 that number. If it is a floating point number, no signature may be
186 longer (in lines) than that number. If it is a function, the function
187 will be called without any parameters, and if it returns nil, there is
188 no signature in the buffer. If it is a string, it will be used as a
189 regexp. If it matches, the text in question is not a signature."
190 :type
'(choice (integer :value
200)
192 (function :value fun
)
193 (regexp :value
".*"))
194 :group
'gnus-article-signature
)
196 (defcustom gnus-hidden-properties
'(invisible t intangible t
)
197 "Property list to use for hiding text."
199 :group
'gnus-article-hiding
)
201 ;; Fixme: This isn't the right thing for mixed graphical and and
202 ;; non-graphical frames in a session.
203 ;; gnus-xmas.el overrides this for XEmacs.
204 (defcustom gnus-article-x-face-command
205 (if (and (fboundp 'image-type-available-p
)
206 (image-type-available-p 'xbm
))
207 'gnus-article-display-xface
208 (if gnus-article-compface-xbm
209 "{ echo '/* Width=48, Height=48 */'; uncompface; } | display -"
210 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
212 "*String or function to be executed to display an X-Face header.
213 If it is a string, the command will be executed in a sub-shell
214 asynchronously. The compressed face will be piped to this command."
215 :type
'(choice string
216 (function-item gnus-article-display-xface
)
218 :group
'gnus-article-washing
)
220 (defcustom gnus-article-x-face-too-ugly nil
221 "Regexp matching posters whose face shouldn't be shown automatically."
222 :type
'(choice regexp
(const nil
))
223 :group
'gnus-article-washing
)
225 (defcustom gnus-article-banner-alist nil
226 "Banner alist for stripping.
228 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( eGroups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
230 :type
'(repeat (cons symbol regexp
))
231 :group
'gnus-article-washing
)
233 (defcustom gnus-emphasis-alist
235 "\\(\\s-\\|^\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\s-\\|[-,;:\"]\\s-\\|[?!.]+\\s-\\|\\s)\\)")
237 '(("_" "_" underline
)
240 ("_/" "/_" underline-italic
)
241 ("_\\*" "\\*_" underline-bold
)
242 ("\\*/" "/\\*" bold-italic
)
243 ("_\\*/" "/\\*_" underline-bold-italic
))))
244 `(("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
245 2 3 gnus-emphasis-underline
)
249 (format format
(car spec
) (cadr spec
))
250 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec
)))))
252 "*Alist that says how to fontify certain phrases.
253 Each item looks like this:
255 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
257 The first element is a regular expression to be matched. The second
258 is a number that says what regular expression grouping used to find
259 the entire emphasized word. The third is a number that says what
260 regexp grouping should be displayed and highlighted. The fourth
261 is the face used for highlighting."
262 :type
'(repeat (list :value
("" 0 0 default
)
264 (integer :tag
"Match group")
265 (integer :tag
"Emphasize group")
267 :group
'gnus-article-emphasis
)
269 (defcustom gnus-emphasize-whitespace-regexp
"^[ \t]+\\|[ \t]*\n"
270 "A regexp to describe whitespace which should not be emphasized.
271 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
272 The former avoids underlining of leading and trailing whitespace,
273 and the latter avoids underlining any whitespace at all."
275 :group
'gnus-article-emphasis
278 (defface gnus-emphasis-bold
'((t (:bold t
)))
279 "Face used for displaying strong emphasized text (*word*)."
280 :group
'gnus-article-emphasis
)
282 (defface gnus-emphasis-italic
'((t (:italic t
)))
283 "Face used for displaying italic emphasized text (/word/)."
284 :group
'gnus-article-emphasis
)
286 (defface gnus-emphasis-underline
'((t (:underline t
)))
287 "Face used for displaying underlined emphasized text (_word_)."
288 :group
'gnus-article-emphasis
)
290 (defface gnus-emphasis-underline-bold
'((t (:bold t
:underline t
)))
291 "Face used for displaying underlined bold emphasized text (_*word*_)."
292 :group
'gnus-article-emphasis
)
294 (defface gnus-emphasis-underline-italic
'((t (:italic t
:underline t
)))
295 "Face used for displaying underlined italic emphasized text (_/word/_)."
296 :group
'gnus-article-emphasis
)
298 (defface gnus-emphasis-bold-italic
'((t (:bold t
:italic t
)))
299 "Face used for displaying bold italic emphasized text (/*word*/)."
300 :group
'gnus-article-emphasis
)
302 (defface gnus-emphasis-underline-bold-italic
303 '((t (:bold t
:italic t
:underline t
)))
304 "Face used for displaying underlined bold italic emphasized text.
305 Esample: (_/*word*/_)."
306 :group
'gnus-article-emphasis
)
308 (defface gnus-emphasis-highlight-words
309 '((t (:background
"black" :foreground
"yellow")))
310 "Face used for displaying highlighted words."
311 :group
'gnus-article-emphasis
)
313 (defcustom gnus-article-time-format
"%a, %b %d %Y %T %Z"
314 "Format for display of Date headers in article bodies.
315 See `format-time-string' for the possible values.
317 The variable can also be function, which should return a complete Date
318 header. The function is called with one argument, the time, which can
319 be fed to `format-time-string'."
320 :type
'(choice string symbol
)
321 :link
'(custom-manual "(gnus)Article Date")
322 :group
'gnus-article-washing
)
325 (autoload 'mail-extract-address-components
"mail-extr"))
327 (defcustom gnus-save-all-headers t
328 "*If non-nil, don't remove any headers before saving."
329 :group
'gnus-article-saving
332 (defcustom gnus-prompt-before-saving
'always
333 "*This variable says how much prompting is to be done when saving articles.
334 If it is nil, no prompting will be done, and the articles will be
335 saved to the default files. If this variable is `always', each and
336 every article that is saved will be preceded by a prompt, even when
337 saving large batches of articles. If this variable is neither nil not
338 `always', there the user will be prompted once for a file name for
339 each invocation of the saving commands."
340 :group
'gnus-article-saving
341 :type
'(choice (item always
)
342 (item :tag
"never" nil
)
343 (sexp :tag
"once" :format
"%t\n" :value t
)))
345 (defcustom gnus-saved-headers gnus-visible-headers
346 "Headers to keep if `gnus-save-all-headers' is nil.
347 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
348 If that variable is nil, however, all headers that match this regexp
349 will be kept while the rest will be deleted before saving."
350 :group
'gnus-article-saving
353 (defcustom gnus-default-article-saver
'gnus-summary-save-in-rmail
354 "A function to save articles in your favourite format.
355 The function must be interactively callable (in other words, it must
356 be an Emacs command).
358 Gnus provides the following functions:
360 * gnus-summary-save-in-rmail (Rmail format)
361 * gnus-summary-save-in-mail (Unix mail format)
362 * gnus-summary-save-in-folder (MH folder)
363 * gnus-summary-save-in-file (article format)
364 * gnus-summary-save-in-vm (use VM's folder format)
365 * gnus-summary-write-to-file (article format -- overwrite)."
366 :group
'gnus-article-saving
367 :type
'(radio (function-item gnus-summary-save-in-rmail
)
368 (function-item gnus-summary-save-in-mail
)
369 (function-item gnus-summary-save-in-folder
)
370 (function-item gnus-summary-save-in-file
)
371 (function-item gnus-summary-save-in-vm
)
372 (function-item gnus-summary-write-to-file
)))
374 (defcustom gnus-rmail-save-name
'gnus-plain-save-name
375 "A function generating a file name to save articles in Rmail format.
376 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
377 :group
'gnus-article-saving
380 (defcustom gnus-mail-save-name
'gnus-plain-save-name
381 "A function generating a file name to save articles in Unix mail format.
382 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
383 :group
'gnus-article-saving
386 (defcustom gnus-folder-save-name
'gnus-folder-save-name
387 "A function generating a file name to save articles in MH folder.
388 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
389 :group
'gnus-article-saving
392 (defcustom gnus-file-save-name
'gnus-numeric-save-name
393 "A function generating a file name to save articles in article format.
394 The function is called with NEWSGROUP, HEADERS, and optional
396 :group
'gnus-article-saving
399 (defcustom gnus-split-methods
400 '((gnus-article-archive-name)
401 (gnus-article-nndoc-name))
402 "*Variable used to suggest where articles are to be saved.
403 For instance, if you would like to save articles related to Gnus in
404 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
405 you could set this variable to something like:
407 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
408 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
410 This variable is an alist where the where the key is the match and the
411 value is a list of possible files to save in if the match is non-nil.
413 If the match is a string, it is used as a regexp match on the
414 article. If the match is a symbol, that symbol will be funcalled
415 from the buffer of the article to be saved with the newsgroup as the
416 parameter. If it is a list, it will be evaled in the same buffer.
418 If this form or function returns a string, this string will be used as
419 a possible file name; and if it returns a non-nil list, that list will
420 be used as possible file names."
421 :group
'gnus-article-saving
422 :type
'(repeat (choice (list :value
(fun) function
)
423 (cons :value
("" "") regexp
(repeat string
))
426 (defcustom gnus-page-delimiter
"^\^L"
427 "*Regexp describing what to use as article page delimiters.
428 The default value is \"^\^L\", which is a form linefeed at the
429 beginning of a line."
431 :group
'gnus-article-various
)
433 (defcustom gnus-article-mode-line-format
"Gnus: %g [%w] %S%m"
434 "*The format specification for the article mode line.
435 See `gnus-summary-mode-line-format' for a closer description.
437 The following additional specs are available:
439 %w The article washing status.
440 %m The number of MIME parts in the article."
442 :group
'gnus-article-various
)
444 (defcustom gnus-article-mode-hook nil
445 "*A hook for Gnus article mode."
447 :group
'gnus-article-various
)
449 (defcustom gnus-article-menu-hook nil
450 "*Hook run after the creation of the article mode menu."
452 :group
'gnus-article-various
)
454 (defcustom gnus-article-prepare-hook nil
455 "*A hook called after an article has been prepared in the article buffer."
457 :group
'gnus-article-various
)
459 (defcustom gnus-article-hide-pgp-hook nil
460 "*A hook called after successfully hiding a PGP signature."
462 :group
'gnus-article-various
)
464 (defcustom gnus-article-button-face
'bold
465 "Face used for highlighting buttons in the article buffer.
467 An article button is a piece of text that you can activate by pressing
468 `RET' or `mouse-2' above it."
470 :group
'gnus-article-buttons
)
472 (defcustom gnus-article-mouse-face
'highlight
473 "Face used for mouse highlighting in the article buffer.
475 Article buttons will be displayed in this face when the cursor is
478 :group
'gnus-article-buttons
)
480 (defcustom gnus-signature-face
'gnus-signature-face
481 "Face used for highlighting a signature in the article buffer.
482 Obsolete; use the face `gnus-signature-face' for customizations instead."
484 :group
'gnus-article-highlight
485 :group
'gnus-article-signature
)
487 (defface gnus-signature-face
490 "Face used for highlighting a signature in the article buffer."
491 :group
'gnus-article-highlight
492 :group
'gnus-article-signature
)
494 (defface gnus-header-from-face
497 (:foreground
"spring green"))
500 (:foreground
"red3"))
503 "Face used for displaying from headers."
504 :group
'gnus-article-headers
505 :group
'gnus-article-highlight
)
507 (defface gnus-header-subject-face
510 (:foreground
"SeaGreen3"))
513 (:foreground
"red4"))
515 (:bold t
:italic t
)))
516 "Face used for displaying subject headers."
517 :group
'gnus-article-headers
518 :group
'gnus-article-highlight
)
520 (defface gnus-header-newsgroups-face
523 (:foreground
"yellow" :italic t
))
526 (:foreground
"MidnightBlue" :italic t
))
529 "Face used for displaying newsgroups headers."
530 :group
'gnus-article-headers
531 :group
'gnus-article-highlight
)
533 (defface gnus-header-name-face
536 (:foreground
"SeaGreen"))
539 (:foreground
"maroon"))
542 "Face used for displaying header names."
543 :group
'gnus-article-headers
544 :group
'gnus-article-highlight
)
546 (defface gnus-header-content-face
549 (:foreground
"forest green" :italic t
))
552 (:foreground
"indianred4" :italic t
))
554 (:italic t
))) "Face used for displaying header content."
555 :group
'gnus-article-headers
556 :group
'gnus-article-highlight
)
558 (defcustom gnus-header-face-alist
559 '(("From" nil gnus-header-from-face
)
560 ("Subject" nil gnus-header-subject-face
)
561 ("Newsgroups:.*," nil gnus-header-newsgroups-face
)
562 ("" gnus-header-name-face gnus-header-content-face
))
563 "*Controls highlighting of article header.
565 An alist of the form (HEADER NAME CONTENT).
567 HEADER is a regular expression which should match the name of an
568 header header and NAME and CONTENT are either face names or nil.
570 The name of each header field will be displayed using the face
571 specified by the first element in the list where HEADER match the
572 header name and NAME is non-nil. Similarly, the content will be
573 displayed by the first non-nil matching CONTENT face."
574 :group
'gnus-article-headers
575 :group
'gnus-article-highlight
576 :type
'(repeat (list (regexp :tag
"Header")
578 (item :tag
"skip" nil
)
579 (face :value default
))
580 (choice :tag
"Content"
581 (item :tag
"skip" nil
)
582 (face :value default
)))))
584 (defcustom gnus-article-decode-hook
585 '(article-decode-charset article-decode-encoded-words
)
586 "*Hook run to decode charsets in articles."
587 :group
'gnus-article-headers
590 (defcustom gnus-display-mime-function
'gnus-display-mime
591 "Function to display MIME articles."
592 :group
'gnus-article-mime
595 (defvar gnus-decode-header-function
'mail-decode-encoded-word-region
596 "Function used to decode headers.")
598 (defvar gnus-article-dumbquotes-map
616 "Table for MS-to-Latin1 translation.")
618 (defcustom gnus-ignored-mime-types nil
619 "List of MIME types that should be ignored by Gnus."
621 :group
'gnus-article-mime
622 :type
'(repeat regexp
))
624 (defcustom gnus-unbuttonized-mime-types
'(".*/.*")
625 "List of MIME types that should not be given buttons when rendered inline."
627 :group
'gnus-article-mime
628 :type
'(repeat regexp
))
630 (defcustom gnus-article-mime-part-function nil
631 "Function called with a MIME handle as the argument.
632 This is meant for people who want to do something automatic based
633 on parts -- for instance, adding Vcard info to a database."
634 :group
'gnus-article-mime
637 (defcustom gnus-mime-multipart-functions nil
638 "An alist of MIME types to functions to display them."
640 :group
'gnus-article-mime
643 (defcustom gnus-article-date-lapsed-new-header nil
644 "Whether the X-Sent and Date headers can coexist.
645 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
646 either replace the old \"Date:\" header (if this variable is nil), or
647 be added below it (otherwise)."
649 :group
'gnus-article-headers
652 (defcustom gnus-article-mime-match-handle-function
'undisplayed-alternative
653 "Function called with a MIME handle as the argument.
654 This is meant for people who want to view first matched part.
655 For `undisplayed-alternative' (default), the first undisplayed
656 part or alternative part is used. For `undisplayed', the first
657 undisplayed part is used. For a function, the first part which
658 the function return `t' is used. For `nil', the first part is
661 :group
'gnus-article-mime
663 (item :tag
"first" :value nil
)
664 (item :tag
"undisplayed" :value undisplayed
)
665 (item :tag
"undisplayed or alternative"
666 :value undisplayed-alternative
)
669 (defcustom gnus-mime-action-alist
670 '(("save to file" . gnus-mime-save-part
)
671 ("display as text" . gnus-mime-inline-part
)
672 ("view the part" . gnus-mime-view-part
)
673 ("pipe to command" . gnus-mime-pipe-part
)
674 ("toggle display" . gnus-article-press-button
)
675 ("view as type" . gnus-mime-view-part-as-type
)
676 ("internalize type" . gnus-mime-internalize-part
)
677 ("externalize type" . gnus-mime-externalize-part
))
678 "An alist of actions that run on the MIME attachment."
680 :group
'gnus-article-mime
681 :type
'(repeat (cons (string :tag
"name")
685 ;;; The treatment variables
688 (defvar gnus-part-display-hook nil
689 "Hook called on parts that are to receive treatment.")
691 (defvar gnus-article-treat-custom
692 '(choice (const :tag
"Off" nil
)
694 (const :tag
"Header" head
)
695 (const :tag
"Last" last
)
696 (integer :tag
"Less")
697 (repeat :tag
"Groups" regexp
)
698 (sexp :tag
"Predicate")))
700 (defvar gnus-article-treat-head-custom
701 '(choice (const :tag
"Off" nil
)
702 (const :tag
"Header" head
)))
704 (defvar gnus-article-treat-types
'("text/plain")
707 (defvar gnus-inhibit-treatment nil
708 "Whether to inhibit treatment.")
710 (defcustom gnus-treat-highlight-signature
'(or last
(typep "text/x-vcard"))
711 "Highlight the signature.
712 Valid values are nil, t, `head', `last', an integer or a predicate.
713 See the manual for details."
714 :group
'gnus-article-treat
715 :type gnus-article-treat-custom
)
716 (put 'gnus-treat-highlight-signature
'highlight t
)
718 (defcustom gnus-treat-buttonize
100000
720 Valid values are nil, t, `head', `last', an integer or a predicate.
721 See the manual for details."
722 :group
'gnus-article-treat
723 :type gnus-article-treat-custom
)
724 (put 'gnus-treat-buttonize
'highlight t
)
726 (defcustom gnus-treat-buttonize-head
'head
727 "Add buttons to the head.
728 Valid values are nil, t, `head', `last', an integer or a predicate.
729 See the manual for details."
730 :group
'gnus-article-treat
731 :type gnus-article-treat-head-custom
)
732 (put 'gnus-treat-buttonize-head
'highlight t
)
734 (defcustom gnus-treat-emphasize
735 (and (or window-system
737 (>= (string-to-number emacs-version
) 21))
740 Valid values are nil, t, `head', `last', an integer or a predicate.
741 See the manual for details."
742 :group
'gnus-article-treat
743 :type gnus-article-treat-custom
)
744 (put 'gnus-treat-emphasize
'highlight t
)
746 (defcustom gnus-treat-strip-cr nil
747 "Remove carriage returns.
748 Valid values are nil, t, `head', `last', an integer or a predicate.
749 See the manual for details."
750 :group
'gnus-article-treat
751 :type gnus-article-treat-custom
)
753 (defcustom gnus-treat-hide-headers
'head
755 Valid values are nil, t, `head', `last', an integer or a predicate.
756 See the manual for details."
757 :group
'gnus-article-treat
758 :type gnus-article-treat-head-custom
)
760 (defcustom gnus-treat-hide-boring-headers nil
761 "Hide boring headers.
762 Valid values are nil, t, `head', `last', an integer or a predicate.
763 See the manual for details."
764 :group
'gnus-article-treat
765 :type gnus-article-treat-head-custom
)
767 (defcustom gnus-treat-hide-signature nil
769 Valid values are nil, t, `head', `last', an integer or a predicate.
770 See the manual for details."
771 :group
'gnus-article-treat
772 :type gnus-article-treat-custom
)
774 (defcustom gnus-treat-fill-article nil
776 Valid values are nil, t, `head', `last', an integer or a predicate.
777 See the manual for details."
778 :group
'gnus-article-treat
779 :type gnus-article-treat-custom
)
781 (defcustom gnus-treat-hide-citation nil
783 Valid values are nil, t, `head', `last', an integer or a predicate.
784 See the manual for details."
785 :group
'gnus-article-treat
786 :type gnus-article-treat-custom
)
788 (defcustom gnus-treat-hide-citation-maybe nil
790 Valid values are nil, t, `head', `last', an integer or a predicate.
791 See the manual for details."
792 :group
'gnus-article-treat
793 :type gnus-article-treat-custom
)
795 (defcustom gnus-treat-strip-list-identifiers
'head
796 "Strip list identifiers from `gnus-list-identifiers`.
797 Valid values are nil, t, `head', `last', an integer or a predicate.
798 See the manual for details."
800 :group
'gnus-article-treat
801 :type gnus-article-treat-custom
)
803 (defcustom gnus-treat-strip-pgp t
804 "Strip PGP signatures.
805 Valid values are nil, t, `head', `last', an integer or a predicate.
806 See the manual for details."
807 :group
'gnus-article-treat
808 :type gnus-article-treat-custom
)
810 (defcustom gnus-treat-strip-pem nil
811 "Strip PEM signatures.
812 Valid values are nil, t, `head', `last', an integer or a predicate.
813 See the manual for details."
814 :group
'gnus-article-treat
815 :type gnus-article-treat-custom
)
817 (defcustom gnus-treat-strip-banner t
818 "Strip banners from articles.
819 The banner to be stripped is specified in the `banner' group parameter.
820 Valid values are nil, t, `head', `last', an integer or a predicate.
821 See the manual for details."
822 :group
'gnus-article-treat
823 :type gnus-article-treat-custom
)
825 (defcustom gnus-treat-highlight-headers
'head
826 "Highlight the headers.
827 Valid values are nil, t, `head', `last', an integer or a predicate.
828 See the manual for details."
829 :group
'gnus-article-treat
830 :type gnus-article-treat-head-custom
)
831 (put 'gnus-treat-highlight-headers
'highlight t
)
833 (defcustom gnus-treat-highlight-citation t
834 "Highlight cited text.
835 Valid values are nil, t, `head', `last', an integer or a predicate.
836 See the manual for details."
837 :group
'gnus-article-treat
838 :type gnus-article-treat-custom
)
839 (put 'gnus-treat-highlight-citation
'highlight t
)
841 (defcustom gnus-treat-date-ut nil
842 "Display the Date in UT (GMT).
843 Valid values are nil, t, `head', `last', an integer or a predicate.
844 See the manual for details."
845 :group
'gnus-article-treat
846 :type gnus-article-treat-head-custom
)
848 (defcustom gnus-treat-date-local nil
849 "Display the Date in the local timezone.
850 Valid values are nil, t, `head', `last', an integer or a predicate.
851 See the manual for details."
852 :group
'gnus-article-treat
853 :type gnus-article-treat-head-custom
)
855 (defcustom gnus-treat-date-lapsed nil
856 "Display the Date header in a way that says how much time has elapsed.
857 Valid values are nil, t, `head', `last', an integer or a predicate.
858 See the manual for details."
859 :group
'gnus-article-treat
860 :type gnus-article-treat-head-custom
)
862 (defcustom gnus-treat-date-original nil
863 "Display the date in the original timezone.
864 Valid values are nil, t, `head', `last', an integer or a predicate.
865 See the manual for details."
866 :group
'gnus-article-treat
867 :type gnus-article-treat-head-custom
)
869 (defcustom gnus-treat-date-iso8601 nil
870 "Display the date in the ISO8601 format.
871 Valid values are nil, t, `head', `last', an integer or a predicate.
872 See the manual for details."
874 :group
'gnus-article-treat
875 :type gnus-article-treat-head-custom
)
877 (defcustom gnus-treat-date-user-defined nil
878 "Display the date in a user-defined format.
879 The format is defined by the `gnus-article-time-format' variable.
880 Valid values are nil, t, `head', `last', an integer or a predicate.
881 See the manual for details."
882 :group
'gnus-article-treat
883 :type gnus-article-treat-head-custom
)
885 (defcustom gnus-treat-strip-headers-in-body t
886 "Strip the X-No-Archive header line from the beginning of the body.
887 Valid values are nil, t, `head', `last', an integer or a predicate.
888 See the manual for details."
890 :group
'gnus-article-treat
891 :type gnus-article-treat-custom
)
893 (defcustom gnus-treat-strip-trailing-blank-lines nil
894 "Strip trailing blank lines.
895 Valid values are nil, t, `head', `last', an integer or a predicate.
896 See the manual for details."
897 :group
'gnus-article-treat
898 :type gnus-article-treat-custom
)
900 (defcustom gnus-treat-strip-leading-blank-lines nil
901 "Strip leading blank lines.
902 Valid values are nil, t, `head', `last', an integer or a predicate.
903 See the manual for details."
904 :group
'gnus-article-treat
905 :type gnus-article-treat-custom
)
907 (defcustom gnus-treat-strip-multiple-blank-lines nil
908 "Strip multiple blank lines.
909 Valid values are nil, t, `head', `last', an integer or a predicate.
910 See the manual for details."
911 :group
'gnus-article-treat
912 :type gnus-article-treat-custom
)
914 (defcustom gnus-treat-overstrike t
915 "Treat overstrike highlighting.
916 Valid values are nil, t, `head', `last', an integer or a predicate.
917 See the manual for details."
918 :group
'gnus-article-treat
919 :type gnus-article-treat-custom
)
920 (put 'gnus-treat-overstrike
'highlight t
)
922 (defcustom gnus-treat-display-xface
923 (and (or (and (fboundp 'image-type-available-p
)
924 (image-type-available-p 'xbm
)
925 (string-match "^0x" (shell-command-to-string "uncompface")))
926 (and (featurep 'xemacs
) (featurep 'xface
)))
928 "Display X-Face headers.
929 Valid values are nil, t, `head', `last', an integer or a predicate.
930 See the manual for details."
931 :group
'gnus-article-treat
932 :type gnus-article-treat-head-custom
)
933 (put 'gnus-treat-display-xface
'highlight t
)
935 (defcustom gnus-treat-display-smileys
936 (if (or (and (featurep 'xemacs
)
938 (and (fboundp 'image-type-available-p
)
939 (image-type-available-p 'pbm
)))
942 Valid values are nil, t, `head', `last', an integer or a predicate.
943 See the manual for details."
944 :group
'gnus-article-treat
945 :type gnus-article-treat-custom
)
946 (put 'gnus-treat-display-smileys
'highlight t
)
948 (defcustom gnus-treat-display-picons
(if (featurep 'xemacs
) 'head nil
)
950 Valid values are nil, t, `head', `last', an integer or a predicate.
951 See the manual for details."
952 :group
'gnus-article-treat
953 :type gnus-article-treat-head-custom
)
954 (put 'gnus-treat-display-picons
'highlight t
)
956 (defcustom gnus-treat-capitalize-sentences nil
957 "Capitalize sentence-starting words.
958 Valid values are nil, t, `head', `last', an integer or a predicate.
959 See the manual for details."
961 :group
'gnus-article-treat
962 :type gnus-article-treat-custom
)
964 (defcustom gnus-treat-fill-long-lines nil
966 Valid values are nil, t, `head', `last', an integer or a predicate.
967 See the manual for details."
968 :group
'gnus-article-treat
969 :type gnus-article-treat-custom
)
971 (defcustom gnus-treat-play-sounds nil
973 Valid values are nil, t, `head', `last', an integer or a predicate.
974 See the manual for details."
976 :group
'gnus-article-treat
977 :type gnus-article-treat-custom
)
979 (defcustom gnus-treat-translate nil
980 "Translate articles from one language to another.
981 Valid values are nil, t, `head', `last', an integer or a predicate.
982 See the manual for details."
984 :group
'gnus-article-treat
985 :type gnus-article-treat-custom
)
987 ;;; Internal variables
989 (defvar article-goto-body-goes-to-point-min-p nil
)
990 (defvar gnus-article-wash-types nil
)
991 (defvar gnus-article-emphasis-alist nil
)
993 (defvar gnus-article-mime-handle-alist-1 nil
)
994 (defvar gnus-treatment-function-alist
995 '((gnus-treat-strip-banner gnus-article-strip-banner
)
996 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body
)
997 (gnus-treat-highlight-signature gnus-article-highlight-signature
)
998 (gnus-treat-buttonize gnus-article-add-buttons
)
999 (gnus-treat-fill-article gnus-article-fill-cited-article
)
1000 (gnus-treat-fill-long-lines gnus-article-fill-long-lines
)
1001 (gnus-treat-strip-cr gnus-article-remove-cr
)
1002 (gnus-treat-emphasize gnus-article-emphasize
)
1003 (gnus-treat-display-xface gnus-article-display-x-face
)
1004 (gnus-treat-hide-headers gnus-article-maybe-hide-headers
)
1005 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers
)
1006 (gnus-treat-hide-signature gnus-article-hide-signature
)
1007 (gnus-treat-hide-citation gnus-article-hide-citation
)
1008 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe
)
1009 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers
)
1010 (gnus-treat-strip-pgp gnus-article-hide-pgp
)
1011 (gnus-treat-strip-pem gnus-article-hide-pem
)
1012 (gnus-treat-highlight-headers gnus-article-highlight-headers
)
1013 (gnus-treat-highlight-citation gnus-article-highlight-citation
)
1014 (gnus-treat-highlight-signature gnus-article-highlight-signature
)
1015 (gnus-treat-date-ut gnus-article-date-ut
)
1016 (gnus-treat-date-local gnus-article-date-local
)
1017 (gnus-treat-date-lapsed gnus-article-date-lapsed
)
1018 (gnus-treat-date-original gnus-article-date-original
)
1019 (gnus-treat-date-user-defined gnus-article-date-user
)
1020 (gnus-treat-date-iso8601 gnus-article-date-iso8601
)
1021 (gnus-treat-strip-trailing-blank-lines
1022 gnus-article-remove-trailing-blank-lines
)
1023 (gnus-treat-strip-leading-blank-lines
1024 gnus-article-strip-leading-blank-lines
)
1025 (gnus-treat-strip-multiple-blank-lines
1026 gnus-article-strip-multiple-blank-lines
)
1027 (gnus-treat-overstrike gnus-article-treat-overstrike
)
1028 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head
)
1029 (gnus-treat-display-smileys gnus-smiley-display
)
1030 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences
)
1031 (gnus-treat-display-picons gnus-article-display-picons
)
1032 (gnus-treat-play-sounds gnus-earcon-display
)))
1034 (defvar gnus-article-mime-handle-alist nil
)
1035 (defvar article-lapsed-timer nil
)
1036 (defvar gnus-article-current-summary nil
)
1038 (defvar gnus-article-mode-syntax-table
1039 (let ((table (copy-syntax-table text-mode-syntax-table
)))
1040 (modify-syntax-entry ?-
"w" table
)
1041 (modify-syntax-entry ?
> ")" table
)
1042 (modify-syntax-entry ?
< "(" table
)
1044 "Syntax table used in article mode buffers.
1045 Initialized from `text-mode-syntax-table.")
1047 (defvar gnus-save-article-buffer nil
)
1049 (defvar gnus-article-mode-line-format-alist
1050 (nconc '((?w
(gnus-article-wash-status) ?s
)
1051 (?m
(gnus-article-mime-part-status) ?s
))
1052 gnus-summary-mode-line-format-alist
))
1054 (defvar gnus-number-of-articles-to-be-saved nil
)
1056 (defvar gnus-inhibit-hiding nil
)
1058 (defsubst gnus-article-hide-text
(b e props
)
1059 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1060 (gnus-add-text-properties-when 'article-type nil b e props
)
1061 (when (memq 'intangible props
)
1063 (max (1- b
) (point-min))
1064 b
'intangible
(cddr (memq 'intangible props
)))))
1066 (defsubst gnus-article-unhide-text
(b e
)
1067 "Remove hidden text properties from region between B and E."
1068 (remove-text-properties b e gnus-hidden-properties
)
1069 (when (memq 'intangible gnus-hidden-properties
)
1070 (put-text-property (max (1- b
) (point-min))
1071 b
'intangible nil
)))
1073 (defun gnus-article-hide-text-type (b e type
)
1074 "Hide text of TYPE between B and E."
1075 (push type gnus-article-wash-types
)
1076 (gnus-article-hide-text
1077 b e
(cons 'article-type
(cons type gnus-hidden-properties
))))
1079 (defun gnus-article-unhide-text-type (b e type
)
1080 "Unhide text of TYPE between B and E."
1081 (setq gnus-article-wash-types
1082 (delq type gnus-article-wash-types
))
1083 (remove-text-properties
1084 b e
(cons 'article-type
(cons type gnus-hidden-properties
)))
1085 (when (memq 'intangible gnus-hidden-properties
)
1086 (put-text-property (max (1- b
) (point-min))
1087 b
'intangible nil
)))
1089 (defun gnus-article-hide-text-of-type (type)
1090 "Hide text of TYPE in the current buffer."
1092 (let ((b (point-min))
1094 (while (setq b
(text-property-any b e
'article-type type
))
1095 (add-text-properties b
(incf b
) gnus-hidden-properties
)))))
1097 (defun gnus-article-delete-text-of-type (type)
1098 "Delete text of TYPE in the current buffer."
1100 (let ((b (point-min)))
1101 (while (setq b
(text-property-any b
(point-max) 'article-type type
))
1103 b
(or (text-property-not-all b
(point-max) 'article-type type
)
1106 (defun gnus-article-delete-invisible-text ()
1107 "Delete all invisible text in the current buffer."
1109 (let ((b (point-min)))
1110 (while (setq b
(text-property-any b
(point-max) 'invisible t
))
1112 b
(or (text-property-not-all b
(point-max) 'invisible t
)
1115 (defun gnus-article-text-type-exists-p (type)
1116 "Say whether any text of type TYPE exists in the buffer."
1117 (text-property-any (point-min) (point-max) 'article-type type
))
1119 (defsubst gnus-article-header-rank
()
1120 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1121 (let ((list gnus-sorted-header-list
)
1124 (when (looking-at (car list
))
1126 (setq list
(cdr list
))
1130 (defun article-hide-headers (&optional arg delete
)
1131 "Hide unwanted headers and possibly sort them as well."
1133 ;; This function might be inhibited.
1134 (unless gnus-inhibit-hiding
1137 (let ((buffer-read-only nil
)
1138 (case-fold-search t
)
1139 (max (1+ (length gnus-sorted-header-list
)))
1140 (ignored (when (not gnus-visible-headers
)
1141 (cond ((stringp gnus-ignored-headers
)
1142 gnus-ignored-headers
)
1143 ((listp gnus-ignored-headers
)
1144 (mapconcat 'identity gnus-ignored-headers
1147 (cond ((stringp gnus-visible-headers
)
1148 gnus-visible-headers
)
1149 ((and gnus-visible-headers
1150 (listp gnus-visible-headers
))
1151 (mapconcat 'identity gnus-visible-headers
"\\|"))))
1152 (inhibit-point-motion-hooks t
)
1154 ;; First we narrow to just the headers.
1155 (article-narrow-to-head)
1156 ;; Hide any "From " lines at the beginning of (mail) articles.
1157 (while (looking-at "From ")
1160 (delete-region (point-min) (point)))
1161 ;; Then treat the rest of the header lines.
1162 ;; Then we use the two regular expressions
1163 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1164 ;; select which header lines is to remain visible in the
1166 (while (re-search-forward "^[^ \t]*:" nil t
)
1168 ;; Mark the rank of the header.
1170 (point) (1+ (point)) 'message-rank
1171 (if (or (and visible
(looking-at visible
))
1173 (not (looking-at ignored
))))
1174 (gnus-article-header-rank)
1177 (message-sort-headers-1)
1178 (when (setq beg
(text-property-any
1179 (point-min) (point-max) 'message-rank
(+ 2 max
)))
1180 ;; We delete the unwanted headers.
1181 (push 'headers gnus-article-wash-types
)
1182 (add-text-properties (point-min) (+ 5 (point-min))
1183 '(article-type headers dummy-invisible t
))
1184 (delete-region beg
(point-max))))))))
1186 (defun article-hide-boring-headers (&optional arg
)
1187 "Toggle hiding of headers that aren't very interesting.
1188 If given a negative prefix, always show; if given a positive prefix,
1190 (interactive (gnus-article-hidden-arg))
1191 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg
))
1192 (not gnus-show-all-headers
))
1195 (let ((buffer-read-only nil
)
1196 (list gnus-boring-article-headers
)
1197 (inhibit-point-motion-hooks t
)
1199 (article-narrow-to-head)
1201 (setq elem
(pop list
))
1202 (goto-char (point-min))
1204 ;; Hide empty headers.
1206 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t
)
1208 (gnus-article-hide-text-type
1209 (progn (beginning-of-line) (point))
1212 (if (re-search-forward "^[^ \t]" nil t
)
1216 ;; Hide boring Newsgroups header.
1217 ((eq elem
'newsgroups
)
1218 (when (equal (gnus-fetch-field "newsgroups")
1219 (gnus-group-real-name
1220 (if (boundp 'gnus-newsgroup-name
)
1223 (gnus-article-hide-header "newsgroups")))
1224 ((eq elem
'followup-to
)
1225 (when (equal (message-fetch-field "followup-to")
1226 (message-fetch-field "newsgroups"))
1227 (gnus-article-hide-header "followup-to")))
1228 ((eq elem
'reply-to
)
1229 (let ((from (message-fetch-field "from"))
1230 (reply-to (message-fetch-field "reply-to")))
1235 (nth 1 (mail-extract-address-components from
))
1236 (nth 1 (mail-extract-address-components reply-to
)))))
1237 (gnus-article-hide-header "reply-to"))))
1239 (let ((date (message-fetch-field "date")))
1241 (< (days-between (current-time-string) date
)
1243 (gnus-article-hide-header "date"))))
1245 (let ((to (message-fetch-field "to"))
1246 (cc (message-fetch-field "cc")))
1247 (when (> (length to
) 1024)
1248 (gnus-article-hide-header "to"))
1249 (when (> (length cc
) 1024)
1250 (gnus-article-hide-header "cc"))))
1254 (goto-char (point-min))
1255 (while (re-search-forward "^to:" nil t
)
1256 (setq to-count
(1+ to-count
)))
1257 (when (> to-count
1)
1258 (while (> to-count
0)
1259 (goto-char (point-min))
1261 (re-search-forward "^to:" nil nil to-count
)
1263 (narrow-to-region (point) (point-max))
1264 (gnus-article-hide-header "to"))
1265 (setq to-count
(1- to-count
))))
1266 (goto-char (point-min))
1267 (while (re-search-forward "^cc:" nil t
)
1268 (setq cc-count
(1+ cc-count
)))
1269 (when (> cc-count
1)
1270 (while (> cc-count
0)
1271 (goto-char (point-min))
1273 (re-search-forward "^cc:" nil nil cc-count
)
1275 (narrow-to-region (point) (point-max))
1276 (gnus-article-hide-header "cc"))
1277 (setq cc-count
(1- cc-count
)))))))))))))
1279 (defun gnus-article-hide-header (header)
1281 (goto-char (point-min))
1282 (when (re-search-forward (concat "^" header
":") nil t
)
1283 (gnus-article-hide-text-type
1284 (progn (beginning-of-line) (point))
1287 (if (re-search-forward "^[^ \t]" nil t
)
1292 (defvar gnus-article-normalized-header-length
40
1293 "Length of normalized headers.")
1295 (defun article-normalize-headers ()
1296 "Make all header lines 40 characters long."
1298 (let ((buffer-read-only nil
)
1302 (article-narrow-to-head)
1305 ((< (setq column
(- (gnus-point-at-eol) (point)))
1306 gnus-article-normalized-header-length
)
1308 (insert (make-string
1309 (- gnus-article-normalized-header-length column
)
1311 ((> column gnus-article-normalized-header-length
)
1312 (gnus-put-text-property
1314 (forward-char gnus-article-normalized-header-length
)
1321 (forward-line 1))))))
1323 (defun article-treat-dumbquotes ()
1324 "Translate M****s*** sm*rtq**t*s into proper text.
1325 Note that this function guesses whether a character is a sm*rtq**t* or
1326 not, so it should only be used interactively.
1328 Sm*rtq**t*s are M****s***'s unilateral extension to the character map
1329 in an attempt to provide more quoting characters. If you see
1330 something like \\222 or \\264 where you're expecting some kind of
1331 apostrophe or quotation mark, then try this wash."
1333 (article-translate-strings gnus-article-dumbquotes-map
))
1335 (defun article-translate-characters (from to
)
1336 "Translate all characters in the body of the article according to FROM and TO.
1337 FROM is a string of characters to translate from; to is a string of
1338 characters to translate to."
1340 (when (article-goto-body)
1341 (let ((buffer-read-only nil
)
1342 (x (make-string 225 ?x
))
1344 (while (< (incf i
) (length x
))
1347 (while (< i
(length from
))
1348 (aset x
(aref from i
) (aref to i
))
1350 (translate-region (point) (point-max) x
)))))
1352 (defun article-translate-strings (map)
1353 "Translate all string in the body of the article according to MAP.
1354 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1356 (when (article-goto-body)
1357 (let ((buffer-read-only nil
)
1359 (while (setq elem
(pop map
))
1361 (while (search-forward (car elem
) nil t
)
1362 (replace-match (cadr elem
)))))))))
1364 (defun article-treat-overstrike ()
1365 "Translate overstrikes into bold text."
1368 (when (article-goto-body)
1369 (let ((buffer-read-only nil
))
1370 (while (search-forward "\b" nil t
)
1371 (let ((next (char-after))
1372 (previous (char-after (- (point) 2))))
1373 ;; We do the boldification/underlining by hiding the
1374 ;; overstrikes and putting the proper text property
1378 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike
)
1379 (put-text-property (point) (1+ (point)) 'face
'bold
))
1381 (gnus-article-hide-text-type
1382 (1- (point)) (1+ (point)) 'overstrike
)
1384 (- (point) 2) (1- (point)) 'face
'underline
))
1386 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike
)
1388 (point) (1+ (point)) 'face
'underline
)))))))))
1390 (defun article-fill-long-lines ()
1391 "Fill lines that are wider than the window width."
1394 (let ((buffer-read-only nil
)
1395 (width (window-width (get-buffer-window (current-buffer)))))
1398 (let ((adaptive-fill-mode nil
))
1401 (when (>= (current-column) (min fill-column width
))
1402 (narrow-to-region (point) (gnus-point-at-bol))
1403 (fill-paragraph nil
)
1404 (goto-char (point-max))
1406 (forward-line 1)))))))
1408 (defun article-capitalize-sentences ()
1409 "Capitalize the first word in each sentence."
1412 (let ((buffer-read-only nil
)
1413 (paragraph-start "^[\n\^L]"))
1417 (forward-sentence)))))
1419 (defun article-remove-cr ()
1420 "Remove trailing CRs and then translate remaining CRs into LFs."
1423 (let ((buffer-read-only nil
))
1424 (goto-char (point-min))
1425 (while (re-search-forward "\r+$" nil t
)
1426 (replace-match "" t t
))
1427 (goto-char (point-min))
1428 (while (search-forward "\r" nil t
)
1429 (replace-match "\n" t t
)))))
1431 (defun article-remove-trailing-blank-lines ()
1432 "Remove all trailing blank lines from the article."
1435 (let ((buffer-read-only nil
))
1436 (goto-char (point-max))
1440 (while (and (not (bobp))
1441 (looking-at "^[ \t]*$")
1442 (not (gnus-annotation-in-region-p
1443 (point) (gnus-point-at-eol))))
1448 (defun article-display-x-face (&optional force
)
1449 "Look for an X-Face header and display it if present."
1450 (interactive (list 'force
))
1452 ;; Delete the old process, if any.
1453 (when (process-status "article-x-face")
1454 (delete-process "article-x-face"))
1455 (let ((inhibit-point-motion-hooks t
)
1456 (case-fold-search t
)
1459 (article-narrow-to-head)
1460 (goto-char (point-min))
1461 (setq from
(message-fetch-field "from"))
1462 (goto-char (point-min))
1463 (while (and gnus-article-x-face-command
1466 ;; Check whether this face is censored.
1467 (not gnus-article-x-face-too-ugly
)
1468 (and gnus-article-x-face-too-ugly from
1469 (not (string-match gnus-article-x-face-too-ugly
1471 ;; Has to be present.
1472 (re-search-forward "^X-Face: " nil t
))
1473 ;; This used to try to do multiple faces (`while' instead of
1474 ;; `when' above), but (a) sending multiple EOFs to xv doesn't
1475 ;; work (b) it can crash some versions of Emacs (c) are
1476 ;; multiple faces really something to encourage?
1477 (when (stringp gnus-article-x-face-command
)
1479 ;; We now have the area of the buffer where the X-Face is stored.
1482 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t
))))
1483 ;; We display the face.
1484 (if (symbolp gnus-article-x-face-command
)
1485 ;; The command is a lisp function, so we call it.
1486 (if (gnus-functionp gnus-article-x-face-command
)
1487 (funcall gnus-article-x-face-command beg end
)
1488 (error "%s is not a function" gnus-article-x-face-command
))
1489 ;; The command is a string, so we interpret the command
1490 ;; as a, well, command, and fork it off.
1491 (let ((process-connection-type nil
))
1492 (process-kill-without-query
1494 "article-x-face" nil shell-file-name shell-command-switch
1495 gnus-article-x-face-command
))
1496 (process-send-region "article-x-face" beg end
)
1497 (process-send-eof "article-x-face"))))))))))
1499 (defun article-decode-mime-words ()
1500 "Decode all MIME-encoded words in the article."
1503 (set-buffer gnus-article-buffer
)
1504 (let ((inhibit-point-motion-hooks t
)
1506 (mail-parse-charset gnus-newsgroup-charset
)
1507 (mail-parse-ignored-charsets
1508 (save-excursion (set-buffer gnus-summary-buffer
)
1509 gnus-newsgroup-ignored-charsets
)))
1510 (mail-decode-encoded-word-region (point-min) (point-max)))))
1512 (defun article-decode-charset (&optional prompt
)
1513 "Decode charset-encoded text in the article.
1514 If PROMPT (the prefix), prompt for a coding system to use."
1516 (let ((inhibit-point-motion-hooks t
) (case-fold-search t
)
1518 (mail-parse-charset gnus-newsgroup-charset
)
1519 (mail-parse-ignored-charsets
1520 (save-excursion (condition-case nil
1521 (set-buffer gnus-summary-buffer
)
1523 gnus-newsgroup-ignored-charsets
))
1524 ct cte ctl charset format
)
1527 (article-narrow-to-head)
1528 (setq ct
(message-fetch-field "Content-Type" t
)
1529 cte
(message-fetch-field "Content-Transfer-Encoding" t
)
1530 ctl
(and ct
(ignore-errors
1531 (mail-header-parse-content-type ct
)))
1534 (mm-read-coding-system "Charset to decode: "))
1536 (mail-content-type-get ctl
'charset
)))
1537 format
(and ctl
(mail-content-type-get ctl
'format
)))
1539 (setq cte
(mail-header-strip cte
)))
1540 (if (and ctl
(not (string-match "/" (car ctl
))))
1542 (goto-char (point-max)))
1545 (narrow-to-region (point) (point-max))
1546 (when (and (eq mail-parse-charset
'gnus-decoded
)
1547 (eq (mm-body-7-or-8) '8bit
))
1548 ;; The text code could have been decoded.
1549 (setq charset mail-parse-charset
))
1550 (when (and (or (not ctl
)
1551 (equal (car ctl
) "text/plain"))
1552 (not format
)) ;; article with format will decode later.
1554 charset
(and cte
(intern (downcase
1555 (gnus-strip-whitespace cte
))))
1558 (defun article-decode-encoded-words ()
1559 "Remove encoded-word encoding from headers."
1560 (let ((inhibit-point-motion-hooks t
)
1561 (mail-parse-charset gnus-newsgroup-charset
)
1562 (mail-parse-ignored-charsets
1563 (save-excursion (condition-case nil
1564 (set-buffer gnus-summary-buffer
)
1566 gnus-newsgroup-ignored-charsets
))
1569 (article-narrow-to-head)
1570 (funcall gnus-decode-header-function
(point-min) (point-max)))))
1572 (defun article-de-quoted-unreadable (&optional force
)
1573 "Translate a quoted-printable-encoded article.
1574 If FORCE, decode the article whether it is marked as quoted-printable
1576 (interactive (list 'force
))
1578 (let ((buffer-read-only nil
) type charset
)
1579 (if (gnus-buffer-live-p gnus-original-article-buffer
)
1580 (with-current-buffer gnus-original-article-buffer
1582 (gnus-fetch-field "content-transfer-encoding"))
1583 (let* ((ct (gnus-fetch-field "content-type"))
1586 (mail-header-parse-content-type ct
)))))
1587 (setq charset
(and ctl
1588 (mail-content-type-get ctl
'charset
)))
1589 (if (stringp charset
)
1590 (setq charset
(intern (downcase charset
)))))))
1592 (setq charset gnus-newsgroup-charset
))
1594 (and type
(let ((case-fold-search t
))
1595 (string-match "quoted-printable" type
))))
1597 (quoted-printable-decode-region
1598 (point) (point-max) (mm-charset-to-coding-system charset
))))))
1600 (defun article-de-base64-unreadable (&optional force
)
1601 "Translate a base64 article.
1602 If FORCE, decode the article whether it is marked as base64 not."
1603 (interactive (list 'force
))
1605 (let ((buffer-read-only nil
) type charset
)
1606 (if (gnus-buffer-live-p gnus-original-article-buffer
)
1607 (with-current-buffer gnus-original-article-buffer
1609 (gnus-fetch-field "content-transfer-encoding"))
1610 (let* ((ct (gnus-fetch-field "content-type"))
1613 (mail-header-parse-content-type ct
)))))
1614 (setq charset
(and ctl
1615 (mail-content-type-get ctl
'charset
)))
1616 (if (stringp charset
)
1617 (setq charset
(intern (downcase charset
)))))))
1619 (setq charset gnus-newsgroup-charset
))
1621 (and type
(let ((case-fold-search t
))
1622 (string-match "base64" type
))))
1625 (narrow-to-region (point) (point-max))
1626 (base64-decode-region (point-min) (point-max))
1627 (mm-decode-coding-region
1628 (point-min) (point-max) (mm-charset-to-coding-system charset
)))))))
1633 (defun article-decode-HZ ()
1634 "Translate a HZ-encoded article."
1638 (let ((buffer-read-only nil
))
1639 (rfc1843-decode-region (point-min) (point-max)))))
1641 (defun article-wash-html ()
1642 "Format an html article."
1645 (let ((buffer-read-only nil
)
1647 (if (gnus-buffer-live-p gnus-original-article-buffer
)
1648 (with-current-buffer gnus-original-article-buffer
1649 (let* ((ct (gnus-fetch-field "content-type"))
1652 (mail-header-parse-content-type ct
)))))
1653 (setq charset
(and ctl
1654 (mail-content-type-get ctl
'charset
)))
1655 (if (stringp charset
)
1656 (setq charset
(intern (downcase charset
)))))))
1658 (setq charset gnus-newsgroup-charset
))
1660 (save-window-excursion
1662 (narrow-to-region (point) (point-max))
1664 (let ((w3-strict-width (window-width))
1665 (url-standalone-mode t
))
1667 (w3-region (point-min) (point-max))
1670 (defun article-hide-list-identifiers ()
1671 "Remove list identifies from the Subject header.
1672 The `gnus-list-identifiers' variable specifies what to do."
1676 (let ((inhibit-point-motion-hooks t
)
1678 (article-narrow-to-head)
1679 (let ((regexp (if (stringp gnus-list-identifiers
) gnus-list-identifiers
1680 (mapconcat 'identity gnus-list-identifiers
" *\\|"))))
1682 (goto-char (point-min))
1683 (when (re-search-forward
1684 (concat "^Subject: +\\(\\(\\(Re: +\\)?\\(" regexp
1685 " *\\)\\)+\\(Re: +\\)?\\)")
1687 (let ((s (or (match-string 3) (match-string 5))))
1688 (delete-region (match-beginning 1) (match-end 1))
1690 (goto-char (match-beginning 1))
1693 (defun article-hide-pgp ()
1694 "Remove any PGP headers and signatures in the current article."
1698 (let ((inhibit-point-motion-hooks t
)
1699 buffer-read-only beg end
)
1701 ;; Hide the "header".
1702 (when (re-search-forward "^-----BEGIN PGP SIGNED MESSAGE-----\n" nil t
)
1703 (push 'pgp gnus-article-wash-types
)
1704 (delete-region (match-beginning 0) (match-end 0))
1705 ;; Remove armor headers (rfc2440 6.2)
1706 (delete-region (point) (or (re-search-forward "^[ \t]*\n" nil t
)
1709 ;; Hide the actual signature.
1710 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t
)
1711 (setq end
(1+ (match-beginning 0)))
1714 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t
)
1716 ;; Perhaps we shouldn't hide to the end of the buffer
1717 ;; if there is no end to the signature?
1719 ;; Hide "- " PGP quotation markers.
1721 (narrow-to-region beg end
)
1722 (goto-char (point-min))
1723 (while (re-search-forward "^- " nil t
)
1725 (match-beginning 0) (match-end 0)))
1727 (gnus-run-hooks 'gnus-article-hide-pgp-hook
))))))
1729 (defun article-hide-pem (&optional arg
)
1730 "Toggle hiding of any PEM headers and signatures in the current article.
1731 If given a negative prefix, always show; if given a positive prefix,
1733 (interactive (gnus-article-hidden-arg))
1734 (unless (gnus-article-check-hidden-text 'pem arg
)
1736 (let (buffer-read-only end
)
1737 (goto-char (point-min))
1738 ;; Hide the horrendously ugly "header".
1739 (when (and (search-forward
1740 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
1742 (setq end
(1+ (match-beginning 0))))
1743 (push 'pem gnus-article-wash-types
)
1744 (gnus-article-hide-text-type
1746 (if (search-forward "\n\n" nil t
)
1750 ;; Hide the trailer as well
1751 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
1753 (gnus-article-hide-text-type
1754 (match-beginning 0) (match-end 0) 'pem
)))))))
1756 (defun article-strip-banner ()
1757 "Strip the banner specified by the `banner' group parameter."
1761 (let ((inhibit-point-motion-hooks t
)
1762 (banner (gnus-group-find-parameter gnus-newsgroup-name
'banner
))
1763 (gnus-signature-limit nil
)
1764 buffer-read-only beg end
)
1768 ((eq banner
'signature
)
1769 (when (gnus-article-narrow-to-signature)
1772 (delete-region (point) (point-max))))
1774 (if (setq banner
(cdr (assq banner gnus-article-banner-alist
)))
1775 (while (re-search-forward banner nil t
)
1776 (delete-region (match-beginning 0) (match-end 0)))))
1778 (while (re-search-forward banner nil t
)
1779 (delete-region (match-beginning 0) (match-end 0))))))))))
1781 (defun article-babel ()
1782 "Translate article using an online translation service."
1786 (set-buffer gnus-article-buffer
)
1787 (when (article-goto-body)
1788 (let* ((buffer-read-only nil
)
1791 (orig (buffer-substring start end
))
1792 (trans (babel-as-string orig
)))
1794 (narrow-to-region start end
)
1795 (delete-region start end
)
1798 (defun article-hide-signature (&optional arg
)
1799 "Hide the signature in the current article.
1800 If given a negative prefix, always show; if given a positive prefix,
1802 (interactive (gnus-article-hidden-arg))
1803 (unless (gnus-article-check-hidden-text 'signature arg
)
1806 (let ((buffer-read-only nil
))
1807 (when (gnus-article-narrow-to-signature)
1808 (gnus-article-hide-text-type
1809 (point-min) (point-max) 'signature
)))))))
1811 (defun article-strip-headers-in-body ()
1812 "Strip offensive headers from bodies."
1816 (let ((case-fold-search t
))
1817 (when (looking-at "x-no-archive:")
1818 (gnus-delete-line)))))
1820 (defun article-strip-leading-blank-lines ()
1821 "Remove all blank lines from the beginning of the article."
1824 (let ((inhibit-point-motion-hooks t
)
1826 (when (article-goto-body)
1827 (while (and (not (eobp))
1828 (looking-at "[ \t]*$"))
1829 (gnus-delete-line))))))
1831 (defun article-narrow-to-head ()
1832 "Narrow the buffer to the head of the message.
1833 Point is left at the beginning of the narrowed-to region."
1835 (goto-char (point-min))
1836 (if (search-forward "\n\n" nil
1)
1839 (goto-char (point-min)))
1841 (defun article-goto-body ()
1842 "Place point at the start of the body."
1843 (goto-char (point-min))
1845 ;; This variable is only bound when dealing with separate
1847 (article-goto-body-goes-to-point-min-p
1849 ((search-forward "\n\n" nil t
)
1852 (goto-char (point-max))
1855 (defun article-strip-multiple-blank-lines ()
1856 "Replace consecutive blank lines with one empty line."
1859 (let ((inhibit-point-motion-hooks t
)
1861 ;; First make all blank lines empty.
1863 (while (re-search-forward "^[ \t]+$" nil t
)
1864 (unless (gnus-annotation-in-region-p
1865 (match-beginning 0) (match-end 0))
1866 (replace-match "" nil t
)))
1867 ;; Then replace multiple empty lines with a single empty line.
1869 (while (re-search-forward "\n\n\n+" nil t
)
1870 (unless (gnus-annotation-in-region-p
1871 (match-beginning 0) (match-end 0))
1872 (replace-match "\n\n" t t
))))))
1874 (defun article-strip-leading-space ()
1875 "Remove all white space from the beginning of the lines in the article."
1878 (let ((inhibit-point-motion-hooks t
)
1881 (while (re-search-forward "^[ \t]+" nil t
)
1882 (replace-match "" t t
)))))
1884 (defun article-strip-trailing-space ()
1885 "Remove all white space from the end of the lines in the article."
1888 (let ((inhibit-point-motion-hooks t
)
1891 (while (re-search-forward "[ \t]+$" nil t
)
1892 (replace-match "" t t
)))))
1894 (defun article-strip-blank-lines ()
1895 "Strip leading, trailing and multiple blank lines."
1897 (article-strip-leading-blank-lines)
1898 (article-remove-trailing-blank-lines)
1899 (article-strip-multiple-blank-lines))
1901 (defun article-strip-all-blank-lines ()
1902 "Strip all blank lines."
1905 (let ((inhibit-point-motion-hooks t
)
1908 (while (re-search-forward "^[ \t]*\n" nil t
)
1909 (replace-match "" t t
)))))
1911 (defun gnus-article-narrow-to-signature ()
1912 "Narrow to the signature; return t if a signature is found, else nil."
1913 (let ((inhibit-point-motion-hooks t
))
1914 (when (gnus-article-search-signature)
1916 ;; Check whether we have some limits to what we consider
1917 ;; to be a signature.
1918 (let ((limits (if (listp gnus-signature-limit
) gnus-signature-limit
1919 (list gnus-signature-limit
)))
1921 (while (setq limit
(pop limits
))
1922 (if (or (and (integerp limit
)
1923 (< (- (point-max) (point)) limit
))
1925 (< (count-lines (point) (point-max)) limit
))
1926 (and (gnus-functionp limit
)
1928 (and (stringp limit
)
1929 (not (re-search-forward limit nil t
))))
1930 () ; This limit did not succeed.
1934 (narrow-to-region (point) (point-max))
1937 (defun gnus-article-search-signature ()
1938 "Search the current buffer for the signature separator.
1939 Put point at the beginning of the signature separator."
1940 (let ((cur (point)))
1941 (goto-char (point-max))
1942 (if (if (stringp gnus-signature-separator
)
1943 (re-search-backward gnus-signature-separator nil t
)
1944 (let ((seps gnus-signature-separator
))
1946 (not (re-search-backward (car seps
) nil t
)))
1953 (defun gnus-article-hidden-arg ()
1954 "Return the current prefix arg as a number, or 0 if no prefix."
1955 (list (if current-prefix-arg
1956 (prefix-numeric-value current-prefix-arg
)
1959 (defun gnus-article-check-hidden-text (type arg
)
1960 "Return nil if hiding is necessary.
1961 Arg can be nil or a number. Nil and positive means hide, negative
1962 means show, 0 means toggle."
1965 (let ((hide (gnus-article-hidden-text-p type
)))
1971 (gnus-article-show-hidden-text type
))
1973 (if (eq hide
'hidden
)
1974 (gnus-article-show-hidden-text type
)
1977 (defun gnus-article-hidden-text-p (type)
1978 "Say whether the current buffer contains hidden text of type TYPE."
1979 (let ((pos (text-property-any (point-min) (point-max) 'article-type type
)))
1981 (not (get-text-property pos
'invisible
))
1982 (not (get-text-property pos
'dummy-invisible
)))
1984 (text-property-any (1+ pos
) (point-max) 'article-type type
)))
1989 (defun gnus-article-show-hidden-text (type &optional dummy
)
1990 "Show all hidden text of type TYPE.
1991 Originally it is hide instead of DUMMY."
1992 (let ((buffer-read-only nil
)
1993 (inhibit-point-motion-hooks t
))
1994 (gnus-remove-text-properties-when
1996 (point-min) (point-max)
1997 (cons 'article-type
(cons type
1998 gnus-hidden-properties
)))))
2000 (defconst article-time-units
2001 `((year .
,(* 365.25 24 60 60))
2002 (week .
,(* 7 24 60 60))
2003 (day .
,(* 24 60 60))
2007 "Mapping from time units to seconds.")
2009 (defun article-date-ut (&optional type highlight header
)
2010 "Convert DATE date to universal time in the current article.
2011 If TYPE is `local', convert to local time; if it is `lapsed', output
2012 how much time has lapsed since DATE. For `lapsed', the value of
2013 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2014 should replace the \"Date:\" one, or should be added below it."
2015 (interactive (list 'ut t
))
2016 (let* ((header (or header
2017 (message-fetch-field "date")
2019 (tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2022 ((not gnus-article-date-lapsed-new-header
)
2028 (date (if (vectorp header
) (mail-header-date header
)
2030 (inhibit-point-motion-hooks t
)
2035 (article-narrow-to-head)
2036 (when (re-search-forward tdate-regexp nil t
)
2037 (setq bface
(get-text-property (gnus-point-at-bol) 'face
)
2038 date
(or (get-text-property (gnus-point-at-bol)
2041 eface
(get-text-property (1- (gnus-point-at-eol)) 'face
))
2043 (when (and date
(not (string= date
"")))
2044 (goto-char (point-min))
2045 (let ((buffer-read-only nil
))
2046 ;; Delete any old Date headers.
2047 (while (re-search-forward date-regexp nil t
)
2049 (delete-region (progn (beginning-of-line) (point))
2050 (progn (forward-line 1) (point)))
2051 (delete-region (progn (beginning-of-line) (point))
2052 (progn (end-of-line) (point)))
2053 (setq pos
(point))))
2054 (when (and (not pos
) (re-search-forward tdate-regexp nil t
))
2056 (if pos
(goto-char pos
))
2057 (insert (article-make-date-line date
(or type
'ut
)))
2063 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2064 (put-text-property (match-beginning 1) (1+ (match-end 1))
2065 'original-date date
)
2066 (put-text-property (match-beginning 1) (1+ (match-end 1))
2068 (put-text-property (match-beginning 2) (match-end 2)
2071 (defun article-make-date-line (date type
)
2072 "Return a DATE line of TYPE."
2073 (let ((time (condition-case ()
2077 ;; Convert to the local timezone. We have to slap a
2078 ;; `condition-case' round the calls to the timezone
2079 ;; functions since they aren't particularly resistant to
2082 (let ((tz (car (current-time-zone time
))))
2083 (format "Date: %s %s%02d%02d" (current-time-string time
)
2084 (if (> tz
0) "+" "-") (/ (abs tz
) 3600)
2085 (/ (%
(abs tz
) 3600) 60))))
2086 ;; Convert to Universal Time.
2089 (current-time-string
2090 (let* ((e (parse-time-string date
))
2091 (tm (apply 'encode-time e
))
2093 (ls (- (cadr tm
) (car (current-time-zone time
)))))
2094 (cond ((< ls
0) (list (1- ms
) (+ ls
65536)))
2095 ((> ls
65535) (list (1+ ms
) (- ls
65536)))
2098 ;; Get the original date from the article.
2099 ((eq type
'original
)
2100 (concat "Date: " (if (string-match "\n+$" date
)
2101 (substring date
0 (match-beginning 0))
2103 ;; Let the user define the format.
2105 (if (gnus-functionp gnus-article-time-format
)
2106 (funcall gnus-article-time-format time
)
2109 (format-time-string gnus-article-time-format time
))))
2112 (let ((tz (car (current-time-zone time
))))
2115 (format-time-string "%Y%m%dT%H%M%S" time
)
2116 (format "%s%02d%02d"
2117 (if (> tz
0) "+" "-") (/ (abs tz
) 3600)
2118 (/ (%
(abs tz
) 3600) 60)))))
2119 ;; Do an X-Sent lapsed format.
2121 ;; If the date is seriously mangled, the timezone functions are
2122 ;; liable to bug out, so we ignore all errors.
2123 (let* ((now (current-time))
2124 (real-time (subtract-time now time
))
2125 (real-sec (and real-time
2126 (+ (* (float (car real-time
)) 65536)
2128 (sec (and real-time
(abs real-sec
)))
2138 ;; This is a bit convoluted, but basically we go
2139 ;; through the time units for years, weeks, etc,
2140 ;; and divide things to see whether that results
2141 ;; in positive answers.
2144 (if (zerop (setq num
(ffloor (/ sec
(cdr unit
)))))
2145 ;; The (remaining) seconds are too few to
2146 ;; be divided into this time unit.
2148 ;; It's big enough, so we output it.
2149 (setq sec
(- sec
(* num
(cdr unit
))))
2151 (concat (if prev
", " "") (int-to-string
2153 " " (symbol-name (car unit
))
2154 (if (> num
1) "s" ""))
2156 article-time-units
"")
2157 ;; If dates are odd, then it might appear like the
2158 ;; article was sent in the future.
2161 " in the future"))))))
2163 (error "Unknown conversion type: %s" type
)))))
2165 (defun article-date-local (&optional highlight
)
2166 "Convert the current article date to the local timezone."
2167 (interactive (list t
))
2168 (article-date-ut 'local highlight
))
2170 (defun article-date-original (&optional highlight
)
2171 "Convert the current article date to what it was originally.
2172 This is only useful if you have used some other date conversion
2173 function and want to see what the date was before converting."
2174 (interactive (list t
))
2175 (article-date-ut 'original highlight
))
2177 (defun article-date-lapsed (&optional highlight
)
2178 "Convert the current article date to time lapsed since it was sent."
2179 (interactive (list t
))
2180 (article-date-ut 'lapsed highlight
))
2182 (defun article-update-date-lapsed ()
2183 "Function to be run from a timer to update the lapsed time line."
2184 (let (deactivate-mark)
2189 (set-buffer (window-buffer w
))
2190 (when (eq major-mode
'gnus-article-mode
)
2191 (goto-char (point-min))
2192 (when (re-search-forward "^X-Sent:" nil t
)
2193 (article-date-lapsed t
))))
2196 (defun gnus-start-date-timer (&optional n
)
2197 "Start a timer to update the X-Sent header in the article buffers.
2198 The numerical prefix says how frequently (in seconds) the function
2203 (gnus-stop-date-timer)
2204 (setq article-lapsed-timer
2205 (nnheader-run-at-time 1 n
'article-update-date-lapsed
)))
2207 (defun gnus-stop-date-timer ()
2208 "Stop the X-Sent timer."
2210 (when article-lapsed-timer
2211 (nnheader-cancel-timer article-lapsed-timer
)
2212 (setq article-lapsed-timer nil
)))
2214 (defun article-date-user (&optional highlight
)
2215 "Convert the current article date to the user-defined format.
2216 This format is defined by the `gnus-article-time-format' variable."
2217 (interactive (list t
))
2218 (article-date-ut 'user highlight
))
2220 (defun article-date-iso8601 (&optional highlight
)
2221 "Convert the current article date to ISO8601."
2222 (interactive (list t
))
2223 (article-date-ut 'iso8601 highlight
))
2225 (defun article-show-all ()
2226 "Show all hidden text in the article buffer."
2229 (let ((buffer-read-only nil
))
2230 (gnus-article-unhide-text (point-min) (point-max)))))
2232 (defun article-emphasize (&optional arg
)
2233 "Emphasize text according to `gnus-emphasis-alist'."
2234 (interactive (gnus-article-hidden-arg))
2235 (unless (gnus-article-check-hidden-text 'emphasis arg
)
2239 (with-current-buffer gnus-summary-buffer
2240 gnus-article-emphasis-alist
)
2242 gnus-emphasis-alist
))
2243 (buffer-read-only nil
)
2244 (props (append '(article-type emphasis
)
2245 gnus-hidden-properties
))
2246 regexp elem beg invisible visible face
)
2249 (while (setq elem
(pop alist
))
2251 (setq regexp
(car elem
)
2252 invisible
(nth 1 elem
)
2253 visible
(nth 2 elem
)
2255 (while (re-search-forward regexp nil t
)
2256 (when (and (match-beginning visible
) (match-beginning invisible
))
2257 (push 'emphasis gnus-article-wash-types
)
2258 (gnus-article-hide-text
2259 (match-beginning invisible
) (match-end invisible
) props
)
2260 (gnus-article-unhide-text-type
2261 (match-beginning visible
) (match-end visible
) 'emphasis
)
2262 (gnus-put-text-property-excluding-newlines
2263 (match-beginning visible
) (match-end visible
) 'face face
)
2264 (goto-char (match-end invisible
)))))))))
2266 (defun gnus-article-setup-highlight-words (&optional highlight-words
)
2267 "Setup newsgroup emphasis alist."
2268 (unless gnus-article-emphasis-alist
2269 (let ((name (and gnus-newsgroup-name
2270 (gnus-group-real-name gnus-newsgroup-name
))))
2271 (make-local-variable 'gnus-article-emphasis-alist
)
2272 (setq gnus-article-emphasis-alist
2274 (let ((alist gnus-group-highlight-words-alist
) elem highlight
)
2275 (while (setq elem
(pop alist
))
2276 (when (and name
(string-match (car elem
) name
))
2278 highlight
(copy-sequence (cdr elem
)))))
2280 (copy-sequence highlight-words
)
2281 (if gnus-newsgroup-name
2282 (copy-sequence (gnus-group-find-parameter
2283 gnus-newsgroup-name
'highlight-words t
)))
2284 gnus-emphasis-alist
)))))
2286 (defvar gnus-summary-article-menu
)
2287 (defvar gnus-summary-post-menu
)
2289 ;;; Saving functions.
2291 (defun gnus-article-save (save-buffer file
&optional num
)
2292 "Save the currently selected article."
2293 (unless gnus-save-all-headers
2294 ;; Remove headers according to `gnus-saved-headers'.
2295 (let ((gnus-visible-headers
2296 (or gnus-saved-headers gnus-visible-headers
))
2297 (gnus-article-buffer save-buffer
))
2299 (set-buffer save-buffer
)
2300 (article-hide-headers 1 t
))))
2301 (save-window-excursion
2302 (if (not gnus-default-article-saver
)
2303 (error "No default saver is defined")
2304 ;; !!! Magic! The saving functions all save
2305 ;; `gnus-save-article-buffer' (or so they think), but we
2306 ;; bind that variable to our save-buffer.
2307 (set-buffer gnus-article-buffer
)
2308 (let* ((gnus-save-article-buffer save-buffer
)
2311 ((not gnus-prompt-before-saving
) 'default
)
2312 ((eq gnus-prompt-before-saving
'always
) nil
)
2314 (gnus-number-of-articles-to-be-saved
2315 (when (eq gnus-prompt-before-saving t
)
2317 (set-buffer gnus-article-current-summary
)
2318 (funcall gnus-default-article-saver filename
)))))
2320 (defun gnus-read-save-file-name (prompt &optional filename
2321 function group headers variable
)
2323 (funcall function group headers
(symbol-value variable
)))
2328 ((eq filename
'default
)
2334 (let* ((split-name (gnus-get-split-value gnus-split-methods
))
2337 (if (and gnus-number-of-articles-to-be-saved
2338 (> gnus-number-of-articles-to-be-saved
1))
2339 (format "these %d articles"
2340 gnus-number-of-articles-to-be-saved
)
2343 ;; Let the split methods have their say.
2345 ;; No split name was found.
2348 (concat prompt
" (default "
2349 (file-name-nondirectory default-name
) ") ")
2350 (file-name-directory default-name
)
2352 ;; A single group name is returned.
2353 ((stringp split-name
)
2355 (funcall function split-name headers
2356 (symbol-value variable
)))
2358 (concat prompt
" (default "
2359 (file-name-nondirectory default-name
) ") ")
2360 (file-name-directory default-name
)
2362 ;; A single split name was found
2363 ((= 1 (length split-name
))
2364 (let* ((name (expand-file-name
2365 (car split-name
) gnus-article-save-directory
))
2366 (dir (cond ((file-directory-p name
)
2367 (file-name-as-directory name
))
2368 ((file-exists-p name
) name
)
2369 (t gnus-article-save-directory
))))
2371 (concat prompt
" (default " name
") ")
2373 ;; A list of splits was found.
2375 (setq split-name
(nreverse split-name
))
2377 (let ((file-name-history
2378 (nconc split-name file-name-history
)))
2382 (concat prompt
" (`M-p' for defaults) ")
2383 gnus-article-save-directory
2385 gnus-article-save-directory
)))
2386 (car (push result file-name-history
)))))))
2387 ;; Create the directory.
2388 (gnus-make-directory (file-name-directory file
))
2389 ;; If we have read a directory, we append the default file name.
2390 (when (file-directory-p file
)
2391 (setq file
(expand-file-name (file-name-nondirectory default-name
)
2392 (file-name-as-directory file
))))
2393 ;; Possibly translate some characters.
2394 (nnheader-translate-file-chars file
))))))
2395 (gnus-make-directory (file-name-directory result
))
2396 (set variable result
)))
2398 (defun gnus-article-archive-name (group)
2399 "Return the first instance of an \"Archive-name\" in the current buffer."
2400 (let ((case-fold-search t
))
2401 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t
)
2402 (nnheader-concat gnus-article-save-directory
2403 (match-string 1)))))
2405 (defun gnus-article-nndoc-name (group)
2406 "If GROUP is an nndoc group, return the name of the parent group."
2407 (when (eq (car (gnus-find-method-for-group group
)) 'nndoc
)
2408 (gnus-group-get-parameter group
'save-article-group
)))
2410 (defun gnus-summary-save-in-rmail (&optional filename
)
2411 "Append this article to Rmail file.
2412 Optional argument FILENAME specifies file name.
2413 Directory to save to is default to `gnus-article-save-directory'."
2414 (setq filename
(gnus-read-save-file-name
2415 "Save %s in rmail file:" filename
2416 gnus-rmail-save-name gnus-newsgroup-name
2417 gnus-current-headers
'gnus-newsgroup-last-rmail
))
2418 (gnus-eval-in-buffer-window gnus-save-article-buffer
2422 (gnus-output-to-rmail filename
))))
2425 (defun gnus-summary-save-in-mail (&optional filename
)
2426 "Append this article to Unix mail file.
2427 Optional argument FILENAME specifies file name.
2428 Directory to save to is default to `gnus-article-save-directory'."
2429 (setq filename
(gnus-read-save-file-name
2430 "Save %s in Unix mail file:" filename
2431 gnus-mail-save-name gnus-newsgroup-name
2432 gnus-current-headers
'gnus-newsgroup-last-mail
))
2433 (gnus-eval-in-buffer-window gnus-save-article-buffer
2437 (if (and (file-readable-p filename
)
2438 (mail-file-babyl-p filename
))
2439 (rmail-output-to-rmail-file filename t
)
2440 (gnus-output-to-mail filename
)))))
2443 (defun gnus-summary-save-in-file (&optional filename overwrite
)
2444 "Append this article to file.
2445 Optional argument FILENAME specifies file name.
2446 Directory to save to is default to `gnus-article-save-directory'."
2447 (setq filename
(gnus-read-save-file-name
2448 "Save %s in file:" filename
2449 gnus-file-save-name gnus-newsgroup-name
2450 gnus-current-headers
'gnus-newsgroup-last-file
))
2451 (gnus-eval-in-buffer-window gnus-save-article-buffer
2455 (when (and overwrite
2456 (file-exists-p filename
))
2457 (delete-file filename
))
2458 (gnus-output-to-file filename
))))
2461 (defun gnus-summary-write-to-file (&optional filename
)
2462 "Write this article to a file.
2463 Optional argument FILENAME specifies file name.
2464 The directory to save in defaults to `gnus-article-save-directory'."
2465 (gnus-summary-save-in-file nil t
))
2467 (defun gnus-summary-save-body-in-file (&optional filename
)
2468 "Append this article body to a file.
2469 Optional argument FILENAME specifies file name.
2470 The directory to save in defaults to `gnus-article-save-directory'."
2471 (setq filename
(gnus-read-save-file-name
2472 "Save %s body in file:" filename
2473 gnus-file-save-name gnus-newsgroup-name
2474 gnus-current-headers
'gnus-newsgroup-last-file
))
2475 (gnus-eval-in-buffer-window gnus-save-article-buffer
2479 (when (article-goto-body)
2480 (narrow-to-region (point) (point-max)))
2481 (gnus-output-to-file filename
))))
2484 (defun gnus-summary-save-in-pipe (&optional command
)
2485 "Pipe this article to subprocess."
2487 (cond ((and (eq command
'default
)
2488 gnus-last-shell-command
)
2489 gnus-last-shell-command
)
2493 "Shell command on %s: "
2494 (if (and gnus-number-of-articles-to-be-saved
2495 (> gnus-number-of-articles-to-be-saved
1))
2496 (format "these %d articles"
2497 gnus-number-of-articles-to-be-saved
)
2499 gnus-last-shell-command
))))
2500 (when (string-equal command
"")
2501 (setq command gnus-last-shell-command
))
2502 (gnus-eval-in-buffer-window gnus-article-buffer
2505 (shell-command-on-region (point-min) (point-max) command nil
)))
2506 (setq gnus-last-shell-command command
))
2508 ;;; Article file names when saving.
2510 (defun gnus-capitalize-newsgroup (newsgroup)
2511 "Capitalize NEWSGROUP name."
2512 (when (not (zerop (length newsgroup
)))
2513 (concat (char-to-string (upcase (aref newsgroup
0)))
2514 (substring newsgroup
1))))
2516 (defun gnus-Numeric-save-name (newsgroup headers
&optional last-file
)
2517 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2518 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
2519 Otherwise, it is like ~/News/news/group/num."
2522 (concat (if (gnus-use-long-file-name 'not-save
)
2523 (gnus-capitalize-newsgroup newsgroup
)
2524 (gnus-newsgroup-directory-form newsgroup
))
2525 "/" (int-to-string (mail-header-number headers
)))
2526 gnus-article-save-directory
)))
2528 (string-equal (file-name-directory default
)
2529 (file-name-directory last-file
))
2530 (string-match "^[0-9]+$" (file-name-nondirectory last-file
)))
2532 (or last-file default
))))
2534 (defun gnus-numeric-save-name (newsgroup headers
&optional last-file
)
2535 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2536 If variable `gnus-use-long-file-name' is non-nil, it is
2537 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2540 (concat (if (gnus-use-long-file-name 'not-save
)
2542 (gnus-newsgroup-directory-form newsgroup
))
2543 "/" (int-to-string (mail-header-number headers
)))
2544 gnus-article-save-directory
)))
2546 (string-equal (file-name-directory default
)
2547 (file-name-directory last-file
))
2548 (string-match "^[0-9]+$" (file-name-nondirectory last-file
)))
2550 (or last-file default
))))
2552 (defun gnus-plain-save-name (newsgroup headers
&optional last-file
)
2553 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2554 If variable `gnus-use-long-file-name' is non-nil, it is
2555 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2558 (if (gnus-use-long-file-name 'not-save
)
2560 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup
)))
2561 gnus-article-save-directory
)))
2568 (setq afunc
(car func
)
2571 gfunc
(intern (format "gnus-%s" func
))))
2574 `(lambda (&optional interactive
&rest args
)
2575 ,(documentation afunc t
)
2576 (interactive (list t
))
2578 (set-buffer gnus-article-buffer
)
2580 (call-interactively ',afunc
)
2581 (apply ',afunc args
))))))))
2582 '(article-hide-headers
2583 article-hide-boring-headers
2584 article-treat-overstrike
2585 article-fill-long-lines
2586 article-capitalize-sentences
2588 article-display-x-face
2589 article-de-quoted-unreadable
2590 article-de-base64-unreadable
2593 article-hide-list-identifiers
2595 article-strip-banner
2598 article-hide-signature
2599 article-strip-headers-in-body
2600 article-remove-trailing-blank-lines
2601 article-strip-leading-blank-lines
2602 article-strip-multiple-blank-lines
2603 article-strip-leading-space
2604 article-strip-trailing-space
2605 article-strip-blank-lines
2606 article-strip-all-blank-lines
2608 article-date-iso8601
2609 article-date-original
2611 article-decode-mime-words
2612 article-decode-charset
2613 article-decode-encoded-words
2617 article-treat-dumbquotes
2618 article-normalize-headers
2619 (article-show-all . gnus-article-show-all-headers
))))
2622 ;;; Gnus article mode
2625 (put 'gnus-article-mode
'mode-class
'special
)
2627 (set-keymap-parent gnus-article-mode-map widget-keymap
)
2629 (gnus-define-keys gnus-article-mode-map
2630 " " gnus-article-goto-next-page
2631 "\177" gnus-article-goto-prev-page
2632 [delete] gnus-article-goto-prev-page
2633 [backspace] gnus-article-goto-prev-page
2634 "\C-c^" gnus-article-refer-article
2635 "h" gnus-article-show-summary
2636 "s" gnus-article-show-summary
2637 "\C-c\C-m" gnus-article-mail
2638 "?" gnus-article-describe-briefly
2639 "e" gnus-summary-edit-article
2640 "<" beginning-of-buffer
2642 "\C-c\C-i" gnus-info-find-node
2644 "\C-hk" gnus-article-describe-key
2645 "\C-hc" gnus-article-describe-key-briefly
2647 "\C-d" gnus-article-read-summary-keys
2648 "\M-*" gnus-article-read-summary-keys
2649 "\M-#" gnus-article-read-summary-keys
2650 "\M-^" gnus-article-read-summary-keys
2651 "\M-g" gnus-article-read-summary-keys)
2653 (substitute-key-definition
2654 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
2656 (defun gnus-article-make-menu-bar ()
2657 (gnus-turn-off-edit-menu 'article)
2658 (unless (boundp 'gnus-article-article-menu)
2660 gnus-article-article-menu gnus-article-mode-map ""
2662 ["Scroll forwards" gnus-article-goto-next-page t]
2663 ["Scroll backwards" gnus-article-goto-prev-page t]
2664 ["Show summary" gnus-article-show-summary t]
2665 ["Fetch Message-ID at point" gnus-article-refer-article t]
2666 ["Mail to address at point" gnus-article-mail t]
2667 ["Send a bug report" gnus-bug t]))
2670 gnus-article-treatment-menu gnus-article-mode-map ""
2671 ;; Fixme: this should use :active (and maybe :visible).
2673 ["Hide headers" gnus-article-hide-headers t]
2674 ["Hide signature" gnus-article-hide-signature t]
2675 ["Hide citation" gnus-article-hide-citation t]
2676 ["Treat overstrike" gnus-article-treat-overstrike t]
2677 ["Remove carriage return" gnus-article-remove-cr t]
2678 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
2679 ["Remove base64" gnus-article-de-base64-unreadable t]
2680 ["Treat html" gnus-article-wash-html t]
2681 ["Decode HZ" gnus-article-decode-HZ t]))
2683 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
2685 (when (boundp 'gnus-summary-post-menu)
2686 (define-key gnus-article-mode-map [menu-bar post]
2687 (cons "Post" gnus-summary-post-menu)))
2689 (gnus-run-hooks 'gnus-article-menu-hook)))
2691 ;; Fixme: do something for the Emacs tool bar in Article mode a la
2694 (defun gnus-article-mode ()
2695 "Major mode for displaying an article.
2697 All normal editing commands are switched off.
2699 The following commands are available in addition to all summary mode
2701 \\<gnus-article-mode-map>
2702 \\[gnus-article-next-page]\t Scroll the article one page forwards
2703 \\[gnus-article-prev-page]\t Scroll the article one page backwards
2704 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
2705 \\[gnus-article-show-summary]\t Display the summary buffer
2706 \\[gnus-article-mail]\t Send a reply to the address near point
2707 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
2708 \\[gnus-info-find-node]\t Go to the Gnus info node"
2710 (when (gnus-visual-p 'article-menu 'menu)
2711 (gnus-article-make-menu-bar))
2712 (gnus-simplify-mode-line)
2713 (setq mode-name "Article")
2714 (setq major-mode 'gnus-article-mode)
2715 (make-local-variable 'minor-mode-alist)
2716 (use-local-map gnus-article-mode-map)
2717 (gnus-update-format-specifications nil 'article-mode)
2718 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
2719 (make-local-variable 'gnus-page-broken)
2720 (make-local-variable 'gnus-button-marker-list)
2721 (make-local-variable 'gnus-article-current-summary)
2722 (make-local-variable 'gnus-article-mime-handles)
2723 (make-local-variable 'gnus-article-decoded-p)
2724 (make-local-variable 'gnus-article-mime-handle-alist)
2725 (make-local-variable 'gnus-article-wash-types)
2726 (gnus-set-default-directory)
2727 (buffer-disable-undo)
2728 (setq buffer-read-only t)
2729 (set-syntax-table gnus-article-mode-syntax-table)
2730 (mm-enable-multibyte)
2731 (gnus-run-hooks 'gnus-article-mode-hook))
2733 (defun gnus-article-setup-buffer ()
2734 "Initialize the article buffer."
2735 (let* ((name (if gnus-single-article-buffer "*Article*"
2736 (concat "*Article " gnus-newsgroup-name "*")))
2738 (progn (string-match "\\*Article" name)
2739 (concat " *Original Article"
2740 (substring name (match-end 0))))))
2741 (setq gnus-article-buffer name)
2742 (setq gnus-original-article-buffer original)
2743 (setq gnus-article-mime-handle-alist nil)
2744 ;; This might be a variable local to the summary buffer.
2745 (unless gnus-single-article-buffer
2747 (set-buffer gnus-summary-buffer)
2748 (setq gnus-article-buffer name)
2749 (setq gnus-original-article-buffer original)
2750 (gnus-set-global-variables)))
2751 (gnus-article-setup-highlight-words)
2752 ;; Init original article buffer.
2754 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
2755 (mm-enable-multibyte)
2756 (setq major-mode 'gnus-original-article-mode)
2757 (make-local-variable 'gnus-original-article))
2758 (if (get-buffer name)
2761 (when gnus-article-mime-handles
2762 (mm-destroy-parts gnus-article-mime-handles)
2763 (setq gnus-article-mime-handles nil))
2764 ;; Set it to nil in article-buffer!
2765 (setq gnus-article-mime-handle-alist nil)
2766 (buffer-disable-undo)
2767 (setq buffer-read-only t)
2768 (unless (eq major-mode 'gnus-article-mode)
2769 (gnus-article-mode))
2772 (set-buffer (gnus-get-buffer-create name))
2774 (make-local-variable 'gnus-summary-buffer)
2775 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2776 (current-buffer)))))
2778 ;; Set article window start at LINE, where LINE is the number of lines
2779 ;; from the head of the article.
2780 (defun gnus-article-set-window-start (&optional line)
2782 (get-buffer-window gnus-article-buffer t)
2784 (set-buffer gnus-article-buffer)
2785 (goto-char (point-min))
2788 (gnus-message 6 "Moved to bookmark")
2789 (search-forward "\n\n" nil t)
2793 (defun gnus-article-prepare (article &optional all-headers header)
2794 "Prepare ARTICLE in article mode buffer.
2795 ARTICLE should either be an article number or a Message-ID.
2796 If ARTICLE is an id, HEADER should be the article headers.
2797 If ALL-HEADERS is non-nil, no headers are hidden."
2799 ;; Make sure we start in a summary buffer.
2800 (unless (eq major-mode 'gnus-summary-mode)
2801 (set-buffer gnus-summary-buffer))
2802 (setq gnus-summary-buffer (current-buffer))
2803 (let* ((gnus-article (if header (mail-header-number header) article))
2804 (summary-buffer (current-buffer))
2805 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
2806 (group gnus-newsgroup-name)
2809 (gnus-article-setup-buffer)
2810 (set-buffer gnus-article-buffer)
2811 ;; Deactivate active regions.
2812 (when (and (boundp 'transient-mark-mode)
2813 transient-mark-mode)
2814 (setq mark-active nil))
2815 (if (not (setq result (let ((buffer-read-only nil))
2816 (gnus-request-article-this-buffer
2818 ;; There is no such article.
2820 (when (and (numberp article)
2821 (not (memq article gnus-newsgroup-sparse)))
2822 (setq gnus-article-current
2823 (cons gnus-newsgroup-name article))
2824 (set-buffer gnus-summary-buffer)
2825 (setq gnus-current-article article)
2826 (if (eq (gnus-article-mark article) gnus-undownloaded-mark)
2828 (gnus-summary-set-agent-mark article)
2829 (message "Message marked for downloading"))
2830 (gnus-summary-mark-article article gnus-canceled-mark)
2831 (unless (memq article gnus-newsgroup-sparse)
2832 (gnus-error 1 "No such article (may have expired or been canceled)")))))
2833 (if (or (eq result 'pseudo)
2834 (eq result 'nneething))
2837 (set-buffer summary-buffer)
2838 (push article gnus-newsgroup-history)
2839 (setq gnus-last-article gnus-current-article
2840 gnus-current-article 0
2841 gnus-current-headers nil
2842 gnus-article-current nil)
2843 (if (eq result 'nneething)
2844 (gnus-configure-windows 'summary)
2845 (gnus-configure-windows 'article))
2846 (gnus-set-global-variables))
2847 (let ((gnus-article-mime-handle-alist-1
2848 gnus-article-mime-handle-alist))
2849 (gnus-set-mode-line 'article)))
2850 ;; The result from the `request' was an actual article -
2851 ;; or at least some text that is now displayed in the
2853 (when (and (numberp article)
2854 (not (eq article gnus-current-article)))
2855 ;; Seems like a new article has been selected.
2856 ;; `gnus-current-article' must be an article number.
2858 (set-buffer summary-buffer)
2859 (push article gnus-newsgroup-history)
2860 (setq gnus-last-article gnus-current-article
2861 gnus-current-article article
2862 gnus-current-headers
2863 (gnus-summary-article-header gnus-current-article)
2864 gnus-article-current
2865 (cons gnus-newsgroup-name gnus-current-article))
2866 (unless (vectorp gnus-current-headers)
2867 (setq gnus-current-headers nil))
2868 (gnus-summary-goto-subject gnus-current-article)
2869 (when (gnus-summary-show-thread)
2870 ;; If the summary buffer really was folded, the
2871 ;; previous goto may not actually have gone to
2872 ;; the right article, but the thread root instead.
2874 (gnus-summary-goto-subject gnus-current-article))
2875 (gnus-run-hooks 'gnus-mark-article-hook)
2876 (gnus-set-mode-line 'summary)
2877 (when (gnus-visual-p 'article-highlight 'highlight)
2878 (gnus-run-hooks 'gnus-visual-mark-article-hook))
2879 ;; Set the global newsgroup variables here.
2880 (gnus-set-global-variables)
2881 (setq gnus-have-all-headers
2882 (or all-headers gnus-show-all-headers))))
2884 (gnus-configure-windows 'article))
2885 (when (or (numberp article)
2887 (gnus-article-prepare-display)
2889 (goto-char (point-min))
2890 (setq gnus-page-broken
2891 (when gnus-break-pages
2892 (gnus-narrow-to-page)
2894 (let ((gnus-article-mime-handle-alist-1
2895 gnus-article-mime-handle-alist))
2896 (gnus-set-mode-line 'article))
2898 (set-window-point (get-buffer-window (current-buffer)) (point))
2899 (gnus-configure-windows 'article)
2903 (defun gnus-article-prepare-display ()
2904 "Make the current buffer look like a nice article."
2905 ;; Hooks for getting information from the article.
2906 ;; This hook must be called before being narrowed.
2907 (let ((gnus-article-buffer (current-buffer))
2909 (unless (eq major-mode 'gnus-article-mode)
2910 (gnus-article-mode))
2911 (setq buffer-read-only nil
2912 gnus-article-wash-types nil)
2913 (gnus-run-hooks 'gnus-tmp-internal-hook)
2914 (when gnus-display-mime-function
2915 (funcall gnus-display-mime-function))
2916 (gnus-run-hooks 'gnus-article-prepare-hook)))
2919 ;;; Gnus MIME viewing functions
2922 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
2923 "The following specs can be used:
2925 %T MIME type, along with additional info
2926 %n The `name' parameter
2927 %d The description, if any
2928 %l The length of the encoded part
2929 %p The part identifier number
2930 %e Dots if the part isn't displayed")
2932 (defvar gnus-mime-button-line-format-alist
2933 '((?t gnus-tmp-type ?s)
2934 (?T gnus-tmp-type-long ?s)
2935 (?n gnus-tmp-name ?s)
2936 (?d gnus-tmp-description ?s)
2938 (?l gnus-tmp-length ?d)
2939 (?e gnus-tmp-dots ?s)))
2941 (defvar gnus-mime-button-commands
2942 '((gnus-article-press-button "\r" "Toggle Display")
2943 (gnus-mime-view-part "v" "View Interactively...")
2944 (gnus-mime-view-part-as-type "t" "View As Type...")
2945 (gnus-mime-save-part "o" "Save...")
2946 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
2947 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
2948 (gnus-mime-internalize-part "E" "View Internally")
2949 (gnus-mime-externalize-part "e" "View Externally")
2950 (gnus-mime-pipe-part "|" "Pipe To Command...")
2951 (gnus-mime-action-on-part "." "Take action on the part")))
2953 (defun gnus-article-mime-part-status ()
2954 (if gnus-article-mime-handle-alist-1
2955 (format " (%d parts)" (length gnus-article-mime-handle-alist-1))
2958 (defvar gnus-mime-button-map
2959 (let ((map (make-sparse-keymap)))
2960 ;; Not for Emacs 21: fixme better.
2961 ;; (set-keymap-parent map gnus-article-mode-map)
2962 (define-key map gnus-mouse-2 'gnus-article-push-button)
2963 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
2964 (dolist (c gnus-mime-button-commands)
2965 (define-key map (cadr c) (car c)))
2968 (defun gnus-mime-button-menu (event)
2969 "Construct a context-sensitive menu of MIME commands."
2972 (mouse-set-point event)
2973 (gnus-article-check-buffer)
2974 (let ((response (x-popup-menu
2976 ("" ,@(mapcar (lambda (c)
2977 (cons (caddr c) (car c)))
2978 gnus-mime-button-commands))))))
2980 (call-interactively response)))))
2982 (defun gnus-mime-view-all-parts (&optional handles)
2983 "View all the MIME parts."
2985 (save-current-buffer
2986 (set-buffer gnus-article-buffer)
2987 (let ((handles (or handles gnus-article-mime-handles))
2988 (mail-parse-charset gnus-newsgroup-charset)
2989 (mail-parse-ignored-charsets
2990 (save-excursion (set-buffer gnus-summary-buffer)
2991 gnus-newsgroup-ignored-charsets)))
2992 (if (stringp (car handles))
2993 (gnus-mime-view-all-parts (cdr handles))
2994 (mapcar 'mm-display-part handles)))))
2996 (defun gnus-mime-save-part ()
2997 "Save the MIME part under point."
2999 (gnus-article-check-buffer)
3000 (let ((data (get-text-property (point) 'gnus-data)))
3001 (mm-save-part data)))
3003 (defun gnus-mime-pipe-part ()
3004 "Pipe the MIME part under point to a process."
3006 (gnus-article-check-buffer)
3007 (let ((data (get-text-property (point) 'gnus-data)))
3008 (mm-pipe-part data)))
3010 (defun gnus-mime-view-part ()
3011 "Interactively choose a viewing method for the MIME part under point."
3013 (gnus-article-check-buffer)
3014 (let ((data (get-text-property (point) 'gnus-data)))
3015 (mm-interactively-view-part data)))
3017 (defun gnus-mime-view-part-as-type-internal ()
3018 (gnus-article-check-buffer)
3019 (let* ((name (mail-content-type-get
3020 (mm-handle-type (get-text-property (point) 'gnus-data))
3022 (def-type (and name (mm-default-file-encoding name))))
3023 (and def-type (cons def-type 0))))
3025 (defun gnus-mime-view-part-as-type (mime-type)
3026 "Choose a MIME media type, and view the part as such."
3028 (list (completing-read
3029 "View as MIME type: "
3030 (mapcar #'list (mailcap-mime-types))
3032 (gnus-mime-view-part-as-type-internal))))
3033 (gnus-article-check-buffer)
3034 (let ((handle (get-text-property (point) 'gnus-data)))
3035 (gnus-mm-display-part
3036 (mm-make-handle (mm-handle-buffer handle)
3037 (cons mime-type (cdr (mm-handle-type handle)))
3038 (mm-handle-encoding handle)
3039 (mm-handle-undisplayer handle)
3040 (mm-handle-disposition handle)
3041 (mm-handle-description handle)
3042 (mm-handle-cache handle)
3043 (mm-handle-id handle)))))
3045 (defun gnus-mime-copy-part (&optional handle)
3046 "Put the the MIME part under point into a new buffer."
3048 (gnus-article-check-buffer)
3049 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3050 (contents (mm-get-part handle))|
3051 (base (file-name-nondirectory
3053 (mail-content-type-get (mm-handle-type handle) 'name)
3054 (mail-content-type-get (mm-handle-type handle)
3057 (buffer (generate-new-buffer base)))
3058 (switch-to-buffer buffer)
3060 ;; We do it this way to make `normal-mode' set the appropriate mode.
3063 (setq buffer-file-name (expand-file-name base))
3065 (setq buffer-file-name nil))
3066 (goto-char (point-min))))
3068 (defun gnus-mime-inline-part (&optional handle arg)
3069 "Insert the MIME part under point into the current buffer."
3070 (interactive (list nil current-prefix-arg))
3071 (gnus-article-check-buffer)
3072 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3076 (if (mm-handle-undisplayer handle)
3077 (mm-remove-part handle)
3078 (setq contents (mm-get-part handle))
3081 (setq charset (or (mail-content-type-get
3082 (mm-handle-type handle) 'charset)
3083 gnus-newsgroup-charset)))
3087 gnus-summary-show-article-charset-alist))
3088 (read-coding-system "Charset: ")))))
3090 (mm-insert-inline handle
3092 (setq charset (mm-charset-to-coding-system
3094 (not (eq charset 'ascii)))
3095 (mm-decode-coding-string contents charset)
3099 (defun gnus-mime-externalize-part (&optional handle)
3100 "View the MIME part under point with an external viewer."
3102 (gnus-article-check-buffer)
3103 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3104 (mm-user-display-methods nil)
3105 (mm-inlined-types nil)
3106 (mail-parse-charset gnus-newsgroup-charset)
3107 (mail-parse-ignored-charsets
3108 (save-excursion (set-buffer gnus-summary-buffer)
3109 gnus-newsgroup-ignored-charsets)))
3110 (if (mm-handle-undisplayer handle)
3111 (mm-remove-part handle)
3112 (mm-display-part handle))))
3114 (defun gnus-mime-internalize-part (&optional handle)
3115 "View the MIME part under point with an internal viewer.
3116 In no internal viewer is available, use an external viewer."
3118 (gnus-article-check-buffer)
3119 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3120 (mm-inlined-types '(".*"))
3121 (mm-inline-large-images t)
3122 (mail-parse-charset gnus-newsgroup-charset)
3123 (mail-parse-ignored-charsets
3124 (save-excursion (set-buffer gnus-summary-buffer)
3125 gnus-newsgroup-ignored-charsets)))
3126 (if (mm-handle-undisplayer handle)
3127 (mm-remove-part handle)
3128 (mm-display-part handle))))
3130 (defun gnus-mime-action-on-part (&optional action)
3131 "Do something with the MIME attachment at \(point\)."
3133 (list (completing-read "Action: " gnus-mime-action-alist)))
3134 (gnus-article-check-buffer)
3135 (let ((action-pair (assoc action gnus-mime-action-alist)))
3137 (funcall (cdr action-pair)))))
3140 (defun gnus-article-part-wrapper (n function)
3141 (save-current-buffer
3142 (set-buffer gnus-article-buffer)
3143 (when (> n (length gnus-article-mime-handle-alist))
3144 (error "No such part"))
3145 (gnus-article-goto-part n)
3146 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
3147 (funcall function handle))))
3149 (defun gnus-article-pipe-part (n)
3150 "Pipe MIME part N, which is the numerical prefix."
3152 (gnus-article-part-wrapper n 'mm-pipe-part))
3154 (defun gnus-article-save-part (n)
3155 "Save MIME part N, which is the numerical prefix."
3157 (gnus-article-part-wrapper n 'mm-save-part))
3159 (defun gnus-article-interactively-view-part (n)
3160 "View MIME part N interactively, which is the numerical prefix."
3162 (gnus-article-part-wrapper n 'mm-interactively-view-part))
3164 (defun gnus-article-copy-part (n)
3165 "Copy MIME part N, which is the numerical prefix."
3167 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
3169 (defun gnus-article-externalize-part (n)
3170 "View MIME part N externally, which is the numerical prefix."
3172 (gnus-article-part-wrapper n 'gnus-mime-externalize-part))
3174 (defun gnus-article-inline-part (n)
3175 "Inline MIME part N, which is the numerical prefix."
3177 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
3179 (defun gnus-article-mime-match-handle-first (condition)
3181 (let ((alist gnus-article-mime-handle-alist) ihandle n)
3182 (while (setq ihandle (pop alist))
3184 ((functionp condition)
3185 (funcall condition (cdr ihandle)))
3186 ((eq condition 'undisplayed)
3187 (not (or (mm-handle-undisplayer (cdr ihandle))
3188 (equal (mm-handle-media-type (cdr ihandle))
3189 "multipart/alternative"))))
3190 ((eq condition 'undisplayed-alternative)
3191 (not (mm-handle-undisplayer (cdr ihandle))))
3193 (gnus-article-goto-part (car ihandle))
3194 (or (not n) (< (car ihandle) n)))
3195 (setq n (car ihandle))))
3199 (defun gnus-article-view-part (&optional n)
3200 "View MIME part N, which is the numerical prefix."
3202 (save-current-buffer
3203 (set-buffer gnus-article-buffer)
3204 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
3205 gnus-article-mime-match-handle-function)))
3206 (when (> n (length gnus-article-mime-handle-alist))
3207 (error "No such part"))
3208 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
3209 (when (gnus-article-goto-part n)
3210 (if (equal (car handle) "multipart/alternative")
3211 (gnus-article-press-button)
3212 (when (eq (gnus-mm-display-part handle) 'internal)
3213 (gnus-set-window-start)))))))
3215 (defsubst gnus-article-mime-total-parts ()
3216 (if (bufferp (car gnus-article-mime-handles))
3218 (1- (length gnus-article-mime-handles))))
3220 (defun gnus-mm-display-part (handle)
3221 "Display HANDLE and fix MIME button."
3222 (let ((id (get-text-property (point) 'gnus-part))
3227 (let ((window (selected-window))
3228 (mail-parse-charset gnus-newsgroup-charset)
3229 (mail-parse-ignored-charsets
3230 (save-excursion (set-buffer gnus-summary-buffer)
3231 gnus-newsgroup-ignored-charsets)))
3234 (let ((win (get-buffer-window (current-buffer) t))
3237 (select-window win))
3240 (if (mm-handle-displayed-p handle)
3241 ;; This will remove the part.
3242 (mm-display-part handle)
3244 (narrow-to-region (point) (1+ (point)))
3245 (mm-display-part handle)
3246 ;; We narrow to the part itself and
3247 ;; then call the treatment functions.
3248 (goto-char (point-min))
3250 (narrow-to-region (point) (point-max))
3253 (gnus-article-mime-total-parts)
3254 (mm-handle-media-type handle)))))
3255 (select-window window))))
3257 (delete-region (gnus-point-at-bol) (progn (forward-line 1) (point)))
3258 (gnus-insert-mime-button
3259 handle id (list (mm-handle-displayed-p handle)))
3260 (goto-char point))))
3262 (defun gnus-article-goto-part (n)
3263 "Go to MIME part N."
3264 (let ((point (text-property-any (point-min) (point-max) 'gnus-part n)))
3266 (goto-char point))))
3268 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
3269 (let ((gnus-tmp-name
3270 (or (mail-content-type-get (mm-handle-type handle)
3272 (mail-content-type-get (mm-handle-disposition handle)
3275 (gnus-tmp-type (mm-handle-media-type handle))
3276 (gnus-tmp-description
3277 (mail-decode-encoded-word-string (or (mm-handle-description handle)
3280 (if (if displayed (car displayed)
3281 (mm-handle-displayed-p handle))
3283 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
3285 gnus-tmp-type-long b e)
3286 (when (string-match ".*/" gnus-tmp-name)
3287 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
3288 (setq gnus-tmp-type-long (concat gnus-tmp-type
3289 (and (not (equal gnus-tmp-name ""))
3290 (concat "; " gnus-tmp-name))))
3291 (or (equal gnus-tmp-description "")
3292 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
3297 gnus-mime-button-line-format gnus-mime-button-line-format-alist
3298 `(keymap ,gnus-mime-button-map
3299 ;; Not for Emacs 21: fixme better.
3300 ;; local-map ,gnus-mime-button-map
3301 gnus-callback gnus-mm-display-part
3302 gnus-part ,gnus-tmp-id
3303 article-type annotation
3306 (widget-convert-button
3309 :action 'gnus-widget-press-button
3310 :button-keymap gnus-mime-button-map
3312 (lambda (widget/window &optional overlay pos)
3313 ;; Needed to properly clear the message due to a bug in
3314 ;; wid-edit (XEmacs only).
3315 (if (boundp 'help-echo-owns-message)
3316 (setq help-echo-owns-message t))
3318 "%S: %s the MIME part; %S: more options"
3319 (aref gnus-mouse-2 0)
3320 ;; XEmacs will get a single widget arg; Emacs 21 will get
3321 ;; window, overlay, position.
3322 (if (mm-handle-displayed-p
3324 (with-current-buffer (gnus-overlay-buffer overlay)
3325 (widget-get (widget-at (gnus-overlay-start overlay))
3327 (widget-get widget/window :mime-handle)))
3329 (aref gnus-down-mouse-3 0))))))
3331 (defun gnus-widget-press-button (elems el)
3332 (goto-char (widget-get elems :from))
3333 (gnus-article-press-button))
3335 (defvar gnus-displaying-mime nil)
3337 (defun gnus-display-mime (&optional ihandles)
3338 "Display the MIME parts."
3340 (save-selected-window
3341 (let ((window (get-buffer-window gnus-article-buffer))
3344 (select-window window)
3345 ;; We have to do this since selecting the window
3346 ;; may change the point. So we set the window point.
3347 (set-window-point window point)))
3348 (let* ((handles (or ihandles (mm-dissect-buffer) (mm-uu-dissect)))
3349 buffer-read-only handle name type b e display)
3350 (when (and (not ihandles)
3351 (not gnus-displaying-mime))
3352 ;; Top-level call; we clean up.
3353 (when gnus-article-mime-handles
3354 (mm-destroy-parts gnus-article-mime-handles)
3355 (setq gnus-article-mime-handle-alist nil));; A trick.
3356 (setq gnus-article-mime-handles handles)
3357 ;; We allow users to glean info from the handles.
3358 (when gnus-article-mime-part-function
3359 (gnus-mime-part-function handles)))
3361 (or (not (stringp (car handles)))
3364 (when (and (not ihandles)
3365 (not gnus-displaying-mime))
3366 ;; Clean up for mime parts.
3368 (delete-region (point) (point-max)))
3369 (let ((gnus-displaying-mime t))
3370 (gnus-mime-display-part handles)))
3373 (narrow-to-region (point) (point-max))
3374 (gnus-treat-article nil 1 1)
3377 ;; Highlight the headers.
3381 (narrow-to-region (point-min) (point))
3382 (gnus-treat-article 'head))))))))
3384 (defvar gnus-mime-display-multipart-as-mixed nil)
3386 (defun gnus-mime-display-part (handle)
3389 ((not (stringp (car handle)))
3390 (gnus-mime-display-single handle))
3391 ;; User-defined multipart
3392 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
3393 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
3395 ;; multipart/alternative
3396 ((and (equal (car handle) "multipart/alternative")
3397 (not gnus-mime-display-multipart-as-mixed))
3398 (let ((id (1+ (length gnus-article-mime-handle-alist))))
3399 (push (cons id handle) gnus-article-mime-handle-alist)
3400 (gnus-mime-display-alternative (cdr handle) nil nil id)))
3401 ;; multipart/related
3402 ((and (equal (car handle) "multipart/related")
3403 (not gnus-mime-display-multipart-as-mixed))
3404 ;;;!!!We should find the start part, but we just default
3405 ;;;!!!to the first part.
3406 (gnus-mime-display-part (cadr handle)))
3407 ;; Other multiparts are handled like multipart/mixed.
3409 (gnus-mime-display-mixed (cdr handle)))))
3411 (defun gnus-mime-part-function (handles)
3412 (if (stringp (car handles))
3413 (mapcar 'gnus-mime-part-function (cdr handles))
3414 (funcall gnus-article-mime-part-function handles)))
3416 (defun gnus-mime-display-mixed (handles)
3417 (mapcar 'gnus-mime-display-part handles))
3419 (defun gnus-mime-display-single (handle)
3420 (let ((type (mm-handle-media-type handle))
3421 (ignored gnus-ignored-mime-types)
3428 (when (string-match (pop ignored) type)
3429 (throw 'ignored nil)))
3430 (if (and (setq not-attachment
3431 (and (not (mm-inline-override-p handle))
3432 (or (not (mm-handle-disposition handle))
3433 (equal (car (mm-handle-disposition handle))
3435 (mm-attachment-override-p handle))))
3436 (mm-automatic-display-p handle)
3437 (or (mm-inlined-p handle)
3438 (mm-automatic-external-display-p type)))
3440 (when (equal (mm-handle-media-supertype handle) "text")
3442 (let ((id (1+ (length gnus-article-mime-handle-alist)))
3444 (push (cons id handle) gnus-article-mime-handle-alist)
3445 (when (or (not display)
3446 (not (gnus-unbuttonized-mime-type-p type)))
3447 ;(gnus-article-insert-newline)
3448 (gnus-insert-mime-button
3449 handle id (list (or display (and not-attachment text))))
3450 (gnus-article-insert-newline)
3451 ;(gnus-article-insert-newline)
3459 (let ((mail-parse-charset gnus-newsgroup-charset)
3460 (mail-parse-ignored-charsets
3461 (save-excursion (condition-case ()
3462 (set-buffer gnus-summary-buffer)
3464 gnus-newsgroup-ignored-charsets)))
3465 (mm-display-part handle t))
3466 (goto-char (point-max)))
3467 ((and text not-attachment)
3471 (gnus-article-insert-newline)
3472 (mm-insert-inline handle (mm-get-part handle))
3473 (goto-char (point-max))))
3477 (narrow-to-region beg (point))
3480 (gnus-article-mime-total-parts)
3481 (mm-handle-media-type handle)))))))))
3483 (defun gnus-unbuttonized-mime-type-p (type)
3484 "Say whether TYPE is to be unbuttonized."
3485 (unless gnus-inhibit-mime-unbuttonizing
3487 (let ((types gnus-unbuttonized-mime-types))
3489 (when (string-match (pop types) type)
3490 (throw 'found t)))))))
3492 (defun gnus-article-insert-newline ()
3493 "Insert a newline, but mark it as undeletable."
3494 (gnus-put-text-property
3495 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
3497 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
3498 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
3501 handle buffer-read-only from props begend not-pref)
3502 (save-window-excursion
3505 (narrow-to-region (car ibegend)
3508 (goto-char (car ibegend))
3511 (delete-region (point-min) (point-max))
3512 (mm-remove-parts handles))
3513 (setq begend (list (point-marker)))
3515 (unless (setq not-pref (cadr (member preferred ihandles)))
3516 (setq not-pref (car ihandles)))
3518 (not (gnus-unbuttonized-mime-type-p
3519 "multipart/alternative")))
3520 (gnus-add-text-properties
3523 (insert (format "%d. " id))
3527 (unless ,(not ibegend)
3528 (setq gnus-article-mime-handle-alist
3529 ',gnus-article-mime-handle-alist))
3530 (gnus-mime-display-alternative
3531 ',ihandles ',not-pref ',begend ,id))
3532 ;; Not for Emacs 21: fixme better.
3533 ;; local-map ,gnus-mime-button-map
3534 ,gnus-mouse-face-prop ,gnus-article-mouse-face
3535 face ,gnus-article-button-face
3536 keymap ,gnus-mime-button-map
3539 (widget-convert-button 'link from (point)
3540 :action 'gnus-widget-press-button
3541 :button-keymap gnus-widget-button-keymap)
3543 (while (setq handle (pop handles))
3544 (gnus-add-text-properties
3547 (insert (format "(%c) %-18s"
3548 (if (equal handle preferred) ?* ? )
3549 (mm-handle-media-type handle)))
3553 (unless ,(not ibegend)
3554 (setq gnus-article-mime-handle-alist
3555 ',gnus-article-mime-handle-alist))
3556 (gnus-mime-display-alternative
3557 ',ihandles ',handle ',begend ,id))
3558 ;; Not for Emacs 21: fixme better.
3559 ;; local-map ,gnus-mime-button-map
3560 ,gnus-mouse-face-prop ,gnus-article-mouse-face
3561 face ,gnus-article-button-face
3562 keymap ,gnus-mime-button-map
3565 (widget-convert-button 'link from (point)
3566 :action 'gnus-widget-press-button
3567 :button-keymap gnus-widget-button-keymap)
3571 (if (stringp (car preferred))
3572 (gnus-display-mime preferred)
3573 (let ((mail-parse-charset gnus-newsgroup-charset)
3574 (mail-parse-ignored-charsets
3575 (save-excursion (set-buffer gnus-summary-buffer)
3576 gnus-newsgroup-ignored-charsets)))
3577 (mm-display-part preferred)
3581 (narrow-to-region (car begend) (point-max))
3583 nil (length gnus-article-mime-handle-alist)
3584 (gnus-article-mime-total-parts)
3585 (mm-handle-media-type handle))))))
3586 (goto-char (point-max))
3587 (setcdr begend (point-marker)))))
3589 (goto-char point))))
3591 (defun gnus-article-wash-status ()
3592 "Return a string which display status of article washing."
3594 (set-buffer gnus-article-buffer)
3595 (let ((cite (memq 'cite gnus-article-wash-types))
3596 (headers (memq 'headers gnus-article-wash-types))
3597 (boring (memq 'boring-headers gnus-article-wash-types))
3598 (pgp (memq 'pgp gnus-article-wash-types))
3599 (pem (memq 'pem gnus-article-wash-types))
3600 (signature (memq 'signature gnus-article-wash-types))
3601 (overstrike (memq 'overstrike gnus-article-wash-types))
3602 (emphasis (memq 'emphasis gnus-article-wash-types)))
3603 (format "%c%c%c%c%c%c"
3605 (if (or headers boring) ?h ? )
3606 (if (or pgp pem) ?p ? )
3607 (if signature ?s ? )
3608 (if overstrike ?o ? )
3609 (if emphasis ?e ? )))))
3611 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
3613 (defun gnus-article-maybe-hide-headers ()
3614 "Hide unwanted headers if `gnus-have-all-headers' is nil.
3615 Provided for backwards compatibility."
3616 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
3617 (not (save-excursion (set-buffer gnus-summary-buffer)
3618 gnus-have-all-headers)))
3619 (not gnus-inhibit-hiding))
3620 (gnus-article-hide-headers)))
3624 (defun gnus-output-to-file (file-name)
3625 "Append the current article to a file named FILE-NAME."
3626 (let ((artbuf (current-buffer)))
3628 (insert-buffer-substring artbuf)
3629 ;; Append newline at end of the buffer as separator, and then
3631 (goto-char (point-max))
3633 (mm-append-to-file (point-min) (point-max) file-name)
3636 (defun gnus-narrow-to-page (&optional arg)
3637 "Narrow the article buffer to a page.
3638 If given a numerical ARG, move forward ARG pages."
3640 (setq arg (if arg (prefix-numeric-value arg) 0))
3642 (set-buffer gnus-article-buffer)
3643 (goto-char (point-min))
3645 ;; Remove any old next/prev buttons.
3646 (when (gnus-visual-p 'page-marker)
3647 (let ((buffer-read-only nil))
3648 (gnus-remove-text-with-property 'gnus-prev)
3649 (gnus-remove-text-with-property 'gnus-next)))
3652 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
3654 (re-search-forward page-delimiter nil 'move arg)))
3655 (goto-char (match-end 0)))
3658 (if (re-search-forward page-delimiter nil 'move)
3661 (when (and (gnus-visual-p 'page-marker)
3662 (not (= (point-min) 1)))
3664 (goto-char (point-min))
3665 (gnus-insert-prev-page-button)))
3666 (when (and (gnus-visual-p 'page-marker)
3667 (< (+ (point-max) 2) (buffer-size)))
3669 (goto-char (point-max))
3670 (gnus-insert-next-page-button)))))
3672 ;; Article mode commands
3674 (defun gnus-article-goto-next-page ()
3675 "Show the next page of the article."
3677 (when (gnus-article-next-page)
3678 (goto-char (point-min))
3679 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
3681 (defun gnus-article-goto-prev-page ()
3682 "Show the next page of the article."
3684 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
3685 (gnus-article-prev-page nil)))
3687 (defun gnus-article-next-page (&optional lines)
3688 "Show the next page of the current article.
3689 If end of article, return non-nil. Otherwise return nil.
3690 Argument LINES specifies lines to be scrolled up."
3692 (move-to-window-line -1)
3695 (and (pos-visible-in-window-p) ;Not continuation line.
3697 ;; Nothing in this page.
3698 (if (or (not gnus-page-broken)
3701 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
3703 (gnus-narrow-to-page 1) ;Go to next page.
3705 ;; More in this page.
3706 (let ((scroll-in-place nil))
3710 ;; Long lines may cause an end-of-buffer error.
3711 (goto-char (point-max)))))
3712 (move-to-window-line 0)
3715 (defun gnus-article-prev-page (&optional lines)
3716 "Show previous page of current article.
3717 Argument LINES specifies lines to be scrolled down."
3719 (move-to-window-line 0)
3720 (if (and gnus-page-broken
3722 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
3724 (gnus-narrow-to-page -1) ;Go to previous page.
3725 (goto-char (point-max))
3727 (let ((scroll-in-place nil))
3731 (beginning-of-buffer
3732 (goto-char (point-min))))
3733 (move-to-window-line 0)))))
3735 (defun gnus-article-refer-article ()
3736 "Read article specified by message-id around point."
3738 (let ((point (point)))
3739 (search-forward ">" nil t) ;Move point to end of "<....>".
3740 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
3741 (let ((message-id (match-string 1)))
3743 (set-buffer gnus-summary-buffer)
3744 (gnus-summary-refer-article message-id))
3746 (error "No references around point"))))
3748 (defun gnus-article-show-summary ()
3749 "Reconfigure windows to show summary buffer."
3751 (if (not (gnus-buffer-live-p gnus-summary-buffer))
3752 (error "There is no summary buffer for this article buffer")
3753 (gnus-article-set-globals)
3754 (gnus-configure-windows 'article)
3755 (gnus-summary-goto-subject gnus-current-article)
3756 (gnus-summary-position-point)))
3758 (defun gnus-article-describe-briefly ()
3759 "Describe article mode commands briefly."
3761 (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")))
3763 (defun gnus-article-summary-command ()
3764 "Execute the last keystroke in the summary buffer."
3766 (let ((obuf (current-buffer))
3767 (owin (current-window-configuration))
3769 (switch-to-buffer gnus-article-current-summary 'norecord)
3770 (setq func (lookup-key (current-local-map) (this-command-keys)))
3771 (call-interactively func)
3773 (set-window-configuration owin)
3774 (set-window-point (get-buffer-window (current-buffer)) (point))))
3776 (defun gnus-article-summary-command-nosave ()
3777 "Execute the last keystroke in the summary buffer."
3780 (pop-to-buffer gnus-article-current-summary 'norecord)
3781 (setq func (lookup-key (current-local-map) (this-command-keys)))
3782 (call-interactively func)))
3784 (defun gnus-article-check-buffer ()
3785 "Beep if not in an article buffer."
3786 (unless (equal major-mode 'gnus-article-mode)
3787 (error "Command invoked outside of a Gnus article buffer")))
3789 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
3790 "Read a summary buffer key sequence and execute it from the article buffer."
3792 (gnus-article-check-buffer)
3794 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
3795 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
3796 "=" "^" "\M-^" "|"))
3802 '("n" "Gn" "p" "Gp"))
3805 (set-buffer gnus-article-current-summary)
3806 (let (gnus-pick-mode)
3807 (push (or key last-command-event) unread-command-events)
3808 (setq keys (if (featurep 'xemacs)
3809 (events-to-keys (read-key-sequence nil))
3810 (read-key-sequence nil)))))
3814 (if (or (member keys nosaves)
3815 (member keys nosave-but-article)
3816 (member keys nosave-in-article))
3818 (save-window-excursion
3819 (pop-to-buffer gnus-article-current-summary 'norecord)
3820 ;; We disable the pick minor mode commands.
3821 (let (gnus-pick-mode)
3822 (setq func (lookup-key (current-local-map) keys))))
3826 (unless (member keys nosave-in-article)
3827 (set-buffer gnus-article-current-summary))
3828 (call-interactively func)
3829 (setq new-sum-point (point)))
3830 (when (member keys nosave-but-article)
3831 (pop-to-buffer gnus-article-buffer 'norecord)))
3832 ;; These commands should restore window configuration.
3833 (let ((obuf (current-buffer))
3834 (owin (current-window-configuration))
3836 (summary gnus-article-current-summary)
3837 func in-buffer selected)
3838 (if not-restore-window
3839 (pop-to-buffer summary 'norecord)
3840 (switch-to-buffer summary 'norecord))
3841 (setq in-buffer (current-buffer))
3842 ;; We disable the pick minor mode commands.
3843 (if (and (setq func (let (gnus-pick-mode)
3844 (lookup-key (current-local-map) keys)))
3847 (call-interactively func)
3848 (setq new-sum-point (point))
3849 (when (eq in-buffer (current-buffer))
3850 (setq selected (gnus-summary-select-article))
3852 (unless not-restore-window
3853 (set-window-configuration owin))
3854 (when (eq selected 'old)
3856 (set-window-start (get-buffer-window (current-buffer))
3858 (set-window-point (get-buffer-window (current-buffer))
3860 (let ((win (get-buffer-window gnus-article-current-summary)))
3862 (set-window-point win new-sum-point)))) )
3863 (switch-to-buffer gnus-article-buffer)
3866 (defun gnus-article-describe-key (key)
3867 "Display documentation of the function invoked by KEY. KEY is a string."
3868 (interactive "kDescribe key: ")
3869 (gnus-article-check-buffer)
3870 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
3872 (set-buffer gnus-article-current-summary)
3873 (let (gnus-pick-mode)
3874 (push (elt key 0) unread-command-events)
3875 (setq key (if (featurep 'xemacs)
3876 (events-to-keys (read-key-sequence "Describe key: "))
3877 (read-key-sequence "Describe key: "))))
3879 (describe-key key)))
3881 (defun gnus-article-describe-key-briefly (key &optional insert)
3882 "Display documentation of the function invoked by KEY. KEY is a string."
3883 (interactive "kDescribe key: \nP")
3884 (gnus-article-check-buffer)
3885 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
3887 (set-buffer gnus-article-current-summary)
3888 (let (gnus-pick-mode)
3889 (push (elt key 0) unread-command-events)
3890 (setq key (if (featurep 'xemacs)
3891 (events-to-keys (read-key-sequence "Describe key: "))
3892 (read-key-sequence "Describe key: "))))
3893 (describe-key-briefly key insert))
3894 (describe-key-briefly key insert)))
3896 (defun gnus-article-hide (&optional arg force)
3897 "Hide all the gruft in the current article.
3898 This means that PGP stuff, signatures, cited text and (some)
3899 headers will be hidden.
3900 If given a prefix, show the hidden text instead."
3901 (interactive (append (gnus-article-hidden-arg) (list 'force)))
3902 (gnus-article-hide-headers arg)
3903 (gnus-article-hide-list-identifiers arg)
3904 (gnus-article-hide-pgp arg)
3905 (gnus-article-hide-citation-maybe arg force)
3906 (gnus-article-hide-signature arg))
3908 (defun gnus-article-maybe-highlight ()
3909 "Do some article highlighting if article highlighting is requested."
3910 (when (gnus-visual-p 'article-highlight 'highlight)
3911 (gnus-article-highlight-some)))
3913 (defun gnus-check-group-server ()
3914 ;; Make sure the connection to the server is alive.
3915 (unless (gnus-server-opened
3916 (gnus-find-method-for-group gnus-newsgroup-name))
3917 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
3918 (gnus-request-group gnus-newsgroup-name t)))
3920 (defun gnus-request-article-this-buffer (article group)
3921 "Get an article and insert it into this buffer."
3922 (let (do-update-line sparse-header)
3926 (gnus-kill-all-overlays)
3927 (setq group (or group gnus-newsgroup-name))
3929 ;; Using `gnus-request-article' directly will insert the article into
3930 ;; `nntp-server-buffer' - so we'll save some time by not having to
3931 ;; copy it from the server buffer into the article buffer.
3933 ;; We only request an article by message-id when we do not have the
3934 ;; headers for it, so we'll have to get those.
3935 (when (stringp article)
3936 (gnus-read-header article))
3938 ;; If the article number is negative, that means that this article
3939 ;; doesn't belong in this newsgroup (possibly), so we find its
3940 ;; message-id and request it by id instead of number.
3941 (when (and (numberp article)
3943 (get-buffer gnus-summary-buffer)
3944 (gnus-buffer-exists-p gnus-summary-buffer))
3946 (set-buffer gnus-summary-buffer)
3947 (let ((header (gnus-summary-article-header article)))
3950 ((memq article gnus-newsgroup-sparse)
3951 ;; This is a sparse gap article.
3952 (setq do-update-line article)
3953 (setq article (mail-header-id header))
3954 (setq sparse-header (gnus-read-header article))
3955 (setq gnus-newsgroup-sparse
3956 (delq article gnus-newsgroup-sparse)))
3958 ;; It's a real article.
3959 (setq article (mail-header-id header)))
3961 ;; It is an extracted pseudo-article.
3962 (setq article 'pseudo)
3963 (gnus-request-pseudo-article header))))
3965 (let ((method (gnus-find-method-for-group
3966 gnus-newsgroup-name)))
3967 (when (and (eq (car method) 'nneething)
3969 (let ((dir (expand-file-name
3970 (mail-header-subject header)
3971 (file-name-as-directory
3972 (or (cadr (assq 'nneething-address method))
3974 (when (file-directory-p dir)
3975 (setq article 'nneething)
3976 (gnus-group-enter-directory dir))))))))
3979 ;; Refuse to select canceled articles.
3980 ((and (numberp article)
3982 (get-buffer gnus-summary-buffer)
3983 (gnus-buffer-exists-p gnus-summary-buffer)
3984 (eq (cdr (save-excursion
3985 (set-buffer gnus-summary-buffer)
3986 (assq article gnus-newsgroup-reads)))
3987 gnus-canceled-mark))
3989 ;; We first check `gnus-original-article-buffer'.
3990 ((and (get-buffer gnus-original-article-buffer)
3993 (set-buffer gnus-original-article-buffer)
3994 (and (equal (car gnus-original-article) group)
3995 (eq (cdr gnus-original-article) article))))
3996 (insert-buffer-substring gnus-original-article-buffer)
3998 ;; Check the backlog.
3999 ((and gnus-keep-backlog
4000 (gnus-backlog-request-article group article (current-buffer)))
4002 ;; Check asynchronous pre-fetch.
4003 ((gnus-async-request-fetched-article group article (current-buffer))
4004 (gnus-async-prefetch-next group article gnus-summary-buffer)
4005 (when (and (numberp article) gnus-keep-backlog)
4006 (gnus-backlog-enter-article group article (current-buffer)))
4009 ((and gnus-use-cache
4011 (gnus-cache-request-article article group))
4013 ;; Get the article and put into the article buffer.
4014 ((or (stringp article)
4016 (let ((gnus-override-method gnus-override-method)
4017 (methods (and (stringp article)
4018 gnus-refer-article-method))
4020 (buffer-read-only nil))
4021 (if (or (not (listp methods))
4022 (and (symbolp (car methods))
4023 (assq (car methods) nnoo-definition-alist)))
4024 (setq methods (list methods)))
4025 (when (and (null gnus-override-method)
4027 (setq gnus-override-method (pop methods)))
4029 (when (eq gnus-override-method 'current)
4030 (setq gnus-override-method gnus-current-select-method))
4032 (gnus-kill-all-overlays)
4033 (let ((gnus-newsgroup-name group))
4034 (gnus-check-group-server))
4035 (when (gnus-request-article article group (current-buffer))
4036 (when (numberp article)
4037 (gnus-async-prefetch-next group article
4038 gnus-summary-buffer)
4039 (when gnus-keep-backlog
4040 (gnus-backlog-enter-article
4041 group article (current-buffer))))
4042 (setq result 'article))
4045 (setq gnus-override-method (pop methods))
4046 (setq result 'done))))
4047 (and (eq result 'article) 'article)))
4051 ;; Associate this article with the current summary buffer.
4052 (setq gnus-article-current-summary gnus-summary-buffer)
4054 ;; Take the article from the original article buffer
4055 ;; and place it in the buffer it's supposed to be in.
4056 (when (and (get-buffer gnus-article-buffer)
4057 (equal (buffer-name (current-buffer))
4058 (buffer-name (get-buffer gnus-article-buffer))))
4060 (if (get-buffer gnus-original-article-buffer)
4061 (set-buffer gnus-original-article-buffer)
4062 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
4063 (buffer-disable-undo)
4064 (setq major-mode 'gnus-original-article-mode)
4065 (setq buffer-read-only t))
4066 (let (buffer-read-only)
4068 (insert-buffer-substring gnus-article-buffer))
4069 (setq gnus-original-article (cons group article)))
4072 (run-hooks 'gnus-article-decode-hook)
4073 ;; Mark article as decoded or not.
4074 (setq gnus-article-decoded-p gnus-article-decode-hook))
4076 ;; Update sparse articles.
4077 (when (and do-update-line
4078 (or (numberp article)
4080 (let ((buf (current-buffer)))
4081 (set-buffer gnus-summary-buffer)
4082 (gnus-summary-update-article do-update-line sparse-header)
4083 (gnus-summary-goto-subject do-update-line nil t)
4084 (set-window-point (get-buffer-window (current-buffer) t)
4086 (set-buffer buf))))))
4092 (defcustom gnus-article-edit-mode-hook nil
4093 "Hook run in article edit mode buffers."
4094 :group 'gnus-article-various
4097 (defvar gnus-article-edit-done-function nil)
4099 (defvar gnus-article-edit-mode-map nil)
4101 ;; Should we be using derived.el for this?
4102 (unless gnus-article-edit-mode-map
4103 (setq gnus-article-edit-mode-map (make-sparse-keymap))
4104 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
4106 (gnus-define-keys gnus-article-edit-mode-map
4107 "\C-c\C-c" gnus-article-edit-done
4108 "\C-c\C-k" gnus-article-edit-exit)
4110 (gnus-define-keys (gnus-article-edit-wash-map
4111 "\C-c\C-w" gnus-article-edit-mode-map)
4112 "f" gnus-article-edit-full-stops))
4114 (defun gnus-article-edit-mode ()
4115 "Major mode for editing articles.
4116 This is an extended text-mode.
4118 \\{gnus-article-edit-mode-map}"
4120 (setq major-mode 'gnus-article-edit-mode)
4121 (setq mode-name "Article Edit")
4122 (use-local-map gnus-article-edit-mode-map)
4123 (make-local-variable 'gnus-article-edit-done-function)
4124 (make-local-variable 'gnus-prev-winconf)
4125 (setq buffer-read-only nil)
4126 (buffer-enable-undo)
4128 (gnus-run-hooks 'text-mode-hook 'gnus-article-edit-mode-hook))
4130 (defun gnus-article-edit (&optional force)
4131 "Edit the current article.
4132 This will have permanent effect only in mail groups.
4133 If FORCE is non-nil, allow editing of articles even in read-only
4136 (when (and (not force)
4137 (gnus-group-read-only-p))
4138 (error "The current newsgroup does not support article editing"))
4139 (gnus-article-date-original)
4140 (gnus-article-edit-article
4142 `(lambda (no-highlight)
4144 (gnus-summary-edit-article-done
4145 ,(or (mail-header-references gnus-current-headers) "")
4146 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
4148 (defun gnus-article-edit-article (start-func exit-func)
4149 "Start editing the contents of the current article buffer."
4150 (let ((winconf (current-window-configuration)))
4151 (set-buffer gnus-article-buffer)
4152 (gnus-article-edit-mode)
4153 (funcall start-func)
4154 (gnus-configure-windows 'edit-article)
4155 (setq gnus-article-edit-done-function exit-func)
4156 (setq gnus-prev-winconf winconf)
4157 (gnus-message 6 "C-c C-c to end edits")))
4159 (defun gnus-article-edit-done (&optional arg)
4160 "Update the article edits and exit."
4165 (when (article-goto-body)
4166 (let ((lines (count-lines (point) (point-max)))
4167 (length (- (point-max) (point)))
4168 (case-fold-search t)
4169 (body (copy-marker (point))))
4170 (goto-char (point-min))
4171 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
4172 (delete-region (match-beginning 1) (match-end 1))
4173 (insert (number-to-string length)))
4174 (goto-char (point-min))
4175 (when (re-search-forward
4176 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
4177 (delete-region (match-beginning 1) (match-end 1))
4178 (insert (number-to-string length)))
4179 (goto-char (point-min))
4180 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
4181 (delete-region (match-beginning 1) (match-end 1))
4182 (insert (number-to-string lines)))))))
4183 (let ((func gnus-article-edit-done-function)
4184 (buf (current-buffer))
4185 (start (window-start)))
4186 (gnus-article-edit-exit)
4189 (let ((buffer-read-only nil))
4191 ;; The cache and backlog have to be flushed somewhat.
4192 (when gnus-keep-backlog
4193 (gnus-backlog-remove-article
4194 (car gnus-article-current) (cdr gnus-article-current)))
4195 ;; Flush original article as well.
4197 (when (get-buffer gnus-original-article-buffer)
4198 (set-buffer gnus-original-article-buffer)
4199 (setq gnus-original-article nil)))
4200 (when gnus-use-cache
4201 (gnus-cache-update-article
4202 (car gnus-article-current) (cdr gnus-article-current))))
4204 (set-window-start (get-buffer-window buf) start)
4205 (set-window-point (get-buffer-window buf) (point))))
4207 (defun gnus-article-edit-exit ()
4208 "Exit the article editing without updating."
4210 ;; We remove all text props from the article buffer.
4211 (let ((buf (buffer-substring-no-properties (point-min) (point-max)))
4212 (curbuf (current-buffer))
4214 (window-start (window-start)))
4217 (let ((winconf gnus-prev-winconf))
4219 (set-window-configuration winconf)
4220 ;; Tippy-toe some to make sure that point remains where it was.
4221 (save-current-buffer
4223 (set-window-start (get-buffer-window (current-buffer)) window-start)
4226 (defun gnus-article-edit-full-stops ()
4227 "Interactively repair spacing at end of sentences."
4230 (goto-char (point-min))
4231 (search-forward-regexp "^$" nil t)
4232 (let ((case-fold-search nil))
4233 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
4236 ;;; Article highlights
4239 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
4241 ;;; Internal Variables:
4243 (defcustom gnus-button-url-regexp "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|news\\|telnet\\|wais\\|mailto\\):\\)\\(//[-a-zA-Z0-9_.]+:[0-9]*\\)?\\([-a-zA-Z0-9_=!?#$@~`%&*+|\\/:;.,]\\|\\w\\)+\\([-a-zA-Z0-9_=#$@~`%&*+|\\/]\\|\\w\\)\\)"
4244 "Regular expression that matches URLs."
4245 :group 'gnus-article-buttons
4248 (defcustom gnus-button-alist
4249 `(("<\\(url:[>\n\t ]*?\\)?news:[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
4250 0 t gnus-button-message-id 2)
4251 ("\\bnews:\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t gnus-button-message-id 1)
4252 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
4254 gnus-button-fetch-group 4)
4255 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
4256 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
4257 t gnus-button-message-id 3)
4258 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
4259 ("mailto:\\([-a-zA-Z.@_+0-9%]+\\)" 0 t gnus-url-mailto 1)
4260 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
4261 ;; This is how URLs _should_ be embedded in text...
4262 ("<URL: *\\([^<>]*\\)>" 0 t gnus-button-embedded-url 1)
4264 (,gnus-button-url-regexp 0 t browse-url 0))
4265 "*Alist of regexps matching buttons in article bodies.
4267 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
4268 REGEXP: is the string matching text around the button,
4269 BUTTON: is the number of the regexp grouping actually matching the button,
4270 FORM: is a lisp expression which must eval to true for the button to
4272 CALLBACK: is the function to call when the user push this button, and each
4273 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
4275 CALLBACK can also be a variable, in that case the value of that
4276 variable it the real callback function."
4277 :group 'gnus-article-buttons
4278 :type '(repeat (list regexp
4279 (integer :tag "Button")
4281 (function :tag "Callback")
4284 (integer :tag "Regexp group")))))
4286 (defcustom gnus-header-button-alist
4287 `(("^\\(References\\|Message-I[Dd]\\):" "<[^>]+>"
4288 0 t gnus-button-message-id 0)
4289 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
4290 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
4291 0 t gnus-button-mailto 0)
4292 ("^X-[Uu][Rr][Ll]:" ,gnus-button-url-regexp 0 t browse-url 0)
4293 ("^Subject:" ,gnus-button-url-regexp 0 t browse-url 0)
4294 ("^[^:]+:" ,gnus-button-url-regexp 0 t browse-url 0)
4295 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
4296 gnus-button-message-id 3))
4297 "*Alist of headers and regexps to match buttons in article heads.
4299 This alist is very similar to `gnus-button-alist', except that each
4300 alist has an additional HEADER element first in each entry:
4302 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
4304 HEADER is a regexp to match a header. For a fuller explanation, see
4305 `gnus-button-alist'."
4306 :group 'gnus-article-buttons
4307 :group 'gnus-article-headers
4308 :type '(repeat (list (regexp :tag "Header")
4310 (integer :tag "Button")
4312 (function :tag "Callback")
4315 (integer :tag "Regexp group")))))
4317 (defvar gnus-button-regexp nil)
4318 (defvar gnus-button-marker-list nil)
4319 ;; Regexp matching any of the regexps from `gnus-button-alist'.
4321 (defvar gnus-button-last nil)
4322 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
4326 (defun gnus-article-push-button (event)
4327 "Check text under the mouse pointer for a callback function.
4328 If the text under the mouse pointer has a `gnus-callback' property,
4329 call it with the value of the `gnus-data' text property."
4331 (set-buffer (window-buffer (posn-window (event-start event))))
4332 (let* ((pos (posn-point (event-start event)))
4333 (data (get-text-property pos 'gnus-data))
4334 (fun (get-text-property pos 'gnus-callback)))
4337 (funcall fun data))))
4339 (defun gnus-article-press-button ()
4340 "Check text at point for a callback function.
4341 If the text at point has a `gnus-callback' property,
4342 call it with the value of the `gnus-data' text property."
4344 (let* ((data (get-text-property (point) 'gnus-data))
4345 (fun (get-text-property (point) 'gnus-callback)))
4347 (funcall fun data))))
4349 (defun gnus-article-highlight (&optional force)
4350 "Highlight current article.
4351 This function calls `gnus-article-highlight-headers',
4352 `gnus-article-highlight-citation',
4353 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
4354 do the highlighting. See the documentation for those functions."
4355 (interactive (list 'force))
4356 (gnus-article-highlight-headers)
4357 (gnus-article-highlight-citation force)
4358 (gnus-article-highlight-signature)
4359 (gnus-article-add-buttons force)
4360 (gnus-article-add-buttons-to-head))
4362 (defun gnus-article-highlight-some (&optional force)
4363 "Highlight current article.
4364 This function calls `gnus-article-highlight-headers',
4365 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
4366 do the highlighting. See the documentation for those functions."
4367 (interactive (list 'force))
4368 (gnus-article-highlight-headers)
4369 (gnus-article-highlight-signature)
4370 (gnus-article-add-buttons))
4372 (defun gnus-article-highlight-headers ()
4373 "Highlight article headers as specified by `gnus-header-face-alist'."
4376 (set-buffer gnus-article-buffer)
4378 (let ((alist gnus-header-face-alist)
4379 (buffer-read-only nil)
4380 (case-fold-search t)
4381 (inhibit-point-motion-hooks t)
4382 entry regexp header-face field-face from hpoints fpoints)
4383 (article-narrow-to-head)
4384 (while (setq entry (pop alist))
4385 (goto-char (point-min))
4386 (setq regexp (concat "^\\("
4387 (if (string-equal "" (nth 0 entry))
4391 header-face (nth 1 entry)
4392 field-face (nth 2 entry))
4393 (while (and (re-search-forward regexp nil t)
4397 (unless (search-forward ":" nil t)
4399 (when (and header-face
4400 (not (memq (point) hpoints)))
4401 (push (point) hpoints)
4402 (gnus-put-text-property from (point) 'face header-face))
4403 (when (and field-face
4404 (not (memq (setq from (point)) fpoints)))
4406 (if (re-search-forward "^[^ \t]" nil t)
4408 (goto-char (point-max)))
4409 (gnus-put-text-property from (point) 'face field-face))))))))
4411 (defun gnus-article-highlight-signature ()
4412 "Highlight the signature in an article.
4413 It does this by highlighting everything after
4414 `gnus-signature-separator' using `gnus-signature-face'."
4417 (set-buffer gnus-article-buffer)
4418 (let ((buffer-read-only nil)
4419 (inhibit-point-motion-hooks t))
4421 (when (and gnus-signature-face
4422 (gnus-article-narrow-to-signature))
4423 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
4424 'face gnus-signature-face)
4426 (gnus-article-search-signature)
4427 (let ((start (match-beginning 0))
4428 (end (set-marker (make-marker) (1+ (match-end 0)))))
4429 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
4432 (defun gnus-button-in-region-p (b e prop)
4433 "Say whether PROP exists in the region."
4434 (text-property-not-all b e prop nil))
4436 (defun gnus-article-add-buttons (&optional force)
4437 "Find external references in the article and make buttons of them.
4438 \"External references\" are things like Message-IDs and URLs, as
4439 specified by `gnus-button-alist'."
4440 (interactive (list 'force))
4442 (set-buffer gnus-article-buffer)
4443 (let ((buffer-read-only nil)
4444 (inhibit-point-motion-hooks t)
4445 (case-fold-search t)
4446 (alist gnus-button-alist)
4448 ;; Remove all old markers.
4449 (let (marker entry new-list)
4450 (while (setq marker (pop gnus-button-marker-list))
4451 (if (or (< marker (point-min)) (>= marker (point-max)))
4452 (push marker new-list)
4454 (when (setq entry (gnus-button-entry))
4455 (put-text-property (match-beginning (nth 1 entry))
4456 (match-end (nth 1 entry))
4457 'gnus-callback nil))
4458 (set-marker marker nil)))
4459 (setq gnus-button-marker-list new-list))
4460 ;; We skip the headers.
4463 (while (setq entry (pop alist))
4464 (setq regexp (car entry))
4466 (while (re-search-forward regexp nil t)
4467 (let* ((start (and entry (match-beginning (nth 1 entry))))
4468 (end (and entry (match-end (nth 1 entry))))
4469 (from (match-beginning 0)))
4470 (when (and (or (eq t (nth 2 entry))
4471 (eval (nth 2 entry)))
4472 (not (gnus-button-in-region-p
4473 start end 'gnus-callback)))
4474 ;; That optional form returned non-nil, so we add the
4476 (gnus-article-add-button
4477 start end 'gnus-button-push
4478 (car (push (set-marker (make-marker) from)
4479 gnus-button-marker-list))))))))))
4481 ;; Add buttons to the head of an article.
4482 (defun gnus-article-add-buttons-to-head ()
4483 "Add buttons to the head of the article."
4486 (set-buffer gnus-article-buffer)
4488 (let ((buffer-read-only nil)
4489 (inhibit-point-motion-hooks t)
4490 (case-fold-search t)
4491 (alist gnus-header-button-alist)
4493 (article-narrow-to-head)
4495 ;; Each alist entry.
4496 (setq entry (car alist)
4498 (goto-char (point-min))
4499 (while (re-search-forward (car entry) nil t)
4500 ;; Each header matching the entry.
4501 (setq beg (match-beginning 0))
4502 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
4503 (match-beginning 0))
4506 (while (re-search-forward (nth 1 entry) end t)
4507 ;; Each match within a header.
4508 (let* ((entry (cdr entry))
4509 (start (match-beginning (nth 1 entry)))
4510 (end (match-end (nth 1 entry)))
4511 (form (nth 2 entry)))
4512 (goto-char (match-end 0))
4514 (gnus-article-add-button
4515 start end (nth 3 entry)
4516 (buffer-substring (match-beginning (nth 4 entry))
4517 (match-end (nth 4 entry)))))))
4518 (goto-char end)))))))
4520 ;;; External functions:
4522 (defun gnus-article-add-button (from to fun &optional data)
4523 "Create a button between FROM and TO with callback FUN and data DATA."
4524 (when gnus-article-button-face
4525 (gnus-overlay-put (gnus-make-overlay from to)
4526 'face gnus-article-button-face))
4527 (gnus-add-text-properties
4529 (nconc (and gnus-article-mouse-face
4530 (list gnus-mouse-face-prop gnus-article-mouse-face))
4531 (list 'gnus-callback fun)
4532 (and data (list 'gnus-data data))))
4533 (widget-convert-button 'link from to :action 'gnus-widget-press-button
4534 :button-keymap gnus-widget-button-keymap))
4536 ;;; Internal functions:
4538 (defun gnus-article-set-globals ()
4540 (set-buffer gnus-summary-buffer)
4541 (gnus-set-global-variables)))
4543 (defun gnus-signature-toggle (end)
4545 (set-buffer gnus-article-buffer)
4546 (let ((buffer-read-only nil)
4547 (inhibit-point-motion-hooks t))
4548 (if (text-property-any end (point-max) 'article-type 'signature)
4549 (gnus-remove-text-properties-when
4550 'article-type 'signature end (point-max)
4551 (cons 'article-type (cons 'signature
4552 gnus-hidden-properties)))
4553 (gnus-add-text-properties-when
4554 'article-type nil end (point-max)
4555 (cons 'article-type (cons 'signature
4556 gnus-hidden-properties)))))))
4558 (defun gnus-button-entry ()
4559 ;; Return the first entry in `gnus-button-alist' matching this place.
4560 (let ((alist gnus-button-alist)
4563 (setq entry (pop alist))
4564 (if (looking-at (car entry))
4569 (defun gnus-button-push (marker)
4570 ;; Push button starting at MARKER.
4573 (let* ((entry (gnus-button-entry))
4574 (inhibit-point-motion-hooks t)
4576 (args (mapcar (lambda (group)
4577 (let ((string (match-string group)))
4578 (gnus-set-text-properties
4579 0 (length string) nil string)
4586 (fboundp (symbol-value fun)))
4587 (apply (symbol-value fun) args))
4589 (gnus-message 1 "You must define `%S' to use this button"
4590 (cons fun args)))))))
4592 (defun gnus-button-message-id (message-id)
4595 (set-buffer gnus-summary-buffer)
4596 (gnus-summary-refer-article message-id)))
4598 (defun gnus-button-fetch-group (address)
4599 "Fetch GROUP specified by ADDRESS."
4600 (if (not (string-match "[:/]" address))
4601 ;; This is just a simple group url.
4602 (gnus-group-read-ephemeral-group address gnus-select-method)
4603 (if (not (string-match "^\\([^:/]+\\)\\(:\\([^/]+\\)/\\)?\\(.*\\)$"
4605 (error "Can't parse %s" address)
4606 (gnus-group-read-ephemeral-group
4607 (match-string 4 address)
4608 `(nntp ,(match-string 1 address)
4609 (nntp-address ,(match-string 1 address))
4610 (nntp-port-number ,(if (match-end 3)
4611 (match-string 3 address)
4614 (defun gnus-url-parse-query-string (query &optional downcase)
4615 (let (retval pairs cur key val)
4616 (setq pairs (split-string query "&"))
4618 (setq cur (car pairs)
4620 (if (not (string-match "=" cur))
4622 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
4623 val (gnus-url-unhex-string (substring cur (match-end 0) nil)))
4625 (setq key (downcase key)))
4626 (setq cur (assoc key retval))
4628 (setcdr cur (cons val (cdr cur)))
4629 (setq retval (cons (list key val) retval)))))
4632 (defun gnus-url-unhex (x)
4639 (defun gnus-url-unhex-string (str &optional allow-newlines)
4640 "Remove %XXX embedded spaces, etc in a url.
4641 If optional second argument ALLOW-NEWLINES is non-nil, then allow the
4642 decoding of carriage returns and line feeds in the string, which is normally
4643 forbidden in URL encoding."
4644 (setq str (or str ""))
4646 (case-fold-search t))
4647 (while (string-match "%[0-9a-f][0-9a-f]" str)
4648 (let* ((start (match-beginning 0))
4649 (ch1 (gnus-url-unhex (elt str (+ start 1))))
4651 (gnus-url-unhex (elt str (+ start 2))))))
4653 tmp (substring str 0 start)
4656 (char-to-string code))
4657 ((or (= code ?\n) (= code ?\r))
4659 (t (char-to-string code))))
4660 str (substring str (match-end 0)))))
4661 (setq tmp (concat tmp str))
4664 (defun gnus-url-mailto (url)
4665 ;; Send mail to someone
4666 (when (string-match "mailto:/*\\(.*\\)" url)
4667 (setq url (substring url (match-beginning 1) nil)))
4668 (let (to args subject func)
4669 (if (string-match (regexp-quote "?") url)
4670 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
4671 args (gnus-url-parse-query-string
4672 (substring url (match-end 0) nil) t))
4673 (setq to (gnus-url-unhex-string url)))
4674 (setq args (cons (list "to" to) args)
4675 subject (cdr-safe (assoc "subject" args)))
4678 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
4681 (message-position-on-field (caar args)))
4682 (insert (mapconcat 'identity (cdar args) ", "))
4683 (setq args (cdr args)))
4686 (message-goto-subject))))
4688 (defun gnus-button-mailto (address)
4690 (set-buffer (gnus-copy-article-buffer))
4691 (message-reply address))
4693 (defalias 'gnus-button-reply 'message-reply)
4695 (defun gnus-button-embedded-url (address)
4696 "Activate ADDRESS with `browse-url'."
4697 (browse-url (gnus-strip-whitespace address)))
4699 ;;; Next/prev buttons in the article buffer.
4701 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
4702 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
4704 (defvar gnus-prev-page-map nil)
4705 (unless gnus-prev-page-map
4706 (setq gnus-prev-page-map (make-sparse-keymap))
4707 (define-key gnus-prev-page-map gnus-mouse-2 'gnus-button-prev-page)
4708 (define-key gnus-prev-page-map "\r" 'gnus-button-prev-page))
4710 (defun gnus-insert-prev-page-button ()
4711 (let ((buffer-read-only nil))
4713 gnus-prev-page-line-format nil
4714 `(gnus-prev t local-map ,gnus-prev-page-map
4715 gnus-callback gnus-article-button-prev-page
4716 article-type annotation))))
4718 (defvar gnus-next-page-map nil)
4719 (unless gnus-next-page-map
4720 (setq gnus-next-page-map (make-keymap))
4721 (suppress-keymap gnus-prev-page-map)
4722 (define-key gnus-next-page-map gnus-mouse-2 'gnus-button-next-page)
4723 (define-key gnus-next-page-map "\r" 'gnus-button-next-page))
4725 (defun gnus-button-next-page ()
4726 "Go to the next page."
4728 (let ((win (selected-window)))
4729 (select-window (get-buffer-window gnus-article-buffer t))
4730 (gnus-article-next-page)
4731 (select-window win)))
4733 (defun gnus-button-prev-page ()
4734 "Go to the prev page."
4736 (let ((win (selected-window)))
4737 (select-window (get-buffer-window gnus-article-buffer t))
4738 (gnus-article-prev-page)
4739 (select-window win)))
4741 (defun gnus-insert-next-page-button ()
4742 (let ((buffer-read-only nil))
4743 (gnus-eval-format gnus-next-page-line-format nil
4745 t local-map ,gnus-next-page-map
4746 gnus-callback gnus-article-button-next-page
4747 article-type annotation))))
4749 (defun gnus-article-button-next-page (arg)
4750 "Go to the next page."
4752 (let ((win (selected-window)))
4753 (select-window (get-buffer-window gnus-article-buffer t))
4754 (gnus-article-next-page)
4755 (select-window win)))
4757 (defun gnus-article-button-prev-page (arg)
4758 "Go to the prev page."
4760 (let ((win (selected-window)))
4761 (select-window (get-buffer-window gnus-article-buffer t))
4762 (gnus-article-prev-page)
4763 (select-window win)))
4765 (defvar gnus-decode-header-methods
4766 '(mail-decode-encoded-word-region)
4767 "List of methods used to decode headers.
4769 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
4770 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
4771 (REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
4772 whose names match REGEXP.
4775 ((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
4776 mail-decode-encoded-word-region
4777 (\"chinese\" . rfc1843-decode-region))
4780 (defvar gnus-decode-header-methods-cache nil)
4782 (defun gnus-multi-decode-header (start end)
4783 "Apply the functions from `gnus-encoded-word-methods' that match."
4784 (unless (and gnus-decode-header-methods-cache
4785 (eq gnus-newsgroup-name
4786 (car gnus-decode-header-methods-cache)))
4787 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
4790 (nconc gnus-decode-header-methods-cache (list x))
4791 (if (and gnus-newsgroup-name
4792 (string-match (car x) gnus-newsgroup-name))
4793 (nconc gnus-decode-header-methods-cache
4795 gnus-decode-header-methods))
4796 (let ((xlist gnus-decode-header-methods-cache))
4799 (narrow-to-region start end)
4801 (funcall (pop xlist) (point-min) (point-max))))))
4804 ;;; Treatment top-level handling.
4807 (defun gnus-treat-article (condition &optional part-number total-parts type)
4808 (let ((length (- (point-max) (point-min)))
4809 (alist gnus-treatment-function-alist)
4810 (article-goto-body-goes-to-point-min-p t)
4814 (let ((list gnus-article-treat-types))
4816 (when (string-match (pop list) type)
4817 (throw 'found t)))))))
4818 (highlightp (gnus-visual-p 'article-highlight 'highlight))
4820 (gnus-run-hooks 'gnus-part-display-hook)
4821 (while (setq elem (pop alist))
4824 (if (gnus-buffer-live-p gnus-summary-buffer)
4825 (set-buffer gnus-summary-buffer))
4826 (symbol-value (car elem))))
4827 (when (and (or (consp val)
4829 (gnus-treat-predicate val)
4830 (or (not (get (car elem) 'highlight))
4833 (funcall (cadr elem)))))))
4835 ;; Dynamic variables.
4837 (defvar part-number)
4838 (defvar total-parts)
4843 (defun gnus-treat-predicate (val)
4848 (stringp (car val)))
4849 (apply 'gnus-or (mapcar `(lambda (s)
4850 (string-match s ,(or gnus-newsgroup-name "")))
4853 (let ((pred (pop val)))
4856 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
4858 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
4860 (not (gnus-treat-predicate (car val))))
4862 (equal (car val) type))
4864 (error "%S is not a valid predicate" pred)))))
4872 (eq part-number total-parts))
4876 (error "%S is not a valid value" val))))
4882 (run-hooks 'gnus-art-load-hook)
4884 ;;; gnus-art.el ends here