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.
713 See also `gnus-buttonized-mime-types' which may override this variable."
715 :group 'gnus-article-mime
716 :type '(repeat regexp))
718 (defcustom gnus-buttonized-mime-types nil
719 "List of MIME types that should be given buttons when rendered inline.
720 If set, this variable overrides `gnus-unbuttonized-mime-types'.
721 To see e.g. security buttons you could set this to
722 `(\"multipart/signed\")'."
724 :group 'gnus-article-mime
725 :type '(repeat regexp))
727 (defcustom gnus-article-mime-part-function nil
728 "Function called with a MIME handle as the argument.
729 This is meant for people who want to do something automatic based
730 on parts -- for instance, adding Vcard info to a database."
731 :group 'gnus-article-mime
734 (defcustom gnus-mime-multipart-functions nil
735 "An alist of MIME types to functions to display them."
737 :group 'gnus-article-mime
740 (defcustom gnus-article-date-lapsed-new-header nil
741 "Whether the X-Sent and Date headers can coexist.
742 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
743 either replace the old \"Date:\" header (if this variable is nil), or
744 be added below it (otherwise)."
746 :group 'gnus-article-headers
749 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
750 "Function called with a MIME handle as the argument.
751 This is meant for people who want to view first matched part.
752 For `undisplayed-alternative' (default), the first undisplayed
753 part or alternative part is used. For `undisplayed', the first
754 undisplayed part is used. For a function, the first part which
755 the function return `t' is used. For `nil', the first part is
758 :group 'gnus-article-mime
760 (item :tag "first" :value nil)
761 (item :tag "undisplayed" :value undisplayed)
762 (item :tag "undisplayed or alternative"
763 :value undisplayed-alternative)
766 (defcustom gnus-mime-action-alist
767 '(("save to file" . gnus-mime-save-part)
768 ("save and strip" . gnus-mime-save-part-and-strip)
769 ("display as text" . gnus-mime-inline-part)
770 ("view the part" . gnus-mime-view-part)
771 ("pipe to command" . gnus-mime-pipe-part)
772 ("toggle display" . gnus-article-press-button)
773 ("toggle display" . gnus-article-view-part-as-charset)
774 ("view as type" . gnus-mime-view-part-as-type)
775 ("internalize type" . gnus-mime-internalize-part)
776 ("externalize type" . gnus-mime-externalize-part))
777 "An alist of actions that run on the MIME attachment."
778 :group 'gnus-article-mime
779 :type '(repeat (cons (string :tag "name")
782 (defcustom gnus-mime-action-alist
783 '(("save to file" . gnus-mime-save-part)
784 ("display as text" . gnus-mime-inline-part)
785 ("view the part" . gnus-mime-view-part)
786 ("pipe to command" . gnus-mime-pipe-part)
787 ("toggle display" . gnus-article-press-button)
788 ("view as type" . gnus-mime-view-part-as-type)
789 ("internalize type" . gnus-mime-internalize-part)
790 ("externalize type" . gnus-mime-externalize-part))
791 "An alist of actions that run on the MIME attachment."
793 :group 'gnus-article-mime
794 :type '(repeat (cons (string :tag "name")
798 ;;; The treatment variables
801 (defvar gnus-part-display-hook nil
802 "Hook called on parts that are to receive treatment.")
804 (defvar gnus-article-treat-custom
805 '(choice (const :tag "Off" nil)
807 (const :tag "Header" head)
808 (const :tag "Last" last)
809 (const :tag "Mime" mime)
810 (integer :tag "Less")
811 (repeat :tag "Groups" regexp)
812 (sexp :tag "Predicate")))
814 (defvar gnus-article-treat-head-custom
815 '(choice (const :tag "Off" nil)
816 (const :tag "Header" head)))
818 (defvar gnus-article-treat-types '("text/plain")
821 (defvar gnus-inhibit-treatment nil
822 "Whether to inhibit treatment.")
824 (defcustom gnus-treat-highlight-signature '(or last (typep "text/x-vcard"))
825 "Highlight the signature.
826 Valid values are nil, t, `head', `last', an integer or a predicate.
827 See the manual for details."
828 :group 'gnus-article-treat
829 :type gnus-article-treat-custom)
830 (put 'gnus-treat-highlight-signature 'highlight t)
832 (defcustom gnus-treat-buttonize 100000
834 Valid values are nil, t, `head', `last', an integer or a predicate.
835 See the manual for details."
836 :group 'gnus-article-treat
837 :type gnus-article-treat-custom)
838 (put 'gnus-treat-buttonize 'highlight t)
840 (defcustom gnus-treat-buttonize-head 'head
841 "Add buttons to the head.
842 Valid values are nil, t, `head', `last', an integer or a predicate.
843 See the manual for details."
844 :group 'gnus-article-treat
845 :type gnus-article-treat-head-custom)
846 (put 'gnus-treat-buttonize-head 'highlight t)
848 (defcustom gnus-treat-emphasize
849 (and (or window-system
851 (>= (string-to-number emacs-version) 21))
854 Valid values are nil, t, `head', `last', an integer or a predicate.
855 See the manual for details."
856 :group 'gnus-article-treat
857 :type gnus-article-treat-custom)
858 (put 'gnus-treat-emphasize 'highlight t)
860 (defcustom gnus-treat-strip-cr nil
861 "Remove carriage returns.
862 Valid values are nil, t, `head', `last', an integer or a predicate.
863 See the manual for details."
864 :group 'gnus-article-treat
865 :type gnus-article-treat-custom)
867 (defcustom gnus-treat-leading-whitespace nil
868 "Remove leading whitespace in headers.
869 Valid values are nil, t, `head', `last', an integer or a predicate.
870 See the manual for details."
871 :group 'gnus-article-treat
872 :type gnus-article-treat-custom)
874 (defcustom gnus-treat-hide-headers 'head
876 Valid values are nil, t, `head', `last', an integer or a predicate.
877 See the manual for details."
878 :group 'gnus-article-treat
879 :type gnus-article-treat-head-custom)
881 (defcustom gnus-treat-hide-boring-headers nil
882 "Hide boring headers.
883 Valid values are nil, t, `head', `last', an integer or a predicate.
884 See the manual for details."
885 :group 'gnus-article-treat
886 :type gnus-article-treat-head-custom)
888 (defcustom gnus-treat-hide-signature nil
890 Valid values are nil, t, `head', `last', an integer or a predicate.
891 See the manual for details."
892 :group 'gnus-article-treat
893 :type gnus-article-treat-custom)
895 (defcustom gnus-treat-fill-article nil
897 Valid values are nil, t, `head', `last', an integer or a predicate.
898 See the manual for details."
899 :group 'gnus-article-treat
900 :type gnus-article-treat-custom)
902 (defcustom gnus-treat-hide-citation nil
904 Valid values are nil, t, `head', `last', an integer or a predicate.
905 See the manual for details."
906 :group 'gnus-article-treat
907 :type gnus-article-treat-custom)
909 (defcustom gnus-treat-hide-citation-maybe nil
911 Valid values are nil, t, `head', `last', an integer or a predicate.
912 See the manual for details."
913 :group 'gnus-article-treat
914 :type gnus-article-treat-custom)
916 (defcustom gnus-treat-hide-citation-maybe nil
918 Valid values are nil, t, `head', `last', an integer or a predicate.
919 See the manual for details."
920 :group 'gnus-article-treat
921 :type gnus-article-treat-custom)
923 (defcustom gnus-treat-strip-list-identifiers 'head
924 "Strip list identifiers from `gnus-list-identifiers`.
925 Valid values are nil, t, `head', `last', an integer or a predicate.
926 See the manual for details."
928 :group 'gnus-article-treat
929 :type gnus-article-treat-custom)
931 (defcustom gnus-treat-strip-pgp t
932 "Strip PGP signatures.
933 Valid values are nil, t, `head', `last', an integer or a predicate.
934 See the manual for details."
935 :group 'gnus-article-treat
936 :type gnus-article-treat-custom)
938 (defcustom gnus-treat-strip-pem nil
939 "Strip PEM signatures.
940 Valid values are nil, t, `head', `last', an integer or a predicate.
941 See the manual for details."
942 :group 'gnus-article-treat
943 :type gnus-article-treat-custom)
945 (defcustom gnus-treat-strip-banner t
946 "Strip banners from articles.
947 The banner to be stripped is specified in the `banner' group parameter.
948 Valid values are nil, t, `head', `last', an integer or a predicate.
949 See the manual for details."
950 :group 'gnus-article-treat
951 :type gnus-article-treat-custom)
953 (defcustom gnus-treat-highlight-headers 'head
954 "Highlight the headers.
955 Valid values are nil, t, `head', `last', an integer or a predicate.
956 See the manual for details."
957 :group 'gnus-article-treat
958 :type gnus-article-treat-head-custom)
959 (put 'gnus-treat-highlight-headers 'highlight t)
961 (defcustom gnus-treat-highlight-citation t
962 "Highlight cited text.
963 Valid values are nil, t, `head', `last', an integer or a predicate.
964 See the manual for details."
965 :group 'gnus-article-treat
966 :type gnus-article-treat-custom)
967 (put 'gnus-treat-highlight-citation 'highlight t)
969 (defcustom gnus-treat-date-ut nil
970 "Display the Date in UT (GMT).
971 Valid values are nil, t, `head', `last', an integer or a predicate.
972 See the manual for details."
973 :group 'gnus-article-treat
974 :type gnus-article-treat-head-custom)
976 (defcustom gnus-treat-date-local nil
977 "Display the Date in the local timezone.
978 Valid values are nil, t, `head', `last', an integer or a predicate.
979 See the manual for details."
980 :group 'gnus-article-treat
981 :type gnus-article-treat-head-custom)
983 (defcustom gnus-treat-date-english nil
984 "Display the Date in a format that can be read aloud in English.
985 Valid values are nil, t, `head', `last', an integer or a predicate.
986 See the manual for details."
987 :group 'gnus-article-treat
988 :type gnus-article-treat-head-custom)
990 (defcustom gnus-treat-date-lapsed nil
991 "Display the Date header in a way that says how much time has elapsed.
992 Valid values are nil, t, `head', `last', an integer or a predicate.
993 See the manual for details."
994 :group 'gnus-article-treat
995 :type gnus-article-treat-head-custom)
997 (defcustom gnus-treat-date-original nil
998 "Display the date in the original timezone.
999 Valid values are nil, t, `head', `last', an integer or a predicate.
1000 See the manual for details."
1001 :group 'gnus-article-treat
1002 :type gnus-article-treat-head-custom)
1004 (defcustom gnus-treat-date-iso8601 nil
1005 "Display the date in the ISO8601 format.
1006 Valid values are nil, t, `head', `last', an integer or a predicate.
1007 See the manual for details."
1009 :group 'gnus-article-treat
1010 :type gnus-article-treat-head-custom)
1012 (defcustom gnus-treat-date-user-defined nil
1013 "Display the date in a user-defined format.
1014 The format is defined by the `gnus-article-time-format' variable.
1015 Valid values are nil, t, `head', `last', an integer or a predicate.
1016 See the manual for details."
1017 :group 'gnus-article-treat
1018 :type gnus-article-treat-head-custom)
1020 (defcustom gnus-treat-strip-headers-in-body t
1021 "Strip the X-No-Archive header line from the beginning of the body.
1022 Valid values are nil, t, `head', `last', an integer or a predicate.
1023 See the manual for details."
1025 :group 'gnus-article-treat
1026 :type gnus-article-treat-custom)
1028 (defcustom gnus-treat-strip-trailing-blank-lines nil
1029 "Strip trailing blank lines.
1030 Valid values are nil, t, `head', `last', an integer or a predicate.
1031 See the manual for details."
1032 :group 'gnus-article-treat
1033 :type gnus-article-treat-custom)
1035 (defcustom gnus-treat-strip-leading-blank-lines nil
1036 "Strip leading blank lines.
1037 Valid values are nil, t, `head', `last', an integer or a predicate.
1038 See the manual for details."
1039 :group 'gnus-article-treat
1040 :type gnus-article-treat-custom)
1042 (defcustom gnus-treat-strip-multiple-blank-lines nil
1043 "Strip multiple blank lines.
1044 Valid values are nil, t, `head', `last', an integer or a predicate.
1045 See the manual for details."
1046 :group 'gnus-article-treat
1047 :type gnus-article-treat-custom)
1049 (defcustom gnus-treat-overstrike t
1050 "Treat overstrike highlighting.
1051 Valid values are nil, t, `head', `last', an integer or a predicate.
1052 See the manual for details."
1053 :group 'gnus-article-treat
1054 :type gnus-article-treat-custom)
1055 (put 'gnus-treat-overstrike 'highlight t)
1057 (defcustom gnus-treat-display-xface
1058 (and (or (and (fboundp 'image-type-available-p)
1059 (image-type-available-p 'xbm)
1060 (string-match "^0x" (shell-command-to-string "uncompface")))
1061 (and (featurep 'xemacs) (featurep 'xface))
1062 (eq 'x-face-mule-gnus-article-display-x-face
1063 gnus-article-x-face-command))
1065 "Display X-Face headers.
1066 Valid values are nil, t, `head', `last', an integer or a predicate.
1067 See the manual for details."
1068 :group 'gnus-article-treat
1070 :type gnus-article-treat-head-custom)
1071 (put 'gnus-treat-display-xface 'highlight t)
1073 (defcustom gnus-treat-display-smileys
1074 (if (or (and (featurep 'xemacs)
1076 (and (fboundp 'image-type-available-p)
1077 (image-type-available-p 'pbm))
1078 (and (not (featurep 'xemacs))
1080 (module-installed-p 'smiley-mule)))
1084 Valid values are nil, t, `head', `last', an integer or a predicate.
1085 See the manual for details."
1086 :group 'gnus-article-treat
1088 :type gnus-article-treat-custom)
1089 (put 'gnus-treat-display-smileys 'highlight t)
1091 (defcustom gnus-treat-display-picons (if (featurep 'xemacs) 'head nil)
1093 Valid values are nil, t, `head', `last', an integer or a predicate.
1094 See the manual for details."
1095 :group 'gnus-article-treat
1096 :type gnus-article-treat-head-custom)
1097 (put 'gnus-treat-display-picons 'highlight t)
1099 (defcustom gnus-treat-capitalize-sentences nil
1100 "Capitalize sentence-starting words.
1101 Valid values are nil, t, `head', `last', an integer or a predicate.
1102 See the manual for details."
1104 :group 'gnus-article-treat
1105 :type gnus-article-treat-custom)
1107 (defcustom gnus-treat-fill-long-lines nil
1109 Valid values are nil, t, `head', `last', an integer or a predicate.
1110 See the manual for details."
1111 :group 'gnus-article-treat
1112 :type gnus-article-treat-custom)
1114 (defcustom gnus-treat-play-sounds nil
1116 Valid values are nil, t, `head', `last', an integer or a predicate.
1117 See the manual for details."
1119 :group 'gnus-article-treat
1120 :type gnus-article-treat-custom)
1122 (defcustom gnus-treat-decode-article-as-default-mime-charset nil
1123 "Decode an article as `default-mime-charset'. For instance, if you want to
1124 attempt to decode an article even if the value of `gnus-show-mime' is nil,
1125 you could set this variable to something like: nil for don't decode, t for
1126 decode the body, '(or header t) for the whole article, etc."
1127 :group 'gnus-article-treat
1128 :type '(radio (const :tag "Off" nil)
1129 (const :tag "Decode body" t)
1130 (const :tag "Decode all" (or head t))))
1132 (defcustom gnus-treat-translate nil
1133 "Translate articles from one language to another.
1134 Valid values are nil, t, `head', `last', an integer or a predicate.
1135 See the manual for details."
1137 :group 'gnus-article-treat
1138 :type gnus-article-treat-custom)
1140 (defcustom gnus-treat-x-pgp-sig nil
1142 To automatically treat X-PGP-Sig, set it to head.
1143 Valid values are nil, t, `head', `last', an integer or a predicate.
1144 See the manual for details."
1145 :group 'gnus-article-treat
1146 :group 'mime-security
1147 :type gnus-article-treat-custom)
1149 (defvar gnus-article-encrypt-protocol-alist
1150 '(("PGP" . mml2015-self-encrypt)))
1152 ;; Set to nil if more than one protocol added to
1153 ;; gnus-article-encrypt-protocol-alist.
1154 (defcustom gnus-article-encrypt-protocol "PGP"
1155 "The protocol used for encrypt articles.
1156 It is a string, such as \"PGP\". If nil, ask user."
1158 :group 'mime-security)
1160 ;;; Internal variables
1162 (defvar gnus-english-month-names
1163 '("January" "February" "March" "April" "May" "June" "July" "August"
1164 "September" "October" "November" "December"))
1166 (defvar article-goto-body-goes-to-point-min-p nil)
1167 (defvar gnus-article-wash-types nil)
1168 (defvar gnus-article-emphasis-alist nil)
1170 (defvar gnus-article-mime-handle-alist-1 nil)
1171 (defvar gnus-treatment-function-alist
1172 `((gnus-treat-decode-article-as-default-mime-charset
1173 gnus-article-decode-article-as-default-mime-charset)
1174 (gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1175 (gnus-treat-strip-banner gnus-article-strip-banner)
1176 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1177 (gnus-treat-buttonize gnus-article-add-buttons)
1178 (gnus-treat-fill-article gnus-article-fill-cited-article)
1179 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1180 (gnus-treat-strip-cr gnus-article-remove-cr)
1181 (gnus-treat-display-xface gnus-article-display-x-face)
1182 (gnus-treat-date-ut gnus-article-date-ut)
1183 (gnus-treat-date-local gnus-article-date-local)
1184 (gnus-treat-date-english gnus-article-date-english)
1185 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1186 (gnus-treat-date-original gnus-article-date-original)
1187 (gnus-treat-date-user-defined gnus-article-date-user)
1188 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1189 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1190 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1191 (gnus-treat-hide-signature gnus-article-hide-signature)
1192 (gnus-treat-hide-citation gnus-article-hide-citation)
1193 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1194 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1195 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1196 (gnus-treat-strip-pgp gnus-article-hide-pgp)
1197 (gnus-treat-strip-pem gnus-article-hide-pem)
1198 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1199 (gnus-treat-emphasize gnus-article-emphasize)
1200 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1201 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1202 (gnus-treat-strip-trailing-blank-lines
1203 gnus-article-remove-trailing-blank-lines)
1204 (gnus-treat-strip-leading-blank-lines
1205 gnus-article-strip-leading-blank-lines)
1206 (gnus-treat-strip-multiple-blank-lines
1207 gnus-article-strip-multiple-blank-lines)
1208 (gnus-treat-overstrike gnus-article-treat-overstrike)
1209 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1210 (gnus-treat-display-smileys ,(if (or (featurep 'xemacs)
1211 (>= emacs-major-version 21))
1212 'gnus-smiley-display
1213 'gnus-article-smiley-display))
1214 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1215 (gnus-treat-display-picons gnus-article-display-picons)
1216 (gnus-treat-play-sounds gnus-earcon-display)))
1218 (defvar gnus-article-mime-handle-alist nil)
1219 (defvar article-lapsed-timer nil)
1220 (defvar gnus-article-current-summary nil)
1222 (defvar gnus-article-mode-syntax-table
1223 (let ((table (copy-syntax-table text-mode-syntax-table)))
1224 ;; This causes the citation match run O(2^n).
1225 ;; (modify-syntax-entry ?- "w" table)
1226 (modify-syntax-entry ?> ")" table)
1227 (modify-syntax-entry ?< "(" table)
1229 "Syntax table used in article mode buffers.
1230 Initialized from `text-mode-syntax-table.")
1232 (defvar gnus-save-article-buffer nil)
1234 (defvar gnus-article-mode-line-format-alist
1235 (nconc '((?w (gnus-article-wash-status) ?s)
1236 (?m (gnus-article-mime-part-status) ?s))
1237 gnus-summary-mode-line-format-alist))
1239 (defvar gnus-number-of-articles-to-be-saved nil)
1241 (defvar gnus-inhibit-hiding nil)
1243 (defsubst gnus-article-hide-text (b e props)
1244 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1245 (gnus-add-text-properties-when 'article-type nil b e props)
1246 (when (memq 'intangible props)
1248 (max (1- b) (point-min))
1249 b 'intangible (cddr (memq 'intangible props)))))
1251 (defsubst gnus-article-unhide-text (b e)
1252 "Remove hidden text properties from region between B and E."
1253 (remove-text-properties b e gnus-hidden-properties)
1254 (when (memq 'intangible gnus-hidden-properties)
1255 (put-text-property (max (1- b) (point-min))
1256 b 'intangible nil)))
1258 (defun gnus-article-hide-text-type (b e type)
1259 "Hide text of TYPE between B and E."
1260 (push type gnus-article-wash-types)
1261 (gnus-article-hide-text
1262 b e (cons 'article-type (cons type gnus-hidden-properties))))
1264 (defun gnus-article-unhide-text-type (b e type)
1265 "Unhide text of TYPE between B and E."
1266 (setq gnus-article-wash-types
1267 (delq type gnus-article-wash-types))
1268 (remove-text-properties
1269 b e (cons 'article-type (cons type gnus-hidden-properties)))
1270 (when (memq 'intangible gnus-hidden-properties)
1271 (put-text-property (max (1- b) (point-min))
1272 b 'intangible nil)))
1274 (defun gnus-article-hide-text-of-type (type)
1275 "Hide text of TYPE in the current buffer."
1277 (let ((b (point-min))
1279 (while (setq b (text-property-any b e 'article-type type))
1280 (add-text-properties b (incf b) gnus-hidden-properties)))))
1282 (defun gnus-article-delete-text-of-type (type)
1283 "Delete text of TYPE in the current buffer."
1285 (let ((b (point-min)))
1286 (while (setq b (text-property-any b (point-max) 'article-type type))
1288 b (or (text-property-not-all b (point-max) 'article-type type)
1291 (defun gnus-article-delete-invisible-text ()
1292 "Delete all invisible text in the current buffer."
1294 (let ((b (point-min)))
1295 (while (setq b (text-property-any b (point-max) 'invisible t))
1297 b (or (text-property-not-all b (point-max) 'invisible t)
1300 (defun gnus-article-text-type-exists-p (type)
1301 "Say whether any text of type TYPE exists in the buffer."
1302 (text-property-any (point-min) (point-max) 'article-type type))
1304 (defsubst gnus-article-header-rank ()
1305 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1306 (let ((list gnus-sorted-header-list)
1309 (when (looking-at (car list))
1311 (setq list (cdr list))
1315 (defun article-hide-headers (&optional arg delete)
1316 "Hide unwanted headers and possibly sort them as well."
1317 (interactive (gnus-article-hidden-arg))
1318 ;; Lars said that this function might be inhibited.
1319 (if (gnus-article-check-hidden-text 'headers arg)
1321 ;; Show boring headers as well.
1322 (gnus-article-show-hidden-text 'boring-headers)
1323 (when (eq 1 (point-min))
1324 (set-window-start (get-buffer-window (current-buffer)) 1)))
1325 (unless gnus-inhibit-hiding
1328 (let ((inhibit-read-only t)
1329 (case-fold-search t)
1330 (max (1+ (length gnus-sorted-header-list)))
1331 (ignored (when (not gnus-visible-headers)
1332 (cond ((stringp gnus-ignored-headers)
1333 gnus-ignored-headers)
1334 ((listp gnus-ignored-headers)
1335 (mapconcat 'identity gnus-ignored-headers
1338 (cond ((stringp gnus-visible-headers)
1339 gnus-visible-headers)
1340 ((and gnus-visible-headers
1341 (listp gnus-visible-headers))
1342 (mapconcat 'identity gnus-visible-headers "\\|"))))
1343 (inhibit-point-motion-hooks t)
1345 ;; First we narrow to just the headers.
1346 (article-narrow-to-head)
1347 ;; Hide any "From " lines at the beginning of (mail) articles.
1348 (while (looking-at "From ")
1352 (delete-region (point-min) (point))
1353 (gnus-article-hide-text (point-min) (point)
1354 (nconc (list 'article-type 'headers)
1355 gnus-hidden-properties))))
1356 ;; Then treat the rest of the header lines.
1357 ;; Then we use the two regular expressions
1358 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1359 ;; select which header lines is to remain visible in the
1361 (while (re-search-forward "^[^ \t:]*:" nil t)
1363 ;; Mark the rank of the header.
1365 (point) (1+ (point)) 'message-rank
1366 (if (or (and visible (looking-at visible))
1368 (not (looking-at ignored))))
1369 (gnus-article-header-rank)
1372 (message-sort-headers-1)
1373 (when (setq beg (text-property-any
1374 (point-min) (point-max) 'message-rank (+ 2 max)))
1375 ;; We delete or make invisible the unwanted headers.
1376 (push 'headers gnus-article-wash-types)
1379 (add-text-properties
1380 (point-min) (+ 5 (point-min))
1381 '(article-type headers dummy-invisible t))
1382 (delete-region beg (point-max)))
1383 (gnus-article-hide-text-type beg (point-max) 'headers))))))))
1386 (defun article-hide-boring-headers (&optional arg)
1387 "Toggle hiding of headers that aren't very interesting.
1388 If given a negative prefix, always show; if given a positive prefix,
1390 (interactive (gnus-article-hidden-arg))
1391 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1392 (not gnus-show-all-headers))
1395 (let ((buffer-read-only nil)
1396 (list gnus-boring-article-headers)
1397 (inhibit-point-motion-hooks t)
1399 (article-narrow-to-head)
1401 (setq elem (pop list))
1402 (goto-char (point-min))
1404 ;; Hide empty headers.
1406 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1408 (gnus-article-hide-text-type
1409 (progn (beginning-of-line) (point))
1412 (if (re-search-forward "^[^ \t]" nil t)
1416 ;; Hide boring Newsgroups header.
1417 ((eq elem 'newsgroups)
1418 (when (gnus-string-equal
1419 (gnus-fetch-field "newsgroups")
1420 (gnus-group-real-name
1421 (if (boundp 'gnus-newsgroup-name)
1424 (gnus-article-hide-header "newsgroups")))
1425 ((eq elem 'to-address)
1426 (let ((to (message-fetch-field "to"))
1428 (gnus-parameter-to-address
1429 (if (boundp 'gnus-newsgroup-name)
1430 gnus-newsgroup-name ""))))
1431 (when (and to to-address
1434 ;; only one address in To
1435 (nth 1 (mail-extract-address-components to))
1437 (gnus-article-hide-header "to"))))
1438 ((eq elem 'followup-to)
1439 (when (gnus-string-equal
1440 (message-fetch-field "followup-to")
1441 (message-fetch-field "newsgroups"))
1442 (gnus-article-hide-header "followup-to")))
1443 ((eq elem 'reply-to)
1444 (let ((from (message-fetch-field "from"))
1445 (reply-to (message-fetch-field "reply-to")))
1450 (nth 1 (mail-extract-address-components from))
1451 (nth 1 (mail-extract-address-components reply-to)))))
1452 (gnus-article-hide-header "reply-to"))))
1454 (let ((date (message-fetch-field "date")))
1456 (< (days-between (current-time-string) date)
1458 (gnus-article-hide-header "date"))))
1460 (let ((to (message-fetch-field "to"))
1461 (cc (message-fetch-field "cc")))
1462 (when (> (length to) 1024)
1463 (gnus-article-hide-header "to"))
1464 (when (> (length cc) 1024)
1465 (gnus-article-hide-header "cc"))))
1469 (goto-char (point-min))
1470 (while (re-search-forward "^to:" nil t)
1471 (setq to-count (1+ to-count)))
1472 (when (> to-count 1)
1473 (while (> to-count 0)
1474 (goto-char (point-min))
1476 (re-search-forward "^to:" nil nil to-count)
1478 (narrow-to-region (point) (point-max))
1479 (gnus-article-hide-header "to"))
1480 (setq to-count (1- to-count))))
1481 (goto-char (point-min))
1482 (while (re-search-forward "^cc:" nil t)
1483 (setq cc-count (1+ cc-count)))
1484 (when (> cc-count 1)
1485 (while (> cc-count 0)
1486 (goto-char (point-min))
1488 (re-search-forward "^cc:" nil nil cc-count)
1490 (narrow-to-region (point) (point-max))
1491 (gnus-article-hide-header "cc"))
1492 (setq cc-count (1- cc-count)))))))))))))
1494 (defun gnus-article-hide-header (header)
1496 (goto-char (point-min))
1497 (when (re-search-forward (concat "^" header ":") nil t)
1498 (gnus-article-hide-text-type
1499 (progn (beginning-of-line) (point))
1502 (if (re-search-forward "^[^ \t]" nil t)
1507 (defun article-toggle-headers (&optional arg)
1508 "Toggle hiding of headers. If given a negative prefix, always show;
1509 if given a positive prefix, always hide."
1510 (interactive (gnus-article-hidden-arg))
1511 (let ((force (when (numberp arg)
1512 (cond ((> arg 0) 'always-hide)
1513 ((< arg 0) 'always-show))))
1514 (window (get-buffer-window gnus-article-buffer))
1515 (header-end (point-min))
1516 header-start field-end field-start
1517 (inhibit-point-motion-hooks t)
1518 (inhibit-read-only t))
1521 (while (and (setq header-start
1522 (text-property-any header-end (point-max)
1523 'article-treated-header t))
1525 (text-property-not-all header-start (point-max)
1526 'article-treated-header t)))
1527 (setq field-end header-start)
1529 (;; Hide exposed invisible fields.
1530 (and (not (eq 'always-show force))
1532 (text-property-any field-end header-end
1533 'exposed-invisible-field t)))
1534 (while (and field-start
1535 (setq field-end (text-property-not-all
1536 field-start header-end
1537 'exposed-invisible-field t)))
1538 (add-text-properties field-start field-end gnus-hidden-properties)
1539 (setq field-start (text-property-any field-end header-end
1540 'exposed-invisible-field t)))
1541 (put-text-property header-start header-end
1542 'exposed-invisible-field nil))
1543 (;; Expose invisible fields.
1544 (and (not (eq 'always-hide force))
1546 (text-property-any field-end header-end 'invisible t)))
1547 (while (and field-start
1548 (setq field-end (text-property-not-all
1549 field-start header-end
1551 ;; If the invisible text is not terminated with newline, we
1552 ;; won't expose it. Because it may be created by x-face-mule.
1553 ;; BTW, XEmacs sometimes fail in putting a invisible text
1554 ;; property with `gnus-article-hide-text' (really?). In that
1555 ;; case, the invisible text might be started from the middle of
1556 ;; a line so we will expose the sort of thing.
1557 (when (or (not (or (eq header-start field-start)
1558 (eq ?\n (char-before field-start))))
1559 (eq ?\n (char-before field-end)))
1560 (remove-text-properties field-start field-end
1561 gnus-hidden-properties)
1562 (put-text-property field-start field-end
1563 'exposed-invisible-field t))
1564 (setq field-start (text-property-any field-end header-end
1567 (not (eq 'always-show force))
1568 (narrow-to-region header-start header-end)
1569 (article-hide-headers)
1570 ;; Re-display X-Face image under XEmacs.
1571 (when (and (featurep 'xemacs)
1572 (gnus-functionp gnus-article-x-face-command))
1573 (let ((func (cadr (assq 'gnus-treat-display-xface
1574 gnus-treatment-function-alist)))
1576 (when (and (not gnus-inhibit-treatment)
1578 (gnus-treat-predicate gnus-treat-display-xface))
1580 (put-text-property header-start header-end 'read-only nil))))
1583 (goto-char (point-min))
1585 (set-window-start window (point-min))))))
1587 (defvar gnus-article-normalized-header-length 40
1588 "Length of normalized headers.")
1590 (defun article-normalize-headers ()
1591 "Make all header lines 40 characters long."
1593 (let ((buffer-read-only nil)
1597 (article-narrow-to-head)
1600 ((< (setq column (- (gnus-point-at-eol) (point)))
1601 gnus-article-normalized-header-length)
1603 (insert (make-string
1604 (- gnus-article-normalized-header-length column)
1606 ((> column gnus-article-normalized-header-length)
1607 (gnus-put-text-property
1609 (forward-char gnus-article-normalized-header-length)
1616 (forward-line 1))))))
1618 (defun article-treat-dumbquotes ()
1619 "Translate M****s*** sm*rtq**t*s into proper text.
1620 Note that this function guesses whether a character is a sm*rtq**t* or
1621 not, so it should only be used interactively.
1623 Sm*rtq**t*s are M****s***'s unilateral extension to the character map
1624 in an attempt to provide more quoting characters. If you see
1625 something like \\222 or \\264 where you're expecting some kind of
1626 apostrophe or quotation mark, then try this wash."
1628 (article-translate-strings gnus-article-dumbquotes-map))
1630 (defun article-translate-characters (from to)
1631 "Translate all characters in the body of the article according to FROM and TO.
1632 FROM is a string of characters to translate from; to is a string of
1633 characters to translate to."
1635 (when (article-goto-body)
1636 (let ((buffer-read-only nil)
1637 (x (make-string 225 ?x))
1639 (while (< (incf i) (length x))
1642 (while (< i (length from))
1643 (aset x (aref from i) (aref to i))
1645 (translate-region (point) (point-max) x)))))
1647 (defun article-translate-strings (map)
1648 "Translate all string in the body of the article according to MAP.
1649 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1651 (when (article-goto-body)
1652 (let ((buffer-read-only nil)
1654 (while (setq elem (pop map))
1656 (while (search-forward (car elem) nil t)
1657 (replace-match (cadr elem)))))))))
1659 (defun article-treat-overstrike ()
1660 "Translate overstrikes into bold text."
1663 (when (article-goto-body)
1664 (let ((buffer-read-only nil))
1665 (while (search-forward "\b" nil t)
1666 (let ((next (char-after))
1670 previous (char-after))
1674 ;; We do the boldification/underlining by hiding the
1675 ;; overstrikes and putting the proper text property
1679 (gnus-article-hide-text-type start (point) 'overstrike)
1680 (put-text-property (point) end 'face 'bold))
1682 (gnus-article-hide-text-type
1683 (1- (point)) (1+ (point)) 'overstrike)
1685 start (1- (point)) 'face 'underline))
1687 (gnus-article-hide-text-type start (point) 'overstrike)
1689 (point) end 'face 'underline)))))))))
1691 (defun article-fill-long-lines ()
1692 "Fill lines that are wider than the window width."
1695 (let ((buffer-read-only nil)
1696 (width (window-width (get-buffer-window (current-buffer)))))
1699 (let ((adaptive-fill-mode nil)) ;Why? -sm
1702 (when (>= (current-column) (min fill-column width))
1703 (narrow-to-region (point) (gnus-point-at-bol))
1704 (fill-paragraph nil)
1705 (goto-char (point-max))
1707 (forward-line 1)))))))
1709 (defun article-capitalize-sentences ()
1710 "Capitalize the first word in each sentence."
1713 (let ((buffer-read-only nil)
1714 (paragraph-start "^[\n\^L]"))
1718 (forward-sentence)))))
1720 (defun article-remove-cr ()
1721 "Remove trailing CRs and then translate remaining CRs into LFs."
1724 (let ((buffer-read-only nil))
1725 (goto-char (point-min))
1726 (while (re-search-forward "\r+$" nil t)
1727 (replace-match "" t t))
1728 (goto-char (point-min))
1729 (while (search-forward "\r" nil t)
1730 (replace-match "\n" t t)))))
1732 (defun article-remove-trailing-blank-lines ()
1733 "Remove all trailing blank lines from the article."
1736 (let ((buffer-read-only nil))
1737 (goto-char (point-max))
1741 (while (and (not (bobp))
1742 (looking-at "^[ \t]*$")
1743 (not (gnus-annotation-in-region-p
1744 (point) (gnus-point-at-eol))))
1749 (defun article-display-x-face (&optional force)
1750 "Look for an X-Face header and display it if present."
1751 (interactive (list 'force))
1753 ;; Delete the old process, if any.
1754 (when (process-status "article-x-face")
1755 (delete-process "article-x-face"))
1756 (let ((inhibit-point-motion-hooks t)
1758 (case-fold-search t)
1761 (article-narrow-to-head)
1762 ;; (when (and buffer-read-only ;; When type `W f'
1764 ;; (goto-char (point-min))
1765 ;; (not (re-search-forward "^X-Face:[\t ]*" nil t)))
1766 ;; (gnus-buffer-live-p gnus-original-article-buffer))
1767 ;; (with-current-buffer gnus-original-article-buffer
1768 ;; (save-restriction
1769 ;; (article-narrow-to-head)
1770 ;; (while (re-search-forward "^X-Face:" nil t)
1774 ;; (buffer-substring
1775 ;; (match-beginning 0)
1776 ;; (1- (re-search-forward
1777 ;; "^\\($\\|[^ \t]\\)" nil t))))))))
1779 ;; (let (point start bface eface buffer-read-only)
1780 ;; (goto-char (point-max))
1781 ;; (forward-line -1)
1782 ;; (setq bface (get-text-property (gnus-point-at-bol) 'face)
1783 ;; eface (get-text-property (1- (gnus-point-at-eol)) 'face))
1784 ;; (goto-char (point-max))
1785 ;; (setq point (point))
1787 ;; (goto-char point)
1788 ;; (while (looking-at "\\([^:]+\\): *")
1789 ;; (put-text-property (match-beginning 1) (1+ (match-end 1))
1791 ;; (setq start (match-end 0))
1793 ;; (while (looking-at "[\t ]")
1794 ;; (forward-line 1))
1795 ;; (put-text-property start (point)
1797 (goto-char (point-min))
1798 (setq from (message-fetch-field "from"))
1799 (goto-char (point-min))
1800 (while (and gnus-article-x-face-command
1803 ;; Check whether this face is censored.
1804 (not gnus-article-x-face-too-ugly)
1805 (and gnus-article-x-face-too-ugly from
1806 (not (string-match gnus-article-x-face-too-ugly
1808 ;; Has to be present.
1809 (re-search-forward "^X-Face:[\t ]*" nil t))
1810 ;; This used to try to do multiple faces (`while' instead of
1811 ;; `when' above), but (a) sending multiple EOFs to xv doesn't
1812 ;; work (b) it can crash some versions of Emacs (c) are
1813 ;; multiple faces really something to encourage?
1814 (when (stringp gnus-article-x-face-command)
1816 ;; We now have the area of the buffer where the X-Face is stored.
1819 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
1820 ;; We display the face.
1821 (if (symbolp gnus-article-x-face-command)
1822 ;; The command is a lisp function, so we call it.
1823 (if (gnus-functionp gnus-article-x-face-command)
1824 (funcall gnus-article-x-face-command beg end)
1825 (error "%s is not a function" gnus-article-x-face-command))
1826 ;; The command is a string, so we interpret the command
1827 ;; as a, well, command, and fork it off.
1828 (let ((process-connection-type nil))
1829 (process-kill-without-query
1831 "article-x-face" nil shell-file-name shell-command-switch
1832 gnus-article-x-face-command))
1833 (process-send-region "article-x-face" beg end)
1834 (process-send-eof "article-x-face"))))))))))
1836 (defun article-decode-mime-words ()
1837 "Decode all MIME-encoded words in the article."
1840 (set-buffer gnus-article-buffer)
1841 (let ((inhibit-point-motion-hooks t)
1843 (mail-parse-charset gnus-newsgroup-charset)
1844 (mail-parse-ignored-charsets
1845 (save-excursion (set-buffer gnus-summary-buffer)
1846 gnus-newsgroup-ignored-charsets)))
1847 (mail-decode-encoded-word-region (point-min) (point-max)))))
1849 (defun article-decode-charset (&optional prompt)
1850 "Decode charset-encoded text in the article.
1851 If PROMPT (the prefix), prompt for a coding system to use."
1853 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
1855 (mail-parse-charset gnus-newsgroup-charset)
1856 (mail-parse-ignored-charsets
1857 (save-excursion (condition-case nil
1858 (set-buffer gnus-summary-buffer)
1860 gnus-newsgroup-ignored-charsets))
1861 ct cte ctl charset format)
1864 (article-narrow-to-head)
1865 (setq ct (message-fetch-field "Content-Type" t)
1866 cte (message-fetch-field "Content-Transfer-Encoding" t)
1867 ctl (and ct (ignore-errors
1868 (mail-header-parse-content-type ct)))
1871 (mm-read-coding-system "Charset to decode: "))
1873 (mail-content-type-get ctl 'charset)))
1874 format (and ctl (mail-content-type-get ctl 'format)))
1876 (setq cte (mail-header-strip cte)))
1877 (if (and ctl (not (string-match "/" (car ctl))))
1879 (goto-char (point-max)))
1882 (narrow-to-region (point) (point-max))
1883 (when (and (eq mail-parse-charset 'gnus-decoded)
1884 (eq (mm-body-7-or-8) '8bit))
1885 ;; The text code could have been decoded.
1886 (setq charset mail-parse-charset))
1887 (when (and (or (not ctl)
1888 (equal (car ctl) "text/plain"))
1889 (not format)) ;; article with format will decode later.
1891 charset (and cte (intern (downcase
1892 (gnus-strip-whitespace cte))))
1895 (defun article-decode-encoded-words ()
1896 "Remove encoded-word encoding from headers."
1897 (let (buffer-read-only)
1898 (let ((charset (save-excursion
1899 (set-buffer gnus-summary-buffer)
1900 default-mime-charset)))
1901 (mime-decode-header-in-buffer charset)
1904 (defun article-de-quoted-unreadable (&optional force read-charset)
1905 "Translate a quoted-printable-encoded article.
1906 If FORCE, decode the article whether it is marked as quoted-printable
1908 If READ-CHARSET, ask for a coding system."
1909 (interactive (list 'force current-prefix-arg))
1911 (let ((buffer-read-only nil) type charset)
1912 (if (gnus-buffer-live-p gnus-original-article-buffer)
1913 (with-current-buffer gnus-original-article-buffer
1915 (gnus-fetch-field "content-transfer-encoding"))
1916 (let* ((ct (gnus-fetch-field "content-type"))
1919 (mail-header-parse-content-type ct)))))
1920 (setq charset (and ctl
1921 (mail-content-type-get ctl 'charset)))
1922 (if (stringp charset)
1923 (setq charset (intern (downcase charset)))))))
1925 (setq charset (mm-read-coding-system "Charset: " charset)))
1927 (setq charset gnus-newsgroup-charset))
1929 (and type (let ((case-fold-search t))
1930 (string-match "quoted-printable" type))))
1932 (quoted-printable-decode-region
1933 (point) (point-max) (mm-charset-to-coding-system charset))))))
1935 (defun article-de-base64-unreadable (&optional force read-charset)
1936 "Translate a base64 article.
1937 If FORCE, decode the article whether it is marked as base64 not.
1938 If READ-CHARSET, ask for a coding system."
1939 (interactive (list 'force current-prefix-arg))
1941 (let ((buffer-read-only nil) type charset)
1942 (if (gnus-buffer-live-p gnus-original-article-buffer)
1943 (with-current-buffer gnus-original-article-buffer
1945 (gnus-fetch-field "content-transfer-encoding"))
1946 (let* ((ct (gnus-fetch-field "content-type"))
1949 (mail-header-parse-content-type ct)))))
1950 (setq charset (and ctl
1951 (mail-content-type-get ctl 'charset)))
1952 (if (stringp charset)
1953 (setq charset (intern (downcase charset)))))))
1955 (setq charset (mm-read-coding-system "Charset: " charset)))
1957 (setq charset gnus-newsgroup-charset))
1959 (and type (let ((case-fold-search t))
1960 (string-match "base64" type))))
1963 (narrow-to-region (point) (point-max))
1964 (base64-decode-region (point-min) (point-max))
1965 (mm-decode-coding-region
1966 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
1971 (defun article-decode-HZ ()
1972 "Translate a HZ-encoded article."
1976 (let ((buffer-read-only nil))
1977 (rfc1843-decode-region (point-min) (point-max)))))
1979 (defun article-wash-html (&optional read-charset)
1980 "Format an html article.
1981 If READ-CHARSET, ask for a coding system."
1984 (let ((buffer-read-only nil)
1986 (if (gnus-buffer-live-p gnus-original-article-buffer)
1987 (with-current-buffer gnus-original-article-buffer
1988 (let* ((ct (gnus-fetch-field "content-type"))
1991 (mail-header-parse-content-type ct)))))
1992 (setq charset (and ctl
1993 (mail-content-type-get ctl 'charset)))
1994 (if (stringp charset)
1995 (setq charset (intern (downcase charset)))))))
1997 (setq charset (mm-read-coding-system "Charset: " charset)))
1999 (setq charset gnus-newsgroup-charset))
2001 (save-window-excursion
2003 (narrow-to-region (point) (point-max))
2005 (let ((w3-strict-width (window-width))
2006 (url-standalone-mode t))
2008 (w3-region (point-min) (point-max))
2011 (defun article-hide-list-identifiers ()
2012 "Remove list identifies from the Subject header.
2013 The `gnus-list-identifiers' variable specifies what to do."
2015 (let ((inhibit-point-motion-hooks t)
2016 (regexp (if (consp gnus-list-identifiers)
2017 (mapconcat 'identity gnus-list-identifiers " *\\|")
2018 gnus-list-identifiers))
2023 (article-narrow-to-head)
2024 (goto-char (point-min))
2025 (while (re-search-forward
2026 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2028 (delete-region (match-beginning 2) (match-end 0))
2029 (beginning-of-line))
2030 (when (re-search-forward
2031 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2032 (delete-region (match-beginning 1) (match-end 1))))))))
2034 (defun article-hide-pgp ()
2035 "Remove any PGP headers and signatures in the current article."
2039 (let ((inhibit-point-motion-hooks t)
2040 buffer-read-only beg end)
2042 ;; Hide the "header".
2043 (when (re-search-forward "^-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
2044 (push 'pgp gnus-article-wash-types)
2045 (delete-region (match-beginning 0) (match-end 0))
2046 ;; Remove armor headers (rfc2440 6.2)
2047 (delete-region (point) (or (re-search-forward "^[ \t]*\n" nil t)
2050 ;; Hide the actual signature.
2051 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
2052 (setq end (1+ (match-beginning 0)))
2055 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
2057 ;; Perhaps we shouldn't hide to the end of the buffer
2058 ;; if there is no end to the signature?
2060 ;; Hide "- " PGP quotation markers.
2062 (narrow-to-region beg end)
2063 (goto-char (point-min))
2064 (while (re-search-forward "^- " nil t)
2066 (match-beginning 0) (match-end 0)))
2068 (gnus-run-hooks 'gnus-article-hide-pgp-hook))))))
2070 (defun article-hide-pem (&optional arg)
2071 "Toggle hiding of any PEM headers and signatures in the current article.
2072 If given a negative prefix, always show; if given a positive prefix,
2074 (interactive (gnus-article-hidden-arg))
2075 (unless (gnus-article-check-hidden-text 'pem arg)
2077 (let (buffer-read-only end)
2078 (goto-char (point-min))
2079 ;; Hide the horrendously ugly "header".
2080 (when (and (search-forward
2081 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2083 (setq end (1+ (match-beginning 0))))
2084 (push 'pem gnus-article-wash-types)
2085 (gnus-article-hide-text-type
2087 (if (search-forward "\n\n" nil t)
2091 ;; Hide the trailer as well
2092 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2094 (gnus-article-hide-text-type
2095 (match-beginning 0) (match-end 0) 'pem)))))))
2097 (defun article-strip-banner ()
2098 "Strip the banner specified by the `banner' group parameter."
2102 (let ((inhibit-point-motion-hooks t)
2103 (banner (gnus-parameter-banner gnus-newsgroup-name))
2104 (gnus-signature-limit nil)
2105 buffer-read-only beg end)
2109 ((eq banner 'signature)
2110 (when (gnus-article-narrow-to-signature)
2113 (delete-region (point) (point-max))))
2115 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2116 (while (re-search-forward banner nil t)
2117 (delete-region (match-beginning 0) (match-end 0)))))
2119 (while (re-search-forward banner nil t)
2120 (delete-region (match-beginning 0) (match-end 0))))))))))
2122 (defun article-babel ()
2123 "Translate article using an online translation service."
2127 (set-buffer gnus-article-buffer)
2128 (when (article-goto-body)
2129 (let* ((buffer-read-only nil)
2132 (orig (buffer-substring start end))
2133 (trans (babel-as-string orig)))
2135 (narrow-to-region start end)
2136 (delete-region start end)
2139 (defun article-hide-signature (&optional arg)
2140 "Hide the signature in the current article.
2141 If given a negative prefix, always show; if given a positive prefix,
2143 (interactive (gnus-article-hidden-arg))
2149 (article-goto-body))
2150 (goto-char (point-min)))
2151 (unless (gnus-article-check-hidden-text 'signature arg)
2152 (let ((buffer-read-only nil)
2154 (while (setq button (text-property-any button (point-max)
2156 'gnus-signature-toggle))
2157 (setq button (text-property-not-all button (point-max)
2159 'gnus-signature-toggle))
2160 (when (and button (not (eobp)))
2161 (gnus-article-hide-text-type
2163 (next-single-property-change (1+ button) 'mime-view-entity
2167 (defun article-strip-headers-in-body ()
2168 "Strip offensive headers from bodies."
2172 (let ((case-fold-search t))
2173 (when (looking-at "x-no-archive:")
2174 (gnus-delete-line)))))
2176 (defun article-strip-leading-blank-lines ()
2177 "Remove all blank lines from the beginning of the article."
2180 (let ((inhibit-point-motion-hooks t)
2182 (when (article-goto-body)
2183 (while (and (not (eobp))
2184 (looking-at "[ \t]*$"))
2185 (gnus-delete-line))))))
2187 (defun article-narrow-to-head ()
2188 "Narrow the buffer to the head of the message.
2189 Point is left at the beginning of the narrowed-to region."
2191 (goto-char (point-min))
2192 (if (search-forward "\n\n" nil 1)
2195 (goto-char (point-min)))
2197 (defun article-goto-body ()
2198 "Place point at the start of the body."
2199 (goto-char (point-min))
2201 ;; This variable is only bound when dealing with separate
2203 (article-goto-body-goes-to-point-min-p
2205 ((search-forward "\n\n" nil t)
2208 (goto-char (point-max))
2211 (defun article-strip-multiple-blank-lines ()
2212 "Replace consecutive blank lines with one empty line."
2215 (let ((inhibit-point-motion-hooks t)
2217 ;; First make all blank lines empty.
2219 (while (re-search-forward "^[ \t]+$" nil t)
2220 (unless (gnus-annotation-in-region-p
2221 (match-beginning 0) (match-end 0))
2222 (replace-match "" nil t)))
2223 ;; Then replace multiple empty lines with a single empty line.
2225 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2226 (unless (gnus-annotation-in-region-p
2227 (match-beginning 0) (match-end 0))
2228 (delete-region (match-beginning 1) (match-end 1)))))))
2230 (defun article-strip-leading-space ()
2231 "Remove all white space from the beginning 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-trailing-space ()
2241 "Remove all white space from the end of the lines in the article."
2244 (let ((inhibit-point-motion-hooks t)
2247 (while (re-search-forward "[ \t]+$" nil t)
2248 (replace-match "" t t)))))
2250 (defun article-strip-blank-lines ()
2251 "Strip leading, trailing and multiple blank lines."
2253 (article-strip-leading-blank-lines)
2254 (article-remove-trailing-blank-lines)
2255 (article-strip-multiple-blank-lines))
2257 (defun article-strip-all-blank-lines ()
2258 "Strip all blank lines."
2261 (let ((inhibit-point-motion-hooks t)
2264 (while (re-search-forward "^[ \t]*\n" nil t)
2265 (replace-match "" t t)))))
2267 (defun gnus-article-narrow-to-signature ()
2268 "Narrow to the signature; return t if a signature is found, else nil."
2269 (let ((inhibit-point-motion-hooks t))
2270 (when (gnus-article-search-signature)
2272 ;; Check whether we have some limits to what we consider
2273 ;; to be a signature.
2274 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2275 (list gnus-signature-limit)))
2277 (while (setq limit (pop limits))
2278 (if (or (and (integerp limit)
2279 (< (- (point-max) (point)) limit))
2281 (< (count-lines (point) (point-max)) limit))
2282 (and (gnus-functionp limit)
2284 (and (stringp limit)
2285 (not (re-search-forward limit nil t))))
2286 () ; This limit did not succeed.
2290 (narrow-to-region (point) (point-max))
2293 (defun gnus-article-search-signature ()
2294 "Search the current buffer for the signature separator.
2295 Put point at the beginning of the signature separator."
2296 (let ((cur (point)))
2297 (goto-char (point-max))
2298 (if (if (stringp gnus-signature-separator)
2299 (re-search-backward gnus-signature-separator nil t)
2300 (let ((seps gnus-signature-separator))
2302 (not (re-search-backward (car seps) nil t)))
2309 (defun gnus-article-hidden-arg ()
2310 "Return the current prefix arg as a number, or 0 if no prefix."
2311 (list (if current-prefix-arg
2312 (prefix-numeric-value current-prefix-arg)
2315 (defun gnus-article-check-hidden-text (type arg)
2316 "Return nil if hiding is necessary.
2317 Arg can be nil or a number. Nil and positive means hide, negative
2318 means show, 0 means toggle."
2321 (let ((hide (gnus-article-hidden-text-p type)))
2327 (gnus-article-show-hidden-text type)
2330 (if (eq hide 'hidden)
2332 (gnus-article-show-hidden-text type)
2336 (defun gnus-article-hidden-text-p (type)
2337 "Say whether the current buffer contains hidden text of type TYPE."
2338 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2340 (not (get-text-property pos 'invisible))
2341 (not (get-text-property pos 'dummy-invisible)))
2343 (text-property-any (1+ pos) (point-max) 'article-type type)))
2348 (defun gnus-article-show-hidden-text (type &optional dummy)
2349 "Show all hidden text of type TYPE.
2350 Originally it is hide instead of DUMMY."
2351 (let ((buffer-read-only nil)
2352 (inhibit-point-motion-hooks t))
2353 (gnus-remove-text-properties-when
2355 (point-min) (point-max)
2356 (cons 'article-type (cons type
2357 gnus-hidden-properties)))))
2359 (defconst article-time-units
2360 `((year . ,(* 365.25 24 60 60))
2361 (week . ,(* 7 24 60 60))
2362 (day . ,(* 24 60 60))
2366 "Mapping from time units to seconds.")
2368 (defun article-date-ut (&optional type highlight header)
2369 "Convert DATE date to universal time in the current article.
2370 If TYPE is `local', convert to local time; if it is `lapsed', output
2371 how much time has lapsed since DATE. For `lapsed', the value of
2372 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2373 should replace the \"Date:\" one, or should be added below it."
2374 (interactive (list 'ut t))
2375 (let* ((header (or header
2376 (and (eq 1 (point-min))
2377 (mail-header-date (save-excursion
2378 (set-buffer gnus-summary-buffer)
2379 gnus-current-headers)))
2380 (message-fetch-field "date")
2382 (date (if (vectorp header) (mail-header-date header)
2384 (inhibit-point-motion-hooks t)
2385 bface eface date-pos)
2386 (when (and date (not (string= date "")))
2389 (article-narrow-to-head)
2390 (when (or (and (eq type 'lapsed)
2391 gnus-article-date-lapsed-new-header
2392 ;; Attempt to get the face of X-Sent first.
2393 (re-search-forward "^X-Sent:[ \t]" nil t))
2394 (re-search-forward "^Date:[ \t]" nil t)
2395 ;; If Date is missing, try again for X-Sent.
2396 (re-search-forward "^X-Sent:[ \t]" nil t))
2397 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2398 date (or (get-text-property (gnus-point-at-bol)
2401 eface (get-text-property (1- (gnus-point-at-eol))
2403 (let ((buffer-read-only nil))
2404 ;; Delete any old X-Sent headers.
2405 (when (setq date-pos
2406 (text-property-any (point-min) (point-max)
2407 'article-date-lapsed t))
2408 (goto-char (setq date-pos (set-marker (make-marker) date-pos)))
2409 (delete-region (match-beginning 0)
2410 (progn (forward-line 1) (point))))
2411 (goto-char (point-min))
2412 ;; Delete any old Date headers.
2413 (while (re-search-forward "^Date:[ \t]" nil t)
2415 (setq date-pos (match-beginning 0)))
2416 (unless (and (eq type 'lapsed)
2417 gnus-article-date-lapsed-new-header)
2418 (delete-region (match-beginning 0)
2419 (progn (message-next-header) (point)))))
2422 (goto-char date-pos)
2424 ;; Possibly, Date has been deleted.
2426 (when (and (eq type 'lapsed)
2427 gnus-article-date-lapsed-new-header
2428 (looking-at "Date:"))
2430 (goto-char (point-min)))
2431 (insert (article-make-date-line date type))
2432 (when (eq type 'lapsed)
2433 (put-text-property (gnus-point-at-bol) (point)
2434 'article-date-lapsed t))
2438 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2439 (put-text-property (match-beginning 1) (1+ (match-end 1))
2440 'original-date date)
2441 (put-text-property (match-beginning 1) (1+ (match-end 1))
2443 (put-text-property (match-beginning 2) (match-end 2)
2446 (defun article-make-date-line (date type)
2447 "Return a DATE line of TYPE."
2448 (unless (memq type '(local ut original user iso8601 lapsed english))
2449 (error "Unknown conversion type: %s" type))
2451 (let ((time (date-to-time date)))
2453 ;; Convert to the local timezone.
2455 (let ((tz (car (current-time-zone time))))
2456 (format "Date: %s %s%02d%02d" (current-time-string time)
2457 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2458 (/ (% (abs tz) 3600) 60))))
2459 ;; Convert to Universal Time.
2462 (current-time-string
2463 (let* ((e (parse-time-string date))
2464 (tm (apply 'encode-time e))
2466 (ls (- (cadr tm) (car (current-time-zone time)))))
2467 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2468 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2471 ;; Get the original date from the article.
2472 ((eq type 'original)
2473 (concat "Date: " (if (string-match "\n+$" date)
2474 (substring date 0 (match-beginning 0))
2476 ;; Let the user define the format.
2478 (if (gnus-functionp gnus-article-time-format)
2479 (funcall gnus-article-time-format time)
2482 (format-time-string gnus-article-time-format time))))
2485 (let ((tz (car (current-time-zone time))))
2488 (format-time-string "%Y%m%dT%H%M%S" time)
2489 (format "%s%02d%02d"
2490 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2491 (/ (% (abs tz) 3600) 60)))))
2492 ;; Do an X-Sent lapsed format.
2494 ;; If the date is seriously mangled, the timezone functions are
2495 ;; liable to bug out, so we ignore all errors.
2496 (let* ((now (current-time))
2497 (real-time (subtract-time now time))
2498 (real-sec (and real-time
2499 (+ (* (float (car real-time)) 65536)
2501 (sec (and real-time (abs real-sec)))
2511 ;; This is a bit convoluted, but basically we go
2512 ;; through the time units for years, weeks, etc,
2513 ;; and divide things to see whether that results
2514 ;; in positive answers.
2517 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2518 ;; The (remaining) seconds are too few to
2519 ;; be divided into this time unit.
2521 ;; It's big enough, so we output it.
2522 (setq sec (- sec (* num (cdr unit))))
2524 (concat (if prev ", " "") (int-to-string
2526 " " (symbol-name (car unit))
2527 (if (> num 1) "s" ""))
2529 article-time-units "")
2530 ;; If dates are odd, then it might appear like the
2531 ;; article was sent in the future.
2534 " in the future"))))))
2535 ;; Display the date in proper English
2537 (let ((dtime (decode-time time)))
2540 (number-to-string (nth 3 dtime))
2541 (let ((digit (% (nth 3 dtime) 10)))
2543 ((memq (nth 3 dtime) '(11 12 13)) "th")
2549 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2551 (number-to-string (nth 5 dtime))
2553 (format "%02d" (nth 2 dtime))
2555 (format "%02d" (nth 1 dtime)))))))
2557 (format "Date: %s (from Oort)" date))))
2559 (defun article-date-local (&optional highlight)
2560 "Convert the current article date to the local timezone."
2561 (interactive (list t))
2562 (article-date-ut 'local highlight))
2564 (defun article-date-english (&optional highlight)
2565 "Convert the current article date to something that is proper English."
2566 (interactive (list t))
2567 (article-date-ut 'english highlight))
2569 (defun article-date-original (&optional highlight)
2570 "Convert the current article date to what it was originally.
2571 This is only useful if you have used some other date conversion
2572 function and want to see what the date was before converting."
2573 (interactive (list t))
2574 (article-date-ut 'original highlight))
2576 (defun article-date-lapsed (&optional highlight)
2577 "Convert the current article date to time lapsed since it was sent."
2578 (interactive (list t))
2579 (article-date-ut 'lapsed highlight))
2581 (defun article-update-date-lapsed ()
2582 "Function to be run from a timer to update the lapsed time line."
2583 (let (deactivate-mark)
2588 (set-buffer (window-buffer w))
2589 (when (eq major-mode 'gnus-article-mode)
2590 (goto-char (point-min))
2591 (when (re-search-forward "^X-Sent:" nil t)
2592 (article-date-lapsed t))))
2595 (defun gnus-start-date-timer (&optional n)
2596 "Start a timer to update the X-Sent header in the article buffers.
2597 The numerical prefix says how frequently (in seconds) the function
2602 (gnus-stop-date-timer)
2603 (setq article-lapsed-timer
2604 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2606 (defun gnus-stop-date-timer ()
2607 "Stop the X-Sent timer."
2609 (when article-lapsed-timer
2610 (nnheader-cancel-timer article-lapsed-timer)
2611 (setq article-lapsed-timer nil)))
2613 (defun article-date-user (&optional highlight)
2614 "Convert the current article date to the user-defined format.
2615 This format is defined by the `gnus-article-time-format' variable."
2616 (interactive (list t))
2617 (article-date-ut 'user highlight))
2619 (defun article-date-iso8601 (&optional highlight)
2620 "Convert the current article date to ISO8601."
2621 (interactive (list t))
2622 (article-date-ut 'iso8601 highlight))
2624 (defun article-show-all ()
2625 "Show all hidden text in the article buffer."
2629 (let ((buffer-read-only nil))
2630 (gnus-article-unhide-text (point-min) (point-max))
2631 (gnus-remove-text-with-property 'gnus-prev)
2632 (gnus-remove-text-with-property 'gnus-next))))
2634 (defun article-show-all-headers ()
2635 "Show all hidden headers in the article buffer."
2640 (article-narrow-to-head)
2641 (let ((buffer-read-only nil))
2642 (gnus-article-unhide-text (point-min) (point-max))))))
2644 (defun article-remove-leading-whitespace ()
2645 "Remove excessive whitespace from all headers."
2649 (let ((buffer-read-only nil))
2650 (article-narrow-to-head)
2651 (goto-char (point-min))
2652 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
2653 (delete-region (match-beginning 1) (match-end 1)))))))
2655 (defun article-emphasize (&optional arg)
2656 "Emphasize text according to `gnus-emphasis-alist'."
2657 (interactive (gnus-article-hidden-arg))
2658 (unless (gnus-article-check-hidden-text 'emphasis arg)
2662 (with-current-buffer gnus-summary-buffer
2663 gnus-article-emphasis-alist)
2665 gnus-emphasis-alist))
2666 (buffer-read-only nil)
2667 (props (append '(article-type emphasis)
2668 gnus-hidden-properties))
2669 regexp elem beg invisible visible face)
2672 (while (setq elem (pop alist))
2674 (setq regexp (car elem)
2675 invisible (nth 1 elem)
2676 visible (nth 2 elem)
2678 (while (re-search-forward regexp nil t)
2679 (when (and (match-beginning visible) (match-beginning invisible))
2680 (push 'emphasis gnus-article-wash-types)
2681 (gnus-article-hide-text
2682 (match-beginning invisible) (match-end invisible) props)
2683 (gnus-article-unhide-text-type
2684 (match-beginning visible) (match-end visible) 'emphasis)
2685 (gnus-put-text-property-excluding-newlines
2686 (match-beginning visible) (match-end visible) 'face face)
2687 (goto-char (match-end invisible)))))))))
2689 (defun gnus-article-setup-highlight-words (&optional highlight-words)
2690 "Setup newsgroup emphasis alist."
2691 (unless gnus-article-emphasis-alist
2692 (let ((name (and gnus-newsgroup-name
2693 (gnus-group-real-name gnus-newsgroup-name))))
2694 (make-local-variable 'gnus-article-emphasis-alist)
2695 (setq gnus-article-emphasis-alist
2697 (let ((alist gnus-group-highlight-words-alist) elem highlight)
2698 (while (setq elem (pop alist))
2699 (when (and name (string-match (car elem) name))
2701 highlight (copy-sequence (cdr elem)))))
2703 (copy-sequence highlight-words)
2704 (if gnus-newsgroup-name
2705 (copy-sequence (gnus-group-find-parameter
2706 gnus-newsgroup-name 'highlight-words t)))
2707 gnus-emphasis-alist)))))
2710 (defvar gnus-summary-article-menu)
2711 (defvar gnus-summary-post-menu))
2713 ;;; Saving functions.
2715 (defun gnus-article-save (save-buffer file &optional num)
2716 "Save the currently selected article."
2717 (unless gnus-save-all-headers
2718 ;; Remove headers according to `gnus-saved-headers'.
2719 (let ((gnus-visible-headers
2720 (or gnus-saved-headers gnus-visible-headers))
2721 (gnus-article-buffer save-buffer))
2723 (set-buffer save-buffer)
2724 (article-hide-headers 1 t))))
2725 (save-window-excursion
2726 (if (not gnus-default-article-saver)
2727 (error "No default saver is defined")
2728 ;; !!! Magic! The saving functions all save
2729 ;; `gnus-save-article-buffer' (or so they think), but we
2730 ;; bind that variable to our save-buffer.
2731 (set-buffer gnus-article-buffer)
2732 (let* ((gnus-save-article-buffer save-buffer)
2735 ((not gnus-prompt-before-saving) 'default)
2736 ((eq gnus-prompt-before-saving 'always) nil)
2738 (gnus-number-of-articles-to-be-saved
2739 (when (eq gnus-prompt-before-saving t)
2741 (set-buffer gnus-article-current-summary)
2742 (funcall gnus-default-article-saver filename)))))
2744 (defun gnus-read-save-file-name (prompt &optional filename
2745 function group headers variable)
2747 (funcall function group headers (symbol-value variable)))
2752 ((eq filename 'default)
2758 (let* ((split-name (gnus-get-split-value gnus-split-methods))
2761 (if (and gnus-number-of-articles-to-be-saved
2762 (> gnus-number-of-articles-to-be-saved 1))
2763 (format "these %d articles"
2764 gnus-number-of-articles-to-be-saved)
2767 ;; Let the split methods have their say.
2769 ;; No split name was found.
2772 (concat prompt " (default "
2773 (file-name-nondirectory default-name) ") ")
2774 (file-name-directory default-name)
2776 ;; A single group name is returned.
2777 ((stringp split-name)
2779 (funcall function split-name headers
2780 (symbol-value variable)))
2782 (concat prompt " (default "
2783 (file-name-nondirectory default-name) ") ")
2784 (file-name-directory default-name)
2786 ;; A single split name was found
2787 ((= 1 (length split-name))
2788 (let* ((name (expand-file-name
2790 gnus-article-save-directory))
2791 (dir (cond ((file-directory-p name)
2792 (file-name-as-directory name))
2793 ((file-exists-p name) name)
2794 (t gnus-article-save-directory))))
2796 (concat prompt " (default " name ") ")
2798 ;; A list of splits was found.
2800 (setq split-name (nreverse split-name))
2802 (let ((file-name-history
2803 (nconc split-name file-name-history)))
2807 (concat prompt " (`M-p' for defaults) ")
2808 gnus-article-save-directory
2810 gnus-article-save-directory)))
2811 (car (push result file-name-history)))))))
2812 ;; Create the directory.
2813 (gnus-make-directory (file-name-directory file))
2814 ;; If we have read a directory, we append the default file name.
2815 (when (file-directory-p file)
2816 (setq file (expand-file-name (file-name-nondirectory
2818 (file-name-as-directory file))))
2819 ;; Possibly translate some characters.
2820 (nnheader-translate-file-chars file))))))
2821 (gnus-make-directory (file-name-directory result))
2822 (set variable result)))
2824 (defun gnus-article-archive-name (group)
2825 "Return the first instance of an \"Archive-name\" in the current buffer."
2826 (let ((case-fold-search t))
2827 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
2828 (nnheader-concat gnus-article-save-directory
2829 (match-string 1)))))
2831 (defun gnus-article-nndoc-name (group)
2832 "If GROUP is an nndoc group, return the name of the parent group."
2833 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
2834 (gnus-group-get-parameter group 'save-article-group)))
2836 (defun gnus-summary-save-in-rmail (&optional filename)
2837 "Append this article to Rmail file.
2838 Optional argument FILENAME specifies file name.
2839 Directory to save to is default to `gnus-article-save-directory'."
2840 (setq filename (gnus-read-save-file-name
2841 "Save %s in rmail file:" filename
2842 gnus-rmail-save-name gnus-newsgroup-name
2843 gnus-current-headers 'gnus-newsgroup-last-rmail))
2844 (gnus-eval-in-buffer-window gnus-save-article-buffer
2848 (gnus-output-to-rmail filename))))
2851 (defun gnus-summary-save-in-mail (&optional filename)
2852 "Append this article to Unix mail file.
2853 Optional argument FILENAME specifies file name.
2854 Directory to save to is default to `gnus-article-save-directory'."
2855 (setq filename (gnus-read-save-file-name
2856 "Save %s in Unix mail file:" filename
2857 gnus-mail-save-name gnus-newsgroup-name
2858 gnus-current-headers 'gnus-newsgroup-last-mail))
2859 (gnus-eval-in-buffer-window gnus-save-article-buffer
2863 (if (and (file-readable-p filename)
2864 (mail-file-babyl-p filename))
2865 (rmail-output-to-rmail-file filename t)
2866 (gnus-output-to-mail filename)))))
2869 (defun gnus-summary-save-in-file (&optional filename overwrite)
2870 "Append this article to file.
2871 Optional argument FILENAME specifies file name.
2872 Directory to save to is default to `gnus-article-save-directory'."
2873 (setq filename (gnus-read-save-file-name
2874 "Save %s in file:" filename
2875 gnus-file-save-name gnus-newsgroup-name
2876 gnus-current-headers 'gnus-newsgroup-last-file))
2877 (gnus-eval-in-buffer-window gnus-save-article-buffer
2881 (when (and overwrite
2882 (file-exists-p filename))
2883 (delete-file filename))
2884 (gnus-output-to-file filename))))
2887 (defun gnus-summary-write-to-file (&optional filename)
2888 "Write this article to a file.
2889 Optional argument FILENAME specifies file name.
2890 The directory to save in defaults to `gnus-article-save-directory'."
2891 (gnus-summary-save-in-file nil t))
2893 (defun gnus-summary-save-body-in-file (&optional filename)
2894 "Append this article body to a file.
2895 Optional argument FILENAME specifies file name.
2896 The directory to save in defaults to `gnus-article-save-directory'."
2897 (setq filename (gnus-read-save-file-name
2898 "Save %s body in file:" filename
2899 gnus-file-save-name gnus-newsgroup-name
2900 gnus-current-headers 'gnus-newsgroup-last-file))
2901 (gnus-eval-in-buffer-window gnus-save-article-buffer
2905 (when (article-goto-body)
2906 (narrow-to-region (point) (point-max)))
2907 (gnus-output-to-file filename))))
2910 (defun gnus-summary-save-in-pipe (&optional command)
2911 "Pipe this article to subprocess."
2913 (cond ((and (eq command 'default)
2914 gnus-last-shell-command)
2915 gnus-last-shell-command)
2920 "Shell command on %s: "
2921 (if (and gnus-number-of-articles-to-be-saved
2922 (> gnus-number-of-articles-to-be-saved 1))
2923 (format "these %d articles"
2924 gnus-number-of-articles-to-be-saved)
2926 gnus-last-shell-command))))
2927 (when (string-equal command "")
2928 (if gnus-last-shell-command
2929 (setq command gnus-last-shell-command)
2930 (error "A command is required")))
2931 (gnus-eval-in-buffer-window gnus-article-buffer
2934 (shell-command-on-region (point-min) (point-max) command nil)))
2935 (setq gnus-last-shell-command command))
2937 ;;; Article file names when saving.
2939 (defun gnus-capitalize-newsgroup (newsgroup)
2940 "Capitalize NEWSGROUP name."
2941 (when (not (zerop (length newsgroup)))
2942 (concat (char-to-string (upcase (aref newsgroup 0)))
2943 (substring newsgroup 1))))
2945 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2946 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2947 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
2948 Otherwise, it is like ~/News/news/group/num."
2951 (concat (if (gnus-use-long-file-name 'not-save)
2952 (gnus-capitalize-newsgroup newsgroup)
2953 (gnus-newsgroup-directory-form newsgroup))
2954 "/" (int-to-string (mail-header-number headers)))
2955 gnus-article-save-directory)))
2957 (string-equal (file-name-directory default)
2958 (file-name-directory last-file))
2959 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2961 (or last-file default))))
2963 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2964 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2965 If variable `gnus-use-long-file-name' is non-nil, it is
2966 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2969 (concat (if (gnus-use-long-file-name 'not-save)
2971 (gnus-newsgroup-directory-form newsgroup))
2972 "/" (int-to-string (mail-header-number headers)))
2973 gnus-article-save-directory)))
2975 (string-equal (file-name-directory default)
2976 (file-name-directory last-file))
2977 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2979 (or last-file default))))
2981 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2982 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2983 If variable `gnus-use-long-file-name' is non-nil, it is
2984 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2987 (if (gnus-use-long-file-name 'not-save)
2990 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
2992 gnus-article-save-directory)))
2994 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
2995 "Generate file name from sender."
2996 (let ((from (mail-header-from headers)))
2998 (if (and from (string-match "\\([^ <]+\\)@" from))
2999 (match-string 1 from)
3001 gnus-article-save-directory)))
3003 (defun article-verify-x-pgp-sig ()
3006 (if (gnus-buffer-live-p gnus-original-article-buffer)
3007 (let ((sig (with-current-buffer gnus-original-article-buffer
3008 (gnus-fetch-field "X-PGP-Sig")))
3012 (mml2015-clear-verify-function))
3014 (insert-buffer gnus-original-article-buffer)
3015 (setq items (split-string sig))
3016 (message-narrow-to-head)
3017 (let ((inhibit-point-motion-hooks t)
3018 (case-fold-search t))
3019 ;; Don't verify multiple headers.
3020 (setq headers (mapconcat (lambda (header)
3022 (mail-fetch-field header) "\n"))
3023 (split-string (nth 1 items) ",") "")))
3024 (delete-region (point-min) (point-max))
3025 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3026 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3031 (if (looking-at "^-")
3034 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3035 (insert "Version: " (car items) "\n\n")
3036 (insert (mapconcat 'identity (cddr items) "\n"))
3037 (insert "\n-----END PGP SIGNATURE-----\n")
3038 (let ((mm-security-handle (list (format "multipart/signed"))))
3039 (mml2015-clean-buffer)
3040 (let ((coding-system-for-write (or gnus-newsgroup-charset
3042 (funcall (mml2015-clear-verify-function)))
3044 (or (mm-handle-multipart-ctl-parameter
3045 mm-security-handle 'gnus-details)
3046 (mm-handle-multipart-ctl-parameter
3047 mm-security-handle 'gnus-info)))))
3049 (let (buffer-read-only bface eface)
3051 (message-narrow-to-head)
3052 (goto-char (point-max))
3054 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3055 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3056 (message-remove-header "X-Gnus-PGP-Verify")
3057 (if (re-search-forward "^X-PGP-Sig:" nil t)
3059 (goto-char (point-max)))
3060 (narrow-to-region (point) (point))
3061 (insert "X-Gnus-PGP-Verify: " info "\n")
3062 (goto-char (point-min))
3065 (if (not (looking-at "^[ \t]"))
3069 (goto-char (point-min))
3070 (when (looking-at "\\([^:]+\\): *")
3071 (put-text-property (match-beginning 1) (1+ (match-end 1))
3073 (put-text-property (match-end 0) (point-max)
3074 'face eface)))))))))
3081 (setq afunc (car func)
3084 gfunc (intern (format "gnus-%s" func))))
3087 `(lambda (&optional interactive &rest args)
3088 ,(documentation afunc t)
3089 (interactive (list t))
3091 (set-buffer gnus-article-buffer)
3093 (call-interactively ',afunc)
3094 (apply ',afunc args))))))))
3095 '(article-hide-headers
3096 article-verify-x-pgp-sig
3097 article-hide-boring-headers
3098 article-toggle-headers
3099 article-treat-overstrike
3100 article-fill-long-lines
3101 article-capitalize-sentences
3103 article-remove-leading-whitespace
3104 article-display-x-face
3105 article-de-quoted-unreadable
3106 article-de-base64-unreadable
3109 article-hide-list-identifiers
3111 article-strip-banner
3114 article-hide-signature
3115 article-strip-headers-in-body
3116 article-remove-trailing-blank-lines
3117 article-strip-leading-blank-lines
3118 article-strip-multiple-blank-lines
3119 article-strip-leading-space
3120 article-strip-trailing-space
3121 article-strip-blank-lines
3122 article-strip-all-blank-lines
3124 article-date-english
3125 article-date-iso8601
3126 article-date-original
3128 article-decode-mime-words
3129 article-decode-charset
3130 article-decode-encoded-words
3134 article-treat-dumbquotes
3135 article-normalize-headers
3136 (article-show-all-headers . gnus-article-show-all-headers)
3137 (article-show-all . gnus-article-show-all))))
3140 ;;; Gnus article mode
3143 (put 'gnus-article-mode 'mode-class 'special)
3145 (gnus-define-keys gnus-article-mode-map
3146 " " gnus-article-goto-next-page
3147 "\177" gnus-article-goto-prev-page
3148 [delete] gnus-article-goto-prev-page
3149 [backspace] gnus-article-goto-prev-page
3150 "\C-c^" gnus-article-refer-article
3151 "h" gnus-article-show-summary
3152 "s" gnus-article-show-summary
3153 "\C-c\C-m" gnus-article-mail
3154 "?" gnus-article-describe-briefly
3155 "e" gnus-summary-edit-article
3156 "<" beginning-of-buffer
3158 "\C-c\C-i" gnus-info-find-node
3160 "\C-hk" gnus-article-describe-key
3161 "\C-hc" gnus-article-describe-key-briefly
3163 "\C-d" gnus-article-read-summary-keys
3164 "\M-*" gnus-article-read-summary-keys
3165 "\M-#" gnus-article-read-summary-keys
3166 "\M-^" gnus-article-read-summary-keys
3167 "\M-g" gnus-article-read-summary-keys)
3169 ;; Define almost undefined keys to `gnus-article-read-summary-keys'.
3173 (push (char-to-string key) keys)
3175 (dolist (elem (accessible-keymaps gnus-summary-mode-map))
3176 (setq key (car elem))
3177 (when (and (> (length key) 0)
3178 (not (eq 'menu-bar (aref key 0)))
3179 (symbolp (lookup-key gnus-summary-mode-map key)))
3182 (unless (lookup-key gnus-article-mode-map key)
3183 (define-key gnus-article-mode-map key 'gnus-article-read-summary-keys))))
3185 (defun gnus-article-make-menu-bar ()
3186 (unless (boundp 'gnus-article-commands-menu)
3187 (gnus-summary-make-menu-bar))
3188 (gnus-turn-off-edit-menu 'article)
3189 (unless (boundp 'gnus-article-article-menu)
3191 gnus-article-article-menu gnus-article-mode-map ""
3193 ["Scroll forwards" gnus-article-goto-next-page t]
3194 ["Scroll backwards" gnus-article-goto-prev-page t]
3195 ["Show summary" gnus-article-show-summary t]
3196 ["Fetch Message-ID at point" gnus-article-refer-article t]
3197 ["Mail to address at point" gnus-article-mail t]
3198 ["Send a bug report" gnus-bug t]))
3201 gnus-article-treatment-menu gnus-article-mode-map ""
3202 ;; Fixme: this should use :active (and maybe :visible).
3204 ["Hide headers" gnus-article-toggle-headers t]
3205 ["Hide signature" gnus-article-hide-signature t]
3206 ["Hide citation" gnus-article-hide-citation t]
3207 ["Treat overstrike" gnus-article-treat-overstrike t]
3208 ["Remove carriage return" gnus-article-remove-cr t]
3209 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3210 ["Decode HZ" gnus-article-decode-HZ t]))
3212 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3214 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3216 (gnus-run-hooks 'gnus-article-menu-hook)))
3218 ;; Fixme: do something for the Emacs tool bar in Article mode a la
3221 (defun gnus-article-mode ()
3222 "Major mode for displaying an article.
3224 All normal editing commands are switched off.
3226 The following commands are available in addition to all summary mode
3228 \\<gnus-article-mode-map>
3229 \\[gnus-article-next-page]\t Scroll the article one page forwards
3230 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3231 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3232 \\[gnus-article-show-summary]\t Display the summary buffer
3233 \\[gnus-article-mail]\t Send a reply to the address near point
3234 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3235 \\[gnus-info-find-node]\t Go to the Gnus info node"
3237 (gnus-simplify-mode-line)
3238 (setq mode-name "Article")
3239 (setq major-mode 'gnus-article-mode)
3240 (make-local-variable 'minor-mode-alist)
3241 (unless (assq 'gnus-show-mime minor-mode-alist)
3242 (push (list 'gnus-show-mime " MIME") minor-mode-alist))
3243 (use-local-map gnus-article-mode-map)
3244 (when (gnus-visual-p 'article-menu 'menu)
3245 (gnus-article-make-menu-bar))
3246 (gnus-update-format-specifications nil 'article-mode)
3247 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3248 (make-local-variable 'gnus-page-broken)
3249 (make-local-variable 'gnus-button-marker-list)
3250 (make-local-variable 'gnus-article-current-summary)
3251 (make-local-variable 'gnus-article-mime-handles)
3252 (make-local-variable 'gnus-article-decoded-p)
3253 (make-local-variable 'gnus-article-mime-handle-alist)
3254 (make-local-variable 'gnus-article-wash-types)
3255 (make-local-variable 'gnus-article-charset)
3256 (make-local-variable 'gnus-article-ignored-charsets)
3257 (gnus-set-default-directory)
3258 (buffer-disable-undo)
3259 (setq buffer-read-only t)
3260 (set-syntax-table gnus-article-mode-syntax-table)
3261 (gnus-run-hooks 'gnus-article-mode-hook))
3263 (defun gnus-article-setup-buffer ()
3264 "Initialize the article buffer."
3265 (let* ((name (if gnus-single-article-buffer "*Article*"
3266 (concat "*Article " gnus-newsgroup-name "*")))
3268 (progn (string-match "\\*Article" name)
3269 (concat " *Original Article"
3270 (substring name (match-end 0))))))
3271 (setq gnus-article-buffer name)
3272 (setq gnus-original-article-buffer original)
3273 (setq gnus-article-mime-handle-alist nil)
3274 ;; This might be a variable local to the summary buffer.
3275 (unless gnus-single-article-buffer
3277 (set-buffer gnus-summary-buffer)
3278 (setq gnus-article-buffer name)
3279 (setq gnus-original-article-buffer original)
3280 (gnus-set-global-variables)))
3281 (gnus-article-setup-highlight-words)
3282 ;; Init original article buffer.
3284 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3285 (set-buffer-multibyte nil)
3286 (setq major-mode 'gnus-original-article-mode)
3287 (make-local-variable 'gnus-original-article))
3288 (if (get-buffer name)
3291 (buffer-disable-undo)
3292 (setq buffer-read-only t)
3293 (unless (eq major-mode 'gnus-article-mode)
3294 (gnus-article-mode))
3297 (set-buffer (gnus-get-buffer-create name))
3299 (make-local-variable 'gnus-summary-buffer)
3300 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3301 (current-buffer)))))
3303 ;; Set article window start at LINE, where LINE is the number of lines
3304 ;; from the head of the article.
3305 (defun gnus-article-set-window-start (&optional line)
3307 (get-buffer-window gnus-article-buffer t)
3309 (set-buffer gnus-article-buffer)
3310 (goto-char (point-min))
3313 (gnus-message 6 "Moved to bookmark")
3314 (search-forward "\n\n" nil t)
3318 ;;; @@ article filters
3321 (defun gnus-article-display-mime-message ()
3322 "Article display method for MIME message."
3323 ;; called from `gnus-original-article-buffer'.
3324 (let (charset all-headers)
3325 (with-current-buffer gnus-summary-buffer
3326 (setq charset default-mime-charset
3327 all-headers gnus-have-all-headers))
3328 (make-local-variable 'default-mime-charset)
3329 (setq default-mime-charset charset)
3330 (with-current-buffer (get-buffer-create gnus-article-buffer)
3331 (make-local-variable 'default-mime-charset)
3332 (setq default-mime-charset charset))
3333 (mime-display-message mime-message-structure
3334 gnus-article-buffer nil gnus-article-mode-map)
3336 (gnus-article-hide-headers nil -1)))
3337 (run-hooks 'gnus-mime-article-prepare-hook))
3339 (defun gnus-article-display-traditional-message ()
3340 "Article display method for traditional message."
3341 (set-buffer gnus-article-buffer)
3342 (let (buffer-read-only)
3344 (insert-buffer-substring gnus-original-article-buffer)))
3346 (defun gnus-article-make-full-mail-header (&optional number charset)
3347 "Create a new mail header structure in a raw article buffer."
3348 (unless (and number charset)
3349 (save-current-buffer
3350 (set-buffer gnus-summary-buffer)
3352 (setq number (or (cdr gnus-article-current) 0)))
3354 (setq charset (or default-mime-charset 'x-ctext)))))
3355 (goto-char (point-min))
3356 (let ((header-end (if (search-forward "\n\n" nil t)
3358 (goto-char (point-max))))
3359 (chars (- (point-max) (point)))
3360 (lines (count-lines (point) (point-max)))
3361 (default-mime-charset charset)
3363 (narrow-to-region (point-min) header-end)
3364 (setq xref (std11-fetch-field "xref"))
3366 (make-full-mail-header
3368 (std11-fetch-field "subject")
3369 (std11-fetch-field "from")
3370 (std11-fetch-field "date")
3371 (std11-fetch-field "message-id")
3372 (std11-fetch-field "references")
3375 (when xref (concat "Xref: " xref)))
3378 (defun gnus-article-prepare (article &optional all-headers header)
3379 "Prepare ARTICLE in article mode buffer.
3380 ARTICLE should either be an article number or a Message-ID.
3381 If ARTICLE is an id, HEADER should be the article headers.
3382 If ALL-HEADERS is non-nil, no headers are hidden."
3384 ;; Make sure we start in a summary buffer.
3385 (unless (eq major-mode 'gnus-summary-mode)
3386 (set-buffer gnus-summary-buffer))
3387 (setq gnus-summary-buffer (current-buffer))
3388 (let* ((gnus-article (if header (mail-header-number header) article))
3389 (summary-buffer (current-buffer))
3390 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3391 (group gnus-newsgroup-name)
3394 (gnus-article-setup-buffer)
3395 (set-buffer gnus-article-buffer)
3396 ;; Deactivate active regions.
3397 (when (and (boundp 'transient-mark-mode)
3398 transient-mark-mode)
3399 (setq mark-active nil))
3400 (if (not (setq result (let ((buffer-read-only nil))
3401 (gnus-request-article-this-buffer
3403 ;; There is no such article.
3405 (when (and (numberp article)
3406 (not (memq article gnus-newsgroup-sparse)))
3407 (setq gnus-article-current
3408 (cons gnus-newsgroup-name article))
3409 (set-buffer gnus-summary-buffer)
3410 (setq gnus-current-article article)
3411 (if (eq (gnus-article-mark article) gnus-undownloaded-mark)
3413 (gnus-summary-set-agent-mark article)
3414 (message "Message marked for downloading"))
3415 (gnus-summary-mark-article article gnus-canceled-mark)
3416 (unless (memq article gnus-newsgroup-sparse)
3417 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3418 (if (or (eq result 'pseudo)
3419 (eq result 'nneething))
3422 (set-buffer summary-buffer)
3423 (push article gnus-newsgroup-history)
3424 (setq gnus-last-article gnus-current-article
3425 gnus-current-article 0
3426 gnus-current-headers nil
3427 gnus-article-current nil)
3428 (if (eq result 'nneething)
3429 (gnus-configure-windows 'summary)
3430 (gnus-configure-windows 'article))
3431 (gnus-set-global-variables))
3432 (let ((gnus-article-mime-handle-alist-1
3433 gnus-article-mime-handle-alist))
3434 (gnus-set-mode-line 'article)))
3435 ;; The result from the `request' was an actual article -
3436 ;; or at least some text that is now displayed in the
3438 (when (and (numberp article)
3439 (not (eq article gnus-current-article)))
3440 ;; Seems like a new article has been selected.
3441 ;; `gnus-current-article' must be an article number.
3443 (set-buffer summary-buffer)
3444 (push article gnus-newsgroup-history)
3445 (setq gnus-last-article gnus-current-article
3446 gnus-current-article article
3447 gnus-current-headers
3448 (gnus-summary-article-header gnus-current-article)
3449 gnus-article-current
3450 (cons gnus-newsgroup-name gnus-current-article))
3451 (unless (vectorp gnus-current-headers)
3452 (setq gnus-current-headers nil))
3453 (gnus-summary-goto-subject gnus-current-article)
3454 (when (gnus-summary-show-thread)
3455 ;; If the summary buffer really was folded, the
3456 ;; previous goto may not actually have gone to
3457 ;; the right article, but the thread root instead.
3459 (gnus-summary-goto-subject gnus-current-article))
3460 (gnus-run-hooks 'gnus-mark-article-hook)
3461 (gnus-set-mode-line 'summary)
3462 (when (gnus-visual-p 'article-highlight 'highlight)
3463 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3464 ;; Set the global newsgroup variables here.
3465 (gnus-set-global-variables)
3466 (setq gnus-have-all-headers
3467 (or all-headers gnus-show-all-headers))))
3469 (gnus-configure-windows 'article))
3470 (when (or (numberp article)
3472 (gnus-article-prepare-display)
3474 (goto-char (point-min))
3475 (setq gnus-page-broken
3476 (when gnus-break-pages
3477 (gnus-narrow-to-page)
3479 (let ((gnus-article-mime-handle-alist-1
3480 gnus-article-mime-handle-alist))
3481 (gnus-set-mode-line 'article))
3483 (set-window-point (get-buffer-window (current-buffer)) (point))
3484 (gnus-configure-windows 'article)
3487 (defun gnus-article-prepare-mime-display (&optional number)
3488 (goto-char (point-min))
3489 (when (re-search-forward "^[^\t ]+:" nil t)
3490 (goto-char (match-beginning 0)))
3491 (let ((entity (if (eq 1 (point-min))
3492 (get-text-property 1 'mime-view-entity)
3493 (get-text-property (point) 'mime-view-entity)))
3494 last-entity child-entity next type)
3495 (setq child-entity (mime-entity-children entity))
3497 (setq last-entity (nth (1- (length child-entity))
3499 (setq last-entity entity))
3501 (narrow-to-region (point)
3502 (if (search-forward "\n\n" nil t)
3505 (gnus-treat-article 'head)
3506 (put-text-property (point-min) (point-max) 'article-treated-header t)
3507 (goto-char (point-max)))
3508 (while (and (not (eobp)) entity)
3509 (setq next (set-marker
3511 (next-single-property-change (point) 'mime-view-entity
3513 (let ((types (mime-entity-content-type entity)))
3514 (while (eq 'multipart (mime-content-type-primary-type types))
3515 (setq entity (car (mime-entity-children entity))
3516 types (mime-entity-content-type entity)))
3518 (setq type (format "%s/%s"
3519 (mime-content-type-primary-type types)
3520 (mime-content-type-subtype types)))))
3521 (if (string-equal type "message/rfc822")
3524 (let ((children (mime-entity-children entity))
3527 (setq last-children (nth (1- (length children)) children))
3530 (not (eq last-children
3531 (get-text-property next 'mime-view-entity)))
3533 (next-single-property-change next
3535 nil (point-max)))))))
3536 (setq next (next-single-property-change next 'mime-view-entity
3539 (narrow-to-region (point) next)
3540 (gnus-article-prepare-mime-display)
3541 (goto-char (point-max)))
3542 (setq entity (get-text-property (point) 'mime-view-entity)))
3544 (narrow-to-region (point) next)
3545 ;; Kludge. We have to count true number, but for now,
3546 ;; part number is here only to achieve `last'.
3547 (gnus-treat-article nil 1
3548 (if (eq entity last-entity)
3551 (goto-char (point-max)))
3552 (setq entity (get-text-property next 'mime-view-entity))))))
3555 (defun gnus-article-prepare-display ()
3556 "Make the current buffer look like a nice article."
3557 (let ((gnus-article-buffer (current-buffer))
3559 (unless (eq major-mode 'gnus-article-mode)
3560 (gnus-article-mode))
3561 (setq buffer-read-only nil
3562 gnus-button-marker-list nil
3563 gnus-article-wash-types nil)
3566 (static-if (featurep 'xemacs)
3567 (map-extents (lambda (extent maparg) (delete-extent extent)))
3568 (let ((lists (overlay-lists)))
3569 (dolist (overlay (nconc (car lists) (cdr lists)))
3570 (delete-overlay overlay)))))
3571 (gnus-run-hooks 'gnus-tmp-internal-hook))
3572 (set-buffer gnus-original-article-buffer)
3574 (setq mime-message-structure gnus-current-headers)
3575 (mime-buffer-entity-set-buffer-internal mime-message-structure
3576 gnus-original-article-buffer)
3577 (mime-entity-set-representation-type-internal mime-message-structure
3578 'mime-buffer-entity)
3579 (luna-send mime-message-structure 'initialize-instance
3580 mime-message-structure)
3582 (let (mime-display-header-hook mime-display-text/plain-hook)
3583 (funcall gnus-article-display-method-for-mime))
3584 (funcall gnus-article-display-method-for-traditional))
3585 ;; Call the treatment functions.
3586 (let ((inhibit-read-only t))
3590 (gnus-article-prepare-mime-display)
3591 (narrow-to-region (goto-char (point-min))
3592 (if (search-forward "\n\n" nil t)
3595 (gnus-treat-article 'head)
3596 (put-text-property (point-min) (point-max) 'article-treated-header t)
3597 (goto-char (point-max))
3599 (narrow-to-region (point) (point-max))
3600 (gnus-treat-article nil))
3601 (put-text-property (point-min) (point-max) 'read-only nil)))
3602 (gnus-run-hooks 'gnus-article-prepare-hook))
3604 (defun gnus-article-decode-article-as-default-mime-charset ()
3605 "Decode an article as `default-mime-charset'. It won't work if the
3606 value of the variable `gnus-show-mime' is non-nil."
3607 (unless gnus-show-mime
3608 (set (make-local-variable 'default-mime-charset)
3609 (with-current-buffer gnus-summary-buffer
3610 default-mime-charset))
3611 (decode-mime-charset-region (point-min) (point-max)
3612 default-mime-charset)))
3615 ;;; Gnus MIME viewing functions
3618 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3619 "The following specs can be used:
3621 %T MIME type, along with additional info
3622 %n The `name' parameter
3623 %d The description, if any
3624 %l The length of the encoded part
3625 %p The part identifier number
3626 %e Dots if the part isn't displayed")
3628 (defvar gnus-mime-button-line-format-alist
3629 '((?t gnus-tmp-type ?s)
3630 (?T gnus-tmp-type-long ?s)
3631 (?n gnus-tmp-name ?s)
3632 (?d gnus-tmp-description ?s)
3634 (?l gnus-tmp-length ?d)
3635 (?e gnus-tmp-dots ?s)))
3637 (defvar gnus-mime-button-commands
3638 '((gnus-article-press-button "\r" "Toggle Display")
3639 (gnus-mime-view-part "v" "View Interactively...")
3640 (gnus-mime-view-part-as-type "t" "View As Type...")
3641 (gnus-mime-view-part-as-charset "C" "View As charset...")
3642 (gnus-mime-save-part "o" "Save...")
3643 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
3644 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
3645 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
3646 (gnus-mime-internalize-part "E" "View Internally")
3647 (gnus-mime-externalize-part "e" "View Externally")
3648 (gnus-mime-pipe-part "|" "Pipe To Command...")
3649 (gnus-mime-action-on-part "." "Take action on the part")))
3651 (defun gnus-article-mime-part-status ()
3652 (with-current-buffer gnus-article-buffer
3653 (let ((entity (get-text-property (point-min) 'mime-view-entity))
3656 (setq children (mime-entity-children entity))
3657 (setq children (length children)))
3660 (format " (%d parts)" children))
3663 (defvar gnus-mime-button-map
3664 (let ((map (make-sparse-keymap)))
3665 (unless (>= (string-to-number emacs-version) 21)
3666 ;; XEmacs doesn't care.
3667 (set-keymap-parent map gnus-article-mode-map))
3668 (define-key map gnus-mouse-2 'gnus-article-push-button)
3669 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
3670 (dolist (c gnus-mime-button-commands)
3671 (define-key map (cadr c) (car c)))
3674 (defun gnus-mime-button-menu (event)
3675 "Construct a context-sensitive menu of MIME commands."
3677 (save-window-excursion
3678 (let ((pos (event-start event)))
3679 (select-window (posn-window pos))
3680 (goto-char (posn-point pos))
3681 (gnus-article-check-buffer)
3682 (let ((response (x-popup-menu
3684 ("" ,@(mapcar (lambda (c)
3685 (cons (caddr c) (car c)))
3686 gnus-mime-button-commands))))))
3688 (call-interactively response))))))
3690 (defun gnus-mime-view-all-parts (&optional handles)
3691 "View all the MIME parts."
3693 (save-current-buffer
3694 (set-buffer gnus-article-buffer)
3695 (let ((handles (or handles gnus-article-mime-handles))
3696 (mail-parse-charset gnus-newsgroup-charset)
3697 (mail-parse-ignored-charsets
3698 (with-current-buffer gnus-summary-buffer
3699 gnus-newsgroup-ignored-charsets)))
3701 (mm-remove-parts handles)
3702 (goto-char (point-min))
3703 (or (search-forward "\n\n") (goto-char (point-max)))
3704 (let (buffer-read-only)
3705 (delete-region (point) (point-max))
3706 (mm-display-parts handles))))))
3708 (defun gnus-mime-save-part-and-strip ()
3709 "Save the MIME part under point then replace it with an external body."
3711 (gnus-article-check-buffer)
3712 (let* ((data (get-text-property (point) 'gnus-data))
3714 (handles gnus-article-mime-handles))
3715 (if (mm-multiple-handles gnus-article-mime-handles)
3716 (error "This function is not implemented"))
3717 (setq file (and data (mm-save-part data)))
3719 (with-current-buffer (mm-handle-buffer data)
3721 (insert "Content-Type: " (mm-handle-media-type data))
3722 (mml-insert-parameter-string (cdr (mm-handle-type data))
3725 (insert "Content-ID: " (message-make-message-id) "\n")
3726 (insert "Content-Transfer-Encoding: binary\n")
3729 (cdr (mm-make-handle nil
3730 `("message/external-body"
3731 (access-type . "LOCAL-FILE")
3733 (set-buffer gnus-summary-buffer)
3734 (gnus-article-edit-article
3737 (let ((mail-parse-charset (or gnus-article-charset
3738 ',gnus-newsgroup-charset))
3739 (mail-parse-ignored-charsets
3740 (or gnus-article-ignored-charsets
3741 ',gnus-newsgroup-ignored-charsets))
3742 (mbl mml-buffer-list))
3743 (setq mml-buffer-list nil)
3744 (insert-buffer gnus-original-article-buffer)
3745 (mime-to-mml ',handles)
3746 (setq gnus-article-mime-handles nil)
3747 (let ((mbl1 mml-buffer-list))
3748 (setq mml-buffer-list mbl)
3749 (set (make-local-variable 'mml-buffer-list) mbl1))
3750 ;; LOCAL argument of add-hook differs between GNU Emacs
3751 ;; and XEmacs. make-local-hook makes sure they are local.
3752 (make-local-hook 'kill-buffer-hook)
3753 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
3754 `(lambda (no-highlight)
3755 (let ((mail-parse-charset (or gnus-article-charset
3756 ',gnus-newsgroup-charset))
3757 (message-options message-options)
3758 (message-options-set-recipient)
3759 (mail-parse-ignored-charsets
3760 (or gnus-article-ignored-charsets
3761 ',gnus-newsgroup-ignored-charsets)))
3763 (mml-destroy-buffers)
3764 (remove-hook 'kill-buffer-hook
3765 'mml-destroy-buffers t)
3766 (kill-local-variable 'mml-buffer-list))
3767 (gnus-summary-edit-article-done
3768 ,(or (mail-header-references gnus-current-headers) "")
3769 ,(gnus-group-read-only-p)
3770 ,gnus-summary-buffer no-highlight))))))
3772 (defun gnus-mime-save-part ()
3773 "Save the MIME part under point."
3775 (gnus-article-check-buffer)
3776 (let ((data (get-text-property (point) 'gnus-data)))
3778 (mm-save-part data))))
3780 (defun gnus-mime-pipe-part ()
3781 "Pipe the MIME part under point to a process."
3783 (gnus-article-check-buffer)
3784 (let ((data (get-text-property (point) 'gnus-data)))
3786 (mm-pipe-part data))))
3788 (defun gnus-mime-view-part ()
3789 "Interactively choose a viewing method for the MIME part under point."
3791 (gnus-article-check-buffer)
3792 (let ((data (get-text-property (point) 'gnus-data)))
3794 (setq gnus-article-mime-handles
3796 gnus-article-mime-handles (setq data (copy-sequence data))))
3797 (mm-interactively-view-part data))))
3799 (defun gnus-mime-view-part-as-type-internal ()
3800 (gnus-article-check-buffer)
3801 (let* ((name (mail-content-type-get
3802 (mm-handle-type (get-text-property (point) 'gnus-data))
3804 (def-type (and name (mm-default-file-encoding name))))
3805 (and def-type (cons def-type 0))))
3807 (defun gnus-mime-view-part-as-type (&optional mime-type)
3808 "Choose a MIME media type, and view the part as such."
3811 (setq mime-type (completing-read
3812 "View as MIME type: "
3813 (mapcar #'list (mailcap-mime-types))
3815 (gnus-mime-view-part-as-type-internal))))
3816 (gnus-article-check-buffer)
3817 (let ((handle (get-text-property (point) 'gnus-data)))
3820 (mm-make-handle (mm-handle-buffer handle)
3821 (cons mime-type (cdr (mm-handle-type handle)))
3822 (mm-handle-encoding handle)
3823 (mm-handle-undisplayer handle)
3824 (mm-handle-disposition handle)
3825 (mm-handle-description handle)
3827 (mm-handle-id handle)))
3828 (setq gnus-article-mime-handles
3829 (mm-merge-handles gnus-article-mime-handles handle))
3830 (gnus-mm-display-part handle))))
3832 (defun gnus-mime-copy-part (&optional handle)
3833 "Put the the MIME part under point into a new buffer."
3835 (gnus-article-check-buffer)
3836 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3837 (contents (and handle (mm-get-part handle)))
3839 (file-name-nondirectory
3841 (mail-content-type-get (mm-handle-type handle) 'name)
3842 (mail-content-type-get (mm-handle-type handle)
3845 (buffer (and base (generate-new-buffer base))))
3847 (switch-to-buffer buffer)
3849 ;; We do it this way to make `normal-mode' set the appropriate mode.
3852 (setq buffer-file-name (expand-file-name base))
3854 (setq buffer-file-name nil))
3855 (goto-char (point-min)))))
3857 (defun gnus-mime-inline-part (&optional handle arg)
3858 "Insert the MIME part under point into the current buffer."
3859 (interactive (list nil current-prefix-arg))
3860 (gnus-article-check-buffer)
3861 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3866 (if (and (not arg) (mm-handle-undisplayer handle))
3867 (mm-remove-part handle)
3868 (setq contents (mm-get-part handle))
3871 (setq charset (or (mail-content-type-get
3872 (mm-handle-type handle) 'charset)
3873 gnus-newsgroup-charset)))
3875 (if (mm-handle-undisplayer handle)
3876 (mm-remove-part handle))
3879 gnus-summary-show-article-charset-alist))
3880 (mm-read-coding-system "Charset: ")))))
3882 (mm-insert-inline handle
3884 (setq charset (mm-charset-to-coding-system
3886 (not (eq charset 'ascii)))
3887 (mm-decode-coding-string contents charset)
3891 (defun gnus-mime-view-part-as-charset (&optional handle arg)
3892 "Insert the MIME part under point into the current buffer using the
3894 (interactive (list nil current-prefix-arg))
3895 (gnus-article-check-buffer)
3896 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3901 (if (mm-handle-undisplayer handle)
3902 (mm-remove-part handle))
3903 (let ((gnus-newsgroup-charset
3905 gnus-summary-show-article-charset-alist))
3906 (mm-read-coding-system "Charset: ")))
3907 (gnus-newsgroup-ignored-charsets 'gnus-all))
3908 (gnus-article-press-button)))))
3910 (defun gnus-mime-externalize-part (&optional handle)
3911 "View the MIME part under point with an external viewer."
3913 (gnus-article-check-buffer)
3914 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3915 (mm-user-display-methods nil)
3916 (mm-inlined-types nil)
3917 (mail-parse-charset gnus-newsgroup-charset)
3918 (mail-parse-ignored-charsets
3919 (save-excursion (set-buffer gnus-summary-buffer)
3920 gnus-newsgroup-ignored-charsets)))
3922 (if (mm-handle-undisplayer handle)
3923 (mm-remove-part handle)
3924 (mm-display-part handle)))))
3926 (defun gnus-mime-internalize-part (&optional handle)
3927 "View the MIME part under point with an internal viewer.
3928 If no internal viewer is available, use an external viewer."
3930 (gnus-article-check-buffer)
3931 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3932 (mm-inlined-types '(".*"))
3933 (mm-inline-large-images t)
3934 (mail-parse-charset gnus-newsgroup-charset)
3935 (mail-parse-ignored-charsets
3936 (save-excursion (set-buffer gnus-summary-buffer)
3937 gnus-newsgroup-ignored-charsets)))
3939 (if (mm-handle-undisplayer handle)
3940 (mm-remove-part handle)
3941 (mm-display-part handle)))))
3943 (defun gnus-mime-action-on-part (&optional action)
3944 "Do something with the MIME attachment at \(point\)."
3946 (list (completing-read "Action: " gnus-mime-action-alist)))
3947 (gnus-article-check-buffer)
3948 (let ((action-pair (assoc action gnus-mime-action-alist)))
3950 (funcall (cdr action-pair)))))
3952 (defun gnus-article-part-wrapper (n function)
3953 (save-current-buffer
3954 (set-buffer gnus-article-buffer)
3955 (when (> n (length gnus-article-mime-handle-alist))
3956 (error "No such part"))
3957 (gnus-article-goto-part n)
3958 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
3959 (funcall function handle))))
3961 (defun gnus-article-pipe-part (n)
3962 "Pipe MIME part N, which is the numerical prefix."
3964 (gnus-article-part-wrapper n 'mm-pipe-part))
3966 (defun gnus-article-save-part (n)
3967 "Save MIME part N, which is the numerical prefix."
3969 (gnus-article-part-wrapper n 'mm-save-part))
3971 (defun gnus-article-interactively-view-part (n)
3972 "View MIME part N interactively, which is the numerical prefix."
3974 (gnus-article-part-wrapper n 'mm-interactively-view-part))
3976 (defun gnus-article-copy-part (n)
3977 "Copy MIME part N, which is the numerical prefix."
3979 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
3981 (defun gnus-article-view-part-as-charset (n)
3982 "Copy MIME part N, which is the numerical prefix."
3984 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
3986 (defun gnus-article-externalize-part (n)
3987 "View MIME part N externally, which is the numerical prefix."
3989 (gnus-article-part-wrapper n 'gnus-mime-externalize-part))
3991 (defun gnus-article-inline-part (n)
3992 "Inline MIME part N, which is the numerical prefix."
3994 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
3996 (defun gnus-article-mime-match-handle-first (condition)
3998 (let ((alist gnus-article-mime-handle-alist) ihandle n)
3999 (while (setq ihandle (pop alist))
4001 ((functionp condition)
4002 (funcall condition (cdr ihandle)))
4003 ((eq condition 'undisplayed)
4004 (not (or (mm-handle-undisplayer (cdr ihandle))
4005 (equal (mm-handle-media-type (cdr ihandle))
4006 "multipart/alternative"))))
4007 ((eq condition 'undisplayed-alternative)
4008 (not (mm-handle-undisplayer (cdr ihandle))))
4010 (gnus-article-goto-part (car ihandle))
4011 (or (not n) (< (car ihandle) n)))
4012 (setq n (car ihandle))))
4016 (defun gnus-article-view-part (&optional n)
4017 "View MIME part N, which is the numerical prefix."
4019 (save-current-buffer
4020 (set-buffer gnus-article-buffer)
4021 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4022 gnus-article-mime-match-handle-function)))
4023 (when (> n (length gnus-article-mime-handle-alist))
4024 (error "No such part"))
4025 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4026 (when (gnus-article-goto-part n)
4027 (if (equal (car handle) "multipart/alternative")
4028 (gnus-article-press-button)
4029 (when (eq (gnus-mm-display-part handle) 'internal)
4030 (gnus-set-window-start)))))))
4032 (defsubst gnus-article-mime-total-parts ()
4033 (if (bufferp (car gnus-article-mime-handles))
4035 (1- (length gnus-article-mime-handles))))
4037 (defun gnus-mm-display-part (handle)
4038 "Display HANDLE and fix MIME button."
4039 (let ((id (get-text-property (point) 'gnus-part))
4044 (let ((window (selected-window))
4045 (mail-parse-charset gnus-newsgroup-charset)
4046 (mail-parse-ignored-charsets
4047 (save-excursion (set-buffer gnus-summary-buffer)
4048 gnus-newsgroup-ignored-charsets)))
4051 (let ((win (get-buffer-window (current-buffer) t))
4054 (select-window win))
4057 (if (mm-handle-displayed-p handle)
4058 ;; This will remove the part.
4059 (mm-display-part handle)
4061 (narrow-to-region (point)
4062 (if (eobp) (point) (1+ (point))))
4063 (mm-display-part handle)
4064 ;; We narrow to the part itself and
4065 ;; then call the treatment functions.
4066 (goto-char (point-min))
4068 (narrow-to-region (point) (point-max))
4071 (gnus-article-mime-total-parts)
4072 (mm-handle-media-type handle)))))
4073 (if (window-live-p window)
4074 (select-window window)))))
4076 (delete-region (gnus-point-at-bol) (progn (forward-line 1) (point)))
4077 (gnus-insert-mime-button
4078 handle id (list (mm-handle-displayed-p handle)))
4079 (goto-char point))))
4081 (defun gnus-article-goto-part (n)
4082 "Go to MIME part N."
4083 (let ((point (text-property-any (point-min) (point-max) 'gnus-part n)))
4085 (goto-char point))))
4087 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4088 (let ((gnus-tmp-name
4089 (or (mail-content-type-get (mm-handle-type handle) 'name)
4090 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4091 (mail-content-type-get (mm-handle-type handle) 'url)
4093 (gnus-tmp-type (mm-handle-media-type handle))
4094 (gnus-tmp-description
4095 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4098 (if (if displayed (car displayed)
4099 (mm-handle-displayed-p handle))
4101 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4103 gnus-tmp-type-long b e)
4104 (when (string-match ".*/" gnus-tmp-name)
4105 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4106 (setq gnus-tmp-type-long (concat gnus-tmp-type
4107 (and (not (equal gnus-tmp-name ""))
4108 (concat "; " gnus-tmp-name))))
4109 (unless (equal gnus-tmp-description "")
4110 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4115 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4116 `(keymap ,gnus-mime-button-map
4117 ,@(if (>= (string-to-number emacs-version) 21)
4119 (list 'local-map gnus-mime-button-map))
4120 gnus-callback gnus-mm-display-part
4121 gnus-part ,gnus-tmp-id
4122 article-type annotation
4125 (widget-convert-button
4128 :action 'gnus-widget-press-button
4129 :button-keymap gnus-mime-button-map
4131 (lambda (widget/window &optional overlay pos)
4132 ;; Needed to properly clear the message due to a bug in
4133 ;; wid-edit (XEmacs only).
4134 (if (boundp 'help-echo-owns-message)
4135 (setq help-echo-owns-message t))
4137 "%S: %s the MIME part; %S: more options"
4138 (aref gnus-mouse-2 0)
4139 ;; XEmacs will get a single widget arg; Emacs 21 will get
4140 ;; window, overlay, position.
4141 (if (mm-handle-displayed-p
4143 (with-current-buffer (gnus-overlay-buffer overlay)
4144 (widget-get (widget-at (gnus-overlay-start overlay))
4146 (widget-get widget/window :mime-handle)))
4148 (aref gnus-down-mouse-3 0))))))
4150 (defun gnus-widget-press-button (elems el)
4151 (goto-char (widget-get elems :from))
4152 (gnus-article-press-button))
4154 (defvar gnus-displaying-mime nil)
4156 (defun gnus-display-mime (&optional ihandles)
4157 "Display the MIME parts."
4159 (save-selected-window
4160 (let ((window (get-buffer-window gnus-article-buffer))
4163 (select-window window)
4164 ;; We have to do this since selecting the window
4165 ;; may change the point. So we set the window point.
4166 (set-window-point window point)))
4167 (let* ((handles (or ihandles (mm-dissect-buffer) (mm-uu-dissect)))
4168 buffer-read-only handle name type b e display)
4169 (when (and (not ihandles)
4170 (not gnus-displaying-mime))
4171 ;; Top-level call; we clean up.
4172 (when gnus-article-mime-handles
4173 (mm-destroy-parts gnus-article-mime-handles)
4174 (setq gnus-article-mime-handle-alist nil));; A trick.
4175 (setq gnus-article-mime-handles handles)
4176 ;; We allow users to glean info from the handles.
4177 (when gnus-article-mime-part-function
4178 (gnus-mime-part-function handles)))
4180 (or (not (stringp (car handles)))
4183 (when (and (not ihandles)
4184 (not gnus-displaying-mime))
4185 ;; Clean up for mime parts.
4187 (delete-region (point) (point-max)))
4188 (let ((gnus-displaying-mime t))
4189 (gnus-mime-display-part handles)))
4192 (narrow-to-region (point) (point-max))
4193 (gnus-treat-article nil 1 1)
4196 ;; Highlight the headers.
4200 (narrow-to-region (point-min) (point))
4201 (gnus-treat-article 'head))))))))
4203 (defvar gnus-mime-display-multipart-as-mixed nil)
4204 (defvar gnus-mime-display-multipart-alternative-as-mixed nil)
4205 (defvar gnus-mime-display-multipart-related-as-mixed nil)
4207 (defun gnus-mime-display-part (handle)
4210 ((not (stringp (car handle)))
4211 (gnus-mime-display-single handle))
4212 ;; User-defined multipart
4213 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4214 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4216 ;; multipart/alternative
4217 ((and (equal (car handle) "multipart/alternative")
4218 (not (or gnus-mime-display-multipart-as-mixed
4219 gnus-mime-display-multipart-alternative-as-mixed)))
4220 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4221 (push (cons id handle) gnus-article-mime-handle-alist)
4222 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4223 ;; multipart/related
4224 ((and (equal (car handle) "multipart/related")
4225 (not (or gnus-mime-display-multipart-as-mixed
4226 gnus-mime-display-multipart-related-as-mixed)))
4227 ;;;!!!We should find the start part, but we just default
4228 ;;;!!!to the first part.
4229 ;;(gnus-mime-display-part (cadr handle))
4230 ;;;!!! Most multipart/related is an HTML message plus images.
4231 ;;;!!! Unfortunately we are unable to let W3 display those
4232 ;;;!!! included images, so we just display it as a mixed multipart.
4233 ;;(gnus-mime-display-mixed (cdr handle))
4234 ;;;!!! No, w3 can display everything just fine.
4235 (gnus-mime-display-part (cadr handle)))
4236 ((equal (car handle) "multipart/signed")
4237 (or (memq 'signed gnus-article-wash-types)
4238 (push 'signed gnus-article-wash-types))
4239 (gnus-mime-display-security handle))
4240 ((equal (car handle) "multipart/encrypted")
4241 (or (memq 'encrypted gnus-article-wash-types)
4242 (push 'encrypted gnus-article-wash-types))
4243 (gnus-mime-display-security handle))
4244 ;; Other multiparts are handled like multipart/mixed.
4246 (gnus-mime-display-mixed (cdr handle)))))
4248 (defun gnus-mime-part-function (handles)
4249 (if (stringp (car handles))
4250 (mapcar 'gnus-mime-part-function (cdr handles))
4251 (funcall gnus-article-mime-part-function handles)))
4253 (defun gnus-mime-display-mixed (handles)
4254 (mapcar 'gnus-mime-display-part handles))
4256 (defun gnus-mime-display-single (handle)
4257 (let ((type (mm-handle-media-type handle))
4258 (ignored gnus-ignored-mime-types)
4265 (when (string-match (pop ignored) type)
4266 (throw 'ignored nil)))
4267 (if (and (setq not-attachment
4268 (and (not (mm-inline-override-p handle))
4269 (or (not (mm-handle-disposition handle))
4270 (equal (car (mm-handle-disposition handle))
4272 (mm-attachment-override-p handle))))
4273 (mm-automatic-display-p handle)
4275 (mm-inlinable-p handle)
4276 (mm-inlined-p handle))
4277 (mm-automatic-external-display-p type)))
4279 (when (equal (mm-handle-media-supertype handle) "text")
4281 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4283 (push (cons id handle) gnus-article-mime-handle-alist)
4284 (when (or (not display)
4285 (not (gnus-unbuttonized-mime-type-p type)))
4286 ;(gnus-article-insert-newline)
4287 (gnus-insert-mime-button
4288 handle id (list (or display (and not-attachment text))))
4289 (gnus-article-insert-newline)
4290 ;(gnus-article-insert-newline)
4291 ;; Remember modify the number of forward lines.
4299 (let ((mail-parse-charset gnus-newsgroup-charset)
4300 (mail-parse-ignored-charsets
4301 (save-excursion (condition-case ()
4302 (set-buffer gnus-summary-buffer)
4304 gnus-newsgroup-ignored-charsets)))
4305 (mm-display-part handle t))
4306 (goto-char (point-max)))
4307 ((and text not-attachment)
4311 (gnus-article-insert-newline)
4312 (mm-insert-inline handle (mm-get-part handle))
4313 (goto-char (point-max))))
4317 (narrow-to-region beg (point))
4320 (gnus-article-mime-total-parts)
4321 (mm-handle-media-type handle)))))))))
4323 (defun gnus-unbuttonized-mime-type-p (type)
4324 "Say whether TYPE is to be unbuttonized."
4325 (unless gnus-inhibit-mime-unbuttonizing
4327 (let ((types gnus-unbuttonized-mime-types))
4329 (when (string-match (pop types) type)
4330 (throw 'found t)))))
4332 (let ((types gnus-buttonized-mime-types))
4334 (when (string-match (pop types) type)
4335 (throw 'found t)))))))))
4337 (defun gnus-article-insert-newline ()
4338 "Insert a newline, but mark it as undeletable."
4339 (gnus-put-text-property
4340 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4342 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4343 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4346 handle buffer-read-only from props begend not-pref)
4347 (save-window-excursion
4350 (narrow-to-region (car ibegend)
4353 (goto-char (car ibegend))
4356 (delete-region (point-min) (point-max))
4357 (mm-remove-parts handles))
4358 (setq begend (list (point-marker)))
4360 (unless (setq not-pref (cadr (member preferred ihandles)))
4361 (setq not-pref (car ihandles)))
4364 (not (gnus-unbuttonized-mime-type-p
4365 "multipart/alternative")))
4366 (gnus-add-text-properties
4369 (insert (format "%d. " id))
4373 (unless ,(not ibegend)
4374 (setq gnus-article-mime-handle-alist
4375 ',gnus-article-mime-handle-alist))
4376 (gnus-mime-display-alternative
4377 ',ihandles ',not-pref ',begend ,id))
4378 ,@(if (>= (string-to-number emacs-version) 21)
4379 nil ;; XEmacs doesn't care
4380 (list 'local-map gnus-mime-button-map))
4381 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4382 face ,gnus-article-button-face
4383 keymap ,gnus-mime-button-map
4386 (widget-convert-button 'link from (point)
4387 :action 'gnus-widget-press-button
4388 :button-keymap gnus-widget-button-keymap)
4390 (while (setq handle (pop handles))
4391 (gnus-add-text-properties
4394 (insert (format "(%c) %-18s"
4395 (if (equal handle preferred) ?* ? )
4396 (mm-handle-media-type handle)))
4400 (unless ,(not ibegend)
4401 (setq gnus-article-mime-handle-alist
4402 ',gnus-article-mime-handle-alist))
4403 (gnus-mime-display-alternative
4404 ',ihandles ',handle ',begend ,id))
4405 ,@(if (>= (string-to-number emacs-version) 21)
4406 nil ;; XEmacs doesn't care
4407 (list 'local-map gnus-mime-button-map))
4408 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4409 face ,gnus-article-button-face
4410 keymap ,gnus-mime-button-map
4413 (widget-convert-button 'link from (point)
4414 :action 'gnus-widget-press-button
4415 :button-keymap gnus-widget-button-keymap)
4419 (if (stringp (car preferred))
4420 (gnus-display-mime preferred)
4421 (let ((mail-parse-charset gnus-newsgroup-charset)
4422 (mail-parse-ignored-charsets
4423 (save-excursion (set-buffer gnus-summary-buffer)
4424 gnus-newsgroup-ignored-charsets)))
4425 (mm-display-part preferred)
4429 (narrow-to-region (car begend) (point-max))
4431 nil (length gnus-article-mime-handle-alist)
4432 (gnus-article-mime-total-parts)
4433 (mm-handle-media-type handle))))))
4434 (goto-char (point-max))
4435 (setcdr begend (point-marker)))))
4437 (goto-char point))))
4439 (defun gnus-article-wash-status ()
4440 "Return a string which display status of article washing."
4442 (set-buffer gnus-article-buffer)
4443 (let ((cite (memq 'cite gnus-article-wash-types))
4444 (headers (memq 'headers gnus-article-wash-types))
4445 (boring (memq 'boring-headers gnus-article-wash-types))
4446 (pgp (memq 'pgp gnus-article-wash-types))
4447 (pem (memq 'pem gnus-article-wash-types))
4448 (signed (memq 'signed gnus-article-wash-types))
4449 (encrypted (memq 'encrypted gnus-article-wash-types))
4450 (signature (memq 'signature gnus-article-wash-types))
4451 (overstrike (memq 'overstrike gnus-article-wash-types))
4452 (emphasis (memq 'emphasis gnus-article-wash-types)))
4453 (format "%c%c%c%c%c%c%c"
4455 (if (or headers boring) ?h ? )
4456 (if (or pgp pem signed encrypted) ?p ? )
4457 (if signature ?s ? )
4458 (if overstrike ?o ? )
4459 (if gnus-show-mime ?m ? )
4460 (if emphasis ?e ? )))))
4462 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
4464 (defun gnus-article-maybe-hide-headers ()
4465 "Hide unwanted headers if `gnus-have-all-headers' is nil.
4466 Provided for backwards compatibility."
4467 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
4468 (not (save-excursion (set-buffer gnus-summary-buffer)
4469 gnus-have-all-headers)))
4470 (not gnus-inhibit-hiding))
4471 (gnus-article-hide-headers)))
4475 (defun gnus-output-to-file (file-name)
4476 "Append the current article to a file named FILE-NAME."
4477 (let ((artbuf (current-buffer)))
4479 (insert-buffer-substring artbuf)
4480 ;; Append newline at end of the buffer as separator, and then
4482 (goto-char (point-max))
4484 (let ((file-name-coding-system nnmail-pathname-coding-system)
4485 (pathname-coding-system nnmail-pathname-coding-system))
4486 (write-region-as-binary (point-min) (point-max) file-name 'append))
4489 (defun gnus-narrow-to-page (&optional arg)
4490 "Narrow the article buffer to a page.
4491 If given a numerical ARG, move forward ARG pages."
4493 (setq arg (if arg (prefix-numeric-value arg) 0))
4495 (set-buffer gnus-article-buffer)
4496 (goto-char (point-min))
4498 ;; Remove any old next/prev buttons.
4499 (when (gnus-visual-p 'page-marker)
4500 (let ((buffer-read-only nil))
4501 (gnus-remove-text-with-property 'gnus-prev)
4502 (gnus-remove-text-with-property 'gnus-next)))
4505 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
4507 (re-search-forward page-delimiter nil 'move arg)))
4508 (goto-char (match-end 0)))
4511 (if (re-search-forward page-delimiter nil 'move)
4514 (when (and (gnus-visual-p 'page-marker)
4515 (not (= (point-min) 1)))
4517 (goto-char (point-min))
4518 (gnus-insert-prev-page-button)))
4519 (when (and (gnus-visual-p 'page-marker)
4520 (< (+ (point-max) 2) (buffer-size)))
4522 (goto-char (point-max))
4523 (gnus-insert-next-page-button)))))
4525 ;; Article mode commands
4527 (defun gnus-article-goto-next-page ()
4528 "Show the next page of the article."
4530 (when (gnus-article-next-page)
4531 (goto-char (point-min))
4532 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
4534 (defun gnus-article-goto-prev-page ()
4535 "Show the next page of the article."
4537 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
4538 (gnus-article-prev-page nil)))
4540 (defun gnus-article-next-page (&optional lines)
4541 "Show the next page of the current article.
4542 If end of article, return non-nil. Otherwise return nil.
4543 Argument LINES specifies lines to be scrolled up."
4545 (let ((start (window-start))
4546 end-of-buffer end-of-page)
4548 (move-to-window-line -1)
4549 (if (<= (point) start)
4552 (setq start (point)))
4555 (unless (or (cond ((eq (1+ (buffer-size)) (point))
4556 (and (pos-visible-in-window-p)
4557 (setq end-of-buffer t)))
4559 (setq end-of-page t)))
4561 (move-to-window-line lines)
4562 (unless (search-backward "\n\n" nil t)
4563 (setq start (point)))))
4564 (cond (end-of-buffer t)
4566 (gnus-narrow-to-page 1)
4570 (set-window-start (selected-window) start)
4571 (let (window-pixel-scroll-increment)
4575 (defun gnus-article-prev-page (&optional lines)
4576 "Show previous page of current article.
4577 Argument LINES specifies lines to be scrolled down."
4579 (let (beginning-of-buffer beginning-of-page)
4581 (move-to-window-line 0)
4582 (cond ((eq 1 (point))
4583 (setq beginning-of-buffer t))
4585 (setq beginning-of-page t))))
4586 (cond (beginning-of-buffer)
4588 (gnus-narrow-to-page -1))
4591 (let (window-pixel-scroll-increment)
4592 (scroll-down lines))
4593 (beginning-of-buffer
4594 (goto-char (point-min))))))))
4596 (defun gnus-article-refer-article ()
4597 "Read article specified by message-id around point."
4599 (let ((point (point)))
4600 (search-forward ">" nil t) ;Move point to end of "<....>".
4601 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
4602 (let ((message-id (match-string 1)))
4604 (set-buffer gnus-summary-buffer)
4605 (gnus-summary-refer-article message-id))
4607 (error "No references around point"))))
4609 (defun gnus-article-show-summary ()
4610 "Reconfigure windows to show summary buffer."
4612 (if (not (gnus-buffer-live-p gnus-summary-buffer))
4613 (error "There is no summary buffer for this article buffer")
4614 (gnus-article-set-globals)
4615 (gnus-configure-windows 'article)
4616 (gnus-summary-goto-subject gnus-current-article)
4617 (gnus-summary-position-point)))
4619 (defun gnus-article-describe-briefly ()
4620 "Describe article mode commands briefly."
4622 (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")))
4624 (defun gnus-article-summary-command ()
4625 "Execute the last keystroke in the summary buffer."
4627 (let ((obuf (current-buffer))
4628 (owin (current-window-configuration))
4630 (switch-to-buffer gnus-article-current-summary 'norecord)
4631 (setq func (lookup-key (current-local-map) (this-command-keys)))
4632 (call-interactively func)
4634 (set-window-configuration owin)
4635 (set-window-point (get-buffer-window (current-buffer)) (point))))
4637 (defun gnus-article-summary-command-nosave ()
4638 "Execute the last keystroke in the summary buffer."
4641 (pop-to-buffer gnus-article-current-summary 'norecord)
4642 (setq func (lookup-key (current-local-map) (this-command-keys)))
4643 (call-interactively func)))
4645 (defun gnus-article-check-buffer ()
4646 "Beep if not in an article buffer."
4647 (unless (eq (get-buffer gnus-article-buffer) (current-buffer))
4648 (error "Command invoked outside of a Gnus article buffer")))
4650 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
4651 "Read a summary buffer key sequence and execute it from the article buffer."
4653 (gnus-article-check-buffer)
4655 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
4656 "Zc" "ZC" "ZE" "ZJ" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
4657 "=" "^" "\M-^" "|"))
4663 '("n" "Gn" "p" "Gp"))
4666 (set-buffer gnus-article-current-summary)
4667 (let (gnus-pick-mode)
4668 (push (or key last-command-event) unread-command-events)
4669 (setq keys (static-if (featurep 'xemacs)
4670 (events-to-keys (read-key-sequence nil))
4671 (read-key-sequence nil)))))
4674 (if (or (member keys nosaves)
4675 (member keys nosave-but-article)
4676 (member keys nosave-in-article))
4678 (save-window-excursion
4679 (pop-to-buffer gnus-article-current-summary 'norecord)
4680 ;; We disable the pick minor mode commands.
4681 (let (gnus-pick-mode)
4682 (setq func (lookup-key (current-local-map) keys))))
4686 (unless (member keys nosave-in-article)
4687 (set-buffer gnus-article-current-summary))
4688 (call-interactively func)
4689 (setq new-sum-point (point)))
4690 (when (member keys nosave-but-article)
4691 (pop-to-buffer gnus-article-buffer 'norecord)))
4692 ;; These commands should restore window configuration.
4693 (let ((obuf (current-buffer))
4694 (owin (current-window-configuration))
4696 (summary gnus-article-current-summary)
4697 func in-buffer selected)
4698 (if not-restore-window
4699 (pop-to-buffer summary 'norecord)
4700 (switch-to-buffer summary 'norecord))
4701 (setq in-buffer (current-buffer))
4702 ;; We disable the pick minor mode commands.
4703 (if (and (setq func (let (gnus-pick-mode)
4704 (lookup-key (current-local-map) keys)))
4707 (call-interactively func)
4708 (setq new-sum-point (point))
4709 (when (eq in-buffer (current-buffer))
4710 (setq selected (gnus-summary-select-article))
4712 (unless not-restore-window
4713 (set-window-configuration owin))
4714 (when (eq selected 'old)
4716 (set-window-start (get-buffer-window (current-buffer))
4718 (set-window-point (get-buffer-window (current-buffer))
4720 (let ((win (get-buffer-window gnus-article-current-summary)))
4722 (set-window-point win new-sum-point)))) )
4723 (switch-to-buffer gnus-article-buffer)
4726 (defun gnus-article-describe-key (key)
4727 "Display documentation of the function invoked by KEY. KEY is a string."
4728 (interactive "kDescribe key: ")
4729 (gnus-article-check-buffer)
4730 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
4732 (set-buffer gnus-article-current-summary)
4733 (let (gnus-pick-mode)
4734 (if (featurep 'xemacs)
4736 (push (elt key 0) unread-command-events)
4737 (setq key (events-to-keys
4738 (read-key-sequence "Describe key: "))))
4739 (setq unread-command-events
4741 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
4743 (setq key (read-key-sequence "Describe key: "))))
4745 (describe-key key)))
4747 (defun gnus-article-describe-key-briefly (key &optional insert)
4748 "Display documentation of the function invoked by KEY. KEY is a string."
4749 (interactive "kDescribe key: \nP")
4750 (gnus-article-check-buffer)
4751 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
4753 (set-buffer gnus-article-current-summary)
4754 (let (gnus-pick-mode)
4755 (if (featurep 'xemacs)
4757 (push (elt key 0) unread-command-events)
4758 (setq key (events-to-keys
4759 (read-key-sequence "Describe key: "))))
4760 (setq unread-command-events
4762 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
4764 (setq key (read-key-sequence "Describe key: "))))
4765 (describe-key-briefly key insert))
4766 (describe-key-briefly key insert)))
4768 (defun gnus-article-hide (&optional arg force)
4769 "Hide all the gruft in the current article.
4770 This means that PGP stuff, signatures, cited text and (some)
4771 headers will be hidden.
4772 If given a prefix, show the hidden text instead."
4773 (interactive (append (gnus-article-hidden-arg) (list 'force)))
4774 (gnus-article-hide-headers arg)
4775 (gnus-article-hide-list-identifiers arg)
4776 (gnus-article-hide-pgp arg)
4777 (gnus-article-hide-citation-maybe arg force)
4778 (gnus-article-hide-signature arg))
4780 (defun gnus-article-maybe-highlight ()
4781 "Do some article highlighting if article highlighting is requested."
4782 (when (gnus-visual-p 'article-highlight 'highlight)
4783 (gnus-article-highlight-some)))
4785 (defun gnus-check-group-server ()
4786 ;; Make sure the connection to the server is alive.
4787 (unless (gnus-server-opened
4788 (gnus-find-method-for-group gnus-newsgroup-name))
4789 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
4790 (gnus-request-group gnus-newsgroup-name t)))
4792 (defun gnus-request-article-this-buffer (article group)
4793 "Get an article and insert it into this buffer.
4794 T-gnus change: Insert an article into `gnus-original-article-buffer'."
4795 (let (do-update-line sparse-header)
4796 ;; The current buffer is `gnus-article-buffer'.
4800 (gnus-kill-all-overlays)
4801 (setq group (or group gnus-newsgroup-name))
4803 ;; Using `gnus-request-article' directly will insert the article into
4804 ;; `nntp-server-buffer' - so we'll save some time by not having to
4805 ;; copy it from the server buffer into the article buffer.
4807 ;; We only request an article by message-id when we do not have the
4808 ;; headers for it, so we'll have to get those.
4809 (when (stringp article)
4810 (gnus-read-header article))
4812 ;; If the article number is negative, that means that this article
4813 ;; doesn't belong in this newsgroup (possibly), so we find its
4814 ;; message-id and request it by id instead of number.
4815 (when (and (numberp article)
4817 (get-buffer gnus-summary-buffer)
4818 (gnus-buffer-exists-p gnus-summary-buffer))
4820 (set-buffer gnus-summary-buffer)
4821 (let ((header (gnus-summary-article-header article)))
4824 ((memq article gnus-newsgroup-sparse)
4825 ;; This is a sparse gap article.
4826 (setq do-update-line article)
4827 (setq article (mail-header-id header))
4828 (setq sparse-header (gnus-read-header article))
4829 (setq gnus-newsgroup-sparse
4830 (delq article gnus-newsgroup-sparse)))
4832 ;; It's a real article.
4833 (setq article (mail-header-id header)))
4835 ;; It is an extracted pseudo-article.
4836 (setq article 'pseudo)
4837 (gnus-request-pseudo-article header))))
4839 (let ((method (gnus-find-method-for-group
4840 gnus-newsgroup-name)))
4841 (when (and (eq (car method) 'nneething)
4843 (let ((dir (expand-file-name
4844 (mail-header-subject header)
4845 (file-name-as-directory
4846 (or (cadr (assq 'nneething-address method))
4848 (when (file-directory-p dir)
4849 (setq article 'nneething)
4850 (gnus-group-enter-directory dir))))))))
4851 (setq gnus-original-article (cons group article))
4853 ;; The current buffer is `gnus-original-article-buffer'.
4854 (if (get-buffer gnus-original-article-buffer)
4855 (set-buffer gnus-original-article-buffer)
4856 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
4857 (set-buffer-multibyte nil)
4858 (buffer-disable-undo)
4859 (setq major-mode 'gnus-original-article-mode)
4860 (setq buffer-read-only nil))
4863 ;; Refuse to select canceled articles.
4864 ((and (numberp article)
4866 (get-buffer gnus-summary-buffer)
4867 (gnus-buffer-exists-p gnus-summary-buffer)
4868 (eq (cdr (save-excursion
4869 (set-buffer gnus-summary-buffer)
4870 (assq article gnus-newsgroup-reads)))
4871 gnus-canceled-mark))
4873 ;; Check the backlog.
4874 ((and gnus-keep-backlog
4875 (gnus-backlog-request-article group article (current-buffer)))
4877 ;; Check asynchronous pre-fetch.
4878 ((gnus-async-request-fetched-article group article (current-buffer))
4879 (gnus-async-prefetch-next group article gnus-summary-buffer)
4880 (when (and (numberp article) gnus-keep-backlog)
4881 (gnus-backlog-enter-article group article (current-buffer)))
4884 ((and gnus-use-cache
4886 (gnus-cache-request-article article group))
4888 ;; Get the article and put into the article buffer.
4889 ((or (stringp article)
4891 (let ((gnus-override-method gnus-override-method)
4892 (methods (and (stringp article)
4893 gnus-refer-article-method))
4895 (buffer-read-only nil))
4896 (if (or (not (listp methods))
4897 (and (symbolp (car methods))
4898 (assq (car methods) nnoo-definition-alist)))
4899 (setq methods (list methods)))
4900 (when (and (null gnus-override-method)
4902 (setq gnus-override-method (pop methods)))
4904 (when (eq gnus-override-method 'current)
4905 (setq gnus-override-method
4906 (with-current-buffer gnus-summary-buffer
4907 gnus-current-select-method)))
4909 (gnus-kill-all-overlays)
4910 (let ((gnus-newsgroup-name group))
4911 (gnus-check-group-server))
4912 (when (gnus-request-article article group (current-buffer))
4913 (when (numberp article)
4914 (gnus-async-prefetch-next group article
4915 gnus-summary-buffer)
4916 (when gnus-keep-backlog
4917 (gnus-backlog-enter-article
4918 group article (current-buffer))))
4919 (setq result 'article))
4922 (setq gnus-override-method (pop methods))
4923 (setq result 'done))))
4924 (and (eq result 'article) 'article)))
4928 ;; Associate this article with the current summary buffer.
4929 (setq gnus-article-current-summary gnus-summary-buffer)
4931 ;; T-gnus change: Copy the requested article from
4932 ;; `gnus-original-article-buffer' to the current buffer when
4933 ;; this function is called.
4934 (insert-buffer gnus-original-article-buffer)
4937 (run-hooks 'gnus-article-decode-hook)
4938 ;; Mark article as decoded or not.
4939 (setq gnus-article-decoded-p gnus-article-decode-hook)
4941 ;; Update sparse articles.
4942 (when (and do-update-line
4943 (or (numberp article)
4945 (let ((buf (current-buffer)))
4946 (set-buffer gnus-summary-buffer)
4947 (gnus-summary-update-article do-update-line sparse-header)
4948 (gnus-summary-goto-subject do-update-line nil t)
4949 (set-window-point (get-buffer-window (current-buffer) t)
4951 (set-buffer buf))))))
4957 (defcustom gnus-article-edit-mode-hook nil
4958 "Hook run in article edit mode buffers."
4959 :group 'gnus-article-various
4962 (defcustom gnus-article-edit-article-setup-function
4963 'gnus-article-mime-edit-article-setup
4964 "Function called to setup an editing article buffer."
4965 :group 'gnus-article-various
4968 (defvar gnus-article-edit-done-function nil)
4970 (defvar gnus-article-edit-mode-map nil)
4972 ;; Should we be using derived.el for this?
4973 (unless gnus-article-edit-mode-map
4974 (setq gnus-article-edit-mode-map (make-sparse-keymap))
4975 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
4977 (gnus-define-keys gnus-article-edit-mode-map
4978 "\C-c\C-c" gnus-article-edit-done
4979 "\C-c\C-k" gnus-article-edit-exit)
4981 (gnus-define-keys (gnus-article-edit-wash-map
4982 "\C-c\C-w" gnus-article-edit-mode-map)
4983 "f" gnus-article-edit-full-stops))
4985 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
4986 "Major mode for editing articles.
4987 This is an extended text-mode.
4989 \\{gnus-article-edit-mode-map}"
4990 (make-local-variable 'gnus-article-edit-done-function)
4991 (make-local-variable 'gnus-prev-winconf)
4992 (set (make-local-variable 'font-lock-defaults)
4993 '(message-font-lock-keywords t))
4994 (setq buffer-read-only nil)
4995 (buffer-enable-undo)
4998 (defun gnus-article-edit (&optional force)
4999 "Edit the current article.
5000 This will have permanent effect only in mail groups.
5001 If FORCE is non-nil, allow editing of articles even in read-only
5004 (when (and (not force)
5005 (gnus-group-read-only-p))
5006 (error "The current newsgroup does not support article editing"))
5007 (gnus-article-date-original)
5008 (gnus-article-edit-article
5010 `(lambda (no-highlight)
5012 (gnus-summary-edit-article-done
5013 ,(or (mail-header-references gnus-current-headers) "")
5014 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5016 (defun gnus-article-edit-article (start-func exit-func)
5017 "Start editing the contents of the current article buffer."
5018 (let ((winconf (current-window-configuration)))
5019 (set-buffer gnus-article-buffer)
5020 (gnus-article-edit-mode)
5021 (funcall start-func)
5022 (set-buffer-modified-p nil)
5023 (gnus-configure-windows 'edit-article)
5024 (setq gnus-article-edit-done-function exit-func)
5025 (setq gnus-prev-winconf winconf)
5026 (when gnus-article-edit-article-setup-function
5027 (funcall gnus-article-edit-article-setup-function))
5028 (gnus-message 6 "C-c C-c to end edits; C-c C-k to exit")))
5030 (defun gnus-article-edit-done (&optional arg)
5031 "Update the article edits and exit."
5033 (let ((func gnus-article-edit-done-function)
5034 (buf (current-buffer))
5035 (start (window-start)))
5036 (remove-hook 'gnus-article-mode-hook
5037 'gnus-article-mime-edit-article-unwind)
5038 ;; We remove all text props from the article buffer.
5040 (buffer-substring-no-properties (point-min) (point-max)))
5044 (let ((winconf gnus-prev-winconf))
5046 (set-window-configuration winconf)
5047 ;; Tippy-toe some to make sure that point remains where it was.
5048 (save-current-buffer
5050 (set-window-start (get-buffer-window (current-buffer)) start)
5054 (let ((buffer-read-only nil))
5056 ;; The cache and backlog have to be flushed somewhat.
5057 (when gnus-keep-backlog
5058 (gnus-backlog-remove-article
5059 (car gnus-article-current) (cdr gnus-article-current)))
5060 ;; Flush original article as well.
5062 (when (get-buffer gnus-original-article-buffer)
5063 (set-buffer gnus-original-article-buffer)
5064 (setq gnus-original-article nil)))
5065 (when gnus-use-cache
5066 (gnus-cache-update-article
5067 (car gnus-article-current) (cdr gnus-article-current))))
5069 (set-window-start (get-buffer-window buf) start)
5070 (set-window-point (get-buffer-window buf) (point))))
5072 (defun gnus-article-edit-exit ()
5073 "Exit the article editing without updating."
5075 (when (or (not (buffer-modified-p))
5076 (yes-or-no-p "Article modified; kill anyway? "))
5077 (let ((curbuf (current-buffer))
5079 (window-start (window-start)))
5081 (if (gnus-buffer-live-p gnus-original-article-buffer)
5082 (insert-buffer gnus-original-article-buffer))
5083 (let ((winconf gnus-prev-winconf))
5085 (set-window-configuration winconf)
5086 ;; Tippy-toe some to make sure that point remains where it was.
5087 (save-current-buffer
5089 (set-window-start (get-buffer-window (current-buffer)) window-start)
5092 (defun gnus-article-edit-full-stops ()
5093 "Interactively repair spacing at end of sentences."
5096 (goto-char (point-min))
5097 (search-forward-regexp "^$" nil t)
5098 (let ((case-fold-search nil))
5099 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5102 ;;; Article editing with MIME-Edit
5105 (defcustom gnus-article-mime-edit-article-setup-hook nil
5106 "Hook run after setting up a MIME editing article buffer."
5107 :group 'gnus-article-various
5110 (defun gnus-article-mime-edit-article-unwind ()
5111 "Unwind `gnus-article-buffer' if article editing was given up."
5112 (remove-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
5113 (when (featurep 'font-lock)
5114 (setq font-lock-defaults nil)
5115 (font-lock-mode -1))
5116 (when mime-edit-mode-flag
5117 (mime-edit-exit 'nomime 'no-error)
5120 (defun gnus-article-mime-edit-article-setup ()
5121 "Convert current buffer to MIME-Edit buffer and turn on MIME-Edit mode
5122 after replacing with the original article."
5123 (setq gnus-show-mime t)
5124 (setq gnus-article-edit-done-function
5125 `(lambda (&rest args)
5126 (when mime-edit-mode-flag
5127 (let (mime-edit-insert-user-agent-field)
5130 (goto-char (point-min))
5131 (let (case-fold-search)
5132 (when (re-search-forward
5133 (format "^%s$" (regexp-quote mail-header-separator))
5135 (replace-match "")))
5136 (apply ,gnus-article-edit-done-function args)
5139 (buffer-substring-no-properties (point-min) (point-max))
5140 (set-buffer (get-buffer-create gnus-original-article-buffer))
5142 (setq gnus-current-headers (gnus-article-make-full-mail-header))
5143 (set-buffer gnus-article-buffer)
5144 (gnus-article-prepare-display)))
5145 (substitute-key-definition 'gnus-article-edit-done
5146 'gnus-article-mime-edit-done
5147 gnus-article-edit-mode-map)
5148 (substitute-key-definition 'gnus-article-edit-exit
5149 'gnus-article-mime-edit-exit
5150 gnus-article-edit-mode-map)
5152 (insert-buffer gnus-original-article-buffer)
5153 (let ((ofn (symbol-function 'mime-edit-decode-single-part-in-buffer)))
5154 (fset 'mime-edit-decode-single-part-in-buffer
5155 (lambda (&rest args)
5156 (if (let ((content-type (car args)))
5157 (and (eq 'message (mime-content-type-primary-type
5159 (eq 'rfc822 (mime-content-type-subtype content-type))))
5160 (setcar (cdr args) 'not-decode-text))
5164 (fset 'mime-edit-decode-single-part-in-buffer ofn)))
5165 (when (featurep 'font-lock)
5166 (set (make-local-variable 'font-lock-defaults)
5167 '(message-font-lock-keywords t))
5168 (font-lock-set-defaults)
5169 (turn-on-font-lock))
5170 (set-buffer-modified-p nil)
5171 (delete-other-windows)
5172 (add-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
5173 (gnus-run-hooks 'gnus-article-mime-edit-article-setup-hook))
5175 (defun gnus-article-mime-edit-done (&optional arg)
5176 "Update the article MIME edits and exit."
5178 (when (featurep 'font-lock)
5179 (setq font-lock-defaults nil)
5180 (font-lock-mode -1))
5181 (gnus-article-edit-done arg))
5183 (defun gnus-article-mime-edit-exit ()
5184 "Exit the article MIME editing without updating."
5186 (when (or (not (buffer-modified-p))
5187 (yes-or-no-p "Article modified; kill anyway? "))
5188 (when (featurep 'font-lock)
5189 (setq font-lock-defaults nil)
5190 (font-lock-mode -1))
5191 (when mime-edit-mode-flag
5192 (let (mime-edit-insert-user-agent-field)
5195 (goto-char (point-min))
5196 (let (case-fold-search)
5197 (when (re-search-forward
5198 (format "^%s$" (regexp-quote mail-header-separator)) nil t)
5199 (replace-match "")))
5200 (let ((winconf gnus-prev-winconf))
5202 (buffer-substring-no-properties (point-min) (point-max))
5203 (set-buffer (get-buffer-create gnus-original-article-buffer))
5205 (setq gnus-current-headers (gnus-article-make-full-mail-header))
5206 (set-buffer gnus-article-buffer)
5207 (gnus-article-prepare-display)
5208 (set-window-configuration winconf))))
5211 ;;; Article highlights
5214 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5216 ;;; Internal Variables:
5218 (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\\)\\)"
5219 "Regular expression that matches URLs."
5220 :group 'gnus-article-buttons
5223 (defcustom gnus-button-alist
5224 `(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
5225 0 t gnus-button-handle-news 3)
5226 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
5227 gnus-button-handle-news 2)
5228 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
5230 gnus-button-fetch-group 4)
5231 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
5232 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
5233 t gnus-button-message-id 3)
5234 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
5235 ("mailto:\\([-a-zA-Z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
5236 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
5238 ("\\binfo:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t
5239 gnus-button-handle-info 2)
5240 ;; This is how URLs _should_ be embedded in text...
5241 ("<URL: *\\([^<>]*\\)>" 0 t gnus-button-embedded-url 1)
5243 (,gnus-button-url-regexp 0 t browse-url 0))
5244 "*Alist of regexps matching buttons in article bodies.
5246 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
5247 REGEXP: is the string matching text around the button,
5248 BUTTON: is the number of the regexp grouping actually matching the button,
5249 FORM: is a lisp expression which must eval to true for the button to
5251 CALLBACK: is the function to call when the user push this button, and each
5252 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
5254 CALLBACK can also be a variable, in that case the value of that
5255 variable it the real callback function."
5256 :group 'gnus-article-buttons
5257 :type '(repeat (list regexp
5258 (integer :tag "Button")
5260 (function :tag "Callback")
5263 (integer :tag "Regexp group")))))
5265 (defcustom gnus-header-button-alist
5266 `(("^\\(References\\|Message-I[Dd]\\):" "<[^<>]+>"
5267 0 t gnus-button-message-id 0)
5268 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
5269 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
5270 0 t gnus-button-mailto 0)
5271 ("^X-[Uu][Rr][Ll]:" ,gnus-button-url-regexp 0 t browse-url 0)
5272 ("^Subject:" ,gnus-button-url-regexp 0 t browse-url 0)
5273 ("^[^:]+:" ,gnus-button-url-regexp 0 t browse-url 0)
5274 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
5275 gnus-button-message-id 3))
5276 "*Alist of headers and regexps to match buttons in article heads.
5278 This alist is very similar to `gnus-button-alist', except that each
5279 alist has an additional HEADER element first in each entry:
5281 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
5283 HEADER is a regexp to match a header. For a fuller explanation, see
5284 `gnus-button-alist'."
5285 :group 'gnus-article-buttons
5286 :group 'gnus-article-headers
5287 :type '(repeat (list (regexp :tag "Header")
5289 (integer :tag "Button")
5291 (function :tag "Callback")
5294 (integer :tag "Regexp group")))))
5296 (defvar gnus-button-regexp nil)
5297 (defvar gnus-button-marker-list nil)
5298 ;; Regexp matching any of the regexps from `gnus-button-alist'.
5300 (defvar gnus-button-last nil)
5301 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
5305 (defun gnus-article-push-button (event)
5306 "Check text under the mouse pointer for a callback function.
5307 If the text under the mouse pointer has a `gnus-callback' property,
5308 call it with the value of the `gnus-data' text property."
5310 (set-buffer (window-buffer (posn-window (event-start event))))
5311 (let* ((pos (posn-point (event-start event)))
5312 (data (get-text-property pos 'gnus-data))
5313 (fun (get-text-property pos 'gnus-callback)))
5316 (funcall fun data))))
5318 (defun gnus-article-press-button ()
5319 "Check text at point for a callback function.
5320 If the text at point has a `gnus-callback' property,
5321 call it with the value of the `gnus-data' text property."
5323 (let* ((data (get-text-property (point) 'gnus-data))
5324 (fun (get-text-property (point) 'gnus-callback)))
5326 (funcall fun data))))
5328 (defun gnus-article-prev-button (n)
5329 "Move point to N buttons backward.
5330 If N is negative, move forward instead."
5332 (gnus-article-next-button (- n)))
5334 (defun gnus-article-next-button (n)
5335 "Move point to N buttons forward.
5336 If N is negative, move backward instead."
5338 (let ((function (if (< n 0) 'previous-single-property-change
5339 'next-single-property-change))
5340 (inhibit-point-motion-hooks t)
5342 (limit (if (< n 0) (point-min) (point-max))))
5344 (while (and (not (= limit (point)))
5346 ;; Skip past the current button.
5347 (when (get-text-property (point) 'gnus-callback)
5348 (goto-char (funcall function (point) 'gnus-callback nil limit)))
5349 ;; Go to the next (or previous) button.
5350 (gnus-goto-char (funcall function (point) 'gnus-callback nil limit))
5351 ;; Put point at the start of the button.
5352 (when (and backward (not (get-text-property (point) 'gnus-callback)))
5353 (goto-char (funcall function (point) 'gnus-callback nil limit)))
5354 ;; Skip past intangible buttons.
5355 (when (get-text-property (point) 'intangible)
5359 (gnus-message 5 "No more buttons"))
5362 (defun gnus-article-highlight (&optional force)
5363 "Highlight current article.
5364 This function calls `gnus-article-highlight-headers',
5365 `gnus-article-highlight-citation',
5366 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
5367 do the highlighting. See the documentation for those functions."
5368 (interactive (list 'force))
5369 (gnus-article-highlight-headers)
5370 (gnus-article-highlight-citation force)
5371 (gnus-article-highlight-signature)
5372 (gnus-article-add-buttons force)
5373 (gnus-article-add-buttons-to-head))
5375 (defun gnus-article-highlight-some (&optional force)
5376 "Highlight current article.
5377 This function calls `gnus-article-highlight-headers',
5378 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
5379 do the highlighting. See the documentation for those functions."
5380 (interactive (list 'force))
5381 (gnus-article-highlight-headers)
5382 (gnus-article-highlight-signature)
5383 (gnus-article-add-buttons))
5385 (defun gnus-article-highlight-headers ()
5386 "Highlight article headers as specified by `gnus-header-face-alist'."
5389 (set-buffer gnus-article-buffer)
5391 (let ((alist gnus-header-face-alist)
5392 (buffer-read-only nil)
5393 (case-fold-search t)
5394 (inhibit-point-motion-hooks t)
5395 entry regexp header-face field-face from hpoints fpoints)
5396 (article-narrow-to-head)
5397 (while (setq entry (pop alist))
5398 (goto-char (point-min))
5399 (setq regexp (concat "^\\("
5400 (if (string-equal "" (nth 0 entry))
5404 header-face (nth 1 entry)
5405 field-face (nth 2 entry))
5406 (while (and (re-search-forward regexp nil t)
5410 (unless (search-forward ":" nil t)
5412 (when (and header-face
5413 (not (memq (point) hpoints)))
5414 (push (point) hpoints)
5415 (gnus-put-text-property from (point) 'face header-face))
5416 (when (and field-face
5417 (not (memq (setq from (point)) fpoints)))
5419 (if (re-search-forward "^[^ \t]" nil t)
5421 (goto-char (point-max)))
5422 (gnus-put-text-property from (point) 'face field-face))))))))
5424 (defun gnus-article-highlight-signature ()
5425 "Highlight the signature in an article.
5426 It does this by highlighting everything after
5427 `gnus-signature-separator' using `gnus-signature-face'."
5429 (when gnus-signature-face
5431 (set-buffer gnus-article-buffer)
5432 (let ((buffer-read-only nil)
5433 (inhibit-point-motion-hooks t))
5435 (when (gnus-article-narrow-to-signature)
5436 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
5437 'face gnus-signature-face)))))))
5439 (defun gnus-article-buttonize-signature ()
5440 "Add button to the signature."
5443 (set-buffer gnus-article-buffer)
5444 (let ((buffer-read-only nil)
5445 (inhibit-point-motion-hooks t))
5446 (when (gnus-article-search-signature)
5447 (gnus-article-add-button (match-beginning 0) (match-end 0)
5448 'gnus-signature-toggle
5449 (set-marker (make-marker)
5450 (1+ (match-end 0))))))))
5452 (defun gnus-button-in-region-p (b e prop)
5453 "Say whether PROP exists in the region."
5454 (text-property-not-all b e prop nil))
5456 (defun gnus-article-add-buttons (&optional force)
5457 "Find external references in the article and make buttons of them.
5458 \"External references\" are things like Message-IDs and URLs, as
5459 specified by `gnus-button-alist'."
5460 (interactive (list 'force))
5462 (set-buffer gnus-article-buffer)
5463 (let ((buffer-read-only nil)
5464 (inhibit-point-motion-hooks t)
5465 (case-fold-search t)
5466 (alist gnus-button-alist)
5468 ;; Remove all old markers.
5469 (let (marker entry new-list)
5470 (while (setq marker (pop gnus-button-marker-list))
5471 (if (or (< marker (point-min)) (>= marker (point-max)))
5472 (push marker new-list)
5474 (when (setq entry (gnus-button-entry))
5475 (put-text-property (match-beginning (nth 1 entry))
5476 (match-end (nth 1 entry))
5477 'gnus-callback nil))
5478 (set-marker marker nil)))
5479 (setq gnus-button-marker-list new-list))
5480 ;; We skip the headers.
5483 (while (setq entry (pop alist))
5484 (setq regexp (car entry))
5486 (while (re-search-forward regexp nil t)
5487 (let* ((start (and entry (match-beginning (nth 1 entry))))
5488 (end (and entry (match-end (nth 1 entry))))
5489 (from (match-beginning 0)))
5490 (when (and (or (eq t (nth 2 entry))
5491 (eval (nth 2 entry)))
5492 (not (gnus-button-in-region-p
5493 start end 'gnus-callback)))
5494 ;; That optional form returned non-nil, so we add the
5496 (gnus-article-add-button
5497 start end 'gnus-button-push
5498 (car (push (set-marker (make-marker) from)
5499 gnus-button-marker-list))))))))))
5501 ;; Add buttons to the head of an article.
5502 (defun gnus-article-add-buttons-to-head ()
5503 "Add buttons to the head of the article."
5506 (set-buffer gnus-article-buffer)
5508 (let ((buffer-read-only nil)
5509 (inhibit-point-motion-hooks t)
5510 (case-fold-search t)
5511 (alist gnus-header-button-alist)
5513 (article-narrow-to-head)
5515 ;; Each alist entry.
5516 (setq entry (car alist)
5518 (goto-char (point-min))
5519 (while (re-search-forward (car entry) nil t)
5520 ;; Each header matching the entry.
5521 (setq beg (match-beginning 0))
5522 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
5523 (match-beginning 0))
5526 (while (re-search-forward (nth 1 entry) end t)
5527 ;; Each match within a header.
5528 (let* ((entry (cdr entry))
5529 (start (match-beginning (nth 1 entry)))
5530 (end (match-end (nth 1 entry)))
5531 (form (nth 2 entry)))
5532 (goto-char (match-end 0))
5534 (gnus-article-add-button
5535 start end (nth 3 entry)
5536 (buffer-substring (match-beginning (nth 4 entry))
5537 (match-end (nth 4 entry)))))))
5538 (goto-char end)))))))
5540 ;;; External functions:
5542 (defun gnus-article-add-button (from to fun &optional data)
5543 "Create a button between FROM and TO with callback FUN and data DATA."
5544 (when gnus-article-button-face
5545 (gnus-overlay-put (gnus-make-overlay from to)
5546 'face gnus-article-button-face))
5547 (gnus-add-text-properties
5549 (nconc (and gnus-article-mouse-face
5550 (list gnus-mouse-face-prop gnus-article-mouse-face))
5551 (list 'gnus-callback fun)
5552 (and data (list 'gnus-data data))))
5553 (widget-convert-button 'link from to :action 'gnus-widget-press-button
5554 ;; Quote `:button-keymap' for Mule 2.3
5555 ;; but it won't work.
5556 ':button-keymap gnus-widget-button-keymap))
5558 ;;; Internal functions:
5560 (defun gnus-article-set-globals ()
5562 (set-buffer gnus-summary-buffer)
5563 (gnus-set-global-variables)))
5565 (defun gnus-signature-toggle (end)
5567 (set-buffer gnus-article-buffer)
5568 (let ((buffer-read-only nil)
5569 (inhibit-point-motion-hooks t)
5570 (limit (next-single-property-change end 'mime-view-entity
5572 (if (text-property-any end limit 'article-type 'signature)
5573 (gnus-remove-text-properties-when
5574 'article-type 'signature end limit
5575 (cons 'article-type (cons 'signature
5576 gnus-hidden-properties)))
5577 (gnus-add-text-properties-when
5578 'article-type nil end limit
5579 (cons 'article-type (cons 'signature
5580 gnus-hidden-properties)))))))
5582 (defun gnus-button-entry ()
5583 ;; Return the first entry in `gnus-button-alist' matching this place.
5584 (let ((alist gnus-button-alist)
5587 (setq entry (pop alist))
5588 (if (looking-at (car entry))
5593 (defun gnus-button-push (marker)
5594 ;; Push button starting at MARKER.
5597 (let* ((entry (gnus-button-entry))
5598 (inhibit-point-motion-hooks t)
5600 (args (mapcar (lambda (group)
5601 (let ((string (match-string group)))
5602 (gnus-set-text-properties
5603 0 (length string) nil string)
5610 (fboundp (symbol-value fun)))
5611 (apply (symbol-value fun) args))
5613 (gnus-message 1 "You must define `%S' to use this button"
5614 (cons fun args)))))))
5616 (defun gnus-parse-news-url (url)
5617 (let (scheme server group message-id articles)
5620 (goto-char (point-min))
5621 (when (looking-at "\\([A-Za-z]+\\):")
5622 (setq scheme (match-string 1))
5623 (goto-char (match-end 0)))
5624 (when (looking-at "//\\([^/]+\\)/")
5625 (setq server (match-string 1))
5626 (goto-char (match-end 0)))
5629 ((looking-at "\\(.*@.*\\)")
5630 (setq message-id (match-string 1)))
5631 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
5632 (setq group (match-string 1)
5633 articles (split-string (match-string 2) "-")))
5634 ((looking-at "\\([^/]+\\)/?")
5635 (setq group (match-string 1)))
5637 (error "Unknown news URL syntax"))))
5638 (list scheme server group message-id articles)))
5640 (defun gnus-button-handle-news (url)
5642 (destructuring-bind (scheme server group message-id articles)
5643 (gnus-parse-news-url url)
5647 (set-buffer gnus-summary-buffer)
5649 (let ((gnus-refer-article-method (list (list 'nntp server))))
5650 (gnus-summary-refer-article message-id))
5651 (gnus-summary-refer-article message-id))))
5653 (gnus-button-fetch-group url)))))
5655 (defun gnus-button-handle-info (url)
5656 "Fetch an info URL."
5658 "^\\([^:/]+\\)?/\\(.*\\)"
5660 (gnus-info-find-node
5661 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
5664 (gnus-url-unhex-string (match-string 2 url))))
5665 (error "Can't parse %s" url)))
5667 (defun gnus-button-message-id (message-id)
5670 (set-buffer gnus-summary-buffer)
5671 (gnus-summary-refer-article message-id)))
5673 (defun gnus-button-fetch-group (address)
5674 "Fetch GROUP specified by ADDRESS."
5675 (if (not (string-match "[:/]" address))
5676 ;; This is just a simple group url.
5677 (gnus-group-read-ephemeral-group address gnus-select-method)
5680 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
5682 (error "Can't parse %s" address)
5683 (gnus-group-read-ephemeral-group
5684 (match-string 4 address)
5685 `(nntp ,(match-string 1 address)
5686 (nntp-address ,(match-string 1 address))
5687 (nntp-port-number ,(if (match-end 3)
5688 (match-string 3 address)
5691 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
5693 (defun gnus-url-parse-query-string (query &optional downcase)
5694 (let (retval pairs cur key val)
5695 (setq pairs (split-string query "&"))
5697 (setq cur (car pairs)
5699 (if (not (string-match "=" cur))
5701 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
5702 val (gnus-url-unhex-string (substring cur (match-end 0) nil)))
5704 (setq key (downcase key)))
5705 (setq cur (assoc key retval))
5707 (setcdr cur (cons val (cdr cur)))
5708 (setq retval (cons (list key val) retval)))))
5711 (defun gnus-url-unhex (x)
5718 (defun gnus-url-unhex-string (str &optional allow-newlines)
5719 "Remove %XXX embedded spaces, etc in a url.
5720 If optional second argument ALLOW-NEWLINES is non-nil, then allow the
5721 decoding of carriage returns and line feeds in the string, which is normally
5722 forbidden in URL encoding."
5723 (setq str (or (nnheader-replace-chars-in-string str ?+ ? ) ""))
5725 (case-fold-search t))
5726 (while (string-match "%[0-9a-f][0-9a-f]" str)
5727 (let* ((start (match-beginning 0))
5728 (ch1 (gnus-url-unhex (elt str (+ start 1))))
5730 (gnus-url-unhex (elt str (+ start 2))))))
5732 tmp (substring str 0 start)
5735 (char-to-string code))
5736 ((or (= code ?\n) (= code ?\r))
5738 (t (char-to-string code))))
5739 str (substring str (match-end 0)))))
5740 (setq tmp (concat tmp str))
5743 (defun gnus-url-mailto (url)
5744 ;; Send mail to someone
5745 (when (string-match "mailto:/*\\(.*\\)" url)
5746 (setq url (substring url (match-beginning 1) nil)))
5747 (let (to args subject func)
5748 (if (string-match (regexp-quote "?") url)
5749 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
5750 args (gnus-url-parse-query-string
5751 (substring url (match-end 0) nil) t))
5752 (setq to (gnus-url-unhex-string url)))
5753 (setq args (cons (list "to" to) args)
5754 subject (cdr-safe (assoc "subject" args)))
5757 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
5760 (message-position-on-field (caar args)))
5761 (insert (mapconcat 'identity (cdar args) ", "))
5762 (setq args (cdr args)))
5765 (message-goto-subject))))
5767 (defun gnus-button-embedded-url (address)
5768 "Activate ADDRESS with `browse-url'."
5769 (browse-url (gnus-strip-whitespace address)))
5772 ;; Silence the byte-compiler.
5773 (autoload 'smiley-toggle-buffer "gnus-bitmap"))
5774 (defun gnus-article-smiley-display ()
5775 "Display \"smileys\" as small graphical icons."
5776 (smiley-toggle-buffer 1 (current-buffer) (point-min) (point-max)))
5778 ;;; Next/prev buttons in the article buffer.
5780 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
5781 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
5783 (defvar gnus-prev-page-map nil)
5784 (unless gnus-prev-page-map
5785 (setq gnus-prev-page-map (make-sparse-keymap))
5786 (define-key gnus-prev-page-map gnus-mouse-2 'gnus-button-prev-page)
5787 (define-key gnus-prev-page-map "\r" 'gnus-button-prev-page))
5789 (static-if (featurep 'xemacs)
5790 (defun gnus-insert-prev-page-button ()
5791 (let ((buffer-read-only nil))
5793 gnus-prev-page-line-format nil
5794 `(gnus-prev t local-map ,gnus-prev-page-map
5795 gnus-callback gnus-article-button-prev-page
5796 article-type annotation))))
5797 (defun gnus-insert-prev-page-button ()
5798 (let ((buffer-read-only nil)
5799 (situation (get-text-property (point-min) 'mime-view-situation)))
5800 (set-keymap-parent gnus-prev-page-map (current-local-map))
5802 gnus-prev-page-line-format nil
5803 `(gnus-prev t local-map ,gnus-prev-page-map
5804 gnus-callback gnus-article-button-prev-page
5805 article-type annotation
5806 mime-view-situation ,situation))))
5809 (defvar gnus-next-page-map nil)
5810 (unless gnus-next-page-map
5811 (setq gnus-next-page-map (make-sparse-keymap))
5812 (define-key gnus-next-page-map gnus-mouse-2 'gnus-button-next-page)
5813 (define-key gnus-next-page-map "\r" 'gnus-button-next-page))
5815 (defun gnus-button-next-page ()
5816 "Go to the next page."
5818 (let ((win (selected-window)))
5819 (select-window (get-buffer-window gnus-article-buffer t))
5820 (gnus-article-next-page)
5821 (select-window win)))
5823 (defun gnus-button-prev-page ()
5824 "Go to the prev page."
5826 (let ((win (selected-window)))
5827 (select-window (get-buffer-window gnus-article-buffer t))
5828 (gnus-article-prev-page)
5829 (select-window win)))
5831 (static-if (featurep 'xemacs)
5832 (defun gnus-insert-next-page-button ()
5833 (let ((buffer-read-only nil))
5834 (gnus-eval-format gnus-next-page-line-format nil
5836 t local-map ,gnus-next-page-map
5837 gnus-callback gnus-article-button-next-page
5838 article-type annotation))))
5839 (defun gnus-insert-next-page-button ()
5840 (let ((buffer-read-only nil)
5841 (situation (get-text-property (point-min) 'mime-view-situation)))
5842 (set-keymap-parent gnus-next-page-map (current-local-map))
5843 (gnus-eval-format gnus-next-page-line-format nil
5845 t local-map ,gnus-next-page-map
5846 gnus-callback gnus-article-button-next-page
5847 article-type annotation
5848 mime-view-situation ,situation))))
5851 (defun gnus-article-button-next-page (arg)
5852 "Go to the next page."
5854 (let ((win (selected-window)))
5855 (select-window (get-buffer-window gnus-article-buffer t))
5856 (gnus-article-next-page)
5857 (select-window win)))
5859 (defun gnus-article-button-prev-page (arg)
5860 "Go to the prev page."
5862 (let ((win (selected-window)))
5863 (select-window (get-buffer-window gnus-article-buffer t))
5864 (gnus-article-prev-page)
5865 (select-window win)))
5867 (defvar gnus-decode-header-methods
5868 '(mail-decode-encoded-word-region)
5869 "List of methods used to decode headers.
5871 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
5872 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
5873 (REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
5874 whose names match REGEXP.
5877 ((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
5878 mail-decode-encoded-word-region
5879 (\"chinese\" . rfc1843-decode-region))
5882 (defvar gnus-decode-header-methods-cache nil)
5884 (defun gnus-multi-decode-header (start end)
5885 "Apply the functions from `gnus-encoded-word-methods' that match."
5886 (unless (and gnus-decode-header-methods-cache
5887 (eq gnus-newsgroup-name
5888 (car gnus-decode-header-methods-cache)))
5889 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
5892 (nconc gnus-decode-header-methods-cache (list x))
5893 (if (and gnus-newsgroup-name
5894 (string-match (car x) gnus-newsgroup-name))
5895 (nconc gnus-decode-header-methods-cache
5897 gnus-decode-header-methods))
5898 (let ((xlist gnus-decode-header-methods-cache))
5901 (narrow-to-region start end)
5903 (funcall (pop xlist) (point-min) (point-max))))))
5906 ;;; Treatment top-level handling.
5909 (defun gnus-treat-article (condition &optional part-number total-parts type)
5910 (let ((length (- (point-max) (point-min)))
5911 (alist gnus-treatment-function-alist)
5912 (article-goto-body-goes-to-point-min-p t)
5916 (let ((list gnus-article-treat-types))
5918 (when (string-match (pop list) type)
5919 (throw 'found t)))))))
5920 (highlightp (gnus-visual-p 'article-highlight 'highlight))
5921 (entity (static-unless (featurep 'xemacs)
5922 (when (eq 'head condition)
5923 (get-text-property (point-min) 'mime-view-entity))))
5924 val elem buttonized)
5925 (gnus-run-hooks 'gnus-part-display-hook)
5926 (unless gnus-inhibit-treatment
5927 (while (setq elem (pop alist))
5930 (if (gnus-buffer-live-p gnus-summary-buffer)
5931 (set-buffer gnus-summary-buffer))
5932 (symbol-value (car elem))))
5933 (when (and (or (consp val)
5935 (gnus-treat-predicate val)
5936 (or (not (get (car elem) 'highlight))
5938 (when (and (not buttonized)
5940 '(gnus-treat-hide-signature
5941 gnus-treat-highlight-signature)))
5942 (gnus-article-buttonize-signature)
5943 (setq buttonized t))
5945 (funcall (cadr elem)))))
5946 ;; FSF Emacsen does not inherit the existing text properties
5947 ;; in the new text, so we should do it for `mime-view-entity'.
5948 (static-unless (featurep 'xemacs)
5950 (put-text-property (point-min) (point-max)
5951 'mime-view-entity entity))))))
5953 ;; Dynamic variables.
5955 (defvar part-number)
5956 (defvar total-parts)
5961 (defun gnus-treat-predicate (val)
5966 (stringp (car val)))
5967 (apply 'gnus-or (mapcar `(lambda (s)
5968 (string-match s ,(or gnus-newsgroup-name "")))
5971 (let ((pred (pop val)))
5974 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
5976 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
5978 (not (gnus-treat-predicate (car val))))
5980 (equal (car val) type))
5982 (error "%S is not a valid predicate" pred)))))
5992 (eq part-number total-parts))
5996 (error "%S is not a valid value" val))))
5998 (defun gnus-article-encrypt-body (protocol &optional n)
5999 "Encrypt the article body."
6002 (or gnus-article-encrypt-protocol
6003 (completing-read "Encrypt protocol: "
6004 gnus-article-encrypt-protocol-alist
6006 current-prefix-arg))
6007 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
6009 (error (format "Can't find the encrypt protocol %s" protocol)))
6010 (if (equal gnus-newsgroup-name "nndraft:drafts")
6011 (error "Can't encrypt the article in group nndraft:drafts"))
6012 (if (equal gnus-newsgroup-name "nndraft:queue")
6013 (error "Don't encrypt the article in group nndraft:queue"))
6014 (gnus-summary-iterate n
6016 (set-buffer gnus-summary-buffer)
6017 (let ((mail-parse-charset gnus-newsgroup-charset)
6018 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6019 (summary-buffer gnus-summary-buffer)
6021 (gnus-set-global-variables)
6022 (when (gnus-group-read-only-p)
6023 (error "The current newsgroup does not support article encrypt"))
6024 (gnus-summary-show-article t)
6026 (or (mail-header-references gnus-current-headers) ""))
6027 (set-buffer gnus-article-buffer)
6028 (let* ((buffer-read-only nil)
6030 (mapcar (lambda (field)
6031 (and (save-restriction
6032 (message-narrow-to-head)
6033 (goto-char (point-min))
6034 (search-forward field nil t))
6036 (message-narrow-to-field)
6037 (buffer-substring (point-min) (point-max))
6038 (delete-region (point-min) (point-max))
6040 '("Content-Type:" "Content-Transfer-Encoding:"
6041 "Content-Disposition:"))))
6042 (message-narrow-to-head)
6043 (message-remove-header "MIME-Version")
6044 (goto-char (point-max))
6045 (setq point (point))
6046 (insert (apply 'concat headers))
6048 (narrow-to-region point (point-max))
6049 (let ((message-options message-options))
6050 (message-options-set 'message-sender user-mail-address)
6051 (message-options-set 'message-recipients user-mail-address)
6052 (message-options-set 'message-sign-encrypt 'not)
6054 (goto-char (point-min))
6055 (insert "MIME-Version: 1.0\n")
6057 (gnus-summary-edit-article-done
6058 references nil summary-buffer t))
6059 (when gnus-keep-backlog
6060 (gnus-backlog-remove-article
6061 (car gnus-article-current) (cdr gnus-article-current)))
6063 (when (get-buffer gnus-original-article-buffer)
6064 (set-buffer gnus-original-article-buffer)
6065 (setq gnus-original-article nil)))
6066 (when gnus-use-cache
6067 (gnus-cache-update-article
6068 (car gnus-article-current) (cdr gnus-article-current))))))))
6070 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
6071 "The following specs can be used:
6072 %t The security MIME type
6075 %D Details if button is pressed")
6077 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
6078 "The following specs can be used:
6079 %t The security MIME type
6082 %D Details if button is pressed")
6084 (defvar gnus-mime-security-button-line-format-alist
6085 '((?t gnus-tmp-type ?s)
6086 (?i gnus-tmp-info ?s)
6087 (?d gnus-tmp-details ?s)
6088 (?D gnus-tmp-pressed-details ?s)))
6090 (defvar gnus-mime-security-button-map
6091 (let ((map (make-sparse-keymap)))
6092 (unless (>= (string-to-number emacs-version) 21)
6093 (set-keymap-parent map gnus-article-mode-map))
6094 (define-key map gnus-mouse-2 'gnus-article-push-button)
6095 (define-key map "\r" 'gnus-article-press-button)
6098 (defvar gnus-mime-security-details-buffer nil)
6100 (defvar gnus-mime-security-button-pressed nil)
6102 (defvar gnus-mime-security-show-details-inline t
6103 "If non-nil, show details in the article buffer.")
6105 (defun gnus-mime-security-verify-or-decrypt (handle)
6106 (mm-remove-parts (cdr handle))
6107 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
6108 point buffer-read-only)
6110 (goto-char (car region)))
6112 (narrow-to-region (point) (point))
6113 (with-current-buffer (mm-handle-multipart-original-buffer handle)
6114 (let* ((mm-verify-option 'known)
6115 (mm-decrypt-option 'known)
6116 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
6117 (unless (eq nparts (cdr handle))
6118 (mm-destroy-parts (cdr handle))
6119 (setcdr handle nparts))))
6120 (setq point (point))
6121 (gnus-mime-display-security handle)
6122 (goto-char (point-max)))
6124 (delete-region (point) (cdr region))
6125 (set-marker (car region) nil)
6126 (set-marker (cdr region) nil))
6129 (defun gnus-mime-security-show-details (handle)
6130 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
6132 (if gnus-mime-security-show-details-inline
6133 (let ((gnus-mime-security-button-pressed t)
6134 (gnus-mime-security-button-line-format
6135 (get-text-property (point) 'gnus-line-format))
6138 (while (eq (get-text-property (point) 'gnus-line-format)
6139 gnus-mime-security-button-line-format)
6143 (narrow-to-region (point) (point))
6144 (gnus-insert-mime-security-button handle))
6145 (delete-region (point)
6146 (or (text-property-not-all
6149 gnus-mime-security-button-line-format)
6151 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
6152 (with-current-buffer gnus-mime-security-details-buffer
6155 (setq gnus-mime-security-details-buffer
6156 (gnus-get-buffer-create "*MIME Security Details*")))
6157 (with-current-buffer gnus-mime-security-details-buffer
6159 (goto-char (point-min)))
6160 (pop-to-buffer gnus-mime-security-details-buffer))
6161 (gnus-message 5 "No details."))))
6163 (defun gnus-mime-security-press-button (handle)
6164 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6165 (gnus-mime-security-show-details handle)
6166 (gnus-mime-security-verify-or-decrypt handle)))
6168 (defun gnus-insert-mime-security-button (handle &optional displayed)
6169 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
6172 (or (nth 2 (assoc protocol mm-verify-function-alist))
6173 (nth 2 (assoc protocol mm-decrypt-function-alist))
6175 (if (equal (car handle) "multipart/signed")
6176 " Signed" " Encrypted")
6179 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6182 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
6183 gnus-tmp-pressed-details
6185 (setq gnus-tmp-details
6186 (if gnus-tmp-details
6187 (concat "\n" gnus-tmp-details) ""))
6188 (setq gnus-tmp-pressed-details
6189 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
6194 gnus-mime-security-button-line-format
6195 gnus-mime-security-button-line-format-alist
6196 `(keymap ,gnus-mime-security-button-map
6197 ,@(if (>= (string-to-number emacs-version) 21)
6198 nil ;; XEmacs doesn't care
6199 (list 'local-map gnus-mime-security-button-map))
6200 gnus-callback gnus-mime-security-press-button
6201 gnus-line-format ,gnus-mime-security-button-line-format
6202 article-type annotation
6205 (widget-convert-button
6208 :action 'gnus-widget-press-button
6209 :button-keymap gnus-mime-security-button-map
6211 (lambda (widget/window &optional overlay pos)
6212 ;; Needed to properly clear the message due to a bug in
6213 ;; wid-edit (XEmacs only).
6214 (if (boundp 'help-echo-owns-message)
6215 (setq help-echo-owns-message t))
6218 (aref gnus-mouse-2 0))))))
6220 (defun gnus-mime-display-security (handle)
6222 (narrow-to-region (point) (point))
6223 (unless (gnus-unbuttonized-mime-type-p (car handle))
6224 (gnus-insert-mime-security-button handle))
6225 (gnus-mime-display-mixed (cdr handle))
6228 (unless (gnus-unbuttonized-mime-type-p (car handle))
6229 (let ((gnus-mime-security-button-line-format
6230 gnus-mime-security-button-end-line-format))
6231 (gnus-insert-mime-security-button handle)))
6232 (mm-set-handle-multipart-parameter
6234 (cons (set-marker (make-marker) (point-min))
6235 (set-marker (make-marker) (point-max))))))
6241 (defun gnus-article-header-presentation-method (entity situation)
6242 (mime-insert-header entity)
6245 (set-alist 'mime-header-presentation-method-alist
6246 'gnus-original-article-mode
6247 #'gnus-article-header-presentation-method)
6249 (defun gnus-mime-preview-quitting-method ()
6250 (mime-preview-kill-buffer)
6251 (delete-other-windows)
6252 (gnus-article-show-summary)
6253 (gnus-summary-select-article gnus-show-all-headers t))
6255 (set-alist 'mime-preview-quitting-method-alist
6256 'gnus-original-article-mode #'gnus-mime-preview-quitting-method)
6258 (set-alist 'mime-preview-following-method-alist
6259 'gnus-original-article-mode #'gnus-following-method)
6261 (set-alist 'mime-preview-over-to-previous-method-alist
6262 'gnus-original-article-mode
6264 (if (> (point-min) 1)
6265 (gnus-article-prev-page)
6266 (gnus-article-read-summary-keys
6267 nil (gnus-character-to-event ?P)))))
6269 (set-alist 'mime-preview-over-to-next-method-alist
6270 'gnus-original-article-mode'
6272 (if (< (point-max) (buffer-size))
6273 (gnus-article-next-page)
6274 (gnus-article-read-summary-keys
6275 nil (gnus-character-to-event ?N)))))
6285 (run-hooks 'gnus-art-load-hook)
6287 ;;; gnus-art.el ends here