1 ;;; gnus-art.el --- article mode commands for Semi-gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
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)The 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."
250 :type '(choice (integer :value 200)
252 (function :value fun)
253 (regexp :value ".*"))
254 :group 'gnus-article-signature)
256 (defcustom gnus-hidden-properties '(invisible t intangible t)
257 "Property list to use for hiding text."
259 :group 'gnus-article-hiding)
261 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
262 ;; frames in a session.
263 (defcustom gnus-article-x-face-command
268 (if (or (gnus-image-type-available-p 'xface)
269 (gnus-image-type-available-p 'pbm))
270 'gnus-display-x-face-in-from
271 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -"))
272 ((and (fboundp 'image-type-available-p)
273 (module-installed-p 'x-face-e21))
274 'x-face-decode-message-header)
275 ((gnus-image-type-available-p 'pbm)
276 'gnus-display-x-face-in-from)
278 (module-installed-p 'x-face-mule))
279 'x-face-mule-gnus-article-display-x-face)
281 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
283 "*String or function to be executed to display an X-Face header.
284 If it is a string, the command will be executed in a sub-shell
285 asynchronously. The compressed face will be piped to this command."
287 ,@(let (x-face-e21 x-face-mule)
288 (if (featurep 'xemacs)
290 (setq x-face-e21 (module-installed-p 'x-face-e21)
291 x-face-mule (module-installed-p 'x-face-mule)))
295 (if (or (gnus-image-type-available-p 'xface)
296 (gnus-image-type-available-p 'pbm))
297 '(function-item gnus-display-x-face-in-from))
299 (fboundp 'image-type-available-p))
301 :tag "x-face-decode-message-header (x-face-e21)"
302 x-face-decode-message-header))
305 x-face-mule-gnus-article-display-x-face))
309 :group 'gnus-article-washing)
311 (defcustom gnus-article-x-face-too-ugly nil
312 "Regexp matching posters whose face shouldn't be shown automatically."
313 :type '(choice regexp (const nil))
314 :group 'gnus-article-washing)
316 (defcustom gnus-article-banner-alist nil
317 "Banner alist for stripping.
319 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
321 :type '(repeat (cons symbol regexp))
322 :group 'gnus-article-washing)
324 (gnus-define-group-parameter
327 "Alist of regexps (to match group names) and banner."
328 :variable-group gnus-article-washing
330 '(choice :tag "Banner"
332 (const :tag "Remove signature" signature)
333 (symbol :tag "Item in `gnus-article-banner-alist'" none)
335 (const :tag "None" nil))
337 "If non-nil, specify how to remove `banners' from articles.
339 Symbol `signature' means to remove signatures delimited by
340 `gnus-signature-separator'. Any other symbol is used to look up a
341 regular expression to match the banner in `gnus-article-banner-alist'.
342 A string is used as a regular expression to match the banner
345 (defcustom gnus-article-address-banner-alist nil
346 "Alist of mail addresses and banners.
347 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
348 to match a mail address in the From: header, BANNER is one of a symbol
349 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
350 If ADDRESS matches author's mail address, it will remove things like
351 advertisements. For example:
353 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
357 (regexp :tag "Address")
358 (choice :tag "Banner" :value nil
359 (const :tag "Remove signature" signature)
360 (symbol :tag "Item in `gnus-article-banner-alist'" none)
362 (const :tag "None" nil))))
363 :group 'gnus-article-washing)
365 (defcustom gnus-emphasis-alist
367 "\\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)")
372 ("_/" "/_" underline-italic)
373 ("_\\*" "\\*_" underline-bold)
374 ("\\*/" "/\\*" bold-italic)
375 ("_\\*/" "/\\*_" underline-bold-italic))))
379 (format format (car spec) (car (cdr spec)))
380 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
382 ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
383 2 3 gnus-emphasis-strikethru)
384 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
385 2 3 gnus-emphasis-underline)))
386 "*Alist that says how to fontify certain phrases.
387 Each item looks like this:
389 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
391 The first element is a regular expression to be matched. The second
392 is a number that says what regular expression grouping used to find
393 the entire emphasized word. The third is a number that says what
394 regexp grouping should be displayed and highlighted. The fourth
395 is the face used for highlighting."
396 :type '(repeat (list :value ("" 0 0 default)
398 (integer :tag "Match group")
399 (integer :tag "Emphasize group")
401 :group 'gnus-article-emphasis)
403 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
404 "A regexp to describe whitespace which should not be emphasized.
405 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
406 The former avoids underlining of leading and trailing whitespace,
407 and the latter avoids underlining any whitespace at all."
409 :group 'gnus-article-emphasis
412 (defface gnus-emphasis-bold '((t (:bold t)))
413 "Face used for displaying strong emphasized text (*word*)."
414 :group 'gnus-article-emphasis)
416 (defface gnus-emphasis-italic '((t (:italic t)))
417 "Face used for displaying italic emphasized text (/word/)."
418 :group 'gnus-article-emphasis)
420 (defface gnus-emphasis-underline '((t (:underline t)))
421 "Face used for displaying underlined emphasized text (_word_)."
422 :group 'gnus-article-emphasis)
424 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
425 "Face used for displaying underlined bold emphasized text (_*word*_)."
426 :group 'gnus-article-emphasis)
428 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
429 "Face used for displaying underlined italic emphasized text (_/word/_)."
430 :group 'gnus-article-emphasis)
432 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
433 "Face used for displaying bold italic emphasized text (/*word*/)."
434 :group 'gnus-article-emphasis)
436 (defface gnus-emphasis-underline-bold-italic
437 '((t (:bold t :italic t :underline t)))
438 "Face used for displaying underlined bold italic emphasized text.
439 Example: (_/*word*/_)."
440 :group 'gnus-article-emphasis)
442 (defface gnus-emphasis-strikethru (if (featurep 'xemacs)
443 '((t (:strikethru t)))
444 '((t (:strike-through t))))
445 "Face used for displaying strike-through text (-word-)."
446 :group 'gnus-article-emphasis)
448 (defface gnus-emphasis-highlight-words
449 '((t (:background "black" :foreground "yellow")))
450 "Face used for displaying highlighted words."
451 :group 'gnus-article-emphasis)
453 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
454 "Format for display of Date headers in article bodies.
455 See `format-time-string' for the possible values.
457 The variable can also be function, which should return a complete Date
458 header. The function is called with one argument, the time, which can
459 be fed to `format-time-string'."
460 :type '(choice string symbol)
461 :link '(custom-manual "(gnus)Article Date")
462 :group 'gnus-article-washing)
465 (autoload 'mail-extract-address-components "mail-extr"))
467 (defcustom gnus-save-all-headers t
468 "*If non-nil, don't remove any headers before saving."
469 :group 'gnus-article-saving
472 (defcustom gnus-prompt-before-saving 'always
473 "*This variable says how much prompting is to be done when saving articles.
474 If it is nil, no prompting will be done, and the articles will be
475 saved to the default files. If this variable is `always', each and
476 every article that is saved will be preceded by a prompt, even when
477 saving large batches of articles. If this variable is neither nil not
478 `always', there the user will be prompted once for a file name for
479 each invocation of the saving commands."
480 :group 'gnus-article-saving
481 :type '(choice (item always)
482 (item :tag "never" nil)
483 (sexp :tag "once" :format "%t\n" :value t)))
485 (defcustom gnus-saved-headers gnus-visible-headers
486 "Headers to keep if `gnus-save-all-headers' is nil.
487 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
488 If that variable is nil, however, all headers that match this regexp
489 will be kept while the rest will be deleted before saving."
490 :group 'gnus-article-saving
493 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
494 "A function to save articles in your favourite format.
495 The function must be interactively callable (in other words, it must
496 be an Emacs command).
498 Gnus provides the following functions:
500 * gnus-summary-save-in-rmail (Rmail format)
501 * gnus-summary-save-in-mail (Unix mail format)
502 * gnus-summary-save-in-folder (MH folder)
503 * gnus-summary-save-in-file (article format)
504 * gnus-summary-save-body-in-file (article body)
505 * gnus-summary-save-in-vm (use VM's folder format)
506 * gnus-summary-write-to-file (article format -- overwrite)."
507 :group 'gnus-article-saving
508 :type '(radio (function-item gnus-summary-save-in-rmail)
509 (function-item gnus-summary-save-in-mail)
510 (function-item gnus-summary-save-in-folder)
511 (function-item gnus-summary-save-in-file)
512 (function-item gnus-summary-save-body-in-file)
513 (function-item gnus-summary-save-in-vm)
514 (function-item gnus-summary-write-to-file)))
516 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
517 "A function generating a file name to save articles in Rmail format.
518 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
519 :group 'gnus-article-saving
522 (defcustom gnus-mail-save-name 'gnus-plain-save-name
523 "A function generating a file name to save articles in Unix mail format.
524 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
525 :group 'gnus-article-saving
528 (defcustom gnus-folder-save-name 'gnus-folder-save-name
529 "A function generating a file name to save articles in MH folder.
530 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
531 :group 'gnus-article-saving
534 (defcustom gnus-file-save-name 'gnus-numeric-save-name
535 "A function generating a file name to save articles in article format.
536 The function is called with NEWSGROUP, HEADERS, and optional
538 :group 'gnus-article-saving
541 (defcustom gnus-split-methods
542 '((gnus-article-archive-name)
543 (gnus-article-nndoc-name))
544 "*Variable used to suggest where articles are to be saved.
545 For instance, if you would like to save articles related to Gnus in
546 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
547 you could set this variable to something like:
549 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
550 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
552 This variable is an alist where the where the key is the match and the
553 value is a list of possible files to save in if the match is non-nil.
555 If the match is a string, it is used as a regexp match on the
556 article. If the match is a symbol, that symbol will be funcalled
557 from the buffer of the article to be saved with the newsgroup as the
558 parameter. If it is a list, it will be evaled in the same buffer.
560 If this form or function returns a string, this string will be used as
561 a possible file name; and if it returns a non-nil list, that list will
562 be used as possible file names."
563 :group 'gnus-article-saving
564 :type '(repeat (choice (list :value (fun) function)
565 (cons :value ("" "") regexp (repeat string))
568 (defcustom gnus-article-display-method-for-mime
569 'gnus-article-display-mime-message
570 "Function to display a MIME message.
571 The function is called from the article buffer."
572 :group 'gnus-article-mime
575 (defcustom gnus-article-display-method-for-traditional
576 'gnus-article-display-traditional-message
577 "*Function to display a traditional message.
578 The function is called from the article buffer."
579 :group 'gnus-article-mime
582 (defcustom gnus-page-delimiter "^\^L"
583 "*Regexp describing what to use as article page delimiters.
584 The default value is \"^\^L\", which is a form linefeed at the
585 beginning of a line."
587 :group 'gnus-article-various)
589 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
590 "*The format specification for the article mode line.
591 See `gnus-summary-mode-line-format' for a closer description.
593 The following additional specs are available:
595 %w The article washing status.
596 %m The number of MIME parts in the article."
598 :group 'gnus-article-various)
600 (defcustom gnus-article-mode-hook nil
601 "*A hook for Gnus article mode."
603 :group 'gnus-article-various)
605 (when (featurep 'xemacs)
606 ;; Extracted from gnus-xmas-define in order to preserve user settings
607 (when (fboundp 'turn-off-scroll-in-place)
608 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
609 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
610 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
612 (defcustom gnus-article-menu-hook nil
613 "*Hook run after the creation of the article mode menu."
615 :group 'gnus-article-various)
617 (defcustom gnus-article-prepare-hook nil
618 "*A hook called after an article has been prepared in the article buffer."
620 :group 'gnus-article-various)
622 (make-obsolete-variable 'gnus-article-hide-pgp-hook
623 "This variable is obsolete in Gnus 5.10.")
625 (defcustom gnus-article-button-face 'bold
626 "Face used for highlighting buttons in the article buffer.
628 An article button is a piece of text that you can activate by pressing
629 `RET' or `mouse-2' above it."
631 :group 'gnus-article-buttons)
633 (defcustom gnus-article-mouse-face 'highlight
634 "Face used for mouse highlighting in the article buffer.
636 Article buttons will be displayed in this face when the cursor is
639 :group 'gnus-article-buttons)
641 (defcustom gnus-signature-face 'gnus-signature-face
642 "Face used for highlighting a signature in the article buffer.
643 Obsolete; use the face `gnus-signature-face' for customizations instead."
645 :group 'gnus-article-highlight
646 :group 'gnus-article-signature)
648 (defface gnus-signature-face
651 "Face used for highlighting a signature in the article buffer."
652 :group 'gnus-article-highlight
653 :group 'gnus-article-signature)
655 (defface gnus-header-from-face
658 (:foreground "spring green"))
661 (:foreground "red3"))
664 "Face used for displaying from headers."
665 :group 'gnus-article-headers
666 :group 'gnus-article-highlight)
668 (defface gnus-header-subject-face
671 (:foreground "SeaGreen3"))
674 (:foreground "red4"))
676 (:bold t :italic t)))
677 "Face used for displaying subject headers."
678 :group 'gnus-article-headers
679 :group 'gnus-article-highlight)
681 (defface gnus-header-newsgroups-face
684 (:foreground "yellow" :italic t))
687 (:foreground "MidnightBlue" :italic t))
690 "Face used for displaying newsgroups headers.
691 In the default setup this face is only used for crossposted
693 :group 'gnus-article-headers
694 :group 'gnus-article-highlight)
696 (defface gnus-header-name-face
699 (:foreground "SeaGreen"))
702 (:foreground "maroon"))
705 "Face used for displaying header names."
706 :group 'gnus-article-headers
707 :group 'gnus-article-highlight)
709 (defface gnus-header-content-face
712 (:foreground "forest green" :italic t))
715 (:foreground "indianred4" :italic t))
718 "Face used for displaying header content."
719 :group 'gnus-article-headers
720 :group 'gnus-article-highlight)
722 (defcustom gnus-header-face-alist
723 '(("From" nil gnus-header-from-face)
724 ("Subject" nil gnus-header-subject-face)
725 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
726 ("" gnus-header-name-face gnus-header-content-face))
727 "*Controls highlighting of article headers.
729 An alist of the form (HEADER NAME CONTENT).
731 HEADER is a regular expression which should match the name of a
732 header and NAME and CONTENT are either face names or nil.
734 The name of each header field will be displayed using the face
735 specified by the first element in the list where HEADER matches
736 the header name and NAME is non-nil. Similarly, the content will
737 be displayed by the first non-nil matching CONTENT face."
738 :group 'gnus-article-headers
739 :group 'gnus-article-highlight
740 :type '(repeat (list (regexp :tag "Header")
742 (item :tag "skip" nil)
743 (face :value default))
744 (choice :tag "Content"
745 (item :tag "skip" nil)
746 (face :value default)))))
748 (defcustom gnus-article-decode-hook
749 '(article-decode-group-name article-decode-idna-rhs)
750 "*Hook run to decode charsets in articles."
751 :group 'gnus-article-headers
754 (defcustom gnus-display-mime-function 'gnus-display-mime
755 "Function to display MIME articles."
756 :group 'gnus-article-mime
759 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
760 "Function used to decode headers.")
762 (defvar gnus-article-dumbquotes-map
782 "Table for MS-to-Latin1 translation.")
784 (defcustom gnus-ignored-mime-types nil
785 "List of MIME types that should be ignored by Gnus."
787 :group 'gnus-article-mime
788 :type '(repeat regexp))
790 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
791 "List of MIME types that should not be given buttons when rendered inline.
792 See also `gnus-buttonized-mime-types' which may override this variable.
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-buttonized-mime-types nil
799 "List of MIME types that should be given buttons when rendered inline.
800 If set, this variable overrides `gnus-unbuttonized-mime-types'.
801 To see e.g. security buttons you could set this to
802 `(\"multipart/signed\")'.
803 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
805 :group 'gnus-article-mime
806 :type '(repeat regexp))
808 (defcustom gnus-inhibit-mime-unbuttonizing nil
809 "If non-nil, all MIME parts get buttons.
810 When nil (the default value), then some MIME parts do not get buttons,
811 as described by the variables `gnus-buttonized-mime-types' and
812 `gnus-unbuttonized-mime-types'."
816 (defcustom gnus-body-boundary-delimiter "_"
817 "String used to delimit header and body.
818 This variable is used by `gnus-article-treat-body-boundary' which can
819 be controlled by `gnus-treat-body-boundary'."
820 :group 'gnus-article-various
821 :type '(choice (item :tag "None" :value nil)
824 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces")
825 "Defines the location of the faces database.
826 For information on obtaining this database of pretty pictures, please
827 see http://www.cs.indiana.edu/picons/ftp/index.html"
828 :type '(repeat directory)
829 :link '(url-link :tag "download"
830 "http://www.cs.indiana.edu/picons/ftp/index.html")
831 :link '(custom-manual "(gnus)Picons")
834 (defun gnus-picons-installed-p ()
835 "Say whether picons are installed on your machine."
836 (let ((installed nil))
837 (dolist (database gnus-picon-databases)
838 (when (file-exists-p database)
842 (defcustom gnus-article-mime-part-function nil
843 "Function called with a MIME handle as the argument.
844 This is meant for people who want to do something automatic based
845 on parts -- for instance, adding Vcard info to a database."
846 :group 'gnus-article-mime
849 (defcustom gnus-mime-multipart-functions nil
850 "An alist of MIME types to functions to display them."
852 :group 'gnus-article-mime
855 (defcustom gnus-article-date-lapsed-new-header nil
856 "Whether the X-Sent and Date headers can coexist.
857 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
858 either replace the old \"Date:\" header (if this variable is nil), or
859 be added below it (otherwise)."
861 :group 'gnus-article-headers
864 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
865 "Function called with a MIME handle as the argument.
866 This is meant for people who want to view first matched part.
867 For `undisplayed-alternative' (default), the first undisplayed
868 part or alternative part is used. For `undisplayed', the first
869 undisplayed part is used. For a function, the first part which
870 the function return t is used. For nil, the first part is
873 :group 'gnus-article-mime
875 (item :tag "first" :value nil)
876 (item :tag "undisplayed" :value undisplayed)
877 (item :tag "undisplayed or alternative"
878 :value undisplayed-alternative)
881 (defcustom gnus-mime-action-alist
882 '(("save to file" . gnus-mime-save-part)
883 ("save and strip" . gnus-mime-save-part-and-strip)
884 ("delete part" . gnus-mime-delete-part)
885 ("display as text" . gnus-mime-inline-part)
886 ("view the part" . gnus-mime-view-part)
887 ("pipe to command" . gnus-mime-pipe-part)
888 ("toggle display" . gnus-article-press-button)
889 ("toggle display" . gnus-article-view-part-as-charset)
890 ("view as type" . gnus-mime-view-part-as-type)
891 ("view internally" . gnus-mime-view-part-internally)
892 ("view externally" . gnus-mime-view-part-externally))
893 "An alist of actions that run on the MIME attachment."
894 :group 'gnus-article-mime
895 :type '(repeat (cons (string :tag "name")
899 ;;; The treatment variables
902 (defvar gnus-part-display-hook nil
903 "Hook called on parts that are to receive treatment.")
905 (defvar gnus-article-treat-custom
906 '(choice (const :tag "Off" nil)
908 (const :tag "Header" head)
909 (const :tag "Last" last)
910 (const :tag "Mime" mime)
911 (integer :tag "Less")
912 (repeat :tag "Groups" regexp)
913 (sexp :tag "Predicate")))
915 (defvar gnus-article-treat-head-custom
916 '(choice (const :tag "Off" nil)
917 (const :tag "Header" head)))
919 (defvar gnus-article-treat-types '("text/plain")
922 (defvar gnus-inhibit-treatment nil
923 "Whether to inhibit treatment.")
925 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
926 "Highlight the signature.
927 Valid values are nil, t, `head', `last', an integer or a predicate.
928 See Info node `(gnus)Customizing Articles'."
929 :group 'gnus-article-treat
930 :link '(custom-manual "(gnus)Customizing Articles")
931 :type gnus-article-treat-custom)
932 (put 'gnus-treat-highlight-signature 'highlight t)
934 (defcustom gnus-treat-buttonize 100000
936 Valid values are nil, t, `head', `last', an integer or a predicate.
937 See Info node `(gnus)Customizing Articles'."
938 :group 'gnus-article-treat
939 :link '(custom-manual "(gnus)Customizing Articles")
940 :type gnus-article-treat-custom)
941 (put 'gnus-treat-buttonize 'highlight t)
943 (defcustom gnus-treat-buttonize-head 'head
944 "Add buttons to the head.
945 Valid values are nil, t, `head', `last', an integer or a predicate.
946 See Info node `(gnus)Customizing Articles' for details."
947 :group 'gnus-article-treat
948 :link '(custom-manual "(gnus)Customizing Articles")
949 :type gnus-article-treat-head-custom)
950 (put 'gnus-treat-buttonize-head 'highlight t)
952 (defcustom gnus-treat-emphasize
953 (and (or window-system
957 Valid values are nil, t, `head', `last', an integer or a predicate.
958 See Info node `(gnus)Customizing Articles' for details."
959 :group 'gnus-article-treat
960 :link '(custom-manual "(gnus)Customizing Articles")
961 :type gnus-article-treat-custom)
962 (put 'gnus-treat-emphasize 'highlight t)
964 (defcustom gnus-treat-strip-cr nil
965 "Remove carriage returns.
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-unsplit-urls nil
973 "Remove newlines from within URLs.
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-leading-whitespace nil
981 "Remove leading whitespace in headers.
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-custom)
988 (defcustom gnus-treat-hide-headers 'head
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-boring-headers nil
997 "Hide boring headers.
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-head-custom)
1004 (defcustom gnus-treat-hide-signature nil
1005 "Hide the signature.
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-fill-article 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 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-hide-citation-maybe nil
1030 Valid values are nil, t, `head', `last', an integer or a predicate.
1031 See Info node `(gnus)Customizing Articles' for details."
1032 :group 'gnus-article-treat
1033 :link '(custom-manual "(gnus)Customizing Articles")
1034 :type gnus-article-treat-custom)
1036 (defcustom gnus-treat-strip-list-identifiers 'head
1037 "Strip list identifiers from `gnus-list-identifiers`.
1038 Valid values are nil, t, `head', `last', an integer or a predicate.
1039 See Info node `(gnus)Customizing Articles' for details."
1041 :group 'gnus-article-treat
1042 :link '(custom-manual "(gnus)Customizing Articles")
1043 :type gnus-article-treat-custom)
1045 (make-obsolete-variable 'gnus-treat-strip-pgp
1046 "This option is obsolete in Gnus 5.10.")
1048 (defcustom gnus-treat-strip-pem nil
1049 "Strip PEM signatures.
1050 Valid values are nil, t, `head', `last', an integer or a predicate.
1051 See Info node `(gnus)Customizing Articles' for details."
1052 :group 'gnus-article-treat
1053 :link '(custom-manual "(gnus)Customizing Articles")
1054 :type gnus-article-treat-custom)
1056 (defcustom gnus-treat-strip-banner t
1057 "Strip banners from articles.
1058 The banner to be stripped is specified in the `banner' group parameter.
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-custom)
1065 (defcustom gnus-treat-highlight-headers 'head
1066 "Highlight the headers.
1067 Valid values are nil, t, `head', `last', an integer or a predicate.
1068 See Info node `(gnus)Customizing Articles' for details."
1069 :group 'gnus-article-treat
1070 :link '(custom-manual "(gnus)Customizing Articles")
1071 :type gnus-article-treat-head-custom)
1072 (put 'gnus-treat-highlight-headers 'highlight t)
1074 (defcustom gnus-treat-highlight-citation t
1075 "Highlight cited text.
1076 Valid values are nil, t, `head', `last', an integer or a predicate.
1077 See Info node `(gnus)Customizing Articles' for details."
1078 :group 'gnus-article-treat
1079 :link '(custom-manual "(gnus)Customizing Articles")
1080 :type gnus-article-treat-custom)
1081 (put 'gnus-treat-highlight-citation 'highlight t)
1083 (defcustom gnus-treat-date-ut nil
1084 "Display the Date in UT (GMT).
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-local nil
1092 "Display the Date in the local timezone.
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-english nil
1100 "Display the Date in a format that can be read aloud in English.
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-lapsed nil
1108 "Display the Date header in a way that says how much time has elapsed.
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-original nil
1116 "Display the date in the original timezone.
1117 Valid values are nil, t, `head', `last', an integer or a predicate.
1118 See Info node `(gnus)Customizing Articles' for details."
1119 :group 'gnus-article-treat
1120 :link '(custom-manual "(gnus)Customizing Articles")
1121 :type gnus-article-treat-head-custom)
1123 (defcustom gnus-treat-date-iso8601 nil
1124 "Display the date in the ISO8601 format.
1125 Valid values are nil, t, `head', `last', an integer or a predicate.
1126 See Info node `(gnus)Customizing Articles' for details."
1128 :group 'gnus-article-treat
1129 :link '(custom-manual "(gnus)Customizing Articles")
1130 :type gnus-article-treat-head-custom)
1132 (defcustom gnus-treat-date-user-defined nil
1133 "Display the date in a user-defined format.
1134 The format is defined by the `gnus-article-time-format' variable.
1135 Valid values are nil, t, `head', `last', an integer or a predicate.
1136 See Info node `(gnus)Customizing Articles' for details."
1137 :group 'gnus-article-treat
1138 :link '(custom-manual "(gnus)Customizing Articles")
1139 :type gnus-article-treat-head-custom)
1141 (defcustom gnus-treat-strip-headers-in-body t
1142 "Strip the X-No-Archive header line from the beginning of the body.
1143 Valid values are nil, t, `head', `last', an integer or a predicate.
1144 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-trailing-blank-lines nil
1151 "Strip trailing 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-leading-blank-lines nil
1159 "Strip leading 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-strip-multiple-blank-lines nil
1167 "Strip multiple blank 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-unfold-headers 'head
1175 "Unfold folded header lines.
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-headers nil
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-fold-newsgroups 'head
1191 "Fold the Newsgroups and Followup-To headers.
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)
1198 (defcustom gnus-treat-overstrike t
1199 "Treat overstrike highlighting.
1200 Valid values are nil, t, `head', `last', an integer or a predicate.
1201 See Info node `(gnus)Customizing Articles' for details."
1202 :group 'gnus-article-treat
1203 :link '(custom-manual "(gnus)Customizing Articles")
1204 :type gnus-article-treat-custom)
1205 (put 'gnus-treat-overstrike 'highlight t)
1207 (defcustom gnus-treat-ansi-sequences (if (locate-library "ansi-color") t)
1208 "Treat ANSI SGR control sequences.
1209 Valid values are nil, t, `head', `last', an integer or a predicate.
1210 See Info node `(gnus)Customizing Articles' for details."
1211 :group 'gnus-article-treat
1212 :link '(custom-manual "(gnus)Customizing Articles")
1213 :type gnus-article-treat-custom)
1215 (make-obsolete-variable 'gnus-treat-display-xface
1216 'gnus-treat-display-x-face)
1218 (defcustom gnus-treat-display-x-face
1219 (and (not noninteractive)
1220 (or (memq gnus-article-x-face-command
1221 '(x-face-decode-message-header
1222 x-face-mule-gnus-article-display-x-face))
1223 (and (fboundp 'image-type-available-p)
1224 (image-type-available-p 'xbm)
1225 (string-match "^0x" (shell-command-to-string "uncompface"))
1226 (executable-find "icontopbm"))
1227 (and (featurep 'xemacs)
1230 "Display X-Face headers.
1231 Valid values are nil, t, `head', `last', an integer or a predicate.
1232 See Info node `(gnus)Customizing Articles' and Info node
1233 `(gnus)X-Face' for details."
1234 :group 'gnus-article-treat
1236 :link '(custom-manual "(gnus)Customizing Articles")
1237 :link '(custom-manual "(gnus)X-Face")
1238 :type gnus-article-treat-head-custom
1239 :set (lambda (symbol value)
1242 (cond ((or (boundp symbol) (get symbol 'saved-value))
1244 ((boundp 'gnus-treat-display-xface)
1246 ** gnus-treat-display-xface is an obsolete variable;\
1247 use gnus-treat-display-x-face instead")
1248 (default-value 'gnus-treat-display-xface))
1249 ((get 'gnus-treat-display-xface 'saved-value)
1251 ** gnus-treat-display-xface is an obsolete variable;\
1252 use gnus-treat-display-x-face instead")
1253 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1256 (put 'gnus-treat-display-x-face 'highlight t)
1258 (defcustom gnus-article-should-use-smiley-mule
1259 (not (or (featurep 'xemacs)
1260 (gnus-image-type-available-p 'xpm)
1261 (gnus-image-type-available-p 'pbm)))
1262 "Non-nil means use `smiley-mule' to show smileys rather than `smiley'.
1263 `smiley-mule' is boundled in BITMAP-MULE package. You can set it to t
1264 even if your Emacs supports images. It has no effect on XEmacs."
1265 :group 'gnus-article-various
1267 :get (lambda (symbol)
1268 (and (not noninteractive)
1269 (default-value symbol)
1270 (not (featurep 'xemacs))
1271 (module-installed-p 'smiley-mule)
1273 :set (lambda (symbol value)
1274 (set-default symbol (and (not noninteractive)
1276 (not (featurep 'xemacs))
1277 (module-installed-p 'smiley-mule)
1280 (defvar gnus-article-smiley-mule-loaded-p nil
1281 "Internal variable used to say whether `smiley-mule' is loaded (whether
1282 smiley functions are not overridden by `smiley').")
1284 (defcustom gnus-treat-display-face
1285 (and (not noninteractive)
1286 ;; x-face-e21 handles both X-Face and Face headers.
1287 (not (and (eq gnus-article-x-face-command 'x-face-decode-message-header)
1288 (module-installed-p 'x-face-e21)))
1289 (or (and (fboundp 'image-type-available-p)
1290 (image-type-available-p 'png))
1291 (and (featurep 'xemacs)
1294 "Display Face headers.
1295 Valid values are nil, t, `head', `last', an integer or a predicate.
1296 See Info node `(gnus)Customizing Articles' and Info node
1297 `(gnus)X-Face' for details."
1298 :group 'gnus-article-treat
1300 :link '(custom-manual "(gnus)Customizing Articles")
1301 :link '(custom-manual "(gnus)X-Face")
1302 :type gnus-article-treat-head-custom)
1303 (put 'gnus-treat-display-face 'highlight t)
1305 (defcustom gnus-treat-display-smileys
1306 (if (and (not noninteractive)
1307 (or (and (featurep 'xemacs)
1309 (gnus-image-type-available-p 'xpm)
1310 (gnus-image-type-available-p 'pbm)
1311 (and (not (featurep 'xemacs))
1313 (module-installed-p 'smiley-mule))))
1317 Valid values are nil, t, `head', `last', an integer or a predicate.
1318 See Info node `(gnus)Customizing Articles' and Info node
1319 `(gnus)Smileys' for details."
1320 :group 'gnus-article-treat
1322 :link '(custom-manual "(gnus)Customizing Articles")
1323 :link '(custom-manual "(gnus)Smileys")
1324 :type gnus-article-treat-custom)
1325 (put 'gnus-treat-display-smileys 'highlight t)
1327 (defcustom gnus-treat-from-picon
1328 (if (and (gnus-image-type-available-p 'xpm)
1329 (gnus-picons-installed-p))
1331 "Display picons in the From header.
1332 Valid values are nil, t, `head', `last', an integer or a predicate.
1333 See Info node `(gnus)Customizing Articles' and Info node
1334 `(gnus)Picons' for details."
1335 :group 'gnus-article-treat
1337 :link '(custom-manual "(gnus)Customizing Articles")
1338 :link '(custom-manual "(gnus)Picons")
1339 :type gnus-article-treat-head-custom)
1340 (put 'gnus-treat-from-picon 'highlight t)
1342 (defcustom gnus-treat-mail-picon
1343 (if (and (gnus-image-type-available-p 'xpm)
1344 (gnus-picons-installed-p))
1346 "Display picons in To and Cc headers.
1347 Valid values are nil, t, `head', `last', an integer or a predicate.
1348 See Info node `(gnus)Customizing Articles' and Info node
1349 `(gnus)Picons' for details."
1350 :group 'gnus-article-treat
1352 :link '(custom-manual "(gnus)Customizing Articles")
1353 :link '(custom-manual "(gnus)Picons")
1354 :type gnus-article-treat-head-custom)
1355 (put 'gnus-treat-mail-picon 'highlight t)
1357 (defcustom gnus-treat-newsgroups-picon
1358 (if (and (gnus-image-type-available-p 'xpm)
1359 (gnus-picons-installed-p))
1361 "Display picons in the Newsgroups and Followup-To headers.
1362 Valid values are nil, t, `head', `last', an integer or a predicate.
1363 See Info node `(gnus)Customizing Articles' and Info node
1364 `(gnus)Picons' for details."
1365 :group 'gnus-article-treat
1367 :link '(custom-manual "(gnus)Customizing Articles")
1368 :link '(custom-manual "(gnus)Picons")
1369 :type gnus-article-treat-head-custom)
1370 (put 'gnus-treat-newsgroups-picon 'highlight t)
1372 (defcustom gnus-treat-body-boundary
1373 (if (or gnus-treat-newsgroups-picon
1374 gnus-treat-mail-picon
1375 gnus-treat-from-picon)
1377 "Draw a boundary at the end of the headers.
1378 Valid values are nil and `head'.
1379 See Info node `(gnus)Customizing Articles' for details."
1381 :group 'gnus-article-treat
1382 :link '(custom-manual "(gnus)Customizing Articles")
1383 :type gnus-article-treat-head-custom)
1385 (defcustom gnus-treat-capitalize-sentences nil
1386 "Capitalize sentence-starting words.
1387 Valid values are nil, t, `head', `last', an integer or a predicate.
1388 See Info node `(gnus)Customizing Articles' for details."
1390 :group 'gnus-article-treat
1391 :link '(custom-manual "(gnus)Customizing Articles")
1392 :type gnus-article-treat-custom)
1394 (defcustom gnus-treat-wash-html nil
1396 Valid values are nil, t, `head', `last', an integer or a predicate.
1397 See Info node `(gnus)Customizing Articles' for details."
1398 :group 'gnus-article-treat
1399 :link '(custom-manual "(gnus)Customizing Articles")
1400 :type gnus-article-treat-custom)
1402 (defcustom gnus-treat-fill-long-lines nil
1404 Valid values are nil, t, `head', `last', an integer or a predicate.
1405 See Info node `(gnus)Customizing Articles' for details."
1406 :group 'gnus-article-treat
1407 :link '(custom-manual "(gnus)Customizing Articles")
1408 :type gnus-article-treat-custom)
1410 (defcustom gnus-treat-play-sounds nil
1412 Valid values are nil, t, `head', `last', an integer or a predicate.
1413 See Info node `(gnus)Customizing Articles' for details."
1415 :group 'gnus-article-treat
1416 :link '(custom-manual "(gnus)Customizing Articles")
1417 :type gnus-article-treat-custom)
1419 (defcustom gnus-treat-decode-article-as-default-mime-charset nil
1420 "Decode an article as `default-mime-charset'. For instance, if you want to
1421 attempt to decode an article even if the value of `gnus-show-mime' is nil,
1422 you could set this variable to something like: nil for don't decode, t for
1423 decode the body, '(or header t) for the whole article, etc."
1424 :group 'gnus-article-treat
1425 :type '(radio (const :tag "Off" nil)
1426 (const :tag "Decode body" t)
1427 (const :tag "Decode all" (or head t))))
1429 (defcustom gnus-treat-translate nil
1430 "Translate articles from one language to another.
1431 Valid values are nil, t, `head', `last', an integer or a predicate.
1432 See Info node `(gnus)Customizing Articles' for details."
1434 :group 'gnus-article-treat
1435 :link '(custom-manual "(gnus)Customizing Articles")
1436 :type gnus-article-treat-custom)
1438 (defcustom gnus-treat-x-pgp-sig nil
1440 To automatically treat X-PGP-Sig, set it to head.
1441 Valid values are nil, t, `head', `last', an integer or a predicate.
1442 See Info node `(gnus)Customizing Articles' for details."
1443 :group 'gnus-article-treat
1444 :group 'mime-security
1445 :type gnus-article-treat-custom)
1447 (defcustom gnus-treat-monafy nil
1448 "Display body part with mona font.
1449 Valid values are nil, t, `head', `last', an integer or a predicate.
1450 See Info node `(gnus)Customizing Articles' for details."
1451 :group 'gnus-article-treat
1452 :group 'mime-security
1453 :link '(custom-manual "(gnus)Customizing Articles")
1454 :type gnus-article-treat-custom)
1456 (defvar gnus-article-encrypt-protocol-alist
1457 '(("PGP" . mml2015-self-encrypt)))
1459 ;; Set to nil if more than one protocol added to
1460 ;; gnus-article-encrypt-protocol-alist.
1461 (defcustom gnus-article-encrypt-protocol "PGP"
1462 "The protocol used for encrypt articles.
1463 It is a string, such as \"PGP\". If nil, ask user."
1465 :group 'mime-security)
1467 (defvar gnus-article-wash-function nil
1468 "Function used for converting HTML into text.")
1470 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1471 (mm-coding-system-p 'utf-8)
1472 (executable-find idna-program))
1473 "Whether IDNA decoding of headers is used when viewing messages.
1474 This requires GNU Libidn, and by default only enabled if it is found."
1475 :group 'gnus-article-headers
1478 (defcustom gnus-article-over-scroll nil
1479 "If non-nil, allow scrolling the article buffer even when there no more text."
1480 :group 'gnus-article
1483 ;;; Internal variables
1485 (defvar gnus-english-month-names
1486 '("January" "February" "March" "April" "May" "June" "July" "August"
1487 "September" "October" "November" "December"))
1489 (defvar article-goto-body-goes-to-point-min-p nil)
1490 (defvar gnus-article-wash-types nil)
1491 (defvar gnus-article-emphasis-alist nil)
1492 (defvar gnus-article-image-alist nil)
1494 (defvar gnus-article-mime-handle-alist-1 nil)
1495 (defvar gnus-treatment-function-alist
1496 '((gnus-treat-decode-article-as-default-mime-charset
1497 gnus-article-decode-article-as-default-mime-charset)
1498 (gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1499 (gnus-treat-monafy gnus-article-monafy)
1500 (gnus-treat-strip-banner gnus-article-strip-banner)
1501 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1502 (gnus-treat-buttonize gnus-article-add-buttons)
1503 (gnus-treat-fill-article gnus-article-fill-cited-article)
1504 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1505 (gnus-treat-strip-cr gnus-article-remove-cr)
1506 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1507 (gnus-treat-date-ut gnus-article-date-ut)
1508 (gnus-treat-date-local gnus-article-date-local)
1509 (gnus-treat-date-english gnus-article-date-english)
1510 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1511 (gnus-treat-date-original gnus-article-date-original)
1512 (gnus-treat-date-user-defined gnus-article-date-user)
1513 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1514 (gnus-treat-display-face gnus-article-display-face)
1515 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1516 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1517 (gnus-treat-hide-signature gnus-article-hide-signature)
1518 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1519 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1520 (gnus-treat-strip-pem gnus-article-hide-pem)
1521 (gnus-treat-from-picon gnus-treat-from-picon)
1522 (gnus-treat-mail-picon gnus-treat-mail-picon)
1523 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1524 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1525 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1526 (gnus-treat-strip-trailing-blank-lines
1527 gnus-article-remove-trailing-blank-lines)
1528 (gnus-treat-strip-leading-blank-lines
1529 gnus-article-strip-leading-blank-lines)
1530 (gnus-treat-strip-multiple-blank-lines
1531 gnus-article-strip-multiple-blank-lines)
1532 (gnus-treat-overstrike gnus-article-treat-overstrike)
1533 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences)
1534 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1535 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1536 ;; Displaying X-Face should be done after unfolding headers
1537 ;; to protect bitmap lines.
1538 (gnus-treat-display-x-face gnus-article-display-x-face)
1539 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1540 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1541 (gnus-treat-display-smileys gnus-treat-smiley)
1542 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1543 (gnus-treat-wash-html gnus-article-wash-html)
1544 (gnus-treat-emphasize gnus-article-emphasize)
1545 (gnus-treat-hide-citation gnus-article-hide-citation)
1546 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1547 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1548 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1549 (gnus-treat-play-sounds gnus-earcon-display)))
1551 (defvar gnus-article-mime-handle-alist nil)
1552 (defvar article-lapsed-timer nil)
1553 (defvar gnus-article-current-summary nil)
1555 (defvar gnus-article-mode-syntax-table
1556 (let ((table (copy-syntax-table text-mode-syntax-table)))
1557 ;; This causes the citation match run O(2^n).
1558 ;; (modify-syntax-entry ?- "w" table)
1559 (modify-syntax-entry ?> ")<" table)
1560 (modify-syntax-entry ?< "(>" table)
1561 ;; make M-. in article buffers work for `foo' strings
1562 (modify-syntax-entry ?' " " table)
1563 (modify-syntax-entry ?` " " table)
1565 "Syntax table used in article mode buffers.
1566 Initialized from `text-mode-syntax-table.")
1568 (defvar gnus-save-article-buffer nil)
1570 (defvar gnus-article-mode-line-format-alist
1571 (nconc '((?w (gnus-article-wash-status) ?s)
1572 (?m (gnus-article-mime-part-status) ?s))
1573 gnus-summary-mode-line-format-alist))
1575 (defvar gnus-number-of-articles-to-be-saved nil)
1577 (defvar gnus-inhibit-hiding nil)
1579 ;;; Macros for dealing with the article buffer.
1581 (defmacro gnus-with-article-headers (&rest forms)
1583 (set-buffer gnus-article-buffer)
1585 (let ((buffer-read-only nil)
1586 (inhibit-point-motion-hooks t)
1587 (case-fold-search t))
1588 (article-narrow-to-head)
1591 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1592 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1594 (defmacro gnus-with-article-buffer (&rest forms)
1596 (set-buffer gnus-article-buffer)
1597 (let ((buffer-read-only nil))
1600 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1601 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1603 (defun gnus-article-goto-header (header)
1604 "Go to HEADER, which is a regular expression."
1605 (re-search-forward (concat "^\\(" header "\\):") nil t))
1607 (defsubst gnus-article-hide-text (b e props)
1608 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1609 (gnus-add-text-properties-when 'article-type nil b e props)
1610 (when (memq 'intangible props)
1612 (max (1- b) (point-min))
1613 b 'intangible (cddr (memq 'intangible props)))))
1615 (defsubst gnus-article-unhide-text (b e)
1616 "Remove hidden text properties from region between B and E."
1617 (remove-text-properties b e gnus-hidden-properties)
1618 (when (memq 'intangible gnus-hidden-properties)
1619 (put-text-property (max (1- b) (point-min))
1620 b 'intangible nil)))
1622 (defun gnus-article-hide-text-type (b e type)
1623 "Hide text of TYPE between B and E."
1624 (gnus-add-wash-type type)
1625 (gnus-article-hide-text
1626 b e (cons 'article-type (cons type gnus-hidden-properties))))
1628 (defun gnus-article-unhide-text-type (b e type)
1629 "Unhide text of TYPE between B and E."
1630 (gnus-delete-wash-type type)
1631 (remove-text-properties
1632 b e (cons 'article-type (cons type gnus-hidden-properties)))
1633 (when (memq 'intangible gnus-hidden-properties)
1634 (put-text-property (max (1- b) (point-min))
1635 b 'intangible nil)))
1637 (defun gnus-article-hide-text-of-type (type)
1638 "Hide text of TYPE in the current buffer."
1640 (let ((b (point-min))
1642 (while (setq b (text-property-any b e 'article-type type))
1643 (add-text-properties b (incf b) gnus-hidden-properties)))))
1645 (defun gnus-article-delete-text-of-type (type)
1646 "Delete text of TYPE in the current buffer."
1648 (let ((b (point-min)))
1649 (while (setq b (text-property-any b (point-max) 'article-type type))
1651 b (or (text-property-not-all b (point-max) 'article-type type)
1654 (defun gnus-article-delete-invisible-text ()
1655 "Delete all invisible text in the current buffer."
1657 (let ((b (point-min)))
1658 (while (setq b (text-property-any b (point-max) 'invisible t))
1660 b (or (text-property-not-all b (point-max) 'invisible t)
1663 (defun gnus-article-text-type-exists-p (type)
1664 "Say whether any text of type TYPE exists in the buffer."
1665 (text-property-any (point-min) (point-max) 'article-type type))
1667 (defsubst gnus-article-header-rank ()
1668 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1669 (let ((list gnus-sorted-header-list)
1672 (if (looking-at (car list))
1674 (setq list (cdr list))
1678 (defun article-hide-headers (&optional arg delete)
1679 "Hide unwanted headers and possibly sort them as well."
1680 (interactive (gnus-article-hidden-arg))
1681 ;; Lars said that this function might be inhibited.
1682 (if (gnus-article-check-hidden-text 'headers arg)
1684 ;; Show boring headers as well.
1685 (gnus-article-show-hidden-text 'boring-headers)
1686 (when (eq 1 (point-min))
1687 (set-window-start (get-buffer-window (current-buffer)) 1)))
1688 (unless gnus-inhibit-hiding
1691 (let ((inhibit-read-only t)
1692 (case-fold-search t)
1693 (max (1+ (length gnus-sorted-header-list)))
1694 (ignored (when (not gnus-visible-headers)
1695 (cond ((stringp gnus-ignored-headers)
1696 gnus-ignored-headers)
1697 ((listp gnus-ignored-headers)
1698 (mapconcat 'identity gnus-ignored-headers
1701 (cond ((stringp gnus-visible-headers)
1702 gnus-visible-headers)
1703 ((and gnus-visible-headers
1704 (listp gnus-visible-headers))
1705 (mapconcat 'identity gnus-visible-headers "\\|"))))
1706 (inhibit-point-motion-hooks t)
1708 ;; First we narrow to just the headers.
1709 (article-narrow-to-head)
1710 ;; Hide any "From " lines at the beginning of (mail) articles.
1711 (while (looking-at "From ")
1715 (delete-region (point-min) (point))
1716 (gnus-article-hide-text (point-min) (point)
1717 (nconc (list 'article-type 'headers)
1718 gnus-hidden-properties))))
1719 ;; Then treat the rest of the header lines.
1720 ;; Then we use the two regular expressions
1721 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1722 ;; select which header lines is to remain visible in the
1724 (while (re-search-forward "^[^ \t:]*:" nil t)
1726 ;; Mark the rank of the header.
1728 (point) (1+ (point)) 'message-rank
1729 (if (or (and visible (looking-at visible))
1731 (not (looking-at ignored))))
1732 (gnus-article-header-rank)
1735 (message-sort-headers-1)
1736 (when (setq beg (text-property-any
1737 (point-min) (point-max) 'message-rank (+ 2 max)))
1738 ;; We delete or make invisible the unwanted headers.
1739 (gnus-add-wash-type 'headers)
1742 (add-text-properties
1743 (point-min) (+ 5 (point-min))
1744 '(article-type headers dummy-invisible t))
1745 (delete-region beg (point-max)))
1746 (gnus-article-hide-text-type beg (point-max) 'headers)))))))))
1748 (defun article-hide-boring-headers (&optional arg)
1749 "Toggle hiding of headers that aren't very interesting.
1750 If given a negative prefix, always show; if given a positive prefix,
1752 (interactive (gnus-article-hidden-arg))
1753 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1754 (not gnus-show-all-headers))
1757 (let ((buffer-read-only nil)
1758 (list gnus-boring-article-headers)
1759 (inhibit-point-motion-hooks t)
1761 (article-narrow-to-head)
1763 (setq elem (pop list))
1764 (goto-char (point-min))
1766 ;; Hide empty headers.
1768 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1770 (gnus-article-hide-text-type
1774 (if (re-search-forward "^[^ \t]" nil t)
1778 ;; Hide boring Newsgroups header.
1779 ((eq elem 'newsgroups)
1780 (when (gnus-string-equal
1781 (gnus-fetch-field "newsgroups")
1782 (gnus-group-real-name
1783 (if (boundp 'gnus-newsgroup-name)
1786 (gnus-article-hide-header "newsgroups")))
1787 ((eq elem 'to-address)
1788 (let ((to (message-fetch-field "to"))
1790 (gnus-parameter-to-address
1791 (if (boundp 'gnus-newsgroup-name)
1792 gnus-newsgroup-name ""))))
1793 (when (and to to-address
1796 ;; only one address in To
1797 (nth 1 (mail-extract-address-components to))
1799 (gnus-article-hide-header "to"))))
1801 (let ((to (message-fetch-field "to"))
1803 (gnus-parameter-to-list
1804 (if (boundp 'gnus-newsgroup-name)
1805 gnus-newsgroup-name ""))))
1806 (when (and to to-list
1809 ;; only one address in To
1810 (nth 1 (mail-extract-address-components to))
1812 (gnus-article-hide-header "to"))))
1814 (let ((cc (message-fetch-field "cc"))
1816 (gnus-parameter-to-list
1817 (if (boundp 'gnus-newsgroup-name)
1818 gnus-newsgroup-name ""))))
1819 (when (and cc to-list
1822 ;; only one address in CC
1823 (nth 1 (mail-extract-address-components cc))
1825 (gnus-article-hide-header "cc"))))
1826 ((eq elem 'followup-to)
1827 (when (gnus-string-equal
1828 (message-fetch-field "followup-to")
1829 (message-fetch-field "newsgroups"))
1830 (gnus-article-hide-header "followup-to")))
1831 ((eq elem 'reply-to)
1832 (if (gnus-group-find-parameter
1833 gnus-newsgroup-name 'broken-reply-to)
1834 (gnus-article-hide-header "reply-to")
1835 (let ((from (message-fetch-field "from"))
1836 (reply-to (message-fetch-field "reply-to")))
1843 (lambda (x) (downcase (cadr x)))
1844 (mail-extract-address-components from t))
1847 (lambda (x) (downcase (cadr x)))
1848 (mail-extract-address-components reply-to t))
1850 (gnus-article-hide-header "reply-to")))))
1852 (let ((date (message-fetch-field "date")))
1854 (< (days-between (current-time-string) date)
1856 (gnus-article-hide-header "date"))))
1858 (let ((to (message-fetch-field "to"))
1859 (cc (message-fetch-field "cc")))
1860 (when (> (length to) 1024)
1861 (gnus-article-hide-header "to"))
1862 (when (> (length cc) 1024)
1863 (gnus-article-hide-header "cc"))))
1867 (goto-char (point-min))
1868 (while (re-search-forward "^to:" nil t)
1869 (setq to-count (1+ to-count)))
1870 (when (> to-count 1)
1871 (while (> to-count 0)
1872 (goto-char (point-min))
1874 (re-search-forward "^to:" nil nil to-count)
1876 (narrow-to-region (point) (point-max))
1877 (gnus-article-hide-header "to"))
1878 (setq to-count (1- to-count))))
1879 (goto-char (point-min))
1880 (while (re-search-forward "^cc:" nil t)
1881 (setq cc-count (1+ cc-count)))
1882 (when (> cc-count 1)
1883 (while (> cc-count 0)
1884 (goto-char (point-min))
1886 (re-search-forward "^cc:" nil nil cc-count)
1888 (narrow-to-region (point) (point-max))
1889 (gnus-article-hide-header "cc"))
1890 (setq cc-count (1- cc-count)))))))))))))
1892 (defun gnus-article-hide-header (header)
1894 (goto-char (point-min))
1895 (when (re-search-forward (concat "^" header ":") nil t)
1896 (gnus-article-hide-text-type
1900 (if (re-search-forward "^[^ \t]" nil t)
1905 (defvar gnus-article-normalized-header-length 40
1906 "Length of normalized headers.")
1908 (defun article-normalize-headers ()
1909 "Make all header lines 40 characters long."
1911 (let ((buffer-read-only nil)
1915 (article-narrow-to-head)
1918 ((< (setq column (- (point-at-eol) (point)))
1919 gnus-article-normalized-header-length)
1921 (insert (make-string
1922 (- gnus-article-normalized-header-length column)
1924 ((> column gnus-article-normalized-header-length)
1925 (gnus-put-text-property
1927 (forward-char gnus-article-normalized-header-length)
1934 (forward-line 1))))))
1936 (defun article-treat-dumbquotes ()
1937 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
1938 Note that this function guesses whether a character is a sm*rtq**t* or
1939 not, so it should only be used interactively.
1941 Sm*rtq**t*s are M****s***'s unilateral extension to the
1942 iso-8859-1 character map in an attempt to provide more quoting
1943 characters. If you see something like \\222 or \\264 where
1944 you're expecting some kind of apostrophe or quotation mark, then
1947 (article-translate-strings gnus-article-dumbquotes-map))
1949 (defun article-translate-characters (from to)
1950 "Translate all characters in the body of the article according to FROM and TO.
1951 FROM is a string of characters to translate from; to is a string of
1952 characters to translate to."
1954 (when (article-goto-body)
1955 (let ((buffer-read-only nil)
1956 (x (make-string 225 ?x))
1958 (while (< (incf i) (length x))
1961 (while (< i (length from))
1962 (aset x (aref from i) (aref to i))
1964 (translate-region (point) (point-max) x)))))
1966 (defun article-translate-strings (map)
1967 "Translate all string in the body of the article according to MAP.
1968 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1970 (when (article-goto-body)
1971 (let ((buffer-read-only nil)
1973 (while (setq elem (pop map))
1975 (while (search-forward (car elem) nil t)
1976 (replace-match (cadr elem)))))))))
1978 (defun article-treat-overstrike ()
1979 "Translate overstrikes into bold text."
1982 (when (article-goto-body)
1983 (let ((buffer-read-only nil))
1984 (while (search-forward "\b" nil t)
1985 (let ((next (char-after))
1989 previous (char-after))
1993 ;; We do the boldification/underlining by hiding the
1994 ;; overstrikes and putting the proper text property
1998 (gnus-article-hide-text-type start (point) 'overstrike)
1999 (put-text-property (point) end 'face 'bold))
2001 (gnus-article-hide-text-type
2002 (1- (point)) (1+ (point)) 'overstrike)
2004 start (1- (point)) 'face 'underline))
2006 (gnus-article-hide-text-type start (point) 'overstrike)
2008 (point) end 'face 'underline)))))))))
2010 (defun article-treat-ansi-sequences ()
2011 "Translate ANSI SGR control sequences into overlays or extents."
2014 (when (article-goto-body)
2015 (let ((buffer-read-only nil))
2016 (ansi-color-apply-on-region (point) (point-max))))))
2018 (defun gnus-article-treat-unfold-headers ()
2019 "Unfold folded message headers.
2020 Only the headers that fit into the current window width will be
2023 (gnus-with-article-headers
2027 (mail-header-narrow-to-field)
2028 (let ((header (buffer-string)))
2031 (goto-char (point-min))
2032 (while (re-search-forward "\n[\t ]" nil t)
2033 (replace-match " " t t)))
2034 (setq length (- (point-max) (point-min) 1)))
2035 (when (< length (window-width))
2036 (while (re-search-forward "\n[\t ]" nil t)
2037 (replace-match " " t t)))
2038 (goto-char (point-max)))))))
2040 (defun gnus-article-treat-fold-headers ()
2041 "Fold message headers."
2043 (gnus-with-article-headers
2046 (mail-header-narrow-to-field)
2047 (mail-header-fold-field)
2048 (goto-char (point-max))))))
2050 (defun gnus-treat-smiley ()
2051 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2053 (unless (featurep 'xemacs)
2054 (when (and (not gnus-article-should-use-smiley-mule)
2055 gnus-article-smiley-mule-loaded-p)
2056 (load "smiley" nil t)
2057 (setq gnus-article-smiley-mule-loaded-p nil))
2058 (when (and gnus-article-should-use-smiley-mule
2059 (not gnus-article-smiley-mule-loaded-p))
2060 (load "smiley-mule" nil t)
2061 (setq gnus-article-smiley-mule-loaded-p t)))
2062 (gnus-with-article-buffer
2063 (if (memq 'smiley gnus-article-wash-types)
2064 (gnus-delete-images 'smiley)
2066 (let ((images (smiley-region (point) (point-max))))
2068 (gnus-add-wash-type 'smiley)
2069 (dolist (image images)
2070 (gnus-add-image 'smiley image)))))))
2072 (defun gnus-article-remove-images ()
2073 "Remove all images from the article buffer."
2075 (gnus-with-article-buffer
2076 (dolist (elem gnus-article-image-alist)
2077 (gnus-delete-images (car elem)))))
2079 (defun gnus-article-treat-fold-newsgroups ()
2080 "Unfold folded message headers.
2081 Only the headers that fit into the current window width will be
2084 (gnus-with-article-headers
2085 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2087 (mail-header-narrow-to-field)
2088 (while (re-search-forward ", *" nil t)
2089 (replace-match ", " t t))
2090 (mail-header-fold-field)
2091 (goto-char (point-max))))))
2093 (defun gnus-article-treat-body-boundary ()
2094 "Place a boundary line at the end of the headers."
2096 (when (and gnus-body-boundary-delimiter
2097 (> (length gnus-body-boundary-delimiter) 0))
2098 (gnus-with-article-headers
2099 (goto-char (point-max))
2100 (let ((start (point)))
2101 (insert "X-Boundary: ")
2102 (gnus-add-text-properties start (point) '(invisible t intangible t))
2104 (while (>= (1- (window-width)) (length str))
2105 (setq str (concat str gnus-body-boundary-delimiter)))
2106 (substring str 0 (1- (window-width))))
2108 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2110 (defun article-fill-long-lines ()
2111 "Fill lines that are wider than the window width."
2114 (let ((buffer-read-only nil)
2115 (width (window-width (get-buffer-window (current-buffer)))))
2118 (let ((adaptive-fill-mode nil)) ;Why? -sm
2121 (when (>= (current-column) (min fill-column width))
2122 (narrow-to-region (min (1+ (point)) (point-max))
2124 (let ((goback (point-marker)))
2125 (fill-paragraph nil)
2126 (goto-char (marker-position goback)))
2128 (forward-line 1)))))))
2130 (defun article-capitalize-sentences ()
2131 "Capitalize the first word in each sentence."
2134 (let ((buffer-read-only nil)
2135 (paragraph-start "^[\n\^L]"))
2139 (forward-sentence)))))
2141 (defun article-remove-cr ()
2142 "Remove trailing CRs and then translate remaining CRs into LFs."
2145 (let ((buffer-read-only nil))
2146 (goto-char (point-min))
2147 (while (re-search-forward "\r+$" nil t)
2148 (replace-match "" t t))
2149 (goto-char (point-min))
2150 (while (search-forward "\r" nil t)
2151 (replace-match "\n" t t)))))
2153 (defun article-remove-trailing-blank-lines ()
2154 "Remove all trailing blank lines from the article."
2157 (let ((buffer-read-only nil))
2158 (goto-char (point-max))
2162 (while (and (not (bobp))
2163 (looking-at "^[ \t]*$")
2164 (not (gnus-annotation-in-region-p
2165 (point) (point-at-eol))))
2170 (defun article-display-face ()
2171 "Display any Face headers in the header."
2173 (let ((wash-face-p buffer-read-only))
2174 (gnus-with-article-headers
2175 ;; When displaying parts, this function can be called several times on
2176 ;; the same article, without any intended toggle semantic (as typing `W
2177 ;; D d' would have). So face deletion must occur only when we come from
2178 ;; an interactive command, that is when the *Article* buffer is
2180 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2181 (gnus-delete-images 'face)
2184 (when (and wash-face-p
2186 (goto-char (point-min))
2187 (not (re-search-forward "^Face:[\t ]*" nil t)))
2188 (gnus-buffer-live-p gnus-original-article-buffer))
2189 (set-buffer gnus-original-article-buffer))
2191 (mail-narrow-to-head)
2192 (while (gnus-article-goto-header "Face")
2193 (push (mail-header-field-value) faces))))
2194 (while (setq face (pop faces))
2195 (let ((png (gnus-convert-face-to-png face))
2198 (setq image (gnus-create-image png 'png t))
2199 (gnus-article-goto-header "from")
2201 (insert "From: [no `from' set]\n")
2203 (gnus-add-wash-type 'face)
2204 (gnus-add-image 'face image)
2205 (gnus-put-image image nil 'face))))))
2208 (defun article-display-x-face (&optional force)
2209 "Look for an X-Face header and display it if present."
2210 (interactive (list 'force))
2211 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2212 (gnus-with-article-headers
2213 ;; Delete the old process, if any.
2214 (when (process-status "article-x-face")
2215 (delete-process "article-x-face"))
2216 ;; See the comment in `article-display-face'.
2217 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2218 ;; We have already displayed X-Faces, so we remove them
2220 (gnus-delete-images 'xface)
2222 (let (x-faces from face)
2224 (when (and wash-face-p
2226 (goto-char (point-min))
2227 (not (re-search-forward
2228 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2229 (gnus-buffer-live-p gnus-original-article-buffer))
2230 ;; If type `W f', use gnus-original-article-buffer,
2231 ;; otherwise use the current buffer because displaying
2232 ;; RFC822 parts calls this function too.
2233 (set-buffer gnus-original-article-buffer))
2235 (mail-narrow-to-head)
2236 (while (gnus-article-goto-header "X-Face")
2237 (push (mail-header-field-value) x-faces))
2238 (setq from (message-fetch-field "from"))))
2239 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2240 ;; single external face.
2241 (when (stringp gnus-article-x-face-command)
2242 (setq x-faces (list (car x-faces))))
2243 (while (and (setq face (pop x-faces))
2244 gnus-article-x-face-command
2246 ;; Check whether this face is censored.
2247 (not gnus-article-x-face-too-ugly)
2248 (and gnus-article-x-face-too-ugly from
2249 (not (string-match gnus-article-x-face-too-ugly
2251 ;; We display the face.
2252 (cond ((stringp gnus-article-x-face-command)
2253 ;; The command is a string, so we interpret the command
2254 ;; as a, well, command, and fork it off.
2255 (let ((process-connection-type nil))
2256 (process-kill-without-query
2258 "article-x-face" nil shell-file-name
2259 shell-command-switch gnus-article-x-face-command))
2262 (process-send-region "article-x-face"
2263 (point-min) (point-max)))
2264 (process-send-eof "article-x-face")))
2265 ((functionp gnus-article-x-face-command)
2266 ;; The command is a lisp function, so we call it.
2267 (funcall gnus-article-x-face-command face))
2269 (error "%s is not a function"
2270 gnus-article-x-face-command)))))))))
2272 (defun article-decode-mime-words ()
2273 "Decode all MIME-encoded words in the article."
2275 (gnus-with-article-buffer
2276 (let ((inhibit-point-motion-hooks t)
2277 (mail-parse-charset gnus-newsgroup-charset)
2278 (mail-parse-ignored-charsets
2279 (with-current-buffer gnus-summary-buffer
2280 gnus-newsgroup-ignored-charsets)))
2281 (mail-decode-encoded-word-region (point-min) (point-max)))))
2283 (defun article-decode-charset (&optional prompt)
2284 "Decode charset-encoded text in the article.
2285 If PROMPT (the prefix), prompt for a coding system to use."
2287 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2289 (mail-parse-charset gnus-newsgroup-charset)
2290 (mail-parse-ignored-charsets
2291 (save-excursion (condition-case nil
2292 (set-buffer gnus-summary-buffer)
2294 gnus-newsgroup-ignored-charsets))
2295 ct cte ctl charset format)
2298 (article-narrow-to-head)
2299 (setq ct (message-fetch-field "Content-Type" t)
2300 cte (message-fetch-field "Content-Transfer-Encoding" t)
2301 ctl (and ct (ignore-errors
2302 (mail-header-parse-content-type ct)))
2305 (mm-read-coding-system "Charset to decode: "))
2307 (mail-content-type-get ctl 'charset)))
2308 format (and ctl (mail-content-type-get ctl 'format)))
2310 (setq cte (mail-header-strip cte)))
2311 (if (and ctl (not (string-match "/" (car ctl))))
2313 (goto-char (point-max)))
2316 (narrow-to-region (point) (point-max))
2317 (when (and (eq mail-parse-charset 'gnus-decoded)
2318 (eq (mm-body-7-or-8) '8bit))
2319 ;; The text code could have been decoded.
2320 (setq charset mail-parse-charset))
2321 (when (and (or (not ctl)
2322 (equal (car ctl) "text/plain"))
2323 (not format)) ;; article with format will decode later.
2325 charset (and cte (intern (downcase
2326 (gnus-strip-whitespace cte))))
2329 (defun article-decode-encoded-words ()
2330 "Remove encoded-word encoding from headers."
2331 (let (buffer-read-only)
2332 (let ((charset (save-excursion
2333 (set-buffer gnus-summary-buffer)
2334 default-mime-charset)))
2335 (mime-decode-header-in-buffer charset))))
2337 (defun article-decode-group-name ()
2338 "Decode group names in `Newsgroups:'."
2339 (let ((inhibit-point-motion-hooks t)
2341 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2342 (when (and (or gnus-group-name-charset-method-alist
2343 gnus-group-name-charset-group-alist)
2344 (gnus-buffer-live-p gnus-original-article-buffer))
2346 (article-narrow-to-head)
2347 (with-current-buffer gnus-original-article-buffer
2348 (goto-char (point-min)))
2349 (while (re-search-forward
2350 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2351 (replace-match (save-match-data
2352 (gnus-decode-newsgroups
2353 ;; XXX how to use data in article buffer?
2354 (with-current-buffer gnus-original-article-buffer
2356 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2359 gnus-newsgroup-name method))
2361 (goto-char (point-min))
2362 (with-current-buffer gnus-original-article-buffer
2363 (goto-char (point-min)))
2364 (while (re-search-forward
2365 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2366 (replace-match (save-match-data
2367 (gnus-decode-newsgroups
2368 ;; XXX how to use data in article buffer?
2369 (with-current-buffer gnus-original-article-buffer
2371 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2374 gnus-newsgroup-name method))
2377 (autoload 'idna-to-unicode "idna")
2379 (defun article-decode-idna-rhs ()
2380 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2383 (let ((inhibit-point-motion-hooks t)
2385 (article-narrow-to-head)
2386 (goto-char (point-min))
2387 (while (re-search-forward "\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2389 (when (save-match-data
2390 (and (setq ace (match-string 1))
2392 (and (re-search-backward "^[^ \t]" nil t)
2393 (looking-at "From\\|To\\|Cc")))
2394 (save-excursion (backward-char)
2395 (message-idna-inside-rhs-p))
2396 (setq unicode (idna-to-unicode ace))))
2397 (unless (string= ace unicode)
2398 (replace-match unicode nil nil nil 1)))))))))
2400 (defun article-de-quoted-unreadable (&optional force read-charset)
2401 "Translate a quoted-printable-encoded article.
2402 If FORCE, decode the article whether it is marked as quoted-printable
2404 If READ-CHARSET, ask for a coding system."
2405 (interactive (list 'force current-prefix-arg))
2407 (let ((buffer-read-only nil) type charset)
2408 (if (gnus-buffer-live-p gnus-original-article-buffer)
2409 (with-current-buffer gnus-original-article-buffer
2411 (gnus-fetch-field "content-transfer-encoding"))
2412 (let* ((ct (gnus-fetch-field "content-type"))
2415 (mail-header-parse-content-type ct)))))
2416 (setq charset (and ctl
2417 (mail-content-type-get ctl 'charset)))
2418 (if (stringp charset)
2419 (setq charset (intern (downcase charset)))))))
2421 (setq charset (mm-read-coding-system "Charset: " charset)))
2423 (setq charset gnus-newsgroup-charset))
2425 (and type (let ((case-fold-search t))
2426 (string-match "quoted-printable" type))))
2428 (quoted-printable-decode-region
2429 (point) (point-max) (mm-charset-to-coding-system charset))))))
2431 (defun article-de-base64-unreadable (&optional force read-charset)
2432 "Translate a base64 article.
2433 If FORCE, decode the article whether it is marked as base64 not.
2434 If READ-CHARSET, ask for a coding system."
2435 (interactive (list 'force current-prefix-arg))
2437 (let ((buffer-read-only nil) type charset)
2438 (if (gnus-buffer-live-p gnus-original-article-buffer)
2439 (with-current-buffer gnus-original-article-buffer
2441 (gnus-fetch-field "content-transfer-encoding"))
2442 (let* ((ct (gnus-fetch-field "content-type"))
2445 (mail-header-parse-content-type ct)))))
2446 (setq charset (and ctl
2447 (mail-content-type-get ctl 'charset)))
2448 (if (stringp charset)
2449 (setq charset (intern (downcase charset)))))))
2451 (setq charset (mm-read-coding-system "Charset: " charset)))
2453 (setq charset gnus-newsgroup-charset))
2455 (and type (let ((case-fold-search t))
2456 (string-match "base64" type))))
2459 (narrow-to-region (point) (point-max))
2460 (base64-decode-region (point-min) (point-max))
2461 (mm-decode-coding-region
2462 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2467 (defun article-decode-HZ ()
2468 "Translate a HZ-encoded article."
2472 (let ((buffer-read-only nil))
2473 (rfc1843-decode-region (point-min) (point-max)))))
2475 (defun article-unsplit-urls ()
2476 "Remove the newlines that some other mailers insert into URLs."
2479 (let ((buffer-read-only nil))
2480 (goto-char (point-min))
2481 (while (re-search-forward
2482 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2483 (replace-match "\\1\\3" t)))
2484 (when (interactive-p)
2485 (gnus-treat-article nil))))
2488 (defun article-wash-html (&optional read-charset)
2489 "Format an HTML article.
2490 If READ-CHARSET, ask for a coding system."
2493 (let ((buffer-read-only nil)
2495 (when (gnus-buffer-live-p gnus-original-article-buffer)
2496 (with-current-buffer gnus-original-article-buffer
2497 (let* ((ct (gnus-fetch-field "content-type"))
2500 (mail-header-parse-content-type ct)))))
2501 (setq charset (and ctl
2502 (mail-content-type-get ctl 'charset)))
2503 (when (stringp charset)
2504 (setq charset (intern (downcase charset)))))))
2506 (setq charset (mm-read-coding-system "Charset: " charset)))
2508 (setq charset gnus-newsgroup-charset))
2510 (save-window-excursion
2512 (narrow-to-region (point) (point-max))
2513 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2514 (entry (assq func mm-text-html-washer-alist)))
2516 (setq func (cdr entry)))
2521 (apply (car func) (cdr func))))))))))
2523 (defun gnus-article-wash-html-with-w3 ()
2524 "Wash the current buffer with w3."
2526 (let ((w3-strict-width (window-width))
2527 (url-standalone-mode t)
2528 (url-gateway-unplugged t)
2529 (w3-honor-stylesheets nil))
2531 (w3-region (point-min) (point-max))
2534 (defun gnus-article-wash-html-with-w3m ()
2535 "Wash the current buffer with emacs-w3m."
2538 (narrow-to-region (point) (point-max))
2539 (let ((w3m-safe-url-regexp (if mm-inline-text-html-with-images
2542 w3m-force-redisplay)
2543 (w3m-region (point-min) (point-max)))
2544 (when (and mm-inline-text-html-with-w3m-keymap
2545 (boundp 'w3m-minor-mode-map)
2547 (add-text-properties
2548 (point-min) (point-max)
2549 (list 'keymap w3m-minor-mode-map
2550 ;; Put the mark meaning this part was rendered by emacs-w3m.
2551 'mm-inline-text-html-with-w3m t)))))
2553 (defun article-hide-list-identifiers ()
2554 "Remove list identifies from the Subject header.
2555 The `gnus-list-identifiers' variable specifies what to do."
2557 (let ((inhibit-point-motion-hooks t)
2558 (regexp (if (consp gnus-list-identifiers)
2559 (mapconcat 'identity gnus-list-identifiers " *\\|")
2560 gnus-list-identifiers))
2565 (article-narrow-to-head)
2566 (goto-char (point-min))
2567 (while (re-search-forward
2568 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2570 (delete-region (match-beginning 2) (match-end 0))
2571 (beginning-of-line))
2572 (when (re-search-forward
2573 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2574 (delete-region (match-beginning 1) (match-end 1))))))))
2576 (defun article-hide-pem (&optional arg)
2577 "Toggle hiding of any PEM headers and signatures in the current article.
2578 If given a negative prefix, always show; if given a positive prefix,
2580 (interactive (gnus-article-hidden-arg))
2581 (unless (gnus-article-check-hidden-text 'pem arg)
2583 (let (buffer-read-only end)
2584 (goto-char (point-min))
2585 ;; Hide the horrendously ugly "header".
2586 (when (and (search-forward
2587 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2589 (setq end (1+ (match-beginning 0))))
2590 (gnus-add-wash-type 'pem)
2591 (gnus-article-hide-text-type
2593 (if (search-forward "\n\n" nil t)
2597 ;; Hide the trailer as well
2598 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2600 (gnus-article-hide-text-type
2601 (match-beginning 0) (match-end 0) 'pem)))))))
2603 (defun article-strip-banner ()
2604 "Strip the banners specified by the `banner' group parameter and by
2605 `gnus-article-address-banner-alist'."
2609 (let ((inhibit-point-motion-hooks t))
2610 (when (gnus-parameter-banner gnus-newsgroup-name)
2611 (article-really-strip-banner
2612 (gnus-parameter-banner gnus-newsgroup-name)))
2613 (when gnus-article-address-banner-alist
2614 (article-really-strip-banner
2615 (let ((from (save-restriction
2617 (article-narrow-to-head)
2618 (mail-fetch-field "from"))))
2621 (caar (mail-header-parse-addresses from))))
2623 (dolist (pair gnus-article-address-banner-alist)
2624 (when (string-match (car pair) from)
2625 (throw 'found (cdr pair)))))))))))))
2627 (defun article-really-strip-banner (banner)
2628 "Strip the banner specified by the argument."
2631 (let ((inhibit-point-motion-hooks t)
2632 (gnus-signature-limit nil)
2636 ((eq banner 'signature)
2637 (when (gnus-article-narrow-to-signature)
2640 (delete-region (point) (point-max))))
2642 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2643 (while (re-search-forward banner nil t)
2644 (delete-region (match-beginning 0) (match-end 0)))))
2646 (while (re-search-forward banner nil t)
2647 (delete-region (match-beginning 0) (match-end 0)))))))))
2649 (defun article-babel ()
2650 "Translate article using an online translation service."
2653 (gnus-with-article-buffer
2654 (when (article-goto-body)
2655 (let* ((start (point))
2657 (orig (buffer-substring start end))
2658 (trans (babel-as-string orig)))
2660 (narrow-to-region start end)
2661 (delete-region start end)
2664 (defun article-hide-signature (&optional arg)
2665 "Hide the signature in the current article.
2666 If given a negative prefix, always show; if given a positive prefix,
2668 (interactive (gnus-article-hidden-arg))
2674 (article-goto-body))
2675 (goto-char (point-min)))
2676 (unless (gnus-article-check-hidden-text 'signature arg)
2677 (let ((buffer-read-only nil)
2679 (while (setq button (text-property-any button (point-max)
2681 'gnus-signature-toggle))
2682 (setq button (text-property-not-all button (point-max)
2684 'gnus-signature-toggle))
2685 (when (and button (not (eobp)))
2686 (gnus-article-hide-text-type
2688 (next-single-property-change (1+ button) 'mime-view-entity
2691 (gnus-set-mode-line 'article))
2693 (defun article-strip-headers-in-body ()
2694 "Strip offensive headers from bodies."
2698 (let ((case-fold-search t))
2699 (when (looking-at "x-no-archive:")
2700 (gnus-delete-line)))))
2702 (defun article-strip-leading-blank-lines ()
2703 "Remove all blank lines from the beginning of the article."
2706 (let ((inhibit-point-motion-hooks t)
2708 (when (article-goto-body)
2709 (while (and (not (eobp))
2710 (looking-at "[ \t]*$"))
2711 (gnus-delete-line))))))
2713 (defun article-narrow-to-head ()
2714 "Narrow the buffer to the head of the message.
2715 Point is left at the beginning of the narrowed-to region."
2717 (goto-char (point-min))
2718 (if (search-forward "\n\n" nil 1)
2721 (goto-char (point-min)))
2723 (defun article-goto-body ()
2724 "Place point at the start of the body."
2725 (goto-char (point-min))
2727 ;; This variable is only bound when dealing with separate
2729 (article-goto-body-goes-to-point-min-p
2731 ((search-forward "\n\n" nil t)
2734 (goto-char (point-max))
2737 (defun article-strip-multiple-blank-lines ()
2738 "Replace consecutive blank lines with one empty line."
2741 (let ((inhibit-point-motion-hooks t)
2743 ;; First make all blank lines empty.
2745 (while (re-search-forward "^[ \t]+$" nil t)
2746 (unless (gnus-annotation-in-region-p
2747 (match-beginning 0) (match-end 0))
2748 (replace-match "" nil t)))
2749 ;; Then replace multiple empty lines with a single empty line.
2751 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2752 (unless (gnus-annotation-in-region-p
2753 (match-beginning 0) (match-end 0))
2754 (delete-region (match-beginning 1) (match-end 1)))))))
2756 (defun article-strip-leading-space ()
2757 "Remove all white space from the beginning of the lines in the article."
2760 (let ((inhibit-point-motion-hooks t)
2763 (while (re-search-forward "^[ \t]+" nil t)
2764 (replace-match "" t t)))))
2766 (defun article-strip-trailing-space ()
2767 "Remove all white space from the end of the lines in the article."
2770 (let ((inhibit-point-motion-hooks t)
2773 (while (re-search-forward "[ \t]+$" nil t)
2774 (replace-match "" t t)))))
2776 (defun article-strip-blank-lines ()
2777 "Strip leading, trailing and multiple blank lines."
2779 (article-strip-leading-blank-lines)
2780 (article-remove-trailing-blank-lines)
2781 (article-strip-multiple-blank-lines))
2783 (defun article-strip-all-blank-lines ()
2784 "Strip all blank lines."
2787 (let ((inhibit-point-motion-hooks t)
2790 (while (re-search-forward "^[ \t]*\n" nil t)
2791 (replace-match "" t t)))))
2793 (defun gnus-article-narrow-to-signature ()
2794 "Narrow to the signature; return t if a signature is found, else nil."
2795 (let ((inhibit-point-motion-hooks t))
2796 (when (gnus-article-search-signature)
2798 ;; Check whether we have some limits to what we consider
2799 ;; to be a signature.
2800 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2801 (list gnus-signature-limit)))
2803 (while (setq limit (pop limits))
2804 (if (or (and (integerp limit)
2805 (< (- (point-max) (point)) limit))
2807 (< (count-lines (point) (point-max)) limit))
2808 (and (functionp limit)
2810 (and (stringp limit)
2811 (not (re-search-forward limit nil t))))
2812 () ; This limit did not succeed.
2816 (narrow-to-region (point) (point-max))
2819 (defun gnus-article-search-signature ()
2820 "Search the current buffer for the signature separator.
2821 Put point at the beginning of the signature separator."
2822 (let ((cur (point)))
2823 (goto-char (point-max))
2824 (if (if (stringp gnus-signature-separator)
2825 (re-search-backward gnus-signature-separator nil t)
2826 (let ((seps gnus-signature-separator))
2828 (not (re-search-backward (car seps) nil t)))
2835 (defun gnus-article-hidden-arg ()
2836 "Return the current prefix arg as a number, or 0 if no prefix."
2837 (list (if current-prefix-arg
2838 (prefix-numeric-value current-prefix-arg)
2841 (defun gnus-article-check-hidden-text (type arg)
2842 "Return nil if hiding is necessary.
2843 Arg can be nil or a number. nil and positive means hide, negative
2844 means show, 0 means toggle."
2847 (let ((hide (gnus-article-hidden-text-p type)))
2853 (gnus-article-show-hidden-text type)
2856 (if (eq hide 'hidden)
2858 (gnus-article-show-hidden-text type)
2862 (defun gnus-article-hidden-text-p (type)
2863 "Say whether the current buffer contains hidden text of type TYPE."
2864 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2866 (not (get-text-property pos 'invisible))
2867 (not (get-text-property pos 'dummy-invisible)))
2869 (text-property-any (1+ pos) (point-max) 'article-type type)))
2874 (defun gnus-article-show-hidden-text (type &optional dummy)
2875 "Show all hidden text of type TYPE.
2876 Originally it is hide instead of DUMMY."
2877 (let ((buffer-read-only nil)
2878 (inhibit-point-motion-hooks t))
2879 (gnus-remove-text-properties-when
2881 (point-min) (point-max)
2882 (cons 'article-type (cons type
2883 gnus-hidden-properties)))
2884 (gnus-delete-wash-type type)))
2886 (defconst article-time-units
2887 `((year . ,(* 365.25 24 60 60))
2888 (week . ,(* 7 24 60 60))
2889 (day . ,(* 24 60 60))
2893 "Mapping from time units to seconds.")
2895 (defun gnus-article-forward-header ()
2896 "Move point to the start of the next header.
2897 If the current header is a continuation header, this can be several
2902 (if (looking-at "[ \t]+[^ \t]")
2906 (defun article-date-ut (&optional type highlight header)
2907 "Convert DATE date to universal time in the current article.
2908 If TYPE is `local', convert to local time; if it is `lapsed', output
2909 how much time has lapsed since DATE. For `lapsed', the value of
2910 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2911 should replace the \"Date:\" one, or should be added below it."
2912 (interactive (list 'ut t))
2913 (let* ((header (or header
2914 (and (eq 1 (point-min))
2915 (mail-header-date (save-excursion
2916 (set-buffer gnus-summary-buffer)
2917 gnus-current-headers)))
2918 (message-fetch-field "date")
2920 (date (if (vectorp header) (mail-header-date header)
2922 (inhibit-point-motion-hooks t)
2923 bface eface date-pos)
2924 (when (and date (not (string= date "")))
2927 (article-narrow-to-head)
2928 (when (or (and (eq type 'lapsed)
2929 gnus-article-date-lapsed-new-header
2930 ;; Attempt to get the face of X-Sent first.
2931 (re-search-forward "^X-Sent:[ \t]" nil t))
2932 (re-search-forward "^Date:[ \t]" nil t)
2933 ;; If Date is missing, try again for X-Sent.
2934 (re-search-forward "^X-Sent:[ \t]" nil t))
2935 (setq bface (get-text-property (point-at-bol) 'face)
2936 date (or (get-text-property (point-at-bol)
2939 eface (get-text-property (1- (point-at-eol))
2941 (let ((buffer-read-only nil))
2942 ;; Delete any old X-Sent headers.
2943 (when (setq date-pos
2944 (text-property-any (point-min) (point-max)
2945 'article-date-lapsed t))
2946 (goto-char (setq date-pos (set-marker (make-marker) date-pos)))
2947 (delete-region (match-beginning 0)
2948 (progn (forward-line 1) (point))))
2949 (goto-char (point-min))
2950 ;; Delete any old Date headers.
2951 (while (re-search-forward "^Date:[ \t]" nil t)
2953 (setq date-pos (match-beginning 0)))
2954 (unless (and (eq type 'lapsed)
2955 gnus-article-date-lapsed-new-header)
2956 (delete-region (match-beginning 0)
2957 (progn (message-next-header) (point)))))
2960 (goto-char date-pos)
2962 ;; Possibly, Date has been deleted.
2964 (when (and (eq type 'lapsed)
2965 gnus-article-date-lapsed-new-header
2966 (looking-at "Date:"))
2968 (goto-char (point-min)))
2969 (insert (article-make-date-line date type))
2970 (when (eq type 'lapsed)
2971 (put-text-property (point-at-bol) (point)
2972 'article-date-lapsed t))
2976 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2977 (put-text-property (match-beginning 1) (1+ (match-end 1))
2978 'original-date date)
2979 (put-text-property (match-beginning 1) (1+ (match-end 1))
2981 (put-text-property (match-beginning 2) (match-end 2)
2984 (defun article-make-date-line (date type)
2985 "Return a DATE line of TYPE."
2986 (unless (memq type '(local ut original user iso8601 lapsed english))
2987 (error "Unknown conversion type: %s" type))
2989 (let ((time (date-to-time date)))
2991 ;; Convert to the local timezone.
2993 (let ((tz (car (current-time-zone time))))
2994 (format "Date: %s %s%02d%02d" (current-time-string time)
2995 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2996 (/ (% (abs tz) 3600) 60))))
2997 ;; Convert to Universal Time.
3000 (current-time-string
3001 (let* ((e (parse-time-string date))
3002 (tm (apply 'encode-time e))
3004 (ls (- (cadr tm) (car (current-time-zone time)))))
3005 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
3006 ((> ls 65535) (list (1+ ms) (- ls 65536)))
3009 ;; Get the original date from the article.
3010 ((eq type 'original)
3011 (concat "Date: " (if (string-match "\n+$" date)
3012 (substring date 0 (match-beginning 0))
3014 ;; Let the user define the format.
3016 (let ((format (or (condition-case nil
3017 (with-current-buffer gnus-summary-buffer
3018 gnus-article-time-format)
3020 gnus-article-time-format)))
3021 (if (functionp format)
3022 (funcall format time)
3023 (concat "Date: " (format-time-string format time)))))
3026 (let ((tz (car (current-time-zone time))))
3029 (format-time-string "%Y%m%dT%H%M%S" time)
3030 (format "%s%02d%02d"
3031 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
3032 (/ (% (abs tz) 3600) 60)))))
3033 ;; Do an X-Sent lapsed format.
3035 ;; If the date is seriously mangled, the timezone functions are
3036 ;; liable to bug out, so we ignore all errors.
3037 (let* ((now (current-time))
3038 (real-time (subtract-time now time))
3039 (real-sec (and real-time
3040 (+ (* (float (car real-time)) 65536)
3042 (sec (and real-time (abs real-sec)))
3052 ;; This is a bit convoluted, but basically we go
3053 ;; through the time units for years, weeks, etc,
3054 ;; and divide things to see whether that results
3055 ;; in positive answers.
3058 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
3059 ;; The (remaining) seconds are too few to
3060 ;; be divided into this time unit.
3062 ;; It's big enough, so we output it.
3063 (setq sec (- sec (* num (cdr unit))))
3065 (concat (if prev ", " "") (int-to-string
3067 " " (symbol-name (car unit))
3068 (if (> num 1) "s" ""))
3070 article-time-units "")
3071 ;; If dates are odd, then it might appear like the
3072 ;; article was sent in the future.
3075 " in the future"))))))
3076 ;; Display the date in proper English
3078 (let ((dtime (decode-time time)))
3081 (number-to-string (nth 3 dtime))
3082 (let ((digit (% (nth 3 dtime) 10)))
3084 ((memq (nth 3 dtime) '(11 12 13)) "th")
3090 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3092 (number-to-string (nth 5 dtime))
3094 (format "%02d" (nth 2 dtime))
3096 (format "%02d" (nth 1 dtime)))))))
3098 (format "Date: %s (from T-gnus)" date))))
3100 (defun article-date-local (&optional highlight)
3101 "Convert the current article date to the local timezone."
3102 (interactive (list t))
3103 (article-date-ut 'local highlight))
3105 (defun article-date-english (&optional highlight)
3106 "Convert the current article date to something that is proper English."
3107 (interactive (list t))
3108 (article-date-ut 'english highlight))
3110 (defun article-date-original (&optional highlight)
3111 "Convert the current article date to what it was originally.
3112 This is only useful if you have used some other date conversion
3113 function and want to see what the date was before converting."
3114 (interactive (list t))
3115 (article-date-ut 'original highlight))
3117 (defun article-date-lapsed (&optional highlight)
3118 "Convert the current article date to time lapsed since it was sent."
3119 (interactive (list t))
3120 (article-date-ut 'lapsed highlight))
3122 (defun article-update-date-lapsed ()
3123 "Function to be run from a timer to update the lapsed time line."
3124 (let (deactivate-mark)
3129 (set-buffer (window-buffer w))
3130 (when (eq major-mode 'gnus-article-mode)
3131 (let ((mark (point-marker)))
3132 (goto-char (point-min))
3133 (when (re-search-forward "^X-Sent:" nil t)
3134 (article-date-lapsed t))
3135 (goto-char (marker-position mark))
3136 (move-marker mark nil))))
3139 (defun gnus-start-date-timer (&optional n)
3140 "Start a timer to update the X-Sent header in the article buffers.
3141 The numerical prefix says how frequently (in seconds) the function
3146 (gnus-stop-date-timer)
3147 (setq article-lapsed-timer
3148 (run-at-time 1 n 'article-update-date-lapsed)))
3150 (defun gnus-stop-date-timer ()
3151 "Stop the X-Sent timer."
3153 (when article-lapsed-timer
3154 (nnheader-cancel-timer article-lapsed-timer)
3155 (setq article-lapsed-timer nil)))
3157 (defun article-date-user (&optional highlight)
3158 "Convert the current article date to the user-defined format.
3159 This format is defined by the `gnus-article-time-format' variable."
3160 (interactive (list t))
3161 (article-date-ut 'user highlight))
3163 (defun article-date-iso8601 (&optional highlight)
3164 "Convert the current article date to ISO8601."
3165 (interactive (list t))
3166 (article-date-ut 'iso8601 highlight))
3168 ;; (defun article-show-all ()
3169 ;; "Show all hidden text in the article buffer."
3173 ;; (let ((buffer-read-only nil))
3174 ;; (gnus-article-unhide-text (point-min) (point-max))
3175 ;; (gnus-remove-text-with-property 'gnus-prev)
3176 ;; (gnus-remove-text-with-property 'gnus-next))))
3178 (defun article-show-all-headers ()
3179 "Show all hidden headers in the article buffer."
3184 (article-narrow-to-head)
3185 (let ((buffer-read-only nil))
3186 (gnus-article-unhide-text (point-min) (point-max))))))
3188 (defun article-remove-leading-whitespace ()
3189 "Remove excessive whitespace from all headers."
3193 (let ((buffer-read-only nil))
3194 (article-narrow-to-head)
3195 (goto-char (point-min))
3196 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3197 (delete-region (match-beginning 1) (match-end 1)))))))
3199 (defun article-emphasize (&optional arg)
3200 "Emphasize text according to `gnus-emphasis-alist'."
3201 (interactive (gnus-article-hidden-arg))
3202 (unless (gnus-article-check-hidden-text 'emphasis arg)
3206 (with-current-buffer gnus-summary-buffer
3207 gnus-article-emphasis-alist)
3209 gnus-emphasis-alist))
3210 (buffer-read-only nil)
3211 (props (append '(article-type emphasis)
3212 gnus-hidden-properties))
3213 regexp elem beg invisible visible face)
3216 (while (setq elem (pop alist))
3218 (setq regexp (car elem)
3219 invisible (nth 1 elem)
3220 visible (nth 2 elem)
3222 (while (re-search-forward regexp nil t)
3223 (when (and (match-beginning visible) (match-beginning invisible))
3224 (gnus-article-hide-text
3225 (match-beginning invisible) (match-end invisible) props)
3226 (gnus-article-unhide-text-type
3227 (match-beginning visible) (match-end visible) 'emphasis)
3228 (gnus-put-overlay-excluding-newlines
3229 (match-beginning visible) (match-end visible) 'face face)
3230 (gnus-add-wash-type 'emphasis)
3231 (goto-char (match-end invisible)))))))))
3233 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3234 "Setup newsgroup emphasis alist."
3235 (unless gnus-article-emphasis-alist
3236 (let ((name (and gnus-newsgroup-name
3237 (gnus-group-real-name gnus-newsgroup-name))))
3238 (make-local-variable 'gnus-article-emphasis-alist)
3239 (setq gnus-article-emphasis-alist
3241 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3242 (while (setq elem (pop alist))
3243 (when (and name (string-match (car elem) name))
3245 highlight (copy-sequence (cdr elem)))))
3247 (copy-sequence highlight-words)
3248 (if gnus-newsgroup-name
3249 (copy-sequence (gnus-group-find-parameter
3250 gnus-newsgroup-name 'highlight-words t)))
3251 gnus-emphasis-alist)))))
3254 (defvar gnus-summary-article-menu)
3255 (defvar gnus-summary-post-menu))
3257 ;;; Saving functions.
3259 (defun gnus-article-save (save-buffer file &optional num)
3260 "Save the currently selected article."
3261 (unless gnus-save-all-headers
3262 ;; Remove headers according to `gnus-saved-headers'.
3263 (let ((gnus-visible-headers
3264 (or gnus-saved-headers gnus-visible-headers))
3265 (gnus-article-buffer save-buffer))
3267 (set-buffer save-buffer)
3268 (article-hide-headers 1 t))))
3269 (save-window-excursion
3270 (if (not gnus-default-article-saver)
3271 (error "No default saver is defined")
3272 ;; !!! Magic! The saving functions all save
3273 ;; `gnus-save-article-buffer' (or so they think), but we
3274 ;; bind that variable to our save-buffer.
3275 (set-buffer gnus-article-buffer)
3276 (let* ((gnus-save-article-buffer save-buffer)
3279 ((not gnus-prompt-before-saving) 'default)
3280 ((eq gnus-prompt-before-saving 'always) nil)
3282 (gnus-number-of-articles-to-be-saved
3283 (when (eq gnus-prompt-before-saving t)
3285 (set-buffer gnus-article-current-summary)
3286 (funcall gnus-default-article-saver filename)))))
3288 (defun gnus-read-save-file-name (prompt &optional filename
3289 function group headers variable)
3291 (funcall function group headers (symbol-value variable)))
3296 ((eq filename 'default)
3302 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3305 (if (and gnus-number-of-articles-to-be-saved
3306 (> gnus-number-of-articles-to-be-saved 1))
3307 (format "these %d articles"
3308 gnus-number-of-articles-to-be-saved)
3311 ;; Let the split methods have their say.
3313 ;; No split name was found.
3316 (concat prompt " (default "
3317 (file-name-nondirectory default-name) ") ")
3318 (file-name-directory default-name)
3320 ;; A single group name is returned.
3321 ((stringp split-name)
3323 (funcall function split-name headers
3324 (symbol-value variable)))
3326 (concat prompt " (default "
3327 (file-name-nondirectory default-name) ") ")
3328 (file-name-directory default-name)
3330 ;; A single split name was found
3331 ((= 1 (length split-name))
3332 (let* ((name (expand-file-name
3334 gnus-article-save-directory))
3335 (dir (cond ((file-directory-p name)
3336 (file-name-as-directory name))
3337 ((file-exists-p name) name)
3338 (t gnus-article-save-directory))))
3340 (concat prompt " (default " name ") ")
3342 ;; A list of splits was found.
3344 (setq split-name (nreverse split-name))
3346 (let ((file-name-history
3347 (nconc split-name file-name-history)))
3351 (concat prompt " (`M-p' for defaults) ")
3352 gnus-article-save-directory
3354 gnus-article-save-directory)))
3355 (car (push result file-name-history)))))))
3356 ;; Create the directory.
3357 (gnus-make-directory (file-name-directory file))
3358 ;; If we have read a directory, we append the default file name.
3359 (when (file-directory-p file)
3360 (setq file (expand-file-name (file-name-nondirectory
3362 (file-name-as-directory file))))
3363 ;; Possibly translate some characters.
3364 (nnheader-translate-file-chars file))))))
3365 (gnus-make-directory (file-name-directory result))
3366 (set variable result)))
3368 (defun gnus-article-archive-name (group)
3369 "Return the first instance of an \"Archive-name\" in the current buffer."
3370 (let ((case-fold-search t))
3371 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3372 (nnheader-concat gnus-article-save-directory
3373 (match-string 1)))))
3375 (defun gnus-article-nndoc-name (group)
3376 "If GROUP is an nndoc group, return the name of the parent group."
3377 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3378 (gnus-group-get-parameter group 'save-article-group)))
3380 (defun gnus-summary-save-in-rmail (&optional filename)
3381 "Append this article to Rmail file.
3382 Optional argument FILENAME specifies file name.
3383 Directory to save to is default to `gnus-article-save-directory'."
3384 (setq filename (gnus-read-save-file-name
3385 "Save %s in rmail file:" filename
3386 gnus-rmail-save-name gnus-newsgroup-name
3387 gnus-current-headers 'gnus-newsgroup-last-rmail))
3388 (gnus-eval-in-buffer-window gnus-save-article-buffer
3392 (gnus-output-to-rmail filename))))
3395 (defun gnus-summary-save-in-mail (&optional filename)
3396 "Append this article to Unix mail file.
3397 Optional argument FILENAME specifies file name.
3398 Directory to save to is default to `gnus-article-save-directory'."
3399 (setq filename (gnus-read-save-file-name
3400 "Save %s in Unix mail file:" filename
3401 gnus-mail-save-name gnus-newsgroup-name
3402 gnus-current-headers 'gnus-newsgroup-last-mail))
3403 (gnus-eval-in-buffer-window gnus-save-article-buffer
3407 (if (and (file-readable-p filename)
3408 (file-regular-p filename)
3409 (mail-file-babyl-p filename))
3410 (rmail-output-to-rmail-file filename t)
3411 (gnus-output-to-mail filename)))))
3414 (defun gnus-summary-save-in-file (&optional filename overwrite)
3415 "Append this article to file.
3416 Optional argument FILENAME specifies file name.
3417 Directory to save to is default to `gnus-article-save-directory'."
3418 (setq filename (gnus-read-save-file-name
3419 "Save %s in file:" filename
3420 gnus-file-save-name gnus-newsgroup-name
3421 gnus-current-headers 'gnus-newsgroup-last-file))
3422 (gnus-eval-in-buffer-window gnus-save-article-buffer
3426 (when (and overwrite
3427 (file-exists-p filename))
3428 (delete-file filename))
3429 (gnus-output-to-file filename))))
3432 (defun gnus-summary-write-to-file (&optional filename)
3433 "Write this article to a file, overwriting it if the file exists.
3434 Optional argument FILENAME specifies file name.
3435 The directory to save in defaults to `gnus-article-save-directory'."
3436 (gnus-summary-save-in-file nil t))
3438 (defun gnus-summary-save-body-in-file (&optional filename)
3439 "Append this article body to a file.
3440 Optional argument FILENAME specifies file name.
3441 The directory to save in defaults to `gnus-article-save-directory'."
3442 (setq filename (gnus-read-save-file-name
3443 "Save %s body in file:" filename
3444 gnus-file-save-name gnus-newsgroup-name
3445 gnus-current-headers 'gnus-newsgroup-last-file))
3446 (gnus-eval-in-buffer-window gnus-save-article-buffer
3450 (when (article-goto-body)
3451 (narrow-to-region (point) (point-max)))
3452 (gnus-output-to-file filename))))
3455 (defun gnus-summary-save-in-pipe (&optional command)
3456 "Pipe this article to subprocess."
3458 (cond ((and (eq command 'default)
3459 gnus-last-shell-command)
3460 gnus-last-shell-command)
3465 "Shell command on %s: "
3466 (if (and gnus-number-of-articles-to-be-saved
3467 (> gnus-number-of-articles-to-be-saved 1))
3468 (format "these %d articles"
3469 gnus-number-of-articles-to-be-saved)
3471 gnus-last-shell-command))))
3472 (when (string-equal command "")
3473 (if gnus-last-shell-command
3474 (setq command gnus-last-shell-command)
3475 (error "A command is required")))
3476 (gnus-eval-in-buffer-window gnus-article-buffer
3479 (shell-command-on-region (point-min) (point-max) command nil)))
3480 (setq gnus-last-shell-command command))
3482 (defun gnus-summary-pipe-to-muttprint (&optional command)
3483 "Pipe this article to muttprint."
3484 (setq command (read-string
3485 "Print using command: " gnus-summary-muttprint-program
3486 nil gnus-summary-muttprint-program))
3487 (gnus-summary-save-in-pipe command))
3489 ;;; Article file names when saving.
3491 (defun gnus-capitalize-newsgroup (newsgroup)
3492 "Capitalize NEWSGROUP name."
3493 (when (not (zerop (length newsgroup)))
3494 (concat (char-to-string (upcase (aref newsgroup 0)))
3495 (substring newsgroup 1))))
3497 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3498 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3499 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3500 Otherwise, it is like ~/News/news/group/num."
3503 (concat (if (gnus-use-long-file-name 'not-save)
3504 (gnus-capitalize-newsgroup newsgroup)
3505 (gnus-newsgroup-directory-form newsgroup))
3506 "/" (int-to-string (mail-header-number headers)))
3507 gnus-article-save-directory)))
3509 (string-equal (file-name-directory default)
3510 (file-name-directory last-file))
3511 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3513 (or last-file default))))
3515 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3516 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3517 If variable `gnus-use-long-file-name' is non-nil, it is
3518 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3521 (concat (if (gnus-use-long-file-name 'not-save)
3523 (gnus-newsgroup-directory-form newsgroup))
3524 "/" (int-to-string (mail-header-number headers)))
3525 gnus-article-save-directory)))
3527 (string-equal (file-name-directory default)
3528 (file-name-directory last-file))
3529 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3531 (or last-file default))))
3533 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3534 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3535 If variable `gnus-use-long-file-name' is non-nil, it is
3536 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3539 (if (gnus-use-long-file-name 'not-save)
3542 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3544 gnus-article-save-directory)))
3546 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3547 "Generate file name from sender."
3548 (let ((from (mail-header-from headers)))
3550 (if (and from (string-match "\\([^ <]+\\)@" from))
3551 (match-string 1 from)
3553 gnus-article-save-directory)))
3555 (defun article-verify-x-pgp-sig ()
3558 (if (gnus-buffer-live-p gnus-original-article-buffer)
3559 (let ((sig (with-current-buffer gnus-original-article-buffer
3560 (gnus-fetch-field "X-PGP-Sig")))
3564 (mml2015-clear-verify-function))
3566 (insert-buffer-substring gnus-original-article-buffer)
3567 (setq items (split-string sig))
3568 (message-narrow-to-head)
3569 (let ((inhibit-point-motion-hooks t)
3570 (case-fold-search t))
3571 ;; Don't verify multiple headers.
3572 (setq headers (mapconcat (lambda (header)
3574 (mail-fetch-field header)
3576 (split-string (nth 1 items) ",") "")))
3577 (delete-region (point-min) (point-max))
3578 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3579 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3584 (if (looking-at "^-")
3587 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3588 (insert "Version: " (car items) "\n\n")
3589 (insert (mapconcat 'identity (cddr items) "\n"))
3590 (insert "\n-----END PGP SIGNATURE-----\n")
3591 (let ((mm-security-handle (list (format "multipart/signed"))))
3592 (mml2015-clean-buffer)
3593 (let ((coding-system-for-write (or gnus-newsgroup-charset
3595 (funcall (mml2015-clear-verify-function)))
3597 (or (mm-handle-multipart-ctl-parameter
3598 mm-security-handle 'gnus-details)
3599 (mm-handle-multipart-ctl-parameter
3600 mm-security-handle 'gnus-info)))))
3602 (let (buffer-read-only bface eface)
3604 (message-narrow-to-head)
3605 (goto-char (point-max))
3607 (setq bface (get-text-property (point-at-bol) 'face)
3608 eface (get-text-property (1- (point-at-eol)) 'face))
3609 (message-remove-header "X-Gnus-PGP-Verify")
3610 (if (re-search-forward "^X-PGP-Sig:" nil t)
3612 (goto-char (point-max)))
3613 (narrow-to-region (point) (point))
3614 (insert "X-Gnus-PGP-Verify: " info "\n")
3615 (goto-char (point-min))
3618 (if (not (looking-at "^[ \t]"))
3622 (goto-char (point-min))
3623 (when (looking-at "\\([^:]+\\): *")
3624 (put-text-property (match-beginning 1) (1+ (match-end 1))
3626 (put-text-property (match-end 0) (point-max)
3627 'face eface)))))))))
3629 (defun article-verify-cancel-lock ()
3630 "Verify Cancel-Lock header."
3632 (if (gnus-buffer-live-p gnus-original-article-buffer)
3633 (canlock-verify gnus-original-article-buffer)))
3635 (defun article-monafy ()
3636 "Display body part with mona font."
3638 (unless (if (featurep 'xemacs)
3639 (find-face 'gnus-mona-face)
3640 (facep 'gnus-mona-face))
3641 (require 'navi2ch-mona)
3642 (set-face-font (make-face 'gnus-mona-face) navi2ch-mona-font))
3644 (let ((buffer-read-only nil))
3647 (gnus-make-overlay (point) (point-max))
3648 'face 'gnus-mona-face))))
3655 (setq afunc (car func)
3658 gfunc (intern (format "gnus-%s" func))))
3660 (when (fboundp afunc)
3661 `(lambda (&optional interactive &rest args)
3662 ,(documentation afunc t)
3663 (interactive (list t))
3665 (set-buffer gnus-article-buffer)
3667 (call-interactively ',afunc)
3668 (apply ',afunc args))))))))
3669 '(article-hide-headers
3670 article-verify-x-pgp-sig
3671 article-verify-cancel-lock
3673 article-hide-boring-headers
3674 article-treat-overstrike
3675 article-treat-ansi-sequences
3676 article-fill-long-lines
3677 article-capitalize-sentences
3679 article-remove-leading-whitespace
3680 article-display-x-face
3681 article-display-face
3682 article-de-quoted-unreadable
3683 article-de-base64-unreadable
3686 article-unsplit-urls
3687 article-hide-list-identifiers
3688 article-strip-banner
3691 article-hide-signature
3692 article-strip-headers-in-body
3693 article-remove-trailing-blank-lines
3694 article-strip-leading-blank-lines
3695 article-strip-multiple-blank-lines
3696 article-strip-leading-space
3697 article-strip-trailing-space
3698 article-strip-blank-lines
3699 article-strip-all-blank-lines
3701 article-date-english
3702 article-date-iso8601
3703 article-date-original
3705 article-decode-mime-words
3706 article-decode-charset
3707 article-decode-encoded-words
3711 article-treat-dumbquotes
3712 article-normalize-headers
3713 (article-show-all-headers . gnus-article-show-all-headers)
3714 ;; (article-show-all . gnus-article-show-all)
3718 ;;; Gnus article mode
3721 (put 'gnus-article-mode 'mode-class 'special)
3723 (gnus-define-keys gnus-article-mode-map
3724 " " gnus-article-goto-next-page
3725 "\177" gnus-article-goto-prev-page
3726 [delete] gnus-article-goto-prev-page
3727 [backspace] gnus-article-goto-prev-page
3728 "\C-c^" gnus-article-refer-article
3729 "h" gnus-article-show-summary
3730 "s" gnus-article-show-summary
3731 "\C-c\C-m" gnus-article-mail
3732 "?" gnus-article-describe-briefly
3733 "e" gnus-summary-edit-article
3734 "<" beginning-of-buffer
3736 "\C-c\C-i" gnus-info-find-node
3738 "R" gnus-article-reply-with-original
3739 "F" gnus-article-followup-with-original
3740 "\C-hk" gnus-article-describe-key
3741 "\C-hc" gnus-article-describe-key-briefly
3743 "\C-d" gnus-article-read-summary-keys
3744 "\M-*" gnus-article-read-summary-keys
3745 "\M-#" gnus-article-read-summary-keys
3746 "\M-^" gnus-article-read-summary-keys
3747 "\M-g" gnus-article-read-summary-keys)
3749 ;; Define almost undefined keys to `gnus-article-read-summary-keys'.
3753 (push (char-to-string key) keys)
3755 (dolist (elem (accessible-keymaps gnus-summary-mode-map))
3756 (setq key (car elem))
3757 (when (and (> (length key) 0)
3758 (not (eq 'menu-bar (aref key 0)))
3759 (symbolp (lookup-key gnus-summary-mode-map key)))
3762 (unless (lookup-key gnus-article-mode-map key)
3763 (define-key gnus-article-mode-map key 'gnus-article-read-summary-keys))))
3765 (defun gnus-article-make-menu-bar ()
3766 (unless (boundp 'gnus-article-commands-menu)
3767 (gnus-summary-make-menu-bar))
3768 (gnus-turn-off-edit-menu 'article)
3769 (unless (boundp 'gnus-article-article-menu)
3771 gnus-article-article-menu gnus-article-mode-map ""
3773 ["Scroll forwards" gnus-article-goto-next-page t]
3774 ["Scroll backwards" gnus-article-goto-prev-page t]
3775 ["Show summary" gnus-article-show-summary t]
3776 ["Fetch Message-ID at point" gnus-article-refer-article t]
3777 ["Mail to address at point" gnus-article-mail t]
3778 ["Send a bug report" gnus-bug t]))
3781 gnus-article-treatment-menu gnus-article-mode-map ""
3782 ;; Fixme: this should use :active (and maybe :visible).
3784 ["Hide headers" gnus-article-hide-headers t]
3785 ["Hide signature" gnus-article-hide-signature t]
3786 ["Hide citation" gnus-article-hide-citation t]
3787 ["Treat overstrike" gnus-article-treat-overstrike t]
3788 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
3789 ["Remove carriage return" gnus-article-remove-cr t]
3790 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3791 ["Treat html" gnus-article-wash-html t]
3792 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3793 ["Decode HZ" gnus-article-decode-HZ t]))
3795 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3797 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3799 (gnus-run-hooks 'gnus-article-menu-hook)))
3801 (defun gnus-article-mode ()
3802 "Major mode for displaying an article.
3804 All normal editing commands are switched off.
3806 The following commands are available in addition to all summary mode
3808 \\<gnus-article-mode-map>
3809 \\[gnus-article-next-page]\t Scroll the article one page forwards
3810 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3811 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3812 \\[gnus-article-show-summary]\t Display the summary buffer
3813 \\[gnus-article-mail]\t Send a reply to the address near point
3814 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3815 \\[gnus-info-find-node]\t Go to the Gnus info node"
3817 (gnus-simplify-mode-line)
3818 (setq mode-name "Article")
3819 (setq major-mode 'gnus-article-mode)
3820 (make-local-variable 'minor-mode-alist)
3821 (unless (assq 'gnus-show-mime minor-mode-alist)
3822 (push (list 'gnus-show-mime " MIME") minor-mode-alist))
3823 (use-local-map gnus-article-mode-map)
3824 (when (gnus-visual-p 'article-menu 'menu)
3825 (gnus-article-make-menu-bar)
3826 (when gnus-summary-tool-bar-map
3827 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3828 (gnus-update-format-specifications nil 'article-mode)
3829 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3830 (set (make-local-variable 'gnus-page-broken) nil)
3831 (make-local-variable 'gnus-button-marker-list)
3832 (make-local-variable 'gnus-article-current-summary)
3833 (make-local-variable 'gnus-article-mime-handles)
3834 (make-local-variable 'gnus-article-decoded-p)
3835 (make-local-variable 'gnus-article-mime-handle-alist)
3836 (make-local-variable 'gnus-article-wash-types)
3837 (make-local-variable 'gnus-article-image-alist)
3838 (make-local-variable 'gnus-article-charset)
3839 (make-local-variable 'gnus-article-ignored-charsets)
3840 (gnus-set-default-directory)
3841 (buffer-disable-undo)
3842 (setq buffer-read-only t)
3843 (set-syntax-table gnus-article-mode-syntax-table)
3844 (gnus-run-hooks 'gnus-article-mode-hook))
3846 (defun gnus-article-setup-buffer ()
3847 "Initialize the article buffer."
3848 (let* ((name (if gnus-single-article-buffer "*Article*"
3849 (concat "*Article " gnus-newsgroup-name "*")))
3851 (progn (string-match "\\*Article" name)
3852 (concat " *Original Article"
3853 (substring name (match-end 0))))))
3854 (setq gnus-article-buffer name)
3855 (setq gnus-original-article-buffer original)
3856 (setq gnus-article-mime-handle-alist nil)
3857 ;; This might be a variable local to the summary buffer.
3858 (unless gnus-single-article-buffer
3860 (set-buffer gnus-summary-buffer)
3861 (setq gnus-article-buffer name)
3862 (setq gnus-original-article-buffer original)
3863 (gnus-set-global-variables)))
3864 (gnus-article-setup-highlight-words)
3865 ;; Init original article buffer.
3867 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3868 (set-buffer-multibyte t)
3869 (setq major-mode 'gnus-original-article-mode)
3870 (make-local-variable 'gnus-original-article))
3871 (if (get-buffer name)
3874 (when (and gnus-article-edit-mode
3877 (y-or-n-p "Article mode edit in progress; discard? ")))
3878 (error "Action aborted"))
3879 (set (make-local-variable 'gnus-article-edit-mode) nil)
3880 (buffer-disable-undo)
3881 (setq buffer-read-only t)
3882 ;; This list just keeps growing if we don't reset it.
3883 (setq gnus-button-marker-list nil)
3884 (unless (eq major-mode 'gnus-article-mode)
3885 (gnus-article-mode))
3888 (set-buffer (gnus-get-buffer-create name))
3890 (make-local-variable 'gnus-summary-buffer)
3891 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3892 (current-buffer)))))
3894 ;; Set article window start at LINE, where LINE is the number of lines
3895 ;; from the head of the article.
3896 (defun gnus-article-set-window-start (&optional line)
3898 (gnus-get-buffer-window gnus-article-buffer t)
3900 (set-buffer gnus-article-buffer)
3901 (goto-char (point-min))
3904 (gnus-message 6 "Moved to bookmark")
3905 (search-forward "\n\n" nil t)
3909 ;;; @@ article filters
3912 (defun gnus-article-display-mime-message ()
3913 "Article display method for MIME message."
3914 ;; called from `gnus-original-article-buffer'.
3915 (let (charset all-headers)
3916 (with-current-buffer gnus-summary-buffer
3917 (setq charset default-mime-charset
3918 all-headers gnus-have-all-headers))
3919 (make-local-variable 'default-mime-charset)
3920 (setq default-mime-charset charset)
3921 (with-current-buffer (get-buffer-create gnus-article-buffer)
3922 (make-local-variable 'default-mime-charset)
3923 (setq default-mime-charset charset))
3924 (mime-display-message mime-message-structure
3925 gnus-article-buffer nil gnus-article-mode-map)
3927 (gnus-article-hide-headers nil -1)))
3928 (run-hooks 'gnus-mime-article-prepare-hook))
3930 (defun gnus-article-display-traditional-message ()
3931 "Article display method for traditional message."
3932 (set-buffer gnus-article-buffer)
3933 (let (buffer-read-only)
3935 (insert-buffer-substring gnus-original-article-buffer)))
3937 (defun gnus-article-make-full-mail-header (&optional number charset)
3938 "Create a new mail header structure in a raw article buffer."
3939 (unless (and number charset)
3940 (save-current-buffer
3941 (set-buffer gnus-summary-buffer)
3943 (setq number (or (cdr gnus-article-current) 0)))
3945 (setq charset (or default-mime-charset 'x-ctext)))))
3946 (goto-char (point-min))
3947 (let ((header-end (if (search-forward "\n\n" nil t)
3949 (goto-char (point-max))))
3950 (chars (- (point-max) (point)))
3951 (lines (count-lines (point) (point-max)))
3952 (default-mime-charset charset)
3954 (narrow-to-region (point-min) header-end)
3955 (setq xref (std11-fetch-field "xref"))
3957 (make-full-mail-header
3959 (std11-fetch-field "subject")
3960 (std11-fetch-field "from")
3961 (std11-fetch-field "date")
3962 (std11-fetch-field "message-id")
3963 (std11-fetch-field "references")
3966 (when xref (concat "Xref: " xref)))
3969 (defun gnus-article-prepare (article &optional all-headers header)
3970 "Prepare ARTICLE in article mode buffer.
3971 ARTICLE should either be an article number or a Message-ID.
3972 If ARTICLE is an id, HEADER should be the article headers.
3973 If ALL-HEADERS is non-nil, no headers are hidden."
3975 ;; Make sure we start in a summary buffer.
3976 (unless (eq major-mode 'gnus-summary-mode)
3977 (set-buffer gnus-summary-buffer))
3978 (setq gnus-summary-buffer (current-buffer))
3979 (let* ((gnus-article (if header (mail-header-number header) article))
3980 (summary-buffer (current-buffer))
3981 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3982 (group gnus-newsgroup-name)
3985 (gnus-article-setup-buffer)
3986 (set-buffer gnus-article-buffer)
3987 ;; Deactivate active regions.
3988 (when (and (boundp 'transient-mark-mode)
3989 transient-mark-mode)
3990 (setq mark-active nil))
3991 (if (not (setq result (let ((buffer-read-only nil))
3992 (gnus-request-article-this-buffer
3994 ;; There is no such article.
3996 (when (and (numberp article)
3997 (not (memq article gnus-newsgroup-sparse)))
3998 (setq gnus-article-current
3999 (cons gnus-newsgroup-name article))
4000 (set-buffer gnus-summary-buffer)
4001 (setq gnus-current-article article)
4002 (if (and (memq article gnus-newsgroup-undownloaded)
4003 (not (gnus-online (gnus-find-method-for-group
4004 gnus-newsgroup-name))))
4006 (gnus-summary-set-agent-mark article)
4007 (message "Message marked for downloading"))
4008 (gnus-summary-mark-article article gnus-canceled-mark)
4009 (unless (memq article gnus-newsgroup-sparse)
4010 (gnus-error 1 "No such article (may have expired or been canceled)")))))
4011 (if (or (eq result 'pseudo)
4012 (eq result 'nneething))
4015 (set-buffer summary-buffer)
4016 (push article gnus-newsgroup-history)
4017 (setq gnus-last-article gnus-current-article
4018 gnus-current-article 0
4019 gnus-current-headers nil
4020 gnus-article-current nil)
4021 (if (eq result 'nneething)
4022 (gnus-configure-windows 'summary)
4023 (gnus-configure-windows 'article))
4024 (gnus-set-global-variables))
4025 (let ((gnus-article-mime-handle-alist-1
4026 gnus-article-mime-handle-alist))
4027 (gnus-set-mode-line 'article)))
4028 ;; The result from the `request' was an actual article -
4029 ;; or at least some text that is now displayed in the
4031 (when (and (numberp article)
4032 (not (eq article gnus-current-article)))
4033 ;; Seems like a new article has been selected.
4034 ;; `gnus-current-article' must be an article number.
4036 (set-buffer summary-buffer)
4037 (push article gnus-newsgroup-history)
4038 (setq gnus-last-article gnus-current-article
4039 gnus-current-article article
4040 gnus-current-headers
4041 (gnus-summary-article-header gnus-current-article)
4042 gnus-article-current
4043 (cons gnus-newsgroup-name gnus-current-article))
4044 (unless (vectorp gnus-current-headers)
4045 (setq gnus-current-headers nil))
4046 (gnus-summary-goto-subject gnus-current-article)
4047 (when (gnus-summary-show-thread)
4048 ;; If the summary buffer really was folded, the
4049 ;; previous goto may not actually have gone to
4050 ;; the right article, but the thread root instead.
4052 (gnus-summary-goto-subject gnus-current-article))
4053 (gnus-run-hooks 'gnus-mark-article-hook)
4054 (gnus-set-mode-line 'summary)
4055 (when (gnus-visual-p 'article-highlight 'highlight)
4056 (gnus-run-hooks 'gnus-visual-mark-article-hook))
4057 ;; Set the global newsgroup variables here.
4058 (gnus-set-global-variables)
4059 (setq gnus-have-all-headers
4060 (or all-headers gnus-show-all-headers))))
4062 (gnus-configure-windows 'article))
4063 (when (or (numberp article)
4065 (gnus-article-prepare-display)
4067 (goto-char (point-min))
4068 (when gnus-break-pages
4069 (gnus-narrow-to-page)))
4070 (let ((gnus-article-mime-handle-alist-1
4071 gnus-article-mime-handle-alist))
4072 (gnus-set-mode-line 'article))
4076 (set-window-point (get-buffer-window (current-buffer)) (point))
4077 (gnus-configure-windows 'article)
4080 (defun gnus-article-prepare-mime-display (&optional number)
4081 (goto-char (point-min))
4082 (when (re-search-forward "^[^\t ]+:" nil t)
4083 (goto-char (match-beginning 0)))
4084 (let ((entity (if (eq 1 (point-min))
4085 (get-text-property 1 'mime-view-entity)
4086 (get-text-property (point) 'mime-view-entity)))
4087 last-entity child-entity next type)
4088 (setq child-entity (mime-entity-children entity))
4090 (setq last-entity (nth (1- (length child-entity))
4092 (setq last-entity entity))
4094 (narrow-to-region (point)
4095 (if (search-forward "\n\n" nil t)
4098 (gnus-treat-article 'head)
4099 (put-text-property (point-min) (point-max) 'article-treated-header t)
4100 (goto-char (point-max)))
4101 (while (and (not (eobp)) entity)
4102 (setq next (set-marker
4104 (next-single-property-change (point) 'mime-view-entity
4106 (let ((types (mime-entity-content-type entity)))
4107 (while (eq 'multipart (mime-content-type-primary-type types))
4108 (setq entity (car (mime-entity-children entity))
4109 types (mime-entity-content-type entity)))
4111 (setq type (format "%s/%s"
4112 (mime-content-type-primary-type types)
4113 (mime-content-type-subtype types)))))
4114 (if (string-equal type "message/rfc822")
4117 (let ((children (mime-entity-children entity))
4120 (setq last-children (nth (1- (length children)) children))
4123 (not (eq last-children
4124 (get-text-property next 'mime-view-entity)))
4126 (next-single-property-change next
4128 nil (point-max)))))))
4129 (setq next (next-single-property-change next 'mime-view-entity
4132 (narrow-to-region (point) next)
4133 (gnus-article-prepare-mime-display)
4134 (goto-char (point-max)))
4135 (setq entity (get-text-property (point) 'mime-view-entity)))
4137 (narrow-to-region (point) next)
4138 ;; Kludge. We have to count true number, but for now,
4139 ;; part number is here only to achieve `last'.
4140 (gnus-treat-article nil 1
4141 (if (eq entity last-entity)
4144 (goto-char (point-max)))
4145 (setq entity (get-text-property next 'mime-view-entity))))))
4148 (defun gnus-article-prepare-display ()
4149 "Make the current buffer look like a nice article."
4150 (let ((gnus-article-buffer (current-buffer))
4152 (unless (eq major-mode 'gnus-article-mode)
4153 (gnus-article-mode))
4154 (setq buffer-read-only nil
4155 gnus-button-marker-list nil
4156 gnus-article-wash-types nil
4157 gnus-article-image-alist nil)
4160 (static-if (featurep 'xemacs)
4161 (map-extents (lambda (extent maparg) (delete-extent extent)))
4162 (let ((lists (overlay-lists)))
4163 (dolist (overlay (nconc (car lists) (cdr lists)))
4164 (delete-overlay overlay)))))
4165 (gnus-run-hooks 'gnus-tmp-internal-hook))
4166 (let ((show-mime (unless (member gnus-newsgroup-name '("nndraft:delayed"
4169 (inhibit-read-only t))
4170 (set-buffer gnus-original-article-buffer)
4172 (setq mime-message-structure gnus-current-headers)
4173 (mime-buffer-entity-set-buffer-internal mime-message-structure
4174 gnus-original-article-buffer)
4175 (mime-entity-set-representation-type-internal mime-message-structure
4176 'mime-buffer-entity)
4177 (luna-send mime-message-structure 'initialize-instance
4178 mime-message-structure)
4180 (let (mime-display-header-hook mime-display-text/plain-hook)
4181 (funcall gnus-article-display-method-for-mime))
4182 (funcall gnus-article-display-method-for-traditional))
4183 ;; Call the treatment functions.
4187 (gnus-article-prepare-mime-display)
4188 (narrow-to-region (goto-char (point-min))
4189 (if (search-forward "\n\n" nil t)
4192 (gnus-treat-article 'head)
4193 (put-text-property (point-min) (point-max) 'article-treated-header t)
4194 (goto-char (point-max))
4196 (narrow-to-region (point) (point-max))
4197 (gnus-treat-article nil))
4198 (put-text-property (point-min) (point-max) 'read-only nil)))
4199 (gnus-run-hooks 'gnus-article-prepare-hook))
4201 (defun gnus-article-decode-article-as-default-mime-charset ()
4202 "Decode an article as `default-mime-charset'. It won't work if the
4203 value of the variable `gnus-show-mime' is non-nil."
4204 (unless (or gnus-show-mime
4205 (member gnus-newsgroup-name '("nndraft:delayed"
4207 (set (make-local-variable 'default-mime-charset)
4208 (with-current-buffer gnus-summary-buffer
4209 default-mime-charset))
4210 (decode-mime-charset-region (point-min) (point-max)
4211 default-mime-charset)))
4214 ;;; Gnus MIME viewing functions
4217 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4218 "Format of the MIME buttons.
4220 Valid specifiers include:
4222 %T MIME type, along with additional info
4223 %n The `name' parameter
4224 %d The description, if any
4225 %l The length of the encoded part
4226 %p The part identifier number
4227 %e Dots if the part isn't displayed
4229 General format specifiers can also be used. See Info node
4230 `(gnus)Formatting Variables'.")
4232 (defvar gnus-mime-button-line-format-alist
4233 '((?t gnus-tmp-type ?s)
4234 (?T gnus-tmp-type-long ?s)
4235 (?n gnus-tmp-name ?s)
4236 (?d gnus-tmp-description ?s)
4238 (?l gnus-tmp-length ?d)
4239 (?e gnus-tmp-dots ?s)))
4241 (defvar gnus-mime-button-commands
4242 '((gnus-article-press-button "\r" "Toggle Display")
4243 (gnus-mime-view-part "v" "View Interactively...")
4244 (gnus-mime-view-part-as-type "t" "View As Type...")
4245 (gnus-mime-view-part-as-charset "C" "View As charset...")
4246 (gnus-mime-save-part "o" "Save...")
4247 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4248 (gnus-mime-delete-part "d" "Delete part")
4249 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4250 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4251 (gnus-mime-view-part-internally "E" "View Internally")
4252 (gnus-mime-view-part-externally "e" "View Externally")
4253 (gnus-mime-print-part "p" "Print")
4254 (gnus-mime-pipe-part "|" "Pipe To Command...")
4255 (gnus-mime-action-on-part "." "Take action on the part...")))
4257 (defun gnus-article-mime-part-status ()
4258 (with-current-buffer gnus-article-buffer
4259 (let ((entity (get-text-property (point-min) 'mime-view-entity))
4262 (setq children (mime-entity-children entity))
4263 (setq children (length children)))
4266 (format " (%d parts)" children))
4269 (defvar gnus-mime-button-map
4270 (let ((map (make-sparse-keymap)))
4271 (define-key map gnus-mouse-2 'gnus-article-push-button)
4272 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4273 (dolist (c gnus-mime-button-commands)
4274 (define-key map (cadr c) (car c)))
4278 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4280 ,@(mapcar (lambda (c)
4281 (vector (caddr c) (car c) :enable t))
4282 gnus-mime-button-commands)))
4284 (defun gnus-mime-button-menu (event prefix)
4285 "Construct a context-sensitive menu of MIME commands."
4286 (interactive "e\nP")
4287 (save-window-excursion
4288 (let ((pos (event-start event)))
4289 (select-window (posn-window pos))
4290 (goto-char (posn-point pos))
4291 (gnus-article-check-buffer)
4292 (popup-menu gnus-mime-button-menu nil prefix))))
4294 (defun gnus-mime-view-all-parts (&optional handles)
4295 "View all the MIME parts."
4297 (with-current-buffer gnus-article-buffer
4298 (let ((handles (or handles gnus-article-mime-handles))
4299 (mail-parse-charset gnus-newsgroup-charset)
4300 (mail-parse-ignored-charsets
4301 (with-current-buffer gnus-summary-buffer
4302 gnus-newsgroup-ignored-charsets)))
4304 (mm-remove-parts handles)
4305 (goto-char (point-min))
4306 (or (search-forward "\n\n") (goto-char (point-max)))
4307 (let (buffer-read-only)
4308 (delete-region (point) (point-max))
4309 (mm-display-parts handles))))))
4311 (defun gnus-mime-save-part-and-strip ()
4312 "Save the MIME part under point then replace it with an external body."
4314 (gnus-article-check-buffer)
4315 (let* ((data (get-text-property (point) 'gnus-data))
4317 (handles gnus-article-mime-handles))
4318 (if (mm-multiple-handles gnus-article-mime-handles)
4319 (error "This function is not implemented"))
4320 (setq file (and data (mm-save-part data)))
4322 (with-current-buffer (mm-handle-buffer data)
4324 (insert "Content-Type: " (mm-handle-media-type data))
4325 (mml-insert-parameter-string (cdr (mm-handle-type data))
4328 (insert "Content-ID: " (message-make-message-id) "\n")
4329 (insert "Content-Transfer-Encoding: binary\n")
4332 (cdr (mm-make-handle nil
4333 `("message/external-body"
4334 (access-type . "LOCAL-FILE")
4336 (set-buffer gnus-summary-buffer)
4337 (gnus-article-edit-article
4340 (let ((mail-parse-charset (or gnus-article-charset
4341 ',gnus-newsgroup-charset))
4342 (mail-parse-ignored-charsets
4343 (or gnus-article-ignored-charsets
4344 ',gnus-newsgroup-ignored-charsets))
4345 (mbl mml-buffer-list))
4346 (setq mml-buffer-list nil)
4347 (insert-buffer gnus-original-article-buffer)
4348 (mime-to-mml ',handles)
4349 (setq gnus-article-mime-handles nil)
4350 (let ((mbl1 mml-buffer-list))
4351 (setq mml-buffer-list mbl)
4352 (set (make-local-variable 'mml-buffer-list) mbl1))
4353 (gnus-make-local-hook 'kill-buffer-hook)
4354 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4355 `(lambda (no-highlight)
4356 (let ((mail-parse-charset (or gnus-article-charset
4357 ',gnus-newsgroup-charset))
4358 (message-options message-options)
4359 (message-options-set-recipient)
4360 (mail-parse-ignored-charsets
4361 (or gnus-article-ignored-charsets
4362 ',gnus-newsgroup-ignored-charsets)))
4364 (mml-destroy-buffers)
4365 (remove-hook 'kill-buffer-hook
4366 'mml-destroy-buffers t)
4367 (kill-local-variable 'mml-buffer-list))
4368 (gnus-summary-edit-article-done
4369 ,(or (mail-header-references gnus-current-headers) "")
4370 ,(gnus-group-read-only-p)
4371 ,gnus-summary-buffer no-highlight))))))
4373 (defun gnus-mime-delete-part ()
4374 "Delete the MIME part under point.
4375 Replace it with some information about the removed part."
4377 (gnus-article-check-buffer)
4378 (unless (and gnus-novice-user
4379 (not (gnus-yes-or-no-p
4380 "Really delete attachment forever? ")))
4381 (let* ((data (get-text-property (point) 'gnus-data))
4382 (handles gnus-article-mime-handles)
4386 (mail-decode-encoded-word-string (or (mm-handle-description data)
4389 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4391 (type (mm-handle-media-type data)))
4392 (if (mm-multiple-handles gnus-article-mime-handles)
4393 (error "This function is not implemented"))
4394 (with-current-buffer (mm-handle-buffer data)
4395 (let ((bsize (format "%s" (buffer-size))))
4400 "| The following attachment has been deleted:\n"
4402 "| Type: " type "\n"
4403 "| Filename: " filename "\n"
4404 "| Size (encoded): " bsize " Byte\n"
4405 "| Description: " description "\n"
4408 (cdr (mm-make-handle
4409 nil `("text/plain") nil nil
4411 (format "Deleted attachment (%s bytes)" bsize))))))
4412 (set-buffer gnus-summary-buffer)
4413 ;; FIXME: maybe some of the following code (borrowed from
4414 ;; `gnus-mime-save-part-and-strip') isn't necessary?
4415 (gnus-article-edit-article
4418 (let ((mail-parse-charset (or gnus-article-charset
4419 ',gnus-newsgroup-charset))
4420 (mail-parse-ignored-charsets
4421 (or gnus-article-ignored-charsets
4422 ',gnus-newsgroup-ignored-charsets))
4423 (mbl mml-buffer-list))
4424 (setq mml-buffer-list nil)
4425 (insert-buffer gnus-original-article-buffer)
4426 (mime-to-mml ',handles)
4427 (setq gnus-article-mime-handles nil)
4428 (let ((mbl1 mml-buffer-list))
4429 (setq mml-buffer-list mbl)
4430 (set (make-local-variable 'mml-buffer-list) mbl1))
4431 (gnus-make-local-hook 'kill-buffer-hook)
4432 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4433 `(lambda (no-highlight)
4434 (let ((mail-parse-charset (or gnus-article-charset
4435 ',gnus-newsgroup-charset))
4436 (message-options message-options)
4437 (message-options-set-recipient)
4438 (mail-parse-ignored-charsets
4439 (or gnus-article-ignored-charsets
4440 ',gnus-newsgroup-ignored-charsets)))
4442 (mml-destroy-buffers)
4443 (remove-hook 'kill-buffer-hook
4444 'mml-destroy-buffers t)
4445 (kill-local-variable 'mml-buffer-list))
4446 (gnus-summary-edit-article-done
4447 ,(or (mail-header-references gnus-current-headers) "")
4448 ,(gnus-group-read-only-p)
4449 ,gnus-summary-buffer no-highlight)))))
4450 ;; Not in `gnus-mime-save-part-and-strip':
4451 (gnus-article-edit-done)
4452 (gnus-summary-expand-window)
4453 (gnus-summary-show-article))
4455 (defun gnus-mime-save-part ()
4456 "Save the MIME part under point."
4458 (gnus-article-check-buffer)
4459 (let ((data (get-text-property (point) 'gnus-data)))
4461 (mm-save-part data))))
4463 (defun gnus-mime-pipe-part ()
4464 "Pipe the MIME part under point to a process."
4466 (gnus-article-check-buffer)
4467 (let ((data (get-text-property (point) 'gnus-data)))
4469 (mm-pipe-part data))))
4471 (defun gnus-mime-view-part ()
4472 "Interactively choose a viewing method for the MIME part under point."
4474 (gnus-article-check-buffer)
4475 (let ((data (get-text-property (point) 'gnus-data)))
4477 (setq gnus-article-mime-handles
4479 gnus-article-mime-handles (setq data (copy-sequence data))))
4480 (mm-interactively-view-part data))))
4482 (defun gnus-mime-view-part-as-type-internal ()
4483 (gnus-article-check-buffer)
4484 (let* ((name (mail-content-type-get
4485 (mm-handle-type (get-text-property (point) 'gnus-data))
4487 (def-type (and name (mm-default-file-encoding name))))
4488 (and def-type (cons def-type 0))))
4490 (defun gnus-mime-view-part-as-type (&optional mime-type)
4491 "Choose a MIME media type, and view the part as such."
4494 (setq mime-type (completing-read
4495 "View as MIME type: "
4496 (mapcar #'list (mailcap-mime-types))
4498 (gnus-mime-view-part-as-type-internal))))
4499 (gnus-article-check-buffer)
4500 (let ((handle (get-text-property (point) 'gnus-data)))
4503 (mm-make-handle (mm-handle-buffer handle)
4504 (cons mime-type (cdr (mm-handle-type handle)))
4505 (mm-handle-encoding handle)
4506 (mm-handle-undisplayer handle)
4507 (mm-handle-disposition handle)
4508 (mm-handle-description handle)
4510 (mm-handle-id handle)))
4511 (setq gnus-article-mime-handles
4512 (mm-merge-handles gnus-article-mime-handles handle))
4513 (gnus-mm-display-part handle))))
4516 (require 'jka-compr))
4518 ;; jka-compr.el uses a "sh -c" to direct stderr to err-file, but these days
4519 ;; emacs can do that itself.
4521 (defun gnus-mime-jka-compr-maybe-uncompress ()
4522 "Uncompress the current buffer if `auto-compression-mode' is enabled.
4523 The uncompress method used is derived from `buffer-file-name'."
4524 (when (and (fboundp 'jka-compr-installed-p)
4525 (jka-compr-installed-p))
4526 (let ((info (jka-compr-get-compression-info buffer-file-name)))
4528 (let ((basename (file-name-nondirectory buffer-file-name))
4529 (args (jka-compr-info-uncompress-args info))
4530 (prog (jka-compr-info-uncompress-program info))
4531 (message (jka-compr-info-uncompress-message info))
4532 (err-file (jka-compr-make-temp-name)))
4534 (message "%s %s..." message basename))
4536 (unless (memq (apply 'call-process-region
4537 (point-min) (point-max)
4539 t (list t err-file) nil
4541 jka-compr-acceptable-retval-list)
4542 (jka-compr-error prog args basename message err-file))
4543 (jka-compr-delete-temp-file err-file)))))))
4545 (defun gnus-mime-copy-part (&optional handle)
4546 "Put the MIME part under point into a new buffer.
4547 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4550 (gnus-article-check-buffer)
4551 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4552 (contents (and handle (mm-get-part handle)))
4554 (file-name-nondirectory
4556 (mail-content-type-get (mm-handle-type handle) 'name)
4557 (mail-content-type-get (mm-handle-disposition handle)
4560 (buffer (and base (generate-new-buffer base))))
4562 (switch-to-buffer buffer)
4564 ;; We do it this way to make `normal-mode' set the appropriate mode.
4567 (setq buffer-file-name (expand-file-name base))
4568 (gnus-mime-jka-compr-maybe-uncompress)
4570 (setq buffer-file-name nil))
4571 (goto-char (point-min)))))
4573 (defun gnus-mime-print-part (&optional handle filename)
4574 "Print the MIME part under point."
4575 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4576 (gnus-article-check-buffer)
4577 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4578 (contents (and handle (mm-get-part handle)))
4579 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4580 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4585 (mm-save-part-to-file handle file)
4586 (call-process shell-file-name nil
4587 (generate-new-buffer " *mm*")
4589 shell-command-switch
4591 printer file (mm-handle-type handle))))
4595 (gnus-print-buffer))
4596 (ps-despool filename)))))
4598 (defun gnus-mime-inline-part (&optional handle arg)
4599 "Insert the MIME part under point into the current buffer."
4600 (interactive (list nil current-prefix-arg))
4601 (gnus-article-check-buffer)
4602 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4607 (if (and (not arg) (mm-handle-undisplayer handle))
4608 (mm-remove-part handle)
4609 (setq contents (mm-get-part handle))
4612 (setq charset (or (mail-content-type-get
4613 (mm-handle-type handle) 'charset)
4614 gnus-newsgroup-charset)))
4616 (if (mm-handle-undisplayer handle)
4617 (mm-remove-part handle))
4620 gnus-summary-show-article-charset-alist))
4621 (mm-read-coding-system "Charset: ")))))
4623 (mm-insert-inline handle
4625 (setq charset (mm-charset-to-coding-system
4627 (not (eq charset 'ascii)))
4628 (mm-decode-coding-string contents charset)
4632 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4633 "Insert the MIME part under point into the current buffer using the
4635 (interactive (list nil current-prefix-arg))
4636 (gnus-article-check-buffer)
4637 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4642 (if (mm-handle-undisplayer handle)
4643 (mm-remove-part handle))
4644 (let ((gnus-newsgroup-charset
4646 gnus-summary-show-article-charset-alist))
4647 (mm-read-coding-system "Charset: ")))
4648 (gnus-newsgroup-ignored-charsets 'gnus-all))
4649 (gnus-article-press-button)))))
4651 (defun gnus-mime-view-part-externally (&optional handle)
4652 "View the MIME part under point with an external viewer."
4654 (gnus-article-check-buffer)
4655 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4656 (mm-user-display-methods nil)
4657 (mm-inlined-types nil)
4658 (mail-parse-charset gnus-newsgroup-charset)
4659 (mail-parse-ignored-charsets
4660 (with-current-buffer gnus-summary-buffer
4661 gnus-newsgroup-ignored-charsets)))
4663 (if (mm-handle-undisplayer handle)
4664 (mm-remove-part handle)
4665 (mm-display-part handle)))))
4667 (defun gnus-mime-view-part-internally (&optional handle)
4668 "View the MIME part under point with an internal viewer.
4669 If no internal viewer is available, use an external viewer."
4671 (gnus-article-check-buffer)
4672 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4673 (mm-inlined-types '(".*"))
4674 (mm-inline-large-images t)
4675 (mail-parse-charset gnus-newsgroup-charset)
4676 (mail-parse-ignored-charsets
4677 (with-current-buffer gnus-summary-buffer
4678 gnus-newsgroup-ignored-charsets))
4681 (if (mm-handle-undisplayer handle)
4682 (mm-remove-part handle)
4683 (mm-display-part handle)))))
4685 (defun gnus-mime-action-on-part (&optional action)
4686 "Do something with the MIME attachment at \(point\)."
4688 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4689 (gnus-article-check-buffer)
4690 (let ((action-pair (assoc action gnus-mime-action-alist)))
4692 (funcall (cdr action-pair)))))
4694 (defun gnus-article-part-wrapper (n function)
4695 (with-current-buffer gnus-article-buffer
4696 (when (> n (length gnus-article-mime-handle-alist))
4697 (error "No such part"))
4698 (gnus-article-goto-part n)
4699 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4700 (funcall function handle))))
4702 (defun gnus-article-pipe-part (n)
4703 "Pipe MIME part N, which is the numerical prefix."
4705 (gnus-article-part-wrapper n 'mm-pipe-part))
4707 (defun gnus-article-save-part (n)
4708 "Save MIME part N, which is the numerical prefix."
4710 (gnus-article-part-wrapper n 'mm-save-part))
4712 (defun gnus-article-interactively-view-part (n)
4713 "View MIME part N interactively, which is the numerical prefix."
4715 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4717 (defun gnus-article-copy-part (n)
4718 "Copy MIME part N, which is the numerical prefix."
4720 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4722 (defun gnus-article-view-part-as-charset (n)
4723 "View MIME part N using a specified charset.
4724 N is the numerical prefix."
4726 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4728 (defun gnus-article-view-part-externally (n)
4729 "View MIME part N externally, which is the numerical prefix."
4731 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4733 (defun gnus-article-inline-part (n)
4734 "Inline MIME part N, which is the numerical prefix."
4736 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4738 (defun gnus-article-mime-match-handle-first (condition)
4740 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4741 (while (setq ihandle (pop alist))
4743 ((functionp condition)
4744 (funcall condition (cdr ihandle)))
4745 ((eq condition 'undisplayed)
4746 (not (or (mm-handle-undisplayer (cdr ihandle))
4747 (equal (mm-handle-media-type (cdr ihandle))
4748 "multipart/alternative"))))
4749 ((eq condition 'undisplayed-alternative)
4750 (not (mm-handle-undisplayer (cdr ihandle))))
4752 (gnus-article-goto-part (car ihandle))
4753 (or (not n) (< (car ihandle) n)))
4754 (setq n (car ihandle))))
4758 (defun gnus-article-view-part (&optional n)
4759 "View MIME part N, which is the numerical prefix."
4761 (with-current-buffer gnus-article-buffer
4762 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4763 gnus-article-mime-match-handle-function)))
4764 (when (> n (length gnus-article-mime-handle-alist))
4765 (error "No such part"))
4766 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4767 (when (gnus-article-goto-part n)
4768 (if (equal (car handle) "multipart/alternative")
4769 (gnus-article-press-button)
4770 (when (eq (gnus-mm-display-part handle) 'internal)
4771 (gnus-set-window-start)))))))
4773 (defsubst gnus-article-mime-total-parts ()
4774 (if (bufferp (car gnus-article-mime-handles))
4776 (1- (length gnus-article-mime-handles))))
4778 (defun gnus-mm-display-part (handle)
4779 "Display HANDLE and fix MIME button."
4780 (let ((id (get-text-property (point) 'gnus-part))
4785 (let ((window (selected-window))
4786 (mail-parse-charset gnus-newsgroup-charset)
4787 (mail-parse-ignored-charsets
4788 (if (gnus-buffer-live-p gnus-summary-buffer)
4789 (with-current-buffer gnus-summary-buffer
4790 gnus-newsgroup-ignored-charsets)
4794 (let ((win (gnus-get-buffer-window (current-buffer) t))
4797 (select-window win))
4800 (if (mm-handle-displayed-p handle)
4801 ;; This will remove the part.
4802 (mm-display-part handle)
4804 (narrow-to-region (point)
4805 (if (eobp) (point) (1+ (point))))
4806 (mm-display-part handle)
4807 ;; We narrow to the part itself and
4808 ;; then call the treatment functions.
4809 (goto-char (point-min))
4811 (narrow-to-region (point) (point-max))
4814 (gnus-article-mime-total-parts)
4815 (mm-handle-media-type handle)))))
4816 (if (window-live-p window)
4817 (select-window window)))))
4820 (gnus-insert-mime-button
4821 handle id (list (mm-handle-displayed-p handle)))
4822 (goto-char point))))
4824 (defun gnus-article-goto-part (n)
4825 "Go to MIME part N."
4826 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4828 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4829 (let ((gnus-tmp-name
4830 (or (mail-content-type-get (mm-handle-type handle) 'name)
4831 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4832 (mail-content-type-get (mm-handle-type handle) 'url)
4834 (gnus-tmp-type (mm-handle-media-type handle))
4835 (gnus-tmp-description
4836 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4839 (if (if displayed (car displayed)
4840 (mm-handle-displayed-p handle))
4842 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4844 gnus-tmp-type-long b e)
4845 (when (string-match ".*/" gnus-tmp-name)
4846 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4847 (setq gnus-tmp-type-long (concat gnus-tmp-type
4848 (and (not (equal gnus-tmp-name ""))
4849 (concat "; " gnus-tmp-name))))
4850 (unless (equal gnus-tmp-description "")
4851 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4856 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4857 `(keymap ,gnus-mime-button-map
4858 gnus-callback gnus-mm-display-part
4859 gnus-part ,gnus-tmp-id
4860 article-type annotation
4863 ;; Exclude a newline.
4866 (widget-convert-button
4869 :action 'gnus-widget-press-button
4870 :button-keymap gnus-mime-button-map
4872 (lambda (widget/window &optional overlay pos)
4873 ;; Needed to properly clear the message due to a bug in
4874 ;; wid-edit (XEmacs only).
4875 (if (boundp 'help-echo-owns-message)
4876 (setq help-echo-owns-message t))
4878 "%S: %s the MIME part; %S: more options"
4879 (aref gnus-mouse-2 0)
4880 ;; XEmacs will get a single widget arg; Emacs 21 will get
4881 ;; window, overlay, position.
4882 (if (mm-handle-displayed-p
4884 (with-current-buffer (gnus-overlay-buffer overlay)
4885 (widget-get (widget-at (gnus-overlay-start overlay))
4887 (widget-get widget/window :mime-handle)))
4889 (aref gnus-down-mouse-3 0))))))
4891 (defun gnus-widget-press-button (elems el)
4892 (goto-char (widget-get elems :from))
4893 (gnus-article-press-button))
4895 (defvar gnus-displaying-mime nil)
4897 (defun gnus-display-mime (&optional ihandles)
4898 "Display the MIME parts."
4900 (save-selected-window
4901 (let ((window (get-buffer-window gnus-article-buffer))
4904 (select-window window)
4905 ;; We have to do this since selecting the window
4906 ;; may change the point. So we set the window point.
4907 (set-window-point window point)))
4908 (let* ((handles (or ihandles
4909 (mm-dissect-buffer nil gnus-article-loose-mime)
4910 (and gnus-article-emulate-mime
4912 buffer-read-only handle name type b e display)
4913 (when (and (not ihandles)
4914 (not gnus-displaying-mime))
4915 ;; Top-level call; we clean up.
4916 (when gnus-article-mime-handles
4917 (mm-destroy-parts gnus-article-mime-handles)
4918 (setq gnus-article-mime-handle-alist nil));; A trick.
4919 (setq gnus-article-mime-handles handles)
4920 ;; We allow users to glean info from the handles.
4921 (when gnus-article-mime-part-function
4922 (gnus-mime-part-function handles)))
4924 (or (not (stringp (car handles)))
4927 (when (and (not ihandles)
4928 (not gnus-displaying-mime))
4929 ;; Clean up for mime parts.
4931 (delete-region (point) (point-max)))
4932 (let ((gnus-displaying-mime t))
4933 (gnus-mime-display-part handles)))
4936 (narrow-to-region (point) (point-max))
4937 (gnus-treat-article nil 1 1)
4940 ;; Highlight the headers.
4944 (narrow-to-region (point-min) (point))
4945 (gnus-treat-article 'head))))))))
4947 (defcustom gnus-mime-display-multipart-as-mixed nil
4948 "Display \"multipart\" parts as \"multipart/mixed\".
4950 If t, it overrides nil values of
4951 `gnus-mime-display-multipart-alternative-as-mixed' and
4952 `gnus-mime-display-multipart-related-as-mixed'."
4953 :group 'gnus-article-mime
4956 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
4957 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
4958 :group 'gnus-article-mime
4961 (defcustom gnus-mime-display-multipart-related-as-mixed nil
4962 "Display \"multipart/related\" parts as \"multipart/mixed\".
4964 If displaying \"text/html\" is discouraged \(see
4965 `mm-discouraged-alternatives'\) images or other material inside a
4966 \"multipart/related\" part might be overlooked when this variable is nil."
4967 :group 'gnus-article-mime
4970 (defun gnus-mime-display-part (handle)
4973 ((not (stringp (car handle)))
4974 (gnus-mime-display-single handle))
4975 ;; User-defined multipart
4976 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4977 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4979 ;; multipart/alternative
4980 ((and (equal (car handle) "multipart/alternative")
4981 (not (or gnus-mime-display-multipart-as-mixed
4982 gnus-mime-display-multipart-alternative-as-mixed)))
4983 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4984 (push (cons id handle) gnus-article-mime-handle-alist)
4985 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4986 ;; multipart/related
4987 ((and (equal (car handle) "multipart/related")
4988 (not (or gnus-mime-display-multipart-as-mixed
4989 gnus-mime-display-multipart-related-as-mixed)))
4990 ;;;!!!We should find the start part, but we just default
4991 ;;;!!!to the first part.
4992 ;;(gnus-mime-display-part (cadr handle))
4993 ;;;!!! Most multipart/related is an HTML message plus images.
4994 ;;;!!! Unfortunately we are unable to let W3 display those
4995 ;;;!!! included images, so we just display it as a mixed multipart.
4996 ;;(gnus-mime-display-mixed (cdr handle))
4997 ;;;!!! No, w3 can display everything just fine.
4998 (gnus-mime-display-part (cadr handle)))
4999 ((equal (car handle) "multipart/signed")
5000 (gnus-add-wash-type 'signed)
5001 (gnus-mime-display-security handle))
5002 ((equal (car handle) "multipart/encrypted")
5003 (gnus-add-wash-type 'encrypted)
5004 (gnus-mime-display-security handle))
5005 ;; Other multiparts are handled like multipart/mixed.
5007 (gnus-mime-display-mixed (cdr handle)))))
5009 (defun gnus-mime-part-function (handles)
5010 (if (stringp (car handles))
5011 (mapcar 'gnus-mime-part-function (cdr handles))
5012 (funcall gnus-article-mime-part-function handles)))
5014 (defun gnus-mime-display-mixed (handles)
5015 (mapcar 'gnus-mime-display-part handles))
5017 (defun gnus-mime-display-single (handle)
5018 (let ((type (mm-handle-media-type handle))
5019 (ignored gnus-ignored-mime-types)
5026 (when (string-match (pop ignored) type)
5027 (throw 'ignored nil)))
5028 (if (and (setq not-attachment
5029 (and (not (mm-inline-override-p handle))
5030 (or (not (mm-handle-disposition handle))
5031 (equal (car (mm-handle-disposition handle))
5033 (mm-attachment-override-p handle))))
5034 (mm-automatic-display-p handle)
5036 (mm-inlinable-p handle)
5037 (mm-inlined-p handle))
5038 (mm-automatic-external-display-p type)))
5040 (when (equal (mm-handle-media-supertype handle) "text")
5042 (let ((id (1+ (length gnus-article-mime-handle-alist)))
5044 (push (cons id handle) gnus-article-mime-handle-alist)
5045 (when (or (not display)
5046 (not (gnus-unbuttonized-mime-type-p type)))
5047 ;(gnus-article-insert-newline)
5048 (gnus-insert-mime-button
5049 handle id (list (or display (and not-attachment text))))
5050 (gnus-article-insert-newline)
5051 ;(gnus-article-insert-newline)
5052 ;; Remember modify the number of forward lines.
5060 (let ((mail-parse-charset gnus-newsgroup-charset)
5061 (mail-parse-ignored-charsets
5062 (save-excursion (condition-case ()
5063 (set-buffer gnus-summary-buffer)
5065 gnus-newsgroup-ignored-charsets)))
5066 (mm-display-part handle t))
5067 (goto-char (point-max)))
5068 ((and text not-attachment)
5072 (gnus-article-insert-newline)
5073 (mm-insert-inline handle (mm-get-part handle))
5074 (goto-char (point-max))))
5078 (narrow-to-region beg (point))
5081 (gnus-article-mime-total-parts)
5082 (mm-handle-media-type handle)))))))))
5084 (defun gnus-unbuttonized-mime-type-p (type)
5085 "Say whether TYPE is to be unbuttonized."
5086 (unless gnus-inhibit-mime-unbuttonizing
5088 (let ((types gnus-unbuttonized-mime-types))
5090 (when (string-match (pop types) type)
5091 (throw 'found t)))))
5093 (let ((types gnus-buttonized-mime-types))
5095 (when (string-match (pop types) type)
5096 (throw 'found t)))))))))
5098 (defun gnus-article-insert-newline ()
5099 "Insert a newline, but mark it as undeletable."
5100 (gnus-put-text-property
5101 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
5103 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
5104 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
5107 handle buffer-read-only from props begend not-pref)
5108 (save-window-excursion
5111 (narrow-to-region (car ibegend)
5114 (goto-char (car ibegend))
5117 (delete-region (point-min) (point-max))
5118 (mm-remove-parts handles))
5119 (setq begend (list (point-marker)))
5121 (unless (setq not-pref (cadr (member preferred ihandles)))
5122 (setq not-pref (car ihandles)))
5125 (not (gnus-unbuttonized-mime-type-p
5126 "multipart/alternative")))
5127 (gnus-add-text-properties
5130 (insert (format "%d. " id))
5134 (unless ,(not ibegend)
5135 (setq gnus-article-mime-handle-alist
5136 ',gnus-article-mime-handle-alist))
5137 (gnus-mime-display-alternative
5138 ',ihandles ',not-pref ',begend ,id))
5139 keymap ,gnus-mime-button-map
5140 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5141 face ,gnus-article-button-face
5144 (widget-convert-button 'link from (point)
5145 :action 'gnus-widget-press-button
5146 :button-keymap gnus-widget-button-keymap)
5148 (while (setq handle (pop handles))
5149 (gnus-add-text-properties
5152 (insert (format "(%c) %-18s"
5153 (if (equal handle preferred) ?* ? )
5154 (mm-handle-media-type handle)))
5158 (unless ,(not ibegend)
5159 (setq gnus-article-mime-handle-alist
5160 ',gnus-article-mime-handle-alist))
5161 (gnus-mime-display-alternative
5162 ',ihandles ',handle ',begend ,id))
5163 keymap ,gnus-mime-button-map
5164 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5165 face ,gnus-article-button-face
5168 (widget-convert-button 'link from (point)
5169 :action 'gnus-widget-press-button
5170 :button-keymap gnus-widget-button-keymap)
5174 (if (stringp (car preferred))
5175 (gnus-display-mime preferred)
5176 (let ((mail-parse-charset gnus-newsgroup-charset)
5177 (mail-parse-ignored-charsets
5178 (with-current-buffer gnus-summary-buffer
5179 gnus-newsgroup-ignored-charsets)))
5180 (mm-display-part preferred)
5184 (narrow-to-region (car begend) (point-max))
5186 nil (length gnus-article-mime-handle-alist)
5187 (gnus-article-mime-total-parts)
5188 (mm-handle-media-type handle))))))
5189 (goto-char (point-max))
5190 (setcdr begend (point-marker)))))
5192 (goto-char point))))
5194 (defconst gnus-article-wash-status-strings
5195 (let ((alist '((cite "c" "Possible hidden citation text"
5196 " " "All citation text visible")
5197 (headers "h" "Hidden headers"
5198 " " "All headers visible.")
5199 (pgp "p" "Encrypted or signed message status hidden"
5200 " " "No hidden encryption nor digital signature status")
5201 (signature "s" "Signature has been hidden"
5202 " " "Signature is visible")
5203 (overstrike "o" "Overstrike (^H) characters applied"
5204 " " "No overstrike characters applied")
5205 (gnus-show-mime "m" "Mime processing is activated"
5206 " " "Mime processing is not activated")
5207 (emphasis "e" "/*_Emphasis_*/ characters applied"
5208 " " "No /*_emphasis_*/ characters applied")))
5210 (dolist (entry alist result)
5211 (let ((key (nth 0 entry))
5212 (on (copy-sequence (nth 1 entry)))
5213 (on-help (nth 2 entry))
5214 (off (copy-sequence (nth 3 entry)))
5215 (off-help (nth 4 entry)))
5216 (put-text-property 0 1 'help-echo on-help on)
5217 (put-text-property 0 1 'help-echo off-help off)
5218 (push (list key on off) result))))
5219 "Alist of strings describing wash status in the mode line.
5220 Each entry has the form (KEY ON OF), where the KEY is a symbol
5221 representing the particular washing function, ON is the string to use
5222 in the article mode line when the washing function is active, and OFF
5223 is the string to use when it is inactive.")
5225 (defun gnus-article-wash-status-entry (key value)
5226 (let ((entry (assoc key gnus-article-wash-status-strings)))
5227 (if value (nth 1 entry) (nth 2 entry))))
5229 (defun gnus-article-wash-status ()
5230 "Return a string which display status of article washing."
5231 (with-current-buffer gnus-article-buffer
5232 (let ((cite (memq 'cite gnus-article-wash-types))
5233 (headers (memq 'headers gnus-article-wash-types))
5234 (boring (memq 'boring-headers gnus-article-wash-types))
5235 (pgp (memq 'pgp gnus-article-wash-types))
5236 (pem (memq 'pem gnus-article-wash-types))
5237 (signed (memq 'signed gnus-article-wash-types))
5238 (encrypted (memq 'encrypted gnus-article-wash-types))
5239 (signature (memq 'signature gnus-article-wash-types))
5240 (overstrike (memq 'overstrike gnus-article-wash-types))
5241 (emphasis (memq 'emphasis gnus-article-wash-types)))
5243 (gnus-article-wash-status-entry 'cite cite)
5244 (gnus-article-wash-status-entry 'headers (or headers boring))
5245 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5246 (gnus-article-wash-status-entry 'signature signature)
5247 (gnus-article-wash-status-entry 'overstrike overstrike)
5248 (gnus-article-wash-status-entry 'gnus-show-mime gnus-show-mime)
5249 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5251 (defun gnus-add-wash-type (type)
5252 "Add a washing of TYPE to the current status."
5253 (add-to-list 'gnus-article-wash-types type))
5255 (defun gnus-delete-wash-type (type)
5256 "Add a washing of TYPE to the current status."
5257 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5259 (defun gnus-add-image (category image)
5260 "Add IMAGE of CATEGORY to the list of displayed images."
5261 (let ((entry (assq category gnus-article-image-alist)))
5263 (setq entry (list category))
5264 (push entry gnus-article-image-alist))
5265 (nconc entry (list image))))
5267 (defun gnus-delete-images (category)
5268 "Delete all images in CATEGORY."
5269 (let ((entry (assq category gnus-article-image-alist)))
5270 (dolist (image (cdr entry))
5271 (gnus-remove-image image category))
5272 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5273 (gnus-delete-wash-type category)))
5275 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5277 (defun gnus-article-maybe-hide-headers ()
5278 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5279 Provided for backwards compatibility."
5280 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5281 (not (with-current-buffer gnus-summary-buffer
5282 gnus-have-all-headers)))
5283 (not gnus-inhibit-hiding))
5284 (gnus-article-hide-headers)))
5288 (defun gnus-output-to-file (file-name)
5289 "Append the current article to a file named FILE-NAME."
5290 (let ((artbuf (current-buffer)))
5292 (insert-buffer-substring artbuf)
5293 ;; Append newline at end of the buffer as separator, and then
5295 (goto-char (point-max))
5297 (let ((file-name-coding-system nnmail-pathname-coding-system))
5298 (write-region-as-binary (point-min) (point-max) file-name 'append))
5301 (defun gnus-narrow-to-page (&optional arg)
5302 "Narrow the article buffer to a page.
5303 If given a numerical ARG, move forward ARG pages."
5305 (setq arg (if arg (prefix-numeric-value arg) 0))
5307 (set-buffer gnus-article-buffer)
5308 (goto-char (point-min))
5310 ;; Remove any old next/prev buttons.
5311 (when (gnus-visual-p 'page-marker)
5312 (let ((buffer-read-only nil))
5313 (gnus-remove-text-with-property 'gnus-prev)
5314 (gnus-remove-text-with-property 'gnus-next)))
5317 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5319 (re-search-forward page-delimiter nil 'move arg)))
5320 (goto-char (match-end 0))
5322 (goto-char (point-min))
5323 (setq gnus-page-broken
5324 (and (re-search-forward page-delimiter nil t) t))))
5325 (when gnus-page-broken
5328 (if (re-search-forward page-delimiter nil 'move)
5331 (when (and (gnus-visual-p 'page-marker)
5332 (not (= (point-min) 1)))
5334 (goto-char (point-min))
5335 (gnus-insert-prev-page-button)))
5336 (when (and (gnus-visual-p 'page-marker)
5337 (< (+ (point-max) 2) (buffer-size)))
5339 (goto-char (point-max))
5340 (gnus-insert-next-page-button))))))
5342 ;; Article mode commands
5344 (defun gnus-article-goto-next-page ()
5345 "Show the next page of the article."
5347 (when (gnus-article-next-page)
5348 (goto-char (point-min))
5349 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5352 (defun gnus-article-goto-prev-page ()
5353 "Show the previous page of the article."
5356 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5357 (gnus-article-prev-page nil)))
5359 ;; This is cleaner but currently breaks `gnus-pick-mode':
5361 ;; (defun gnus-article-goto-next-page ()
5362 ;; "Show the next page of the article."
5364 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5365 ;; (gnus-summary-next-page)))
5367 ;; (defun gnus-article-goto-prev-page ()
5368 ;; "Show the next page of the article."
5370 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5371 ;; (gnus-summary-prev-page)))
5373 (defun gnus-article-next-page (&optional lines)
5374 "Show the next page of the current article.
5375 If end of article, return non-nil. Otherwise return nil.
5376 Argument LINES specifies lines to be scrolled up."
5378 (move-to-window-line -1)
5381 (and (pos-visible-in-window-p) ;Not continuation line.
5382 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5383 ;; Nothing in this page.
5384 (if (or (not gnus-page-broken)
5388 (eobp)))) ;Real end-of-buffer?
5390 (when gnus-article-over-scroll
5391 (gnus-article-next-page-1 lines))
5393 (gnus-narrow-to-page 1) ;Go to next page.
5395 ;; More in this page.
5396 (gnus-article-next-page-1 lines)
5399 (defun gnus-article-next-page-1 (lines)
5400 (let ((scroll-in-place nil))
5404 ;; Long lines may cause an end-of-buffer error.
5405 (goto-char (point-max)))))
5406 (move-to-window-line 0))
5408 (defun gnus-article-prev-page (&optional lines)
5409 "Show previous page of current article.
5410 Argument LINES specifies lines to be scrolled down."
5412 (move-to-window-line 0)
5413 (if (and gnus-page-broken
5415 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5417 (gnus-narrow-to-page -1) ;Go to previous page.
5418 (goto-char (point-max))
5420 (let ((scroll-in-place nil))
5424 (beginning-of-buffer
5425 (goto-char (point-min))))
5426 (move-to-window-line 0)))))
5428 (defun gnus-article-only-boring-p ()
5429 "Decide whether there is only boring text remaining in the article.
5430 Something \"interesting\" is a word of at least two letters that does
5431 not have a face in `gnus-article-boring-faces'."
5432 (when (and gnus-article-skip-boring
5433 (boundp 'gnus-article-boring-faces)
5434 (symbol-value 'gnus-article-boring-faces))
5437 (while (re-search-forward "\\b\\w\\w" nil t)
5439 (when (not (gnus-intersection
5440 (gnus-faces-at (point))
5441 (symbol-value 'gnus-article-boring-faces)))
5442 (throw 'only-boring nil)))
5443 (throw 'only-boring t)))))
5445 (defun gnus-article-refer-article ()
5446 "Read article specified by message-id around point."
5449 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
5450 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
5451 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
5452 (let ((msg-id (concat "<" (match-string 0) ">")))
5453 (set-buffer gnus-summary-buffer)
5454 (gnus-summary-refer-article msg-id))
5455 (error "No references around point"))))
5457 (defun gnus-article-show-summary ()
5458 "Reconfigure windows to show summary buffer."
5460 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5461 (error "There is no summary buffer for this article buffer")
5462 (gnus-article-set-globals)
5463 (gnus-configure-windows 'article)
5464 (gnus-summary-goto-subject gnus-current-article)
5465 (gnus-summary-position-point)))
5467 (defun gnus-article-describe-briefly ()
5468 "Describe article mode commands briefly."
5470 (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")))
5472 (defun gnus-article-summary-command ()
5473 "Execute the last keystroke in the summary buffer."
5475 (let ((obuf (current-buffer))
5476 (owin (current-window-configuration))
5478 (switch-to-buffer gnus-article-current-summary 'norecord)
5479 (setq func (lookup-key (current-local-map) (this-command-keys)))
5480 (call-interactively func)
5482 (set-window-configuration owin)
5483 (set-window-point (get-buffer-window (current-buffer)) (point))))
5485 (defun gnus-article-summary-command-nosave ()
5486 "Execute the last keystroke in the summary buffer."
5489 (pop-to-buffer gnus-article-current-summary 'norecord)
5490 (setq func (lookup-key (current-local-map) (this-command-keys)))
5491 (call-interactively func)))
5493 (defun gnus-article-check-buffer ()
5494 "Beep if not in an article buffer."
5495 (unless (eq (get-buffer gnus-article-buffer) (current-buffer))
5496 (error "Command invoked outside of a Gnus article buffer")))
5498 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5499 "Read a summary buffer key sequence and execute it from the article buffer."
5501 (gnus-article-check-buffer)
5503 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5504 "Zc" "ZC" "ZE" "ZJ" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5505 "=" "^" "\M-^" "|"))
5511 '("n" "Gn" "p" "Gp"))
5514 (set-buffer gnus-article-current-summary)
5515 (let (gnus-pick-mode)
5516 (push (or key last-command-event) unread-command-events)
5517 (setq keys (static-if (featurep 'xemacs)
5518 (events-to-keys (read-key-sequence nil))
5519 (read-key-sequence nil)))))
5522 (if (or (member keys nosaves)
5523 (member keys nosave-but-article)
5524 (member keys nosave-in-article))
5526 (save-window-excursion
5527 (pop-to-buffer gnus-article-current-summary 'norecord)
5528 ;; We disable the pick minor mode commands.
5529 (let (gnus-pick-mode)
5530 (setq func (lookup-key (current-local-map) keys))))
5534 (unless (member keys nosave-in-article)
5535 (set-buffer gnus-article-current-summary))
5536 (call-interactively func)
5537 (setq new-sum-point (point)))
5538 (when (member keys nosave-but-article)
5539 (pop-to-buffer gnus-article-buffer 'norecord)))
5540 ;; These commands should restore window configuration.
5541 (let ((obuf (current-buffer))
5542 (owin (current-window-configuration))
5544 (summary gnus-article-current-summary)
5545 func in-buffer selected)
5546 (if not-restore-window
5547 (pop-to-buffer summary 'norecord)
5548 (switch-to-buffer summary 'norecord))
5549 (setq in-buffer (current-buffer))
5550 ;; We disable the pick minor mode commands.
5551 (if (and (setq func (let (gnus-pick-mode)
5552 (lookup-key (current-local-map) keys)))
5555 (call-interactively func)
5556 (setq new-sum-point (point))
5557 (when (eq in-buffer (current-buffer))
5558 (setq selected (gnus-summary-select-article))
5560 (unless not-restore-window
5561 (set-window-configuration owin))
5562 (when (eq selected 'old)
5564 (set-window-start (get-buffer-window (current-buffer))
5566 (set-window-point (get-buffer-window (current-buffer))
5568 (let ((win (get-buffer-window gnus-article-current-summary)))
5570 (set-window-point win new-sum-point)))) )
5571 (switch-to-buffer gnus-article-buffer)
5574 (defun gnus-article-describe-key (key)
5575 "Display documentation of the function invoked by KEY. KEY is a string."
5576 (interactive "kDescribe key: ")
5577 (gnus-article-check-buffer)
5578 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5580 (set-buffer gnus-article-current-summary)
5581 (let (gnus-pick-mode)
5582 (if (featurep 'xemacs)
5584 (push (elt key 0) unread-command-events)
5585 (setq key (events-to-keys
5586 (read-key-sequence "Describe key: "))))
5587 (setq unread-command-events
5589 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5591 (setq key (read-key-sequence "Describe key: "))))
5593 (describe-key key)))
5595 (defun gnus-article-describe-key-briefly (key &optional insert)
5596 "Display documentation of the function invoked by KEY. KEY is a string."
5597 (interactive "kDescribe key: \nP")
5598 (gnus-article-check-buffer)
5599 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5601 (set-buffer gnus-article-current-summary)
5602 (let (gnus-pick-mode)
5603 (if (featurep 'xemacs)
5605 (push (elt key 0) unread-command-events)
5606 (setq key (events-to-keys
5607 (read-key-sequence "Describe key: "))))
5608 (setq unread-command-events
5610 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5612 (setq key (read-key-sequence "Describe key: "))))
5613 (describe-key-briefly key insert))
5614 (describe-key-briefly key insert)))
5616 (defun gnus-article-reply-with-original (&optional wide)
5617 "Start composing a reply mail to the current message.
5618 The text in the region will be yanked. If the region isn't active,
5619 the entire article will be yanked."
5621 (let ((article (cdr gnus-article-current))
5623 (if (not (gnus-mark-active-p))
5624 (with-current-buffer gnus-summary-buffer
5625 (gnus-summary-reply (list (list article)) wide))
5626 (setq contents (buffer-substring (point) (mark t)))
5627 ;; Deactivate active regions.
5628 (when (and (boundp 'transient-mark-mode)
5629 transient-mark-mode)
5630 (setq mark-active nil))
5631 (with-current-buffer gnus-summary-buffer
5633 (list (list article contents)) wide)))))
5635 (defun gnus-article-followup-with-original ()
5636 "Compose a followup to the current article.
5637 The text in the region will be yanked. If the region isn't active,
5638 the entire article will be yanked."
5640 (let ((article (cdr gnus-article-current))
5642 (if (not (gnus-mark-active-p))
5643 (with-current-buffer gnus-summary-buffer
5644 (gnus-summary-followup (list (list article))))
5645 (setq contents (buffer-substring (point) (mark t)))
5646 ;; Deactivate active regions.
5647 (when (and (boundp 'transient-mark-mode)
5648 transient-mark-mode)
5649 (setq mark-active nil))
5650 (with-current-buffer gnus-summary-buffer
5651 (gnus-summary-followup
5652 (list (list article contents)))))))
5654 (defun gnus-article-hide (&optional arg force)
5655 "Hide all the gruft in the current article.
5656 This means that signatures, cited text and (some) headers will be
5658 If given a prefix, show the hidden text instead."
5659 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5660 (gnus-article-hide-headers arg)
5661 (gnus-article-hide-list-identifiers arg)
5662 (gnus-article-hide-citation-maybe arg force)
5663 (gnus-article-hide-signature arg))
5665 (defun gnus-article-maybe-highlight ()
5666 "Do some article highlighting if article highlighting is requested."
5667 (when (gnus-visual-p 'article-highlight 'highlight)
5668 (gnus-article-highlight-some)))
5670 (defun gnus-check-group-server ()
5671 ;; Make sure the connection to the server is alive.
5672 (unless (gnus-server-opened
5673 (gnus-find-method-for-group gnus-newsgroup-name))
5674 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5675 (gnus-request-group gnus-newsgroup-name t)))
5678 (autoload 'nneething-get-file-name "nneething"))
5680 (defun gnus-request-article-this-buffer (article group)
5681 "Get an article and insert it into this buffer."
5682 (let (do-update-line sparse-header)
5686 (gnus-kill-all-overlays)
5687 (setq group (or group gnus-newsgroup-name))
5689 ;; Using `gnus-request-article' directly will insert the article into
5690 ;; `nntp-server-buffer' - so we'll save some time by not having to
5691 ;; copy it from the server buffer into the article buffer.
5693 ;; We only request an article by message-id when we do not have the
5694 ;; headers for it, so we'll have to get those.
5695 (when (stringp article)
5696 (gnus-read-header article))
5698 ;; If the article number is negative, that means that this article
5699 ;; doesn't belong in this newsgroup (possibly), so we find its
5700 ;; message-id and request it by id instead of number.
5701 (when (and (numberp article)
5703 (get-buffer gnus-summary-buffer)
5704 (gnus-buffer-exists-p gnus-summary-buffer))
5706 (set-buffer gnus-summary-buffer)
5707 (let ((header (gnus-summary-article-header article)))
5710 ((memq article gnus-newsgroup-sparse)
5711 ;; This is a sparse gap article.
5712 (setq do-update-line article)
5713 (setq article (mail-header-id header))
5714 (setq sparse-header (gnus-read-header article))
5715 (setq gnus-newsgroup-sparse
5716 (delq article gnus-newsgroup-sparse)))
5718 ;; It's a real article.
5719 (setq article (mail-header-id header)))
5721 ;; It is an extracted pseudo-article.
5722 (setq article 'pseudo)
5723 (gnus-request-pseudo-article header))))
5725 (let ((method (gnus-find-method-for-group
5726 gnus-newsgroup-name)))
5727 (when (and (eq (car method) 'nneething)
5729 (let ((dir (nneething-get-file-name
5730 (mail-header-id header))))
5731 (when (and (stringp dir)
5732 (file-directory-p dir))
5733 (setq article 'nneething)
5734 (gnus-group-enter-directory dir))))))))
5737 ;; Refuse to select canceled articles.
5738 ((and (numberp article)
5740 (get-buffer gnus-summary-buffer)
5741 (gnus-buffer-exists-p gnus-summary-buffer)
5742 (eq (cdr (with-current-buffer gnus-summary-buffer
5743 (assq article gnus-newsgroup-reads)))
5744 gnus-canceled-mark))
5746 ;; We first check `gnus-original-article-buffer'.
5747 ((and (get-buffer gnus-original-article-buffer)
5749 (with-current-buffer gnus-original-article-buffer
5750 (and (equal (car gnus-original-article) group)
5751 (eq (cdr gnus-original-article) article))))
5752 (insert-buffer-substring gnus-original-article-buffer)
5754 ;; Check the backlog.
5755 ((and gnus-keep-backlog
5756 (gnus-backlog-request-article group article (current-buffer)))
5758 ;; Check asynchronous pre-fetch.
5759 ((gnus-async-request-fetched-article group article (current-buffer))
5760 (gnus-async-prefetch-next group article gnus-summary-buffer)
5761 (when (and (numberp article) gnus-keep-backlog)
5762 (gnus-backlog-enter-article group article (current-buffer)))
5765 ((and gnus-use-cache
5767 (gnus-cache-request-article article group))
5769 ;; Check the agent cache.
5770 ((gnus-agent-request-article article group)
5772 ;; Get the article and put into the article buffer.
5773 ((or (stringp article)
5775 (let ((gnus-override-method gnus-override-method)
5776 (methods (and (stringp article)
5777 gnus-refer-article-method))
5778 (backend (car (gnus-find-method-for-group
5779 gnus-newsgroup-name)))
5781 (buffer-read-only nil))
5782 (if (or (not (listp methods))
5783 (and (symbolp (car methods))
5784 (assq (car methods) nnoo-definition-alist)))
5785 (setq methods (list methods)))
5786 (when (and (null gnus-override-method)
5788 (setq gnus-override-method (pop methods)))
5790 (when (eq gnus-override-method 'current)
5791 (setq gnus-override-method
5792 (with-current-buffer gnus-summary-buffer
5793 gnus-current-select-method)))
5795 (gnus-kill-all-overlays)
5796 (let ((gnus-newsgroup-name group))
5797 (gnus-check-group-server))
5799 ((gnus-request-article article group (current-buffer))
5800 (when (numberp article)
5801 (gnus-async-prefetch-next group article
5802 gnus-summary-buffer)
5803 (when gnus-keep-backlog
5804 (gnus-backlog-enter-article
5805 group article (current-buffer))))
5806 (setq result 'article))
5808 (setq gnus-override-method (pop methods)))
5809 ((not (string-match "^400 "
5810 (nnheader-get-report backend)))
5811 ;; If we get 400 server disconnect, reconnect and
5812 ;; retry; otherwise, assume the article has expired.
5813 (setq result 'done))))
5814 (and (eq result 'article) 'article)))
5818 ;; Associate this article with the current summary buffer.
5819 (setq gnus-article-current-summary gnus-summary-buffer)
5821 ;; Take the article from the original article buffer
5822 ;; and place it in the buffer it's supposed to be in.
5823 (when (and (get-buffer gnus-article-buffer)
5824 (equal (buffer-name (current-buffer))
5825 (buffer-name (get-buffer gnus-article-buffer))))
5827 (if (get-buffer gnus-original-article-buffer)
5828 (set-buffer gnus-original-article-buffer)
5829 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5830 (buffer-disable-undo)
5831 (setq major-mode 'gnus-original-article-mode)
5832 (setq buffer-read-only t))
5833 (let (buffer-read-only)
5835 (insert-buffer-substring gnus-article-buffer))
5836 (setq gnus-original-article (cons group article)))
5839 (run-hooks 'gnus-article-decode-hook)
5840 ;; Mark article as decoded or not.
5841 (setq gnus-article-decoded-p gnus-article-decode-hook))
5843 ;; Update sparse articles.
5844 (when (and do-update-line
5845 (or (numberp article)
5847 (let ((buf (current-buffer)))
5848 (set-buffer gnus-summary-buffer)
5849 (gnus-summary-update-article do-update-line sparse-header)
5850 (gnus-summary-goto-subject do-update-line nil t)
5851 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5853 (set-buffer buf))))))
5859 (defcustom gnus-article-edit-mode-hook nil
5860 "Hook run in article edit mode buffers."
5861 :group 'gnus-article-various
5864 (defcustom gnus-article-edit-article-setup-function
5865 'gnus-article-mime-edit-article-setup
5866 "Function called to setup an editing article buffer."
5867 :group 'gnus-article-various
5870 (defvar gnus-article-edit-done-function nil)
5872 (defvar gnus-article-edit-mode-map nil)
5873 (defvar gnus-article-edit-mode nil)
5875 ;; Should we be using derived.el for this?
5876 (unless gnus-article-edit-mode-map
5877 (setq gnus-article-edit-mode-map (make-keymap))
5878 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5880 (gnus-define-keys gnus-article-edit-mode-map
5881 "\C-c?" describe-mode
5882 "\C-c\C-c" gnus-article-edit-done
5883 "\C-c\C-k" gnus-article-edit-exit
5884 "\C-c\C-f\C-t" message-goto-to
5885 "\C-c\C-f\C-o" message-goto-from
5886 "\C-c\C-f\C-b" message-goto-bcc
5887 ;;"\C-c\C-f\C-w" message-goto-fcc
5888 "\C-c\C-f\C-c" message-goto-cc
5889 "\C-c\C-f\C-s" message-goto-subject
5890 "\C-c\C-f\C-r" message-goto-reply-to
5891 "\C-c\C-f\C-n" message-goto-newsgroups
5892 "\C-c\C-f\C-d" message-goto-distribution
5893 "\C-c\C-f\C-f" message-goto-followup-to
5894 "\C-c\C-f\C-m" message-goto-mail-followup-to
5895 "\C-c\C-f\C-k" message-goto-keywords
5896 "\C-c\C-f\C-u" message-goto-summary
5897 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5898 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5899 "\C-c\C-b" message-goto-body
5900 "\C-c\C-i" message-goto-signature
5902 "\C-c\C-t" message-insert-to
5903 "\C-c\C-n" message-insert-newsgroups
5904 "\C-c\C-o" message-sort-headers
5905 "\C-c\C-e" message-elide-region
5906 "\C-c\C-v" message-delete-not-region
5907 "\C-c\C-z" message-kill-to-signature
5908 "\M-\r" message-newline-and-reformat
5909 "\C-c\C-a" mml-attach-file
5910 "\C-a" message-beginning-of-line
5912 "\M-;" comment-region)
5914 (gnus-define-keys (gnus-article-edit-wash-map
5915 "\C-c\C-w" gnus-article-edit-mode-map)
5916 "f" gnus-article-edit-full-stops))
5919 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5921 ["Fetch To" message-insert-to t]
5922 ["Fetch Newsgroups" message-insert-newsgroups t]
5924 ["To" message-goto-to t]
5925 ["From" message-goto-from t]
5926 ["Subject" message-goto-subject t]
5927 ["Cc" message-goto-cc t]
5928 ["Reply-To" message-goto-reply-to t]
5929 ["Summary" message-goto-summary t]
5930 ["Keywords" message-goto-keywords t]
5931 ["Newsgroups" message-goto-newsgroups t]
5932 ["Followup-To" message-goto-followup-to t]
5933 ["Mail-Followup-To" message-goto-mail-followup-to t]
5934 ["Distribution" message-goto-distribution t]
5935 ["Body" message-goto-body t]
5936 ["Signature" message-goto-signature t]))
5938 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
5939 "Major mode for editing articles.
5940 This is an extended text-mode.
5942 \\{gnus-article-edit-mode-map}"
5943 (make-local-variable 'gnus-article-edit-done-function)
5944 (make-local-variable 'gnus-prev-winconf)
5945 (set (make-local-variable 'font-lock-defaults)
5946 '(message-font-lock-keywords t))
5947 (set (make-local-variable 'mail-header-separator) "")
5948 (set (make-local-variable 'gnus-article-edit-mode) t)
5949 (easy-menu-add message-mode-field-menu message-mode-map)
5950 (setq buffer-read-only nil)
5951 (buffer-enable-undo)
5954 (defun gnus-article-edit (&optional force)
5955 "Edit the current article.
5956 This will have permanent effect only in mail groups.
5957 If FORCE is non-nil, allow editing of articles even in read-only
5960 (when (and (not force)
5961 (gnus-group-read-only-p))
5962 (error "The current newsgroup does not support article editing"))
5963 (gnus-article-date-original)
5964 (gnus-article-edit-article
5966 `(lambda (no-highlight)
5968 (gnus-summary-edit-article-done
5969 ,(or (mail-header-references gnus-current-headers) "")
5970 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5972 (defun gnus-article-edit-article (start-func exit-func)
5973 "Start editing the contents of the current article buffer."
5974 (let ((winconf (current-window-configuration)))
5975 (set-buffer gnus-article-buffer)
5976 (gnus-article-edit-mode)
5977 (funcall start-func)
5978 (set-buffer-modified-p nil)
5979 (gnus-configure-windows 'edit-article)
5980 (setq gnus-article-edit-done-function exit-func)
5981 (setq gnus-prev-winconf winconf)
5982 (when gnus-article-edit-article-setup-function
5983 (funcall gnus-article-edit-article-setup-function))
5984 (gnus-message 6 "C-c C-c to end edits; C-c C-k to exit")))
5986 (defun gnus-article-edit-done (&optional arg)
5987 "Update the article edits and exit."
5989 (let ((func gnus-article-edit-done-function)
5990 (buf (current-buffer))
5991 (start (window-start))
5993 (winconf gnus-prev-winconf))
5994 (remove-hook 'gnus-article-mode-hook
5995 'gnus-article-mime-edit-article-unwind)
5996 (widen) ;; Widen it in case that users narrowed the buffer.
5999 ;; The cache and backlog have to be flushed somewhat.
6000 (when gnus-keep-backlog
6001 (gnus-backlog-remove-article
6002 (car gnus-article-current) (cdr gnus-article-current)))
6003 ;; Flush original article as well.
6005 (when (get-buffer gnus-original-article-buffer)
6006 (set-buffer gnus-original-article-buffer)
6007 (setq gnus-original-article nil)))
6008 (when gnus-use-cache
6009 (gnus-cache-update-article
6010 (car gnus-article-current) (cdr gnus-article-current)))
6011 ;; We remove all text props from the article buffer.
6012 (kill-all-local-variables)
6013 (set-text-properties (point-min) (point-max) nil)
6015 (set-window-configuration winconf)
6017 (set-window-start (get-buffer-window buf) start)
6018 (set-window-point (get-buffer-window buf) (point)))
6019 (gnus-summary-show-article))
6021 (defun gnus-article-edit-exit ()
6022 "Exit the article editing without updating."
6024 (when (or (not (buffer-modified-p))
6025 (yes-or-no-p "Article modified; kill anyway? "))
6026 (let ((curbuf (current-buffer))
6028 (window-start (window-start)))
6030 (if (gnus-buffer-live-p gnus-original-article-buffer)
6031 (insert-buffer-substring gnus-original-article-buffer))
6032 (let ((winconf gnus-prev-winconf))
6033 (kill-all-local-variables)
6035 (set-window-configuration winconf)
6036 ;; Tippy-toe some to make sure that point remains where it was.
6037 (save-current-buffer
6039 (set-window-start (get-buffer-window (current-buffer)) window-start)
6041 (gnus-summary-show-article)))
6043 (defun gnus-article-edit-full-stops ()
6044 "Interactively repair spacing at end of sentences."
6047 (goto-char (point-min))
6048 (search-forward-regexp "^$" nil t)
6049 (let ((case-fold-search nil))
6050 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
6053 ;;; Article editing with MIME-Edit
6056 (defcustom gnus-article-mime-edit-article-setup-hook nil
6057 "Hook run after setting up a MIME editing article buffer."
6058 :group 'gnus-article-various
6061 (defun gnus-article-mime-edit-article-unwind ()
6062 "Unwind `gnus-article-buffer' if article editing was given up."
6063 (remove-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6064 (when (featurep 'font-lock)
6065 (setq font-lock-defaults nil)
6066 (font-lock-mode -1))
6067 (when mime-edit-mode-flag
6068 (mime-edit-exit 'nomime 'no-error)
6071 (defun gnus-article-mime-edit-article-setup ()
6072 "Convert current buffer to MIME-Edit buffer and turn on MIME-Edit mode
6073 after replacing with the original article."
6074 (setq gnus-show-mime t)
6075 (setq gnus-article-edit-done-function
6076 `(lambda (&rest args)
6077 (when mime-edit-mode-flag
6078 (let (mime-edit-insert-user-agent-field)
6081 (goto-char (point-min))
6082 (let (case-fold-search)
6083 (when (re-search-forward
6084 (format "^%s$" (regexp-quote mail-header-separator))
6086 (replace-match "")))
6087 (apply ,gnus-article-edit-done-function args)
6090 (buffer-substring-no-properties (point-min) (point-max))
6091 (set-buffer (get-buffer-create gnus-original-article-buffer))
6093 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6094 (set-buffer gnus-article-buffer)
6095 (gnus-article-prepare-display)))
6096 (substitute-key-definition 'gnus-article-edit-done
6097 'gnus-article-mime-edit-done
6098 gnus-article-edit-mode-map)
6099 (substitute-key-definition 'gnus-article-edit-exit
6100 'gnus-article-mime-edit-exit
6101 gnus-article-edit-mode-map)
6103 (insert-buffer-substring gnus-original-article-buffer)
6104 (unless (member (with-current-buffer gnus-summary-buffer
6105 gnus-newsgroup-name)
6106 '("nndraft:delayed" "nndraft:drafts"))
6107 (let ((ofn (symbol-function 'mime-edit-decode-single-part-in-buffer)))
6108 (fset 'mime-edit-decode-single-part-in-buffer
6109 (lambda (&rest args)
6110 (if (let ((content-type (car args)))
6111 (and (eq 'message (mime-content-type-primary-type
6113 (eq 'rfc822 (mime-content-type-subtype
6115 (setcar (cdr args) 'not-decode-text))
6119 (fset 'mime-edit-decode-single-part-in-buffer ofn))))
6120 (when (featurep 'font-lock)
6121 (set (make-local-variable 'font-lock-defaults)
6122 '(message-font-lock-keywords t))
6123 (font-lock-set-defaults)
6124 (turn-on-font-lock))
6125 (set-buffer-modified-p nil)
6126 (delete-other-windows)
6127 (add-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6128 (gnus-run-hooks 'gnus-article-mime-edit-article-setup-hook))
6130 (defun gnus-article-mime-edit-done (&optional arg)
6131 "Update the article MIME edits and exit."
6133 (when (featurep 'font-lock)
6134 (setq font-lock-defaults nil)
6135 (font-lock-mode -1))
6136 (let ((inhibit-read-only t))
6137 (gnus-article-edit-done arg)))
6139 (defun gnus-article-mime-edit-exit ()
6140 "Exit the article MIME editing without updating."
6142 (when (or (not (buffer-modified-p))
6143 (yes-or-no-p "Article modified; kill anyway? "))
6144 (when (featurep 'font-lock)
6145 (setq font-lock-defaults nil)
6146 (font-lock-mode -1))
6147 (when mime-edit-mode-flag
6148 (let (mime-edit-insert-user-agent-field)
6151 (goto-char (point-min))
6152 (let (case-fold-search)
6153 (when (re-search-forward
6154 (format "^%s$" (regexp-quote mail-header-separator)) nil t)
6155 (replace-match "")))
6156 (let ((winconf gnus-prev-winconf))
6158 (buffer-substring-no-properties (point-min) (point-max))
6159 (set-buffer (get-buffer-create gnus-original-article-buffer))
6161 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6162 (set-buffer gnus-article-buffer)
6163 (gnus-article-prepare-display)
6164 (set-window-configuration winconf))))
6167 ;;; Article highlights
6170 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
6172 ;;; Internal Variables:
6174 (defcustom gnus-button-url-regexp
6175 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
6176 "\\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:]]\\)"
6177 "\\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\\)\\)")
6178 "Regular expression that matches URLs."
6179 :group 'gnus-article-buttons
6182 (defcustom gnus-button-valid-fqdn-regexp
6183 message-valid-fqdn-regexp
6184 "Regular expression that matches a valid FQDN."
6185 :group 'gnus-article-buttons
6188 (defcustom gnus-button-man-handler 'manual-entry
6189 "Function to use for displaying man pages.
6190 The function must take at least one argument with a string naming the
6192 :type '(choice (function-item :tag "Man" manual-entry)
6193 (function-item :tag "Woman" woman)
6194 (function :tag "Other"))
6195 :group 'gnus-article-buttons)
6197 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
6198 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
6199 If the default site is too slow, try to find a CTAN mirror, see
6200 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
6201 the variable `gnus-button-handle-ctan'."
6202 :group 'gnus-article-buttons
6203 :link '(custom-manual "(gnus)Group Parameters")
6204 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
6205 (const "http://tug.ctan.org/tex-archive/")
6206 (const "http://www.dante.de/CTAN/")
6207 (string :tag "Other")))
6209 (defcustom gnus-button-ctan-handler 'browse-url
6210 "Function to use for displaying CTAN links.
6211 The function must take one argument, the string naming the URL."
6212 :type '(choice (function-item :tag "Browse Url" browse-url)
6213 (function :tag "Other"))
6214 :group 'gnus-article-buttons)
6216 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
6217 "Bogus strings removed from CTAN URLs."
6218 :group 'gnus-article-buttons
6219 :type '(choice (const "^/?tex-archive/\\|/")
6220 (regexp :tag "Other")))
6222 (defcustom gnus-button-ctan-directory-regexp
6225 "biblio\\|digests\\|dviware\\|fonts\\|graphics\\|help\\|"
6226 "indexing\\|info\\|language\\|macros\\|support\\|systems\\|"
6227 "tds\\|tools\\|usergrps\\|web\\|nonfree\\|obsolete"
6229 "Regular expression for ctan directories.
6230 It should match all directories in the top level of `gnus-ctan-url'."
6231 :group 'gnus-article-buttons
6234 (defcustom gnus-button-mid-or-mail-regexp
6235 (concat "\\b\\(<?[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t ]*@"
6236 ;; Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
6237 gnus-button-valid-fqdn-regexp
6239 "Regular expression that matches a message ID or a mail address."
6240 :group 'gnus-article-buttons
6243 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
6244 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
6245 Strings like this can be either a message ID or a mail address. If it is one
6246 of the symbols `mid' or `mail', Gnus will always assume that the string is a
6247 message ID or a mail address, respectively. If this variable is set to the
6248 symbol `ask', always query the user what do do. If it is a function, this
6249 function will be called with the string as it's only argument. The function
6250 must return `mid', `mail', `invalid' or `ask'."
6251 :group 'gnus-article-buttons
6252 :type '(choice (function-item :tag "Heuristic function"
6253 gnus-button-mid-or-mail-heuristic)
6258 (defcustom gnus-button-mid-or-mail-heuristic-alist
6259 '((-10.0 . ".+\\$.+@")
6262 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
6263 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
6264 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
6265 (-1.0 . "^[^a-z]+@")
6267 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
6268 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
6269 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
6270 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
6273 (-1.0 . "^[0-9][0-9]")
6275 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
6276 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6277 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
6278 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6280 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
6281 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
6284 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
6286 ;; compensation for TDMA dated mail addresses:
6287 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
6289 (-20.0 . "\\.fsf@") ;; Gnus
6292 (-20.0 . "_-_") ;; Subject change in thread
6294 (-20.0 . "\\.ln@") ;; leafnode
6295 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
6296 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
6298 ;; (5.0 . "") ;; $local_part_len <= 7
6299 (10.0 . "^[^0-9]+@")
6300 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
6301 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
6304 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
6306 (0.5 . "^[A-Z][a-z]")
6307 (0.5 . "^[A-Z][a-z][a-z]")
6308 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
6309 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
6310 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
6312 A negative RATE indicates a message IDs, whereas a positive indicates a mail
6313 address. The REGEXP is processed with `case-fold-search' set to nil."
6314 :group 'gnus-article-buttons
6315 :type '(repeat (cons (number :tag "Rate")
6316 (regexp :tag "Regexp"))))
6318 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
6319 "Guess whether MID-OR-MAIL is a message ID or a mail address.
6320 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
6321 address, `ask' if unsure and `invalid' if the string is invalid."
6322 (let ((case-fold-search nil)
6323 (list gnus-button-mid-or-mail-heuristic-alist)
6324 (result 0) rate regexp lpartlen elem)
6326 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
6327 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
6328 ;; Certain special cases...
6331 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
6332 "^[0-9]+\\.[0-9]+@compuserve\\|"
6333 "@public\\.gmane\\.org")
6335 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
6336 (setq result 'mail))
6337 (when (string-match "@.*@\\| " mid-or-mail)
6338 (gnus-message 8 "`%s' is invalid." mid-or-mail)
6339 (setq result 'invalid))
6340 ;; Nothing more to do, if result is not a number here...
6341 (when (numberp result)
6343 (setq elem (car list)
6347 (when (string-match regexp mid-or-mail)
6348 (setq result (+ result rate))
6350 9 "`%s' matched `%s', rate `%s', result `%s'."
6351 mid-or-mail regexp rate result)))
6352 (when (<= lpartlen 7)
6353 (setq result (+ result 5.0))
6354 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
6355 mid-or-mail result))
6356 (when (>= lpartlen 12)
6357 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
6359 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
6360 ;; Long local part should contain realname if e-mail address,
6361 ;; too many digits: message-id.
6362 ;; $score -= 5.0 + 0.1 * $local_part_len;
6363 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6364 (setq result (+ result rate))
6366 9 "Many digits in `%s', rate `%s', result `%s'."
6367 mid-or-mail rate result))
6368 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6370 ;; Too few vowels [^aeiouy]{4,}.*\@
6371 (setq result (+ result -5.0))
6373 9 "Few vowels in `%s', rate `%s', result `%s'."
6374 mid-or-mail -5.0 result))
6376 (setq result (+ result 5.0))
6378 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6379 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6380 ;; Maybe we should make this a customizable alist: (condition . 'result)
6382 ((symbolp result) result)
6383 ;; Now convert number into proper results:
6384 ((< result -10.0) 'mid)
6385 ((> result 10.0) 'mail)
6388 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6389 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6390 (url-mid (concat "news" ":" mid-or-mail))
6391 (url-mailto (concat "mailto" ":" mid-or-mail)))
6392 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6393 (when (fboundp pref)
6395 ;; get rid of surrounding angles...
6397 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6398 (if (or (eq 'mid guessed) (eq 'mail guessed))
6402 (save-window-excursion
6403 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6406 (cond ((eq pref 'mid)
6407 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6408 (gnus-button-handle-news url-mid))
6410 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6411 (gnus-url-mailto url-mailto))
6412 (t (gnus-message 3 "Invalid string.")))))
6414 (defun gnus-button-handle-custom (url)
6415 "Follow a Custom URL."
6416 (customize-apropos (gnus-url-unhex-string url)))
6418 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6420 ;; FIXME: Maybe we should merge some of the functions that do quite similar
6423 (defun gnus-button-handle-describe-function (url)
6424 "Call `describe-function' when pushing the corresponding URL button."
6427 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6429 (defun gnus-button-handle-describe-variable (url)
6430 "Call `describe-variable' when pushing the corresponding URL button."
6433 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6435 (defun gnus-button-handle-symbol (url)
6436 "Display help on variable or function.
6437 Calls `describe-variable' or `describe-function'."
6438 (let ((sym (intern url)))
6440 ((fboundp sym) (describe-function sym))
6441 ((boundp sym) (describe-variable sym))
6442 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
6444 (defun gnus-button-handle-describe-key (url)
6445 "Call `describe-key' when pushing the corresponding URL button."
6447 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6448 (keys (ignore-errors (eval `(kbd ,key-string)))))
6451 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6453 (defun gnus-button-handle-apropos (url)
6454 "Call `apropos' when pushing the corresponding URL button."
6455 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6457 (defun gnus-button-handle-apropos-command (url)
6458 "Call `apropos' when pushing the corresponding URL button."
6460 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6462 (defun gnus-button-handle-apropos-variable (url)
6463 "Call `apropos' when pushing the corresponding URL button."
6465 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6466 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6468 (defun gnus-button-handle-apropos-documentation (url)
6469 "Call `apropos' when pushing the corresponding URL button."
6471 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6472 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6474 (defun gnus-button-handle-library (url)
6475 "Call `locate-library' when pushing the corresponding URL button."
6476 (gnus-message 9 "url=`%s'" url)
6477 (let* ((lib (locate-library url))
6478 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6480 (gnus-message 1 "Cannot locale library `%s'." url)
6481 (find-file-read-only file))))
6483 (defun gnus-button-handle-ctan (url)
6484 "Call `browse-url' when pushing a CTAN URL button."
6486 gnus-button-ctan-handler
6489 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6491 (defcustom gnus-button-tex-level 5
6492 "*Integer that says how many TeX-related buttons Gnus will show.
6493 The higher the number, the more buttons will appear and the more false
6494 positives are possible. Note that you can set this variable local to
6495 specific groups. Setting it higher in TeX groups is probably a good idea.
6496 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6497 how to set variables in specific groups."
6498 :group 'gnus-article-buttons
6499 :link '(custom-manual "(gnus)Group Parameters")
6502 (defcustom gnus-button-man-level 5
6503 "*Integer that says how many man-related buttons Gnus will show.
6504 The higher the number, the more buttons will appear and the more false
6505 positives are possible. Note that you can set this variable local to
6506 specific groups. Setting it higher in Unix groups is probably a good idea.
6507 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6508 how to set variables in specific groups."
6509 :group 'gnus-article-buttons
6510 :link '(custom-manual "(gnus)Group Parameters")
6513 (defcustom gnus-button-emacs-level 5
6514 "*Integer that says how many emacs-related buttons Gnus will show.
6515 The higher the number, the more buttons will appear and the more false
6516 positives are possible. Note that you can set this variable local to
6517 specific groups. Setting it higher in Emacs or Gnus related groups is
6518 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6519 `gnus-parameters' on how to set variables in specific groups."
6520 :group 'gnus-article-buttons
6521 :link '(custom-manual "(gnus)Group Parameters")
6524 (defcustom gnus-button-message-level 5
6525 "*Integer that says how many buttons for news or mail messages will appear.
6526 The higher the number, the more buttons will appear and the more false
6527 positives are possible."
6528 ;; mail addresses, MIDs, URLs for news, ...
6529 :group 'gnus-article-buttons
6532 (defcustom gnus-button-browse-level 5
6533 "*Integer that says how many buttons for browsing will appear.
6534 The higher the number, the more buttons will appear and the more false
6535 positives are possible."
6536 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6537 :group 'gnus-article-buttons
6540 (defcustom gnus-button-alist
6541 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6542 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6543 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
6544 gnus-button-handle-news 2)
6545 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6546 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6547 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6548 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6549 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
6550 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
6551 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
6552 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6553 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6554 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6555 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6556 ;; RFC 2368 (The mailto URL scheme)
6557 ("mailto:\\([-a-z.@_+0-9%=?&]+\\)"
6558 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6559 ("\\bmailto:\\([^ \n\t]+\\)"
6560 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6562 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6563 gnus-button-ctan-directory-regexp
6564 "[^][>)!;:,'\n\t ]+\\)")
6565 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6566 ((concat "\\btex-archive/\\("
6567 gnus-button-ctan-directory-regexp
6568 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6569 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6572 gnus-button-ctan-directory-regexp
6573 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6574 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6575 ;; This is info (home-grown style) <info://foo/bar+baz>
6576 ("\\binfo://\\([^'\">\n\t ]+\\)"
6577 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6578 ;; Info GNOME style <info:foo#bar_baz>
6579 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6580 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6581 ;; Info KDE style <info:(foo)bar baz>
6582 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6583 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6584 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6585 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6586 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6587 ;; Info links like `C-h i d m CC Mode RET'
6588 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6590 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6591 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6592 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6593 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6594 ;; Emacs help commands
6595 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6596 ;; regexp doesn't match arguments containing ` '.
6597 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6598 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6599 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6600 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6601 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6602 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6603 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6604 ;; The following entries may lead to many false positives so don't enable
6605 ;; them by default (use a high button level):
6606 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>"
6607 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6608 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6609 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6610 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6611 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6612 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6613 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6614 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6615 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6616 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6617 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
6618 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6619 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6620 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6621 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6622 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6623 ;; Unlike the other regexps we really have to require quoting
6624 ;; here to determine where it ends.
6625 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6626 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
6627 ("<URL: *\\([^<>]*\\)>"
6628 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6629 ;; RFC 2396 (2.4.3., delims) ...
6630 ("\"URL: *\\([^\"]*\\)\""
6631 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6632 ;; RFC 2396 (2.4.3., delims) ...
6633 ("\"URL: *\\([^\"]*\\)\""
6634 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6636 (gnus-button-url-regexp
6637 0 (>= gnus-button-browse-level 0) browse-url 0)
6639 ("\\b\\([a-z][a-z]+\\)([1-9])\\W"
6640 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6641 gnus-button-handle-man 1)
6642 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6643 ("\\b\\([a-z][-_.a-z0-9]+\\)([1-9])\\W"
6644 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6645 gnus-button-handle-man 1)
6646 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6647 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6648 ("\\b\\([a-z][-+_.:a-z0-9]+\\)([1-9][X1a-z]*)\\W\\|\\b\\(X\\)([1-9])\\W"
6649 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6650 ;; MID or mail: To avoid too many false positives we don't try to catch
6651 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6652 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6653 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6654 ;; so that non-ambiguous entries (see above) match first.
6655 (gnus-button-mid-or-mail-regexp
6656 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6657 "*Alist of regexps matching buttons in article bodies.
6659 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6660 REGEXP: is the string (case insensitive) matching text around the button (can
6661 also be Lisp expression evaluating to a string),
6662 BUTTON: is the number of the regexp grouping actually matching the button,
6663 FORM: is a Lisp expression which must eval to true for the button to
6665 CALLBACK: is the function to call when the user push this button, and each
6666 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6668 CALLBACK can also be a variable, in that case the value of that
6669 variable it the real callback function."
6670 :group 'gnus-article-buttons
6671 :type '(repeat (list (choice regexp variable sexp)
6672 (integer :tag "Button")
6674 (function :tag "Callback")
6677 (integer :tag "Regexp group")))))
6679 (defcustom gnus-header-button-alist
6680 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
6681 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6682 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6683 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6684 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6685 0 (>= gnus-button-message-level 0) gnus-button-mailto 0)
6686 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6687 0 (>= gnus-button-browse-level 0) browse-url 0)
6688 ("^Subject:" gnus-button-url-regexp
6689 0 (>= gnus-button-browse-level 0) browse-url 0)
6690 ("^[^:]+:" gnus-button-url-regexp
6691 0 (>= gnus-button-browse-level 0) browse-url 0)
6692 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&]+\\)"
6693 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6694 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6695 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6696 "*Alist of headers and regexps to match buttons in article heads.
6698 This alist is very similar to `gnus-button-alist', except that each
6699 alist has an additional HEADER element first in each entry:
6701 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6703 HEADER is a regexp to match a header. For a fuller explanation, see
6704 `gnus-button-alist'."
6705 :group 'gnus-article-buttons
6706 :group 'gnus-article-headers
6707 :type '(repeat (list (regexp :tag "Header")
6708 (choice regexp variable)
6709 (integer :tag "Button")
6711 (function :tag "Callback")
6714 (integer :tag "Regexp group")))))
6716 (defvar gnus-button-regexp nil)
6717 (defvar gnus-button-marker-list nil)
6718 ;; Regexp matching any of the regexps from `gnus-button-alist'.
6720 (defvar gnus-button-last nil)
6721 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
6725 (defun gnus-article-push-button (event)
6726 "Check text under the mouse pointer for a callback function.
6727 If the text under the mouse pointer has a `gnus-callback' property,
6728 call it with the value of the `gnus-data' text property."
6730 (set-buffer (window-buffer (posn-window (event-start event))))
6731 (let* ((pos (posn-point (event-start event)))
6732 (data (get-text-property pos 'gnus-data))
6733 (fun (get-text-property pos 'gnus-callback)))
6736 (funcall fun data))))
6738 (defun gnus-article-press-button ()
6739 "Check text at point for a callback function.
6740 If the text at point has a `gnus-callback' property,
6741 call it with the value of the `gnus-data' text property."
6743 (let ((data (get-text-property (point) 'gnus-data))
6744 (fun (get-text-property (point) 'gnus-callback)))
6746 (funcall fun data))))
6748 (defun gnus-article-prev-button (n)
6749 "Move point to N buttons backward.
6750 If N is negative, move forward instead."
6752 (gnus-article-next-button (- n)))
6754 (defun gnus-article-next-button (n)
6755 "Move point to N buttons forward.
6756 If N is negative, move backward instead."
6758 (let ((function (if (< n 0) 'previous-single-property-change
6759 'next-single-property-change))
6760 (inhibit-point-motion-hooks t)
6762 (limit (if (< n 0) (point-min) (point-max))))
6764 (while (and (not (= limit (point)))
6766 ;; Skip past the current button.
6767 (when (get-text-property (point) 'gnus-callback)
6768 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6769 ;; Go to the next (or previous) button.
6770 (gnus-goto-char (funcall function (point) 'gnus-callback nil limit))
6771 ;; Put point at the start of the button.
6772 (when (and backward (not (get-text-property (point) 'gnus-callback)))
6773 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6774 ;; Skip past intangible buttons.
6775 (when (get-text-property (point) 'intangible)
6779 (gnus-message 5 "No more buttons"))
6782 (defun gnus-article-highlight (&optional force)
6783 "Highlight current article.
6784 This function calls `gnus-article-highlight-headers',
6785 `gnus-article-highlight-citation',
6786 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6787 do the highlighting. See the documentation for those functions."
6788 (interactive (list 'force))
6789 (gnus-article-highlight-headers)
6790 (gnus-article-highlight-citation force)
6791 (gnus-article-highlight-signature)
6792 (gnus-article-add-buttons force)
6793 (gnus-article-add-buttons-to-head))
6795 (defun gnus-article-highlight-some (&optional force)
6796 "Highlight current article.
6797 This function calls `gnus-article-highlight-headers',
6798 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6799 do the highlighting. See the documentation for those functions."
6800 (interactive (list 'force))
6801 (gnus-article-highlight-headers)
6802 (gnus-article-highlight-signature)
6803 (gnus-article-add-buttons))
6805 (defun gnus-article-highlight-headers ()
6806 "Highlight article headers as specified by `gnus-header-face-alist'."
6808 (gnus-with-article-headers
6809 (let ((alist gnus-header-face-alist)
6810 entry regexp header-face field-face from hpoints fpoints)
6811 (while (setq entry (pop alist))
6812 (goto-char (point-min))
6813 (setq regexp (concat "^\\("
6814 (if (string-equal "" (nth 0 entry))
6818 header-face (nth 1 entry)
6819 field-face (nth 2 entry))
6820 (while (and (re-search-forward regexp nil t)
6824 (unless (search-forward ":" nil t)
6826 (when (and header-face
6827 (not (memq (point) hpoints)))
6828 (push (point) hpoints)
6829 (gnus-put-text-property from (point) 'face header-face))
6830 (when (and field-face
6831 (not (memq (setq from (point)) fpoints)))
6833 (if (re-search-forward "^[^ \t]" nil t)
6835 (goto-char (point-max)))
6836 (gnus-put-text-property from (point) 'face field-face)))))))
6838 (defun gnus-article-highlight-signature ()
6839 "Highlight the signature in an article.
6840 It does this by highlighting everything after
6841 `gnus-signature-separator' using `gnus-signature-face'."
6843 (when gnus-signature-face
6844 (gnus-with-article-buffer
6845 (let ((inhibit-point-motion-hooks t))
6847 (when (gnus-article-narrow-to-signature)
6848 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6849 'face gnus-signature-face)))))))
6851 (defun gnus-article-buttonize-signature ()
6852 "Add button to the signature."
6855 (set-buffer gnus-article-buffer)
6856 (let ((buffer-read-only nil)
6857 (inhibit-point-motion-hooks t))
6858 (when (gnus-article-search-signature)
6859 (gnus-article-add-button (match-beginning 0) (match-end 0)
6860 'gnus-signature-toggle
6861 (set-marker (make-marker)
6862 (1+ (match-end 0))))))))
6864 (defun gnus-button-in-region-p (b e prop)
6865 "Say whether PROP exists in the region."
6866 (text-property-not-all b e prop nil))
6868 (defun gnus-article-add-buttons (&optional force)
6869 "Find external references in the article and make buttons of them.
6870 \"External references\" are things like Message-IDs and URLs, as
6871 specified by `gnus-button-alist'."
6872 (interactive (list 'force))
6873 (gnus-with-article-buffer
6874 (let ((inhibit-point-motion-hooks t)
6875 (case-fold-search t)
6876 (alist gnus-button-alist)
6878 ;; Remove all old markers.
6879 (let (marker entry new-list)
6880 (while (setq marker (pop gnus-button-marker-list))
6881 (if (or (< marker (point-min)) (>= marker (point-max)))
6882 (push marker new-list)
6884 (when (setq entry (gnus-button-entry))
6885 (put-text-property (match-beginning (nth 1 entry))
6886 (match-end (nth 1 entry))
6887 'gnus-callback nil))
6888 (set-marker marker nil)))
6889 (setq gnus-button-marker-list new-list))
6890 ;; We skip the headers.
6893 (while (setq entry (pop alist))
6894 (setq regexp (eval (car entry)))
6896 (while (re-search-forward regexp nil t)
6897 (let* ((start (and entry (match-beginning (nth 1 entry))))
6898 (end (and entry (match-end (nth 1 entry))))
6899 (from (match-beginning 0)))
6900 (when (and (or (eq t (nth 2 entry))
6901 (eval (nth 2 entry)))
6902 (not (gnus-button-in-region-p
6903 start end 'gnus-callback)))
6904 ;; That optional form returned non-nil, so we add the
6906 (gnus-article-add-button
6907 start end 'gnus-button-push
6908 (car (push (set-marker (make-marker) from)
6909 gnus-button-marker-list))))))))))
6911 ;; Add buttons to the head of an article.
6912 (defun gnus-article-add-buttons-to-head ()
6913 "Add buttons to the head of the article."
6915 (gnus-with-article-headers
6916 (let ((alist gnus-header-button-alist)
6919 ;; Each alist entry.
6920 (setq entry (pop alist))
6921 (goto-char (point-min))
6922 (while (re-search-forward (car entry) nil t)
6923 ;; Each header matching the entry.
6924 (setq beg (match-beginning 0))
6925 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6926 (match-beginning 0))
6929 (while (re-search-forward (eval (nth 1 entry)) end t)
6930 ;; Each match within a header.
6931 (let* ((entry (cdr entry))
6932 (start (match-beginning (nth 1 entry)))
6933 (end (match-end (nth 1 entry)))
6934 (form (nth 2 entry)))
6935 (goto-char (match-end 0))
6937 (gnus-article-add-button
6938 start end (nth 3 entry)
6939 (buffer-substring (match-beginning (nth 4 entry))
6940 (match-end (nth 4 entry)))))))
6941 (goto-char end))))))
6943 ;;; External functions:
6945 (defun gnus-article-add-button (from to fun &optional data)
6946 "Create a button between FROM and TO with callback FUN and data DATA."
6947 (when gnus-article-button-face
6948 (gnus-overlay-put (gnus-make-overlay from to)
6949 'face gnus-article-button-face))
6950 (gnus-add-text-properties
6952 (nconc (and gnus-article-mouse-face
6953 (list gnus-mouse-face-prop gnus-article-mouse-face))
6954 (list 'gnus-callback fun)
6955 (and data (list 'gnus-data data))))
6956 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6957 :button-keymap gnus-widget-button-keymap))
6959 ;;; Internal functions:
6961 (defun gnus-article-set-globals ()
6962 (with-current-buffer gnus-summary-buffer
6963 (gnus-set-global-variables)))
6965 (defun gnus-signature-toggle (end)
6966 (gnus-with-article-buffer
6967 (let ((inhibit-point-motion-hooks t)
6968 (limit (next-single-property-change end 'mime-view-entity
6970 (if (text-property-any end limit 'article-type 'signature)
6972 (gnus-delete-wash-type 'signature)
6973 (gnus-remove-text-properties-when
6974 'article-type 'signature end limit
6975 (cons 'article-type (cons 'signature
6976 gnus-hidden-properties))))
6977 (gnus-add-wash-type 'signature)
6978 (gnus-add-text-properties-when
6979 'article-type nil end limit
6980 (cons 'article-type (cons 'signature
6981 gnus-hidden-properties)))))
6982 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6983 (gnus-set-mode-line 'article))))
6985 (defun gnus-button-entry ()
6986 ;; Return the first entry in `gnus-button-alist' matching this place.
6987 (let ((alist gnus-button-alist)
6990 (setq entry (pop alist))
6991 (if (looking-at (eval (car entry)))
6996 (defun gnus-button-push (marker)
6997 ;; Push button starting at MARKER.
7000 (let* ((entry (gnus-button-entry))
7001 (inhibit-point-motion-hooks t)
7003 (args (mapcar (lambda (group)
7004 (let ((string (match-string group)))
7005 (set-text-properties
7006 0 (length string) nil string)
7013 (fboundp (symbol-value fun)))
7014 (apply (symbol-value fun) args))
7016 (gnus-message 1 "You must define `%S' to use this button"
7017 (cons fun args)))))))
7019 (defun gnus-parse-news-url (url)
7020 (let (scheme server group message-id articles)
7023 (goto-char (point-min))
7024 (when (looking-at "\\([A-Za-z]+\\):")
7025 (setq scheme (match-string 1))
7026 (goto-char (match-end 0)))
7027 (when (looking-at "//\\([^/]+\\)/")
7028 (setq server (match-string 1))
7029 (goto-char (match-end 0)))
7032 ((looking-at "\\(.*@.*\\)")
7033 (setq message-id (match-string 1)))
7034 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
7035 (setq group (match-string 1)
7036 articles (split-string (match-string 2) "-")))
7037 ((looking-at "\\([^/]+\\)/?")
7038 (setq group (match-string 1)))
7040 (error "Unknown news URL syntax"))))
7041 (list scheme server group message-id articles)))
7043 (defun gnus-button-handle-news (url)
7045 (destructuring-bind (scheme server group message-id articles)
7046 (gnus-parse-news-url url)
7050 (set-buffer gnus-summary-buffer)
7052 (let ((gnus-refer-article-method (list (list 'nntp server))))
7053 (gnus-summary-refer-article message-id))
7054 (gnus-summary-refer-article message-id))))
7056 (gnus-button-fetch-group url)))))
7058 (defun gnus-button-handle-man (url)
7060 (funcall gnus-button-man-handler url))
7062 (defun gnus-button-handle-info-url (url)
7063 "Fetch an info URL."
7064 (setq url (mm-subst-char-in-string ?+ ?\ url))
7066 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
7067 (gnus-info-find-node
7068 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
7070 ")" (gnus-url-unhex-string (match-string 2 url)))))
7071 ((string-match "([^)\"]+)[^\"]+" url)
7073 (gnus-replace-in-string
7074 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
7075 (gnus-info-find-node url))
7076 (t (error "Can't parse %s" url))))
7078 (defun gnus-button-handle-info-url-gnome (url)
7079 "Fetch GNOME style info URL."
7080 (setq url (mm-subst-char-in-string ?_ ?\ url))
7081 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
7082 (gnus-info-find-node
7084 (gnus-url-unhex-string
7085 (match-string 1 url))
7087 (or (gnus-url-unhex-string
7088 (match-string 2 url))
7090 (error "Can't parse %s" url)))
7092 (defun gnus-button-handle-info-url-kde (url)
7093 "Fetch KDE style info URL."
7094 (gnus-info-find-node (gnus-url-unhex-string url)))
7096 (defun gnus-button-handle-info-keystrokes (url)
7097 "Call `info' when pushing the corresponding URL button."
7098 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
7103 (defun gnus-button-message-id (message-id)
7105 (with-current-buffer gnus-summary-buffer
7106 (gnus-summary-refer-article message-id)))
7108 (defun gnus-button-fetch-group (address)
7109 "Fetch GROUP specified by ADDRESS."
7110 (if (not (string-match "[:/]" address))
7111 ;; This is just a simple group url.
7112 (gnus-group-read-ephemeral-group address gnus-select-method)
7115 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
7117 (error "Can't parse %s" address)
7118 (gnus-group-read-ephemeral-group
7119 (match-string 4 address)
7120 `(nntp ,(match-string 1 address)
7121 (nntp-address ,(match-string 1 address))
7122 (nntp-port-number ,(if (match-end 3)
7123 (match-string 3 address)
7126 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
7128 (defun gnus-url-parse-query-string (query &optional downcase)
7129 (let (retval pairs cur key val)
7130 (setq pairs (split-string query "&"))
7132 (setq cur (car pairs)
7134 (if (not (string-match "=" cur))
7136 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
7137 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
7139 (setq key (downcase key)))
7140 (setq cur (assoc key retval))
7142 (setcdr cur (cons val (cdr cur)))
7143 (setq retval (cons (list key val) retval)))))
7146 (defun gnus-url-mailto (url)
7147 ;; Send mail to someone
7148 (when (string-match "mailto:/*\\(.*\\)" url)
7149 (setq url (substring url (match-beginning 1) nil)))
7150 (let (to args subject func)
7151 (setq args (gnus-url-parse-query-string
7152 (if (string-match "^\\?" url)
7154 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
7155 (concat "to=" (match-string 1 url) "&"
7156 (match-string 2 url))
7157 (concat "to=" url)))
7159 subject (cdr-safe (assoc "subject" args)))
7162 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
7165 (message-position-on-field (caar args)))
7166 (insert (gnus-replace-in-string
7167 (mapconcat 'identity (reverse (cdar args)) ", ")
7169 (setq args (cdr args)))
7172 (message-goto-subject))))
7174 (defun gnus-button-embedded-url (address)
7175 "Activate ADDRESS with `browse-url'."
7176 (browse-url (gnus-strip-whitespace address)))
7178 ;;; Next/prev buttons in the article buffer.
7180 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
7181 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
7183 (defvar gnus-prev-page-map
7184 (let ((map (make-sparse-keymap)))
7185 (define-key map gnus-mouse-2 'gnus-button-prev-page)
7186 (define-key map "\r" 'gnus-button-prev-page)
7189 (defvar gnus-next-page-map
7190 (let ((map (make-sparse-keymap)))
7191 (define-key map gnus-mouse-2 'gnus-button-next-page)
7192 (define-key map "\r" 'gnus-button-next-page)
7195 (defun gnus-insert-prev-page-button ()
7197 (buffer-read-only nil)
7198 (situation (get-text-property (point-min) 'mime-view-situation)))
7200 gnus-prev-page-line-format nil
7201 `(keymap ,gnus-prev-page-map
7203 gnus-callback gnus-article-button-prev-page
7204 article-type annotation
7205 mime-view-situation ,situation))
7206 (widget-convert-button
7208 ;; Exclude a newline.
7211 :action 'gnus-button-prev-page
7212 :button-keymap gnus-prev-page-map)))
7214 (defun gnus-button-next-page (&optional args more-args)
7215 "Go to the next page."
7217 (let ((win (selected-window)))
7218 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7219 (gnus-article-next-page)
7220 (select-window win)))
7222 (defun gnus-button-prev-page (&optional args more-args)
7223 "Go to the prev page."
7225 (let ((win (selected-window)))
7226 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7227 (gnus-article-prev-page)
7228 (select-window win)))
7230 (defun gnus-insert-next-page-button ()
7232 (buffer-read-only nil)
7233 (situation (get-text-property (point-min) 'mime-view-situation)))
7234 (gnus-eval-format gnus-next-page-line-format nil
7235 `(keymap ,gnus-next-page-map
7237 gnus-callback gnus-article-button-next-page
7238 article-type annotation
7239 mime-view-situation ,situation))
7240 (widget-convert-button
7242 ;; Exclude a newline.
7245 :action 'gnus-button-next-page
7246 :button-keymap gnus-next-page-map)))
7248 (defun gnus-article-button-next-page (arg)
7249 "Go to the next page."
7251 (let ((win (selected-window)))
7252 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7253 (gnus-article-next-page)
7254 (select-window win)))
7256 (defun gnus-article-button-prev-page (arg)
7257 "Go to the prev page."
7259 (let ((win (selected-window)))
7260 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7261 (gnus-article-prev-page)
7262 (select-window win)))
7264 (defvar gnus-decode-header-methods
7265 '(mail-decode-encoded-word-region)
7266 "List of methods used to decode headers.
7268 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
7269 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
7270 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
7271 whose names match REGEXP.
7274 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
7275 mail-decode-encoded-word-region
7276 (\"chinese\" . rfc1843-decode-region))
7279 (defvar gnus-decode-header-methods-cache nil)
7281 (defun gnus-multi-decode-header (start end)
7282 "Apply the functions from `gnus-encoded-word-methods' that match."
7283 (unless (and gnus-decode-header-methods-cache
7284 (eq gnus-newsgroup-name
7285 (car gnus-decode-header-methods-cache)))
7286 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
7289 (nconc gnus-decode-header-methods-cache (list x))
7290 (if (and gnus-newsgroup-name
7291 (string-match (car x) gnus-newsgroup-name))
7292 (nconc gnus-decode-header-methods-cache
7294 gnus-decode-header-methods))
7295 (let ((xlist gnus-decode-header-methods-cache))
7298 (narrow-to-region start end)
7300 (funcall (pop xlist) (point-min) (point-max))))))
7303 ;;; Treatment top-level handling.
7306 (defun gnus-treat-article (condition &optional part-number total-parts type)
7307 (let ((length (- (point-max) (point-min)))
7308 (alist gnus-treatment-function-alist)
7309 (article-goto-body-goes-to-point-min-p t)
7313 (let ((list gnus-article-treat-types))
7315 (when (string-match (pop list) type)
7316 (throw 'found t)))))))
7317 (highlightp (gnus-visual-p 'article-highlight 'highlight))
7318 (entity (static-unless (featurep 'xemacs)
7319 (when (eq 'head condition)
7320 (get-text-property (point-min) 'mime-view-entity))))
7321 val elem buttonized)
7322 (gnus-run-hooks 'gnus-part-display-hook)
7323 (unless gnus-inhibit-treatment
7324 (dolist (elem alist)
7327 (when (gnus-buffer-live-p gnus-summary-buffer)
7328 (set-buffer gnus-summary-buffer))
7329 (symbol-value (car elem))))
7330 (when (and (or (consp val)
7332 (gnus-treat-predicate val)
7333 (or (not (get (car elem) 'highlight))
7335 (when (and (not buttonized)
7337 '(gnus-treat-hide-signature
7338 gnus-treat-highlight-signature)))
7339 (gnus-article-buttonize-signature)
7340 (setq buttonized t))
7342 (funcall (cadr elem)))))
7343 ;; FSF Emacsen does not inherit the existing text properties
7344 ;; in the new text, so we should do it for `mime-view-entity'.
7345 (static-unless (featurep 'xemacs)
7347 (put-text-property (point-min) (point-max)
7348 'mime-view-entity entity))))))
7350 ;; Dynamic variables.
7352 (defvar part-number)
7353 (defvar total-parts)
7358 (defun gnus-treat-predicate (val)
7363 (stringp (car val)))
7364 (apply 'gnus-or (mapcar `(lambda (s)
7365 (string-match s ,(or gnus-newsgroup-name "")))
7368 (let ((pred (pop val)))
7371 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
7373 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
7375 (not (gnus-treat-predicate (car val))))
7377 (equal (car val) type))
7379 (error "%S is not a valid predicate" pred)))))
7389 (eq part-number total-parts))
7393 (error "%S is not a valid value" val))))
7395 (defun gnus-article-encrypt-body (protocol &optional n)
7396 "Encrypt the article body."
7399 (or gnus-article-encrypt-protocol
7400 (completing-read "Encrypt protocol: "
7401 gnus-article-encrypt-protocol-alist
7403 current-prefix-arg))
7404 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7406 (error (format "Can't find the encrypt protocol %s" protocol)))
7407 (if (member gnus-newsgroup-name '("nndraft:delayed"
7410 (error "Can't encrypt the article in group %s"
7411 gnus-newsgroup-name))
7412 (gnus-summary-iterate n
7414 (set-buffer gnus-summary-buffer)
7415 (let ((mail-parse-charset gnus-newsgroup-charset)
7416 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7417 (summary-buffer gnus-summary-buffer)
7419 (gnus-set-global-variables)
7420 (when (gnus-group-read-only-p)
7421 (error "The current newsgroup does not support article encrypt"))
7422 (gnus-summary-show-article t)
7424 (or (mail-header-references gnus-current-headers) ""))
7425 (set-buffer gnus-article-buffer)
7426 (let* ((buffer-read-only nil)
7428 (mapcar (lambda (field)
7429 (and (save-restriction
7430 (message-narrow-to-head)
7431 (goto-char (point-min))
7432 (search-forward field nil t))
7434 (message-narrow-to-field)
7436 (delete-region (point-min) (point-max))
7438 '("Content-Type:" "Content-Transfer-Encoding:"
7439 "Content-Disposition:"))))
7440 (message-narrow-to-head)
7441 (message-remove-header "MIME-Version")
7442 (goto-char (point-max))
7443 (setq point (point))
7444 (insert (apply 'concat headers))
7446 (narrow-to-region point (point-max))
7447 (let ((message-options message-options))
7448 (message-options-set 'message-sender user-mail-address)
7449 (message-options-set 'message-recipients user-mail-address)
7450 (message-options-set 'message-sign-encrypt 'not)
7452 (goto-char (point-min))
7453 (insert "MIME-Version: 1.0\n")
7455 (gnus-summary-edit-article-done
7456 references nil summary-buffer t))
7457 (when gnus-keep-backlog
7458 (gnus-backlog-remove-article
7459 (car gnus-article-current) (cdr gnus-article-current)))
7461 (when (get-buffer gnus-original-article-buffer)
7462 (set-buffer gnus-original-article-buffer)
7463 (setq gnus-original-article nil)))
7464 (when gnus-use-cache
7465 (gnus-cache-update-article
7466 (car gnus-article-current) (cdr gnus-article-current))))))))
7468 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7469 "The following specs can be used:
7470 %t The security MIME type
7473 %D Details if button is pressed")
7475 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
7476 "The following specs can be used:
7477 %t The security MIME type
7480 %D Details if button is pressed")
7482 (defvar gnus-mime-security-button-line-format-alist
7483 '((?t gnus-tmp-type ?s)
7484 (?i gnus-tmp-info ?s)
7485 (?d gnus-tmp-details ?s)
7486 (?D gnus-tmp-pressed-details ?s)))
7488 (defvar gnus-mime-security-button-map
7489 (let ((map (make-sparse-keymap)))
7490 (define-key map gnus-mouse-2 'gnus-article-push-button)
7491 (define-key map "\r" 'gnus-article-press-button)
7494 (defvar gnus-mime-security-details-buffer nil)
7496 (defvar gnus-mime-security-button-pressed nil)
7498 (defvar gnus-mime-security-show-details-inline t
7499 "If non-nil, show details in the article buffer.")
7501 (defun gnus-mime-security-verify-or-decrypt (handle)
7502 (mm-remove-parts (cdr handle))
7503 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7504 point buffer-read-only)
7506 (goto-char (car region)))
7508 (narrow-to-region (point) (point))
7509 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7510 (let* ((mm-verify-option 'known)
7511 (mm-decrypt-option 'known)
7512 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7513 (unless (eq nparts (cdr handle))
7514 (mm-destroy-parts (cdr handle))
7515 (setcdr handle nparts))))
7516 (setq point (point))
7517 (gnus-mime-display-security handle)
7518 (goto-char (point-max)))
7520 (delete-region (point) (cdr region))
7521 (set-marker (car region) nil)
7522 (set-marker (cdr region) nil))
7525 (defun gnus-mime-security-show-details (handle)
7526 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7528 (gnus-message 5 "No details.")
7529 (if gnus-mime-security-show-details-inline
7530 (let ((gnus-mime-security-button-pressed
7531 (not (get-text-property (point) 'gnus-mime-details)))
7532 (gnus-mime-security-button-line-format
7533 (get-text-property (point) 'gnus-line-format))
7536 (while (eq (get-text-property (point) 'gnus-line-format)
7537 gnus-mime-security-button-line-format)
7541 (narrow-to-region (point) (point))
7542 (gnus-insert-mime-security-button handle))
7543 (delete-region (point)
7544 (or (text-property-not-all
7547 gnus-mime-security-button-line-format)
7550 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7551 (with-current-buffer gnus-mime-security-details-buffer
7554 (setq gnus-mime-security-details-buffer
7555 (gnus-get-buffer-create "*MIME Security Details*")))
7556 (with-current-buffer gnus-mime-security-details-buffer
7558 (goto-char (point-min)))
7559 (pop-to-buffer gnus-mime-security-details-buffer)))))
7561 (defun gnus-mime-security-press-button (handle)
7563 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7564 (gnus-mime-security-show-details handle)
7565 (gnus-mime-security-verify-or-decrypt handle))))
7567 (defun gnus-insert-mime-security-button (handle &optional displayed)
7568 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7571 (or (nth 2 (assoc protocol mm-verify-function-alist))
7572 (nth 2 (assoc protocol mm-decrypt-function-alist))
7574 (if (equal (car handle) "multipart/signed")
7575 " Signed" " Encrypted")
7578 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7581 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7582 gnus-tmp-pressed-details
7584 (setq gnus-tmp-details
7585 (if gnus-tmp-details
7586 (concat "\n" gnus-tmp-details)
7588 (setq gnus-tmp-pressed-details
7589 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7594 gnus-mime-security-button-line-format
7595 gnus-mime-security-button-line-format-alist
7596 `(keymap ,gnus-mime-security-button-map
7597 gnus-callback gnus-mime-security-press-button
7598 gnus-line-format ,gnus-mime-security-button-line-format
7599 gnus-mime-details ,gnus-mime-security-button-pressed
7600 article-type annotation
7603 ;; Exclude a newline.
7606 (widget-convert-button
7609 :action 'gnus-widget-press-button
7610 :button-keymap gnus-mime-security-button-map
7612 (lambda (widget/window &optional overlay pos)
7613 ;; Needed to properly clear the message due to a bug in
7614 ;; wid-edit (XEmacs only).
7615 (when (boundp 'help-echo-owns-message)
7616 (setq help-echo-owns-message t))
7619 (aref gnus-mouse-2 0))))))
7621 (defun gnus-mime-display-security (handle)
7623 (narrow-to-region (point) (point))
7624 (unless (gnus-unbuttonized-mime-type-p (car handle))
7625 (gnus-insert-mime-security-button handle))
7626 (gnus-mime-display-mixed (cdr handle))
7629 (unless (gnus-unbuttonized-mime-type-p (car handle))
7630 (let ((gnus-mime-security-button-line-format
7631 gnus-mime-security-button-end-line-format))
7632 (gnus-insert-mime-security-button handle)))
7633 (mm-set-handle-multipart-parameter
7635 (cons (set-marker (make-marker) (point-min))
7636 (set-marker (make-marker) (point-max))))))
7642 (defun gnus-article-header-presentation-method (entity situation)
7643 (mime-insert-header entity)
7644 (article-decode-group-name))
7646 (set-alist 'mime-header-presentation-method-alist
7647 'gnus-original-article-mode
7648 #'gnus-article-header-presentation-method)
7650 (defun gnus-mime-preview-quitting-method ()
7651 (mime-preview-kill-buffer)
7652 (delete-other-windows)
7653 (gnus-article-show-summary)
7654 (gnus-summary-select-article gnus-show-all-headers t))
7656 (set-alist 'mime-preview-quitting-method-alist
7657 'gnus-original-article-mode #'gnus-mime-preview-quitting-method)
7659 (set-alist 'mime-preview-following-method-alist
7660 'gnus-original-article-mode #'gnus-following-method)
7662 (set-alist 'mime-preview-over-to-previous-method-alist
7663 'gnus-original-article-mode
7665 (if (> (point-min) 1)
7666 (gnus-article-prev-page)
7667 (gnus-article-read-summary-keys
7668 nil (gnus-character-to-event ?P)))))
7670 (set-alist 'mime-preview-over-to-next-method-alist
7671 'gnus-original-article-mode'
7673 (if (< (point-max) (buffer-size))
7674 (gnus-article-next-page)
7675 (gnus-article-read-summary-keys
7676 nil (gnus-character-to-event ?N)))))
7686 (run-hooks 'gnus-art-load-hook)
7688 ;;; gnus-art.el ends here