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))
42 (autoload 'gnus-msg-mail "gnus-msg" nil t)
43 (autoload 'gnus-button-mailto "gnus-msg")
44 (autoload 'gnus-button-reply "gnus-msg" nil t)
46 (defgroup gnus-article nil
48 :link '(custom-manual "(gnus)The Article Buffer")
51 (defgroup gnus-article-treat nil
52 "Treating article parts."
53 :link '(custom-manual "(gnus)Article Hiding")
56 (defgroup gnus-article-hiding nil
57 "Hiding article parts."
58 :link '(custom-manual "(gnus)Article Hiding")
61 (defgroup gnus-article-highlight nil
62 "Article highlighting."
63 :link '(custom-manual "(gnus)Article Highlighting")
67 (defgroup gnus-article-signature nil
69 :link '(custom-manual "(gnus)Article Signature")
72 (defgroup gnus-article-headers nil
74 :link '(custom-manual "(gnus)Hiding Headers")
77 (defgroup gnus-article-washing nil
78 "Special commands on articles."
79 :link '(custom-manual "(gnus)Article Washing")
82 (defgroup gnus-article-emphasis nil
83 "Fontisizing articles."
84 :link '(custom-manual "(gnus)Article Fontisizing")
87 (defgroup gnus-article-saving nil
89 :link '(custom-manual "(gnus)Saving Articles")
92 (defgroup gnus-article-mime nil
93 "Worshiping the MIME wonder."
94 :link '(custom-manual "(gnus)Using MIME")
97 (defgroup gnus-article-buttons nil
98 "Pushable buttons in the article buffer."
99 :link '(custom-manual "(gnus)Article Buttons")
100 :group 'gnus-article)
102 (defgroup gnus-article-various nil
103 "Other article options."
104 :link '(custom-manual "(gnus)Misc Article")
105 :group 'gnus-article)
107 (defcustom gnus-ignored-headers
108 '("^Path:" "^Expires:" "^Date-Received:" "^References:" "^Xref:" "^Lines:"
109 "^Relay-Version:" "^Message-ID:" "^Approved:" "^Sender:" "^Received:"
110 "^X-UIDL:" "^MIME-Version:" "^Return-Path:" "^In-Reply-To:"
111 "^Content-Type:" "^Content-Transfer-Encoding:" "^X-WebTV-Signature:"
112 "^X-MimeOLE:" "^X-MSMail-Priority:" "^X-Priority:" "^X-Loop:"
113 "^X-Authentication-Warning:" "^X-MIME-Autoconverted:" "^X-Face:"
114 "^X-Attribution:" "^X-Originating-IP:" "^Delivered-To:"
115 "^NNTP-[-A-Za-z]+:" "^Distribution:" "^X-no-archive:" "^X-Trace:"
116 "^X-Complaints-To:" "^X-NNTP-Posting-Host:" "^X-Orig.*:"
117 "^Abuse-Reports-To:" "^Cache-Post-Path:" "^X-Article-Creation-Date:"
118 "^X-Poster:" "^X-Mail2News-Path:" "^X-Server-Date:" "^X-Cache:"
119 "^Originator:" "^X-Problems-To:" "^X-Auth-User:" "^X-Post-Time:"
120 "^X-Admin:" "^X-UID:" "^Resent-[-A-Za-z]+:" "^X-Mailing-List:"
121 "^Precedence:" "^Original-[-A-Za-z]+:" "^X-filename:" "^X-Orcpt:"
122 "^Old-Received:" "^X-Pgp" "^X-Auth:" "^X-From-Line:"
123 "^X-Gnus-Article-Number:" "^X-Majordomo:" "^X-Url:" "^X-Sender:"
124 "^MBOX-Line" "^Priority:" "^X400-[-A-Za-z]+:"
125 "^Status:" "^X-Gnus-Mail-Source:" "^Cancel-Lock:"
126 "^X-FTN" "^X-EXP32-SerialNo:" "^Encoding:" "^Importance:"
127 "^Autoforwarded:" "^Original-Encoded-Information-Types:" "^X-Ya-Pop3:"
128 "^X-Face-Version:" "^X-Vms-To:" "^X-ML-NAME:" "^X-ML-COUNT:"
129 "^Mailing-List:" "^X-finfo:" "^X-md5sum:" "^X-md5sum-Origin:"
130 "^X-Sun-Charset:" "^X-Accept-Language:" "^X-Envelope-Sender:"
131 "^List-[A-Za-z]+:" "^X-Listprocessor-Version:"
132 "^X-Received:" "^X-Distribute:" "^X-Sequence:" "^X-Juno-Line-Breaks:"
133 "^X-Notes-Item:" "^X-MS-TNEF-Correlator:" "^x-uunet-gateway:"
134 "^X-Received:" "^Content-length:" "X-precedence:"
135 "^X-Authenticated-User:" "^X-Comment" "^X-Report:" "^X-Abuse-Info:"
136 "^X-HTTP-Proxy:" "^X-Mydeja-Info:" "^X-Copyright" "^X-No-Markup:"
138 "*All headers that start with this regexp will be hidden.
139 This variable can also be a list of regexps of headers to be ignored.
140 If `gnus-visible-headers' is non-nil, this variable will be ignored."
141 :type '(choice :custom-show nil
144 :group 'gnus-article-hiding)
146 (defcustom gnus-visible-headers
147 "^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:"
148 "*All headers that do not match this regexp will be hidden.
149 This variable can also be a list of regexp of headers to remain visible.
150 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
151 :type '(repeat :value-to-internal (lambda (widget value)
152 (custom-split-regexp-maybe value))
153 :match (lambda (widget value)
155 (widget-editable-list-match widget value)))
157 :group 'gnus-article-hiding)
159 (defcustom gnus-sorted-header-list
160 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
161 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
162 "*This variable is a list of regular expressions.
163 If it is non-nil, headers that match the regular expressions will
164 be placed first in the article buffer in the sequence specified by
166 :type '(repeat regexp)
167 :group 'gnus-article-hiding)
169 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
170 "Headers that are only to be displayed if they have interesting data.
171 Possible values in this list are:
173 'empty Headers with no content.
174 'newsgroups Newsgroup identical to Gnus group.
175 'to-address To identical to To-address.
176 'followup-to Followup-to identical to Newsgroups.
177 'reply-to Reply-to identical to From.
178 'date Date less than four days old.
179 'long-to To and/or Cc longer than 1024 characters.
180 'many-to Multiple To and/or Cc."
181 :type '(set (const :tag "Headers with no content." empty)
182 (const :tag "Newsgroups identical to Gnus group." newsgroups)
183 (const :tag "To identical to To-address." to-address)
184 (const :tag "Followup-to identical to Newsgroups." followup-to)
185 (const :tag "Reply-to identical to From." reply-to)
186 (const :tag "Date less than four days old." date)
187 (const :tag "To and/or Cc longer than 1024 characters." long-to)
188 (const :tag "Multiple To and/or Cc headers." many-to))
189 :group 'gnus-article-hiding)
191 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
192 "Regexp matching signature separator.
193 This can also be a list of regexps. In that case, it will be checked
194 from head to tail looking for a separator. Searches will be done from
195 the end of the buffer."
196 :type '(repeat string)
197 :group 'gnus-article-signature)
199 (defcustom gnus-signature-limit nil
200 "Provide a limit to what is considered a signature.
201 If it is a number, no signature may not be longer (in characters) than
202 that number. If it is a floating point number, no signature may be
203 longer (in lines) than that number. If it is a function, the function
204 will be called without any parameters, and if it returns nil, there is
205 no signature in the buffer. If it is a string, it will be used as a
206 regexp. If it matches, the text in question is not a signature."
207 :type '(choice (integer :value 200)
209 (function :value fun)
210 (regexp :value ".*"))
211 :group 'gnus-article-signature)
213 (defcustom gnus-hidden-properties '(invisible t intangible t)
214 "Property list to use for hiding text."
216 :group 'gnus-article-hiding)
218 ;; Fixme: This isn't the right thing for mixed graphical and and
219 ;; non-graphical frames in a session.
220 ;; gnus-xmas.el overrides this for XEmacs.
221 (defcustom gnus-article-x-face-command
222 (if (and (fboundp 'image-type-available-p)
223 (image-type-available-p 'xbm))
224 'gnus-article-display-xface
225 (if gnus-article-compface-xbm
226 "{ echo '/* Width=48, Height=48 */'; uncompface; } | display -"
227 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
229 "*String or function to be executed to display an X-Face header.
230 If it is a string, the command will be executed in a sub-shell
231 asynchronously. The compressed face will be piped to this command."
232 :type '(choice string
233 (function-item gnus-article-display-xface)
236 :group 'gnus-article-washing)
238 (defcustom gnus-article-x-face-too-ugly nil
239 "Regexp matching posters whose face shouldn't be shown automatically."
240 :type '(choice regexp (const nil))
241 :group 'gnus-article-washing)
243 (defcustom gnus-article-banner-alist nil
244 "Banner alist for stripping.
246 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
248 :type '(repeat (cons symbol regexp))
249 :group 'gnus-article-washing)
251 (gnus-define-group-parameter
254 "Alist of regexps (to match group names) and banner."
255 :variable-group gnus-article-washing
257 '(choice :tag "Banner"
259 (const :tag "Remove signature" signature)
260 (symbol :tag "Item in `gnus-article-banner-alist'" none)
262 (const :tag "None" nil))
264 "If non-nil, specify how to remove `banners' from articles.
266 Symbol `signature' means to remove signatures delimited by
267 `gnus-signature-separator'. Any other symbol is used to look up a
268 regular expression to match the banner in `gnus-article-banner-alist'.
269 A string is used as a regular expression to match the banner
272 (defcustom gnus-emphasis-alist
274 "\\(\\s-\\|^\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\s-\\|[-,;:\"]\\s-\\|[?!.]+\\s-\\|\\s)\\)")
276 '(("_" "_" underline)
279 ("_/" "/_" underline-italic)
280 ("_\\*" "\\*_" underline-bold)
281 ("\\*/" "/\\*" bold-italic)
282 ("_\\*/" "/\\*_" underline-bold-italic))))
283 `(("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
284 2 3 gnus-emphasis-underline)
288 (format format (car spec) (cadr spec))
289 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
291 "*Alist that says how to fontify certain phrases.
292 Each item looks like this:
294 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
296 The first element is a regular expression to be matched. The second
297 is a number that says what regular expression grouping used to find
298 the entire emphasized word. The third is a number that says what
299 regexp grouping should be displayed and highlighted. The fourth
300 is the face used for highlighting."
301 :type '(repeat (list :value ("" 0 0 default)
303 (integer :tag "Match group")
304 (integer :tag "Emphasize group")
306 :group 'gnus-article-emphasis)
308 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
309 "A regexp to describe whitespace which should not be emphasized.
310 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
311 The former avoids underlining of leading and trailing whitespace,
312 and the latter avoids underlining any whitespace at all."
314 :group 'gnus-article-emphasis
317 (defface gnus-emphasis-bold '((t (:bold t)))
318 "Face used for displaying strong emphasized text (*word*)."
319 :group 'gnus-article-emphasis)
321 (defface gnus-emphasis-italic '((t (:italic t)))
322 "Face used for displaying italic emphasized text (/word/)."
323 :group 'gnus-article-emphasis)
325 (defface gnus-emphasis-underline '((t (:underline t)))
326 "Face used for displaying underlined emphasized text (_word_)."
327 :group 'gnus-article-emphasis)
329 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
330 "Face used for displaying underlined bold emphasized text (_*word*_)."
331 :group 'gnus-article-emphasis)
333 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
334 "Face used for displaying underlined italic emphasized text (_/word/_)."
335 :group 'gnus-article-emphasis)
337 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
338 "Face used for displaying bold italic emphasized text (/*word*/)."
339 :group 'gnus-article-emphasis)
341 (defface gnus-emphasis-underline-bold-italic
342 '((t (:bold t :italic t :underline t)))
343 "Face used for displaying underlined bold italic emphasized text.
344 Esample: (_/*word*/_)."
345 :group 'gnus-article-emphasis)
347 (defface gnus-emphasis-highlight-words
348 '((t (:background "black" :foreground "yellow")))
349 "Face used for displaying highlighted words."
350 :group 'gnus-article-emphasis)
352 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
353 "Format for display of Date headers in article bodies.
354 See `format-time-string' for the possible values.
356 The variable can also be function, which should return a complete Date
357 header. The function is called with one argument, the time, which can
358 be fed to `format-time-string'."
359 :type '(choice string symbol)
360 :link '(custom-manual "(gnus)Article Date")
361 :group 'gnus-article-washing)
364 (autoload 'mail-extract-address-components "mail-extr"))
366 (defcustom gnus-save-all-headers t
367 "*If non-nil, don't remove any headers before saving."
368 :group 'gnus-article-saving
371 (defcustom gnus-prompt-before-saving 'always
372 "*This variable says how much prompting is to be done when saving articles.
373 If it is nil, no prompting will be done, and the articles will be
374 saved to the default files. If this variable is `always', each and
375 every article that is saved will be preceded by a prompt, even when
376 saving large batches of articles. If this variable is neither nil not
377 `always', there the user will be prompted once for a file name for
378 each invocation of the saving commands."
379 :group 'gnus-article-saving
380 :type '(choice (item always)
381 (item :tag "never" nil)
382 (sexp :tag "once" :format "%t\n" :value t)))
384 (defcustom gnus-saved-headers gnus-visible-headers
385 "Headers to keep if `gnus-save-all-headers' is nil.
386 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
387 If that variable is nil, however, all headers that match this regexp
388 will be kept while the rest will be deleted before saving."
389 :group 'gnus-article-saving
392 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
393 "A function to save articles in your favourite format.
394 The function must be interactively callable (in other words, it must
395 be an Emacs command).
397 Gnus provides the following functions:
399 * gnus-summary-save-in-rmail (Rmail format)
400 * gnus-summary-save-in-mail (Unix mail format)
401 * gnus-summary-save-in-folder (MH folder)
402 * gnus-summary-save-in-file (article format)
403 * gnus-summary-save-in-vm (use VM's folder format)
404 * gnus-summary-write-to-file (article format -- overwrite)."
405 :group 'gnus-article-saving
406 :type '(radio (function-item gnus-summary-save-in-rmail)
407 (function-item gnus-summary-save-in-mail)
408 (function-item gnus-summary-save-in-folder)
409 (function-item gnus-summary-save-in-file)
410 (function-item gnus-summary-save-in-vm)
411 (function-item gnus-summary-write-to-file)))
413 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
414 "A function generating a file name to save articles in Rmail format.
415 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
416 :group 'gnus-article-saving
419 (defcustom gnus-mail-save-name 'gnus-plain-save-name
420 "A function generating a file name to save articles in Unix mail format.
421 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
422 :group 'gnus-article-saving
425 (defcustom gnus-folder-save-name 'gnus-folder-save-name
426 "A function generating a file name to save articles in MH folder.
427 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
428 :group 'gnus-article-saving
431 (defcustom gnus-file-save-name 'gnus-numeric-save-name
432 "A function generating a file name to save articles in article format.
433 The function is called with NEWSGROUP, HEADERS, and optional
435 :group 'gnus-article-saving
438 (defcustom gnus-split-methods
439 '((gnus-article-archive-name)
440 (gnus-article-nndoc-name))
441 "*Variable used to suggest where articles are to be saved.
442 For instance, if you would like to save articles related to Gnus in
443 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
444 you could set this variable to something like:
446 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
447 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
449 This variable is an alist where the where the key is the match and the
450 value is a list of possible files to save in if the match is non-nil.
452 If the match is a string, it is used as a regexp match on the
453 article. If the match is a symbol, that symbol will be funcalled
454 from the buffer of the article to be saved with the newsgroup as the
455 parameter. If it is a list, it will be evaled in the same buffer.
457 If this form or function returns a string, this string will be used as
458 a possible file name; and if it returns a non-nil list, that list will
459 be used as possible file names."
460 :group 'gnus-article-saving
461 :type '(repeat (choice (list :value (fun) function)
462 (cons :value ("" "") regexp (repeat string))
465 (defcustom gnus-page-delimiter "^\^L"
466 "*Regexp describing what to use as article page delimiters.
467 The default value is \"^\^L\", which is a form linefeed at the
468 beginning of a line."
470 :group 'gnus-article-various)
472 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
473 "*The format specification for the article mode line.
474 See `gnus-summary-mode-line-format' for a closer description.
476 The following additional specs are available:
478 %w The article washing status.
479 %m The number of MIME parts in the article."
481 :group 'gnus-article-various)
483 (defcustom gnus-article-mode-hook nil
484 "*A hook for Gnus article mode."
486 :group 'gnus-article-various)
488 (when (featurep 'xemacs)
489 ;; Extracted from gnus-xmas-define in order to preserve user settings
490 (when (fboundp 'turn-off-scroll-in-place)
491 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
492 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
493 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
495 (defcustom gnus-article-menu-hook nil
496 "*Hook run after the creation of the article mode menu."
498 :group 'gnus-article-various)
500 (defcustom gnus-article-prepare-hook nil
501 "*A hook called after an article has been prepared in the article buffer."
503 :group 'gnus-article-various)
505 (defcustom gnus-article-hide-pgp-hook nil
506 "*A hook called after successfully hiding a PGP signature."
508 :group 'gnus-article-various)
510 (defcustom gnus-article-button-face 'bold
511 "Face used for highlighting buttons in the article buffer.
513 An article button is a piece of text that you can activate by pressing
514 `RET' or `mouse-2' above it."
516 :group 'gnus-article-buttons)
518 (defcustom gnus-article-mouse-face 'highlight
519 "Face used for mouse highlighting in the article buffer.
521 Article buttons will be displayed in this face when the cursor is
524 :group 'gnus-article-buttons)
526 (defcustom gnus-signature-face 'gnus-signature-face
527 "Face used for highlighting a signature in the article buffer.
528 Obsolete; use the face `gnus-signature-face' for customizations instead."
530 :group 'gnus-article-highlight
531 :group 'gnus-article-signature)
533 (defface gnus-signature-face
536 "Face used for highlighting a signature in the article buffer."
537 :group 'gnus-article-highlight
538 :group 'gnus-article-signature)
540 (defface gnus-header-from-face
543 (:foreground "spring green"))
546 (:foreground "red3"))
549 "Face used for displaying from headers."
550 :group 'gnus-article-headers
551 :group 'gnus-article-highlight)
553 (defface gnus-header-subject-face
556 (:foreground "SeaGreen3"))
559 (:foreground "red4"))
561 (:bold t :italic t)))
562 "Face used for displaying subject headers."
563 :group 'gnus-article-headers
564 :group 'gnus-article-highlight)
566 (defface gnus-header-newsgroups-face
569 (:foreground "yellow" :italic t))
572 (:foreground "MidnightBlue" :italic t))
575 "Face used for displaying newsgroups headers."
576 :group 'gnus-article-headers
577 :group 'gnus-article-highlight)
579 (defface gnus-header-name-face
582 (:foreground "SeaGreen"))
585 (:foreground "maroon"))
588 "Face used for displaying header names."
589 :group 'gnus-article-headers
590 :group 'gnus-article-highlight)
592 (defface gnus-header-content-face
595 (:foreground "forest green" :italic t))
598 (:foreground "indianred4" :italic t))
600 (:italic t))) "Face used for displaying header content."
601 :group 'gnus-article-headers
602 :group 'gnus-article-highlight)
604 (defcustom gnus-header-face-alist
605 '(("From" nil gnus-header-from-face)
606 ("Subject" nil gnus-header-subject-face)
607 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
608 ("" gnus-header-name-face gnus-header-content-face))
609 "*Controls highlighting of article header.
611 An alist of the form (HEADER NAME CONTENT).
613 HEADER is a regular expression which should match the name of an
614 header header and NAME and CONTENT are either face names or nil.
616 The name of each header field will be displayed using the face
617 specified by the first element in the list where HEADER match the
618 header name and NAME is non-nil. Similarly, the content will be
619 displayed by the first non-nil matching CONTENT face."
620 :group 'gnus-article-headers
621 :group 'gnus-article-highlight
622 :type '(repeat (list (regexp :tag "Header")
624 (item :tag "skip" nil)
625 (face :value default))
626 (choice :tag "Content"
627 (item :tag "skip" nil)
628 (face :value default)))))
630 (defcustom gnus-article-decode-hook
631 '(article-decode-charset article-decode-encoded-words)
632 "*Hook run to decode charsets in articles."
633 :group 'gnus-article-headers
636 (defcustom gnus-display-mime-function 'gnus-display-mime
637 "Function to display MIME articles."
638 :group 'gnus-article-mime
641 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
642 "Function used to decode headers.")
644 (defvar gnus-article-dumbquotes-map
663 "Table for MS-to-Latin1 translation.")
665 (defcustom gnus-ignored-mime-types nil
666 "List of MIME types that should be ignored by Gnus."
668 :group 'gnus-article-mime
669 :type '(repeat regexp))
671 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
672 "List of MIME types that should not be given buttons when rendered inline."
674 :group 'gnus-article-mime
675 :type '(repeat regexp))
677 (defcustom gnus-article-mime-part-function nil
678 "Function called with a MIME handle as the argument.
679 This is meant for people who want to do something automatic based
680 on parts -- for instance, adding Vcard info to a database."
681 :group 'gnus-article-mime
684 (defcustom gnus-mime-multipart-functions nil
685 "An alist of MIME types to functions to display them."
687 :group 'gnus-article-mime
690 (defcustom gnus-article-date-lapsed-new-header nil
691 "Whether the X-Sent and Date headers can coexist.
692 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
693 either replace the old \"Date:\" header (if this variable is nil), or
694 be added below it (otherwise)."
696 :group 'gnus-article-headers
699 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
700 "Function called with a MIME handle as the argument.
701 This is meant for people who want to view first matched part.
702 For `undisplayed-alternative' (default), the first undisplayed
703 part or alternative part is used. For `undisplayed', the first
704 undisplayed part is used. For a function, the first part which
705 the function return `t' is used. For `nil', the first part is
708 :group 'gnus-article-mime
710 (item :tag "first" :value nil)
711 (item :tag "undisplayed" :value undisplayed)
712 (item :tag "undisplayed or alternative"
713 :value undisplayed-alternative)
716 (defcustom gnus-mime-action-alist
717 '(("save to file" . gnus-mime-save-part)
718 ("save and strip" . gnus-mime-save-part-and-strip)
719 ("display as text" . gnus-mime-inline-part)
720 ("view the part" . gnus-mime-view-part)
721 ("pipe to command" . gnus-mime-pipe-part)
722 ("toggle display" . gnus-article-press-button)
723 ("toggle display" . gnus-article-view-part-as-charset)
724 ("view as type" . gnus-mime-view-part-as-type)
725 ("internalize type" . gnus-mime-internalize-part)
726 ("externalize type" . gnus-mime-externalize-part))
727 "An alist of actions that run on the MIME attachment."
728 :group 'gnus-article-mime
729 :type '(repeat (cons (string :tag "name")
732 (defcustom gnus-mime-action-alist
733 '(("save to file" . gnus-mime-save-part)
734 ("display as text" . gnus-mime-inline-part)
735 ("view the part" . gnus-mime-view-part)
736 ("pipe to command" . gnus-mime-pipe-part)
737 ("toggle display" . gnus-article-press-button)
738 ("view as type" . gnus-mime-view-part-as-type)
739 ("internalize type" . gnus-mime-internalize-part)
740 ("externalize type" . gnus-mime-externalize-part))
741 "An alist of actions that run on the MIME attachment."
743 :group 'gnus-article-mime
744 :type '(repeat (cons (string :tag "name")
748 ;;; The treatment variables
751 (defvar gnus-part-display-hook nil
752 "Hook called on parts that are to receive treatment.")
754 (defvar gnus-article-treat-custom
755 '(choice (const :tag "Off" nil)
757 (const :tag "Header" head)
758 (const :tag "Last" last)
759 (integer :tag "Less")
760 (repeat :tag "Groups" regexp)
761 (sexp :tag "Predicate")))
763 (defvar gnus-article-treat-head-custom
764 '(choice (const :tag "Off" nil)
765 (const :tag "Header" head)))
767 (defvar gnus-article-treat-types '("text/plain")
770 (defvar gnus-inhibit-treatment nil
771 "Whether to inhibit treatment.")
773 (defcustom gnus-treat-highlight-signature '(or last (typep "text/x-vcard"))
774 "Highlight the signature.
775 Valid values are nil, t, `head', `last', an integer or a predicate.
776 See the manual for details."
777 :group 'gnus-article-treat
778 :type gnus-article-treat-custom)
779 (put 'gnus-treat-highlight-signature 'highlight t)
781 (defcustom gnus-treat-buttonize 100000
783 Valid values are nil, t, `head', `last', an integer or a predicate.
784 See the manual for details."
785 :group 'gnus-article-treat
786 :type gnus-article-treat-custom)
787 (put 'gnus-treat-buttonize 'highlight t)
789 (defcustom gnus-treat-buttonize-head 'head
790 "Add buttons to the head.
791 Valid values are nil, t, `head', `last', an integer or a predicate.
792 See the manual for details."
793 :group 'gnus-article-treat
794 :type gnus-article-treat-head-custom)
795 (put 'gnus-treat-buttonize-head 'highlight t)
797 (defcustom gnus-treat-emphasize
798 (and (or window-system
800 (>= (string-to-number emacs-version) 21))
803 Valid values are nil, t, `head', `last', an integer or a predicate.
804 See the manual for details."
805 :group 'gnus-article-treat
806 :type gnus-article-treat-custom)
807 (put 'gnus-treat-emphasize 'highlight t)
809 (defcustom gnus-treat-strip-cr nil
810 "Remove carriage returns.
811 Valid values are nil, t, `head', `last', an integer or a predicate.
812 See the manual for details."
813 :group 'gnus-article-treat
814 :type gnus-article-treat-custom)
816 (defcustom gnus-treat-leading-whitespace nil
817 "Remove leading whitespace in headers.
818 Valid values are nil, t, `head', `last', an integer or a predicate.
819 See the manual for details."
820 :group 'gnus-article-treat
821 :type gnus-article-treat-custom)
823 (defcustom gnus-treat-hide-headers 'head
825 Valid values are nil, t, `head', `last', an integer or a predicate.
826 See the manual for details."
827 :group 'gnus-article-treat
828 :type gnus-article-treat-head-custom)
830 (defcustom gnus-treat-hide-boring-headers nil
831 "Hide boring headers.
832 Valid values are nil, t, `head', `last', an integer or a predicate.
833 See the manual for details."
834 :group 'gnus-article-treat
835 :type gnus-article-treat-head-custom)
837 (defcustom gnus-treat-hide-signature nil
839 Valid values are nil, t, `head', `last', an integer or a predicate.
840 See the manual for details."
841 :group 'gnus-article-treat
842 :type gnus-article-treat-custom)
844 (defcustom gnus-treat-fill-article nil
846 Valid values are nil, t, `head', `last', an integer or a predicate.
847 See the manual for details."
848 :group 'gnus-article-treat
849 :type gnus-article-treat-custom)
851 (defcustom gnus-treat-hide-citation nil
853 Valid values are nil, t, `head', `last', an integer or a predicate.
854 See the manual for details."
855 :group 'gnus-article-treat
856 :type gnus-article-treat-custom)
858 (defcustom gnus-treat-hide-citation-maybe nil
860 Valid values are nil, t, `head', `last', an integer or a predicate.
861 See the manual for details."
862 :group 'gnus-article-treat
863 :type gnus-article-treat-custom)
865 (defcustom gnus-treat-hide-citation-maybe nil
867 Valid values are nil, t, `head', `last', an integer or a predicate.
868 See the manual for details."
869 :group 'gnus-article-treat
870 :type gnus-article-treat-custom)
872 (defcustom gnus-treat-strip-list-identifiers 'head
873 "Strip list identifiers from `gnus-list-identifiers`.
874 Valid values are nil, t, `head', `last', an integer or a predicate.
875 See the manual for details."
877 :group 'gnus-article-treat
878 :type gnus-article-treat-custom)
880 (defcustom gnus-treat-strip-pgp t
881 "Strip PGP signatures.
882 Valid values are nil, t, `head', `last', an integer or a predicate.
883 See the manual for details."
884 :group 'gnus-article-treat
885 :type gnus-article-treat-custom)
887 (defcustom gnus-treat-strip-pem nil
888 "Strip PEM signatures.
889 Valid values are nil, t, `head', `last', an integer or a predicate.
890 See the manual for details."
891 :group 'gnus-article-treat
892 :type gnus-article-treat-custom)
894 (defcustom gnus-treat-strip-banner t
895 "Strip banners from articles.
896 The banner to be stripped is specified in the `banner' group parameter.
897 Valid values are nil, t, `head', `last', an integer or a predicate.
898 See the manual for details."
899 :group 'gnus-article-treat
900 :type gnus-article-treat-custom)
902 (defcustom gnus-treat-highlight-headers 'head
903 "Highlight the headers.
904 Valid values are nil, t, `head', `last', an integer or a predicate.
905 See the manual for details."
906 :group 'gnus-article-treat
907 :type gnus-article-treat-head-custom)
908 (put 'gnus-treat-highlight-headers 'highlight t)
910 (defcustom gnus-treat-highlight-citation t
911 "Highlight cited text.
912 Valid values are nil, t, `head', `last', an integer or a predicate.
913 See the manual for details."
914 :group 'gnus-article-treat
915 :type gnus-article-treat-custom)
916 (put 'gnus-treat-highlight-citation 'highlight t)
918 (defcustom gnus-treat-date-ut nil
919 "Display the Date in UT (GMT).
920 Valid values are nil, t, `head', `last', an integer or a predicate.
921 See the manual for details."
922 :group 'gnus-article-treat
923 :type gnus-article-treat-head-custom)
925 (defcustom gnus-treat-date-local nil
926 "Display the Date in the local timezone.
927 Valid values are nil, t, `head', `last', an integer or a predicate.
928 See the manual for details."
929 :group 'gnus-article-treat
930 :type gnus-article-treat-head-custom)
932 (defcustom gnus-treat-date-english nil
933 "Display the Date in a format that can be read aloud in English.
934 Valid values are nil, t, `head', `last', an integer or a predicate.
935 See the manual for details."
936 :group 'gnus-article-treat
937 :type gnus-article-treat-head-custom)
939 (defcustom gnus-treat-date-lapsed nil
940 "Display the Date header in a way that says how much time has elapsed.
941 Valid values are nil, t, `head', `last', an integer or a predicate.
942 See the manual for details."
943 :group 'gnus-article-treat
944 :type gnus-article-treat-head-custom)
946 (defcustom gnus-treat-date-original nil
947 "Display the date in the original timezone.
948 Valid values are nil, t, `head', `last', an integer or a predicate.
949 See the manual for details."
950 :group 'gnus-article-treat
951 :type gnus-article-treat-head-custom)
953 (defcustom gnus-treat-date-iso8601 nil
954 "Display the date in the ISO8601 format.
955 Valid values are nil, t, `head', `last', an integer or a predicate.
956 See the manual for details."
958 :group 'gnus-article-treat
959 :type gnus-article-treat-head-custom)
961 (defcustom gnus-treat-date-user-defined nil
962 "Display the date in a user-defined format.
963 The format is defined by the `gnus-article-time-format' variable.
964 Valid values are nil, t, `head', `last', an integer or a predicate.
965 See the manual for details."
966 :group 'gnus-article-treat
967 :type gnus-article-treat-head-custom)
969 (defcustom gnus-treat-strip-headers-in-body t
970 "Strip the X-No-Archive header line from the beginning of the body.
971 Valid values are nil, t, `head', `last', an integer or a predicate.
972 See the manual for details."
974 :group 'gnus-article-treat
975 :type gnus-article-treat-custom)
977 (defcustom gnus-treat-strip-trailing-blank-lines nil
978 "Strip trailing blank lines.
979 Valid values are nil, t, `head', `last', an integer or a predicate.
980 See the manual for details."
981 :group 'gnus-article-treat
982 :type gnus-article-treat-custom)
984 (defcustom gnus-treat-strip-leading-blank-lines nil
985 "Strip leading blank lines.
986 Valid values are nil, t, `head', `last', an integer or a predicate.
987 See the manual for details."
988 :group 'gnus-article-treat
989 :type gnus-article-treat-custom)
991 (defcustom gnus-treat-strip-multiple-blank-lines nil
992 "Strip multiple blank lines.
993 Valid values are nil, t, `head', `last', an integer or a predicate.
994 See the manual for details."
995 :group 'gnus-article-treat
996 :type gnus-article-treat-custom)
998 (defcustom gnus-treat-overstrike t
999 "Treat overstrike highlighting.
1000 Valid values are nil, t, `head', `last', an integer or a predicate.
1001 See the manual for details."
1002 :group 'gnus-article-treat
1003 :type gnus-article-treat-custom)
1004 (put 'gnus-treat-overstrike 'highlight t)
1006 (defcustom gnus-treat-display-xface
1007 (and (or (and (fboundp 'image-type-available-p)
1008 (image-type-available-p 'xbm)
1009 (string-match "^0x" (shell-command-to-string "uncompface")))
1010 (and (featurep 'xemacs) (featurep 'xface)))
1012 "Display X-Face headers.
1013 Valid values are nil, t, `head', `last', an integer or a predicate.
1014 See the manual for details."
1015 :group 'gnus-article-treat
1017 :type gnus-article-treat-head-custom)
1018 (put 'gnus-treat-display-xface 'highlight t)
1020 (defcustom gnus-treat-display-smileys
1021 (if (or (and (featurep 'xemacs)
1023 (and (fboundp 'image-type-available-p)
1024 (image-type-available-p 'pbm)))
1027 Valid values are nil, t, `head', `last', an integer or a predicate.
1028 See the manual for details."
1029 :group 'gnus-article-treat
1031 :type gnus-article-treat-custom)
1032 (put 'gnus-treat-display-smileys 'highlight t)
1034 (defcustom gnus-treat-display-picons (if (featurep 'xemacs) 'head nil)
1036 Valid values are nil, t, `head', `last', an integer or a predicate.
1037 See the manual for details."
1038 :group 'gnus-article-treat
1039 :type gnus-article-treat-head-custom)
1040 (put 'gnus-treat-display-picons 'highlight t)
1042 (defcustom gnus-treat-capitalize-sentences nil
1043 "Capitalize sentence-starting words.
1044 Valid values are nil, t, `head', `last', an integer or a predicate.
1045 See the manual for details."
1047 :group 'gnus-article-treat
1048 :type gnus-article-treat-custom)
1050 (defcustom gnus-treat-fill-long-lines nil
1052 Valid values are nil, t, `head', `last', an integer or a predicate.
1053 See the manual for details."
1054 :group 'gnus-article-treat
1055 :type gnus-article-treat-custom)
1057 (defcustom gnus-treat-play-sounds nil
1059 Valid values are nil, t, `head', `last', an integer or a predicate.
1060 See the manual for details."
1062 :group 'gnus-article-treat
1063 :type gnus-article-treat-custom)
1065 (defcustom gnus-treat-translate nil
1066 "Translate articles from one language to another.
1067 Valid values are nil, t, `head', `last', an integer or a predicate.
1068 See the manual for details."
1070 :group 'gnus-article-treat
1071 :type gnus-article-treat-custom)
1073 (defcustom gnus-treat-x-pgp-sig nil
1075 To automatically treat X-PGP-Sig, set it to head.
1076 Valid values are nil, t, `head', `last', an integer or a predicate.
1077 See the manual for details."
1078 :group 'gnus-article-treat
1079 :group 'mime-security
1080 :type gnus-article-treat-custom)
1082 (defvar gnus-article-encrypt-protocol-alist
1083 '(("PGP" . mml2015-self-encrypt)))
1085 ;; Set to nil if more than one protocol added to
1086 ;; gnus-article-encrypt-protocol-alist.
1087 (defcustom gnus-article-encrypt-protocol "PGP"
1088 "The protocol used for encrypt articles.
1089 It is a string, such as \"PGP\". If nil, ask user."
1091 :group 'mime-security)
1093 ;;; Internal variables
1095 (defvar gnus-english-month-names
1096 '("January" "February" "March" "April" "May" "June" "July" "August"
1097 "September" "October" "November" "December"))
1099 (defvar article-goto-body-goes-to-point-min-p nil)
1100 (defvar gnus-article-wash-types nil)
1101 (defvar gnus-article-emphasis-alist nil)
1103 (defvar gnus-article-mime-handle-alist-1 nil)
1104 (defvar gnus-treatment-function-alist
1105 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1106 (gnus-treat-strip-banner gnus-article-strip-banner)
1107 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1108 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1109 (gnus-treat-buttonize gnus-article-add-buttons)
1110 (gnus-treat-fill-article gnus-article-fill-cited-article)
1111 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1112 (gnus-treat-strip-cr gnus-article-remove-cr)
1113 (gnus-treat-emphasize gnus-article-emphasize)
1114 (gnus-treat-display-xface gnus-article-display-x-face)
1115 (gnus-treat-date-ut gnus-article-date-ut)
1116 (gnus-treat-date-local gnus-article-date-local)
1117 (gnus-treat-date-english gnus-article-date-english)
1118 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1119 (gnus-treat-date-original gnus-article-date-original)
1120 (gnus-treat-date-user-defined gnus-article-date-user)
1121 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1122 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1123 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1124 (gnus-treat-hide-signature gnus-article-hide-signature)
1125 (gnus-treat-hide-citation gnus-article-hide-citation)
1126 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1127 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1128 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1129 (gnus-treat-strip-pgp gnus-article-hide-pgp)
1130 (gnus-treat-strip-pem gnus-article-hide-pem)
1131 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1132 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1133 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1134 (gnus-treat-strip-trailing-blank-lines
1135 gnus-article-remove-trailing-blank-lines)
1136 (gnus-treat-strip-leading-blank-lines
1137 gnus-article-strip-leading-blank-lines)
1138 (gnus-treat-strip-multiple-blank-lines
1139 gnus-article-strip-multiple-blank-lines)
1140 (gnus-treat-overstrike gnus-article-treat-overstrike)
1141 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1142 (gnus-treat-display-smileys gnus-smiley-display)
1143 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1144 (gnus-treat-display-picons gnus-article-display-picons)
1145 (gnus-treat-play-sounds gnus-earcon-display)))
1147 (defvar gnus-article-mime-handle-alist nil)
1148 (defvar article-lapsed-timer nil)
1149 (defvar gnus-article-current-summary nil)
1151 (defvar gnus-article-mode-syntax-table
1152 (let ((table (copy-syntax-table text-mode-syntax-table)))
1153 ;; This causes the citation match run O(2^n).
1154 ;; (modify-syntax-entry ?- "w" table)
1155 (modify-syntax-entry ?> ")" table)
1156 (modify-syntax-entry ?< "(" table)
1158 "Syntax table used in article mode buffers.
1159 Initialized from `text-mode-syntax-table.")
1161 (defvar gnus-save-article-buffer nil)
1163 (defvar gnus-article-mode-line-format-alist
1164 (nconc '((?w (gnus-article-wash-status) ?s)
1165 (?m (gnus-article-mime-part-status) ?s))
1166 gnus-summary-mode-line-format-alist))
1168 (defvar gnus-number-of-articles-to-be-saved nil)
1170 (defvar gnus-inhibit-hiding nil)
1172 (defsubst gnus-article-hide-text (b e props)
1173 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1174 (gnus-add-text-properties-when 'article-type nil b e props)
1175 (when (memq 'intangible props)
1177 (max (1- b) (point-min))
1178 b 'intangible (cddr (memq 'intangible props)))))
1180 (defsubst gnus-article-unhide-text (b e)
1181 "Remove hidden text properties from region between B and E."
1182 (remove-text-properties b e gnus-hidden-properties)
1183 (when (memq 'intangible gnus-hidden-properties)
1184 (put-text-property (max (1- b) (point-min))
1185 b 'intangible nil)))
1187 (defun gnus-article-hide-text-type (b e type)
1188 "Hide text of TYPE between B and E."
1189 (push type gnus-article-wash-types)
1190 (gnus-article-hide-text
1191 b e (cons 'article-type (cons type gnus-hidden-properties))))
1193 (defun gnus-article-unhide-text-type (b e type)
1194 "Unhide text of TYPE between B and E."
1195 (setq gnus-article-wash-types
1196 (delq type gnus-article-wash-types))
1197 (remove-text-properties
1198 b e (cons 'article-type (cons type gnus-hidden-properties)))
1199 (when (memq 'intangible gnus-hidden-properties)
1200 (put-text-property (max (1- b) (point-min))
1201 b 'intangible nil)))
1203 (defun gnus-article-hide-text-of-type (type)
1204 "Hide text of TYPE in the current buffer."
1206 (let ((b (point-min))
1208 (while (setq b (text-property-any b e 'article-type type))
1209 (add-text-properties b (incf b) gnus-hidden-properties)))))
1211 (defun gnus-article-delete-text-of-type (type)
1212 "Delete text of TYPE in the current buffer."
1214 (let ((b (point-min)))
1215 (while (setq b (text-property-any b (point-max) 'article-type type))
1217 b (or (text-property-not-all b (point-max) 'article-type type)
1220 (defun gnus-article-delete-invisible-text ()
1221 "Delete all invisible text in the current buffer."
1223 (let ((b (point-min)))
1224 (while (setq b (text-property-any b (point-max) 'invisible t))
1226 b (or (text-property-not-all b (point-max) 'invisible t)
1229 (defun gnus-article-text-type-exists-p (type)
1230 "Say whether any text of type TYPE exists in the buffer."
1231 (text-property-any (point-min) (point-max) 'article-type type))
1233 (defsubst gnus-article-header-rank ()
1234 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1235 (let ((list gnus-sorted-header-list)
1238 (when (looking-at (car list))
1240 (setq list (cdr list))
1244 (defun article-hide-headers (&optional arg delete)
1245 "Hide unwanted headers and possibly sort them as well."
1247 ;; This function might be inhibited.
1248 (unless gnus-inhibit-hiding
1251 (let ((buffer-read-only nil)
1252 (case-fold-search t)
1253 (max (1+ (length gnus-sorted-header-list)))
1254 (ignored (when (not gnus-visible-headers)
1255 (cond ((stringp gnus-ignored-headers)
1256 gnus-ignored-headers)
1257 ((listp gnus-ignored-headers)
1258 (mapconcat 'identity gnus-ignored-headers
1261 (cond ((stringp gnus-visible-headers)
1262 gnus-visible-headers)
1263 ((and gnus-visible-headers
1264 (listp gnus-visible-headers))
1265 (mapconcat 'identity gnus-visible-headers "\\|"))))
1266 (inhibit-point-motion-hooks t)
1268 ;; First we narrow to just the headers.
1269 (article-narrow-to-head)
1270 ;; Hide any "From " lines at the beginning of (mail) articles.
1271 (while (looking-at "From ")
1274 (delete-region (point-min) (point)))
1275 ;; Then treat the rest of the header lines.
1276 ;; Then we use the two regular expressions
1277 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1278 ;; select which header lines is to remain visible in the
1280 (while (re-search-forward "^[^ \t:]*:" nil t)
1282 ;; Mark the rank of the header.
1284 (point) (1+ (point)) 'message-rank
1285 (if (or (and visible (looking-at visible))
1287 (not (looking-at ignored))))
1288 (gnus-article-header-rank)
1291 (message-sort-headers-1)
1292 (when (setq beg (text-property-any
1293 (point-min) (point-max) 'message-rank (+ 2 max)))
1294 ;; We delete the unwanted headers.
1295 (push 'headers gnus-article-wash-types)
1296 (add-text-properties (point-min) (+ 5 (point-min))
1297 '(article-type headers dummy-invisible t))
1298 (delete-region beg (point-max))))))))
1300 (defun article-hide-boring-headers (&optional arg)
1301 "Toggle hiding of headers that aren't very interesting.
1302 If given a negative prefix, always show; if given a positive prefix,
1304 (interactive (gnus-article-hidden-arg))
1305 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1306 (not gnus-show-all-headers))
1309 (let ((buffer-read-only nil)
1310 (list gnus-boring-article-headers)
1311 (inhibit-point-motion-hooks t)
1313 (article-narrow-to-head)
1315 (setq elem (pop list))
1316 (goto-char (point-min))
1318 ;; Hide empty headers.
1320 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1322 (gnus-article-hide-text-type
1323 (progn (beginning-of-line) (point))
1326 (if (re-search-forward "^[^ \t]" nil t)
1330 ;; Hide boring Newsgroups header.
1331 ((eq elem 'newsgroups)
1332 (when (gnus-string-equal
1333 (gnus-fetch-field "newsgroups")
1334 (gnus-group-real-name
1335 (if (boundp 'gnus-newsgroup-name)
1338 (gnus-article-hide-header "newsgroups")))
1339 ((eq elem 'to-address)
1340 (let ((to (message-fetch-field "to"))
1342 (gnus-parameter-to-address
1343 (if (boundp 'gnus-newsgroup-name)
1344 gnus-newsgroup-name ""))))
1345 (when (and to to-address
1348 ;; only one address in To
1349 (nth 1 (mail-extract-address-components to))
1351 (gnus-article-hide-header "to"))))
1352 ((eq elem 'followup-to)
1353 (when (gnus-string-equal
1354 (message-fetch-field "followup-to")
1355 (message-fetch-field "newsgroups"))
1356 (gnus-article-hide-header "followup-to")))
1357 ((eq elem 'reply-to)
1358 (let ((from (message-fetch-field "from"))
1359 (reply-to (message-fetch-field "reply-to")))
1364 (nth 1 (mail-extract-address-components from))
1365 (nth 1 (mail-extract-address-components reply-to)))))
1366 (gnus-article-hide-header "reply-to"))))
1368 (let ((date (message-fetch-field "date")))
1370 (< (days-between (current-time-string) date)
1372 (gnus-article-hide-header "date"))))
1374 (let ((to (message-fetch-field "to"))
1375 (cc (message-fetch-field "cc")))
1376 (when (> (length to) 1024)
1377 (gnus-article-hide-header "to"))
1378 (when (> (length cc) 1024)
1379 (gnus-article-hide-header "cc"))))
1383 (goto-char (point-min))
1384 (while (re-search-forward "^to:" nil t)
1385 (setq to-count (1+ to-count)))
1386 (when (> to-count 1)
1387 (while (> to-count 0)
1388 (goto-char (point-min))
1390 (re-search-forward "^to:" nil nil to-count)
1392 (narrow-to-region (point) (point-max))
1393 (gnus-article-hide-header "to"))
1394 (setq to-count (1- to-count))))
1395 (goto-char (point-min))
1396 (while (re-search-forward "^cc:" nil t)
1397 (setq cc-count (1+ cc-count)))
1398 (when (> cc-count 1)
1399 (while (> cc-count 0)
1400 (goto-char (point-min))
1402 (re-search-forward "^cc:" nil nil cc-count)
1404 (narrow-to-region (point) (point-max))
1405 (gnus-article-hide-header "cc"))
1406 (setq cc-count (1- cc-count)))))))))))))
1408 (defun gnus-article-hide-header (header)
1410 (goto-char (point-min))
1411 (when (re-search-forward (concat "^" header ":") nil t)
1412 (gnus-article-hide-text-type
1413 (progn (beginning-of-line) (point))
1416 (if (re-search-forward "^[^ \t]" nil t)
1421 (defvar gnus-article-normalized-header-length 40
1422 "Length of normalized headers.")
1424 (defun article-normalize-headers ()
1425 "Make all header lines 40 characters long."
1427 (let ((buffer-read-only nil)
1431 (article-narrow-to-head)
1434 ((< (setq column (- (gnus-point-at-eol) (point)))
1435 gnus-article-normalized-header-length)
1437 (insert (make-string
1438 (- gnus-article-normalized-header-length column)
1440 ((> column gnus-article-normalized-header-length)
1441 (gnus-put-text-property
1443 (forward-char gnus-article-normalized-header-length)
1450 (forward-line 1))))))
1452 (defun article-treat-dumbquotes ()
1453 "Translate M****s*** sm*rtq**t*s into proper text.
1454 Note that this function guesses whether a character is a sm*rtq**t* or
1455 not, so it should only be used interactively.
1457 Sm*rtq**t*s are M****s***'s unilateral extension to the character map
1458 in an attempt to provide more quoting characters. If you see
1459 something like \\222 or \\264 where you're expecting some kind of
1460 apostrophe or quotation mark, then try this wash."
1462 (article-translate-strings gnus-article-dumbquotes-map))
1464 (defun article-translate-characters (from to)
1465 "Translate all characters in the body of the article according to FROM and TO.
1466 FROM is a string of characters to translate from; to is a string of
1467 characters to translate to."
1469 (when (article-goto-body)
1470 (let ((buffer-read-only nil)
1471 (x (make-string 225 ?x))
1473 (while (< (incf i) (length x))
1476 (while (< i (length from))
1477 (aset x (aref from i) (aref to i))
1479 (translate-region (point) (point-max) x)))))
1481 (defun article-translate-strings (map)
1482 "Translate all string in the body of the article according to MAP.
1483 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1485 (when (article-goto-body)
1486 (let ((buffer-read-only nil)
1488 (while (setq elem (pop map))
1490 (while (search-forward (car elem) nil t)
1491 (replace-match (cadr elem)))))))))
1493 (defun article-treat-overstrike ()
1494 "Translate overstrikes into bold text."
1497 (when (article-goto-body)
1498 (let ((buffer-read-only nil))
1499 (while (search-forward "\b" nil t)
1500 (let ((next (char-after))
1501 (previous (char-after (- (point) 2))))
1502 ;; We do the boldification/underlining by hiding the
1503 ;; overstrikes and putting the proper text property
1507 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1508 (put-text-property (point) (1+ (point)) 'face 'bold))
1510 (gnus-article-hide-text-type
1511 (1- (point)) (1+ (point)) 'overstrike)
1513 (- (point) 2) (1- (point)) 'face 'underline))
1515 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1517 (point) (1+ (point)) 'face 'underline)))))))))
1519 (defun article-fill-long-lines ()
1520 "Fill lines that are wider than the window width."
1523 (let ((buffer-read-only nil)
1524 (width (window-width (get-buffer-window (current-buffer)))))
1527 (let ((adaptive-fill-mode nil))
1530 (when (>= (current-column) (min fill-column width))
1531 (narrow-to-region (point) (gnus-point-at-bol))
1532 (fill-paragraph nil)
1533 (goto-char (point-max))
1535 (forward-line 1)))))))
1537 (defun article-capitalize-sentences ()
1538 "Capitalize the first word in each sentence."
1541 (let ((buffer-read-only nil)
1542 (paragraph-start "^[\n\^L]"))
1546 (forward-sentence)))))
1548 (defun article-remove-cr ()
1549 "Remove trailing CRs and then translate remaining CRs into LFs."
1552 (let ((buffer-read-only nil))
1553 (goto-char (point-min))
1554 (while (re-search-forward "\r+$" nil t)
1555 (replace-match "" t t))
1556 (goto-char (point-min))
1557 (while (search-forward "\r" nil t)
1558 (replace-match "\n" t t)))))
1560 (defun article-remove-trailing-blank-lines ()
1561 "Remove all trailing blank lines from the article."
1564 (let ((buffer-read-only nil))
1565 (goto-char (point-max))
1569 (while (and (not (bobp))
1570 (looking-at "^[ \t]*$")
1571 (not (gnus-annotation-in-region-p
1572 (point) (gnus-point-at-eol))))
1577 (defun article-display-x-face (&optional force)
1578 "Look for an X-Face header and display it if present."
1579 (interactive (list 'force))
1581 ;; Delete the old process, if any.
1582 (when (process-status "article-x-face")
1583 (delete-process "article-x-face"))
1584 (let ((inhibit-point-motion-hooks t)
1586 (case-fold-search t)
1589 (article-narrow-to-head)
1590 (when (and buffer-read-only ;; When type `W f'
1592 (goto-char (point-min))
1593 (not (re-search-forward "^X-Face:[\t ]*" nil t)))
1594 (gnus-buffer-live-p gnus-original-article-buffer))
1595 (with-current-buffer gnus-original-article-buffer
1597 (article-narrow-to-head)
1598 (while (re-search-forward "^X-Face:" nil t)
1604 (1- (re-search-forward
1605 "^\\($\\|[^ \t]\\)" nil t))))))))
1607 (let (point start bface eface buffer-read-only)
1608 (goto-char (point-max))
1610 (setq bface (get-text-property (gnus-point-at-bol) 'face)
1611 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
1612 (goto-char (point-max))
1613 (setq point (point))
1616 (while (looking-at "\\([^:]+\\): *")
1617 (put-text-property (match-beginning 1) (1+ (match-end 1))
1619 (setq start (match-end 0))
1621 (while (looking-at "[\t ]")
1623 (put-text-property start (point)
1625 (goto-char (point-min))
1626 (setq from (message-fetch-field "from"))
1627 (goto-char (point-min))
1628 (while (and gnus-article-x-face-command
1631 ;; Check whether this face is censored.
1632 (not gnus-article-x-face-too-ugly)
1633 (and gnus-article-x-face-too-ugly from
1634 (not (string-match gnus-article-x-face-too-ugly
1636 ;; Has to be present.
1637 (re-search-forward "^X-Face:[\t ]*" nil t))
1638 ;; This used to try to do multiple faces (`while' instead of
1639 ;; `when' above), but (a) sending multiple EOFs to xv doesn't
1640 ;; work (b) it can crash some versions of Emacs (c) are
1641 ;; multiple faces really something to encourage?
1642 (when (stringp gnus-article-x-face-command)
1644 ;; We now have the area of the buffer where the X-Face is stored.
1647 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
1648 ;; We display the face.
1649 (if (symbolp gnus-article-x-face-command)
1650 ;; The command is a lisp function, so we call it.
1651 (if (gnus-functionp gnus-article-x-face-command)
1652 (funcall gnus-article-x-face-command beg end)
1653 (error "%s is not a function" gnus-article-x-face-command))
1654 ;; The command is a string, so we interpret the command
1655 ;; as a, well, command, and fork it off.
1656 (let ((process-connection-type nil))
1657 (process-kill-without-query
1659 "article-x-face" nil shell-file-name shell-command-switch
1660 gnus-article-x-face-command))
1661 (process-send-region "article-x-face" beg end)
1662 (process-send-eof "article-x-face"))))))))))
1664 (defun article-decode-mime-words ()
1665 "Decode all MIME-encoded words in the article."
1668 (set-buffer gnus-article-buffer)
1669 (let ((inhibit-point-motion-hooks t)
1671 (mail-parse-charset gnus-newsgroup-charset)
1672 (mail-parse-ignored-charsets
1673 (save-excursion (set-buffer gnus-summary-buffer)
1674 gnus-newsgroup-ignored-charsets)))
1675 (mail-decode-encoded-word-region (point-min) (point-max)))))
1677 (defun article-decode-charset (&optional prompt)
1678 "Decode charset-encoded text in the article.
1679 If PROMPT (the prefix), prompt for a coding system to use."
1681 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
1683 (mail-parse-charset gnus-newsgroup-charset)
1684 (mail-parse-ignored-charsets
1685 (save-excursion (condition-case nil
1686 (set-buffer gnus-summary-buffer)
1688 gnus-newsgroup-ignored-charsets))
1689 ct cte ctl charset format)
1692 (article-narrow-to-head)
1693 (setq ct (message-fetch-field "Content-Type" t)
1694 cte (message-fetch-field "Content-Transfer-Encoding" t)
1695 ctl (and ct (ignore-errors
1696 (mail-header-parse-content-type ct)))
1699 (mm-read-coding-system "Charset to decode: "))
1701 (mail-content-type-get ctl 'charset)))
1702 format (and ctl (mail-content-type-get ctl 'format)))
1704 (setq cte (mail-header-strip cte)))
1705 (if (and ctl (not (string-match "/" (car ctl))))
1707 (goto-char (point-max)))
1710 (narrow-to-region (point) (point-max))
1711 (when (and (eq mail-parse-charset 'gnus-decoded)
1712 (eq (mm-body-7-or-8) '8bit))
1713 ;; The text code could have been decoded.
1714 (setq charset mail-parse-charset))
1715 (when (and (or (not ctl)
1716 (equal (car ctl) "text/plain"))
1717 (not format)) ;; article with format will decode later.
1719 charset (and cte (intern (downcase
1720 (gnus-strip-whitespace cte))))
1723 (defun article-decode-encoded-words ()
1724 "Remove encoded-word encoding from headers."
1725 (let ((inhibit-point-motion-hooks t)
1726 (mail-parse-charset gnus-newsgroup-charset)
1727 (mail-parse-ignored-charsets
1728 (save-excursion (condition-case nil
1729 (set-buffer gnus-summary-buffer)
1731 gnus-newsgroup-ignored-charsets))
1734 (article-narrow-to-head)
1735 (funcall gnus-decode-header-function (point-min) (point-max)))))
1737 (defun article-de-quoted-unreadable (&optional force read-charset)
1738 "Translate a quoted-printable-encoded article.
1739 If FORCE, decode the article whether it is marked as quoted-printable
1741 If READ-CHARSET, ask for a coding system."
1742 (interactive (list 'force current-prefix-arg))
1744 (let ((buffer-read-only nil) type charset)
1745 (if (gnus-buffer-live-p gnus-original-article-buffer)
1746 (with-current-buffer gnus-original-article-buffer
1748 (gnus-fetch-field "content-transfer-encoding"))
1749 (let* ((ct (gnus-fetch-field "content-type"))
1752 (mail-header-parse-content-type ct)))))
1753 (setq charset (and ctl
1754 (mail-content-type-get ctl 'charset)))
1755 (if (stringp charset)
1756 (setq charset (intern (downcase charset)))))))
1758 (setq charset (read-coding-system "Charset: " charset)))
1760 (setq charset gnus-newsgroup-charset))
1762 (and type (let ((case-fold-search t))
1763 (string-match "quoted-printable" type))))
1765 (quoted-printable-decode-region
1766 (point) (point-max) (mm-charset-to-coding-system charset))))))
1768 (defun article-de-base64-unreadable (&optional force read-charset)
1769 "Translate a base64 article.
1770 If FORCE, decode the article whether it is marked as base64 not.
1771 If READ-CHARSET, ask for a coding system."
1772 (interactive (list 'force current-prefix-arg))
1774 (let ((buffer-read-only nil) type charset)
1775 (if (gnus-buffer-live-p gnus-original-article-buffer)
1776 (with-current-buffer gnus-original-article-buffer
1778 (gnus-fetch-field "content-transfer-encoding"))
1779 (let* ((ct (gnus-fetch-field "content-type"))
1782 (mail-header-parse-content-type ct)))))
1783 (setq charset (and ctl
1784 (mail-content-type-get ctl 'charset)))
1785 (if (stringp charset)
1786 (setq charset (intern (downcase charset)))))))
1788 (setq charset (read-coding-system "Charset: " charset)))
1790 (setq charset gnus-newsgroup-charset))
1792 (and type (let ((case-fold-search t))
1793 (string-match "base64" type))))
1796 (narrow-to-region (point) (point-max))
1797 (base64-decode-region (point-min) (point-max))
1798 (mm-decode-coding-region
1799 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
1804 (defun article-decode-HZ ()
1805 "Translate a HZ-encoded article."
1809 (let ((buffer-read-only nil))
1810 (rfc1843-decode-region (point-min) (point-max)))))
1812 (defun article-wash-html (&optional read-charset)
1813 "Format an html article.
1814 If READ-CHARSET, ask for a coding system."
1817 (let ((buffer-read-only nil)
1819 (if (gnus-buffer-live-p gnus-original-article-buffer)
1820 (with-current-buffer gnus-original-article-buffer
1821 (let* ((ct (gnus-fetch-field "content-type"))
1824 (mail-header-parse-content-type ct)))))
1825 (setq charset (and ctl
1826 (mail-content-type-get ctl 'charset)))
1827 (if (stringp charset)
1828 (setq charset (intern (downcase charset)))))))
1830 (setq charset (read-coding-system "Charset: " charset)))
1832 (setq charset gnus-newsgroup-charset))
1834 (save-window-excursion
1836 (narrow-to-region (point) (point-max))
1838 (let ((w3-strict-width (window-width))
1839 (url-standalone-mode t))
1841 (w3-region (point-min) (point-max))
1844 (defun article-hide-list-identifiers ()
1845 "Remove list identifies from the Subject header.
1846 The `gnus-list-identifiers' variable specifies what to do."
1848 (let ((inhibit-point-motion-hooks t)
1849 (regexp (if (consp gnus-list-identifiers)
1850 (mapconcat 'identity gnus-list-identifiers " *\\|")
1851 gnus-list-identifiers))
1856 (article-narrow-to-head)
1857 (goto-char (point-min))
1858 (while (re-search-forward
1859 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
1861 (delete-region (match-beginning 2) (match-end 0))
1862 (beginning-of-line))
1863 (when (re-search-forward
1864 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
1865 (delete-region (match-beginning 1) (match-end 1))))))))
1867 (defun article-hide-pgp ()
1868 "Remove any PGP headers and signatures in the current article."
1872 (let ((inhibit-point-motion-hooks t)
1873 buffer-read-only beg end)
1875 ;; Hide the "header".
1876 (when (re-search-forward "^-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
1877 (push 'pgp gnus-article-wash-types)
1878 (delete-region (match-beginning 0) (match-end 0))
1879 ;; Remove armor headers (rfc2440 6.2)
1880 (delete-region (point) (or (re-search-forward "^[ \t]*\n" nil t)
1883 ;; Hide the actual signature.
1884 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
1885 (setq end (1+ (match-beginning 0)))
1888 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
1890 ;; Perhaps we shouldn't hide to the end of the buffer
1891 ;; if there is no end to the signature?
1893 ;; Hide "- " PGP quotation markers.
1895 (narrow-to-region beg end)
1896 (goto-char (point-min))
1897 (while (re-search-forward "^- " nil t)
1899 (match-beginning 0) (match-end 0)))
1901 (gnus-run-hooks 'gnus-article-hide-pgp-hook))))))
1903 (defun article-hide-pem (&optional arg)
1904 "Toggle hiding of any PEM headers and signatures in the current article.
1905 If given a negative prefix, always show; if given a positive prefix,
1907 (interactive (gnus-article-hidden-arg))
1908 (unless (gnus-article-check-hidden-text 'pem arg)
1910 (let (buffer-read-only end)
1911 (goto-char (point-min))
1912 ;; Hide the horrendously ugly "header".
1913 (when (and (search-forward
1914 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
1916 (setq end (1+ (match-beginning 0))))
1917 (push 'pem gnus-article-wash-types)
1918 (gnus-article-hide-text-type
1920 (if (search-forward "\n\n" nil t)
1924 ;; Hide the trailer as well
1925 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
1927 (gnus-article-hide-text-type
1928 (match-beginning 0) (match-end 0) 'pem)))))))
1930 (defun article-strip-banner ()
1931 "Strip the banner specified by the `banner' group parameter."
1935 (let ((inhibit-point-motion-hooks t)
1936 (banner (gnus-parameter-banner gnus-newsgroup-name))
1937 (gnus-signature-limit nil)
1938 buffer-read-only beg end)
1942 ((eq banner 'signature)
1943 (when (gnus-article-narrow-to-signature)
1946 (delete-region (point) (point-max))))
1948 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
1949 (while (re-search-forward banner nil t)
1950 (delete-region (match-beginning 0) (match-end 0)))))
1952 (while (re-search-forward banner nil t)
1953 (delete-region (match-beginning 0) (match-end 0))))))))))
1955 (defun article-babel ()
1956 "Translate article using an online translation service."
1960 (set-buffer gnus-article-buffer)
1961 (when (article-goto-body)
1962 (let* ((buffer-read-only nil)
1965 (orig (buffer-substring start end))
1966 (trans (babel-as-string orig)))
1968 (narrow-to-region start end)
1969 (delete-region start end)
1972 (defun article-hide-signature (&optional arg)
1973 "Hide the signature in the current article.
1974 If given a negative prefix, always show; if given a positive prefix,
1976 (interactive (gnus-article-hidden-arg))
1977 (unless (gnus-article-check-hidden-text 'signature arg)
1980 (let ((buffer-read-only nil))
1981 (when (gnus-article-narrow-to-signature)
1982 (gnus-article-hide-text-type
1983 (point-min) (point-max) 'signature)))))))
1985 (defun article-strip-headers-in-body ()
1986 "Strip offensive headers from bodies."
1990 (let ((case-fold-search t))
1991 (when (looking-at "x-no-archive:")
1992 (gnus-delete-line)))))
1994 (defun article-strip-leading-blank-lines ()
1995 "Remove all blank lines from the beginning of the article."
1998 (let ((inhibit-point-motion-hooks t)
2000 (when (article-goto-body)
2001 (while (and (not (eobp))
2002 (looking-at "[ \t]*$"))
2003 (gnus-delete-line))))))
2005 (defun article-narrow-to-head ()
2006 "Narrow the buffer to the head of the message.
2007 Point is left at the beginning of the narrowed-to region."
2009 (goto-char (point-min))
2010 (if (search-forward "\n\n" nil 1)
2013 (goto-char (point-min)))
2015 (defun article-goto-body ()
2016 "Place point at the start of the body."
2017 (goto-char (point-min))
2019 ;; This variable is only bound when dealing with separate
2021 (article-goto-body-goes-to-point-min-p
2023 ((search-forward "\n\n" nil t)
2026 (goto-char (point-max))
2029 (defun article-strip-multiple-blank-lines ()
2030 "Replace consecutive blank lines with one empty line."
2033 (let ((inhibit-point-motion-hooks t)
2035 ;; First make all blank lines empty.
2037 (while (re-search-forward "^[ \t]+$" nil t)
2038 (unless (gnus-annotation-in-region-p
2039 (match-beginning 0) (match-end 0))
2040 (replace-match "" nil t)))
2041 ;; Then replace multiple empty lines with a single empty line.
2043 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2044 (unless (gnus-annotation-in-region-p
2045 (match-beginning 0) (match-end 0))
2046 (delete-region (match-beginning 1) (match-end 1)))))))
2048 (defun article-strip-leading-space ()
2049 "Remove all white space from the beginning of the lines in the article."
2052 (let ((inhibit-point-motion-hooks t)
2055 (while (re-search-forward "^[ \t]+" nil t)
2056 (replace-match "" t t)))))
2058 (defun article-strip-trailing-space ()
2059 "Remove all white space from the end of the lines in the article."
2062 (let ((inhibit-point-motion-hooks t)
2065 (while (re-search-forward "[ \t]+$" nil t)
2066 (replace-match "" t t)))))
2068 (defun article-strip-blank-lines ()
2069 "Strip leading, trailing and multiple blank lines."
2071 (article-strip-leading-blank-lines)
2072 (article-remove-trailing-blank-lines)
2073 (article-strip-multiple-blank-lines))
2075 (defun article-strip-all-blank-lines ()
2076 "Strip all blank lines."
2079 (let ((inhibit-point-motion-hooks t)
2082 (while (re-search-forward "^[ \t]*\n" nil t)
2083 (replace-match "" t t)))))
2085 (defun gnus-article-narrow-to-signature ()
2086 "Narrow to the signature; return t if a signature is found, else nil."
2087 (let ((inhibit-point-motion-hooks t))
2088 (when (gnus-article-search-signature)
2090 ;; Check whether we have some limits to what we consider
2091 ;; to be a signature.
2092 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2093 (list gnus-signature-limit)))
2095 (while (setq limit (pop limits))
2096 (if (or (and (integerp limit)
2097 (< (- (point-max) (point)) limit))
2099 (< (count-lines (point) (point-max)) limit))
2100 (and (gnus-functionp limit)
2102 (and (stringp limit)
2103 (not (re-search-forward limit nil t))))
2104 () ; This limit did not succeed.
2108 (narrow-to-region (point) (point-max))
2111 (defun gnus-article-search-signature ()
2112 "Search the current buffer for the signature separator.
2113 Put point at the beginning of the signature separator."
2114 (let ((cur (point)))
2115 (goto-char (point-max))
2116 (if (if (stringp gnus-signature-separator)
2117 (re-search-backward gnus-signature-separator nil t)
2118 (let ((seps gnus-signature-separator))
2120 (not (re-search-backward (car seps) nil t)))
2127 (defun gnus-article-hidden-arg ()
2128 "Return the current prefix arg as a number, or 0 if no prefix."
2129 (list (if current-prefix-arg
2130 (prefix-numeric-value current-prefix-arg)
2133 (defun gnus-article-check-hidden-text (type arg)
2134 "Return nil if hiding is necessary.
2135 Arg can be nil or a number. Nil and positive means hide, negative
2136 means show, 0 means toggle."
2139 (let ((hide (gnus-article-hidden-text-p type)))
2145 (gnus-article-show-hidden-text type)
2148 (if (eq hide 'hidden)
2150 (gnus-article-show-hidden-text type)
2154 (defun gnus-article-hidden-text-p (type)
2155 "Say whether the current buffer contains hidden text of type TYPE."
2156 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2158 (not (get-text-property pos 'invisible))
2159 (not (get-text-property pos 'dummy-invisible)))
2161 (text-property-any (1+ pos) (point-max) 'article-type type)))
2166 (defun gnus-article-show-hidden-text (type &optional dummy)
2167 "Show all hidden text of type TYPE.
2168 Originally it is hide instead of DUMMY."
2169 (let ((buffer-read-only nil)
2170 (inhibit-point-motion-hooks t))
2171 (gnus-remove-text-properties-when
2173 (point-min) (point-max)
2174 (cons 'article-type (cons type
2175 gnus-hidden-properties)))))
2177 (defconst article-time-units
2178 `((year . ,(* 365.25 24 60 60))
2179 (week . ,(* 7 24 60 60))
2180 (day . ,(* 24 60 60))
2184 "Mapping from time units to seconds.")
2186 (defun article-date-ut (&optional type highlight header)
2187 "Convert DATE date to universal time in the current article.
2188 If TYPE is `local', convert to local time; if it is `lapsed', output
2189 how much time has lapsed since DATE. For `lapsed', the value of
2190 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2191 should replace the \"Date:\" one, or should be added below it."
2192 (interactive (list 'ut t))
2193 (let* ((header (or header
2194 (message-fetch-field "date")
2196 (tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2199 ((not gnus-article-date-lapsed-new-header)
2205 (date (if (vectorp header) (mail-header-date header)
2207 (inhibit-point-motion-hooks t)
2212 (article-narrow-to-head)
2213 (when (re-search-forward tdate-regexp nil t)
2214 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2215 date (or (get-text-property (gnus-point-at-bol)
2218 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
2220 (when (and date (not (string= date "")))
2221 (goto-char (point-min))
2222 (let ((buffer-read-only nil))
2223 ;; Delete any old Date headers.
2224 (while (re-search-forward date-regexp nil t)
2226 (delete-region (progn (beginning-of-line) (point))
2227 (progn (forward-line 1) (point)))
2228 (delete-region (progn (beginning-of-line) (point))
2229 (progn (end-of-line) (point)))
2230 (setq pos (point))))
2231 (when (and (not pos) (re-search-forward tdate-regexp nil t))
2233 (if pos (goto-char pos))
2234 (insert (article-make-date-line date (or type 'ut)))
2240 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2241 (put-text-property (match-beginning 1) (1+ (match-end 1))
2242 'original-date date)
2243 (put-text-property (match-beginning 1) (1+ (match-end 1))
2245 (put-text-property (match-beginning 2) (match-end 2)
2248 (defun article-make-date-line (date type)
2249 "Return a DATE line of TYPE."
2250 (unless (memq type '(local ut original user iso8601 lapsed english))
2251 (error "Unknown conversion type: %s" type))
2253 (let ((time (date-to-time date)))
2255 ;; Convert to the local timezone.
2257 (let ((tz (car (current-time-zone time))))
2258 (format "Date: %s %s%02d%02d" (current-time-string time)
2259 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2260 (/ (% (abs tz) 3600) 60))))
2261 ;; Convert to Universal Time.
2264 (current-time-string
2265 (let* ((e (parse-time-string date))
2266 (tm (apply 'encode-time e))
2268 (ls (- (cadr tm) (car (current-time-zone time)))))
2269 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2270 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2273 ;; Get the original date from the article.
2274 ((eq type 'original)
2275 (concat "Date: " (if (string-match "\n+$" date)
2276 (substring date 0 (match-beginning 0))
2278 ;; Let the user define the format.
2280 (if (gnus-functionp gnus-article-time-format)
2281 (funcall gnus-article-time-format time)
2284 (format-time-string gnus-article-time-format time))))
2287 (let ((tz (car (current-time-zone time))))
2290 (format-time-string "%Y%m%dT%H%M%S" time)
2291 (format "%s%02d%02d"
2292 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2293 (/ (% (abs tz) 3600) 60)))))
2294 ;; Do an X-Sent lapsed format.
2296 ;; If the date is seriously mangled, the timezone functions are
2297 ;; liable to bug out, so we ignore all errors.
2298 (let* ((now (current-time))
2299 (real-time (subtract-time now time))
2300 (real-sec (and real-time
2301 (+ (* (float (car real-time)) 65536)
2303 (sec (and real-time (abs real-sec)))
2313 ;; This is a bit convoluted, but basically we go
2314 ;; through the time units for years, weeks, etc,
2315 ;; and divide things to see whether that results
2316 ;; in positive answers.
2319 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2320 ;; The (remaining) seconds are too few to
2321 ;; be divided into this time unit.
2323 ;; It's big enough, so we output it.
2324 (setq sec (- sec (* num (cdr unit))))
2326 (concat (if prev ", " "") (int-to-string
2328 " " (symbol-name (car unit))
2329 (if (> num 1) "s" ""))
2331 article-time-units "")
2332 ;; If dates are odd, then it might appear like the
2333 ;; article was sent in the future.
2336 " in the future"))))))
2337 ;; Display the date in proper English
2339 (let ((dtime (decode-time time)))
2342 (number-to-string (nth 3 dtime))
2343 (let ((digit (% (nth 3 dtime) 10)))
2345 ((memq (nth 3 dtime) '(11 12 13)) "th")
2351 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2353 (number-to-string (nth 5 dtime))
2355 (format "%02d" (nth 2 dtime))
2357 (format "%02d" (nth 1 dtime)))))))
2359 (format "Date: %s (from Oort)" date))))
2361 (defun article-date-local (&optional highlight)
2362 "Convert the current article date to the local timezone."
2363 (interactive (list t))
2364 (article-date-ut 'local highlight))
2366 (defun article-date-english (&optional highlight)
2367 "Convert the current article date to something that is proper English."
2368 (interactive (list t))
2369 (article-date-ut 'english highlight))
2371 (defun article-date-original (&optional highlight)
2372 "Convert the current article date to what it was originally.
2373 This is only useful if you have used some other date conversion
2374 function and want to see what the date was before converting."
2375 (interactive (list t))
2376 (article-date-ut 'original highlight))
2378 (defun article-date-lapsed (&optional highlight)
2379 "Convert the current article date to time lapsed since it was sent."
2380 (interactive (list t))
2381 (article-date-ut 'lapsed highlight))
2383 (defun article-update-date-lapsed ()
2384 "Function to be run from a timer to update the lapsed time line."
2385 (let (deactivate-mark)
2390 (set-buffer (window-buffer w))
2391 (when (eq major-mode 'gnus-article-mode)
2392 (goto-char (point-min))
2393 (when (re-search-forward "^X-Sent:" nil t)
2394 (article-date-lapsed t))))
2397 (defun gnus-start-date-timer (&optional n)
2398 "Start a timer to update the X-Sent header in the article buffers.
2399 The numerical prefix says how frequently (in seconds) the function
2404 (gnus-stop-date-timer)
2405 (setq article-lapsed-timer
2406 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2408 (defun gnus-stop-date-timer ()
2409 "Stop the X-Sent timer."
2411 (when article-lapsed-timer
2412 (nnheader-cancel-timer article-lapsed-timer)
2413 (setq article-lapsed-timer nil)))
2415 (defun article-date-user (&optional highlight)
2416 "Convert the current article date to the user-defined format.
2417 This format is defined by the `gnus-article-time-format' variable."
2418 (interactive (list t))
2419 (article-date-ut 'user highlight))
2421 (defun article-date-iso8601 (&optional highlight)
2422 "Convert the current article date to ISO8601."
2423 (interactive (list t))
2424 (article-date-ut 'iso8601 highlight))
2426 (defun article-show-all ()
2427 "Show all hidden text in the article buffer."
2430 (let ((buffer-read-only nil))
2431 (gnus-article-unhide-text (point-min) (point-max)))))
2433 (defun article-remove-leading-whitespace ()
2434 "Remove excessive whitespace from all headers."
2438 (let ((buffer-read-only nil))
2439 (article-narrow-to-head)
2440 (goto-char (point-min))
2441 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
2442 (delete-region (match-beginning 1) (match-end 1)))))))
2444 (defun article-emphasize (&optional arg)
2445 "Emphasize text according to `gnus-emphasis-alist'."
2446 (interactive (gnus-article-hidden-arg))
2447 (unless (gnus-article-check-hidden-text 'emphasis arg)
2451 (with-current-buffer gnus-summary-buffer
2452 gnus-article-emphasis-alist)
2454 gnus-emphasis-alist))
2455 (buffer-read-only nil)
2456 (props (append '(article-type emphasis)
2457 gnus-hidden-properties))
2458 regexp elem beg invisible visible face)
2461 (while (setq elem (pop alist))
2463 (setq regexp (car elem)
2464 invisible (nth 1 elem)
2465 visible (nth 2 elem)
2467 (while (re-search-forward regexp nil t)
2468 (when (and (match-beginning visible) (match-beginning invisible))
2469 (push 'emphasis gnus-article-wash-types)
2470 (gnus-article-hide-text
2471 (match-beginning invisible) (match-end invisible) props)
2472 (gnus-article-unhide-text-type
2473 (match-beginning visible) (match-end visible) 'emphasis)
2474 (gnus-put-text-property-excluding-newlines
2475 (match-beginning visible) (match-end visible) 'face face)
2476 (goto-char (match-end invisible)))))))))
2478 (defun gnus-article-setup-highlight-words (&optional highlight-words)
2479 "Setup newsgroup emphasis alist."
2480 (unless gnus-article-emphasis-alist
2481 (let ((name (and gnus-newsgroup-name
2482 (gnus-group-real-name gnus-newsgroup-name))))
2483 (make-local-variable 'gnus-article-emphasis-alist)
2484 (setq gnus-article-emphasis-alist
2486 (let ((alist gnus-group-highlight-words-alist) elem highlight)
2487 (while (setq elem (pop alist))
2488 (when (and name (string-match (car elem) name))
2490 highlight (copy-sequence (cdr elem)))))
2492 (copy-sequence highlight-words)
2493 (if gnus-newsgroup-name
2494 (copy-sequence (gnus-group-find-parameter
2495 gnus-newsgroup-name 'highlight-words t)))
2496 gnus-emphasis-alist)))))
2499 (defvar gnus-summary-article-menu)
2500 (defvar gnus-summary-post-menu))
2502 ;;; Saving functions.
2504 (defun gnus-article-save (save-buffer file &optional num)
2505 "Save the currently selected article."
2506 (unless gnus-save-all-headers
2507 ;; Remove headers according to `gnus-saved-headers'.
2508 (let ((gnus-visible-headers
2509 (or gnus-saved-headers gnus-visible-headers))
2510 (gnus-article-buffer save-buffer))
2512 (set-buffer save-buffer)
2513 (article-hide-headers 1 t))))
2514 (save-window-excursion
2515 (if (not gnus-default-article-saver)
2516 (error "No default saver is defined")
2517 ;; !!! Magic! The saving functions all save
2518 ;; `gnus-save-article-buffer' (or so they think), but we
2519 ;; bind that variable to our save-buffer.
2520 (set-buffer gnus-article-buffer)
2521 (let* ((gnus-save-article-buffer save-buffer)
2524 ((not gnus-prompt-before-saving) 'default)
2525 ((eq gnus-prompt-before-saving 'always) nil)
2527 (gnus-number-of-articles-to-be-saved
2528 (when (eq gnus-prompt-before-saving t)
2530 (set-buffer gnus-article-current-summary)
2531 (funcall gnus-default-article-saver filename)))))
2533 (defun gnus-read-save-file-name (prompt &optional filename
2534 function group headers variable)
2536 (funcall function group headers (symbol-value variable)))
2541 ((eq filename 'default)
2547 (let* ((split-name (gnus-get-split-value gnus-split-methods))
2550 (if (and gnus-number-of-articles-to-be-saved
2551 (> gnus-number-of-articles-to-be-saved 1))
2552 (format "these %d articles"
2553 gnus-number-of-articles-to-be-saved)
2556 ;; Let the split methods have their say.
2558 ;; No split name was found.
2561 (concat prompt " (default "
2562 (file-name-nondirectory default-name) ") ")
2563 (file-name-directory default-name)
2565 ;; A single group name is returned.
2566 ((stringp split-name)
2568 (funcall function split-name headers
2569 (symbol-value variable)))
2571 (concat prompt " (default "
2572 (file-name-nondirectory default-name) ") ")
2573 (file-name-directory default-name)
2575 ;; A single split name was found
2576 ((= 1 (length split-name))
2577 (let* ((name (expand-file-name
2579 gnus-article-save-directory))
2580 (dir (cond ((file-directory-p name)
2581 (file-name-as-directory name))
2582 ((file-exists-p name) name)
2583 (t gnus-article-save-directory))))
2585 (concat prompt " (default " name ") ")
2587 ;; A list of splits was found.
2589 (setq split-name (nreverse split-name))
2591 (let ((file-name-history
2592 (nconc split-name file-name-history)))
2596 (concat prompt " (`M-p' for defaults) ")
2597 gnus-article-save-directory
2599 gnus-article-save-directory)))
2600 (car (push result file-name-history)))))))
2601 ;; Create the directory.
2602 (gnus-make-directory (file-name-directory file))
2603 ;; If we have read a directory, we append the default file name.
2604 (when (file-directory-p file)
2605 (setq file (expand-file-name (file-name-nondirectory
2607 (file-name-as-directory file))))
2608 ;; Possibly translate some characters.
2609 (nnheader-translate-file-chars file))))))
2610 (gnus-make-directory (file-name-directory result))
2611 (set variable result)))
2613 (defun gnus-article-archive-name (group)
2614 "Return the first instance of an \"Archive-name\" in the current buffer."
2615 (let ((case-fold-search t))
2616 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
2617 (nnheader-concat gnus-article-save-directory
2618 (match-string 1)))))
2620 (defun gnus-article-nndoc-name (group)
2621 "If GROUP is an nndoc group, return the name of the parent group."
2622 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
2623 (gnus-group-get-parameter group 'save-article-group)))
2625 (defun gnus-summary-save-in-rmail (&optional filename)
2626 "Append this article to Rmail file.
2627 Optional argument FILENAME specifies file name.
2628 Directory to save to is default to `gnus-article-save-directory'."
2629 (setq filename (gnus-read-save-file-name
2630 "Save %s in rmail file:" filename
2631 gnus-rmail-save-name gnus-newsgroup-name
2632 gnus-current-headers 'gnus-newsgroup-last-rmail))
2633 (gnus-eval-in-buffer-window gnus-save-article-buffer
2637 (gnus-output-to-rmail filename))))
2640 (defun gnus-summary-save-in-mail (&optional filename)
2641 "Append this article to Unix mail file.
2642 Optional argument FILENAME specifies file name.
2643 Directory to save to is default to `gnus-article-save-directory'."
2644 (setq filename (gnus-read-save-file-name
2645 "Save %s in Unix mail file:" filename
2646 gnus-mail-save-name gnus-newsgroup-name
2647 gnus-current-headers 'gnus-newsgroup-last-mail))
2648 (gnus-eval-in-buffer-window gnus-save-article-buffer
2652 (if (and (file-readable-p filename)
2653 (mail-file-babyl-p filename))
2654 (rmail-output-to-rmail-file filename t)
2655 (gnus-output-to-mail filename)))))
2658 (defun gnus-summary-save-in-file (&optional filename overwrite)
2659 "Append this article to file.
2660 Optional argument FILENAME specifies file name.
2661 Directory to save to is default to `gnus-article-save-directory'."
2662 (setq filename (gnus-read-save-file-name
2663 "Save %s in file:" filename
2664 gnus-file-save-name gnus-newsgroup-name
2665 gnus-current-headers 'gnus-newsgroup-last-file))
2666 (gnus-eval-in-buffer-window gnus-save-article-buffer
2670 (when (and overwrite
2671 (file-exists-p filename))
2672 (delete-file filename))
2673 (gnus-output-to-file filename))))
2676 (defun gnus-summary-write-to-file (&optional filename)
2677 "Write this article to a file.
2678 Optional argument FILENAME specifies file name.
2679 The directory to save in defaults to `gnus-article-save-directory'."
2680 (gnus-summary-save-in-file nil t))
2682 (defun gnus-summary-save-body-in-file (&optional filename)
2683 "Append this article body to a file.
2684 Optional argument FILENAME specifies file name.
2685 The directory to save in defaults to `gnus-article-save-directory'."
2686 (setq filename (gnus-read-save-file-name
2687 "Save %s body in file:" filename
2688 gnus-file-save-name gnus-newsgroup-name
2689 gnus-current-headers 'gnus-newsgroup-last-file))
2690 (gnus-eval-in-buffer-window gnus-save-article-buffer
2694 (when (article-goto-body)
2695 (narrow-to-region (point) (point-max)))
2696 (gnus-output-to-file filename))))
2699 (defun gnus-summary-save-in-pipe (&optional command)
2700 "Pipe this article to subprocess."
2702 (cond ((and (eq command 'default)
2703 gnus-last-shell-command)
2704 gnus-last-shell-command)
2709 "Shell command on %s: "
2710 (if (and gnus-number-of-articles-to-be-saved
2711 (> gnus-number-of-articles-to-be-saved 1))
2712 (format "these %d articles"
2713 gnus-number-of-articles-to-be-saved)
2715 gnus-last-shell-command))))
2716 (when (string-equal command "")
2717 (if gnus-last-shell-command
2718 (setq command gnus-last-shell-command)
2719 (error "A command is required.")))
2720 (gnus-eval-in-buffer-window gnus-article-buffer
2723 (shell-command-on-region (point-min) (point-max) command nil)))
2724 (setq gnus-last-shell-command command))
2726 ;;; Article file names when saving.
2728 (defun gnus-capitalize-newsgroup (newsgroup)
2729 "Capitalize NEWSGROUP name."
2730 (when (not (zerop (length newsgroup)))
2731 (concat (char-to-string (upcase (aref newsgroup 0)))
2732 (substring newsgroup 1))))
2734 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2735 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2736 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
2737 Otherwise, it is like ~/News/news/group/num."
2740 (concat (if (gnus-use-long-file-name 'not-save)
2741 (gnus-capitalize-newsgroup newsgroup)
2742 (gnus-newsgroup-directory-form newsgroup))
2743 "/" (int-to-string (mail-header-number headers)))
2744 gnus-article-save-directory)))
2746 (string-equal (file-name-directory default)
2747 (file-name-directory last-file))
2748 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2750 (or last-file default))))
2752 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2753 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2754 If variable `gnus-use-long-file-name' is non-nil, it is
2755 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2758 (concat (if (gnus-use-long-file-name 'not-save)
2760 (gnus-newsgroup-directory-form newsgroup))
2761 "/" (int-to-string (mail-header-number headers)))
2762 gnus-article-save-directory)))
2764 (string-equal (file-name-directory default)
2765 (file-name-directory last-file))
2766 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2768 (or last-file default))))
2770 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2771 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2772 If variable `gnus-use-long-file-name' is non-nil, it is
2773 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2776 (if (gnus-use-long-file-name 'not-save)
2779 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
2781 gnus-article-save-directory)))
2783 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
2784 "Generate file name from sender."
2785 (let ((from (mail-header-from headers)))
2787 (if (and from (string-match "\\([^ <]+\\)@" from))
2788 (match-string 1 from)
2790 gnus-article-save-directory)))
2792 (defun article-verify-x-pgp-sig ()
2795 (if (gnus-buffer-live-p gnus-original-article-buffer)
2796 (let ((sig (with-current-buffer gnus-original-article-buffer
2797 (gnus-fetch-field "X-PGP-Sig")))
2801 (mml2015-clear-verify-function))
2803 (insert-buffer gnus-original-article-buffer)
2804 (setq items (split-string sig))
2805 (message-narrow-to-head)
2806 (let ((inhibit-point-motion-hooks t)
2807 (case-fold-search t))
2808 ;; Don't verify multiple headers.
2809 (setq headers (mapconcat (lambda (header)
2811 (mail-fetch-field header) "\n"))
2812 (split-string (nth 1 items) ",") "")))
2813 (delete-region (point-min) (point-max))
2814 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
2815 (insert "X-Signed-Headers: " (nth 1 items) "\n")
2820 (if (looking-at "^-")
2823 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
2824 (insert "Version: " (car items) "\n\n")
2825 (insert (mapconcat 'identity (cddr items) "\n"))
2826 (insert "\n-----END PGP SIGNATURE-----\n")
2827 (let ((mm-security-handle (list (format "multipart/signed"))))
2828 (mml2015-clean-buffer)
2829 (let ((coding-system-for-write (or gnus-newsgroup-charset
2831 (funcall (mml2015-clear-verify-function)))
2833 (or (mm-handle-multipart-ctl-parameter
2834 mm-security-handle 'gnus-details)
2835 (mm-handle-multipart-ctl-parameter
2836 mm-security-handle 'gnus-info)))))
2838 (let (buffer-read-only bface eface)
2840 (message-narrow-to-head)
2841 (goto-char (point-max))
2843 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2844 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
2845 (message-remove-header "X-Gnus-PGP-Verify")
2846 (if (re-search-forward "^X-PGP-Sig:" nil t)
2848 (goto-char (point-max)))
2849 (narrow-to-region (point) (point))
2850 (insert "X-Gnus-PGP-Verify: " info "\n")
2851 (goto-char (point-min))
2854 (if (not (looking-at "^[ \t]"))
2858 (goto-char (point-min))
2859 (when (looking-at "\\([^:]+\\): *")
2860 (put-text-property (match-beginning 1) (1+ (match-end 1))
2862 (put-text-property (match-end 0) (point-max)
2863 'face eface)))))))))
2870 (setq afunc (car func)
2873 gfunc (intern (format "gnus-%s" func))))
2876 `(lambda (&optional interactive &rest args)
2877 ,(documentation afunc t)
2878 (interactive (list t))
2880 (set-buffer gnus-article-buffer)
2882 (call-interactively ',afunc)
2883 (apply ',afunc args))))))))
2884 '(article-hide-headers
2885 article-verify-x-pgp-sig
2886 article-hide-boring-headers
2887 article-treat-overstrike
2888 article-fill-long-lines
2889 article-capitalize-sentences
2891 article-remove-leading-whitespace
2892 article-display-x-face
2893 article-de-quoted-unreadable
2894 article-de-base64-unreadable
2897 article-hide-list-identifiers
2899 article-strip-banner
2902 article-hide-signature
2903 article-strip-headers-in-body
2904 article-remove-trailing-blank-lines
2905 article-strip-leading-blank-lines
2906 article-strip-multiple-blank-lines
2907 article-strip-leading-space
2908 article-strip-trailing-space
2909 article-strip-blank-lines
2910 article-strip-all-blank-lines
2911 article-replace-with-quoted-text
2913 article-date-english
2914 article-date-iso8601
2915 article-date-original
2917 article-decode-mime-words
2918 article-decode-charset
2919 article-decode-encoded-words
2923 article-treat-dumbquotes
2924 article-normalize-headers
2925 (article-show-all . gnus-article-show-all-headers))))
2928 ;;; Gnus article mode
2931 (put 'gnus-article-mode 'mode-class 'special)
2933 (set-keymap-parent gnus-article-mode-map widget-keymap)
2935 (gnus-define-keys gnus-article-mode-map
2936 " " gnus-article-goto-next-page
2937 "\177" gnus-article-goto-prev-page
2938 [delete] gnus-article-goto-prev-page
2939 [backspace] gnus-article-goto-prev-page
2940 "\C-c^" gnus-article-refer-article
2941 "h" gnus-article-show-summary
2942 "s" gnus-article-show-summary
2943 "\C-c\C-m" gnus-article-mail
2944 "?" gnus-article-describe-briefly
2945 "e" gnus-summary-edit-article
2946 "<" beginning-of-buffer
2948 "\C-c\C-i" gnus-info-find-node
2950 "\C-hk" gnus-article-describe-key
2951 "\C-hc" gnus-article-describe-key-briefly
2953 "\C-d" gnus-article-read-summary-keys
2954 "\M-*" gnus-article-read-summary-keys
2955 "\M-#" gnus-article-read-summary-keys
2956 "\M-^" gnus-article-read-summary-keys
2957 "\M-g" gnus-article-read-summary-keys)
2959 (substitute-key-definition
2960 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
2962 (defun gnus-article-make-menu-bar ()
2963 (unless (boundp 'gnus-article-commands-menu)
2964 (gnus-summary-make-menu-bar))
2965 (gnus-turn-off-edit-menu 'article)
2966 (unless (boundp 'gnus-article-article-menu)
2968 gnus-article-article-menu gnus-article-mode-map ""
2970 ["Scroll forwards" gnus-article-goto-next-page t]
2971 ["Scroll backwards" gnus-article-goto-prev-page t]
2972 ["Show summary" gnus-article-show-summary t]
2973 ["Fetch Message-ID at point" gnus-article-refer-article t]
2974 ["Mail to address at point" gnus-article-mail t]
2975 ["Send a bug report" gnus-bug t]))
2978 gnus-article-treatment-menu gnus-article-mode-map ""
2979 ;; Fixme: this should use :active (and maybe :visible).
2981 ["Hide headers" gnus-article-hide-headers t]
2982 ["Hide signature" gnus-article-hide-signature t]
2983 ["Hide citation" gnus-article-hide-citation t]
2984 ["Treat overstrike" gnus-article-treat-overstrike t]
2985 ["Remove carriage return" gnus-article-remove-cr t]
2986 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
2987 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
2988 ["Remove base64" gnus-article-de-base64-unreadable t]
2989 ["Treat html" gnus-article-wash-html t]
2990 ["Decode HZ" gnus-article-decode-HZ t]))
2992 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
2994 ;; Note "Post" menu is defined in gnus-sum.el for consistency
2996 (gnus-run-hooks 'gnus-article-menu-hook)))
2998 ;; Fixme: do something for the Emacs tool bar in Article mode a la
3001 (defun gnus-article-mode ()
3002 "Major mode for displaying an article.
3004 All normal editing commands are switched off.
3006 The following commands are available in addition to all summary mode
3008 \\<gnus-article-mode-map>
3009 \\[gnus-article-next-page]\t Scroll the article one page forwards
3010 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3011 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3012 \\[gnus-article-show-summary]\t Display the summary buffer
3013 \\[gnus-article-mail]\t Send a reply to the address near point
3014 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3015 \\[gnus-info-find-node]\t Go to the Gnus info node"
3017 (gnus-simplify-mode-line)
3018 (setq mode-name "Article")
3019 (setq major-mode 'gnus-article-mode)
3020 (make-local-variable 'minor-mode-alist)
3021 (use-local-map gnus-article-mode-map)
3022 (when (gnus-visual-p 'article-menu 'menu)
3023 (gnus-article-make-menu-bar))
3024 (gnus-update-format-specifications nil 'article-mode)
3025 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3026 (make-local-variable 'gnus-page-broken)
3027 (make-local-variable 'gnus-button-marker-list)
3028 (make-local-variable 'gnus-article-current-summary)
3029 (make-local-variable 'gnus-article-mime-handles)
3030 (make-local-variable 'gnus-article-decoded-p)
3031 (make-local-variable 'gnus-article-mime-handle-alist)
3032 (make-local-variable 'gnus-article-wash-types)
3033 (make-local-variable 'gnus-article-charset)
3034 (make-local-variable 'gnus-article-ignored-charsets)
3035 (gnus-set-default-directory)
3036 (buffer-disable-undo)
3037 (setq buffer-read-only t)
3038 (set-syntax-table gnus-article-mode-syntax-table)
3039 (mm-enable-multibyte)
3040 (gnus-run-hooks 'gnus-article-mode-hook))
3042 (defun gnus-article-setup-buffer ()
3043 "Initialize the article buffer."
3044 (let* ((name (if gnus-single-article-buffer "*Article*"
3045 (concat "*Article " gnus-newsgroup-name "*")))
3047 (progn (string-match "\\*Article" name)
3048 (concat " *Original Article"
3049 (substring name (match-end 0))))))
3050 (setq gnus-article-buffer name)
3051 (setq gnus-original-article-buffer original)
3052 (setq gnus-article-mime-handle-alist nil)
3053 ;; This might be a variable local to the summary buffer.
3054 (unless gnus-single-article-buffer
3056 (set-buffer gnus-summary-buffer)
3057 (setq gnus-article-buffer name)
3058 (setq gnus-original-article-buffer original)
3059 (gnus-set-global-variables)))
3060 (gnus-article-setup-highlight-words)
3061 ;; Init original article buffer.
3063 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3064 (mm-enable-multibyte)
3065 (setq major-mode 'gnus-original-article-mode)
3066 (make-local-variable 'gnus-original-article))
3067 (if (get-buffer name)
3070 (when gnus-article-mime-handles
3071 (mm-destroy-parts gnus-article-mime-handles)
3072 (setq gnus-article-mime-handles nil))
3073 ;; Set it to nil in article-buffer!
3074 (setq gnus-article-mime-handle-alist nil)
3075 (buffer-disable-undo)
3076 (setq buffer-read-only t)
3077 (unless (eq major-mode 'gnus-article-mode)
3078 (gnus-article-mode))
3081 (set-buffer (gnus-get-buffer-create name))
3083 (make-local-variable 'gnus-summary-buffer)
3084 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3085 (current-buffer)))))
3087 ;; Set article window start at LINE, where LINE is the number of lines
3088 ;; from the head of the article.
3089 (defun gnus-article-set-window-start (&optional line)
3091 (get-buffer-window gnus-article-buffer t)
3093 (set-buffer gnus-article-buffer)
3094 (goto-char (point-min))
3097 (gnus-message 6 "Moved to bookmark")
3098 (search-forward "\n\n" nil t)
3102 (defun gnus-article-prepare (article &optional all-headers header)
3103 "Prepare ARTICLE in article mode buffer.
3104 ARTICLE should either be an article number or a Message-ID.
3105 If ARTICLE is an id, HEADER should be the article headers.
3106 If ALL-HEADERS is non-nil, no headers are hidden."
3108 ;; Make sure we start in a summary buffer.
3109 (unless (eq major-mode 'gnus-summary-mode)
3110 (set-buffer gnus-summary-buffer))
3111 (setq gnus-summary-buffer (current-buffer))
3112 (let* ((gnus-article (if header (mail-header-number header) article))
3113 (summary-buffer (current-buffer))
3114 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3115 (group gnus-newsgroup-name)
3118 (gnus-article-setup-buffer)
3119 (set-buffer gnus-article-buffer)
3120 ;; Deactivate active regions.
3121 (when (and (boundp 'transient-mark-mode)
3122 transient-mark-mode)
3123 (setq mark-active nil))
3124 (if (not (setq result (let ((buffer-read-only nil))
3125 (gnus-request-article-this-buffer
3127 ;; There is no such article.
3129 (when (and (numberp article)
3130 (not (memq article gnus-newsgroup-sparse)))
3131 (setq gnus-article-current
3132 (cons gnus-newsgroup-name article))
3133 (set-buffer gnus-summary-buffer)
3134 (setq gnus-current-article article)
3135 (if (eq (gnus-article-mark article) gnus-undownloaded-mark)
3137 (gnus-summary-set-agent-mark article)
3138 (message "Message marked for downloading"))
3139 (gnus-summary-mark-article article gnus-canceled-mark)
3140 (unless (memq article gnus-newsgroup-sparse)
3141 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3142 (if (or (eq result 'pseudo)
3143 (eq result 'nneething))
3146 (set-buffer summary-buffer)
3147 (push article gnus-newsgroup-history)
3148 (setq gnus-last-article gnus-current-article
3149 gnus-current-article 0
3150 gnus-current-headers nil
3151 gnus-article-current nil)
3152 (if (eq result 'nneething)
3153 (gnus-configure-windows 'summary)
3154 (gnus-configure-windows 'article))
3155 (gnus-set-global-variables))
3156 (let ((gnus-article-mime-handle-alist-1
3157 gnus-article-mime-handle-alist))
3158 (gnus-set-mode-line 'article)))
3159 ;; The result from the `request' was an actual article -
3160 ;; or at least some text that is now displayed in the
3162 (when (and (numberp article)
3163 (not (eq article gnus-current-article)))
3164 ;; Seems like a new article has been selected.
3165 ;; `gnus-current-article' must be an article number.
3167 (set-buffer summary-buffer)
3168 (push article gnus-newsgroup-history)
3169 (setq gnus-last-article gnus-current-article
3170 gnus-current-article article
3171 gnus-current-headers
3172 (gnus-summary-article-header gnus-current-article)
3173 gnus-article-current
3174 (cons gnus-newsgroup-name gnus-current-article))
3175 (unless (vectorp gnus-current-headers)
3176 (setq gnus-current-headers nil))
3177 (gnus-summary-goto-subject gnus-current-article)
3178 (when (gnus-summary-show-thread)
3179 ;; If the summary buffer really was folded, the
3180 ;; previous goto may not actually have gone to
3181 ;; the right article, but the thread root instead.
3183 (gnus-summary-goto-subject gnus-current-article))
3184 (gnus-run-hooks 'gnus-mark-article-hook)
3185 (gnus-set-mode-line 'summary)
3186 (when (gnus-visual-p 'article-highlight 'highlight)
3187 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3188 ;; Set the global newsgroup variables here.
3189 (gnus-set-global-variables)
3190 (setq gnus-have-all-headers
3191 (or all-headers gnus-show-all-headers))))
3193 (gnus-configure-windows 'article))
3194 (when (or (numberp article)
3196 (gnus-article-prepare-display)
3198 (goto-char (point-min))
3199 (setq gnus-page-broken
3200 (when gnus-break-pages
3201 (gnus-narrow-to-page)
3203 (let ((gnus-article-mime-handle-alist-1
3204 gnus-article-mime-handle-alist))
3205 (gnus-set-mode-line 'article))
3207 (set-window-point (get-buffer-window (current-buffer)) (point))
3208 (gnus-configure-windows 'article)
3212 (defun gnus-article-prepare-display ()
3213 "Make the current buffer look like a nice article."
3214 ;; Hooks for getting information from the article.
3215 ;; This hook must be called before being narrowed.
3216 (let ((gnus-article-buffer (current-buffer))
3218 (unless (eq major-mode 'gnus-article-mode)
3219 (gnus-article-mode))
3220 (setq buffer-read-only nil
3221 gnus-article-wash-types nil)
3222 (gnus-run-hooks 'gnus-tmp-internal-hook)
3223 (when gnus-display-mime-function
3224 (funcall gnus-display-mime-function))
3225 (gnus-run-hooks 'gnus-article-prepare-hook)))
3228 ;;; Gnus MIME viewing functions
3231 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3232 "The following specs can be used:
3234 %T MIME type, along with additional info
3235 %n The `name' parameter
3236 %d The description, if any
3237 %l The length of the encoded part
3238 %p The part identifier number
3239 %e Dots if the part isn't displayed")
3241 (defvar gnus-mime-button-line-format-alist
3242 '((?t gnus-tmp-type ?s)
3243 (?T gnus-tmp-type-long ?s)
3244 (?n gnus-tmp-name ?s)
3245 (?d gnus-tmp-description ?s)
3247 (?l gnus-tmp-length ?d)
3248 (?e gnus-tmp-dots ?s)))
3250 (defvar gnus-mime-button-commands
3251 '((gnus-article-press-button "\r" "Toggle Display")
3252 (gnus-mime-view-part "v" "View Interactively...")
3253 (gnus-mime-view-part-as-type "t" "View As Type...")
3254 (gnus-mime-view-part-as-charset "C" "View As charset...")
3255 (gnus-mime-save-part "o" "Save...")
3256 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
3257 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
3258 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
3259 (gnus-mime-internalize-part "E" "View Internally")
3260 (gnus-mime-externalize-part "e" "View Externally")
3261 (gnus-mime-pipe-part "|" "Pipe To Command...")
3262 (gnus-mime-action-on-part "." "Take action on the part")))
3264 (defun gnus-article-mime-part-status ()
3265 (if gnus-article-mime-handle-alist-1
3266 (if (eq 1 (length gnus-article-mime-handle-alist-1))
3268 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
3271 (defvar gnus-mime-button-map
3272 (let ((map (make-sparse-keymap)))
3273 (unless (>= (string-to-number emacs-version) 21)
3274 ;; XEmacs doesn't care.
3275 (set-keymap-parent map gnus-article-mode-map))
3276 (define-key map gnus-mouse-2 'gnus-article-push-button)
3277 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
3278 (dolist (c gnus-mime-button-commands)
3279 (define-key map (cadr c) (car c)))
3282 (defun gnus-mime-button-menu (event)
3283 "Construct a context-sensitive menu of MIME commands."
3285 (save-window-excursion
3286 (let ((pos (event-start event)))
3287 (select-window (posn-window pos))
3288 (goto-char (posn-point pos))
3289 (gnus-article-check-buffer)
3290 (let ((response (x-popup-menu
3292 ("" ,@(mapcar (lambda (c)
3293 (cons (caddr c) (car c)))
3294 gnus-mime-button-commands))))))
3296 (call-interactively response))))))
3298 (defun gnus-mime-view-all-parts (&optional handles)
3299 "View all the MIME parts."
3301 (save-current-buffer
3302 (set-buffer gnus-article-buffer)
3303 (let ((handles (or handles gnus-article-mime-handles))
3304 (mail-parse-charset gnus-newsgroup-charset)
3305 (mail-parse-ignored-charsets
3306 (with-current-buffer gnus-summary-buffer
3307 gnus-newsgroup-ignored-charsets)))
3309 (mm-remove-parts handles)
3310 (goto-char (point-min))
3311 (or (search-forward "\n\n") (goto-char (point-max)))
3312 (let (buffer-read-only)
3313 (delete-region (point) (point-max)))
3314 (mm-display-parts handles)))))
3316 (defun gnus-mime-save-part-and-strip ()
3317 "Save the MIME part under point then replace it with an external body."
3319 (gnus-article-check-buffer)
3320 (let* ((data (get-text-property (point) 'gnus-data))
3322 (if (mm-multiple-handles gnus-article-mime-handles)
3323 (error "This function is not implemented."))
3324 (setq file (and data (mm-save-part data)))
3326 (with-current-buffer (mm-handle-buffer data)
3328 (insert "Content-Type: " (mm-handle-media-type data))
3329 (mml-insert-parameter-string (cdr (mm-handle-type data))
3332 (insert "Content-ID: " (message-make-message-id) "\n")
3333 (insert "Content-Transfer-Encoding: binary\n")
3336 (cdr (mm-make-handle nil
3337 `("message/external-body"
3338 (access-type . "LOCAL-FILE")
3340 (set-buffer gnus-summary-buffer)
3341 (gnus-article-edit-article
3344 (let ((mail-parse-charset (or gnus-article-charset
3345 ',gnus-newsgroup-charset))
3346 (mail-parse-ignored-charsets
3347 (or gnus-article-ignored-charsets
3348 ',gnus-newsgroup-ignored-charsets))
3349 (mbl mml-buffer-list))
3350 (setq mml-buffer-list nil)
3351 (insert-buffer gnus-original-article-buffer)
3352 (mime-to-mml gnus-article-mime-handles)
3353 (setq gnus-article-mime-handles nil)
3354 (make-local-hook 'kill-buffer-hook)
3355 (let ((mbl1 mml-buffer-list))
3356 (setq mml-buffer-list mbl)
3357 (set (make-local-variable 'mml-buffer-list) mbl1))
3358 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
3359 `(lambda (no-highlight)
3360 (let ((mail-parse-charset (or gnus-article-charset
3361 ',gnus-newsgroup-charset))
3362 (message-options message-options)
3363 (message-options-set-recipient)
3364 (mail-parse-ignored-charsets
3365 (or gnus-article-ignored-charsets
3366 ',gnus-newsgroup-ignored-charsets)))
3368 (mml-destroy-buffers)
3369 (remove-hook 'kill-buffer-hook
3370 'mml-destroy-buffers t)
3371 (kill-local-variable 'mml-buffer-list))
3372 (gnus-summary-edit-article-done
3373 ,(or (mail-header-references gnus-current-headers) "")
3374 ,(gnus-group-read-only-p)
3375 ,gnus-summary-buffer no-highlight))))))
3377 (defun gnus-mime-save-part ()
3378 "Save the MIME part under point."
3380 (gnus-article-check-buffer)
3381 (let ((data (get-text-property (point) 'gnus-data)))
3383 (mm-save-part data))))
3385 (defun gnus-mime-pipe-part ()
3386 "Pipe the MIME part under point to a process."
3388 (gnus-article-check-buffer)
3389 (let ((data (get-text-property (point) 'gnus-data)))
3391 (mm-pipe-part data))))
3393 (defun gnus-mime-view-part ()
3394 "Interactively choose a viewing method for the MIME part under point."
3396 (gnus-article-check-buffer)
3397 (let ((data (get-text-property (point) 'gnus-data)))
3399 (setq gnus-article-mime-handles
3401 gnus-article-mime-handles (setq data (copy-sequence data))))
3402 (mm-interactively-view-part data))))
3404 (defun gnus-mime-view-part-as-type-internal ()
3405 (gnus-article-check-buffer)
3406 (let* ((name (mail-content-type-get
3407 (mm-handle-type (get-text-property (point) 'gnus-data))
3409 (def-type (and name (mm-default-file-encoding name))))
3410 (and def-type (cons def-type 0))))
3412 (defun gnus-mime-view-part-as-type (&optional mime-type)
3413 "Choose a MIME media type, and view the part as such."
3416 (setq mime-type (completing-read
3417 "View as MIME type: "
3418 (mapcar #'list (mailcap-mime-types))
3420 (gnus-mime-view-part-as-type-internal))))
3421 (gnus-article-check-buffer)
3422 (let ((handle (get-text-property (point) 'gnus-data)))
3425 (mm-make-handle (mm-handle-buffer handle)
3426 (cons mime-type (cdr (mm-handle-type handle)))
3427 (mm-handle-encoding handle)
3428 (mm-handle-undisplayer handle)
3429 (mm-handle-disposition handle)
3430 (mm-handle-description handle)
3431 (mm-handle-cache handle)
3432 (mm-handle-id handle)))
3433 (setq gnus-article-mime-handles
3434 (mm-merge-handles gnus-article-mime-handles handle))
3435 (gnus-mm-display-part handle))))
3437 (defun gnus-mime-copy-part (&optional handle)
3438 "Put the the MIME part under point into a new buffer."
3440 (gnus-article-check-buffer)
3441 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3442 (contents (and handle (mm-get-part handle)))
3444 (file-name-nondirectory
3446 (mail-content-type-get (mm-handle-type handle) 'name)
3447 (mail-content-type-get (mm-handle-type handle)
3450 (buffer (and base (generate-new-buffer base))))
3452 (switch-to-buffer buffer)
3454 ;; We do it this way to make `normal-mode' set the appropriate mode.
3457 (setq buffer-file-name (expand-file-name base))
3459 (setq buffer-file-name nil))
3460 (goto-char (point-min)))))
3462 (defun gnus-mime-inline-part (&optional handle arg)
3463 "Insert the MIME part under point into the current buffer."
3464 (interactive (list nil current-prefix-arg))
3465 (gnus-article-check-buffer)
3466 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3471 (if (and (not arg) (mm-handle-undisplayer handle))
3472 (mm-remove-part handle)
3473 (setq contents (mm-get-part handle))
3476 (setq charset (or (mail-content-type-get
3477 (mm-handle-type handle) 'charset)
3478 gnus-newsgroup-charset)))
3480 (if (mm-handle-undisplayer handle)
3481 (mm-remove-part handle))
3484 gnus-summary-show-article-charset-alist))
3485 (read-coding-system "Charset: ")))))
3487 (mm-insert-inline handle
3489 (setq charset (mm-charset-to-coding-system
3491 (not (eq charset 'ascii)))
3492 (mm-decode-coding-string contents charset)
3496 (defun gnus-mime-view-part-as-charset (&optional handle arg)
3497 "Insert the MIME part under point into the current buffer using the
3499 (interactive (list nil current-prefix-arg))
3500 (gnus-article-check-buffer)
3501 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3506 (if (mm-handle-undisplayer handle)
3507 (mm-remove-part handle))
3508 (let ((gnus-newsgroup-charset
3510 gnus-summary-show-article-charset-alist))
3511 (read-coding-system "Charset: ")))
3512 (gnus-newsgroup-ignored-charsets 'gnus-all))
3513 (gnus-article-press-button)))))
3515 (defun gnus-mime-externalize-part (&optional handle)
3516 "View the MIME part under point with an external viewer."
3518 (gnus-article-check-buffer)
3519 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3520 (mm-user-display-methods nil)
3521 (mm-inlined-types nil)
3522 (mail-parse-charset gnus-newsgroup-charset)
3523 (mail-parse-ignored-charsets
3524 (save-excursion (set-buffer gnus-summary-buffer)
3525 gnus-newsgroup-ignored-charsets)))
3527 (if (mm-handle-undisplayer handle)
3528 (mm-remove-part handle)
3529 (mm-display-part handle)))))
3531 (defun gnus-mime-internalize-part (&optional handle)
3532 "View the MIME part under point with an internal viewer.
3533 If no internal viewer is available, use an external viewer."
3535 (gnus-article-check-buffer)
3536 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3537 (mm-inlined-types '(".*"))
3538 (mm-inline-large-images t)
3539 (mail-parse-charset gnus-newsgroup-charset)
3540 (mail-parse-ignored-charsets
3541 (save-excursion (set-buffer gnus-summary-buffer)
3542 gnus-newsgroup-ignored-charsets)))
3544 (if (mm-handle-undisplayer handle)
3545 (mm-remove-part handle)
3546 (mm-display-part handle)))))
3548 (defun gnus-mime-action-on-part (&optional action)
3549 "Do something with the MIME attachment at \(point\)."
3551 (list (completing-read "Action: " gnus-mime-action-alist)))
3552 (gnus-article-check-buffer)
3553 (let ((action-pair (assoc action gnus-mime-action-alist)))
3555 (funcall (cdr action-pair)))))
3557 (defun gnus-article-part-wrapper (n function)
3558 (save-current-buffer
3559 (set-buffer gnus-article-buffer)
3560 (when (> n (length gnus-article-mime-handle-alist))
3561 (error "No such part"))
3562 (gnus-article-goto-part n)
3563 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
3564 (funcall function handle))))
3566 (defun gnus-article-pipe-part (n)
3567 "Pipe MIME part N, which is the numerical prefix."
3569 (gnus-article-part-wrapper n 'mm-pipe-part))
3571 (defun gnus-article-save-part (n)
3572 "Save MIME part N, which is the numerical prefix."
3574 (gnus-article-part-wrapper n 'mm-save-part))
3576 (defun gnus-article-interactively-view-part (n)
3577 "View MIME part N interactively, which is the numerical prefix."
3579 (gnus-article-part-wrapper n 'mm-interactively-view-part))
3581 (defun gnus-article-copy-part (n)
3582 "Copy MIME part N, which is the numerical prefix."
3584 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
3586 (defun gnus-article-view-part-as-charset (n)
3587 "Copy MIME part N, which is the numerical prefix."
3589 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
3591 (defun gnus-article-externalize-part (n)
3592 "View MIME part N externally, which is the numerical prefix."
3594 (gnus-article-part-wrapper n 'gnus-mime-externalize-part))
3596 (defun gnus-article-inline-part (n)
3597 "Inline MIME part N, which is the numerical prefix."
3599 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
3601 (defun gnus-article-mime-match-handle-first (condition)
3603 (let ((alist gnus-article-mime-handle-alist) ihandle n)
3604 (while (setq ihandle (pop alist))
3606 ((functionp condition)
3607 (funcall condition (cdr ihandle)))
3608 ((eq condition 'undisplayed)
3609 (not (or (mm-handle-undisplayer (cdr ihandle))
3610 (equal (mm-handle-media-type (cdr ihandle))
3611 "multipart/alternative"))))
3612 ((eq condition 'undisplayed-alternative)
3613 (not (mm-handle-undisplayer (cdr ihandle))))
3615 (gnus-article-goto-part (car ihandle))
3616 (or (not n) (< (car ihandle) n)))
3617 (setq n (car ihandle))))
3621 (defun gnus-article-view-part (&optional n)
3622 "View MIME part N, which is the numerical prefix."
3624 (save-current-buffer
3625 (set-buffer gnus-article-buffer)
3626 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
3627 gnus-article-mime-match-handle-function)))
3628 (when (> n (length gnus-article-mime-handle-alist))
3629 (error "No such part"))
3630 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
3631 (when (gnus-article-goto-part n)
3632 (if (equal (car handle) "multipart/alternative")
3633 (gnus-article-press-button)
3634 (when (eq (gnus-mm-display-part handle) 'internal)
3635 (gnus-set-window-start)))))))
3637 (defsubst gnus-article-mime-total-parts ()
3638 (if (bufferp (car gnus-article-mime-handles))
3640 (1- (length gnus-article-mime-handles))))
3642 (defun gnus-mm-display-part (handle)
3643 "Display HANDLE and fix MIME button."
3644 (let ((id (get-text-property (point) 'gnus-part))
3649 (let ((window (selected-window))
3650 (mail-parse-charset gnus-newsgroup-charset)
3651 (mail-parse-ignored-charsets
3652 (save-excursion (set-buffer gnus-summary-buffer)
3653 gnus-newsgroup-ignored-charsets)))
3656 (let ((win (get-buffer-window (current-buffer) t))
3659 (select-window win))
3662 (if (mm-handle-displayed-p handle)
3663 ;; This will remove the part.
3664 (mm-display-part handle)
3666 (narrow-to-region (point) (1+ (point)))
3667 (mm-display-part handle)
3668 ;; We narrow to the part itself and
3669 ;; then call the treatment functions.
3670 (goto-char (point-min))
3672 (narrow-to-region (point) (point-max))
3675 (gnus-article-mime-total-parts)
3676 (mm-handle-media-type handle)))))
3677 (select-window window))))
3679 (delete-region (gnus-point-at-bol) (progn (forward-line 1) (point)))
3680 (gnus-insert-mime-button
3681 handle id (list (mm-handle-displayed-p handle)))
3682 (goto-char point))))
3684 (defun gnus-article-goto-part (n)
3685 "Go to MIME part N."
3686 (let ((point (text-property-any (point-min) (point-max) 'gnus-part n)))
3688 (goto-char point))))
3690 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
3691 (let ((gnus-tmp-name
3692 (or (mail-content-type-get (mm-handle-type handle)
3694 (mail-content-type-get (mm-handle-disposition handle)
3696 (mail-content-type-get (mm-handle-type handle)
3699 (gnus-tmp-type (mm-handle-media-type handle))
3700 (gnus-tmp-description
3701 (mail-decode-encoded-word-string (or (mm-handle-description handle)
3704 (if (if displayed (car displayed)
3705 (mm-handle-displayed-p handle))
3707 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
3709 gnus-tmp-type-long b e)
3710 (when (string-match ".*/" gnus-tmp-name)
3711 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
3712 (setq gnus-tmp-type-long (concat gnus-tmp-type
3713 (and (not (equal gnus-tmp-name ""))
3714 (concat "; " gnus-tmp-name))))
3715 (or (equal gnus-tmp-description "")
3716 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
3721 gnus-mime-button-line-format gnus-mime-button-line-format-alist
3722 `(keymap ,gnus-mime-button-map
3723 ,@(if (>= (string-to-number emacs-version) 21)
3725 (list 'local-map gnus-mime-button-map))
3726 gnus-callback gnus-mm-display-part
3727 gnus-part ,gnus-tmp-id
3728 article-type annotation
3731 (widget-convert-button
3734 :action 'gnus-widget-press-button
3735 :button-keymap gnus-mime-button-map
3737 (lambda (widget/window &optional overlay pos)
3738 ;; Needed to properly clear the message due to a bug in
3739 ;; wid-edit (XEmacs only).
3740 (if (boundp 'help-echo-owns-message)
3741 (setq help-echo-owns-message t))
3743 "%S: %s the MIME part; %S: more options"
3744 (aref gnus-mouse-2 0)
3745 ;; XEmacs will get a single widget arg; Emacs 21 will get
3746 ;; window, overlay, position.
3747 (if (mm-handle-displayed-p
3749 (with-current-buffer (gnus-overlay-buffer overlay)
3750 (widget-get (widget-at (gnus-overlay-start overlay))
3752 (widget-get widget/window :mime-handle)))
3754 (aref gnus-down-mouse-3 0))))))
3756 (defun gnus-widget-press-button (elems el)
3757 (goto-char (widget-get elems :from))
3758 (gnus-article-press-button))
3760 (defvar gnus-displaying-mime nil)
3762 (defun gnus-display-mime (&optional ihandles)
3763 "Display the MIME parts."
3765 (save-selected-window
3766 (let ((window (get-buffer-window gnus-article-buffer))
3769 (select-window window)
3770 ;; We have to do this since selecting the window
3771 ;; may change the point. So we set the window point.
3772 (set-window-point window point)))
3773 (let* ((handles (or ihandles (mm-dissect-buffer) (mm-uu-dissect)))
3774 buffer-read-only handle name type b e display)
3775 (when (and (not ihandles)
3776 (not gnus-displaying-mime))
3777 ;; Top-level call; we clean up.
3778 (when gnus-article-mime-handles
3779 (mm-destroy-parts gnus-article-mime-handles)
3780 (setq gnus-article-mime-handle-alist nil));; A trick.
3781 (setq gnus-article-mime-handles handles)
3782 ;; We allow users to glean info from the handles.
3783 (when gnus-article-mime-part-function
3784 (gnus-mime-part-function handles)))
3786 (or (not (stringp (car handles)))
3789 (when (and (not ihandles)
3790 (not gnus-displaying-mime))
3791 ;; Clean up for mime parts.
3793 (delete-region (point) (point-max)))
3794 (let ((gnus-displaying-mime t))
3795 (gnus-mime-display-part handles)))
3798 (narrow-to-region (point) (point-max))
3799 (gnus-treat-article nil 1 1)
3802 ;; Highlight the headers.
3806 (narrow-to-region (point-min) (point))
3807 (gnus-treat-article 'head))))))))
3809 (defvar gnus-mime-display-multipart-as-mixed nil)
3810 (defvar gnus-mime-display-multipart-alternative-as-mixed nil)
3811 (defvar gnus-mime-display-multipart-related-as-mixed nil)
3813 (defun gnus-mime-display-part (handle)
3816 ((not (stringp (car handle)))
3817 (gnus-mime-display-single handle))
3818 ;; User-defined multipart
3819 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
3820 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
3822 ;; multipart/alternative
3823 ((and (equal (car handle) "multipart/alternative")
3824 (not (or gnus-mime-display-multipart-as-mixed
3825 gnus-mime-display-multipart-alternative-as-mixed)))
3826 (let ((id (1+ (length gnus-article-mime-handle-alist))))
3827 (push (cons id handle) gnus-article-mime-handle-alist)
3828 (gnus-mime-display-alternative (cdr handle) nil nil id)))
3829 ;; multipart/related
3830 ((and (equal (car handle) "multipart/related")
3831 (not (or gnus-mime-display-multipart-as-mixed
3832 gnus-mime-display-multipart-related-as-mixed)))
3833 ;;;!!!We should find the start part, but we just default
3834 ;;;!!!to the first part.
3835 ;;(gnus-mime-display-part (cadr handle))
3836 ;;;!!! Most multipart/related is an HTML message plus images.
3837 ;;;!!! Unfortunately we are unable to let W3 display those
3838 ;;;!!! included images, so we just display it as a mixed multipart.
3839 ;;(gnus-mime-display-mixed (cdr handle))
3840 ;;;!!! No, w3 can display everything just fine.
3841 (gnus-mime-display-part (cadr handle)))
3842 ((equal (car handle) "multipart/signed")
3843 (or (memq 'signed gnus-article-wash-types)
3844 (push 'signed gnus-article-wash-types))
3845 (gnus-mime-display-security handle))
3846 ((equal (car handle) "multipart/encrypted")
3847 (or (memq 'encrypted gnus-article-wash-types)
3848 (push 'encrypted gnus-article-wash-types))
3849 (gnus-mime-display-security handle))
3850 ;; Other multiparts are handled like multipart/mixed.
3852 (gnus-mime-display-mixed (cdr handle)))))
3854 (defun gnus-mime-part-function (handles)
3855 (if (stringp (car handles))
3856 (mapcar 'gnus-mime-part-function (cdr handles))
3857 (funcall gnus-article-mime-part-function handles)))
3859 (defun gnus-mime-display-mixed (handles)
3860 (mapcar 'gnus-mime-display-part handles))
3862 (defun gnus-mime-display-single (handle)
3863 (let ((type (mm-handle-media-type handle))
3864 (ignored gnus-ignored-mime-types)
3871 (when (string-match (pop ignored) type)
3872 (throw 'ignored nil)))
3873 (if (and (setq not-attachment
3874 (and (not (mm-inline-override-p handle))
3875 (or (not (mm-handle-disposition handle))
3876 (equal (car (mm-handle-disposition handle))
3878 (mm-attachment-override-p handle))))
3879 (mm-automatic-display-p handle)
3881 (mm-inlinable-p handle)
3882 (mm-inlined-p handle))
3883 (mm-automatic-external-display-p type)))
3885 (when (equal (mm-handle-media-supertype handle) "text")
3887 (let ((id (1+ (length gnus-article-mime-handle-alist)))
3889 (push (cons id handle) gnus-article-mime-handle-alist)
3890 (when (or (not display)
3891 (not (gnus-unbuttonized-mime-type-p type)))
3892 ;(gnus-article-insert-newline)
3893 (gnus-insert-mime-button
3894 handle id (list (or display (and not-attachment text))))
3895 (gnus-article-insert-newline)
3896 ;(gnus-article-insert-newline)
3897 ;; Remember modify the number of forward lines.
3905 (let ((mail-parse-charset gnus-newsgroup-charset)
3906 (mail-parse-ignored-charsets
3907 (save-excursion (condition-case ()
3908 (set-buffer gnus-summary-buffer)
3910 gnus-newsgroup-ignored-charsets)))
3911 (mm-display-part handle t))
3912 (goto-char (point-max)))
3913 ((and text not-attachment)
3917 (gnus-article-insert-newline)
3918 (mm-insert-inline handle (mm-get-part handle))
3919 (goto-char (point-max))))
3923 (narrow-to-region beg (point))
3926 (gnus-article-mime-total-parts)
3927 (mm-handle-media-type handle)))))))))
3929 (defun gnus-unbuttonized-mime-type-p (type)
3930 "Say whether TYPE is to be unbuttonized."
3931 (unless gnus-inhibit-mime-unbuttonizing
3933 (let ((types gnus-unbuttonized-mime-types))
3935 (when (string-match (pop types) type)
3936 (throw 'found t)))))))
3938 (defun gnus-article-insert-newline ()
3939 "Insert a newline, but mark it as undeletable."
3940 (gnus-put-text-property
3941 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
3943 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
3944 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
3947 handle buffer-read-only from props begend not-pref)
3948 (save-window-excursion
3951 (narrow-to-region (car ibegend)
3954 (goto-char (car ibegend))
3957 (delete-region (point-min) (point-max))
3958 (mm-remove-parts handles))
3959 (setq begend (list (point-marker)))
3961 (unless (setq not-pref (cadr (member preferred ihandles)))
3962 (setq not-pref (car ihandles)))
3965 (not (gnus-unbuttonized-mime-type-p
3966 "multipart/alternative")))
3967 (gnus-add-text-properties
3970 (insert (format "%d. " id))
3974 (unless ,(not ibegend)
3975 (setq gnus-article-mime-handle-alist
3976 ',gnus-article-mime-handle-alist))
3977 (gnus-mime-display-alternative
3978 ',ihandles ',not-pref ',begend ,id))
3979 ,@(if (>= (string-to-number emacs-version) 21)
3980 nil ;; XEmacs doesn't care
3981 (list 'local-map gnus-mime-button-map))
3982 ,gnus-mouse-face-prop ,gnus-article-mouse-face
3983 face ,gnus-article-button-face
3984 keymap ,gnus-mime-button-map
3987 (widget-convert-button 'link from (point)
3988 :action 'gnus-widget-press-button
3989 :button-keymap gnus-widget-button-keymap)
3991 (while (setq handle (pop handles))
3992 (gnus-add-text-properties
3995 (insert (format "(%c) %-18s"
3996 (if (equal handle preferred) ?* ? )
3997 (mm-handle-media-type handle)))
4001 (unless ,(not ibegend)
4002 (setq gnus-article-mime-handle-alist
4003 ',gnus-article-mime-handle-alist))
4004 (gnus-mime-display-alternative
4005 ',ihandles ',handle ',begend ,id))
4006 ,@(if (>= (string-to-number emacs-version) 21)
4007 nil ;; XEmacs doesn't care
4008 (list 'local-map gnus-mime-button-map))
4009 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4010 face ,gnus-article-button-face
4011 keymap ,gnus-mime-button-map
4014 (widget-convert-button 'link from (point)
4015 :action 'gnus-widget-press-button
4016 :button-keymap gnus-widget-button-keymap)
4020 (if (stringp (car preferred))
4021 (gnus-display-mime preferred)
4022 (let ((mail-parse-charset gnus-newsgroup-charset)
4023 (mail-parse-ignored-charsets
4024 (save-excursion (set-buffer gnus-summary-buffer)
4025 gnus-newsgroup-ignored-charsets)))
4026 (mm-display-part preferred)
4030 (narrow-to-region (car begend) (point-max))
4032 nil (length gnus-article-mime-handle-alist)
4033 (gnus-article-mime-total-parts)
4034 (mm-handle-media-type handle))))))
4035 (goto-char (point-max))
4036 (setcdr begend (point-marker)))))
4038 (goto-char point))))
4040 (defun gnus-article-wash-status ()
4041 "Return a string which display status of article washing."
4043 (set-buffer gnus-article-buffer)
4044 (let ((cite (memq 'cite gnus-article-wash-types))
4045 (headers (memq 'headers gnus-article-wash-types))
4046 (boring (memq 'boring-headers gnus-article-wash-types))
4047 (pgp (memq 'pgp gnus-article-wash-types))
4048 (pem (memq 'pem gnus-article-wash-types))
4049 (signed (memq 'signed gnus-article-wash-types))
4050 (encrypted (memq 'encrypted gnus-article-wash-types))
4051 (signature (memq 'signature gnus-article-wash-types))
4052 (overstrike (memq 'overstrike gnus-article-wash-types))
4053 (emphasis (memq 'emphasis gnus-article-wash-types)))
4054 (format "%c%c%c%c%c%c"
4056 (if (or headers boring) ?h ? )
4057 (if (or pgp pem signed encrypted) ?p ? )
4058 (if signature ?s ? )
4059 (if overstrike ?o ? )
4060 (if emphasis ?e ? )))))
4062 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
4064 (defun gnus-article-maybe-hide-headers ()
4065 "Hide unwanted headers if `gnus-have-all-headers' is nil.
4066 Provided for backwards compatibility."
4067 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
4068 (not (save-excursion (set-buffer gnus-summary-buffer)
4069 gnus-have-all-headers)))
4070 (not gnus-inhibit-hiding))
4071 (gnus-article-hide-headers)))
4075 (defun gnus-output-to-file (file-name)
4076 "Append the current article to a file named FILE-NAME."
4077 (let ((artbuf (current-buffer)))
4079 (insert-buffer-substring artbuf)
4080 ;; Append newline at end of the buffer as separator, and then
4082 (goto-char (point-max))
4084 (mm-append-to-file (point-min) (point-max) file-name)
4087 (defun gnus-narrow-to-page (&optional arg)
4088 "Narrow the article buffer to a page.
4089 If given a numerical ARG, move forward ARG pages."
4091 (setq arg (if arg (prefix-numeric-value arg) 0))
4093 (set-buffer gnus-article-buffer)
4094 (goto-char (point-min))
4096 ;; Remove any old next/prev buttons.
4097 (when (gnus-visual-p 'page-marker)
4098 (let ((buffer-read-only nil))
4099 (gnus-remove-text-with-property 'gnus-prev)
4100 (gnus-remove-text-with-property 'gnus-next)))
4103 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
4105 (re-search-forward page-delimiter nil 'move arg)))
4106 (goto-char (match-end 0)))
4109 (if (re-search-forward page-delimiter nil 'move)
4112 (when (and (gnus-visual-p 'page-marker)
4113 (not (= (point-min) 1)))
4115 (goto-char (point-min))
4116 (gnus-insert-prev-page-button)))
4117 (when (and (gnus-visual-p 'page-marker)
4118 (< (+ (point-max) 2) (buffer-size)))
4120 (goto-char (point-max))
4121 (gnus-insert-next-page-button)))))
4123 ;; Article mode commands
4125 (defun gnus-article-goto-next-page ()
4126 "Show the next page of the article."
4128 (when (gnus-article-next-page)
4129 (goto-char (point-min))
4130 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
4132 (defun gnus-article-goto-prev-page ()
4133 "Show the next page of the article."
4135 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
4136 (gnus-article-prev-page nil)))
4138 (defun gnus-article-next-page (&optional lines)
4139 "Show the next page of the current article.
4140 If end of article, return non-nil. Otherwise return nil.
4141 Argument LINES specifies lines to be scrolled up."
4143 (move-to-window-line -1)
4146 (and (pos-visible-in-window-p) ;Not continuation line.
4148 ;; Nothing in this page.
4149 (if (or (not gnus-page-broken)
4152 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
4154 (gnus-narrow-to-page 1) ;Go to next page.
4156 ;; More in this page.
4157 (let ((scroll-in-place nil))
4161 ;; Long lines may cause an end-of-buffer error.
4162 (goto-char (point-max)))))
4163 (move-to-window-line 0)
4166 (defun gnus-article-prev-page (&optional lines)
4167 "Show previous page of current article.
4168 Argument LINES specifies lines to be scrolled down."
4170 (move-to-window-line 0)
4171 (if (and gnus-page-broken
4173 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
4175 (gnus-narrow-to-page -1) ;Go to previous page.
4176 (goto-char (point-max))
4178 (let ((scroll-in-place nil))
4182 (beginning-of-buffer
4183 (goto-char (point-min))))
4184 (move-to-window-line 0)))))
4186 (defun gnus-article-refer-article ()
4187 "Read article specified by message-id around point."
4189 (let ((point (point)))
4190 (search-forward ">" nil t) ;Move point to end of "<....>".
4191 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
4192 (let ((message-id (match-string 1)))
4194 (set-buffer gnus-summary-buffer)
4195 (gnus-summary-refer-article message-id))
4197 (error "No references around point"))))
4199 (defun gnus-article-show-summary ()
4200 "Reconfigure windows to show summary buffer."
4202 (if (not (gnus-buffer-live-p gnus-summary-buffer))
4203 (error "There is no summary buffer for this article buffer")
4204 (gnus-article-set-globals)
4205 (gnus-configure-windows 'article)
4206 (gnus-summary-goto-subject gnus-current-article)
4207 (gnus-summary-position-point)))
4209 (defun gnus-article-describe-briefly ()
4210 "Describe article mode commands briefly."
4212 (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")))
4214 (defun gnus-article-summary-command ()
4215 "Execute the last keystroke in the summary buffer."
4217 (let ((obuf (current-buffer))
4218 (owin (current-window-configuration))
4220 (switch-to-buffer gnus-article-current-summary 'norecord)
4221 (setq func (lookup-key (current-local-map) (this-command-keys)))
4222 (call-interactively func)
4224 (set-window-configuration owin)
4225 (set-window-point (get-buffer-window (current-buffer)) (point))))
4227 (defun gnus-article-summary-command-nosave ()
4228 "Execute the last keystroke in the summary buffer."
4231 (pop-to-buffer gnus-article-current-summary 'norecord)
4232 (setq func (lookup-key (current-local-map) (this-command-keys)))
4233 (call-interactively func)))
4235 (defun gnus-article-check-buffer ()
4236 "Beep if not in an article buffer."
4237 (unless (equal major-mode 'gnus-article-mode)
4238 (error "Command invoked outside of a Gnus article buffer")))
4240 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
4241 "Read a summary buffer key sequence and execute it from the article buffer."
4243 (gnus-article-check-buffer)
4245 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
4246 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
4247 "=" "^" "\M-^" "|"))
4253 '("n" "Gn" "p" "Gp"))
4256 (set-buffer gnus-article-current-summary)
4257 (let (gnus-pick-mode)
4258 (push (or key last-command-event) unread-command-events)
4259 (setq keys (if (featurep 'xemacs)
4260 (events-to-keys (read-key-sequence nil))
4261 (read-key-sequence nil)))))
4265 (if (or (member keys nosaves)
4266 (member keys nosave-but-article)
4267 (member keys nosave-in-article))
4269 (save-window-excursion
4270 (pop-to-buffer gnus-article-current-summary 'norecord)
4271 ;; We disable the pick minor mode commands.
4272 (let (gnus-pick-mode)
4273 (setq func (lookup-key (current-local-map) keys))))
4277 (unless (member keys nosave-in-article)
4278 (set-buffer gnus-article-current-summary))
4279 (call-interactively func)
4280 (setq new-sum-point (point)))
4281 (when (member keys nosave-but-article)
4282 (pop-to-buffer gnus-article-buffer 'norecord)))
4283 ;; These commands should restore window configuration.
4284 (let ((obuf (current-buffer))
4285 (owin (current-window-configuration))
4287 (summary gnus-article-current-summary)
4288 func in-buffer selected)
4289 (if not-restore-window
4290 (pop-to-buffer summary 'norecord)
4291 (switch-to-buffer summary 'norecord))
4292 (setq in-buffer (current-buffer))
4293 ;; We disable the pick minor mode commands.
4294 (if (and (setq func (let (gnus-pick-mode)
4295 (lookup-key (current-local-map) keys)))
4298 (call-interactively func)
4299 (setq new-sum-point (point))
4300 (when (eq in-buffer (current-buffer))
4301 (setq selected (gnus-summary-select-article))
4303 (unless not-restore-window
4304 (set-window-configuration owin))
4305 (when (eq selected 'old)
4307 (set-window-start (get-buffer-window (current-buffer))
4309 (set-window-point (get-buffer-window (current-buffer))
4311 (let ((win (get-buffer-window gnus-article-current-summary)))
4313 (set-window-point win new-sum-point)))) )
4314 (switch-to-buffer gnus-article-buffer)
4317 (defun gnus-article-describe-key (key)
4318 "Display documentation of the function invoked by KEY. KEY is a string."
4319 (interactive "kDescribe key: ")
4320 (gnus-article-check-buffer)
4321 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
4323 (set-buffer gnus-article-current-summary)
4324 (let (gnus-pick-mode)
4325 (if (featurep 'xemacs)
4327 (push (elt key 0) unread-command-events)
4328 (setq key (events-to-keys
4329 (read-key-sequence "Describe key: "))))
4330 (setq unread-command-events
4332 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
4333 (string-to-list key)))
4334 (setq key (read-key-sequence "Describe key: "))))
4336 (describe-key key)))
4338 (defun gnus-article-describe-key-briefly (key &optional insert)
4339 "Display documentation of the function invoked by KEY. KEY is a string."
4340 (interactive "kDescribe key: \nP")
4341 (gnus-article-check-buffer)
4342 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
4344 (set-buffer gnus-article-current-summary)
4345 (let (gnus-pick-mode)
4346 (if (featurep 'xemacs)
4348 (push (elt key 0) unread-command-events)
4349 (setq key (events-to-keys
4350 (read-key-sequence "Describe key: "))))
4351 (setq unread-command-events
4353 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
4354 (string-to-list key)))
4355 (setq key (read-key-sequence "Describe key: "))))
4356 (describe-key-briefly key insert))
4357 (describe-key-briefly key insert)))
4359 (defun gnus-article-hide (&optional arg force)
4360 "Hide all the gruft in the current article.
4361 This means that PGP stuff, signatures, cited text and (some)
4362 headers will be hidden.
4363 If given a prefix, show the hidden text instead."
4364 (interactive (append (gnus-article-hidden-arg) (list 'force)))
4365 (gnus-article-hide-headers arg)
4366 (gnus-article-hide-list-identifiers arg)
4367 (gnus-article-hide-pgp arg)
4368 (gnus-article-hide-citation-maybe arg force)
4369 (gnus-article-hide-signature arg))
4371 (defun gnus-article-maybe-highlight ()
4372 "Do some article highlighting if article highlighting is requested."
4373 (when (gnus-visual-p 'article-highlight 'highlight)
4374 (gnus-article-highlight-some)))
4376 (defun gnus-check-group-server ()
4377 ;; Make sure the connection to the server is alive.
4378 (unless (gnus-server-opened
4379 (gnus-find-method-for-group gnus-newsgroup-name))
4380 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
4381 (gnus-request-group gnus-newsgroup-name t)))
4383 (defun gnus-request-article-this-buffer (article group)
4384 "Get an article and insert it into this buffer."
4385 (let (do-update-line sparse-header)
4389 (gnus-kill-all-overlays)
4390 (setq group (or group gnus-newsgroup-name))
4392 ;; Using `gnus-request-article' directly will insert the article into
4393 ;; `nntp-server-buffer' - so we'll save some time by not having to
4394 ;; copy it from the server buffer into the article buffer.
4396 ;; We only request an article by message-id when we do not have the
4397 ;; headers for it, so we'll have to get those.
4398 (when (stringp article)
4399 (gnus-read-header article))
4401 ;; If the article number is negative, that means that this article
4402 ;; doesn't belong in this newsgroup (possibly), so we find its
4403 ;; message-id and request it by id instead of number.
4404 (when (and (numberp article)
4406 (get-buffer gnus-summary-buffer)
4407 (gnus-buffer-exists-p gnus-summary-buffer))
4409 (set-buffer gnus-summary-buffer)
4410 (let ((header (gnus-summary-article-header article)))
4413 ((memq article gnus-newsgroup-sparse)
4414 ;; This is a sparse gap article.
4415 (setq do-update-line article)
4416 (setq article (mail-header-id header))
4417 (setq sparse-header (gnus-read-header article))
4418 (setq gnus-newsgroup-sparse
4419 (delq article gnus-newsgroup-sparse)))
4421 ;; It's a real article.
4422 (setq article (mail-header-id header)))
4424 ;; It is an extracted pseudo-article.
4425 (setq article 'pseudo)
4426 (gnus-request-pseudo-article header))))
4428 (let ((method (gnus-find-method-for-group
4429 gnus-newsgroup-name)))
4430 (when (and (eq (car method) 'nneething)
4432 (let ((dir (expand-file-name
4433 (mail-header-subject header)
4434 (file-name-as-directory
4435 (or (cadr (assq 'nneething-address method))
4437 (when (file-directory-p dir)
4438 (setq article 'nneething)
4439 (gnus-group-enter-directory dir))))))))
4442 ;; Refuse to select canceled articles.
4443 ((and (numberp article)
4445 (get-buffer gnus-summary-buffer)
4446 (gnus-buffer-exists-p gnus-summary-buffer)
4447 (eq (cdr (save-excursion
4448 (set-buffer gnus-summary-buffer)
4449 (assq article gnus-newsgroup-reads)))
4450 gnus-canceled-mark))
4452 ;; We first check `gnus-original-article-buffer'.
4453 ((and (get-buffer gnus-original-article-buffer)
4456 (set-buffer gnus-original-article-buffer)
4457 (and (equal (car gnus-original-article) group)
4458 (eq (cdr gnus-original-article) article))))
4459 (insert-buffer-substring gnus-original-article-buffer)
4461 ;; Check the backlog.
4462 ((and gnus-keep-backlog
4463 (gnus-backlog-request-article group article (current-buffer)))
4465 ;; Check asynchronous pre-fetch.
4466 ((gnus-async-request-fetched-article group article (current-buffer))
4467 (gnus-async-prefetch-next group article gnus-summary-buffer)
4468 (when (and (numberp article) gnus-keep-backlog)
4469 (gnus-backlog-enter-article group article (current-buffer)))
4472 ((and gnus-use-cache
4474 (gnus-cache-request-article article group))
4476 ;; Get the article and put into the article buffer.
4477 ((or (stringp article)
4479 (let ((gnus-override-method gnus-override-method)
4480 (methods (and (stringp article)
4481 gnus-refer-article-method))
4483 (buffer-read-only nil))
4484 (if (or (not (listp methods))
4485 (and (symbolp (car methods))
4486 (assq (car methods) nnoo-definition-alist)))
4487 (setq methods (list methods)))
4488 (when (and (null gnus-override-method)
4490 (setq gnus-override-method (pop methods)))
4492 (when (eq gnus-override-method 'current)
4493 (setq gnus-override-method gnus-current-select-method))
4495 (gnus-kill-all-overlays)
4496 (let ((gnus-newsgroup-name group))
4497 (gnus-check-group-server))
4498 (when (gnus-request-article article group (current-buffer))
4499 (when (numberp article)
4500 (gnus-async-prefetch-next group article
4501 gnus-summary-buffer)
4502 (when gnus-keep-backlog
4503 (gnus-backlog-enter-article
4504 group article (current-buffer))))
4505 (setq result 'article))
4508 (setq gnus-override-method (pop methods))
4509 (setq result 'done))))
4510 (and (eq result 'article) 'article)))
4514 ;; Associate this article with the current summary buffer.
4515 (setq gnus-article-current-summary gnus-summary-buffer)
4517 ;; Take the article from the original article buffer
4518 ;; and place it in the buffer it's supposed to be in.
4519 (when (and (get-buffer gnus-article-buffer)
4520 (equal (buffer-name (current-buffer))
4521 (buffer-name (get-buffer gnus-article-buffer))))
4523 (if (get-buffer gnus-original-article-buffer)
4524 (set-buffer gnus-original-article-buffer)
4525 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
4526 (buffer-disable-undo)
4527 (setq major-mode 'gnus-original-article-mode)
4528 (setq buffer-read-only t))
4529 (let (buffer-read-only)
4531 (insert-buffer-substring gnus-article-buffer))
4532 (setq gnus-original-article (cons group article)))
4535 (run-hooks 'gnus-article-decode-hook)
4536 ;; Mark article as decoded or not.
4537 (setq gnus-article-decoded-p gnus-article-decode-hook))
4539 ;; Update sparse articles.
4540 (when (and do-update-line
4541 (or (numberp article)
4543 (let ((buf (current-buffer)))
4544 (set-buffer gnus-summary-buffer)
4545 (gnus-summary-update-article do-update-line sparse-header)
4546 (gnus-summary-goto-subject do-update-line nil t)
4547 (set-window-point (get-buffer-window (current-buffer) t)
4549 (set-buffer buf))))))
4555 (defcustom gnus-article-edit-mode-hook nil
4556 "Hook run in article edit mode buffers."
4557 :group 'gnus-article-various
4560 (defvar gnus-article-edit-done-function nil)
4562 (defvar gnus-article-edit-mode-map nil)
4564 ;; Should we be using derived.el for this?
4565 (unless gnus-article-edit-mode-map
4566 (setq gnus-article-edit-mode-map (make-sparse-keymap))
4567 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
4569 (gnus-define-keys gnus-article-edit-mode-map
4570 "\C-c\C-c" gnus-article-edit-done
4571 "\C-c\C-k" gnus-article-edit-exit)
4573 (gnus-define-keys (gnus-article-edit-wash-map
4574 "\C-c\C-w" gnus-article-edit-mode-map)
4575 "f" gnus-article-edit-full-stops))
4577 (defun gnus-article-edit-mode ()
4578 "Major mode for editing articles.
4579 This is an extended text-mode.
4581 \\{gnus-article-edit-mode-map}"
4583 (setq major-mode 'gnus-article-edit-mode)
4584 (setq mode-name "Article Edit")
4585 (use-local-map gnus-article-edit-mode-map)
4586 (make-local-variable 'gnus-article-edit-done-function)
4587 (make-local-variable 'gnus-prev-winconf)
4588 (setq buffer-read-only nil)
4589 (buffer-enable-undo)
4591 (gnus-run-hooks 'text-mode-hook 'gnus-article-edit-mode-hook))
4593 (defun gnus-article-edit (&optional force)
4594 "Edit the current article.
4595 This will have permanent effect only in mail groups.
4596 If FORCE is non-nil, allow editing of articles even in read-only
4599 (when (and (not force)
4600 (gnus-group-read-only-p))
4601 (error "The current newsgroup does not support article editing"))
4602 (gnus-article-date-original)
4603 (gnus-article-edit-article
4605 `(lambda (no-highlight)
4607 (gnus-summary-edit-article-done
4608 ,(or (mail-header-references gnus-current-headers) "")
4609 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
4611 (defun gnus-article-edit-article (start-func exit-func)
4612 "Start editing the contents of the current article buffer."
4613 (let ((winconf (current-window-configuration)))
4614 (set-buffer gnus-article-buffer)
4615 (gnus-article-edit-mode)
4616 (funcall start-func)
4617 (set-buffer-modified-p nil)
4618 (gnus-configure-windows 'edit-article)
4619 (setq gnus-article-edit-done-function exit-func)
4620 (setq gnus-prev-winconf winconf)
4621 (gnus-message 6 "C-c C-c to end edits")))
4623 (defun gnus-article-edit-done (&optional arg)
4624 "Update the article edits and exit."
4626 (let ((func gnus-article-edit-done-function)
4627 (buf (current-buffer))
4628 (start (window-start)))
4629 ;; We remove all text props from the article buffer.
4631 (buffer-substring-no-properties (point-min) (point-max)))
4635 (let ((winconf gnus-prev-winconf))
4637 (set-window-configuration winconf)
4638 ;; Tippy-toe some to make sure that point remains where it was.
4639 (save-current-buffer
4641 (set-window-start (get-buffer-window (current-buffer)) start)
4645 (let ((buffer-read-only nil))
4647 ;; The cache and backlog have to be flushed somewhat.
4648 (when gnus-keep-backlog
4649 (gnus-backlog-remove-article
4650 (car gnus-article-current) (cdr gnus-article-current)))
4651 ;; Flush original article as well.
4653 (when (get-buffer gnus-original-article-buffer)
4654 (set-buffer gnus-original-article-buffer)
4655 (setq gnus-original-article nil)))
4656 (when gnus-use-cache
4657 (gnus-cache-update-article
4658 (car gnus-article-current) (cdr gnus-article-current))))
4660 (set-window-start (get-buffer-window buf) start)
4661 (set-window-point (get-buffer-window buf) (point))))
4663 (defun gnus-article-edit-exit ()
4664 "Exit the article editing without updating."
4666 (when (or (not (buffer-modified-p))
4667 (yes-or-no-p "Article modified; kill anyway? "))
4668 (let ((curbuf (current-buffer))
4670 (window-start (window-start)))
4672 (if (gnus-buffer-live-p gnus-original-article-buffer)
4673 (insert-buffer gnus-original-article-buffer))
4674 (let ((winconf gnus-prev-winconf))
4676 (set-window-configuration winconf)
4677 ;; Tippy-toe some to make sure that point remains where it was.
4678 (save-current-buffer
4680 (set-window-start (get-buffer-window (current-buffer)) window-start)
4683 (defun gnus-article-edit-full-stops ()
4684 "Interactively repair spacing at end of sentences."
4687 (goto-char (point-min))
4688 (search-forward-regexp "^$" nil t)
4689 (let ((case-fold-search nil))
4690 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
4693 ;;; Article highlights
4696 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
4698 ;;; Internal Variables:
4700 (defcustom gnus-button-url-regexp "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|news\\|telnet\\|wais\\|mailto\\):\\)\\(//[-a-zA-Z0-9_.]+:[0-9]*\\)?\\([-a-zA-Z0-9_=!?#$@~`%&*+|\\/:;.,]\\|\\w\\)+\\([-a-zA-Z0-9_=#$@~`%&*+|\\/]\\|\\w\\)\\)"
4701 "Regular expression that matches URLs."
4702 :group 'gnus-article-buttons
4705 (defcustom gnus-button-alist
4706 `(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
4707 0 t gnus-button-handle-news 3)
4708 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
4709 gnus-button-handle-news 2)
4710 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
4712 gnus-button-fetch-group 4)
4713 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
4714 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
4715 t gnus-button-message-id 3)
4716 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
4717 ("mailto:\\([-a-zA-Z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
4718 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
4719 ;; This is how URLs _should_ be embedded in text...
4720 ("<URL: *\\([^<>]*\\)>" 0 t gnus-button-embedded-url 1)
4722 (,gnus-button-url-regexp 0 t browse-url 0))
4723 "*Alist of regexps matching buttons in article bodies.
4725 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
4726 REGEXP: is the string matching text around the button,
4727 BUTTON: is the number of the regexp grouping actually matching the button,
4728 FORM: is a lisp expression which must eval to true for the button to
4730 CALLBACK: is the function to call when the user push this button, and each
4731 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
4733 CALLBACK can also be a variable, in that case the value of that
4734 variable it the real callback function."
4735 :group 'gnus-article-buttons
4736 :type '(repeat (list regexp
4737 (integer :tag "Button")
4739 (function :tag "Callback")
4742 (integer :tag "Regexp group")))))
4744 (defcustom gnus-header-button-alist
4745 `(("^\\(References\\|Message-I[Dd]\\):" "<[^>]+>"
4746 0 t gnus-button-message-id 0)
4747 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
4748 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
4749 0 t gnus-button-mailto 0)
4750 ("^X-[Uu][Rr][Ll]:" ,gnus-button-url-regexp 0 t browse-url 0)
4751 ("^Subject:" ,gnus-button-url-regexp 0 t browse-url 0)
4752 ("^[^:]+:" ,gnus-button-url-regexp 0 t browse-url 0)
4753 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
4754 gnus-button-message-id 3))
4755 "*Alist of headers and regexps to match buttons in article heads.
4757 This alist is very similar to `gnus-button-alist', except that each
4758 alist has an additional HEADER element first in each entry:
4760 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
4762 HEADER is a regexp to match a header. For a fuller explanation, see
4763 `gnus-button-alist'."
4764 :group 'gnus-article-buttons
4765 :group 'gnus-article-headers
4766 :type '(repeat (list (regexp :tag "Header")
4768 (integer :tag "Button")
4770 (function :tag "Callback")
4773 (integer :tag "Regexp group")))))
4775 (defvar gnus-button-regexp nil)
4776 (defvar gnus-button-marker-list nil)
4777 ;; Regexp matching any of the regexps from `gnus-button-alist'.
4779 (defvar gnus-button-last nil)
4780 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
4784 (defun gnus-article-push-button (event)
4785 "Check text under the mouse pointer for a callback function.
4786 If the text under the mouse pointer has a `gnus-callback' property,
4787 call it with the value of the `gnus-data' text property."
4789 (set-buffer (window-buffer (posn-window (event-start event))))
4790 (let* ((pos (posn-point (event-start event)))
4791 (data (get-text-property pos 'gnus-data))
4792 (fun (get-text-property pos 'gnus-callback)))
4795 (funcall fun data))))
4797 (defun gnus-article-press-button ()
4798 "Check text at point for a callback function.
4799 If the text at point has a `gnus-callback' property,
4800 call it with the value of the `gnus-data' text property."
4802 (let* ((data (get-text-property (point) 'gnus-data))
4803 (fun (get-text-property (point) 'gnus-callback)))
4805 (funcall fun data))))
4807 (defun gnus-article-highlight (&optional force)
4808 "Highlight current article.
4809 This function calls `gnus-article-highlight-headers',
4810 `gnus-article-highlight-citation',
4811 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
4812 do the highlighting. See the documentation for those functions."
4813 (interactive (list 'force))
4814 (gnus-article-highlight-headers)
4815 (gnus-article-highlight-citation force)
4816 (gnus-article-highlight-signature)
4817 (gnus-article-add-buttons force)
4818 (gnus-article-add-buttons-to-head))
4820 (defun gnus-article-highlight-some (&optional force)
4821 "Highlight current article.
4822 This function calls `gnus-article-highlight-headers',
4823 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
4824 do the highlighting. See the documentation for those functions."
4825 (interactive (list 'force))
4826 (gnus-article-highlight-headers)
4827 (gnus-article-highlight-signature)
4828 (gnus-article-add-buttons))
4830 (defun gnus-article-highlight-headers ()
4831 "Highlight article headers as specified by `gnus-header-face-alist'."
4834 (set-buffer gnus-article-buffer)
4836 (let ((alist gnus-header-face-alist)
4837 (buffer-read-only nil)
4838 (case-fold-search t)
4839 (inhibit-point-motion-hooks t)
4840 entry regexp header-face field-face from hpoints fpoints)
4841 (article-narrow-to-head)
4842 (while (setq entry (pop alist))
4843 (goto-char (point-min))
4844 (setq regexp (concat "^\\("
4845 (if (string-equal "" (nth 0 entry))
4849 header-face (nth 1 entry)
4850 field-face (nth 2 entry))
4851 (while (and (re-search-forward regexp nil t)
4855 (unless (search-forward ":" nil t)
4857 (when (and header-face
4858 (not (memq (point) hpoints)))
4859 (push (point) hpoints)
4860 (gnus-put-text-property from (point) 'face header-face))
4861 (when (and field-face
4862 (not (memq (setq from (point)) fpoints)))
4864 (if (re-search-forward "^[^ \t]" nil t)
4866 (goto-char (point-max)))
4867 (gnus-put-text-property from (point) 'face field-face))))))))
4869 (defun gnus-article-highlight-signature ()
4870 "Highlight the signature in an article.
4871 It does this by highlighting everything after
4872 `gnus-signature-separator' using `gnus-signature-face'."
4875 (set-buffer gnus-article-buffer)
4876 (let ((buffer-read-only nil)
4877 (inhibit-point-motion-hooks t))
4879 (when (and gnus-signature-face
4880 (gnus-article-narrow-to-signature))
4881 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
4882 'face gnus-signature-face)
4884 (gnus-article-search-signature)
4885 (let ((start (match-beginning 0))
4886 (end (set-marker (make-marker) (1+ (match-end 0)))))
4887 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
4890 (defun gnus-button-in-region-p (b e prop)
4891 "Say whether PROP exists in the region."
4892 (text-property-not-all b e prop nil))
4894 (defun gnus-article-add-buttons (&optional force)
4895 "Find external references in the article and make buttons of them.
4896 \"External references\" are things like Message-IDs and URLs, as
4897 specified by `gnus-button-alist'."
4898 (interactive (list 'force))
4900 (set-buffer gnus-article-buffer)
4901 (let ((buffer-read-only nil)
4902 (inhibit-point-motion-hooks t)
4903 (case-fold-search t)
4904 (alist gnus-button-alist)
4906 ;; Remove all old markers.
4907 (let (marker entry new-list)
4908 (while (setq marker (pop gnus-button-marker-list))
4909 (if (or (< marker (point-min)) (>= marker (point-max)))
4910 (push marker new-list)
4912 (when (setq entry (gnus-button-entry))
4913 (put-text-property (match-beginning (nth 1 entry))
4914 (match-end (nth 1 entry))
4915 'gnus-callback nil))
4916 (set-marker marker nil)))
4917 (setq gnus-button-marker-list new-list))
4918 ;; We skip the headers.
4921 (while (setq entry (pop alist))
4922 (setq regexp (car entry))
4924 (while (re-search-forward regexp nil t)
4925 (let* ((start (and entry (match-beginning (nth 1 entry))))
4926 (end (and entry (match-end (nth 1 entry))))
4927 (from (match-beginning 0)))
4928 (when (and (or (eq t (nth 2 entry))
4929 (eval (nth 2 entry)))
4930 (not (gnus-button-in-region-p
4931 start end 'gnus-callback)))
4932 ;; That optional form returned non-nil, so we add the
4934 (gnus-article-add-button
4935 start end 'gnus-button-push
4936 (car (push (set-marker (make-marker) from)
4937 gnus-button-marker-list))))))))))
4939 ;; Add buttons to the head of an article.
4940 (defun gnus-article-add-buttons-to-head ()
4941 "Add buttons to the head of the article."
4944 (set-buffer gnus-article-buffer)
4946 (let ((buffer-read-only nil)
4947 (inhibit-point-motion-hooks t)
4948 (case-fold-search t)
4949 (alist gnus-header-button-alist)
4951 (article-narrow-to-head)
4953 ;; Each alist entry.
4954 (setq entry (car alist)
4956 (goto-char (point-min))
4957 (while (re-search-forward (car entry) nil t)
4958 ;; Each header matching the entry.
4959 (setq beg (match-beginning 0))
4960 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
4961 (match-beginning 0))
4964 (while (re-search-forward (nth 1 entry) end t)
4965 ;; Each match within a header.
4966 (let* ((entry (cdr entry))
4967 (start (match-beginning (nth 1 entry)))
4968 (end (match-end (nth 1 entry)))
4969 (form (nth 2 entry)))
4970 (goto-char (match-end 0))
4972 (gnus-article-add-button
4973 start end (nth 3 entry)
4974 (buffer-substring (match-beginning (nth 4 entry))
4975 (match-end (nth 4 entry)))))))
4976 (goto-char end)))))))
4978 ;;; External functions:
4980 (defun gnus-article-add-button (from to fun &optional data)
4981 "Create a button between FROM and TO with callback FUN and data DATA."
4982 (when gnus-article-button-face
4983 (gnus-overlay-put (gnus-make-overlay from to)
4984 'face gnus-article-button-face))
4985 (gnus-add-text-properties
4987 (nconc (and gnus-article-mouse-face
4988 (list gnus-mouse-face-prop gnus-article-mouse-face))
4989 (list 'gnus-callback fun)
4990 (and data (list 'gnus-data data))))
4991 (widget-convert-button 'link from to :action 'gnus-widget-press-button
4992 :button-keymap gnus-widget-button-keymap))
4994 ;;; Internal functions:
4996 (defun gnus-article-set-globals ()
4998 (set-buffer gnus-summary-buffer)
4999 (gnus-set-global-variables)))
5001 (defun gnus-signature-toggle (end)
5003 (set-buffer gnus-article-buffer)
5004 (let ((buffer-read-only nil)
5005 (inhibit-point-motion-hooks t))
5006 (if (text-property-any end (point-max) 'article-type 'signature)
5007 (gnus-remove-text-properties-when
5008 'article-type 'signature end (point-max)
5009 (cons 'article-type (cons 'signature
5010 gnus-hidden-properties)))
5011 (gnus-add-text-properties-when
5012 'article-type nil end (point-max)
5013 (cons 'article-type (cons 'signature
5014 gnus-hidden-properties)))))))
5016 (defun gnus-button-entry ()
5017 ;; Return the first entry in `gnus-button-alist' matching this place.
5018 (let ((alist gnus-button-alist)
5021 (setq entry (pop alist))
5022 (if (looking-at (car entry))
5027 (defun gnus-button-push (marker)
5028 ;; Push button starting at MARKER.
5031 (let* ((entry (gnus-button-entry))
5032 (inhibit-point-motion-hooks t)
5034 (args (mapcar (lambda (group)
5035 (let ((string (match-string group)))
5036 (gnus-set-text-properties
5037 0 (length string) nil string)
5044 (fboundp (symbol-value fun)))
5045 (apply (symbol-value fun) args))
5047 (gnus-message 1 "You must define `%S' to use this button"
5048 (cons fun args)))))))
5050 (defun gnus-parse-news-url (url)
5051 (let (scheme server group message-id articles)
5054 (goto-char (point-min))
5055 (when (looking-at "\\([A-Za-z]+\\):")
5056 (setq scheme (match-string 1))
5057 (goto-char (match-end 0)))
5058 (when (looking-at "//\\([^/]+\\)/")
5059 (setq server (match-string 1))
5060 (goto-char (match-end 0)))
5063 ((looking-at "\\(.*@.*\\)")
5064 (setq message-id (match-string 1)))
5065 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
5066 (setq group (match-string 1)
5067 articles (split-string (match-string 2) "-")))
5068 ((looking-at "\\([^/]+\\)/?")
5069 (setq group (match-string 1)))
5071 (error "Unknown news URL syntax"))))
5072 (list scheme server group message-id articles)))
5074 (defun gnus-button-handle-news (url)
5076 (destructuring-bind (scheme server group message-id articles)
5077 (gnus-parse-news-url url)
5081 (set-buffer gnus-summary-buffer)
5083 (let ((gnus-refer-article-method (list (list 'nntp server))))
5084 (gnus-summary-refer-article message-id))
5085 (gnus-summary-refer-article message-id))))
5087 (gnus-button-fetch-group url)))))
5089 (defun gnus-button-message-id (message-id)
5092 (set-buffer gnus-summary-buffer)
5093 (gnus-summary-refer-article message-id)))
5095 (defun gnus-button-fetch-group (address)
5096 "Fetch GROUP specified by ADDRESS."
5097 (if (not (string-match "[:/]" address))
5098 ;; This is just a simple group url.
5099 (gnus-group-read-ephemeral-group address gnus-select-method)
5100 (if (not (string-match "^\\([^:/]+\\)\\(:\\([^/]+\\)/\\)?\\(.*\\)$"
5102 (error "Can't parse %s" address)
5103 (gnus-group-read-ephemeral-group
5104 (match-string 4 address)
5105 `(nntp ,(match-string 1 address)
5106 (nntp-address ,(match-string 1 address))
5107 (nntp-port-number ,(if (match-end 3)
5108 (match-string 3 address)
5111 (defun gnus-url-parse-query-string (query &optional downcase)
5112 (let (retval pairs cur key val)
5113 (setq pairs (split-string query "&"))
5115 (setq cur (car pairs)
5117 (if (not (string-match "=" cur))
5119 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
5120 val (gnus-url-unhex-string (substring cur (match-end 0) nil)))
5122 (setq key (downcase key)))
5123 (setq cur (assoc key retval))
5125 (setcdr cur (cons val (cdr cur)))
5126 (setq retval (cons (list key val) retval)))))
5129 (defun gnus-url-unhex (x)
5136 (defun gnus-url-unhex-string (str &optional allow-newlines)
5137 "Remove %XXX embedded spaces, etc in a url.
5138 If optional second argument ALLOW-NEWLINES is non-nil, then allow the
5139 decoding of carriage returns and line feeds in the string, which is normally
5140 forbidden in URL encoding."
5141 (setq str (or str ""))
5143 (case-fold-search t))
5144 (while (string-match "%[0-9a-f][0-9a-f]" str)
5145 (let* ((start (match-beginning 0))
5146 (ch1 (gnus-url-unhex (elt str (+ start 1))))
5148 (gnus-url-unhex (elt str (+ start 2))))))
5150 tmp (substring str 0 start)
5153 (char-to-string code))
5154 ((or (= code ?\n) (= code ?\r))
5156 (t (char-to-string code))))
5157 str (substring str (match-end 0)))))
5158 (setq tmp (concat tmp str))
5161 (defun gnus-url-mailto (url)
5162 ;; Send mail to someone
5163 (when (string-match "mailto:/*\\(.*\\)" url)
5164 (setq url (substring url (match-beginning 1) nil)))
5165 (let (to args subject func)
5166 (if (string-match (regexp-quote "?") url)
5167 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
5168 args (gnus-url-parse-query-string
5169 (substring url (match-end 0) nil) t))
5170 (setq to (gnus-url-unhex-string url)))
5171 (setq args (cons (list "to" to) args)
5172 subject (cdr-safe (assoc "subject" args)))
5175 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
5178 (message-position-on-field (caar args)))
5179 (insert (mapconcat 'identity (cdar args) ", "))
5180 (setq args (cdr args)))
5183 (message-goto-subject))))
5185 (defun gnus-button-embedded-url (address)
5186 "Activate ADDRESS with `browse-url'."
5187 (browse-url (gnus-strip-whitespace address)))
5189 ;;; Next/prev buttons in the article buffer.
5191 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
5192 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
5194 (defvar gnus-prev-page-map nil)
5195 (unless gnus-prev-page-map
5196 (setq gnus-prev-page-map (make-sparse-keymap))
5197 (define-key gnus-prev-page-map gnus-mouse-2 'gnus-button-prev-page)
5198 (define-key gnus-prev-page-map "\r" 'gnus-button-prev-page))
5200 (defun gnus-insert-prev-page-button ()
5201 (let ((buffer-read-only nil))
5203 gnus-prev-page-line-format nil
5204 `(gnus-prev t local-map ,gnus-prev-page-map
5205 gnus-callback gnus-article-button-prev-page
5206 article-type annotation))))
5208 (defvar gnus-next-page-map nil)
5209 (unless gnus-next-page-map
5210 (setq gnus-next-page-map (make-keymap))
5211 (suppress-keymap gnus-prev-page-map)
5212 (define-key gnus-next-page-map gnus-mouse-2 'gnus-button-next-page)
5213 (define-key gnus-next-page-map "\r" 'gnus-button-next-page))
5215 (defun gnus-button-next-page ()
5216 "Go to the next page."
5218 (let ((win (selected-window)))
5219 (select-window (get-buffer-window gnus-article-buffer t))
5220 (gnus-article-next-page)
5221 (select-window win)))
5223 (defun gnus-button-prev-page ()
5224 "Go to the prev page."
5226 (let ((win (selected-window)))
5227 (select-window (get-buffer-window gnus-article-buffer t))
5228 (gnus-article-prev-page)
5229 (select-window win)))
5231 (defun gnus-insert-next-page-button ()
5232 (let ((buffer-read-only nil))
5233 (gnus-eval-format gnus-next-page-line-format nil
5235 t local-map ,gnus-next-page-map
5236 gnus-callback gnus-article-button-next-page
5237 article-type annotation))))
5239 (defun gnus-article-button-next-page (arg)
5240 "Go to the next page."
5242 (let ((win (selected-window)))
5243 (select-window (get-buffer-window gnus-article-buffer t))
5244 (gnus-article-next-page)
5245 (select-window win)))
5247 (defun gnus-article-button-prev-page (arg)
5248 "Go to the prev page."
5250 (let ((win (selected-window)))
5251 (select-window (get-buffer-window gnus-article-buffer t))
5252 (gnus-article-prev-page)
5253 (select-window win)))
5255 (defvar gnus-decode-header-methods
5256 '(mail-decode-encoded-word-region)
5257 "List of methods used to decode headers.
5259 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
5260 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
5261 (REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
5262 whose names match REGEXP.
5265 ((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
5266 mail-decode-encoded-word-region
5267 (\"chinese\" . rfc1843-decode-region))
5270 (defvar gnus-decode-header-methods-cache nil)
5272 (defun gnus-multi-decode-header (start end)
5273 "Apply the functions from `gnus-encoded-word-methods' that match."
5274 (unless (and gnus-decode-header-methods-cache
5275 (eq gnus-newsgroup-name
5276 (car gnus-decode-header-methods-cache)))
5277 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
5280 (nconc gnus-decode-header-methods-cache (list x))
5281 (if (and gnus-newsgroup-name
5282 (string-match (car x) gnus-newsgroup-name))
5283 (nconc gnus-decode-header-methods-cache
5285 gnus-decode-header-methods))
5286 (let ((xlist gnus-decode-header-methods-cache))
5289 (narrow-to-region start end)
5291 (funcall (pop xlist) (point-min) (point-max))))))
5294 ;;; Treatment top-level handling.
5297 (defun gnus-treat-article (condition &optional part-number total-parts type)
5298 (let ((length (- (point-max) (point-min)))
5299 (alist gnus-treatment-function-alist)
5300 (article-goto-body-goes-to-point-min-p t)
5304 (let ((list gnus-article-treat-types))
5306 (when (string-match (pop list) type)
5307 (throw 'found t)))))))
5308 (highlightp (gnus-visual-p 'article-highlight 'highlight))
5310 (gnus-run-hooks 'gnus-part-display-hook)
5311 (while (setq elem (pop alist))
5314 (if (gnus-buffer-live-p gnus-summary-buffer)
5315 (set-buffer gnus-summary-buffer))
5316 (symbol-value (car elem))))
5317 (when (and (or (consp val)
5319 (gnus-treat-predicate val)
5320 (or (not (get (car elem) 'highlight))
5323 (funcall (cadr elem)))))))
5325 ;; Dynamic variables.
5327 (defvar part-number)
5328 (defvar total-parts)
5333 (defun gnus-treat-predicate (val)
5338 (stringp (car val)))
5339 (apply 'gnus-or (mapcar `(lambda (s)
5340 (string-match s ,(or gnus-newsgroup-name "")))
5343 (let ((pred (pop val)))
5346 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
5348 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
5350 (not (gnus-treat-predicate (car val))))
5352 (equal (car val) type))
5354 (error "%S is not a valid predicate" pred)))))
5362 (eq part-number total-parts))
5366 (error "%S is not a valid value" val))))
5368 (defun gnus-article-encrypt-body (protocol &optional n)
5369 "Encrypt the article body."
5372 (or gnus-article-encrypt-protocol
5373 (completing-read "Encrypt protocol: "
5374 gnus-article-encrypt-protocol-alist
5376 current-prefix-arg))
5377 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
5379 (error (format "Can't find the encrypt protocol %s" protocol)))
5380 (if (equal gnus-newsgroup-name "nndraft:drafts")
5381 (error "Can't encrypt the article in group nndraft:drafts."))
5382 (if (equal gnus-newsgroup-name "nndraft:queue")
5383 (error "Don't encrypt the article in group nndraft:queue."))
5384 (gnus-summary-iterate n
5386 (set-buffer gnus-summary-buffer)
5387 (let ((mail-parse-charset gnus-newsgroup-charset)
5388 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5389 (summary-buffer gnus-summary-buffer)
5391 (gnus-set-global-variables)
5392 (when (gnus-group-read-only-p)
5393 (error "The current newsgroup does not support article encrypt"))
5394 (gnus-summary-show-article t)
5396 (or (mail-header-references gnus-current-headers) ""))
5397 (set-buffer gnus-article-buffer)
5398 (let* ((buffer-read-only nil)
5400 (mapcar (lambda (field)
5401 (and (save-restriction
5402 (message-narrow-to-head)
5403 (goto-char (point-min))
5404 (search-forward field nil t))
5406 (message-narrow-to-field)
5407 (buffer-substring (point-min) (point-max))
5408 (delete-region (point-min) (point-max))
5410 '("Content-Type:" "Content-Transfer-Encoding:"
5411 "Content-Disposition:"))))
5412 (message-narrow-to-head)
5413 (message-remove-header "MIME-Version")
5414 (goto-char (point-max))
5415 (setq point (point))
5416 (insert (apply 'concat headers))
5418 (narrow-to-region point (point-max))
5419 (let ((message-options message-options))
5420 (message-options-set 'message-sender user-mail-address)
5421 (message-options-set 'message-recipients user-mail-address)
5422 (message-options-set 'message-sign-encrypt 'not)
5424 (goto-char (point-min))
5425 (insert "MIME-Version: 1.0\n")
5427 (gnus-summary-edit-article-done
5428 references nil summary-buffer t))
5429 (when gnus-keep-backlog
5430 (gnus-backlog-remove-article
5431 (car gnus-article-current) (cdr gnus-article-current)))
5433 (when (get-buffer gnus-original-article-buffer)
5434 (set-buffer gnus-original-article-buffer)
5435 (setq gnus-original-article nil)))
5436 (when gnus-use-cache
5437 (gnus-cache-update-article
5438 (car gnus-article-current) (cdr gnus-article-current))))))))
5440 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
5441 "The following specs can be used:
5442 %t The security MIME type
5445 %D Details if button is pressed")
5447 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
5448 "The following specs can be used:
5449 %t The security MIME type
5452 %D Details if button is pressed")
5454 (defvar gnus-mime-security-button-line-format-alist
5455 '((?t gnus-tmp-type ?s)
5456 (?i gnus-tmp-info ?s)
5457 (?d gnus-tmp-details ?s)
5458 (?D gnus-tmp-pressed-details ?s)))
5460 (defvar gnus-mime-security-button-map
5461 (let ((map (make-sparse-keymap)))
5462 (unless (>= (string-to-number emacs-version) 21)
5463 (set-keymap-parent map gnus-article-mode-map))
5464 (define-key map gnus-mouse-2 'gnus-article-push-button)
5465 (define-key map "\r" 'gnus-article-press-button)
5468 (defvar gnus-mime-security-details-buffer nil)
5470 (defvar gnus-mime-security-button-pressed nil)
5472 (defvar gnus-mime-security-show-details-inline t
5473 "If non-nil, show details in the article buffer.")
5475 (defun gnus-mime-security-verify-or-decrypt (handle)
5476 (mm-remove-parts (cdr handle))
5477 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
5480 (delete-region (car region) (cdr region))
5481 (set-marker (car region) nil)
5482 (set-marker (cdr region) nil)))
5483 (with-current-buffer (mm-handle-multipart-original-buffer handle)
5484 (let* ((mm-verify-option 'known)
5485 (mm-decrypt-option 'known)
5486 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
5487 (unless (eq nparts (cdr handle))
5488 (mm-destroy-parts (cdr handle))
5489 (setcdr handle nparts))))
5490 (let ((point (point))
5492 (gnus-mime-display-security handle)
5495 (defun gnus-mime-security-show-details (handle)
5496 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
5498 (if gnus-mime-security-show-details-inline
5499 (let ((gnus-mime-security-button-pressed t)
5500 (gnus-mime-security-button-line-format
5501 (get-text-property (point) 'gnus-line-format))
5504 (while (eq (get-text-property (point) 'gnus-line-format)
5505 gnus-mime-security-button-line-format)
5508 (delete-region (point)
5509 (or (text-property-not-all
5512 gnus-mime-security-button-line-format)
5514 (gnus-insert-mime-security-button handle))
5515 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
5516 (with-current-buffer gnus-mime-security-details-buffer
5519 (setq gnus-mime-security-details-buffer
5520 (gnus-get-buffer-create "*MIME Security Details*")))
5521 (with-current-buffer gnus-mime-security-details-buffer
5523 (goto-char (point-min)))
5524 (pop-to-buffer gnus-mime-security-details-buffer))
5525 (gnus-message 5 "No details."))))
5527 (defun gnus-mime-security-press-button (handle)
5528 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
5529 (gnus-mime-security-show-details handle)
5530 (gnus-mime-security-verify-or-decrypt handle)))
5532 (defun gnus-insert-mime-security-button (handle &optional displayed)
5533 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
5536 (or (nth 2 (assoc protocol mm-verify-function-alist))
5537 (nth 2 (assoc protocol mm-decrypt-function-alist))
5539 (if (equal (car handle) "multipart/signed")
5540 " Signed" " Encrypted")
5543 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
5546 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
5547 gnus-tmp-pressed-details
5549 (setq gnus-tmp-details
5550 (if gnus-tmp-details
5551 (concat "\n" gnus-tmp-details) ""))
5552 (setq gnus-tmp-pressed-details
5553 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
5558 gnus-mime-security-button-line-format
5559 gnus-mime-security-button-line-format-alist
5560 `(keymap ,gnus-mime-security-button-map
5561 ,@(if (>= (string-to-number emacs-version) 21)
5562 nil ;; XEmacs doesn't care
5563 (list 'local-map gnus-mime-security-button-map))
5564 gnus-callback gnus-mime-security-press-button
5565 gnus-line-format ,gnus-mime-security-button-line-format
5566 article-type annotation
5569 (widget-convert-button
5572 :action 'gnus-widget-press-button
5573 :button-keymap gnus-mime-security-button-map
5575 (lambda (widget/window &optional overlay pos)
5576 ;; Needed to properly clear the message due to a bug in
5577 ;; wid-edit (XEmacs only).
5578 (if (boundp 'help-echo-owns-message)
5579 (setq help-echo-owns-message t))
5582 (aref gnus-mouse-2 0))))))
5584 (defun gnus-mime-display-security (handle)
5586 (narrow-to-region (point) (point))
5587 (gnus-insert-mime-security-button handle)
5588 (gnus-mime-display-mixed (cdr handle))
5591 (let ((gnus-mime-security-button-line-format
5592 gnus-mime-security-button-end-line-format))
5593 (gnus-insert-mime-security-button handle))
5594 (mm-set-handle-multipart-parameter
5596 (cons (set-marker (make-marker) (point-min))
5597 (set-marker (make-marker) (point-max))))))
5603 (run-hooks 'gnus-art-load-hook)
5605 ;;; gnus-art.el ends here