1 ;;; gnus-art.el --- article mode commands for Semi-gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
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.
34 (defvar tool-bar-map))
44 (when (static-if (featurep 'xemacs)
45 (console-on-window-system-p)
47 (require 'mime-image))
50 ;; Avoid byte-compile warnings.
60 (autoload 'gnus-msg-mail "gnus-msg" nil t)
61 (autoload 'gnus-button-mailto "gnus-msg")
62 (autoload 'gnus-button-reply "gnus-msg" nil t)
63 (autoload 'ansi-color-apply-on-region "ansi-color")
65 (defgroup gnus-article nil
67 :link '(custom-manual "(gnus)Article Buffer")
70 (defgroup gnus-article-treat nil
71 "Treating article parts."
72 :link '(custom-manual "(gnus)Article Hiding")
75 (defgroup gnus-article-hiding nil
76 "Hiding article parts."
77 :link '(custom-manual "(gnus)Article Hiding")
80 (defgroup gnus-article-highlight nil
81 "Article highlighting."
82 :link '(custom-manual "(gnus)Article Highlighting")
86 (defgroup gnus-article-signature nil
88 :link '(custom-manual "(gnus)Article Signature")
91 (defgroup gnus-article-headers nil
93 :link '(custom-manual "(gnus)Hiding Headers")
96 (defgroup gnus-article-washing nil
97 "Special commands on articles."
98 :link '(custom-manual "(gnus)Article Washing")
101 (defgroup gnus-article-emphasis nil
102 "Fontisizing articles."
103 :link '(custom-manual "(gnus)Article Fontisizing")
104 :group 'gnus-article)
106 (defgroup gnus-article-saving nil
108 :link '(custom-manual "(gnus)Saving Articles")
109 :group 'gnus-article)
111 (defgroup gnus-article-mime nil
112 "Worshiping the MIME wonder."
113 :link '(custom-manual "(gnus)Using MIME")
114 :group 'gnus-article)
116 (defgroup gnus-article-buttons nil
117 "Pushable buttons in the article buffer."
118 :link '(custom-manual "(gnus)Article Buttons")
119 :group 'gnus-article)
121 (defgroup gnus-article-various nil
122 "Other article options."
123 :link '(custom-manual "(gnus)Misc Article")
124 :group 'gnus-article)
126 (defcustom gnus-ignored-headers
129 (concat "^" header ":"))
130 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
131 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
132 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
133 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
134 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
135 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
136 "X-Attribution" "X-Originating-IP" "Delivered-To"
137 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
138 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
139 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
140 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
141 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
142 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
143 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
144 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
145 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
146 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
147 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
148 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
149 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
150 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
151 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
152 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
153 "List-[A-Za-z]+" "X-Listprocessor-Version"
154 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
155 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
156 "X-Received" "Content-length" "X-precedence"
157 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
158 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
159 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
160 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
161 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
162 "X-Content-length" "X-Posting-Agent" "Original-Received"
163 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
164 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
165 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
166 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
167 "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer"))
168 "*All headers that start with this regexp will be hidden.
169 This variable can also be a list of regexps of headers to be ignored.
170 If `gnus-visible-headers' is non-nil, this variable will be ignored."
171 :type '(choice :custom-show nil
174 :group 'gnus-article-hiding)
176 (defcustom gnus-visible-headers
177 "^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:"
178 "*All headers that do not match this regexp will be hidden.
179 This variable can also be a list of regexp of headers to remain visible.
180 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
181 :type '(repeat :value-to-internal (lambda (widget value)
182 (custom-split-regexp-maybe value))
183 :match (lambda (widget value)
185 (widget-editable-list-match widget value)))
187 :group 'gnus-article-hiding)
189 (defcustom gnus-sorted-header-list
190 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
191 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
192 "*This variable is a list of regular expressions.
193 If it is non-nil, headers that match the regular expressions will
194 be placed first in the article buffer in the sequence specified by
196 :type '(repeat regexp)
197 :group 'gnus-article-hiding)
199 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
200 "Headers that are only to be displayed if they have interesting data.
201 Possible values in this list are:
203 'empty Headers with no content.
204 'newsgroups Newsgroup identical to Gnus group.
205 'to-address To identical to To-address.
206 'to-list To identical to To-list.
207 'cc-list CC identical to To-list.
208 'followup-to Followup-to identical to Newsgroups.
209 'reply-to Reply-to identical to From.
210 'date Date less than four days old.
211 'long-to To and/or Cc longer than 1024 characters.
212 'many-to Multiple To and/or Cc."
213 :type '(set (const :tag "Headers with no content." empty)
214 (const :tag "Newsgroups identical to Gnus group." newsgroups)
215 (const :tag "To identical to To-address." to-address)
216 (const :tag "To identical to To-list." to-list)
217 (const :tag "CC identical to To-list." cc-list)
218 (const :tag "Followup-to identical to Newsgroups." followup-to)
219 (const :tag "Reply-to identical to From." reply-to)
220 (const :tag "Date less than four days old." date)
221 (const :tag "To and/or Cc longer than 1024 characters." long-to)
222 (const :tag "Multiple To and/or Cc headers." many-to))
223 :group 'gnus-article-hiding)
225 (defcustom gnus-article-skip-boring nil
226 "Skip over text that is not worth reading.
227 By default, if you set this t, then Gnus will display citations and
228 signatures, but will never scroll down to show you a page consisting
229 only of boring text. Boring text is controlled by
230 `gnus-article-boring-faces'."
232 :group 'gnus-article-hiding)
234 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
235 "Regexp matching signature separator.
236 This can also be a list of regexps. In that case, it will be checked
237 from head to tail looking for a separator. Searches will be done from
238 the end of the buffer."
239 :type '(repeat string)
240 :group 'gnus-article-signature)
242 (defcustom gnus-signature-limit nil
243 "Provide a limit to what is considered a signature.
244 If it is a number, no signature may not be longer (in characters) than
245 that number. If it is a floating point number, no signature may be
246 longer (in lines) than that number. If it is a function, the function
247 will be called without any parameters, and if it returns nil, there is
248 no signature in the buffer. If it is a string, it will be used as a
249 regexp. If it matches, the text in question is not a signature.
251 This can also be a list of the above values."
252 :type '(choice (integer :value 200)
254 (function :value fun)
255 (regexp :value ".*"))
256 :group 'gnus-article-signature)
258 (defcustom gnus-hidden-properties '(invisible t intangible t)
259 "Property list to use for hiding text."
261 :group 'gnus-article-hiding)
263 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
264 ;; frames in a session.
265 (defcustom gnus-article-x-face-command
270 (if (or (gnus-image-type-available-p 'xface)
271 (gnus-image-type-available-p 'pbm))
272 'gnus-display-x-face-in-from
273 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -"))
274 ((gnus-image-type-available-p 'pbm)
275 'gnus-display-x-face-in-from)
277 (module-installed-p 'x-face-mule))
278 'x-face-mule-gnus-article-display-x-face)
280 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
282 "*String or function to be executed to display an X-Face header.
283 If it is a string, the command will be executed in a sub-shell
284 asynchronously. The compressed face will be piped to this command."
286 ,@(let ((x-face-mule (if (featurep 'xemacs)
288 (module-installed-p 'x-face-mule))))
292 (if (or (gnus-image-type-available-p 'xface)
293 (gnus-image-type-available-p 'pbm))
294 '(function-item gnus-display-x-face-in-from))
297 x-face-mule-gnus-article-display-x-face))
301 :group 'gnus-article-washing)
303 (defcustom gnus-article-x-face-too-ugly nil
304 "Regexp matching posters whose face shouldn't be shown automatically."
305 :type '(choice regexp (const nil))
306 :group 'gnus-article-washing)
308 (defcustom gnus-article-banner-alist nil
309 "Banner alist for stripping.
311 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
313 :type '(repeat (cons symbol regexp))
314 :group 'gnus-article-washing)
316 (gnus-define-group-parameter
319 "Alist of regexps (to match group names) and banner."
320 :variable-group gnus-article-washing
322 '(choice :tag "Banner"
324 (const :tag "Remove signature" signature)
325 (symbol :tag "Item in `gnus-article-banner-alist'" none)
327 (const :tag "None" nil))
329 "If non-nil, specify how to remove `banners' from articles.
331 Symbol `signature' means to remove signatures delimited by
332 `gnus-signature-separator'. Any other symbol is used to look up a
333 regular expression to match the banner in `gnus-article-banner-alist'.
334 A string is used as a regular expression to match the banner
337 (defcustom gnus-article-address-banner-alist nil
338 "Alist of mail addresses and banners.
339 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
340 to match a mail address in the From: header, BANNER is one of a symbol
341 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
342 If ADDRESS matches author's mail address, it will remove things like
343 advertisements. For example:
345 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
349 (regexp :tag "Address")
350 (choice :tag "Banner" :value nil
351 (const :tag "Remove signature" signature)
352 (symbol :tag "Item in `gnus-article-banner-alist'" none)
354 (const :tag "None" nil))))
355 :group 'gnus-article-washing)
357 (defcustom gnus-emphasis-alist
359 "\\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)")
364 ("_/" "/_" underline-italic)
365 ("_\\*" "\\*_" underline-bold)
366 ("\\*/" "/\\*" bold-italic)
367 ("_\\*/" "/\\*_" underline-bold-italic))))
371 (format format (car spec) (car (cdr spec)))
372 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
374 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
375 2 3 gnus-emphasis-underline)))
376 "*Alist that says how to fontify certain phrases.
377 Each item looks like this:
379 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
381 The first element is a regular expression to be matched. The second
382 is a number that says what regular expression grouping used to find
383 the entire emphasized word. The third is a number that says what
384 regexp grouping should be displayed and highlighted. The fourth
385 is the face used for highlighting."
386 :type '(repeat (list :value ("" 0 0 default)
388 (integer :tag "Match group")
389 (integer :tag "Emphasize group")
391 :group 'gnus-article-emphasis)
393 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
394 "A regexp to describe whitespace which should not be emphasized.
395 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
396 The former avoids underlining of leading and trailing whitespace,
397 and the latter avoids underlining any whitespace at all."
399 :group 'gnus-article-emphasis
402 (defface gnus-emphasis-bold '((t (:bold t)))
403 "Face used for displaying strong emphasized text (*word*)."
404 :group 'gnus-article-emphasis)
406 (defface gnus-emphasis-italic '((t (:italic t)))
407 "Face used for displaying italic emphasized text (/word/)."
408 :group 'gnus-article-emphasis)
410 (defface gnus-emphasis-underline '((t (:underline t)))
411 "Face used for displaying underlined emphasized text (_word_)."
412 :group 'gnus-article-emphasis)
414 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
415 "Face used for displaying underlined bold emphasized text (_*word*_)."
416 :group 'gnus-article-emphasis)
418 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
419 "Face used for displaying underlined italic emphasized text (_/word/_)."
420 :group 'gnus-article-emphasis)
422 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
423 "Face used for displaying bold italic emphasized text (/*word*/)."
424 :group 'gnus-article-emphasis)
426 (defface gnus-emphasis-underline-bold-italic
427 '((t (:bold t :italic t :underline t)))
428 "Face used for displaying underlined bold italic emphasized text.
429 Example: (_/*word*/_)."
430 :group 'gnus-article-emphasis)
432 (defface gnus-emphasis-strikethru (if (featurep 'xemacs)
433 '((t (:strikethru t)))
434 '((t (:strike-through t))))
435 "Face used for displaying strike-through text (-word-)."
436 :group 'gnus-article-emphasis)
438 (defface gnus-emphasis-highlight-words
439 '((t (:background "black" :foreground "yellow")))
440 "Face used for displaying highlighted words."
441 :group 'gnus-article-emphasis)
443 (defcustom gnus-article-time-format "%a, %d %b %Y %T %Z"
444 "Format for display of Date headers in article bodies.
445 See `format-time-string' for the possible values.
447 The variable can also be function, which should return a complete Date
448 header. The function is called with one argument, the time, which can
449 be fed to `format-time-string'."
450 :type '(choice string function)
451 :link '(custom-manual "(gnus)Article Date")
452 :group 'gnus-article-washing)
455 (autoload 'mail-extract-address-components "mail-extr"))
457 (defcustom gnus-save-all-headers t
458 "*If non-nil, don't remove any headers before saving."
459 :group 'gnus-article-saving
462 (defcustom gnus-prompt-before-saving 'always
463 "*This variable says how much prompting is to be done when saving articles.
464 If it is nil, no prompting will be done, and the articles will be
465 saved to the default files. If this variable is `always', each and
466 every article that is saved will be preceded by a prompt, even when
467 saving large batches of articles. If this variable is neither nil not
468 `always', there the user will be prompted once for a file name for
469 each invocation of the saving commands."
470 :group 'gnus-article-saving
471 :type '(choice (item always)
472 (item :tag "never" nil)
473 (sexp :tag "once" :format "%t\n" :value t)))
475 (defcustom gnus-saved-headers gnus-visible-headers
476 "Headers to keep if `gnus-save-all-headers' is nil.
477 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
478 If that variable is nil, however, all headers that match this regexp
479 will be kept while the rest will be deleted before saving."
480 :group 'gnus-article-saving
483 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
484 "A function to save articles in your favourite format.
485 The function must be interactively callable (in other words, it must
486 be an Emacs command).
488 Gnus provides the following functions:
490 * gnus-summary-save-in-rmail (Rmail format)
491 * gnus-summary-save-in-mail (Unix mail format)
492 * gnus-summary-save-in-folder (MH folder)
493 * gnus-summary-save-in-file (article format)
494 * gnus-summary-save-body-in-file (article body)
495 * gnus-summary-save-in-vm (use VM's folder format)
496 * gnus-summary-write-to-file (article format -- overwrite)."
497 :group 'gnus-article-saving
498 :type '(radio (function-item gnus-summary-save-in-rmail)
499 (function-item gnus-summary-save-in-mail)
500 (function-item gnus-summary-save-in-folder)
501 (function-item gnus-summary-save-in-file)
502 (function-item gnus-summary-save-body-in-file)
503 (function-item gnus-summary-save-in-vm)
504 (function-item gnus-summary-write-to-file)))
506 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
507 "A function generating a file name to save articles in Rmail format.
508 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
509 :group 'gnus-article-saving
512 (defcustom gnus-mail-save-name 'gnus-plain-save-name
513 "A function generating a file name to save articles in Unix mail format.
514 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
515 :group 'gnus-article-saving
518 (defcustom gnus-folder-save-name 'gnus-folder-save-name
519 "A function generating a file name to save articles in MH folder.
520 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
521 :group 'gnus-article-saving
524 (defcustom gnus-file-save-name 'gnus-numeric-save-name
525 "A function generating a file name to save articles in article format.
526 The function is called with NEWSGROUP, HEADERS, and optional
528 :group 'gnus-article-saving
531 (defcustom gnus-split-methods
532 '((gnus-article-archive-name)
533 (gnus-article-nndoc-name))
534 "*Variable used to suggest where articles are to be saved.
535 For instance, if you would like to save articles related to Gnus in
536 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
537 you could set this variable to something like:
539 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
540 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
542 This variable is an alist where the where the key is the match and the
543 value is a list of possible files to save in if the match is non-nil.
545 If the match is a string, it is used as a regexp match on the
546 article. If the match is a symbol, that symbol will be funcalled
547 from the buffer of the article to be saved with the newsgroup as the
548 parameter. If it is a list, it will be evaled in the same buffer.
550 If this form or function returns a string, this string will be used as
551 a possible file name; and if it returns a non-nil list, that list will
552 be used as possible file names."
553 :group 'gnus-article-saving
554 :type '(repeat (choice (list :value (fun) function)
555 (cons :value ("" "") regexp (repeat string))
558 (defcustom gnus-article-display-method-for-mime
559 'gnus-article-display-mime-message
560 "Function to display a MIME message.
561 The function is called from the article buffer."
562 :group 'gnus-article-mime
565 (defcustom gnus-article-display-method-for-traditional
566 'gnus-article-display-traditional-message
567 "*Function to display a traditional message.
568 The function is called from the article buffer."
569 :group 'gnus-article-mime
572 (defcustom gnus-page-delimiter "^\^L"
573 "*Regexp describing what to use as article page delimiters.
574 The default value is \"^\^L\", which is a form linefeed at the
575 beginning of a line."
577 :group 'gnus-article-various)
579 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
580 "*The format specification for the article mode line.
581 See `gnus-summary-mode-line-format' for a closer description.
583 The following additional specs are available:
585 %w The article washing status.
586 %m The number of MIME parts in the article."
588 :group 'gnus-article-various)
590 (defcustom gnus-article-mode-hook nil
591 "*A hook for Gnus article mode."
593 :group 'gnus-article-various)
595 (when (featurep 'xemacs)
596 ;; Extracted from gnus-xmas-define in order to preserve user settings
597 (when (fboundp 'turn-off-scroll-in-place)
598 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
599 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
600 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
602 (defcustom gnus-article-menu-hook nil
603 "*Hook run after the creation of the article mode menu."
605 :group 'gnus-article-various)
607 (defcustom gnus-article-prepare-hook nil
608 "*A hook called after an article has been prepared in the article buffer."
610 :group 'gnus-article-various)
612 (make-obsolete-variable 'gnus-article-hide-pgp-hook
613 "This variable is obsolete in Gnus 5.10.")
615 (defcustom gnus-article-button-face 'bold
616 "Face used for highlighting buttons in the article buffer.
618 An article button is a piece of text that you can activate by pressing
619 `RET' or `mouse-2' above it."
621 :group 'gnus-article-buttons)
623 (defcustom gnus-article-mouse-face 'highlight
624 "Face used for mouse highlighting in the article buffer.
626 Article buttons will be displayed in this face when the cursor is
629 :group 'gnus-article-buttons)
631 (defcustom gnus-signature-face 'gnus-signature-face
632 "Face used for highlighting a signature in the article buffer.
633 Obsolete; use the face `gnus-signature-face' for customizations instead."
635 :group 'gnus-article-highlight
636 :group 'gnus-article-signature)
638 (defface gnus-signature-face
641 "Face used for highlighting a signature in the article buffer."
642 :group 'gnus-article-highlight
643 :group 'gnus-article-signature)
645 (defface gnus-header-from-face
648 (:foreground "spring green"))
651 (:foreground "red3"))
654 "Face used for displaying from headers."
655 :group 'gnus-article-headers
656 :group 'gnus-article-highlight)
658 (defface gnus-header-subject-face
661 (:foreground "SeaGreen3"))
664 (:foreground "red4"))
666 (:bold t :italic t)))
667 "Face used for displaying subject headers."
668 :group 'gnus-article-headers
669 :group 'gnus-article-highlight)
671 (defface gnus-header-newsgroups-face
674 (:foreground "yellow" :italic t))
677 (:foreground "MidnightBlue" :italic t))
680 "Face used for displaying newsgroups headers.
681 In the default setup this face is only used for crossposted
683 :group 'gnus-article-headers
684 :group 'gnus-article-highlight)
686 (defface gnus-header-name-face
689 (:foreground "SeaGreen"))
692 (:foreground "maroon"))
695 "Face used for displaying header names."
696 :group 'gnus-article-headers
697 :group 'gnus-article-highlight)
699 (defface gnus-header-content-face
702 (:foreground "forest green" :italic t))
705 (:foreground "indianred4" :italic t))
708 "Face used for displaying header content."
709 :group 'gnus-article-headers
710 :group 'gnus-article-highlight)
712 (defcustom gnus-header-face-alist
713 '(("From" nil gnus-header-from-face)
714 ("Subject" nil gnus-header-subject-face)
715 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
716 ("" gnus-header-name-face gnus-header-content-face))
717 "*Controls highlighting of article headers.
719 An alist of the form (HEADER NAME CONTENT).
721 HEADER is a regular expression which should match the name of a
722 header and NAME and CONTENT are either face names or nil.
724 The name of each header field will be displayed using the face
725 specified by the first element in the list where HEADER matches
726 the header name and NAME is non-nil. Similarly, the content will
727 be displayed by the first non-nil matching CONTENT face."
728 :group 'gnus-article-headers
729 :group 'gnus-article-highlight
730 :type '(repeat (list (regexp :tag "Header")
732 (item :tag "skip" nil)
733 (face :value default))
734 (choice :tag "Content"
735 (item :tag "skip" nil)
736 (face :value default)))))
738 (defcustom gnus-article-decode-hook
739 '(article-decode-group-name article-decode-idna-rhs)
740 "*Hook run to decode charsets in articles."
741 :group 'gnus-article-headers
744 (defcustom gnus-display-mime-function 'gnus-display-mime
745 "Function to display MIME articles."
746 :group 'gnus-article-mime
749 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
750 "Function used to decode headers.")
752 (defvar gnus-article-dumbquotes-map
772 "Table for MS-to-Latin1 translation.")
774 (defcustom gnus-ignored-mime-types nil
775 "List of MIME types that should be ignored by Gnus."
777 :group 'gnus-article-mime
778 :type '(repeat regexp))
780 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
781 "List of MIME types that should not be given buttons when rendered inline.
782 See also `gnus-buttonized-mime-types' which may override this variable.
783 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
785 :group 'gnus-article-mime
786 :type '(repeat regexp))
788 (defcustom gnus-buttonized-mime-types nil
789 "List of MIME types that should be given buttons when rendered inline.
790 If set, this variable overrides `gnus-unbuttonized-mime-types'.
791 To see e.g. security buttons you could set this to
792 `(\"multipart/signed\")'.
793 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
795 :group 'gnus-article-mime
796 :type '(repeat regexp))
798 (defcustom gnus-inhibit-mime-unbuttonizing nil
799 "If non-nil, all MIME parts get buttons.
800 When nil (the default value), then some MIME parts do not get buttons,
801 as described by the variables `gnus-buttonized-mime-types' and
802 `gnus-unbuttonized-mime-types'."
804 :group 'gnus-article-mime
807 (defcustom gnus-body-boundary-delimiter "_"
808 "String used to delimit header and body.
809 This variable is used by `gnus-article-treat-body-boundary' which can
810 be controlled by `gnus-treat-body-boundary'."
811 :group 'gnus-article-various
812 :type '(choice (item :tag "None" :value nil)
815 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces"
817 "Defines the location of the faces database.
818 For information on obtaining this database of pretty pictures, please
819 see http://www.cs.indiana.edu/picons/ftp/index.html"
820 :type '(repeat directory)
821 :link '(url-link :tag "download"
822 "http://www.cs.indiana.edu/picons/ftp/index.html")
823 :link '(custom-manual "(gnus)Picons")
826 (defun gnus-picons-installed-p ()
827 "Say whether picons are installed on your machine."
828 (let ((installed nil))
829 (dolist (database gnus-picon-databases)
830 (when (file-exists-p database)
834 (defcustom gnus-article-mime-part-function nil
835 "Function called with a MIME handle as the argument.
836 This is meant for people who want to do something automatic based
837 on parts -- for instance, adding Vcard info to a database."
838 :group 'gnus-article-mime
841 (defcustom gnus-mime-multipart-functions nil
842 "An alist of MIME types to functions to display them."
844 :group 'gnus-article-mime
845 :type '(repeat (cons :format "%v" (string :tag "MIME type") function)))
847 (defcustom gnus-article-date-lapsed-new-header nil
848 "Whether the X-Sent and Date headers can coexist.
849 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
850 either replace the old \"Date:\" header (if this variable is nil), or
851 be added below it (otherwise)."
853 :group 'gnus-article-headers
856 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
857 "Function called with a MIME handle as the argument.
858 This is meant for people who want to view first matched part.
859 For `undisplayed-alternative' (default), the first undisplayed
860 part or alternative part is used. For `undisplayed', the first
861 undisplayed part is used. For a function, the first part which
862 the function return t is used. For nil, the first part is
865 :group 'gnus-article-mime
867 (item :tag "first" :value nil)
868 (item :tag "undisplayed" :value undisplayed)
869 (item :tag "undisplayed or alternative"
870 :value undisplayed-alternative)
873 (defcustom gnus-mime-action-alist
874 '(("save to file" . gnus-mime-save-part)
875 ("save and strip" . gnus-mime-save-part-and-strip)
876 ("delete part" . gnus-mime-delete-part)
877 ("display as text" . gnus-mime-inline-part)
878 ("view the part" . gnus-mime-view-part)
879 ("pipe to command" . gnus-mime-pipe-part)
880 ("toggle display" . gnus-article-press-button)
881 ("toggle display" . gnus-article-view-part-as-charset)
882 ("view as type" . gnus-mime-view-part-as-type)
883 ("view internally" . gnus-mime-view-part-internally)
884 ("view externally" . gnus-mime-view-part-externally))
885 "An alist of actions that run on the MIME attachment."
886 :group 'gnus-article-mime
887 :type '(repeat (cons (string :tag "name")
891 ;;; The treatment variables
894 (defvar gnus-part-display-hook nil
895 "Hook called on parts that are to receive treatment.")
897 (defvar gnus-article-treat-custom
898 '(choice (const :tag "Off" nil)
900 (const :tag "Header" head)
901 (const :tag "Last" last)
902 (const :tag "Mime" mime)
903 (integer :tag "Less")
904 (repeat :tag "Groups" regexp)
905 (sexp :tag "Predicate")))
907 (defvar gnus-article-treat-head-custom
908 '(choice (const :tag "Off" nil)
909 (const :tag "Header" head)))
911 (defvar gnus-article-treat-types '("text/plain")
914 (defvar gnus-inhibit-treatment nil
915 "Whether to inhibit treatment.")
917 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
918 "Highlight the signature.
919 Valid values are nil, t, `head', `last', an integer or a predicate.
920 See Info node `(gnus)Customizing Articles'."
921 :group 'gnus-article-treat
922 :link '(custom-manual "(gnus)Customizing Articles")
923 :type gnus-article-treat-custom)
924 (put 'gnus-treat-highlight-signature 'highlight t)
926 (defcustom gnus-treat-buttonize 100000
928 Valid values are nil, t, `head', `last', an integer or a predicate.
929 See Info node `(gnus)Customizing Articles'."
930 :group 'gnus-article-treat
931 :link '(custom-manual "(gnus)Customizing Articles")
932 :type gnus-article-treat-custom)
933 (put 'gnus-treat-buttonize 'highlight t)
935 (defcustom gnus-treat-buttonize-head 'head
936 "Add buttons to the head.
937 Valid values are nil, t, `head', `last', an integer or a predicate.
938 See Info node `(gnus)Customizing Articles' for details."
939 :group 'gnus-article-treat
940 :link '(custom-manual "(gnus)Customizing Articles")
941 :type gnus-article-treat-head-custom)
942 (put 'gnus-treat-buttonize-head 'highlight t)
944 (defcustom gnus-treat-emphasize
945 (and (or window-system
949 Valid values are nil, t, `head', `last', an integer or a predicate.
950 See Info node `(gnus)Customizing Articles' for details."
951 :group 'gnus-article-treat
952 :link '(custom-manual "(gnus)Customizing Articles")
953 :type gnus-article-treat-custom)
954 (put 'gnus-treat-emphasize 'highlight t)
956 (defcustom gnus-treat-strip-cr nil
957 "Remove carriage returns.
958 Valid values are nil, t, `head', `last', an integer or a predicate.
959 See Info node `(gnus)Customizing Articles' for details."
960 :group 'gnus-article-treat
961 :link '(custom-manual "(gnus)Customizing Articles")
962 :type gnus-article-treat-custom)
964 (defcustom gnus-treat-unsplit-urls nil
965 "Remove newlines from within URLs.
966 Valid values are nil, t, `head', `last', an integer or a predicate.
967 See Info node `(gnus)Customizing Articles' for details."
968 :group 'gnus-article-treat
969 :link '(custom-manual "(gnus)Customizing Articles")
970 :type gnus-article-treat-custom)
972 (defcustom gnus-treat-leading-whitespace nil
973 "Remove leading whitespace in headers.
974 Valid values are nil, t, `head', `last', an integer or a predicate.
975 See Info node `(gnus)Customizing Articles' for details."
976 :group 'gnus-article-treat
977 :link '(custom-manual "(gnus)Customizing Articles")
978 :type gnus-article-treat-custom)
980 (defcustom gnus-treat-hide-headers 'head
982 Valid values are nil, t, `head', `last', an integer or a predicate.
983 See Info node `(gnus)Customizing Articles' for details."
984 :group 'gnus-article-treat
985 :link '(custom-manual "(gnus)Customizing Articles")
986 :type gnus-article-treat-head-custom)
988 (defcustom gnus-treat-hide-boring-headers nil
989 "Hide boring headers.
990 Valid values are nil, t, `head', `last', an integer or a predicate.
991 See Info node `(gnus)Customizing Articles' for details."
992 :group 'gnus-article-treat
993 :link '(custom-manual "(gnus)Customizing Articles")
994 :type gnus-article-treat-head-custom)
996 (defcustom gnus-treat-hide-signature nil
998 Valid values are nil, t, `head', `last', an integer or a predicate.
999 See Info node `(gnus)Customizing Articles' for details."
1000 :group 'gnus-article-treat
1001 :link '(custom-manual "(gnus)Customizing Articles")
1002 :type gnus-article-treat-custom)
1004 (defcustom gnus-treat-fill-article nil
1006 Valid values are nil, t, `head', `last', an integer or a predicate.
1007 See Info node `(gnus)Customizing Articles' for details."
1008 :group 'gnus-article-treat
1009 :link '(custom-manual "(gnus)Customizing Articles")
1010 :type gnus-article-treat-custom)
1012 (defcustom gnus-treat-hide-citation nil
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 :link '(custom-manual "(gnus)Customizing Articles")
1018 :type gnus-article-treat-custom)
1020 (defcustom gnus-treat-hide-citation-maybe nil
1022 Valid values are nil, t, `head', `last', an integer or a predicate.
1023 See Info node `(gnus)Customizing Articles' for details."
1024 :group 'gnus-article-treat
1025 :link '(custom-manual "(gnus)Customizing Articles")
1026 :type gnus-article-treat-custom)
1028 (defcustom gnus-treat-strip-list-identifiers 'head
1029 "Strip list identifiers from `gnus-list-identifiers`.
1030 Valid values are nil, t, `head', `last', an integer or a predicate.
1031 See Info node `(gnus)Customizing Articles' for details."
1033 :group 'gnus-article-treat
1034 :link '(custom-manual "(gnus)Customizing Articles")
1035 :type gnus-article-treat-custom)
1037 (make-obsolete-variable 'gnus-treat-strip-pgp
1038 "This option is obsolete in Gnus 5.10.")
1040 (defcustom gnus-treat-strip-pem nil
1041 "Strip PEM signatures.
1042 Valid values are nil, t, `head', `last', an integer or a predicate.
1043 See Info node `(gnus)Customizing Articles' for details."
1044 :group 'gnus-article-treat
1045 :link '(custom-manual "(gnus)Customizing Articles")
1046 :type gnus-article-treat-custom)
1048 (defcustom gnus-treat-strip-banner t
1049 "Strip banners from articles.
1050 The banner to be stripped is specified in the `banner' group parameter.
1051 Valid values are nil, t, `head', `last', an integer or a predicate.
1052 See Info node `(gnus)Customizing Articles' for details."
1053 :group 'gnus-article-treat
1054 :link '(custom-manual "(gnus)Customizing Articles")
1055 :type gnus-article-treat-custom)
1057 (defcustom gnus-treat-highlight-headers 'head
1058 "Highlight the headers.
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 :link '(custom-manual "(gnus)Customizing Articles")
1063 :type gnus-article-treat-head-custom)
1064 (put 'gnus-treat-highlight-headers 'highlight t)
1066 (defcustom gnus-treat-highlight-citation t
1067 "Highlight cited text.
1068 Valid values are nil, t, `head', `last', an integer or a predicate.
1069 See Info node `(gnus)Customizing Articles' for details."
1070 :group 'gnus-article-treat
1071 :link '(custom-manual "(gnus)Customizing Articles")
1072 :type gnus-article-treat-custom)
1073 (put 'gnus-treat-highlight-citation 'highlight t)
1075 (defcustom gnus-treat-date-ut nil
1076 "Display the Date in UT (GMT).
1077 Valid values are nil, t, `head', `last', an integer or a predicate.
1078 See Info node `(gnus)Customizing Articles' for details."
1079 :group 'gnus-article-treat
1080 :link '(custom-manual "(gnus)Customizing Articles")
1081 :type gnus-article-treat-head-custom)
1083 (defcustom gnus-treat-date-local nil
1084 "Display the Date in the local timezone.
1085 Valid values are nil, t, `head', `last', an integer or a predicate.
1086 See Info node `(gnus)Customizing Articles' for details."
1087 :group 'gnus-article-treat
1088 :link '(custom-manual "(gnus)Customizing Articles")
1089 :type gnus-article-treat-head-custom)
1091 (defcustom gnus-treat-date-english nil
1092 "Display the Date in a format that can be read aloud in English.
1093 Valid values are nil, t, `head', `last', an integer or a predicate.
1094 See Info node `(gnus)Customizing Articles' for details."
1095 :group 'gnus-article-treat
1096 :link '(custom-manual "(gnus)Customizing Articles")
1097 :type gnus-article-treat-head-custom)
1099 (defcustom gnus-treat-date-lapsed nil
1100 "Display the Date header in a way that says how much time has elapsed.
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 :link '(custom-manual "(gnus)Customizing Articles")
1105 :type gnus-article-treat-head-custom)
1107 (defcustom gnus-treat-date-original nil
1108 "Display the date in the original timezone.
1109 Valid values are nil, t, `head', `last', an integer or a predicate.
1110 See Info node `(gnus)Customizing Articles' for details."
1111 :group 'gnus-article-treat
1112 :link '(custom-manual "(gnus)Customizing Articles")
1113 :type gnus-article-treat-head-custom)
1115 (defcustom gnus-treat-date-iso8601 nil
1116 "Display the date in the ISO8601 format.
1117 Valid values are nil, t, `head', `last', an integer or a predicate.
1118 See Info node `(gnus)Customizing Articles' for details."
1120 :group 'gnus-article-treat
1121 :link '(custom-manual "(gnus)Customizing Articles")
1122 :type gnus-article-treat-head-custom)
1124 (defcustom gnus-treat-date-user-defined nil
1125 "Display the date in a user-defined format.
1126 The format is defined by the `gnus-article-time-format' variable.
1127 Valid values are nil, t, `head', `last', an integer or a predicate.
1128 See Info node `(gnus)Customizing Articles' for details."
1129 :group 'gnus-article-treat
1130 :link '(custom-manual "(gnus)Customizing Articles")
1131 :type gnus-article-treat-head-custom)
1133 (defcustom gnus-treat-strip-headers-in-body t
1134 "Strip the X-No-Archive header line from the beginning of the body.
1135 Valid values are nil, t, `head', `last', an integer or a predicate.
1136 See Info node `(gnus)Customizing Articles' for details."
1138 :group 'gnus-article-treat
1139 :link '(custom-manual "(gnus)Customizing Articles")
1140 :type gnus-article-treat-custom)
1142 (defcustom gnus-treat-strip-trailing-blank-lines nil
1143 "Strip trailing blank lines.
1144 Valid values are nil, t, `head', `last', an integer or a predicate.
1145 See Info node `(gnus)Customizing Articles' for details."
1146 :group 'gnus-article-treat
1147 :link '(custom-manual "(gnus)Customizing Articles")
1148 :type gnus-article-treat-custom)
1150 (defcustom gnus-treat-strip-leading-blank-lines nil
1151 "Strip leading blank lines.
1152 Valid values are nil, t, `head', `last', an integer or a predicate.
1153 See Info node `(gnus)Customizing Articles' for details."
1154 :group 'gnus-article-treat
1155 :link '(custom-manual "(gnus)Customizing Articles")
1156 :type gnus-article-treat-custom)
1158 (defcustom gnus-treat-strip-multiple-blank-lines nil
1159 "Strip multiple blank lines.
1160 Valid values are nil, t, `head', `last', an integer or a predicate.
1161 See Info node `(gnus)Customizing Articles' for details."
1162 :group 'gnus-article-treat
1163 :link '(custom-manual "(gnus)Customizing Articles")
1164 :type gnus-article-treat-custom)
1166 (defcustom gnus-treat-unfold-headers 'head
1167 "Unfold folded header lines.
1168 Valid values are nil, t, `head', `last', an integer or a predicate.
1169 See Info node `(gnus)Customizing Articles' for details."
1170 :group 'gnus-article-treat
1171 :link '(custom-manual "(gnus)Customizing Articles")
1172 :type gnus-article-treat-custom)
1174 (defcustom gnus-treat-fold-headers nil
1176 Valid values are nil, t, `head', `last', an integer or a predicate.
1177 See Info node `(gnus)Customizing Articles' for details."
1178 :group 'gnus-article-treat
1179 :link '(custom-manual "(gnus)Customizing Articles")
1180 :type gnus-article-treat-custom)
1182 (defcustom gnus-treat-fold-newsgroups 'head
1183 "Fold the Newsgroups and Followup-To headers.
1184 Valid values are nil, t, `head', `last', an integer or a predicate.
1185 See Info node `(gnus)Customizing Articles' for details."
1186 :group 'gnus-article-treat
1187 :link '(custom-manual "(gnus)Customizing Articles")
1188 :type gnus-article-treat-custom)
1190 (defcustom gnus-treat-overstrike t
1191 "Treat overstrike highlighting.
1192 Valid values are nil, t, `head', `last', an integer or a predicate.
1193 See Info node `(gnus)Customizing Articles' for details."
1194 :group 'gnus-article-treat
1195 :link '(custom-manual "(gnus)Customizing Articles")
1196 :type gnus-article-treat-custom)
1197 (put 'gnus-treat-overstrike 'highlight t)
1199 (defcustom gnus-treat-ansi-sequences (if (locate-library "ansi-color") t)
1200 "Treat ANSI SGR control sequences.
1201 Valid values are nil, t, `head', `last', an integer or a predicate.
1202 See Info node `(gnus)Customizing Articles' for details."
1203 :group 'gnus-article-treat
1204 :link '(custom-manual "(gnus)Customizing Articles")
1205 :type gnus-article-treat-custom)
1207 (make-obsolete-variable 'gnus-treat-display-xface
1208 'gnus-treat-display-x-face)
1210 (defcustom gnus-treat-display-x-face
1211 (and (not noninteractive)
1212 (or (eq gnus-article-x-face-command
1213 'x-face-mule-gnus-article-display-x-face)
1214 (and (fboundp 'image-type-available-p)
1215 (image-type-available-p 'xbm)
1216 (string-match "^0x" (shell-command-to-string "uncompface"))
1217 (executable-find "icontopbm"))
1218 (and (featurep 'xemacs)
1221 "Display X-Face headers.
1222 Valid values are nil, t, `head', `last', an integer or a predicate.
1223 See Info node `(gnus)Customizing Articles' and Info node
1224 `(gnus)X-Face' for details."
1225 :group 'gnus-article-treat
1227 :link '(custom-manual "(gnus)Customizing Articles")
1228 :link '(custom-manual "(gnus)X-Face")
1229 :type gnus-article-treat-head-custom
1230 :set (lambda (symbol value)
1233 (cond ((or (boundp symbol) (get symbol 'saved-value))
1235 ((boundp 'gnus-treat-display-xface)
1237 ** gnus-treat-display-xface is an obsolete variable;\
1238 use gnus-treat-display-x-face instead")
1239 (default-value 'gnus-treat-display-xface))
1240 ((get 'gnus-treat-display-xface 'saved-value)
1242 ** gnus-treat-display-xface is an obsolete variable;\
1243 use gnus-treat-display-x-face instead")
1244 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1247 (put 'gnus-treat-display-x-face 'highlight t)
1249 (defcustom gnus-article-should-use-smiley-mule
1250 (not (or (featurep 'xemacs)
1251 (gnus-image-type-available-p 'xpm)
1252 (gnus-image-type-available-p 'pbm)))
1253 "Non-nil means use `smiley-mule' to show smileys rather than `smiley'.
1254 `smiley-mule' is boundled in BITMAP-MULE package. You can set it to t
1255 even if your Emacs supports images. It has no effect on XEmacs."
1256 :group 'gnus-article-various
1258 :get (lambda (symbol)
1259 (and (not noninteractive)
1260 (default-value symbol)
1261 (not (featurep 'xemacs))
1262 (module-installed-p 'smiley-mule)
1264 :set (lambda (symbol value)
1265 (set-default symbol (and (not noninteractive)
1267 (not (featurep 'xemacs))
1268 (module-installed-p 'smiley-mule)
1271 (defvar gnus-article-smiley-mule-loaded-p nil
1272 "Internal variable used to say whether `smiley-mule' is loaded (whether
1273 smiley functions are not overridden by `smiley').")
1275 (defcustom gnus-treat-display-face
1276 (and (not noninteractive)
1277 (or (and (fboundp 'image-type-available-p)
1278 (image-type-available-p 'png))
1279 (and (featurep 'xemacs)
1282 "Display Face headers.
1283 Valid values are nil, t, `head', `last', an integer or a predicate.
1284 See Info node `(gnus)Customizing Articles' and Info node
1285 `(gnus)X-Face' for details."
1286 :group 'gnus-article-treat
1288 :link '(custom-manual "(gnus)Customizing Articles")
1289 :link '(custom-manual "(gnus)X-Face")
1290 :type gnus-article-treat-head-custom)
1291 (put 'gnus-treat-display-face 'highlight t)
1293 (defcustom gnus-treat-display-smileys
1294 (if (and (not noninteractive)
1295 (or (and (featurep 'xemacs)
1297 (gnus-image-type-available-p 'xpm)
1298 (gnus-image-type-available-p 'pbm)
1299 (and (not (featurep 'xemacs))
1301 (module-installed-p 'smiley-mule))))
1305 Valid values are nil, t, `head', `last', an integer or a predicate.
1306 See Info node `(gnus)Customizing Articles' and Info node
1307 `(gnus)Smileys' for details."
1308 :group 'gnus-article-treat
1310 :link '(custom-manual "(gnus)Customizing Articles")
1311 :link '(custom-manual "(gnus)Smileys")
1312 :type gnus-article-treat-custom)
1313 (put 'gnus-treat-display-smileys 'highlight t)
1315 (defcustom gnus-treat-from-picon
1316 (if (and (gnus-image-type-available-p 'xpm)
1317 (gnus-picons-installed-p))
1319 "Display picons in the From header.
1320 Valid values are nil, t, `head', `last', an integer or a predicate.
1321 See Info node `(gnus)Customizing Articles' and Info node
1322 `(gnus)Picons' for details."
1323 :group 'gnus-article-treat
1325 :link '(custom-manual "(gnus)Customizing Articles")
1326 :link '(custom-manual "(gnus)Picons")
1327 :type gnus-article-treat-head-custom)
1328 (put 'gnus-treat-from-picon 'highlight t)
1330 (defcustom gnus-treat-mail-picon
1331 (if (and (gnus-image-type-available-p 'xpm)
1332 (gnus-picons-installed-p))
1334 "Display picons in To and Cc headers.
1335 Valid values are nil, t, `head', `last', an integer or a predicate.
1336 See Info node `(gnus)Customizing Articles' and Info node
1337 `(gnus)Picons' for details."
1338 :group 'gnus-article-treat
1340 :link '(custom-manual "(gnus)Customizing Articles")
1341 :link '(custom-manual "(gnus)Picons")
1342 :type gnus-article-treat-head-custom)
1343 (put 'gnus-treat-mail-picon 'highlight t)
1345 (defcustom gnus-treat-newsgroups-picon
1346 (if (and (gnus-image-type-available-p 'xpm)
1347 (gnus-picons-installed-p))
1349 "Display picons in the Newsgroups and Followup-To headers.
1350 Valid values are nil, t, `head', `last', an integer or a predicate.
1351 See Info node `(gnus)Customizing Articles' and Info node
1352 `(gnus)Picons' for details."
1353 :group 'gnus-article-treat
1355 :link '(custom-manual "(gnus)Customizing Articles")
1356 :link '(custom-manual "(gnus)Picons")
1357 :type gnus-article-treat-head-custom)
1358 (put 'gnus-treat-newsgroups-picon 'highlight t)
1360 (defcustom gnus-treat-body-boundary
1361 (if (or gnus-treat-newsgroups-picon
1362 gnus-treat-mail-picon
1363 gnus-treat-from-picon)
1365 "Draw a boundary at the end of the headers.
1366 Valid values are nil and `head'.
1367 See Info node `(gnus)Customizing Articles' for details."
1369 :group 'gnus-article-treat
1370 :link '(custom-manual "(gnus)Customizing Articles")
1371 :type gnus-article-treat-head-custom)
1373 (defcustom gnus-treat-capitalize-sentences nil
1374 "Capitalize sentence-starting words.
1375 Valid values are nil, t, `head', `last', an integer or a predicate.
1376 See Info node `(gnus)Customizing Articles' for details."
1378 :group 'gnus-article-treat
1379 :link '(custom-manual "(gnus)Customizing Articles")
1380 :type gnus-article-treat-custom)
1382 (defcustom gnus-treat-wash-html nil
1384 Valid values are nil, t, `head', `last', an integer or a predicate.
1385 See Info node `(gnus)Customizing Articles' for details."
1386 :group 'gnus-article-treat
1387 :link '(custom-manual "(gnus)Customizing Articles")
1388 :type gnus-article-treat-custom)
1390 (defcustom gnus-treat-fill-long-lines nil
1392 Valid values are nil, t, `head', `last', an integer or a predicate.
1393 See Info node `(gnus)Customizing Articles' for details."
1394 :group 'gnus-article-treat
1395 :link '(custom-manual "(gnus)Customizing Articles")
1396 :type gnus-article-treat-custom)
1398 (defcustom gnus-treat-play-sounds nil
1400 Valid values are nil, t, `head', `last', an integer or a predicate.
1401 See Info node `(gnus)Customizing Articles' for details."
1403 :group 'gnus-article-treat
1404 :link '(custom-manual "(gnus)Customizing Articles")
1405 :type gnus-article-treat-custom)
1407 (defcustom gnus-treat-decode-article-as-default-mime-charset nil
1408 "Decode an article as `default-mime-charset'. For instance, if you want to
1409 attempt to decode an article even if the value of `gnus-show-mime' is nil,
1410 you could set this variable to something like: nil for don't decode, t for
1411 decode the body, '(or header t) for the whole article, etc."
1412 :group 'gnus-article-treat
1413 :type '(radio (const :tag "Off" nil)
1414 (const :tag "Decode body" t)
1415 (const :tag "Decode all" (or head t))))
1417 (defcustom gnus-treat-translate nil
1418 "Translate articles from one language to another.
1419 Valid values are nil, t, `head', `last', an integer or a predicate.
1420 See Info node `(gnus)Customizing Articles' for details."
1422 :group 'gnus-article-treat
1423 :link '(custom-manual "(gnus)Customizing Articles")
1424 :type gnus-article-treat-custom)
1426 (defcustom gnus-treat-x-pgp-sig nil
1428 To automatically treat X-PGP-Sig, set it to head.
1429 Valid values are nil, t, `head', `last', an integer or a predicate.
1430 See Info node `(gnus)Customizing Articles' for details."
1431 :group 'gnus-article-treat
1432 :group 'mime-security
1433 :type gnus-article-treat-custom)
1435 (defcustom gnus-treat-monafy nil
1436 "Display body part with mona font.
1437 Valid values are nil, t, `head', `last', an integer or a predicate.
1438 See Info node `(gnus)Customizing Articles' for details."
1439 :group 'gnus-article-treat
1440 :group 'mime-security
1441 :link '(custom-manual "(gnus)Customizing Articles")
1442 :type gnus-article-treat-custom)
1444 (defvar gnus-article-encrypt-protocol-alist
1445 '(("PGP" . mml2015-self-encrypt)))
1447 ;; Set to nil if more than one protocol added to
1448 ;; gnus-article-encrypt-protocol-alist.
1449 (defcustom gnus-article-encrypt-protocol "PGP"
1450 "The protocol used for encrypt articles.
1451 It is a string, such as \"PGP\". If nil, ask user."
1453 :group 'mime-security)
1455 (defvar gnus-article-wash-function nil
1456 "Function used for converting HTML into text.")
1458 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1459 (mm-coding-system-p 'utf-8)
1460 (executable-find idna-program))
1461 "Whether IDNA decoding of headers is used when viewing messages.
1462 This requires GNU Libidn, and by default only enabled if it is found."
1463 :group 'gnus-article-headers
1466 (defcustom gnus-article-over-scroll nil
1467 "If non-nil, allow scrolling the article buffer even when there no more text."
1468 :group 'gnus-article
1471 ;;; Internal variables
1473 (defvar gnus-english-month-names
1474 '("January" "February" "March" "April" "May" "June" "July" "August"
1475 "September" "October" "November" "December"))
1477 (defvar gnus-button-regexp nil)
1478 (defvar gnus-button-marker-list nil)
1479 ;; Regexp matching any of the regexps from `gnus-button-alist'.
1481 (defvar gnus-button-last nil)
1482 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
1484 (defvar article-goto-body-goes-to-point-min-p nil)
1485 (defvar gnus-article-wash-types nil)
1486 (defvar gnus-article-emphasis-alist nil)
1487 (defvar gnus-article-image-alist nil)
1489 (defvar gnus-article-mime-handle-alist-1 nil)
1490 (defvar gnus-treatment-function-alist
1491 '((gnus-treat-decode-article-as-default-mime-charset
1492 gnus-article-decode-article-as-default-mime-charset)
1493 (gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1494 (gnus-treat-monafy gnus-article-monafy)
1495 (gnus-treat-strip-banner gnus-article-strip-banner)
1496 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1497 (gnus-treat-buttonize gnus-article-add-buttons)
1498 (gnus-treat-fill-article gnus-article-fill-cited-article)
1499 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1500 (gnus-treat-strip-cr gnus-article-remove-cr)
1501 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1502 (gnus-treat-date-ut gnus-article-date-ut)
1503 (gnus-treat-date-local gnus-article-date-local)
1504 (gnus-treat-date-english gnus-article-date-english)
1505 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1506 (gnus-treat-date-original gnus-article-date-original)
1507 (gnus-treat-date-user-defined gnus-article-date-user)
1508 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1509 (gnus-treat-display-face gnus-article-display-face)
1510 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1511 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1512 (gnus-treat-hide-signature gnus-article-hide-signature)
1513 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1514 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1515 (gnus-treat-strip-pem gnus-article-hide-pem)
1516 (gnus-treat-from-picon gnus-treat-from-picon)
1517 (gnus-treat-mail-picon gnus-treat-mail-picon)
1518 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1519 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1520 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1521 (gnus-treat-strip-trailing-blank-lines
1522 gnus-article-remove-trailing-blank-lines)
1523 (gnus-treat-strip-leading-blank-lines
1524 gnus-article-strip-leading-blank-lines)
1525 (gnus-treat-strip-multiple-blank-lines
1526 gnus-article-strip-multiple-blank-lines)
1527 (gnus-treat-overstrike gnus-article-treat-overstrike)
1528 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences)
1529 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1530 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1531 ;; Displaying X-Face should be done after unfolding headers
1532 ;; to protect bitmap lines.
1533 (gnus-treat-display-x-face gnus-article-display-x-face)
1534 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1535 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1536 (gnus-treat-display-smileys gnus-treat-smiley)
1537 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1538 (gnus-treat-wash-html gnus-article-wash-html)
1539 (gnus-treat-emphasize gnus-article-emphasize)
1540 (gnus-treat-hide-citation gnus-article-hide-citation)
1541 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1542 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1543 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1544 (gnus-treat-play-sounds gnus-earcon-display)))
1546 (defvar gnus-article-mime-handle-alist nil)
1547 (defvar article-lapsed-timer nil)
1548 (defvar gnus-article-current-summary nil)
1550 (defvar gnus-article-mode-syntax-table
1551 (let ((table (copy-syntax-table text-mode-syntax-table)))
1552 ;; This causes the citation match run O(2^n).
1553 ;; (modify-syntax-entry ?- "w" table)
1554 (modify-syntax-entry ?> ")<" table)
1555 (modify-syntax-entry ?< "(>" table)
1556 ;; make M-. in article buffers work for `foo' strings
1557 (modify-syntax-entry ?' " " table)
1558 (modify-syntax-entry ?` " " table)
1560 "Syntax table used in article mode buffers.
1561 Initialized from `text-mode-syntax-table.")
1563 (defvar gnus-save-article-buffer nil)
1565 (defvar gnus-article-mode-line-format-alist
1566 (nconc '((?w (gnus-article-wash-status) ?s)
1567 (?m (gnus-article-mime-part-status) ?s))
1568 gnus-summary-mode-line-format-alist))
1570 (defvar gnus-number-of-articles-to-be-saved nil)
1572 (defvar gnus-inhibit-hiding nil)
1574 (defvar gnus-article-edit-mode nil)
1576 ;;; Macros for dealing with the article buffer.
1578 (defmacro gnus-with-article-headers (&rest forms)
1580 (set-buffer gnus-article-buffer)
1582 (let ((inhibit-read-only t)
1583 (inhibit-point-motion-hooks t)
1584 (case-fold-search t))
1585 (article-narrow-to-head)
1588 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1589 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1591 (defmacro gnus-with-article-buffer (&rest forms)
1593 (set-buffer gnus-article-buffer)
1594 (let ((inhibit-read-only t))
1597 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1598 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1600 (defun gnus-article-goto-header (header)
1601 "Go to HEADER, which is a regular expression."
1602 (re-search-forward (concat "^\\(" header "\\):") nil t))
1604 (defsubst gnus-article-hide-text (b e props)
1605 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1606 (gnus-add-text-properties-when 'article-type nil b e props)
1607 (when (memq 'intangible props)
1609 (max (1- b) (point-min))
1610 b 'intangible (cddr (memq 'intangible props)))))
1612 (defsubst gnus-article-unhide-text (b e)
1613 "Remove hidden text properties from region between B and E."
1614 (remove-text-properties b e gnus-hidden-properties)
1615 (when (memq 'intangible gnus-hidden-properties)
1616 (put-text-property (max (1- b) (point-min))
1617 b 'intangible nil)))
1619 (defun gnus-article-hide-text-type (b e type)
1620 "Hide text of TYPE between B and E."
1621 (gnus-add-wash-type type)
1622 (gnus-article-hide-text
1623 b e (cons 'article-type (cons type gnus-hidden-properties))))
1625 (defun gnus-article-unhide-text-type (b e type)
1626 "Unhide text of TYPE between B and E."
1627 (gnus-delete-wash-type type)
1628 (remove-text-properties
1629 b e (cons 'article-type (cons type gnus-hidden-properties)))
1630 (when (memq 'intangible gnus-hidden-properties)
1631 (put-text-property (max (1- b) (point-min))
1632 b 'intangible nil)))
1634 (defun gnus-article-hide-text-of-type (type)
1635 "Hide text of TYPE in the current buffer."
1637 (let ((b (point-min))
1639 (while (setq b (text-property-any b e 'article-type type))
1640 (add-text-properties b (incf b) gnus-hidden-properties)))))
1642 (defun gnus-article-delete-text-of-type (type)
1643 "Delete text of TYPE in the current buffer."
1645 (let ((b (point-min)))
1646 (while (setq b (text-property-any b (point-max) 'article-type type))
1648 b (or (text-property-not-all b (point-max) 'article-type type)
1651 (defun gnus-article-delete-invisible-text ()
1652 "Delete all invisible text in the current buffer."
1654 (let ((b (point-min)))
1655 (while (setq b (text-property-any b (point-max) 'invisible t))
1657 b (or (text-property-not-all b (point-max) 'invisible t)
1660 (defun gnus-article-text-type-exists-p (type)
1661 "Say whether any text of type TYPE exists in the buffer."
1662 (text-property-any (point-min) (point-max) 'article-type type))
1664 (defsubst gnus-article-header-rank ()
1665 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1666 (let ((list gnus-sorted-header-list)
1669 (if (looking-at (car list))
1671 (setq list (cdr list))
1675 (defun article-hide-headers (&optional arg delete)
1676 "Hide unwanted headers and possibly sort them as well."
1677 (interactive (gnus-article-hidden-arg))
1678 ;; Lars said that this function might be inhibited.
1679 (if (gnus-article-check-hidden-text 'headers arg)
1681 ;; Show boring headers as well.
1682 (gnus-article-show-hidden-text 'boring-headers)
1683 (when (eq 1 (point-min))
1684 (set-window-start (get-buffer-window (current-buffer)) 1)))
1685 (unless gnus-inhibit-hiding
1686 (let ((inhibit-read-only t)
1687 (case-fold-search t)
1688 (max (1+ (length gnus-sorted-header-list)))
1689 (inhibit-point-motion-hooks t)
1690 (cur (current-buffer))
1691 ignored visible beg)
1693 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1694 ;; group parameters, so we should go to the summary buffer.
1697 (progn (set-buffer gnus-summary-buffer) t)
1699 (setq ignored (when (not gnus-visible-headers)
1700 (cond ((stringp gnus-ignored-headers)
1701 gnus-ignored-headers)
1702 ((listp gnus-ignored-headers)
1703 (mapconcat 'identity
1704 gnus-ignored-headers
1706 visible (cond ((stringp gnus-visible-headers)
1707 gnus-visible-headers)
1708 ((and gnus-visible-headers
1709 (listp gnus-visible-headers))
1710 (mapconcat 'identity
1711 gnus-visible-headers
1715 ;; First we narrow to just the headers.
1716 (article-narrow-to-head)
1717 ;; Hide any "From " lines at the beginning of (mail) articles.
1718 (while (looking-at "From ")
1722 (delete-region (point-min) (point))
1723 (gnus-article-hide-text (point-min) (point)
1724 (nconc (list 'article-type 'headers)
1725 gnus-hidden-properties))))
1726 ;; Then treat the rest of the header lines.
1727 ;; Then we use the two regular expressions
1728 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1729 ;; select which header lines is to remain visible in the
1731 (while (re-search-forward "^[^ \t:]*:" nil t)
1733 ;; Mark the rank of the header.
1735 (point) (1+ (point)) 'message-rank
1736 (if (or (and visible (looking-at visible))
1738 (not (looking-at ignored))))
1739 (gnus-article-header-rank)
1742 (message-sort-headers-1)
1743 (when (setq beg (text-property-any
1744 (point-min) (point-max) 'message-rank (+ 2 max)))
1745 ;; We delete or make invisible the unwanted headers.
1746 (gnus-add-wash-type 'headers)
1749 (add-text-properties
1750 (point-min) (+ 5 (point-min))
1751 '(article-type headers dummy-invisible t))
1752 (delete-region beg (point-max)))
1753 (gnus-article-hide-text-type beg (point-max) 'headers)))))))))
1755 (defun article-hide-boring-headers (&optional arg)
1756 "Toggle hiding of headers that aren't very interesting.
1757 If given a negative prefix, always show; if given a positive prefix,
1759 (interactive (gnus-article-hidden-arg))
1760 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1761 (not gnus-show-all-headers))
1764 (let ((inhibit-read-only t)
1765 (list gnus-boring-article-headers)
1766 (inhibit-point-motion-hooks t)
1768 (article-narrow-to-head)
1770 (setq elem (pop list))
1771 (goto-char (point-min))
1773 ;; Hide empty headers.
1775 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1777 (gnus-article-hide-text-type
1781 (if (re-search-forward "^[^ \t]" nil t)
1785 ;; Hide boring Newsgroups header.
1786 ((eq elem 'newsgroups)
1787 (when (gnus-string-equal
1788 (gnus-fetch-field "newsgroups")
1789 (gnus-group-real-name
1790 (if (boundp 'gnus-newsgroup-name)
1793 (gnus-article-hide-header "newsgroups")))
1794 ((eq elem 'to-address)
1795 (let ((to (message-fetch-field "to"))
1797 (gnus-parameter-to-address
1798 (if (boundp 'gnus-newsgroup-name)
1799 gnus-newsgroup-name ""))))
1800 (when (and to to-address
1803 ;; only one address in To
1804 (nth 1 (mail-extract-address-components to))
1806 (gnus-article-hide-header "to"))))
1808 (let ((to (message-fetch-field "to"))
1810 (gnus-parameter-to-list
1811 (if (boundp 'gnus-newsgroup-name)
1812 gnus-newsgroup-name ""))))
1813 (when (and to to-list
1816 ;; only one address in To
1817 (nth 1 (mail-extract-address-components to))
1819 (gnus-article-hide-header "to"))))
1821 (let ((cc (message-fetch-field "cc"))
1823 (gnus-parameter-to-list
1824 (if (boundp 'gnus-newsgroup-name)
1825 gnus-newsgroup-name ""))))
1826 (when (and cc to-list
1829 ;; only one address in CC
1830 (nth 1 (mail-extract-address-components cc))
1832 (gnus-article-hide-header "cc"))))
1833 ((eq elem 'followup-to)
1834 (when (gnus-string-equal
1835 (message-fetch-field "followup-to")
1836 (message-fetch-field "newsgroups"))
1837 (gnus-article-hide-header "followup-to")))
1838 ((eq elem 'reply-to)
1839 (if (gnus-group-find-parameter
1840 gnus-newsgroup-name 'broken-reply-to)
1841 (gnus-article-hide-header "reply-to")
1842 (let ((from (message-fetch-field "from"))
1843 (reply-to (message-fetch-field "reply-to")))
1850 (lambda (x) (downcase (cadr x)))
1851 (mail-extract-address-components from t))
1854 (lambda (x) (downcase (cadr x)))
1855 (mail-extract-address-components reply-to t))
1857 (gnus-article-hide-header "reply-to")))))
1859 (let ((date (message-fetch-field "date")))
1861 (< (days-between (current-time-string) date)
1863 (gnus-article-hide-header "date"))))
1865 (let ((to (message-fetch-field "to"))
1866 (cc (message-fetch-field "cc")))
1867 (when (> (length to) 1024)
1868 (gnus-article-hide-header "to"))
1869 (when (> (length cc) 1024)
1870 (gnus-article-hide-header "cc"))))
1874 (goto-char (point-min))
1875 (while (re-search-forward "^to:" nil t)
1876 (setq to-count (1+ to-count)))
1877 (when (> to-count 1)
1878 (while (> to-count 0)
1879 (goto-char (point-min))
1881 (re-search-forward "^to:" nil nil to-count)
1883 (narrow-to-region (point) (point-max))
1884 (gnus-article-hide-header "to"))
1885 (setq to-count (1- to-count))))
1886 (goto-char (point-min))
1887 (while (re-search-forward "^cc:" nil t)
1888 (setq cc-count (1+ cc-count)))
1889 (when (> cc-count 1)
1890 (while (> cc-count 0)
1891 (goto-char (point-min))
1893 (re-search-forward "^cc:" nil nil cc-count)
1895 (narrow-to-region (point) (point-max))
1896 (gnus-article-hide-header "cc"))
1897 (setq cc-count (1- cc-count)))))))))))))
1899 (defun gnus-article-hide-header (header)
1901 (goto-char (point-min))
1902 (when (re-search-forward (concat "^" header ":") nil t)
1903 (gnus-article-hide-text-type
1907 (if (re-search-forward "^[^ \t]" nil t)
1912 (defvar gnus-article-normalized-header-length 40
1913 "Length of normalized headers.")
1915 (defun article-normalize-headers ()
1916 "Make all header lines 40 characters long."
1918 (let ((inhibit-read-only t)
1922 (article-narrow-to-head)
1925 ((< (setq column (- (point-at-eol) (point)))
1926 gnus-article-normalized-header-length)
1928 (insert (make-string
1929 (- gnus-article-normalized-header-length column)
1931 ((> column gnus-article-normalized-header-length)
1932 (gnus-put-text-property
1934 (forward-char gnus-article-normalized-header-length)
1941 (forward-line 1))))))
1943 (defun article-treat-dumbquotes ()
1944 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
1945 Note that this function guesses whether a character is a sm*rtq**t* or
1946 not, so it should only be used interactively.
1948 Sm*rtq**t*s are M****s***'s unilateral extension to the
1949 iso-8859-1 character map in an attempt to provide more quoting
1950 characters. If you see something like \\222 or \\264 where
1951 you're expecting some kind of apostrophe or quotation mark, then
1954 (article-translate-strings gnus-article-dumbquotes-map))
1956 (defun article-translate-characters (from to)
1957 "Translate all characters in the body of the article according to FROM and TO.
1958 FROM is a string of characters to translate from; to is a string of
1959 characters to translate to."
1961 (when (article-goto-body)
1962 (let ((inhibit-read-only t)
1963 (x (make-string 225 ?x))
1965 (while (< (incf i) (length x))
1968 (while (< i (length from))
1969 (aset x (aref from i) (aref to i))
1971 (translate-region (point) (point-max) x)))))
1973 (defun article-translate-strings (map)
1974 "Translate all string in the body of the article according to MAP.
1975 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1977 (when (article-goto-body)
1978 (let ((inhibit-read-only t)
1980 (while (setq elem (pop map))
1982 (while (search-forward (car elem) nil t)
1983 (replace-match (cadr elem)))))))))
1985 (defun article-treat-overstrike ()
1986 "Translate overstrikes into bold text."
1989 (when (article-goto-body)
1990 (let ((inhibit-read-only t))
1991 (while (search-forward "\b" nil t)
1992 (let ((next (char-after))
1996 previous (char-after))
2000 ;; We do the boldification/underlining by hiding the
2001 ;; overstrikes and putting the proper text property
2005 (gnus-article-hide-text-type start (point) 'overstrike)
2006 (put-text-property (point) end 'face 'bold))
2008 (gnus-article-hide-text-type
2009 (1- (point)) (1+ (point)) 'overstrike)
2011 start (1- (point)) 'face 'underline))
2013 (gnus-article-hide-text-type start (point) 'overstrike)
2015 (point) end 'face 'underline)))))))))
2017 (defun article-treat-ansi-sequences ()
2018 "Translate ANSI SGR control sequences into overlays or extents."
2021 (when (article-goto-body)
2022 (let ((inhibit-read-only t))
2023 (ansi-color-apply-on-region (point) (point-max))))))
2025 (defun gnus-article-treat-unfold-headers ()
2026 "Unfold folded message headers.
2027 Only the headers that fit into the current window width will be
2030 (gnus-with-article-headers
2034 (mail-header-narrow-to-field)
2035 (let ((header (buffer-string)))
2038 (goto-char (point-min))
2039 (while (re-search-forward "\n[\t ]" nil t)
2040 (replace-match " " t t)))
2041 (setq length (- (point-max) (point-min) 1)))
2042 (when (< length (window-width))
2043 (while (re-search-forward "\n[\t ]" nil t)
2044 (replace-match " " t t)))
2045 (goto-char (point-max)))))))
2047 (defun gnus-article-treat-fold-headers ()
2048 "Fold message headers."
2050 (gnus-with-article-headers
2053 (mail-header-narrow-to-field)
2054 (mail-header-fold-field)
2055 (goto-char (point-max))))))
2057 (defun gnus-treat-smiley ()
2058 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2060 (unless (featurep 'xemacs)
2061 (when (and (not gnus-article-should-use-smiley-mule)
2062 gnus-article-smiley-mule-loaded-p)
2063 (load "smiley" nil t)
2064 (setq gnus-article-smiley-mule-loaded-p nil))
2065 (when (and gnus-article-should-use-smiley-mule
2066 (not gnus-article-smiley-mule-loaded-p))
2067 (load "smiley-mule" nil t)
2068 (setq gnus-article-smiley-mule-loaded-p t)))
2069 (gnus-with-article-buffer
2070 (if (memq 'smiley gnus-article-wash-types)
2071 (gnus-delete-images 'smiley)
2073 (let ((images (smiley-region (point) (point-max))))
2075 (gnus-add-wash-type 'smiley)
2076 (dolist (image images)
2077 (gnus-add-image 'smiley image)))))))
2079 (defun gnus-article-remove-images ()
2080 "Remove all images from the article buffer."
2082 (gnus-with-article-buffer
2083 (dolist (elem gnus-article-image-alist)
2084 (gnus-delete-images (car elem)))))
2086 (defun gnus-article-treat-fold-newsgroups ()
2087 "Unfold folded message headers.
2088 Only the headers that fit into the current window width will be
2091 (gnus-with-article-headers
2092 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2094 (mail-header-narrow-to-field)
2095 (while (re-search-forward ", *" nil t)
2096 (replace-match ", " t t))
2097 (mail-header-fold-field)
2098 (goto-char (point-max))))))
2100 (defun gnus-article-treat-body-boundary ()
2101 "Place a boundary line at the end of the headers."
2103 (when (and gnus-body-boundary-delimiter
2104 (> (length gnus-body-boundary-delimiter) 0))
2105 (gnus-with-article-headers
2106 (goto-char (point-max))
2107 (let ((start (point)))
2108 (insert "X-Boundary: ")
2109 (gnus-add-text-properties start (point) '(invisible t intangible t))
2111 (while (>= (1- (window-width)) (length str))
2112 (setq str (concat str gnus-body-boundary-delimiter)))
2113 (substring str 0 (1- (window-width))))
2115 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2117 (defun article-fill-long-lines ()
2118 "Fill lines that are wider than the window width."
2121 (let ((inhibit-read-only t)
2122 (width (window-width (get-buffer-window (current-buffer)))))
2125 (let ((adaptive-fill-mode nil)) ;Why? -sm
2128 (when (>= (current-column) (min fill-column width))
2129 (narrow-to-region (min (1+ (point)) (point-max))
2131 (let ((goback (point-marker)))
2132 (fill-paragraph nil)
2133 (goto-char (marker-position goback)))
2135 (forward-line 1)))))))
2137 (defun article-capitalize-sentences ()
2138 "Capitalize the first word in each sentence."
2141 (let ((inhibit-read-only t)
2142 (paragraph-start "^[\n\^L]"))
2146 (forward-sentence)))))
2148 (defun article-remove-cr ()
2149 "Remove trailing CRs and then translate remaining CRs into LFs."
2152 (let ((inhibit-read-only t))
2153 (goto-char (point-min))
2154 (while (re-search-forward "\r+$" nil t)
2155 (replace-match "" t t))
2156 (goto-char (point-min))
2157 (while (search-forward "\r" nil t)
2158 (replace-match "\n" t t)))))
2160 (defun article-remove-trailing-blank-lines ()
2161 "Remove all trailing blank lines from the article."
2164 (let ((inhibit-read-only t))
2165 (goto-char (point-max))
2169 (while (and (not (bobp))
2170 (looking-at "^[ \t]*$")
2171 (not (gnus-annotation-in-region-p
2172 (point) (point-at-eol))))
2178 (defvar gnus-face-properties-alist))
2180 (defun article-display-face ()
2181 "Display any Face headers in the header."
2183 (let ((wash-face-p buffer-read-only))
2184 (gnus-with-article-headers
2185 ;; When displaying parts, this function can be called several times on
2186 ;; the same article, without any intended toggle semantic (as typing `W
2187 ;; D d' would have). So face deletion must occur only when we come from
2188 ;; an interactive command, that is when the *Article* buffer is
2190 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2191 (gnus-delete-images 'face)
2194 (when (and wash-face-p
2196 (goto-char (point-min))
2197 (not (re-search-forward "^Face:[\t ]*" nil t)))
2198 (gnus-buffer-live-p gnus-original-article-buffer))
2199 (set-buffer gnus-original-article-buffer))
2201 (mail-narrow-to-head)
2202 (while (gnus-article-goto-header "Face")
2203 (setq faces (nconc faces (list (mail-header-field-value)))))))
2204 (while (setq face (pop faces))
2205 (let ((png (gnus-convert-face-to-png face))
2209 (apply 'gnus-create-image png 'png t
2210 (cdr (assq 'png gnus-face-properties-alist))))
2211 (gnus-article-goto-header "from")
2213 (insert "From: [no `from' set]\n")
2215 (gnus-add-wash-type 'face)
2216 (gnus-add-image 'face image)
2217 (gnus-put-image image nil 'face))))))
2220 (defun article-display-x-face (&optional force)
2221 "Look for an X-Face header and display it if present."
2222 (interactive (list 'force))
2223 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2224 (gnus-with-article-headers
2225 ;; Delete the old process, if any.
2226 (when (process-status "article-x-face")
2227 (delete-process "article-x-face"))
2228 ;; See the comment in `article-display-face'.
2229 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2230 ;; We have already displayed X-Faces, so we remove them
2232 (gnus-delete-images 'xface)
2234 (let (x-faces from face)
2236 (when (and wash-face-p
2238 (goto-char (point-min))
2239 (not (re-search-forward
2240 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2241 (gnus-buffer-live-p gnus-original-article-buffer))
2242 ;; If type `W f', use gnus-original-article-buffer,
2243 ;; otherwise use the current buffer because displaying
2244 ;; RFC822 parts calls this function too.
2245 (set-buffer gnus-original-article-buffer))
2247 (mail-narrow-to-head)
2248 (while (gnus-article-goto-header "X-Face")
2249 (push (mail-header-field-value) x-faces))
2250 (setq from (message-fetch-field "from"))))
2251 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2252 ;; single external face.
2253 (when (stringp gnus-article-x-face-command)
2254 (setq x-faces (list (car x-faces))))
2255 (while (and (setq face (pop x-faces))
2256 gnus-article-x-face-command
2258 ;; Check whether this face is censored.
2259 (not gnus-article-x-face-too-ugly)
2260 (and gnus-article-x-face-too-ugly from
2261 (not (string-match gnus-article-x-face-too-ugly
2263 ;; We display the face.
2264 (cond ((stringp gnus-article-x-face-command)
2265 ;; The command is a string, so we interpret the command
2266 ;; as a, well, command, and fork it off.
2267 (let ((process-connection-type nil))
2268 (process-kill-without-query
2270 "article-x-face" nil shell-file-name
2271 shell-command-switch gnus-article-x-face-command))
2274 (process-send-region "article-x-face"
2275 (point-min) (point-max)))
2276 (process-send-eof "article-x-face")))
2277 ((functionp gnus-article-x-face-command)
2278 ;; The command is a lisp function, so we call it.
2279 (funcall gnus-article-x-face-command face))
2281 (error "%s is not a function"
2282 gnus-article-x-face-command)))))))))
2284 (defun article-decode-mime-words ()
2285 "Decode all MIME-encoded words in the article."
2287 (gnus-with-article-buffer
2288 (let ((inhibit-point-motion-hooks t)
2289 (mail-parse-charset gnus-newsgroup-charset)
2290 (mail-parse-ignored-charsets
2291 (with-current-buffer gnus-summary-buffer
2292 gnus-newsgroup-ignored-charsets)))
2293 (mail-decode-encoded-word-region (point-min) (point-max)))))
2295 (defun article-decode-charset (&optional prompt)
2296 "Decode charset-encoded text in the article.
2297 If PROMPT (the prefix), prompt for a coding system to use."
2299 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2300 (inhibit-read-only t)
2301 (mail-parse-charset gnus-newsgroup-charset)
2302 (mail-parse-ignored-charsets
2303 (save-excursion (condition-case nil
2304 (set-buffer gnus-summary-buffer)
2306 gnus-newsgroup-ignored-charsets))
2307 ct cte ctl charset format)
2310 (article-narrow-to-head)
2311 (setq ct (message-fetch-field "Content-Type" t)
2312 cte (message-fetch-field "Content-Transfer-Encoding" t)
2313 ctl (and ct (ignore-errors
2314 (mail-header-parse-content-type ct)))
2317 (mm-read-coding-system "Charset to decode: "))
2319 (mail-content-type-get ctl 'charset)))
2320 format (and ctl (mail-content-type-get ctl 'format)))
2322 (setq cte (mail-header-strip cte)))
2323 (if (and ctl (not (string-match "/" (car ctl))))
2325 (goto-char (point-max)))
2328 (narrow-to-region (point) (point-max))
2329 (when (and (eq mail-parse-charset 'gnus-decoded)
2330 (eq (mm-body-7-or-8) '8bit))
2331 ;; The text code could have been decoded.
2332 (setq charset mail-parse-charset))
2333 (when (and (or (not ctl)
2334 (equal (car ctl) "text/plain"))
2335 (not format)) ;; article with format will decode later.
2337 charset (and cte (intern (downcase
2338 (gnus-strip-whitespace cte))))
2341 (defun article-decode-encoded-words ()
2342 "Remove encoded-word encoding from headers."
2343 (let ((charset (save-excursion
2344 (set-buffer gnus-summary-buffer)
2345 default-mime-charset))
2346 (inhibit-read-only t))
2347 (mime-decode-header-in-buffer charset)))
2349 (defun article-decode-group-name ()
2350 "Decode group names in `Newsgroups:'."
2351 (let ((inhibit-point-motion-hooks t)
2352 (inhibit-read-only t)
2353 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2354 (when (and (or gnus-group-name-charset-method-alist
2355 gnus-group-name-charset-group-alist)
2356 (gnus-buffer-live-p gnus-original-article-buffer))
2358 (article-narrow-to-head)
2359 (with-current-buffer gnus-original-article-buffer
2360 (goto-char (point-min)))
2361 (while (re-search-forward
2362 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2363 (replace-match (save-match-data
2364 (gnus-decode-newsgroups
2365 ;; XXX how to use data in article buffer?
2366 (with-current-buffer gnus-original-article-buffer
2368 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2371 gnus-newsgroup-name method))
2373 (goto-char (point-min))
2374 (with-current-buffer gnus-original-article-buffer
2375 (goto-char (point-min)))
2376 (while (re-search-forward
2377 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2378 (replace-match (save-match-data
2379 (gnus-decode-newsgroups
2380 ;; XXX how to use data in article buffer?
2381 (with-current-buffer gnus-original-article-buffer
2383 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2386 gnus-newsgroup-name method))
2389 (autoload 'idna-to-unicode "idna")
2391 (defun article-decode-idna-rhs ()
2392 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2395 (let ((inhibit-point-motion-hooks t)
2396 (inhibit-read-only t))
2397 (article-narrow-to-head)
2398 (goto-char (point-min))
2399 (while (re-search-forward "@.*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2401 (when (save-match-data
2402 (and (setq ace (match-string 1))
2404 (and (re-search-backward "^[^ \t]" nil t)
2405 (looking-at "From\\|To\\|Cc")))
2406 (setq unicode (idna-to-unicode ace))))
2407 (unless (string= ace unicode)
2408 (replace-match unicode nil nil nil 1)))))))))
2410 (defun article-de-quoted-unreadable (&optional force read-charset)
2411 "Translate a quoted-printable-encoded article.
2412 If FORCE, decode the article whether it is marked as quoted-printable
2414 If READ-CHARSET, ask for a coding system."
2415 (interactive (list 'force current-prefix-arg))
2417 (let ((inhibit-read-only t) type charset)
2418 (if (gnus-buffer-live-p gnus-original-article-buffer)
2419 (with-current-buffer gnus-original-article-buffer
2421 (gnus-fetch-field "content-transfer-encoding"))
2422 (let* ((ct (gnus-fetch-field "content-type"))
2425 (mail-header-parse-content-type ct)))))
2426 (setq charset (and ctl
2427 (mail-content-type-get ctl 'charset)))
2428 (if (stringp charset)
2429 (setq charset (intern (downcase charset)))))))
2431 (setq charset (mm-read-coding-system "Charset: " charset)))
2433 (setq charset gnus-newsgroup-charset))
2435 (and type (let ((case-fold-search t))
2436 (string-match "quoted-printable" type))))
2438 (quoted-printable-decode-region
2439 (point) (point-max) (mm-charset-to-coding-system charset))))))
2441 (defun article-de-base64-unreadable (&optional force read-charset)
2442 "Translate a base64 article.
2443 If FORCE, decode the article whether it is marked as base64 not.
2444 If READ-CHARSET, ask for a coding system."
2445 (interactive (list 'force current-prefix-arg))
2447 (let ((inhibit-read-only t) type charset)
2448 (if (gnus-buffer-live-p gnus-original-article-buffer)
2449 (with-current-buffer gnus-original-article-buffer
2451 (gnus-fetch-field "content-transfer-encoding"))
2452 (let* ((ct (gnus-fetch-field "content-type"))
2455 (mail-header-parse-content-type ct)))))
2456 (setq charset (and ctl
2457 (mail-content-type-get ctl 'charset)))
2458 (if (stringp charset)
2459 (setq charset (intern (downcase charset)))))))
2461 (setq charset (mm-read-coding-system "Charset: " charset)))
2463 (setq charset gnus-newsgroup-charset))
2465 (and type (let ((case-fold-search t))
2466 (string-match "base64" type))))
2469 (narrow-to-region (point) (point-max))
2470 (base64-decode-region (point-min) (point-max))
2471 (mm-decode-coding-region
2472 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2477 (defun article-decode-HZ ()
2478 "Translate a HZ-encoded article."
2482 (let ((inhibit-read-only t))
2483 (rfc1843-decode-region (point-min) (point-max)))))
2485 (defun article-unsplit-urls ()
2486 "Remove the newlines that some other mailers insert into URLs."
2489 (let ((inhibit-read-only t))
2490 (goto-char (point-min))
2491 (while (re-search-forward
2492 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2493 (replace-match "\\1\\3" t)))
2494 (when (interactive-p)
2495 (gnus-treat-article nil))))
2498 (defun article-wash-html (&optional read-charset)
2499 "Format an HTML article.
2500 If READ-CHARSET, ask for a coding system."
2503 (let ((inhibit-read-only t)
2505 (when (gnus-buffer-live-p gnus-original-article-buffer)
2506 (with-current-buffer gnus-original-article-buffer
2507 (let* ((ct (gnus-fetch-field "content-type"))
2510 (mail-header-parse-content-type ct)))))
2511 (setq charset (and ctl
2512 (mail-content-type-get ctl 'charset)))
2513 (when (stringp charset)
2514 (setq charset (intern (downcase charset)))))))
2516 (setq charset (mm-read-coding-system "Charset: " charset)))
2518 (setq charset gnus-newsgroup-charset))
2520 (save-window-excursion
2522 (narrow-to-region (point) (point-max))
2523 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2524 (entry (assq func mm-text-html-washer-alist)))
2526 (setq func (cdr entry)))
2531 (apply (car func) (cdr func))))))))))
2533 (defun gnus-article-wash-html-with-w3 ()
2534 "Wash the current buffer with w3."
2536 (let ((w3-strict-width (window-width))
2537 (url-standalone-mode t)
2538 (url-gateway-unplugged t)
2539 (w3-honor-stylesheets nil))
2541 (w3-region (point-min) (point-max))
2544 (defun gnus-article-wash-html-with-w3m ()
2545 "Wash the current buffer with emacs-w3m."
2548 (narrow-to-region (point) (point-max))
2549 (let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp)
2550 w3m-force-redisplay)
2551 (w3m-region (point-min) (point-max)))
2552 (when (and mm-inline-text-html-with-w3m-keymap
2553 (boundp 'w3m-minor-mode-map)
2555 (add-text-properties
2556 (point-min) (point-max)
2557 (list 'keymap w3m-minor-mode-map
2558 ;; Put the mark meaning this part was rendered by emacs-w3m.
2559 'mm-inline-text-html-with-w3m t)))))
2561 (defun article-hide-list-identifiers ()
2562 "Remove list identifies from the Subject header.
2563 The `gnus-list-identifiers' variable specifies what to do."
2565 (let ((inhibit-point-motion-hooks t)
2566 (regexp (if (consp gnus-list-identifiers)
2567 (mapconcat 'identity gnus-list-identifiers " *\\|")
2568 gnus-list-identifiers))
2569 (inhibit-read-only t))
2573 (article-narrow-to-head)
2574 (goto-char (point-min))
2575 (while (re-search-forward
2576 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2578 (delete-region (match-beginning 2) (match-end 0))
2579 (beginning-of-line))
2580 (when (re-search-forward
2581 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2582 (delete-region (match-beginning 1) (match-end 1))))))))
2584 (defun article-hide-pem (&optional arg)
2585 "Toggle hiding of any PEM headers and signatures in the current article.
2586 If given a negative prefix, always show; if given a positive prefix,
2588 (interactive (gnus-article-hidden-arg))
2589 (unless (gnus-article-check-hidden-text 'pem arg)
2591 (let ((inhibit-read-only t) end)
2592 (goto-char (point-min))
2593 ;; Hide the horrendously ugly "header".
2594 (when (and (search-forward
2595 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2597 (setq end (1+ (match-beginning 0))))
2598 (gnus-add-wash-type 'pem)
2599 (gnus-article-hide-text-type
2601 (if (search-forward "\n\n" nil t)
2605 ;; Hide the trailer as well
2606 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2608 (gnus-article-hide-text-type
2609 (match-beginning 0) (match-end 0) 'pem)))))))
2611 (defun article-strip-banner ()
2612 "Strip the banners specified by the `banner' group parameter and by
2613 `gnus-article-address-banner-alist'."
2617 (let ((inhibit-point-motion-hooks t))
2618 (when (gnus-parameter-banner gnus-newsgroup-name)
2619 (article-really-strip-banner
2620 (gnus-parameter-banner gnus-newsgroup-name)))
2621 (when gnus-article-address-banner-alist
2622 ;; It is necessary to encode from fields before checking,
2623 ;; because `mail-header-parse-addresses' does not work
2624 ;; (reliably) on decoded headers. And more, it is
2625 ;; impossible to use `gnus-fetch-original-field' here,
2626 ;; because `article-strip-banner' may be called in draft
2627 ;; buffers to preview them.
2628 (let ((from (save-restriction
2630 (article-narrow-to-head)
2631 (mail-fetch-field "from"))))
2634 (caar (mail-header-parse-addresses
2635 (mail-encode-encoded-word-string from)))))
2637 (dolist (pair gnus-article-address-banner-alist)
2638 (when (string-match (car pair) from)
2640 (article-really-strip-banner (cdr pair)))))))))))))
2642 (defun article-really-strip-banner (banner)
2643 "Strip the banner specified by the argument."
2646 (let ((inhibit-point-motion-hooks t)
2647 (gnus-signature-limit nil)
2648 (inhibit-read-only t))
2651 ((eq banner 'signature)
2652 (when (gnus-article-narrow-to-signature)
2655 (delete-region (point) (point-max))))
2657 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2658 (while (re-search-forward banner nil t)
2659 (delete-region (match-beginning 0) (match-end 0)))))
2661 (while (re-search-forward banner nil t)
2662 (delete-region (match-beginning 0) (match-end 0)))))))))
2664 (defun article-babel ()
2665 "Translate article using an online translation service."
2668 (gnus-with-article-buffer
2669 (when (article-goto-body)
2670 (let* ((start (point))
2672 (orig (buffer-substring start end))
2673 (trans (babel-as-string orig)))
2675 (narrow-to-region start end)
2676 (delete-region start end)
2679 (defun article-hide-signature (&optional arg)
2680 "Hide the signature in the current article.
2681 If given a negative prefix, always show; if given a positive prefix,
2683 (interactive (gnus-article-hidden-arg))
2689 (article-goto-body))
2690 (goto-char (point-min)))
2691 (unless (gnus-article-check-hidden-text 'signature arg)
2692 (let ((inhibit-read-only t)
2694 (while (setq button (text-property-any button (point-max)
2696 'gnus-signature-toggle))
2697 (setq button (text-property-not-all button (point-max)
2699 'gnus-signature-toggle))
2700 (when (and button (not (eobp)))
2701 (gnus-article-hide-text-type
2703 (next-single-property-change (1+ button) 'mime-view-entity
2706 (gnus-set-mode-line 'article))
2708 (defun article-strip-headers-in-body ()
2709 "Strip offensive headers from bodies."
2713 (let ((case-fold-search t))
2714 (when (looking-at "x-no-archive:")
2715 (gnus-delete-line)))))
2717 (defun article-strip-leading-blank-lines ()
2718 "Remove all blank lines from the beginning of the article."
2721 (let ((inhibit-point-motion-hooks t)
2722 (inhibit-read-only t))
2723 (when (article-goto-body)
2724 (while (and (not (eobp))
2725 (looking-at "[ \t]*$"))
2726 (gnus-delete-line))))))
2728 (defun article-narrow-to-head ()
2729 "Narrow the buffer to the head of the message.
2730 Point is left at the beginning of the narrowed-to region."
2732 (goto-char (point-min))
2733 (if (search-forward "\n\n" nil 1)
2736 (goto-char (point-min)))
2738 (defun article-goto-body ()
2739 "Place point at the start of the body."
2740 (goto-char (point-min))
2742 ;; This variable is only bound when dealing with separate
2744 (article-goto-body-goes-to-point-min-p
2746 ((search-forward "\n\n" nil t)
2749 (goto-char (point-max))
2752 (defun article-strip-multiple-blank-lines ()
2753 "Replace consecutive blank lines with one empty line."
2756 (let ((inhibit-point-motion-hooks t)
2757 (inhibit-read-only t))
2758 ;; First make all blank lines empty.
2760 (while (re-search-forward "^[ \t]+$" nil t)
2761 (unless (gnus-annotation-in-region-p
2762 (match-beginning 0) (match-end 0))
2763 (replace-match "" nil t)))
2764 ;; Then replace multiple empty lines with a single empty line.
2766 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2767 (unless (gnus-annotation-in-region-p
2768 (match-beginning 0) (match-end 0))
2769 (delete-region (match-beginning 1) (match-end 1)))))))
2771 (defun article-strip-leading-space ()
2772 "Remove all white space from the beginning of the lines in the article."
2775 (let ((inhibit-point-motion-hooks t)
2776 (inhibit-read-only t))
2778 (while (re-search-forward "^[ \t]+" nil t)
2779 (replace-match "" t t)))))
2781 (defun article-strip-trailing-space ()
2782 "Remove all white space from the end of the lines in the article."
2785 (let ((inhibit-point-motion-hooks t)
2786 (inhibit-read-only t))
2788 (while (re-search-forward "[ \t]+$" nil t)
2789 (replace-match "" t t)))))
2791 (defun article-strip-blank-lines ()
2792 "Strip leading, trailing and multiple blank lines."
2794 (article-strip-leading-blank-lines)
2795 (article-remove-trailing-blank-lines)
2796 (article-strip-multiple-blank-lines))
2798 (defun article-strip-all-blank-lines ()
2799 "Strip all blank lines."
2802 (let ((inhibit-point-motion-hooks t)
2803 (inhibit-read-only t))
2805 (while (re-search-forward "^[ \t]*\n" nil t)
2806 (replace-match "" t t)))))
2808 (defun gnus-article-narrow-to-signature ()
2809 "Narrow to the signature; return t if a signature is found, else nil."
2810 (let ((inhibit-point-motion-hooks t))
2811 (when (gnus-article-search-signature)
2813 ;; Check whether we have some limits to what we consider
2814 ;; to be a signature.
2815 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2816 (list gnus-signature-limit)))
2818 (while (setq limit (pop limits))
2819 (if (or (and (integerp limit)
2820 (< (- (point-max) (point)) limit))
2822 (< (count-lines (point) (point-max)) limit))
2823 (and (functionp limit)
2825 (and (stringp limit)
2826 (not (re-search-forward limit nil t))))
2827 () ; This limit did not succeed.
2831 (narrow-to-region (point) (point-max))
2834 (defun gnus-article-search-signature ()
2835 "Search the current buffer for the signature separator.
2836 Put point at the beginning of the signature separator."
2837 (let ((cur (point)))
2838 (goto-char (point-max))
2839 (if (if (stringp gnus-signature-separator)
2840 (re-search-backward gnus-signature-separator nil t)
2841 (let ((seps gnus-signature-separator))
2843 (not (re-search-backward (car seps) nil t)))
2850 (defun gnus-article-hidden-arg ()
2851 "Return the current prefix arg as a number, or 0 if no prefix."
2852 (list (if current-prefix-arg
2853 (prefix-numeric-value current-prefix-arg)
2856 (defun gnus-article-check-hidden-text (type arg)
2857 "Return nil if hiding is necessary.
2858 Arg can be nil or a number. nil and positive means hide, negative
2859 means show, 0 means toggle."
2862 (let ((hide (gnus-article-hidden-text-p type)))
2868 (gnus-article-show-hidden-text type)
2871 (if (eq hide 'hidden)
2873 (gnus-article-show-hidden-text type)
2877 (defun gnus-article-hidden-text-p (type)
2878 "Say whether the current buffer contains hidden text of type TYPE."
2879 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2881 (not (get-text-property pos 'invisible))
2882 (not (get-text-property pos 'dummy-invisible)))
2884 (text-property-any (1+ pos) (point-max) 'article-type type)))
2889 (defun gnus-article-show-hidden-text (type &optional dummy)
2890 "Show all hidden text of type TYPE.
2891 Originally it is hide instead of DUMMY."
2892 (let ((inhibit-read-only t)
2893 (inhibit-point-motion-hooks t))
2894 (gnus-remove-text-properties-when
2896 (point-min) (point-max)
2897 (cons 'article-type (cons type
2898 gnus-hidden-properties)))
2899 (gnus-delete-wash-type type)))
2901 (defconst article-time-units
2902 `((year . ,(* 365.25 24 60 60))
2903 (week . ,(* 7 24 60 60))
2904 (day . ,(* 24 60 60))
2908 "Mapping from time units to seconds.")
2910 (defun gnus-article-forward-header ()
2911 "Move point to the start of the next header.
2912 If the current header is a continuation header, this can be several
2917 (if (looking-at "[ \t]+[^ \t]")
2921 (defun article-date-ut (&optional type highlight header)
2922 "Convert DATE date to universal time in the current article.
2923 If TYPE is `local', convert to local time; if it is `lapsed', output
2924 how much time has lapsed since DATE. For `lapsed', the value of
2925 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2926 should replace the \"Date:\" one, or should be added below it."
2927 (interactive (list 'ut t))
2928 (let* ((header (or header
2929 (and (eq 1 (point-min))
2930 (mail-header-date (save-excursion
2931 (set-buffer gnus-summary-buffer)
2932 gnus-current-headers)))
2933 (message-fetch-field "date")
2935 (date (if (vectorp header) (mail-header-date header)
2937 (inhibit-point-motion-hooks t)
2938 bface eface date-pos)
2939 (when (and date (not (string= date "")))
2942 (article-narrow-to-head)
2943 (when (or (and (eq type 'lapsed)
2944 gnus-article-date-lapsed-new-header
2945 ;; Attempt to get the face of X-Sent first.
2946 (re-search-forward "^X-Sent:[ \t]" nil t))
2947 (re-search-forward "^Date:[ \t]" nil t)
2948 ;; If Date is missing, try again for X-Sent.
2949 (re-search-forward "^X-Sent:[ \t]" nil t))
2950 (setq bface (get-text-property (point-at-bol) 'face)
2951 date (or (get-text-property (point-at-bol)
2954 eface (get-text-property (1- (point-at-eol))
2956 (let ((inhibit-read-only t))
2957 ;; Delete any old X-Sent headers.
2958 (when (setq date-pos
2959 (text-property-any (point-min) (point-max)
2960 'article-date-lapsed t))
2961 (goto-char (setq date-pos (set-marker (make-marker) date-pos)))
2962 (delete-region (match-beginning 0)
2963 (progn (forward-line 1) (point))))
2964 (goto-char (point-min))
2965 ;; Delete any old Date headers.
2966 (while (re-search-forward "^Date:[ \t]" nil t)
2968 (setq date-pos (match-beginning 0)))
2969 (unless (and (eq type 'lapsed)
2970 gnus-article-date-lapsed-new-header)
2971 (delete-region (match-beginning 0)
2972 (progn (message-next-header) (point)))))
2975 (goto-char date-pos)
2977 ;; Possibly, Date has been deleted.
2979 (when (and (eq type 'lapsed)
2980 gnus-article-date-lapsed-new-header
2981 (looking-at "Date:"))
2983 (goto-char (point-min)))
2984 (insert (article-make-date-line date type))
2985 (when (eq type 'lapsed)
2986 (put-text-property (point-at-bol) (point)
2987 'article-date-lapsed t))
2991 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2992 (add-text-properties (match-beginning 1) (1+ (match-end 1))
2993 (list 'original-date date 'face bface))
2994 (put-text-property (match-beginning 2) (match-end 2)
2997 (defun article-make-date-line (date type)
2998 "Return a DATE line of TYPE."
2999 (unless (memq type '(local ut original user iso8601 lapsed english))
3000 (error "Unknown conversion type: %s" type))
3002 (let ((time (date-to-time date)))
3004 ;; Convert to the local timezone.
3006 (concat "Date: " (message-make-date time)))
3007 ;; Convert to Universal Time.
3012 (let* ((e (parse-time-string date))
3013 (tm (apply 'encode-time e))
3015 (ls (- (cadr tm) (car (current-time-zone time)))))
3016 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
3017 ((> ls 65535) (list (1+ ms) (- ls 65536)))
3021 ;; Get the original date from the article.
3022 ((eq type 'original)
3023 (concat "Date: " (if (string-match "\n+$" date)
3024 (substring date 0 (match-beginning 0))
3026 ;; Let the user define the format.
3028 (let ((format (or (condition-case nil
3029 (with-current-buffer gnus-summary-buffer
3030 gnus-article-time-format)
3032 gnus-article-time-format)))
3033 (if (functionp format)
3034 (funcall format time)
3035 (concat "Date: " (format-time-string format time)))))
3038 (let ((tz (car (current-time-zone time))))
3041 (format-time-string "%Y%m%dT%H%M%S" time)
3042 (format "%s%02d%02d"
3043 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
3044 (/ (% (abs tz) 3600) 60)))))
3045 ;; Do an X-Sent lapsed format.
3047 ;; If the date is seriously mangled, the timezone functions are
3048 ;; liable to bug out, so we ignore all errors.
3049 (let* ((now (current-time))
3050 (real-time (subtract-time now time))
3051 (real-sec (and real-time
3052 (+ (* (float (car real-time)) 65536)
3054 (sec (and real-time (abs real-sec)))
3064 ;; This is a bit convoluted, but basically we go
3065 ;; through the time units for years, weeks, etc,
3066 ;; and divide things to see whether that results
3067 ;; in positive answers.
3070 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
3071 ;; The (remaining) seconds are too few to
3072 ;; be divided into this time unit.
3074 ;; It's big enough, so we output it.
3075 (setq sec (- sec (* num (cdr unit))))
3077 (concat (if prev ", " "") (int-to-string
3079 " " (symbol-name (car unit))
3080 (if (> num 1) "s" ""))
3082 article-time-units "")
3083 ;; If dates are odd, then it might appear like the
3084 ;; article was sent in the future.
3087 " in the future"))))))
3088 ;; Display the date in proper English
3090 (let ((dtime (decode-time time)))
3093 (number-to-string (nth 3 dtime))
3094 (let ((digit (% (nth 3 dtime) 10)))
3096 ((memq (nth 3 dtime) '(11 12 13)) "th")
3102 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3104 (number-to-string (nth 5 dtime))
3106 (format "%02d" (nth 2 dtime))
3108 (format "%02d" (nth 1 dtime)))))))
3110 (format "Date: %s (from T-gnus)" date))))
3112 (defun article-date-local (&optional highlight)
3113 "Convert the current article date to the local timezone."
3114 (interactive (list t))
3115 (article-date-ut 'local highlight))
3117 (defun article-date-english (&optional highlight)
3118 "Convert the current article date to something that is proper English."
3119 (interactive (list t))
3120 (article-date-ut 'english highlight))
3122 (defun article-date-original (&optional highlight)
3123 "Convert the current article date to what it was originally.
3124 This is only useful if you have used some other date conversion
3125 function and want to see what the date was before converting."
3126 (interactive (list t))
3127 (article-date-ut 'original highlight))
3129 (defun article-date-lapsed (&optional highlight)
3130 "Convert the current article date to time lapsed since it was sent."
3131 (interactive (list t))
3132 (article-date-ut 'lapsed highlight))
3134 (defun article-update-date-lapsed ()
3135 "Function to be run from a timer to update the lapsed time line."
3136 (let (deactivate-mark)
3141 (set-buffer (window-buffer w))
3142 (when (eq major-mode 'gnus-article-mode)
3143 (let ((mark (point-marker)))
3144 (goto-char (point-min))
3145 (when (re-search-forward "^X-Sent:" nil t)
3146 (article-date-lapsed t))
3147 (goto-char (marker-position mark))
3148 (move-marker mark nil))))
3151 (defun gnus-start-date-timer (&optional n)
3152 "Start a timer to update the X-Sent header in the article buffers.
3153 The numerical prefix says how frequently (in seconds) the function
3158 (gnus-stop-date-timer)
3159 (setq article-lapsed-timer
3160 (run-at-time 1 n 'article-update-date-lapsed)))
3162 (defun gnus-stop-date-timer ()
3163 "Stop the X-Sent timer."
3165 (when article-lapsed-timer
3166 (nnheader-cancel-timer article-lapsed-timer)
3167 (setq article-lapsed-timer nil)))
3169 (defun article-date-user (&optional highlight)
3170 "Convert the current article date to the user-defined format.
3171 This format is defined by the `gnus-article-time-format' variable."
3172 (interactive (list t))
3173 (article-date-ut 'user highlight))
3175 (defun article-date-iso8601 (&optional highlight)
3176 "Convert the current article date to ISO8601."
3177 (interactive (list t))
3178 (article-date-ut 'iso8601 highlight))
3180 ;; (defun article-show-all ()
3181 ;; "Show all hidden text in the article buffer."
3185 ;; (let ((inhibit-read-only t))
3186 ;; (gnus-article-unhide-text (point-min) (point-max))
3187 ;; (gnus-remove-text-with-property 'gnus-prev)
3188 ;; (gnus-remove-text-with-property 'gnus-next))))
3190 (defun article-show-all-headers ()
3191 "Show all hidden headers in the article buffer."
3196 (article-narrow-to-head)
3197 (let ((inhibit-read-only t))
3198 (gnus-article-unhide-text (point-min) (point-max))))))
3200 (defun article-remove-leading-whitespace ()
3201 "Remove excessive whitespace from all headers."
3205 (let ((inhibit-read-only t))
3206 (article-narrow-to-head)
3207 (goto-char (point-min))
3208 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3209 (delete-region (match-beginning 1) (match-end 1)))))))
3211 (defun article-emphasize (&optional arg)
3212 "Emphasize text according to `gnus-emphasis-alist'."
3213 (interactive (gnus-article-hidden-arg))
3214 (unless (gnus-article-check-hidden-text 'emphasis arg)
3218 (with-current-buffer gnus-summary-buffer
3219 gnus-article-emphasis-alist)
3221 gnus-emphasis-alist))
3222 (inhibit-read-only t)
3223 (props (append '(article-type emphasis)
3224 gnus-hidden-properties))
3225 regexp elem beg invisible visible face)
3228 (while (setq elem (pop alist))
3230 (setq regexp (car elem)
3231 invisible (nth 1 elem)
3232 visible (nth 2 elem)
3234 (while (re-search-forward regexp nil t)
3235 (when (and (match-beginning visible) (match-beginning invisible))
3236 (gnus-article-hide-text
3237 (match-beginning invisible) (match-end invisible) props)
3238 (gnus-article-unhide-text-type
3239 (match-beginning visible) (match-end visible) 'emphasis)
3240 (gnus-put-overlay-excluding-newlines
3241 (match-beginning visible) (match-end visible) 'face face)
3242 (gnus-add-wash-type 'emphasis)
3243 (goto-char (match-end invisible)))))))))
3245 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3246 "Setup newsgroup emphasis alist."
3247 (unless gnus-article-emphasis-alist
3248 (let ((name (and gnus-newsgroup-name
3249 (gnus-group-real-name gnus-newsgroup-name))))
3250 (make-local-variable 'gnus-article-emphasis-alist)
3251 (setq gnus-article-emphasis-alist
3253 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3254 (while (setq elem (pop alist))
3255 (when (and name (string-match (car elem) name))
3257 highlight (copy-sequence (cdr elem)))))
3259 (copy-sequence highlight-words)
3260 (if gnus-newsgroup-name
3261 (copy-sequence (gnus-group-find-parameter
3262 gnus-newsgroup-name 'highlight-words t)))
3263 gnus-emphasis-alist)))))
3266 (defvar gnus-summary-article-menu)
3267 (defvar gnus-summary-post-menu))
3269 ;;; Saving functions.
3271 (defun gnus-article-save (save-buffer file &optional num)
3272 "Save the currently selected article."
3273 (unless gnus-save-all-headers
3274 ;; Remove headers according to `gnus-saved-headers'.
3275 (let ((gnus-visible-headers
3276 (or gnus-saved-headers gnus-visible-headers))
3277 (gnus-article-buffer save-buffer))
3279 (set-buffer save-buffer)
3280 (article-hide-headers 1 t))))
3281 (save-window-excursion
3282 (if (not gnus-default-article-saver)
3283 (error "No default saver is defined")
3284 ;; !!! Magic! The saving functions all save
3285 ;; `gnus-save-article-buffer' (or so they think), but we
3286 ;; bind that variable to our save-buffer.
3287 (set-buffer gnus-article-buffer)
3288 (let* ((gnus-save-article-buffer save-buffer)
3291 ((not gnus-prompt-before-saving) 'default)
3292 ((eq gnus-prompt-before-saving 'always) nil)
3294 (gnus-number-of-articles-to-be-saved
3295 (when (eq gnus-prompt-before-saving t)
3297 (set-buffer gnus-article-current-summary)
3298 (funcall gnus-default-article-saver filename)))))
3300 (defun gnus-read-save-file-name (prompt &optional filename
3301 function group headers variable)
3303 (funcall function group headers (symbol-value variable)))
3308 ((eq filename 'default)
3314 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3317 (if (and gnus-number-of-articles-to-be-saved
3318 (> gnus-number-of-articles-to-be-saved 1))
3319 (format "these %d articles"
3320 gnus-number-of-articles-to-be-saved)
3323 ;; Let the split methods have their say.
3325 ;; No split name was found.
3328 (concat prompt " (default "
3329 (file-name-nondirectory default-name) ") ")
3330 (file-name-directory default-name)
3332 ;; A single group name is returned.
3333 ((stringp split-name)
3335 (funcall function split-name headers
3336 (symbol-value variable)))
3338 (concat prompt " (default "
3339 (file-name-nondirectory default-name) ") ")
3340 (file-name-directory default-name)
3342 ;; A single split name was found
3343 ((= 1 (length split-name))
3344 (let* ((name (expand-file-name
3346 gnus-article-save-directory))
3347 (dir (cond ((file-directory-p name)
3348 (file-name-as-directory name))
3349 ((file-exists-p name) name)
3350 (t gnus-article-save-directory))))
3352 (concat prompt " (default " name ") ")
3354 ;; A list of splits was found.
3356 (setq split-name (nreverse split-name))
3358 (let ((file-name-history
3359 (nconc split-name file-name-history)))
3363 (concat prompt " (`M-p' for defaults) ")
3364 gnus-article-save-directory
3366 gnus-article-save-directory)))
3367 (car (push result file-name-history)))))))
3368 ;; Create the directory.
3369 (gnus-make-directory (file-name-directory file))
3370 ;; If we have read a directory, we append the default file name.
3371 (when (file-directory-p file)
3372 (setq file (expand-file-name (file-name-nondirectory
3374 (file-name-as-directory file))))
3375 ;; Possibly translate some characters.
3376 (nnheader-translate-file-chars file))))))
3377 (gnus-make-directory (file-name-directory result))
3378 (set variable result)))
3380 (defun gnus-article-archive-name (group)
3381 "Return the first instance of an \"Archive-name\" in the current buffer."
3382 (let ((case-fold-search t))
3383 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3384 (nnheader-concat gnus-article-save-directory
3385 (match-string 1)))))
3387 (defun gnus-article-nndoc-name (group)
3388 "If GROUP is an nndoc group, return the name of the parent group."
3389 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3390 (gnus-group-get-parameter group 'save-article-group)))
3392 (defun gnus-summary-save-in-rmail (&optional filename)
3393 "Append this article to Rmail file.
3394 Optional argument FILENAME specifies file name.
3395 Directory to save to is default to `gnus-article-save-directory'."
3396 (setq filename (gnus-read-save-file-name
3397 "Save %s in rmail file:" filename
3398 gnus-rmail-save-name gnus-newsgroup-name
3399 gnus-current-headers 'gnus-newsgroup-last-rmail))
3400 (gnus-eval-in-buffer-window gnus-save-article-buffer
3404 (gnus-output-to-rmail filename))))
3407 (defun gnus-summary-save-in-mail (&optional filename)
3408 "Append this article to Unix mail file.
3409 Optional argument FILENAME specifies file name.
3410 Directory to save to is default to `gnus-article-save-directory'."
3411 (setq filename (gnus-read-save-file-name
3412 "Save %s in Unix mail file:" filename
3413 gnus-mail-save-name gnus-newsgroup-name
3414 gnus-current-headers 'gnus-newsgroup-last-mail))
3415 (gnus-eval-in-buffer-window gnus-save-article-buffer
3419 (if (and (file-readable-p filename)
3420 (file-regular-p filename)
3421 (mail-file-babyl-p filename))
3422 (rmail-output-to-rmail-file filename t)
3423 (gnus-output-to-mail filename)))))
3426 (defun gnus-summary-save-in-file (&optional filename overwrite)
3427 "Append this article to file.
3428 Optional argument FILENAME specifies file name.
3429 Directory to save to is default to `gnus-article-save-directory'."
3430 (setq filename (gnus-read-save-file-name
3431 "Save %s in file:" filename
3432 gnus-file-save-name gnus-newsgroup-name
3433 gnus-current-headers 'gnus-newsgroup-last-file))
3434 (gnus-eval-in-buffer-window gnus-save-article-buffer
3438 (when (and overwrite
3439 (file-exists-p filename))
3440 (delete-file filename))
3441 (gnus-output-to-file filename))))
3444 (defun gnus-summary-write-to-file (&optional filename)
3445 "Write this article to a file, overwriting it if the file exists.
3446 Optional argument FILENAME specifies file name.
3447 The directory to save in defaults to `gnus-article-save-directory'."
3448 (gnus-summary-save-in-file nil t))
3450 (defun gnus-summary-save-body-in-file (&optional filename)
3451 "Append this article body to a file.
3452 Optional argument FILENAME specifies file name.
3453 The directory to save in defaults to `gnus-article-save-directory'."
3454 (setq filename (gnus-read-save-file-name
3455 "Save %s body in file:" filename
3456 gnus-file-save-name gnus-newsgroup-name
3457 gnus-current-headers 'gnus-newsgroup-last-file))
3458 (gnus-eval-in-buffer-window gnus-save-article-buffer
3462 (when (article-goto-body)
3463 (narrow-to-region (point) (point-max)))
3464 (gnus-output-to-file filename))))
3467 (defun gnus-summary-save-in-pipe (&optional command)
3468 "Pipe this article to subprocess."
3470 (cond ((and (eq command 'default)
3471 gnus-last-shell-command)
3472 gnus-last-shell-command)
3477 "Shell command on %s: "
3478 (if (and gnus-number-of-articles-to-be-saved
3479 (> gnus-number-of-articles-to-be-saved 1))
3480 (format "these %d articles"
3481 gnus-number-of-articles-to-be-saved)
3483 gnus-last-shell-command))))
3484 (when (string-equal command "")
3485 (if gnus-last-shell-command
3486 (setq command gnus-last-shell-command)
3487 (error "A command is required")))
3488 (gnus-eval-in-buffer-window gnus-article-buffer
3491 (shell-command-on-region (point-min) (point-max) command nil)))
3492 (setq gnus-last-shell-command command))
3494 (defun gnus-summary-pipe-to-muttprint (&optional command)
3495 "Pipe this article to muttprint."
3496 (setq command (read-string
3497 "Print using command: " gnus-summary-muttprint-program
3498 nil gnus-summary-muttprint-program))
3499 (gnus-summary-save-in-pipe command))
3501 ;;; Article file names when saving.
3503 (defun gnus-capitalize-newsgroup (newsgroup)
3504 "Capitalize NEWSGROUP name."
3505 (when (not (zerop (length newsgroup)))
3506 (concat (char-to-string (upcase (aref newsgroup 0)))
3507 (substring newsgroup 1))))
3509 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3510 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3511 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3512 Otherwise, it is like ~/News/news/group/num."
3515 (concat (if (gnus-use-long-file-name 'not-save)
3516 (gnus-capitalize-newsgroup newsgroup)
3517 (gnus-newsgroup-directory-form newsgroup))
3518 "/" (int-to-string (mail-header-number headers)))
3519 gnus-article-save-directory)))
3521 (string-equal (file-name-directory default)
3522 (file-name-directory last-file))
3523 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3525 (or last-file default))))
3527 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3528 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3529 If variable `gnus-use-long-file-name' is non-nil, it is
3530 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3533 (concat (if (gnus-use-long-file-name 'not-save)
3535 (gnus-newsgroup-directory-form newsgroup))
3536 "/" (int-to-string (mail-header-number headers)))
3537 gnus-article-save-directory)))
3539 (string-equal (file-name-directory default)
3540 (file-name-directory last-file))
3541 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3543 (or last-file default))))
3545 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3546 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3547 If variable `gnus-use-long-file-name' is non-nil, it is
3548 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3551 (if (gnus-use-long-file-name 'not-save)
3554 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3556 gnus-article-save-directory)))
3558 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3559 "Generate file name from sender."
3560 (let ((from (mail-header-from headers)))
3562 (if (and from (string-match "\\([^ <]+\\)@" from))
3563 (match-string 1 from)
3565 gnus-article-save-directory)))
3567 (defun article-verify-x-pgp-sig ()
3570 (if (gnus-buffer-live-p gnus-original-article-buffer)
3571 (let ((sig (with-current-buffer gnus-original-article-buffer
3572 (gnus-fetch-field "X-PGP-Sig")))
3576 (mml2015-clear-verify-function))
3578 (insert-buffer-substring gnus-original-article-buffer)
3579 (setq items (split-string sig))
3580 (message-narrow-to-head)
3581 (let ((inhibit-point-motion-hooks t)
3582 (case-fold-search t))
3583 ;; Don't verify multiple headers.
3584 (setq headers (mapconcat (lambda (header)
3586 (mail-fetch-field header)
3588 (split-string (nth 1 items) ",") "")))
3589 (delete-region (point-min) (point-max))
3590 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3591 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3596 (if (looking-at "^-")
3599 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3600 (insert "Version: " (car items) "\n\n")
3601 (insert (mapconcat 'identity (cddr items) "\n"))
3602 (insert "\n-----END PGP SIGNATURE-----\n")
3603 (let ((mm-security-handle (list (format "multipart/signed"))))
3604 (mml2015-clean-buffer)
3605 (let ((coding-system-for-write (or gnus-newsgroup-charset
3607 (funcall (mml2015-clear-verify-function)))
3609 (or (mm-handle-multipart-ctl-parameter
3610 mm-security-handle 'gnus-details)
3611 (mm-handle-multipart-ctl-parameter
3612 mm-security-handle 'gnus-info)))))
3614 (let ((inhibit-read-only t) bface eface)
3616 (message-narrow-to-head)
3617 (goto-char (point-max))
3619 (setq bface (get-text-property (point-at-bol) 'face)
3620 eface (get-text-property (1- (point-at-eol)) 'face))
3621 (message-remove-header "X-Gnus-PGP-Verify")
3622 (if (re-search-forward "^X-PGP-Sig:" nil t)
3624 (goto-char (point-max)))
3625 (narrow-to-region (point) (point))
3626 (insert "X-Gnus-PGP-Verify: " info "\n")
3627 (goto-char (point-min))
3630 (if (not (looking-at "^[ \t]"))
3634 (goto-char (point-min))
3635 (when (looking-at "\\([^:]+\\): *")
3636 (put-text-property (match-beginning 1) (1+ (match-end 1))
3638 (put-text-property (match-end 0) (point-max)
3639 'face eface)))))))))
3641 (defun article-verify-cancel-lock ()
3642 "Verify Cancel-Lock header."
3644 (if (gnus-buffer-live-p gnus-original-article-buffer)
3645 (canlock-verify gnus-original-article-buffer)))
3647 (defun article-monafy ()
3648 "Display body part with mona font."
3650 (unless (if (featurep 'xemacs)
3651 (find-face 'gnus-mona-face)
3652 (facep 'gnus-mona-face))
3653 (require 'navi2ch-mona)
3654 (set-face-font (make-face 'gnus-mona-face) navi2ch-mona-font))
3656 (let ((inhibit-read-only t))
3659 (gnus-make-overlay (point) (point-max))
3660 'face 'gnus-mona-face))))
3667 (setq afunc (car func)
3670 gfunc (intern (format "gnus-%s" func))))
3672 (when (fboundp afunc)
3673 `(lambda (&optional interactive &rest args)
3674 ,(documentation afunc t)
3675 (interactive (list t))
3677 (set-buffer gnus-article-buffer)
3679 (call-interactively ',afunc)
3680 (apply ',afunc args))))))))
3681 '(article-hide-headers
3682 article-verify-x-pgp-sig
3683 article-verify-cancel-lock
3685 article-hide-boring-headers
3686 article-treat-overstrike
3687 article-treat-ansi-sequences
3688 article-fill-long-lines
3689 article-capitalize-sentences
3691 article-remove-leading-whitespace
3692 article-display-x-face
3693 article-display-face
3694 article-de-quoted-unreadable
3695 article-de-base64-unreadable
3698 article-unsplit-urls
3699 article-hide-list-identifiers
3700 article-strip-banner
3703 article-hide-signature
3704 article-strip-headers-in-body
3705 article-remove-trailing-blank-lines
3706 article-strip-leading-blank-lines
3707 article-strip-multiple-blank-lines
3708 article-strip-leading-space
3709 article-strip-trailing-space
3710 article-strip-blank-lines
3711 article-strip-all-blank-lines
3713 article-date-english
3714 article-date-iso8601
3715 article-date-original
3717 article-decode-mime-words
3718 article-decode-charset
3719 article-decode-encoded-words
3723 article-treat-dumbquotes
3724 article-normalize-headers
3725 (article-show-all-headers . gnus-article-show-all-headers)
3726 ;; (article-show-all . gnus-article-show-all)
3730 ;;; Gnus article mode
3733 (put 'gnus-article-mode 'mode-class 'special)
3735 (gnus-define-keys gnus-article-mode-map
3736 " " gnus-article-goto-next-page
3737 "\177" gnus-article-goto-prev-page
3738 [delete] gnus-article-goto-prev-page
3739 [backspace] gnus-article-goto-prev-page
3740 "\C-c^" gnus-article-refer-article
3741 "h" gnus-article-show-summary
3742 "s" gnus-article-show-summary
3743 "\C-c\C-m" gnus-article-mail
3744 "?" gnus-article-describe-briefly
3745 "e" gnus-summary-edit-article
3746 "<" beginning-of-buffer
3748 "\C-c\C-i" gnus-info-find-node
3750 "R" gnus-article-reply-with-original
3751 "F" gnus-article-followup-with-original
3752 "\C-hk" gnus-article-describe-key
3753 "\C-hc" gnus-article-describe-key-briefly
3755 "\C-d" gnus-article-read-summary-keys
3756 "\M-*" gnus-article-read-summary-keys
3757 "\M-#" gnus-article-read-summary-keys
3758 "\M-^" gnus-article-read-summary-keys
3759 "\M-g" gnus-article-read-summary-keys)
3761 ;; Define almost undefined keys to `gnus-article-read-summary-keys'.
3765 (push (char-to-string key) keys)
3767 (dolist (elem (accessible-keymaps gnus-summary-mode-map))
3768 (setq key (car elem))
3769 (when (and (> (length key) 0)
3770 (not (eq 'menu-bar (aref key 0)))
3771 (symbolp (lookup-key gnus-summary-mode-map key)))
3774 (unless (lookup-key gnus-article-mode-map key)
3775 (define-key gnus-article-mode-map key 'gnus-article-read-summary-keys))))
3777 (defun gnus-article-make-menu-bar ()
3778 (unless (boundp 'gnus-article-commands-menu)
3779 (gnus-summary-make-menu-bar))
3780 (gnus-turn-off-edit-menu 'article)
3781 (unless (boundp 'gnus-article-article-menu)
3783 gnus-article-article-menu gnus-article-mode-map ""
3785 ["Scroll forwards" gnus-article-goto-next-page t]
3786 ["Scroll backwards" gnus-article-goto-prev-page t]
3787 ["Show summary" gnus-article-show-summary t]
3788 ["Fetch Message-ID at point" gnus-article-refer-article t]
3789 ["Mail to address at point" gnus-article-mail t]
3790 ["Send a bug report" gnus-bug t]))
3793 gnus-article-treatment-menu gnus-article-mode-map ""
3794 ;; Fixme: this should use :active (and maybe :visible).
3796 ["Hide headers" gnus-article-hide-headers t]
3797 ["Hide signature" gnus-article-hide-signature t]
3798 ["Hide citation" gnus-article-hide-citation t]
3799 ["Treat overstrike" gnus-article-treat-overstrike t]
3800 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
3801 ["Remove carriage return" gnus-article-remove-cr t]
3802 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3803 ["Treat html" gnus-article-wash-html t]
3804 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3805 ["Decode HZ" gnus-article-decode-HZ t]))
3807 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3809 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3811 (gnus-run-hooks 'gnus-article-menu-hook)))
3813 (defun gnus-article-mode ()
3814 "Major mode for displaying an article.
3816 All normal editing commands are switched off.
3818 The following commands are available in addition to all summary mode
3820 \\<gnus-article-mode-map>
3821 \\[gnus-article-next-page]\t Scroll the article one page forwards
3822 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3823 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3824 \\[gnus-article-show-summary]\t Display the summary buffer
3825 \\[gnus-article-mail]\t Send a reply to the address near point
3826 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3827 \\[gnus-info-find-node]\t Go to the Gnus info node"
3829 (gnus-simplify-mode-line)
3830 (setq mode-name "Article")
3831 (setq major-mode 'gnus-article-mode)
3832 (make-local-variable 'minor-mode-alist)
3833 (unless (assq 'gnus-show-mime minor-mode-alist)
3834 (push (list 'gnus-show-mime " MIME") minor-mode-alist))
3835 (use-local-map gnus-article-mode-map)
3836 (when (gnus-visual-p 'article-menu 'menu)
3837 (gnus-article-make-menu-bar)
3838 (when gnus-summary-tool-bar-map
3839 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3840 (gnus-update-format-specifications nil 'article-mode)
3841 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3842 (set (make-local-variable 'gnus-page-broken) nil)
3843 (make-local-variable 'gnus-button-marker-list)
3844 (make-local-variable 'gnus-article-current-summary)
3845 (make-local-variable 'gnus-article-mime-handles)
3846 (make-local-variable 'gnus-article-decoded-p)
3847 (make-local-variable 'gnus-article-mime-handle-alist)
3848 (make-local-variable 'gnus-article-wash-types)
3849 (make-local-variable 'gnus-article-image-alist)
3850 (make-local-variable 'gnus-article-charset)
3851 (make-local-variable 'gnus-article-ignored-charsets)
3852 (gnus-set-default-directory)
3853 (buffer-disable-undo)
3854 (setq buffer-read-only t
3855 show-trailing-whitespace nil)
3856 (set-syntax-table gnus-article-mode-syntax-table)
3857 (gnus-run-hooks 'gnus-article-mode-hook))
3859 (defun gnus-article-setup-buffer ()
3860 "Initialize the article buffer."
3861 (let* ((name (if gnus-single-article-buffer "*Article*"
3862 (concat "*Article " gnus-newsgroup-name "*")))
3864 (progn (string-match "\\*Article" name)
3865 (concat " *Original Article"
3866 (substring name (match-end 0))))))
3867 (setq gnus-article-buffer name)
3868 (setq gnus-original-article-buffer original)
3869 (setq gnus-article-mime-handle-alist nil)
3870 ;; This might be a variable local to the summary buffer.
3871 (unless gnus-single-article-buffer
3873 (set-buffer gnus-summary-buffer)
3874 (setq gnus-article-buffer name)
3875 (setq gnus-original-article-buffer original)
3876 (gnus-set-global-variables)))
3877 (gnus-article-setup-highlight-words)
3878 ;; Init original article buffer.
3880 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3881 (set-buffer-multibyte t)
3882 (setq major-mode 'gnus-original-article-mode)
3883 (make-local-variable 'gnus-original-article))
3884 (if (get-buffer name)
3887 (when (and gnus-article-edit-mode
3890 (y-or-n-p "Article mode edit in progress; discard? ")))
3891 (error "Action aborted"))
3892 (set (make-local-variable 'gnus-article-edit-mode) nil)
3893 (buffer-disable-undo)
3894 (setq buffer-read-only t)
3895 ;; This list just keeps growing if we don't reset it.
3896 (setq gnus-button-marker-list nil)
3897 (unless (eq major-mode 'gnus-article-mode)
3898 (gnus-article-mode))
3901 (set-buffer (gnus-get-buffer-create name))
3903 (make-local-variable 'gnus-summary-buffer)
3904 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3905 (current-buffer)))))
3907 ;; Set article window start at LINE, where LINE is the number of lines
3908 ;; from the head of the article.
3909 (defun gnus-article-set-window-start (&optional line)
3911 (gnus-get-buffer-window gnus-article-buffer t)
3913 (set-buffer gnus-article-buffer)
3914 (goto-char (point-min))
3917 (gnus-message 6 "Moved to bookmark")
3918 (search-forward "\n\n" nil t)
3922 ;;; @@ article filters
3925 (defun gnus-article-display-mime-message ()
3926 "Article display method for MIME message."
3927 ;; called from `gnus-original-article-buffer'.
3928 (let (charset all-headers)
3929 (with-current-buffer gnus-summary-buffer
3930 (setq charset default-mime-charset
3931 all-headers gnus-have-all-headers))
3932 (make-local-variable 'default-mime-charset)
3933 (setq default-mime-charset charset)
3934 (with-current-buffer (get-buffer-create gnus-article-buffer)
3935 (make-local-variable 'default-mime-charset)
3936 (setq default-mime-charset charset))
3937 (mime-display-message mime-message-structure
3938 gnus-article-buffer nil gnus-article-mode-map)
3940 (gnus-article-hide-headers nil -1)))
3941 (run-hooks 'gnus-mime-article-prepare-hook))
3943 (defun gnus-article-display-traditional-message ()
3944 "Article display method for traditional message."
3945 (set-buffer gnus-article-buffer)
3946 (let ((inhibit-read-only t))
3948 (insert-buffer-substring gnus-original-article-buffer)))
3950 (defun gnus-article-make-full-mail-header (&optional number charset)
3951 "Create a new mail header structure in a raw article buffer."
3952 (unless (and number charset)
3953 (save-current-buffer
3954 (set-buffer gnus-summary-buffer)
3956 (setq number (or (cdr gnus-article-current) 0)))
3958 (setq charset (or default-mime-charset 'x-ctext)))))
3959 (goto-char (point-min))
3960 (let ((header-end (if (search-forward "\n\n" nil t)
3962 (goto-char (point-max))))
3963 (chars (- (point-max) (point)))
3964 (lines (count-lines (point) (point-max)))
3965 (default-mime-charset charset)
3967 (narrow-to-region (point-min) header-end)
3968 (setq xref (std11-fetch-field "xref"))
3970 (make-full-mail-header
3972 (std11-fetch-field "subject")
3973 (std11-fetch-field "from")
3974 (std11-fetch-field "date")
3975 (std11-fetch-field "message-id")
3976 (std11-fetch-field "references")
3979 (when xref (concat "Xref: " xref)))
3982 (defun gnus-article-prepare (article &optional all-headers header)
3983 "Prepare ARTICLE in article mode buffer.
3984 ARTICLE should either be an article number or a Message-ID.
3985 If ARTICLE is an id, HEADER should be the article headers.
3986 If ALL-HEADERS is non-nil, no headers are hidden."
3988 ;; Make sure we start in a summary buffer.
3989 (unless (eq major-mode 'gnus-summary-mode)
3990 (set-buffer gnus-summary-buffer))
3991 (setq gnus-summary-buffer (current-buffer))
3992 (let* ((gnus-article (if header (mail-header-number header) article))
3993 (summary-buffer (current-buffer))
3994 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3995 (group gnus-newsgroup-name)
3998 (gnus-article-setup-buffer)
3999 (set-buffer gnus-article-buffer)
4000 ;; Deactivate active regions.
4001 (when (and (boundp 'transient-mark-mode)
4002 transient-mark-mode)
4003 (setq mark-active nil))
4004 (if (not (setq result (let ((inhibit-read-only t))
4005 (gnus-request-article-this-buffer
4007 ;; There is no such article.
4009 (when (and (numberp article)
4010 (not (memq article gnus-newsgroup-sparse)))
4011 (setq gnus-article-current
4012 (cons gnus-newsgroup-name article))
4013 (set-buffer gnus-summary-buffer)
4014 (setq gnus-current-article article)
4015 (if (and (memq article gnus-newsgroup-undownloaded)
4016 (not (gnus-online (gnus-find-method-for-group
4017 gnus-newsgroup-name))))
4019 (gnus-summary-set-agent-mark article)
4020 (message "Message marked for downloading"))
4021 (gnus-summary-mark-article article gnus-canceled-mark)
4022 (unless (memq article gnus-newsgroup-sparse)
4023 (gnus-error 1 "No such article (may have expired or been canceled)")))))
4024 (if (or (eq result 'pseudo)
4025 (eq result 'nneething))
4028 (set-buffer summary-buffer)
4029 (push article gnus-newsgroup-history)
4030 (setq gnus-last-article gnus-current-article
4031 gnus-current-article 0
4032 gnus-current-headers nil
4033 gnus-article-current nil)
4034 (if (eq result 'nneething)
4035 (gnus-configure-windows 'summary)
4036 (gnus-configure-windows 'article))
4037 (gnus-set-global-variables))
4038 (let ((gnus-article-mime-handle-alist-1
4039 gnus-article-mime-handle-alist))
4040 (gnus-set-mode-line 'article)))
4041 ;; The result from the `request' was an actual article -
4042 ;; or at least some text that is now displayed in the
4044 (when (and (numberp article)
4045 (not (eq article gnus-current-article)))
4046 ;; Seems like a new article has been selected.
4047 ;; `gnus-current-article' must be an article number.
4049 (set-buffer summary-buffer)
4050 (push article gnus-newsgroup-history)
4051 (setq gnus-last-article gnus-current-article
4052 gnus-current-article article
4053 gnus-current-headers
4054 (gnus-summary-article-header gnus-current-article)
4055 gnus-article-current
4056 (cons gnus-newsgroup-name gnus-current-article))
4057 (unless (vectorp gnus-current-headers)
4058 (setq gnus-current-headers nil))
4059 (gnus-summary-goto-subject gnus-current-article)
4060 (when (gnus-summary-show-thread)
4061 ;; If the summary buffer really was folded, the
4062 ;; previous goto may not actually have gone to
4063 ;; the right article, but the thread root instead.
4065 (gnus-summary-goto-subject gnus-current-article))
4066 (gnus-run-hooks 'gnus-mark-article-hook)
4067 (gnus-set-mode-line 'summary)
4068 (when (gnus-visual-p 'article-highlight 'highlight)
4069 (gnus-run-hooks 'gnus-visual-mark-article-hook))
4070 ;; Set the global newsgroup variables here.
4071 (gnus-set-global-variables)
4072 (setq gnus-have-all-headers
4073 (or all-headers gnus-show-all-headers))))
4075 (gnus-configure-windows 'article))
4076 (when (or (numberp article)
4078 (gnus-article-prepare-display)
4080 (goto-char (point-min))
4081 (when gnus-break-pages
4082 (gnus-narrow-to-page)))
4083 (let ((gnus-article-mime-handle-alist-1
4084 gnus-article-mime-handle-alist))
4085 (gnus-set-mode-line 'article))
4089 (set-window-point (get-buffer-window (current-buffer)) (point))
4090 (gnus-configure-windows 'article)
4093 (defun gnus-article-prepare-mime-display (&optional number)
4094 (goto-char (point-min))
4095 (when (re-search-forward "^[^\t ]+:" nil t)
4096 (goto-char (match-beginning 0)))
4097 (let ((entity (if (eq 1 (point-min))
4098 (get-text-property 1 'mime-view-entity)
4099 (get-text-property (point) 'mime-view-entity)))
4100 last-entity child-entity next type)
4101 (setq child-entity (mime-entity-children entity))
4103 (setq last-entity (nth (1- (length child-entity))
4105 (setq last-entity entity))
4107 (narrow-to-region (point)
4108 (if (search-forward "\n\n" nil t)
4111 (gnus-treat-article 'head)
4112 (put-text-property (point-min) (point-max) 'article-treated-header t)
4113 (goto-char (point-max)))
4114 (while (and (not (eobp)) entity)
4115 (setq next (set-marker
4117 (next-single-property-change (point) 'mime-view-entity
4119 (let ((types (mime-entity-content-type entity)))
4120 (while (eq 'multipart (mime-content-type-primary-type types))
4121 (setq entity (car (mime-entity-children entity))
4122 types (mime-entity-content-type entity)))
4124 (setq type (format "%s/%s"
4125 (mime-content-type-primary-type types)
4126 (mime-content-type-subtype types)))))
4127 (if (string-equal type "message/rfc822")
4130 (let ((children (mime-entity-children entity))
4133 (setq last-children (nth (1- (length children)) children))
4136 (not (eq last-children
4137 (get-text-property next 'mime-view-entity)))
4139 (next-single-property-change next
4141 nil (point-max)))))))
4142 (setq next (next-single-property-change next 'mime-view-entity
4145 (narrow-to-region (point) next)
4146 (gnus-article-prepare-mime-display)
4147 (goto-char (point-max)))
4148 (setq entity (get-text-property (point) 'mime-view-entity)))
4150 (narrow-to-region (point) next)
4151 ;; Kludge. We have to count true number, but for now,
4152 ;; part number is here only to achieve `last'.
4153 (gnus-treat-article nil 1
4154 (if (eq entity last-entity)
4157 (goto-char (point-max)))
4158 (setq entity (get-text-property next 'mime-view-entity))))))
4161 (defun gnus-article-prepare-display ()
4162 "Make the current buffer look like a nice article."
4163 (let ((gnus-article-buffer (current-buffer))
4165 (inhibit-read-only t))
4166 (unless (eq major-mode 'gnus-article-mode)
4167 (gnus-article-mode))
4168 (setq buffer-read-only nil
4169 gnus-button-marker-list nil
4170 gnus-article-wash-types nil
4171 gnus-article-image-alist nil)
4174 (static-if (featurep 'xemacs)
4175 (map-extents (lambda (extent maparg) (delete-extent extent)))
4176 (let ((lists (overlay-lists)))
4177 (dolist (overlay (nconc (car lists) (cdr lists)))
4178 (delete-overlay overlay)))))
4179 (gnus-run-hooks 'gnus-tmp-internal-hook))
4180 (let ((show-mime (unless (member gnus-newsgroup-name '("nndraft:delayed"
4183 (inhibit-read-only t))
4184 (set-buffer gnus-original-article-buffer)
4186 (setq mime-message-structure gnus-current-headers)
4187 (mime-buffer-entity-set-buffer-internal mime-message-structure
4188 gnus-original-article-buffer)
4189 (mime-entity-set-representation-type-internal mime-message-structure
4190 'mime-buffer-entity)
4191 (luna-send mime-message-structure 'initialize-instance
4192 mime-message-structure)
4194 (let (mime-display-header-hook mime-display-text/plain-hook)
4195 (funcall gnus-article-display-method-for-mime))
4196 (funcall gnus-article-display-method-for-traditional))
4197 ;; Call the treatment functions.
4201 (gnus-article-prepare-mime-display)
4202 (narrow-to-region (goto-char (point-min))
4203 (if (search-forward "\n\n" nil t)
4206 (gnus-treat-article 'head)
4207 (put-text-property (point-min) (point-max) 'article-treated-header t)
4208 (goto-char (point-max))
4210 (narrow-to-region (point) (point-max))
4211 (gnus-treat-article nil))
4212 (put-text-property (point-min) (point-max) 'read-only nil)))
4213 (gnus-run-hooks 'gnus-article-prepare-hook))
4215 (defun gnus-article-decode-article-as-default-mime-charset ()
4216 "Decode an article as `default-mime-charset'. It won't work if the
4217 value of the variable `gnus-show-mime' is non-nil."
4218 (unless (or gnus-show-mime
4219 (member gnus-newsgroup-name '("nndraft:delayed"
4221 (set (make-local-variable 'default-mime-charset)
4222 (with-current-buffer gnus-summary-buffer
4223 default-mime-charset))
4224 (decode-mime-charset-region (point-min) (point-max)
4225 default-mime-charset)))
4228 ;;; Gnus MIME viewing functions
4231 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4232 "Format of the MIME buttons.
4234 Valid specifiers include:
4236 %T MIME type, along with additional info
4237 %n The `name' parameter
4238 %d The description, if any
4239 %l The length of the encoded part
4240 %p The part identifier number
4241 %e Dots if the part isn't displayed
4243 General format specifiers can also be used. See Info node
4244 `(gnus)Formatting Variables'.")
4246 (defvar gnus-mime-button-line-format-alist
4247 '((?t gnus-tmp-type ?s)
4248 (?T gnus-tmp-type-long ?s)
4249 (?n gnus-tmp-name ?s)
4250 (?d gnus-tmp-description ?s)
4252 (?l gnus-tmp-length ?d)
4253 (?e gnus-tmp-dots ?s)))
4255 (defvar gnus-mime-button-commands
4256 '((gnus-article-press-button "\r" "Toggle Display")
4257 (gnus-mime-view-part "v" "View Interactively...")
4258 (gnus-mime-view-part-as-type "t" "View As Type...")
4259 (gnus-mime-view-part-as-charset "C" "View As charset...")
4260 (gnus-mime-save-part "o" "Save...")
4261 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4262 (gnus-mime-delete-part "d" "Delete part")
4263 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4264 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4265 (gnus-mime-view-part-internally "E" "View Internally")
4266 (gnus-mime-view-part-externally "e" "View Externally")
4267 (gnus-mime-print-part "p" "Print")
4268 (gnus-mime-pipe-part "|" "Pipe To Command...")
4269 (gnus-mime-action-on-part "." "Take action on the part...")))
4271 (defun gnus-article-mime-part-status ()
4272 (with-current-buffer gnus-article-buffer
4273 (let ((entity (get-text-property (point-min) 'mime-view-entity))
4276 (setq children (mime-entity-children entity))
4277 (setq children (length children)))
4280 (format " (%d parts)" children))
4283 (defvar gnus-mime-button-map
4284 (let ((map (make-sparse-keymap)))
4285 (define-key map gnus-mouse-2 'gnus-article-push-button)
4286 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4287 (dolist (c gnus-mime-button-commands)
4288 (define-key map (cadr c) (car c)))
4292 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4294 ,@(mapcar (lambda (c)
4295 (vector (caddr c) (car c) :enable t))
4296 gnus-mime-button-commands)))
4298 (defun gnus-mime-button-menu (event prefix)
4299 "Construct a context-sensitive menu of MIME commands."
4300 (interactive "e\nP")
4301 (save-window-excursion
4302 (let ((pos (event-start event)))
4303 (select-window (posn-window pos))
4304 (goto-char (posn-point pos))
4305 (gnus-article-check-buffer)
4306 (popup-menu gnus-mime-button-menu nil prefix))))
4308 (defun gnus-mime-view-all-parts (&optional handles)
4309 "View all the MIME parts."
4311 (with-current-buffer gnus-article-buffer
4312 (let ((handles (or handles gnus-article-mime-handles))
4313 (mail-parse-charset gnus-newsgroup-charset)
4314 (mail-parse-ignored-charsets
4315 (with-current-buffer gnus-summary-buffer
4316 gnus-newsgroup-ignored-charsets)))
4318 (mm-remove-parts handles)
4319 (goto-char (point-min))
4320 (or (search-forward "\n\n") (goto-char (point-max)))
4321 (let ((inhibit-read-only t))
4322 (delete-region (point) (point-max))
4323 (mm-display-parts handles))))))
4326 (defsubst gnus-article-edit-part (handles)
4327 "Edit an article in order to delete a mime part.
4328 This function is exclusively used by `gnus-mime-save-part-and-strip'
4329 and `gnus-mime-delete-part', and not provided at run-time normally."
4330 (gnus-article-edit-article
4333 (let ((mail-parse-charset (or gnus-article-charset
4334 ',gnus-newsgroup-charset))
4335 (mail-parse-ignored-charsets
4336 (or gnus-article-ignored-charsets
4337 ',gnus-newsgroup-ignored-charsets))
4338 (mbl mml-buffer-list))
4339 (setq mml-buffer-list nil)
4340 (insert-buffer gnus-original-article-buffer)
4341 (mime-to-mml ',handles)
4342 (setq gnus-article-mime-handles nil)
4343 (let ((mbl1 mml-buffer-list))
4344 (setq mml-buffer-list mbl)
4345 (set (make-local-variable 'mml-buffer-list) mbl1))
4346 (gnus-make-local-hook 'kill-buffer-hook)
4347 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4348 `(lambda (no-highlight)
4349 (let ((mail-parse-charset (or gnus-article-charset
4350 ',gnus-newsgroup-charset))
4351 (message-options message-options)
4352 (message-options-set-recipient)
4353 (mail-parse-ignored-charsets
4354 (or gnus-article-ignored-charsets
4355 ',gnus-newsgroup-ignored-charsets)))
4357 (mml-destroy-buffers)
4358 (remove-hook 'kill-buffer-hook
4359 'mml-destroy-buffers t)
4360 (kill-local-variable 'mml-buffer-list))
4361 (gnus-summary-edit-article-done
4362 ,(or (mail-header-references gnus-current-headers) "")
4363 ,(gnus-group-read-only-p)
4364 ,gnus-summary-buffer no-highlight)))
4365 (gnus-article-edit-done)
4366 (gnus-summary-expand-window)
4367 (gnus-summary-show-article)))
4369 (defun gnus-mime-save-part-and-strip ()
4370 "Save the MIME part under point then replace it with an external body."
4372 (gnus-article-check-buffer)
4373 (when (gnus-group-read-only-p)
4374 (error "The current group does not support deleting of parts"))
4375 (when (mm-complicated-handles gnus-article-mime-handles)
4377 The current article has a complicated MIME structure, giving up..."))
4378 (when (gnus-yes-or-no-p "\
4379 Deleting parts may malfunction or destroy the article; continue? ")
4380 (let* ((data (get-text-property (point) 'gnus-data))
4382 (handles gnus-article-mime-handles))
4383 (setq file (and data (mm-save-part data)))
4385 (with-current-buffer (mm-handle-buffer data)
4387 (insert "Content-Type: " (mm-handle-media-type data))
4388 (mml-insert-parameter-string (cdr (mm-handle-type data))
4391 (insert "Content-ID: " (message-make-message-id) "\n")
4392 (insert "Content-Transfer-Encoding: binary\n")
4395 (cdr (mm-make-handle nil
4396 `("message/external-body"
4397 (access-type . "LOCAL-FILE")
4399 (set-buffer gnus-summary-buffer)
4400 (gnus-article-edit-part handles)))))
4402 (defun gnus-mime-delete-part ()
4403 "Delete the MIME part under point.
4404 Replace it with some information about the removed part."
4406 (gnus-article-check-buffer)
4407 (when (gnus-group-read-only-p)
4408 (error "The current group does not support deleting of parts"))
4409 (when (mm-complicated-handles gnus-article-mime-handles)
4411 The current article has a complicated MIME structure, giving up..."))
4412 (when (gnus-yes-or-no-p "\
4413 Deleting parts may malfunction or destroy the article; continue? ")
4414 (let* ((data (get-text-property (point) 'gnus-data))
4415 (handles gnus-article-mime-handles)
4419 (mail-decode-encoded-word-string (or (mm-handle-description data)
4422 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4424 (type (mm-handle-media-type data)))
4426 (error "No MIME part under point"))
4427 (with-current-buffer (mm-handle-buffer data)
4428 (let ((bsize (format "%s" (buffer-size))))
4433 "| The following attachment has been deleted:\n"
4435 "| Type: " type "\n"
4436 "| Filename: " filename "\n"
4437 "| Size (encoded): " bsize " Byte\n"
4438 "| Description: " description "\n"
4441 (cdr (mm-make-handle
4442 nil `("text/plain") nil nil
4444 (format "Deleted attachment (%s bytes)" bsize))))))
4445 (set-buffer gnus-summary-buffer)
4446 (gnus-article-edit-part handles))))
4448 (defun gnus-mime-save-part ()
4449 "Save the MIME part under point."
4451 (gnus-article-check-buffer)
4452 (let ((data (get-text-property (point) 'gnus-data)))
4454 (mm-save-part data))))
4456 (defun gnus-mime-pipe-part ()
4457 "Pipe the MIME part under point to a process."
4459 (gnus-article-check-buffer)
4460 (let ((data (get-text-property (point) 'gnus-data)))
4462 (mm-pipe-part data))))
4464 (defun gnus-mime-view-part ()
4465 "Interactively choose a viewing method for the MIME part under point."
4467 (gnus-article-check-buffer)
4468 (let ((data (get-text-property (point) 'gnus-data)))
4470 (setq gnus-article-mime-handles
4472 gnus-article-mime-handles (setq data (copy-sequence data))))
4473 (mm-interactively-view-part data))))
4475 (defun gnus-mime-view-part-as-type-internal ()
4476 (gnus-article-check-buffer)
4477 (let* ((name (mail-content-type-get
4478 (mm-handle-type (get-text-property (point) 'gnus-data))
4480 (def-type (and name (mm-default-file-encoding name))))
4481 (and def-type (cons def-type 0))))
4483 (defun gnus-mime-view-part-as-type (&optional mime-type)
4484 "Choose a MIME media type, and view the part as such."
4487 (setq mime-type (completing-read
4488 "View as MIME type: "
4489 (mapcar #'list (mailcap-mime-types))
4491 (gnus-mime-view-part-as-type-internal))))
4492 (gnus-article-check-buffer)
4493 (let ((handle (get-text-property (point) 'gnus-data)))
4496 (mm-make-handle (mm-handle-buffer handle)
4497 (cons mime-type (cdr (mm-handle-type handle)))
4498 (mm-handle-encoding handle)
4499 (mm-handle-undisplayer handle)
4500 (mm-handle-disposition handle)
4501 (mm-handle-description handle)
4503 (mm-handle-id handle)))
4504 (setq gnus-article-mime-handles
4505 (mm-merge-handles gnus-article-mime-handles handle))
4506 (gnus-mm-display-part handle))))
4509 (require 'jka-compr))
4511 ;; jka-compr.el uses a "sh -c" to direct stderr to err-file, but these days
4512 ;; emacs can do that itself.
4514 (defun gnus-mime-jka-compr-maybe-uncompress ()
4515 "Uncompress the current buffer if `auto-compression-mode' is enabled.
4516 The uncompress method used is derived from `buffer-file-name'."
4517 (when (and (fboundp 'jka-compr-installed-p)
4518 (jka-compr-installed-p))
4519 (let ((info (jka-compr-get-compression-info buffer-file-name)))
4521 (let ((basename (file-name-nondirectory buffer-file-name))
4522 (args (jka-compr-info-uncompress-args info))
4523 (prog (jka-compr-info-uncompress-program info))
4524 (message (jka-compr-info-uncompress-message info))
4525 (err-file (jka-compr-make-temp-name)))
4527 (message "%s %s..." message basename))
4529 (unless (memq (apply 'call-process-region
4530 (point-min) (point-max)
4532 t (list t err-file) nil
4534 jka-compr-acceptable-retval-list)
4535 (jka-compr-error prog args basename message err-file))
4536 (jka-compr-delete-temp-file err-file)))))))
4538 (defun gnus-mime-copy-part (&optional handle)
4539 "Put the MIME part under point into a new buffer.
4540 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4543 (gnus-article-check-buffer)
4544 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4545 (contents (and handle (mm-get-part handle)))
4547 (file-name-nondirectory
4549 (mail-content-type-get (mm-handle-type handle) 'name)
4550 (mail-content-type-get (mm-handle-disposition handle)
4553 (buffer (and base (generate-new-buffer base))))
4555 (switch-to-buffer buffer)
4557 ;; We do it this way to make `normal-mode' set the appropriate mode.
4560 (setq buffer-file-name (expand-file-name base))
4561 (gnus-mime-jka-compr-maybe-uncompress)
4563 (setq buffer-file-name nil))
4564 (goto-char (point-min)))))
4566 (defun gnus-mime-print-part (&optional handle filename)
4567 "Print the MIME part under point."
4568 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4569 (gnus-article-check-buffer)
4570 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4571 (contents (and handle (mm-get-part handle)))
4572 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4573 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4578 (mm-save-part-to-file handle file)
4579 (call-process shell-file-name nil
4580 (generate-new-buffer " *mm*")
4582 shell-command-switch
4584 printer file (mm-handle-type handle))))
4588 (gnus-print-buffer))
4589 (ps-despool filename)))))
4591 (defun gnus-mime-inline-part (&optional handle arg)
4592 "Insert the MIME part under point into the current buffer."
4593 (interactive (list nil current-prefix-arg))
4594 (gnus-article-check-buffer)
4595 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4598 (inhibit-read-only t))
4600 (if (and (not arg) (mm-handle-undisplayer handle))
4601 (mm-remove-part handle)
4602 (setq contents (mm-get-part handle))
4605 (setq charset (or (mail-content-type-get
4606 (mm-handle-type handle) 'charset)
4607 gnus-newsgroup-charset)))
4609 (if (mm-handle-undisplayer handle)
4610 (mm-remove-part handle))
4613 gnus-summary-show-article-charset-alist))
4614 (mm-read-coding-system "Charset: ")))))
4616 (mm-insert-inline handle
4618 (setq charset (mm-charset-to-coding-system
4620 (not (eq charset 'ascii)))
4621 (mm-decode-coding-string contents charset)
4625 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4626 "Insert the MIME part under point into the current buffer using the
4628 (interactive (list nil current-prefix-arg))
4629 (gnus-article-check-buffer)
4630 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4633 (inhibit-read-only t))
4635 (if (mm-handle-undisplayer handle)
4636 (mm-remove-part handle))
4637 (let ((gnus-newsgroup-charset
4639 gnus-summary-show-article-charset-alist))
4640 (mm-read-coding-system "Charset: ")))
4641 (gnus-newsgroup-ignored-charsets 'gnus-all))
4642 (gnus-article-press-button)))))
4644 (defun gnus-mime-view-part-externally (&optional handle)
4645 "View the MIME part under point with an external viewer."
4647 (gnus-article-check-buffer)
4648 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4649 (mm-user-display-methods nil)
4650 (mm-inlined-types nil)
4651 (mail-parse-charset gnus-newsgroup-charset)
4652 (mail-parse-ignored-charsets
4653 (with-current-buffer gnus-summary-buffer
4654 gnus-newsgroup-ignored-charsets)))
4656 (if (mm-handle-undisplayer handle)
4657 (mm-remove-part handle)
4658 (mm-display-part handle)))))
4660 (defun gnus-mime-view-part-internally (&optional handle)
4661 "View the MIME part under point with an internal viewer.
4662 If no internal viewer is available, use an external viewer."
4664 (gnus-article-check-buffer)
4665 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4666 (mm-inlined-types '(".*"))
4667 (mm-inline-large-images t)
4668 (mail-parse-charset gnus-newsgroup-charset)
4669 (mail-parse-ignored-charsets
4670 (with-current-buffer gnus-summary-buffer
4671 gnus-newsgroup-ignored-charsets))
4672 (inhibit-read-only t))
4674 (if (mm-handle-undisplayer handle)
4675 (mm-remove-part handle)
4676 (mm-display-part handle)))))
4678 (defun gnus-mime-action-on-part (&optional action)
4679 "Do something with the MIME attachment at \(point\)."
4681 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4682 (gnus-article-check-buffer)
4683 (let ((action-pair (assoc action gnus-mime-action-alist)))
4685 (funcall (cdr action-pair)))))
4687 (defun gnus-article-part-wrapper (n function)
4688 (with-current-buffer gnus-article-buffer
4689 (when (> n (length gnus-article-mime-handle-alist))
4690 (error "No such part"))
4691 (gnus-article-goto-part n)
4692 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4693 (funcall function handle))))
4695 (defun gnus-article-pipe-part (n)
4696 "Pipe MIME part N, which is the numerical prefix."
4698 (gnus-article-part-wrapper n 'mm-pipe-part))
4700 (defun gnus-article-save-part (n)
4701 "Save MIME part N, which is the numerical prefix."
4703 (gnus-article-part-wrapper n 'mm-save-part))
4705 (defun gnus-article-interactively-view-part (n)
4706 "View MIME part N interactively, which is the numerical prefix."
4708 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4710 (defun gnus-article-copy-part (n)
4711 "Copy MIME part N, which is the numerical prefix."
4713 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4715 (defun gnus-article-view-part-as-charset (n)
4716 "View MIME part N using a specified charset.
4717 N is the numerical prefix."
4719 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4721 (defun gnus-article-view-part-externally (n)
4722 "View MIME part N externally, which is the numerical prefix."
4724 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4726 (defun gnus-article-inline-part (n)
4727 "Inline MIME part N, which is the numerical prefix."
4729 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4731 (defun gnus-article-mime-match-handle-first (condition)
4733 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4734 (while (setq ihandle (pop alist))
4736 ((functionp condition)
4737 (funcall condition (cdr ihandle)))
4738 ((eq condition 'undisplayed)
4739 (not (or (mm-handle-undisplayer (cdr ihandle))
4740 (equal (mm-handle-media-type (cdr ihandle))
4741 "multipart/alternative"))))
4742 ((eq condition 'undisplayed-alternative)
4743 (not (mm-handle-undisplayer (cdr ihandle))))
4745 (gnus-article-goto-part (car ihandle))
4746 (or (not n) (< (car ihandle) n)))
4747 (setq n (car ihandle))))
4751 (defun gnus-article-view-part (&optional n)
4752 "View MIME part N, which is the numerical prefix."
4754 (with-current-buffer gnus-article-buffer
4755 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4756 gnus-article-mime-match-handle-function)))
4757 (when (> n (length gnus-article-mime-handle-alist))
4758 (error "No such part"))
4759 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4760 (when (gnus-article-goto-part n)
4761 (if (equal (car handle) "multipart/alternative")
4762 (gnus-article-press-button)
4763 (when (eq (gnus-mm-display-part handle) 'internal)
4764 (gnus-set-window-start)))))))
4766 (defsubst gnus-article-mime-total-parts ()
4767 (if (bufferp (car gnus-article-mime-handles))
4769 (1- (length gnus-article-mime-handles))))
4771 (defun gnus-mm-display-part (handle)
4772 "Display HANDLE and fix MIME button."
4773 (let ((id (get-text-property (point) 'gnus-part))
4775 (inhibit-read-only t))
4778 (let ((window (selected-window))
4779 (mail-parse-charset gnus-newsgroup-charset)
4780 (mail-parse-ignored-charsets
4781 (if (gnus-buffer-live-p gnus-summary-buffer)
4782 (with-current-buffer gnus-summary-buffer
4783 gnus-newsgroup-ignored-charsets)
4787 (let ((win (gnus-get-buffer-window (current-buffer) t))
4790 (select-window win))
4793 (if (mm-handle-displayed-p handle)
4794 ;; This will remove the part.
4795 (mm-display-part handle)
4797 (narrow-to-region (point)
4798 (if (eobp) (point) (1+ (point))))
4799 (mm-display-part handle)
4800 ;; We narrow to the part itself and
4801 ;; then call the treatment functions.
4802 (goto-char (point-min))
4804 (narrow-to-region (point) (point-max))
4807 (gnus-article-mime-total-parts)
4808 (mm-handle-media-type handle)))))
4809 (if (window-live-p window)
4810 (select-window window)))))
4813 (gnus-insert-mime-button
4814 handle id (list (mm-handle-displayed-p handle)))
4815 (goto-char point))))
4817 (defun gnus-article-goto-part (n)
4818 "Go to MIME part N."
4819 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4821 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4822 (let ((gnus-tmp-name
4823 (or (mail-content-type-get (mm-handle-type handle) 'name)
4824 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4825 (mail-content-type-get (mm-handle-type handle) 'url)
4827 (gnus-tmp-type (mm-handle-media-type handle))
4828 (gnus-tmp-description
4829 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4832 (if (if displayed (car displayed)
4833 (mm-handle-displayed-p handle))
4835 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4837 gnus-tmp-type-long b e)
4838 (when (string-match ".*/" gnus-tmp-name)
4839 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4840 (setq gnus-tmp-type-long (concat gnus-tmp-type
4841 (and (not (equal gnus-tmp-name ""))
4842 (concat "; " gnus-tmp-name))))
4843 (unless (equal gnus-tmp-description "")
4844 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4849 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4850 `(keymap ,gnus-mime-button-map
4851 gnus-callback gnus-mm-display-part
4852 gnus-part ,gnus-tmp-id
4853 article-type annotation
4856 ;; Exclude a newline.
4859 (widget-convert-button
4862 :action 'gnus-widget-press-button
4863 :button-keymap gnus-mime-button-map
4865 (lambda (widget/window &optional overlay pos)
4866 ;; Needed to properly clear the message due to a bug in
4867 ;; wid-edit (XEmacs only).
4868 (if (boundp 'help-echo-owns-message)
4869 (setq help-echo-owns-message t))
4871 "%S: %s the MIME part; %S: more options"
4872 (aref gnus-mouse-2 0)
4873 ;; XEmacs will get a single widget arg; Emacs 21 will get
4874 ;; window, overlay, position.
4875 (if (mm-handle-displayed-p
4877 (with-current-buffer (gnus-overlay-buffer overlay)
4878 (widget-get (widget-at (gnus-overlay-start overlay))
4880 (widget-get widget/window :mime-handle)))
4882 (aref gnus-down-mouse-3 0))))))
4884 (defun gnus-widget-press-button (elems el)
4885 (goto-char (widget-get elems :from))
4886 (gnus-article-press-button))
4888 (defvar gnus-displaying-mime nil)
4890 (defun gnus-display-mime (&optional ihandles)
4891 "Display the MIME parts."
4893 (save-selected-window
4894 (let ((window (get-buffer-window gnus-article-buffer))
4897 (select-window window)
4898 ;; We have to do this since selecting the window
4899 ;; may change the point. So we set the window point.
4900 (set-window-point window point)))
4901 (let* ((handles (or ihandles
4902 (mm-dissect-buffer nil gnus-article-loose-mime)
4903 (and gnus-article-emulate-mime
4905 (inhibit-read-only t) handle name type b e display)
4906 (when (and (not ihandles)
4907 (not gnus-displaying-mime))
4908 ;; Top-level call; we clean up.
4909 (when gnus-article-mime-handles
4910 (mm-destroy-parts gnus-article-mime-handles)
4911 (setq gnus-article-mime-handle-alist nil));; A trick.
4912 (setq gnus-article-mime-handles handles)
4913 ;; We allow users to glean info from the handles.
4914 (when gnus-article-mime-part-function
4915 (gnus-mime-part-function handles)))
4917 (or (not (stringp (car handles)))
4920 (when (and (not ihandles)
4921 (not gnus-displaying-mime))
4922 ;; Clean up for mime parts.
4924 (delete-region (point) (point-max)))
4925 (let ((gnus-displaying-mime t))
4926 (gnus-mime-display-part handles)))
4929 (narrow-to-region (point) (point-max))
4930 (gnus-treat-article nil 1 1)
4933 ;; Highlight the headers.
4937 (narrow-to-region (point-min) (point))
4938 (gnus-treat-article 'head))))))))
4940 (defcustom gnus-mime-display-multipart-as-mixed nil
4941 "Display \"multipart\" parts as \"multipart/mixed\".
4943 If t, it overrides nil values of
4944 `gnus-mime-display-multipart-alternative-as-mixed' and
4945 `gnus-mime-display-multipart-related-as-mixed'."
4946 :group 'gnus-article-mime
4949 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
4950 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
4951 :group 'gnus-article-mime
4954 (defcustom gnus-mime-display-multipart-related-as-mixed nil
4955 "Display \"multipart/related\" parts as \"multipart/mixed\".
4957 If displaying \"text/html\" is discouraged \(see
4958 `mm-discouraged-alternatives'\) images or other material inside a
4959 \"multipart/related\" part might be overlooked when this variable is nil."
4960 :group 'gnus-article-mime
4963 (defun gnus-mime-display-part (handle)
4966 ((not (stringp (car handle)))
4967 (gnus-mime-display-single handle))
4968 ;; User-defined multipart
4969 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4970 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4972 ;; multipart/alternative
4973 ((and (equal (car handle) "multipart/alternative")
4974 (not (or gnus-mime-display-multipart-as-mixed
4975 gnus-mime-display-multipart-alternative-as-mixed)))
4976 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4977 (push (cons id handle) gnus-article-mime-handle-alist)
4978 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4979 ;; multipart/related
4980 ((and (equal (car handle) "multipart/related")
4981 (not (or gnus-mime-display-multipart-as-mixed
4982 gnus-mime-display-multipart-related-as-mixed)))
4983 ;;;!!!We should find the start part, but we just default
4984 ;;;!!!to the first part.
4985 ;;(gnus-mime-display-part (cadr handle))
4986 ;;;!!! Most multipart/related is an HTML message plus images.
4987 ;;;!!! Unfortunately we are unable to let W3 display those
4988 ;;;!!! included images, so we just display it as a mixed multipart.
4989 ;;(gnus-mime-display-mixed (cdr handle))
4990 ;;;!!! No, w3 can display everything just fine.
4991 (gnus-mime-display-part (cadr handle)))
4992 ((equal (car handle) "multipart/signed")
4993 (gnus-add-wash-type 'signed)
4994 (gnus-mime-display-security handle))
4995 ((equal (car handle) "multipart/encrypted")
4996 (gnus-add-wash-type 'encrypted)
4997 (gnus-mime-display-security handle))
4998 ;; Other multiparts are handled like multipart/mixed.
5000 (gnus-mime-display-mixed (cdr handle)))))
5002 (defun gnus-mime-part-function (handles)
5003 (if (stringp (car handles))
5004 (mapcar 'gnus-mime-part-function (cdr handles))
5005 (funcall gnus-article-mime-part-function handles)))
5007 (defun gnus-mime-display-mixed (handles)
5008 (mapcar 'gnus-mime-display-part handles))
5010 (defun gnus-mime-display-single (handle)
5011 (let ((type (mm-handle-media-type handle))
5012 (ignored gnus-ignored-mime-types)
5019 (when (string-match (pop ignored) type)
5020 (throw 'ignored nil)))
5021 (if (and (setq not-attachment
5022 (and (not (mm-inline-override-p handle))
5023 (or (not (mm-handle-disposition handle))
5024 (equal (car (mm-handle-disposition handle))
5026 (mm-attachment-override-p handle))))
5027 (mm-automatic-display-p handle)
5029 (mm-inlinable-p handle)
5030 (mm-inlined-p handle))
5031 (mm-automatic-external-display-p type)))
5033 (when (equal (mm-handle-media-supertype handle) "text")
5035 (let ((id (1+ (length gnus-article-mime-handle-alist)))
5037 (push (cons id handle) gnus-article-mime-handle-alist)
5038 (when (or (not display)
5039 (not (gnus-unbuttonized-mime-type-p type)))
5040 (gnus-insert-mime-button
5041 handle id (list (or display (and not-attachment text))))
5042 (gnus-article-insert-newline)
5043 ;; Remember modify the number of forward lines.
5051 (let ((mail-parse-charset gnus-newsgroup-charset)
5052 (mail-parse-ignored-charsets
5053 (save-excursion (condition-case ()
5054 (set-buffer gnus-summary-buffer)
5056 gnus-newsgroup-ignored-charsets)))
5057 (mm-display-part handle t))
5058 (goto-char (point-max)))
5059 ((and text not-attachment)
5063 (gnus-article-insert-newline)
5064 (mm-insert-inline handle (mm-get-part handle))
5065 (goto-char (point-max))))
5069 (narrow-to-region beg (point))
5072 (gnus-article-mime-total-parts)
5073 (mm-handle-media-type handle)))))))))
5075 (defun gnus-unbuttonized-mime-type-p (type)
5076 "Say whether TYPE is to be unbuttonized."
5077 (unless gnus-inhibit-mime-unbuttonizing
5079 (let ((types gnus-unbuttonized-mime-types))
5081 (when (string-match (pop types) type)
5082 (throw 'found t)))))
5084 (let ((types gnus-buttonized-mime-types))
5086 (when (string-match (pop types) type)
5087 (throw 'found t)))))))))
5089 (defun gnus-article-insert-newline ()
5090 "Insert a newline, but mark it as undeletable."
5091 (gnus-put-text-property
5092 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
5094 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
5095 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
5098 handle (inhibit-read-only t) from props begend not-pref)
5099 (save-window-excursion
5102 (narrow-to-region (car ibegend)
5105 (goto-char (car ibegend))
5108 (delete-region (point-min) (point-max))
5109 (mm-remove-parts handles))
5110 (setq begend (list (point-marker)))
5112 (unless (setq not-pref (cadr (member preferred ihandles)))
5113 (setq not-pref (car ihandles)))
5116 (not (gnus-unbuttonized-mime-type-p
5117 "multipart/alternative")))
5118 (gnus-add-text-properties
5121 (insert (format "%d. " id))
5125 (unless ,(not ibegend)
5126 (setq gnus-article-mime-handle-alist
5127 ',gnus-article-mime-handle-alist))
5128 (gnus-mime-display-alternative
5129 ',ihandles ',not-pref ',begend ,id))
5130 keymap ,gnus-mime-button-map
5131 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5132 face ,gnus-article-button-face
5135 (widget-convert-button 'link from (point)
5136 :action 'gnus-widget-press-button
5137 :button-keymap gnus-widget-button-keymap)
5139 (while (setq handle (pop handles))
5140 (gnus-add-text-properties
5143 (insert (format "(%c) %-18s"
5144 (if (equal handle preferred) ?* ? )
5145 (mm-handle-media-type handle)))
5149 (unless ,(not ibegend)
5150 (setq gnus-article-mime-handle-alist
5151 ',gnus-article-mime-handle-alist))
5152 (gnus-mime-display-alternative
5153 ',ihandles ',handle ',begend ,id))
5154 keymap ,gnus-mime-button-map
5155 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5156 face ,gnus-article-button-face
5159 (widget-convert-button 'link from (point)
5160 :action 'gnus-widget-press-button
5161 :button-keymap gnus-widget-button-keymap)
5165 (if (stringp (car preferred))
5166 (gnus-display-mime preferred)
5167 (let ((mail-parse-charset gnus-newsgroup-charset)
5168 (mail-parse-ignored-charsets
5169 (with-current-buffer gnus-summary-buffer
5170 gnus-newsgroup-ignored-charsets)))
5171 (mm-display-part preferred)
5175 (narrow-to-region (car begend) (point-max))
5177 nil (length gnus-article-mime-handle-alist)
5178 (gnus-article-mime-total-parts)
5179 (mm-handle-media-type handle))))))
5180 (goto-char (point-max))
5181 (setcdr begend (point-marker)))))
5183 (goto-char point))))
5185 (defconst gnus-article-wash-status-strings
5186 (let ((alist '((cite "c" "Possible hidden citation text"
5187 " " "All citation text visible")
5188 (headers "h" "Hidden headers"
5189 " " "All headers visible.")
5190 (pgp "p" "Encrypted or signed message status hidden"
5191 " " "No hidden encryption nor digital signature status")
5192 (signature "s" "Signature has been hidden"
5193 " " "Signature is visible")
5194 (overstrike "o" "Overstrike (^H) characters applied"
5195 " " "No overstrike characters applied")
5196 (gnus-show-mime "m" "Mime processing is activated"
5197 " " "Mime processing is not activated")
5198 (emphasis "e" "/*_Emphasis_*/ characters applied"
5199 " " "No /*_emphasis_*/ characters applied")))
5201 (dolist (entry alist result)
5202 (let ((key (nth 0 entry))
5203 (on (copy-sequence (nth 1 entry)))
5204 (on-help (nth 2 entry))
5205 (off (copy-sequence (nth 3 entry)))
5206 (off-help (nth 4 entry)))
5207 (put-text-property 0 1 'help-echo on-help on)
5208 (put-text-property 0 1 'help-echo off-help off)
5209 (push (list key on off) result))))
5210 "Alist of strings describing wash status in the mode line.
5211 Each entry has the form (KEY ON OF), where the KEY is a symbol
5212 representing the particular washing function, ON is the string to use
5213 in the article mode line when the washing function is active, and OFF
5214 is the string to use when it is inactive.")
5216 (defun gnus-article-wash-status-entry (key value)
5217 (let ((entry (assoc key gnus-article-wash-status-strings)))
5218 (if value (nth 1 entry) (nth 2 entry))))
5220 (defun gnus-article-wash-status ()
5221 "Return a string which display status of article washing."
5222 (with-current-buffer gnus-article-buffer
5223 (let ((cite (memq 'cite gnus-article-wash-types))
5224 (headers (memq 'headers gnus-article-wash-types))
5225 (boring (memq 'boring-headers gnus-article-wash-types))
5226 (pgp (memq 'pgp gnus-article-wash-types))
5227 (pem (memq 'pem gnus-article-wash-types))
5228 (signed (memq 'signed gnus-article-wash-types))
5229 (encrypted (memq 'encrypted gnus-article-wash-types))
5230 (signature (memq 'signature gnus-article-wash-types))
5231 (overstrike (memq 'overstrike gnus-article-wash-types))
5232 (emphasis (memq 'emphasis gnus-article-wash-types)))
5234 (gnus-article-wash-status-entry 'cite cite)
5235 (gnus-article-wash-status-entry 'headers (or headers boring))
5236 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5237 (gnus-article-wash-status-entry 'signature signature)
5238 (gnus-article-wash-status-entry 'overstrike overstrike)
5239 (gnus-article-wash-status-entry 'gnus-show-mime gnus-show-mime)
5240 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5242 (defun gnus-add-wash-type (type)
5243 "Add a washing of TYPE to the current status."
5244 (add-to-list 'gnus-article-wash-types type))
5246 (defun gnus-delete-wash-type (type)
5247 "Add a washing of TYPE to the current status."
5248 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5250 (defun gnus-add-image (category image)
5251 "Add IMAGE of CATEGORY to the list of displayed images."
5252 (let ((entry (assq category gnus-article-image-alist)))
5254 (setq entry (list category))
5255 (push entry gnus-article-image-alist))
5256 (nconc entry (list image))))
5258 (defun gnus-delete-images (category)
5259 "Delete all images in CATEGORY."
5260 (let ((entry (assq category gnus-article-image-alist)))
5261 (dolist (image (cdr entry))
5262 (gnus-remove-image image category))
5263 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5264 (gnus-delete-wash-type category)))
5266 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5268 (defun gnus-article-maybe-hide-headers ()
5269 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5270 Provided for backwards compatibility."
5271 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5272 (not (with-current-buffer gnus-summary-buffer
5273 gnus-have-all-headers)))
5274 (not gnus-inhibit-hiding))
5275 (gnus-article-hide-headers)))
5279 (defun gnus-output-to-file (file-name)
5280 "Append the current article to a file named FILE-NAME."
5281 (let ((artbuf (current-buffer)))
5283 (insert-buffer-substring artbuf)
5284 ;; Append newline at end of the buffer as separator, and then
5286 (goto-char (point-max))
5288 (let ((file-name-coding-system nnmail-pathname-coding-system))
5289 (write-region-as-binary (point-min) (point-max) file-name 'append))
5292 (defun gnus-narrow-to-page (&optional arg)
5293 "Narrow the article buffer to a page.
5294 If given a numerical ARG, move forward ARG pages."
5296 (setq arg (if arg (prefix-numeric-value arg) 0))
5298 (set-buffer gnus-article-buffer)
5299 (goto-char (point-min))
5301 ;; Remove any old next/prev buttons.
5302 (when (gnus-visual-p 'page-marker)
5303 (let ((inhibit-read-only t))
5304 (gnus-remove-text-with-property 'gnus-prev)
5305 (gnus-remove-text-with-property 'gnus-next)))
5308 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5310 (re-search-forward page-delimiter nil 'move arg)))
5311 (goto-char (match-end 0))
5313 (goto-char (point-min))
5314 (setq gnus-page-broken
5315 (and (re-search-forward page-delimiter nil t) t))))
5316 (when gnus-page-broken
5319 (if (re-search-forward page-delimiter nil 'move)
5322 (when (and (gnus-visual-p 'page-marker)
5323 (> (point-min) (save-restriction (widen) (point-min))))
5325 (goto-char (point-min))
5326 (gnus-insert-prev-page-button)))
5327 (when (and (gnus-visual-p 'page-marker)
5328 (< (+ (point-max) 2) (buffer-size)))
5330 (goto-char (point-max))
5331 (gnus-insert-next-page-button))))))
5333 ;; Article mode commands
5335 (defun gnus-article-goto-next-page ()
5336 "Show the next page of the article."
5338 (when (gnus-article-next-page)
5339 (goto-char (point-min))
5340 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5343 (defun gnus-article-goto-prev-page ()
5344 "Show the previous page of the article."
5347 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5348 (gnus-article-prev-page nil)))
5350 ;; This is cleaner but currently breaks `gnus-pick-mode':
5352 ;; (defun gnus-article-goto-next-page ()
5353 ;; "Show the next page of the article."
5355 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5356 ;; (gnus-summary-next-page)))
5358 ;; (defun gnus-article-goto-prev-page ()
5359 ;; "Show the next page of the article."
5361 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5362 ;; (gnus-summary-prev-page)))
5364 (defun gnus-article-next-page (&optional lines)
5365 "Show the next page of the current article.
5366 If end of article, return non-nil. Otherwise return nil.
5367 Argument LINES specifies lines to be scrolled up."
5369 (move-to-window-line -1)
5372 (and (pos-visible-in-window-p) ;Not continuation line.
5373 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5374 ;; Nothing in this page.
5375 (if (or (not gnus-page-broken)
5380 (eobp)))) ;Real end-of-buffer?
5382 (when gnus-article-over-scroll
5383 (gnus-article-next-page-1 lines))
5385 (gnus-narrow-to-page 1) ;Go to next page.
5387 ;; More in this page.
5388 (gnus-article-next-page-1 lines)
5391 (defun gnus-article-next-page-1 (lines)
5392 (let ((scroll-in-place nil))
5396 ;; Long lines may cause an end-of-buffer error.
5397 (goto-char (point-max)))))
5398 (move-to-window-line 0))
5400 (defun gnus-article-prev-page (&optional lines)
5401 "Show previous page of current article.
5402 Argument LINES specifies lines to be scrolled down."
5404 (move-to-window-line 0)
5405 (if (and gnus-page-broken
5407 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5409 (gnus-narrow-to-page -1) ;Go to previous page.
5410 (goto-char (point-max))
5412 (let ((scroll-in-place nil))
5416 (beginning-of-buffer
5417 (goto-char (point-min))))
5418 (move-to-window-line 0)))))
5420 (defun gnus-article-only-boring-p ()
5421 "Decide whether there is only boring text remaining in the article.
5422 Something \"interesting\" is a word of at least two letters that does
5423 not have a face in `gnus-article-boring-faces'."
5424 (when (and gnus-article-skip-boring
5425 (boundp 'gnus-article-boring-faces)
5426 (symbol-value 'gnus-article-boring-faces))
5429 (while (re-search-forward "\\b\\w\\w" nil t)
5431 (when (not (gnus-intersection
5432 (gnus-faces-at (point))
5433 (symbol-value 'gnus-article-boring-faces)))
5434 (throw 'only-boring nil)))
5435 (throw 'only-boring t)))))
5437 (defun gnus-article-refer-article ()
5438 "Read article specified by message-id around point."
5441 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
5442 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
5443 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
5444 (let ((msg-id (concat "<" (match-string 0) ">")))
5445 (set-buffer gnus-summary-buffer)
5446 (gnus-summary-refer-article msg-id))
5447 (error "No references around point"))))
5449 (defun gnus-article-show-summary ()
5450 "Reconfigure windows to show summary buffer."
5452 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5453 (error "There is no summary buffer for this article buffer")
5454 (gnus-article-set-globals)
5455 (gnus-configure-windows 'article)
5456 (gnus-summary-goto-subject gnus-current-article)
5457 (gnus-summary-position-point)))
5459 (defun gnus-article-describe-briefly ()
5460 "Describe article mode commands briefly."
5462 (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")))
5464 (defun gnus-article-summary-command ()
5465 "Execute the last keystroke in the summary buffer."
5467 (let ((obuf (current-buffer))
5468 (owin (current-window-configuration))
5470 (switch-to-buffer gnus-article-current-summary 'norecord)
5471 (setq func (lookup-key (current-local-map) (this-command-keys)))
5472 (call-interactively func)
5474 (set-window-configuration owin)
5475 (set-window-point (get-buffer-window (current-buffer)) (point))))
5477 (defun gnus-article-summary-command-nosave ()
5478 "Execute the last keystroke in the summary buffer."
5481 (pop-to-buffer gnus-article-current-summary 'norecord)
5482 (setq func (lookup-key (current-local-map) (this-command-keys)))
5483 (call-interactively func)))
5485 (defun gnus-article-check-buffer ()
5486 "Beep if not in an article buffer."
5487 (unless (eq (get-buffer gnus-article-buffer) (current-buffer))
5488 (error "Command invoked outside of a Gnus article buffer")))
5490 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5491 "Read a summary buffer key sequence and execute it from the article buffer."
5493 (gnus-article-check-buffer)
5495 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5496 "Zc" "ZC" "ZE" "ZJ" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5497 "=" "^" "\M-^" "|"))
5503 '("n" "Gn" "p" "Gp"))
5506 (set-buffer gnus-article-current-summary)
5507 (let (gnus-pick-mode)
5508 (push (or key last-command-event) unread-command-events)
5509 (setq keys (static-if (featurep 'xemacs)
5510 (events-to-keys (read-key-sequence nil))
5511 (read-key-sequence nil)))))
5514 (if (or (member keys nosaves)
5515 (member keys nosave-but-article)
5516 (member keys nosave-in-article))
5518 (save-window-excursion
5519 (pop-to-buffer gnus-article-current-summary 'norecord)
5520 ;; We disable the pick minor mode commands.
5521 (let (gnus-pick-mode)
5522 (setq func (lookup-key (current-local-map) keys))))
5526 (unless (member keys nosave-in-article)
5527 (set-buffer gnus-article-current-summary))
5528 (call-interactively func)
5529 (setq new-sum-point (point)))
5530 (when (member keys nosave-but-article)
5531 (pop-to-buffer gnus-article-buffer 'norecord)))
5532 ;; These commands should restore window configuration.
5533 (let ((obuf (current-buffer))
5534 (owin (current-window-configuration))
5536 win func in-buffer selected new-sum-start new-sum-hscroll)
5537 (cond (not-restore-window
5538 (pop-to-buffer gnus-article-current-summary 'norecord))
5539 ((setq win (get-buffer-window gnus-article-current-summary))
5540 (select-window win))
5542 (switch-to-buffer gnus-article-current-summary 'norecord)))
5543 (setq in-buffer (current-buffer))
5544 ;; We disable the pick minor mode commands.
5545 (if (and (setq func (let (gnus-pick-mode)
5546 (lookup-key (current-local-map) keys)))
5549 (call-interactively func)
5550 (when (eq win (selected-window))
5551 (setq new-sum-point (point)
5552 new-sum-start (window-start win)
5553 new-sum-hscroll (window-hscroll win))
5554 (when (eq in-buffer (current-buffer))
5555 (setq selected (gnus-summary-select-article))
5557 (unless not-restore-window
5558 (set-window-configuration owin))
5559 (when (eq selected 'old)
5561 (set-window-start (get-buffer-window (current-buffer))
5563 (set-window-point (get-buffer-window (current-buffer))
5565 (when (and (not not-restore-window)
5567 (set-window-point win new-sum-point)
5568 (set-window-start win new-sum-start)
5569 (set-window-hscroll win new-sum-hscroll)))))
5570 (set-window-configuration owin)
5573 (defun gnus-article-describe-key (key)
5574 "Display documentation of the function invoked by KEY. KEY is a string."
5575 (interactive "kDescribe key: ")
5576 (gnus-article-check-buffer)
5577 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5579 (set-buffer gnus-article-current-summary)
5580 (let (gnus-pick-mode)
5581 (if (featurep 'xemacs)
5583 (push (elt key 0) unread-command-events)
5584 (setq key (events-to-keys
5585 (read-key-sequence "Describe key: "))))
5586 (setq unread-command-events
5588 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5590 (setq key (read-key-sequence "Describe key: "))))
5592 (describe-key key)))
5594 (defun gnus-article-describe-key-briefly (key &optional insert)
5595 "Display documentation of the function invoked by KEY. KEY is a string."
5596 (interactive "kDescribe key: \nP")
5597 (gnus-article-check-buffer)
5598 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5600 (set-buffer gnus-article-current-summary)
5601 (let (gnus-pick-mode)
5602 (if (featurep 'xemacs)
5604 (push (elt key 0) unread-command-events)
5605 (setq key (events-to-keys
5606 (read-key-sequence "Describe key: "))))
5607 (setq unread-command-events
5609 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5611 (setq key (read-key-sequence "Describe key: "))))
5612 (describe-key-briefly key insert))
5613 (describe-key-briefly key insert)))
5615 (defun gnus-article-reply-with-original (&optional wide)
5616 "Start composing a reply mail to the current message.
5617 The text in the region will be yanked. If the region isn't active,
5618 the entire article will be yanked."
5620 (let ((article (cdr gnus-article-current))
5622 (if (not (gnus-region-active-p))
5623 (with-current-buffer gnus-summary-buffer
5624 (gnus-summary-reply (list (list article)) wide))
5625 (setq contents (buffer-substring (point) (mark t)))
5626 ;; Deactivate active regions.
5627 (when (and (boundp 'transient-mark-mode)
5628 transient-mark-mode)
5629 (setq mark-active nil))
5630 (with-current-buffer gnus-summary-buffer
5632 (list (list article contents)) wide)))))
5634 (defun gnus-article-followup-with-original ()
5635 "Compose a followup to the current article.
5636 The text in the region will be yanked. If the region isn't active,
5637 the entire article will be yanked."
5639 (let ((article (cdr gnus-article-current))
5641 (if (not (gnus-region-active-p))
5642 (with-current-buffer gnus-summary-buffer
5643 (gnus-summary-followup (list (list article))))
5644 (setq contents (buffer-substring (point) (mark t)))
5645 ;; Deactivate active regions.
5646 (when (and (boundp 'transient-mark-mode)
5647 transient-mark-mode)
5648 (setq mark-active nil))
5649 (with-current-buffer gnus-summary-buffer
5650 (gnus-summary-followup
5651 (list (list article contents)))))))
5653 (defun gnus-article-hide (&optional arg force)
5654 "Hide all the gruft in the current article.
5655 This means that signatures, cited text and (some) headers will be
5657 If given a prefix, show the hidden text instead."
5658 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5659 (gnus-article-hide-headers arg)
5660 (gnus-article-hide-list-identifiers arg)
5661 (gnus-article-hide-citation-maybe arg force)
5662 (gnus-article-hide-signature arg))
5664 (defun gnus-article-maybe-highlight ()
5665 "Do some article highlighting if article highlighting is requested."
5666 (when (gnus-visual-p 'article-highlight 'highlight)
5667 (gnus-article-highlight-some)))
5669 (defun gnus-check-group-server ()
5670 ;; Make sure the connection to the server is alive.
5671 (unless (gnus-server-opened
5672 (gnus-find-method-for-group gnus-newsgroup-name))
5673 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5674 (gnus-request-group gnus-newsgroup-name t)))
5677 (autoload 'nneething-get-file-name "nneething"))
5679 (defun gnus-request-article-this-buffer (article group)
5680 "Get an article and insert it into this buffer."
5681 (let (do-update-line sparse-header)
5685 (gnus-kill-all-overlays)
5686 (setq group (or group gnus-newsgroup-name))
5688 ;; Using `gnus-request-article' directly will insert the article into
5689 ;; `nntp-server-buffer' - so we'll save some time by not having to
5690 ;; copy it from the server buffer into the article buffer.
5692 ;; We only request an article by message-id when we do not have the
5693 ;; headers for it, so we'll have to get those.
5694 (when (stringp article)
5695 (gnus-read-header article))
5697 ;; If the article number is negative, that means that this article
5698 ;; doesn't belong in this newsgroup (possibly), so we find its
5699 ;; message-id and request it by id instead of number.
5700 (when (and (numberp article)
5702 (get-buffer gnus-summary-buffer)
5703 (gnus-buffer-exists-p gnus-summary-buffer))
5705 (set-buffer gnus-summary-buffer)
5706 (let ((header (gnus-summary-article-header article)))
5709 ((memq article gnus-newsgroup-sparse)
5710 ;; This is a sparse gap article.
5711 (setq do-update-line article)
5712 (setq article (mail-header-id header))
5713 (setq sparse-header (gnus-read-header article))
5714 (setq gnus-newsgroup-sparse
5715 (delq article gnus-newsgroup-sparse)))
5717 ;; It's a real article.
5718 (setq article (mail-header-id header)))
5720 ;; It is an extracted pseudo-article.
5721 (setq article 'pseudo)
5722 (gnus-request-pseudo-article header))))
5724 (let ((method (gnus-find-method-for-group
5725 gnus-newsgroup-name)))
5726 (when (and (eq (car method) 'nneething)
5728 (let ((dir (nneething-get-file-name
5729 (mail-header-id header))))
5730 (when (and (stringp dir)
5731 (file-directory-p dir))
5732 (setq article 'nneething)
5733 (gnus-group-enter-directory dir))))))))
5736 ;; Refuse to select canceled articles.
5737 ((and (numberp article)
5739 (get-buffer gnus-summary-buffer)
5740 (gnus-buffer-exists-p gnus-summary-buffer)
5741 (eq (cdr (with-current-buffer gnus-summary-buffer
5742 (assq article gnus-newsgroup-reads)))
5743 gnus-canceled-mark))
5745 ;; We first check `gnus-original-article-buffer'.
5746 ((and (get-buffer gnus-original-article-buffer)
5748 (with-current-buffer gnus-original-article-buffer
5749 (and (equal (car gnus-original-article) group)
5750 (eq (cdr gnus-original-article) article))))
5751 (insert-buffer-substring gnus-original-article-buffer)
5753 ;; Check the backlog.
5754 ((and gnus-keep-backlog
5755 (gnus-backlog-request-article group article (current-buffer)))
5757 ;; Check asynchronous pre-fetch.
5758 ((gnus-async-request-fetched-article group article (current-buffer))
5759 (gnus-async-prefetch-next group article gnus-summary-buffer)
5760 (when (and (numberp article) gnus-keep-backlog)
5761 (gnus-backlog-enter-article group article (current-buffer)))
5764 ((and gnus-use-cache
5766 (gnus-cache-request-article article group))
5768 ;; Check the agent cache.
5769 ((gnus-agent-request-article article group)
5771 ;; Get the article and put into the article buffer.
5772 ((or (stringp article)
5774 (let ((gnus-override-method gnus-override-method)
5775 (methods (and (stringp article)
5776 gnus-refer-article-method))
5777 (backend (car (gnus-find-method-for-group
5778 gnus-newsgroup-name)))
5780 (inhibit-read-only t))
5781 (if (or (not (listp methods))
5782 (and (symbolp (car methods))
5783 (assq (car methods) nnoo-definition-alist)))
5784 (setq methods (list methods)))
5785 (when (and (null gnus-override-method)
5787 (setq gnus-override-method (pop methods)))
5789 (when (eq gnus-override-method 'current)
5790 (setq gnus-override-method
5791 (with-current-buffer gnus-summary-buffer
5792 gnus-current-select-method)))
5794 (gnus-kill-all-overlays)
5795 (let ((gnus-newsgroup-name group))
5796 (gnus-check-group-server))
5798 ((gnus-request-article article group (current-buffer))
5799 (when (numberp article)
5800 (gnus-async-prefetch-next group article
5801 gnus-summary-buffer)
5802 (when gnus-keep-backlog
5803 (gnus-backlog-enter-article
5804 group article (current-buffer))))
5805 (setq result 'article))
5807 (setq gnus-override-method (pop methods)))
5808 ((not (string-match "^400 "
5809 (nnheader-get-report backend)))
5810 ;; If we get 400 server disconnect, reconnect and
5811 ;; retry; otherwise, assume the article has expired.
5812 (setq result 'done))))
5813 (and (eq result 'article) 'article)))
5817 ;; Associate this article with the current summary buffer.
5818 (setq gnus-article-current-summary gnus-summary-buffer)
5820 ;; Take the article from the original article buffer
5821 ;; and place it in the buffer it's supposed to be in.
5822 (when (and (get-buffer gnus-article-buffer)
5823 (equal (buffer-name (current-buffer))
5824 (buffer-name (get-buffer gnus-article-buffer))))
5826 (if (get-buffer gnus-original-article-buffer)
5827 (set-buffer gnus-original-article-buffer)
5828 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5829 (buffer-disable-undo)
5830 (setq major-mode 'gnus-original-article-mode)
5831 (setq buffer-read-only t))
5832 (let ((inhibit-read-only t))
5834 (insert-buffer-substring gnus-article-buffer))
5835 (setq gnus-original-article (cons group article)))
5838 (run-hooks 'gnus-article-decode-hook)
5839 ;; Mark article as decoded or not.
5840 (setq gnus-article-decoded-p gnus-article-decode-hook))
5842 ;; Update sparse articles.
5843 (when (and do-update-line
5844 (or (numberp article)
5846 (let ((buf (current-buffer)))
5847 (set-buffer gnus-summary-buffer)
5848 (gnus-summary-update-article do-update-line sparse-header)
5849 (gnus-summary-goto-subject do-update-line nil t)
5850 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5852 (set-buffer buf))))))
5858 (defcustom gnus-article-edit-mode-hook nil
5859 "Hook run in article edit mode buffers."
5860 :group 'gnus-article-various
5863 (defcustom gnus-article-edit-article-setup-function
5864 'gnus-article-mime-edit-article-setup
5865 "Function called to setup an editing article buffer."
5866 :group 'gnus-article-various
5869 (defvar gnus-article-edit-done-function nil)
5871 (defvar gnus-article-edit-mode-map nil)
5873 ;; Should we be using derived.el for this?
5874 (unless gnus-article-edit-mode-map
5875 (setq gnus-article-edit-mode-map (make-keymap))
5876 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5878 (gnus-define-keys gnus-article-edit-mode-map
5879 "\C-c?" describe-mode
5880 "\C-c\C-c" gnus-article-edit-done
5881 "\C-c\C-k" gnus-article-edit-exit
5882 "\C-c\C-f\C-t" message-goto-to
5883 "\C-c\C-f\C-o" message-goto-from
5884 "\C-c\C-f\C-b" message-goto-bcc
5885 ;;"\C-c\C-f\C-w" message-goto-fcc
5886 "\C-c\C-f\C-c" message-goto-cc
5887 "\C-c\C-f\C-s" message-goto-subject
5888 "\C-c\C-f\C-r" message-goto-reply-to
5889 "\C-c\C-f\C-n" message-goto-newsgroups
5890 "\C-c\C-f\C-d" message-goto-distribution
5891 "\C-c\C-f\C-f" message-goto-followup-to
5892 "\C-c\C-f\C-m" message-goto-mail-followup-to
5893 "\C-c\C-f\C-k" message-goto-keywords
5894 "\C-c\C-f\C-u" message-goto-summary
5895 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5896 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5897 "\C-c\C-b" message-goto-body
5898 "\C-c\C-i" message-goto-signature
5900 "\C-c\C-t" message-insert-to
5901 "\C-c\C-n" message-insert-newsgroups
5902 "\C-c\C-o" message-sort-headers
5903 "\C-c\C-e" message-elide-region
5904 "\C-c\C-v" message-delete-not-region
5905 "\C-c\C-z" message-kill-to-signature
5906 "\M-\r" message-newline-and-reformat
5907 "\C-c\C-a" mml-attach-file
5908 "\C-a" message-beginning-of-line
5910 "\M-;" comment-region)
5912 (gnus-define-keys (gnus-article-edit-wash-map
5913 "\C-c\C-w" gnus-article-edit-mode-map)
5914 "f" gnus-article-edit-full-stops))
5917 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5919 ["Fetch To" message-insert-to t]
5920 ["Fetch Newsgroups" message-insert-newsgroups t]
5922 ["To" message-goto-to t]
5923 ["From" message-goto-from t]
5924 ["Subject" message-goto-subject t]
5925 ["Cc" message-goto-cc t]
5926 ["Reply-To" message-goto-reply-to t]
5927 ["Summary" message-goto-summary t]
5928 ["Keywords" message-goto-keywords t]
5929 ["Newsgroups" message-goto-newsgroups t]
5930 ["Followup-To" message-goto-followup-to t]
5931 ["Mail-Followup-To" message-goto-mail-followup-to t]
5932 ["Distribution" message-goto-distribution t]
5933 ["Body" message-goto-body t]
5934 ["Signature" message-goto-signature t]))
5936 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
5937 "Major mode for editing articles.
5938 This is an extended text-mode.
5940 \\{gnus-article-edit-mode-map}"
5941 (make-local-variable 'gnus-article-edit-done-function)
5942 (make-local-variable 'gnus-prev-winconf)
5943 (set (make-local-variable 'font-lock-defaults)
5944 '(message-font-lock-keywords t))
5945 (set (make-local-variable 'mail-header-separator) "")
5946 (set (make-local-variable 'gnus-article-edit-mode) t)
5947 (easy-menu-add message-mode-field-menu message-mode-map)
5948 (setq buffer-read-only nil)
5949 (buffer-enable-undo)
5952 (defun gnus-article-edit (&optional force)
5953 "Edit the current article.
5954 This will have permanent effect only in mail groups.
5955 If FORCE is non-nil, allow editing of articles even in read-only
5958 (when (and (not force)
5959 (gnus-group-read-only-p))
5960 (error "The current newsgroup does not support article editing"))
5961 (gnus-article-date-original)
5962 (gnus-article-edit-article
5964 `(lambda (no-highlight)
5966 (gnus-summary-edit-article-done
5967 ,(or (mail-header-references gnus-current-headers) "")
5968 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5970 (defun gnus-article-edit-article (start-func exit-func)
5971 "Start editing the contents of the current article buffer."
5972 (let ((winconf (current-window-configuration)))
5973 (set-buffer gnus-article-buffer)
5974 (gnus-article-edit-mode)
5975 (funcall start-func)
5976 (set-buffer-modified-p nil)
5977 (gnus-configure-windows 'edit-article)
5978 (setq gnus-article-edit-done-function exit-func)
5979 (setq gnus-prev-winconf winconf)
5980 (when gnus-article-edit-article-setup-function
5981 (funcall gnus-article-edit-article-setup-function))
5982 (gnus-message 6 "C-c C-c to end edits; C-c C-k to exit")))
5984 (defun gnus-article-edit-done (&optional arg)
5985 "Update the article edits and exit."
5987 (let ((func gnus-article-edit-done-function)
5988 (buf (current-buffer))
5989 (start (window-start))
5991 (winconf gnus-prev-winconf))
5992 (remove-hook 'gnus-article-mode-hook
5993 'gnus-article-mime-edit-article-unwind)
5994 (widen) ;; Widen it in case that users narrowed the buffer.
5997 ;; The cache and backlog have to be flushed somewhat.
5998 (when gnus-keep-backlog
5999 (gnus-backlog-remove-article
6000 (car gnus-article-current) (cdr gnus-article-current)))
6001 ;; Flush original article as well.
6003 (when (get-buffer gnus-original-article-buffer)
6004 (set-buffer gnus-original-article-buffer)
6005 (setq gnus-original-article nil)))
6006 (when gnus-use-cache
6007 (gnus-cache-update-article
6008 (car gnus-article-current) (cdr gnus-article-current)))
6009 ;; We remove all text props from the article buffer.
6010 (kill-all-local-variables)
6011 (set-text-properties (point-min) (point-max) nil)
6013 (set-window-configuration winconf)
6015 (set-window-start (get-buffer-window buf) start)
6016 (set-window-point (get-buffer-window buf) (point)))
6017 (gnus-summary-show-article))
6019 (defun gnus-article-edit-exit ()
6020 "Exit the article editing without updating."
6022 (when (or (not (buffer-modified-p))
6023 (yes-or-no-p "Article modified; kill anyway? "))
6024 (let ((curbuf (current-buffer))
6026 (window-start (window-start)))
6028 (if (gnus-buffer-live-p gnus-original-article-buffer)
6029 (insert-buffer-substring gnus-original-article-buffer))
6030 (let ((winconf gnus-prev-winconf))
6031 (kill-all-local-variables)
6033 (set-window-configuration winconf)
6034 ;; Tippy-toe some to make sure that point remains where it was.
6035 (save-current-buffer
6037 (set-window-start (get-buffer-window (current-buffer)) window-start)
6039 (gnus-summary-show-article)))
6041 (defun gnus-article-edit-full-stops ()
6042 "Interactively repair spacing at end of sentences."
6045 (goto-char (point-min))
6046 (search-forward-regexp "^$" nil t)
6047 (let ((case-fold-search nil))
6048 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
6051 ;;; Article editing with MIME-Edit
6054 (defcustom gnus-article-mime-edit-article-setup-hook nil
6055 "Hook run after setting up a MIME editing article buffer."
6056 :group 'gnus-article-various
6059 (defun gnus-article-mime-edit-article-unwind ()
6060 "Unwind `gnus-article-buffer' if article editing was given up."
6061 (remove-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6062 (when (featurep 'font-lock)
6063 (setq font-lock-defaults nil)
6064 (font-lock-mode -1))
6065 (when mime-edit-mode-flag
6066 (mime-edit-exit 'nomime 'no-error)
6069 (defun gnus-article-mime-edit-article-setup ()
6070 "Convert current buffer to MIME-Edit buffer and turn on MIME-Edit mode
6071 after replacing with the original article."
6072 (setq gnus-show-mime t)
6073 (setq gnus-article-edit-done-function
6074 `(lambda (&rest args)
6075 (when mime-edit-mode-flag
6076 (let (mime-edit-insert-user-agent-field)
6079 (goto-char (point-min))
6080 (let (case-fold-search)
6081 (when (re-search-forward
6082 (format "^%s$" (regexp-quote mail-header-separator))
6084 (replace-match "")))
6085 (apply ,gnus-article-edit-done-function args)
6088 (buffer-substring-no-properties (point-min) (point-max))
6089 (set-buffer (get-buffer-create gnus-original-article-buffer))
6091 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6092 (set-buffer gnus-article-buffer)
6093 (gnus-article-prepare-display)))
6094 (substitute-key-definition 'gnus-article-edit-done
6095 'gnus-article-mime-edit-done
6096 gnus-article-edit-mode-map)
6097 (substitute-key-definition 'gnus-article-edit-exit
6098 'gnus-article-mime-edit-exit
6099 gnus-article-edit-mode-map)
6101 (insert-buffer-substring gnus-original-article-buffer)
6102 (unless (member (with-current-buffer gnus-summary-buffer
6103 gnus-newsgroup-name)
6104 '("nndraft:delayed" "nndraft:drafts"))
6105 (let ((ofn (symbol-function 'mime-edit-decode-single-part-in-buffer)))
6106 (fset 'mime-edit-decode-single-part-in-buffer
6107 (lambda (&rest args)
6108 (if (let ((content-type (car args)))
6109 (and (eq 'message (mime-content-type-primary-type
6111 (eq 'rfc822 (mime-content-type-subtype
6113 (setcar (cdr args) 'not-decode-text))
6117 (fset 'mime-edit-decode-single-part-in-buffer ofn))))
6118 (when (featurep 'font-lock)
6119 (set (make-local-variable 'font-lock-defaults)
6120 '(message-font-lock-keywords t))
6121 (font-lock-set-defaults)
6122 (turn-on-font-lock))
6123 (set-buffer-modified-p nil)
6124 (delete-other-windows)
6125 (add-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6126 (gnus-run-hooks 'gnus-article-mime-edit-article-setup-hook))
6128 (defun gnus-article-mime-edit-done (&optional arg)
6129 "Update the article MIME edits and exit."
6131 (when (featurep 'font-lock)
6132 (setq font-lock-defaults nil)
6133 (font-lock-mode -1))
6134 (let ((inhibit-read-only t))
6135 (gnus-article-edit-done arg)))
6137 (defun gnus-article-mime-edit-exit ()
6138 "Exit the article MIME editing without updating."
6140 (when (or (not (buffer-modified-p))
6141 (yes-or-no-p "Article modified; kill anyway? "))
6142 (when (featurep 'font-lock)
6143 (setq font-lock-defaults nil)
6144 (font-lock-mode -1))
6145 (when mime-edit-mode-flag
6146 (let (mime-edit-insert-user-agent-field)
6149 (goto-char (point-min))
6150 (let (case-fold-search)
6151 (when (re-search-forward
6152 (format "^%s$" (regexp-quote mail-header-separator)) nil t)
6153 (replace-match "")))
6154 (let ((winconf gnus-prev-winconf))
6156 (buffer-substring-no-properties (point-min) (point-max))
6157 (set-buffer (get-buffer-create gnus-original-article-buffer))
6159 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6160 (set-buffer gnus-article-buffer)
6161 (gnus-article-prepare-display)
6162 (set-window-configuration winconf))))
6165 ;;; Article highlights
6168 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
6170 ;;; Internal Variables:
6172 (defcustom gnus-button-url-regexp
6173 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
6174 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|nntp\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-z0-9_.]+:[0-9]*\\)?[-a-z0-9_=!?#$@~%&*+\\/:;.,[:word:]]+[-a-z0-9_=#$@~%&*+\\/[:word:]]\\)"
6175 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|nntp\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-z0-9_.]+:[0-9]*\\)?\\([-a-z0-9_=!?#$@~%&*+\\/:;.,]\\|\\w\\)+\\([-a-z0-9_=#$@~%&*+\\/]\\|\\w\\)\\)")
6176 "Regular expression that matches URLs."
6177 :group 'gnus-article-buttons
6180 (defcustom gnus-button-valid-fqdn-regexp
6181 message-valid-fqdn-regexp
6182 "Regular expression that matches a valid FQDN."
6183 :group 'gnus-article-buttons
6186 (defcustom gnus-button-man-handler 'manual-entry
6187 "Function to use for displaying man pages.
6188 The function must take at least one argument with a string naming the
6190 :type '(choice (function-item :tag "Man" manual-entry)
6191 (function-item :tag "Woman" woman)
6192 (function :tag "Other"))
6193 :group 'gnus-article-buttons)
6195 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
6196 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
6197 If the default site is too slow, try to find a CTAN mirror, see
6198 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
6199 the variable `gnus-button-handle-ctan'."
6200 :group 'gnus-article-buttons
6201 :link '(custom-manual "(gnus)Group Parameters")
6202 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
6203 (const "http://tug.ctan.org/tex-archive/")
6204 (const "http://www.dante.de/CTAN/")
6205 (string :tag "Other")))
6207 (defcustom gnus-button-ctan-handler 'browse-url
6208 "Function to use for displaying CTAN links.
6209 The function must take one argument, the string naming the URL."
6210 :type '(choice (function-item :tag "Browse Url" browse-url)
6211 (function :tag "Other"))
6212 :group 'gnus-article-buttons)
6214 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
6215 "Bogus strings removed from CTAN URLs."
6216 :group 'gnus-article-buttons
6217 :type '(choice (const "^/?tex-archive/\\|/")
6218 (regexp :tag "Other")))
6220 (defcustom gnus-button-ctan-directory-regexp
6223 "biblio\\|digests\\|dviware\\|fonts\\|graphics\\|help\\|"
6224 "indexing\\|info\\|language\\|macros\\|support\\|systems\\|"
6225 "tds\\|tools\\|usergrps\\|web\\|nonfree\\|obsolete"
6227 "Regular expression for ctan directories.
6228 It should match all directories in the top level of `gnus-ctan-url'."
6229 :group 'gnus-article-buttons
6232 (defcustom gnus-button-mid-or-mail-regexp
6233 (concat "\\b\\(<?[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t ]*@"
6234 ;; Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
6235 gnus-button-valid-fqdn-regexp
6237 "Regular expression that matches a message ID or a mail address."
6238 :group 'gnus-article-buttons
6241 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
6242 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
6243 Strings like this can be either a message ID or a mail address. If it is one
6244 of the symbols `mid' or `mail', Gnus will always assume that the string is a
6245 message ID or a mail address, respectively. If this variable is set to the
6246 symbol `ask', always query the user what do do. If it is a function, this
6247 function will be called with the string as it's only argument. The function
6248 must return `mid', `mail', `invalid' or `ask'."
6249 :group 'gnus-article-buttons
6250 :type '(choice (function-item :tag "Heuristic function"
6251 gnus-button-mid-or-mail-heuristic)
6256 (defcustom gnus-button-mid-or-mail-heuristic-alist
6257 '((-10.0 . ".+\\$.+@")
6260 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
6261 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
6262 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
6263 (-1.0 . "^[^a-z]+@")
6265 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
6266 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
6267 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
6268 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
6271 (-1.0 . "^[0-9][0-9]")
6273 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
6274 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6275 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
6276 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6278 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
6279 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
6282 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
6284 ;; compensation for TDMA dated mail addresses:
6285 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
6287 (-20.0 . "\\.fsf@") ;; Gnus
6290 (-20.0 . "_-_") ;; Subject change in thread
6292 (-20.0 . "\\.ln@") ;; leafnode
6293 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
6294 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
6296 ;; (5.0 . "") ;; $local_part_len <= 7
6297 (10.0 . "^[^0-9]+@")
6298 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
6299 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
6302 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
6304 (0.5 . "^[A-Z][a-z]")
6305 (0.5 . "^[A-Z][a-z][a-z]")
6306 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
6307 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
6308 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
6310 A negative RATE indicates a message IDs, whereas a positive indicates a mail
6311 address. The REGEXP is processed with `case-fold-search' set to nil."
6312 :group 'gnus-article-buttons
6313 :type '(repeat (cons (number :tag "Rate")
6314 (regexp :tag "Regexp"))))
6316 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
6317 "Guess whether MID-OR-MAIL is a message ID or a mail address.
6318 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
6319 address, `ask' if unsure and `invalid' if the string is invalid."
6320 (let ((case-fold-search nil)
6321 (list gnus-button-mid-or-mail-heuristic-alist)
6322 (result 0) rate regexp lpartlen elem)
6324 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
6325 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
6326 ;; Certain special cases...
6329 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
6330 "^[0-9]+\\.[0-9]+@compuserve\\|"
6331 "@public\\.gmane\\.org")
6333 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
6334 (setq result 'mail))
6335 (when (string-match "@.*@\\| " mid-or-mail)
6336 (gnus-message 8 "`%s' is invalid." mid-or-mail)
6337 (setq result 'invalid))
6338 ;; Nothing more to do, if result is not a number here...
6339 (when (numberp result)
6341 (setq elem (car list)
6345 (when (string-match regexp mid-or-mail)
6346 (setq result (+ result rate))
6348 9 "`%s' matched `%s', rate `%s', result `%s'."
6349 mid-or-mail regexp rate result)))
6350 (when (<= lpartlen 7)
6351 (setq result (+ result 5.0))
6352 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
6353 mid-or-mail result))
6354 (when (>= lpartlen 12)
6355 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
6357 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
6358 ;; Long local part should contain realname if e-mail address,
6359 ;; too many digits: message-id.
6360 ;; $score -= 5.0 + 0.1 * $local_part_len;
6361 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6362 (setq result (+ result rate))
6364 9 "Many digits in `%s', rate `%s', result `%s'."
6365 mid-or-mail rate result))
6366 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6368 ;; Too few vowels [^aeiouy]{4,}.*\@
6369 (setq result (+ result -5.0))
6371 9 "Few vowels in `%s', rate `%s', result `%s'."
6372 mid-or-mail -5.0 result))
6374 (setq result (+ result 5.0))
6376 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6377 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6378 ;; Maybe we should make this a customizable alist: (condition . 'result)
6380 ((symbolp result) result)
6381 ;; Now convert number into proper results:
6382 ((< result -10.0) 'mid)
6383 ((> result 10.0) 'mail)
6386 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6387 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6388 (url-mid (concat "news" ":" mid-or-mail))
6389 (url-mailto (concat "mailto" ":" mid-or-mail)))
6390 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6391 (when (fboundp pref)
6393 ;; get rid of surrounding angles...
6395 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6396 (if (or (eq 'mid guessed) (eq 'mail guessed))
6400 (save-window-excursion
6401 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6404 (cond ((eq pref 'mid)
6405 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6406 (gnus-button-handle-news url-mid))
6408 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6409 (gnus-url-mailto url-mailto))
6410 (t (gnus-message 3 "Invalid string.")))))
6412 (defun gnus-button-handle-custom (url)
6413 "Follow a Custom URL."
6414 (customize-apropos (gnus-url-unhex-string url)))
6416 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6418 ;; FIXME: Maybe we should merge some of the functions that do quite similar
6421 (defun gnus-button-handle-describe-function (url)
6422 "Call `describe-function' when pushing the corresponding URL button."
6425 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6427 (defun gnus-button-handle-describe-variable (url)
6428 "Call `describe-variable' when pushing the corresponding URL button."
6431 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6433 (defun gnus-button-handle-symbol (url)
6434 "Display help on variable or function.
6435 Calls `describe-variable' or `describe-function'."
6436 (let ((sym (intern url)))
6438 ((fboundp sym) (describe-function sym))
6439 ((boundp sym) (describe-variable sym))
6440 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
6442 (defun gnus-button-handle-describe-key (url)
6443 "Call `describe-key' when pushing the corresponding URL button."
6445 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6446 (keys (ignore-errors (eval `(kbd ,key-string)))))
6449 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6451 (defun gnus-button-handle-apropos (url)
6452 "Call `apropos' when pushing the corresponding URL button."
6453 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6455 (defun gnus-button-handle-apropos-command (url)
6456 "Call `apropos' when pushing the corresponding URL button."
6458 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6460 (defun gnus-button-handle-apropos-variable (url)
6461 "Call `apropos' when pushing the corresponding URL button."
6463 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6464 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6466 (defun gnus-button-handle-apropos-documentation (url)
6467 "Call `apropos' when pushing the corresponding URL button."
6469 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6470 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6472 (defun gnus-button-handle-library (url)
6473 "Call `locate-library' when pushing the corresponding URL button."
6474 (gnus-message 9 "url=`%s'" url)
6475 (let* ((lib (locate-library url))
6476 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6478 (gnus-message 1 "Cannot locale library `%s'." url)
6479 (find-file-read-only file))))
6481 (defun gnus-button-handle-ctan (url)
6482 "Call `browse-url' when pushing a CTAN URL button."
6484 gnus-button-ctan-handler
6487 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6489 (defcustom gnus-button-tex-level 5
6490 "*Integer that says how many TeX-related buttons Gnus will show.
6491 The higher the number, the more buttons will appear and the more false
6492 positives are possible. Note that you can set this variable local to
6493 specific groups. Setting it higher in TeX groups is probably a good idea.
6494 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6495 how to set variables in specific groups."
6496 :group 'gnus-article-buttons
6497 :link '(custom-manual "(gnus)Group Parameters")
6500 (defcustom gnus-button-man-level 5
6501 "*Integer that says how many man-related buttons Gnus will show.
6502 The higher the number, the more buttons will appear and the more false
6503 positives are possible. Note that you can set this variable local to
6504 specific groups. Setting it higher in Unix groups is probably a good idea.
6505 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6506 how to set variables in specific groups."
6507 :group 'gnus-article-buttons
6508 :link '(custom-manual "(gnus)Group Parameters")
6511 (defcustom gnus-button-emacs-level 5
6512 "*Integer that says how many emacs-related buttons Gnus will show.
6513 The higher the number, the more buttons will appear and the more false
6514 positives are possible. Note that you can set this variable local to
6515 specific groups. Setting it higher in Emacs or Gnus related groups is
6516 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6517 `gnus-parameters' on how to set variables in specific groups."
6518 :group 'gnus-article-buttons
6519 :link '(custom-manual "(gnus)Group Parameters")
6522 (defcustom gnus-button-message-level 5
6523 "*Integer that says how many buttons for news or mail messages will appear.
6524 The higher the number, the more buttons will appear and the more false
6525 positives are possible."
6526 ;; mail addresses, MIDs, URLs for news, ...
6527 :group 'gnus-article-buttons
6530 (defcustom gnus-button-browse-level 5
6531 "*Integer that says how many buttons for browsing will appear.
6532 The higher the number, the more buttons will appear and the more false
6533 positives are possible."
6534 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6535 :group 'gnus-article-buttons
6538 (defcustom gnus-button-alist
6539 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6540 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6541 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
6542 gnus-button-handle-news 2)
6543 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6544 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6545 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6546 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6547 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
6548 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
6549 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
6550 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6551 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6552 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6553 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6554 ;; RFC 2368 (The mailto URL scheme)
6555 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6556 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6557 ("\\bmailto:\\([^ \n\t]+\\)"
6558 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6560 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6561 gnus-button-ctan-directory-regexp
6562 "[^][>)!;:,'\n\t ]+\\)")
6563 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6564 ((concat "\\btex-archive/\\("
6565 gnus-button-ctan-directory-regexp
6566 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6567 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6570 gnus-button-ctan-directory-regexp
6571 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6572 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6573 ;; This is info (home-grown style) <info://foo/bar+baz>
6574 ("\\binfo://\\([^'\">\n\t ]+\\)"
6575 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6576 ;; Info GNOME style <info:foo#bar_baz>
6577 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6578 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6579 ;; Info KDE style <info:(foo)bar baz>
6580 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6581 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6582 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6583 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6584 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6585 ;; Info links like `C-h i d m CC Mode RET'
6586 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6588 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6589 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6590 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6591 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6592 ;; Emacs help commands
6593 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6594 ;; regexp doesn't match arguments containing ` '.
6595 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6596 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6597 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6598 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6599 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6600 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6601 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6602 ;; The following entries may lead to many false positives so don't enable
6603 ;; them by default (use a high button level).
6604 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
6605 ;; Exclude [.?] for URLs in gmane.emacs.cvs
6606 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6607 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6608 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6609 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6610 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6611 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6612 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6613 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6614 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6615 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6616 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
6617 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6618 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6619 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6620 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6621 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6622 ;; Unlike the other regexps we really have to require quoting
6623 ;; here to determine where it ends.
6624 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6625 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
6626 ("<URL: *\\([^<>]*\\)>"
6627 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6628 ;; RFC 2396 (2.4.3., delims) ...
6629 ("\"URL: *\\([^\"]*\\)\""
6630 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6631 ;; RFC 2396 (2.4.3., delims) ...
6632 ("\"URL: *\\([^\"]*\\)\""
6633 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6635 (gnus-button-url-regexp
6636 0 (>= gnus-button-browse-level 0) browse-url 0)
6638 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
6639 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6640 gnus-button-handle-man 1)
6641 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6642 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
6643 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6644 gnus-button-handle-man 1)
6645 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6646 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6647 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
6648 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6649 ;; MID or mail: To avoid too many false positives we don't try to catch
6650 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6651 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6652 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6653 ;; so that non-ambiguous entries (see above) match first.
6654 (gnus-button-mid-or-mail-regexp
6655 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6656 "*Alist of regexps matching buttons in article bodies.
6658 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6659 REGEXP: is the string (case insensitive) matching text around the button (can
6660 also be Lisp expression evaluating to a string),
6661 BUTTON: is the number of the regexp grouping actually matching the button,
6662 FORM: is a Lisp expression which must eval to true for the button to
6664 CALLBACK: is the function to call when the user push this button, and each
6665 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6667 CALLBACK can also be a variable, in that case the value of that
6668 variable it the real callback function."
6669 :group 'gnus-article-buttons
6670 :type '(repeat (list (choice regexp variable sexp)
6671 (integer :tag "Button")
6673 (function :tag "Callback")
6676 (integer :tag "Regexp group")))))
6678 (defcustom gnus-header-button-alist
6679 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
6680 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6681 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6682 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6683 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6684 0 (>= gnus-button-message-level 0) gnus-button-mailto 0)
6685 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6686 0 (>= gnus-button-browse-level 0) browse-url 0)
6687 ("^Subject:" gnus-button-url-regexp
6688 0 (>= gnus-button-browse-level 0) browse-url 0)
6689 ("^[^:]+:" gnus-button-url-regexp
6690 0 (>= gnus-button-browse-level 0) browse-url 0)
6691 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6692 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6693 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6694 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6695 "*Alist of headers and regexps to match buttons in article heads.
6697 This alist is very similar to `gnus-button-alist', except that each
6698 alist has an additional HEADER element first in each entry:
6700 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6702 HEADER is a regexp to match a header. For a fuller explanation, see
6703 `gnus-button-alist'."
6704 :group 'gnus-article-buttons
6705 :group 'gnus-article-headers
6706 :type '(repeat (list (regexp :tag "Header")
6707 (choice regexp variable)
6708 (integer :tag "Button")
6710 (function :tag "Callback")
6713 (integer :tag "Regexp group")))))
6717 (defun gnus-article-push-button (event)
6718 "Check text under the mouse pointer for a callback function.
6719 If the text under the mouse pointer has a `gnus-callback' property,
6720 call it with the value of the `gnus-data' text property."
6722 (set-buffer (window-buffer (posn-window (event-start event))))
6723 (let* ((pos (posn-point (event-start event)))
6724 (data (get-text-property pos 'gnus-data))
6725 (fun (get-text-property pos 'gnus-callback)))
6728 (funcall fun data))))
6730 (defun gnus-article-press-button ()
6731 "Check text at point for a callback function.
6732 If the text at point has a `gnus-callback' property,
6733 call it with the value of the `gnus-data' text property."
6735 (let ((data (get-text-property (point) 'gnus-data))
6736 (fun (get-text-property (point) 'gnus-callback)))
6738 (funcall fun data))))
6740 (defun gnus-article-prev-button (n)
6741 "Move point to N buttons backward.
6742 If N is negative, move forward instead."
6744 (gnus-article-next-button (- n)))
6746 (defun gnus-article-next-button (n)
6747 "Move point to N buttons forward.
6748 If N is negative, move backward instead."
6750 (let ((function (if (< n 0) 'previous-single-property-change
6751 'next-single-property-change))
6752 (inhibit-point-motion-hooks t)
6754 (limit (if (< n 0) (point-min) (point-max))))
6756 (while (and (not (= limit (point)))
6758 ;; Skip past the current button.
6759 (when (get-text-property (point) 'gnus-callback)
6760 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6761 ;; Go to the next (or previous) button.
6762 (gnus-goto-char (funcall function (point) 'gnus-callback nil limit))
6763 ;; Put point at the start of the button.
6764 (when (and backward (not (get-text-property (point) 'gnus-callback)))
6765 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6766 ;; Skip past intangible buttons.
6767 (when (get-text-property (point) 'intangible)
6771 (gnus-message 5 "No more buttons"))
6774 (defun gnus-article-highlight (&optional force)
6775 "Highlight current article.
6776 This function calls `gnus-article-highlight-headers',
6777 `gnus-article-highlight-citation',
6778 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6779 do the highlighting. See the documentation for those functions."
6780 (interactive (list 'force))
6781 (gnus-article-highlight-headers)
6782 (gnus-article-highlight-citation force)
6783 (gnus-article-highlight-signature)
6784 (gnus-article-add-buttons force)
6785 (gnus-article-add-buttons-to-head))
6787 (defun gnus-article-highlight-some (&optional force)
6788 "Highlight current article.
6789 This function calls `gnus-article-highlight-headers',
6790 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6791 do the highlighting. See the documentation for those functions."
6792 (interactive (list 'force))
6793 (gnus-article-highlight-headers)
6794 (gnus-article-highlight-signature)
6795 (gnus-article-add-buttons))
6797 (defun gnus-article-highlight-headers ()
6798 "Highlight article headers as specified by `gnus-header-face-alist'."
6800 (gnus-with-article-headers
6801 (let ((alist gnus-header-face-alist)
6802 entry regexp header-face field-face from hpoints fpoints)
6803 (while (setq entry (pop alist))
6804 (goto-char (point-min))
6805 (setq regexp (concat "^\\("
6806 (if (string-equal "" (nth 0 entry))
6810 header-face (nth 1 entry)
6811 field-face (nth 2 entry))
6812 (while (and (re-search-forward regexp nil t)
6816 (unless (search-forward ":" nil t)
6818 (when (and header-face
6819 (not (memq (point) hpoints)))
6820 (push (point) hpoints)
6821 (gnus-put-text-property from (point) 'face header-face))
6822 (when (and field-face
6823 (not (memq (setq from (point)) fpoints)))
6825 (if (re-search-forward "^[^ \t]" nil t)
6827 (goto-char (point-max)))
6828 (gnus-put-text-property from (point) 'face field-face)))))))
6830 (defun gnus-article-highlight-signature ()
6831 "Highlight the signature in an article.
6832 It does this by highlighting everything after
6833 `gnus-signature-separator' using `gnus-signature-face'."
6835 (when gnus-signature-face
6836 (gnus-with-article-buffer
6837 (let ((inhibit-point-motion-hooks t))
6839 (when (gnus-article-narrow-to-signature)
6840 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6841 'face gnus-signature-face)))))))
6843 (defun gnus-article-buttonize-signature ()
6844 "Add button to the signature."
6847 (set-buffer gnus-article-buffer)
6848 (let ((inhibit-read-only t)
6849 (inhibit-point-motion-hooks t))
6850 (when (gnus-article-search-signature)
6851 (gnus-article-add-button (match-beginning 0) (match-end 0)
6852 'gnus-signature-toggle
6853 (set-marker (make-marker)
6854 (1+ (match-end 0))))))))
6856 (defun gnus-button-in-region-p (b e prop)
6857 "Say whether PROP exists in the region."
6858 (text-property-not-all b e prop nil))
6860 (defun gnus-article-add-buttons (&optional force)
6861 "Find external references in the article and make buttons of them.
6862 \"External references\" are things like Message-IDs and URLs, as
6863 specified by `gnus-button-alist'."
6864 (interactive (list 'force))
6865 (gnus-with-article-buffer
6866 (let ((inhibit-point-motion-hooks t)
6867 (case-fold-search t)
6868 (alist gnus-button-alist)
6870 ;; Remove all old markers.
6871 (let (marker entry new-list)
6872 (while (setq marker (pop gnus-button-marker-list))
6873 (if (or (< marker (point-min)) (>= marker (point-max)))
6874 (push marker new-list)
6876 (when (setq entry (gnus-button-entry))
6877 (put-text-property (match-beginning (nth 1 entry))
6878 (match-end (nth 1 entry))
6879 'gnus-callback nil))
6880 (set-marker marker nil)))
6881 (setq gnus-button-marker-list new-list))
6882 ;; We skip the headers.
6885 (while (setq entry (pop alist))
6886 (setq regexp (eval (car entry)))
6888 (while (re-search-forward regexp nil t)
6889 (let* ((start (and entry (match-beginning (nth 1 entry))))
6890 (end (and entry (match-end (nth 1 entry))))
6891 (from (match-beginning 0)))
6892 (when (and (or (eq t (nth 2 entry))
6893 (eval (nth 2 entry)))
6894 (not (gnus-button-in-region-p
6895 start end 'gnus-callback)))
6896 ;; That optional form returned non-nil, so we add the
6898 (gnus-article-add-button
6899 start end 'gnus-button-push
6900 (car (push (set-marker (make-marker) from)
6901 gnus-button-marker-list))))))))))
6903 ;; Add buttons to the head of an article.
6904 (defun gnus-article-add-buttons-to-head ()
6905 "Add buttons to the head of the article."
6907 (gnus-with-article-headers
6908 (let ((alist gnus-header-button-alist)
6911 ;; Each alist entry.
6912 (setq entry (pop alist))
6913 (goto-char (point-min))
6914 (while (re-search-forward (car entry) nil t)
6915 ;; Each header matching the entry.
6916 (setq beg (match-beginning 0))
6917 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6918 (match-beginning 0))
6921 (while (re-search-forward (eval (nth 1 entry)) end t)
6922 ;; Each match within a header.
6923 (let* ((entry (cdr entry))
6924 (start (match-beginning (nth 1 entry)))
6925 (end (match-end (nth 1 entry)))
6926 (form (nth 2 entry)))
6927 (goto-char (match-end 0))
6929 (gnus-article-add-button
6930 start end (nth 3 entry)
6931 (buffer-substring (match-beginning (nth 4 entry))
6932 (match-end (nth 4 entry)))))))
6933 (goto-char end))))))
6935 ;;; External functions:
6937 (defun gnus-article-add-button (from to fun &optional data)
6938 "Create a button between FROM and TO with callback FUN and data DATA."
6939 (when gnus-article-button-face
6940 (gnus-overlay-put (gnus-make-overlay from to)
6941 'face gnus-article-button-face))
6942 (gnus-add-text-properties
6944 (nconc (and gnus-article-mouse-face
6945 (list gnus-mouse-face-prop gnus-article-mouse-face))
6946 (list 'gnus-callback fun)
6947 (and data (list 'gnus-data data))))
6948 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6949 :button-keymap gnus-widget-button-keymap))
6951 ;;; Internal functions:
6953 (defun gnus-article-set-globals ()
6954 (with-current-buffer gnus-summary-buffer
6955 (gnus-set-global-variables)))
6957 (defun gnus-signature-toggle (end)
6958 (gnus-with-article-buffer
6959 (let ((inhibit-point-motion-hooks t)
6960 (limit (next-single-property-change end 'mime-view-entity
6962 (if (text-property-any end limit 'article-type 'signature)
6964 (gnus-delete-wash-type 'signature)
6965 (gnus-remove-text-properties-when
6966 'article-type 'signature end limit
6967 (cons 'article-type (cons 'signature
6968 gnus-hidden-properties))))
6969 (gnus-add-wash-type 'signature)
6970 (gnus-add-text-properties-when
6971 'article-type nil end limit
6972 (cons 'article-type (cons 'signature
6973 gnus-hidden-properties)))))
6974 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6975 (gnus-set-mode-line 'article))))
6977 (defun gnus-button-entry ()
6978 ;; Return the first entry in `gnus-button-alist' matching this place.
6979 (let ((alist gnus-button-alist)
6982 (setq entry (pop alist))
6983 (if (looking-at (eval (car entry)))
6988 (defun gnus-button-push (marker)
6989 ;; Push button starting at MARKER.
6992 (let* ((entry (gnus-button-entry))
6993 (inhibit-point-motion-hooks t)
6995 (args (mapcar (lambda (group)
6996 (let ((string (match-string group)))
6997 (set-text-properties
6998 0 (length string) nil string)
7005 (fboundp (symbol-value fun)))
7006 (apply (symbol-value fun) args))
7008 (gnus-message 1 "You must define `%S' to use this button"
7009 (cons fun args)))))))
7011 (defun gnus-parse-news-url (url)
7012 (let (scheme server group message-id articles)
7015 (goto-char (point-min))
7016 (when (looking-at "\\([A-Za-z]+\\):")
7017 (setq scheme (match-string 1))
7018 (goto-char (match-end 0)))
7019 (when (looking-at "//\\([^/]+\\)/")
7020 (setq server (match-string 1))
7021 (goto-char (match-end 0)))
7024 ((looking-at "\\(.*@.*\\)")
7025 (setq message-id (match-string 1)))
7026 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
7027 (setq group (match-string 1)
7028 articles (split-string (match-string 2) "-")))
7029 ((looking-at "\\([^/]+\\)/?")
7030 (setq group (match-string 1)))
7032 (error "Unknown news URL syntax"))))
7033 (list scheme server group message-id articles)))
7035 (defun gnus-button-handle-news (url)
7037 (destructuring-bind (scheme server group message-id articles)
7038 (gnus-parse-news-url url)
7042 (set-buffer gnus-summary-buffer)
7044 (let ((gnus-refer-article-method (list (list 'nntp server))))
7045 (gnus-summary-refer-article message-id))
7046 (gnus-summary-refer-article message-id))))
7048 (gnus-button-fetch-group url)))))
7050 (defun gnus-button-handle-man (url)
7052 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7053 (when (eq gnus-button-man-handler 'woman)
7054 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
7055 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7056 (funcall gnus-button-man-handler url))
7058 (defun gnus-button-handle-info-url (url)
7059 "Fetch an info URL."
7060 (setq url (mm-subst-char-in-string ?+ ?\ url))
7062 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
7063 (gnus-info-find-node
7064 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
7066 ")" (gnus-url-unhex-string (match-string 2 url)))))
7067 ((string-match "([^)\"]+)[^\"]+" url)
7069 (gnus-replace-in-string
7070 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
7071 (gnus-info-find-node url))
7072 (t (error "Can't parse %s" url))))
7074 (defun gnus-button-handle-info-url-gnome (url)
7075 "Fetch GNOME style info URL."
7076 (setq url (mm-subst-char-in-string ?_ ?\ url))
7077 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
7078 (gnus-info-find-node
7080 (gnus-url-unhex-string
7081 (match-string 1 url))
7083 (or (gnus-url-unhex-string
7084 (match-string 2 url))
7086 (error "Can't parse %s" url)))
7088 (defun gnus-button-handle-info-url-kde (url)
7089 "Fetch KDE style info URL."
7090 (gnus-info-find-node (gnus-url-unhex-string url)))
7092 (defun gnus-button-handle-info-keystrokes (url)
7093 "Call `info' when pushing the corresponding URL button."
7094 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
7099 (defun gnus-button-message-id (message-id)
7101 (with-current-buffer gnus-summary-buffer
7102 (gnus-summary-refer-article message-id)))
7104 (defun gnus-button-fetch-group (address)
7105 "Fetch GROUP specified by ADDRESS."
7106 (if (not (string-match "[:/]" address))
7107 ;; This is just a simple group url.
7108 (gnus-group-read-ephemeral-group address gnus-select-method)
7111 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
7113 (error "Can't parse %s" address)
7114 (gnus-group-read-ephemeral-group
7115 (match-string 4 address)
7116 `(nntp ,(match-string 1 address)
7117 (nntp-address ,(match-string 1 address))
7118 (nntp-port-number ,(if (match-end 3)
7119 (match-string 3 address)
7122 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
7124 (defun gnus-url-parse-query-string (query &optional downcase)
7125 (let (retval pairs cur key val)
7126 (setq pairs (split-string query "&"))
7128 (setq cur (car pairs)
7130 (if (not (string-match "=" cur))
7132 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
7133 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
7135 (setq key (downcase key)))
7136 (setq cur (assoc key retval))
7138 (setcdr cur (cons val (cdr cur)))
7139 (setq retval (cons (list key val) retval)))))
7142 (defun gnus-url-mailto (url)
7143 ;; Send mail to someone
7144 (when (string-match "mailto:/*\\(.*\\)" url)
7145 (setq url (substring url (match-beginning 1) nil)))
7146 (let (to args subject func)
7147 (setq args (gnus-url-parse-query-string
7148 (if (string-match "^\\?" url)
7150 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
7151 (concat "to=" (match-string 1 url) "&"
7152 (match-string 2 url))
7153 (concat "to=" url)))
7155 subject (cdr-safe (assoc "subject" args)))
7158 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
7161 (message-position-on-field (caar args)))
7162 (insert (gnus-replace-in-string
7163 (mapconcat 'identity (reverse (cdar args)) ", ")
7165 (setq args (cdr args)))
7168 (message-goto-subject))))
7170 (defun gnus-button-embedded-url (address)
7171 "Activate ADDRESS with `browse-url'."
7172 (browse-url (gnus-strip-whitespace address)))
7174 ;;; Next/prev buttons in the article buffer.
7176 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
7177 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
7179 (defvar gnus-prev-page-map
7180 (let ((map (make-sparse-keymap)))
7181 (define-key map gnus-mouse-2 'gnus-button-prev-page)
7182 (define-key map "\r" 'gnus-button-prev-page)
7185 (defvar gnus-next-page-map
7186 (let ((map (make-sparse-keymap)))
7187 (unless (>= emacs-major-version 21)
7188 ;; XEmacs doesn't care.
7189 (set-keymap-parent map gnus-article-mode-map))
7190 (define-key map gnus-mouse-2 'gnus-button-next-page)
7191 (define-key map "\r" 'gnus-button-next-page)
7194 (defun gnus-insert-prev-page-button ()
7196 (inhibit-read-only t)
7197 (situation (get-text-property (point-min) 'mime-view-situation)))
7199 gnus-prev-page-line-format nil
7200 `(keymap ,gnus-prev-page-map
7202 gnus-callback gnus-article-button-prev-page
7203 article-type annotation
7204 mime-view-situation ,situation))
7205 (widget-convert-button
7207 ;; Exclude a newline.
7210 :action 'gnus-button-prev-page
7211 :button-keymap gnus-prev-page-map)))
7213 (defun gnus-button-next-page (&optional args more-args)
7214 "Go to the next page."
7216 (let ((win (selected-window)))
7217 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7218 (gnus-article-next-page)
7219 (select-window win)))
7221 (defun gnus-button-prev-page (&optional args more-args)
7222 "Go to the prev page."
7224 (let ((win (selected-window)))
7225 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7226 (gnus-article-prev-page)
7227 (select-window win)))
7229 (defun gnus-insert-next-page-button ()
7231 (inhibit-read-only t)
7232 (situation (get-text-property (point-min) 'mime-view-situation)))
7233 (gnus-eval-format gnus-next-page-line-format nil
7234 `(keymap ,gnus-next-page-map
7236 gnus-callback gnus-article-button-next-page
7237 article-type annotation
7238 mime-view-situation ,situation))
7239 (widget-convert-button
7241 ;; Exclude a newline.
7244 :action 'gnus-button-next-page
7245 :button-keymap gnus-next-page-map)))
7247 (defun gnus-article-button-next-page (arg)
7248 "Go to the next page."
7250 (let ((win (selected-window)))
7251 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7252 (gnus-article-next-page)
7253 (select-window win)))
7255 (defun gnus-article-button-prev-page (arg)
7256 "Go to the prev page."
7258 (let ((win (selected-window)))
7259 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7260 (gnus-article-prev-page)
7261 (select-window win)))
7263 (defvar gnus-decode-header-methods
7264 '(mail-decode-encoded-word-region)
7265 "List of methods used to decode headers.
7267 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
7268 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
7269 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
7270 whose names match REGEXP.
7273 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
7274 mail-decode-encoded-word-region
7275 (\"chinese\" . rfc1843-decode-region))
7278 (defvar gnus-decode-header-methods-cache nil)
7280 (defun gnus-multi-decode-header (start end)
7281 "Apply the functions from `gnus-encoded-word-methods' that match."
7282 (unless (and gnus-decode-header-methods-cache
7283 (eq gnus-newsgroup-name
7284 (car gnus-decode-header-methods-cache)))
7285 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
7288 (nconc gnus-decode-header-methods-cache (list x))
7289 (if (and gnus-newsgroup-name
7290 (string-match (car x) gnus-newsgroup-name))
7291 (nconc gnus-decode-header-methods-cache
7293 gnus-decode-header-methods))
7294 (let ((xlist gnus-decode-header-methods-cache))
7297 (narrow-to-region start end)
7299 (funcall (pop xlist) (point-min) (point-max))))))
7302 ;;; Treatment top-level handling.
7305 (defun gnus-treat-article (condition &optional part-number total-parts type)
7306 (let ((length (- (point-max) (point-min)))
7307 (alist gnus-treatment-function-alist)
7308 (article-goto-body-goes-to-point-min-p t)
7312 (let ((list gnus-article-treat-types))
7314 (when (string-match (pop list) type)
7315 (throw 'found t)))))))
7316 (highlightp (gnus-visual-p 'article-highlight 'highlight))
7317 (entity (static-unless (featurep 'xemacs)
7318 (when (eq 'head condition)
7319 (get-text-property (point-min) 'mime-view-entity))))
7320 val elem buttonized)
7321 (gnus-run-hooks 'gnus-part-display-hook)
7322 (unless gnus-inhibit-treatment
7323 (dolist (elem alist)
7326 (when (gnus-buffer-live-p gnus-summary-buffer)
7327 (set-buffer gnus-summary-buffer))
7328 (symbol-value (car elem))))
7329 (when (and (or (consp val)
7331 (gnus-treat-predicate val)
7332 (or (not (get (car elem) 'highlight))
7334 (when (and (not buttonized)
7336 '(gnus-treat-hide-signature
7337 gnus-treat-highlight-signature)))
7338 (gnus-article-buttonize-signature)
7339 (setq buttonized t))
7341 (funcall (cadr elem)))))
7342 ;; FSF Emacsen does not inherit the existing text properties
7343 ;; in the new text, so we should do it for `mime-view-entity'.
7344 (static-unless (featurep 'xemacs)
7346 (put-text-property (point-min) (point-max)
7347 'mime-view-entity entity))))))
7349 ;; Dynamic variables.
7351 (defvar part-number)
7352 (defvar total-parts)
7357 (defun gnus-treat-predicate (val)
7362 (stringp (car val)))
7363 (apply 'gnus-or (mapcar `(lambda (s)
7364 (string-match s ,(or gnus-newsgroup-name "")))
7367 (let ((pred (pop val)))
7370 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
7372 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
7374 (not (gnus-treat-predicate (car val))))
7376 (equal (car val) type))
7378 (error "%S is not a valid predicate" pred)))))
7388 (eq part-number total-parts))
7392 (error "%S is not a valid value" val))))
7394 (defun gnus-article-encrypt-body (protocol &optional n)
7395 "Encrypt the article body."
7398 (or gnus-article-encrypt-protocol
7399 (completing-read "Encrypt protocol: "
7400 gnus-article-encrypt-protocol-alist
7402 current-prefix-arg))
7403 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7405 (error (format "Can't find the encrypt protocol %s" protocol)))
7406 (if (member gnus-newsgroup-name '("nndraft:delayed"
7409 (error "Can't encrypt the article in group %s"
7410 gnus-newsgroup-name))
7411 (gnus-summary-iterate n
7413 (set-buffer gnus-summary-buffer)
7414 (let ((mail-parse-charset gnus-newsgroup-charset)
7415 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7416 (summary-buffer gnus-summary-buffer)
7418 (gnus-set-global-variables)
7419 (when (gnus-group-read-only-p)
7420 (error "The current newsgroup does not support article encrypt"))
7421 (gnus-summary-show-article t)
7423 (or (mail-header-references gnus-current-headers) ""))
7424 (set-buffer gnus-article-buffer)
7425 (let* ((inhibit-read-only t)
7427 (mapcar (lambda (field)
7428 (and (save-restriction
7429 (message-narrow-to-head)
7430 (goto-char (point-min))
7431 (search-forward field nil t))
7433 (message-narrow-to-field)
7435 (delete-region (point-min) (point-max))
7437 '("Content-Type:" "Content-Transfer-Encoding:"
7438 "Content-Disposition:"))))
7439 (message-narrow-to-head)
7440 (message-remove-header "MIME-Version")
7441 (goto-char (point-max))
7442 (setq point (point))
7443 (insert (apply 'concat headers))
7445 (narrow-to-region point (point-max))
7446 (let ((message-options message-options))
7447 (message-options-set 'message-sender user-mail-address)
7448 (message-options-set 'message-recipients user-mail-address)
7449 (message-options-set 'message-sign-encrypt 'not)
7451 (goto-char (point-min))
7452 (insert "MIME-Version: 1.0\n")
7454 (gnus-summary-edit-article-done
7455 references nil summary-buffer t))
7456 (when gnus-keep-backlog
7457 (gnus-backlog-remove-article
7458 (car gnus-article-current) (cdr gnus-article-current)))
7460 (when (get-buffer gnus-original-article-buffer)
7461 (set-buffer gnus-original-article-buffer)
7462 (setq gnus-original-article nil)))
7463 (when gnus-use-cache
7464 (gnus-cache-update-article
7465 (car gnus-article-current) (cdr gnus-article-current))))))))
7467 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7468 "The following specs can be used:
7469 %t The security MIME type
7472 %D Details if button is pressed")
7474 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
7475 "The following specs can be used:
7476 %t The security MIME type
7479 %D Details if button is pressed")
7481 (defvar gnus-mime-security-button-line-format-alist
7482 '((?t gnus-tmp-type ?s)
7483 (?i gnus-tmp-info ?s)
7484 (?d gnus-tmp-details ?s)
7485 (?D gnus-tmp-pressed-details ?s)))
7487 (defvar gnus-mime-security-button-map
7488 (let ((map (make-sparse-keymap)))
7489 (define-key map gnus-mouse-2 'gnus-article-push-button)
7490 (define-key map "\r" 'gnus-article-press-button)
7493 (defvar gnus-mime-security-details-buffer nil)
7495 (defvar gnus-mime-security-button-pressed nil)
7497 (defvar gnus-mime-security-show-details-inline t
7498 "If non-nil, show details in the article buffer.")
7500 (defun gnus-mime-security-verify-or-decrypt (handle)
7501 (mm-remove-parts (cdr handle))
7502 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7503 point (inhibit-read-only t))
7505 (goto-char (car region)))
7507 (narrow-to-region (point) (point))
7508 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7509 (let* ((mm-verify-option 'known)
7510 (mm-decrypt-option 'known)
7511 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7512 (unless (eq nparts (cdr handle))
7513 (mm-destroy-parts (cdr handle))
7514 (setcdr handle nparts))))
7515 (setq point (point))
7516 (gnus-mime-display-security handle)
7517 (goto-char (point-max)))
7519 (delete-region (point) (cdr region))
7520 (set-marker (car region) nil)
7521 (set-marker (cdr region) nil))
7524 (defun gnus-mime-security-show-details (handle)
7525 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7527 (gnus-message 5 "No details.")
7528 (if gnus-mime-security-show-details-inline
7529 (let ((gnus-mime-security-button-pressed
7530 (not (get-text-property (point) 'gnus-mime-details)))
7531 (gnus-mime-security-button-line-format
7532 (get-text-property (point) 'gnus-line-format))
7533 (inhibit-read-only t))
7535 (while (eq (get-text-property (point) 'gnus-line-format)
7536 gnus-mime-security-button-line-format)
7540 (narrow-to-region (point) (point))
7541 (gnus-insert-mime-security-button handle))
7542 (delete-region (point)
7543 (or (text-property-not-all
7546 gnus-mime-security-button-line-format)
7549 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7550 (with-current-buffer gnus-mime-security-details-buffer
7553 (setq gnus-mime-security-details-buffer
7554 (gnus-get-buffer-create "*MIME Security Details*")))
7555 (with-current-buffer gnus-mime-security-details-buffer
7557 (goto-char (point-min)))
7558 (pop-to-buffer gnus-mime-security-details-buffer)))))
7560 (defun gnus-mime-security-press-button (handle)
7562 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7563 (gnus-mime-security-show-details handle)
7564 (gnus-mime-security-verify-or-decrypt handle))))
7566 (defun gnus-insert-mime-security-button (handle &optional displayed)
7567 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7570 (or (nth 2 (assoc protocol mm-verify-function-alist))
7571 (nth 2 (assoc protocol mm-decrypt-function-alist))
7573 (if (equal (car handle) "multipart/signed")
7574 " Signed" " Encrypted")
7577 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7580 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7581 gnus-tmp-pressed-details
7583 (setq gnus-tmp-details
7584 (if gnus-tmp-details
7585 (concat "\n" gnus-tmp-details)
7587 (setq gnus-tmp-pressed-details
7588 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7593 gnus-mime-security-button-line-format
7594 gnus-mime-security-button-line-format-alist
7595 `(keymap ,gnus-mime-security-button-map
7596 gnus-callback gnus-mime-security-press-button
7597 gnus-line-format ,gnus-mime-security-button-line-format
7598 gnus-mime-details ,gnus-mime-security-button-pressed
7599 article-type annotation
7602 ;; Exclude a newline.
7605 (widget-convert-button
7608 :action 'gnus-widget-press-button
7609 :button-keymap gnus-mime-security-button-map
7611 (lambda (widget/window &optional overlay pos)
7612 ;; Needed to properly clear the message due to a bug in
7613 ;; wid-edit (XEmacs only).
7614 (when (boundp 'help-echo-owns-message)
7615 (setq help-echo-owns-message t))
7618 (aref gnus-mouse-2 0))))))
7620 (defun gnus-mime-display-security (handle)
7622 (narrow-to-region (point) (point))
7623 (unless (gnus-unbuttonized-mime-type-p (car handle))
7624 (gnus-insert-mime-security-button handle))
7625 (gnus-mime-display-mixed (cdr handle))
7628 (unless (gnus-unbuttonized-mime-type-p (car handle))
7629 (let ((gnus-mime-security-button-line-format
7630 gnus-mime-security-button-end-line-format))
7631 (gnus-insert-mime-security-button handle)))
7632 (mm-set-handle-multipart-parameter
7634 (cons (set-marker (make-marker) (point-min))
7635 (set-marker (make-marker) (point-max))))))
7641 (defun gnus-article-header-presentation-method (entity situation)
7642 (mime-insert-header entity)
7643 (article-decode-group-name))
7645 (set-alist 'mime-header-presentation-method-alist
7646 'gnus-original-article-mode
7647 #'gnus-article-header-presentation-method)
7649 (defun gnus-mime-preview-quitting-method ()
7650 (mime-preview-kill-buffer)
7651 (delete-other-windows)
7652 (gnus-article-show-summary)
7653 (gnus-summary-select-article gnus-show-all-headers t))
7655 (set-alist 'mime-preview-quitting-method-alist
7656 'gnus-original-article-mode #'gnus-mime-preview-quitting-method)
7658 (set-alist 'mime-preview-following-method-alist
7659 'gnus-original-article-mode #'gnus-following-method)
7661 (set-alist 'mime-preview-over-to-previous-method-alist
7662 'gnus-original-article-mode
7664 (if (> (point-min) 1)
7665 (gnus-article-prev-page)
7666 (gnus-article-read-summary-keys
7667 nil (gnus-character-to-event ?P)))))
7669 (set-alist 'mime-preview-over-to-next-method-alist
7670 'gnus-original-article-mode'
7672 (if (< (point-max) (buffer-size))
7673 (gnus-article-next-page)
7674 (gnus-article-read-summary-keys
7675 nil (gnus-character-to-event ?N)))))
7685 (run-hooks 'gnus-art-load-hook)
7687 ;;; gnus-art.el ends here