1 ;;; gnus-art.el --- article mode commands for Semi-gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
7 ;; Katsumi Yamaoka <yamaoka@jpl.org>
8 ;; Keywords: mail, news, MIME
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
31 (eval-when-compile (require 'cl))
32 (eval-when-compile (require 'static))
44 ;; Avoid byte-compile warnings.
53 (autoload 'gnus-msg-mail "gnus-msg" nil t)
54 (autoload 'gnus-button-mailto "gnus-msg")
55 (autoload 'gnus-button-reply "gnus-msg" nil t)
57 (defgroup gnus-article nil
59 :link '(custom-manual "(gnus)The Article Buffer")
62 (defgroup gnus-article-treat nil
63 "Treating article parts."
64 :link '(custom-manual "(gnus)Article Hiding")
67 (defgroup gnus-article-hiding nil
68 "Hiding article parts."
69 :link '(custom-manual "(gnus)Article Hiding")
72 (defgroup gnus-article-highlight nil
73 "Article highlighting."
74 :link '(custom-manual "(gnus)Article Highlighting")
78 (defgroup gnus-article-signature nil
80 :link '(custom-manual "(gnus)Article Signature")
83 (defgroup gnus-article-headers nil
85 :link '(custom-manual "(gnus)Hiding Headers")
88 (defgroup gnus-article-washing nil
89 "Special commands on articles."
90 :link '(custom-manual "(gnus)Article Washing")
93 (defgroup gnus-article-emphasis nil
94 "Fontisizing articles."
95 :link '(custom-manual "(gnus)Article Fontisizing")
98 (defgroup gnus-article-saving nil
100 :link '(custom-manual "(gnus)Saving Articles")
101 :group 'gnus-article)
103 (defgroup gnus-article-mime nil
104 "Worshiping the MIME wonder."
105 :link '(custom-manual "(gnus)Using MIME")
106 :group 'gnus-article)
108 (defgroup gnus-article-buttons nil
109 "Pushable buttons in the article buffer."
110 :link '(custom-manual "(gnus)Article Buttons")
111 :group 'gnus-article)
113 (defgroup gnus-article-various nil
114 "Other article options."
115 :link '(custom-manual "(gnus)Misc Article")
116 :group 'gnus-article)
118 (defcustom gnus-ignored-headers
119 '("^Path:" "^Expires:" "^Date-Received:" "^References:" "^Xref:" "^Lines:"
120 "^Relay-Version:" "^Message-ID:" "^Approved:" "^Sender:" "^Received:"
121 "^X-UIDL:" "^MIME-Version:" "^Return-Path:" "^In-Reply-To:"
122 "^Content-Type:" "^Content-Transfer-Encoding:" "^X-WebTV-Signature:"
123 "^X-MimeOLE:" "^X-MSMail-Priority:" "^X-Priority:" "^X-Loop:"
124 "^X-Authentication-Warning:" "^X-MIME-Autoconverted:" "^X-Face"
125 "^X-Attribution:" "^X-Originating-IP:" "^Delivered-To:"
126 "^NNTP-[-A-Za-z]+:" "^Distribution:" "^X-no-archive:" "^X-Trace:"
127 "^X-Complaints-To:" "^X-NNTP-Posting-Host:" "^X-Orig.*:"
128 "^Abuse-Reports-To:" "^Cache-Post-Path:" "^X-Article-Creation-Date:"
129 "^X-Poster:" "^X-Mail2News-Path:" "^X-Server-Date:" "^X-Cache:"
130 "^Originator:" "^X-Problems-To:" "^X-Auth-User:" "^X-Post-Time:"
131 "^X-Admin:" "^X-UID:" "^Resent-[-A-Za-z]+:" "^X-Mailing-List:"
132 "^Precedence:" "^Original-[-A-Za-z]+:" "^X-filename:" "^X-Orcpt:"
133 "^Old-Received:" "^X-Pgp" "^X-Auth:" "^X-From-Line:"
134 "^X-Gnus-Article-Number:" "^X-Majordomo:" "^X-Url:" "^X-Sender:"
135 "^MBOX-Line" "^Priority:" "^X400-[-A-Za-z]+:"
136 "^Status:" "^X-Gnus-Mail-Source:" "^Cancel-Lock:"
137 "^X-FTN" "^X-EXP32-SerialNo:" "^Encoding:" "^Importance:"
138 "^Autoforwarded:" "^Original-Encoded-Information-Types:" "^X-Ya-Pop3:"
139 "^X-Face-Version:" "^X-Vms-To:" "^X-ML-NAME:" "^X-ML-COUNT:"
140 "^Mailing-List:" "^X-finfo:" "^X-md5sum:" "^X-md5sum-Origin:"
141 "^X-Sun-Charset:" "^X-Accept-Language:" "^X-Envelope-Sender:"
142 "^List-[A-Za-z]+:" "^X-Listprocessor-Version:"
143 "^X-Received:" "^X-Distribute:" "^X-Sequence:" "^X-Juno-Line-Breaks:"
144 "^X-Notes-Item:" "^X-MS-TNEF-Correlator:" "^x-uunet-gateway:"
145 "^X-Received:" "^Content-length:" "X-precedence:"
146 "^X-Authenticated-User:" "^X-Comment" "^X-Report:" "^X-Abuse-Info:"
147 "^X-HTTP-Proxy:" "^X-Mydeja-Info:" "^X-Copyright" "^X-No-Markup:"
148 "^X-Abuse-Info:" "^X-From_:" "^X-Accept-Language:" "^Errors-To:"
149 "^X-BeenThere:" "^X-Mailman-Version:" "^List-Help:" "^List-Post:"
150 "^List-Subscribe:" "^List-Id:" "^List-Unsubscribe:" "^List-Archive:"
151 "^X-Content-length:" "^X-Posting-Agent:" "^Original-Received:"
152 "^X-Request-PGP:" "^X-Fingerprint:" "^X-WRIEnvto:" "^X-WRIEnvfrom:"
153 "^X-Virus-Scanned:" "^X-Delivery-Agent:" "^Posted-Date:" "^X-Gateway:"
154 "^X-Local-Origin:" "^X-Local-Destination:" "^X-UserInfo1:"
156 "*All headers that start with this regexp will be hidden.
157 This variable can also be a list of regexps of headers to be ignored.
158 If `gnus-visible-headers' is non-nil, this variable will be ignored."
159 :type '(choice :custom-show nil
162 :group 'gnus-article-hiding)
164 (defcustom gnus-visible-headers
165 "^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:"
166 "*All headers that do not match this regexp will be hidden.
167 This variable can also be a list of regexp of headers to remain visible.
168 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
169 :type '(repeat :value-to-internal (lambda (widget value)
170 (custom-split-regexp-maybe value))
171 :match (lambda (widget value)
173 (widget-editable-list-match widget value)))
175 :group 'gnus-article-hiding)
177 (defcustom gnus-sorted-header-list
178 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
179 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
180 "*This variable is a list of regular expressions.
181 If it is non-nil, headers that match the regular expressions will
182 be placed first in the article buffer in the sequence specified by
184 :type '(repeat regexp)
185 :group 'gnus-article-hiding)
187 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
188 "Headers that are only to be displayed if they have interesting data.
189 Possible values in this list are:
191 'empty Headers with no content.
192 'newsgroups Newsgroup identical to Gnus group.
193 'to-address To identical to To-address.
194 'followup-to Followup-to identical to Newsgroups.
195 'reply-to Reply-to identical to From.
196 'date Date less than four days old.
197 'long-to To and/or Cc longer than 1024 characters.
198 'many-to Multiple To and/or Cc."
199 :type '(set (const :tag "Headers with no content." empty)
200 (const :tag "Newsgroups identical to Gnus group." newsgroups)
201 (const :tag "To identical to To-address." to-address)
202 (const :tag "Followup-to identical to Newsgroups." followup-to)
203 (const :tag "Reply-to identical to From." reply-to)
204 (const :tag "Date less than four days old." date)
205 (const :tag "To and/or Cc longer than 1024 characters." long-to)
206 (const :tag "Multiple To and/or Cc headers." many-to))
207 :group 'gnus-article-hiding)
209 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
210 "Regexp matching signature separator.
211 This can also be a list of regexps. In that case, it will be checked
212 from head to tail looking for a separator. Searches will be done from
213 the end of the buffer."
214 :type '(repeat string)
215 :group 'gnus-article-signature)
217 (defcustom gnus-signature-limit nil
218 "Provide a limit to what is considered a signature.
219 If it is a number, no signature may not be longer (in characters) than
220 that number. If it is a floating point number, no signature may be
221 longer (in lines) than that number. If it is a function, the function
222 will be called without any parameters, and if it returns nil, there is
223 no signature in the buffer. If it is a string, it will be used as a
224 regexp. If it matches, the text in question is not a signature."
225 :type '(choice (integer :value 200)
227 (function :value fun)
228 (regexp :value ".*"))
229 :group 'gnus-article-signature)
231 (defcustom gnus-hidden-properties '(invisible t intangible t)
232 "Property list to use for hiding text."
234 :group 'gnus-article-hiding)
236 ;; Fixme: This isn't the right thing for mixed graphical and and
237 ;; non-graphical frames in a session.
238 (defcustom gnus-article-x-face-command
241 (if (or (gnus-image-type-available-p 'xface)
242 (gnus-image-type-available-p 'pbm))
243 'gnus-display-x-face-in-from
244 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -"))
245 ((and (fboundp 'image-type-available-p)
246 (module-installed-p 'x-face-e21))
247 'x-face-decode-message-header)
248 ((gnus-image-type-available-p 'pbm)
249 'gnus-display-x-face-in-from)
251 (module-installed-p 'x-face-mule))
252 'x-face-mule-gnus-article-display-x-face)
254 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
256 "*String or function to be executed to display an X-Face header.
257 If it is a string, the command will be executed in a sub-shell
258 asynchronously. The compressed face will be piped to this command."
260 ,@(let (x-face-e21 x-face-mule)
261 (if (featurep 'xemacs)
263 (setq x-face-e21 (module-installed-p 'x-face-e21)
264 x-face-mule (module-installed-p 'x-face-mule)))
268 (if (or (gnus-image-type-available-p 'xface)
269 (gnus-image-type-available-p 'pbm))
270 '(function-item gnus-display-x-face-in-from))
272 (fboundp 'image-type-available-p))
274 :tag "x-face-decode-message-header (x-face-e21)"
275 x-face-decode-message-header))
278 x-face-mule-gnus-article-display-x-face))
281 :group 'gnus-article-washing)
283 (defcustom gnus-article-x-face-too-ugly nil
284 "Regexp matching posters whose face shouldn't be shown automatically."
285 :type '(choice regexp (const nil))
286 :group 'gnus-article-washing)
288 (defcustom gnus-article-banner-alist nil
289 "Banner alist for stripping.
291 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
293 :type '(repeat (cons symbol regexp))
294 :group 'gnus-article-washing)
296 (gnus-define-group-parameter
299 "Alist of regexps (to match group names) and banner."
300 :variable-group gnus-article-washing
302 '(choice :tag "Banner"
304 (const :tag "Remove signature" signature)
305 (symbol :tag "Item in `gnus-article-banner-alist'" none)
307 (const :tag "None" nil))
309 "If non-nil, specify how to remove `banners' from articles.
311 Symbol `signature' means to remove signatures delimited by
312 `gnus-signature-separator'. Any other symbol is used to look up a
313 regular expression to match the banner in `gnus-article-banner-alist'.
314 A string is used as a regular expression to match the banner
317 (defcustom gnus-emphasis-alist
319 "\\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)")
324 ("_/" "/_" underline-italic)
325 ("_\\*" "\\*_" underline-bold)
326 ("\\*/" "/\\*" bold-italic)
327 ("_\\*/" "/\\*_" underline-bold-italic))))
331 (format format (car spec) (car (cdr spec)))
332 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
334 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
335 2 3 gnus-emphasis-underline)))
336 "*Alist that says how to fontify certain phrases.
337 Each item looks like this:
339 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
341 The first element is a regular expression to be matched. The second
342 is a number that says what regular expression grouping used to find
343 the entire emphasized word. The third is a number that says what
344 regexp grouping should be displayed and highlighted. The fourth
345 is the face used for highlighting."
346 :type '(repeat (list :value ("" 0 0 default)
348 (integer :tag "Match group")
349 (integer :tag "Emphasize group")
351 :group 'gnus-article-emphasis)
353 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
354 "A regexp to describe whitespace which should not be emphasized.
355 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
356 The former avoids underlining of leading and trailing whitespace,
357 and the latter avoids underlining any whitespace at all."
359 :group 'gnus-article-emphasis
362 (defface gnus-emphasis-bold '((t (:bold t)))
363 "Face used for displaying strong emphasized text (*word*)."
364 :group 'gnus-article-emphasis)
366 (defface gnus-emphasis-italic '((t (:italic t)))
367 "Face used for displaying italic emphasized text (/word/)."
368 :group 'gnus-article-emphasis)
370 (defface gnus-emphasis-underline '((t (:underline t)))
371 "Face used for displaying underlined emphasized text (_word_)."
372 :group 'gnus-article-emphasis)
374 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
375 "Face used for displaying underlined bold emphasized text (_*word*_)."
376 :group 'gnus-article-emphasis)
378 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
379 "Face used for displaying underlined italic emphasized text (_/word/_)."
380 :group 'gnus-article-emphasis)
382 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
383 "Face used for displaying bold italic emphasized text (/*word*/)."
384 :group 'gnus-article-emphasis)
386 (defface gnus-emphasis-underline-bold-italic
387 '((t (:bold t :italic t :underline t)))
388 "Face used for displaying underlined bold italic emphasized text.
389 Esample: (_/*word*/_)."
390 :group 'gnus-article-emphasis)
392 (defface gnus-emphasis-highlight-words
393 '((t (:background "black" :foreground "yellow")))
394 "Face used for displaying highlighted words."
395 :group 'gnus-article-emphasis)
397 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
398 "Format for display of Date headers in article bodies.
399 See `format-time-string' for the possible values.
401 The variable can also be function, which should return a complete Date
402 header. The function is called with one argument, the time, which can
403 be fed to `format-time-string'."
404 :type '(choice string symbol)
405 :link '(custom-manual "(gnus)Article Date")
406 :group 'gnus-article-washing)
409 (autoload 'mail-extract-address-components "mail-extr"))
411 (defcustom gnus-save-all-headers t
412 "*If non-nil, don't remove any headers before saving."
413 :group 'gnus-article-saving
416 (defcustom gnus-prompt-before-saving 'always
417 "*This variable says how much prompting is to be done when saving articles.
418 If it is nil, no prompting will be done, and the articles will be
419 saved to the default files. If this variable is `always', each and
420 every article that is saved will be preceded by a prompt, even when
421 saving large batches of articles. If this variable is neither nil not
422 `always', there the user will be prompted once for a file name for
423 each invocation of the saving commands."
424 :group 'gnus-article-saving
425 :type '(choice (item always)
426 (item :tag "never" nil)
427 (sexp :tag "once" :format "%t\n" :value t)))
429 (defcustom gnus-saved-headers gnus-visible-headers
430 "Headers to keep if `gnus-save-all-headers' is nil.
431 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
432 If that variable is nil, however, all headers that match this regexp
433 will be kept while the rest will be deleted before saving."
434 :group 'gnus-article-saving
437 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
438 "A function to save articles in your favourite format.
439 The function must be interactively callable (in other words, it must
440 be an Emacs command).
442 Gnus provides the following functions:
444 * gnus-summary-save-in-rmail (Rmail format)
445 * gnus-summary-save-in-mail (Unix mail format)
446 * gnus-summary-save-in-folder (MH folder)
447 * gnus-summary-save-in-file (article format)
448 * gnus-summary-save-body-in-file (article body)
449 * gnus-summary-save-in-vm (use VM's folder format)
450 * gnus-summary-write-to-file (article format -- overwrite)."
451 :group 'gnus-article-saving
452 :type '(radio (function-item gnus-summary-save-in-rmail)
453 (function-item gnus-summary-save-in-mail)
454 (function-item gnus-summary-save-in-folder)
455 (function-item gnus-summary-save-in-file)
456 (function-item gnus-summary-save-body-in-file)
457 (function-item gnus-summary-save-in-vm)
458 (function-item gnus-summary-write-to-file)))
460 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
461 "A function generating a file name to save articles in Rmail format.
462 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
463 :group 'gnus-article-saving
466 (defcustom gnus-mail-save-name 'gnus-plain-save-name
467 "A function generating a file name to save articles in Unix mail format.
468 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
469 :group 'gnus-article-saving
472 (defcustom gnus-folder-save-name 'gnus-folder-save-name
473 "A function generating a file name to save articles in MH folder.
474 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
475 :group 'gnus-article-saving
478 (defcustom gnus-file-save-name 'gnus-numeric-save-name
479 "A function generating a file name to save articles in article format.
480 The function is called with NEWSGROUP, HEADERS, and optional
482 :group 'gnus-article-saving
485 (defcustom gnus-split-methods
486 '((gnus-article-archive-name)
487 (gnus-article-nndoc-name))
488 "*Variable used to suggest where articles are to be saved.
489 For instance, if you would like to save articles related to Gnus in
490 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
491 you could set this variable to something like:
493 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
494 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
496 This variable is an alist where the where the key is the match and the
497 value is a list of possible files to save in if the match is non-nil.
499 If the match is a string, it is used as a regexp match on the
500 article. If the match is a symbol, that symbol will be funcalled
501 from the buffer of the article to be saved with the newsgroup as the
502 parameter. If it is a list, it will be evaled in the same buffer.
504 If this form or function returns a string, this string will be used as
505 a possible file name; and if it returns a non-nil list, that list will
506 be used as possible file names."
507 :group 'gnus-article-saving
508 :type '(repeat (choice (list :value (fun) function)
509 (cons :value ("" "") regexp (repeat string))
512 (defcustom gnus-article-display-method-for-mime
513 'gnus-article-display-mime-message
514 "Function to display a MIME message.
515 The function is called from the article buffer."
516 :group 'gnus-article-mime
519 (defcustom gnus-article-display-method-for-traditional
520 'gnus-article-display-traditional-message
521 "*Function to display a traditional message.
522 The function is called from the article buffer."
523 :group 'gnus-article-mime
526 (defcustom gnus-page-delimiter "^\^L"
527 "*Regexp describing what to use as article page delimiters.
528 The default value is \"^\^L\", which is a form linefeed at the
529 beginning of a line."
531 :group 'gnus-article-various)
533 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
534 "*The format specification for the article mode line.
535 See `gnus-summary-mode-line-format' for a closer description.
537 The following additional specs are available:
539 %w The article washing status.
540 %m The number of MIME parts in the article."
542 :group 'gnus-article-various)
544 (defcustom gnus-article-mode-hook nil
545 "*A hook for Gnus article mode."
547 :group 'gnus-article-various)
549 (when (featurep 'xemacs)
550 ;; Extracted from gnus-xmas-define in order to preserve user settings
551 (when (fboundp 'turn-off-scroll-in-place)
552 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
553 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
554 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
556 (defcustom gnus-article-menu-hook nil
557 "*Hook run after the creation of the article mode menu."
559 :group 'gnus-article-various)
561 (defcustom gnus-article-prepare-hook nil
562 "*A hook called after an article has been prepared in the article buffer."
564 :group 'gnus-article-various)
566 (defcustom gnus-article-hide-pgp-hook nil
567 "*A hook called after successfully hiding a PGP signature."
569 :group 'gnus-article-various)
571 (defcustom gnus-article-button-face 'bold
572 "Face used for highlighting buttons in the article buffer.
574 An article button is a piece of text that you can activate by pressing
575 `RET' or `mouse-2' above it."
577 :group 'gnus-article-buttons)
579 (defcustom gnus-article-mouse-face 'highlight
580 "Face used for mouse highlighting in the article buffer.
582 Article buttons will be displayed in this face when the cursor is
585 :group 'gnus-article-buttons)
587 (defcustom gnus-signature-face 'gnus-signature-face
588 "Face used for highlighting a signature in the article buffer.
589 Obsolete; use the face `gnus-signature-face' for customizations instead."
591 :group 'gnus-article-highlight
592 :group 'gnus-article-signature)
594 (defface gnus-signature-face
597 "Face used for highlighting a signature in the article buffer."
598 :group 'gnus-article-highlight
599 :group 'gnus-article-signature)
601 (defface gnus-header-from-face
604 (:foreground "spring green"))
607 (:foreground "red3"))
610 "Face used for displaying from headers."
611 :group 'gnus-article-headers
612 :group 'gnus-article-highlight)
614 (defface gnus-header-subject-face
617 (:foreground "SeaGreen3"))
620 (:foreground "red4"))
622 (:bold t :italic t)))
623 "Face used for displaying subject headers."
624 :group 'gnus-article-headers
625 :group 'gnus-article-highlight)
627 (defface gnus-header-newsgroups-face
630 (:foreground "yellow" :italic t))
633 (:foreground "MidnightBlue" :italic t))
636 "Face used for displaying newsgroups headers."
637 :group 'gnus-article-headers
638 :group 'gnus-article-highlight)
640 (defface gnus-header-name-face
643 (:foreground "SeaGreen"))
646 (:foreground "maroon"))
649 "Face used for displaying header names."
650 :group 'gnus-article-headers
651 :group 'gnus-article-highlight)
653 (defface gnus-header-content-face
656 (:foreground "forest green" :italic t))
659 (:foreground "indianred4" :italic t))
662 "Face used for displaying header content."
663 :group 'gnus-article-headers
664 :group 'gnus-article-highlight)
666 (defcustom gnus-header-face-alist
667 '(("From" nil gnus-header-from-face)
668 ("Subject" nil gnus-header-subject-face)
669 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
670 ("" gnus-header-name-face gnus-header-content-face))
671 "*Controls highlighting of article header.
673 An alist of the form (HEADER NAME CONTENT).
675 HEADER is a regular expression which should match the name of an
676 header header and NAME and CONTENT are either face names or nil.
678 The name of each header field will be displayed using the face
679 specified by the first element in the list where HEADER match the
680 header name and NAME is non-nil. Similarly, the content will be
681 displayed by the first non-nil matching CONTENT face."
682 :group 'gnus-article-headers
683 :group 'gnus-article-highlight
684 :type '(repeat (list (regexp :tag "Header")
686 (item :tag "skip" nil)
687 (face :value default))
688 (choice :tag "Content"
689 (item :tag "skip" nil)
690 (face :value default)))))
692 (defcustom gnus-article-decode-hook nil
693 "*Hook run to decode charsets in articles."
694 :group 'gnus-article-headers
697 (defcustom gnus-display-mime-function 'gnus-display-mime
698 "Function to display MIME articles."
699 :group 'gnus-article-mime
702 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
703 "Function used to decode headers.")
705 (defvar gnus-article-dumbquotes-map
724 "Table for MS-to-Latin1 translation.")
726 (defcustom gnus-ignored-mime-types nil
727 "List of MIME types that should be ignored by Gnus."
729 :group 'gnus-article-mime
730 :type '(repeat regexp))
732 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
733 "List of MIME types that should not be given buttons when rendered inline.
734 See also `gnus-buttonized-mime-types' which may override this variable."
736 :group 'gnus-article-mime
737 :type '(repeat regexp))
739 (defcustom gnus-buttonized-mime-types nil
740 "List of MIME types that should be given buttons when rendered inline.
741 If set, this variable overrides `gnus-unbuttonized-mime-types'.
742 To see e.g. security buttons you could set this to
743 `(\"multipart/signed\")'."
745 :group 'gnus-article-mime
746 :type '(repeat regexp))
748 (defcustom gnus-body-boundary-delimiter "_"
749 "String used to delimit header and body.
750 This variable is used by `gnus-article-treat-body-boundary' which can
751 be controlled by `gnus-treat-body-boundary'."
752 :group 'gnus-article-various
753 :type '(choice (item :tag "None" :value nil)
756 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces")
757 "*Defines the location of the faces database.
758 For information on obtaining this database of pretty pictures, please
759 see http://www.cs.indiana.edu/picons/ftp/index.html"
763 (defun gnus-picons-installed-p ()
764 "Say whether picons are installed on your machine."
765 (let ((installed nil))
766 (dolist (database gnus-picon-databases)
767 (when (file-exists-p database)
771 (defcustom gnus-article-mime-part-function nil
772 "Function called with a MIME handle as the argument.
773 This is meant for people who want to do something automatic based
774 on parts -- for instance, adding Vcard info to a database."
775 :group 'gnus-article-mime
778 (defcustom gnus-mime-multipart-functions nil
779 "An alist of MIME types to functions to display them."
781 :group 'gnus-article-mime
784 (defcustom gnus-article-date-lapsed-new-header nil
785 "Whether the X-Sent and Date headers can coexist.
786 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
787 either replace the old \"Date:\" header (if this variable is nil), or
788 be added below it (otherwise)."
790 :group 'gnus-article-headers
793 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
794 "Function called with a MIME handle as the argument.
795 This is meant for people who want to view first matched part.
796 For `undisplayed-alternative' (default), the first undisplayed
797 part or alternative part is used. For `undisplayed', the first
798 undisplayed part is used. For a function, the first part which
799 the function return `t' is used. For `nil', the first part is
802 :group 'gnus-article-mime
804 (item :tag "first" :value nil)
805 (item :tag "undisplayed" :value undisplayed)
806 (item :tag "undisplayed or alternative"
807 :value undisplayed-alternative)
810 (defcustom gnus-mime-action-alist
811 '(("save to file" . gnus-mime-save-part)
812 ("save and strip" . gnus-mime-save-part-and-strip)
813 ("display as text" . gnus-mime-inline-part)
814 ("view the part" . gnus-mime-view-part)
815 ("pipe to command" . gnus-mime-pipe-part)
816 ("toggle display" . gnus-article-press-button)
817 ("toggle display" . gnus-article-view-part-as-charset)
818 ("view as type" . gnus-mime-view-part-as-type)
819 ("view internally" . gnus-mime-view-part-internally)
820 ("view externally" . gnus-mime-view-part-externally))
821 "An alist of actions that run on the MIME attachment."
822 :group 'gnus-article-mime
823 :type '(repeat (cons (string :tag "name")
827 ;;; The treatment variables
830 (defvar gnus-part-display-hook nil
831 "Hook called on parts that are to receive treatment.")
833 (defvar gnus-article-treat-custom
834 '(choice (const :tag "Off" nil)
836 (const :tag "Header" head)
837 (const :tag "Last" last)
838 (const :tag "Mime" mime)
839 (integer :tag "Less")
840 (repeat :tag "Groups" regexp)
841 (sexp :tag "Predicate")))
843 (defvar gnus-article-treat-head-custom
844 '(choice (const :tag "Off" nil)
845 (const :tag "Header" head)))
847 (defvar gnus-article-treat-types '("text/plain")
850 (defvar gnus-inhibit-treatment nil
851 "Whether to inhibit treatment.")
853 (defcustom gnus-treat-highlight-signature '(or last (typep "text/x-vcard"))
854 "Highlight the signature.
855 Valid values are nil, t, `head', `last', an integer or a predicate.
856 See Info node `(gnus)Customizing Articles'."
857 :group 'gnus-article-treat
858 :type gnus-article-treat-custom)
859 (put 'gnus-treat-highlight-signature 'highlight t)
861 (defcustom gnus-treat-buttonize 100000
863 Valid values are nil, t, `head', `last', an integer or a predicate.
864 See Info node `(gnus)Customizing Articles'."
865 :group 'gnus-article-treat
866 :type gnus-article-treat-custom)
867 (put 'gnus-treat-buttonize 'highlight t)
869 (defcustom gnus-treat-buttonize-head 'head
870 "Add buttons to the head.
871 Valid values are nil, t, `head', `last', an integer or a predicate.
872 See Info node `(gnus)Customizing Articles' for details."
873 :group 'gnus-article-treat
874 :type gnus-article-treat-head-custom)
875 (put 'gnus-treat-buttonize-head 'highlight t)
877 (defcustom gnus-treat-emphasize
878 (and (or window-system
880 (>= (string-to-number emacs-version) 21))
883 Valid values are nil, t, `head', `last', an integer or a predicate.
884 See Info node `(gnus)Customizing Articles' for details."
885 :group 'gnus-article-treat
886 :type gnus-article-treat-custom)
887 (put 'gnus-treat-emphasize 'highlight t)
889 (defcustom gnus-treat-strip-cr nil
890 "Remove carriage returns.
891 Valid values are nil, t, `head', `last', an integer or a predicate.
892 See Info node `(gnus)Customizing Articles' for details."
893 :group 'gnus-article-treat
894 :type gnus-article-treat-custom)
896 (defcustom gnus-treat-unsplit-urls nil
897 "Remove newlines from within URLs.
898 Valid values are nil, t, `head', `last', an integer or a predicate.
899 See Info node `(gnus)Customizing Articles' for details."
900 :group 'gnus-article-treat
901 :type gnus-article-treat-custom)
903 (defcustom gnus-treat-leading-whitespace nil
904 "Remove leading whitespace in headers.
905 Valid values are nil, t, `head', `last', an integer or a predicate.
906 See Info node `(gnus)Customizing Articles' for details."
907 :group 'gnus-article-treat
908 :type gnus-article-treat-custom)
910 (defcustom gnus-treat-hide-headers 'head
912 Valid values are nil, t, `head', `last', an integer or a predicate.
913 See Info node `(gnus)Customizing Articles' for details."
914 :group 'gnus-article-treat
915 :type gnus-article-treat-head-custom)
917 (defcustom gnus-treat-hide-boring-headers nil
918 "Hide boring headers.
919 Valid values are nil, t, `head', `last', an integer or a predicate.
920 See Info node `(gnus)Customizing Articles' for details."
921 :group 'gnus-article-treat
922 :type gnus-article-treat-head-custom)
924 (defcustom gnus-treat-hide-signature nil
926 Valid values are nil, t, `head', `last', an integer or a predicate.
927 See Info node `(gnus)Customizing Articles' for details."
928 :group 'gnus-article-treat
929 :type gnus-article-treat-custom)
931 (defcustom gnus-treat-fill-article nil
933 Valid values are nil, t, `head', `last', an integer or a predicate.
934 See Info node `(gnus)Customizing Articles' for details."
935 :group 'gnus-article-treat
936 :type gnus-article-treat-custom)
938 (defcustom gnus-treat-hide-citation nil
940 Valid values are nil, t, `head', `last', an integer or a predicate.
941 See Info node `(gnus)Customizing Articles' for details."
942 :group 'gnus-article-treat
943 :type gnus-article-treat-custom)
945 (defcustom gnus-treat-hide-citation-maybe nil
947 Valid values are nil, t, `head', `last', an integer or a predicate.
948 See Info node `(gnus)Customizing Articles' for details."
949 :group 'gnus-article-treat
950 :type gnus-article-treat-custom)
952 (defcustom gnus-treat-strip-list-identifiers 'head
953 "Strip list identifiers from `gnus-list-identifiers`.
954 Valid values are nil, t, `head', `last', an integer or a predicate.
955 See Info node `(gnus)Customizing Articles' for details."
957 :group 'gnus-article-treat
958 :type gnus-article-treat-custom)
960 (defcustom gnus-treat-strip-pgp t
961 "Strip PGP signatures.
962 Valid values are nil, t, `head', `last', an integer or a predicate.
963 See Info node `(gnus)Customizing Articles' for details."
964 :group 'gnus-article-treat
965 :type gnus-article-treat-custom)
967 (defcustom gnus-treat-strip-pem nil
968 "Strip PEM signatures.
969 Valid values are nil, t, `head', `last', an integer or a predicate.
970 See Info node `(gnus)Customizing Articles' for details."
971 :group 'gnus-article-treat
972 :type gnus-article-treat-custom)
974 (defcustom gnus-treat-strip-banner t
975 "Strip banners from articles.
976 The banner to be stripped is specified in the `banner' group parameter.
977 Valid values are nil, t, `head', `last', an integer or a predicate.
978 See Info node `(gnus)Customizing Articles' for details."
979 :group 'gnus-article-treat
980 :type gnus-article-treat-custom)
982 (defcustom gnus-treat-highlight-headers 'head
983 "Highlight the headers.
984 Valid values are nil, t, `head', `last', an integer or a predicate.
985 See Info node `(gnus)Customizing Articles' for details."
986 :group 'gnus-article-treat
987 :type gnus-article-treat-head-custom)
988 (put 'gnus-treat-highlight-headers 'highlight t)
990 (defcustom gnus-treat-highlight-citation t
991 "Highlight cited text.
992 Valid values are nil, t, `head', `last', an integer or a predicate.
993 See Info node `(gnus)Customizing Articles' for details."
994 :group 'gnus-article-treat
995 :type gnus-article-treat-custom)
996 (put 'gnus-treat-highlight-citation 'highlight t)
998 (defcustom gnus-treat-date-ut nil
999 "Display the Date in UT (GMT).
1000 Valid values are nil, t, `head', `last', an integer or a predicate.
1001 See Info node `(gnus)Customizing Articles' for details."
1002 :group 'gnus-article-treat
1003 :type gnus-article-treat-head-custom)
1005 (defcustom gnus-treat-date-local nil
1006 "Display the Date in the local timezone.
1007 Valid values are nil, t, `head', `last', an integer or a predicate.
1008 See Info node `(gnus)Customizing Articles' for details."
1009 :group 'gnus-article-treat
1010 :type gnus-article-treat-head-custom)
1012 (defcustom gnus-treat-date-english nil
1013 "Display the Date in a format that can be read aloud in English.
1014 Valid values are nil, t, `head', `last', an integer or a predicate.
1015 See Info node `(gnus)Customizing Articles' for details."
1016 :group 'gnus-article-treat
1017 :type gnus-article-treat-head-custom)
1019 (defcustom gnus-treat-date-lapsed nil
1020 "Display the Date header in a way that says how much time has elapsed.
1021 Valid values are nil, t, `head', `last', an integer or a predicate.
1022 See Info node `(gnus)Customizing Articles' for details."
1023 :group 'gnus-article-treat
1024 :type gnus-article-treat-head-custom)
1026 (defcustom gnus-treat-date-original nil
1027 "Display the date in the original timezone.
1028 Valid values are nil, t, `head', `last', an integer or a predicate.
1029 See Info node `(gnus)Customizing Articles' for details."
1030 :group 'gnus-article-treat
1031 :type gnus-article-treat-head-custom)
1033 (defcustom gnus-treat-date-iso8601 nil
1034 "Display the date in the ISO8601 format.
1035 Valid values are nil, t, `head', `last', an integer or a predicate.
1036 See Info node `(gnus)Customizing Articles' for details."
1038 :group 'gnus-article-treat
1039 :type gnus-article-treat-head-custom)
1041 (defcustom gnus-treat-date-user-defined nil
1042 "Display the date in a user-defined format.
1043 The format is defined by the `gnus-article-time-format' variable.
1044 Valid values are nil, t, `head', `last', an integer or a predicate.
1045 See Info node `(gnus)Customizing Articles' for details."
1046 :group 'gnus-article-treat
1047 :type gnus-article-treat-head-custom)
1049 (defcustom gnus-treat-strip-headers-in-body t
1050 "Strip the X-No-Archive header line from the beginning of the body.
1051 Valid values are nil, t, `head', `last', an integer or a predicate.
1052 See Info node `(gnus)Customizing Articles' for details."
1054 :group 'gnus-article-treat
1055 :type gnus-article-treat-custom)
1057 (defcustom gnus-treat-strip-trailing-blank-lines nil
1058 "Strip trailing blank lines.
1059 Valid values are nil, t, `head', `last', an integer or a predicate.
1060 See Info node `(gnus)Customizing Articles' for details."
1061 :group 'gnus-article-treat
1062 :type gnus-article-treat-custom)
1064 (defcustom gnus-treat-strip-leading-blank-lines nil
1065 "Strip leading blank lines.
1066 Valid values are nil, t, `head', `last', an integer or a predicate.
1067 See Info node `(gnus)Customizing Articles' for details."
1068 :group 'gnus-article-treat
1069 :type gnus-article-treat-custom)
1071 (defcustom gnus-treat-strip-multiple-blank-lines nil
1072 "Strip multiple blank lines.
1073 Valid values are nil, t, `head', `last', an integer or a predicate.
1074 See Info node `(gnus)Customizing Articles' for details."
1075 :group 'gnus-article-treat
1076 :type gnus-article-treat-custom)
1078 (defcustom gnus-treat-unfold-headers 'head
1079 "Unfold folded header lines.
1080 Valid values are nil, t, `head', `last', an integer or a predicate.
1081 See Info node `(gnus)Customizing Articles' for details."
1082 :group 'gnus-article-treat
1083 :type gnus-article-treat-custom)
1085 (defcustom gnus-treat-fold-headers nil
1087 Valid values are nil, t, `head', `last', an integer or a predicate.
1088 See Info node `(gnus)Customizing Articles' for details."
1089 :group 'gnus-article-treat
1090 :type gnus-article-treat-custom)
1092 (defcustom gnus-treat-fold-newsgroups 'head
1093 "Fold the Newsgroups and Followup-To headers.
1094 Valid values are nil, t, `head', `last', an integer or a predicate.
1095 See Info node `(gnus)Customizing Articles' for details."
1096 :group 'gnus-article-treat
1097 :type gnus-article-treat-custom)
1099 (defcustom gnus-treat-overstrike t
1100 "Treat overstrike highlighting.
1101 Valid values are nil, t, `head', `last', an integer or a predicate.
1102 See Info node `(gnus)Customizing Articles' for details."
1103 :group 'gnus-article-treat
1104 :type gnus-article-treat-custom)
1105 (put 'gnus-treat-overstrike 'highlight t)
1107 (defcustom gnus-treat-display-xface
1108 (and (not noninteractive)
1109 (or (and (fboundp 'image-type-available-p)
1110 (image-type-available-p 'xbm)
1111 (string-match "^0x" (shell-command-to-string "uncompface")))
1112 (and (featurep 'xemacs)
1114 (eq 'x-face-mule-gnus-article-display-x-face
1115 gnus-article-x-face-command))
1117 "Display X-Face headers.
1118 Valid values are nil, t, `head', `last', an integer or a predicate.
1119 See Info node `(gnus)Customizing Articles' and Info node
1120 `(gnus)X-Face' for details."
1121 :group 'gnus-article-treat
1123 :type gnus-article-treat-head-custom)
1124 (put 'gnus-treat-display-xface 'highlight t)
1126 (defcustom gnus-article-should-use-smiley-mule
1127 (not (or (featurep 'xemacs)
1128 (gnus-image-type-available-p 'xpm)
1129 (gnus-image-type-available-p 'pbm)))
1130 "If non-nil, gnus uses `smiley-mule' for displaying smileys rather than
1131 `smiley'. It defaults to t when Emacs 20 or earlier is running.
1132 `smiley-mule' is boundled in BITMAP-MULE package. You can set it to t
1133 even if you are using Emacs 21+. It has no effect on XEmacs."
1134 :group 'gnus-article-various
1136 :get (lambda (symbol)
1137 (and (default-value symbol)
1138 (not (featurep 'xemacs))
1139 (module-installed-p 'smiley-mule)
1141 :set (lambda (symbol value)
1142 (set-default symbol (and value
1143 (not (featurep 'xemacs))
1144 (module-installed-p 'smiley-mule)
1147 (defvar gnus-article-smiley-mule-loaded-p nil
1148 "Internal variable used to say whether `smiley-mule' is loaded (whether
1149 smiley functions are not overridden by `smiley').")
1151 (defcustom gnus-treat-display-grey-xface
1152 (and (not noninteractive)
1153 (or (featurep 'xemacs)
1154 (and (fboundp 'display-images-p)
1155 (display-images-p)))
1156 (string-match "^0x" (shell-command-to-string "uncompface"))
1158 "Display grey X-Face headers.
1159 Valid values are nil, t."
1160 :group 'gnus-article-treat
1163 (put 'gnus-treat-display-grey-xface 'highlight t)
1165 (defcustom gnus-treat-display-smileys
1166 (if (or (and (featurep 'xemacs)
1168 (gnus-image-type-available-p 'xpm)
1169 (gnus-image-type-available-p 'pbm)
1170 (and (not (featurep 'xemacs))
1172 (module-installed-p 'smiley-mule)))
1176 Valid values are nil, t, `head', `last', an integer or a predicate.
1177 See Info node `(gnus)Customizing Articles' and Info node
1178 `(gnus)Smileys' for details."
1179 :group 'gnus-article-treat
1181 :type gnus-article-treat-custom)
1182 (put 'gnus-treat-display-smileys 'highlight t)
1184 (defcustom gnus-treat-from-picon
1185 (if (and (gnus-image-type-available-p 'xpm)
1186 (gnus-picons-installed-p))
1188 "Display picons in the From header.
1189 Valid values are nil, t, `head', `last', an integer or a predicate.
1190 See Info node `(gnus)Customizing Articles' and Info node
1191 `(gnus)Picons' for details."
1192 :group 'gnus-article-treat
1193 :type gnus-article-treat-head-custom)
1194 (put 'gnus-treat-from-picon 'highlight t)
1196 (defcustom gnus-treat-mail-picon
1197 (if (and (gnus-image-type-available-p 'xpm)
1198 (gnus-picons-installed-p))
1200 "Display picons in To and Cc headers.
1201 Valid values are nil, t, `head', `last', an integer or a predicate.
1202 See Info node `(gnus)Customizing Articles' and Info node
1203 `(gnus)Picons' for details."
1204 :group 'gnus-article-treat
1205 :type gnus-article-treat-head-custom)
1206 (put 'gnus-treat-mail-picon 'highlight t)
1208 (defcustom gnus-treat-newsgroups-picon
1209 (if (and (gnus-image-type-available-p 'xpm)
1210 (gnus-picons-installed-p))
1212 "Display picons in the Newsgroups and Followup-To headers.
1213 Valid values are nil, t, `head', `last', an integer or a predicate.
1214 See Info node `(gnus)Customizing Articles' and Info node
1215 `(gnus)Picons' for details."
1216 :group 'gnus-article-treat
1217 :type gnus-article-treat-head-custom)
1218 (put 'gnus-treat-newsgroups-picon 'highlight t)
1220 (defcustom gnus-treat-body-boundary
1221 (if (or gnus-treat-newsgroups-picon
1222 gnus-treat-mail-picon
1223 gnus-treat-from-picon)
1225 "Draw a boundary at the end of the headers.
1226 Valid values are nil, t, `head', `last', an integer or a predicate.
1227 See Info node `(gnus)Customizing Articles' for details."
1229 :group 'gnus-article-treat
1230 :type gnus-article-treat-custom)
1232 (defcustom gnus-treat-capitalize-sentences nil
1233 "Capitalize sentence-starting words.
1234 Valid values are nil, t, `head', `last', an integer or a predicate.
1235 See Info node `(gnus)Customizing Articles' for details."
1237 :group 'gnus-article-treat
1238 :type gnus-article-treat-custom)
1240 (defcustom gnus-treat-fill-long-lines nil
1242 Valid values are nil, t, `head', `last', an integer or a predicate.
1243 See Info node `(gnus)Customizing Articles' for details."
1244 :group 'gnus-article-treat
1245 :type gnus-article-treat-custom)
1247 (defcustom gnus-treat-play-sounds nil
1249 Valid values are nil, t, `head', `last', an integer or a predicate.
1250 See Info node `(gnus)Customizing Articles' for details."
1252 :group 'gnus-article-treat
1253 :type gnus-article-treat-custom)
1255 (defcustom gnus-treat-decode-article-as-default-mime-charset nil
1256 "Decode an article as `default-mime-charset'. For instance, if you want to
1257 attempt to decode an article even if the value of `gnus-show-mime' is nil,
1258 you could set this variable to something like: nil for don't decode, t for
1259 decode the body, '(or header t) for the whole article, etc."
1260 :group 'gnus-article-treat
1261 :type '(radio (const :tag "Off" nil)
1262 (const :tag "Decode body" t)
1263 (const :tag "Decode all" (or head t))))
1265 (defcustom gnus-treat-translate nil
1266 "Translate articles from one language to another.
1267 Valid values are nil, t, `head', `last', an integer or a predicate.
1268 See Info node `(gnus)Customizing Articles' for details."
1270 :group 'gnus-article-treat
1271 :type gnus-article-treat-custom)
1273 (defcustom gnus-treat-x-pgp-sig nil
1275 To automatically treat X-PGP-Sig, set it to head.
1276 Valid values are nil, t, `head', `last', an integer or a predicate.
1277 See Info node `(gnus)Customizing Articles' for details."
1278 :group 'gnus-article-treat
1279 :group 'mime-security
1280 :type gnus-article-treat-custom)
1282 (defcustom gnus-treat-monafy nil
1283 "Display body part with mona font.
1284 Valid values are nil, t, `head', `last', an integer or a predicate.
1285 See Info node `(gnus)Customizing Articles' for details."
1286 :group 'gnus-article-treat
1287 :group 'mime-security
1288 :type gnus-article-treat-custom)
1290 (defvar gnus-article-encrypt-protocol-alist
1291 '(("PGP" . mml2015-self-encrypt)))
1293 ;; Set to nil if more than one protocol added to
1294 ;; gnus-article-encrypt-protocol-alist.
1295 (defcustom gnus-article-encrypt-protocol "PGP"
1296 "The protocol used for encrypt articles.
1297 It is a string, such as \"PGP\". If nil, ask user."
1299 :group 'mime-security)
1301 (defvar gnus-article-wash-function nil
1302 "Function used for converting HTML into text.")
1304 ;;; Internal variables
1306 (defvar gnus-english-month-names
1307 '("January" "February" "March" "April" "May" "June" "July" "August"
1308 "September" "October" "November" "December"))
1310 (defvar article-goto-body-goes-to-point-min-p nil)
1311 (defvar gnus-article-wash-types nil)
1312 (defvar gnus-article-emphasis-alist nil)
1313 (defvar gnus-article-image-alist nil)
1315 (defvar gnus-article-mime-handle-alist-1 nil)
1316 (defvar gnus-treatment-function-alist
1317 '((gnus-treat-decode-article-as-default-mime-charset
1318 gnus-article-decode-article-as-default-mime-charset)
1319 (gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1320 (gnus-treat-monafy gnus-article-monafy)
1321 (gnus-treat-strip-banner gnus-article-strip-banner)
1322 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1323 (gnus-treat-buttonize gnus-article-add-buttons)
1324 (gnus-treat-fill-article gnus-article-fill-cited-article)
1325 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1326 (gnus-treat-strip-cr gnus-article-remove-cr)
1327 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1328 (gnus-treat-date-ut gnus-article-date-ut)
1329 (gnus-treat-date-local gnus-article-date-local)
1330 (gnus-treat-date-english gnus-article-date-english)
1331 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1332 (gnus-treat-date-original gnus-article-date-original)
1333 (gnus-treat-date-user-defined gnus-article-date-user)
1334 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1335 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1336 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1337 (gnus-treat-hide-signature gnus-article-hide-signature)
1338 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1339 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1340 (gnus-treat-strip-pgp gnus-article-hide-pgp)
1341 (gnus-treat-strip-pem gnus-article-hide-pem)
1342 (gnus-treat-from-picon gnus-treat-from-picon)
1343 (gnus-treat-mail-picon gnus-treat-mail-picon)
1344 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1345 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1346 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1347 (gnus-treat-strip-trailing-blank-lines
1348 gnus-article-remove-trailing-blank-lines)
1349 (gnus-treat-strip-leading-blank-lines
1350 gnus-article-strip-leading-blank-lines)
1351 (gnus-treat-strip-multiple-blank-lines
1352 gnus-article-strip-multiple-blank-lines)
1353 (gnus-treat-overstrike gnus-article-treat-overstrike)
1354 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1355 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1356 ;; Displaying X-Face should be done after unfolding headers
1357 ;; to protect bitmap lines.
1358 (gnus-treat-display-xface gnus-article-display-x-face)
1359 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1360 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1361 (gnus-treat-display-smileys gnus-treat-smiley)
1362 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1363 (gnus-treat-emphasize gnus-article-emphasize)
1364 (gnus-treat-hide-citation gnus-article-hide-citation)
1365 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1366 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1367 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1368 (gnus-treat-play-sounds gnus-earcon-display)))
1370 (defvar gnus-article-mime-handle-alist nil)
1371 (defvar article-lapsed-timer nil)
1372 (defvar gnus-article-current-summary nil)
1374 (defvar gnus-article-mode-syntax-table
1375 (let ((table (copy-syntax-table text-mode-syntax-table)))
1376 ;; This causes the citation match run O(2^n).
1377 ;; (modify-syntax-entry ?- "w" table)
1378 (modify-syntax-entry ?> ")" table)
1379 (modify-syntax-entry ?< "(" table)
1381 "Syntax table used in article mode buffers.
1382 Initialized from `text-mode-syntax-table.")
1384 (defvar gnus-save-article-buffer nil)
1386 (defvar gnus-article-mode-line-format-alist
1387 (nconc '((?w (gnus-article-wash-status) ?s)
1388 (?m (gnus-article-mime-part-status) ?s))
1389 gnus-summary-mode-line-format-alist))
1391 (defvar gnus-number-of-articles-to-be-saved nil)
1393 (defvar gnus-inhibit-hiding nil)
1395 ;;; Macros for dealing with the article buffer.
1397 (defmacro gnus-with-article-headers (&rest forms)
1399 (set-buffer gnus-article-buffer)
1401 (let ((buffer-read-only nil)
1402 (inhibit-point-motion-hooks t)
1403 (case-fold-search t))
1404 (article-narrow-to-head)
1407 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1408 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1410 (defmacro gnus-with-article-buffer (&rest forms)
1412 (set-buffer gnus-article-buffer)
1413 (let ((buffer-read-only nil))
1416 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1417 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1419 (defun gnus-article-goto-header (header)
1420 "Go to HEADER, which is a regular expression."
1421 (re-search-forward (concat "^\\(" header "\\):") nil t))
1423 (defsubst gnus-article-hide-text (b e props)
1424 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1425 (gnus-add-text-properties-when 'article-type nil b e props)
1426 (when (memq 'intangible props)
1428 (max (1- b) (point-min))
1429 b 'intangible (cddr (memq 'intangible props)))))
1431 (defsubst gnus-article-unhide-text (b e)
1432 "Remove hidden text properties from region between B and E."
1433 (remove-text-properties b e gnus-hidden-properties)
1434 (when (memq 'intangible gnus-hidden-properties)
1435 (put-text-property (max (1- b) (point-min))
1436 b 'intangible nil)))
1438 (defun gnus-article-hide-text-type (b e type)
1439 "Hide text of TYPE between B and E."
1440 (gnus-add-wash-type type)
1441 (gnus-article-hide-text
1442 b e (cons 'article-type (cons type gnus-hidden-properties))))
1444 (defun gnus-article-unhide-text-type (b e type)
1445 "Unhide text of TYPE between B and E."
1446 (gnus-delete-wash-type type)
1447 (remove-text-properties
1448 b e (cons 'article-type (cons type gnus-hidden-properties)))
1449 (when (memq 'intangible gnus-hidden-properties)
1450 (put-text-property (max (1- b) (point-min))
1451 b 'intangible nil)))
1453 (defun gnus-article-hide-text-of-type (type)
1454 "Hide text of TYPE in the current buffer."
1456 (let ((b (point-min))
1458 (while (setq b (text-property-any b e 'article-type type))
1459 (add-text-properties b (incf b) gnus-hidden-properties)))))
1461 (defun gnus-article-delete-text-of-type (type)
1462 "Delete text of TYPE in the current buffer."
1464 (let ((b (point-min)))
1465 (while (setq b (text-property-any b (point-max) 'article-type type))
1467 b (or (text-property-not-all b (point-max) 'article-type type)
1470 (defun gnus-article-delete-invisible-text ()
1471 "Delete all invisible text in the current buffer."
1473 (let ((b (point-min)))
1474 (while (setq b (text-property-any b (point-max) 'invisible t))
1476 b (or (text-property-not-all b (point-max) 'invisible t)
1479 (defun gnus-article-text-type-exists-p (type)
1480 "Say whether any text of type TYPE exists in the buffer."
1481 (text-property-any (point-min) (point-max) 'article-type type))
1483 (defsubst gnus-article-header-rank ()
1484 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1485 (let ((list gnus-sorted-header-list)
1488 (when (looking-at (car list))
1490 (setq list (cdr list))
1494 (defun article-hide-headers (&optional arg delete)
1495 "Hide unwanted headers and possibly sort them as well."
1496 (interactive (gnus-article-hidden-arg))
1497 ;; Lars said that this function might be inhibited.
1498 (if (gnus-article-check-hidden-text 'headers arg)
1500 ;; Show boring headers as well.
1501 (gnus-article-show-hidden-text 'boring-headers)
1502 (when (eq 1 (point-min))
1503 (set-window-start (get-buffer-window (current-buffer)) 1)))
1504 (unless gnus-inhibit-hiding
1507 (let ((inhibit-read-only t)
1508 (case-fold-search t)
1509 (max (1+ (length gnus-sorted-header-list)))
1510 (ignored (when (not gnus-visible-headers)
1511 (cond ((stringp gnus-ignored-headers)
1512 gnus-ignored-headers)
1513 ((listp gnus-ignored-headers)
1514 (mapconcat 'identity gnus-ignored-headers
1517 (cond ((stringp gnus-visible-headers)
1518 gnus-visible-headers)
1519 ((and gnus-visible-headers
1520 (listp gnus-visible-headers))
1521 (mapconcat 'identity gnus-visible-headers "\\|"))))
1522 (inhibit-point-motion-hooks t)
1524 ;; First we narrow to just the headers.
1525 (article-narrow-to-head)
1526 ;; Hide any "From " lines at the beginning of (mail) articles.
1527 (while (looking-at "From ")
1531 (delete-region (point-min) (point))
1532 (gnus-article-hide-text (point-min) (point)
1533 (nconc (list 'article-type 'headers)
1534 gnus-hidden-properties))))
1535 ;; Then treat the rest of the header lines.
1536 ;; Then we use the two regular expressions
1537 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1538 ;; select which header lines is to remain visible in the
1540 (while (re-search-forward "^[^ \t:]*:" nil t)
1542 ;; Mark the rank of the header.
1544 (point) (1+ (point)) 'message-rank
1545 (if (or (and visible (looking-at visible))
1547 (not (looking-at ignored))))
1548 (gnus-article-header-rank)
1551 (message-sort-headers-1)
1552 (when (setq beg (text-property-any
1553 (point-min) (point-max) 'message-rank (+ 2 max)))
1554 ;; We delete or make invisible the unwanted headers.
1555 (gnus-add-wash-type 'headers)
1558 (add-text-properties
1559 (point-min) (+ 5 (point-min))
1560 '(article-type headers dummy-invisible t))
1561 (delete-region beg (point-max)))
1562 (gnus-article-hide-text-type beg (point-max) 'headers)))))))))
1564 (defun article-hide-boring-headers (&optional arg)
1565 "Toggle hiding of headers that aren't very interesting.
1566 If given a negative prefix, always show; if given a positive prefix,
1568 (interactive (gnus-article-hidden-arg))
1569 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1570 (not gnus-show-all-headers))
1573 (let ((buffer-read-only nil)
1574 (list gnus-boring-article-headers)
1575 (inhibit-point-motion-hooks t)
1577 (article-narrow-to-head)
1579 (setq elem (pop list))
1580 (goto-char (point-min))
1582 ;; Hide empty headers.
1584 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1586 (gnus-article-hide-text-type
1587 (progn (beginning-of-line) (point))
1590 (if (re-search-forward "^[^ \t]" nil t)
1594 ;; Hide boring Newsgroups header.
1595 ((eq elem 'newsgroups)
1596 (when (gnus-string-equal
1597 (gnus-fetch-field "newsgroups")
1598 (gnus-group-real-name
1599 (if (boundp 'gnus-newsgroup-name)
1602 (gnus-article-hide-header "newsgroups")))
1603 ((eq elem 'to-address)
1604 (let ((to (message-fetch-field "to"))
1606 (gnus-parameter-to-address
1607 (if (boundp 'gnus-newsgroup-name)
1608 gnus-newsgroup-name ""))))
1609 (when (and to to-address
1612 ;; only one address in To
1613 (nth 1 (mail-extract-address-components to))
1615 (gnus-article-hide-header "to"))))
1616 ((eq elem 'followup-to)
1617 (when (gnus-string-equal
1618 (message-fetch-field "followup-to")
1619 (message-fetch-field "newsgroups"))
1620 (gnus-article-hide-header "followup-to")))
1621 ((eq elem 'reply-to)
1622 (let ((from (message-fetch-field "from"))
1623 (reply-to (message-fetch-field "reply-to")))
1628 (nth 1 (mail-extract-address-components from))
1629 (nth 1 (mail-extract-address-components reply-to)))))
1630 (gnus-article-hide-header "reply-to"))))
1632 (let ((date (message-fetch-field "date")))
1634 (< (days-between (current-time-string) date)
1636 (gnus-article-hide-header "date"))))
1638 (let ((to (message-fetch-field "to"))
1639 (cc (message-fetch-field "cc")))
1640 (when (> (length to) 1024)
1641 (gnus-article-hide-header "to"))
1642 (when (> (length cc) 1024)
1643 (gnus-article-hide-header "cc"))))
1647 (goto-char (point-min))
1648 (while (re-search-forward "^to:" nil t)
1649 (setq to-count (1+ to-count)))
1650 (when (> to-count 1)
1651 (while (> to-count 0)
1652 (goto-char (point-min))
1654 (re-search-forward "^to:" nil nil to-count)
1656 (narrow-to-region (point) (point-max))
1657 (gnus-article-hide-header "to"))
1658 (setq to-count (1- to-count))))
1659 (goto-char (point-min))
1660 (while (re-search-forward "^cc:" nil t)
1661 (setq cc-count (1+ cc-count)))
1662 (when (> cc-count 1)
1663 (while (> cc-count 0)
1664 (goto-char (point-min))
1666 (re-search-forward "^cc:" nil nil cc-count)
1668 (narrow-to-region (point) (point-max))
1669 (gnus-article-hide-header "cc"))
1670 (setq cc-count (1- cc-count)))))))))))))
1672 (defun gnus-article-hide-header (header)
1674 (goto-char (point-min))
1675 (when (re-search-forward (concat "^" header ":") nil t)
1676 (gnus-article-hide-text-type
1677 (progn (beginning-of-line) (point))
1680 (if (re-search-forward "^[^ \t]" nil t)
1685 (defun article-toggle-headers (&optional arg)
1686 "Toggle hiding of headers. If given a negative prefix, always show;
1687 if given a positive prefix, always hide."
1688 (interactive (gnus-article-hidden-arg))
1689 (let ((force (when (numberp arg)
1690 (cond ((> arg 0) 'always-hide)
1691 ((< arg 0) 'always-show))))
1692 (window (get-buffer-window gnus-article-buffer))
1693 (header-end (point-min))
1694 header-start field-end field-start
1695 (inhibit-point-motion-hooks t)
1696 (inhibit-read-only t))
1699 (while (and (setq header-start
1700 (text-property-any header-end (point-max)
1701 'article-treated-header t))
1703 (text-property-not-all header-start (point-max)
1704 'article-treated-header t)))
1705 (setq field-end header-start)
1707 (;; Hide exposed invisible fields.
1708 (and (not (eq 'always-show force))
1710 (text-property-any field-end header-end
1711 'exposed-invisible-field t)))
1712 (while (and field-start
1713 (setq field-end (text-property-not-all
1714 field-start header-end
1715 'exposed-invisible-field t)))
1716 (add-text-properties field-start field-end gnus-hidden-properties)
1717 (setq field-start (text-property-any field-end header-end
1718 'exposed-invisible-field t)))
1719 (put-text-property header-start header-end
1720 'exposed-invisible-field nil))
1721 (;; Expose invisible fields.
1722 (and (not (eq 'always-hide force))
1724 (text-property-any field-end header-end 'invisible t)))
1725 (while (and field-start
1726 (setq field-end (text-property-not-all
1727 field-start header-end
1729 ;; If the invisible text is not terminated with newline, we
1730 ;; won't expose it. Because it may be created by x-face-mule.
1731 ;; BTW, XEmacs sometimes fail in putting an invisible text
1732 ;; property with `gnus-article-hide-text' (really?). In that
1733 ;; case, the invisible text might be started from the middle of
1734 ;; a line, so we will expose the sort of thing.
1735 (when (or (not (or (eq header-start field-start)
1736 (eq ?\n (char-before field-start))))
1737 (eq ?\n (char-before field-end))
1738 ;; Expose a boundary line anyway.
1741 (buffer-substring (max (- field-end 13) header-start)
1743 (remove-text-properties field-start field-end
1744 gnus-hidden-properties)
1745 (put-text-property field-start field-end
1746 'exposed-invisible-field t))
1747 (setq field-start (text-property-any field-end header-end
1750 (not (eq 'always-show force))
1751 (narrow-to-region header-start header-end)
1752 (article-hide-headers)
1753 ;; Re-display X-Face image under XEmacs.
1754 (when (and (featurep 'xemacs)
1755 (gnus-functionp gnus-article-x-face-command))
1756 (let ((func (cadr (assq 'gnus-treat-display-xface
1757 gnus-treatment-function-alist)))
1759 (when (and (not gnus-inhibit-treatment)
1761 (gnus-treat-predicate gnus-treat-display-xface))
1763 (put-text-property header-start header-end 'read-only nil))))
1766 (goto-char (point-min))
1768 (set-window-start window (point-min))))))
1770 (defvar gnus-article-normalized-header-length 40
1771 "Length of normalized headers.")
1773 (defun article-normalize-headers ()
1774 "Make all header lines 40 characters long."
1776 (let ((buffer-read-only nil)
1780 (article-narrow-to-head)
1783 ((< (setq column (- (gnus-point-at-eol) (point)))
1784 gnus-article-normalized-header-length)
1786 (insert (make-string
1787 (- gnus-article-normalized-header-length column)
1789 ((> column gnus-article-normalized-header-length)
1790 (gnus-put-text-property
1792 (forward-char gnus-article-normalized-header-length)
1799 (forward-line 1))))))
1801 (defun article-treat-dumbquotes ()
1802 "Translate M****s*** sm*rtq**t*s into proper text.
1803 Note that this function guesses whether a character is a sm*rtq**t* or
1804 not, so it should only be used interactively.
1806 Sm*rtq**t*s are M****s***'s unilateral extension to the character map
1807 in an attempt to provide more quoting characters. If you see
1808 something like \\222 or \\264 where you're expecting some kind of
1809 apostrophe or quotation mark, then try this wash."
1811 (article-translate-strings gnus-article-dumbquotes-map))
1813 (defun article-translate-characters (from to)
1814 "Translate all characters in the body of the article according to FROM and TO.
1815 FROM is a string of characters to translate from; to is a string of
1816 characters to translate to."
1818 (when (article-goto-body)
1819 (let ((buffer-read-only nil)
1820 (x (make-string 225 ?x))
1822 (while (< (incf i) (length x))
1825 (while (< i (length from))
1826 (aset x (aref from i) (aref to i))
1828 (translate-region (point) (point-max) x)))))
1830 (defun article-translate-strings (map)
1831 "Translate all string in the body of the article according to MAP.
1832 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1834 (when (article-goto-body)
1835 (let ((buffer-read-only nil)
1837 (while (setq elem (pop map))
1839 (while (search-forward (car elem) nil t)
1840 (replace-match (cadr elem)))))))))
1842 (defun article-treat-overstrike ()
1843 "Translate overstrikes into bold text."
1846 (when (article-goto-body)
1847 (let ((buffer-read-only nil))
1848 (while (search-forward "\b" nil t)
1849 (let ((next (char-after))
1853 previous (char-after))
1857 ;; We do the boldification/underlining by hiding the
1858 ;; overstrikes and putting the proper text property
1862 (gnus-article-hide-text-type start (point) 'overstrike)
1863 (put-text-property (point) end 'face 'bold))
1865 (gnus-article-hide-text-type
1866 (1- (point)) (1+ (point)) 'overstrike)
1868 start (1- (point)) 'face 'underline))
1870 (gnus-article-hide-text-type start (point) 'overstrike)
1872 (point) end 'face 'underline)))))))))
1874 (defun gnus-article-treat-unfold-headers ()
1875 "Unfold folded message headers.
1876 Only the headers that fit into the current window width will be
1879 (gnus-with-article-headers
1883 (mail-header-narrow-to-field)
1884 (let ((header (buffer-substring (point-min) (point-max))))
1887 (goto-char (point-min))
1888 (while (re-search-forward "\n[\t ]" nil t)
1889 (replace-match " " t t)))
1890 (setq length (- (point-max) (point-min) 1)))
1891 (when (< length (window-width))
1892 (while (re-search-forward "\n[\t ]" nil t)
1893 (replace-match " " t t)))
1894 (goto-char (point-max)))))))
1896 (defun gnus-article-treat-fold-headers ()
1897 "Fold message headers."
1899 (gnus-with-article-headers
1902 (mail-header-narrow-to-field)
1903 (mail-header-fold-field)
1904 (goto-char (point-max))))))
1906 (defun gnus-treat-smiley ()
1907 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
1909 (unless (featurep 'xemacs)
1910 (when (and (>= emacs-major-version 21)
1911 (not gnus-article-should-use-smiley-mule)
1912 gnus-article-smiley-mule-loaded-p)
1913 (load "smiley" nil t)
1914 (setq gnus-article-smiley-mule-loaded-p nil))
1915 (when (and gnus-article-should-use-smiley-mule
1916 (not gnus-article-smiley-mule-loaded-p))
1917 (load "smiley-mule" nil t)
1918 (setq gnus-article-smiley-mule-loaded-p t)))
1919 (gnus-with-article-buffer
1920 (if (memq 'smiley gnus-article-wash-types)
1921 (gnus-delete-images 'smiley)
1923 (let ((images (smiley-region (point) (point-max))))
1925 (gnus-add-wash-type 'smiley)
1926 (dolist (image images)
1927 (gnus-add-image 'smiley image)))))))
1929 (defun gnus-article-remove-images ()
1930 "Remove all images from the article buffer."
1932 (gnus-with-article-buffer
1933 (dolist (elem gnus-article-image-alist)
1934 (gnus-delete-images (car elem)))))
1936 (defun gnus-article-treat-fold-newsgroups ()
1937 "Unfold folded message headers.
1938 Only the headers that fit into the current window width will be
1941 (gnus-with-article-headers
1942 (while (gnus-article-goto-header "newsgroups\\|followup-to")
1944 (mail-header-narrow-to-field)
1945 (while (re-search-forward ", *" nil t)
1946 (replace-match ", " t t))
1947 (mail-header-fold-field)
1948 (goto-char (point-max))))))
1950 (defun gnus-article-treat-body-boundary ()
1951 "Place a boundary line at the end of the headers."
1953 (when (and gnus-body-boundary-delimiter
1954 (> (length gnus-body-boundary-delimiter) 0))
1955 (gnus-with-article-headers
1956 (goto-char (point-max))
1957 (let ((start (point)))
1958 (insert "X-Boundary: ")
1959 (gnus-add-text-properties start (point) '(invisible t intangible t))
1961 (while (>= (1- (window-width)) (length str))
1962 (setq str (concat str gnus-body-boundary-delimiter)))
1963 (substring str 0 (1- (window-width))))
1965 (gnus-add-text-properties start (point) '(gnus-decoration 'header))))))
1967 (defun article-fill-long-lines ()
1968 "Fill lines that are wider than the window width."
1971 (let ((buffer-read-only nil)
1972 (width (window-width (get-buffer-window (current-buffer)))))
1975 (let ((adaptive-fill-mode nil)) ;Why? -sm
1978 (when (>= (current-column) (min fill-column width))
1979 (narrow-to-region (point) (gnus-point-at-bol))
1980 (fill-paragraph nil)
1981 (goto-char (point-max))
1983 (forward-line 1)))))))
1985 (defun article-capitalize-sentences ()
1986 "Capitalize the first word in each sentence."
1989 (let ((buffer-read-only nil)
1990 (paragraph-start "^[\n\^L]"))
1994 (forward-sentence)))))
1996 (defun article-remove-cr ()
1997 "Remove trailing CRs and then translate remaining CRs into LFs."
2000 (let ((buffer-read-only nil))
2001 (goto-char (point-min))
2002 (while (re-search-forward "\r+$" nil t)
2003 (replace-match "" t t))
2004 (goto-char (point-min))
2005 (while (search-forward "\r" nil t)
2006 (replace-match "\n" t t)))))
2008 (defun article-remove-trailing-blank-lines ()
2009 "Remove all trailing blank lines from the article."
2012 (let ((buffer-read-only nil))
2013 (goto-char (point-max))
2017 (while (and (not (bobp))
2018 (looking-at "^[ \t]*$")
2019 (not (gnus-annotation-in-region-p
2020 (point) (gnus-point-at-eol))))
2025 (defun article-display-x-face (&optional force)
2026 "Look for an X-Face header and display it if present."
2027 (interactive (list 'force))
2028 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2029 (gnus-with-article-headers
2030 ;; Delete the old process, if any.
2031 (when (process-status "article-x-face")
2032 (delete-process "article-x-face"))
2033 (if (memq 'xface gnus-article-wash-types)
2034 ;; We have already displayed X-Faces, so we remove them
2036 (gnus-delete-images 'xface)
2038 (let (x-faces from face grey)
2040 (when (and wash-face-p
2042 (goto-char (point-min))
2043 (not (re-search-forward
2044 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2045 (gnus-buffer-live-p gnus-original-article-buffer))
2046 ;; If type `W f', use gnus-original-article-buffer,
2047 ;; otherwise use the current buffer because displaying
2048 ;; RFC822 parts calls this function too.
2049 (set-buffer gnus-original-article-buffer))
2051 (mail-narrow-to-head)
2052 (if gnus-treat-display-grey-xface
2054 (while (gnus-article-goto-header "X-Face\\(-[0-9]+\\)?")
2055 (if (match-beginning 2)
2058 (push (cons (- (string-to-number (match-string 2)))
2059 (mail-header-field-value))
2061 (push (cons 0 (mail-header-field-value)) x-faces)))
2062 (dolist (x-face (prog1
2064 (sort x-faces 'car-less-than-car)
2066 (setq x-faces nil)))
2067 (push (cdr x-face) x-faces)))
2068 (while (gnus-article-goto-header "X-Face")
2069 (push (mail-header-field-value) x-faces)))
2070 (setq from (message-fetch-field "from"))))
2072 (let ((xpm (gnus-convert-gray-x-face-to-xpm x-faces))
2075 (setq image (gnus-create-image xpm 'xpm t))
2076 (gnus-article-goto-header "from")
2078 (insert "From: [no `from' set]\n")
2080 (gnus-add-wash-type 'xface)
2081 (gnus-add-image 'xface image)
2082 (gnus-put-image image)))
2083 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2084 ;; single external face.
2085 (when (stringp gnus-article-x-face-command)
2086 (setq x-faces (list (car x-faces))))
2087 (while (and (setq face (pop x-faces))
2088 gnus-article-x-face-command
2090 ;; Check whether this face is censored.
2091 (not gnus-article-x-face-too-ugly)
2092 (and gnus-article-x-face-too-ugly from
2093 (not (string-match gnus-article-x-face-too-ugly
2095 ;; We display the face.
2096 (if (symbolp gnus-article-x-face-command)
2097 ;; The command is a lisp function, so we call it.
2098 (if (gnus-functionp gnus-article-x-face-command)
2099 (funcall gnus-article-x-face-command face)
2100 (error "%s is not a function" gnus-article-x-face-command))
2101 ;; The command is a string, so we interpret the command
2102 ;; as a, well, command, and fork it off.
2103 (let ((process-connection-type nil))
2104 (process-kill-without-query
2106 "article-x-face" nil shell-file-name shell-command-switch
2107 gnus-article-x-face-command))
2110 (process-send-region "article-x-face"
2111 (point-min) (point-max)))
2112 (process-send-eof "article-x-face"))))))))))
2114 (defun article-decode-mime-words ()
2115 "Decode all MIME-encoded words in the article."
2118 (set-buffer gnus-article-buffer)
2119 (let ((inhibit-point-motion-hooks t)
2121 (mail-parse-charset gnus-newsgroup-charset)
2122 (mail-parse-ignored-charsets
2123 (save-excursion (set-buffer gnus-summary-buffer)
2124 gnus-newsgroup-ignored-charsets)))
2125 (mail-decode-encoded-word-region (point-min) (point-max)))))
2127 (defun article-decode-charset (&optional prompt)
2128 "Decode charset-encoded text in the article.
2129 If PROMPT (the prefix), prompt for a coding system to use."
2131 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2133 (mail-parse-charset gnus-newsgroup-charset)
2134 (mail-parse-ignored-charsets
2135 (save-excursion (condition-case nil
2136 (set-buffer gnus-summary-buffer)
2138 gnus-newsgroup-ignored-charsets))
2139 ct cte ctl charset format)
2142 (article-narrow-to-head)
2143 (setq ct (message-fetch-field "Content-Type" t)
2144 cte (message-fetch-field "Content-Transfer-Encoding" t)
2145 ctl (and ct (ignore-errors
2146 (mail-header-parse-content-type ct)))
2149 (mm-read-coding-system "Charset to decode: "))
2151 (mail-content-type-get ctl 'charset)))
2152 format (and ctl (mail-content-type-get ctl 'format)))
2154 (setq cte (mail-header-strip cte)))
2155 (if (and ctl (not (string-match "/" (car ctl))))
2157 (goto-char (point-max)))
2160 (narrow-to-region (point) (point-max))
2161 (when (and (eq mail-parse-charset 'gnus-decoded)
2162 (eq (mm-body-7-or-8) '8bit))
2163 ;; The text code could have been decoded.
2164 (setq charset mail-parse-charset))
2165 (when (and (or (not ctl)
2166 (equal (car ctl) "text/plain"))
2167 (not format)) ;; article with format will decode later.
2169 charset (and cte (intern (downcase
2170 (gnus-strip-whitespace cte))))
2173 (defun article-decode-encoded-words ()
2174 "Remove encoded-word encoding from headers."
2175 (let (buffer-read-only)
2176 (let ((charset (save-excursion
2177 (set-buffer gnus-summary-buffer)
2178 default-mime-charset)))
2179 (mime-decode-header-in-buffer charset))))
2181 (defun article-decode-group-name ()
2182 "Decode group names in `Newsgroups:'."
2183 (let ((inhibit-point-motion-hooks t)
2185 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2186 (when (and (or gnus-group-name-charset-method-alist
2187 gnus-group-name-charset-group-alist)
2188 (gnus-buffer-live-p gnus-original-article-buffer))
2189 (when (nnmail-fetch-field "Newsgroups")
2190 (nnheader-replace-header "Newsgroups"
2191 (gnus-decode-newsgroups
2192 (with-current-buffer
2193 gnus-original-article-buffer
2194 (nnmail-fetch-field "Newsgroups"))
2195 gnus-newsgroup-name method)))
2196 (when (nnmail-fetch-field "Followup-To")
2197 (nnheader-replace-header "Followup-To"
2198 (gnus-decode-newsgroups
2199 (with-current-buffer
2200 gnus-original-article-buffer
2201 (nnmail-fetch-field "Followup-To"))
2202 gnus-newsgroup-name method))))))
2204 (defun article-de-quoted-unreadable (&optional force read-charset)
2205 "Translate a quoted-printable-encoded article.
2206 If FORCE, decode the article whether it is marked as quoted-printable
2208 If READ-CHARSET, ask for a coding system."
2209 (interactive (list 'force current-prefix-arg))
2211 (let ((buffer-read-only nil) type charset)
2212 (if (gnus-buffer-live-p gnus-original-article-buffer)
2213 (with-current-buffer gnus-original-article-buffer
2215 (gnus-fetch-field "content-transfer-encoding"))
2216 (let* ((ct (gnus-fetch-field "content-type"))
2219 (mail-header-parse-content-type ct)))))
2220 (setq charset (and ctl
2221 (mail-content-type-get ctl 'charset)))
2222 (if (stringp charset)
2223 (setq charset (intern (downcase charset)))))))
2225 (setq charset (mm-read-coding-system "Charset: " charset)))
2227 (setq charset gnus-newsgroup-charset))
2229 (and type (let ((case-fold-search t))
2230 (string-match "quoted-printable" type))))
2232 (quoted-printable-decode-region
2233 (point) (point-max) (mm-charset-to-coding-system charset))))))
2235 (defun article-de-base64-unreadable (&optional force read-charset)
2236 "Translate a base64 article.
2237 If FORCE, decode the article whether it is marked as base64 not.
2238 If READ-CHARSET, ask for a coding system."
2239 (interactive (list 'force current-prefix-arg))
2241 (let ((buffer-read-only nil) type charset)
2242 (if (gnus-buffer-live-p gnus-original-article-buffer)
2243 (with-current-buffer gnus-original-article-buffer
2245 (gnus-fetch-field "content-transfer-encoding"))
2246 (let* ((ct (gnus-fetch-field "content-type"))
2249 (mail-header-parse-content-type ct)))))
2250 (setq charset (and ctl
2251 (mail-content-type-get ctl 'charset)))
2252 (if (stringp charset)
2253 (setq charset (intern (downcase charset)))))))
2255 (setq charset (mm-read-coding-system "Charset: " charset)))
2257 (setq charset gnus-newsgroup-charset))
2259 (and type (let ((case-fold-search t))
2260 (string-match "base64" type))))
2263 (narrow-to-region (point) (point-max))
2264 (base64-decode-region (point-min) (point-max))
2265 (mm-decode-coding-region
2266 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2271 (defun article-decode-HZ ()
2272 "Translate a HZ-encoded article."
2276 (let ((buffer-read-only nil))
2277 (rfc1843-decode-region (point-min) (point-max)))))
2279 (defun article-unsplit-urls ()
2280 "Remove the newlines that some other mailers insert into URLs."
2283 (let ((buffer-read-only nil))
2284 (goto-char (point-min))
2285 (while (re-search-forward
2286 "^\\(\\(https?\\|ftp\\)://\\S-+\\)\n\\(\\S-+\\)" nil t)
2287 (replace-match "\\1\\3" t)))))
2289 (defun article-wash-html (&optional read-charset)
2290 "Format an html article.
2291 If READ-CHARSET, ask for a coding system."
2294 (let ((buffer-read-only nil)
2296 (if (gnus-buffer-live-p gnus-original-article-buffer)
2297 (with-current-buffer gnus-original-article-buffer
2298 (let* ((ct (gnus-fetch-field "content-type"))
2301 (mail-header-parse-content-type ct)))))
2302 (setq charset (and ctl
2303 (mail-content-type-get ctl 'charset)))
2304 (if (stringp charset)
2305 (setq charset (intern (downcase charset)))))))
2307 (setq charset (mm-read-coding-system "Charset: " charset)))
2309 (setq charset gnus-newsgroup-charset))
2311 (save-window-excursion
2313 (narrow-to-region (point) (point-max))
2314 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2315 (entry (assq func mm-text-html-washer-alist)))
2317 (setq func (cdr entry)))
2319 ((gnus-functionp func)
2322 (apply (car func) (cdr func))))))))))
2324 (defun gnus-article-wash-html-with-w3 ()
2325 "Wash the current buffer with w3."
2327 (let ((w3-strict-width (window-width))
2328 (url-standalone-mode t)
2329 (url-gateway-unplugged t)
2330 (w3-honor-stylesheets nil))
2332 (w3-region (point-min) (point-max))
2335 (defun gnus-article-wash-html-with-w3m ()
2336 "Wash the current buffer with emacs-w3m."
2339 (narrow-to-region (point) (point-max))
2340 (let ((w3m-safe-url-regexp (if mm-inline-text-html-with-images
2343 (w3m-display-inline-images mm-inline-text-html-with-images)
2344 w3m-force-redisplay)
2345 (w3m-region (point-min) (point-max)))
2346 (when mm-inline-text-html-with-w3m-keymap
2347 (add-text-properties
2348 (point-min) (point-max)
2349 (append '(mm-inline-text-html-with-w3m t)
2350 (gnus-local-map-property mm-w3m-mode-map))))))
2352 (defun article-hide-list-identifiers ()
2353 "Remove list identifies from the Subject header.
2354 The `gnus-list-identifiers' variable specifies what to do."
2356 (let ((inhibit-point-motion-hooks t)
2357 (regexp (if (consp gnus-list-identifiers)
2358 (mapconcat 'identity gnus-list-identifiers " *\\|")
2359 gnus-list-identifiers))
2364 (article-narrow-to-head)
2365 (goto-char (point-min))
2366 (while (re-search-forward
2367 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2369 (delete-region (match-beginning 2) (match-end 0))
2370 (beginning-of-line))
2371 (when (re-search-forward
2372 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2373 (delete-region (match-beginning 1) (match-end 1))))))))
2375 (defun article-hide-pgp ()
2376 "Remove any PGP headers and signatures in the current article."
2380 (let ((inhibit-point-motion-hooks t)
2381 buffer-read-only beg end)
2383 ;; Hide the "header".
2384 (when (re-search-forward "^-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
2385 (gnus-add-wash-type 'pgp)
2386 (delete-region (match-beginning 0) (match-end 0))
2387 ;; Remove armor headers (rfc2440 6.2)
2388 (delete-region (point) (or (re-search-forward "^[ \t]*\n" nil t)
2391 ;; Hide the actual signature.
2392 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
2393 (setq end (1+ (match-beginning 0)))
2396 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
2398 ;; Perhaps we shouldn't hide to the end of the buffer
2399 ;; if there is no end to the signature?
2401 ;; Hide "- " PGP quotation markers.
2403 (narrow-to-region beg end)
2404 (goto-char (point-min))
2405 (while (re-search-forward "^- " nil t)
2407 (match-beginning 0) (match-end 0)))
2409 (gnus-run-hooks 'gnus-article-hide-pgp-hook))))))
2411 (defun article-hide-pem (&optional arg)
2412 "Toggle hiding of any PEM headers and signatures in the current article.
2413 If given a negative prefix, always show; if given a positive prefix,
2415 (interactive (gnus-article-hidden-arg))
2416 (unless (gnus-article-check-hidden-text 'pem arg)
2418 (let (buffer-read-only end)
2419 (goto-char (point-min))
2420 ;; Hide the horrendously ugly "header".
2421 (when (and (search-forward
2422 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2424 (setq end (1+ (match-beginning 0))))
2425 (gnus-add-wash-type 'pem)
2426 (gnus-article-hide-text-type
2428 (if (search-forward "\n\n" nil t)
2432 ;; Hide the trailer as well
2433 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2435 (gnus-article-hide-text-type
2436 (match-beginning 0) (match-end 0) 'pem)))))))
2438 (defun article-strip-banner ()
2439 "Strip the banner specified by the `banner' group parameter."
2443 (let ((inhibit-point-motion-hooks t)
2444 (banner (gnus-parameter-banner gnus-newsgroup-name))
2445 (gnus-signature-limit nil)
2446 buffer-read-only beg end)
2450 ((eq banner 'signature)
2451 (when (gnus-article-narrow-to-signature)
2454 (delete-region (point) (point-max))))
2456 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2457 (while (re-search-forward banner nil t)
2458 (delete-region (match-beginning 0) (match-end 0)))))
2460 (while (re-search-forward banner nil t)
2461 (delete-region (match-beginning 0) (match-end 0))))))))))
2463 (defun article-babel ()
2464 "Translate article using an online translation service."
2468 (set-buffer gnus-article-buffer)
2469 (when (article-goto-body)
2470 (let* ((buffer-read-only nil)
2473 (orig (buffer-substring start end))
2474 (trans (babel-as-string orig)))
2476 (narrow-to-region start end)
2477 (delete-region start end)
2480 (defun article-hide-signature (&optional arg)
2481 "Hide the signature in the current article.
2482 If given a negative prefix, always show; if given a positive prefix,
2484 (interactive (gnus-article-hidden-arg))
2490 (article-goto-body))
2491 (goto-char (point-min)))
2492 (unless (gnus-article-check-hidden-text 'signature arg)
2493 (let ((buffer-read-only nil)
2495 (while (setq button (text-property-any button (point-max)
2497 'gnus-signature-toggle))
2498 (setq button (text-property-not-all button (point-max)
2500 'gnus-signature-toggle))
2501 (when (and button (not (eobp)))
2502 (gnus-article-hide-text-type
2504 (next-single-property-change (1+ button) 'mime-view-entity
2507 (gnus-set-mode-line 'article))
2509 (defun article-strip-headers-in-body ()
2510 "Strip offensive headers from bodies."
2514 (let ((case-fold-search t))
2515 (when (looking-at "x-no-archive:")
2516 (gnus-delete-line)))))
2518 (defun article-strip-leading-blank-lines ()
2519 "Remove all blank lines from the beginning of the article."
2522 (let ((inhibit-point-motion-hooks t)
2524 (when (article-goto-body)
2525 (while (and (not (eobp))
2526 (looking-at "[ \t]*$"))
2527 (gnus-delete-line))))))
2529 (defun article-narrow-to-head ()
2530 "Narrow the buffer to the head of the message.
2531 Point is left at the beginning of the narrowed-to region."
2533 (goto-char (point-min))
2534 (if (search-forward "\n\n" nil 1)
2537 (goto-char (point-min)))
2539 (defun article-goto-body ()
2540 "Place point at the start of the body."
2541 (goto-char (point-min))
2543 ;; This variable is only bound when dealing with separate
2545 (article-goto-body-goes-to-point-min-p
2547 ((search-forward "\n\n" nil t)
2550 (goto-char (point-max))
2553 (defun article-strip-multiple-blank-lines ()
2554 "Replace consecutive blank lines with one empty line."
2557 (let ((inhibit-point-motion-hooks t)
2559 ;; First make all blank lines empty.
2561 (while (re-search-forward "^[ \t]+$" nil t)
2562 (unless (gnus-annotation-in-region-p
2563 (match-beginning 0) (match-end 0))
2564 (replace-match "" nil t)))
2565 ;; Then replace multiple empty lines with a single empty line.
2567 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2568 (unless (gnus-annotation-in-region-p
2569 (match-beginning 0) (match-end 0))
2570 (delete-region (match-beginning 1) (match-end 1)))))))
2572 (defun article-strip-leading-space ()
2573 "Remove all white space from the beginning of the lines in the article."
2576 (let ((inhibit-point-motion-hooks t)
2579 (while (re-search-forward "^[ \t]+" nil t)
2580 (replace-match "" t t)))))
2582 (defun article-strip-trailing-space ()
2583 "Remove all white space from the end of the lines in the article."
2586 (let ((inhibit-point-motion-hooks t)
2589 (while (re-search-forward "[ \t]+$" nil t)
2590 (replace-match "" t t)))))
2592 (defun article-strip-blank-lines ()
2593 "Strip leading, trailing and multiple blank lines."
2595 (article-strip-leading-blank-lines)
2596 (article-remove-trailing-blank-lines)
2597 (article-strip-multiple-blank-lines))
2599 (defun article-strip-all-blank-lines ()
2600 "Strip all blank lines."
2603 (let ((inhibit-point-motion-hooks t)
2606 (while (re-search-forward "^[ \t]*\n" nil t)
2607 (replace-match "" t t)))))
2609 (defun gnus-article-narrow-to-signature ()
2610 "Narrow to the signature; return t if a signature is found, else nil."
2611 (let ((inhibit-point-motion-hooks t))
2612 (when (gnus-article-search-signature)
2614 ;; Check whether we have some limits to what we consider
2615 ;; to be a signature.
2616 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2617 (list gnus-signature-limit)))
2619 (while (setq limit (pop limits))
2620 (if (or (and (integerp limit)
2621 (< (- (point-max) (point)) limit))
2623 (< (count-lines (point) (point-max)) limit))
2624 (and (gnus-functionp limit)
2626 (and (stringp limit)
2627 (not (re-search-forward limit nil t))))
2628 () ; This limit did not succeed.
2632 (narrow-to-region (point) (point-max))
2635 (defun gnus-article-search-signature ()
2636 "Search the current buffer for the signature separator.
2637 Put point at the beginning of the signature separator."
2638 (let ((cur (point)))
2639 (goto-char (point-max))
2640 (if (if (stringp gnus-signature-separator)
2641 (re-search-backward gnus-signature-separator nil t)
2642 (let ((seps gnus-signature-separator))
2644 (not (re-search-backward (car seps) nil t)))
2651 (defun gnus-article-hidden-arg ()
2652 "Return the current prefix arg as a number, or 0 if no prefix."
2653 (list (if current-prefix-arg
2654 (prefix-numeric-value current-prefix-arg)
2657 (defun gnus-article-check-hidden-text (type arg)
2658 "Return nil if hiding is necessary.
2659 Arg can be nil or a number. nil and positive means hide, negative
2660 means show, 0 means toggle."
2663 (let ((hide (gnus-article-hidden-text-p type)))
2669 (gnus-article-show-hidden-text type)
2672 (if (eq hide 'hidden)
2674 (gnus-article-show-hidden-text type)
2678 (defun gnus-article-hidden-text-p (type)
2679 "Say whether the current buffer contains hidden text of type TYPE."
2680 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2682 (not (get-text-property pos 'invisible))
2683 (not (get-text-property pos 'dummy-invisible)))
2685 (text-property-any (1+ pos) (point-max) 'article-type type)))
2690 (defun gnus-article-show-hidden-text (type &optional dummy)
2691 "Show all hidden text of type TYPE.
2692 Originally it is hide instead of DUMMY."
2693 (let ((buffer-read-only nil)
2694 (inhibit-point-motion-hooks t))
2695 (gnus-remove-text-properties-when
2697 (point-min) (point-max)
2698 (cons 'article-type (cons type
2699 gnus-hidden-properties)))
2700 (gnus-delete-wash-type type)))
2702 (defconst article-time-units
2703 `((year . ,(* 365.25 24 60 60))
2704 (week . ,(* 7 24 60 60))
2705 (day . ,(* 24 60 60))
2709 "Mapping from time units to seconds.")
2711 (defun article-date-ut (&optional type highlight header)
2712 "Convert DATE date to universal time in the current article.
2713 If TYPE is `local', convert to local time; if it is `lapsed', output
2714 how much time has lapsed since DATE. For `lapsed', the value of
2715 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2716 should replace the \"Date:\" one, or should be added below it."
2717 (interactive (list 'ut t))
2718 (let* ((header (or header
2719 (and (eq 1 (point-min))
2720 (mail-header-date (save-excursion
2721 (set-buffer gnus-summary-buffer)
2722 gnus-current-headers)))
2723 (message-fetch-field "date")
2725 (date (if (vectorp header) (mail-header-date header)
2727 (inhibit-point-motion-hooks t)
2728 bface eface date-pos)
2729 (when (and date (not (string= date "")))
2732 (article-narrow-to-head)
2733 (when (or (and (eq type 'lapsed)
2734 gnus-article-date-lapsed-new-header
2735 ;; Attempt to get the face of X-Sent first.
2736 (re-search-forward "^X-Sent:[ \t]" nil t))
2737 (re-search-forward "^Date:[ \t]" nil t)
2738 ;; If Date is missing, try again for X-Sent.
2739 (re-search-forward "^X-Sent:[ \t]" nil t))
2740 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2741 date (or (get-text-property (gnus-point-at-bol)
2744 eface (get-text-property (1- (gnus-point-at-eol))
2746 (let ((buffer-read-only nil))
2747 ;; Delete any old X-Sent headers.
2748 (when (setq date-pos
2749 (text-property-any (point-min) (point-max)
2750 'article-date-lapsed t))
2751 (goto-char (setq date-pos (set-marker (make-marker) date-pos)))
2752 (delete-region (match-beginning 0)
2753 (progn (forward-line 1) (point))))
2754 (goto-char (point-min))
2755 ;; Delete any old Date headers.
2756 (while (re-search-forward "^Date:[ \t]" nil t)
2758 (setq date-pos (match-beginning 0)))
2759 (unless (and (eq type 'lapsed)
2760 gnus-article-date-lapsed-new-header)
2761 (delete-region (match-beginning 0)
2762 (progn (message-next-header) (point)))))
2765 (goto-char date-pos)
2767 ;; Possibly, Date has been deleted.
2769 (when (and (eq type 'lapsed)
2770 gnus-article-date-lapsed-new-header
2771 (looking-at "Date:"))
2773 (goto-char (point-min)))
2774 (insert (article-make-date-line date type))
2775 (when (eq type 'lapsed)
2776 (put-text-property (gnus-point-at-bol) (point)
2777 'article-date-lapsed t))
2781 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2782 (put-text-property (match-beginning 1) (1+ (match-end 1))
2783 'original-date date)
2784 (put-text-property (match-beginning 1) (1+ (match-end 1))
2786 (put-text-property (match-beginning 2) (match-end 2)
2789 (defun article-make-date-line (date type)
2790 "Return a DATE line of TYPE."
2791 (unless (memq type '(local ut original user iso8601 lapsed english))
2792 (error "Unknown conversion type: %s" type))
2794 (let ((time (date-to-time date)))
2796 ;; Convert to the local timezone.
2798 (let ((tz (car (current-time-zone time))))
2799 (format "Date: %s %s%02d%02d" (current-time-string time)
2800 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2801 (/ (% (abs tz) 3600) 60))))
2802 ;; Convert to Universal Time.
2805 (current-time-string
2806 (let* ((e (parse-time-string date))
2807 (tm (apply 'encode-time e))
2809 (ls (- (cadr tm) (car (current-time-zone time)))))
2810 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2811 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2814 ;; Get the original date from the article.
2815 ((eq type 'original)
2816 (concat "Date: " (if (string-match "\n+$" date)
2817 (substring date 0 (match-beginning 0))
2819 ;; Let the user define the format.
2821 (if (gnus-functionp gnus-article-time-format)
2822 (funcall gnus-article-time-format time)
2825 (format-time-string gnus-article-time-format time))))
2828 (let ((tz (car (current-time-zone time))))
2831 (format-time-string "%Y%m%dT%H%M%S" time)
2832 (format "%s%02d%02d"
2833 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2834 (/ (% (abs tz) 3600) 60)))))
2835 ;; Do an X-Sent lapsed format.
2837 ;; If the date is seriously mangled, the timezone functions are
2838 ;; liable to bug out, so we ignore all errors.
2839 (let* ((now (current-time))
2840 (real-time (subtract-time now time))
2841 (real-sec (and real-time
2842 (+ (* (float (car real-time)) 65536)
2844 (sec (and real-time (abs real-sec)))
2854 ;; This is a bit convoluted, but basically we go
2855 ;; through the time units for years, weeks, etc,
2856 ;; and divide things to see whether that results
2857 ;; in positive answers.
2860 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2861 ;; The (remaining) seconds are too few to
2862 ;; be divided into this time unit.
2864 ;; It's big enough, so we output it.
2865 (setq sec (- sec (* num (cdr unit))))
2867 (concat (if prev ", " "") (int-to-string
2869 " " (symbol-name (car unit))
2870 (if (> num 1) "s" ""))
2872 article-time-units "")
2873 ;; If dates are odd, then it might appear like the
2874 ;; article was sent in the future.
2877 " in the future"))))))
2878 ;; Display the date in proper English
2880 (let ((dtime (decode-time time)))
2883 (number-to-string (nth 3 dtime))
2884 (let ((digit (% (nth 3 dtime) 10)))
2886 ((memq (nth 3 dtime) '(11 12 13)) "th")
2892 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2894 (number-to-string (nth 5 dtime))
2896 (format "%02d" (nth 2 dtime))
2898 (format "%02d" (nth 1 dtime)))))))
2900 (format "Date: %s (from Oort)" date))))
2902 (defun article-date-local (&optional highlight)
2903 "Convert the current article date to the local timezone."
2904 (interactive (list t))
2905 (article-date-ut 'local highlight))
2907 (defun article-date-english (&optional highlight)
2908 "Convert the current article date to something that is proper English."
2909 (interactive (list t))
2910 (article-date-ut 'english highlight))
2912 (defun article-date-original (&optional highlight)
2913 "Convert the current article date to what it was originally.
2914 This is only useful if you have used some other date conversion
2915 function and want to see what the date was before converting."
2916 (interactive (list t))
2917 (article-date-ut 'original highlight))
2919 (defun article-date-lapsed (&optional highlight)
2920 "Convert the current article date to time lapsed since it was sent."
2921 (interactive (list t))
2922 (article-date-ut 'lapsed highlight))
2924 (defun article-update-date-lapsed ()
2925 "Function to be run from a timer to update the lapsed time line."
2926 (let (deactivate-mark)
2931 (set-buffer (window-buffer w))
2932 (when (eq major-mode 'gnus-article-mode)
2933 (goto-char (point-min))
2934 (when (re-search-forward "^X-Sent:" nil t)
2935 (article-date-lapsed t))))
2938 (defun gnus-start-date-timer (&optional n)
2939 "Start a timer to update the X-Sent header in the article buffers.
2940 The numerical prefix says how frequently (in seconds) the function
2945 (gnus-stop-date-timer)
2946 (setq article-lapsed-timer
2947 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2949 (defun gnus-stop-date-timer ()
2950 "Stop the X-Sent timer."
2952 (when article-lapsed-timer
2953 (nnheader-cancel-timer article-lapsed-timer)
2954 (setq article-lapsed-timer nil)))
2956 (defun article-date-user (&optional highlight)
2957 "Convert the current article date to the user-defined format.
2958 This format is defined by the `gnus-article-time-format' variable."
2959 (interactive (list t))
2960 (article-date-ut 'user highlight))
2962 (defun article-date-iso8601 (&optional highlight)
2963 "Convert the current article date to ISO8601."
2964 (interactive (list t))
2965 (article-date-ut 'iso8601 highlight))
2967 ;; (defun article-show-all ()
2968 ;; "Show all hidden text in the article buffer."
2972 ;; (let ((buffer-read-only nil))
2973 ;; (gnus-article-unhide-text (point-min) (point-max))
2974 ;; (gnus-remove-text-with-property 'gnus-prev)
2975 ;; (gnus-remove-text-with-property 'gnus-next))))
2977 (defun article-show-all-headers ()
2978 "Show all hidden headers in the article buffer."
2983 (article-narrow-to-head)
2984 (let ((buffer-read-only nil))
2985 (gnus-article-unhide-text (point-min) (point-max))))))
2987 (defun article-remove-leading-whitespace ()
2988 "Remove excessive whitespace from all headers."
2992 (let ((buffer-read-only nil))
2993 (article-narrow-to-head)
2994 (goto-char (point-min))
2995 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
2996 (delete-region (match-beginning 1) (match-end 1)))))))
2998 (defun article-emphasize (&optional arg)
2999 "Emphasize text according to `gnus-emphasis-alist'."
3000 (interactive (gnus-article-hidden-arg))
3001 (unless (gnus-article-check-hidden-text 'emphasis arg)
3005 (with-current-buffer gnus-summary-buffer
3006 gnus-article-emphasis-alist)
3008 gnus-emphasis-alist))
3009 (buffer-read-only nil)
3010 (props (append '(article-type emphasis)
3011 gnus-hidden-properties))
3012 regexp elem beg invisible visible face)
3015 (while (setq elem (pop alist))
3017 (setq regexp (car elem)
3018 invisible (nth 1 elem)
3019 visible (nth 2 elem)
3021 (while (re-search-forward regexp nil t)
3022 (when (and (match-beginning visible) (match-beginning invisible))
3023 (gnus-article-hide-text
3024 (match-beginning invisible) (match-end invisible) props)
3025 (gnus-article-unhide-text-type
3026 (match-beginning visible) (match-end visible) 'emphasis)
3027 (gnus-put-overlay-excluding-newlines
3028 (match-beginning visible) (match-end visible) 'face face)
3029 (gnus-add-wash-type 'emphasis)
3030 (goto-char (match-end invisible)))))))))
3032 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3033 "Setup newsgroup emphasis alist."
3034 (unless gnus-article-emphasis-alist
3035 (let ((name (and gnus-newsgroup-name
3036 (gnus-group-real-name gnus-newsgroup-name))))
3037 (make-local-variable 'gnus-article-emphasis-alist)
3038 (setq gnus-article-emphasis-alist
3040 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3041 (while (setq elem (pop alist))
3042 (when (and name (string-match (car elem) name))
3044 highlight (copy-sequence (cdr elem)))))
3046 (copy-sequence highlight-words)
3047 (if gnus-newsgroup-name
3048 (copy-sequence (gnus-group-find-parameter
3049 gnus-newsgroup-name 'highlight-words t)))
3050 gnus-emphasis-alist)))))
3053 (defvar gnus-summary-article-menu)
3054 (defvar gnus-summary-post-menu))
3056 ;;; Saving functions.
3058 (defun gnus-article-save (save-buffer file &optional num)
3059 "Save the currently selected article."
3060 (unless gnus-save-all-headers
3061 ;; Remove headers according to `gnus-saved-headers'.
3062 (let ((gnus-visible-headers
3063 (or gnus-saved-headers gnus-visible-headers))
3064 (gnus-article-buffer save-buffer))
3066 (set-buffer save-buffer)
3067 (article-hide-headers 1 t))))
3068 (save-window-excursion
3069 (if (not gnus-default-article-saver)
3070 (error "No default saver is defined")
3071 ;; !!! Magic! The saving functions all save
3072 ;; `gnus-save-article-buffer' (or so they think), but we
3073 ;; bind that variable to our save-buffer.
3074 (set-buffer gnus-article-buffer)
3075 (let* ((gnus-save-article-buffer save-buffer)
3078 ((not gnus-prompt-before-saving) 'default)
3079 ((eq gnus-prompt-before-saving 'always) nil)
3081 (gnus-number-of-articles-to-be-saved
3082 (when (eq gnus-prompt-before-saving t)
3084 (set-buffer gnus-article-current-summary)
3085 (funcall gnus-default-article-saver filename)))))
3087 (defun gnus-read-save-file-name (prompt &optional filename
3088 function group headers variable)
3090 (funcall function group headers (symbol-value variable)))
3095 ((eq filename 'default)
3101 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3104 (if (and gnus-number-of-articles-to-be-saved
3105 (> gnus-number-of-articles-to-be-saved 1))
3106 (format "these %d articles"
3107 gnus-number-of-articles-to-be-saved)
3110 ;; Let the split methods have their say.
3112 ;; No split name was found.
3115 (concat prompt " (default "
3116 (file-name-nondirectory default-name) ") ")
3117 (file-name-directory default-name)
3119 ;; A single group name is returned.
3120 ((stringp split-name)
3122 (funcall function split-name headers
3123 (symbol-value variable)))
3125 (concat prompt " (default "
3126 (file-name-nondirectory default-name) ") ")
3127 (file-name-directory default-name)
3129 ;; A single split name was found
3130 ((= 1 (length split-name))
3131 (let* ((name (expand-file-name
3133 gnus-article-save-directory))
3134 (dir (cond ((file-directory-p name)
3135 (file-name-as-directory name))
3136 ((file-exists-p name) name)
3137 (t gnus-article-save-directory))))
3139 (concat prompt " (default " name ") ")
3141 ;; A list of splits was found.
3143 (setq split-name (nreverse split-name))
3145 (let ((file-name-history
3146 (nconc split-name file-name-history)))
3150 (concat prompt " (`M-p' for defaults) ")
3151 gnus-article-save-directory
3153 gnus-article-save-directory)))
3154 (car (push result file-name-history)))))))
3155 ;; Create the directory.
3156 (gnus-make-directory (file-name-directory file))
3157 ;; If we have read a directory, we append the default file name.
3158 (when (file-directory-p file)
3159 (setq file (expand-file-name (file-name-nondirectory
3161 (file-name-as-directory file))))
3162 ;; Possibly translate some characters.
3163 (nnheader-translate-file-chars file))))))
3164 (gnus-make-directory (file-name-directory result))
3165 (set variable result)))
3167 (defun gnus-article-archive-name (group)
3168 "Return the first instance of an \"Archive-name\" in the current buffer."
3169 (let ((case-fold-search t))
3170 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3171 (nnheader-concat gnus-article-save-directory
3172 (match-string 1)))))
3174 (defun gnus-article-nndoc-name (group)
3175 "If GROUP is an nndoc group, return the name of the parent group."
3176 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3177 (gnus-group-get-parameter group 'save-article-group)))
3179 (defun gnus-summary-save-in-rmail (&optional filename)
3180 "Append this article to Rmail file.
3181 Optional argument FILENAME specifies file name.
3182 Directory to save to is default to `gnus-article-save-directory'."
3183 (setq filename (gnus-read-save-file-name
3184 "Save %s in rmail file:" filename
3185 gnus-rmail-save-name gnus-newsgroup-name
3186 gnus-current-headers 'gnus-newsgroup-last-rmail))
3187 (gnus-eval-in-buffer-window gnus-save-article-buffer
3191 (gnus-output-to-rmail filename))))
3194 (defun gnus-summary-save-in-mail (&optional filename)
3195 "Append this article to Unix mail file.
3196 Optional argument FILENAME specifies file name.
3197 Directory to save to is default to `gnus-article-save-directory'."
3198 (setq filename (gnus-read-save-file-name
3199 "Save %s in Unix mail file:" filename
3200 gnus-mail-save-name gnus-newsgroup-name
3201 gnus-current-headers 'gnus-newsgroup-last-mail))
3202 (gnus-eval-in-buffer-window gnus-save-article-buffer
3206 (if (and (file-readable-p filename)
3207 (mail-file-babyl-p filename))
3208 (rmail-output-to-rmail-file filename t)
3209 (gnus-output-to-mail filename)))))
3212 (defun gnus-summary-save-in-file (&optional filename overwrite)
3213 "Append this article to file.
3214 Optional argument FILENAME specifies file name.
3215 Directory to save to is default to `gnus-article-save-directory'."
3216 (setq filename (gnus-read-save-file-name
3217 "Save %s in file:" filename
3218 gnus-file-save-name gnus-newsgroup-name
3219 gnus-current-headers 'gnus-newsgroup-last-file))
3220 (gnus-eval-in-buffer-window gnus-save-article-buffer
3224 (when (and overwrite
3225 (file-exists-p filename))
3226 (delete-file filename))
3227 (gnus-output-to-file filename))))
3230 (defun gnus-summary-write-to-file (&optional filename)
3231 "Write this article to a file, overwriting it if the file exists.
3232 Optional argument FILENAME specifies file name.
3233 The directory to save in defaults to `gnus-article-save-directory'."
3234 (gnus-summary-save-in-file nil t))
3236 (defun gnus-summary-save-body-in-file (&optional filename)
3237 "Append this article body to a file.
3238 Optional argument FILENAME specifies file name.
3239 The directory to save in defaults to `gnus-article-save-directory'."
3240 (setq filename (gnus-read-save-file-name
3241 "Save %s body in file:" filename
3242 gnus-file-save-name gnus-newsgroup-name
3243 gnus-current-headers 'gnus-newsgroup-last-file))
3244 (gnus-eval-in-buffer-window gnus-save-article-buffer
3248 (when (article-goto-body)
3249 (narrow-to-region (point) (point-max)))
3250 (gnus-output-to-file filename))))
3253 (defun gnus-summary-save-in-pipe (&optional command)
3254 "Pipe this article to subprocess."
3256 (cond ((and (eq command 'default)
3257 gnus-last-shell-command)
3258 gnus-last-shell-command)
3263 "Shell command on %s: "
3264 (if (and gnus-number-of-articles-to-be-saved
3265 (> gnus-number-of-articles-to-be-saved 1))
3266 (format "these %d articles"
3267 gnus-number-of-articles-to-be-saved)
3269 gnus-last-shell-command))))
3270 (when (string-equal command "")
3271 (if gnus-last-shell-command
3272 (setq command gnus-last-shell-command)
3273 (error "A command is required")))
3274 (gnus-eval-in-buffer-window gnus-article-buffer
3277 (shell-command-on-region (point-min) (point-max) command nil)))
3278 (setq gnus-last-shell-command command))
3280 (defun gnus-summary-pipe-to-muttprint (&optional command)
3281 "Pipe this article to muttprint."
3282 (setq command (read-string
3283 "Print using command: " gnus-summary-muttprint-program
3284 nil gnus-summary-muttprint-program))
3285 (gnus-summary-save-in-pipe command))
3287 ;;; Article file names when saving.
3289 (defun gnus-capitalize-newsgroup (newsgroup)
3290 "Capitalize NEWSGROUP name."
3291 (when (not (zerop (length newsgroup)))
3292 (concat (char-to-string (upcase (aref newsgroup 0)))
3293 (substring newsgroup 1))))
3295 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3296 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3297 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3298 Otherwise, it is like ~/News/news/group/num."
3301 (concat (if (gnus-use-long-file-name 'not-save)
3302 (gnus-capitalize-newsgroup newsgroup)
3303 (gnus-newsgroup-directory-form newsgroup))
3304 "/" (int-to-string (mail-header-number headers)))
3305 gnus-article-save-directory)))
3307 (string-equal (file-name-directory default)
3308 (file-name-directory last-file))
3309 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3311 (or last-file default))))
3313 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3314 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3315 If variable `gnus-use-long-file-name' is non-nil, it is
3316 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3319 (concat (if (gnus-use-long-file-name 'not-save)
3321 (gnus-newsgroup-directory-form newsgroup))
3322 "/" (int-to-string (mail-header-number headers)))
3323 gnus-article-save-directory)))
3325 (string-equal (file-name-directory default)
3326 (file-name-directory last-file))
3327 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3329 (or last-file default))))
3331 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3332 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3333 If variable `gnus-use-long-file-name' is non-nil, it is
3334 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3337 (if (gnus-use-long-file-name 'not-save)
3340 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3342 gnus-article-save-directory)))
3344 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3345 "Generate file name from sender."
3346 (let ((from (mail-header-from headers)))
3348 (if (and from (string-match "\\([^ <]+\\)@" from))
3349 (match-string 1 from)
3351 gnus-article-save-directory)))
3353 (defun article-verify-x-pgp-sig ()
3356 (if (gnus-buffer-live-p gnus-original-article-buffer)
3357 (let ((sig (with-current-buffer gnus-original-article-buffer
3358 (gnus-fetch-field "X-PGP-Sig")))
3362 (mml2015-clear-verify-function))
3364 (insert-buffer gnus-original-article-buffer)
3365 (setq items (split-string sig))
3366 (message-narrow-to-head)
3367 (let ((inhibit-point-motion-hooks t)
3368 (case-fold-search t))
3369 ;; Don't verify multiple headers.
3370 (setq headers (mapconcat (lambda (header)
3372 (mail-fetch-field header) "\n"))
3373 (split-string (nth 1 items) ",") "")))
3374 (delete-region (point-min) (point-max))
3375 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3376 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3381 (if (looking-at "^-")
3384 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3385 (insert "Version: " (car items) "\n\n")
3386 (insert (mapconcat 'identity (cddr items) "\n"))
3387 (insert "\n-----END PGP SIGNATURE-----\n")
3388 (let ((mm-security-handle (list (format "multipart/signed"))))
3389 (mml2015-clean-buffer)
3390 (let ((coding-system-for-write (or gnus-newsgroup-charset
3392 (funcall (mml2015-clear-verify-function)))
3394 (or (mm-handle-multipart-ctl-parameter
3395 mm-security-handle 'gnus-details)
3396 (mm-handle-multipart-ctl-parameter
3397 mm-security-handle 'gnus-info)))))
3399 (let (buffer-read-only bface eface)
3401 (message-narrow-to-head)
3402 (goto-char (point-max))
3404 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3405 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3406 (message-remove-header "X-Gnus-PGP-Verify")
3407 (if (re-search-forward "^X-PGP-Sig:" nil t)
3409 (goto-char (point-max)))
3410 (narrow-to-region (point) (point))
3411 (insert "X-Gnus-PGP-Verify: " info "\n")
3412 (goto-char (point-min))
3415 (if (not (looking-at "^[ \t]"))
3419 (goto-char (point-min))
3420 (when (looking-at "\\([^:]+\\): *")
3421 (put-text-property (match-beginning 1) (1+ (match-end 1))
3423 (put-text-property (match-end 0) (point-max)
3424 'face eface)))))))))
3426 (defun article-verify-cancel-lock ()
3427 "Verify Cancel-Lock header."
3429 (if (gnus-buffer-live-p gnus-original-article-buffer)
3430 (canlock-verify gnus-original-article-buffer)))
3432 (defun article-monafy ()
3433 "Display body part with mona font."
3435 (unless (if (featurep 'xemacs)
3436 (find-face 'gnus-mona-face)
3437 (facep 'gnus-mona-face))
3438 (require 'navi2ch-mona)
3439 (set-face-font (make-face 'gnus-mona-face) navi2ch-mona-font))
3441 (let ((buffer-read-only nil))
3444 (gnus-make-overlay (point) (point-max))
3445 'face 'gnus-mona-face))))
3452 (setq afunc (car func)
3455 gfunc (intern (format "gnus-%s" func))))
3457 (when (fboundp afunc)
3458 `(lambda (&optional interactive &rest args)
3459 ,(documentation afunc t)
3460 (interactive (list t))
3462 (set-buffer gnus-article-buffer)
3464 (call-interactively ',afunc)
3465 (apply ',afunc args))))))))
3466 '(article-hide-headers
3467 article-verify-x-pgp-sig
3468 article-verify-cancel-lock
3470 article-hide-boring-headers
3471 article-toggle-headers
3472 article-treat-overstrike
3473 article-fill-long-lines
3474 article-capitalize-sentences
3476 article-remove-leading-whitespace
3477 article-display-x-face
3478 article-de-quoted-unreadable
3479 article-de-base64-unreadable
3482 article-unsplit-urls
3483 article-hide-list-identifiers
3485 article-strip-banner
3488 article-hide-signature
3489 article-strip-headers-in-body
3490 article-remove-trailing-blank-lines
3491 article-strip-leading-blank-lines
3492 article-strip-multiple-blank-lines
3493 article-strip-leading-space
3494 article-strip-trailing-space
3495 article-strip-blank-lines
3496 article-strip-all-blank-lines
3498 article-date-english
3499 article-date-iso8601
3500 article-date-original
3502 article-decode-mime-words
3503 article-decode-charset
3504 article-decode-encoded-words
3508 article-treat-dumbquotes
3509 article-normalize-headers
3510 (article-show-all-headers . gnus-article-show-all-headers)
3511 ;; (article-show-all . gnus-article-show-all)
3515 ;;; Gnus article mode
3518 (put 'gnus-article-mode 'mode-class 'special)
3520 (gnus-define-keys gnus-article-mode-map
3521 " " gnus-article-goto-next-page
3522 "\177" gnus-article-goto-prev-page
3523 [delete] gnus-article-goto-prev-page
3524 [backspace] gnus-article-goto-prev-page
3525 "\C-c^" gnus-article-refer-article
3526 "h" gnus-article-show-summary
3527 "s" gnus-article-show-summary
3528 "\C-c\C-m" gnus-article-mail
3529 "?" gnus-article-describe-briefly
3530 "e" gnus-summary-edit-article
3531 "<" beginning-of-buffer
3533 "\C-c\C-i" gnus-info-find-node
3535 "R" gnus-article-reply-with-original
3536 "F" gnus-article-followup-with-original
3537 "\C-hk" gnus-article-describe-key
3538 "\C-hc" gnus-article-describe-key-briefly
3540 "\C-d" gnus-article-read-summary-keys
3541 "\M-*" gnus-article-read-summary-keys
3542 "\M-#" gnus-article-read-summary-keys
3543 "\M-^" gnus-article-read-summary-keys
3544 "\M-g" gnus-article-read-summary-keys)
3546 ;; Define almost undefined keys to `gnus-article-read-summary-keys'.
3550 (push (char-to-string key) keys)
3552 (dolist (elem (accessible-keymaps gnus-summary-mode-map))
3553 (setq key (car elem))
3554 (when (and (> (length key) 0)
3555 (not (eq 'menu-bar (aref key 0)))
3556 (symbolp (lookup-key gnus-summary-mode-map key)))
3559 (unless (lookup-key gnus-article-mode-map key)
3560 (define-key gnus-article-mode-map key 'gnus-article-read-summary-keys))))
3562 (defun gnus-article-make-menu-bar ()
3563 (unless (boundp 'gnus-article-commands-menu)
3564 (gnus-summary-make-menu-bar))
3565 (gnus-turn-off-edit-menu 'article)
3566 (unless (boundp 'gnus-article-article-menu)
3568 gnus-article-article-menu gnus-article-mode-map ""
3570 ["Scroll forwards" gnus-article-goto-next-page t]
3571 ["Scroll backwards" gnus-article-goto-prev-page t]
3572 ["Show summary" gnus-article-show-summary t]
3573 ["Fetch Message-ID at point" gnus-article-refer-article t]
3574 ["Mail to address at point" gnus-article-mail t]
3575 ["Send a bug report" gnus-bug t]))
3578 gnus-article-treatment-menu gnus-article-mode-map ""
3579 ;; Fixme: this should use :active (and maybe :visible).
3581 ["Hide headers" gnus-article-toggle-headers t]
3582 ["Hide signature" gnus-article-hide-signature t]
3583 ["Hide citation" gnus-article-hide-citation t]
3584 ["Treat overstrike" gnus-article-treat-overstrike t]
3585 ["Remove carriage return" gnus-article-remove-cr t]
3586 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3587 ["Treat html" gnus-article-wash-html t]
3588 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3589 ["Decode HZ" gnus-article-decode-HZ t]))
3591 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3593 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3595 (gnus-run-hooks 'gnus-article-menu-hook)))
3597 ;; Fixme: do something for the Emacs tool bar in Article mode a la
3600 (defun gnus-article-mode ()
3601 "Major mode for displaying an article.
3603 All normal editing commands are switched off.
3605 The following commands are available in addition to all summary mode
3607 \\<gnus-article-mode-map>
3608 \\[gnus-article-next-page]\t Scroll the article one page forwards
3609 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3610 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3611 \\[gnus-article-show-summary]\t Display the summary buffer
3612 \\[gnus-article-mail]\t Send a reply to the address near point
3613 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3614 \\[gnus-info-find-node]\t Go to the Gnus info node"
3616 (gnus-simplify-mode-line)
3617 (setq mode-name "Article")
3618 (setq major-mode 'gnus-article-mode)
3619 (make-local-variable 'minor-mode-alist)
3620 (unless (assq 'gnus-show-mime minor-mode-alist)
3621 (push (list 'gnus-show-mime " MIME") minor-mode-alist))
3622 (use-local-map gnus-article-mode-map)
3623 (when (gnus-visual-p 'article-menu 'menu)
3624 (gnus-article-make-menu-bar))
3625 (gnus-update-format-specifications nil 'article-mode)
3626 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3627 (make-local-variable 'gnus-page-broken)
3628 (make-local-variable 'gnus-button-marker-list)
3629 (make-local-variable 'gnus-article-current-summary)
3630 (make-local-variable 'gnus-article-mime-handles)
3631 (make-local-variable 'gnus-article-decoded-p)
3632 (make-local-variable 'gnus-article-mime-handle-alist)
3633 (make-local-variable 'gnus-article-wash-types)
3634 (make-local-variable 'gnus-article-image-alist)
3635 (make-local-variable 'gnus-article-charset)
3636 (make-local-variable 'gnus-article-ignored-charsets)
3637 (gnus-set-default-directory)
3638 (buffer-disable-undo)
3639 (setq buffer-read-only t)
3640 (set-syntax-table gnus-article-mode-syntax-table)
3641 (gnus-run-hooks 'gnus-article-mode-hook))
3643 (defun gnus-article-setup-buffer ()
3644 "Initialize the article buffer."
3645 (let* ((name (if gnus-single-article-buffer "*Article*"
3646 (concat "*Article " gnus-newsgroup-name "*")))
3648 (progn (string-match "\\*Article" name)
3649 (concat " *Original Article"
3650 (substring name (match-end 0))))))
3651 (setq gnus-article-buffer name)
3652 (setq gnus-original-article-buffer original)
3653 (setq gnus-article-mime-handle-alist nil)
3654 ;; This might be a variable local to the summary buffer.
3655 (unless gnus-single-article-buffer
3657 (set-buffer gnus-summary-buffer)
3658 (setq gnus-article-buffer name)
3659 (setq gnus-original-article-buffer original)
3660 (gnus-set-global-variables)))
3661 (gnus-article-setup-highlight-words)
3662 ;; Init original article buffer.
3664 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3665 (set-buffer-multibyte t)
3666 (setq major-mode 'gnus-original-article-mode)
3667 (make-local-variable 'gnus-original-article))
3668 (if (get-buffer name)
3671 (buffer-disable-undo)
3672 (setq buffer-read-only t)
3673 (unless (eq major-mode 'gnus-article-mode)
3674 (gnus-article-mode))
3677 (set-buffer (gnus-get-buffer-create name))
3679 (make-local-variable 'gnus-summary-buffer)
3680 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3681 (current-buffer)))))
3683 ;; Set article window start at LINE, where LINE is the number of lines
3684 ;; from the head of the article.
3685 (defun gnus-article-set-window-start (&optional line)
3687 (gnus-get-buffer-window gnus-article-buffer t)
3689 (set-buffer gnus-article-buffer)
3690 (goto-char (point-min))
3693 (gnus-message 6 "Moved to bookmark")
3694 (search-forward "\n\n" nil t)
3698 ;;; @@ article filters
3701 (defun gnus-article-display-mime-message ()
3702 "Article display method for MIME message."
3703 ;; called from `gnus-original-article-buffer'.
3704 (let (charset all-headers)
3705 (with-current-buffer gnus-summary-buffer
3706 (setq charset default-mime-charset
3707 all-headers gnus-have-all-headers))
3708 (make-local-variable 'default-mime-charset)
3709 (setq default-mime-charset charset)
3710 (with-current-buffer (get-buffer-create gnus-article-buffer)
3711 (make-local-variable 'default-mime-charset)
3712 (setq default-mime-charset charset))
3713 (mime-display-message mime-message-structure
3714 gnus-article-buffer nil gnus-article-mode-map)
3716 (gnus-article-hide-headers nil -1)))
3717 (run-hooks 'gnus-mime-article-prepare-hook))
3719 (defun gnus-article-display-traditional-message ()
3720 "Article display method for traditional message."
3721 (set-buffer gnus-article-buffer)
3722 (let (buffer-read-only)
3724 (insert-buffer-substring gnus-original-article-buffer)))
3726 (defun gnus-article-make-full-mail-header (&optional number charset)
3727 "Create a new mail header structure in a raw article buffer."
3728 (unless (and number charset)
3729 (save-current-buffer
3730 (set-buffer gnus-summary-buffer)
3732 (setq number (or (cdr gnus-article-current) 0)))
3734 (setq charset (or default-mime-charset 'x-ctext)))))
3735 (goto-char (point-min))
3736 (let ((header-end (if (search-forward "\n\n" nil t)
3738 (goto-char (point-max))))
3739 (chars (- (point-max) (point)))
3740 (lines (count-lines (point) (point-max)))
3741 (default-mime-charset charset)
3743 (narrow-to-region (point-min) header-end)
3744 (setq xref (std11-fetch-field "xref"))
3746 (make-full-mail-header
3748 (std11-fetch-field "subject")
3749 (std11-fetch-field "from")
3750 (std11-fetch-field "date")
3751 (std11-fetch-field "message-id")
3752 (std11-fetch-field "references")
3755 (when xref (concat "Xref: " xref)))
3758 (defun gnus-article-prepare (article &optional all-headers header)
3759 "Prepare ARTICLE in article mode buffer.
3760 ARTICLE should either be an article number or a Message-ID.
3761 If ARTICLE is an id, HEADER should be the article headers.
3762 If ALL-HEADERS is non-nil, no headers are hidden."
3764 ;; Make sure we start in a summary buffer.
3765 (unless (eq major-mode 'gnus-summary-mode)
3766 (set-buffer gnus-summary-buffer))
3767 (setq gnus-summary-buffer (current-buffer))
3768 (let* ((gnus-article (if header (mail-header-number header) article))
3769 (summary-buffer (current-buffer))
3770 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3771 (group gnus-newsgroup-name)
3774 (gnus-article-setup-buffer)
3775 (set-buffer gnus-article-buffer)
3776 ;; Deactivate active regions.
3777 (when (and (boundp 'transient-mark-mode)
3778 transient-mark-mode)
3779 (setq mark-active nil))
3780 (if (not (setq result (let ((buffer-read-only nil))
3781 (gnus-request-article-this-buffer
3783 ;; There is no such article.
3785 (when (and (numberp article)
3786 (not (memq article gnus-newsgroup-sparse)))
3787 (setq gnus-article-current
3788 (cons gnus-newsgroup-name article))
3789 (set-buffer gnus-summary-buffer)
3790 (setq gnus-current-article article)
3791 (if (eq (gnus-article-mark article) gnus-undownloaded-mark)
3793 (gnus-summary-set-agent-mark article)
3794 (message "Message marked for downloading"))
3795 (gnus-summary-mark-article article gnus-canceled-mark)
3796 (unless (memq article gnus-newsgroup-sparse)
3797 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3798 (if (or (eq result 'pseudo)
3799 (eq result 'nneething))
3802 (set-buffer summary-buffer)
3803 (push article gnus-newsgroup-history)
3804 (setq gnus-last-article gnus-current-article
3805 gnus-current-article 0
3806 gnus-current-headers nil
3807 gnus-article-current nil)
3808 (if (eq result 'nneething)
3809 (gnus-configure-windows 'summary)
3810 (gnus-configure-windows 'article))
3811 (gnus-set-global-variables))
3812 (let ((gnus-article-mime-handle-alist-1
3813 gnus-article-mime-handle-alist))
3814 (gnus-set-mode-line 'article)))
3815 ;; The result from the `request' was an actual article -
3816 ;; or at least some text that is now displayed in the
3818 (when (and (numberp article)
3819 (not (eq article gnus-current-article)))
3820 ;; Seems like a new article has been selected.
3821 ;; `gnus-current-article' must be an article number.
3823 (set-buffer summary-buffer)
3824 (push article gnus-newsgroup-history)
3825 (setq gnus-last-article gnus-current-article
3826 gnus-current-article article
3827 gnus-current-headers
3828 (gnus-summary-article-header gnus-current-article)
3829 gnus-article-current
3830 (cons gnus-newsgroup-name gnus-current-article))
3831 (unless (vectorp gnus-current-headers)
3832 (setq gnus-current-headers nil))
3833 (gnus-summary-goto-subject gnus-current-article)
3834 (when (gnus-summary-show-thread)
3835 ;; If the summary buffer really was folded, the
3836 ;; previous goto may not actually have gone to
3837 ;; the right article, but the thread root instead.
3839 (gnus-summary-goto-subject gnus-current-article))
3840 (gnus-run-hooks 'gnus-mark-article-hook)
3841 (gnus-set-mode-line 'summary)
3842 (when (gnus-visual-p 'article-highlight 'highlight)
3843 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3844 ;; Set the global newsgroup variables here.
3845 (gnus-set-global-variables)
3846 (setq gnus-have-all-headers
3847 (or all-headers gnus-show-all-headers))))
3849 (gnus-configure-windows 'article))
3850 (when (or (numberp article)
3852 (gnus-article-prepare-display)
3854 (goto-char (point-min))
3855 (setq gnus-page-broken
3856 (when gnus-break-pages
3857 (gnus-narrow-to-page)
3859 (let ((gnus-article-mime-handle-alist-1
3860 gnus-article-mime-handle-alist))
3861 (gnus-set-mode-line 'article))
3863 (set-window-point (get-buffer-window (current-buffer)) (point))
3864 (gnus-configure-windows 'article)
3867 (defun gnus-article-prepare-mime-display (&optional number)
3868 (goto-char (point-min))
3869 (when (re-search-forward "^[^\t ]+:" nil t)
3870 (goto-char (match-beginning 0)))
3871 (let ((entity (if (eq 1 (point-min))
3872 (get-text-property 1 'mime-view-entity)
3873 (get-text-property (point) 'mime-view-entity)))
3874 last-entity child-entity next type)
3875 (setq child-entity (mime-entity-children entity))
3877 (setq last-entity (nth (1- (length child-entity))
3879 (setq last-entity entity))
3881 (narrow-to-region (point)
3882 (if (search-forward "\n\n" nil t)
3885 (gnus-treat-article 'head)
3886 (put-text-property (point-min) (point-max) 'article-treated-header t)
3887 (goto-char (point-max)))
3888 (while (and (not (eobp)) entity)
3889 (setq next (set-marker
3891 (next-single-property-change (point) 'mime-view-entity
3893 (let ((types (mime-entity-content-type entity)))
3894 (while (eq 'multipart (mime-content-type-primary-type types))
3895 (setq entity (car (mime-entity-children entity))
3896 types (mime-entity-content-type entity)))
3898 (setq type (format "%s/%s"
3899 (mime-content-type-primary-type types)
3900 (mime-content-type-subtype types)))))
3901 (if (string-equal type "message/rfc822")
3904 (let ((children (mime-entity-children entity))
3907 (setq last-children (nth (1- (length children)) children))
3910 (not (eq last-children
3911 (get-text-property next 'mime-view-entity)))
3913 (next-single-property-change next
3915 nil (point-max)))))))
3916 (setq next (next-single-property-change next 'mime-view-entity
3919 (narrow-to-region (point) next)
3920 (gnus-article-prepare-mime-display)
3921 (goto-char (point-max)))
3922 (setq entity (get-text-property (point) 'mime-view-entity)))
3924 (narrow-to-region (point) next)
3925 ;; Kludge. We have to count true number, but for now,
3926 ;; part number is here only to achieve `last'.
3927 (gnus-treat-article nil 1
3928 (if (eq entity last-entity)
3931 (goto-char (point-max)))
3932 (setq entity (get-text-property next 'mime-view-entity))))))
3935 (defun gnus-article-prepare-display ()
3936 "Make the current buffer look like a nice article."
3937 (let ((gnus-article-buffer (current-buffer))
3939 (unless (eq major-mode 'gnus-article-mode)
3940 (gnus-article-mode))
3941 (setq buffer-read-only nil
3942 gnus-button-marker-list nil
3943 gnus-article-wash-types nil
3944 gnus-article-image-alist nil)
3947 (static-if (featurep 'xemacs)
3948 (map-extents (lambda (extent maparg) (delete-extent extent)))
3949 (let ((lists (overlay-lists)))
3950 (dolist (overlay (nconc (car lists) (cdr lists)))
3951 (delete-overlay overlay)))))
3952 (gnus-run-hooks 'gnus-tmp-internal-hook))
3953 (set-buffer gnus-original-article-buffer)
3955 (setq mime-message-structure gnus-current-headers)
3956 (mime-buffer-entity-set-buffer-internal mime-message-structure
3957 gnus-original-article-buffer)
3958 (mime-entity-set-representation-type-internal mime-message-structure
3959 'mime-buffer-entity)
3960 (luna-send mime-message-structure 'initialize-instance
3961 mime-message-structure)
3963 (let (mime-display-header-hook mime-display-text/plain-hook)
3964 (funcall gnus-article-display-method-for-mime))
3965 (funcall gnus-article-display-method-for-traditional))
3966 ;; Call the treatment functions.
3967 (let ((inhibit-read-only t))
3971 (gnus-article-prepare-mime-display)
3972 (narrow-to-region (goto-char (point-min))
3973 (if (search-forward "\n\n" nil t)
3976 (gnus-treat-article 'head)
3977 (put-text-property (point-min) (point-max) 'article-treated-header t)
3978 (goto-char (point-max))
3980 (narrow-to-region (point) (point-max))
3981 (gnus-treat-article nil))
3982 (put-text-property (point-min) (point-max) 'read-only nil)))
3983 (gnus-run-hooks 'gnus-article-prepare-hook))
3985 (defun gnus-article-decode-article-as-default-mime-charset ()
3986 "Decode an article as `default-mime-charset'. It won't work if the
3987 value of the variable `gnus-show-mime' is non-nil."
3988 (unless gnus-show-mime
3989 (set (make-local-variable 'default-mime-charset)
3990 (with-current-buffer gnus-summary-buffer
3991 default-mime-charset))
3992 (decode-mime-charset-region (point-min) (point-max)
3993 default-mime-charset)))
3996 ;;; Gnus MIME viewing functions
3999 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4000 "Format of the MIME buttons.
4002 Valid specifiers include:
4004 %T MIME type, along with additional info
4005 %n The `name' parameter
4006 %d The description, if any
4007 %l The length of the encoded part
4008 %p The part identifier number
4009 %e Dots if the part isn't displayed
4011 General format specifiers can also be used. See
4012 (gnus)Formatting Variables.")
4014 (defvar gnus-mime-button-line-format-alist
4015 '((?t gnus-tmp-type ?s)
4016 (?T gnus-tmp-type-long ?s)
4017 (?n gnus-tmp-name ?s)
4018 (?d gnus-tmp-description ?s)
4020 (?l gnus-tmp-length ?d)
4021 (?e gnus-tmp-dots ?s)))
4023 (defvar gnus-mime-button-commands
4024 '((gnus-article-press-button "\r" "Toggle Display")
4025 (gnus-mime-view-part "v" "View Interactively...")
4026 (gnus-mime-view-part-as-type "t" "View As Type...")
4027 (gnus-mime-view-part-as-charset "C" "View As charset...")
4028 (gnus-mime-save-part "o" "Save...")
4029 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4030 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4031 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4032 (gnus-mime-view-part-internally "E" "View Internally")
4033 (gnus-mime-view-part-externally "e" "View Externally")
4034 (gnus-mime-print-part "p" "Print")
4035 (gnus-mime-pipe-part "|" "Pipe To Command...")
4036 (gnus-mime-action-on-part "." "Take action on the part")))
4038 (defun gnus-article-mime-part-status ()
4039 (with-current-buffer gnus-article-buffer
4040 (let ((entity (get-text-property (point-min) 'mime-view-entity))
4043 (setq children (mime-entity-children entity))
4044 (setq children (length children)))
4047 (format " (%d parts)" children))
4050 (defvar gnus-mime-button-map
4051 (let ((map (make-sparse-keymap)))
4052 (unless (>= (string-to-number emacs-version) 21)
4053 ;; XEmacs doesn't care.
4054 (set-keymap-parent map gnus-article-mode-map))
4055 (define-key map gnus-mouse-2 'gnus-article-push-button)
4056 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4057 (dolist (c gnus-mime-button-commands)
4058 (define-key map (cadr c) (car c)))
4061 (defun gnus-mime-button-menu (event)
4062 "Construct a context-sensitive menu of MIME commands."
4064 (save-window-excursion
4065 (let ((pos (event-start event)))
4066 (select-window (posn-window pos))
4067 (goto-char (posn-point pos))
4068 (gnus-article-check-buffer)
4069 (let ((response (x-popup-menu
4071 ("" ,@(mapcar (lambda (c)
4072 (cons (caddr c) (car c)))
4073 gnus-mime-button-commands))))))
4075 (call-interactively response))))))
4077 (defun gnus-mime-view-all-parts (&optional handles)
4078 "View all the MIME parts."
4080 (save-current-buffer
4081 (set-buffer gnus-article-buffer)
4082 (let ((handles (or handles gnus-article-mime-handles))
4083 (mail-parse-charset gnus-newsgroup-charset)
4084 (mail-parse-ignored-charsets
4085 (with-current-buffer gnus-summary-buffer
4086 gnus-newsgroup-ignored-charsets)))
4088 (mm-remove-parts handles)
4089 (goto-char (point-min))
4090 (or (search-forward "\n\n") (goto-char (point-max)))
4091 (let (buffer-read-only)
4092 (delete-region (point) (point-max))
4093 (mm-display-parts handles))))))
4095 (defun gnus-mime-save-part-and-strip ()
4096 "Save the MIME part under point then replace it with an external body."
4098 (gnus-article-check-buffer)
4099 (let* ((data (get-text-property (point) 'gnus-data))
4101 (handles gnus-article-mime-handles))
4102 (if (mm-multiple-handles gnus-article-mime-handles)
4103 (error "This function is not implemented"))
4104 (setq file (and data (mm-save-part data)))
4106 (with-current-buffer (mm-handle-buffer data)
4108 (insert "Content-Type: " (mm-handle-media-type data))
4109 (mml-insert-parameter-string (cdr (mm-handle-type data))
4112 (insert "Content-ID: " (message-make-message-id) "\n")
4113 (insert "Content-Transfer-Encoding: binary\n")
4116 (cdr (mm-make-handle nil
4117 `("message/external-body"
4118 (access-type . "LOCAL-FILE")
4120 (set-buffer gnus-summary-buffer)
4121 (gnus-article-edit-article
4124 (let ((mail-parse-charset (or gnus-article-charset
4125 ',gnus-newsgroup-charset))
4126 (mail-parse-ignored-charsets
4127 (or gnus-article-ignored-charsets
4128 ',gnus-newsgroup-ignored-charsets))
4129 (mbl mml-buffer-list))
4130 (setq mml-buffer-list nil)
4131 (insert-buffer gnus-original-article-buffer)
4132 (mime-to-mml ',handles)
4133 (setq gnus-article-mime-handles nil)
4134 (let ((mbl1 mml-buffer-list))
4135 (setq mml-buffer-list mbl)
4136 (set (make-local-variable 'mml-buffer-list) mbl1))
4137 ;; LOCAL argument of add-hook differs between GNU Emacs
4138 ;; and XEmacs. make-local-hook makes sure they are local.
4139 (make-local-hook 'kill-buffer-hook)
4140 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4141 `(lambda (no-highlight)
4142 (let ((mail-parse-charset (or gnus-article-charset
4143 ',gnus-newsgroup-charset))
4144 (message-options message-options)
4145 (message-options-set-recipient)
4146 (mail-parse-ignored-charsets
4147 (or gnus-article-ignored-charsets
4148 ',gnus-newsgroup-ignored-charsets)))
4150 (mml-destroy-buffers)
4151 (remove-hook 'kill-buffer-hook
4152 'mml-destroy-buffers t)
4153 (kill-local-variable 'mml-buffer-list))
4154 (gnus-summary-edit-article-done
4155 ,(or (mail-header-references gnus-current-headers) "")
4156 ,(gnus-group-read-only-p)
4157 ,gnus-summary-buffer no-highlight))))))
4159 (defun gnus-mime-save-part ()
4160 "Save the MIME part under point."
4162 (gnus-article-check-buffer)
4163 (let ((data (get-text-property (point) 'gnus-data)))
4165 (mm-save-part data))))
4167 (defun gnus-mime-pipe-part ()
4168 "Pipe the MIME part under point to a process."
4170 (gnus-article-check-buffer)
4171 (let ((data (get-text-property (point) 'gnus-data)))
4173 (mm-pipe-part data))))
4175 (defun gnus-mime-view-part ()
4176 "Interactively choose a viewing method for the MIME part under point."
4178 (gnus-article-check-buffer)
4179 (let ((data (get-text-property (point) 'gnus-data)))
4181 (setq gnus-article-mime-handles
4183 gnus-article-mime-handles (setq data (copy-sequence data))))
4184 (mm-interactively-view-part data))))
4186 (defun gnus-mime-view-part-as-type-internal ()
4187 (gnus-article-check-buffer)
4188 (let* ((name (mail-content-type-get
4189 (mm-handle-type (get-text-property (point) 'gnus-data))
4191 (def-type (and name (mm-default-file-encoding name))))
4192 (and def-type (cons def-type 0))))
4194 (defun gnus-mime-view-part-as-type (&optional mime-type)
4195 "Choose a MIME media type, and view the part as such."
4198 (setq mime-type (completing-read
4199 "View as MIME type: "
4200 (mapcar #'list (mailcap-mime-types))
4202 (gnus-mime-view-part-as-type-internal))))
4203 (gnus-article-check-buffer)
4204 (let ((handle (get-text-property (point) 'gnus-data)))
4207 (mm-make-handle (mm-handle-buffer handle)
4208 (cons mime-type (cdr (mm-handle-type handle)))
4209 (mm-handle-encoding handle)
4210 (mm-handle-undisplayer handle)
4211 (mm-handle-disposition handle)
4212 (mm-handle-description handle)
4214 (mm-handle-id handle)))
4215 (setq gnus-article-mime-handles
4216 (mm-merge-handles gnus-article-mime-handles handle))
4217 (gnus-mm-display-part handle))))
4219 (defun gnus-mime-copy-part (&optional handle)
4220 "Put the MIME part under point into a new buffer."
4222 (gnus-article-check-buffer)
4223 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4224 (contents (and handle (mm-get-part handle)))
4226 (file-name-nondirectory
4228 (mail-content-type-get (mm-handle-type handle) 'name)
4229 (mail-content-type-get (mm-handle-type handle)
4232 (buffer (and base (generate-new-buffer base))))
4234 (switch-to-buffer buffer)
4236 ;; We do it this way to make `normal-mode' set the appropriate mode.
4239 (setq buffer-file-name (expand-file-name base))
4241 (setq buffer-file-name nil))
4242 (goto-char (point-min)))))
4244 (defun gnus-mime-print-part (&optional handle filename)
4245 "Print the MIME part under point."
4246 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4247 (gnus-article-check-buffer)
4248 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4249 (contents (and handle (mm-get-part handle)))
4250 (file (make-temp-name (expand-file-name "mm." mm-tmp-directory)))
4251 (printer (mailcap-mime-info (mm-handle-type handle) "print")))
4256 (with-temp-file file
4258 (call-process shell-file-name nil
4259 (generate-new-buffer " *mm*")
4261 shell-command-switch
4263 printer file (mm-handle-type handle))))
4267 (gnus-print-buffer))
4268 (ps-despool filename)))))
4270 (defun gnus-mime-inline-part (&optional handle arg)
4271 "Insert the MIME part under point into the current buffer."
4272 (interactive (list nil current-prefix-arg))
4273 (gnus-article-check-buffer)
4274 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4279 (if (and (not arg) (mm-handle-undisplayer handle))
4280 (mm-remove-part handle)
4281 (setq contents (mm-get-part handle))
4284 (setq charset (or (mail-content-type-get
4285 (mm-handle-type handle) 'charset)
4286 gnus-newsgroup-charset)))
4288 (if (mm-handle-undisplayer handle)
4289 (mm-remove-part handle))
4292 gnus-summary-show-article-charset-alist))
4293 (mm-read-coding-system "Charset: ")))))
4295 (mm-insert-inline handle
4297 (setq charset (mm-charset-to-coding-system
4299 (not (eq charset 'ascii)))
4300 (mm-decode-coding-string contents charset)
4304 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4305 "Insert the MIME part under point into the current buffer using the
4307 (interactive (list nil current-prefix-arg))
4308 (gnus-article-check-buffer)
4309 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4314 (if (mm-handle-undisplayer handle)
4315 (mm-remove-part handle))
4316 (let ((gnus-newsgroup-charset
4318 gnus-summary-show-article-charset-alist))
4319 (mm-read-coding-system "Charset: ")))
4320 (gnus-newsgroup-ignored-charsets 'gnus-all))
4321 (gnus-article-press-button)))))
4323 (defun gnus-mime-view-part-externally (&optional handle)
4324 "View the MIME part under point with an external viewer."
4326 (gnus-article-check-buffer)
4327 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4328 (mm-user-display-methods nil)
4329 (mm-inlined-types nil)
4330 (mail-parse-charset gnus-newsgroup-charset)
4331 (mail-parse-ignored-charsets
4332 (save-excursion (set-buffer gnus-summary-buffer)
4333 gnus-newsgroup-ignored-charsets)))
4335 (if (mm-handle-undisplayer handle)
4336 (mm-remove-part handle)
4337 (mm-display-part handle)))))
4339 (defun gnus-mime-view-part-internally (&optional handle)
4340 "View the MIME part under point with an internal viewer.
4341 If no internal viewer is available, use an external viewer."
4343 (gnus-article-check-buffer)
4344 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4345 (mm-inlined-types '(".*"))
4346 (mm-inline-large-images t)
4347 (mail-parse-charset gnus-newsgroup-charset)
4348 (mail-parse-ignored-charsets
4349 (save-excursion (set-buffer gnus-summary-buffer)
4350 gnus-newsgroup-ignored-charsets)))
4352 (if (mm-handle-undisplayer handle)
4353 (mm-remove-part handle)
4354 (mm-display-part handle)))))
4356 (defun gnus-mime-action-on-part (&optional action)
4357 "Do something with the MIME attachment at \(point\)."
4359 (list (completing-read "Action: " gnus-mime-action-alist)))
4360 (gnus-article-check-buffer)
4361 (let ((action-pair (assoc action gnus-mime-action-alist)))
4363 (funcall (cdr action-pair)))))
4365 (defun gnus-article-part-wrapper (n function)
4366 (save-current-buffer
4367 (set-buffer gnus-article-buffer)
4368 (when (> n (length gnus-article-mime-handle-alist))
4369 (error "No such part"))
4370 (gnus-article-goto-part n)
4371 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4372 (funcall function handle))))
4374 (defun gnus-article-pipe-part (n)
4375 "Pipe MIME part N, which is the numerical prefix."
4377 (gnus-article-part-wrapper n 'mm-pipe-part))
4379 (defun gnus-article-save-part (n)
4380 "Save MIME part N, which is the numerical prefix."
4382 (gnus-article-part-wrapper n 'mm-save-part))
4384 (defun gnus-article-interactively-view-part (n)
4385 "View MIME part N interactively, which is the numerical prefix."
4387 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4389 (defun gnus-article-copy-part (n)
4390 "Copy MIME part N, which is the numerical prefix."
4392 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4394 (defun gnus-article-view-part-as-charset (n)
4395 "Copy MIME part N, which is the numerical prefix."
4397 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4399 (defun gnus-article-view-part-externally (n)
4400 "View MIME part N externally, which is the numerical prefix."
4402 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4404 (defun gnus-article-inline-part (n)
4405 "Inline MIME part N, which is the numerical prefix."
4407 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4409 (defun gnus-article-mime-match-handle-first (condition)
4411 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4412 (while (setq ihandle (pop alist))
4414 ((functionp condition)
4415 (funcall condition (cdr ihandle)))
4416 ((eq condition 'undisplayed)
4417 (not (or (mm-handle-undisplayer (cdr ihandle))
4418 (equal (mm-handle-media-type (cdr ihandle))
4419 "multipart/alternative"))))
4420 ((eq condition 'undisplayed-alternative)
4421 (not (mm-handle-undisplayer (cdr ihandle))))
4423 (gnus-article-goto-part (car ihandle))
4424 (or (not n) (< (car ihandle) n)))
4425 (setq n (car ihandle))))
4429 (defun gnus-article-view-part (&optional n)
4430 "View MIME part N, which is the numerical prefix."
4432 (save-current-buffer
4433 (set-buffer gnus-article-buffer)
4434 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4435 gnus-article-mime-match-handle-function)))
4436 (when (> n (length gnus-article-mime-handle-alist))
4437 (error "No such part"))
4438 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4439 (when (gnus-article-goto-part n)
4440 (if (equal (car handle) "multipart/alternative")
4441 (gnus-article-press-button)
4442 (when (eq (gnus-mm-display-part handle) 'internal)
4443 (gnus-set-window-start)))))))
4445 (defsubst gnus-article-mime-total-parts ()
4446 (if (bufferp (car gnus-article-mime-handles))
4448 (1- (length gnus-article-mime-handles))))
4450 (defun gnus-mm-display-part (handle)
4451 "Display HANDLE and fix MIME button."
4452 (let ((id (get-text-property (point) 'gnus-part))
4457 (let ((window (selected-window))
4458 (mail-parse-charset gnus-newsgroup-charset)
4459 (mail-parse-ignored-charsets
4460 (if (gnus-buffer-live-p gnus-summary-buffer)
4462 (set-buffer gnus-summary-buffer)
4463 gnus-newsgroup-ignored-charsets)
4467 (let ((win (gnus-get-buffer-window (current-buffer) t))
4470 (select-window win))
4473 (if (mm-handle-displayed-p handle)
4474 ;; This will remove the part.
4475 (mm-display-part handle)
4477 (narrow-to-region (point)
4478 (if (eobp) (point) (1+ (point))))
4479 (mm-display-part handle)
4480 ;; We narrow to the part itself and
4481 ;; then call the treatment functions.
4482 (goto-char (point-min))
4484 (narrow-to-region (point) (point-max))
4487 (gnus-article-mime-total-parts)
4488 (mm-handle-media-type handle)))))
4489 (if (window-live-p window)
4490 (select-window window)))))
4492 (delete-region (gnus-point-at-bol) (progn (forward-line 1) (point)))
4493 (gnus-insert-mime-button
4494 handle id (list (mm-handle-displayed-p handle)))
4495 (goto-char point))))
4497 (defun gnus-article-goto-part (n)
4498 "Go to MIME part N."
4499 (let ((point (text-property-any (point-min) (point-max) 'gnus-part n)))
4501 (goto-char point))))
4503 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4504 (let ((gnus-tmp-name
4505 (or (mail-content-type-get (mm-handle-type handle) 'name)
4506 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4507 (mail-content-type-get (mm-handle-type handle) 'url)
4509 (gnus-tmp-type (mm-handle-media-type handle))
4510 (gnus-tmp-description
4511 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4514 (if (if displayed (car displayed)
4515 (mm-handle-displayed-p handle))
4517 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4519 gnus-tmp-type-long b e)
4520 (when (string-match ".*/" gnus-tmp-name)
4521 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4522 (setq gnus-tmp-type-long (concat gnus-tmp-type
4523 (and (not (equal gnus-tmp-name ""))
4524 (concat "; " gnus-tmp-name))))
4525 (unless (equal gnus-tmp-description "")
4526 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4531 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4532 `(,@(gnus-local-map-property gnus-mime-button-map)
4533 gnus-callback gnus-mm-display-part
4534 gnus-part ,gnus-tmp-id
4535 article-type annotation
4538 (widget-convert-button
4541 :action 'gnus-widget-press-button
4542 :button-keymap gnus-mime-button-map
4544 (lambda (widget/window &optional overlay pos)
4545 ;; Needed to properly clear the message due to a bug in
4546 ;; wid-edit (XEmacs only).
4547 (if (boundp 'help-echo-owns-message)
4548 (setq help-echo-owns-message t))
4550 "%S: %s the MIME part; %S: more options"
4551 (aref gnus-mouse-2 0)
4552 ;; XEmacs will get a single widget arg; Emacs 21 will get
4553 ;; window, overlay, position.
4554 (if (mm-handle-displayed-p
4556 (with-current-buffer (gnus-overlay-buffer overlay)
4557 (widget-get (widget-at (gnus-overlay-start overlay))
4559 (widget-get widget/window :mime-handle)))
4561 (aref gnus-down-mouse-3 0))))))
4563 (defun gnus-widget-press-button (elems el)
4564 (goto-char (widget-get elems :from))
4565 (gnus-article-press-button))
4567 (defvar gnus-displaying-mime nil)
4569 (defun gnus-display-mime (&optional ihandles)
4570 "Display the MIME parts."
4572 (save-selected-window
4573 (let ((window (get-buffer-window gnus-article-buffer))
4576 (select-window window)
4577 ;; We have to do this since selecting the window
4578 ;; may change the point. So we set the window point.
4579 (set-window-point window point)))
4580 (let* ((handles (or ihandles (mm-dissect-buffer
4581 nil gnus-article-loose-mime)
4583 buffer-read-only handle name type b e display)
4584 (when (and (not ihandles)
4585 (not gnus-displaying-mime))
4586 ;; Top-level call; we clean up.
4587 (when gnus-article-mime-handles
4588 (mm-destroy-parts gnus-article-mime-handles)
4589 (setq gnus-article-mime-handle-alist nil));; A trick.
4590 (setq gnus-article-mime-handles handles)
4591 ;; We allow users to glean info from the handles.
4592 (when gnus-article-mime-part-function
4593 (gnus-mime-part-function handles)))
4595 (or (not (stringp (car handles)))
4598 (when (and (not ihandles)
4599 (not gnus-displaying-mime))
4600 ;; Clean up for mime parts.
4602 (delete-region (point) (point-max)))
4603 (let ((gnus-displaying-mime t))
4604 (gnus-mime-display-part handles)))
4607 (narrow-to-region (point) (point-max))
4608 (gnus-treat-article nil 1 1)
4611 ;; Highlight the headers.
4615 (narrow-to-region (point-min) (point))
4616 (gnus-treat-article 'head))))))))
4618 (defvar gnus-mime-display-multipart-as-mixed nil)
4619 (defvar gnus-mime-display-multipart-alternative-as-mixed nil)
4620 (defvar gnus-mime-display-multipart-related-as-mixed nil)
4622 (defun gnus-mime-display-part (handle)
4625 ((not (stringp (car handle)))
4626 (gnus-mime-display-single handle))
4627 ;; User-defined multipart
4628 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4629 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4631 ;; multipart/alternative
4632 ((and (equal (car handle) "multipart/alternative")
4633 (not (or gnus-mime-display-multipart-as-mixed
4634 gnus-mime-display-multipart-alternative-as-mixed)))
4635 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4636 (push (cons id handle) gnus-article-mime-handle-alist)
4637 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4638 ;; multipart/related
4639 ((and (equal (car handle) "multipart/related")
4640 (not (or gnus-mime-display-multipart-as-mixed
4641 gnus-mime-display-multipart-related-as-mixed)))
4642 ;;;!!!We should find the start part, but we just default
4643 ;;;!!!to the first part.
4644 ;;(gnus-mime-display-part (cadr handle))
4645 ;;;!!! Most multipart/related is an HTML message plus images.
4646 ;;;!!! Unfortunately we are unable to let W3 display those
4647 ;;;!!! included images, so we just display it as a mixed multipart.
4648 ;;(gnus-mime-display-mixed (cdr handle))
4649 ;;;!!! No, w3 can display everything just fine.
4650 (gnus-mime-display-part (cadr handle)))
4651 ((equal (car handle) "multipart/signed")
4652 (gnus-add-wash-type 'signed)
4653 (gnus-mime-display-security handle))
4654 ((equal (car handle) "multipart/encrypted")
4655 (gnus-add-wash-type 'encrypted)
4656 (gnus-mime-display-security handle))
4657 ;; Other multiparts are handled like multipart/mixed.
4659 (gnus-mime-display-mixed (cdr handle)))))
4661 (defun gnus-mime-part-function (handles)
4662 (if (stringp (car handles))
4663 (mapcar 'gnus-mime-part-function (cdr handles))
4664 (funcall gnus-article-mime-part-function handles)))
4666 (defun gnus-mime-display-mixed (handles)
4667 (mapcar 'gnus-mime-display-part handles))
4669 (defun gnus-mime-display-single (handle)
4670 (let ((type (mm-handle-media-type handle))
4671 (ignored gnus-ignored-mime-types)
4678 (when (string-match (pop ignored) type)
4679 (throw 'ignored nil)))
4680 (if (and (setq not-attachment
4681 (and (not (mm-inline-override-p handle))
4682 (or (not (mm-handle-disposition handle))
4683 (equal (car (mm-handle-disposition handle))
4685 (mm-attachment-override-p handle))))
4686 (mm-automatic-display-p handle)
4688 (mm-inlinable-p handle)
4689 (mm-inlined-p handle))
4690 (mm-automatic-external-display-p type)))
4692 (when (equal (mm-handle-media-supertype handle) "text")
4694 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4696 (push (cons id handle) gnus-article-mime-handle-alist)
4697 (when (or (not display)
4698 (not (gnus-unbuttonized-mime-type-p type)))
4699 ;(gnus-article-insert-newline)
4700 (gnus-insert-mime-button
4701 handle id (list (or display (and not-attachment text))))
4702 (gnus-article-insert-newline)
4703 ;(gnus-article-insert-newline)
4704 ;; Remember modify the number of forward lines.
4712 (let ((mail-parse-charset gnus-newsgroup-charset)
4713 (mail-parse-ignored-charsets
4714 (save-excursion (condition-case ()
4715 (set-buffer gnus-summary-buffer)
4717 gnus-newsgroup-ignored-charsets)))
4718 (mm-display-part handle t))
4719 (goto-char (point-max)))
4720 ((and text not-attachment)
4724 (gnus-article-insert-newline)
4725 (mm-insert-inline handle (mm-get-part handle))
4726 (goto-char (point-max))))
4730 (narrow-to-region beg (point))
4733 (gnus-article-mime-total-parts)
4734 (mm-handle-media-type handle)))))))))
4736 (defun gnus-unbuttonized-mime-type-p (type)
4737 "Say whether TYPE is to be unbuttonized."
4738 (unless gnus-inhibit-mime-unbuttonizing
4740 (let ((types gnus-unbuttonized-mime-types))
4742 (when (string-match (pop types) type)
4743 (throw 'found t)))))
4745 (let ((types gnus-buttonized-mime-types))
4747 (when (string-match (pop types) type)
4748 (throw 'found t)))))))))
4750 (defun gnus-article-insert-newline ()
4751 "Insert a newline, but mark it as undeletable."
4752 (gnus-put-text-property
4753 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4755 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4756 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4759 handle buffer-read-only from props begend not-pref)
4760 (save-window-excursion
4763 (narrow-to-region (car ibegend)
4766 (goto-char (car ibegend))
4769 (delete-region (point-min) (point-max))
4770 (mm-remove-parts handles))
4771 (setq begend (list (point-marker)))
4773 (unless (setq not-pref (cadr (member preferred ihandles)))
4774 (setq not-pref (car ihandles)))
4777 (not (gnus-unbuttonized-mime-type-p
4778 "multipart/alternative")))
4779 (gnus-add-text-properties
4782 (insert (format "%d. " id))
4786 (unless ,(not ibegend)
4787 (setq gnus-article-mime-handle-alist
4788 ',gnus-article-mime-handle-alist))
4789 (gnus-mime-display-alternative
4790 ',ihandles ',not-pref ',begend ,id))
4791 ,@(gnus-local-map-property gnus-mime-button-map)
4792 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4793 face ,gnus-article-button-face
4796 (widget-convert-button 'link from (point)
4797 :action 'gnus-widget-press-button
4798 :button-keymap gnus-widget-button-keymap)
4800 (while (setq handle (pop handles))
4801 (gnus-add-text-properties
4804 (insert (format "(%c) %-18s"
4805 (if (equal handle preferred) ?* ? )
4806 (mm-handle-media-type handle)))
4810 (unless ,(not ibegend)
4811 (setq gnus-article-mime-handle-alist
4812 ',gnus-article-mime-handle-alist))
4813 (gnus-mime-display-alternative
4814 ',ihandles ',handle ',begend ,id))
4815 ,@(gnus-local-map-property gnus-mime-button-map)
4816 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4817 face ,gnus-article-button-face
4820 (widget-convert-button 'link from (point)
4821 :action 'gnus-widget-press-button
4822 :button-keymap gnus-widget-button-keymap)
4826 (if (stringp (car preferred))
4827 (gnus-display-mime preferred)
4828 (let ((mail-parse-charset gnus-newsgroup-charset)
4829 (mail-parse-ignored-charsets
4830 (save-excursion (set-buffer gnus-summary-buffer)
4831 gnus-newsgroup-ignored-charsets)))
4832 (mm-display-part preferred)
4836 (narrow-to-region (car begend) (point-max))
4838 nil (length gnus-article-mime-handle-alist)
4839 (gnus-article-mime-total-parts)
4840 (mm-handle-media-type handle))))))
4841 (goto-char (point-max))
4842 (setcdr begend (point-marker)))))
4844 (goto-char point))))
4846 (defconst gnus-article-wash-status-strings
4847 (let ((alist '((cite "c" "Possible hidden citation text"
4848 " " "All citation text visible")
4849 (headers "h" "Hidden headers"
4850 " " "All headers visible.")
4851 (pgp "p" "Encrypted or signed message status hidden"
4852 " " "No hidden encryption nor digital signature status")
4853 (signature "s" "Signature has been hidden"
4854 " " "Signature is visible")
4855 (overstrike "o" "Overstrike (^H) characters applied"
4856 " " "No overstrike characters applied")
4857 (gnus-show-mime "m" "Mime processing is activated"
4858 " " "Mime processing is not activated")
4859 (emphasis "e" "/*_Emphasis_*/ characters applied"
4860 " " "No /*_emphasis_*/ characters applied")))
4862 (dolist (entry alist result)
4863 (let ((key (nth 0 entry))
4864 (on (copy-sequence (nth 1 entry)))
4865 (on-help (nth 2 entry))
4866 (off (copy-sequence (nth 3 entry)))
4867 (off-help (nth 4 entry)))
4868 (put-text-property 0 1 'help-echo on-help on)
4869 (put-text-property 0 1 'help-echo off-help off)
4870 (push (list key on off) result))))
4871 "Alist of strings describing wash status in the mode line.
4872 Each entry has the form (KEY ON OF), where the KEY is a symbol
4873 representing the particular washing function, ON is the string to use
4874 in the article mode line when the washing function is active, and OFF
4875 is the string to use when it is inactive.")
4877 (defun gnus-article-wash-status-entry (key value)
4878 (let ((entry (assoc key gnus-article-wash-status-strings)))
4879 (if value (nth 1 entry) (nth 2 entry))))
4881 (defun gnus-article-wash-status ()
4882 "Return a string which display status of article washing."
4884 (set-buffer gnus-article-buffer)
4885 (let ((cite (memq 'cite gnus-article-wash-types))
4886 (headers (memq 'headers gnus-article-wash-types))
4887 (boring (memq 'boring-headers gnus-article-wash-types))
4888 (pgp (memq 'pgp gnus-article-wash-types))
4889 (pem (memq 'pem gnus-article-wash-types))
4890 (signed (memq 'signed gnus-article-wash-types))
4891 (encrypted (memq 'encrypted gnus-article-wash-types))
4892 (signature (memq 'signature gnus-article-wash-types))
4893 (overstrike (memq 'overstrike gnus-article-wash-types))
4894 (emphasis (memq 'emphasis gnus-article-wash-types)))
4896 (gnus-article-wash-status-entry 'cite cite)
4897 (gnus-article-wash-status-entry 'headers (or headers boring))
4898 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
4899 (gnus-article-wash-status-entry 'signature signature)
4900 (gnus-article-wash-status-entry 'overstrike overstrike)
4901 (gnus-article-wash-status-entry 'gnus-show-mime gnus-show-mime)
4902 (gnus-article-wash-status-entry 'emphasis emphasis)))))
4904 (defun gnus-add-wash-type (type)
4905 "Add a washing of TYPE to the current status."
4906 (add-to-list 'gnus-article-wash-types type))
4908 (defun gnus-delete-wash-type (type)
4909 "Add a washing of TYPE to the current status."
4910 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
4912 (defun gnus-add-image (category image)
4913 "Add IMAGE of CATEGORY to the list of displayed images."
4914 (let ((entry (assq category gnus-article-image-alist)))
4916 (setq entry (list category))
4917 (push entry gnus-article-image-alist))
4918 (nconc entry (list image))))
4920 (defun gnus-delete-images (category)
4921 "Delete all images in CATEGORY."
4922 (let ((entry (assq category gnus-article-image-alist)))
4923 (dolist (image (cdr entry))
4924 (gnus-remove-image image))
4925 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
4926 (gnus-delete-wash-type category)))
4928 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
4930 (defun gnus-article-maybe-hide-headers ()
4931 "Hide unwanted headers if `gnus-have-all-headers' is nil.
4932 Provided for backwards compatibility."
4933 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
4934 (not (save-excursion (set-buffer gnus-summary-buffer)
4935 gnus-have-all-headers)))
4936 (not gnus-inhibit-hiding))
4937 (gnus-article-hide-headers)))
4941 (defun gnus-output-to-file (file-name)
4942 "Append the current article to a file named FILE-NAME."
4943 (let ((artbuf (current-buffer)))
4945 (insert-buffer-substring artbuf)
4946 ;; Append newline at end of the buffer as separator, and then
4948 (goto-char (point-max))
4950 (let ((file-name-coding-system nnmail-pathname-coding-system)
4951 (pathname-coding-system nnmail-pathname-coding-system))
4952 (write-region-as-binary (point-min) (point-max) file-name 'append))
4955 (defun gnus-narrow-to-page (&optional arg)
4956 "Narrow the article buffer to a page.
4957 If given a numerical ARG, move forward ARG pages."
4959 (setq arg (if arg (prefix-numeric-value arg) 0))
4961 (set-buffer gnus-article-buffer)
4962 (goto-char (point-min))
4964 ;; Remove any old next/prev buttons.
4965 (when (gnus-visual-p 'page-marker)
4966 (let ((buffer-read-only nil))
4967 (gnus-remove-text-with-property 'gnus-prev)
4968 (gnus-remove-text-with-property 'gnus-next)))
4971 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
4973 (re-search-forward page-delimiter nil 'move arg)))
4974 (goto-char (match-end 0)))
4977 (if (re-search-forward page-delimiter nil 'move)
4980 (when (and (gnus-visual-p 'page-marker)
4981 (not (= (point-min) 1)))
4983 (goto-char (point-min))
4984 (gnus-insert-prev-page-button)))
4985 (when (and (gnus-visual-p 'page-marker)
4986 (< (+ (point-max) 2) (buffer-size)))
4988 (goto-char (point-max))
4989 (gnus-insert-next-page-button)))))
4991 ;; Article mode commands
4993 (defun gnus-article-goto-next-page ()
4994 "Show the next page of the article."
4996 (when (gnus-article-next-page)
4997 (goto-char (point-min))
4998 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5000 (defun gnus-article-goto-prev-page ()
5001 "Show the next page of the article."
5003 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5004 (gnus-article-prev-page nil)))
5006 (defun gnus-article-next-page (&optional lines)
5007 "Show the next page of the current article.
5008 If end of article, return non-nil. Otherwise return nil.
5009 Argument LINES specifies lines to be scrolled up."
5011 (let ((start (window-start))
5012 end-of-buffer end-of-page)
5014 (move-to-window-line -1)
5015 (if (<= (point) start)
5018 (setq start (point)))
5021 (unless (or (cond ((eq (1+ (buffer-size)) (point))
5022 (and (pos-visible-in-window-p)
5023 (setq end-of-buffer t)))
5025 (setq end-of-page t)))
5027 (move-to-window-line lines)
5028 (unless (search-backward "\n\n" nil t)
5029 (setq start (point)))))
5030 (cond (end-of-buffer t)
5032 (gnus-narrow-to-page 1)
5036 (set-window-start (selected-window) start)
5037 (let (window-pixel-scroll-increment)
5041 (defun gnus-article-prev-page (&optional lines)
5042 "Show previous page of current article.
5043 Argument LINES specifies lines to be scrolled down."
5045 (let (beginning-of-buffer beginning-of-page)
5047 (move-to-window-line 0)
5048 (cond ((eq 1 (point))
5049 (setq beginning-of-buffer t))
5051 (setq beginning-of-page t))))
5052 (cond (beginning-of-buffer)
5054 (gnus-narrow-to-page -1))
5057 (let (window-pixel-scroll-increment)
5058 (scroll-down lines))
5059 (beginning-of-buffer
5060 (goto-char (point-min))))))))
5062 (defun gnus-article-refer-article ()
5063 "Read article specified by message-id around point."
5065 (let ((point (point)))
5066 (search-forward ">" nil t) ;Move point to end of "<....>".
5067 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
5068 (let ((message-id (match-string 1)))
5070 (set-buffer gnus-summary-buffer)
5071 (gnus-summary-refer-article message-id))
5073 (error "No references around point"))))
5075 (defun gnus-article-show-summary ()
5076 "Reconfigure windows to show summary buffer."
5078 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5079 (error "There is no summary buffer for this article buffer")
5080 (gnus-article-set-globals)
5081 (gnus-configure-windows 'article)
5082 (gnus-summary-goto-subject gnus-current-article)
5083 (gnus-summary-position-point)))
5085 (defun gnus-article-describe-briefly ()
5086 "Describe article mode commands briefly."
5088 (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")))
5090 (defun gnus-article-summary-command ()
5091 "Execute the last keystroke in the summary buffer."
5093 (let ((obuf (current-buffer))
5094 (owin (current-window-configuration))
5096 (switch-to-buffer gnus-article-current-summary 'norecord)
5097 (setq func (lookup-key (current-local-map) (this-command-keys)))
5098 (call-interactively func)
5100 (set-window-configuration owin)
5101 (set-window-point (get-buffer-window (current-buffer)) (point))))
5103 (defun gnus-article-summary-command-nosave ()
5104 "Execute the last keystroke in the summary buffer."
5107 (pop-to-buffer gnus-article-current-summary 'norecord)
5108 (setq func (lookup-key (current-local-map) (this-command-keys)))
5109 (call-interactively func)))
5111 (defun gnus-article-check-buffer ()
5112 "Beep if not in an article buffer."
5113 (unless (eq (get-buffer gnus-article-buffer) (current-buffer))
5114 (error "Command invoked outside of a Gnus article buffer")))
5116 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5117 "Read a summary buffer key sequence and execute it from the article buffer."
5119 (gnus-article-check-buffer)
5121 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5122 "Zc" "ZC" "ZE" "ZJ" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5123 "=" "^" "\M-^" "|"))
5129 '("n" "Gn" "p" "Gp"))
5132 (set-buffer gnus-article-current-summary)
5133 (let (gnus-pick-mode)
5134 (push (or key last-command-event) unread-command-events)
5135 (setq keys (static-if (featurep 'xemacs)
5136 (events-to-keys (read-key-sequence nil))
5137 (read-key-sequence nil)))))
5140 (if (or (member keys nosaves)
5141 (member keys nosave-but-article)
5142 (member keys nosave-in-article))
5144 (save-window-excursion
5145 (pop-to-buffer gnus-article-current-summary 'norecord)
5146 ;; We disable the pick minor mode commands.
5147 (let (gnus-pick-mode)
5148 (setq func (lookup-key (current-local-map) keys))))
5152 (unless (member keys nosave-in-article)
5153 (set-buffer gnus-article-current-summary))
5154 (call-interactively func)
5155 (setq new-sum-point (point)))
5156 (when (member keys nosave-but-article)
5157 (pop-to-buffer gnus-article-buffer 'norecord)))
5158 ;; These commands should restore window configuration.
5159 (let ((obuf (current-buffer))
5160 (owin (current-window-configuration))
5162 (summary gnus-article-current-summary)
5163 func in-buffer selected)
5164 (if not-restore-window
5165 (pop-to-buffer summary 'norecord)
5166 (switch-to-buffer summary 'norecord))
5167 (setq in-buffer (current-buffer))
5168 ;; We disable the pick minor mode commands.
5169 (if (and (setq func (let (gnus-pick-mode)
5170 (lookup-key (current-local-map) keys)))
5173 (call-interactively func)
5174 (setq new-sum-point (point))
5175 (when (eq in-buffer (current-buffer))
5176 (setq selected (gnus-summary-select-article))
5178 (unless not-restore-window
5179 (set-window-configuration owin))
5180 (when (eq selected 'old)
5182 (set-window-start (get-buffer-window (current-buffer))
5184 (set-window-point (get-buffer-window (current-buffer))
5186 (let ((win (get-buffer-window gnus-article-current-summary)))
5188 (set-window-point win new-sum-point)))) )
5189 (switch-to-buffer gnus-article-buffer)
5192 (defun gnus-article-describe-key (key)
5193 "Display documentation of the function invoked by KEY. KEY is a string."
5194 (interactive "kDescribe key: ")
5195 (gnus-article-check-buffer)
5196 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5198 (set-buffer gnus-article-current-summary)
5199 (let (gnus-pick-mode)
5200 (if (featurep 'xemacs)
5202 (push (elt key 0) unread-command-events)
5203 (setq key (events-to-keys
5204 (read-key-sequence "Describe key: "))))
5205 (setq unread-command-events
5207 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5209 (setq key (read-key-sequence "Describe key: "))))
5211 (describe-key key)))
5213 (defun gnus-article-describe-key-briefly (key &optional insert)
5214 "Display documentation of the function invoked by KEY. KEY is a string."
5215 (interactive "kDescribe key: \nP")
5216 (gnus-article-check-buffer)
5217 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5219 (set-buffer gnus-article-current-summary)
5220 (let (gnus-pick-mode)
5221 (if (featurep 'xemacs)
5223 (push (elt key 0) unread-command-events)
5224 (setq key (events-to-keys
5225 (read-key-sequence "Describe key: "))))
5226 (setq unread-command-events
5228 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5230 (setq key (read-key-sequence "Describe key: "))))
5231 (describe-key-briefly key insert))
5232 (describe-key-briefly key insert)))
5234 (defun gnus-article-reply-with-original (&optional wide)
5235 "Start composing a reply mail to the current message.
5236 The text in the region will be yanked. If the region isn't active,
5237 the entire article will be yanked."
5239 (let ((article (cdr gnus-article-current)) cont)
5241 (gnus-summary-reply (list (list article)) wide)
5242 (setq cont (buffer-substring (point) (mark t)))
5243 ;; Deactivate active regions.
5244 (when (and (boundp 'transient-mark-mode)
5245 transient-mark-mode)
5246 (setq mark-active nil))
5248 (list (list article cont)) wide))))
5250 (defun gnus-article-followup-with-original ()
5251 "Compose a followup to the current article.
5252 The text in the region will be yanked. If the region isn't active,
5253 the entire article will be yanked."
5255 (let ((article (cdr gnus-article-current))
5258 (gnus-summary-followup (list (list article)))
5259 (setq cont (buffer-substring (point) (mark t)))
5260 ;; Deactivate active regions.
5261 (when (and (boundp 'transient-mark-mode)
5262 transient-mark-mode)
5263 (setq mark-active nil))
5264 (gnus-summary-followup
5265 (list (list article cont))))))
5267 (defun gnus-article-hide (&optional arg force)
5268 "Hide all the gruft in the current article.
5269 This means that PGP stuff, signatures, cited text and (some)
5270 headers will be hidden.
5271 If given a prefix, show the hidden text instead."
5272 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5273 (gnus-article-hide-headers arg)
5274 (gnus-article-hide-list-identifiers arg)
5275 (gnus-article-hide-pgp arg)
5276 (gnus-article-hide-citation-maybe arg force)
5277 (gnus-article-hide-signature arg))
5279 (defun gnus-article-maybe-highlight ()
5280 "Do some article highlighting if article highlighting is requested."
5281 (when (gnus-visual-p 'article-highlight 'highlight)
5282 (gnus-article-highlight-some)))
5284 (defun gnus-check-group-server ()
5285 ;; Make sure the connection to the server is alive.
5286 (unless (gnus-server-opened
5287 (gnus-find-method-for-group gnus-newsgroup-name))
5288 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5289 (gnus-request-group gnus-newsgroup-name t)))
5292 (autoload 'nneething-get-file-name "nneething"))
5294 (defun gnus-request-article-this-buffer (article group)
5295 "Get an article and insert it into this buffer.
5296 T-gnus change: Insert an article into `gnus-original-article-buffer'."
5297 (let (do-update-line sparse-header)
5298 ;; The current buffer is `gnus-article-buffer'.
5302 (gnus-kill-all-overlays)
5303 (setq group (or group gnus-newsgroup-name))
5305 ;; Using `gnus-request-article' directly will insert the article into
5306 ;; `nntp-server-buffer' - so we'll save some time by not having to
5307 ;; copy it from the server buffer into the article buffer.
5309 ;; We only request an article by message-id when we do not have the
5310 ;; headers for it, so we'll have to get those.
5311 (when (stringp article)
5312 (gnus-read-header article))
5314 ;; If the article number is negative, that means that this article
5315 ;; doesn't belong in this newsgroup (possibly), so we find its
5316 ;; message-id and request it by id instead of number.
5317 (when (and (numberp article)
5319 (get-buffer gnus-summary-buffer)
5320 (gnus-buffer-exists-p gnus-summary-buffer))
5322 (set-buffer gnus-summary-buffer)
5323 (let ((header (gnus-summary-article-header article)))
5326 ((memq article gnus-newsgroup-sparse)
5327 ;; This is a sparse gap article.
5328 (setq do-update-line article)
5329 (setq article (mail-header-id header))
5330 (setq sparse-header (gnus-read-header article))
5331 (setq gnus-newsgroup-sparse
5332 (delq article gnus-newsgroup-sparse)))
5334 ;; It's a real article.
5335 (setq article (mail-header-id header)))
5337 ;; It is an extracted pseudo-article.
5338 (setq article 'pseudo)
5339 (gnus-request-pseudo-article header))))
5341 (let ((method (gnus-find-method-for-group
5342 gnus-newsgroup-name)))
5343 (when (and (eq (car method) 'nneething)
5345 (let ((dir (nneething-get-file-name
5346 (mail-header-id header))))
5347 (when (and (stringp dir)
5348 (file-directory-p dir))
5349 (setq article 'nneething)
5350 (gnus-group-enter-directory dir))))))))
5351 (setq gnus-original-article (cons group article))
5353 ;; The current buffer is `gnus-original-article-buffer'.
5354 (if (get-buffer gnus-original-article-buffer)
5355 (set-buffer gnus-original-article-buffer)
5356 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5357 (set-buffer-multibyte nil)
5358 (buffer-disable-undo)
5359 (setq major-mode 'gnus-original-article-mode)
5360 (setq buffer-read-only nil))
5363 ;; Refuse to select canceled articles.
5364 ((and (numberp article)
5366 (get-buffer gnus-summary-buffer)
5367 (gnus-buffer-exists-p gnus-summary-buffer)
5368 (eq (cdr (save-excursion
5369 (set-buffer gnus-summary-buffer)
5370 (assq article gnus-newsgroup-reads)))
5371 gnus-canceled-mark))
5373 ;; Check the backlog.
5374 ((and gnus-keep-backlog
5375 (gnus-backlog-request-article group article (current-buffer)))
5377 ;; Check asynchronous pre-fetch.
5378 ((gnus-async-request-fetched-article group article (current-buffer))
5379 (gnus-async-prefetch-next group article gnus-summary-buffer)
5380 (when (and (numberp article) gnus-keep-backlog)
5381 (gnus-backlog-enter-article group article (current-buffer)))
5384 ((and gnus-use-cache
5386 (gnus-cache-request-article article group))
5388 ;; Check the agent cache.
5389 ((and gnus-agent gnus-agent-cache gnus-plugged
5391 (gnus-agent-request-article article group))
5393 ;; Get the article and put into the article buffer.
5394 ((or (stringp article)
5396 (let ((gnus-override-method gnus-override-method)
5397 (methods (and (stringp article)
5398 gnus-refer-article-method))
5400 (buffer-read-only nil))
5401 (if (or (not (listp methods))
5402 (and (symbolp (car methods))
5403 (assq (car methods) nnoo-definition-alist)))
5404 (setq methods (list methods)))
5405 (when (and (null gnus-override-method)
5407 (setq gnus-override-method (pop methods)))
5409 (when (eq gnus-override-method 'current)
5410 (setq gnus-override-method
5411 (with-current-buffer gnus-summary-buffer
5412 gnus-current-select-method)))
5414 (gnus-kill-all-overlays)
5415 (let ((gnus-newsgroup-name group))
5416 (gnus-check-group-server))
5417 (when (gnus-request-article article group (current-buffer))
5418 (when (numberp article)
5419 (gnus-async-prefetch-next group article
5420 gnus-summary-buffer)
5421 (when gnus-keep-backlog
5422 (gnus-backlog-enter-article
5423 group article (current-buffer))))
5424 (setq result 'article))
5427 (setq gnus-override-method (pop methods))
5428 (setq result 'done))))
5429 (and (eq result 'article) 'article)))
5433 ;; Associate this article with the current summary buffer.
5434 (setq gnus-article-current-summary gnus-summary-buffer)
5436 ;; Copy the requested article from `gnus-original-article-buffer'.
5437 (unless (equal (buffer-name (current-buffer))
5438 (buffer-name (get-buffer gnus-original-article-buffer)))
5439 ;; There may be the same article if the current buffer is
5440 ;; `nntp-server-buffer' (e.g. a case that the command
5441 ;; `gnus-cache-enter-article' is invoked), it should be erased.
5443 (insert-buffer gnus-original-article-buffer))
5446 (run-hooks 'gnus-article-decode-hook)
5447 ;; Mark article as decoded or not.
5448 (setq gnus-article-decoded-p gnus-article-decode-hook)
5450 ;; Update sparse articles.
5451 (when (and do-update-line
5452 (or (numberp article)
5454 (let ((buf (current-buffer)))
5455 (set-buffer gnus-summary-buffer)
5456 (gnus-summary-update-article do-update-line sparse-header)
5457 (gnus-summary-goto-subject do-update-line nil t)
5458 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5460 (set-buffer buf))))))
5466 (defcustom gnus-article-edit-mode-hook nil
5467 "Hook run in article edit mode buffers."
5468 :group 'gnus-article-various
5471 (defcustom gnus-article-edit-article-setup-function
5472 'gnus-article-mime-edit-article-setup
5473 "Function called to setup an editing article buffer."
5474 :group 'gnus-article-various
5477 (defvar gnus-article-edit-done-function nil)
5479 (defvar gnus-article-edit-mode-map nil)
5481 ;; Should we be using derived.el for this?
5482 (unless gnus-article-edit-mode-map
5483 (setq gnus-article-edit-mode-map (make-keymap))
5484 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5486 (gnus-define-keys gnus-article-edit-mode-map
5487 "\C-c?" describe-mode
5488 "\C-c\C-c" gnus-article-edit-done
5489 "\C-c\C-k" gnus-article-edit-exit
5490 "\C-c\C-f\C-t" message-goto-to
5491 "\C-c\C-f\C-o" message-goto-from
5492 "\C-c\C-f\C-b" message-goto-bcc
5493 ;;"\C-c\C-f\C-w" message-goto-fcc
5494 "\C-c\C-f\C-c" message-goto-cc
5495 "\C-c\C-f\C-s" message-goto-subject
5496 "\C-c\C-f\C-r" message-goto-reply-to
5497 "\C-c\C-f\C-n" message-goto-newsgroups
5498 "\C-c\C-f\C-d" message-goto-distribution
5499 "\C-c\C-f\C-f" message-goto-followup-to
5500 "\C-c\C-f\C-m" message-goto-mail-followup-to
5501 "\C-c\C-f\C-k" message-goto-keywords
5502 "\C-c\C-f\C-u" message-goto-summary
5503 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5504 "\C-c\C-f\C-a" message-gen-unsubscribed-mft
5505 "\C-c\C-b" message-goto-body
5506 "\C-c\C-i" message-goto-signature
5508 "\C-c\C-t" message-insert-to
5509 "\C-c\C-n" message-insert-newsgroups
5510 "\C-c\C-o" message-sort-headers
5511 "\C-c\C-e" message-elide-region
5512 "\C-c\C-v" message-delete-not-region
5513 "\C-c\C-z" message-kill-to-signature
5514 "\M-\r" message-newline-and-reformat
5515 "\C-c\C-a" mml-attach-file
5516 "\C-a" message-beginning-of-line
5518 "\M-;" comment-region)
5520 (gnus-define-keys (gnus-article-edit-wash-map
5521 "\C-c\C-w" gnus-article-edit-mode-map)
5522 "f" gnus-article-edit-full-stops))
5525 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5527 ["Fetch To" message-insert-to t]
5528 ["Fetch Newsgroups" message-insert-newsgroups t]
5530 ["To" message-goto-to t]
5531 ["From" message-goto-from t]
5532 ["Subject" message-goto-subject t]
5533 ["Cc" message-goto-cc t]
5534 ["Reply-To" message-goto-reply-to t]
5535 ["Summary" message-goto-summary t]
5536 ["Keywords" message-goto-keywords t]
5537 ["Newsgroups" message-goto-newsgroups t]
5538 ["Followup-To" message-goto-followup-to t]
5539 ["Mail-Followup-To" message-goto-mail-followup-to t]
5540 ["Distribution" message-goto-distribution t]
5541 ["Body" message-goto-body t]
5542 ["Signature" message-goto-signature t]))
5544 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
5545 "Major mode for editing articles.
5546 This is an extended text-mode.
5548 \\{gnus-article-edit-mode-map}"
5549 (make-local-variable 'gnus-article-edit-done-function)
5550 (make-local-variable 'gnus-prev-winconf)
5551 (set (make-local-variable 'font-lock-defaults)
5552 '(message-font-lock-keywords t))
5553 (set (make-local-variable 'mail-header-separator) "")
5554 (easy-menu-add message-mode-field-menu message-mode-map)
5556 (setq buffer-read-only nil)
5557 (buffer-enable-undo)
5560 (defun gnus-article-edit (&optional force)
5561 "Edit the current article.
5562 This will have permanent effect only in mail groups.
5563 If FORCE is non-nil, allow editing of articles even in read-only
5566 (when (and (not force)
5567 (gnus-group-read-only-p))
5568 (error "The current newsgroup does not support article editing"))
5569 (gnus-article-date-original)
5570 (gnus-article-edit-article
5572 `(lambda (no-highlight)
5574 (gnus-summary-edit-article-done
5575 ,(or (mail-header-references gnus-current-headers) "")
5576 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5578 (defun gnus-article-edit-article (start-func exit-func)
5579 "Start editing the contents of the current article buffer."
5580 (let ((winconf (current-window-configuration)))
5581 (set-buffer gnus-article-buffer)
5582 (gnus-article-edit-mode)
5583 (funcall start-func)
5584 (set-buffer-modified-p nil)
5585 (gnus-configure-windows 'edit-article)
5586 (setq gnus-article-edit-done-function exit-func)
5587 (setq gnus-prev-winconf winconf)
5588 (when gnus-article-edit-article-setup-function
5589 (funcall gnus-article-edit-article-setup-function))
5590 (gnus-message 6 "C-c C-c to end edits; C-c C-k to exit")))
5592 (defun gnus-article-edit-done (&optional arg)
5593 "Update the article edits and exit."
5595 (let ((func gnus-article-edit-done-function)
5596 (buf (current-buffer))
5597 (start (window-start))
5599 (winconf gnus-prev-winconf))
5600 (remove-hook 'gnus-article-mode-hook
5601 'gnus-article-mime-edit-article-unwind)
5602 (widen) ;; Widen it in case that users narrowed the buffer.
5605 ;; The cache and backlog have to be flushed somewhat.
5606 (when gnus-keep-backlog
5607 (gnus-backlog-remove-article
5608 (car gnus-article-current) (cdr gnus-article-current)))
5609 ;; Flush original article as well.
5611 (when (get-buffer gnus-original-article-buffer)
5612 (set-buffer gnus-original-article-buffer)
5613 (setq gnus-original-article nil)))
5614 (when gnus-use-cache
5615 (gnus-cache-update-article
5616 (car gnus-article-current) (cdr gnus-article-current)))
5617 ;; We remove all text props from the article buffer.
5618 (kill-all-local-variables)
5619 (gnus-set-text-properties (point-min) (point-max) nil)
5621 (set-window-configuration winconf)
5623 (set-window-start (get-buffer-window buf) start)
5624 (set-window-point (get-buffer-window buf) (point))))
5626 (defun gnus-article-edit-exit ()
5627 "Exit the article editing without updating."
5629 (when (or (not (buffer-modified-p))
5630 (yes-or-no-p "Article modified; kill anyway? "))
5631 (let ((curbuf (current-buffer))
5633 (window-start (window-start)))
5635 (if (gnus-buffer-live-p gnus-original-article-buffer)
5636 (insert-buffer gnus-original-article-buffer))
5637 (let ((winconf gnus-prev-winconf))
5639 (set-window-configuration winconf)
5640 ;; Tippy-toe some to make sure that point remains where it was.
5641 (save-current-buffer
5643 (set-window-start (get-buffer-window (current-buffer)) window-start)
5646 (defun gnus-article-edit-full-stops ()
5647 "Interactively repair spacing at end of sentences."
5650 (goto-char (point-min))
5651 (search-forward-regexp "^$" nil t)
5652 (let ((case-fold-search nil))
5653 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5656 ;;; Article editing with MIME-Edit
5659 (defcustom gnus-article-mime-edit-article-setup-hook nil
5660 "Hook run after setting up a MIME editing article buffer."
5661 :group 'gnus-article-various
5664 (defun gnus-article-mime-edit-article-unwind ()
5665 "Unwind `gnus-article-buffer' if article editing was given up."
5666 (remove-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
5667 (when (featurep 'font-lock)
5668 (setq font-lock-defaults nil)
5669 (font-lock-mode -1))
5670 (when mime-edit-mode-flag
5671 (mime-edit-exit 'nomime 'no-error)
5674 (defun gnus-article-mime-edit-article-setup ()
5675 "Convert current buffer to MIME-Edit buffer and turn on MIME-Edit mode
5676 after replacing with the original article."
5677 (setq gnus-show-mime t)
5678 (setq gnus-article-edit-done-function
5679 `(lambda (&rest args)
5680 (when mime-edit-mode-flag
5681 (let (mime-edit-insert-user-agent-field)
5684 (goto-char (point-min))
5685 (let (case-fold-search)
5686 (when (re-search-forward
5687 (format "^%s$" (regexp-quote mail-header-separator))
5689 (replace-match "")))
5690 (apply ,gnus-article-edit-done-function args)
5693 (buffer-substring-no-properties (point-min) (point-max))
5694 (set-buffer (get-buffer-create gnus-original-article-buffer))
5696 (setq gnus-current-headers (gnus-article-make-full-mail-header))
5697 (set-buffer gnus-article-buffer)
5698 (gnus-article-prepare-display)))
5699 (substitute-key-definition 'gnus-article-edit-done
5700 'gnus-article-mime-edit-done
5701 gnus-article-edit-mode-map)
5702 (substitute-key-definition 'gnus-article-edit-exit
5703 'gnus-article-mime-edit-exit
5704 gnus-article-edit-mode-map)
5706 (insert-buffer gnus-original-article-buffer)
5707 (let ((ofn (symbol-function 'mime-edit-decode-single-part-in-buffer)))
5708 (fset 'mime-edit-decode-single-part-in-buffer
5709 (lambda (&rest args)
5710 (if (let ((content-type (car args)))
5711 (and (eq 'message (mime-content-type-primary-type
5713 (eq 'rfc822 (mime-content-type-subtype content-type))))
5714 (setcar (cdr args) 'not-decode-text))
5718 (fset 'mime-edit-decode-single-part-in-buffer ofn)))
5719 (when (featurep 'font-lock)
5720 (set (make-local-variable 'font-lock-defaults)
5721 '(message-font-lock-keywords t))
5722 (font-lock-set-defaults)
5723 (turn-on-font-lock))
5724 (set-buffer-modified-p nil)
5725 (delete-other-windows)
5726 (add-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
5727 (gnus-run-hooks 'gnus-article-mime-edit-article-setup-hook))
5729 (defun gnus-article-mime-edit-done (&optional arg)
5730 "Update the article MIME edits and exit."
5732 (when (featurep 'font-lock)
5733 (setq font-lock-defaults nil)
5734 (font-lock-mode -1))
5735 (gnus-article-edit-done arg))
5737 (defun gnus-article-mime-edit-exit ()
5738 "Exit the article MIME editing without updating."
5740 (when (or (not (buffer-modified-p))
5741 (yes-or-no-p "Article modified; kill anyway? "))
5742 (when (featurep 'font-lock)
5743 (setq font-lock-defaults nil)
5744 (font-lock-mode -1))
5745 (when mime-edit-mode-flag
5746 (let (mime-edit-insert-user-agent-field)
5749 (goto-char (point-min))
5750 (let (case-fold-search)
5751 (when (re-search-forward
5752 (format "^%s$" (regexp-quote mail-header-separator)) nil t)
5753 (replace-match "")))
5754 (let ((winconf gnus-prev-winconf))
5756 (buffer-substring-no-properties (point-min) (point-max))
5757 (set-buffer (get-buffer-create gnus-original-article-buffer))
5759 (setq gnus-current-headers (gnus-article-make-full-mail-header))
5760 (set-buffer gnus-article-buffer)
5761 (gnus-article-prepare-display)
5762 (set-window-configuration winconf))))
5765 ;;; Article highlights
5768 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5770 ;;; Internal Variables:
5772 (defcustom gnus-button-url-regexp "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-zA-Z0-9_.]+:[0-9]*\\)?\\([-a-zA-Z0-9_=!?#$@~`%&*+|\\/:;.,]\\|\\w\\)+\\([-a-zA-Z0-9_=#$@~`%&*+|\\/]\\|\\w\\)\\)"
5773 "Regular expression that matches URLs."
5774 :group 'gnus-article-buttons
5777 (defcustom gnus-button-alist
5778 `(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
5779 0 t gnus-button-handle-news 3)
5780 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
5781 gnus-button-handle-news 2)
5782 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
5784 gnus-button-fetch-group 4)
5785 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
5786 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
5787 t gnus-button-message-id 3)
5788 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
5789 ("mailto:\\([-a-zA-Z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
5790 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
5792 ("\\binfo:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t
5793 gnus-button-handle-info 2)
5794 ;; This is how URLs _should_ be embedded in text...
5795 ("<URL: *\\([^<>]*\\)>" 1 t gnus-button-embedded-url 1)
5797 (,gnus-button-url-regexp 0 t browse-url 0))
5798 "*Alist of regexps matching buttons in article bodies.
5800 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
5801 REGEXP: is the string matching text around the button,
5802 BUTTON: is the number of the regexp grouping actually matching the button,
5803 FORM: is a lisp expression which must eval to true for the button to
5805 CALLBACK: is the function to call when the user push this button, and each
5806 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
5808 CALLBACK can also be a variable, in that case the value of that
5809 variable it the real callback function."
5810 :group 'gnus-article-buttons
5811 :type '(repeat (list regexp
5812 (integer :tag "Button")
5814 (function :tag "Callback")
5817 (integer :tag "Regexp group")))))
5819 (defcustom gnus-header-button-alist
5820 `(("^\\(References\\|Message-I[Dd]\\):" "<[^<>]+>"
5821 0 t gnus-button-message-id 0)
5822 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
5823 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
5824 0 t gnus-button-mailto 0)
5825 ("^X-[Uu][Rr][Ll]:" ,gnus-button-url-regexp 0 t browse-url 0)
5826 ("^Subject:" ,gnus-button-url-regexp 0 t browse-url 0)
5827 ("^[^:]+:" ,gnus-button-url-regexp 0 t browse-url 0)
5828 ("^[^:]+:" "\\bmailto:\\([-a-zA-Z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
5829 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
5830 gnus-button-message-id 3))
5831 "*Alist of headers and regexps to match buttons in article heads.
5833 This alist is very similar to `gnus-button-alist', except that each
5834 alist has an additional HEADER element first in each entry:
5836 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
5838 HEADER is a regexp to match a header. For a fuller explanation, see
5839 `gnus-button-alist'."
5840 :group 'gnus-article-buttons
5841 :group 'gnus-article-headers
5842 :type '(repeat (list (regexp :tag "Header")
5844 (integer :tag "Button")
5846 (function :tag "Callback")
5849 (integer :tag "Regexp group")))))
5851 (defvar gnus-button-regexp nil)
5852 (defvar gnus-button-marker-list nil)
5853 ;; Regexp matching any of the regexps from `gnus-button-alist'.
5855 (defvar gnus-button-last nil)
5856 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
5860 (defun gnus-article-push-button (event)
5861 "Check text under the mouse pointer for a callback function.
5862 If the text under the mouse pointer has a `gnus-callback' property,
5863 call it with the value of the `gnus-data' text property."
5865 (set-buffer (window-buffer (posn-window (event-start event))))
5866 (let* ((pos (posn-point (event-start event)))
5867 (data (get-text-property pos 'gnus-data))
5868 (fun (get-text-property pos 'gnus-callback)))
5871 (funcall fun data))))
5873 (defun gnus-article-press-button ()
5874 "Check text at point for a callback function.
5875 If the text at point has a `gnus-callback' property,
5876 call it with the value of the `gnus-data' text property."
5878 (let* ((data (get-text-property (point) 'gnus-data))
5879 (fun (get-text-property (point) 'gnus-callback)))
5881 (funcall fun data))))
5883 (defun gnus-article-prev-button (n)
5884 "Move point to N buttons backward.
5885 If N is negative, move forward instead."
5887 (gnus-article-next-button (- n)))
5889 (defun gnus-article-next-button (n)
5890 "Move point to N buttons forward.
5891 If N is negative, move backward instead."
5893 (let ((function (if (< n 0) 'previous-single-property-change
5894 'next-single-property-change))
5895 (inhibit-point-motion-hooks t)
5897 (limit (if (< n 0) (point-min) (point-max))))
5899 (while (and (not (= limit (point)))
5901 ;; Skip past the current button.
5902 (when (get-text-property (point) 'gnus-callback)
5903 (goto-char (funcall function (point) 'gnus-callback nil limit)))
5904 ;; Go to the next (or previous) button.
5905 (gnus-goto-char (funcall function (point) 'gnus-callback nil limit))
5906 ;; Put point at the start of the button.
5907 (when (and backward (not (get-text-property (point) 'gnus-callback)))
5908 (goto-char (funcall function (point) 'gnus-callback nil limit)))
5909 ;; Skip past intangible buttons.
5910 (when (get-text-property (point) 'intangible)
5914 (gnus-message 5 "No more buttons"))
5917 (defun gnus-article-highlight (&optional force)
5918 "Highlight current article.
5919 This function calls `gnus-article-highlight-headers',
5920 `gnus-article-highlight-citation',
5921 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
5922 do the highlighting. See the documentation for those functions."
5923 (interactive (list 'force))
5924 (gnus-article-highlight-headers)
5925 (gnus-article-highlight-citation force)
5926 (gnus-article-highlight-signature)
5927 (gnus-article-add-buttons force)
5928 (gnus-article-add-buttons-to-head))
5930 (defun gnus-article-highlight-some (&optional force)
5931 "Highlight current article.
5932 This function calls `gnus-article-highlight-headers',
5933 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
5934 do the highlighting. See the documentation for those functions."
5935 (interactive (list 'force))
5936 (gnus-article-highlight-headers)
5937 (gnus-article-highlight-signature)
5938 (gnus-article-add-buttons))
5940 (defun gnus-article-highlight-headers ()
5941 "Highlight article headers as specified by `gnus-header-face-alist'."
5944 (set-buffer gnus-article-buffer)
5946 (let ((alist gnus-header-face-alist)
5947 (buffer-read-only nil)
5948 (case-fold-search t)
5949 (inhibit-point-motion-hooks t)
5950 entry regexp header-face field-face from hpoints fpoints)
5951 (article-narrow-to-head)
5952 (while (setq entry (pop alist))
5953 (goto-char (point-min))
5954 (setq regexp (concat "^\\("
5955 (if (string-equal "" (nth 0 entry))
5959 header-face (nth 1 entry)
5960 field-face (nth 2 entry))
5961 (while (and (re-search-forward regexp nil t)
5965 (unless (search-forward ":" nil t)
5967 (when (and header-face
5968 (not (memq (point) hpoints)))
5969 (push (point) hpoints)
5970 (gnus-put-text-property from (point) 'face header-face))
5971 (when (and field-face
5972 (not (memq (setq from (point)) fpoints)))
5974 (if (re-search-forward "^[^ \t]" nil t)
5976 (goto-char (point-max)))
5977 (gnus-put-text-property from (point) 'face field-face))))))))
5979 (defun gnus-article-highlight-signature ()
5980 "Highlight the signature in an article.
5981 It does this by highlighting everything after
5982 `gnus-signature-separator' using `gnus-signature-face'."
5984 (when gnus-signature-face
5986 (set-buffer gnus-article-buffer)
5987 (let ((buffer-read-only nil)
5988 (inhibit-point-motion-hooks t))
5990 (when (gnus-article-narrow-to-signature)
5991 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
5992 'face gnus-signature-face)))))))
5994 (defun gnus-article-buttonize-signature ()
5995 "Add button to the signature."
5998 (set-buffer gnus-article-buffer)
5999 (let ((buffer-read-only nil)
6000 (inhibit-point-motion-hooks t))
6001 (when (gnus-article-search-signature)
6002 (gnus-article-add-button (match-beginning 0) (match-end 0)
6003 'gnus-signature-toggle
6004 (set-marker (make-marker)
6005 (1+ (match-end 0))))))))
6007 (defun gnus-button-in-region-p (b e prop)
6008 "Say whether PROP exists in the region."
6009 (text-property-not-all b e prop nil))
6011 (defun gnus-article-add-buttons (&optional force)
6012 "Find external references in the article and make buttons of them.
6013 \"External references\" are things like Message-IDs and URLs, as
6014 specified by `gnus-button-alist'."
6015 (interactive (list 'force))
6017 (set-buffer gnus-article-buffer)
6018 (let ((buffer-read-only nil)
6019 (inhibit-point-motion-hooks t)
6020 (case-fold-search t)
6021 (alist gnus-button-alist)
6023 ;; Remove all old markers.
6024 (let (marker entry new-list)
6025 (while (setq marker (pop gnus-button-marker-list))
6026 (if (or (< marker (point-min)) (>= marker (point-max)))
6027 (push marker new-list)
6029 (when (setq entry (gnus-button-entry))
6030 (put-text-property (match-beginning (nth 1 entry))
6031 (match-end (nth 1 entry))
6032 'gnus-callback nil))
6033 (set-marker marker nil)))
6034 (setq gnus-button-marker-list new-list))
6035 ;; We skip the headers.
6038 (while (setq entry (pop alist))
6039 (setq regexp (car entry))
6041 (while (re-search-forward regexp nil t)
6042 (let* ((start (and entry (match-beginning (nth 1 entry))))
6043 (end (and entry (match-end (nth 1 entry))))
6044 (from (match-beginning 0)))
6045 (when (and (or (eq t (nth 2 entry))
6046 (eval (nth 2 entry)))
6047 (not (gnus-button-in-region-p
6048 start end 'gnus-callback)))
6049 ;; That optional form returned non-nil, so we add the
6051 (gnus-article-add-button
6052 start end 'gnus-button-push
6053 (car (push (set-marker (make-marker) from)
6054 gnus-button-marker-list))))))))))
6056 ;; Add buttons to the head of an article.
6057 (defun gnus-article-add-buttons-to-head ()
6058 "Add buttons to the head of the article."
6061 (set-buffer gnus-article-buffer)
6063 (let ((buffer-read-only nil)
6064 (inhibit-point-motion-hooks t)
6065 (case-fold-search t)
6066 (alist gnus-header-button-alist)
6068 (article-narrow-to-head)
6070 ;; Each alist entry.
6071 (setq entry (car alist)
6073 (goto-char (point-min))
6074 (while (re-search-forward (car entry) nil t)
6075 ;; Each header matching the entry.
6076 (setq beg (match-beginning 0))
6077 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6078 (match-beginning 0))
6081 (while (re-search-forward (nth 1 entry) end t)
6082 ;; Each match within a header.
6083 (let* ((entry (cdr entry))
6084 (start (match-beginning (nth 1 entry)))
6085 (end (match-end (nth 1 entry)))
6086 (form (nth 2 entry)))
6087 (goto-char (match-end 0))
6089 (gnus-article-add-button
6090 start end (nth 3 entry)
6091 (buffer-substring (match-beginning (nth 4 entry))
6092 (match-end (nth 4 entry)))))))
6093 (goto-char end)))))))
6095 ;;; External functions:
6097 (defun gnus-article-add-button (from to fun &optional data)
6098 "Create a button between FROM and TO with callback FUN and data DATA."
6099 (when gnus-article-button-face
6100 (gnus-overlay-put (gnus-make-overlay from to)
6101 'face gnus-article-button-face))
6102 (gnus-add-text-properties
6104 (nconc (and gnus-article-mouse-face
6105 (list gnus-mouse-face-prop gnus-article-mouse-face))
6106 (list 'gnus-callback fun)
6107 (and data (list 'gnus-data data))))
6108 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6109 ;; Quote `:button-keymap' for Mule 2.3
6110 ;; but it won't work.
6111 ':button-keymap gnus-widget-button-keymap))
6113 ;;; Internal functions:
6115 (defun gnus-article-set-globals ()
6117 (set-buffer gnus-summary-buffer)
6118 (gnus-set-global-variables)))
6120 (defun gnus-signature-toggle (end)
6122 (set-buffer gnus-article-buffer)
6123 (let ((buffer-read-only nil)
6124 (inhibit-point-motion-hooks t)
6125 (limit (next-single-property-change end 'mime-view-entity
6127 (if (text-property-any end limit 'article-type 'signature)
6129 (gnus-delete-wash-type 'signature)
6130 (gnus-remove-text-properties-when
6131 'article-type 'signature end limit
6132 (cons 'article-type (cons 'signature
6133 gnus-hidden-properties))))
6134 (gnus-add-wash-type 'signature)
6135 (gnus-add-text-properties-when
6136 'article-type nil end limit
6137 (cons 'article-type (cons 'signature
6138 gnus-hidden-properties)))))
6139 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6140 (gnus-set-mode-line 'article))))
6142 (defun gnus-button-entry ()
6143 ;; Return the first entry in `gnus-button-alist' matching this place.
6144 (let ((alist gnus-button-alist)
6147 (setq entry (pop alist))
6148 (if (looking-at (car entry))
6153 (defun gnus-button-push (marker)
6154 ;; Push button starting at MARKER.
6157 (let* ((entry (gnus-button-entry))
6158 (inhibit-point-motion-hooks t)
6160 (args (mapcar (lambda (group)
6161 (let ((string (match-string group)))
6162 (gnus-set-text-properties
6163 0 (length string) nil string)
6170 (fboundp (symbol-value fun)))
6171 (apply (symbol-value fun) args))
6173 (gnus-message 1 "You must define `%S' to use this button"
6174 (cons fun args)))))))
6176 (defun gnus-parse-news-url (url)
6177 (let (scheme server group message-id articles)
6180 (goto-char (point-min))
6181 (when (looking-at "\\([A-Za-z]+\\):")
6182 (setq scheme (match-string 1))
6183 (goto-char (match-end 0)))
6184 (when (looking-at "//\\([^/]+\\)/")
6185 (setq server (match-string 1))
6186 (goto-char (match-end 0)))
6189 ((looking-at "\\(.*@.*\\)")
6190 (setq message-id (match-string 1)))
6191 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
6192 (setq group (match-string 1)
6193 articles (split-string (match-string 2) "-")))
6194 ((looking-at "\\([^/]+\\)/?")
6195 (setq group (match-string 1)))
6197 (error "Unknown news URL syntax"))))
6198 (list scheme server group message-id articles)))
6200 (defun gnus-button-handle-news (url)
6202 (destructuring-bind (scheme server group message-id articles)
6203 (gnus-parse-news-url url)
6207 (set-buffer gnus-summary-buffer)
6209 (let ((gnus-refer-article-method (list (list 'nntp server))))
6210 (gnus-summary-refer-article message-id))
6211 (gnus-summary-refer-article message-id))))
6213 (gnus-button-fetch-group url)))))
6215 (defun gnus-button-handle-info (url)
6216 "Fetch an info URL."
6218 "^\\([^:/]+\\)?/\\(.*\\)"
6220 (gnus-info-find-node
6221 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
6224 (gnus-url-unhex-string (match-string 2 url))))
6225 (error "Can't parse %s" url)))
6227 (defun gnus-button-message-id (message-id)
6230 (set-buffer gnus-summary-buffer)
6231 (gnus-summary-refer-article message-id)))
6233 (defun gnus-button-fetch-group (address)
6234 "Fetch GROUP specified by ADDRESS."
6235 (if (not (string-match "[:/]" address))
6236 ;; This is just a simple group url.
6237 (gnus-group-read-ephemeral-group address gnus-select-method)
6240 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
6242 (error "Can't parse %s" address)
6243 (gnus-group-read-ephemeral-group
6244 (match-string 4 address)
6245 `(nntp ,(match-string 1 address)
6246 (nntp-address ,(match-string 1 address))
6247 (nntp-port-number ,(if (match-end 3)
6248 (match-string 3 address)
6251 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
6253 (defun gnus-url-parse-query-string (query &optional downcase)
6254 (let (retval pairs cur key val)
6255 (setq pairs (split-string query "&"))
6257 (setq cur (car pairs)
6259 (if (not (string-match "=" cur))
6261 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
6262 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
6264 (setq key (downcase key)))
6265 (setq cur (assoc key retval))
6267 (setcdr cur (cons val (cdr cur)))
6268 (setq retval (cons (list key val) retval)))))
6271 (defun gnus-url-mailto (url)
6272 ;; Send mail to someone
6273 (when (string-match "mailto:/*\\(.*\\)" url)
6274 (setq url (substring url (match-beginning 1) nil)))
6275 (let (to args subject func)
6276 (if (string-match (regexp-quote "?") url)
6277 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
6278 args (gnus-url-parse-query-string
6279 (substring url (match-end 0) nil) t))
6280 (setq to (gnus-url-unhex-string url)))
6281 (setq args (cons (list "to" to) args)
6282 subject (cdr-safe (assoc "subject" args)))
6285 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
6288 (message-position-on-field (caar args)))
6289 (insert (mapconcat 'identity (cdar args) ", "))
6290 (setq args (cdr args)))
6293 (message-goto-subject))))
6295 (defun gnus-button-embedded-url (address)
6296 "Activate ADDRESS with `browse-url'."
6297 (browse-url (gnus-strip-whitespace address)))
6299 ;;; Next/prev buttons in the article buffer.
6301 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
6302 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
6304 (defvar gnus-prev-page-map
6305 (let ((map (make-sparse-keymap)))
6306 (unless (>= emacs-major-version 21)
6307 ;; XEmacs doesn't care.
6308 (set-keymap-parent map gnus-article-mode-map))
6309 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6310 (define-key map "\r" 'gnus-button-prev-page)
6313 (defun gnus-insert-prev-page-button ()
6315 (buffer-read-only nil)
6316 (situation (get-text-property (point-min) 'mime-view-situation)))
6318 gnus-prev-page-line-format nil
6319 `(,@(gnus-local-map-property gnus-prev-page-map)
6321 gnus-callback gnus-article-button-prev-page
6322 article-type annotation
6323 mime-view-situation ,situation))
6324 (widget-convert-button
6326 :action 'gnus-button-prev-page
6327 :button-keymap gnus-prev-page-map)))
6329 (defvar gnus-next-page-map
6330 (let ((map (make-sparse-keymap)))
6331 (unless (>= emacs-major-version 21)
6332 ;; XEmacs doesn't care.
6333 (set-keymap-parent map gnus-article-mode-map))
6334 (define-key map gnus-mouse-2 'gnus-button-next-page)
6335 (define-key map "\r" 'gnus-button-next-page)
6338 (defun gnus-button-next-page (&optional args more-args)
6339 "Go to the next page."
6341 (let ((win (selected-window)))
6342 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6343 (gnus-article-next-page)
6344 (select-window win)))
6346 (defun gnus-button-prev-page (&optional args more-args)
6347 "Go to the prev page."
6349 (let ((win (selected-window)))
6350 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6351 (gnus-article-prev-page)
6352 (select-window win)))
6354 (defun gnus-insert-next-page-button ()
6356 (buffer-read-only nil)
6357 (situation (get-text-property (point-min) 'mime-view-situation)))
6358 (gnus-eval-format gnus-next-page-line-format nil
6359 `(,@(gnus-local-map-property gnus-next-page-map)
6361 gnus-callback gnus-article-button-next-page
6362 article-type annotation
6363 mime-view-situation ,situation))
6364 (widget-convert-button
6366 :action 'gnus-button-next-page
6367 :button-keymap gnus-next-page-map)))
6369 (defun gnus-article-button-next-page (arg)
6370 "Go to the next page."
6372 (let ((win (selected-window)))
6373 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6374 (gnus-article-next-page)
6375 (select-window win)))
6377 (defun gnus-article-button-prev-page (arg)
6378 "Go to the prev page."
6380 (let ((win (selected-window)))
6381 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6382 (gnus-article-prev-page)
6383 (select-window win)))
6385 (defvar gnus-decode-header-methods
6386 '(mail-decode-encoded-word-region)
6387 "List of methods used to decode headers.
6389 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
6390 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
6391 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
6392 whose names match REGEXP.
6395 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
6396 mail-decode-encoded-word-region
6397 (\"chinese\" . rfc1843-decode-region))
6400 (defvar gnus-decode-header-methods-cache nil)
6402 (defun gnus-multi-decode-header (start end)
6403 "Apply the functions from `gnus-encoded-word-methods' that match."
6404 (unless (and gnus-decode-header-methods-cache
6405 (eq gnus-newsgroup-name
6406 (car gnus-decode-header-methods-cache)))
6407 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
6410 (nconc gnus-decode-header-methods-cache (list x))
6411 (if (and gnus-newsgroup-name
6412 (string-match (car x) gnus-newsgroup-name))
6413 (nconc gnus-decode-header-methods-cache
6415 gnus-decode-header-methods))
6416 (let ((xlist gnus-decode-header-methods-cache))
6419 (narrow-to-region start end)
6421 (funcall (pop xlist) (point-min) (point-max))))))
6424 ;;; Treatment top-level handling.
6427 (defun gnus-treat-article (condition &optional part-number total-parts type)
6428 (let ((length (- (point-max) (point-min)))
6429 (alist gnus-treatment-function-alist)
6430 (article-goto-body-goes-to-point-min-p t)
6434 (let ((list gnus-article-treat-types))
6436 (when (string-match (pop list) type)
6437 (throw 'found t)))))))
6438 (highlightp (gnus-visual-p 'article-highlight 'highlight))
6439 (entity (static-unless (featurep 'xemacs)
6440 (when (eq 'head condition)
6441 (get-text-property (point-min) 'mime-view-entity))))
6442 val elem buttonized)
6443 (gnus-run-hooks 'gnus-part-display-hook)
6444 (unless gnus-inhibit-treatment
6445 (while (setq elem (pop alist))
6448 (if (gnus-buffer-live-p gnus-summary-buffer)
6449 (set-buffer gnus-summary-buffer))
6450 (symbol-value (car elem))))
6451 (when (and (or (consp val)
6453 (gnus-treat-predicate val)
6454 (or (not (get (car elem) 'highlight))
6456 (when (and (not buttonized)
6458 '(gnus-treat-hide-signature
6459 gnus-treat-highlight-signature)))
6460 (gnus-article-buttonize-signature)
6461 (setq buttonized t))
6463 (funcall (cadr elem)))))
6464 ;; FSF Emacsen does not inherit the existing text properties
6465 ;; in the new text, so we should do it for `mime-view-entity'.
6466 (static-unless (featurep 'xemacs)
6468 (put-text-property (point-min) (point-max)
6469 'mime-view-entity entity))))))
6471 ;; Dynamic variables.
6473 (defvar part-number)
6474 (defvar total-parts)
6479 (defun gnus-treat-predicate (val)
6484 (stringp (car val)))
6485 (apply 'gnus-or (mapcar `(lambda (s)
6486 (string-match s ,(or gnus-newsgroup-name "")))
6489 (let ((pred (pop val)))
6492 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
6494 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
6496 (not (gnus-treat-predicate (car val))))
6498 (equal (car val) type))
6500 (error "%S is not a valid predicate" pred)))))
6510 (eq part-number total-parts))
6514 (error "%S is not a valid value" val))))
6516 (defun gnus-article-encrypt-body (protocol &optional n)
6517 "Encrypt the article body."
6520 (or gnus-article-encrypt-protocol
6521 (completing-read "Encrypt protocol: "
6522 gnus-article-encrypt-protocol-alist
6524 current-prefix-arg))
6525 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
6527 (error (format "Can't find the encrypt protocol %s" protocol)))
6528 (if (equal gnus-newsgroup-name "nndraft:drafts")
6529 (error "Can't encrypt the article in group nndraft:drafts"))
6530 (if (equal gnus-newsgroup-name "nndraft:queue")
6531 (error "Don't encrypt the article in group nndraft:queue"))
6532 (gnus-summary-iterate n
6534 (set-buffer gnus-summary-buffer)
6535 (let ((mail-parse-charset gnus-newsgroup-charset)
6536 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6537 (summary-buffer gnus-summary-buffer)
6539 (gnus-set-global-variables)
6540 (when (gnus-group-read-only-p)
6541 (error "The current newsgroup does not support article encrypt"))
6542 (gnus-summary-show-article t)
6544 (or (mail-header-references gnus-current-headers) ""))
6545 (set-buffer gnus-article-buffer)
6546 (let* ((buffer-read-only nil)
6548 (mapcar (lambda (field)
6549 (and (save-restriction
6550 (message-narrow-to-head)
6551 (goto-char (point-min))
6552 (search-forward field nil t))
6554 (message-narrow-to-field)
6555 (buffer-substring (point-min) (point-max))
6556 (delete-region (point-min) (point-max))
6558 '("Content-Type:" "Content-Transfer-Encoding:"
6559 "Content-Disposition:"))))
6560 (message-narrow-to-head)
6561 (message-remove-header "MIME-Version")
6562 (goto-char (point-max))
6563 (setq point (point))
6564 (insert (apply 'concat headers))
6566 (narrow-to-region point (point-max))
6567 (let ((message-options message-options))
6568 (message-options-set 'message-sender user-mail-address)
6569 (message-options-set 'message-recipients user-mail-address)
6570 (message-options-set 'message-sign-encrypt 'not)
6572 (goto-char (point-min))
6573 (insert "MIME-Version: 1.0\n")
6575 (gnus-summary-edit-article-done
6576 references nil summary-buffer t))
6577 (when gnus-keep-backlog
6578 (gnus-backlog-remove-article
6579 (car gnus-article-current) (cdr gnus-article-current)))
6581 (when (get-buffer gnus-original-article-buffer)
6582 (set-buffer gnus-original-article-buffer)
6583 (setq gnus-original-article nil)))
6584 (when gnus-use-cache
6585 (gnus-cache-update-article
6586 (car gnus-article-current) (cdr gnus-article-current))))))))
6588 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
6589 "The following specs can be used:
6590 %t The security MIME type
6593 %D Details if button is pressed")
6595 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
6596 "The following specs can be used:
6597 %t The security MIME type
6600 %D Details if button is pressed")
6602 (defvar gnus-mime-security-button-line-format-alist
6603 '((?t gnus-tmp-type ?s)
6604 (?i gnus-tmp-info ?s)
6605 (?d gnus-tmp-details ?s)
6606 (?D gnus-tmp-pressed-details ?s)))
6608 (defvar gnus-mime-security-button-map
6609 (let ((map (make-sparse-keymap)))
6610 (unless (>= (string-to-number emacs-version) 21)
6611 (set-keymap-parent map gnus-article-mode-map))
6612 (define-key map gnus-mouse-2 'gnus-article-push-button)
6613 (define-key map "\r" 'gnus-article-press-button)
6616 (defvar gnus-mime-security-details-buffer nil)
6618 (defvar gnus-mime-security-button-pressed nil)
6620 (defvar gnus-mime-security-show-details-inline t
6621 "If non-nil, show details in the article buffer.")
6623 (defun gnus-mime-security-verify-or-decrypt (handle)
6624 (mm-remove-parts (cdr handle))
6625 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
6626 point buffer-read-only)
6628 (goto-char (car region)))
6630 (narrow-to-region (point) (point))
6631 (with-current-buffer (mm-handle-multipart-original-buffer handle)
6632 (let* ((mm-verify-option 'known)
6633 (mm-decrypt-option 'known)
6634 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
6635 (unless (eq nparts (cdr handle))
6636 (mm-destroy-parts (cdr handle))
6637 (setcdr handle nparts))))
6638 (setq point (point))
6639 (gnus-mime-display-security handle)
6640 (goto-char (point-max)))
6642 (delete-region (point) (cdr region))
6643 (set-marker (car region) nil)
6644 (set-marker (cdr region) nil))
6647 (defun gnus-mime-security-show-details (handle)
6648 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
6650 (if gnus-mime-security-show-details-inline
6651 (let ((gnus-mime-security-button-pressed t)
6652 (gnus-mime-security-button-line-format
6653 (get-text-property (point) 'gnus-line-format))
6656 (while (eq (get-text-property (point) 'gnus-line-format)
6657 gnus-mime-security-button-line-format)
6661 (narrow-to-region (point) (point))
6662 (gnus-insert-mime-security-button handle))
6663 (delete-region (point)
6664 (or (text-property-not-all
6667 gnus-mime-security-button-line-format)
6669 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
6670 (with-current-buffer gnus-mime-security-details-buffer
6673 (setq gnus-mime-security-details-buffer
6674 (gnus-get-buffer-create "*MIME Security Details*")))
6675 (with-current-buffer gnus-mime-security-details-buffer
6677 (goto-char (point-min)))
6678 (pop-to-buffer gnus-mime-security-details-buffer))
6679 (gnus-message 5 "No details."))))
6681 (defun gnus-mime-security-press-button (handle)
6682 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6683 (gnus-mime-security-show-details handle)
6684 (gnus-mime-security-verify-or-decrypt handle)))
6686 (defun gnus-insert-mime-security-button (handle &optional displayed)
6687 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
6690 (or (nth 2 (assoc protocol mm-verify-function-alist))
6691 (nth 2 (assoc protocol mm-decrypt-function-alist))
6693 (if (equal (car handle) "multipart/signed")
6694 " Signed" " Encrypted")
6697 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6700 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
6701 gnus-tmp-pressed-details
6703 (setq gnus-tmp-details
6704 (if gnus-tmp-details
6705 (concat "\n" gnus-tmp-details) ""))
6706 (setq gnus-tmp-pressed-details
6707 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
6712 gnus-mime-security-button-line-format
6713 gnus-mime-security-button-line-format-alist
6714 `(,@(gnus-local-map-property gnus-mime-security-button-map)
6715 gnus-callback gnus-mime-security-press-button
6716 gnus-line-format ,gnus-mime-security-button-line-format
6717 article-type annotation
6720 (widget-convert-button
6723 :action 'gnus-widget-press-button
6724 :button-keymap gnus-mime-security-button-map
6726 (lambda (widget/window &optional overlay pos)
6727 ;; Needed to properly clear the message due to a bug in
6728 ;; wid-edit (XEmacs only).
6729 (if (boundp 'help-echo-owns-message)
6730 (setq help-echo-owns-message t))
6733 (aref gnus-mouse-2 0))))))
6735 (defun gnus-mime-display-security (handle)
6737 (narrow-to-region (point) (point))
6738 (unless (gnus-unbuttonized-mime-type-p (car handle))
6739 (gnus-insert-mime-security-button handle))
6740 (gnus-mime-display-mixed (cdr handle))
6743 (unless (gnus-unbuttonized-mime-type-p (car handle))
6744 (let ((gnus-mime-security-button-line-format
6745 gnus-mime-security-button-end-line-format))
6746 (gnus-insert-mime-security-button handle)))
6747 (mm-set-handle-multipart-parameter
6749 (cons (set-marker (make-marker) (point-min))
6750 (set-marker (make-marker) (point-max))))))
6756 (defun gnus-article-header-presentation-method (entity situation)
6757 (mime-insert-header entity)
6758 (article-decode-group-name))
6760 (set-alist 'mime-header-presentation-method-alist
6761 'gnus-original-article-mode
6762 #'gnus-article-header-presentation-method)
6764 (defun gnus-mime-preview-quitting-method ()
6765 (mime-preview-kill-buffer)
6766 (delete-other-windows)
6767 (gnus-article-show-summary)
6768 (gnus-summary-select-article gnus-show-all-headers t))
6770 (set-alist 'mime-preview-quitting-method-alist
6771 'gnus-original-article-mode #'gnus-mime-preview-quitting-method)
6773 (set-alist 'mime-preview-following-method-alist
6774 'gnus-original-article-mode #'gnus-following-method)
6776 (set-alist 'mime-preview-over-to-previous-method-alist
6777 'gnus-original-article-mode
6779 (if (> (point-min) 1)
6780 (gnus-article-prev-page)
6781 (gnus-article-read-summary-keys
6782 nil (gnus-character-to-event ?P)))))
6784 (set-alist 'mime-preview-over-to-next-method-alist
6785 'gnus-original-article-mode'
6787 (if (< (point-max) (buffer-size))
6788 (gnus-article-next-page)
6789 (gnus-article-read-summary-keys
6790 nil (gnus-character-to-event ?N)))))
6800 (run-hooks 'gnus-art-load-hook)
6802 ;;; gnus-art.el ends here