1 ;;; gnus-art.el --- article mode commands for Semi-gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
7 ;; Katsumi Yamaoka <yamaoka@jpl.org>
8 ;; Keywords: mail, news, MIME
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
34 (defvar tool-bar-map))
44 (when (static-if (featurep 'xemacs)
45 (console-on-window-system-p)
47 (require 'mime-image))
50 ;; Avoid byte-compile warnings.
60 (autoload 'gnus-msg-mail "gnus-msg" nil t)
61 (autoload 'gnus-button-mailto "gnus-msg")
62 (autoload 'gnus-button-reply "gnus-msg" nil t)
63 (autoload 'ansi-color-apply-on-region "ansi-color")
65 (defgroup gnus-article nil
67 :link '(custom-manual "(gnus)Article Buffer")
70 (defgroup gnus-article-treat nil
71 "Treating article parts."
72 :link '(custom-manual "(gnus)Article Hiding")
75 (defgroup gnus-article-hiding nil
76 "Hiding article parts."
77 :link '(custom-manual "(gnus)Article Hiding")
80 (defgroup gnus-article-highlight nil
81 "Article highlighting."
82 :link '(custom-manual "(gnus)Article Highlighting")
86 (defgroup gnus-article-signature nil
88 :link '(custom-manual "(gnus)Article Signature")
91 (defgroup gnus-article-headers nil
93 :link '(custom-manual "(gnus)Hiding Headers")
96 (defgroup gnus-article-washing nil
97 "Special commands on articles."
98 :link '(custom-manual "(gnus)Article Washing")
101 (defgroup gnus-article-emphasis nil
102 "Fontisizing articles."
103 :link '(custom-manual "(gnus)Article Fontisizing")
104 :group 'gnus-article)
106 (defgroup gnus-article-saving nil
108 :link '(custom-manual "(gnus)Saving Articles")
109 :group 'gnus-article)
111 (defgroup gnus-article-mime nil
112 "Worshiping the MIME wonder."
113 :link '(custom-manual "(gnus)Using MIME")
114 :group 'gnus-article)
116 (defgroup gnus-article-buttons nil
117 "Pushable buttons in the article buffer."
118 :link '(custom-manual "(gnus)Article Buttons")
119 :group 'gnus-article)
121 (defgroup gnus-article-various nil
122 "Other article options."
123 :link '(custom-manual "(gnus)Misc Article")
124 :group 'gnus-article)
126 (defcustom gnus-ignored-headers
129 (concat "^" header ":"))
130 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
131 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
132 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
133 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
134 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
135 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
136 "X-Attribution" "X-Originating-IP" "Delivered-To"
137 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
138 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
139 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
140 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
141 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
142 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
143 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
144 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
145 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
146 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
147 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
148 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
149 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
150 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
151 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
152 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
153 "List-[A-Za-z]+" "X-Listprocessor-Version"
154 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
155 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
156 "X-Received" "Content-length" "X-precedence"
157 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
158 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
159 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
160 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
161 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
162 "X-Content-length" "X-Posting-Agent" "Original-Received"
163 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
164 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
165 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
166 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
167 "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer"))
168 "*All headers that start with this regexp will be hidden.
169 This variable can also be a list of regexps of headers to be ignored.
170 If `gnus-visible-headers' is non-nil, this variable will be ignored."
171 :type '(choice :custom-show nil
174 :group 'gnus-article-hiding)
176 (defcustom gnus-visible-headers
177 "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^[BGF]?Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Mail-Followup-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-From:\\|^X-Sent:"
178 "*All headers that do not match this regexp will be hidden.
179 This variable can also be a list of regexp of headers to remain visible.
180 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
181 :type '(repeat :value-to-internal (lambda (widget value)
182 (custom-split-regexp-maybe value))
183 :match (lambda (widget value)
185 (widget-editable-list-match widget value)))
187 :group 'gnus-article-hiding)
189 (defcustom gnus-sorted-header-list
190 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
191 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
192 "*This variable is a list of regular expressions.
193 If it is non-nil, headers that match the regular expressions will
194 be placed first in the article buffer in the sequence specified by
196 :type '(repeat regexp)
197 :group 'gnus-article-hiding)
199 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
200 "Headers that are only to be displayed if they have interesting data.
201 Possible values in this list are:
203 'empty Headers with no content.
204 'newsgroups Newsgroup identical to Gnus group.
205 'to-address To identical to To-address.
206 'to-list To identical to To-list.
207 'cc-list CC identical to To-list.
208 'followup-to Followup-to identical to Newsgroups.
209 'reply-to Reply-to identical to From.
210 'date Date less than four days old.
211 'long-to To and/or Cc longer than 1024 characters.
212 'many-to Multiple To and/or Cc."
213 :type '(set (const :tag "Headers with no content." empty)
214 (const :tag "Newsgroups identical to Gnus group." newsgroups)
215 (const :tag "To identical to To-address." to-address)
216 (const :tag "To identical to To-list." to-list)
217 (const :tag "CC identical to To-list." cc-list)
218 (const :tag "Followup-to identical to Newsgroups." followup-to)
219 (const :tag "Reply-to identical to From." reply-to)
220 (const :tag "Date less than four days old." date)
221 (const :tag "To and/or Cc longer than 1024 characters." long-to)
222 (const :tag "Multiple To and/or Cc headers." many-to))
223 :group 'gnus-article-hiding)
225 (defcustom gnus-article-skip-boring nil
226 "Skip over text that is not worth reading.
227 By default, if you set this t, then Gnus will display citations and
228 signatures, but will never scroll down to show you a page consisting
229 only of boring text. Boring text is controlled by
230 `gnus-article-boring-faces'."
233 :group 'gnus-article-hiding)
235 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
236 "Regexp matching signature separator.
237 This can also be a list of regexps. In that case, it will be checked
238 from head to tail looking for a separator. Searches will be done from
239 the end of the buffer."
240 :type '(repeat string)
241 :group 'gnus-article-signature)
243 (defcustom gnus-signature-limit nil
244 "Provide a limit to what is considered a signature.
245 If it is a number, no signature may not be longer (in characters) than
246 that number. If it is a floating point number, no signature may be
247 longer (in lines) than that number. If it is a function, the function
248 will be called without any parameters, and if it returns nil, there is
249 no signature in the buffer. If it is a string, it will be used as a
250 regexp. If it matches, the text in question is not a signature.
252 This can also be a list of the above values."
253 :type '(choice (integer :value 200)
255 (function :value fun)
256 (regexp :value ".*"))
257 :group 'gnus-article-signature)
259 (defcustom gnus-hidden-properties '(invisible t intangible t)
260 "Property list to use for hiding text."
262 :group 'gnus-article-hiding)
264 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
265 ;; frames in a session.
266 (defcustom gnus-article-x-face-command
271 (if (or (gnus-image-type-available-p 'xface)
272 (gnus-image-type-available-p 'pbm))
273 'gnus-display-x-face-in-from
274 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -"))
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-mule (if (featurep 'xemacs)
289 (module-installed-p 'x-face-mule))))
293 (if (or (gnus-image-type-available-p 'xface)
294 (gnus-image-type-available-p 'pbm))
295 '(function-item gnus-display-x-face-in-from))
298 x-face-mule-gnus-article-display-x-face))
302 :group 'gnus-article-washing)
304 (defcustom gnus-article-x-face-too-ugly nil
305 "Regexp matching posters whose face shouldn't be shown automatically."
306 :type '(choice regexp (const nil))
307 :group 'gnus-article-washing)
309 (defcustom gnus-article-banner-alist nil
310 "Banner alist for stripping.
312 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
314 :type '(repeat (cons symbol regexp))
315 :group 'gnus-article-washing)
317 (gnus-define-group-parameter
320 "Alist of regexps (to match group names) and banner."
321 :variable-group gnus-article-washing
323 '(choice :tag "Banner"
325 (const :tag "Remove signature" signature)
326 (symbol :tag "Item in `gnus-article-banner-alist'" none)
328 (const :tag "None" nil))
330 "If non-nil, specify how to remove `banners' from articles.
332 Symbol `signature' means to remove signatures delimited by
333 `gnus-signature-separator'. Any other symbol is used to look up a
334 regular expression to match the banner in `gnus-article-banner-alist'.
335 A string is used as a regular expression to match the banner
338 (defcustom gnus-article-address-banner-alist nil
339 "Alist of mail addresses and banners.
340 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
341 to match a mail address in the From: header, BANNER is one of a symbol
342 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
343 If ADDRESS matches author's mail address, it will remove things like
344 advertisements. For example:
346 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
350 (regexp :tag "Address")
351 (choice :tag "Banner" :value nil
352 (const :tag "Remove signature" signature)
353 (symbol :tag "Item in `gnus-article-banner-alist'" none)
355 (const :tag "None" nil))))
356 :group 'gnus-article-washing)
358 (defcustom gnus-emphasis-alist
360 "\\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)")
365 ("_/" "/_" underline-italic)
366 ("_\\*" "\\*_" underline-bold)
367 ("\\*/" "/\\*" bold-italic)
368 ("_\\*/" "/\\*_" underline-bold-italic))))
372 (format format (car spec) (car (cdr spec)))
373 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
375 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
376 2 3 gnus-emphasis-underline)))
377 "*Alist that says how to fontify certain phrases.
378 Each item looks like this:
380 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
382 The first element is a regular expression to be matched. The second
383 is a number that says what regular expression grouping used to find
384 the entire emphasized word. The third is a number that says what
385 regexp grouping should be displayed and highlighted. The fourth
386 is the face used for highlighting."
387 :type '(repeat (list :value ("" 0 0 default)
389 (integer :tag "Match group")
390 (integer :tag "Emphasize group")
392 :group 'gnus-article-emphasis)
394 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
395 "A regexp to describe whitespace which should not be emphasized.
396 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
397 The former avoids underlining of leading and trailing whitespace,
398 and the latter avoids underlining any whitespace at all."
400 :group 'gnus-article-emphasis
403 (defface gnus-emphasis-bold '((t (:bold t)))
404 "Face used for displaying strong emphasized text (*word*)."
405 :group 'gnus-article-emphasis)
407 (defface gnus-emphasis-italic '((t (:italic t)))
408 "Face used for displaying italic emphasized text (/word/)."
409 :group 'gnus-article-emphasis)
411 (defface gnus-emphasis-underline '((t (:underline t)))
412 "Face used for displaying underlined emphasized text (_word_)."
413 :group 'gnus-article-emphasis)
415 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
416 "Face used for displaying underlined bold emphasized text (_*word*_)."
417 :group 'gnus-article-emphasis)
419 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
420 "Face used for displaying underlined italic emphasized text (_/word/_)."
421 :group 'gnus-article-emphasis)
423 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
424 "Face used for displaying bold italic emphasized text (/*word*/)."
425 :group 'gnus-article-emphasis)
427 (defface gnus-emphasis-underline-bold-italic
428 '((t (:bold t :italic t :underline t)))
429 "Face used for displaying underlined bold italic emphasized text.
430 Example: (_/*word*/_)."
431 :group 'gnus-article-emphasis)
433 (defface gnus-emphasis-strikethru (if (featurep 'xemacs)
434 '((t (:strikethru t)))
435 '((t (:strike-through t))))
436 "Face used for displaying strike-through text (-word-)."
437 :group 'gnus-article-emphasis)
439 (defface gnus-emphasis-highlight-words
440 '((t (:background "black" :foreground "yellow")))
441 "Face used for displaying highlighted words."
442 :group 'gnus-article-emphasis)
444 (defcustom gnus-article-time-format "%a, %d %b %Y %T %Z"
445 "Format for display of Date headers in article bodies.
446 See `format-time-string' for the possible values.
448 The variable can also be function, which should return a complete Date
449 header. The function is called with one argument, the time, which can
450 be fed to `format-time-string'."
451 :type '(choice string function)
452 :link '(custom-manual "(gnus)Article Date")
453 :group 'gnus-article-washing)
456 (autoload 'mail-extract-address-components "mail-extr"))
458 (defcustom gnus-save-all-headers t
459 "*If non-nil, don't remove any headers before saving."
460 :group 'gnus-article-saving
463 (defcustom gnus-prompt-before-saving 'always
464 "*This variable says how much prompting is to be done when saving articles.
465 If it is nil, no prompting will be done, and the articles will be
466 saved to the default files. If this variable is `always', each and
467 every article that is saved will be preceded by a prompt, even when
468 saving large batches of articles. If this variable is neither nil not
469 `always', there the user will be prompted once for a file name for
470 each invocation of the saving commands."
471 :group 'gnus-article-saving
472 :type '(choice (item always)
473 (item :tag "never" nil)
474 (sexp :tag "once" :format "%t\n" :value t)))
476 (defcustom gnus-saved-headers gnus-visible-headers
477 "Headers to keep if `gnus-save-all-headers' is nil.
478 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
479 If that variable is nil, however, all headers that match this regexp
480 will be kept while the rest will be deleted before saving."
481 :group 'gnus-article-saving
484 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
485 "A function to save articles in your favourite format.
486 The function must be interactively callable (in other words, it must
487 be an Emacs command).
489 Gnus provides the following functions:
491 * gnus-summary-save-in-rmail (Rmail format)
492 * gnus-summary-save-in-mail (Unix mail format)
493 * gnus-summary-save-in-folder (MH folder)
494 * gnus-summary-save-in-file (article format)
495 * gnus-summary-save-body-in-file (article body)
496 * gnus-summary-save-in-vm (use VM's folder format)
497 * gnus-summary-write-to-file (article format -- overwrite)."
498 :group 'gnus-article-saving
499 :type '(radio (function-item gnus-summary-save-in-rmail)
500 (function-item gnus-summary-save-in-mail)
501 (function-item gnus-summary-save-in-folder)
502 (function-item gnus-summary-save-in-file)
503 (function-item gnus-summary-save-body-in-file)
504 (function-item gnus-summary-save-in-vm)
505 (function-item gnus-summary-write-to-file)))
507 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
508 "A function generating a file name to save articles in Rmail format.
509 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
510 :group 'gnus-article-saving
513 (defcustom gnus-mail-save-name 'gnus-plain-save-name
514 "A function generating a file name to save articles in Unix mail format.
515 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
516 :group 'gnus-article-saving
519 (defcustom gnus-folder-save-name 'gnus-folder-save-name
520 "A function generating a file name to save articles in MH folder.
521 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
522 :group 'gnus-article-saving
525 (defcustom gnus-file-save-name 'gnus-numeric-save-name
526 "A function generating a file name to save articles in article format.
527 The function is called with NEWSGROUP, HEADERS, and optional
529 :group 'gnus-article-saving
532 (defcustom gnus-split-methods
533 '((gnus-article-archive-name)
534 (gnus-article-nndoc-name))
535 "*Variable used to suggest where articles are to be saved.
536 For instance, if you would like to save articles related to Gnus in
537 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
538 you could set this variable to something like:
540 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
541 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
543 This variable is an alist where the where the key is the match and the
544 value is a list of possible files to save in if the match is non-nil.
546 If the match is a string, it is used as a regexp match on the
547 article. If the match is a symbol, that symbol will be funcalled
548 from the buffer of the article to be saved with the newsgroup as the
549 parameter. If it is a list, it will be evaled in the same buffer.
551 If this form or function returns a string, this string will be used as
552 a possible file name; and if it returns a non-nil list, that list will
553 be used as possible file names."
554 :group 'gnus-article-saving
555 :type '(repeat (choice (list :value (fun) function)
556 (cons :value ("" "") regexp (repeat string))
559 (defcustom gnus-article-display-method-for-mime
560 'gnus-article-display-mime-message
561 "Function to display a MIME message.
562 The function is called from the article buffer."
563 :group 'gnus-article-mime
566 (defcustom gnus-article-display-method-for-traditional
567 'gnus-article-display-traditional-message
568 "*Function to display a traditional message.
569 The function is called from the article buffer."
570 :group 'gnus-article-mime
573 (defcustom gnus-page-delimiter "^\^L"
574 "*Regexp describing what to use as article page delimiters.
575 The default value is \"^\^L\", which is a form linefeed at the
576 beginning of a line."
578 :group 'gnus-article-various)
580 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
581 "*The format specification for the article mode line.
582 See `gnus-summary-mode-line-format' for a closer description.
584 The following additional specs are available:
586 %w The article washing status.
587 %m The number of MIME parts in the article."
589 :group 'gnus-article-various)
591 (defcustom gnus-article-mode-hook nil
592 "*A hook for Gnus article mode."
594 :group 'gnus-article-various)
596 (when (featurep 'xemacs)
597 ;; Extracted from gnus-xmas-define in order to preserve user settings
598 (when (fboundp 'turn-off-scroll-in-place)
599 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
600 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
601 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
603 (defcustom gnus-article-menu-hook nil
604 "*Hook run after the creation of the article mode menu."
606 :group 'gnus-article-various)
608 (defcustom gnus-article-prepare-hook nil
609 "*A hook called after an article has been prepared in the article buffer."
611 :group 'gnus-article-various)
613 (defcustom gnus-copy-article-ignored-headers '("Xref")
614 "List of headers to be removed when copying an article.
615 Each element is a regular expression."
616 :version "22.0" ;; No Gnus
617 :type '(choice :custom-show nil
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'."
814 :group 'gnus-article-mime
817 (defcustom gnus-body-boundary-delimiter "_"
818 "String used to delimit header and body.
819 This variable is used by `gnus-article-treat-body-boundary' which can
820 be controlled by `gnus-treat-body-boundary'."
822 :group 'gnus-article-various
823 :type '(choice (item :tag "None" :value nil)
826 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces"
828 "Defines the location of the faces database.
829 For information on obtaining this database of pretty pictures, please
830 see http://www.cs.indiana.edu/picons/ftp/index.html"
832 :type '(repeat directory)
833 :link '(url-link :tag "download"
834 "http://www.cs.indiana.edu/picons/ftp/index.html")
835 :link '(custom-manual "(gnus)Picons")
838 (defun gnus-picons-installed-p ()
839 "Say whether picons are installed on your machine."
840 (let ((installed nil))
841 (dolist (database gnus-picon-databases)
842 (when (file-exists-p database)
846 (defcustom gnus-article-mime-part-function nil
847 "Function called with a MIME handle as the argument.
848 This is meant for people who want to do something automatic based
849 on parts -- for instance, adding Vcard info to a database."
850 :group 'gnus-article-mime
853 (defcustom gnus-mime-multipart-functions nil
854 "An alist of MIME types to functions to display them."
856 :group 'gnus-article-mime
857 :type '(repeat (cons :format "%v" (string :tag "MIME type") function)))
859 (defcustom gnus-article-date-lapsed-new-header nil
860 "Whether the X-Sent and Date headers can coexist.
861 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
862 either replace the old \"Date:\" header (if this variable is nil), or
863 be added below it (otherwise)."
865 :group 'gnus-article-headers
868 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
869 "Function called with a MIME handle as the argument.
870 This is meant for people who want to view first matched part.
871 For `undisplayed-alternative' (default), the first undisplayed
872 part or alternative part is used. For `undisplayed', the first
873 undisplayed part is used. For a function, the first part which
874 the function return t is used. For nil, the first part is
877 :group 'gnus-article-mime
879 (item :tag "first" :value nil)
880 (item :tag "undisplayed" :value undisplayed)
881 (item :tag "undisplayed or alternative"
882 :value undisplayed-alternative)
885 (defcustom gnus-mime-action-alist
886 '(("save to file" . gnus-mime-save-part)
887 ("save and strip" . gnus-mime-save-part-and-strip)
888 ("delete part" . gnus-mime-delete-part)
889 ("display as text" . gnus-mime-inline-part)
890 ("view the part" . gnus-mime-view-part)
891 ("pipe to command" . gnus-mime-pipe-part)
892 ("toggle display" . gnus-article-press-button)
893 ("toggle display" . gnus-article-view-part-as-charset)
894 ("view as type" . gnus-mime-view-part-as-type)
895 ("view internally" . gnus-mime-view-part-internally)
896 ("view externally" . gnus-mime-view-part-externally))
897 "An alist of actions that run on the MIME attachment."
898 :group 'gnus-article-mime
899 :type '(repeat (cons (string :tag "name")
903 ;;; The treatment variables
906 (defvar gnus-part-display-hook nil
907 "Hook called on parts that are to receive treatment.")
909 (defvar gnus-article-treat-custom
910 '(choice (const :tag "Off" nil)
912 (const :tag "Header" head)
913 (const :tag "Last" last)
914 (const :tag "Mime" mime)
915 (integer :tag "Less")
916 (repeat :tag "Groups" regexp)
917 (sexp :tag "Predicate")))
919 (defvar gnus-article-treat-head-custom
920 '(choice (const :tag "Off" nil)
921 (const :tag "Header" head)))
923 (defvar gnus-article-treat-types '("text/plain")
926 (defvar gnus-inhibit-treatment nil
927 "Whether to inhibit treatment.")
929 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
930 "Highlight the signature.
931 Valid values are nil, t, `head', `last', an integer or a predicate.
932 See Info node `(gnus)Customizing Articles'."
933 :group 'gnus-article-treat
934 :link '(custom-manual "(gnus)Customizing Articles")
935 :type gnus-article-treat-custom)
936 (put 'gnus-treat-highlight-signature 'highlight t)
938 (defcustom gnus-treat-buttonize 100000
940 Valid values are nil, t, `head', `last', an integer or a predicate.
941 See Info node `(gnus)Customizing Articles'."
942 :group 'gnus-article-treat
943 :link '(custom-manual "(gnus)Customizing Articles")
944 :type gnus-article-treat-custom)
945 (put 'gnus-treat-buttonize 'highlight t)
947 (defcustom gnus-treat-buttonize-head 'head
948 "Add buttons to the head.
949 Valid values are nil, t, `head', `last', an integer or a predicate.
950 See Info node `(gnus)Customizing Articles' for details."
951 :group 'gnus-article-treat
952 :link '(custom-manual "(gnus)Customizing Articles")
953 :type gnus-article-treat-head-custom)
954 (put 'gnus-treat-buttonize-head 'highlight t)
956 (defcustom gnus-treat-emphasize
957 (and (or window-system
961 Valid values are nil, t, `head', `last', an integer or a predicate.
962 See Info node `(gnus)Customizing Articles' for details."
963 :group 'gnus-article-treat
964 :link '(custom-manual "(gnus)Customizing Articles")
965 :type gnus-article-treat-custom)
966 (put 'gnus-treat-emphasize 'highlight t)
968 (defcustom gnus-treat-strip-cr nil
969 "Remove carriage returns.
970 Valid values are nil, t, `head', `last', an integer or a predicate.
971 See Info node `(gnus)Customizing Articles' for details."
973 :group 'gnus-article-treat
974 :link '(custom-manual "(gnus)Customizing Articles")
975 :type gnus-article-treat-custom)
977 (defcustom gnus-treat-unsplit-urls nil
978 "Remove newlines from within URLs.
979 Valid values are nil, t, `head', `last', an integer or a predicate.
980 See Info node `(gnus)Customizing Articles' for details."
981 :group 'gnus-article-treat
982 :link '(custom-manual "(gnus)Customizing Articles")
983 :type gnus-article-treat-custom)
985 (defcustom gnus-treat-leading-whitespace nil
986 "Remove leading whitespace in headers.
987 Valid values are nil, t, `head', `last', an integer or a predicate.
988 See Info node `(gnus)Customizing Articles' for details."
990 :group 'gnus-article-treat
991 :link '(custom-manual "(gnus)Customizing Articles")
992 :type gnus-article-treat-custom)
994 (defcustom gnus-treat-hide-headers 'head
996 Valid values are nil, t, `head', `last', an integer or a predicate.
997 See Info node `(gnus)Customizing Articles' for details."
998 :group 'gnus-article-treat
999 :link '(custom-manual "(gnus)Customizing Articles")
1000 :type gnus-article-treat-head-custom)
1002 (defcustom gnus-treat-hide-boring-headers nil
1003 "Hide boring headers.
1004 Valid values are nil, t, `head', `last', an integer or a predicate.
1005 See Info node `(gnus)Customizing Articles' for details."
1006 :group 'gnus-article-treat
1007 :link '(custom-manual "(gnus)Customizing Articles")
1008 :type gnus-article-treat-head-custom)
1010 (defcustom gnus-treat-hide-signature nil
1011 "Hide the signature.
1012 Valid values are nil, t, `head', `last', an integer or a predicate.
1013 See Info node `(gnus)Customizing Articles' for details."
1014 :group 'gnus-article-treat
1015 :link '(custom-manual "(gnus)Customizing Articles")
1016 :type gnus-article-treat-custom)
1018 (defcustom gnus-treat-fill-article nil
1020 Valid values are nil, t, `head', `last', an integer or a predicate.
1021 See Info node `(gnus)Customizing Articles' for details."
1022 :group 'gnus-article-treat
1023 :link '(custom-manual "(gnus)Customizing Articles")
1024 :type gnus-article-treat-custom)
1026 (defcustom gnus-treat-hide-citation nil
1028 Valid values are nil, t, `head', `last', an integer or a predicate.
1029 See Info node `(gnus)Customizing Articles' for details."
1030 :group 'gnus-article-treat
1031 :link '(custom-manual "(gnus)Customizing Articles")
1032 :type gnus-article-treat-custom)
1034 (defcustom gnus-treat-hide-citation-maybe nil
1036 Valid values are nil, t, `head', `last', an integer or a predicate.
1037 See Info node `(gnus)Customizing Articles' for details."
1038 :group 'gnus-article-treat
1039 :link '(custom-manual "(gnus)Customizing Articles")
1040 :type gnus-article-treat-custom)
1042 (defcustom gnus-treat-strip-list-identifiers 'head
1043 "Strip list identifiers from `gnus-list-identifiers`.
1044 Valid values are nil, t, `head', `last', an integer or a predicate.
1045 See Info node `(gnus)Customizing Articles' for details."
1047 :group 'gnus-article-treat
1048 :link '(custom-manual "(gnus)Customizing Articles")
1049 :type gnus-article-treat-custom)
1051 (make-obsolete-variable 'gnus-treat-strip-pgp
1052 "This option is obsolete in Gnus 5.10.")
1054 (defcustom gnus-treat-strip-pem nil
1055 "Strip PEM signatures.
1056 Valid values are nil, t, `head', `last', an integer or a predicate.
1057 See Info node `(gnus)Customizing Articles' for details."
1058 :group 'gnus-article-treat
1059 :link '(custom-manual "(gnus)Customizing Articles")
1060 :type gnus-article-treat-custom)
1062 (defcustom gnus-treat-strip-banner t
1063 "Strip banners from articles.
1064 The banner to be stripped is specified in the `banner' group parameter.
1065 Valid values are nil, t, `head', `last', an integer or a predicate.
1066 See Info node `(gnus)Customizing Articles' for details."
1067 :group 'gnus-article-treat
1068 :link '(custom-manual "(gnus)Customizing Articles")
1069 :type gnus-article-treat-custom)
1071 (defcustom gnus-treat-highlight-headers 'head
1072 "Highlight the headers.
1073 Valid values are nil, t, `head', `last', an integer or a predicate.
1074 See Info node `(gnus)Customizing Articles' for details."
1075 :group 'gnus-article-treat
1076 :link '(custom-manual "(gnus)Customizing Articles")
1077 :type gnus-article-treat-head-custom)
1078 (put 'gnus-treat-highlight-headers 'highlight t)
1080 (defcustom gnus-treat-highlight-citation t
1081 "Highlight cited text.
1082 Valid values are nil, t, `head', `last', an integer or a predicate.
1083 See Info node `(gnus)Customizing Articles' for details."
1084 :group 'gnus-article-treat
1085 :link '(custom-manual "(gnus)Customizing Articles")
1086 :type gnus-article-treat-custom)
1087 (put 'gnus-treat-highlight-citation 'highlight t)
1089 (defcustom gnus-treat-date-ut nil
1090 "Display the Date in UT (GMT).
1091 Valid values are nil, t, `head', `last', an integer or a predicate.
1092 See Info node `(gnus)Customizing Articles' for details."
1093 :group 'gnus-article-treat
1094 :link '(custom-manual "(gnus)Customizing Articles")
1095 :type gnus-article-treat-head-custom)
1097 (defcustom gnus-treat-date-local nil
1098 "Display the Date in the local timezone.
1099 Valid values are nil, t, `head', `last', an integer or a predicate.
1100 See Info node `(gnus)Customizing Articles' for details."
1101 :group 'gnus-article-treat
1102 :link '(custom-manual "(gnus)Customizing Articles")
1103 :type gnus-article-treat-head-custom)
1105 (defcustom gnus-treat-date-english nil
1106 "Display the Date in a format that can be read aloud in English.
1107 Valid values are nil, t, `head', `last', an integer or a predicate.
1108 See Info node `(gnus)Customizing Articles' for details."
1110 :group 'gnus-article-treat
1111 :link '(custom-manual "(gnus)Customizing Articles")
1112 :type gnus-article-treat-head-custom)
1114 (defcustom gnus-treat-date-lapsed nil
1115 "Display the Date header in a way that says how much time has elapsed.
1116 Valid values are nil, t, `head', `last', an integer or a predicate.
1117 See Info node `(gnus)Customizing Articles' for details."
1118 :group 'gnus-article-treat
1119 :link '(custom-manual "(gnus)Customizing Articles")
1120 :type gnus-article-treat-head-custom)
1122 (defcustom gnus-treat-date-original nil
1123 "Display the date in the original timezone.
1124 Valid values are nil, t, `head', `last', an integer or a predicate.
1125 See Info node `(gnus)Customizing Articles' for details."
1126 :group 'gnus-article-treat
1127 :link '(custom-manual "(gnus)Customizing Articles")
1128 :type gnus-article-treat-head-custom)
1130 (defcustom gnus-treat-date-iso8601 nil
1131 "Display the date in the ISO8601 format.
1132 Valid values are nil, t, `head', `last', an integer or a predicate.
1133 See Info node `(gnus)Customizing Articles' for details."
1135 :group 'gnus-article-treat
1136 :link '(custom-manual "(gnus)Customizing Articles")
1137 :type gnus-article-treat-head-custom)
1139 (defcustom gnus-treat-date-user-defined nil
1140 "Display the date in a user-defined format.
1141 The format is defined by the `gnus-article-time-format' variable.
1142 Valid values are nil, t, `head', `last', an integer or a predicate.
1143 See Info node `(gnus)Customizing Articles' for details."
1144 :group 'gnus-article-treat
1145 :link '(custom-manual "(gnus)Customizing Articles")
1146 :type gnus-article-treat-head-custom)
1148 (defcustom gnus-treat-strip-headers-in-body t
1149 "Strip the X-No-Archive header line from the beginning of the body.
1150 Valid values are nil, t, `head', `last', an integer or a predicate.
1151 See Info node `(gnus)Customizing Articles' for details."
1153 :group 'gnus-article-treat
1154 :link '(custom-manual "(gnus)Customizing Articles")
1155 :type gnus-article-treat-custom)
1157 (defcustom gnus-treat-strip-trailing-blank-lines nil
1158 "Strip trailing blank lines.
1159 Valid values are nil, t, `head', `last', an integer or a predicate.
1160 See Info node `(gnus)Customizing Articles' for details."
1161 :group 'gnus-article-treat
1162 :link '(custom-manual "(gnus)Customizing Articles")
1163 :type gnus-article-treat-custom)
1165 (defcustom gnus-treat-strip-leading-blank-lines nil
1166 "Strip leading blank lines.
1167 Valid values are nil, t, `head', `last', an integer or a predicate.
1168 See Info node `(gnus)Customizing Articles' for details."
1169 :group 'gnus-article-treat
1170 :link '(custom-manual "(gnus)Customizing Articles")
1171 :type gnus-article-treat-custom)
1173 (defcustom gnus-treat-strip-multiple-blank-lines nil
1174 "Strip multiple blank lines.
1175 Valid values are nil, t, `head', `last', an integer or a predicate.
1176 See Info node `(gnus)Customizing Articles' for details."
1177 :group 'gnus-article-treat
1178 :link '(custom-manual "(gnus)Customizing Articles")
1179 :type gnus-article-treat-custom)
1181 (defcustom gnus-treat-unfold-headers 'head
1182 "Unfold folded header lines.
1183 Valid values are nil, t, `head', `last', an integer or a predicate.
1184 See Info node `(gnus)Customizing Articles' for details."
1185 :group 'gnus-article-treat
1186 :link '(custom-manual "(gnus)Customizing Articles")
1187 :type gnus-article-treat-custom)
1189 (defcustom gnus-treat-fold-headers nil
1191 Valid values are nil, t, `head', `last', an integer or a predicate.
1192 See Info node `(gnus)Customizing Articles' for details."
1194 :group 'gnus-article-treat
1195 :link '(custom-manual "(gnus)Customizing Articles")
1196 :type gnus-article-treat-custom)
1198 (defcustom gnus-treat-fold-newsgroups 'head
1199 "Fold the Newsgroups and Followup-To headers.
1200 Valid values are nil, t, `head', `last', an integer or a predicate.
1201 See Info node `(gnus)Customizing Articles' for details."
1203 :group 'gnus-article-treat
1204 :link '(custom-manual "(gnus)Customizing Articles")
1205 :type gnus-article-treat-custom)
1207 (defcustom gnus-treat-overstrike t
1208 "Treat overstrike highlighting.
1209 Valid values are nil, t, `head', `last', an integer or a predicate.
1210 See Info node `(gnus)Customizing Articles' for details."
1211 :group 'gnus-article-treat
1212 :link '(custom-manual "(gnus)Customizing Articles")
1213 :type gnus-article-treat-custom)
1214 (put 'gnus-treat-overstrike 'highlight t)
1216 (defcustom gnus-treat-ansi-sequences (if (locate-library "ansi-color") t)
1217 "Treat ANSI SGR control sequences.
1218 Valid values are nil, t, `head', `last', an integer or a predicate.
1219 See Info node `(gnus)Customizing Articles' for details."
1220 :group 'gnus-article-treat
1221 :link '(custom-manual "(gnus)Customizing Articles")
1222 :type gnus-article-treat-custom)
1224 (make-obsolete-variable 'gnus-treat-display-xface
1225 'gnus-treat-display-x-face)
1227 (defcustom gnus-treat-display-x-face
1228 (and (not noninteractive)
1229 (or (eq gnus-article-x-face-command
1230 'x-face-mule-gnus-article-display-x-face)
1231 (and (fboundp 'image-type-available-p)
1232 (image-type-available-p 'xbm)
1233 (string-match "^0x" (shell-command-to-string "uncompface"))
1234 (executable-find "icontopbm"))
1235 (and (featurep 'xemacs)
1238 "Display X-Face headers.
1239 Valid values are nil, t, `head', `last', an integer or a predicate.
1240 See Info node `(gnus)Customizing Articles' and Info node
1241 `(gnus)X-Face' for details."
1242 :group 'gnus-article-treat
1244 :link '(custom-manual "(gnus)Customizing Articles")
1245 :link '(custom-manual "(gnus)X-Face")
1246 :type gnus-article-treat-head-custom
1247 :set (lambda (symbol value)
1250 (cond ((or (boundp symbol) (get symbol 'saved-value))
1252 ((boundp 'gnus-treat-display-xface)
1254 ** gnus-treat-display-xface is an obsolete variable;\
1255 use gnus-treat-display-x-face instead")
1256 (default-value 'gnus-treat-display-xface))
1257 ((get 'gnus-treat-display-xface 'saved-value)
1259 ** gnus-treat-display-xface is an obsolete variable;\
1260 use gnus-treat-display-x-face instead")
1261 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1264 (put 'gnus-treat-display-x-face 'highlight t)
1266 (defcustom gnus-article-should-use-smiley-mule
1267 (not (or (featurep 'xemacs)
1268 (gnus-image-type-available-p 'xpm)
1269 (gnus-image-type-available-p 'pbm)))
1270 "Non-nil means use `smiley-mule' to show smileys rather than `smiley'.
1271 `smiley-mule' is boundled in BITMAP-MULE package. You can set it to t
1272 even if your Emacs supports images. It has no effect on XEmacs."
1273 :group 'gnus-article-various
1275 :get (lambda (symbol)
1276 (and (not noninteractive)
1277 (default-value symbol)
1278 (not (featurep 'xemacs))
1279 (module-installed-p 'smiley-mule)
1281 :set (lambda (symbol value)
1282 (set-default symbol (and (not noninteractive)
1284 (not (featurep 'xemacs))
1285 (module-installed-p 'smiley-mule)
1288 (defvar gnus-article-smiley-mule-loaded-p nil
1289 "Internal variable used to say whether `smiley-mule' is loaded (whether
1290 smiley functions are not overridden by `smiley').")
1292 (defcustom gnus-treat-display-face
1293 (and (not noninteractive)
1294 (or (and (fboundp 'image-type-available-p)
1295 (image-type-available-p 'png))
1296 (and (featurep 'xemacs)
1299 "Display Face headers.
1300 Valid values are nil, t, `head', `last', an integer or a predicate.
1301 See Info node `(gnus)Customizing Articles' and Info node
1302 `(gnus)X-Face' for details."
1303 :group 'gnus-article-treat
1305 :link '(custom-manual "(gnus)Customizing Articles")
1306 :link '(custom-manual "(gnus)X-Face")
1307 :type gnus-article-treat-head-custom)
1308 (put 'gnus-treat-display-face 'highlight t)
1310 (defcustom gnus-treat-display-smileys
1311 (if (and (not noninteractive)
1312 (or (and (featurep 'xemacs)
1314 (gnus-image-type-available-p 'xpm)
1315 (gnus-image-type-available-p 'pbm)
1316 (and (not (featurep 'xemacs))
1318 (module-installed-p 'smiley-mule))))
1322 Valid values are nil, t, `head', `last', an integer or a predicate.
1323 See Info node `(gnus)Customizing Articles' and Info node
1324 `(gnus)Smileys' for details."
1325 :group 'gnus-article-treat
1327 :link '(custom-manual "(gnus)Customizing Articles")
1328 :link '(custom-manual "(gnus)Smileys")
1329 :type gnus-article-treat-custom)
1330 (put 'gnus-treat-display-smileys 'highlight t)
1332 (defcustom gnus-treat-from-picon
1333 (if (and (gnus-image-type-available-p 'xpm)
1334 (gnus-picons-installed-p))
1336 "Display picons in the From header.
1337 Valid values are nil, t, `head', `last', an integer or a predicate.
1338 See Info node `(gnus)Customizing Articles' and Info node
1339 `(gnus)Picons' for details."
1340 :group 'gnus-article-treat
1342 :link '(custom-manual "(gnus)Customizing Articles")
1343 :link '(custom-manual "(gnus)Picons")
1344 :type gnus-article-treat-head-custom)
1345 (put 'gnus-treat-from-picon 'highlight t)
1347 (defcustom gnus-treat-mail-picon
1348 (if (and (gnus-image-type-available-p 'xpm)
1349 (gnus-picons-installed-p))
1351 "Display picons in To and Cc headers.
1352 Valid values are nil, t, `head', `last', an integer or a predicate.
1353 See Info node `(gnus)Customizing Articles' and Info node
1354 `(gnus)Picons' for details."
1355 :group 'gnus-article-treat
1357 :link '(custom-manual "(gnus)Customizing Articles")
1358 :link '(custom-manual "(gnus)Picons")
1359 :type gnus-article-treat-head-custom)
1360 (put 'gnus-treat-mail-picon 'highlight t)
1362 (defcustom gnus-treat-newsgroups-picon
1363 (if (and (gnus-image-type-available-p 'xpm)
1364 (gnus-picons-installed-p))
1366 "Display picons in the Newsgroups and Followup-To headers.
1367 Valid values are nil, t, `head', `last', an integer or a predicate.
1368 See Info node `(gnus)Customizing Articles' and Info node
1369 `(gnus)Picons' for details."
1371 :group 'gnus-article-treat
1373 :link '(custom-manual "(gnus)Customizing Articles")
1374 :link '(custom-manual "(gnus)Picons")
1375 :type gnus-article-treat-head-custom)
1376 (put 'gnus-treat-newsgroups-picon 'highlight t)
1378 (defcustom gnus-treat-body-boundary
1379 (if (and (eq window-system 'x)
1380 (or gnus-treat-newsgroups-picon
1381 gnus-treat-mail-picon
1382 gnus-treat-from-picon))
1384 "Draw a boundary at the end of the headers.
1385 Valid values are nil and `head'.
1386 See Info node `(gnus)Customizing Articles' for details."
1388 :group 'gnus-article-treat
1389 :link '(custom-manual "(gnus)Customizing Articles")
1390 :type gnus-article-treat-head-custom)
1392 (defcustom gnus-treat-capitalize-sentences nil
1393 "Capitalize sentence-starting words.
1394 Valid values are nil, t, `head', `last', an integer or a predicate.
1395 See Info node `(gnus)Customizing Articles' for details."
1397 :group 'gnus-article-treat
1398 :link '(custom-manual "(gnus)Customizing Articles")
1399 :type gnus-article-treat-custom)
1401 (defcustom gnus-treat-wash-html nil
1403 Valid values are nil, t, `head', `last', an integer or a predicate.
1404 See Info node `(gnus)Customizing Articles' for details."
1406 :group 'gnus-article-treat
1407 :link '(custom-manual "(gnus)Customizing Articles")
1408 :type gnus-article-treat-custom)
1410 (defcustom gnus-treat-fill-long-lines nil
1412 Valid values are nil, t, `head', `last', an integer or a predicate.
1413 See Info node `(gnus)Customizing Articles' for details."
1414 :group 'gnus-article-treat
1415 :link '(custom-manual "(gnus)Customizing Articles")
1416 :type gnus-article-treat-custom)
1418 (defcustom gnus-treat-play-sounds nil
1420 Valid values are nil, t, `head', `last', an integer or a predicate.
1421 See Info node `(gnus)Customizing Articles' for details."
1423 :group 'gnus-article-treat
1424 :link '(custom-manual "(gnus)Customizing Articles")
1425 :type gnus-article-treat-custom)
1427 (defcustom gnus-treat-decode-article-as-default-mime-charset nil
1428 "Decode an article as `default-mime-charset'. For instance, if you want to
1429 attempt to decode an article even if the value of `gnus-show-mime' is nil,
1430 you could set this variable to something like: nil for don't decode, t for
1431 decode the body, '(or header t) for the whole article, etc."
1432 :group 'gnus-article-treat
1433 :type '(radio (const :tag "Off" nil)
1434 (const :tag "Decode body" t)
1435 (const :tag "Decode all" (or head t))))
1437 (defcustom gnus-treat-translate nil
1438 "Translate articles from one language to another.
1439 Valid values are nil, t, `head', `last', an integer or a predicate.
1440 See Info node `(gnus)Customizing Articles' for details."
1442 :group 'gnus-article-treat
1443 :link '(custom-manual "(gnus)Customizing Articles")
1444 :type gnus-article-treat-custom)
1446 (defcustom gnus-treat-x-pgp-sig nil
1448 To automatically treat X-PGP-Sig, set it to head.
1449 Valid values are nil, t, `head', `last', an integer or a predicate.
1450 See Info node `(gnus)Customizing Articles' for details."
1451 :group 'gnus-article-treat
1452 :group 'mime-security
1453 :type gnus-article-treat-custom)
1455 (defcustom gnus-treat-monafy nil
1456 "Display body part with mona font.
1457 Valid values are nil, t, `head', `last', an integer or a predicate.
1458 See Info node `(gnus)Customizing Articles' for details."
1459 :group 'gnus-article-treat
1460 :group 'mime-security
1461 :link '(custom-manual "(gnus)Customizing Articles")
1462 :type gnus-article-treat-custom)
1464 (defvar gnus-article-encrypt-protocol-alist
1465 '(("PGP" . mml2015-self-encrypt)))
1467 ;; Set to nil if more than one protocol added to
1468 ;; gnus-article-encrypt-protocol-alist.
1469 (defcustom gnus-article-encrypt-protocol "PGP"
1470 "The protocol used for encrypt articles.
1471 It is a string, such as \"PGP\". If nil, ask user."
1474 :group 'mime-security)
1476 (defvar gnus-article-wash-function nil
1477 "Function used for converting HTML into text.")
1479 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1480 (mm-coding-system-p 'utf-8)
1481 (executable-find idna-program))
1482 "Whether IDNA decoding of headers is used when viewing messages.
1483 This requires GNU Libidn, and by default only enabled if it is found."
1485 :group 'gnus-article-headers
1488 (defcustom gnus-article-over-scroll nil
1489 "If non-nil, allow scrolling the article buffer even when there no more text."
1491 :group 'gnus-article
1494 ;;; Internal variables
1496 (defvar gnus-english-month-names
1497 '("January" "February" "March" "April" "May" "June" "July" "August"
1498 "September" "October" "November" "December"))
1500 (defvar gnus-button-regexp nil)
1501 (defvar gnus-button-marker-list nil)
1502 ;; Regexp matching any of the regexps from `gnus-button-alist'.
1504 (defvar gnus-button-last nil)
1505 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
1507 (defvar article-goto-body-goes-to-point-min-p nil)
1508 (defvar gnus-article-wash-types nil)
1509 (defvar gnus-article-emphasis-alist nil)
1510 (defvar gnus-article-image-alist nil)
1512 (defvar gnus-article-mime-handle-alist-1 nil)
1513 (defvar gnus-treatment-function-alist
1514 '((gnus-treat-decode-article-as-default-mime-charset
1515 gnus-article-decode-article-as-default-mime-charset)
1516 (gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1517 (gnus-treat-monafy gnus-article-monafy)
1518 (gnus-treat-strip-banner gnus-article-strip-banner)
1519 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1520 (gnus-treat-buttonize gnus-article-add-buttons)
1521 (gnus-treat-fill-article gnus-article-fill-cited-article)
1522 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1523 (gnus-treat-strip-cr gnus-article-remove-cr)
1524 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1525 (gnus-treat-date-ut gnus-article-date-ut)
1526 (gnus-treat-date-local gnus-article-date-local)
1527 (gnus-treat-date-english gnus-article-date-english)
1528 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1529 (gnus-treat-date-original gnus-article-date-original)
1530 (gnus-treat-date-user-defined gnus-article-date-user)
1531 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1532 (gnus-treat-display-face gnus-article-display-face)
1533 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1534 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1535 (gnus-treat-hide-signature gnus-article-hide-signature)
1536 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1537 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1538 (gnus-treat-strip-pem gnus-article-hide-pem)
1539 (gnus-treat-from-picon gnus-treat-from-picon)
1540 (gnus-treat-mail-picon gnus-treat-mail-picon)
1541 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1542 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1543 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1544 (gnus-treat-strip-trailing-blank-lines
1545 gnus-article-remove-trailing-blank-lines)
1546 (gnus-treat-strip-leading-blank-lines
1547 gnus-article-strip-leading-blank-lines)
1548 (gnus-treat-strip-multiple-blank-lines
1549 gnus-article-strip-multiple-blank-lines)
1550 (gnus-treat-overstrike gnus-article-treat-overstrike)
1551 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences)
1552 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1553 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1554 ;; Displaying X-Face should be done after unfolding headers
1555 ;; to protect bitmap lines.
1556 (gnus-treat-display-x-face gnus-article-display-x-face)
1557 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1558 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1559 (gnus-treat-display-smileys gnus-treat-smiley)
1560 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1561 (gnus-treat-wash-html gnus-article-wash-html)
1562 (gnus-treat-emphasize gnus-article-emphasize)
1563 (gnus-treat-hide-citation gnus-article-hide-citation)
1564 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1565 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1566 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1567 (gnus-treat-play-sounds gnus-earcon-display)))
1569 (defvar gnus-article-mime-handle-alist nil)
1570 (defvar article-lapsed-timer nil)
1571 (defvar gnus-article-current-summary nil)
1573 (defvar gnus-article-mode-syntax-table
1574 (let ((table (copy-syntax-table text-mode-syntax-table)))
1575 ;; This causes the citation match run O(2^n).
1576 ;; (modify-syntax-entry ?- "w" table)
1577 (modify-syntax-entry ?> ")<" table)
1578 (modify-syntax-entry ?< "(>" table)
1579 ;; make M-. in article buffers work for `foo' strings
1580 (modify-syntax-entry ?' " " table)
1581 (modify-syntax-entry ?` " " table)
1583 "Syntax table used in article mode buffers.
1584 Initialized from `text-mode-syntax-table.")
1586 (defvar gnus-save-article-buffer nil)
1588 (defvar gnus-article-mode-line-format-alist
1589 (nconc '((?w (gnus-article-wash-status) ?s)
1590 (?m (gnus-article-mime-part-status) ?s))
1591 gnus-summary-mode-line-format-alist))
1593 (defvar gnus-number-of-articles-to-be-saved nil)
1595 (defvar gnus-inhibit-hiding nil)
1597 (defvar gnus-article-edit-mode nil)
1599 ;;; Macros for dealing with the article buffer.
1601 (defmacro gnus-with-article-headers (&rest forms)
1603 (set-buffer gnus-article-buffer)
1605 (let ((inhibit-read-only t)
1606 (inhibit-point-motion-hooks t)
1607 (case-fold-search t))
1608 (article-narrow-to-head)
1611 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1612 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1614 (defmacro gnus-with-article-buffer (&rest forms)
1616 (set-buffer gnus-article-buffer)
1617 (let ((inhibit-read-only t))
1620 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1621 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1623 (defun gnus-article-goto-header (header)
1624 "Go to HEADER, which is a regular expression."
1625 (re-search-forward (concat "^\\(" header "\\):") nil t))
1627 (defsubst gnus-article-hide-text (b e props)
1628 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1629 (gnus-add-text-properties-when 'article-type nil b e props)
1630 (when (memq 'intangible props)
1632 (max (1- b) (point-min))
1633 b 'intangible (cddr (memq 'intangible props)))))
1635 (defsubst gnus-article-unhide-text (b e)
1636 "Remove hidden text properties from region between B and E."
1637 (remove-text-properties b e gnus-hidden-properties)
1638 (when (memq 'intangible gnus-hidden-properties)
1639 (put-text-property (max (1- b) (point-min))
1640 b 'intangible nil)))
1642 (defun gnus-article-hide-text-type (b e type)
1643 "Hide text of TYPE between B and E."
1644 (gnus-add-wash-type type)
1645 (gnus-article-hide-text
1646 b e (cons 'article-type (cons type gnus-hidden-properties))))
1648 (defun gnus-article-unhide-text-type (b e type)
1649 "Unhide text of TYPE between B and E."
1650 (gnus-delete-wash-type type)
1651 (remove-text-properties
1652 b e (cons 'article-type (cons type gnus-hidden-properties)))
1653 (when (memq 'intangible gnus-hidden-properties)
1654 (put-text-property (max (1- b) (point-min))
1655 b 'intangible nil)))
1657 (defun gnus-article-hide-text-of-type (type)
1658 "Hide text of TYPE in the current buffer."
1660 (let ((b (point-min))
1662 (while (setq b (text-property-any b e 'article-type type))
1663 (add-text-properties b (incf b) gnus-hidden-properties)))))
1665 (defun gnus-article-delete-text-of-type (type)
1666 "Delete text of TYPE in the current buffer."
1668 (let ((b (point-min)))
1669 (while (setq b (text-property-any b (point-max) 'article-type type))
1671 b (or (text-property-not-all b (point-max) 'article-type type)
1674 (defun gnus-article-delete-invisible-text ()
1675 "Delete all invisible text in the current buffer."
1677 (let ((b (point-min)))
1678 (while (setq b (text-property-any b (point-max) 'invisible t))
1680 b (or (text-property-not-all b (point-max) 'invisible t)
1683 (defun gnus-article-text-type-exists-p (type)
1684 "Say whether any text of type TYPE exists in the buffer."
1685 (text-property-any (point-min) (point-max) 'article-type type))
1687 (defsubst gnus-article-header-rank ()
1688 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1689 (let ((list gnus-sorted-header-list)
1692 (if (looking-at (car list))
1694 (setq list (cdr list))
1698 (defun article-hide-headers (&optional arg delete)
1699 "Hide unwanted headers and possibly sort them as well."
1700 (interactive (gnus-article-hidden-arg))
1701 ;; Lars said that this function might be inhibited.
1702 (if (gnus-article-check-hidden-text 'headers arg)
1704 ;; Show boring headers as well.
1705 (gnus-article-show-hidden-text 'boring-headers)
1706 (when (eq 1 (point-min))
1707 (set-window-start (get-buffer-window (current-buffer)) 1)))
1708 (unless gnus-inhibit-hiding
1709 (let ((inhibit-read-only t)
1710 (case-fold-search t)
1711 (max (1+ (length gnus-sorted-header-list)))
1712 (inhibit-point-motion-hooks t)
1713 (cur (current-buffer))
1714 ignored visible beg)
1716 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1717 ;; group parameters, so we should go to the summary buffer.
1720 (progn (set-buffer gnus-summary-buffer) t)
1722 (setq ignored (when (not gnus-visible-headers)
1723 (cond ((stringp gnus-ignored-headers)
1724 gnus-ignored-headers)
1725 ((listp gnus-ignored-headers)
1726 (mapconcat 'identity
1727 gnus-ignored-headers
1729 visible (cond ((stringp gnus-visible-headers)
1730 gnus-visible-headers)
1731 ((and gnus-visible-headers
1732 (listp gnus-visible-headers))
1733 (mapconcat 'identity
1734 gnus-visible-headers
1738 ;; First we narrow to just the headers.
1739 (article-narrow-to-head)
1740 ;; Hide any "From " lines at the beginning of (mail) articles.
1741 (while (looking-at "From ")
1745 (delete-region (point-min) (point))
1746 (gnus-article-hide-text (point-min) (point)
1747 (nconc (list 'article-type 'headers)
1748 gnus-hidden-properties))))
1749 ;; Then treat the rest of the header lines.
1750 ;; Then we use the two regular expressions
1751 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1752 ;; select which header lines is to remain visible in the
1754 (while (re-search-forward "^[^ \t:]*:" nil t)
1756 ;; Mark the rank of the header.
1758 (point) (1+ (point)) 'message-rank
1759 (if (or (and visible (looking-at visible))
1761 (not (looking-at ignored))))
1762 (gnus-article-header-rank)
1765 (message-sort-headers-1)
1766 (when (setq beg (text-property-any
1767 (point-min) (point-max) 'message-rank (+ 2 max)))
1768 ;; We delete or make invisible the unwanted headers.
1769 (gnus-add-wash-type 'headers)
1772 (add-text-properties
1773 (point-min) (+ 5 (point-min))
1774 '(article-type headers dummy-invisible t))
1775 (delete-region beg (point-max)))
1776 (gnus-article-hide-text-type beg (point-max) 'headers)))))))))
1778 (defun article-hide-boring-headers (&optional arg)
1779 "Toggle hiding of headers that aren't very interesting.
1780 If given a negative prefix, always show; if given a positive prefix,
1782 (interactive (gnus-article-hidden-arg))
1783 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1784 (not gnus-show-all-headers))
1787 (let ((inhibit-read-only t)
1788 (inhibit-point-motion-hooks t))
1789 (article-narrow-to-head)
1790 (dolist (elem gnus-boring-article-headers)
1791 (goto-char (point-min))
1793 ;; Hide empty headers.
1795 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1797 (gnus-article-hide-text-type
1801 (if (re-search-forward "^[^ \t]" nil t)
1805 ;; Hide boring Newsgroups header.
1806 ((eq elem 'newsgroups)
1807 (when (gnus-string-equal
1808 (gnus-fetch-field "newsgroups")
1809 (gnus-group-real-name
1810 (if (boundp 'gnus-newsgroup-name)
1813 (gnus-article-hide-header "newsgroups")))
1814 ((eq elem 'to-address)
1815 (let ((to (message-fetch-field "to"))
1817 (gnus-parameter-to-address
1818 (if (boundp 'gnus-newsgroup-name)
1819 gnus-newsgroup-name ""))))
1820 (when (and to to-address
1823 ;; only one address in To
1824 (nth 1 (mail-extract-address-components to))
1826 (gnus-article-hide-header "to"))))
1828 (let ((to (message-fetch-field "to"))
1830 (gnus-parameter-to-list
1831 (if (boundp 'gnus-newsgroup-name)
1832 gnus-newsgroup-name ""))))
1833 (when (and to to-list
1836 ;; only one address in To
1837 (nth 1 (mail-extract-address-components to))
1839 (gnus-article-hide-header "to"))))
1841 (let ((cc (message-fetch-field "cc"))
1843 (gnus-parameter-to-list
1844 (if (boundp 'gnus-newsgroup-name)
1845 gnus-newsgroup-name ""))))
1846 (when (and cc to-list
1849 ;; only one address in CC
1850 (nth 1 (mail-extract-address-components cc))
1852 (gnus-article-hide-header "cc"))))
1853 ((eq elem 'followup-to)
1854 (when (gnus-string-equal
1855 (message-fetch-field "followup-to")
1856 (message-fetch-field "newsgroups"))
1857 (gnus-article-hide-header "followup-to")))
1858 ((eq elem 'reply-to)
1859 (if (gnus-group-find-parameter
1860 gnus-newsgroup-name 'broken-reply-to)
1861 (gnus-article-hide-header "reply-to")
1862 (let ((from (message-fetch-field "from"))
1863 (reply-to (message-fetch-field "reply-to")))
1870 (lambda (x) (downcase (cadr x)))
1871 (mail-extract-address-components from t))
1874 (lambda (x) (downcase (cadr x)))
1875 (mail-extract-address-components reply-to t))
1877 (gnus-article-hide-header "reply-to")))))
1879 (let ((date (message-fetch-field "date")))
1881 (< (days-between (current-time-string) date)
1883 (gnus-article-hide-header "date"))))
1885 (let ((to (message-fetch-field "to"))
1886 (cc (message-fetch-field "cc")))
1887 (when (> (length to) 1024)
1888 (gnus-article-hide-header "to"))
1889 (when (> (length cc) 1024)
1890 (gnus-article-hide-header "cc"))))
1894 (goto-char (point-min))
1895 (while (re-search-forward "^to:" nil t)
1896 (setq to-count (1+ to-count)))
1897 (when (> to-count 1)
1898 (while (> to-count 0)
1899 (goto-char (point-min))
1901 (re-search-forward "^to:" nil nil to-count)
1903 (narrow-to-region (point) (point-max))
1904 (gnus-article-hide-header "to"))
1905 (setq to-count (1- to-count))))
1906 (goto-char (point-min))
1907 (while (re-search-forward "^cc:" nil t)
1908 (setq cc-count (1+ cc-count)))
1909 (when (> cc-count 1)
1910 (while (> cc-count 0)
1911 (goto-char (point-min))
1913 (re-search-forward "^cc:" nil nil cc-count)
1915 (narrow-to-region (point) (point-max))
1916 (gnus-article-hide-header "cc"))
1917 (setq cc-count (1- cc-count)))))))))))))
1919 (defun gnus-article-hide-header (header)
1921 (goto-char (point-min))
1922 (when (re-search-forward (concat "^" header ":") nil t)
1923 (gnus-article-hide-text-type
1927 (if (re-search-forward "^[^ \t]" nil t)
1932 (defvar gnus-article-normalized-header-length 40
1933 "Length of normalized headers.")
1935 (defun article-normalize-headers ()
1936 "Make all header lines 40 characters long."
1938 (let ((inhibit-read-only t)
1942 (article-narrow-to-head)
1945 ((< (setq column (- (point-at-eol) (point)))
1946 gnus-article-normalized-header-length)
1948 (insert (make-string
1949 (- gnus-article-normalized-header-length column)
1951 ((> column gnus-article-normalized-header-length)
1952 (gnus-put-text-property
1954 (forward-char gnus-article-normalized-header-length)
1961 (forward-line 1))))))
1963 (defun article-treat-dumbquotes ()
1964 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
1965 Note that this function guesses whether a character is a sm*rtq**t* or
1966 not, so it should only be used interactively.
1968 Sm*rtq**t*s are M****s***'s unilateral extension to the
1969 iso-8859-1 character map in an attempt to provide more quoting
1970 characters. If you see something like \\222 or \\264 where
1971 you're expecting some kind of apostrophe or quotation mark, then
1974 (article-translate-strings gnus-article-dumbquotes-map))
1976 (defun article-translate-characters (from to)
1977 "Translate all characters in the body of the article according to FROM and TO.
1978 FROM is a string of characters to translate from; to is a string of
1979 characters to translate to."
1981 (when (article-goto-body)
1982 (let ((inhibit-read-only t)
1983 (x (make-string 225 ?x))
1985 (while (< (incf i) (length x))
1988 (while (< i (length from))
1989 (aset x (aref from i) (aref to i))
1991 (translate-region (point) (point-max) x)))))
1993 (defun article-translate-strings (map)
1994 "Translate all string in the body of the article according to MAP.
1995 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1997 (when (article-goto-body)
1998 (let ((inhibit-read-only t))
2001 (while (search-forward (car elem) nil t)
2002 (replace-match (cadr elem)))))))))
2004 (defun article-treat-overstrike ()
2005 "Translate overstrikes into bold text."
2008 (when (article-goto-body)
2009 (let ((inhibit-read-only t))
2010 (while (search-forward "\b" nil t)
2011 (let ((next (char-after))
2015 previous (char-after))
2019 ;; We do the boldification/underlining by hiding the
2020 ;; overstrikes and putting the proper text property
2024 (gnus-article-hide-text-type start (point) 'overstrike)
2025 (put-text-property (point) end 'face 'bold))
2027 (gnus-article-hide-text-type
2028 (1- (point)) (1+ (point)) 'overstrike)
2030 start (1- (point)) 'face 'underline))
2032 (gnus-article-hide-text-type start (point) 'overstrike)
2034 (point) end 'face 'underline)))))))))
2036 (defun article-treat-ansi-sequences ()
2037 "Translate ANSI SGR control sequences into overlays or extents."
2040 (when (article-goto-body)
2041 (let ((inhibit-read-only t))
2042 (ansi-color-apply-on-region (point) (point-max))))))
2044 (defun gnus-article-treat-unfold-headers ()
2045 "Unfold folded message headers.
2046 Only the headers that fit into the current window width will be
2049 (gnus-with-article-headers
2053 (mail-header-narrow-to-field)
2054 (let ((header (buffer-string)))
2057 (goto-char (point-min))
2058 (while (re-search-forward "\n[\t ]" nil t)
2059 (replace-match " " t t)))
2060 (setq length (- (point-max) (point-min) 1)))
2061 (when (< length (window-width))
2062 (while (re-search-forward "\n[\t ]" nil t)
2063 (replace-match " " t t)))
2064 (goto-char (point-max)))))))
2066 (defun gnus-article-treat-fold-headers ()
2067 "Fold message headers."
2069 (gnus-with-article-headers
2072 (mail-header-narrow-to-field)
2073 (mail-header-fold-field)
2074 (goto-char (point-max))))))
2076 (defun gnus-treat-smiley ()
2077 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2079 (unless (featurep 'xemacs)
2080 (when (and (not gnus-article-should-use-smiley-mule)
2081 gnus-article-smiley-mule-loaded-p)
2082 (load "smiley" nil t)
2083 (setq gnus-article-smiley-mule-loaded-p nil))
2084 (when (and gnus-article-should-use-smiley-mule
2085 (not gnus-article-smiley-mule-loaded-p))
2086 (load "smiley-mule" nil t)
2087 (setq gnus-article-smiley-mule-loaded-p t)))
2088 (gnus-with-article-buffer
2089 (if (memq 'smiley gnus-article-wash-types)
2090 (gnus-delete-images 'smiley)
2092 (let ((images (smiley-region (point) (point-max))))
2094 (gnus-add-wash-type 'smiley)
2095 (dolist (image images)
2096 (gnus-add-image 'smiley image)))))))
2098 (defun gnus-article-remove-images ()
2099 "Remove all images from the article buffer."
2101 (gnus-with-article-buffer
2102 (dolist (elem gnus-article-image-alist)
2103 (gnus-delete-images (car elem)))))
2105 (defun gnus-article-treat-fold-newsgroups ()
2106 "Unfold folded message headers.
2107 Only the headers that fit into the current window width will be
2110 (gnus-with-article-headers
2111 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2113 (mail-header-narrow-to-field)
2114 (while (re-search-forward ", *" nil t)
2115 (replace-match ", " t t))
2116 (mail-header-fold-field)
2117 (goto-char (point-max))))))
2119 (defun gnus-article-treat-body-boundary ()
2120 "Place a boundary line at the end of the headers."
2122 (when (and gnus-body-boundary-delimiter
2123 (> (length gnus-body-boundary-delimiter) 0))
2124 (gnus-with-article-headers
2125 (goto-char (point-max))
2126 (let ((start (point)))
2127 (insert "X-Boundary: ")
2128 (gnus-add-text-properties start (point) '(invisible t intangible t))
2130 (while (>= (1- (window-width)) (length str))
2131 (setq str (concat str gnus-body-boundary-delimiter)))
2132 (substring str 0 (1- (window-width))))
2134 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2136 (defun article-fill-long-lines ()
2137 "Fill lines that are wider than the window width."
2140 (let ((inhibit-read-only t)
2141 (width (window-width (get-buffer-window (current-buffer)))))
2144 (let ((adaptive-fill-mode nil)) ;Why? -sm
2147 (when (>= (current-column) (min fill-column width))
2148 (narrow-to-region (min (1+ (point)) (point-max))
2150 (let ((goback (point-marker)))
2151 (fill-paragraph nil)
2152 (goto-char (marker-position goback)))
2154 (forward-line 1)))))))
2156 (defun article-capitalize-sentences ()
2157 "Capitalize the first word in each sentence."
2160 (let ((inhibit-read-only t)
2161 (paragraph-start "^[\n\^L]"))
2165 (forward-sentence)))))
2167 (defun article-remove-cr ()
2168 "Remove trailing CRs and then translate remaining CRs into LFs."
2171 (let ((inhibit-read-only t))
2172 (goto-char (point-min))
2173 (while (re-search-forward "\r+$" nil t)
2174 (replace-match "" t t))
2175 (goto-char (point-min))
2176 (while (search-forward "\r" nil t)
2177 (replace-match "\n" t t)))))
2179 (defun article-remove-trailing-blank-lines ()
2180 "Remove all trailing blank lines from the article."
2183 (let ((inhibit-read-only t))
2184 (goto-char (point-max))
2188 (while (and (not (bobp))
2189 (looking-at "^[ \t]*$")
2190 (not (gnus-annotation-in-region-p
2191 (point) (point-at-eol))))
2197 (defvar gnus-face-properties-alist))
2199 (defun article-display-face ()
2200 "Display any Face headers in the header."
2202 (let ((wash-face-p buffer-read-only))
2203 (gnus-with-article-headers
2204 ;; When displaying parts, this function can be called several times on
2205 ;; the same article, without any intended toggle semantic (as typing `W
2206 ;; D d' would have). So face deletion must occur only when we come from
2207 ;; an interactive command, that is when the *Article* buffer is
2209 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2210 (gnus-delete-images 'face)
2213 (when (and wash-face-p
2215 (goto-char (point-min))
2216 (not (re-search-forward "^Face:[\t ]*" nil t)))
2217 (gnus-buffer-live-p gnus-original-article-buffer))
2218 (set-buffer gnus-original-article-buffer))
2220 (mail-narrow-to-head)
2221 (while (gnus-article-goto-header "Face")
2222 (setq faces (nconc faces (list (mail-header-field-value)))))))
2223 (dolist (face faces)
2224 (let ((png (gnus-convert-face-to-png face))
2228 (apply 'gnus-create-image png 'png t
2229 (cdr (assq 'png gnus-face-properties-alist))))
2230 (gnus-article-goto-header "from")
2232 (insert "From: [no `from' set]\n")
2234 (gnus-add-wash-type 'face)
2235 (gnus-add-image 'face image)
2236 (gnus-put-image image nil 'face))))))
2239 (defun article-display-x-face (&optional force)
2240 "Look for an X-Face header and display it if present."
2241 (interactive (list 'force))
2242 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2243 (gnus-with-article-headers
2244 ;; Delete the old process, if any.
2245 (when (process-status "article-x-face")
2246 (delete-process "article-x-face"))
2247 ;; See the comment in `article-display-face'.
2248 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2249 ;; We have already displayed X-Faces, so we remove them
2251 (gnus-delete-images 'xface)
2253 (let (x-faces from face)
2255 (when (and wash-face-p
2257 (goto-char (point-min))
2258 (not (re-search-forward
2259 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2260 (gnus-buffer-live-p gnus-original-article-buffer))
2261 ;; If type `W f', use gnus-original-article-buffer,
2262 ;; otherwise use the current buffer because displaying
2263 ;; RFC822 parts calls this function too.
2264 (set-buffer gnus-original-article-buffer))
2266 (mail-narrow-to-head)
2267 (while (gnus-article-goto-header "X-Face")
2268 (push (mail-header-field-value) x-faces))
2269 (setq from (message-fetch-field "from"))))
2270 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2271 ;; single external face.
2272 (when (stringp gnus-article-x-face-command)
2273 (setq x-faces (list (car x-faces))))
2274 (while (and (setq face (pop x-faces))
2275 gnus-article-x-face-command
2277 ;; Check whether this face is censored.
2278 (not gnus-article-x-face-too-ugly)
2279 (and gnus-article-x-face-too-ugly from
2280 (not (string-match gnus-article-x-face-too-ugly
2282 ;; We display the face.
2283 (cond ((stringp gnus-article-x-face-command)
2284 ;; The command is a string, so we interpret the command
2285 ;; as a, well, command, and fork it off.
2286 (let ((process-connection-type nil))
2287 (process-kill-without-query
2289 "article-x-face" nil shell-file-name
2290 shell-command-switch gnus-article-x-face-command))
2293 (process-send-region "article-x-face"
2294 (point-min) (point-max)))
2295 (process-send-eof "article-x-face")))
2296 ((functionp gnus-article-x-face-command)
2297 ;; The command is a lisp function, so we call it.
2298 (funcall gnus-article-x-face-command face))
2300 (error "%s is not a function"
2301 gnus-article-x-face-command)))))))))
2303 (defun article-decode-mime-words ()
2304 "Decode all MIME-encoded words in the article."
2306 (gnus-with-article-buffer
2307 (let ((inhibit-point-motion-hooks t)
2308 (mail-parse-charset gnus-newsgroup-charset)
2309 (mail-parse-ignored-charsets
2310 (with-current-buffer gnus-summary-buffer
2311 gnus-newsgroup-ignored-charsets)))
2312 (mail-decode-encoded-word-region (point-min) (point-max)))))
2314 (defun article-decode-charset (&optional prompt)
2315 "Decode charset-encoded text in the article.
2316 If PROMPT (the prefix), prompt for a coding system to use."
2318 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2319 (inhibit-read-only t)
2320 (mail-parse-charset gnus-newsgroup-charset)
2321 (mail-parse-ignored-charsets
2322 (save-excursion (condition-case nil
2323 (set-buffer gnus-summary-buffer)
2325 gnus-newsgroup-ignored-charsets))
2326 ct cte ctl charset format)
2329 (article-narrow-to-head)
2330 (setq ct (message-fetch-field "Content-Type" t)
2331 cte (message-fetch-field "Content-Transfer-Encoding" t)
2332 ctl (and ct (ignore-errors
2333 (mail-header-parse-content-type ct)))
2336 (mm-read-coding-system "Charset to decode: "))
2338 (mail-content-type-get ctl 'charset)))
2339 format (and ctl (mail-content-type-get ctl 'format)))
2341 (setq cte (mail-header-strip cte)))
2342 (if (and ctl (not (string-match "/" (car ctl))))
2344 (goto-char (point-max)))
2347 (narrow-to-region (point) (point-max))
2348 (when (and (eq mail-parse-charset 'gnus-decoded)
2349 (eq (mm-body-7-or-8) '8bit))
2350 ;; The text code could have been decoded.
2351 (setq charset mail-parse-charset))
2352 (when (and (or (not ctl)
2353 (equal (car ctl) "text/plain"))
2354 (not format)) ;; article with format will decode later.
2356 charset (and cte (intern (downcase
2357 (gnus-strip-whitespace cte))))
2360 (defun article-decode-encoded-words ()
2361 "Remove encoded-word encoding from headers."
2362 (let ((charset (save-excursion
2363 (set-buffer gnus-summary-buffer)
2364 default-mime-charset))
2365 (inhibit-read-only t))
2366 (mime-decode-header-in-buffer charset)))
2368 (defun article-decode-group-name ()
2369 "Decode group names in `Newsgroups:'."
2370 (let ((inhibit-point-motion-hooks t)
2371 (inhibit-read-only t)
2372 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2373 (when (and (or gnus-group-name-charset-method-alist
2374 gnus-group-name-charset-group-alist)
2375 (gnus-buffer-live-p gnus-original-article-buffer))
2377 (article-narrow-to-head)
2378 (with-current-buffer gnus-original-article-buffer
2379 (goto-char (point-min)))
2380 (while (re-search-forward
2381 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2382 (replace-match (save-match-data
2383 (gnus-decode-newsgroups
2384 ;; XXX how to use data in article buffer?
2385 (with-current-buffer gnus-original-article-buffer
2387 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2390 gnus-newsgroup-name method))
2392 (goto-char (point-min))
2393 (with-current-buffer gnus-original-article-buffer
2394 (goto-char (point-min)))
2395 (while (re-search-forward
2396 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2397 (replace-match (save-match-data
2398 (gnus-decode-newsgroups
2399 ;; XXX how to use data in article buffer?
2400 (with-current-buffer gnus-original-article-buffer
2402 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2405 gnus-newsgroup-name method))
2408 (autoload 'idna-to-unicode "idna")
2410 (defun article-decode-idna-rhs ()
2411 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2414 (let ((inhibit-point-motion-hooks t)
2415 (inhibit-read-only t))
2416 (article-narrow-to-head)
2417 (goto-char (point-min))
2418 (while (re-search-forward "@.*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2420 (when (save-match-data
2421 (and (setq ace (match-string 1))
2423 (and (re-search-backward "^[^ \t]" nil t)
2424 (looking-at "From\\|To\\|Cc")))
2425 (setq unicode (idna-to-unicode ace))))
2426 (unless (string= ace unicode)
2427 (replace-match unicode nil nil nil 1)))))))))
2429 (defun article-de-quoted-unreadable (&optional force read-charset)
2430 "Translate a quoted-printable-encoded article.
2431 If FORCE, decode the article whether it is marked as quoted-printable
2433 If READ-CHARSET, ask for a coding system."
2434 (interactive (list 'force current-prefix-arg))
2436 (let ((inhibit-read-only t) type charset)
2437 (if (gnus-buffer-live-p gnus-original-article-buffer)
2438 (with-current-buffer gnus-original-article-buffer
2440 (gnus-fetch-field "content-transfer-encoding"))
2441 (let* ((ct (gnus-fetch-field "content-type"))
2444 (mail-header-parse-content-type ct)))))
2445 (setq charset (and ctl
2446 (mail-content-type-get ctl 'charset)))
2447 (if (stringp charset)
2448 (setq charset (intern (downcase charset)))))))
2450 (setq charset (mm-read-coding-system "Charset: " charset)))
2452 (setq charset gnus-newsgroup-charset))
2454 (and type (let ((case-fold-search t))
2455 (string-match "quoted-printable" type))))
2457 (quoted-printable-decode-region
2458 (point) (point-max) (mm-charset-to-coding-system charset))))))
2460 (defun article-de-base64-unreadable (&optional force read-charset)
2461 "Translate a base64 article.
2462 If FORCE, decode the article whether it is marked as base64 not.
2463 If READ-CHARSET, ask for a coding system."
2464 (interactive (list 'force current-prefix-arg))
2466 (let ((inhibit-read-only t) type charset)
2467 (if (gnus-buffer-live-p gnus-original-article-buffer)
2468 (with-current-buffer gnus-original-article-buffer
2470 (gnus-fetch-field "content-transfer-encoding"))
2471 (let* ((ct (gnus-fetch-field "content-type"))
2474 (mail-header-parse-content-type ct)))))
2475 (setq charset (and ctl
2476 (mail-content-type-get ctl 'charset)))
2477 (if (stringp charset)
2478 (setq charset (intern (downcase charset)))))))
2480 (setq charset (mm-read-coding-system "Charset: " charset)))
2482 (setq charset gnus-newsgroup-charset))
2484 (and type (let ((case-fold-search t))
2485 (string-match "base64" type))))
2488 (narrow-to-region (point) (point-max))
2489 (base64-decode-region (point-min) (point-max))
2490 (mm-decode-coding-region
2491 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2496 (defun article-decode-HZ ()
2497 "Translate a HZ-encoded article."
2501 (let ((inhibit-read-only t))
2502 (rfc1843-decode-region (point-min) (point-max)))))
2504 (defun article-unsplit-urls ()
2505 "Remove the newlines that some other mailers insert into URLs."
2508 (let ((inhibit-read-only t))
2509 (goto-char (point-min))
2510 (while (re-search-forward
2511 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2512 (replace-match "\\1\\3" t)))
2513 (when (interactive-p)
2514 (gnus-treat-article nil))))
2517 (defun article-wash-html (&optional read-charset)
2518 "Format an HTML article.
2519 If READ-CHARSET, ask for a coding system."
2522 (let ((inhibit-read-only t)
2524 (when (gnus-buffer-live-p gnus-original-article-buffer)
2525 (with-current-buffer gnus-original-article-buffer
2526 (let* ((ct (gnus-fetch-field "content-type"))
2529 (mail-header-parse-content-type ct)))))
2530 (setq charset (and ctl
2531 (mail-content-type-get ctl 'charset)))
2532 (when (stringp charset)
2533 (setq charset (intern (downcase charset)))))))
2535 (setq charset (mm-read-coding-system "Charset: " charset)))
2537 (setq charset gnus-newsgroup-charset))
2539 (save-window-excursion
2541 (narrow-to-region (point) (point-max))
2542 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2543 (entry (assq func mm-text-html-washer-alist)))
2545 (setq func (cdr entry)))
2550 (apply (car func) (cdr func))))))))))
2552 (defun gnus-article-wash-html-with-w3 ()
2553 "Wash the current buffer with w3."
2555 (let ((w3-strict-width (window-width))
2556 (url-standalone-mode t)
2557 (url-gateway-unplugged t)
2558 (w3-honor-stylesheets nil))
2560 (w3-region (point-min) (point-max))
2563 (defun gnus-article-wash-html-with-w3m ()
2564 "Wash the current buffer with emacs-w3m."
2567 (narrow-to-region (point) (point-max))
2568 (let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp)
2569 w3m-force-redisplay)
2570 (w3m-region (point-min) (point-max)))
2571 (when (and mm-inline-text-html-with-w3m-keymap
2572 (boundp 'w3m-minor-mode-map)
2574 (add-text-properties
2575 (point-min) (point-max)
2576 (list 'keymap w3m-minor-mode-map
2577 ;; Put the mark meaning this part was rendered by emacs-w3m.
2578 'mm-inline-text-html-with-w3m t)))))
2580 (defun article-hide-list-identifiers ()
2581 "Remove list identifies from the Subject header.
2582 The `gnus-list-identifiers' variable specifies what to do."
2584 (let ((inhibit-point-motion-hooks t)
2585 (regexp (if (consp gnus-list-identifiers)
2586 (mapconcat 'identity gnus-list-identifiers " *\\|")
2587 gnus-list-identifiers))
2588 (inhibit-read-only t))
2592 (article-narrow-to-head)
2593 (goto-char (point-min))
2594 (while (re-search-forward
2595 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2597 (delete-region (match-beginning 2) (match-end 0))
2598 (beginning-of-line))
2599 (when (re-search-forward
2600 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2601 (delete-region (match-beginning 1) (match-end 1))))))))
2603 (defun article-hide-pem (&optional arg)
2604 "Toggle hiding of any PEM headers and signatures in the current article.
2605 If given a negative prefix, always show; if given a positive prefix,
2607 (interactive (gnus-article-hidden-arg))
2608 (unless (gnus-article-check-hidden-text 'pem arg)
2610 (let ((inhibit-read-only t) end)
2611 (goto-char (point-min))
2612 ;; Hide the horrendously ugly "header".
2613 (when (and (search-forward
2614 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2616 (setq end (1+ (match-beginning 0))))
2617 (gnus-add-wash-type 'pem)
2618 (gnus-article-hide-text-type
2620 (if (search-forward "\n\n" nil t)
2624 ;; Hide the trailer as well
2625 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2627 (gnus-article-hide-text-type
2628 (match-beginning 0) (match-end 0) 'pem)))))))
2630 (defun article-strip-banner ()
2631 "Strip the banners specified by the `banner' group parameter and by
2632 `gnus-article-address-banner-alist'."
2636 (let ((inhibit-point-motion-hooks t))
2637 (when (gnus-parameter-banner gnus-newsgroup-name)
2638 (article-really-strip-banner
2639 (gnus-parameter-banner gnus-newsgroup-name)))
2640 (when gnus-article-address-banner-alist
2641 ;; It is necessary to encode from fields before checking,
2642 ;; because `mail-header-parse-addresses' does not work
2643 ;; (reliably) on decoded headers. And more, it is
2644 ;; impossible to use `gnus-fetch-original-field' here,
2645 ;; because `article-strip-banner' may be called in draft
2646 ;; buffers to preview them.
2647 (let ((from (save-restriction
2649 (article-narrow-to-head)
2650 (mail-fetch-field "from"))))
2653 (caar (mail-header-parse-addresses
2654 (mail-encode-encoded-word-string from)))))
2656 (dolist (pair gnus-article-address-banner-alist)
2657 (when (string-match (car pair) from)
2659 (article-really-strip-banner (cdr pair)))))))))))))
2661 (defun article-really-strip-banner (banner)
2662 "Strip the banner specified by the argument."
2665 (let ((inhibit-point-motion-hooks t)
2666 (gnus-signature-limit nil)
2667 (inhibit-read-only t))
2670 ((eq banner 'signature)
2671 (when (gnus-article-narrow-to-signature)
2674 (delete-region (point) (point-max))))
2676 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2677 (while (re-search-forward banner nil t)
2678 (delete-region (match-beginning 0) (match-end 0)))))
2680 (while (re-search-forward banner nil t)
2681 (delete-region (match-beginning 0) (match-end 0)))))))))
2683 (defun article-babel ()
2684 "Translate article using an online translation service."
2687 (gnus-with-article-buffer
2688 (when (article-goto-body)
2689 (let* ((start (point))
2691 (orig (buffer-substring start end))
2692 (trans (babel-as-string orig)))
2694 (narrow-to-region start end)
2695 (delete-region start end)
2698 (defun article-hide-signature (&optional arg)
2699 "Hide the signature in the current article.
2700 If given a negative prefix, always show; if given a positive prefix,
2702 (interactive (gnus-article-hidden-arg))
2708 (article-goto-body))
2709 (goto-char (point-min)))
2710 (unless (gnus-article-check-hidden-text 'signature arg)
2711 (let ((inhibit-read-only t)
2713 (while (setq button (text-property-any button (point-max)
2715 'gnus-signature-toggle))
2716 (setq button (text-property-not-all button (point-max)
2718 'gnus-signature-toggle))
2719 (when (and button (not (eobp)))
2720 (gnus-article-hide-text-type
2722 (next-single-property-change (1+ button) 'mime-view-entity
2725 (gnus-set-mode-line 'article))
2727 (defun article-strip-headers-in-body ()
2728 "Strip offensive headers from bodies."
2732 (let ((case-fold-search t))
2733 (when (looking-at "x-no-archive:")
2734 (gnus-delete-line)))))
2736 (defun article-strip-leading-blank-lines ()
2737 "Remove all blank lines from the beginning of the article."
2740 (let ((inhibit-point-motion-hooks t)
2741 (inhibit-read-only t))
2742 (when (article-goto-body)
2743 (while (and (not (eobp))
2744 (looking-at "[ \t]*$"))
2745 (gnus-delete-line))))))
2747 (defun article-narrow-to-head ()
2748 "Narrow the buffer to the head of the message.
2749 Point is left at the beginning of the narrowed-to region."
2751 (goto-char (point-min))
2752 (if (search-forward "\n\n" nil 1)
2755 (goto-char (point-min)))
2757 (defun article-goto-body ()
2758 "Place point at the start of the body."
2759 (goto-char (point-min))
2761 ;; This variable is only bound when dealing with separate
2763 (article-goto-body-goes-to-point-min-p
2765 ((search-forward "\n\n" nil t)
2768 (goto-char (point-max))
2771 (defun article-strip-multiple-blank-lines ()
2772 "Replace consecutive blank lines with one empty line."
2775 (let ((inhibit-point-motion-hooks t)
2776 (inhibit-read-only t))
2777 ;; First make all blank lines empty.
2779 (while (re-search-forward "^[ \t]+$" nil t)
2780 (unless (gnus-annotation-in-region-p
2781 (match-beginning 0) (match-end 0))
2782 (replace-match "" nil t)))
2783 ;; Then replace multiple empty lines with a single empty line.
2785 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2786 (unless (gnus-annotation-in-region-p
2787 (match-beginning 0) (match-end 0))
2788 (delete-region (match-beginning 1) (match-end 1)))))))
2790 (defun article-strip-leading-space ()
2791 "Remove all white space from the beginning of the lines in the article."
2794 (let ((inhibit-point-motion-hooks t)
2795 (inhibit-read-only t))
2797 (while (re-search-forward "^[ \t]+" nil t)
2798 (replace-match "" t t)))))
2800 (defun article-strip-trailing-space ()
2801 "Remove all white space from the end of the lines in the article."
2804 (let ((inhibit-point-motion-hooks t)
2805 (inhibit-read-only t))
2807 (while (re-search-forward "[ \t]+$" nil t)
2808 (replace-match "" t t)))))
2810 (defun article-strip-blank-lines ()
2811 "Strip leading, trailing and multiple blank lines."
2813 (article-strip-leading-blank-lines)
2814 (article-remove-trailing-blank-lines)
2815 (article-strip-multiple-blank-lines))
2817 (defun article-strip-all-blank-lines ()
2818 "Strip all blank lines."
2821 (let ((inhibit-point-motion-hooks t)
2822 (inhibit-read-only t))
2824 (while (re-search-forward "^[ \t]*\n" nil t)
2825 (replace-match "" t t)))))
2827 (defun gnus-article-narrow-to-signature ()
2828 "Narrow to the signature; return t if a signature is found, else nil."
2829 (let ((inhibit-point-motion-hooks t))
2830 (when (gnus-article-search-signature)
2832 ;; Check whether we have some limits to what we consider
2833 ;; to be a signature.
2834 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2835 (list gnus-signature-limit)))
2837 (while (setq limit (pop limits))
2838 (if (or (and (integerp limit)
2839 (< (- (point-max) (point)) limit))
2841 (< (count-lines (point) (point-max)) limit))
2842 (and (functionp limit)
2844 (and (stringp limit)
2845 (not (re-search-forward limit nil t))))
2846 () ; This limit did not succeed.
2850 (narrow-to-region (point) (point-max))
2853 (defun gnus-article-search-signature ()
2854 "Search the current buffer for the signature separator.
2855 Put point at the beginning of the signature separator."
2856 (let ((cur (point)))
2857 (goto-char (point-max))
2858 (if (if (stringp gnus-signature-separator)
2859 (re-search-backward gnus-signature-separator nil t)
2860 (let ((seps gnus-signature-separator))
2862 (not (re-search-backward (car seps) nil t)))
2869 (defun gnus-article-hidden-arg ()
2870 "Return the current prefix arg as a number, or 0 if no prefix."
2871 (list (if current-prefix-arg
2872 (prefix-numeric-value current-prefix-arg)
2875 (defun gnus-article-check-hidden-text (type arg)
2876 "Return nil if hiding is necessary.
2877 Arg can be nil or a number. nil and positive means hide, negative
2878 means show, 0 means toggle."
2881 (let ((hide (gnus-article-hidden-text-p type)))
2887 (gnus-article-show-hidden-text type)
2890 (if (eq hide 'hidden)
2892 (gnus-article-show-hidden-text type)
2896 (defun gnus-article-hidden-text-p (type)
2897 "Say whether the current buffer contains hidden text of type TYPE."
2898 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2900 (not (get-text-property pos 'invisible))
2901 (not (get-text-property pos 'dummy-invisible)))
2903 (text-property-any (1+ pos) (point-max) 'article-type type)))
2908 (defun gnus-article-show-hidden-text (type &optional dummy)
2909 "Show all hidden text of type TYPE.
2910 Originally it is hide instead of DUMMY."
2911 (let ((inhibit-read-only t)
2912 (inhibit-point-motion-hooks t))
2913 (gnus-remove-text-properties-when
2915 (point-min) (point-max)
2916 (cons 'article-type (cons type
2917 gnus-hidden-properties)))
2918 (gnus-delete-wash-type type)))
2920 (defconst article-time-units
2921 `((year . ,(* 365.25 24 60 60))
2922 (week . ,(* 7 24 60 60))
2923 (day . ,(* 24 60 60))
2927 "Mapping from time units to seconds.")
2929 (defun gnus-article-forward-header ()
2930 "Move point to the start of the next header.
2931 If the current header is a continuation header, this can be several
2936 (if (looking-at "[ \t]+[^ \t]")
2940 (defun article-date-ut (&optional type highlight header)
2941 "Convert DATE date to universal time in the current article.
2942 If TYPE is `local', convert to local time; if it is `lapsed', output
2943 how much time has lapsed since DATE. For `lapsed', the value of
2944 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2945 should replace the \"Date:\" one, or should be added below it."
2946 (interactive (list 'ut t))
2947 (let* ((header (or header
2948 (and (eq 1 (point-min))
2949 (mail-header-date (save-excursion
2950 (set-buffer gnus-summary-buffer)
2951 gnus-current-headers)))
2952 (message-fetch-field "date")
2954 (date (if (vectorp header) (mail-header-date header)
2956 (inhibit-point-motion-hooks t)
2957 bface eface date-pos)
2958 (when (and date (not (string= date "")))
2961 (article-narrow-to-head)
2962 (when (or (and (eq type 'lapsed)
2963 gnus-article-date-lapsed-new-header
2964 ;; Attempt to get the face of X-Sent first.
2965 (re-search-forward "^X-Sent:[ \t]" nil t))
2966 (re-search-forward "^Date:[ \t]" nil t)
2967 ;; If Date is missing, try again for X-Sent.
2968 (re-search-forward "^X-Sent:[ \t]" nil t))
2969 (setq bface (get-text-property (point-at-bol) 'face)
2970 date (or (get-text-property (point-at-bol)
2973 eface (get-text-property (1- (point-at-eol))
2975 (let ((inhibit-read-only t))
2976 ;; Delete any old X-Sent headers.
2977 (when (setq date-pos
2978 (text-property-any (point-min) (point-max)
2979 'article-date-lapsed t))
2980 (goto-char (setq date-pos (set-marker (make-marker) date-pos)))
2981 (delete-region (match-beginning 0)
2982 (progn (forward-line 1) (point))))
2983 (goto-char (point-min))
2984 ;; Delete any old Date headers.
2985 (while (re-search-forward "^Date:[ \t]" nil t)
2987 (setq date-pos (match-beginning 0)))
2988 (unless (and (eq type 'lapsed)
2989 gnus-article-date-lapsed-new-header)
2990 (delete-region (match-beginning 0)
2991 (progn (message-next-header) (point)))))
2994 (goto-char date-pos)
2996 ;; Possibly, Date has been deleted.
2998 (when (and (eq type 'lapsed)
2999 gnus-article-date-lapsed-new-header
3000 (looking-at "Date:"))
3002 (goto-char (point-min)))
3003 (insert (article-make-date-line date type))
3004 (when (eq type 'lapsed)
3005 (put-text-property (point-at-bol) (point)
3006 'article-date-lapsed t))
3010 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
3011 (add-text-properties (match-beginning 1) (1+ (match-end 1))
3012 (list 'original-date date 'face bface))
3013 (put-text-property (match-beginning 2) (match-end 2)
3016 (defun article-make-date-line (date type)
3017 "Return a DATE line of TYPE."
3018 (unless (memq type '(local ut original user iso8601 lapsed english))
3019 (error "Unknown conversion type: %s" type))
3021 (let ((time (date-to-time date)))
3023 ;; Convert to the local timezone.
3025 (concat "Date: " (message-make-date time)))
3026 ;; Convert to Universal Time.
3031 (let* ((e (parse-time-string date))
3032 (tm (apply 'encode-time e))
3034 (ls (- (cadr tm) (car (current-time-zone time)))))
3035 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
3036 ((> ls 65535) (list (1+ ms) (- ls 65536)))
3040 ;; Get the original date from the article.
3041 ((eq type 'original)
3042 (concat "Date: " (if (string-match "\n+$" date)
3043 (substring date 0 (match-beginning 0))
3045 ;; Let the user define the format.
3047 (let ((format (or (condition-case nil
3048 (with-current-buffer gnus-summary-buffer
3049 gnus-article-time-format)
3051 gnus-article-time-format)))
3052 (if (functionp format)
3053 (funcall format time)
3054 (concat "Date: " (format-time-string format time)))))
3057 (let ((tz (car (current-time-zone time))))
3060 (format-time-string "%Y%m%dT%H%M%S" time)
3061 (format "%s%02d%02d"
3062 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
3063 (/ (% (abs tz) 3600) 60)))))
3064 ;; Do an X-Sent lapsed format.
3066 ;; If the date is seriously mangled, the timezone functions are
3067 ;; liable to bug out, so we ignore all errors.
3068 (let* ((now (current-time))
3069 (real-time (subtract-time now time))
3070 (real-sec (and real-time
3071 (+ (* (float (car real-time)) 65536)
3073 (sec (and real-time (abs real-sec)))
3083 ;; This is a bit convoluted, but basically we go
3084 ;; through the time units for years, weeks, etc,
3085 ;; and divide things to see whether that results
3086 ;; in positive answers.
3089 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
3090 ;; The (remaining) seconds are too few to
3091 ;; be divided into this time unit.
3093 ;; It's big enough, so we output it.
3094 (setq sec (- sec (* num (cdr unit))))
3096 (concat (if prev ", " "") (int-to-string
3098 " " (symbol-name (car unit))
3099 (if (> num 1) "s" ""))
3101 article-time-units "")
3102 ;; If dates are odd, then it might appear like the
3103 ;; article was sent in the future.
3106 " in the future"))))))
3107 ;; Display the date in proper English
3109 (let ((dtime (decode-time time)))
3112 (number-to-string (nth 3 dtime))
3113 (let ((digit (% (nth 3 dtime) 10)))
3115 ((memq (nth 3 dtime) '(11 12 13)) "th")
3121 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3123 (number-to-string (nth 5 dtime))
3125 (format "%02d" (nth 2 dtime))
3127 (format "%02d" (nth 1 dtime)))))))
3129 (format "Date: %s (from T-gnus)" date))))
3131 (defun article-date-local (&optional highlight)
3132 "Convert the current article date to the local timezone."
3133 (interactive (list t))
3134 (article-date-ut 'local highlight))
3136 (defun article-date-english (&optional highlight)
3137 "Convert the current article date to something that is proper English."
3138 (interactive (list t))
3139 (article-date-ut 'english highlight))
3141 (defun article-date-original (&optional highlight)
3142 "Convert the current article date to what it was originally.
3143 This is only useful if you have used some other date conversion
3144 function and want to see what the date was before converting."
3145 (interactive (list t))
3146 (article-date-ut 'original highlight))
3148 (defun article-date-lapsed (&optional highlight)
3149 "Convert the current article date to time lapsed since it was sent."
3150 (interactive (list t))
3151 (article-date-ut 'lapsed highlight))
3153 (defun article-update-date-lapsed ()
3154 "Function to be run from a timer to update the lapsed time line."
3155 (let (deactivate-mark)
3160 (set-buffer (window-buffer w))
3161 (when (eq major-mode 'gnus-article-mode)
3162 (let ((mark (point-marker)))
3163 (goto-char (point-min))
3164 (when (re-search-forward "^X-Sent:" nil t)
3165 (article-date-lapsed t))
3166 (goto-char (marker-position mark))
3167 (move-marker mark nil))))
3170 (defun gnus-start-date-timer (&optional n)
3171 "Start a timer to update the X-Sent header in the article buffers.
3172 The numerical prefix says how frequently (in seconds) the function
3177 (gnus-stop-date-timer)
3178 (setq article-lapsed-timer
3179 (run-at-time 1 n 'article-update-date-lapsed)))
3181 (defun gnus-stop-date-timer ()
3182 "Stop the X-Sent timer."
3184 (when article-lapsed-timer
3185 (nnheader-cancel-timer article-lapsed-timer)
3186 (setq article-lapsed-timer nil)))
3188 (defun article-date-user (&optional highlight)
3189 "Convert the current article date to the user-defined format.
3190 This format is defined by the `gnus-article-time-format' variable."
3191 (interactive (list t))
3192 (article-date-ut 'user highlight))
3194 (defun article-date-iso8601 (&optional highlight)
3195 "Convert the current article date to ISO8601."
3196 (interactive (list t))
3197 (article-date-ut 'iso8601 highlight))
3199 ;; (defun article-show-all ()
3200 ;; "Show all hidden text in the article buffer."
3204 ;; (let ((inhibit-read-only t))
3205 ;; (gnus-article-unhide-text (point-min) (point-max))
3206 ;; (gnus-remove-text-with-property 'gnus-prev)
3207 ;; (gnus-remove-text-with-property 'gnus-next))))
3209 (defun article-show-all-headers ()
3210 "Show all hidden headers in the article buffer."
3215 (article-narrow-to-head)
3216 (let ((inhibit-read-only t))
3217 (gnus-article-unhide-text (point-min) (point-max))))))
3219 (defun article-remove-leading-whitespace ()
3220 "Remove excessive whitespace from all headers."
3224 (let ((inhibit-read-only t))
3225 (article-narrow-to-head)
3226 (goto-char (point-min))
3227 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3228 (delete-region (match-beginning 1) (match-end 1)))))))
3230 (defun article-emphasize (&optional arg)
3231 "Emphasize text according to `gnus-emphasis-alist'."
3232 (interactive (gnus-article-hidden-arg))
3233 (unless (gnus-article-check-hidden-text 'emphasis arg)
3237 (with-current-buffer gnus-summary-buffer
3238 gnus-article-emphasis-alist)
3240 gnus-emphasis-alist))
3241 (inhibit-read-only t)
3242 (props (append '(article-type emphasis)
3243 gnus-hidden-properties))
3244 regexp elem beg invisible visible face)
3247 (while (setq elem (pop alist))
3249 (setq regexp (car elem)
3250 invisible (nth 1 elem)
3251 visible (nth 2 elem)
3253 (while (re-search-forward regexp nil t)
3254 (when (and (match-beginning visible) (match-beginning invisible))
3255 (gnus-article-hide-text
3256 (match-beginning invisible) (match-end invisible) props)
3257 (gnus-article-unhide-text-type
3258 (match-beginning visible) (match-end visible) 'emphasis)
3259 (gnus-put-overlay-excluding-newlines
3260 (match-beginning visible) (match-end visible) 'face face)
3261 (gnus-add-wash-type 'emphasis)
3262 (goto-char (match-end invisible)))))))))
3264 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3265 "Setup newsgroup emphasis alist."
3266 (unless gnus-article-emphasis-alist
3267 (let ((name (and gnus-newsgroup-name
3268 (gnus-group-real-name gnus-newsgroup-name))))
3269 (make-local-variable 'gnus-article-emphasis-alist)
3270 (setq gnus-article-emphasis-alist
3272 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3273 (while (setq elem (pop alist))
3274 (when (and name (string-match (car elem) name))
3276 highlight (copy-sequence (cdr elem)))))
3278 (copy-sequence highlight-words)
3279 (if gnus-newsgroup-name
3280 (copy-sequence (gnus-group-find-parameter
3281 gnus-newsgroup-name 'highlight-words t)))
3282 gnus-emphasis-alist)))))
3285 (defvar gnus-summary-article-menu)
3286 (defvar gnus-summary-post-menu))
3288 ;;; Saving functions.
3290 (defun gnus-article-save (save-buffer file &optional num)
3291 "Save the currently selected article."
3292 (unless gnus-save-all-headers
3293 ;; Remove headers according to `gnus-saved-headers'.
3294 (let ((gnus-visible-headers
3295 (or gnus-saved-headers gnus-visible-headers))
3296 (gnus-article-buffer save-buffer))
3298 (set-buffer save-buffer)
3299 (article-hide-headers 1 t))))
3300 (save-window-excursion
3301 (if (not gnus-default-article-saver)
3302 (error "No default saver is defined")
3303 ;; !!! Magic! The saving functions all save
3304 ;; `gnus-save-article-buffer' (or so they think), but we
3305 ;; bind that variable to our save-buffer.
3306 (set-buffer gnus-article-buffer)
3307 (let* ((gnus-save-article-buffer save-buffer)
3310 ((not gnus-prompt-before-saving) 'default)
3311 ((eq gnus-prompt-before-saving 'always) nil)
3313 (gnus-number-of-articles-to-be-saved
3314 (when (eq gnus-prompt-before-saving t)
3316 (set-buffer gnus-article-current-summary)
3317 (funcall gnus-default-article-saver filename)))))
3319 (defun gnus-read-save-file-name (prompt &optional filename
3320 function group headers variable)
3322 (funcall function group headers (symbol-value variable)))
3327 ((eq filename 'default)
3333 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3336 (if (and gnus-number-of-articles-to-be-saved
3337 (> gnus-number-of-articles-to-be-saved 1))
3338 (format "these %d articles"
3339 gnus-number-of-articles-to-be-saved)
3342 ;; Let the split methods have their say.
3344 ;; No split name was found.
3347 (concat prompt " (default "
3348 (file-name-nondirectory default-name) ") ")
3349 (file-name-directory default-name)
3351 ;; A single group name is returned.
3352 ((stringp split-name)
3354 (funcall function split-name headers
3355 (symbol-value variable)))
3357 (concat prompt " (default "
3358 (file-name-nondirectory default-name) ") ")
3359 (file-name-directory default-name)
3361 ;; A single split name was found
3362 ((= 1 (length split-name))
3363 (let* ((name (expand-file-name
3365 gnus-article-save-directory))
3366 (dir (cond ((file-directory-p name)
3367 (file-name-as-directory name))
3368 ((file-exists-p name) name)
3369 (t gnus-article-save-directory))))
3371 (concat prompt " (default " name ") ")
3373 ;; A list of splits was found.
3375 (setq split-name (nreverse split-name))
3377 (let ((file-name-history
3378 (nconc split-name file-name-history)))
3382 (concat prompt " (`M-p' for defaults) ")
3383 gnus-article-save-directory
3385 gnus-article-save-directory)))
3386 (car (push result file-name-history)))))))
3387 ;; Create the directory.
3388 (gnus-make-directory (file-name-directory file))
3389 ;; If we have read a directory, we append the default file name.
3390 (when (file-directory-p file)
3391 (setq file (expand-file-name (file-name-nondirectory
3393 (file-name-as-directory file))))
3394 ;; Possibly translate some characters.
3395 (nnheader-translate-file-chars file))))))
3396 (gnus-make-directory (file-name-directory result))
3397 (set variable result)))
3399 (defun gnus-article-archive-name (group)
3400 "Return the first instance of an \"Archive-name\" in the current buffer."
3401 (let ((case-fold-search t))
3402 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3403 (nnheader-concat gnus-article-save-directory
3404 (match-string 1)))))
3406 (defun gnus-article-nndoc-name (group)
3407 "If GROUP is an nndoc group, return the name of the parent group."
3408 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3409 (gnus-group-get-parameter group 'save-article-group)))
3411 (defun gnus-summary-save-in-rmail (&optional filename)
3412 "Append this article to Rmail file.
3413 Optional argument FILENAME specifies file name.
3414 Directory to save to is default to `gnus-article-save-directory'."
3415 (setq filename (gnus-read-save-file-name
3416 "Save %s in rmail file:" filename
3417 gnus-rmail-save-name gnus-newsgroup-name
3418 gnus-current-headers 'gnus-newsgroup-last-rmail))
3419 (gnus-eval-in-buffer-window gnus-save-article-buffer
3423 (gnus-output-to-rmail filename))))
3426 (defun gnus-summary-save-in-mail (&optional filename)
3427 "Append this article to Unix mail file.
3428 Optional argument FILENAME specifies file name.
3429 Directory to save to is default to `gnus-article-save-directory'."
3430 (setq filename (gnus-read-save-file-name
3431 "Save %s in Unix mail file:" filename
3432 gnus-mail-save-name gnus-newsgroup-name
3433 gnus-current-headers 'gnus-newsgroup-last-mail))
3434 (gnus-eval-in-buffer-window gnus-save-article-buffer
3438 (if (and (file-readable-p filename)
3439 (file-regular-p filename)
3440 (mail-file-babyl-p filename))
3441 (rmail-output-to-rmail-file filename t)
3442 (gnus-output-to-mail filename)))))
3445 (defun gnus-summary-save-in-file (&optional filename overwrite)
3446 "Append this article to file.
3447 Optional argument FILENAME specifies file name.
3448 Directory to save to is default to `gnus-article-save-directory'."
3449 (setq filename (gnus-read-save-file-name
3450 "Save %s in file:" filename
3451 gnus-file-save-name gnus-newsgroup-name
3452 gnus-current-headers 'gnus-newsgroup-last-file))
3453 (gnus-eval-in-buffer-window gnus-save-article-buffer
3457 (when (and overwrite
3458 (file-exists-p filename))
3459 (delete-file filename))
3460 (gnus-output-to-file filename))))
3463 (defun gnus-summary-write-to-file (&optional filename)
3464 "Write this article to a file, overwriting it if the file exists.
3465 Optional argument FILENAME specifies file name.
3466 The directory to save in defaults to `gnus-article-save-directory'."
3467 (gnus-summary-save-in-file nil t))
3469 (defun gnus-summary-save-body-in-file (&optional filename)
3470 "Append this article body to a file.
3471 Optional argument FILENAME specifies file name.
3472 The directory to save in defaults to `gnus-article-save-directory'."
3473 (setq filename (gnus-read-save-file-name
3474 "Save %s body in file:" filename
3475 gnus-file-save-name gnus-newsgroup-name
3476 gnus-current-headers 'gnus-newsgroup-last-file))
3477 (gnus-eval-in-buffer-window gnus-save-article-buffer
3481 (when (article-goto-body)
3482 (narrow-to-region (point) (point-max)))
3483 (gnus-output-to-file filename))))
3486 (defun gnus-summary-save-in-pipe (&optional command)
3487 "Pipe this article to subprocess."
3489 (cond ((and (eq command 'default)
3490 gnus-last-shell-command)
3491 gnus-last-shell-command)
3496 "Shell command on %s: "
3497 (if (and gnus-number-of-articles-to-be-saved
3498 (> gnus-number-of-articles-to-be-saved 1))
3499 (format "these %d articles"
3500 gnus-number-of-articles-to-be-saved)
3502 gnus-last-shell-command))))
3503 (when (string-equal command "")
3504 (if gnus-last-shell-command
3505 (setq command gnus-last-shell-command)
3506 (error "A command is required")))
3507 (gnus-eval-in-buffer-window gnus-article-buffer
3510 (shell-command-on-region (point-min) (point-max) command nil)))
3511 (setq gnus-last-shell-command command))
3513 (defun gnus-summary-pipe-to-muttprint (&optional command)
3514 "Pipe this article to muttprint."
3515 (setq command (read-string
3516 "Print using command: " gnus-summary-muttprint-program
3517 nil gnus-summary-muttprint-program))
3518 (gnus-summary-save-in-pipe command))
3520 ;;; Article file names when saving.
3522 (defun gnus-capitalize-newsgroup (newsgroup)
3523 "Capitalize NEWSGROUP name."
3524 (when (not (zerop (length newsgroup)))
3525 (concat (char-to-string (upcase (aref newsgroup 0)))
3526 (substring newsgroup 1))))
3528 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3529 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3530 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3531 Otherwise, it is like ~/News/news/group/num."
3534 (concat (if (gnus-use-long-file-name 'not-save)
3535 (gnus-capitalize-newsgroup newsgroup)
3536 (gnus-newsgroup-directory-form newsgroup))
3537 "/" (int-to-string (mail-header-number headers)))
3538 gnus-article-save-directory)))
3540 (string-equal (file-name-directory default)
3541 (file-name-directory last-file))
3542 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3544 (or last-file default))))
3546 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3547 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3548 If variable `gnus-use-long-file-name' is non-nil, it is
3549 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3552 (concat (if (gnus-use-long-file-name 'not-save)
3554 (gnus-newsgroup-directory-form newsgroup))
3555 "/" (int-to-string (mail-header-number headers)))
3556 gnus-article-save-directory)))
3558 (string-equal (file-name-directory default)
3559 (file-name-directory last-file))
3560 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3562 (or last-file default))))
3564 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3565 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3566 If variable `gnus-use-long-file-name' is non-nil, it is
3567 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3570 (if (gnus-use-long-file-name 'not-save)
3573 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3575 gnus-article-save-directory)))
3577 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3578 "Generate file name from sender."
3579 (let ((from (mail-header-from headers)))
3581 (if (and from (string-match "\\([^ <]+\\)@" from))
3582 (match-string 1 from)
3584 gnus-article-save-directory)))
3586 (defun article-verify-x-pgp-sig ()
3589 (if (gnus-buffer-live-p gnus-original-article-buffer)
3590 (let ((sig (with-current-buffer gnus-original-article-buffer
3591 (gnus-fetch-field "X-PGP-Sig")))
3595 (mml2015-clear-verify-function))
3597 (insert-buffer-substring gnus-original-article-buffer)
3598 (setq items (split-string sig))
3599 (message-narrow-to-head)
3600 (let ((inhibit-point-motion-hooks t)
3601 (case-fold-search t))
3602 ;; Don't verify multiple headers.
3603 (setq headers (mapconcat (lambda (header)
3605 (mail-fetch-field header)
3607 (split-string (nth 1 items) ",") "")))
3608 (delete-region (point-min) (point-max))
3609 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3610 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3615 (if (looking-at "^-")
3618 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3619 (insert "Version: " (car items) "\n\n")
3620 (insert (mapconcat 'identity (cddr items) "\n"))
3621 (insert "\n-----END PGP SIGNATURE-----\n")
3622 (let ((mm-security-handle (list (format "multipart/signed"))))
3623 (mml2015-clean-buffer)
3624 (let ((coding-system-for-write (or gnus-newsgroup-charset
3626 (funcall (mml2015-clear-verify-function)))
3628 (or (mm-handle-multipart-ctl-parameter
3629 mm-security-handle 'gnus-details)
3630 (mm-handle-multipart-ctl-parameter
3631 mm-security-handle 'gnus-info)))))
3633 (let ((inhibit-read-only t) bface eface)
3635 (message-narrow-to-head)
3636 (goto-char (point-max))
3638 (setq bface (get-text-property (point-at-bol) 'face)
3639 eface (get-text-property (1- (point-at-eol)) 'face))
3640 (message-remove-header "X-Gnus-PGP-Verify")
3641 (if (re-search-forward "^X-PGP-Sig:" nil t)
3643 (goto-char (point-max)))
3644 (narrow-to-region (point) (point))
3645 (insert "X-Gnus-PGP-Verify: " info "\n")
3646 (goto-char (point-min))
3649 (if (not (looking-at "^[ \t]"))
3653 (goto-char (point-min))
3654 (when (looking-at "\\([^:]+\\): *")
3655 (put-text-property (match-beginning 1) (1+ (match-end 1))
3657 (put-text-property (match-end 0) (point-max)
3658 'face eface)))))))))
3660 (defun article-verify-cancel-lock ()
3661 "Verify Cancel-Lock header."
3663 (if (gnus-buffer-live-p gnus-original-article-buffer)
3664 (canlock-verify gnus-original-article-buffer)))
3666 (defun article-monafy ()
3667 "Display body part with mona font."
3669 (unless (if (featurep 'xemacs)
3670 (find-face 'gnus-mona-face)
3671 (facep 'gnus-mona-face))
3672 (require 'navi2ch-mona)
3673 (set-face-font (make-face 'gnus-mona-face) navi2ch-mona-font))
3675 (let ((inhibit-read-only t))
3678 (gnus-make-overlay (point) (point-max))
3679 'face 'gnus-mona-face))))
3686 (setq afunc (car func)
3689 gfunc (intern (format "gnus-%s" func))))
3691 (when (fboundp afunc)
3692 `(lambda (&optional interactive &rest args)
3693 ,(documentation afunc t)
3694 (interactive (list t))
3696 (set-buffer gnus-article-buffer)
3698 (call-interactively ',afunc)
3699 (apply ',afunc args))))))))
3700 '(article-hide-headers
3701 article-verify-x-pgp-sig
3702 article-verify-cancel-lock
3704 article-hide-boring-headers
3705 article-treat-overstrike
3706 article-treat-ansi-sequences
3707 article-fill-long-lines
3708 article-capitalize-sentences
3710 article-remove-leading-whitespace
3711 article-display-x-face
3712 article-display-face
3713 article-de-quoted-unreadable
3714 article-de-base64-unreadable
3717 article-unsplit-urls
3718 article-hide-list-identifiers
3719 article-strip-banner
3722 article-hide-signature
3723 article-strip-headers-in-body
3724 article-remove-trailing-blank-lines
3725 article-strip-leading-blank-lines
3726 article-strip-multiple-blank-lines
3727 article-strip-leading-space
3728 article-strip-trailing-space
3729 article-strip-blank-lines
3730 article-strip-all-blank-lines
3732 article-date-english
3733 article-date-iso8601
3734 article-date-original
3736 article-decode-mime-words
3737 article-decode-charset
3738 article-decode-encoded-words
3742 article-treat-dumbquotes
3743 article-normalize-headers
3744 (article-show-all-headers . gnus-article-show-all-headers)
3745 ;; (article-show-all . gnus-article-show-all)
3749 ;;; Gnus article mode
3752 (put 'gnus-article-mode 'mode-class 'special)
3754 (gnus-define-keys gnus-article-mode-map
3755 " " gnus-article-goto-next-page
3756 "\177" gnus-article-goto-prev-page
3757 [delete] gnus-article-goto-prev-page
3758 [backspace] gnus-article-goto-prev-page
3759 "\C-c^" gnus-article-refer-article
3760 "h" gnus-article-show-summary
3761 "s" gnus-article-show-summary
3762 "\C-c\C-m" gnus-article-mail
3763 "?" gnus-article-describe-briefly
3764 "e" gnus-summary-edit-article
3765 "<" beginning-of-buffer
3767 "\C-c\C-i" gnus-info-find-node
3769 "R" gnus-article-reply-with-original
3770 "F" gnus-article-followup-with-original
3771 "\C-hk" gnus-article-describe-key
3772 "\C-hc" gnus-article-describe-key-briefly
3774 "\C-d" gnus-article-read-summary-keys
3775 "\M-*" gnus-article-read-summary-keys
3776 "\M-#" gnus-article-read-summary-keys
3777 "\M-^" gnus-article-read-summary-keys
3778 "\M-g" gnus-article-read-summary-keys)
3780 ;; Define almost undefined keys to `gnus-article-read-summary-keys'.
3784 (push (char-to-string key) keys)
3786 (dolist (elem (accessible-keymaps gnus-summary-mode-map))
3787 (setq key (car elem))
3788 (when (and (> (length key) 0)
3789 (not (eq 'menu-bar (aref key 0)))
3790 (symbolp (lookup-key gnus-summary-mode-map key)))
3793 (unless (lookup-key gnus-article-mode-map key)
3794 (define-key gnus-article-mode-map key 'gnus-article-read-summary-keys))))
3796 (defun gnus-article-make-menu-bar ()
3797 (unless (boundp 'gnus-article-commands-menu)
3798 (gnus-summary-make-menu-bar))
3799 (gnus-turn-off-edit-menu 'article)
3800 (unless (boundp 'gnus-article-article-menu)
3802 gnus-article-article-menu gnus-article-mode-map ""
3804 ["Scroll forwards" gnus-article-goto-next-page t]
3805 ["Scroll backwards" gnus-article-goto-prev-page t]
3806 ["Show summary" gnus-article-show-summary t]
3807 ["Fetch Message-ID at point" gnus-article-refer-article t]
3808 ["Mail to address at point" gnus-article-mail t]
3809 ["Send a bug report" gnus-bug t]))
3812 gnus-article-treatment-menu gnus-article-mode-map ""
3813 ;; Fixme: this should use :active (and maybe :visible).
3815 ["Hide headers" gnus-article-hide-headers t]
3816 ["Hide signature" gnus-article-hide-signature t]
3817 ["Hide citation" gnus-article-hide-citation t]
3818 ["Treat overstrike" gnus-article-treat-overstrike t]
3819 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
3820 ["Remove carriage return" gnus-article-remove-cr t]
3821 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3822 ["Treat html" gnus-article-wash-html t]
3823 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3824 ["Decode HZ" gnus-article-decode-HZ t]))
3826 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3828 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3830 (gnus-run-hooks 'gnus-article-menu-hook)))
3832 (defun gnus-article-mode ()
3833 "Major mode for displaying an article.
3835 All normal editing commands are switched off.
3837 The following commands are available in addition to all summary mode
3839 \\<gnus-article-mode-map>
3840 \\[gnus-article-next-page]\t Scroll the article one page forwards
3841 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3842 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3843 \\[gnus-article-show-summary]\t Display the summary buffer
3844 \\[gnus-article-mail]\t Send a reply to the address near point
3845 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3846 \\[gnus-info-find-node]\t Go to the Gnus info node"
3848 (gnus-simplify-mode-line)
3849 (setq mode-name "Article")
3850 (setq major-mode 'gnus-article-mode)
3851 (make-local-variable 'minor-mode-alist)
3852 (unless (assq 'gnus-show-mime minor-mode-alist)
3853 (push (list 'gnus-show-mime " MIME") minor-mode-alist))
3854 (use-local-map gnus-article-mode-map)
3855 (when (gnus-visual-p 'article-menu 'menu)
3856 (gnus-article-make-menu-bar)
3857 (when gnus-summary-tool-bar-map
3858 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3859 (gnus-update-format-specifications nil 'article-mode)
3860 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3861 (set (make-local-variable 'gnus-page-broken) nil)
3862 (make-local-variable 'gnus-button-marker-list)
3863 (make-local-variable 'gnus-article-current-summary)
3864 (make-local-variable 'gnus-article-mime-handles)
3865 (make-local-variable 'gnus-article-decoded-p)
3866 (make-local-variable 'gnus-article-mime-handle-alist)
3867 (make-local-variable 'gnus-article-wash-types)
3868 (make-local-variable 'gnus-article-image-alist)
3869 (make-local-variable 'gnus-article-charset)
3870 (make-local-variable 'gnus-article-ignored-charsets)
3871 (gnus-set-default-directory)
3872 (buffer-disable-undo)
3873 (setq buffer-read-only t
3874 show-trailing-whitespace nil)
3875 (set-syntax-table gnus-article-mode-syntax-table)
3876 (gnus-run-hooks 'gnus-article-mode-hook))
3878 (defun gnus-article-setup-buffer ()
3879 "Initialize the article buffer."
3880 (let* ((name (if gnus-single-article-buffer "*Article*"
3881 (concat "*Article " gnus-newsgroup-name "*")))
3883 (progn (string-match "\\*Article" name)
3884 (concat " *Original Article"
3885 (substring name (match-end 0))))))
3886 (setq gnus-article-buffer name)
3887 (setq gnus-original-article-buffer original)
3888 (setq gnus-article-mime-handle-alist nil)
3889 ;; This might be a variable local to the summary buffer.
3890 (unless gnus-single-article-buffer
3892 (set-buffer gnus-summary-buffer)
3893 (setq gnus-article-buffer name)
3894 (setq gnus-original-article-buffer original)
3895 (gnus-set-global-variables)))
3896 (gnus-article-setup-highlight-words)
3897 ;; Init original article buffer.
3899 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3900 (set-buffer-multibyte t)
3901 (setq major-mode 'gnus-original-article-mode)
3902 (make-local-variable 'gnus-original-article))
3903 (if (get-buffer name)
3906 (when (and gnus-article-edit-mode
3909 (y-or-n-p "Article mode edit in progress; discard? ")))
3910 (error "Action aborted"))
3911 (set (make-local-variable 'gnus-article-edit-mode) nil)
3912 (buffer-disable-undo)
3913 (setq buffer-read-only t)
3914 ;; This list just keeps growing if we don't reset it.
3915 (setq gnus-button-marker-list nil)
3916 (unless (eq major-mode 'gnus-article-mode)
3917 (gnus-article-mode))
3920 (set-buffer (gnus-get-buffer-create name))
3922 (make-local-variable 'gnus-summary-buffer)
3923 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3924 (current-buffer)))))
3926 ;; Set article window start at LINE, where LINE is the number of lines
3927 ;; from the head of the article.
3928 (defun gnus-article-set-window-start (&optional line)
3930 (gnus-get-buffer-window gnus-article-buffer t)
3932 (set-buffer gnus-article-buffer)
3933 (goto-char (point-min))
3936 (gnus-message 6 "Moved to bookmark")
3937 (search-forward "\n\n" nil t)
3941 ;;; @@ article filters
3944 (defun gnus-article-display-mime-message ()
3945 "Article display method for MIME message."
3946 ;; called from `gnus-original-article-buffer'.
3947 (let (charset all-headers)
3948 (with-current-buffer gnus-summary-buffer
3949 (setq charset default-mime-charset
3950 all-headers gnus-have-all-headers))
3951 (make-local-variable 'default-mime-charset)
3952 (setq default-mime-charset charset)
3953 (with-current-buffer (get-buffer-create gnus-article-buffer)
3954 (make-local-variable 'default-mime-charset)
3955 (setq default-mime-charset charset))
3956 (mime-display-message mime-message-structure
3957 gnus-article-buffer nil gnus-article-mode-map)
3959 (gnus-article-hide-headers nil -1)))
3960 (run-hooks 'gnus-mime-article-prepare-hook))
3962 (defun gnus-article-display-traditional-message ()
3963 "Article display method for traditional message."
3964 (set-buffer gnus-article-buffer)
3965 (let ((inhibit-read-only t))
3967 (insert-buffer-substring gnus-original-article-buffer)))
3969 (defun gnus-article-make-full-mail-header (&optional number charset)
3970 "Create a new mail header structure in a raw article buffer."
3971 (unless (and number charset)
3972 (save-current-buffer
3973 (set-buffer gnus-summary-buffer)
3975 (setq number (or (cdr gnus-article-current) 0)))
3977 (setq charset (or default-mime-charset 'x-ctext)))))
3978 (goto-char (point-min))
3979 (let ((header-end (if (search-forward "\n\n" nil t)
3981 (goto-char (point-max))))
3982 (chars (- (point-max) (point)))
3983 (lines (count-lines (point) (point-max)))
3984 (default-mime-charset charset)
3986 (narrow-to-region (point-min) header-end)
3987 (setq xref (std11-fetch-field "xref"))
3989 (make-full-mail-header
3991 (std11-fetch-field "subject")
3992 (std11-fetch-field "from")
3993 (std11-fetch-field "date")
3994 (std11-fetch-field "message-id")
3995 (std11-fetch-field "references")
3998 (when xref (concat "Xref: " xref)))
4001 (defun gnus-article-prepare (article &optional all-headers header)
4002 "Prepare ARTICLE in article mode buffer.
4003 ARTICLE should either be an article number or a Message-ID.
4004 If ARTICLE is an id, HEADER should be the article headers.
4005 If ALL-HEADERS is non-nil, no headers are hidden."
4007 ;; Make sure we start in a summary buffer.
4008 (unless (eq major-mode 'gnus-summary-mode)
4009 (set-buffer gnus-summary-buffer))
4010 (setq gnus-summary-buffer (current-buffer))
4011 (let* ((gnus-article (if header (mail-header-number header) article))
4012 (summary-buffer (current-buffer))
4013 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
4014 (group gnus-newsgroup-name)
4017 (gnus-article-setup-buffer)
4018 (set-buffer gnus-article-buffer)
4019 ;; Deactivate active regions.
4020 (when (and (boundp 'transient-mark-mode)
4021 transient-mark-mode)
4022 (setq mark-active nil))
4023 (if (not (setq result (let ((inhibit-read-only t))
4024 (gnus-request-article-this-buffer
4026 ;; There is no such article.
4028 (when (and (numberp article)
4029 (not (memq article gnus-newsgroup-sparse)))
4030 (setq gnus-article-current
4031 (cons gnus-newsgroup-name article))
4032 (set-buffer gnus-summary-buffer)
4033 (setq gnus-current-article article)
4034 (if (and (memq article gnus-newsgroup-undownloaded)
4035 (not (gnus-online (gnus-find-method-for-group
4036 gnus-newsgroup-name))))
4038 (gnus-summary-set-agent-mark article)
4039 (message "Message marked for downloading"))
4040 (gnus-summary-mark-article article gnus-canceled-mark)
4041 (unless (memq article gnus-newsgroup-sparse)
4042 (gnus-error 1 "No such article (may have expired or been canceled)")))))
4043 (if (or (eq result 'pseudo)
4044 (eq result 'nneething))
4047 (set-buffer summary-buffer)
4048 (push article gnus-newsgroup-history)
4049 (setq gnus-last-article gnus-current-article
4050 gnus-current-article 0
4051 gnus-current-headers nil
4052 gnus-article-current nil)
4053 (if (eq result 'nneething)
4054 (gnus-configure-windows 'summary)
4055 (gnus-configure-windows 'article))
4056 (gnus-set-global-variables))
4057 (let ((gnus-article-mime-handle-alist-1
4058 gnus-article-mime-handle-alist))
4059 (gnus-set-mode-line 'article)))
4060 ;; The result from the `request' was an actual article -
4061 ;; or at least some text that is now displayed in the
4063 (when (and (numberp article)
4064 (not (eq article gnus-current-article)))
4065 ;; Seems like a new article has been selected.
4066 ;; `gnus-current-article' must be an article number.
4068 (set-buffer summary-buffer)
4069 (push article gnus-newsgroup-history)
4070 (setq gnus-last-article gnus-current-article
4071 gnus-current-article article
4072 gnus-current-headers
4073 (gnus-summary-article-header gnus-current-article)
4074 gnus-article-current
4075 (cons gnus-newsgroup-name gnus-current-article))
4076 (unless (vectorp gnus-current-headers)
4077 (setq gnus-current-headers nil))
4078 (gnus-summary-goto-subject gnus-current-article)
4079 (when (gnus-summary-show-thread)
4080 ;; If the summary buffer really was folded, the
4081 ;; previous goto may not actually have gone to
4082 ;; the right article, but the thread root instead.
4084 (gnus-summary-goto-subject gnus-current-article))
4085 (gnus-run-hooks 'gnus-mark-article-hook)
4086 (gnus-set-mode-line 'summary)
4087 (when (gnus-visual-p 'article-highlight 'highlight)
4088 (gnus-run-hooks 'gnus-visual-mark-article-hook))
4089 ;; Set the global newsgroup variables here.
4090 (gnus-set-global-variables)
4091 (setq gnus-have-all-headers
4092 (or all-headers gnus-show-all-headers))))
4094 (gnus-configure-windows 'article))
4095 (when (or (numberp article)
4097 (gnus-article-prepare-display)
4099 (goto-char (point-min))
4100 (when gnus-break-pages
4101 (gnus-narrow-to-page)))
4102 (let ((gnus-article-mime-handle-alist-1
4103 gnus-article-mime-handle-alist))
4104 (gnus-set-mode-line 'article))
4108 (set-window-point (get-buffer-window (current-buffer)) (point))
4109 (gnus-configure-windows 'article)
4112 (defun gnus-article-prepare-mime-display (&optional number)
4113 (goto-char (point-min))
4114 (when (re-search-forward "^[^\t ]+:" nil t)
4115 (goto-char (match-beginning 0)))
4116 (let ((entity (if (eq 1 (point-min))
4117 (get-text-property 1 'mime-view-entity)
4118 (get-text-property (point) 'mime-view-entity)))
4119 last-entity child-entity next type)
4120 (setq child-entity (mime-entity-children entity))
4122 (setq last-entity (nth (1- (length child-entity))
4124 (setq last-entity entity))
4126 (narrow-to-region (point)
4127 (if (search-forward "\n\n" nil t)
4130 (gnus-treat-article 'head)
4131 (put-text-property (point-min) (point-max) 'article-treated-header t)
4132 (goto-char (point-max)))
4133 (while (and (not (eobp)) entity)
4134 (setq next (set-marker
4136 (next-single-property-change (point) 'mime-view-entity
4138 (let ((types (mime-entity-content-type entity)))
4139 (while (eq 'multipart (mime-content-type-primary-type types))
4140 (setq entity (car (mime-entity-children entity))
4141 types (mime-entity-content-type entity)))
4143 (setq type (format "%s/%s"
4144 (mime-content-type-primary-type types)
4145 (mime-content-type-subtype types)))))
4146 (if (string-equal type "message/rfc822")
4149 (let ((children (mime-entity-children entity))
4152 (setq last-children (nth (1- (length children)) children))
4155 (not (eq last-children
4156 (get-text-property next 'mime-view-entity)))
4158 (next-single-property-change next
4160 nil (point-max)))))))
4161 (setq next (next-single-property-change next 'mime-view-entity
4164 (narrow-to-region (point) next)
4165 (gnus-article-prepare-mime-display)
4166 (goto-char (point-max)))
4167 (setq entity (get-text-property (point) 'mime-view-entity)))
4169 (narrow-to-region (point) next)
4170 ;; Kludge. We have to count true number, but for now,
4171 ;; part number is here only to achieve `last'.
4172 (gnus-treat-article nil 1
4173 (if (eq entity last-entity)
4176 (goto-char (point-max)))
4177 (setq entity (get-text-property next 'mime-view-entity))))))
4180 (defun gnus-article-prepare-display ()
4181 "Make the current buffer look like a nice article."
4182 (let ((gnus-article-buffer (current-buffer))
4184 (inhibit-read-only t))
4185 (unless (eq major-mode 'gnus-article-mode)
4186 (gnus-article-mode))
4187 (setq buffer-read-only nil
4188 gnus-button-marker-list nil
4189 gnus-article-wash-types nil
4190 gnus-article-image-alist nil)
4193 (static-if (featurep 'xemacs)
4194 (map-extents (lambda (extent maparg) (delete-extent extent)))
4195 (let ((lists (overlay-lists)))
4196 (dolist (overlay (nconc (car lists) (cdr lists)))
4197 (delete-overlay overlay)))))
4198 (gnus-run-hooks 'gnus-tmp-internal-hook))
4199 (let ((show-mime (unless (member gnus-newsgroup-name '("nndraft:delayed"
4202 (inhibit-read-only t))
4203 (set-buffer gnus-original-article-buffer)
4205 (setq mime-message-structure gnus-current-headers)
4206 (mime-buffer-entity-set-buffer-internal mime-message-structure
4207 gnus-original-article-buffer)
4208 (mime-entity-set-representation-type-internal mime-message-structure
4209 'mime-buffer-entity)
4210 (luna-send mime-message-structure 'initialize-instance
4211 mime-message-structure)
4213 (let (mime-display-header-hook mime-display-text/plain-hook)
4214 (funcall gnus-article-display-method-for-mime))
4215 (funcall gnus-article-display-method-for-traditional))
4216 ;; Call the treatment functions.
4220 (gnus-article-prepare-mime-display)
4221 (narrow-to-region (goto-char (point-min))
4222 (if (search-forward "\n\n" nil t)
4225 (gnus-treat-article 'head)
4226 (put-text-property (point-min) (point-max) 'article-treated-header t)
4227 (goto-char (point-max))
4229 (narrow-to-region (point) (point-max))
4230 (gnus-treat-article nil))
4231 (put-text-property (point-min) (point-max) 'read-only nil)))
4232 (gnus-run-hooks 'gnus-article-prepare-hook))
4234 (defun gnus-article-decode-article-as-default-mime-charset ()
4235 "Decode an article as `default-mime-charset'. It won't work if the
4236 value of the variable `gnus-show-mime' is non-nil."
4237 (unless (or gnus-show-mime
4238 (member gnus-newsgroup-name '("nndraft:delayed"
4240 (set (make-local-variable 'default-mime-charset)
4241 (with-current-buffer gnus-summary-buffer
4242 default-mime-charset))
4243 (decode-mime-charset-region (point-min) (point-max)
4244 default-mime-charset)))
4247 ;;; Gnus MIME viewing functions
4250 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4251 "Format of the MIME buttons.
4253 Valid specifiers include:
4255 %T MIME type, along with additional info
4256 %n The `name' parameter
4257 %d The description, if any
4258 %l The length of the encoded part
4259 %p The part identifier number
4260 %e Dots if the part isn't displayed
4262 General format specifiers can also be used. See Info node
4263 `(gnus)Formatting Variables'.")
4265 (defvar gnus-mime-button-line-format-alist
4266 '((?t gnus-tmp-type ?s)
4267 (?T gnus-tmp-type-long ?s)
4268 (?n gnus-tmp-name ?s)
4269 (?d gnus-tmp-description ?s)
4271 (?l gnus-tmp-length ?d)
4272 (?e gnus-tmp-dots ?s)))
4274 (defvar gnus-mime-button-commands
4275 '((gnus-article-press-button "\r" "Toggle Display")
4276 (gnus-mime-view-part "v" "View Interactively...")
4277 (gnus-mime-view-part-as-type "t" "View As Type...")
4278 (gnus-mime-view-part-as-charset "C" "View As charset...")
4279 (gnus-mime-save-part "o" "Save...")
4280 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4281 (gnus-mime-delete-part "d" "Delete part")
4282 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4283 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4284 (gnus-mime-view-part-internally "E" "View Internally")
4285 (gnus-mime-view-part-externally "e" "View Externally")
4286 (gnus-mime-print-part "p" "Print")
4287 (gnus-mime-pipe-part "|" "Pipe To Command...")
4288 (gnus-mime-action-on-part "." "Take action on the part...")))
4290 (defun gnus-article-mime-part-status ()
4291 (with-current-buffer gnus-article-buffer
4292 (let ((entity (get-text-property (point-min) 'mime-view-entity))
4295 (setq children (mime-entity-children entity))
4296 (setq children (length children)))
4299 (format " (%d parts)" children))
4302 (defvar gnus-mime-button-map
4303 (let ((map (make-sparse-keymap)))
4304 (define-key map gnus-mouse-2 'gnus-article-push-button)
4305 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4306 (dolist (c gnus-mime-button-commands)
4307 (define-key map (cadr c) (car c)))
4311 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4313 ,@(mapcar (lambda (c)
4314 (vector (caddr c) (car c) :enable t))
4315 gnus-mime-button-commands)))
4317 (defun gnus-mime-button-menu (event prefix)
4318 "Construct a context-sensitive menu of MIME commands."
4319 (interactive "e\nP")
4320 (save-window-excursion
4321 (let ((pos (event-start event)))
4322 (select-window (posn-window pos))
4323 (goto-char (posn-point pos))
4324 (gnus-article-check-buffer)
4325 (popup-menu gnus-mime-button-menu nil prefix))))
4327 (defun gnus-mime-view-all-parts (&optional handles)
4328 "View all the MIME parts."
4330 (with-current-buffer gnus-article-buffer
4331 (let ((handles (or handles gnus-article-mime-handles))
4332 (mail-parse-charset gnus-newsgroup-charset)
4333 (mail-parse-ignored-charsets
4334 (with-current-buffer gnus-summary-buffer
4335 gnus-newsgroup-ignored-charsets)))
4337 (mm-remove-parts handles)
4338 (goto-char (point-min))
4339 (or (search-forward "\n\n") (goto-char (point-max)))
4340 (let ((inhibit-read-only t))
4341 (delete-region (point) (point-max))
4342 (mm-display-parts handles))))))
4345 (defsubst gnus-article-edit-part (handles)
4346 "Edit an article in order to delete a mime part.
4347 This function is exclusively used by `gnus-mime-save-part-and-strip'
4348 and `gnus-mime-delete-part', and not provided at run-time normally."
4349 (gnus-article-edit-article
4352 (let ((mail-parse-charset (or gnus-article-charset
4353 ',gnus-newsgroup-charset))
4354 (mail-parse-ignored-charsets
4355 (or gnus-article-ignored-charsets
4356 ',gnus-newsgroup-ignored-charsets))
4357 (mbl mml-buffer-list))
4358 (setq mml-buffer-list nil)
4359 (insert-buffer gnus-original-article-buffer)
4360 (mime-to-mml ',handles)
4361 (setq gnus-article-mime-handles nil)
4362 (let ((mbl1 mml-buffer-list))
4363 (setq mml-buffer-list mbl)
4364 (set (make-local-variable 'mml-buffer-list) mbl1))
4365 (gnus-make-local-hook 'kill-buffer-hook)
4366 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4367 `(lambda (no-highlight)
4368 (let ((mail-parse-charset (or gnus-article-charset
4369 ',gnus-newsgroup-charset))
4370 (message-options message-options)
4371 (message-options-set-recipient)
4372 (mail-parse-ignored-charsets
4373 (or gnus-article-ignored-charsets
4374 ',gnus-newsgroup-ignored-charsets)))
4376 (mml-destroy-buffers)
4377 (remove-hook 'kill-buffer-hook
4378 'mml-destroy-buffers t)
4379 (kill-local-variable 'mml-buffer-list))
4380 (gnus-summary-edit-article-done
4381 ,(or (mail-header-references gnus-current-headers) "")
4382 ,(gnus-group-read-only-p)
4383 ,gnus-summary-buffer no-highlight)))
4384 (gnus-article-edit-done)
4385 (gnus-summary-expand-window)
4386 (gnus-summary-show-article)))
4388 (defun gnus-mime-save-part-and-strip ()
4389 "Save the MIME part under point then replace it with an external body."
4391 (gnus-article-check-buffer)
4392 (when (gnus-group-read-only-p)
4393 (error "The current group does not support deleting of parts"))
4394 (when (mm-complicated-handles gnus-article-mime-handles)
4396 The current article has a complicated MIME structure, giving up..."))
4397 (when (gnus-yes-or-no-p "\
4398 Deleting parts may malfunction or destroy the article; continue? ")
4399 (let* ((data (get-text-property (point) 'gnus-data))
4401 (handles gnus-article-mime-handles))
4402 (setq file (and data (mm-save-part data)))
4404 (with-current-buffer (mm-handle-buffer data)
4406 (insert "Content-Type: " (mm-handle-media-type data))
4407 (mml-insert-parameter-string (cdr (mm-handle-type data))
4410 (insert "Content-ID: " (message-make-message-id) "\n")
4411 (insert "Content-Transfer-Encoding: binary\n")
4414 (cdr (mm-make-handle nil
4415 `("message/external-body"
4416 (access-type . "LOCAL-FILE")
4418 (set-buffer gnus-summary-buffer)
4419 (gnus-article-edit-part handles)))))
4421 (defun gnus-mime-delete-part ()
4422 "Delete the MIME part under point.
4423 Replace it with some information about the removed part."
4425 (gnus-article-check-buffer)
4426 (when (gnus-group-read-only-p)
4427 (error "The current group does not support deleting of parts"))
4428 (when (mm-complicated-handles gnus-article-mime-handles)
4430 The current article has a complicated MIME structure, giving up..."))
4431 (when (gnus-yes-or-no-p "\
4432 Deleting parts may malfunction or destroy the article; continue? ")
4433 (let* ((data (get-text-property (point) 'gnus-data))
4434 (handles gnus-article-mime-handles)
4438 (mail-decode-encoded-word-string (or (mm-handle-description data)
4441 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4443 (type (mm-handle-media-type data)))
4445 (error "No MIME part under point"))
4446 (with-current-buffer (mm-handle-buffer data)
4447 (let ((bsize (format "%s" (buffer-size))))
4452 "| The following attachment has been deleted:\n"
4454 "| Type: " type "\n"
4455 "| Filename: " filename "\n"
4456 "| Size (encoded): " bsize " Byte\n"
4457 "| Description: " description "\n"
4460 (cdr (mm-make-handle
4461 nil `("text/plain") nil nil
4463 (format "Deleted attachment (%s bytes)" bsize))))))
4464 (set-buffer gnus-summary-buffer)
4465 (gnus-article-edit-part handles))))
4467 (defun gnus-mime-save-part ()
4468 "Save the MIME part under point."
4470 (gnus-article-check-buffer)
4471 (let ((data (get-text-property (point) 'gnus-data)))
4473 (mm-save-part data))))
4475 (defun gnus-mime-pipe-part ()
4476 "Pipe the MIME part under point to a process."
4478 (gnus-article-check-buffer)
4479 (let ((data (get-text-property (point) 'gnus-data)))
4481 (mm-pipe-part data))))
4483 (defun gnus-mime-view-part ()
4484 "Interactively choose a viewing method for the MIME part under point."
4486 (gnus-article-check-buffer)
4487 (let ((data (get-text-property (point) 'gnus-data)))
4489 (setq gnus-article-mime-handles
4491 gnus-article-mime-handles (setq data (copy-sequence data))))
4492 (mm-interactively-view-part data))))
4494 (defun gnus-mime-view-part-as-type-internal ()
4495 (gnus-article-check-buffer)
4496 (let* ((name (mail-content-type-get
4497 (mm-handle-type (get-text-property (point) 'gnus-data))
4499 (def-type (and name (mm-default-file-encoding name))))
4500 (and def-type (cons def-type 0))))
4502 (defun gnus-mime-view-part-as-type (&optional mime-type)
4503 "Choose a MIME media type, and view the part as such."
4506 (setq mime-type (completing-read
4507 "View as MIME type: "
4508 (mapcar #'list (mailcap-mime-types))
4510 (gnus-mime-view-part-as-type-internal))))
4511 (gnus-article-check-buffer)
4512 (let ((handle (get-text-property (point) 'gnus-data)))
4515 (mm-make-handle (mm-handle-buffer handle)
4516 (cons mime-type (cdr (mm-handle-type handle)))
4517 (mm-handle-encoding handle)
4518 (mm-handle-undisplayer handle)
4519 (mm-handle-disposition handle)
4520 (mm-handle-description handle)
4522 (mm-handle-id handle)))
4523 (setq gnus-article-mime-handles
4524 (mm-merge-handles gnus-article-mime-handles handle))
4525 (gnus-mm-display-part handle))))
4528 (require 'jka-compr))
4530 ;; jka-compr.el uses a "sh -c" to direct stderr to err-file, but these days
4531 ;; emacs can do that itself.
4533 (defun gnus-mime-jka-compr-maybe-uncompress ()
4534 "Uncompress the current buffer if `auto-compression-mode' is enabled.
4535 The uncompress method used is derived from `buffer-file-name'."
4536 (when (and (fboundp 'jka-compr-installed-p)
4537 (jka-compr-installed-p))
4538 (let ((info (jka-compr-get-compression-info buffer-file-name)))
4540 (let ((basename (file-name-nondirectory buffer-file-name))
4541 (args (jka-compr-info-uncompress-args info))
4542 (prog (jka-compr-info-uncompress-program info))
4543 (message (jka-compr-info-uncompress-message info))
4544 (err-file (jka-compr-make-temp-name)))
4546 (message "%s %s..." message basename))
4548 (unless (memq (apply 'call-process-region
4549 (point-min) (point-max)
4551 t (list t err-file) nil
4553 jka-compr-acceptable-retval-list)
4554 (jka-compr-error prog args basename message err-file))
4555 (jka-compr-delete-temp-file err-file)))))))
4557 (defun gnus-mime-copy-part (&optional handle)
4558 "Put the MIME part under point into a new buffer.
4559 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4562 (gnus-article-check-buffer)
4563 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4564 (contents (and handle (mm-get-part handle)))
4566 (file-name-nondirectory
4568 (mail-content-type-get (mm-handle-type handle) 'name)
4569 (mail-content-type-get (mm-handle-disposition handle)
4572 (buffer (and base (generate-new-buffer base))))
4574 (switch-to-buffer buffer)
4576 ;; We do it this way to make `normal-mode' set the appropriate mode.
4579 (setq buffer-file-name (expand-file-name base))
4580 (gnus-mime-jka-compr-maybe-uncompress)
4582 (setq buffer-file-name nil))
4583 (goto-char (point-min)))))
4585 (defun gnus-mime-print-part (&optional handle filename)
4586 "Print the MIME part under point."
4587 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4588 (gnus-article-check-buffer)
4589 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4590 (contents (and handle (mm-get-part handle)))
4591 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4592 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4597 (mm-save-part-to-file handle file)
4598 (call-process shell-file-name nil
4599 (generate-new-buffer " *mm*")
4601 shell-command-switch
4603 printer file (mm-handle-type handle))))
4607 (gnus-print-buffer))
4608 (ps-despool filename)))))
4610 (defun gnus-mime-inline-part (&optional handle arg)
4611 "Insert the MIME part under point into the current buffer."
4612 (interactive (list nil current-prefix-arg))
4613 (gnus-article-check-buffer)
4614 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4617 (inhibit-read-only t))
4619 (if (and (not arg) (mm-handle-undisplayer handle))
4620 (mm-remove-part handle)
4621 (setq contents (mm-get-part handle))
4624 (setq charset (or (mail-content-type-get
4625 (mm-handle-type handle) 'charset)
4626 gnus-newsgroup-charset)))
4628 (if (mm-handle-undisplayer handle)
4629 (mm-remove-part handle))
4632 gnus-summary-show-article-charset-alist))
4633 (mm-read-coding-system "Charset: ")))))
4635 (mm-insert-inline handle
4637 (setq charset (mm-charset-to-coding-system
4639 (not (eq charset 'ascii)))
4640 (mm-decode-coding-string contents charset)
4644 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4645 "Insert the MIME part under point into the current buffer using the
4647 (interactive (list nil current-prefix-arg))
4648 (gnus-article-check-buffer)
4649 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4652 (inhibit-read-only t))
4654 (if (mm-handle-undisplayer handle)
4655 (mm-remove-part handle))
4656 (let ((gnus-newsgroup-charset
4658 gnus-summary-show-article-charset-alist))
4659 (mm-read-coding-system "Charset: ")))
4660 (gnus-newsgroup-ignored-charsets 'gnus-all))
4661 (gnus-article-press-button)))))
4663 (defun gnus-mime-view-part-externally (&optional handle)
4664 "View the MIME part under point with an external viewer."
4666 (gnus-article-check-buffer)
4667 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4668 (mm-user-display-methods nil)
4669 (mm-inlined-types nil)
4670 (mail-parse-charset gnus-newsgroup-charset)
4671 (mail-parse-ignored-charsets
4672 (with-current-buffer gnus-summary-buffer
4673 gnus-newsgroup-ignored-charsets)))
4675 (if (mm-handle-undisplayer handle)
4676 (mm-remove-part handle)
4677 (mm-display-part handle)))))
4679 (defun gnus-mime-view-part-internally (&optional handle)
4680 "View the MIME part under point with an internal viewer.
4681 If no internal viewer is available, use an external viewer."
4683 (gnus-article-check-buffer)
4684 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4685 (mm-inlined-types '(".*"))
4686 (mm-inline-large-images t)
4687 (mail-parse-charset gnus-newsgroup-charset)
4688 (mail-parse-ignored-charsets
4689 (with-current-buffer gnus-summary-buffer
4690 gnus-newsgroup-ignored-charsets))
4691 (inhibit-read-only t))
4693 (if (mm-handle-undisplayer handle)
4694 (mm-remove-part handle)
4695 (mm-display-part handle)))))
4697 (defun gnus-mime-action-on-part (&optional action)
4698 "Do something with the MIME attachment at \(point\)."
4700 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4701 (gnus-article-check-buffer)
4702 (let ((action-pair (assoc action gnus-mime-action-alist)))
4704 (funcall (cdr action-pair)))))
4706 (defun gnus-article-part-wrapper (n function)
4707 (with-current-buffer gnus-article-buffer
4708 (when (> n (length gnus-article-mime-handle-alist))
4709 (error "No such part"))
4710 (gnus-article-goto-part n)
4711 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4712 (funcall function handle))))
4714 (defun gnus-article-pipe-part (n)
4715 "Pipe MIME part N, which is the numerical prefix."
4717 (gnus-article-part-wrapper n 'mm-pipe-part))
4719 (defun gnus-article-save-part (n)
4720 "Save MIME part N, which is the numerical prefix."
4722 (gnus-article-part-wrapper n 'mm-save-part))
4724 (defun gnus-article-interactively-view-part (n)
4725 "View MIME part N interactively, which is the numerical prefix."
4727 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4729 (defun gnus-article-copy-part (n)
4730 "Copy MIME part N, which is the numerical prefix."
4732 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4734 (defun gnus-article-view-part-as-charset (n)
4735 "View MIME part N using a specified charset.
4736 N is the numerical prefix."
4738 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4740 (defun gnus-article-view-part-externally (n)
4741 "View MIME part N externally, which is the numerical prefix."
4743 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4745 (defun gnus-article-inline-part (n)
4746 "Inline MIME part N, which is the numerical prefix."
4748 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4750 (defun gnus-article-mime-match-handle-first (condition)
4753 (dolist (ihandle gnus-article-mime-handle-alist)
4755 ((functionp condition)
4756 (funcall condition (cdr ihandle)))
4757 ((eq condition 'undisplayed)
4758 (not (or (mm-handle-undisplayer (cdr ihandle))
4759 (equal (mm-handle-media-type (cdr ihandle))
4760 "multipart/alternative"))))
4761 ((eq condition 'undisplayed-alternative)
4762 (not (mm-handle-undisplayer (cdr ihandle))))
4764 (gnus-article-goto-part (car ihandle))
4765 (or (not n) (< (car ihandle) n)))
4766 (setq n (car ihandle))))
4770 (defun gnus-article-view-part (&optional n)
4771 "View MIME part N, which is the numerical prefix."
4773 (with-current-buffer gnus-article-buffer
4774 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4775 gnus-article-mime-match-handle-function)))
4776 (when (> n (length gnus-article-mime-handle-alist))
4777 (error "No such part"))
4778 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4779 (when (gnus-article-goto-part n)
4780 (if (equal (car handle) "multipart/alternative")
4781 (gnus-article-press-button)
4782 (when (eq (gnus-mm-display-part handle) 'internal)
4783 (gnus-set-window-start)))))))
4785 (defsubst gnus-article-mime-total-parts ()
4786 (if (bufferp (car gnus-article-mime-handles))
4788 (1- (length gnus-article-mime-handles))))
4790 (defun gnus-mm-display-part (handle)
4791 "Display HANDLE and fix MIME button."
4792 (let ((id (get-text-property (point) 'gnus-part))
4794 (inhibit-read-only t))
4797 (let ((window (selected-window))
4798 (mail-parse-charset gnus-newsgroup-charset)
4799 (mail-parse-ignored-charsets
4800 (if (gnus-buffer-live-p gnus-summary-buffer)
4801 (with-current-buffer gnus-summary-buffer
4802 gnus-newsgroup-ignored-charsets)
4806 (let ((win (gnus-get-buffer-window (current-buffer) t))
4809 (select-window win))
4812 (if (mm-handle-displayed-p handle)
4813 ;; This will remove the part.
4814 (mm-display-part handle)
4816 (narrow-to-region (point)
4817 (if (eobp) (point) (1+ (point))))
4818 (mm-display-part handle)
4819 ;; We narrow to the part itself and
4820 ;; then call the treatment functions.
4821 (goto-char (point-min))
4823 (narrow-to-region (point) (point-max))
4826 (gnus-article-mime-total-parts)
4827 (mm-handle-media-type handle)))))
4828 (if (window-live-p window)
4829 (select-window window)))))
4832 (gnus-insert-mime-button
4833 handle id (list (mm-handle-displayed-p handle)))
4834 (goto-char point))))
4836 (defun gnus-article-goto-part (n)
4837 "Go to MIME part N."
4838 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4840 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4841 (let ((gnus-tmp-name
4842 (or (mail-content-type-get (mm-handle-type handle) 'name)
4843 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4844 (mail-content-type-get (mm-handle-type handle) 'url)
4846 (gnus-tmp-type (mm-handle-media-type handle))
4847 (gnus-tmp-description
4848 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4851 (if (if displayed (car displayed)
4852 (mm-handle-displayed-p handle))
4854 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4856 gnus-tmp-type-long b e)
4857 (when (string-match ".*/" gnus-tmp-name)
4858 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4859 (setq gnus-tmp-type-long (concat gnus-tmp-type
4860 (and (not (equal gnus-tmp-name ""))
4861 (concat "; " gnus-tmp-name))))
4862 (unless (equal gnus-tmp-description "")
4863 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4868 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4869 `(keymap ,gnus-mime-button-map
4870 gnus-callback gnus-mm-display-part
4871 gnus-part ,gnus-tmp-id
4872 article-type annotation
4875 ;; Exclude a newline.
4878 (widget-convert-button
4881 :action 'gnus-widget-press-button
4882 :button-keymap gnus-mime-button-map
4884 (lambda (widget/window &optional overlay pos)
4885 ;; Needed to properly clear the message due to a bug in
4886 ;; wid-edit (XEmacs only).
4887 (if (boundp 'help-echo-owns-message)
4888 (setq help-echo-owns-message t))
4890 "%S: %s the MIME part; %S: more options"
4891 (aref gnus-mouse-2 0)
4892 ;; XEmacs will get a single widget arg; Emacs 21 will get
4893 ;; window, overlay, position.
4894 (if (mm-handle-displayed-p
4896 (with-current-buffer (gnus-overlay-buffer overlay)
4897 (widget-get (widget-at (gnus-overlay-start overlay))
4899 (widget-get widget/window :mime-handle)))
4901 (aref gnus-down-mouse-3 0))))))
4903 (defun gnus-widget-press-button (elems el)
4904 (goto-char (widget-get elems :from))
4905 (gnus-article-press-button))
4907 (defvar gnus-displaying-mime nil)
4909 (defun gnus-display-mime (&optional ihandles)
4910 "Display the MIME parts."
4912 (save-selected-window
4913 (let ((window (get-buffer-window gnus-article-buffer))
4916 (select-window window)
4917 ;; We have to do this since selecting the window
4918 ;; may change the point. So we set the window point.
4919 (set-window-point window point)))
4920 (let ((handles ihandles)
4921 (inhibit-read-only t)
4922 handle name type b e display)
4924 ((setq handles (mm-dissect-buffer nil gnus-article-loose-mime))
4925 (when gnus-article-emulate-mime
4926 (mm-uu-dissect-text-parts handles)))
4927 (gnus-article-emulate-mime
4928 (setq handles (mm-uu-dissect))))
4929 (when (and (not ihandles)
4930 (not gnus-displaying-mime))
4931 ;; Top-level call; we clean up.
4932 (when gnus-article-mime-handles
4933 (mm-destroy-parts gnus-article-mime-handles)
4934 (setq gnus-article-mime-handle-alist nil));; A trick.
4935 (setq gnus-article-mime-handles handles)
4936 ;; We allow users to glean info from the handles.
4937 (when gnus-article-mime-part-function
4938 (gnus-mime-part-function handles)))
4940 (or (not (stringp (car handles)))
4943 (when (and (not ihandles)
4944 (not gnus-displaying-mime))
4945 ;; Clean up for mime parts.
4947 (delete-region (point) (point-max)))
4948 (let ((gnus-displaying-mime t))
4949 (gnus-mime-display-part handles)))
4952 (narrow-to-region (point) (point-max))
4953 (gnus-treat-article nil 1 1)
4956 ;; Highlight the headers.
4960 (narrow-to-region (point-min) (point))
4961 (gnus-treat-article 'head))))))))
4963 (defcustom gnus-mime-display-multipart-as-mixed nil
4964 "Display \"multipart\" parts as \"multipart/mixed\".
4966 If t, it overrides nil values of
4967 `gnus-mime-display-multipart-alternative-as-mixed' and
4968 `gnus-mime-display-multipart-related-as-mixed'."
4969 :group 'gnus-article-mime
4972 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
4973 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
4975 :group 'gnus-article-mime
4978 (defcustom gnus-mime-display-multipart-related-as-mixed nil
4979 "Display \"multipart/related\" parts as \"multipart/mixed\".
4981 If displaying \"text/html\" is discouraged \(see
4982 `mm-discouraged-alternatives'\) images or other material inside a
4983 \"multipart/related\" part might be overlooked when this variable is nil."
4985 :group 'gnus-article-mime
4988 (defun gnus-mime-display-part (handle)
4991 ((not (stringp (car handle)))
4992 (gnus-mime-display-single handle))
4993 ;; User-defined multipart
4994 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4995 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4997 ;; multipart/alternative
4998 ((and (equal (car handle) "multipart/alternative")
4999 (not (or gnus-mime-display-multipart-as-mixed
5000 gnus-mime-display-multipart-alternative-as-mixed)))
5001 (let ((id (1+ (length gnus-article-mime-handle-alist))))
5002 (push (cons id handle) gnus-article-mime-handle-alist)
5003 (gnus-mime-display-alternative (cdr handle) nil nil id)))
5004 ;; multipart/related
5005 ((and (equal (car handle) "multipart/related")
5006 (not (or gnus-mime-display-multipart-as-mixed
5007 gnus-mime-display-multipart-related-as-mixed)))
5008 ;;;!!!We should find the start part, but we just default
5009 ;;;!!!to the first part.
5010 ;;(gnus-mime-display-part (cadr handle))
5011 ;;;!!! Most multipart/related is an HTML message plus images.
5012 ;;;!!! Unfortunately we are unable to let W3 display those
5013 ;;;!!! included images, so we just display it as a mixed multipart.
5014 ;;(gnus-mime-display-mixed (cdr handle))
5015 ;;;!!! No, w3 can display everything just fine.
5016 (gnus-mime-display-part (cadr handle)))
5017 ((equal (car handle) "multipart/signed")
5018 (gnus-add-wash-type 'signed)
5019 (gnus-mime-display-security handle))
5020 ((equal (car handle) "multipart/encrypted")
5021 (gnus-add-wash-type 'encrypted)
5022 (gnus-mime-display-security handle))
5023 ;; Other multiparts are handled like multipart/mixed.
5025 (gnus-mime-display-mixed (cdr handle)))))
5027 (defun gnus-mime-part-function (handles)
5028 (if (stringp (car handles))
5029 (mapcar 'gnus-mime-part-function (cdr handles))
5030 (funcall gnus-article-mime-part-function handles)))
5032 (defun gnus-mime-display-mixed (handles)
5033 (mapcar 'gnus-mime-display-part handles))
5035 (defun gnus-mime-display-single (handle)
5036 (let ((type (mm-handle-media-type handle))
5037 (ignored gnus-ignored-mime-types)
5044 (when (string-match (pop ignored) type)
5045 (throw 'ignored nil)))
5046 (if (and (setq not-attachment
5047 (and (not (mm-inline-override-p handle))
5048 (or (not (mm-handle-disposition handle))
5049 (equal (car (mm-handle-disposition handle))
5051 (mm-attachment-override-p handle))))
5052 (mm-automatic-display-p handle)
5054 (mm-inlinable-p handle)
5055 (mm-inlined-p handle))
5056 (mm-automatic-external-display-p type)))
5058 (when (equal (mm-handle-media-supertype handle) "text")
5060 (let ((id (1+ (length gnus-article-mime-handle-alist)))
5062 (push (cons id handle) gnus-article-mime-handle-alist)
5063 (when (or (not display)
5064 (not (gnus-unbuttonized-mime-type-p type)))
5065 (gnus-insert-mime-button
5066 handle id (list (or display (and not-attachment text))))
5067 (gnus-article-insert-newline)
5068 ;; Remember modify the number of forward lines.
5076 (let ((mail-parse-charset gnus-newsgroup-charset)
5077 (mail-parse-ignored-charsets
5078 (save-excursion (condition-case ()
5079 (set-buffer gnus-summary-buffer)
5081 gnus-newsgroup-ignored-charsets)))
5082 (mm-display-part handle t))
5083 (goto-char (point-max)))
5084 ((and text not-attachment)
5088 (gnus-article-insert-newline)
5089 (mm-display-inline handle)
5090 (goto-char (point-max))))
5094 (narrow-to-region beg (point))
5097 (gnus-article-mime-total-parts)
5098 (mm-handle-media-type handle)))))))))
5100 (defun gnus-unbuttonized-mime-type-p (type)
5101 "Say whether TYPE is to be unbuttonized."
5102 (unless gnus-inhibit-mime-unbuttonizing
5104 (let ((types gnus-unbuttonized-mime-types))
5106 (when (string-match (pop types) type)
5107 (throw 'found t)))))
5109 (let ((types gnus-buttonized-mime-types))
5111 (when (string-match (pop types) type)
5112 (throw 'found t)))))))))
5114 (defun gnus-article-insert-newline ()
5115 "Insert a newline, but mark it as undeletable."
5116 (gnus-put-text-property
5117 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
5119 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
5120 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
5123 handle (inhibit-read-only t) from props begend not-pref)
5124 (save-window-excursion
5127 (narrow-to-region (car ibegend)
5130 (goto-char (car ibegend))
5133 (delete-region (point-min) (point-max))
5134 (mm-remove-parts handles))
5135 (setq begend (list (point-marker)))
5137 (unless (setq not-pref (cadr (member preferred ihandles)))
5138 (setq not-pref (car ihandles)))
5141 (not (gnus-unbuttonized-mime-type-p
5142 "multipart/alternative")))
5143 (gnus-add-text-properties
5146 (insert (format "%d. " id))
5150 (unless ,(not ibegend)
5151 (setq gnus-article-mime-handle-alist
5152 ',gnus-article-mime-handle-alist))
5153 (gnus-mime-display-alternative
5154 ',ihandles ',not-pref ',begend ,id))
5155 keymap ,gnus-mime-button-map
5156 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5157 face ,gnus-article-button-face
5160 (widget-convert-button 'link from (point)
5161 :action 'gnus-widget-press-button
5162 :button-keymap gnus-widget-button-keymap)
5164 (while (setq handle (pop handles))
5165 (gnus-add-text-properties
5168 (insert (format "(%c) %-18s"
5169 (if (equal handle preferred) ?* ? )
5170 (mm-handle-media-type handle)))
5174 (unless ,(not ibegend)
5175 (setq gnus-article-mime-handle-alist
5176 ',gnus-article-mime-handle-alist))
5177 (gnus-mime-display-alternative
5178 ',ihandles ',handle ',begend ,id))
5179 keymap ,gnus-mime-button-map
5180 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5181 face ,gnus-article-button-face
5184 (widget-convert-button 'link from (point)
5185 :action 'gnus-widget-press-button
5186 :button-keymap gnus-widget-button-keymap)
5190 (if (stringp (car preferred))
5191 (gnus-display-mime preferred)
5192 (let ((mail-parse-charset gnus-newsgroup-charset)
5193 (mail-parse-ignored-charsets
5194 (with-current-buffer gnus-summary-buffer
5195 gnus-newsgroup-ignored-charsets)))
5196 (mm-display-part preferred)
5200 (narrow-to-region (car begend) (point-max))
5202 nil (length gnus-article-mime-handle-alist)
5203 (gnus-article-mime-total-parts)
5204 (mm-handle-media-type handle))))))
5205 (goto-char (point-max))
5206 (setcdr begend (point-marker)))))
5208 (goto-char point))))
5210 (defconst gnus-article-wash-status-strings
5211 (let ((alist '((cite "c" "Possible hidden citation text"
5212 " " "All citation text visible")
5213 (headers "h" "Hidden headers"
5214 " " "All headers visible.")
5215 (pgp "p" "Encrypted or signed message status hidden"
5216 " " "No hidden encryption nor digital signature status")
5217 (signature "s" "Signature has been hidden"
5218 " " "Signature is visible")
5219 (overstrike "o" "Overstrike (^H) characters applied"
5220 " " "No overstrike characters applied")
5221 (gnus-show-mime "m" "Mime processing is activated"
5222 " " "Mime processing is not activated")
5223 (emphasis "e" "/*_Emphasis_*/ characters applied"
5224 " " "No /*_emphasis_*/ characters applied")))
5226 (dolist (entry alist result)
5227 (let ((key (nth 0 entry))
5228 (on (copy-sequence (nth 1 entry)))
5229 (on-help (nth 2 entry))
5230 (off (copy-sequence (nth 3 entry)))
5231 (off-help (nth 4 entry)))
5232 (put-text-property 0 1 'help-echo on-help on)
5233 (put-text-property 0 1 'help-echo off-help off)
5234 (push (list key on off) result))))
5235 "Alist of strings describing wash status in the mode line.
5236 Each entry has the form (KEY ON OF), where the KEY is a symbol
5237 representing the particular washing function, ON is the string to use
5238 in the article mode line when the washing function is active, and OFF
5239 is the string to use when it is inactive.")
5241 (defun gnus-article-wash-status-entry (key value)
5242 (let ((entry (assoc key gnus-article-wash-status-strings)))
5243 (if value (nth 1 entry) (nth 2 entry))))
5245 (defun gnus-article-wash-status ()
5246 "Return a string which display status of article washing."
5247 (with-current-buffer gnus-article-buffer
5248 (let ((cite (memq 'cite gnus-article-wash-types))
5249 (headers (memq 'headers gnus-article-wash-types))
5250 (boring (memq 'boring-headers gnus-article-wash-types))
5251 (pgp (memq 'pgp gnus-article-wash-types))
5252 (pem (memq 'pem gnus-article-wash-types))
5253 (signed (memq 'signed gnus-article-wash-types))
5254 (encrypted (memq 'encrypted gnus-article-wash-types))
5255 (signature (memq 'signature gnus-article-wash-types))
5256 (overstrike (memq 'overstrike gnus-article-wash-types))
5257 (emphasis (memq 'emphasis gnus-article-wash-types)))
5259 (gnus-article-wash-status-entry 'cite cite)
5260 (gnus-article-wash-status-entry 'headers (or headers boring))
5261 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5262 (gnus-article-wash-status-entry 'signature signature)
5263 (gnus-article-wash-status-entry 'overstrike overstrike)
5264 (gnus-article-wash-status-entry 'gnus-show-mime gnus-show-mime)
5265 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5267 (defun gnus-add-wash-type (type)
5268 "Add a washing of TYPE to the current status."
5269 (add-to-list 'gnus-article-wash-types type))
5271 (defun gnus-delete-wash-type (type)
5272 "Add a washing of TYPE to the current status."
5273 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5275 (defun gnus-add-image (category image)
5276 "Add IMAGE of CATEGORY to the list of displayed images."
5277 (let ((entry (assq category gnus-article-image-alist)))
5279 (setq entry (list category))
5280 (push entry gnus-article-image-alist))
5281 (nconc entry (list image))))
5283 (defun gnus-delete-images (category)
5284 "Delete all images in CATEGORY."
5285 (let ((entry (assq category gnus-article-image-alist)))
5286 (dolist (image (cdr entry))
5287 (gnus-remove-image image category))
5288 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5289 (gnus-delete-wash-type category)))
5291 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5293 (defun gnus-article-maybe-hide-headers ()
5294 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5295 Provided for backwards compatibility."
5296 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5297 (not (with-current-buffer gnus-summary-buffer
5298 gnus-have-all-headers)))
5299 (not gnus-inhibit-hiding))
5300 (gnus-article-hide-headers)))
5304 (defun gnus-output-to-file (file-name)
5305 "Append the current article to a file named FILE-NAME."
5306 (let ((artbuf (current-buffer)))
5308 (insert-buffer-substring artbuf)
5309 ;; Append newline at end of the buffer as separator, and then
5311 (goto-char (point-max))
5313 (let ((file-name-coding-system nnmail-pathname-coding-system))
5314 (write-region-as-binary (point-min) (point-max) file-name 'append))
5317 (defun gnus-narrow-to-page (&optional arg)
5318 "Narrow the article buffer to a page.
5319 If given a numerical ARG, move forward ARG pages."
5321 (setq arg (if arg (prefix-numeric-value arg) 0))
5323 (set-buffer gnus-article-buffer)
5324 (goto-char (point-min))
5326 ;; Remove any old next/prev buttons.
5327 (when (gnus-visual-p 'page-marker)
5328 (let ((inhibit-read-only t))
5329 (gnus-remove-text-with-property 'gnus-prev)
5330 (gnus-remove-text-with-property 'gnus-next)))
5333 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5335 (re-search-forward page-delimiter nil 'move arg)))
5336 (goto-char (match-end 0))
5338 (goto-char (point-min))
5339 (setq gnus-page-broken
5340 (and (re-search-forward page-delimiter nil t) t))))
5341 (when gnus-page-broken
5344 (if (re-search-forward page-delimiter nil 'move)
5347 (when (and (gnus-visual-p 'page-marker)
5348 (> (point-min) (save-restriction (widen) (point-min))))
5350 (goto-char (point-min))
5351 (gnus-insert-prev-page-button)))
5352 (when (and (gnus-visual-p 'page-marker)
5353 (< (+ (point-max) 2) (buffer-size)))
5355 (goto-char (point-max))
5356 (gnus-insert-next-page-button))))))
5358 ;; Article mode commands
5360 (defun gnus-article-goto-next-page ()
5361 "Show the next page of the article."
5363 (when (gnus-article-next-page)
5364 (goto-char (point-min))
5365 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5368 (defun gnus-article-goto-prev-page ()
5369 "Show the previous page of the article."
5372 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5373 (gnus-article-prev-page nil)))
5375 ;; This is cleaner but currently breaks `gnus-pick-mode':
5377 ;; (defun gnus-article-goto-next-page ()
5378 ;; "Show the next page of the article."
5380 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5381 ;; (gnus-summary-next-page)))
5383 ;; (defun gnus-article-goto-prev-page ()
5384 ;; "Show the next page of the article."
5386 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5387 ;; (gnus-summary-prev-page)))
5389 (defun gnus-article-next-page (&optional lines)
5390 "Show the next page of the current article.
5391 If end of article, return non-nil. Otherwise return nil.
5392 Argument LINES specifies lines to be scrolled up."
5394 (move-to-window-line -1)
5397 (and (pos-visible-in-window-p) ;Not continuation line.
5398 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5399 ;; Nothing in this page.
5400 (if (or (not gnus-page-broken)
5405 (eobp)))) ;Real end-of-buffer?
5407 (when gnus-article-over-scroll
5408 (gnus-article-next-page-1 lines))
5410 (gnus-narrow-to-page 1) ;Go to next page.
5412 ;; More in this page.
5413 (gnus-article-next-page-1 lines)
5416 (defun gnus-article-next-page-1 (lines)
5417 (let ((scroll-in-place nil))
5421 ;; Long lines may cause an end-of-buffer error.
5422 (goto-char (point-max)))))
5423 (move-to-window-line 0))
5425 (defun gnus-article-prev-page (&optional lines)
5426 "Show previous page of current article.
5427 Argument LINES specifies lines to be scrolled down."
5429 (move-to-window-line 0)
5430 (if (and gnus-page-broken
5432 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5434 (gnus-narrow-to-page -1) ;Go to previous page.
5435 (goto-char (point-max))
5437 (let ((scroll-in-place nil))
5441 (beginning-of-buffer
5442 (goto-char (point-min))))
5443 (move-to-window-line 0)))))
5445 (defun gnus-article-only-boring-p ()
5446 "Decide whether there is only boring text remaining in the article.
5447 Something \"interesting\" is a word of at least two letters that does
5448 not have a face in `gnus-article-boring-faces'."
5449 (when (and gnus-article-skip-boring
5450 (boundp 'gnus-article-boring-faces)
5451 (symbol-value 'gnus-article-boring-faces))
5454 (while (re-search-forward "\\b\\w\\w" nil t)
5456 (when (not (gnus-intersection
5457 (gnus-faces-at (point))
5458 (symbol-value 'gnus-article-boring-faces)))
5459 (throw 'only-boring nil)))
5460 (throw 'only-boring t)))))
5462 (defun gnus-article-refer-article ()
5463 "Read article specified by message-id around point."
5466 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
5467 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
5468 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
5469 (let ((msg-id (concat "<" (match-string 0) ">")))
5470 (set-buffer gnus-summary-buffer)
5471 (gnus-summary-refer-article msg-id))
5472 (error "No references around point"))))
5474 (defun gnus-article-show-summary ()
5475 "Reconfigure windows to show summary buffer."
5477 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5478 (error "There is no summary buffer for this article buffer")
5479 (gnus-article-set-globals)
5480 (gnus-configure-windows 'article)
5481 (gnus-summary-goto-subject gnus-current-article)
5482 (gnus-summary-position-point)))
5484 (defun gnus-article-describe-briefly ()
5485 "Describe article mode commands briefly."
5487 (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")))
5489 (defun gnus-article-summary-command ()
5490 "Execute the last keystroke in the summary buffer."
5492 (let ((obuf (current-buffer))
5493 (owin (current-window-configuration))
5495 (switch-to-buffer gnus-article-current-summary 'norecord)
5496 (setq func (lookup-key (current-local-map) (this-command-keys)))
5497 (call-interactively func)
5499 (set-window-configuration owin)
5500 (set-window-point (get-buffer-window (current-buffer)) (point))))
5502 (defun gnus-article-summary-command-nosave ()
5503 "Execute the last keystroke in the summary buffer."
5506 (pop-to-buffer gnus-article-current-summary 'norecord)
5507 (setq func (lookup-key (current-local-map) (this-command-keys)))
5508 (call-interactively func)))
5510 (defun gnus-article-check-buffer ()
5511 "Beep if not in an article buffer."
5512 (unless (eq (get-buffer gnus-article-buffer) (current-buffer))
5513 (error "Command invoked outside of a Gnus article buffer")))
5515 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5516 "Read a summary buffer key sequence and execute it from the article buffer."
5518 (gnus-article-check-buffer)
5520 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5521 "Zc" "ZC" "ZE" "ZJ" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5522 "=" "^" "\M-^" "|"))
5528 '("n" "Gn" "p" "Gp"))
5531 (set-buffer gnus-article-current-summary)
5532 (let (gnus-pick-mode)
5533 (push (or key last-command-event) unread-command-events)
5534 (setq keys (static-if (featurep 'xemacs)
5535 (events-to-keys (read-key-sequence nil))
5536 (read-key-sequence nil)))))
5539 (if (or (member keys nosaves)
5540 (member keys nosave-but-article)
5541 (member keys nosave-in-article))
5543 (save-window-excursion
5544 (pop-to-buffer gnus-article-current-summary 'norecord)
5545 ;; We disable the pick minor mode commands.
5546 (let (gnus-pick-mode)
5547 (setq func (lookup-key (current-local-map) keys))))
5551 (unless (member keys nosave-in-article)
5552 (set-buffer gnus-article-current-summary))
5553 (call-interactively func)
5554 (setq new-sum-point (point)))
5555 (when (member keys nosave-but-article)
5556 (pop-to-buffer gnus-article-buffer 'norecord)))
5557 ;; These commands should restore window configuration.
5558 (let ((obuf (current-buffer))
5559 (owin (current-window-configuration))
5561 win func in-buffer selected new-sum-start new-sum-hscroll)
5562 (cond (not-restore-window
5563 (pop-to-buffer gnus-article-current-summary 'norecord))
5564 ((setq win (get-buffer-window gnus-article-current-summary))
5565 (select-window win))
5567 (switch-to-buffer gnus-article-current-summary 'norecord)))
5568 (setq in-buffer (current-buffer))
5569 ;; We disable the pick minor mode commands.
5570 (if (and (setq func (let (gnus-pick-mode)
5571 (lookup-key (current-local-map) keys)))
5574 (call-interactively func)
5575 (when (eq win (selected-window))
5576 (setq new-sum-point (point)
5577 new-sum-start (window-start win)
5578 new-sum-hscroll (window-hscroll win))
5579 (when (eq in-buffer (current-buffer))
5580 (setq selected (gnus-summary-select-article))
5582 (unless not-restore-window
5583 (set-window-configuration owin))
5584 (when (eq selected 'old)
5586 (set-window-start (get-buffer-window (current-buffer))
5588 (set-window-point (get-buffer-window (current-buffer))
5590 (when (and (not not-restore-window)
5592 (set-window-point win new-sum-point)
5593 (set-window-start win new-sum-start)
5594 (set-window-hscroll win new-sum-hscroll)))))
5595 (set-window-configuration owin)
5598 (defun gnus-article-describe-key (key)
5599 "Display documentation of the function invoked by KEY. KEY is a string."
5600 (interactive "kDescribe key: ")
5601 (gnus-article-check-buffer)
5602 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5604 (set-buffer gnus-article-current-summary)
5605 (let (gnus-pick-mode)
5606 (if (featurep 'xemacs)
5608 (push (elt key 0) unread-command-events)
5609 (setq key (events-to-keys
5610 (read-key-sequence "Describe key: "))))
5611 (setq unread-command-events
5613 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5615 (setq key (read-key-sequence "Describe key: "))))
5617 (describe-key key)))
5619 (defun gnus-article-describe-key-briefly (key &optional insert)
5620 "Display documentation of the function invoked by KEY. KEY is a string."
5621 (interactive "kDescribe key: \nP")
5622 (gnus-article-check-buffer)
5623 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5625 (set-buffer gnus-article-current-summary)
5626 (let (gnus-pick-mode)
5627 (if (featurep 'xemacs)
5629 (push (elt key 0) unread-command-events)
5630 (setq key (events-to-keys
5631 (read-key-sequence "Describe key: "))))
5632 (setq unread-command-events
5634 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5636 (setq key (read-key-sequence "Describe key: "))))
5637 (describe-key-briefly key insert))
5638 (describe-key-briefly key insert)))
5640 (defun gnus-article-reply-with-original (&optional wide)
5641 "Start composing a reply mail to the current message.
5642 The text in the region will be yanked. If the region isn't active,
5643 the entire article will be yanked."
5645 (let ((article (cdr gnus-article-current))
5647 (if (not (gnus-region-active-p))
5648 (with-current-buffer gnus-summary-buffer
5649 (gnus-summary-reply (list (list article)) wide))
5650 (setq contents (buffer-substring (point) (mark t)))
5651 ;; Deactivate active regions.
5652 (when (and (boundp 'transient-mark-mode)
5653 transient-mark-mode)
5654 (setq mark-active nil))
5655 (with-current-buffer gnus-summary-buffer
5657 (list (list article contents)) wide)))))
5659 (defun gnus-article-followup-with-original ()
5660 "Compose a followup to the current article.
5661 The text in the region will be yanked. If the region isn't active,
5662 the entire article will be yanked."
5664 (let ((article (cdr gnus-article-current))
5666 (if (not (gnus-region-active-p))
5667 (with-current-buffer gnus-summary-buffer
5668 (gnus-summary-followup (list (list article))))
5669 (setq contents (buffer-substring (point) (mark t)))
5670 ;; Deactivate active regions.
5671 (when (and (boundp 'transient-mark-mode)
5672 transient-mark-mode)
5673 (setq mark-active nil))
5674 (with-current-buffer gnus-summary-buffer
5675 (gnus-summary-followup
5676 (list (list article contents)))))))
5678 (defun gnus-article-hide (&optional arg force)
5679 "Hide all the gruft in the current article.
5680 This means that signatures, cited text and (some) headers will be
5682 If given a prefix, show the hidden text instead."
5683 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5684 (gnus-article-hide-headers arg)
5685 (gnus-article-hide-list-identifiers arg)
5686 (gnus-article-hide-citation-maybe arg force)
5687 (gnus-article-hide-signature arg))
5689 (defun gnus-article-maybe-highlight ()
5690 "Do some article highlighting if article highlighting is requested."
5691 (when (gnus-visual-p 'article-highlight 'highlight)
5692 (gnus-article-highlight-some)))
5694 (defun gnus-check-group-server ()
5695 ;; Make sure the connection to the server is alive.
5696 (unless (gnus-server-opened
5697 (gnus-find-method-for-group gnus-newsgroup-name))
5698 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5699 (gnus-request-group gnus-newsgroup-name t)))
5702 (autoload 'nneething-get-file-name "nneething"))
5704 (defun gnus-request-article-this-buffer (article group)
5705 "Get an article and insert it into this buffer."
5706 (let (do-update-line sparse-header)
5710 (gnus-kill-all-overlays)
5711 (setq group (or group gnus-newsgroup-name))
5713 ;; Using `gnus-request-article' directly will insert the article into
5714 ;; `nntp-server-buffer' - so we'll save some time by not having to
5715 ;; copy it from the server buffer into the article buffer.
5717 ;; We only request an article by message-id when we do not have the
5718 ;; headers for it, so we'll have to get those.
5719 (when (stringp article)
5720 (gnus-read-header article))
5722 ;; If the article number is negative, that means that this article
5723 ;; doesn't belong in this newsgroup (possibly), so we find its
5724 ;; message-id and request it by id instead of number.
5725 (when (and (numberp article)
5727 (get-buffer gnus-summary-buffer)
5728 (gnus-buffer-exists-p gnus-summary-buffer))
5730 (set-buffer gnus-summary-buffer)
5731 (let ((header (gnus-summary-article-header article)))
5734 ((memq article gnus-newsgroup-sparse)
5735 ;; This is a sparse gap article.
5736 (setq do-update-line article)
5737 (setq article (mail-header-id header))
5738 (setq sparse-header (gnus-read-header article))
5739 (setq gnus-newsgroup-sparse
5740 (delq article gnus-newsgroup-sparse)))
5742 ;; It's a real article.
5743 (setq article (mail-header-id header)))
5745 ;; It is an extracted pseudo-article.
5746 (setq article 'pseudo)
5747 (gnus-request-pseudo-article header))))
5749 (let ((method (gnus-find-method-for-group
5750 gnus-newsgroup-name)))
5751 (when (and (eq (car method) 'nneething)
5753 (let ((dir (nneething-get-file-name
5754 (mail-header-id header))))
5755 (when (and (stringp dir)
5756 (file-directory-p dir))
5757 (setq article 'nneething)
5758 (gnus-group-enter-directory dir))))))))
5761 ;; Refuse to select canceled articles.
5762 ((and (numberp article)
5764 (get-buffer gnus-summary-buffer)
5765 (gnus-buffer-exists-p gnus-summary-buffer)
5766 (eq (cdr (with-current-buffer gnus-summary-buffer
5767 (assq article gnus-newsgroup-reads)))
5768 gnus-canceled-mark))
5770 ;; We first check `gnus-original-article-buffer'.
5771 ((and (get-buffer gnus-original-article-buffer)
5773 (with-current-buffer gnus-original-article-buffer
5774 (and (equal (car gnus-original-article) group)
5775 (eq (cdr gnus-original-article) article))))
5776 (insert-buffer-substring gnus-original-article-buffer)
5778 ;; Check the backlog.
5779 ((and gnus-keep-backlog
5780 (gnus-backlog-request-article group article (current-buffer)))
5782 ;; Check asynchronous pre-fetch.
5783 ((gnus-async-request-fetched-article group article (current-buffer))
5784 (gnus-async-prefetch-next group article gnus-summary-buffer)
5785 (when (and (numberp article) gnus-keep-backlog)
5786 (gnus-backlog-enter-article group article (current-buffer)))
5789 ((and gnus-use-cache
5791 (gnus-cache-request-article article group))
5793 ;; Check the agent cache.
5794 ((gnus-agent-request-article article group)
5796 ;; Get the article and put into the article buffer.
5797 ((or (stringp article)
5799 (let ((gnus-override-method gnus-override-method)
5800 (methods (and (stringp article)
5801 gnus-refer-article-method))
5802 (backend (car (gnus-find-method-for-group
5803 gnus-newsgroup-name)))
5805 (inhibit-read-only t))
5806 (if (or (not (listp methods))
5807 (and (symbolp (car methods))
5808 (assq (car methods) nnoo-definition-alist)))
5809 (setq methods (list methods)))
5810 (when (and (null gnus-override-method)
5812 (setq gnus-override-method (pop methods)))
5814 (when (eq gnus-override-method 'current)
5815 (setq gnus-override-method
5816 (with-current-buffer gnus-summary-buffer
5817 gnus-current-select-method)))
5819 (gnus-kill-all-overlays)
5820 (let ((gnus-newsgroup-name group))
5821 (gnus-check-group-server))
5823 ((gnus-request-article article group (current-buffer))
5824 (when (numberp article)
5825 (gnus-async-prefetch-next group article
5826 gnus-summary-buffer)
5827 (when gnus-keep-backlog
5828 (gnus-backlog-enter-article
5829 group article (current-buffer))))
5830 (setq result 'article))
5832 (setq gnus-override-method (pop methods)))
5833 ((not (string-match "^400 "
5834 (nnheader-get-report backend)))
5835 ;; If we get 400 server disconnect, reconnect and
5836 ;; retry; otherwise, assume the article has expired.
5837 (setq result 'done))))
5838 (and (eq result 'article) 'article)))
5842 ;; Associate this article with the current summary buffer.
5843 (setq gnus-article-current-summary gnus-summary-buffer)
5845 ;; Take the article from the original article buffer
5846 ;; and place it in the buffer it's supposed to be in.
5847 (when (and (get-buffer gnus-article-buffer)
5848 (equal (buffer-name (current-buffer))
5849 (buffer-name (get-buffer gnus-article-buffer))))
5851 (if (get-buffer gnus-original-article-buffer)
5852 (set-buffer gnus-original-article-buffer)
5853 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5854 (buffer-disable-undo)
5855 (setq major-mode 'gnus-original-article-mode)
5856 (setq buffer-read-only t))
5857 (let ((inhibit-read-only t))
5859 (insert-buffer-substring gnus-article-buffer))
5860 (setq gnus-original-article (cons group article)))
5863 (run-hooks 'gnus-article-decode-hook)
5864 ;; Mark article as decoded or not.
5865 (setq gnus-article-decoded-p gnus-article-decode-hook))
5867 ;; Update sparse articles.
5868 (when (and do-update-line
5869 (or (numberp article)
5871 (let ((buf (current-buffer)))
5872 (set-buffer gnus-summary-buffer)
5873 (gnus-summary-update-article do-update-line sparse-header)
5874 (gnus-summary-goto-subject do-update-line nil t)
5875 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5877 (set-buffer buf))))))
5883 (defcustom gnus-article-edit-mode-hook nil
5884 "Hook run in article edit mode buffers."
5885 :group 'gnus-article-various
5888 (defcustom gnus-article-edit-article-setup-function
5889 'gnus-article-mime-edit-article-setup
5890 "Function called to setup an editing article buffer."
5891 :group 'gnus-article-various
5894 (defvar gnus-article-edit-done-function nil)
5896 (defvar gnus-article-edit-mode-map nil)
5898 ;; Should we be using derived.el for this?
5899 (unless gnus-article-edit-mode-map
5900 (setq gnus-article-edit-mode-map (make-keymap))
5901 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5903 (gnus-define-keys gnus-article-edit-mode-map
5904 "\C-c?" describe-mode
5905 "\C-c\C-c" gnus-article-edit-done
5906 "\C-c\C-k" gnus-article-edit-exit
5907 "\C-c\C-f\C-t" message-goto-to
5908 "\C-c\C-f\C-o" message-goto-from
5909 "\C-c\C-f\C-b" message-goto-bcc
5910 ;;"\C-c\C-f\C-w" message-goto-fcc
5911 "\C-c\C-f\C-c" message-goto-cc
5912 "\C-c\C-f\C-s" message-goto-subject
5913 "\C-c\C-f\C-r" message-goto-reply-to
5914 "\C-c\C-f\C-n" message-goto-newsgroups
5915 "\C-c\C-f\C-d" message-goto-distribution
5916 "\C-c\C-f\C-f" message-goto-followup-to
5917 "\C-c\C-f\C-m" message-goto-mail-followup-to
5918 "\C-c\C-f\C-k" message-goto-keywords
5919 "\C-c\C-f\C-u" message-goto-summary
5920 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5921 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5922 "\C-c\C-b" message-goto-body
5923 "\C-c\C-i" message-goto-signature
5925 "\C-c\C-t" message-insert-to
5926 "\C-c\C-n" message-insert-newsgroups
5927 "\C-c\C-o" message-sort-headers
5928 "\C-c\C-e" message-elide-region
5929 "\C-c\C-v" message-delete-not-region
5930 "\C-c\C-z" message-kill-to-signature
5931 "\M-\r" message-newline-and-reformat
5932 "\C-c\C-a" mml-attach-file
5933 "\C-a" message-beginning-of-line
5935 "\M-;" comment-region)
5937 (gnus-define-keys (gnus-article-edit-wash-map
5938 "\C-c\C-w" gnus-article-edit-mode-map)
5939 "f" gnus-article-edit-full-stops))
5942 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5944 ["Fetch To" message-insert-to t]
5945 ["Fetch Newsgroups" message-insert-newsgroups t]
5947 ["To" message-goto-to t]
5948 ["From" message-goto-from t]
5949 ["Subject" message-goto-subject t]
5950 ["Cc" message-goto-cc t]
5951 ["Reply-To" message-goto-reply-to t]
5952 ["Summary" message-goto-summary t]
5953 ["Keywords" message-goto-keywords t]
5954 ["Newsgroups" message-goto-newsgroups t]
5955 ["Followup-To" message-goto-followup-to t]
5956 ["Mail-Followup-To" message-goto-mail-followup-to t]
5957 ["Distribution" message-goto-distribution t]
5958 ["Body" message-goto-body t]
5959 ["Signature" message-goto-signature t]))
5961 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
5962 "Major mode for editing articles.
5963 This is an extended text-mode.
5965 \\{gnus-article-edit-mode-map}"
5966 (make-local-variable 'gnus-article-edit-done-function)
5967 (make-local-variable 'gnus-prev-winconf)
5968 (set (make-local-variable 'font-lock-defaults)
5969 '(message-font-lock-keywords t))
5970 (set (make-local-variable 'mail-header-separator) "")
5971 (set (make-local-variable 'gnus-article-edit-mode) t)
5972 (easy-menu-add message-mode-field-menu message-mode-map)
5973 (setq buffer-read-only nil)
5974 (buffer-enable-undo)
5977 (defun gnus-article-edit (&optional force)
5978 "Edit the current article.
5979 This will have permanent effect only in mail groups.
5980 If FORCE is non-nil, allow editing of articles even in read-only
5983 (when (and (not force)
5984 (gnus-group-read-only-p))
5985 (error "The current newsgroup does not support article editing"))
5986 (gnus-article-date-original)
5987 (gnus-article-edit-article
5989 `(lambda (no-highlight)
5991 (gnus-summary-edit-article-done
5992 ,(or (mail-header-references gnus-current-headers) "")
5993 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5995 (defun gnus-article-edit-article (start-func exit-func)
5996 "Start editing the contents of the current article buffer."
5997 (let ((winconf (current-window-configuration)))
5998 (set-buffer gnus-article-buffer)
5999 (gnus-article-edit-mode)
6000 (funcall start-func)
6001 (set-buffer-modified-p nil)
6002 (gnus-configure-windows 'edit-article)
6003 (setq gnus-article-edit-done-function exit-func)
6004 (setq gnus-prev-winconf winconf)
6005 (when gnus-article-edit-article-setup-function
6006 (funcall gnus-article-edit-article-setup-function))
6007 (gnus-message 6 "C-c C-c to end edits; C-c C-k to exit")))
6009 (defun gnus-article-edit-done (&optional arg)
6010 "Update the article edits and exit."
6012 (let ((func gnus-article-edit-done-function)
6013 (buf (current-buffer))
6014 (start (window-start))
6016 (winconf gnus-prev-winconf))
6017 (remove-hook 'gnus-article-mode-hook
6018 'gnus-article-mime-edit-article-unwind)
6019 (widen) ;; Widen it in case that users narrowed the buffer.
6022 ;; The cache and backlog have to be flushed somewhat.
6023 (when gnus-keep-backlog
6024 (gnus-backlog-remove-article
6025 (car gnus-article-current) (cdr gnus-article-current)))
6026 ;; Flush original article as well.
6028 (when (get-buffer gnus-original-article-buffer)
6029 (set-buffer gnus-original-article-buffer)
6030 (setq gnus-original-article nil)))
6031 (when gnus-use-cache
6032 (gnus-cache-update-article
6033 (car gnus-article-current) (cdr gnus-article-current)))
6034 ;; We remove all text props from the article buffer.
6035 (kill-all-local-variables)
6036 (set-text-properties (point-min) (point-max) nil)
6038 (set-window-configuration winconf)
6040 (set-window-start (get-buffer-window buf) start)
6041 (set-window-point (get-buffer-window buf) (point)))
6042 (gnus-summary-show-article))
6044 (defun gnus-article-edit-exit ()
6045 "Exit the article editing without updating."
6047 (when (or (not (buffer-modified-p))
6048 (yes-or-no-p "Article modified; kill anyway? "))
6049 (let ((curbuf (current-buffer))
6051 (window-start (window-start)))
6053 (if (gnus-buffer-live-p gnus-original-article-buffer)
6054 (insert-buffer-substring gnus-original-article-buffer))
6055 (let ((winconf gnus-prev-winconf))
6056 (kill-all-local-variables)
6058 (set-window-configuration winconf)
6059 ;; Tippy-toe some to make sure that point remains where it was.
6060 (save-current-buffer
6062 (set-window-start (get-buffer-window (current-buffer)) window-start)
6064 (gnus-summary-show-article)))
6066 (defun gnus-article-edit-full-stops ()
6067 "Interactively repair spacing at end of sentences."
6070 (goto-char (point-min))
6071 (search-forward-regexp "^$" nil t)
6072 (let ((case-fold-search nil))
6073 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
6076 ;;; Article editing with MIME-Edit
6079 (defcustom gnus-article-mime-edit-article-setup-hook nil
6080 "Hook run after setting up a MIME editing article buffer."
6081 :group 'gnus-article-various
6084 (defun gnus-article-mime-edit-article-unwind ()
6085 "Unwind `gnus-article-buffer' if article editing was given up."
6086 (remove-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6087 (when (featurep 'font-lock)
6088 (setq font-lock-defaults nil)
6089 (font-lock-mode -1))
6090 (when mime-edit-mode-flag
6091 (mime-edit-exit 'nomime 'no-error)
6094 (defun gnus-article-mime-edit-article-setup ()
6095 "Convert current buffer to MIME-Edit buffer and turn on MIME-Edit mode
6096 after replacing with the original article."
6097 (setq gnus-show-mime t)
6098 (setq gnus-article-edit-done-function
6099 `(lambda (&rest args)
6100 (when mime-edit-mode-flag
6101 (let (mime-edit-insert-user-agent-field)
6104 (goto-char (point-min))
6105 (let (case-fold-search)
6106 (when (re-search-forward
6107 (format "^%s$" (regexp-quote mail-header-separator))
6109 (replace-match "")))
6110 (apply ,gnus-article-edit-done-function args)
6113 (buffer-substring-no-properties (point-min) (point-max))
6114 (set-buffer (get-buffer-create gnus-original-article-buffer))
6116 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6117 (set-buffer gnus-article-buffer)
6118 (gnus-article-prepare-display)))
6119 (substitute-key-definition 'gnus-article-edit-done
6120 'gnus-article-mime-edit-done
6121 gnus-article-edit-mode-map)
6122 (substitute-key-definition 'gnus-article-edit-exit
6123 'gnus-article-mime-edit-exit
6124 gnus-article-edit-mode-map)
6126 (insert-buffer-substring gnus-original-article-buffer)
6127 (unless (member (with-current-buffer gnus-summary-buffer
6128 gnus-newsgroup-name)
6129 '("nndraft:delayed" "nndraft:drafts"))
6130 (let ((ofn (symbol-function 'mime-edit-decode-single-part-in-buffer)))
6131 (fset 'mime-edit-decode-single-part-in-buffer
6132 (lambda (&rest args)
6133 (if (let ((content-type (car args)))
6134 (and (eq 'message (mime-content-type-primary-type
6136 (eq 'rfc822 (mime-content-type-subtype
6138 (setcar (cdr args) 'not-decode-text))
6142 (fset 'mime-edit-decode-single-part-in-buffer ofn))))
6143 (when (featurep 'font-lock)
6144 (set (make-local-variable 'font-lock-defaults)
6145 '(message-font-lock-keywords t))
6146 (font-lock-set-defaults)
6147 (turn-on-font-lock))
6148 (set-buffer-modified-p nil)
6149 (delete-other-windows)
6150 (add-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6151 (gnus-run-hooks 'gnus-article-mime-edit-article-setup-hook))
6153 (defun gnus-article-mime-edit-done (&optional arg)
6154 "Update the article MIME edits and exit."
6156 (when (featurep 'font-lock)
6157 (setq font-lock-defaults nil)
6158 (font-lock-mode -1))
6159 (let ((inhibit-read-only t))
6160 (gnus-article-edit-done arg)))
6162 (defun gnus-article-mime-edit-exit ()
6163 "Exit the article MIME editing without updating."
6165 (when (or (not (buffer-modified-p))
6166 (yes-or-no-p "Article modified; kill anyway? "))
6167 (when (featurep 'font-lock)
6168 (setq font-lock-defaults nil)
6169 (font-lock-mode -1))
6170 (when mime-edit-mode-flag
6171 (let (mime-edit-insert-user-agent-field)
6174 (goto-char (point-min))
6175 (let (case-fold-search)
6176 (when (re-search-forward
6177 (format "^%s$" (regexp-quote mail-header-separator)) nil t)
6178 (replace-match "")))
6179 (let ((winconf gnus-prev-winconf))
6181 (buffer-substring-no-properties (point-min) (point-max))
6182 (set-buffer (get-buffer-create gnus-original-article-buffer))
6184 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6185 (set-buffer gnus-article-buffer)
6186 (gnus-article-prepare-display)
6187 (set-window-configuration winconf))))
6190 ;;; Article highlights
6193 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
6195 ;;; Internal Variables:
6197 (defcustom gnus-button-url-regexp
6198 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
6199 "\\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:]]\\)"
6200 "\\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\\)\\)")
6201 "Regular expression that matches URLs."
6202 :group 'gnus-article-buttons
6205 (defcustom gnus-button-valid-fqdn-regexp
6206 message-valid-fqdn-regexp
6207 "Regular expression that matches a valid FQDN."
6209 :group 'gnus-article-buttons
6212 (defcustom gnus-button-man-handler 'manual-entry
6213 "Function to use for displaying man pages.
6214 The function must take at least one argument with a string naming the
6217 :type '(choice (function-item :tag "Man" manual-entry)
6218 (function-item :tag "Woman" woman)
6219 (function :tag "Other"))
6220 :group 'gnus-article-buttons)
6222 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
6223 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
6224 If the default site is too slow, try to find a CTAN mirror, see
6225 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
6226 the variable `gnus-button-handle-ctan'."
6228 :group 'gnus-article-buttons
6229 :link '(custom-manual "(gnus)Group Parameters")
6230 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
6231 (const "http://tug.ctan.org/tex-archive/")
6232 (const "http://www.dante.de/CTAN/")
6233 (string :tag "Other")))
6235 (defcustom gnus-button-ctan-handler 'browse-url
6236 "Function to use for displaying CTAN links.
6237 The function must take one argument, the string naming the URL."
6239 :type '(choice (function-item :tag "Browse Url" browse-url)
6240 (function :tag "Other"))
6241 :group 'gnus-article-buttons)
6243 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
6244 "Bogus strings removed from CTAN URLs."
6246 :group 'gnus-article-buttons
6247 :type '(choice (const "^/?tex-archive/\\|/")
6248 (regexp :tag "Other")))
6250 (defcustom gnus-button-ctan-directory-regexp
6253 "biblio\\|digests\\|dviware\\|fonts\\|graphics\\|help\\|"
6254 "indexing\\|info\\|language\\|macros\\|support\\|systems\\|"
6255 "tds\\|tools\\|usergrps\\|web\\|nonfree\\|obsolete"
6257 "Regular expression for ctan directories.
6258 It should match all directories in the top level of `gnus-ctan-url'."
6260 :group 'gnus-article-buttons
6263 (defcustom gnus-button-mid-or-mail-regexp
6264 (concat "\\b\\(<?[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t ]*@"
6265 ;; Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
6266 gnus-button-valid-fqdn-regexp
6268 "Regular expression that matches a message ID or a mail address."
6270 :group 'gnus-article-buttons
6273 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
6274 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
6275 Strings like this can be either a message ID or a mail address. If it is one
6276 of the symbols `mid' or `mail', Gnus will always assume that the string is a
6277 message ID or a mail address, respectively. If this variable is set to the
6278 symbol `ask', always query the user what do do. If it is a function, this
6279 function will be called with the string as it's only argument. The function
6280 must return `mid', `mail', `invalid' or `ask'."
6282 :group 'gnus-article-buttons
6283 :type '(choice (function-item :tag "Heuristic function"
6284 gnus-button-mid-or-mail-heuristic)
6289 (defcustom gnus-button-mid-or-mail-heuristic-alist
6290 '((-10.0 . ".+\\$.+@")
6293 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
6294 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
6295 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
6296 (-1.0 . "^[^a-z]+@")
6298 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
6299 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
6300 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
6301 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
6304 (-1.0 . "^[0-9][0-9]")
6306 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
6307 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6308 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
6309 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6311 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
6312 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
6315 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
6317 ;; compensation for TDMA dated mail addresses:
6318 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
6320 (-20.0 . "\\.fsf@") ;; Gnus
6323 (-20.0 . "_-_") ;; Subject change in thread
6325 (-20.0 . "\\.ln@") ;; leafnode
6326 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
6327 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
6329 ;; (5.0 . "") ;; $local_part_len <= 7
6330 (10.0 . "^[^0-9]+@")
6331 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
6332 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
6335 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
6337 (0.5 . "^[A-Z][a-z]")
6338 (0.5 . "^[A-Z][a-z][a-z]")
6339 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
6340 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
6341 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
6343 A negative RATE indicates a message IDs, whereas a positive indicates a mail
6344 address. The REGEXP is processed with `case-fold-search' set to nil."
6346 :group 'gnus-article-buttons
6347 :type '(repeat (cons (number :tag "Rate")
6348 (regexp :tag "Regexp"))))
6350 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
6351 "Guess whether MID-OR-MAIL is a message ID or a mail address.
6352 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
6353 address, `ask' if unsure and `invalid' if the string is invalid."
6354 (let ((case-fold-search nil)
6355 (list gnus-button-mid-or-mail-heuristic-alist)
6356 (result 0) rate regexp lpartlen elem)
6358 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
6359 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
6360 ;; Certain special cases...
6363 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
6364 "^[0-9]+\\.[0-9]+@compuserve\\|"
6365 "@public\\.gmane\\.org")
6367 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
6368 (setq result 'mail))
6369 (when (string-match "@.*@\\| " mid-or-mail)
6370 (gnus-message 8 "`%s' is invalid." mid-or-mail)
6371 (setq result 'invalid))
6372 ;; Nothing more to do, if result is not a number here...
6373 (when (numberp result)
6375 (setq elem (car list)
6379 (when (string-match regexp mid-or-mail)
6380 (setq result (+ result rate))
6382 9 "`%s' matched `%s', rate `%s', result `%s'."
6383 mid-or-mail regexp rate result)))
6384 (when (<= lpartlen 7)
6385 (setq result (+ result 5.0))
6386 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
6387 mid-or-mail result))
6388 (when (>= lpartlen 12)
6389 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
6391 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
6392 ;; Long local part should contain realname if e-mail address,
6393 ;; too many digits: message-id.
6394 ;; $score -= 5.0 + 0.1 * $local_part_len;
6395 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6396 (setq result (+ result rate))
6398 9 "Many digits in `%s', rate `%s', result `%s'."
6399 mid-or-mail rate result))
6400 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6402 ;; Too few vowels [^aeiouy]{4,}.*\@
6403 (setq result (+ result -5.0))
6405 9 "Few vowels in `%s', rate `%s', result `%s'."
6406 mid-or-mail -5.0 result))
6408 (setq result (+ result 5.0))
6410 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6411 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6412 ;; Maybe we should make this a customizable alist: (condition . 'result)
6414 ((symbolp result) result)
6415 ;; Now convert number into proper results:
6416 ((< result -10.0) 'mid)
6417 ((> result 10.0) 'mail)
6420 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6421 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6422 (url-mid (concat "news" ":" mid-or-mail))
6423 (url-mailto (concat "mailto" ":" mid-or-mail)))
6424 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6425 (when (fboundp pref)
6427 ;; get rid of surrounding angles...
6429 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6430 (if (or (eq 'mid guessed) (eq 'mail guessed))
6434 (save-window-excursion
6435 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6438 (cond ((eq pref 'mid)
6439 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6440 (gnus-button-handle-news url-mid))
6442 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6443 (gnus-url-mailto url-mailto))
6444 (t (gnus-message 3 "Invalid string.")))))
6446 (defun gnus-button-handle-custom (url)
6447 "Follow a Custom URL."
6448 (customize-apropos (gnus-url-unhex-string url)))
6450 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6452 ;; FIXME: Maybe we should merge some of the functions that do quite similar
6455 (defun gnus-button-handle-describe-function (url)
6456 "Call `describe-function' when pushing the corresponding URL button."
6459 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6461 (defun gnus-button-handle-describe-variable (url)
6462 "Call `describe-variable' when pushing the corresponding URL button."
6465 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6467 (defun gnus-button-handle-symbol (url)
6468 "Display help on variable or function.
6469 Calls `describe-variable' or `describe-function'."
6470 (let ((sym (intern url)))
6472 ((fboundp sym) (describe-function sym))
6473 ((boundp sym) (describe-variable sym))
6474 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
6476 (defun gnus-button-handle-describe-key (url)
6477 "Call `describe-key' when pushing the corresponding URL button."
6479 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6480 (keys (ignore-errors (eval `(kbd ,key-string)))))
6483 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6485 (defun gnus-button-handle-apropos (url)
6486 "Call `apropos' when pushing the corresponding URL button."
6487 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6489 (defun gnus-button-handle-apropos-command (url)
6490 "Call `apropos' when pushing the corresponding URL button."
6492 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6494 (defun gnus-button-handle-apropos-variable (url)
6495 "Call `apropos' when pushing the corresponding URL button."
6497 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6498 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6500 (defun gnus-button-handle-apropos-documentation (url)
6501 "Call `apropos' when pushing the corresponding URL button."
6503 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6504 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6506 (defun gnus-button-handle-library (url)
6507 "Call `locate-library' when pushing the corresponding URL button."
6508 (gnus-message 9 "url=`%s'" url)
6509 (let* ((lib (locate-library url))
6510 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6512 (gnus-message 1 "Cannot locale library `%s'." url)
6513 (find-file-read-only file))))
6515 (defun gnus-button-handle-ctan (url)
6516 "Call `browse-url' when pushing a CTAN URL button."
6518 gnus-button-ctan-handler
6521 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6523 (defcustom gnus-button-tex-level 5
6524 "*Integer that says how many TeX-related buttons Gnus will show.
6525 The higher the number, the more buttons will appear and the more false
6526 positives are possible. Note that you can set this variable local to
6527 specific groups. Setting it higher in TeX groups is probably a good idea.
6528 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6529 how to set variables in specific groups."
6531 :group 'gnus-article-buttons
6532 :link '(custom-manual "(gnus)Group Parameters")
6535 (defcustom gnus-button-man-level 5
6536 "*Integer that says how many man-related buttons Gnus will show.
6537 The higher the number, the more buttons will appear and the more false
6538 positives are possible. Note that you can set this variable local to
6539 specific groups. Setting it higher in Unix groups is probably a good idea.
6540 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6541 how to set variables in specific groups."
6543 :group 'gnus-article-buttons
6544 :link '(custom-manual "(gnus)Group Parameters")
6547 (defcustom gnus-button-emacs-level 5
6548 "*Integer that says how many emacs-related buttons Gnus will show.
6549 The higher the number, the more buttons will appear and the more false
6550 positives are possible. Note that you can set this variable local to
6551 specific groups. Setting it higher in Emacs or Gnus related groups is
6552 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6553 `gnus-parameters' on how to set variables in specific groups."
6555 :group 'gnus-article-buttons
6556 :link '(custom-manual "(gnus)Group Parameters")
6559 (defcustom gnus-button-message-level 5
6560 "*Integer that says how many buttons for news or mail messages will appear.
6561 The higher the number, the more buttons will appear and the more false
6562 positives are possible."
6563 ;; mail addresses, MIDs, URLs for news, ...
6565 :group 'gnus-article-buttons
6568 (defcustom gnus-button-browse-level 5
6569 "*Integer that says how many buttons for browsing will appear.
6570 The higher the number, the more buttons will appear and the more false
6571 positives are possible."
6572 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6574 :group 'gnus-article-buttons
6577 (defcustom gnus-button-alist
6578 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6579 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6580 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
6581 gnus-button-handle-news 2)
6582 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6583 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6584 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6585 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6586 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
6587 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
6588 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
6589 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6590 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6591 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6592 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6593 ;; RFC 2368 (The mailto URL scheme)
6594 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6595 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6596 ("\\bmailto:\\([^ \n\t]+\\)"
6597 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6599 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6600 gnus-button-ctan-directory-regexp
6601 "[^][>)!;:,'\n\t ]+\\)")
6602 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6603 ((concat "\\btex-archive/\\("
6604 gnus-button-ctan-directory-regexp
6605 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6606 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6609 gnus-button-ctan-directory-regexp
6610 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6611 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6612 ;; This is info (home-grown style) <info://foo/bar+baz>
6613 ("\\binfo://\\([^'\">\n\t ]+\\)"
6614 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6615 ;; Info GNOME style <info:foo#bar_baz>
6616 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6617 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6618 ;; Info KDE style <info:(foo)bar baz>
6619 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6620 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6621 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6622 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6623 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6624 ;; Info links like `C-h i d m CC Mode RET'
6625 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6627 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6628 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6629 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6630 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6631 ;; Emacs help commands
6632 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6633 ;; regexp doesn't match arguments containing ` '.
6634 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6635 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6636 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6637 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6638 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6639 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6640 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6641 ;; The following entries may lead to many false positives so don't enable
6642 ;; them by default (use a high button level).
6643 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
6644 ;; Exclude [.?] for URLs in gmane.emacs.cvs
6645 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6646 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6647 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6648 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6649 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6650 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6651 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6652 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6653 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6654 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6655 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
6656 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6657 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6658 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6659 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6660 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6661 ;; Unlike the other regexps we really have to require quoting
6662 ;; here to determine where it ends.
6663 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6664 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
6665 ("<URL: *\\([^<>]*\\)>"
6666 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6667 ;; RFC 2396 (2.4.3., delims) ...
6668 ("\"URL: *\\([^\"]*\\)\""
6669 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6670 ;; RFC 2396 (2.4.3., delims) ...
6671 ("\"URL: *\\([^\"]*\\)\""
6672 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6674 (gnus-button-url-regexp
6675 0 (>= gnus-button-browse-level 0) browse-url 0)
6677 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
6678 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6679 gnus-button-handle-man 1)
6680 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6681 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
6682 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6683 gnus-button-handle-man 1)
6684 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6685 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6686 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
6687 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6688 ;; MID or mail: To avoid too many false positives we don't try to catch
6689 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6690 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6691 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6692 ;; so that non-ambiguous entries (see above) match first.
6693 (gnus-button-mid-or-mail-regexp
6694 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6695 "*Alist of regexps matching buttons in article bodies.
6697 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6698 REGEXP: is the string (case insensitive) matching text around the button (can
6699 also be Lisp expression evaluating to a string),
6700 BUTTON: is the number of the regexp grouping actually matching the button,
6701 FORM: is a Lisp expression which must eval to true for the button to
6703 CALLBACK: is the function to call when the user push this button, and each
6704 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6706 CALLBACK can also be a variable, in that case the value of that
6707 variable it the real callback function."
6708 :group 'gnus-article-buttons
6709 :type '(repeat (list (choice regexp variable sexp)
6710 (integer :tag "Button")
6712 (function :tag "Callback")
6715 (integer :tag "Regexp group")))))
6717 (defcustom gnus-header-button-alist
6718 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
6719 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6720 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6721 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6722 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6723 0 (>= gnus-button-message-level 0) gnus-button-mailto 0)
6724 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6725 0 (>= gnus-button-browse-level 0) browse-url 0)
6726 ("^Subject:" gnus-button-url-regexp
6727 0 (>= gnus-button-browse-level 0) browse-url 0)
6728 ("^[^:]+:" gnus-button-url-regexp
6729 0 (>= gnus-button-browse-level 0) browse-url 0)
6730 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6731 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6732 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6733 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6734 "*Alist of headers and regexps to match buttons in article heads.
6736 This alist is very similar to `gnus-button-alist', except that each
6737 alist has an additional HEADER element first in each entry:
6739 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6741 HEADER is a regexp to match a header. For a fuller explanation, see
6742 `gnus-button-alist'."
6743 :group 'gnus-article-buttons
6744 :group 'gnus-article-headers
6745 :type '(repeat (list (regexp :tag "Header")
6746 (choice regexp variable)
6747 (integer :tag "Button")
6749 (function :tag "Callback")
6752 (integer :tag "Regexp group")))))
6756 (defun gnus-article-push-button (event)
6757 "Check text under the mouse pointer for a callback function.
6758 If the text under the mouse pointer has a `gnus-callback' property,
6759 call it with the value of the `gnus-data' text property."
6761 (set-buffer (window-buffer (posn-window (event-start event))))
6762 (let* ((pos (posn-point (event-start event)))
6763 (data (get-text-property pos 'gnus-data))
6764 (fun (get-text-property pos 'gnus-callback)))
6767 (funcall fun data))))
6769 (defun gnus-article-press-button ()
6770 "Check text at point for a callback function.
6771 If the text at point has a `gnus-callback' property,
6772 call it with the value of the `gnus-data' text property."
6774 (let ((data (get-text-property (point) 'gnus-data))
6775 (fun (get-text-property (point) 'gnus-callback)))
6777 (funcall fun data))))
6779 (defun gnus-article-prev-button (n)
6780 "Move point to N buttons backward.
6781 If N is negative, move forward instead."
6783 (gnus-article-next-button (- n)))
6785 (defun gnus-article-next-button (n)
6786 "Move point to N buttons forward.
6787 If N is negative, move backward instead."
6789 (let ((function (if (< n 0) 'previous-single-property-change
6790 'next-single-property-change))
6791 (inhibit-point-motion-hooks t)
6793 (limit (if (< n 0) (point-min) (point-max))))
6795 (while (and (not (= limit (point)))
6797 ;; Skip past the current button.
6798 (when (get-text-property (point) 'gnus-callback)
6799 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6800 ;; Go to the next (or previous) button.
6801 (gnus-goto-char (funcall function (point) 'gnus-callback nil limit))
6802 ;; Put point at the start of the button.
6803 (when (and backward (not (get-text-property (point) 'gnus-callback)))
6804 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6805 ;; Skip past intangible buttons.
6806 (when (get-text-property (point) 'intangible)
6810 (gnus-message 5 "No more buttons"))
6813 (defun gnus-article-highlight (&optional force)
6814 "Highlight current article.
6815 This function calls `gnus-article-highlight-headers',
6816 `gnus-article-highlight-citation',
6817 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6818 do the highlighting. See the documentation for those functions."
6819 (interactive (list 'force))
6820 (gnus-article-highlight-headers)
6821 (gnus-article-highlight-citation force)
6822 (gnus-article-highlight-signature)
6823 (gnus-article-add-buttons force)
6824 (gnus-article-add-buttons-to-head))
6826 (defun gnus-article-highlight-some (&optional force)
6827 "Highlight current article.
6828 This function calls `gnus-article-highlight-headers',
6829 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6830 do the highlighting. See the documentation for those functions."
6831 (interactive (list 'force))
6832 (gnus-article-highlight-headers)
6833 (gnus-article-highlight-signature)
6834 (gnus-article-add-buttons))
6836 (defun gnus-article-highlight-headers ()
6837 "Highlight article headers as specified by `gnus-header-face-alist'."
6839 (gnus-with-article-headers
6840 (let (regexp header-face field-face from hpoints fpoints)
6841 (dolist (entry gnus-header-face-alist)
6842 (goto-char (point-min))
6843 (setq regexp (concat "^\\("
6844 (if (string-equal "" (nth 0 entry))
6848 header-face (nth 1 entry)
6849 field-face (nth 2 entry))
6850 (while (and (re-search-forward regexp nil t)
6854 (unless (search-forward ":" nil t)
6856 (when (and header-face
6857 (not (memq (point) hpoints)))
6858 (push (point) hpoints)
6859 (gnus-put-text-property from (point) 'face header-face))
6860 (when (and field-face
6861 (not (memq (setq from (point)) fpoints)))
6863 (if (re-search-forward "^[^ \t]" nil t)
6865 (goto-char (point-max)))
6866 (gnus-put-text-property from (point) 'face field-face)))))))
6868 (defun gnus-article-highlight-signature ()
6869 "Highlight the signature in an article.
6870 It does this by highlighting everything after
6871 `gnus-signature-separator' using `gnus-signature-face'."
6873 (when gnus-signature-face
6874 (gnus-with-article-buffer
6875 (let ((inhibit-point-motion-hooks t))
6877 (when (gnus-article-narrow-to-signature)
6878 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6879 'face gnus-signature-face)))))))
6881 (defun gnus-article-buttonize-signature ()
6882 "Add button to the signature."
6885 (set-buffer gnus-article-buffer)
6886 (let ((inhibit-read-only t)
6887 (inhibit-point-motion-hooks t))
6888 (when (gnus-article-search-signature)
6889 (gnus-article-add-button (match-beginning 0) (match-end 0)
6890 'gnus-signature-toggle
6891 (set-marker (make-marker)
6892 (1+ (match-end 0))))))))
6894 (defun gnus-button-in-region-p (b e prop)
6895 "Say whether PROP exists in the region."
6896 (text-property-not-all b e prop nil))
6898 (defun gnus-article-add-buttons (&optional force)
6899 "Find external references in the article and make buttons of them.
6900 \"External references\" are things like Message-IDs and URLs, as
6901 specified by `gnus-button-alist'."
6902 (interactive (list 'force))
6903 (gnus-with-article-buffer
6904 (let ((inhibit-point-motion-hooks t)
6905 (case-fold-search t)
6906 (alist gnus-button-alist)
6908 ;; Remove all old markers.
6909 (let (marker entry new-list)
6910 (while (setq marker (pop gnus-button-marker-list))
6911 (if (or (< marker (point-min)) (>= marker (point-max)))
6912 (push marker new-list)
6914 (when (setq entry (gnus-button-entry))
6915 (put-text-property (match-beginning (nth 1 entry))
6916 (match-end (nth 1 entry))
6917 'gnus-callback nil))
6918 (set-marker marker nil)))
6919 (setq gnus-button-marker-list new-list))
6920 ;; We skip the headers.
6923 (while (setq entry (pop alist))
6924 (setq regexp (eval (car entry)))
6926 (while (re-search-forward regexp nil t)
6927 (let* ((start (and entry (match-beginning (nth 1 entry))))
6928 (end (and entry (match-end (nth 1 entry))))
6929 (from (match-beginning 0)))
6930 (when (and (or (eq t (nth 2 entry))
6931 (eval (nth 2 entry)))
6932 (not (gnus-button-in-region-p
6933 start end 'gnus-callback)))
6934 ;; That optional form returned non-nil, so we add the
6936 (gnus-article-add-button
6937 start end 'gnus-button-push
6938 (car (push (set-marker (make-marker) from)
6939 gnus-button-marker-list))))))))))
6941 ;; Add buttons to the head of an article.
6942 (defun gnus-article-add-buttons-to-head ()
6943 "Add buttons to the head of the article."
6945 (gnus-with-article-headers
6947 (dolist (entry gnus-header-button-alist)
6948 ;; Each alist entry.
6949 (goto-char (point-min))
6950 (while (re-search-forward (car entry) nil t)
6951 ;; Each header matching the entry.
6952 (setq beg (match-beginning 0))
6953 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6954 (match-beginning 0))
6957 (while (re-search-forward (eval (nth 1 entry)) end t)
6958 ;; Each match within a header.
6959 (let* ((entry (cdr entry))
6960 (start (match-beginning (nth 1 entry)))
6961 (end (match-end (nth 1 entry)))
6962 (form (nth 2 entry)))
6963 (goto-char (match-end 0))
6965 (gnus-article-add-button
6966 start end (nth 3 entry)
6967 (buffer-substring (match-beginning (nth 4 entry))
6968 (match-end (nth 4 entry)))))))
6969 (goto-char end))))))
6971 ;;; External functions:
6973 (defun gnus-article-add-button (from to fun &optional data)
6974 "Create a button between FROM and TO with callback FUN and data DATA."
6975 (when gnus-article-button-face
6976 (gnus-overlay-put (gnus-make-overlay from to)
6977 'face gnus-article-button-face))
6978 (gnus-add-text-properties
6980 (nconc (and gnus-article-mouse-face
6981 (list gnus-mouse-face-prop gnus-article-mouse-face))
6982 (list 'gnus-callback fun)
6983 (and data (list 'gnus-data data))))
6984 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6985 :button-keymap gnus-widget-button-keymap))
6987 ;;; Internal functions:
6989 (defun gnus-article-set-globals ()
6990 (with-current-buffer gnus-summary-buffer
6991 (gnus-set-global-variables)))
6993 (defun gnus-signature-toggle (end)
6994 (gnus-with-article-buffer
6995 (let ((inhibit-point-motion-hooks t)
6996 (limit (next-single-property-change end 'mime-view-entity
6998 (if (text-property-any end limit 'article-type 'signature)
7000 (gnus-delete-wash-type 'signature)
7001 (gnus-remove-text-properties-when
7002 'article-type 'signature end limit
7003 (cons 'article-type (cons 'signature
7004 gnus-hidden-properties))))
7005 (gnus-add-wash-type 'signature)
7006 (gnus-add-text-properties-when
7007 'article-type nil end limit
7008 (cons 'article-type (cons 'signature
7009 gnus-hidden-properties)))))
7010 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
7011 (gnus-set-mode-line 'article))))
7013 (defun gnus-button-entry ()
7014 ;; Return the first entry in `gnus-button-alist' matching this place.
7015 (let ((alist gnus-button-alist)
7018 (setq entry (pop alist))
7019 (if (looking-at (eval (car entry)))
7024 (defun gnus-button-push (marker)
7025 ;; Push button starting at MARKER.
7028 (let* ((entry (gnus-button-entry))
7029 (inhibit-point-motion-hooks t)
7031 (args (mapcar (lambda (group)
7032 (let ((string (match-string group)))
7033 (set-text-properties
7034 0 (length string) nil string)
7041 (fboundp (symbol-value fun)))
7042 (apply (symbol-value fun) args))
7044 (gnus-message 1 "You must define `%S' to use this button"
7045 (cons fun args)))))))
7047 (defun gnus-parse-news-url (url)
7048 (let (scheme server group message-id articles)
7051 (goto-char (point-min))
7052 (when (looking-at "\\([A-Za-z]+\\):")
7053 (setq scheme (match-string 1))
7054 (goto-char (match-end 0)))
7055 (when (looking-at "//\\([^/]+\\)/")
7056 (setq server (match-string 1))
7057 (goto-char (match-end 0)))
7060 ((looking-at "\\(.*@.*\\)")
7061 (setq message-id (match-string 1)))
7062 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
7063 (setq group (match-string 1)
7064 articles (split-string (match-string 2) "-")))
7065 ((looking-at "\\([^/]+\\)/?")
7066 (setq group (match-string 1)))
7068 (error "Unknown news URL syntax"))))
7069 (list scheme server group message-id articles)))
7071 (defun gnus-button-handle-news (url)
7073 (destructuring-bind (scheme server group message-id articles)
7074 (gnus-parse-news-url url)
7078 (set-buffer gnus-summary-buffer)
7080 (let ((gnus-refer-article-method (list (list 'nntp server))))
7081 (gnus-summary-refer-article message-id))
7082 (gnus-summary-refer-article message-id))))
7084 (gnus-button-fetch-group url)))))
7086 (defun gnus-button-handle-man (url)
7088 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7089 (when (eq gnus-button-man-handler 'woman)
7090 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
7091 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7092 (funcall gnus-button-man-handler url))
7094 (defun gnus-button-handle-info-url (url)
7095 "Fetch an info URL."
7096 (setq url (mm-subst-char-in-string ?+ ?\ url))
7098 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
7099 (gnus-info-find-node
7100 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
7102 ")" (gnus-url-unhex-string (match-string 2 url)))))
7103 ((string-match "([^)\"]+)[^\"]+" url)
7105 (gnus-replace-in-string
7106 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
7107 (gnus-info-find-node url))
7108 (t (error "Can't parse %s" url))))
7110 (defun gnus-button-handle-info-url-gnome (url)
7111 "Fetch GNOME style info URL."
7112 (setq url (mm-subst-char-in-string ?_ ?\ url))
7113 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
7114 (gnus-info-find-node
7116 (gnus-url-unhex-string
7117 (match-string 1 url))
7119 (or (gnus-url-unhex-string
7120 (match-string 2 url))
7122 (error "Can't parse %s" url)))
7124 (defun gnus-button-handle-info-url-kde (url)
7125 "Fetch KDE style info URL."
7126 (gnus-info-find-node (gnus-url-unhex-string url)))
7128 (defun gnus-button-handle-info-keystrokes (url)
7129 "Call `info' when pushing the corresponding URL button."
7130 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
7135 (defun gnus-button-message-id (message-id)
7137 (with-current-buffer gnus-summary-buffer
7138 (gnus-summary-refer-article message-id)))
7140 (defun gnus-button-fetch-group (address)
7141 "Fetch GROUP specified by ADDRESS."
7142 (if (not (string-match "[:/]" address))
7143 ;; This is just a simple group url.
7144 (gnus-group-read-ephemeral-group address gnus-select-method)
7147 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
7149 (error "Can't parse %s" address)
7150 (gnus-group-read-ephemeral-group
7151 (match-string 4 address)
7152 `(nntp ,(match-string 1 address)
7153 (nntp-address ,(match-string 1 address))
7154 (nntp-port-number ,(if (match-end 3)
7155 (match-string 3 address)
7158 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
7160 (defun gnus-url-parse-query-string (query &optional downcase)
7161 (let (retval pairs cur key val)
7162 (setq pairs (split-string query "&"))
7164 (setq cur (car pairs)
7166 (if (not (string-match "=" cur))
7168 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
7169 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
7171 (setq key (downcase key)))
7172 (setq cur (assoc key retval))
7174 (setcdr cur (cons val (cdr cur)))
7175 (setq retval (cons (list key val) retval)))))
7178 (defun gnus-url-mailto (url)
7179 ;; Send mail to someone
7180 (when (string-match "mailto:/*\\(.*\\)" url)
7181 (setq url (substring url (match-beginning 1) nil)))
7182 (let (to args subject func)
7183 (setq args (gnus-url-parse-query-string
7184 (if (string-match "^\\?" url)
7186 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
7187 (concat "to=" (match-string 1 url) "&"
7188 (match-string 2 url))
7189 (concat "to=" url)))
7191 subject (cdr-safe (assoc "subject" args)))
7194 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
7197 (message-position-on-field (caar args)))
7198 (insert (gnus-replace-in-string
7199 (mapconcat 'identity (reverse (cdar args)) ", ")
7201 (setq args (cdr args)))
7204 (message-goto-subject))))
7206 (defun gnus-button-embedded-url (address)
7207 "Activate ADDRESS with `browse-url'."
7208 (browse-url (gnus-strip-whitespace address)))
7210 ;;; Next/prev buttons in the article buffer.
7212 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
7213 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
7215 (defvar gnus-prev-page-map
7216 (let ((map (make-sparse-keymap)))
7217 (define-key map gnus-mouse-2 'gnus-button-prev-page)
7218 (define-key map "\r" 'gnus-button-prev-page)
7221 (defvar gnus-next-page-map
7222 (let ((map (make-sparse-keymap)))
7223 (unless (>= emacs-major-version 21)
7224 ;; XEmacs doesn't care.
7225 (set-keymap-parent map gnus-article-mode-map))
7226 (define-key map gnus-mouse-2 'gnus-button-next-page)
7227 (define-key map "\r" 'gnus-button-next-page)
7230 (defun gnus-insert-prev-page-button ()
7232 (inhibit-read-only t)
7233 (situation (get-text-property (point-min) 'mime-view-situation)))
7235 gnus-prev-page-line-format nil
7236 `(keymap ,gnus-prev-page-map
7238 gnus-callback gnus-article-button-prev-page
7239 article-type annotation
7240 mime-view-situation ,situation))
7241 (widget-convert-button
7243 ;; Exclude a newline.
7246 :action 'gnus-button-prev-page
7247 :button-keymap gnus-prev-page-map)))
7249 (defun gnus-button-next-page (&optional args more-args)
7250 "Go to the next page."
7252 (let ((win (selected-window)))
7253 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7254 (gnus-article-next-page)
7255 (select-window win)))
7257 (defun gnus-button-prev-page (&optional args more-args)
7258 "Go to the prev page."
7260 (let ((win (selected-window)))
7261 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7262 (gnus-article-prev-page)
7263 (select-window win)))
7265 (defun gnus-insert-next-page-button ()
7267 (inhibit-read-only t)
7268 (situation (get-text-property (point-min) 'mime-view-situation)))
7269 (gnus-eval-format gnus-next-page-line-format nil
7270 `(keymap ,gnus-next-page-map
7272 gnus-callback gnus-article-button-next-page
7273 article-type annotation
7274 mime-view-situation ,situation))
7275 (widget-convert-button
7277 ;; Exclude a newline.
7280 :action 'gnus-button-next-page
7281 :button-keymap gnus-next-page-map)))
7283 (defun gnus-article-button-next-page (arg)
7284 "Go to the next page."
7286 (let ((win (selected-window)))
7287 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7288 (gnus-article-next-page)
7289 (select-window win)))
7291 (defun gnus-article-button-prev-page (arg)
7292 "Go to the prev page."
7294 (let ((win (selected-window)))
7295 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7296 (gnus-article-prev-page)
7297 (select-window win)))
7299 (defvar gnus-decode-header-methods
7300 '(mail-decode-encoded-word-region)
7301 "List of methods used to decode headers.
7303 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
7304 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
7305 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
7306 whose names match REGEXP.
7309 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
7310 mail-decode-encoded-word-region
7311 (\"chinese\" . rfc1843-decode-region))
7314 (defvar gnus-decode-header-methods-cache nil)
7316 (defun gnus-multi-decode-header (start end)
7317 "Apply the functions from `gnus-encoded-word-methods' that match."
7318 (unless (and gnus-decode-header-methods-cache
7319 (eq gnus-newsgroup-name
7320 (car gnus-decode-header-methods-cache)))
7321 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
7324 (nconc gnus-decode-header-methods-cache (list x))
7325 (if (and gnus-newsgroup-name
7326 (string-match (car x) gnus-newsgroup-name))
7327 (nconc gnus-decode-header-methods-cache
7329 gnus-decode-header-methods))
7330 (let ((xlist gnus-decode-header-methods-cache))
7333 (narrow-to-region start end)
7335 (funcall (pop xlist) (point-min) (point-max))))))
7338 ;;; Treatment top-level handling.
7341 (defun gnus-treat-article (condition &optional part-number total-parts type)
7342 (let ((length (- (point-max) (point-min)))
7343 (alist gnus-treatment-function-alist)
7344 (article-goto-body-goes-to-point-min-p t)
7348 (let ((list gnus-article-treat-types))
7350 (when (string-match (pop list) type)
7351 (throw 'found t)))))))
7352 (highlightp (gnus-visual-p 'article-highlight 'highlight))
7353 (entity (static-unless (featurep 'xemacs)
7354 (when (eq 'head condition)
7355 (get-text-property (point-min) 'mime-view-entity))))
7356 val elem buttonized)
7357 (gnus-run-hooks 'gnus-part-display-hook)
7358 (unless gnus-inhibit-treatment
7359 (dolist (elem alist)
7362 (when (gnus-buffer-live-p gnus-summary-buffer)
7363 (set-buffer gnus-summary-buffer))
7364 (symbol-value (car elem))))
7365 (when (and (or (consp val)
7367 (gnus-treat-predicate val)
7368 (or (not (get (car elem) 'highlight))
7370 (when (and (not buttonized)
7372 '(gnus-treat-hide-signature
7373 gnus-treat-highlight-signature)))
7374 (gnus-article-buttonize-signature)
7375 (setq buttonized t))
7377 (funcall (cadr elem)))))
7378 ;; FSF Emacsen does not inherit the existing text properties
7379 ;; in the new text, so we should do it for `mime-view-entity'.
7380 (static-unless (featurep 'xemacs)
7382 (put-text-property (point-min) (point-max)
7383 'mime-view-entity entity))))))
7385 ;; Dynamic variables.
7387 (defvar part-number)
7388 (defvar total-parts)
7393 (defun gnus-treat-predicate (val)
7398 (stringp (car val)))
7399 (apply 'gnus-or (mapcar `(lambda (s)
7400 (string-match s ,(or gnus-newsgroup-name "")))
7403 (let ((pred (pop val)))
7406 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
7408 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
7410 (not (gnus-treat-predicate (car val))))
7412 (equal (car val) type))
7414 (error "%S is not a valid predicate" pred)))))
7424 (eq part-number total-parts))
7428 (error "%S is not a valid value" val))))
7430 (defun gnus-article-encrypt-body (protocol &optional n)
7431 "Encrypt the article body."
7434 (or gnus-article-encrypt-protocol
7435 (completing-read "Encrypt protocol: "
7436 gnus-article-encrypt-protocol-alist
7438 current-prefix-arg))
7439 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7441 (error (format "Can't find the encrypt protocol %s" protocol)))
7442 (if (member gnus-newsgroup-name '("nndraft:delayed"
7445 (error "Can't encrypt the article in group %s"
7446 gnus-newsgroup-name))
7447 (gnus-summary-iterate n
7449 (set-buffer gnus-summary-buffer)
7450 (let ((mail-parse-charset gnus-newsgroup-charset)
7451 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7452 (summary-buffer gnus-summary-buffer)
7454 (gnus-set-global-variables)
7455 (when (gnus-group-read-only-p)
7456 (error "The current newsgroup does not support article encrypt"))
7457 (gnus-summary-show-article t)
7459 (or (mail-header-references gnus-current-headers) ""))
7460 (set-buffer gnus-article-buffer)
7461 (let* ((inhibit-read-only t)
7463 (mapcar (lambda (field)
7464 (and (save-restriction
7465 (message-narrow-to-head)
7466 (goto-char (point-min))
7467 (search-forward field nil t))
7469 (message-narrow-to-field)
7471 (delete-region (point-min) (point-max))
7473 '("Content-Type:" "Content-Transfer-Encoding:"
7474 "Content-Disposition:"))))
7475 (message-narrow-to-head)
7476 (message-remove-header "MIME-Version")
7477 (goto-char (point-max))
7478 (setq point (point))
7479 (insert (apply 'concat headers))
7481 (narrow-to-region point (point-max))
7482 (let ((message-options message-options))
7483 (message-options-set 'message-sender user-mail-address)
7484 (message-options-set 'message-recipients user-mail-address)
7485 (message-options-set 'message-sign-encrypt 'not)
7487 (goto-char (point-min))
7488 (insert "MIME-Version: 1.0\n")
7490 (gnus-summary-edit-article-done
7491 references nil summary-buffer t))
7492 (when gnus-keep-backlog
7493 (gnus-backlog-remove-article
7494 (car gnus-article-current) (cdr gnus-article-current)))
7496 (when (get-buffer gnus-original-article-buffer)
7497 (set-buffer gnus-original-article-buffer)
7498 (setq gnus-original-article nil)))
7499 (when gnus-use-cache
7500 (gnus-cache-update-article
7501 (car gnus-article-current) (cdr gnus-article-current))))))))
7503 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7504 "The following specs can be used:
7505 %t The security MIME type
7508 %D Details if button is pressed")
7510 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
7511 "The following specs can be used:
7512 %t The security MIME type
7515 %D Details if button is pressed")
7517 (defvar gnus-mime-security-button-line-format-alist
7518 '((?t gnus-tmp-type ?s)
7519 (?i gnus-tmp-info ?s)
7520 (?d gnus-tmp-details ?s)
7521 (?D gnus-tmp-pressed-details ?s)))
7523 (defvar gnus-mime-security-button-map
7524 (let ((map (make-sparse-keymap)))
7525 (define-key map gnus-mouse-2 'gnus-article-push-button)
7526 (define-key map "\r" 'gnus-article-press-button)
7529 (defvar gnus-mime-security-details-buffer nil)
7531 (defvar gnus-mime-security-button-pressed nil)
7533 (defvar gnus-mime-security-show-details-inline t
7534 "If non-nil, show details in the article buffer.")
7536 (defun gnus-mime-security-verify-or-decrypt (handle)
7537 (mm-remove-parts (cdr handle))
7538 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7539 point (inhibit-read-only t))
7541 (goto-char (car region)))
7543 (narrow-to-region (point) (point))
7544 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7545 (let* ((mm-verify-option 'known)
7546 (mm-decrypt-option 'known)
7547 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7548 (unless (eq nparts (cdr handle))
7549 (mm-destroy-parts (cdr handle))
7550 (setcdr handle nparts))))
7551 (setq point (point))
7552 (gnus-mime-display-security handle)
7553 (goto-char (point-max)))
7555 (delete-region (point) (cdr region))
7556 (set-marker (car region) nil)
7557 (set-marker (cdr region) nil))
7560 (defun gnus-mime-security-show-details (handle)
7561 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7563 (gnus-message 5 "No details.")
7564 (if gnus-mime-security-show-details-inline
7565 (let ((gnus-mime-security-button-pressed
7566 (not (get-text-property (point) 'gnus-mime-details)))
7567 (gnus-mime-security-button-line-format
7568 (get-text-property (point) 'gnus-line-format))
7569 (inhibit-read-only t))
7571 (while (eq (get-text-property (point) 'gnus-line-format)
7572 gnus-mime-security-button-line-format)
7576 (narrow-to-region (point) (point))
7577 (gnus-insert-mime-security-button handle))
7578 (delete-region (point)
7579 (or (text-property-not-all
7582 gnus-mime-security-button-line-format)
7585 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7586 (with-current-buffer gnus-mime-security-details-buffer
7589 (setq gnus-mime-security-details-buffer
7590 (gnus-get-buffer-create "*MIME Security Details*")))
7591 (with-current-buffer gnus-mime-security-details-buffer
7593 (goto-char (point-min)))
7594 (pop-to-buffer gnus-mime-security-details-buffer)))))
7596 (defun gnus-mime-security-press-button (handle)
7598 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7599 (gnus-mime-security-show-details handle)
7600 (gnus-mime-security-verify-or-decrypt handle))))
7602 (defun gnus-insert-mime-security-button (handle &optional displayed)
7603 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7606 (or (nth 2 (assoc protocol mm-verify-function-alist))
7607 (nth 2 (assoc protocol mm-decrypt-function-alist))
7609 (if (equal (car handle) "multipart/signed")
7610 " Signed" " Encrypted")
7613 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7616 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7617 gnus-tmp-pressed-details
7619 (setq gnus-tmp-details
7620 (if gnus-tmp-details
7621 (concat "\n" gnus-tmp-details)
7623 (setq gnus-tmp-pressed-details
7624 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7629 gnus-mime-security-button-line-format
7630 gnus-mime-security-button-line-format-alist
7631 `(keymap ,gnus-mime-security-button-map
7632 gnus-callback gnus-mime-security-press-button
7633 gnus-line-format ,gnus-mime-security-button-line-format
7634 gnus-mime-details ,gnus-mime-security-button-pressed
7635 article-type annotation
7638 ;; Exclude a newline.
7641 (widget-convert-button
7644 :action 'gnus-widget-press-button
7645 :button-keymap gnus-mime-security-button-map
7647 (lambda (widget/window &optional overlay pos)
7648 ;; Needed to properly clear the message due to a bug in
7649 ;; wid-edit (XEmacs only).
7650 (when (boundp 'help-echo-owns-message)
7651 (setq help-echo-owns-message t))
7654 (aref gnus-mouse-2 0))))))
7656 (defun gnus-mime-display-security (handle)
7658 (narrow-to-region (point) (point))
7659 (unless (gnus-unbuttonized-mime-type-p (car handle))
7660 (gnus-insert-mime-security-button handle))
7661 (gnus-mime-display-mixed (cdr handle))
7664 (unless (gnus-unbuttonized-mime-type-p (car handle))
7665 (let ((gnus-mime-security-button-line-format
7666 gnus-mime-security-button-end-line-format))
7667 (gnus-insert-mime-security-button handle)))
7668 (mm-set-handle-multipart-parameter
7670 (cons (set-marker (make-marker) (point-min))
7671 (set-marker (make-marker) (point-max))))))
7677 (defun gnus-article-header-presentation-method (entity situation)
7678 (mime-insert-header entity)
7679 (article-decode-group-name))
7681 (set-alist 'mime-header-presentation-method-alist
7682 'gnus-original-article-mode
7683 #'gnus-article-header-presentation-method)
7685 (defun gnus-mime-preview-quitting-method ()
7686 (mime-preview-kill-buffer)
7687 (delete-other-windows)
7688 (gnus-article-show-summary)
7689 (gnus-summary-select-article gnus-show-all-headers t))
7691 (set-alist 'mime-preview-quitting-method-alist
7692 'gnus-original-article-mode #'gnus-mime-preview-quitting-method)
7694 (set-alist 'mime-preview-following-method-alist
7695 'gnus-original-article-mode #'gnus-following-method)
7697 (set-alist 'mime-preview-over-to-previous-method-alist
7698 'gnus-original-article-mode
7700 (if (> (point-min) 1)
7701 (gnus-article-prev-page)
7702 (gnus-article-read-summary-keys
7703 nil (gnus-character-to-event ?P)))))
7705 (set-alist 'mime-preview-over-to-next-method-alist
7706 'gnus-original-article-mode'
7708 (if (< (point-max) (buffer-size))
7709 (gnus-article-next-page)
7710 (gnus-article-read-summary-keys
7711 nil (gnus-character-to-event ?N)))))
7721 (run-hooks 'gnus-art-load-hook)
7723 ;;; gnus-art.el ends here