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
955 (>= (string-to-number emacs-version) 21))
958 Valid values are nil, t, `head', `last', an integer or a predicate.
959 See Info node `(gnus)Customizing Articles' for details."
960 :group 'gnus-article-treat
961 :link '(custom-manual "(gnus)Customizing Articles")
962 :type gnus-article-treat-custom)
963 (put 'gnus-treat-emphasize 'highlight t)
965 (defcustom gnus-treat-strip-cr nil
966 "Remove carriage returns.
967 Valid values are nil, t, `head', `last', an integer or a predicate.
968 See Info node `(gnus)Customizing Articles' for details."
969 :group 'gnus-article-treat
970 :link '(custom-manual "(gnus)Customizing Articles")
971 :type gnus-article-treat-custom)
973 (defcustom gnus-treat-unsplit-urls nil
974 "Remove newlines from within URLs.
975 Valid values are nil, t, `head', `last', an integer or a predicate.
976 See Info node `(gnus)Customizing Articles' for details."
977 :group 'gnus-article-treat
978 :link '(custom-manual "(gnus)Customizing Articles")
979 :type gnus-article-treat-custom)
981 (defcustom gnus-treat-leading-whitespace nil
982 "Remove leading whitespace in headers.
983 Valid values are nil, t, `head', `last', an integer or a predicate.
984 See Info node `(gnus)Customizing Articles' for details."
985 :group 'gnus-article-treat
986 :link '(custom-manual "(gnus)Customizing Articles")
987 :type gnus-article-treat-custom)
989 (defcustom gnus-treat-hide-headers 'head
991 Valid values are nil, t, `head', `last', an integer or a predicate.
992 See Info node `(gnus)Customizing Articles' for details."
993 :group 'gnus-article-treat
994 :link '(custom-manual "(gnus)Customizing Articles")
995 :type gnus-article-treat-head-custom)
997 (defcustom gnus-treat-hide-boring-headers nil
998 "Hide boring headers.
999 Valid values are nil, t, `head', `last', an integer or a predicate.
1000 See Info node `(gnus)Customizing Articles' for details."
1001 :group 'gnus-article-treat
1002 :link '(custom-manual "(gnus)Customizing Articles")
1003 :type gnus-article-treat-head-custom)
1005 (defcustom gnus-treat-hide-signature nil
1006 "Hide the signature.
1007 Valid values are nil, t, `head', `last', an integer or a predicate.
1008 See Info node `(gnus)Customizing Articles' for details."
1009 :group 'gnus-article-treat
1010 :link '(custom-manual "(gnus)Customizing Articles")
1011 :type gnus-article-treat-custom)
1013 (defcustom gnus-treat-fill-article nil
1015 Valid values are nil, t, `head', `last', an integer or a predicate.
1016 See Info node `(gnus)Customizing Articles' for details."
1017 :group 'gnus-article-treat
1018 :link '(custom-manual "(gnus)Customizing Articles")
1019 :type gnus-article-treat-custom)
1021 (defcustom gnus-treat-hide-citation nil
1023 Valid values are nil, t, `head', `last', an integer or a predicate.
1024 See Info node `(gnus)Customizing Articles' for details."
1025 :group 'gnus-article-treat
1026 :link '(custom-manual "(gnus)Customizing Articles")
1027 :type gnus-article-treat-custom)
1029 (defcustom gnus-treat-hide-citation-maybe nil
1031 Valid values are nil, t, `head', `last', an integer or a predicate.
1032 See Info node `(gnus)Customizing Articles' for details."
1033 :group 'gnus-article-treat
1034 :link '(custom-manual "(gnus)Customizing Articles")
1035 :type gnus-article-treat-custom)
1037 (defcustom gnus-treat-strip-list-identifiers 'head
1038 "Strip list identifiers from `gnus-list-identifiers`.
1039 Valid values are nil, t, `head', `last', an integer or a predicate.
1040 See Info node `(gnus)Customizing Articles' for details."
1042 :group 'gnus-article-treat
1043 :link '(custom-manual "(gnus)Customizing Articles")
1044 :type gnus-article-treat-custom)
1046 (make-obsolete-variable 'gnus-treat-strip-pgp
1047 "This option is obsolete in Gnus 5.10.")
1049 (defcustom gnus-treat-strip-pem nil
1050 "Strip PEM signatures.
1051 Valid values are nil, t, `head', `last', an integer or a predicate.
1052 See Info node `(gnus)Customizing Articles' for details."
1053 :group 'gnus-article-treat
1054 :link '(custom-manual "(gnus)Customizing Articles")
1055 :type gnus-article-treat-custom)
1057 (defcustom gnus-treat-strip-banner t
1058 "Strip banners from articles.
1059 The banner to be stripped is specified in the `banner' group parameter.
1060 Valid values are nil, t, `head', `last', an integer or a predicate.
1061 See Info node `(gnus)Customizing Articles' for details."
1062 :group 'gnus-article-treat
1063 :link '(custom-manual "(gnus)Customizing Articles")
1064 :type gnus-article-treat-custom)
1066 (defcustom gnus-treat-highlight-headers 'head
1067 "Highlight the headers.
1068 Valid values are nil, t, `head', `last', an integer or a predicate.
1069 See Info node `(gnus)Customizing Articles' for details."
1070 :group 'gnus-article-treat
1071 :link '(custom-manual "(gnus)Customizing Articles")
1072 :type gnus-article-treat-head-custom)
1073 (put 'gnus-treat-highlight-headers 'highlight t)
1075 (defcustom gnus-treat-highlight-citation t
1076 "Highlight cited text.
1077 Valid values are nil, t, `head', `last', an integer or a predicate.
1078 See Info node `(gnus)Customizing Articles' for details."
1079 :group 'gnus-article-treat
1080 :link '(custom-manual "(gnus)Customizing Articles")
1081 :type gnus-article-treat-custom)
1082 (put 'gnus-treat-highlight-citation 'highlight t)
1084 (defcustom gnus-treat-date-ut nil
1085 "Display the Date in UT (GMT).
1086 Valid values are nil, t, `head', `last', an integer or a predicate.
1087 See Info node `(gnus)Customizing Articles' for details."
1088 :group 'gnus-article-treat
1089 :link '(custom-manual "(gnus)Customizing Articles")
1090 :type gnus-article-treat-head-custom)
1092 (defcustom gnus-treat-date-local nil
1093 "Display the Date in the local timezone.
1094 Valid values are nil, t, `head', `last', an integer or a predicate.
1095 See Info node `(gnus)Customizing Articles' for details."
1096 :group 'gnus-article-treat
1097 :link '(custom-manual "(gnus)Customizing Articles")
1098 :type gnus-article-treat-head-custom)
1100 (defcustom gnus-treat-date-english nil
1101 "Display the Date in a format that can be read aloud in English.
1102 Valid values are nil, t, `head', `last', an integer or a predicate.
1103 See Info node `(gnus)Customizing Articles' for details."
1104 :group 'gnus-article-treat
1105 :link '(custom-manual "(gnus)Customizing Articles")
1106 :type gnus-article-treat-head-custom)
1108 (defcustom gnus-treat-date-lapsed nil
1109 "Display the Date header in a way that says how much time has elapsed.
1110 Valid values are nil, t, `head', `last', an integer or a predicate.
1111 See Info node `(gnus)Customizing Articles' for details."
1112 :group 'gnus-article-treat
1113 :link '(custom-manual "(gnus)Customizing Articles")
1114 :type gnus-article-treat-head-custom)
1116 (defcustom gnus-treat-date-original nil
1117 "Display the date in the original timezone.
1118 Valid values are nil, t, `head', `last', an integer or a predicate.
1119 See Info node `(gnus)Customizing Articles' for details."
1120 :group 'gnus-article-treat
1121 :link '(custom-manual "(gnus)Customizing Articles")
1122 :type gnus-article-treat-head-custom)
1124 (defcustom gnus-treat-date-iso8601 nil
1125 "Display the date in the ISO8601 format.
1126 Valid values are nil, t, `head', `last', an integer or a predicate.
1127 See Info node `(gnus)Customizing Articles' for details."
1129 :group 'gnus-article-treat
1130 :link '(custom-manual "(gnus)Customizing Articles")
1131 :type gnus-article-treat-head-custom)
1133 (defcustom gnus-treat-date-user-defined nil
1134 "Display the date in a user-defined format.
1135 The format is defined by the `gnus-article-time-format' variable.
1136 Valid values are nil, t, `head', `last', an integer or a predicate.
1137 See Info node `(gnus)Customizing Articles' for details."
1138 :group 'gnus-article-treat
1139 :link '(custom-manual "(gnus)Customizing Articles")
1140 :type gnus-article-treat-head-custom)
1142 (defcustom gnus-treat-strip-headers-in-body t
1143 "Strip the X-No-Archive header line from the beginning of the body.
1144 Valid values are nil, t, `head', `last', an integer or a predicate.
1145 See Info node `(gnus)Customizing Articles' for details."
1147 :group 'gnus-article-treat
1148 :link '(custom-manual "(gnus)Customizing Articles")
1149 :type gnus-article-treat-custom)
1151 (defcustom gnus-treat-strip-trailing-blank-lines nil
1152 "Strip trailing blank lines.
1153 Valid values are nil, t, `head', `last', an integer or a predicate.
1154 See Info node `(gnus)Customizing Articles' for details."
1155 :group 'gnus-article-treat
1156 :link '(custom-manual "(gnus)Customizing Articles")
1157 :type gnus-article-treat-custom)
1159 (defcustom gnus-treat-strip-leading-blank-lines nil
1160 "Strip leading blank lines.
1161 Valid values are nil, t, `head', `last', an integer or a predicate.
1162 See Info node `(gnus)Customizing Articles' for details."
1163 :group 'gnus-article-treat
1164 :link '(custom-manual "(gnus)Customizing Articles")
1165 :type gnus-article-treat-custom)
1167 (defcustom gnus-treat-strip-multiple-blank-lines nil
1168 "Strip multiple blank lines.
1169 Valid values are nil, t, `head', `last', an integer or a predicate.
1170 See Info node `(gnus)Customizing Articles' for details."
1171 :group 'gnus-article-treat
1172 :link '(custom-manual "(gnus)Customizing Articles")
1173 :type gnus-article-treat-custom)
1175 (defcustom gnus-treat-unfold-headers 'head
1176 "Unfold folded header lines.
1177 Valid values are nil, t, `head', `last', an integer or a predicate.
1178 See Info node `(gnus)Customizing Articles' for details."
1179 :group 'gnus-article-treat
1180 :link '(custom-manual "(gnus)Customizing Articles")
1181 :type gnus-article-treat-custom)
1183 (defcustom gnus-treat-fold-headers nil
1185 Valid values are nil, t, `head', `last', an integer or a predicate.
1186 See Info node `(gnus)Customizing Articles' for details."
1187 :group 'gnus-article-treat
1188 :link '(custom-manual "(gnus)Customizing Articles")
1189 :type gnus-article-treat-custom)
1191 (defcustom gnus-treat-fold-newsgroups 'head
1192 "Fold the Newsgroups and Followup-To headers.
1193 Valid values are nil, t, `head', `last', an integer or a predicate.
1194 See Info node `(gnus)Customizing Articles' for details."
1195 :group 'gnus-article-treat
1196 :link '(custom-manual "(gnus)Customizing Articles")
1197 :type gnus-article-treat-custom)
1199 (defcustom gnus-treat-overstrike t
1200 "Treat overstrike highlighting.
1201 Valid values are nil, t, `head', `last', an integer or a predicate.
1202 See Info node `(gnus)Customizing Articles' for details."
1203 :group 'gnus-article-treat
1204 :link '(custom-manual "(gnus)Customizing Articles")
1205 :type gnus-article-treat-custom)
1206 (put 'gnus-treat-overstrike 'highlight t)
1208 (defcustom gnus-treat-ansi-sequences t
1209 "Treat ANSI SGR control sequences.
1210 Valid values are nil, t, `head', `last', an integer or a predicate.
1211 See Info node `(gnus)Customizing Articles' for details."
1212 :group 'gnus-article-treat
1213 :link '(custom-manual "(gnus)Customizing Articles")
1214 :type gnus-article-treat-custom)
1216 (make-obsolete-variable 'gnus-treat-display-xface
1217 'gnus-treat-display-x-face)
1219 (defcustom gnus-treat-display-x-face
1220 (and (not noninteractive)
1221 (or (memq gnus-article-x-face-command
1222 '(x-face-decode-message-header
1223 x-face-mule-gnus-article-display-x-face))
1224 (and (fboundp 'image-type-available-p)
1225 (image-type-available-p 'xbm)
1226 (string-match "^0x" (shell-command-to-string "uncompface"))
1227 (executable-find "icontopbm"))
1228 (and (featurep 'xemacs)
1231 "Display X-Face headers.
1232 Valid values are nil, t, `head', `last', an integer or a predicate.
1233 See Info node `(gnus)Customizing Articles' and Info node
1234 `(gnus)X-Face' for details."
1235 :group 'gnus-article-treat
1237 :link '(custom-manual "(gnus)Customizing Articles")
1238 :link '(custom-manual "(gnus)X-Face")
1239 :type gnus-article-treat-head-custom
1240 :set (lambda (symbol value)
1243 (cond ((or (boundp symbol) (get symbol 'saved-value))
1245 ((boundp 'gnus-treat-display-xface)
1247 ** gnus-treat-display-xface is an obsolete variable;\
1248 use gnus-treat-display-x-face instead")
1249 (default-value 'gnus-treat-display-xface))
1250 ((get 'gnus-treat-display-xface 'saved-value)
1252 ** gnus-treat-display-xface is an obsolete variable;\
1253 use gnus-treat-display-x-face instead")
1254 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1257 (put 'gnus-treat-display-x-face 'highlight t)
1259 (defcustom gnus-article-should-use-smiley-mule
1260 (not (or (featurep 'xemacs)
1261 (gnus-image-type-available-p 'xpm)
1262 (gnus-image-type-available-p 'pbm)))
1263 "If non-nil, gnus uses `smiley-mule' for displaying smileys rather than
1264 `smiley'. It defaults to t when Emacs 20 or earlier is running.
1265 `smiley-mule' is boundled in BITMAP-MULE package. You can set it to t
1266 even if you are using Emacs 21+. It has no effect on XEmacs."
1267 :group 'gnus-article-various
1269 :get (lambda (symbol)
1270 (and (not noninteractive)
1271 (default-value symbol)
1272 (not (featurep 'xemacs))
1273 (module-installed-p 'smiley-mule)
1275 :set (lambda (symbol value)
1276 (set-default symbol (and (not noninteractive)
1278 (not (featurep 'xemacs))
1279 (module-installed-p 'smiley-mule)
1282 (defvar gnus-article-smiley-mule-loaded-p nil
1283 "Internal variable used to say whether `smiley-mule' is loaded (whether
1284 smiley functions are not overridden by `smiley').")
1286 (defcustom gnus-treat-display-face
1287 (and (not noninteractive)
1288 ;; x-face-e21 handles both X-Face and Face headers.
1289 (not (and (eq gnus-article-x-face-command 'x-face-decode-message-header)
1290 (module-installed-p 'x-face-e21)))
1291 (or (and (fboundp 'image-type-available-p)
1292 (image-type-available-p 'png))
1293 (and (featurep 'xemacs)
1296 "Display Face headers.
1297 Valid values are nil, t, `head', `last', an integer or a predicate.
1298 See Info node `(gnus)Customizing Articles' and Info node
1299 `(gnus)X-Face' for details."
1300 :group 'gnus-article-treat
1302 :link '(custom-manual "(gnus)Customizing Articles")
1303 :link '(custom-manual "(gnus)X-Face")
1304 :type gnus-article-treat-head-custom)
1305 (put 'gnus-treat-display-face 'highlight t)
1307 (defcustom gnus-treat-display-smileys
1308 (if (and (not noninteractive)
1309 (or (and (featurep 'xemacs)
1311 (gnus-image-type-available-p 'xpm)
1312 (gnus-image-type-available-p 'pbm)
1313 (and (not (featurep 'xemacs))
1315 (module-installed-p 'smiley-mule))))
1319 Valid values are nil, t, `head', `last', an integer or a predicate.
1320 See Info node `(gnus)Customizing Articles' and Info node
1321 `(gnus)Smileys' for details."
1322 :group 'gnus-article-treat
1324 :link '(custom-manual "(gnus)Customizing Articles")
1325 :link '(custom-manual "(gnus)Smileys")
1326 :type gnus-article-treat-custom)
1327 (put 'gnus-treat-display-smileys 'highlight t)
1329 (defcustom gnus-treat-from-picon
1330 (if (and (gnus-image-type-available-p 'xpm)
1331 (gnus-picons-installed-p))
1333 "Display picons in the From header.
1334 Valid values are nil, t, `head', `last', an integer or a predicate.
1335 See Info node `(gnus)Customizing Articles' and Info node
1336 `(gnus)Picons' for details."
1337 :group 'gnus-article-treat
1339 :link '(custom-manual "(gnus)Customizing Articles")
1340 :link '(custom-manual "(gnus)Picons")
1341 :type gnus-article-treat-head-custom)
1342 (put 'gnus-treat-from-picon 'highlight t)
1344 (defcustom gnus-treat-mail-picon
1345 (if (and (gnus-image-type-available-p 'xpm)
1346 (gnus-picons-installed-p))
1348 "Display picons in To and Cc headers.
1349 Valid values are nil, t, `head', `last', an integer or a predicate.
1350 See Info node `(gnus)Customizing Articles' and Info node
1351 `(gnus)Picons' for details."
1352 :group 'gnus-article-treat
1354 :link '(custom-manual "(gnus)Customizing Articles")
1355 :link '(custom-manual "(gnus)Picons")
1356 :type gnus-article-treat-head-custom)
1357 (put 'gnus-treat-mail-picon 'highlight t)
1359 (defcustom gnus-treat-newsgroups-picon
1360 (if (and (gnus-image-type-available-p 'xpm)
1361 (gnus-picons-installed-p))
1363 "Display picons in the Newsgroups and Followup-To headers.
1364 Valid values are nil, t, `head', `last', an integer or a predicate.
1365 See Info node `(gnus)Customizing Articles' and Info node
1366 `(gnus)Picons' for details."
1367 :group 'gnus-article-treat
1369 :link '(custom-manual "(gnus)Customizing Articles")
1370 :link '(custom-manual "(gnus)Picons")
1371 :type gnus-article-treat-head-custom)
1372 (put 'gnus-treat-newsgroups-picon 'highlight t)
1374 (defcustom gnus-treat-body-boundary
1375 (if (or gnus-treat-newsgroups-picon
1376 gnus-treat-mail-picon
1377 gnus-treat-from-picon)
1379 "Draw a boundary at the end of the headers.
1380 Valid values are nil and `head'.
1381 See Info node `(gnus)Customizing Articles' for details."
1383 :group 'gnus-article-treat
1384 :link '(custom-manual "(gnus)Customizing Articles")
1385 :type gnus-article-treat-head-custom)
1387 (defcustom gnus-treat-capitalize-sentences nil
1388 "Capitalize sentence-starting words.
1389 Valid values are nil, t, `head', `last', an integer or a predicate.
1390 See Info node `(gnus)Customizing Articles' for details."
1392 :group 'gnus-article-treat
1393 :link '(custom-manual "(gnus)Customizing Articles")
1394 :type gnus-article-treat-custom)
1396 (defcustom gnus-treat-wash-html nil
1398 Valid values are nil, t, `head', `last', an integer or a predicate.
1399 See Info node `(gnus)Customizing Articles' for details."
1400 :group 'gnus-article-treat
1401 :link '(custom-manual "(gnus)Customizing Articles")
1402 :type gnus-article-treat-custom)
1404 (defcustom gnus-treat-fill-long-lines nil
1406 Valid values are nil, t, `head', `last', an integer or a predicate.
1407 See Info node `(gnus)Customizing Articles' for details."
1408 :group 'gnus-article-treat
1409 :link '(custom-manual "(gnus)Customizing Articles")
1410 :type gnus-article-treat-custom)
1412 (defcustom gnus-treat-play-sounds nil
1414 Valid values are nil, t, `head', `last', an integer or a predicate.
1415 See Info node `(gnus)Customizing Articles' for details."
1417 :group 'gnus-article-treat
1418 :link '(custom-manual "(gnus)Customizing Articles")
1419 :type gnus-article-treat-custom)
1421 (defcustom gnus-treat-decode-article-as-default-mime-charset nil
1422 "Decode an article as `default-mime-charset'. For instance, if you want to
1423 attempt to decode an article even if the value of `gnus-show-mime' is nil,
1424 you could set this variable to something like: nil for don't decode, t for
1425 decode the body, '(or header t) for the whole article, etc."
1426 :group 'gnus-article-treat
1427 :type '(radio (const :tag "Off" nil)
1428 (const :tag "Decode body" t)
1429 (const :tag "Decode all" (or head t))))
1431 (defcustom gnus-treat-translate nil
1432 "Translate articles from one language to another.
1433 Valid values are nil, t, `head', `last', an integer or a predicate.
1434 See Info node `(gnus)Customizing Articles' for details."
1436 :group 'gnus-article-treat
1437 :link '(custom-manual "(gnus)Customizing Articles")
1438 :type gnus-article-treat-custom)
1440 (defcustom gnus-treat-x-pgp-sig nil
1442 To automatically treat X-PGP-Sig, set it to head.
1443 Valid values are nil, t, `head', `last', an integer or a predicate.
1444 See Info node `(gnus)Customizing Articles' for details."
1445 :group 'gnus-article-treat
1446 :group 'mime-security
1447 :type gnus-article-treat-custom)
1449 (defcustom gnus-treat-monafy nil
1450 "Display body part with mona font.
1451 Valid values are nil, t, `head', `last', an integer or a predicate.
1452 See Info node `(gnus)Customizing Articles' for details."
1453 :group 'gnus-article-treat
1454 :group 'mime-security
1455 :link '(custom-manual "(gnus)Customizing Articles")
1456 :type gnus-article-treat-custom)
1458 (defvar gnus-article-encrypt-protocol-alist
1459 '(("PGP" . mml2015-self-encrypt)))
1461 ;; Set to nil if more than one protocol added to
1462 ;; gnus-article-encrypt-protocol-alist.
1463 (defcustom gnus-article-encrypt-protocol "PGP"
1464 "The protocol used for encrypt articles.
1465 It is a string, such as \"PGP\". If nil, ask user."
1467 :group 'mime-security)
1469 (defvar gnus-article-wash-function nil
1470 "Function used for converting HTML into text.")
1472 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1473 (mm-coding-system-p 'utf-8)
1474 (executable-find idna-program))
1475 "Whether IDNA decoding of headers is used when viewing messages.
1476 This requires GNU Libidn, and by default only enabled if it is found."
1477 :group 'gnus-article-headers
1480 (defcustom gnus-article-over-scroll nil
1481 "If non-nil, allow scrolling the article buffer even when there no more text."
1482 :group 'gnus-article
1485 ;;; Internal variables
1487 (defvar gnus-english-month-names
1488 '("January" "February" "March" "April" "May" "June" "July" "August"
1489 "September" "October" "November" "December"))
1491 (defvar article-goto-body-goes-to-point-min-p nil)
1492 (defvar gnus-article-wash-types nil)
1493 (defvar gnus-article-emphasis-alist nil)
1494 (defvar gnus-article-image-alist nil)
1496 (defvar gnus-article-mime-handle-alist-1 nil)
1497 (defvar gnus-treatment-function-alist
1498 '((gnus-treat-decode-article-as-default-mime-charset
1499 gnus-article-decode-article-as-default-mime-charset)
1500 (gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1501 (gnus-treat-monafy gnus-article-monafy)
1502 (gnus-treat-strip-banner gnus-article-strip-banner)
1503 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1504 (gnus-treat-buttonize gnus-article-add-buttons)
1505 (gnus-treat-fill-article gnus-article-fill-cited-article)
1506 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1507 (gnus-treat-strip-cr gnus-article-remove-cr)
1508 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1509 (gnus-treat-date-ut gnus-article-date-ut)
1510 (gnus-treat-date-local gnus-article-date-local)
1511 (gnus-treat-date-english gnus-article-date-english)
1512 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1513 (gnus-treat-date-original gnus-article-date-original)
1514 (gnus-treat-date-user-defined gnus-article-date-user)
1515 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1516 (gnus-treat-display-face gnus-article-display-face)
1517 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1518 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1519 (gnus-treat-hide-signature gnus-article-hide-signature)
1520 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1521 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1522 (gnus-treat-strip-pem gnus-article-hide-pem)
1523 (gnus-treat-from-picon gnus-treat-from-picon)
1524 (gnus-treat-mail-picon gnus-treat-mail-picon)
1525 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1526 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1527 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1528 (gnus-treat-strip-trailing-blank-lines
1529 gnus-article-remove-trailing-blank-lines)
1530 (gnus-treat-strip-leading-blank-lines
1531 gnus-article-strip-leading-blank-lines)
1532 (gnus-treat-strip-multiple-blank-lines
1533 gnus-article-strip-multiple-blank-lines)
1534 (gnus-treat-overstrike gnus-article-treat-overstrike)
1535 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences)
1536 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1537 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1538 ;; Displaying X-Face should be done after unfolding headers
1539 ;; to protect bitmap lines.
1540 (gnus-treat-display-x-face gnus-article-display-x-face)
1541 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1542 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1543 (gnus-treat-display-smileys gnus-treat-smiley)
1544 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1545 (gnus-treat-wash-html gnus-article-wash-html)
1546 (gnus-treat-emphasize gnus-article-emphasize)
1547 (gnus-treat-hide-citation gnus-article-hide-citation)
1548 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1549 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1550 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1551 (gnus-treat-play-sounds gnus-earcon-display)))
1553 (defvar gnus-article-mime-handle-alist nil)
1554 (defvar article-lapsed-timer nil)
1555 (defvar gnus-article-current-summary nil)
1557 (defvar gnus-article-mode-syntax-table
1558 (let ((table (copy-syntax-table text-mode-syntax-table)))
1559 ;; This causes the citation match run O(2^n).
1560 ;; (modify-syntax-entry ?- "w" table)
1561 (modify-syntax-entry ?> ")<" table)
1562 (modify-syntax-entry ?< "(>" table)
1563 ;; make M-. in article buffers work for `foo' strings
1564 (modify-syntax-entry ?' " " table)
1565 (modify-syntax-entry ?` " " table)
1567 "Syntax table used in article mode buffers.
1568 Initialized from `text-mode-syntax-table.")
1570 (defvar gnus-save-article-buffer nil)
1572 (defvar gnus-article-mode-line-format-alist
1573 (nconc '((?w (gnus-article-wash-status) ?s)
1574 (?m (gnus-article-mime-part-status) ?s))
1575 gnus-summary-mode-line-format-alist))
1577 (defvar gnus-number-of-articles-to-be-saved nil)
1579 (defvar gnus-inhibit-hiding 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 (>= emacs-major-version 21)
2057 (not gnus-article-should-use-smiley-mule)
2058 gnus-article-smiley-mule-loaded-p)
2059 (load "smiley" nil t)
2060 (setq gnus-article-smiley-mule-loaded-p nil))
2061 (when (and gnus-article-should-use-smiley-mule
2062 (not gnus-article-smiley-mule-loaded-p))
2063 (load "smiley-mule" nil t)
2064 (setq gnus-article-smiley-mule-loaded-p t)))
2065 (gnus-with-article-buffer
2066 (if (memq 'smiley gnus-article-wash-types)
2067 (gnus-delete-images 'smiley)
2069 (let ((images (smiley-region (point) (point-max))))
2071 (gnus-add-wash-type 'smiley)
2072 (dolist (image images)
2073 (gnus-add-image 'smiley image)))))))
2075 (defun gnus-article-remove-images ()
2076 "Remove all images from the article buffer."
2078 (gnus-with-article-buffer
2079 (dolist (elem gnus-article-image-alist)
2080 (gnus-delete-images (car elem)))))
2082 (defun gnus-article-treat-fold-newsgroups ()
2083 "Unfold folded message headers.
2084 Only the headers that fit into the current window width will be
2087 (gnus-with-article-headers
2088 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2090 (mail-header-narrow-to-field)
2091 (while (re-search-forward ", *" nil t)
2092 (replace-match ", " t t))
2093 (mail-header-fold-field)
2094 (goto-char (point-max))))))
2096 (defun gnus-article-treat-body-boundary ()
2097 "Place a boundary line at the end of the headers."
2099 (when (and gnus-body-boundary-delimiter
2100 (> (length gnus-body-boundary-delimiter) 0))
2101 (gnus-with-article-headers
2102 (goto-char (point-max))
2103 (let ((start (point)))
2104 (insert "X-Boundary: ")
2105 (gnus-add-text-properties start (point) '(invisible t intangible t))
2107 (while (>= (1- (window-width)) (length str))
2108 (setq str (concat str gnus-body-boundary-delimiter)))
2109 (substring str 0 (1- (window-width))))
2111 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2113 (defun article-fill-long-lines ()
2114 "Fill lines that are wider than the window width."
2117 (let ((buffer-read-only nil)
2118 (width (window-width (get-buffer-window (current-buffer)))))
2121 (let ((adaptive-fill-mode nil)) ;Why? -sm
2124 (when (>= (current-column) (min fill-column width))
2125 (narrow-to-region (min (1+ (point)) (point-max))
2127 (let ((goback (point-marker)))
2128 (fill-paragraph nil)
2129 (goto-char (marker-position goback)))
2131 (forward-line 1)))))))
2133 (defun article-capitalize-sentences ()
2134 "Capitalize the first word in each sentence."
2137 (let ((buffer-read-only nil)
2138 (paragraph-start "^[\n\^L]"))
2142 (forward-sentence)))))
2144 (defun article-remove-cr ()
2145 "Remove trailing CRs and then translate remaining CRs into LFs."
2148 (let ((buffer-read-only nil))
2149 (goto-char (point-min))
2150 (while (re-search-forward "\r+$" nil t)
2151 (replace-match "" t t))
2152 (goto-char (point-min))
2153 (while (search-forward "\r" nil t)
2154 (replace-match "\n" t t)))))
2156 (defun article-remove-trailing-blank-lines ()
2157 "Remove all trailing blank lines from the article."
2160 (let ((buffer-read-only nil))
2161 (goto-char (point-max))
2165 (while (and (not (bobp))
2166 (looking-at "^[ \t]*$")
2167 (not (gnus-annotation-in-region-p
2168 (point) (point-at-eol))))
2173 (defun article-display-face ()
2174 "Display any Face headers in the header."
2176 (let ((wash-face-p buffer-read-only))
2177 (gnus-with-article-headers
2178 ;; When displaying parts, this function can be called several times on
2179 ;; the same article, without any intended toggle semantic (as typing `W
2180 ;; D d' would have). So face deletion must occur only when we come from
2181 ;; an interactive command, that is when the *Article* buffer is
2183 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2184 (gnus-delete-images 'face)
2187 (when (and wash-face-p
2189 (goto-char (point-min))
2190 (not (re-search-forward "^Face:[\t ]*" nil t)))
2191 (gnus-buffer-live-p gnus-original-article-buffer))
2192 (set-buffer gnus-original-article-buffer))
2194 (mail-narrow-to-head)
2195 (while (gnus-article-goto-header "Face")
2196 (push (mail-header-field-value) faces))))
2197 (while (setq face (pop faces))
2198 (let ((png (gnus-convert-face-to-png face))
2201 (setq image (gnus-create-image png 'png t))
2202 (gnus-article-goto-header "from")
2204 (insert "From: [no `from' set]\n")
2206 (gnus-add-wash-type 'face)
2207 (gnus-add-image 'face image)
2208 (gnus-put-image image nil 'face))))))
2211 (defun article-display-x-face (&optional force)
2212 "Look for an X-Face header and display it if present."
2213 (interactive (list 'force))
2214 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2215 (gnus-with-article-headers
2216 ;; Delete the old process, if any.
2217 (when (process-status "article-x-face")
2218 (delete-process "article-x-face"))
2219 ;; See the comment in `article-display-face'.
2220 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2221 ;; We have already displayed X-Faces, so we remove them
2223 (gnus-delete-images 'xface)
2225 (let (x-faces from face)
2227 (when (and wash-face-p
2229 (goto-char (point-min))
2230 (not (re-search-forward
2231 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2232 (gnus-buffer-live-p gnus-original-article-buffer))
2233 ;; If type `W f', use gnus-original-article-buffer,
2234 ;; otherwise use the current buffer because displaying
2235 ;; RFC822 parts calls this function too.
2236 (set-buffer gnus-original-article-buffer))
2238 (mail-narrow-to-head)
2239 (while (gnus-article-goto-header "X-Face")
2240 (push (mail-header-field-value) x-faces))
2241 (setq from (message-fetch-field "from"))))
2242 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2243 ;; single external face.
2244 (when (stringp gnus-article-x-face-command)
2245 (setq x-faces (list (car x-faces))))
2246 (while (and (setq face (pop x-faces))
2247 gnus-article-x-face-command
2249 ;; Check whether this face is censored.
2250 (not gnus-article-x-face-too-ugly)
2251 (and gnus-article-x-face-too-ugly from
2252 (not (string-match gnus-article-x-face-too-ugly
2254 ;; We display the face.
2255 (cond ((stringp gnus-article-x-face-command)
2256 ;; The command is a string, so we interpret the command
2257 ;; as a, well, command, and fork it off.
2258 (let ((process-connection-type nil))
2259 (process-kill-without-query
2261 "article-x-face" nil shell-file-name
2262 shell-command-switch gnus-article-x-face-command))
2265 (process-send-region "article-x-face"
2266 (point-min) (point-max)))
2267 (process-send-eof "article-x-face")))
2268 ((functionp gnus-article-x-face-command)
2269 ;; The command is a lisp function, so we call it.
2270 (funcall gnus-article-x-face-command face))
2272 (error "%s is not a function"
2273 gnus-article-x-face-command)))))))))
2275 (defun article-decode-mime-words ()
2276 "Decode all MIME-encoded words in the article."
2279 (set-buffer gnus-article-buffer)
2280 (let ((inhibit-point-motion-hooks t)
2282 (mail-parse-charset gnus-newsgroup-charset)
2283 (mail-parse-ignored-charsets
2284 (save-excursion (set-buffer gnus-summary-buffer)
2285 gnus-newsgroup-ignored-charsets)))
2286 (mail-decode-encoded-word-region (point-min) (point-max)))))
2288 (defun article-decode-charset (&optional prompt)
2289 "Decode charset-encoded text in the article.
2290 If PROMPT (the prefix), prompt for a coding system to use."
2292 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2294 (mail-parse-charset gnus-newsgroup-charset)
2295 (mail-parse-ignored-charsets
2296 (save-excursion (condition-case nil
2297 (set-buffer gnus-summary-buffer)
2299 gnus-newsgroup-ignored-charsets))
2300 ct cte ctl charset format)
2303 (article-narrow-to-head)
2304 (setq ct (message-fetch-field "Content-Type" t)
2305 cte (message-fetch-field "Content-Transfer-Encoding" t)
2306 ctl (and ct (ignore-errors
2307 (mail-header-parse-content-type ct)))
2310 (mm-read-coding-system "Charset to decode: "))
2312 (mail-content-type-get ctl 'charset)))
2313 format (and ctl (mail-content-type-get ctl 'format)))
2315 (setq cte (mail-header-strip cte)))
2316 (if (and ctl (not (string-match "/" (car ctl))))
2318 (goto-char (point-max)))
2321 (narrow-to-region (point) (point-max))
2322 (when (and (eq mail-parse-charset 'gnus-decoded)
2323 (eq (mm-body-7-or-8) '8bit))
2324 ;; The text code could have been decoded.
2325 (setq charset mail-parse-charset))
2326 (when (and (or (not ctl)
2327 (equal (car ctl) "text/plain"))
2328 (not format)) ;; article with format will decode later.
2330 charset (and cte (intern (downcase
2331 (gnus-strip-whitespace cte))))
2334 (defun article-decode-encoded-words ()
2335 "Remove encoded-word encoding from headers."
2336 (let (buffer-read-only)
2337 (let ((charset (save-excursion
2338 (set-buffer gnus-summary-buffer)
2339 default-mime-charset)))
2340 (mime-decode-header-in-buffer charset))))
2342 (defun article-decode-group-name ()
2343 "Decode group names in `Newsgroups:'."
2344 (let ((inhibit-point-motion-hooks t)
2346 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2347 (when (and (or gnus-group-name-charset-method-alist
2348 gnus-group-name-charset-group-alist)
2349 (gnus-buffer-live-p gnus-original-article-buffer))
2351 (article-narrow-to-head)
2352 (with-current-buffer gnus-original-article-buffer
2353 (goto-char (point-min)))
2354 (while (re-search-forward
2355 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2356 (replace-match (save-match-data
2357 (gnus-decode-newsgroups
2358 ;; XXX how to use data in article buffer?
2359 (with-current-buffer gnus-original-article-buffer
2361 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2364 gnus-newsgroup-name method))
2366 (goto-char (point-min))
2367 (with-current-buffer gnus-original-article-buffer
2368 (goto-char (point-min)))
2369 (while (re-search-forward
2370 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2371 (replace-match (save-match-data
2372 (gnus-decode-newsgroups
2373 ;; XXX how to use data in article buffer?
2374 (with-current-buffer gnus-original-article-buffer
2376 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2379 gnus-newsgroup-name method))
2382 (autoload 'idna-to-unicode "idna")
2384 (defun article-decode-idna-rhs ()
2385 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2388 (let ((inhibit-point-motion-hooks t)
2390 (article-narrow-to-head)
2391 (goto-char (point-min))
2392 (while (re-search-forward "\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2394 (when (save-match-data
2395 (and (setq ace (match-string 1))
2397 (and (re-search-backward "^[^ \t]" nil t)
2398 (looking-at "From\\|To\\|Cc")))
2399 (save-excursion (backward-char)
2400 (message-idna-inside-rhs-p))
2401 (setq unicode (idna-to-unicode ace))))
2402 (unless (string= ace unicode)
2403 (replace-match unicode nil nil nil 1)))))))))
2405 (defun article-de-quoted-unreadable (&optional force read-charset)
2406 "Translate a quoted-printable-encoded article.
2407 If FORCE, decode the article whether it is marked as quoted-printable
2409 If READ-CHARSET, ask for a coding system."
2410 (interactive (list 'force current-prefix-arg))
2412 (let ((buffer-read-only nil) type charset)
2413 (if (gnus-buffer-live-p gnus-original-article-buffer)
2414 (with-current-buffer gnus-original-article-buffer
2416 (gnus-fetch-field "content-transfer-encoding"))
2417 (let* ((ct (gnus-fetch-field "content-type"))
2420 (mail-header-parse-content-type ct)))))
2421 (setq charset (and ctl
2422 (mail-content-type-get ctl 'charset)))
2423 (if (stringp charset)
2424 (setq charset (intern (downcase charset)))))))
2426 (setq charset (mm-read-coding-system "Charset: " charset)))
2428 (setq charset gnus-newsgroup-charset))
2430 (and type (let ((case-fold-search t))
2431 (string-match "quoted-printable" type))))
2433 (quoted-printable-decode-region
2434 (point) (point-max) (mm-charset-to-coding-system charset))))))
2436 (defun article-de-base64-unreadable (&optional force read-charset)
2437 "Translate a base64 article.
2438 If FORCE, decode the article whether it is marked as base64 not.
2439 If READ-CHARSET, ask for a coding system."
2440 (interactive (list 'force current-prefix-arg))
2442 (let ((buffer-read-only nil) type charset)
2443 (if (gnus-buffer-live-p gnus-original-article-buffer)
2444 (with-current-buffer gnus-original-article-buffer
2446 (gnus-fetch-field "content-transfer-encoding"))
2447 (let* ((ct (gnus-fetch-field "content-type"))
2450 (mail-header-parse-content-type ct)))))
2451 (setq charset (and ctl
2452 (mail-content-type-get ctl 'charset)))
2453 (if (stringp charset)
2454 (setq charset (intern (downcase charset)))))))
2456 (setq charset (mm-read-coding-system "Charset: " charset)))
2458 (setq charset gnus-newsgroup-charset))
2460 (and type (let ((case-fold-search t))
2461 (string-match "base64" type))))
2464 (narrow-to-region (point) (point-max))
2465 (base64-decode-region (point-min) (point-max))
2466 (mm-decode-coding-region
2467 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2472 (defun article-decode-HZ ()
2473 "Translate a HZ-encoded article."
2477 (let ((buffer-read-only nil))
2478 (rfc1843-decode-region (point-min) (point-max)))))
2480 (defun article-unsplit-urls ()
2481 "Remove the newlines that some other mailers insert into URLs."
2484 (let ((buffer-read-only nil))
2485 (goto-char (point-min))
2486 (while (re-search-forward
2487 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2488 (replace-match "\\1\\3" t)))
2489 (when (interactive-p)
2490 (gnus-treat-article nil))))
2493 (defun article-wash-html (&optional read-charset)
2494 "Format an HTML article.
2495 If READ-CHARSET, ask for a coding system."
2498 (let ((buffer-read-only nil)
2500 (when (gnus-buffer-live-p gnus-original-article-buffer)
2501 (with-current-buffer gnus-original-article-buffer
2502 (let* ((ct (gnus-fetch-field "content-type"))
2505 (mail-header-parse-content-type ct)))))
2506 (setq charset (and ctl
2507 (mail-content-type-get ctl 'charset)))
2508 (when (stringp charset)
2509 (setq charset (intern (downcase charset)))))))
2511 (setq charset (mm-read-coding-system "Charset: " charset)))
2513 (setq charset gnus-newsgroup-charset))
2515 (save-window-excursion
2517 (narrow-to-region (point) (point-max))
2518 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2519 (entry (assq func mm-text-html-washer-alist)))
2521 (setq func (cdr entry)))
2526 (apply (car func) (cdr func))))))))))
2528 (defun gnus-article-wash-html-with-w3 ()
2529 "Wash the current buffer with w3."
2531 (let ((w3-strict-width (window-width))
2532 (url-standalone-mode t)
2533 (url-gateway-unplugged t)
2534 (w3-honor-stylesheets nil))
2536 (w3-region (point-min) (point-max))
2539 (defun gnus-article-wash-html-with-w3m ()
2540 "Wash the current buffer with emacs-w3m."
2543 (narrow-to-region (point) (point-max))
2544 (let ((w3m-safe-url-regexp (if mm-inline-text-html-with-images
2547 w3m-force-redisplay)
2548 (w3m-region (point-min) (point-max)))
2549 (when mm-inline-text-html-with-w3m-keymap
2550 (add-text-properties
2551 (point-min) (point-max)
2552 (nconc (mm-w3m-local-map-property)
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."
2656 (set-buffer gnus-article-buffer)
2657 (when (article-goto-body)
2658 (let* ((buffer-read-only nil)
2661 (orig (buffer-substring start end))
2662 (trans (babel-as-string orig)))
2664 (narrow-to-region start end)
2665 (delete-region start end)
2668 (defun article-hide-signature (&optional arg)
2669 "Hide the signature in the current article.
2670 If given a negative prefix, always show; if given a positive prefix,
2672 (interactive (gnus-article-hidden-arg))
2678 (article-goto-body))
2679 (goto-char (point-min)))
2680 (unless (gnus-article-check-hidden-text 'signature arg)
2681 (let ((buffer-read-only nil)
2683 (while (setq button (text-property-any button (point-max)
2685 'gnus-signature-toggle))
2686 (setq button (text-property-not-all button (point-max)
2688 'gnus-signature-toggle))
2689 (when (and button (not (eobp)))
2690 (gnus-article-hide-text-type
2692 (next-single-property-change (1+ button) 'mime-view-entity
2695 (gnus-set-mode-line 'article))
2697 (defun article-strip-headers-in-body ()
2698 "Strip offensive headers from bodies."
2702 (let ((case-fold-search t))
2703 (when (looking-at "x-no-archive:")
2704 (gnus-delete-line)))))
2706 (defun article-strip-leading-blank-lines ()
2707 "Remove all blank lines from the beginning of the article."
2710 (let ((inhibit-point-motion-hooks t)
2712 (when (article-goto-body)
2713 (while (and (not (eobp))
2714 (looking-at "[ \t]*$"))
2715 (gnus-delete-line))))))
2717 (defun article-narrow-to-head ()
2718 "Narrow the buffer to the head of the message.
2719 Point is left at the beginning of the narrowed-to region."
2721 (goto-char (point-min))
2722 (if (search-forward "\n\n" nil 1)
2725 (goto-char (point-min)))
2727 (defun article-goto-body ()
2728 "Place point at the start of the body."
2729 (goto-char (point-min))
2731 ;; This variable is only bound when dealing with separate
2733 (article-goto-body-goes-to-point-min-p
2735 ((search-forward "\n\n" nil t)
2738 (goto-char (point-max))
2741 (defun article-strip-multiple-blank-lines ()
2742 "Replace consecutive blank lines with one empty line."
2745 (let ((inhibit-point-motion-hooks t)
2747 ;; First make all blank lines empty.
2749 (while (re-search-forward "^[ \t]+$" nil t)
2750 (unless (gnus-annotation-in-region-p
2751 (match-beginning 0) (match-end 0))
2752 (replace-match "" nil t)))
2753 ;; Then replace multiple empty lines with a single empty line.
2755 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2756 (unless (gnus-annotation-in-region-p
2757 (match-beginning 0) (match-end 0))
2758 (delete-region (match-beginning 1) (match-end 1)))))))
2760 (defun article-strip-leading-space ()
2761 "Remove all white space from the beginning of the lines in the article."
2764 (let ((inhibit-point-motion-hooks t)
2767 (while (re-search-forward "^[ \t]+" nil t)
2768 (replace-match "" t t)))))
2770 (defun article-strip-trailing-space ()
2771 "Remove all white space from the end of the lines in the article."
2774 (let ((inhibit-point-motion-hooks t)
2777 (while (re-search-forward "[ \t]+$" nil t)
2778 (replace-match "" t t)))))
2780 (defun article-strip-blank-lines ()
2781 "Strip leading, trailing and multiple blank lines."
2783 (article-strip-leading-blank-lines)
2784 (article-remove-trailing-blank-lines)
2785 (article-strip-multiple-blank-lines))
2787 (defun article-strip-all-blank-lines ()
2788 "Strip all blank lines."
2791 (let ((inhibit-point-motion-hooks t)
2794 (while (re-search-forward "^[ \t]*\n" nil t)
2795 (replace-match "" t t)))))
2797 (defun gnus-article-narrow-to-signature ()
2798 "Narrow to the signature; return t if a signature is found, else nil."
2799 (let ((inhibit-point-motion-hooks t))
2800 (when (gnus-article-search-signature)
2802 ;; Check whether we have some limits to what we consider
2803 ;; to be a signature.
2804 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2805 (list gnus-signature-limit)))
2807 (while (setq limit (pop limits))
2808 (if (or (and (integerp limit)
2809 (< (- (point-max) (point)) limit))
2811 (< (count-lines (point) (point-max)) limit))
2812 (and (functionp limit)
2814 (and (stringp limit)
2815 (not (re-search-forward limit nil t))))
2816 () ; This limit did not succeed.
2820 (narrow-to-region (point) (point-max))
2823 (defun gnus-article-search-signature ()
2824 "Search the current buffer for the signature separator.
2825 Put point at the beginning of the signature separator."
2826 (let ((cur (point)))
2827 (goto-char (point-max))
2828 (if (if (stringp gnus-signature-separator)
2829 (re-search-backward gnus-signature-separator nil t)
2830 (let ((seps gnus-signature-separator))
2832 (not (re-search-backward (car seps) nil t)))
2839 (defun gnus-article-hidden-arg ()
2840 "Return the current prefix arg as a number, or 0 if no prefix."
2841 (list (if current-prefix-arg
2842 (prefix-numeric-value current-prefix-arg)
2845 (defun gnus-article-check-hidden-text (type arg)
2846 "Return nil if hiding is necessary.
2847 Arg can be nil or a number. nil and positive means hide, negative
2848 means show, 0 means toggle."
2851 (let ((hide (gnus-article-hidden-text-p type)))
2857 (gnus-article-show-hidden-text type)
2860 (if (eq hide 'hidden)
2862 (gnus-article-show-hidden-text type)
2866 (defun gnus-article-hidden-text-p (type)
2867 "Say whether the current buffer contains hidden text of type TYPE."
2868 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2870 (not (get-text-property pos 'invisible))
2871 (not (get-text-property pos 'dummy-invisible)))
2873 (text-property-any (1+ pos) (point-max) 'article-type type)))
2878 (defun gnus-article-show-hidden-text (type &optional dummy)
2879 "Show all hidden text of type TYPE.
2880 Originally it is hide instead of DUMMY."
2881 (let ((buffer-read-only nil)
2882 (inhibit-point-motion-hooks t))
2883 (gnus-remove-text-properties-when
2885 (point-min) (point-max)
2886 (cons 'article-type (cons type
2887 gnus-hidden-properties)))
2888 (gnus-delete-wash-type type)))
2890 (defconst article-time-units
2891 `((year . ,(* 365.25 24 60 60))
2892 (week . ,(* 7 24 60 60))
2893 (day . ,(* 24 60 60))
2897 "Mapping from time units to seconds.")
2899 (defun gnus-article-forward-header ()
2900 "Move point to the start of the next header.
2901 If the current header is a continuation header, this can be several
2906 (if (looking-at "[ \t]+[^ \t]")
2910 (defun article-date-ut (&optional type highlight header)
2911 "Convert DATE date to universal time in the current article.
2912 If TYPE is `local', convert to local time; if it is `lapsed', output
2913 how much time has lapsed since DATE. For `lapsed', the value of
2914 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2915 should replace the \"Date:\" one, or should be added below it."
2916 (interactive (list 'ut t))
2917 (let* ((header (or header
2918 (and (eq 1 (point-min))
2919 (mail-header-date (save-excursion
2920 (set-buffer gnus-summary-buffer)
2921 gnus-current-headers)))
2922 (message-fetch-field "date")
2924 (date (if (vectorp header) (mail-header-date header)
2926 (inhibit-point-motion-hooks t)
2927 bface eface date-pos)
2928 (when (and date (not (string= date "")))
2931 (article-narrow-to-head)
2932 (when (or (and (eq type 'lapsed)
2933 gnus-article-date-lapsed-new-header
2934 ;; Attempt to get the face of X-Sent first.
2935 (re-search-forward "^X-Sent:[ \t]" nil t))
2936 (re-search-forward "^Date:[ \t]" nil t)
2937 ;; If Date is missing, try again for X-Sent.
2938 (re-search-forward "^X-Sent:[ \t]" nil t))
2939 (setq bface (get-text-property (point-at-bol) 'face)
2940 date (or (get-text-property (point-at-bol)
2943 eface (get-text-property (1- (point-at-eol))
2945 (let ((buffer-read-only nil))
2946 ;; Delete any old X-Sent headers.
2947 (when (setq date-pos
2948 (text-property-any (point-min) (point-max)
2949 'article-date-lapsed t))
2950 (goto-char (setq date-pos (set-marker (make-marker) date-pos)))
2951 (delete-region (match-beginning 0)
2952 (progn (forward-line 1) (point))))
2953 (goto-char (point-min))
2954 ;; Delete any old Date headers.
2955 (while (re-search-forward "^Date:[ \t]" nil t)
2957 (setq date-pos (match-beginning 0)))
2958 (unless (and (eq type 'lapsed)
2959 gnus-article-date-lapsed-new-header)
2960 (delete-region (match-beginning 0)
2961 (progn (message-next-header) (point)))))
2964 (goto-char date-pos)
2966 ;; Possibly, Date has been deleted.
2968 (when (and (eq type 'lapsed)
2969 gnus-article-date-lapsed-new-header
2970 (looking-at "Date:"))
2972 (goto-char (point-min)))
2973 (insert (article-make-date-line date type))
2974 (when (eq type 'lapsed)
2975 (put-text-property (point-at-bol) (point)
2976 'article-date-lapsed t))
2980 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2981 (put-text-property (match-beginning 1) (1+ (match-end 1))
2982 'original-date date)
2983 (put-text-property (match-beginning 1) (1+ (match-end 1))
2985 (put-text-property (match-beginning 2) (match-end 2)
2988 (defun article-make-date-line (date type)
2989 "Return a DATE line of TYPE."
2990 (unless (memq type '(local ut original user iso8601 lapsed english))
2991 (error "Unknown conversion type: %s" type))
2993 (let ((time (date-to-time date)))
2995 ;; Convert to the local timezone.
2997 (let ((tz (car (current-time-zone time))))
2998 (format "Date: %s %s%02d%02d" (current-time-string time)
2999 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
3000 (/ (% (abs tz) 3600) 60))))
3001 ;; Convert to Universal Time.
3004 (current-time-string
3005 (let* ((e (parse-time-string date))
3006 (tm (apply 'encode-time e))
3008 (ls (- (cadr tm) (car (current-time-zone time)))))
3009 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
3010 ((> ls 65535) (list (1+ ms) (- ls 65536)))
3013 ;; Get the original date from the article.
3014 ((eq type 'original)
3015 (concat "Date: " (if (string-match "\n+$" date)
3016 (substring date 0 (match-beginning 0))
3018 ;; Let the user define the format.
3020 (let ((format (or (condition-case nil
3021 (with-current-buffer gnus-summary-buffer
3022 gnus-article-time-format)
3024 gnus-article-time-format)))
3025 (if (functionp format)
3026 (funcall format time)
3027 (concat "Date: " (format-time-string format time)))))
3030 (let ((tz (car (current-time-zone time))))
3033 (format-time-string "%Y%m%dT%H%M%S" time)
3034 (format "%s%02d%02d"
3035 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
3036 (/ (% (abs tz) 3600) 60)))))
3037 ;; Do an X-Sent lapsed format.
3039 ;; If the date is seriously mangled, the timezone functions are
3040 ;; liable to bug out, so we ignore all errors.
3041 (let* ((now (current-time))
3042 (real-time (subtract-time now time))
3043 (real-sec (and real-time
3044 (+ (* (float (car real-time)) 65536)
3046 (sec (and real-time (abs real-sec)))
3056 ;; This is a bit convoluted, but basically we go
3057 ;; through the time units for years, weeks, etc,
3058 ;; and divide things to see whether that results
3059 ;; in positive answers.
3062 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
3063 ;; The (remaining) seconds are too few to
3064 ;; be divided into this time unit.
3066 ;; It's big enough, so we output it.
3067 (setq sec (- sec (* num (cdr unit))))
3069 (concat (if prev ", " "") (int-to-string
3071 " " (symbol-name (car unit))
3072 (if (> num 1) "s" ""))
3074 article-time-units "")
3075 ;; If dates are odd, then it might appear like the
3076 ;; article was sent in the future.
3079 " in the future"))))))
3080 ;; Display the date in proper English
3082 (let ((dtime (decode-time time)))
3085 (number-to-string (nth 3 dtime))
3086 (let ((digit (% (nth 3 dtime) 10)))
3088 ((memq (nth 3 dtime) '(11 12 13)) "th")
3094 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3096 (number-to-string (nth 5 dtime))
3098 (format "%02d" (nth 2 dtime))
3100 (format "%02d" (nth 1 dtime)))))))
3102 (format "Date: %s (from T-gnus)" date))))
3104 (defun article-date-local (&optional highlight)
3105 "Convert the current article date to the local timezone."
3106 (interactive (list t))
3107 (article-date-ut 'local highlight))
3109 (defun article-date-english (&optional highlight)
3110 "Convert the current article date to something that is proper English."
3111 (interactive (list t))
3112 (article-date-ut 'english highlight))
3114 (defun article-date-original (&optional highlight)
3115 "Convert the current article date to what it was originally.
3116 This is only useful if you have used some other date conversion
3117 function and want to see what the date was before converting."
3118 (interactive (list t))
3119 (article-date-ut 'original highlight))
3121 (defun article-date-lapsed (&optional highlight)
3122 "Convert the current article date to time lapsed since it was sent."
3123 (interactive (list t))
3124 (article-date-ut 'lapsed highlight))
3126 (defun article-update-date-lapsed ()
3127 "Function to be run from a timer to update the lapsed time line."
3128 (let (deactivate-mark)
3133 (set-buffer (window-buffer w))
3134 (when (eq major-mode 'gnus-article-mode)
3135 (let ((mark (point-marker)))
3136 (goto-char (point-min))
3137 (when (re-search-forward "^X-Sent:" nil t)
3138 (article-date-lapsed t))
3139 (goto-char (marker-position mark))
3140 (move-marker mark nil))))
3143 (defun gnus-start-date-timer (&optional n)
3144 "Start a timer to update the X-Sent header in the article buffers.
3145 The numerical prefix says how frequently (in seconds) the function
3150 (gnus-stop-date-timer)
3151 (setq article-lapsed-timer
3152 (run-at-time 1 n 'article-update-date-lapsed)))
3154 (defun gnus-stop-date-timer ()
3155 "Stop the X-Sent timer."
3157 (when article-lapsed-timer
3158 (nnheader-cancel-timer article-lapsed-timer)
3159 (setq article-lapsed-timer nil)))
3161 (defun article-date-user (&optional highlight)
3162 "Convert the current article date to the user-defined format.
3163 This format is defined by the `gnus-article-time-format' variable."
3164 (interactive (list t))
3165 (article-date-ut 'user highlight))
3167 (defun article-date-iso8601 (&optional highlight)
3168 "Convert the current article date to ISO8601."
3169 (interactive (list t))
3170 (article-date-ut 'iso8601 highlight))
3172 ;; (defun article-show-all ()
3173 ;; "Show all hidden text in the article buffer."
3177 ;; (let ((buffer-read-only nil))
3178 ;; (gnus-article-unhide-text (point-min) (point-max))
3179 ;; (gnus-remove-text-with-property 'gnus-prev)
3180 ;; (gnus-remove-text-with-property 'gnus-next))))
3182 (defun article-show-all-headers ()
3183 "Show all hidden headers in the article buffer."
3188 (article-narrow-to-head)
3189 (let ((buffer-read-only nil))
3190 (gnus-article-unhide-text (point-min) (point-max))))))
3192 (defun article-remove-leading-whitespace ()
3193 "Remove excessive whitespace from all headers."
3197 (let ((buffer-read-only nil))
3198 (article-narrow-to-head)
3199 (goto-char (point-min))
3200 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3201 (delete-region (match-beginning 1) (match-end 1)))))))
3203 (defun article-emphasize (&optional arg)
3204 "Emphasize text according to `gnus-emphasis-alist'."
3205 (interactive (gnus-article-hidden-arg))
3206 (unless (gnus-article-check-hidden-text 'emphasis arg)
3210 (with-current-buffer gnus-summary-buffer
3211 gnus-article-emphasis-alist)
3213 gnus-emphasis-alist))
3214 (buffer-read-only nil)
3215 (props (append '(article-type emphasis)
3216 gnus-hidden-properties))
3217 regexp elem beg invisible visible face)
3220 (while (setq elem (pop alist))
3222 (setq regexp (car elem)
3223 invisible (nth 1 elem)
3224 visible (nth 2 elem)
3226 (while (re-search-forward regexp nil t)
3227 (when (and (match-beginning visible) (match-beginning invisible))
3228 (gnus-article-hide-text
3229 (match-beginning invisible) (match-end invisible) props)
3230 (gnus-article-unhide-text-type
3231 (match-beginning visible) (match-end visible) 'emphasis)
3232 (gnus-put-overlay-excluding-newlines
3233 (match-beginning visible) (match-end visible) 'face face)
3234 (gnus-add-wash-type 'emphasis)
3235 (goto-char (match-end invisible)))))))))
3237 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3238 "Setup newsgroup emphasis alist."
3239 (unless gnus-article-emphasis-alist
3240 (let ((name (and gnus-newsgroup-name
3241 (gnus-group-real-name gnus-newsgroup-name))))
3242 (make-local-variable 'gnus-article-emphasis-alist)
3243 (setq gnus-article-emphasis-alist
3245 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3246 (while (setq elem (pop alist))
3247 (when (and name (string-match (car elem) name))
3249 highlight (copy-sequence (cdr elem)))))
3251 (copy-sequence highlight-words)
3252 (if gnus-newsgroup-name
3253 (copy-sequence (gnus-group-find-parameter
3254 gnus-newsgroup-name 'highlight-words t)))
3255 gnus-emphasis-alist)))))
3258 (defvar gnus-summary-article-menu)
3259 (defvar gnus-summary-post-menu))
3261 ;;; Saving functions.
3263 (defun gnus-article-save (save-buffer file &optional num)
3264 "Save the currently selected article."
3265 (unless gnus-save-all-headers
3266 ;; Remove headers according to `gnus-saved-headers'.
3267 (let ((gnus-visible-headers
3268 (or gnus-saved-headers gnus-visible-headers))
3269 (gnus-article-buffer save-buffer))
3271 (set-buffer save-buffer)
3272 (article-hide-headers 1 t))))
3273 (save-window-excursion
3274 (if (not gnus-default-article-saver)
3275 (error "No default saver is defined")
3276 ;; !!! Magic! The saving functions all save
3277 ;; `gnus-save-article-buffer' (or so they think), but we
3278 ;; bind that variable to our save-buffer.
3279 (set-buffer gnus-article-buffer)
3280 (let* ((gnus-save-article-buffer save-buffer)
3283 ((not gnus-prompt-before-saving) 'default)
3284 ((eq gnus-prompt-before-saving 'always) nil)
3286 (gnus-number-of-articles-to-be-saved
3287 (when (eq gnus-prompt-before-saving t)
3289 (set-buffer gnus-article-current-summary)
3290 (funcall gnus-default-article-saver filename)))))
3292 (defun gnus-read-save-file-name (prompt &optional filename
3293 function group headers variable)
3295 (funcall function group headers (symbol-value variable)))
3300 ((eq filename 'default)
3306 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3309 (if (and gnus-number-of-articles-to-be-saved
3310 (> gnus-number-of-articles-to-be-saved 1))
3311 (format "these %d articles"
3312 gnus-number-of-articles-to-be-saved)
3315 ;; Let the split methods have their say.
3317 ;; No split name was found.
3320 (concat prompt " (default "
3321 (file-name-nondirectory default-name) ") ")
3322 (file-name-directory default-name)
3324 ;; A single group name is returned.
3325 ((stringp split-name)
3327 (funcall function split-name headers
3328 (symbol-value variable)))
3330 (concat prompt " (default "
3331 (file-name-nondirectory default-name) ") ")
3332 (file-name-directory default-name)
3334 ;; A single split name was found
3335 ((= 1 (length split-name))
3336 (let* ((name (expand-file-name
3338 gnus-article-save-directory))
3339 (dir (cond ((file-directory-p name)
3340 (file-name-as-directory name))
3341 ((file-exists-p name) name)
3342 (t gnus-article-save-directory))))
3344 (concat prompt " (default " name ") ")
3346 ;; A list of splits was found.
3348 (setq split-name (nreverse split-name))
3350 (let ((file-name-history
3351 (nconc split-name file-name-history)))
3355 (concat prompt " (`M-p' for defaults) ")
3356 gnus-article-save-directory
3358 gnus-article-save-directory)))
3359 (car (push result file-name-history)))))))
3360 ;; Create the directory.
3361 (gnus-make-directory (file-name-directory file))
3362 ;; If we have read a directory, we append the default file name.
3363 (when (file-directory-p file)
3364 (setq file (expand-file-name (file-name-nondirectory
3366 (file-name-as-directory file))))
3367 ;; Possibly translate some characters.
3368 (nnheader-translate-file-chars file))))))
3369 (gnus-make-directory (file-name-directory result))
3370 (set variable result)))
3372 (defun gnus-article-archive-name (group)
3373 "Return the first instance of an \"Archive-name\" in the current buffer."
3374 (let ((case-fold-search t))
3375 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3376 (nnheader-concat gnus-article-save-directory
3377 (match-string 1)))))
3379 (defun gnus-article-nndoc-name (group)
3380 "If GROUP is an nndoc group, return the name of the parent group."
3381 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3382 (gnus-group-get-parameter group 'save-article-group)))
3384 (defun gnus-summary-save-in-rmail (&optional filename)
3385 "Append this article to Rmail file.
3386 Optional argument FILENAME specifies file name.
3387 Directory to save to is default to `gnus-article-save-directory'."
3388 (setq filename (gnus-read-save-file-name
3389 "Save %s in rmail file:" filename
3390 gnus-rmail-save-name gnus-newsgroup-name
3391 gnus-current-headers 'gnus-newsgroup-last-rmail))
3392 (gnus-eval-in-buffer-window gnus-save-article-buffer
3396 (gnus-output-to-rmail filename))))
3399 (defun gnus-summary-save-in-mail (&optional filename)
3400 "Append this article to Unix mail file.
3401 Optional argument FILENAME specifies file name.
3402 Directory to save to is default to `gnus-article-save-directory'."
3403 (setq filename (gnus-read-save-file-name
3404 "Save %s in Unix mail file:" filename
3405 gnus-mail-save-name gnus-newsgroup-name
3406 gnus-current-headers 'gnus-newsgroup-last-mail))
3407 (gnus-eval-in-buffer-window gnus-save-article-buffer
3411 (if (and (file-readable-p filename)
3412 (file-regular-p filename)
3413 (mail-file-babyl-p filename))
3414 (rmail-output-to-rmail-file filename t)
3415 (gnus-output-to-mail filename)))))
3418 (defun gnus-summary-save-in-file (&optional filename overwrite)
3419 "Append this article to file.
3420 Optional argument FILENAME specifies file name.
3421 Directory to save to is default to `gnus-article-save-directory'."
3422 (setq filename (gnus-read-save-file-name
3423 "Save %s in file:" filename
3424 gnus-file-save-name gnus-newsgroup-name
3425 gnus-current-headers 'gnus-newsgroup-last-file))
3426 (gnus-eval-in-buffer-window gnus-save-article-buffer
3430 (when (and overwrite
3431 (file-exists-p filename))
3432 (delete-file filename))
3433 (gnus-output-to-file filename))))
3436 (defun gnus-summary-write-to-file (&optional filename)
3437 "Write this article to a file, overwriting it if the file exists.
3438 Optional argument FILENAME specifies file name.
3439 The directory to save in defaults to `gnus-article-save-directory'."
3440 (gnus-summary-save-in-file nil t))
3442 (defun gnus-summary-save-body-in-file (&optional filename)
3443 "Append this article body to a file.
3444 Optional argument FILENAME specifies file name.
3445 The directory to save in defaults to `gnus-article-save-directory'."
3446 (setq filename (gnus-read-save-file-name
3447 "Save %s body in file:" filename
3448 gnus-file-save-name gnus-newsgroup-name
3449 gnus-current-headers 'gnus-newsgroup-last-file))
3450 (gnus-eval-in-buffer-window gnus-save-article-buffer
3454 (when (article-goto-body)
3455 (narrow-to-region (point) (point-max)))
3456 (gnus-output-to-file filename))))
3459 (defun gnus-summary-save-in-pipe (&optional command)
3460 "Pipe this article to subprocess."
3462 (cond ((and (eq command 'default)
3463 gnus-last-shell-command)
3464 gnus-last-shell-command)
3469 "Shell command on %s: "
3470 (if (and gnus-number-of-articles-to-be-saved
3471 (> gnus-number-of-articles-to-be-saved 1))
3472 (format "these %d articles"
3473 gnus-number-of-articles-to-be-saved)
3475 gnus-last-shell-command))))
3476 (when (string-equal command "")
3477 (if gnus-last-shell-command
3478 (setq command gnus-last-shell-command)
3479 (error "A command is required")))
3480 (gnus-eval-in-buffer-window gnus-article-buffer
3483 (shell-command-on-region (point-min) (point-max) command nil)))
3484 (setq gnus-last-shell-command command))
3486 (defun gnus-summary-pipe-to-muttprint (&optional command)
3487 "Pipe this article to muttprint."
3488 (setq command (read-string
3489 "Print using command: " gnus-summary-muttprint-program
3490 nil gnus-summary-muttprint-program))
3491 (gnus-summary-save-in-pipe command))
3493 ;;; Article file names when saving.
3495 (defun gnus-capitalize-newsgroup (newsgroup)
3496 "Capitalize NEWSGROUP name."
3497 (when (not (zerop (length newsgroup)))
3498 (concat (char-to-string (upcase (aref newsgroup 0)))
3499 (substring newsgroup 1))))
3501 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3502 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3503 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3504 Otherwise, it is like ~/News/news/group/num."
3507 (concat (if (gnus-use-long-file-name 'not-save)
3508 (gnus-capitalize-newsgroup newsgroup)
3509 (gnus-newsgroup-directory-form newsgroup))
3510 "/" (int-to-string (mail-header-number headers)))
3511 gnus-article-save-directory)))
3513 (string-equal (file-name-directory default)
3514 (file-name-directory last-file))
3515 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3517 (or last-file default))))
3519 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3520 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3521 If variable `gnus-use-long-file-name' is non-nil, it is
3522 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3525 (concat (if (gnus-use-long-file-name 'not-save)
3527 (gnus-newsgroup-directory-form newsgroup))
3528 "/" (int-to-string (mail-header-number headers)))
3529 gnus-article-save-directory)))
3531 (string-equal (file-name-directory default)
3532 (file-name-directory last-file))
3533 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3535 (or last-file default))))
3537 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3538 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3539 If variable `gnus-use-long-file-name' is non-nil, it is
3540 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3543 (if (gnus-use-long-file-name 'not-save)
3546 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3548 gnus-article-save-directory)))
3550 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3551 "Generate file name from sender."
3552 (let ((from (mail-header-from headers)))
3554 (if (and from (string-match "\\([^ <]+\\)@" from))
3555 (match-string 1 from)
3557 gnus-article-save-directory)))
3559 (defun article-verify-x-pgp-sig ()
3562 (if (gnus-buffer-live-p gnus-original-article-buffer)
3563 (let ((sig (with-current-buffer gnus-original-article-buffer
3564 (gnus-fetch-field "X-PGP-Sig")))
3568 (mml2015-clear-verify-function))
3570 (insert-buffer-substring gnus-original-article-buffer)
3571 (setq items (split-string sig))
3572 (message-narrow-to-head)
3573 (let ((inhibit-point-motion-hooks t)
3574 (case-fold-search t))
3575 ;; Don't verify multiple headers.
3576 (setq headers (mapconcat (lambda (header)
3578 (mail-fetch-field header)
3580 (split-string (nth 1 items) ",") "")))
3581 (delete-region (point-min) (point-max))
3582 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3583 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3588 (if (looking-at "^-")
3591 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3592 (insert "Version: " (car items) "\n\n")
3593 (insert (mapconcat 'identity (cddr items) "\n"))
3594 (insert "\n-----END PGP SIGNATURE-----\n")
3595 (let ((mm-security-handle (list (format "multipart/signed"))))
3596 (mml2015-clean-buffer)
3597 (let ((coding-system-for-write (or gnus-newsgroup-charset
3599 (funcall (mml2015-clear-verify-function)))
3601 (or (mm-handle-multipart-ctl-parameter
3602 mm-security-handle 'gnus-details)
3603 (mm-handle-multipart-ctl-parameter
3604 mm-security-handle 'gnus-info)))))
3606 (let (buffer-read-only bface eface)
3608 (message-narrow-to-head)
3609 (goto-char (point-max))
3611 (setq bface (get-text-property (point-at-bol) 'face)
3612 eface (get-text-property (1- (point-at-eol)) 'face))
3613 (message-remove-header "X-Gnus-PGP-Verify")
3614 (if (re-search-forward "^X-PGP-Sig:" nil t)
3616 (goto-char (point-max)))
3617 (narrow-to-region (point) (point))
3618 (insert "X-Gnus-PGP-Verify: " info "\n")
3619 (goto-char (point-min))
3622 (if (not (looking-at "^[ \t]"))
3626 (goto-char (point-min))
3627 (when (looking-at "\\([^:]+\\): *")
3628 (put-text-property (match-beginning 1) (1+ (match-end 1))
3630 (put-text-property (match-end 0) (point-max)
3631 'face eface)))))))))
3633 (defun article-verify-cancel-lock ()
3634 "Verify Cancel-Lock header."
3636 (if (gnus-buffer-live-p gnus-original-article-buffer)
3637 (canlock-verify gnus-original-article-buffer)))
3639 (defun article-monafy ()
3640 "Display body part with mona font."
3642 (unless (if (featurep 'xemacs)
3643 (find-face 'gnus-mona-face)
3644 (facep 'gnus-mona-face))
3645 (require 'navi2ch-mona)
3646 (set-face-font (make-face 'gnus-mona-face) navi2ch-mona-font))
3648 (let ((buffer-read-only nil))
3651 (gnus-make-overlay (point) (point-max))
3652 'face 'gnus-mona-face))))
3659 (setq afunc (car func)
3662 gfunc (intern (format "gnus-%s" func))))
3664 (when (fboundp afunc)
3665 `(lambda (&optional interactive &rest args)
3666 ,(documentation afunc t)
3667 (interactive (list t))
3669 (set-buffer gnus-article-buffer)
3671 (call-interactively ',afunc)
3672 (apply ',afunc args))))))))
3673 '(article-hide-headers
3674 article-verify-x-pgp-sig
3675 article-verify-cancel-lock
3677 article-hide-boring-headers
3678 article-treat-overstrike
3679 article-treat-ansi-sequences
3680 article-fill-long-lines
3681 article-capitalize-sentences
3683 article-remove-leading-whitespace
3684 article-display-x-face
3685 article-display-face
3686 article-de-quoted-unreadable
3687 article-de-base64-unreadable
3690 article-unsplit-urls
3691 article-hide-list-identifiers
3692 article-strip-banner
3695 article-hide-signature
3696 article-strip-headers-in-body
3697 article-remove-trailing-blank-lines
3698 article-strip-leading-blank-lines
3699 article-strip-multiple-blank-lines
3700 article-strip-leading-space
3701 article-strip-trailing-space
3702 article-strip-blank-lines
3703 article-strip-all-blank-lines
3705 article-date-english
3706 article-date-iso8601
3707 article-date-original
3709 article-decode-mime-words
3710 article-decode-charset
3711 article-decode-encoded-words
3715 article-treat-dumbquotes
3716 article-normalize-headers
3717 (article-show-all-headers . gnus-article-show-all-headers)
3718 ;; (article-show-all . gnus-article-show-all)
3722 ;;; Gnus article mode
3725 (put 'gnus-article-mode 'mode-class 'special)
3727 (gnus-define-keys gnus-article-mode-map
3728 " " gnus-article-goto-next-page
3729 "\177" gnus-article-goto-prev-page
3730 [delete] gnus-article-goto-prev-page
3731 [backspace] gnus-article-goto-prev-page
3732 "\C-c^" gnus-article-refer-article
3733 "h" gnus-article-show-summary
3734 "s" gnus-article-show-summary
3735 "\C-c\C-m" gnus-article-mail
3736 "?" gnus-article-describe-briefly
3737 "e" gnus-summary-edit-article
3738 "<" beginning-of-buffer
3740 "\C-c\C-i" gnus-info-find-node
3742 "R" gnus-article-reply-with-original
3743 "F" gnus-article-followup-with-original
3744 "\C-hk" gnus-article-describe-key
3745 "\C-hc" gnus-article-describe-key-briefly
3747 "\C-d" gnus-article-read-summary-keys
3748 "\M-*" gnus-article-read-summary-keys
3749 "\M-#" gnus-article-read-summary-keys
3750 "\M-^" gnus-article-read-summary-keys
3751 "\M-g" gnus-article-read-summary-keys)
3753 ;; Define almost undefined keys to `gnus-article-read-summary-keys'.
3757 (push (char-to-string key) keys)
3759 (dolist (elem (accessible-keymaps gnus-summary-mode-map))
3760 (setq key (car elem))
3761 (when (and (> (length key) 0)
3762 (not (eq 'menu-bar (aref key 0)))
3763 (symbolp (lookup-key gnus-summary-mode-map key)))
3766 (unless (lookup-key gnus-article-mode-map key)
3767 (define-key gnus-article-mode-map key 'gnus-article-read-summary-keys))))
3769 (defun gnus-article-make-menu-bar ()
3770 (unless (boundp 'gnus-article-commands-menu)
3771 (gnus-summary-make-menu-bar))
3772 (gnus-turn-off-edit-menu 'article)
3773 (unless (boundp 'gnus-article-article-menu)
3775 gnus-article-article-menu gnus-article-mode-map ""
3777 ["Scroll forwards" gnus-article-goto-next-page t]
3778 ["Scroll backwards" gnus-article-goto-prev-page t]
3779 ["Show summary" gnus-article-show-summary t]
3780 ["Fetch Message-ID at point" gnus-article-refer-article t]
3781 ["Mail to address at point" gnus-article-mail t]
3782 ["Send a bug report" gnus-bug t]))
3785 gnus-article-treatment-menu gnus-article-mode-map ""
3786 ;; Fixme: this should use :active (and maybe :visible).
3788 ["Hide headers" gnus-article-hide-headers t]
3789 ["Hide signature" gnus-article-hide-signature t]
3790 ["Hide citation" gnus-article-hide-citation t]
3791 ["Treat overstrike" gnus-article-treat-overstrike t]
3792 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
3793 ["Remove carriage return" gnus-article-remove-cr t]
3794 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3795 ["Treat html" gnus-article-wash-html t]
3796 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3797 ["Decode HZ" gnus-article-decode-HZ t]))
3799 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3801 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3803 (gnus-run-hooks 'gnus-article-menu-hook)))
3805 (defun gnus-article-mode ()
3806 "Major mode for displaying an article.
3808 All normal editing commands are switched off.
3810 The following commands are available in addition to all summary mode
3812 \\<gnus-article-mode-map>
3813 \\[gnus-article-next-page]\t Scroll the article one page forwards
3814 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3815 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3816 \\[gnus-article-show-summary]\t Display the summary buffer
3817 \\[gnus-article-mail]\t Send a reply to the address near point
3818 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3819 \\[gnus-info-find-node]\t Go to the Gnus info node"
3821 (gnus-simplify-mode-line)
3822 (setq mode-name "Article")
3823 (setq major-mode 'gnus-article-mode)
3824 (make-local-variable 'minor-mode-alist)
3825 (unless (assq 'gnus-show-mime minor-mode-alist)
3826 (push (list 'gnus-show-mime " MIME") minor-mode-alist))
3827 (use-local-map gnus-article-mode-map)
3828 (when (gnus-visual-p 'article-menu 'menu)
3829 (gnus-article-make-menu-bar)
3830 (when gnus-summary-tool-bar-map
3831 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3832 (gnus-update-format-specifications nil 'article-mode)
3833 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3834 (set (make-local-variable 'gnus-page-broken) nil)
3835 (make-local-variable 'gnus-button-marker-list)
3836 (make-local-variable 'gnus-article-current-summary)
3837 (make-local-variable 'gnus-article-mime-handles)
3838 (make-local-variable 'gnus-article-decoded-p)
3839 (make-local-variable 'gnus-article-mime-handle-alist)
3840 (make-local-variable 'gnus-article-wash-types)
3841 (make-local-variable 'gnus-article-image-alist)
3842 (make-local-variable 'gnus-article-charset)
3843 (make-local-variable 'gnus-article-ignored-charsets)
3844 (gnus-set-default-directory)
3845 (buffer-disable-undo)
3846 (setq buffer-read-only t)
3847 (set-syntax-table gnus-article-mode-syntax-table)
3848 (gnus-run-hooks 'gnus-article-mode-hook))
3850 (defun gnus-article-setup-buffer ()
3851 "Initialize the article buffer."
3852 (let* ((name (if gnus-single-article-buffer "*Article*"
3853 (concat "*Article " gnus-newsgroup-name "*")))
3855 (progn (string-match "\\*Article" name)
3856 (concat " *Original Article"
3857 (substring name (match-end 0))))))
3858 (setq gnus-article-buffer name)
3859 (setq gnus-original-article-buffer original)
3860 (setq gnus-article-mime-handle-alist nil)
3861 ;; This might be a variable local to the summary buffer.
3862 (unless gnus-single-article-buffer
3864 (set-buffer gnus-summary-buffer)
3865 (setq gnus-article-buffer name)
3866 (setq gnus-original-article-buffer original)
3867 (gnus-set-global-variables)))
3868 (gnus-article-setup-highlight-words)
3869 ;; Init original article buffer.
3871 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3872 (set-buffer-multibyte t)
3873 (setq major-mode 'gnus-original-article-mode)
3874 (make-local-variable 'gnus-original-article))
3875 (if (get-buffer name)
3878 (when (and gnus-article-edit-mode
3881 (y-or-n-p "Article mode edit in progress; discard? ")))
3882 (error "Action aborted"))
3883 (set (make-local-variable 'gnus-article-edit-mode) nil)
3884 (buffer-disable-undo)
3885 (setq buffer-read-only t)
3886 ;; This list just keeps growing if we don't reset it.
3887 (setq gnus-button-marker-list nil)
3888 (unless (eq major-mode 'gnus-article-mode)
3889 (gnus-article-mode))
3892 (set-buffer (gnus-get-buffer-create name))
3894 (make-local-variable 'gnus-summary-buffer)
3895 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3896 (current-buffer)))))
3898 ;; Set article window start at LINE, where LINE is the number of lines
3899 ;; from the head of the article.
3900 (defun gnus-article-set-window-start (&optional line)
3902 (gnus-get-buffer-window gnus-article-buffer t)
3904 (set-buffer gnus-article-buffer)
3905 (goto-char (point-min))
3908 (gnus-message 6 "Moved to bookmark")
3909 (search-forward "\n\n" nil t)
3913 ;;; @@ article filters
3916 (defun gnus-article-display-mime-message ()
3917 "Article display method for MIME message."
3918 ;; called from `gnus-original-article-buffer'.
3919 (let (charset all-headers)
3920 (with-current-buffer gnus-summary-buffer
3921 (setq charset default-mime-charset
3922 all-headers gnus-have-all-headers))
3923 (make-local-variable 'default-mime-charset)
3924 (setq default-mime-charset charset)
3925 (with-current-buffer (get-buffer-create gnus-article-buffer)
3926 (make-local-variable 'default-mime-charset)
3927 (setq default-mime-charset charset))
3928 (mime-display-message mime-message-structure
3929 gnus-article-buffer nil gnus-article-mode-map)
3931 (gnus-article-hide-headers nil -1)))
3932 (run-hooks 'gnus-mime-article-prepare-hook))
3934 (defun gnus-article-display-traditional-message ()
3935 "Article display method for traditional message."
3936 (set-buffer gnus-article-buffer)
3937 (let (buffer-read-only)
3939 (insert-buffer-substring gnus-original-article-buffer)))
3941 (defun gnus-article-make-full-mail-header (&optional number charset)
3942 "Create a new mail header structure in a raw article buffer."
3943 (unless (and number charset)
3944 (save-current-buffer
3945 (set-buffer gnus-summary-buffer)
3947 (setq number (or (cdr gnus-article-current) 0)))
3949 (setq charset (or default-mime-charset 'x-ctext)))))
3950 (goto-char (point-min))
3951 (let ((header-end (if (search-forward "\n\n" nil t)
3953 (goto-char (point-max))))
3954 (chars (- (point-max) (point)))
3955 (lines (count-lines (point) (point-max)))
3956 (default-mime-charset charset)
3958 (narrow-to-region (point-min) header-end)
3959 (setq xref (std11-fetch-field "xref"))
3961 (make-full-mail-header
3963 (std11-fetch-field "subject")
3964 (std11-fetch-field "from")
3965 (std11-fetch-field "date")
3966 (std11-fetch-field "message-id")
3967 (std11-fetch-field "references")
3970 (when xref (concat "Xref: " xref)))
3973 (defun gnus-article-prepare (article &optional all-headers header)
3974 "Prepare ARTICLE in article mode buffer.
3975 ARTICLE should either be an article number or a Message-ID.
3976 If ARTICLE is an id, HEADER should be the article headers.
3977 If ALL-HEADERS is non-nil, no headers are hidden."
3979 ;; Make sure we start in a summary buffer.
3980 (unless (eq major-mode 'gnus-summary-mode)
3981 (set-buffer gnus-summary-buffer))
3982 (setq gnus-summary-buffer (current-buffer))
3983 (let* ((gnus-article (if header (mail-header-number header) article))
3984 (summary-buffer (current-buffer))
3985 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3986 (group gnus-newsgroup-name)
3989 (gnus-article-setup-buffer)
3990 (set-buffer gnus-article-buffer)
3991 ;; Deactivate active regions.
3992 (when (and (boundp 'transient-mark-mode)
3993 transient-mark-mode)
3994 (setq mark-active nil))
3995 (if (not (setq result (let ((buffer-read-only nil))
3996 (gnus-request-article-this-buffer
3998 ;; There is no such article.
4000 (when (and (numberp article)
4001 (not (memq article gnus-newsgroup-sparse)))
4002 (setq gnus-article-current
4003 (cons gnus-newsgroup-name article))
4004 (set-buffer gnus-summary-buffer)
4005 (setq gnus-current-article article)
4006 (if (and (memq article gnus-newsgroup-undownloaded)
4007 (not (gnus-online (gnus-find-method-for-group
4008 gnus-newsgroup-name))))
4010 (gnus-summary-set-agent-mark article)
4011 (message "Message marked for downloading"))
4012 (gnus-summary-mark-article article gnus-canceled-mark)
4013 (unless (memq article gnus-newsgroup-sparse)
4014 (gnus-error 1 "No such article (may have expired or been canceled)")))))
4015 (if (or (eq result 'pseudo)
4016 (eq result 'nneething))
4019 (set-buffer summary-buffer)
4020 (push article gnus-newsgroup-history)
4021 (setq gnus-last-article gnus-current-article
4022 gnus-current-article 0
4023 gnus-current-headers nil
4024 gnus-article-current nil)
4025 (if (eq result 'nneething)
4026 (gnus-configure-windows 'summary)
4027 (gnus-configure-windows 'article))
4028 (gnus-set-global-variables))
4029 (let ((gnus-article-mime-handle-alist-1
4030 gnus-article-mime-handle-alist))
4031 (gnus-set-mode-line 'article)))
4032 ;; The result from the `request' was an actual article -
4033 ;; or at least some text that is now displayed in the
4035 (when (and (numberp article)
4036 (not (eq article gnus-current-article)))
4037 ;; Seems like a new article has been selected.
4038 ;; `gnus-current-article' must be an article number.
4040 (set-buffer summary-buffer)
4041 (push article gnus-newsgroup-history)
4042 (setq gnus-last-article gnus-current-article
4043 gnus-current-article article
4044 gnus-current-headers
4045 (gnus-summary-article-header gnus-current-article)
4046 gnus-article-current
4047 (cons gnus-newsgroup-name gnus-current-article))
4048 (unless (vectorp gnus-current-headers)
4049 (setq gnus-current-headers nil))
4050 (gnus-summary-goto-subject gnus-current-article)
4051 (when (gnus-summary-show-thread)
4052 ;; If the summary buffer really was folded, the
4053 ;; previous goto may not actually have gone to
4054 ;; the right article, but the thread root instead.
4056 (gnus-summary-goto-subject gnus-current-article))
4057 (gnus-run-hooks 'gnus-mark-article-hook)
4058 (gnus-set-mode-line 'summary)
4059 (when (gnus-visual-p 'article-highlight 'highlight)
4060 (gnus-run-hooks 'gnus-visual-mark-article-hook))
4061 ;; Set the global newsgroup variables here.
4062 (gnus-set-global-variables)
4063 (setq gnus-have-all-headers
4064 (or all-headers gnus-show-all-headers))))
4066 (gnus-configure-windows 'article))
4067 (when (or (numberp article)
4069 (gnus-article-prepare-display)
4071 (goto-char (point-min))
4072 (when gnus-break-pages
4073 (gnus-narrow-to-page)))
4074 (let ((gnus-article-mime-handle-alist-1
4075 gnus-article-mime-handle-alist))
4076 (gnus-set-mode-line 'article))
4080 (set-window-point (get-buffer-window (current-buffer)) (point))
4081 (gnus-configure-windows 'article)
4084 (defun gnus-article-prepare-mime-display (&optional number)
4085 (goto-char (point-min))
4086 (when (re-search-forward "^[^\t ]+:" nil t)
4087 (goto-char (match-beginning 0)))
4088 (let ((entity (if (eq 1 (point-min))
4089 (get-text-property 1 'mime-view-entity)
4090 (get-text-property (point) 'mime-view-entity)))
4091 last-entity child-entity next type)
4092 (setq child-entity (mime-entity-children entity))
4094 (setq last-entity (nth (1- (length child-entity))
4096 (setq last-entity entity))
4098 (narrow-to-region (point)
4099 (if (search-forward "\n\n" nil t)
4102 (gnus-treat-article 'head)
4103 (put-text-property (point-min) (point-max) 'article-treated-header t)
4104 (goto-char (point-max)))
4105 (while (and (not (eobp)) entity)
4106 (setq next (set-marker
4108 (next-single-property-change (point) 'mime-view-entity
4110 (let ((types (mime-entity-content-type entity)))
4111 (while (eq 'multipart (mime-content-type-primary-type types))
4112 (setq entity (car (mime-entity-children entity))
4113 types (mime-entity-content-type entity)))
4115 (setq type (format "%s/%s"
4116 (mime-content-type-primary-type types)
4117 (mime-content-type-subtype types)))))
4118 (if (string-equal type "message/rfc822")
4121 (let ((children (mime-entity-children entity))
4124 (setq last-children (nth (1- (length children)) children))
4127 (not (eq last-children
4128 (get-text-property next 'mime-view-entity)))
4130 (next-single-property-change next
4132 nil (point-max)))))))
4133 (setq next (next-single-property-change next 'mime-view-entity
4136 (narrow-to-region (point) next)
4137 (gnus-article-prepare-mime-display)
4138 (goto-char (point-max)))
4139 (setq entity (get-text-property (point) 'mime-view-entity)))
4141 (narrow-to-region (point) next)
4142 ;; Kludge. We have to count true number, but for now,
4143 ;; part number is here only to achieve `last'.
4144 (gnus-treat-article nil 1
4145 (if (eq entity last-entity)
4148 (goto-char (point-max)))
4149 (setq entity (get-text-property next 'mime-view-entity))))))
4152 (defun gnus-article-prepare-display ()
4153 "Make the current buffer look like a nice article."
4154 (let ((gnus-article-buffer (current-buffer))
4156 (unless (eq major-mode 'gnus-article-mode)
4157 (gnus-article-mode))
4158 (setq buffer-read-only nil
4159 gnus-button-marker-list nil
4160 gnus-article-wash-types nil
4161 gnus-article-image-alist nil)
4164 (static-if (featurep 'xemacs)
4165 (map-extents (lambda (extent maparg) (delete-extent extent)))
4166 (let ((lists (overlay-lists)))
4167 (dolist (overlay (nconc (car lists) (cdr lists)))
4168 (delete-overlay overlay)))))
4169 (gnus-run-hooks 'gnus-tmp-internal-hook))
4170 (let ((show-mime (unless (member gnus-newsgroup-name '("nndraft:delayed"
4173 (inhibit-read-only t))
4174 (set-buffer gnus-original-article-buffer)
4176 (setq mime-message-structure gnus-current-headers)
4177 (mime-buffer-entity-set-buffer-internal mime-message-structure
4178 gnus-original-article-buffer)
4179 (mime-entity-set-representation-type-internal mime-message-structure
4180 'mime-buffer-entity)
4181 (luna-send mime-message-structure 'initialize-instance
4182 mime-message-structure)
4184 (let (mime-display-header-hook mime-display-text/plain-hook)
4185 (funcall gnus-article-display-method-for-mime))
4186 (funcall gnus-article-display-method-for-traditional))
4187 ;; Call the treatment functions.
4191 (gnus-article-prepare-mime-display)
4192 (narrow-to-region (goto-char (point-min))
4193 (if (search-forward "\n\n" nil t)
4196 (gnus-treat-article 'head)
4197 (put-text-property (point-min) (point-max) 'article-treated-header t)
4198 (goto-char (point-max))
4200 (narrow-to-region (point) (point-max))
4201 (gnus-treat-article nil))
4202 (put-text-property (point-min) (point-max) 'read-only nil)))
4203 (gnus-run-hooks 'gnus-article-prepare-hook))
4205 (defun gnus-article-decode-article-as-default-mime-charset ()
4206 "Decode an article as `default-mime-charset'. It won't work if the
4207 value of the variable `gnus-show-mime' is non-nil."
4208 (unless (or gnus-show-mime
4209 (member gnus-newsgroup-name '("nndraft:delayed"
4211 (set (make-local-variable 'default-mime-charset)
4212 (with-current-buffer gnus-summary-buffer
4213 default-mime-charset))
4214 (decode-mime-charset-region (point-min) (point-max)
4215 default-mime-charset)))
4218 ;;; Gnus MIME viewing functions
4221 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4222 "Format of the MIME buttons.
4224 Valid specifiers include:
4226 %T MIME type, along with additional info
4227 %n The `name' parameter
4228 %d The description, if any
4229 %l The length of the encoded part
4230 %p The part identifier number
4231 %e Dots if the part isn't displayed
4233 General format specifiers can also be used. See Info node
4234 `(gnus)Formatting Variables'.")
4236 (defvar gnus-mime-button-line-format-alist
4237 '((?t gnus-tmp-type ?s)
4238 (?T gnus-tmp-type-long ?s)
4239 (?n gnus-tmp-name ?s)
4240 (?d gnus-tmp-description ?s)
4242 (?l gnus-tmp-length ?d)
4243 (?e gnus-tmp-dots ?s)))
4245 (defvar gnus-mime-button-commands
4246 '((gnus-article-press-button "\r" "Toggle Display")
4247 (gnus-mime-view-part "v" "View Interactively...")
4248 (gnus-mime-view-part-as-type "t" "View As Type...")
4249 (gnus-mime-view-part-as-charset "C" "View As charset...")
4250 (gnus-mime-save-part "o" "Save...")
4251 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4252 (gnus-mime-delete-part "d" "Delete part")
4253 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4254 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4255 (gnus-mime-view-part-internally "E" "View Internally")
4256 (gnus-mime-view-part-externally "e" "View Externally")
4257 (gnus-mime-print-part "p" "Print")
4258 (gnus-mime-pipe-part "|" "Pipe To Command...")
4259 (gnus-mime-action-on-part "." "Take action on the part...")))
4261 (defun gnus-article-mime-part-status ()
4262 (with-current-buffer gnus-article-buffer
4263 (let ((entity (get-text-property (point-min) 'mime-view-entity))
4266 (setq children (mime-entity-children entity))
4267 (setq children (length children)))
4270 (format " (%d parts)" children))
4273 (defvar gnus-mime-button-map
4274 (let ((map (make-sparse-keymap)))
4275 (unless (>= (string-to-number emacs-version) 21)
4276 ;; XEmacs doesn't care.
4277 (set-keymap-parent map gnus-article-mode-map))
4278 (define-key map gnus-mouse-2 'gnus-article-push-button)
4279 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4280 (dolist (c gnus-mime-button-commands)
4281 (define-key map (cadr c) (car c)))
4285 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4287 ,@(mapcar (lambda (c)
4288 (vector (caddr c) (car c) :enable t))
4289 gnus-mime-button-commands)))
4291 (defun gnus-mime-button-menu (event prefix)
4292 "Construct a context-sensitive menu of MIME commands."
4293 (interactive "e\nP")
4294 (save-window-excursion
4295 (let ((pos (event-start event)))
4296 (select-window (posn-window pos))
4297 (goto-char (posn-point pos))
4298 (gnus-article-check-buffer)
4299 (popup-menu gnus-mime-button-menu nil prefix))))
4301 (defun gnus-mime-view-all-parts (&optional handles)
4302 "View all the MIME parts."
4304 (save-current-buffer
4305 (set-buffer gnus-article-buffer)
4306 (let ((handles (or handles gnus-article-mime-handles))
4307 (mail-parse-charset gnus-newsgroup-charset)
4308 (mail-parse-ignored-charsets
4309 (with-current-buffer gnus-summary-buffer
4310 gnus-newsgroup-ignored-charsets)))
4312 (mm-remove-parts handles)
4313 (goto-char (point-min))
4314 (or (search-forward "\n\n") (goto-char (point-max)))
4315 (let (buffer-read-only)
4316 (delete-region (point) (point-max))
4317 (mm-display-parts handles))))))
4319 (defun gnus-mime-save-part-and-strip ()
4320 "Save the MIME part under point then replace it with an external body."
4322 (gnus-article-check-buffer)
4323 (let* ((data (get-text-property (point) 'gnus-data))
4325 (handles gnus-article-mime-handles))
4326 (if (mm-multiple-handles gnus-article-mime-handles)
4327 (error "This function is not implemented"))
4328 (setq file (and data (mm-save-part data)))
4330 (with-current-buffer (mm-handle-buffer data)
4332 (insert "Content-Type: " (mm-handle-media-type data))
4333 (mml-insert-parameter-string (cdr (mm-handle-type data))
4336 (insert "Content-ID: " (message-make-message-id) "\n")
4337 (insert "Content-Transfer-Encoding: binary\n")
4340 (cdr (mm-make-handle nil
4341 `("message/external-body"
4342 (access-type . "LOCAL-FILE")
4344 (set-buffer gnus-summary-buffer)
4345 (gnus-article-edit-article
4348 (let ((mail-parse-charset (or gnus-article-charset
4349 ',gnus-newsgroup-charset))
4350 (mail-parse-ignored-charsets
4351 (or gnus-article-ignored-charsets
4352 ',gnus-newsgroup-ignored-charsets))
4353 (mbl mml-buffer-list))
4354 (setq mml-buffer-list nil)
4355 (insert-buffer gnus-original-article-buffer)
4356 (mime-to-mml ',handles)
4357 (setq gnus-article-mime-handles nil)
4358 (let ((mbl1 mml-buffer-list))
4359 (setq mml-buffer-list mbl)
4360 (set (make-local-variable 'mml-buffer-list) mbl1))
4361 (gnus-make-local-hook 'kill-buffer-hook)
4362 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4363 `(lambda (no-highlight)
4364 (let ((mail-parse-charset (or gnus-article-charset
4365 ',gnus-newsgroup-charset))
4366 (message-options message-options)
4367 (message-options-set-recipient)
4368 (mail-parse-ignored-charsets
4369 (or gnus-article-ignored-charsets
4370 ',gnus-newsgroup-ignored-charsets)))
4372 (mml-destroy-buffers)
4373 (remove-hook 'kill-buffer-hook
4374 'mml-destroy-buffers t)
4375 (kill-local-variable 'mml-buffer-list))
4376 (gnus-summary-edit-article-done
4377 ,(or (mail-header-references gnus-current-headers) "")
4378 ,(gnus-group-read-only-p)
4379 ,gnus-summary-buffer no-highlight))))))
4381 (defun gnus-mime-delete-part ()
4382 "Delete the MIME part under point.
4383 Replace it with some information about the removed part."
4385 (gnus-article-check-buffer)
4386 (unless (and gnus-novice-user
4387 (not (gnus-yes-or-no-p
4388 "Really delete attachment forever? ")))
4389 (let* ((data (get-text-property (point) 'gnus-data))
4390 (handles gnus-article-mime-handles)
4394 (mail-decode-encoded-word-string (or (mm-handle-description data)
4397 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4399 (type (mm-handle-media-type data)))
4400 (if (mm-multiple-handles gnus-article-mime-handles)
4401 (error "This function is not implemented"))
4402 (with-current-buffer (mm-handle-buffer data)
4403 (let ((bsize (format "%s" (buffer-size))))
4408 "| The following attachment has been deleted:\n"
4410 "| Type: " type "\n"
4411 "| Filename: " filename "\n"
4412 "| Size (encoded): " bsize " Byte\n"
4413 "| Description: " description "\n"
4416 (cdr (mm-make-handle
4417 nil `("text/plain") nil nil
4419 (format "Deleted attachment (%s bytes)" bsize))))))
4420 (set-buffer gnus-summary-buffer)
4421 ;; FIXME: maybe some of the following code (borrowed from
4422 ;; `gnus-mime-save-part-and-strip') isn't necessary?
4423 (gnus-article-edit-article
4426 (let ((mail-parse-charset (or gnus-article-charset
4427 ',gnus-newsgroup-charset))
4428 (mail-parse-ignored-charsets
4429 (or gnus-article-ignored-charsets
4430 ',gnus-newsgroup-ignored-charsets))
4431 (mbl mml-buffer-list))
4432 (setq mml-buffer-list nil)
4433 (insert-buffer gnus-original-article-buffer)
4434 (mime-to-mml ',handles)
4435 (setq gnus-article-mime-handles nil)
4436 (let ((mbl1 mml-buffer-list))
4437 (setq mml-buffer-list mbl)
4438 (set (make-local-variable 'mml-buffer-list) mbl1))
4439 (gnus-make-local-hook 'kill-buffer-hook)
4440 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4441 `(lambda (no-highlight)
4442 (let ((mail-parse-charset (or gnus-article-charset
4443 ',gnus-newsgroup-charset))
4444 (message-options message-options)
4445 (message-options-set-recipient)
4446 (mail-parse-ignored-charsets
4447 (or gnus-article-ignored-charsets
4448 ',gnus-newsgroup-ignored-charsets)))
4450 (mml-destroy-buffers)
4451 (remove-hook 'kill-buffer-hook
4452 'mml-destroy-buffers t)
4453 (kill-local-variable 'mml-buffer-list))
4454 (gnus-summary-edit-article-done
4455 ,(or (mail-header-references gnus-current-headers) "")
4456 ,(gnus-group-read-only-p)
4457 ,gnus-summary-buffer no-highlight)))))
4458 ;; Not in `gnus-mime-save-part-and-strip':
4459 (gnus-article-edit-done)
4460 (gnus-summary-expand-window)
4461 (gnus-summary-show-article))
4463 (defun gnus-mime-save-part ()
4464 "Save the MIME part under point."
4466 (gnus-article-check-buffer)
4467 (let ((data (get-text-property (point) 'gnus-data)))
4469 (mm-save-part data))))
4471 (defun gnus-mime-pipe-part ()
4472 "Pipe the MIME part under point to a process."
4474 (gnus-article-check-buffer)
4475 (let ((data (get-text-property (point) 'gnus-data)))
4477 (mm-pipe-part data))))
4479 (defun gnus-mime-view-part ()
4480 "Interactively choose a viewing method for the MIME part under point."
4482 (gnus-article-check-buffer)
4483 (let ((data (get-text-property (point) 'gnus-data)))
4485 (setq gnus-article-mime-handles
4487 gnus-article-mime-handles (setq data (copy-sequence data))))
4488 (mm-interactively-view-part data))))
4490 (defun gnus-mime-view-part-as-type-internal ()
4491 (gnus-article-check-buffer)
4492 (let* ((name (mail-content-type-get
4493 (mm-handle-type (get-text-property (point) 'gnus-data))
4495 (def-type (and name (mm-default-file-encoding name))))
4496 (and def-type (cons def-type 0))))
4498 (defun gnus-mime-view-part-as-type (&optional mime-type)
4499 "Choose a MIME media type, and view the part as such."
4502 (setq mime-type (completing-read
4503 "View as MIME type: "
4504 (mapcar #'list (mailcap-mime-types))
4506 (gnus-mime-view-part-as-type-internal))))
4507 (gnus-article-check-buffer)
4508 (let ((handle (get-text-property (point) 'gnus-data)))
4511 (mm-make-handle (mm-handle-buffer handle)
4512 (cons mime-type (cdr (mm-handle-type handle)))
4513 (mm-handle-encoding handle)
4514 (mm-handle-undisplayer handle)
4515 (mm-handle-disposition handle)
4516 (mm-handle-description handle)
4518 (mm-handle-id handle)))
4519 (setq gnus-article-mime-handles
4520 (mm-merge-handles gnus-article-mime-handles handle))
4521 (gnus-mm-display-part handle))))
4524 (require 'jka-compr))
4526 ;; jka-compr.el uses a "sh -c" to direct stderr to err-file, but these days
4527 ;; emacs can do that itself.
4529 (defun gnus-mime-jka-compr-maybe-uncompress ()
4530 "Uncompress the current buffer if `auto-compression-mode' is enabled.
4531 The uncompress method used is derived from `buffer-file-name'."
4532 (when (and (fboundp 'jka-compr-installed-p)
4533 (jka-compr-installed-p))
4534 (let ((info (jka-compr-get-compression-info buffer-file-name)))
4536 (let ((basename (file-name-nondirectory buffer-file-name))
4537 (args (jka-compr-info-uncompress-args info))
4538 (prog (jka-compr-info-uncompress-program info))
4539 (message (jka-compr-info-uncompress-message info))
4540 (err-file (jka-compr-make-temp-name)))
4542 (message "%s %s..." message basename))
4544 (unless (memq (apply 'call-process-region
4545 (point-min) (point-max)
4547 t (list t err-file) nil
4549 jka-compr-acceptable-retval-list)
4550 (jka-compr-error prog args basename message err-file))
4551 (jka-compr-delete-temp-file err-file)))))))
4553 (defun gnus-mime-copy-part (&optional handle)
4554 "Put the MIME part under point into a new buffer.
4555 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4558 (gnus-article-check-buffer)
4559 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4560 (contents (and handle (mm-get-part handle)))
4562 (file-name-nondirectory
4564 (mail-content-type-get (mm-handle-type handle) 'name)
4565 (mail-content-type-get (mm-handle-disposition handle)
4568 (buffer (and base (generate-new-buffer base))))
4570 (switch-to-buffer buffer)
4572 ;; We do it this way to make `normal-mode' set the appropriate mode.
4575 (setq buffer-file-name (expand-file-name base))
4576 (gnus-mime-jka-compr-maybe-uncompress)
4578 (setq buffer-file-name nil))
4579 (goto-char (point-min)))))
4581 (defun gnus-mime-print-part (&optional handle filename)
4582 "Print the MIME part under point."
4583 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4584 (gnus-article-check-buffer)
4585 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4586 (contents (and handle (mm-get-part handle)))
4587 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4588 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4593 (mm-save-part-to-file handle file)
4594 (call-process shell-file-name nil
4595 (generate-new-buffer " *mm*")
4597 shell-command-switch
4599 printer file (mm-handle-type handle))))
4603 (gnus-print-buffer))
4604 (ps-despool filename)))))
4606 (defun gnus-mime-inline-part (&optional handle arg)
4607 "Insert the MIME part under point into the current buffer."
4608 (interactive (list nil current-prefix-arg))
4609 (gnus-article-check-buffer)
4610 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4615 (if (and (not arg) (mm-handle-undisplayer handle))
4616 (mm-remove-part handle)
4617 (setq contents (mm-get-part handle))
4620 (setq charset (or (mail-content-type-get
4621 (mm-handle-type handle) 'charset)
4622 gnus-newsgroup-charset)))
4624 (if (mm-handle-undisplayer handle)
4625 (mm-remove-part handle))
4628 gnus-summary-show-article-charset-alist))
4629 (mm-read-coding-system "Charset: ")))))
4631 (mm-insert-inline handle
4633 (setq charset (mm-charset-to-coding-system
4635 (not (eq charset 'ascii)))
4636 (mm-decode-coding-string contents charset)
4640 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4641 "Insert the MIME part under point into the current buffer using the
4643 (interactive (list nil current-prefix-arg))
4644 (gnus-article-check-buffer)
4645 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4650 (if (mm-handle-undisplayer handle)
4651 (mm-remove-part handle))
4652 (let ((gnus-newsgroup-charset
4654 gnus-summary-show-article-charset-alist))
4655 (mm-read-coding-system "Charset: ")))
4656 (gnus-newsgroup-ignored-charsets 'gnus-all))
4657 (gnus-article-press-button)))))
4659 (defun gnus-mime-view-part-externally (&optional handle)
4660 "View the MIME part under point with an external viewer."
4662 (gnus-article-check-buffer)
4663 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4664 (mm-user-display-methods nil)
4665 (mm-inlined-types nil)
4666 (mail-parse-charset gnus-newsgroup-charset)
4667 (mail-parse-ignored-charsets
4668 (save-excursion (set-buffer gnus-summary-buffer)
4669 gnus-newsgroup-ignored-charsets)))
4671 (if (mm-handle-undisplayer handle)
4672 (mm-remove-part handle)
4673 (mm-display-part handle)))))
4675 (defun gnus-mime-view-part-internally (&optional handle)
4676 "View the MIME part under point with an internal viewer.
4677 If no internal viewer is available, use an external viewer."
4679 (gnus-article-check-buffer)
4680 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4681 (mm-inlined-types '(".*"))
4682 (mm-inline-large-images t)
4683 (mail-parse-charset gnus-newsgroup-charset)
4684 (mail-parse-ignored-charsets
4685 (save-excursion (set-buffer gnus-summary-buffer)
4686 gnus-newsgroup-ignored-charsets))
4689 (if (mm-handle-undisplayer handle)
4690 (mm-remove-part handle)
4691 (mm-display-part handle)))))
4693 (defun gnus-mime-action-on-part (&optional action)
4694 "Do something with the MIME attachment at \(point\)."
4696 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4697 (gnus-article-check-buffer)
4698 (let ((action-pair (assoc action gnus-mime-action-alist)))
4700 (funcall (cdr action-pair)))))
4702 (defun gnus-article-part-wrapper (n function)
4703 (save-current-buffer
4704 (set-buffer gnus-article-buffer)
4705 (when (> n (length gnus-article-mime-handle-alist))
4706 (error "No such part"))
4707 (gnus-article-goto-part n)
4708 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4709 (funcall function handle))))
4711 (defun gnus-article-pipe-part (n)
4712 "Pipe MIME part N, which is the numerical prefix."
4714 (gnus-article-part-wrapper n 'mm-pipe-part))
4716 (defun gnus-article-save-part (n)
4717 "Save MIME part N, which is the numerical prefix."
4719 (gnus-article-part-wrapper n 'mm-save-part))
4721 (defun gnus-article-interactively-view-part (n)
4722 "View MIME part N interactively, which is the numerical prefix."
4724 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4726 (defun gnus-article-copy-part (n)
4727 "Copy MIME part N, which is the numerical prefix."
4729 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4731 (defun gnus-article-view-part-as-charset (n)
4732 "View MIME part N using a specified charset.
4733 N is the numerical prefix."
4735 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4737 (defun gnus-article-view-part-externally (n)
4738 "View MIME part N externally, which is the numerical prefix."
4740 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4742 (defun gnus-article-inline-part (n)
4743 "Inline MIME part N, which is the numerical prefix."
4745 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4747 (defun gnus-article-mime-match-handle-first (condition)
4749 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4750 (while (setq ihandle (pop alist))
4752 ((functionp condition)
4753 (funcall condition (cdr ihandle)))
4754 ((eq condition 'undisplayed)
4755 (not (or (mm-handle-undisplayer (cdr ihandle))
4756 (equal (mm-handle-media-type (cdr ihandle))
4757 "multipart/alternative"))))
4758 ((eq condition 'undisplayed-alternative)
4759 (not (mm-handle-undisplayer (cdr ihandle))))
4761 (gnus-article-goto-part (car ihandle))
4762 (or (not n) (< (car ihandle) n)))
4763 (setq n (car ihandle))))
4767 (defun gnus-article-view-part (&optional n)
4768 "View MIME part N, which is the numerical prefix."
4770 (save-current-buffer
4771 (set-buffer gnus-article-buffer)
4772 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4773 gnus-article-mime-match-handle-function)))
4774 (when (> n (length gnus-article-mime-handle-alist))
4775 (error "No such part"))
4776 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4777 (when (gnus-article-goto-part n)
4778 (if (equal (car handle) "multipart/alternative")
4779 (gnus-article-press-button)
4780 (when (eq (gnus-mm-display-part handle) 'internal)
4781 (gnus-set-window-start)))))))
4783 (defsubst gnus-article-mime-total-parts ()
4784 (if (bufferp (car gnus-article-mime-handles))
4786 (1- (length gnus-article-mime-handles))))
4788 (defun gnus-mm-display-part (handle)
4789 "Display HANDLE and fix MIME button."
4790 (let ((id (get-text-property (point) 'gnus-part))
4795 (let ((window (selected-window))
4796 (mail-parse-charset gnus-newsgroup-charset)
4797 (mail-parse-ignored-charsets
4798 (if (gnus-buffer-live-p gnus-summary-buffer)
4800 (set-buffer gnus-summary-buffer)
4801 gnus-newsgroup-ignored-charsets)
4805 (let ((win (gnus-get-buffer-window (current-buffer) t))
4808 (select-window win))
4811 (if (mm-handle-displayed-p handle)
4812 ;; This will remove the part.
4813 (mm-display-part handle)
4815 (narrow-to-region (point)
4816 (if (eobp) (point) (1+ (point))))
4817 (mm-display-part handle)
4818 ;; We narrow to the part itself and
4819 ;; then call the treatment functions.
4820 (goto-char (point-min))
4822 (narrow-to-region (point) (point-max))
4825 (gnus-article-mime-total-parts)
4826 (mm-handle-media-type handle)))))
4827 (if (window-live-p window)
4828 (select-window window)))))
4831 (gnus-insert-mime-button
4832 handle id (list (mm-handle-displayed-p handle)))
4833 (goto-char point))))
4835 (defun gnus-article-goto-part (n)
4836 "Go to MIME part N."
4837 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4839 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4840 (let ((gnus-tmp-name
4841 (or (mail-content-type-get (mm-handle-type handle) 'name)
4842 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4843 (mail-content-type-get (mm-handle-type handle) 'url)
4845 (gnus-tmp-type (mm-handle-media-type handle))
4846 (gnus-tmp-description
4847 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4850 (if (if displayed (car displayed)
4851 (mm-handle-displayed-p handle))
4853 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4855 gnus-tmp-type-long b e)
4856 (when (string-match ".*/" gnus-tmp-name)
4857 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4858 (setq gnus-tmp-type-long (concat gnus-tmp-type
4859 (and (not (equal gnus-tmp-name ""))
4860 (concat "; " gnus-tmp-name))))
4861 (unless (equal gnus-tmp-description "")
4862 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4867 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4868 `(keymap ,gnus-mime-button-map
4869 gnus-callback gnus-mm-display-part
4870 gnus-part ,gnus-tmp-id
4871 article-type annotation
4874 ;; Exclude a newline.
4877 (widget-convert-button
4880 :action 'gnus-widget-press-button
4881 :button-keymap gnus-mime-button-map
4883 (lambda (widget/window &optional overlay pos)
4884 ;; Needed to properly clear the message due to a bug in
4885 ;; wid-edit (XEmacs only).
4886 (if (boundp 'help-echo-owns-message)
4887 (setq help-echo-owns-message t))
4889 "%S: %s the MIME part; %S: more options"
4890 (aref gnus-mouse-2 0)
4891 ;; XEmacs will get a single widget arg; Emacs 21 will get
4892 ;; window, overlay, position.
4893 (if (mm-handle-displayed-p
4895 (with-current-buffer (gnus-overlay-buffer overlay)
4896 (widget-get (widget-at (gnus-overlay-start overlay))
4898 (widget-get widget/window :mime-handle)))
4900 (aref gnus-down-mouse-3 0))))))
4902 (defun gnus-widget-press-button (elems el)
4903 (goto-char (widget-get elems :from))
4904 (gnus-article-press-button))
4906 (defvar gnus-displaying-mime nil)
4908 (defun gnus-display-mime (&optional ihandles)
4909 "Display the MIME parts."
4911 (save-selected-window
4912 (let ((window (get-buffer-window gnus-article-buffer))
4915 (select-window window)
4916 ;; We have to do this since selecting the window
4917 ;; may change the point. So we set the window point.
4918 (set-window-point window point)))
4919 (let* ((handles (or ihandles
4920 (mm-dissect-buffer nil gnus-article-loose-mime)
4921 (and gnus-article-emulate-mime
4923 buffer-read-only handle name type b e display)
4924 (when (and (not ihandles)
4925 (not gnus-displaying-mime))
4926 ;; Top-level call; we clean up.
4927 (when gnus-article-mime-handles
4928 (mm-destroy-parts gnus-article-mime-handles)
4929 (setq gnus-article-mime-handle-alist nil));; A trick.
4930 (setq gnus-article-mime-handles handles)
4931 ;; We allow users to glean info from the handles.
4932 (when gnus-article-mime-part-function
4933 (gnus-mime-part-function handles)))
4935 (or (not (stringp (car handles)))
4938 (when (and (not ihandles)
4939 (not gnus-displaying-mime))
4940 ;; Clean up for mime parts.
4942 (delete-region (point) (point-max)))
4943 (let ((gnus-displaying-mime t))
4944 (gnus-mime-display-part handles)))
4947 (narrow-to-region (point) (point-max))
4948 (gnus-treat-article nil 1 1)
4951 ;; Highlight the headers.
4955 (narrow-to-region (point-min) (point))
4956 (gnus-treat-article 'head))))))))
4958 (defcustom gnus-mime-display-multipart-as-mixed nil
4959 "Display \"multipart\" parts as \"multipart/mixed\".
4961 If t, it overrides nil values of
4962 `gnus-mime-display-multipart-alternative-as-mixed' and
4963 `gnus-mime-display-multipart-related-as-mixed'."
4964 :group 'gnus-article-mime
4967 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
4968 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
4969 :group 'gnus-article-mime
4972 (defcustom gnus-mime-display-multipart-related-as-mixed nil
4973 "Display \"multipart/related\" parts as \"multipart/mixed\".
4975 If displaying \"text/html\" is discouraged \(see
4976 `mm-discouraged-alternatives'\) images or other material inside a
4977 \"multipart/related\" part might be overlooked when this variable is nil."
4978 :group 'gnus-article-mime
4981 (defun gnus-mime-display-part (handle)
4984 ((not (stringp (car handle)))
4985 (gnus-mime-display-single handle))
4986 ;; User-defined multipart
4987 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4988 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4990 ;; multipart/alternative
4991 ((and (equal (car handle) "multipart/alternative")
4992 (not (or gnus-mime-display-multipart-as-mixed
4993 gnus-mime-display-multipart-alternative-as-mixed)))
4994 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4995 (push (cons id handle) gnus-article-mime-handle-alist)
4996 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4997 ;; multipart/related
4998 ((and (equal (car handle) "multipart/related")
4999 (not (or gnus-mime-display-multipart-as-mixed
5000 gnus-mime-display-multipart-related-as-mixed)))
5001 ;;;!!!We should find the start part, but we just default
5002 ;;;!!!to the first part.
5003 ;;(gnus-mime-display-part (cadr handle))
5004 ;;;!!! Most multipart/related is an HTML message plus images.
5005 ;;;!!! Unfortunately we are unable to let W3 display those
5006 ;;;!!! included images, so we just display it as a mixed multipart.
5007 ;;(gnus-mime-display-mixed (cdr handle))
5008 ;;;!!! No, w3 can display everything just fine.
5009 (gnus-mime-display-part (cadr handle)))
5010 ((equal (car handle) "multipart/signed")
5011 (gnus-add-wash-type 'signed)
5012 (gnus-mime-display-security handle))
5013 ((equal (car handle) "multipart/encrypted")
5014 (gnus-add-wash-type 'encrypted)
5015 (gnus-mime-display-security handle))
5016 ;; Other multiparts are handled like multipart/mixed.
5018 (gnus-mime-display-mixed (cdr handle)))))
5020 (defun gnus-mime-part-function (handles)
5021 (if (stringp (car handles))
5022 (mapcar 'gnus-mime-part-function (cdr handles))
5023 (funcall gnus-article-mime-part-function handles)))
5025 (defun gnus-mime-display-mixed (handles)
5026 (mapcar 'gnus-mime-display-part handles))
5028 (defun gnus-mime-display-single (handle)
5029 (let ((type (mm-handle-media-type handle))
5030 (ignored gnus-ignored-mime-types)
5037 (when (string-match (pop ignored) type)
5038 (throw 'ignored nil)))
5039 (if (and (setq not-attachment
5040 (and (not (mm-inline-override-p handle))
5041 (or (not (mm-handle-disposition handle))
5042 (equal (car (mm-handle-disposition handle))
5044 (mm-attachment-override-p handle))))
5045 (mm-automatic-display-p handle)
5047 (mm-inlinable-p handle)
5048 (mm-inlined-p handle))
5049 (mm-automatic-external-display-p type)))
5051 (when (equal (mm-handle-media-supertype handle) "text")
5053 (let ((id (1+ (length gnus-article-mime-handle-alist)))
5055 (push (cons id handle) gnus-article-mime-handle-alist)
5056 (when (or (not display)
5057 (not (gnus-unbuttonized-mime-type-p type)))
5058 ;(gnus-article-insert-newline)
5059 (gnus-insert-mime-button
5060 handle id (list (or display (and not-attachment text))))
5061 (gnus-article-insert-newline)
5062 ;(gnus-article-insert-newline)
5063 ;; Remember modify the number of forward lines.
5071 (let ((mail-parse-charset gnus-newsgroup-charset)
5072 (mail-parse-ignored-charsets
5073 (save-excursion (condition-case ()
5074 (set-buffer gnus-summary-buffer)
5076 gnus-newsgroup-ignored-charsets)))
5077 (mm-display-part handle t))
5078 (goto-char (point-max)))
5079 ((and text not-attachment)
5083 (gnus-article-insert-newline)
5084 (mm-insert-inline handle (mm-get-part handle))
5085 (goto-char (point-max))))
5089 (narrow-to-region beg (point))
5092 (gnus-article-mime-total-parts)
5093 (mm-handle-media-type handle)))))))))
5095 (defun gnus-unbuttonized-mime-type-p (type)
5096 "Say whether TYPE is to be unbuttonized."
5097 (unless gnus-inhibit-mime-unbuttonizing
5099 (let ((types gnus-unbuttonized-mime-types))
5101 (when (string-match (pop types) type)
5102 (throw 'found t)))))
5104 (let ((types gnus-buttonized-mime-types))
5106 (when (string-match (pop types) type)
5107 (throw 'found t)))))))))
5109 (defun gnus-article-insert-newline ()
5110 "Insert a newline, but mark it as undeletable."
5111 (gnus-put-text-property
5112 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
5114 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
5115 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
5118 handle buffer-read-only from props begend not-pref)
5119 (save-window-excursion
5122 (narrow-to-region (car ibegend)
5125 (goto-char (car ibegend))
5128 (delete-region (point-min) (point-max))
5129 (mm-remove-parts handles))
5130 (setq begend (list (point-marker)))
5132 (unless (setq not-pref (cadr (member preferred ihandles)))
5133 (setq not-pref (car ihandles)))
5136 (not (gnus-unbuttonized-mime-type-p
5137 "multipart/alternative")))
5138 (gnus-add-text-properties
5141 (insert (format "%d. " id))
5145 (unless ,(not ibegend)
5146 (setq gnus-article-mime-handle-alist
5147 ',gnus-article-mime-handle-alist))
5148 (gnus-mime-display-alternative
5149 ',ihandles ',not-pref ',begend ,id))
5150 keymap ,gnus-mime-button-map
5151 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5152 face ,gnus-article-button-face
5155 (widget-convert-button 'link from (point)
5156 :action 'gnus-widget-press-button
5157 :button-keymap gnus-widget-button-keymap)
5159 (while (setq handle (pop handles))
5160 (gnus-add-text-properties
5163 (insert (format "(%c) %-18s"
5164 (if (equal handle preferred) ?* ? )
5165 (mm-handle-media-type handle)))
5169 (unless ,(not ibegend)
5170 (setq gnus-article-mime-handle-alist
5171 ',gnus-article-mime-handle-alist))
5172 (gnus-mime-display-alternative
5173 ',ihandles ',handle ',begend ,id))
5174 keymap ,gnus-mime-button-map
5175 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5176 face ,gnus-article-button-face
5179 (widget-convert-button 'link from (point)
5180 :action 'gnus-widget-press-button
5181 :button-keymap gnus-widget-button-keymap)
5185 (if (stringp (car preferred))
5186 (gnus-display-mime preferred)
5187 (let ((mail-parse-charset gnus-newsgroup-charset)
5188 (mail-parse-ignored-charsets
5189 (save-excursion (set-buffer gnus-summary-buffer)
5190 gnus-newsgroup-ignored-charsets)))
5191 (mm-display-part preferred)
5195 (narrow-to-region (car begend) (point-max))
5197 nil (length gnus-article-mime-handle-alist)
5198 (gnus-article-mime-total-parts)
5199 (mm-handle-media-type handle))))))
5200 (goto-char (point-max))
5201 (setcdr begend (point-marker)))))
5203 (goto-char point))))
5205 (defconst gnus-article-wash-status-strings
5206 (let ((alist '((cite "c" "Possible hidden citation text"
5207 " " "All citation text visible")
5208 (headers "h" "Hidden headers"
5209 " " "All headers visible.")
5210 (pgp "p" "Encrypted or signed message status hidden"
5211 " " "No hidden encryption nor digital signature status")
5212 (signature "s" "Signature has been hidden"
5213 " " "Signature is visible")
5214 (overstrike "o" "Overstrike (^H) characters applied"
5215 " " "No overstrike characters applied")
5216 (gnus-show-mime "m" "Mime processing is activated"
5217 " " "Mime processing is not activated")
5218 (emphasis "e" "/*_Emphasis_*/ characters applied"
5219 " " "No /*_emphasis_*/ characters applied")))
5221 (dolist (entry alist result)
5222 (let ((key (nth 0 entry))
5223 (on (copy-sequence (nth 1 entry)))
5224 (on-help (nth 2 entry))
5225 (off (copy-sequence (nth 3 entry)))
5226 (off-help (nth 4 entry)))
5227 (put-text-property 0 1 'help-echo on-help on)
5228 (put-text-property 0 1 'help-echo off-help off)
5229 (push (list key on off) result))))
5230 "Alist of strings describing wash status in the mode line.
5231 Each entry has the form (KEY ON OF), where the KEY is a symbol
5232 representing the particular washing function, ON is the string to use
5233 in the article mode line when the washing function is active, and OFF
5234 is the string to use when it is inactive.")
5236 (defun gnus-article-wash-status-entry (key value)
5237 (let ((entry (assoc key gnus-article-wash-status-strings)))
5238 (if value (nth 1 entry) (nth 2 entry))))
5240 (defun gnus-article-wash-status ()
5241 "Return a string which display status of article washing."
5243 (set-buffer gnus-article-buffer)
5244 (let ((cite (memq 'cite gnus-article-wash-types))
5245 (headers (memq 'headers gnus-article-wash-types))
5246 (boring (memq 'boring-headers gnus-article-wash-types))
5247 (pgp (memq 'pgp gnus-article-wash-types))
5248 (pem (memq 'pem gnus-article-wash-types))
5249 (signed (memq 'signed gnus-article-wash-types))
5250 (encrypted (memq 'encrypted gnus-article-wash-types))
5251 (signature (memq 'signature gnus-article-wash-types))
5252 (overstrike (memq 'overstrike gnus-article-wash-types))
5253 (emphasis (memq 'emphasis gnus-article-wash-types)))
5255 (gnus-article-wash-status-entry 'cite cite)
5256 (gnus-article-wash-status-entry 'headers (or headers boring))
5257 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5258 (gnus-article-wash-status-entry 'signature signature)
5259 (gnus-article-wash-status-entry 'overstrike overstrike)
5260 (gnus-article-wash-status-entry 'gnus-show-mime gnus-show-mime)
5261 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5263 (defun gnus-add-wash-type (type)
5264 "Add a washing of TYPE to the current status."
5265 (add-to-list 'gnus-article-wash-types type))
5267 (defun gnus-delete-wash-type (type)
5268 "Add a washing of TYPE to the current status."
5269 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5271 (defun gnus-add-image (category image)
5272 "Add IMAGE of CATEGORY to the list of displayed images."
5273 (let ((entry (assq category gnus-article-image-alist)))
5275 (setq entry (list category))
5276 (push entry gnus-article-image-alist))
5277 (nconc entry (list image))))
5279 (defun gnus-delete-images (category)
5280 "Delete all images in CATEGORY."
5281 (let ((entry (assq category gnus-article-image-alist)))
5282 (dolist (image (cdr entry))
5283 (gnus-remove-image image category))
5284 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5285 (gnus-delete-wash-type category)))
5287 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5289 (defun gnus-article-maybe-hide-headers ()
5290 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5291 Provided for backwards compatibility."
5292 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5293 (not (save-excursion (set-buffer gnus-summary-buffer)
5294 gnus-have-all-headers)))
5295 (not gnus-inhibit-hiding))
5296 (gnus-article-hide-headers)))
5300 (defun gnus-output-to-file (file-name)
5301 "Append the current article to a file named FILE-NAME."
5302 (let ((artbuf (current-buffer)))
5304 (insert-buffer-substring artbuf)
5305 ;; Append newline at end of the buffer as separator, and then
5307 (goto-char (point-max))
5309 (let ((file-name-coding-system nnmail-pathname-coding-system))
5310 (write-region-as-binary (point-min) (point-max) file-name 'append))
5313 (defun gnus-narrow-to-page (&optional arg)
5314 "Narrow the article buffer to a page.
5315 If given a numerical ARG, move forward ARG pages."
5317 (setq arg (if arg (prefix-numeric-value arg) 0))
5319 (set-buffer gnus-article-buffer)
5320 (goto-char (point-min))
5322 ;; Remove any old next/prev buttons.
5323 (when (gnus-visual-p 'page-marker)
5324 (let ((buffer-read-only nil))
5325 (gnus-remove-text-with-property 'gnus-prev)
5326 (gnus-remove-text-with-property 'gnus-next)))
5329 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5331 (re-search-forward page-delimiter nil 'move arg)))
5332 (goto-char (match-end 0))
5334 (goto-char (point-min))
5335 (setq gnus-page-broken
5336 (and (re-search-forward page-delimiter nil t) t))))
5337 (when gnus-page-broken
5340 (if (re-search-forward page-delimiter nil 'move)
5343 (when (and (gnus-visual-p 'page-marker)
5344 (not (= (point-min) 1)))
5346 (goto-char (point-min))
5347 (gnus-insert-prev-page-button)))
5348 (when (and (gnus-visual-p 'page-marker)
5349 (< (+ (point-max) 2) (buffer-size)))
5351 (goto-char (point-max))
5352 (gnus-insert-next-page-button))))))
5354 ;; Article mode commands
5356 (defun gnus-article-goto-next-page ()
5357 "Show the next page of the article."
5359 (when (gnus-article-next-page)
5360 (goto-char (point-min))
5361 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5364 (defun gnus-article-goto-prev-page ()
5365 "Show the previous page of the article."
5368 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5369 (gnus-article-prev-page nil)))
5371 ;; This is cleaner but currently breaks `gnus-pick-mode':
5373 ;; (defun gnus-article-goto-next-page ()
5374 ;; "Show the next page of the article."
5376 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5377 ;; (gnus-summary-next-page)))
5379 ;; (defun gnus-article-goto-prev-page ()
5380 ;; "Show the next page of the article."
5382 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5383 ;; (gnus-summary-prev-page)))
5385 (defun gnus-article-next-page (&optional lines)
5386 "Show the next page of the current article.
5387 If end of article, return non-nil. Otherwise return nil.
5388 Argument LINES specifies lines to be scrolled up."
5390 (move-to-window-line -1)
5393 (and (pos-visible-in-window-p) ;Not continuation line.
5394 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5395 ;; Nothing in this page.
5396 (if (or (not gnus-page-broken)
5400 (eobp)))) ;Real end-of-buffer?
5402 (when gnus-article-over-scroll
5403 (gnus-article-next-page-1 lines))
5405 (gnus-narrow-to-page 1) ;Go to next page.
5407 ;; More in this page.
5408 (gnus-article-next-page-1 lines)
5411 (defun gnus-article-next-page-1 (lines)
5412 (let ((scroll-in-place nil))
5416 ;; Long lines may cause an end-of-buffer error.
5417 (goto-char (point-max)))))
5418 (move-to-window-line 0))
5420 (defun gnus-article-prev-page (&optional lines)
5421 "Show previous page of current article.
5422 Argument LINES specifies lines to be scrolled down."
5424 (move-to-window-line 0)
5425 (if (and gnus-page-broken
5427 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5429 (gnus-narrow-to-page -1) ;Go to previous page.
5430 (goto-char (point-max))
5432 (let ((scroll-in-place nil))
5436 (beginning-of-buffer
5437 (goto-char (point-min))))
5438 (move-to-window-line 0)))))
5440 (defun gnus-article-only-boring-p ()
5441 "Decide whether there is only boring text remaining in the article.
5442 Something \"interesting\" is a word of at least two letters that does
5443 not have a face in `gnus-article-boring-faces'."
5444 (when (and gnus-article-skip-boring
5445 (boundp 'gnus-article-boring-faces)
5446 (symbol-value 'gnus-article-boring-faces))
5449 (while (re-search-forward "\\b\\w\\w" nil t)
5451 (when (not (gnus-intersection
5452 (gnus-faces-at (point))
5453 (symbol-value 'gnus-article-boring-faces)))
5454 (throw 'only-boring nil)))
5455 (throw 'only-boring t)))))
5457 (defun gnus-article-refer-article ()
5458 "Read article specified by message-id around point."
5461 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
5462 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
5463 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
5464 (let ((msg-id (concat "<" (match-string 0) ">")))
5465 (set-buffer gnus-summary-buffer)
5466 (gnus-summary-refer-article msg-id))
5467 (error "No references around point"))))
5469 (defun gnus-article-show-summary ()
5470 "Reconfigure windows to show summary buffer."
5472 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5473 (error "There is no summary buffer for this article buffer")
5474 (gnus-article-set-globals)
5475 (gnus-configure-windows 'article)
5476 (gnus-summary-goto-subject gnus-current-article)
5477 (gnus-summary-position-point)))
5479 (defun gnus-article-describe-briefly ()
5480 "Describe article mode commands briefly."
5482 (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")))
5484 (defun gnus-article-summary-command ()
5485 "Execute the last keystroke in the summary buffer."
5487 (let ((obuf (current-buffer))
5488 (owin (current-window-configuration))
5490 (switch-to-buffer gnus-article-current-summary 'norecord)
5491 (setq func (lookup-key (current-local-map) (this-command-keys)))
5492 (call-interactively func)
5494 (set-window-configuration owin)
5495 (set-window-point (get-buffer-window (current-buffer)) (point))))
5497 (defun gnus-article-summary-command-nosave ()
5498 "Execute the last keystroke in the summary buffer."
5501 (pop-to-buffer gnus-article-current-summary 'norecord)
5502 (setq func (lookup-key (current-local-map) (this-command-keys)))
5503 (call-interactively func)))
5505 (defun gnus-article-check-buffer ()
5506 "Beep if not in an article buffer."
5507 (unless (eq (get-buffer gnus-article-buffer) (current-buffer))
5508 (error "Command invoked outside of a Gnus article buffer")))
5510 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5511 "Read a summary buffer key sequence and execute it from the article buffer."
5513 (gnus-article-check-buffer)
5515 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5516 "Zc" "ZC" "ZE" "ZJ" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5517 "=" "^" "\M-^" "|"))
5523 '("n" "Gn" "p" "Gp"))
5526 (set-buffer gnus-article-current-summary)
5527 (let (gnus-pick-mode)
5528 (push (or key last-command-event) unread-command-events)
5529 (setq keys (static-if (featurep 'xemacs)
5530 (events-to-keys (read-key-sequence nil))
5531 (read-key-sequence nil)))))
5534 (if (or (member keys nosaves)
5535 (member keys nosave-but-article)
5536 (member keys nosave-in-article))
5538 (save-window-excursion
5539 (pop-to-buffer gnus-article-current-summary 'norecord)
5540 ;; We disable the pick minor mode commands.
5541 (let (gnus-pick-mode)
5542 (setq func (lookup-key (current-local-map) keys))))
5546 (unless (member keys nosave-in-article)
5547 (set-buffer gnus-article-current-summary))
5548 (call-interactively func)
5549 (setq new-sum-point (point)))
5550 (when (member keys nosave-but-article)
5551 (pop-to-buffer gnus-article-buffer 'norecord)))
5552 ;; These commands should restore window configuration.
5553 (let ((obuf (current-buffer))
5554 (owin (current-window-configuration))
5556 (summary gnus-article-current-summary)
5557 func in-buffer selected)
5558 (if not-restore-window
5559 (pop-to-buffer summary 'norecord)
5560 (switch-to-buffer summary 'norecord))
5561 (setq in-buffer (current-buffer))
5562 ;; We disable the pick minor mode commands.
5563 (if (and (setq func (let (gnus-pick-mode)
5564 (lookup-key (current-local-map) keys)))
5567 (call-interactively func)
5568 (setq new-sum-point (point))
5569 (when (eq in-buffer (current-buffer))
5570 (setq selected (gnus-summary-select-article))
5572 (unless not-restore-window
5573 (set-window-configuration owin))
5574 (when (eq selected 'old)
5576 (set-window-start (get-buffer-window (current-buffer))
5578 (set-window-point (get-buffer-window (current-buffer))
5580 (let ((win (get-buffer-window gnus-article-current-summary)))
5582 (set-window-point win new-sum-point)))) )
5583 (switch-to-buffer gnus-article-buffer)
5586 (defun gnus-article-describe-key (key)
5587 "Display documentation of the function invoked by KEY. KEY is a string."
5588 (interactive "kDescribe key: ")
5589 (gnus-article-check-buffer)
5590 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5592 (set-buffer gnus-article-current-summary)
5593 (let (gnus-pick-mode)
5594 (if (featurep 'xemacs)
5596 (push (elt key 0) unread-command-events)
5597 (setq key (events-to-keys
5598 (read-key-sequence "Describe key: "))))
5599 (setq unread-command-events
5601 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5603 (setq key (read-key-sequence "Describe key: "))))
5605 (describe-key key)))
5607 (defun gnus-article-describe-key-briefly (key &optional insert)
5608 "Display documentation of the function invoked by KEY. KEY is a string."
5609 (interactive "kDescribe key: \nP")
5610 (gnus-article-check-buffer)
5611 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5613 (set-buffer gnus-article-current-summary)
5614 (let (gnus-pick-mode)
5615 (if (featurep 'xemacs)
5617 (push (elt key 0) unread-command-events)
5618 (setq key (events-to-keys
5619 (read-key-sequence "Describe key: "))))
5620 (setq unread-command-events
5622 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5624 (setq key (read-key-sequence "Describe key: "))))
5625 (describe-key-briefly key insert))
5626 (describe-key-briefly key insert)))
5628 (defun gnus-article-reply-with-original (&optional wide)
5629 "Start composing a reply mail to the current message.
5630 The text in the region will be yanked. If the region isn't active,
5631 the entire article will be yanked."
5633 (let ((article (cdr gnus-article-current))
5635 (if (not (gnus-mark-active-p))
5636 (with-current-buffer gnus-summary-buffer
5637 (gnus-summary-reply (list (list article)) wide))
5638 (setq contents (buffer-substring (point) (mark t)))
5639 ;; Deactivate active regions.
5640 (when (and (boundp 'transient-mark-mode)
5641 transient-mark-mode)
5642 (setq mark-active nil))
5643 (with-current-buffer gnus-summary-buffer
5645 (list (list article contents)) wide)))))
5647 (defun gnus-article-followup-with-original ()
5648 "Compose a followup to the current article.
5649 The text in the region will be yanked. If the region isn't active,
5650 the entire article will be yanked."
5652 (let ((article (cdr gnus-article-current))
5654 (if (not (gnus-mark-active-p))
5655 (with-current-buffer gnus-summary-buffer
5656 (gnus-summary-followup (list (list article))))
5657 (setq contents (buffer-substring (point) (mark t)))
5658 ;; Deactivate active regions.
5659 (when (and (boundp 'transient-mark-mode)
5660 transient-mark-mode)
5661 (setq mark-active nil))
5662 (with-current-buffer gnus-summary-buffer
5663 (gnus-summary-followup
5664 (list (list article contents)))))))
5666 (defun gnus-article-hide (&optional arg force)
5667 "Hide all the gruft in the current article.
5668 This means that signatures, cited text and (some) headers will be
5670 If given a prefix, show the hidden text instead."
5671 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5672 (gnus-article-hide-headers arg)
5673 (gnus-article-hide-list-identifiers arg)
5674 (gnus-article-hide-citation-maybe arg force)
5675 (gnus-article-hide-signature arg))
5677 (defun gnus-article-maybe-highlight ()
5678 "Do some article highlighting if article highlighting is requested."
5679 (when (gnus-visual-p 'article-highlight 'highlight)
5680 (gnus-article-highlight-some)))
5682 (defun gnus-check-group-server ()
5683 ;; Make sure the connection to the server is alive.
5684 (unless (gnus-server-opened
5685 (gnus-find-method-for-group gnus-newsgroup-name))
5686 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5687 (gnus-request-group gnus-newsgroup-name t)))
5690 (autoload 'nneething-get-file-name "nneething"))
5692 (defun gnus-request-article-this-buffer (article group)
5693 "Get an article and insert it into this buffer."
5694 (let (do-update-line sparse-header)
5698 (gnus-kill-all-overlays)
5699 (setq group (or group gnus-newsgroup-name))
5701 ;; Using `gnus-request-article' directly will insert the article into
5702 ;; `nntp-server-buffer' - so we'll save some time by not having to
5703 ;; copy it from the server buffer into the article buffer.
5705 ;; We only request an article by message-id when we do not have the
5706 ;; headers for it, so we'll have to get those.
5707 (when (stringp article)
5708 (gnus-read-header article))
5710 ;; If the article number is negative, that means that this article
5711 ;; doesn't belong in this newsgroup (possibly), so we find its
5712 ;; message-id and request it by id instead of number.
5713 (when (and (numberp article)
5715 (get-buffer gnus-summary-buffer)
5716 (gnus-buffer-exists-p gnus-summary-buffer))
5718 (set-buffer gnus-summary-buffer)
5719 (let ((header (gnus-summary-article-header article)))
5722 ((memq article gnus-newsgroup-sparse)
5723 ;; This is a sparse gap article.
5724 (setq do-update-line article)
5725 (setq article (mail-header-id header))
5726 (setq sparse-header (gnus-read-header article))
5727 (setq gnus-newsgroup-sparse
5728 (delq article gnus-newsgroup-sparse)))
5730 ;; It's a real article.
5731 (setq article (mail-header-id header)))
5733 ;; It is an extracted pseudo-article.
5734 (setq article 'pseudo)
5735 (gnus-request-pseudo-article header))))
5737 (let ((method (gnus-find-method-for-group
5738 gnus-newsgroup-name)))
5739 (when (and (eq (car method) 'nneething)
5741 (let ((dir (nneething-get-file-name
5742 (mail-header-id header))))
5743 (when (and (stringp dir)
5744 (file-directory-p dir))
5745 (setq article 'nneething)
5746 (gnus-group-enter-directory dir))))))))
5749 ;; Refuse to select canceled articles.
5750 ((and (numberp article)
5752 (get-buffer gnus-summary-buffer)
5753 (gnus-buffer-exists-p gnus-summary-buffer)
5754 (eq (cdr (save-excursion
5755 (set-buffer gnus-summary-buffer)
5756 (assq article gnus-newsgroup-reads)))
5757 gnus-canceled-mark))
5759 ;; We first check `gnus-original-article-buffer'.
5760 ((and (get-buffer gnus-original-article-buffer)
5763 (set-buffer gnus-original-article-buffer)
5764 (and (equal (car gnus-original-article) group)
5765 (eq (cdr gnus-original-article) article))))
5766 (insert-buffer-substring gnus-original-article-buffer)
5768 ;; Check the backlog.
5769 ((and gnus-keep-backlog
5770 (gnus-backlog-request-article group article (current-buffer)))
5772 ;; Check asynchronous pre-fetch.
5773 ((gnus-async-request-fetched-article group article (current-buffer))
5774 (gnus-async-prefetch-next group article gnus-summary-buffer)
5775 (when (and (numberp article) gnus-keep-backlog)
5776 (gnus-backlog-enter-article group article (current-buffer)))
5779 ((and gnus-use-cache
5781 (gnus-cache-request-article article group))
5783 ;; Check the agent cache.
5784 ((gnus-agent-request-article article group)
5786 ;; Get the article and put into the article buffer.
5787 ((or (stringp article)
5789 (let ((gnus-override-method gnus-override-method)
5790 (methods (and (stringp article)
5791 gnus-refer-article-method))
5792 (backend (car (gnus-find-method-for-group
5793 gnus-newsgroup-name)))
5795 (buffer-read-only nil))
5796 (if (or (not (listp methods))
5797 (and (symbolp (car methods))
5798 (assq (car methods) nnoo-definition-alist)))
5799 (setq methods (list methods)))
5800 (when (and (null gnus-override-method)
5802 (setq gnus-override-method (pop methods)))
5804 (when (eq gnus-override-method 'current)
5805 (setq gnus-override-method
5806 (with-current-buffer gnus-summary-buffer
5807 gnus-current-select-method)))
5809 (gnus-kill-all-overlays)
5810 (let ((gnus-newsgroup-name group))
5811 (gnus-check-group-server))
5813 ((gnus-request-article article group (current-buffer))
5814 (when (numberp article)
5815 (gnus-async-prefetch-next group article
5816 gnus-summary-buffer)
5817 (when gnus-keep-backlog
5818 (gnus-backlog-enter-article
5819 group article (current-buffer))))
5820 (setq result 'article))
5822 (setq gnus-override-method (pop methods)))
5823 ((not (string-match "^400 "
5824 (nnheader-get-report backend)))
5825 ;; If we get 400 server disconnect, reconnect and
5826 ;; retry; otherwise, assume the article has expired.
5827 (setq result 'done))))
5828 (and (eq result 'article) 'article)))
5832 ;; Associate this article with the current summary buffer.
5833 (setq gnus-article-current-summary gnus-summary-buffer)
5835 ;; Take the article from the original article buffer
5836 ;; and place it in the buffer it's supposed to be in.
5837 (when (and (get-buffer gnus-article-buffer)
5838 (equal (buffer-name (current-buffer))
5839 (buffer-name (get-buffer gnus-article-buffer))))
5841 (if (get-buffer gnus-original-article-buffer)
5842 (set-buffer gnus-original-article-buffer)
5843 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5844 (buffer-disable-undo)
5845 (setq major-mode 'gnus-original-article-mode)
5846 (setq buffer-read-only t))
5847 (let (buffer-read-only)
5849 (insert-buffer-substring gnus-article-buffer))
5850 (setq gnus-original-article (cons group article)))
5853 (run-hooks 'gnus-article-decode-hook)
5854 ;; Mark article as decoded or not.
5855 (setq gnus-article-decoded-p gnus-article-decode-hook))
5857 ;; Update sparse articles.
5858 (when (and do-update-line
5859 (or (numberp article)
5861 (let ((buf (current-buffer)))
5862 (set-buffer gnus-summary-buffer)
5863 (gnus-summary-update-article do-update-line sparse-header)
5864 (gnus-summary-goto-subject do-update-line nil t)
5865 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5867 (set-buffer buf))))))
5873 (defcustom gnus-article-edit-mode-hook nil
5874 "Hook run in article edit mode buffers."
5875 :group 'gnus-article-various
5878 (defcustom gnus-article-edit-article-setup-function
5879 'gnus-article-mime-edit-article-setup
5880 "Function called to setup an editing article buffer."
5881 :group 'gnus-article-various
5884 (defvar gnus-article-edit-done-function nil)
5886 (defvar gnus-article-edit-mode-map nil)
5887 (defvar gnus-article-edit-mode nil)
5889 ;; Should we be using derived.el for this?
5890 (unless gnus-article-edit-mode-map
5891 (setq gnus-article-edit-mode-map (make-keymap))
5892 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5894 (gnus-define-keys gnus-article-edit-mode-map
5895 "\C-c?" describe-mode
5896 "\C-c\C-c" gnus-article-edit-done
5897 "\C-c\C-k" gnus-article-edit-exit
5898 "\C-c\C-f\C-t" message-goto-to
5899 "\C-c\C-f\C-o" message-goto-from
5900 "\C-c\C-f\C-b" message-goto-bcc
5901 ;;"\C-c\C-f\C-w" message-goto-fcc
5902 "\C-c\C-f\C-c" message-goto-cc
5903 "\C-c\C-f\C-s" message-goto-subject
5904 "\C-c\C-f\C-r" message-goto-reply-to
5905 "\C-c\C-f\C-n" message-goto-newsgroups
5906 "\C-c\C-f\C-d" message-goto-distribution
5907 "\C-c\C-f\C-f" message-goto-followup-to
5908 "\C-c\C-f\C-m" message-goto-mail-followup-to
5909 "\C-c\C-f\C-k" message-goto-keywords
5910 "\C-c\C-f\C-u" message-goto-summary
5911 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5912 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5913 "\C-c\C-b" message-goto-body
5914 "\C-c\C-i" message-goto-signature
5916 "\C-c\C-t" message-insert-to
5917 "\C-c\C-n" message-insert-newsgroups
5918 "\C-c\C-o" message-sort-headers
5919 "\C-c\C-e" message-elide-region
5920 "\C-c\C-v" message-delete-not-region
5921 "\C-c\C-z" message-kill-to-signature
5922 "\M-\r" message-newline-and-reformat
5923 "\C-c\C-a" mml-attach-file
5924 "\C-a" message-beginning-of-line
5926 "\M-;" comment-region)
5928 (gnus-define-keys (gnus-article-edit-wash-map
5929 "\C-c\C-w" gnus-article-edit-mode-map)
5930 "f" gnus-article-edit-full-stops))
5933 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5935 ["Fetch To" message-insert-to t]
5936 ["Fetch Newsgroups" message-insert-newsgroups t]
5938 ["To" message-goto-to t]
5939 ["From" message-goto-from t]
5940 ["Subject" message-goto-subject t]
5941 ["Cc" message-goto-cc t]
5942 ["Reply-To" message-goto-reply-to t]
5943 ["Summary" message-goto-summary t]
5944 ["Keywords" message-goto-keywords t]
5945 ["Newsgroups" message-goto-newsgroups t]
5946 ["Followup-To" message-goto-followup-to t]
5947 ["Mail-Followup-To" message-goto-mail-followup-to t]
5948 ["Distribution" message-goto-distribution t]
5949 ["Body" message-goto-body t]
5950 ["Signature" message-goto-signature t]))
5952 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
5953 "Major mode for editing articles.
5954 This is an extended text-mode.
5956 \\{gnus-article-edit-mode-map}"
5957 (make-local-variable 'gnus-article-edit-done-function)
5958 (make-local-variable 'gnus-prev-winconf)
5959 (set (make-local-variable 'font-lock-defaults)
5960 '(message-font-lock-keywords t))
5961 (set (make-local-variable 'mail-header-separator) "")
5962 (set (make-local-variable 'gnus-article-edit-mode) t)
5963 (easy-menu-add message-mode-field-menu message-mode-map)
5964 (setq buffer-read-only nil)
5965 (buffer-enable-undo)
5968 (defun gnus-article-edit (&optional force)
5969 "Edit the current article.
5970 This will have permanent effect only in mail groups.
5971 If FORCE is non-nil, allow editing of articles even in read-only
5974 (when (and (not force)
5975 (gnus-group-read-only-p))
5976 (error "The current newsgroup does not support article editing"))
5977 (gnus-article-date-original)
5978 (gnus-article-edit-article
5980 `(lambda (no-highlight)
5982 (gnus-summary-edit-article-done
5983 ,(or (mail-header-references gnus-current-headers) "")
5984 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5986 (defun gnus-article-edit-article (start-func exit-func)
5987 "Start editing the contents of the current article buffer."
5988 (let ((winconf (current-window-configuration)))
5989 (set-buffer gnus-article-buffer)
5990 (gnus-article-edit-mode)
5991 (funcall start-func)
5992 (set-buffer-modified-p nil)
5993 (gnus-configure-windows 'edit-article)
5994 (setq gnus-article-edit-done-function exit-func)
5995 (setq gnus-prev-winconf winconf)
5996 (when gnus-article-edit-article-setup-function
5997 (funcall gnus-article-edit-article-setup-function))
5998 (gnus-message 6 "C-c C-c to end edits; C-c C-k to exit")))
6000 (defun gnus-article-edit-done (&optional arg)
6001 "Update the article edits and exit."
6003 (let ((func gnus-article-edit-done-function)
6004 (buf (current-buffer))
6005 (start (window-start))
6007 (winconf gnus-prev-winconf))
6008 (remove-hook 'gnus-article-mode-hook
6009 'gnus-article-mime-edit-article-unwind)
6010 (widen) ;; Widen it in case that users narrowed the buffer.
6013 ;; The cache and backlog have to be flushed somewhat.
6014 (when gnus-keep-backlog
6015 (gnus-backlog-remove-article
6016 (car gnus-article-current) (cdr gnus-article-current)))
6017 ;; Flush original article as well.
6019 (when (get-buffer gnus-original-article-buffer)
6020 (set-buffer gnus-original-article-buffer)
6021 (setq gnus-original-article nil)))
6022 (when gnus-use-cache
6023 (gnus-cache-update-article
6024 (car gnus-article-current) (cdr gnus-article-current)))
6025 ;; We remove all text props from the article buffer.
6026 (kill-all-local-variables)
6027 (set-text-properties (point-min) (point-max) nil)
6029 (set-window-configuration winconf)
6031 (set-window-start (get-buffer-window buf) start)
6032 (set-window-point (get-buffer-window buf) (point)))
6033 (gnus-summary-show-article))
6035 (defun gnus-article-edit-exit ()
6036 "Exit the article editing without updating."
6038 (when (or (not (buffer-modified-p))
6039 (yes-or-no-p "Article modified; kill anyway? "))
6040 (let ((curbuf (current-buffer))
6042 (window-start (window-start)))
6044 (if (gnus-buffer-live-p gnus-original-article-buffer)
6045 (insert-buffer-substring gnus-original-article-buffer))
6046 (let ((winconf gnus-prev-winconf))
6047 (kill-all-local-variables)
6049 (set-window-configuration winconf)
6050 ;; Tippy-toe some to make sure that point remains where it was.
6051 (save-current-buffer
6053 (set-window-start (get-buffer-window (current-buffer)) window-start)
6055 (gnus-summary-show-article)))
6057 (defun gnus-article-edit-full-stops ()
6058 "Interactively repair spacing at end of sentences."
6061 (goto-char (point-min))
6062 (search-forward-regexp "^$" nil t)
6063 (let ((case-fold-search nil))
6064 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
6067 ;;; Article editing with MIME-Edit
6070 (defcustom gnus-article-mime-edit-article-setup-hook nil
6071 "Hook run after setting up a MIME editing article buffer."
6072 :group 'gnus-article-various
6075 (defun gnus-article-mime-edit-article-unwind ()
6076 "Unwind `gnus-article-buffer' if article editing was given up."
6077 (remove-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6078 (when (featurep 'font-lock)
6079 (setq font-lock-defaults nil)
6080 (font-lock-mode -1))
6081 (when mime-edit-mode-flag
6082 (mime-edit-exit 'nomime 'no-error)
6085 (defun gnus-article-mime-edit-article-setup ()
6086 "Convert current buffer to MIME-Edit buffer and turn on MIME-Edit mode
6087 after replacing with the original article."
6088 (setq gnus-show-mime t)
6089 (setq gnus-article-edit-done-function
6090 `(lambda (&rest args)
6091 (when mime-edit-mode-flag
6092 (let (mime-edit-insert-user-agent-field)
6095 (goto-char (point-min))
6096 (let (case-fold-search)
6097 (when (re-search-forward
6098 (format "^%s$" (regexp-quote mail-header-separator))
6100 (replace-match "")))
6101 (apply ,gnus-article-edit-done-function args)
6104 (buffer-substring-no-properties (point-min) (point-max))
6105 (set-buffer (get-buffer-create gnus-original-article-buffer))
6107 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6108 (set-buffer gnus-article-buffer)
6109 (gnus-article-prepare-display)))
6110 (substitute-key-definition 'gnus-article-edit-done
6111 'gnus-article-mime-edit-done
6112 gnus-article-edit-mode-map)
6113 (substitute-key-definition 'gnus-article-edit-exit
6114 'gnus-article-mime-edit-exit
6115 gnus-article-edit-mode-map)
6117 (insert-buffer-substring gnus-original-article-buffer)
6118 (unless (member (with-current-buffer gnus-summary-buffer
6119 gnus-newsgroup-name)
6120 '("nndraft:delayed" "nndraft:drafts"))
6121 (let ((ofn (symbol-function 'mime-edit-decode-single-part-in-buffer)))
6122 (fset 'mime-edit-decode-single-part-in-buffer
6123 (lambda (&rest args)
6124 (if (let ((content-type (car args)))
6125 (and (eq 'message (mime-content-type-primary-type
6127 (eq 'rfc822 (mime-content-type-subtype
6129 (setcar (cdr args) 'not-decode-text))
6133 (fset 'mime-edit-decode-single-part-in-buffer ofn))))
6134 (when (featurep 'font-lock)
6135 (set (make-local-variable 'font-lock-defaults)
6136 '(message-font-lock-keywords t))
6137 (font-lock-set-defaults)
6138 (turn-on-font-lock))
6139 (set-buffer-modified-p nil)
6140 (delete-other-windows)
6141 (add-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6142 (gnus-run-hooks 'gnus-article-mime-edit-article-setup-hook))
6144 (defun gnus-article-mime-edit-done (&optional arg)
6145 "Update the article MIME edits and exit."
6147 (when (featurep 'font-lock)
6148 (setq font-lock-defaults nil)
6149 (font-lock-mode -1))
6150 (let ((inhibit-read-only t))
6151 (gnus-article-edit-done arg)))
6153 (defun gnus-article-mime-edit-exit ()
6154 "Exit the article MIME editing without updating."
6156 (when (or (not (buffer-modified-p))
6157 (yes-or-no-p "Article modified; kill anyway? "))
6158 (when (featurep 'font-lock)
6159 (setq font-lock-defaults nil)
6160 (font-lock-mode -1))
6161 (when mime-edit-mode-flag
6162 (let (mime-edit-insert-user-agent-field)
6165 (goto-char (point-min))
6166 (let (case-fold-search)
6167 (when (re-search-forward
6168 (format "^%s$" (regexp-quote mail-header-separator)) nil t)
6169 (replace-match "")))
6170 (let ((winconf gnus-prev-winconf))
6172 (buffer-substring-no-properties (point-min) (point-max))
6173 (set-buffer (get-buffer-create gnus-original-article-buffer))
6175 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6176 (set-buffer gnus-article-buffer)
6177 (gnus-article-prepare-display)
6178 (set-window-configuration winconf))))
6181 ;;; Article highlights
6184 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
6186 ;;; Internal Variables:
6188 (defcustom gnus-button-url-regexp
6189 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
6190 "\\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:]]\\)"
6191 "\\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\\)\\)")
6192 "Regular expression that matches URLs."
6193 :group 'gnus-article-buttons
6196 (defcustom gnus-button-valid-fqdn-regexp
6197 message-valid-fqdn-regexp
6198 "Regular expression that matches a valid FQDN."
6199 :group 'gnus-article-buttons
6202 (defcustom gnus-button-man-handler 'manual-entry
6203 "Function to use for displaying man pages.
6204 The function must take at least one argument with a string naming the
6206 :type '(choice (function-item :tag "Man" manual-entry)
6207 (function-item :tag "Woman" woman)
6208 (function :tag "Other"))
6209 :group 'gnus-article-buttons)
6211 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
6212 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
6213 If the default site is too slow, try to find a CTAN mirror, see
6214 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
6215 the variable `gnus-button-handle-ctan'."
6216 :group 'gnus-article-buttons
6217 :link '(custom-manual "(gnus)Group Parameters")
6218 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
6219 (const "http://tug.ctan.org/tex-archive/")
6220 (const "http://www.dante.de/CTAN/")
6221 (string :tag "Other")))
6223 (defcustom gnus-button-ctan-handler 'browse-url
6224 "Function to use for displaying CTAN links.
6225 The function must take one argument, the string naming the URL."
6226 :type '(choice (function-item :tag "Browse Url" browse-url)
6227 (function :tag "Other"))
6228 :group 'gnus-article-buttons)
6230 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
6231 "Bogus strings removed from CTAN URLs."
6232 :group 'gnus-article-buttons
6233 :type '(choice (const "^/?tex-archive/\\|/")
6234 (regexp :tag "Other")))
6236 (defcustom gnus-button-ctan-directory-regexp
6238 "\\("; Cannot use `\(?: ... \)' (compatibility with Emacs 20).
6239 "biblio\\|digests\\|dviware\\|fonts\\|graphics\\|help\\|"
6240 "indexing\\|info\\|language\\|macros\\|support\\|systems\\|"
6241 "tds\\|tools\\|usergrps\\|web\\|nonfree\\|obsolete"
6243 "Regular expression for ctan directories.
6244 It should match all directories in the top level of `gnus-ctan-url'."
6245 :group 'gnus-article-buttons
6248 (defcustom gnus-button-mid-or-mail-regexp
6249 (concat "\\b\\(<?[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t ]*@"
6250 ;; Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
6251 gnus-button-valid-fqdn-regexp
6253 "Regular expression that matches a message ID or a mail address."
6254 :group 'gnus-article-buttons
6257 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
6258 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
6259 Strings like this can be either a message ID or a mail address. If it is one
6260 of the symbols `mid' or `mail', Gnus will always assume that the string is a
6261 message ID or a mail address, respectively. If this variable is set to the
6262 symbol `ask', always query the user what do do. If it is a function, this
6263 function will be called with the string as it's only argument. The function
6264 must return `mid', `mail', `invalid' or `ask'."
6265 :group 'gnus-article-buttons
6266 :type '(choice (function-item :tag "Heuristic function"
6267 gnus-button-mid-or-mail-heuristic)
6272 (defcustom gnus-button-mid-or-mail-heuristic-alist
6273 '((-10.0 . ".+\\$.+@")
6276 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
6277 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
6278 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
6279 (-1.0 . "^[^a-z]+@")
6281 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
6282 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
6283 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
6284 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
6287 (-1.0 . "^[0-9][0-9]")
6289 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
6290 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6291 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
6292 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6294 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
6295 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
6298 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
6300 ;; compensation for TDMA dated mail addresses:
6301 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
6303 (-20.0 . "\\.fsf@") ;; Gnus
6306 (-20.0 . "_-_") ;; Subject change in thread
6308 (-20.0 . "\\.ln@") ;; leafnode
6309 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
6310 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
6312 ;; (5.0 . "") ;; $local_part_len <= 7
6313 (10.0 . "^[^0-9]+@")
6314 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
6315 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
6318 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
6320 (0.5 . "^[A-Z][a-z]")
6321 (0.5 . "^[A-Z][a-z][a-z]")
6322 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
6323 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
6324 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
6326 A negative RATE indicates a message IDs, whereas a positive indicates a mail
6327 address. The REGEXP is processed with `case-fold-search' set to nil."
6328 :group 'gnus-article-buttons
6329 :type '(repeat (cons (number :tag "Rate")
6330 (regexp :tag "Regexp"))))
6332 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
6333 "Guess whether MID-OR-MAIL is a message ID or a mail address.
6334 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
6335 address, `ask' if unsure and `invalid' if the string is invalid."
6336 (let ((case-fold-search nil)
6337 (list gnus-button-mid-or-mail-heuristic-alist)
6338 (result 0) rate regexp lpartlen elem)
6340 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
6341 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
6342 ;; Certain special cases...
6345 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
6346 "^[0-9]+\\.[0-9]+@compuserve\\|"
6347 "@public\\.gmane\\.org")
6349 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
6350 (setq result 'mail))
6351 (when (string-match "@.*@\\| " mid-or-mail)
6352 (gnus-message 8 "`%s' is invalid." mid-or-mail)
6353 (setq result 'invalid))
6354 ;; Nothing more to do, if result is not a number here...
6355 (when (numberp result)
6357 (setq elem (car list)
6361 (when (string-match regexp mid-or-mail)
6362 (setq result (+ result rate))
6364 9 "`%s' matched `%s', rate `%s', result `%s'."
6365 mid-or-mail regexp rate result)))
6366 (when (<= lpartlen 7)
6367 (setq result (+ result 5.0))
6368 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
6369 mid-or-mail result))
6370 (when (>= lpartlen 12)
6371 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
6373 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
6374 ;; Long local part should contain realname if e-mail address,
6375 ;; too many digits: message-id.
6376 ;; $score -= 5.0 + 0.1 * $local_part_len;
6377 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6378 (setq result (+ result rate))
6380 9 "Many digits in `%s', rate `%s', result `%s'."
6381 mid-or-mail rate result))
6382 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6384 ;; Too few vowels [^aeiouy]{4,}.*\@
6385 (setq result (+ result -5.0))
6387 9 "Few vowels in `%s', rate `%s', result `%s'."
6388 mid-or-mail -5.0 result))
6390 (setq result (+ result 5.0))
6392 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6393 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6394 ;; Maybe we should make this a customizable alist: (condition . 'result)
6396 ((symbolp result) result)
6397 ;; Now convert number into proper results:
6398 ((< result -10.0) 'mid)
6399 ((> result 10.0) 'mail)
6402 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6403 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6404 (url-mid (concat "news" ":" mid-or-mail))
6405 (url-mailto (concat "mailto" ":" mid-or-mail)))
6406 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6407 (when (fboundp pref)
6409 ;; get rid of surrounding angles...
6411 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6412 (if (or (eq 'mid guessed) (eq 'mail guessed))
6416 (save-window-excursion
6417 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6420 (cond ((eq pref 'mid)
6421 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6422 (gnus-button-handle-news url-mid))
6424 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6425 (gnus-url-mailto url-mailto))
6426 (t (gnus-message 3 "Invalid string.")))))
6428 (defun gnus-button-handle-custom (url)
6429 "Follow a Custom URL."
6430 (customize-apropos (gnus-url-unhex-string url)))
6432 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6434 ;; FIXME: Maybe we should merge some of the functions that do quite similar
6437 (defun gnus-button-handle-describe-function (url)
6438 "Call `describe-function' when pushing the corresponding URL button."
6441 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6443 (defun gnus-button-handle-describe-variable (url)
6444 "Call `describe-variable' when pushing the corresponding URL button."
6447 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6449 (defun gnus-button-handle-symbol (url)
6450 "Display help on variable or function.
6451 Calls `describe-variable' or `describe-function'."
6452 (let ((sym (intern url)))
6454 ((fboundp sym) (describe-function sym))
6455 ((boundp sym) (describe-variable sym))
6456 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
6458 (defun gnus-button-handle-describe-key (url)
6459 "Call `describe-key' when pushing the corresponding URL button."
6461 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6462 (keys (ignore-errors (eval `(kbd ,key-string)))))
6465 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6467 (defun gnus-button-handle-apropos (url)
6468 "Call `apropos' when pushing the corresponding URL button."
6469 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6471 (defun gnus-button-handle-apropos-command (url)
6472 "Call `apropos' when pushing the corresponding URL button."
6474 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6476 (defun gnus-button-handle-apropos-variable (url)
6477 "Call `apropos' when pushing the corresponding URL button."
6479 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6480 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6482 (defun gnus-button-handle-apropos-documentation (url)
6483 "Call `apropos' when pushing the corresponding URL button."
6485 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6486 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6488 (defun gnus-button-handle-library (url)
6489 "Call `locate-library' when pushing the corresponding URL button."
6490 (gnus-message 9 "url=`%s'" url)
6491 (let* ((lib (locate-library url))
6492 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6494 (gnus-message 1 "Cannot locale library `%s'." url)
6495 (find-file-read-only file))))
6497 (defun gnus-button-handle-ctan (url)
6498 "Call `browse-url' when pushing a CTAN URL button."
6500 gnus-button-ctan-handler
6503 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6505 (defcustom gnus-button-tex-level 5
6506 "*Integer that says how many TeX-related buttons Gnus will show.
6507 The higher the number, the more buttons will appear and the more false
6508 positives are possible. Note that you can set this variable local to
6509 specific groups. Setting it higher in TeX groups is probably a good idea.
6510 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6511 how to set variables in specific groups."
6512 :group 'gnus-article-buttons
6513 :link '(custom-manual "(gnus)Group Parameters")
6516 (defcustom gnus-button-man-level 5
6517 "*Integer that says how many man-related buttons Gnus will show.
6518 The higher the number, the more buttons will appear and the more false
6519 positives are possible. Note that you can set this variable local to
6520 specific groups. Setting it higher in Unix groups is probably a good idea.
6521 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6522 how to set variables in specific groups."
6523 :group 'gnus-article-buttons
6524 :link '(custom-manual "(gnus)Group Parameters")
6527 (defcustom gnus-button-emacs-level 5
6528 "*Integer that says how many emacs-related buttons Gnus will show.
6529 The higher the number, the more buttons will appear and the more false
6530 positives are possible. Note that you can set this variable local to
6531 specific groups. Setting it higher in Emacs or Gnus related groups is
6532 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6533 `gnus-parameters' on how to set variables in specific groups."
6534 :group 'gnus-article-buttons
6535 :link '(custom-manual "(gnus)Group Parameters")
6538 (defcustom gnus-button-message-level 5
6539 "*Integer that says how many buttons for news or mail messages will appear.
6540 The higher the number, the more buttons will appear and the more false
6541 positives are possible."
6542 ;; mail addresses, MIDs, URLs for news, ...
6543 :group 'gnus-article-buttons
6546 (defcustom gnus-button-browse-level 5
6547 "*Integer that says how many buttons for browsing will appear.
6548 The higher the number, the more buttons will appear and the more false
6549 positives are possible."
6550 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6551 :group 'gnus-article-buttons
6554 (defcustom gnus-button-alist
6555 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6556 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6557 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
6558 gnus-button-handle-news 2)
6559 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6560 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6561 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6562 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6563 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
6564 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
6565 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
6566 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6567 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6568 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6569 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6570 ;; RFC 2368 (The mailto URL scheme)
6571 ("mailto:\\([-a-z.@_+0-9%=?&]+\\)"
6572 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6573 ("\\bmailto:\\([^ \n\t]+\\)"
6574 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6576 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6577 gnus-button-ctan-directory-regexp
6578 "[^][>)!;:,'\n\t ]+\\)")
6579 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6580 ((concat "\\btex-archive/\\("
6581 gnus-button-ctan-directory-regexp
6582 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6583 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6586 gnus-button-ctan-directory-regexp
6587 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6588 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6589 ;; This is info (home-grown style) <info://foo/bar+baz>
6590 ("\\binfo://\\([^'\">\n\t ]+\\)"
6591 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6592 ;; Info GNOME style <info:foo#bar_baz>
6593 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6594 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6595 ;; Info KDE style <info:(foo)bar baz>
6596 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6597 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6598 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6599 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6600 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6601 ;; Info links like `C-h i d m CC Mode RET'
6602 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6604 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6605 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6606 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6607 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6608 ;; Emacs help commands
6609 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6610 ;; regexp doesn't match arguments containing ` '.
6611 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6612 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6613 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6614 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6615 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6616 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6617 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6618 ;; The following entries may lead to many false positives so don't enable
6619 ;; them by default (use a high button level):
6620 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>"
6621 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6622 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6623 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6624 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6625 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6626 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6627 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6628 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6629 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6630 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6631 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
6632 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6633 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6634 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6635 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6636 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6637 ;; Unlike the other regexps we really have to require quoting
6638 ;; here to determine where it ends.
6639 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6640 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
6641 ("<URL: *\\([^<>]*\\)>"
6642 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6643 ;; RFC 2396 (2.4.3., delims) ...
6644 ("\"URL: *\\([^\"]*\\)\""
6645 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6646 ;; RFC 2396 (2.4.3., delims) ...
6647 ("\"URL: *\\([^\"]*\\)\""
6648 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6650 (gnus-button-url-regexp
6651 0 (>= gnus-button-browse-level 0) browse-url 0)
6653 ("\\b\\([a-z][a-z]+\\)([1-9])\\W"
6654 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6655 gnus-button-handle-man 1)
6656 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6657 ("\\b\\([a-z][-_.a-z0-9]+\\)([1-9])\\W"
6658 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6659 gnus-button-handle-man 1)
6660 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6661 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6662 ("\\b\\([a-z][-+_.:a-z0-9]+\\)([1-9][X1a-z]*)\\W\\|\\b\\(X\\)([1-9])\\W"
6663 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6664 ;; MID or mail: To avoid too many false positives we don't try to catch
6665 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6666 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6667 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6668 ;; so that non-ambiguous entries (see above) match first.
6669 (gnus-button-mid-or-mail-regexp
6670 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6671 "*Alist of regexps matching buttons in article bodies.
6673 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6674 REGEXP: is the string (case insensitive) matching text around the button (can
6675 also be Lisp expression evaluating to a string),
6676 BUTTON: is the number of the regexp grouping actually matching the button,
6677 FORM: is a Lisp expression which must eval to true for the button to
6679 CALLBACK: is the function to call when the user push this button, and each
6680 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6682 CALLBACK can also be a variable, in that case the value of that
6683 variable it the real callback function."
6684 :group 'gnus-article-buttons
6685 :type '(repeat (list (choice regexp variable sexp)
6686 (integer :tag "Button")
6688 (function :tag "Callback")
6691 (integer :tag "Regexp group")))))
6693 (defcustom gnus-header-button-alist
6694 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
6695 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6696 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6697 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6698 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6699 0 (>= gnus-button-message-level 0) gnus-button-mailto 0)
6700 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6701 0 (>= gnus-button-browse-level 0) browse-url 0)
6702 ("^Subject:" gnus-button-url-regexp
6703 0 (>= gnus-button-browse-level 0) browse-url 0)
6704 ("^[^:]+:" gnus-button-url-regexp
6705 0 (>= gnus-button-browse-level 0) browse-url 0)
6706 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&]+\\)"
6707 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6708 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6709 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6710 "*Alist of headers and regexps to match buttons in article heads.
6712 This alist is very similar to `gnus-button-alist', except that each
6713 alist has an additional HEADER element first in each entry:
6715 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6717 HEADER is a regexp to match a header. For a fuller explanation, see
6718 `gnus-button-alist'."
6719 :group 'gnus-article-buttons
6720 :group 'gnus-article-headers
6721 :type '(repeat (list (regexp :tag "Header")
6722 (choice regexp variable)
6723 (integer :tag "Button")
6725 (function :tag "Callback")
6728 (integer :tag "Regexp group")))))
6730 (defvar gnus-button-regexp nil)
6731 (defvar gnus-button-marker-list nil)
6732 ;; Regexp matching any of the regexps from `gnus-button-alist'.
6734 (defvar gnus-button-last nil)
6735 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
6739 (defun gnus-article-push-button (event)
6740 "Check text under the mouse pointer for a callback function.
6741 If the text under the mouse pointer has a `gnus-callback' property,
6742 call it with the value of the `gnus-data' text property."
6744 (set-buffer (window-buffer (posn-window (event-start event))))
6745 (let* ((pos (posn-point (event-start event)))
6746 (data (get-text-property pos 'gnus-data))
6747 (fun (get-text-property pos 'gnus-callback)))
6750 (funcall fun data))))
6752 (defun gnus-article-press-button ()
6753 "Check text at point for a callback function.
6754 If the text at point has a `gnus-callback' property,
6755 call it with the value of the `gnus-data' text property."
6757 (let ((data (get-text-property (point) 'gnus-data))
6758 (fun (get-text-property (point) 'gnus-callback)))
6760 (funcall fun data))))
6762 (defun gnus-article-prev-button (n)
6763 "Move point to N buttons backward.
6764 If N is negative, move forward instead."
6766 (gnus-article-next-button (- n)))
6768 (defun gnus-article-next-button (n)
6769 "Move point to N buttons forward.
6770 If N is negative, move backward instead."
6772 (let ((function (if (< n 0) 'previous-single-property-change
6773 'next-single-property-change))
6774 (inhibit-point-motion-hooks t)
6776 (limit (if (< n 0) (point-min) (point-max))))
6778 (while (and (not (= limit (point)))
6780 ;; Skip past the current button.
6781 (when (get-text-property (point) 'gnus-callback)
6782 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6783 ;; Go to the next (or previous) button.
6784 (gnus-goto-char (funcall function (point) 'gnus-callback nil limit))
6785 ;; Put point at the start of the button.
6786 (when (and backward (not (get-text-property (point) 'gnus-callback)))
6787 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6788 ;; Skip past intangible buttons.
6789 (when (get-text-property (point) 'intangible)
6793 (gnus-message 5 "No more buttons"))
6796 (defun gnus-article-highlight (&optional force)
6797 "Highlight current article.
6798 This function calls `gnus-article-highlight-headers',
6799 `gnus-article-highlight-citation',
6800 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6801 do the highlighting. See the documentation for those functions."
6802 (interactive (list 'force))
6803 (gnus-article-highlight-headers)
6804 (gnus-article-highlight-citation force)
6805 (gnus-article-highlight-signature)
6806 (gnus-article-add-buttons force)
6807 (gnus-article-add-buttons-to-head))
6809 (defun gnus-article-highlight-some (&optional force)
6810 "Highlight current article.
6811 This function calls `gnus-article-highlight-headers',
6812 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6813 do the highlighting. See the documentation for those functions."
6814 (interactive (list 'force))
6815 (gnus-article-highlight-headers)
6816 (gnus-article-highlight-signature)
6817 (gnus-article-add-buttons))
6819 (defun gnus-article-highlight-headers ()
6820 "Highlight article headers as specified by `gnus-header-face-alist'."
6823 (set-buffer gnus-article-buffer)
6825 (let ((alist gnus-header-face-alist)
6826 (buffer-read-only nil)
6827 (case-fold-search t)
6828 (inhibit-point-motion-hooks t)
6829 entry regexp header-face field-face from hpoints fpoints)
6830 (article-narrow-to-head)
6831 (while (setq entry (pop alist))
6832 (goto-char (point-min))
6833 (setq regexp (concat "^\\("
6834 (if (string-equal "" (nth 0 entry))
6838 header-face (nth 1 entry)
6839 field-face (nth 2 entry))
6840 (while (and (re-search-forward regexp nil t)
6844 (unless (search-forward ":" nil t)
6846 (when (and header-face
6847 (not (memq (point) hpoints)))
6848 (push (point) hpoints)
6849 (gnus-put-text-property from (point) 'face header-face))
6850 (when (and field-face
6851 (not (memq (setq from (point)) fpoints)))
6853 (if (re-search-forward "^[^ \t]" nil t)
6855 (goto-char (point-max)))
6856 (gnus-put-text-property from (point) 'face field-face))))))))
6858 (defun gnus-article-highlight-signature ()
6859 "Highlight the signature in an article.
6860 It does this by highlighting everything after
6861 `gnus-signature-separator' using `gnus-signature-face'."
6863 (when gnus-signature-face
6865 (set-buffer gnus-article-buffer)
6866 (let ((buffer-read-only nil)
6867 (inhibit-point-motion-hooks t))
6869 (when (gnus-article-narrow-to-signature)
6870 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6871 'face gnus-signature-face)))))))
6873 (defun gnus-article-buttonize-signature ()
6874 "Add button to the signature."
6877 (set-buffer gnus-article-buffer)
6878 (let ((buffer-read-only nil)
6879 (inhibit-point-motion-hooks t))
6880 (when (gnus-article-search-signature)
6881 (gnus-article-add-button (match-beginning 0) (match-end 0)
6882 'gnus-signature-toggle
6883 (set-marker (make-marker)
6884 (1+ (match-end 0))))))))
6886 (defun gnus-button-in-region-p (b e prop)
6887 "Say whether PROP exists in the region."
6888 (text-property-not-all b e prop nil))
6890 (defun gnus-article-add-buttons (&optional force)
6891 "Find external references in the article and make buttons of them.
6892 \"External references\" are things like Message-IDs and URLs, as
6893 specified by `gnus-button-alist'."
6894 (interactive (list 'force))
6896 (set-buffer gnus-article-buffer)
6897 (let ((buffer-read-only nil)
6898 (inhibit-point-motion-hooks t)
6899 (case-fold-search t)
6900 (alist gnus-button-alist)
6902 ;; Remove all old markers.
6903 (let (marker entry new-list)
6904 (while (setq marker (pop gnus-button-marker-list))
6905 (if (or (< marker (point-min)) (>= marker (point-max)))
6906 (push marker new-list)
6908 (when (setq entry (gnus-button-entry))
6909 (put-text-property (match-beginning (nth 1 entry))
6910 (match-end (nth 1 entry))
6911 'gnus-callback nil))
6912 (set-marker marker nil)))
6913 (setq gnus-button-marker-list new-list))
6914 ;; We skip the headers.
6917 (while (setq entry (pop alist))
6918 (setq regexp (eval (car entry)))
6920 (while (re-search-forward regexp nil t)
6921 (let* ((start (and entry (match-beginning (nth 1 entry))))
6922 (end (and entry (match-end (nth 1 entry))))
6923 (from (match-beginning 0)))
6924 (when (and (or (eq t (nth 2 entry))
6925 (eval (nth 2 entry)))
6926 (not (gnus-button-in-region-p
6927 start end 'gnus-callback)))
6928 ;; That optional form returned non-nil, so we add the
6930 (gnus-article-add-button
6931 start end 'gnus-button-push
6932 (car (push (set-marker (make-marker) from)
6933 gnus-button-marker-list))))))))))
6935 ;; Add buttons to the head of an article.
6936 (defun gnus-article-add-buttons-to-head ()
6937 "Add buttons to the head of the article."
6940 (set-buffer gnus-article-buffer)
6942 (let ((buffer-read-only nil)
6943 (inhibit-point-motion-hooks t)
6944 (case-fold-search t)
6945 (alist gnus-header-button-alist)
6947 (article-narrow-to-head)
6949 ;; Each alist entry.
6950 (setq entry (car alist)
6952 (goto-char (point-min))
6953 (while (re-search-forward (car entry) nil t)
6954 ;; Each header matching the entry.
6955 (setq beg (match-beginning 0))
6956 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6957 (match-beginning 0))
6960 (while (re-search-forward (eval (nth 1 entry)) end t)
6961 ;; Each match within a header.
6962 (let* ((entry (cdr entry))
6963 (start (match-beginning (nth 1 entry)))
6964 (end (match-end (nth 1 entry)))
6965 (form (nth 2 entry)))
6966 (goto-char (match-end 0))
6968 (gnus-article-add-button
6969 start end (nth 3 entry)
6970 (buffer-substring (match-beginning (nth 4 entry))
6971 (match-end (nth 4 entry)))))))
6972 (goto-char end)))))))
6974 ;;; External functions:
6976 (defun gnus-article-add-button (from to fun &optional data)
6977 "Create a button between FROM and TO with callback FUN and data DATA."
6978 (when gnus-article-button-face
6979 (gnus-overlay-put (gnus-make-overlay from to)
6980 'face gnus-article-button-face))
6981 (gnus-add-text-properties
6983 (nconc (and gnus-article-mouse-face
6984 (list gnus-mouse-face-prop gnus-article-mouse-face))
6985 (list 'gnus-callback fun)
6986 (and data (list 'gnus-data data))))
6987 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6988 ;; Quote `:button-keymap' for Mule 2.3
6989 ;; but it won't work.
6990 ':button-keymap gnus-widget-button-keymap))
6992 ;;; Internal functions:
6994 (defun gnus-article-set-globals ()
6996 (set-buffer gnus-summary-buffer)
6997 (gnus-set-global-variables)))
6999 (defun gnus-signature-toggle (end)
7001 (set-buffer gnus-article-buffer)
7002 (let ((buffer-read-only nil)
7003 (inhibit-point-motion-hooks t)
7004 (limit (next-single-property-change end 'mime-view-entity
7006 (if (text-property-any end limit 'article-type 'signature)
7008 (gnus-delete-wash-type 'signature)
7009 (gnus-remove-text-properties-when
7010 'article-type 'signature end limit
7011 (cons 'article-type (cons 'signature
7012 gnus-hidden-properties))))
7013 (gnus-add-wash-type 'signature)
7014 (gnus-add-text-properties-when
7015 'article-type nil end limit
7016 (cons 'article-type (cons 'signature
7017 gnus-hidden-properties)))))
7018 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
7019 (gnus-set-mode-line 'article))))
7021 (defun gnus-button-entry ()
7022 ;; Return the first entry in `gnus-button-alist' matching this place.
7023 (let ((alist gnus-button-alist)
7026 (setq entry (pop alist))
7027 (if (looking-at (eval (car entry)))
7032 (defun gnus-button-push (marker)
7033 ;; Push button starting at MARKER.
7036 (let* ((entry (gnus-button-entry))
7037 (inhibit-point-motion-hooks t)
7039 (args (mapcar (lambda (group)
7040 (let ((string (match-string group)))
7041 (set-text-properties
7042 0 (length string) nil string)
7049 (fboundp (symbol-value fun)))
7050 (apply (symbol-value fun) args))
7052 (gnus-message 1 "You must define `%S' to use this button"
7053 (cons fun args)))))))
7055 (defun gnus-parse-news-url (url)
7056 (let (scheme server group message-id articles)
7059 (goto-char (point-min))
7060 (when (looking-at "\\([A-Za-z]+\\):")
7061 (setq scheme (match-string 1))
7062 (goto-char (match-end 0)))
7063 (when (looking-at "//\\([^/]+\\)/")
7064 (setq server (match-string 1))
7065 (goto-char (match-end 0)))
7068 ((looking-at "\\(.*@.*\\)")
7069 (setq message-id (match-string 1)))
7070 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
7071 (setq group (match-string 1)
7072 articles (split-string (match-string 2) "-")))
7073 ((looking-at "\\([^/]+\\)/?")
7074 (setq group (match-string 1)))
7076 (error "Unknown news URL syntax"))))
7077 (list scheme server group message-id articles)))
7079 (defun gnus-button-handle-news (url)
7081 (destructuring-bind (scheme server group message-id articles)
7082 (gnus-parse-news-url url)
7086 (set-buffer gnus-summary-buffer)
7088 (let ((gnus-refer-article-method (list (list 'nntp server))))
7089 (gnus-summary-refer-article message-id))
7090 (gnus-summary-refer-article message-id))))
7092 (gnus-button-fetch-group url)))))
7094 (defun gnus-button-handle-man (url)
7096 (funcall gnus-button-man-handler url))
7098 (defun gnus-button-handle-info-url (url)
7099 "Fetch an info URL."
7100 (setq url (mm-subst-char-in-string ?+ ?\ url))
7102 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
7103 (gnus-info-find-node
7104 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
7106 ")" (gnus-url-unhex-string (match-string 2 url)))))
7107 ((string-match "([^)\"]+)[^\"]+" url)
7109 (gnus-replace-in-string
7110 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
7111 (gnus-info-find-node url))
7112 (t (error "Can't parse %s" url))))
7114 (defun gnus-button-handle-info-url-gnome (url)
7115 "Fetch GNOME style info URL."
7116 (setq url (mm-subst-char-in-string ?_ ?\ url))
7117 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
7118 (gnus-info-find-node
7120 (gnus-url-unhex-string
7121 (match-string 1 url))
7123 (or (gnus-url-unhex-string
7124 (match-string 2 url))
7126 (error "Can't parse %s" url)))
7128 (defun gnus-button-handle-info-url-kde (url)
7129 "Fetch KDE style info URL."
7130 (gnus-info-find-node (gnus-url-unhex-string url)))
7132 (defun gnus-button-handle-info-keystrokes (url)
7133 "Call `info' when pushing the corresponding URL button."
7134 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
7139 (defun gnus-button-message-id (message-id)
7142 (set-buffer gnus-summary-buffer)
7143 (gnus-summary-refer-article message-id)))
7145 (defun gnus-button-fetch-group (address)
7146 "Fetch GROUP specified by ADDRESS."
7147 (if (not (string-match "[:/]" address))
7148 ;; This is just a simple group url.
7149 (gnus-group-read-ephemeral-group address gnus-select-method)
7152 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
7154 (error "Can't parse %s" address)
7155 (gnus-group-read-ephemeral-group
7156 (match-string 4 address)
7157 `(nntp ,(match-string 1 address)
7158 (nntp-address ,(match-string 1 address))
7159 (nntp-port-number ,(if (match-end 3)
7160 (match-string 3 address)
7163 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
7165 (defun gnus-url-parse-query-string (query &optional downcase)
7166 (let (retval pairs cur key val)
7167 (setq pairs (split-string query "&"))
7169 (setq cur (car pairs)
7171 (if (not (string-match "=" cur))
7173 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
7174 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
7176 (setq key (downcase key)))
7177 (setq cur (assoc key retval))
7179 (setcdr cur (cons val (cdr cur)))
7180 (setq retval (cons (list key val) retval)))))
7183 (defun gnus-url-mailto (url)
7184 ;; Send mail to someone
7185 (when (string-match "mailto:/*\\(.*\\)" url)
7186 (setq url (substring url (match-beginning 1) nil)))
7187 (let (to args subject func)
7188 (setq args (gnus-url-parse-query-string
7189 (if (string-match "^\\?" url)
7191 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
7192 (concat "to=" (match-string 1 url) "&"
7193 (match-string 2 url))
7194 (concat "to=" url)))
7196 subject (cdr-safe (assoc "subject" args)))
7199 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
7202 (message-position-on-field (caar args)))
7203 (insert (gnus-replace-in-string
7204 (mapconcat 'identity (reverse (cdar args)) ", ")
7206 (setq args (cdr args)))
7209 (message-goto-subject))))
7211 (defun gnus-button-embedded-url (address)
7212 "Activate ADDRESS with `browse-url'."
7213 (browse-url (gnus-strip-whitespace address)))
7215 ;;; Next/prev buttons in the article buffer.
7217 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
7218 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
7220 (defvar gnus-prev-page-map
7221 (let ((map (make-sparse-keymap)))
7222 (unless (>= emacs-major-version 21)
7223 ;; XEmacs doesn't care.
7224 (set-keymap-parent map gnus-article-mode-map))
7225 (define-key map gnus-mouse-2 'gnus-button-prev-page)
7226 (define-key map "\r" 'gnus-button-prev-page)
7229 (defun gnus-insert-prev-page-button ()
7231 (buffer-read-only nil)
7232 (situation (get-text-property (point-min) 'mime-view-situation)))
7234 gnus-prev-page-line-format nil
7235 `(keymap ,gnus-prev-page-map
7237 gnus-callback gnus-article-button-prev-page
7238 article-type annotation
7239 mime-view-situation ,situation))
7240 (widget-convert-button
7242 ;; Exclude a newline.
7245 :action 'gnus-button-prev-page
7246 :button-keymap gnus-prev-page-map)))
7248 (defvar gnus-next-page-map
7249 (let ((map (make-sparse-keymap)))
7250 (unless (>= emacs-major-version 21)
7251 ;; XEmacs doesn't care.
7252 (set-keymap-parent map gnus-article-mode-map))
7253 (define-key map gnus-mouse-2 'gnus-button-next-page)
7254 (define-key map "\r" 'gnus-button-next-page)
7257 (defun gnus-button-next-page (&optional args more-args)
7258 "Go to the next page."
7260 (let ((win (selected-window)))
7261 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7262 (gnus-article-next-page)
7263 (select-window win)))
7265 (defun gnus-button-prev-page (&optional args more-args)
7266 "Go to the prev page."
7268 (let ((win (selected-window)))
7269 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7270 (gnus-article-prev-page)
7271 (select-window win)))
7273 (defun gnus-insert-next-page-button ()
7275 (buffer-read-only nil)
7276 (situation (get-text-property (point-min) 'mime-view-situation)))
7277 (gnus-eval-format gnus-next-page-line-format nil
7278 `(keymap ,gnus-next-page-map
7280 gnus-callback gnus-article-button-next-page
7281 article-type annotation
7282 mime-view-situation ,situation))
7283 (widget-convert-button
7285 ;; Exclude a newline.
7288 :action 'gnus-button-next-page
7289 :button-keymap gnus-next-page-map)))
7291 (defun gnus-article-button-next-page (arg)
7292 "Go to the next page."
7294 (let ((win (selected-window)))
7295 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7296 (gnus-article-next-page)
7297 (select-window win)))
7299 (defun gnus-article-button-prev-page (arg)
7300 "Go to the prev page."
7302 (let ((win (selected-window)))
7303 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7304 (gnus-article-prev-page)
7305 (select-window win)))
7307 (defvar gnus-decode-header-methods
7308 '(mail-decode-encoded-word-region)
7309 "List of methods used to decode headers.
7311 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
7312 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
7313 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
7314 whose names match REGEXP.
7317 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
7318 mail-decode-encoded-word-region
7319 (\"chinese\" . rfc1843-decode-region))
7322 (defvar gnus-decode-header-methods-cache nil)
7324 (defun gnus-multi-decode-header (start end)
7325 "Apply the functions from `gnus-encoded-word-methods' that match."
7326 (unless (and gnus-decode-header-methods-cache
7327 (eq gnus-newsgroup-name
7328 (car gnus-decode-header-methods-cache)))
7329 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
7332 (nconc gnus-decode-header-methods-cache (list x))
7333 (if (and gnus-newsgroup-name
7334 (string-match (car x) gnus-newsgroup-name))
7335 (nconc gnus-decode-header-methods-cache
7337 gnus-decode-header-methods))
7338 (let ((xlist gnus-decode-header-methods-cache))
7341 (narrow-to-region start end)
7343 (funcall (pop xlist) (point-min) (point-max))))))
7346 ;;; Treatment top-level handling.
7349 (defun gnus-treat-article (condition &optional part-number total-parts type)
7350 (let ((length (- (point-max) (point-min)))
7351 (alist gnus-treatment-function-alist)
7352 (article-goto-body-goes-to-point-min-p t)
7356 (let ((list gnus-article-treat-types))
7358 (when (string-match (pop list) type)
7359 (throw 'found t)))))))
7360 (highlightp (gnus-visual-p 'article-highlight 'highlight))
7361 (entity (static-unless (featurep 'xemacs)
7362 (when (eq 'head condition)
7363 (get-text-property (point-min) 'mime-view-entity))))
7364 val elem buttonized)
7365 (gnus-run-hooks 'gnus-part-display-hook)
7366 (unless gnus-inhibit-treatment
7367 (dolist (elem alist)
7370 (when (gnus-buffer-live-p gnus-summary-buffer)
7371 (set-buffer gnus-summary-buffer))
7372 (symbol-value (car elem))))
7373 (when (and (or (consp val)
7375 (gnus-treat-predicate val)
7376 (or (not (get (car elem) 'highlight))
7378 (when (and (not buttonized)
7380 '(gnus-treat-hide-signature
7381 gnus-treat-highlight-signature)))
7382 (gnus-article-buttonize-signature)
7383 (setq buttonized t))
7385 (funcall (cadr elem)))))
7386 ;; FSF Emacsen does not inherit the existing text properties
7387 ;; in the new text, so we should do it for `mime-view-entity'.
7388 (static-unless (featurep 'xemacs)
7390 (put-text-property (point-min) (point-max)
7391 'mime-view-entity entity))))))
7393 ;; Dynamic variables.
7395 (defvar part-number)
7396 (defvar total-parts)
7401 (defun gnus-treat-predicate (val)
7406 (stringp (car val)))
7407 (apply 'gnus-or (mapcar `(lambda (s)
7408 (string-match s ,(or gnus-newsgroup-name "")))
7411 (let ((pred (pop val)))
7414 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
7416 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
7418 (not (gnus-treat-predicate (car val))))
7420 (equal (car val) type))
7422 (error "%S is not a valid predicate" pred)))))
7432 (eq part-number total-parts))
7436 (error "%S is not a valid value" val))))
7438 (defun gnus-article-encrypt-body (protocol &optional n)
7439 "Encrypt the article body."
7442 (or gnus-article-encrypt-protocol
7443 (completing-read "Encrypt protocol: "
7444 gnus-article-encrypt-protocol-alist
7446 current-prefix-arg))
7447 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7449 (error (format "Can't find the encrypt protocol %s" protocol)))
7450 (if (member gnus-newsgroup-name '("nndraft:delayed"
7453 (error "Can't encrypt the article in group %s"
7454 gnus-newsgroup-name))
7455 (gnus-summary-iterate n
7457 (set-buffer gnus-summary-buffer)
7458 (let ((mail-parse-charset gnus-newsgroup-charset)
7459 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7460 (summary-buffer gnus-summary-buffer)
7462 (gnus-set-global-variables)
7463 (when (gnus-group-read-only-p)
7464 (error "The current newsgroup does not support article encrypt"))
7465 (gnus-summary-show-article t)
7467 (or (mail-header-references gnus-current-headers) ""))
7468 (set-buffer gnus-article-buffer)
7469 (let* ((buffer-read-only nil)
7471 (mapcar (lambda (field)
7472 (and (save-restriction
7473 (message-narrow-to-head)
7474 (goto-char (point-min))
7475 (search-forward field nil t))
7477 (message-narrow-to-field)
7479 (delete-region (point-min) (point-max))
7481 '("Content-Type:" "Content-Transfer-Encoding:"
7482 "Content-Disposition:"))))
7483 (message-narrow-to-head)
7484 (message-remove-header "MIME-Version")
7485 (goto-char (point-max))
7486 (setq point (point))
7487 (insert (apply 'concat headers))
7489 (narrow-to-region point (point-max))
7490 (let ((message-options message-options))
7491 (message-options-set 'message-sender user-mail-address)
7492 (message-options-set 'message-recipients user-mail-address)
7493 (message-options-set 'message-sign-encrypt 'not)
7495 (goto-char (point-min))
7496 (insert "MIME-Version: 1.0\n")
7498 (gnus-summary-edit-article-done
7499 references nil summary-buffer t))
7500 (when gnus-keep-backlog
7501 (gnus-backlog-remove-article
7502 (car gnus-article-current) (cdr gnus-article-current)))
7504 (when (get-buffer gnus-original-article-buffer)
7505 (set-buffer gnus-original-article-buffer)
7506 (setq gnus-original-article nil)))
7507 (when gnus-use-cache
7508 (gnus-cache-update-article
7509 (car gnus-article-current) (cdr gnus-article-current))))))))
7511 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7512 "The following specs can be used:
7513 %t The security MIME type
7516 %D Details if button is pressed")
7518 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
7519 "The following specs can be used:
7520 %t The security MIME type
7523 %D Details if button is pressed")
7525 (defvar gnus-mime-security-button-line-format-alist
7526 '((?t gnus-tmp-type ?s)
7527 (?i gnus-tmp-info ?s)
7528 (?d gnus-tmp-details ?s)
7529 (?D gnus-tmp-pressed-details ?s)))
7531 (defvar gnus-mime-security-button-map
7532 (let ((map (make-sparse-keymap)))
7533 (unless (>= (string-to-number emacs-version) 21)
7534 (set-keymap-parent map gnus-article-mode-map))
7535 (define-key map gnus-mouse-2 'gnus-article-push-button)
7536 (define-key map "\r" 'gnus-article-press-button)
7539 (defvar gnus-mime-security-details-buffer nil)
7541 (defvar gnus-mime-security-button-pressed nil)
7543 (defvar gnus-mime-security-show-details-inline t
7544 "If non-nil, show details in the article buffer.")
7546 (defun gnus-mime-security-verify-or-decrypt (handle)
7547 (mm-remove-parts (cdr handle))
7548 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7549 point buffer-read-only)
7551 (goto-char (car region)))
7553 (narrow-to-region (point) (point))
7554 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7555 (let* ((mm-verify-option 'known)
7556 (mm-decrypt-option 'known)
7557 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7558 (unless (eq nparts (cdr handle))
7559 (mm-destroy-parts (cdr handle))
7560 (setcdr handle nparts))))
7561 (setq point (point))
7562 (gnus-mime-display-security handle)
7563 (goto-char (point-max)))
7565 (delete-region (point) (cdr region))
7566 (set-marker (car region) nil)
7567 (set-marker (cdr region) nil))
7570 (defun gnus-mime-security-show-details (handle)
7571 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7573 (gnus-message 5 "No details.")
7574 (if gnus-mime-security-show-details-inline
7575 (let ((gnus-mime-security-button-pressed
7576 (not (get-text-property (point) 'gnus-mime-details)))
7577 (gnus-mime-security-button-line-format
7578 (get-text-property (point) 'gnus-line-format))
7581 (while (eq (get-text-property (point) 'gnus-line-format)
7582 gnus-mime-security-button-line-format)
7586 (narrow-to-region (point) (point))
7587 (gnus-insert-mime-security-button handle))
7588 (delete-region (point)
7589 (or (text-property-not-all
7592 gnus-mime-security-button-line-format)
7595 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7596 (with-current-buffer gnus-mime-security-details-buffer
7599 (setq gnus-mime-security-details-buffer
7600 (gnus-get-buffer-create "*MIME Security Details*")))
7601 (with-current-buffer gnus-mime-security-details-buffer
7603 (goto-char (point-min)))
7604 (pop-to-buffer gnus-mime-security-details-buffer)))))
7606 (defun gnus-mime-security-press-button (handle)
7608 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7609 (gnus-mime-security-show-details handle)
7610 (gnus-mime-security-verify-or-decrypt handle))))
7612 (defun gnus-insert-mime-security-button (handle &optional displayed)
7613 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7616 (or (nth 2 (assoc protocol mm-verify-function-alist))
7617 (nth 2 (assoc protocol mm-decrypt-function-alist))
7619 (if (equal (car handle) "multipart/signed")
7620 " Signed" " Encrypted")
7623 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7626 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7627 gnus-tmp-pressed-details
7629 (setq gnus-tmp-details
7630 (if gnus-tmp-details
7631 (concat "\n" gnus-tmp-details)
7633 (setq gnus-tmp-pressed-details
7634 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7639 gnus-mime-security-button-line-format
7640 gnus-mime-security-button-line-format-alist
7641 `(keymap ,gnus-mime-security-button-map
7642 gnus-callback gnus-mime-security-press-button
7643 gnus-line-format ,gnus-mime-security-button-line-format
7644 gnus-mime-details ,gnus-mime-security-button-pressed
7645 article-type annotation
7648 ;; Exclude a newline.
7651 (widget-convert-button
7654 :action 'gnus-widget-press-button
7655 :button-keymap gnus-mime-security-button-map
7657 (lambda (widget/window &optional overlay pos)
7658 ;; Needed to properly clear the message due to a bug in
7659 ;; wid-edit (XEmacs only).
7660 (when (boundp 'help-echo-owns-message)
7661 (setq help-echo-owns-message t))
7664 (aref gnus-mouse-2 0))))))
7666 (defun gnus-mime-display-security (handle)
7668 (narrow-to-region (point) (point))
7669 (unless (gnus-unbuttonized-mime-type-p (car handle))
7670 (gnus-insert-mime-security-button handle))
7671 (gnus-mime-display-mixed (cdr handle))
7674 (unless (gnus-unbuttonized-mime-type-p (car handle))
7675 (let ((gnus-mime-security-button-line-format
7676 gnus-mime-security-button-end-line-format))
7677 (gnus-insert-mime-security-button handle)))
7678 (mm-set-handle-multipart-parameter
7680 (cons (set-marker (make-marker) (point-min))
7681 (set-marker (make-marker) (point-max))))))
7687 (defun gnus-article-header-presentation-method (entity situation)
7688 (mime-insert-header entity)
7689 (article-decode-group-name))
7691 (set-alist 'mime-header-presentation-method-alist
7692 'gnus-original-article-mode
7693 #'gnus-article-header-presentation-method)
7695 (defun gnus-mime-preview-quitting-method ()
7696 (mime-preview-kill-buffer)
7697 (delete-other-windows)
7698 (gnus-article-show-summary)
7699 (gnus-summary-select-article gnus-show-all-headers t))
7701 (set-alist 'mime-preview-quitting-method-alist
7702 'gnus-original-article-mode #'gnus-mime-preview-quitting-method)
7704 (set-alist 'mime-preview-following-method-alist
7705 'gnus-original-article-mode #'gnus-following-method)
7707 (set-alist 'mime-preview-over-to-previous-method-alist
7708 'gnus-original-article-mode
7710 (if (> (point-min) 1)
7711 (gnus-article-prev-page)
7712 (gnus-article-read-summary-keys
7713 nil (gnus-character-to-event ?P)))))
7715 (set-alist 'mime-preview-over-to-next-method-alist
7716 'gnus-original-article-mode'
7718 (if (< (point-max) (buffer-size))
7719 (gnus-article-next-page)
7720 (gnus-article-read-summary-keys
7721 nil (gnus-character-to-event ?N)))))
7731 (run-hooks 'gnus-art-load-hook)
7733 ;;; gnus-art.el ends here