1 ;;; gnus-art.el --- article mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval-when-compile (require 'cl))
43 (autoload 'gnus-msg-mail "gnus-msg" nil t)
44 (autoload 'gnus-button-mailto "gnus-msg")
45 (autoload 'gnus-button-reply "gnus-msg" nil t)
47 (defgroup gnus-article nil
49 :link '(custom-manual "(gnus)The Article Buffer")
52 (defgroup gnus-article-treat nil
53 "Treating article parts."
54 :link '(custom-manual "(gnus)Article Hiding")
57 (defgroup gnus-article-hiding nil
58 "Hiding article parts."
59 :link '(custom-manual "(gnus)Article Hiding")
62 (defgroup gnus-article-highlight nil
63 "Article highlighting."
64 :link '(custom-manual "(gnus)Article Highlighting")
68 (defgroup gnus-article-signature nil
70 :link '(custom-manual "(gnus)Article Signature")
73 (defgroup gnus-article-headers nil
75 :link '(custom-manual "(gnus)Hiding Headers")
78 (defgroup gnus-article-washing nil
79 "Special commands on articles."
80 :link '(custom-manual "(gnus)Article Washing")
83 (defgroup gnus-article-emphasis nil
84 "Fontisizing articles."
85 :link '(custom-manual "(gnus)Article Fontisizing")
88 (defgroup gnus-article-saving nil
90 :link '(custom-manual "(gnus)Saving Articles")
93 (defgroup gnus-article-mime nil
94 "Worshiping the MIME wonder."
95 :link '(custom-manual "(gnus)Using MIME")
98 (defgroup gnus-article-buttons nil
99 "Pushable buttons in the article buffer."
100 :link '(custom-manual "(gnus)Article Buttons")
101 :group 'gnus-article)
103 (defgroup gnus-article-various nil
104 "Other article options."
105 :link '(custom-manual "(gnus)Misc Article")
106 :group 'gnus-article)
108 (defcustom gnus-ignored-headers
109 '("^Path:" "^Expires:" "^Date-Received:" "^References:" "^Xref:" "^Lines:"
110 "^Relay-Version:" "^Message-ID:" "^Approved:" "^Sender:" "^Received:"
111 "^X-UIDL:" "^MIME-Version:" "^Return-Path:" "^In-Reply-To:"
112 "^Content-Type:" "^Content-Transfer-Encoding:" "^X-WebTV-Signature:"
113 "^X-MimeOLE:" "^X-MSMail-Priority:" "^X-Priority:" "^X-Loop:"
114 "^X-Authentication-Warning:" "^X-MIME-Autoconverted:" "^X-Face"
115 "^X-Attribution:" "^X-Originating-IP:" "^Delivered-To:"
116 "^NNTP-[-A-Za-z]+:" "^Distribution:" "^X-no-archive:" "^X-Trace:"
117 "^X-Complaints-To:" "^X-NNTP-Posting-Host:" "^X-Orig.*:"
118 "^Abuse-Reports-To:" "^Cache-Post-Path:" "^X-Article-Creation-Date:"
119 "^X-Poster:" "^X-Mail2News-Path:" "^X-Server-Date:" "^X-Cache:"
120 "^Originator:" "^X-Problems-To:" "^X-Auth-User:" "^X-Post-Time:"
121 "^X-Admin:" "^X-UID:" "^Resent-[-A-Za-z]+:" "^X-Mailing-List:"
122 "^Precedence:" "^Original-[-A-Za-z]+:" "^X-filename:" "^X-Orcpt:"
123 "^Old-Received:" "^X-Pgp" "^X-Auth:" "^X-From-Line:"
124 "^X-Gnus-Article-Number:" "^X-Majordomo:" "^X-Url:" "^X-Sender:"
125 "^MBOX-Line" "^Priority:" "^X400-[-A-Za-z]+:"
126 "^Status:" "^X-Gnus-Mail-Source:" "^Cancel-Lock:"
127 "^X-FTN" "^X-EXP32-SerialNo:" "^Encoding:" "^Importance:"
128 "^Autoforwarded:" "^Original-Encoded-Information-Types:" "^X-Ya-Pop3:"
129 "^X-Face-Version:" "^X-Vms-To:" "^X-ML-NAME:" "^X-ML-COUNT:"
130 "^Mailing-List:" "^X-finfo:" "^X-md5sum:" "^X-md5sum-Origin:"
131 "^X-Sun-Charset:" "^X-Accept-Language:" "^X-Envelope-Sender:"
132 "^List-[A-Za-z]+:" "^X-Listprocessor-Version:"
133 "^X-Received:" "^X-Distribute:" "^X-Sequence:" "^X-Juno-Line-Breaks:"
134 "^X-Notes-Item:" "^X-MS-TNEF-Correlator:" "^x-uunet-gateway:"
135 "^X-Received:" "^Content-length:" "X-precedence:"
136 "^X-Authenticated-User:" "^X-Comment" "^X-Report:" "^X-Abuse-Info:"
137 "^X-HTTP-Proxy:" "^X-Mydeja-Info:" "^X-Copyright" "^X-No-Markup:"
138 "^X-Abuse-Info:" "^X-From_:" "^X-Accept-Language:" "^Errors-To:"
139 "^X-BeenThere:" "^X-Mailman-Version:" "^List-Help:" "^List-Post:"
140 "^List-Subscribe:" "^List-Id:" "^List-Unsubscribe:" "^List-Archive:"
141 "^X-Content-length:" "^X-Posting-Agent:" "^Original-Received:"
142 "^X-Request-PGP:" "^X-Fingerprint:" "^X-WRIEnvto:" "^X-WRIEnvfrom:"
143 "^X-Virus-Scanned:" "^X-Delivery-Agent:" "^Posted-Date:" "^X-Gateway:"
144 "^X-Local-Origin:" "^X-Local-Destination:" "^X-UserInfo1:"
146 "*All headers that start with this regexp will be hidden.
147 This variable can also be a list of regexps of headers to be ignored.
148 If `gnus-visible-headers' is non-nil, this variable will be ignored."
149 :type '(choice :custom-show nil
152 :group 'gnus-article-hiding)
154 (defcustom gnus-visible-headers
155 "^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:"
156 "*All headers that do not match this regexp will be hidden.
157 This variable can also be a list of regexp of headers to remain visible.
158 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
159 :type '(repeat :value-to-internal (lambda (widget value)
160 (custom-split-regexp-maybe value))
161 :match (lambda (widget value)
163 (widget-editable-list-match widget value)))
165 :group 'gnus-article-hiding)
167 (defcustom gnus-sorted-header-list
168 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
169 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
170 "*This variable is a list of regular expressions.
171 If it is non-nil, headers that match the regular expressions will
172 be placed first in the article buffer in the sequence specified by
174 :type '(repeat regexp)
175 :group 'gnus-article-hiding)
177 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
178 "Headers that are only to be displayed if they have interesting data.
179 Possible values in this list are:
181 'empty Headers with no content.
182 'newsgroups Newsgroup identical to Gnus group.
183 'to-address To identical to To-address.
184 'followup-to Followup-to identical to Newsgroups.
185 'reply-to Reply-to identical to From.
186 'date Date less than four days old.
187 'long-to To and/or Cc longer than 1024 characters.
188 'many-to Multiple To and/or Cc."
189 :type '(set (const :tag "Headers with no content." empty)
190 (const :tag "Newsgroups identical to Gnus group." newsgroups)
191 (const :tag "To identical to To-address." to-address)
192 (const :tag "Followup-to identical to Newsgroups." followup-to)
193 (const :tag "Reply-to identical to From." reply-to)
194 (const :tag "Date less than four days old." date)
195 (const :tag "To and/or Cc longer than 1024 characters." long-to)
196 (const :tag "Multiple To and/or Cc headers." many-to))
197 :group 'gnus-article-hiding)
199 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
200 "Regexp matching signature separator.
201 This can also be a list of regexps. In that case, it will be checked
202 from head to tail looking for a separator. Searches will be done from
203 the end of the buffer."
204 :type '(repeat string)
205 :group 'gnus-article-signature)
207 (defcustom gnus-signature-limit nil
208 "Provide a limit to what is considered a signature.
209 If it is a number, no signature may not be longer (in characters) than
210 that number. If it is a floating point number, no signature may be
211 longer (in lines) than that number. If it is a function, the function
212 will be called without any parameters, and if it returns nil, there is
213 no signature in the buffer. If it is a string, it will be used as a
214 regexp. If it matches, the text in question is not a signature."
215 :type '(choice (integer :value 200)
217 (function :value fun)
218 (regexp :value ".*"))
219 :group 'gnus-article-signature)
221 (defcustom gnus-hidden-properties '(invisible t intangible t)
222 "Property list to use for hiding text."
224 :group 'gnus-article-hiding)
226 ;; Fixme: This isn't the right thing for mixed graphical and and
227 ;; non-graphical frames in a session.
228 (defcustom gnus-article-x-face-command
229 (if (featurep 'xemacs)
230 (if (or (gnus-image-type-available-p 'xface)
231 (gnus-image-type-available-p 'pbm))
232 'gnus-display-x-face-in-from
233 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
234 (if (gnus-image-type-available-p 'pbm)
235 'gnus-display-x-face-in-from
236 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
238 "*String or function to be executed to display an X-Face header.
239 If it is a string, the command will be executed in a sub-shell
240 asynchronously. The compressed face will be piped to this command."
241 :type `(choice string
242 (function-item gnus-display-x-face-in-from)
246 :group 'gnus-article-washing)
248 (defcustom gnus-article-x-face-too-ugly nil
249 "Regexp matching posters whose face shouldn't be shown automatically."
250 :type '(choice regexp (const nil))
251 :group 'gnus-article-washing)
253 (defcustom gnus-article-banner-alist nil
254 "Banner alist for stripping.
256 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
258 :type '(repeat (cons symbol regexp))
259 :group 'gnus-article-washing)
261 (gnus-define-group-parameter
264 "Alist of regexps (to match group names) and banner."
265 :variable-group gnus-article-washing
267 '(choice :tag "Banner"
269 (const :tag "Remove signature" signature)
270 (symbol :tag "Item in `gnus-article-banner-alist'" none)
272 (const :tag "None" nil))
274 "If non-nil, specify how to remove `banners' from articles.
276 Symbol `signature' means to remove signatures delimited by
277 `gnus-signature-separator'. Any other symbol is used to look up a
278 regular expression to match the banner in `gnus-article-banner-alist'.
279 A string is used as a regular expression to match the banner
282 (defcustom gnus-article-address-banner-alist nil
283 "Alist of mail addresses and banners.
284 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
285 to match a mail address in the From: header, BANNER is one of a symbol
286 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
287 If ADDRESS matches author's mail address, it will remove things like
288 advertisements. For example:
290 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
294 (regexp :tag "Address")
295 (choice :tag "Banner" :value nil
296 (const :tag "Remove signature" signature)
297 (symbol :tag "Item in `gnus-article-banner-alist'" none)
299 (const :tag "None" nil))))
300 :group 'gnus-article-washing)
302 (defcustom gnus-emphasis-alist
304 "\\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)")
309 ("_/" "/_" underline-italic)
310 ("_\\*" "\\*_" underline-bold)
311 ("\\*/" "/\\*" bold-italic)
312 ("_\\*/" "/\\*_" underline-bold-italic))))
316 (format format (car spec) (cadr spec))
317 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
319 ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
320 2 3 gnus-emphasis-strikethru)
321 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
322 2 3 gnus-emphasis-underline)))
323 "*Alist that says how to fontify certain phrases.
324 Each item looks like this:
326 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
328 The first element is a regular expression to be matched. The second
329 is a number that says what regular expression grouping used to find
330 the entire emphasized word. The third is a number that says what
331 regexp grouping should be displayed and highlighted. The fourth
332 is the face used for highlighting."
333 :type '(repeat (list :value ("" 0 0 default)
335 (integer :tag "Match group")
336 (integer :tag "Emphasize group")
338 :group 'gnus-article-emphasis)
340 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
341 "A regexp to describe whitespace which should not be emphasized.
342 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
343 The former avoids underlining of leading and trailing whitespace,
344 and the latter avoids underlining any whitespace at all."
346 :group 'gnus-article-emphasis
349 (defface gnus-emphasis-bold '((t (:bold t)))
350 "Face used for displaying strong emphasized text (*word*)."
351 :group 'gnus-article-emphasis)
353 (defface gnus-emphasis-italic '((t (:italic t)))
354 "Face used for displaying italic emphasized text (/word/)."
355 :group 'gnus-article-emphasis)
357 (defface gnus-emphasis-underline '((t (:underline t)))
358 "Face used for displaying underlined emphasized text (_word_)."
359 :group 'gnus-article-emphasis)
361 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
362 "Face used for displaying underlined bold emphasized text (_*word*_)."
363 :group 'gnus-article-emphasis)
365 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
366 "Face used for displaying underlined italic emphasized text (_/word/_)."
367 :group 'gnus-article-emphasis)
369 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
370 "Face used for displaying bold italic emphasized text (/*word*/)."
371 :group 'gnus-article-emphasis)
373 (defface gnus-emphasis-underline-bold-italic
374 '((t (:bold t :italic t :underline t)))
375 "Face used for displaying underlined bold italic emphasized text.
376 Example: (_/*word*/_)."
377 :group 'gnus-article-emphasis)
379 (defface gnus-emphasis-strikethru '((t (:strikethru t)))
380 "Face used for displaying strike-through text (-word-)."
381 :group 'gnus-article-emphasis)
383 (defface gnus-emphasis-highlight-words
384 '((t (:background "black" :foreground "yellow")))
385 "Face used for displaying highlighted words."
386 :group 'gnus-article-emphasis)
388 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
389 "Format for display of Date headers in article bodies.
390 See `format-time-string' for the possible values.
392 The variable can also be function, which should return a complete Date
393 header. The function is called with one argument, the time, which can
394 be fed to `format-time-string'."
395 :type '(choice string symbol)
396 :link '(custom-manual "(gnus)Article Date")
397 :group 'gnus-article-washing)
400 (autoload 'mail-extract-address-components "mail-extr"))
402 (defcustom gnus-save-all-headers t
403 "*If non-nil, don't remove any headers before saving."
404 :group 'gnus-article-saving
407 (defcustom gnus-prompt-before-saving 'always
408 "*This variable says how much prompting is to be done when saving articles.
409 If it is nil, no prompting will be done, and the articles will be
410 saved to the default files. If this variable is `always', each and
411 every article that is saved will be preceded by a prompt, even when
412 saving large batches of articles. If this variable is neither nil not
413 `always', there the user will be prompted once for a file name for
414 each invocation of the saving commands."
415 :group 'gnus-article-saving
416 :type '(choice (item always)
417 (item :tag "never" nil)
418 (sexp :tag "once" :format "%t\n" :value t)))
420 (defcustom gnus-saved-headers gnus-visible-headers
421 "Headers to keep if `gnus-save-all-headers' is nil.
422 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
423 If that variable is nil, however, all headers that match this regexp
424 will be kept while the rest will be deleted before saving."
425 :group 'gnus-article-saving
428 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
429 "A function to save articles in your favourite format.
430 The function must be interactively callable (in other words, it must
431 be an Emacs command).
433 Gnus provides the following functions:
435 * gnus-summary-save-in-rmail (Rmail format)
436 * gnus-summary-save-in-mail (Unix mail format)
437 * gnus-summary-save-in-folder (MH folder)
438 * gnus-summary-save-in-file (article format)
439 * gnus-summary-save-body-in-file (article body)
440 * gnus-summary-save-in-vm (use VM's folder format)
441 * gnus-summary-write-to-file (article format -- overwrite)."
442 :group 'gnus-article-saving
443 :type '(radio (function-item gnus-summary-save-in-rmail)
444 (function-item gnus-summary-save-in-mail)
445 (function-item gnus-summary-save-in-folder)
446 (function-item gnus-summary-save-in-file)
447 (function-item gnus-summary-save-body-in-file)
448 (function-item gnus-summary-save-in-vm)
449 (function-item gnus-summary-write-to-file)))
451 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
452 "A function generating a file name to save articles in Rmail format.
453 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
454 :group 'gnus-article-saving
457 (defcustom gnus-mail-save-name 'gnus-plain-save-name
458 "A function generating a file name to save articles in Unix mail format.
459 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
460 :group 'gnus-article-saving
463 (defcustom gnus-folder-save-name 'gnus-folder-save-name
464 "A function generating a file name to save articles in MH folder.
465 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
466 :group 'gnus-article-saving
469 (defcustom gnus-file-save-name 'gnus-numeric-save-name
470 "A function generating a file name to save articles in article format.
471 The function is called with NEWSGROUP, HEADERS, and optional
473 :group 'gnus-article-saving
476 (defcustom gnus-split-methods
477 '((gnus-article-archive-name)
478 (gnus-article-nndoc-name))
479 "*Variable used to suggest where articles are to be saved.
480 For instance, if you would like to save articles related to Gnus in
481 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
482 you could set this variable to something like:
484 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
485 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
487 This variable is an alist where the where the key is the match and the
488 value is a list of possible files to save in if the match is non-nil.
490 If the match is a string, it is used as a regexp match on the
491 article. If the match is a symbol, that symbol will be funcalled
492 from the buffer of the article to be saved with the newsgroup as the
493 parameter. If it is a list, it will be evaled in the same buffer.
495 If this form or function returns a string, this string will be used as
496 a possible file name; and if it returns a non-nil list, that list will
497 be used as possible file names."
498 :group 'gnus-article-saving
499 :type '(repeat (choice (list :value (fun) function)
500 (cons :value ("" "") regexp (repeat string))
503 (defcustom gnus-page-delimiter "^\^L"
504 "*Regexp describing what to use as article page delimiters.
505 The default value is \"^\^L\", which is a form linefeed at the
506 beginning of a line."
508 :group 'gnus-article-various)
510 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
511 "*The format specification for the article mode line.
512 See `gnus-summary-mode-line-format' for a closer description.
514 The following additional specs are available:
516 %w The article washing status.
517 %m The number of MIME parts in the article."
519 :group 'gnus-article-various)
521 (defcustom gnus-article-mode-hook nil
522 "*A hook for Gnus article mode."
524 :group 'gnus-article-various)
526 (when (featurep 'xemacs)
527 ;; Extracted from gnus-xmas-define in order to preserve user settings
528 (when (fboundp 'turn-off-scroll-in-place)
529 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
530 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
531 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
533 (defcustom gnus-article-menu-hook nil
534 "*Hook run after the creation of the article mode menu."
536 :group 'gnus-article-various)
538 (defcustom gnus-article-prepare-hook nil
539 "*A hook called after an article has been prepared in the article buffer."
541 :group 'gnus-article-various)
543 (defcustom gnus-article-hide-pgp-hook nil
544 "*A hook called after successfully hiding a PGP signature."
546 :group 'gnus-article-various)
548 (defcustom gnus-article-button-face 'bold
549 "Face used for highlighting buttons in the article buffer.
551 An article button is a piece of text that you can activate by pressing
552 `RET' or `mouse-2' above it."
554 :group 'gnus-article-buttons)
556 (defcustom gnus-article-mouse-face 'highlight
557 "Face used for mouse highlighting in the article buffer.
559 Article buttons will be displayed in this face when the cursor is
562 :group 'gnus-article-buttons)
564 (defcustom gnus-signature-face 'gnus-signature-face
565 "Face used for highlighting a signature in the article buffer.
566 Obsolete; use the face `gnus-signature-face' for customizations instead."
568 :group 'gnus-article-highlight
569 :group 'gnus-article-signature)
571 (defface gnus-signature-face
574 "Face used for highlighting a signature in the article buffer."
575 :group 'gnus-article-highlight
576 :group 'gnus-article-signature)
578 (defface gnus-header-from-face
581 (:foreground "spring green"))
584 (:foreground "red3"))
587 "Face used for displaying from headers."
588 :group 'gnus-article-headers
589 :group 'gnus-article-highlight)
591 (defface gnus-header-subject-face
594 (:foreground "SeaGreen3"))
597 (:foreground "red4"))
599 (:bold t :italic t)))
600 "Face used for displaying subject headers."
601 :group 'gnus-article-headers
602 :group 'gnus-article-highlight)
604 (defface gnus-header-newsgroups-face
607 (:foreground "yellow" :italic t))
610 (:foreground "MidnightBlue" :italic t))
613 "Face used for displaying newsgroups headers."
614 :group 'gnus-article-headers
615 :group 'gnus-article-highlight)
617 (defface gnus-header-name-face
620 (:foreground "SeaGreen"))
623 (:foreground "maroon"))
626 "Face used for displaying header names."
627 :group 'gnus-article-headers
628 :group 'gnus-article-highlight)
630 (defface gnus-header-content-face
633 (:foreground "forest green" :italic t))
636 (:foreground "indianred4" :italic t))
638 (:italic t))) "Face used for displaying header content."
639 :group 'gnus-article-headers
640 :group 'gnus-article-highlight)
642 (defcustom gnus-header-face-alist
643 '(("From" nil gnus-header-from-face)
644 ("Subject" nil gnus-header-subject-face)
645 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
646 ("" gnus-header-name-face gnus-header-content-face))
647 "*Controls highlighting of article header.
649 An alist of the form (HEADER NAME CONTENT).
651 HEADER is a regular expression which should match the name of an
652 header header and NAME and CONTENT are either face names or nil.
654 The name of each header field will be displayed using the face
655 specified by the first element in the list where HEADER match the
656 header name and NAME is non-nil. Similarly, the content will be
657 displayed by the first non-nil matching CONTENT face."
658 :group 'gnus-article-headers
659 :group 'gnus-article-highlight
660 :type '(repeat (list (regexp :tag "Header")
662 (item :tag "skip" nil)
663 (face :value default))
664 (choice :tag "Content"
665 (item :tag "skip" nil)
666 (face :value default)))))
668 (defcustom gnus-article-decode-hook
669 '(article-decode-charset article-decode-encoded-words
670 article-decode-group-name)
671 "*Hook run to decode charsets in articles."
672 :group 'gnus-article-headers
675 (defcustom gnus-display-mime-function 'gnus-display-mime
676 "Function to display MIME articles."
677 :group 'gnus-article-mime
680 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
681 "Function used to decode headers.")
683 (defvar gnus-article-dumbquotes-map
698 ("\230" "-") ; This might not be correct.
703 "Table for MS-to-Latin1 translation.")
705 (defcustom gnus-ignored-mime-types nil
706 "List of MIME types that should be ignored by Gnus."
708 :group 'gnus-article-mime
709 :type '(repeat regexp))
711 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
712 "List of MIME types that should not be given buttons when rendered inline.
713 See also `gnus-buttonized-mime-types' which may override this variable."
715 :group 'gnus-article-mime
716 :type '(repeat regexp))
718 (defcustom gnus-buttonized-mime-types nil
719 "List of MIME types that should be given buttons when rendered inline.
720 If set, this variable overrides `gnus-unbuttonized-mime-types'.
721 To see e.g. security buttons you could set this to
722 `(\"multipart/signed\")'."
724 :group 'gnus-article-mime
725 :type '(repeat regexp))
727 (defcustom gnus-body-boundary-delimiter "_"
728 "String used to delimit header and body.
729 This variable is used by `gnus-article-treat-body-boundary' which can
730 be controlled by `gnus-treat-body-boundary'."
731 :group 'gnus-article-various
732 :type '(choice (item :tag "None" :value nil)
735 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces")
736 "Defines the location of the faces database.
737 For information on obtaining this database of pretty pictures, please
738 see http://www.cs.indiana.edu/picons/ftp/index.html"
739 :type '(repeat directory)
740 :link '(url-link :tag "download"
741 "http://www.cs.indiana.edu/picons/ftp/index.html")
742 :link '(custom-manual "(gnus)Picons")
745 (defun gnus-picons-installed-p ()
746 "Say whether picons are installed on your machine."
747 (let ((installed nil))
748 (dolist (database gnus-picon-databases)
749 (when (file-exists-p database)
753 (defcustom gnus-article-mime-part-function nil
754 "Function called with a MIME handle as the argument.
755 This is meant for people who want to do something automatic based
756 on parts -- for instance, adding Vcard info to a database."
757 :group 'gnus-article-mime
760 (defcustom gnus-mime-multipart-functions nil
761 "An alist of MIME types to functions to display them."
763 :group 'gnus-article-mime
766 (defcustom gnus-article-date-lapsed-new-header nil
767 "Whether the X-Sent and Date headers can coexist.
768 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
769 either replace the old \"Date:\" header (if this variable is nil), or
770 be added below it (otherwise)."
772 :group 'gnus-article-headers
775 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
776 "Function called with a MIME handle as the argument.
777 This is meant for people who want to view first matched part.
778 For `undisplayed-alternative' (default), the first undisplayed
779 part or alternative part is used. For `undisplayed', the first
780 undisplayed part is used. For a function, the first part which
781 the function return `t' is used. For `nil', the first part is
784 :group 'gnus-article-mime
786 (item :tag "first" :value nil)
787 (item :tag "undisplayed" :value undisplayed)
788 (item :tag "undisplayed or alternative"
789 :value undisplayed-alternative)
792 (defcustom gnus-mime-action-alist
793 '(("save to file" . gnus-mime-save-part)
794 ("save and strip" . gnus-mime-save-part-and-strip)
795 ("display as text" . gnus-mime-inline-part)
796 ("view the part" . gnus-mime-view-part)
797 ("pipe to command" . gnus-mime-pipe-part)
798 ("toggle display" . gnus-article-press-button)
799 ("toggle display" . gnus-article-view-part-as-charset)
800 ("view as type" . gnus-mime-view-part-as-type)
801 ("view internally" . gnus-mime-view-part-internally)
802 ("view externally" . gnus-mime-view-part-externally))
803 "An alist of actions that run on the MIME attachment."
804 :group 'gnus-article-mime
805 :type '(repeat (cons (string :tag "name")
809 ;;; The treatment variables
812 (defvar gnus-part-display-hook nil
813 "Hook called on parts that are to receive treatment.")
815 (defvar gnus-article-treat-custom
816 '(choice (const :tag "Off" nil)
818 (const :tag "Header" head)
819 (const :tag "Last" last)
820 (integer :tag "Less")
821 (repeat :tag "Groups" regexp)
822 (sexp :tag "Predicate")))
824 (defvar gnus-article-treat-head-custom
825 '(choice (const :tag "Off" nil)
826 (const :tag "Header" head)))
828 (defvar gnus-article-treat-types '("text/plain")
831 (defvar gnus-inhibit-treatment nil
832 "Whether to inhibit treatment.")
834 (defcustom gnus-treat-highlight-signature '(or last (typep "text/x-vcard"))
835 "Highlight the signature.
836 Valid values are nil, t, `head', `last', an integer or a predicate.
837 See Info node `(gnus)Customizing Articles'."
838 :group 'gnus-article-treat
839 :type gnus-article-treat-custom)
840 (put 'gnus-treat-highlight-signature 'highlight t)
842 (defcustom gnus-treat-buttonize 100000
844 Valid values are nil, t, `head', `last', an integer or a predicate.
845 See Info node `(gnus)Customizing Articles'."
846 :group 'gnus-article-treat
847 :type gnus-article-treat-custom)
848 (put 'gnus-treat-buttonize 'highlight t)
850 (defcustom gnus-treat-buttonize-head 'head
851 "Add buttons to the head.
852 Valid values are nil, t, `head', `last', an integer or a predicate.
853 See Info node `(gnus)Customizing Articles' for details."
854 :group 'gnus-article-treat
855 :type gnus-article-treat-head-custom)
856 (put 'gnus-treat-buttonize-head 'highlight t)
858 (defcustom gnus-treat-emphasize
859 (and (or window-system
861 (>= (string-to-number emacs-version) 21))
864 Valid values are nil, t, `head', `last', an integer or a predicate.
865 See Info node `(gnus)Customizing Articles' for details."
866 :group 'gnus-article-treat
867 :type gnus-article-treat-custom)
868 (put 'gnus-treat-emphasize 'highlight t)
870 (defcustom gnus-treat-strip-cr nil
871 "Remove carriage returns.
872 Valid values are nil, t, `head', `last', an integer or a predicate.
873 See Info node `(gnus)Customizing Articles' for details."
874 :group 'gnus-article-treat
875 :type gnus-article-treat-custom)
877 (defcustom gnus-treat-unsplit-urls nil
878 "Remove newlines from within URLs.
879 Valid values are nil, t, `head', `last', an integer or a predicate.
880 See Info node `(gnus)Customizing Articles' for details."
881 :group 'gnus-article-treat
882 :type gnus-article-treat-custom)
884 (defcustom gnus-treat-leading-whitespace nil
885 "Remove leading whitespace in headers.
886 Valid values are nil, t, `head', `last', an integer or a predicate.
887 See Info node `(gnus)Customizing Articles' for details."
888 :group 'gnus-article-treat
889 :type gnus-article-treat-custom)
891 (defcustom gnus-treat-hide-headers 'head
893 Valid values are nil, t, `head', `last', an integer or a predicate.
894 See Info node `(gnus)Customizing Articles' for details."
895 :group 'gnus-article-treat
896 :type gnus-article-treat-head-custom)
898 (defcustom gnus-treat-hide-boring-headers nil
899 "Hide boring headers.
900 Valid values are nil, t, `head', `last', an integer or a predicate.
901 See Info node `(gnus)Customizing Articles' for details."
902 :group 'gnus-article-treat
903 :type gnus-article-treat-head-custom)
905 (defcustom gnus-treat-hide-signature nil
907 Valid values are nil, t, `head', `last', an integer or a predicate.
908 See Info node `(gnus)Customizing Articles' for details."
909 :group 'gnus-article-treat
910 :type gnus-article-treat-custom)
912 (defcustom gnus-treat-fill-article nil
914 Valid values are nil, t, `head', `last', an integer or a predicate.
915 See Info node `(gnus)Customizing Articles' for details."
916 :group 'gnus-article-treat
917 :type gnus-article-treat-custom)
919 (defcustom gnus-treat-hide-citation nil
921 Valid values are nil, t, `head', `last', an integer or a predicate.
922 See Info node `(gnus)Customizing Articles' for details."
923 :group 'gnus-article-treat
924 :type gnus-article-treat-custom)
926 (defcustom gnus-treat-hide-citation-maybe nil
928 Valid values are nil, t, `head', `last', an integer or a predicate.
929 See Info node `(gnus)Customizing Articles' for details."
930 :group 'gnus-article-treat
931 :type gnus-article-treat-custom)
933 (defcustom gnus-treat-strip-list-identifiers 'head
934 "Strip list identifiers from `gnus-list-identifiers`.
935 Valid values are nil, t, `head', `last', an integer or a predicate.
936 See Info node `(gnus)Customizing Articles' for details."
938 :group 'gnus-article-treat
939 :type gnus-article-treat-custom)
941 (defcustom gnus-treat-strip-pgp t
942 "Strip PGP signatures.
943 Valid values are nil, t, `head', `last', an integer or a predicate.
944 See Info node `(gnus)Customizing Articles' for details."
945 :group 'gnus-article-treat
946 :type gnus-article-treat-custom)
948 (defcustom gnus-treat-strip-pem nil
949 "Strip PEM signatures.
950 Valid values are nil, t, `head', `last', an integer or a predicate.
951 See Info node `(gnus)Customizing Articles' for details."
952 :group 'gnus-article-treat
953 :type gnus-article-treat-custom)
955 (defcustom gnus-treat-strip-banner t
956 "Strip banners from articles.
957 The banner to be stripped is specified in the `banner' group parameter.
958 Valid values are nil, t, `head', `last', an integer or a predicate.
959 See Info node `(gnus)Customizing Articles' for details."
960 :group 'gnus-article-treat
961 :type gnus-article-treat-custom)
963 (defcustom gnus-treat-highlight-headers 'head
964 "Highlight the headers.
965 Valid values are nil, t, `head', `last', an integer or a predicate.
966 See Info node `(gnus)Customizing Articles' for details."
967 :group 'gnus-article-treat
968 :type gnus-article-treat-head-custom)
969 (put 'gnus-treat-highlight-headers 'highlight t)
971 (defcustom gnus-treat-highlight-citation t
972 "Highlight cited text.
973 Valid values are nil, t, `head', `last', an integer or a predicate.
974 See Info node `(gnus)Customizing Articles' for details."
975 :group 'gnus-article-treat
976 :type gnus-article-treat-custom)
977 (put 'gnus-treat-highlight-citation 'highlight t)
979 (defcustom gnus-treat-date-ut nil
980 "Display the Date in UT (GMT).
981 Valid values are nil, t, `head', `last', an integer or a predicate.
982 See Info node `(gnus)Customizing Articles' for details."
983 :group 'gnus-article-treat
984 :type gnus-article-treat-head-custom)
986 (defcustom gnus-treat-date-local nil
987 "Display the Date in the local timezone.
988 Valid values are nil, t, `head', `last', an integer or a predicate.
989 See Info node `(gnus)Customizing Articles' for details."
990 :group 'gnus-article-treat
991 :type gnus-article-treat-head-custom)
993 (defcustom gnus-treat-date-english nil
994 "Display the Date in a format that can be read aloud in English.
995 Valid values are nil, t, `head', `last', an integer or a predicate.
996 See Info node `(gnus)Customizing Articles' for details."
997 :group 'gnus-article-treat
998 :type gnus-article-treat-head-custom)
1000 (defcustom gnus-treat-date-lapsed nil
1001 "Display the Date header in a way that says how much time has elapsed.
1002 Valid values are nil, t, `head', `last', an integer or a predicate.
1003 See Info node `(gnus)Customizing Articles' for details."
1004 :group 'gnus-article-treat
1005 :type gnus-article-treat-head-custom)
1007 (defcustom gnus-treat-date-original nil
1008 "Display the date in the original timezone.
1009 Valid values are nil, t, `head', `last', an integer or a predicate.
1010 See Info node `(gnus)Customizing Articles' for details."
1011 :group 'gnus-article-treat
1012 :type gnus-article-treat-head-custom)
1014 (defcustom gnus-treat-date-iso8601 nil
1015 "Display the date in the ISO8601 format.
1016 Valid values are nil, t, `head', `last', an integer or a predicate.
1017 See Info node `(gnus)Customizing Articles' for details."
1019 :group 'gnus-article-treat
1020 :type gnus-article-treat-head-custom)
1022 (defcustom gnus-treat-date-user-defined nil
1023 "Display the date in a user-defined format.
1024 The format is defined by the `gnus-article-time-format' variable.
1025 Valid values are nil, t, `head', `last', an integer or a predicate.
1026 See Info node `(gnus)Customizing Articles' for details."
1027 :group 'gnus-article-treat
1028 :type gnus-article-treat-head-custom)
1030 (defcustom gnus-treat-strip-headers-in-body t
1031 "Strip the X-No-Archive header line from the beginning of the body.
1032 Valid values are nil, t, `head', `last', an integer or a predicate.
1033 See Info node `(gnus)Customizing Articles' for details."
1035 :group 'gnus-article-treat
1036 :type gnus-article-treat-custom)
1038 (defcustom gnus-treat-strip-trailing-blank-lines nil
1039 "Strip trailing blank lines.
1040 Valid values are nil, t, `head', `last', an integer or a predicate.
1041 See Info node `(gnus)Customizing Articles' for details."
1042 :group 'gnus-article-treat
1043 :type gnus-article-treat-custom)
1045 (defcustom gnus-treat-strip-leading-blank-lines nil
1046 "Strip leading blank lines.
1047 Valid values are nil, t, `head', `last', an integer or a predicate.
1048 See Info node `(gnus)Customizing Articles' for details."
1049 :group 'gnus-article-treat
1050 :type gnus-article-treat-custom)
1052 (defcustom gnus-treat-strip-multiple-blank-lines nil
1053 "Strip multiple blank lines.
1054 Valid values are nil, t, `head', `last', an integer or a predicate.
1055 See Info node `(gnus)Customizing Articles' for details."
1056 :group 'gnus-article-treat
1057 :type gnus-article-treat-custom)
1059 (defcustom gnus-treat-unfold-headers 'head
1060 "Unfold folded header lines.
1061 Valid values are nil, t, `head', `last', an integer or a predicate.
1062 See Info node `(gnus)Customizing Articles' for details."
1063 :group 'gnus-article-treat
1064 :type gnus-article-treat-custom)
1066 (defcustom gnus-treat-fold-headers nil
1068 Valid values are nil, t, `head', `last', an integer or a predicate.
1069 See Info node `(gnus)Customizing Articles' for details."
1070 :group 'gnus-article-treat
1071 :type gnus-article-treat-custom)
1073 (defcustom gnus-treat-fold-newsgroups 'head
1074 "Fold the Newsgroups and Followup-To headers.
1075 Valid values are nil, t, `head', `last', an integer or a predicate.
1076 See Info node `(gnus)Customizing Articles' for details."
1077 :group 'gnus-article-treat
1078 :type gnus-article-treat-custom)
1080 (defcustom gnus-treat-overstrike t
1081 "Treat overstrike highlighting.
1082 Valid values are nil, t, `head', `last', an integer or a predicate.
1083 See Info node `(gnus)Customizing Articles' for details."
1084 :group 'gnus-article-treat
1085 :type gnus-article-treat-custom)
1086 (put 'gnus-treat-overstrike 'highlight t)
1088 (defcustom gnus-treat-display-xface
1089 (and (not noninteractive)
1090 (or (and (fboundp 'image-type-available-p)
1091 (image-type-available-p 'xbm)
1092 (string-match "^0x" (shell-command-to-string "uncompface")))
1093 (and (featurep 'xemacs)
1096 "Display X-Face headers.
1097 Valid values are nil, t, `head', `last', an integer or a predicate.
1098 See Info node `(gnus)Customizing Articles' and Info node
1099 `(gnus)X-Face' for details."
1100 :group 'gnus-article-treat
1102 :type gnus-article-treat-head-custom)
1103 (put 'gnus-treat-display-xface 'highlight t)
1105 (defcustom gnus-treat-display-grey-xface
1106 (and (not noninteractive)
1107 (string-match "^0x" (shell-command-to-string "uncompface"))
1109 "Display grey X-Face headers.
1110 Valid values are nil, t."
1111 :group 'gnus-article-treat
1114 (put 'gnus-treat-display-grey-xface 'highlight t)
1116 (defcustom gnus-treat-display-smileys
1117 (if (or (and (featurep 'xemacs)
1119 (and (fboundp 'image-type-available-p)
1120 (image-type-available-p 'pbm)))
1123 Valid values are nil, t, `head', `last', an integer or a predicate.
1124 See Info node `(gnus)Customizing Articles' and Info node
1125 `(gnus)Smileys' for details."
1126 :group 'gnus-article-treat
1128 :type gnus-article-treat-custom)
1129 (put 'gnus-treat-display-smileys 'highlight t)
1131 (defcustom gnus-treat-from-picon
1132 (if (and (gnus-image-type-available-p 'xpm)
1133 (gnus-picons-installed-p))
1135 "Display picons in the From header.
1136 Valid values are nil, t, `head', `last', an integer or a predicate.
1137 See Info node `(gnus)Customizing Articles' and Info node
1138 `(gnus)Picons' for details."
1139 :group 'gnus-article-treat
1141 :link '(info-link "(gnus)Customizing Articles")
1142 :link '(info-link "(gnus)Picons")
1143 :type gnus-article-treat-head-custom)
1144 (put 'gnus-treat-from-picon 'highlight t)
1146 (defcustom gnus-treat-mail-picon
1147 (if (and (gnus-image-type-available-p 'xpm)
1148 (gnus-picons-installed-p))
1150 "Display picons in To and Cc headers.
1151 Valid values are nil, t, `head', `last', an integer or a predicate.
1152 See Info node `(gnus)Customizing Articles' and Info node
1153 `(gnus)Picons' for details."
1154 :group 'gnus-article-treat
1156 :link '(info-link "(gnus)Customizing Articles")
1157 :link '(info-link "(gnus)Picons")
1158 :type gnus-article-treat-head-custom)
1159 (put 'gnus-treat-mail-picon 'highlight t)
1161 (defcustom gnus-treat-newsgroups-picon
1162 (if (and (gnus-image-type-available-p 'xpm)
1163 (gnus-picons-installed-p))
1165 "Display picons in the Newsgroups and Followup-To headers.
1166 Valid values are nil, t, `head', `last', an integer or a predicate.
1167 See Info node `(gnus)Customizing Articles' and Info node
1168 `(gnus)Picons' for details."
1169 :group 'gnus-article-treat
1171 :link '(info-link "(gnus)Customizing Articles")
1172 :link '(info-link "(gnus)Picons")
1173 :type gnus-article-treat-head-custom)
1174 (put 'gnus-treat-newsgroups-picon 'highlight t)
1176 (defcustom gnus-treat-body-boundary
1177 (if (or gnus-treat-newsgroups-picon
1178 gnus-treat-mail-picon
1179 gnus-treat-from-picon)
1181 "Draw a boundary at the end of the headers.
1182 Valid values are nil, t, `head', `last', an integer or a predicate.
1183 See Info node `(gnus)Customizing Articles' for details."
1185 :group 'gnus-article-treat
1186 :type gnus-article-treat-custom)
1188 (defcustom gnus-treat-capitalize-sentences nil
1189 "Capitalize sentence-starting words.
1190 Valid values are nil, t, `head', `last', an integer or a predicate.
1191 See Info node `(gnus)Customizing Articles' for details."
1193 :group 'gnus-article-treat
1194 :type gnus-article-treat-custom)
1196 (defcustom gnus-treat-fill-long-lines nil
1198 Valid values are nil, t, `head', `last', an integer or a predicate.
1199 See Info node `(gnus)Customizing Articles' for details."
1200 :group 'gnus-article-treat
1201 :type gnus-article-treat-custom)
1203 (defcustom gnus-treat-play-sounds nil
1205 Valid values are nil, t, `head', `last', an integer or a predicate.
1206 See Info node `(gnus)Customizing Articles' for details."
1208 :group 'gnus-article-treat
1209 :type gnus-article-treat-custom)
1211 (defcustom gnus-treat-translate nil
1212 "Translate articles from one language to another.
1213 Valid values are nil, t, `head', `last', an integer or a predicate.
1214 See Info node `(gnus)Customizing Articles' for details."
1216 :group 'gnus-article-treat
1217 :type gnus-article-treat-custom)
1219 (defcustom gnus-treat-x-pgp-sig nil
1221 To automatically treat X-PGP-Sig, set it to head.
1222 Valid values are nil, t, `head', `last', an integer or a predicate.
1223 See Info node `(gnus)Customizing Articles' for details."
1224 :group 'gnus-article-treat
1225 :group 'mime-security
1226 :type gnus-article-treat-custom)
1228 (defvar gnus-article-encrypt-protocol-alist
1229 '(("PGP" . mml2015-self-encrypt)))
1231 ;; Set to nil if more than one protocol added to
1232 ;; gnus-article-encrypt-protocol-alist.
1233 (defcustom gnus-article-encrypt-protocol "PGP"
1234 "The protocol used for encrypt articles.
1235 It is a string, such as \"PGP\". If nil, ask user."
1237 :group 'mime-security)
1239 (defvar gnus-article-wash-function nil
1240 "Function used for converting HTML into text.")
1242 ;;; Internal variables
1244 (defvar gnus-english-month-names
1245 '("January" "February" "March" "April" "May" "June" "July" "August"
1246 "September" "October" "November" "December"))
1248 (defvar article-goto-body-goes-to-point-min-p nil)
1249 (defvar gnus-article-wash-types nil)
1250 (defvar gnus-article-emphasis-alist nil)
1251 (defvar gnus-article-image-alist nil)
1253 (defvar gnus-article-mime-handle-alist-1 nil)
1254 (defvar gnus-treatment-function-alist
1255 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1256 (gnus-treat-strip-banner gnus-article-strip-banner)
1257 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1258 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1259 (gnus-treat-buttonize gnus-article-add-buttons)
1260 (gnus-treat-fill-article gnus-article-fill-cited-article)
1261 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1262 (gnus-treat-strip-cr gnus-article-remove-cr)
1263 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1264 (gnus-treat-date-ut gnus-article-date-ut)
1265 (gnus-treat-date-local gnus-article-date-local)
1266 (gnus-treat-date-english gnus-article-date-english)
1267 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1268 (gnus-treat-date-original gnus-article-date-original)
1269 (gnus-treat-date-user-defined gnus-article-date-user)
1270 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1271 (gnus-treat-display-xface gnus-article-display-x-face)
1272 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1273 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1274 (gnus-treat-hide-signature gnus-article-hide-signature)
1275 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1276 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1277 (gnus-treat-strip-pgp gnus-article-hide-pgp)
1278 (gnus-treat-strip-pem gnus-article-hide-pem)
1279 (gnus-treat-from-picon gnus-treat-from-picon)
1280 (gnus-treat-mail-picon gnus-treat-mail-picon)
1281 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1282 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1283 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1284 (gnus-treat-strip-trailing-blank-lines
1285 gnus-article-remove-trailing-blank-lines)
1286 (gnus-treat-strip-leading-blank-lines
1287 gnus-article-strip-leading-blank-lines)
1288 (gnus-treat-strip-multiple-blank-lines
1289 gnus-article-strip-multiple-blank-lines)
1290 (gnus-treat-overstrike gnus-article-treat-overstrike)
1291 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1292 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1293 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1294 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1295 (gnus-treat-display-smileys gnus-treat-smiley)
1296 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1297 (gnus-treat-emphasize gnus-article-emphasize)
1298 (gnus-treat-hide-citation gnus-article-hide-citation)
1299 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1300 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1301 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1302 (gnus-treat-play-sounds gnus-earcon-display)))
1304 (defvar gnus-article-mime-handle-alist nil)
1305 (defvar article-lapsed-timer nil)
1306 (defvar gnus-article-current-summary nil)
1308 (defvar gnus-article-mode-syntax-table
1309 (let ((table (copy-syntax-table text-mode-syntax-table)))
1310 ;; This causes the citation match run O(2^n).
1311 ;; (modify-syntax-entry ?- "w" table)
1312 (modify-syntax-entry ?> ")<" table)
1313 (modify-syntax-entry ?< "(>" table)
1315 "Syntax table used in article mode buffers.
1316 Initialized from `text-mode-syntax-table.")
1318 (defvar gnus-save-article-buffer nil)
1320 (defvar gnus-article-mode-line-format-alist
1321 (nconc '((?w (gnus-article-wash-status) ?s)
1322 (?m (gnus-article-mime-part-status) ?s))
1323 gnus-summary-mode-line-format-alist))
1325 (defvar gnus-number-of-articles-to-be-saved nil)
1327 (defvar gnus-inhibit-hiding nil)
1329 ;;; Macros for dealing with the article buffer.
1331 (defmacro gnus-with-article-headers (&rest forms)
1333 (set-buffer gnus-article-buffer)
1335 (let ((buffer-read-only nil)
1336 (inhibit-point-motion-hooks t)
1337 (case-fold-search t))
1338 (article-narrow-to-head)
1341 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1342 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1344 (defmacro gnus-with-article-buffer (&rest forms)
1346 (set-buffer gnus-article-buffer)
1347 (let ((buffer-read-only nil))
1350 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1351 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1353 (defun gnus-article-goto-header (header)
1354 "Go to HEADER, which is a regular expression."
1355 (re-search-forward (concat "^\\(" header "\\):") nil t))
1357 (defsubst gnus-article-hide-text (b e props)
1358 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1359 (gnus-add-text-properties-when 'article-type nil b e props)
1360 (when (memq 'intangible props)
1362 (max (1- b) (point-min))
1363 b 'intangible (cddr (memq 'intangible props)))))
1365 (defsubst gnus-article-unhide-text (b e)
1366 "Remove hidden text properties from region between B and E."
1367 (remove-text-properties b e gnus-hidden-properties)
1368 (when (memq 'intangible gnus-hidden-properties)
1369 (put-text-property (max (1- b) (point-min))
1370 b 'intangible nil)))
1372 (defun gnus-article-hide-text-type (b e type)
1373 "Hide text of TYPE between B and E."
1374 (gnus-add-wash-type type)
1375 (gnus-article-hide-text
1376 b e (cons 'article-type (cons type gnus-hidden-properties))))
1378 (defun gnus-article-unhide-text-type (b e type)
1379 "Unhide text of TYPE between B and E."
1380 (gnus-delete-wash-type type)
1381 (remove-text-properties
1382 b e (cons 'article-type (cons type gnus-hidden-properties)))
1383 (when (memq 'intangible gnus-hidden-properties)
1384 (put-text-property (max (1- b) (point-min))
1385 b 'intangible nil)))
1387 (defun gnus-article-hide-text-of-type (type)
1388 "Hide text of TYPE in the current buffer."
1390 (let ((b (point-min))
1392 (while (setq b (text-property-any b e 'article-type type))
1393 (add-text-properties b (incf b) gnus-hidden-properties)))))
1395 (defun gnus-article-delete-text-of-type (type)
1396 "Delete text of TYPE in the current buffer."
1398 (let ((b (point-min)))
1399 (while (setq b (text-property-any b (point-max) 'article-type type))
1401 b (or (text-property-not-all b (point-max) 'article-type type)
1404 (defun gnus-article-delete-invisible-text ()
1405 "Delete all invisible text in the current buffer."
1407 (let ((b (point-min)))
1408 (while (setq b (text-property-any b (point-max) 'invisible t))
1410 b (or (text-property-not-all b (point-max) 'invisible t)
1413 (defun gnus-article-text-type-exists-p (type)
1414 "Say whether any text of type TYPE exists in the buffer."
1415 (text-property-any (point-min) (point-max) 'article-type type))
1417 (defsubst gnus-article-header-rank ()
1418 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1419 (let ((list gnus-sorted-header-list)
1422 (when (looking-at (car list))
1424 (setq list (cdr list))
1428 (defun article-hide-headers (&optional arg delete)
1429 "Hide unwanted headers and possibly sort them as well."
1431 ;; This function might be inhibited.
1432 (unless gnus-inhibit-hiding
1435 (let ((buffer-read-only nil)
1436 (case-fold-search t)
1437 (max (1+ (length gnus-sorted-header-list)))
1438 (ignored (when (not gnus-visible-headers)
1439 (cond ((stringp gnus-ignored-headers)
1440 gnus-ignored-headers)
1441 ((listp gnus-ignored-headers)
1442 (mapconcat 'identity gnus-ignored-headers
1445 (cond ((stringp gnus-visible-headers)
1446 gnus-visible-headers)
1447 ((and gnus-visible-headers
1448 (listp gnus-visible-headers))
1449 (mapconcat 'identity gnus-visible-headers "\\|"))))
1450 (inhibit-point-motion-hooks t)
1452 ;; First we narrow to just the headers.
1453 (article-narrow-to-head)
1454 ;; Hide any "From " lines at the beginning of (mail) articles.
1455 (while (looking-at "From ")
1458 (delete-region (point-min) (point)))
1459 ;; Then treat the rest of the header lines.
1460 ;; Then we use the two regular expressions
1461 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1462 ;; select which header lines is to remain visible in the
1464 (while (re-search-forward "^[^ \t:]*:" nil t)
1466 ;; Mark the rank of the header.
1468 (point) (1+ (point)) 'message-rank
1469 (if (or (and visible (looking-at visible))
1471 (not (looking-at ignored))))
1472 (gnus-article-header-rank)
1475 (message-sort-headers-1)
1476 (when (setq beg (text-property-any
1477 (point-min) (point-max) 'message-rank (+ 2 max)))
1478 ;; We delete the unwanted headers.
1479 (gnus-add-wash-type 'headers)
1480 (add-text-properties (point-min) (+ 5 (point-min))
1481 '(article-type headers dummy-invisible t))
1482 (delete-region beg (point-max))))))))
1484 (defun article-hide-boring-headers (&optional arg)
1485 "Toggle hiding of headers that aren't very interesting.
1486 If given a negative prefix, always show; if given a positive prefix,
1488 (interactive (gnus-article-hidden-arg))
1489 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1490 (not gnus-show-all-headers))
1493 (let ((buffer-read-only nil)
1494 (list gnus-boring-article-headers)
1495 (inhibit-point-motion-hooks t)
1497 (article-narrow-to-head)
1499 (setq elem (pop list))
1500 (goto-char (point-min))
1502 ;; Hide empty headers.
1504 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1506 (gnus-article-hide-text-type
1507 (progn (beginning-of-line) (point))
1510 (if (re-search-forward "^[^ \t]" nil t)
1514 ;; Hide boring Newsgroups header.
1515 ((eq elem 'newsgroups)
1516 (when (gnus-string-equal
1517 (gnus-fetch-field "newsgroups")
1518 (gnus-group-real-name
1519 (if (boundp 'gnus-newsgroup-name)
1522 (gnus-article-hide-header "newsgroups")))
1523 ((eq elem 'to-address)
1524 (let ((to (message-fetch-field "to"))
1526 (gnus-parameter-to-address
1527 (if (boundp 'gnus-newsgroup-name)
1528 gnus-newsgroup-name ""))))
1529 (when (and to to-address
1532 ;; only one address in To
1533 (nth 1 (mail-extract-address-components to))
1535 (gnus-article-hide-header "to"))))
1536 ((eq elem 'followup-to)
1537 (when (gnus-string-equal
1538 (message-fetch-field "followup-to")
1539 (message-fetch-field "newsgroups"))
1540 (gnus-article-hide-header "followup-to")))
1541 ((eq elem 'reply-to)
1542 (let ((from (message-fetch-field "from"))
1543 (reply-to (message-fetch-field "reply-to")))
1548 (nth 1 (mail-extract-address-components from))
1549 (nth 1 (mail-extract-address-components reply-to)))))
1550 (gnus-article-hide-header "reply-to"))))
1552 (let ((date (message-fetch-field "date")))
1554 (< (days-between (current-time-string) date)
1556 (gnus-article-hide-header "date"))))
1558 (let ((to (message-fetch-field "to"))
1559 (cc (message-fetch-field "cc")))
1560 (when (> (length to) 1024)
1561 (gnus-article-hide-header "to"))
1562 (when (> (length cc) 1024)
1563 (gnus-article-hide-header "cc"))))
1567 (goto-char (point-min))
1568 (while (re-search-forward "^to:" nil t)
1569 (setq to-count (1+ to-count)))
1570 (when (> to-count 1)
1571 (while (> to-count 0)
1572 (goto-char (point-min))
1574 (re-search-forward "^to:" nil nil to-count)
1576 (narrow-to-region (point) (point-max))
1577 (gnus-article-hide-header "to"))
1578 (setq to-count (1- to-count))))
1579 (goto-char (point-min))
1580 (while (re-search-forward "^cc:" nil t)
1581 (setq cc-count (1+ cc-count)))
1582 (when (> cc-count 1)
1583 (while (> cc-count 0)
1584 (goto-char (point-min))
1586 (re-search-forward "^cc:" nil nil cc-count)
1588 (narrow-to-region (point) (point-max))
1589 (gnus-article-hide-header "cc"))
1590 (setq cc-count (1- cc-count)))))))))))))
1592 (defun gnus-article-hide-header (header)
1594 (goto-char (point-min))
1595 (when (re-search-forward (concat "^" header ":") nil t)
1596 (gnus-article-hide-text-type
1597 (progn (beginning-of-line) (point))
1600 (if (re-search-forward "^[^ \t]" nil t)
1605 (defvar gnus-article-normalized-header-length 40
1606 "Length of normalized headers.")
1608 (defun article-normalize-headers ()
1609 "Make all header lines 40 characters long."
1611 (let ((buffer-read-only nil)
1615 (article-narrow-to-head)
1618 ((< (setq column (- (gnus-point-at-eol) (point)))
1619 gnus-article-normalized-header-length)
1621 (insert (make-string
1622 (- gnus-article-normalized-header-length column)
1624 ((> column gnus-article-normalized-header-length)
1625 (gnus-put-text-property
1627 (forward-char gnus-article-normalized-header-length)
1634 (forward-line 1))))))
1636 (defun article-treat-dumbquotes ()
1637 "Translate M****s*** sm*rtq**t*s into proper text.
1638 Note that this function guesses whether a character is a sm*rtq**t* or
1639 not, so it should only be used interactively.
1641 Sm*rtq**t*s are M****s***'s unilateral extension to the character map
1642 in an attempt to provide more quoting characters. If you see
1643 something like \\222 or \\264 where you're expecting some kind of
1644 apostrophe or quotation mark, then try this wash."
1646 (article-translate-strings gnus-article-dumbquotes-map))
1648 (defun article-translate-characters (from to)
1649 "Translate all characters in the body of the article according to FROM and TO.
1650 FROM is a string of characters to translate from; to is a string of
1651 characters to translate to."
1653 (when (article-goto-body)
1654 (let ((buffer-read-only nil)
1655 (x (make-string 225 ?x))
1657 (while (< (incf i) (length x))
1660 (while (< i (length from))
1661 (aset x (aref from i) (aref to i))
1663 (translate-region (point) (point-max) x)))))
1665 (defun article-translate-strings (map)
1666 "Translate all string in the body of the article according to MAP.
1667 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1669 (when (article-goto-body)
1670 (let ((buffer-read-only nil)
1672 (while (setq elem (pop map))
1674 (while (search-forward (car elem) nil t)
1675 (replace-match (cadr elem)))))))))
1677 (defun article-treat-overstrike ()
1678 "Translate overstrikes into bold text."
1681 (when (article-goto-body)
1682 (let ((buffer-read-only nil))
1683 (while (search-forward "\b" nil t)
1684 (let ((next (char-after))
1685 (previous (char-after (- (point) 2))))
1686 ;; We do the boldification/underlining by hiding the
1687 ;; overstrikes and putting the proper text property
1691 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1692 (put-text-property (point) (1+ (point)) 'face 'bold))
1694 (gnus-article-hide-text-type
1695 (1- (point)) (1+ (point)) 'overstrike)
1697 (- (point) 2) (1- (point)) 'face 'underline))
1699 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1701 (point) (1+ (point)) 'face 'underline)))))))))
1703 (defun gnus-article-treat-unfold-headers ()
1704 "Unfold folded message headers.
1705 Only the headers that fit into the current window width will be
1708 (gnus-with-article-headers
1712 (mail-header-narrow-to-field)
1713 (let ((header (buffer-substring (point-min) (point-max))))
1716 (goto-char (point-min))
1717 (while (re-search-forward "\n[\t ]" nil t)
1718 (replace-match " " t t)))
1719 (setq length (- (point-max) (point-min) 1)))
1720 (when (< length (window-width))
1721 (while (re-search-forward "\n[\t ]" nil t)
1722 (replace-match " " t t)))
1723 (goto-char (point-max)))))))
1725 (defun gnus-article-treat-fold-headers ()
1726 "Fold message headers."
1728 (gnus-with-article-headers
1731 (mail-header-narrow-to-field)
1732 (mail-header-fold-field)
1733 (goto-char (point-max))))))
1735 (defun gnus-treat-smiley ()
1736 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
1738 (gnus-with-article-buffer
1739 (if (memq 'smiley gnus-article-wash-types)
1740 (gnus-delete-images 'smiley)
1742 (let ((images (smiley-region (point) (point-max))))
1744 (gnus-add-wash-type 'smiley)
1745 (dolist (image images)
1746 (gnus-add-image 'smiley image)))))))
1748 (defun gnus-article-remove-images ()
1749 "Remove all images from the article buffer."
1751 (gnus-with-article-buffer
1752 (dolist (elem gnus-article-image-alist)
1753 (gnus-delete-images (car elem)))))
1755 (defun gnus-article-treat-fold-newsgroups ()
1756 "Unfold folded message headers.
1757 Only the headers that fit into the current window width will be
1760 (gnus-with-article-headers
1761 (while (gnus-article-goto-header "newsgroups\\|followup-to")
1763 (mail-header-narrow-to-field)
1764 (while (re-search-forward ", *" nil t)
1765 (replace-match ", " t t))
1766 (mail-header-fold-field)
1767 (goto-char (point-max))))))
1769 (defun gnus-article-treat-body-boundary ()
1770 "Place a boundary line at the end of the headers."
1772 (when (and gnus-body-boundary-delimiter
1773 (> (length gnus-body-boundary-delimiter) 0))
1774 (gnus-with-article-headers
1775 (goto-char (point-max))
1776 (let ((start (point)))
1777 (insert "X-Boundary: ")
1778 (gnus-add-text-properties start (point) '(invisible t intangible t))
1780 (while (>= (1- (window-width)) (length str))
1781 (setq str (concat str gnus-body-boundary-delimiter)))
1782 (substring str 0 (1- (window-width))))
1784 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
1786 (defun article-fill-long-lines ()
1787 "Fill lines that are wider than the window width."
1790 (let ((buffer-read-only nil)
1791 (width (window-width (get-buffer-window (current-buffer)))))
1794 (let ((adaptive-fill-mode nil)) ;Why? -sm
1797 (when (>= (current-column) (min fill-column width))
1798 (narrow-to-region (point) (gnus-point-at-bol))
1799 (fill-paragraph nil)
1800 (goto-char (point-max))
1802 (forward-line 1)))))))
1804 (defun article-capitalize-sentences ()
1805 "Capitalize the first word in each sentence."
1808 (let ((buffer-read-only nil)
1809 (paragraph-start "^[\n\^L]"))
1813 (forward-sentence)))))
1815 (defun article-remove-cr ()
1816 "Remove trailing CRs and then translate remaining CRs into LFs."
1819 (let ((buffer-read-only nil))
1820 (goto-char (point-min))
1821 (while (re-search-forward "\r+$" nil t)
1822 (replace-match "" t t))
1823 (goto-char (point-min))
1824 (while (search-forward "\r" nil t)
1825 (replace-match "\n" t t)))))
1827 (defun article-remove-trailing-blank-lines ()
1828 "Remove all trailing blank lines from the article."
1831 (let ((buffer-read-only nil))
1832 (goto-char (point-max))
1836 (while (and (not (bobp))
1837 (looking-at "^[ \t]*$")
1838 (not (gnus-annotation-in-region-p
1839 (point) (gnus-point-at-eol))))
1844 (defun article-display-x-face (&optional force)
1845 "Look for an X-Face header and display it if present."
1846 (interactive (list 'force))
1847 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
1848 (gnus-with-article-headers
1849 ;; Delete the old process, if any.
1850 (when (process-status "article-x-face")
1851 (delete-process "article-x-face"))
1852 (if (memq 'xface gnus-article-wash-types)
1853 ;; We have already displayed X-Faces, so we remove them
1855 (gnus-delete-images 'xface)
1857 (let (x-faces from face grey)
1859 (when (and wash-face-p
1861 (goto-char (point-min))
1862 (not (re-search-forward
1863 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
1864 (gnus-buffer-live-p gnus-original-article-buffer))
1865 ;; If type `W f', use gnus-original-article-buffer,
1866 ;; otherwise use the current buffer because displaying
1867 ;; RFC822 parts calls this function too.
1868 (set-buffer gnus-original-article-buffer))
1870 (mail-narrow-to-head)
1871 (if gnus-treat-display-grey-xface
1873 (while (gnus-article-goto-header "X-Face\\(-[0-9]+\\)?")
1874 (if (match-beginning 2)
1877 (push (cons (- (string-to-number (match-string 2)))
1878 (mail-header-field-value))
1880 (push (cons 0 (mail-header-field-value)) x-faces)))
1881 (dolist (x-face (prog1
1883 (sort x-faces 'car-less-than-car)
1885 (setq x-faces nil)))
1886 (push (cdr x-face) x-faces)))
1887 (while (gnus-article-goto-header "X-Face")
1888 (push (mail-header-field-value) x-faces)))
1889 (setq from (message-fetch-field "from"))))
1891 (let ((xpm (gnus-convert-gray-x-face-to-xpm x-faces))
1894 (setq image (gnus-create-image xpm 'xpm t))
1895 (gnus-article-goto-header "from")
1897 (insert "From: [no `from' set]\n")
1899 (gnus-add-wash-type 'xface)
1900 (gnus-add-image 'xface image)
1901 (gnus-put-image image)))
1902 ;; Sending multiple EOFs to xv doesn't work, so we only do a
1903 ;; single external face.
1904 (when (stringp gnus-article-x-face-command)
1905 (setq x-faces (list (car x-faces))))
1906 (while (and (setq face (pop x-faces))
1907 gnus-article-x-face-command
1909 ;; Check whether this face is censored.
1910 (not gnus-article-x-face-too-ugly)
1911 (and gnus-article-x-face-too-ugly from
1912 (not (string-match gnus-article-x-face-too-ugly
1914 ;; We display the face.
1915 (if (symbolp gnus-article-x-face-command)
1916 ;; The command is a lisp function, so we call it.
1917 (if (gnus-functionp gnus-article-x-face-command)
1918 (funcall gnus-article-x-face-command face)
1919 (error "%s is not a function" gnus-article-x-face-command))
1920 ;; The command is a string, so we interpret the command
1921 ;; as a, well, command, and fork it off.
1922 (let ((process-connection-type nil))
1923 (process-kill-without-query
1925 "article-x-face" nil shell-file-name shell-command-switch
1926 gnus-article-x-face-command))
1929 (process-send-region "article-x-face"
1930 (point-min) (point-max)))
1931 (process-send-eof "article-x-face"))))))))))
1933 (defun article-decode-mime-words ()
1934 "Decode all MIME-encoded words in the article."
1937 (set-buffer gnus-article-buffer)
1938 (let ((inhibit-point-motion-hooks t)
1940 (mail-parse-charset gnus-newsgroup-charset)
1941 (mail-parse-ignored-charsets
1942 (save-excursion (set-buffer gnus-summary-buffer)
1943 gnus-newsgroup-ignored-charsets)))
1944 (mail-decode-encoded-word-region (point-min) (point-max)))))
1946 (defun article-decode-charset (&optional prompt)
1947 "Decode charset-encoded text in the article.
1948 If PROMPT (the prefix), prompt for a coding system to use."
1950 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
1952 (mail-parse-charset gnus-newsgroup-charset)
1953 (mail-parse-ignored-charsets
1954 (save-excursion (condition-case nil
1955 (set-buffer gnus-summary-buffer)
1957 gnus-newsgroup-ignored-charsets))
1958 ct cte ctl charset format)
1961 (article-narrow-to-head)
1962 (setq ct (message-fetch-field "Content-Type" t)
1963 cte (message-fetch-field "Content-Transfer-Encoding" t)
1964 ctl (and ct (ignore-errors
1965 (mail-header-parse-content-type ct)))
1968 (mm-read-coding-system "Charset to decode: "))
1970 (mail-content-type-get ctl 'charset)))
1971 format (and ctl (mail-content-type-get ctl 'format)))
1973 (setq cte (mail-header-strip cte)))
1974 (if (and ctl (not (string-match "/" (car ctl))))
1976 (goto-char (point-max)))
1979 (narrow-to-region (point) (point-max))
1980 (when (and (eq mail-parse-charset 'gnus-decoded)
1981 (eq (mm-body-7-or-8) '8bit))
1982 ;; The text code could have been decoded.
1983 (setq charset mail-parse-charset))
1984 (when (and (or (not ctl)
1985 (equal (car ctl) "text/plain"))
1986 (not format)) ;; article with format will decode later.
1988 charset (and cte (intern (downcase
1989 (gnus-strip-whitespace cte))))
1992 (defun article-decode-encoded-words ()
1993 "Remove encoded-word encoding from headers."
1994 (let ((inhibit-point-motion-hooks t)
1995 (mail-parse-charset gnus-newsgroup-charset)
1996 (mail-parse-ignored-charsets
1997 (save-excursion (condition-case nil
1998 (set-buffer gnus-summary-buffer)
2000 gnus-newsgroup-ignored-charsets))
2003 (article-narrow-to-head)
2004 (funcall gnus-decode-header-function (point-min) (point-max)))))
2006 (defun article-decode-group-name ()
2007 "Decode group names in `Newsgroups:'."
2008 (let ((inhibit-point-motion-hooks t)
2010 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2011 (when (and (or gnus-group-name-charset-method-alist
2012 gnus-group-name-charset-group-alist)
2013 (gnus-buffer-live-p gnus-original-article-buffer))
2014 (when (nnmail-fetch-field "Newsgroups")
2015 (nnheader-replace-header "Newsgroups"
2016 (gnus-decode-newsgroups
2017 (with-current-buffer
2018 gnus-original-article-buffer
2019 (nnmail-fetch-field "Newsgroups"))
2020 gnus-newsgroup-name method)))
2021 (when (nnmail-fetch-field "Followup-To")
2022 (nnheader-replace-header "Followup-To"
2023 (gnus-decode-newsgroups
2024 (with-current-buffer
2025 gnus-original-article-buffer
2026 (nnmail-fetch-field "Followup-To"))
2027 gnus-newsgroup-name method))))))
2029 (defun article-de-quoted-unreadable (&optional force read-charset)
2030 "Translate a quoted-printable-encoded article.
2031 If FORCE, decode the article whether it is marked as quoted-printable
2033 If READ-CHARSET, ask for a coding system."
2034 (interactive (list 'force current-prefix-arg))
2036 (let ((buffer-read-only nil) type charset)
2037 (if (gnus-buffer-live-p gnus-original-article-buffer)
2038 (with-current-buffer gnus-original-article-buffer
2040 (gnus-fetch-field "content-transfer-encoding"))
2041 (let* ((ct (gnus-fetch-field "content-type"))
2044 (mail-header-parse-content-type ct)))))
2045 (setq charset (and ctl
2046 (mail-content-type-get ctl 'charset)))
2047 (if (stringp charset)
2048 (setq charset (intern (downcase charset)))))))
2050 (setq charset (mm-read-coding-system "Charset: " charset)))
2052 (setq charset gnus-newsgroup-charset))
2054 (and type (let ((case-fold-search t))
2055 (string-match "quoted-printable" type))))
2057 (quoted-printable-decode-region
2058 (point) (point-max) (mm-charset-to-coding-system charset))))))
2060 (defun article-de-base64-unreadable (&optional force read-charset)
2061 "Translate a base64 article.
2062 If FORCE, decode the article whether it is marked as base64 not.
2063 If READ-CHARSET, ask for a coding system."
2064 (interactive (list 'force current-prefix-arg))
2066 (let ((buffer-read-only nil) type charset)
2067 (if (gnus-buffer-live-p gnus-original-article-buffer)
2068 (with-current-buffer gnus-original-article-buffer
2070 (gnus-fetch-field "content-transfer-encoding"))
2071 (let* ((ct (gnus-fetch-field "content-type"))
2074 (mail-header-parse-content-type ct)))))
2075 (setq charset (and ctl
2076 (mail-content-type-get ctl 'charset)))
2077 (if (stringp charset)
2078 (setq charset (intern (downcase charset)))))))
2080 (setq charset (mm-read-coding-system "Charset: " charset)))
2082 (setq charset gnus-newsgroup-charset))
2084 (and type (let ((case-fold-search t))
2085 (string-match "base64" type))))
2088 (narrow-to-region (point) (point-max))
2089 (base64-decode-region (point-min) (point-max))
2090 (mm-decode-coding-region
2091 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2096 (defun article-decode-HZ ()
2097 "Translate a HZ-encoded article."
2101 (let ((buffer-read-only nil))
2102 (rfc1843-decode-region (point-min) (point-max)))))
2104 (defun article-unsplit-urls ()
2105 "Remove the newlines that some other mailers insert into URLs."
2108 (let ((buffer-read-only nil))
2109 (goto-char (point-min))
2110 (while (re-search-forward
2111 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2112 (replace-match "\\1\\3" t)))
2113 (when (and gnus-display-mime-function (interactive-p))
2114 (funcall gnus-display-mime-function))))
2117 (defun article-wash-html (&optional read-charset)
2118 "Format an html article.
2119 If READ-CHARSET, ask for a coding system."
2122 (let ((buffer-read-only nil)
2124 (if (gnus-buffer-live-p gnus-original-article-buffer)
2125 (with-current-buffer gnus-original-article-buffer
2126 (let* ((ct (gnus-fetch-field "content-type"))
2129 (mail-header-parse-content-type ct)))))
2130 (setq charset (and ctl
2131 (mail-content-type-get ctl 'charset)))
2132 (if (stringp charset)
2133 (setq charset (intern (downcase charset)))))))
2135 (setq charset (mm-read-coding-system "Charset: " charset)))
2137 (setq charset gnus-newsgroup-charset))
2139 (save-window-excursion
2141 (narrow-to-region (point) (point-max))
2142 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2143 (entry (assq func mm-text-html-washer-alist)))
2145 (setq func (cdr entry)))
2147 ((gnus-functionp func)
2150 (apply (car func) (cdr func))))))))))
2152 (defun gnus-article-wash-html-with-w3 ()
2153 "Wash the current buffer with w3."
2155 (let ((w3-strict-width (window-width))
2156 (url-standalone-mode t)
2157 (url-gateway-unplugged t)
2158 (w3-honor-stylesheets nil))
2160 (w3-region (point-min) (point-max))
2163 (defun gnus-article-wash-html-with-w3m ()
2164 "Wash the current buffer with emacs-w3m."
2167 (narrow-to-region (point) (point-max))
2168 (let ((w3m-safe-url-regexp (if mm-inline-text-html-with-images
2171 (w3m-display-inline-images mm-inline-text-html-with-images)
2172 w3m-force-redisplay)
2173 (w3m-region (point-min) (point-max)))
2174 (when mm-inline-text-html-with-w3m-keymap
2175 (add-text-properties
2176 (point-min) (point-max)
2177 (append '(mm-inline-text-html-with-w3m t)
2178 (gnus-local-map-property mm-w3m-mode-map))))))
2180 (defun article-hide-list-identifiers ()
2181 "Remove list identifies from the Subject header.
2182 The `gnus-list-identifiers' variable specifies what to do."
2184 (let ((inhibit-point-motion-hooks t)
2185 (regexp (if (consp gnus-list-identifiers)
2186 (mapconcat 'identity gnus-list-identifiers " *\\|")
2187 gnus-list-identifiers))
2192 (article-narrow-to-head)
2193 (goto-char (point-min))
2194 (while (re-search-forward
2195 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2197 (delete-region (match-beginning 2) (match-end 0))
2198 (beginning-of-line))
2199 (when (re-search-forward
2200 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2201 (delete-region (match-beginning 1) (match-end 1))))))))
2203 (defun article-hide-pgp ()
2204 "Remove any PGP headers and signatures in the current article."
2208 (let ((inhibit-point-motion-hooks t)
2209 buffer-read-only beg end)
2211 ;; Hide the "header".
2212 (when (re-search-forward "^-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
2213 (gnus-add-wash-type 'pgp)
2214 (delete-region (match-beginning 0) (match-end 0))
2215 ;; Remove armor headers (rfc2440 6.2)
2216 (delete-region (point) (or (re-search-forward "^[ \t]*\n" nil t)
2219 ;; Hide the actual signature.
2220 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
2221 (setq end (1+ (match-beginning 0)))
2224 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
2226 ;; Perhaps we shouldn't hide to the end of the buffer
2227 ;; if there is no end to the signature?
2229 ;; Hide "- " PGP quotation markers.
2231 (narrow-to-region beg end)
2232 (goto-char (point-min))
2233 (while (re-search-forward "^- " nil t)
2235 (match-beginning 0) (match-end 0)))
2237 (gnus-run-hooks 'gnus-article-hide-pgp-hook))))))
2239 (defun article-hide-pem (&optional arg)
2240 "Toggle hiding of any PEM headers and signatures in the current article.
2241 If given a negative prefix, always show; if given a positive prefix,
2243 (interactive (gnus-article-hidden-arg))
2244 (unless (gnus-article-check-hidden-text 'pem arg)
2246 (let (buffer-read-only end)
2247 (goto-char (point-min))
2248 ;; Hide the horrendously ugly "header".
2249 (when (and (search-forward
2250 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2252 (setq end (1+ (match-beginning 0))))
2253 (gnus-add-wash-type 'pem)
2254 (gnus-article-hide-text-type
2256 (if (search-forward "\n\n" nil t)
2260 ;; Hide the trailer as well
2261 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2263 (gnus-article-hide-text-type
2264 (match-beginning 0) (match-end 0) 'pem)))))))
2266 (defun article-strip-banner ()
2267 "Strip the banner specified by the `banner' group parameter."
2271 (let ((inhibit-point-motion-hooks t)
2272 (banner (gnus-parameter-banner gnus-newsgroup-name))
2273 (gnus-signature-limit nil)
2274 buffer-read-only beg end)
2275 (when (and gnus-article-address-banner-alist
2278 (let ((from (save-restriction
2280 (article-narrow-to-head)
2281 (caar (mail-header-parse-addresses
2282 (mail-fetch-field "from"))))))
2284 (dolist (pair gnus-article-address-banner-alist)
2285 (when (string-match (car pair) from)
2286 (throw 'found (cdr pair))))))))
2290 ((eq banner 'signature)
2291 (when (gnus-article-narrow-to-signature)
2294 (delete-region (point) (point-max))))
2296 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2297 (while (re-search-forward banner nil t)
2298 (delete-region (match-beginning 0) (match-end 0)))))
2300 (while (re-search-forward banner nil t)
2301 (delete-region (match-beginning 0) (match-end 0))))))))))
2303 (defun article-babel ()
2304 "Translate article using an online translation service."
2308 (set-buffer gnus-article-buffer)
2309 (when (article-goto-body)
2310 (let* ((buffer-read-only nil)
2313 (orig (buffer-substring start end))
2314 (trans (babel-as-string orig)))
2316 (narrow-to-region start end)
2317 (delete-region start end)
2320 (defun article-hide-signature (&optional arg)
2321 "Hide the signature in the current article.
2322 If given a negative prefix, always show; if given a positive prefix,
2324 (interactive (gnus-article-hidden-arg))
2325 (unless (gnus-article-check-hidden-text 'signature arg)
2328 (let ((buffer-read-only nil))
2329 (when (gnus-article-narrow-to-signature)
2330 (gnus-article-hide-text-type
2331 (point-min) (point-max) 'signature))))))
2332 (gnus-set-mode-line 'article))
2334 (defun article-strip-headers-in-body ()
2335 "Strip offensive headers from bodies."
2339 (let ((case-fold-search t))
2340 (when (looking-at "x-no-archive:")
2341 (gnus-delete-line)))))
2343 (defun article-strip-leading-blank-lines ()
2344 "Remove all blank lines from the beginning of the article."
2347 (let ((inhibit-point-motion-hooks t)
2349 (when (article-goto-body)
2350 (while (and (not (eobp))
2351 (looking-at "[ \t]*$"))
2352 (gnus-delete-line))))))
2354 (defun article-narrow-to-head ()
2355 "Narrow the buffer to the head of the message.
2356 Point is left at the beginning of the narrowed-to region."
2358 (goto-char (point-min))
2359 (if (search-forward "\n\n" nil 1)
2362 (goto-char (point-min)))
2364 (defun article-goto-body ()
2365 "Place point at the start of the body."
2366 (goto-char (point-min))
2368 ;; This variable is only bound when dealing with separate
2370 (article-goto-body-goes-to-point-min-p
2372 ((search-forward "\n\n" nil t)
2375 (goto-char (point-max))
2378 (defun article-strip-multiple-blank-lines ()
2379 "Replace consecutive blank lines with one empty line."
2382 (let ((inhibit-point-motion-hooks t)
2384 ;; First make all blank lines empty.
2386 (while (re-search-forward "^[ \t]+$" nil t)
2387 (unless (gnus-annotation-in-region-p
2388 (match-beginning 0) (match-end 0))
2389 (replace-match "" nil t)))
2390 ;; Then replace multiple empty lines with a single empty line.
2392 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2393 (unless (gnus-annotation-in-region-p
2394 (match-beginning 0) (match-end 0))
2395 (delete-region (match-beginning 1) (match-end 1)))))))
2397 (defun article-strip-leading-space ()
2398 "Remove all white space from the beginning of the lines in the article."
2401 (let ((inhibit-point-motion-hooks t)
2404 (while (re-search-forward "^[ \t]+" nil t)
2405 (replace-match "" t t)))))
2407 (defun article-strip-trailing-space ()
2408 "Remove all white space from the end of the lines in the article."
2411 (let ((inhibit-point-motion-hooks t)
2414 (while (re-search-forward "[ \t]+$" nil t)
2415 (replace-match "" t t)))))
2417 (defun article-strip-blank-lines ()
2418 "Strip leading, trailing and multiple blank lines."
2420 (article-strip-leading-blank-lines)
2421 (article-remove-trailing-blank-lines)
2422 (article-strip-multiple-blank-lines))
2424 (defun article-strip-all-blank-lines ()
2425 "Strip all blank lines."
2428 (let ((inhibit-point-motion-hooks t)
2431 (while (re-search-forward "^[ \t]*\n" nil t)
2432 (replace-match "" t t)))))
2434 (defun gnus-article-narrow-to-signature ()
2435 "Narrow to the signature; return t if a signature is found, else nil."
2436 (let ((inhibit-point-motion-hooks t))
2437 (when (gnus-article-search-signature)
2439 ;; Check whether we have some limits to what we consider
2440 ;; to be a signature.
2441 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2442 (list gnus-signature-limit)))
2444 (while (setq limit (pop limits))
2445 (if (or (and (integerp limit)
2446 (< (- (point-max) (point)) limit))
2448 (< (count-lines (point) (point-max)) limit))
2449 (and (gnus-functionp limit)
2451 (and (stringp limit)
2452 (not (re-search-forward limit nil t))))
2453 () ; This limit did not succeed.
2457 (narrow-to-region (point) (point-max))
2460 (defun gnus-article-search-signature ()
2461 "Search the current buffer for the signature separator.
2462 Put point at the beginning of the signature separator."
2463 (let ((cur (point)))
2464 (goto-char (point-max))
2465 (if (if (stringp gnus-signature-separator)
2466 (re-search-backward gnus-signature-separator nil t)
2467 (let ((seps gnus-signature-separator))
2469 (not (re-search-backward (car seps) nil t)))
2476 (defun gnus-article-hidden-arg ()
2477 "Return the current prefix arg as a number, or 0 if no prefix."
2478 (list (if current-prefix-arg
2479 (prefix-numeric-value current-prefix-arg)
2482 (defun gnus-article-check-hidden-text (type arg)
2483 "Return nil if hiding is necessary.
2484 Arg can be nil or a number. nil and positive means hide, negative
2485 means show, 0 means toggle."
2488 (let ((hide (gnus-article-hidden-text-p type)))
2494 (gnus-article-show-hidden-text type)
2497 (if (eq hide 'hidden)
2499 (gnus-article-show-hidden-text type)
2503 (defun gnus-article-hidden-text-p (type)
2504 "Say whether the current buffer contains hidden text of type TYPE."
2505 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2507 (not (get-text-property pos 'invisible))
2508 (not (get-text-property pos 'dummy-invisible)))
2510 (text-property-any (1+ pos) (point-max) 'article-type type)))
2515 (defun gnus-article-show-hidden-text (type &optional dummy)
2516 "Show all hidden text of type TYPE.
2517 Originally it is hide instead of DUMMY."
2518 (let ((buffer-read-only nil)
2519 (inhibit-point-motion-hooks t))
2520 (gnus-remove-text-properties-when
2522 (point-min) (point-max)
2523 (cons 'article-type (cons type
2524 gnus-hidden-properties)))
2525 (gnus-delete-wash-type type)))
2527 (defconst article-time-units
2528 `((year . ,(* 365.25 24 60 60))
2529 (week . ,(* 7 24 60 60))
2530 (day . ,(* 24 60 60))
2534 "Mapping from time units to seconds.")
2536 (defun article-date-ut (&optional type highlight header)
2537 "Convert DATE date to universal time in the current article.
2538 If TYPE is `local', convert to local time; if it is `lapsed', output
2539 how much time has lapsed since DATE. For `lapsed', the value of
2540 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2541 should replace the \"Date:\" one, or should be added below it."
2542 (interactive (list 'ut t))
2543 (let* ((header (or header
2544 (message-fetch-field "date")
2546 (tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2549 ((not gnus-article-date-lapsed-new-header)
2555 (date (if (vectorp header) (mail-header-date header)
2557 (inhibit-point-motion-hooks t)
2562 (article-narrow-to-head)
2563 (when (re-search-forward tdate-regexp nil t)
2564 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2565 date (or (get-text-property (gnus-point-at-bol)
2568 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
2570 (when (and date (not (string= date "")))
2571 (goto-char (point-min))
2572 (let ((buffer-read-only nil))
2573 ;; Delete any old Date headers.
2574 (while (re-search-forward date-regexp nil t)
2576 (delete-region (progn (beginning-of-line) (point))
2577 (progn (forward-line 1) (point)))
2578 (delete-region (progn (beginning-of-line) (point))
2579 (progn (end-of-line) (point)))
2580 (setq pos (point))))
2581 (when (and (not pos) (re-search-forward tdate-regexp nil t))
2583 (if pos (goto-char pos))
2584 (insert (article-make-date-line date (or type 'ut)))
2590 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2591 (put-text-property (match-beginning 1) (1+ (match-end 1))
2592 'original-date date)
2593 (put-text-property (match-beginning 1) (1+ (match-end 1))
2595 (put-text-property (match-beginning 2) (match-end 2)
2598 (defun article-make-date-line (date type)
2599 "Return a DATE line of TYPE."
2600 (unless (memq type '(local ut original user iso8601 lapsed english))
2601 (error "Unknown conversion type: %s" type))
2603 (let ((time (date-to-time date)))
2605 ;; Convert to the local timezone.
2607 (let ((tz (car (current-time-zone time))))
2608 (format "Date: %s %s%02d%02d" (current-time-string time)
2609 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2610 (/ (% (abs tz) 3600) 60))))
2611 ;; Convert to Universal Time.
2614 (current-time-string
2615 (let* ((e (parse-time-string date))
2616 (tm (apply 'encode-time e))
2618 (ls (- (cadr tm) (car (current-time-zone time)))))
2619 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2620 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2623 ;; Get the original date from the article.
2624 ((eq type 'original)
2625 (concat "Date: " (if (string-match "\n+$" date)
2626 (substring date 0 (match-beginning 0))
2628 ;; Let the user define the format.
2630 (let ((format (or (condition-case nil
2631 (with-current-buffer gnus-summary-buffer
2632 gnus-article-time-format)
2634 gnus-article-time-format)))
2635 (if (gnus-functionp format)
2636 (funcall format time)
2637 (concat "Date: " (format-time-string format time)))))
2640 (let ((tz (car (current-time-zone time))))
2643 (format-time-string "%Y%m%dT%H%M%S" time)
2644 (format "%s%02d%02d"
2645 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2646 (/ (% (abs tz) 3600) 60)))))
2647 ;; Do an X-Sent lapsed format.
2649 ;; If the date is seriously mangled, the timezone functions are
2650 ;; liable to bug out, so we ignore all errors.
2651 (let* ((now (current-time))
2652 (real-time (subtract-time now time))
2653 (real-sec (and real-time
2654 (+ (* (float (car real-time)) 65536)
2656 (sec (and real-time (abs real-sec)))
2666 ;; This is a bit convoluted, but basically we go
2667 ;; through the time units for years, weeks, etc,
2668 ;; and divide things to see whether that results
2669 ;; in positive answers.
2672 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2673 ;; The (remaining) seconds are too few to
2674 ;; be divided into this time unit.
2676 ;; It's big enough, so we output it.
2677 (setq sec (- sec (* num (cdr unit))))
2679 (concat (if prev ", " "") (int-to-string
2681 " " (symbol-name (car unit))
2682 (if (> num 1) "s" ""))
2684 article-time-units "")
2685 ;; If dates are odd, then it might appear like the
2686 ;; article was sent in the future.
2689 " in the future"))))))
2690 ;; Display the date in proper English
2692 (let ((dtime (decode-time time)))
2695 (number-to-string (nth 3 dtime))
2696 (let ((digit (% (nth 3 dtime) 10)))
2698 ((memq (nth 3 dtime) '(11 12 13)) "th")
2704 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2706 (number-to-string (nth 5 dtime))
2708 (format "%02d" (nth 2 dtime))
2710 (format "%02d" (nth 1 dtime)))))))
2712 (format "Date: %s (from Gnus)" date))))
2714 (defun article-date-local (&optional highlight)
2715 "Convert the current article date to the local timezone."
2716 (interactive (list t))
2717 (article-date-ut 'local highlight))
2719 (defun article-date-english (&optional highlight)
2720 "Convert the current article date to something that is proper English."
2721 (interactive (list t))
2722 (article-date-ut 'english highlight))
2724 (defun article-date-original (&optional highlight)
2725 "Convert the current article date to what it was originally.
2726 This is only useful if you have used some other date conversion
2727 function and want to see what the date was before converting."
2728 (interactive (list t))
2729 (article-date-ut 'original highlight))
2731 (defun article-date-lapsed (&optional highlight)
2732 "Convert the current article date to time lapsed since it was sent."
2733 (interactive (list t))
2734 (article-date-ut 'lapsed highlight))
2736 (defun article-update-date-lapsed ()
2737 "Function to be run from a timer to update the lapsed time line."
2738 (let (deactivate-mark)
2743 (set-buffer (window-buffer w))
2744 (when (eq major-mode 'gnus-article-mode)
2745 (goto-char (point-min))
2746 (when (re-search-forward "^X-Sent:" nil t)
2747 (article-date-lapsed t))))
2750 (defun gnus-start-date-timer (&optional n)
2751 "Start a timer to update the X-Sent header in the article buffers.
2752 The numerical prefix says how frequently (in seconds) the function
2757 (gnus-stop-date-timer)
2758 (setq article-lapsed-timer
2759 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2761 (defun gnus-stop-date-timer ()
2762 "Stop the X-Sent timer."
2764 (when article-lapsed-timer
2765 (nnheader-cancel-timer article-lapsed-timer)
2766 (setq article-lapsed-timer nil)))
2768 (defun article-date-user (&optional highlight)
2769 "Convert the current article date to the user-defined format.
2770 This format is defined by the `gnus-article-time-format' variable."
2771 (interactive (list t))
2772 (article-date-ut 'user highlight))
2774 (defun article-date-iso8601 (&optional highlight)
2775 "Convert the current article date to ISO8601."
2776 (interactive (list t))
2777 (article-date-ut 'iso8601 highlight))
2779 ;; (defun article-show-all ()
2780 ;; "Show all hidden text in the article buffer."
2783 ;; (let ((buffer-read-only nil))
2784 ;; (gnus-article-unhide-text (point-min) (point-max)))))
2786 (defun article-remove-leading-whitespace ()
2787 "Remove excessive whitespace from all headers."
2791 (let ((buffer-read-only nil))
2792 (article-narrow-to-head)
2793 (goto-char (point-min))
2794 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
2795 (delete-region (match-beginning 1) (match-end 1)))))))
2797 (defun article-emphasize (&optional arg)
2798 "Emphasize text according to `gnus-emphasis-alist'."
2799 (interactive (gnus-article-hidden-arg))
2800 (unless (gnus-article-check-hidden-text 'emphasis arg)
2804 (with-current-buffer gnus-summary-buffer
2805 gnus-article-emphasis-alist)
2807 gnus-emphasis-alist))
2808 (buffer-read-only nil)
2809 (props (append '(article-type emphasis)
2810 gnus-hidden-properties))
2811 regexp elem beg invisible visible face)
2814 (while (setq elem (pop alist))
2816 (setq regexp (car elem)
2817 invisible (nth 1 elem)
2818 visible (nth 2 elem)
2820 (while (re-search-forward regexp nil t)
2821 (when (and (match-beginning visible) (match-beginning invisible))
2822 (gnus-article-hide-text
2823 (match-beginning invisible) (match-end invisible) props)
2824 (gnus-article-unhide-text-type
2825 (match-beginning visible) (match-end visible) 'emphasis)
2826 (gnus-put-overlay-excluding-newlines
2827 (match-beginning visible) (match-end visible) 'face face)
2828 (gnus-add-wash-type 'emphasis)
2829 (goto-char (match-end invisible)))))))))
2831 (defun gnus-article-setup-highlight-words (&optional highlight-words)
2832 "Setup newsgroup emphasis alist."
2833 (unless gnus-article-emphasis-alist
2834 (let ((name (and gnus-newsgroup-name
2835 (gnus-group-real-name gnus-newsgroup-name))))
2836 (make-local-variable 'gnus-article-emphasis-alist)
2837 (setq gnus-article-emphasis-alist
2839 (let ((alist gnus-group-highlight-words-alist) elem highlight)
2840 (while (setq elem (pop alist))
2841 (when (and name (string-match (car elem) name))
2843 highlight (copy-sequence (cdr elem)))))
2845 (copy-sequence highlight-words)
2846 (if gnus-newsgroup-name
2847 (copy-sequence (gnus-group-find-parameter
2848 gnus-newsgroup-name 'highlight-words t)))
2849 gnus-emphasis-alist)))))
2852 (defvar gnus-summary-article-menu)
2853 (defvar gnus-summary-post-menu))
2855 ;;; Saving functions.
2857 (defun gnus-article-save (save-buffer file &optional num)
2858 "Save the currently selected article."
2859 (unless gnus-save-all-headers
2860 ;; Remove headers according to `gnus-saved-headers'.
2861 (let ((gnus-visible-headers
2862 (or gnus-saved-headers gnus-visible-headers))
2863 (gnus-article-buffer save-buffer))
2865 (set-buffer save-buffer)
2866 (article-hide-headers 1 t))))
2867 (save-window-excursion
2868 (if (not gnus-default-article-saver)
2869 (error "No default saver is defined")
2870 ;; !!! Magic! The saving functions all save
2871 ;; `gnus-save-article-buffer' (or so they think), but we
2872 ;; bind that variable to our save-buffer.
2873 (set-buffer gnus-article-buffer)
2874 (let* ((gnus-save-article-buffer save-buffer)
2877 ((not gnus-prompt-before-saving) 'default)
2878 ((eq gnus-prompt-before-saving 'always) nil)
2880 (gnus-number-of-articles-to-be-saved
2881 (when (eq gnus-prompt-before-saving t)
2883 (set-buffer gnus-article-current-summary)
2884 (funcall gnus-default-article-saver filename)))))
2886 (defun gnus-read-save-file-name (prompt &optional filename
2887 function group headers variable)
2889 (funcall function group headers (symbol-value variable)))
2894 ((eq filename 'default)
2900 (let* ((split-name (gnus-get-split-value gnus-split-methods))
2903 (if (and gnus-number-of-articles-to-be-saved
2904 (> gnus-number-of-articles-to-be-saved 1))
2905 (format "these %d articles"
2906 gnus-number-of-articles-to-be-saved)
2909 ;; Let the split methods have their say.
2911 ;; No split name was found.
2914 (concat prompt " (default "
2915 (file-name-nondirectory default-name) ") ")
2916 (file-name-directory default-name)
2918 ;; A single group name is returned.
2919 ((stringp split-name)
2921 (funcall function split-name headers
2922 (symbol-value variable)))
2924 (concat prompt " (default "
2925 (file-name-nondirectory default-name) ") ")
2926 (file-name-directory default-name)
2928 ;; A single split name was found
2929 ((= 1 (length split-name))
2930 (let* ((name (expand-file-name
2932 gnus-article-save-directory))
2933 (dir (cond ((file-directory-p name)
2934 (file-name-as-directory name))
2935 ((file-exists-p name) name)
2936 (t gnus-article-save-directory))))
2938 (concat prompt " (default " name ") ")
2940 ;; A list of splits was found.
2942 (setq split-name (nreverse split-name))
2944 (let ((file-name-history
2945 (nconc split-name file-name-history)))
2949 (concat prompt " (`M-p' for defaults) ")
2950 gnus-article-save-directory
2952 gnus-article-save-directory)))
2953 (car (push result file-name-history)))))))
2954 ;; Create the directory.
2955 (gnus-make-directory (file-name-directory file))
2956 ;; If we have read a directory, we append the default file name.
2957 (when (file-directory-p file)
2958 (setq file (expand-file-name (file-name-nondirectory
2960 (file-name-as-directory file))))
2961 ;; Possibly translate some characters.
2962 (nnheader-translate-file-chars file))))))
2963 (gnus-make-directory (file-name-directory result))
2964 (set variable result)))
2966 (defun gnus-article-archive-name (group)
2967 "Return the first instance of an \"Archive-name\" in the current buffer."
2968 (let ((case-fold-search t))
2969 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
2970 (nnheader-concat gnus-article-save-directory
2971 (match-string 1)))))
2973 (defun gnus-article-nndoc-name (group)
2974 "If GROUP is an nndoc group, return the name of the parent group."
2975 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
2976 (gnus-group-get-parameter group 'save-article-group)))
2978 (defun gnus-summary-save-in-rmail (&optional filename)
2979 "Append this article to Rmail file.
2980 Optional argument FILENAME specifies file name.
2981 Directory to save to is default to `gnus-article-save-directory'."
2982 (setq filename (gnus-read-save-file-name
2983 "Save %s in rmail file:" filename
2984 gnus-rmail-save-name gnus-newsgroup-name
2985 gnus-current-headers 'gnus-newsgroup-last-rmail))
2986 (gnus-eval-in-buffer-window gnus-save-article-buffer
2990 (gnus-output-to-rmail filename))))
2993 (defun gnus-summary-save-in-mail (&optional filename)
2994 "Append this article to Unix mail file.
2995 Optional argument FILENAME specifies file name.
2996 Directory to save to is default to `gnus-article-save-directory'."
2997 (setq filename (gnus-read-save-file-name
2998 "Save %s in Unix mail file:" filename
2999 gnus-mail-save-name gnus-newsgroup-name
3000 gnus-current-headers 'gnus-newsgroup-last-mail))
3001 (gnus-eval-in-buffer-window gnus-save-article-buffer
3005 (if (and (file-readable-p filename)
3006 (mail-file-babyl-p filename))
3007 (rmail-output-to-rmail-file filename t)
3008 (gnus-output-to-mail filename)))))
3011 (defun gnus-summary-save-in-file (&optional filename overwrite)
3012 "Append this article to file.
3013 Optional argument FILENAME specifies file name.
3014 Directory to save to is default to `gnus-article-save-directory'."
3015 (setq filename (gnus-read-save-file-name
3016 "Save %s in file:" filename
3017 gnus-file-save-name gnus-newsgroup-name
3018 gnus-current-headers 'gnus-newsgroup-last-file))
3019 (gnus-eval-in-buffer-window gnus-save-article-buffer
3023 (when (and overwrite
3024 (file-exists-p filename))
3025 (delete-file filename))
3026 (gnus-output-to-file filename))))
3029 (defun gnus-summary-write-to-file (&optional filename)
3030 "Write this article to a file, overwriting it if the file exists.
3031 Optional argument FILENAME specifies file name.
3032 The directory to save in defaults to `gnus-article-save-directory'."
3033 (gnus-summary-save-in-file nil t))
3035 (defun gnus-summary-save-body-in-file (&optional filename)
3036 "Append this article body to a file.
3037 Optional argument FILENAME specifies file name.
3038 The directory to save in defaults to `gnus-article-save-directory'."
3039 (setq filename (gnus-read-save-file-name
3040 "Save %s body in file:" filename
3041 gnus-file-save-name gnus-newsgroup-name
3042 gnus-current-headers 'gnus-newsgroup-last-file))
3043 (gnus-eval-in-buffer-window gnus-save-article-buffer
3047 (when (article-goto-body)
3048 (narrow-to-region (point) (point-max)))
3049 (gnus-output-to-file filename))))
3052 (defun gnus-summary-save-in-pipe (&optional command)
3053 "Pipe this article to subprocess."
3055 (cond ((and (eq command 'default)
3056 gnus-last-shell-command)
3057 gnus-last-shell-command)
3062 "Shell command on %s: "
3063 (if (and gnus-number-of-articles-to-be-saved
3064 (> gnus-number-of-articles-to-be-saved 1))
3065 (format "these %d articles"
3066 gnus-number-of-articles-to-be-saved)
3068 gnus-last-shell-command))))
3069 (when (string-equal command "")
3070 (if gnus-last-shell-command
3071 (setq command gnus-last-shell-command)
3072 (error "A command is required")))
3073 (gnus-eval-in-buffer-window gnus-article-buffer
3076 (shell-command-on-region (point-min) (point-max) command nil)))
3077 (setq gnus-last-shell-command command))
3079 (defun gnus-summary-pipe-to-muttprint (&optional command)
3080 "Pipe this article to muttprint."
3081 (setq command (read-string
3082 "Print using command: " gnus-summary-muttprint-program
3083 nil gnus-summary-muttprint-program))
3084 (gnus-summary-save-in-pipe command))
3086 ;;; Article file names when saving.
3088 (defun gnus-capitalize-newsgroup (newsgroup)
3089 "Capitalize NEWSGROUP name."
3090 (when (not (zerop (length newsgroup)))
3091 (concat (char-to-string (upcase (aref newsgroup 0)))
3092 (substring newsgroup 1))))
3094 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3095 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3096 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3097 Otherwise, it is like ~/News/news/group/num."
3100 (concat (if (gnus-use-long-file-name 'not-save)
3101 (gnus-capitalize-newsgroup newsgroup)
3102 (gnus-newsgroup-directory-form newsgroup))
3103 "/" (int-to-string (mail-header-number headers)))
3104 gnus-article-save-directory)))
3106 (string-equal (file-name-directory default)
3107 (file-name-directory last-file))
3108 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3110 (or last-file default))))
3112 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3113 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3114 If variable `gnus-use-long-file-name' is non-nil, it is
3115 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3118 (concat (if (gnus-use-long-file-name 'not-save)
3120 (gnus-newsgroup-directory-form newsgroup))
3121 "/" (int-to-string (mail-header-number headers)))
3122 gnus-article-save-directory)))
3124 (string-equal (file-name-directory default)
3125 (file-name-directory last-file))
3126 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3128 (or last-file default))))
3130 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3131 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3132 If variable `gnus-use-long-file-name' is non-nil, it is
3133 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3136 (if (gnus-use-long-file-name 'not-save)
3139 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3141 gnus-article-save-directory)))
3143 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3144 "Generate file name from sender."
3145 (let ((from (mail-header-from headers)))
3147 (if (and from (string-match "\\([^ <]+\\)@" from))
3148 (match-string 1 from)
3150 gnus-article-save-directory)))
3152 (defun article-verify-x-pgp-sig ()
3155 (if (gnus-buffer-live-p gnus-original-article-buffer)
3156 (let ((sig (with-current-buffer gnus-original-article-buffer
3157 (gnus-fetch-field "X-PGP-Sig")))
3161 (mml2015-clear-verify-function))
3163 (insert-buffer gnus-original-article-buffer)
3164 (setq items (split-string sig))
3165 (message-narrow-to-head)
3166 (let ((inhibit-point-motion-hooks t)
3167 (case-fold-search t))
3168 ;; Don't verify multiple headers.
3169 (setq headers (mapconcat (lambda (header)
3171 (mail-fetch-field header) "\n"))
3172 (split-string (nth 1 items) ",") "")))
3173 (delete-region (point-min) (point-max))
3174 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3175 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3180 (if (looking-at "^-")
3183 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3184 (insert "Version: " (car items) "\n\n")
3185 (insert (mapconcat 'identity (cddr items) "\n"))
3186 (insert "\n-----END PGP SIGNATURE-----\n")
3187 (let ((mm-security-handle (list (format "multipart/signed"))))
3188 (mml2015-clean-buffer)
3189 (let ((coding-system-for-write (or gnus-newsgroup-charset
3191 (funcall (mml2015-clear-verify-function)))
3193 (or (mm-handle-multipart-ctl-parameter
3194 mm-security-handle 'gnus-details)
3195 (mm-handle-multipart-ctl-parameter
3196 mm-security-handle 'gnus-info)))))
3198 (let (buffer-read-only bface eface)
3200 (message-narrow-to-head)
3201 (goto-char (point-max))
3203 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3204 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3205 (message-remove-header "X-Gnus-PGP-Verify")
3206 (if (re-search-forward "^X-PGP-Sig:" nil t)
3208 (goto-char (point-max)))
3209 (narrow-to-region (point) (point))
3210 (insert "X-Gnus-PGP-Verify: " info "\n")
3211 (goto-char (point-min))
3214 (if (not (looking-at "^[ \t]"))
3218 (goto-char (point-min))
3219 (when (looking-at "\\([^:]+\\): *")
3220 (put-text-property (match-beginning 1) (1+ (match-end 1))
3222 (put-text-property (match-end 0) (point-max)
3223 'face eface)))))))))
3225 (defun article-verify-cancel-lock ()
3226 "Verify Cancel-Lock header."
3228 (if (gnus-buffer-live-p gnus-original-article-buffer)
3229 (canlock-verify gnus-original-article-buffer)))
3236 (setq afunc (car func)
3239 gfunc (intern (format "gnus-%s" func))))
3241 (when (fboundp afunc)
3242 `(lambda (&optional interactive &rest args)
3243 ,(documentation afunc t)
3244 (interactive (list t))
3246 (set-buffer gnus-article-buffer)
3248 (call-interactively ',afunc)
3249 (apply ',afunc args))))))))
3250 '(article-hide-headers
3251 article-verify-x-pgp-sig
3252 article-verify-cancel-lock
3253 article-hide-boring-headers
3254 article-treat-overstrike
3255 article-fill-long-lines
3256 article-capitalize-sentences
3258 article-remove-leading-whitespace
3259 article-display-x-face
3260 article-de-quoted-unreadable
3261 article-de-base64-unreadable
3264 article-unsplit-urls
3265 article-hide-list-identifiers
3267 article-strip-banner
3270 article-hide-signature
3271 article-strip-headers-in-body
3272 article-remove-trailing-blank-lines
3273 article-strip-leading-blank-lines
3274 article-strip-multiple-blank-lines
3275 article-strip-leading-space
3276 article-strip-trailing-space
3277 article-strip-blank-lines
3278 article-strip-all-blank-lines
3280 article-date-english
3281 article-date-iso8601
3282 article-date-original
3284 article-decode-mime-words
3285 article-decode-charset
3286 article-decode-encoded-words
3290 article-treat-dumbquotes
3291 article-normalize-headers
3292 ;; (article-show-all . gnus-article-show-all-headers)
3296 ;;; Gnus article mode
3299 (put 'gnus-article-mode 'mode-class 'special)
3301 (set-keymap-parent gnus-article-mode-map widget-keymap)
3303 (gnus-define-keys gnus-article-mode-map
3304 " " gnus-article-goto-next-page
3305 "\177" gnus-article-goto-prev-page
3306 [delete] gnus-article-goto-prev-page
3307 [backspace] gnus-article-goto-prev-page
3308 "\C-c^" gnus-article-refer-article
3309 "h" gnus-article-show-summary
3310 "s" gnus-article-show-summary
3311 "\C-c\C-m" gnus-article-mail
3312 "?" gnus-article-describe-briefly
3313 "e" gnus-summary-edit-article
3314 "<" beginning-of-buffer
3316 "\C-c\C-i" gnus-info-find-node
3318 "R" gnus-article-reply-with-original
3319 "F" gnus-article-followup-with-original
3320 "\C-hk" gnus-article-describe-key
3321 "\C-hc" gnus-article-describe-key-briefly
3323 "\C-d" gnus-article-read-summary-keys
3324 "\M-*" gnus-article-read-summary-keys
3325 "\M-#" gnus-article-read-summary-keys
3326 "\M-^" gnus-article-read-summary-keys
3327 "\M-g" gnus-article-read-summary-keys)
3329 (substitute-key-definition
3330 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3332 (defun gnus-article-make-menu-bar ()
3333 (unless (boundp 'gnus-article-commands-menu)
3334 (gnus-summary-make-menu-bar))
3335 (gnus-turn-off-edit-menu 'article)
3336 (unless (boundp 'gnus-article-article-menu)
3338 gnus-article-article-menu gnus-article-mode-map ""
3340 ["Scroll forwards" gnus-article-goto-next-page t]
3341 ["Scroll backwards" gnus-article-goto-prev-page t]
3342 ["Show summary" gnus-article-show-summary t]
3343 ["Fetch Message-ID at point" gnus-article-refer-article t]
3344 ["Mail to address at point" gnus-article-mail t]
3345 ["Send a bug report" gnus-bug t]))
3348 gnus-article-treatment-menu gnus-article-mode-map ""
3349 ;; Fixme: this should use :active (and maybe :visible).
3351 ["Hide headers" gnus-article-hide-headers t]
3352 ["Hide signature" gnus-article-hide-signature t]
3353 ["Hide citation" gnus-article-hide-citation t]
3354 ["Treat overstrike" gnus-article-treat-overstrike t]
3355 ["Remove carriage return" gnus-article-remove-cr t]
3356 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3357 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3358 ["Remove base64" gnus-article-de-base64-unreadable t]
3359 ["Treat html" gnus-article-wash-html t]
3360 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3361 ["Decode HZ" gnus-article-decode-HZ t]))
3363 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3365 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3367 (gnus-run-hooks 'gnus-article-menu-hook)))
3369 ;; Fixme: do something for the Emacs tool bar in Article mode a la
3372 (defun gnus-article-mode ()
3373 "Major mode for displaying an article.
3375 All normal editing commands are switched off.
3377 The following commands are available in addition to all summary mode
3379 \\<gnus-article-mode-map>
3380 \\[gnus-article-next-page]\t Scroll the article one page forwards
3381 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3382 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3383 \\[gnus-article-show-summary]\t Display the summary buffer
3384 \\[gnus-article-mail]\t Send a reply to the address near point
3385 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3386 \\[gnus-info-find-node]\t Go to the Gnus info node"
3388 (gnus-simplify-mode-line)
3389 (setq mode-name "Article")
3390 (setq major-mode 'gnus-article-mode)
3391 (make-local-variable 'minor-mode-alist)
3392 (use-local-map gnus-article-mode-map)
3393 (when (gnus-visual-p 'article-menu 'menu)
3394 (gnus-article-make-menu-bar))
3395 (gnus-update-format-specifications nil 'article-mode)
3396 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3397 (make-local-variable 'gnus-page-broken)
3398 (make-local-variable 'gnus-button-marker-list)
3399 (make-local-variable 'gnus-article-current-summary)
3400 (make-local-variable 'gnus-article-mime-handles)
3401 (make-local-variable 'gnus-article-decoded-p)
3402 (make-local-variable 'gnus-article-mime-handle-alist)
3403 (make-local-variable 'gnus-article-wash-types)
3404 (make-local-variable 'gnus-article-image-alist)
3405 (make-local-variable 'gnus-article-charset)
3406 (make-local-variable 'gnus-article-ignored-charsets)
3407 (gnus-set-default-directory)
3408 (buffer-disable-undo)
3409 (setq buffer-read-only t)
3410 (set-syntax-table gnus-article-mode-syntax-table)
3411 (mm-enable-multibyte)
3412 (gnus-run-hooks 'gnus-article-mode-hook))
3414 (defun gnus-article-setup-buffer ()
3415 "Initialize the article buffer."
3416 (let* ((name (if gnus-single-article-buffer "*Article*"
3417 (concat "*Article " gnus-newsgroup-name "*")))
3419 (progn (string-match "\\*Article" name)
3420 (concat " *Original Article"
3421 (substring name (match-end 0))))))
3422 (setq gnus-article-buffer name)
3423 (setq gnus-original-article-buffer original)
3424 (setq gnus-article-mime-handle-alist nil)
3425 ;; This might be a variable local to the summary buffer.
3426 (unless gnus-single-article-buffer
3428 (set-buffer gnus-summary-buffer)
3429 (setq gnus-article-buffer name)
3430 (setq gnus-original-article-buffer original)
3431 (gnus-set-global-variables)))
3432 (gnus-article-setup-highlight-words)
3433 ;; Init original article buffer.
3435 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3436 (mm-enable-multibyte)
3437 (setq major-mode 'gnus-original-article-mode)
3438 (make-local-variable 'gnus-original-article))
3439 (if (get-buffer name)
3442 (when gnus-article-mime-handles
3443 (mm-destroy-parts gnus-article-mime-handles)
3444 (setq gnus-article-mime-handles nil))
3445 ;; Set it to nil in article-buffer!
3446 (setq gnus-article-mime-handle-alist nil)
3447 (buffer-disable-undo)
3448 (setq buffer-read-only t)
3449 (unless (eq major-mode 'gnus-article-mode)
3450 (gnus-article-mode))
3453 (set-buffer (gnus-get-buffer-create name))
3455 (make-local-variable 'gnus-summary-buffer)
3456 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3457 (current-buffer)))))
3459 ;; Set article window start at LINE, where LINE is the number of lines
3460 ;; from the head of the article.
3461 (defun gnus-article-set-window-start (&optional line)
3463 (gnus-get-buffer-window gnus-article-buffer t)
3465 (set-buffer gnus-article-buffer)
3466 (goto-char (point-min))
3469 (gnus-message 6 "Moved to bookmark")
3470 (search-forward "\n\n" nil t)
3474 (defun gnus-article-prepare (article &optional all-headers header)
3475 "Prepare ARTICLE in article mode buffer.
3476 ARTICLE should either be an article number or a Message-ID.
3477 If ARTICLE is an id, HEADER should be the article headers.
3478 If ALL-HEADERS is non-nil, no headers are hidden."
3480 ;; Make sure we start in a summary buffer.
3481 (unless (eq major-mode 'gnus-summary-mode)
3482 (set-buffer gnus-summary-buffer))
3483 (setq gnus-summary-buffer (current-buffer))
3484 (let* ((gnus-article (if header (mail-header-number header) article))
3485 (summary-buffer (current-buffer))
3486 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3487 (group gnus-newsgroup-name)
3490 (gnus-article-setup-buffer)
3491 (set-buffer gnus-article-buffer)
3492 ;; Deactivate active regions.
3493 (when (and (boundp 'transient-mark-mode)
3494 transient-mark-mode)
3495 (setq mark-active nil))
3496 (if (not (setq result (let ((buffer-read-only nil))
3497 (gnus-request-article-this-buffer
3499 ;; There is no such article.
3501 (when (and (numberp article)
3502 (not (memq article gnus-newsgroup-sparse)))
3503 (setq gnus-article-current
3504 (cons gnus-newsgroup-name article))
3505 (set-buffer gnus-summary-buffer)
3506 (setq gnus-current-article article)
3507 (if (eq (gnus-article-mark article) gnus-undownloaded-mark)
3509 (gnus-summary-set-agent-mark article)
3510 (message "Message marked for downloading"))
3511 (gnus-summary-mark-article article gnus-canceled-mark)
3512 (unless (memq article gnus-newsgroup-sparse)
3513 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3514 (if (or (eq result 'pseudo)
3515 (eq result 'nneething))
3518 (set-buffer summary-buffer)
3519 (push article gnus-newsgroup-history)
3520 (setq gnus-last-article gnus-current-article
3521 gnus-current-article 0
3522 gnus-current-headers nil
3523 gnus-article-current nil)
3524 (if (eq result 'nneething)
3525 (gnus-configure-windows 'summary)
3526 (gnus-configure-windows 'article))
3527 (gnus-set-global-variables))
3528 (let ((gnus-article-mime-handle-alist-1
3529 gnus-article-mime-handle-alist))
3530 (gnus-set-mode-line 'article)))
3531 ;; The result from the `request' was an actual article -
3532 ;; or at least some text that is now displayed in the
3534 (when (and (numberp article)
3535 (not (eq article gnus-current-article)))
3536 ;; Seems like a new article has been selected.
3537 ;; `gnus-current-article' must be an article number.
3539 (set-buffer summary-buffer)
3540 (push article gnus-newsgroup-history)
3541 (setq gnus-last-article gnus-current-article
3542 gnus-current-article article
3543 gnus-current-headers
3544 (gnus-summary-article-header gnus-current-article)
3545 gnus-article-current
3546 (cons gnus-newsgroup-name gnus-current-article))
3547 (unless (vectorp gnus-current-headers)
3548 (setq gnus-current-headers nil))
3549 (gnus-summary-goto-subject gnus-current-article)
3550 (when (gnus-summary-show-thread)
3551 ;; If the summary buffer really was folded, the
3552 ;; previous goto may not actually have gone to
3553 ;; the right article, but the thread root instead.
3555 (gnus-summary-goto-subject gnus-current-article))
3556 (gnus-run-hooks 'gnus-mark-article-hook)
3557 (gnus-set-mode-line 'summary)
3558 (when (gnus-visual-p 'article-highlight 'highlight)
3559 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3560 ;; Set the global newsgroup variables here.
3561 (gnus-set-global-variables)
3562 (setq gnus-have-all-headers
3563 (or all-headers gnus-show-all-headers))))
3565 (gnus-configure-windows 'article))
3566 (when (or (numberp article)
3568 (gnus-article-prepare-display)
3570 (goto-char (point-min))
3571 (setq gnus-page-broken
3572 (when gnus-break-pages
3573 (gnus-narrow-to-page)
3575 (let ((gnus-article-mime-handle-alist-1
3576 gnus-article-mime-handle-alist))
3577 (gnus-set-mode-line 'article))
3581 (set-window-point (get-buffer-window (current-buffer)) (point))
3582 (gnus-configure-windows 'article)
3586 (defun gnus-article-prepare-display ()
3587 "Make the current buffer look like a nice article."
3588 ;; Hooks for getting information from the article.
3589 ;; This hook must be called before being narrowed.
3590 (let ((gnus-article-buffer (current-buffer))
3592 (unless (eq major-mode 'gnus-article-mode)
3593 (gnus-article-mode))
3594 (setq buffer-read-only nil
3595 gnus-article-wash-types nil
3596 gnus-article-image-alist nil)
3597 (gnus-run-hooks 'gnus-tmp-internal-hook)
3598 (when gnus-display-mime-function
3599 (funcall gnus-display-mime-function))
3600 (gnus-run-hooks 'gnus-article-prepare-hook)))
3603 ;;; Gnus MIME viewing functions
3606 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3607 "Format of the MIME buttons.
3609 Valid specifiers include:
3611 %T MIME type, along with additional info
3612 %n The `name' parameter
3613 %d The description, if any
3614 %l The length of the encoded part
3615 %p The part identifier number
3616 %e Dots if the part isn't displayed
3618 General format specifiers can also be used. See
3619 (gnus)Formatting Variables.")
3621 (defvar gnus-mime-button-line-format-alist
3622 '((?t gnus-tmp-type ?s)
3623 (?T gnus-tmp-type-long ?s)
3624 (?n gnus-tmp-name ?s)
3625 (?d gnus-tmp-description ?s)
3627 (?l gnus-tmp-length ?d)
3628 (?e gnus-tmp-dots ?s)))
3630 (defvar gnus-mime-button-commands
3631 '((gnus-article-press-button "\r" "Toggle Display")
3632 (gnus-mime-view-part "v" "View Interactively...")
3633 (gnus-mime-view-part-as-type "t" "View As Type...")
3634 (gnus-mime-view-part-as-charset "C" "View As charset...")
3635 (gnus-mime-save-part "o" "Save...")
3636 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
3637 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
3638 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
3639 (gnus-mime-view-part-internally "E" "View Internally")
3640 (gnus-mime-view-part-externally "e" "View Externally")
3641 (gnus-mime-print-part "p" "Print")
3642 (gnus-mime-pipe-part "|" "Pipe To Command...")
3643 (gnus-mime-action-on-part "." "Take action on the part")))
3645 (defun gnus-article-mime-part-status ()
3646 (if gnus-article-mime-handle-alist-1
3647 (if (eq 1 (length gnus-article-mime-handle-alist-1))
3649 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
3652 (defvar gnus-mime-button-map
3653 (let ((map (make-sparse-keymap)))
3654 (unless (>= (string-to-number emacs-version) 21)
3655 ;; XEmacs doesn't care.
3656 (set-keymap-parent map gnus-article-mode-map))
3657 (define-key map gnus-mouse-2 'gnus-article-push-button)
3658 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
3659 (dolist (c gnus-mime-button-commands)
3660 (define-key map (cadr c) (car c)))
3663 (defun gnus-mime-button-menu (event)
3664 "Construct a context-sensitive menu of MIME commands."
3666 (save-window-excursion
3667 (let ((pos (event-start event)))
3668 (select-window (posn-window pos))
3669 (goto-char (posn-point pos))
3670 (gnus-article-check-buffer)
3671 (let ((response (x-popup-menu
3673 ("" ,@(mapcar (lambda (c)
3674 (cons (caddr c) (car c)))
3675 gnus-mime-button-commands))))))
3677 (call-interactively response))))))
3679 (defun gnus-mime-view-all-parts (&optional handles)
3680 "View all the MIME parts."
3682 (save-current-buffer
3683 (set-buffer gnus-article-buffer)
3684 (let ((handles (or handles gnus-article-mime-handles))
3685 (mail-parse-charset gnus-newsgroup-charset)
3686 (mail-parse-ignored-charsets
3687 (with-current-buffer gnus-summary-buffer
3688 gnus-newsgroup-ignored-charsets)))
3690 (mm-remove-parts handles)
3691 (goto-char (point-min))
3692 (or (search-forward "\n\n") (goto-char (point-max)))
3693 (let (buffer-read-only)
3694 (delete-region (point) (point-max))
3695 (mm-display-parts handles))))))
3697 (defun gnus-mime-save-part-and-strip ()
3698 "Save the MIME part under point then replace it with an external body."
3700 (gnus-article-check-buffer)
3701 (let* ((data (get-text-property (point) 'gnus-data))
3703 (handles gnus-article-mime-handles))
3704 (if (mm-multiple-handles gnus-article-mime-handles)
3705 (error "This function is not implemented"))
3706 (setq file (and data (mm-save-part data)))
3708 (with-current-buffer (mm-handle-buffer data)
3710 (insert "Content-Type: " (mm-handle-media-type data))
3711 (mml-insert-parameter-string (cdr (mm-handle-type data))
3714 (insert "Content-ID: " (message-make-message-id) "\n")
3715 (insert "Content-Transfer-Encoding: binary\n")
3718 (cdr (mm-make-handle nil
3719 `("message/external-body"
3720 (access-type . "LOCAL-FILE")
3722 (set-buffer gnus-summary-buffer)
3723 (gnus-article-edit-article
3726 (let ((mail-parse-charset (or gnus-article-charset
3727 ',gnus-newsgroup-charset))
3728 (mail-parse-ignored-charsets
3729 (or gnus-article-ignored-charsets
3730 ',gnus-newsgroup-ignored-charsets))
3731 (mbl mml-buffer-list))
3732 (setq mml-buffer-list nil)
3733 (insert-buffer gnus-original-article-buffer)
3734 (mime-to-mml ',handles)
3735 (setq gnus-article-mime-handles nil)
3736 (let ((mbl1 mml-buffer-list))
3737 (setq mml-buffer-list mbl)
3738 (set (make-local-variable 'mml-buffer-list) mbl1))
3739 ;; LOCAL argument of add-hook differs between GNU Emacs
3740 ;; and XEmacs. make-local-hook makes sure they are local.
3741 (make-local-hook 'kill-buffer-hook)
3742 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
3743 `(lambda (no-highlight)
3744 (let ((mail-parse-charset (or gnus-article-charset
3745 ',gnus-newsgroup-charset))
3746 (message-options message-options)
3747 (message-options-set-recipient)
3748 (mail-parse-ignored-charsets
3749 (or gnus-article-ignored-charsets
3750 ',gnus-newsgroup-ignored-charsets)))
3752 (mml-destroy-buffers)
3753 (remove-hook 'kill-buffer-hook
3754 'mml-destroy-buffers t)
3755 (kill-local-variable 'mml-buffer-list))
3756 (gnus-summary-edit-article-done
3757 ,(or (mail-header-references gnus-current-headers) "")
3758 ,(gnus-group-read-only-p)
3759 ,gnus-summary-buffer no-highlight))))))
3761 (defun gnus-mime-save-part ()
3762 "Save the MIME part under point."
3764 (gnus-article-check-buffer)
3765 (let ((data (get-text-property (point) 'gnus-data)))
3767 (mm-save-part data))))
3769 (defun gnus-mime-pipe-part ()
3770 "Pipe the MIME part under point to a process."
3772 (gnus-article-check-buffer)
3773 (let ((data (get-text-property (point) 'gnus-data)))
3775 (mm-pipe-part data))))
3777 (defun gnus-mime-view-part ()
3778 "Interactively choose a viewing method for the MIME part under point."
3780 (gnus-article-check-buffer)
3781 (let ((data (get-text-property (point) 'gnus-data)))
3783 (setq gnus-article-mime-handles
3785 gnus-article-mime-handles (setq data (copy-sequence data))))
3786 (mm-interactively-view-part data))))
3788 (defun gnus-mime-view-part-as-type-internal ()
3789 (gnus-article-check-buffer)
3790 (let* ((name (mail-content-type-get
3791 (mm-handle-type (get-text-property (point) 'gnus-data))
3793 (def-type (and name (mm-default-file-encoding name))))
3794 (and def-type (cons def-type 0))))
3796 (defun gnus-mime-view-part-as-type (&optional mime-type)
3797 "Choose a MIME media type, and view the part as such."
3800 (setq mime-type (completing-read
3801 "View as MIME type: "
3802 (mapcar #'list (mailcap-mime-types))
3804 (gnus-mime-view-part-as-type-internal))))
3805 (gnus-article-check-buffer)
3806 (let ((handle (get-text-property (point) 'gnus-data)))
3809 (mm-make-handle (mm-handle-buffer handle)
3810 (cons mime-type (cdr (mm-handle-type handle)))
3811 (mm-handle-encoding handle)
3812 (mm-handle-undisplayer handle)
3813 (mm-handle-disposition handle)
3814 (mm-handle-description handle)
3816 (mm-handle-id handle)))
3817 (setq gnus-article-mime-handles
3818 (mm-merge-handles gnus-article-mime-handles handle))
3819 (gnus-mm-display-part handle))))
3821 (defun gnus-mime-copy-part (&optional handle)
3822 "Put the MIME part under point into a new buffer."
3824 (gnus-article-check-buffer)
3825 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3826 (contents (and handle (mm-get-part handle)))
3828 (file-name-nondirectory
3830 (mail-content-type-get (mm-handle-type handle) 'name)
3831 (mail-content-type-get (mm-handle-type handle)
3834 (buffer (and base (generate-new-buffer base))))
3836 (switch-to-buffer buffer)
3838 ;; We do it this way to make `normal-mode' set the appropriate mode.
3841 (setq buffer-file-name (expand-file-name base))
3843 (setq buffer-file-name nil))
3844 (goto-char (point-min)))))
3846 (defun gnus-mime-print-part (&optional handle filename)
3847 "Print the MIME part under point."
3848 (interactive (list nil (ps-print-preprint current-prefix-arg)))
3849 (gnus-article-check-buffer)
3850 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3851 (contents (and handle (mm-get-part handle)))
3852 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
3853 (printer (mailcap-mime-info (mm-handle-type handle) "print")))
3858 (with-temp-file file
3860 (call-process shell-file-name nil
3861 (generate-new-buffer " *mm*")
3863 shell-command-switch
3865 printer file (mm-handle-type handle))))
3869 (gnus-print-buffer))
3870 (ps-despool filename)))))
3872 (defun gnus-mime-inline-part (&optional handle arg)
3873 "Insert the MIME part under point into the current buffer."
3874 (interactive (list nil current-prefix-arg))
3875 (gnus-article-check-buffer)
3876 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3881 (if (and (not arg) (mm-handle-undisplayer handle))
3882 (mm-remove-part handle)
3883 (setq contents (mm-get-part handle))
3886 (setq charset (or (mail-content-type-get
3887 (mm-handle-type handle) 'charset)
3888 gnus-newsgroup-charset)))
3890 (if (mm-handle-undisplayer handle)
3891 (mm-remove-part handle))
3894 gnus-summary-show-article-charset-alist))
3895 (mm-read-coding-system "Charset: ")))))
3897 (mm-insert-inline handle
3899 (setq charset (mm-charset-to-coding-system
3901 (not (eq charset 'ascii)))
3902 (mm-decode-coding-string contents charset)
3906 (defun gnus-mime-view-part-as-charset (&optional handle arg)
3907 "Insert the MIME part under point into the current buffer using the
3909 (interactive (list nil current-prefix-arg))
3910 (gnus-article-check-buffer)
3911 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3916 (if (mm-handle-undisplayer handle)
3917 (mm-remove-part handle))
3918 (let ((gnus-newsgroup-charset
3920 gnus-summary-show-article-charset-alist))
3921 (mm-read-coding-system "Charset: ")))
3922 (gnus-newsgroup-ignored-charsets 'gnus-all))
3923 (gnus-article-press-button)))))
3925 (defun gnus-mime-view-part-externally (&optional handle)
3926 "View the MIME part under point with an external viewer."
3928 (gnus-article-check-buffer)
3929 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3930 (mm-user-display-methods nil)
3931 (mm-inlined-types nil)
3932 (mail-parse-charset gnus-newsgroup-charset)
3933 (mail-parse-ignored-charsets
3934 (save-excursion (set-buffer gnus-summary-buffer)
3935 gnus-newsgroup-ignored-charsets)))
3937 (if (mm-handle-undisplayer handle)
3938 (mm-remove-part handle)
3939 (mm-display-part handle)))))
3941 (defun gnus-mime-view-part-internally (&optional handle)
3942 "View the MIME part under point with an internal viewer.
3943 If no internal viewer is available, use an external viewer."
3945 (gnus-article-check-buffer)
3946 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3947 (mm-inlined-types '(".*"))
3948 (mm-inline-large-images t)
3949 (mail-parse-charset gnus-newsgroup-charset)
3950 (mail-parse-ignored-charsets
3951 (save-excursion (set-buffer gnus-summary-buffer)
3952 gnus-newsgroup-ignored-charsets)))
3954 (if (mm-handle-undisplayer handle)
3955 (mm-remove-part handle)
3956 (mm-display-part handle)))))
3958 (defun gnus-mime-action-on-part (&optional action)
3959 "Do something with the MIME attachment at \(point\)."
3961 (list (completing-read "Action: " gnus-mime-action-alist)))
3962 (gnus-article-check-buffer)
3963 (let ((action-pair (assoc action gnus-mime-action-alist)))
3965 (funcall (cdr action-pair)))))
3967 (defun gnus-article-part-wrapper (n function)
3968 (save-current-buffer
3969 (set-buffer gnus-article-buffer)
3970 (when (> n (length gnus-article-mime-handle-alist))
3971 (error "No such part"))
3972 (gnus-article-goto-part n)
3973 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
3974 (funcall function handle))))
3976 (defun gnus-article-pipe-part (n)
3977 "Pipe MIME part N, which is the numerical prefix."
3979 (gnus-article-part-wrapper n 'mm-pipe-part))
3981 (defun gnus-article-save-part (n)
3982 "Save MIME part N, which is the numerical prefix."
3984 (gnus-article-part-wrapper n 'mm-save-part))
3986 (defun gnus-article-interactively-view-part (n)
3987 "View MIME part N interactively, which is the numerical prefix."
3989 (gnus-article-part-wrapper n 'mm-interactively-view-part))
3991 (defun gnus-article-copy-part (n)
3992 "Copy MIME part N, which is the numerical prefix."
3994 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
3996 (defun gnus-article-view-part-as-charset (n)
3997 "Copy MIME part N, which is the numerical prefix."
3999 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4001 (defun gnus-article-view-part-externally (n)
4002 "View MIME part N externally, which is the numerical prefix."
4004 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4006 (defun gnus-article-inline-part (n)
4007 "Inline MIME part N, which is the numerical prefix."
4009 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4011 (defun gnus-article-mime-match-handle-first (condition)
4013 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4014 (while (setq ihandle (pop alist))
4016 ((functionp condition)
4017 (funcall condition (cdr ihandle)))
4018 ((eq condition 'undisplayed)
4019 (not (or (mm-handle-undisplayer (cdr ihandle))
4020 (equal (mm-handle-media-type (cdr ihandle))
4021 "multipart/alternative"))))
4022 ((eq condition 'undisplayed-alternative)
4023 (not (mm-handle-undisplayer (cdr ihandle))))
4025 (gnus-article-goto-part (car ihandle))
4026 (or (not n) (< (car ihandle) n)))
4027 (setq n (car ihandle))))
4031 (defun gnus-article-view-part (&optional n)
4032 "View MIME part N, which is the numerical prefix."
4034 (save-current-buffer
4035 (set-buffer gnus-article-buffer)
4036 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4037 gnus-article-mime-match-handle-function)))
4038 (when (> n (length gnus-article-mime-handle-alist))
4039 (error "No such part"))
4040 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4041 (when (gnus-article-goto-part n)
4042 (if (equal (car handle) "multipart/alternative")
4043 (gnus-article-press-button)
4044 (when (eq (gnus-mm-display-part handle) 'internal)
4045 (gnus-set-window-start)))))))
4047 (defsubst gnus-article-mime-total-parts ()
4048 (if (bufferp (car gnus-article-mime-handles))
4050 (1- (length gnus-article-mime-handles))))
4052 (defun gnus-mm-display-part (handle)
4053 "Display HANDLE and fix MIME button."
4054 (let ((id (get-text-property (point) 'gnus-part))
4059 (let ((window (selected-window))
4060 (mail-parse-charset gnus-newsgroup-charset)
4061 (mail-parse-ignored-charsets
4062 (if (gnus-buffer-live-p gnus-summary-buffer)
4064 (set-buffer gnus-summary-buffer)
4065 gnus-newsgroup-ignored-charsets)
4069 (let ((win (gnus-get-buffer-window (current-buffer) t))
4072 (select-window win))
4075 (if (mm-handle-displayed-p handle)
4076 ;; This will remove the part.
4077 (mm-display-part handle)
4079 (narrow-to-region (point)
4080 (if (eobp) (point) (1+ (point))))
4081 (mm-display-part handle)
4082 ;; We narrow to the part itself and
4083 ;; then call the treatment functions.
4084 (goto-char (point-min))
4086 (narrow-to-region (point) (point-max))
4089 (gnus-article-mime-total-parts)
4090 (mm-handle-media-type handle)))))
4091 (if (window-live-p window)
4092 (select-window window)))))
4094 (delete-region (gnus-point-at-bol) (progn (forward-line 1) (point)))
4095 (gnus-insert-mime-button
4096 handle id (list (mm-handle-displayed-p handle)))
4097 (goto-char point))))
4099 (defun gnus-article-goto-part (n)
4100 "Go to MIME part N."
4101 (let ((point (text-property-any (point-min) (point-max) 'gnus-part n)))
4103 (goto-char point))))
4105 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4106 (let ((gnus-tmp-name
4107 (or (mail-content-type-get (mm-handle-type handle) 'name)
4108 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4109 (mail-content-type-get (mm-handle-type handle) 'url)
4111 (gnus-tmp-type (mm-handle-media-type handle))
4112 (gnus-tmp-description
4113 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4116 (if (if displayed (car displayed)
4117 (mm-handle-displayed-p handle))
4119 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4121 gnus-tmp-type-long b e)
4122 (when (string-match ".*/" gnus-tmp-name)
4123 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4124 (setq gnus-tmp-type-long (concat gnus-tmp-type
4125 (and (not (equal gnus-tmp-name ""))
4126 (concat "; " gnus-tmp-name))))
4127 (unless (equal gnus-tmp-description "")
4128 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4133 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4134 `(,@(gnus-local-map-property gnus-mime-button-map)
4135 gnus-callback gnus-mm-display-part
4136 gnus-part ,gnus-tmp-id
4137 article-type annotation
4140 (widget-convert-button
4143 :action 'gnus-widget-press-button
4144 :button-keymap gnus-mime-button-map
4146 (lambda (widget/window &optional overlay pos)
4147 ;; Needed to properly clear the message due to a bug in
4148 ;; wid-edit (XEmacs only).
4149 (if (boundp 'help-echo-owns-message)
4150 (setq help-echo-owns-message t))
4152 "%S: %s the MIME part; %S: more options"
4153 (aref gnus-mouse-2 0)
4154 ;; XEmacs will get a single widget arg; Emacs 21 will get
4155 ;; window, overlay, position.
4156 (if (mm-handle-displayed-p
4158 (with-current-buffer (gnus-overlay-buffer overlay)
4159 (widget-get (widget-at (gnus-overlay-start overlay))
4161 (widget-get widget/window :mime-handle)))
4163 (aref gnus-down-mouse-3 0))))))
4165 (defun gnus-widget-press-button (elems el)
4166 (goto-char (widget-get elems :from))
4167 (gnus-article-press-button))
4169 (defvar gnus-displaying-mime nil)
4171 (defun gnus-display-mime (&optional ihandles)
4172 "Display the MIME parts."
4174 (save-selected-window
4175 (let ((window (get-buffer-window gnus-article-buffer))
4178 (select-window window)
4179 ;; We have to do this since selecting the window
4180 ;; may change the point. So we set the window point.
4181 (set-window-point window point)))
4182 (let* ((handles (or ihandles (mm-dissect-buffer
4183 nil gnus-article-loose-mime)
4185 buffer-read-only handle name type b e display)
4186 (when (and (not ihandles)
4187 (not gnus-displaying-mime))
4188 ;; Top-level call; we clean up.
4189 (when gnus-article-mime-handles
4190 (mm-destroy-parts gnus-article-mime-handles)
4191 (setq gnus-article-mime-handle-alist nil));; A trick.
4192 (setq gnus-article-mime-handles handles)
4193 ;; We allow users to glean info from the handles.
4194 (when gnus-article-mime-part-function
4195 (gnus-mime-part-function handles)))
4197 (or (not (stringp (car handles)))
4200 (when (and (not ihandles)
4201 (not gnus-displaying-mime))
4202 ;; Clean up for mime parts.
4204 (delete-region (point) (point-max)))
4205 (let ((gnus-displaying-mime t))
4206 (gnus-mime-display-part handles)))
4209 (narrow-to-region (point) (point-max))
4210 (gnus-treat-article nil 1 1)
4213 ;; Highlight the headers.
4217 (narrow-to-region (point-min) (point))
4218 (gnus-treat-article 'head))))))))
4220 (defvar gnus-mime-display-multipart-as-mixed nil)
4221 (defvar gnus-mime-display-multipart-alternative-as-mixed nil)
4222 (defvar gnus-mime-display-multipart-related-as-mixed nil)
4224 (defun gnus-mime-display-part (handle)
4227 ((not (stringp (car handle)))
4228 (gnus-mime-display-single handle))
4229 ;; User-defined multipart
4230 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4231 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4233 ;; multipart/alternative
4234 ((and (equal (car handle) "multipart/alternative")
4235 (not (or gnus-mime-display-multipart-as-mixed
4236 gnus-mime-display-multipart-alternative-as-mixed)))
4237 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4238 (push (cons id handle) gnus-article-mime-handle-alist)
4239 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4240 ;; multipart/related
4241 ((and (equal (car handle) "multipart/related")
4242 (not (or gnus-mime-display-multipart-as-mixed
4243 gnus-mime-display-multipart-related-as-mixed)))
4244 ;;;!!!We should find the start part, but we just default
4245 ;;;!!!to the first part.
4246 ;;(gnus-mime-display-part (cadr handle))
4247 ;;;!!! Most multipart/related is an HTML message plus images.
4248 ;;;!!! Unfortunately we are unable to let W3 display those
4249 ;;;!!! included images, so we just display it as a mixed multipart.
4250 ;;(gnus-mime-display-mixed (cdr handle))
4251 ;;;!!! No, w3 can display everything just fine.
4252 (gnus-mime-display-part (cadr handle)))
4253 ((equal (car handle) "multipart/signed")
4254 (gnus-add-wash-type 'signed)
4255 (gnus-mime-display-security handle))
4256 ((equal (car handle) "multipart/encrypted")
4257 (gnus-add-wash-type 'encrypted)
4258 (gnus-mime-display-security handle))
4259 ;; Other multiparts are handled like multipart/mixed.
4261 (gnus-mime-display-mixed (cdr handle)))))
4263 (defun gnus-mime-part-function (handles)
4264 (if (stringp (car handles))
4265 (mapcar 'gnus-mime-part-function (cdr handles))
4266 (funcall gnus-article-mime-part-function handles)))
4268 (defun gnus-mime-display-mixed (handles)
4269 (mapcar 'gnus-mime-display-part handles))
4271 (defun gnus-mime-display-single (handle)
4272 (let ((type (mm-handle-media-type handle))
4273 (ignored gnus-ignored-mime-types)
4280 (when (string-match (pop ignored) type)
4281 (throw 'ignored nil)))
4282 (if (and (setq not-attachment
4283 (and (not (mm-inline-override-p handle))
4284 (or (not (mm-handle-disposition handle))
4285 (equal (car (mm-handle-disposition handle))
4287 (mm-attachment-override-p handle))))
4288 (mm-automatic-display-p handle)
4290 (mm-inlinable-p handle)
4291 (mm-inlined-p handle))
4292 (mm-automatic-external-display-p type)))
4294 (when (equal (mm-handle-media-supertype handle) "text")
4296 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4298 (push (cons id handle) gnus-article-mime-handle-alist)
4299 (when (or (not display)
4300 (not (gnus-unbuttonized-mime-type-p type)))
4301 ;(gnus-article-insert-newline)
4302 (gnus-insert-mime-button
4303 handle id (list (or display (and not-attachment text))))
4304 (gnus-article-insert-newline)
4305 ;(gnus-article-insert-newline)
4306 ;; Remember modify the number of forward lines.
4314 (let ((mail-parse-charset gnus-newsgroup-charset)
4315 (mail-parse-ignored-charsets
4316 (save-excursion (condition-case ()
4317 (set-buffer gnus-summary-buffer)
4319 gnus-newsgroup-ignored-charsets)))
4320 (mm-display-part handle t))
4321 (goto-char (point-max)))
4322 ((and text not-attachment)
4326 (gnus-article-insert-newline)
4327 (mm-insert-inline handle (mm-get-part handle))
4328 (goto-char (point-max))))
4332 (narrow-to-region beg (point))
4335 (gnus-article-mime-total-parts)
4336 (mm-handle-media-type handle)))))))))
4338 (defun gnus-unbuttonized-mime-type-p (type)
4339 "Say whether TYPE is to be unbuttonized."
4340 (unless gnus-inhibit-mime-unbuttonizing
4342 (let ((types gnus-unbuttonized-mime-types))
4344 (when (string-match (pop types) type)
4345 (throw 'found t)))))
4347 (let ((types gnus-buttonized-mime-types))
4349 (when (string-match (pop types) type)
4350 (throw 'found t)))))))))
4352 (defun gnus-article-insert-newline ()
4353 "Insert a newline, but mark it as undeletable."
4354 (gnus-put-text-property
4355 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4357 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4358 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4361 handle buffer-read-only from props begend not-pref)
4362 (save-window-excursion
4365 (narrow-to-region (car ibegend)
4368 (goto-char (car ibegend))
4371 (delete-region (point-min) (point-max))
4372 (mm-remove-parts handles))
4373 (setq begend (list (point-marker)))
4375 (unless (setq not-pref (cadr (member preferred ihandles)))
4376 (setq not-pref (car ihandles)))
4379 (not (gnus-unbuttonized-mime-type-p
4380 "multipart/alternative")))
4381 (gnus-add-text-properties
4384 (insert (format "%d. " id))
4388 (unless ,(not ibegend)
4389 (setq gnus-article-mime-handle-alist
4390 ',gnus-article-mime-handle-alist))
4391 (gnus-mime-display-alternative
4392 ',ihandles ',not-pref ',begend ,id))
4393 ,@(gnus-local-map-property gnus-mime-button-map)
4394 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4395 face ,gnus-article-button-face
4398 (widget-convert-button 'link from (point)
4399 :action 'gnus-widget-press-button
4400 :button-keymap gnus-widget-button-keymap)
4402 (while (setq handle (pop handles))
4403 (gnus-add-text-properties
4406 (insert (format "(%c) %-18s"
4407 (if (equal handle preferred) ?* ? )
4408 (mm-handle-media-type handle)))
4412 (unless ,(not ibegend)
4413 (setq gnus-article-mime-handle-alist
4414 ',gnus-article-mime-handle-alist))
4415 (gnus-mime-display-alternative
4416 ',ihandles ',handle ',begend ,id))
4417 ,@(gnus-local-map-property gnus-mime-button-map)
4418 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4419 face ,gnus-article-button-face
4422 (widget-convert-button 'link from (point)
4423 :action 'gnus-widget-press-button
4424 :button-keymap gnus-widget-button-keymap)
4428 (if (stringp (car preferred))
4429 (gnus-display-mime preferred)
4430 (let ((mail-parse-charset gnus-newsgroup-charset)
4431 (mail-parse-ignored-charsets
4432 (save-excursion (set-buffer gnus-summary-buffer)
4433 gnus-newsgroup-ignored-charsets)))
4434 (mm-display-part preferred)
4438 (narrow-to-region (car begend) (point-max))
4440 nil (length gnus-article-mime-handle-alist)
4441 (gnus-article-mime-total-parts)
4442 (mm-handle-media-type handle))))))
4443 (goto-char (point-max))
4444 (setcdr begend (point-marker)))))
4446 (goto-char point))))
4448 (defconst gnus-article-wash-status-strings
4449 (let ((alist '((cite "c" "Possible hidden citation text"
4450 " " "All citation text visible")
4451 (headers "h" "Hidden headers"
4452 " " "All headers visible.")
4453 (pgp "p" "Encrypted or signed message status hidden"
4454 " " "No hidden encryption nor digital signature status")
4455 (signature "s" "Signature has been hidden"
4456 " " "Signature is visible")
4457 (overstrike "o" "Overstrike (^H) characters applied"
4458 " " "No overstrike characters applied")
4459 (emphasis "e" "/*_Emphasis_*/ characters applied"
4460 " " "No /*_emphasis_*/ characters applied")))
4462 (dolist (entry alist result)
4463 (let ((key (nth 0 entry))
4464 (on (copy-sequence (nth 1 entry)))
4465 (on-help (nth 2 entry))
4466 (off (copy-sequence (nth 3 entry)))
4467 (off-help (nth 4 entry)))
4468 (put-text-property 0 1 'help-echo on-help on)
4469 (put-text-property 0 1 'help-echo off-help off)
4470 (push (list key on off) result))))
4471 "Alist of strings describing wash status in the mode line.
4472 Each entry has the form (KEY ON OF), where the KEY is a symbol
4473 representing the particular washing function, ON is the string to use
4474 in the article mode line when the washing function is active, and OFF
4475 is the string to use when it is inactive.")
4477 (defun gnus-article-wash-status-entry (key value)
4478 (let ((entry (assoc key gnus-article-wash-status-strings)))
4479 (if value (nth 1 entry) (nth 2 entry))))
4481 (defun gnus-article-wash-status ()
4482 "Return a string which display status of article washing."
4484 (set-buffer gnus-article-buffer)
4485 (let ((cite (memq 'cite gnus-article-wash-types))
4486 (headers (memq 'headers gnus-article-wash-types))
4487 (boring (memq 'boring-headers gnus-article-wash-types))
4488 (pgp (memq 'pgp gnus-article-wash-types))
4489 (pem (memq 'pem gnus-article-wash-types))
4490 (signed (memq 'signed gnus-article-wash-types))
4491 (encrypted (memq 'encrypted gnus-article-wash-types))
4492 (signature (memq 'signature gnus-article-wash-types))
4493 (overstrike (memq 'overstrike gnus-article-wash-types))
4494 (emphasis (memq 'emphasis gnus-article-wash-types)))
4496 (gnus-article-wash-status-entry 'cite cite)
4497 (gnus-article-wash-status-entry 'headers (or headers boring))
4498 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
4499 (gnus-article-wash-status-entry 'signature signature)
4500 (gnus-article-wash-status-entry 'overstrike overstrike)
4501 (gnus-article-wash-status-entry 'emphasis emphasis)))))
4503 (defun gnus-add-wash-type (type)
4504 "Add a washing of TYPE to the current status."
4505 (add-to-list 'gnus-article-wash-types type))
4507 (defun gnus-delete-wash-type (type)
4508 "Add a washing of TYPE to the current status."
4509 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
4511 (defun gnus-add-image (category image)
4512 "Add IMAGE of CATEGORY to the list of displayed images."
4513 (let ((entry (assq category gnus-article-image-alist)))
4515 (setq entry (list category))
4516 (push entry gnus-article-image-alist))
4517 (nconc entry (list image))))
4519 (defun gnus-delete-images (category)
4520 "Delete all images in CATEGORY."
4521 (let ((entry (assq category gnus-article-image-alist)))
4522 (dolist (image (cdr entry))
4523 (gnus-remove-image image))
4524 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
4525 (gnus-delete-wash-type category)))
4527 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
4529 (defun gnus-article-maybe-hide-headers ()
4530 "Hide unwanted headers if `gnus-have-all-headers' is nil.
4531 Provided for backwards compatibility."
4532 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
4533 (not (save-excursion (set-buffer gnus-summary-buffer)
4534 gnus-have-all-headers)))
4535 (not gnus-inhibit-hiding))
4536 (gnus-article-hide-headers)))
4540 (defun gnus-output-to-file (file-name)
4541 "Append the current article to a file named FILE-NAME."
4542 (let ((artbuf (current-buffer)))
4544 (insert-buffer-substring artbuf)
4545 ;; Append newline at end of the buffer as separator, and then
4547 (goto-char (point-max))
4549 (let ((file-name-coding-system nnmail-pathname-coding-system))
4550 (mm-append-to-file (point-min) (point-max) file-name))
4553 (defun gnus-narrow-to-page (&optional arg)
4554 "Narrow the article buffer to a page.
4555 If given a numerical ARG, move forward ARG pages."
4557 (setq arg (if arg (prefix-numeric-value arg) 0))
4559 (set-buffer gnus-article-buffer)
4560 (goto-char (point-min))
4562 ;; Remove any old next/prev buttons.
4563 (when (gnus-visual-p 'page-marker)
4564 (let ((buffer-read-only nil))
4565 (gnus-remove-text-with-property 'gnus-prev)
4566 (gnus-remove-text-with-property 'gnus-next)))
4569 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
4571 (re-search-forward page-delimiter nil 'move arg)))
4572 (goto-char (match-end 0)))
4575 (if (re-search-forward page-delimiter nil 'move)
4578 (when (and (gnus-visual-p 'page-marker)
4579 (not (= (point-min) 1)))
4581 (goto-char (point-min))
4582 (gnus-insert-prev-page-button)))
4583 (when (and (gnus-visual-p 'page-marker)
4584 (< (+ (point-max) 2) (buffer-size)))
4586 (goto-char (point-max))
4587 (gnus-insert-next-page-button)))))
4589 ;; Article mode commands
4591 (defun gnus-article-goto-next-page ()
4592 "Show the next page of the article."
4594 (when (gnus-article-next-page)
4595 (goto-char (point-min))
4596 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
4598 (defun gnus-article-goto-prev-page ()
4599 "Show the next page of the article."
4601 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
4602 (gnus-article-prev-page nil)))
4604 (defun gnus-article-next-page (&optional lines)
4605 "Show the next page of the current article.
4606 If end of article, return non-nil. Otherwise return nil.
4607 Argument LINES specifies lines to be scrolled up."
4609 (move-to-window-line -1)
4612 (and (pos-visible-in-window-p) ;Not continuation line.
4614 ;; Nothing in this page.
4615 (if (or (not gnus-page-broken)
4618 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
4620 (gnus-narrow-to-page 1) ;Go to next page.
4622 ;; More in this page.
4623 (let ((scroll-in-place nil))
4627 ;; Long lines may cause an end-of-buffer error.
4628 (goto-char (point-max)))))
4629 (move-to-window-line 0)
4632 (defun gnus-article-prev-page (&optional lines)
4633 "Show previous page of current article.
4634 Argument LINES specifies lines to be scrolled down."
4636 (move-to-window-line 0)
4637 (if (and gnus-page-broken
4639 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
4641 (gnus-narrow-to-page -1) ;Go to previous page.
4642 (goto-char (point-max))
4644 (let ((scroll-in-place nil))
4648 (beginning-of-buffer
4649 (goto-char (point-min))))
4650 (move-to-window-line 0)))))
4652 (defun gnus-article-refer-article ()
4653 "Read article specified by message-id around point."
4655 (let ((point (point)))
4656 (search-forward ">" nil t) ;Move point to end of "<....>".
4657 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
4658 (let ((message-id (match-string 1)))
4660 (set-buffer gnus-summary-buffer)
4661 (gnus-summary-refer-article message-id))
4663 (error "No references around point"))))
4665 (defun gnus-article-show-summary ()
4666 "Reconfigure windows to show summary buffer."
4668 (if (not (gnus-buffer-live-p gnus-summary-buffer))
4669 (error "There is no summary buffer for this article buffer")
4670 (gnus-article-set-globals)
4671 (gnus-configure-windows 'article)
4672 (gnus-summary-goto-subject gnus-current-article)
4673 (gnus-summary-position-point)))
4675 (defun gnus-article-describe-briefly ()
4676 "Describe article mode commands briefly."
4678 (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")))
4680 (defun gnus-article-summary-command ()
4681 "Execute the last keystroke in the summary buffer."
4683 (let ((obuf (current-buffer))
4684 (owin (current-window-configuration))
4686 (switch-to-buffer gnus-article-current-summary 'norecord)
4687 (setq func (lookup-key (current-local-map) (this-command-keys)))
4688 (call-interactively func)
4690 (set-window-configuration owin)
4691 (set-window-point (get-buffer-window (current-buffer)) (point))))
4693 (defun gnus-article-summary-command-nosave ()
4694 "Execute the last keystroke in the summary buffer."
4697 (pop-to-buffer gnus-article-current-summary 'norecord)
4698 (setq func (lookup-key (current-local-map) (this-command-keys)))
4699 (call-interactively func)))
4701 (defun gnus-article-check-buffer ()
4702 "Beep if not in an article buffer."
4703 (unless (equal major-mode 'gnus-article-mode)
4704 (error "Command invoked outside of a Gnus article buffer")))
4706 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
4707 "Read a summary buffer key sequence and execute it from the article buffer."
4709 (gnus-article-check-buffer)
4711 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
4712 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
4713 "=" "^" "\M-^" "|"))
4719 '("n" "Gn" "p" "Gp"))
4722 (set-buffer gnus-article-current-summary)
4723 (let (gnus-pick-mode)
4724 (push (or key last-command-event) unread-command-events)
4725 (setq keys (if (featurep 'xemacs)
4726 (events-to-keys (read-key-sequence nil))
4727 (read-key-sequence nil)))))
4731 (if (or (member keys nosaves)
4732 (member keys nosave-but-article)
4733 (member keys nosave-in-article))
4735 (save-window-excursion
4736 (pop-to-buffer gnus-article-current-summary 'norecord)
4737 ;; We disable the pick minor mode commands.
4738 (let (gnus-pick-mode)
4739 (setq func (lookup-key (current-local-map) keys))))
4743 (unless (member keys nosave-in-article)
4744 (set-buffer gnus-article-current-summary))
4745 (call-interactively func)
4746 (setq new-sum-point (point)))
4747 (when (member keys nosave-but-article)
4748 (pop-to-buffer gnus-article-buffer 'norecord)))
4749 ;; These commands should restore window configuration.
4750 (let ((obuf (current-buffer))
4751 (owin (current-window-configuration))
4753 (summary gnus-article-current-summary)
4754 func in-buffer selected)
4755 (if not-restore-window
4756 (pop-to-buffer summary 'norecord)
4757 (switch-to-buffer summary 'norecord))
4758 (setq in-buffer (current-buffer))
4759 ;; We disable the pick minor mode commands.
4760 (if (and (setq func (let (gnus-pick-mode)
4761 (lookup-key (current-local-map) keys)))
4764 (call-interactively func)
4765 (setq new-sum-point (point))
4766 (when (eq in-buffer (current-buffer))
4767 (setq selected (gnus-summary-select-article))
4769 (unless not-restore-window
4770 (set-window-configuration owin))
4771 (when (eq selected 'old)
4773 (set-window-start (get-buffer-window (current-buffer))
4775 (set-window-point (get-buffer-window (current-buffer))
4777 (let ((win (get-buffer-window gnus-article-current-summary)))
4779 (set-window-point win new-sum-point)))) )
4780 (switch-to-buffer gnus-article-buffer)
4783 (defun gnus-article-describe-key (key)
4784 "Display documentation of the function invoked by KEY. KEY is a string."
4785 (interactive "kDescribe key: ")
4786 (gnus-article-check-buffer)
4787 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
4789 (set-buffer gnus-article-current-summary)
4790 (let (gnus-pick-mode)
4791 (if (featurep 'xemacs)
4793 (push (elt key 0) unread-command-events)
4794 (setq key (events-to-keys
4795 (read-key-sequence "Describe key: "))))
4796 (setq unread-command-events
4798 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
4799 (string-to-list key)))
4800 (setq key (read-key-sequence "Describe key: "))))
4802 (describe-key key)))
4804 (defun gnus-article-describe-key-briefly (key &optional insert)
4805 "Display documentation of the function invoked by KEY. KEY is a string."
4806 (interactive "kDescribe key: \nP")
4807 (gnus-article-check-buffer)
4808 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
4810 (set-buffer gnus-article-current-summary)
4811 (let (gnus-pick-mode)
4812 (if (featurep 'xemacs)
4814 (push (elt key 0) unread-command-events)
4815 (setq key (events-to-keys
4816 (read-key-sequence "Describe key: "))))
4817 (setq unread-command-events
4819 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
4820 (string-to-list key)))
4821 (setq key (read-key-sequence "Describe key: "))))
4822 (describe-key-briefly key insert))
4823 (describe-key-briefly key insert)))
4825 (defun gnus-article-reply-with-original (&optional wide)
4826 "Start composing a reply mail to the current message.
4827 The text in the region will be yanked. If the region isn't active,
4828 the entire article will be yanked."
4830 (let ((article (cdr gnus-article-current)) cont)
4832 (gnus-summary-reply (list (list article)) wide)
4833 (setq cont (buffer-substring (point) (mark t)))
4834 ;; Deactivate active regions.
4835 (when (and (boundp 'transient-mark-mode)
4836 transient-mark-mode)
4837 (setq mark-active nil))
4839 (list (list article cont)) wide))))
4841 (defun gnus-article-followup-with-original ()
4842 "Compose a followup to the current article.
4843 The text in the region will be yanked. If the region isn't active,
4844 the entire article will be yanked."
4846 (let ((article (cdr gnus-article-current))
4849 (gnus-summary-followup (list (list article)))
4850 (setq cont (buffer-substring (point) (mark t)))
4851 ;; Deactivate active regions.
4852 (when (and (boundp 'transient-mark-mode)
4853 transient-mark-mode)
4854 (setq mark-active nil))
4855 (gnus-summary-followup
4856 (list (list article cont))))))
4858 (defun gnus-article-hide (&optional arg force)
4859 "Hide all the gruft in the current article.
4860 This means that PGP stuff, signatures, cited text and (some)
4861 headers will be hidden.
4862 If given a prefix, show the hidden text instead."
4863 (interactive (append (gnus-article-hidden-arg) (list 'force)))
4864 (gnus-article-hide-headers arg)
4865 (gnus-article-hide-list-identifiers arg)
4866 (gnus-article-hide-pgp arg)
4867 (gnus-article-hide-citation-maybe arg force)
4868 (gnus-article-hide-signature arg))
4870 (defun gnus-article-maybe-highlight ()
4871 "Do some article highlighting if article highlighting is requested."
4872 (when (gnus-visual-p 'article-highlight 'highlight)
4873 (gnus-article-highlight-some)))
4875 (defun gnus-check-group-server ()
4876 ;; Make sure the connection to the server is alive.
4877 (unless (gnus-server-opened
4878 (gnus-find-method-for-group gnus-newsgroup-name))
4879 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
4880 (gnus-request-group gnus-newsgroup-name t)))
4883 (autoload 'nneething-get-file-name "nneething"))
4885 (defun gnus-request-article-this-buffer (article group)
4886 "Get an article and insert it into this buffer."
4887 (let (do-update-line sparse-header)
4891 (gnus-kill-all-overlays)
4892 (setq group (or group gnus-newsgroup-name))
4894 ;; Using `gnus-request-article' directly will insert the article into
4895 ;; `nntp-server-buffer' - so we'll save some time by not having to
4896 ;; copy it from the server buffer into the article buffer.
4898 ;; We only request an article by message-id when we do not have the
4899 ;; headers for it, so we'll have to get those.
4900 (when (stringp article)
4901 (gnus-read-header article))
4903 ;; If the article number is negative, that means that this article
4904 ;; doesn't belong in this newsgroup (possibly), so we find its
4905 ;; message-id and request it by id instead of number.
4906 (when (and (numberp article)
4908 (get-buffer gnus-summary-buffer)
4909 (gnus-buffer-exists-p gnus-summary-buffer))
4911 (set-buffer gnus-summary-buffer)
4912 (let ((header (gnus-summary-article-header article)))
4915 ((memq article gnus-newsgroup-sparse)
4916 ;; This is a sparse gap article.
4917 (setq do-update-line article)
4918 (setq article (mail-header-id header))
4919 (setq sparse-header (gnus-read-header article))
4920 (setq gnus-newsgroup-sparse
4921 (delq article gnus-newsgroup-sparse)))
4923 ;; It's a real article.
4924 (setq article (mail-header-id header)))
4926 ;; It is an extracted pseudo-article.
4927 (setq article 'pseudo)
4928 (gnus-request-pseudo-article header))))
4930 (let ((method (gnus-find-method-for-group
4931 gnus-newsgroup-name)))
4932 (when (and (eq (car method) 'nneething)
4934 (let ((dir (nneething-get-file-name
4935 (mail-header-id header))))
4936 (when (and (stringp dir)
4937 (file-directory-p dir))
4938 (setq article 'nneething)
4939 (gnus-group-enter-directory dir))))))))
4942 ;; Refuse to select canceled articles.
4943 ((and (numberp article)
4945 (get-buffer gnus-summary-buffer)
4946 (gnus-buffer-exists-p gnus-summary-buffer)
4947 (eq (cdr (save-excursion
4948 (set-buffer gnus-summary-buffer)
4949 (assq article gnus-newsgroup-reads)))
4950 gnus-canceled-mark))
4952 ;; We first check `gnus-original-article-buffer'.
4953 ((and (get-buffer gnus-original-article-buffer)
4956 (set-buffer gnus-original-article-buffer)
4957 (and (equal (car gnus-original-article) group)
4958 (eq (cdr gnus-original-article) article))))
4959 (insert-buffer-substring gnus-original-article-buffer)
4961 ;; Check the backlog.
4962 ((and gnus-keep-backlog
4963 (gnus-backlog-request-article group article (current-buffer)))
4965 ;; Check asynchronous pre-fetch.
4966 ((gnus-async-request-fetched-article group article (current-buffer))
4967 (gnus-async-prefetch-next group article gnus-summary-buffer)
4968 (when (and (numberp article) gnus-keep-backlog)
4969 (gnus-backlog-enter-article group article (current-buffer)))
4972 ((and gnus-use-cache
4974 (gnus-cache-request-article article group))
4976 ;; Check the agent cache.
4977 ((and gnus-agent gnus-agent-cache gnus-plugged
4979 (gnus-agent-request-article article group))
4981 ;; Get the article and put into the article buffer.
4982 ((or (stringp article)
4984 (let ((gnus-override-method gnus-override-method)
4985 (methods (and (stringp article)
4986 gnus-refer-article-method))
4987 (backend (car (gnus-find-method-for-group
4988 gnus-newsgroup-name)))
4990 (buffer-read-only nil))
4991 (if (or (not (listp methods))
4992 (and (symbolp (car methods))
4993 (assq (car methods) nnoo-definition-alist)))
4994 (setq methods (list methods)))
4995 (when (and (null gnus-override-method)
4997 (setq gnus-override-method (pop methods)))
4999 (when (eq gnus-override-method 'current)
5000 (setq gnus-override-method
5001 (with-current-buffer gnus-summary-buffer
5002 gnus-current-select-method)))
5004 (gnus-kill-all-overlays)
5005 (let ((gnus-newsgroup-name group))
5006 (gnus-check-group-server))
5008 ((gnus-request-article article group (current-buffer))
5009 (when (numberp article)
5010 (gnus-async-prefetch-next group article
5011 gnus-summary-buffer)
5012 (when gnus-keep-backlog
5013 (gnus-backlog-enter-article
5014 group article (current-buffer))))
5015 (setq result 'article))
5017 (setq gnus-override-method (pop methods)))
5018 ((not (string-match "^400 "
5019 (nnheader-get-report backend)))
5020 ;; If we get 400 server disconnect, reconnect and
5021 ;; retry; otherwise, assume the article has expired.
5022 (setq result 'done))))
5023 (and (eq result 'article) 'article)))
5027 ;; Associate this article with the current summary buffer.
5028 (setq gnus-article-current-summary gnus-summary-buffer)
5030 ;; Take the article from the original article buffer
5031 ;; and place it in the buffer it's supposed to be in.
5032 (when (and (get-buffer gnus-article-buffer)
5033 (equal (buffer-name (current-buffer))
5034 (buffer-name (get-buffer gnus-article-buffer))))
5036 (if (get-buffer gnus-original-article-buffer)
5037 (set-buffer gnus-original-article-buffer)
5038 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5039 (buffer-disable-undo)
5040 (setq major-mode 'gnus-original-article-mode)
5041 (setq buffer-read-only t))
5042 (let (buffer-read-only)
5044 (insert-buffer-substring gnus-article-buffer))
5045 (setq gnus-original-article (cons group article)))
5048 (run-hooks 'gnus-article-decode-hook)
5049 ;; Mark article as decoded or not.
5050 (setq gnus-article-decoded-p gnus-article-decode-hook))
5052 ;; Update sparse articles.
5053 (when (and do-update-line
5054 (or (numberp article)
5056 (let ((buf (current-buffer)))
5057 (set-buffer gnus-summary-buffer)
5058 (gnus-summary-update-article do-update-line sparse-header)
5059 (gnus-summary-goto-subject do-update-line nil t)
5060 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5062 (set-buffer buf))))))
5068 (defcustom gnus-article-edit-mode-hook nil
5069 "Hook run in article edit mode buffers."
5070 :group 'gnus-article-various
5073 (defvar gnus-article-edit-done-function nil)
5075 (defvar gnus-article-edit-mode-map nil)
5077 ;; Should we be using derived.el for this?
5078 (unless gnus-article-edit-mode-map
5079 (setq gnus-article-edit-mode-map (make-keymap))
5080 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5083 (gnus-define-keys gnus-article-edit-mode-map
5084 "\C-c?" describe-mode
5085 "\C-c\C-c" gnus-article-edit-done
5086 "\C-c\C-k" gnus-article-edit-exit
5087 "\C-c\C-f\C-t" message-goto-to
5088 "\C-c\C-f\C-o" message-goto-from
5089 "\C-c\C-f\C-b" message-goto-bcc
5090 ;;"\C-c\C-f\C-w" message-goto-fcc
5091 "\C-c\C-f\C-c" message-goto-cc
5092 "\C-c\C-f\C-s" message-goto-subject
5093 "\C-c\C-f\C-r" message-goto-reply-to
5094 "\C-c\C-f\C-n" message-goto-newsgroups
5095 "\C-c\C-f\C-d" message-goto-distribution
5096 "\C-c\C-f\C-f" message-goto-followup-to
5097 "\C-c\C-f\C-m" message-goto-mail-followup-to
5098 "\C-c\C-f\C-k" message-goto-keywords
5099 "\C-c\C-f\C-u" message-goto-summary
5100 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5101 "\C-c\C-f\C-a" message-gen-unsubscribed-mft
5102 "\C-c\C-b" message-goto-body
5103 "\C-c\C-i" message-goto-signature
5105 "\C-c\C-t" message-insert-to
5106 "\C-c\C-n" message-insert-newsgroups
5107 "\C-c\C-o" message-sort-headers
5108 "\C-c\C-e" message-elide-region
5109 "\C-c\C-v" message-delete-not-region
5110 "\C-c\C-z" message-kill-to-signature
5111 "\M-\r" message-newline-and-reformat
5112 "\C-c\C-a" mml-attach-file
5113 "\C-a" message-beginning-of-line
5115 "\M-;" comment-region)
5117 (gnus-define-keys (gnus-article-edit-wash-map
5118 "\C-c\C-w" gnus-article-edit-mode-map)
5119 "f" gnus-article-edit-full-stops))
5122 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5124 ["Fetch To" message-insert-to t]
5125 ["Fetch Newsgroups" message-insert-newsgroups t]
5127 ["To" message-goto-to t]
5128 ["From" message-goto-from t]
5129 ["Subject" message-goto-subject t]
5130 ["Cc" message-goto-cc t]
5131 ["Reply-To" message-goto-reply-to t]
5132 ["Summary" message-goto-summary t]
5133 ["Keywords" message-goto-keywords t]
5134 ["Newsgroups" message-goto-newsgroups t]
5135 ["Followup-To" message-goto-followup-to t]
5136 ["Mail-Followup-To" message-goto-mail-followup-to t]
5137 ["Distribution" message-goto-distribution t]
5138 ["Body" message-goto-body t]
5139 ["Signature" message-goto-signature t]))
5141 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
5142 "Major mode for editing articles.
5143 This is an extended text-mode.
5145 \\{gnus-article-edit-mode-map}"
5146 (make-local-variable 'gnus-article-edit-done-function)
5147 (make-local-variable 'gnus-prev-winconf)
5148 (set (make-local-variable 'font-lock-defaults)
5149 '(message-font-lock-keywords t))
5150 (set (make-local-variable 'mail-header-separator) "")
5151 (easy-menu-add message-mode-field-menu message-mode-map)
5153 (setq buffer-read-only nil)
5154 (buffer-enable-undo)
5157 (defun gnus-article-edit (&optional force)
5158 "Edit the current article.
5159 This will have permanent effect only in mail groups.
5160 If FORCE is non-nil, allow editing of articles even in read-only
5163 (when (and (not force)
5164 (gnus-group-read-only-p))
5165 (error "The current newsgroup does not support article editing"))
5166 (gnus-article-date-original)
5167 (gnus-article-edit-article
5169 `(lambda (no-highlight)
5171 (gnus-summary-edit-article-done
5172 ,(or (mail-header-references gnus-current-headers) "")
5173 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5175 (defun gnus-article-edit-article (start-func exit-func)
5176 "Start editing the contents of the current article buffer."
5177 (let ((winconf (current-window-configuration)))
5178 (set-buffer gnus-article-buffer)
5179 (gnus-article-edit-mode)
5180 (funcall start-func)
5181 (set-buffer-modified-p nil)
5182 (gnus-configure-windows 'edit-article)
5183 (setq gnus-article-edit-done-function exit-func)
5184 (setq gnus-prev-winconf winconf)
5185 (gnus-message 6 "C-c C-c to end edits")))
5187 (defun gnus-article-edit-done (&optional arg)
5188 "Update the article edits and exit."
5190 (let ((func gnus-article-edit-done-function)
5191 (buf (current-buffer))
5192 (start (window-start))
5194 (winconf gnus-prev-winconf))
5195 (widen) ;; Widen it in case that users narrowed the buffer.
5198 ;; The cache and backlog have to be flushed somewhat.
5199 (when gnus-keep-backlog
5200 (gnus-backlog-remove-article
5201 (car gnus-article-current) (cdr gnus-article-current)))
5202 ;; Flush original article as well.
5204 (when (get-buffer gnus-original-article-buffer)
5205 (set-buffer gnus-original-article-buffer)
5206 (setq gnus-original-article nil)))
5207 (when gnus-use-cache
5208 (gnus-cache-update-article
5209 (car gnus-article-current) (cdr gnus-article-current)))
5210 ;; We remove all text props from the article buffer.
5211 (kill-all-local-variables)
5212 (gnus-set-text-properties (point-min) (point-max) nil)
5214 (set-window-configuration winconf)
5216 (set-window-start (get-buffer-window buf) start)
5217 (set-window-point (get-buffer-window buf) (point))))
5219 (defun gnus-article-edit-exit ()
5220 "Exit the article editing without updating."
5222 (when (or (not (buffer-modified-p))
5223 (yes-or-no-p "Article modified; kill anyway? "))
5224 (let ((curbuf (current-buffer))
5226 (window-start (window-start)))
5228 (if (gnus-buffer-live-p gnus-original-article-buffer)
5229 (insert-buffer gnus-original-article-buffer))
5230 (let ((winconf gnus-prev-winconf))
5232 (set-window-configuration winconf)
5233 ;; Tippy-toe some to make sure that point remains where it was.
5234 (save-current-buffer
5236 (set-window-start (get-buffer-window (current-buffer)) window-start)
5239 (defun gnus-article-edit-full-stops ()
5240 "Interactively repair spacing at end of sentences."
5243 (goto-char (point-min))
5244 (search-forward-regexp "^$" nil t)
5245 (let ((case-fold-search nil))
5246 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5249 ;;; Article highlights
5252 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5254 ;;; Internal Variables:
5256 (defcustom gnus-button-url-regexp
5257 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
5258 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-zA-Z0-9_.]+:[0-9]*\\)?[-a-zA-Z0-9_=!?#$@~`%&*+|\\/:;.,[:word:]]+[-a-zA-Z0-9_=#$@~`%&*+|\\/[:word:]]\\)"
5259 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-zA-Z0-9_.]+:[0-9]*\\)?\\([-a-zA-Z0-9_=!?#$@~`%&*+|\\/:;.,]\\|\\w\\)+\\([-a-zA-Z0-9_=#$@~`%&*+|\\/]\\|\\w\\)\\)")
5260 "Regular expression that matches URLs."
5261 :group 'gnus-article-buttons
5264 (defcustom gnus-button-man-handler 'man
5265 "Function to use for displaying man pages.
5266 The function must take at least one argument with a string naming the
5268 :type '(choice (function-item :tag "Man" man)
5269 (function-item :tag "Woman" woman)
5270 (function :tag "Other"))
5271 :group 'gnus-article-buttons)
5273 (defcustom gnus-button-alist
5274 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
5275 0 t gnus-button-handle-news 3)
5276 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
5277 gnus-button-handle-news 2)
5278 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
5280 gnus-button-fetch-group 4)
5281 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
5282 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
5283 t gnus-button-message-id 3)
5284 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
5285 ("mailto:\\([-a-zA-Z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
5286 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
5288 ("\\binfo:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t
5289 gnus-button-handle-info 2)
5290 ;; This is how URLs _should_ be embedded in text...
5291 ("<URL: *\\([^<>]*\\)>" 1 t gnus-button-embedded-url 1)
5293 (gnus-button-url-regexp 0 t browse-url 0)
5295 ("\\b\\([a-z]+\\)([0-9])\\W" 0 t gnus-button-handle-man 1))
5296 "*Alist of regexps matching buttons in article bodies.
5298 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
5299 REGEXP: is the string matching text around the button (can also be lisp
5300 expression evaluating to a string),
5301 BUTTON: is the number of the regexp grouping actually matching the button,
5302 FORM: is a lisp expression which must eval to true for the button to
5304 CALLBACK: is the function to call when the user push this button, and each
5305 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
5307 CALLBACK can also be a variable, in that case the value of that
5308 variable it the real callback function."
5309 :group 'gnus-article-buttons
5310 :type '(repeat (list (choice regexp variable)
5311 (integer :tag "Button")
5313 (function :tag "Callback")
5316 (integer :tag "Regexp group")))))
5318 (defcustom gnus-header-button-alist
5319 '(("^\\(References\\|Message-I[Dd]\\):" "<[^<>]+>"
5320 0 t gnus-button-message-id 0)
5321 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
5322 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
5323 0 t gnus-button-mailto 0)
5324 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp 0 t browse-url 0)
5325 ("^Subject:" gnus-button-url-regexp 0 t browse-url 0)
5326 ("^[^:]+:" gnus-button-url-regexp 0 t browse-url 0)
5327 ("^[^:]+:" "\\bmailto:\\([-a-zA-Z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
5328 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
5329 gnus-button-message-id 3))
5330 "*Alist of headers and regexps to match buttons in article heads.
5332 This alist is very similar to `gnus-button-alist', except that each
5333 alist has an additional HEADER element first in each entry:
5335 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
5337 HEADER is a regexp to match a header. For a fuller explanation, see
5338 `gnus-button-alist'."
5339 :group 'gnus-article-buttons
5340 :group 'gnus-article-headers
5341 :type '(repeat (list (regexp :tag "Header")
5343 (integer :tag "Button")
5345 (function :tag "Callback")
5348 (integer :tag "Regexp group")))))
5350 (defvar gnus-button-regexp nil)
5351 (defvar gnus-button-marker-list nil)
5352 ;; Regexp matching any of the regexps from `gnus-button-alist'.
5354 (defvar gnus-button-last nil)
5355 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
5359 (defun gnus-article-push-button (event)
5360 "Check text under the mouse pointer for a callback function.
5361 If the text under the mouse pointer has a `gnus-callback' property,
5362 call it with the value of the `gnus-data' text property."
5364 (set-buffer (window-buffer (posn-window (event-start event))))
5365 (let* ((pos (posn-point (event-start event)))
5366 (data (get-text-property pos 'gnus-data))
5367 (fun (get-text-property pos 'gnus-callback)))
5370 (funcall fun data))))
5372 (defun gnus-article-press-button ()
5373 "Check text at point for a callback function.
5374 If the text at point has a `gnus-callback' property,
5375 call it with the value of the `gnus-data' text property."
5377 (let* ((data (get-text-property (point) 'gnus-data))
5378 (fun (get-text-property (point) 'gnus-callback)))
5380 (funcall fun data))))
5382 (defun gnus-article-highlight (&optional force)
5383 "Highlight current article.
5384 This function calls `gnus-article-highlight-headers',
5385 `gnus-article-highlight-citation',
5386 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
5387 do the highlighting. See the documentation for those functions."
5388 (interactive (list 'force))
5389 (gnus-article-highlight-headers)
5390 (gnus-article-highlight-citation force)
5391 (gnus-article-highlight-signature)
5392 (gnus-article-add-buttons force)
5393 (gnus-article-add-buttons-to-head))
5395 (defun gnus-article-highlight-some (&optional force)
5396 "Highlight current article.
5397 This function calls `gnus-article-highlight-headers',
5398 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
5399 do the highlighting. See the documentation for those functions."
5400 (interactive (list 'force))
5401 (gnus-article-highlight-headers)
5402 (gnus-article-highlight-signature)
5403 (gnus-article-add-buttons))
5405 (defun gnus-article-highlight-headers ()
5406 "Highlight article headers as specified by `gnus-header-face-alist'."
5409 (set-buffer gnus-article-buffer)
5411 (let ((alist gnus-header-face-alist)
5412 (buffer-read-only nil)
5413 (case-fold-search t)
5414 (inhibit-point-motion-hooks t)
5415 entry regexp header-face field-face from hpoints fpoints)
5416 (article-narrow-to-head)
5417 (while (setq entry (pop alist))
5418 (goto-char (point-min))
5419 (setq regexp (concat "^\\("
5420 (if (string-equal "" (nth 0 entry))
5424 header-face (nth 1 entry)
5425 field-face (nth 2 entry))
5426 (while (and (re-search-forward regexp nil t)
5430 (unless (search-forward ":" nil t)
5432 (when (and header-face
5433 (not (memq (point) hpoints)))
5434 (push (point) hpoints)
5435 (gnus-put-text-property from (point) 'face header-face))
5436 (when (and field-face
5437 (not (memq (setq from (point)) fpoints)))
5439 (if (re-search-forward "^[^ \t]" nil t)
5441 (goto-char (point-max)))
5442 (gnus-put-text-property from (point) 'face field-face))))))))
5444 (defun gnus-article-highlight-signature ()
5445 "Highlight the signature in an article.
5446 It does this by highlighting everything after
5447 `gnus-signature-separator' using `gnus-signature-face'."
5450 (set-buffer gnus-article-buffer)
5451 (let ((buffer-read-only nil)
5452 (inhibit-point-motion-hooks t))
5454 (when (and gnus-signature-face
5455 (gnus-article-narrow-to-signature))
5456 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
5457 'face gnus-signature-face)
5459 (gnus-article-search-signature)
5460 (let ((start (match-beginning 0))
5461 (end (set-marker (make-marker) (1+ (match-end 0)))))
5462 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
5465 (defun gnus-button-in-region-p (b e prop)
5466 "Say whether PROP exists in the region."
5467 (text-property-not-all b e prop nil))
5469 (defun gnus-article-add-buttons (&optional force)
5470 "Find external references in the article and make buttons of them.
5471 \"External references\" are things like Message-IDs and URLs, as
5472 specified by `gnus-button-alist'."
5473 (interactive (list 'force))
5475 (set-buffer gnus-article-buffer)
5476 (let ((buffer-read-only nil)
5477 (inhibit-point-motion-hooks t)
5478 (case-fold-search t)
5479 (alist gnus-button-alist)
5481 ;; Remove all old markers.
5482 (let (marker entry new-list)
5483 (while (setq marker (pop gnus-button-marker-list))
5484 (if (or (< marker (point-min)) (>= marker (point-max)))
5485 (push marker new-list)
5487 (when (setq entry (gnus-button-entry))
5488 (put-text-property (match-beginning (nth 1 entry))
5489 (match-end (nth 1 entry))
5490 'gnus-callback nil))
5491 (set-marker marker nil)))
5492 (setq gnus-button-marker-list new-list))
5493 ;; We skip the headers.
5496 (while (setq entry (pop alist))
5497 (setq regexp (eval (car entry)))
5499 (while (re-search-forward regexp nil t)
5500 (let* ((start (and entry (match-beginning (nth 1 entry))))
5501 (end (and entry (match-end (nth 1 entry))))
5502 (from (match-beginning 0)))
5503 (when (and (or (eq t (nth 2 entry))
5504 (eval (nth 2 entry)))
5505 (not (gnus-button-in-region-p
5506 start end 'gnus-callback)))
5507 ;; That optional form returned non-nil, so we add the
5509 (gnus-article-add-button
5510 start end 'gnus-button-push
5511 (car (push (set-marker (make-marker) from)
5512 gnus-button-marker-list))))))))))
5514 ;; Add buttons to the head of an article.
5515 (defun gnus-article-add-buttons-to-head ()
5516 "Add buttons to the head of the article."
5519 (set-buffer gnus-article-buffer)
5521 (let ((buffer-read-only nil)
5522 (inhibit-point-motion-hooks t)
5523 (case-fold-search t)
5524 (alist gnus-header-button-alist)
5526 (article-narrow-to-head)
5528 ;; Each alist entry.
5529 (setq entry (car alist)
5531 (goto-char (point-min))
5532 (while (re-search-forward (car entry) nil t)
5533 ;; Each header matching the entry.
5534 (setq beg (match-beginning 0))
5535 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
5536 (match-beginning 0))
5539 (while (re-search-forward (eval (nth 1 entry)) end t)
5540 ;; Each match within a header.
5541 (let* ((entry (cdr entry))
5542 (start (match-beginning (nth 1 entry)))
5543 (end (match-end (nth 1 entry)))
5544 (form (nth 2 entry)))
5545 (goto-char (match-end 0))
5547 (gnus-article-add-button
5548 start end (nth 3 entry)
5549 (buffer-substring (match-beginning (nth 4 entry))
5550 (match-end (nth 4 entry)))))))
5551 (goto-char end)))))))
5553 ;;; External functions:
5555 (defun gnus-article-add-button (from to fun &optional data)
5556 "Create a button between FROM and TO with callback FUN and data DATA."
5557 (when gnus-article-button-face
5558 (gnus-overlay-put (gnus-make-overlay from to)
5559 'face gnus-article-button-face))
5560 (gnus-add-text-properties
5562 (nconc (and gnus-article-mouse-face
5563 (list gnus-mouse-face-prop gnus-article-mouse-face))
5564 (list 'gnus-callback fun)
5565 (and data (list 'gnus-data data))))
5566 (widget-convert-button 'link from to :action 'gnus-widget-press-button
5567 :button-keymap gnus-widget-button-keymap))
5569 ;;; Internal functions:
5571 (defun gnus-article-set-globals ()
5573 (set-buffer gnus-summary-buffer)
5574 (gnus-set-global-variables)))
5576 (defun gnus-signature-toggle (end)
5578 (set-buffer gnus-article-buffer)
5579 (let ((buffer-read-only nil)
5580 (inhibit-point-motion-hooks t))
5581 (if (text-property-any end (point-max) 'article-type 'signature)
5583 (gnus-delete-wash-type 'signature)
5584 (gnus-remove-text-properties-when
5585 'article-type 'signature end (point-max)
5586 (cons 'article-type (cons 'signature
5587 gnus-hidden-properties))))
5588 (gnus-add-wash-type 'signature)
5589 (gnus-add-text-properties-when
5590 'article-type nil end (point-max)
5591 (cons 'article-type (cons 'signature
5592 gnus-hidden-properties)))))
5593 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
5594 (gnus-set-mode-line 'article))))
5596 (defun gnus-button-entry ()
5597 ;; Return the first entry in `gnus-button-alist' matching this place.
5598 (let ((alist gnus-button-alist)
5601 (setq entry (pop alist))
5602 (if (looking-at (eval (car entry)))
5607 (defun gnus-button-push (marker)
5608 ;; Push button starting at MARKER.
5611 (let* ((entry (gnus-button-entry))
5612 (inhibit-point-motion-hooks t)
5614 (args (mapcar (lambda (group)
5615 (let ((string (match-string group)))
5616 (gnus-set-text-properties
5617 0 (length string) nil string)
5624 (fboundp (symbol-value fun)))
5625 (apply (symbol-value fun) args))
5627 (gnus-message 1 "You must define `%S' to use this button"
5628 (cons fun args)))))))
5630 (defun gnus-parse-news-url (url)
5631 (let (scheme server group message-id articles)
5634 (goto-char (point-min))
5635 (when (looking-at "\\([A-Za-z]+\\):")
5636 (setq scheme (match-string 1))
5637 (goto-char (match-end 0)))
5638 (when (looking-at "//\\([^/]+\\)/")
5639 (setq server (match-string 1))
5640 (goto-char (match-end 0)))
5643 ((looking-at "\\(.*@.*\\)")
5644 (setq message-id (match-string 1)))
5645 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
5646 (setq group (match-string 1)
5647 articles (split-string (match-string 2) "-")))
5648 ((looking-at "\\([^/]+\\)/?")
5649 (setq group (match-string 1)))
5651 (error "Unknown news URL syntax"))))
5652 (list scheme server group message-id articles)))
5654 (defun gnus-button-handle-news (url)
5656 (destructuring-bind (scheme server group message-id articles)
5657 (gnus-parse-news-url url)
5661 (set-buffer gnus-summary-buffer)
5663 (let ((gnus-refer-article-method (list (list 'nntp server))))
5664 (gnus-summary-refer-article message-id))
5665 (gnus-summary-refer-article message-id))))
5667 (gnus-button-fetch-group url)))))
5669 (defun gnus-button-handle-man (url)
5671 (funcall gnus-button-man-handler url))
5673 (defun gnus-button-handle-info (url)
5674 "Fetch an info URL."
5676 "^\\([^:/]+\\)?/\\(.*\\)"
5678 (gnus-info-find-node
5679 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
5682 (gnus-url-unhex-string (match-string 2 url))))
5683 (error "Can't parse %s" url)))
5685 (defun gnus-button-message-id (message-id)
5688 (set-buffer gnus-summary-buffer)
5689 (gnus-summary-refer-article message-id)))
5691 (defun gnus-button-fetch-group (address)
5692 "Fetch GROUP specified by ADDRESS."
5693 (if (not (string-match "[:/]" address))
5694 ;; This is just a simple group url.
5695 (gnus-group-read-ephemeral-group address gnus-select-method)
5698 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
5700 (error "Can't parse %s" address)
5701 (gnus-group-read-ephemeral-group
5702 (match-string 4 address)
5703 `(nntp ,(match-string 1 address)
5704 (nntp-address ,(match-string 1 address))
5705 (nntp-port-number ,(if (match-end 3)
5706 (match-string 3 address)
5709 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
5711 (defun gnus-url-parse-query-string (query &optional downcase)
5712 (let (retval pairs cur key val)
5713 (setq pairs (split-string query "&"))
5715 (setq cur (car pairs)
5717 (if (not (string-match "=" cur))
5719 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
5720 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
5722 (setq key (downcase key)))
5723 (setq cur (assoc key retval))
5725 (setcdr cur (cons val (cdr cur)))
5726 (setq retval (cons (list key val) retval)))))
5729 (defun gnus-url-mailto (url)
5730 ;; Send mail to someone
5731 (when (string-match "mailto:/*\\(.*\\)" url)
5732 (setq url (substring url (match-beginning 1) nil)))
5733 (let (to args subject func)
5734 (if (string-match (regexp-quote "?") url)
5735 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
5736 args (gnus-url-parse-query-string
5737 (substring url (match-end 0) nil) t))
5738 (setq to (gnus-url-unhex-string url)))
5739 (setq args (cons (list "to" to) args)
5740 subject (cdr-safe (assoc "subject" args)))
5743 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
5746 (message-position-on-field (caar args)))
5747 (insert (mapconcat 'identity (cdar args) ", "))
5748 (setq args (cdr args)))
5751 (message-goto-subject))))
5753 (defun gnus-button-embedded-url (address)
5754 "Activate ADDRESS with `browse-url'."
5755 (browse-url (gnus-strip-whitespace address)))
5757 ;;; Next/prev buttons in the article buffer.
5759 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
5760 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
5762 (defvar gnus-prev-page-map
5763 (let ((map (make-sparse-keymap)))
5764 (unless (>= emacs-major-version 21)
5765 ;; XEmacs doesn't care.
5766 (set-keymap-parent map gnus-article-mode-map))
5767 (define-key map gnus-mouse-2 'gnus-button-prev-page)
5768 (define-key map "\r" 'gnus-button-prev-page)
5771 (defun gnus-insert-prev-page-button ()
5773 (buffer-read-only nil))
5775 gnus-prev-page-line-format nil
5776 `(,@(gnus-local-map-property gnus-prev-page-map)
5778 gnus-callback gnus-article-button-prev-page
5779 article-type annotation))
5780 (widget-convert-button
5782 :action 'gnus-button-prev-page
5783 :button-keymap gnus-prev-page-map)))
5785 (defvar gnus-prev-page-map
5786 (let ((map (make-sparse-keymap)))
5787 (unless (>= emacs-major-version 21)
5788 ;; XEmacs doesn't care.
5789 (set-keymap-parent map gnus-article-mode-map))
5790 (define-key map gnus-mouse-2 'gnus-button-prev-page)
5791 (define-key map "\r" 'gnus-button-prev-page)
5794 (defvar gnus-next-page-map
5795 (let ((map (make-sparse-keymap)))
5796 (unless (>= emacs-major-version 21)
5797 ;; XEmacs doesn't care.
5798 (set-keymap-parent map gnus-article-mode-map))
5799 (define-key map gnus-mouse-2 'gnus-button-next-page)
5800 (define-key map "\r" 'gnus-button-next-page)
5803 (defun gnus-button-next-page (&optional args more-args)
5804 "Go to the next page."
5806 (let ((win (selected-window)))
5807 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5808 (gnus-article-next-page)
5809 (select-window win)))
5811 (defun gnus-button-prev-page (&optional args more-args)
5812 "Go to the prev page."
5814 (let ((win (selected-window)))
5815 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5816 (gnus-article-prev-page)
5817 (select-window win)))
5819 (defun gnus-insert-next-page-button ()
5821 (buffer-read-only nil))
5822 (gnus-eval-format gnus-next-page-line-format nil
5823 `(,@(gnus-local-map-property gnus-next-page-map)
5825 gnus-callback gnus-article-button-next-page
5826 article-type annotation))
5827 (widget-convert-button
5829 :action 'gnus-button-next-page
5830 :button-keymap gnus-next-page-map)))
5832 (defun gnus-article-button-next-page (arg)
5833 "Go to the next page."
5835 (let ((win (selected-window)))
5836 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5837 (gnus-article-next-page)
5838 (select-window win)))
5840 (defun gnus-article-button-prev-page (arg)
5841 "Go to the prev page."
5843 (let ((win (selected-window)))
5844 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5845 (gnus-article-prev-page)
5846 (select-window win)))
5848 (defvar gnus-decode-header-methods
5849 '(mail-decode-encoded-word-region)
5850 "List of methods used to decode headers.
5852 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
5853 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
5854 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
5855 whose names match REGEXP.
5858 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
5859 mail-decode-encoded-word-region
5860 (\"chinese\" . rfc1843-decode-region))
5863 (defvar gnus-decode-header-methods-cache nil)
5865 (defun gnus-multi-decode-header (start end)
5866 "Apply the functions from `gnus-encoded-word-methods' that match."
5867 (unless (and gnus-decode-header-methods-cache
5868 (eq gnus-newsgroup-name
5869 (car gnus-decode-header-methods-cache)))
5870 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
5873 (nconc gnus-decode-header-methods-cache (list x))
5874 (if (and gnus-newsgroup-name
5875 (string-match (car x) gnus-newsgroup-name))
5876 (nconc gnus-decode-header-methods-cache
5878 gnus-decode-header-methods))
5879 (let ((xlist gnus-decode-header-methods-cache))
5882 (narrow-to-region start end)
5884 (funcall (pop xlist) (point-min) (point-max))))))
5887 ;;; Treatment top-level handling.
5890 (defun gnus-treat-article (condition &optional part-number total-parts type)
5891 (let ((length (- (point-max) (point-min)))
5892 (alist gnus-treatment-function-alist)
5893 (article-goto-body-goes-to-point-min-p t)
5897 (let ((list gnus-article-treat-types))
5899 (when (string-match (pop list) type)
5900 (throw 'found t)))))))
5901 (highlightp (gnus-visual-p 'article-highlight 'highlight))
5903 (gnus-run-hooks 'gnus-part-display-hook)
5904 (while (setq elem (pop alist))
5907 (if (gnus-buffer-live-p gnus-summary-buffer)
5908 (set-buffer gnus-summary-buffer))
5909 (symbol-value (car elem))))
5910 (when (and (or (consp val)
5912 (gnus-treat-predicate val)
5913 (or (not (get (car elem) 'highlight))
5916 (funcall (cadr elem)))))))
5918 ;; Dynamic variables.
5920 (defvar part-number)
5921 (defvar total-parts)
5926 (defun gnus-treat-predicate (val)
5931 (stringp (car val)))
5932 (apply 'gnus-or (mapcar `(lambda (s)
5933 (string-match s ,(or gnus-newsgroup-name "")))
5936 (let ((pred (pop val)))
5939 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
5941 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
5943 (not (gnus-treat-predicate (car val))))
5945 (equal (car val) type))
5947 (error "%S is not a valid predicate" pred)))))
5955 (eq part-number total-parts))
5959 (error "%S is not a valid value" val))))
5961 (defun gnus-article-encrypt-body (protocol &optional n)
5962 "Encrypt the article body."
5965 (or gnus-article-encrypt-protocol
5966 (completing-read "Encrypt protocol: "
5967 gnus-article-encrypt-protocol-alist
5969 current-prefix-arg))
5970 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
5972 (error (format "Can't find the encrypt protocol %s" protocol)))
5973 (if (equal gnus-newsgroup-name "nndraft:drafts")
5974 (error "Can't encrypt the article in group nndraft:drafts"))
5975 (if (equal gnus-newsgroup-name "nndraft:queue")
5976 (error "Don't encrypt the article in group nndraft:queue"))
5977 (gnus-summary-iterate n
5979 (set-buffer gnus-summary-buffer)
5980 (let ((mail-parse-charset gnus-newsgroup-charset)
5981 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5982 (summary-buffer gnus-summary-buffer)
5984 (gnus-set-global-variables)
5985 (when (gnus-group-read-only-p)
5986 (error "The current newsgroup does not support article encrypt"))
5987 (gnus-summary-show-article t)
5989 (or (mail-header-references gnus-current-headers) ""))
5990 (set-buffer gnus-article-buffer)
5991 (let* ((buffer-read-only nil)
5993 (mapcar (lambda (field)
5994 (and (save-restriction
5995 (message-narrow-to-head)
5996 (goto-char (point-min))
5997 (search-forward field nil t))
5999 (message-narrow-to-field)
6000 (buffer-substring (point-min) (point-max))
6001 (delete-region (point-min) (point-max))
6003 '("Content-Type:" "Content-Transfer-Encoding:"
6004 "Content-Disposition:"))))
6005 (message-narrow-to-head)
6006 (message-remove-header "MIME-Version")
6007 (goto-char (point-max))
6008 (setq point (point))
6009 (insert (apply 'concat headers))
6011 (narrow-to-region point (point-max))
6012 (let ((message-options message-options))
6013 (message-options-set 'message-sender user-mail-address)
6014 (message-options-set 'message-recipients user-mail-address)
6015 (message-options-set 'message-sign-encrypt 'not)
6017 (goto-char (point-min))
6018 (insert "MIME-Version: 1.0\n")
6020 (gnus-summary-edit-article-done
6021 references nil summary-buffer t))
6022 (when gnus-keep-backlog
6023 (gnus-backlog-remove-article
6024 (car gnus-article-current) (cdr gnus-article-current)))
6026 (when (get-buffer gnus-original-article-buffer)
6027 (set-buffer gnus-original-article-buffer)
6028 (setq gnus-original-article nil)))
6029 (when gnus-use-cache
6030 (gnus-cache-update-article
6031 (car gnus-article-current) (cdr gnus-article-current))))))))
6033 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
6034 "The following specs can be used:
6035 %t The security MIME type
6038 %D Details if button is pressed")
6040 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
6041 "The following specs can be used:
6042 %t The security MIME type
6045 %D Details if button is pressed")
6047 (defvar gnus-mime-security-button-line-format-alist
6048 '((?t gnus-tmp-type ?s)
6049 (?i gnus-tmp-info ?s)
6050 (?d gnus-tmp-details ?s)
6051 (?D gnus-tmp-pressed-details ?s)))
6053 (defvar gnus-mime-security-button-map
6054 (let ((map (make-sparse-keymap)))
6055 (unless (>= (string-to-number emacs-version) 21)
6056 (set-keymap-parent map gnus-article-mode-map))
6057 (define-key map gnus-mouse-2 'gnus-article-push-button)
6058 (define-key map "\r" 'gnus-article-press-button)
6061 (defvar gnus-mime-security-details-buffer nil)
6063 (defvar gnus-mime-security-button-pressed nil)
6065 (defvar gnus-mime-security-show-details-inline t
6066 "If non-nil, show details in the article buffer.")
6068 (defun gnus-mime-security-verify-or-decrypt (handle)
6069 (mm-remove-parts (cdr handle))
6070 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
6071 point buffer-read-only)
6073 (goto-char (car region)))
6075 (narrow-to-region (point) (point))
6076 (with-current-buffer (mm-handle-multipart-original-buffer handle)
6077 (let* ((mm-verify-option 'known)
6078 (mm-decrypt-option 'known)
6079 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
6080 (unless (eq nparts (cdr handle))
6081 (mm-destroy-parts (cdr handle))
6082 (setcdr handle nparts))))
6083 (setq point (point))
6084 (gnus-mime-display-security handle)
6085 (goto-char (point-max)))
6087 (delete-region (point) (cdr region))
6088 (set-marker (car region) nil)
6089 (set-marker (cdr region) nil))
6092 (defun gnus-mime-security-show-details (handle)
6093 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
6095 (if gnus-mime-security-show-details-inline
6096 (let ((gnus-mime-security-button-pressed t)
6097 (gnus-mime-security-button-line-format
6098 (get-text-property (point) 'gnus-line-format))
6101 (while (eq (get-text-property (point) 'gnus-line-format)
6102 gnus-mime-security-button-line-format)
6106 (narrow-to-region (point) (point))
6107 (gnus-insert-mime-security-button handle))
6108 (delete-region (point)
6109 (or (text-property-not-all
6112 gnus-mime-security-button-line-format)
6114 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
6115 (with-current-buffer gnus-mime-security-details-buffer
6118 (setq gnus-mime-security-details-buffer
6119 (gnus-get-buffer-create "*MIME Security Details*")))
6120 (with-current-buffer gnus-mime-security-details-buffer
6122 (goto-char (point-min)))
6123 (pop-to-buffer gnus-mime-security-details-buffer))
6124 (gnus-message 5 "No details."))))
6126 (defun gnus-mime-security-press-button (handle)
6127 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6128 (gnus-mime-security-show-details handle)
6129 (gnus-mime-security-verify-or-decrypt handle)))
6131 (defun gnus-insert-mime-security-button (handle &optional displayed)
6132 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
6135 (or (nth 2 (assoc protocol mm-verify-function-alist))
6136 (nth 2 (assoc protocol mm-decrypt-function-alist))
6138 (if (equal (car handle) "multipart/signed")
6139 " Signed" " Encrypted")
6142 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6145 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
6146 gnus-tmp-pressed-details
6148 (setq gnus-tmp-details
6149 (if gnus-tmp-details
6150 (concat "\n" gnus-tmp-details) ""))
6151 (setq gnus-tmp-pressed-details
6152 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
6157 gnus-mime-security-button-line-format
6158 gnus-mime-security-button-line-format-alist
6159 `(,@(gnus-local-map-property gnus-mime-security-button-map)
6160 gnus-callback gnus-mime-security-press-button
6161 gnus-line-format ,gnus-mime-security-button-line-format
6162 article-type annotation
6165 (widget-convert-button
6168 :action 'gnus-widget-press-button
6169 :button-keymap gnus-mime-security-button-map
6171 (lambda (widget/window &optional overlay pos)
6172 ;; Needed to properly clear the message due to a bug in
6173 ;; wid-edit (XEmacs only).
6174 (if (boundp 'help-echo-owns-message)
6175 (setq help-echo-owns-message t))
6178 (aref gnus-mouse-2 0))))))
6180 (defun gnus-mime-display-security (handle)
6182 (narrow-to-region (point) (point))
6183 (unless (gnus-unbuttonized-mime-type-p (car handle))
6184 (gnus-insert-mime-security-button handle))
6185 (gnus-mime-display-mixed (cdr handle))
6188 (unless (gnus-unbuttonized-mime-type-p (car handle))
6189 (let ((gnus-mime-security-button-line-format
6190 gnus-mime-security-button-end-line-format))
6191 (gnus-insert-mime-security-button handle)))
6192 (mm-set-handle-multipart-parameter
6194 (cons (set-marker (make-marker) (point-min))
6195 (set-marker (make-marker) (point-max))))))
6201 (run-hooks 'gnus-art-load-hook)
6203 ;;; gnus-art.el ends here