1 ;;; gnus-art.el --- article mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval-when-compile (require 'cl))
43 (autoload 'gnus-msg-mail "gnus-msg" nil t)
44 (autoload 'gnus-button-mailto "gnus-msg")
45 (autoload 'gnus-button-reply "gnus-msg" nil t)
47 (defgroup gnus-article nil
49 :link '(custom-manual "(gnus)The Article Buffer")
52 (defgroup gnus-article-treat nil
53 "Treating article parts."
54 :link '(custom-manual "(gnus)Article Hiding")
57 (defgroup gnus-article-hiding nil
58 "Hiding article parts."
59 :link '(custom-manual "(gnus)Article Hiding")
62 (defgroup gnus-article-highlight nil
63 "Article highlighting."
64 :link '(custom-manual "(gnus)Article Highlighting")
68 (defgroup gnus-article-signature nil
70 :link '(custom-manual "(gnus)Article Signature")
73 (defgroup gnus-article-headers nil
75 :link '(custom-manual "(gnus)Hiding Headers")
78 (defgroup gnus-article-washing nil
79 "Special commands on articles."
80 :link '(custom-manual "(gnus)Article Washing")
83 (defgroup gnus-article-emphasis nil
84 "Fontisizing articles."
85 :link '(custom-manual "(gnus)Article Fontisizing")
88 (defgroup gnus-article-saving nil
90 :link '(custom-manual "(gnus)Saving Articles")
93 (defgroup gnus-article-mime nil
94 "Worshiping the MIME wonder."
95 :link '(custom-manual "(gnus)Using MIME")
98 (defgroup gnus-article-buttons nil
99 "Pushable buttons in the article buffer."
100 :link '(custom-manual "(gnus)Article Buttons")
101 :group 'gnus-article)
103 (defgroup gnus-article-various nil
104 "Other article options."
105 :link '(custom-manual "(gnus)Misc Article")
106 :group 'gnus-article)
108 (defcustom gnus-ignored-headers
109 '("^Path:" "^Expires:" "^Date-Received:" "^References:" "^Xref:" "^Lines:"
110 "^Relay-Version:" "^Message-ID:" "^Approved:" "^Sender:" "^Received:"
111 "^X-UIDL:" "^MIME-Version:" "^Return-Path:" "^In-Reply-To:"
112 "^Content-Type:" "^Content-Transfer-Encoding:" "^X-WebTV-Signature:"
113 "^X-MimeOLE:" "^X-MSMail-Priority:" "^X-Priority:" "^X-Loop:"
114 "^X-Authentication-Warning:" "^X-MIME-Autoconverted:" "^X-Face:"
115 "^X-Attribution:" "^X-Originating-IP:" "^Delivered-To:"
116 "^NNTP-[-A-Za-z]+:" "^Distribution:" "^X-no-archive:" "^X-Trace:"
117 "^X-Complaints-To:" "^X-NNTP-Posting-Host:" "^X-Orig.*:"
118 "^Abuse-Reports-To:" "^Cache-Post-Path:" "^X-Article-Creation-Date:"
119 "^X-Poster:" "^X-Mail2News-Path:" "^X-Server-Date:" "^X-Cache:"
120 "^Originator:" "^X-Problems-To:" "^X-Auth-User:" "^X-Post-Time:"
121 "^X-Admin:" "^X-UID:" "^Resent-[-A-Za-z]+:" "^X-Mailing-List:"
122 "^Precedence:" "^Original-[-A-Za-z]+:" "^X-filename:" "^X-Orcpt:"
123 "^Old-Received:" "^X-Pgp" "^X-Auth:" "^X-From-Line:"
124 "^X-Gnus-Article-Number:" "^X-Majordomo:" "^X-Url:" "^X-Sender:"
125 "^MBOX-Line" "^Priority:" "^X400-[-A-Za-z]+:"
126 "^Status:" "^X-Gnus-Mail-Source:" "^Cancel-Lock:"
127 "^X-FTN" "^X-EXP32-SerialNo:" "^Encoding:" "^Importance:"
128 "^Autoforwarded:" "^Original-Encoded-Information-Types:" "^X-Ya-Pop3:"
129 "^X-Face-Version:" "^X-Vms-To:" "^X-ML-NAME:" "^X-ML-COUNT:"
130 "^Mailing-List:" "^X-finfo:" "^X-md5sum:" "^X-md5sum-Origin:"
131 "^X-Sun-Charset:" "^X-Accept-Language:" "^X-Envelope-Sender:"
132 "^List-[A-Za-z]+:" "^X-Listprocessor-Version:"
133 "^X-Received:" "^X-Distribute:" "^X-Sequence:" "^X-Juno-Line-Breaks:"
134 "^X-Notes-Item:" "^X-MS-TNEF-Correlator:" "^x-uunet-gateway:"
135 "^X-Received:" "^Content-length:" "X-precedence:"
136 "^X-Authenticated-User:" "^X-Comment" "^X-Report:" "^X-Abuse-Info:"
137 "^X-HTTP-Proxy:" "^X-Mydeja-Info:" "^X-Copyright" "^X-No-Markup:"
138 "^X-Abuse-Info:" "^X-From_:" "^X-Accept-Language:" "^Errors-To:"
139 "^X-BeenThere:" "^X-Mailman-Version:" "^List-Help:" "^List-Post:"
140 "^List-Subscribe:" "^List-Id:" "^List-Unsubscribe:" "^List-Archive:"
141 "^X-Content-length:" "^X-Posting-Agent:" "^Original-Received:")
142 "*All headers that start with this regexp will be hidden.
143 This variable can also be a list of regexps of headers to be ignored.
144 If `gnus-visible-headers' is non-nil, this variable will be ignored."
145 :type '(choice :custom-show nil
148 :group 'gnus-article-hiding)
150 (defcustom gnus-visible-headers
151 "^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:"
152 "*All headers that do not match this regexp will be hidden.
153 This variable can also be a list of regexp of headers to remain visible.
154 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
155 :type '(repeat :value-to-internal (lambda (widget value)
156 (custom-split-regexp-maybe value))
157 :match (lambda (widget value)
159 (widget-editable-list-match widget value)))
161 :group 'gnus-article-hiding)
163 (defcustom gnus-sorted-header-list
164 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
165 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
166 "*This variable is a list of regular expressions.
167 If it is non-nil, headers that match the regular expressions will
168 be placed first in the article buffer in the sequence specified by
170 :type '(repeat regexp)
171 :group 'gnus-article-hiding)
173 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
174 "Headers that are only to be displayed if they have interesting data.
175 Possible values in this list are:
177 'empty Headers with no content.
178 'newsgroups Newsgroup identical to Gnus group.
179 'to-address To identical to To-address.
180 'followup-to Followup-to identical to Newsgroups.
181 'reply-to Reply-to identical to From.
182 'date Date less than four days old.
183 'long-to To and/or Cc longer than 1024 characters.
184 'many-to Multiple To and/or Cc."
185 :type '(set (const :tag "Headers with no content." empty)
186 (const :tag "Newsgroups identical to Gnus group." newsgroups)
187 (const :tag "To identical to To-address." to-address)
188 (const :tag "Followup-to identical to Newsgroups." followup-to)
189 (const :tag "Reply-to identical to From." reply-to)
190 (const :tag "Date less than four days old." date)
191 (const :tag "To and/or Cc longer than 1024 characters." long-to)
192 (const :tag "Multiple To and/or Cc headers." many-to))
193 :group 'gnus-article-hiding)
195 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
196 "Regexp matching signature separator.
197 This can also be a list of regexps. In that case, it will be checked
198 from head to tail looking for a separator. Searches will be done from
199 the end of the buffer."
200 :type '(repeat string)
201 :group 'gnus-article-signature)
203 (defcustom gnus-signature-limit nil
204 "Provide a limit to what is considered a signature.
205 If it is a number, no signature may not be longer (in characters) than
206 that number. If it is a floating point number, no signature may be
207 longer (in lines) than that number. If it is a function, the function
208 will be called without any parameters, and if it returns nil, there is
209 no signature in the buffer. If it is a string, it will be used as a
210 regexp. If it matches, the text in question is not a signature."
211 :type '(choice (integer :value 200)
213 (function :value fun)
214 (regexp :value ".*"))
215 :group 'gnus-article-signature)
217 (defcustom gnus-hidden-properties '(invisible t intangible t)
218 "Property list to use for hiding text."
220 :group 'gnus-article-hiding)
222 ;; Fixme: This isn't the right thing for mixed graphical and and
223 ;; non-graphical frames in a session.
224 (defcustom gnus-article-x-face-command
225 (if (featurep 'xemacs)
226 (if (or (featurep 'xface)
228 'gnus-xmas-article-display-xface
229 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
230 (if (and (fboundp 'image-type-available-p)
231 (image-type-available-p 'xbm))
232 'gnus-article-display-xface
233 (if gnus-article-compface-xbm
234 "{ echo '/* Width=48, Height=48 */'; uncompface; } | display -"
235 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
237 "*String or function to be executed to display an X-Face header.
238 If it is a string, the command will be executed in a sub-shell
239 asynchronously. The compressed face will be piped to this command."
240 :type `(choice string
242 ,(if (featurep 'xemacs)
243 'gnus-xmas-article-display-xface
244 'gnus-article-display-xface))
247 :group 'gnus-article-washing)
249 (defcustom gnus-article-x-face-too-ugly nil
250 "Regexp matching posters whose face shouldn't be shown automatically."
251 :type '(choice regexp (const nil))
252 :group 'gnus-article-washing)
254 (defcustom gnus-article-banner-alist nil
255 "Banner alist for stripping.
257 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
259 :type '(repeat (cons symbol regexp))
260 :group 'gnus-article-washing)
262 (gnus-define-group-parameter
265 "Alist of regexps (to match group names) and banner."
266 :variable-group gnus-article-washing
268 '(choice :tag "Banner"
270 (const :tag "Remove signature" signature)
271 (symbol :tag "Item in `gnus-article-banner-alist'" none)
273 (const :tag "None" nil))
275 "If non-nil, specify how to remove `banners' from articles.
277 Symbol `signature' means to remove signatures delimited by
278 `gnus-signature-separator'. Any other symbol is used to look up a
279 regular expression to match the banner in `gnus-article-banner-alist'.
280 A string is used as a regular expression to match the banner
283 (defcustom gnus-emphasis-alist
285 "\\(\\s-\\|^\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\s-\\|[-,;:\"]\\s-\\|[?!.]+\\s-\\|\\s)\\)")
287 '(("_" "_" underline)
290 ("_/" "/_" underline-italic)
291 ("_\\*" "\\*_" underline-bold)
292 ("\\*/" "/\\*" bold-italic)
293 ("_\\*/" "/\\*_" underline-bold-italic))))
294 `(("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
295 2 3 gnus-emphasis-underline)
299 (format format (car spec) (cadr spec))
300 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
302 "*Alist that says how to fontify certain phrases.
303 Each item looks like this:
305 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
307 The first element is a regular expression to be matched. The second
308 is a number that says what regular expression grouping used to find
309 the entire emphasized word. The third is a number that says what
310 regexp grouping should be displayed and highlighted. The fourth
311 is the face used for highlighting."
312 :type '(repeat (list :value ("" 0 0 default)
314 (integer :tag "Match group")
315 (integer :tag "Emphasize group")
317 :group 'gnus-article-emphasis)
319 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
320 "A regexp to describe whitespace which should not be emphasized.
321 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
322 The former avoids underlining of leading and trailing whitespace,
323 and the latter avoids underlining any whitespace at all."
325 :group 'gnus-article-emphasis
328 (defface gnus-emphasis-bold '((t (:bold t)))
329 "Face used for displaying strong emphasized text (*word*)."
330 :group 'gnus-article-emphasis)
332 (defface gnus-emphasis-italic '((t (:italic t)))
333 "Face used for displaying italic emphasized text (/word/)."
334 :group 'gnus-article-emphasis)
336 (defface gnus-emphasis-underline '((t (:underline t)))
337 "Face used for displaying underlined emphasized text (_word_)."
338 :group 'gnus-article-emphasis)
340 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
341 "Face used for displaying underlined bold emphasized text (_*word*_)."
342 :group 'gnus-article-emphasis)
344 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
345 "Face used for displaying underlined italic emphasized text (_/word/_)."
346 :group 'gnus-article-emphasis)
348 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
349 "Face used for displaying bold italic emphasized text (/*word*/)."
350 :group 'gnus-article-emphasis)
352 (defface gnus-emphasis-underline-bold-italic
353 '((t (:bold t :italic t :underline t)))
354 "Face used for displaying underlined bold italic emphasized text.
355 Esample: (_/*word*/_)."
356 :group 'gnus-article-emphasis)
358 (defface gnus-emphasis-highlight-words
359 '((t (:background "black" :foreground "yellow")))
360 "Face used for displaying highlighted words."
361 :group 'gnus-article-emphasis)
363 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
364 "Format for display of Date headers in article bodies.
365 See `format-time-string' for the possible values.
367 The variable can also be function, which should return a complete Date
368 header. The function is called with one argument, the time, which can
369 be fed to `format-time-string'."
370 :type '(choice string symbol)
371 :link '(custom-manual "(gnus)Article Date")
372 :group 'gnus-article-washing)
375 (autoload 'mail-extract-address-components "mail-extr"))
377 (defcustom gnus-save-all-headers t
378 "*If non-nil, don't remove any headers before saving."
379 :group 'gnus-article-saving
382 (defcustom gnus-prompt-before-saving 'always
383 "*This variable says how much prompting is to be done when saving articles.
384 If it is nil, no prompting will be done, and the articles will be
385 saved to the default files. If this variable is `always', each and
386 every article that is saved will be preceded by a prompt, even when
387 saving large batches of articles. If this variable is neither nil not
388 `always', there the user will be prompted once for a file name for
389 each invocation of the saving commands."
390 :group 'gnus-article-saving
391 :type '(choice (item always)
392 (item :tag "never" nil)
393 (sexp :tag "once" :format "%t\n" :value t)))
395 (defcustom gnus-saved-headers gnus-visible-headers
396 "Headers to keep if `gnus-save-all-headers' is nil.
397 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
398 If that variable is nil, however, all headers that match this regexp
399 will be kept while the rest will be deleted before saving."
400 :group 'gnus-article-saving
403 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
404 "A function to save articles in your favourite format.
405 The function must be interactively callable (in other words, it must
406 be an Emacs command).
408 Gnus provides the following functions:
410 * gnus-summary-save-in-rmail (Rmail format)
411 * gnus-summary-save-in-mail (Unix mail format)
412 * gnus-summary-save-in-folder (MH folder)
413 * gnus-summary-save-in-file (article format)
414 * gnus-summary-save-body-in-file (article body)
415 * gnus-summary-save-in-vm (use VM's folder format)
416 * gnus-summary-write-to-file (article format -- overwrite)."
417 :group 'gnus-article-saving
418 :type '(radio (function-item gnus-summary-save-in-rmail)
419 (function-item gnus-summary-save-in-mail)
420 (function-item gnus-summary-save-in-folder)
421 (function-item gnus-summary-save-in-file)
422 (function-item gnus-summary-save-body-in-file)
423 (function-item gnus-summary-save-in-vm)
424 (function-item gnus-summary-write-to-file)))
426 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
427 "A function generating a file name to save articles in Rmail format.
428 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
429 :group 'gnus-article-saving
432 (defcustom gnus-mail-save-name 'gnus-plain-save-name
433 "A function generating a file name to save articles in Unix mail format.
434 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
435 :group 'gnus-article-saving
438 (defcustom gnus-folder-save-name 'gnus-folder-save-name
439 "A function generating a file name to save articles in MH folder.
440 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
441 :group 'gnus-article-saving
444 (defcustom gnus-file-save-name 'gnus-numeric-save-name
445 "A function generating a file name to save articles in article format.
446 The function is called with NEWSGROUP, HEADERS, and optional
448 :group 'gnus-article-saving
451 (defcustom gnus-split-methods
452 '((gnus-article-archive-name)
453 (gnus-article-nndoc-name))
454 "*Variable used to suggest where articles are to be saved.
455 For instance, if you would like to save articles related to Gnus in
456 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
457 you could set this variable to something like:
459 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
460 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
462 This variable is an alist where the where the key is the match and the
463 value is a list of possible files to save in if the match is non-nil.
465 If the match is a string, it is used as a regexp match on the
466 article. If the match is a symbol, that symbol will be funcalled
467 from the buffer of the article to be saved with the newsgroup as the
468 parameter. If it is a list, it will be evaled in the same buffer.
470 If this form or function returns a string, this string will be used as
471 a possible file name; and if it returns a non-nil list, that list will
472 be used as possible file names."
473 :group 'gnus-article-saving
474 :type '(repeat (choice (list :value (fun) function)
475 (cons :value ("" "") regexp (repeat string))
478 (defcustom gnus-page-delimiter "^\^L"
479 "*Regexp describing what to use as article page delimiters.
480 The default value is \"^\^L\", which is a form linefeed at the
481 beginning of a line."
483 :group 'gnus-article-various)
485 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
486 "*The format specification for the article mode line.
487 See `gnus-summary-mode-line-format' for a closer description.
489 The following additional specs are available:
491 %w The article washing status.
492 %m The number of MIME parts in the article."
494 :group 'gnus-article-various)
496 (defcustom gnus-article-mode-hook nil
497 "*A hook for Gnus article mode."
499 :group 'gnus-article-various)
501 (when (featurep 'xemacs)
502 ;; Extracted from gnus-xmas-define in order to preserve user settings
503 (when (fboundp 'turn-off-scroll-in-place)
504 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
505 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
506 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
508 (defcustom gnus-article-menu-hook nil
509 "*Hook run after the creation of the article mode menu."
511 :group 'gnus-article-various)
513 (defcustom gnus-article-prepare-hook nil
514 "*A hook called after an article has been prepared in the article buffer."
516 :group 'gnus-article-various)
518 (defcustom gnus-article-hide-pgp-hook nil
519 "*A hook called after successfully hiding a PGP signature."
521 :group 'gnus-article-various)
523 (defcustom gnus-article-button-face 'bold
524 "Face used for highlighting buttons in the article buffer.
526 An article button is a piece of text that you can activate by pressing
527 `RET' or `mouse-2' above it."
529 :group 'gnus-article-buttons)
531 (defcustom gnus-article-mouse-face 'highlight
532 "Face used for mouse highlighting in the article buffer.
534 Article buttons will be displayed in this face when the cursor is
537 :group 'gnus-article-buttons)
539 (defcustom gnus-signature-face 'gnus-signature-face
540 "Face used for highlighting a signature in the article buffer.
541 Obsolete; use the face `gnus-signature-face' for customizations instead."
543 :group 'gnus-article-highlight
544 :group 'gnus-article-signature)
546 (defface gnus-signature-face
549 "Face used for highlighting a signature in the article buffer."
550 :group 'gnus-article-highlight
551 :group 'gnus-article-signature)
553 (defface gnus-header-from-face
556 (:foreground "spring green"))
559 (:foreground "red3"))
562 "Face used for displaying from headers."
563 :group 'gnus-article-headers
564 :group 'gnus-article-highlight)
566 (defface gnus-header-subject-face
569 (:foreground "SeaGreen3"))
572 (:foreground "red4"))
574 (:bold t :italic t)))
575 "Face used for displaying subject headers."
576 :group 'gnus-article-headers
577 :group 'gnus-article-highlight)
579 (defface gnus-header-newsgroups-face
582 (:foreground "yellow" :italic t))
585 (:foreground "MidnightBlue" :italic t))
588 "Face used for displaying newsgroups headers."
589 :group 'gnus-article-headers
590 :group 'gnus-article-highlight)
592 (defface gnus-header-name-face
595 (:foreground "SeaGreen"))
598 (:foreground "maroon"))
601 "Face used for displaying header names."
602 :group 'gnus-article-headers
603 :group 'gnus-article-highlight)
605 (defface gnus-header-content-face
608 (:foreground "forest green" :italic t))
611 (:foreground "indianred4" :italic t))
613 (:italic t))) "Face used for displaying header content."
614 :group 'gnus-article-headers
615 :group 'gnus-article-highlight)
617 (defcustom gnus-header-face-alist
618 '(("From" nil gnus-header-from-face)
619 ("Subject" nil gnus-header-subject-face)
620 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
621 ("" gnus-header-name-face gnus-header-content-face))
622 "*Controls highlighting of article header.
624 An alist of the form (HEADER NAME CONTENT).
626 HEADER is a regular expression which should match the name of an
627 header header and NAME and CONTENT are either face names or nil.
629 The name of each header field will be displayed using the face
630 specified by the first element in the list where HEADER match the
631 header name and NAME is non-nil. Similarly, the content will be
632 displayed by the first non-nil matching CONTENT face."
633 :group 'gnus-article-headers
634 :group 'gnus-article-highlight
635 :type '(repeat (list (regexp :tag "Header")
637 (item :tag "skip" nil)
638 (face :value default))
639 (choice :tag "Content"
640 (item :tag "skip" nil)
641 (face :value default)))))
643 (defcustom gnus-article-decode-hook
644 '(article-decode-charset article-decode-encoded-words
645 article-decode-group-name)
646 "*Hook run to decode charsets in articles."
647 :group 'gnus-article-headers
650 (defcustom gnus-display-mime-function 'gnus-display-mime
651 "Function to display MIME articles."
652 :group 'gnus-article-mime
655 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
656 "Function used to decode headers.")
658 (defvar gnus-article-dumbquotes-map
677 "Table for MS-to-Latin1 translation.")
679 (defcustom gnus-ignored-mime-types nil
680 "List of MIME types that should be ignored by Gnus."
682 :group 'gnus-article-mime
683 :type '(repeat regexp))
685 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
686 "List of MIME types that should not be given buttons when rendered inline.
687 See also `gnus-buttonized-mime-types' which may override this variable."
689 :group 'gnus-article-mime
690 :type '(repeat regexp))
692 (defcustom gnus-buttonized-mime-types nil
693 "List of MIME types that should be given buttons when rendered inline.
694 If set, this variable overrides `gnus-unbuttonized-mime-types'.
695 To see e.g. security buttons you could set this to
696 `(\"multipart/signed\")'."
698 :group 'gnus-article-mime
699 :type '(repeat regexp))
701 (defcustom gnus-article-mime-part-function nil
702 "Function called with a MIME handle as the argument.
703 This is meant for people who want to do something automatic based
704 on parts -- for instance, adding Vcard info to a database."
705 :group 'gnus-article-mime
708 (defcustom gnus-mime-multipart-functions nil
709 "An alist of MIME types to functions to display them."
711 :group 'gnus-article-mime
714 (defcustom gnus-article-date-lapsed-new-header nil
715 "Whether the X-Sent and Date headers can coexist.
716 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
717 either replace the old \"Date:\" header (if this variable is nil), or
718 be added below it (otherwise)."
720 :group 'gnus-article-headers
723 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
724 "Function called with a MIME handle as the argument.
725 This is meant for people who want to view first matched part.
726 For `undisplayed-alternative' (default), the first undisplayed
727 part or alternative part is used. For `undisplayed', the first
728 undisplayed part is used. For a function, the first part which
729 the function return `t' is used. For `nil', the first part is
732 :group 'gnus-article-mime
734 (item :tag "first" :value nil)
735 (item :tag "undisplayed" :value undisplayed)
736 (item :tag "undisplayed or alternative"
737 :value undisplayed-alternative)
740 (defcustom gnus-mime-action-alist
741 '(("save to file" . gnus-mime-save-part)
742 ("save and strip" . gnus-mime-save-part-and-strip)
743 ("display as text" . gnus-mime-inline-part)
744 ("view the part" . gnus-mime-view-part)
745 ("pipe to command" . gnus-mime-pipe-part)
746 ("toggle display" . gnus-article-press-button)
747 ("toggle display" . gnus-article-view-part-as-charset)
748 ("view as type" . gnus-mime-view-part-as-type)
749 ("internalize type" . gnus-mime-internalize-part)
750 ("externalize type" . gnus-mime-externalize-part))
751 "An alist of actions that run on the MIME attachment."
752 :group 'gnus-article-mime
753 :type '(repeat (cons (string :tag "name")
756 (defcustom gnus-mime-action-alist
757 '(("save to file" . gnus-mime-save-part)
758 ("display as text" . gnus-mime-inline-part)
759 ("view the part" . gnus-mime-view-part)
760 ("pipe to command" . gnus-mime-pipe-part)
761 ("toggle display" . gnus-article-press-button)
762 ("view as type" . gnus-mime-view-part-as-type)
763 ("internalize type" . gnus-mime-internalize-part)
764 ("externalize type" . gnus-mime-externalize-part))
765 "An alist of actions that run on the MIME attachment."
767 :group 'gnus-article-mime
768 :type '(repeat (cons (string :tag "name")
772 ;;; The treatment variables
775 (defvar gnus-part-display-hook nil
776 "Hook called on parts that are to receive treatment.")
778 (defvar gnus-article-treat-custom
779 '(choice (const :tag "Off" nil)
781 (const :tag "Header" head)
782 (const :tag "Last" last)
783 (integer :tag "Less")
784 (repeat :tag "Groups" regexp)
785 (sexp :tag "Predicate")))
787 (defvar gnus-article-treat-head-custom
788 '(choice (const :tag "Off" nil)
789 (const :tag "Header" head)))
791 (defvar gnus-article-treat-types '("text/plain")
794 (defvar gnus-inhibit-treatment nil
795 "Whether to inhibit treatment.")
797 (defcustom gnus-treat-highlight-signature '(or last (typep "text/x-vcard"))
798 "Highlight the signature.
799 Valid values are nil, t, `head', `last', an integer or a predicate.
800 See Info node `(gnus)Customizing Articles'."
801 :group 'gnus-article-treat
802 :type gnus-article-treat-custom)
803 (put 'gnus-treat-highlight-signature 'highlight t)
805 (defcustom gnus-treat-buttonize 100000
807 Valid values are nil, t, `head', `last', an integer or a predicate.
808 See the manual for details."
809 :group 'gnus-article-treat
810 :type gnus-article-treat-custom)
811 (put 'gnus-treat-buttonize 'highlight t)
813 (defcustom gnus-treat-buttonize-head 'head
814 "Add buttons to the head.
815 Valid values are nil, t, `head', `last', an integer or a predicate.
816 See the manual for details."
817 :group 'gnus-article-treat
818 :type gnus-article-treat-head-custom)
819 (put 'gnus-treat-buttonize-head 'highlight t)
821 (defcustom gnus-treat-emphasize
822 (and (or window-system
824 (>= (string-to-number emacs-version) 21))
827 Valid values are nil, t, `head', `last', an integer or a predicate.
828 See the manual for details."
829 :group 'gnus-article-treat
830 :type gnus-article-treat-custom)
831 (put 'gnus-treat-emphasize 'highlight t)
833 (defcustom gnus-treat-strip-cr nil
834 "Remove carriage returns.
835 Valid values are nil, t, `head', `last', an integer or a predicate.
836 See the manual for details."
837 :group 'gnus-article-treat
838 :type gnus-article-treat-custom)
840 (defcustom gnus-treat-leading-whitespace nil
841 "Remove leading whitespace in headers.
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-custom)
847 (defcustom gnus-treat-hide-headers 'head
849 Valid values are nil, t, `head', `last', an integer or a predicate.
850 See the manual for details."
851 :group 'gnus-article-treat
852 :type gnus-article-treat-head-custom)
854 (defcustom gnus-treat-hide-boring-headers nil
855 "Hide boring headers.
856 Valid values are nil, t, `head', `last', an integer or a predicate.
857 See the manual for details."
858 :group 'gnus-article-treat
859 :type gnus-article-treat-head-custom)
861 (defcustom gnus-treat-hide-signature nil
863 Valid values are nil, t, `head', `last', an integer or a predicate.
864 See the manual for details."
865 :group 'gnus-article-treat
866 :type gnus-article-treat-custom)
868 (defcustom gnus-treat-fill-article nil
870 Valid values are nil, t, `head', `last', an integer or a predicate.
871 See the manual for details."
872 :group 'gnus-article-treat
873 :type gnus-article-treat-custom)
875 (defcustom gnus-treat-hide-citation nil
877 Valid values are nil, t, `head', `last', an integer or a predicate.
878 See the manual for details."
879 :group 'gnus-article-treat
880 :type gnus-article-treat-custom)
882 (defcustom gnus-treat-hide-citation-maybe nil
884 Valid values are nil, t, `head', `last', an integer or a predicate.
885 See the manual for details."
886 :group 'gnus-article-treat
887 :type gnus-article-treat-custom)
889 (defcustom gnus-treat-strip-list-identifiers 'head
890 "Strip list identifiers from `gnus-list-identifiers`.
891 Valid values are nil, t, `head', `last', an integer or a predicate.
892 See the manual for details."
894 :group 'gnus-article-treat
895 :type gnus-article-treat-custom)
897 (defcustom gnus-treat-strip-pgp t
898 "Strip PGP signatures.
899 Valid values are nil, t, `head', `last', an integer or a predicate.
900 See the manual for details."
901 :group 'gnus-article-treat
902 :type gnus-article-treat-custom)
904 (defcustom gnus-treat-strip-pem nil
905 "Strip PEM signatures.
906 Valid values are nil, t, `head', `last', an integer or a predicate.
907 See the manual for details."
908 :group 'gnus-article-treat
909 :type gnus-article-treat-custom)
911 (defcustom gnus-treat-strip-banner t
912 "Strip banners from articles.
913 The banner to be stripped is specified in the `banner' group parameter.
914 Valid values are nil, t, `head', `last', an integer or a predicate.
915 See the manual for details."
916 :group 'gnus-article-treat
917 :type gnus-article-treat-custom)
919 (defcustom gnus-treat-highlight-headers 'head
920 "Highlight the headers.
921 Valid values are nil, t, `head', `last', an integer or a predicate.
922 See the manual for details."
923 :group 'gnus-article-treat
924 :type gnus-article-treat-head-custom)
925 (put 'gnus-treat-highlight-headers 'highlight t)
927 (defcustom gnus-treat-highlight-citation t
928 "Highlight cited text.
929 Valid values are nil, t, `head', `last', an integer or a predicate.
930 See the manual for details."
931 :group 'gnus-article-treat
932 :type gnus-article-treat-custom)
933 (put 'gnus-treat-highlight-citation 'highlight t)
935 (defcustom gnus-treat-date-ut nil
936 "Display the Date in UT (GMT).
937 Valid values are nil, t, `head', `last', an integer or a predicate.
938 See the manual for details."
939 :group 'gnus-article-treat
940 :type gnus-article-treat-head-custom)
942 (defcustom gnus-treat-date-local nil
943 "Display the Date in the local timezone.
944 Valid values are nil, t, `head', `last', an integer or a predicate.
945 See the manual for details."
946 :group 'gnus-article-treat
947 :type gnus-article-treat-head-custom)
949 (defcustom gnus-treat-date-english nil
950 "Display the Date in a format that can be read aloud in English.
951 Valid values are nil, t, `head', `last', an integer or a predicate.
952 See the manual for details."
953 :group 'gnus-article-treat
954 :type gnus-article-treat-head-custom)
956 (defcustom gnus-treat-date-lapsed nil
957 "Display the Date header in a way that says how much time has elapsed.
958 Valid values are nil, t, `head', `last', an integer or a predicate.
959 See the manual for details."
960 :group 'gnus-article-treat
961 :type gnus-article-treat-head-custom)
963 (defcustom gnus-treat-date-original nil
964 "Display the date in the original timezone.
965 Valid values are nil, t, `head', `last', an integer or a predicate.
966 See the manual for details."
967 :group 'gnus-article-treat
968 :type gnus-article-treat-head-custom)
970 (defcustom gnus-treat-date-iso8601 nil
971 "Display the date in the ISO8601 format.
972 Valid values are nil, t, `head', `last', an integer or a predicate.
973 See the manual for details."
975 :group 'gnus-article-treat
976 :type gnus-article-treat-head-custom)
978 (defcustom gnus-treat-date-user-defined nil
979 "Display the date in a user-defined format.
980 The format is defined by the `gnus-article-time-format' variable.
981 Valid values are nil, t, `head', `last', an integer or a predicate.
982 See the manual for details."
983 :group 'gnus-article-treat
984 :type gnus-article-treat-head-custom)
986 (defcustom gnus-treat-strip-headers-in-body t
987 "Strip the X-No-Archive header line from the beginning of the body.
988 Valid values are nil, t, `head', `last', an integer or a predicate.
989 See the manual for details."
991 :group 'gnus-article-treat
992 :type gnus-article-treat-custom)
994 (defcustom gnus-treat-strip-trailing-blank-lines nil
995 "Strip trailing blank lines.
996 Valid values are nil, t, `head', `last', an integer or a predicate.
997 See the manual for details."
998 :group 'gnus-article-treat
999 :type gnus-article-treat-custom)
1001 (defcustom gnus-treat-strip-leading-blank-lines nil
1002 "Strip leading blank lines.
1003 Valid values are nil, t, `head', `last', an integer or a predicate.
1004 See the manual for details."
1005 :group 'gnus-article-treat
1006 :type gnus-article-treat-custom)
1008 (defcustom gnus-treat-strip-multiple-blank-lines nil
1009 "Strip multiple blank lines.
1010 Valid values are nil, t, `head', `last', an integer or a predicate.
1011 See the manual for details."
1012 :group 'gnus-article-treat
1013 :type gnus-article-treat-custom)
1015 (defcustom gnus-treat-overstrike t
1016 "Treat overstrike highlighting.
1017 Valid values are nil, t, `head', `last', an integer or a predicate.
1018 See the manual for details."
1019 :group 'gnus-article-treat
1020 :type gnus-article-treat-custom)
1021 (put 'gnus-treat-overstrike 'highlight t)
1023 (defcustom gnus-treat-display-xface
1024 (and (or (and (fboundp 'image-type-available-p)
1025 (image-type-available-p 'xbm)
1026 (string-match "^0x" (shell-command-to-string "uncompface")))
1027 (and (featurep 'xemacs) (featurep 'xface)))
1029 "Display X-Face headers.
1030 Valid values are nil, t, `head', `last', an integer or a predicate.
1031 See the manual for details."
1032 :group 'gnus-article-treat
1034 :type gnus-article-treat-head-custom)
1035 (put 'gnus-treat-display-xface 'highlight t)
1037 (defcustom gnus-treat-display-smileys
1038 (if (or (and (featurep 'xemacs)
1040 (and (fboundp 'image-type-available-p)
1041 (image-type-available-p 'pbm)))
1044 Valid values are nil, t, `head', `last', an integer or a predicate.
1045 See the manual for details."
1046 :group 'gnus-article-treat
1048 :type gnus-article-treat-custom)
1049 (put 'gnus-treat-display-smileys 'highlight t)
1051 (defcustom gnus-treat-display-picons (if (featurep 'xemacs) 'head nil)
1053 Valid values are nil, t, `head', `last', an integer or a predicate.
1054 See the manual for details."
1055 :group 'gnus-article-treat
1056 :type gnus-article-treat-head-custom)
1057 (put 'gnus-treat-display-picons 'highlight t)
1059 (defcustom gnus-treat-capitalize-sentences nil
1060 "Capitalize sentence-starting words.
1061 Valid values are nil, t, `head', `last', an integer or a predicate.
1062 See the manual for details."
1064 :group 'gnus-article-treat
1065 :type gnus-article-treat-custom)
1067 (defcustom gnus-treat-fill-long-lines nil
1069 Valid values are nil, t, `head', `last', an integer or a predicate.
1070 See the manual for details."
1071 :group 'gnus-article-treat
1072 :type gnus-article-treat-custom)
1074 (defcustom gnus-treat-play-sounds nil
1076 Valid values are nil, t, `head', `last', an integer or a predicate.
1077 See the manual for details."
1079 :group 'gnus-article-treat
1080 :type gnus-article-treat-custom)
1082 (defcustom gnus-treat-translate nil
1083 "Translate articles from one language to another.
1084 Valid values are nil, t, `head', `last', an integer or a predicate.
1085 See the manual for details."
1087 :group 'gnus-article-treat
1088 :type gnus-article-treat-custom)
1090 (defcustom gnus-treat-x-pgp-sig nil
1092 To automatically treat X-PGP-Sig, set it to head.
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 :group 'mime-security
1097 :type gnus-article-treat-custom)
1099 (defvar gnus-article-encrypt-protocol-alist
1100 '(("PGP" . mml2015-self-encrypt)))
1102 ;; Set to nil if more than one protocol added to
1103 ;; gnus-article-encrypt-protocol-alist.
1104 (defcustom gnus-article-encrypt-protocol "PGP"
1105 "The protocol used for encrypt articles.
1106 It is a string, such as \"PGP\". If nil, ask user."
1108 :group 'mime-security)
1110 ;;; Internal variables
1112 (defvar gnus-english-month-names
1113 '("January" "February" "March" "April" "May" "June" "July" "August"
1114 "September" "October" "November" "December"))
1116 (defvar article-goto-body-goes-to-point-min-p nil)
1117 (defvar gnus-article-wash-types nil)
1118 (defvar gnus-article-emphasis-alist nil)
1120 (defvar gnus-article-mime-handle-alist-1 nil)
1121 (defvar gnus-treatment-function-alist
1122 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1123 (gnus-treat-strip-banner gnus-article-strip-banner)
1124 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1125 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1126 (gnus-treat-buttonize gnus-article-add-buttons)
1127 (gnus-treat-fill-article gnus-article-fill-cited-article)
1128 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1129 (gnus-treat-strip-cr gnus-article-remove-cr)
1130 (gnus-treat-emphasize gnus-article-emphasize)
1131 (gnus-treat-display-xface gnus-article-display-x-face)
1132 (gnus-treat-date-ut gnus-article-date-ut)
1133 (gnus-treat-date-local gnus-article-date-local)
1134 (gnus-treat-date-english gnus-article-date-english)
1135 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1136 (gnus-treat-date-original gnus-article-date-original)
1137 (gnus-treat-date-user-defined gnus-article-date-user)
1138 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1139 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1140 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1141 (gnus-treat-hide-signature gnus-article-hide-signature)
1142 (gnus-treat-hide-citation gnus-article-hide-citation)
1143 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1144 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1145 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1146 (gnus-treat-strip-pgp gnus-article-hide-pgp)
1147 (gnus-treat-strip-pem gnus-article-hide-pem)
1148 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1149 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1150 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1151 (gnus-treat-strip-trailing-blank-lines
1152 gnus-article-remove-trailing-blank-lines)
1153 (gnus-treat-strip-leading-blank-lines
1154 gnus-article-strip-leading-blank-lines)
1155 (gnus-treat-strip-multiple-blank-lines
1156 gnus-article-strip-multiple-blank-lines)
1157 (gnus-treat-overstrike gnus-article-treat-overstrike)
1158 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1159 (gnus-treat-display-smileys gnus-smiley-display)
1160 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1161 (gnus-treat-display-picons gnus-article-display-picons)
1162 (gnus-treat-play-sounds gnus-earcon-display)))
1164 (defvar gnus-article-mime-handle-alist nil)
1165 (defvar article-lapsed-timer nil)
1166 (defvar gnus-article-current-summary nil)
1168 (defvar gnus-article-mode-syntax-table
1169 (let ((table (copy-syntax-table text-mode-syntax-table)))
1170 ;; This causes the citation match run O(2^n).
1171 ;; (modify-syntax-entry ?- "w" table)
1172 (modify-syntax-entry ?> ")" table)
1173 (modify-syntax-entry ?< "(" table)
1175 "Syntax table used in article mode buffers.
1176 Initialized from `text-mode-syntax-table.")
1178 (defvar gnus-save-article-buffer nil)
1180 (defvar gnus-article-mode-line-format-alist
1181 (nconc '((?w (gnus-article-wash-status) ?s)
1182 (?m (gnus-article-mime-part-status) ?s))
1183 gnus-summary-mode-line-format-alist))
1185 (defvar gnus-number-of-articles-to-be-saved nil)
1187 (defvar gnus-inhibit-hiding nil)
1189 (defsubst gnus-article-hide-text (b e props)
1190 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1191 (gnus-add-text-properties-when 'article-type nil b e props)
1192 (when (memq 'intangible props)
1194 (max (1- b) (point-min))
1195 b 'intangible (cddr (memq 'intangible props)))))
1197 (defsubst gnus-article-unhide-text (b e)
1198 "Remove hidden text properties from region between B and E."
1199 (remove-text-properties b e gnus-hidden-properties)
1200 (when (memq 'intangible gnus-hidden-properties)
1201 (put-text-property (max (1- b) (point-min))
1202 b 'intangible nil)))
1204 (defun gnus-article-hide-text-type (b e type)
1205 "Hide text of TYPE between B and E."
1206 (push type gnus-article-wash-types)
1207 (gnus-article-hide-text
1208 b e (cons 'article-type (cons type gnus-hidden-properties))))
1210 (defun gnus-article-unhide-text-type (b e type)
1211 "Unhide text of TYPE between B and E."
1212 (setq gnus-article-wash-types
1213 (delq type gnus-article-wash-types))
1214 (remove-text-properties
1215 b e (cons 'article-type (cons type gnus-hidden-properties)))
1216 (when (memq 'intangible gnus-hidden-properties)
1217 (put-text-property (max (1- b) (point-min))
1218 b 'intangible nil)))
1220 (defun gnus-article-hide-text-of-type (type)
1221 "Hide text of TYPE in the current buffer."
1223 (let ((b (point-min))
1225 (while (setq b (text-property-any b e 'article-type type))
1226 (add-text-properties b (incf b) gnus-hidden-properties)))))
1228 (defun gnus-article-delete-text-of-type (type)
1229 "Delete text of TYPE in the current buffer."
1231 (let ((b (point-min)))
1232 (while (setq b (text-property-any b (point-max) 'article-type type))
1234 b (or (text-property-not-all b (point-max) 'article-type type)
1237 (defun gnus-article-delete-invisible-text ()
1238 "Delete all invisible text in the current buffer."
1240 (let ((b (point-min)))
1241 (while (setq b (text-property-any b (point-max) 'invisible t))
1243 b (or (text-property-not-all b (point-max) 'invisible t)
1246 (defun gnus-article-text-type-exists-p (type)
1247 "Say whether any text of type TYPE exists in the buffer."
1248 (text-property-any (point-min) (point-max) 'article-type type))
1250 (defsubst gnus-article-header-rank ()
1251 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1252 (let ((list gnus-sorted-header-list)
1255 (when (looking-at (car list))
1257 (setq list (cdr list))
1261 (defun article-hide-headers (&optional arg delete)
1262 "Hide unwanted headers and possibly sort them as well."
1264 ;; This function might be inhibited.
1265 (unless gnus-inhibit-hiding
1268 (let ((buffer-read-only nil)
1269 (case-fold-search t)
1270 (max (1+ (length gnus-sorted-header-list)))
1271 (ignored (when (not gnus-visible-headers)
1272 (cond ((stringp gnus-ignored-headers)
1273 gnus-ignored-headers)
1274 ((listp gnus-ignored-headers)
1275 (mapconcat 'identity gnus-ignored-headers
1278 (cond ((stringp gnus-visible-headers)
1279 gnus-visible-headers)
1280 ((and gnus-visible-headers
1281 (listp gnus-visible-headers))
1282 (mapconcat 'identity gnus-visible-headers "\\|"))))
1283 (inhibit-point-motion-hooks t)
1285 ;; First we narrow to just the headers.
1286 (article-narrow-to-head)
1287 ;; Hide any "From " lines at the beginning of (mail) articles.
1288 (while (looking-at "From ")
1291 (delete-region (point-min) (point)))
1292 ;; Then treat the rest of the header lines.
1293 ;; Then we use the two regular expressions
1294 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1295 ;; select which header lines is to remain visible in the
1297 (while (re-search-forward "^[^ \t:]*:" nil t)
1299 ;; Mark the rank of the header.
1301 (point) (1+ (point)) 'message-rank
1302 (if (or (and visible (looking-at visible))
1304 (not (looking-at ignored))))
1305 (gnus-article-header-rank)
1308 (message-sort-headers-1)
1309 (when (setq beg (text-property-any
1310 (point-min) (point-max) 'message-rank (+ 2 max)))
1311 ;; We delete the unwanted headers.
1312 (push 'headers gnus-article-wash-types)
1313 (add-text-properties (point-min) (+ 5 (point-min))
1314 '(article-type headers dummy-invisible t))
1315 (delete-region beg (point-max))))))))
1317 (defun article-hide-boring-headers (&optional arg)
1318 "Toggle hiding of headers that aren't very interesting.
1319 If given a negative prefix, always show; if given a positive prefix,
1321 (interactive (gnus-article-hidden-arg))
1322 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1323 (not gnus-show-all-headers))
1326 (let ((buffer-read-only nil)
1327 (list gnus-boring-article-headers)
1328 (inhibit-point-motion-hooks t)
1330 (article-narrow-to-head)
1332 (setq elem (pop list))
1333 (goto-char (point-min))
1335 ;; Hide empty headers.
1337 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1339 (gnus-article-hide-text-type
1340 (progn (beginning-of-line) (point))
1343 (if (re-search-forward "^[^ \t]" nil t)
1347 ;; Hide boring Newsgroups header.
1348 ((eq elem 'newsgroups)
1349 (when (gnus-string-equal
1350 (gnus-fetch-field "newsgroups")
1351 (gnus-group-real-name
1352 (if (boundp 'gnus-newsgroup-name)
1355 (gnus-article-hide-header "newsgroups")))
1356 ((eq elem 'to-address)
1357 (let ((to (message-fetch-field "to"))
1359 (gnus-parameter-to-address
1360 (if (boundp 'gnus-newsgroup-name)
1361 gnus-newsgroup-name ""))))
1362 (when (and to to-address
1365 ;; only one address in To
1366 (nth 1 (mail-extract-address-components to))
1368 (gnus-article-hide-header "to"))))
1369 ((eq elem 'followup-to)
1370 (when (gnus-string-equal
1371 (message-fetch-field "followup-to")
1372 (message-fetch-field "newsgroups"))
1373 (gnus-article-hide-header "followup-to")))
1374 ((eq elem 'reply-to)
1375 (let ((from (message-fetch-field "from"))
1376 (reply-to (message-fetch-field "reply-to")))
1381 (nth 1 (mail-extract-address-components from))
1382 (nth 1 (mail-extract-address-components reply-to)))))
1383 (gnus-article-hide-header "reply-to"))))
1385 (let ((date (message-fetch-field "date")))
1387 (< (days-between (current-time-string) date)
1389 (gnus-article-hide-header "date"))))
1391 (let ((to (message-fetch-field "to"))
1392 (cc (message-fetch-field "cc")))
1393 (when (> (length to) 1024)
1394 (gnus-article-hide-header "to"))
1395 (when (> (length cc) 1024)
1396 (gnus-article-hide-header "cc"))))
1400 (goto-char (point-min))
1401 (while (re-search-forward "^to:" nil t)
1402 (setq to-count (1+ to-count)))
1403 (when (> to-count 1)
1404 (while (> to-count 0)
1405 (goto-char (point-min))
1407 (re-search-forward "^to:" nil nil to-count)
1409 (narrow-to-region (point) (point-max))
1410 (gnus-article-hide-header "to"))
1411 (setq to-count (1- to-count))))
1412 (goto-char (point-min))
1413 (while (re-search-forward "^cc:" nil t)
1414 (setq cc-count (1+ cc-count)))
1415 (when (> cc-count 1)
1416 (while (> cc-count 0)
1417 (goto-char (point-min))
1419 (re-search-forward "^cc:" nil nil cc-count)
1421 (narrow-to-region (point) (point-max))
1422 (gnus-article-hide-header "cc"))
1423 (setq cc-count (1- cc-count)))))))))))))
1425 (defun gnus-article-hide-header (header)
1427 (goto-char (point-min))
1428 (when (re-search-forward (concat "^" header ":") nil t)
1429 (gnus-article-hide-text-type
1430 (progn (beginning-of-line) (point))
1433 (if (re-search-forward "^[^ \t]" nil t)
1438 (defvar gnus-article-normalized-header-length 40
1439 "Length of normalized headers.")
1441 (defun article-normalize-headers ()
1442 "Make all header lines 40 characters long."
1444 (let ((buffer-read-only nil)
1448 (article-narrow-to-head)
1451 ((< (setq column (- (gnus-point-at-eol) (point)))
1452 gnus-article-normalized-header-length)
1454 (insert (make-string
1455 (- gnus-article-normalized-header-length column)
1457 ((> column gnus-article-normalized-header-length)
1458 (gnus-put-text-property
1460 (forward-char gnus-article-normalized-header-length)
1467 (forward-line 1))))))
1469 (defun article-treat-dumbquotes ()
1470 "Translate M****s*** sm*rtq**t*s into proper text.
1471 Note that this function guesses whether a character is a sm*rtq**t* or
1472 not, so it should only be used interactively.
1474 Sm*rtq**t*s are M****s***'s unilateral extension to the character map
1475 in an attempt to provide more quoting characters. If you see
1476 something like \\222 or \\264 where you're expecting some kind of
1477 apostrophe or quotation mark, then try this wash."
1479 (article-translate-strings gnus-article-dumbquotes-map))
1481 (defun article-translate-characters (from to)
1482 "Translate all characters in the body of the article according to FROM and TO.
1483 FROM is a string of characters to translate from; to is a string of
1484 characters to translate to."
1486 (when (article-goto-body)
1487 (let ((buffer-read-only nil)
1488 (x (make-string 225 ?x))
1490 (while (< (incf i) (length x))
1493 (while (< i (length from))
1494 (aset x (aref from i) (aref to i))
1496 (translate-region (point) (point-max) x)))))
1498 (defun article-translate-strings (map)
1499 "Translate all string in the body of the article according to MAP.
1500 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1502 (when (article-goto-body)
1503 (let ((buffer-read-only nil)
1505 (while (setq elem (pop map))
1507 (while (search-forward (car elem) nil t)
1508 (replace-match (cadr elem)))))))))
1510 (defun article-treat-overstrike ()
1511 "Translate overstrikes into bold text."
1514 (when (article-goto-body)
1515 (let ((buffer-read-only nil))
1516 (while (search-forward "\b" nil t)
1517 (let ((next (char-after))
1518 (previous (char-after (- (point) 2))))
1519 ;; We do the boldification/underlining by hiding the
1520 ;; overstrikes and putting the proper text property
1524 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1525 (put-text-property (point) (1+ (point)) 'face 'bold))
1527 (gnus-article-hide-text-type
1528 (1- (point)) (1+ (point)) 'overstrike)
1530 (- (point) 2) (1- (point)) 'face 'underline))
1532 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1534 (point) (1+ (point)) 'face 'underline)))))))))
1536 (defun article-fill-long-lines ()
1537 "Fill lines that are wider than the window width."
1540 (let ((buffer-read-only nil)
1541 (width (window-width (get-buffer-window (current-buffer)))))
1544 (let ((adaptive-fill-mode nil)) ;Why? -sm
1547 (when (>= (current-column) (min fill-column width))
1548 (narrow-to-region (point) (gnus-point-at-bol))
1549 (fill-paragraph nil)
1550 (goto-char (point-max))
1552 (forward-line 1)))))))
1554 (defun article-capitalize-sentences ()
1555 "Capitalize the first word in each sentence."
1558 (let ((buffer-read-only nil)
1559 (paragraph-start "^[\n\^L]"))
1563 (forward-sentence)))))
1565 (defun article-remove-cr ()
1566 "Remove trailing CRs and then translate remaining CRs into LFs."
1569 (let ((buffer-read-only nil))
1570 (goto-char (point-min))
1571 (while (re-search-forward "\r+$" nil t)
1572 (replace-match "" t t))
1573 (goto-char (point-min))
1574 (while (search-forward "\r" nil t)
1575 (replace-match "\n" t t)))))
1577 (defun article-remove-trailing-blank-lines ()
1578 "Remove all trailing blank lines from the article."
1581 (let ((buffer-read-only nil))
1582 (goto-char (point-max))
1586 (while (and (not (bobp))
1587 (looking-at "^[ \t]*$")
1588 (not (gnus-annotation-in-region-p
1589 (point) (gnus-point-at-eol))))
1594 (defun article-display-x-face (&optional force)
1595 "Look for an X-Face header and display it if present."
1596 (interactive (list 'force))
1598 ;; Delete the old process, if any.
1599 (when (process-status "article-x-face")
1600 (delete-process "article-x-face"))
1601 (let ((inhibit-point-motion-hooks t)
1603 (case-fold-search t)
1606 (article-narrow-to-head)
1607 (when (and buffer-read-only ;; When type `W f'
1609 (goto-char (point-min))
1610 (not (re-search-forward "^X-Face:[\t ]*" nil t)))
1611 (gnus-buffer-live-p gnus-original-article-buffer))
1612 (with-current-buffer gnus-original-article-buffer
1614 (article-narrow-to-head)
1615 (while (re-search-forward "^X-Face:" nil t)
1621 (1- (re-search-forward
1622 "^\\($\\|[^ \t]\\)" nil t))))))))
1624 (let (point start bface eface buffer-read-only)
1625 (goto-char (point-max))
1627 (setq bface (get-text-property (gnus-point-at-bol) 'face)
1628 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
1629 (goto-char (point-max))
1630 (setq point (point))
1633 (while (looking-at "\\([^:]+\\): *")
1634 (put-text-property (match-beginning 1) (1+ (match-end 1))
1636 (setq start (match-end 0))
1638 (while (looking-at "[\t ]")
1640 (put-text-property start (point)
1642 (goto-char (point-min))
1643 (setq from (message-fetch-field "from"))
1644 (goto-char (point-min))
1645 (while (and gnus-article-x-face-command
1648 ;; Check whether this face is censored.
1649 (not gnus-article-x-face-too-ugly)
1650 (and gnus-article-x-face-too-ugly from
1651 (not (string-match gnus-article-x-face-too-ugly
1653 ;; Has to be present.
1654 (re-search-forward "^X-Face:[\t ]*" nil t))
1655 ;; This used to try to do multiple faces (`while' instead of
1656 ;; `when' above), but (a) sending multiple EOFs to xv doesn't
1657 ;; work (b) it can crash some versions of Emacs (c) are
1658 ;; multiple faces really something to encourage?
1659 (when (stringp gnus-article-x-face-command)
1661 ;; We now have the area of the buffer where the X-Face is stored.
1664 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t)))
1666 ;; We display the face.
1667 (if (symbolp gnus-article-x-face-command)
1668 ;; The command is a lisp function, so we call it.
1669 (if (gnus-functionp gnus-article-x-face-command)
1670 (funcall gnus-article-x-face-command beg end)
1671 (error "%s is not a function" gnus-article-x-face-command))
1672 ;; The command is a string, so we interpret the command
1673 ;; as a, well, command, and fork it off.
1674 (let ((process-connection-type nil))
1675 (process-kill-without-query
1677 "article-x-face" nil shell-file-name shell-command-switch
1678 gnus-article-x-face-command))
1679 (process-send-region "article-x-face" beg end)
1680 (process-send-eof "article-x-face"))))))))))
1682 (defun article-decode-mime-words ()
1683 "Decode all MIME-encoded words in the article."
1686 (set-buffer gnus-article-buffer)
1687 (let ((inhibit-point-motion-hooks t)
1689 (mail-parse-charset gnus-newsgroup-charset)
1690 (mail-parse-ignored-charsets
1691 (save-excursion (set-buffer gnus-summary-buffer)
1692 gnus-newsgroup-ignored-charsets)))
1693 (mail-decode-encoded-word-region (point-min) (point-max)))))
1695 (defun article-decode-charset (&optional prompt)
1696 "Decode charset-encoded text in the article.
1697 If PROMPT (the prefix), prompt for a coding system to use."
1699 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
1701 (mail-parse-charset gnus-newsgroup-charset)
1702 (mail-parse-ignored-charsets
1703 (save-excursion (condition-case nil
1704 (set-buffer gnus-summary-buffer)
1706 gnus-newsgroup-ignored-charsets))
1707 ct cte ctl charset format)
1710 (article-narrow-to-head)
1711 (setq ct (message-fetch-field "Content-Type" t)
1712 cte (message-fetch-field "Content-Transfer-Encoding" t)
1713 ctl (and ct (ignore-errors
1714 (mail-header-parse-content-type ct)))
1717 (mm-read-coding-system "Charset to decode: "))
1719 (mail-content-type-get ctl 'charset)))
1720 format (and ctl (mail-content-type-get ctl 'format)))
1722 (setq cte (mail-header-strip cte)))
1723 (if (and ctl (not (string-match "/" (car ctl))))
1725 (goto-char (point-max)))
1728 (narrow-to-region (point) (point-max))
1729 (when (and (eq mail-parse-charset 'gnus-decoded)
1730 (eq (mm-body-7-or-8) '8bit))
1731 ;; The text code could have been decoded.
1732 (setq charset mail-parse-charset))
1733 (when (and (or (not ctl)
1734 (equal (car ctl) "text/plain"))
1735 (not format)) ;; article with format will decode later.
1737 charset (and cte (intern (downcase
1738 (gnus-strip-whitespace cte))))
1741 (defun article-decode-encoded-words ()
1742 "Remove encoded-word encoding from headers."
1743 (let ((inhibit-point-motion-hooks t)
1744 (mail-parse-charset gnus-newsgroup-charset)
1745 (mail-parse-ignored-charsets
1746 (save-excursion (condition-case nil
1747 (set-buffer gnus-summary-buffer)
1749 gnus-newsgroup-ignored-charsets))
1752 (article-narrow-to-head)
1753 (funcall gnus-decode-header-function (point-min) (point-max)))))
1755 (defun article-decode-group-name ()
1756 "Decode group names in `Newsgroups:'."
1757 (let ((inhibit-point-motion-hooks t)
1759 (method (gnus-find-method-for-group gnus-newsgroup-name)))
1760 (when (and (or gnus-group-name-charset-method-alist
1761 gnus-group-name-charset-group-alist)
1762 (gnus-buffer-live-p gnus-original-article-buffer))
1763 (when (nnmail-fetch-field "Newsgroups")
1764 (nnheader-replace-header "Newsgroups"
1765 (gnus-decode-newsgroups
1766 (with-current-buffer
1767 gnus-original-article-buffer
1768 (nnmail-fetch-field "Newsgroups"))
1769 gnus-newsgroup-name method)))
1770 (when (nnmail-fetch-field "Followup-To")
1771 (nnheader-replace-header "Followup-To"
1772 (gnus-decode-newsgroups
1773 (with-current-buffer
1774 gnus-original-article-buffer
1775 (nnmail-fetch-field "Followup-To"))
1776 gnus-newsgroup-name method))))))
1778 (defun article-de-quoted-unreadable (&optional force read-charset)
1779 "Translate a quoted-printable-encoded article.
1780 If FORCE, decode the article whether it is marked as quoted-printable
1782 If READ-CHARSET, ask for a coding system."
1783 (interactive (list 'force current-prefix-arg))
1785 (let ((buffer-read-only nil) type charset)
1786 (if (gnus-buffer-live-p gnus-original-article-buffer)
1787 (with-current-buffer gnus-original-article-buffer
1789 (gnus-fetch-field "content-transfer-encoding"))
1790 (let* ((ct (gnus-fetch-field "content-type"))
1793 (mail-header-parse-content-type ct)))))
1794 (setq charset (and ctl
1795 (mail-content-type-get ctl 'charset)))
1796 (if (stringp charset)
1797 (setq charset (intern (downcase charset)))))))
1799 (setq charset (mm-read-coding-system "Charset: " charset)))
1801 (setq charset gnus-newsgroup-charset))
1803 (and type (let ((case-fold-search t))
1804 (string-match "quoted-printable" type))))
1806 (quoted-printable-decode-region
1807 (point) (point-max) (mm-charset-to-coding-system charset))))))
1809 (defun article-de-base64-unreadable (&optional force read-charset)
1810 "Translate a base64 article.
1811 If FORCE, decode the article whether it is marked as base64 not.
1812 If READ-CHARSET, ask for a coding system."
1813 (interactive (list 'force current-prefix-arg))
1815 (let ((buffer-read-only nil) type charset)
1816 (if (gnus-buffer-live-p gnus-original-article-buffer)
1817 (with-current-buffer gnus-original-article-buffer
1819 (gnus-fetch-field "content-transfer-encoding"))
1820 (let* ((ct (gnus-fetch-field "content-type"))
1823 (mail-header-parse-content-type ct)))))
1824 (setq charset (and ctl
1825 (mail-content-type-get ctl 'charset)))
1826 (if (stringp charset)
1827 (setq charset (intern (downcase charset)))))))
1829 (setq charset (mm-read-coding-system "Charset: " charset)))
1831 (setq charset gnus-newsgroup-charset))
1833 (and type (let ((case-fold-search t))
1834 (string-match "base64" type))))
1837 (narrow-to-region (point) (point-max))
1838 (base64-decode-region (point-min) (point-max))
1839 (mm-decode-coding-region
1840 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
1845 (defun article-decode-HZ ()
1846 "Translate a HZ-encoded article."
1850 (let ((buffer-read-only nil))
1851 (rfc1843-decode-region (point-min) (point-max)))))
1853 (defun article-wash-html (&optional read-charset)
1854 "Format an html article.
1855 If READ-CHARSET, ask for a coding system."
1858 (let ((buffer-read-only nil)
1860 (if (gnus-buffer-live-p gnus-original-article-buffer)
1861 (with-current-buffer gnus-original-article-buffer
1862 (let* ((ct (gnus-fetch-field "content-type"))
1865 (mail-header-parse-content-type ct)))))
1866 (setq charset (and ctl
1867 (mail-content-type-get ctl 'charset)))
1868 (if (stringp charset)
1869 (setq charset (intern (downcase charset)))))))
1871 (setq charset (mm-read-coding-system "Charset: " charset)))
1873 (setq charset gnus-newsgroup-charset))
1875 (save-window-excursion
1877 (narrow-to-region (point) (point-max))
1879 (let ((w3-strict-width (window-width))
1880 (url-standalone-mode t))
1882 (w3-region (point-min) (point-max))
1885 (defun article-hide-list-identifiers ()
1886 "Remove list identifies from the Subject header.
1887 The `gnus-list-identifiers' variable specifies what to do."
1889 (let ((inhibit-point-motion-hooks t)
1890 (regexp (if (consp gnus-list-identifiers)
1891 (mapconcat 'identity gnus-list-identifiers " *\\|")
1892 gnus-list-identifiers))
1897 (article-narrow-to-head)
1898 (goto-char (point-min))
1899 (while (re-search-forward
1900 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
1902 (delete-region (match-beginning 2) (match-end 0))
1903 (beginning-of-line))
1904 (when (re-search-forward
1905 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
1906 (delete-region (match-beginning 1) (match-end 1))))))))
1908 (defun article-hide-pgp ()
1909 "Remove any PGP headers and signatures in the current article."
1913 (let ((inhibit-point-motion-hooks t)
1914 buffer-read-only beg end)
1916 ;; Hide the "header".
1917 (when (re-search-forward "^-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
1918 (push 'pgp gnus-article-wash-types)
1919 (delete-region (match-beginning 0) (match-end 0))
1920 ;; Remove armor headers (rfc2440 6.2)
1921 (delete-region (point) (or (re-search-forward "^[ \t]*\n" nil t)
1924 ;; Hide the actual signature.
1925 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
1926 (setq end (1+ (match-beginning 0)))
1929 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
1931 ;; Perhaps we shouldn't hide to the end of the buffer
1932 ;; if there is no end to the signature?
1934 ;; Hide "- " PGP quotation markers.
1936 (narrow-to-region beg end)
1937 (goto-char (point-min))
1938 (while (re-search-forward "^- " nil t)
1940 (match-beginning 0) (match-end 0)))
1942 (gnus-run-hooks 'gnus-article-hide-pgp-hook))))))
1944 (defun article-hide-pem (&optional arg)
1945 "Toggle hiding of any PEM headers and signatures in the current article.
1946 If given a negative prefix, always show; if given a positive prefix,
1948 (interactive (gnus-article-hidden-arg))
1949 (unless (gnus-article-check-hidden-text 'pem arg)
1951 (let (buffer-read-only end)
1952 (goto-char (point-min))
1953 ;; Hide the horrendously ugly "header".
1954 (when (and (search-forward
1955 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
1957 (setq end (1+ (match-beginning 0))))
1958 (push 'pem gnus-article-wash-types)
1959 (gnus-article-hide-text-type
1961 (if (search-forward "\n\n" nil t)
1965 ;; Hide the trailer as well
1966 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
1968 (gnus-article-hide-text-type
1969 (match-beginning 0) (match-end 0) 'pem)))))))
1971 (defun article-strip-banner ()
1972 "Strip the banner specified by the `banner' group parameter."
1976 (let ((inhibit-point-motion-hooks t)
1977 (banner (gnus-parameter-banner gnus-newsgroup-name))
1978 (gnus-signature-limit nil)
1979 buffer-read-only beg end)
1983 ((eq banner 'signature)
1984 (when (gnus-article-narrow-to-signature)
1987 (delete-region (point) (point-max))))
1989 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
1990 (while (re-search-forward banner nil t)
1991 (delete-region (match-beginning 0) (match-end 0)))))
1993 (while (re-search-forward banner nil t)
1994 (delete-region (match-beginning 0) (match-end 0))))))))))
1996 (defun article-babel ()
1997 "Translate article using an online translation service."
2001 (set-buffer gnus-article-buffer)
2002 (when (article-goto-body)
2003 (let* ((buffer-read-only nil)
2006 (orig (buffer-substring start end))
2007 (trans (babel-as-string orig)))
2009 (narrow-to-region start end)
2010 (delete-region start end)
2013 (defun article-hide-signature (&optional arg)
2014 "Hide the signature in the current article.
2015 If given a negative prefix, always show; if given a positive prefix,
2017 (interactive (gnus-article-hidden-arg))
2018 (unless (gnus-article-check-hidden-text 'signature arg)
2021 (let ((buffer-read-only nil))
2022 (when (gnus-article-narrow-to-signature)
2023 (gnus-article-hide-text-type
2024 (point-min) (point-max) 'signature)))))))
2026 (defun article-strip-headers-in-body ()
2027 "Strip offensive headers from bodies."
2031 (let ((case-fold-search t))
2032 (when (looking-at "x-no-archive:")
2033 (gnus-delete-line)))))
2035 (defun article-strip-leading-blank-lines ()
2036 "Remove all blank lines from the beginning of the article."
2039 (let ((inhibit-point-motion-hooks t)
2041 (when (article-goto-body)
2042 (while (and (not (eobp))
2043 (looking-at "[ \t]*$"))
2044 (gnus-delete-line))))))
2046 (defun article-narrow-to-head ()
2047 "Narrow the buffer to the head of the message.
2048 Point is left at the beginning of the narrowed-to region."
2050 (goto-char (point-min))
2051 (if (search-forward "\n\n" nil 1)
2054 (goto-char (point-min)))
2056 (defun article-goto-body ()
2057 "Place point at the start of the body."
2058 (goto-char (point-min))
2060 ;; This variable is only bound when dealing with separate
2062 (article-goto-body-goes-to-point-min-p
2064 ((search-forward "\n\n" nil t)
2067 (goto-char (point-max))
2070 (defun article-strip-multiple-blank-lines ()
2071 "Replace consecutive blank lines with one empty line."
2074 (let ((inhibit-point-motion-hooks t)
2076 ;; First make all blank lines empty.
2078 (while (re-search-forward "^[ \t]+$" nil t)
2079 (unless (gnus-annotation-in-region-p
2080 (match-beginning 0) (match-end 0))
2081 (replace-match "" nil t)))
2082 ;; Then replace multiple empty lines with a single empty line.
2084 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2085 (unless (gnus-annotation-in-region-p
2086 (match-beginning 0) (match-end 0))
2087 (delete-region (match-beginning 1) (match-end 1)))))))
2089 (defun article-strip-leading-space ()
2090 "Remove all white space from the beginning of the lines in the article."
2093 (let ((inhibit-point-motion-hooks t)
2096 (while (re-search-forward "^[ \t]+" nil t)
2097 (replace-match "" t t)))))
2099 (defun article-strip-trailing-space ()
2100 "Remove all white space from the end of the lines in the article."
2103 (let ((inhibit-point-motion-hooks t)
2106 (while (re-search-forward "[ \t]+$" nil t)
2107 (replace-match "" t t)))))
2109 (defun article-strip-blank-lines ()
2110 "Strip leading, trailing and multiple blank lines."
2112 (article-strip-leading-blank-lines)
2113 (article-remove-trailing-blank-lines)
2114 (article-strip-multiple-blank-lines))
2116 (defun article-strip-all-blank-lines ()
2117 "Strip all blank lines."
2120 (let ((inhibit-point-motion-hooks t)
2123 (while (re-search-forward "^[ \t]*\n" nil t)
2124 (replace-match "" t t)))))
2126 (defun gnus-article-narrow-to-signature ()
2127 "Narrow to the signature; return t if a signature is found, else nil."
2128 (let ((inhibit-point-motion-hooks t))
2129 (when (gnus-article-search-signature)
2131 ;; Check whether we have some limits to what we consider
2132 ;; to be a signature.
2133 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2134 (list gnus-signature-limit)))
2136 (while (setq limit (pop limits))
2137 (if (or (and (integerp limit)
2138 (< (- (point-max) (point)) limit))
2140 (< (count-lines (point) (point-max)) limit))
2141 (and (gnus-functionp limit)
2143 (and (stringp limit)
2144 (not (re-search-forward limit nil t))))
2145 () ; This limit did not succeed.
2149 (narrow-to-region (point) (point-max))
2152 (defun gnus-article-search-signature ()
2153 "Search the current buffer for the signature separator.
2154 Put point at the beginning of the signature separator."
2155 (let ((cur (point)))
2156 (goto-char (point-max))
2157 (if (if (stringp gnus-signature-separator)
2158 (re-search-backward gnus-signature-separator nil t)
2159 (let ((seps gnus-signature-separator))
2161 (not (re-search-backward (car seps) nil t)))
2168 (defun gnus-article-hidden-arg ()
2169 "Return the current prefix arg as a number, or 0 if no prefix."
2170 (list (if current-prefix-arg
2171 (prefix-numeric-value current-prefix-arg)
2174 (defun gnus-article-check-hidden-text (type arg)
2175 "Return nil if hiding is necessary.
2176 Arg can be nil or a number. Nil and positive means hide, negative
2177 means show, 0 means toggle."
2180 (let ((hide (gnus-article-hidden-text-p type)))
2186 (gnus-article-show-hidden-text type)
2189 (if (eq hide 'hidden)
2191 (gnus-article-show-hidden-text type)
2195 (defun gnus-article-hidden-text-p (type)
2196 "Say whether the current buffer contains hidden text of type TYPE."
2197 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2199 (not (get-text-property pos 'invisible))
2200 (not (get-text-property pos 'dummy-invisible)))
2202 (text-property-any (1+ pos) (point-max) 'article-type type)))
2207 (defun gnus-article-show-hidden-text (type &optional dummy)
2208 "Show all hidden text of type TYPE.
2209 Originally it is hide instead of DUMMY."
2210 (let ((buffer-read-only nil)
2211 (inhibit-point-motion-hooks t))
2212 (gnus-remove-text-properties-when
2214 (point-min) (point-max)
2215 (cons 'article-type (cons type
2216 gnus-hidden-properties)))))
2218 (defconst article-time-units
2219 `((year . ,(* 365.25 24 60 60))
2220 (week . ,(* 7 24 60 60))
2221 (day . ,(* 24 60 60))
2225 "Mapping from time units to seconds.")
2227 (defun article-date-ut (&optional type highlight header)
2228 "Convert DATE date to universal time in the current article.
2229 If TYPE is `local', convert to local time; if it is `lapsed', output
2230 how much time has lapsed since DATE. For `lapsed', the value of
2231 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2232 should replace the \"Date:\" one, or should be added below it."
2233 (interactive (list 'ut t))
2234 (let* ((header (or header
2235 (message-fetch-field "date")
2237 (tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2240 ((not gnus-article-date-lapsed-new-header)
2246 (date (if (vectorp header) (mail-header-date header)
2248 (inhibit-point-motion-hooks t)
2253 (article-narrow-to-head)
2254 (when (re-search-forward tdate-regexp nil t)
2255 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2256 date (or (get-text-property (gnus-point-at-bol)
2259 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
2261 (when (and date (not (string= date "")))
2262 (goto-char (point-min))
2263 (let ((buffer-read-only nil))
2264 ;; Delete any old Date headers.
2265 (while (re-search-forward date-regexp nil t)
2267 (delete-region (progn (beginning-of-line) (point))
2268 (progn (forward-line 1) (point)))
2269 (delete-region (progn (beginning-of-line) (point))
2270 (progn (end-of-line) (point)))
2271 (setq pos (point))))
2272 (when (and (not pos) (re-search-forward tdate-regexp nil t))
2274 (if pos (goto-char pos))
2275 (insert (article-make-date-line date (or type 'ut)))
2281 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2282 (put-text-property (match-beginning 1) (1+ (match-end 1))
2283 'original-date date)
2284 (put-text-property (match-beginning 1) (1+ (match-end 1))
2286 (put-text-property (match-beginning 2) (match-end 2)
2289 (defun article-make-date-line (date type)
2290 "Return a DATE line of TYPE."
2291 (unless (memq type '(local ut original user iso8601 lapsed english))
2292 (error "Unknown conversion type: %s" type))
2294 (let ((time (date-to-time date)))
2296 ;; Convert to the local timezone.
2298 (let ((tz (car (current-time-zone time))))
2299 (format "Date: %s %s%02d%02d" (current-time-string time)
2300 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2301 (/ (% (abs tz) 3600) 60))))
2302 ;; Convert to Universal Time.
2305 (current-time-string
2306 (let* ((e (parse-time-string date))
2307 (tm (apply 'encode-time e))
2309 (ls (- (cadr tm) (car (current-time-zone time)))))
2310 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2311 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2314 ;; Get the original date from the article.
2315 ((eq type 'original)
2316 (concat "Date: " (if (string-match "\n+$" date)
2317 (substring date 0 (match-beginning 0))
2319 ;; Let the user define the format.
2321 (if (gnus-functionp gnus-article-time-format)
2322 (funcall gnus-article-time-format time)
2325 (format-time-string gnus-article-time-format time))))
2328 (let ((tz (car (current-time-zone time))))
2331 (format-time-string "%Y%m%dT%H%M%S" time)
2332 (format "%s%02d%02d"
2333 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2334 (/ (% (abs tz) 3600) 60)))))
2335 ;; Do an X-Sent lapsed format.
2337 ;; If the date is seriously mangled, the timezone functions are
2338 ;; liable to bug out, so we ignore all errors.
2339 (let* ((now (current-time))
2340 (real-time (subtract-time now time))
2341 (real-sec (and real-time
2342 (+ (* (float (car real-time)) 65536)
2344 (sec (and real-time (abs real-sec)))
2354 ;; This is a bit convoluted, but basically we go
2355 ;; through the time units for years, weeks, etc,
2356 ;; and divide things to see whether that results
2357 ;; in positive answers.
2360 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2361 ;; The (remaining) seconds are too few to
2362 ;; be divided into this time unit.
2364 ;; It's big enough, so we output it.
2365 (setq sec (- sec (* num (cdr unit))))
2367 (concat (if prev ", " "") (int-to-string
2369 " " (symbol-name (car unit))
2370 (if (> num 1) "s" ""))
2372 article-time-units "")
2373 ;; If dates are odd, then it might appear like the
2374 ;; article was sent in the future.
2377 " in the future"))))))
2378 ;; Display the date in proper English
2380 (let ((dtime (decode-time time)))
2383 (number-to-string (nth 3 dtime))
2384 (let ((digit (% (nth 3 dtime) 10)))
2386 ((memq (nth 3 dtime) '(11 12 13)) "th")
2392 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2394 (number-to-string (nth 5 dtime))
2396 (format "%02d" (nth 2 dtime))
2398 (format "%02d" (nth 1 dtime)))))))
2400 (format "Date: %s (from Oort)" date))))
2402 (defun article-date-local (&optional highlight)
2403 "Convert the current article date to the local timezone."
2404 (interactive (list t))
2405 (article-date-ut 'local highlight))
2407 (defun article-date-english (&optional highlight)
2408 "Convert the current article date to something that is proper English."
2409 (interactive (list t))
2410 (article-date-ut 'english highlight))
2412 (defun article-date-original (&optional highlight)
2413 "Convert the current article date to what it was originally.
2414 This is only useful if you have used some other date conversion
2415 function and want to see what the date was before converting."
2416 (interactive (list t))
2417 (article-date-ut 'original highlight))
2419 (defun article-date-lapsed (&optional highlight)
2420 "Convert the current article date to time lapsed since it was sent."
2421 (interactive (list t))
2422 (article-date-ut 'lapsed highlight))
2424 (defun article-update-date-lapsed ()
2425 "Function to be run from a timer to update the lapsed time line."
2426 (let (deactivate-mark)
2431 (set-buffer (window-buffer w))
2432 (when (eq major-mode 'gnus-article-mode)
2433 (goto-char (point-min))
2434 (when (re-search-forward "^X-Sent:" nil t)
2435 (article-date-lapsed t))))
2438 (defun gnus-start-date-timer (&optional n)
2439 "Start a timer to update the X-Sent header in the article buffers.
2440 The numerical prefix says how frequently (in seconds) the function
2445 (gnus-stop-date-timer)
2446 (setq article-lapsed-timer
2447 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2449 (defun gnus-stop-date-timer ()
2450 "Stop the X-Sent timer."
2452 (when article-lapsed-timer
2453 (nnheader-cancel-timer article-lapsed-timer)
2454 (setq article-lapsed-timer nil)))
2456 (defun article-date-user (&optional highlight)
2457 "Convert the current article date to the user-defined format.
2458 This format is defined by the `gnus-article-time-format' variable."
2459 (interactive (list t))
2460 (article-date-ut 'user highlight))
2462 (defun article-date-iso8601 (&optional highlight)
2463 "Convert the current article date to ISO8601."
2464 (interactive (list t))
2465 (article-date-ut 'iso8601 highlight))
2467 (defun article-show-all ()
2468 "Show all hidden text in the article buffer."
2471 (let ((buffer-read-only nil))
2472 (gnus-article-unhide-text (point-min) (point-max)))))
2474 (defun article-remove-leading-whitespace ()
2475 "Remove excessive whitespace from all headers."
2479 (let ((buffer-read-only nil))
2480 (article-narrow-to-head)
2481 (goto-char (point-min))
2482 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
2483 (delete-region (match-beginning 1) (match-end 1)))))))
2485 (defun article-emphasize (&optional arg)
2486 "Emphasize text according to `gnus-emphasis-alist'."
2487 (interactive (gnus-article-hidden-arg))
2488 (unless (gnus-article-check-hidden-text 'emphasis arg)
2492 (with-current-buffer gnus-summary-buffer
2493 gnus-article-emphasis-alist)
2495 gnus-emphasis-alist))
2496 (buffer-read-only nil)
2497 (props (append '(article-type emphasis)
2498 gnus-hidden-properties))
2499 regexp elem beg invisible visible face)
2502 (while (setq elem (pop alist))
2504 (setq regexp (car elem)
2505 invisible (nth 1 elem)
2506 visible (nth 2 elem)
2508 (while (re-search-forward regexp nil t)
2509 (when (and (match-beginning visible) (match-beginning invisible))
2510 (gnus-article-hide-text
2511 (match-beginning invisible) (match-end invisible) props)
2512 (gnus-article-unhide-text-type
2513 (match-beginning visible) (match-end visible) 'emphasis)
2514 (gnus-put-text-property-excluding-newlines
2515 (match-beginning visible) (match-end visible) 'face face)
2516 (push 'emphasis gnus-article-wash-types)
2517 (goto-char (match-end invisible)))))))))
2519 (defun gnus-article-setup-highlight-words (&optional highlight-words)
2520 "Setup newsgroup emphasis alist."
2521 (unless gnus-article-emphasis-alist
2522 (let ((name (and gnus-newsgroup-name
2523 (gnus-group-real-name gnus-newsgroup-name))))
2524 (make-local-variable 'gnus-article-emphasis-alist)
2525 (setq gnus-article-emphasis-alist
2527 (let ((alist gnus-group-highlight-words-alist) elem highlight)
2528 (while (setq elem (pop alist))
2529 (when (and name (string-match (car elem) name))
2531 highlight (copy-sequence (cdr elem)))))
2533 (copy-sequence highlight-words)
2534 (if gnus-newsgroup-name
2535 (copy-sequence (gnus-group-find-parameter
2536 gnus-newsgroup-name 'highlight-words t)))
2537 gnus-emphasis-alist)))))
2540 (defvar gnus-summary-article-menu)
2541 (defvar gnus-summary-post-menu))
2543 ;;; Saving functions.
2545 (defun gnus-article-save (save-buffer file &optional num)
2546 "Save the currently selected article."
2547 (unless gnus-save-all-headers
2548 ;; Remove headers according to `gnus-saved-headers'.
2549 (let ((gnus-visible-headers
2550 (or gnus-saved-headers gnus-visible-headers))
2551 (gnus-article-buffer save-buffer))
2553 (set-buffer save-buffer)
2554 (article-hide-headers 1 t))))
2555 (save-window-excursion
2556 (if (not gnus-default-article-saver)
2557 (error "No default saver is defined")
2558 ;; !!! Magic! The saving functions all save
2559 ;; `gnus-save-article-buffer' (or so they think), but we
2560 ;; bind that variable to our save-buffer.
2561 (set-buffer gnus-article-buffer)
2562 (let* ((gnus-save-article-buffer save-buffer)
2565 ((not gnus-prompt-before-saving) 'default)
2566 ((eq gnus-prompt-before-saving 'always) nil)
2568 (gnus-number-of-articles-to-be-saved
2569 (when (eq gnus-prompt-before-saving t)
2571 (set-buffer gnus-article-current-summary)
2572 (funcall gnus-default-article-saver filename)))))
2574 (defun gnus-read-save-file-name (prompt &optional filename
2575 function group headers variable)
2577 (funcall function group headers (symbol-value variable)))
2582 ((eq filename 'default)
2588 (let* ((split-name (gnus-get-split-value gnus-split-methods))
2591 (if (and gnus-number-of-articles-to-be-saved
2592 (> gnus-number-of-articles-to-be-saved 1))
2593 (format "these %d articles"
2594 gnus-number-of-articles-to-be-saved)
2597 ;; Let the split methods have their say.
2599 ;; No split name was found.
2602 (concat prompt " (default "
2603 (file-name-nondirectory default-name) ") ")
2604 (file-name-directory default-name)
2606 ;; A single group name is returned.
2607 ((stringp split-name)
2609 (funcall function split-name headers
2610 (symbol-value variable)))
2612 (concat prompt " (default "
2613 (file-name-nondirectory default-name) ") ")
2614 (file-name-directory default-name)
2616 ;; A single split name was found
2617 ((= 1 (length split-name))
2618 (let* ((name (expand-file-name
2620 gnus-article-save-directory))
2621 (dir (cond ((file-directory-p name)
2622 (file-name-as-directory name))
2623 ((file-exists-p name) name)
2624 (t gnus-article-save-directory))))
2626 (concat prompt " (default " name ") ")
2628 ;; A list of splits was found.
2630 (setq split-name (nreverse split-name))
2632 (let ((file-name-history
2633 (nconc split-name file-name-history)))
2637 (concat prompt " (`M-p' for defaults) ")
2638 gnus-article-save-directory
2640 gnus-article-save-directory)))
2641 (car (push result file-name-history)))))))
2642 ;; Create the directory.
2643 (gnus-make-directory (file-name-directory file))
2644 ;; If we have read a directory, we append the default file name.
2645 (when (file-directory-p file)
2646 (setq file (expand-file-name (file-name-nondirectory
2648 (file-name-as-directory file))))
2649 ;; Possibly translate some characters.
2650 (nnheader-translate-file-chars file))))))
2651 (gnus-make-directory (file-name-directory result))
2652 (set variable result)))
2654 (defun gnus-article-archive-name (group)
2655 "Return the first instance of an \"Archive-name\" in the current buffer."
2656 (let ((case-fold-search t))
2657 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
2658 (nnheader-concat gnus-article-save-directory
2659 (match-string 1)))))
2661 (defun gnus-article-nndoc-name (group)
2662 "If GROUP is an nndoc group, return the name of the parent group."
2663 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
2664 (gnus-group-get-parameter group 'save-article-group)))
2666 (defun gnus-summary-save-in-rmail (&optional filename)
2667 "Append this article to Rmail file.
2668 Optional argument FILENAME specifies file name.
2669 Directory to save to is default to `gnus-article-save-directory'."
2670 (setq filename (gnus-read-save-file-name
2671 "Save %s in rmail file:" filename
2672 gnus-rmail-save-name gnus-newsgroup-name
2673 gnus-current-headers 'gnus-newsgroup-last-rmail))
2674 (gnus-eval-in-buffer-window gnus-save-article-buffer
2678 (gnus-output-to-rmail filename))))
2681 (defun gnus-summary-save-in-mail (&optional filename)
2682 "Append this article to Unix mail file.
2683 Optional argument FILENAME specifies file name.
2684 Directory to save to is default to `gnus-article-save-directory'."
2685 (setq filename (gnus-read-save-file-name
2686 "Save %s in Unix mail file:" filename
2687 gnus-mail-save-name gnus-newsgroup-name
2688 gnus-current-headers 'gnus-newsgroup-last-mail))
2689 (gnus-eval-in-buffer-window gnus-save-article-buffer
2693 (if (and (file-readable-p filename)
2694 (mail-file-babyl-p filename))
2695 (rmail-output-to-rmail-file filename t)
2696 (gnus-output-to-mail filename)))))
2699 (defun gnus-summary-save-in-file (&optional filename overwrite)
2700 "Append this article to file.
2701 Optional argument FILENAME specifies file name.
2702 Directory to save to is default to `gnus-article-save-directory'."
2703 (setq filename (gnus-read-save-file-name
2704 "Save %s in file:" filename
2705 gnus-file-save-name gnus-newsgroup-name
2706 gnus-current-headers 'gnus-newsgroup-last-file))
2707 (gnus-eval-in-buffer-window gnus-save-article-buffer
2711 (when (and overwrite
2712 (file-exists-p filename))
2713 (delete-file filename))
2714 (gnus-output-to-file filename))))
2717 (defun gnus-summary-write-to-file (&optional filename)
2718 "Write this article to a file, overwriting it if the file exists.
2719 Optional argument FILENAME specifies file name.
2720 The directory to save in defaults to `gnus-article-save-directory'."
2721 (gnus-summary-save-in-file nil t))
2723 (defun gnus-summary-save-body-in-file (&optional filename)
2724 "Append this article body to a file.
2725 Optional argument FILENAME specifies file name.
2726 The directory to save in defaults to `gnus-article-save-directory'."
2727 (setq filename (gnus-read-save-file-name
2728 "Save %s body in file:" filename
2729 gnus-file-save-name gnus-newsgroup-name
2730 gnus-current-headers 'gnus-newsgroup-last-file))
2731 (gnus-eval-in-buffer-window gnus-save-article-buffer
2735 (when (article-goto-body)
2736 (narrow-to-region (point) (point-max)))
2737 (gnus-output-to-file filename))))
2740 (defun gnus-summary-save-in-pipe (&optional command)
2741 "Pipe this article to subprocess."
2743 (cond ((and (eq command 'default)
2744 gnus-last-shell-command)
2745 gnus-last-shell-command)
2750 "Shell command on %s: "
2751 (if (and gnus-number-of-articles-to-be-saved
2752 (> gnus-number-of-articles-to-be-saved 1))
2753 (format "these %d articles"
2754 gnus-number-of-articles-to-be-saved)
2756 gnus-last-shell-command))))
2757 (when (string-equal command "")
2758 (if gnus-last-shell-command
2759 (setq command gnus-last-shell-command)
2760 (error "A command is required")))
2761 (gnus-eval-in-buffer-window gnus-article-buffer
2764 (shell-command-on-region (point-min) (point-max) command nil)))
2765 (setq gnus-last-shell-command command))
2767 (defun gnus-summary-pipe-to-muttprint (&optional command)
2768 "Pipe this article to muttprint."
2769 (setq command (read-string
2770 "Print using command: " gnus-summary-muttprint-program
2771 nil gnus-summary-muttprint-program))
2772 (gnus-summary-save-in-pipe command))
2774 ;;; Article file names when saving.
2776 (defun gnus-capitalize-newsgroup (newsgroup)
2777 "Capitalize NEWSGROUP name."
2778 (when (not (zerop (length newsgroup)))
2779 (concat (char-to-string (upcase (aref newsgroup 0)))
2780 (substring newsgroup 1))))
2782 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2783 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2784 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
2785 Otherwise, it is like ~/News/news/group/num."
2788 (concat (if (gnus-use-long-file-name 'not-save)
2789 (gnus-capitalize-newsgroup newsgroup)
2790 (gnus-newsgroup-directory-form newsgroup))
2791 "/" (int-to-string (mail-header-number headers)))
2792 gnus-article-save-directory)))
2794 (string-equal (file-name-directory default)
2795 (file-name-directory last-file))
2796 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2798 (or last-file default))))
2800 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2801 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2802 If variable `gnus-use-long-file-name' is non-nil, it is
2803 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2806 (concat (if (gnus-use-long-file-name 'not-save)
2808 (gnus-newsgroup-directory-form newsgroup))
2809 "/" (int-to-string (mail-header-number headers)))
2810 gnus-article-save-directory)))
2812 (string-equal (file-name-directory default)
2813 (file-name-directory last-file))
2814 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2816 (or last-file default))))
2818 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2819 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2820 If variable `gnus-use-long-file-name' is non-nil, it is
2821 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2824 (if (gnus-use-long-file-name 'not-save)
2827 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
2829 gnus-article-save-directory)))
2831 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
2832 "Generate file name from sender."
2833 (let ((from (mail-header-from headers)))
2835 (if (and from (string-match "\\([^ <]+\\)@" from))
2836 (match-string 1 from)
2838 gnus-article-save-directory)))
2840 (defun article-verify-x-pgp-sig ()
2843 (if (gnus-buffer-live-p gnus-original-article-buffer)
2844 (let ((sig (with-current-buffer gnus-original-article-buffer
2845 (gnus-fetch-field "X-PGP-Sig")))
2849 (mml2015-clear-verify-function))
2851 (insert-buffer gnus-original-article-buffer)
2852 (setq items (split-string sig))
2853 (message-narrow-to-head)
2854 (let ((inhibit-point-motion-hooks t)
2855 (case-fold-search t))
2856 ;; Don't verify multiple headers.
2857 (setq headers (mapconcat (lambda (header)
2859 (mail-fetch-field header) "\n"))
2860 (split-string (nth 1 items) ",") "")))
2861 (delete-region (point-min) (point-max))
2862 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
2863 (insert "X-Signed-Headers: " (nth 1 items) "\n")
2868 (if (looking-at "^-")
2871 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
2872 (insert "Version: " (car items) "\n\n")
2873 (insert (mapconcat 'identity (cddr items) "\n"))
2874 (insert "\n-----END PGP SIGNATURE-----\n")
2875 (let ((mm-security-handle (list (format "multipart/signed"))))
2876 (mml2015-clean-buffer)
2877 (let ((coding-system-for-write (or gnus-newsgroup-charset
2879 (funcall (mml2015-clear-verify-function)))
2881 (or (mm-handle-multipart-ctl-parameter
2882 mm-security-handle 'gnus-details)
2883 (mm-handle-multipart-ctl-parameter
2884 mm-security-handle 'gnus-info)))))
2886 (let (buffer-read-only bface eface)
2888 (message-narrow-to-head)
2889 (goto-char (point-max))
2891 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2892 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
2893 (message-remove-header "X-Gnus-PGP-Verify")
2894 (if (re-search-forward "^X-PGP-Sig:" nil t)
2896 (goto-char (point-max)))
2897 (narrow-to-region (point) (point))
2898 (insert "X-Gnus-PGP-Verify: " info "\n")
2899 (goto-char (point-min))
2902 (if (not (looking-at "^[ \t]"))
2906 (goto-char (point-min))
2907 (when (looking-at "\\([^:]+\\): *")
2908 (put-text-property (match-beginning 1) (1+ (match-end 1))
2910 (put-text-property (match-end 0) (point-max)
2911 'face eface)))))))))
2913 (defun article-verify-cancel-lock ()
2914 "Verify Cancel-Lock header."
2916 (if (gnus-buffer-live-p gnus-original-article-buffer)
2917 (canlock-verify gnus-original-article-buffer)))
2924 (setq afunc (car func)
2927 gfunc (intern (format "gnus-%s" func))))
2930 `(lambda (&optional interactive &rest args)
2931 ,(documentation afunc t)
2932 (interactive (list t))
2934 (set-buffer gnus-article-buffer)
2936 (call-interactively ',afunc)
2937 (apply ',afunc args))))))))
2938 '(article-hide-headers
2939 article-verify-x-pgp-sig
2940 article-verify-cancel-lock
2941 article-hide-boring-headers
2942 article-treat-overstrike
2943 article-fill-long-lines
2944 article-capitalize-sentences
2946 article-remove-leading-whitespace
2947 article-display-x-face
2948 article-de-quoted-unreadable
2949 article-de-base64-unreadable
2952 article-hide-list-identifiers
2954 article-strip-banner
2957 article-hide-signature
2958 article-strip-headers-in-body
2959 article-remove-trailing-blank-lines
2960 article-strip-leading-blank-lines
2961 article-strip-multiple-blank-lines
2962 article-strip-leading-space
2963 article-strip-trailing-space
2964 article-strip-blank-lines
2965 article-strip-all-blank-lines
2966 article-replace-with-quoted-text
2968 article-date-english
2969 article-date-iso8601
2970 article-date-original
2972 article-decode-mime-words
2973 article-decode-charset
2974 article-decode-encoded-words
2978 article-treat-dumbquotes
2979 article-normalize-headers
2980 (article-show-all . gnus-article-show-all-headers))))
2983 ;;; Gnus article mode
2986 (put 'gnus-article-mode 'mode-class 'special)
2988 (set-keymap-parent gnus-article-mode-map widget-keymap)
2990 (gnus-define-keys gnus-article-mode-map
2991 " " gnus-article-goto-next-page
2992 "\177" gnus-article-goto-prev-page
2993 [delete] gnus-article-goto-prev-page
2994 [backspace] gnus-article-goto-prev-page
2995 "\C-c^" gnus-article-refer-article
2996 "h" gnus-article-show-summary
2997 "s" gnus-article-show-summary
2998 "\C-c\C-m" gnus-article-mail
2999 "?" gnus-article-describe-briefly
3000 "e" gnus-summary-edit-article
3001 "<" beginning-of-buffer
3003 "\C-c\C-i" gnus-info-find-node
3005 "\C-hk" gnus-article-describe-key
3006 "\C-hc" gnus-article-describe-key-briefly
3008 "\C-d" gnus-article-read-summary-keys
3009 "\M-*" gnus-article-read-summary-keys
3010 "\M-#" gnus-article-read-summary-keys
3011 "\M-^" gnus-article-read-summary-keys
3012 "\M-g" gnus-article-read-summary-keys)
3014 (substitute-key-definition
3015 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3017 (defun gnus-article-make-menu-bar ()
3018 (unless (boundp 'gnus-article-commands-menu)
3019 (gnus-summary-make-menu-bar))
3020 (gnus-turn-off-edit-menu 'article)
3021 (unless (boundp 'gnus-article-article-menu)
3023 gnus-article-article-menu gnus-article-mode-map ""
3025 ["Scroll forwards" gnus-article-goto-next-page t]
3026 ["Scroll backwards" gnus-article-goto-prev-page t]
3027 ["Show summary" gnus-article-show-summary t]
3028 ["Fetch Message-ID at point" gnus-article-refer-article t]
3029 ["Mail to address at point" gnus-article-mail t]
3030 ["Send a bug report" gnus-bug t]))
3033 gnus-article-treatment-menu gnus-article-mode-map ""
3034 ;; Fixme: this should use :active (and maybe :visible).
3036 ["Hide headers" gnus-article-hide-headers t]
3037 ["Hide signature" gnus-article-hide-signature t]
3038 ["Hide citation" gnus-article-hide-citation t]
3039 ["Treat overstrike" gnus-article-treat-overstrike t]
3040 ["Remove carriage return" gnus-article-remove-cr t]
3041 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3042 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3043 ["Remove base64" gnus-article-de-base64-unreadable t]
3044 ["Treat html" gnus-article-wash-html t]
3045 ["Decode HZ" gnus-article-decode-HZ t]))
3047 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3049 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3051 (gnus-run-hooks 'gnus-article-menu-hook)))
3053 ;; Fixme: do something for the Emacs tool bar in Article mode a la
3056 (defun gnus-article-mode ()
3057 "Major mode for displaying an article.
3059 All normal editing commands are switched off.
3061 The following commands are available in addition to all summary mode
3063 \\<gnus-article-mode-map>
3064 \\[gnus-article-next-page]\t Scroll the article one page forwards
3065 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3066 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3067 \\[gnus-article-show-summary]\t Display the summary buffer
3068 \\[gnus-article-mail]\t Send a reply to the address near point
3069 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3070 \\[gnus-info-find-node]\t Go to the Gnus info node"
3072 (gnus-simplify-mode-line)
3073 (setq mode-name "Article")
3074 (setq major-mode 'gnus-article-mode)
3075 (make-local-variable 'minor-mode-alist)
3076 (use-local-map gnus-article-mode-map)
3077 (when (gnus-visual-p 'article-menu 'menu)
3078 (gnus-article-make-menu-bar))
3079 (gnus-update-format-specifications nil 'article-mode)
3080 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3081 (make-local-variable 'gnus-page-broken)
3082 (make-local-variable 'gnus-button-marker-list)
3083 (make-local-variable 'gnus-article-current-summary)
3084 (make-local-variable 'gnus-article-mime-handles)
3085 (make-local-variable 'gnus-article-decoded-p)
3086 (make-local-variable 'gnus-article-mime-handle-alist)
3087 (make-local-variable 'gnus-article-wash-types)
3088 (make-local-variable 'gnus-article-charset)
3089 (make-local-variable 'gnus-article-ignored-charsets)
3090 (gnus-set-default-directory)
3091 (buffer-disable-undo)
3092 (setq buffer-read-only t)
3093 (set-syntax-table gnus-article-mode-syntax-table)
3094 (mm-enable-multibyte)
3095 (gnus-run-hooks 'gnus-article-mode-hook))
3097 (defun gnus-article-setup-buffer ()
3098 "Initialize the article buffer."
3099 (let* ((name (if gnus-single-article-buffer "*Article*"
3100 (concat "*Article " gnus-newsgroup-name "*")))
3102 (progn (string-match "\\*Article" name)
3103 (concat " *Original Article"
3104 (substring name (match-end 0))))))
3105 (setq gnus-article-buffer name)
3106 (setq gnus-original-article-buffer original)
3107 (setq gnus-article-mime-handle-alist nil)
3108 ;; This might be a variable local to the summary buffer.
3109 (unless gnus-single-article-buffer
3111 (set-buffer gnus-summary-buffer)
3112 (setq gnus-article-buffer name)
3113 (setq gnus-original-article-buffer original)
3114 (gnus-set-global-variables)))
3115 (gnus-article-setup-highlight-words)
3116 ;; Init original article buffer.
3118 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3119 (mm-enable-multibyte)
3120 (setq major-mode 'gnus-original-article-mode)
3121 (make-local-variable 'gnus-original-article))
3122 (if (get-buffer name)
3125 (when gnus-article-mime-handles
3126 (mm-destroy-parts gnus-article-mime-handles)
3127 (setq gnus-article-mime-handles nil))
3128 ;; Set it to nil in article-buffer!
3129 (setq gnus-article-mime-handle-alist nil)
3130 (buffer-disable-undo)
3131 (setq buffer-read-only t)
3132 (unless (eq major-mode 'gnus-article-mode)
3133 (gnus-article-mode))
3136 (set-buffer (gnus-get-buffer-create name))
3138 (make-local-variable 'gnus-summary-buffer)
3139 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3140 (current-buffer)))))
3142 ;; Set article window start at LINE, where LINE is the number of lines
3143 ;; from the head of the article.
3144 (defun gnus-article-set-window-start (&optional line)
3146 (gnus-get-buffer-window gnus-article-buffer t)
3148 (set-buffer gnus-article-buffer)
3149 (goto-char (point-min))
3152 (gnus-message 6 "Moved to bookmark")
3153 (search-forward "\n\n" nil t)
3157 (defun gnus-article-prepare (article &optional all-headers header)
3158 "Prepare ARTICLE in article mode buffer.
3159 ARTICLE should either be an article number or a Message-ID.
3160 If ARTICLE is an id, HEADER should be the article headers.
3161 If ALL-HEADERS is non-nil, no headers are hidden."
3163 ;; Make sure we start in a summary buffer.
3164 (unless (eq major-mode 'gnus-summary-mode)
3165 (set-buffer gnus-summary-buffer))
3166 (setq gnus-summary-buffer (current-buffer))
3167 (let* ((gnus-article (if header (mail-header-number header) article))
3168 (summary-buffer (current-buffer))
3169 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3170 (group gnus-newsgroup-name)
3173 (gnus-article-setup-buffer)
3174 (set-buffer gnus-article-buffer)
3175 ;; Deactivate active regions.
3176 (when (and (boundp 'transient-mark-mode)
3177 transient-mark-mode)
3178 (setq mark-active nil))
3179 (if (not (setq result (let ((buffer-read-only nil))
3180 (gnus-request-article-this-buffer
3182 ;; There is no such article.
3184 (when (and (numberp article)
3185 (not (memq article gnus-newsgroup-sparse)))
3186 (setq gnus-article-current
3187 (cons gnus-newsgroup-name article))
3188 (set-buffer gnus-summary-buffer)
3189 (setq gnus-current-article article)
3190 (if (eq (gnus-article-mark article) gnus-undownloaded-mark)
3192 (gnus-summary-set-agent-mark article)
3193 (message "Message marked for downloading"))
3194 (gnus-summary-mark-article article gnus-canceled-mark)
3195 (unless (memq article gnus-newsgroup-sparse)
3196 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3197 (if (or (eq result 'pseudo)
3198 (eq result 'nneething))
3201 (set-buffer summary-buffer)
3202 (push article gnus-newsgroup-history)
3203 (setq gnus-last-article gnus-current-article
3204 gnus-current-article 0
3205 gnus-current-headers nil
3206 gnus-article-current nil)
3207 (if (eq result 'nneething)
3208 (gnus-configure-windows 'summary)
3209 (gnus-configure-windows 'article))
3210 (gnus-set-global-variables))
3211 (let ((gnus-article-mime-handle-alist-1
3212 gnus-article-mime-handle-alist))
3213 (gnus-set-mode-line 'article)))
3214 ;; The result from the `request' was an actual article -
3215 ;; or at least some text that is now displayed in the
3217 (when (and (numberp article)
3218 (not (eq article gnus-current-article)))
3219 ;; Seems like a new article has been selected.
3220 ;; `gnus-current-article' must be an article number.
3222 (set-buffer summary-buffer)
3223 (push article gnus-newsgroup-history)
3224 (setq gnus-last-article gnus-current-article
3225 gnus-current-article article
3226 gnus-current-headers
3227 (gnus-summary-article-header gnus-current-article)
3228 gnus-article-current
3229 (cons gnus-newsgroup-name gnus-current-article))
3230 (unless (vectorp gnus-current-headers)
3231 (setq gnus-current-headers nil))
3232 (gnus-summary-goto-subject gnus-current-article)
3233 (when (gnus-summary-show-thread)
3234 ;; If the summary buffer really was folded, the
3235 ;; previous goto may not actually have gone to
3236 ;; the right article, but the thread root instead.
3238 (gnus-summary-goto-subject gnus-current-article))
3239 (gnus-run-hooks 'gnus-mark-article-hook)
3240 (gnus-set-mode-line 'summary)
3241 (when (gnus-visual-p 'article-highlight 'highlight)
3242 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3243 ;; Set the global newsgroup variables here.
3244 (gnus-set-global-variables)
3245 (setq gnus-have-all-headers
3246 (or all-headers gnus-show-all-headers))))
3248 (gnus-configure-windows 'article))
3249 (when (or (numberp article)
3251 (gnus-article-prepare-display)
3253 (goto-char (point-min))
3254 (setq gnus-page-broken
3255 (when gnus-break-pages
3256 (gnus-narrow-to-page)
3258 (let ((gnus-article-mime-handle-alist-1
3259 gnus-article-mime-handle-alist))
3260 (gnus-set-mode-line 'article))
3262 (set-window-point (get-buffer-window (current-buffer)) (point))
3263 (gnus-configure-windows 'article)
3267 (defun gnus-article-prepare-display ()
3268 "Make the current buffer look like a nice article."
3269 ;; Hooks for getting information from the article.
3270 ;; This hook must be called before being narrowed.
3271 (let ((gnus-article-buffer (current-buffer))
3273 (unless (eq major-mode 'gnus-article-mode)
3274 (gnus-article-mode))
3275 (setq buffer-read-only nil
3276 gnus-article-wash-types nil)
3277 (gnus-run-hooks 'gnus-tmp-internal-hook)
3278 (when gnus-display-mime-function
3279 (funcall gnus-display-mime-function))
3280 (gnus-run-hooks 'gnus-article-prepare-hook)))
3283 ;;; Gnus MIME viewing functions
3286 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3287 "The following specs can be used:
3289 %T MIME type, along with additional info
3290 %n The `name' parameter
3291 %d The description, if any
3292 %l The length of the encoded part
3293 %p The part identifier number
3294 %e Dots if the part isn't displayed")
3296 (defvar gnus-mime-button-line-format-alist
3297 '((?t gnus-tmp-type ?s)
3298 (?T gnus-tmp-type-long ?s)
3299 (?n gnus-tmp-name ?s)
3300 (?d gnus-tmp-description ?s)
3302 (?l gnus-tmp-length ?d)
3303 (?e gnus-tmp-dots ?s)))
3305 (defvar gnus-mime-button-commands
3306 '((gnus-article-press-button "\r" "Toggle Display")
3307 (gnus-mime-view-part "v" "View Interactively...")
3308 (gnus-mime-view-part-as-type "t" "View As Type...")
3309 (gnus-mime-view-part-as-charset "C" "View As charset...")
3310 (gnus-mime-save-part "o" "Save...")
3311 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
3312 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
3313 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
3314 (gnus-mime-internalize-part "E" "View Internally")
3315 (gnus-mime-externalize-part "e" "View Externally")
3316 (gnus-mime-pipe-part "|" "Pipe To Command...")
3317 (gnus-mime-action-on-part "." "Take action on the part")))
3319 (defun gnus-article-mime-part-status ()
3320 (if gnus-article-mime-handle-alist-1
3321 (if (eq 1 (length gnus-article-mime-handle-alist-1))
3323 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
3326 (defvar gnus-mime-button-map
3327 (let ((map (make-sparse-keymap)))
3328 (unless (>= (string-to-number emacs-version) 21)
3329 ;; XEmacs doesn't care.
3330 (set-keymap-parent map gnus-article-mode-map))
3331 (define-key map gnus-mouse-2 'gnus-article-push-button)
3332 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
3333 (dolist (c gnus-mime-button-commands)
3334 (define-key map (cadr c) (car c)))
3337 (defun gnus-mime-button-menu (event)
3338 "Construct a context-sensitive menu of MIME commands."
3340 (save-window-excursion
3341 (let ((pos (event-start event)))
3342 (select-window (posn-window pos))
3343 (goto-char (posn-point pos))
3344 (gnus-article-check-buffer)
3345 (let ((response (x-popup-menu
3347 ("" ,@(mapcar (lambda (c)
3348 (cons (caddr c) (car c)))
3349 gnus-mime-button-commands))))))
3351 (call-interactively response))))))
3353 (defun gnus-mime-view-all-parts (&optional handles)
3354 "View all the MIME parts."
3356 (save-current-buffer
3357 (set-buffer gnus-article-buffer)
3358 (let ((handles (or handles gnus-article-mime-handles))
3359 (mail-parse-charset gnus-newsgroup-charset)
3360 (mail-parse-ignored-charsets
3361 (with-current-buffer gnus-summary-buffer
3362 gnus-newsgroup-ignored-charsets)))
3364 (mm-remove-parts handles)
3365 (goto-char (point-min))
3366 (or (search-forward "\n\n") (goto-char (point-max)))
3367 (let (buffer-read-only)
3368 (delete-region (point) (point-max))
3369 (mm-display-parts handles))))))
3371 (defun gnus-mime-save-part-and-strip ()
3372 "Save the MIME part under point then replace it with an external body."
3374 (gnus-article-check-buffer)
3375 (let* ((data (get-text-property (point) 'gnus-data))
3377 (handles gnus-article-mime-handles))
3378 (if (mm-multiple-handles gnus-article-mime-handles)
3379 (error "This function is not implemented"))
3380 (setq file (and data (mm-save-part data)))
3382 (with-current-buffer (mm-handle-buffer data)
3384 (insert "Content-Type: " (mm-handle-media-type data))
3385 (mml-insert-parameter-string (cdr (mm-handle-type data))
3388 (insert "Content-ID: " (message-make-message-id) "\n")
3389 (insert "Content-Transfer-Encoding: binary\n")
3392 (cdr (mm-make-handle nil
3393 `("message/external-body"
3394 (access-type . "LOCAL-FILE")
3396 (set-buffer gnus-summary-buffer)
3397 (gnus-article-edit-article
3400 (let ((mail-parse-charset (or gnus-article-charset
3401 ',gnus-newsgroup-charset))
3402 (mail-parse-ignored-charsets
3403 (or gnus-article-ignored-charsets
3404 ',gnus-newsgroup-ignored-charsets))
3405 (mbl mml-buffer-list))
3406 (setq mml-buffer-list nil)
3407 (insert-buffer gnus-original-article-buffer)
3408 (mime-to-mml ',handles)
3409 (setq gnus-article-mime-handles nil)
3410 (let ((mbl1 mml-buffer-list))
3411 (setq mml-buffer-list mbl)
3412 (set (make-local-variable 'mml-buffer-list) mbl1))
3413 ;; LOCAL argument of add-hook differs between GNU Emacs
3414 ;; and XEmacs. make-local-hook makes sure they are local.
3415 (make-local-hook 'kill-buffer-hook)
3416 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
3417 `(lambda (no-highlight)
3418 (let ((mail-parse-charset (or gnus-article-charset
3419 ',gnus-newsgroup-charset))
3420 (message-options message-options)
3421 (message-options-set-recipient)
3422 (mail-parse-ignored-charsets
3423 (or gnus-article-ignored-charsets
3424 ',gnus-newsgroup-ignored-charsets)))
3426 (mml-destroy-buffers)
3427 (remove-hook 'kill-buffer-hook
3428 'mml-destroy-buffers t)
3429 (kill-local-variable 'mml-buffer-list))
3430 (gnus-summary-edit-article-done
3431 ,(or (mail-header-references gnus-current-headers) "")
3432 ,(gnus-group-read-only-p)
3433 ,gnus-summary-buffer no-highlight))))))
3435 (defun gnus-mime-save-part ()
3436 "Save the MIME part under point."
3438 (gnus-article-check-buffer)
3439 (let ((data (get-text-property (point) 'gnus-data)))
3441 (mm-save-part data))))
3443 (defun gnus-mime-pipe-part ()
3444 "Pipe the MIME part under point to a process."
3446 (gnus-article-check-buffer)
3447 (let ((data (get-text-property (point) 'gnus-data)))
3449 (mm-pipe-part data))))
3451 (defun gnus-mime-view-part ()
3452 "Interactively choose a viewing method for the MIME part under point."
3454 (gnus-article-check-buffer)
3455 (let ((data (get-text-property (point) 'gnus-data)))
3457 (setq gnus-article-mime-handles
3459 gnus-article-mime-handles (setq data (copy-sequence data))))
3460 (mm-interactively-view-part data))))
3462 (defun gnus-mime-view-part-as-type-internal ()
3463 (gnus-article-check-buffer)
3464 (let* ((name (mail-content-type-get
3465 (mm-handle-type (get-text-property (point) 'gnus-data))
3467 (def-type (and name (mm-default-file-encoding name))))
3468 (and def-type (cons def-type 0))))
3470 (defun gnus-mime-view-part-as-type (&optional mime-type)
3471 "Choose a MIME media type, and view the part as such."
3474 (setq mime-type (completing-read
3475 "View as MIME type: "
3476 (mapcar #'list (mailcap-mime-types))
3478 (gnus-mime-view-part-as-type-internal))))
3479 (gnus-article-check-buffer)
3480 (let ((handle (get-text-property (point) 'gnus-data)))
3483 (mm-make-handle (mm-handle-buffer handle)
3484 (cons mime-type (cdr (mm-handle-type handle)))
3485 (mm-handle-encoding handle)
3486 (mm-handle-undisplayer handle)
3487 (mm-handle-disposition handle)
3488 (mm-handle-description handle)
3490 (mm-handle-id handle)))
3491 (setq gnus-article-mime-handles
3492 (mm-merge-handles gnus-article-mime-handles handle))
3493 (gnus-mm-display-part handle))))
3495 (defun gnus-mime-copy-part (&optional handle)
3496 "Put the the MIME part under point into a new buffer."
3498 (gnus-article-check-buffer)
3499 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3500 (contents (and handle (mm-get-part handle)))
3502 (file-name-nondirectory
3504 (mail-content-type-get (mm-handle-type handle) 'name)
3505 (mail-content-type-get (mm-handle-type handle)
3508 (buffer (and base (generate-new-buffer base))))
3510 (switch-to-buffer buffer)
3512 ;; We do it this way to make `normal-mode' set the appropriate mode.
3515 (setq buffer-file-name (expand-file-name base))
3517 (setq buffer-file-name nil))
3518 (goto-char (point-min)))))
3520 (defun gnus-mime-inline-part (&optional handle arg)
3521 "Insert the MIME part under point into the current buffer."
3522 (interactive (list nil current-prefix-arg))
3523 (gnus-article-check-buffer)
3524 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3529 (if (and (not arg) (mm-handle-undisplayer handle))
3530 (mm-remove-part handle)
3531 (setq contents (mm-get-part handle))
3534 (setq charset (or (mail-content-type-get
3535 (mm-handle-type handle) 'charset)
3536 gnus-newsgroup-charset)))
3538 (if (mm-handle-undisplayer handle)
3539 (mm-remove-part handle))
3542 gnus-summary-show-article-charset-alist))
3543 (mm-read-coding-system "Charset: ")))))
3545 (mm-insert-inline handle
3547 (setq charset (mm-charset-to-coding-system
3549 (not (eq charset 'ascii)))
3550 (mm-decode-coding-string contents charset)
3554 (defun gnus-mime-view-part-as-charset (&optional handle arg)
3555 "Insert the MIME part under point into the current buffer using the
3557 (interactive (list nil current-prefix-arg))
3558 (gnus-article-check-buffer)
3559 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3564 (if (mm-handle-undisplayer handle)
3565 (mm-remove-part handle))
3566 (let ((gnus-newsgroup-charset
3568 gnus-summary-show-article-charset-alist))
3569 (mm-read-coding-system "Charset: ")))
3570 (gnus-newsgroup-ignored-charsets 'gnus-all))
3571 (gnus-article-press-button)))))
3573 (defun gnus-mime-externalize-part (&optional handle)
3574 "View the MIME part under point with an external viewer."
3576 (gnus-article-check-buffer)
3577 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3578 (mm-user-display-methods nil)
3579 (mm-inlined-types nil)
3580 (mail-parse-charset gnus-newsgroup-charset)
3581 (mail-parse-ignored-charsets
3582 (save-excursion (set-buffer gnus-summary-buffer)
3583 gnus-newsgroup-ignored-charsets)))
3585 (if (mm-handle-undisplayer handle)
3586 (mm-remove-part handle)
3587 (mm-display-part handle)))))
3589 (defun gnus-mime-internalize-part (&optional handle)
3590 "View the MIME part under point with an internal viewer.
3591 If no internal viewer is available, use an external viewer."
3593 (gnus-article-check-buffer)
3594 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3595 (mm-inlined-types '(".*"))
3596 (mm-inline-large-images t)
3597 (mail-parse-charset gnus-newsgroup-charset)
3598 (mail-parse-ignored-charsets
3599 (save-excursion (set-buffer gnus-summary-buffer)
3600 gnus-newsgroup-ignored-charsets)))
3602 (if (mm-handle-undisplayer handle)
3603 (mm-remove-part handle)
3604 (mm-display-part handle)))))
3606 (defun gnus-mime-action-on-part (&optional action)
3607 "Do something with the MIME attachment at \(point\)."
3609 (list (completing-read "Action: " gnus-mime-action-alist)))
3610 (gnus-article-check-buffer)
3611 (let ((action-pair (assoc action gnus-mime-action-alist)))
3613 (funcall (cdr action-pair)))))
3615 (defun gnus-article-part-wrapper (n function)
3616 (save-current-buffer
3617 (set-buffer gnus-article-buffer)
3618 (when (> n (length gnus-article-mime-handle-alist))
3619 (error "No such part"))
3620 (gnus-article-goto-part n)
3621 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
3622 (funcall function handle))))
3624 (defun gnus-article-pipe-part (n)
3625 "Pipe MIME part N, which is the numerical prefix."
3627 (gnus-article-part-wrapper n 'mm-pipe-part))
3629 (defun gnus-article-save-part (n)
3630 "Save MIME part N, which is the numerical prefix."
3632 (gnus-article-part-wrapper n 'mm-save-part))
3634 (defun gnus-article-interactively-view-part (n)
3635 "View MIME part N interactively, which is the numerical prefix."
3637 (gnus-article-part-wrapper n 'mm-interactively-view-part))
3639 (defun gnus-article-copy-part (n)
3640 "Copy MIME part N, which is the numerical prefix."
3642 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
3644 (defun gnus-article-view-part-as-charset (n)
3645 "Copy MIME part N, which is the numerical prefix."
3647 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
3649 (defun gnus-article-externalize-part (n)
3650 "View MIME part N externally, which is the numerical prefix."
3652 (gnus-article-part-wrapper n 'gnus-mime-externalize-part))
3654 (defun gnus-article-inline-part (n)
3655 "Inline MIME part N, which is the numerical prefix."
3657 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
3659 (defun gnus-article-mime-match-handle-first (condition)
3661 (let ((alist gnus-article-mime-handle-alist) ihandle n)
3662 (while (setq ihandle (pop alist))
3664 ((functionp condition)
3665 (funcall condition (cdr ihandle)))
3666 ((eq condition 'undisplayed)
3667 (not (or (mm-handle-undisplayer (cdr ihandle))
3668 (equal (mm-handle-media-type (cdr ihandle))
3669 "multipart/alternative"))))
3670 ((eq condition 'undisplayed-alternative)
3671 (not (mm-handle-undisplayer (cdr ihandle))))
3673 (gnus-article-goto-part (car ihandle))
3674 (or (not n) (< (car ihandle) n)))
3675 (setq n (car ihandle))))
3679 (defun gnus-article-view-part (&optional n)
3680 "View MIME part N, which is the numerical prefix."
3682 (save-current-buffer
3683 (set-buffer gnus-article-buffer)
3684 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
3685 gnus-article-mime-match-handle-function)))
3686 (when (> n (length gnus-article-mime-handle-alist))
3687 (error "No such part"))
3688 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
3689 (when (gnus-article-goto-part n)
3690 (if (equal (car handle) "multipart/alternative")
3691 (gnus-article-press-button)
3692 (when (eq (gnus-mm-display-part handle) 'internal)
3693 (gnus-set-window-start)))))))
3695 (defsubst gnus-article-mime-total-parts ()
3696 (if (bufferp (car gnus-article-mime-handles))
3698 (1- (length gnus-article-mime-handles))))
3700 (defun gnus-mm-display-part (handle)
3701 "Display HANDLE and fix MIME button."
3702 (let ((id (get-text-property (point) 'gnus-part))
3707 (let ((window (selected-window))
3708 (mail-parse-charset gnus-newsgroup-charset)
3709 (mail-parse-ignored-charsets
3710 (save-excursion (set-buffer gnus-summary-buffer)
3711 gnus-newsgroup-ignored-charsets)))
3714 (let ((win (gnus-get-buffer-window (current-buffer) t))
3717 (select-window win))
3720 (if (mm-handle-displayed-p handle)
3721 ;; This will remove the part.
3722 (mm-display-part handle)
3724 (narrow-to-region (point)
3725 (if (eobp) (point) (1+ (point))))
3726 (mm-display-part handle)
3727 ;; We narrow to the part itself and
3728 ;; then call the treatment functions.
3729 (goto-char (point-min))
3731 (narrow-to-region (point) (point-max))
3734 (gnus-article-mime-total-parts)
3735 (mm-handle-media-type handle)))))
3736 (if (window-live-p window)
3737 (select-window window)))))
3739 (delete-region (gnus-point-at-bol) (progn (forward-line 1) (point)))
3740 (gnus-insert-mime-button
3741 handle id (list (mm-handle-displayed-p handle)))
3742 (goto-char point))))
3744 (defun gnus-article-goto-part (n)
3745 "Go to MIME part N."
3746 (let ((point (text-property-any (point-min) (point-max) 'gnus-part n)))
3748 (goto-char point))))
3750 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
3751 (let ((gnus-tmp-name
3752 (or (mail-content-type-get (mm-handle-type handle) 'name)
3753 (mail-content-type-get (mm-handle-disposition handle) 'filename)
3754 (mail-content-type-get (mm-handle-type handle) 'url)
3756 (gnus-tmp-type (mm-handle-media-type handle))
3757 (gnus-tmp-description
3758 (mail-decode-encoded-word-string (or (mm-handle-description handle)
3761 (if (if displayed (car displayed)
3762 (mm-handle-displayed-p handle))
3764 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
3766 gnus-tmp-type-long b e)
3767 (when (string-match ".*/" gnus-tmp-name)
3768 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
3769 (setq gnus-tmp-type-long (concat gnus-tmp-type
3770 (and (not (equal gnus-tmp-name ""))
3771 (concat "; " gnus-tmp-name))))
3772 (unless (equal gnus-tmp-description "")
3773 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
3778 gnus-mime-button-line-format gnus-mime-button-line-format-alist
3779 `(keymap ,gnus-mime-button-map
3780 ,@(if (>= (string-to-number emacs-version) 21)
3782 (list 'local-map gnus-mime-button-map))
3783 gnus-callback gnus-mm-display-part
3784 gnus-part ,gnus-tmp-id
3785 article-type annotation
3788 (widget-convert-button
3791 :action 'gnus-widget-press-button
3792 :button-keymap gnus-mime-button-map
3794 (lambda (widget/window &optional overlay pos)
3795 ;; Needed to properly clear the message due to a bug in
3796 ;; wid-edit (XEmacs only).
3797 (if (boundp 'help-echo-owns-message)
3798 (setq help-echo-owns-message t))
3800 "%S: %s the MIME part; %S: more options"
3801 (aref gnus-mouse-2 0)
3802 ;; XEmacs will get a single widget arg; Emacs 21 will get
3803 ;; window, overlay, position.
3804 (if (mm-handle-displayed-p
3806 (with-current-buffer (gnus-overlay-buffer overlay)
3807 (widget-get (widget-at (gnus-overlay-start overlay))
3809 (widget-get widget/window :mime-handle)))
3811 (aref gnus-down-mouse-3 0))))))
3813 (defun gnus-widget-press-button (elems el)
3814 (goto-char (widget-get elems :from))
3815 (gnus-article-press-button))
3817 (defvar gnus-displaying-mime nil)
3819 (defun gnus-display-mime (&optional ihandles)
3820 "Display the MIME parts."
3822 (save-selected-window
3823 (let ((window (get-buffer-window gnus-article-buffer))
3826 (select-window window)
3827 ;; We have to do this since selecting the window
3828 ;; may change the point. So we set the window point.
3829 (set-window-point window point)))
3830 (let* ((handles (or ihandles (mm-dissect-buffer) (mm-uu-dissect)))
3831 buffer-read-only handle name type b e display)
3832 (when (and (not ihandles)
3833 (not gnus-displaying-mime))
3834 ;; Top-level call; we clean up.
3835 (when gnus-article-mime-handles
3836 (mm-destroy-parts gnus-article-mime-handles)
3837 (setq gnus-article-mime-handle-alist nil));; A trick.
3838 (setq gnus-article-mime-handles handles)
3839 ;; We allow users to glean info from the handles.
3840 (when gnus-article-mime-part-function
3841 (gnus-mime-part-function handles)))
3843 (or (not (stringp (car handles)))
3846 (when (and (not ihandles)
3847 (not gnus-displaying-mime))
3848 ;; Clean up for mime parts.
3850 (delete-region (point) (point-max)))
3851 (let ((gnus-displaying-mime t))
3852 (gnus-mime-display-part handles)))
3855 (narrow-to-region (point) (point-max))
3856 (gnus-treat-article nil 1 1)
3859 ;; Highlight the headers.
3863 (narrow-to-region (point-min) (point))
3864 (gnus-treat-article 'head))))))))
3866 (defvar gnus-mime-display-multipart-as-mixed nil)
3867 (defvar gnus-mime-display-multipart-alternative-as-mixed nil)
3868 (defvar gnus-mime-display-multipart-related-as-mixed nil)
3870 (defun gnus-mime-display-part (handle)
3873 ((not (stringp (car handle)))
3874 (gnus-mime-display-single handle))
3875 ;; User-defined multipart
3876 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
3877 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
3879 ;; multipart/alternative
3880 ((and (equal (car handle) "multipart/alternative")
3881 (not (or gnus-mime-display-multipart-as-mixed
3882 gnus-mime-display-multipart-alternative-as-mixed)))
3883 (let ((id (1+ (length gnus-article-mime-handle-alist))))
3884 (push (cons id handle) gnus-article-mime-handle-alist)
3885 (gnus-mime-display-alternative (cdr handle) nil nil id)))
3886 ;; multipart/related
3887 ((and (equal (car handle) "multipart/related")
3888 (not (or gnus-mime-display-multipart-as-mixed
3889 gnus-mime-display-multipart-related-as-mixed)))
3890 ;;;!!!We should find the start part, but we just default
3891 ;;;!!!to the first part.
3892 ;;(gnus-mime-display-part (cadr handle))
3893 ;;;!!! Most multipart/related is an HTML message plus images.
3894 ;;;!!! Unfortunately we are unable to let W3 display those
3895 ;;;!!! included images, so we just display it as a mixed multipart.
3896 ;;(gnus-mime-display-mixed (cdr handle))
3897 ;;;!!! No, w3 can display everything just fine.
3898 (gnus-mime-display-part (cadr handle)))
3899 ((equal (car handle) "multipart/signed")
3900 (or (memq 'signed gnus-article-wash-types)
3901 (push 'signed gnus-article-wash-types))
3902 (gnus-mime-display-security handle))
3903 ((equal (car handle) "multipart/encrypted")
3904 (or (memq 'encrypted gnus-article-wash-types)
3905 (push 'encrypted gnus-article-wash-types))
3906 (gnus-mime-display-security handle))
3907 ;; Other multiparts are handled like multipart/mixed.
3909 (gnus-mime-display-mixed (cdr handle)))))
3911 (defun gnus-mime-part-function (handles)
3912 (if (stringp (car handles))
3913 (mapcar 'gnus-mime-part-function (cdr handles))
3914 (funcall gnus-article-mime-part-function handles)))
3916 (defun gnus-mime-display-mixed (handles)
3917 (mapcar 'gnus-mime-display-part handles))
3919 (defun gnus-mime-display-single (handle)
3920 (let ((type (mm-handle-media-type handle))
3921 (ignored gnus-ignored-mime-types)
3928 (when (string-match (pop ignored) type)
3929 (throw 'ignored nil)))
3930 (if (and (setq not-attachment
3931 (and (not (mm-inline-override-p handle))
3932 (or (not (mm-handle-disposition handle))
3933 (equal (car (mm-handle-disposition handle))
3935 (mm-attachment-override-p handle))))
3936 (mm-automatic-display-p handle)
3938 (mm-inlinable-p handle)
3939 (mm-inlined-p handle))
3940 (mm-automatic-external-display-p type)))
3942 (when (equal (mm-handle-media-supertype handle) "text")
3944 (let ((id (1+ (length gnus-article-mime-handle-alist)))
3946 (push (cons id handle) gnus-article-mime-handle-alist)
3947 (when (or (not display)
3948 (not (gnus-unbuttonized-mime-type-p type)))
3949 ;(gnus-article-insert-newline)
3950 (gnus-insert-mime-button
3951 handle id (list (or display (and not-attachment text))))
3952 (gnus-article-insert-newline)
3953 ;(gnus-article-insert-newline)
3954 ;; Remember modify the number of forward lines.
3962 (let ((mail-parse-charset gnus-newsgroup-charset)
3963 (mail-parse-ignored-charsets
3964 (save-excursion (condition-case ()
3965 (set-buffer gnus-summary-buffer)
3967 gnus-newsgroup-ignored-charsets)))
3968 (mm-display-part handle t))
3969 (goto-char (point-max)))
3970 ((and text not-attachment)
3974 (gnus-article-insert-newline)
3975 (mm-insert-inline handle (mm-get-part handle))
3976 (goto-char (point-max))))
3980 (narrow-to-region beg (point))
3983 (gnus-article-mime-total-parts)
3984 (mm-handle-media-type handle)))))))))
3986 (defun gnus-unbuttonized-mime-type-p (type)
3987 "Say whether TYPE is to be unbuttonized."
3988 (unless gnus-inhibit-mime-unbuttonizing
3990 (let ((types gnus-unbuttonized-mime-types))
3992 (when (string-match (pop types) type)
3993 (throw 'found t)))))
3995 (let ((types gnus-buttonized-mime-types))
3997 (when (string-match (pop types) type)
3998 (throw 'found t)))))))))
4000 (defun gnus-article-insert-newline ()
4001 "Insert a newline, but mark it as undeletable."
4002 (gnus-put-text-property
4003 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4005 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4006 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4009 handle buffer-read-only from props begend not-pref)
4010 (save-window-excursion
4013 (narrow-to-region (car ibegend)
4016 (goto-char (car ibegend))
4019 (delete-region (point-min) (point-max))
4020 (mm-remove-parts handles))
4021 (setq begend (list (point-marker)))
4023 (unless (setq not-pref (cadr (member preferred ihandles)))
4024 (setq not-pref (car ihandles)))
4027 (not (gnus-unbuttonized-mime-type-p
4028 "multipart/alternative")))
4029 (gnus-add-text-properties
4032 (insert (format "%d. " id))
4036 (unless ,(not ibegend)
4037 (setq gnus-article-mime-handle-alist
4038 ',gnus-article-mime-handle-alist))
4039 (gnus-mime-display-alternative
4040 ',ihandles ',not-pref ',begend ,id))
4041 ,@(if (>= (string-to-number emacs-version) 21)
4042 nil ;; XEmacs doesn't care
4043 (list 'local-map gnus-mime-button-map))
4044 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4045 face ,gnus-article-button-face
4046 keymap ,gnus-mime-button-map
4049 (widget-convert-button 'link from (point)
4050 :action 'gnus-widget-press-button
4051 :button-keymap gnus-widget-button-keymap)
4053 (while (setq handle (pop handles))
4054 (gnus-add-text-properties
4057 (insert (format "(%c) %-18s"
4058 (if (equal handle preferred) ?* ? )
4059 (mm-handle-media-type handle)))
4063 (unless ,(not ibegend)
4064 (setq gnus-article-mime-handle-alist
4065 ',gnus-article-mime-handle-alist))
4066 (gnus-mime-display-alternative
4067 ',ihandles ',handle ',begend ,id))
4068 ,@(if (>= (string-to-number emacs-version) 21)
4069 nil ;; XEmacs doesn't care
4070 (list 'local-map gnus-mime-button-map))
4071 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4072 face ,gnus-article-button-face
4073 keymap ,gnus-mime-button-map
4076 (widget-convert-button 'link from (point)
4077 :action 'gnus-widget-press-button
4078 :button-keymap gnus-widget-button-keymap)
4082 (if (stringp (car preferred))
4083 (gnus-display-mime preferred)
4084 (let ((mail-parse-charset gnus-newsgroup-charset)
4085 (mail-parse-ignored-charsets
4086 (save-excursion (set-buffer gnus-summary-buffer)
4087 gnus-newsgroup-ignored-charsets)))
4088 (mm-display-part preferred)
4092 (narrow-to-region (car begend) (point-max))
4094 nil (length gnus-article-mime-handle-alist)
4095 (gnus-article-mime-total-parts)
4096 (mm-handle-media-type handle))))))
4097 (goto-char (point-max))
4098 (setcdr begend (point-marker)))))
4100 (goto-char point))))
4102 (defconst gnus-article-wash-status-strings
4103 (let ((alist '((cite "c" "Possible hidden citation text"
4104 " " "All citation text visible")
4105 (headers "h" "Hidden headers"
4106 " " "All headers visible.")
4107 (pgp "p" "Encrypted or signed message status hidden"
4108 " " "No hidden encryption nor digital signature status")
4109 (signature "s" "Signature has been hidden"
4110 " " "Signature is visible")
4111 (overstrike "o" "Overstrike (^H) characters applied"
4112 " " "No overstrike characters applied")
4113 (emphasis "e" "/*_Emphasis_*/ characters applied"
4114 " " "No /*_emphasis_*/ characters applied")))
4116 (dolist (entry alist result)
4117 (let ((key (nth 0 entry))
4118 (on (copy-sequence (nth 1 entry)))
4119 (on-help (nth 2 entry))
4120 (off (copy-sequence (nth 3 entry)))
4121 (off-help (nth 4 entry)))
4122 (put-text-property 0 1 'help-echo on-help on)
4123 (put-text-property 0 1 'help-echo off-help off)
4124 (push (list key on off) result))))
4125 "Alist of strings describing wash status in the mode line.
4126 Each entry has the form (KEY ON OF), where the KEY is a symbol
4127 representing the particular washing function, ON is the string to use
4128 in the article mode line when the washing function is active, and OFF
4129 is the string to use when it is inactive.")
4131 (defun gnus-gnus-article-wash-status-entry (key value)
4132 (let ((entry (assoc key gnus-article-wash-status-strings)))
4133 (if value (nth 1 entry) (nth 2 entry))))
4135 (defun gnus-article-wash-status ()
4136 "Return a string which display status of article washing."
4138 (set-buffer gnus-article-buffer)
4139 (let ((cite (memq 'cite gnus-article-wash-types))
4140 (headers (memq 'headers gnus-article-wash-types))
4141 (boring (memq 'boring-headers gnus-article-wash-types))
4142 (pgp (memq 'pgp gnus-article-wash-types))
4143 (pem (memq 'pem gnus-article-wash-types))
4144 (signed (memq 'signed gnus-article-wash-types))
4145 (encrypted (memq 'encrypted gnus-article-wash-types))
4146 (signature (memq 'signature gnus-article-wash-types))
4147 (overstrike (memq 'overstrike gnus-article-wash-types))
4148 (emphasis (memq 'emphasis gnus-article-wash-types)))
4149 (concat (gnus-gnus-article-wash-status-entry 'cite cite)
4150 (gnus-gnus-article-wash-status-entry 'headers
4151 (or headers boring))
4152 (gnus-gnus-article-wash-status-entry
4153 'pgp (or pgp pem signed encrypted))
4154 (gnus-gnus-article-wash-status-entry 'signature signature)
4155 (gnus-gnus-article-wash-status-entry 'overstrike overstrike)
4156 (gnus-gnus-article-wash-status-entry 'emphasis emphasis)))))
4158 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
4160 (defun gnus-article-maybe-hide-headers ()
4161 "Hide unwanted headers if `gnus-have-all-headers' is nil.
4162 Provided for backwards compatibility."
4163 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
4164 (not (save-excursion (set-buffer gnus-summary-buffer)
4165 gnus-have-all-headers)))
4166 (not gnus-inhibit-hiding))
4167 (gnus-article-hide-headers)))
4171 (defun gnus-output-to-file (file-name)
4172 "Append the current article to a file named FILE-NAME."
4173 (let ((artbuf (current-buffer)))
4175 (insert-buffer-substring artbuf)
4176 ;; Append newline at end of the buffer as separator, and then
4178 (goto-char (point-max))
4180 (let ((file-name-coding-system nnmail-pathname-coding-system))
4181 (mm-append-to-file (point-min) (point-max) file-name))
4184 (defun gnus-narrow-to-page (&optional arg)
4185 "Narrow the article buffer to a page.
4186 If given a numerical ARG, move forward ARG pages."
4188 (setq arg (if arg (prefix-numeric-value arg) 0))
4190 (set-buffer gnus-article-buffer)
4191 (goto-char (point-min))
4193 ;; Remove any old next/prev buttons.
4194 (when (gnus-visual-p 'page-marker)
4195 (let ((buffer-read-only nil))
4196 (gnus-remove-text-with-property 'gnus-prev)
4197 (gnus-remove-text-with-property 'gnus-next)))
4200 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
4202 (re-search-forward page-delimiter nil 'move arg)))
4203 (goto-char (match-end 0)))
4206 (if (re-search-forward page-delimiter nil 'move)
4209 (when (and (gnus-visual-p 'page-marker)
4210 (not (= (point-min) 1)))
4212 (goto-char (point-min))
4213 (gnus-insert-prev-page-button)))
4214 (when (and (gnus-visual-p 'page-marker)
4215 (< (+ (point-max) 2) (buffer-size)))
4217 (goto-char (point-max))
4218 (gnus-insert-next-page-button)))))
4220 ;; Article mode commands
4222 (defun gnus-article-goto-next-page ()
4223 "Show the next page of the article."
4225 (when (gnus-article-next-page)
4226 (goto-char (point-min))
4227 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
4229 (defun gnus-article-goto-prev-page ()
4230 "Show the next page of the article."
4232 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
4233 (gnus-article-prev-page nil)))
4235 (defun gnus-article-next-page (&optional lines)
4236 "Show the next page of the current article.
4237 If end of article, return non-nil. Otherwise return nil.
4238 Argument LINES specifies lines to be scrolled up."
4240 (move-to-window-line -1)
4243 (and (pos-visible-in-window-p) ;Not continuation line.
4245 ;; Nothing in this page.
4246 (if (or (not gnus-page-broken)
4249 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
4251 (gnus-narrow-to-page 1) ;Go to next page.
4253 ;; More in this page.
4254 (let ((scroll-in-place nil))
4258 ;; Long lines may cause an end-of-buffer error.
4259 (goto-char (point-max)))))
4260 (move-to-window-line 0)
4263 (defun gnus-article-prev-page (&optional lines)
4264 "Show previous page of current article.
4265 Argument LINES specifies lines to be scrolled down."
4267 (move-to-window-line 0)
4268 (if (and gnus-page-broken
4270 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
4272 (gnus-narrow-to-page -1) ;Go to previous page.
4273 (goto-char (point-max))
4275 (let ((scroll-in-place nil))
4279 (beginning-of-buffer
4280 (goto-char (point-min))))
4281 (move-to-window-line 0)))))
4283 (defun gnus-article-refer-article ()
4284 "Read article specified by message-id around point."
4286 (let ((point (point)))
4287 (search-forward ">" nil t) ;Move point to end of "<....>".
4288 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
4289 (let ((message-id (match-string 1)))
4291 (set-buffer gnus-summary-buffer)
4292 (gnus-summary-refer-article message-id))
4294 (error "No references around point"))))
4296 (defun gnus-article-show-summary ()
4297 "Reconfigure windows to show summary buffer."
4299 (if (not (gnus-buffer-live-p gnus-summary-buffer))
4300 (error "There is no summary buffer for this article buffer")
4301 (gnus-article-set-globals)
4302 (gnus-configure-windows 'article)
4303 (gnus-summary-goto-subject gnus-current-article)
4304 (gnus-summary-position-point)))
4306 (defun gnus-article-describe-briefly ()
4307 "Describe article mode commands briefly."
4309 (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")))
4311 (defun gnus-article-summary-command ()
4312 "Execute the last keystroke in the summary buffer."
4314 (let ((obuf (current-buffer))
4315 (owin (current-window-configuration))
4317 (switch-to-buffer gnus-article-current-summary 'norecord)
4318 (setq func (lookup-key (current-local-map) (this-command-keys)))
4319 (call-interactively func)
4321 (set-window-configuration owin)
4322 (set-window-point (get-buffer-window (current-buffer)) (point))))
4324 (defun gnus-article-summary-command-nosave ()
4325 "Execute the last keystroke in the summary buffer."
4328 (pop-to-buffer gnus-article-current-summary 'norecord)
4329 (setq func (lookup-key (current-local-map) (this-command-keys)))
4330 (call-interactively func)))
4332 (defun gnus-article-check-buffer ()
4333 "Beep if not in an article buffer."
4334 (unless (equal major-mode 'gnus-article-mode)
4335 (error "Command invoked outside of a Gnus article buffer")))
4337 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
4338 "Read a summary buffer key sequence and execute it from the article buffer."
4340 (gnus-article-check-buffer)
4342 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
4343 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
4344 "=" "^" "\M-^" "|"))
4350 '("n" "Gn" "p" "Gp"))
4353 (set-buffer gnus-article-current-summary)
4354 (let (gnus-pick-mode)
4355 (push (or key last-command-event) unread-command-events)
4356 (setq keys (if (featurep 'xemacs)
4357 (events-to-keys (read-key-sequence nil))
4358 (read-key-sequence nil)))))
4362 (if (or (member keys nosaves)
4363 (member keys nosave-but-article)
4364 (member keys nosave-in-article))
4366 (save-window-excursion
4367 (pop-to-buffer gnus-article-current-summary 'norecord)
4368 ;; We disable the pick minor mode commands.
4369 (let (gnus-pick-mode)
4370 (setq func (lookup-key (current-local-map) keys))))
4374 (unless (member keys nosave-in-article)
4375 (set-buffer gnus-article-current-summary))
4376 (call-interactively func)
4377 (setq new-sum-point (point)))
4378 (when (member keys nosave-but-article)
4379 (pop-to-buffer gnus-article-buffer 'norecord)))
4380 ;; These commands should restore window configuration.
4381 (let ((obuf (current-buffer))
4382 (owin (current-window-configuration))
4384 (summary gnus-article-current-summary)
4385 func in-buffer selected)
4386 (if not-restore-window
4387 (pop-to-buffer summary 'norecord)
4388 (switch-to-buffer summary 'norecord))
4389 (setq in-buffer (current-buffer))
4390 ;; We disable the pick minor mode commands.
4391 (if (and (setq func (let (gnus-pick-mode)
4392 (lookup-key (current-local-map) keys)))
4395 (call-interactively func)
4396 (setq new-sum-point (point))
4397 (when (eq in-buffer (current-buffer))
4398 (setq selected (gnus-summary-select-article))
4400 (unless not-restore-window
4401 (set-window-configuration owin))
4402 (when (eq selected 'old)
4404 (set-window-start (get-buffer-window (current-buffer))
4406 (set-window-point (get-buffer-window (current-buffer))
4408 (let ((win (get-buffer-window gnus-article-current-summary)))
4410 (set-window-point win new-sum-point)))) )
4411 (switch-to-buffer gnus-article-buffer)
4414 (defun gnus-article-describe-key (key)
4415 "Display documentation of the function invoked by KEY. KEY is a string."
4416 (interactive "kDescribe key: ")
4417 (gnus-article-check-buffer)
4418 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
4420 (set-buffer gnus-article-current-summary)
4421 (let (gnus-pick-mode)
4422 (if (featurep 'xemacs)
4424 (push (elt key 0) unread-command-events)
4425 (setq key (events-to-keys
4426 (read-key-sequence "Describe key: "))))
4427 (setq unread-command-events
4429 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
4430 (string-to-list key)))
4431 (setq key (read-key-sequence "Describe key: "))))
4433 (describe-key key)))
4435 (defun gnus-article-describe-key-briefly (key &optional insert)
4436 "Display documentation of the function invoked by KEY. KEY is a string."
4437 (interactive "kDescribe key: \nP")
4438 (gnus-article-check-buffer)
4439 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
4441 (set-buffer gnus-article-current-summary)
4442 (let (gnus-pick-mode)
4443 (if (featurep 'xemacs)
4445 (push (elt key 0) unread-command-events)
4446 (setq key (events-to-keys
4447 (read-key-sequence "Describe key: "))))
4448 (setq unread-command-events
4450 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
4451 (string-to-list key)))
4452 (setq key (read-key-sequence "Describe key: "))))
4453 (describe-key-briefly key insert))
4454 (describe-key-briefly key insert)))
4456 (defun gnus-article-hide (&optional arg force)
4457 "Hide all the gruft in the current article.
4458 This means that PGP stuff, signatures, cited text and (some)
4459 headers will be hidden.
4460 If given a prefix, show the hidden text instead."
4461 (interactive (append (gnus-article-hidden-arg) (list 'force)))
4462 (gnus-article-hide-headers arg)
4463 (gnus-article-hide-list-identifiers arg)
4464 (gnus-article-hide-pgp arg)
4465 (gnus-article-hide-citation-maybe arg force)
4466 (gnus-article-hide-signature arg))
4468 (defun gnus-article-maybe-highlight ()
4469 "Do some article highlighting if article highlighting is requested."
4470 (when (gnus-visual-p 'article-highlight 'highlight)
4471 (gnus-article-highlight-some)))
4473 (defun gnus-check-group-server ()
4474 ;; Make sure the connection to the server is alive.
4475 (unless (gnus-server-opened
4476 (gnus-find-method-for-group gnus-newsgroup-name))
4477 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
4478 (gnus-request-group gnus-newsgroup-name t)))
4480 (defun gnus-request-article-this-buffer (article group)
4481 "Get an article and insert it into this buffer."
4482 (let (do-update-line sparse-header)
4486 (gnus-kill-all-overlays)
4487 (setq group (or group gnus-newsgroup-name))
4489 ;; Using `gnus-request-article' directly will insert the article into
4490 ;; `nntp-server-buffer' - so we'll save some time by not having to
4491 ;; copy it from the server buffer into the article buffer.
4493 ;; We only request an article by message-id when we do not have the
4494 ;; headers for it, so we'll have to get those.
4495 (when (stringp article)
4496 (gnus-read-header article))
4498 ;; If the article number is negative, that means that this article
4499 ;; doesn't belong in this newsgroup (possibly), so we find its
4500 ;; message-id and request it by id instead of number.
4501 (when (and (numberp article)
4503 (get-buffer gnus-summary-buffer)
4504 (gnus-buffer-exists-p gnus-summary-buffer))
4506 (set-buffer gnus-summary-buffer)
4507 (let ((header (gnus-summary-article-header article)))
4510 ((memq article gnus-newsgroup-sparse)
4511 ;; This is a sparse gap article.
4512 (setq do-update-line article)
4513 (setq article (mail-header-id header))
4514 (setq sparse-header (gnus-read-header article))
4515 (setq gnus-newsgroup-sparse
4516 (delq article gnus-newsgroup-sparse)))
4518 ;; It's a real article.
4519 (setq article (mail-header-id header)))
4521 ;; It is an extracted pseudo-article.
4522 (setq article 'pseudo)
4523 (gnus-request-pseudo-article header))))
4525 (let ((method (gnus-find-method-for-group
4526 gnus-newsgroup-name)))
4527 (when (and (eq (car method) 'nneething)
4529 (let ((dir (expand-file-name
4530 (mail-header-subject header)
4531 (file-name-as-directory
4532 (or (cadr (assq 'nneething-address method))
4534 (when (file-directory-p dir)
4535 (setq article 'nneething)
4536 (gnus-group-enter-directory dir))))))))
4539 ;; Refuse to select canceled articles.
4540 ((and (numberp article)
4542 (get-buffer gnus-summary-buffer)
4543 (gnus-buffer-exists-p gnus-summary-buffer)
4544 (eq (cdr (save-excursion
4545 (set-buffer gnus-summary-buffer)
4546 (assq article gnus-newsgroup-reads)))
4547 gnus-canceled-mark))
4549 ;; We first check `gnus-original-article-buffer'.
4550 ((and (get-buffer gnus-original-article-buffer)
4553 (set-buffer gnus-original-article-buffer)
4554 (and (equal (car gnus-original-article) group)
4555 (eq (cdr gnus-original-article) article))))
4556 (insert-buffer-substring gnus-original-article-buffer)
4558 ;; Check the backlog.
4559 ((and gnus-keep-backlog
4560 (gnus-backlog-request-article group article (current-buffer)))
4562 ;; Check asynchronous pre-fetch.
4563 ((gnus-async-request-fetched-article group article (current-buffer))
4564 (gnus-async-prefetch-next group article gnus-summary-buffer)
4565 (when (and (numberp article) gnus-keep-backlog)
4566 (gnus-backlog-enter-article group article (current-buffer)))
4569 ((and gnus-use-cache
4571 (gnus-cache-request-article article group))
4573 ;; Get the article and put into the article buffer.
4574 ((or (stringp article)
4576 (let ((gnus-override-method gnus-override-method)
4577 (methods (and (stringp article)
4578 gnus-refer-article-method))
4580 (buffer-read-only nil))
4581 (if (or (not (listp methods))
4582 (and (symbolp (car methods))
4583 (assq (car methods) nnoo-definition-alist)))
4584 (setq methods (list methods)))
4585 (when (and (null gnus-override-method)
4587 (setq gnus-override-method (pop methods)))
4589 (when (eq gnus-override-method 'current)
4590 (setq gnus-override-method
4591 (with-current-buffer gnus-summary-buffer
4592 gnus-current-select-method)))
4594 (gnus-kill-all-overlays)
4595 (let ((gnus-newsgroup-name group))
4596 (gnus-check-group-server))
4597 (when (gnus-request-article article group (current-buffer))
4598 (when (numberp article)
4599 (gnus-async-prefetch-next group article
4600 gnus-summary-buffer)
4601 (when gnus-keep-backlog
4602 (gnus-backlog-enter-article
4603 group article (current-buffer))))
4604 (setq result 'article))
4607 (setq gnus-override-method (pop methods))
4608 (setq result 'done))))
4609 (and (eq result 'article) 'article)))
4613 ;; Associate this article with the current summary buffer.
4614 (setq gnus-article-current-summary gnus-summary-buffer)
4616 ;; Take the article from the original article buffer
4617 ;; and place it in the buffer it's supposed to be in.
4618 (when (and (get-buffer gnus-article-buffer)
4619 (equal (buffer-name (current-buffer))
4620 (buffer-name (get-buffer gnus-article-buffer))))
4622 (if (get-buffer gnus-original-article-buffer)
4623 (set-buffer gnus-original-article-buffer)
4624 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
4625 (buffer-disable-undo)
4626 (setq major-mode 'gnus-original-article-mode)
4627 (setq buffer-read-only t))
4628 (let (buffer-read-only)
4630 (insert-buffer-substring gnus-article-buffer))
4631 (setq gnus-original-article (cons group article)))
4634 (run-hooks 'gnus-article-decode-hook)
4635 ;; Mark article as decoded or not.
4636 (setq gnus-article-decoded-p gnus-article-decode-hook))
4638 ;; Update sparse articles.
4639 (when (and do-update-line
4640 (or (numberp article)
4642 (let ((buf (current-buffer)))
4643 (set-buffer gnus-summary-buffer)
4644 (gnus-summary-update-article do-update-line sparse-header)
4645 (gnus-summary-goto-subject do-update-line nil t)
4646 (set-window-point (gnus-get-buffer-window (current-buffer) t)
4648 (set-buffer buf))))))
4654 (defcustom gnus-article-edit-mode-hook nil
4655 "Hook run in article edit mode buffers."
4656 :group 'gnus-article-various
4659 (defvar gnus-article-edit-done-function nil)
4661 (defvar gnus-article-edit-mode-map nil)
4663 ;; Should we be using derived.el for this?
4664 (unless gnus-article-edit-mode-map
4665 (setq gnus-article-edit-mode-map (make-sparse-keymap))
4666 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
4668 (gnus-define-keys gnus-article-edit-mode-map
4669 "\C-c\C-c" gnus-article-edit-done
4670 "\C-c\C-k" gnus-article-edit-exit)
4672 (gnus-define-keys (gnus-article-edit-wash-map
4673 "\C-c\C-w" gnus-article-edit-mode-map)
4674 "f" gnus-article-edit-full-stops))
4676 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
4677 "Major mode for editing articles.
4678 This is an extended text-mode.
4680 \\{gnus-article-edit-mode-map}"
4681 (make-local-variable 'gnus-article-edit-done-function)
4682 (make-local-variable 'gnus-prev-winconf)
4683 (set (make-local-variable 'font-lock-defaults)
4684 '(message-font-lock-keywords t))
4685 (setq buffer-read-only nil)
4686 (buffer-enable-undo)
4689 (defun gnus-article-edit (&optional force)
4690 "Edit the current article.
4691 This will have permanent effect only in mail groups.
4692 If FORCE is non-nil, allow editing of articles even in read-only
4695 (when (and (not force)
4696 (gnus-group-read-only-p))
4697 (error "The current newsgroup does not support article editing"))
4698 (gnus-article-date-original)
4699 (gnus-article-edit-article
4701 `(lambda (no-highlight)
4703 (gnus-summary-edit-article-done
4704 ,(or (mail-header-references gnus-current-headers) "")
4705 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
4707 (defun gnus-article-edit-article (start-func exit-func)
4708 "Start editing the contents of the current article buffer."
4709 (let ((winconf (current-window-configuration)))
4710 (set-buffer gnus-article-buffer)
4711 (gnus-article-edit-mode)
4712 (funcall start-func)
4713 (set-buffer-modified-p nil)
4714 (gnus-configure-windows 'edit-article)
4715 (setq gnus-article-edit-done-function exit-func)
4716 (setq gnus-prev-winconf winconf)
4717 (gnus-message 6 "C-c C-c to end edits")))
4719 (defun gnus-article-edit-done (&optional arg)
4720 "Update the article edits and exit."
4722 (let ((func gnus-article-edit-done-function)
4723 (buf (current-buffer))
4724 (start (window-start)))
4725 ;; We remove all text props from the article buffer.
4727 (buffer-substring-no-properties (point-min) (point-max)))
4731 (let ((winconf gnus-prev-winconf))
4733 (set-window-configuration winconf)
4734 ;; Tippy-toe some to make sure that point remains where it was.
4735 (save-current-buffer
4737 (set-window-start (get-buffer-window (current-buffer)) start)
4741 (let ((buffer-read-only nil))
4743 ;; The cache and backlog have to be flushed somewhat.
4744 (when gnus-keep-backlog
4745 (gnus-backlog-remove-article
4746 (car gnus-article-current) (cdr gnus-article-current)))
4747 ;; Flush original article as well.
4749 (when (get-buffer gnus-original-article-buffer)
4750 (set-buffer gnus-original-article-buffer)
4751 (setq gnus-original-article nil)))
4752 (when gnus-use-cache
4753 (gnus-cache-update-article
4754 (car gnus-article-current) (cdr gnus-article-current))))
4756 (set-window-start (get-buffer-window buf) start)
4757 (set-window-point (get-buffer-window buf) (point))))
4759 (defun gnus-article-edit-exit ()
4760 "Exit the article editing without updating."
4762 (when (or (not (buffer-modified-p))
4763 (yes-or-no-p "Article modified; kill anyway? "))
4764 (let ((curbuf (current-buffer))
4766 (window-start (window-start)))
4768 (if (gnus-buffer-live-p gnus-original-article-buffer)
4769 (insert-buffer gnus-original-article-buffer))
4770 (let ((winconf gnus-prev-winconf))
4772 (set-window-configuration winconf)
4773 ;; Tippy-toe some to make sure that point remains where it was.
4774 (save-current-buffer
4776 (set-window-start (get-buffer-window (current-buffer)) window-start)
4779 (defun gnus-article-edit-full-stops ()
4780 "Interactively repair spacing at end of sentences."
4783 (goto-char (point-min))
4784 (search-forward-regexp "^$" nil t)
4785 (let ((case-fold-search nil))
4786 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
4789 ;;; Article highlights
4792 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
4794 ;;; Internal Variables:
4796 (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\\)\\)"
4797 "Regular expression that matches URLs."
4798 :group 'gnus-article-buttons
4801 (defcustom gnus-button-alist
4802 `(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
4803 0 t gnus-button-handle-news 3)
4804 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
4805 gnus-button-handle-news 2)
4806 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
4808 gnus-button-fetch-group 4)
4809 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
4810 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
4811 t gnus-button-message-id 3)
4812 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
4813 ("mailto:\\([-a-zA-Z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
4814 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
4816 ("\\binfo:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t
4817 gnus-button-handle-info 2)
4818 ;; This is how URLs _should_ be embedded in text...
4819 ("<URL: *\\([^<>]*\\)>" 0 t gnus-button-embedded-url 1)
4821 (,gnus-button-url-regexp 0 t browse-url 0))
4822 "*Alist of regexps matching buttons in article bodies.
4824 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
4825 REGEXP: is the string matching text around the button,
4826 BUTTON: is the number of the regexp grouping actually matching the button,
4827 FORM: is a lisp expression which must eval to true for the button to
4829 CALLBACK: is the function to call when the user push this button, and each
4830 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
4832 CALLBACK can also be a variable, in that case the value of that
4833 variable it the real callback function."
4834 :group 'gnus-article-buttons
4835 :type '(repeat (list regexp
4836 (integer :tag "Button")
4838 (function :tag "Callback")
4841 (integer :tag "Regexp group")))))
4843 (defcustom gnus-header-button-alist
4844 `(("^\\(References\\|Message-I[Dd]\\):" "<[^<>]+>"
4845 0 t gnus-button-message-id 0)
4846 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
4847 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
4848 0 t gnus-button-mailto 0)
4849 ("^X-[Uu][Rr][Ll]:" ,gnus-button-url-regexp 0 t browse-url 0)
4850 ("^Subject:" ,gnus-button-url-regexp 0 t browse-url 0)
4851 ("^[^:]+:" ,gnus-button-url-regexp 0 t browse-url 0)
4852 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
4853 gnus-button-message-id 3))
4854 "*Alist of headers and regexps to match buttons in article heads.
4856 This alist is very similar to `gnus-button-alist', except that each
4857 alist has an additional HEADER element first in each entry:
4859 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
4861 HEADER is a regexp to match a header. For a fuller explanation, see
4862 `gnus-button-alist'."
4863 :group 'gnus-article-buttons
4864 :group 'gnus-article-headers
4865 :type '(repeat (list (regexp :tag "Header")
4867 (integer :tag "Button")
4869 (function :tag "Callback")
4872 (integer :tag "Regexp group")))))
4874 (defvar gnus-button-regexp nil)
4875 (defvar gnus-button-marker-list nil)
4876 ;; Regexp matching any of the regexps from `gnus-button-alist'.
4878 (defvar gnus-button-last nil)
4879 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
4883 (defun gnus-article-push-button (event)
4884 "Check text under the mouse pointer for a callback function.
4885 If the text under the mouse pointer has a `gnus-callback' property,
4886 call it with the value of the `gnus-data' text property."
4888 (set-buffer (window-buffer (posn-window (event-start event))))
4889 (let* ((pos (posn-point (event-start event)))
4890 (data (get-text-property pos 'gnus-data))
4891 (fun (get-text-property pos 'gnus-callback)))
4894 (funcall fun data))))
4896 (defun gnus-article-press-button ()
4897 "Check text at point for a callback function.
4898 If the text at point has a `gnus-callback' property,
4899 call it with the value of the `gnus-data' text property."
4901 (let* ((data (get-text-property (point) 'gnus-data))
4902 (fun (get-text-property (point) 'gnus-callback)))
4904 (funcall fun data))))
4906 (defun gnus-article-highlight (&optional force)
4907 "Highlight current article.
4908 This function calls `gnus-article-highlight-headers',
4909 `gnus-article-highlight-citation',
4910 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
4911 do the highlighting. See the documentation for those functions."
4912 (interactive (list 'force))
4913 (gnus-article-highlight-headers)
4914 (gnus-article-highlight-citation force)
4915 (gnus-article-highlight-signature)
4916 (gnus-article-add-buttons force)
4917 (gnus-article-add-buttons-to-head))
4919 (defun gnus-article-highlight-some (&optional force)
4920 "Highlight current article.
4921 This function calls `gnus-article-highlight-headers',
4922 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
4923 do the highlighting. See the documentation for those functions."
4924 (interactive (list 'force))
4925 (gnus-article-highlight-headers)
4926 (gnus-article-highlight-signature)
4927 (gnus-article-add-buttons))
4929 (defun gnus-article-highlight-headers ()
4930 "Highlight article headers as specified by `gnus-header-face-alist'."
4933 (set-buffer gnus-article-buffer)
4935 (let ((alist gnus-header-face-alist)
4936 (buffer-read-only nil)
4937 (case-fold-search t)
4938 (inhibit-point-motion-hooks t)
4939 entry regexp header-face field-face from hpoints fpoints)
4940 (article-narrow-to-head)
4941 (while (setq entry (pop alist))
4942 (goto-char (point-min))
4943 (setq regexp (concat "^\\("
4944 (if (string-equal "" (nth 0 entry))
4948 header-face (nth 1 entry)
4949 field-face (nth 2 entry))
4950 (while (and (re-search-forward regexp nil t)
4954 (unless (search-forward ":" nil t)
4956 (when (and header-face
4957 (not (memq (point) hpoints)))
4958 (push (point) hpoints)
4959 (gnus-put-text-property from (point) 'face header-face))
4960 (when (and field-face
4961 (not (memq (setq from (point)) fpoints)))
4963 (if (re-search-forward "^[^ \t]" nil t)
4965 (goto-char (point-max)))
4966 (gnus-put-text-property from (point) 'face field-face))))))))
4968 (defun gnus-article-highlight-signature ()
4969 "Highlight the signature in an article.
4970 It does this by highlighting everything after
4971 `gnus-signature-separator' using `gnus-signature-face'."
4974 (set-buffer gnus-article-buffer)
4975 (let ((buffer-read-only nil)
4976 (inhibit-point-motion-hooks t))
4978 (when (and gnus-signature-face
4979 (gnus-article-narrow-to-signature))
4980 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
4981 'face gnus-signature-face)
4983 (gnus-article-search-signature)
4984 (let ((start (match-beginning 0))
4985 (end (set-marker (make-marker) (1+ (match-end 0)))))
4986 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
4989 (defun gnus-button-in-region-p (b e prop)
4990 "Say whether PROP exists in the region."
4991 (text-property-not-all b e prop nil))
4993 (defun gnus-article-add-buttons (&optional force)
4994 "Find external references in the article and make buttons of them.
4995 \"External references\" are things like Message-IDs and URLs, as
4996 specified by `gnus-button-alist'."
4997 (interactive (list 'force))
4999 (set-buffer gnus-article-buffer)
5000 (let ((buffer-read-only nil)
5001 (inhibit-point-motion-hooks t)
5002 (case-fold-search t)
5003 (alist gnus-button-alist)
5005 ;; Remove all old markers.
5006 (let (marker entry new-list)
5007 (while (setq marker (pop gnus-button-marker-list))
5008 (if (or (< marker (point-min)) (>= marker (point-max)))
5009 (push marker new-list)
5011 (when (setq entry (gnus-button-entry))
5012 (put-text-property (match-beginning (nth 1 entry))
5013 (match-end (nth 1 entry))
5014 'gnus-callback nil))
5015 (set-marker marker nil)))
5016 (setq gnus-button-marker-list new-list))
5017 ;; We skip the headers.
5020 (while (setq entry (pop alist))
5021 (setq regexp (car entry))
5023 (while (re-search-forward regexp nil t)
5024 (let* ((start (and entry (match-beginning (nth 1 entry))))
5025 (end (and entry (match-end (nth 1 entry))))
5026 (from (match-beginning 0)))
5027 (when (and (or (eq t (nth 2 entry))
5028 (eval (nth 2 entry)))
5029 (not (gnus-button-in-region-p
5030 start end 'gnus-callback)))
5031 ;; That optional form returned non-nil, so we add the
5033 (gnus-article-add-button
5034 start end 'gnus-button-push
5035 (car (push (set-marker (make-marker) from)
5036 gnus-button-marker-list))))))))))
5038 ;; Add buttons to the head of an article.
5039 (defun gnus-article-add-buttons-to-head ()
5040 "Add buttons to the head of the article."
5043 (set-buffer gnus-article-buffer)
5045 (let ((buffer-read-only nil)
5046 (inhibit-point-motion-hooks t)
5047 (case-fold-search t)
5048 (alist gnus-header-button-alist)
5050 (article-narrow-to-head)
5052 ;; Each alist entry.
5053 (setq entry (car alist)
5055 (goto-char (point-min))
5056 (while (re-search-forward (car entry) nil t)
5057 ;; Each header matching the entry.
5058 (setq beg (match-beginning 0))
5059 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
5060 (match-beginning 0))
5063 (while (re-search-forward (nth 1 entry) end t)
5064 ;; Each match within a header.
5065 (let* ((entry (cdr entry))
5066 (start (match-beginning (nth 1 entry)))
5067 (end (match-end (nth 1 entry)))
5068 (form (nth 2 entry)))
5069 (goto-char (match-end 0))
5071 (gnus-article-add-button
5072 start end (nth 3 entry)
5073 (buffer-substring (match-beginning (nth 4 entry))
5074 (match-end (nth 4 entry)))))))
5075 (goto-char end)))))))
5077 ;;; External functions:
5079 (defun gnus-article-add-button (from to fun &optional data)
5080 "Create a button between FROM and TO with callback FUN and data DATA."
5081 (when gnus-article-button-face
5082 (gnus-overlay-put (gnus-make-overlay from to)
5083 'face gnus-article-button-face))
5084 (gnus-add-text-properties
5086 (nconc (and gnus-article-mouse-face
5087 (list gnus-mouse-face-prop gnus-article-mouse-face))
5088 (list 'gnus-callback fun)
5089 (and data (list 'gnus-data data))))
5090 (widget-convert-button 'link from to :action 'gnus-widget-press-button
5091 :button-keymap gnus-widget-button-keymap))
5093 ;;; Internal functions:
5095 (defun gnus-article-set-globals ()
5097 (set-buffer gnus-summary-buffer)
5098 (gnus-set-global-variables)))
5100 (defun gnus-signature-toggle (end)
5102 (set-buffer gnus-article-buffer)
5103 (let ((buffer-read-only nil)
5104 (inhibit-point-motion-hooks t))
5105 (if (text-property-any end (point-max) 'article-type 'signature)
5107 (setq gnus-article-wash-types
5108 (delq 'signature gnus-article-wash-types))
5109 (gnus-remove-text-properties-when
5110 'article-type 'signature end (point-max)
5111 (cons 'article-type (cons 'signature
5112 gnus-hidden-properties))))
5113 (or (memq 'signature gnus-article-wash-types)
5114 (push 'signature gnus-article-wash-types))
5115 (gnus-add-text-properties-when
5116 'article-type nil end (point-max)
5117 (cons 'article-type (cons 'signature
5118 gnus-hidden-properties)))))
5119 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
5120 (gnus-set-mode-line 'article))))
5122 (defun gnus-button-entry ()
5123 ;; Return the first entry in `gnus-button-alist' matching this place.
5124 (let ((alist gnus-button-alist)
5127 (setq entry (pop alist))
5128 (if (looking-at (car entry))
5133 (defun gnus-button-push (marker)
5134 ;; Push button starting at MARKER.
5137 (let* ((entry (gnus-button-entry))
5138 (inhibit-point-motion-hooks t)
5140 (args (mapcar (lambda (group)
5141 (let ((string (match-string group)))
5142 (gnus-set-text-properties
5143 0 (length string) nil string)
5150 (fboundp (symbol-value fun)))
5151 (apply (symbol-value fun) args))
5153 (gnus-message 1 "You must define `%S' to use this button"
5154 (cons fun args)))))))
5156 (defun gnus-parse-news-url (url)
5157 (let (scheme server group message-id articles)
5160 (goto-char (point-min))
5161 (when (looking-at "\\([A-Za-z]+\\):")
5162 (setq scheme (match-string 1))
5163 (goto-char (match-end 0)))
5164 (when (looking-at "//\\([^/]+\\)/")
5165 (setq server (match-string 1))
5166 (goto-char (match-end 0)))
5169 ((looking-at "\\(.*@.*\\)")
5170 (setq message-id (match-string 1)))
5171 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
5172 (setq group (match-string 1)
5173 articles (split-string (match-string 2) "-")))
5174 ((looking-at "\\([^/]+\\)/?")
5175 (setq group (match-string 1)))
5177 (error "Unknown news URL syntax"))))
5178 (list scheme server group message-id articles)))
5180 (defun gnus-button-handle-news (url)
5182 (destructuring-bind (scheme server group message-id articles)
5183 (gnus-parse-news-url url)
5187 (set-buffer gnus-summary-buffer)
5189 (let ((gnus-refer-article-method (list (list 'nntp server))))
5190 (gnus-summary-refer-article message-id))
5191 (gnus-summary-refer-article message-id))))
5193 (gnus-button-fetch-group url)))))
5195 (defun gnus-button-handle-info (url)
5196 "Fetch an info URL."
5198 "^\\([^:/]+\\)?/\\(.*\\)"
5200 (gnus-info-find-node
5201 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
5204 (gnus-url-unhex-string (match-string 2 url))))
5205 (error "Can't parse %s" url)))
5207 (defun gnus-button-message-id (message-id)
5210 (set-buffer gnus-summary-buffer)
5211 (gnus-summary-refer-article message-id)))
5213 (defun gnus-button-fetch-group (address)
5214 "Fetch GROUP specified by ADDRESS."
5215 (if (not (string-match "[:/]" address))
5216 ;; This is just a simple group url.
5217 (gnus-group-read-ephemeral-group address gnus-select-method)
5220 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
5222 (error "Can't parse %s" address)
5223 (gnus-group-read-ephemeral-group
5224 (match-string 4 address)
5225 `(nntp ,(match-string 1 address)
5226 (nntp-address ,(match-string 1 address))
5227 (nntp-port-number ,(if (match-end 3)
5228 (match-string 3 address)
5231 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
5233 (defun gnus-url-parse-query-string (query &optional downcase)
5234 (let (retval pairs cur key val)
5235 (setq pairs (split-string query "&"))
5237 (setq cur (car pairs)
5239 (if (not (string-match "=" cur))
5241 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
5242 val (gnus-url-unhex-string (substring cur (match-end 0) nil)))
5244 (setq key (downcase key)))
5245 (setq cur (assoc key retval))
5247 (setcdr cur (cons val (cdr cur)))
5248 (setq retval (cons (list key val) retval)))))
5251 (defun gnus-url-mailto (url)
5252 ;; Send mail to someone
5253 (when (string-match "mailto:/*\\(.*\\)" url)
5254 (setq url (substring url (match-beginning 1) nil)))
5255 (let (to args subject func)
5256 (if (string-match (regexp-quote "?") url)
5257 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
5258 args (gnus-url-parse-query-string
5259 (substring url (match-end 0) nil) t))
5260 (setq to (gnus-url-unhex-string url)))
5261 (setq args (cons (list "to" to) args)
5262 subject (cdr-safe (assoc "subject" args)))
5265 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
5268 (message-position-on-field (caar args)))
5269 (insert (mapconcat 'identity (cdar args) ", "))
5270 (setq args (cdr args)))
5273 (message-goto-subject))))
5275 (defun gnus-button-embedded-url (address)
5276 "Activate ADDRESS with `browse-url'."
5277 (browse-url (gnus-strip-whitespace address)))
5279 ;;; Next/prev buttons in the article buffer.
5281 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
5282 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
5284 (defvar gnus-prev-page-map nil)
5285 (unless gnus-prev-page-map
5286 (setq gnus-prev-page-map (make-sparse-keymap))
5287 (define-key gnus-prev-page-map gnus-mouse-2 'gnus-button-prev-page)
5288 (define-key gnus-prev-page-map "\r" 'gnus-button-prev-page))
5290 (defun gnus-insert-prev-page-button ()
5291 (let ((buffer-read-only nil))
5293 gnus-prev-page-line-format nil
5294 `(gnus-prev t local-map ,gnus-prev-page-map
5295 gnus-callback gnus-article-button-prev-page
5296 article-type annotation))))
5298 (defvar gnus-next-page-map nil)
5299 (unless gnus-next-page-map
5300 (setq gnus-next-page-map (make-keymap))
5301 (suppress-keymap gnus-prev-page-map)
5302 (define-key gnus-next-page-map gnus-mouse-2 'gnus-button-next-page)
5303 (define-key gnus-next-page-map "\r" 'gnus-button-next-page))
5305 (defun gnus-button-next-page ()
5306 "Go to the next page."
5308 (let ((win (selected-window)))
5309 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5310 (gnus-article-next-page)
5311 (select-window win)))
5313 (defun gnus-button-prev-page ()
5314 "Go to the prev page."
5316 (let ((win (selected-window)))
5317 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5318 (gnus-article-prev-page)
5319 (select-window win)))
5321 (defun gnus-insert-next-page-button ()
5322 (let ((buffer-read-only nil))
5323 (gnus-eval-format gnus-next-page-line-format nil
5325 t local-map ,gnus-next-page-map
5326 gnus-callback gnus-article-button-next-page
5327 article-type annotation))))
5329 (defun gnus-article-button-next-page (arg)
5330 "Go to the next page."
5332 (let ((win (selected-window)))
5333 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5334 (gnus-article-next-page)
5335 (select-window win)))
5337 (defun gnus-article-button-prev-page (arg)
5338 "Go to the prev page."
5340 (let ((win (selected-window)))
5341 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5342 (gnus-article-prev-page)
5343 (select-window win)))
5345 (defvar gnus-decode-header-methods
5346 '(mail-decode-encoded-word-region)
5347 "List of methods used to decode headers.
5349 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
5350 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
5351 (REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
5352 whose names match REGEXP.
5355 ((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
5356 mail-decode-encoded-word-region
5357 (\"chinese\" . rfc1843-decode-region))
5360 (defvar gnus-decode-header-methods-cache nil)
5362 (defun gnus-multi-decode-header (start end)
5363 "Apply the functions from `gnus-encoded-word-methods' that match."
5364 (unless (and gnus-decode-header-methods-cache
5365 (eq gnus-newsgroup-name
5366 (car gnus-decode-header-methods-cache)))
5367 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
5370 (nconc gnus-decode-header-methods-cache (list x))
5371 (if (and gnus-newsgroup-name
5372 (string-match (car x) gnus-newsgroup-name))
5373 (nconc gnus-decode-header-methods-cache
5375 gnus-decode-header-methods))
5376 (let ((xlist gnus-decode-header-methods-cache))
5379 (narrow-to-region start end)
5381 (funcall (pop xlist) (point-min) (point-max))))))
5384 ;;; Treatment top-level handling.
5387 (defun gnus-treat-article (condition &optional part-number total-parts type)
5388 (let ((length (- (point-max) (point-min)))
5389 (alist gnus-treatment-function-alist)
5390 (article-goto-body-goes-to-point-min-p t)
5394 (let ((list gnus-article-treat-types))
5396 (when (string-match (pop list) type)
5397 (throw 'found t)))))))
5398 (highlightp (gnus-visual-p 'article-highlight 'highlight))
5400 (gnus-run-hooks 'gnus-part-display-hook)
5401 (while (setq elem (pop alist))
5404 (if (gnus-buffer-live-p gnus-summary-buffer)
5405 (set-buffer gnus-summary-buffer))
5406 (symbol-value (car elem))))
5407 (when (and (or (consp val)
5409 (gnus-treat-predicate val)
5410 (or (not (get (car elem) 'highlight))
5413 (funcall (cadr elem)))))))
5415 ;; Dynamic variables.
5417 (defvar part-number)
5418 (defvar total-parts)
5423 (defun gnus-treat-predicate (val)
5428 (stringp (car val)))
5429 (apply 'gnus-or (mapcar `(lambda (s)
5430 (string-match s ,(or gnus-newsgroup-name "")))
5433 (let ((pred (pop val)))
5436 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
5438 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
5440 (not (gnus-treat-predicate (car val))))
5442 (equal (car val) type))
5444 (error "%S is not a valid predicate" pred)))))
5452 (eq part-number total-parts))
5456 (error "%S is not a valid value" val))))
5458 (defun gnus-article-encrypt-body (protocol &optional n)
5459 "Encrypt the article body."
5462 (or gnus-article-encrypt-protocol
5463 (completing-read "Encrypt protocol: "
5464 gnus-article-encrypt-protocol-alist
5466 current-prefix-arg))
5467 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
5469 (error (format "Can't find the encrypt protocol %s" protocol)))
5470 (if (equal gnus-newsgroup-name "nndraft:drafts")
5471 (error "Can't encrypt the article in group nndraft:drafts"))
5472 (if (equal gnus-newsgroup-name "nndraft:queue")
5473 (error "Don't encrypt the article in group nndraft:queue"))
5474 (gnus-summary-iterate n
5476 (set-buffer gnus-summary-buffer)
5477 (let ((mail-parse-charset gnus-newsgroup-charset)
5478 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5479 (summary-buffer gnus-summary-buffer)
5481 (gnus-set-global-variables)
5482 (when (gnus-group-read-only-p)
5483 (error "The current newsgroup does not support article encrypt"))
5484 (gnus-summary-show-article t)
5486 (or (mail-header-references gnus-current-headers) ""))
5487 (set-buffer gnus-article-buffer)
5488 (let* ((buffer-read-only nil)
5490 (mapcar (lambda (field)
5491 (and (save-restriction
5492 (message-narrow-to-head)
5493 (goto-char (point-min))
5494 (search-forward field nil t))
5496 (message-narrow-to-field)
5497 (buffer-substring (point-min) (point-max))
5498 (delete-region (point-min) (point-max))
5500 '("Content-Type:" "Content-Transfer-Encoding:"
5501 "Content-Disposition:"))))
5502 (message-narrow-to-head)
5503 (message-remove-header "MIME-Version")
5504 (goto-char (point-max))
5505 (setq point (point))
5506 (insert (apply 'concat headers))
5508 (narrow-to-region point (point-max))
5509 (let ((message-options message-options))
5510 (message-options-set 'message-sender user-mail-address)
5511 (message-options-set 'message-recipients user-mail-address)
5512 (message-options-set 'message-sign-encrypt 'not)
5514 (goto-char (point-min))
5515 (insert "MIME-Version: 1.0\n")
5517 (gnus-summary-edit-article-done
5518 references nil summary-buffer t))
5519 (when gnus-keep-backlog
5520 (gnus-backlog-remove-article
5521 (car gnus-article-current) (cdr gnus-article-current)))
5523 (when (get-buffer gnus-original-article-buffer)
5524 (set-buffer gnus-original-article-buffer)
5525 (setq gnus-original-article nil)))
5526 (when gnus-use-cache
5527 (gnus-cache-update-article
5528 (car gnus-article-current) (cdr gnus-article-current))))))))
5530 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
5531 "The following specs can be used:
5532 %t The security MIME type
5535 %D Details if button is pressed")
5537 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
5538 "The following specs can be used:
5539 %t The security MIME type
5542 %D Details if button is pressed")
5544 (defvar gnus-mime-security-button-line-format-alist
5545 '((?t gnus-tmp-type ?s)
5546 (?i gnus-tmp-info ?s)
5547 (?d gnus-tmp-details ?s)
5548 (?D gnus-tmp-pressed-details ?s)))
5550 (defvar gnus-mime-security-button-map
5551 (let ((map (make-sparse-keymap)))
5552 (unless (>= (string-to-number emacs-version) 21)
5553 (set-keymap-parent map gnus-article-mode-map))
5554 (define-key map gnus-mouse-2 'gnus-article-push-button)
5555 (define-key map "\r" 'gnus-article-press-button)
5558 (defvar gnus-mime-security-details-buffer nil)
5560 (defvar gnus-mime-security-button-pressed nil)
5562 (defvar gnus-mime-security-show-details-inline t
5563 "If non-nil, show details in the article buffer.")
5565 (defun gnus-mime-security-verify-or-decrypt (handle)
5566 (mm-remove-parts (cdr handle))
5567 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
5568 point buffer-read-only)
5570 (goto-char (car region)))
5572 (narrow-to-region (point) (point))
5573 (with-current-buffer (mm-handle-multipart-original-buffer handle)
5574 (let* ((mm-verify-option 'known)
5575 (mm-decrypt-option 'known)
5576 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
5577 (unless (eq nparts (cdr handle))
5578 (mm-destroy-parts (cdr handle))
5579 (setcdr handle nparts))))
5580 (setq point (point))
5581 (gnus-mime-display-security handle)
5582 (goto-char (point-max)))
5584 (delete-region (point) (cdr region))
5585 (set-marker (car region) nil)
5586 (set-marker (cdr region) nil))
5589 (defun gnus-mime-security-show-details (handle)
5590 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
5592 (if gnus-mime-security-show-details-inline
5593 (let ((gnus-mime-security-button-pressed t)
5594 (gnus-mime-security-button-line-format
5595 (get-text-property (point) 'gnus-line-format))
5598 (while (eq (get-text-property (point) 'gnus-line-format)
5599 gnus-mime-security-button-line-format)
5603 (narrow-to-region (point) (point))
5604 (gnus-insert-mime-security-button handle))
5605 (delete-region (point)
5606 (or (text-property-not-all
5609 gnus-mime-security-button-line-format)
5611 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
5612 (with-current-buffer gnus-mime-security-details-buffer
5615 (setq gnus-mime-security-details-buffer
5616 (gnus-get-buffer-create "*MIME Security Details*")))
5617 (with-current-buffer gnus-mime-security-details-buffer
5619 (goto-char (point-min)))
5620 (pop-to-buffer gnus-mime-security-details-buffer))
5621 (gnus-message 5 "No details."))))
5623 (defun gnus-mime-security-press-button (handle)
5624 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
5625 (gnus-mime-security-show-details handle)
5626 (gnus-mime-security-verify-or-decrypt handle)))
5628 (defun gnus-insert-mime-security-button (handle &optional displayed)
5629 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
5632 (or (nth 2 (assoc protocol mm-verify-function-alist))
5633 (nth 2 (assoc protocol mm-decrypt-function-alist))
5635 (if (equal (car handle) "multipart/signed")
5636 " Signed" " Encrypted")
5639 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
5642 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
5643 gnus-tmp-pressed-details
5645 (setq gnus-tmp-details
5646 (if gnus-tmp-details
5647 (concat "\n" gnus-tmp-details) ""))
5648 (setq gnus-tmp-pressed-details
5649 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
5654 gnus-mime-security-button-line-format
5655 gnus-mime-security-button-line-format-alist
5656 `(keymap ,gnus-mime-security-button-map
5657 ,@(if (>= (string-to-number emacs-version) 21)
5658 nil ;; XEmacs doesn't care
5659 (list 'local-map gnus-mime-security-button-map))
5660 gnus-callback gnus-mime-security-press-button
5661 gnus-line-format ,gnus-mime-security-button-line-format
5662 article-type annotation
5665 (widget-convert-button
5668 :action 'gnus-widget-press-button
5669 :button-keymap gnus-mime-security-button-map
5671 (lambda (widget/window &optional overlay pos)
5672 ;; Needed to properly clear the message due to a bug in
5673 ;; wid-edit (XEmacs only).
5674 (if (boundp 'help-echo-owns-message)
5675 (setq help-echo-owns-message t))
5678 (aref gnus-mouse-2 0))))))
5680 (defun gnus-mime-display-security (handle)
5682 (narrow-to-region (point) (point))
5683 (unless (gnus-unbuttonized-mime-type-p (car handle))
5684 (gnus-insert-mime-security-button handle))
5685 (gnus-mime-display-mixed (cdr handle))
5688 (unless (gnus-unbuttonized-mime-type-p (car handle))
5689 (let ((gnus-mime-security-button-line-format
5690 gnus-mime-security-button-end-line-format))
5691 (gnus-insert-mime-security-button handle)))
5692 (mm-set-handle-multipart-parameter
5694 (cons (set-marker (make-marker) (point-min))
5695 (set-marker (make-marker) (point-max))))))
5701 (run-hooks 'gnus-art-load-hook)
5703 ;;; gnus-art.el ends here