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 (defvar gnus-article-edit-mode nil)
1581 ;;; Macros for dealing with the article buffer.
1583 (defmacro gnus-with-article-headers (&rest forms)
1585 (set-buffer gnus-article-buffer)
1587 (let ((buffer-read-only nil)
1588 (inhibit-point-motion-hooks t)
1589 (case-fold-search t))
1590 (article-narrow-to-head)
1593 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1594 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1596 (defmacro gnus-with-article-buffer (&rest forms)
1598 (set-buffer gnus-article-buffer)
1599 (let ((buffer-read-only nil))
1602 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1603 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1605 (defun gnus-article-goto-header (header)
1606 "Go to HEADER, which is a regular expression."
1607 (re-search-forward (concat "^\\(" header "\\):") nil t))
1609 (defsubst gnus-article-hide-text (b e props)
1610 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1611 (gnus-add-text-properties-when 'article-type nil b e props)
1612 (when (memq 'intangible props)
1614 (max (1- b) (point-min))
1615 b 'intangible (cddr (memq 'intangible props)))))
1617 (defsubst gnus-article-unhide-text (b e)
1618 "Remove hidden text properties from region between B and E."
1619 (remove-text-properties b e gnus-hidden-properties)
1620 (when (memq 'intangible gnus-hidden-properties)
1621 (put-text-property (max (1- b) (point-min))
1622 b 'intangible nil)))
1624 (defun gnus-article-hide-text-type (b e type)
1625 "Hide text of TYPE between B and E."
1626 (gnus-add-wash-type type)
1627 (gnus-article-hide-text
1628 b e (cons 'article-type (cons type gnus-hidden-properties))))
1630 (defun gnus-article-unhide-text-type (b e type)
1631 "Unhide text of TYPE between B and E."
1632 (gnus-delete-wash-type type)
1633 (remove-text-properties
1634 b e (cons 'article-type (cons type gnus-hidden-properties)))
1635 (when (memq 'intangible gnus-hidden-properties)
1636 (put-text-property (max (1- b) (point-min))
1637 b 'intangible nil)))
1639 (defun gnus-article-hide-text-of-type (type)
1640 "Hide text of TYPE in the current buffer."
1642 (let ((b (point-min))
1644 (while (setq b (text-property-any b e 'article-type type))
1645 (add-text-properties b (incf b) gnus-hidden-properties)))))
1647 (defun gnus-article-delete-text-of-type (type)
1648 "Delete text of TYPE in the current buffer."
1650 (let ((b (point-min)))
1651 (while (setq b (text-property-any b (point-max) 'article-type type))
1653 b (or (text-property-not-all b (point-max) 'article-type type)
1656 (defun gnus-article-delete-invisible-text ()
1657 "Delete all invisible text in the current buffer."
1659 (let ((b (point-min)))
1660 (while (setq b (text-property-any b (point-max) 'invisible t))
1662 b (or (text-property-not-all b (point-max) 'invisible t)
1665 (defun gnus-article-text-type-exists-p (type)
1666 "Say whether any text of type TYPE exists in the buffer."
1667 (text-property-any (point-min) (point-max) 'article-type type))
1669 (defsubst gnus-article-header-rank ()
1670 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1671 (let ((list gnus-sorted-header-list)
1674 (if (looking-at (car list))
1676 (setq list (cdr list))
1680 (defun article-hide-headers (&optional arg delete)
1681 "Hide unwanted headers and possibly sort them as well."
1682 (interactive (gnus-article-hidden-arg))
1683 ;; Lars said that this function might be inhibited.
1684 (if (gnus-article-check-hidden-text 'headers arg)
1686 ;; Show boring headers as well.
1687 (gnus-article-show-hidden-text 'boring-headers)
1688 (when (eq 1 (point-min))
1689 (set-window-start (get-buffer-window (current-buffer)) 1)))
1690 (unless gnus-inhibit-hiding
1693 (let ((inhibit-read-only t)
1694 (case-fold-search t)
1695 (max (1+ (length gnus-sorted-header-list)))
1696 (ignored (when (not gnus-visible-headers)
1697 (cond ((stringp gnus-ignored-headers)
1698 gnus-ignored-headers)
1699 ((listp gnus-ignored-headers)
1700 (mapconcat 'identity gnus-ignored-headers
1703 (cond ((stringp gnus-visible-headers)
1704 gnus-visible-headers)
1705 ((and gnus-visible-headers
1706 (listp gnus-visible-headers))
1707 (mapconcat 'identity gnus-visible-headers "\\|"))))
1708 (inhibit-point-motion-hooks t)
1710 ;; First we narrow to just the headers.
1711 (article-narrow-to-head)
1712 ;; Hide any "From " lines at the beginning of (mail) articles.
1713 (while (looking-at "From ")
1717 (delete-region (point-min) (point))
1718 (gnus-article-hide-text (point-min) (point)
1719 (nconc (list 'article-type 'headers)
1720 gnus-hidden-properties))))
1721 ;; Then treat the rest of the header lines.
1722 ;; Then we use the two regular expressions
1723 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1724 ;; select which header lines is to remain visible in the
1726 (while (re-search-forward "^[^ \t:]*:" nil t)
1728 ;; Mark the rank of the header.
1730 (point) (1+ (point)) 'message-rank
1731 (if (or (and visible (looking-at visible))
1733 (not (looking-at ignored))))
1734 (gnus-article-header-rank)
1737 (message-sort-headers-1)
1738 (when (setq beg (text-property-any
1739 (point-min) (point-max) 'message-rank (+ 2 max)))
1740 ;; We delete or make invisible the unwanted headers.
1741 (gnus-add-wash-type 'headers)
1744 (add-text-properties
1745 (point-min) (+ 5 (point-min))
1746 '(article-type headers dummy-invisible t))
1747 (delete-region beg (point-max)))
1748 (gnus-article-hide-text-type beg (point-max) 'headers)))))))))
1750 (defun article-hide-boring-headers (&optional arg)
1751 "Toggle hiding of headers that aren't very interesting.
1752 If given a negative prefix, always show; if given a positive prefix,
1754 (interactive (gnus-article-hidden-arg))
1755 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1756 (not gnus-show-all-headers))
1759 (let ((buffer-read-only nil)
1760 (list gnus-boring-article-headers)
1761 (inhibit-point-motion-hooks t)
1763 (article-narrow-to-head)
1765 (setq elem (pop list))
1766 (goto-char (point-min))
1768 ;; Hide empty headers.
1770 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1772 (gnus-article-hide-text-type
1776 (if (re-search-forward "^[^ \t]" nil t)
1780 ;; Hide boring Newsgroups header.
1781 ((eq elem 'newsgroups)
1782 (when (gnus-string-equal
1783 (gnus-fetch-field "newsgroups")
1784 (gnus-group-real-name
1785 (if (boundp 'gnus-newsgroup-name)
1788 (gnus-article-hide-header "newsgroups")))
1789 ((eq elem 'to-address)
1790 (let ((to (message-fetch-field "to"))
1792 (gnus-parameter-to-address
1793 (if (boundp 'gnus-newsgroup-name)
1794 gnus-newsgroup-name ""))))
1795 (when (and to to-address
1798 ;; only one address in To
1799 (nth 1 (mail-extract-address-components to))
1801 (gnus-article-hide-header "to"))))
1803 (let ((to (message-fetch-field "to"))
1805 (gnus-parameter-to-list
1806 (if (boundp 'gnus-newsgroup-name)
1807 gnus-newsgroup-name ""))))
1808 (when (and to to-list
1811 ;; only one address in To
1812 (nth 1 (mail-extract-address-components to))
1814 (gnus-article-hide-header "to"))))
1816 (let ((cc (message-fetch-field "cc"))
1818 (gnus-parameter-to-list
1819 (if (boundp 'gnus-newsgroup-name)
1820 gnus-newsgroup-name ""))))
1821 (when (and cc to-list
1824 ;; only one address in CC
1825 (nth 1 (mail-extract-address-components cc))
1827 (gnus-article-hide-header "cc"))))
1828 ((eq elem 'followup-to)
1829 (when (gnus-string-equal
1830 (message-fetch-field "followup-to")
1831 (message-fetch-field "newsgroups"))
1832 (gnus-article-hide-header "followup-to")))
1833 ((eq elem 'reply-to)
1834 (if (gnus-group-find-parameter
1835 gnus-newsgroup-name 'broken-reply-to)
1836 (gnus-article-hide-header "reply-to")
1837 (let ((from (message-fetch-field "from"))
1838 (reply-to (message-fetch-field "reply-to")))
1845 (lambda (x) (downcase (cadr x)))
1846 (mail-extract-address-components from t))
1849 (lambda (x) (downcase (cadr x)))
1850 (mail-extract-address-components reply-to t))
1852 (gnus-article-hide-header "reply-to")))))
1854 (let ((date (message-fetch-field "date")))
1856 (< (days-between (current-time-string) date)
1858 (gnus-article-hide-header "date"))))
1860 (let ((to (message-fetch-field "to"))
1861 (cc (message-fetch-field "cc")))
1862 (when (> (length to) 1024)
1863 (gnus-article-hide-header "to"))
1864 (when (> (length cc) 1024)
1865 (gnus-article-hide-header "cc"))))
1869 (goto-char (point-min))
1870 (while (re-search-forward "^to:" nil t)
1871 (setq to-count (1+ to-count)))
1872 (when (> to-count 1)
1873 (while (> to-count 0)
1874 (goto-char (point-min))
1876 (re-search-forward "^to:" nil nil to-count)
1878 (narrow-to-region (point) (point-max))
1879 (gnus-article-hide-header "to"))
1880 (setq to-count (1- to-count))))
1881 (goto-char (point-min))
1882 (while (re-search-forward "^cc:" nil t)
1883 (setq cc-count (1+ cc-count)))
1884 (when (> cc-count 1)
1885 (while (> cc-count 0)
1886 (goto-char (point-min))
1888 (re-search-forward "^cc:" nil nil cc-count)
1890 (narrow-to-region (point) (point-max))
1891 (gnus-article-hide-header "cc"))
1892 (setq cc-count (1- cc-count)))))))))))))
1894 (defun gnus-article-hide-header (header)
1896 (goto-char (point-min))
1897 (when (re-search-forward (concat "^" header ":") nil t)
1898 (gnus-article-hide-text-type
1902 (if (re-search-forward "^[^ \t]" nil t)
1907 (defvar gnus-article-normalized-header-length 40
1908 "Length of normalized headers.")
1910 (defun article-normalize-headers ()
1911 "Make all header lines 40 characters long."
1913 (let ((buffer-read-only nil)
1917 (article-narrow-to-head)
1920 ((< (setq column (- (point-at-eol) (point)))
1921 gnus-article-normalized-header-length)
1923 (insert (make-string
1924 (- gnus-article-normalized-header-length column)
1926 ((> column gnus-article-normalized-header-length)
1927 (gnus-put-text-property
1929 (forward-char gnus-article-normalized-header-length)
1936 (forward-line 1))))))
1938 (defun article-treat-dumbquotes ()
1939 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
1940 Note that this function guesses whether a character is a sm*rtq**t* or
1941 not, so it should only be used interactively.
1943 Sm*rtq**t*s are M****s***'s unilateral extension to the
1944 iso-8859-1 character map in an attempt to provide more quoting
1945 characters. If you see something like \\222 or \\264 where
1946 you're expecting some kind of apostrophe or quotation mark, then
1949 (article-translate-strings gnus-article-dumbquotes-map))
1951 (defun article-translate-characters (from to)
1952 "Translate all characters in the body of the article according to FROM and TO.
1953 FROM is a string of characters to translate from; to is a string of
1954 characters to translate to."
1956 (when (article-goto-body)
1957 (let ((buffer-read-only nil)
1958 (x (make-string 225 ?x))
1960 (while (< (incf i) (length x))
1963 (while (< i (length from))
1964 (aset x (aref from i) (aref to i))
1966 (translate-region (point) (point-max) x)))))
1968 (defun article-translate-strings (map)
1969 "Translate all string in the body of the article according to MAP.
1970 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1972 (when (article-goto-body)
1973 (let ((buffer-read-only nil)
1975 (while (setq elem (pop map))
1977 (while (search-forward (car elem) nil t)
1978 (replace-match (cadr elem)))))))))
1980 (defun article-treat-overstrike ()
1981 "Translate overstrikes into bold text."
1984 (when (article-goto-body)
1985 (let ((buffer-read-only nil))
1986 (while (search-forward "\b" nil t)
1987 (let ((next (char-after))
1991 previous (char-after))
1995 ;; We do the boldification/underlining by hiding the
1996 ;; overstrikes and putting the proper text property
2000 (gnus-article-hide-text-type start (point) 'overstrike)
2001 (put-text-property (point) end 'face 'bold))
2003 (gnus-article-hide-text-type
2004 (1- (point)) (1+ (point)) 'overstrike)
2006 start (1- (point)) 'face 'underline))
2008 (gnus-article-hide-text-type start (point) 'overstrike)
2010 (point) end 'face 'underline)))))))))
2012 (defun article-treat-ansi-sequences ()
2013 "Translate ANSI SGR control sequences into overlays or extents."
2016 (when (article-goto-body)
2017 (let ((buffer-read-only nil))
2018 (ansi-color-apply-on-region (point) (point-max))))))
2020 (defun gnus-article-treat-unfold-headers ()
2021 "Unfold folded message headers.
2022 Only the headers that fit into the current window width will be
2025 (gnus-with-article-headers
2029 (mail-header-narrow-to-field)
2030 (let ((header (buffer-string)))
2033 (goto-char (point-min))
2034 (while (re-search-forward "\n[\t ]" nil t)
2035 (replace-match " " t t)))
2036 (setq length (- (point-max) (point-min) 1)))
2037 (when (< length (window-width))
2038 (while (re-search-forward "\n[\t ]" nil t)
2039 (replace-match " " t t)))
2040 (goto-char (point-max)))))))
2042 (defun gnus-article-treat-fold-headers ()
2043 "Fold message headers."
2045 (gnus-with-article-headers
2048 (mail-header-narrow-to-field)
2049 (mail-header-fold-field)
2050 (goto-char (point-max))))))
2052 (defun gnus-treat-smiley ()
2053 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2055 (unless (featurep 'xemacs)
2056 (when (and (not gnus-article-should-use-smiley-mule)
2057 gnus-article-smiley-mule-loaded-p)
2058 (load "smiley" nil t)
2059 (setq gnus-article-smiley-mule-loaded-p nil))
2060 (when (and gnus-article-should-use-smiley-mule
2061 (not gnus-article-smiley-mule-loaded-p))
2062 (load "smiley-mule" nil t)
2063 (setq gnus-article-smiley-mule-loaded-p t)))
2064 (gnus-with-article-buffer
2065 (if (memq 'smiley gnus-article-wash-types)
2066 (gnus-delete-images 'smiley)
2068 (let ((images (smiley-region (point) (point-max))))
2070 (gnus-add-wash-type 'smiley)
2071 (dolist (image images)
2072 (gnus-add-image 'smiley image)))))))
2074 (defun gnus-article-remove-images ()
2075 "Remove all images from the article buffer."
2077 (gnus-with-article-buffer
2078 (dolist (elem gnus-article-image-alist)
2079 (gnus-delete-images (car elem)))))
2081 (defun gnus-article-treat-fold-newsgroups ()
2082 "Unfold folded message headers.
2083 Only the headers that fit into the current window width will be
2086 (gnus-with-article-headers
2087 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2089 (mail-header-narrow-to-field)
2090 (while (re-search-forward ", *" nil t)
2091 (replace-match ", " t t))
2092 (mail-header-fold-field)
2093 (goto-char (point-max))))))
2095 (defun gnus-article-treat-body-boundary ()
2096 "Place a boundary line at the end of the headers."
2098 (when (and gnus-body-boundary-delimiter
2099 (> (length gnus-body-boundary-delimiter) 0))
2100 (gnus-with-article-headers
2101 (goto-char (point-max))
2102 (let ((start (point)))
2103 (insert "X-Boundary: ")
2104 (gnus-add-text-properties start (point) '(invisible t intangible t))
2106 (while (>= (1- (window-width)) (length str))
2107 (setq str (concat str gnus-body-boundary-delimiter)))
2108 (substring str 0 (1- (window-width))))
2110 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2112 (defun article-fill-long-lines ()
2113 "Fill lines that are wider than the window width."
2116 (let ((buffer-read-only nil)
2117 (width (window-width (get-buffer-window (current-buffer)))))
2120 (let ((adaptive-fill-mode nil)) ;Why? -sm
2123 (when (>= (current-column) (min fill-column width))
2124 (narrow-to-region (min (1+ (point)) (point-max))
2126 (let ((goback (point-marker)))
2127 (fill-paragraph nil)
2128 (goto-char (marker-position goback)))
2130 (forward-line 1)))))))
2132 (defun article-capitalize-sentences ()
2133 "Capitalize the first word in each sentence."
2136 (let ((buffer-read-only nil)
2137 (paragraph-start "^[\n\^L]"))
2141 (forward-sentence)))))
2143 (defun article-remove-cr ()
2144 "Remove trailing CRs and then translate remaining CRs into LFs."
2147 (let ((buffer-read-only nil))
2148 (goto-char (point-min))
2149 (while (re-search-forward "\r+$" nil t)
2150 (replace-match "" t t))
2151 (goto-char (point-min))
2152 (while (search-forward "\r" nil t)
2153 (replace-match "\n" t t)))))
2155 (defun article-remove-trailing-blank-lines ()
2156 "Remove all trailing blank lines from the article."
2159 (let ((buffer-read-only nil))
2160 (goto-char (point-max))
2164 (while (and (not (bobp))
2165 (looking-at "^[ \t]*$")
2166 (not (gnus-annotation-in-region-p
2167 (point) (point-at-eol))))
2172 (defun article-display-face ()
2173 "Display any Face headers in the header."
2175 (let ((wash-face-p buffer-read-only))
2176 (gnus-with-article-headers
2177 ;; When displaying parts, this function can be called several times on
2178 ;; the same article, without any intended toggle semantic (as typing `W
2179 ;; D d' would have). So face deletion must occur only when we come from
2180 ;; an interactive command, that is when the *Article* buffer is
2182 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2183 (gnus-delete-images 'face)
2186 (when (and wash-face-p
2188 (goto-char (point-min))
2189 (not (re-search-forward "^Face:[\t ]*" nil t)))
2190 (gnus-buffer-live-p gnus-original-article-buffer))
2191 (set-buffer gnus-original-article-buffer))
2193 (mail-narrow-to-head)
2194 (while (gnus-article-goto-header "Face")
2195 (push (mail-header-field-value) faces))))
2196 (while (setq face (pop faces))
2197 (let ((png (gnus-convert-face-to-png face))
2200 (setq image (gnus-create-image png 'png t))
2201 (gnus-article-goto-header "from")
2203 (insert "From: [no `from' set]\n")
2205 (gnus-add-wash-type 'face)
2206 (gnus-add-image 'face image)
2207 (gnus-put-image image nil 'face))))))
2210 (defun article-display-x-face (&optional force)
2211 "Look for an X-Face header and display it if present."
2212 (interactive (list 'force))
2213 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2214 (gnus-with-article-headers
2215 ;; Delete the old process, if any.
2216 (when (process-status "article-x-face")
2217 (delete-process "article-x-face"))
2218 ;; See the comment in `article-display-face'.
2219 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2220 ;; We have already displayed X-Faces, so we remove them
2222 (gnus-delete-images 'xface)
2224 (let (x-faces from face)
2226 (when (and wash-face-p
2228 (goto-char (point-min))
2229 (not (re-search-forward
2230 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2231 (gnus-buffer-live-p gnus-original-article-buffer))
2232 ;; If type `W f', use gnus-original-article-buffer,
2233 ;; otherwise use the current buffer because displaying
2234 ;; RFC822 parts calls this function too.
2235 (set-buffer gnus-original-article-buffer))
2237 (mail-narrow-to-head)
2238 (while (gnus-article-goto-header "X-Face")
2239 (push (mail-header-field-value) x-faces))
2240 (setq from (message-fetch-field "from"))))
2241 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2242 ;; single external face.
2243 (when (stringp gnus-article-x-face-command)
2244 (setq x-faces (list (car x-faces))))
2245 (while (and (setq face (pop x-faces))
2246 gnus-article-x-face-command
2248 ;; Check whether this face is censored.
2249 (not gnus-article-x-face-too-ugly)
2250 (and gnus-article-x-face-too-ugly from
2251 (not (string-match gnus-article-x-face-too-ugly
2253 ;; We display the face.
2254 (cond ((stringp gnus-article-x-face-command)
2255 ;; The command is a string, so we interpret the command
2256 ;; as a, well, command, and fork it off.
2257 (let ((process-connection-type nil))
2258 (process-kill-without-query
2260 "article-x-face" nil shell-file-name
2261 shell-command-switch gnus-article-x-face-command))
2264 (process-send-region "article-x-face"
2265 (point-min) (point-max)))
2266 (process-send-eof "article-x-face")))
2267 ((functionp gnus-article-x-face-command)
2268 ;; The command is a lisp function, so we call it.
2269 (funcall gnus-article-x-face-command face))
2271 (error "%s is not a function"
2272 gnus-article-x-face-command)))))))))
2274 (defun article-decode-mime-words ()
2275 "Decode all MIME-encoded words in the article."
2277 (gnus-with-article-buffer
2278 (let ((inhibit-point-motion-hooks t)
2279 (mail-parse-charset gnus-newsgroup-charset)
2280 (mail-parse-ignored-charsets
2281 (with-current-buffer gnus-summary-buffer
2282 gnus-newsgroup-ignored-charsets)))
2283 (mail-decode-encoded-word-region (point-min) (point-max)))))
2285 (defun article-decode-charset (&optional prompt)
2286 "Decode charset-encoded text in the article.
2287 If PROMPT (the prefix), prompt for a coding system to use."
2289 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2291 (mail-parse-charset gnus-newsgroup-charset)
2292 (mail-parse-ignored-charsets
2293 (save-excursion (condition-case nil
2294 (set-buffer gnus-summary-buffer)
2296 gnus-newsgroup-ignored-charsets))
2297 ct cte ctl charset format)
2300 (article-narrow-to-head)
2301 (setq ct (message-fetch-field "Content-Type" t)
2302 cte (message-fetch-field "Content-Transfer-Encoding" t)
2303 ctl (and ct (ignore-errors
2304 (mail-header-parse-content-type ct)))
2307 (mm-read-coding-system "Charset to decode: "))
2309 (mail-content-type-get ctl 'charset)))
2310 format (and ctl (mail-content-type-get ctl 'format)))
2312 (setq cte (mail-header-strip cte)))
2313 (if (and ctl (not (string-match "/" (car ctl))))
2315 (goto-char (point-max)))
2318 (narrow-to-region (point) (point-max))
2319 (when (and (eq mail-parse-charset 'gnus-decoded)
2320 (eq (mm-body-7-or-8) '8bit))
2321 ;; The text code could have been decoded.
2322 (setq charset mail-parse-charset))
2323 (when (and (or (not ctl)
2324 (equal (car ctl) "text/plain"))
2325 (not format)) ;; article with format will decode later.
2327 charset (and cte (intern (downcase
2328 (gnus-strip-whitespace cte))))
2331 (defun article-decode-encoded-words ()
2332 "Remove encoded-word encoding from headers."
2333 (let (buffer-read-only)
2334 (let ((charset (save-excursion
2335 (set-buffer gnus-summary-buffer)
2336 default-mime-charset)))
2337 (mime-decode-header-in-buffer charset))))
2339 (defun article-decode-group-name ()
2340 "Decode group names in `Newsgroups:'."
2341 (let ((inhibit-point-motion-hooks t)
2343 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2344 (when (and (or gnus-group-name-charset-method-alist
2345 gnus-group-name-charset-group-alist)
2346 (gnus-buffer-live-p gnus-original-article-buffer))
2348 (article-narrow-to-head)
2349 (with-current-buffer gnus-original-article-buffer
2350 (goto-char (point-min)))
2351 (while (re-search-forward
2352 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2353 (replace-match (save-match-data
2354 (gnus-decode-newsgroups
2355 ;; XXX how to use data in article buffer?
2356 (with-current-buffer gnus-original-article-buffer
2358 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2361 gnus-newsgroup-name method))
2363 (goto-char (point-min))
2364 (with-current-buffer gnus-original-article-buffer
2365 (goto-char (point-min)))
2366 (while (re-search-forward
2367 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2368 (replace-match (save-match-data
2369 (gnus-decode-newsgroups
2370 ;; XXX how to use data in article buffer?
2371 (with-current-buffer gnus-original-article-buffer
2373 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2376 gnus-newsgroup-name method))
2379 (autoload 'idna-to-unicode "idna")
2381 (defun article-decode-idna-rhs ()
2382 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2385 (let ((inhibit-point-motion-hooks t)
2387 (article-narrow-to-head)
2388 (goto-char (point-min))
2389 (while (re-search-forward "\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2391 (when (save-match-data
2392 (and (setq ace (match-string 1))
2394 (and (re-search-backward "^[^ \t]" nil t)
2395 (looking-at "From\\|To\\|Cc")))
2396 (save-excursion (backward-char)
2397 (message-idna-inside-rhs-p))
2398 (setq unicode (idna-to-unicode ace))))
2399 (unless (string= ace unicode)
2400 (replace-match unicode nil nil nil 1)))))))))
2402 (defun article-de-quoted-unreadable (&optional force read-charset)
2403 "Translate a quoted-printable-encoded article.
2404 If FORCE, decode the article whether it is marked as quoted-printable
2406 If READ-CHARSET, ask for a coding system."
2407 (interactive (list 'force current-prefix-arg))
2409 (let ((buffer-read-only nil) type charset)
2410 (if (gnus-buffer-live-p gnus-original-article-buffer)
2411 (with-current-buffer gnus-original-article-buffer
2413 (gnus-fetch-field "content-transfer-encoding"))
2414 (let* ((ct (gnus-fetch-field "content-type"))
2417 (mail-header-parse-content-type ct)))))
2418 (setq charset (and ctl
2419 (mail-content-type-get ctl 'charset)))
2420 (if (stringp charset)
2421 (setq charset (intern (downcase charset)))))))
2423 (setq charset (mm-read-coding-system "Charset: " charset)))
2425 (setq charset gnus-newsgroup-charset))
2427 (and type (let ((case-fold-search t))
2428 (string-match "quoted-printable" type))))
2430 (quoted-printable-decode-region
2431 (point) (point-max) (mm-charset-to-coding-system charset))))))
2433 (defun article-de-base64-unreadable (&optional force read-charset)
2434 "Translate a base64 article.
2435 If FORCE, decode the article whether it is marked as base64 not.
2436 If READ-CHARSET, ask for a coding system."
2437 (interactive (list 'force current-prefix-arg))
2439 (let ((buffer-read-only nil) type charset)
2440 (if (gnus-buffer-live-p gnus-original-article-buffer)
2441 (with-current-buffer gnus-original-article-buffer
2443 (gnus-fetch-field "content-transfer-encoding"))
2444 (let* ((ct (gnus-fetch-field "content-type"))
2447 (mail-header-parse-content-type ct)))))
2448 (setq charset (and ctl
2449 (mail-content-type-get ctl 'charset)))
2450 (if (stringp charset)
2451 (setq charset (intern (downcase charset)))))))
2453 (setq charset (mm-read-coding-system "Charset: " charset)))
2455 (setq charset gnus-newsgroup-charset))
2457 (and type (let ((case-fold-search t))
2458 (string-match "base64" type))))
2461 (narrow-to-region (point) (point-max))
2462 (base64-decode-region (point-min) (point-max))
2463 (mm-decode-coding-region
2464 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2469 (defun article-decode-HZ ()
2470 "Translate a HZ-encoded article."
2474 (let ((buffer-read-only nil))
2475 (rfc1843-decode-region (point-min) (point-max)))))
2477 (defun article-unsplit-urls ()
2478 "Remove the newlines that some other mailers insert into URLs."
2481 (let ((buffer-read-only nil))
2482 (goto-char (point-min))
2483 (while (re-search-forward
2484 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2485 (replace-match "\\1\\3" t)))
2486 (when (interactive-p)
2487 (gnus-treat-article nil))))
2490 (defun article-wash-html (&optional read-charset)
2491 "Format an HTML article.
2492 If READ-CHARSET, ask for a coding system."
2495 (let ((buffer-read-only nil)
2497 (when (gnus-buffer-live-p gnus-original-article-buffer)
2498 (with-current-buffer gnus-original-article-buffer
2499 (let* ((ct (gnus-fetch-field "content-type"))
2502 (mail-header-parse-content-type ct)))))
2503 (setq charset (and ctl
2504 (mail-content-type-get ctl 'charset)))
2505 (when (stringp charset)
2506 (setq charset (intern (downcase charset)))))))
2508 (setq charset (mm-read-coding-system "Charset: " charset)))
2510 (setq charset gnus-newsgroup-charset))
2512 (save-window-excursion
2514 (narrow-to-region (point) (point-max))
2515 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2516 (entry (assq func mm-text-html-washer-alist)))
2518 (setq func (cdr entry)))
2523 (apply (car func) (cdr func))))))))))
2525 (defun gnus-article-wash-html-with-w3 ()
2526 "Wash the current buffer with w3."
2528 (let ((w3-strict-width (window-width))
2529 (url-standalone-mode t)
2530 (url-gateway-unplugged t)
2531 (w3-honor-stylesheets nil))
2533 (w3-region (point-min) (point-max))
2536 (defun gnus-article-wash-html-with-w3m ()
2537 "Wash the current buffer with emacs-w3m."
2540 (narrow-to-region (point) (point-max))
2541 (let ((w3m-safe-url-regexp (if mm-inline-text-html-with-images
2544 w3m-force-redisplay)
2545 (w3m-region (point-min) (point-max)))
2546 (when (and mm-inline-text-html-with-w3m-keymap
2547 (boundp 'w3m-minor-mode-map)
2549 (add-text-properties
2550 (point-min) (point-max)
2551 (list 'keymap w3m-minor-mode-map
2552 ;; Put the mark meaning this part was rendered by emacs-w3m.
2553 'mm-inline-text-html-with-w3m t)))))
2555 (defun article-hide-list-identifiers ()
2556 "Remove list identifies from the Subject header.
2557 The `gnus-list-identifiers' variable specifies what to do."
2559 (let ((inhibit-point-motion-hooks t)
2560 (regexp (if (consp gnus-list-identifiers)
2561 (mapconcat 'identity gnus-list-identifiers " *\\|")
2562 gnus-list-identifiers))
2567 (article-narrow-to-head)
2568 (goto-char (point-min))
2569 (while (re-search-forward
2570 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2572 (delete-region (match-beginning 2) (match-end 0))
2573 (beginning-of-line))
2574 (when (re-search-forward
2575 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2576 (delete-region (match-beginning 1) (match-end 1))))))))
2578 (defun article-hide-pem (&optional arg)
2579 "Toggle hiding of any PEM headers and signatures in the current article.
2580 If given a negative prefix, always show; if given a positive prefix,
2582 (interactive (gnus-article-hidden-arg))
2583 (unless (gnus-article-check-hidden-text 'pem arg)
2585 (let (buffer-read-only end)
2586 (goto-char (point-min))
2587 ;; Hide the horrendously ugly "header".
2588 (when (and (search-forward
2589 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2591 (setq end (1+ (match-beginning 0))))
2592 (gnus-add-wash-type 'pem)
2593 (gnus-article-hide-text-type
2595 (if (search-forward "\n\n" nil t)
2599 ;; Hide the trailer as well
2600 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2602 (gnus-article-hide-text-type
2603 (match-beginning 0) (match-end 0) 'pem)))))))
2605 (defun article-strip-banner ()
2606 "Strip the banners specified by the `banner' group parameter and by
2607 `gnus-article-address-banner-alist'."
2611 (let ((inhibit-point-motion-hooks t))
2612 (when (gnus-parameter-banner gnus-newsgroup-name)
2613 (article-really-strip-banner
2614 (gnus-parameter-banner gnus-newsgroup-name)))
2615 (when gnus-article-address-banner-alist
2616 (article-really-strip-banner
2617 (let ((from (save-restriction
2619 (article-narrow-to-head)
2620 (mail-fetch-field "from"))))
2623 (caar (mail-header-parse-addresses from))))
2625 (dolist (pair gnus-article-address-banner-alist)
2626 (when (string-match (car pair) from)
2627 (throw 'found (cdr pair)))))))))))))
2629 (defun article-really-strip-banner (banner)
2630 "Strip the banner specified by the argument."
2633 (let ((inhibit-point-motion-hooks t)
2634 (gnus-signature-limit nil)
2638 ((eq banner 'signature)
2639 (when (gnus-article-narrow-to-signature)
2642 (delete-region (point) (point-max))))
2644 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2645 (while (re-search-forward banner nil t)
2646 (delete-region (match-beginning 0) (match-end 0)))))
2648 (while (re-search-forward banner nil t)
2649 (delete-region (match-beginning 0) (match-end 0)))))))))
2651 (defun article-babel ()
2652 "Translate article using an online translation service."
2655 (gnus-with-article-buffer
2656 (when (article-goto-body)
2657 (let* ((start (point))
2659 (orig (buffer-substring start end))
2660 (trans (babel-as-string orig)))
2662 (narrow-to-region start end)
2663 (delete-region start end)
2666 (defun article-hide-signature (&optional arg)
2667 "Hide the signature in the current article.
2668 If given a negative prefix, always show; if given a positive prefix,
2670 (interactive (gnus-article-hidden-arg))
2676 (article-goto-body))
2677 (goto-char (point-min)))
2678 (unless (gnus-article-check-hidden-text 'signature arg)
2679 (let ((buffer-read-only nil)
2681 (while (setq button (text-property-any button (point-max)
2683 'gnus-signature-toggle))
2684 (setq button (text-property-not-all button (point-max)
2686 'gnus-signature-toggle))
2687 (when (and button (not (eobp)))
2688 (gnus-article-hide-text-type
2690 (next-single-property-change (1+ button) 'mime-view-entity
2693 (gnus-set-mode-line 'article))
2695 (defun article-strip-headers-in-body ()
2696 "Strip offensive headers from bodies."
2700 (let ((case-fold-search t))
2701 (when (looking-at "x-no-archive:")
2702 (gnus-delete-line)))))
2704 (defun article-strip-leading-blank-lines ()
2705 "Remove all blank lines from the beginning of the article."
2708 (let ((inhibit-point-motion-hooks t)
2710 (when (article-goto-body)
2711 (while (and (not (eobp))
2712 (looking-at "[ \t]*$"))
2713 (gnus-delete-line))))))
2715 (defun article-narrow-to-head ()
2716 "Narrow the buffer to the head of the message.
2717 Point is left at the beginning of the narrowed-to region."
2719 (goto-char (point-min))
2720 (if (search-forward "\n\n" nil 1)
2723 (goto-char (point-min)))
2725 (defun article-goto-body ()
2726 "Place point at the start of the body."
2727 (goto-char (point-min))
2729 ;; This variable is only bound when dealing with separate
2731 (article-goto-body-goes-to-point-min-p
2733 ((search-forward "\n\n" nil t)
2736 (goto-char (point-max))
2739 (defun article-strip-multiple-blank-lines ()
2740 "Replace consecutive blank lines with one empty line."
2743 (let ((inhibit-point-motion-hooks t)
2745 ;; First make all blank lines empty.
2747 (while (re-search-forward "^[ \t]+$" nil t)
2748 (unless (gnus-annotation-in-region-p
2749 (match-beginning 0) (match-end 0))
2750 (replace-match "" nil t)))
2751 ;; Then replace multiple empty lines with a single empty line.
2753 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2754 (unless (gnus-annotation-in-region-p
2755 (match-beginning 0) (match-end 0))
2756 (delete-region (match-beginning 1) (match-end 1)))))))
2758 (defun article-strip-leading-space ()
2759 "Remove all white space from the beginning of the lines in the article."
2762 (let ((inhibit-point-motion-hooks t)
2765 (while (re-search-forward "^[ \t]+" nil t)
2766 (replace-match "" t t)))))
2768 (defun article-strip-trailing-space ()
2769 "Remove all white space from the end of the lines in the article."
2772 (let ((inhibit-point-motion-hooks t)
2775 (while (re-search-forward "[ \t]+$" nil t)
2776 (replace-match "" t t)))))
2778 (defun article-strip-blank-lines ()
2779 "Strip leading, trailing and multiple blank lines."
2781 (article-strip-leading-blank-lines)
2782 (article-remove-trailing-blank-lines)
2783 (article-strip-multiple-blank-lines))
2785 (defun article-strip-all-blank-lines ()
2786 "Strip all blank lines."
2789 (let ((inhibit-point-motion-hooks t)
2792 (while (re-search-forward "^[ \t]*\n" nil t)
2793 (replace-match "" t t)))))
2795 (defun gnus-article-narrow-to-signature ()
2796 "Narrow to the signature; return t if a signature is found, else nil."
2797 (let ((inhibit-point-motion-hooks t))
2798 (when (gnus-article-search-signature)
2800 ;; Check whether we have some limits to what we consider
2801 ;; to be a signature.
2802 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2803 (list gnus-signature-limit)))
2805 (while (setq limit (pop limits))
2806 (if (or (and (integerp limit)
2807 (< (- (point-max) (point)) limit))
2809 (< (count-lines (point) (point-max)) limit))
2810 (and (functionp limit)
2812 (and (stringp limit)
2813 (not (re-search-forward limit nil t))))
2814 () ; This limit did not succeed.
2818 (narrow-to-region (point) (point-max))
2821 (defun gnus-article-search-signature ()
2822 "Search the current buffer for the signature separator.
2823 Put point at the beginning of the signature separator."
2824 (let ((cur (point)))
2825 (goto-char (point-max))
2826 (if (if (stringp gnus-signature-separator)
2827 (re-search-backward gnus-signature-separator nil t)
2828 (let ((seps gnus-signature-separator))
2830 (not (re-search-backward (car seps) nil t)))
2837 (defun gnus-article-hidden-arg ()
2838 "Return the current prefix arg as a number, or 0 if no prefix."
2839 (list (if current-prefix-arg
2840 (prefix-numeric-value current-prefix-arg)
2843 (defun gnus-article-check-hidden-text (type arg)
2844 "Return nil if hiding is necessary.
2845 Arg can be nil or a number. nil and positive means hide, negative
2846 means show, 0 means toggle."
2849 (let ((hide (gnus-article-hidden-text-p type)))
2855 (gnus-article-show-hidden-text type)
2858 (if (eq hide 'hidden)
2860 (gnus-article-show-hidden-text type)
2864 (defun gnus-article-hidden-text-p (type)
2865 "Say whether the current buffer contains hidden text of type TYPE."
2866 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2868 (not (get-text-property pos 'invisible))
2869 (not (get-text-property pos 'dummy-invisible)))
2871 (text-property-any (1+ pos) (point-max) 'article-type type)))
2876 (defun gnus-article-show-hidden-text (type &optional dummy)
2877 "Show all hidden text of type TYPE.
2878 Originally it is hide instead of DUMMY."
2879 (let ((buffer-read-only nil)
2880 (inhibit-point-motion-hooks t))
2881 (gnus-remove-text-properties-when
2883 (point-min) (point-max)
2884 (cons 'article-type (cons type
2885 gnus-hidden-properties)))
2886 (gnus-delete-wash-type type)))
2888 (defconst article-time-units
2889 `((year . ,(* 365.25 24 60 60))
2890 (week . ,(* 7 24 60 60))
2891 (day . ,(* 24 60 60))
2895 "Mapping from time units to seconds.")
2897 (defun gnus-article-forward-header ()
2898 "Move point to the start of the next header.
2899 If the current header is a continuation header, this can be several
2904 (if (looking-at "[ \t]+[^ \t]")
2908 (defun article-date-ut (&optional type highlight header)
2909 "Convert DATE date to universal time in the current article.
2910 If TYPE is `local', convert to local time; if it is `lapsed', output
2911 how much time has lapsed since DATE. For `lapsed', the value of
2912 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2913 should replace the \"Date:\" one, or should be added below it."
2914 (interactive (list 'ut t))
2915 (let* ((header (or header
2916 (and (eq 1 (point-min))
2917 (mail-header-date (save-excursion
2918 (set-buffer gnus-summary-buffer)
2919 gnus-current-headers)))
2920 (message-fetch-field "date")
2922 (date (if (vectorp header) (mail-header-date header)
2924 (inhibit-point-motion-hooks t)
2925 bface eface date-pos)
2926 (when (and date (not (string= date "")))
2929 (article-narrow-to-head)
2930 (when (or (and (eq type 'lapsed)
2931 gnus-article-date-lapsed-new-header
2932 ;; Attempt to get the face of X-Sent first.
2933 (re-search-forward "^X-Sent:[ \t]" nil t))
2934 (re-search-forward "^Date:[ \t]" nil t)
2935 ;; If Date is missing, try again for X-Sent.
2936 (re-search-forward "^X-Sent:[ \t]" nil t))
2937 (setq bface (get-text-property (point-at-bol) 'face)
2938 date (or (get-text-property (point-at-bol)
2941 eface (get-text-property (1- (point-at-eol))
2943 (let ((buffer-read-only nil))
2944 ;; Delete any old X-Sent headers.
2945 (when (setq date-pos
2946 (text-property-any (point-min) (point-max)
2947 'article-date-lapsed t))
2948 (goto-char (setq date-pos (set-marker (make-marker) date-pos)))
2949 (delete-region (match-beginning 0)
2950 (progn (forward-line 1) (point))))
2951 (goto-char (point-min))
2952 ;; Delete any old Date headers.
2953 (while (re-search-forward "^Date:[ \t]" nil t)
2955 (setq date-pos (match-beginning 0)))
2956 (unless (and (eq type 'lapsed)
2957 gnus-article-date-lapsed-new-header)
2958 (delete-region (match-beginning 0)
2959 (progn (message-next-header) (point)))))
2962 (goto-char date-pos)
2964 ;; Possibly, Date has been deleted.
2966 (when (and (eq type 'lapsed)
2967 gnus-article-date-lapsed-new-header
2968 (looking-at "Date:"))
2970 (goto-char (point-min)))
2971 (insert (article-make-date-line date type))
2972 (when (eq type 'lapsed)
2973 (put-text-property (point-at-bol) (point)
2974 'article-date-lapsed t))
2978 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2979 (put-text-property (match-beginning 1) (1+ (match-end 1))
2980 'original-date date)
2981 (put-text-property (match-beginning 1) (1+ (match-end 1))
2983 (put-text-property (match-beginning 2) (match-end 2)
2986 (defun article-make-date-line (date type)
2987 "Return a DATE line of TYPE."
2988 (unless (memq type '(local ut original user iso8601 lapsed english))
2989 (error "Unknown conversion type: %s" type))
2991 (let ((time (date-to-time date)))
2993 ;; Convert to the local timezone.
2995 (let ((tz (car (current-time-zone time))))
2996 (format "Date: %s %s%02d%02d" (current-time-string time)
2997 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2998 (/ (% (abs tz) 3600) 60))))
2999 ;; Convert to Universal Time.
3002 (current-time-string
3003 (let* ((e (parse-time-string date))
3004 (tm (apply 'encode-time e))
3006 (ls (- (cadr tm) (car (current-time-zone time)))))
3007 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
3008 ((> ls 65535) (list (1+ ms) (- ls 65536)))
3011 ;; Get the original date from the article.
3012 ((eq type 'original)
3013 (concat "Date: " (if (string-match "\n+$" date)
3014 (substring date 0 (match-beginning 0))
3016 ;; Let the user define the format.
3018 (let ((format (or (condition-case nil
3019 (with-current-buffer gnus-summary-buffer
3020 gnus-article-time-format)
3022 gnus-article-time-format)))
3023 (if (functionp format)
3024 (funcall format time)
3025 (concat "Date: " (format-time-string format time)))))
3028 (let ((tz (car (current-time-zone time))))
3031 (format-time-string "%Y%m%dT%H%M%S" time)
3032 (format "%s%02d%02d"
3033 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
3034 (/ (% (abs tz) 3600) 60)))))
3035 ;; Do an X-Sent lapsed format.
3037 ;; If the date is seriously mangled, the timezone functions are
3038 ;; liable to bug out, so we ignore all errors.
3039 (let* ((now (current-time))
3040 (real-time (subtract-time now time))
3041 (real-sec (and real-time
3042 (+ (* (float (car real-time)) 65536)
3044 (sec (and real-time (abs real-sec)))
3054 ;; This is a bit convoluted, but basically we go
3055 ;; through the time units for years, weeks, etc,
3056 ;; and divide things to see whether that results
3057 ;; in positive answers.
3060 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
3061 ;; The (remaining) seconds are too few to
3062 ;; be divided into this time unit.
3064 ;; It's big enough, so we output it.
3065 (setq sec (- sec (* num (cdr unit))))
3067 (concat (if prev ", " "") (int-to-string
3069 " " (symbol-name (car unit))
3070 (if (> num 1) "s" ""))
3072 article-time-units "")
3073 ;; If dates are odd, then it might appear like the
3074 ;; article was sent in the future.
3077 " in the future"))))))
3078 ;; Display the date in proper English
3080 (let ((dtime (decode-time time)))
3083 (number-to-string (nth 3 dtime))
3084 (let ((digit (% (nth 3 dtime) 10)))
3086 ((memq (nth 3 dtime) '(11 12 13)) "th")
3092 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3094 (number-to-string (nth 5 dtime))
3096 (format "%02d" (nth 2 dtime))
3098 (format "%02d" (nth 1 dtime)))))))
3100 (format "Date: %s (from T-gnus)" date))))
3102 (defun article-date-local (&optional highlight)
3103 "Convert the current article date to the local timezone."
3104 (interactive (list t))
3105 (article-date-ut 'local highlight))
3107 (defun article-date-english (&optional highlight)
3108 "Convert the current article date to something that is proper English."
3109 (interactive (list t))
3110 (article-date-ut 'english highlight))
3112 (defun article-date-original (&optional highlight)
3113 "Convert the current article date to what it was originally.
3114 This is only useful if you have used some other date conversion
3115 function and want to see what the date was before converting."
3116 (interactive (list t))
3117 (article-date-ut 'original highlight))
3119 (defun article-date-lapsed (&optional highlight)
3120 "Convert the current article date to time lapsed since it was sent."
3121 (interactive (list t))
3122 (article-date-ut 'lapsed highlight))
3124 (defun article-update-date-lapsed ()
3125 "Function to be run from a timer to update the lapsed time line."
3126 (let (deactivate-mark)
3131 (set-buffer (window-buffer w))
3132 (when (eq major-mode 'gnus-article-mode)
3133 (let ((mark (point-marker)))
3134 (goto-char (point-min))
3135 (when (re-search-forward "^X-Sent:" nil t)
3136 (article-date-lapsed t))
3137 (goto-char (marker-position mark))
3138 (move-marker mark nil))))
3141 (defun gnus-start-date-timer (&optional n)
3142 "Start a timer to update the X-Sent header in the article buffers.
3143 The numerical prefix says how frequently (in seconds) the function
3148 (gnus-stop-date-timer)
3149 (setq article-lapsed-timer
3150 (run-at-time 1 n 'article-update-date-lapsed)))
3152 (defun gnus-stop-date-timer ()
3153 "Stop the X-Sent timer."
3155 (when article-lapsed-timer
3156 (nnheader-cancel-timer article-lapsed-timer)
3157 (setq article-lapsed-timer nil)))
3159 (defun article-date-user (&optional highlight)
3160 "Convert the current article date to the user-defined format.
3161 This format is defined by the `gnus-article-time-format' variable."
3162 (interactive (list t))
3163 (article-date-ut 'user highlight))
3165 (defun article-date-iso8601 (&optional highlight)
3166 "Convert the current article date to ISO8601."
3167 (interactive (list t))
3168 (article-date-ut 'iso8601 highlight))
3170 ;; (defun article-show-all ()
3171 ;; "Show all hidden text in the article buffer."
3175 ;; (let ((buffer-read-only nil))
3176 ;; (gnus-article-unhide-text (point-min) (point-max))
3177 ;; (gnus-remove-text-with-property 'gnus-prev)
3178 ;; (gnus-remove-text-with-property 'gnus-next))))
3180 (defun article-show-all-headers ()
3181 "Show all hidden headers in the article buffer."
3186 (article-narrow-to-head)
3187 (let ((buffer-read-only nil))
3188 (gnus-article-unhide-text (point-min) (point-max))))))
3190 (defun article-remove-leading-whitespace ()
3191 "Remove excessive whitespace from all headers."
3195 (let ((buffer-read-only nil))
3196 (article-narrow-to-head)
3197 (goto-char (point-min))
3198 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3199 (delete-region (match-beginning 1) (match-end 1)))))))
3201 (defun article-emphasize (&optional arg)
3202 "Emphasize text according to `gnus-emphasis-alist'."
3203 (interactive (gnus-article-hidden-arg))
3204 (unless (gnus-article-check-hidden-text 'emphasis arg)
3208 (with-current-buffer gnus-summary-buffer
3209 gnus-article-emphasis-alist)
3211 gnus-emphasis-alist))
3212 (buffer-read-only nil)
3213 (props (append '(article-type emphasis)
3214 gnus-hidden-properties))
3215 regexp elem beg invisible visible face)
3218 (while (setq elem (pop alist))
3220 (setq regexp (car elem)
3221 invisible (nth 1 elem)
3222 visible (nth 2 elem)
3224 (while (re-search-forward regexp nil t)
3225 (when (and (match-beginning visible) (match-beginning invisible))
3226 (gnus-article-hide-text
3227 (match-beginning invisible) (match-end invisible) props)
3228 (gnus-article-unhide-text-type
3229 (match-beginning visible) (match-end visible) 'emphasis)
3230 (gnus-put-overlay-excluding-newlines
3231 (match-beginning visible) (match-end visible) 'face face)
3232 (gnus-add-wash-type 'emphasis)
3233 (goto-char (match-end invisible)))))))))
3235 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3236 "Setup newsgroup emphasis alist."
3237 (unless gnus-article-emphasis-alist
3238 (let ((name (and gnus-newsgroup-name
3239 (gnus-group-real-name gnus-newsgroup-name))))
3240 (make-local-variable 'gnus-article-emphasis-alist)
3241 (setq gnus-article-emphasis-alist
3243 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3244 (while (setq elem (pop alist))
3245 (when (and name (string-match (car elem) name))
3247 highlight (copy-sequence (cdr elem)))))
3249 (copy-sequence highlight-words)
3250 (if gnus-newsgroup-name
3251 (copy-sequence (gnus-group-find-parameter
3252 gnus-newsgroup-name 'highlight-words t)))
3253 gnus-emphasis-alist)))))
3256 (defvar gnus-summary-article-menu)
3257 (defvar gnus-summary-post-menu))
3259 ;;; Saving functions.
3261 (defun gnus-article-save (save-buffer file &optional num)
3262 "Save the currently selected article."
3263 (unless gnus-save-all-headers
3264 ;; Remove headers according to `gnus-saved-headers'.
3265 (let ((gnus-visible-headers
3266 (or gnus-saved-headers gnus-visible-headers))
3267 (gnus-article-buffer save-buffer))
3269 (set-buffer save-buffer)
3270 (article-hide-headers 1 t))))
3271 (save-window-excursion
3272 (if (not gnus-default-article-saver)
3273 (error "No default saver is defined")
3274 ;; !!! Magic! The saving functions all save
3275 ;; `gnus-save-article-buffer' (or so they think), but we
3276 ;; bind that variable to our save-buffer.
3277 (set-buffer gnus-article-buffer)
3278 (let* ((gnus-save-article-buffer save-buffer)
3281 ((not gnus-prompt-before-saving) 'default)
3282 ((eq gnus-prompt-before-saving 'always) nil)
3284 (gnus-number-of-articles-to-be-saved
3285 (when (eq gnus-prompt-before-saving t)
3287 (set-buffer gnus-article-current-summary)
3288 (funcall gnus-default-article-saver filename)))))
3290 (defun gnus-read-save-file-name (prompt &optional filename
3291 function group headers variable)
3293 (funcall function group headers (symbol-value variable)))
3298 ((eq filename 'default)
3304 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3307 (if (and gnus-number-of-articles-to-be-saved
3308 (> gnus-number-of-articles-to-be-saved 1))
3309 (format "these %d articles"
3310 gnus-number-of-articles-to-be-saved)
3313 ;; Let the split methods have their say.
3315 ;; No split name was found.
3318 (concat prompt " (default "
3319 (file-name-nondirectory default-name) ") ")
3320 (file-name-directory default-name)
3322 ;; A single group name is returned.
3323 ((stringp split-name)
3325 (funcall function split-name headers
3326 (symbol-value variable)))
3328 (concat prompt " (default "
3329 (file-name-nondirectory default-name) ") ")
3330 (file-name-directory default-name)
3332 ;; A single split name was found
3333 ((= 1 (length split-name))
3334 (let* ((name (expand-file-name
3336 gnus-article-save-directory))
3337 (dir (cond ((file-directory-p name)
3338 (file-name-as-directory name))
3339 ((file-exists-p name) name)
3340 (t gnus-article-save-directory))))
3342 (concat prompt " (default " name ") ")
3344 ;; A list of splits was found.
3346 (setq split-name (nreverse split-name))
3348 (let ((file-name-history
3349 (nconc split-name file-name-history)))
3353 (concat prompt " (`M-p' for defaults) ")
3354 gnus-article-save-directory
3356 gnus-article-save-directory)))
3357 (car (push result file-name-history)))))))
3358 ;; Create the directory.
3359 (gnus-make-directory (file-name-directory file))
3360 ;; If we have read a directory, we append the default file name.
3361 (when (file-directory-p file)
3362 (setq file (expand-file-name (file-name-nondirectory
3364 (file-name-as-directory file))))
3365 ;; Possibly translate some characters.
3366 (nnheader-translate-file-chars file))))))
3367 (gnus-make-directory (file-name-directory result))
3368 (set variable result)))
3370 (defun gnus-article-archive-name (group)
3371 "Return the first instance of an \"Archive-name\" in the current buffer."
3372 (let ((case-fold-search t))
3373 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3374 (nnheader-concat gnus-article-save-directory
3375 (match-string 1)))))
3377 (defun gnus-article-nndoc-name (group)
3378 "If GROUP is an nndoc group, return the name of the parent group."
3379 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3380 (gnus-group-get-parameter group 'save-article-group)))
3382 (defun gnus-summary-save-in-rmail (&optional filename)
3383 "Append this article to Rmail file.
3384 Optional argument FILENAME specifies file name.
3385 Directory to save to is default to `gnus-article-save-directory'."
3386 (setq filename (gnus-read-save-file-name
3387 "Save %s in rmail file:" filename
3388 gnus-rmail-save-name gnus-newsgroup-name
3389 gnus-current-headers 'gnus-newsgroup-last-rmail))
3390 (gnus-eval-in-buffer-window gnus-save-article-buffer
3394 (gnus-output-to-rmail filename))))
3397 (defun gnus-summary-save-in-mail (&optional filename)
3398 "Append this article to Unix mail file.
3399 Optional argument FILENAME specifies file name.
3400 Directory to save to is default to `gnus-article-save-directory'."
3401 (setq filename (gnus-read-save-file-name
3402 "Save %s in Unix mail file:" filename
3403 gnus-mail-save-name gnus-newsgroup-name
3404 gnus-current-headers 'gnus-newsgroup-last-mail))
3405 (gnus-eval-in-buffer-window gnus-save-article-buffer
3409 (if (and (file-readable-p filename)
3410 (file-regular-p filename)
3411 (mail-file-babyl-p filename))
3412 (rmail-output-to-rmail-file filename t)
3413 (gnus-output-to-mail filename)))))
3416 (defun gnus-summary-save-in-file (&optional filename overwrite)
3417 "Append this article to file.
3418 Optional argument FILENAME specifies file name.
3419 Directory to save to is default to `gnus-article-save-directory'."
3420 (setq filename (gnus-read-save-file-name
3421 "Save %s in file:" filename
3422 gnus-file-save-name gnus-newsgroup-name
3423 gnus-current-headers 'gnus-newsgroup-last-file))
3424 (gnus-eval-in-buffer-window gnus-save-article-buffer
3428 (when (and overwrite
3429 (file-exists-p filename))
3430 (delete-file filename))
3431 (gnus-output-to-file filename))))
3434 (defun gnus-summary-write-to-file (&optional filename)
3435 "Write this article to a file, overwriting it if the file exists.
3436 Optional argument FILENAME specifies file name.
3437 The directory to save in defaults to `gnus-article-save-directory'."
3438 (gnus-summary-save-in-file nil t))
3440 (defun gnus-summary-save-body-in-file (&optional filename)
3441 "Append this article body to a file.
3442 Optional argument FILENAME specifies file name.
3443 The directory to save in defaults to `gnus-article-save-directory'."
3444 (setq filename (gnus-read-save-file-name
3445 "Save %s body in file:" filename
3446 gnus-file-save-name gnus-newsgroup-name
3447 gnus-current-headers 'gnus-newsgroup-last-file))
3448 (gnus-eval-in-buffer-window gnus-save-article-buffer
3452 (when (article-goto-body)
3453 (narrow-to-region (point) (point-max)))
3454 (gnus-output-to-file filename))))
3457 (defun gnus-summary-save-in-pipe (&optional command)
3458 "Pipe this article to subprocess."
3460 (cond ((and (eq command 'default)
3461 gnus-last-shell-command)
3462 gnus-last-shell-command)
3467 "Shell command on %s: "
3468 (if (and gnus-number-of-articles-to-be-saved
3469 (> gnus-number-of-articles-to-be-saved 1))
3470 (format "these %d articles"
3471 gnus-number-of-articles-to-be-saved)
3473 gnus-last-shell-command))))
3474 (when (string-equal command "")
3475 (if gnus-last-shell-command
3476 (setq command gnus-last-shell-command)
3477 (error "A command is required")))
3478 (gnus-eval-in-buffer-window gnus-article-buffer
3481 (shell-command-on-region (point-min) (point-max) command nil)))
3482 (setq gnus-last-shell-command command))
3484 (defun gnus-summary-pipe-to-muttprint (&optional command)
3485 "Pipe this article to muttprint."
3486 (setq command (read-string
3487 "Print using command: " gnus-summary-muttprint-program
3488 nil gnus-summary-muttprint-program))
3489 (gnus-summary-save-in-pipe command))
3491 ;;; Article file names when saving.
3493 (defun gnus-capitalize-newsgroup (newsgroup)
3494 "Capitalize NEWSGROUP name."
3495 (when (not (zerop (length newsgroup)))
3496 (concat (char-to-string (upcase (aref newsgroup 0)))
3497 (substring newsgroup 1))))
3499 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3500 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3501 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3502 Otherwise, it is like ~/News/news/group/num."
3505 (concat (if (gnus-use-long-file-name 'not-save)
3506 (gnus-capitalize-newsgroup newsgroup)
3507 (gnus-newsgroup-directory-form newsgroup))
3508 "/" (int-to-string (mail-header-number headers)))
3509 gnus-article-save-directory)))
3511 (string-equal (file-name-directory default)
3512 (file-name-directory last-file))
3513 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3515 (or last-file default))))
3517 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3518 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3519 If variable `gnus-use-long-file-name' is non-nil, it is
3520 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3523 (concat (if (gnus-use-long-file-name 'not-save)
3525 (gnus-newsgroup-directory-form newsgroup))
3526 "/" (int-to-string (mail-header-number headers)))
3527 gnus-article-save-directory)))
3529 (string-equal (file-name-directory default)
3530 (file-name-directory last-file))
3531 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3533 (or last-file default))))
3535 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3536 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3537 If variable `gnus-use-long-file-name' is non-nil, it is
3538 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3541 (if (gnus-use-long-file-name 'not-save)
3544 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3546 gnus-article-save-directory)))
3548 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3549 "Generate file name from sender."
3550 (let ((from (mail-header-from headers)))
3552 (if (and from (string-match "\\([^ <]+\\)@" from))
3553 (match-string 1 from)
3555 gnus-article-save-directory)))
3557 (defun article-verify-x-pgp-sig ()
3560 (if (gnus-buffer-live-p gnus-original-article-buffer)
3561 (let ((sig (with-current-buffer gnus-original-article-buffer
3562 (gnus-fetch-field "X-PGP-Sig")))
3566 (mml2015-clear-verify-function))
3568 (insert-buffer-substring gnus-original-article-buffer)
3569 (setq items (split-string sig))
3570 (message-narrow-to-head)
3571 (let ((inhibit-point-motion-hooks t)
3572 (case-fold-search t))
3573 ;; Don't verify multiple headers.
3574 (setq headers (mapconcat (lambda (header)
3576 (mail-fetch-field header)
3578 (split-string (nth 1 items) ",") "")))
3579 (delete-region (point-min) (point-max))
3580 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3581 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3586 (if (looking-at "^-")
3589 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3590 (insert "Version: " (car items) "\n\n")
3591 (insert (mapconcat 'identity (cddr items) "\n"))
3592 (insert "\n-----END PGP SIGNATURE-----\n")
3593 (let ((mm-security-handle (list (format "multipart/signed"))))
3594 (mml2015-clean-buffer)
3595 (let ((coding-system-for-write (or gnus-newsgroup-charset
3597 (funcall (mml2015-clear-verify-function)))
3599 (or (mm-handle-multipart-ctl-parameter
3600 mm-security-handle 'gnus-details)
3601 (mm-handle-multipart-ctl-parameter
3602 mm-security-handle 'gnus-info)))))
3604 (let (buffer-read-only bface eface)
3606 (message-narrow-to-head)
3607 (goto-char (point-max))
3609 (setq bface (get-text-property (point-at-bol) 'face)
3610 eface (get-text-property (1- (point-at-eol)) 'face))
3611 (message-remove-header "X-Gnus-PGP-Verify")
3612 (if (re-search-forward "^X-PGP-Sig:" nil t)
3614 (goto-char (point-max)))
3615 (narrow-to-region (point) (point))
3616 (insert "X-Gnus-PGP-Verify: " info "\n")
3617 (goto-char (point-min))
3620 (if (not (looking-at "^[ \t]"))
3624 (goto-char (point-min))
3625 (when (looking-at "\\([^:]+\\): *")
3626 (put-text-property (match-beginning 1) (1+ (match-end 1))
3628 (put-text-property (match-end 0) (point-max)
3629 'face eface)))))))))
3631 (defun article-verify-cancel-lock ()
3632 "Verify Cancel-Lock header."
3634 (if (gnus-buffer-live-p gnus-original-article-buffer)
3635 (canlock-verify gnus-original-article-buffer)))
3637 (defun article-monafy ()
3638 "Display body part with mona font."
3640 (unless (if (featurep 'xemacs)
3641 (find-face 'gnus-mona-face)
3642 (facep 'gnus-mona-face))
3643 (require 'navi2ch-mona)
3644 (set-face-font (make-face 'gnus-mona-face) navi2ch-mona-font))
3646 (let ((buffer-read-only nil))
3649 (gnus-make-overlay (point) (point-max))
3650 'face 'gnus-mona-face))))
3657 (setq afunc (car func)
3660 gfunc (intern (format "gnus-%s" func))))
3662 (when (fboundp afunc)
3663 `(lambda (&optional interactive &rest args)
3664 ,(documentation afunc t)
3665 (interactive (list t))
3667 (set-buffer gnus-article-buffer)
3669 (call-interactively ',afunc)
3670 (apply ',afunc args))))))))
3671 '(article-hide-headers
3672 article-verify-x-pgp-sig
3673 article-verify-cancel-lock
3675 article-hide-boring-headers
3676 article-treat-overstrike
3677 article-treat-ansi-sequences
3678 article-fill-long-lines
3679 article-capitalize-sentences
3681 article-remove-leading-whitespace
3682 article-display-x-face
3683 article-display-face
3684 article-de-quoted-unreadable
3685 article-de-base64-unreadable
3688 article-unsplit-urls
3689 article-hide-list-identifiers
3690 article-strip-banner
3693 article-hide-signature
3694 article-strip-headers-in-body
3695 article-remove-trailing-blank-lines
3696 article-strip-leading-blank-lines
3697 article-strip-multiple-blank-lines
3698 article-strip-leading-space
3699 article-strip-trailing-space
3700 article-strip-blank-lines
3701 article-strip-all-blank-lines
3703 article-date-english
3704 article-date-iso8601
3705 article-date-original
3707 article-decode-mime-words
3708 article-decode-charset
3709 article-decode-encoded-words
3713 article-treat-dumbquotes
3714 article-normalize-headers
3715 (article-show-all-headers . gnus-article-show-all-headers)
3716 ;; (article-show-all . gnus-article-show-all)
3720 ;;; Gnus article mode
3723 (put 'gnus-article-mode 'mode-class 'special)
3725 (gnus-define-keys gnus-article-mode-map
3726 " " gnus-article-goto-next-page
3727 "\177" gnus-article-goto-prev-page
3728 [delete] gnus-article-goto-prev-page
3729 [backspace] gnus-article-goto-prev-page
3730 "\C-c^" gnus-article-refer-article
3731 "h" gnus-article-show-summary
3732 "s" gnus-article-show-summary
3733 "\C-c\C-m" gnus-article-mail
3734 "?" gnus-article-describe-briefly
3735 "e" gnus-summary-edit-article
3736 "<" beginning-of-buffer
3738 "\C-c\C-i" gnus-info-find-node
3740 "R" gnus-article-reply-with-original
3741 "F" gnus-article-followup-with-original
3742 "\C-hk" gnus-article-describe-key
3743 "\C-hc" gnus-article-describe-key-briefly
3745 "\C-d" gnus-article-read-summary-keys
3746 "\M-*" gnus-article-read-summary-keys
3747 "\M-#" gnus-article-read-summary-keys
3748 "\M-^" gnus-article-read-summary-keys
3749 "\M-g" gnus-article-read-summary-keys)
3751 ;; Define almost undefined keys to `gnus-article-read-summary-keys'.
3755 (push (char-to-string key) keys)
3757 (dolist (elem (accessible-keymaps gnus-summary-mode-map))
3758 (setq key (car elem))
3759 (when (and (> (length key) 0)
3760 (not (eq 'menu-bar (aref key 0)))
3761 (symbolp (lookup-key gnus-summary-mode-map key)))
3764 (unless (lookup-key gnus-article-mode-map key)
3765 (define-key gnus-article-mode-map key 'gnus-article-read-summary-keys))))
3767 (defun gnus-article-make-menu-bar ()
3768 (unless (boundp 'gnus-article-commands-menu)
3769 (gnus-summary-make-menu-bar))
3770 (gnus-turn-off-edit-menu 'article)
3771 (unless (boundp 'gnus-article-article-menu)
3773 gnus-article-article-menu gnus-article-mode-map ""
3775 ["Scroll forwards" gnus-article-goto-next-page t]
3776 ["Scroll backwards" gnus-article-goto-prev-page t]
3777 ["Show summary" gnus-article-show-summary t]
3778 ["Fetch Message-ID at point" gnus-article-refer-article t]
3779 ["Mail to address at point" gnus-article-mail t]
3780 ["Send a bug report" gnus-bug t]))
3783 gnus-article-treatment-menu gnus-article-mode-map ""
3784 ;; Fixme: this should use :active (and maybe :visible).
3786 ["Hide headers" gnus-article-hide-headers t]
3787 ["Hide signature" gnus-article-hide-signature t]
3788 ["Hide citation" gnus-article-hide-citation t]
3789 ["Treat overstrike" gnus-article-treat-overstrike t]
3790 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
3791 ["Remove carriage return" gnus-article-remove-cr t]
3792 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3793 ["Treat html" gnus-article-wash-html t]
3794 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3795 ["Decode HZ" gnus-article-decode-HZ t]))
3797 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3799 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3801 (gnus-run-hooks 'gnus-article-menu-hook)))
3803 (defun gnus-article-mode ()
3804 "Major mode for displaying an article.
3806 All normal editing commands are switched off.
3808 The following commands are available in addition to all summary mode
3810 \\<gnus-article-mode-map>
3811 \\[gnus-article-next-page]\t Scroll the article one page forwards
3812 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3813 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3814 \\[gnus-article-show-summary]\t Display the summary buffer
3815 \\[gnus-article-mail]\t Send a reply to the address near point
3816 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3817 \\[gnus-info-find-node]\t Go to the Gnus info node"
3819 (gnus-simplify-mode-line)
3820 (setq mode-name "Article")
3821 (setq major-mode 'gnus-article-mode)
3822 (make-local-variable 'minor-mode-alist)
3823 (unless (assq 'gnus-show-mime minor-mode-alist)
3824 (push (list 'gnus-show-mime " MIME") minor-mode-alist))
3825 (use-local-map gnus-article-mode-map)
3826 (when (gnus-visual-p 'article-menu 'menu)
3827 (gnus-article-make-menu-bar)
3828 (when gnus-summary-tool-bar-map
3829 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3830 (gnus-update-format-specifications nil 'article-mode)
3831 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3832 (set (make-local-variable 'gnus-page-broken) nil)
3833 (make-local-variable 'gnus-button-marker-list)
3834 (make-local-variable 'gnus-article-current-summary)
3835 (make-local-variable 'gnus-article-mime-handles)
3836 (make-local-variable 'gnus-article-decoded-p)
3837 (make-local-variable 'gnus-article-mime-handle-alist)
3838 (make-local-variable 'gnus-article-wash-types)
3839 (make-local-variable 'gnus-article-image-alist)
3840 (make-local-variable 'gnus-article-charset)
3841 (make-local-variable 'gnus-article-ignored-charsets)
3842 (gnus-set-default-directory)
3843 (buffer-disable-undo)
3844 (setq buffer-read-only t)
3845 (set-syntax-table gnus-article-mode-syntax-table)
3846 (gnus-run-hooks 'gnus-article-mode-hook))
3848 (defun gnus-article-setup-buffer ()
3849 "Initialize the article buffer."
3850 (let* ((name (if gnus-single-article-buffer "*Article*"
3851 (concat "*Article " gnus-newsgroup-name "*")))
3853 (progn (string-match "\\*Article" name)
3854 (concat " *Original Article"
3855 (substring name (match-end 0))))))
3856 (setq gnus-article-buffer name)
3857 (setq gnus-original-article-buffer original)
3858 (setq gnus-article-mime-handle-alist nil)
3859 ;; This might be a variable local to the summary buffer.
3860 (unless gnus-single-article-buffer
3862 (set-buffer gnus-summary-buffer)
3863 (setq gnus-article-buffer name)
3864 (setq gnus-original-article-buffer original)
3865 (gnus-set-global-variables)))
3866 (gnus-article-setup-highlight-words)
3867 ;; Init original article buffer.
3869 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3870 (set-buffer-multibyte t)
3871 (setq major-mode 'gnus-original-article-mode)
3872 (make-local-variable 'gnus-original-article))
3873 (if (get-buffer name)
3876 (when (and gnus-article-edit-mode
3879 (y-or-n-p "Article mode edit in progress; discard? ")))
3880 (error "Action aborted"))
3881 (set (make-local-variable 'gnus-article-edit-mode) nil)
3882 (buffer-disable-undo)
3883 (setq buffer-read-only t)
3884 ;; This list just keeps growing if we don't reset it.
3885 (setq gnus-button-marker-list nil)
3886 (unless (eq major-mode 'gnus-article-mode)
3887 (gnus-article-mode))
3890 (set-buffer (gnus-get-buffer-create name))
3892 (make-local-variable 'gnus-summary-buffer)
3893 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3894 (current-buffer)))))
3896 ;; Set article window start at LINE, where LINE is the number of lines
3897 ;; from the head of the article.
3898 (defun gnus-article-set-window-start (&optional line)
3900 (gnus-get-buffer-window gnus-article-buffer t)
3902 (set-buffer gnus-article-buffer)
3903 (goto-char (point-min))
3906 (gnus-message 6 "Moved to bookmark")
3907 (search-forward "\n\n" nil t)
3911 ;;; @@ article filters
3914 (defun gnus-article-display-mime-message ()
3915 "Article display method for MIME message."
3916 ;; called from `gnus-original-article-buffer'.
3917 (let (charset all-headers)
3918 (with-current-buffer gnus-summary-buffer
3919 (setq charset default-mime-charset
3920 all-headers gnus-have-all-headers))
3921 (make-local-variable 'default-mime-charset)
3922 (setq default-mime-charset charset)
3923 (with-current-buffer (get-buffer-create gnus-article-buffer)
3924 (make-local-variable 'default-mime-charset)
3925 (setq default-mime-charset charset))
3926 (mime-display-message mime-message-structure
3927 gnus-article-buffer nil gnus-article-mode-map)
3929 (gnus-article-hide-headers nil -1)))
3930 (run-hooks 'gnus-mime-article-prepare-hook))
3932 (defun gnus-article-display-traditional-message ()
3933 "Article display method for traditional message."
3934 (set-buffer gnus-article-buffer)
3935 (let (buffer-read-only)
3937 (insert-buffer-substring gnus-original-article-buffer)))
3939 (defun gnus-article-make-full-mail-header (&optional number charset)
3940 "Create a new mail header structure in a raw article buffer."
3941 (unless (and number charset)
3942 (save-current-buffer
3943 (set-buffer gnus-summary-buffer)
3945 (setq number (or (cdr gnus-article-current) 0)))
3947 (setq charset (or default-mime-charset 'x-ctext)))))
3948 (goto-char (point-min))
3949 (let ((header-end (if (search-forward "\n\n" nil t)
3951 (goto-char (point-max))))
3952 (chars (- (point-max) (point)))
3953 (lines (count-lines (point) (point-max)))
3954 (default-mime-charset charset)
3956 (narrow-to-region (point-min) header-end)
3957 (setq xref (std11-fetch-field "xref"))
3959 (make-full-mail-header
3961 (std11-fetch-field "subject")
3962 (std11-fetch-field "from")
3963 (std11-fetch-field "date")
3964 (std11-fetch-field "message-id")
3965 (std11-fetch-field "references")
3968 (when xref (concat "Xref: " xref)))
3971 (defun gnus-article-prepare (article &optional all-headers header)
3972 "Prepare ARTICLE in article mode buffer.
3973 ARTICLE should either be an article number or a Message-ID.
3974 If ARTICLE is an id, HEADER should be the article headers.
3975 If ALL-HEADERS is non-nil, no headers are hidden."
3977 ;; Make sure we start in a summary buffer.
3978 (unless (eq major-mode 'gnus-summary-mode)
3979 (set-buffer gnus-summary-buffer))
3980 (setq gnus-summary-buffer (current-buffer))
3981 (let* ((gnus-article (if header (mail-header-number header) article))
3982 (summary-buffer (current-buffer))
3983 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3984 (group gnus-newsgroup-name)
3987 (gnus-article-setup-buffer)
3988 (set-buffer gnus-article-buffer)
3989 ;; Deactivate active regions.
3990 (when (and (boundp 'transient-mark-mode)
3991 transient-mark-mode)
3992 (setq mark-active nil))
3993 (if (not (setq result (let ((buffer-read-only nil))
3994 (gnus-request-article-this-buffer
3996 ;; There is no such article.
3998 (when (and (numberp article)
3999 (not (memq article gnus-newsgroup-sparse)))
4000 (setq gnus-article-current
4001 (cons gnus-newsgroup-name article))
4002 (set-buffer gnus-summary-buffer)
4003 (setq gnus-current-article article)
4004 (if (and (memq article gnus-newsgroup-undownloaded)
4005 (not (gnus-online (gnus-find-method-for-group
4006 gnus-newsgroup-name))))
4008 (gnus-summary-set-agent-mark article)
4009 (message "Message marked for downloading"))
4010 (gnus-summary-mark-article article gnus-canceled-mark)
4011 (unless (memq article gnus-newsgroup-sparse)
4012 (gnus-error 1 "No such article (may have expired or been canceled)")))))
4013 (if (or (eq result 'pseudo)
4014 (eq result 'nneething))
4017 (set-buffer summary-buffer)
4018 (push article gnus-newsgroup-history)
4019 (setq gnus-last-article gnus-current-article
4020 gnus-current-article 0
4021 gnus-current-headers nil
4022 gnus-article-current nil)
4023 (if (eq result 'nneething)
4024 (gnus-configure-windows 'summary)
4025 (gnus-configure-windows 'article))
4026 (gnus-set-global-variables))
4027 (let ((gnus-article-mime-handle-alist-1
4028 gnus-article-mime-handle-alist))
4029 (gnus-set-mode-line 'article)))
4030 ;; The result from the `request' was an actual article -
4031 ;; or at least some text that is now displayed in the
4033 (when (and (numberp article)
4034 (not (eq article gnus-current-article)))
4035 ;; Seems like a new article has been selected.
4036 ;; `gnus-current-article' must be an article number.
4038 (set-buffer summary-buffer)
4039 (push article gnus-newsgroup-history)
4040 (setq gnus-last-article gnus-current-article
4041 gnus-current-article article
4042 gnus-current-headers
4043 (gnus-summary-article-header gnus-current-article)
4044 gnus-article-current
4045 (cons gnus-newsgroup-name gnus-current-article))
4046 (unless (vectorp gnus-current-headers)
4047 (setq gnus-current-headers nil))
4048 (gnus-summary-goto-subject gnus-current-article)
4049 (when (gnus-summary-show-thread)
4050 ;; If the summary buffer really was folded, the
4051 ;; previous goto may not actually have gone to
4052 ;; the right article, but the thread root instead.
4054 (gnus-summary-goto-subject gnus-current-article))
4055 (gnus-run-hooks 'gnus-mark-article-hook)
4056 (gnus-set-mode-line 'summary)
4057 (when (gnus-visual-p 'article-highlight 'highlight)
4058 (gnus-run-hooks 'gnus-visual-mark-article-hook))
4059 ;; Set the global newsgroup variables here.
4060 (gnus-set-global-variables)
4061 (setq gnus-have-all-headers
4062 (or all-headers gnus-show-all-headers))))
4064 (gnus-configure-windows 'article))
4065 (when (or (numberp article)
4067 (gnus-article-prepare-display)
4069 (goto-char (point-min))
4070 (when gnus-break-pages
4071 (gnus-narrow-to-page)))
4072 (let ((gnus-article-mime-handle-alist-1
4073 gnus-article-mime-handle-alist))
4074 (gnus-set-mode-line 'article))
4078 (set-window-point (get-buffer-window (current-buffer)) (point))
4079 (gnus-configure-windows 'article)
4082 (defun gnus-article-prepare-mime-display (&optional number)
4083 (goto-char (point-min))
4084 (when (re-search-forward "^[^\t ]+:" nil t)
4085 (goto-char (match-beginning 0)))
4086 (let ((entity (if (eq 1 (point-min))
4087 (get-text-property 1 'mime-view-entity)
4088 (get-text-property (point) 'mime-view-entity)))
4089 last-entity child-entity next type)
4090 (setq child-entity (mime-entity-children entity))
4092 (setq last-entity (nth (1- (length child-entity))
4094 (setq last-entity entity))
4096 (narrow-to-region (point)
4097 (if (search-forward "\n\n" nil t)
4100 (gnus-treat-article 'head)
4101 (put-text-property (point-min) (point-max) 'article-treated-header t)
4102 (goto-char (point-max)))
4103 (while (and (not (eobp)) entity)
4104 (setq next (set-marker
4106 (next-single-property-change (point) 'mime-view-entity
4108 (let ((types (mime-entity-content-type entity)))
4109 (while (eq 'multipart (mime-content-type-primary-type types))
4110 (setq entity (car (mime-entity-children entity))
4111 types (mime-entity-content-type entity)))
4113 (setq type (format "%s/%s"
4114 (mime-content-type-primary-type types)
4115 (mime-content-type-subtype types)))))
4116 (if (string-equal type "message/rfc822")
4119 (let ((children (mime-entity-children entity))
4122 (setq last-children (nth (1- (length children)) children))
4125 (not (eq last-children
4126 (get-text-property next 'mime-view-entity)))
4128 (next-single-property-change next
4130 nil (point-max)))))))
4131 (setq next (next-single-property-change next 'mime-view-entity
4134 (narrow-to-region (point) next)
4135 (gnus-article-prepare-mime-display)
4136 (goto-char (point-max)))
4137 (setq entity (get-text-property (point) 'mime-view-entity)))
4139 (narrow-to-region (point) next)
4140 ;; Kludge. We have to count true number, but for now,
4141 ;; part number is here only to achieve `last'.
4142 (gnus-treat-article nil 1
4143 (if (eq entity last-entity)
4146 (goto-char (point-max)))
4147 (setq entity (get-text-property next 'mime-view-entity))))))
4150 (defun gnus-article-prepare-display ()
4151 "Make the current buffer look like a nice article."
4152 (let ((gnus-article-buffer (current-buffer))
4154 (unless (eq major-mode 'gnus-article-mode)
4155 (gnus-article-mode))
4156 (setq buffer-read-only nil
4157 gnus-button-marker-list nil
4158 gnus-article-wash-types nil
4159 gnus-article-image-alist nil)
4162 (static-if (featurep 'xemacs)
4163 (map-extents (lambda (extent maparg) (delete-extent extent)))
4164 (let ((lists (overlay-lists)))
4165 (dolist (overlay (nconc (car lists) (cdr lists)))
4166 (delete-overlay overlay)))))
4167 (gnus-run-hooks 'gnus-tmp-internal-hook))
4168 (let ((show-mime (unless (member gnus-newsgroup-name '("nndraft:delayed"
4171 (inhibit-read-only t))
4172 (set-buffer gnus-original-article-buffer)
4174 (setq mime-message-structure gnus-current-headers)
4175 (mime-buffer-entity-set-buffer-internal mime-message-structure
4176 gnus-original-article-buffer)
4177 (mime-entity-set-representation-type-internal mime-message-structure
4178 'mime-buffer-entity)
4179 (luna-send mime-message-structure 'initialize-instance
4180 mime-message-structure)
4182 (let (mime-display-header-hook mime-display-text/plain-hook)
4183 (funcall gnus-article-display-method-for-mime))
4184 (funcall gnus-article-display-method-for-traditional))
4185 ;; Call the treatment functions.
4189 (gnus-article-prepare-mime-display)
4190 (narrow-to-region (goto-char (point-min))
4191 (if (search-forward "\n\n" nil t)
4194 (gnus-treat-article 'head)
4195 (put-text-property (point-min) (point-max) 'article-treated-header t)
4196 (goto-char (point-max))
4198 (narrow-to-region (point) (point-max))
4199 (gnus-treat-article nil))
4200 (put-text-property (point-min) (point-max) 'read-only nil)))
4201 (gnus-run-hooks 'gnus-article-prepare-hook))
4203 (defun gnus-article-decode-article-as-default-mime-charset ()
4204 "Decode an article as `default-mime-charset'. It won't work if the
4205 value of the variable `gnus-show-mime' is non-nil."
4206 (unless (or gnus-show-mime
4207 (member gnus-newsgroup-name '("nndraft:delayed"
4209 (set (make-local-variable 'default-mime-charset)
4210 (with-current-buffer gnus-summary-buffer
4211 default-mime-charset))
4212 (decode-mime-charset-region (point-min) (point-max)
4213 default-mime-charset)))
4216 ;;; Gnus MIME viewing functions
4219 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4220 "Format of the MIME buttons.
4222 Valid specifiers include:
4224 %T MIME type, along with additional info
4225 %n The `name' parameter
4226 %d The description, if any
4227 %l The length of the encoded part
4228 %p The part identifier number
4229 %e Dots if the part isn't displayed
4231 General format specifiers can also be used. See Info node
4232 `(gnus)Formatting Variables'.")
4234 (defvar gnus-mime-button-line-format-alist
4235 '((?t gnus-tmp-type ?s)
4236 (?T gnus-tmp-type-long ?s)
4237 (?n gnus-tmp-name ?s)
4238 (?d gnus-tmp-description ?s)
4240 (?l gnus-tmp-length ?d)
4241 (?e gnus-tmp-dots ?s)))
4243 (defvar gnus-mime-button-commands
4244 '((gnus-article-press-button "\r" "Toggle Display")
4245 (gnus-mime-view-part "v" "View Interactively...")
4246 (gnus-mime-view-part-as-type "t" "View As Type...")
4247 (gnus-mime-view-part-as-charset "C" "View As charset...")
4248 (gnus-mime-save-part "o" "Save...")
4249 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4250 (gnus-mime-delete-part "d" "Delete part")
4251 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4252 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4253 (gnus-mime-view-part-internally "E" "View Internally")
4254 (gnus-mime-view-part-externally "e" "View Externally")
4255 (gnus-mime-print-part "p" "Print")
4256 (gnus-mime-pipe-part "|" "Pipe To Command...")
4257 (gnus-mime-action-on-part "." "Take action on the part...")))
4259 (defun gnus-article-mime-part-status ()
4260 (with-current-buffer gnus-article-buffer
4261 (let ((entity (get-text-property (point-min) 'mime-view-entity))
4264 (setq children (mime-entity-children entity))
4265 (setq children (length children)))
4268 (format " (%d parts)" children))
4271 (defvar gnus-mime-button-map
4272 (let ((map (make-sparse-keymap)))
4273 (define-key map gnus-mouse-2 'gnus-article-push-button)
4274 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4275 (dolist (c gnus-mime-button-commands)
4276 (define-key map (cadr c) (car c)))
4280 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4282 ,@(mapcar (lambda (c)
4283 (vector (caddr c) (car c) :enable t))
4284 gnus-mime-button-commands)))
4286 (defun gnus-mime-button-menu (event prefix)
4287 "Construct a context-sensitive menu of MIME commands."
4288 (interactive "e\nP")
4289 (save-window-excursion
4290 (let ((pos (event-start event)))
4291 (select-window (posn-window pos))
4292 (goto-char (posn-point pos))
4293 (gnus-article-check-buffer)
4294 (popup-menu gnus-mime-button-menu nil prefix))))
4296 (defun gnus-mime-view-all-parts (&optional handles)
4297 "View all the MIME parts."
4299 (with-current-buffer gnus-article-buffer
4300 (let ((handles (or handles gnus-article-mime-handles))
4301 (mail-parse-charset gnus-newsgroup-charset)
4302 (mail-parse-ignored-charsets
4303 (with-current-buffer gnus-summary-buffer
4304 gnus-newsgroup-ignored-charsets)))
4306 (mm-remove-parts handles)
4307 (goto-char (point-min))
4308 (or (search-forward "\n\n") (goto-char (point-max)))
4309 (let (buffer-read-only)
4310 (delete-region (point) (point-max))
4311 (mm-display-parts handles))))))
4313 (defun gnus-mime-save-part-and-strip ()
4314 "Save the MIME part under point then replace it with an external body."
4316 (gnus-article-check-buffer)
4317 (let* ((data (get-text-property (point) 'gnus-data))
4319 (handles gnus-article-mime-handles))
4320 (if (mm-multiple-handles gnus-article-mime-handles)
4321 (error "This function is not implemented"))
4322 (setq file (and data (mm-save-part data)))
4324 (with-current-buffer (mm-handle-buffer data)
4326 (insert "Content-Type: " (mm-handle-media-type data))
4327 (mml-insert-parameter-string (cdr (mm-handle-type data))
4330 (insert "Content-ID: " (message-make-message-id) "\n")
4331 (insert "Content-Transfer-Encoding: binary\n")
4334 (cdr (mm-make-handle nil
4335 `("message/external-body"
4336 (access-type . "LOCAL-FILE")
4338 (set-buffer gnus-summary-buffer)
4339 (gnus-article-edit-article
4342 (let ((mail-parse-charset (or gnus-article-charset
4343 ',gnus-newsgroup-charset))
4344 (mail-parse-ignored-charsets
4345 (or gnus-article-ignored-charsets
4346 ',gnus-newsgroup-ignored-charsets))
4347 (mbl mml-buffer-list))
4348 (setq mml-buffer-list nil)
4349 (insert-buffer gnus-original-article-buffer)
4350 (mime-to-mml ',handles)
4351 (setq gnus-article-mime-handles nil)
4352 (let ((mbl1 mml-buffer-list))
4353 (setq mml-buffer-list mbl)
4354 (set (make-local-variable 'mml-buffer-list) mbl1))
4355 (gnus-make-local-hook 'kill-buffer-hook)
4356 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4357 `(lambda (no-highlight)
4358 (let ((mail-parse-charset (or gnus-article-charset
4359 ',gnus-newsgroup-charset))
4360 (message-options message-options)
4361 (message-options-set-recipient)
4362 (mail-parse-ignored-charsets
4363 (or gnus-article-ignored-charsets
4364 ',gnus-newsgroup-ignored-charsets)))
4366 (mml-destroy-buffers)
4367 (remove-hook 'kill-buffer-hook
4368 'mml-destroy-buffers t)
4369 (kill-local-variable 'mml-buffer-list))
4370 (gnus-summary-edit-article-done
4371 ,(or (mail-header-references gnus-current-headers) "")
4372 ,(gnus-group-read-only-p)
4373 ,gnus-summary-buffer no-highlight))))))
4375 (defun gnus-mime-delete-part ()
4376 "Delete the MIME part under point.
4377 Replace it with some information about the removed part."
4379 (gnus-article-check-buffer)
4380 (unless (and gnus-novice-user
4381 (not (gnus-yes-or-no-p
4382 "Really delete attachment forever? ")))
4383 (let* ((data (get-text-property (point) 'gnus-data))
4384 (handles gnus-article-mime-handles)
4388 (mail-decode-encoded-word-string (or (mm-handle-description data)
4391 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4393 (type (mm-handle-media-type data)))
4394 (if (mm-multiple-handles gnus-article-mime-handles)
4395 (error "This function is not implemented"))
4396 (with-current-buffer (mm-handle-buffer data)
4397 (let ((bsize (format "%s" (buffer-size))))
4402 "| The following attachment has been deleted:\n"
4404 "| Type: " type "\n"
4405 "| Filename: " filename "\n"
4406 "| Size (encoded): " bsize " Byte\n"
4407 "| Description: " description "\n"
4410 (cdr (mm-make-handle
4411 nil `("text/plain") nil nil
4413 (format "Deleted attachment (%s bytes)" bsize))))))
4414 (set-buffer gnus-summary-buffer)
4415 ;; FIXME: maybe some of the following code (borrowed from
4416 ;; `gnus-mime-save-part-and-strip') isn't necessary?
4417 (gnus-article-edit-article
4420 (let ((mail-parse-charset (or gnus-article-charset
4421 ',gnus-newsgroup-charset))
4422 (mail-parse-ignored-charsets
4423 (or gnus-article-ignored-charsets
4424 ',gnus-newsgroup-ignored-charsets))
4425 (mbl mml-buffer-list))
4426 (setq mml-buffer-list nil)
4427 (insert-buffer gnus-original-article-buffer)
4428 (mime-to-mml ',handles)
4429 (setq gnus-article-mime-handles nil)
4430 (let ((mbl1 mml-buffer-list))
4431 (setq mml-buffer-list mbl)
4432 (set (make-local-variable 'mml-buffer-list) mbl1))
4433 (gnus-make-local-hook 'kill-buffer-hook)
4434 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4435 `(lambda (no-highlight)
4436 (let ((mail-parse-charset (or gnus-article-charset
4437 ',gnus-newsgroup-charset))
4438 (message-options message-options)
4439 (message-options-set-recipient)
4440 (mail-parse-ignored-charsets
4441 (or gnus-article-ignored-charsets
4442 ',gnus-newsgroup-ignored-charsets)))
4444 (mml-destroy-buffers)
4445 (remove-hook 'kill-buffer-hook
4446 'mml-destroy-buffers t)
4447 (kill-local-variable 'mml-buffer-list))
4448 (gnus-summary-edit-article-done
4449 ,(or (mail-header-references gnus-current-headers) "")
4450 ,(gnus-group-read-only-p)
4451 ,gnus-summary-buffer no-highlight)))))
4452 ;; Not in `gnus-mime-save-part-and-strip':
4453 (gnus-article-edit-done)
4454 (gnus-summary-expand-window)
4455 (gnus-summary-show-article))
4457 (defun gnus-mime-save-part ()
4458 "Save the MIME part under point."
4460 (gnus-article-check-buffer)
4461 (let ((data (get-text-property (point) 'gnus-data)))
4463 (mm-save-part data))))
4465 (defun gnus-mime-pipe-part ()
4466 "Pipe the MIME part under point to a process."
4468 (gnus-article-check-buffer)
4469 (let ((data (get-text-property (point) 'gnus-data)))
4471 (mm-pipe-part data))))
4473 (defun gnus-mime-view-part ()
4474 "Interactively choose a viewing method for the MIME part under point."
4476 (gnus-article-check-buffer)
4477 (let ((data (get-text-property (point) 'gnus-data)))
4479 (setq gnus-article-mime-handles
4481 gnus-article-mime-handles (setq data (copy-sequence data))))
4482 (mm-interactively-view-part data))))
4484 (defun gnus-mime-view-part-as-type-internal ()
4485 (gnus-article-check-buffer)
4486 (let* ((name (mail-content-type-get
4487 (mm-handle-type (get-text-property (point) 'gnus-data))
4489 (def-type (and name (mm-default-file-encoding name))))
4490 (and def-type (cons def-type 0))))
4492 (defun gnus-mime-view-part-as-type (&optional mime-type)
4493 "Choose a MIME media type, and view the part as such."
4496 (setq mime-type (completing-read
4497 "View as MIME type: "
4498 (mapcar #'list (mailcap-mime-types))
4500 (gnus-mime-view-part-as-type-internal))))
4501 (gnus-article-check-buffer)
4502 (let ((handle (get-text-property (point) 'gnus-data)))
4505 (mm-make-handle (mm-handle-buffer handle)
4506 (cons mime-type (cdr (mm-handle-type handle)))
4507 (mm-handle-encoding handle)
4508 (mm-handle-undisplayer handle)
4509 (mm-handle-disposition handle)
4510 (mm-handle-description handle)
4512 (mm-handle-id handle)))
4513 (setq gnus-article-mime-handles
4514 (mm-merge-handles gnus-article-mime-handles handle))
4515 (gnus-mm-display-part handle))))
4518 (require 'jka-compr))
4520 ;; jka-compr.el uses a "sh -c" to direct stderr to err-file, but these days
4521 ;; emacs can do that itself.
4523 (defun gnus-mime-jka-compr-maybe-uncompress ()
4524 "Uncompress the current buffer if `auto-compression-mode' is enabled.
4525 The uncompress method used is derived from `buffer-file-name'."
4526 (when (and (fboundp 'jka-compr-installed-p)
4527 (jka-compr-installed-p))
4528 (let ((info (jka-compr-get-compression-info buffer-file-name)))
4530 (let ((basename (file-name-nondirectory buffer-file-name))
4531 (args (jka-compr-info-uncompress-args info))
4532 (prog (jka-compr-info-uncompress-program info))
4533 (message (jka-compr-info-uncompress-message info))
4534 (err-file (jka-compr-make-temp-name)))
4536 (message "%s %s..." message basename))
4538 (unless (memq (apply 'call-process-region
4539 (point-min) (point-max)
4541 t (list t err-file) nil
4543 jka-compr-acceptable-retval-list)
4544 (jka-compr-error prog args basename message err-file))
4545 (jka-compr-delete-temp-file err-file)))))))
4547 (defun gnus-mime-copy-part (&optional handle)
4548 "Put the MIME part under point into a new buffer.
4549 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4552 (gnus-article-check-buffer)
4553 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4554 (contents (and handle (mm-get-part handle)))
4556 (file-name-nondirectory
4558 (mail-content-type-get (mm-handle-type handle) 'name)
4559 (mail-content-type-get (mm-handle-disposition handle)
4562 (buffer (and base (generate-new-buffer base))))
4564 (switch-to-buffer buffer)
4566 ;; We do it this way to make `normal-mode' set the appropriate mode.
4569 (setq buffer-file-name (expand-file-name base))
4570 (gnus-mime-jka-compr-maybe-uncompress)
4572 (setq buffer-file-name nil))
4573 (goto-char (point-min)))))
4575 (defun gnus-mime-print-part (&optional handle filename)
4576 "Print the MIME part under point."
4577 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4578 (gnus-article-check-buffer)
4579 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4580 (contents (and handle (mm-get-part handle)))
4581 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4582 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4587 (mm-save-part-to-file handle file)
4588 (call-process shell-file-name nil
4589 (generate-new-buffer " *mm*")
4591 shell-command-switch
4593 printer file (mm-handle-type handle))))
4597 (gnus-print-buffer))
4598 (ps-despool filename)))))
4600 (defun gnus-mime-inline-part (&optional handle arg)
4601 "Insert the MIME part under point into the current buffer."
4602 (interactive (list nil current-prefix-arg))
4603 (gnus-article-check-buffer)
4604 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4609 (if (and (not arg) (mm-handle-undisplayer handle))
4610 (mm-remove-part handle)
4611 (setq contents (mm-get-part handle))
4614 (setq charset (or (mail-content-type-get
4615 (mm-handle-type handle) 'charset)
4616 gnus-newsgroup-charset)))
4618 (if (mm-handle-undisplayer handle)
4619 (mm-remove-part handle))
4622 gnus-summary-show-article-charset-alist))
4623 (mm-read-coding-system "Charset: ")))))
4625 (mm-insert-inline handle
4627 (setq charset (mm-charset-to-coding-system
4629 (not (eq charset 'ascii)))
4630 (mm-decode-coding-string contents charset)
4634 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4635 "Insert the MIME part under point into the current buffer using the
4637 (interactive (list nil current-prefix-arg))
4638 (gnus-article-check-buffer)
4639 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4644 (if (mm-handle-undisplayer handle)
4645 (mm-remove-part handle))
4646 (let ((gnus-newsgroup-charset
4648 gnus-summary-show-article-charset-alist))
4649 (mm-read-coding-system "Charset: ")))
4650 (gnus-newsgroup-ignored-charsets 'gnus-all))
4651 (gnus-article-press-button)))))
4653 (defun gnus-mime-view-part-externally (&optional handle)
4654 "View the MIME part under point with an external viewer."
4656 (gnus-article-check-buffer)
4657 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4658 (mm-user-display-methods nil)
4659 (mm-inlined-types nil)
4660 (mail-parse-charset gnus-newsgroup-charset)
4661 (mail-parse-ignored-charsets
4662 (with-current-buffer gnus-summary-buffer
4663 gnus-newsgroup-ignored-charsets)))
4665 (if (mm-handle-undisplayer handle)
4666 (mm-remove-part handle)
4667 (mm-display-part handle)))))
4669 (defun gnus-mime-view-part-internally (&optional handle)
4670 "View the MIME part under point with an internal viewer.
4671 If no internal viewer is available, use an external viewer."
4673 (gnus-article-check-buffer)
4674 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4675 (mm-inlined-types '(".*"))
4676 (mm-inline-large-images t)
4677 (mail-parse-charset gnus-newsgroup-charset)
4678 (mail-parse-ignored-charsets
4679 (with-current-buffer gnus-summary-buffer
4680 gnus-newsgroup-ignored-charsets))
4683 (if (mm-handle-undisplayer handle)
4684 (mm-remove-part handle)
4685 (mm-display-part handle)))))
4687 (defun gnus-mime-action-on-part (&optional action)
4688 "Do something with the MIME attachment at \(point\)."
4690 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4691 (gnus-article-check-buffer)
4692 (let ((action-pair (assoc action gnus-mime-action-alist)))
4694 (funcall (cdr action-pair)))))
4696 (defun gnus-article-part-wrapper (n function)
4697 (with-current-buffer gnus-article-buffer
4698 (when (> n (length gnus-article-mime-handle-alist))
4699 (error "No such part"))
4700 (gnus-article-goto-part n)
4701 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4702 (funcall function handle))))
4704 (defun gnus-article-pipe-part (n)
4705 "Pipe MIME part N, which is the numerical prefix."
4707 (gnus-article-part-wrapper n 'mm-pipe-part))
4709 (defun gnus-article-save-part (n)
4710 "Save MIME part N, which is the numerical prefix."
4712 (gnus-article-part-wrapper n 'mm-save-part))
4714 (defun gnus-article-interactively-view-part (n)
4715 "View MIME part N interactively, which is the numerical prefix."
4717 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4719 (defun gnus-article-copy-part (n)
4720 "Copy MIME part N, which is the numerical prefix."
4722 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4724 (defun gnus-article-view-part-as-charset (n)
4725 "View MIME part N using a specified charset.
4726 N is the numerical prefix."
4728 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4730 (defun gnus-article-view-part-externally (n)
4731 "View MIME part N externally, which is the numerical prefix."
4733 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4735 (defun gnus-article-inline-part (n)
4736 "Inline MIME part N, which is the numerical prefix."
4738 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4740 (defun gnus-article-mime-match-handle-first (condition)
4742 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4743 (while (setq ihandle (pop alist))
4745 ((functionp condition)
4746 (funcall condition (cdr ihandle)))
4747 ((eq condition 'undisplayed)
4748 (not (or (mm-handle-undisplayer (cdr ihandle))
4749 (equal (mm-handle-media-type (cdr ihandle))
4750 "multipart/alternative"))))
4751 ((eq condition 'undisplayed-alternative)
4752 (not (mm-handle-undisplayer (cdr ihandle))))
4754 (gnus-article-goto-part (car ihandle))
4755 (or (not n) (< (car ihandle) n)))
4756 (setq n (car ihandle))))
4760 (defun gnus-article-view-part (&optional n)
4761 "View MIME part N, which is the numerical prefix."
4763 (with-current-buffer gnus-article-buffer
4764 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4765 gnus-article-mime-match-handle-function)))
4766 (when (> n (length gnus-article-mime-handle-alist))
4767 (error "No such part"))
4768 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4769 (when (gnus-article-goto-part n)
4770 (if (equal (car handle) "multipart/alternative")
4771 (gnus-article-press-button)
4772 (when (eq (gnus-mm-display-part handle) 'internal)
4773 (gnus-set-window-start)))))))
4775 (defsubst gnus-article-mime-total-parts ()
4776 (if (bufferp (car gnus-article-mime-handles))
4778 (1- (length gnus-article-mime-handles))))
4780 (defun gnus-mm-display-part (handle)
4781 "Display HANDLE and fix MIME button."
4782 (let ((id (get-text-property (point) 'gnus-part))
4787 (let ((window (selected-window))
4788 (mail-parse-charset gnus-newsgroup-charset)
4789 (mail-parse-ignored-charsets
4790 (if (gnus-buffer-live-p gnus-summary-buffer)
4791 (with-current-buffer gnus-summary-buffer
4792 gnus-newsgroup-ignored-charsets)
4796 (let ((win (gnus-get-buffer-window (current-buffer) t))
4799 (select-window win))
4802 (if (mm-handle-displayed-p handle)
4803 ;; This will remove the part.
4804 (mm-display-part handle)
4806 (narrow-to-region (point)
4807 (if (eobp) (point) (1+ (point))))
4808 (mm-display-part handle)
4809 ;; We narrow to the part itself and
4810 ;; then call the treatment functions.
4811 (goto-char (point-min))
4813 (narrow-to-region (point) (point-max))
4816 (gnus-article-mime-total-parts)
4817 (mm-handle-media-type handle)))))
4818 (if (window-live-p window)
4819 (select-window window)))))
4822 (gnus-insert-mime-button
4823 handle id (list (mm-handle-displayed-p handle)))
4824 (goto-char point))))
4826 (defun gnus-article-goto-part (n)
4827 "Go to MIME part N."
4828 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4830 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4831 (let ((gnus-tmp-name
4832 (or (mail-content-type-get (mm-handle-type handle) 'name)
4833 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4834 (mail-content-type-get (mm-handle-type handle) 'url)
4836 (gnus-tmp-type (mm-handle-media-type handle))
4837 (gnus-tmp-description
4838 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4841 (if (if displayed (car displayed)
4842 (mm-handle-displayed-p handle))
4844 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4846 gnus-tmp-type-long b e)
4847 (when (string-match ".*/" gnus-tmp-name)
4848 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4849 (setq gnus-tmp-type-long (concat gnus-tmp-type
4850 (and (not (equal gnus-tmp-name ""))
4851 (concat "; " gnus-tmp-name))))
4852 (unless (equal gnus-tmp-description "")
4853 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4858 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4859 `(keymap ,gnus-mime-button-map
4860 gnus-callback gnus-mm-display-part
4861 gnus-part ,gnus-tmp-id
4862 article-type annotation
4865 ;; Exclude a newline.
4868 (widget-convert-button
4871 :action 'gnus-widget-press-button
4872 :button-keymap gnus-mime-button-map
4874 (lambda (widget/window &optional overlay pos)
4875 ;; Needed to properly clear the message due to a bug in
4876 ;; wid-edit (XEmacs only).
4877 (if (boundp 'help-echo-owns-message)
4878 (setq help-echo-owns-message t))
4880 "%S: %s the MIME part; %S: more options"
4881 (aref gnus-mouse-2 0)
4882 ;; XEmacs will get a single widget arg; Emacs 21 will get
4883 ;; window, overlay, position.
4884 (if (mm-handle-displayed-p
4886 (with-current-buffer (gnus-overlay-buffer overlay)
4887 (widget-get (widget-at (gnus-overlay-start overlay))
4889 (widget-get widget/window :mime-handle)))
4891 (aref gnus-down-mouse-3 0))))))
4893 (defun gnus-widget-press-button (elems el)
4894 (goto-char (widget-get elems :from))
4895 (gnus-article-press-button))
4897 (defvar gnus-displaying-mime nil)
4899 (defun gnus-display-mime (&optional ihandles)
4900 "Display the MIME parts."
4902 (save-selected-window
4903 (let ((window (get-buffer-window gnus-article-buffer))
4906 (select-window window)
4907 ;; We have to do this since selecting the window
4908 ;; may change the point. So we set the window point.
4909 (set-window-point window point)))
4910 (let* ((handles (or ihandles
4911 (mm-dissect-buffer nil gnus-article-loose-mime)
4912 (and gnus-article-emulate-mime
4914 buffer-read-only handle name type b e display)
4915 (when (and (not ihandles)
4916 (not gnus-displaying-mime))
4917 ;; Top-level call; we clean up.
4918 (when gnus-article-mime-handles
4919 (mm-destroy-parts gnus-article-mime-handles)
4920 (setq gnus-article-mime-handle-alist nil));; A trick.
4921 (setq gnus-article-mime-handles handles)
4922 ;; We allow users to glean info from the handles.
4923 (when gnus-article-mime-part-function
4924 (gnus-mime-part-function handles)))
4926 (or (not (stringp (car handles)))
4929 (when (and (not ihandles)
4930 (not gnus-displaying-mime))
4931 ;; Clean up for mime parts.
4933 (delete-region (point) (point-max)))
4934 (let ((gnus-displaying-mime t))
4935 (gnus-mime-display-part handles)))
4938 (narrow-to-region (point) (point-max))
4939 (gnus-treat-article nil 1 1)
4942 ;; Highlight the headers.
4946 (narrow-to-region (point-min) (point))
4947 (gnus-treat-article 'head))))))))
4949 (defcustom gnus-mime-display-multipart-as-mixed nil
4950 "Display \"multipart\" parts as \"multipart/mixed\".
4952 If t, it overrides nil values of
4953 `gnus-mime-display-multipart-alternative-as-mixed' and
4954 `gnus-mime-display-multipart-related-as-mixed'."
4955 :group 'gnus-article-mime
4958 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
4959 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
4960 :group 'gnus-article-mime
4963 (defcustom gnus-mime-display-multipart-related-as-mixed nil
4964 "Display \"multipart/related\" parts as \"multipart/mixed\".
4966 If displaying \"text/html\" is discouraged \(see
4967 `mm-discouraged-alternatives'\) images or other material inside a
4968 \"multipart/related\" part might be overlooked when this variable is nil."
4969 :group 'gnus-article-mime
4972 (defun gnus-mime-display-part (handle)
4975 ((not (stringp (car handle)))
4976 (gnus-mime-display-single handle))
4977 ;; User-defined multipart
4978 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4979 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4981 ;; multipart/alternative
4982 ((and (equal (car handle) "multipart/alternative")
4983 (not (or gnus-mime-display-multipart-as-mixed
4984 gnus-mime-display-multipart-alternative-as-mixed)))
4985 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4986 (push (cons id handle) gnus-article-mime-handle-alist)
4987 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4988 ;; multipart/related
4989 ((and (equal (car handle) "multipart/related")
4990 (not (or gnus-mime-display-multipart-as-mixed
4991 gnus-mime-display-multipart-related-as-mixed)))
4992 ;;;!!!We should find the start part, but we just default
4993 ;;;!!!to the first part.
4994 ;;(gnus-mime-display-part (cadr handle))
4995 ;;;!!! Most multipart/related is an HTML message plus images.
4996 ;;;!!! Unfortunately we are unable to let W3 display those
4997 ;;;!!! included images, so we just display it as a mixed multipart.
4998 ;;(gnus-mime-display-mixed (cdr handle))
4999 ;;;!!! No, w3 can display everything just fine.
5000 (gnus-mime-display-part (cadr handle)))
5001 ((equal (car handle) "multipart/signed")
5002 (gnus-add-wash-type 'signed)
5003 (gnus-mime-display-security handle))
5004 ((equal (car handle) "multipart/encrypted")
5005 (gnus-add-wash-type 'encrypted)
5006 (gnus-mime-display-security handle))
5007 ;; Other multiparts are handled like multipart/mixed.
5009 (gnus-mime-display-mixed (cdr handle)))))
5011 (defun gnus-mime-part-function (handles)
5012 (if (stringp (car handles))
5013 (mapcar 'gnus-mime-part-function (cdr handles))
5014 (funcall gnus-article-mime-part-function handles)))
5016 (defun gnus-mime-display-mixed (handles)
5017 (mapcar 'gnus-mime-display-part handles))
5019 (defun gnus-mime-display-single (handle)
5020 (let ((type (mm-handle-media-type handle))
5021 (ignored gnus-ignored-mime-types)
5028 (when (string-match (pop ignored) type)
5029 (throw 'ignored nil)))
5030 (if (and (setq not-attachment
5031 (and (not (mm-inline-override-p handle))
5032 (or (not (mm-handle-disposition handle))
5033 (equal (car (mm-handle-disposition handle))
5035 (mm-attachment-override-p handle))))
5036 (mm-automatic-display-p handle)
5038 (mm-inlinable-p handle)
5039 (mm-inlined-p handle))
5040 (mm-automatic-external-display-p type)))
5042 (when (equal (mm-handle-media-supertype handle) "text")
5044 (let ((id (1+ (length gnus-article-mime-handle-alist)))
5046 (push (cons id handle) gnus-article-mime-handle-alist)
5047 (when (or (not display)
5048 (not (gnus-unbuttonized-mime-type-p type)))
5049 ;(gnus-article-insert-newline)
5050 (gnus-insert-mime-button
5051 handle id (list (or display (and not-attachment text))))
5052 (gnus-article-insert-newline)
5053 ;(gnus-article-insert-newline)
5054 ;; Remember modify the number of forward lines.
5062 (let ((mail-parse-charset gnus-newsgroup-charset)
5063 (mail-parse-ignored-charsets
5064 (save-excursion (condition-case ()
5065 (set-buffer gnus-summary-buffer)
5067 gnus-newsgroup-ignored-charsets)))
5068 (mm-display-part handle t))
5069 (goto-char (point-max)))
5070 ((and text not-attachment)
5074 (gnus-article-insert-newline)
5075 (mm-insert-inline handle (mm-get-part handle))
5076 (goto-char (point-max))))
5080 (narrow-to-region beg (point))
5083 (gnus-article-mime-total-parts)
5084 (mm-handle-media-type handle)))))))))
5086 (defun gnus-unbuttonized-mime-type-p (type)
5087 "Say whether TYPE is to be unbuttonized."
5088 (unless gnus-inhibit-mime-unbuttonizing
5090 (let ((types gnus-unbuttonized-mime-types))
5092 (when (string-match (pop types) type)
5093 (throw 'found t)))))
5095 (let ((types gnus-buttonized-mime-types))
5097 (when (string-match (pop types) type)
5098 (throw 'found t)))))))))
5100 (defun gnus-article-insert-newline ()
5101 "Insert a newline, but mark it as undeletable."
5102 (gnus-put-text-property
5103 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
5105 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
5106 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
5109 handle buffer-read-only from props begend not-pref)
5110 (save-window-excursion
5113 (narrow-to-region (car ibegend)
5116 (goto-char (car ibegend))
5119 (delete-region (point-min) (point-max))
5120 (mm-remove-parts handles))
5121 (setq begend (list (point-marker)))
5123 (unless (setq not-pref (cadr (member preferred ihandles)))
5124 (setq not-pref (car ihandles)))
5127 (not (gnus-unbuttonized-mime-type-p
5128 "multipart/alternative")))
5129 (gnus-add-text-properties
5132 (insert (format "%d. " id))
5136 (unless ,(not ibegend)
5137 (setq gnus-article-mime-handle-alist
5138 ',gnus-article-mime-handle-alist))
5139 (gnus-mime-display-alternative
5140 ',ihandles ',not-pref ',begend ,id))
5141 keymap ,gnus-mime-button-map
5142 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5143 face ,gnus-article-button-face
5146 (widget-convert-button 'link from (point)
5147 :action 'gnus-widget-press-button
5148 :button-keymap gnus-widget-button-keymap)
5150 (while (setq handle (pop handles))
5151 (gnus-add-text-properties
5154 (insert (format "(%c) %-18s"
5155 (if (equal handle preferred) ?* ? )
5156 (mm-handle-media-type handle)))
5160 (unless ,(not ibegend)
5161 (setq gnus-article-mime-handle-alist
5162 ',gnus-article-mime-handle-alist))
5163 (gnus-mime-display-alternative
5164 ',ihandles ',handle ',begend ,id))
5165 keymap ,gnus-mime-button-map
5166 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5167 face ,gnus-article-button-face
5170 (widget-convert-button 'link from (point)
5171 :action 'gnus-widget-press-button
5172 :button-keymap gnus-widget-button-keymap)
5176 (if (stringp (car preferred))
5177 (gnus-display-mime preferred)
5178 (let ((mail-parse-charset gnus-newsgroup-charset)
5179 (mail-parse-ignored-charsets
5180 (with-current-buffer gnus-summary-buffer
5181 gnus-newsgroup-ignored-charsets)))
5182 (mm-display-part preferred)
5186 (narrow-to-region (car begend) (point-max))
5188 nil (length gnus-article-mime-handle-alist)
5189 (gnus-article-mime-total-parts)
5190 (mm-handle-media-type handle))))))
5191 (goto-char (point-max))
5192 (setcdr begend (point-marker)))))
5194 (goto-char point))))
5196 (defconst gnus-article-wash-status-strings
5197 (let ((alist '((cite "c" "Possible hidden citation text"
5198 " " "All citation text visible")
5199 (headers "h" "Hidden headers"
5200 " " "All headers visible.")
5201 (pgp "p" "Encrypted or signed message status hidden"
5202 " " "No hidden encryption nor digital signature status")
5203 (signature "s" "Signature has been hidden"
5204 " " "Signature is visible")
5205 (overstrike "o" "Overstrike (^H) characters applied"
5206 " " "No overstrike characters applied")
5207 (gnus-show-mime "m" "Mime processing is activated"
5208 " " "Mime processing is not activated")
5209 (emphasis "e" "/*_Emphasis_*/ characters applied"
5210 " " "No /*_emphasis_*/ characters applied")))
5212 (dolist (entry alist result)
5213 (let ((key (nth 0 entry))
5214 (on (copy-sequence (nth 1 entry)))
5215 (on-help (nth 2 entry))
5216 (off (copy-sequence (nth 3 entry)))
5217 (off-help (nth 4 entry)))
5218 (put-text-property 0 1 'help-echo on-help on)
5219 (put-text-property 0 1 'help-echo off-help off)
5220 (push (list key on off) result))))
5221 "Alist of strings describing wash status in the mode line.
5222 Each entry has the form (KEY ON OF), where the KEY is a symbol
5223 representing the particular washing function, ON is the string to use
5224 in the article mode line when the washing function is active, and OFF
5225 is the string to use when it is inactive.")
5227 (defun gnus-article-wash-status-entry (key value)
5228 (let ((entry (assoc key gnus-article-wash-status-strings)))
5229 (if value (nth 1 entry) (nth 2 entry))))
5231 (defun gnus-article-wash-status ()
5232 "Return a string which display status of article washing."
5233 (with-current-buffer gnus-article-buffer
5234 (let ((cite (memq 'cite gnus-article-wash-types))
5235 (headers (memq 'headers gnus-article-wash-types))
5236 (boring (memq 'boring-headers gnus-article-wash-types))
5237 (pgp (memq 'pgp gnus-article-wash-types))
5238 (pem (memq 'pem gnus-article-wash-types))
5239 (signed (memq 'signed gnus-article-wash-types))
5240 (encrypted (memq 'encrypted gnus-article-wash-types))
5241 (signature (memq 'signature gnus-article-wash-types))
5242 (overstrike (memq 'overstrike gnus-article-wash-types))
5243 (emphasis (memq 'emphasis gnus-article-wash-types)))
5245 (gnus-article-wash-status-entry 'cite cite)
5246 (gnus-article-wash-status-entry 'headers (or headers boring))
5247 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5248 (gnus-article-wash-status-entry 'signature signature)
5249 (gnus-article-wash-status-entry 'overstrike overstrike)
5250 (gnus-article-wash-status-entry 'gnus-show-mime gnus-show-mime)
5251 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5253 (defun gnus-add-wash-type (type)
5254 "Add a washing of TYPE to the current status."
5255 (add-to-list 'gnus-article-wash-types type))
5257 (defun gnus-delete-wash-type (type)
5258 "Add a washing of TYPE to the current status."
5259 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5261 (defun gnus-add-image (category image)
5262 "Add IMAGE of CATEGORY to the list of displayed images."
5263 (let ((entry (assq category gnus-article-image-alist)))
5265 (setq entry (list category))
5266 (push entry gnus-article-image-alist))
5267 (nconc entry (list image))))
5269 (defun gnus-delete-images (category)
5270 "Delete all images in CATEGORY."
5271 (let ((entry (assq category gnus-article-image-alist)))
5272 (dolist (image (cdr entry))
5273 (gnus-remove-image image category))
5274 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5275 (gnus-delete-wash-type category)))
5277 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5279 (defun gnus-article-maybe-hide-headers ()
5280 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5281 Provided for backwards compatibility."
5282 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5283 (not (with-current-buffer gnus-summary-buffer
5284 gnus-have-all-headers)))
5285 (not gnus-inhibit-hiding))
5286 (gnus-article-hide-headers)))
5290 (defun gnus-output-to-file (file-name)
5291 "Append the current article to a file named FILE-NAME."
5292 (let ((artbuf (current-buffer)))
5294 (insert-buffer-substring artbuf)
5295 ;; Append newline at end of the buffer as separator, and then
5297 (goto-char (point-max))
5299 (let ((file-name-coding-system nnmail-pathname-coding-system))
5300 (write-region-as-binary (point-min) (point-max) file-name 'append))
5303 (defun gnus-narrow-to-page (&optional arg)
5304 "Narrow the article buffer to a page.
5305 If given a numerical ARG, move forward ARG pages."
5307 (setq arg (if arg (prefix-numeric-value arg) 0))
5309 (set-buffer gnus-article-buffer)
5310 (goto-char (point-min))
5312 ;; Remove any old next/prev buttons.
5313 (when (gnus-visual-p 'page-marker)
5314 (let ((buffer-read-only nil))
5315 (gnus-remove-text-with-property 'gnus-prev)
5316 (gnus-remove-text-with-property 'gnus-next)))
5319 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5321 (re-search-forward page-delimiter nil 'move arg)))
5322 (goto-char (match-end 0))
5324 (goto-char (point-min))
5325 (setq gnus-page-broken
5326 (and (re-search-forward page-delimiter nil t) t))))
5327 (when gnus-page-broken
5330 (if (re-search-forward page-delimiter nil 'move)
5333 (when (and (gnus-visual-p 'page-marker)
5334 (not (= (point-min) 1)))
5336 (goto-char (point-min))
5337 (gnus-insert-prev-page-button)))
5338 (when (and (gnus-visual-p 'page-marker)
5339 (< (+ (point-max) 2) (buffer-size)))
5341 (goto-char (point-max))
5342 (gnus-insert-next-page-button))))))
5344 ;; Article mode commands
5346 (defun gnus-article-goto-next-page ()
5347 "Show the next page of the article."
5349 (when (gnus-article-next-page)
5350 (goto-char (point-min))
5351 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5354 (defun gnus-article-goto-prev-page ()
5355 "Show the previous page of the article."
5358 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5359 (gnus-article-prev-page nil)))
5361 ;; This is cleaner but currently breaks `gnus-pick-mode':
5363 ;; (defun gnus-article-goto-next-page ()
5364 ;; "Show the next page of the article."
5366 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5367 ;; (gnus-summary-next-page)))
5369 ;; (defun gnus-article-goto-prev-page ()
5370 ;; "Show the next page of the article."
5372 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5373 ;; (gnus-summary-prev-page)))
5375 (defun gnus-article-next-page (&optional lines)
5376 "Show the next page of the current article.
5377 If end of article, return non-nil. Otherwise return nil.
5378 Argument LINES specifies lines to be scrolled up."
5380 (move-to-window-line -1)
5383 (and (pos-visible-in-window-p) ;Not continuation line.
5384 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5385 ;; Nothing in this page.
5386 (if (or (not gnus-page-broken)
5390 (eobp)))) ;Real end-of-buffer?
5392 (when gnus-article-over-scroll
5393 (gnus-article-next-page-1 lines))
5395 (gnus-narrow-to-page 1) ;Go to next page.
5397 ;; More in this page.
5398 (gnus-article-next-page-1 lines)
5401 (defun gnus-article-next-page-1 (lines)
5402 (let ((scroll-in-place nil))
5406 ;; Long lines may cause an end-of-buffer error.
5407 (goto-char (point-max)))))
5408 (move-to-window-line 0))
5410 (defun gnus-article-prev-page (&optional lines)
5411 "Show previous page of current article.
5412 Argument LINES specifies lines to be scrolled down."
5414 (move-to-window-line 0)
5415 (if (and gnus-page-broken
5417 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5419 (gnus-narrow-to-page -1) ;Go to previous page.
5420 (goto-char (point-max))
5422 (let ((scroll-in-place nil))
5426 (beginning-of-buffer
5427 (goto-char (point-min))))
5428 (move-to-window-line 0)))))
5430 (defun gnus-article-only-boring-p ()
5431 "Decide whether there is only boring text remaining in the article.
5432 Something \"interesting\" is a word of at least two letters that does
5433 not have a face in `gnus-article-boring-faces'."
5434 (when (and gnus-article-skip-boring
5435 (boundp 'gnus-article-boring-faces)
5436 (symbol-value 'gnus-article-boring-faces))
5439 (while (re-search-forward "\\b\\w\\w" nil t)
5441 (when (not (gnus-intersection
5442 (gnus-faces-at (point))
5443 (symbol-value 'gnus-article-boring-faces)))
5444 (throw 'only-boring nil)))
5445 (throw 'only-boring t)))))
5447 (defun gnus-article-refer-article ()
5448 "Read article specified by message-id around point."
5451 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
5452 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
5453 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
5454 (let ((msg-id (concat "<" (match-string 0) ">")))
5455 (set-buffer gnus-summary-buffer)
5456 (gnus-summary-refer-article msg-id))
5457 (error "No references around point"))))
5459 (defun gnus-article-show-summary ()
5460 "Reconfigure windows to show summary buffer."
5462 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5463 (error "There is no summary buffer for this article buffer")
5464 (gnus-article-set-globals)
5465 (gnus-configure-windows 'article)
5466 (gnus-summary-goto-subject gnus-current-article)
5467 (gnus-summary-position-point)))
5469 (defun gnus-article-describe-briefly ()
5470 "Describe article mode commands briefly."
5472 (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")))
5474 (defun gnus-article-summary-command ()
5475 "Execute the last keystroke in the summary buffer."
5477 (let ((obuf (current-buffer))
5478 (owin (current-window-configuration))
5480 (switch-to-buffer gnus-article-current-summary 'norecord)
5481 (setq func (lookup-key (current-local-map) (this-command-keys)))
5482 (call-interactively func)
5484 (set-window-configuration owin)
5485 (set-window-point (get-buffer-window (current-buffer)) (point))))
5487 (defun gnus-article-summary-command-nosave ()
5488 "Execute the last keystroke in the summary buffer."
5491 (pop-to-buffer gnus-article-current-summary 'norecord)
5492 (setq func (lookup-key (current-local-map) (this-command-keys)))
5493 (call-interactively func)))
5495 (defun gnus-article-check-buffer ()
5496 "Beep if not in an article buffer."
5497 (unless (eq (get-buffer gnus-article-buffer) (current-buffer))
5498 (error "Command invoked outside of a Gnus article buffer")))
5500 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5501 "Read a summary buffer key sequence and execute it from the article buffer."
5503 (gnus-article-check-buffer)
5505 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5506 "Zc" "ZC" "ZE" "ZJ" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5507 "=" "^" "\M-^" "|"))
5513 '("n" "Gn" "p" "Gp"))
5516 (set-buffer gnus-article-current-summary)
5517 (let (gnus-pick-mode)
5518 (push (or key last-command-event) unread-command-events)
5519 (setq keys (static-if (featurep 'xemacs)
5520 (events-to-keys (read-key-sequence nil))
5521 (read-key-sequence nil)))))
5524 (if (or (member keys nosaves)
5525 (member keys nosave-but-article)
5526 (member keys nosave-in-article))
5528 (save-window-excursion
5529 (pop-to-buffer gnus-article-current-summary 'norecord)
5530 ;; We disable the pick minor mode commands.
5531 (let (gnus-pick-mode)
5532 (setq func (lookup-key (current-local-map) keys))))
5536 (unless (member keys nosave-in-article)
5537 (set-buffer gnus-article-current-summary))
5538 (call-interactively func)
5539 (setq new-sum-point (point)))
5540 (when (member keys nosave-but-article)
5541 (pop-to-buffer gnus-article-buffer 'norecord)))
5542 ;; These commands should restore window configuration.
5543 (let ((obuf (current-buffer))
5544 (owin (current-window-configuration))
5546 (summary gnus-article-current-summary)
5547 func in-buffer selected)
5548 (if not-restore-window
5549 (pop-to-buffer summary 'norecord)
5550 (switch-to-buffer summary 'norecord))
5551 (setq in-buffer (current-buffer))
5552 ;; We disable the pick minor mode commands.
5553 (if (and (setq func (let (gnus-pick-mode)
5554 (lookup-key (current-local-map) keys)))
5557 (call-interactively func)
5558 (setq new-sum-point (point))
5559 (when (eq in-buffer (current-buffer))
5560 (setq selected (gnus-summary-select-article))
5562 (unless not-restore-window
5563 (set-window-configuration owin))
5564 (when (eq selected 'old)
5566 (set-window-start (get-buffer-window (current-buffer))
5568 (set-window-point (get-buffer-window (current-buffer))
5570 (let ((win (get-buffer-window gnus-article-current-summary)))
5572 (set-window-point win new-sum-point)))) )
5573 (switch-to-buffer gnus-article-buffer)
5576 (defun gnus-article-describe-key (key)
5577 "Display documentation of the function invoked by KEY. KEY is a string."
5578 (interactive "kDescribe key: ")
5579 (gnus-article-check-buffer)
5580 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5582 (set-buffer gnus-article-current-summary)
5583 (let (gnus-pick-mode)
5584 (if (featurep 'xemacs)
5586 (push (elt key 0) unread-command-events)
5587 (setq key (events-to-keys
5588 (read-key-sequence "Describe key: "))))
5589 (setq unread-command-events
5591 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5593 (setq key (read-key-sequence "Describe key: "))))
5595 (describe-key key)))
5597 (defun gnus-article-describe-key-briefly (key &optional insert)
5598 "Display documentation of the function invoked by KEY. KEY is a string."
5599 (interactive "kDescribe key: \nP")
5600 (gnus-article-check-buffer)
5601 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5603 (set-buffer gnus-article-current-summary)
5604 (let (gnus-pick-mode)
5605 (if (featurep 'xemacs)
5607 (push (elt key 0) unread-command-events)
5608 (setq key (events-to-keys
5609 (read-key-sequence "Describe key: "))))
5610 (setq unread-command-events
5612 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5614 (setq key (read-key-sequence "Describe key: "))))
5615 (describe-key-briefly key insert))
5616 (describe-key-briefly key insert)))
5618 (defun gnus-article-reply-with-original (&optional wide)
5619 "Start composing a reply mail to the current message.
5620 The text in the region will be yanked. If the region isn't active,
5621 the entire article will be yanked."
5623 (let ((article (cdr gnus-article-current))
5625 (if (not (gnus-mark-active-p))
5626 (with-current-buffer gnus-summary-buffer
5627 (gnus-summary-reply (list (list article)) wide))
5628 (setq contents (buffer-substring (point) (mark t)))
5629 ;; Deactivate active regions.
5630 (when (and (boundp 'transient-mark-mode)
5631 transient-mark-mode)
5632 (setq mark-active nil))
5633 (with-current-buffer gnus-summary-buffer
5635 (list (list article contents)) wide)))))
5637 (defun gnus-article-followup-with-original ()
5638 "Compose a followup to the current article.
5639 The text in the region will be yanked. If the region isn't active,
5640 the entire article will be yanked."
5642 (let ((article (cdr gnus-article-current))
5644 (if (not (gnus-mark-active-p))
5645 (with-current-buffer gnus-summary-buffer
5646 (gnus-summary-followup (list (list article))))
5647 (setq contents (buffer-substring (point) (mark t)))
5648 ;; Deactivate active regions.
5649 (when (and (boundp 'transient-mark-mode)
5650 transient-mark-mode)
5651 (setq mark-active nil))
5652 (with-current-buffer gnus-summary-buffer
5653 (gnus-summary-followup
5654 (list (list article contents)))))))
5656 (defun gnus-article-hide (&optional arg force)
5657 "Hide all the gruft in the current article.
5658 This means that signatures, cited text and (some) headers will be
5660 If given a prefix, show the hidden text instead."
5661 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5662 (gnus-article-hide-headers arg)
5663 (gnus-article-hide-list-identifiers arg)
5664 (gnus-article-hide-citation-maybe arg force)
5665 (gnus-article-hide-signature arg))
5667 (defun gnus-article-maybe-highlight ()
5668 "Do some article highlighting if article highlighting is requested."
5669 (when (gnus-visual-p 'article-highlight 'highlight)
5670 (gnus-article-highlight-some)))
5672 (defun gnus-check-group-server ()
5673 ;; Make sure the connection to the server is alive.
5674 (unless (gnus-server-opened
5675 (gnus-find-method-for-group gnus-newsgroup-name))
5676 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5677 (gnus-request-group gnus-newsgroup-name t)))
5680 (autoload 'nneething-get-file-name "nneething"))
5682 (defun gnus-request-article-this-buffer (article group)
5683 "Get an article and insert it into this buffer."
5684 (let (do-update-line sparse-header)
5688 (gnus-kill-all-overlays)
5689 (setq group (or group gnus-newsgroup-name))
5691 ;; Using `gnus-request-article' directly will insert the article into
5692 ;; `nntp-server-buffer' - so we'll save some time by not having to
5693 ;; copy it from the server buffer into the article buffer.
5695 ;; We only request an article by message-id when we do not have the
5696 ;; headers for it, so we'll have to get those.
5697 (when (stringp article)
5698 (gnus-read-header article))
5700 ;; If the article number is negative, that means that this article
5701 ;; doesn't belong in this newsgroup (possibly), so we find its
5702 ;; message-id and request it by id instead of number.
5703 (when (and (numberp article)
5705 (get-buffer gnus-summary-buffer)
5706 (gnus-buffer-exists-p gnus-summary-buffer))
5708 (set-buffer gnus-summary-buffer)
5709 (let ((header (gnus-summary-article-header article)))
5712 ((memq article gnus-newsgroup-sparse)
5713 ;; This is a sparse gap article.
5714 (setq do-update-line article)
5715 (setq article (mail-header-id header))
5716 (setq sparse-header (gnus-read-header article))
5717 (setq gnus-newsgroup-sparse
5718 (delq article gnus-newsgroup-sparse)))
5720 ;; It's a real article.
5721 (setq article (mail-header-id header)))
5723 ;; It is an extracted pseudo-article.
5724 (setq article 'pseudo)
5725 (gnus-request-pseudo-article header))))
5727 (let ((method (gnus-find-method-for-group
5728 gnus-newsgroup-name)))
5729 (when (and (eq (car method) 'nneething)
5731 (let ((dir (nneething-get-file-name
5732 (mail-header-id header))))
5733 (when (and (stringp dir)
5734 (file-directory-p dir))
5735 (setq article 'nneething)
5736 (gnus-group-enter-directory dir))))))))
5739 ;; Refuse to select canceled articles.
5740 ((and (numberp article)
5742 (get-buffer gnus-summary-buffer)
5743 (gnus-buffer-exists-p gnus-summary-buffer)
5744 (eq (cdr (with-current-buffer gnus-summary-buffer
5745 (assq article gnus-newsgroup-reads)))
5746 gnus-canceled-mark))
5748 ;; We first check `gnus-original-article-buffer'.
5749 ((and (get-buffer gnus-original-article-buffer)
5751 (with-current-buffer gnus-original-article-buffer
5752 (and (equal (car gnus-original-article) group)
5753 (eq (cdr gnus-original-article) article))))
5754 (insert-buffer-substring gnus-original-article-buffer)
5756 ;; Check the backlog.
5757 ((and gnus-keep-backlog
5758 (gnus-backlog-request-article group article (current-buffer)))
5760 ;; Check asynchronous pre-fetch.
5761 ((gnus-async-request-fetched-article group article (current-buffer))
5762 (gnus-async-prefetch-next group article gnus-summary-buffer)
5763 (when (and (numberp article) gnus-keep-backlog)
5764 (gnus-backlog-enter-article group article (current-buffer)))
5767 ((and gnus-use-cache
5769 (gnus-cache-request-article article group))
5771 ;; Check the agent cache.
5772 ((gnus-agent-request-article article group)
5774 ;; Get the article and put into the article buffer.
5775 ((or (stringp article)
5777 (let ((gnus-override-method gnus-override-method)
5778 (methods (and (stringp article)
5779 gnus-refer-article-method))
5780 (backend (car (gnus-find-method-for-group
5781 gnus-newsgroup-name)))
5783 (buffer-read-only nil))
5784 (if (or (not (listp methods))
5785 (and (symbolp (car methods))
5786 (assq (car methods) nnoo-definition-alist)))
5787 (setq methods (list methods)))
5788 (when (and (null gnus-override-method)
5790 (setq gnus-override-method (pop methods)))
5792 (when (eq gnus-override-method 'current)
5793 (setq gnus-override-method
5794 (with-current-buffer gnus-summary-buffer
5795 gnus-current-select-method)))
5797 (gnus-kill-all-overlays)
5798 (let ((gnus-newsgroup-name group))
5799 (gnus-check-group-server))
5801 ((gnus-request-article article group (current-buffer))
5802 (when (numberp article)
5803 (gnus-async-prefetch-next group article
5804 gnus-summary-buffer)
5805 (when gnus-keep-backlog
5806 (gnus-backlog-enter-article
5807 group article (current-buffer))))
5808 (setq result 'article))
5810 (setq gnus-override-method (pop methods)))
5811 ((not (string-match "^400 "
5812 (nnheader-get-report backend)))
5813 ;; If we get 400 server disconnect, reconnect and
5814 ;; retry; otherwise, assume the article has expired.
5815 (setq result 'done))))
5816 (and (eq result 'article) 'article)))
5820 ;; Associate this article with the current summary buffer.
5821 (setq gnus-article-current-summary gnus-summary-buffer)
5823 ;; Take the article from the original article buffer
5824 ;; and place it in the buffer it's supposed to be in.
5825 (when (and (get-buffer gnus-article-buffer)
5826 (equal (buffer-name (current-buffer))
5827 (buffer-name (get-buffer gnus-article-buffer))))
5829 (if (get-buffer gnus-original-article-buffer)
5830 (set-buffer gnus-original-article-buffer)
5831 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5832 (buffer-disable-undo)
5833 (setq major-mode 'gnus-original-article-mode)
5834 (setq buffer-read-only t))
5835 (let (buffer-read-only)
5837 (insert-buffer-substring gnus-article-buffer))
5838 (setq gnus-original-article (cons group article)))
5841 (run-hooks 'gnus-article-decode-hook)
5842 ;; Mark article as decoded or not.
5843 (setq gnus-article-decoded-p gnus-article-decode-hook))
5845 ;; Update sparse articles.
5846 (when (and do-update-line
5847 (or (numberp article)
5849 (let ((buf (current-buffer)))
5850 (set-buffer gnus-summary-buffer)
5851 (gnus-summary-update-article do-update-line sparse-header)
5852 (gnus-summary-goto-subject do-update-line nil t)
5853 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5855 (set-buffer buf))))))
5861 (defcustom gnus-article-edit-mode-hook nil
5862 "Hook run in article edit mode buffers."
5863 :group 'gnus-article-various
5866 (defcustom gnus-article-edit-article-setup-function
5867 'gnus-article-mime-edit-article-setup
5868 "Function called to setup an editing article buffer."
5869 :group 'gnus-article-various
5872 (defvar gnus-article-edit-done-function nil)
5874 (defvar gnus-article-edit-mode-map nil)
5876 ;; Should we be using derived.el for this?
5877 (unless gnus-article-edit-mode-map
5878 (setq gnus-article-edit-mode-map (make-keymap))
5879 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5881 (gnus-define-keys gnus-article-edit-mode-map
5882 "\C-c?" describe-mode
5883 "\C-c\C-c" gnus-article-edit-done
5884 "\C-c\C-k" gnus-article-edit-exit
5885 "\C-c\C-f\C-t" message-goto-to
5886 "\C-c\C-f\C-o" message-goto-from
5887 "\C-c\C-f\C-b" message-goto-bcc
5888 ;;"\C-c\C-f\C-w" message-goto-fcc
5889 "\C-c\C-f\C-c" message-goto-cc
5890 "\C-c\C-f\C-s" message-goto-subject
5891 "\C-c\C-f\C-r" message-goto-reply-to
5892 "\C-c\C-f\C-n" message-goto-newsgroups
5893 "\C-c\C-f\C-d" message-goto-distribution
5894 "\C-c\C-f\C-f" message-goto-followup-to
5895 "\C-c\C-f\C-m" message-goto-mail-followup-to
5896 "\C-c\C-f\C-k" message-goto-keywords
5897 "\C-c\C-f\C-u" message-goto-summary
5898 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5899 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5900 "\C-c\C-b" message-goto-body
5901 "\C-c\C-i" message-goto-signature
5903 "\C-c\C-t" message-insert-to
5904 "\C-c\C-n" message-insert-newsgroups
5905 "\C-c\C-o" message-sort-headers
5906 "\C-c\C-e" message-elide-region
5907 "\C-c\C-v" message-delete-not-region
5908 "\C-c\C-z" message-kill-to-signature
5909 "\M-\r" message-newline-and-reformat
5910 "\C-c\C-a" mml-attach-file
5911 "\C-a" message-beginning-of-line
5913 "\M-;" comment-region)
5915 (gnus-define-keys (gnus-article-edit-wash-map
5916 "\C-c\C-w" gnus-article-edit-mode-map)
5917 "f" gnus-article-edit-full-stops))
5920 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5922 ["Fetch To" message-insert-to t]
5923 ["Fetch Newsgroups" message-insert-newsgroups t]
5925 ["To" message-goto-to t]
5926 ["From" message-goto-from t]
5927 ["Subject" message-goto-subject t]
5928 ["Cc" message-goto-cc t]
5929 ["Reply-To" message-goto-reply-to t]
5930 ["Summary" message-goto-summary t]
5931 ["Keywords" message-goto-keywords t]
5932 ["Newsgroups" message-goto-newsgroups t]
5933 ["Followup-To" message-goto-followup-to t]
5934 ["Mail-Followup-To" message-goto-mail-followup-to t]
5935 ["Distribution" message-goto-distribution t]
5936 ["Body" message-goto-body t]
5937 ["Signature" message-goto-signature t]))
5939 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
5940 "Major mode for editing articles.
5941 This is an extended text-mode.
5943 \\{gnus-article-edit-mode-map}"
5944 (make-local-variable 'gnus-article-edit-done-function)
5945 (make-local-variable 'gnus-prev-winconf)
5946 (set (make-local-variable 'font-lock-defaults)
5947 '(message-font-lock-keywords t))
5948 (set (make-local-variable 'mail-header-separator) "")
5949 (set (make-local-variable 'gnus-article-edit-mode) t)
5950 (easy-menu-add message-mode-field-menu message-mode-map)
5951 (setq buffer-read-only nil)
5952 (buffer-enable-undo)
5955 (defun gnus-article-edit (&optional force)
5956 "Edit the current article.
5957 This will have permanent effect only in mail groups.
5958 If FORCE is non-nil, allow editing of articles even in read-only
5961 (when (and (not force)
5962 (gnus-group-read-only-p))
5963 (error "The current newsgroup does not support article editing"))
5964 (gnus-article-date-original)
5965 (gnus-article-edit-article
5967 `(lambda (no-highlight)
5969 (gnus-summary-edit-article-done
5970 ,(or (mail-header-references gnus-current-headers) "")
5971 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5973 (defun gnus-article-edit-article (start-func exit-func)
5974 "Start editing the contents of the current article buffer."
5975 (let ((winconf (current-window-configuration)))
5976 (set-buffer gnus-article-buffer)
5977 (gnus-article-edit-mode)
5978 (funcall start-func)
5979 (set-buffer-modified-p nil)
5980 (gnus-configure-windows 'edit-article)
5981 (setq gnus-article-edit-done-function exit-func)
5982 (setq gnus-prev-winconf winconf)
5983 (when gnus-article-edit-article-setup-function
5984 (funcall gnus-article-edit-article-setup-function))
5985 (gnus-message 6 "C-c C-c to end edits; C-c C-k to exit")))
5987 (defun gnus-article-edit-done (&optional arg)
5988 "Update the article edits and exit."
5990 (let ((func gnus-article-edit-done-function)
5991 (buf (current-buffer))
5992 (start (window-start))
5994 (winconf gnus-prev-winconf))
5995 (remove-hook 'gnus-article-mode-hook
5996 'gnus-article-mime-edit-article-unwind)
5997 (widen) ;; Widen it in case that users narrowed the buffer.
6000 ;; The cache and backlog have to be flushed somewhat.
6001 (when gnus-keep-backlog
6002 (gnus-backlog-remove-article
6003 (car gnus-article-current) (cdr gnus-article-current)))
6004 ;; Flush original article as well.
6006 (when (get-buffer gnus-original-article-buffer)
6007 (set-buffer gnus-original-article-buffer)
6008 (setq gnus-original-article nil)))
6009 (when gnus-use-cache
6010 (gnus-cache-update-article
6011 (car gnus-article-current) (cdr gnus-article-current)))
6012 ;; We remove all text props from the article buffer.
6013 (kill-all-local-variables)
6014 (set-text-properties (point-min) (point-max) nil)
6016 (set-window-configuration winconf)
6018 (set-window-start (get-buffer-window buf) start)
6019 (set-window-point (get-buffer-window buf) (point)))
6020 (gnus-summary-show-article))
6022 (defun gnus-article-edit-exit ()
6023 "Exit the article editing without updating."
6025 (when (or (not (buffer-modified-p))
6026 (yes-or-no-p "Article modified; kill anyway? "))
6027 (let ((curbuf (current-buffer))
6029 (window-start (window-start)))
6031 (if (gnus-buffer-live-p gnus-original-article-buffer)
6032 (insert-buffer-substring gnus-original-article-buffer))
6033 (let ((winconf gnus-prev-winconf))
6034 (kill-all-local-variables)
6036 (set-window-configuration winconf)
6037 ;; Tippy-toe some to make sure that point remains where it was.
6038 (save-current-buffer
6040 (set-window-start (get-buffer-window (current-buffer)) window-start)
6042 (gnus-summary-show-article)))
6044 (defun gnus-article-edit-full-stops ()
6045 "Interactively repair spacing at end of sentences."
6048 (goto-char (point-min))
6049 (search-forward-regexp "^$" nil t)
6050 (let ((case-fold-search nil))
6051 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
6054 ;;; Article editing with MIME-Edit
6057 (defcustom gnus-article-mime-edit-article-setup-hook nil
6058 "Hook run after setting up a MIME editing article buffer."
6059 :group 'gnus-article-various
6062 (defun gnus-article-mime-edit-article-unwind ()
6063 "Unwind `gnus-article-buffer' if article editing was given up."
6064 (remove-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6065 (when (featurep 'font-lock)
6066 (setq font-lock-defaults nil)
6067 (font-lock-mode -1))
6068 (when mime-edit-mode-flag
6069 (mime-edit-exit 'nomime 'no-error)
6072 (defun gnus-article-mime-edit-article-setup ()
6073 "Convert current buffer to MIME-Edit buffer and turn on MIME-Edit mode
6074 after replacing with the original article."
6075 (setq gnus-show-mime t)
6076 (setq gnus-article-edit-done-function
6077 `(lambda (&rest args)
6078 (when mime-edit-mode-flag
6079 (let (mime-edit-insert-user-agent-field)
6082 (goto-char (point-min))
6083 (let (case-fold-search)
6084 (when (re-search-forward
6085 (format "^%s$" (regexp-quote mail-header-separator))
6087 (replace-match "")))
6088 (apply ,gnus-article-edit-done-function args)
6091 (buffer-substring-no-properties (point-min) (point-max))
6092 (set-buffer (get-buffer-create gnus-original-article-buffer))
6094 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6095 (set-buffer gnus-article-buffer)
6096 (gnus-article-prepare-display)))
6097 (substitute-key-definition 'gnus-article-edit-done
6098 'gnus-article-mime-edit-done
6099 gnus-article-edit-mode-map)
6100 (substitute-key-definition 'gnus-article-edit-exit
6101 'gnus-article-mime-edit-exit
6102 gnus-article-edit-mode-map)
6104 (insert-buffer-substring gnus-original-article-buffer)
6105 (unless (member (with-current-buffer gnus-summary-buffer
6106 gnus-newsgroup-name)
6107 '("nndraft:delayed" "nndraft:drafts"))
6108 (let ((ofn (symbol-function 'mime-edit-decode-single-part-in-buffer)))
6109 (fset 'mime-edit-decode-single-part-in-buffer
6110 (lambda (&rest args)
6111 (if (let ((content-type (car args)))
6112 (and (eq 'message (mime-content-type-primary-type
6114 (eq 'rfc822 (mime-content-type-subtype
6116 (setcar (cdr args) 'not-decode-text))
6120 (fset 'mime-edit-decode-single-part-in-buffer ofn))))
6121 (when (featurep 'font-lock)
6122 (set (make-local-variable 'font-lock-defaults)
6123 '(message-font-lock-keywords t))
6124 (font-lock-set-defaults)
6125 (turn-on-font-lock))
6126 (set-buffer-modified-p nil)
6127 (delete-other-windows)
6128 (add-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6129 (gnus-run-hooks 'gnus-article-mime-edit-article-setup-hook))
6131 (defun gnus-article-mime-edit-done (&optional arg)
6132 "Update the article MIME edits and exit."
6134 (when (featurep 'font-lock)
6135 (setq font-lock-defaults nil)
6136 (font-lock-mode -1))
6137 (let ((inhibit-read-only t))
6138 (gnus-article-edit-done arg)))
6140 (defun gnus-article-mime-edit-exit ()
6141 "Exit the article MIME editing without updating."
6143 (when (or (not (buffer-modified-p))
6144 (yes-or-no-p "Article modified; kill anyway? "))
6145 (when (featurep 'font-lock)
6146 (setq font-lock-defaults nil)
6147 (font-lock-mode -1))
6148 (when mime-edit-mode-flag
6149 (let (mime-edit-insert-user-agent-field)
6152 (goto-char (point-min))
6153 (let (case-fold-search)
6154 (when (re-search-forward
6155 (format "^%s$" (regexp-quote mail-header-separator)) nil t)
6156 (replace-match "")))
6157 (let ((winconf gnus-prev-winconf))
6159 (buffer-substring-no-properties (point-min) (point-max))
6160 (set-buffer (get-buffer-create gnus-original-article-buffer))
6162 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6163 (set-buffer gnus-article-buffer)
6164 (gnus-article-prepare-display)
6165 (set-window-configuration winconf))))
6168 ;;; Article highlights
6171 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
6173 ;;; Internal Variables:
6175 (defcustom gnus-button-url-regexp
6176 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
6177 "\\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:]]\\)"
6178 "\\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\\)\\)")
6179 "Regular expression that matches URLs."
6180 :group 'gnus-article-buttons
6183 (defcustom gnus-button-valid-fqdn-regexp
6184 message-valid-fqdn-regexp
6185 "Regular expression that matches a valid FQDN."
6186 :group 'gnus-article-buttons
6189 (defcustom gnus-button-man-handler 'manual-entry
6190 "Function to use for displaying man pages.
6191 The function must take at least one argument with a string naming the
6193 :type '(choice (function-item :tag "Man" manual-entry)
6194 (function-item :tag "Woman" woman)
6195 (function :tag "Other"))
6196 :group 'gnus-article-buttons)
6198 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
6199 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
6200 If the default site is too slow, try to find a CTAN mirror, see
6201 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
6202 the variable `gnus-button-handle-ctan'."
6203 :group 'gnus-article-buttons
6204 :link '(custom-manual "(gnus)Group Parameters")
6205 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
6206 (const "http://tug.ctan.org/tex-archive/")
6207 (const "http://www.dante.de/CTAN/")
6208 (string :tag "Other")))
6210 (defcustom gnus-button-ctan-handler 'browse-url
6211 "Function to use for displaying CTAN links.
6212 The function must take one argument, the string naming the URL."
6213 :type '(choice (function-item :tag "Browse Url" browse-url)
6214 (function :tag "Other"))
6215 :group 'gnus-article-buttons)
6217 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
6218 "Bogus strings removed from CTAN URLs."
6219 :group 'gnus-article-buttons
6220 :type '(choice (const "^/?tex-archive/\\|/")
6221 (regexp :tag "Other")))
6223 (defcustom gnus-button-ctan-directory-regexp
6226 "biblio\\|digests\\|dviware\\|fonts\\|graphics\\|help\\|"
6227 "indexing\\|info\\|language\\|macros\\|support\\|systems\\|"
6228 "tds\\|tools\\|usergrps\\|web\\|nonfree\\|obsolete"
6230 "Regular expression for ctan directories.
6231 It should match all directories in the top level of `gnus-ctan-url'."
6232 :group 'gnus-article-buttons
6235 (defcustom gnus-button-mid-or-mail-regexp
6236 (concat "\\b\\(<?[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t ]*@"
6237 ;; Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
6238 gnus-button-valid-fqdn-regexp
6240 "Regular expression that matches a message ID or a mail address."
6241 :group 'gnus-article-buttons
6244 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
6245 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
6246 Strings like this can be either a message ID or a mail address. If it is one
6247 of the symbols `mid' or `mail', Gnus will always assume that the string is a
6248 message ID or a mail address, respectively. If this variable is set to the
6249 symbol `ask', always query the user what do do. If it is a function, this
6250 function will be called with the string as it's only argument. The function
6251 must return `mid', `mail', `invalid' or `ask'."
6252 :group 'gnus-article-buttons
6253 :type '(choice (function-item :tag "Heuristic function"
6254 gnus-button-mid-or-mail-heuristic)
6259 (defcustom gnus-button-mid-or-mail-heuristic-alist
6260 '((-10.0 . ".+\\$.+@")
6263 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
6264 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
6265 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
6266 (-1.0 . "^[^a-z]+@")
6268 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
6269 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
6270 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
6271 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
6274 (-1.0 . "^[0-9][0-9]")
6276 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
6277 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6278 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
6279 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6281 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
6282 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
6285 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
6287 ;; compensation for TDMA dated mail addresses:
6288 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
6290 (-20.0 . "\\.fsf@") ;; Gnus
6293 (-20.0 . "_-_") ;; Subject change in thread
6295 (-20.0 . "\\.ln@") ;; leafnode
6296 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
6297 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
6299 ;; (5.0 . "") ;; $local_part_len <= 7
6300 (10.0 . "^[^0-9]+@")
6301 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
6302 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
6305 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
6307 (0.5 . "^[A-Z][a-z]")
6308 (0.5 . "^[A-Z][a-z][a-z]")
6309 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
6310 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
6311 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
6313 A negative RATE indicates a message IDs, whereas a positive indicates a mail
6314 address. The REGEXP is processed with `case-fold-search' set to nil."
6315 :group 'gnus-article-buttons
6316 :type '(repeat (cons (number :tag "Rate")
6317 (regexp :tag "Regexp"))))
6319 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
6320 "Guess whether MID-OR-MAIL is a message ID or a mail address.
6321 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
6322 address, `ask' if unsure and `invalid' if the string is invalid."
6323 (let ((case-fold-search nil)
6324 (list gnus-button-mid-or-mail-heuristic-alist)
6325 (result 0) rate regexp lpartlen elem)
6327 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
6328 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
6329 ;; Certain special cases...
6332 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
6333 "^[0-9]+\\.[0-9]+@compuserve\\|"
6334 "@public\\.gmane\\.org")
6336 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
6337 (setq result 'mail))
6338 (when (string-match "@.*@\\| " mid-or-mail)
6339 (gnus-message 8 "`%s' is invalid." mid-or-mail)
6340 (setq result 'invalid))
6341 ;; Nothing more to do, if result is not a number here...
6342 (when (numberp result)
6344 (setq elem (car list)
6348 (when (string-match regexp mid-or-mail)
6349 (setq result (+ result rate))
6351 9 "`%s' matched `%s', rate `%s', result `%s'."
6352 mid-or-mail regexp rate result)))
6353 (when (<= lpartlen 7)
6354 (setq result (+ result 5.0))
6355 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
6356 mid-or-mail result))
6357 (when (>= lpartlen 12)
6358 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
6360 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
6361 ;; Long local part should contain realname if e-mail address,
6362 ;; too many digits: message-id.
6363 ;; $score -= 5.0 + 0.1 * $local_part_len;
6364 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6365 (setq result (+ result rate))
6367 9 "Many digits in `%s', rate `%s', result `%s'."
6368 mid-or-mail rate result))
6369 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6371 ;; Too few vowels [^aeiouy]{4,}.*\@
6372 (setq result (+ result -5.0))
6374 9 "Few vowels in `%s', rate `%s', result `%s'."
6375 mid-or-mail -5.0 result))
6377 (setq result (+ result 5.0))
6379 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6380 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6381 ;; Maybe we should make this a customizable alist: (condition . 'result)
6383 ((symbolp result) result)
6384 ;; Now convert number into proper results:
6385 ((< result -10.0) 'mid)
6386 ((> result 10.0) 'mail)
6389 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6390 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6391 (url-mid (concat "news" ":" mid-or-mail))
6392 (url-mailto (concat "mailto" ":" mid-or-mail)))
6393 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6394 (when (fboundp pref)
6396 ;; get rid of surrounding angles...
6398 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6399 (if (or (eq 'mid guessed) (eq 'mail guessed))
6403 (save-window-excursion
6404 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6407 (cond ((eq pref 'mid)
6408 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6409 (gnus-button-handle-news url-mid))
6411 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6412 (gnus-url-mailto url-mailto))
6413 (t (gnus-message 3 "Invalid string.")))))
6415 (defun gnus-button-handle-custom (url)
6416 "Follow a Custom URL."
6417 (customize-apropos (gnus-url-unhex-string url)))
6419 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6421 ;; FIXME: Maybe we should merge some of the functions that do quite similar
6424 (defun gnus-button-handle-describe-function (url)
6425 "Call `describe-function' when pushing the corresponding URL button."
6428 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6430 (defun gnus-button-handle-describe-variable (url)
6431 "Call `describe-variable' when pushing the corresponding URL button."
6434 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6436 (defun gnus-button-handle-symbol (url)
6437 "Display help on variable or function.
6438 Calls `describe-variable' or `describe-function'."
6439 (let ((sym (intern url)))
6441 ((fboundp sym) (describe-function sym))
6442 ((boundp sym) (describe-variable sym))
6443 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
6445 (defun gnus-button-handle-describe-key (url)
6446 "Call `describe-key' when pushing the corresponding URL button."
6448 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6449 (keys (ignore-errors (eval `(kbd ,key-string)))))
6452 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6454 (defun gnus-button-handle-apropos (url)
6455 "Call `apropos' when pushing the corresponding URL button."
6456 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6458 (defun gnus-button-handle-apropos-command (url)
6459 "Call `apropos' when pushing the corresponding URL button."
6461 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6463 (defun gnus-button-handle-apropos-variable (url)
6464 "Call `apropos' when pushing the corresponding URL button."
6466 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6467 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6469 (defun gnus-button-handle-apropos-documentation (url)
6470 "Call `apropos' when pushing the corresponding URL button."
6472 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6473 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6475 (defun gnus-button-handle-library (url)
6476 "Call `locate-library' when pushing the corresponding URL button."
6477 (gnus-message 9 "url=`%s'" url)
6478 (let* ((lib (locate-library url))
6479 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6481 (gnus-message 1 "Cannot locale library `%s'." url)
6482 (find-file-read-only file))))
6484 (defun gnus-button-handle-ctan (url)
6485 "Call `browse-url' when pushing a CTAN URL button."
6487 gnus-button-ctan-handler
6490 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6492 (defcustom gnus-button-tex-level 5
6493 "*Integer that says how many TeX-related buttons Gnus will show.
6494 The higher the number, the more buttons will appear and the more false
6495 positives are possible. Note that you can set this variable local to
6496 specific groups. Setting it higher in TeX groups is probably a good idea.
6497 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6498 how to set variables in specific groups."
6499 :group 'gnus-article-buttons
6500 :link '(custom-manual "(gnus)Group Parameters")
6503 (defcustom gnus-button-man-level 5
6504 "*Integer that says how many man-related buttons Gnus will show.
6505 The higher the number, the more buttons will appear and the more false
6506 positives are possible. Note that you can set this variable local to
6507 specific groups. Setting it higher in Unix groups is probably a good idea.
6508 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6509 how to set variables in specific groups."
6510 :group 'gnus-article-buttons
6511 :link '(custom-manual "(gnus)Group Parameters")
6514 (defcustom gnus-button-emacs-level 5
6515 "*Integer that says how many emacs-related buttons Gnus will show.
6516 The higher the number, the more buttons will appear and the more false
6517 positives are possible. Note that you can set this variable local to
6518 specific groups. Setting it higher in Emacs or Gnus related groups is
6519 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6520 `gnus-parameters' on how to set variables in specific groups."
6521 :group 'gnus-article-buttons
6522 :link '(custom-manual "(gnus)Group Parameters")
6525 (defcustom gnus-button-message-level 5
6526 "*Integer that says how many buttons for news or mail messages will appear.
6527 The higher the number, the more buttons will appear and the more false
6528 positives are possible."
6529 ;; mail addresses, MIDs, URLs for news, ...
6530 :group 'gnus-article-buttons
6533 (defcustom gnus-button-browse-level 5
6534 "*Integer that says how many buttons for browsing will appear.
6535 The higher the number, the more buttons will appear and the more false
6536 positives are possible."
6537 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6538 :group 'gnus-article-buttons
6541 (defcustom gnus-button-alist
6542 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6543 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6544 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
6545 gnus-button-handle-news 2)
6546 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6547 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6548 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6549 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6550 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
6551 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
6552 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
6553 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6554 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6555 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6556 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6557 ;; RFC 2368 (The mailto URL scheme)
6558 ("mailto:\\([-a-z.@_+0-9%=?&]+\\)"
6559 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6560 ("\\bmailto:\\([^ \n\t]+\\)"
6561 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6563 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6564 gnus-button-ctan-directory-regexp
6565 "[^][>)!;:,'\n\t ]+\\)")
6566 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6567 ((concat "\\btex-archive/\\("
6568 gnus-button-ctan-directory-regexp
6569 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6570 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6573 gnus-button-ctan-directory-regexp
6574 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6575 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6576 ;; This is info (home-grown style) <info://foo/bar+baz>
6577 ("\\binfo://\\([^'\">\n\t ]+\\)"
6578 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6579 ;; Info GNOME style <info:foo#bar_baz>
6580 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6581 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6582 ;; Info KDE style <info:(foo)bar baz>
6583 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6584 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6585 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6586 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6587 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6588 ;; Info links like `C-h i d m CC Mode RET'
6589 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6591 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6592 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6593 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6594 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6595 ;; Emacs help commands
6596 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6597 ;; regexp doesn't match arguments containing ` '.
6598 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6599 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6600 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6601 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6602 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6603 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6604 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6605 ;; The following entries may lead to many false positives so don't enable
6606 ;; them by default (use a high button level):
6607 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>"
6608 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6609 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6610 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6611 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6612 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6613 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6614 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6615 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6616 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6617 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6618 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
6619 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6620 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6621 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6622 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6623 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6624 ;; Unlike the other regexps we really have to require quoting
6625 ;; here to determine where it ends.
6626 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6627 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
6628 ("<URL: *\\([^<>]*\\)>"
6629 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6630 ;; RFC 2396 (2.4.3., delims) ...
6631 ("\"URL: *\\([^\"]*\\)\""
6632 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6633 ;; RFC 2396 (2.4.3., delims) ...
6634 ("\"URL: *\\([^\"]*\\)\""
6635 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6637 (gnus-button-url-regexp
6638 0 (>= gnus-button-browse-level 0) browse-url 0)
6640 ("\\b\\([a-z][a-z]+\\)([1-9])\\W"
6641 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6642 gnus-button-handle-man 1)
6643 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6644 ("\\b\\([a-z][-_.a-z0-9]+\\)([1-9])\\W"
6645 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6646 gnus-button-handle-man 1)
6647 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6648 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6649 ("\\b\\([a-z][-+_.:a-z0-9]+\\)([1-9][X1a-z]*)\\W\\|\\b\\(X\\)([1-9])\\W"
6650 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6651 ;; MID or mail: To avoid too many false positives we don't try to catch
6652 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6653 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6654 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6655 ;; so that non-ambiguous entries (see above) match first.
6656 (gnus-button-mid-or-mail-regexp
6657 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6658 "*Alist of regexps matching buttons in article bodies.
6660 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6661 REGEXP: is the string (case insensitive) matching text around the button (can
6662 also be Lisp expression evaluating to a string),
6663 BUTTON: is the number of the regexp grouping actually matching the button,
6664 FORM: is a Lisp expression which must eval to true for the button to
6666 CALLBACK: is the function to call when the user push this button, and each
6667 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6669 CALLBACK can also be a variable, in that case the value of that
6670 variable it the real callback function."
6671 :group 'gnus-article-buttons
6672 :type '(repeat (list (choice regexp variable sexp)
6673 (integer :tag "Button")
6675 (function :tag "Callback")
6678 (integer :tag "Regexp group")))))
6680 (defcustom gnus-header-button-alist
6681 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
6682 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6683 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6684 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6685 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6686 0 (>= gnus-button-message-level 0) gnus-button-mailto 0)
6687 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6688 0 (>= gnus-button-browse-level 0) browse-url 0)
6689 ("^Subject:" gnus-button-url-regexp
6690 0 (>= gnus-button-browse-level 0) browse-url 0)
6691 ("^[^:]+:" gnus-button-url-regexp
6692 0 (>= gnus-button-browse-level 0) browse-url 0)
6693 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&]+\\)"
6694 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6695 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6696 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6697 "*Alist of headers and regexps to match buttons in article heads.
6699 This alist is very similar to `gnus-button-alist', except that each
6700 alist has an additional HEADER element first in each entry:
6702 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6704 HEADER is a regexp to match a header. For a fuller explanation, see
6705 `gnus-button-alist'."
6706 :group 'gnus-article-buttons
6707 :group 'gnus-article-headers
6708 :type '(repeat (list (regexp :tag "Header")
6709 (choice regexp variable)
6710 (integer :tag "Button")
6712 (function :tag "Callback")
6715 (integer :tag "Regexp group")))))
6717 (defvar gnus-button-regexp nil)
6718 (defvar gnus-button-marker-list nil)
6719 ;; Regexp matching any of the regexps from `gnus-button-alist'.
6721 (defvar gnus-button-last nil)
6722 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
6726 (defun gnus-article-push-button (event)
6727 "Check text under the mouse pointer for a callback function.
6728 If the text under the mouse pointer has a `gnus-callback' property,
6729 call it with the value of the `gnus-data' text property."
6731 (set-buffer (window-buffer (posn-window (event-start event))))
6732 (let* ((pos (posn-point (event-start event)))
6733 (data (get-text-property pos 'gnus-data))
6734 (fun (get-text-property pos 'gnus-callback)))
6737 (funcall fun data))))
6739 (defun gnus-article-press-button ()
6740 "Check text at point for a callback function.
6741 If the text at point has a `gnus-callback' property,
6742 call it with the value of the `gnus-data' text property."
6744 (let ((data (get-text-property (point) 'gnus-data))
6745 (fun (get-text-property (point) 'gnus-callback)))
6747 (funcall fun data))))
6749 (defun gnus-article-prev-button (n)
6750 "Move point to N buttons backward.
6751 If N is negative, move forward instead."
6753 (gnus-article-next-button (- n)))
6755 (defun gnus-article-next-button (n)
6756 "Move point to N buttons forward.
6757 If N is negative, move backward instead."
6759 (let ((function (if (< n 0) 'previous-single-property-change
6760 'next-single-property-change))
6761 (inhibit-point-motion-hooks t)
6763 (limit (if (< n 0) (point-min) (point-max))))
6765 (while (and (not (= limit (point)))
6767 ;; Skip past the current button.
6768 (when (get-text-property (point) 'gnus-callback)
6769 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6770 ;; Go to the next (or previous) button.
6771 (gnus-goto-char (funcall function (point) 'gnus-callback nil limit))
6772 ;; Put point at the start of the button.
6773 (when (and backward (not (get-text-property (point) 'gnus-callback)))
6774 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6775 ;; Skip past intangible buttons.
6776 (when (get-text-property (point) 'intangible)
6780 (gnus-message 5 "No more buttons"))
6783 (defun gnus-article-highlight (&optional force)
6784 "Highlight current article.
6785 This function calls `gnus-article-highlight-headers',
6786 `gnus-article-highlight-citation',
6787 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6788 do the highlighting. See the documentation for those functions."
6789 (interactive (list 'force))
6790 (gnus-article-highlight-headers)
6791 (gnus-article-highlight-citation force)
6792 (gnus-article-highlight-signature)
6793 (gnus-article-add-buttons force)
6794 (gnus-article-add-buttons-to-head))
6796 (defun gnus-article-highlight-some (&optional force)
6797 "Highlight current article.
6798 This function calls `gnus-article-highlight-headers',
6799 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6800 do the highlighting. See the documentation for those functions."
6801 (interactive (list 'force))
6802 (gnus-article-highlight-headers)
6803 (gnus-article-highlight-signature)
6804 (gnus-article-add-buttons))
6806 (defun gnus-article-highlight-headers ()
6807 "Highlight article headers as specified by `gnus-header-face-alist'."
6809 (gnus-with-article-headers
6810 (let ((alist gnus-header-face-alist)
6811 entry regexp header-face field-face from hpoints fpoints)
6812 (while (setq entry (pop alist))
6813 (goto-char (point-min))
6814 (setq regexp (concat "^\\("
6815 (if (string-equal "" (nth 0 entry))
6819 header-face (nth 1 entry)
6820 field-face (nth 2 entry))
6821 (while (and (re-search-forward regexp nil t)
6825 (unless (search-forward ":" nil t)
6827 (when (and header-face
6828 (not (memq (point) hpoints)))
6829 (push (point) hpoints)
6830 (gnus-put-text-property from (point) 'face header-face))
6831 (when (and field-face
6832 (not (memq (setq from (point)) fpoints)))
6834 (if (re-search-forward "^[^ \t]" nil t)
6836 (goto-char (point-max)))
6837 (gnus-put-text-property from (point) 'face field-face)))))))
6839 (defun gnus-article-highlight-signature ()
6840 "Highlight the signature in an article.
6841 It does this by highlighting everything after
6842 `gnus-signature-separator' using `gnus-signature-face'."
6844 (when gnus-signature-face
6845 (gnus-with-article-buffer
6846 (let ((inhibit-point-motion-hooks t))
6848 (when (gnus-article-narrow-to-signature)
6849 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6850 'face gnus-signature-face)))))))
6852 (defun gnus-article-buttonize-signature ()
6853 "Add button to the signature."
6856 (set-buffer gnus-article-buffer)
6857 (let ((buffer-read-only nil)
6858 (inhibit-point-motion-hooks t))
6859 (when (gnus-article-search-signature)
6860 (gnus-article-add-button (match-beginning 0) (match-end 0)
6861 'gnus-signature-toggle
6862 (set-marker (make-marker)
6863 (1+ (match-end 0))))))))
6865 (defun gnus-button-in-region-p (b e prop)
6866 "Say whether PROP exists in the region."
6867 (text-property-not-all b e prop nil))
6869 (defun gnus-article-add-buttons (&optional force)
6870 "Find external references in the article and make buttons of them.
6871 \"External references\" are things like Message-IDs and URLs, as
6872 specified by `gnus-button-alist'."
6873 (interactive (list 'force))
6874 (gnus-with-article-buffer
6875 (let ((inhibit-point-motion-hooks t)
6876 (case-fold-search t)
6877 (alist gnus-button-alist)
6879 ;; Remove all old markers.
6880 (let (marker entry new-list)
6881 (while (setq marker (pop gnus-button-marker-list))
6882 (if (or (< marker (point-min)) (>= marker (point-max)))
6883 (push marker new-list)
6885 (when (setq entry (gnus-button-entry))
6886 (put-text-property (match-beginning (nth 1 entry))
6887 (match-end (nth 1 entry))
6888 'gnus-callback nil))
6889 (set-marker marker nil)))
6890 (setq gnus-button-marker-list new-list))
6891 ;; We skip the headers.
6894 (while (setq entry (pop alist))
6895 (setq regexp (eval (car entry)))
6897 (while (re-search-forward regexp nil t)
6898 (let* ((start (and entry (match-beginning (nth 1 entry))))
6899 (end (and entry (match-end (nth 1 entry))))
6900 (from (match-beginning 0)))
6901 (when (and (or (eq t (nth 2 entry))
6902 (eval (nth 2 entry)))
6903 (not (gnus-button-in-region-p
6904 start end 'gnus-callback)))
6905 ;; That optional form returned non-nil, so we add the
6907 (gnus-article-add-button
6908 start end 'gnus-button-push
6909 (car (push (set-marker (make-marker) from)
6910 gnus-button-marker-list))))))))))
6912 ;; Add buttons to the head of an article.
6913 (defun gnus-article-add-buttons-to-head ()
6914 "Add buttons to the head of the article."
6916 (gnus-with-article-headers
6917 (let ((alist gnus-header-button-alist)
6920 ;; Each alist entry.
6921 (setq entry (pop alist))
6922 (goto-char (point-min))
6923 (while (re-search-forward (car entry) nil t)
6924 ;; Each header matching the entry.
6925 (setq beg (match-beginning 0))
6926 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6927 (match-beginning 0))
6930 (while (re-search-forward (eval (nth 1 entry)) end t)
6931 ;; Each match within a header.
6932 (let* ((entry (cdr entry))
6933 (start (match-beginning (nth 1 entry)))
6934 (end (match-end (nth 1 entry)))
6935 (form (nth 2 entry)))
6936 (goto-char (match-end 0))
6938 (gnus-article-add-button
6939 start end (nth 3 entry)
6940 (buffer-substring (match-beginning (nth 4 entry))
6941 (match-end (nth 4 entry)))))))
6942 (goto-char end))))))
6944 ;;; External functions:
6946 (defun gnus-article-add-button (from to fun &optional data)
6947 "Create a button between FROM and TO with callback FUN and data DATA."
6948 (when gnus-article-button-face
6949 (gnus-overlay-put (gnus-make-overlay from to)
6950 'face gnus-article-button-face))
6951 (gnus-add-text-properties
6953 (nconc (and gnus-article-mouse-face
6954 (list gnus-mouse-face-prop gnus-article-mouse-face))
6955 (list 'gnus-callback fun)
6956 (and data (list 'gnus-data data))))
6957 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6958 :button-keymap gnus-widget-button-keymap))
6960 ;;; Internal functions:
6962 (defun gnus-article-set-globals ()
6963 (with-current-buffer gnus-summary-buffer
6964 (gnus-set-global-variables)))
6966 (defun gnus-signature-toggle (end)
6967 (gnus-with-article-buffer
6968 (let ((inhibit-point-motion-hooks t)
6969 (limit (next-single-property-change end 'mime-view-entity
6971 (if (text-property-any end limit 'article-type 'signature)
6973 (gnus-delete-wash-type 'signature)
6974 (gnus-remove-text-properties-when
6975 'article-type 'signature end limit
6976 (cons 'article-type (cons 'signature
6977 gnus-hidden-properties))))
6978 (gnus-add-wash-type 'signature)
6979 (gnus-add-text-properties-when
6980 'article-type nil end limit
6981 (cons 'article-type (cons 'signature
6982 gnus-hidden-properties)))))
6983 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6984 (gnus-set-mode-line 'article))))
6986 (defun gnus-button-entry ()
6987 ;; Return the first entry in `gnus-button-alist' matching this place.
6988 (let ((alist gnus-button-alist)
6991 (setq entry (pop alist))
6992 (if (looking-at (eval (car entry)))
6997 (defun gnus-button-push (marker)
6998 ;; Push button starting at MARKER.
7001 (let* ((entry (gnus-button-entry))
7002 (inhibit-point-motion-hooks t)
7004 (args (mapcar (lambda (group)
7005 (let ((string (match-string group)))
7006 (set-text-properties
7007 0 (length string) nil string)
7014 (fboundp (symbol-value fun)))
7015 (apply (symbol-value fun) args))
7017 (gnus-message 1 "You must define `%S' to use this button"
7018 (cons fun args)))))))
7020 (defun gnus-parse-news-url (url)
7021 (let (scheme server group message-id articles)
7024 (goto-char (point-min))
7025 (when (looking-at "\\([A-Za-z]+\\):")
7026 (setq scheme (match-string 1))
7027 (goto-char (match-end 0)))
7028 (when (looking-at "//\\([^/]+\\)/")
7029 (setq server (match-string 1))
7030 (goto-char (match-end 0)))
7033 ((looking-at "\\(.*@.*\\)")
7034 (setq message-id (match-string 1)))
7035 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
7036 (setq group (match-string 1)
7037 articles (split-string (match-string 2) "-")))
7038 ((looking-at "\\([^/]+\\)/?")
7039 (setq group (match-string 1)))
7041 (error "Unknown news URL syntax"))))
7042 (list scheme server group message-id articles)))
7044 (defun gnus-button-handle-news (url)
7046 (destructuring-bind (scheme server group message-id articles)
7047 (gnus-parse-news-url url)
7051 (set-buffer gnus-summary-buffer)
7053 (let ((gnus-refer-article-method (list (list 'nntp server))))
7054 (gnus-summary-refer-article message-id))
7055 (gnus-summary-refer-article message-id))))
7057 (gnus-button-fetch-group url)))))
7059 (defun gnus-button-handle-man (url)
7061 (funcall gnus-button-man-handler url))
7063 (defun gnus-button-handle-info-url (url)
7064 "Fetch an info URL."
7065 (setq url (mm-subst-char-in-string ?+ ?\ url))
7067 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
7068 (gnus-info-find-node
7069 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
7071 ")" (gnus-url-unhex-string (match-string 2 url)))))
7072 ((string-match "([^)\"]+)[^\"]+" url)
7074 (gnus-replace-in-string
7075 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
7076 (gnus-info-find-node url))
7077 (t (error "Can't parse %s" url))))
7079 (defun gnus-button-handle-info-url-gnome (url)
7080 "Fetch GNOME style info URL."
7081 (setq url (mm-subst-char-in-string ?_ ?\ url))
7082 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
7083 (gnus-info-find-node
7085 (gnus-url-unhex-string
7086 (match-string 1 url))
7088 (or (gnus-url-unhex-string
7089 (match-string 2 url))
7091 (error "Can't parse %s" url)))
7093 (defun gnus-button-handle-info-url-kde (url)
7094 "Fetch KDE style info URL."
7095 (gnus-info-find-node (gnus-url-unhex-string url)))
7097 (defun gnus-button-handle-info-keystrokes (url)
7098 "Call `info' when pushing the corresponding URL button."
7099 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
7104 (defun gnus-button-message-id (message-id)
7106 (with-current-buffer gnus-summary-buffer
7107 (gnus-summary-refer-article message-id)))
7109 (defun gnus-button-fetch-group (address)
7110 "Fetch GROUP specified by ADDRESS."
7111 (if (not (string-match "[:/]" address))
7112 ;; This is just a simple group url.
7113 (gnus-group-read-ephemeral-group address gnus-select-method)
7116 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
7118 (error "Can't parse %s" address)
7119 (gnus-group-read-ephemeral-group
7120 (match-string 4 address)
7121 `(nntp ,(match-string 1 address)
7122 (nntp-address ,(match-string 1 address))
7123 (nntp-port-number ,(if (match-end 3)
7124 (match-string 3 address)
7127 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
7129 (defun gnus-url-parse-query-string (query &optional downcase)
7130 (let (retval pairs cur key val)
7131 (setq pairs (split-string query "&"))
7133 (setq cur (car pairs)
7135 (if (not (string-match "=" cur))
7137 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
7138 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
7140 (setq key (downcase key)))
7141 (setq cur (assoc key retval))
7143 (setcdr cur (cons val (cdr cur)))
7144 (setq retval (cons (list key val) retval)))))
7147 (defun gnus-url-mailto (url)
7148 ;; Send mail to someone
7149 (when (string-match "mailto:/*\\(.*\\)" url)
7150 (setq url (substring url (match-beginning 1) nil)))
7151 (let (to args subject func)
7152 (setq args (gnus-url-parse-query-string
7153 (if (string-match "^\\?" url)
7155 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
7156 (concat "to=" (match-string 1 url) "&"
7157 (match-string 2 url))
7158 (concat "to=" url)))
7160 subject (cdr-safe (assoc "subject" args)))
7163 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
7166 (message-position-on-field (caar args)))
7167 (insert (gnus-replace-in-string
7168 (mapconcat 'identity (reverse (cdar args)) ", ")
7170 (setq args (cdr args)))
7173 (message-goto-subject))))
7175 (defun gnus-button-embedded-url (address)
7176 "Activate ADDRESS with `browse-url'."
7177 (browse-url (gnus-strip-whitespace address)))
7179 ;;; Next/prev buttons in the article buffer.
7181 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
7182 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
7184 (defvar gnus-prev-page-map
7185 (let ((map (make-sparse-keymap)))
7186 (define-key map gnus-mouse-2 'gnus-button-prev-page)
7187 (define-key map "\r" 'gnus-button-prev-page)
7190 (defvar gnus-next-page-map
7191 (let ((map (make-sparse-keymap)))
7192 (define-key map gnus-mouse-2 'gnus-button-next-page)
7193 (define-key map "\r" 'gnus-button-next-page)
7196 (defun gnus-insert-prev-page-button ()
7198 (buffer-read-only nil)
7199 (situation (get-text-property (point-min) 'mime-view-situation)))
7201 gnus-prev-page-line-format nil
7202 `(keymap ,gnus-prev-page-map
7204 gnus-callback gnus-article-button-prev-page
7205 article-type annotation
7206 mime-view-situation ,situation))
7207 (widget-convert-button
7209 ;; Exclude a newline.
7212 :action 'gnus-button-prev-page
7213 :button-keymap gnus-prev-page-map)))
7215 (defun gnus-button-next-page (&optional args more-args)
7216 "Go to the next page."
7218 (let ((win (selected-window)))
7219 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7220 (gnus-article-next-page)
7221 (select-window win)))
7223 (defun gnus-button-prev-page (&optional args more-args)
7224 "Go to the prev page."
7226 (let ((win (selected-window)))
7227 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7228 (gnus-article-prev-page)
7229 (select-window win)))
7231 (defun gnus-insert-next-page-button ()
7233 (buffer-read-only nil)
7234 (situation (get-text-property (point-min) 'mime-view-situation)))
7235 (gnus-eval-format gnus-next-page-line-format nil
7236 `(keymap ,gnus-next-page-map
7238 gnus-callback gnus-article-button-next-page
7239 article-type annotation
7240 mime-view-situation ,situation))
7241 (widget-convert-button
7243 ;; Exclude a newline.
7246 :action 'gnus-button-next-page
7247 :button-keymap gnus-next-page-map)))
7249 (defun gnus-article-button-next-page (arg)
7250 "Go to the next page."
7252 (let ((win (selected-window)))
7253 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7254 (gnus-article-next-page)
7255 (select-window win)))
7257 (defun gnus-article-button-prev-page (arg)
7258 "Go to the prev page."
7260 (let ((win (selected-window)))
7261 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7262 (gnus-article-prev-page)
7263 (select-window win)))
7265 (defvar gnus-decode-header-methods
7266 '(mail-decode-encoded-word-region)
7267 "List of methods used to decode headers.
7269 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
7270 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
7271 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
7272 whose names match REGEXP.
7275 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
7276 mail-decode-encoded-word-region
7277 (\"chinese\" . rfc1843-decode-region))
7280 (defvar gnus-decode-header-methods-cache nil)
7282 (defun gnus-multi-decode-header (start end)
7283 "Apply the functions from `gnus-encoded-word-methods' that match."
7284 (unless (and gnus-decode-header-methods-cache
7285 (eq gnus-newsgroup-name
7286 (car gnus-decode-header-methods-cache)))
7287 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
7290 (nconc gnus-decode-header-methods-cache (list x))
7291 (if (and gnus-newsgroup-name
7292 (string-match (car x) gnus-newsgroup-name))
7293 (nconc gnus-decode-header-methods-cache
7295 gnus-decode-header-methods))
7296 (let ((xlist gnus-decode-header-methods-cache))
7299 (narrow-to-region start end)
7301 (funcall (pop xlist) (point-min) (point-max))))))
7304 ;;; Treatment top-level handling.
7307 (defun gnus-treat-article (condition &optional part-number total-parts type)
7308 (let ((length (- (point-max) (point-min)))
7309 (alist gnus-treatment-function-alist)
7310 (article-goto-body-goes-to-point-min-p t)
7314 (let ((list gnus-article-treat-types))
7316 (when (string-match (pop list) type)
7317 (throw 'found t)))))))
7318 (highlightp (gnus-visual-p 'article-highlight 'highlight))
7319 (entity (static-unless (featurep 'xemacs)
7320 (when (eq 'head condition)
7321 (get-text-property (point-min) 'mime-view-entity))))
7322 val elem buttonized)
7323 (gnus-run-hooks 'gnus-part-display-hook)
7324 (unless gnus-inhibit-treatment
7325 (dolist (elem alist)
7328 (when (gnus-buffer-live-p gnus-summary-buffer)
7329 (set-buffer gnus-summary-buffer))
7330 (symbol-value (car elem))))
7331 (when (and (or (consp val)
7333 (gnus-treat-predicate val)
7334 (or (not (get (car elem) 'highlight))
7336 (when (and (not buttonized)
7338 '(gnus-treat-hide-signature
7339 gnus-treat-highlight-signature)))
7340 (gnus-article-buttonize-signature)
7341 (setq buttonized t))
7343 (funcall (cadr elem)))))
7344 ;; FSF Emacsen does not inherit the existing text properties
7345 ;; in the new text, so we should do it for `mime-view-entity'.
7346 (static-unless (featurep 'xemacs)
7348 (put-text-property (point-min) (point-max)
7349 'mime-view-entity entity))))))
7351 ;; Dynamic variables.
7353 (defvar part-number)
7354 (defvar total-parts)
7359 (defun gnus-treat-predicate (val)
7364 (stringp (car val)))
7365 (apply 'gnus-or (mapcar `(lambda (s)
7366 (string-match s ,(or gnus-newsgroup-name "")))
7369 (let ((pred (pop val)))
7372 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
7374 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
7376 (not (gnus-treat-predicate (car val))))
7378 (equal (car val) type))
7380 (error "%S is not a valid predicate" pred)))))
7390 (eq part-number total-parts))
7394 (error "%S is not a valid value" val))))
7396 (defun gnus-article-encrypt-body (protocol &optional n)
7397 "Encrypt the article body."
7400 (or gnus-article-encrypt-protocol
7401 (completing-read "Encrypt protocol: "
7402 gnus-article-encrypt-protocol-alist
7404 current-prefix-arg))
7405 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7407 (error (format "Can't find the encrypt protocol %s" protocol)))
7408 (if (member gnus-newsgroup-name '("nndraft:delayed"
7411 (error "Can't encrypt the article in group %s"
7412 gnus-newsgroup-name))
7413 (gnus-summary-iterate n
7415 (set-buffer gnus-summary-buffer)
7416 (let ((mail-parse-charset gnus-newsgroup-charset)
7417 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7418 (summary-buffer gnus-summary-buffer)
7420 (gnus-set-global-variables)
7421 (when (gnus-group-read-only-p)
7422 (error "The current newsgroup does not support article encrypt"))
7423 (gnus-summary-show-article t)
7425 (or (mail-header-references gnus-current-headers) ""))
7426 (set-buffer gnus-article-buffer)
7427 (let* ((buffer-read-only nil)
7429 (mapcar (lambda (field)
7430 (and (save-restriction
7431 (message-narrow-to-head)
7432 (goto-char (point-min))
7433 (search-forward field nil t))
7435 (message-narrow-to-field)
7437 (delete-region (point-min) (point-max))
7439 '("Content-Type:" "Content-Transfer-Encoding:"
7440 "Content-Disposition:"))))
7441 (message-narrow-to-head)
7442 (message-remove-header "MIME-Version")
7443 (goto-char (point-max))
7444 (setq point (point))
7445 (insert (apply 'concat headers))
7447 (narrow-to-region point (point-max))
7448 (let ((message-options message-options))
7449 (message-options-set 'message-sender user-mail-address)
7450 (message-options-set 'message-recipients user-mail-address)
7451 (message-options-set 'message-sign-encrypt 'not)
7453 (goto-char (point-min))
7454 (insert "MIME-Version: 1.0\n")
7456 (gnus-summary-edit-article-done
7457 references nil summary-buffer t))
7458 (when gnus-keep-backlog
7459 (gnus-backlog-remove-article
7460 (car gnus-article-current) (cdr gnus-article-current)))
7462 (when (get-buffer gnus-original-article-buffer)
7463 (set-buffer gnus-original-article-buffer)
7464 (setq gnus-original-article nil)))
7465 (when gnus-use-cache
7466 (gnus-cache-update-article
7467 (car gnus-article-current) (cdr gnus-article-current))))))))
7469 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7470 "The following specs can be used:
7471 %t The security MIME type
7474 %D Details if button is pressed")
7476 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
7477 "The following specs can be used:
7478 %t The security MIME type
7481 %D Details if button is pressed")
7483 (defvar gnus-mime-security-button-line-format-alist
7484 '((?t gnus-tmp-type ?s)
7485 (?i gnus-tmp-info ?s)
7486 (?d gnus-tmp-details ?s)
7487 (?D gnus-tmp-pressed-details ?s)))
7489 (defvar gnus-mime-security-button-map
7490 (let ((map (make-sparse-keymap)))
7491 (define-key map gnus-mouse-2 'gnus-article-push-button)
7492 (define-key map "\r" 'gnus-article-press-button)
7495 (defvar gnus-mime-security-details-buffer nil)
7497 (defvar gnus-mime-security-button-pressed nil)
7499 (defvar gnus-mime-security-show-details-inline t
7500 "If non-nil, show details in the article buffer.")
7502 (defun gnus-mime-security-verify-or-decrypt (handle)
7503 (mm-remove-parts (cdr handle))
7504 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7505 point buffer-read-only)
7507 (goto-char (car region)))
7509 (narrow-to-region (point) (point))
7510 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7511 (let* ((mm-verify-option 'known)
7512 (mm-decrypt-option 'known)
7513 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7514 (unless (eq nparts (cdr handle))
7515 (mm-destroy-parts (cdr handle))
7516 (setcdr handle nparts))))
7517 (setq point (point))
7518 (gnus-mime-display-security handle)
7519 (goto-char (point-max)))
7521 (delete-region (point) (cdr region))
7522 (set-marker (car region) nil)
7523 (set-marker (cdr region) nil))
7526 (defun gnus-mime-security-show-details (handle)
7527 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7529 (gnus-message 5 "No details.")
7530 (if gnus-mime-security-show-details-inline
7531 (let ((gnus-mime-security-button-pressed
7532 (not (get-text-property (point) 'gnus-mime-details)))
7533 (gnus-mime-security-button-line-format
7534 (get-text-property (point) 'gnus-line-format))
7537 (while (eq (get-text-property (point) 'gnus-line-format)
7538 gnus-mime-security-button-line-format)
7542 (narrow-to-region (point) (point))
7543 (gnus-insert-mime-security-button handle))
7544 (delete-region (point)
7545 (or (text-property-not-all
7548 gnus-mime-security-button-line-format)
7551 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7552 (with-current-buffer gnus-mime-security-details-buffer
7555 (setq gnus-mime-security-details-buffer
7556 (gnus-get-buffer-create "*MIME Security Details*")))
7557 (with-current-buffer gnus-mime-security-details-buffer
7559 (goto-char (point-min)))
7560 (pop-to-buffer gnus-mime-security-details-buffer)))))
7562 (defun gnus-mime-security-press-button (handle)
7564 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7565 (gnus-mime-security-show-details handle)
7566 (gnus-mime-security-verify-or-decrypt handle))))
7568 (defun gnus-insert-mime-security-button (handle &optional displayed)
7569 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7572 (or (nth 2 (assoc protocol mm-verify-function-alist))
7573 (nth 2 (assoc protocol mm-decrypt-function-alist))
7575 (if (equal (car handle) "multipart/signed")
7576 " Signed" " Encrypted")
7579 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7582 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7583 gnus-tmp-pressed-details
7585 (setq gnus-tmp-details
7586 (if gnus-tmp-details
7587 (concat "\n" gnus-tmp-details)
7589 (setq gnus-tmp-pressed-details
7590 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7595 gnus-mime-security-button-line-format
7596 gnus-mime-security-button-line-format-alist
7597 `(keymap ,gnus-mime-security-button-map
7598 gnus-callback gnus-mime-security-press-button
7599 gnus-line-format ,gnus-mime-security-button-line-format
7600 gnus-mime-details ,gnus-mime-security-button-pressed
7601 article-type annotation
7604 ;; Exclude a newline.
7607 (widget-convert-button
7610 :action 'gnus-widget-press-button
7611 :button-keymap gnus-mime-security-button-map
7613 (lambda (widget/window &optional overlay pos)
7614 ;; Needed to properly clear the message due to a bug in
7615 ;; wid-edit (XEmacs only).
7616 (when (boundp 'help-echo-owns-message)
7617 (setq help-echo-owns-message t))
7620 (aref gnus-mouse-2 0))))))
7622 (defun gnus-mime-display-security (handle)
7624 (narrow-to-region (point) (point))
7625 (unless (gnus-unbuttonized-mime-type-p (car handle))
7626 (gnus-insert-mime-security-button handle))
7627 (gnus-mime-display-mixed (cdr handle))
7630 (unless (gnus-unbuttonized-mime-type-p (car handle))
7631 (let ((gnus-mime-security-button-line-format
7632 gnus-mime-security-button-end-line-format))
7633 (gnus-insert-mime-security-button handle)))
7634 (mm-set-handle-multipart-parameter
7636 (cons (set-marker (make-marker) (point-min))
7637 (set-marker (make-marker) (point-max))))))
7643 (defun gnus-article-header-presentation-method (entity situation)
7644 (mime-insert-header entity)
7645 (article-decode-group-name))
7647 (set-alist 'mime-header-presentation-method-alist
7648 'gnus-original-article-mode
7649 #'gnus-article-header-presentation-method)
7651 (defun gnus-mime-preview-quitting-method ()
7652 (mime-preview-kill-buffer)
7653 (delete-other-windows)
7654 (gnus-article-show-summary)
7655 (gnus-summary-select-article gnus-show-all-headers t))
7657 (set-alist 'mime-preview-quitting-method-alist
7658 'gnus-original-article-mode #'gnus-mime-preview-quitting-method)
7660 (set-alist 'mime-preview-following-method-alist
7661 'gnus-original-article-mode #'gnus-following-method)
7663 (set-alist 'mime-preview-over-to-previous-method-alist
7664 'gnus-original-article-mode
7666 (if (> (point-min) 1)
7667 (gnus-article-prev-page)
7668 (gnus-article-read-summary-keys
7669 nil (gnus-character-to-event ?P)))))
7671 (set-alist 'mime-preview-over-to-next-method-alist
7672 'gnus-original-article-mode'
7674 (if (< (point-max) (buffer-size))
7675 (gnus-article-next-page)
7676 (gnus-article-read-summary-keys
7677 nil (gnus-character-to-event ?N)))))
7687 (run-hooks 'gnus-art-load-hook)
7689 ;;; gnus-art.el ends here