1 ;;; gnus-art.el --- article mode commands for Semi-gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
7 ;; Katsumi Yamaoka <yamaoka@jpl.org>
8 ;; Keywords: mail, news, MIME
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
31 (eval-when-compile (require 'cl))
32 (eval-when-compile (require 'static))
43 ;; Avoid byte-compile warnings.
52 (autoload 'gnus-msg-mail "gnus-msg" nil t)
53 (autoload 'gnus-button-mailto "gnus-msg")
54 (autoload 'gnus-button-reply "gnus-msg" nil t)
56 (defgroup gnus-article nil
58 :link '(custom-manual "(gnus)The Article Buffer")
61 (defgroup gnus-article-treat nil
62 "Treating article parts."
63 :link '(custom-manual "(gnus)Article Hiding")
66 (defgroup gnus-article-hiding nil
67 "Hiding article parts."
68 :link '(custom-manual "(gnus)Article Hiding")
71 (defgroup gnus-article-highlight nil
72 "Article highlighting."
73 :link '(custom-manual "(gnus)Article Highlighting")
77 (defgroup gnus-article-signature nil
79 :link '(custom-manual "(gnus)Article Signature")
82 (defgroup gnus-article-headers nil
84 :link '(custom-manual "(gnus)Hiding Headers")
87 (defgroup gnus-article-washing nil
88 "Special commands on articles."
89 :link '(custom-manual "(gnus)Article Washing")
92 (defgroup gnus-article-emphasis nil
93 "Fontisizing articles."
94 :link '(custom-manual "(gnus)Article Fontisizing")
97 (defgroup gnus-article-saving nil
99 :link '(custom-manual "(gnus)Saving Articles")
100 :group 'gnus-article)
102 (defgroup gnus-article-mime nil
103 "Worshiping the MIME wonder."
104 :link '(custom-manual "(gnus)Using MIME")
105 :group 'gnus-article)
107 (defgroup gnus-article-buttons nil
108 "Pushable buttons in the article buffer."
109 :link '(custom-manual "(gnus)Article Buttons")
110 :group 'gnus-article)
112 (defgroup gnus-article-various nil
113 "Other article options."
114 :link '(custom-manual "(gnus)Misc Article")
115 :group 'gnus-article)
117 (defcustom gnus-ignored-headers
118 '("^Path:" "^Expires:" "^Date-Received:" "^References:" "^Xref:" "^Lines:"
119 "^Relay-Version:" "^Message-ID:" "^Approved:" "^Sender:" "^Received:"
120 "^X-UIDL:" "^MIME-Version:" "^Return-Path:" "^In-Reply-To:"
121 "^Content-Type:" "^Content-Transfer-Encoding:" "^X-WebTV-Signature:"
122 "^X-MimeOLE:" "^X-MSMail-Priority:" "^X-Priority:" "^X-Loop:"
123 "^X-Authentication-Warning:" "^X-MIME-Autoconverted:" "^X-Face:"
124 "^X-Attribution:" "^X-Originating-IP:" "^Delivered-To:"
125 "^NNTP-[-A-Za-z]+:" "^Distribution:" "^X-no-archive:" "^X-Trace:"
126 "^X-Complaints-To:" "^X-NNTP-Posting-Host:" "^X-Orig.*:"
127 "^Abuse-Reports-To:" "^Cache-Post-Path:" "^X-Article-Creation-Date:"
128 "^X-Poster:" "^X-Mail2News-Path:" "^X-Server-Date:" "^X-Cache:"
129 "^Originator:" "^X-Problems-To:" "^X-Auth-User:" "^X-Post-Time:"
130 "^X-Admin:" "^X-UID:" "^Resent-[-A-Za-z]+:" "^X-Mailing-List:"
131 "^Precedence:" "^Original-[-A-Za-z]+:" "^X-filename:" "^X-Orcpt:"
132 "^Old-Received:" "^X-Pgp" "^X-Auth:" "^X-From-Line:"
133 "^X-Gnus-Article-Number:" "^X-Majordomo:" "^X-Url:" "^X-Sender:"
134 "^MBOX-Line" "^Priority:" "^X400-[-A-Za-z]+:"
135 "^Status:" "^X-Gnus-Mail-Source:" "^Cancel-Lock:"
136 "^X-FTN" "^X-EXP32-SerialNo:" "^Encoding:" "^Importance:"
137 "^Autoforwarded:" "^Original-Encoded-Information-Types:" "^X-Ya-Pop3:"
138 "^X-Face-Version:" "^X-Vms-To:" "^X-ML-NAME:" "^X-ML-COUNT:"
139 "^Mailing-List:" "^X-finfo:" "^X-md5sum:" "^X-md5sum-Origin:"
140 "^X-Sun-Charset:" "^X-Accept-Language:" "^X-Envelope-Sender:"
141 "^List-[A-Za-z]+:" "^X-Listprocessor-Version:"
142 "^X-Received:" "^X-Distribute:" "^X-Sequence:" "^X-Juno-Line-Breaks:"
143 "^X-Notes-Item:" "^X-MS-TNEF-Correlator:" "^x-uunet-gateway:"
144 "^X-Received:" "^Content-length:" "X-precedence:"
145 "^X-Authenticated-User:" "^X-Comment" "^X-Report:" "^X-Abuse-Info:"
146 "^X-HTTP-Proxy:" "^X-Mydeja-Info:" "^X-Copyright" "^X-No-Markup:"
147 "^X-Abuse-Info:" "^X-From_:" "^X-Accept-Language:" "^Errors-To:"
148 "^X-BeenThere:" "^X-Mailman-Version:" "^List-Help:" "^List-Post:"
149 "^List-Subscribe:" "^List-Id:" "^List-Unsubscribe:" "^List-Archive:"
150 "^X-Content-length:" "^X-Posting-Agent:" "^Original-Received:")
151 "*All headers that start with this regexp will be hidden.
152 This variable can also be a list of regexps of headers to be ignored.
153 If `gnus-visible-headers' is non-nil, this variable will be ignored."
154 :type '(choice :custom-show nil
157 :group 'gnus-article-hiding)
159 (defcustom gnus-visible-headers
160 "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^[BGF]?Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Mail-Followup-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-From:\\|^X-Sent:"
161 "*All headers that do not match this regexp will be hidden.
162 This variable can also be a list of regexp of headers to remain visible.
163 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
164 :type '(repeat :value-to-internal (lambda (widget value)
165 (custom-split-regexp-maybe value))
166 :match (lambda (widget value)
168 (widget-editable-list-match widget value)))
170 :group 'gnus-article-hiding)
172 (defcustom gnus-sorted-header-list
173 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
174 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
175 "*This variable is a list of regular expressions.
176 If it is non-nil, headers that match the regular expressions will
177 be placed first in the article buffer in the sequence specified by
179 :type '(repeat regexp)
180 :group 'gnus-article-hiding)
182 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
183 "Headers that are only to be displayed if they have interesting data.
184 Possible values in this list are:
186 'empty Headers with no content.
187 'newsgroups Newsgroup identical to Gnus group.
188 'to-address To identical to To-address.
189 'followup-to Followup-to identical to Newsgroups.
190 'reply-to Reply-to identical to From.
191 'date Date less than four days old.
192 'long-to To and/or Cc longer than 1024 characters.
193 'many-to Multiple To and/or Cc."
194 :type '(set (const :tag "Headers with no content." empty)
195 (const :tag "Newsgroups identical to Gnus group." newsgroups)
196 (const :tag "To identical to To-address." to-address)
197 (const :tag "Followup-to identical to Newsgroups." followup-to)
198 (const :tag "Reply-to identical to From." reply-to)
199 (const :tag "Date less than four days old." date)
200 (const :tag "To and/or Cc longer than 1024 characters." long-to)
201 (const :tag "Multiple To and/or Cc headers." many-to))
202 :group 'gnus-article-hiding)
204 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
205 "Regexp matching signature separator.
206 This can also be a list of regexps. In that case, it will be checked
207 from head to tail looking for a separator. Searches will be done from
208 the end of the buffer."
209 :type '(repeat string)
210 :group 'gnus-article-signature)
212 (defcustom gnus-signature-limit nil
213 "Provide a limit to what is considered a signature.
214 If it is a number, no signature may not be longer (in characters) than
215 that number. If it is a floating point number, no signature may be
216 longer (in lines) than that number. If it is a function, the function
217 will be called without any parameters, and if it returns nil, there is
218 no signature in the buffer. If it is a string, it will be used as a
219 regexp. If it matches, the text in question is not a signature."
220 :type '(choice (integer :value 200)
222 (function :value fun)
223 (regexp :value ".*"))
224 :group 'gnus-article-signature)
226 (defcustom gnus-hidden-properties '(invisible t intangible t)
227 "Property list to use for hiding text."
229 :group 'gnus-article-hiding)
231 ;; Fixme: This isn't the right thing for mixed graphical and and
232 ;; non-graphical frames in a session.
233 ;; gnus-xmas.el overrides this for XEmacs.
234 (defcustom gnus-article-x-face-command
236 ((and (fboundp 'image-type-available-p)
237 (module-installed-p 'x-face-e21))
238 'x-face-decode-message-header)
239 ((and (fboundp 'image-type-available-p)
240 (image-type-available-p 'xbm))
241 'gnus-article-display-xface)
242 ((and (not (featurep 'xemacs))
244 (module-installed-p 'x-face-mule))
245 'x-face-mule-gnus-article-display-x-face)
246 (gnus-article-compface-xbm
247 "{ echo '/* Width=48, Height=48 */'; uncompface; } | display -")
249 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
251 "*String or function to be executed to display an X-Face header.
252 If it is a string, the command will be executed in a sub-shell
253 asynchronously. The compressed face will be piped to this command."
254 :type '(choice string
256 :tag "x-face-decode-message-header (x-face-e21)"
257 x-face-decode-message-header)
258 (function-item gnus-article-display-xface)
259 (function-item x-face-mule-gnus-article-display-x-face)
262 :group 'gnus-article-washing)
264 (defcustom gnus-article-x-face-too-ugly nil
265 "Regexp matching posters whose face shouldn't be shown automatically."
266 :type '(choice regexp (const nil))
267 :group 'gnus-article-washing)
269 (defcustom gnus-article-banner-alist nil
270 "Banner alist for stripping.
272 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
274 :type '(repeat (cons symbol regexp))
275 :group 'gnus-article-washing)
277 (gnus-define-group-parameter
280 "Alist of regexps (to match group names) and banner."
281 :variable-group gnus-article-washing
283 '(choice :tag "Banner"
285 (const :tag "Remove signature" signature)
286 (symbol :tag "Item in `gnus-article-banner-alist'" none)
288 (const :tag "None" nil))
290 "If non-nil, specify how to remove `banners' from articles.
292 Symbol `signature' means to remove signatures delimited by
293 `gnus-signature-separator'. Any other symbol is used to look up a
294 regular expression to match the banner in `gnus-article-banner-alist'.
295 A string is used as a regular expression to match the banner
298 (defcustom gnus-emphasis-alist
300 "\\(\\s-\\|^\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\s-\\|[-,;:\"]\\s-\\|[?!.]+\\s-\\|\\s)\\)")
302 '(("_" "_" underline)
305 ("_/" "/_" underline-italic)
306 ("_\\*" "\\*_" underline-bold)
307 ("\\*/" "/\\*" bold-italic)
308 ("_\\*/" "/\\*_" underline-bold-italic))))
309 `(("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
310 2 3 gnus-emphasis-underline)
314 (format format (car spec) (car (cdr spec)))
315 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
317 "*Alist that says how to fontify certain phrases.
318 Each item looks like this:
320 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
322 The first element is a regular expression to be matched. The second
323 is a number that says what regular expression grouping used to find
324 the entire emphasized word. The third is a number that says what
325 regexp grouping should be displayed and highlighted. The fourth
326 is the face used for highlighting."
327 :type '(repeat (list :value ("" 0 0 default)
329 (integer :tag "Match group")
330 (integer :tag "Emphasize group")
332 :group 'gnus-article-emphasis)
334 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
335 "A regexp to describe whitespace which should not be emphasized.
336 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
337 The former avoids underlining of leading and trailing whitespace,
338 and the latter avoids underlining any whitespace at all."
340 :group 'gnus-article-emphasis
343 (defface gnus-emphasis-bold '((t (:bold t)))
344 "Face used for displaying strong emphasized text (*word*)."
345 :group 'gnus-article-emphasis)
347 (defface gnus-emphasis-italic '((t (:italic t)))
348 "Face used for displaying italic emphasized text (/word/)."
349 :group 'gnus-article-emphasis)
351 (defface gnus-emphasis-underline '((t (:underline t)))
352 "Face used for displaying underlined emphasized text (_word_)."
353 :group 'gnus-article-emphasis)
355 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
356 "Face used for displaying underlined bold emphasized text (_*word*_)."
357 :group 'gnus-article-emphasis)
359 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
360 "Face used for displaying underlined italic emphasized text (_/word/_)."
361 :group 'gnus-article-emphasis)
363 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
364 "Face used for displaying bold italic emphasized text (/*word*/)."
365 :group 'gnus-article-emphasis)
367 (defface gnus-emphasis-underline-bold-italic
368 '((t (:bold t :italic t :underline t)))
369 "Face used for displaying underlined bold italic emphasized text.
370 Esample: (_/*word*/_)."
371 :group 'gnus-article-emphasis)
373 (defface gnus-emphasis-highlight-words
374 '((t (:background "black" :foreground "yellow")))
375 "Face used for displaying highlighted words."
376 :group 'gnus-article-emphasis)
378 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
379 "Format for display of Date headers in article bodies.
380 See `format-time-string' for the possible values.
382 The variable can also be function, which should return a complete Date
383 header. The function is called with one argument, the time, which can
384 be fed to `format-time-string'."
385 :type '(choice string symbol)
386 :link '(custom-manual "(gnus)Article Date")
387 :group 'gnus-article-washing)
390 (autoload 'mail-extract-address-components "mail-extr"))
392 (defcustom gnus-save-all-headers t
393 "*If non-nil, don't remove any headers before saving."
394 :group 'gnus-article-saving
397 (defcustom gnus-prompt-before-saving 'always
398 "*This variable says how much prompting is to be done when saving articles.
399 If it is nil, no prompting will be done, and the articles will be
400 saved to the default files. If this variable is `always', each and
401 every article that is saved will be preceded by a prompt, even when
402 saving large batches of articles. If this variable is neither nil not
403 `always', there the user will be prompted once for a file name for
404 each invocation of the saving commands."
405 :group 'gnus-article-saving
406 :type '(choice (item always)
407 (item :tag "never" nil)
408 (sexp :tag "once" :format "%t\n" :value t)))
410 (defcustom gnus-saved-headers gnus-visible-headers
411 "Headers to keep if `gnus-save-all-headers' is nil.
412 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
413 If that variable is nil, however, all headers that match this regexp
414 will be kept while the rest will be deleted before saving."
415 :group 'gnus-article-saving
418 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
419 "A function to save articles in your favourite format.
420 The function must be interactively callable (in other words, it must
421 be an Emacs command).
423 Gnus provides the following functions:
425 * gnus-summary-save-in-rmail (Rmail format)
426 * gnus-summary-save-in-mail (Unix mail format)
427 * gnus-summary-save-in-folder (MH folder)
428 * gnus-summary-save-in-file (article format)
429 * gnus-summary-save-in-vm (use VM's folder format)
430 * gnus-summary-write-to-file (article format -- overwrite)."
431 :group 'gnus-article-saving
432 :type '(radio (function-item gnus-summary-save-in-rmail)
433 (function-item gnus-summary-save-in-mail)
434 (function-item gnus-summary-save-in-folder)
435 (function-item gnus-summary-save-in-file)
436 (function-item gnus-summary-save-in-vm)
437 (function-item gnus-summary-write-to-file)))
439 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
440 "A function generating a file name to save articles in Rmail format.
441 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
442 :group 'gnus-article-saving
445 (defcustom gnus-mail-save-name 'gnus-plain-save-name
446 "A function generating a file name to save articles in Unix mail format.
447 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
448 :group 'gnus-article-saving
451 (defcustom gnus-folder-save-name 'gnus-folder-save-name
452 "A function generating a file name to save articles in MH folder.
453 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
454 :group 'gnus-article-saving
457 (defcustom gnus-file-save-name 'gnus-numeric-save-name
458 "A function generating a file name to save articles in article format.
459 The function is called with NEWSGROUP, HEADERS, and optional
461 :group 'gnus-article-saving
464 (defcustom gnus-split-methods
465 '((gnus-article-archive-name)
466 (gnus-article-nndoc-name))
467 "*Variable used to suggest where articles are to be saved.
468 For instance, if you would like to save articles related to Gnus in
469 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
470 you could set this variable to something like:
472 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
473 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
475 This variable is an alist where the where the key is the match and the
476 value is a list of possible files to save in if the match is non-nil.
478 If the match is a string, it is used as a regexp match on the
479 article. If the match is a symbol, that symbol will be funcalled
480 from the buffer of the article to be saved with the newsgroup as the
481 parameter. If it is a list, it will be evaled in the same buffer.
483 If this form or function returns a string, this string will be used as
484 a possible file name; and if it returns a non-nil list, that list will
485 be used as possible file names."
486 :group 'gnus-article-saving
487 :type '(repeat (choice (list :value (fun) function)
488 (cons :value ("" "") regexp (repeat string))
491 (defcustom gnus-article-display-method-for-mime
492 'gnus-article-display-mime-message
493 "Function to display a MIME message.
494 The function is called from the article buffer."
495 :group 'gnus-article-mime
498 (defcustom gnus-article-display-method-for-traditional
499 'gnus-article-display-traditional-message
500 "*Function to display a traditional message.
501 The function is called from the article buffer."
502 :group 'gnus-article-mime
505 (defcustom gnus-page-delimiter "^\^L"
506 "*Regexp describing what to use as article page delimiters.
507 The default value is \"^\^L\", which is a form linefeed at the
508 beginning of a line."
510 :group 'gnus-article-various)
512 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
513 "*The format specification for the article mode line.
514 See `gnus-summary-mode-line-format' for a closer description.
516 The following additional specs are available:
518 %w The article washing status.
519 %m The number of MIME parts in the article."
521 :group 'gnus-article-various)
523 (defcustom gnus-article-mode-hook nil
524 "*A hook for Gnus article mode."
526 :group 'gnus-article-various)
528 (when (featurep 'xemacs)
529 ;; Extracted from gnus-xmas-define in order to preserve user settings
530 (when (fboundp 'turn-off-scroll-in-place)
531 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
532 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
533 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
535 (defcustom gnus-article-menu-hook nil
536 "*Hook run after the creation of the article mode menu."
538 :group 'gnus-article-various)
540 (defcustom gnus-article-prepare-hook nil
541 "*A hook called after an article has been prepared in the article buffer."
543 :group 'gnus-article-various)
545 (defcustom gnus-article-hide-pgp-hook nil
546 "*A hook called after successfully hiding a PGP signature."
548 :group 'gnus-article-various)
550 (defcustom gnus-article-button-face 'bold
551 "Face used for highlighting buttons in the article buffer.
553 An article button is a piece of text that you can activate by pressing
554 `RET' or `mouse-2' above it."
556 :group 'gnus-article-buttons)
558 (defcustom gnus-article-mouse-face 'highlight
559 "Face used for mouse highlighting in the article buffer.
561 Article buttons will be displayed in this face when the cursor is
564 :group 'gnus-article-buttons)
566 (defcustom gnus-signature-face 'gnus-signature-face
567 "Face used for highlighting a signature in the article buffer.
568 Obsolete; use the face `gnus-signature-face' for customizations instead."
570 :group 'gnus-article-highlight
571 :group 'gnus-article-signature)
573 (defface gnus-signature-face
576 "Face used for highlighting a signature in the article buffer."
577 :group 'gnus-article-highlight
578 :group 'gnus-article-signature)
580 (defface gnus-header-from-face
583 (:foreground "spring green"))
586 (:foreground "red3"))
589 "Face used for displaying from headers."
590 :group 'gnus-article-headers
591 :group 'gnus-article-highlight)
593 (defface gnus-header-subject-face
596 (:foreground "SeaGreen3"))
599 (:foreground "red4"))
601 (:bold t :italic t)))
602 "Face used for displaying subject headers."
603 :group 'gnus-article-headers
604 :group 'gnus-article-highlight)
606 (defface gnus-header-newsgroups-face
609 (:foreground "yellow" :italic t))
612 (:foreground "MidnightBlue" :italic t))
615 "Face used for displaying newsgroups headers."
616 :group 'gnus-article-headers
617 :group 'gnus-article-highlight)
619 (defface gnus-header-name-face
622 (:foreground "SeaGreen"))
625 (:foreground "maroon"))
628 "Face used for displaying header names."
629 :group 'gnus-article-headers
630 :group 'gnus-article-highlight)
632 (defface gnus-header-content-face
635 (:foreground "forest green" :italic t))
638 (:foreground "indianred4" :italic t))
641 "Face used for displaying header content."
642 :group 'gnus-article-headers
643 :group 'gnus-article-highlight)
645 (defcustom gnus-header-face-alist
646 '(("From" nil gnus-header-from-face)
647 ("Subject" nil gnus-header-subject-face)
648 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
649 ("" gnus-header-name-face gnus-header-content-face))
650 "*Controls highlighting of article header.
652 An alist of the form (HEADER NAME CONTENT).
654 HEADER is a regular expression which should match the name of an
655 header header and NAME and CONTENT are either face names or nil.
657 The name of each header field will be displayed using the face
658 specified by the first element in the list where HEADER match the
659 header name and NAME is non-nil. Similarly, the content will be
660 displayed by the first non-nil matching CONTENT face."
661 :group 'gnus-article-headers
662 :group 'gnus-article-highlight
663 :type '(repeat (list (regexp :tag "Header")
665 (item :tag "skip" nil)
666 (face :value default))
667 (choice :tag "Content"
668 (item :tag "skip" nil)
669 (face :value default)))))
671 (defcustom gnus-article-decode-hook nil
672 "*Hook run to decode charsets in articles."
673 :group 'gnus-article-headers
676 (defcustom gnus-display-mime-function 'gnus-display-mime
677 "Function to display MIME articles."
678 :group 'gnus-article-mime
681 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
682 "Function used to decode headers.")
684 (defvar gnus-article-dumbquotes-map
703 "Table for MS-to-Latin1 translation.")
705 (defcustom gnus-ignored-mime-types nil
706 "List of MIME types that should be ignored by Gnus."
708 :group 'gnus-article-mime
709 :type '(repeat regexp))
711 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
712 "List of MIME types that should not be given buttons when rendered inline."
714 :group 'gnus-article-mime
715 :type '(repeat regexp))
717 (defcustom gnus-article-mime-part-function nil
718 "Function called with a MIME handle as the argument.
719 This is meant for people who want to do something automatic based
720 on parts -- for instance, adding Vcard info to a database."
721 :group 'gnus-article-mime
724 (defcustom gnus-mime-multipart-functions nil
725 "An alist of MIME types to functions to display them."
727 :group 'gnus-article-mime
730 (defcustom gnus-article-date-lapsed-new-header nil
731 "Whether the X-Sent and Date headers can coexist.
732 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
733 either replace the old \"Date:\" header (if this variable is nil), or
734 be added below it (otherwise)."
736 :group 'gnus-article-headers
739 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
740 "Function called with a MIME handle as the argument.
741 This is meant for people who want to view first matched part.
742 For `undisplayed-alternative' (default), the first undisplayed
743 part or alternative part is used. For `undisplayed', the first
744 undisplayed part is used. For a function, the first part which
745 the function return `t' is used. For `nil', the first part is
748 :group 'gnus-article-mime
750 (item :tag "first" :value nil)
751 (item :tag "undisplayed" :value undisplayed)
752 (item :tag "undisplayed or alternative"
753 :value undisplayed-alternative)
756 (defcustom gnus-mime-action-alist
757 '(("save to file" . gnus-mime-save-part)
758 ("save and strip" . gnus-mime-save-part-and-strip)
759 ("display as text" . gnus-mime-inline-part)
760 ("view the part" . gnus-mime-view-part)
761 ("pipe to command" . gnus-mime-pipe-part)
762 ("toggle display" . gnus-article-press-button)
763 ("toggle display" . gnus-article-view-part-as-charset)
764 ("view as type" . gnus-mime-view-part-as-type)
765 ("internalize type" . gnus-mime-internalize-part)
766 ("externalize type" . gnus-mime-externalize-part))
767 "An alist of actions that run on the MIME attachment."
768 :group 'gnus-article-mime
769 :type '(repeat (cons (string :tag "name")
772 (defcustom gnus-mime-action-alist
773 '(("save to file" . gnus-mime-save-part)
774 ("display as text" . gnus-mime-inline-part)
775 ("view the part" . gnus-mime-view-part)
776 ("pipe to command" . gnus-mime-pipe-part)
777 ("toggle display" . gnus-article-press-button)
778 ("view as type" . gnus-mime-view-part-as-type)
779 ("internalize type" . gnus-mime-internalize-part)
780 ("externalize type" . gnus-mime-externalize-part))
781 "An alist of actions that run on the MIME attachment."
783 :group 'gnus-article-mime
784 :type '(repeat (cons (string :tag "name")
788 ;;; The treatment variables
791 (defvar gnus-part-display-hook nil
792 "Hook called on parts that are to receive treatment.")
794 (defvar gnus-article-treat-custom
795 '(choice (const :tag "Off" nil)
797 (const :tag "Header" head)
798 (const :tag "Last" last)
799 (const :tag "Mime" mime)
800 (integer :tag "Less")
801 (repeat :tag "Groups" regexp)
802 (sexp :tag "Predicate")))
804 (defvar gnus-article-treat-head-custom
805 '(choice (const :tag "Off" nil)
806 (const :tag "Header" head)))
808 (defvar gnus-article-treat-types '("text/plain")
811 (defvar gnus-inhibit-treatment nil
812 "Whether to inhibit treatment.")
814 (defcustom gnus-treat-highlight-signature '(or last (typep "text/x-vcard"))
815 "Highlight the signature.
816 Valid values are nil, t, `head', `last', an integer or a predicate.
817 See the manual for details."
818 :group 'gnus-article-treat
819 :type gnus-article-treat-custom)
820 (put 'gnus-treat-highlight-signature 'highlight t)
822 (defcustom gnus-treat-buttonize 100000
824 Valid values are nil, t, `head', `last', an integer or a predicate.
825 See the manual for details."
826 :group 'gnus-article-treat
827 :type gnus-article-treat-custom)
828 (put 'gnus-treat-buttonize 'highlight t)
830 (defcustom gnus-treat-buttonize-head 'head
831 "Add buttons to the head.
832 Valid values are nil, t, `head', `last', an integer or a predicate.
833 See the manual for details."
834 :group 'gnus-article-treat
835 :type gnus-article-treat-head-custom)
836 (put 'gnus-treat-buttonize-head 'highlight t)
838 (defcustom gnus-treat-emphasize
839 (and (or window-system
841 (>= (string-to-number emacs-version) 21))
844 Valid values are nil, t, `head', `last', an integer or a predicate.
845 See the manual for details."
846 :group 'gnus-article-treat
847 :type gnus-article-treat-custom)
848 (put 'gnus-treat-emphasize 'highlight t)
850 (defcustom gnus-treat-strip-cr nil
851 "Remove carriage returns.
852 Valid values are nil, t, `head', `last', an integer or a predicate.
853 See the manual for details."
854 :group 'gnus-article-treat
855 :type gnus-article-treat-custom)
857 (defcustom gnus-treat-leading-whitespace nil
858 "Remove leading whitespace in headers.
859 Valid values are nil, t, `head', `last', an integer or a predicate.
860 See the manual for details."
861 :group 'gnus-article-treat
862 :type gnus-article-treat-custom)
864 (defcustom gnus-treat-hide-headers 'head
866 Valid values are nil, t, `head', `last', an integer or a predicate.
867 See the manual for details."
868 :group 'gnus-article-treat
869 :type gnus-article-treat-head-custom)
871 (defcustom gnus-treat-hide-boring-headers nil
872 "Hide boring headers.
873 Valid values are nil, t, `head', `last', an integer or a predicate.
874 See the manual for details."
875 :group 'gnus-article-treat
876 :type gnus-article-treat-head-custom)
878 (defcustom gnus-treat-hide-signature nil
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-custom)
885 (defcustom gnus-treat-fill-article nil
887 Valid values are nil, t, `head', `last', an integer or a predicate.
888 See the manual for details."
889 :group 'gnus-article-treat
890 :type gnus-article-treat-custom)
892 (defcustom gnus-treat-hide-citation nil
894 Valid values are nil, t, `head', `last', an integer or a predicate.
895 See the manual for details."
896 :group 'gnus-article-treat
897 :type gnus-article-treat-custom)
899 (defcustom gnus-treat-hide-citation-maybe nil
901 Valid values are nil, t, `head', `last', an integer or a predicate.
902 See the manual for details."
903 :group 'gnus-article-treat
904 :type gnus-article-treat-custom)
906 (defcustom gnus-treat-hide-citation-maybe nil
908 Valid values are nil, t, `head', `last', an integer or a predicate.
909 See the manual for details."
910 :group 'gnus-article-treat
911 :type gnus-article-treat-custom)
913 (defcustom gnus-treat-strip-list-identifiers 'head
914 "Strip list identifiers from `gnus-list-identifiers`.
915 Valid values are nil, t, `head', `last', an integer or a predicate.
916 See the manual for details."
918 :group 'gnus-article-treat
919 :type gnus-article-treat-custom)
921 (defcustom gnus-treat-strip-pgp t
922 "Strip PGP signatures.
923 Valid values are nil, t, `head', `last', an integer or a predicate.
924 See the manual for details."
925 :group 'gnus-article-treat
926 :type gnus-article-treat-custom)
928 (defcustom gnus-treat-strip-pem nil
929 "Strip PEM signatures.
930 Valid values are nil, t, `head', `last', an integer or a predicate.
931 See the manual for details."
932 :group 'gnus-article-treat
933 :type gnus-article-treat-custom)
935 (defcustom gnus-treat-strip-banner t
936 "Strip banners from articles.
937 The banner to be stripped is specified in the `banner' group parameter.
938 Valid values are nil, t, `head', `last', an integer or a predicate.
939 See the manual for details."
940 :group 'gnus-article-treat
941 :type gnus-article-treat-custom)
943 (defcustom gnus-treat-highlight-headers 'head
944 "Highlight the headers.
945 Valid values are nil, t, `head', `last', an integer or a predicate.
946 See the manual for details."
947 :group 'gnus-article-treat
948 :type gnus-article-treat-head-custom)
949 (put 'gnus-treat-highlight-headers 'highlight t)
951 (defcustom gnus-treat-highlight-citation t
952 "Highlight cited text.
953 Valid values are nil, t, `head', `last', an integer or a predicate.
954 See the manual for details."
955 :group 'gnus-article-treat
956 :type gnus-article-treat-custom)
957 (put 'gnus-treat-highlight-citation 'highlight t)
959 (defcustom gnus-treat-date-ut nil
960 "Display the Date in UT (GMT).
961 Valid values are nil, t, `head', `last', an integer or a predicate.
962 See the manual for details."
963 :group 'gnus-article-treat
964 :type gnus-article-treat-head-custom)
966 (defcustom gnus-treat-date-local nil
967 "Display the Date in the local timezone.
968 Valid values are nil, t, `head', `last', an integer or a predicate.
969 See the manual for details."
970 :group 'gnus-article-treat
971 :type gnus-article-treat-head-custom)
973 (defcustom gnus-treat-date-english nil
974 "Display the Date in a format that can be read aloud in English.
975 Valid values are nil, t, `head', `last', an integer or a predicate.
976 See the manual for details."
977 :group 'gnus-article-treat
978 :type gnus-article-treat-head-custom)
980 (defcustom gnus-treat-date-lapsed nil
981 "Display the Date header in a way that says how much time has elapsed.
982 Valid values are nil, t, `head', `last', an integer or a predicate.
983 See the manual for details."
984 :group 'gnus-article-treat
985 :type gnus-article-treat-head-custom)
987 (defcustom gnus-treat-date-original nil
988 "Display the date in the original timezone.
989 Valid values are nil, t, `head', `last', an integer or a predicate.
990 See the manual for details."
991 :group 'gnus-article-treat
992 :type gnus-article-treat-head-custom)
994 (defcustom gnus-treat-date-iso8601 nil
995 "Display the date in the ISO8601 format.
996 Valid values are nil, t, `head', `last', an integer or a predicate.
997 See the manual for details."
999 :group 'gnus-article-treat
1000 :type gnus-article-treat-head-custom)
1002 (defcustom gnus-treat-date-user-defined nil
1003 "Display the date in a user-defined format.
1004 The format is defined by the `gnus-article-time-format' variable.
1005 Valid values are nil, t, `head', `last', an integer or a predicate.
1006 See the manual for details."
1007 :group 'gnus-article-treat
1008 :type gnus-article-treat-head-custom)
1010 (defcustom gnus-treat-strip-headers-in-body t
1011 "Strip the X-No-Archive header line from the beginning of the body.
1012 Valid values are nil, t, `head', `last', an integer or a predicate.
1013 See the manual for details."
1015 :group 'gnus-article-treat
1016 :type gnus-article-treat-custom)
1018 (defcustom gnus-treat-strip-trailing-blank-lines nil
1019 "Strip trailing blank lines.
1020 Valid values are nil, t, `head', `last', an integer or a predicate.
1021 See the manual for details."
1022 :group 'gnus-article-treat
1023 :type gnus-article-treat-custom)
1025 (defcustom gnus-treat-strip-leading-blank-lines nil
1026 "Strip leading blank lines.
1027 Valid values are nil, t, `head', `last', an integer or a predicate.
1028 See the manual for details."
1029 :group 'gnus-article-treat
1030 :type gnus-article-treat-custom)
1032 (defcustom gnus-treat-strip-multiple-blank-lines nil
1033 "Strip multiple blank lines.
1034 Valid values are nil, t, `head', `last', an integer or a predicate.
1035 See the manual for details."
1036 :group 'gnus-article-treat
1037 :type gnus-article-treat-custom)
1039 (defcustom gnus-treat-overstrike t
1040 "Treat overstrike highlighting.
1041 Valid values are nil, t, `head', `last', an integer or a predicate.
1042 See the manual for details."
1043 :group 'gnus-article-treat
1044 :type gnus-article-treat-custom)
1045 (put 'gnus-treat-overstrike 'highlight t)
1047 (defcustom gnus-treat-display-xface
1048 (and (or (and (fboundp 'image-type-available-p)
1049 (image-type-available-p 'xbm)
1050 (string-match "^0x" (shell-command-to-string "uncompface")))
1051 (and (featurep 'xemacs) (featurep 'xface))
1052 (eq 'x-face-mule-gnus-article-display-x-face
1053 gnus-article-x-face-command))
1055 "Display X-Face headers.
1056 Valid values are nil, t, `head', `last', an integer or a predicate.
1057 See the manual for details."
1058 :group 'gnus-article-treat
1060 :type gnus-article-treat-head-custom)
1061 (put 'gnus-treat-display-xface 'highlight t)
1063 (defcustom gnus-treat-display-smileys
1064 (if (or (and (featurep 'xemacs)
1066 (and (fboundp 'image-type-available-p)
1067 (image-type-available-p 'pbm))
1068 (and (not (featurep 'xemacs))
1070 (module-installed-p 'smiley-mule)))
1074 Valid values are nil, t, `head', `last', an integer or a predicate.
1075 See the manual for details."
1076 :group 'gnus-article-treat
1078 :type gnus-article-treat-custom)
1079 (put 'gnus-treat-display-smileys 'highlight t)
1081 (defcustom gnus-treat-display-picons (if (featurep 'xemacs) 'head nil)
1083 Valid values are nil, t, `head', `last', an integer or a predicate.
1084 See the manual for details."
1085 :group 'gnus-article-treat
1086 :type gnus-article-treat-head-custom)
1087 (put 'gnus-treat-display-picons 'highlight t)
1089 (defcustom gnus-treat-capitalize-sentences nil
1090 "Capitalize sentence-starting words.
1091 Valid values are nil, t, `head', `last', an integer or a predicate.
1092 See the manual for details."
1094 :group 'gnus-article-treat
1095 :type gnus-article-treat-custom)
1097 (defcustom gnus-treat-fill-long-lines nil
1099 Valid values are nil, t, `head', `last', an integer or a predicate.
1100 See the manual for details."
1101 :group 'gnus-article-treat
1102 :type gnus-article-treat-custom)
1104 (defcustom gnus-treat-play-sounds nil
1106 Valid values are nil, t, `head', `last', an integer or a predicate.
1107 See the manual for details."
1109 :group 'gnus-article-treat
1110 :type gnus-article-treat-custom)
1112 (defcustom gnus-treat-decode-article-as-default-mime-charset nil
1113 "Decode an article as `default-mime-charset'. For instance, if you want to
1114 attempt to decode an article even if the value of `gnus-show-mime' is nil,
1115 you could set this variable to something like: nil for don't decode, t for
1116 decode the body, '(or header t) for the whole article, etc."
1117 :group 'gnus-article-treat
1118 :type '(radio (const :tag "Off" nil)
1119 (const :tag "Decode body" t)
1120 (const :tag "Decode all" (or head t))))
1122 (defcustom gnus-treat-translate nil
1123 "Translate articles from one language to another.
1124 Valid values are nil, t, `head', `last', an integer or a predicate.
1125 See the manual for details."
1127 :group 'gnus-article-treat
1128 :type gnus-article-treat-custom)
1130 (defcustom gnus-treat-x-pgp-sig nil
1132 To automatically treat X-PGP-Sig, set it to head.
1133 Valid values are nil, t, `head', `last', an integer or a predicate.
1134 See the manual for details."
1135 :group 'gnus-article-treat
1136 :group 'mime-security
1137 :type gnus-article-treat-custom)
1139 (defvar gnus-article-encrypt-protocol-alist
1140 '(("PGP" . mml2015-self-encrypt)))
1142 ;; Set to nil if more than one protocol added to
1143 ;; gnus-article-encrypt-protocol-alist.
1144 (defcustom gnus-article-encrypt-protocol "PGP"
1145 "The protocol used for encrypt articles.
1146 It is a string, such as \"PGP\". If nil, ask user."
1148 :group 'mime-security)
1150 ;;; Internal variables
1152 (defvar gnus-english-month-names
1153 '("January" "February" "March" "April" "May" "June" "July" "August"
1154 "September" "October" "November" "December"))
1156 (defvar article-goto-body-goes-to-point-min-p nil)
1157 (defvar gnus-article-wash-types nil)
1158 (defvar gnus-article-emphasis-alist nil)
1160 (defvar gnus-article-mime-handle-alist-1 nil)
1161 (defvar gnus-treatment-function-alist
1162 `((gnus-treat-decode-article-as-default-mime-charset
1163 gnus-article-decode-article-as-default-mime-charset)
1164 (gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1165 (gnus-treat-strip-banner gnus-article-strip-banner)
1166 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1167 (gnus-treat-buttonize gnus-article-add-buttons)
1168 (gnus-treat-fill-article gnus-article-fill-cited-article)
1169 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1170 (gnus-treat-strip-cr gnus-article-remove-cr)
1171 (gnus-treat-display-xface gnus-article-display-x-face)
1172 (gnus-treat-date-ut gnus-article-date-ut)
1173 (gnus-treat-date-local gnus-article-date-local)
1174 (gnus-treat-date-english gnus-article-date-english)
1175 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1176 (gnus-treat-date-original gnus-article-date-original)
1177 (gnus-treat-date-user-defined gnus-article-date-user)
1178 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1179 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1180 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1181 (gnus-treat-hide-signature gnus-article-hide-signature)
1182 (gnus-treat-hide-citation gnus-article-hide-citation)
1183 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1184 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1185 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1186 (gnus-treat-strip-pgp gnus-article-hide-pgp)
1187 (gnus-treat-strip-pem gnus-article-hide-pem)
1188 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1189 (gnus-treat-emphasize gnus-article-emphasize)
1190 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1191 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1192 (gnus-treat-strip-trailing-blank-lines
1193 gnus-article-remove-trailing-blank-lines)
1194 (gnus-treat-strip-leading-blank-lines
1195 gnus-article-strip-leading-blank-lines)
1196 (gnus-treat-strip-multiple-blank-lines
1197 gnus-article-strip-multiple-blank-lines)
1198 (gnus-treat-overstrike gnus-article-treat-overstrike)
1199 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1200 (gnus-treat-display-smileys ,(if (or (featurep 'xemacs)
1201 (>= emacs-major-version 21))
1202 'gnus-smiley-display
1203 'gnus-article-smiley-display))
1204 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1205 (gnus-treat-display-picons gnus-article-display-picons)
1206 (gnus-treat-play-sounds gnus-earcon-display)))
1208 (defvar gnus-article-mime-handle-alist nil)
1209 (defvar article-lapsed-timer nil)
1210 (defvar gnus-article-current-summary nil)
1212 (defvar gnus-article-mode-syntax-table
1213 (let ((table (copy-syntax-table text-mode-syntax-table)))
1214 ;; This causes the citation match run O(2^n).
1215 ;; (modify-syntax-entry ?- "w" table)
1216 (modify-syntax-entry ?> ")" table)
1217 (modify-syntax-entry ?< "(" table)
1219 "Syntax table used in article mode buffers.
1220 Initialized from `text-mode-syntax-table.")
1222 (defvar gnus-save-article-buffer nil)
1224 (defvar gnus-article-mode-line-format-alist
1225 (nconc '((?w (gnus-article-wash-status) ?s)
1226 (?m (gnus-article-mime-part-status) ?s))
1227 gnus-summary-mode-line-format-alist))
1229 (defvar gnus-number-of-articles-to-be-saved nil)
1231 (defvar gnus-inhibit-hiding nil)
1233 (defsubst gnus-article-hide-text (b e props)
1234 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1235 (gnus-add-text-properties-when 'article-type nil b e props)
1236 (when (memq 'intangible props)
1238 (max (1- b) (point-min))
1239 b 'intangible (cddr (memq 'intangible props)))))
1241 (defsubst gnus-article-unhide-text (b e)
1242 "Remove hidden text properties from region between B and E."
1243 (remove-text-properties b e gnus-hidden-properties)
1244 (when (memq 'intangible gnus-hidden-properties)
1245 (put-text-property (max (1- b) (point-min))
1246 b 'intangible nil)))
1248 (defun gnus-article-hide-text-type (b e type)
1249 "Hide text of TYPE between B and E."
1250 (push type gnus-article-wash-types)
1251 (gnus-article-hide-text
1252 b e (cons 'article-type (cons type gnus-hidden-properties))))
1254 (defun gnus-article-unhide-text-type (b e type)
1255 "Unhide text of TYPE between B and E."
1256 (setq gnus-article-wash-types
1257 (delq type gnus-article-wash-types))
1258 (remove-text-properties
1259 b e (cons 'article-type (cons type gnus-hidden-properties)))
1260 (when (memq 'intangible gnus-hidden-properties)
1261 (put-text-property (max (1- b) (point-min))
1262 b 'intangible nil)))
1264 (defun gnus-article-hide-text-of-type (type)
1265 "Hide text of TYPE in the current buffer."
1267 (let ((b (point-min))
1269 (while (setq b (text-property-any b e 'article-type type))
1270 (add-text-properties b (incf b) gnus-hidden-properties)))))
1272 (defun gnus-article-delete-text-of-type (type)
1273 "Delete text of TYPE in the current buffer."
1275 (let ((b (point-min)))
1276 (while (setq b (text-property-any b (point-max) 'article-type type))
1278 b (or (text-property-not-all b (point-max) 'article-type type)
1281 (defun gnus-article-delete-invisible-text ()
1282 "Delete all invisible text in the current buffer."
1284 (let ((b (point-min)))
1285 (while (setq b (text-property-any b (point-max) 'invisible t))
1287 b (or (text-property-not-all b (point-max) 'invisible t)
1290 (defun gnus-article-text-type-exists-p (type)
1291 "Say whether any text of type TYPE exists in the buffer."
1292 (text-property-any (point-min) (point-max) 'article-type type))
1294 (defsubst gnus-article-header-rank ()
1295 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1296 (let ((list gnus-sorted-header-list)
1299 (when (looking-at (car list))
1301 (setq list (cdr list))
1305 (defun article-hide-headers (&optional arg delete)
1306 "Hide unwanted headers and possibly sort them as well."
1307 (interactive (gnus-article-hidden-arg))
1308 ;; Lars said that this function might be inhibited.
1309 (if (gnus-article-check-hidden-text 'headers arg)
1311 ;; Show boring headers as well.
1312 (gnus-article-show-hidden-text 'boring-headers)
1313 (when (eq 1 (point-min))
1314 (set-window-start (get-buffer-window (current-buffer)) 1)))
1315 (unless gnus-inhibit-hiding
1318 (let ((inhibit-read-only t)
1319 (case-fold-search t)
1320 (max (1+ (length gnus-sorted-header-list)))
1321 (ignored (when (not gnus-visible-headers)
1322 (cond ((stringp gnus-ignored-headers)
1323 gnus-ignored-headers)
1324 ((listp gnus-ignored-headers)
1325 (mapconcat 'identity gnus-ignored-headers
1328 (cond ((stringp gnus-visible-headers)
1329 gnus-visible-headers)
1330 ((and gnus-visible-headers
1331 (listp gnus-visible-headers))
1332 (mapconcat 'identity gnus-visible-headers "\\|"))))
1333 (inhibit-point-motion-hooks t)
1335 ;; First we narrow to just the headers.
1336 (article-narrow-to-head)
1337 ;; Hide any "From " lines at the beginning of (mail) articles.
1338 (while (looking-at "From ")
1342 (delete-region (point-min) (point))
1343 (gnus-article-hide-text (point-min) (point)
1344 (nconc (list 'article-type 'headers)
1345 gnus-hidden-properties))))
1346 ;; Then treat the rest of the header lines.
1347 ;; Then we use the two regular expressions
1348 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1349 ;; select which header lines is to remain visible in the
1351 (while (re-search-forward "^[^ \t:]*:" nil t)
1353 ;; Mark the rank of the header.
1355 (point) (1+ (point)) 'message-rank
1356 (if (or (and visible (looking-at visible))
1358 (not (looking-at ignored))))
1359 (gnus-article-header-rank)
1362 (message-sort-headers-1)
1363 (when (setq beg (text-property-any
1364 (point-min) (point-max) 'message-rank (+ 2 max)))
1365 ;; We delete or make invisible the unwanted headers.
1366 (push 'headers gnus-article-wash-types)
1369 (add-text-properties
1370 (point-min) (+ 5 (point-min))
1371 '(article-type headers dummy-invisible t))
1372 (delete-region beg (point-max)))
1373 (gnus-article-hide-text-type beg (point-max) 'headers))))))))
1376 (defun article-hide-boring-headers (&optional arg)
1377 "Toggle hiding of headers that aren't very interesting.
1378 If given a negative prefix, always show; if given a positive prefix,
1380 (interactive (gnus-article-hidden-arg))
1381 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1382 (not gnus-show-all-headers))
1385 (let ((buffer-read-only nil)
1386 (list gnus-boring-article-headers)
1387 (inhibit-point-motion-hooks t)
1389 (article-narrow-to-head)
1391 (setq elem (pop list))
1392 (goto-char (point-min))
1394 ;; Hide empty headers.
1396 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1398 (gnus-article-hide-text-type
1399 (progn (beginning-of-line) (point))
1402 (if (re-search-forward "^[^ \t]" nil t)
1406 ;; Hide boring Newsgroups header.
1407 ((eq elem 'newsgroups)
1408 (when (gnus-string-equal
1409 (gnus-fetch-field "newsgroups")
1410 (gnus-group-real-name
1411 (if (boundp 'gnus-newsgroup-name)
1414 (gnus-article-hide-header "newsgroups")))
1415 ((eq elem 'to-address)
1416 (let ((to (message-fetch-field "to"))
1418 (gnus-parameter-to-address
1419 (if (boundp 'gnus-newsgroup-name)
1420 gnus-newsgroup-name ""))))
1421 (when (and to to-address
1424 ;; only one address in To
1425 (nth 1 (mail-extract-address-components to))
1427 (gnus-article-hide-header "to"))))
1428 ((eq elem 'followup-to)
1429 (when (gnus-string-equal
1430 (message-fetch-field "followup-to")
1431 (message-fetch-field "newsgroups"))
1432 (gnus-article-hide-header "followup-to")))
1433 ((eq elem 'reply-to)
1434 (let ((from (message-fetch-field "from"))
1435 (reply-to (message-fetch-field "reply-to")))
1440 (nth 1 (mail-extract-address-components from))
1441 (nth 1 (mail-extract-address-components reply-to)))))
1442 (gnus-article-hide-header "reply-to"))))
1444 (let ((date (message-fetch-field "date")))
1446 (< (days-between (current-time-string) date)
1448 (gnus-article-hide-header "date"))))
1450 (let ((to (message-fetch-field "to"))
1451 (cc (message-fetch-field "cc")))
1452 (when (> (length to) 1024)
1453 (gnus-article-hide-header "to"))
1454 (when (> (length cc) 1024)
1455 (gnus-article-hide-header "cc"))))
1459 (goto-char (point-min))
1460 (while (re-search-forward "^to:" nil t)
1461 (setq to-count (1+ to-count)))
1462 (when (> to-count 1)
1463 (while (> to-count 0)
1464 (goto-char (point-min))
1466 (re-search-forward "^to:" nil nil to-count)
1468 (narrow-to-region (point) (point-max))
1469 (gnus-article-hide-header "to"))
1470 (setq to-count (1- to-count))))
1471 (goto-char (point-min))
1472 (while (re-search-forward "^cc:" nil t)
1473 (setq cc-count (1+ cc-count)))
1474 (when (> cc-count 1)
1475 (while (> cc-count 0)
1476 (goto-char (point-min))
1478 (re-search-forward "^cc:" nil nil cc-count)
1480 (narrow-to-region (point) (point-max))
1481 (gnus-article-hide-header "cc"))
1482 (setq cc-count (1- cc-count)))))))))))))
1484 (defun gnus-article-hide-header (header)
1486 (goto-char (point-min))
1487 (when (re-search-forward (concat "^" header ":") nil t)
1488 (gnus-article-hide-text-type
1489 (progn (beginning-of-line) (point))
1492 (if (re-search-forward "^[^ \t]" nil t)
1497 (defun article-toggle-headers (&optional arg)
1498 "Toggle hiding of headers. If given a negative prefix, always show;
1499 if given a positive prefix, always hide."
1500 (interactive (gnus-article-hidden-arg))
1501 (let ((force (when (numberp arg)
1502 (cond ((> arg 0) 'always-hide)
1503 ((< arg 0) 'always-show))))
1504 (window (get-buffer-window gnus-article-buffer))
1505 (header-end (point-min))
1506 header-start field-end field-start
1507 (inhibit-point-motion-hooks t)
1508 (inhibit-read-only t))
1511 (while (and (setq header-start
1512 (text-property-any header-end (point-max)
1513 'article-treated-header t))
1515 (text-property-not-all header-start (point-max)
1516 'article-treated-header t)))
1517 (setq field-end header-start)
1519 (;; Hide exposed invisible fields.
1520 (and (not (eq 'always-show force))
1522 (text-property-any field-end header-end
1523 'exposed-invisible-field t)))
1524 (while (and field-start
1525 (setq field-end (text-property-not-all
1526 field-start header-end
1527 'exposed-invisible-field t)))
1528 (add-text-properties field-start field-end gnus-hidden-properties)
1529 (setq field-start (text-property-any field-end header-end
1530 'exposed-invisible-field t)))
1531 (put-text-property header-start header-end
1532 'exposed-invisible-field nil))
1533 (;; Expose invisible fields.
1534 (and (not (eq 'always-hide force))
1536 (text-property-any field-end header-end 'invisible t)))
1537 (while (and field-start
1538 (setq field-end (text-property-not-all
1539 field-start header-end
1541 ;; If the invisible text is not terminated with newline, we
1542 ;; won't expose it. Because it may be created by x-face-mule.
1543 ;; BTW, XEmacs sometimes fail in putting a invisible text
1544 ;; property with `gnus-article-hide-text' (really?). In that
1545 ;; case, the invisible text might be started from the middle of
1546 ;; a line so we will expose the sort of thing.
1547 (when (or (not (or (eq header-start field-start)
1548 (eq ?\n (char-before field-start))))
1549 (eq ?\n (char-before field-end)))
1550 (remove-text-properties field-start field-end
1551 gnus-hidden-properties)
1552 (put-text-property field-start field-end
1553 'exposed-invisible-field t))
1554 (setq field-start (text-property-any field-end header-end
1557 (not (eq 'always-show force))
1558 (narrow-to-region header-start header-end)
1559 (article-hide-headers)
1560 ;; Re-display X-Face image under XEmacs.
1561 (when (and (featurep 'xemacs)
1562 (gnus-functionp gnus-article-x-face-command))
1563 (let ((func (cadr (assq 'gnus-treat-display-xface
1564 gnus-treatment-function-alist)))
1566 (when (and (not gnus-inhibit-treatment)
1568 (gnus-treat-predicate gnus-treat-display-xface))
1570 (put-text-property header-start header-end 'read-only nil))))
1573 (goto-char (point-min))
1575 (set-window-start window (point-min))))))
1577 (defvar gnus-article-normalized-header-length 40
1578 "Length of normalized headers.")
1580 (defun article-normalize-headers ()
1581 "Make all header lines 40 characters long."
1583 (let ((buffer-read-only nil)
1587 (article-narrow-to-head)
1590 ((< (setq column (- (gnus-point-at-eol) (point)))
1591 gnus-article-normalized-header-length)
1593 (insert (make-string
1594 (- gnus-article-normalized-header-length column)
1596 ((> column gnus-article-normalized-header-length)
1597 (gnus-put-text-property
1599 (forward-char gnus-article-normalized-header-length)
1606 (forward-line 1))))))
1608 (defun article-treat-dumbquotes ()
1609 "Translate M****s*** sm*rtq**t*s into proper text.
1610 Note that this function guesses whether a character is a sm*rtq**t* or
1611 not, so it should only be used interactively.
1613 Sm*rtq**t*s are M****s***'s unilateral extension to the character map
1614 in an attempt to provide more quoting characters. If you see
1615 something like \\222 or \\264 where you're expecting some kind of
1616 apostrophe or quotation mark, then try this wash."
1618 (article-translate-strings gnus-article-dumbquotes-map))
1620 (defun article-translate-characters (from to)
1621 "Translate all characters in the body of the article according to FROM and TO.
1622 FROM is a string of characters to translate from; to is a string of
1623 characters to translate to."
1625 (when (article-goto-body)
1626 (let ((buffer-read-only nil)
1627 (x (make-string 225 ?x))
1629 (while (< (incf i) (length x))
1632 (while (< i (length from))
1633 (aset x (aref from i) (aref to i))
1635 (translate-region (point) (point-max) x)))))
1637 (defun article-translate-strings (map)
1638 "Translate all string in the body of the article according to MAP.
1639 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1641 (when (article-goto-body)
1642 (let ((buffer-read-only nil)
1644 (while (setq elem (pop map))
1646 (while (search-forward (car elem) nil t)
1647 (replace-match (cadr elem)))))))))
1649 (defun article-treat-overstrike ()
1650 "Translate overstrikes into bold text."
1653 (when (article-goto-body)
1654 (let ((buffer-read-only nil))
1655 (while (search-forward "\b" nil t)
1656 (let ((next (char-after))
1660 previous (char-after))
1664 ;; We do the boldification/underlining by hiding the
1665 ;; overstrikes and putting the proper text property
1669 (gnus-article-hide-text-type start (point) 'overstrike)
1670 (put-text-property (point) end 'face 'bold))
1672 (gnus-article-hide-text-type
1673 (1- (point)) (1+ (point)) 'overstrike)
1675 start (1- (point)) 'face 'underline))
1677 (gnus-article-hide-text-type start (point) 'overstrike)
1679 (point) end 'face 'underline)))))))))
1681 (defun article-fill-long-lines ()
1682 "Fill lines that are wider than the window width."
1685 (let ((buffer-read-only nil)
1686 (width (window-width (get-buffer-window (current-buffer)))))
1689 (let ((adaptive-fill-mode nil)) ;Why? -sm
1692 (when (>= (current-column) (min fill-column width))
1693 (narrow-to-region (point) (gnus-point-at-bol))
1694 (fill-paragraph nil)
1695 (goto-char (point-max))
1697 (forward-line 1)))))))
1699 (defun article-capitalize-sentences ()
1700 "Capitalize the first word in each sentence."
1703 (let ((buffer-read-only nil)
1704 (paragraph-start "^[\n\^L]"))
1708 (forward-sentence)))))
1710 (defun article-remove-cr ()
1711 "Remove trailing CRs and then translate remaining CRs into LFs."
1714 (let ((buffer-read-only nil))
1715 (goto-char (point-min))
1716 (while (re-search-forward "\r+$" nil t)
1717 (replace-match "" t t))
1718 (goto-char (point-min))
1719 (while (search-forward "\r" nil t)
1720 (replace-match "\n" t t)))))
1722 (defun article-remove-trailing-blank-lines ()
1723 "Remove all trailing blank lines from the article."
1726 (let ((buffer-read-only nil))
1727 (goto-char (point-max))
1731 (while (and (not (bobp))
1732 (looking-at "^[ \t]*$")
1733 (not (gnus-annotation-in-region-p
1734 (point) (gnus-point-at-eol))))
1739 (defun article-display-x-face (&optional force)
1740 "Look for an X-Face header and display it if present."
1741 (interactive (list 'force))
1743 ;; Delete the old process, if any.
1744 (when (process-status "article-x-face")
1745 (delete-process "article-x-face"))
1746 (let ((inhibit-point-motion-hooks t)
1748 (case-fold-search t)
1751 (article-narrow-to-head)
1752 ;; (when (and buffer-read-only ;; When type `W f'
1754 ;; (goto-char (point-min))
1755 ;; (not (re-search-forward "^X-Face:[\t ]*" nil t)))
1756 ;; (gnus-buffer-live-p gnus-original-article-buffer))
1757 ;; (with-current-buffer gnus-original-article-buffer
1758 ;; (save-restriction
1759 ;; (article-narrow-to-head)
1760 ;; (while (re-search-forward "^X-Face:" nil t)
1764 ;; (buffer-substring
1765 ;; (match-beginning 0)
1766 ;; (1- (re-search-forward
1767 ;; "^\\($\\|[^ \t]\\)" nil t))))))))
1769 ;; (let (point start bface eface buffer-read-only)
1770 ;; (goto-char (point-max))
1771 ;; (forward-line -1)
1772 ;; (setq bface (get-text-property (gnus-point-at-bol) 'face)
1773 ;; eface (get-text-property (1- (gnus-point-at-eol)) 'face))
1774 ;; (goto-char (point-max))
1775 ;; (setq point (point))
1777 ;; (goto-char point)
1778 ;; (while (looking-at "\\([^:]+\\): *")
1779 ;; (put-text-property (match-beginning 1) (1+ (match-end 1))
1781 ;; (setq start (match-end 0))
1783 ;; (while (looking-at "[\t ]")
1784 ;; (forward-line 1))
1785 ;; (put-text-property start (point)
1787 (goto-char (point-min))
1788 (setq from (message-fetch-field "from"))
1789 (goto-char (point-min))
1790 (while (and gnus-article-x-face-command
1793 ;; Check whether this face is censored.
1794 (not gnus-article-x-face-too-ugly)
1795 (and gnus-article-x-face-too-ugly from
1796 (not (string-match gnus-article-x-face-too-ugly
1798 ;; Has to be present.
1799 (re-search-forward "^X-Face:[\t ]*" nil t))
1800 ;; This used to try to do multiple faces (`while' instead of
1801 ;; `when' above), but (a) sending multiple EOFs to xv doesn't
1802 ;; work (b) it can crash some versions of Emacs (c) are
1803 ;; multiple faces really something to encourage?
1804 (when (stringp gnus-article-x-face-command)
1806 ;; We now have the area of the buffer where the X-Face is stored.
1809 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
1810 ;; We display the face.
1811 (if (symbolp gnus-article-x-face-command)
1812 ;; The command is a lisp function, so we call it.
1813 (if (gnus-functionp gnus-article-x-face-command)
1814 (funcall gnus-article-x-face-command beg end)
1815 (error "%s is not a function" gnus-article-x-face-command))
1816 ;; The command is a string, so we interpret the command
1817 ;; as a, well, command, and fork it off.
1818 (let ((process-connection-type nil))
1819 (process-kill-without-query
1821 "article-x-face" nil shell-file-name shell-command-switch
1822 gnus-article-x-face-command))
1823 (process-send-region "article-x-face" beg end)
1824 (process-send-eof "article-x-face"))))))))))
1826 (defun article-decode-mime-words ()
1827 "Decode all MIME-encoded words in the article."
1830 (set-buffer gnus-article-buffer)
1831 (let ((inhibit-point-motion-hooks t)
1833 (mail-parse-charset gnus-newsgroup-charset)
1834 (mail-parse-ignored-charsets
1835 (save-excursion (set-buffer gnus-summary-buffer)
1836 gnus-newsgroup-ignored-charsets)))
1837 (mail-decode-encoded-word-region (point-min) (point-max)))))
1839 (defun article-decode-charset (&optional prompt)
1840 "Decode charset-encoded text in the article.
1841 If PROMPT (the prefix), prompt for a coding system to use."
1843 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
1845 (mail-parse-charset gnus-newsgroup-charset)
1846 (mail-parse-ignored-charsets
1847 (save-excursion (condition-case nil
1848 (set-buffer gnus-summary-buffer)
1850 gnus-newsgroup-ignored-charsets))
1851 ct cte ctl charset format)
1854 (article-narrow-to-head)
1855 (setq ct (message-fetch-field "Content-Type" t)
1856 cte (message-fetch-field "Content-Transfer-Encoding" t)
1857 ctl (and ct (ignore-errors
1858 (mail-header-parse-content-type ct)))
1861 (mm-read-coding-system "Charset to decode: "))
1863 (mail-content-type-get ctl 'charset)))
1864 format (and ctl (mail-content-type-get ctl 'format)))
1866 (setq cte (mail-header-strip cte)))
1867 (if (and ctl (not (string-match "/" (car ctl))))
1869 (goto-char (point-max)))
1872 (narrow-to-region (point) (point-max))
1873 (when (and (eq mail-parse-charset 'gnus-decoded)
1874 (eq (mm-body-7-or-8) '8bit))
1875 ;; The text code could have been decoded.
1876 (setq charset mail-parse-charset))
1877 (when (and (or (not ctl)
1878 (equal (car ctl) "text/plain"))
1879 (not format)) ;; article with format will decode later.
1881 charset (and cte (intern (downcase
1882 (gnus-strip-whitespace cte))))
1885 (defun article-decode-encoded-words ()
1886 "Remove encoded-word encoding from headers."
1887 (let (buffer-read-only)
1888 (let ((charset (save-excursion
1889 (set-buffer gnus-summary-buffer)
1890 default-mime-charset)))
1891 (mime-decode-header-in-buffer charset)
1894 (defun article-de-quoted-unreadable (&optional force read-charset)
1895 "Translate a quoted-printable-encoded article.
1896 If FORCE, decode the article whether it is marked as quoted-printable
1898 If READ-CHARSET, ask for a coding system."
1899 (interactive (list 'force current-prefix-arg))
1901 (let ((buffer-read-only nil) type charset)
1902 (if (gnus-buffer-live-p gnus-original-article-buffer)
1903 (with-current-buffer gnus-original-article-buffer
1905 (gnus-fetch-field "content-transfer-encoding"))
1906 (let* ((ct (gnus-fetch-field "content-type"))
1909 (mail-header-parse-content-type ct)))))
1910 (setq charset (and ctl
1911 (mail-content-type-get ctl 'charset)))
1912 (if (stringp charset)
1913 (setq charset (intern (downcase charset)))))))
1915 (setq charset (mm-read-coding-system "Charset: " charset)))
1917 (setq charset gnus-newsgroup-charset))
1919 (and type (let ((case-fold-search t))
1920 (string-match "quoted-printable" type))))
1922 (quoted-printable-decode-region
1923 (point) (point-max) (mm-charset-to-coding-system charset))))))
1925 (defun article-de-base64-unreadable (&optional force read-charset)
1926 "Translate a base64 article.
1927 If FORCE, decode the article whether it is marked as base64 not.
1928 If READ-CHARSET, ask for a coding system."
1929 (interactive (list 'force current-prefix-arg))
1931 (let ((buffer-read-only nil) type charset)
1932 (if (gnus-buffer-live-p gnus-original-article-buffer)
1933 (with-current-buffer gnus-original-article-buffer
1935 (gnus-fetch-field "content-transfer-encoding"))
1936 (let* ((ct (gnus-fetch-field "content-type"))
1939 (mail-header-parse-content-type ct)))))
1940 (setq charset (and ctl
1941 (mail-content-type-get ctl 'charset)))
1942 (if (stringp charset)
1943 (setq charset (intern (downcase charset)))))))
1945 (setq charset (mm-read-coding-system "Charset: " charset)))
1947 (setq charset gnus-newsgroup-charset))
1949 (and type (let ((case-fold-search t))
1950 (string-match "base64" type))))
1953 (narrow-to-region (point) (point-max))
1954 (base64-decode-region (point-min) (point-max))
1955 (mm-decode-coding-region
1956 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
1961 (defun article-decode-HZ ()
1962 "Translate a HZ-encoded article."
1966 (let ((buffer-read-only nil))
1967 (rfc1843-decode-region (point-min) (point-max)))))
1969 (defun article-wash-html (&optional read-charset)
1970 "Format an html article.
1971 If READ-CHARSET, ask for a coding system."
1974 (let ((buffer-read-only nil)
1976 (if (gnus-buffer-live-p gnus-original-article-buffer)
1977 (with-current-buffer gnus-original-article-buffer
1978 (let* ((ct (gnus-fetch-field "content-type"))
1981 (mail-header-parse-content-type ct)))))
1982 (setq charset (and ctl
1983 (mail-content-type-get ctl 'charset)))
1984 (if (stringp charset)
1985 (setq charset (intern (downcase charset)))))))
1987 (setq charset (mm-read-coding-system "Charset: " charset)))
1989 (setq charset gnus-newsgroup-charset))
1991 (save-window-excursion
1993 (narrow-to-region (point) (point-max))
1995 (let ((w3-strict-width (window-width))
1996 (url-standalone-mode t))
1998 (w3-region (point-min) (point-max))
2001 (defun article-hide-list-identifiers ()
2002 "Remove list identifies from the Subject header.
2003 The `gnus-list-identifiers' variable specifies what to do."
2005 (let ((inhibit-point-motion-hooks t)
2006 (regexp (if (consp gnus-list-identifiers)
2007 (mapconcat 'identity gnus-list-identifiers " *\\|")
2008 gnus-list-identifiers))
2013 (article-narrow-to-head)
2014 (goto-char (point-min))
2015 (while (re-search-forward
2016 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2018 (delete-region (match-beginning 2) (match-end 0))
2019 (beginning-of-line))
2020 (when (re-search-forward
2021 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2022 (delete-region (match-beginning 1) (match-end 1))))))))
2024 (defun article-hide-pgp ()
2025 "Remove any PGP headers and signatures in the current article."
2029 (let ((inhibit-point-motion-hooks t)
2030 buffer-read-only beg end)
2032 ;; Hide the "header".
2033 (when (re-search-forward "^-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
2034 (push 'pgp gnus-article-wash-types)
2035 (delete-region (match-beginning 0) (match-end 0))
2036 ;; Remove armor headers (rfc2440 6.2)
2037 (delete-region (point) (or (re-search-forward "^[ \t]*\n" nil t)
2040 ;; Hide the actual signature.
2041 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
2042 (setq end (1+ (match-beginning 0)))
2045 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
2047 ;; Perhaps we shouldn't hide to the end of the buffer
2048 ;; if there is no end to the signature?
2050 ;; Hide "- " PGP quotation markers.
2052 (narrow-to-region beg end)
2053 (goto-char (point-min))
2054 (while (re-search-forward "^- " nil t)
2056 (match-beginning 0) (match-end 0)))
2058 (gnus-run-hooks 'gnus-article-hide-pgp-hook))))))
2060 (defun article-hide-pem (&optional arg)
2061 "Toggle hiding of any PEM headers and signatures in the current article.
2062 If given a negative prefix, always show; if given a positive prefix,
2064 (interactive (gnus-article-hidden-arg))
2065 (unless (gnus-article-check-hidden-text 'pem arg)
2067 (let (buffer-read-only end)
2068 (goto-char (point-min))
2069 ;; Hide the horrendously ugly "header".
2070 (when (and (search-forward
2071 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2073 (setq end (1+ (match-beginning 0))))
2074 (push 'pem gnus-article-wash-types)
2075 (gnus-article-hide-text-type
2077 (if (search-forward "\n\n" nil t)
2081 ;; Hide the trailer as well
2082 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2084 (gnus-article-hide-text-type
2085 (match-beginning 0) (match-end 0) 'pem)))))))
2087 (defun article-strip-banner ()
2088 "Strip the banner specified by the `banner' group parameter."
2092 (let ((inhibit-point-motion-hooks t)
2093 (banner (gnus-parameter-banner gnus-newsgroup-name))
2094 (gnus-signature-limit nil)
2095 buffer-read-only beg end)
2099 ((eq banner 'signature)
2100 (when (gnus-article-narrow-to-signature)
2103 (delete-region (point) (point-max))))
2105 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2106 (while (re-search-forward banner nil t)
2107 (delete-region (match-beginning 0) (match-end 0)))))
2109 (while (re-search-forward banner nil t)
2110 (delete-region (match-beginning 0) (match-end 0))))))))))
2112 (defun article-babel ()
2113 "Translate article using an online translation service."
2117 (set-buffer gnus-article-buffer)
2118 (when (article-goto-body)
2119 (let* ((buffer-read-only nil)
2122 (orig (buffer-substring start end))
2123 (trans (babel-as-string orig)))
2125 (narrow-to-region start end)
2126 (delete-region start end)
2129 (defun article-hide-signature (&optional arg)
2130 "Hide the signature in the current article.
2131 If given a negative prefix, always show; if given a positive prefix,
2133 (interactive (gnus-article-hidden-arg))
2139 (article-goto-body))
2140 (goto-char (point-min)))
2141 (unless (gnus-article-check-hidden-text 'signature arg)
2142 (let ((buffer-read-only nil)
2144 (while (setq button (text-property-any button (point-max)
2146 'gnus-signature-toggle))
2147 (setq button (text-property-not-all button (point-max)
2149 'gnus-signature-toggle))
2150 (when (and button (not (eobp)))
2151 (gnus-article-hide-text-type
2153 (next-single-property-change (1+ button) 'mime-view-entity
2157 (defun article-strip-headers-in-body ()
2158 "Strip offensive headers from bodies."
2162 (let ((case-fold-search t))
2163 (when (looking-at "x-no-archive:")
2164 (gnus-delete-line)))))
2166 (defun article-strip-leading-blank-lines ()
2167 "Remove all blank lines from the beginning of the article."
2170 (let ((inhibit-point-motion-hooks t)
2172 (when (article-goto-body)
2173 (while (and (not (eobp))
2174 (looking-at "[ \t]*$"))
2175 (gnus-delete-line))))))
2177 (defun article-narrow-to-head ()
2178 "Narrow the buffer to the head of the message.
2179 Point is left at the beginning of the narrowed-to region."
2181 (goto-char (point-min))
2182 (if (search-forward "\n\n" nil 1)
2185 (goto-char (point-min)))
2187 (defun article-goto-body ()
2188 "Place point at the start of the body."
2189 (goto-char (point-min))
2191 ;; This variable is only bound when dealing with separate
2193 (article-goto-body-goes-to-point-min-p
2195 ((search-forward "\n\n" nil t)
2198 (goto-char (point-max))
2201 (defun article-strip-multiple-blank-lines ()
2202 "Replace consecutive blank lines with one empty line."
2205 (let ((inhibit-point-motion-hooks t)
2207 ;; First make all blank lines empty.
2209 (while (re-search-forward "^[ \t]+$" nil t)
2210 (unless (gnus-annotation-in-region-p
2211 (match-beginning 0) (match-end 0))
2212 (replace-match "" nil t)))
2213 ;; Then replace multiple empty lines with a single empty line.
2215 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2216 (unless (gnus-annotation-in-region-p
2217 (match-beginning 0) (match-end 0))
2218 (delete-region (match-beginning 1) (match-end 1)))))))
2220 (defun article-strip-leading-space ()
2221 "Remove all white space from the beginning of the lines in the article."
2224 (let ((inhibit-point-motion-hooks t)
2227 (while (re-search-forward "^[ \t]+" nil t)
2228 (replace-match "" t t)))))
2230 (defun article-strip-trailing-space ()
2231 "Remove all white space from the end of the lines in the article."
2234 (let ((inhibit-point-motion-hooks t)
2237 (while (re-search-forward "[ \t]+$" nil t)
2238 (replace-match "" t t)))))
2240 (defun article-strip-blank-lines ()
2241 "Strip leading, trailing and multiple blank lines."
2243 (article-strip-leading-blank-lines)
2244 (article-remove-trailing-blank-lines)
2245 (article-strip-multiple-blank-lines))
2247 (defun article-strip-all-blank-lines ()
2248 "Strip all blank lines."
2251 (let ((inhibit-point-motion-hooks t)
2254 (while (re-search-forward "^[ \t]*\n" nil t)
2255 (replace-match "" t t)))))
2257 (defun gnus-article-narrow-to-signature ()
2258 "Narrow to the signature; return t if a signature is found, else nil."
2259 (let ((inhibit-point-motion-hooks t))
2260 (when (gnus-article-search-signature)
2262 ;; Check whether we have some limits to what we consider
2263 ;; to be a signature.
2264 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2265 (list gnus-signature-limit)))
2267 (while (setq limit (pop limits))
2268 (if (or (and (integerp limit)
2269 (< (- (point-max) (point)) limit))
2271 (< (count-lines (point) (point-max)) limit))
2272 (and (gnus-functionp limit)
2274 (and (stringp limit)
2275 (not (re-search-forward limit nil t))))
2276 () ; This limit did not succeed.
2280 (narrow-to-region (point) (point-max))
2283 (defun gnus-article-search-signature ()
2284 "Search the current buffer for the signature separator.
2285 Put point at the beginning of the signature separator."
2286 (let ((cur (point)))
2287 (goto-char (point-max))
2288 (if (if (stringp gnus-signature-separator)
2289 (re-search-backward gnus-signature-separator nil t)
2290 (let ((seps gnus-signature-separator))
2292 (not (re-search-backward (car seps) nil t)))
2299 (defun gnus-article-hidden-arg ()
2300 "Return the current prefix arg as a number, or 0 if no prefix."
2301 (list (if current-prefix-arg
2302 (prefix-numeric-value current-prefix-arg)
2305 (defun gnus-article-check-hidden-text (type arg)
2306 "Return nil if hiding is necessary.
2307 Arg can be nil or a number. Nil and positive means hide, negative
2308 means show, 0 means toggle."
2311 (let ((hide (gnus-article-hidden-text-p type)))
2317 (gnus-article-show-hidden-text type)
2320 (if (eq hide 'hidden)
2322 (gnus-article-show-hidden-text type)
2326 (defun gnus-article-hidden-text-p (type)
2327 "Say whether the current buffer contains hidden text of type TYPE."
2328 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2330 (not (get-text-property pos 'invisible))
2331 (not (get-text-property pos 'dummy-invisible)))
2333 (text-property-any (1+ pos) (point-max) 'article-type type)))
2338 (defun gnus-article-show-hidden-text (type &optional dummy)
2339 "Show all hidden text of type TYPE.
2340 Originally it is hide instead of DUMMY."
2341 (let ((buffer-read-only nil)
2342 (inhibit-point-motion-hooks t))
2343 (gnus-remove-text-properties-when
2345 (point-min) (point-max)
2346 (cons 'article-type (cons type
2347 gnus-hidden-properties)))))
2349 (defconst article-time-units
2350 `((year . ,(* 365.25 24 60 60))
2351 (week . ,(* 7 24 60 60))
2352 (day . ,(* 24 60 60))
2356 "Mapping from time units to seconds.")
2358 (defun article-date-ut (&optional type highlight header)
2359 "Convert DATE date to universal time in the current article.
2360 If TYPE is `local', convert to local time; if it is `lapsed', output
2361 how much time has lapsed since DATE. For `lapsed', the value of
2362 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2363 should replace the \"Date:\" one, or should be added below it."
2364 (interactive (list 'ut t))
2365 (let* ((header (or header
2366 (and (eq 1 (point-min))
2367 (mail-header-date (save-excursion
2368 (set-buffer gnus-summary-buffer)
2369 gnus-current-headers)))
2370 (message-fetch-field "date")
2372 (date (if (vectorp header) (mail-header-date header)
2374 (inhibit-point-motion-hooks t)
2375 bface eface date-pos)
2376 (when (and date (not (string= date "")))
2379 (article-narrow-to-head)
2380 (when (or (and (eq type 'lapsed)
2381 gnus-article-date-lapsed-new-header
2382 ;; Attempt to get the face of X-Sent first.
2383 (re-search-forward "^X-Sent:[ \t]" nil t))
2384 (re-search-forward "^Date:[ \t]" nil t)
2385 ;; If Date is missing, try again for X-Sent.
2386 (re-search-forward "^X-Sent:[ \t]" nil t))
2387 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2388 date (or (get-text-property (gnus-point-at-bol)
2391 eface (get-text-property (1- (gnus-point-at-eol))
2393 (let ((buffer-read-only nil))
2394 ;; Delete any old X-Sent headers.
2395 (when (setq date-pos
2396 (text-property-any (point-min) (point-max)
2397 'article-date-lapsed t))
2398 (goto-char (setq date-pos (set-marker (make-marker) date-pos)))
2399 (delete-region (match-beginning 0)
2400 (progn (forward-line 1) (point))))
2401 (goto-char (point-min))
2402 ;; Delete any old Date headers.
2403 (while (re-search-forward "^Date:[ \t]" nil t)
2405 (setq date-pos (match-beginning 0)))
2406 (unless (and (eq type 'lapsed)
2407 gnus-article-date-lapsed-new-header)
2408 (delete-region (match-beginning 0)
2409 (progn (message-next-header) (point)))))
2412 (goto-char date-pos)
2414 ;; Possibly, Date has been deleted.
2416 (when (and (eq type 'lapsed)
2417 gnus-article-date-lapsed-new-header
2418 (looking-at "Date:"))
2420 (goto-char (point-min)))
2421 (insert (article-make-date-line date type))
2422 (when (eq type 'lapsed)
2423 (put-text-property (gnus-point-at-bol) (point)
2424 'article-date-lapsed t))
2428 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2429 (put-text-property (match-beginning 1) (1+ (match-end 1))
2430 'original-date date)
2431 (put-text-property (match-beginning 1) (1+ (match-end 1))
2433 (put-text-property (match-beginning 2) (match-end 2)
2436 (defun article-make-date-line (date type)
2437 "Return a DATE line of TYPE."
2438 (unless (memq type '(local ut original user iso8601 lapsed english))
2439 (error "Unknown conversion type: %s" type))
2441 (let ((time (date-to-time date)))
2443 ;; Convert to the local timezone.
2445 (let ((tz (car (current-time-zone time))))
2446 (format "Date: %s %s%02d%02d" (current-time-string time)
2447 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2448 (/ (% (abs tz) 3600) 60))))
2449 ;; Convert to Universal Time.
2452 (current-time-string
2453 (let* ((e (parse-time-string date))
2454 (tm (apply 'encode-time e))
2456 (ls (- (cadr tm) (car (current-time-zone time)))))
2457 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2458 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2461 ;; Get the original date from the article.
2462 ((eq type 'original)
2463 (concat "Date: " (if (string-match "\n+$" date)
2464 (substring date 0 (match-beginning 0))
2466 ;; Let the user define the format.
2468 (if (gnus-functionp gnus-article-time-format)
2469 (funcall gnus-article-time-format time)
2472 (format-time-string gnus-article-time-format time))))
2475 (let ((tz (car (current-time-zone time))))
2478 (format-time-string "%Y%m%dT%H%M%S" time)
2479 (format "%s%02d%02d"
2480 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2481 (/ (% (abs tz) 3600) 60)))))
2482 ;; Do an X-Sent lapsed format.
2484 ;; If the date is seriously mangled, the timezone functions are
2485 ;; liable to bug out, so we ignore all errors.
2486 (let* ((now (current-time))
2487 (real-time (subtract-time now time))
2488 (real-sec (and real-time
2489 (+ (* (float (car real-time)) 65536)
2491 (sec (and real-time (abs real-sec)))
2501 ;; This is a bit convoluted, but basically we go
2502 ;; through the time units for years, weeks, etc,
2503 ;; and divide things to see whether that results
2504 ;; in positive answers.
2507 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2508 ;; The (remaining) seconds are too few to
2509 ;; be divided into this time unit.
2511 ;; It's big enough, so we output it.
2512 (setq sec (- sec (* num (cdr unit))))
2514 (concat (if prev ", " "") (int-to-string
2516 " " (symbol-name (car unit))
2517 (if (> num 1) "s" ""))
2519 article-time-units "")
2520 ;; If dates are odd, then it might appear like the
2521 ;; article was sent in the future.
2524 " in the future"))))))
2525 ;; Display the date in proper English
2527 (let ((dtime (decode-time time)))
2530 (number-to-string (nth 3 dtime))
2531 (let ((digit (% (nth 3 dtime) 10)))
2533 ((memq (nth 3 dtime) '(11 12 13)) "th")
2539 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2541 (number-to-string (nth 5 dtime))
2543 (format "%02d" (nth 2 dtime))
2545 (format "%02d" (nth 1 dtime)))))))
2547 (format "Date: %s (from Oort)" date))))
2549 (defun article-date-local (&optional highlight)
2550 "Convert the current article date to the local timezone."
2551 (interactive (list t))
2552 (article-date-ut 'local highlight))
2554 (defun article-date-english (&optional highlight)
2555 "Convert the current article date to something that is proper English."
2556 (interactive (list t))
2557 (article-date-ut 'english highlight))
2559 (defun article-date-original (&optional highlight)
2560 "Convert the current article date to what it was originally.
2561 This is only useful if you have used some other date conversion
2562 function and want to see what the date was before converting."
2563 (interactive (list t))
2564 (article-date-ut 'original highlight))
2566 (defun article-date-lapsed (&optional highlight)
2567 "Convert the current article date to time lapsed since it was sent."
2568 (interactive (list t))
2569 (article-date-ut 'lapsed highlight))
2571 (defun article-update-date-lapsed ()
2572 "Function to be run from a timer to update the lapsed time line."
2573 (let (deactivate-mark)
2578 (set-buffer (window-buffer w))
2579 (when (eq major-mode 'gnus-article-mode)
2580 (goto-char (point-min))
2581 (when (re-search-forward "^X-Sent:" nil t)
2582 (article-date-lapsed t))))
2585 (defun gnus-start-date-timer (&optional n)
2586 "Start a timer to update the X-Sent header in the article buffers.
2587 The numerical prefix says how frequently (in seconds) the function
2592 (gnus-stop-date-timer)
2593 (setq article-lapsed-timer
2594 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2596 (defun gnus-stop-date-timer ()
2597 "Stop the X-Sent timer."
2599 (when article-lapsed-timer
2600 (nnheader-cancel-timer article-lapsed-timer)
2601 (setq article-lapsed-timer nil)))
2603 (defun article-date-user (&optional highlight)
2604 "Convert the current article date to the user-defined format.
2605 This format is defined by the `gnus-article-time-format' variable."
2606 (interactive (list t))
2607 (article-date-ut 'user highlight))
2609 (defun article-date-iso8601 (&optional highlight)
2610 "Convert the current article date to ISO8601."
2611 (interactive (list t))
2612 (article-date-ut 'iso8601 highlight))
2614 (defun article-show-all ()
2615 "Show all hidden text in the article buffer."
2619 (let ((buffer-read-only nil))
2620 (gnus-article-unhide-text (point-min) (point-max))
2621 (gnus-remove-text-with-property 'gnus-prev)
2622 (gnus-remove-text-with-property 'gnus-next))))
2624 (defun article-show-all-headers ()
2625 "Show all hidden headers in the article buffer."
2630 (article-narrow-to-head)
2631 (let ((buffer-read-only nil))
2632 (gnus-article-unhide-text (point-min) (point-max))))))
2634 (defun article-remove-leading-whitespace ()
2635 "Remove excessive whitespace from all headers."
2639 (let ((buffer-read-only nil))
2640 (article-narrow-to-head)
2641 (goto-char (point-min))
2642 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
2643 (delete-region (match-beginning 1) (match-end 1)))))))
2645 (defun article-emphasize (&optional arg)
2646 "Emphasize text according to `gnus-emphasis-alist'."
2647 (interactive (gnus-article-hidden-arg))
2648 (unless (gnus-article-check-hidden-text 'emphasis arg)
2652 (with-current-buffer gnus-summary-buffer
2653 gnus-article-emphasis-alist)
2655 gnus-emphasis-alist))
2656 (buffer-read-only nil)
2657 (props (append '(article-type emphasis)
2658 gnus-hidden-properties))
2659 regexp elem beg invisible visible face)
2662 (while (setq elem (pop alist))
2664 (setq regexp (car elem)
2665 invisible (nth 1 elem)
2666 visible (nth 2 elem)
2668 (while (re-search-forward regexp nil t)
2669 (when (and (match-beginning visible) (match-beginning invisible))
2670 (push 'emphasis gnus-article-wash-types)
2671 (gnus-article-hide-text
2672 (match-beginning invisible) (match-end invisible) props)
2673 (gnus-article-unhide-text-type
2674 (match-beginning visible) (match-end visible) 'emphasis)
2675 (gnus-put-text-property-excluding-newlines
2676 (match-beginning visible) (match-end visible) 'face face)
2677 (goto-char (match-end invisible)))))))))
2679 (defun gnus-article-setup-highlight-words (&optional highlight-words)
2680 "Setup newsgroup emphasis alist."
2681 (unless gnus-article-emphasis-alist
2682 (let ((name (and gnus-newsgroup-name
2683 (gnus-group-real-name gnus-newsgroup-name))))
2684 (make-local-variable 'gnus-article-emphasis-alist)
2685 (setq gnus-article-emphasis-alist
2687 (let ((alist gnus-group-highlight-words-alist) elem highlight)
2688 (while (setq elem (pop alist))
2689 (when (and name (string-match (car elem) name))
2691 highlight (copy-sequence (cdr elem)))))
2693 (copy-sequence highlight-words)
2694 (if gnus-newsgroup-name
2695 (copy-sequence (gnus-group-find-parameter
2696 gnus-newsgroup-name 'highlight-words t)))
2697 gnus-emphasis-alist)))))
2700 (defvar gnus-summary-article-menu)
2701 (defvar gnus-summary-post-menu))
2703 ;;; Saving functions.
2705 (defun gnus-article-save (save-buffer file &optional num)
2706 "Save the currently selected article."
2707 (unless gnus-save-all-headers
2708 ;; Remove headers according to `gnus-saved-headers'.
2709 (let ((gnus-visible-headers
2710 (or gnus-saved-headers gnus-visible-headers))
2711 (gnus-article-buffer save-buffer))
2713 (set-buffer save-buffer)
2714 (article-hide-headers 1 t))))
2715 (save-window-excursion
2716 (if (not gnus-default-article-saver)
2717 (error "No default saver is defined")
2718 ;; !!! Magic! The saving functions all save
2719 ;; `gnus-save-article-buffer' (or so they think), but we
2720 ;; bind that variable to our save-buffer.
2721 (set-buffer gnus-article-buffer)
2722 (let* ((gnus-save-article-buffer save-buffer)
2725 ((not gnus-prompt-before-saving) 'default)
2726 ((eq gnus-prompt-before-saving 'always) nil)
2728 (gnus-number-of-articles-to-be-saved
2729 (when (eq gnus-prompt-before-saving t)
2731 (set-buffer gnus-article-current-summary)
2732 (funcall gnus-default-article-saver filename)))))
2734 (defun gnus-read-save-file-name (prompt &optional filename
2735 function group headers variable)
2737 (funcall function group headers (symbol-value variable)))
2742 ((eq filename 'default)
2748 (let* ((split-name (gnus-get-split-value gnus-split-methods))
2751 (if (and gnus-number-of-articles-to-be-saved
2752 (> gnus-number-of-articles-to-be-saved 1))
2753 (format "these %d articles"
2754 gnus-number-of-articles-to-be-saved)
2757 ;; Let the split methods have their say.
2759 ;; No split name was found.
2762 (concat prompt " (default "
2763 (file-name-nondirectory default-name) ") ")
2764 (file-name-directory default-name)
2766 ;; A single group name is returned.
2767 ((stringp split-name)
2769 (funcall function split-name headers
2770 (symbol-value variable)))
2772 (concat prompt " (default "
2773 (file-name-nondirectory default-name) ") ")
2774 (file-name-directory default-name)
2776 ;; A single split name was found
2777 ((= 1 (length split-name))
2778 (let* ((name (expand-file-name
2780 gnus-article-save-directory))
2781 (dir (cond ((file-directory-p name)
2782 (file-name-as-directory name))
2783 ((file-exists-p name) name)
2784 (t gnus-article-save-directory))))
2786 (concat prompt " (default " name ") ")
2788 ;; A list of splits was found.
2790 (setq split-name (nreverse split-name))
2792 (let ((file-name-history
2793 (nconc split-name file-name-history)))
2797 (concat prompt " (`M-p' for defaults) ")
2798 gnus-article-save-directory
2800 gnus-article-save-directory)))
2801 (car (push result file-name-history)))))))
2802 ;; Create the directory.
2803 (gnus-make-directory (file-name-directory file))
2804 ;; If we have read a directory, we append the default file name.
2805 (when (file-directory-p file)
2806 (setq file (expand-file-name (file-name-nondirectory
2808 (file-name-as-directory file))))
2809 ;; Possibly translate some characters.
2810 (nnheader-translate-file-chars file))))))
2811 (gnus-make-directory (file-name-directory result))
2812 (set variable result)))
2814 (defun gnus-article-archive-name (group)
2815 "Return the first instance of an \"Archive-name\" in the current buffer."
2816 (let ((case-fold-search t))
2817 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
2818 (nnheader-concat gnus-article-save-directory
2819 (match-string 1)))))
2821 (defun gnus-article-nndoc-name (group)
2822 "If GROUP is an nndoc group, return the name of the parent group."
2823 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
2824 (gnus-group-get-parameter group 'save-article-group)))
2826 (defun gnus-summary-save-in-rmail (&optional filename)
2827 "Append this article to Rmail file.
2828 Optional argument FILENAME specifies file name.
2829 Directory to save to is default to `gnus-article-save-directory'."
2830 (setq filename (gnus-read-save-file-name
2831 "Save %s in rmail file:" filename
2832 gnus-rmail-save-name gnus-newsgroup-name
2833 gnus-current-headers 'gnus-newsgroup-last-rmail))
2834 (gnus-eval-in-buffer-window gnus-save-article-buffer
2838 (gnus-output-to-rmail filename))))
2841 (defun gnus-summary-save-in-mail (&optional filename)
2842 "Append this article to Unix mail file.
2843 Optional argument FILENAME specifies file name.
2844 Directory to save to is default to `gnus-article-save-directory'."
2845 (setq filename (gnus-read-save-file-name
2846 "Save %s in Unix mail file:" filename
2847 gnus-mail-save-name gnus-newsgroup-name
2848 gnus-current-headers 'gnus-newsgroup-last-mail))
2849 (gnus-eval-in-buffer-window gnus-save-article-buffer
2853 (if (and (file-readable-p filename)
2854 (mail-file-babyl-p filename))
2855 (rmail-output-to-rmail-file filename t)
2856 (gnus-output-to-mail filename)))))
2859 (defun gnus-summary-save-in-file (&optional filename overwrite)
2860 "Append this article to file.
2861 Optional argument FILENAME specifies file name.
2862 Directory to save to is default to `gnus-article-save-directory'."
2863 (setq filename (gnus-read-save-file-name
2864 "Save %s in file:" filename
2865 gnus-file-save-name gnus-newsgroup-name
2866 gnus-current-headers 'gnus-newsgroup-last-file))
2867 (gnus-eval-in-buffer-window gnus-save-article-buffer
2871 (when (and overwrite
2872 (file-exists-p filename))
2873 (delete-file filename))
2874 (gnus-output-to-file filename))))
2877 (defun gnus-summary-write-to-file (&optional filename)
2878 "Write this article to a file.
2879 Optional argument FILENAME specifies file name.
2880 The directory to save in defaults to `gnus-article-save-directory'."
2881 (gnus-summary-save-in-file nil t))
2883 (defun gnus-summary-save-body-in-file (&optional filename)
2884 "Append this article body to a file.
2885 Optional argument FILENAME specifies file name.
2886 The directory to save in defaults to `gnus-article-save-directory'."
2887 (setq filename (gnus-read-save-file-name
2888 "Save %s body in file:" filename
2889 gnus-file-save-name gnus-newsgroup-name
2890 gnus-current-headers 'gnus-newsgroup-last-file))
2891 (gnus-eval-in-buffer-window gnus-save-article-buffer
2895 (when (article-goto-body)
2896 (narrow-to-region (point) (point-max)))
2897 (gnus-output-to-file filename))))
2900 (defun gnus-summary-save-in-pipe (&optional command)
2901 "Pipe this article to subprocess."
2903 (cond ((and (eq command 'default)
2904 gnus-last-shell-command)
2905 gnus-last-shell-command)
2910 "Shell command on %s: "
2911 (if (and gnus-number-of-articles-to-be-saved
2912 (> gnus-number-of-articles-to-be-saved 1))
2913 (format "these %d articles"
2914 gnus-number-of-articles-to-be-saved)
2916 gnus-last-shell-command))))
2917 (when (string-equal command "")
2918 (if gnus-last-shell-command
2919 (setq command gnus-last-shell-command)
2920 (error "A command is required")))
2921 (gnus-eval-in-buffer-window gnus-article-buffer
2924 (shell-command-on-region (point-min) (point-max) command nil)))
2925 (setq gnus-last-shell-command command))
2927 ;;; Article file names when saving.
2929 (defun gnus-capitalize-newsgroup (newsgroup)
2930 "Capitalize NEWSGROUP name."
2931 (when (not (zerop (length newsgroup)))
2932 (concat (char-to-string (upcase (aref newsgroup 0)))
2933 (substring newsgroup 1))))
2935 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2936 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2937 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
2938 Otherwise, it is like ~/News/news/group/num."
2941 (concat (if (gnus-use-long-file-name 'not-save)
2942 (gnus-capitalize-newsgroup newsgroup)
2943 (gnus-newsgroup-directory-form newsgroup))
2944 "/" (int-to-string (mail-header-number headers)))
2945 gnus-article-save-directory)))
2947 (string-equal (file-name-directory default)
2948 (file-name-directory last-file))
2949 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2951 (or last-file default))))
2953 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2954 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2955 If variable `gnus-use-long-file-name' is non-nil, it is
2956 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2959 (concat (if (gnus-use-long-file-name 'not-save)
2961 (gnus-newsgroup-directory-form newsgroup))
2962 "/" (int-to-string (mail-header-number headers)))
2963 gnus-article-save-directory)))
2965 (string-equal (file-name-directory default)
2966 (file-name-directory last-file))
2967 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2969 (or last-file default))))
2971 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2972 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2973 If variable `gnus-use-long-file-name' is non-nil, it is
2974 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2977 (if (gnus-use-long-file-name 'not-save)
2980 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
2982 gnus-article-save-directory)))
2984 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
2985 "Generate file name from sender."
2986 (let ((from (mail-header-from headers)))
2988 (if (and from (string-match "\\([^ <]+\\)@" from))
2989 (match-string 1 from)
2991 gnus-article-save-directory)))
2993 (defun article-verify-x-pgp-sig ()
2996 (if (gnus-buffer-live-p gnus-original-article-buffer)
2997 (let ((sig (with-current-buffer gnus-original-article-buffer
2998 (gnus-fetch-field "X-PGP-Sig")))
3002 (mml2015-clear-verify-function))
3004 (insert-buffer gnus-original-article-buffer)
3005 (setq items (split-string sig))
3006 (message-narrow-to-head)
3007 (let ((inhibit-point-motion-hooks t)
3008 (case-fold-search t))
3009 ;; Don't verify multiple headers.
3010 (setq headers (mapconcat (lambda (header)
3012 (mail-fetch-field header) "\n"))
3013 (split-string (nth 1 items) ",") "")))
3014 (delete-region (point-min) (point-max))
3015 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3016 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3021 (if (looking-at "^-")
3024 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3025 (insert "Version: " (car items) "\n\n")
3026 (insert (mapconcat 'identity (cddr items) "\n"))
3027 (insert "\n-----END PGP SIGNATURE-----\n")
3028 (let ((mm-security-handle (list (format "multipart/signed"))))
3029 (mml2015-clean-buffer)
3030 (let ((coding-system-for-write (or gnus-newsgroup-charset
3032 (funcall (mml2015-clear-verify-function)))
3034 (or (mm-handle-multipart-ctl-parameter
3035 mm-security-handle 'gnus-details)
3036 (mm-handle-multipart-ctl-parameter
3037 mm-security-handle 'gnus-info)))))
3039 (let (buffer-read-only bface eface)
3041 (message-narrow-to-head)
3042 (goto-char (point-max))
3044 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3045 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3046 (message-remove-header "X-Gnus-PGP-Verify")
3047 (if (re-search-forward "^X-PGP-Sig:" nil t)
3049 (goto-char (point-max)))
3050 (narrow-to-region (point) (point))
3051 (insert "X-Gnus-PGP-Verify: " info "\n")
3052 (goto-char (point-min))
3055 (if (not (looking-at "^[ \t]"))
3059 (goto-char (point-min))
3060 (when (looking-at "\\([^:]+\\): *")
3061 (put-text-property (match-beginning 1) (1+ (match-end 1))
3063 (put-text-property (match-end 0) (point-max)
3064 'face eface)))))))))
3071 (setq afunc (car func)
3074 gfunc (intern (format "gnus-%s" func))))
3077 `(lambda (&optional interactive &rest args)
3078 ,(documentation afunc t)
3079 (interactive (list t))
3081 (set-buffer gnus-article-buffer)
3083 (call-interactively ',afunc)
3084 (apply ',afunc args))))))))
3085 '(article-hide-headers
3086 article-verify-x-pgp-sig
3087 article-hide-boring-headers
3088 article-toggle-headers
3089 article-treat-overstrike
3090 article-fill-long-lines
3091 article-capitalize-sentences
3093 article-remove-leading-whitespace
3094 article-display-x-face
3095 article-de-quoted-unreadable
3096 article-de-base64-unreadable
3099 article-hide-list-identifiers
3101 article-strip-banner
3104 article-hide-signature
3105 article-strip-headers-in-body
3106 article-remove-trailing-blank-lines
3107 article-strip-leading-blank-lines
3108 article-strip-multiple-blank-lines
3109 article-strip-leading-space
3110 article-strip-trailing-space
3111 article-strip-blank-lines
3112 article-strip-all-blank-lines
3114 article-date-english
3115 article-date-iso8601
3116 article-date-original
3118 article-decode-mime-words
3119 article-decode-charset
3120 article-decode-encoded-words
3124 article-treat-dumbquotes
3125 article-normalize-headers
3126 (article-show-all-headers . gnus-article-show-all-headers)
3127 (article-show-all . gnus-article-show-all))))
3130 ;;; Gnus article mode
3133 (put 'gnus-article-mode 'mode-class 'special)
3135 (gnus-define-keys gnus-article-mode-map
3136 " " gnus-article-goto-next-page
3137 "\177" gnus-article-goto-prev-page
3138 [delete] gnus-article-goto-prev-page
3139 [backspace] gnus-article-goto-prev-page
3140 "\C-c^" gnus-article-refer-article
3141 "h" gnus-article-show-summary
3142 "s" gnus-article-show-summary
3143 "\C-c\C-m" gnus-article-mail
3144 "?" gnus-article-describe-briefly
3145 "e" gnus-summary-edit-article
3146 "<" beginning-of-buffer
3148 "\C-c\C-i" gnus-info-find-node
3150 "\C-hk" gnus-article-describe-key
3151 "\C-hc" gnus-article-describe-key-briefly
3153 "\C-d" gnus-article-read-summary-keys
3154 "\M-*" gnus-article-read-summary-keys
3155 "\M-#" gnus-article-read-summary-keys
3156 "\M-^" gnus-article-read-summary-keys
3157 "\M-g" gnus-article-read-summary-keys)
3159 ;; Define almost undefined keys to `gnus-article-read-summary-keys'.
3163 (push (char-to-string key) keys)
3165 (dolist (elem (accessible-keymaps gnus-summary-mode-map))
3166 (setq key (car elem))
3167 (when (and (> (length key) 0)
3168 (not (eq 'menu-bar (aref key 0)))
3169 (symbolp (lookup-key gnus-summary-mode-map key)))
3172 (unless (lookup-key gnus-article-mode-map key)
3173 (define-key gnus-article-mode-map key 'gnus-article-read-summary-keys))))
3175 (defun gnus-article-make-menu-bar ()
3176 (unless (boundp 'gnus-article-commands-menu)
3177 (gnus-summary-make-menu-bar))
3178 (gnus-turn-off-edit-menu 'article)
3179 (unless (boundp 'gnus-article-article-menu)
3181 gnus-article-article-menu gnus-article-mode-map ""
3183 ["Scroll forwards" gnus-article-goto-next-page t]
3184 ["Scroll backwards" gnus-article-goto-prev-page t]
3185 ["Show summary" gnus-article-show-summary t]
3186 ["Fetch Message-ID at point" gnus-article-refer-article t]
3187 ["Mail to address at point" gnus-article-mail t]
3188 ["Send a bug report" gnus-bug t]))
3191 gnus-article-treatment-menu gnus-article-mode-map ""
3192 ;; Fixme: this should use :active (and maybe :visible).
3194 ["Hide headers" gnus-article-toggle-headers t]
3195 ["Hide signature" gnus-article-hide-signature t]
3196 ["Hide citation" gnus-article-hide-citation t]
3197 ["Treat overstrike" gnus-article-treat-overstrike t]
3198 ["Remove carriage return" gnus-article-remove-cr t]
3199 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3200 ["Decode HZ" gnus-article-decode-HZ t]))
3202 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3204 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3206 (gnus-run-hooks 'gnus-article-menu-hook)))
3208 ;; Fixme: do something for the Emacs tool bar in Article mode a la
3211 (defun gnus-article-mode ()
3212 "Major mode for displaying an article.
3214 All normal editing commands are switched off.
3216 The following commands are available in addition to all summary mode
3218 \\<gnus-article-mode-map>
3219 \\[gnus-article-next-page]\t Scroll the article one page forwards
3220 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3221 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3222 \\[gnus-article-show-summary]\t Display the summary buffer
3223 \\[gnus-article-mail]\t Send a reply to the address near point
3224 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3225 \\[gnus-info-find-node]\t Go to the Gnus info node"
3227 (gnus-simplify-mode-line)
3228 (setq mode-name "Article")
3229 (setq major-mode 'gnus-article-mode)
3230 (make-local-variable 'minor-mode-alist)
3231 (unless (assq 'gnus-show-mime minor-mode-alist)
3232 (push (list 'gnus-show-mime " MIME") minor-mode-alist))
3233 (use-local-map gnus-article-mode-map)
3234 (when (gnus-visual-p 'article-menu 'menu)
3235 (gnus-article-make-menu-bar))
3236 (gnus-update-format-specifications nil 'article-mode)
3237 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3238 (make-local-variable 'gnus-page-broken)
3239 (make-local-variable 'gnus-button-marker-list)
3240 (make-local-variable 'gnus-article-current-summary)
3241 (make-local-variable 'gnus-article-mime-handles)
3242 (make-local-variable 'gnus-article-decoded-p)
3243 (make-local-variable 'gnus-article-mime-handle-alist)
3244 (make-local-variable 'gnus-article-wash-types)
3245 (make-local-variable 'gnus-article-charset)
3246 (make-local-variable 'gnus-article-ignored-charsets)
3247 (gnus-set-default-directory)
3248 (buffer-disable-undo)
3249 (setq buffer-read-only t)
3250 (set-syntax-table gnus-article-mode-syntax-table)
3251 (gnus-run-hooks 'gnus-article-mode-hook))
3253 (defun gnus-article-setup-buffer ()
3254 "Initialize the article buffer."
3255 (let* ((name (if gnus-single-article-buffer "*Article*"
3256 (concat "*Article " gnus-newsgroup-name "*")))
3258 (progn (string-match "\\*Article" name)
3259 (concat " *Original Article"
3260 (substring name (match-end 0))))))
3261 (setq gnus-article-buffer name)
3262 (setq gnus-original-article-buffer original)
3263 (setq gnus-article-mime-handle-alist nil)
3264 ;; This might be a variable local to the summary buffer.
3265 (unless gnus-single-article-buffer
3267 (set-buffer gnus-summary-buffer)
3268 (setq gnus-article-buffer name)
3269 (setq gnus-original-article-buffer original)
3270 (gnus-set-global-variables)))
3271 (gnus-article-setup-highlight-words)
3272 ;; Init original article buffer.
3274 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3275 (set-buffer-multibyte nil)
3276 (setq major-mode 'gnus-original-article-mode)
3277 (make-local-variable 'gnus-original-article))
3278 (if (get-buffer name)
3281 (buffer-disable-undo)
3282 (setq buffer-read-only t)
3283 (unless (eq major-mode 'gnus-article-mode)
3284 (gnus-article-mode))
3287 (set-buffer (gnus-get-buffer-create name))
3289 (make-local-variable 'gnus-summary-buffer)
3290 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3291 (current-buffer)))))
3293 ;; Set article window start at LINE, where LINE is the number of lines
3294 ;; from the head of the article.
3295 (defun gnus-article-set-window-start (&optional line)
3297 (get-buffer-window gnus-article-buffer t)
3299 (set-buffer gnus-article-buffer)
3300 (goto-char (point-min))
3303 (gnus-message 6 "Moved to bookmark")
3304 (search-forward "\n\n" nil t)
3308 ;;; @@ article filters
3311 (defun gnus-article-display-mime-message ()
3312 "Article display method for MIME message."
3313 ;; called from `gnus-original-article-buffer'.
3314 (let (charset all-headers)
3315 (with-current-buffer gnus-summary-buffer
3316 (setq charset default-mime-charset
3317 all-headers gnus-have-all-headers))
3318 (make-local-variable 'default-mime-charset)
3319 (setq default-mime-charset charset)
3320 (with-current-buffer (get-buffer-create gnus-article-buffer)
3321 (make-local-variable 'default-mime-charset)
3322 (setq default-mime-charset charset))
3323 (mime-display-message mime-message-structure
3324 gnus-article-buffer nil gnus-article-mode-map)
3326 (gnus-article-hide-headers nil -1)))
3327 (run-hooks 'gnus-mime-article-prepare-hook))
3329 (defun gnus-article-display-traditional-message ()
3330 "Article display method for traditional message."
3331 (set-buffer gnus-article-buffer)
3332 (let (buffer-read-only)
3334 (insert-buffer-substring gnus-original-article-buffer)))
3336 (defun gnus-article-make-full-mail-header (&optional number charset)
3337 "Create a new mail header structure in a raw article buffer."
3338 (unless (and number charset)
3339 (save-current-buffer
3340 (set-buffer gnus-summary-buffer)
3342 (setq number (or (cdr gnus-article-current) 0)))
3344 (setq charset (or default-mime-charset 'x-ctext)))))
3345 (goto-char (point-min))
3346 (let ((header-end (if (search-forward "\n\n" nil t)
3348 (goto-char (point-max))))
3349 (chars (- (point-max) (point)))
3350 (lines (count-lines (point) (point-max)))
3351 (default-mime-charset charset)
3353 (narrow-to-region (point-min) header-end)
3354 (setq xref (std11-fetch-field "xref"))
3356 (make-full-mail-header
3358 (std11-fetch-field "subject")
3359 (std11-fetch-field "from")
3360 (std11-fetch-field "date")
3361 (std11-fetch-field "message-id")
3362 (std11-fetch-field "references")
3365 (when xref (concat "Xref: " xref)))
3368 (defun gnus-article-prepare (article &optional all-headers header)
3369 "Prepare ARTICLE in article mode buffer.
3370 ARTICLE should either be an article number or a Message-ID.
3371 If ARTICLE is an id, HEADER should be the article headers.
3372 If ALL-HEADERS is non-nil, no headers are hidden."
3374 ;; Make sure we start in a summary buffer.
3375 (unless (eq major-mode 'gnus-summary-mode)
3376 (set-buffer gnus-summary-buffer))
3377 (setq gnus-summary-buffer (current-buffer))
3378 (let* ((gnus-article (if header (mail-header-number header) article))
3379 (summary-buffer (current-buffer))
3380 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3381 (group gnus-newsgroup-name)
3384 (gnus-article-setup-buffer)
3385 (set-buffer gnus-article-buffer)
3386 ;; Deactivate active regions.
3387 (when (and (boundp 'transient-mark-mode)
3388 transient-mark-mode)
3389 (setq mark-active nil))
3390 (if (not (setq result (let ((buffer-read-only nil))
3391 (gnus-request-article-this-buffer
3393 ;; There is no such article.
3395 (when (and (numberp article)
3396 (not (memq article gnus-newsgroup-sparse)))
3397 (setq gnus-article-current
3398 (cons gnus-newsgroup-name article))
3399 (set-buffer gnus-summary-buffer)
3400 (setq gnus-current-article article)
3401 (if (eq (gnus-article-mark article) gnus-undownloaded-mark)
3403 (gnus-summary-set-agent-mark article)
3404 (message "Message marked for downloading"))
3405 (gnus-summary-mark-article article gnus-canceled-mark)
3406 (unless (memq article gnus-newsgroup-sparse)
3407 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3408 (if (or (eq result 'pseudo)
3409 (eq result 'nneething))
3412 (set-buffer summary-buffer)
3413 (push article gnus-newsgroup-history)
3414 (setq gnus-last-article gnus-current-article
3415 gnus-current-article 0
3416 gnus-current-headers nil
3417 gnus-article-current nil)
3418 (if (eq result 'nneething)
3419 (gnus-configure-windows 'summary)
3420 (gnus-configure-windows 'article))
3421 (gnus-set-global-variables))
3422 (let ((gnus-article-mime-handle-alist-1
3423 gnus-article-mime-handle-alist))
3424 (gnus-set-mode-line 'article)))
3425 ;; The result from the `request' was an actual article -
3426 ;; or at least some text that is now displayed in the
3428 (when (and (numberp article)
3429 (not (eq article gnus-current-article)))
3430 ;; Seems like a new article has been selected.
3431 ;; `gnus-current-article' must be an article number.
3433 (set-buffer summary-buffer)
3434 (push article gnus-newsgroup-history)
3435 (setq gnus-last-article gnus-current-article
3436 gnus-current-article article
3437 gnus-current-headers
3438 (gnus-summary-article-header gnus-current-article)
3439 gnus-article-current
3440 (cons gnus-newsgroup-name gnus-current-article))
3441 (unless (vectorp gnus-current-headers)
3442 (setq gnus-current-headers nil))
3443 (gnus-summary-goto-subject gnus-current-article)
3444 (when (gnus-summary-show-thread)
3445 ;; If the summary buffer really was folded, the
3446 ;; previous goto may not actually have gone to
3447 ;; the right article, but the thread root instead.
3449 (gnus-summary-goto-subject gnus-current-article))
3450 (gnus-run-hooks 'gnus-mark-article-hook)
3451 (gnus-set-mode-line 'summary)
3452 (when (gnus-visual-p 'article-highlight 'highlight)
3453 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3454 ;; Set the global newsgroup variables here.
3455 (gnus-set-global-variables)
3456 (setq gnus-have-all-headers
3457 (or all-headers gnus-show-all-headers))))
3459 (gnus-configure-windows 'article))
3460 (when (or (numberp article)
3462 (gnus-article-prepare-display)
3464 (goto-char (point-min))
3465 (setq gnus-page-broken
3466 (when gnus-break-pages
3467 (gnus-narrow-to-page)
3469 (let ((gnus-article-mime-handle-alist-1
3470 gnus-article-mime-handle-alist))
3471 (gnus-set-mode-line 'article))
3473 (set-window-point (get-buffer-window (current-buffer)) (point))
3474 (gnus-configure-windows 'article)
3477 (defun gnus-article-prepare-mime-display (&optional number)
3478 (goto-char (point-min))
3479 (when (re-search-forward "^[^\t ]+:" nil t)
3480 (goto-char (match-beginning 0)))
3481 (let ((entity (if (eq 1 (point-min))
3482 (get-text-property 1 'mime-view-entity)
3483 (get-text-property (point) 'mime-view-entity)))
3484 last-entity child-entity next type)
3485 (setq child-entity (mime-entity-children entity))
3487 (setq last-entity (nth (1- (length child-entity))
3489 (setq last-entity entity))
3491 (narrow-to-region (point)
3492 (if (search-forward "\n\n" nil t)
3495 (gnus-treat-article 'head)
3496 (put-text-property (point-min) (point-max) 'article-treated-header t)
3497 (goto-char (point-max)))
3498 (while (and (not (eobp)) entity)
3499 (setq next (set-marker
3501 (next-single-property-change (point) 'mime-view-entity
3503 (let ((types (mime-entity-content-type entity)))
3504 (while (eq 'multipart (mime-content-type-primary-type types))
3505 (setq entity (car (mime-entity-children entity))
3506 types (mime-entity-content-type entity)))
3508 (setq type (format "%s/%s"
3509 (mime-content-type-primary-type types)
3510 (mime-content-type-subtype types)))))
3511 (if (string-equal type "message/rfc822")
3514 (let ((children (mime-entity-children entity))
3517 (setq last-children (nth (1- (length children)) children))
3520 (not (eq last-children
3521 (get-text-property next 'mime-view-entity)))
3523 (next-single-property-change next
3525 nil (point-max)))))))
3526 (setq next (next-single-property-change next 'mime-view-entity
3529 (narrow-to-region (point) next)
3530 (gnus-article-prepare-mime-display)
3531 (goto-char (point-max)))
3532 (setq entity (get-text-property (point) 'mime-view-entity)))
3534 (narrow-to-region (point) next)
3535 ;; Kludge. We have to count true number, but for now,
3536 ;; part number is here only to achieve `last'.
3537 (gnus-treat-article nil 1
3538 (if (eq entity last-entity)
3541 (goto-char (point-max)))
3542 (setq entity (get-text-property next 'mime-view-entity))))))
3545 (defun gnus-article-prepare-display ()
3546 "Make the current buffer look like a nice article."
3547 (let ((gnus-article-buffer (current-buffer))
3549 (unless (eq major-mode 'gnus-article-mode)
3550 (gnus-article-mode))
3551 (setq buffer-read-only nil
3552 gnus-button-marker-list nil
3553 gnus-article-wash-types nil)
3556 (static-if (featurep 'xemacs)
3557 (map-extents (lambda (extent maparg) (delete-extent extent)))
3558 (let ((lists (overlay-lists)))
3559 (dolist (overlay (nconc (car lists) (cdr lists)))
3560 (delete-overlay overlay)))))
3561 (gnus-run-hooks 'gnus-tmp-internal-hook))
3562 (set-buffer gnus-original-article-buffer)
3564 (setq mime-message-structure gnus-current-headers)
3565 (mime-buffer-entity-set-buffer-internal mime-message-structure
3566 gnus-original-article-buffer)
3567 (mime-entity-set-representation-type-internal mime-message-structure
3568 'mime-buffer-entity)
3569 (luna-send mime-message-structure 'initialize-instance
3570 mime-message-structure)
3572 (let (mime-display-header-hook mime-display-text/plain-hook)
3573 (funcall gnus-article-display-method-for-mime))
3574 (funcall gnus-article-display-method-for-traditional))
3575 ;; Call the treatment functions.
3576 (let ((inhibit-read-only t))
3580 (gnus-article-prepare-mime-display)
3581 (narrow-to-region (goto-char (point-min))
3582 (if (search-forward "\n\n" nil t)
3585 (gnus-treat-article 'head)
3586 (put-text-property (point-min) (point-max) 'article-treated-header t)
3587 (goto-char (point-max))
3589 (narrow-to-region (point) (point-max))
3590 (gnus-treat-article nil))
3591 (put-text-property (point-min) (point-max) 'read-only nil)))
3592 (gnus-run-hooks 'gnus-article-prepare-hook))
3594 (defun gnus-article-decode-article-as-default-mime-charset ()
3595 "Decode an article as `default-mime-charset'. It won't work if the
3596 value of the variable `gnus-show-mime' is non-nil."
3597 (unless gnus-show-mime
3598 (set (make-local-variable 'default-mime-charset)
3599 (with-current-buffer gnus-summary-buffer
3600 default-mime-charset))
3601 (decode-mime-charset-region (point-min) (point-max)
3602 default-mime-charset)))
3605 ;;; Gnus MIME viewing functions
3608 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3609 "The following specs can be used:
3611 %T MIME type, along with additional info
3612 %n The `name' parameter
3613 %d The description, if any
3614 %l The length of the encoded part
3615 %p The part identifier number
3616 %e Dots if the part isn't displayed")
3618 (defvar gnus-mime-button-line-format-alist
3619 '((?t gnus-tmp-type ?s)
3620 (?T gnus-tmp-type-long ?s)
3621 (?n gnus-tmp-name ?s)
3622 (?d gnus-tmp-description ?s)
3624 (?l gnus-tmp-length ?d)
3625 (?e gnus-tmp-dots ?s)))
3627 (defvar gnus-mime-button-commands
3628 '((gnus-article-press-button "\r" "Toggle Display")
3629 (gnus-mime-view-part "v" "View Interactively...")
3630 (gnus-mime-view-part-as-type "t" "View As Type...")
3631 (gnus-mime-view-part-as-charset "C" "View As charset...")
3632 (gnus-mime-save-part "o" "Save...")
3633 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
3634 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
3635 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
3636 (gnus-mime-internalize-part "E" "View Internally")
3637 (gnus-mime-externalize-part "e" "View Externally")
3638 (gnus-mime-pipe-part "|" "Pipe To Command...")
3639 (gnus-mime-action-on-part "." "Take action on the part")))
3641 (defun gnus-article-mime-part-status ()
3642 (with-current-buffer gnus-article-buffer
3643 (let ((entity (get-text-property (point-min) 'mime-view-entity))
3646 (setq children (mime-entity-children entity))
3647 (setq children (length children)))
3650 (format " (%d parts)" children))
3653 (defvar gnus-mime-button-map
3654 (let ((map (make-sparse-keymap)))
3655 (unless (>= (string-to-number emacs-version) 21)
3656 ;; XEmacs doesn't care.
3657 (set-keymap-parent map gnus-article-mode-map))
3658 (define-key map gnus-mouse-2 'gnus-article-push-button)
3659 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
3660 (dolist (c gnus-mime-button-commands)
3661 (define-key map (cadr c) (car c)))
3664 (defun gnus-mime-button-menu (event)
3665 "Construct a context-sensitive menu of MIME commands."
3667 (save-window-excursion
3668 (let ((pos (event-start event)))
3669 (select-window (posn-window pos))
3670 (goto-char (posn-point pos))
3671 (gnus-article-check-buffer)
3672 (let ((response (x-popup-menu
3674 ("" ,@(mapcar (lambda (c)
3675 (cons (caddr c) (car c)))
3676 gnus-mime-button-commands))))))
3678 (call-interactively response))))))
3680 (defun gnus-mime-view-all-parts (&optional handles)
3681 "View all the MIME parts."
3683 (save-current-buffer
3684 (set-buffer gnus-article-buffer)
3685 (let ((handles (or handles gnus-article-mime-handles))
3686 (mail-parse-charset gnus-newsgroup-charset)
3687 (mail-parse-ignored-charsets
3688 (with-current-buffer gnus-summary-buffer
3689 gnus-newsgroup-ignored-charsets)))
3691 (mm-remove-parts handles)
3692 (goto-char (point-min))
3693 (or (search-forward "\n\n") (goto-char (point-max)))
3694 (let (buffer-read-only)
3695 (delete-region (point) (point-max))
3696 (mm-display-parts handles))))))
3698 (defun gnus-mime-save-part-and-strip ()
3699 "Save the MIME part under point then replace it with an external body."
3701 (gnus-article-check-buffer)
3702 (let* ((data (get-text-property (point) 'gnus-data))
3704 (handles gnus-article-mime-handles))
3705 (if (mm-multiple-handles gnus-article-mime-handles)
3706 (error "This function is not implemented"))
3707 (setq file (and data (mm-save-part data)))
3709 (with-current-buffer (mm-handle-buffer data)
3711 (insert "Content-Type: " (mm-handle-media-type data))
3712 (mml-insert-parameter-string (cdr (mm-handle-type data))
3715 (insert "Content-ID: " (message-make-message-id) "\n")
3716 (insert "Content-Transfer-Encoding: binary\n")
3719 (cdr (mm-make-handle nil
3720 `("message/external-body"
3721 (access-type . "LOCAL-FILE")
3723 (set-buffer gnus-summary-buffer)
3724 (gnus-article-edit-article
3727 (let ((mail-parse-charset (or gnus-article-charset
3728 ',gnus-newsgroup-charset))
3729 (mail-parse-ignored-charsets
3730 (or gnus-article-ignored-charsets
3731 ',gnus-newsgroup-ignored-charsets))
3732 (mbl mml-buffer-list))
3733 (setq mml-buffer-list nil)
3734 (insert-buffer gnus-original-article-buffer)
3735 (mime-to-mml ',handles)
3736 (setq gnus-article-mime-handles nil)
3737 (let ((mbl1 mml-buffer-list))
3738 (setq mml-buffer-list mbl)
3739 (set (make-local-variable 'mml-buffer-list) mbl1))
3740 ;; LOCAL argument of add-hook differs between GNU Emacs
3741 ;; and XEmacs. make-local-hook makes sure they are local.
3742 (make-local-hook 'kill-buffer-hook)
3743 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
3744 `(lambda (no-highlight)
3745 (let ((mail-parse-charset (or gnus-article-charset
3746 ',gnus-newsgroup-charset))
3747 (message-options message-options)
3748 (message-options-set-recipient)
3749 (mail-parse-ignored-charsets
3750 (or gnus-article-ignored-charsets
3751 ',gnus-newsgroup-ignored-charsets)))
3753 (mml-destroy-buffers)
3754 (remove-hook 'kill-buffer-hook
3755 'mml-destroy-buffers t)
3756 (kill-local-variable 'mml-buffer-list))
3757 (gnus-summary-edit-article-done
3758 ,(or (mail-header-references gnus-current-headers) "")
3759 ,(gnus-group-read-only-p)
3760 ,gnus-summary-buffer no-highlight))))))
3762 (defun gnus-mime-save-part ()
3763 "Save the MIME part under point."
3765 (gnus-article-check-buffer)
3766 (let ((data (get-text-property (point) 'gnus-data)))
3768 (mm-save-part data))))
3770 (defun gnus-mime-pipe-part ()
3771 "Pipe the MIME part under point to a process."
3773 (gnus-article-check-buffer)
3774 (let ((data (get-text-property (point) 'gnus-data)))
3776 (mm-pipe-part data))))
3778 (defun gnus-mime-view-part ()
3779 "Interactively choose a viewing method for the MIME part under point."
3781 (gnus-article-check-buffer)
3782 (let ((data (get-text-property (point) 'gnus-data)))
3784 (setq gnus-article-mime-handles
3786 gnus-article-mime-handles (setq data (copy-sequence data))))
3787 (mm-interactively-view-part data))))
3789 (defun gnus-mime-view-part-as-type-internal ()
3790 (gnus-article-check-buffer)
3791 (let* ((name (mail-content-type-get
3792 (mm-handle-type (get-text-property (point) 'gnus-data))
3794 (def-type (and name (mm-default-file-encoding name))))
3795 (and def-type (cons def-type 0))))
3797 (defun gnus-mime-view-part-as-type (&optional mime-type)
3798 "Choose a MIME media type, and view the part as such."
3801 (setq mime-type (completing-read
3802 "View as MIME type: "
3803 (mapcar #'list (mailcap-mime-types))
3805 (gnus-mime-view-part-as-type-internal))))
3806 (gnus-article-check-buffer)
3807 (let ((handle (get-text-property (point) 'gnus-data)))
3810 (mm-make-handle (mm-handle-buffer handle)
3811 (cons mime-type (cdr (mm-handle-type handle)))
3812 (mm-handle-encoding handle)
3813 (mm-handle-undisplayer handle)
3814 (mm-handle-disposition handle)
3815 (mm-handle-description handle)
3817 (mm-handle-id handle)))
3818 (setq gnus-article-mime-handles
3819 (mm-merge-handles gnus-article-mime-handles handle))
3820 (gnus-mm-display-part handle))))
3822 (defun gnus-mime-copy-part (&optional handle)
3823 "Put the the MIME part under point into a new buffer."
3825 (gnus-article-check-buffer)
3826 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3827 (contents (and handle (mm-get-part handle)))
3829 (file-name-nondirectory
3831 (mail-content-type-get (mm-handle-type handle) 'name)
3832 (mail-content-type-get (mm-handle-type handle)
3835 (buffer (and base (generate-new-buffer base))))
3837 (switch-to-buffer buffer)
3839 ;; We do it this way to make `normal-mode' set the appropriate mode.
3842 (setq buffer-file-name (expand-file-name base))
3844 (setq buffer-file-name nil))
3845 (goto-char (point-min)))))
3847 (defun gnus-mime-inline-part (&optional handle arg)
3848 "Insert the MIME part under point into the current buffer."
3849 (interactive (list nil current-prefix-arg))
3850 (gnus-article-check-buffer)
3851 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3856 (if (and (not arg) (mm-handle-undisplayer handle))
3857 (mm-remove-part handle)
3858 (setq contents (mm-get-part handle))
3861 (setq charset (or (mail-content-type-get
3862 (mm-handle-type handle) 'charset)
3863 gnus-newsgroup-charset)))
3865 (if (mm-handle-undisplayer handle)
3866 (mm-remove-part handle))
3869 gnus-summary-show-article-charset-alist))
3870 (mm-read-coding-system "Charset: ")))))
3872 (mm-insert-inline handle
3874 (setq charset (mm-charset-to-coding-system
3876 (not (eq charset 'ascii)))
3877 (mm-decode-coding-string contents charset)
3881 (defun gnus-mime-view-part-as-charset (&optional handle arg)
3882 "Insert the MIME part under point into the current buffer using the
3884 (interactive (list nil current-prefix-arg))
3885 (gnus-article-check-buffer)
3886 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3891 (if (mm-handle-undisplayer handle)
3892 (mm-remove-part handle))
3893 (let ((gnus-newsgroup-charset
3895 gnus-summary-show-article-charset-alist))
3896 (mm-read-coding-system "Charset: ")))
3897 (gnus-newsgroup-ignored-charsets 'gnus-all))
3898 (gnus-article-press-button)))))
3900 (defun gnus-mime-externalize-part (&optional handle)
3901 "View the MIME part under point with an external viewer."
3903 (gnus-article-check-buffer)
3904 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3905 (mm-user-display-methods nil)
3906 (mm-inlined-types nil)
3907 (mail-parse-charset gnus-newsgroup-charset)
3908 (mail-parse-ignored-charsets
3909 (save-excursion (set-buffer gnus-summary-buffer)
3910 gnus-newsgroup-ignored-charsets)))
3912 (if (mm-handle-undisplayer handle)
3913 (mm-remove-part handle)
3914 (mm-display-part handle)))))
3916 (defun gnus-mime-internalize-part (&optional handle)
3917 "View the MIME part under point with an internal viewer.
3918 If no internal viewer is available, use an external viewer."
3920 (gnus-article-check-buffer)
3921 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3922 (mm-inlined-types '(".*"))
3923 (mm-inline-large-images t)
3924 (mail-parse-charset gnus-newsgroup-charset)
3925 (mail-parse-ignored-charsets
3926 (save-excursion (set-buffer gnus-summary-buffer)
3927 gnus-newsgroup-ignored-charsets)))
3929 (if (mm-handle-undisplayer handle)
3930 (mm-remove-part handle)
3931 (mm-display-part handle)))))
3933 (defun gnus-mime-action-on-part (&optional action)
3934 "Do something with the MIME attachment at \(point\)."
3936 (list (completing-read "Action: " gnus-mime-action-alist)))
3937 (gnus-article-check-buffer)
3938 (let ((action-pair (assoc action gnus-mime-action-alist)))
3940 (funcall (cdr action-pair)))))
3942 (defun gnus-article-part-wrapper (n function)
3943 (save-current-buffer
3944 (set-buffer gnus-article-buffer)
3945 (when (> n (length gnus-article-mime-handle-alist))
3946 (error "No such part"))
3947 (gnus-article-goto-part n)
3948 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
3949 (funcall function handle))))
3951 (defun gnus-article-pipe-part (n)
3952 "Pipe MIME part N, which is the numerical prefix."
3954 (gnus-article-part-wrapper n 'mm-pipe-part))
3956 (defun gnus-article-save-part (n)
3957 "Save MIME part N, which is the numerical prefix."
3959 (gnus-article-part-wrapper n 'mm-save-part))
3961 (defun gnus-article-interactively-view-part (n)
3962 "View MIME part N interactively, which is the numerical prefix."
3964 (gnus-article-part-wrapper n 'mm-interactively-view-part))
3966 (defun gnus-article-copy-part (n)
3967 "Copy MIME part N, which is the numerical prefix."
3969 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
3971 (defun gnus-article-view-part-as-charset (n)
3972 "Copy MIME part N, which is the numerical prefix."
3974 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
3976 (defun gnus-article-externalize-part (n)
3977 "View MIME part N externally, which is the numerical prefix."
3979 (gnus-article-part-wrapper n 'gnus-mime-externalize-part))
3981 (defun gnus-article-inline-part (n)
3982 "Inline MIME part N, which is the numerical prefix."
3984 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
3986 (defun gnus-article-mime-match-handle-first (condition)
3988 (let ((alist gnus-article-mime-handle-alist) ihandle n)
3989 (while (setq ihandle (pop alist))
3991 ((functionp condition)
3992 (funcall condition (cdr ihandle)))
3993 ((eq condition 'undisplayed)
3994 (not (or (mm-handle-undisplayer (cdr ihandle))
3995 (equal (mm-handle-media-type (cdr ihandle))
3996 "multipart/alternative"))))
3997 ((eq condition 'undisplayed-alternative)
3998 (not (mm-handle-undisplayer (cdr ihandle))))
4000 (gnus-article-goto-part (car ihandle))
4001 (or (not n) (< (car ihandle) n)))
4002 (setq n (car ihandle))))
4006 (defun gnus-article-view-part (&optional n)
4007 "View MIME part N, which is the numerical prefix."
4009 (save-current-buffer
4010 (set-buffer gnus-article-buffer)
4011 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4012 gnus-article-mime-match-handle-function)))
4013 (when (> n (length gnus-article-mime-handle-alist))
4014 (error "No such part"))
4015 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4016 (when (gnus-article-goto-part n)
4017 (if (equal (car handle) "multipart/alternative")
4018 (gnus-article-press-button)
4019 (when (eq (gnus-mm-display-part handle) 'internal)
4020 (gnus-set-window-start)))))))
4022 (defsubst gnus-article-mime-total-parts ()
4023 (if (bufferp (car gnus-article-mime-handles))
4025 (1- (length gnus-article-mime-handles))))
4027 (defun gnus-mm-display-part (handle)
4028 "Display HANDLE and fix MIME button."
4029 (let ((id (get-text-property (point) 'gnus-part))
4034 (let ((window (selected-window))
4035 (mail-parse-charset gnus-newsgroup-charset)
4036 (mail-parse-ignored-charsets
4037 (save-excursion (set-buffer gnus-summary-buffer)
4038 gnus-newsgroup-ignored-charsets)))
4041 (let ((win (get-buffer-window (current-buffer) t))
4044 (select-window win))
4047 (if (mm-handle-displayed-p handle)
4048 ;; This will remove the part.
4049 (mm-display-part handle)
4051 (narrow-to-region (point)
4052 (if (eobp) (point) (1+ (point))))
4053 (mm-display-part handle)
4054 ;; We narrow to the part itself and
4055 ;; then call the treatment functions.
4056 (goto-char (point-min))
4058 (narrow-to-region (point) (point-max))
4061 (gnus-article-mime-total-parts)
4062 (mm-handle-media-type handle)))))
4063 (if (window-live-p window)
4064 (select-window window)))))
4066 (delete-region (gnus-point-at-bol) (progn (forward-line 1) (point)))
4067 (gnus-insert-mime-button
4068 handle id (list (mm-handle-displayed-p handle)))
4069 (goto-char point))))
4071 (defun gnus-article-goto-part (n)
4072 "Go to MIME part N."
4073 (let ((point (text-property-any (point-min) (point-max) 'gnus-part n)))
4075 (goto-char point))))
4077 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4078 (let ((gnus-tmp-name
4079 (or (mail-content-type-get (mm-handle-type handle) 'name)
4080 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4081 (mail-content-type-get (mm-handle-type handle) 'url)
4083 (gnus-tmp-type (mm-handle-media-type handle))
4084 (gnus-tmp-description
4085 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4088 (if (if displayed (car displayed)
4089 (mm-handle-displayed-p handle))
4091 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4093 gnus-tmp-type-long b e)
4094 (when (string-match ".*/" gnus-tmp-name)
4095 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4096 (setq gnus-tmp-type-long (concat gnus-tmp-type
4097 (and (not (equal gnus-tmp-name ""))
4098 (concat "; " gnus-tmp-name))))
4099 (unless (equal gnus-tmp-description "")
4100 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4105 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4106 `(keymap ,gnus-mime-button-map
4107 ,@(if (>= (string-to-number emacs-version) 21)
4109 (list 'local-map gnus-mime-button-map))
4110 gnus-callback gnus-mm-display-part
4111 gnus-part ,gnus-tmp-id
4112 article-type annotation
4115 (widget-convert-button
4118 :action 'gnus-widget-press-button
4119 :button-keymap gnus-mime-button-map
4121 (lambda (widget/window &optional overlay pos)
4122 ;; Needed to properly clear the message due to a bug in
4123 ;; wid-edit (XEmacs only).
4124 (if (boundp 'help-echo-owns-message)
4125 (setq help-echo-owns-message t))
4127 "%S: %s the MIME part; %S: more options"
4128 (aref gnus-mouse-2 0)
4129 ;; XEmacs will get a single widget arg; Emacs 21 will get
4130 ;; window, overlay, position.
4131 (if (mm-handle-displayed-p
4133 (with-current-buffer (gnus-overlay-buffer overlay)
4134 (widget-get (widget-at (gnus-overlay-start overlay))
4136 (widget-get widget/window :mime-handle)))
4138 (aref gnus-down-mouse-3 0))))))
4140 (defun gnus-widget-press-button (elems el)
4141 (goto-char (widget-get elems :from))
4142 (gnus-article-press-button))
4144 (defvar gnus-displaying-mime nil)
4146 (defun gnus-display-mime (&optional ihandles)
4147 "Display the MIME parts."
4149 (save-selected-window
4150 (let ((window (get-buffer-window gnus-article-buffer))
4153 (select-window window)
4154 ;; We have to do this since selecting the window
4155 ;; may change the point. So we set the window point.
4156 (set-window-point window point)))
4157 (let* ((handles (or ihandles (mm-dissect-buffer) (mm-uu-dissect)))
4158 buffer-read-only handle name type b e display)
4159 (when (and (not ihandles)
4160 (not gnus-displaying-mime))
4161 ;; Top-level call; we clean up.
4162 (when gnus-article-mime-handles
4163 (mm-destroy-parts gnus-article-mime-handles)
4164 (setq gnus-article-mime-handle-alist nil));; A trick.
4165 (setq gnus-article-mime-handles handles)
4166 ;; We allow users to glean info from the handles.
4167 (when gnus-article-mime-part-function
4168 (gnus-mime-part-function handles)))
4170 (or (not (stringp (car handles)))
4173 (when (and (not ihandles)
4174 (not gnus-displaying-mime))
4175 ;; Clean up for mime parts.
4177 (delete-region (point) (point-max)))
4178 (let ((gnus-displaying-mime t))
4179 (gnus-mime-display-part handles)))
4182 (narrow-to-region (point) (point-max))
4183 (gnus-treat-article nil 1 1)
4186 ;; Highlight the headers.
4190 (narrow-to-region (point-min) (point))
4191 (gnus-treat-article 'head))))))))
4193 (defvar gnus-mime-display-multipart-as-mixed nil)
4194 (defvar gnus-mime-display-multipart-alternative-as-mixed nil)
4195 (defvar gnus-mime-display-multipart-related-as-mixed nil)
4197 (defun gnus-mime-display-part (handle)
4200 ((not (stringp (car handle)))
4201 (gnus-mime-display-single handle))
4202 ;; User-defined multipart
4203 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4204 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4206 ;; multipart/alternative
4207 ((and (equal (car handle) "multipart/alternative")
4208 (not (or gnus-mime-display-multipart-as-mixed
4209 gnus-mime-display-multipart-alternative-as-mixed)))
4210 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4211 (push (cons id handle) gnus-article-mime-handle-alist)
4212 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4213 ;; multipart/related
4214 ((and (equal (car handle) "multipart/related")
4215 (not (or gnus-mime-display-multipart-as-mixed
4216 gnus-mime-display-multipart-related-as-mixed)))
4217 ;;;!!!We should find the start part, but we just default
4218 ;;;!!!to the first part.
4219 ;;(gnus-mime-display-part (cadr handle))
4220 ;;;!!! Most multipart/related is an HTML message plus images.
4221 ;;;!!! Unfortunately we are unable to let W3 display those
4222 ;;;!!! included images, so we just display it as a mixed multipart.
4223 ;;(gnus-mime-display-mixed (cdr handle))
4224 ;;;!!! No, w3 can display everything just fine.
4225 (gnus-mime-display-part (cadr handle)))
4226 ((equal (car handle) "multipart/signed")
4227 (or (memq 'signed gnus-article-wash-types)
4228 (push 'signed gnus-article-wash-types))
4229 (gnus-mime-display-security handle))
4230 ((equal (car handle) "multipart/encrypted")
4231 (or (memq 'encrypted gnus-article-wash-types)
4232 (push 'encrypted gnus-article-wash-types))
4233 (gnus-mime-display-security handle))
4234 ;; Other multiparts are handled like multipart/mixed.
4236 (gnus-mime-display-mixed (cdr handle)))))
4238 (defun gnus-mime-part-function (handles)
4239 (if (stringp (car handles))
4240 (mapcar 'gnus-mime-part-function (cdr handles))
4241 (funcall gnus-article-mime-part-function handles)))
4243 (defun gnus-mime-display-mixed (handles)
4244 (mapcar 'gnus-mime-display-part handles))
4246 (defun gnus-mime-display-single (handle)
4247 (let ((type (mm-handle-media-type handle))
4248 (ignored gnus-ignored-mime-types)
4255 (when (string-match (pop ignored) type)
4256 (throw 'ignored nil)))
4257 (if (and (setq not-attachment
4258 (and (not (mm-inline-override-p handle))
4259 (or (not (mm-handle-disposition handle))
4260 (equal (car (mm-handle-disposition handle))
4262 (mm-attachment-override-p handle))))
4263 (mm-automatic-display-p handle)
4265 (mm-inlinable-p handle)
4266 (mm-inlined-p handle))
4267 (mm-automatic-external-display-p type)))
4269 (when (equal (mm-handle-media-supertype handle) "text")
4271 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4273 (push (cons id handle) gnus-article-mime-handle-alist)
4274 (when (or (not display)
4275 (not (gnus-unbuttonized-mime-type-p type)))
4276 ;(gnus-article-insert-newline)
4277 (gnus-insert-mime-button
4278 handle id (list (or display (and not-attachment text))))
4279 (gnus-article-insert-newline)
4280 ;(gnus-article-insert-newline)
4281 ;; Remember modify the number of forward lines.
4289 (let ((mail-parse-charset gnus-newsgroup-charset)
4290 (mail-parse-ignored-charsets
4291 (save-excursion (condition-case ()
4292 (set-buffer gnus-summary-buffer)
4294 gnus-newsgroup-ignored-charsets)))
4295 (mm-display-part handle t))
4296 (goto-char (point-max)))
4297 ((and text not-attachment)
4301 (gnus-article-insert-newline)
4302 (mm-insert-inline handle (mm-get-part handle))
4303 (goto-char (point-max))))
4307 (narrow-to-region beg (point))
4310 (gnus-article-mime-total-parts)
4311 (mm-handle-media-type handle)))))))))
4313 (defun gnus-unbuttonized-mime-type-p (type)
4314 "Say whether TYPE is to be unbuttonized."
4315 (unless gnus-inhibit-mime-unbuttonizing
4317 (let ((types gnus-unbuttonized-mime-types))
4319 (when (string-match (pop types) type)
4320 (throw 'found t)))))))
4322 (defun gnus-article-insert-newline ()
4323 "Insert a newline, but mark it as undeletable."
4324 (gnus-put-text-property
4325 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4327 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4328 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4331 handle buffer-read-only from props begend not-pref)
4332 (save-window-excursion
4335 (narrow-to-region (car ibegend)
4338 (goto-char (car ibegend))
4341 (delete-region (point-min) (point-max))
4342 (mm-remove-parts handles))
4343 (setq begend (list (point-marker)))
4345 (unless (setq not-pref (cadr (member preferred ihandles)))
4346 (setq not-pref (car ihandles)))
4349 (not (gnus-unbuttonized-mime-type-p
4350 "multipart/alternative")))
4351 (gnus-add-text-properties
4354 (insert (format "%d. " id))
4358 (unless ,(not ibegend)
4359 (setq gnus-article-mime-handle-alist
4360 ',gnus-article-mime-handle-alist))
4361 (gnus-mime-display-alternative
4362 ',ihandles ',not-pref ',begend ,id))
4363 ,@(if (>= (string-to-number emacs-version) 21)
4364 nil ;; XEmacs doesn't care
4365 (list 'local-map gnus-mime-button-map))
4366 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4367 face ,gnus-article-button-face
4368 keymap ,gnus-mime-button-map
4371 (widget-convert-button 'link from (point)
4372 :action 'gnus-widget-press-button
4373 :button-keymap gnus-widget-button-keymap)
4375 (while (setq handle (pop handles))
4376 (gnus-add-text-properties
4379 (insert (format "(%c) %-18s"
4380 (if (equal handle preferred) ?* ? )
4381 (mm-handle-media-type handle)))
4385 (unless ,(not ibegend)
4386 (setq gnus-article-mime-handle-alist
4387 ',gnus-article-mime-handle-alist))
4388 (gnus-mime-display-alternative
4389 ',ihandles ',handle ',begend ,id))
4390 ,@(if (>= (string-to-number emacs-version) 21)
4391 nil ;; XEmacs doesn't care
4392 (list 'local-map gnus-mime-button-map))
4393 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4394 face ,gnus-article-button-face
4395 keymap ,gnus-mime-button-map
4398 (widget-convert-button 'link from (point)
4399 :action 'gnus-widget-press-button
4400 :button-keymap gnus-widget-button-keymap)
4404 (if (stringp (car preferred))
4405 (gnus-display-mime preferred)
4406 (let ((mail-parse-charset gnus-newsgroup-charset)
4407 (mail-parse-ignored-charsets
4408 (save-excursion (set-buffer gnus-summary-buffer)
4409 gnus-newsgroup-ignored-charsets)))
4410 (mm-display-part preferred)
4414 (narrow-to-region (car begend) (point-max))
4416 nil (length gnus-article-mime-handle-alist)
4417 (gnus-article-mime-total-parts)
4418 (mm-handle-media-type handle))))))
4419 (goto-char (point-max))
4420 (setcdr begend (point-marker)))))
4422 (goto-char point))))
4424 (defun gnus-article-wash-status ()
4425 "Return a string which display status of article washing."
4427 (set-buffer gnus-article-buffer)
4428 (let ((cite (memq 'cite gnus-article-wash-types))
4429 (headers (memq 'headers gnus-article-wash-types))
4430 (boring (memq 'boring-headers gnus-article-wash-types))
4431 (pgp (memq 'pgp gnus-article-wash-types))
4432 (pem (memq 'pem gnus-article-wash-types))
4433 (signed (memq 'signed gnus-article-wash-types))
4434 (encrypted (memq 'encrypted gnus-article-wash-types))
4435 (signature (memq 'signature gnus-article-wash-types))
4436 (overstrike (memq 'overstrike gnus-article-wash-types))
4437 (emphasis (memq 'emphasis gnus-article-wash-types)))
4438 (format "%c%c%c%c%c%c%c"
4440 (if (or headers boring) ?h ? )
4441 (if (or pgp pem signed encrypted) ?p ? )
4442 (if signature ?s ? )
4443 (if overstrike ?o ? )
4444 (if gnus-show-mime ?m ? )
4445 (if emphasis ?e ? )))))
4447 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
4449 (defun gnus-article-maybe-hide-headers ()
4450 "Hide unwanted headers if `gnus-have-all-headers' is nil.
4451 Provided for backwards compatibility."
4452 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
4453 (not (save-excursion (set-buffer gnus-summary-buffer)
4454 gnus-have-all-headers)))
4455 (not gnus-inhibit-hiding))
4456 (gnus-article-hide-headers)))
4460 (defun gnus-output-to-file (file-name)
4461 "Append the current article to a file named FILE-NAME."
4462 (let ((artbuf (current-buffer)))
4464 (insert-buffer-substring artbuf)
4465 ;; Append newline at end of the buffer as separator, and then
4467 (goto-char (point-max))
4469 (let ((file-name-coding-system nnmail-pathname-coding-system)
4470 (pathname-coding-system nnmail-pathname-coding-system))
4471 (write-region-as-binary (point-min) (point-max) file-name 'append))
4474 (defun gnus-narrow-to-page (&optional arg)
4475 "Narrow the article buffer to a page.
4476 If given a numerical ARG, move forward ARG pages."
4478 (setq arg (if arg (prefix-numeric-value arg) 0))
4480 (set-buffer gnus-article-buffer)
4481 (goto-char (point-min))
4483 ;; Remove any old next/prev buttons.
4484 (when (gnus-visual-p 'page-marker)
4485 (let ((buffer-read-only nil))
4486 (gnus-remove-text-with-property 'gnus-prev)
4487 (gnus-remove-text-with-property 'gnus-next)))
4490 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
4492 (re-search-forward page-delimiter nil 'move arg)))
4493 (goto-char (match-end 0)))
4496 (if (re-search-forward page-delimiter nil 'move)
4499 (when (and (gnus-visual-p 'page-marker)
4500 (not (= (point-min) 1)))
4502 (goto-char (point-min))
4503 (gnus-insert-prev-page-button)))
4504 (when (and (gnus-visual-p 'page-marker)
4505 (< (+ (point-max) 2) (buffer-size)))
4507 (goto-char (point-max))
4508 (gnus-insert-next-page-button)))))
4510 ;; Article mode commands
4512 (defun gnus-article-goto-next-page ()
4513 "Show the next page of the article."
4515 (when (gnus-article-next-page)
4516 (goto-char (point-min))
4517 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
4519 (defun gnus-article-goto-prev-page ()
4520 "Show the next page of the article."
4522 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
4523 (gnus-article-prev-page nil)))
4525 (defun gnus-article-next-page (&optional lines)
4526 "Show the next page of the current article.
4527 If end of article, return non-nil. Otherwise return nil.
4528 Argument LINES specifies lines to be scrolled up."
4530 (let ((start (window-start))
4531 end-of-buffer end-of-page)
4533 (move-to-window-line -1)
4534 (if (<= (point) start)
4537 (setq start (point)))
4540 (unless (or (cond ((eq (1+ (buffer-size)) (point))
4541 (and (pos-visible-in-window-p)
4542 (setq end-of-buffer t)))
4544 (setq end-of-page t)))
4546 (move-to-window-line lines)
4547 (unless (search-backward "\n\n" nil t)
4548 (setq start (point)))))
4549 (cond (end-of-buffer t)
4551 (gnus-narrow-to-page 1)
4555 (set-window-start (selected-window) start)
4556 (let (window-pixel-scroll-increment)
4560 (defun gnus-article-prev-page (&optional lines)
4561 "Show previous page of current article.
4562 Argument LINES specifies lines to be scrolled down."
4564 (let (beginning-of-buffer beginning-of-page)
4566 (move-to-window-line 0)
4567 (cond ((eq 1 (point))
4568 (setq beginning-of-buffer t))
4570 (setq beginning-of-page t))))
4571 (cond (beginning-of-buffer)
4573 (gnus-narrow-to-page -1))
4576 (let (window-pixel-scroll-increment)
4577 (scroll-down lines))
4578 (beginning-of-buffer
4579 (goto-char (point-min))))))))
4581 (defun gnus-article-refer-article ()
4582 "Read article specified by message-id around point."
4584 (let ((point (point)))
4585 (search-forward ">" nil t) ;Move point to end of "<....>".
4586 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
4587 (let ((message-id (match-string 1)))
4589 (set-buffer gnus-summary-buffer)
4590 (gnus-summary-refer-article message-id))
4592 (error "No references around point"))))
4594 (defun gnus-article-show-summary ()
4595 "Reconfigure windows to show summary buffer."
4597 (if (not (gnus-buffer-live-p gnus-summary-buffer))
4598 (error "There is no summary buffer for this article buffer")
4599 (gnus-article-set-globals)
4600 (gnus-configure-windows 'article)
4601 (gnus-summary-goto-subject gnus-current-article)
4602 (gnus-summary-position-point)))
4604 (defun gnus-article-describe-briefly ()
4605 "Describe article mode commands briefly."
4607 (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")))
4609 (defun gnus-article-summary-command ()
4610 "Execute the last keystroke in the summary buffer."
4612 (let ((obuf (current-buffer))
4613 (owin (current-window-configuration))
4615 (switch-to-buffer gnus-article-current-summary 'norecord)
4616 (setq func (lookup-key (current-local-map) (this-command-keys)))
4617 (call-interactively func)
4619 (set-window-configuration owin)
4620 (set-window-point (get-buffer-window (current-buffer)) (point))))
4622 (defun gnus-article-summary-command-nosave ()
4623 "Execute the last keystroke in the summary buffer."
4626 (pop-to-buffer gnus-article-current-summary 'norecord)
4627 (setq func (lookup-key (current-local-map) (this-command-keys)))
4628 (call-interactively func)))
4630 (defun gnus-article-check-buffer ()
4631 "Beep if not in an article buffer."
4632 (unless (eq (get-buffer gnus-article-buffer) (current-buffer))
4633 (error "Command invoked outside of a Gnus article buffer")))
4635 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
4636 "Read a summary buffer key sequence and execute it from the article buffer."
4638 (gnus-article-check-buffer)
4640 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
4641 "Zc" "ZC" "ZE" "ZJ" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
4642 "=" "^" "\M-^" "|"))
4648 '("n" "Gn" "p" "Gp"))
4651 (set-buffer gnus-article-current-summary)
4652 (let (gnus-pick-mode)
4653 (push (or key last-command-event) unread-command-events)
4654 (setq keys (static-if (featurep 'xemacs)
4655 (events-to-keys (read-key-sequence nil))
4656 (read-key-sequence nil)))))
4659 (if (or (member keys nosaves)
4660 (member keys nosave-but-article)
4661 (member keys nosave-in-article))
4663 (save-window-excursion
4664 (pop-to-buffer gnus-article-current-summary 'norecord)
4665 ;; We disable the pick minor mode commands.
4666 (let (gnus-pick-mode)
4667 (setq func (lookup-key (current-local-map) keys))))
4671 (unless (member keys nosave-in-article)
4672 (set-buffer gnus-article-current-summary))
4673 (call-interactively func)
4674 (setq new-sum-point (point)))
4675 (when (member keys nosave-but-article)
4676 (pop-to-buffer gnus-article-buffer 'norecord)))
4677 ;; These commands should restore window configuration.
4678 (let ((obuf (current-buffer))
4679 (owin (current-window-configuration))
4681 (summary gnus-article-current-summary)
4682 func in-buffer selected)
4683 (if not-restore-window
4684 (pop-to-buffer summary 'norecord)
4685 (switch-to-buffer summary 'norecord))
4686 (setq in-buffer (current-buffer))
4687 ;; We disable the pick minor mode commands.
4688 (if (and (setq func (let (gnus-pick-mode)
4689 (lookup-key (current-local-map) keys)))
4692 (call-interactively func)
4693 (setq new-sum-point (point))
4694 (when (eq in-buffer (current-buffer))
4695 (setq selected (gnus-summary-select-article))
4697 (unless not-restore-window
4698 (set-window-configuration owin))
4699 (when (eq selected 'old)
4701 (set-window-start (get-buffer-window (current-buffer))
4703 (set-window-point (get-buffer-window (current-buffer))
4705 (let ((win (get-buffer-window gnus-article-current-summary)))
4707 (set-window-point win new-sum-point)))) )
4708 (switch-to-buffer gnus-article-buffer)
4711 (defun gnus-article-describe-key (key)
4712 "Display documentation of the function invoked by KEY. KEY is a string."
4713 (interactive "kDescribe key: ")
4714 (gnus-article-check-buffer)
4715 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
4717 (set-buffer gnus-article-current-summary)
4718 (let (gnus-pick-mode)
4719 (if (featurep 'xemacs)
4721 (push (elt key 0) unread-command-events)
4722 (setq key (events-to-keys
4723 (read-key-sequence "Describe key: "))))
4724 (setq unread-command-events
4726 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
4728 (setq key (read-key-sequence "Describe key: "))))
4730 (describe-key key)))
4732 (defun gnus-article-describe-key-briefly (key &optional insert)
4733 "Display documentation of the function invoked by KEY. KEY is a string."
4734 (interactive "kDescribe key: \nP")
4735 (gnus-article-check-buffer)
4736 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
4738 (set-buffer gnus-article-current-summary)
4739 (let (gnus-pick-mode)
4740 (if (featurep 'xemacs)
4742 (push (elt key 0) unread-command-events)
4743 (setq key (events-to-keys
4744 (read-key-sequence "Describe key: "))))
4745 (setq unread-command-events
4747 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
4749 (setq key (read-key-sequence "Describe key: "))))
4750 (describe-key-briefly key insert))
4751 (describe-key-briefly key insert)))
4753 (defun gnus-article-hide (&optional arg force)
4754 "Hide all the gruft in the current article.
4755 This means that PGP stuff, signatures, cited text and (some)
4756 headers will be hidden.
4757 If given a prefix, show the hidden text instead."
4758 (interactive (append (gnus-article-hidden-arg) (list 'force)))
4759 (gnus-article-hide-headers arg)
4760 (gnus-article-hide-list-identifiers arg)
4761 (gnus-article-hide-pgp arg)
4762 (gnus-article-hide-citation-maybe arg force)
4763 (gnus-article-hide-signature arg))
4765 (defun gnus-article-maybe-highlight ()
4766 "Do some article highlighting if article highlighting is requested."
4767 (when (gnus-visual-p 'article-highlight 'highlight)
4768 (gnus-article-highlight-some)))
4770 (defun gnus-check-group-server ()
4771 ;; Make sure the connection to the server is alive.
4772 (unless (gnus-server-opened
4773 (gnus-find-method-for-group gnus-newsgroup-name))
4774 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
4775 (gnus-request-group gnus-newsgroup-name t)))
4777 (defun gnus-request-article-this-buffer (article group)
4778 "Get an article and insert it into this buffer.
4779 T-gnus change: Insert an article into `gnus-original-article-buffer'."
4780 (let (do-update-line sparse-header)
4781 ;; The current buffer is `gnus-article-buffer'.
4785 (gnus-kill-all-overlays)
4786 (setq group (or group gnus-newsgroup-name))
4788 ;; Using `gnus-request-article' directly will insert the article into
4789 ;; `nntp-server-buffer' - so we'll save some time by not having to
4790 ;; copy it from the server buffer into the article buffer.
4792 ;; We only request an article by message-id when we do not have the
4793 ;; headers for it, so we'll have to get those.
4794 (when (stringp article)
4795 (gnus-read-header article))
4797 ;; If the article number is negative, that means that this article
4798 ;; doesn't belong in this newsgroup (possibly), so we find its
4799 ;; message-id and request it by id instead of number.
4800 (when (and (numberp article)
4802 (get-buffer gnus-summary-buffer)
4803 (gnus-buffer-exists-p gnus-summary-buffer))
4805 (set-buffer gnus-summary-buffer)
4806 (let ((header (gnus-summary-article-header article)))
4809 ((memq article gnus-newsgroup-sparse)
4810 ;; This is a sparse gap article.
4811 (setq do-update-line article)
4812 (setq article (mail-header-id header))
4813 (setq sparse-header (gnus-read-header article))
4814 (setq gnus-newsgroup-sparse
4815 (delq article gnus-newsgroup-sparse)))
4817 ;; It's a real article.
4818 (setq article (mail-header-id header)))
4820 ;; It is an extracted pseudo-article.
4821 (setq article 'pseudo)
4822 (gnus-request-pseudo-article header))))
4824 (let ((method (gnus-find-method-for-group
4825 gnus-newsgroup-name)))
4826 (when (and (eq (car method) 'nneething)
4828 (let ((dir (expand-file-name
4829 (mail-header-subject header)
4830 (file-name-as-directory
4831 (or (cadr (assq 'nneething-address method))
4833 (when (file-directory-p dir)
4834 (setq article 'nneething)
4835 (gnus-group-enter-directory dir))))))))
4836 (setq gnus-original-article (cons group article))
4838 (set-buffer gnus-original-article-buffer)
4840 ;; Refuse to select canceled articles.
4841 ((and (numberp article)
4843 (get-buffer gnus-summary-buffer)
4844 (gnus-buffer-exists-p gnus-summary-buffer)
4845 (eq (cdr (save-excursion
4846 (set-buffer gnus-summary-buffer)
4847 (assq article gnus-newsgroup-reads)))
4848 gnus-canceled-mark))
4850 ;; Check the backlog.
4851 ((and gnus-keep-backlog
4852 (gnus-backlog-request-article group article (current-buffer)))
4854 ;; Check asynchronous pre-fetch.
4855 ((gnus-async-request-fetched-article group article (current-buffer))
4856 (gnus-async-prefetch-next group article gnus-summary-buffer)
4857 (when (and (numberp article) gnus-keep-backlog)
4858 (gnus-backlog-enter-article group article (current-buffer)))
4861 ((and gnus-use-cache
4863 (gnus-cache-request-article article group))
4865 ;; Get the article and put into the article buffer.
4866 ((or (stringp article)
4868 (let ((gnus-override-method gnus-override-method)
4869 (methods (and (stringp article)
4870 gnus-refer-article-method))
4872 (buffer-read-only nil))
4873 (if (or (not (listp methods))
4874 (and (symbolp (car methods))
4875 (assq (car methods) nnoo-definition-alist)))
4876 (setq methods (list methods)))
4877 (when (and (null gnus-override-method)
4879 (setq gnus-override-method (pop methods)))
4881 (when (eq gnus-override-method 'current)
4882 (setq gnus-override-method gnus-current-select-method))
4884 (gnus-kill-all-overlays)
4885 (let ((gnus-newsgroup-name group))
4886 (gnus-check-group-server))
4887 (when (gnus-request-article article group (current-buffer))
4888 (when (numberp article)
4889 (gnus-async-prefetch-next group article
4890 gnus-summary-buffer)
4891 (when gnus-keep-backlog
4892 (gnus-backlog-enter-article
4893 group article (current-buffer))))
4894 (setq result 'article))
4897 (setq gnus-override-method (pop methods))
4898 (setq result 'done))))
4899 (and (eq result 'article) 'article)))
4903 ;; Associate this article with the current summary buffer.
4904 (setq gnus-article-current-summary gnus-summary-buffer)
4907 (run-hooks 'gnus-article-decode-hook)
4908 ;; Mark article as decoded or not.
4909 (setq gnus-article-decoded-p gnus-article-decode-hook)
4911 ;; Update sparse articles.
4912 (when (and do-update-line
4913 (or (numberp article)
4915 (let ((buf (current-buffer)))
4916 (set-buffer gnus-summary-buffer)
4917 (gnus-summary-update-article do-update-line sparse-header)
4918 (gnus-summary-goto-subject do-update-line nil t)
4919 (set-window-point (get-buffer-window (current-buffer) t)
4921 (set-buffer buf))))))
4927 (defcustom gnus-article-edit-mode-hook nil
4928 "Hook run in article edit mode buffers."
4929 :group 'gnus-article-various
4932 (defcustom gnus-article-edit-article-setup-function
4933 'gnus-article-mime-edit-article-setup
4934 "Function called to setup an editing article buffer."
4935 :group 'gnus-article-various
4938 (defvar gnus-article-edit-done-function nil)
4940 (defvar gnus-article-edit-mode-map nil)
4942 ;; Should we be using derived.el for this?
4943 (unless gnus-article-edit-mode-map
4944 (setq gnus-article-edit-mode-map (make-sparse-keymap))
4945 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
4947 (gnus-define-keys gnus-article-edit-mode-map
4948 "\C-c\C-c" gnus-article-edit-done
4949 "\C-c\C-k" gnus-article-edit-exit)
4951 (gnus-define-keys (gnus-article-edit-wash-map
4952 "\C-c\C-w" gnus-article-edit-mode-map)
4953 "f" gnus-article-edit-full-stops))
4955 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
4956 "Major mode for editing articles.
4957 This is an extended text-mode.
4959 \\{gnus-article-edit-mode-map}"
4960 (make-local-variable 'gnus-article-edit-done-function)
4961 (make-local-variable 'gnus-prev-winconf)
4962 (set (make-local-variable 'font-lock-defaults)
4963 '(message-font-lock-keywords t))
4964 (setq buffer-read-only nil)
4965 (buffer-enable-undo)
4968 (defun gnus-article-edit (&optional force)
4969 "Edit the current article.
4970 This will have permanent effect only in mail groups.
4971 If FORCE is non-nil, allow editing of articles even in read-only
4974 (when (and (not force)
4975 (gnus-group-read-only-p))
4976 (error "The current newsgroup does not support article editing"))
4977 (gnus-article-date-original)
4978 (gnus-article-edit-article
4980 `(lambda (no-highlight)
4982 (gnus-summary-edit-article-done
4983 ,(or (mail-header-references gnus-current-headers) "")
4984 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
4986 (defun gnus-article-edit-article (start-func exit-func)
4987 "Start editing the contents of the current article buffer."
4988 (let ((winconf (current-window-configuration)))
4989 (set-buffer gnus-article-buffer)
4990 (gnus-article-edit-mode)
4991 (funcall start-func)
4992 (set-buffer-modified-p nil)
4993 (gnus-configure-windows 'edit-article)
4994 (setq gnus-article-edit-done-function exit-func)
4995 (setq gnus-prev-winconf winconf)
4996 (when gnus-article-edit-article-setup-function
4997 (funcall gnus-article-edit-article-setup-function))
4998 (gnus-message 6 "C-c C-c to end edits; C-c C-k to exit")))
5000 (defun gnus-article-edit-done (&optional arg)
5001 "Update the article edits and exit."
5003 (let ((func gnus-article-edit-done-function)
5004 (buf (current-buffer))
5005 (start (window-start)))
5006 (remove-hook 'gnus-article-mode-hook
5007 'gnus-article-mime-edit-article-unwind)
5008 ;; We remove all text props from the article buffer.
5010 (buffer-substring-no-properties (point-min) (point-max)))
5014 (let ((winconf gnus-prev-winconf))
5016 (set-window-configuration winconf)
5017 ;; Tippy-toe some to make sure that point remains where it was.
5018 (save-current-buffer
5020 (set-window-start (get-buffer-window (current-buffer)) start)
5024 (let ((buffer-read-only nil))
5026 ;; The cache and backlog have to be flushed somewhat.
5027 (when gnus-keep-backlog
5028 (gnus-backlog-remove-article
5029 (car gnus-article-current) (cdr gnus-article-current)))
5030 ;; Flush original article as well.
5032 (when (get-buffer gnus-original-article-buffer)
5033 (set-buffer gnus-original-article-buffer)
5034 (setq gnus-original-article nil)))
5035 (when gnus-use-cache
5036 (gnus-cache-update-article
5037 (car gnus-article-current) (cdr gnus-article-current))))
5039 (set-window-start (get-buffer-window buf) start)
5040 (set-window-point (get-buffer-window buf) (point))))
5042 (defun gnus-article-edit-exit ()
5043 "Exit the article editing without updating."
5045 (when (or (not (buffer-modified-p))
5046 (yes-or-no-p "Article modified; kill anyway? "))
5047 (let ((curbuf (current-buffer))
5049 (window-start (window-start)))
5051 (if (gnus-buffer-live-p gnus-original-article-buffer)
5052 (insert-buffer gnus-original-article-buffer))
5053 (let ((winconf gnus-prev-winconf))
5055 (set-window-configuration winconf)
5056 ;; Tippy-toe some to make sure that point remains where it was.
5057 (save-current-buffer
5059 (set-window-start (get-buffer-window (current-buffer)) window-start)
5062 (defun gnus-article-edit-full-stops ()
5063 "Interactively repair spacing at end of sentences."
5066 (goto-char (point-min))
5067 (search-forward-regexp "^$" nil t)
5068 (let ((case-fold-search nil))
5069 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5072 ;;; Article editing with MIME-Edit
5075 (defcustom gnus-article-mime-edit-article-setup-hook nil
5076 "Hook run after setting up a MIME editing article buffer."
5077 :group 'gnus-article-various
5080 (defun gnus-article-mime-edit-article-unwind ()
5081 "Unwind `gnus-article-buffer' if article editing was given up."
5082 (remove-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
5083 (when (featurep 'font-lock)
5084 (setq font-lock-defaults nil)
5085 (font-lock-mode -1))
5086 (when mime-edit-mode-flag
5087 (mime-edit-exit 'nomime 'no-error)
5090 (defun gnus-article-mime-edit-article-setup ()
5091 "Convert current buffer to MIME-Edit buffer and turn on MIME-Edit mode
5092 after replacing with the original article."
5093 (setq gnus-show-mime t)
5094 (setq gnus-article-edit-done-function
5095 `(lambda (&rest args)
5096 (when mime-edit-mode-flag
5097 (let (mime-edit-insert-user-agent-field)
5100 (goto-char (point-min))
5101 (let (case-fold-search)
5102 (when (re-search-forward
5103 (format "^%s$" (regexp-quote mail-header-separator))
5105 (replace-match "")))
5106 (apply ,gnus-article-edit-done-function args)
5109 (buffer-substring-no-properties (point-min) (point-max))
5110 (set-buffer (get-buffer-create gnus-original-article-buffer))
5112 (setq gnus-current-headers (gnus-article-make-full-mail-header))
5113 (set-buffer gnus-article-buffer)
5114 (gnus-article-prepare-display)))
5115 (substitute-key-definition 'gnus-article-edit-done
5116 'gnus-article-mime-edit-done
5117 gnus-article-edit-mode-map)
5118 (substitute-key-definition 'gnus-article-edit-exit
5119 'gnus-article-mime-edit-exit
5120 gnus-article-edit-mode-map)
5122 (insert-buffer gnus-original-article-buffer)
5123 (let ((ofn (symbol-function 'mime-edit-decode-single-part-in-buffer)))
5124 (fset 'mime-edit-decode-single-part-in-buffer
5125 (lambda (&rest args)
5126 (if (let ((content-type (car args)))
5127 (and (eq 'message (mime-content-type-primary-type
5129 (eq 'rfc822 (mime-content-type-subtype content-type))))
5130 (setcar (cdr args) 'not-decode-text))
5134 (fset 'mime-edit-decode-single-part-in-buffer ofn)))
5135 (when (featurep 'font-lock)
5136 (set (make-local-variable 'font-lock-defaults)
5137 '(message-font-lock-keywords t))
5138 (font-lock-set-defaults)
5139 (turn-on-font-lock))
5140 (set-buffer-modified-p nil)
5141 (delete-other-windows)
5142 (add-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
5143 (gnus-run-hooks 'gnus-article-mime-edit-article-setup-hook))
5145 (defun gnus-article-mime-edit-done (&optional arg)
5146 "Update the article MIME edits and exit."
5148 (when (featurep 'font-lock)
5149 (setq font-lock-defaults nil)
5150 (font-lock-mode -1))
5151 (gnus-article-edit-done arg))
5153 (defun gnus-article-mime-edit-exit ()
5154 "Exit the article MIME editing without updating."
5156 (when (or (not (buffer-modified-p))
5157 (yes-or-no-p "Article modified; kill anyway? "))
5158 (when (featurep 'font-lock)
5159 (setq font-lock-defaults nil)
5160 (font-lock-mode -1))
5161 (when mime-edit-mode-flag
5162 (let (mime-edit-insert-user-agent-field)
5165 (goto-char (point-min))
5166 (let (case-fold-search)
5167 (when (re-search-forward
5168 (format "^%s$" (regexp-quote mail-header-separator)) nil t)
5169 (replace-match "")))
5170 (let ((winconf gnus-prev-winconf))
5172 (buffer-substring-no-properties (point-min) (point-max))
5173 (set-buffer (get-buffer-create gnus-original-article-buffer))
5175 (setq gnus-current-headers (gnus-article-make-full-mail-header))
5176 (set-buffer gnus-article-buffer)
5177 (gnus-article-prepare-display)
5178 (set-window-configuration winconf))))
5181 ;;; Article highlights
5184 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5186 ;;; Internal Variables:
5188 (defcustom gnus-button-url-regexp "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-zA-Z0-9_.]+:[0-9]*\\)?\\([-a-zA-Z0-9_=!?#$@~`%&*+|\\/:;.,]\\|\\w\\)+\\([-a-zA-Z0-9_=#$@~`%&*+|\\/]\\|\\w\\)\\)"
5189 "Regular expression that matches URLs."
5190 :group 'gnus-article-buttons
5193 (defcustom gnus-button-alist
5194 `(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
5195 0 t gnus-button-handle-news 3)
5196 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
5197 gnus-button-handle-news 2)
5198 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
5200 gnus-button-fetch-group 4)
5201 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
5202 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
5203 t gnus-button-message-id 3)
5204 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
5205 ("mailto:\\([-a-zA-Z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
5206 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
5208 ("\\binfo:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t
5209 gnus-button-handle-info 2)
5210 ;; This is how URLs _should_ be embedded in text...
5211 ("<URL: *\\([^<>]*\\)>" 0 t gnus-button-embedded-url 1)
5213 (,gnus-button-url-regexp 0 t browse-url 0))
5214 "*Alist of regexps matching buttons in article bodies.
5216 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
5217 REGEXP: is the string matching text around the button,
5218 BUTTON: is the number of the regexp grouping actually matching the button,
5219 FORM: is a lisp expression which must eval to true for the button to
5221 CALLBACK: is the function to call when the user push this button, and each
5222 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
5224 CALLBACK can also be a variable, in that case the value of that
5225 variable it the real callback function."
5226 :group 'gnus-article-buttons
5227 :type '(repeat (list regexp
5228 (integer :tag "Button")
5230 (function :tag "Callback")
5233 (integer :tag "Regexp group")))))
5235 (defcustom gnus-header-button-alist
5236 `(("^\\(References\\|Message-I[Dd]\\):" "<[^<>]+>"
5237 0 t gnus-button-message-id 0)
5238 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
5239 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
5240 0 t gnus-button-mailto 0)
5241 ("^X-[Uu][Rr][Ll]:" ,gnus-button-url-regexp 0 t browse-url 0)
5242 ("^Subject:" ,gnus-button-url-regexp 0 t browse-url 0)
5243 ("^[^:]+:" ,gnus-button-url-regexp 0 t browse-url 0)
5244 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
5245 gnus-button-message-id 3))
5246 "*Alist of headers and regexps to match buttons in article heads.
5248 This alist is very similar to `gnus-button-alist', except that each
5249 alist has an additional HEADER element first in each entry:
5251 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
5253 HEADER is a regexp to match a header. For a fuller explanation, see
5254 `gnus-button-alist'."
5255 :group 'gnus-article-buttons
5256 :group 'gnus-article-headers
5257 :type '(repeat (list (regexp :tag "Header")
5259 (integer :tag "Button")
5261 (function :tag "Callback")
5264 (integer :tag "Regexp group")))))
5266 (defvar gnus-button-regexp nil)
5267 (defvar gnus-button-marker-list nil)
5268 ;; Regexp matching any of the regexps from `gnus-button-alist'.
5270 (defvar gnus-button-last nil)
5271 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
5275 (defun gnus-article-push-button (event)
5276 "Check text under the mouse pointer for a callback function.
5277 If the text under the mouse pointer has a `gnus-callback' property,
5278 call it with the value of the `gnus-data' text property."
5280 (set-buffer (window-buffer (posn-window (event-start event))))
5281 (let* ((pos (posn-point (event-start event)))
5282 (data (get-text-property pos 'gnus-data))
5283 (fun (get-text-property pos 'gnus-callback)))
5286 (funcall fun data))))
5288 (defun gnus-article-press-button ()
5289 "Check text at point for a callback function.
5290 If the text at point has a `gnus-callback' property,
5291 call it with the value of the `gnus-data' text property."
5293 (let* ((data (get-text-property (point) 'gnus-data))
5294 (fun (get-text-property (point) 'gnus-callback)))
5296 (funcall fun data))))
5298 (defun gnus-article-prev-button (n)
5299 "Move point to N buttons backward.
5300 If N is negative, move forward instead."
5302 (gnus-article-next-button (- n)))
5304 (defun gnus-article-next-button (n)
5305 "Move point to N buttons forward.
5306 If N is negative, move backward instead."
5308 (let ((function (if (< n 0) 'previous-single-property-change
5309 'next-single-property-change))
5310 (inhibit-point-motion-hooks t)
5312 (limit (if (< n 0) (point-min) (point-max))))
5314 (while (and (not (= limit (point)))
5316 ;; Skip past the current button.
5317 (when (get-text-property (point) 'gnus-callback)
5318 (goto-char (funcall function (point) 'gnus-callback nil limit)))
5319 ;; Go to the next (or previous) button.
5320 (gnus-goto-char (funcall function (point) 'gnus-callback nil limit))
5321 ;; Put point at the start of the button.
5322 (when (and backward (not (get-text-property (point) 'gnus-callback)))
5323 (goto-char (funcall function (point) 'gnus-callback nil limit)))
5324 ;; Skip past intangible buttons.
5325 (when (get-text-property (point) 'intangible)
5329 (gnus-message 5 "No more buttons"))
5332 (defun gnus-article-highlight (&optional force)
5333 "Highlight current article.
5334 This function calls `gnus-article-highlight-headers',
5335 `gnus-article-highlight-citation',
5336 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
5337 do the highlighting. See the documentation for those functions."
5338 (interactive (list 'force))
5339 (gnus-article-highlight-headers)
5340 (gnus-article-highlight-citation force)
5341 (gnus-article-highlight-signature)
5342 (gnus-article-add-buttons force)
5343 (gnus-article-add-buttons-to-head))
5345 (defun gnus-article-highlight-some (&optional force)
5346 "Highlight current article.
5347 This function calls `gnus-article-highlight-headers',
5348 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
5349 do the highlighting. See the documentation for those functions."
5350 (interactive (list 'force))
5351 (gnus-article-highlight-headers)
5352 (gnus-article-highlight-signature)
5353 (gnus-article-add-buttons))
5355 (defun gnus-article-highlight-headers ()
5356 "Highlight article headers as specified by `gnus-header-face-alist'."
5359 (set-buffer gnus-article-buffer)
5361 (let ((alist gnus-header-face-alist)
5362 (buffer-read-only nil)
5363 (case-fold-search t)
5364 (inhibit-point-motion-hooks t)
5365 entry regexp header-face field-face from hpoints fpoints)
5366 (article-narrow-to-head)
5367 (while (setq entry (pop alist))
5368 (goto-char (point-min))
5369 (setq regexp (concat "^\\("
5370 (if (string-equal "" (nth 0 entry))
5374 header-face (nth 1 entry)
5375 field-face (nth 2 entry))
5376 (while (and (re-search-forward regexp nil t)
5380 (unless (search-forward ":" nil t)
5382 (when (and header-face
5383 (not (memq (point) hpoints)))
5384 (push (point) hpoints)
5385 (gnus-put-text-property from (point) 'face header-face))
5386 (when (and field-face
5387 (not (memq (setq from (point)) fpoints)))
5389 (if (re-search-forward "^[^ \t]" nil t)
5391 (goto-char (point-max)))
5392 (gnus-put-text-property from (point) 'face field-face))))))))
5394 (defun gnus-article-highlight-signature ()
5395 "Highlight the signature in an article.
5396 It does this by highlighting everything after
5397 `gnus-signature-separator' using `gnus-signature-face'."
5399 (when gnus-signature-face
5401 (set-buffer gnus-article-buffer)
5402 (let ((buffer-read-only nil)
5403 (inhibit-point-motion-hooks t))
5405 (when (gnus-article-narrow-to-signature)
5406 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
5407 'face gnus-signature-face)))))))
5409 (defun gnus-article-buttonize-signature ()
5410 "Add button to the signature."
5413 (set-buffer gnus-article-buffer)
5414 (let ((buffer-read-only nil)
5415 (inhibit-point-motion-hooks t))
5416 (when (gnus-article-search-signature)
5417 (gnus-article-add-button (match-beginning 0) (match-end 0)
5418 'gnus-signature-toggle
5419 (set-marker (make-marker)
5420 (1+ (match-end 0))))))))
5422 (defun gnus-button-in-region-p (b e prop)
5423 "Say whether PROP exists in the region."
5424 (text-property-not-all b e prop nil))
5426 (defun gnus-article-add-buttons (&optional force)
5427 "Find external references in the article and make buttons of them.
5428 \"External references\" are things like Message-IDs and URLs, as
5429 specified by `gnus-button-alist'."
5430 (interactive (list 'force))
5432 (set-buffer gnus-article-buffer)
5433 (let ((buffer-read-only nil)
5434 (inhibit-point-motion-hooks t)
5435 (case-fold-search t)
5436 (alist gnus-button-alist)
5438 ;; Remove all old markers.
5439 (let (marker entry new-list)
5440 (while (setq marker (pop gnus-button-marker-list))
5441 (if (or (< marker (point-min)) (>= marker (point-max)))
5442 (push marker new-list)
5444 (when (setq entry (gnus-button-entry))
5445 (put-text-property (match-beginning (nth 1 entry))
5446 (match-end (nth 1 entry))
5447 'gnus-callback nil))
5448 (set-marker marker nil)))
5449 (setq gnus-button-marker-list new-list))
5450 ;; We skip the headers.
5453 (while (setq entry (pop alist))
5454 (setq regexp (car entry))
5456 (while (re-search-forward regexp nil t)
5457 (let* ((start (and entry (match-beginning (nth 1 entry))))
5458 (end (and entry (match-end (nth 1 entry))))
5459 (from (match-beginning 0)))
5460 (when (and (or (eq t (nth 2 entry))
5461 (eval (nth 2 entry)))
5462 (not (gnus-button-in-region-p
5463 start end 'gnus-callback)))
5464 ;; That optional form returned non-nil, so we add the
5466 (gnus-article-add-button
5467 start end 'gnus-button-push
5468 (car (push (set-marker (make-marker) from)
5469 gnus-button-marker-list))))))))))
5471 ;; Add buttons to the head of an article.
5472 (defun gnus-article-add-buttons-to-head ()
5473 "Add buttons to the head of the article."
5476 (set-buffer gnus-article-buffer)
5478 (let ((buffer-read-only nil)
5479 (inhibit-point-motion-hooks t)
5480 (case-fold-search t)
5481 (alist gnus-header-button-alist)
5483 (article-narrow-to-head)
5485 ;; Each alist entry.
5486 (setq entry (car alist)
5488 (goto-char (point-min))
5489 (while (re-search-forward (car entry) nil t)
5490 ;; Each header matching the entry.
5491 (setq beg (match-beginning 0))
5492 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
5493 (match-beginning 0))
5496 (while (re-search-forward (nth 1 entry) end t)
5497 ;; Each match within a header.
5498 (let* ((entry (cdr entry))
5499 (start (match-beginning (nth 1 entry)))
5500 (end (match-end (nth 1 entry)))
5501 (form (nth 2 entry)))
5502 (goto-char (match-end 0))
5504 (gnus-article-add-button
5505 start end (nth 3 entry)
5506 (buffer-substring (match-beginning (nth 4 entry))
5507 (match-end (nth 4 entry)))))))
5508 (goto-char end)))))))
5510 ;;; External functions:
5512 (defun gnus-article-add-button (from to fun &optional data)
5513 "Create a button between FROM and TO with callback FUN and data DATA."
5514 (when gnus-article-button-face
5515 (gnus-overlay-put (gnus-make-overlay from to)
5516 'face gnus-article-button-face))
5517 (gnus-add-text-properties
5519 (nconc (and gnus-article-mouse-face
5520 (list gnus-mouse-face-prop gnus-article-mouse-face))
5521 (list 'gnus-callback fun)
5522 (and data (list 'gnus-data data))))
5523 (widget-convert-button 'link from to :action 'gnus-widget-press-button
5524 ;; Quote `:button-keymap' for Mule 2.3
5525 ;; but it won't work.
5526 ':button-keymap gnus-widget-button-keymap))
5528 ;;; Internal functions:
5530 (defun gnus-article-set-globals ()
5532 (set-buffer gnus-summary-buffer)
5533 (gnus-set-global-variables)))
5535 (defun gnus-signature-toggle (end)
5537 (set-buffer gnus-article-buffer)
5538 (let ((buffer-read-only nil)
5539 (inhibit-point-motion-hooks t)
5540 (limit (next-single-property-change end 'mime-view-entity
5542 (if (text-property-any end limit 'article-type 'signature)
5543 (gnus-remove-text-properties-when
5544 'article-type 'signature end limit
5545 (cons 'article-type (cons 'signature
5546 gnus-hidden-properties)))
5547 (gnus-add-text-properties-when
5548 'article-type nil end limit
5549 (cons 'article-type (cons 'signature
5550 gnus-hidden-properties)))))))
5552 (defun gnus-button-entry ()
5553 ;; Return the first entry in `gnus-button-alist' matching this place.
5554 (let ((alist gnus-button-alist)
5557 (setq entry (pop alist))
5558 (if (looking-at (car entry))
5563 (defun gnus-button-push (marker)
5564 ;; Push button starting at MARKER.
5567 (let* ((entry (gnus-button-entry))
5568 (inhibit-point-motion-hooks t)
5570 (args (mapcar (lambda (group)
5571 (let ((string (match-string group)))
5572 (gnus-set-text-properties
5573 0 (length string) nil string)
5580 (fboundp (symbol-value fun)))
5581 (apply (symbol-value fun) args))
5583 (gnus-message 1 "You must define `%S' to use this button"
5584 (cons fun args)))))))
5586 (defun gnus-parse-news-url (url)
5587 (let (scheme server group message-id articles)
5590 (goto-char (point-min))
5591 (when (looking-at "\\([A-Za-z]+\\):")
5592 (setq scheme (match-string 1))
5593 (goto-char (match-end 0)))
5594 (when (looking-at "//\\([^/]+\\)/")
5595 (setq server (match-string 1))
5596 (goto-char (match-end 0)))
5599 ((looking-at "\\(.*@.*\\)")
5600 (setq message-id (match-string 1)))
5601 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
5602 (setq group (match-string 1)
5603 articles (split-string (match-string 2) "-")))
5604 ((looking-at "\\([^/]+\\)/?")
5605 (setq group (match-string 1)))
5607 (error "Unknown news URL syntax"))))
5608 (list scheme server group message-id articles)))
5610 (defun gnus-button-handle-news (url)
5612 (destructuring-bind (scheme server group message-id articles)
5613 (gnus-parse-news-url url)
5617 (set-buffer gnus-summary-buffer)
5619 (let ((gnus-refer-article-method (list (list 'nntp server))))
5620 (gnus-summary-refer-article message-id))
5621 (gnus-summary-refer-article message-id))))
5623 (gnus-button-fetch-group url)))))
5625 (defun gnus-button-handle-info (url)
5626 "Fetch an info URL."
5628 "^\\([^:/]+\\)?/\\(.*\\)"
5630 (gnus-info-find-node
5631 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
5634 (gnus-url-unhex-string (match-string 2 url))))
5635 (error "Can't parse %s" url)))
5637 (defun gnus-button-message-id (message-id)
5640 (set-buffer gnus-summary-buffer)
5641 (gnus-summary-refer-article message-id)))
5643 (defun gnus-button-fetch-group (address)
5644 "Fetch GROUP specified by ADDRESS."
5645 (if (not (string-match "[:/]" address))
5646 ;; This is just a simple group url.
5647 (gnus-group-read-ephemeral-group address gnus-select-method)
5650 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
5652 (error "Can't parse %s" address)
5653 (gnus-group-read-ephemeral-group
5654 (match-string 4 address)
5655 `(nntp ,(match-string 1 address)
5656 (nntp-address ,(match-string 1 address))
5657 (nntp-port-number ,(if (match-end 3)
5658 (match-string 3 address)
5661 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
5663 (defun gnus-url-parse-query-string (query &optional downcase)
5664 (let (retval pairs cur key val)
5665 (setq pairs (split-string query "&"))
5667 (setq cur (car pairs)
5669 (if (not (string-match "=" cur))
5671 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
5672 val (gnus-url-unhex-string (substring cur (match-end 0) nil)))
5674 (setq key (downcase key)))
5675 (setq cur (assoc key retval))
5677 (setcdr cur (cons val (cdr cur)))
5678 (setq retval (cons (list key val) retval)))))
5681 (defun gnus-url-unhex (x)
5688 (defun gnus-url-unhex-string (str &optional allow-newlines)
5689 "Remove %XXX embedded spaces, etc in a url.
5690 If optional second argument ALLOW-NEWLINES is non-nil, then allow the
5691 decoding of carriage returns and line feeds in the string, which is normally
5692 forbidden in URL encoding."
5693 (setq str (or (nnheader-replace-chars-in-string str ?+ ? ) ""))
5695 (case-fold-search t))
5696 (while (string-match "%[0-9a-f][0-9a-f]" str)
5697 (let* ((start (match-beginning 0))
5698 (ch1 (gnus-url-unhex (elt str (+ start 1))))
5700 (gnus-url-unhex (elt str (+ start 2))))))
5702 tmp (substring str 0 start)
5705 (char-to-string code))
5706 ((or (= code ?\n) (= code ?\r))
5708 (t (char-to-string code))))
5709 str (substring str (match-end 0)))))
5710 (setq tmp (concat tmp str))
5713 (defun gnus-url-mailto (url)
5714 ;; Send mail to someone
5715 (when (string-match "mailto:/*\\(.*\\)" url)
5716 (setq url (substring url (match-beginning 1) nil)))
5717 (let (to args subject func)
5718 (if (string-match (regexp-quote "?") url)
5719 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
5720 args (gnus-url-parse-query-string
5721 (substring url (match-end 0) nil) t))
5722 (setq to (gnus-url-unhex-string url)))
5723 (setq args (cons (list "to" to) args)
5724 subject (cdr-safe (assoc "subject" args)))
5727 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
5730 (message-position-on-field (caar args)))
5731 (insert (mapconcat 'identity (cdar args) ", "))
5732 (setq args (cdr args)))
5735 (message-goto-subject))))
5737 (defun gnus-button-embedded-url (address)
5738 "Activate ADDRESS with `browse-url'."
5739 (browse-url (gnus-strip-whitespace address)))
5742 ;; Silence the byte-compiler.
5743 (autoload 'smiley-toggle-buffer "gnus-bitmap"))
5744 (defun gnus-article-smiley-display ()
5745 "Display \"smileys\" as small graphical icons."
5746 (smiley-toggle-buffer 1 (current-buffer) (point-min) (point-max)))
5748 ;;; Next/prev buttons in the article buffer.
5750 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
5751 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
5753 (defvar gnus-prev-page-map nil)
5754 (unless gnus-prev-page-map
5755 (setq gnus-prev-page-map (make-sparse-keymap))
5756 (define-key gnus-prev-page-map gnus-mouse-2 'gnus-button-prev-page)
5757 (define-key gnus-prev-page-map "\r" 'gnus-button-prev-page))
5759 (static-if (featurep 'xemacs)
5760 (defun gnus-insert-prev-page-button ()
5761 (let ((buffer-read-only nil))
5763 gnus-prev-page-line-format nil
5764 `(gnus-prev t local-map ,gnus-prev-page-map
5765 gnus-callback gnus-article-button-prev-page
5766 article-type annotation))))
5767 (defun gnus-insert-prev-page-button ()
5768 (let ((buffer-read-only nil)
5769 (situation (get-text-property (point-min) 'mime-view-situation)))
5770 (set-keymap-parent gnus-prev-page-map (current-local-map))
5772 gnus-prev-page-line-format nil
5773 `(gnus-prev t local-map ,gnus-prev-page-map
5774 gnus-callback gnus-article-button-prev-page
5775 article-type annotation
5776 mime-view-situation ,situation))))
5779 (defvar gnus-next-page-map nil)
5780 (unless gnus-next-page-map
5781 (setq gnus-next-page-map (make-sparse-keymap))
5782 (define-key gnus-next-page-map gnus-mouse-2 'gnus-button-next-page)
5783 (define-key gnus-next-page-map "\r" 'gnus-button-next-page))
5785 (defun gnus-button-next-page ()
5786 "Go to the next page."
5788 (let ((win (selected-window)))
5789 (select-window (get-buffer-window gnus-article-buffer t))
5790 (gnus-article-next-page)
5791 (select-window win)))
5793 (defun gnus-button-prev-page ()
5794 "Go to the prev page."
5796 (let ((win (selected-window)))
5797 (select-window (get-buffer-window gnus-article-buffer t))
5798 (gnus-article-prev-page)
5799 (select-window win)))
5801 (static-if (featurep 'xemacs)
5802 (defun gnus-insert-next-page-button ()
5803 (let ((buffer-read-only nil))
5804 (gnus-eval-format gnus-next-page-line-format nil
5806 t local-map ,gnus-next-page-map
5807 gnus-callback gnus-article-button-next-page
5808 article-type annotation))))
5809 (defun gnus-insert-next-page-button ()
5810 (let ((buffer-read-only nil)
5811 (situation (get-text-property (point-min) 'mime-view-situation)))
5812 (set-keymap-parent gnus-next-page-map (current-local-map))
5813 (gnus-eval-format gnus-next-page-line-format nil
5815 t local-map ,gnus-next-page-map
5816 gnus-callback gnus-article-button-next-page
5817 article-type annotation
5818 mime-view-situation ,situation))))
5821 (defun gnus-article-button-next-page (arg)
5822 "Go to the next page."
5824 (let ((win (selected-window)))
5825 (select-window (get-buffer-window gnus-article-buffer t))
5826 (gnus-article-next-page)
5827 (select-window win)))
5829 (defun gnus-article-button-prev-page (arg)
5830 "Go to the prev page."
5832 (let ((win (selected-window)))
5833 (select-window (get-buffer-window gnus-article-buffer t))
5834 (gnus-article-prev-page)
5835 (select-window win)))
5837 (defvar gnus-decode-header-methods
5838 '(mail-decode-encoded-word-region)
5839 "List of methods used to decode headers.
5841 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
5842 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
5843 (REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
5844 whose names match REGEXP.
5847 ((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
5848 mail-decode-encoded-word-region
5849 (\"chinese\" . rfc1843-decode-region))
5852 (defvar gnus-decode-header-methods-cache nil)
5854 (defun gnus-multi-decode-header (start end)
5855 "Apply the functions from `gnus-encoded-word-methods' that match."
5856 (unless (and gnus-decode-header-methods-cache
5857 (eq gnus-newsgroup-name
5858 (car gnus-decode-header-methods-cache)))
5859 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
5862 (nconc gnus-decode-header-methods-cache (list x))
5863 (if (and gnus-newsgroup-name
5864 (string-match (car x) gnus-newsgroup-name))
5865 (nconc gnus-decode-header-methods-cache
5867 gnus-decode-header-methods))
5868 (let ((xlist gnus-decode-header-methods-cache))
5871 (narrow-to-region start end)
5873 (funcall (pop xlist) (point-min) (point-max))))))
5876 ;;; Treatment top-level handling.
5879 (defun gnus-treat-article (condition &optional part-number total-parts type)
5880 (let ((length (- (point-max) (point-min)))
5881 (alist gnus-treatment-function-alist)
5882 (article-goto-body-goes-to-point-min-p t)
5886 (let ((list gnus-article-treat-types))
5888 (when (string-match (pop list) type)
5889 (throw 'found t)))))))
5890 (highlightp (gnus-visual-p 'article-highlight 'highlight))
5891 (entity (static-unless (featurep 'xemacs)
5892 (when (eq 'head condition)
5893 (get-text-property (point-min) 'mime-view-entity))))
5894 val elem buttonized)
5895 (gnus-run-hooks 'gnus-part-display-hook)
5896 (unless gnus-inhibit-treatment
5897 (while (setq elem (pop alist))
5900 (if (gnus-buffer-live-p gnus-summary-buffer)
5901 (set-buffer gnus-summary-buffer))
5902 (symbol-value (car elem))))
5903 (when (and (or (consp val)
5905 (gnus-treat-predicate val)
5906 (or (not (get (car elem) 'highlight))
5908 (when (and (not buttonized)
5910 '(gnus-treat-hide-signature
5911 gnus-treat-highlight-signature)))
5912 (gnus-article-buttonize-signature)
5913 (setq buttonized t))
5915 (funcall (cadr elem)))))
5916 ;; FSF Emacsen does not inherit the existing text properties
5917 ;; in the new text, so we should do it for `mime-view-entity'.
5918 (static-unless (featurep 'xemacs)
5920 (put-text-property (point-min) (point-max)
5921 'mime-view-entity entity))))))
5923 ;; Dynamic variables.
5925 (defvar part-number)
5926 (defvar total-parts)
5931 (defun gnus-treat-predicate (val)
5936 (stringp (car val)))
5937 (apply 'gnus-or (mapcar `(lambda (s)
5938 (string-match s ,(or gnus-newsgroup-name "")))
5941 (let ((pred (pop val)))
5944 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
5946 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
5948 (not (gnus-treat-predicate (car val))))
5950 (equal (car val) type))
5952 (error "%S is not a valid predicate" pred)))))
5962 (eq part-number total-parts))
5966 (error "%S is not a valid value" val))))
5968 (defun gnus-article-encrypt-body (protocol &optional n)
5969 "Encrypt the article body."
5972 (or gnus-article-encrypt-protocol
5973 (completing-read "Encrypt protocol: "
5974 gnus-article-encrypt-protocol-alist
5976 current-prefix-arg))
5977 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
5979 (error (format "Can't find the encrypt protocol %s" protocol)))
5980 (if (equal gnus-newsgroup-name "nndraft:drafts")
5981 (error "Can't encrypt the article in group nndraft:drafts"))
5982 (if (equal gnus-newsgroup-name "nndraft:queue")
5983 (error "Don't encrypt the article in group nndraft:queue"))
5984 (gnus-summary-iterate n
5986 (set-buffer gnus-summary-buffer)
5987 (let ((mail-parse-charset gnus-newsgroup-charset)
5988 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5989 (summary-buffer gnus-summary-buffer)
5991 (gnus-set-global-variables)
5992 (when (gnus-group-read-only-p)
5993 (error "The current newsgroup does not support article encrypt"))
5994 (gnus-summary-show-article t)
5996 (or (mail-header-references gnus-current-headers) ""))
5997 (set-buffer gnus-article-buffer)
5998 (let* ((buffer-read-only nil)
6000 (mapcar (lambda (field)
6001 (and (save-restriction
6002 (message-narrow-to-head)
6003 (goto-char (point-min))
6004 (search-forward field nil t))
6006 (message-narrow-to-field)
6007 (buffer-substring (point-min) (point-max))
6008 (delete-region (point-min) (point-max))
6010 '("Content-Type:" "Content-Transfer-Encoding:"
6011 "Content-Disposition:"))))
6012 (message-narrow-to-head)
6013 (message-remove-header "MIME-Version")
6014 (goto-char (point-max))
6015 (setq point (point))
6016 (insert (apply 'concat headers))
6018 (narrow-to-region point (point-max))
6019 (let ((message-options message-options))
6020 (message-options-set 'message-sender user-mail-address)
6021 (message-options-set 'message-recipients user-mail-address)
6022 (message-options-set 'message-sign-encrypt 'not)
6024 (goto-char (point-min))
6025 (insert "MIME-Version: 1.0\n")
6027 (gnus-summary-edit-article-done
6028 references nil summary-buffer t))
6029 (when gnus-keep-backlog
6030 (gnus-backlog-remove-article
6031 (car gnus-article-current) (cdr gnus-article-current)))
6033 (when (get-buffer gnus-original-article-buffer)
6034 (set-buffer gnus-original-article-buffer)
6035 (setq gnus-original-article nil)))
6036 (when gnus-use-cache
6037 (gnus-cache-update-article
6038 (car gnus-article-current) (cdr gnus-article-current))))))))
6040 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
6041 "The following specs can be used:
6042 %t The security MIME type
6045 %D Details if button is pressed")
6047 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
6048 "The following specs can be used:
6049 %t The security MIME type
6052 %D Details if button is pressed")
6054 (defvar gnus-mime-security-button-line-format-alist
6055 '((?t gnus-tmp-type ?s)
6056 (?i gnus-tmp-info ?s)
6057 (?d gnus-tmp-details ?s)
6058 (?D gnus-tmp-pressed-details ?s)))
6060 (defvar gnus-mime-security-button-map
6061 (let ((map (make-sparse-keymap)))
6062 (unless (>= (string-to-number emacs-version) 21)
6063 (set-keymap-parent map gnus-article-mode-map))
6064 (define-key map gnus-mouse-2 'gnus-article-push-button)
6065 (define-key map "\r" 'gnus-article-press-button)
6068 (defvar gnus-mime-security-details-buffer nil)
6070 (defvar gnus-mime-security-button-pressed nil)
6072 (defvar gnus-mime-security-show-details-inline t
6073 "If non-nil, show details in the article buffer.")
6075 (defun gnus-mime-security-verify-or-decrypt (handle)
6076 (mm-remove-parts (cdr handle))
6077 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
6078 point buffer-read-only)
6080 (goto-char (car region)))
6082 (narrow-to-region (point) (point))
6083 (with-current-buffer (mm-handle-multipart-original-buffer handle)
6084 (let* ((mm-verify-option 'known)
6085 (mm-decrypt-option 'known)
6086 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
6087 (unless (eq nparts (cdr handle))
6088 (mm-destroy-parts (cdr handle))
6089 (setcdr handle nparts))))
6090 (setq point (point))
6091 (gnus-mime-display-security handle)
6092 (goto-char (point-max)))
6094 (delete-region (point) (cdr region))
6095 (set-marker (car region) nil)
6096 (set-marker (cdr region) nil))
6099 (defun gnus-mime-security-show-details (handle)
6100 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
6102 (if gnus-mime-security-show-details-inline
6103 (let ((gnus-mime-security-button-pressed t)
6104 (gnus-mime-security-button-line-format
6105 (get-text-property (point) 'gnus-line-format))
6108 (while (eq (get-text-property (point) 'gnus-line-format)
6109 gnus-mime-security-button-line-format)
6113 (narrow-to-region (point) (point))
6114 (gnus-insert-mime-security-button handle))
6115 (delete-region (point)
6116 (or (text-property-not-all
6119 gnus-mime-security-button-line-format)
6121 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
6122 (with-current-buffer gnus-mime-security-details-buffer
6125 (setq gnus-mime-security-details-buffer
6126 (gnus-get-buffer-create "*MIME Security Details*")))
6127 (with-current-buffer gnus-mime-security-details-buffer
6129 (goto-char (point-min)))
6130 (pop-to-buffer gnus-mime-security-details-buffer))
6131 (gnus-message 5 "No details."))))
6133 (defun gnus-mime-security-press-button (handle)
6134 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6135 (gnus-mime-security-show-details handle)
6136 (gnus-mime-security-verify-or-decrypt handle)))
6138 (defun gnus-insert-mime-security-button (handle &optional displayed)
6139 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
6142 (or (nth 2 (assoc protocol mm-verify-function-alist))
6143 (nth 2 (assoc protocol mm-decrypt-function-alist))
6145 (if (equal (car handle) "multipart/signed")
6146 " Signed" " Encrypted")
6149 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6152 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
6153 gnus-tmp-pressed-details
6155 (setq gnus-tmp-details
6156 (if gnus-tmp-details
6157 (concat "\n" gnus-tmp-details) ""))
6158 (setq gnus-tmp-pressed-details
6159 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
6164 gnus-mime-security-button-line-format
6165 gnus-mime-security-button-line-format-alist
6166 `(keymap ,gnus-mime-security-button-map
6167 ,@(if (>= (string-to-number emacs-version) 21)
6168 nil ;; XEmacs doesn't care
6169 (list 'local-map gnus-mime-security-button-map))
6170 gnus-callback gnus-mime-security-press-button
6171 gnus-line-format ,gnus-mime-security-button-line-format
6172 article-type annotation
6175 (widget-convert-button
6178 :action 'gnus-widget-press-button
6179 :button-keymap gnus-mime-security-button-map
6181 (lambda (widget/window &optional overlay pos)
6182 ;; Needed to properly clear the message due to a bug in
6183 ;; wid-edit (XEmacs only).
6184 (if (boundp 'help-echo-owns-message)
6185 (setq help-echo-owns-message t))
6188 (aref gnus-mouse-2 0))))))
6190 (defun gnus-mime-display-security (handle)
6192 (narrow-to-region (point) (point))
6193 (unless (gnus-unbuttonized-mime-type-p (car handle))
6194 (gnus-insert-mime-security-button handle))
6195 (gnus-mime-display-mixed (cdr handle))
6198 (unless (gnus-unbuttonized-mime-type-p (car handle))
6199 (let ((gnus-mime-security-button-line-format
6200 gnus-mime-security-button-end-line-format))
6201 (gnus-insert-mime-security-button handle)))
6202 (mm-set-handle-multipart-parameter
6204 (cons (set-marker (make-marker) (point-min))
6205 (set-marker (make-marker) (point-max))))))
6211 (defun gnus-article-header-presentation-method (entity situation)
6212 (mime-insert-header entity)
6215 (set-alist 'mime-header-presentation-method-alist
6216 'gnus-original-article-mode
6217 #'gnus-article-header-presentation-method)
6219 (defun gnus-mime-preview-quitting-method ()
6220 (mime-preview-kill-buffer)
6221 (delete-other-windows)
6222 (gnus-article-show-summary)
6223 (gnus-summary-select-article gnus-show-all-headers t))
6225 (set-alist 'mime-preview-quitting-method-alist
6226 'gnus-original-article-mode #'gnus-mime-preview-quitting-method)
6228 (set-alist 'mime-preview-following-method-alist
6229 'gnus-original-article-mode #'gnus-following-method)
6231 (set-alist 'mime-preview-over-to-previous-method-alist
6232 'gnus-original-article-mode
6234 (if (> (point-min) 1)
6235 (gnus-article-prev-page)
6236 (gnus-article-read-summary-keys
6237 nil (gnus-character-to-event ?P)))))
6239 (set-alist 'mime-preview-over-to-next-method-alist
6240 'gnus-original-article-mode'
6242 (if (< (point-max) (buffer-size))
6243 (gnus-article-next-page)
6244 (gnus-article-read-summary-keys
6245 nil (gnus-character-to-event ?N)))))
6255 (run-hooks 'gnus-art-load-hook)
6257 ;;; gnus-art.el ends here