1 ;;; gnus-art.el --- article mode commands for Semi-gnus
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005, 2006 Free Software Foundation, Inc.
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
7 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
8 ;; Katsumi Yamaoka <yamaoka@jpl.org>
9 ;; Keywords: mail, news, MIME
11 ;; This file is part of GNU Emacs.
13 ;; GNU Emacs is free software; you can redistribute it and/or modify
14 ;; it under the terms of the GNU General Public License as published by
15 ;; the Free Software Foundation; either version 2, or (at your option)
18 ;; GNU Emacs is distributed in the hope that it will be useful,
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;; GNU General Public License for more details.
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the
25 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
26 ;; Boston, MA 02110-1301, USA.
36 (defvar w3m-minor-mode-map))
40 ;; Avoid the "Recursive load suspected" error in Emacs 21.1.
42 (let ((recursive-load-depth-limit 100))
49 (when (static-if (featurep 'xemacs)
50 (console-on-window-system-p)
52 (require 'mime-image))
55 ;; Avoid byte-compile warnings.
65 (autoload 'gnus-msg-mail "gnus-msg" nil t)
66 (autoload 'gnus-button-mailto "gnus-msg")
67 (autoload 'gnus-button-reply "gnus-msg" nil t)
68 (autoload 'parse-time-string "parse-time" nil nil)
69 (autoload 'ansi-color-apply-on-region "ansi-color")
71 (defgroup gnus-article nil
73 :link '(custom-manual "(gnus)Article Buffer")
76 (defgroup gnus-article-treat nil
77 "Treating article parts."
78 :link '(custom-manual "(gnus)Article Hiding")
81 (defgroup gnus-article-hiding nil
82 "Hiding article parts."
83 :link '(custom-manual "(gnus)Article Hiding")
86 (defgroup gnus-article-highlight nil
87 "Article highlighting."
88 :link '(custom-manual "(gnus)Article Highlighting")
92 (defgroup gnus-article-signature nil
94 :link '(custom-manual "(gnus)Article Signature")
97 (defgroup gnus-article-headers nil
99 :link '(custom-manual "(gnus)Hiding Headers")
100 :group 'gnus-article)
102 (defgroup gnus-article-washing nil
103 "Special commands on articles."
104 :link '(custom-manual "(gnus)Article Washing")
105 :group 'gnus-article)
107 (defgroup gnus-article-emphasis nil
108 "Fontisizing articles."
109 :link '(custom-manual "(gnus)Article Fontisizing")
110 :group 'gnus-article)
112 (defgroup gnus-article-saving nil
114 :link '(custom-manual "(gnus)Saving Articles")
115 :group 'gnus-article)
117 (defgroup gnus-article-mime nil
118 "Worshiping the MIME wonder."
119 :link '(custom-manual "(gnus)Using MIME")
120 :group 'gnus-article)
122 (defgroup gnus-article-buttons nil
123 "Pushable buttons in the article buffer."
124 :link '(custom-manual "(gnus)Article Buttons")
125 :group 'gnus-article)
127 (defgroup gnus-article-various nil
128 "Other article options."
129 :link '(custom-manual "(gnus)Misc Article")
130 :group 'gnus-article)
132 (defcustom gnus-ignored-headers
135 (concat "^" header ":"))
136 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
137 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
138 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
139 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
140 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
141 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
142 "X-Attribution" "X-Originating-IP" "Delivered-To"
143 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
144 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
145 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
146 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
147 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
148 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
149 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
150 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
151 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
152 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
153 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
154 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
155 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
156 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
157 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
158 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
159 "List-[A-Za-z]+" "X-Listprocessor-Version"
160 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
161 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
162 "X-Received" "Content-length" "X-precedence"
163 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
164 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
165 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
166 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
167 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
168 "X-Content-length" "X-Posting-Agent" "Original-Received"
169 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
170 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
171 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
172 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
173 "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer"))
174 "*All headers that start with this regexp will be hidden.
175 This variable can also be a list of regexps of headers to be ignored.
176 If `gnus-visible-headers' is non-nil, this variable will be ignored."
177 :type '(choice :custom-show nil
180 :group 'gnus-article-hiding)
182 (defcustom gnus-visible-headers
183 "^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:"
184 "*All headers that do not match this regexp will be hidden.
185 This variable can also be a list of regexp of headers to remain visible.
186 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
187 :type '(repeat :value-to-internal (lambda (widget value)
188 (custom-split-regexp-maybe value))
189 :match (lambda (widget value)
191 (widget-editable-list-match widget value)))
193 :group 'gnus-article-hiding)
195 (defcustom gnus-sorted-header-list
196 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
197 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
198 "*This variable is a list of regular expressions.
199 If it is non-nil, headers that match the regular expressions will
200 be placed first in the article buffer in the sequence specified by
202 :type '(repeat regexp)
203 :group 'gnus-article-hiding)
205 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
206 "Headers that are only to be displayed if they have interesting data.
207 Possible values in this list are:
209 'empty Headers with no content.
210 'newsgroups Newsgroup identical to Gnus group.
211 'to-address To identical to To-address.
212 'to-list To identical to To-list.
213 'cc-list CC identical to To-list.
214 'followup-to Followup-to identical to Newsgroups.
215 'reply-to Reply-to identical to From.
216 'date Date less than four days old.
217 'long-to To and/or Cc longer than 1024 characters.
218 'many-to Multiple To and/or Cc."
219 :type '(set (const :tag "Headers with no content." empty)
220 (const :tag "Newsgroups identical to Gnus group." newsgroups)
221 (const :tag "To identical to To-address." to-address)
222 (const :tag "To identical to To-list." to-list)
223 (const :tag "CC identical to To-list." cc-list)
224 (const :tag "Followup-to identical to Newsgroups." followup-to)
225 (const :tag "Reply-to identical to From." reply-to)
226 (const :tag "Date less than four days old." date)
227 (const :tag "To and/or Cc longer than 1024 characters." long-to)
228 (const :tag "Multiple To and/or Cc headers." many-to))
229 :group 'gnus-article-hiding)
231 (defcustom gnus-article-skip-boring nil
232 "Skip over text that is not worth reading.
233 By default, if you set this t, then Gnus will display citations and
234 signatures, but will never scroll down to show you a page consisting
235 only of boring text. Boring text is controlled by
236 `gnus-article-boring-faces'."
239 :group 'gnus-article-hiding)
241 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
242 "Regexp matching signature separator.
243 This can also be a list of regexps. In that case, it will be checked
244 from head to tail looking for a separator. Searches will be done from
245 the end of the buffer."
246 :type '(choice :format "%{%t%}: %[Value Menu%]\n%v"
248 (repeat :tag "List of regexp" regexp))
249 :group 'gnus-article-signature)
251 (defcustom gnus-signature-limit nil
252 "Provide a limit to what is considered a signature.
253 If it is a number, no signature may not be longer (in characters) than
254 that number. If it is a floating point number, no signature may be
255 longer (in lines) than that number. If it is a function, the function
256 will be called without any parameters, and if it returns nil, there is
257 no signature in the buffer. If it is a string, it will be used as a
258 regexp. If it matches, the text in question is not a signature.
260 This can also be a list of the above values."
261 :type '(choice (const nil)
264 (function :value fun)
265 (regexp :value ".*"))
266 :group 'gnus-article-signature)
268 (defcustom gnus-hidden-properties '(invisible t intangible t)
269 "Property list to use for hiding text."
271 :group 'gnus-article-hiding)
273 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
274 ;; frames in a session.
275 (defcustom gnus-article-x-face-command
280 (if (or (gnus-image-type-available-p 'xface)
281 (gnus-image-type-available-p 'pbm))
282 'gnus-display-x-face-in-from
283 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -"))
284 ((gnus-image-type-available-p 'pbm)
285 'gnus-display-x-face-in-from)
287 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
289 "*String or function to be executed to display an X-Face header.
290 If it is a string, the command will be executed in a sub-shell
291 asynchronously. The compressed face will be piped to this command."
293 :format "%{%t%}:\n%[Value Menu%] %v"
297 (if (or (gnus-image-type-available-p 'xface)
298 (gnus-image-type-available-p 'pbm))
299 '(function-item gnus-display-x-face-in-from))
303 :group 'gnus-article-washing)
305 (defcustom gnus-article-x-face-too-ugly nil
306 "Regexp matching posters whose face shouldn't be shown automatically."
307 :type '(choice regexp (const nil))
308 :group 'gnus-article-washing)
310 (defcustom gnus-article-banner-alist nil
311 "Banner alist for stripping.
313 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
315 :type '(repeat (cons symbol regexp))
316 :group 'gnus-article-washing)
318 (gnus-define-group-parameter
321 "Alist of regexps (to match group names) and banner."
322 :variable-group gnus-article-washing
324 '(choice :tag "Banner"
326 (const :tag "Remove signature" signature)
327 (symbol :tag "Item in `gnus-article-banner-alist'" none)
329 (const :tag "None" nil))
331 "If non-nil, specify how to remove `banners' from articles.
333 Symbol `signature' means to remove signatures delimited by
334 `gnus-signature-separator'. Any other symbol is used to look up a
335 regular expression to match the banner in `gnus-article-banner-alist'.
336 A string is used as a regular expression to match the banner
339 (defcustom gnus-article-address-banner-alist nil
340 "Alist of mail addresses and banners.
341 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
342 to match a mail address in the From: header, BANNER is one of a symbol
343 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
344 If ADDRESS matches author's mail address, it will remove things like
345 advertisements. For example:
347 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
351 (regexp :tag "Address")
352 (choice :tag "Banner" :value nil
353 (const :tag "Remove signature" signature)
354 (symbol :tag "Item in `gnus-article-banner-alist'" none)
356 (const :tag "None" nil))))
358 :group 'gnus-article-washing)
360 (defmacro gnus-emphasis-custom-with-format (&rest body)
362 \\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\
363 \\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)"))
366 (defun gnus-emphasis-custom-value-to-external (value)
367 (gnus-emphasis-custom-with-format
368 (if (consp (car value))
369 (list (format format (car (car value)) (cdr (car value)))
371 (if (nth 1 value) 2 3)
375 (defun gnus-emphasis-custom-value-to-internal (value)
376 (gnus-emphasis-custom-with-format
377 (let ((regexp (concat "\\`"
378 (format (regexp-quote format)
379 "\\([^()]+\\)" "\\([^()]+\\)")
382 (if (string-match regexp (setq pattern (car value)))
383 (list (cons (match-string 1 pattern) (match-string 2 pattern))
388 (defcustom gnus-emphasis-alist
390 '(("\\*" "\\*" bold nil 2)
393 ("_/" "/_" underline-italic)
394 ("_\\*" "\\*_" underline-bold)
395 ("\\*/" "/\\*" bold-italic)
396 ("_\\*/" "/\\*_" underline-bold-italic))))
398 (gnus-emphasis-custom-with-format
399 (mapcar (lambda (spec)
400 (list (format format (car spec) (cadr spec))
403 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
405 '(;; I've never seen anyone use this strikethru convention whereas I've
406 ;; several times seen it triggered by normal text. --Stef
407 ;; Miles suggests that this form is sometimes used but for italics,
408 ;; so maybe we should map it to `italic'.
409 ;; ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
410 ;; 2 3 gnus-emphasis-strikethru)
411 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
412 2 3 gnus-emphasis-underline))))
413 "*Alist that says how to fontify certain phrases.
414 Each item looks like this:
416 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
418 The first element is a regular expression to be matched. The second
419 is a number that says what regular expression grouping used to find
420 the entire emphasized word. The third is a number that says what
421 regexp grouping should be displayed and highlighted. The fourth
422 is the face used for highlighting."
426 :format "%[Customizing Style%]\n%v"
428 (group :tag "Default"
429 :value ("" 0 0 default)
432 (let ((value (widget-get
433 (cadr (widget-get (widget-get widget :parent)
436 (if (not (eq (nth 2 value) 'default))
440 (gnus-emphasis-custom-value-to-external value))))
441 (widget-group-value-create widget))
443 (integer :format "Match group: %v")
444 (integer :format "Emphasize group: %v")
447 :value (("_" . "_") nil default)
449 (regexp :format "Start regexp: %v")
450 (regexp :format "End regexp: %v"))
451 (boolean :format "Show start and end patterns: %[%v%]\n"
452 :on " On " :off " Off ")
454 :get (lambda (symbol)
455 (mapcar 'gnus-emphasis-custom-value-to-internal
456 (default-value symbol)))
457 :set (lambda (symbol value)
458 (set-default symbol (mapcar 'gnus-emphasis-custom-value-to-external
460 :group 'gnus-article-emphasis)
462 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
463 "A regexp to describe whitespace which should not be emphasized.
464 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
465 The former avoids underlining of leading and trailing whitespace,
466 and the latter avoids underlining any whitespace at all."
468 :group 'gnus-article-emphasis
471 (defface gnus-emphasis-bold '((t (:bold t)))
472 "Face used for displaying strong emphasized text (*word*)."
473 :group 'gnus-article-emphasis)
475 (defface gnus-emphasis-italic '((t (:italic t)))
476 "Face used for displaying italic emphasized text (/word/)."
477 :group 'gnus-article-emphasis)
479 (defface gnus-emphasis-underline '((t (:underline t)))
480 "Face used for displaying underlined emphasized text (_word_)."
481 :group 'gnus-article-emphasis)
483 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
484 "Face used for displaying underlined bold emphasized text (_*word*_)."
485 :group 'gnus-article-emphasis)
487 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
488 "Face used for displaying underlined italic emphasized text (_/word/_)."
489 :group 'gnus-article-emphasis)
491 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
492 "Face used for displaying bold italic emphasized text (/*word*/)."
493 :group 'gnus-article-emphasis)
495 (defface gnus-emphasis-underline-bold-italic
496 '((t (:bold t :italic t :underline t)))
497 "Face used for displaying underlined bold italic emphasized text.
498 Example: (_/*word*/_)."
499 :group 'gnus-article-emphasis)
501 (defface gnus-emphasis-strikethru (if (featurep 'xemacs)
502 '((t (:strikethru t)))
503 '((t (:strike-through t))))
504 "Face used for displaying strike-through text (-word-)."
505 :group 'gnus-article-emphasis)
507 (defface gnus-emphasis-highlight-words
508 '((t (:background "black" :foreground "yellow")))
509 "Face used for displaying highlighted words."
510 :group 'gnus-article-emphasis)
512 (defcustom gnus-article-time-format "%a, %d %b %Y %T %Z"
513 "Format for display of Date headers in article bodies.
514 See `format-time-string' for the possible values.
516 The variable can also be function, which should return a complete Date
517 header. The function is called with one argument, the time, which can
518 be fed to `format-time-string'."
519 :type '(choice string function)
520 :link '(custom-manual "(gnus)Article Date")
521 :group 'gnus-article-washing)
523 (defcustom gnus-save-all-headers t
524 "*If non-nil, don't remove any headers before saving."
525 :group 'gnus-article-saving
528 (defcustom gnus-prompt-before-saving 'always
529 "*This variable says how much prompting is to be done when saving articles.
530 If it is nil, no prompting will be done, and the articles will be
531 saved to the default files. If this variable is `always', each and
532 every article that is saved will be preceded by a prompt, even when
533 saving large batches of articles. If this variable is neither nil not
534 `always', there the user will be prompted once for a file name for
535 each invocation of the saving commands."
536 :group 'gnus-article-saving
537 :type '(choice (item always)
538 (item :tag "never" nil)
539 (sexp :tag "once" :format "%t\n" :value t)))
541 (defcustom gnus-saved-headers gnus-visible-headers
542 "Headers to keep if `gnus-save-all-headers' is nil.
543 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
544 If that variable is nil, however, all headers that match this regexp
545 will be kept while the rest will be deleted before saving."
546 :group 'gnus-article-saving
549 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
550 "A function to save articles in your favourite format.
551 The function must be interactively callable (in other words, it must
552 be an Emacs command).
554 Gnus provides the following functions:
556 * gnus-summary-save-in-rmail (Rmail format)
557 * gnus-summary-save-in-mail (Unix mail format)
558 * gnus-summary-save-in-folder (MH folder)
559 * gnus-summary-save-in-file (article format)
560 * gnus-summary-save-body-in-file (article body)
561 * gnus-summary-save-in-vm (use VM's folder format)
562 * gnus-summary-write-to-file (article format -- overwrite)."
563 :group 'gnus-article-saving
564 :type '(radio (function-item gnus-summary-save-in-rmail)
565 (function-item gnus-summary-save-in-mail)
566 (function-item gnus-summary-save-in-folder)
567 (function-item gnus-summary-save-in-file)
568 (function-item gnus-summary-save-body-in-file)
569 (function-item gnus-summary-save-in-vm)
570 (function-item gnus-summary-write-to-file)))
572 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
573 "A function generating a file name to save articles in Rmail format.
574 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
575 :group 'gnus-article-saving
578 (defcustom gnus-mail-save-name 'gnus-plain-save-name
579 "A function generating a file name to save articles in Unix mail format.
580 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
581 :group 'gnus-article-saving
584 (defcustom gnus-folder-save-name 'gnus-folder-save-name
585 "A function generating a file name to save articles in MH folder.
586 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
587 :group 'gnus-article-saving
590 (defcustom gnus-file-save-name 'gnus-numeric-save-name
591 "A function generating a file name to save articles in article format.
592 The function is called with NEWSGROUP, HEADERS, and optional
594 :group 'gnus-article-saving
597 (defcustom gnus-split-methods
598 '((gnus-article-archive-name)
599 (gnus-article-nndoc-name))
600 "*Variable used to suggest where articles are to be saved.
601 For instance, if you would like to save articles related to Gnus in
602 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
603 you could set this variable to something like:
605 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
606 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
608 This variable is an alist where the key is the match and the
609 value is a list of possible files to save in if the match is
612 If the match is a string, it is used as a regexp match on the
613 article. If the match is a symbol, that symbol will be funcalled
614 from the buffer of the article to be saved with the newsgroup as
615 the parameter. If it is a list, it will be evaled in the same
618 If this form or function returns a string, this string will be
619 used as a possible file name; and if it returns a non-nil list,
620 that list will be used as possible file names."
621 :group 'gnus-article-saving
622 :type '(repeat (choice (list :value (fun) function)
623 (cons :value ("" "") regexp (repeat string))
626 (defcustom gnus-article-display-method-for-mime
627 'gnus-article-display-mime-message
628 "Function to display a MIME message.
629 The function is called from the article buffer."
630 :group 'gnus-article-mime
633 (defcustom gnus-article-display-method-for-traditional
634 'gnus-article-display-traditional-message
635 "*Function to display a traditional message.
636 The function is called from the article buffer."
637 :group 'gnus-article-mime
640 (defcustom gnus-page-delimiter "^\^L"
641 "*Regexp describing what to use as article page delimiters.
642 The default value is \"^\^L\", which is a form linefeed at the
643 beginning of a line."
645 :group 'gnus-article-various)
647 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
648 "*The format specification for the article mode line.
649 See `gnus-summary-mode-line-format' for a closer description.
651 The following additional specs are available:
653 %w The article washing status.
654 %m The number of MIME parts in the article."
656 :group 'gnus-article-various)
658 (defcustom gnus-article-mode-hook nil
659 "*A hook for Gnus article mode."
661 :group 'gnus-article-various)
663 (when (featurep 'xemacs)
664 ;; Extracted from gnus-xmas-define in order to preserve user settings
665 (when (fboundp 'turn-off-scroll-in-place)
666 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
667 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
668 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
670 (defcustom gnus-article-menu-hook nil
671 "*Hook run after the creation of the article mode menu."
673 :group 'gnus-article-various)
675 (defcustom gnus-article-prepare-hook nil
676 "*A hook called after an article has been prepared in the article buffer."
678 :group 'gnus-article-various)
680 (defcustom gnus-copy-article-ignored-headers nil
681 "List of headers to be removed when copying an article.
682 Each element is a regular expression."
683 :version "23.0" ;; No Gnus
684 :type '(repeat regexp)
685 :group 'gnus-article-various)
687 (make-obsolete-variable 'gnus-article-hide-pgp-hook
688 "This variable is obsolete in Gnus 5.10.")
690 (defcustom gnus-article-button-face 'bold
691 "Face used for highlighting buttons in the article buffer.
693 An article button is a piece of text that you can activate by pressing
694 `RET' or `mouse-2' above it."
696 :group 'gnus-article-buttons)
698 (defcustom gnus-article-mouse-face 'highlight
699 "Face used for mouse highlighting in the article buffer.
701 Article buttons will be displayed in this face when the cursor is
704 :group 'gnus-article-buttons)
706 (defcustom gnus-signature-face 'gnus-signature
707 "Face used for highlighting a signature in the article buffer.
708 Obsolete; use the face `gnus-signature' for customizations instead."
710 :group 'gnus-article-highlight
711 :group 'gnus-article-signature)
713 (defface gnus-signature
716 "Face used for highlighting a signature in the article buffer."
717 :group 'gnus-article-highlight
718 :group 'gnus-article-signature)
719 ;; backward-compatibility alias
720 (put 'gnus-signature-face 'face-alias 'gnus-signature)
722 (defface gnus-header-from
725 (:foreground "spring green"))
728 (:foreground "red3"))
731 "Face used for displaying from headers."
732 :group 'gnus-article-headers
733 :group 'gnus-article-highlight)
734 ;; backward-compatibility alias
735 (put 'gnus-header-from-face 'face-alias 'gnus-header-from)
737 (defface gnus-header-subject
740 (:foreground "SeaGreen3"))
743 (:foreground "red4"))
745 (:bold t :italic t)))
746 "Face used for displaying subject headers."
747 :group 'gnus-article-headers
748 :group 'gnus-article-highlight)
749 ;; backward-compatibility alias
750 (put 'gnus-header-subject-face 'face-alias 'gnus-header-subject)
752 (defface gnus-header-newsgroups
755 (:foreground "yellow" :italic t))
758 (:foreground "MidnightBlue" :italic t))
761 "Face used for displaying newsgroups headers.
762 In the default setup this face is only used for crossposted
764 :group 'gnus-article-headers
765 :group 'gnus-article-highlight)
766 ;; backward-compatibility alias
767 (put 'gnus-header-newsgroups-face 'face-alias 'gnus-header-newsgroups)
769 (defface gnus-header-name
772 (:foreground "SeaGreen"))
775 (:foreground "maroon"))
778 "Face used for displaying header names."
779 :group 'gnus-article-headers
780 :group 'gnus-article-highlight)
781 ;; backward-compatibility alias
782 (put 'gnus-header-name-face 'face-alias 'gnus-header-name)
784 (defface gnus-header-content
787 (:foreground "forest green" :italic t))
790 (:foreground "indianred4" :italic t))
793 "Face used for displaying header content."
794 :group 'gnus-article-headers
795 :group 'gnus-article-highlight)
796 ;; backward-compatibility alias
797 (put 'gnus-header-content-face 'face-alias 'gnus-header-content)
799 (defcustom gnus-header-face-alist
800 '(("From" nil gnus-header-from)
801 ("Subject" nil gnus-header-subject)
802 ("Newsgroups:.*," nil gnus-header-newsgroups)
803 ("" gnus-header-name gnus-header-content))
804 "*Controls highlighting of article headers.
806 An alist of the form (HEADER NAME CONTENT).
808 HEADER is a regular expression which should match the name of a
809 header and NAME and CONTENT are either face names or nil.
811 The name of each header field will be displayed using the face
812 specified by the first element in the list where HEADER matches
813 the header name and NAME is non-nil. Similarly, the content will
814 be displayed by the first non-nil matching CONTENT face."
815 :group 'gnus-article-headers
816 :group 'gnus-article-highlight
817 :type '(repeat (list (regexp :tag "Header")
819 (item :tag "skip" nil)
820 (face :value default))
821 (choice :tag "Content"
822 (item :tag "skip" nil)
823 (face :value default)))))
825 (defcustom gnus-article-decode-hook
826 '(article-decode-group-name article-decode-idna-rhs)
827 "*Hook run to decode charsets in articles."
828 :group 'gnus-article-headers
831 (defcustom gnus-display-mime-function 'gnus-display-mime
832 "Function to display MIME articles."
833 :group 'gnus-article-mime
836 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
837 "Function used to decode headers.")
839 (defvar gnus-article-dumbquotes-map
859 "Table for MS-to-Latin1 translation.")
861 (defcustom gnus-ignored-mime-types nil
862 "List of MIME types that should be ignored by Gnus."
864 :group 'gnus-article-mime
865 :type '(repeat regexp))
867 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
868 "List of MIME types that should not be given buttons when rendered inline.
869 See also `gnus-buttonized-mime-types' which may override this variable.
870 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
872 :group 'gnus-article-mime
873 :type '(repeat regexp))
875 (defcustom gnus-buttonized-mime-types nil
876 "List of MIME types that should be given buttons when rendered inline.
877 If set, this variable overrides `gnus-unbuttonized-mime-types'.
878 To see e.g. security buttons you could set this to
879 `(\"multipart/signed\")'. You could also add \"multipart/alternative\" to
880 this list to display radio buttons that allow you to choose one of two
881 media types those mails include. See also `mm-discouraged-alternatives'.
882 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
884 :group 'gnus-article-mime
885 :type '(repeat regexp))
887 (defcustom gnus-inhibit-mime-unbuttonizing nil
888 "If non-nil, all MIME parts get buttons.
889 When nil (the default value), then some MIME parts do not get buttons,
890 as described by the variables `gnus-buttonized-mime-types' and
891 `gnus-unbuttonized-mime-types'."
893 :group 'gnus-article-mime
896 (defcustom gnus-body-boundary-delimiter "_"
897 "String used to delimit header and body.
898 This variable is used by `gnus-article-treat-body-boundary' which can
899 be controlled by `gnus-treat-body-boundary'."
901 :group 'gnus-article-various
902 :type '(choice (item :tag "None" :value nil)
905 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces"
907 "Defines the location of the faces database.
908 For information on obtaining this database of pretty pictures, please
909 see http://www.cs.indiana.edu/picons/ftp/index.html"
911 :type '(repeat directory)
912 :link '(url-link :tag "download"
913 "http://www.cs.indiana.edu/picons/ftp/index.html")
914 :link '(custom-manual "(gnus)Picons")
917 (defun gnus-picons-installed-p ()
918 "Say whether picons are installed on your machine."
919 (let ((installed nil))
920 (dolist (database gnus-picon-databases)
921 (when (file-exists-p database)
925 (defcustom gnus-article-mime-part-function nil
926 "Function called with a MIME handle as the argument.
927 This is meant for people who want to do something automatic based
928 on parts -- for instance, adding Vcard info to a database."
929 :group 'gnus-article-mime
930 :type '(choice (const nil)
933 (defcustom gnus-mime-multipart-functions nil
934 "An alist of MIME types to functions to display them."
936 :group 'gnus-article-mime
937 :type '(repeat (cons :format "%v" (string :tag "MIME type") function)))
939 (defcustom gnus-article-date-lapsed-new-header nil
940 "Whether the X-Sent and Date headers can coexist.
941 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
942 either replace the old \"Date:\" header (if this variable is nil), or
943 be added below it (otherwise)."
945 :group 'gnus-article-headers
948 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
949 "Function called with a MIME handle as the argument.
950 This is meant for people who want to view first matched part.
951 For `undisplayed-alternative' (default), the first undisplayed
952 part or alternative part is used. For `undisplayed', the first
953 undisplayed part is used. For a function, the first part which
954 the function return t is used. For nil, the first part is
957 :group 'gnus-article-mime
959 (item :tag "first" :value nil)
960 (item :tag "undisplayed" :value undisplayed)
961 (item :tag "undisplayed or alternative"
962 :value undisplayed-alternative)
965 (defcustom gnus-mime-action-alist
966 '(("save to file" . gnus-mime-save-part)
967 ("save and strip" . gnus-mime-save-part-and-strip)
968 ("replace with file" . gnus-mime-replace-part)
969 ("delete part" . gnus-mime-delete-part)
970 ("display as text" . gnus-mime-inline-part)
971 ("view the part" . gnus-mime-view-part)
972 ("pipe to command" . gnus-mime-pipe-part)
973 ("toggle display" . gnus-article-press-button)
974 ("toggle display" . gnus-article-view-part-as-charset)
975 ("view as type" . gnus-mime-view-part-as-type)
976 ("view internally" . gnus-mime-view-part-internally)
977 ("view externally" . gnus-mime-view-part-externally))
978 "An alist of actions that run on the MIME attachment."
979 :group 'gnus-article-mime
980 :type '(repeat (cons (string :tag "name")
983 (defcustom gnus-auto-select-part 1
984 "Advance to next MIME part when deleting or stripping parts.
986 When 0, point will be placed on the same part as before. When
987 positive (negative), move point forward (backwards) this many
988 parts. When nil, redisplay article."
989 :version "23.0" ;; No Gnus
990 :group 'gnus-article-mime
991 :type '(choice (const nil :tag "Redisplay article.")
992 (const 1 :tag "Next part.")
993 (const 0 :tag "Current part.")
997 ;;; The treatment variables
1000 (defvar gnus-part-display-hook nil
1001 "Hook called on parts that are to receive treatment.")
1003 (defvar gnus-article-treat-custom
1004 '(choice (const :tag "Off" nil)
1006 (const :tag "Header" head)
1007 (const :tag "First" first)
1008 (const :tag "Last" last)
1009 (const :tag "Mime" mime)
1010 (integer :tag "Less")
1011 (repeat :tag "Groups" regexp)
1012 (sexp :tag "Predicate")))
1014 (defvar gnus-article-treat-head-custom
1015 '(choice (const :tag "Off" nil)
1016 (const :tag "Header" head)))
1018 (defvar gnus-article-treat-types '("text/plain")
1021 (defvar gnus-inhibit-treatment nil
1022 "Whether to inhibit treatment.")
1024 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
1025 "Highlight the signature.
1026 Valid values are nil, t, `head', `first', `last', an integer or a
1027 predicate. See Info node `(gnus)Customizing Articles'."
1028 :group 'gnus-article-treat
1029 :link '(custom-manual "(gnus)Customizing Articles")
1030 :type gnus-article-treat-custom)
1031 (put 'gnus-treat-highlight-signature 'highlight t)
1033 (defcustom gnus-treat-buttonize 100000
1035 Valid values are nil, t, `head', `first', `last', an integer or a
1036 predicate. See Info node `(gnus)Customizing Articles'."
1037 :group 'gnus-article-treat
1038 :link '(custom-manual "(gnus)Customizing Articles")
1039 :type gnus-article-treat-custom)
1040 (put 'gnus-treat-buttonize 'highlight t)
1042 (defcustom gnus-treat-buttonize-head 'head
1043 "Add buttons to the head.
1044 Valid values are nil, t, `head', `first', `last', an integer or a
1045 predicate. See Info node `(gnus)Customizing Articles'."
1046 :group 'gnus-article-treat
1047 :link '(custom-manual "(gnus)Customizing Articles")
1048 :type gnus-article-treat-head-custom)
1049 (put 'gnus-treat-buttonize-head 'highlight t)
1051 (defcustom gnus-treat-emphasize
1052 (and (or window-system
1056 Valid values are nil, t, `head', `first', `last', an integer or a
1057 predicate. See Info node `(gnus)Customizing Articles'."
1058 :group 'gnus-article-treat
1059 :link '(custom-manual "(gnus)Customizing Articles")
1060 :type gnus-article-treat-custom)
1061 (put 'gnus-treat-emphasize 'highlight t)
1063 (defcustom gnus-treat-strip-cr nil
1064 "Remove carriage returns.
1065 Valid values are nil, t, `head', `first', `last', an integer or a
1066 predicate. See Info node `(gnus)Customizing Articles'."
1068 :group 'gnus-article-treat
1069 :link '(custom-manual "(gnus)Customizing Articles")
1070 :type gnus-article-treat-custom)
1072 (defcustom gnus-treat-unsplit-urls nil
1073 "Remove newlines from within URLs.
1074 Valid values are nil, t, `head', `first', `last', an integer or a
1075 predicate. See Info node `(gnus)Customizing Articles'."
1077 :group 'gnus-article-treat
1078 :link '(custom-manual "(gnus)Customizing Articles")
1079 :type gnus-article-treat-custom)
1081 (defcustom gnus-treat-leading-whitespace nil
1082 "Remove leading whitespace in headers.
1083 Valid values are nil, t, `head', `first', `last', an integer or a
1084 predicate. See Info node `(gnus)Customizing Articles'."
1086 :group 'gnus-article-treat
1087 :link '(custom-manual "(gnus)Customizing Articles")
1088 :type gnus-article-treat-custom)
1090 (defcustom gnus-treat-hide-headers 'head
1092 Valid values are nil, t, `head', `first', `last', an integer or a
1093 predicate. See Info node `(gnus)Customizing Articles'."
1094 :group 'gnus-article-treat
1095 :link '(custom-manual "(gnus)Customizing Articles")
1096 :type gnus-article-treat-head-custom)
1098 (defcustom gnus-treat-hide-boring-headers nil
1099 "Hide boring headers.
1100 Valid values are nil, t, `head', `first', `last', an integer or a
1101 predicate. See Info node `(gnus)Customizing Articles'."
1102 :group 'gnus-article-treat
1103 :link '(custom-manual "(gnus)Customizing Articles")
1104 :type gnus-article-treat-head-custom)
1106 (defcustom gnus-treat-hide-signature nil
1107 "Hide the signature.
1108 Valid values are nil, t, `head', `first', `last', an integer or a
1109 predicate. See Info node `(gnus)Customizing Articles'."
1110 :group 'gnus-article-treat
1111 :link '(custom-manual "(gnus)Customizing Articles")
1112 :type gnus-article-treat-custom)
1114 (defcustom gnus-treat-fill-article nil
1116 Valid values are nil, t, `head', `first', `last', an integer or a
1117 predicate. See Info node `(gnus)Customizing Articles'."
1118 :group 'gnus-article-treat
1119 :link '(custom-manual "(gnus)Customizing Articles")
1120 :type gnus-article-treat-custom)
1122 (defcustom gnus-treat-hide-citation nil
1124 Valid values are nil, t, `head', `first', `last', an integer or a
1125 predicate. See Info node `(gnus)Customizing Articles'."
1126 :group 'gnus-article-treat
1127 :link '(custom-manual "(gnus)Customizing Articles")
1128 :type gnus-article-treat-custom)
1130 (defcustom gnus-treat-hide-citation-maybe nil
1132 Valid values are nil, t, `head', `first', `last', an integer or a
1133 predicate. See Info node `(gnus)Customizing Articles'."
1134 :group 'gnus-article-treat
1135 :link '(custom-manual "(gnus)Customizing Articles")
1136 :type gnus-article-treat-custom)
1138 (defcustom gnus-treat-strip-list-identifiers 'head
1139 "Strip list identifiers from `gnus-list-identifiers`.
1140 Valid values are nil, t, `head', `first', `last', an integer or a
1141 predicate. See Info node `(gnus)Customizing Articles'."
1143 :group 'gnus-article-treat
1144 :link '(custom-manual "(gnus)Customizing Articles")
1145 :type gnus-article-treat-custom)
1147 (make-obsolete-variable 'gnus-treat-strip-pgp
1148 "This option is obsolete in Gnus 5.10.")
1150 (defcustom gnus-treat-strip-pem nil
1151 "Strip PEM signatures.
1152 Valid values are nil, t, `head', `first', `last', an integer or a
1153 predicate. See Info node `(gnus)Customizing Articles'."
1154 :group 'gnus-article-treat
1155 :link '(custom-manual "(gnus)Customizing Articles")
1156 :type gnus-article-treat-custom)
1158 (defcustom gnus-treat-strip-banner t
1159 "Strip banners from articles.
1160 The banner to be stripped is specified in the `banner' group parameter.
1161 Valid values are nil, t, `head', `first', `last', an integer or a
1162 predicate. See Info node `(gnus)Customizing Articles'."
1163 :group 'gnus-article-treat
1164 :link '(custom-manual "(gnus)Customizing Articles")
1165 :type gnus-article-treat-custom)
1167 (defcustom gnus-treat-highlight-headers 'head
1168 "Highlight the headers.
1169 Valid values are nil, t, `head', `first', `last', an integer or a
1170 predicate. See Info node `(gnus)Customizing Articles'."
1171 :group 'gnus-article-treat
1172 :link '(custom-manual "(gnus)Customizing Articles")
1173 :type gnus-article-treat-head-custom)
1174 (put 'gnus-treat-highlight-headers 'highlight t)
1176 (defcustom gnus-treat-highlight-citation t
1177 "Highlight cited text.
1178 Valid values are nil, t, `head', `first', `last', an integer or a
1179 predicate. See Info node `(gnus)Customizing Articles'."
1180 :group 'gnus-article-treat
1181 :link '(custom-manual "(gnus)Customizing Articles")
1182 :type gnus-article-treat-custom)
1183 (put 'gnus-treat-highlight-citation 'highlight t)
1185 (defcustom gnus-treat-date-ut nil
1186 "Display the Date in UT (GMT).
1187 Valid values are nil, t, `head', `first', `last', an integer or a
1188 predicate. See Info node `(gnus)Customizing Articles'."
1189 :group 'gnus-article-treat
1190 :link '(custom-manual "(gnus)Customizing Articles")
1191 :type gnus-article-treat-head-custom)
1193 (defcustom gnus-treat-date-local nil
1194 "Display the Date in the local timezone.
1195 Valid values are nil, t, `head', `first', `last', an integer or a
1196 predicate. See Info node `(gnus)Customizing Articles'."
1197 :group 'gnus-article-treat
1198 :link '(custom-manual "(gnus)Customizing Articles")
1199 :type gnus-article-treat-head-custom)
1201 (defcustom gnus-treat-date-english nil
1202 "Display the Date in a format that can be read aloud in English.
1203 Valid values are nil, t, `head', `first', `last', an integer or a
1204 predicate. See Info node `(gnus)Customizing Articles'."
1206 :group 'gnus-article-treat
1207 :link '(custom-manual "(gnus)Customizing Articles")
1208 :type gnus-article-treat-head-custom)
1210 (defcustom gnus-treat-date-lapsed nil
1211 "Display the Date header in a way that says how much time has elapsed.
1212 Valid values are nil, t, `head', `first', `last', an integer or a
1213 predicate. See Info node `(gnus)Customizing Articles'."
1214 :group 'gnus-article-treat
1215 :link '(custom-manual "(gnus)Customizing Articles")
1216 :type gnus-article-treat-head-custom)
1218 (defcustom gnus-treat-date-original nil
1219 "Display the date in the original timezone.
1220 Valid values are nil, t, `head', `first', `last', an integer or a
1221 predicate. See Info node `(gnus)Customizing Articles'."
1222 :group 'gnus-article-treat
1223 :link '(custom-manual "(gnus)Customizing Articles")
1224 :type gnus-article-treat-head-custom)
1226 (defcustom gnus-treat-date-iso8601 nil
1227 "Display the date in the ISO8601 format.
1228 Valid values are nil, t, `head', `first', `last', an integer or a
1229 predicate. See Info node `(gnus)Customizing Articles'."
1231 :group 'gnus-article-treat
1232 :link '(custom-manual "(gnus)Customizing Articles")
1233 :type gnus-article-treat-head-custom)
1235 (defcustom gnus-treat-date-user-defined nil
1236 "Display the date in a user-defined format.
1237 The format is defined by the `gnus-article-time-format' variable.
1238 Valid values are nil, t, `head', `first', `last', an integer or a
1239 predicate. See Info node `(gnus)Customizing Articles'."
1240 :group 'gnus-article-treat
1241 :link '(custom-manual "(gnus)Customizing Articles")
1242 :type gnus-article-treat-head-custom)
1244 (defcustom gnus-treat-strip-headers-in-body t
1245 "Strip the X-No-Archive header line from the beginning of the body.
1246 Valid values are nil, t, `head', `first', `last', an integer or a
1247 predicate. See Info node `(gnus)Customizing Articles'."
1249 :group 'gnus-article-treat
1250 :link '(custom-manual "(gnus)Customizing Articles")
1251 :type gnus-article-treat-custom)
1253 (defcustom gnus-treat-strip-trailing-blank-lines nil
1254 "Strip trailing blank lines.
1255 Valid values are nil, t, `head', `first', `last', an integer or a
1256 predicate. See Info node `(gnus)Customizing Articles'.
1258 When set to t, it also strips trailing blanks in all MIME parts.
1259 Consider to use `last' instead."
1260 :group 'gnus-article-treat
1261 :link '(custom-manual "(gnus)Customizing Articles")
1262 :type gnus-article-treat-custom)
1264 (defcustom gnus-treat-strip-leading-blank-lines nil
1265 "Strip leading blank lines.
1266 Valid values are nil, t, `head', `first', `last', an integer or a
1267 predicate. See Info node `(gnus)Customizing Articles'.
1269 When set to t, it also strips trailing blanks in all MIME parts."
1270 :group 'gnus-article-treat
1271 :link '(custom-manual "(gnus)Customizing Articles")
1272 :type gnus-article-treat-custom)
1274 (defcustom gnus-treat-strip-multiple-blank-lines nil
1275 "Strip multiple blank lines.
1276 Valid values are nil, t, `head', `first', `last', an integer or a
1277 predicate. See Info node `(gnus)Customizing Articles'."
1278 :group 'gnus-article-treat
1279 :link '(custom-manual "(gnus)Customizing Articles")
1280 :type gnus-article-treat-custom)
1282 (defcustom gnus-treat-unfold-headers 'head
1283 "Unfold folded header lines.
1284 Valid values are nil, t, `head', `first', `last', an integer or a
1285 predicate. See Info node `(gnus)Customizing Articles'."
1287 :group 'gnus-article-treat
1288 :link '(custom-manual "(gnus)Customizing Articles")
1289 :type gnus-article-treat-custom)
1291 (defcustom gnus-treat-fold-headers nil
1293 Valid values are nil, t, `head', `first', `last', an integer or a
1294 predicate. See Info node `(gnus)Customizing Articles'."
1296 :group 'gnus-article-treat
1297 :link '(custom-manual "(gnus)Customizing Articles")
1298 :type gnus-article-treat-custom)
1300 (defcustom gnus-treat-fold-newsgroups 'head
1301 "Fold the Newsgroups and Followup-To headers.
1302 Valid values are nil, t, `head', `first', `last', an integer or a
1303 predicate. See Info node `(gnus)Customizing Articles'."
1305 :group 'gnus-article-treat
1306 :link '(custom-manual "(gnus)Customizing Articles")
1307 :type gnus-article-treat-custom)
1309 (defcustom gnus-treat-overstrike t
1310 "Treat overstrike highlighting.
1311 Valid values are nil, t, `head', `first', `last', an integer or a
1312 predicate. See Info node `(gnus)Customizing Articles'."
1313 :group 'gnus-article-treat
1314 :link '(custom-manual "(gnus)Customizing Articles")
1315 :type gnus-article-treat-custom)
1316 (put 'gnus-treat-overstrike 'highlight t)
1318 (defcustom gnus-treat-ansi-sequences (if (locate-library "ansi-color") t)
1319 "Treat ANSI SGR control sequences.
1320 Valid values are nil, t, `head', `first', `last', an integer or a
1321 predicate. See Info node `(gnus)Customizing Articles'."
1322 :group 'gnus-article-treat
1323 :link '(custom-manual "(gnus)Customizing Articles")
1324 :type gnus-article-treat-custom)
1326 (make-obsolete-variable 'gnus-treat-display-xface
1327 'gnus-treat-display-x-face)
1329 (defcustom gnus-treat-display-x-face
1330 (and (not noninteractive)
1331 (or (and (fboundp 'image-type-available-p)
1332 (image-type-available-p 'xbm)
1333 (string-match "^0x" (shell-command-to-string "uncompface"))
1334 (executable-find "icontopbm"))
1335 (and (featurep 'xemacs)
1338 "Display X-Face headers.
1339 Valid values are nil, t, `head', `first', `last', an integer or a
1340 predicate. See Info node `(gnus)Customizing Articles' and Info
1341 node `(gnus)X-Face' for details."
1342 :group 'gnus-article-treat
1344 :link '(custom-manual "(gnus)Customizing Articles")
1345 :link '(custom-manual "(gnus)X-Face")
1346 :type gnus-article-treat-head-custom
1347 :set (lambda (symbol value)
1350 (cond ((or (boundp symbol) (get symbol 'saved-value))
1352 ((boundp 'gnus-treat-display-xface)
1354 ** gnus-treat-display-xface is an obsolete variable;\
1355 use gnus-treat-display-x-face instead")
1356 (default-value 'gnus-treat-display-xface))
1357 ((get 'gnus-treat-display-xface 'saved-value)
1359 ** gnus-treat-display-xface is an obsolete variable;\
1360 use gnus-treat-display-x-face instead")
1361 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1364 (put 'gnus-treat-display-x-face 'highlight t)
1366 (defcustom gnus-article-should-use-smiley-mule
1367 (not (or (featurep 'xemacs)
1368 (gnus-image-type-available-p 'xpm)
1369 (gnus-image-type-available-p 'pbm)))
1370 "Non-nil means use `smiley-mule' to show smileys rather than `smiley'.
1371 `smiley-mule' is boundled in BITMAP-MULE package. You can set it to t
1372 even if your Emacs supports images. It has no effect on XEmacs."
1373 :group 'gnus-article-various
1375 :get (lambda (symbol)
1376 (and (not noninteractive)
1377 (default-value symbol)
1378 (not (featurep 'xemacs))
1379 (module-installed-p 'smiley-mule)
1381 :set (lambda (symbol value)
1382 (set-default symbol (and (not noninteractive)
1384 (not (featurep 'xemacs))
1385 (module-installed-p 'smiley-mule)
1388 (defvar gnus-article-smiley-mule-loaded-p nil
1389 "Internal variable used to say whether `smiley-mule' is loaded (whether
1390 smiley functions are not overridden by `smiley').")
1392 (defcustom gnus-treat-display-face
1393 (and (not noninteractive)
1394 (or (and (fboundp 'image-type-available-p)
1395 (image-type-available-p 'png))
1396 (and (featurep 'xemacs)
1399 "Display Face headers.
1400 Valid values are nil, t, `head', `first', `last', an integer or a
1401 predicate. See Info node `(gnus)Customizing Articles' and Info
1402 node `(gnus)X-Face' for details."
1403 :group 'gnus-article-treat
1405 :link '(custom-manual "(gnus)Customizing Articles")
1406 :link '(custom-manual "(gnus)X-Face")
1407 :type gnus-article-treat-head-custom)
1408 (put 'gnus-treat-display-face 'highlight t)
1410 (defcustom gnus-treat-display-smileys
1411 (if (and (not noninteractive)
1412 (or (and (featurep 'xemacs)
1414 (gnus-image-type-available-p 'xpm)
1415 (gnus-image-type-available-p 'pbm)
1416 (and (not (featurep 'xemacs))
1418 (module-installed-p 'smiley-mule))))
1422 Valid values are nil, t, `head', `first', `last', an integer or a
1423 predicate. See Info node `(gnus)Customizing Articles' and Info
1424 node `(gnus)Smileys' for details."
1425 :group 'gnus-article-treat
1427 :link '(custom-manual "(gnus)Customizing Articles")
1428 :link '(custom-manual "(gnus)Smileys")
1429 :type gnus-article-treat-custom)
1430 (put 'gnus-treat-display-smileys 'highlight t)
1432 (defcustom gnus-treat-from-picon
1433 (if (and (gnus-image-type-available-p 'xpm)
1434 (gnus-picons-installed-p))
1436 "Display picons in the From header.
1437 Valid values are nil, t, `head', `first', `last', an integer or a
1438 predicate. See Info node `(gnus)Customizing Articles' and Info
1439 node `(gnus)Picons' for details."
1441 :group 'gnus-article-treat
1443 :link '(custom-manual "(gnus)Customizing Articles")
1444 :link '(custom-manual "(gnus)Picons")
1445 :type gnus-article-treat-head-custom)
1446 (put 'gnus-treat-from-picon 'highlight t)
1448 (defcustom gnus-treat-mail-picon
1449 (if (and (gnus-image-type-available-p 'xpm)
1450 (gnus-picons-installed-p))
1452 "Display picons in To and Cc headers.
1453 Valid values are nil, t, `head', `first', `last', an integer or a
1454 predicate. See Info node `(gnus)Customizing Articles' and Info
1455 node `(gnus)Picons' for details."
1457 :group 'gnus-article-treat
1459 :link '(custom-manual "(gnus)Customizing Articles")
1460 :link '(custom-manual "(gnus)Picons")
1461 :type gnus-article-treat-head-custom)
1462 (put 'gnus-treat-mail-picon 'highlight t)
1464 (defcustom gnus-treat-newsgroups-picon
1465 (if (and (gnus-image-type-available-p 'xpm)
1466 (gnus-picons-installed-p))
1468 "Display picons in the Newsgroups and Followup-To headers.
1469 Valid values are nil, t, `head', `first', `last', an integer or a
1470 predicate. See Info node `(gnus)Customizing Articles' and Info
1471 node `(gnus)Picons' for details."
1473 :group 'gnus-article-treat
1475 :link '(custom-manual "(gnus)Customizing Articles")
1476 :link '(custom-manual "(gnus)Picons")
1477 :type gnus-article-treat-head-custom)
1478 (put 'gnus-treat-newsgroups-picon 'highlight t)
1480 (defcustom gnus-treat-body-boundary
1481 (if (and (eq window-system 'x)
1482 (or gnus-treat-newsgroups-picon
1483 gnus-treat-mail-picon
1484 gnus-treat-from-picon))
1486 "Draw a boundary at the end of the headers.
1487 Valid values are nil and `head'.
1488 See Info node `(gnus)Customizing Articles' for details."
1490 :group 'gnus-article-treat
1491 :link '(custom-manual "(gnus)Customizing Articles")
1492 :type gnus-article-treat-head-custom)
1494 (defcustom gnus-treat-capitalize-sentences nil
1495 "Capitalize sentence-starting words.
1496 Valid values are nil, t, `head', `first', `last', an integer or a
1497 predicate. See Info node `(gnus)Customizing Articles'."
1499 :group 'gnus-article-treat
1500 :link '(custom-manual "(gnus)Customizing Articles")
1501 :type gnus-article-treat-custom)
1503 (defcustom gnus-treat-wash-html nil
1505 Valid values are nil, t, `head', `first', `last', an integer or a
1506 predicate. See Info node `(gnus)Customizing Articles'."
1508 :group 'gnus-article-treat
1509 :link '(custom-manual "(gnus)Customizing Articles")
1510 :type gnus-article-treat-custom)
1512 (defcustom gnus-treat-fill-long-lines nil
1514 Valid values are nil, t, `head', `first', `last', an integer or a
1515 predicate. See Info node `(gnus)Customizing Articles'."
1516 :group 'gnus-article-treat
1517 :link '(custom-manual "(gnus)Customizing Articles")
1518 :type gnus-article-treat-custom)
1520 (defcustom gnus-treat-play-sounds nil
1522 Valid values are nil, t, `head', `first', `last', an integer or a
1523 predicate. See Info node `(gnus)Customizing Articles'."
1525 :group 'gnus-article-treat
1526 :link '(custom-manual "(gnus)Customizing Articles")
1527 :type gnus-article-treat-custom)
1529 (defcustom gnus-treat-decode-article-as-default-mime-charset nil
1530 "Decode an article as `default-mime-charset'. For instance, if you want to
1531 attempt to decode an article even if the value of `gnus-show-mime' is nil,
1532 you could set this variable to something like: nil for don't decode, t for
1533 decode the body, '(or header t) for the whole article, etc."
1534 :group 'gnus-article-treat
1535 :type '(radio (const :tag "Off" nil)
1536 (const :tag "Decode body" t)
1537 (const :tag "Decode all" (or head t))))
1539 (defcustom gnus-treat-translate nil
1540 "Translate articles from one language to another.
1541 Valid values are nil, t, `head', `first', `last', an integer or a
1542 predicate. See Info node `(gnus)Customizing Articles'."
1544 :group 'gnus-article-treat
1545 :link '(custom-manual "(gnus)Customizing Articles")
1546 :type gnus-article-treat-custom)
1548 (defcustom gnus-treat-x-pgp-sig nil
1550 To automatically treat X-PGP-Sig, set it to head.
1551 Valid values are nil, t, `head', `first', `last', an integer or a
1552 predicate. See Info node `(gnus)Customizing Articles'."
1554 :group 'gnus-article-treat
1555 :group 'mime-security
1556 :type gnus-article-treat-custom)
1558 (defcustom gnus-treat-monafy nil
1559 "Display body part with mona font.
1560 Valid values are nil, t, `head', `last', an integer or a predicate.
1561 See Info node `(gnus)Customizing Articles' for details."
1562 :group 'gnus-article-treat
1563 :group 'mime-security
1564 :link '(custom-manual "(gnus)Customizing Articles")
1565 :type gnus-article-treat-custom)
1567 (defvar gnus-article-encrypt-protocol-alist
1568 '(("PGP" . mml2015-self-encrypt)))
1570 ;; Set to nil if more than one protocol added to
1571 ;; gnus-article-encrypt-protocol-alist.
1572 (defcustom gnus-article-encrypt-protocol "PGP"
1573 "The protocol used for encrypt articles.
1574 It is a string, such as \"PGP\". If nil, ask user."
1577 :group 'mime-security)
1579 (defvar gnus-article-wash-function nil
1580 "Function used for converting HTML into text.")
1582 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1583 (mm-coding-system-p 'utf-8)
1584 (executable-find idna-program))
1585 "Whether IDNA decoding of headers is used when viewing messages.
1586 This requires GNU Libidn, and by default only enabled if it is found."
1588 :group 'gnus-article-headers
1591 (defcustom gnus-article-over-scroll nil
1592 "If non-nil, allow scrolling the article buffer even when there no more text."
1594 :group 'gnus-article
1597 ;;; Internal variables
1599 (defvar gnus-english-month-names
1600 '("January" "February" "March" "April" "May" "June" "July" "August"
1601 "September" "October" "November" "December"))
1603 (defvar gnus-button-regexp nil)
1604 (defvar gnus-button-marker-list nil)
1605 ;; Regexp matching any of the regexps from `gnus-button-alist'.
1607 (defvar gnus-button-last nil)
1608 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
1610 (defvar article-goto-body-goes-to-point-min-p nil)
1611 (defvar gnus-article-wash-types nil)
1612 (defvar gnus-article-emphasis-alist nil)
1613 (defvar gnus-article-image-alist nil)
1615 (defvar gnus-article-mime-handle-alist-1 nil)
1616 (defvar gnus-treatment-function-alist
1617 '((gnus-treat-decode-article-as-default-mime-charset
1618 gnus-article-decode-article-as-default-mime-charset)
1619 (gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1620 (gnus-treat-monafy gnus-article-monafy)
1621 (gnus-treat-strip-banner gnus-article-strip-banner)
1622 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1623 (gnus-treat-buttonize gnus-article-add-buttons)
1624 (gnus-treat-fill-article gnus-article-fill-cited-article)
1625 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1626 (gnus-treat-strip-cr gnus-article-remove-cr)
1627 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1628 (gnus-treat-date-ut gnus-article-date-ut)
1629 (gnus-treat-date-local gnus-article-date-local)
1630 (gnus-treat-date-english gnus-article-date-english)
1631 (gnus-treat-date-original gnus-article-date-original)
1632 (gnus-treat-date-user-defined gnus-article-date-user)
1633 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1634 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1635 (gnus-treat-display-face gnus-article-display-face)
1636 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1637 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1638 (gnus-treat-hide-signature gnus-article-hide-signature)
1639 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1640 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1641 (gnus-treat-strip-pem gnus-article-hide-pem)
1642 (gnus-treat-from-picon gnus-treat-from-picon)
1643 (gnus-treat-mail-picon gnus-treat-mail-picon)
1644 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1645 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1646 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1647 (gnus-treat-strip-trailing-blank-lines
1648 gnus-article-remove-trailing-blank-lines)
1649 (gnus-treat-strip-leading-blank-lines
1650 gnus-article-strip-leading-blank-lines)
1651 (gnus-treat-strip-multiple-blank-lines
1652 gnus-article-strip-multiple-blank-lines)
1653 (gnus-treat-overstrike gnus-article-treat-overstrike)
1654 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences)
1655 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1656 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1657 ;; Displaying X-Face should be done after unfolding headers
1658 ;; to protect bitmap lines.
1659 (gnus-treat-display-x-face gnus-article-display-x-face)
1660 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1661 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1662 (gnus-treat-display-smileys gnus-treat-smiley)
1663 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1664 (gnus-treat-wash-html gnus-article-wash-html)
1665 (gnus-treat-emphasize gnus-article-emphasize)
1666 (gnus-treat-hide-citation gnus-article-hide-citation)
1667 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1668 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1669 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1670 (gnus-treat-play-sounds gnus-earcon-display)))
1672 (defvar gnus-article-mime-handle-alist nil)
1673 (defvar article-lapsed-timer nil)
1674 (defvar gnus-article-current-summary nil)
1676 (defvar gnus-article-mode-syntax-table
1677 (let ((table (copy-syntax-table text-mode-syntax-table)))
1678 ;; This causes the citation match run O(2^n).
1679 ;; (modify-syntax-entry ?- "w" table)
1680 (modify-syntax-entry ?> ")<" table)
1681 (modify-syntax-entry ?< "(>" table)
1682 ;; make M-. in article buffers work for `foo' strings
1683 (modify-syntax-entry ?' " " table)
1684 (modify-syntax-entry ?` " " table)
1686 "Syntax table used in article mode buffers.
1687 Initialized from `text-mode-syntax-table.")
1689 (defvar gnus-save-article-buffer nil)
1691 (defvar gnus-article-mode-line-format-alist
1692 (nconc '((?w (gnus-article-wash-status) ?s)
1693 (?m (gnus-article-mime-part-status) ?s))
1694 gnus-summary-mode-line-format-alist))
1696 (defvar gnus-number-of-articles-to-be-saved nil)
1698 (defvar gnus-inhibit-hiding nil)
1700 (defvar gnus-article-edit-mode nil)
1702 ;;; Macros for dealing with the article buffer.
1704 (defmacro gnus-with-article-headers (&rest forms)
1706 (set-buffer gnus-article-buffer)
1708 (let ((inhibit-read-only t)
1709 (inhibit-point-motion-hooks t)
1710 (case-fold-search t))
1711 (article-narrow-to-head)
1714 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1715 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1717 (defmacro gnus-with-article-buffer (&rest forms)
1719 (set-buffer gnus-article-buffer)
1720 (let ((inhibit-read-only t))
1723 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1724 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1726 (defun gnus-article-goto-header (header)
1727 "Go to HEADER, which is a regular expression."
1728 (re-search-forward (concat "^\\(" header "\\):") nil t))
1730 (defsubst gnus-article-hide-text (b e props)
1731 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1732 (gnus-add-text-properties-when 'article-type nil b e props)
1733 (when (memq 'intangible props)
1735 (max (1- b) (point-min))
1736 b 'intangible (cddr (memq 'intangible props)))))
1738 (defsubst gnus-article-unhide-text (b e)
1739 "Remove hidden text properties from region between B and E."
1740 (remove-text-properties b e gnus-hidden-properties)
1741 (when (memq 'intangible gnus-hidden-properties)
1742 (put-text-property (max (1- b) (point-min))
1743 b 'intangible nil)))
1745 (defun gnus-article-hide-text-type (b e type)
1746 "Hide text of TYPE between B and E."
1747 (gnus-add-wash-type type)
1748 (gnus-article-hide-text
1749 b e (cons 'article-type (cons type gnus-hidden-properties))))
1751 (defun gnus-article-unhide-text-type (b e type)
1752 "Unhide text of TYPE between B and E."
1753 (gnus-delete-wash-type type)
1754 (remove-text-properties
1755 b e (cons 'article-type (cons type gnus-hidden-properties)))
1756 (when (memq 'intangible gnus-hidden-properties)
1757 (put-text-property (max (1- b) (point-min))
1758 b 'intangible nil)))
1760 (defun gnus-article-hide-text-of-type (type)
1761 "Hide text of TYPE in the current buffer."
1763 (let ((b (point-min))
1765 (while (setq b (text-property-any b e 'article-type type))
1766 (add-text-properties b (incf b) gnus-hidden-properties)))))
1768 (defun gnus-article-delete-text-of-type (type)
1769 "Delete text of TYPE in the current buffer."
1771 (let ((b (point-min)))
1772 (if (eq type 'multipart)
1773 ;; Remove MIME buttons associated with multipart/alternative parts.
1776 (while (if (get-text-property (point) 'gnus-part)
1778 (when (setq b (next-single-property-change (point)
1783 (skip-chars-forward "\n")
1784 (when (eq (get-text-property b 'article-type) 'multipart)
1785 (delete-region b (point)))))
1786 (while (setq b (text-property-any b (point-max) 'article-type type))
1788 b (or (text-property-not-all b (point-max) 'article-type type)
1791 (defun gnus-article-delete-invisible-text ()
1792 "Delete all invisible text in the current buffer."
1794 (let ((b (point-min)))
1795 (while (setq b (text-property-any b (point-max) 'invisible t))
1797 b (or (text-property-not-all b (point-max) 'invisible t)
1800 (defun gnus-article-text-type-exists-p (type)
1801 "Say whether any text of type TYPE exists in the buffer."
1802 (text-property-any (point-min) (point-max) 'article-type type))
1804 (defsubst gnus-article-header-rank ()
1805 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1806 (let ((list gnus-sorted-header-list)
1809 (if (looking-at (car list))
1811 (setq list (cdr list))
1815 (defun article-hide-headers (&optional arg delete)
1816 "Hide unwanted headers and possibly sort them as well."
1817 (interactive (gnus-article-hidden-arg))
1818 ;; Lars said that this function might be inhibited.
1819 (if (gnus-article-check-hidden-text 'headers arg)
1821 ;; Show boring headers as well.
1822 (gnus-article-show-hidden-text 'boring-headers)
1823 (when (eq 1 (point-min))
1824 (set-window-start (get-buffer-window (current-buffer)) 1)))
1825 (unless gnus-inhibit-hiding
1826 (let ((inhibit-read-only t)
1827 (case-fold-search t)
1828 (max (1+ (length gnus-sorted-header-list)))
1829 (inhibit-point-motion-hooks t)
1830 (cur (current-buffer))
1831 ignored visible beg)
1833 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1834 ;; group parameters, so we should go to the summary buffer.
1837 (progn (set-buffer gnus-summary-buffer) t)
1839 (setq ignored (when (not gnus-visible-headers)
1840 (cond ((stringp gnus-ignored-headers)
1841 gnus-ignored-headers)
1842 ((listp gnus-ignored-headers)
1843 (mapconcat 'identity
1844 gnus-ignored-headers
1846 visible (cond ((stringp gnus-visible-headers)
1847 gnus-visible-headers)
1848 ((and gnus-visible-headers
1849 (listp gnus-visible-headers))
1850 (mapconcat 'identity
1851 gnus-visible-headers
1855 ;; First we narrow to just the headers.
1856 (article-narrow-to-head)
1857 ;; Hide any "From " lines at the beginning of (mail) articles.
1858 (while (looking-at "From ")
1862 (delete-region (point-min) (point))
1863 (gnus-article-hide-text (point-min) (point)
1864 (nconc (list 'article-type 'headers)
1865 gnus-hidden-properties))))
1866 ;; Then treat the rest of the header lines.
1867 ;; Then we use the two regular expressions
1868 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1869 ;; select which header lines is to remain visible in the
1871 (while (re-search-forward "^[^ \t:]*:" nil t)
1873 ;; Mark the rank of the header.
1875 (point) (1+ (point)) 'message-rank
1876 (if (or (and visible (looking-at visible))
1878 (not (looking-at ignored))))
1879 (gnus-article-header-rank)
1882 (message-sort-headers-1)
1883 (when (setq beg (text-property-any
1884 (point-min) (point-max) 'message-rank (+ 2 max)))
1885 ;; We delete or make invisible the unwanted headers.
1886 (gnus-add-wash-type 'headers)
1889 (add-text-properties
1890 (point-min) (+ 5 (point-min))
1891 '(article-type headers dummy-invisible t))
1892 (delete-region beg (point-max)))
1893 (gnus-article-hide-text-type beg (point-max) 'headers)))))))))
1895 (defun article-hide-boring-headers (&optional arg)
1896 "Toggle hiding of headers that aren't very interesting.
1897 If given a negative prefix, always show; if given a positive prefix,
1899 (interactive (gnus-article-hidden-arg))
1900 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1901 (not gnus-show-all-headers))
1904 (let ((inhibit-read-only t)
1905 (inhibit-point-motion-hooks t))
1906 (article-narrow-to-head)
1907 (dolist (elem gnus-boring-article-headers)
1908 (goto-char (point-min))
1910 ;; Hide empty headers.
1912 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1914 (gnus-article-hide-text-type
1918 (if (re-search-forward "^[^ \t]" nil t)
1922 ;; Hide boring Newsgroups header.
1923 ((eq elem 'newsgroups)
1924 (when (gnus-string-equal
1925 (gnus-fetch-field "newsgroups")
1926 (gnus-group-real-name
1927 (if (boundp 'gnus-newsgroup-name)
1930 (gnus-article-hide-header "newsgroups")))
1931 ((eq elem 'to-address)
1932 (let ((to (message-fetch-field "to"))
1934 (gnus-parameter-to-address
1935 (if (boundp 'gnus-newsgroup-name)
1936 gnus-newsgroup-name ""))))
1937 (when (and to to-address
1940 ;; only one address in To
1941 (nth 1 (mail-extract-address-components to))
1943 (gnus-article-hide-header "to"))))
1945 (let ((to (message-fetch-field "to"))
1947 (gnus-parameter-to-list
1948 (if (boundp 'gnus-newsgroup-name)
1949 gnus-newsgroup-name ""))))
1950 (when (and to to-list
1953 ;; only one address in To
1954 (nth 1 (mail-extract-address-components to))
1956 (gnus-article-hide-header "to"))))
1958 (let ((cc (message-fetch-field "cc"))
1960 (gnus-parameter-to-list
1961 (if (boundp 'gnus-newsgroup-name)
1962 gnus-newsgroup-name ""))))
1963 (when (and cc to-list
1966 ;; only one address in CC
1967 (nth 1 (mail-extract-address-components cc))
1969 (gnus-article-hide-header "cc"))))
1970 ((eq elem 'followup-to)
1971 (when (gnus-string-equal
1972 (message-fetch-field "followup-to")
1973 (message-fetch-field "newsgroups"))
1974 (gnus-article-hide-header "followup-to")))
1975 ((eq elem 'reply-to)
1976 (if (gnus-group-find-parameter
1977 gnus-newsgroup-name 'broken-reply-to)
1978 (gnus-article-hide-header "reply-to")
1979 (let ((from (message-fetch-field "from"))
1980 (reply-to (message-fetch-field "reply-to")))
1987 (lambda (x) (downcase (cadr x)))
1988 (mail-extract-address-components from t))
1991 (lambda (x) (downcase (cadr x)))
1992 (mail-extract-address-components reply-to t))
1994 (gnus-article-hide-header "reply-to")))))
1996 (let ((date (message-fetch-field "date")))
1998 (< (days-between (current-time-string) date)
2000 (gnus-article-hide-header "date"))))
2002 (let ((to (message-fetch-field "to"))
2003 (cc (message-fetch-field "cc")))
2004 (when (> (length to) 1024)
2005 (gnus-article-hide-header "to"))
2006 (when (> (length cc) 1024)
2007 (gnus-article-hide-header "cc"))))
2011 (goto-char (point-min))
2012 (while (re-search-forward "^to:" nil t)
2013 (setq to-count (1+ to-count)))
2014 (when (> to-count 1)
2015 (while (> to-count 0)
2016 (goto-char (point-min))
2018 (re-search-forward "^to:" nil nil to-count)
2020 (narrow-to-region (point) (point-max))
2021 (gnus-article-hide-header "to"))
2022 (setq to-count (1- to-count))))
2023 (goto-char (point-min))
2024 (while (re-search-forward "^cc:" nil t)
2025 (setq cc-count (1+ cc-count)))
2026 (when (> cc-count 1)
2027 (while (> cc-count 0)
2028 (goto-char (point-min))
2030 (re-search-forward "^cc:" nil nil cc-count)
2032 (narrow-to-region (point) (point-max))
2033 (gnus-article-hide-header "cc"))
2034 (setq cc-count (1- cc-count)))))))))))))
2036 (defun gnus-article-hide-header (header)
2038 (goto-char (point-min))
2039 (when (re-search-forward (concat "^" header ":") nil t)
2040 (gnus-article-hide-text-type
2044 (if (re-search-forward "^[^ \t]" nil t)
2049 (defvar gnus-article-normalized-header-length 40
2050 "Length of normalized headers.")
2052 (defun article-normalize-headers ()
2053 "Make all header lines 40 characters long."
2055 (let ((inhibit-read-only t)
2059 (article-narrow-to-head)
2062 ((< (setq column (- (point-at-eol) (point)))
2063 gnus-article-normalized-header-length)
2065 (insert (make-string
2066 (- gnus-article-normalized-header-length column)
2068 ((> column gnus-article-normalized-header-length)
2069 (gnus-put-text-property
2071 (forward-char gnus-article-normalized-header-length)
2078 (forward-line 1))))))
2080 (defun article-treat-dumbquotes ()
2081 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
2082 Note that this function guesses whether a character is a sm*rtq**t* or
2083 not, so it should only be used interactively.
2085 Sm*rtq**t*s are M****s***'s unilateral extension to the
2086 iso-8859-1 character map in an attempt to provide more quoting
2087 characters. If you see something like \\222 or \\264 where
2088 you're expecting some kind of apostrophe or quotation mark, then
2091 (article-translate-strings gnus-article-dumbquotes-map))
2093 (defun article-translate-characters (from to)
2094 "Translate all characters in the body of the article according to FROM and TO.
2095 FROM is a string of characters to translate from; to is a string of
2096 characters to translate to."
2098 (when (article-goto-body)
2099 (let ((inhibit-read-only t)
2100 (x (make-string 225 ?x))
2102 (while (< (incf i) (length x))
2105 (while (< i (length from))
2106 (aset x (aref from i) (aref to i))
2108 (translate-region (point) (point-max) x)))))
2110 (defun article-translate-strings (map)
2111 "Translate all string in the body of the article according to MAP.
2112 MAP is an alist where the elements are on the form (\"from\" \"to\")."
2114 (when (article-goto-body)
2115 (let ((inhibit-read-only t))
2118 (while (search-forward (car elem) nil t)
2119 (replace-match (cadr elem)))))))))
2121 (defun article-treat-overstrike ()
2122 "Translate overstrikes into bold text."
2125 (when (article-goto-body)
2126 (let ((inhibit-read-only t))
2127 (while (search-forward "\b" nil t)
2128 (let ((next (char-after))
2132 previous (char-after))
2136 ;; We do the boldification/underlining by hiding the
2137 ;; overstrikes and putting the proper text property
2141 (gnus-article-hide-text-type start (point) 'overstrike)
2142 (put-text-property (point) end 'face 'bold))
2144 (gnus-article-hide-text-type
2145 (1- (point)) (1+ (point)) 'overstrike)
2147 start (1- (point)) 'face 'underline))
2149 (gnus-article-hide-text-type start (point) 'overstrike)
2151 (point) end 'face 'underline)))))))))
2153 (defun article-treat-ansi-sequences ()
2154 "Translate ANSI SGR control sequences into overlays or extents."
2157 (when (article-goto-body)
2158 (let ((inhibit-read-only t))
2159 (ansi-color-apply-on-region (point) (point-max))))))
2161 (defun gnus-article-treat-unfold-headers ()
2162 "Unfold folded message headers.
2163 Only the headers that fit into the current window width will be
2166 (gnus-with-article-headers
2170 (mail-header-narrow-to-field)
2171 (let ((header (buffer-string)))
2174 (goto-char (point-min))
2175 (while (re-search-forward "\n[\t ]" nil t)
2176 (replace-match " " t t)))
2177 (setq length (- (point-max) (point-min) 1)))
2178 (when (< length (window-width))
2179 (while (re-search-forward "\n[\t ]" nil t)
2180 (replace-match " " t t)))
2181 (goto-char (point-max)))))))
2183 (defun gnus-article-treat-fold-headers ()
2184 "Fold message headers."
2186 (gnus-with-article-headers
2189 (mail-header-narrow-to-field)
2190 (mail-header-fold-field)
2191 (goto-char (point-max))))))
2193 (defun gnus-treat-smiley ()
2194 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2196 (unless (featurep 'xemacs)
2197 (when (and (not gnus-article-should-use-smiley-mule)
2198 gnus-article-smiley-mule-loaded-p)
2199 (load "smiley" nil t)
2200 (setq gnus-article-smiley-mule-loaded-p nil))
2201 (when (and gnus-article-should-use-smiley-mule
2202 (not gnus-article-smiley-mule-loaded-p))
2203 (load "smiley-mule" nil t)
2204 (setq gnus-article-smiley-mule-loaded-p t)))
2205 (gnus-with-article-buffer
2206 (if (memq 'smiley gnus-article-wash-types)
2207 (gnus-delete-images 'smiley)
2209 (let ((images (smiley-region (point) (point-max))))
2211 (gnus-add-wash-type 'smiley)
2212 (dolist (image images)
2213 (gnus-add-image 'smiley image)))))))
2215 (defun gnus-article-remove-images ()
2216 "Remove all images from the article buffer."
2218 (gnus-with-article-buffer
2219 (dolist (elem gnus-article-image-alist)
2220 (gnus-delete-images (car elem)))))
2222 (defun gnus-article-treat-fold-newsgroups ()
2223 "Unfold folded message headers.
2224 Only the headers that fit into the current window width will be
2227 (gnus-with-article-headers
2228 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2230 (mail-header-narrow-to-field)
2231 (while (re-search-forward ", *" nil t)
2232 (replace-match ", " t t))
2233 (mail-header-fold-field)
2234 (goto-char (point-max))))))
2236 (defun gnus-article-treat-body-boundary ()
2237 "Place a boundary line at the end of the headers."
2239 (when (and gnus-body-boundary-delimiter
2240 (> (length gnus-body-boundary-delimiter) 0))
2241 (gnus-with-article-headers
2242 (goto-char (point-max))
2243 (let ((start (point)))
2244 (insert "X-Boundary: ")
2245 (gnus-add-text-properties start (point) '(invisible t intangible t))
2247 (while (>= (1- (window-width)) (length str))
2248 (setq str (concat str gnus-body-boundary-delimiter)))
2249 (substring str 0 (1- (window-width))))
2251 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2253 (defun article-fill-long-lines ()
2254 "Fill lines that are wider than the window width."
2257 (let ((inhibit-read-only t)
2258 (width (window-width (get-buffer-window (current-buffer)))))
2261 (let ((adaptive-fill-mode nil)) ;Why? -sm
2264 (when (>= (current-column) (min fill-column width))
2265 (narrow-to-region (min (1+ (point)) (point-max))
2267 (let ((goback (point-marker)))
2268 (fill-paragraph nil)
2269 (goto-char (marker-position goback)))
2271 (forward-line 1)))))))
2273 (defun article-capitalize-sentences ()
2274 "Capitalize the first word in each sentence."
2277 (let ((inhibit-read-only t)
2278 (paragraph-start "^[\n\^L]"))
2282 (forward-sentence)))))
2284 (defun article-remove-cr ()
2285 "Remove trailing CRs and then translate remaining CRs into LFs."
2288 (let ((inhibit-read-only t))
2289 (goto-char (point-min))
2290 (while (re-search-forward "\r+$" nil t)
2291 (replace-match "" t t))
2292 (goto-char (point-min))
2293 (while (search-forward "\r" nil t)
2294 (replace-match "\n" t t)))))
2296 (defun article-remove-trailing-blank-lines ()
2297 "Remove all trailing blank lines from the article."
2300 (let ((inhibit-read-only t))
2301 (goto-char (point-max))
2305 (while (and (not (bobp))
2306 (looking-at "^[ \t]*$")
2307 (not (gnus-annotation-in-region-p
2308 (point) (point-at-eol))))
2314 (defvar gnus-face-properties-alist))
2316 (defun article-display-face ()
2317 "Display any Face headers in the header."
2319 (let ((wash-face-p buffer-read-only))
2320 (gnus-with-article-headers
2321 ;; When displaying parts, this function can be called several times on
2322 ;; the same article, without any intended toggle semantic (as typing `W
2323 ;; D d' would have). So face deletion must occur only when we come from
2324 ;; an interactive command, that is when the *Article* buffer is
2326 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2327 (gnus-delete-images 'face)
2328 (let (face faces from)
2329 (save-current-buffer
2330 (when (and wash-face-p
2331 (gnus-buffer-live-p gnus-original-article-buffer)
2332 (not (re-search-forward "^Face:[\t ]*" nil t)))
2333 (set-buffer gnus-original-article-buffer))
2335 (mail-narrow-to-head)
2336 (while (gnus-article-goto-header "Face")
2337 (push (mail-header-field-value) faces))))
2339 (goto-char (point-min))
2340 (let ((from (gnus-article-goto-header "from"))
2345 (insert "[no `from' set]\n"))
2347 (when (setq png (gnus-convert-face-to-png (pop faces)))
2349 (apply 'gnus-create-image png 'png t
2350 (cdr (assq 'png gnus-face-properties-alist))))
2352 (gnus-add-wash-type 'face)
2353 (gnus-add-image 'face image)
2354 (gnus-put-image image nil 'face))))))))))
2356 (defun article-display-x-face (&optional force)
2357 "Look for an X-Face header and display it if present."
2358 (interactive (list 'force))
2359 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2360 (gnus-with-article-headers
2361 ;; Delete the old process, if any.
2362 (when (process-status "article-x-face")
2363 (delete-process "article-x-face"))
2364 ;; See the comment in `article-display-face'.
2365 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2366 ;; We have already displayed X-Faces, so we remove them
2368 (gnus-delete-images 'xface)
2370 (let (x-faces from face)
2371 (save-current-buffer
2372 (when (and wash-face-p
2373 (gnus-buffer-live-p gnus-original-article-buffer)
2374 (not (re-search-forward "^X-Face:[\t ]*" nil t)))
2375 ;; If type `W f', use gnus-original-article-buffer,
2376 ;; otherwise use the current buffer because displaying
2377 ;; RFC822 parts calls this function too.
2378 (set-buffer gnus-original-article-buffer))
2380 (mail-narrow-to-head)
2381 (while (gnus-article-goto-header "X-Face")
2382 (push (mail-header-field-value) x-faces))
2383 (setq from (message-fetch-field "from"))))
2384 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2385 ;; single external face.
2386 (when (stringp gnus-article-x-face-command)
2387 (setq x-faces (list (car x-faces))))
2389 gnus-article-x-face-command
2391 ;; Check whether this face is censored.
2392 (not gnus-article-x-face-too-ugly)
2394 (not (string-match gnus-article-x-face-too-ugly
2396 (while (setq face (pop x-faces))
2397 ;; We display the face.
2398 (cond ((stringp gnus-article-x-face-command)
2399 ;; The command is a string, so we interpret the command
2400 ;; as a, well, command, and fork it off.
2401 (let ((process-connection-type nil))
2402 (gnus-set-process-query-on-exit-flag
2404 "article-x-face" nil shell-file-name
2405 shell-command-switch gnus-article-x-face-command)
2409 (process-send-region "article-x-face"
2410 (point-min) (point-max)))
2411 (process-send-eof "article-x-face")))
2412 ((functionp gnus-article-x-face-command)
2413 ;; The command is a lisp function, so we call it.
2414 (funcall gnus-article-x-face-command face))
2416 (error "%s is not a function"
2417 gnus-article-x-face-command))))))))))
2419 (defun article-decode-mime-words ()
2420 "Decode all MIME-encoded words in the article."
2422 (gnus-with-article-buffer
2423 (let ((inhibit-point-motion-hooks t)
2424 (mail-parse-charset gnus-newsgroup-charset)
2425 (mail-parse-ignored-charsets
2426 (with-current-buffer gnus-summary-buffer
2427 gnus-newsgroup-ignored-charsets)))
2428 (mail-decode-encoded-word-region (point-min) (point-max)))))
2430 (defun article-decode-charset (&optional prompt)
2431 "Decode charset-encoded text in the article.
2432 If PROMPT (the prefix), prompt for a coding system to use."
2434 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2435 (inhibit-read-only t)
2436 (mail-parse-charset gnus-newsgroup-charset)
2437 (mail-parse-ignored-charsets
2438 (save-excursion (condition-case nil
2439 (set-buffer gnus-summary-buffer)
2441 gnus-newsgroup-ignored-charsets))
2442 ct cte ctl charset format)
2445 (article-narrow-to-head)
2446 (setq ct (message-fetch-field "Content-Type" t)
2447 cte (message-fetch-field "Content-Transfer-Encoding" t)
2448 ctl (and ct (ignore-errors
2449 (mail-header-parse-content-type ct)))
2452 (mm-read-coding-system "Charset to decode: "))
2454 (mail-content-type-get ctl 'charset)))
2455 format (and ctl (mail-content-type-get ctl 'format)))
2457 (setq cte (mail-header-strip cte)))
2458 (if (and ctl (not (string-match "/" (car ctl))))
2460 (goto-char (point-max)))
2463 (narrow-to-region (point) (point-max))
2464 (when (and (eq mail-parse-charset 'gnus-decoded)
2465 (eq (mm-body-7-or-8) '8bit))
2466 ;; The text code could have been decoded.
2467 (setq charset mail-parse-charset))
2468 (when (and (or (not ctl)
2469 (equal (car ctl) "text/plain"))
2470 (not format)) ;; article with format will decode later.
2472 charset (and cte (intern (downcase
2473 (gnus-strip-whitespace cte))))
2476 (defun article-decode-encoded-words ()
2477 "Remove encoded-word encoding from headers."
2478 (let ((charset (save-excursion
2479 (set-buffer gnus-summary-buffer)
2480 default-mime-charset))
2481 (inhibit-read-only t))
2482 (mime-decode-header-in-buffer charset)))
2484 (defun article-decode-group-name ()
2485 "Decode group names in `Newsgroups:'."
2486 (let ((inhibit-point-motion-hooks t)
2487 (inhibit-read-only t)
2488 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2489 (when (and (or gnus-group-name-charset-method-alist
2490 gnus-group-name-charset-group-alist)
2491 (gnus-buffer-live-p gnus-original-article-buffer))
2493 (article-narrow-to-head)
2494 (with-current-buffer gnus-original-article-buffer
2495 (goto-char (point-min)))
2496 (while (re-search-forward
2497 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2498 (replace-match (save-match-data
2499 (gnus-decode-newsgroups
2500 ;; XXX how to use data in article buffer?
2501 (with-current-buffer gnus-original-article-buffer
2503 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2506 gnus-newsgroup-name method))
2508 (goto-char (point-min))
2509 (with-current-buffer gnus-original-article-buffer
2510 (goto-char (point-min)))
2511 (while (re-search-forward
2512 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2513 (replace-match (save-match-data
2514 (gnus-decode-newsgroups
2515 ;; XXX how to use data in article buffer?
2516 (with-current-buffer gnus-original-article-buffer
2518 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2521 gnus-newsgroup-name method))
2524 (autoload 'idna-to-unicode "idna")
2526 (defun article-decode-idna-rhs ()
2527 "Decode IDNA strings in RHS in various headers in current buffer.
2528 The following headers are decoded: From:, To:, Cc:, Reply-To:,
2529 Mail-Reply-To: and Mail-Followup-To:."
2532 (let ((inhibit-point-motion-hooks t)
2533 (inhibit-read-only t))
2534 (article-narrow-to-head)
2535 (goto-char (point-min))
2536 (while (re-search-forward "@[^ \t\n\r,>]*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2538 (when (save-match-data
2539 (and (setq ace (match-string 1))
2541 (and (re-search-backward "^[^ \t]" nil t)
2542 (looking-at "From\\|To\\|Cc\\|Reply-To\\|Mail-Reply-To\\|Mail-Followup-To")))
2543 (setq unicode (idna-to-unicode ace))))
2544 (unless (string= ace unicode)
2545 (replace-match unicode nil nil nil 1)))))))))
2547 (defun article-de-quoted-unreadable (&optional force read-charset)
2548 "Translate a quoted-printable-encoded article.
2549 If FORCE, decode the article whether it is marked as quoted-printable
2551 If READ-CHARSET, ask for a coding system."
2552 (interactive (list 'force current-prefix-arg))
2554 (let ((inhibit-read-only t) type charset)
2555 (if (gnus-buffer-live-p gnus-original-article-buffer)
2556 (with-current-buffer gnus-original-article-buffer
2558 (gnus-fetch-field "content-transfer-encoding"))
2559 (let* ((ct (gnus-fetch-field "content-type"))
2562 (mail-header-parse-content-type ct)))))
2563 (setq charset (and ctl
2564 (mail-content-type-get ctl 'charset)))
2565 (if (stringp charset)
2566 (setq charset (intern (downcase charset)))))))
2568 (setq charset (mm-read-coding-system "Charset: " charset)))
2570 (setq charset gnus-newsgroup-charset))
2572 (and type (let ((case-fold-search t))
2573 (string-match "quoted-printable" type))))
2575 (quoted-printable-decode-region
2576 (point) (point-max) (mm-charset-to-coding-system charset))))))
2578 (defun article-de-base64-unreadable (&optional force read-charset)
2579 "Translate a base64 article.
2580 If FORCE, decode the article whether it is marked as base64 not.
2581 If READ-CHARSET, ask for a coding system."
2582 (interactive (list 'force current-prefix-arg))
2584 (let ((inhibit-read-only t) type charset)
2585 (if (gnus-buffer-live-p gnus-original-article-buffer)
2586 (with-current-buffer gnus-original-article-buffer
2588 (gnus-fetch-field "content-transfer-encoding"))
2589 (let* ((ct (gnus-fetch-field "content-type"))
2592 (mail-header-parse-content-type ct)))))
2593 (setq charset (and ctl
2594 (mail-content-type-get ctl 'charset)))
2595 (if (stringp charset)
2596 (setq charset (intern (downcase charset)))))))
2598 (setq charset (mm-read-coding-system "Charset: " charset)))
2600 (setq charset gnus-newsgroup-charset))
2602 (and type (let ((case-fold-search t))
2603 (string-match "base64" type))))
2606 (narrow-to-region (point) (point-max))
2607 (base64-decode-region (point-min) (point-max))
2608 (mm-decode-coding-region
2609 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2614 (defun article-decode-HZ ()
2615 "Translate a HZ-encoded article."
2619 (let ((inhibit-read-only t))
2620 (rfc1843-decode-region (point-min) (point-max)))))
2622 (defun article-unsplit-urls ()
2623 "Remove the newlines that some other mailers insert into URLs."
2626 (let ((inhibit-read-only t))
2627 (goto-char (point-min))
2628 (while (re-search-forward
2629 "\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2630 (replace-match "\\1\\3" t)))
2631 (when (interactive-p)
2632 (gnus-treat-article nil))))
2635 (defun article-wash-html (&optional read-charset)
2636 "Format an HTML article.
2637 If READ-CHARSET, ask for a coding system. If it is a number, the
2638 charset defined in `gnus-summary-show-article-charset-alist' is used."
2641 (let ((inhibit-read-only t)
2644 (if (or (and (numberp read-charset)
2648 gnus-summary-show-article-charset-alist))))
2649 (setq charset (mm-read-coding-system "Charset: ")))
2650 (let ((gnus-summary-show-article-charset-alist
2651 (list (cons 1 charset))))
2652 (with-current-buffer gnus-summary-buffer
2653 (gnus-summary-show-article 1)))
2654 (error "No charset is given"))
2655 (when (gnus-buffer-live-p gnus-original-article-buffer)
2656 (with-current-buffer gnus-original-article-buffer
2657 (let* ((ct (gnus-fetch-field "content-type"))
2660 (mail-header-parse-content-type ct)))))
2661 (setq charset (and ctl
2662 (mail-content-type-get ctl 'charset)))
2663 (when (stringp charset)
2664 (setq charset (intern (downcase charset)))))))
2666 (setq charset gnus-newsgroup-charset)))
2668 (save-window-excursion
2670 (narrow-to-region (point) (point-max))
2671 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2672 (entry (assq func mm-text-html-washer-alist)))
2674 (setq func (cdr entry)))
2679 (apply (car func) (cdr func))))))))))
2681 (defun gnus-article-wash-html-with-w3 ()
2682 "Wash the current buffer with w3."
2684 (let ((w3-strict-width (window-width))
2685 (url-standalone-mode t)
2686 (url-gateway-unplugged t)
2687 (w3-honor-stylesheets nil))
2689 (w3-region (point-min) (point-max))
2692 (defun gnus-article-wash-html-with-w3m ()
2693 "Wash the current buffer with emacs-w3m."
2695 (let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp)
2696 w3m-force-redisplay)
2697 (w3m-region (point-min) (point-max)))
2698 (when (and mm-inline-text-html-with-w3m-keymap
2699 (boundp 'w3m-minor-mode-map)
2701 (add-text-properties
2702 (point-min) (point-max)
2703 (list 'keymap w3m-minor-mode-map
2704 ;; Put the mark meaning this part was rendered by emacs-w3m.
2705 'mm-inline-text-html-with-w3m t))))
2707 (eval-when-compile (defvar charset)) ;; Bound by `article-wash-html'.
2709 (defun gnus-article-wash-html-with-w3m-standalone ()
2710 "Wash the current buffer with w3m."
2711 (if (mm-w3m-standalone-supports-m17n-p)
2713 (unless (mm-coding-system-p charset) ;; Bound by `article-wash-html'.
2715 (setq charset 'iso-8859-1))
2716 (let ((coding-system-for-write charset)
2717 (coding-system-for-read charset))
2718 (call-process-region
2719 (point-min) (point-max)
2720 "w3m" t t nil "-dump" "-T" "text/html"
2721 "-I" (symbol-name charset) "-O" (symbol-name charset))))
2722 (mm-inline-wash-with-stdin nil "w3m" "-dump" "-T" "text/html")))
2724 (defun article-hide-list-identifiers ()
2725 "Remove list identifies from the Subject header.
2726 The `gnus-list-identifiers' variable specifies what to do."
2728 (let ((inhibit-point-motion-hooks t)
2729 (regexp (if (consp gnus-list-identifiers)
2730 (mapconcat 'identity gnus-list-identifiers " *\\|")
2731 gnus-list-identifiers))
2732 (inhibit-read-only t))
2736 (article-narrow-to-head)
2737 (goto-char (point-min))
2738 (while (re-search-forward
2739 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2741 (delete-region (match-beginning 2) (match-end 0))
2742 (beginning-of-line))
2743 (when (re-search-forward
2744 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2745 (delete-region (match-beginning 1) (match-end 1))))))))
2747 (defun article-hide-pem (&optional arg)
2748 "Toggle hiding of any PEM headers and signatures in the current article.
2749 If given a negative prefix, always show; if given a positive prefix,
2751 (interactive (gnus-article-hidden-arg))
2752 (unless (gnus-article-check-hidden-text 'pem arg)
2754 (let ((inhibit-read-only t) end)
2755 (goto-char (point-min))
2756 ;; Hide the horrendously ugly "header".
2757 (when (and (search-forward
2758 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2760 (setq end (1+ (match-beginning 0))))
2761 (gnus-add-wash-type 'pem)
2762 (gnus-article-hide-text-type
2764 (if (search-forward "\n\n" nil t)
2768 ;; Hide the trailer as well
2769 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2771 (gnus-article-hide-text-type
2772 (match-beginning 0) (match-end 0) 'pem)))))))
2774 (defun article-strip-banner ()
2775 "Strip the banners specified by the `banner' group parameter and by
2776 `gnus-article-address-banner-alist'."
2780 (let ((inhibit-point-motion-hooks t))
2781 (when (gnus-parameter-banner gnus-newsgroup-name)
2782 (article-really-strip-banner
2783 (gnus-parameter-banner gnus-newsgroup-name)))
2784 (when gnus-article-address-banner-alist
2785 ;; It is necessary to encode from fields before checking,
2786 ;; because `mail-header-parse-addresses' does not work
2787 ;; (reliably) on decoded headers. And more, it is
2788 ;; impossible to use `gnus-fetch-original-field' here,
2789 ;; because `article-strip-banner' may be called in draft
2790 ;; buffers to preview them.
2791 (let ((from (save-restriction
2793 (article-narrow-to-head)
2794 (mail-fetch-field "from"))))
2797 (caar (mail-header-parse-addresses
2798 (mail-encode-encoded-word-string from)))))
2800 (dolist (pair gnus-article-address-banner-alist)
2801 (when (string-match (car pair) from)
2803 (article-really-strip-banner (cdr pair)))))))))))))
2805 (defun article-really-strip-banner (banner)
2806 "Strip the banner specified by the argument."
2809 (let ((inhibit-point-motion-hooks t)
2810 (gnus-signature-limit nil)
2811 (inhibit-read-only t))
2814 ((eq banner 'signature)
2815 (when (gnus-article-narrow-to-signature)
2818 (delete-region (point) (point-max))))
2820 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2821 (while (re-search-forward banner nil t)
2822 (delete-region (match-beginning 0) (match-end 0)))))
2824 (while (re-search-forward banner nil t)
2825 (delete-region (match-beginning 0) (match-end 0)))))))))
2827 (defun article-babel ()
2828 "Translate article using an online translation service."
2831 (gnus-with-article-buffer
2832 (when (article-goto-body)
2833 (let* ((start (point))
2835 (orig (buffer-substring start end))
2836 (trans (babel-as-string orig)))
2838 (narrow-to-region start end)
2839 (delete-region start end)
2842 (defun article-hide-signature (&optional arg)
2843 "Hide the signature in the current article.
2844 If given a negative prefix, always show; if given a positive prefix,
2846 (interactive (gnus-article-hidden-arg))
2852 (article-goto-body))
2853 (goto-char (point-min)))
2854 (unless (gnus-article-check-hidden-text 'signature arg)
2855 (let ((inhibit-read-only t)
2857 (while (setq button (text-property-any button (point-max)
2859 'gnus-signature-toggle))
2860 (setq button (text-property-not-all button (point-max)
2862 'gnus-signature-toggle))
2863 (when (and button (not (eobp)))
2864 (gnus-article-hide-text-type
2866 (next-single-property-change (1+ button) 'mime-view-entity
2869 (gnus-set-mode-line 'article))
2871 (defun article-strip-headers-in-body ()
2872 "Strip offensive headers from bodies."
2876 (let ((case-fold-search t))
2877 (when (looking-at "x-no-archive:")
2878 (gnus-delete-line)))))
2880 (defun article-strip-leading-blank-lines ()
2881 "Remove all blank lines from the beginning of the article."
2884 (let ((inhibit-point-motion-hooks t)
2885 (inhibit-read-only t))
2886 (when (article-goto-body)
2887 (while (and (not (eobp))
2888 (looking-at "[ \t]*$"))
2889 (gnus-delete-line))))))
2891 (defun article-narrow-to-head ()
2892 "Narrow the buffer to the head of the message.
2893 Point is left at the beginning of the narrowed-to region."
2895 (goto-char (point-min))
2896 (if (search-forward "\n\n" nil 1)
2899 (goto-char (point-min)))
2901 (defun article-goto-body ()
2902 "Place point at the start of the body."
2903 (goto-char (point-min))
2905 ;; This variable is only bound when dealing with separate
2907 (article-goto-body-goes-to-point-min-p
2909 ((search-forward "\n\n" nil t)
2912 (goto-char (point-max))
2915 (defun article-strip-multiple-blank-lines ()
2916 "Replace consecutive blank lines with one empty line."
2919 (let ((inhibit-point-motion-hooks t)
2920 (inhibit-read-only t))
2921 ;; First make all blank lines empty.
2923 (while (re-search-forward "^[ \t]+$" nil t)
2924 (unless (gnus-annotation-in-region-p
2925 (match-beginning 0) (match-end 0))
2926 (replace-match "" nil t)))
2927 ;; Then replace multiple empty lines with a single empty line.
2929 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2930 (unless (gnus-annotation-in-region-p
2931 (match-beginning 0) (match-end 0))
2932 (delete-region (match-beginning 1) (match-end 1)))))))
2934 (defun article-strip-leading-space ()
2935 "Remove all white space from the beginning of the lines in the article."
2938 (let ((inhibit-point-motion-hooks t)
2939 (inhibit-read-only t))
2941 (while (re-search-forward "^[ \t]+" nil t)
2942 (replace-match "" t t)))))
2944 (defun article-strip-trailing-space ()
2945 "Remove all white space from the end of the lines in the article."
2948 (let ((inhibit-point-motion-hooks t)
2949 (inhibit-read-only t))
2951 (while (re-search-forward "[ \t]+$" nil t)
2952 (replace-match "" t t)))))
2954 (defun article-strip-blank-lines ()
2955 "Strip leading, trailing and multiple blank lines."
2957 (article-strip-leading-blank-lines)
2958 (article-remove-trailing-blank-lines)
2959 (article-strip-multiple-blank-lines))
2961 (defun article-strip-all-blank-lines ()
2962 "Strip all blank lines."
2965 (let ((inhibit-point-motion-hooks t)
2966 (inhibit-read-only t))
2968 (while (re-search-forward "^[ \t]*\n" nil t)
2969 (replace-match "" t t)))))
2971 (defun gnus-article-narrow-to-signature ()
2972 "Narrow to the signature; return t if a signature is found, else nil."
2973 (let ((inhibit-point-motion-hooks t))
2974 (when (gnus-article-search-signature)
2976 ;; Check whether we have some limits to what we consider
2977 ;; to be a signature.
2978 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2979 (list gnus-signature-limit)))
2981 (while (setq limit (pop limits))
2982 (if (or (and (integerp limit)
2983 (< (- (point-max) (point)) limit))
2985 (< (count-lines (point) (point-max)) limit))
2986 (and (functionp limit)
2988 (and (stringp limit)
2989 (not (re-search-forward limit nil t))))
2990 () ; This limit did not succeed.
2994 (narrow-to-region (point) (point-max))
2997 (defun gnus-article-search-signature ()
2998 "Search the current buffer for the signature separator.
2999 Put point at the beginning of the signature separator."
3000 (let ((cur (point)))
3001 (goto-char (point-max))
3002 (if (if (stringp gnus-signature-separator)
3003 (re-search-backward gnus-signature-separator nil t)
3004 (let ((seps gnus-signature-separator))
3006 (not (re-search-backward (car seps) nil t)))
3013 (defun gnus-article-hidden-arg ()
3014 "Return the current prefix arg as a number, or 0 if no prefix."
3015 (list (if current-prefix-arg
3016 (prefix-numeric-value current-prefix-arg)
3019 (defun gnus-article-check-hidden-text (type arg)
3020 "Return nil if hiding is necessary.
3021 Arg can be nil or a number. nil and positive means hide, negative
3022 means show, 0 means toggle."
3025 (let ((hide (gnus-article-hidden-text-p type)))
3031 (gnus-article-show-hidden-text type)
3034 (if (eq hide 'hidden)
3036 (gnus-article-show-hidden-text type)
3040 (defun gnus-article-hidden-text-p (type)
3041 "Say whether the current buffer contains hidden text of type TYPE."
3042 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
3044 (not (get-text-property pos 'invisible))
3045 (not (get-text-property pos 'dummy-invisible)))
3047 (text-property-any (1+ pos) (point-max) 'article-type type)))
3052 (defun gnus-article-show-hidden-text (type &optional dummy)
3053 "Show all hidden text of type TYPE.
3054 Originally it is hide instead of DUMMY."
3055 (let ((inhibit-read-only t)
3056 (inhibit-point-motion-hooks t))
3057 (gnus-remove-text-properties-when
3059 (point-min) (point-max)
3060 (cons 'article-type (cons type
3061 gnus-hidden-properties)))
3062 (gnus-delete-wash-type type)))
3064 (defconst article-time-units
3065 `((year . ,(* 365.25 24 60 60))
3066 (week . ,(* 7 24 60 60))
3067 (day . ,(* 24 60 60))
3071 "Mapping from time units to seconds.")
3073 (defun gnus-article-forward-header ()
3074 "Move point to the start of the next header.
3075 If the current header is a continuation header, this can be several
3080 (if (looking-at "[ \t]+[^ \t]")
3084 (defun article-date-ut (&optional type highlight)
3085 "Convert DATE date to universal time in the current article.
3086 If TYPE is `local', convert to local time; if it is `lapsed', output
3087 how much time has lapsed since DATE. For `lapsed', the value of
3088 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
3089 should replace the \"Date:\" one, or should be added below it."
3090 (interactive (list 'ut t))
3091 (let* ((tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
3092 (date-regexp (cond ((not gnus-article-date-lapsed-new-header)
3096 (article-lapsed-timer
3100 (case-fold-search t)
3101 (inhibit-read-only t)
3102 (inhibit-point-motion-hooks t)
3103 pos date bface eface)
3107 (goto-char (point-min))
3108 (while (or (setq date (get-text-property (setq pos (point))
3110 (when (setq pos (next-single-property-change
3111 (point) 'original-date))
3112 (setq date (get-text-property pos 'original-date))
3114 (narrow-to-region pos (or (text-property-any pos (point-max)
3117 (goto-char (point-min))
3118 (when (re-search-forward tdate-regexp nil t)
3119 (setq bface (get-text-property (point-at-bol) 'face)
3120 eface (get-text-property (1- (point-at-eol)) 'face)))
3121 (goto-char (point-min))
3123 ;; Delete any old Date headers.
3124 (while (re-search-forward date-regexp nil t)
3126 (delete-region (point-at-bol) (progn
3127 (gnus-article-forward-header)
3129 (delete-region (point-at-bol) (progn
3130 (gnus-article-forward-header)
3133 (setq pos (point))))
3134 (when (and (not pos)
3135 (re-search-forward tdate-regexp nil t))
3137 (gnus-goto-char pos)
3138 (insert (article-make-date-line date (or type 'ut)))
3144 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
3145 (put-text-property (match-beginning 1) (1+ (match-end 1))
3147 (put-text-property (match-beginning 2) (match-end 2)
3149 (put-text-property (point-min) (1- (point-max)) 'original-date date)
3150 (goto-char (point-max))
3153 (defun article-make-date-line (date type)
3154 "Return a DATE line of TYPE."
3155 (unless (memq type '(local ut original user iso8601 lapsed english))
3156 (error "Unknown conversion type: %s" type))
3158 (let ((time (date-to-time date)))
3160 ;; Convert to the local timezone.
3162 (concat "Date: " (message-make-date time)))
3163 ;; Convert to Universal Time.
3168 (let* ((e (parse-time-string date))
3169 (tm (apply 'encode-time e))
3171 (ls (- (cadr tm) (car (current-time-zone time)))))
3172 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
3173 ((> ls 65535) (list (1+ ms) (- ls 65536)))
3177 ;; Get the original date from the article.
3178 ((eq type 'original)
3179 (concat "Date: " (if (string-match "\n+$" date)
3180 (substring date 0 (match-beginning 0))
3182 ;; Let the user define the format.
3184 (let ((format (or (condition-case nil
3185 (with-current-buffer gnus-summary-buffer
3186 gnus-article-time-format)
3188 gnus-article-time-format)))
3189 (if (functionp format)
3190 (funcall format time)
3191 (concat "Date: " (format-time-string format time)))))
3194 (let ((tz (car (current-time-zone time))))
3197 (format-time-string "%Y%m%dT%H%M%S" time)
3198 (format "%s%02d%02d"
3199 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
3200 (/ (% (abs tz) 3600) 60)))))
3201 ;; Do an X-Sent lapsed format.
3203 ;; If the date is seriously mangled, the timezone functions are
3204 ;; liable to bug out, so we ignore all errors.
3205 (let* ((now (current-time))
3206 (real-time (subtract-time now time))
3207 (real-sec (and real-time
3208 (+ (* (float (car real-time)) 65536)
3210 (sec (and real-time (abs real-sec)))
3220 ;; This is a bit convoluted, but basically we go
3221 ;; through the time units for years, weeks, etc,
3222 ;; and divide things to see whether that results
3223 ;; in positive answers.
3226 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
3227 ;; The (remaining) seconds are too few to
3228 ;; be divided into this time unit.
3230 ;; It's big enough, so we output it.
3231 (setq sec (- sec (* num (cdr unit))))
3233 (concat (if prev ", " "") (int-to-string
3235 " " (symbol-name (car unit))
3236 (if (> num 1) "s" ""))
3238 article-time-units "")
3239 ;; If dates are odd, then it might appear like the
3240 ;; article was sent in the future.
3243 " in the future"))))))
3244 ;; Display the date in proper English
3246 (let ((dtime (decode-time time)))
3249 (number-to-string (nth 3 dtime))
3250 (let ((digit (% (nth 3 dtime) 10)))
3252 ((memq (nth 3 dtime) '(11 12 13)) "th")
3258 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3260 (number-to-string (nth 5 dtime))
3262 (format "%02d" (nth 2 dtime))
3264 (format "%02d" (nth 1 dtime)))))))
3266 (format "Date: %s (from T-gnus)" date))))
3268 (defun article-date-local (&optional highlight)
3269 "Convert the current article date to the local timezone."
3270 (interactive (list t))
3271 (article-date-ut 'local highlight))
3273 (defun article-date-english (&optional highlight)
3274 "Convert the current article date to something that is proper English."
3275 (interactive (list t))
3276 (article-date-ut 'english highlight))
3278 (defun article-date-original (&optional highlight)
3279 "Convert the current article date to what it was originally.
3280 This is only useful if you have used some other date conversion
3281 function and want to see what the date was before converting."
3282 (interactive (list t))
3283 (article-date-ut 'original highlight))
3285 (defun article-date-lapsed (&optional highlight)
3286 "Convert the current article date to time lapsed since it was sent."
3287 (interactive (list t))
3288 (article-date-ut 'lapsed highlight))
3290 (defun article-update-date-lapsed ()
3291 "Function to be run from a timer to update the lapsed time line."
3293 (let (deactivate-mark)
3298 (set-buffer (window-buffer w))
3299 (when (or (and (eq major-mode 'mime-view-mode)
3300 (eq (mime-preview-original-major-mode)
3301 'gnus-original-article-mode))
3302 (eq major-mode 'gnus-article-mode))
3303 (let ((mark (point-marker)))
3304 (goto-char (point-min))
3305 (when (re-search-forward "^X-Sent:" nil t)
3306 (article-date-lapsed t))
3307 (goto-char (marker-position mark))
3308 (move-marker mark nil))))
3311 (defun gnus-start-date-timer (&optional n)
3312 "Start a timer to update the X-Sent header in the article buffers.
3313 The numerical prefix says how frequently (in seconds) the function
3318 (gnus-stop-date-timer)
3319 (setq article-lapsed-timer
3320 (run-at-time 1 n 'article-update-date-lapsed)))
3322 (defun gnus-stop-date-timer ()
3323 "Stop the X-Sent timer."
3325 (when article-lapsed-timer
3326 (nnheader-cancel-timer article-lapsed-timer)
3327 (setq article-lapsed-timer nil)))
3329 (defun article-date-user (&optional highlight)
3330 "Convert the current article date to the user-defined format.
3331 This format is defined by the `gnus-article-time-format' variable."
3332 (interactive (list t))
3333 (article-date-ut 'user highlight))
3335 (defun article-date-iso8601 (&optional highlight)
3336 "Convert the current article date to ISO8601."
3337 (interactive (list t))
3338 (article-date-ut 'iso8601 highlight))
3340 (defmacro gnus-article-save-original-date (&rest forms)
3341 "Save the original date as a text property and evaluate FORMS."
3342 `(let* ((case-fold-search t)
3344 (goto-char (point-min))
3345 (when (and (re-search-forward "^date:[\t\n ]+" nil t)
3348 (date (when (and start
3349 (re-search-forward "[\t ]*\n\\(?:[^\t ]\\|\\'\\)"
3351 (buffer-substring-no-properties start
3352 (match-beginning 0)))))
3353 (goto-char (point-max))
3354 (skip-chars-backward "\n")
3355 (put-text-property (point-min) (point) 'original-date date)
3357 (goto-char (point-max))
3358 (skip-chars-backward "\n")
3359 (put-text-property (point-min) (point) 'original-date date)))
3361 ;; (defun article-show-all ()
3362 ;; "Show all hidden text in the article buffer."
3366 ;; (let ((inhibit-read-only t))
3367 ;; (gnus-article-unhide-text (point-min) (point-max))
3368 ;; (gnus-remove-text-with-property 'gnus-prev)
3369 ;; (gnus-remove-text-with-property 'gnus-next))))
3371 (defun article-show-all-headers ()
3372 "Show all hidden headers in the article buffer."
3377 (article-narrow-to-head)
3378 (let ((inhibit-read-only t))
3379 (gnus-article-unhide-text (point-min) (point-max))))))
3381 (defun article-remove-leading-whitespace ()
3382 "Remove excessive whitespace from all headers."
3386 (let ((inhibit-read-only t))
3387 (article-narrow-to-head)
3388 (goto-char (point-min))
3389 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3390 (delete-region (match-beginning 1) (match-end 1)))))))
3392 (defun article-emphasize (&optional arg)
3393 "Emphasize text according to `gnus-emphasis-alist'."
3394 (interactive (gnus-article-hidden-arg))
3395 (unless (gnus-article-check-hidden-text 'emphasis arg)
3399 (with-current-buffer gnus-summary-buffer
3400 gnus-article-emphasis-alist)
3402 gnus-emphasis-alist))
3403 (inhibit-read-only t)
3404 (props (append '(article-type emphasis)
3405 gnus-hidden-properties))
3406 regexp elem beg invisible visible face)
3409 (while (setq elem (pop alist))
3411 (setq regexp (car elem)
3412 invisible (nth 1 elem)
3413 visible (nth 2 elem)
3415 (while (re-search-forward regexp nil t)
3416 (when (and (match-beginning visible) (match-beginning invisible))
3417 (gnus-article-hide-text
3418 (match-beginning invisible) (match-end invisible) props)
3419 (gnus-article-unhide-text-type
3420 (match-beginning visible) (match-end visible) 'emphasis)
3421 (gnus-put-overlay-excluding-newlines
3422 (match-beginning visible) (match-end visible) 'face face)
3423 (gnus-add-wash-type 'emphasis)
3424 (goto-char (match-end invisible)))))))))
3426 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3427 "Setup newsgroup emphasis alist."
3428 (unless gnus-article-emphasis-alist
3429 (let ((name (and gnus-newsgroup-name
3430 (gnus-group-real-name gnus-newsgroup-name))))
3431 (make-local-variable 'gnus-article-emphasis-alist)
3432 (setq gnus-article-emphasis-alist
3434 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3435 (while (setq elem (pop alist))
3436 (when (and name (string-match (car elem) name))
3438 highlight (copy-sequence (cdr elem)))))
3440 (copy-sequence highlight-words)
3441 (if gnus-newsgroup-name
3442 (copy-sequence (gnus-group-find-parameter
3443 gnus-newsgroup-name 'highlight-words t)))
3444 gnus-emphasis-alist)))))
3447 (defvar gnus-summary-article-menu)
3448 (defvar gnus-summary-post-menu))
3450 ;;; Saving functions.
3452 (defun gnus-article-save (save-buffer file &optional num)
3453 "Save the currently selected article."
3454 (unless gnus-save-all-headers
3455 ;; Remove headers according to `gnus-saved-headers'.
3456 (let ((gnus-visible-headers
3457 (or gnus-saved-headers gnus-visible-headers))
3458 (gnus-article-buffer save-buffer))
3460 (set-buffer save-buffer)
3461 (article-hide-headers 1 t))))
3462 (save-window-excursion
3463 (if (not gnus-default-article-saver)
3464 (error "No default saver is defined")
3465 ;; !!! Magic! The saving functions all save
3466 ;; `gnus-save-article-buffer' (or so they think), but we
3467 ;; bind that variable to our save-buffer.
3468 (set-buffer gnus-article-buffer)
3469 (let* ((gnus-save-article-buffer save-buffer)
3472 ((not gnus-prompt-before-saving) 'default)
3473 ((eq gnus-prompt-before-saving 'always) nil)
3475 (gnus-number-of-articles-to-be-saved
3476 (when (eq gnus-prompt-before-saving t)
3478 (set-buffer gnus-article-current-summary)
3479 (funcall gnus-default-article-saver filename)))))
3481 (defun gnus-read-save-file-name (prompt &optional filename
3482 function group headers variable)
3484 (funcall function group headers (symbol-value variable)))
3489 ((eq filename 'default)
3495 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3498 (if (and gnus-number-of-articles-to-be-saved
3499 (> gnus-number-of-articles-to-be-saved 1))
3500 (format "these %d articles"
3501 gnus-number-of-articles-to-be-saved)
3504 ;; Let the split methods have their say.
3506 ;; No split name was found.
3509 (concat prompt " (default "
3510 (file-name-nondirectory default-name) "): ")
3511 (file-name-directory default-name)
3513 ;; A single group name is returned.
3514 ((stringp split-name)
3516 (funcall function split-name headers
3517 (symbol-value variable)))
3519 (concat prompt " (default "
3520 (file-name-nondirectory default-name) "): ")
3521 (file-name-directory default-name)
3523 ;; A single split name was found
3524 ((= 1 (length split-name))
3525 (let* ((name (expand-file-name
3527 gnus-article-save-directory))
3528 (dir (cond ((file-directory-p name)
3529 (file-name-as-directory name))
3530 ((file-exists-p name) name)
3531 (t gnus-article-save-directory))))
3533 (concat prompt " (default " name "): ")
3535 ;; A list of splits was found.
3537 (setq split-name (nreverse split-name))
3539 (let ((file-name-history
3540 (nconc split-name file-name-history)))
3544 (concat prompt " (`M-p' for defaults): ")
3545 gnus-article-save-directory
3547 gnus-article-save-directory)))
3548 (car (push result file-name-history)))))))
3549 ;; Create the directory.
3550 (gnus-make-directory (file-name-directory file))
3551 ;; If we have read a directory, we append the default file name.
3552 (when (file-directory-p file)
3553 (setq file (expand-file-name (file-name-nondirectory
3555 (file-name-as-directory file))))
3556 ;; Possibly translate some characters.
3557 (nnheader-translate-file-chars file))))))
3558 (gnus-make-directory (file-name-directory result))
3559 (set variable result)))
3561 (defun gnus-article-archive-name (group)
3562 "Return the first instance of an \"Archive-name\" in the current buffer."
3563 (let ((case-fold-search t))
3564 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3565 (nnheader-concat gnus-article-save-directory
3566 (match-string 1)))))
3568 (defun gnus-article-nndoc-name (group)
3569 "If GROUP is an nndoc group, return the name of the parent group."
3570 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3571 (gnus-group-get-parameter group 'save-article-group)))
3573 (defun gnus-summary-save-in-rmail (&optional filename)
3574 "Append this article to Rmail file.
3575 Optional argument FILENAME specifies file name.
3576 Directory to save to is default to `gnus-article-save-directory'."
3577 (setq filename (gnus-read-save-file-name
3578 "Save %s in rmail file" filename
3579 gnus-rmail-save-name gnus-newsgroup-name
3580 gnus-current-headers 'gnus-newsgroup-last-rmail))
3581 (gnus-eval-in-buffer-window gnus-save-article-buffer
3585 (gnus-output-to-rmail filename))))
3588 (defun gnus-summary-save-in-mail (&optional filename)
3589 "Append this article to Unix mail file.
3590 Optional argument FILENAME specifies file name.
3591 Directory to save to is default to `gnus-article-save-directory'."
3592 (setq filename (gnus-read-save-file-name
3593 "Save %s in Unix mail file" filename
3594 gnus-mail-save-name gnus-newsgroup-name
3595 gnus-current-headers 'gnus-newsgroup-last-mail))
3596 (gnus-eval-in-buffer-window gnus-save-article-buffer
3600 (if (and (file-readable-p filename)
3601 (file-regular-p filename)
3602 (mail-file-babyl-p filename))
3603 (rmail-output-to-rmail-file filename t)
3604 (gnus-output-to-mail filename)))))
3607 (defun gnus-summary-save-in-file (&optional filename overwrite)
3608 "Append this article to file.
3609 Optional argument FILENAME specifies file name.
3610 Directory to save to is default to `gnus-article-save-directory'."
3611 (setq filename (gnus-read-save-file-name
3612 "Save %s in file" filename
3613 gnus-file-save-name gnus-newsgroup-name
3614 gnus-current-headers 'gnus-newsgroup-last-file))
3615 (gnus-eval-in-buffer-window gnus-save-article-buffer
3619 (when (and overwrite
3620 (file-exists-p filename))
3621 (delete-file filename))
3622 (gnus-output-to-file filename))))
3625 (defun gnus-summary-write-to-file (&optional filename)
3626 "Write this article to a file, overwriting it if the file exists.
3627 Optional argument FILENAME specifies file name.
3628 The directory to save in defaults to `gnus-article-save-directory'."
3629 (gnus-summary-save-in-file nil t))
3631 (defun gnus-summary-save-body-in-file (&optional filename)
3632 "Append this article body to a file.
3633 Optional argument FILENAME specifies file name.
3634 The directory to save in defaults to `gnus-article-save-directory'."
3635 (setq filename (gnus-read-save-file-name
3636 "Save %s body in file" filename
3637 gnus-file-save-name gnus-newsgroup-name
3638 gnus-current-headers 'gnus-newsgroup-last-file))
3639 (gnus-eval-in-buffer-window gnus-save-article-buffer
3643 (when (article-goto-body)
3644 (narrow-to-region (point) (point-max)))
3645 (gnus-output-to-file filename))))
3648 (defun gnus-summary-save-in-pipe (&optional command)
3649 "Pipe this article to subprocess."
3651 (cond ((and (eq command 'default)
3652 gnus-last-shell-command)
3653 gnus-last-shell-command)
3658 "Shell command on %s: "
3659 (if (and gnus-number-of-articles-to-be-saved
3660 (> gnus-number-of-articles-to-be-saved 1))
3661 (format "these %d articles"
3662 gnus-number-of-articles-to-be-saved)
3664 gnus-last-shell-command))))
3665 (when (string-equal command "")
3666 (if gnus-last-shell-command
3667 (setq command gnus-last-shell-command)
3668 (error "A command is required")))
3669 (gnus-eval-in-buffer-window gnus-article-buffer
3672 (shell-command-on-region (point-min) (point-max) command nil)))
3673 (setq gnus-last-shell-command command))
3675 (defun gnus-summary-pipe-to-muttprint (&optional command)
3676 "Pipe this article to muttprint."
3677 (setq command (read-string
3678 "Print using command: " gnus-summary-muttprint-program
3679 nil gnus-summary-muttprint-program))
3680 (gnus-summary-save-in-pipe command))
3682 ;;; Article file names when saving.
3684 (defun gnus-capitalize-newsgroup (newsgroup)
3685 "Capitalize NEWSGROUP name."
3686 (when (not (zerop (length newsgroup)))
3687 (concat (char-to-string (upcase (aref newsgroup 0)))
3688 (substring newsgroup 1))))
3690 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3691 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3692 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3693 Otherwise, it is like ~/News/news/group/num."
3696 (concat (if (gnus-use-long-file-name 'not-save)
3697 (gnus-capitalize-newsgroup newsgroup)
3698 (gnus-newsgroup-directory-form newsgroup))
3699 "/" (int-to-string (mail-header-number headers)))
3700 gnus-article-save-directory)))
3702 (string-equal (file-name-directory default)
3703 (file-name-directory last-file))
3704 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3706 (or last-file default))))
3708 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3709 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3710 If variable `gnus-use-long-file-name' is non-nil, it is
3711 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3714 (concat (if (gnus-use-long-file-name 'not-save)
3716 (gnus-newsgroup-directory-form newsgroup))
3717 "/" (int-to-string (mail-header-number headers)))
3718 gnus-article-save-directory)))
3720 (string-equal (file-name-directory default)
3721 (file-name-directory last-file))
3722 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3724 (or last-file default))))
3726 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3727 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3728 If variable `gnus-use-long-file-name' is non-nil, it is
3729 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3732 (if (gnus-use-long-file-name 'not-save)
3735 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3737 gnus-article-save-directory)))
3739 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3740 "Generate file name from sender."
3741 (let ((from (mail-header-from headers)))
3743 (if (and from (string-match "\\([^ <]+\\)@" from))
3744 (match-string 1 from)
3746 gnus-article-save-directory)))
3748 (defun article-verify-x-pgp-sig ()
3751 (if (gnus-buffer-live-p gnus-original-article-buffer)
3752 (let ((sig (with-current-buffer gnus-original-article-buffer
3753 (gnus-fetch-field "X-PGP-Sig")))
3757 (mml2015-clear-verify-function))
3759 (insert-buffer-substring gnus-original-article-buffer)
3760 (setq items (split-string sig))
3761 (message-narrow-to-head)
3762 (let ((inhibit-point-motion-hooks t)
3763 (case-fold-search t))
3764 ;; Don't verify multiple headers.
3765 (setq headers (mapconcat (lambda (header)
3767 (mail-fetch-field header)
3769 (split-string (nth 1 items) ",") "")))
3770 (delete-region (point-min) (point-max))
3771 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3772 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3777 (if (looking-at "^-")
3780 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3781 (insert "Version: " (car items) "\n\n")
3782 (insert (mapconcat 'identity (cddr items) "\n"))
3783 (insert "\n-----END PGP SIGNATURE-----\n")
3784 (let ((mm-security-handle (list (format "multipart/signed"))))
3785 (mml2015-clean-buffer)
3786 (let ((coding-system-for-write (or gnus-newsgroup-charset
3788 (funcall (mml2015-clear-verify-function)))
3790 (or (mm-handle-multipart-ctl-parameter
3791 mm-security-handle 'gnus-details)
3792 (mm-handle-multipart-ctl-parameter
3793 mm-security-handle 'gnus-info)))))
3795 (let ((inhibit-read-only t) bface eface)
3797 (message-narrow-to-head)
3798 (goto-char (point-max))
3800 (setq bface (get-text-property (point-at-bol) 'face)
3801 eface (get-text-property (1- (point-at-eol)) 'face))
3802 (message-remove-header "X-Gnus-PGP-Verify")
3803 (if (re-search-forward "^X-PGP-Sig:" nil t)
3805 (goto-char (point-max)))
3806 (narrow-to-region (point) (point))
3807 (insert "X-Gnus-PGP-Verify: " info "\n")
3808 (goto-char (point-min))
3811 (if (not (looking-at "^[ \t]"))
3815 (goto-char (point-min))
3816 (when (looking-at "\\([^:]+\\): *")
3817 (put-text-property (match-beginning 1) (1+ (match-end 1))
3819 (put-text-property (match-end 0) (point-max)
3820 'face eface)))))))))
3822 (defun article-verify-cancel-lock ()
3823 "Verify Cancel-Lock header."
3825 (if (gnus-buffer-live-p gnus-original-article-buffer)
3826 (canlock-verify gnus-original-article-buffer)))
3828 (defun article-monafy ()
3829 "Display body part with mona font."
3831 (unless (if (featurep 'xemacs)
3832 (find-face 'gnus-mona-face)
3833 (facep 'gnus-mona-face))
3834 (require 'navi2ch-mona)
3835 (set-face-font (make-face 'gnus-mona-face) navi2ch-mona-font))
3837 (let ((inhibit-read-only t))
3840 (gnus-make-overlay (point) (point-max))
3841 'face 'gnus-mona-face))))
3848 (setq afunc (car func)
3851 gfunc (intern (format "gnus-%s" func))))
3853 (when (fboundp afunc)
3854 `(lambda (&optional interactive &rest args)
3855 ,(documentation afunc t)
3856 (interactive (list t))
3858 (set-buffer gnus-article-buffer)
3860 (call-interactively ',afunc)
3861 (apply ',afunc args))))))))
3862 '(article-hide-headers
3863 article-verify-x-pgp-sig
3864 article-verify-cancel-lock
3866 article-hide-boring-headers
3867 article-treat-overstrike
3868 article-treat-ansi-sequences
3869 article-fill-long-lines
3870 article-capitalize-sentences
3872 article-remove-leading-whitespace
3873 article-display-x-face
3874 article-display-face
3875 article-de-quoted-unreadable
3876 article-de-base64-unreadable
3879 article-unsplit-urls
3880 article-hide-list-identifiers
3881 article-strip-banner
3884 article-hide-signature
3885 article-strip-headers-in-body
3886 article-remove-trailing-blank-lines
3887 article-strip-leading-blank-lines
3888 article-strip-multiple-blank-lines
3889 article-strip-leading-space
3890 article-strip-trailing-space
3891 article-strip-blank-lines
3892 article-strip-all-blank-lines
3894 article-date-english
3895 article-date-iso8601
3896 article-date-original
3898 article-decode-mime-words
3899 article-decode-charset
3900 article-decode-encoded-words
3904 article-treat-dumbquotes
3905 article-normalize-headers
3906 (article-show-all-headers . gnus-article-show-all-headers)
3907 ;; (article-show-all . gnus-article-show-all)
3911 ;;; Gnus article mode
3914 (put 'gnus-article-mode 'mode-class 'special)
3916 (gnus-define-keys gnus-article-mode-map
3917 " " gnus-article-goto-next-page
3918 "\177" gnus-article-goto-prev-page
3919 [delete] gnus-article-goto-prev-page
3920 [backspace] gnus-article-goto-prev-page
3921 "\C-c^" gnus-article-refer-article
3922 "h" gnus-article-show-summary
3923 "s" gnus-article-show-summary
3924 "\C-c\C-m" gnus-article-mail
3925 "?" gnus-article-describe-briefly
3926 "e" gnus-summary-edit-article
3927 "<" beginning-of-buffer
3929 "\C-c\C-i" gnus-info-find-node
3931 "R" gnus-article-reply-with-original
3932 "F" gnus-article-followup-with-original
3933 "\C-hk" gnus-article-describe-key
3934 "\C-hc" gnus-article-describe-key-briefly
3936 "\C-d" gnus-article-read-summary-keys
3937 "\M-*" gnus-article-read-summary-keys
3938 "\M-#" gnus-article-read-summary-keys
3939 "\M-^" gnus-article-read-summary-keys
3940 "\M-g" gnus-article-read-summary-keys)
3942 ;; Define almost undefined keys to `gnus-article-read-summary-keys'.
3946 (push (char-to-string key) keys)
3948 (dolist (elem (accessible-keymaps gnus-summary-mode-map))
3949 (setq key (car elem))
3950 (when (and (> (length key) 0)
3951 (not (eq 'menu-bar (aref key 0)))
3952 (symbolp (lookup-key gnus-summary-mode-map key)))
3955 (unless (lookup-key gnus-article-mode-map key)
3956 (define-key gnus-article-mode-map key 'gnus-article-read-summary-keys))))
3958 (defun gnus-article-make-menu-bar ()
3959 (unless (boundp 'gnus-article-commands-menu)
3960 (gnus-summary-make-menu-bar))
3961 (gnus-turn-off-edit-menu 'article)
3962 (unless (boundp 'gnus-article-article-menu)
3964 gnus-article-article-menu gnus-article-mode-map ""
3966 ["Scroll forwards" gnus-article-goto-next-page t]
3967 ["Scroll backwards" gnus-article-goto-prev-page t]
3968 ["Show summary" gnus-article-show-summary t]
3969 ["Fetch Message-ID at point" gnus-article-refer-article t]
3970 ["Mail to address at point" gnus-article-mail t]
3971 ["Send a bug report" gnus-bug t]))
3974 gnus-article-treatment-menu gnus-article-mode-map ""
3975 ;; Fixme: this should use :active (and maybe :visible).
3977 ["Hide headers" gnus-article-hide-headers t]
3978 ["Hide signature" gnus-article-hide-signature t]
3979 ["Hide citation" gnus-article-hide-citation t]
3980 ["Treat overstrike" gnus-article-treat-overstrike t]
3981 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
3982 ["Remove carriage return" gnus-article-remove-cr t]
3983 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3984 ["Treat html" gnus-article-wash-html t]
3985 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3986 ["Decode HZ" gnus-article-decode-HZ t]))
3988 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3990 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3992 (gnus-run-hooks 'gnus-article-menu-hook)))
3994 (defun gnus-article-mode ()
3995 "Major mode for displaying an article.
3997 All normal editing commands are switched off.
3999 The following commands are available in addition to all summary mode
4001 \\<gnus-article-mode-map>
4002 \\[gnus-article-next-page]\t Scroll the article one page forwards
4003 \\[gnus-article-prev-page]\t Scroll the article one page backwards
4004 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
4005 \\[gnus-article-show-summary]\t Display the summary buffer
4006 \\[gnus-article-mail]\t Send a reply to the address near point
4007 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
4008 \\[gnus-info-find-node]\t Go to the Gnus info node"
4010 (kill-all-local-variables)
4011 (gnus-simplify-mode-line)
4012 (setq mode-name "Article")
4013 (setq major-mode 'gnus-article-mode)
4014 (make-local-variable 'minor-mode-alist)
4015 (unless (assq 'gnus-show-mime minor-mode-alist)
4016 (push (list 'gnus-show-mime " MIME") minor-mode-alist))
4017 (use-local-map gnus-article-mode-map)
4018 (when (gnus-visual-p 'article-menu 'menu)
4019 (gnus-article-make-menu-bar)
4020 (when gnus-summary-tool-bar-map
4021 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
4022 (gnus-update-format-specifications nil 'article-mode)
4023 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
4024 (set (make-local-variable 'gnus-page-broken) nil)
4025 (make-local-variable 'gnus-button-marker-list)
4026 (make-local-variable 'gnus-article-current-summary)
4027 (make-local-variable 'gnus-article-mime-handles)
4028 (make-local-variable 'gnus-article-decoded-p)
4029 (make-local-variable 'gnus-article-mime-handle-alist)
4030 (make-local-variable 'gnus-article-wash-types)
4031 (make-local-variable 'gnus-article-image-alist)
4032 (make-local-variable 'gnus-article-charset)
4033 (make-local-variable 'gnus-article-ignored-charsets)
4034 ;; Prevent recent Emacsen from displaying non-break space as "\ ".
4035 (set (make-local-variable 'nobreak-char-display) nil)
4036 (gnus-set-default-directory)
4037 (buffer-disable-undo)
4038 (setq buffer-read-only t
4039 show-trailing-whitespace nil)
4040 (set-syntax-table gnus-article-mode-syntax-table)
4041 (gnus-run-mode-hooks 'gnus-article-mode-hook))
4043 (defun gnus-article-setup-buffer ()
4044 "Initialize the article buffer."
4045 (let* ((name (if gnus-single-article-buffer "*Article*"
4046 (concat "*Article " gnus-newsgroup-name "*")))
4048 (progn (string-match "\\*Article" name)
4049 (concat " *Original Article"
4050 (substring name (match-end 0))))))
4051 (setq gnus-article-buffer name)
4052 (setq gnus-original-article-buffer original)
4053 (setq gnus-article-mime-handle-alist nil)
4054 ;; This might be a variable local to the summary buffer.
4055 (unless gnus-single-article-buffer
4057 (set-buffer gnus-summary-buffer)
4058 (setq gnus-article-buffer name)
4059 (setq gnus-original-article-buffer original)
4060 (gnus-set-global-variables)))
4061 (gnus-article-setup-highlight-words)
4062 ;; Init original article buffer.
4064 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
4065 (set-buffer-multibyte t)
4066 (setq major-mode 'gnus-original-article-mode)
4067 (make-local-variable 'gnus-original-article))
4068 (if (and (get-buffer name)
4069 (with-current-buffer name
4070 (if gnus-article-edit-mode
4071 (if (y-or-n-p "Article mode edit in progress; discard? ")
4073 (set-buffer-modified-p nil)
4074 (gnus-kill-buffer name)
4077 (error "Action aborted"))
4081 (set (make-local-variable 'gnus-article-edit-mode) nil)
4082 (buffer-disable-undo)
4083 (setq buffer-read-only t)
4084 ;; This list just keeps growing if we don't reset it.
4085 (setq gnus-button-marker-list nil)
4086 (unless (eq major-mode 'gnus-article-mode)
4087 (gnus-article-mode))
4090 (set-buffer (gnus-get-buffer-create name))
4092 (make-local-variable 'gnus-summary-buffer)
4093 (gnus-summary-set-local-parameters gnus-newsgroup-name)
4094 (current-buffer)))))
4096 ;; Set article window start at LINE, where LINE is the number of lines
4097 ;; from the head of the article.
4098 (defun gnus-article-set-window-start (&optional line)
4100 (gnus-get-buffer-window gnus-article-buffer t)
4102 (set-buffer gnus-article-buffer)
4103 (goto-char (point-min))
4106 (gnus-message 6 "Moved to bookmark")
4107 (search-forward "\n\n" nil t)
4111 ;;; @@ article filters
4114 (defun gnus-article-display-mime-message ()
4115 "Article display method for MIME message."
4116 ;; called from `gnus-original-article-buffer'.
4117 (let (charset all-headers)
4118 (with-current-buffer gnus-summary-buffer
4119 (setq charset default-mime-charset
4120 all-headers gnus-have-all-headers))
4121 (make-local-variable 'default-mime-charset)
4122 (setq default-mime-charset charset)
4123 (with-current-buffer (get-buffer-create gnus-article-buffer)
4124 (make-local-variable 'default-mime-charset)
4125 (setq default-mime-charset charset))
4126 (mime-display-message mime-message-structure
4127 gnus-article-buffer nil gnus-article-mode-map)
4129 (gnus-article-hide-headers nil -1)))
4130 (run-hooks 'gnus-mime-article-prepare-hook))
4132 (defun gnus-article-display-traditional-message ()
4133 "Article display method for traditional message."
4134 (set-buffer gnus-article-buffer)
4135 (let ((inhibit-read-only t))
4137 (insert-buffer-substring gnus-original-article-buffer)))
4139 (defun gnus-article-make-full-mail-header (&optional number charset)
4140 "Create a new mail header structure in a raw article buffer."
4141 (unless (and number charset)
4142 (save-current-buffer
4143 (set-buffer gnus-summary-buffer)
4145 (setq number (or (cdr gnus-article-current) 0)))
4147 (setq charset (or default-mime-charset 'x-ctext)))))
4148 (goto-char (point-min))
4149 (let ((header-end (if (search-forward "\n\n" nil t)
4151 (goto-char (point-max))))
4152 (chars (- (point-max) (point)))
4153 (lines (count-lines (point) (point-max)))
4154 (default-mime-charset charset)
4156 (narrow-to-region (point-min) header-end)
4157 (setq xref (std11-fetch-field "xref"))
4159 (make-full-mail-header
4161 (std11-fetch-field "subject")
4162 (std11-fetch-field "from")
4163 (std11-fetch-field "date")
4164 (std11-fetch-field "message-id")
4165 (std11-fetch-field "references")
4168 (when xref (concat "Xref: " xref)))
4171 (defun gnus-article-prepare (article &optional all-headers header)
4172 "Prepare ARTICLE in article mode buffer.
4173 ARTICLE should either be an article number or a Message-ID.
4174 If ARTICLE is an id, HEADER should be the article headers.
4175 If ALL-HEADERS is non-nil, no headers are hidden."
4177 ;; Make sure we start in a summary buffer.
4178 (unless (eq major-mode 'gnus-summary-mode)
4179 (set-buffer gnus-summary-buffer))
4180 (setq gnus-summary-buffer (current-buffer))
4181 (let* ((gnus-article (if header (mail-header-number header) article))
4182 (summary-buffer (current-buffer))
4183 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
4184 (group gnus-newsgroup-name)
4187 (gnus-article-setup-buffer)
4188 (set-buffer gnus-article-buffer)
4189 ;; Deactivate active regions.
4190 (when (and (boundp 'transient-mark-mode)
4191 transient-mark-mode)
4192 (setq mark-active nil))
4193 (if (not (setq result (let ((inhibit-read-only t))
4194 (gnus-request-article-this-buffer
4196 ;; There is no such article.
4198 (when (and (numberp article)
4199 (not (memq article gnus-newsgroup-sparse)))
4200 (setq gnus-article-current
4201 (cons gnus-newsgroup-name article))
4202 (set-buffer gnus-summary-buffer)
4203 (setq gnus-current-article article)
4204 (if (and (memq article gnus-newsgroup-undownloaded)
4205 (not (gnus-online (gnus-find-method-for-group
4206 gnus-newsgroup-name))))
4208 (gnus-summary-set-agent-mark article)
4209 (message "Message marked for downloading"))
4210 (gnus-summary-mark-article article gnus-canceled-mark)
4211 (unless (memq article gnus-newsgroup-sparse)
4212 (gnus-error 1 "No such article (may have expired or been canceled)")))))
4213 (if (or (eq result 'pseudo)
4214 (eq result 'nneething))
4217 (set-buffer summary-buffer)
4218 (push article gnus-newsgroup-history)
4219 (setq gnus-last-article gnus-current-article
4220 gnus-current-article 0
4221 gnus-current-headers nil
4222 gnus-article-current nil)
4223 (if (eq result 'nneething)
4224 (gnus-configure-windows 'summary)
4225 (gnus-configure-windows 'article))
4226 (gnus-set-global-variables))
4227 (let ((gnus-article-mime-handle-alist-1
4228 gnus-article-mime-handle-alist))
4229 (gnus-set-mode-line 'article)))
4230 ;; The result from the `request' was an actual article -
4231 ;; or at least some text that is now displayed in the
4233 (when (and (numberp article)
4234 (not (eq article gnus-current-article)))
4235 ;; Seems like a new article has been selected.
4236 ;; `gnus-current-article' must be an article number.
4238 (set-buffer summary-buffer)
4239 (push article gnus-newsgroup-history)
4240 (setq gnus-last-article gnus-current-article
4241 gnus-current-article article
4242 gnus-current-headers
4243 (gnus-summary-article-header gnus-current-article)
4244 gnus-article-current
4245 (cons gnus-newsgroup-name gnus-current-article))
4246 (unless (vectorp gnus-current-headers)
4247 (setq gnus-current-headers nil))
4248 (gnus-summary-goto-subject gnus-current-article)
4249 (when (gnus-summary-show-thread)
4250 ;; If the summary buffer really was folded, the
4251 ;; previous goto may not actually have gone to
4252 ;; the right article, but the thread root instead.
4254 (gnus-summary-goto-subject gnus-current-article))
4255 (gnus-run-hooks 'gnus-mark-article-hook)
4256 (gnus-set-mode-line 'summary)
4257 (when (gnus-visual-p 'article-highlight 'highlight)
4258 (gnus-run-hooks 'gnus-visual-mark-article-hook))
4259 ;; Set the global newsgroup variables here.
4260 (gnus-set-global-variables)
4261 (setq gnus-have-all-headers
4262 (or all-headers gnus-show-all-headers))))
4264 (gnus-configure-windows 'article))
4265 (when (or (numberp article)
4267 (gnus-article-prepare-display)
4269 (goto-char (point-min))
4270 (when gnus-break-pages
4271 (gnus-narrow-to-page)))
4272 (let ((gnus-article-mime-handle-alist-1
4273 gnus-article-mime-handle-alist))
4274 (gnus-set-mode-line 'article))
4278 (set-window-point (get-buffer-window (current-buffer)) (point))
4279 (gnus-configure-windows 'article)
4282 (defun gnus-article-prepare-mime-display (&optional number)
4283 (goto-char (point-min))
4284 (when (re-search-forward "^[^\t ]+:" nil t)
4285 (goto-char (match-beginning 0)))
4286 (let ((entity (if (eq 1 (point-min))
4287 (get-text-property 1 'mime-view-entity)
4288 (get-text-property (point) 'mime-view-entity)))
4289 last-entity child-entity next type)
4290 (setq child-entity (mime-entity-children entity))
4292 (setq last-entity (nth (1- (length child-entity))
4294 (setq last-entity entity))
4296 (narrow-to-region (point)
4297 (if (search-forward "\n\n" nil t)
4300 (gnus-article-save-original-date (gnus-treat-article 'head))
4301 (put-text-property (point-min) (point-max) 'article-treated-header t)
4302 (goto-char (point-max)))
4303 (while (and (not (eobp)) entity)
4304 (setq next (set-marker
4306 (next-single-property-change (point) 'mime-view-entity
4308 (let ((types (mime-entity-content-type entity)))
4309 (while (eq 'multipart (mime-content-type-primary-type types))
4310 (setq entity (car (mime-entity-children entity))
4311 types (mime-entity-content-type entity)))
4313 (setq type (format "%s/%s"
4314 (mime-content-type-primary-type types)
4315 (mime-content-type-subtype types)))))
4316 (if (string-equal type "message/rfc822")
4319 (let ((children (mime-entity-children entity))
4322 (setq last-children (nth (1- (length children)) children))
4325 (not (eq last-children
4326 (get-text-property next 'mime-view-entity)))
4328 (next-single-property-change next
4330 nil (point-max)))))))
4331 (setq next (next-single-property-change next 'mime-view-entity
4334 (narrow-to-region (point) next)
4335 (gnus-article-prepare-mime-display)
4336 (goto-char (point-max)))
4337 (setq entity (get-text-property (point) 'mime-view-entity)))
4339 (narrow-to-region (point) next)
4340 ;; Kludge. We have to count true number, but for now,
4341 ;; part number is here only to achieve `last'.
4342 (gnus-treat-article nil 1
4343 (if (eq entity last-entity)
4346 (goto-char (point-max)))
4347 (setq entity (get-text-property next 'mime-view-entity))))))
4350 (defun gnus-article-prepare-display ()
4351 "Make the current buffer look like a nice article."
4352 (let ((gnus-article-buffer (current-buffer))
4354 (inhibit-read-only t))
4355 (unless (eq major-mode 'gnus-article-mode)
4356 (gnus-article-mode))
4357 (setq buffer-read-only nil
4358 gnus-button-marker-list nil
4359 gnus-article-wash-types nil
4360 gnus-article-image-alist nil)
4363 (static-if (featurep 'xemacs)
4364 (map-extents (lambda (extent maparg) (delete-extent extent)))
4365 (let ((lists (overlay-lists)))
4366 (dolist (overlay (nconc (car lists) (cdr lists)))
4367 (delete-overlay overlay)))))
4368 (gnus-run-hooks 'gnus-tmp-internal-hook))
4369 (let ((show-mime (unless (member gnus-newsgroup-name '("nndraft:delayed"
4372 (inhibit-read-only t))
4373 (set-buffer gnus-original-article-buffer)
4375 (setq mime-message-structure gnus-current-headers)
4376 (mime-buffer-entity-set-buffer-internal mime-message-structure
4377 gnus-original-article-buffer)
4378 (mime-entity-set-representation-type-internal mime-message-structure
4379 'mime-buffer-entity)
4380 (luna-send mime-message-structure 'initialize-instance
4381 mime-message-structure)
4383 (let (mime-display-header-hook mime-display-text/plain-hook)
4384 (funcall gnus-article-display-method-for-mime))
4385 (funcall gnus-article-display-method-for-traditional))
4386 ;; Call the treatment functions.
4390 (gnus-article-prepare-mime-display)
4391 (narrow-to-region (goto-char (point-min))
4392 (if (search-forward "\n\n" nil t)
4395 (gnus-article-save-original-date (gnus-treat-article 'head))
4396 (put-text-property (point-min) (point-max) 'article-treated-header t)
4397 (goto-char (point-max))
4399 (narrow-to-region (point) (point-max))
4400 (gnus-treat-article nil))
4401 (put-text-property (point-min) (point-max) 'read-only nil)))
4402 (gnus-run-hooks 'gnus-article-prepare-hook))
4404 (defun gnus-article-decode-article-as-default-mime-charset ()
4405 "Decode an article as `default-mime-charset'. It won't work if the
4406 value of the variable `gnus-show-mime' is non-nil."
4407 (unless (or gnus-show-mime
4408 (member gnus-newsgroup-name '("nndraft:delayed"
4410 (set (make-local-variable 'default-mime-charset)
4411 (with-current-buffer gnus-summary-buffer
4412 default-mime-charset))
4413 (decode-mime-charset-region (point-min) (point-max)
4414 default-mime-charset)))
4417 ;;; Gnus MIME viewing functions
4420 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4421 "Format of the MIME buttons.
4423 Valid specifiers include:
4425 %T MIME type, along with additional info
4426 %n The `name' parameter
4427 %d The description, if any
4428 %l The length of the encoded part
4429 %p The part identifier number
4430 %e Dots if the part isn't displayed
4432 General format specifiers can also be used. See Info node
4433 `(gnus)Formatting Variables'.")
4435 (defvar gnus-mime-button-line-format-alist
4436 '((?t gnus-tmp-type ?s)
4437 (?T gnus-tmp-type-long ?s)
4438 (?n gnus-tmp-name ?s)
4439 (?d gnus-tmp-description ?s)
4441 (?l gnus-tmp-length ?d)
4442 (?e gnus-tmp-dots ?s)))
4444 (defvar gnus-mime-button-commands
4445 '((gnus-article-press-button "\r" "Toggle Display")
4446 (gnus-mime-view-part "v" "View Interactively...")
4447 (gnus-mime-view-part-as-type "t" "View As Type...")
4448 (gnus-mime-view-part-as-charset "C" "View As charset...")
4449 (gnus-mime-save-part "o" "Save...")
4450 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4451 (gnus-mime-replace-part "r" "Replace part")
4452 (gnus-mime-delete-part "d" "Delete part")
4453 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4454 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4455 (gnus-mime-view-part-internally "E" "View Internally") ;; Why `E'?
4456 (gnus-mime-view-part-externally "e" "View Externally")
4457 (gnus-mime-print-part "p" "Print")
4458 (gnus-mime-pipe-part "|" "Pipe To Command...")
4459 (gnus-mime-action-on-part "." "Take action on the part...")))
4461 (defun gnus-article-mime-part-status ()
4462 (with-current-buffer gnus-article-buffer
4463 (let ((entity (get-text-property (point-min) 'mime-view-entity))
4466 (setq children (mime-entity-children entity))
4467 (setq children (length children)))
4470 (format " (%d parts)" children))
4473 (defvar gnus-mime-button-map
4474 (let ((map (make-sparse-keymap)))
4475 (define-key map gnus-mouse-2 'gnus-article-push-button)
4476 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4477 (dolist (c gnus-mime-button-commands)
4478 (define-key map (cadr c) (car c)))
4482 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4484 ,@(mapcar (lambda (c)
4485 (vector (caddr c) (car c) :enable t))
4486 gnus-mime-button-commands)))
4488 (defun gnus-mime-button-menu (event prefix)
4489 "Construct a context-sensitive menu of MIME commands."
4490 (interactive "e\nP")
4491 (save-window-excursion
4492 (let ((pos (event-start event)))
4493 (select-window (posn-window pos))
4494 (goto-char (posn-point pos))
4495 (gnus-article-check-buffer)
4496 (popup-menu gnus-mime-button-menu nil prefix))))
4498 (defun gnus-mime-view-all-parts (&optional handles)
4499 "View all the MIME parts."
4501 (with-current-buffer gnus-article-buffer
4502 (let ((handles (or handles gnus-article-mime-handles))
4503 (mail-parse-charset gnus-newsgroup-charset)
4504 (mail-parse-ignored-charsets
4505 (with-current-buffer gnus-summary-buffer
4506 gnus-newsgroup-ignored-charsets)))
4508 (mm-remove-parts handles)
4509 (goto-char (point-min))
4510 (or (search-forward "\n\n") (goto-char (point-max)))
4511 (let ((inhibit-read-only t))
4512 (delete-region (point) (point-max))
4513 (mm-display-parts handles))))))
4515 (defun gnus-article-jump-to-part (n)
4516 "Jump to MIME part N."
4518 (pop-to-buffer gnus-article-buffer)
4519 ;; FIXME: why is it necessary?
4521 (let ((parts (length gnus-article-mime-handle-alist)))
4524 (read-string ;; Emacs 21 doesn't have `read-number'.
4525 (format "Jump to part (2..%s): " parts)))))
4526 (unless (and (integerp n) (<= n parts) (>= n 1))
4529 (gnus-message 7 "Invalid part `%s', using %s instead."
4532 (gnus-message 9 "Jumping to part %s." n)
4533 (cond ((>= gnus-auto-select-part 1)
4534 (while (and (<= n parts)
4535 (not (gnus-article-goto-part n)))
4537 ((< gnus-auto-select-part 0)
4538 (while (and (>= n 1)
4539 (not (gnus-article-goto-part n)))
4542 (gnus-article-goto-part n)))))
4545 (defsubst gnus-article-edit-part (handles &optional current-id)
4546 "Edit an article in order to delete a mime part.
4547 This function is exclusively used by `gnus-mime-save-part-and-strip'
4548 and `gnus-mime-delete-part', and not provided at run-time normally."
4549 (gnus-article-edit-article
4551 (buffer-disable-undo)
4553 (let ((mail-parse-charset (or gnus-article-charset
4554 ',gnus-newsgroup-charset))
4555 (mail-parse-ignored-charsets
4556 (or gnus-article-ignored-charsets
4557 ',gnus-newsgroup-ignored-charsets))
4558 (mbl mml-buffer-list))
4559 (setq mml-buffer-list nil)
4560 (insert-buffer-substring gnus-original-article-buffer)
4561 (mime-to-mml ',handles)
4562 (setq gnus-article-mime-handles nil)
4563 (let ((mbl1 mml-buffer-list))
4564 (setq mml-buffer-list mbl)
4565 (set (make-local-variable 'mml-buffer-list) mbl1))
4566 (gnus-make-local-hook 'kill-buffer-hook)
4567 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4568 `(lambda (no-highlight)
4569 (let ((mail-parse-charset (or gnus-article-charset
4570 ',gnus-newsgroup-charset))
4571 (message-options message-options)
4572 (message-options-set-recipient)
4573 (mail-parse-ignored-charsets
4574 (or gnus-article-ignored-charsets
4575 ',gnus-newsgroup-ignored-charsets)))
4577 (mml-destroy-buffers)
4578 (remove-hook 'kill-buffer-hook
4579 'mml-destroy-buffers t)
4580 (kill-local-variable 'mml-buffer-list))
4581 (gnus-summary-edit-article-done
4582 ,(or (mail-header-references gnus-current-headers) "")
4583 ,(gnus-group-read-only-p)
4584 ,gnus-summary-buffer no-highlight))
4586 (gnus-article-edit-done)
4587 (gnus-summary-expand-window)
4588 (gnus-summary-show-article)
4589 (when (and current-id (integerp gnus-auto-select-part))
4590 (gnus-article-jump-to-part
4591 (+ current-id gnus-auto-select-part)))))
4593 (defun gnus-mime-replace-part (file)
4594 "Replace MIME part under point with an external body."
4595 ;; Useful if file has already been saved to disk
4599 (read-file-name "Replace MIME part with file: "
4600 (or mm-default-directory default-directory)
4602 (gnus-mime-save-part-and-strip file))
4604 (defun gnus-mime-save-part-and-strip (&optional file)
4605 "Save the MIME part under point then replace it with an external body.
4606 If FILE is given, use it for the external part."
4608 (gnus-article-check-buffer)
4609 (when (gnus-group-read-only-p)
4610 (error "The current group does not support deleting of parts"))
4611 (when (mm-complicated-handles gnus-article-mime-handles)
4613 The current article has a complicated MIME structure, giving up..."))
4614 (let* ((data (get-text-property (point) 'gnus-data))
4615 (id (get-text-property (point) 'gnus-part))
4617 (handles gnus-article-mime-handles))
4620 (and data (mm-save-part data "Delete MIME part and save to: "))))
4622 (with-current-buffer (mm-handle-buffer data)
4624 (insert "Content-Type: " (mm-handle-media-type data))
4625 (mml-insert-parameter-string (cdr (mm-handle-type data))
4628 (insert "Content-ID: " (message-make-message-id) "\n")
4629 (insert "Content-Transfer-Encoding: binary\n")
4632 (cdr (mm-make-handle nil
4633 `("message/external-body"
4634 (access-type . "LOCAL-FILE")
4636 ;; (set-buffer gnus-summary-buffer)
4637 (gnus-article-edit-part handles id))))
4639 ;; A function like `gnus-summary-save-parts' (`X m', `<MIME> <Extract all
4640 ;; parts...>') but with stripping would be nice.
4642 (defun gnus-mime-delete-part ()
4643 "Delete the MIME part under point.
4644 Replace it with some information about the removed part."
4646 (gnus-article-check-buffer)
4647 (when (gnus-group-read-only-p)
4648 (error "The current group does not support deleting of parts"))
4649 (when (mm-complicated-handles gnus-article-mime-handles)
4651 The current article has a complicated MIME structure, giving up..."))
4652 (when (or gnus-expert-user
4653 (gnus-yes-or-no-p "\
4654 Deleting parts may malfunction or destroy the article; continue? "))
4655 (let* ((data (get-text-property (point) 'gnus-data))
4656 (id (get-text-property (point) 'gnus-part))
4657 (handles gnus-article-mime-handles)
4661 (mail-decode-encoded-word-string (or (mm-handle-description data)
4664 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4666 (type (mm-handle-media-type data)))
4668 (error "No MIME part under point"))
4669 (with-current-buffer (mm-handle-buffer data)
4670 (let ((bsize (format "%s" (buffer-size))))
4675 "| The following attachment has been deleted:\n"
4677 "| Type: " type "\n"
4678 "| Filename: " filename "\n"
4679 "| Size (encoded): " bsize " Byte\n"
4680 "| Description: " description "\n"
4683 (cdr (mm-make-handle
4684 nil `("text/plain") nil nil
4686 (format "Deleted attachment (%s bytes)" bsize))))))
4687 ;; (set-buffer gnus-summary-buffer)
4688 (gnus-article-edit-part handles id))))
4690 (defun gnus-mime-save-part ()
4691 "Save the MIME part under point."
4693 (gnus-article-check-buffer)
4694 (let ((data (get-text-property (point) 'gnus-data)))
4696 (mm-save-part data))))
4698 (defun gnus-mime-pipe-part ()
4699 "Pipe the MIME part under point to a process."
4701 (gnus-article-check-buffer)
4702 (let ((data (get-text-property (point) 'gnus-data)))
4704 (mm-pipe-part data))))
4706 (defun gnus-mime-view-part ()
4707 "Interactively choose a viewing method for the MIME part under point."
4709 (gnus-article-check-buffer)
4710 (let ((data (get-text-property (point) 'gnus-data)))
4712 (setq gnus-article-mime-handles
4714 gnus-article-mime-handles (setq data (copy-sequence data))))
4715 (mm-interactively-view-part data))))
4717 (defun gnus-mime-view-part-as-type-internal ()
4718 (gnus-article-check-buffer)
4719 (let* ((handle (get-text-property (point) 'gnus-data))
4721 ;; Content-Type: foo/bar; name=...
4722 (mail-content-type-get (mm-handle-type handle) 'name)
4723 ;; Content-Disposition: attachment; filename=...
4724 (cdr (assq 'filename (cdr (mm-handle-disposition handle))))))
4725 (def-type (and name (mm-default-file-encoding name))))
4726 (and def-type (cons def-type 0))))
4728 (defun gnus-mime-view-part-as-type (&optional mime-type)
4729 "Choose a MIME media type, and view the part as such."
4733 (let ((default (gnus-mime-view-part-as-type-internal)))
4735 (format "View as MIME type (default %s): "
4737 (mapcar #'list (mailcap-mime-types))
4740 (gnus-article-check-buffer)
4741 (let ((handle (get-text-property (point) 'gnus-data)))
4744 (mm-make-handle (mm-handle-buffer handle)
4745 (cons mime-type (cdr (mm-handle-type handle)))
4746 (mm-handle-encoding handle)
4747 (mm-handle-undisplayer handle)
4748 (mm-handle-disposition handle)
4749 (mm-handle-description handle)
4751 (mm-handle-id handle)))
4752 (setq gnus-article-mime-handles
4753 (mm-merge-handles gnus-article-mime-handles handle))
4754 (gnus-mm-display-part handle))))
4756 (defun gnus-mime-copy-part (&optional handle arg)
4757 "Put the MIME part under point into a new buffer.
4758 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4760 (interactive (list nil current-prefix-arg))
4761 (gnus-article-check-buffer)
4763 (setq handle (get-text-property (point) 'gnus-data)))
4765 (let ((filename (or (mail-content-type-get (mm-handle-disposition handle)
4767 (mail-content-type-get (mm-handle-disposition handle)
4769 contents dont-decode charset coding-system)
4770 (mm-with-unibyte-buffer
4771 (mm-insert-part handle)
4772 (setq contents (or (condition-case nil
4773 (mm-decompress-buffer filename nil 'sig)
4775 (setq dont-decode t)
4778 (setq filename (cond (filename (file-name-nondirectory filename))
4779 (dont-decode "*raw data*")
4784 (unless (setq charset (mail-content-type-get
4785 (mm-handle-type handle) 'charset))
4786 (unless (setq coding-system (mm-with-unibyte-buffer
4788 (mm-find-buffer-file-coding-system)))
4789 (setq charset gnus-newsgroup-charset))))
4791 (setq charset (or (cdr (assq arg
4792 gnus-summary-show-article-charset-alist))
4793 (mm-read-coding-system "Charset: ")))))
4794 (switch-to-buffer (generate-new-buffer filename))
4795 (if (or coding-system
4797 (setq coding-system (mm-charset-to-coding-system charset))
4798 (not (eq charset 'ascii))))
4800 (mm-enable-multibyte)
4801 (insert (mm-decode-coding-string contents coding-system))
4802 (setq buffer-file-coding-system
4803 (if (boundp 'last-coding-system-used)
4804 (symbol-value 'last-coding-system-used)
4806 (mm-disable-multibyte)
4808 (setq buffer-file-coding-system mm-binary-coding-system))
4809 ;; We do it this way to make `normal-mode' set the appropriate mode.
4812 (setq buffer-file-name (expand-file-name filename))
4814 (setq buffer-file-name nil))
4815 (goto-char (point-min)))))
4817 (defun gnus-mime-print-part (&optional handle filename)
4818 "Print the MIME part under point."
4819 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4820 (gnus-article-check-buffer)
4821 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4822 (contents (and handle (mm-get-part handle)))
4823 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4824 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4829 (mm-save-part-to-file handle file)
4830 (call-process shell-file-name nil
4831 (generate-new-buffer " *mm*")
4833 shell-command-switch
4835 printer file (mm-handle-type handle))))
4839 (gnus-print-buffer))
4840 (ps-despool filename)))))
4842 (defun gnus-mime-inline-part (&optional handle arg)
4843 "Insert the MIME part under point into the current buffer.
4844 Compressed files like .gz and .bz2 are decompressed."
4845 (interactive (list nil current-prefix-arg))
4846 (gnus-article-check-buffer)
4848 (setq handle (get-text-property (point) 'gnus-data)))
4851 (inhibit-read-only t)
4852 contents charset coding-system)
4853 (if (and (not arg) (mm-handle-undisplayer handle))
4854 (mm-remove-part handle)
4855 (mm-with-unibyte-buffer
4856 (mm-insert-part handle)
4858 (or (mm-decompress-buffer
4859 (or (mail-content-type-get (mm-handle-disposition handle)
4861 (mail-content-type-get (mm-handle-disposition handle)
4867 (unless (setq charset (mail-content-type-get
4868 (mm-handle-type handle) 'charset))
4869 (unless (setq coding-system
4870 (mm-with-unibyte-buffer
4872 (mm-find-buffer-file-coding-system)))
4873 (setq charset gnus-newsgroup-charset))))
4875 (if (mm-handle-undisplayer handle)
4876 (mm-remove-part handle))
4879 gnus-summary-show-article-charset-alist))
4880 (mm-read-coding-system "Charset: "))))
4882 (if (mm-handle-undisplayer handle)
4883 (mm-remove-part handle))))
4887 (if (or coding-system
4890 (mm-charset-to-coding-system charset))
4891 (not (eq coding-system 'ascii))))
4892 (mm-decode-coding-string contents coding-system)
4893 (mm-string-to-multibyte contents)))
4896 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4897 "Insert the MIME part under point into the current buffer using the
4899 (interactive (list nil current-prefix-arg))
4900 (gnus-article-check-buffer)
4901 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4904 (inhibit-read-only t))
4906 (if (mm-handle-undisplayer handle)
4907 (mm-remove-part handle))
4908 (let ((gnus-newsgroup-charset
4910 gnus-summary-show-article-charset-alist))
4911 (mm-read-coding-system "Charset: ")))
4912 (gnus-newsgroup-ignored-charsets 'gnus-all))
4913 (gnus-article-press-button)))))
4915 (defun gnus-mime-view-part-externally (&optional handle)
4916 "View the MIME part under point with an external viewer."
4918 (gnus-article-check-buffer)
4919 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4920 (mm-user-display-methods nil)
4921 (mm-inlined-types nil)
4922 (mail-parse-charset gnus-newsgroup-charset)
4923 (mail-parse-ignored-charsets
4924 (with-current-buffer gnus-summary-buffer
4925 gnus-newsgroup-ignored-charsets)))
4927 (if (mm-handle-undisplayer handle)
4928 (mm-remove-part handle)
4929 (mm-display-part handle)))))
4931 (defun gnus-mime-view-part-internally (&optional handle)
4932 "View the MIME part under point with an internal viewer.
4933 If no internal viewer is available, use an external viewer."
4935 (gnus-article-check-buffer)
4936 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4937 (mm-inlined-types '(".*"))
4938 (mm-inline-large-images t)
4939 (mail-parse-charset gnus-newsgroup-charset)
4940 (mail-parse-ignored-charsets
4941 (with-current-buffer gnus-summary-buffer
4942 gnus-newsgroup-ignored-charsets))
4943 (inhibit-read-only t))
4945 (if (mm-handle-undisplayer handle)
4946 (mm-remove-part handle)
4947 (mm-display-part handle)))))
4949 (defun gnus-mime-action-on-part (&optional action)
4950 "Do something with the MIME attachment at \(point\)."
4952 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4953 (gnus-article-check-buffer)
4954 (let ((action-pair (assoc action gnus-mime-action-alist)))
4956 (funcall (cdr action-pair)))))
4958 (defun gnus-article-part-wrapper (n function &optional no-handle interactive)
4959 "Call FUNCTION on MIME part N.
4960 Unless NO-HANDLE, call FUNCTION with N-th MIME handle as it's only argument.
4961 If INTERACTIVE, call FUNCTION interactivly."
4963 ;; Check whether the article is displayed.
4964 (unless (and (gnus-buffer-live-p gnus-article-buffer)
4965 (setq window (get-buffer-window gnus-article-buffer t))
4966 (frame-visible-p (setq frame (window-frame window))))
4967 (error "No article is displayed"))
4968 (with-current-buffer gnus-article-buffer
4969 ;; Check whether the article displays the right contents.
4970 (unless (with-current-buffer gnus-summary-buffer
4971 (eq gnus-current-article (gnus-summary-article-number)))
4972 (error "You should select the right article first"))
4973 ;; Check whether the specified part exists.
4974 (when (> n (length gnus-article-mime-handle-alist))
4975 (error "No such part")))
4978 ;; To select the window is needed so that the cursor
4979 ;; might be visible on the MIME button.
4980 (select-window (prog1
4982 (setq window (selected-window))
4983 ;; Article may be displayed in the other frame.
4984 (gnus-select-frame-set-input-focus
4987 (setq frame (selected-frame))))))
4988 (when (gnus-article-goto-part n)
4989 ;; We point the cursor and the arrow at the MIME button
4990 ;; when the `function' prompt the user for something.
4991 (let ((cursor-in-non-selected-windows t)
4992 (overlay-arrow-string "=>")
4993 (overlay-arrow-position (point-marker)))
4996 ((and no-handle interactive)
4997 (call-interactively function))
5003 (cdr (assq n gnus-article-mime-handle-alist))))
5006 (cdr (assq n gnus-article-mime-handle-alist)))))
5007 (set-marker overlay-arrow-position nil)
5008 (unless gnus-auto-select-part
5009 (gnus-select-frame-set-input-focus frame)
5010 (select-window window))))
5012 (if gnus-inhibit-mime-unbuttonizing
5013 ;; This is the default though the program shouldn't reach here.
5014 (error "No such part")
5015 ;; The part which doesn't have the MIME button is selected.
5016 ;; So, we display all the buttons and redo it.
5017 (let ((gnus-inhibit-mime-unbuttonizing t))
5018 (gnus-summary-show-article)
5019 (gnus-article-part-wrapper n function no-handle))))))
5021 (defun gnus-article-pipe-part (n)
5022 "Pipe MIME part N, which is the numerical prefix."
5024 (gnus-article-part-wrapper n 'mm-pipe-part))
5026 (defun gnus-article-save-part (n)
5027 "Save MIME part N, which is the numerical prefix."
5029 (gnus-article-part-wrapper n 'mm-save-part))
5031 (defun gnus-article-interactively-view-part (n)
5032 "View MIME part N interactively, which is the numerical prefix."
5034 (gnus-article-part-wrapper n 'mm-interactively-view-part))
5036 (defun gnus-article-copy-part (n)
5037 "Copy MIME part N, which is the numerical prefix."
5039 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
5041 (defun gnus-article-view-part-as-charset (n)
5042 "View MIME part N using a specified charset.
5043 N is the numerical prefix."
5045 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
5047 (defun gnus-article-view-part-externally (n)
5048 "View MIME part N externally, which is the numerical prefix."
5050 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
5052 (defun gnus-article-inline-part (n)
5053 "Inline MIME part N, which is the numerical prefix."
5055 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
5057 (defun gnus-article-save-part-and-strip (n)
5058 "Save MIME part N and replace it with an external body.
5059 N is the numerical prefix."
5061 (gnus-article-part-wrapper n 'gnus-mime-save-part-and-strip t))
5063 (defun gnus-article-replace-part (n)
5064 "Replace MIME part N with an external body.
5065 N is the numerical prefix."
5067 (gnus-article-part-wrapper n 'gnus-mime-replace-part t t))
5069 (defun gnus-article-delete-part (n)
5070 "Delete MIME part N and add some information about the removed part.
5071 N is the numerical prefix."
5073 (gnus-article-part-wrapper n 'gnus-mime-delete-part t))
5075 (defun gnus-article-mime-match-handle-first (condition)
5078 (dolist (ihandle gnus-article-mime-handle-alist)
5080 ((functionp condition)
5081 (funcall condition (cdr ihandle)))
5082 ((eq condition 'undisplayed)
5083 (not (or (mm-handle-undisplayer (cdr ihandle))
5084 (equal (mm-handle-media-type (cdr ihandle))
5085 "multipart/alternative"))))
5086 ((eq condition 'undisplayed-alternative)
5087 (not (mm-handle-undisplayer (cdr ihandle))))
5089 (gnus-article-goto-part (car ihandle))
5090 (or (not n) (< (car ihandle) n)))
5091 (setq n (car ihandle))))
5095 (defun gnus-article-view-part (&optional n)
5096 "View MIME part N, which is the numerical prefix."
5098 (with-current-buffer gnus-article-buffer
5099 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
5100 gnus-article-mime-match-handle-function)))
5101 (when (> n (length gnus-article-mime-handle-alist))
5102 (error "No such part"))
5103 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
5104 (when (gnus-article-goto-part n)
5105 (if (equal (car handle) "multipart/alternative")
5106 (gnus-article-press-button)
5107 (when (eq (gnus-mm-display-part handle) 'internal)
5108 (gnus-set-window-start)))))))
5110 (defsubst gnus-article-mime-total-parts ()
5111 (if (bufferp (car gnus-article-mime-handles))
5113 (1- (length gnus-article-mime-handles))))
5115 (defun gnus-mm-display-part (handle)
5116 "Display HANDLE and fix MIME button."
5117 (let ((id (get-text-property (point) 'gnus-part))
5119 (inhibit-read-only t))
5122 (let ((window (selected-window))
5123 (mail-parse-charset gnus-newsgroup-charset)
5124 (mail-parse-ignored-charsets
5125 (if (gnus-buffer-live-p gnus-summary-buffer)
5126 (with-current-buffer gnus-summary-buffer
5127 gnus-newsgroup-ignored-charsets)
5131 (let ((win (gnus-get-buffer-window (current-buffer) t))
5134 (select-window win))
5137 (if (mm-handle-displayed-p handle)
5138 ;; This will remove the part.
5139 (mm-display-part handle)
5141 (narrow-to-region (point)
5142 (if (eobp) (point) (1+ (point))))
5143 (mm-display-part handle)
5144 ;; We narrow to the part itself and
5145 ;; then call the treatment functions.
5146 (goto-char (point-min))
5148 (narrow-to-region (point) (point-max))
5151 (gnus-article-mime-total-parts)
5152 (mm-handle-media-type handle)))))
5153 (if (window-live-p window)
5154 (select-window window)))))
5157 (gnus-insert-mime-button
5158 handle id (list (mm-handle-displayed-p handle)))
5159 (goto-char point))))
5161 (defun gnus-article-goto-part (n)
5162 "Go to MIME part N."
5163 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
5165 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
5166 (let ((gnus-tmp-name
5167 (or (mail-content-type-get (mm-handle-type handle) 'name)
5168 (mail-content-type-get (mm-handle-disposition handle) 'filename)
5169 (mail-content-type-get (mm-handle-type handle) 'url)
5171 (gnus-tmp-type (mm-handle-media-type handle))
5172 (gnus-tmp-description
5173 (mail-decode-encoded-word-string (or (mm-handle-description handle)
5176 (if (if displayed (car displayed)
5177 (mm-handle-displayed-p handle))
5179 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
5181 gnus-tmp-type-long b e)
5182 (when (string-match ".*/" gnus-tmp-name)
5183 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
5184 (setq gnus-tmp-type-long (concat gnus-tmp-type
5185 (and (not (equal gnus-tmp-name ""))
5186 (concat "; " gnus-tmp-name))))
5187 (unless (equal gnus-tmp-description "")
5188 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
5193 gnus-mime-button-line-format gnus-mime-button-line-format-alist
5194 `(keymap ,gnus-mime-button-map
5195 gnus-callback gnus-mm-display-part
5196 gnus-part ,gnus-tmp-id
5197 article-type annotation
5200 ;; Exclude a newline.
5203 (widget-convert-button
5206 :action 'gnus-widget-press-button
5207 :button-keymap gnus-mime-button-map
5209 (lambda (widget/window &optional overlay pos)
5210 ;; Needed to properly clear the message due to a bug in
5211 ;; wid-edit (XEmacs only).
5212 (if (boundp 'help-echo-owns-message)
5213 (setq help-echo-owns-message t))
5215 "%S: %s the MIME part; %S: more options"
5216 (aref gnus-mouse-2 0)
5217 ;; XEmacs will get a single widget arg; Emacs 21 will get
5218 ;; window, overlay, position.
5219 (if (mm-handle-displayed-p
5221 (with-current-buffer (gnus-overlay-buffer overlay)
5222 (widget-get (widget-at (gnus-overlay-start overlay))
5224 (widget-get widget/window :mime-handle)))
5226 (aref gnus-down-mouse-3 0))))))
5228 (defun gnus-widget-press-button (elems el)
5229 (goto-char (widget-get elems :from))
5230 (gnus-article-press-button))
5232 (defvar gnus-displaying-mime nil)
5234 (defun gnus-display-mime (&optional ihandles)
5235 "Display the MIME parts."
5237 (save-selected-window
5238 (let ((window (get-buffer-window gnus-article-buffer))
5241 (select-window window)
5242 ;; We have to do this since selecting the window
5243 ;; may change the point. So we set the window point.
5244 (set-window-point window point)))
5245 (let ((handles ihandles)
5246 (inhibit-read-only t)
5249 ((setq handles (mm-dissect-buffer nil gnus-article-loose-mime))
5250 (when gnus-article-emulate-mime
5251 (mm-uu-dissect-text-parts handles)))
5252 (gnus-article-emulate-mime
5253 (setq handles (mm-uu-dissect))))
5254 (when (and (not ihandles)
5255 (not gnus-displaying-mime))
5256 ;; Top-level call; we clean up.
5257 (when gnus-article-mime-handles
5258 (mm-destroy-parts gnus-article-mime-handles)
5259 (setq gnus-article-mime-handle-alist nil));; A trick.
5260 (setq gnus-article-mime-handles handles)
5261 ;; We allow users to glean info from the handles.
5262 (when gnus-article-mime-part-function
5263 (gnus-mime-part-function handles)))
5265 (or (not (stringp (car handles)))
5268 (when (and (not ihandles)
5269 (not gnus-displaying-mime))
5270 ;; Clean up for mime parts.
5272 (delete-region (point) (point-max)))
5273 (let ((gnus-displaying-mime t))
5274 (gnus-mime-display-part handles)))
5277 (narrow-to-region (point) (point-max))
5278 (gnus-treat-article nil 1 1)
5281 ;; Highlight the headers.
5285 (narrow-to-region (point-min) (point))
5286 (gnus-article-save-original-date
5287 (gnus-treat-article 'head)))))))))
5289 (defcustom gnus-mime-display-multipart-as-mixed nil
5290 "Display \"multipart\" parts as \"multipart/mixed\".
5292 If t, it overrides nil values of
5293 `gnus-mime-display-multipart-alternative-as-mixed' and
5294 `gnus-mime-display-multipart-related-as-mixed'."
5295 :group 'gnus-article-mime
5298 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
5299 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
5301 :group 'gnus-article-mime
5304 (defcustom gnus-mime-display-multipart-related-as-mixed nil
5305 "Display \"multipart/related\" parts as \"multipart/mixed\".
5307 If displaying \"text/html\" is discouraged \(see
5308 `mm-discouraged-alternatives'\) images or other material inside a
5309 \"multipart/related\" part might be overlooked when this variable is nil."
5311 :group 'gnus-article-mime
5314 (defun gnus-mime-display-part (handle)
5316 ;; Maybe a broken MIME message.
5319 ((not (stringp (car handle)))
5320 (gnus-mime-display-single handle))
5321 ;; User-defined multipart
5322 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
5323 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
5325 ;; multipart/alternative
5326 ((and (equal (car handle) "multipart/alternative")
5327 (not (or gnus-mime-display-multipart-as-mixed
5328 gnus-mime-display-multipart-alternative-as-mixed)))
5329 (let ((id (1+ (length gnus-article-mime-handle-alist))))
5330 (push (cons id handle) gnus-article-mime-handle-alist)
5331 (gnus-mime-display-alternative (cdr handle) nil nil id)))
5332 ;; multipart/related
5333 ((and (equal (car handle) "multipart/related")
5334 (not (or gnus-mime-display-multipart-as-mixed
5335 gnus-mime-display-multipart-related-as-mixed)))
5336 ;;;!!!We should find the start part, but we just default
5337 ;;;!!!to the first part.
5338 ;;(gnus-mime-display-part (cadr handle))
5339 ;;;!!! Most multipart/related is an HTML message plus images.
5340 ;;;!!! Unfortunately we are unable to let W3 display those
5341 ;;;!!! included images, so we just display it as a mixed multipart.
5342 ;;(gnus-mime-display-mixed (cdr handle))
5343 ;;;!!! No, w3 can display everything just fine.
5344 (gnus-mime-display-part (cadr handle)))
5345 ((equal (car handle) "multipart/signed")
5346 (gnus-add-wash-type 'signed)
5347 (gnus-mime-display-security handle))
5348 ((equal (car handle) "multipart/encrypted")
5349 (gnus-add-wash-type 'encrypted)
5350 (gnus-mime-display-security handle))
5351 ;; Other multiparts are handled like multipart/mixed.
5353 (gnus-mime-display-mixed (cdr handle)))))
5355 (defun gnus-mime-part-function (handles)
5356 (if (stringp (car handles))
5357 (mapcar 'gnus-mime-part-function (cdr handles))
5358 (funcall gnus-article-mime-part-function handles)))
5360 (defun gnus-mime-display-mixed (handles)
5361 (mapcar 'gnus-mime-display-part handles))
5363 (defun gnus-mime-display-single (handle)
5364 (let ((type (mm-handle-media-type handle))
5365 (ignored gnus-ignored-mime-types)
5372 (when (string-match (pop ignored) type)
5373 (throw 'ignored nil)))
5374 (if (and (setq not-attachment
5375 (and (not (mm-inline-override-p handle))
5376 (or (not (mm-handle-disposition handle))
5377 (equal (car (mm-handle-disposition handle))
5379 (mm-attachment-override-p handle))))
5380 (mm-automatic-display-p handle)
5382 (mm-inlinable-p handle)
5383 (mm-inlined-p handle))
5384 (mm-automatic-external-display-p type)))
5386 (when (equal (mm-handle-media-supertype handle) "text")
5388 (let ((id (1+ (length gnus-article-mime-handle-alist)))
5390 (push (cons id handle) gnus-article-mime-handle-alist)
5391 (when (or (not display)
5392 (not (gnus-unbuttonized-mime-type-p type)))
5393 (gnus-insert-mime-button
5394 handle id (list (or display (and not-attachment text))))
5395 (gnus-article-insert-newline)
5396 ;; Remember modify the number of forward lines.
5404 (let ((mail-parse-charset gnus-newsgroup-charset)
5405 (mail-parse-ignored-charsets
5406 (save-excursion (condition-case ()
5407 (set-buffer gnus-summary-buffer)
5409 gnus-newsgroup-ignored-charsets)))
5410 (mm-display-part handle t))
5411 (goto-char (point-max)))
5412 ((and text not-attachment)
5416 (gnus-article-insert-newline)
5419 (let ((charset (mail-content-type-get (mm-handle-type handle)
5421 (cond ((not charset)
5422 (mm-string-as-multibyte (mm-get-part handle)))
5423 ((eq charset 'gnus-decoded)
5424 (with-current-buffer (mm-handle-buffer handle)
5427 (mm-decode-string (mm-get-part handle) charset)))))
5428 (goto-char (point-max))))
5432 (narrow-to-region beg (point))
5435 (gnus-article-mime-total-parts)
5436 (mm-handle-media-type handle)))))))))
5438 (defun gnus-unbuttonized-mime-type-p (type)
5439 "Say whether TYPE is to be unbuttonized."
5440 (unless gnus-inhibit-mime-unbuttonizing
5442 (let ((types gnus-unbuttonized-mime-types))
5444 (when (string-match (pop types) type)
5445 (throw 'found t)))))
5447 (let ((types gnus-buttonized-mime-types))
5449 (when (string-match (pop types) type)
5450 (throw 'found t)))))))))
5452 (defun gnus-article-insert-newline ()
5453 "Insert a newline, but mark it as undeletable."
5454 (gnus-put-text-property
5455 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
5457 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
5458 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
5461 handle (inhibit-read-only t) from props begend not-pref)
5462 (save-window-excursion
5465 (narrow-to-region (car ibegend)
5468 (goto-char (car ibegend))
5471 (delete-region (point-min) (point-max))
5472 (mm-remove-parts handles))
5473 (setq begend (list (point-marker)))
5475 (unless (setq not-pref (cadr (member preferred ihandles)))
5476 (setq not-pref (car ihandles)))
5479 (not (gnus-unbuttonized-mime-type-p
5480 "multipart/alternative")))
5481 (gnus-add-text-properties
5484 (insert (format "%d. " id))
5488 (unless ,(not ibegend)
5489 (setq gnus-article-mime-handle-alist
5490 ',gnus-article-mime-handle-alist))
5491 (gnus-mime-display-alternative
5492 ',ihandles ',not-pref ',begend ,id))
5493 keymap ,gnus-mime-button-map
5494 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5495 face ,gnus-article-button-face
5497 article-type multipart))
5498 (widget-convert-button 'link from (point)
5499 :action 'gnus-widget-press-button
5500 :button-keymap gnus-widget-button-keymap)
5502 (while (setq handle (pop handles))
5503 (gnus-add-text-properties
5506 (insert (format "(%c) %-18s"
5507 (if (equal handle preferred) ?* ? )
5508 (mm-handle-media-type handle)))
5512 (unless ,(not ibegend)
5513 (setq gnus-article-mime-handle-alist
5514 ',gnus-article-mime-handle-alist))
5515 (gnus-mime-display-alternative
5516 ',ihandles ',handle ',begend ,id))
5517 keymap ,gnus-mime-button-map
5518 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5519 face ,gnus-article-button-face
5522 (widget-convert-button 'link from (point)
5523 :action 'gnus-widget-press-button
5524 :button-keymap gnus-widget-button-keymap)
5528 (if (stringp (car preferred))
5529 (gnus-display-mime preferred)
5530 (let ((mail-parse-charset gnus-newsgroup-charset)
5531 (mail-parse-ignored-charsets
5532 (with-current-buffer gnus-summary-buffer
5533 gnus-newsgroup-ignored-charsets)))
5534 (mm-display-part preferred)
5538 (narrow-to-region (car begend) (point-max))
5540 nil (length gnus-article-mime-handle-alist)
5541 (gnus-article-mime-total-parts)
5542 (mm-handle-media-type handle))))))
5543 (goto-char (point-max))
5544 (setcdr begend (point-marker)))))
5546 (goto-char point))))
5548 (defconst gnus-article-wash-status-strings
5549 (let ((alist '((cite "c" "Possible hidden citation text"
5550 " " "All citation text visible")
5551 (headers "h" "Hidden headers"
5552 " " "All headers visible.")
5553 (pgp "p" "Encrypted or signed message status hidden"
5554 " " "No hidden encryption nor digital signature status")
5555 (signature "s" "Signature has been hidden"
5556 " " "Signature is visible")
5557 (overstrike "o" "Overstrike (^H) characters applied"
5558 " " "No overstrike characters applied")
5559 (gnus-show-mime "m" "Mime processing is activated"
5560 " " "Mime processing is not activated")
5561 (emphasis "e" "/*_Emphasis_*/ characters applied"
5562 " " "No /*_emphasis_*/ characters applied")))
5564 (dolist (entry alist result)
5565 (let ((key (nth 0 entry))
5566 (on (copy-sequence (nth 1 entry)))
5567 (on-help (nth 2 entry))
5568 (off (copy-sequence (nth 3 entry)))
5569 (off-help (nth 4 entry)))
5570 (put-text-property 0 1 'help-echo on-help on)
5571 (put-text-property 0 1 'help-echo off-help off)
5572 (push (list key on off) result))))
5573 "Alist of strings describing wash status in the mode line.
5574 Each entry has the form (KEY ON OF), where the KEY is a symbol
5575 representing the particular washing function, ON is the string to use
5576 in the article mode line when the washing function is active, and OFF
5577 is the string to use when it is inactive.")
5579 (defun gnus-article-wash-status-entry (key value)
5580 (let ((entry (assoc key gnus-article-wash-status-strings)))
5581 (if value (nth 1 entry) (nth 2 entry))))
5583 (defun gnus-article-wash-status ()
5584 "Return a string which display status of article washing."
5585 (with-current-buffer gnus-article-buffer
5586 (let ((cite (memq 'cite gnus-article-wash-types))
5587 (headers (memq 'headers gnus-article-wash-types))
5588 (boring (memq 'boring-headers gnus-article-wash-types))
5589 (pgp (memq 'pgp gnus-article-wash-types))
5590 (pem (memq 'pem gnus-article-wash-types))
5591 (signed (memq 'signed gnus-article-wash-types))
5592 (encrypted (memq 'encrypted gnus-article-wash-types))
5593 (signature (memq 'signature gnus-article-wash-types))
5594 (overstrike (memq 'overstrike gnus-article-wash-types))
5595 (emphasis (memq 'emphasis gnus-article-wash-types)))
5597 (gnus-article-wash-status-entry 'cite cite)
5598 (gnus-article-wash-status-entry 'headers (or headers boring))
5599 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5600 (gnus-article-wash-status-entry 'signature signature)
5601 (gnus-article-wash-status-entry 'overstrike overstrike)
5602 (gnus-article-wash-status-entry 'gnus-show-mime gnus-show-mime)
5603 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5605 (defun gnus-add-wash-type (type)
5606 "Add a washing of TYPE to the current status."
5607 (add-to-list 'gnus-article-wash-types type))
5609 (defun gnus-delete-wash-type (type)
5610 "Add a washing of TYPE to the current status."
5611 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5613 (defun gnus-add-image (category image)
5614 "Add IMAGE of CATEGORY to the list of displayed images."
5615 (let ((entry (assq category gnus-article-image-alist)))
5617 (setq entry (list category))
5618 (push entry gnus-article-image-alist))
5619 (nconc entry (list image))))
5621 (defun gnus-delete-images (category)
5622 "Delete all images in CATEGORY."
5623 (let ((entry (assq category gnus-article-image-alist)))
5624 (dolist (image (cdr entry))
5625 (gnus-remove-image image category))
5626 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5627 (gnus-delete-wash-type category)))
5629 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5631 (defun gnus-article-maybe-hide-headers ()
5632 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5633 Provided for backwards compatibility."
5634 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5635 (not (with-current-buffer gnus-summary-buffer
5636 gnus-have-all-headers)))
5637 (not gnus-inhibit-hiding))
5638 (gnus-article-hide-headers)))
5642 (defun gnus-output-to-file (file-name)
5643 "Append the current article to a file named FILE-NAME."
5644 (let ((artbuf (current-buffer)))
5646 (insert-buffer-substring artbuf)
5647 ;; Append newline at end of the buffer as separator, and then
5649 (goto-char (point-max))
5651 (let ((file-name-coding-system nnmail-pathname-coding-system))
5652 (write-region-as-binary (point-min) (point-max) file-name 'append))
5655 (defun gnus-narrow-to-page (&optional arg)
5656 "Narrow the article buffer to a page.
5657 If given a numerical ARG, move forward ARG pages."
5659 (setq arg (if arg (prefix-numeric-value arg) 0))
5661 (set-buffer gnus-article-buffer)
5662 (goto-char (point-min))
5664 ;; Remove any old next/prev buttons.
5665 (when (gnus-visual-p 'page-marker)
5666 (let ((inhibit-read-only t))
5667 (gnus-remove-text-with-property 'gnus-prev)
5668 (gnus-remove-text-with-property 'gnus-next)))
5671 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5673 (re-search-forward page-delimiter nil 'move arg)))
5674 (goto-char (match-end 0))
5676 (goto-char (point-min))
5677 (setq gnus-page-broken
5678 (and (re-search-forward page-delimiter nil t) t))))
5679 (when gnus-page-broken
5682 (if (re-search-forward page-delimiter nil 'move)
5685 (when (and (gnus-visual-p 'page-marker)
5686 (> (point-min) (save-restriction (widen) (point-min))))
5688 (goto-char (point-min))
5689 (gnus-insert-prev-page-button)))
5690 (when (and (gnus-visual-p 'page-marker)
5691 (< (point-max) (save-restriction (widen) (point-max))))
5693 (goto-char (point-max))
5694 (gnus-insert-next-page-button))))))
5696 ;; Article mode commands
5698 (defun gnus-article-goto-next-page ()
5699 "Show the next page of the article."
5701 (when (gnus-article-next-page)
5702 (goto-char (point-min))
5703 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5706 (defun gnus-article-goto-prev-page ()
5707 "Show the previous page of the article."
5710 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5711 (gnus-article-prev-page nil)))
5713 ;; This is cleaner but currently breaks `gnus-pick-mode':
5715 ;; (defun gnus-article-goto-next-page ()
5716 ;; "Show the next page of the article."
5718 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5719 ;; (gnus-summary-next-page)))
5721 ;; (defun gnus-article-goto-prev-page ()
5722 ;; "Show the next page of the article."
5724 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5725 ;; (gnus-summary-prev-page)))
5727 (defun gnus-article-next-page (&optional lines)
5728 "Show the next page of the current article.
5729 If end of article, return non-nil. Otherwise return nil.
5730 Argument LINES specifies lines to be scrolled up."
5732 (move-to-window-line -1)
5735 (and (pos-visible-in-window-p) ;Not continuation line.
5736 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5737 ;; Nothing in this page.
5738 (if (or (not gnus-page-broken)
5743 (eobp)))) ;Real end-of-buffer?
5745 (when gnus-article-over-scroll
5746 (gnus-article-next-page-1 lines))
5748 (gnus-narrow-to-page 1) ;Go to next page.
5750 ;; More in this page.
5751 (gnus-article-next-page-1 lines)
5754 (defmacro gnus-article-beginning-of-window ()
5755 "Move point to the beginning of the window.
5756 In Emacs, the point is placed at the line number which `scroll-margin'
5758 (if (featurep 'xemacs)
5759 '(move-to-window-line 0)
5760 '(move-to-window-line
5761 (min (max 0 scroll-margin)
5762 (max 1 (- (window-height)
5763 (if mode-line-format 1 0)
5764 (if header-line-format 1 0)))))))
5766 (defun gnus-article-next-page-1 (lines)
5767 (when (and (not (featurep 'xemacs))
5770 (numberp (symbol-value 'scroll-margin))
5771 (> (symbol-value 'scroll-margin) 0))
5772 ;; Protect against the bug that Emacs 21.x hangs up when scrolling up for
5773 ;; too many number of lines if `scroll-margin' is set as two or greater.
5774 (setq lines (min lines
5775 (max 0 (- (count-lines (window-start) (point-max))
5776 (symbol-value 'scroll-margin))))))
5778 (let ((scroll-in-place nil))
5781 ;; Long lines may cause an end-of-buffer error.
5782 (goto-char (point-max))))
5783 (gnus-article-beginning-of-window))
5785 (defun gnus-article-prev-page (&optional lines)
5786 "Show previous page of current article.
5787 Argument LINES specifies lines to be scrolled down."
5789 (move-to-window-line 0)
5790 (if (and gnus-page-broken
5792 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5794 (gnus-narrow-to-page -1) ;Go to previous page.
5795 (goto-char (point-max))
5799 (let ((scroll-in-place nil))
5800 (scroll-down lines))
5801 (beginning-of-buffer
5802 (goto-char (point-min))))
5803 (gnus-article-beginning-of-window))))
5805 (defun gnus-article-only-boring-p ()
5806 "Decide whether there is only boring text remaining in the article.
5807 Something \"interesting\" is a word of at least two letters that does
5808 not have a face in `gnus-article-boring-faces'."
5809 (when (and gnus-article-skip-boring
5810 (boundp 'gnus-article-boring-faces)
5811 (symbol-value 'gnus-article-boring-faces))
5814 (while (re-search-forward "\\b\\w\\w" nil t)
5816 (when (not (gnus-intersection
5817 (gnus-faces-at (point))
5818 (symbol-value 'gnus-article-boring-faces)))
5819 (throw 'only-boring nil)))
5820 (throw 'only-boring t)))))
5822 (defun gnus-article-refer-article ()
5823 "Read article specified by message-id around point."
5826 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
5827 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
5828 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
5829 (let ((msg-id (concat "<" (match-string 0) ">")))
5830 (set-buffer gnus-summary-buffer)
5831 (gnus-summary-refer-article msg-id))
5832 (error "No references around point"))))
5834 (defun gnus-article-show-summary ()
5835 "Reconfigure windows to show summary buffer."
5837 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5838 (error "There is no summary buffer for this article buffer")
5839 (gnus-article-set-globals)
5840 (gnus-configure-windows 'article)
5841 (gnus-summary-goto-subject gnus-current-article)
5842 (gnus-summary-position-point)))
5844 (defun gnus-article-describe-briefly ()
5845 "Describe article mode commands briefly."
5847 (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")))
5849 (defun gnus-article-summary-command ()
5850 "Execute the last keystroke in the summary buffer."
5852 (let ((obuf (current-buffer))
5853 (owin (current-window-configuration))
5855 (switch-to-buffer gnus-article-current-summary 'norecord)
5856 (setq func (lookup-key (current-local-map) (this-command-keys)))
5857 (call-interactively func)
5859 (set-window-configuration owin)
5860 (set-window-point (get-buffer-window (current-buffer)) (point))))
5862 (defun gnus-article-summary-command-nosave ()
5863 "Execute the last keystroke in the summary buffer."
5866 (pop-to-buffer gnus-article-current-summary 'norecord)
5867 (setq func (lookup-key (current-local-map) (this-command-keys)))
5868 (call-interactively func)))
5870 (defun gnus-article-check-buffer ()
5871 "Beep if not in an article buffer."
5872 (unless (eq (get-buffer gnus-article-buffer) (current-buffer))
5873 (error "Command invoked outside of a Gnus article buffer")))
5875 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5876 "Read a summary buffer key sequence and execute it from the article buffer."
5878 (gnus-article-check-buffer)
5880 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5881 "Zc" "ZC" "ZE" "ZJ" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5882 "=" "^" "\M-^" "|"))
5888 '("n" "Gn" "p" "Gp"))
5891 (set-buffer gnus-article-current-summary)
5892 (let (gnus-pick-mode)
5893 (push (or key last-command-event) unread-command-events)
5894 (setq keys (static-if (featurep 'xemacs)
5895 (events-to-keys (read-key-sequence nil))
5896 (read-key-sequence nil)))))
5899 (if (or (member keys nosaves)
5900 (member keys nosave-but-article)
5901 (member keys nosave-in-article))
5903 (save-window-excursion
5904 (pop-to-buffer gnus-article-current-summary 'norecord)
5905 ;; We disable the pick minor mode commands.
5906 (let (gnus-pick-mode)
5907 (setq func (lookup-key (current-local-map) keys))))
5911 (unless (member keys nosave-in-article)
5912 (set-buffer gnus-article-current-summary))
5913 (call-interactively func)
5914 (setq new-sum-point (point)))
5915 (when (member keys nosave-but-article)
5916 (pop-to-buffer gnus-article-buffer 'norecord)))
5917 ;; These commands should restore window configuration.
5918 (let ((obuf (current-buffer))
5919 (owin (current-window-configuration))
5921 win func in-buffer selected new-sum-start new-sum-hscroll)
5922 (cond (not-restore-window
5923 (pop-to-buffer gnus-article-current-summary 'norecord))
5924 ((setq win (get-buffer-window gnus-article-current-summary))
5925 (select-window win))
5927 (switch-to-buffer gnus-article-current-summary 'norecord)))
5928 (setq in-buffer (current-buffer))
5929 ;; We disable the pick minor mode commands.
5930 (if (and (setq func (let (gnus-pick-mode)
5931 (lookup-key (current-local-map) keys)))
5934 (call-interactively func)
5935 (when (eq win (selected-window))
5936 (setq new-sum-point (point)
5937 new-sum-start (window-start win)
5938 new-sum-hscroll (window-hscroll win)))
5939 (when (eq in-buffer (current-buffer))
5940 (setq selected (gnus-summary-select-article))
5942 (unless not-restore-window
5943 (set-window-configuration owin))
5944 (when (eq selected 'old)
5946 (set-window-start (get-buffer-window (current-buffer))
5948 (set-window-point (get-buffer-window (current-buffer))
5950 (when (and (not not-restore-window)
5952 (set-window-point win new-sum-point)
5953 (set-window-start win new-sum-start)
5954 (set-window-hscroll win new-sum-hscroll))))
5955 (set-window-configuration owin)
5958 (defun gnus-article-describe-key (key)
5959 "Display documentation of the function invoked by KEY. KEY is a string."
5960 (interactive "kDescribe key: ")
5961 (gnus-article-check-buffer)
5962 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5964 (set-buffer gnus-article-current-summary)
5965 (let (gnus-pick-mode)
5966 (if (featurep 'xemacs)
5968 (push (elt key 0) unread-command-events)
5969 (setq key (events-to-keys
5970 (read-key-sequence "Describe key: "))))
5971 (setq unread-command-events
5973 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5975 (setq key (read-key-sequence "Describe key: "))))
5977 (describe-key key)))
5979 (defun gnus-article-describe-key-briefly (key &optional insert)
5980 "Display documentation of the function invoked by KEY. KEY is a string."
5981 (interactive "kDescribe key: \nP")
5982 (gnus-article-check-buffer)
5983 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5985 (set-buffer gnus-article-current-summary)
5986 (let (gnus-pick-mode)
5987 (if (featurep 'xemacs)
5989 (push (elt key 0) unread-command-events)
5990 (setq key (events-to-keys
5991 (read-key-sequence "Describe key: "))))
5992 (setq unread-command-events
5994 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5996 (setq key (read-key-sequence "Describe key: "))))
5997 (describe-key-briefly key insert))
5998 (describe-key-briefly key insert)))
6000 (defun gnus-article-reply-with-original (&optional wide)
6001 "Start composing a reply mail to the current message.
6002 The text in the region will be yanked. If the region isn't active,
6003 the entire article will be yanked."
6005 (let ((article (cdr gnus-article-current))
6007 (if (not (gnus-region-active-p))
6008 (with-current-buffer gnus-summary-buffer
6009 (gnus-summary-reply (list (list article)) wide))
6010 (setq contents (buffer-substring (point) (mark t)))
6011 ;; Deactivate active regions.
6012 (when (and (boundp 'transient-mark-mode)
6013 transient-mark-mode)
6014 (setq mark-active nil))
6015 (with-current-buffer gnus-summary-buffer
6017 (list (list article contents)) wide)))))
6019 (defun gnus-article-followup-with-original ()
6020 "Compose a followup to the current article.
6021 The text in the region will be yanked. If the region isn't active,
6022 the entire article will be yanked."
6024 (let ((article (cdr gnus-article-current))
6026 (if (not (gnus-region-active-p))
6027 (with-current-buffer gnus-summary-buffer
6028 (gnus-summary-followup (list (list article))))
6029 (setq contents (buffer-substring (point) (mark t)))
6030 ;; Deactivate active regions.
6031 (when (and (boundp 'transient-mark-mode)
6032 transient-mark-mode)
6033 (setq mark-active nil))
6034 (with-current-buffer gnus-summary-buffer
6035 (gnus-summary-followup
6036 (list (list article contents)))))))
6038 (defun gnus-article-hide (&optional arg force)
6039 "Hide all the gruft in the current article.
6040 This means that signatures, cited text and (some) headers will be
6042 If given a prefix, show the hidden text instead."
6043 (interactive (append (gnus-article-hidden-arg) (list 'force)))
6044 (gnus-article-hide-headers arg)
6045 (gnus-article-hide-list-identifiers arg)
6046 (gnus-article-hide-citation-maybe arg force)
6047 (gnus-article-hide-signature arg))
6049 (defun gnus-article-maybe-highlight ()
6050 "Do some article highlighting if article highlighting is requested."
6051 (when (gnus-visual-p 'article-highlight 'highlight)
6052 (gnus-article-highlight-some)))
6054 (defun gnus-check-group-server ()
6055 ;; Make sure the connection to the server is alive.
6056 (unless (gnus-server-opened
6057 (gnus-find-method-for-group gnus-newsgroup-name))
6058 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
6059 (gnus-request-group gnus-newsgroup-name t)))
6062 (autoload 'nneething-get-file-name "nneething"))
6064 (defun gnus-request-article-this-buffer (article group)
6065 "Get an article and insert it into this buffer."
6066 (let (do-update-line sparse-header)
6070 (gnus-kill-all-overlays)
6071 (setq group (or group gnus-newsgroup-name))
6073 ;; Using `gnus-request-article' directly will insert the article into
6074 ;; `nntp-server-buffer' - so we'll save some time by not having to
6075 ;; copy it from the server buffer into the article buffer.
6077 ;; We only request an article by message-id when we do not have the
6078 ;; headers for it, so we'll have to get those.
6079 (when (stringp article)
6080 (gnus-read-header article))
6082 ;; If the article number is negative, that means that this article
6083 ;; doesn't belong in this newsgroup (possibly), so we find its
6084 ;; message-id and request it by id instead of number.
6085 (when (and (numberp article)
6087 (get-buffer gnus-summary-buffer)
6088 (gnus-buffer-exists-p gnus-summary-buffer))
6090 (set-buffer gnus-summary-buffer)
6091 (let ((header (gnus-summary-article-header article)))
6094 ((memq article gnus-newsgroup-sparse)
6095 ;; This is a sparse gap article.
6096 (setq do-update-line article)
6097 (setq article (mail-header-id header))
6098 (setq sparse-header (gnus-read-header article))
6099 (setq gnus-newsgroup-sparse
6100 (delq article gnus-newsgroup-sparse)))
6102 ;; It's a real article.
6103 (setq article (mail-header-id header)))
6105 ;; It is an extracted pseudo-article.
6106 (setq article 'pseudo)
6107 (gnus-request-pseudo-article header))))
6109 (let ((method (gnus-find-method-for-group
6110 gnus-newsgroup-name)))
6111 (when (and (eq (car method) 'nneething)
6113 (let ((dir (nneething-get-file-name
6114 (mail-header-id header))))
6115 (when (and (stringp dir)
6116 (file-directory-p dir))
6117 (setq article 'nneething)
6118 (gnus-group-enter-directory dir))))))))
6121 ;; Refuse to select canceled articles.
6122 ((and (numberp article)
6124 (get-buffer gnus-summary-buffer)
6125 (gnus-buffer-exists-p gnus-summary-buffer)
6126 (eq (cdr (with-current-buffer gnus-summary-buffer
6127 (assq article gnus-newsgroup-reads)))
6128 gnus-canceled-mark))
6130 ;; We first check `gnus-original-article-buffer'.
6131 ((and (get-buffer gnus-original-article-buffer)
6133 (with-current-buffer gnus-original-article-buffer
6134 (and (equal (car gnus-original-article) group)
6135 (eq (cdr gnus-original-article) article))))
6136 (insert-buffer-substring gnus-original-article-buffer)
6138 ;; Check the backlog.
6139 ((and gnus-keep-backlog
6140 (gnus-backlog-request-article group article (current-buffer)))
6142 ;; Check asynchronous pre-fetch.
6143 ((gnus-async-request-fetched-article group article (current-buffer))
6144 (gnus-async-prefetch-next group article gnus-summary-buffer)
6145 (when (and (numberp article) gnus-keep-backlog)
6146 (gnus-backlog-enter-article group article (current-buffer)))
6149 ((and gnus-use-cache
6151 (gnus-cache-request-article article group))
6153 ;; Check the agent cache.
6154 ((gnus-agent-request-article article group)
6156 ;; Get the article and put into the article buffer.
6157 ((or (stringp article)
6159 (let ((gnus-override-method gnus-override-method)
6160 (methods (and (stringp article)
6161 gnus-refer-article-method))
6162 (backend (car (gnus-find-method-for-group
6163 gnus-newsgroup-name)))
6165 (inhibit-read-only t))
6166 (if (or (not (listp methods))
6167 (and (symbolp (car methods))
6168 (assq (car methods) nnoo-definition-alist)))
6169 (setq methods (list methods)))
6170 (when (and (null gnus-override-method)
6172 (setq gnus-override-method (pop methods)))
6174 (when (eq gnus-override-method 'current)
6175 (setq gnus-override-method
6176 (with-current-buffer gnus-summary-buffer
6177 gnus-current-select-method)))
6179 (gnus-kill-all-overlays)
6180 (let ((gnus-newsgroup-name group))
6181 (gnus-check-group-server))
6183 ((gnus-request-article article group (current-buffer))
6184 (when (numberp article)
6185 (gnus-async-prefetch-next group article
6186 gnus-summary-buffer)
6187 (when gnus-keep-backlog
6188 (gnus-backlog-enter-article
6189 group article (current-buffer))))
6190 (setq result 'article))
6192 (setq gnus-override-method (pop methods)))
6193 ((not (string-match "^400 "
6194 (nnheader-get-report backend)))
6195 ;; If we get 400 server disconnect, reconnect and
6196 ;; retry; otherwise, assume the article has expired.
6197 (setq result 'done))))
6198 (and (eq result 'article) 'article)))
6202 ;; Associate this article with the current summary buffer.
6203 (setq gnus-article-current-summary gnus-summary-buffer)
6205 ;; Take the article from the original article buffer
6206 ;; and place it in the buffer it's supposed to be in.
6207 (when (and (get-buffer gnus-article-buffer)
6208 (equal (buffer-name (current-buffer))
6209 (buffer-name (get-buffer gnus-article-buffer))))
6211 (if (get-buffer gnus-original-article-buffer)
6212 (set-buffer gnus-original-article-buffer)
6213 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
6214 (buffer-disable-undo)
6215 (setq major-mode 'gnus-original-article-mode)
6216 (setq buffer-read-only t))
6217 (let ((inhibit-read-only t))
6219 (insert-buffer-substring gnus-article-buffer))
6220 (setq gnus-original-article (cons group article)))
6223 (run-hooks 'gnus-article-decode-hook)
6224 ;; Mark article as decoded or not.
6225 (setq gnus-article-decoded-p gnus-article-decode-hook))
6227 ;; Update sparse articles.
6228 (when (and do-update-line
6229 (or (numberp article)
6231 (let ((buf (current-buffer)))
6232 (set-buffer gnus-summary-buffer)
6233 (gnus-summary-update-article do-update-line sparse-header)
6234 (gnus-summary-goto-subject do-update-line nil t)
6235 (set-window-point (gnus-get-buffer-window (current-buffer) t)
6237 (set-buffer buf))))))
6243 (defcustom gnus-article-edit-mode-hook nil
6244 "Hook run in article edit mode buffers."
6245 :group 'gnus-article-various
6248 (defcustom gnus-article-edit-article-setup-function
6249 'gnus-article-mime-edit-article-setup
6250 "Function called to setup an editing article buffer."
6251 :group 'gnus-article-various
6254 (defvar gnus-article-edit-done-function nil)
6256 (defvar gnus-article-edit-mode-map nil)
6258 ;; Should we be using derived.el for this?
6259 (unless gnus-article-edit-mode-map
6260 (setq gnus-article-edit-mode-map (make-keymap))
6261 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
6263 (gnus-define-keys gnus-article-edit-mode-map
6264 "\C-c?" describe-mode
6265 "\C-c\C-c" gnus-article-edit-done
6266 "\C-c\C-k" gnus-article-edit-exit
6267 "\C-c\C-f\C-t" message-goto-to
6268 "\C-c\C-f\C-o" message-goto-from
6269 "\C-c\C-f\C-b" message-goto-bcc
6270 ;;"\C-c\C-f\C-w" message-goto-fcc
6271 "\C-c\C-f\C-c" message-goto-cc
6272 "\C-c\C-f\C-s" message-goto-subject
6273 "\C-c\C-f\C-r" message-goto-reply-to
6274 "\C-c\C-f\C-n" message-goto-newsgroups
6275 "\C-c\C-f\C-d" message-goto-distribution
6276 "\C-c\C-f\C-f" message-goto-followup-to
6277 "\C-c\C-f\C-m" message-goto-mail-followup-to
6278 "\C-c\C-f\C-k" message-goto-keywords
6279 "\C-c\C-f\C-u" message-goto-summary
6280 "\C-c\C-f\C-i" message-insert-or-toggle-importance
6281 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
6282 "\C-c\C-b" message-goto-body
6283 "\C-c\C-i" message-goto-signature
6285 "\C-c\C-t" message-insert-to
6286 "\C-c\C-n" message-insert-newsgroups
6287 "\C-c\C-o" message-sort-headers
6288 "\C-c\C-e" message-elide-region
6289 "\C-c\C-v" message-delete-not-region
6290 "\C-c\C-z" message-kill-to-signature
6291 "\M-\r" message-newline-and-reformat
6292 "\C-c\C-a" mml-attach-file
6293 "\C-a" message-beginning-of-line
6295 "\M-;" comment-region)
6297 (gnus-define-keys (gnus-article-edit-wash-map
6298 "\C-c\C-w" gnus-article-edit-mode-map)
6299 "f" gnus-article-edit-full-stops))
6302 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
6304 ["Fetch To" message-insert-to t]
6305 ["Fetch Newsgroups" message-insert-newsgroups t]
6307 ["To" message-goto-to t]
6308 ["From" message-goto-from t]
6309 ["Subject" message-goto-subject t]
6310 ["Cc" message-goto-cc t]
6311 ["Reply-To" message-goto-reply-to t]
6312 ["Summary" message-goto-summary t]
6313 ["Keywords" message-goto-keywords t]
6314 ["Newsgroups" message-goto-newsgroups t]
6315 ["Followup-To" message-goto-followup-to t]
6316 ["Mail-Followup-To" message-goto-mail-followup-to t]
6317 ["Distribution" message-goto-distribution t]
6318 ["Body" message-goto-body t]
6319 ["Signature" message-goto-signature t]))
6321 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
6322 "Major mode for editing articles.
6323 This is an extended text-mode.
6325 \\{gnus-article-edit-mode-map}"
6326 (make-local-variable 'gnus-article-edit-done-function)
6327 (make-local-variable 'gnus-prev-winconf)
6328 (set (make-local-variable 'font-lock-defaults)
6329 '(message-font-lock-keywords t))
6330 (set (make-local-variable 'mail-header-separator) "")
6331 (set (make-local-variable 'gnus-article-edit-mode) t)
6332 (easy-menu-add message-mode-field-menu message-mode-map)
6333 (setq buffer-read-only nil)
6334 (buffer-enable-undo)
6337 (defun gnus-article-edit (&optional force)
6338 "Edit the current article.
6339 This will have permanent effect only in mail groups.
6340 If FORCE is non-nil, allow editing of articles even in read-only
6343 (when (and (not force)
6344 (gnus-group-read-only-p))
6345 (error "The current newsgroup does not support article editing"))
6346 (gnus-article-date-original)
6347 (gnus-article-edit-article
6349 `(lambda (no-highlight)
6351 (gnus-summary-edit-article-done
6352 ,(or (mail-header-references gnus-current-headers) "")
6353 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
6355 (defun gnus-article-edit-article (start-func exit-func &optional quiet)
6356 "Start editing the contents of the current article buffer."
6357 (let ((winconf (current-window-configuration)))
6358 (set-buffer gnus-article-buffer)
6359 (let ((message-auto-save-directory
6360 ;; Don't associate the article buffer with a draft file.
6362 (gnus-article-edit-mode))
6363 (funcall start-func)
6364 (set-buffer-modified-p nil)
6365 (gnus-configure-windows 'edit-article)
6366 (setq gnus-article-edit-done-function exit-func)
6367 (setq gnus-prev-winconf winconf)
6368 (when gnus-article-edit-article-setup-function
6369 (funcall gnus-article-edit-article-setup-function))
6371 (gnus-message 6 "C-c C-c to end edits; C-c C-k to exit"))))
6373 (defun gnus-article-edit-done (&optional arg)
6374 "Update the article edits and exit."
6376 (let ((func gnus-article-edit-done-function)
6377 (buf (current-buffer))
6378 (start (window-start))
6380 (winconf gnus-prev-winconf))
6381 (remove-hook 'gnus-article-mode-hook
6382 'gnus-article-mime-edit-article-unwind)
6383 (widen) ;; Widen it in case that users narrowed the buffer.
6386 ;; The cache and backlog have to be flushed somewhat.
6387 (when gnus-keep-backlog
6388 (gnus-backlog-remove-article
6389 (car gnus-article-current) (cdr gnus-article-current)))
6390 ;; Flush original article as well.
6392 (when (get-buffer gnus-original-article-buffer)
6393 (set-buffer gnus-original-article-buffer)
6394 (setq gnus-original-article nil)))
6395 (when gnus-use-cache
6396 (gnus-cache-update-article
6397 (car gnus-article-current) (cdr gnus-article-current)))
6398 ;; We remove all text props from the article buffer.
6399 (kill-all-local-variables)
6400 (set-text-properties (point-min) (point-max) nil)
6402 (set-window-configuration winconf)
6404 (set-window-start (get-buffer-window buf) start)
6405 (set-window-point (get-buffer-window buf) (point)))
6406 (gnus-summary-show-article))
6408 (defun gnus-article-edit-exit ()
6409 "Exit the article editing without updating."
6411 (when (or (not (buffer-modified-p))
6412 (yes-or-no-p "Article modified; kill anyway? "))
6413 (let ((curbuf (current-buffer))
6415 (window-start (window-start)))
6417 (if (gnus-buffer-live-p gnus-original-article-buffer)
6418 (insert-buffer-substring gnus-original-article-buffer))
6419 (let ((winconf gnus-prev-winconf))
6420 (kill-all-local-variables)
6422 (set-window-configuration winconf)
6423 ;; Tippy-toe some to make sure that point remains where it was.
6424 (save-current-buffer
6426 (set-window-start (get-buffer-window (current-buffer)) window-start)
6428 (gnus-summary-show-article)))
6430 (defun gnus-article-edit-full-stops ()
6431 "Interactively repair spacing at end of sentences."
6434 (goto-char (point-min))
6435 (search-forward-regexp "^$" nil t)
6436 (let ((case-fold-search nil))
6437 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
6440 ;;; Article editing with MIME-Edit
6443 (defcustom gnus-article-mime-edit-article-setup-hook nil
6444 "Hook run after setting up a MIME editing article buffer."
6445 :group 'gnus-article-various
6448 (defun gnus-article-mime-edit-article-unwind ()
6449 "Unwind `gnus-article-buffer' if article editing was given up."
6450 (remove-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6451 (when (featurep 'font-lock)
6452 (setq font-lock-defaults nil)
6453 (font-lock-mode -1))
6454 (when mime-edit-mode-flag
6455 (mime-edit-exit 'nomime 'no-error)
6458 (defun gnus-article-mime-edit-article-setup ()
6459 "Convert current buffer to MIME-Edit buffer and turn on MIME-Edit mode
6460 after replacing with the original article."
6461 (setq gnus-show-mime t)
6462 (setq gnus-article-edit-done-function
6463 `(lambda (&rest args)
6464 (when mime-edit-mode-flag
6465 (let (mime-edit-insert-user-agent-field)
6468 (goto-char (point-min))
6469 (let (case-fold-search)
6470 (when (re-search-forward
6471 (format "^%s$" (regexp-quote mail-header-separator))
6473 (replace-match "")))
6474 (apply ,gnus-article-edit-done-function args)
6477 (buffer-substring-no-properties (point-min) (point-max))
6478 (set-buffer (get-buffer-create gnus-original-article-buffer))
6480 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6481 (set-buffer gnus-article-buffer)
6482 (gnus-article-prepare-display)))
6483 (substitute-key-definition 'gnus-article-edit-done
6484 'gnus-article-mime-edit-done
6485 gnus-article-edit-mode-map)
6486 (substitute-key-definition 'gnus-article-edit-exit
6487 'gnus-article-mime-edit-exit
6488 gnus-article-edit-mode-map)
6490 (insert-buffer-substring gnus-original-article-buffer)
6491 (unless (member (with-current-buffer gnus-summary-buffer
6492 gnus-newsgroup-name)
6493 '("nndraft:delayed" "nndraft:drafts"))
6494 (let ((ofn (symbol-function 'mime-edit-decode-single-part-in-buffer)))
6495 (fset 'mime-edit-decode-single-part-in-buffer
6496 (lambda (&rest args)
6497 (if (let ((content-type (car args)))
6498 (and (eq 'message (mime-content-type-primary-type
6500 (eq 'rfc822 (mime-content-type-subtype
6502 (setcar (cdr args) 'not-decode-text))
6506 (fset 'mime-edit-decode-single-part-in-buffer ofn))))
6507 (when (featurep 'font-lock)
6508 (set (make-local-variable 'font-lock-defaults)
6509 '(message-font-lock-keywords t))
6510 (font-lock-set-defaults)
6511 (turn-on-font-lock))
6512 (set-buffer-modified-p nil)
6513 (delete-other-windows)
6514 (add-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6515 (gnus-run-hooks 'gnus-article-mime-edit-article-setup-hook))
6517 (defun gnus-article-mime-edit-done (&optional arg)
6518 "Update the article MIME edits and exit."
6520 (when (featurep 'font-lock)
6521 (setq font-lock-defaults nil)
6522 (font-lock-mode -1))
6523 (let ((inhibit-read-only t))
6524 (gnus-article-edit-done arg)))
6526 (defun gnus-article-mime-edit-exit ()
6527 "Exit the article MIME editing without updating."
6529 (when (or (not (buffer-modified-p))
6530 (yes-or-no-p "Article modified; kill anyway? "))
6531 (when (featurep 'font-lock)
6532 (setq font-lock-defaults nil)
6533 (font-lock-mode -1))
6534 (when mime-edit-mode-flag
6535 (let (mime-edit-insert-user-agent-field)
6538 (goto-char (point-min))
6539 (let (case-fold-search)
6540 (when (re-search-forward
6541 (format "^%s$" (regexp-quote mail-header-separator)) nil t)
6542 (replace-match "")))
6543 (let ((winconf gnus-prev-winconf))
6545 (buffer-substring-no-properties (point-min) (point-max))
6546 (set-buffer (get-buffer-create gnus-original-article-buffer))
6548 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6549 (set-buffer gnus-article-buffer)
6550 (gnus-article-prepare-display)
6551 (set-window-configuration winconf))))
6554 ;;; Article highlights
6557 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
6559 ;;; Internal Variables:
6561 (defcustom gnus-button-url-regexp
6562 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
6563 "\\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:]]\\)"
6564 "\\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\\)\\)")
6565 "Regular expression that matches URLs."
6566 :group 'gnus-article-buttons
6569 (defcustom gnus-button-valid-fqdn-regexp
6570 message-valid-fqdn-regexp
6571 "Regular expression that matches a valid FQDN."
6573 :group 'gnus-article-buttons
6576 ;; Regexp suggested by Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
6577 (defcustom gnus-button-valid-localpart-regexp
6578 "[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t ]*"
6579 "Regular expression that matches a localpart of mail addresses or MIDs."
6581 :group 'gnus-article-buttons
6584 (defcustom gnus-button-man-handler 'manual-entry
6585 "Function to use for displaying man pages.
6586 The function must take at least one argument with a string naming the
6589 :type '(choice (function-item :tag "Man" manual-entry)
6590 (function-item :tag "Woman" woman)
6591 (function :tag "Other"))
6592 :group 'gnus-article-buttons)
6594 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
6595 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
6596 If the default site is too slow, try to find a CTAN mirror, see
6597 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
6598 the variable `gnus-button-handle-ctan'."
6600 :group 'gnus-article-buttons
6601 :link '(custom-manual "(gnus)Group Parameters")
6602 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
6603 (const "http://tug.ctan.org/tex-archive/")
6604 (const "http://www.dante.de/CTAN/")
6605 (string :tag "Other")))
6607 (defcustom gnus-button-ctan-handler 'browse-url
6608 "Function to use for displaying CTAN links.
6609 The function must take one argument, the string naming the URL."
6611 :type '(choice (function-item :tag "Browse Url" browse-url)
6612 (function :tag "Other"))
6613 :group 'gnus-article-buttons)
6615 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
6616 "Bogus strings removed from CTAN URLs."
6618 :group 'gnus-article-buttons
6619 :type '(choice (const "^/?tex-archive/\\|/")
6620 (regexp :tag "Other")))
6622 (defcustom gnus-button-ctan-directory-regexp
6624 (list "archive-tools" "biblio" "bibliography" "digests" "documentation"
6625 "dviware" "fonts" "graphics" "help" "indexing" "info" "language"
6626 "languages" "macros" "nonfree" "obsolete" "support" "systems"
6627 "tds" "tools" "usergrps" "web") t)
6628 "Regular expression for ctan directories.
6629 It should match all directories in the top level of `gnus-ctan-url'."
6631 :group 'gnus-article-buttons
6634 (defcustom gnus-button-mid-or-mail-regexp
6635 (concat "\\b\\(<?" gnus-button-valid-localpart-regexp "@"
6636 gnus-button-valid-fqdn-regexp
6638 "Regular expression that matches a message ID or a mail address."
6640 :group 'gnus-article-buttons
6643 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
6644 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
6645 Strings like this can be either a message ID or a mail address. If it is one
6646 of the symbols `mid' or `mail', Gnus will always assume that the string is a
6647 message ID or a mail address, respectively. If this variable is set to the
6648 symbol `ask', always query the user what do do. If it is a function, this
6649 function will be called with the string as it's only argument. The function
6650 must return `mid', `mail', `invalid' or `ask'."
6652 :group 'gnus-article-buttons
6653 :type '(choice (function-item :tag "Heuristic function"
6654 gnus-button-mid-or-mail-heuristic)
6659 (defcustom gnus-button-mid-or-mail-heuristic-alist
6660 '((-10.0 . ".+\\$.+@")
6663 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
6664 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
6665 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
6666 (-1.0 . "^[^a-z]+@")
6668 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
6669 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
6670 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
6671 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
6674 (-1.0 . "^[0-9][0-9]")
6676 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
6677 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6678 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
6679 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6681 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
6682 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
6685 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
6687 ;; compensation for TDMA dated mail addresses:
6688 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
6690 (-20.0 . "\\.fsf@") ;; Gnus
6693 (-20.0 . "_-_") ;; Subject change in thread
6695 (-20.0 . "\\.ln@") ;; leafnode
6696 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
6697 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
6699 ;; (5.0 . "") ;; $local_part_len <= 7
6700 (10.0 . "^[^0-9]+@")
6701 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
6702 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
6705 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
6707 (0.5 . "^[A-Z][a-z]")
6708 (0.5 . "^[A-Z][a-z][a-z]")
6709 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
6710 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
6711 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
6713 A negative RATE indicates a message IDs, whereas a positive indicates a mail
6714 address. The REGEXP is processed with `case-fold-search' set to nil."
6716 :group 'gnus-article-buttons
6717 :type '(repeat (cons (number :tag "Rate")
6718 (regexp :tag "Regexp"))))
6720 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
6721 "Guess whether MID-OR-MAIL is a message ID or a mail address.
6722 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
6723 address, `ask' if unsure and `invalid' if the string is invalid."
6724 (let ((case-fold-search nil)
6725 (list gnus-button-mid-or-mail-heuristic-alist)
6726 (result 0) rate regexp lpartlen elem)
6728 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
6729 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
6730 ;; Certain special cases...
6733 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
6734 "^[0-9]+\\.[0-9]+@compuserve\\|"
6735 "@public\\.gmane\\.org")
6737 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
6738 (setq result 'mail))
6739 (when (string-match "@.*@\\| " mid-or-mail)
6740 (gnus-message 8 "`%s' is invalid." mid-or-mail)
6741 (setq result 'invalid))
6742 ;; Nothing more to do, if result is not a number here...
6743 (when (numberp result)
6745 (setq elem (car list)
6749 (when (string-match regexp mid-or-mail)
6750 (setq result (+ result rate))
6752 9 "`%s' matched `%s', rate `%s', result `%s'."
6753 mid-or-mail regexp rate result)))
6754 (when (<= lpartlen 7)
6755 (setq result (+ result 5.0))
6756 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
6757 mid-or-mail result))
6758 (when (>= lpartlen 12)
6759 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
6761 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
6762 ;; Long local part should contain realname if e-mail address,
6763 ;; too many digits: message-id.
6764 ;; $score -= 5.0 + 0.1 * $local_part_len;
6765 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6766 (setq result (+ result rate))
6768 9 "Many digits in `%s', rate `%s', result `%s'."
6769 mid-or-mail rate result))
6770 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6772 ;; Too few vowels [^aeiouy]{4,}.*\@
6773 (setq result (+ result -5.0))
6775 9 "Few vowels in `%s', rate `%s', result `%s'."
6776 mid-or-mail -5.0 result))
6778 (setq result (+ result 5.0))
6780 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6781 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6782 ;; Maybe we should make this a customizable alist: (condition . 'result)
6784 ((symbolp result) result)
6785 ;; Now convert number into proper results:
6786 ((< result -10.0) 'mid)
6787 ((> result 10.0) 'mail)
6790 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6791 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6792 (url-mid (concat "news" ":" mid-or-mail))
6793 (url-mailto (concat "mailto" ":" mid-or-mail)))
6794 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6795 (when (fboundp pref)
6797 ;; get rid of surrounding angles...
6799 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6800 (if (or (eq 'mid guessed) (eq 'mail guessed))
6804 (save-window-excursion
6805 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6808 (cond ((eq pref 'mid)
6809 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6810 (gnus-button-handle-news url-mid))
6812 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6813 (gnus-url-mailto url-mailto))
6814 (t (gnus-message 3 "Invalid string.")))))
6816 (defun gnus-button-handle-custom (fun arg)
6817 "Call function FUN on argument ARG.
6818 Both FUN and ARG are supposed to be strings. ARG will be passed
6819 as a symbol to FUN."
6820 (funcall (intern fun) (intern arg)))
6822 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6824 ;; FIXME: Maybe we should merge some of the functions that do quite similar
6827 (defun gnus-button-handle-describe-function (url)
6828 "Call `describe-function' when pushing the corresponding URL button."
6831 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6833 (defun gnus-button-handle-describe-variable (url)
6834 "Call `describe-variable' when pushing the corresponding URL button."
6837 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6839 (defun gnus-button-handle-symbol (url)
6840 "Display help on variable or function.
6841 Calls `describe-variable' or `describe-function'."
6842 (let ((sym (intern url)))
6844 ((fboundp sym) (describe-function sym))
6845 ((boundp sym) (describe-variable sym))
6846 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
6848 (defun gnus-button-handle-describe-key (url)
6849 "Call `describe-key' when pushing the corresponding URL button."
6851 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6852 (keys (ignore-errors (eval `(kbd ,key-string)))))
6855 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6857 (defun gnus-button-handle-apropos (url)
6858 "Call `apropos' when pushing the corresponding URL button."
6859 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6861 (defun gnus-button-handle-apropos-command (url)
6862 "Call `apropos' when pushing the corresponding URL button."
6864 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6866 (defun gnus-button-handle-apropos-variable (url)
6867 "Call `apropos' when pushing the corresponding URL button."
6869 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6870 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6872 (defun gnus-button-handle-apropos-documentation (url)
6873 "Call `apropos' when pushing the corresponding URL button."
6875 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6876 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6878 (defun gnus-button-handle-library (url)
6879 "Call `locate-library' when pushing the corresponding URL button."
6880 (gnus-message 9 "url=`%s'" url)
6881 (let* ((lib (locate-library url))
6882 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6884 (gnus-message 1 "Cannot locale library `%s'." url)
6885 (find-file-read-only file))))
6887 (defun gnus-button-handle-ctan (url)
6888 "Call `browse-url' when pushing a CTAN URL button."
6890 gnus-button-ctan-handler
6893 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6895 (defcustom gnus-button-tex-level 5
6896 "*Integer that says how many TeX-related buttons Gnus will show.
6897 The higher the number, the more buttons will appear and the more false
6898 positives are possible. Note that you can set this variable local to
6899 specific groups. Setting it higher in TeX groups is probably a good idea.
6900 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6901 how to set variables in specific groups."
6903 :group 'gnus-article-buttons
6904 :link '(custom-manual "(gnus)Group Parameters")
6907 (defcustom gnus-button-man-level 5
6908 "*Integer that says how many man-related buttons Gnus will show.
6909 The higher the number, the more buttons will appear and the more false
6910 positives are possible. Note that you can set this variable local to
6911 specific groups. Setting it higher in Unix groups is probably a good idea.
6912 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6913 how to set variables in specific groups."
6915 :group 'gnus-article-buttons
6916 :link '(custom-manual "(gnus)Group Parameters")
6919 (defcustom gnus-button-emacs-level 5
6920 "*Integer that says how many emacs-related buttons Gnus will show.
6921 The higher the number, the more buttons will appear and the more false
6922 positives are possible. Note that you can set this variable local to
6923 specific groups. Setting it higher in Emacs or Gnus related groups is
6924 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6925 `gnus-parameters' on how to set variables in specific groups."
6927 :group 'gnus-article-buttons
6928 :link '(custom-manual "(gnus)Group Parameters")
6931 (defcustom gnus-button-message-level 5
6932 "*Integer that says how many buttons for news or mail messages will appear.
6933 The higher the number, the more buttons will appear and the more false
6934 positives are possible."
6935 ;; mail addresses, MIDs, URLs for news, ...
6937 :group 'gnus-article-buttons
6940 (defcustom gnus-button-browse-level 5
6941 "*Integer that says how many buttons for browsing will appear.
6942 The higher the number, the more buttons will appear and the more false
6943 positives are possible."
6944 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6946 :group 'gnus-article-buttons
6949 (defcustom gnus-button-alist
6950 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6951 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6952 ((concat "\\b\\(nntp\\|news\\):\\("
6953 gnus-button-valid-localpart-regexp "@[a-z0-9.-]+[a-z]\\)")
6954 0 t gnus-button-handle-news 2)
6955 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6956 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6957 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6958 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6959 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
6960 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
6961 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
6962 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6963 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6964 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6965 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6966 ;; RFC 2368 (The mailto URL scheme)
6967 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6968 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6969 ("\\bmailto:\\([^ \n\t]+\\)"
6970 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6972 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6973 gnus-button-ctan-directory-regexp
6974 "[^][>)!;:,'\n\t ]+\\)")
6975 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6976 ((concat "\\btex-archive/\\("
6977 gnus-button-ctan-directory-regexp
6978 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6979 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6982 gnus-button-ctan-directory-regexp
6983 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6984 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6985 ;; This is info (home-grown style) <info://foo/bar+baz>
6986 ("\\binfo://\\([^'\">\n\t ]+\\)"
6987 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6988 ;; Info GNOME style <info:foo#bar_baz>
6989 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6990 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6991 ;; Info KDE style <info:(foo)bar baz>
6992 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6993 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6994 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6995 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6996 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6997 ;; Info links like `C-h i d m CC Mode RET'
6998 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
7000 ("M-x[ \t\n]\\(customize-[^ ]+\\)[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
7001 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1 2)
7002 ;; Emacs help commands
7003 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
7004 ;; regexp doesn't match arguments containing ` '.
7005 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
7006 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
7007 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
7008 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
7009 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
7010 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
7011 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
7012 ;; The following entries may lead to many false positives so don't enable
7013 ;; them by default (use a high button level).
7014 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
7015 ;; Exclude [.?] for URLs in gmane.emacs.cvs
7016 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
7017 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
7018 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
7019 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
7020 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
7021 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
7022 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
7023 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
7024 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
7025 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
7026 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
7027 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
7028 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
7029 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
7030 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
7031 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
7032 ;; Unlike the other regexps we really have to require quoting
7033 ;; here to determine where it ends.
7034 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
7035 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
7036 ("<URL: *\\([^<>]*\\)>"
7037 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
7038 ;; RFC 2396 (2.4.3., delims) ...
7039 ("\"URL: *\\([^\"]*\\)\""
7040 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
7041 ;; RFC 2396 (2.4.3., delims) ...
7042 ("\"URL: *\\([^\"]*\\)\""
7043 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
7045 (gnus-button-url-regexp
7046 0 (>= gnus-button-browse-level 0) browse-url 0)
7048 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
7049 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
7050 gnus-button-handle-man 1)
7051 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
7052 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
7053 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
7054 gnus-button-handle-man 1)
7055 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
7056 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
7057 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
7058 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
7059 ;; MID or mail: To avoid too many false positives we don't try to catch
7060 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
7061 ;; at least one dot. TLD must contain two or three chars or be a know TLD
7062 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
7063 ;; so that non-ambiguous entries (see above) match first.
7064 (gnus-button-mid-or-mail-regexp
7065 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
7066 "*Alist of regexps matching buttons in article bodies.
7068 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
7069 REGEXP: is the string (case insensitive) matching text around the button (can
7070 also be Lisp expression evaluating to a string),
7071 BUTTON: is the number of the regexp grouping actually matching the button,
7072 FORM: is a Lisp expression which must eval to true for the button to
7074 CALLBACK: is the function to call when the user push this button, and each
7075 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
7077 CALLBACK can also be a variable, in that case the value of that
7078 variable it the real callback function."
7079 :group 'gnus-article-buttons
7080 :type '(repeat (list (choice regexp variable sexp)
7081 (integer :tag "Button")
7083 (function :tag "Callback")
7086 (integer :tag "Regexp group")))))
7088 (defcustom gnus-header-button-alist
7089 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
7090 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
7091 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
7092 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
7093 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
7094 0 (>= gnus-button-message-level 0) gnus-msg-mail 0)
7095 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
7096 0 (>= gnus-button-browse-level 0) browse-url 0)
7097 ("^Subject:" gnus-button-url-regexp
7098 0 (>= gnus-button-browse-level 0) browse-url 0)
7099 ("^[^:]+:" gnus-button-url-regexp
7100 0 (>= gnus-button-browse-level 0) browse-url 0)
7101 ("^OpenPGP:.*url=" gnus-button-url-regexp
7102 0 (>= gnus-button-browse-level 0) gnus-button-openpgp 0)
7103 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
7104 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
7105 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
7106 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
7107 "*Alist of headers and regexps to match buttons in article heads.
7109 This alist is very similar to `gnus-button-alist', except that each
7110 alist has an additional HEADER element first in each entry:
7112 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
7114 HEADER is a regexp to match a header. For a fuller explanation, see
7115 `gnus-button-alist'."
7116 :group 'gnus-article-buttons
7117 :group 'gnus-article-headers
7118 :type '(repeat (list (regexp :tag "Header")
7119 (choice regexp variable)
7120 (integer :tag "Button")
7122 (function :tag "Callback")
7125 (integer :tag "Regexp group")))))
7129 (defun gnus-article-push-button (event)
7130 "Check text under the mouse pointer for a callback function.
7131 If the text under the mouse pointer has a `gnus-callback' property,
7132 call it with the value of the `gnus-data' text property."
7134 (set-buffer (window-buffer (posn-window (event-start event))))
7135 (let* ((pos (posn-point (event-start event)))
7136 (data (get-text-property pos 'gnus-data))
7137 (fun (get-text-property pos 'gnus-callback)))
7140 (funcall fun data))))
7142 (defun gnus-article-press-button ()
7143 "Check text at point for a callback function.
7144 If the text at point has a `gnus-callback' property,
7145 call it with the value of the `gnus-data' text property."
7147 (let ((data (get-text-property (point) 'gnus-data))
7148 (fun (get-text-property (point) 'gnus-callback)))
7150 (funcall fun data))))
7152 (defun gnus-article-prev-button (n)
7153 "Move point to N buttons backward.
7154 If N is negative, move forward instead."
7156 (gnus-article-next-button (- n)))
7158 (defun gnus-article-next-button (n)
7159 "Move point to N buttons forward.
7160 If N is negative, move backward instead."
7162 (let ((function (if (< n 0) 'previous-single-property-change
7163 'next-single-property-change))
7164 (inhibit-point-motion-hooks t)
7166 (limit (if (< n 0) (point-min) (point-max))))
7168 (while (and (not (= limit (point)))
7170 ;; Skip past the current button.
7171 (when (get-text-property (point) 'gnus-callback)
7172 (goto-char (funcall function (point) 'gnus-callback nil limit)))
7173 ;; Go to the next (or previous) button.
7174 (gnus-goto-char (funcall function (point) 'gnus-callback nil limit))
7175 ;; Put point at the start of the button.
7176 (when (and backward (not (get-text-property (point) 'gnus-callback)))
7177 (goto-char (funcall function (point) 'gnus-callback nil limit)))
7178 ;; Skip past intangible buttons.
7179 (when (get-text-property (point) 'intangible)
7183 (gnus-message 5 "No more buttons"))
7186 (defun gnus-article-highlight (&optional force)
7187 "Highlight current article.
7188 This function calls `gnus-article-highlight-headers',
7189 `gnus-article-highlight-citation',
7190 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
7191 do the highlighting. See the documentation for those functions."
7192 (interactive (list 'force))
7193 (gnus-article-highlight-headers)
7194 (gnus-article-highlight-citation force)
7195 (gnus-article-highlight-signature)
7196 (gnus-article-add-buttons force)
7197 (gnus-article-add-buttons-to-head))
7199 (defun gnus-article-highlight-some (&optional force)
7200 "Highlight current article.
7201 This function calls `gnus-article-highlight-headers',
7202 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
7203 do the highlighting. See the documentation for those functions."
7204 (interactive (list 'force))
7205 (gnus-article-highlight-headers)
7206 (gnus-article-highlight-signature)
7207 (gnus-article-add-buttons))
7209 (defun gnus-article-highlight-headers ()
7210 "Highlight article headers as specified by `gnus-header-face-alist'."
7212 (gnus-with-article-headers
7213 (let (regexp header-face field-face from hpoints fpoints)
7214 (dolist (entry gnus-header-face-alist)
7215 (goto-char (point-min))
7216 (setq regexp (concat "^\\("
7217 (if (string-equal "" (nth 0 entry))
7221 header-face (nth 1 entry)
7222 field-face (nth 2 entry))
7223 (while (and (re-search-forward regexp nil t)
7227 (unless (search-forward ":" nil t)
7229 (when (and header-face
7230 (not (memq (point) hpoints)))
7231 (push (point) hpoints)
7232 (gnus-put-text-property from (point) 'face header-face))
7233 (when (and field-face
7234 (not (memq (setq from (point)) fpoints)))
7236 (if (re-search-forward "^[^ \t]" nil t)
7238 (goto-char (point-max)))
7239 (gnus-put-text-property from (point) 'face field-face)))))))
7241 (defun gnus-article-highlight-signature ()
7242 "Highlight the signature in an article.
7243 It does this by highlighting everything after
7244 `gnus-signature-separator' using the face `gnus-signature'."
7246 (when gnus-signature-face
7247 (gnus-with-article-buffer
7248 (let ((inhibit-point-motion-hooks t))
7250 (when (gnus-article-narrow-to-signature)
7251 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
7252 'face gnus-signature-face)))))))
7254 (defun gnus-article-buttonize-signature ()
7255 "Add button to the signature."
7258 (set-buffer gnus-article-buffer)
7259 (let ((inhibit-read-only t)
7260 (inhibit-point-motion-hooks t))
7261 (when (gnus-article-search-signature)
7262 (gnus-article-add-button (match-beginning 0) (match-end 0)
7263 'gnus-signature-toggle
7264 (set-marker (make-marker)
7265 (1+ (match-end 0))))))))
7267 (defun gnus-button-in-region-p (b e prop)
7268 "Say whether PROP exists in the region."
7269 (text-property-not-all b e prop nil))
7271 (defun gnus-article-add-buttons (&optional force)
7272 "Find external references in the article and make buttons of them.
7273 \"External references\" are things like Message-IDs and URLs, as
7274 specified by `gnus-button-alist'."
7275 (interactive (list 'force))
7276 (gnus-with-article-buffer
7277 (let ((inhibit-point-motion-hooks t)
7278 (case-fold-search t)
7279 (alist gnus-button-alist)
7281 ;; Remove all old markers.
7282 (let (marker entry new-list)
7283 (while (setq marker (pop gnus-button-marker-list))
7284 (if (or (< marker (point-min)) (>= marker (point-max)))
7285 (push marker new-list)
7287 (when (setq entry (gnus-button-entry))
7288 (put-text-property (match-beginning (nth 1 entry))
7289 (match-end (nth 1 entry))
7290 'gnus-callback nil))
7291 (set-marker marker nil)))
7292 (setq gnus-button-marker-list new-list))
7293 ;; We skip the headers.
7296 (while (setq entry (pop alist))
7297 (setq regexp (eval (car entry)))
7299 (while (re-search-forward regexp nil t)
7300 (let* ((start (and entry (match-beginning (nth 1 entry))))
7301 (end (and entry (match-end (nth 1 entry))))
7302 (from (match-beginning 0)))
7303 (when (and (or (eq t (nth 2 entry))
7304 (eval (nth 2 entry)))
7305 (not (gnus-button-in-region-p
7306 start end 'gnus-callback)))
7307 ;; That optional form returned non-nil, so we add the
7309 (gnus-article-add-button
7310 start end 'gnus-button-push
7311 (car (push (set-marker (make-marker) from)
7312 gnus-button-marker-list))))))))))
7314 ;; Add buttons to the head of an article.
7315 (defun gnus-article-add-buttons-to-head ()
7316 "Add buttons to the head of the article."
7318 (gnus-with-article-headers
7320 (dolist (entry gnus-header-button-alist)
7321 ;; Each alist entry.
7322 (goto-char (point-min))
7323 (while (re-search-forward (car entry) nil t)
7324 ;; Each header matching the entry.
7325 (setq beg (match-beginning 0))
7326 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
7327 (match-beginning 0))
7330 (while (re-search-forward (eval (nth 1 entry)) end t)
7331 ;; Each match within a header.
7332 (let* ((entry (cdr entry))
7333 (start (match-beginning (nth 1 entry)))
7334 (end (match-end (nth 1 entry)))
7335 (form (nth 2 entry)))
7336 (goto-char (match-end 0))
7338 (gnus-article-add-button
7339 start end (nth 3 entry)
7340 (buffer-substring (match-beginning (nth 4 entry))
7341 (match-end (nth 4 entry)))))))
7342 (goto-char end))))))
7344 ;;; External functions:
7346 (defun gnus-article-add-button (from to fun &optional data)
7347 "Create a button between FROM and TO with callback FUN and data DATA."
7348 (when gnus-article-button-face
7349 (gnus-overlay-put (gnus-make-overlay from to)
7350 'face gnus-article-button-face))
7351 (gnus-add-text-properties
7353 (nconc (and gnus-article-mouse-face
7354 (list gnus-mouse-face-prop gnus-article-mouse-face))
7355 (list 'gnus-callback fun)
7356 (and data (list 'gnus-data data))))
7357 (widget-convert-button 'link from to :action 'gnus-widget-press-button
7358 :button-keymap gnus-widget-button-keymap))
7360 ;;; Internal functions:
7362 (defun gnus-article-set-globals ()
7363 (with-current-buffer gnus-summary-buffer
7364 (gnus-set-global-variables)))
7366 (defun gnus-signature-toggle (end)
7367 (gnus-with-article-buffer
7368 (let ((inhibit-point-motion-hooks t)
7369 (limit (next-single-property-change end 'mime-view-entity
7371 (if (text-property-any end limit 'article-type 'signature)
7373 (gnus-delete-wash-type 'signature)
7374 (gnus-remove-text-properties-when
7375 'article-type 'signature end limit
7376 (cons 'article-type (cons 'signature
7377 gnus-hidden-properties))))
7378 (gnus-add-wash-type 'signature)
7379 (gnus-add-text-properties-when
7380 'article-type nil end limit
7381 (cons 'article-type (cons 'signature
7382 gnus-hidden-properties)))))
7383 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
7384 (gnus-set-mode-line 'article))))
7386 (defun gnus-button-entry ()
7387 ;; Return the first entry in `gnus-button-alist' matching this place.
7388 (let ((alist gnus-button-alist)
7391 (setq entry (pop alist))
7392 (if (looking-at (eval (car entry)))
7397 (defun gnus-button-push (marker)
7398 ;; Push button starting at MARKER.
7401 (let* ((entry (gnus-button-entry))
7402 (inhibit-point-motion-hooks t)
7404 (args (mapcar (lambda (group)
7405 (let ((string (match-string group)))
7406 (set-text-properties
7407 0 (length string) nil string)
7414 (fboundp (symbol-value fun)))
7415 (apply (symbol-value fun) args))
7417 (gnus-message 1 "You must define `%S' to use this button"
7418 (cons fun args)))))))
7420 (defun gnus-parse-news-url (url)
7421 (let (scheme server port group message-id articles)
7424 (goto-char (point-min))
7425 (when (looking-at "\\([A-Za-z]+\\):")
7426 (setq scheme (match-string 1))
7427 (goto-char (match-end 0)))
7428 (when (looking-at "//\\([^:/]+\\)\\(:?\\)\\([0-9]+\\)?/")
7429 (setq server (match-string 1))
7430 (setq port (if (stringp (match-string 3))
7431 (string-to-number (match-string 3))
7433 (goto-char (match-end 0)))
7436 ((looking-at "\\(.*@.*\\)")
7437 (setq message-id (match-string 1)))
7438 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
7439 (setq group (match-string 1)
7440 articles (split-string (match-string 2) "-")))
7441 ((looking-at "\\([^/]+\\)/?")
7442 (setq group (match-string 1)))
7444 (error "Unknown news URL syntax"))))
7445 (list scheme server port group message-id articles)))
7447 (defun gnus-button-handle-news (url)
7449 (destructuring-bind (scheme server port group message-id articles)
7450 (gnus-parse-news-url url)
7454 (set-buffer gnus-summary-buffer)
7456 (let ((gnus-refer-article-method
7457 (nconc (list (list 'nntp server))
7458 gnus-refer-article-method))
7459 (nntp-port-number (or port "nntp")))
7460 (gnus-message 7 "Fetching %s with %s"
7461 message-id gnus-refer-article-method)
7462 (gnus-summary-refer-article message-id))
7463 (gnus-summary-refer-article message-id))))
7465 (gnus-button-fetch-group url)))))
7467 (defun gnus-button-handle-man (url)
7469 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7470 (when (eq gnus-button-man-handler 'woman)
7471 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
7472 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7473 (funcall gnus-button-man-handler url))
7475 (defun gnus-button-handle-info-url (url)
7476 "Fetch an info URL."
7477 (setq url (mm-subst-char-in-string ?+ ?\ url))
7479 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
7480 (gnus-info-find-node
7481 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
7483 ")" (gnus-url-unhex-string (match-string 2 url)))))
7484 ((string-match "([^)\"]+)[^\"]+" url)
7486 (gnus-replace-in-string
7487 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
7488 (gnus-info-find-node url))
7489 (t (error "Can't parse %s" url))))
7491 (defun gnus-button-handle-info-url-gnome (url)
7492 "Fetch GNOME style info URL."
7493 (setq url (mm-subst-char-in-string ?_ ?\ url))
7494 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
7495 (gnus-info-find-node
7497 (gnus-url-unhex-string
7498 (match-string 1 url))
7500 (or (gnus-url-unhex-string
7501 (match-string 2 url))
7503 (error "Can't parse %s" url)))
7505 (defun gnus-button-handle-info-url-kde (url)
7506 "Fetch KDE style info URL."
7507 (gnus-info-find-node (gnus-url-unhex-string url)))
7509 (defun gnus-button-handle-info-keystrokes (url)
7510 "Call `info' when pushing the corresponding URL button."
7511 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
7516 (defun gnus-button-openpgp (url)
7517 "Retrieve and add an OpenPGP key given URL from an OpenPGP header."
7519 (mm-url-insert-file-contents-external url)
7520 (pgg-snarf-keys-region (point-min) (point-max))
7521 (pgg-display-output-buffer nil nil nil)))
7523 (defun gnus-button-message-id (message-id)
7525 (with-current-buffer gnus-summary-buffer
7526 (gnus-summary-refer-article message-id)))
7528 (defun gnus-button-fetch-group (address)
7529 "Fetch GROUP specified by ADDRESS."
7530 (if (not (string-match "[:/]" address))
7531 ;; This is just a simple group url.
7532 (gnus-group-read-ephemeral-group address gnus-select-method)
7535 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
7537 (error "Can't parse %s" address)
7538 (gnus-group-read-ephemeral-group
7539 (match-string 4 address)
7540 `(nntp ,(match-string 1 address)
7541 (nntp-address ,(match-string 1 address))
7542 (nntp-port-number ,(if (match-end 3)
7543 (match-string 3 address)
7546 (and (match-end 6) (list (string-to-number (match-string 6 address))))))))
7548 (defun gnus-url-parse-query-string (query &optional downcase)
7549 (let (retval pairs cur key val)
7550 (setq pairs (split-string query "&"))
7552 (setq cur (car pairs)
7554 (if (not (string-match "=" cur))
7556 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
7557 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
7559 (setq key (downcase key)))
7560 (setq cur (assoc key retval))
7562 (setcdr cur (cons val (cdr cur)))
7563 (setq retval (cons (list key val) retval)))))
7566 (defun gnus-url-mailto (url)
7567 ;; Send mail to someone
7568 (when (string-match "mailto:/*\\(.*\\)" url)
7569 (setq url (substring url (match-beginning 1) nil)))
7570 (let (to args subject func)
7571 (setq args (gnus-url-parse-query-string
7572 (if (string-match "^\\?" url)
7574 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
7575 (concat "to=" (match-string 1 url) "&"
7576 (match-string 2 url))
7577 (concat "to=" url)))
7579 subject (cdr-safe (assoc "subject" args)))
7582 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
7585 (message-position-on-field (caar args)))
7586 (insert (gnus-replace-in-string
7587 (mapconcat 'identity (reverse (cdar args)) ", ")
7589 (setq args (cdr args)))
7592 (message-goto-subject))))
7594 (defun gnus-button-embedded-url (address)
7595 "Activate ADDRESS with `browse-url'."
7596 (browse-url (gnus-strip-whitespace address)))
7598 ;;; Next/prev buttons in the article buffer.
7600 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
7601 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
7603 (defvar gnus-prev-page-map
7604 (let ((map (make-sparse-keymap)))
7605 (define-key map gnus-mouse-2 'gnus-button-prev-page)
7606 (define-key map "\r" 'gnus-button-prev-page)
7609 (defvar gnus-next-page-map
7610 (let ((map (make-sparse-keymap)))
7611 (unless (>= emacs-major-version 21)
7612 ;; XEmacs doesn't care.
7613 (set-keymap-parent map gnus-article-mode-map))
7614 (define-key map gnus-mouse-2 'gnus-button-next-page)
7615 (define-key map "\r" 'gnus-button-next-page)
7618 (defun gnus-insert-prev-page-button ()
7620 (inhibit-read-only t)
7621 (situation (get-text-property (point-min) 'mime-view-situation)))
7623 gnus-prev-page-line-format nil
7624 `(keymap ,gnus-prev-page-map
7626 gnus-callback gnus-article-button-prev-page
7627 article-type annotation
7628 mime-view-situation ,situation))
7629 (widget-convert-button
7631 ;; Exclude a newline.
7634 :action 'gnus-button-prev-page
7635 :button-keymap gnus-prev-page-map)))
7637 (defun gnus-button-next-page (&optional args more-args)
7638 "Go to the next page."
7640 (let ((win (selected-window)))
7641 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7642 (gnus-article-next-page)
7643 (select-window win)))
7645 (defun gnus-button-prev-page (&optional args more-args)
7646 "Go to the prev page."
7648 (let ((win (selected-window)))
7649 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7650 (gnus-article-prev-page)
7651 (select-window win)))
7653 (defun gnus-insert-next-page-button ()
7655 (inhibit-read-only t)
7656 (situation (get-text-property (point-min) 'mime-view-situation)))
7657 (gnus-eval-format gnus-next-page-line-format nil
7658 `(keymap ,gnus-next-page-map
7660 gnus-callback gnus-article-button-next-page
7661 article-type annotation
7662 mime-view-situation ,situation))
7663 (widget-convert-button
7665 ;; Exclude a newline.
7668 :action 'gnus-button-next-page
7669 :button-keymap gnus-next-page-map)))
7671 (defun gnus-article-button-next-page (arg)
7672 "Go to the next page."
7674 (let ((win (selected-window)))
7675 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7676 (gnus-article-next-page)
7677 (select-window win)))
7679 (defun gnus-article-button-prev-page (arg)
7680 "Go to the prev page."
7682 (let ((win (selected-window)))
7683 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7684 (gnus-article-prev-page)
7685 (select-window win)))
7687 (defvar gnus-decode-header-methods
7688 '(mail-decode-encoded-word-region)
7689 "List of methods used to decode headers.
7691 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
7692 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
7693 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
7694 whose names match REGEXP.
7697 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
7698 mail-decode-encoded-word-region
7699 (\"chinese\" . rfc1843-decode-region))
7702 (defvar gnus-decode-header-methods-cache nil)
7704 (defun gnus-multi-decode-header (start end)
7705 "Apply the functions from `gnus-encoded-word-methods' that match."
7706 (unless (and gnus-decode-header-methods-cache
7707 (eq gnus-newsgroup-name
7708 (car gnus-decode-header-methods-cache)))
7709 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
7712 (nconc gnus-decode-header-methods-cache (list x))
7713 (if (and gnus-newsgroup-name
7714 (string-match (car x) gnus-newsgroup-name))
7715 (nconc gnus-decode-header-methods-cache
7717 gnus-decode-header-methods))
7718 (let ((xlist gnus-decode-header-methods-cache))
7721 (narrow-to-region start end)
7723 (funcall (pop xlist) (point-min) (point-max))))))
7726 ;;; Treatment top-level handling.
7729 (defun gnus-treat-article (condition &optional part-number total-parts type)
7730 (let ((length (- (point-max) (point-min)))
7731 (alist gnus-treatment-function-alist)
7732 (article-goto-body-goes-to-point-min-p t)
7736 (let ((list gnus-article-treat-types))
7738 (when (string-match (pop list) type)
7739 (throw 'found t)))))))
7740 (highlightp (gnus-visual-p 'article-highlight 'highlight))
7741 (entity (static-unless (featurep 'xemacs)
7742 (when (eq 'head condition)
7743 (get-text-property (point-min) 'mime-view-entity))))
7744 val elem buttonized)
7745 (gnus-run-hooks 'gnus-part-display-hook)
7746 (unless gnus-inhibit-treatment
7747 (dolist (elem alist)
7750 (when (gnus-buffer-live-p gnus-summary-buffer)
7751 (set-buffer gnus-summary-buffer))
7752 (symbol-value (car elem))))
7753 (when (and (or (consp val)
7755 (gnus-treat-predicate val)
7756 (or (not (get (car elem) 'highlight))
7758 (when (and (not buttonized)
7760 '(gnus-treat-hide-signature
7761 gnus-treat-highlight-signature)))
7762 (gnus-article-buttonize-signature)
7763 (setq buttonized t))
7765 (funcall (cadr elem)))))
7766 ;; FSF Emacsen does not inherit the existing text properties
7767 ;; in the new text, so we should do it for `mime-view-entity'.
7768 (static-unless (featurep 'xemacs)
7770 (put-text-property (point-min) (point-max)
7771 'mime-view-entity entity))))))
7773 ;; Dynamic variables.
7775 (defvar part-number)
7776 (defvar total-parts)
7781 (defun gnus-treat-predicate (val)
7786 (stringp (car val)))
7787 (apply 'gnus-or (mapcar `(lambda (s)
7788 (string-match s ,(or gnus-newsgroup-name "")))
7791 (let ((pred (pop val)))
7794 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
7796 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
7798 (not (gnus-treat-predicate (car val))))
7800 (equal (car val) type))
7802 (error "%S is not a valid predicate" pred)))))
7814 (eq part-number total-parts))
7818 (error "%S is not a valid value" val))))
7820 (defun gnus-article-encrypt-body (protocol &optional n)
7821 "Encrypt the article body."
7824 (or gnus-article-encrypt-protocol
7825 (completing-read "Encrypt protocol: "
7826 gnus-article-encrypt-protocol-alist
7828 current-prefix-arg))
7829 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7831 (error "Can't find the encrypt protocol %s" protocol))
7832 (if (member gnus-newsgroup-name '("nndraft:delayed"
7835 (error "Can't encrypt the article in group %s"
7836 gnus-newsgroup-name))
7837 (gnus-summary-iterate n
7839 (set-buffer gnus-summary-buffer)
7840 (let ((mail-parse-charset gnus-newsgroup-charset)
7841 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7842 (summary-buffer gnus-summary-buffer)
7844 (gnus-set-global-variables)
7845 (when (gnus-group-read-only-p)
7846 (error "The current newsgroup does not support article encrypt"))
7847 (gnus-summary-show-article t)
7849 (or (mail-header-references gnus-current-headers) ""))
7850 (set-buffer gnus-article-buffer)
7851 (let* ((inhibit-read-only t)
7853 (mapcar (lambda (field)
7854 (and (save-restriction
7855 (message-narrow-to-head)
7856 (goto-char (point-min))
7857 (search-forward field nil t))
7859 (message-narrow-to-field)
7861 (delete-region (point-min) (point-max))
7863 '("Content-Type:" "Content-Transfer-Encoding:"
7864 "Content-Disposition:"))))
7865 (message-narrow-to-head)
7866 (message-remove-header "MIME-Version")
7867 (goto-char (point-max))
7868 (setq point (point))
7869 (insert (apply 'concat headers))
7871 (narrow-to-region point (point-max))
7872 (let ((message-options message-options))
7873 (message-options-set 'message-sender user-mail-address)
7874 (message-options-set 'message-recipients user-mail-address)
7875 (message-options-set 'message-sign-encrypt 'not)
7877 (goto-char (point-min))
7878 (insert "MIME-Version: 1.0\n")
7880 (gnus-summary-edit-article-done
7881 references nil summary-buffer t))
7882 (when gnus-keep-backlog
7883 (gnus-backlog-remove-article
7884 (car gnus-article-current) (cdr gnus-article-current)))
7886 (when (get-buffer gnus-original-article-buffer)
7887 (set-buffer gnus-original-article-buffer)
7888 (setq gnus-original-article nil)))
7889 (when gnus-use-cache
7890 (gnus-cache-update-article
7891 (car gnus-article-current) (cdr gnus-article-current))))))))
7893 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7894 "The following specs can be used:
7895 %t The security MIME type
7898 %D Details if button is pressed")
7900 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
7901 "The following specs can be used:
7902 %t The security MIME type
7905 %D Details if button is pressed")
7907 (defvar gnus-mime-security-button-line-format-alist
7908 '((?t gnus-tmp-type ?s)
7909 (?i gnus-tmp-info ?s)
7910 (?d gnus-tmp-details ?s)
7911 (?D gnus-tmp-pressed-details ?s)))
7913 (defvar gnus-mime-security-button-commands
7914 '((gnus-article-press-button "\r" "Show Detail")
7918 (gnus-mime-security-save-part "o" "Save...")
7927 (gnus-mime-security-pipe-part "|" "Pipe To Command...")
7930 (defvar gnus-mime-security-button-map
7931 (let ((map (make-sparse-keymap)))
7932 (define-key map gnus-mouse-2 'gnus-article-push-button)
7933 (define-key map gnus-down-mouse-3 'gnus-mime-security-button-menu)
7934 (dolist (c gnus-mime-security-button-commands)
7935 (define-key map (cadr c) (car c)))
7939 gnus-mime-security-button-menu gnus-mime-security-button-map
7940 "Security button menu."
7944 (unless (eq (car c) 'undefined)
7945 (vector (caddr c) (car c) :enable t)))
7946 gnus-mime-security-button-commands))))
7948 (defun gnus-mime-security-button-menu (event prefix)
7949 "Construct a context-sensitive menu of security commands."
7950 (interactive "e\nP")
7951 (save-window-excursion
7952 (let ((pos (event-start event)))
7953 (select-window (posn-window pos))
7954 (goto-char (posn-point pos))
7955 (gnus-article-check-buffer)
7956 (popup-menu gnus-mime-security-button-menu nil prefix))))
7958 (defvar gnus-mime-security-details-buffer nil)
7960 (defvar gnus-mime-security-button-pressed nil)
7962 (defvar gnus-mime-security-show-details-inline t
7963 "If non-nil, show details in the article buffer.")
7965 (defun gnus-mime-security-verify-or-decrypt (handle)
7966 (mm-remove-parts (cdr handle))
7967 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7968 point (inhibit-read-only t))
7970 (goto-char (car region)))
7972 (narrow-to-region (point) (point))
7973 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7974 (let* ((mm-verify-option 'known)
7975 (mm-decrypt-option 'known)
7976 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7977 (unless (eq nparts (cdr handle))
7978 (mm-destroy-parts (cdr handle))
7979 (setcdr handle nparts))))
7980 (setq point (point))
7981 (gnus-mime-display-security handle)
7982 (goto-char (point-max)))
7984 (delete-region (point) (cdr region))
7985 (set-marker (car region) nil)
7986 (set-marker (cdr region) nil))
7989 (defun gnus-mime-security-show-details (handle)
7990 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7992 (gnus-message 5 "No details.")
7993 (if gnus-mime-security-show-details-inline
7994 (let ((gnus-mime-security-button-pressed
7995 (not (get-text-property (point) 'gnus-mime-details)))
7996 (gnus-mime-security-button-line-format
7997 (get-text-property (point) 'gnus-line-format))
7998 (inhibit-read-only t))
8000 (while (eq (get-text-property (point) 'gnus-line-format)
8001 gnus-mime-security-button-line-format)
8005 (narrow-to-region (point) (point))
8006 (gnus-insert-mime-security-button handle))
8007 (delete-region (point)
8008 (or (text-property-not-all
8011 gnus-mime-security-button-line-format)
8014 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
8015 (with-current-buffer gnus-mime-security-details-buffer
8018 (setq gnus-mime-security-details-buffer
8019 (gnus-get-buffer-create "*MIME Security Details*")))
8020 (with-current-buffer gnus-mime-security-details-buffer
8022 (goto-char (point-min)))
8023 (pop-to-buffer gnus-mime-security-details-buffer)))))
8025 (defun gnus-mime-security-press-button (handle)
8027 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
8028 (gnus-mime-security-show-details handle)
8029 (gnus-mime-security-verify-or-decrypt handle))))
8031 (defun gnus-insert-mime-security-button (handle &optional displayed)
8032 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
8035 (or (nth 2 (assoc protocol mm-verify-function-alist))
8036 (nth 2 (assoc protocol mm-decrypt-function-alist))
8038 (if (equal (car handle) "multipart/signed")
8039 " Signed" " Encrypted")
8042 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
8045 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
8046 gnus-tmp-pressed-details
8048 (setq gnus-tmp-details
8049 (if gnus-tmp-details
8050 (concat "\n" gnus-tmp-details)
8052 (setq gnus-tmp-pressed-details
8053 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
8058 gnus-mime-security-button-line-format
8059 gnus-mime-security-button-line-format-alist
8060 `(keymap ,gnus-mime-security-button-map
8061 gnus-callback gnus-mime-security-press-button
8062 gnus-line-format ,gnus-mime-security-button-line-format
8063 gnus-mime-details ,gnus-mime-security-button-pressed
8064 article-type annotation
8067 ;; Exclude a newline.
8070 (widget-convert-button
8073 :action 'gnus-widget-press-button
8074 :button-keymap gnus-mime-security-button-map
8076 (lambda (widget/window &optional overlay pos)
8077 ;; Needed to properly clear the message due to a bug in
8078 ;; wid-edit (XEmacs only).
8079 (when (boundp 'help-echo-owns-message)
8080 (setq help-echo-owns-message t))
8082 "%S: show detail; %S: more options"
8083 (aref gnus-mouse-2 0)
8084 (aref gnus-down-mouse-3 0))))))
8086 (defun gnus-mime-display-security (handle)
8088 (narrow-to-region (point) (point))
8089 (unless (gnus-unbuttonized-mime-type-p (car handle))
8090 (gnus-insert-mime-security-button handle))
8091 (gnus-mime-display-part (cadr handle))
8094 (unless (gnus-unbuttonized-mime-type-p (car handle))
8095 (let ((gnus-mime-security-button-line-format
8096 gnus-mime-security-button-end-line-format))
8097 (gnus-insert-mime-security-button handle)))
8098 (mm-set-handle-multipart-parameter
8100 (cons (set-marker (make-marker) (point-min))
8101 (set-marker (make-marker) (point-max))))))
8107 (defun gnus-article-header-presentation-method (entity situation)
8108 (mime-insert-header entity)
8109 (article-decode-group-name))
8111 (set-alist 'mime-header-presentation-method-alist
8112 'gnus-original-article-mode
8113 #'gnus-article-header-presentation-method)
8115 (defun gnus-mime-preview-quitting-method ()
8116 (mime-preview-kill-buffer)
8117 (delete-other-windows)
8118 (gnus-article-show-summary)
8119 (gnus-summary-select-article gnus-show-all-headers t))
8121 (set-alist 'mime-preview-quitting-method-alist
8122 'gnus-original-article-mode #'gnus-mime-preview-quitting-method)
8124 (set-alist 'mime-preview-following-method-alist
8125 'gnus-original-article-mode #'gnus-following-method)
8127 (set-alist 'mime-preview-over-to-previous-method-alist
8128 'gnus-original-article-mode
8130 (if (> (point-min) 1)
8131 (gnus-article-prev-page)
8132 (gnus-article-read-summary-keys
8133 nil (gnus-character-to-event ?P)))))
8135 (set-alist 'mime-preview-over-to-next-method-alist
8136 'gnus-original-article-mode'
8138 (if (< (point-max) (buffer-size))
8139 (gnus-article-next-page)
8140 (gnus-article-read-summary-keys
8141 nil (gnus-character-to-event ?N)))))
8147 (defun gnus-mime-security-run-function (function)
8148 "Run FUNCTION with the security part under point."
8149 (gnus-article-check-buffer)
8150 (let ((data (get-text-property (point) 'gnus-data))
8152 (when (and (stringp (car-safe data))
8153 (setq buffer (mm-handle-multipart-original-buffer data))
8154 (setq handle (cadr data)))
8155 (if (bufferp (mm-handle-buffer handle))
8157 (setq handle (cons buffer (copy-sequence (cdr handle))))
8158 (mm-handle-set-undisplayer handle nil))
8159 (setq handle (mm-make-handle
8161 (mm-handle-multipart-ctl-parameter handle 'protocol)
8162 nil nil nil nil nil nil)))
8163 (funcall function handle))))
8165 (defun gnus-mime-security-save-part ()
8166 "Save the security part under point."
8168 (gnus-mime-security-run-function 'mm-save-part))
8170 (defun gnus-mime-security-pipe-part ()
8171 "Pipe the security part under point to a process."
8173 (gnus-mime-security-run-function 'mm-pipe-part))
8179 (run-hooks 'gnus-art-load-hook)
8181 ;;; gnus-art.el ends here