1 ;;; gnus-art.el --- article mode commands for Semi-gnus
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005 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."
2640 (let ((inhibit-read-only t)
2642 (when (gnus-buffer-live-p gnus-original-article-buffer)
2643 (with-current-buffer gnus-original-article-buffer
2644 (let* ((ct (gnus-fetch-field "content-type"))
2647 (mail-header-parse-content-type ct)))))
2648 (setq charset (and ctl
2649 (mail-content-type-get ctl 'charset)))
2650 (when (stringp charset)
2651 (setq charset (intern (downcase charset)))))))
2653 (setq charset (mm-read-coding-system "Charset: " charset)))
2655 (setq charset gnus-newsgroup-charset))
2657 (save-window-excursion
2659 (narrow-to-region (point) (point-max))
2660 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2661 (entry (assq func mm-text-html-washer-alist)))
2663 (setq func (cdr entry)))
2668 (apply (car func) (cdr func))))))))))
2670 (defun gnus-article-wash-html-with-w3 ()
2671 "Wash the current buffer with w3."
2673 (let ((w3-strict-width (window-width))
2674 (url-standalone-mode t)
2675 (url-gateway-unplugged t)
2676 (w3-honor-stylesheets nil))
2678 (w3-region (point-min) (point-max))
2681 (defun gnus-article-wash-html-with-w3m ()
2682 "Wash the current buffer with emacs-w3m."
2684 (let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp)
2685 w3m-force-redisplay)
2686 (w3m-region (point-min) (point-max)))
2687 (when (and mm-inline-text-html-with-w3m-keymap
2688 (boundp 'w3m-minor-mode-map)
2690 (add-text-properties
2691 (point-min) (point-max)
2692 (list 'keymap w3m-minor-mode-map
2693 ;; Put the mark meaning this part was rendered by emacs-w3m.
2694 'mm-inline-text-html-with-w3m t))))
2696 (defun article-hide-list-identifiers ()
2697 "Remove list identifies from the Subject header.
2698 The `gnus-list-identifiers' variable specifies what to do."
2700 (let ((inhibit-point-motion-hooks t)
2701 (regexp (if (consp gnus-list-identifiers)
2702 (mapconcat 'identity gnus-list-identifiers " *\\|")
2703 gnus-list-identifiers))
2704 (inhibit-read-only t))
2708 (article-narrow-to-head)
2709 (goto-char (point-min))
2710 (while (re-search-forward
2711 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2713 (delete-region (match-beginning 2) (match-end 0))
2714 (beginning-of-line))
2715 (when (re-search-forward
2716 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2717 (delete-region (match-beginning 1) (match-end 1))))))))
2719 (defun article-hide-pem (&optional arg)
2720 "Toggle hiding of any PEM headers and signatures in the current article.
2721 If given a negative prefix, always show; if given a positive prefix,
2723 (interactive (gnus-article-hidden-arg))
2724 (unless (gnus-article-check-hidden-text 'pem arg)
2726 (let ((inhibit-read-only t) end)
2727 (goto-char (point-min))
2728 ;; Hide the horrendously ugly "header".
2729 (when (and (search-forward
2730 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2732 (setq end (1+ (match-beginning 0))))
2733 (gnus-add-wash-type 'pem)
2734 (gnus-article-hide-text-type
2736 (if (search-forward "\n\n" nil t)
2740 ;; Hide the trailer as well
2741 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2743 (gnus-article-hide-text-type
2744 (match-beginning 0) (match-end 0) 'pem)))))))
2746 (defun article-strip-banner ()
2747 "Strip the banners specified by the `banner' group parameter and by
2748 `gnus-article-address-banner-alist'."
2752 (let ((inhibit-point-motion-hooks t))
2753 (when (gnus-parameter-banner gnus-newsgroup-name)
2754 (article-really-strip-banner
2755 (gnus-parameter-banner gnus-newsgroup-name)))
2756 (when gnus-article-address-banner-alist
2757 ;; It is necessary to encode from fields before checking,
2758 ;; because `mail-header-parse-addresses' does not work
2759 ;; (reliably) on decoded headers. And more, it is
2760 ;; impossible to use `gnus-fetch-original-field' here,
2761 ;; because `article-strip-banner' may be called in draft
2762 ;; buffers to preview them.
2763 (let ((from (save-restriction
2765 (article-narrow-to-head)
2766 (mail-fetch-field "from"))))
2769 (caar (mail-header-parse-addresses
2770 (mail-encode-encoded-word-string from)))))
2772 (dolist (pair gnus-article-address-banner-alist)
2773 (when (string-match (car pair) from)
2775 (article-really-strip-banner (cdr pair)))))))))))))
2777 (defun article-really-strip-banner (banner)
2778 "Strip the banner specified by the argument."
2781 (let ((inhibit-point-motion-hooks t)
2782 (gnus-signature-limit nil)
2783 (inhibit-read-only t))
2786 ((eq banner 'signature)
2787 (when (gnus-article-narrow-to-signature)
2790 (delete-region (point) (point-max))))
2792 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2793 (while (re-search-forward banner nil t)
2794 (delete-region (match-beginning 0) (match-end 0)))))
2796 (while (re-search-forward banner nil t)
2797 (delete-region (match-beginning 0) (match-end 0)))))))))
2799 (defun article-babel ()
2800 "Translate article using an online translation service."
2803 (gnus-with-article-buffer
2804 (when (article-goto-body)
2805 (let* ((start (point))
2807 (orig (buffer-substring start end))
2808 (trans (babel-as-string orig)))
2810 (narrow-to-region start end)
2811 (delete-region start end)
2814 (defun article-hide-signature (&optional arg)
2815 "Hide the signature in the current article.
2816 If given a negative prefix, always show; if given a positive prefix,
2818 (interactive (gnus-article-hidden-arg))
2824 (article-goto-body))
2825 (goto-char (point-min)))
2826 (unless (gnus-article-check-hidden-text 'signature arg)
2827 (let ((inhibit-read-only t)
2829 (while (setq button (text-property-any button (point-max)
2831 'gnus-signature-toggle))
2832 (setq button (text-property-not-all button (point-max)
2834 'gnus-signature-toggle))
2835 (when (and button (not (eobp)))
2836 (gnus-article-hide-text-type
2838 (next-single-property-change (1+ button) 'mime-view-entity
2841 (gnus-set-mode-line 'article))
2843 (defun article-strip-headers-in-body ()
2844 "Strip offensive headers from bodies."
2848 (let ((case-fold-search t))
2849 (when (looking-at "x-no-archive:")
2850 (gnus-delete-line)))))
2852 (defun article-strip-leading-blank-lines ()
2853 "Remove all blank lines from the beginning of the article."
2856 (let ((inhibit-point-motion-hooks t)
2857 (inhibit-read-only t))
2858 (when (article-goto-body)
2859 (while (and (not (eobp))
2860 (looking-at "[ \t]*$"))
2861 (gnus-delete-line))))))
2863 (defun article-narrow-to-head ()
2864 "Narrow the buffer to the head of the message.
2865 Point is left at the beginning of the narrowed-to region."
2867 (goto-char (point-min))
2868 (if (search-forward "\n\n" nil 1)
2871 (goto-char (point-min)))
2873 (defun article-goto-body ()
2874 "Place point at the start of the body."
2875 (goto-char (point-min))
2877 ;; This variable is only bound when dealing with separate
2879 (article-goto-body-goes-to-point-min-p
2881 ((search-forward "\n\n" nil t)
2884 (goto-char (point-max))
2887 (defun article-strip-multiple-blank-lines ()
2888 "Replace consecutive blank lines with one empty line."
2891 (let ((inhibit-point-motion-hooks t)
2892 (inhibit-read-only t))
2893 ;; First make all blank lines empty.
2895 (while (re-search-forward "^[ \t]+$" nil t)
2896 (unless (gnus-annotation-in-region-p
2897 (match-beginning 0) (match-end 0))
2898 (replace-match "" nil t)))
2899 ;; Then replace multiple empty lines with a single empty line.
2901 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2902 (unless (gnus-annotation-in-region-p
2903 (match-beginning 0) (match-end 0))
2904 (delete-region (match-beginning 1) (match-end 1)))))))
2906 (defun article-strip-leading-space ()
2907 "Remove all white space from the beginning of the lines in the article."
2910 (let ((inhibit-point-motion-hooks t)
2911 (inhibit-read-only t))
2913 (while (re-search-forward "^[ \t]+" nil t)
2914 (replace-match "" t t)))))
2916 (defun article-strip-trailing-space ()
2917 "Remove all white space from the end of the lines in the article."
2920 (let ((inhibit-point-motion-hooks t)
2921 (inhibit-read-only t))
2923 (while (re-search-forward "[ \t]+$" nil t)
2924 (replace-match "" t t)))))
2926 (defun article-strip-blank-lines ()
2927 "Strip leading, trailing and multiple blank lines."
2929 (article-strip-leading-blank-lines)
2930 (article-remove-trailing-blank-lines)
2931 (article-strip-multiple-blank-lines))
2933 (defun article-strip-all-blank-lines ()
2934 "Strip all blank lines."
2937 (let ((inhibit-point-motion-hooks t)
2938 (inhibit-read-only t))
2940 (while (re-search-forward "^[ \t]*\n" nil t)
2941 (replace-match "" t t)))))
2943 (defun gnus-article-narrow-to-signature ()
2944 "Narrow to the signature; return t if a signature is found, else nil."
2945 (let ((inhibit-point-motion-hooks t))
2946 (when (gnus-article-search-signature)
2948 ;; Check whether we have some limits to what we consider
2949 ;; to be a signature.
2950 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2951 (list gnus-signature-limit)))
2953 (while (setq limit (pop limits))
2954 (if (or (and (integerp limit)
2955 (< (- (point-max) (point)) limit))
2957 (< (count-lines (point) (point-max)) limit))
2958 (and (functionp limit)
2960 (and (stringp limit)
2961 (not (re-search-forward limit nil t))))
2962 () ; This limit did not succeed.
2966 (narrow-to-region (point) (point-max))
2969 (defun gnus-article-search-signature ()
2970 "Search the current buffer for the signature separator.
2971 Put point at the beginning of the signature separator."
2972 (let ((cur (point)))
2973 (goto-char (point-max))
2974 (if (if (stringp gnus-signature-separator)
2975 (re-search-backward gnus-signature-separator nil t)
2976 (let ((seps gnus-signature-separator))
2978 (not (re-search-backward (car seps) nil t)))
2985 (defun gnus-article-hidden-arg ()
2986 "Return the current prefix arg as a number, or 0 if no prefix."
2987 (list (if current-prefix-arg
2988 (prefix-numeric-value current-prefix-arg)
2991 (defun gnus-article-check-hidden-text (type arg)
2992 "Return nil if hiding is necessary.
2993 Arg can be nil or a number. nil and positive means hide, negative
2994 means show, 0 means toggle."
2997 (let ((hide (gnus-article-hidden-text-p type)))
3003 (gnus-article-show-hidden-text type)
3006 (if (eq hide 'hidden)
3008 (gnus-article-show-hidden-text type)
3012 (defun gnus-article-hidden-text-p (type)
3013 "Say whether the current buffer contains hidden text of type TYPE."
3014 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
3016 (not (get-text-property pos 'invisible))
3017 (not (get-text-property pos 'dummy-invisible)))
3019 (text-property-any (1+ pos) (point-max) 'article-type type)))
3024 (defun gnus-article-show-hidden-text (type &optional dummy)
3025 "Show all hidden text of type TYPE.
3026 Originally it is hide instead of DUMMY."
3027 (let ((inhibit-read-only t)
3028 (inhibit-point-motion-hooks t))
3029 (gnus-remove-text-properties-when
3031 (point-min) (point-max)
3032 (cons 'article-type (cons type
3033 gnus-hidden-properties)))
3034 (gnus-delete-wash-type type)))
3036 (defconst article-time-units
3037 `((year . ,(* 365.25 24 60 60))
3038 (week . ,(* 7 24 60 60))
3039 (day . ,(* 24 60 60))
3043 "Mapping from time units to seconds.")
3045 (defun gnus-article-forward-header ()
3046 "Move point to the start of the next header.
3047 If the current header is a continuation header, this can be several
3052 (if (looking-at "[ \t]+[^ \t]")
3056 (defun article-date-ut (&optional type highlight)
3057 "Convert DATE date to universal time in the current article.
3058 If TYPE is `local', convert to local time; if it is `lapsed', output
3059 how much time has lapsed since DATE. For `lapsed', the value of
3060 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
3061 should replace the \"Date:\" one, or should be added below it."
3062 (interactive (list 'ut t))
3063 (let* ((tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
3064 (date-regexp (cond ((not gnus-article-date-lapsed-new-header)
3068 (article-lapsed-timer
3072 (case-fold-search t)
3073 (inhibit-read-only t)
3074 (inhibit-point-motion-hooks t)
3075 pos date bface eface)
3079 (goto-char (point-min))
3080 (while (or (setq date (get-text-property (setq pos (point))
3082 (when (setq pos (next-single-property-change
3083 (point) 'original-date))
3084 (setq date (get-text-property pos 'original-date))
3086 (narrow-to-region pos (or (text-property-any pos (point-max)
3089 (goto-char (point-min))
3090 (when (re-search-forward tdate-regexp nil t)
3091 (setq bface (get-text-property (point-at-bol) 'face)
3092 eface (get-text-property (1- (point-at-eol)) 'face)))
3093 (goto-char (point-min))
3095 ;; Delete any old Date headers.
3096 (while (re-search-forward date-regexp nil t)
3098 (delete-region (point-at-bol) (progn
3099 (gnus-article-forward-header)
3101 (delete-region (point-at-bol) (progn
3102 (gnus-article-forward-header)
3105 (setq pos (point))))
3106 (when (and (not pos)
3107 (re-search-forward tdate-regexp nil t))
3109 (gnus-goto-char pos)
3110 (insert (article-make-date-line date (or type 'ut)))
3116 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
3117 (put-text-property (match-beginning 1) (1+ (match-end 1))
3119 (put-text-property (match-beginning 2) (match-end 2)
3121 (put-text-property (point-min) (1- (point-max)) 'original-date date)
3122 (goto-char (point-max))
3125 (defun article-make-date-line (date type)
3126 "Return a DATE line of TYPE."
3127 (unless (memq type '(local ut original user iso8601 lapsed english))
3128 (error "Unknown conversion type: %s" type))
3130 (let ((time (date-to-time date)))
3132 ;; Convert to the local timezone.
3134 (concat "Date: " (message-make-date time)))
3135 ;; Convert to Universal Time.
3140 (let* ((e (parse-time-string date))
3141 (tm (apply 'encode-time e))
3143 (ls (- (cadr tm) (car (current-time-zone time)))))
3144 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
3145 ((> ls 65535) (list (1+ ms) (- ls 65536)))
3149 ;; Get the original date from the article.
3150 ((eq type 'original)
3151 (concat "Date: " (if (string-match "\n+$" date)
3152 (substring date 0 (match-beginning 0))
3154 ;; Let the user define the format.
3156 (let ((format (or (condition-case nil
3157 (with-current-buffer gnus-summary-buffer
3158 gnus-article-time-format)
3160 gnus-article-time-format)))
3161 (if (functionp format)
3162 (funcall format time)
3163 (concat "Date: " (format-time-string format time)))))
3166 (let ((tz (car (current-time-zone time))))
3169 (format-time-string "%Y%m%dT%H%M%S" time)
3170 (format "%s%02d%02d"
3171 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
3172 (/ (% (abs tz) 3600) 60)))))
3173 ;; Do an X-Sent lapsed format.
3175 ;; If the date is seriously mangled, the timezone functions are
3176 ;; liable to bug out, so we ignore all errors.
3177 (let* ((now (current-time))
3178 (real-time (subtract-time now time))
3179 (real-sec (and real-time
3180 (+ (* (float (car real-time)) 65536)
3182 (sec (and real-time (abs real-sec)))
3192 ;; This is a bit convoluted, but basically we go
3193 ;; through the time units for years, weeks, etc,
3194 ;; and divide things to see whether that results
3195 ;; in positive answers.
3198 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
3199 ;; The (remaining) seconds are too few to
3200 ;; be divided into this time unit.
3202 ;; It's big enough, so we output it.
3203 (setq sec (- sec (* num (cdr unit))))
3205 (concat (if prev ", " "") (int-to-string
3207 " " (symbol-name (car unit))
3208 (if (> num 1) "s" ""))
3210 article-time-units "")
3211 ;; If dates are odd, then it might appear like the
3212 ;; article was sent in the future.
3215 " in the future"))))))
3216 ;; Display the date in proper English
3218 (let ((dtime (decode-time time)))
3221 (number-to-string (nth 3 dtime))
3222 (let ((digit (% (nth 3 dtime) 10)))
3224 ((memq (nth 3 dtime) '(11 12 13)) "th")
3230 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3232 (number-to-string (nth 5 dtime))
3234 (format "%02d" (nth 2 dtime))
3236 (format "%02d" (nth 1 dtime)))))))
3238 (format "Date: %s (from T-gnus)" date))))
3240 (defun article-date-local (&optional highlight)
3241 "Convert the current article date to the local timezone."
3242 (interactive (list t))
3243 (article-date-ut 'local highlight))
3245 (defun article-date-english (&optional highlight)
3246 "Convert the current article date to something that is proper English."
3247 (interactive (list t))
3248 (article-date-ut 'english highlight))
3250 (defun article-date-original (&optional highlight)
3251 "Convert the current article date to what it was originally.
3252 This is only useful if you have used some other date conversion
3253 function and want to see what the date was before converting."
3254 (interactive (list t))
3255 (article-date-ut 'original highlight))
3257 (defun article-date-lapsed (&optional highlight)
3258 "Convert the current article date to time lapsed since it was sent."
3259 (interactive (list t))
3260 (article-date-ut 'lapsed highlight))
3262 (defun article-update-date-lapsed ()
3263 "Function to be run from a timer to update the lapsed time line."
3265 (let (deactivate-mark)
3270 (set-buffer (window-buffer w))
3271 (when (or (and (eq major-mode 'mime-view-mode)
3272 (eq (mime-preview-original-major-mode)
3273 'gnus-original-article-mode))
3274 (eq major-mode 'gnus-article-mode))
3275 (let ((mark (point-marker)))
3276 (goto-char (point-min))
3277 (when (re-search-forward "^X-Sent:" nil t)
3278 (article-date-lapsed t))
3279 (goto-char (marker-position mark))
3280 (move-marker mark nil))))
3283 (defun gnus-start-date-timer (&optional n)
3284 "Start a timer to update the X-Sent header in the article buffers.
3285 The numerical prefix says how frequently (in seconds) the function
3290 (gnus-stop-date-timer)
3291 (setq article-lapsed-timer
3292 (run-at-time 1 n 'article-update-date-lapsed)))
3294 (defun gnus-stop-date-timer ()
3295 "Stop the X-Sent timer."
3297 (when article-lapsed-timer
3298 (nnheader-cancel-timer article-lapsed-timer)
3299 (setq article-lapsed-timer nil)))
3301 (defun article-date-user (&optional highlight)
3302 "Convert the current article date to the user-defined format.
3303 This format is defined by the `gnus-article-time-format' variable."
3304 (interactive (list t))
3305 (article-date-ut 'user highlight))
3307 (defun article-date-iso8601 (&optional highlight)
3308 "Convert the current article date to ISO8601."
3309 (interactive (list t))
3310 (article-date-ut 'iso8601 highlight))
3312 (defmacro gnus-article-save-original-date (&rest forms)
3313 "Save the original date as a text property and evaluate FORMS."
3314 `(let* ((case-fold-search t)
3316 (goto-char (point-min))
3317 (when (and (re-search-forward "^date:[\t\n ]+" nil t)
3320 (date (when (and start
3321 (re-search-forward "[\t ]*\n\\(?:[^\t ]\\|\\'\\)"
3323 (buffer-substring-no-properties start
3324 (match-beginning 0)))))
3325 (goto-char (point-max))
3326 (skip-chars-backward "\n")
3327 (put-text-property (point-min) (point) 'original-date date)
3329 (goto-char (point-max))
3330 (skip-chars-backward "\n")
3331 (put-text-property (point-min) (point) 'original-date date)))
3333 ;; (defun article-show-all ()
3334 ;; "Show all hidden text in the article buffer."
3338 ;; (let ((inhibit-read-only t))
3339 ;; (gnus-article-unhide-text (point-min) (point-max))
3340 ;; (gnus-remove-text-with-property 'gnus-prev)
3341 ;; (gnus-remove-text-with-property 'gnus-next))))
3343 (defun article-show-all-headers ()
3344 "Show all hidden headers in the article buffer."
3349 (article-narrow-to-head)
3350 (let ((inhibit-read-only t))
3351 (gnus-article-unhide-text (point-min) (point-max))))))
3353 (defun article-remove-leading-whitespace ()
3354 "Remove excessive whitespace from all headers."
3358 (let ((inhibit-read-only t))
3359 (article-narrow-to-head)
3360 (goto-char (point-min))
3361 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3362 (delete-region (match-beginning 1) (match-end 1)))))))
3364 (defun article-emphasize (&optional arg)
3365 "Emphasize text according to `gnus-emphasis-alist'."
3366 (interactive (gnus-article-hidden-arg))
3367 (unless (gnus-article-check-hidden-text 'emphasis arg)
3371 (with-current-buffer gnus-summary-buffer
3372 gnus-article-emphasis-alist)
3374 gnus-emphasis-alist))
3375 (inhibit-read-only t)
3376 (props (append '(article-type emphasis)
3377 gnus-hidden-properties))
3378 regexp elem beg invisible visible face)
3381 (while (setq elem (pop alist))
3383 (setq regexp (car elem)
3384 invisible (nth 1 elem)
3385 visible (nth 2 elem)
3387 (while (re-search-forward regexp nil t)
3388 (when (and (match-beginning visible) (match-beginning invisible))
3389 (gnus-article-hide-text
3390 (match-beginning invisible) (match-end invisible) props)
3391 (gnus-article-unhide-text-type
3392 (match-beginning visible) (match-end visible) 'emphasis)
3393 (gnus-put-overlay-excluding-newlines
3394 (match-beginning visible) (match-end visible) 'face face)
3395 (gnus-add-wash-type 'emphasis)
3396 (goto-char (match-end invisible)))))))))
3398 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3399 "Setup newsgroup emphasis alist."
3400 (unless gnus-article-emphasis-alist
3401 (let ((name (and gnus-newsgroup-name
3402 (gnus-group-real-name gnus-newsgroup-name))))
3403 (make-local-variable 'gnus-article-emphasis-alist)
3404 (setq gnus-article-emphasis-alist
3406 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3407 (while (setq elem (pop alist))
3408 (when (and name (string-match (car elem) name))
3410 highlight (copy-sequence (cdr elem)))))
3412 (copy-sequence highlight-words)
3413 (if gnus-newsgroup-name
3414 (copy-sequence (gnus-group-find-parameter
3415 gnus-newsgroup-name 'highlight-words t)))
3416 gnus-emphasis-alist)))))
3419 (defvar gnus-summary-article-menu)
3420 (defvar gnus-summary-post-menu))
3422 ;;; Saving functions.
3424 (defun gnus-article-save (save-buffer file &optional num)
3425 "Save the currently selected article."
3426 (unless gnus-save-all-headers
3427 ;; Remove headers according to `gnus-saved-headers'.
3428 (let ((gnus-visible-headers
3429 (or gnus-saved-headers gnus-visible-headers))
3430 (gnus-article-buffer save-buffer))
3432 (set-buffer save-buffer)
3433 (article-hide-headers 1 t))))
3434 (save-window-excursion
3435 (if (not gnus-default-article-saver)
3436 (error "No default saver is defined")
3437 ;; !!! Magic! The saving functions all save
3438 ;; `gnus-save-article-buffer' (or so they think), but we
3439 ;; bind that variable to our save-buffer.
3440 (set-buffer gnus-article-buffer)
3441 (let* ((gnus-save-article-buffer save-buffer)
3444 ((not gnus-prompt-before-saving) 'default)
3445 ((eq gnus-prompt-before-saving 'always) nil)
3447 (gnus-number-of-articles-to-be-saved
3448 (when (eq gnus-prompt-before-saving t)
3450 (set-buffer gnus-article-current-summary)
3451 (funcall gnus-default-article-saver filename)))))
3453 (defun gnus-read-save-file-name (prompt &optional filename
3454 function group headers variable)
3456 (funcall function group headers (symbol-value variable)))
3461 ((eq filename 'default)
3467 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3470 (if (and gnus-number-of-articles-to-be-saved
3471 (> gnus-number-of-articles-to-be-saved 1))
3472 (format "these %d articles"
3473 gnus-number-of-articles-to-be-saved)
3476 ;; Let the split methods have their say.
3478 ;; No split name was found.
3481 (concat prompt " (default "
3482 (file-name-nondirectory default-name) "): ")
3483 (file-name-directory default-name)
3485 ;; A single group name is returned.
3486 ((stringp split-name)
3488 (funcall function split-name headers
3489 (symbol-value variable)))
3491 (concat prompt " (default "
3492 (file-name-nondirectory default-name) "): ")
3493 (file-name-directory default-name)
3495 ;; A single split name was found
3496 ((= 1 (length split-name))
3497 (let* ((name (expand-file-name
3499 gnus-article-save-directory))
3500 (dir (cond ((file-directory-p name)
3501 (file-name-as-directory name))
3502 ((file-exists-p name) name)
3503 (t gnus-article-save-directory))))
3505 (concat prompt " (default " name "): ")
3507 ;; A list of splits was found.
3509 (setq split-name (nreverse split-name))
3511 (let ((file-name-history
3512 (nconc split-name file-name-history)))
3516 (concat prompt " (`M-p' for defaults): ")
3517 gnus-article-save-directory
3519 gnus-article-save-directory)))
3520 (car (push result file-name-history)))))))
3521 ;; Create the directory.
3522 (gnus-make-directory (file-name-directory file))
3523 ;; If we have read a directory, we append the default file name.
3524 (when (file-directory-p file)
3525 (setq file (expand-file-name (file-name-nondirectory
3527 (file-name-as-directory file))))
3528 ;; Possibly translate some characters.
3529 (nnheader-translate-file-chars file))))))
3530 (gnus-make-directory (file-name-directory result))
3531 (set variable result)))
3533 (defun gnus-article-archive-name (group)
3534 "Return the first instance of an \"Archive-name\" in the current buffer."
3535 (let ((case-fold-search t))
3536 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3537 (nnheader-concat gnus-article-save-directory
3538 (match-string 1)))))
3540 (defun gnus-article-nndoc-name (group)
3541 "If GROUP is an nndoc group, return the name of the parent group."
3542 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3543 (gnus-group-get-parameter group 'save-article-group)))
3545 (defun gnus-summary-save-in-rmail (&optional filename)
3546 "Append this article to Rmail file.
3547 Optional argument FILENAME specifies file name.
3548 Directory to save to is default to `gnus-article-save-directory'."
3549 (setq filename (gnus-read-save-file-name
3550 "Save %s in rmail file" filename
3551 gnus-rmail-save-name gnus-newsgroup-name
3552 gnus-current-headers 'gnus-newsgroup-last-rmail))
3553 (gnus-eval-in-buffer-window gnus-save-article-buffer
3557 (gnus-output-to-rmail filename))))
3560 (defun gnus-summary-save-in-mail (&optional filename)
3561 "Append this article to Unix mail file.
3562 Optional argument FILENAME specifies file name.
3563 Directory to save to is default to `gnus-article-save-directory'."
3564 (setq filename (gnus-read-save-file-name
3565 "Save %s in Unix mail file" filename
3566 gnus-mail-save-name gnus-newsgroup-name
3567 gnus-current-headers 'gnus-newsgroup-last-mail))
3568 (gnus-eval-in-buffer-window gnus-save-article-buffer
3572 (if (and (file-readable-p filename)
3573 (file-regular-p filename)
3574 (mail-file-babyl-p filename))
3575 (rmail-output-to-rmail-file filename t)
3576 (gnus-output-to-mail filename)))))
3579 (defun gnus-summary-save-in-file (&optional filename overwrite)
3580 "Append this article to file.
3581 Optional argument FILENAME specifies file name.
3582 Directory to save to is default to `gnus-article-save-directory'."
3583 (setq filename (gnus-read-save-file-name
3584 "Save %s in file" filename
3585 gnus-file-save-name gnus-newsgroup-name
3586 gnus-current-headers 'gnus-newsgroup-last-file))
3587 (gnus-eval-in-buffer-window gnus-save-article-buffer
3591 (when (and overwrite
3592 (file-exists-p filename))
3593 (delete-file filename))
3594 (gnus-output-to-file filename))))
3597 (defun gnus-summary-write-to-file (&optional filename)
3598 "Write this article to a file, overwriting it if the file exists.
3599 Optional argument FILENAME specifies file name.
3600 The directory to save in defaults to `gnus-article-save-directory'."
3601 (gnus-summary-save-in-file nil t))
3603 (defun gnus-summary-save-body-in-file (&optional filename)
3604 "Append this article body to a file.
3605 Optional argument FILENAME specifies file name.
3606 The directory to save in defaults to `gnus-article-save-directory'."
3607 (setq filename (gnus-read-save-file-name
3608 "Save %s body in file" filename
3609 gnus-file-save-name gnus-newsgroup-name
3610 gnus-current-headers 'gnus-newsgroup-last-file))
3611 (gnus-eval-in-buffer-window gnus-save-article-buffer
3615 (when (article-goto-body)
3616 (narrow-to-region (point) (point-max)))
3617 (gnus-output-to-file filename))))
3620 (defun gnus-summary-save-in-pipe (&optional command)
3621 "Pipe this article to subprocess."
3623 (cond ((and (eq command 'default)
3624 gnus-last-shell-command)
3625 gnus-last-shell-command)
3630 "Shell command on %s: "
3631 (if (and gnus-number-of-articles-to-be-saved
3632 (> gnus-number-of-articles-to-be-saved 1))
3633 (format "these %d articles"
3634 gnus-number-of-articles-to-be-saved)
3636 gnus-last-shell-command))))
3637 (when (string-equal command "")
3638 (if gnus-last-shell-command
3639 (setq command gnus-last-shell-command)
3640 (error "A command is required")))
3641 (gnus-eval-in-buffer-window gnus-article-buffer
3644 (shell-command-on-region (point-min) (point-max) command nil)))
3645 (setq gnus-last-shell-command command))
3647 (defun gnus-summary-pipe-to-muttprint (&optional command)
3648 "Pipe this article to muttprint."
3649 (setq command (read-string
3650 "Print using command: " gnus-summary-muttprint-program
3651 nil gnus-summary-muttprint-program))
3652 (gnus-summary-save-in-pipe command))
3654 ;;; Article file names when saving.
3656 (defun gnus-capitalize-newsgroup (newsgroup)
3657 "Capitalize NEWSGROUP name."
3658 (when (not (zerop (length newsgroup)))
3659 (concat (char-to-string (upcase (aref newsgroup 0)))
3660 (substring newsgroup 1))))
3662 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3663 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3664 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3665 Otherwise, it is like ~/News/news/group/num."
3668 (concat (if (gnus-use-long-file-name 'not-save)
3669 (gnus-capitalize-newsgroup newsgroup)
3670 (gnus-newsgroup-directory-form newsgroup))
3671 "/" (int-to-string (mail-header-number headers)))
3672 gnus-article-save-directory)))
3674 (string-equal (file-name-directory default)
3675 (file-name-directory last-file))
3676 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3678 (or last-file default))))
3680 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3681 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3682 If variable `gnus-use-long-file-name' is non-nil, it is
3683 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3686 (concat (if (gnus-use-long-file-name 'not-save)
3688 (gnus-newsgroup-directory-form newsgroup))
3689 "/" (int-to-string (mail-header-number headers)))
3690 gnus-article-save-directory)))
3692 (string-equal (file-name-directory default)
3693 (file-name-directory last-file))
3694 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3696 (or last-file default))))
3698 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3699 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3700 If variable `gnus-use-long-file-name' is non-nil, it is
3701 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3704 (if (gnus-use-long-file-name 'not-save)
3707 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3709 gnus-article-save-directory)))
3711 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3712 "Generate file name from sender."
3713 (let ((from (mail-header-from headers)))
3715 (if (and from (string-match "\\([^ <]+\\)@" from))
3716 (match-string 1 from)
3718 gnus-article-save-directory)))
3720 (defun article-verify-x-pgp-sig ()
3723 (if (gnus-buffer-live-p gnus-original-article-buffer)
3724 (let ((sig (with-current-buffer gnus-original-article-buffer
3725 (gnus-fetch-field "X-PGP-Sig")))
3729 (mml2015-clear-verify-function))
3731 (insert-buffer-substring gnus-original-article-buffer)
3732 (setq items (split-string sig))
3733 (message-narrow-to-head)
3734 (let ((inhibit-point-motion-hooks t)
3735 (case-fold-search t))
3736 ;; Don't verify multiple headers.
3737 (setq headers (mapconcat (lambda (header)
3739 (mail-fetch-field header)
3741 (split-string (nth 1 items) ",") "")))
3742 (delete-region (point-min) (point-max))
3743 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3744 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3749 (if (looking-at "^-")
3752 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3753 (insert "Version: " (car items) "\n\n")
3754 (insert (mapconcat 'identity (cddr items) "\n"))
3755 (insert "\n-----END PGP SIGNATURE-----\n")
3756 (let ((mm-security-handle (list (format "multipart/signed"))))
3757 (mml2015-clean-buffer)
3758 (let ((coding-system-for-write (or gnus-newsgroup-charset
3760 (funcall (mml2015-clear-verify-function)))
3762 (or (mm-handle-multipart-ctl-parameter
3763 mm-security-handle 'gnus-details)
3764 (mm-handle-multipart-ctl-parameter
3765 mm-security-handle 'gnus-info)))))
3767 (let ((inhibit-read-only t) bface eface)
3769 (message-narrow-to-head)
3770 (goto-char (point-max))
3772 (setq bface (get-text-property (point-at-bol) 'face)
3773 eface (get-text-property (1- (point-at-eol)) 'face))
3774 (message-remove-header "X-Gnus-PGP-Verify")
3775 (if (re-search-forward "^X-PGP-Sig:" nil t)
3777 (goto-char (point-max)))
3778 (narrow-to-region (point) (point))
3779 (insert "X-Gnus-PGP-Verify: " info "\n")
3780 (goto-char (point-min))
3783 (if (not (looking-at "^[ \t]"))
3787 (goto-char (point-min))
3788 (when (looking-at "\\([^:]+\\): *")
3789 (put-text-property (match-beginning 1) (1+ (match-end 1))
3791 (put-text-property (match-end 0) (point-max)
3792 'face eface)))))))))
3794 (defun article-verify-cancel-lock ()
3795 "Verify Cancel-Lock header."
3797 (if (gnus-buffer-live-p gnus-original-article-buffer)
3798 (canlock-verify gnus-original-article-buffer)))
3800 (defun article-monafy ()
3801 "Display body part with mona font."
3803 (unless (if (featurep 'xemacs)
3804 (find-face 'gnus-mona-face)
3805 (facep 'gnus-mona-face))
3806 (require 'navi2ch-mona)
3807 (set-face-font (make-face 'gnus-mona-face) navi2ch-mona-font))
3809 (let ((inhibit-read-only t))
3812 (gnus-make-overlay (point) (point-max))
3813 'face 'gnus-mona-face))))
3820 (setq afunc (car func)
3823 gfunc (intern (format "gnus-%s" func))))
3825 (when (fboundp afunc)
3826 `(lambda (&optional interactive &rest args)
3827 ,(documentation afunc t)
3828 (interactive (list t))
3830 (set-buffer gnus-article-buffer)
3832 (call-interactively ',afunc)
3833 (apply ',afunc args))))))))
3834 '(article-hide-headers
3835 article-verify-x-pgp-sig
3836 article-verify-cancel-lock
3838 article-hide-boring-headers
3839 article-treat-overstrike
3840 article-treat-ansi-sequences
3841 article-fill-long-lines
3842 article-capitalize-sentences
3844 article-remove-leading-whitespace
3845 article-display-x-face
3846 article-display-face
3847 article-de-quoted-unreadable
3848 article-de-base64-unreadable
3851 article-unsplit-urls
3852 article-hide-list-identifiers
3853 article-strip-banner
3856 article-hide-signature
3857 article-strip-headers-in-body
3858 article-remove-trailing-blank-lines
3859 article-strip-leading-blank-lines
3860 article-strip-multiple-blank-lines
3861 article-strip-leading-space
3862 article-strip-trailing-space
3863 article-strip-blank-lines
3864 article-strip-all-blank-lines
3866 article-date-english
3867 article-date-iso8601
3868 article-date-original
3870 article-decode-mime-words
3871 article-decode-charset
3872 article-decode-encoded-words
3876 article-treat-dumbquotes
3877 article-normalize-headers
3878 (article-show-all-headers . gnus-article-show-all-headers)
3879 ;; (article-show-all . gnus-article-show-all)
3883 ;;; Gnus article mode
3886 (put 'gnus-article-mode 'mode-class 'special)
3888 (gnus-define-keys gnus-article-mode-map
3889 " " gnus-article-goto-next-page
3890 "\177" gnus-article-goto-prev-page
3891 [delete] gnus-article-goto-prev-page
3892 [backspace] gnus-article-goto-prev-page
3893 "\C-c^" gnus-article-refer-article
3894 "h" gnus-article-show-summary
3895 "s" gnus-article-show-summary
3896 "\C-c\C-m" gnus-article-mail
3897 "?" gnus-article-describe-briefly
3898 "e" gnus-summary-edit-article
3899 "<" beginning-of-buffer
3901 "\C-c\C-i" gnus-info-find-node
3903 "R" gnus-article-reply-with-original
3904 "F" gnus-article-followup-with-original
3905 "\C-hk" gnus-article-describe-key
3906 "\C-hc" gnus-article-describe-key-briefly
3908 "\C-d" gnus-article-read-summary-keys
3909 "\M-*" gnus-article-read-summary-keys
3910 "\M-#" gnus-article-read-summary-keys
3911 "\M-^" gnus-article-read-summary-keys
3912 "\M-g" gnus-article-read-summary-keys)
3914 ;; Define almost undefined keys to `gnus-article-read-summary-keys'.
3918 (push (char-to-string key) keys)
3920 (dolist (elem (accessible-keymaps gnus-summary-mode-map))
3921 (setq key (car elem))
3922 (when (and (> (length key) 0)
3923 (not (eq 'menu-bar (aref key 0)))
3924 (symbolp (lookup-key gnus-summary-mode-map key)))
3927 (unless (lookup-key gnus-article-mode-map key)
3928 (define-key gnus-article-mode-map key 'gnus-article-read-summary-keys))))
3930 (defun gnus-article-make-menu-bar ()
3931 (unless (boundp 'gnus-article-commands-menu)
3932 (gnus-summary-make-menu-bar))
3933 (gnus-turn-off-edit-menu 'article)
3934 (unless (boundp 'gnus-article-article-menu)
3936 gnus-article-article-menu gnus-article-mode-map ""
3938 ["Scroll forwards" gnus-article-goto-next-page t]
3939 ["Scroll backwards" gnus-article-goto-prev-page t]
3940 ["Show summary" gnus-article-show-summary t]
3941 ["Fetch Message-ID at point" gnus-article-refer-article t]
3942 ["Mail to address at point" gnus-article-mail t]
3943 ["Send a bug report" gnus-bug t]))
3946 gnus-article-treatment-menu gnus-article-mode-map ""
3947 ;; Fixme: this should use :active (and maybe :visible).
3949 ["Hide headers" gnus-article-hide-headers t]
3950 ["Hide signature" gnus-article-hide-signature t]
3951 ["Hide citation" gnus-article-hide-citation t]
3952 ["Treat overstrike" gnus-article-treat-overstrike t]
3953 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
3954 ["Remove carriage return" gnus-article-remove-cr t]
3955 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3956 ["Treat html" gnus-article-wash-html t]
3957 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3958 ["Decode HZ" gnus-article-decode-HZ t]))
3960 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3962 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3964 (gnus-run-hooks 'gnus-article-menu-hook)))
3966 (defun gnus-article-mode ()
3967 "Major mode for displaying an article.
3969 All normal editing commands are switched off.
3971 The following commands are available in addition to all summary mode
3973 \\<gnus-article-mode-map>
3974 \\[gnus-article-next-page]\t Scroll the article one page forwards
3975 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3976 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3977 \\[gnus-article-show-summary]\t Display the summary buffer
3978 \\[gnus-article-mail]\t Send a reply to the address near point
3979 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3980 \\[gnus-info-find-node]\t Go to the Gnus info node"
3982 (kill-all-local-variables)
3983 (gnus-simplify-mode-line)
3984 (setq mode-name "Article")
3985 (setq major-mode 'gnus-article-mode)
3986 (make-local-variable 'minor-mode-alist)
3987 (unless (assq 'gnus-show-mime minor-mode-alist)
3988 (push (list 'gnus-show-mime " MIME") minor-mode-alist))
3989 (use-local-map gnus-article-mode-map)
3990 (when (gnus-visual-p 'article-menu 'menu)
3991 (gnus-article-make-menu-bar)
3992 (when gnus-summary-tool-bar-map
3993 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3994 (gnus-update-format-specifications nil 'article-mode)
3995 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3996 (set (make-local-variable 'gnus-page-broken) nil)
3997 (make-local-variable 'gnus-button-marker-list)
3998 (make-local-variable 'gnus-article-current-summary)
3999 (make-local-variable 'gnus-article-mime-handles)
4000 (make-local-variable 'gnus-article-decoded-p)
4001 (make-local-variable 'gnus-article-mime-handle-alist)
4002 (make-local-variable 'gnus-article-wash-types)
4003 (make-local-variable 'gnus-article-image-alist)
4004 (make-local-variable 'gnus-article-charset)
4005 (make-local-variable 'gnus-article-ignored-charsets)
4006 ;; Prevent recent Emacsen from displaying non-break space as "\ ".
4007 (set (make-local-variable 'nobreak-char-display) nil)
4008 (gnus-set-default-directory)
4009 (buffer-disable-undo)
4010 (setq buffer-read-only t
4011 show-trailing-whitespace nil)
4012 (set-syntax-table gnus-article-mode-syntax-table)
4013 (gnus-run-mode-hooks 'gnus-article-mode-hook))
4015 (defun gnus-article-setup-buffer ()
4016 "Initialize the article buffer."
4017 (let* ((name (if gnus-single-article-buffer "*Article*"
4018 (concat "*Article " gnus-newsgroup-name "*")))
4020 (progn (string-match "\\*Article" name)
4021 (concat " *Original Article"
4022 (substring name (match-end 0))))))
4023 (setq gnus-article-buffer name)
4024 (setq gnus-original-article-buffer original)
4025 (setq gnus-article-mime-handle-alist nil)
4026 ;; This might be a variable local to the summary buffer.
4027 (unless gnus-single-article-buffer
4029 (set-buffer gnus-summary-buffer)
4030 (setq gnus-article-buffer name)
4031 (setq gnus-original-article-buffer original)
4032 (gnus-set-global-variables)))
4033 (gnus-article-setup-highlight-words)
4034 ;; Init original article buffer.
4036 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
4037 (set-buffer-multibyte t)
4038 (setq major-mode 'gnus-original-article-mode)
4039 (make-local-variable 'gnus-original-article))
4040 (if (and (get-buffer name)
4041 (with-current-buffer name
4042 (if gnus-article-edit-mode
4043 (if (y-or-n-p "Article mode edit in progress; discard? ")
4045 (set-buffer-modified-p nil)
4046 (gnus-kill-buffer name)
4049 (error "Action aborted"))
4053 (set (make-local-variable 'gnus-article-edit-mode) nil)
4054 (buffer-disable-undo)
4055 (setq buffer-read-only t)
4056 ;; This list just keeps growing if we don't reset it.
4057 (setq gnus-button-marker-list nil)
4058 (unless (eq major-mode 'gnus-article-mode)
4059 (gnus-article-mode))
4062 (set-buffer (gnus-get-buffer-create name))
4064 (make-local-variable 'gnus-summary-buffer)
4065 (gnus-summary-set-local-parameters gnus-newsgroup-name)
4066 (current-buffer)))))
4068 ;; Set article window start at LINE, where LINE is the number of lines
4069 ;; from the head of the article.
4070 (defun gnus-article-set-window-start (&optional line)
4072 (gnus-get-buffer-window gnus-article-buffer t)
4074 (set-buffer gnus-article-buffer)
4075 (goto-char (point-min))
4078 (gnus-message 6 "Moved to bookmark")
4079 (search-forward "\n\n" nil t)
4083 ;;; @@ article filters
4086 (defun gnus-article-display-mime-message ()
4087 "Article display method for MIME message."
4088 ;; called from `gnus-original-article-buffer'.
4089 (let (charset all-headers)
4090 (with-current-buffer gnus-summary-buffer
4091 (setq charset default-mime-charset
4092 all-headers gnus-have-all-headers))
4093 (make-local-variable 'default-mime-charset)
4094 (setq default-mime-charset charset)
4095 (with-current-buffer (get-buffer-create gnus-article-buffer)
4096 (make-local-variable 'default-mime-charset)
4097 (setq default-mime-charset charset))
4098 (mime-display-message mime-message-structure
4099 gnus-article-buffer nil gnus-article-mode-map)
4101 (gnus-article-hide-headers nil -1)))
4102 (run-hooks 'gnus-mime-article-prepare-hook))
4104 (defun gnus-article-display-traditional-message ()
4105 "Article display method for traditional message."
4106 (set-buffer gnus-article-buffer)
4107 (let ((inhibit-read-only t))
4109 (insert-buffer-substring gnus-original-article-buffer)))
4111 (defun gnus-article-make-full-mail-header (&optional number charset)
4112 "Create a new mail header structure in a raw article buffer."
4113 (unless (and number charset)
4114 (save-current-buffer
4115 (set-buffer gnus-summary-buffer)
4117 (setq number (or (cdr gnus-article-current) 0)))
4119 (setq charset (or default-mime-charset 'x-ctext)))))
4120 (goto-char (point-min))
4121 (let ((header-end (if (search-forward "\n\n" nil t)
4123 (goto-char (point-max))))
4124 (chars (- (point-max) (point)))
4125 (lines (count-lines (point) (point-max)))
4126 (default-mime-charset charset)
4128 (narrow-to-region (point-min) header-end)
4129 (setq xref (std11-fetch-field "xref"))
4131 (make-full-mail-header
4133 (std11-fetch-field "subject")
4134 (std11-fetch-field "from")
4135 (std11-fetch-field "date")
4136 (std11-fetch-field "message-id")
4137 (std11-fetch-field "references")
4140 (when xref (concat "Xref: " xref)))
4143 (defun gnus-article-prepare (article &optional all-headers header)
4144 "Prepare ARTICLE in article mode buffer.
4145 ARTICLE should either be an article number or a Message-ID.
4146 If ARTICLE is an id, HEADER should be the article headers.
4147 If ALL-HEADERS is non-nil, no headers are hidden."
4149 ;; Make sure we start in a summary buffer.
4150 (unless (eq major-mode 'gnus-summary-mode)
4151 (set-buffer gnus-summary-buffer))
4152 (setq gnus-summary-buffer (current-buffer))
4153 (let* ((gnus-article (if header (mail-header-number header) article))
4154 (summary-buffer (current-buffer))
4155 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
4156 (group gnus-newsgroup-name)
4159 (gnus-article-setup-buffer)
4160 (set-buffer gnus-article-buffer)
4161 ;; Deactivate active regions.
4162 (when (and (boundp 'transient-mark-mode)
4163 transient-mark-mode)
4164 (setq mark-active nil))
4165 (if (not (setq result (let ((inhibit-read-only t))
4166 (gnus-request-article-this-buffer
4168 ;; There is no such article.
4170 (when (and (numberp article)
4171 (not (memq article gnus-newsgroup-sparse)))
4172 (setq gnus-article-current
4173 (cons gnus-newsgroup-name article))
4174 (set-buffer gnus-summary-buffer)
4175 (setq gnus-current-article article)
4176 (if (and (memq article gnus-newsgroup-undownloaded)
4177 (not (gnus-online (gnus-find-method-for-group
4178 gnus-newsgroup-name))))
4180 (gnus-summary-set-agent-mark article)
4181 (message "Message marked for downloading"))
4182 (gnus-summary-mark-article article gnus-canceled-mark)
4183 (unless (memq article gnus-newsgroup-sparse)
4184 (gnus-error 1 "No such article (may have expired or been canceled)")))))
4185 (if (or (eq result 'pseudo)
4186 (eq result 'nneething))
4189 (set-buffer summary-buffer)
4190 (push article gnus-newsgroup-history)
4191 (setq gnus-last-article gnus-current-article
4192 gnus-current-article 0
4193 gnus-current-headers nil
4194 gnus-article-current nil)
4195 (if (eq result 'nneething)
4196 (gnus-configure-windows 'summary)
4197 (gnus-configure-windows 'article))
4198 (gnus-set-global-variables))
4199 (let ((gnus-article-mime-handle-alist-1
4200 gnus-article-mime-handle-alist))
4201 (gnus-set-mode-line 'article)))
4202 ;; The result from the `request' was an actual article -
4203 ;; or at least some text that is now displayed in the
4205 (when (and (numberp article)
4206 (not (eq article gnus-current-article)))
4207 ;; Seems like a new article has been selected.
4208 ;; `gnus-current-article' must be an article number.
4210 (set-buffer summary-buffer)
4211 (push article gnus-newsgroup-history)
4212 (setq gnus-last-article gnus-current-article
4213 gnus-current-article article
4214 gnus-current-headers
4215 (gnus-summary-article-header gnus-current-article)
4216 gnus-article-current
4217 (cons gnus-newsgroup-name gnus-current-article))
4218 (unless (vectorp gnus-current-headers)
4219 (setq gnus-current-headers nil))
4220 (gnus-summary-goto-subject gnus-current-article)
4221 (when (gnus-summary-show-thread)
4222 ;; If the summary buffer really was folded, the
4223 ;; previous goto may not actually have gone to
4224 ;; the right article, but the thread root instead.
4226 (gnus-summary-goto-subject gnus-current-article))
4227 (gnus-run-hooks 'gnus-mark-article-hook)
4228 (gnus-set-mode-line 'summary)
4229 (when (gnus-visual-p 'article-highlight 'highlight)
4230 (gnus-run-hooks 'gnus-visual-mark-article-hook))
4231 ;; Set the global newsgroup variables here.
4232 (gnus-set-global-variables)
4233 (setq gnus-have-all-headers
4234 (or all-headers gnus-show-all-headers))))
4236 (gnus-configure-windows 'article))
4237 (when (or (numberp article)
4239 (gnus-article-prepare-display)
4241 (goto-char (point-min))
4242 (when gnus-break-pages
4243 (gnus-narrow-to-page)))
4244 (let ((gnus-article-mime-handle-alist-1
4245 gnus-article-mime-handle-alist))
4246 (gnus-set-mode-line 'article))
4250 (set-window-point (get-buffer-window (current-buffer)) (point))
4251 (gnus-configure-windows 'article)
4254 (defun gnus-article-prepare-mime-display (&optional number)
4255 (goto-char (point-min))
4256 (when (re-search-forward "^[^\t ]+:" nil t)
4257 (goto-char (match-beginning 0)))
4258 (let ((entity (if (eq 1 (point-min))
4259 (get-text-property 1 'mime-view-entity)
4260 (get-text-property (point) 'mime-view-entity)))
4261 last-entity child-entity next type)
4262 (setq child-entity (mime-entity-children entity))
4264 (setq last-entity (nth (1- (length child-entity))
4266 (setq last-entity entity))
4268 (narrow-to-region (point)
4269 (if (search-forward "\n\n" nil t)
4272 (gnus-article-save-original-date (gnus-treat-article 'head))
4273 (put-text-property (point-min) (point-max) 'article-treated-header t)
4274 (goto-char (point-max)))
4275 (while (and (not (eobp)) entity)
4276 (setq next (set-marker
4278 (next-single-property-change (point) 'mime-view-entity
4280 (let ((types (mime-entity-content-type entity)))
4281 (while (eq 'multipart (mime-content-type-primary-type types))
4282 (setq entity (car (mime-entity-children entity))
4283 types (mime-entity-content-type entity)))
4285 (setq type (format "%s/%s"
4286 (mime-content-type-primary-type types)
4287 (mime-content-type-subtype types)))))
4288 (if (string-equal type "message/rfc822")
4291 (let ((children (mime-entity-children entity))
4294 (setq last-children (nth (1- (length children)) children))
4297 (not (eq last-children
4298 (get-text-property next 'mime-view-entity)))
4300 (next-single-property-change next
4302 nil (point-max)))))))
4303 (setq next (next-single-property-change next 'mime-view-entity
4306 (narrow-to-region (point) next)
4307 (gnus-article-prepare-mime-display)
4308 (goto-char (point-max)))
4309 (setq entity (get-text-property (point) 'mime-view-entity)))
4311 (narrow-to-region (point) next)
4312 ;; Kludge. We have to count true number, but for now,
4313 ;; part number is here only to achieve `last'.
4314 (gnus-treat-article nil 1
4315 (if (eq entity last-entity)
4318 (goto-char (point-max)))
4319 (setq entity (get-text-property next 'mime-view-entity))))))
4322 (defun gnus-article-prepare-display ()
4323 "Make the current buffer look like a nice article."
4324 (let ((gnus-article-buffer (current-buffer))
4326 (inhibit-read-only t))
4327 (unless (eq major-mode 'gnus-article-mode)
4328 (gnus-article-mode))
4329 (setq buffer-read-only nil
4330 gnus-button-marker-list nil
4331 gnus-article-wash-types nil
4332 gnus-article-image-alist nil)
4335 (static-if (featurep 'xemacs)
4336 (map-extents (lambda (extent maparg) (delete-extent extent)))
4337 (let ((lists (overlay-lists)))
4338 (dolist (overlay (nconc (car lists) (cdr lists)))
4339 (delete-overlay overlay)))))
4340 (gnus-run-hooks 'gnus-tmp-internal-hook))
4341 (let ((show-mime (unless (member gnus-newsgroup-name '("nndraft:delayed"
4344 (inhibit-read-only t))
4345 (set-buffer gnus-original-article-buffer)
4347 (setq mime-message-structure gnus-current-headers)
4348 (mime-buffer-entity-set-buffer-internal mime-message-structure
4349 gnus-original-article-buffer)
4350 (mime-entity-set-representation-type-internal mime-message-structure
4351 'mime-buffer-entity)
4352 (luna-send mime-message-structure 'initialize-instance
4353 mime-message-structure)
4355 (let (mime-display-header-hook mime-display-text/plain-hook)
4356 (funcall gnus-article-display-method-for-mime))
4357 (funcall gnus-article-display-method-for-traditional))
4358 ;; Call the treatment functions.
4362 (gnus-article-prepare-mime-display)
4363 (narrow-to-region (goto-char (point-min))
4364 (if (search-forward "\n\n" nil t)
4367 (gnus-article-save-original-date (gnus-treat-article 'head))
4368 (put-text-property (point-min) (point-max) 'article-treated-header t)
4369 (goto-char (point-max))
4371 (narrow-to-region (point) (point-max))
4372 (gnus-treat-article nil))
4373 (put-text-property (point-min) (point-max) 'read-only nil)))
4374 (gnus-run-hooks 'gnus-article-prepare-hook))
4376 (defun gnus-article-decode-article-as-default-mime-charset ()
4377 "Decode an article as `default-mime-charset'. It won't work if the
4378 value of the variable `gnus-show-mime' is non-nil."
4379 (unless (or gnus-show-mime
4380 (member gnus-newsgroup-name '("nndraft:delayed"
4382 (set (make-local-variable 'default-mime-charset)
4383 (with-current-buffer gnus-summary-buffer
4384 default-mime-charset))
4385 (decode-mime-charset-region (point-min) (point-max)
4386 default-mime-charset)))
4389 ;;; Gnus MIME viewing functions
4392 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4393 "Format of the MIME buttons.
4395 Valid specifiers include:
4397 %T MIME type, along with additional info
4398 %n The `name' parameter
4399 %d The description, if any
4400 %l The length of the encoded part
4401 %p The part identifier number
4402 %e Dots if the part isn't displayed
4404 General format specifiers can also be used. See Info node
4405 `(gnus)Formatting Variables'.")
4407 (defvar gnus-mime-button-line-format-alist
4408 '((?t gnus-tmp-type ?s)
4409 (?T gnus-tmp-type-long ?s)
4410 (?n gnus-tmp-name ?s)
4411 (?d gnus-tmp-description ?s)
4413 (?l gnus-tmp-length ?d)
4414 (?e gnus-tmp-dots ?s)))
4416 (defvar gnus-mime-button-commands
4417 '((gnus-article-press-button "\r" "Toggle Display")
4418 (gnus-mime-view-part "v" "View Interactively...")
4419 (gnus-mime-view-part-as-type "t" "View As Type...")
4420 (gnus-mime-view-part-as-charset "C" "View As charset...")
4421 (gnus-mime-save-part "o" "Save...")
4422 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4423 (gnus-mime-replace-part "r" "Replace part")
4424 (gnus-mime-delete-part "d" "Delete part")
4425 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4426 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4427 (gnus-mime-view-part-internally "E" "View Internally") ;; Why `E'?
4428 (gnus-mime-view-part-externally "e" "View Externally")
4429 (gnus-mime-print-part "p" "Print")
4430 (gnus-mime-pipe-part "|" "Pipe To Command...")
4431 (gnus-mime-action-on-part "." "Take action on the part...")))
4433 (defun gnus-article-mime-part-status ()
4434 (with-current-buffer gnus-article-buffer
4435 (let ((entity (get-text-property (point-min) 'mime-view-entity))
4438 (setq children (mime-entity-children entity))
4439 (setq children (length children)))
4442 (format " (%d parts)" children))
4445 (defvar gnus-mime-button-map
4446 (let ((map (make-sparse-keymap)))
4447 (define-key map gnus-mouse-2 'gnus-article-push-button)
4448 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4449 (dolist (c gnus-mime-button-commands)
4450 (define-key map (cadr c) (car c)))
4454 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4456 ,@(mapcar (lambda (c)
4457 (vector (caddr c) (car c) :enable t))
4458 gnus-mime-button-commands)))
4460 (defun gnus-mime-button-menu (event prefix)
4461 "Construct a context-sensitive menu of MIME commands."
4462 (interactive "e\nP")
4463 (save-window-excursion
4464 (let ((pos (event-start event)))
4465 (select-window (posn-window pos))
4466 (goto-char (posn-point pos))
4467 (gnus-article-check-buffer)
4468 (popup-menu gnus-mime-button-menu nil prefix))))
4470 (defun gnus-mime-view-all-parts (&optional handles)
4471 "View all the MIME parts."
4473 (with-current-buffer gnus-article-buffer
4474 (let ((handles (or handles gnus-article-mime-handles))
4475 (mail-parse-charset gnus-newsgroup-charset)
4476 (mail-parse-ignored-charsets
4477 (with-current-buffer gnus-summary-buffer
4478 gnus-newsgroup-ignored-charsets)))
4480 (mm-remove-parts handles)
4481 (goto-char (point-min))
4482 (or (search-forward "\n\n") (goto-char (point-max)))
4483 (let ((inhibit-read-only t))
4484 (delete-region (point) (point-max))
4485 (mm-display-parts handles))))))
4487 (defun gnus-article-jump-to-part (n)
4488 "Jump to MIME part N."
4490 (pop-to-buffer gnus-article-buffer)
4491 ;; FIXME: why is it necessary?
4493 (let ((parts (length gnus-article-mime-handle-alist)))
4496 (read-string ;; Emacs 21 doesn't have `read-number'.
4497 (format "Jump to part (2..%s): " parts)))))
4498 (unless (and (integerp n) (<= n parts) (>= n 1))
4501 (gnus-message 7 "Invalid part `%s', using %s instead."
4504 (gnus-message 9 "Jumping to part %s." n)
4505 (cond ((>= gnus-auto-select-part 1)
4506 (while (and (<= n parts)
4507 (not (gnus-article-goto-part n)))
4509 ((< gnus-auto-select-part 0)
4510 (while (and (>= n 1)
4511 (not (gnus-article-goto-part n)))
4514 (gnus-article-goto-part n)))))
4517 (defsubst gnus-article-edit-part (handles &optional current-id)
4518 "Edit an article in order to delete a mime part.
4519 This function is exclusively used by `gnus-mime-save-part-and-strip'
4520 and `gnus-mime-delete-part', and not provided at run-time normally."
4521 (gnus-article-edit-article
4523 (buffer-disable-undo)
4525 (let ((mail-parse-charset (or gnus-article-charset
4526 ',gnus-newsgroup-charset))
4527 (mail-parse-ignored-charsets
4528 (or gnus-article-ignored-charsets
4529 ',gnus-newsgroup-ignored-charsets))
4530 (mbl mml-buffer-list))
4531 (setq mml-buffer-list nil)
4532 (insert-buffer-substring gnus-original-article-buffer)
4533 (mime-to-mml ',handles)
4534 (setq gnus-article-mime-handles nil)
4535 (let ((mbl1 mml-buffer-list))
4536 (setq mml-buffer-list mbl)
4537 (set (make-local-variable 'mml-buffer-list) mbl1))
4538 (gnus-make-local-hook 'kill-buffer-hook)
4539 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4540 `(lambda (no-highlight)
4541 (let ((mail-parse-charset (or gnus-article-charset
4542 ',gnus-newsgroup-charset))
4543 (message-options message-options)
4544 (message-options-set-recipient)
4545 (mail-parse-ignored-charsets
4546 (or gnus-article-ignored-charsets
4547 ',gnus-newsgroup-ignored-charsets)))
4549 (mml-destroy-buffers)
4550 (remove-hook 'kill-buffer-hook
4551 'mml-destroy-buffers t)
4552 (kill-local-variable 'mml-buffer-list))
4553 (gnus-summary-edit-article-done
4554 ,(or (mail-header-references gnus-current-headers) "")
4555 ,(gnus-group-read-only-p)
4556 ,gnus-summary-buffer no-highlight))
4558 (gnus-article-edit-done)
4559 (gnus-summary-expand-window)
4560 (gnus-summary-show-article)
4561 (when (and current-id (integerp gnus-auto-select-part))
4562 (gnus-article-jump-to-part
4563 (+ current-id gnus-auto-select-part)))))
4565 (defun gnus-mime-replace-part (file)
4566 "Replace MIME part under point with an external body."
4567 ;; Useful if file has already been saved to disk
4571 (read-file-name "Replace MIME part with file: "
4572 (or mm-default-directory default-directory)
4574 (gnus-mime-save-part-and-strip file))
4576 (defun gnus-mime-save-part-and-strip (&optional file)
4577 "Save the MIME part under point then replace it with an external body.
4578 If FILE is given, use it for the external part."
4580 (gnus-article-check-buffer)
4581 (when (gnus-group-read-only-p)
4582 (error "The current group does not support deleting of parts"))
4583 (when (mm-complicated-handles gnus-article-mime-handles)
4585 The current article has a complicated MIME structure, giving up..."))
4586 (let* ((data (get-text-property (point) 'gnus-data))
4587 (id (get-text-property (point) 'gnus-part))
4589 (handles gnus-article-mime-handles))
4592 (and data (mm-save-part data "Delete MIME part and save to: "))))
4594 (with-current-buffer (mm-handle-buffer data)
4596 (insert "Content-Type: " (mm-handle-media-type data))
4597 (mml-insert-parameter-string (cdr (mm-handle-type data))
4600 (insert "Content-ID: " (message-make-message-id) "\n")
4601 (insert "Content-Transfer-Encoding: binary\n")
4604 (cdr (mm-make-handle nil
4605 `("message/external-body"
4606 (access-type . "LOCAL-FILE")
4608 ;; (set-buffer gnus-summary-buffer)
4609 (gnus-article-edit-part handles id))))
4611 ;; A function like `gnus-summary-save-parts' (`X m', `<MIME> <Extract all
4612 ;; parts...>') but with stripping would be nice.
4614 (defun gnus-mime-delete-part ()
4615 "Delete the MIME part under point.
4616 Replace it with some information about the removed part."
4618 (gnus-article-check-buffer)
4619 (when (gnus-group-read-only-p)
4620 (error "The current group does not support deleting of parts"))
4621 (when (mm-complicated-handles gnus-article-mime-handles)
4623 The current article has a complicated MIME structure, giving up..."))
4624 (when (or gnus-expert-user
4625 (gnus-yes-or-no-p "\
4626 Deleting parts may malfunction or destroy the article; continue? "))
4627 (let* ((data (get-text-property (point) 'gnus-data))
4628 (id (get-text-property (point) 'gnus-part))
4629 (handles gnus-article-mime-handles)
4633 (mail-decode-encoded-word-string (or (mm-handle-description data)
4636 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4638 (type (mm-handle-media-type data)))
4640 (error "No MIME part under point"))
4641 (with-current-buffer (mm-handle-buffer data)
4642 (let ((bsize (format "%s" (buffer-size))))
4647 "| The following attachment has been deleted:\n"
4649 "| Type: " type "\n"
4650 "| Filename: " filename "\n"
4651 "| Size (encoded): " bsize " Byte\n"
4652 "| Description: " description "\n"
4655 (cdr (mm-make-handle
4656 nil `("text/plain") nil nil
4658 (format "Deleted attachment (%s bytes)" bsize))))))
4659 ;; (set-buffer gnus-summary-buffer)
4660 (gnus-article-edit-part handles id))))
4662 (defun gnus-mime-save-part ()
4663 "Save the MIME part under point."
4665 (gnus-article-check-buffer)
4666 (let ((data (get-text-property (point) 'gnus-data)))
4668 (mm-save-part data))))
4670 (defun gnus-mime-pipe-part ()
4671 "Pipe the MIME part under point to a process."
4673 (gnus-article-check-buffer)
4674 (let ((data (get-text-property (point) 'gnus-data)))
4676 (mm-pipe-part data))))
4678 (defun gnus-mime-view-part ()
4679 "Interactively choose a viewing method for the MIME part under point."
4681 (gnus-article-check-buffer)
4682 (let ((data (get-text-property (point) 'gnus-data)))
4684 (setq gnus-article-mime-handles
4686 gnus-article-mime-handles (setq data (copy-sequence data))))
4687 (mm-interactively-view-part data))))
4689 (defun gnus-mime-view-part-as-type-internal ()
4690 (gnus-article-check-buffer)
4691 (let* ((handle (get-text-property (point) 'gnus-data))
4693 ;; Content-Type: foo/bar; name=...
4694 (mail-content-type-get (mm-handle-type handle) 'name)
4695 ;; Content-Disposition: attachment; filename=...
4696 (cdr (assq 'filename (cdr (mm-handle-disposition handle))))))
4697 (def-type (and name (mm-default-file-encoding name))))
4698 (and def-type (cons def-type 0))))
4700 (defun gnus-mime-view-part-as-type (&optional mime-type)
4701 "Choose a MIME media type, and view the part as such."
4705 (let ((default (gnus-mime-view-part-as-type-internal)))
4707 (format "View as MIME type (default %s): "
4709 (mapcar #'list (mailcap-mime-types))
4712 (gnus-article-check-buffer)
4713 (let ((handle (get-text-property (point) 'gnus-data)))
4716 (mm-make-handle (mm-handle-buffer handle)
4717 (cons mime-type (cdr (mm-handle-type handle)))
4718 (mm-handle-encoding handle)
4719 (mm-handle-undisplayer handle)
4720 (mm-handle-disposition handle)
4721 (mm-handle-description handle)
4723 (mm-handle-id handle)))
4724 (setq gnus-article-mime-handles
4725 (mm-merge-handles gnus-article-mime-handles handle))
4726 (gnus-mm-display-part handle))))
4728 (defun gnus-mime-copy-part (&optional handle arg)
4729 "Put the MIME part under point into a new buffer.
4730 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4732 (interactive (list nil current-prefix-arg))
4733 (gnus-article-check-buffer)
4735 (setq handle (get-text-property (point) 'gnus-data)))
4737 (let ((filename (or (mail-content-type-get (mm-handle-disposition handle)
4739 (mail-content-type-get (mm-handle-disposition handle)
4741 contents dont-decode charset coding-system)
4742 (mm-with-unibyte-buffer
4743 (mm-insert-part handle)
4744 (setq contents (or (condition-case nil
4745 (mm-decompress-buffer filename nil 'sig)
4747 (setq dont-decode t)
4750 (setq filename (cond (filename (file-name-nondirectory filename))
4751 (dont-decode "*raw data*")
4756 (unless (setq charset (mail-content-type-get
4757 (mm-handle-type handle) 'charset))
4758 (unless (setq coding-system (mm-with-unibyte-buffer
4760 (mm-find-buffer-file-coding-system)))
4761 (setq charset gnus-newsgroup-charset))))
4763 (setq charset (or (cdr (assq arg
4764 gnus-summary-show-article-charset-alist))
4765 (mm-read-coding-system "Charset: ")))))
4766 (switch-to-buffer (generate-new-buffer filename))
4767 (if (or coding-system
4769 (setq coding-system (mm-charset-to-coding-system charset))
4770 (not (eq charset 'ascii))))
4772 (mm-enable-multibyte)
4773 (insert (mm-decode-coding-string contents coding-system))
4774 (setq buffer-file-coding-system
4775 (if (boundp 'last-coding-system-used)
4776 (symbol-value 'last-coding-system-used)
4778 (mm-disable-multibyte)
4780 (setq buffer-file-coding-system mm-binary-coding-system))
4781 ;; We do it this way to make `normal-mode' set the appropriate mode.
4784 (setq buffer-file-name (expand-file-name filename))
4786 (setq buffer-file-name nil))
4787 (goto-char (point-min)))))
4789 (defun gnus-mime-print-part (&optional handle filename)
4790 "Print the MIME part under point."
4791 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4792 (gnus-article-check-buffer)
4793 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4794 (contents (and handle (mm-get-part handle)))
4795 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4796 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4801 (mm-save-part-to-file handle file)
4802 (call-process shell-file-name nil
4803 (generate-new-buffer " *mm*")
4805 shell-command-switch
4807 printer file (mm-handle-type handle))))
4811 (gnus-print-buffer))
4812 (ps-despool filename)))))
4814 (defun gnus-mime-inline-part (&optional handle arg)
4815 "Insert the MIME part under point into the current buffer.
4816 Compressed files like .gz and .bz2 are decompressed."
4817 (interactive (list nil current-prefix-arg))
4818 (gnus-article-check-buffer)
4820 (setq handle (get-text-property (point) 'gnus-data)))
4823 (inhibit-read-only t)
4824 contents charset coding-system)
4825 (if (and (not arg) (mm-handle-undisplayer handle))
4826 (mm-remove-part handle)
4827 (mm-with-unibyte-buffer
4828 (mm-insert-part handle)
4830 (or (mm-decompress-buffer
4831 (or (mail-content-type-get (mm-handle-disposition handle)
4833 (mail-content-type-get (mm-handle-disposition handle)
4839 (unless (setq charset (mail-content-type-get
4840 (mm-handle-type handle) 'charset))
4841 (unless (setq coding-system
4842 (mm-with-unibyte-buffer
4844 (mm-find-buffer-file-coding-system)))
4845 (setq charset gnus-newsgroup-charset))))
4847 (if (mm-handle-undisplayer handle)
4848 (mm-remove-part handle))
4851 gnus-summary-show-article-charset-alist))
4852 (mm-read-coding-system "Charset: "))))
4854 (if (mm-handle-undisplayer handle)
4855 (mm-remove-part handle))))
4859 (if (or coding-system
4862 (mm-charset-to-coding-system charset))
4863 (not (eq coding-system 'ascii))))
4864 (mm-decode-coding-string contents coding-system)
4865 (mm-string-to-multibyte contents)))
4868 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4869 "Insert the MIME part under point into the current buffer using the
4871 (interactive (list nil current-prefix-arg))
4872 (gnus-article-check-buffer)
4873 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4876 (inhibit-read-only t))
4878 (if (mm-handle-undisplayer handle)
4879 (mm-remove-part handle))
4880 (let ((gnus-newsgroup-charset
4882 gnus-summary-show-article-charset-alist))
4883 (mm-read-coding-system "Charset: ")))
4884 (gnus-newsgroup-ignored-charsets 'gnus-all))
4885 (gnus-article-press-button)))))
4887 (defun gnus-mime-view-part-externally (&optional handle)
4888 "View the MIME part under point with an external viewer."
4890 (gnus-article-check-buffer)
4891 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4892 (mm-user-display-methods nil)
4893 (mm-inlined-types nil)
4894 (mail-parse-charset gnus-newsgroup-charset)
4895 (mail-parse-ignored-charsets
4896 (with-current-buffer gnus-summary-buffer
4897 gnus-newsgroup-ignored-charsets)))
4899 (if (mm-handle-undisplayer handle)
4900 (mm-remove-part handle)
4901 (mm-display-part handle)))))
4903 (defun gnus-mime-view-part-internally (&optional handle)
4904 "View the MIME part under point with an internal viewer.
4905 If no internal viewer is available, use an external viewer."
4907 (gnus-article-check-buffer)
4908 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4909 (mm-inlined-types '(".*"))
4910 (mm-inline-large-images t)
4911 (mail-parse-charset gnus-newsgroup-charset)
4912 (mail-parse-ignored-charsets
4913 (with-current-buffer gnus-summary-buffer
4914 gnus-newsgroup-ignored-charsets))
4915 (inhibit-read-only t))
4917 (if (mm-handle-undisplayer handle)
4918 (mm-remove-part handle)
4919 (mm-display-part handle)))))
4921 (defun gnus-mime-action-on-part (&optional action)
4922 "Do something with the MIME attachment at \(point\)."
4924 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4925 (gnus-article-check-buffer)
4926 (let ((action-pair (assoc action gnus-mime-action-alist)))
4928 (funcall (cdr action-pair)))))
4930 (defun gnus-article-part-wrapper (n function &optional no-handle interactive)
4931 "Call FUNCTION on MIME part N.
4932 Unless NO-HANDLE, call FUNCTION with N-th MIME handle as it's only argument.
4933 If INTERACTIVE, call FUNCTION interactivly."
4935 ;; Check whether the article is displayed.
4936 (unless (and (gnus-buffer-live-p gnus-article-buffer)
4937 (setq window (get-buffer-window gnus-article-buffer t))
4938 (frame-visible-p (setq frame (window-frame window))))
4939 (error "No article is displayed"))
4940 (with-current-buffer gnus-article-buffer
4941 ;; Check whether the article displays the right contents.
4942 (unless (with-current-buffer gnus-summary-buffer
4943 (eq gnus-current-article (gnus-summary-article-number)))
4944 (error "You should select the right article first"))
4945 ;; Check whether the specified part exists.
4946 (when (> n (length gnus-article-mime-handle-alist))
4947 (error "No such part")))
4950 ;; To select the window is needed so that the cursor
4951 ;; might be visible on the MIME button.
4952 (select-window (prog1
4954 (setq window (selected-window))
4955 ;; Article may be displayed in the other frame.
4956 (gnus-select-frame-set-input-focus
4959 (setq frame (selected-frame))))))
4960 (when (gnus-article-goto-part n)
4961 ;; We point the cursor and the arrow at the MIME button
4962 ;; when the `function' prompt the user for something.
4963 (let ((cursor-in-non-selected-windows t)
4964 (overlay-arrow-string "=>")
4965 (overlay-arrow-position (point-marker)))
4968 ((and no-handle interactive)
4969 (call-interactively function))
4975 (cdr (assq n gnus-article-mime-handle-alist))))
4978 (cdr (assq n gnus-article-mime-handle-alist)))))
4979 (set-marker overlay-arrow-position nil)
4980 (unless gnus-auto-select-part
4981 (gnus-select-frame-set-input-focus frame)
4982 (select-window window))))
4984 (if gnus-inhibit-mime-unbuttonizing
4985 ;; This is the default though the program shouldn't reach here.
4986 (error "No such part")
4987 ;; The part which doesn't have the MIME button is selected.
4988 ;; So, we display all the buttons and redo it.
4989 (let ((gnus-inhibit-mime-unbuttonizing t))
4990 (gnus-summary-show-article)
4991 (gnus-article-part-wrapper n function no-handle))))))
4993 (defun gnus-article-pipe-part (n)
4994 "Pipe MIME part N, which is the numerical prefix."
4996 (gnus-article-part-wrapper n 'mm-pipe-part))
4998 (defun gnus-article-save-part (n)
4999 "Save MIME part N, which is the numerical prefix."
5001 (gnus-article-part-wrapper n 'mm-save-part))
5003 (defun gnus-article-interactively-view-part (n)
5004 "View MIME part N interactively, which is the numerical prefix."
5006 (gnus-article-part-wrapper n 'mm-interactively-view-part))
5008 (defun gnus-article-copy-part (n)
5009 "Copy MIME part N, which is the numerical prefix."
5011 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
5013 (defun gnus-article-view-part-as-charset (n)
5014 "View MIME part N using a specified charset.
5015 N is the numerical prefix."
5017 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
5019 (defun gnus-article-view-part-externally (n)
5020 "View MIME part N externally, which is the numerical prefix."
5022 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
5024 (defun gnus-article-inline-part (n)
5025 "Inline MIME part N, which is the numerical prefix."
5027 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
5029 (defun gnus-article-save-part-and-strip (n)
5030 "Save MIME part N and replace it with an external body.
5031 N is the numerical prefix."
5033 (gnus-article-part-wrapper n 'gnus-mime-save-part-and-strip t))
5035 (defun gnus-article-replace-part (n)
5036 "Replace MIME part N with an external body.
5037 N is the numerical prefix."
5039 (gnus-article-part-wrapper n 'gnus-mime-replace-part t t))
5041 (defun gnus-article-delete-part (n)
5042 "Delete MIME part N and add some information about the removed part.
5043 N is the numerical prefix."
5045 (gnus-article-part-wrapper n 'gnus-mime-delete-part t))
5047 (defun gnus-article-mime-match-handle-first (condition)
5050 (dolist (ihandle gnus-article-mime-handle-alist)
5052 ((functionp condition)
5053 (funcall condition (cdr ihandle)))
5054 ((eq condition 'undisplayed)
5055 (not (or (mm-handle-undisplayer (cdr ihandle))
5056 (equal (mm-handle-media-type (cdr ihandle))
5057 "multipart/alternative"))))
5058 ((eq condition 'undisplayed-alternative)
5059 (not (mm-handle-undisplayer (cdr ihandle))))
5061 (gnus-article-goto-part (car ihandle))
5062 (or (not n) (< (car ihandle) n)))
5063 (setq n (car ihandle))))
5067 (defun gnus-article-view-part (&optional n)
5068 "View MIME part N, which is the numerical prefix."
5070 (with-current-buffer gnus-article-buffer
5071 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
5072 gnus-article-mime-match-handle-function)))
5073 (when (> n (length gnus-article-mime-handle-alist))
5074 (error "No such part"))
5075 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
5076 (when (gnus-article-goto-part n)
5077 (if (equal (car handle) "multipart/alternative")
5078 (gnus-article-press-button)
5079 (when (eq (gnus-mm-display-part handle) 'internal)
5080 (gnus-set-window-start)))))))
5082 (defsubst gnus-article-mime-total-parts ()
5083 (if (bufferp (car gnus-article-mime-handles))
5085 (1- (length gnus-article-mime-handles))))
5087 (defun gnus-mm-display-part (handle)
5088 "Display HANDLE and fix MIME button."
5089 (let ((id (get-text-property (point) 'gnus-part))
5091 (inhibit-read-only t))
5094 (let ((window (selected-window))
5095 (mail-parse-charset gnus-newsgroup-charset)
5096 (mail-parse-ignored-charsets
5097 (if (gnus-buffer-live-p gnus-summary-buffer)
5098 (with-current-buffer gnus-summary-buffer
5099 gnus-newsgroup-ignored-charsets)
5103 (let ((win (gnus-get-buffer-window (current-buffer) t))
5106 (select-window win))
5109 (if (mm-handle-displayed-p handle)
5110 ;; This will remove the part.
5111 (mm-display-part handle)
5113 (narrow-to-region (point)
5114 (if (eobp) (point) (1+ (point))))
5115 (mm-display-part handle)
5116 ;; We narrow to the part itself and
5117 ;; then call the treatment functions.
5118 (goto-char (point-min))
5120 (narrow-to-region (point) (point-max))
5123 (gnus-article-mime-total-parts)
5124 (mm-handle-media-type handle)))))
5125 (if (window-live-p window)
5126 (select-window window)))))
5129 (gnus-insert-mime-button
5130 handle id (list (mm-handle-displayed-p handle)))
5131 (goto-char point))))
5133 (defun gnus-article-goto-part (n)
5134 "Go to MIME part N."
5135 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
5137 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
5138 (let ((gnus-tmp-name
5139 (or (mail-content-type-get (mm-handle-type handle) 'name)
5140 (mail-content-type-get (mm-handle-disposition handle) 'filename)
5141 (mail-content-type-get (mm-handle-type handle) 'url)
5143 (gnus-tmp-type (mm-handle-media-type handle))
5144 (gnus-tmp-description
5145 (mail-decode-encoded-word-string (or (mm-handle-description handle)
5148 (if (if displayed (car displayed)
5149 (mm-handle-displayed-p handle))
5151 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
5153 gnus-tmp-type-long b e)
5154 (when (string-match ".*/" gnus-tmp-name)
5155 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
5156 (setq gnus-tmp-type-long (concat gnus-tmp-type
5157 (and (not (equal gnus-tmp-name ""))
5158 (concat "; " gnus-tmp-name))))
5159 (unless (equal gnus-tmp-description "")
5160 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
5165 gnus-mime-button-line-format gnus-mime-button-line-format-alist
5166 `(keymap ,gnus-mime-button-map
5167 gnus-callback gnus-mm-display-part
5168 gnus-part ,gnus-tmp-id
5169 article-type annotation
5172 ;; Exclude a newline.
5175 (widget-convert-button
5178 :action 'gnus-widget-press-button
5179 :button-keymap gnus-mime-button-map
5181 (lambda (widget/window &optional overlay pos)
5182 ;; Needed to properly clear the message due to a bug in
5183 ;; wid-edit (XEmacs only).
5184 (if (boundp 'help-echo-owns-message)
5185 (setq help-echo-owns-message t))
5187 "%S: %s the MIME part; %S: more options"
5188 (aref gnus-mouse-2 0)
5189 ;; XEmacs will get a single widget arg; Emacs 21 will get
5190 ;; window, overlay, position.
5191 (if (mm-handle-displayed-p
5193 (with-current-buffer (gnus-overlay-buffer overlay)
5194 (widget-get (widget-at (gnus-overlay-start overlay))
5196 (widget-get widget/window :mime-handle)))
5198 (aref gnus-down-mouse-3 0))))))
5200 (defun gnus-widget-press-button (elems el)
5201 (goto-char (widget-get elems :from))
5202 (gnus-article-press-button))
5204 (defvar gnus-displaying-mime nil)
5206 (defun gnus-display-mime (&optional ihandles)
5207 "Display the MIME parts."
5209 (save-selected-window
5210 (let ((window (get-buffer-window gnus-article-buffer))
5213 (select-window window)
5214 ;; We have to do this since selecting the window
5215 ;; may change the point. So we set the window point.
5216 (set-window-point window point)))
5217 (let ((handles ihandles)
5218 (inhibit-read-only t)
5221 ((setq handles (mm-dissect-buffer nil gnus-article-loose-mime))
5222 (when gnus-article-emulate-mime
5223 (mm-uu-dissect-text-parts handles)))
5224 (gnus-article-emulate-mime
5225 (setq handles (mm-uu-dissect))))
5226 (when (and (not ihandles)
5227 (not gnus-displaying-mime))
5228 ;; Top-level call; we clean up.
5229 (when gnus-article-mime-handles
5230 (mm-destroy-parts gnus-article-mime-handles)
5231 (setq gnus-article-mime-handle-alist nil));; A trick.
5232 (setq gnus-article-mime-handles handles)
5233 ;; We allow users to glean info from the handles.
5234 (when gnus-article-mime-part-function
5235 (gnus-mime-part-function handles)))
5237 (or (not (stringp (car handles)))
5240 (when (and (not ihandles)
5241 (not gnus-displaying-mime))
5242 ;; Clean up for mime parts.
5244 (delete-region (point) (point-max)))
5245 (let ((gnus-displaying-mime t))
5246 (gnus-mime-display-part handles)))
5249 (narrow-to-region (point) (point-max))
5250 (gnus-treat-article nil 1 1)
5253 ;; Highlight the headers.
5257 (narrow-to-region (point-min) (point))
5258 (gnus-article-save-original-date
5259 (gnus-treat-article 'head)))))))))
5261 (defcustom gnus-mime-display-multipart-as-mixed nil
5262 "Display \"multipart\" parts as \"multipart/mixed\".
5264 If t, it overrides nil values of
5265 `gnus-mime-display-multipart-alternative-as-mixed' and
5266 `gnus-mime-display-multipart-related-as-mixed'."
5267 :group 'gnus-article-mime
5270 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
5271 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
5273 :group 'gnus-article-mime
5276 (defcustom gnus-mime-display-multipart-related-as-mixed nil
5277 "Display \"multipart/related\" parts as \"multipart/mixed\".
5279 If displaying \"text/html\" is discouraged \(see
5280 `mm-discouraged-alternatives'\) images or other material inside a
5281 \"multipart/related\" part might be overlooked when this variable is nil."
5283 :group 'gnus-article-mime
5286 (defun gnus-mime-display-part (handle)
5288 ;; Maybe a broken MIME message.
5291 ((not (stringp (car handle)))
5292 (gnus-mime-display-single handle))
5293 ;; User-defined multipart
5294 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
5295 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
5297 ;; multipart/alternative
5298 ((and (equal (car handle) "multipart/alternative")
5299 (not (or gnus-mime-display-multipart-as-mixed
5300 gnus-mime-display-multipart-alternative-as-mixed)))
5301 (let ((id (1+ (length gnus-article-mime-handle-alist))))
5302 (push (cons id handle) gnus-article-mime-handle-alist)
5303 (gnus-mime-display-alternative (cdr handle) nil nil id)))
5304 ;; multipart/related
5305 ((and (equal (car handle) "multipart/related")
5306 (not (or gnus-mime-display-multipart-as-mixed
5307 gnus-mime-display-multipart-related-as-mixed)))
5308 ;;;!!!We should find the start part, but we just default
5309 ;;;!!!to the first part.
5310 ;;(gnus-mime-display-part (cadr handle))
5311 ;;;!!! Most multipart/related is an HTML message plus images.
5312 ;;;!!! Unfortunately we are unable to let W3 display those
5313 ;;;!!! included images, so we just display it as a mixed multipart.
5314 ;;(gnus-mime-display-mixed (cdr handle))
5315 ;;;!!! No, w3 can display everything just fine.
5316 (gnus-mime-display-part (cadr handle)))
5317 ((equal (car handle) "multipart/signed")
5318 (gnus-add-wash-type 'signed)
5319 (gnus-mime-display-security handle))
5320 ((equal (car handle) "multipart/encrypted")
5321 (gnus-add-wash-type 'encrypted)
5322 (gnus-mime-display-security handle))
5323 ;; Other multiparts are handled like multipart/mixed.
5325 (gnus-mime-display-mixed (cdr handle)))))
5327 (defun gnus-mime-part-function (handles)
5328 (if (stringp (car handles))
5329 (mapcar 'gnus-mime-part-function (cdr handles))
5330 (funcall gnus-article-mime-part-function handles)))
5332 (defun gnus-mime-display-mixed (handles)
5333 (mapcar 'gnus-mime-display-part handles))
5335 (defun gnus-mime-display-single (handle)
5336 (let ((type (mm-handle-media-type handle))
5337 (ignored gnus-ignored-mime-types)
5344 (when (string-match (pop ignored) type)
5345 (throw 'ignored nil)))
5346 (if (and (setq not-attachment
5347 (and (not (mm-inline-override-p handle))
5348 (or (not (mm-handle-disposition handle))
5349 (equal (car (mm-handle-disposition handle))
5351 (mm-attachment-override-p handle))))
5352 (mm-automatic-display-p handle)
5354 (mm-inlinable-p handle)
5355 (mm-inlined-p handle))
5356 (mm-automatic-external-display-p type)))
5358 (when (equal (mm-handle-media-supertype handle) "text")
5360 (let ((id (1+ (length gnus-article-mime-handle-alist)))
5362 (push (cons id handle) gnus-article-mime-handle-alist)
5363 (when (or (not display)
5364 (not (gnus-unbuttonized-mime-type-p type)))
5365 (gnus-insert-mime-button
5366 handle id (list (or display (and not-attachment text))))
5367 (gnus-article-insert-newline)
5368 ;; Remember modify the number of forward lines.
5376 (let ((mail-parse-charset gnus-newsgroup-charset)
5377 (mail-parse-ignored-charsets
5378 (save-excursion (condition-case ()
5379 (set-buffer gnus-summary-buffer)
5381 gnus-newsgroup-ignored-charsets)))
5382 (mm-display-part handle t))
5383 (goto-char (point-max)))
5384 ((and text not-attachment)
5388 (gnus-article-insert-newline)
5391 (let ((charset (mail-content-type-get (mm-handle-type handle)
5393 (cond ((not charset)
5394 (mm-string-as-multibyte (mm-get-part handle)))
5395 ((eq charset 'gnus-decoded)
5396 (with-current-buffer (mm-handle-buffer handle)
5399 (mm-decode-string (mm-get-part handle) charset)))))
5400 (goto-char (point-max))))
5404 (narrow-to-region beg (point))
5407 (gnus-article-mime-total-parts)
5408 (mm-handle-media-type handle)))))))))
5410 (defun gnus-unbuttonized-mime-type-p (type)
5411 "Say whether TYPE is to be unbuttonized."
5412 (unless gnus-inhibit-mime-unbuttonizing
5414 (let ((types gnus-unbuttonized-mime-types))
5416 (when (string-match (pop types) type)
5417 (throw 'found t)))))
5419 (let ((types gnus-buttonized-mime-types))
5421 (when (string-match (pop types) type)
5422 (throw 'found t)))))))))
5424 (defun gnus-article-insert-newline ()
5425 "Insert a newline, but mark it as undeletable."
5426 (gnus-put-text-property
5427 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
5429 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
5430 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
5433 handle (inhibit-read-only t) from props begend not-pref)
5434 (save-window-excursion
5437 (narrow-to-region (car ibegend)
5440 (goto-char (car ibegend))
5443 (delete-region (point-min) (point-max))
5444 (mm-remove-parts handles))
5445 (setq begend (list (point-marker)))
5447 (unless (setq not-pref (cadr (member preferred ihandles)))
5448 (setq not-pref (car ihandles)))
5451 (not (gnus-unbuttonized-mime-type-p
5452 "multipart/alternative")))
5453 (gnus-add-text-properties
5456 (insert (format "%d. " id))
5460 (unless ,(not ibegend)
5461 (setq gnus-article-mime-handle-alist
5462 ',gnus-article-mime-handle-alist))
5463 (gnus-mime-display-alternative
5464 ',ihandles ',not-pref ',begend ,id))
5465 keymap ,gnus-mime-button-map
5466 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5467 face ,gnus-article-button-face
5469 article-type multipart))
5470 (widget-convert-button 'link from (point)
5471 :action 'gnus-widget-press-button
5472 :button-keymap gnus-widget-button-keymap)
5474 (while (setq handle (pop handles))
5475 (gnus-add-text-properties
5478 (insert (format "(%c) %-18s"
5479 (if (equal handle preferred) ?* ? )
5480 (mm-handle-media-type handle)))
5484 (unless ,(not ibegend)
5485 (setq gnus-article-mime-handle-alist
5486 ',gnus-article-mime-handle-alist))
5487 (gnus-mime-display-alternative
5488 ',ihandles ',handle ',begend ,id))
5489 keymap ,gnus-mime-button-map
5490 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5491 face ,gnus-article-button-face
5494 (widget-convert-button 'link from (point)
5495 :action 'gnus-widget-press-button
5496 :button-keymap gnus-widget-button-keymap)
5500 (if (stringp (car preferred))
5501 (gnus-display-mime preferred)
5502 (let ((mail-parse-charset gnus-newsgroup-charset)
5503 (mail-parse-ignored-charsets
5504 (with-current-buffer gnus-summary-buffer
5505 gnus-newsgroup-ignored-charsets)))
5506 (mm-display-part preferred)
5510 (narrow-to-region (car begend) (point-max))
5512 nil (length gnus-article-mime-handle-alist)
5513 (gnus-article-mime-total-parts)
5514 (mm-handle-media-type handle))))))
5515 (goto-char (point-max))
5516 (setcdr begend (point-marker)))))
5518 (goto-char point))))
5520 (defconst gnus-article-wash-status-strings
5521 (let ((alist '((cite "c" "Possible hidden citation text"
5522 " " "All citation text visible")
5523 (headers "h" "Hidden headers"
5524 " " "All headers visible.")
5525 (pgp "p" "Encrypted or signed message status hidden"
5526 " " "No hidden encryption nor digital signature status")
5527 (signature "s" "Signature has been hidden"
5528 " " "Signature is visible")
5529 (overstrike "o" "Overstrike (^H) characters applied"
5530 " " "No overstrike characters applied")
5531 (gnus-show-mime "m" "Mime processing is activated"
5532 " " "Mime processing is not activated")
5533 (emphasis "e" "/*_Emphasis_*/ characters applied"
5534 " " "No /*_emphasis_*/ characters applied")))
5536 (dolist (entry alist result)
5537 (let ((key (nth 0 entry))
5538 (on (copy-sequence (nth 1 entry)))
5539 (on-help (nth 2 entry))
5540 (off (copy-sequence (nth 3 entry)))
5541 (off-help (nth 4 entry)))
5542 (put-text-property 0 1 'help-echo on-help on)
5543 (put-text-property 0 1 'help-echo off-help off)
5544 (push (list key on off) result))))
5545 "Alist of strings describing wash status in the mode line.
5546 Each entry has the form (KEY ON OF), where the KEY is a symbol
5547 representing the particular washing function, ON is the string to use
5548 in the article mode line when the washing function is active, and OFF
5549 is the string to use when it is inactive.")
5551 (defun gnus-article-wash-status-entry (key value)
5552 (let ((entry (assoc key gnus-article-wash-status-strings)))
5553 (if value (nth 1 entry) (nth 2 entry))))
5555 (defun gnus-article-wash-status ()
5556 "Return a string which display status of article washing."
5557 (with-current-buffer gnus-article-buffer
5558 (let ((cite (memq 'cite gnus-article-wash-types))
5559 (headers (memq 'headers gnus-article-wash-types))
5560 (boring (memq 'boring-headers gnus-article-wash-types))
5561 (pgp (memq 'pgp gnus-article-wash-types))
5562 (pem (memq 'pem gnus-article-wash-types))
5563 (signed (memq 'signed gnus-article-wash-types))
5564 (encrypted (memq 'encrypted gnus-article-wash-types))
5565 (signature (memq 'signature gnus-article-wash-types))
5566 (overstrike (memq 'overstrike gnus-article-wash-types))
5567 (emphasis (memq 'emphasis gnus-article-wash-types)))
5569 (gnus-article-wash-status-entry 'cite cite)
5570 (gnus-article-wash-status-entry 'headers (or headers boring))
5571 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5572 (gnus-article-wash-status-entry 'signature signature)
5573 (gnus-article-wash-status-entry 'overstrike overstrike)
5574 (gnus-article-wash-status-entry 'gnus-show-mime gnus-show-mime)
5575 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5577 (defun gnus-add-wash-type (type)
5578 "Add a washing of TYPE to the current status."
5579 (add-to-list 'gnus-article-wash-types type))
5581 (defun gnus-delete-wash-type (type)
5582 "Add a washing of TYPE to the current status."
5583 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5585 (defun gnus-add-image (category image)
5586 "Add IMAGE of CATEGORY to the list of displayed images."
5587 (let ((entry (assq category gnus-article-image-alist)))
5589 (setq entry (list category))
5590 (push entry gnus-article-image-alist))
5591 (nconc entry (list image))))
5593 (defun gnus-delete-images (category)
5594 "Delete all images in CATEGORY."
5595 (let ((entry (assq category gnus-article-image-alist)))
5596 (dolist (image (cdr entry))
5597 (gnus-remove-image image category))
5598 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5599 (gnus-delete-wash-type category)))
5601 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5603 (defun gnus-article-maybe-hide-headers ()
5604 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5605 Provided for backwards compatibility."
5606 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5607 (not (with-current-buffer gnus-summary-buffer
5608 gnus-have-all-headers)))
5609 (not gnus-inhibit-hiding))
5610 (gnus-article-hide-headers)))
5614 (defun gnus-output-to-file (file-name)
5615 "Append the current article to a file named FILE-NAME."
5616 (let ((artbuf (current-buffer)))
5618 (insert-buffer-substring artbuf)
5619 ;; Append newline at end of the buffer as separator, and then
5621 (goto-char (point-max))
5623 (let ((file-name-coding-system nnmail-pathname-coding-system))
5624 (write-region-as-binary (point-min) (point-max) file-name 'append))
5627 (defun gnus-narrow-to-page (&optional arg)
5628 "Narrow the article buffer to a page.
5629 If given a numerical ARG, move forward ARG pages."
5631 (setq arg (if arg (prefix-numeric-value arg) 0))
5633 (set-buffer gnus-article-buffer)
5634 (goto-char (point-min))
5636 ;; Remove any old next/prev buttons.
5637 (when (gnus-visual-p 'page-marker)
5638 (let ((inhibit-read-only t))
5639 (gnus-remove-text-with-property 'gnus-prev)
5640 (gnus-remove-text-with-property 'gnus-next)))
5643 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5645 (re-search-forward page-delimiter nil 'move arg)))
5646 (goto-char (match-end 0))
5648 (goto-char (point-min))
5649 (setq gnus-page-broken
5650 (and (re-search-forward page-delimiter nil t) t))))
5651 (when gnus-page-broken
5654 (if (re-search-forward page-delimiter nil 'move)
5657 (when (and (gnus-visual-p 'page-marker)
5658 (> (point-min) (save-restriction (widen) (point-min))))
5660 (goto-char (point-min))
5661 (gnus-insert-prev-page-button)))
5662 (when (and (gnus-visual-p 'page-marker)
5663 (< (point-max) (save-restriction (widen) (point-max))))
5665 (goto-char (point-max))
5666 (gnus-insert-next-page-button))))))
5668 ;; Article mode commands
5670 (defun gnus-article-goto-next-page ()
5671 "Show the next page of the article."
5673 (when (gnus-article-next-page)
5674 (goto-char (point-min))
5675 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5678 (defun gnus-article-goto-prev-page ()
5679 "Show the previous page of the article."
5682 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5683 (gnus-article-prev-page nil)))
5685 ;; This is cleaner but currently breaks `gnus-pick-mode':
5687 ;; (defun gnus-article-goto-next-page ()
5688 ;; "Show the next page of the article."
5690 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5691 ;; (gnus-summary-next-page)))
5693 ;; (defun gnus-article-goto-prev-page ()
5694 ;; "Show the next page of the article."
5696 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5697 ;; (gnus-summary-prev-page)))
5699 (defun gnus-article-next-page (&optional lines)
5700 "Show the next page of the current article.
5701 If end of article, return non-nil. Otherwise return nil.
5702 Argument LINES specifies lines to be scrolled up."
5704 (move-to-window-line -1)
5707 (and (pos-visible-in-window-p) ;Not continuation line.
5708 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5709 ;; Nothing in this page.
5710 (if (or (not gnus-page-broken)
5715 (eobp)))) ;Real end-of-buffer?
5717 (when gnus-article-over-scroll
5718 (gnus-article-next-page-1 lines))
5720 (gnus-narrow-to-page 1) ;Go to next page.
5722 ;; More in this page.
5723 (gnus-article-next-page-1 lines)
5726 (defmacro gnus-article-beginning-of-window ()
5727 "Move point to the beginning of the window.
5728 In Emacs, the point is placed at the line number which `scroll-margin'
5730 (if (featurep 'xemacs)
5731 '(move-to-window-line 0)
5732 '(move-to-window-line
5733 (min (max 0 scroll-margin)
5734 (max 1 (- (window-height)
5735 (if mode-line-format 1 0)
5736 (if header-line-format 1 0)))))))
5738 (defun gnus-article-next-page-1 (lines)
5739 (when (and (not (featurep 'xemacs))
5742 (numberp (symbol-value 'scroll-margin))
5743 (> (symbol-value 'scroll-margin) 0))
5744 ;; Protect against the bug that Emacs 21.x hangs up when scrolling up for
5745 ;; too many number of lines if `scroll-margin' is set as two or greater.
5746 (setq lines (min lines
5747 (max 0 (- (count-lines (window-start) (point-max))
5748 (symbol-value 'scroll-margin))))))
5750 (let ((scroll-in-place nil))
5753 ;; Long lines may cause an end-of-buffer error.
5754 (goto-char (point-max))))
5755 (gnus-article-beginning-of-window))
5757 (defun gnus-article-prev-page (&optional lines)
5758 "Show previous page of current article.
5759 Argument LINES specifies lines to be scrolled down."
5761 (move-to-window-line 0)
5762 (if (and gnus-page-broken
5764 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5766 (gnus-narrow-to-page -1) ;Go to previous page.
5767 (goto-char (point-max))
5771 (let ((scroll-in-place nil))
5772 (scroll-down lines))
5773 (beginning-of-buffer
5774 (goto-char (point-min))))
5775 (gnus-article-beginning-of-window))))
5777 (defun gnus-article-only-boring-p ()
5778 "Decide whether there is only boring text remaining in the article.
5779 Something \"interesting\" is a word of at least two letters that does
5780 not have a face in `gnus-article-boring-faces'."
5781 (when (and gnus-article-skip-boring
5782 (boundp 'gnus-article-boring-faces)
5783 (symbol-value 'gnus-article-boring-faces))
5786 (while (re-search-forward "\\b\\w\\w" nil t)
5788 (when (not (gnus-intersection
5789 (gnus-faces-at (point))
5790 (symbol-value 'gnus-article-boring-faces)))
5791 (throw 'only-boring nil)))
5792 (throw 'only-boring t)))))
5794 (defun gnus-article-refer-article ()
5795 "Read article specified by message-id around point."
5798 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
5799 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
5800 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
5801 (let ((msg-id (concat "<" (match-string 0) ">")))
5802 (set-buffer gnus-summary-buffer)
5803 (gnus-summary-refer-article msg-id))
5804 (error "No references around point"))))
5806 (defun gnus-article-show-summary ()
5807 "Reconfigure windows to show summary buffer."
5809 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5810 (error "There is no summary buffer for this article buffer")
5811 (gnus-article-set-globals)
5812 (gnus-configure-windows 'article)
5813 (gnus-summary-goto-subject gnus-current-article)
5814 (gnus-summary-position-point)))
5816 (defun gnus-article-describe-briefly ()
5817 "Describe article mode commands briefly."
5819 (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")))
5821 (defun gnus-article-summary-command ()
5822 "Execute the last keystroke in the summary buffer."
5824 (let ((obuf (current-buffer))
5825 (owin (current-window-configuration))
5827 (switch-to-buffer gnus-article-current-summary 'norecord)
5828 (setq func (lookup-key (current-local-map) (this-command-keys)))
5829 (call-interactively func)
5831 (set-window-configuration owin)
5832 (set-window-point (get-buffer-window (current-buffer)) (point))))
5834 (defun gnus-article-summary-command-nosave ()
5835 "Execute the last keystroke in the summary buffer."
5838 (pop-to-buffer gnus-article-current-summary 'norecord)
5839 (setq func (lookup-key (current-local-map) (this-command-keys)))
5840 (call-interactively func)))
5842 (defun gnus-article-check-buffer ()
5843 "Beep if not in an article buffer."
5844 (unless (eq (get-buffer gnus-article-buffer) (current-buffer))
5845 (error "Command invoked outside of a Gnus article buffer")))
5847 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5848 "Read a summary buffer key sequence and execute it from the article buffer."
5850 (gnus-article-check-buffer)
5852 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5853 "Zc" "ZC" "ZE" "ZJ" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5854 "=" "^" "\M-^" "|"))
5860 '("n" "Gn" "p" "Gp"))
5863 (set-buffer gnus-article-current-summary)
5864 (let (gnus-pick-mode)
5865 (push (or key last-command-event) unread-command-events)
5866 (setq keys (static-if (featurep 'xemacs)
5867 (events-to-keys (read-key-sequence nil))
5868 (read-key-sequence nil)))))
5871 (if (or (member keys nosaves)
5872 (member keys nosave-but-article)
5873 (member keys nosave-in-article))
5875 (save-window-excursion
5876 (pop-to-buffer gnus-article-current-summary 'norecord)
5877 ;; We disable the pick minor mode commands.
5878 (let (gnus-pick-mode)
5879 (setq func (lookup-key (current-local-map) keys))))
5883 (unless (member keys nosave-in-article)
5884 (set-buffer gnus-article-current-summary))
5885 (call-interactively func)
5886 (setq new-sum-point (point)))
5887 (when (member keys nosave-but-article)
5888 (pop-to-buffer gnus-article-buffer 'norecord)))
5889 ;; These commands should restore window configuration.
5890 (let ((obuf (current-buffer))
5891 (owin (current-window-configuration))
5893 win func in-buffer selected new-sum-start new-sum-hscroll)
5894 (cond (not-restore-window
5895 (pop-to-buffer gnus-article-current-summary 'norecord))
5896 ((setq win (get-buffer-window gnus-article-current-summary))
5897 (select-window win))
5899 (switch-to-buffer gnus-article-current-summary 'norecord)))
5900 (setq in-buffer (current-buffer))
5901 ;; We disable the pick minor mode commands.
5902 (if (and (setq func (let (gnus-pick-mode)
5903 (lookup-key (current-local-map) keys)))
5906 (call-interactively func)
5907 (when (eq win (selected-window))
5908 (setq new-sum-point (point)
5909 new-sum-start (window-start win)
5910 new-sum-hscroll (window-hscroll win)))
5911 (when (eq in-buffer (current-buffer))
5912 (setq selected (gnus-summary-select-article))
5914 (unless not-restore-window
5915 (set-window-configuration owin))
5916 (when (eq selected 'old)
5918 (set-window-start (get-buffer-window (current-buffer))
5920 (set-window-point (get-buffer-window (current-buffer))
5922 (when (and (not not-restore-window)
5924 (set-window-point win new-sum-point)
5925 (set-window-start win new-sum-start)
5926 (set-window-hscroll win new-sum-hscroll))))
5927 (set-window-configuration owin)
5930 (defun gnus-article-describe-key (key)
5931 "Display documentation of the function invoked by KEY. KEY is a string."
5932 (interactive "kDescribe key: ")
5933 (gnus-article-check-buffer)
5934 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5936 (set-buffer gnus-article-current-summary)
5937 (let (gnus-pick-mode)
5938 (if (featurep 'xemacs)
5940 (push (elt key 0) unread-command-events)
5941 (setq key (events-to-keys
5942 (read-key-sequence "Describe key: "))))
5943 (setq unread-command-events
5945 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5947 (setq key (read-key-sequence "Describe key: "))))
5949 (describe-key key)))
5951 (defun gnus-article-describe-key-briefly (key &optional insert)
5952 "Display documentation of the function invoked by KEY. KEY is a string."
5953 (interactive "kDescribe key: \nP")
5954 (gnus-article-check-buffer)
5955 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5957 (set-buffer gnus-article-current-summary)
5958 (let (gnus-pick-mode)
5959 (if (featurep 'xemacs)
5961 (push (elt key 0) unread-command-events)
5962 (setq key (events-to-keys
5963 (read-key-sequence "Describe key: "))))
5964 (setq unread-command-events
5966 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5968 (setq key (read-key-sequence "Describe key: "))))
5969 (describe-key-briefly key insert))
5970 (describe-key-briefly key insert)))
5972 (defun gnus-article-reply-with-original (&optional wide)
5973 "Start composing a reply mail to the current message.
5974 The text in the region will be yanked. If the region isn't active,
5975 the entire article will be yanked."
5977 (let ((article (cdr gnus-article-current))
5979 (if (not (gnus-region-active-p))
5980 (with-current-buffer gnus-summary-buffer
5981 (gnus-summary-reply (list (list article)) wide))
5982 (setq contents (buffer-substring (point) (mark t)))
5983 ;; Deactivate active regions.
5984 (when (and (boundp 'transient-mark-mode)
5985 transient-mark-mode)
5986 (setq mark-active nil))
5987 (with-current-buffer gnus-summary-buffer
5989 (list (list article contents)) wide)))))
5991 (defun gnus-article-followup-with-original ()
5992 "Compose a followup to the current article.
5993 The text in the region will be yanked. If the region isn't active,
5994 the entire article will be yanked."
5996 (let ((article (cdr gnus-article-current))
5998 (if (not (gnus-region-active-p))
5999 (with-current-buffer gnus-summary-buffer
6000 (gnus-summary-followup (list (list article))))
6001 (setq contents (buffer-substring (point) (mark t)))
6002 ;; Deactivate active regions.
6003 (when (and (boundp 'transient-mark-mode)
6004 transient-mark-mode)
6005 (setq mark-active nil))
6006 (with-current-buffer gnus-summary-buffer
6007 (gnus-summary-followup
6008 (list (list article contents)))))))
6010 (defun gnus-article-hide (&optional arg force)
6011 "Hide all the gruft in the current article.
6012 This means that signatures, cited text and (some) headers will be
6014 If given a prefix, show the hidden text instead."
6015 (interactive (append (gnus-article-hidden-arg) (list 'force)))
6016 (gnus-article-hide-headers arg)
6017 (gnus-article-hide-list-identifiers arg)
6018 (gnus-article-hide-citation-maybe arg force)
6019 (gnus-article-hide-signature arg))
6021 (defun gnus-article-maybe-highlight ()
6022 "Do some article highlighting if article highlighting is requested."
6023 (when (gnus-visual-p 'article-highlight 'highlight)
6024 (gnus-article-highlight-some)))
6026 (defun gnus-check-group-server ()
6027 ;; Make sure the connection to the server is alive.
6028 (unless (gnus-server-opened
6029 (gnus-find-method-for-group gnus-newsgroup-name))
6030 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
6031 (gnus-request-group gnus-newsgroup-name t)))
6034 (autoload 'nneething-get-file-name "nneething"))
6036 (defun gnus-request-article-this-buffer (article group)
6037 "Get an article and insert it into this buffer."
6038 (let (do-update-line sparse-header)
6042 (gnus-kill-all-overlays)
6043 (setq group (or group gnus-newsgroup-name))
6045 ;; Using `gnus-request-article' directly will insert the article into
6046 ;; `nntp-server-buffer' - so we'll save some time by not having to
6047 ;; copy it from the server buffer into the article buffer.
6049 ;; We only request an article by message-id when we do not have the
6050 ;; headers for it, so we'll have to get those.
6051 (when (stringp article)
6052 (gnus-read-header article))
6054 ;; If the article number is negative, that means that this article
6055 ;; doesn't belong in this newsgroup (possibly), so we find its
6056 ;; message-id and request it by id instead of number.
6057 (when (and (numberp article)
6059 (get-buffer gnus-summary-buffer)
6060 (gnus-buffer-exists-p gnus-summary-buffer))
6062 (set-buffer gnus-summary-buffer)
6063 (let ((header (gnus-summary-article-header article)))
6066 ((memq article gnus-newsgroup-sparse)
6067 ;; This is a sparse gap article.
6068 (setq do-update-line article)
6069 (setq article (mail-header-id header))
6070 (setq sparse-header (gnus-read-header article))
6071 (setq gnus-newsgroup-sparse
6072 (delq article gnus-newsgroup-sparse)))
6074 ;; It's a real article.
6075 (setq article (mail-header-id header)))
6077 ;; It is an extracted pseudo-article.
6078 (setq article 'pseudo)
6079 (gnus-request-pseudo-article header))))
6081 (let ((method (gnus-find-method-for-group
6082 gnus-newsgroup-name)))
6083 (when (and (eq (car method) 'nneething)
6085 (let ((dir (nneething-get-file-name
6086 (mail-header-id header))))
6087 (when (and (stringp dir)
6088 (file-directory-p dir))
6089 (setq article 'nneething)
6090 (gnus-group-enter-directory dir))))))))
6093 ;; Refuse to select canceled articles.
6094 ((and (numberp article)
6096 (get-buffer gnus-summary-buffer)
6097 (gnus-buffer-exists-p gnus-summary-buffer)
6098 (eq (cdr (with-current-buffer gnus-summary-buffer
6099 (assq article gnus-newsgroup-reads)))
6100 gnus-canceled-mark))
6102 ;; We first check `gnus-original-article-buffer'.
6103 ((and (get-buffer gnus-original-article-buffer)
6105 (with-current-buffer gnus-original-article-buffer
6106 (and (equal (car gnus-original-article) group)
6107 (eq (cdr gnus-original-article) article))))
6108 (insert-buffer-substring gnus-original-article-buffer)
6110 ;; Check the backlog.
6111 ((and gnus-keep-backlog
6112 (gnus-backlog-request-article group article (current-buffer)))
6114 ;; Check asynchronous pre-fetch.
6115 ((gnus-async-request-fetched-article group article (current-buffer))
6116 (gnus-async-prefetch-next group article gnus-summary-buffer)
6117 (when (and (numberp article) gnus-keep-backlog)
6118 (gnus-backlog-enter-article group article (current-buffer)))
6121 ((and gnus-use-cache
6123 (gnus-cache-request-article article group))
6125 ;; Check the agent cache.
6126 ((gnus-agent-request-article article group)
6128 ;; Get the article and put into the article buffer.
6129 ((or (stringp article)
6131 (let ((gnus-override-method gnus-override-method)
6132 (methods (and (stringp article)
6133 gnus-refer-article-method))
6134 (backend (car (gnus-find-method-for-group
6135 gnus-newsgroup-name)))
6137 (inhibit-read-only t))
6138 (if (or (not (listp methods))
6139 (and (symbolp (car methods))
6140 (assq (car methods) nnoo-definition-alist)))
6141 (setq methods (list methods)))
6142 (when (and (null gnus-override-method)
6144 (setq gnus-override-method (pop methods)))
6146 (when (eq gnus-override-method 'current)
6147 (setq gnus-override-method
6148 (with-current-buffer gnus-summary-buffer
6149 gnus-current-select-method)))
6151 (gnus-kill-all-overlays)
6152 (let ((gnus-newsgroup-name group))
6153 (gnus-check-group-server))
6155 ((gnus-request-article article group (current-buffer))
6156 (when (numberp article)
6157 (gnus-async-prefetch-next group article
6158 gnus-summary-buffer)
6159 (when gnus-keep-backlog
6160 (gnus-backlog-enter-article
6161 group article (current-buffer))))
6162 (setq result 'article))
6164 (setq gnus-override-method (pop methods)))
6165 ((not (string-match "^400 "
6166 (nnheader-get-report backend)))
6167 ;; If we get 400 server disconnect, reconnect and
6168 ;; retry; otherwise, assume the article has expired.
6169 (setq result 'done))))
6170 (and (eq result 'article) 'article)))
6174 ;; Associate this article with the current summary buffer.
6175 (setq gnus-article-current-summary gnus-summary-buffer)
6177 ;; Take the article from the original article buffer
6178 ;; and place it in the buffer it's supposed to be in.
6179 (when (and (get-buffer gnus-article-buffer)
6180 (equal (buffer-name (current-buffer))
6181 (buffer-name (get-buffer gnus-article-buffer))))
6183 (if (get-buffer gnus-original-article-buffer)
6184 (set-buffer gnus-original-article-buffer)
6185 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
6186 (buffer-disable-undo)
6187 (setq major-mode 'gnus-original-article-mode)
6188 (setq buffer-read-only t))
6189 (let ((inhibit-read-only t))
6191 (insert-buffer-substring gnus-article-buffer))
6192 (setq gnus-original-article (cons group article)))
6195 (run-hooks 'gnus-article-decode-hook)
6196 ;; Mark article as decoded or not.
6197 (setq gnus-article-decoded-p gnus-article-decode-hook))
6199 ;; Update sparse articles.
6200 (when (and do-update-line
6201 (or (numberp article)
6203 (let ((buf (current-buffer)))
6204 (set-buffer gnus-summary-buffer)
6205 (gnus-summary-update-article do-update-line sparse-header)
6206 (gnus-summary-goto-subject do-update-line nil t)
6207 (set-window-point (gnus-get-buffer-window (current-buffer) t)
6209 (set-buffer buf))))))
6215 (defcustom gnus-article-edit-mode-hook nil
6216 "Hook run in article edit mode buffers."
6217 :group 'gnus-article-various
6220 (defcustom gnus-article-edit-article-setup-function
6221 'gnus-article-mime-edit-article-setup
6222 "Function called to setup an editing article buffer."
6223 :group 'gnus-article-various
6226 (defvar gnus-article-edit-done-function nil)
6228 (defvar gnus-article-edit-mode-map nil)
6230 ;; Should we be using derived.el for this?
6231 (unless gnus-article-edit-mode-map
6232 (setq gnus-article-edit-mode-map (make-keymap))
6233 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
6235 (gnus-define-keys gnus-article-edit-mode-map
6236 "\C-c?" describe-mode
6237 "\C-c\C-c" gnus-article-edit-done
6238 "\C-c\C-k" gnus-article-edit-exit
6239 "\C-c\C-f\C-t" message-goto-to
6240 "\C-c\C-f\C-o" message-goto-from
6241 "\C-c\C-f\C-b" message-goto-bcc
6242 ;;"\C-c\C-f\C-w" message-goto-fcc
6243 "\C-c\C-f\C-c" message-goto-cc
6244 "\C-c\C-f\C-s" message-goto-subject
6245 "\C-c\C-f\C-r" message-goto-reply-to
6246 "\C-c\C-f\C-n" message-goto-newsgroups
6247 "\C-c\C-f\C-d" message-goto-distribution
6248 "\C-c\C-f\C-f" message-goto-followup-to
6249 "\C-c\C-f\C-m" message-goto-mail-followup-to
6250 "\C-c\C-f\C-k" message-goto-keywords
6251 "\C-c\C-f\C-u" message-goto-summary
6252 "\C-c\C-f\C-i" message-insert-or-toggle-importance
6253 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
6254 "\C-c\C-b" message-goto-body
6255 "\C-c\C-i" message-goto-signature
6257 "\C-c\C-t" message-insert-to
6258 "\C-c\C-n" message-insert-newsgroups
6259 "\C-c\C-o" message-sort-headers
6260 "\C-c\C-e" message-elide-region
6261 "\C-c\C-v" message-delete-not-region
6262 "\C-c\C-z" message-kill-to-signature
6263 "\M-\r" message-newline-and-reformat
6264 "\C-c\C-a" mml-attach-file
6265 "\C-a" message-beginning-of-line
6267 "\M-;" comment-region)
6269 (gnus-define-keys (gnus-article-edit-wash-map
6270 "\C-c\C-w" gnus-article-edit-mode-map)
6271 "f" gnus-article-edit-full-stops))
6274 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
6276 ["Fetch To" message-insert-to t]
6277 ["Fetch Newsgroups" message-insert-newsgroups t]
6279 ["To" message-goto-to t]
6280 ["From" message-goto-from t]
6281 ["Subject" message-goto-subject t]
6282 ["Cc" message-goto-cc t]
6283 ["Reply-To" message-goto-reply-to t]
6284 ["Summary" message-goto-summary t]
6285 ["Keywords" message-goto-keywords t]
6286 ["Newsgroups" message-goto-newsgroups t]
6287 ["Followup-To" message-goto-followup-to t]
6288 ["Mail-Followup-To" message-goto-mail-followup-to t]
6289 ["Distribution" message-goto-distribution t]
6290 ["Body" message-goto-body t]
6291 ["Signature" message-goto-signature t]))
6293 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
6294 "Major mode for editing articles.
6295 This is an extended text-mode.
6297 \\{gnus-article-edit-mode-map}"
6298 (make-local-variable 'gnus-article-edit-done-function)
6299 (make-local-variable 'gnus-prev-winconf)
6300 (set (make-local-variable 'font-lock-defaults)
6301 '(message-font-lock-keywords t))
6302 (set (make-local-variable 'mail-header-separator) "")
6303 (set (make-local-variable 'gnus-article-edit-mode) t)
6304 (easy-menu-add message-mode-field-menu message-mode-map)
6305 (setq buffer-read-only nil)
6306 (buffer-enable-undo)
6309 (defun gnus-article-edit (&optional force)
6310 "Edit the current article.
6311 This will have permanent effect only in mail groups.
6312 If FORCE is non-nil, allow editing of articles even in read-only
6315 (when (and (not force)
6316 (gnus-group-read-only-p))
6317 (error "The current newsgroup does not support article editing"))
6318 (gnus-article-date-original)
6319 (gnus-article-edit-article
6321 `(lambda (no-highlight)
6323 (gnus-summary-edit-article-done
6324 ,(or (mail-header-references gnus-current-headers) "")
6325 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
6327 (defun gnus-article-edit-article (start-func exit-func &optional quiet)
6328 "Start editing the contents of the current article buffer."
6329 (let ((winconf (current-window-configuration)))
6330 (set-buffer gnus-article-buffer)
6331 (let ((message-auto-save-directory
6332 ;; Don't associate the article buffer with a draft file.
6334 (gnus-article-edit-mode))
6335 (funcall start-func)
6336 (set-buffer-modified-p nil)
6337 (gnus-configure-windows 'edit-article)
6338 (setq gnus-article-edit-done-function exit-func)
6339 (setq gnus-prev-winconf winconf)
6340 (when gnus-article-edit-article-setup-function
6341 (funcall gnus-article-edit-article-setup-function))
6343 (gnus-message 6 "C-c C-c to end edits; C-c C-k to exit"))))
6345 (defun gnus-article-edit-done (&optional arg)
6346 "Update the article edits and exit."
6348 (let ((func gnus-article-edit-done-function)
6349 (buf (current-buffer))
6350 (start (window-start))
6352 (winconf gnus-prev-winconf))
6353 (remove-hook 'gnus-article-mode-hook
6354 'gnus-article-mime-edit-article-unwind)
6355 (widen) ;; Widen it in case that users narrowed the buffer.
6358 ;; The cache and backlog have to be flushed somewhat.
6359 (when gnus-keep-backlog
6360 (gnus-backlog-remove-article
6361 (car gnus-article-current) (cdr gnus-article-current)))
6362 ;; Flush original article as well.
6364 (when (get-buffer gnus-original-article-buffer)
6365 (set-buffer gnus-original-article-buffer)
6366 (setq gnus-original-article nil)))
6367 (when gnus-use-cache
6368 (gnus-cache-update-article
6369 (car gnus-article-current) (cdr gnus-article-current)))
6370 ;; We remove all text props from the article buffer.
6371 (kill-all-local-variables)
6372 (set-text-properties (point-min) (point-max) nil)
6374 (set-window-configuration winconf)
6376 (set-window-start (get-buffer-window buf) start)
6377 (set-window-point (get-buffer-window buf) (point)))
6378 (gnus-summary-show-article))
6380 (defun gnus-article-edit-exit ()
6381 "Exit the article editing without updating."
6383 (when (or (not (buffer-modified-p))
6384 (yes-or-no-p "Article modified; kill anyway? "))
6385 (let ((curbuf (current-buffer))
6387 (window-start (window-start)))
6389 (if (gnus-buffer-live-p gnus-original-article-buffer)
6390 (insert-buffer-substring gnus-original-article-buffer))
6391 (let ((winconf gnus-prev-winconf))
6392 (kill-all-local-variables)
6394 (set-window-configuration winconf)
6395 ;; Tippy-toe some to make sure that point remains where it was.
6396 (save-current-buffer
6398 (set-window-start (get-buffer-window (current-buffer)) window-start)
6400 (gnus-summary-show-article)))
6402 (defun gnus-article-edit-full-stops ()
6403 "Interactively repair spacing at end of sentences."
6406 (goto-char (point-min))
6407 (search-forward-regexp "^$" nil t)
6408 (let ((case-fold-search nil))
6409 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
6412 ;;; Article editing with MIME-Edit
6415 (defcustom gnus-article-mime-edit-article-setup-hook nil
6416 "Hook run after setting up a MIME editing article buffer."
6417 :group 'gnus-article-various
6420 (defun gnus-article-mime-edit-article-unwind ()
6421 "Unwind `gnus-article-buffer' if article editing was given up."
6422 (remove-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6423 (when (featurep 'font-lock)
6424 (setq font-lock-defaults nil)
6425 (font-lock-mode -1))
6426 (when mime-edit-mode-flag
6427 (mime-edit-exit 'nomime 'no-error)
6430 (defun gnus-article-mime-edit-article-setup ()
6431 "Convert current buffer to MIME-Edit buffer and turn on MIME-Edit mode
6432 after replacing with the original article."
6433 (setq gnus-show-mime t)
6434 (setq gnus-article-edit-done-function
6435 `(lambda (&rest args)
6436 (when mime-edit-mode-flag
6437 (let (mime-edit-insert-user-agent-field)
6440 (goto-char (point-min))
6441 (let (case-fold-search)
6442 (when (re-search-forward
6443 (format "^%s$" (regexp-quote mail-header-separator))
6445 (replace-match "")))
6446 (apply ,gnus-article-edit-done-function args)
6449 (buffer-substring-no-properties (point-min) (point-max))
6450 (set-buffer (get-buffer-create gnus-original-article-buffer))
6452 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6453 (set-buffer gnus-article-buffer)
6454 (gnus-article-prepare-display)))
6455 (substitute-key-definition 'gnus-article-edit-done
6456 'gnus-article-mime-edit-done
6457 gnus-article-edit-mode-map)
6458 (substitute-key-definition 'gnus-article-edit-exit
6459 'gnus-article-mime-edit-exit
6460 gnus-article-edit-mode-map)
6462 (insert-buffer-substring gnus-original-article-buffer)
6463 (unless (member (with-current-buffer gnus-summary-buffer
6464 gnus-newsgroup-name)
6465 '("nndraft:delayed" "nndraft:drafts"))
6466 (let ((ofn (symbol-function 'mime-edit-decode-single-part-in-buffer)))
6467 (fset 'mime-edit-decode-single-part-in-buffer
6468 (lambda (&rest args)
6469 (if (let ((content-type (car args)))
6470 (and (eq 'message (mime-content-type-primary-type
6472 (eq 'rfc822 (mime-content-type-subtype
6474 (setcar (cdr args) 'not-decode-text))
6478 (fset 'mime-edit-decode-single-part-in-buffer ofn))))
6479 (when (featurep 'font-lock)
6480 (set (make-local-variable 'font-lock-defaults)
6481 '(message-font-lock-keywords t))
6482 (font-lock-set-defaults)
6483 (turn-on-font-lock))
6484 (set-buffer-modified-p nil)
6485 (delete-other-windows)
6486 (add-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6487 (gnus-run-hooks 'gnus-article-mime-edit-article-setup-hook))
6489 (defun gnus-article-mime-edit-done (&optional arg)
6490 "Update the article MIME edits and exit."
6492 (when (featurep 'font-lock)
6493 (setq font-lock-defaults nil)
6494 (font-lock-mode -1))
6495 (let ((inhibit-read-only t))
6496 (gnus-article-edit-done arg)))
6498 (defun gnus-article-mime-edit-exit ()
6499 "Exit the article MIME editing without updating."
6501 (when (or (not (buffer-modified-p))
6502 (yes-or-no-p "Article modified; kill anyway? "))
6503 (when (featurep 'font-lock)
6504 (setq font-lock-defaults nil)
6505 (font-lock-mode -1))
6506 (when mime-edit-mode-flag
6507 (let (mime-edit-insert-user-agent-field)
6510 (goto-char (point-min))
6511 (let (case-fold-search)
6512 (when (re-search-forward
6513 (format "^%s$" (regexp-quote mail-header-separator)) nil t)
6514 (replace-match "")))
6515 (let ((winconf gnus-prev-winconf))
6517 (buffer-substring-no-properties (point-min) (point-max))
6518 (set-buffer (get-buffer-create gnus-original-article-buffer))
6520 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6521 (set-buffer gnus-article-buffer)
6522 (gnus-article-prepare-display)
6523 (set-window-configuration winconf))))
6526 ;;; Article highlights
6529 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
6531 ;;; Internal Variables:
6533 (defcustom gnus-button-url-regexp
6534 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
6535 "\\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:]]\\)"
6536 "\\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\\)\\)")
6537 "Regular expression that matches URLs."
6538 :group 'gnus-article-buttons
6541 (defcustom gnus-button-valid-fqdn-regexp
6542 message-valid-fqdn-regexp
6543 "Regular expression that matches a valid FQDN."
6545 :group 'gnus-article-buttons
6548 ;; Regexp suggested by Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
6549 (defcustom gnus-button-valid-localpart-regexp
6550 "[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t ]*"
6551 "Regular expression that matches a localpart of mail addresses or MIDs."
6553 :group 'gnus-article-buttons
6556 (defcustom gnus-button-man-handler 'manual-entry
6557 "Function to use for displaying man pages.
6558 The function must take at least one argument with a string naming the
6561 :type '(choice (function-item :tag "Man" manual-entry)
6562 (function-item :tag "Woman" woman)
6563 (function :tag "Other"))
6564 :group 'gnus-article-buttons)
6566 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
6567 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
6568 If the default site is too slow, try to find a CTAN mirror, see
6569 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
6570 the variable `gnus-button-handle-ctan'."
6572 :group 'gnus-article-buttons
6573 :link '(custom-manual "(gnus)Group Parameters")
6574 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
6575 (const "http://tug.ctan.org/tex-archive/")
6576 (const "http://www.dante.de/CTAN/")
6577 (string :tag "Other")))
6579 (defcustom gnus-button-ctan-handler 'browse-url
6580 "Function to use for displaying CTAN links.
6581 The function must take one argument, the string naming the URL."
6583 :type '(choice (function-item :tag "Browse Url" browse-url)
6584 (function :tag "Other"))
6585 :group 'gnus-article-buttons)
6587 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
6588 "Bogus strings removed from CTAN URLs."
6590 :group 'gnus-article-buttons
6591 :type '(choice (const "^/?tex-archive/\\|/")
6592 (regexp :tag "Other")))
6594 (defcustom gnus-button-ctan-directory-regexp
6596 (list "archive-tools" "biblio" "bibliography" "digests" "documentation"
6597 "dviware" "fonts" "graphics" "help" "indexing" "info" "language"
6598 "languages" "macros" "nonfree" "obsolete" "support" "systems"
6599 "tds" "tools" "usergrps" "web") t)
6600 "Regular expression for ctan directories.
6601 It should match all directories in the top level of `gnus-ctan-url'."
6603 :group 'gnus-article-buttons
6606 (defcustom gnus-button-mid-or-mail-regexp
6607 (concat "\\b\\(<?" gnus-button-valid-localpart-regexp "@"
6608 gnus-button-valid-fqdn-regexp
6610 "Regular expression that matches a message ID or a mail address."
6612 :group 'gnus-article-buttons
6615 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
6616 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
6617 Strings like this can be either a message ID or a mail address. If it is one
6618 of the symbols `mid' or `mail', Gnus will always assume that the string is a
6619 message ID or a mail address, respectively. If this variable is set to the
6620 symbol `ask', always query the user what do do. If it is a function, this
6621 function will be called with the string as it's only argument. The function
6622 must return `mid', `mail', `invalid' or `ask'."
6624 :group 'gnus-article-buttons
6625 :type '(choice (function-item :tag "Heuristic function"
6626 gnus-button-mid-or-mail-heuristic)
6631 (defcustom gnus-button-mid-or-mail-heuristic-alist
6632 '((-10.0 . ".+\\$.+@")
6635 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
6636 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
6637 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
6638 (-1.0 . "^[^a-z]+@")
6640 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
6641 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
6642 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
6643 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
6646 (-1.0 . "^[0-9][0-9]")
6648 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
6649 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6650 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
6651 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6653 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
6654 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
6657 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
6659 ;; compensation for TDMA dated mail addresses:
6660 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
6662 (-20.0 . "\\.fsf@") ;; Gnus
6665 (-20.0 . "_-_") ;; Subject change in thread
6667 (-20.0 . "\\.ln@") ;; leafnode
6668 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
6669 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
6671 ;; (5.0 . "") ;; $local_part_len <= 7
6672 (10.0 . "^[^0-9]+@")
6673 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
6674 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
6677 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
6679 (0.5 . "^[A-Z][a-z]")
6680 (0.5 . "^[A-Z][a-z][a-z]")
6681 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
6682 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
6683 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
6685 A negative RATE indicates a message IDs, whereas a positive indicates a mail
6686 address. The REGEXP is processed with `case-fold-search' set to nil."
6688 :group 'gnus-article-buttons
6689 :type '(repeat (cons (number :tag "Rate")
6690 (regexp :tag "Regexp"))))
6692 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
6693 "Guess whether MID-OR-MAIL is a message ID or a mail address.
6694 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
6695 address, `ask' if unsure and `invalid' if the string is invalid."
6696 (let ((case-fold-search nil)
6697 (list gnus-button-mid-or-mail-heuristic-alist)
6698 (result 0) rate regexp lpartlen elem)
6700 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
6701 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
6702 ;; Certain special cases...
6705 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
6706 "^[0-9]+\\.[0-9]+@compuserve\\|"
6707 "@public\\.gmane\\.org")
6709 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
6710 (setq result 'mail))
6711 (when (string-match "@.*@\\| " mid-or-mail)
6712 (gnus-message 8 "`%s' is invalid." mid-or-mail)
6713 (setq result 'invalid))
6714 ;; Nothing more to do, if result is not a number here...
6715 (when (numberp result)
6717 (setq elem (car list)
6721 (when (string-match regexp mid-or-mail)
6722 (setq result (+ result rate))
6724 9 "`%s' matched `%s', rate `%s', result `%s'."
6725 mid-or-mail regexp rate result)))
6726 (when (<= lpartlen 7)
6727 (setq result (+ result 5.0))
6728 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
6729 mid-or-mail result))
6730 (when (>= lpartlen 12)
6731 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
6733 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
6734 ;; Long local part should contain realname if e-mail address,
6735 ;; too many digits: message-id.
6736 ;; $score -= 5.0 + 0.1 * $local_part_len;
6737 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6738 (setq result (+ result rate))
6740 9 "Many digits in `%s', rate `%s', result `%s'."
6741 mid-or-mail rate result))
6742 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6744 ;; Too few vowels [^aeiouy]{4,}.*\@
6745 (setq result (+ result -5.0))
6747 9 "Few vowels in `%s', rate `%s', result `%s'."
6748 mid-or-mail -5.0 result))
6750 (setq result (+ result 5.0))
6752 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6753 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6754 ;; Maybe we should make this a customizable alist: (condition . 'result)
6756 ((symbolp result) result)
6757 ;; Now convert number into proper results:
6758 ((< result -10.0) 'mid)
6759 ((> result 10.0) 'mail)
6762 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6763 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6764 (url-mid (concat "news" ":" mid-or-mail))
6765 (url-mailto (concat "mailto" ":" mid-or-mail)))
6766 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6767 (when (fboundp pref)
6769 ;; get rid of surrounding angles...
6771 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6772 (if (or (eq 'mid guessed) (eq 'mail guessed))
6776 (save-window-excursion
6777 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6780 (cond ((eq pref 'mid)
6781 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6782 (gnus-button-handle-news url-mid))
6784 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6785 (gnus-url-mailto url-mailto))
6786 (t (gnus-message 3 "Invalid string.")))))
6788 (defun gnus-button-handle-custom (fun arg)
6789 "Call function FUN on argument ARG.
6790 Both FUN and ARG are supposed to be strings. ARG will be passed
6791 as a symbol to FUN."
6792 (funcall (intern fun) (intern arg)))
6794 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6796 ;; FIXME: Maybe we should merge some of the functions that do quite similar
6799 (defun gnus-button-handle-describe-function (url)
6800 "Call `describe-function' when pushing the corresponding URL button."
6803 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6805 (defun gnus-button-handle-describe-variable (url)
6806 "Call `describe-variable' when pushing the corresponding URL button."
6809 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6811 (defun gnus-button-handle-symbol (url)
6812 "Display help on variable or function.
6813 Calls `describe-variable' or `describe-function'."
6814 (let ((sym (intern url)))
6816 ((fboundp sym) (describe-function sym))
6817 ((boundp sym) (describe-variable sym))
6818 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
6820 (defun gnus-button-handle-describe-key (url)
6821 "Call `describe-key' when pushing the corresponding URL button."
6823 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6824 (keys (ignore-errors (eval `(kbd ,key-string)))))
6827 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6829 (defun gnus-button-handle-apropos (url)
6830 "Call `apropos' when pushing the corresponding URL button."
6831 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6833 (defun gnus-button-handle-apropos-command (url)
6834 "Call `apropos' when pushing the corresponding URL button."
6836 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6838 (defun gnus-button-handle-apropos-variable (url)
6839 "Call `apropos' when pushing the corresponding URL button."
6841 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6842 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6844 (defun gnus-button-handle-apropos-documentation (url)
6845 "Call `apropos' when pushing the corresponding URL button."
6847 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6848 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6850 (defun gnus-button-handle-library (url)
6851 "Call `locate-library' when pushing the corresponding URL button."
6852 (gnus-message 9 "url=`%s'" url)
6853 (let* ((lib (locate-library url))
6854 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6856 (gnus-message 1 "Cannot locale library `%s'." url)
6857 (find-file-read-only file))))
6859 (defun gnus-button-handle-ctan (url)
6860 "Call `browse-url' when pushing a CTAN URL button."
6862 gnus-button-ctan-handler
6865 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6867 (defcustom gnus-button-tex-level 5
6868 "*Integer that says how many TeX-related buttons Gnus will show.
6869 The higher the number, the more buttons will appear and the more false
6870 positives are possible. Note that you can set this variable local to
6871 specific groups. Setting it higher in TeX groups is probably a good idea.
6872 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6873 how to set variables in specific groups."
6875 :group 'gnus-article-buttons
6876 :link '(custom-manual "(gnus)Group Parameters")
6879 (defcustom gnus-button-man-level 5
6880 "*Integer that says how many man-related buttons Gnus will show.
6881 The higher the number, the more buttons will appear and the more false
6882 positives are possible. Note that you can set this variable local to
6883 specific groups. Setting it higher in Unix groups is probably a good idea.
6884 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6885 how to set variables in specific groups."
6887 :group 'gnus-article-buttons
6888 :link '(custom-manual "(gnus)Group Parameters")
6891 (defcustom gnus-button-emacs-level 5
6892 "*Integer that says how many emacs-related buttons Gnus will show.
6893 The higher the number, the more buttons will appear and the more false
6894 positives are possible. Note that you can set this variable local to
6895 specific groups. Setting it higher in Emacs or Gnus related groups is
6896 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6897 `gnus-parameters' on how to set variables in specific groups."
6899 :group 'gnus-article-buttons
6900 :link '(custom-manual "(gnus)Group Parameters")
6903 (defcustom gnus-button-message-level 5
6904 "*Integer that says how many buttons for news or mail messages will appear.
6905 The higher the number, the more buttons will appear and the more false
6906 positives are possible."
6907 ;; mail addresses, MIDs, URLs for news, ...
6909 :group 'gnus-article-buttons
6912 (defcustom gnus-button-browse-level 5
6913 "*Integer that says how many buttons for browsing will appear.
6914 The higher the number, the more buttons will appear and the more false
6915 positives are possible."
6916 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6918 :group 'gnus-article-buttons
6921 (defcustom gnus-button-alist
6922 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6923 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6924 ((concat "\\b\\(nntp\\|news\\):\\("
6925 gnus-button-valid-localpart-regexp "@[a-z0-9.-]+[a-z]\\)")
6926 0 t gnus-button-handle-news 2)
6927 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6928 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6929 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6930 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6931 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
6932 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
6933 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
6934 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6935 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6936 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6937 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6938 ;; RFC 2368 (The mailto URL scheme)
6939 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6940 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6941 ("\\bmailto:\\([^ \n\t]+\\)"
6942 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6944 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6945 gnus-button-ctan-directory-regexp
6946 "[^][>)!;:,'\n\t ]+\\)")
6947 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6948 ((concat "\\btex-archive/\\("
6949 gnus-button-ctan-directory-regexp
6950 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6951 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6954 gnus-button-ctan-directory-regexp
6955 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6956 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6957 ;; This is info (home-grown style) <info://foo/bar+baz>
6958 ("\\binfo://\\([^'\">\n\t ]+\\)"
6959 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6960 ;; Info GNOME style <info:foo#bar_baz>
6961 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6962 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6963 ;; Info KDE style <info:(foo)bar baz>
6964 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6965 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6966 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6967 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6968 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6969 ;; Info links like `C-h i d m CC Mode RET'
6970 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6972 ("M-x[ \t\n]\\(customize-[^ ]+\\)[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6973 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1 2)
6974 ;; Emacs help commands
6975 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6976 ;; regexp doesn't match arguments containing ` '.
6977 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6978 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6979 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6980 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6981 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6982 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6983 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6984 ;; The following entries may lead to many false positives so don't enable
6985 ;; them by default (use a high button level).
6986 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
6987 ;; Exclude [.?] for URLs in gmane.emacs.cvs
6988 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6989 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6990 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6991 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6992 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6993 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6994 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6995 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6996 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6997 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6998 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
6999 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
7000 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
7001 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
7002 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
7003 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
7004 ;; Unlike the other regexps we really have to require quoting
7005 ;; here to determine where it ends.
7006 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
7007 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
7008 ("<URL: *\\([^<>]*\\)>"
7009 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
7010 ;; RFC 2396 (2.4.3., delims) ...
7011 ("\"URL: *\\([^\"]*\\)\""
7012 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
7013 ;; RFC 2396 (2.4.3., delims) ...
7014 ("\"URL: *\\([^\"]*\\)\""
7015 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
7017 (gnus-button-url-regexp
7018 0 (>= gnus-button-browse-level 0) browse-url 0)
7020 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
7021 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
7022 gnus-button-handle-man 1)
7023 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
7024 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
7025 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
7026 gnus-button-handle-man 1)
7027 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
7028 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
7029 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
7030 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
7031 ;; MID or mail: To avoid too many false positives we don't try to catch
7032 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
7033 ;; at least one dot. TLD must contain two or three chars or be a know TLD
7034 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
7035 ;; so that non-ambiguous entries (see above) match first.
7036 (gnus-button-mid-or-mail-regexp
7037 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
7038 "*Alist of regexps matching buttons in article bodies.
7040 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
7041 REGEXP: is the string (case insensitive) matching text around the button (can
7042 also be Lisp expression evaluating to a string),
7043 BUTTON: is the number of the regexp grouping actually matching the button,
7044 FORM: is a Lisp expression which must eval to true for the button to
7046 CALLBACK: is the function to call when the user push this button, and each
7047 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
7049 CALLBACK can also be a variable, in that case the value of that
7050 variable it the real callback function."
7051 :group 'gnus-article-buttons
7052 :type '(repeat (list (choice regexp variable sexp)
7053 (integer :tag "Button")
7055 (function :tag "Callback")
7058 (integer :tag "Regexp group")))))
7060 (defcustom gnus-header-button-alist
7061 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
7062 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
7063 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
7064 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
7065 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
7066 0 (>= gnus-button-message-level 0) gnus-msg-mail 0)
7067 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
7068 0 (>= gnus-button-browse-level 0) browse-url 0)
7069 ("^Subject:" gnus-button-url-regexp
7070 0 (>= gnus-button-browse-level 0) browse-url 0)
7071 ("^[^:]+:" gnus-button-url-regexp
7072 0 (>= gnus-button-browse-level 0) browse-url 0)
7073 ("^OpenPGP:.*url=" gnus-button-url-regexp
7074 0 (>= gnus-button-browse-level 0) gnus-button-openpgp 0)
7075 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
7076 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
7077 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
7078 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
7079 "*Alist of headers and regexps to match buttons in article heads.
7081 This alist is very similar to `gnus-button-alist', except that each
7082 alist has an additional HEADER element first in each entry:
7084 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
7086 HEADER is a regexp to match a header. For a fuller explanation, see
7087 `gnus-button-alist'."
7088 :group 'gnus-article-buttons
7089 :group 'gnus-article-headers
7090 :type '(repeat (list (regexp :tag "Header")
7091 (choice regexp variable)
7092 (integer :tag "Button")
7094 (function :tag "Callback")
7097 (integer :tag "Regexp group")))))
7101 (defun gnus-article-push-button (event)
7102 "Check text under the mouse pointer for a callback function.
7103 If the text under the mouse pointer has a `gnus-callback' property,
7104 call it with the value of the `gnus-data' text property."
7106 (set-buffer (window-buffer (posn-window (event-start event))))
7107 (let* ((pos (posn-point (event-start event)))
7108 (data (get-text-property pos 'gnus-data))
7109 (fun (get-text-property pos 'gnus-callback)))
7112 (funcall fun data))))
7114 (defun gnus-article-press-button ()
7115 "Check text at point for a callback function.
7116 If the text at point has a `gnus-callback' property,
7117 call it with the value of the `gnus-data' text property."
7119 (let ((data (get-text-property (point) 'gnus-data))
7120 (fun (get-text-property (point) 'gnus-callback)))
7122 (funcall fun data))))
7124 (defun gnus-article-prev-button (n)
7125 "Move point to N buttons backward.
7126 If N is negative, move forward instead."
7128 (gnus-article-next-button (- n)))
7130 (defun gnus-article-next-button (n)
7131 "Move point to N buttons forward.
7132 If N is negative, move backward instead."
7134 (let ((function (if (< n 0) 'previous-single-property-change
7135 'next-single-property-change))
7136 (inhibit-point-motion-hooks t)
7138 (limit (if (< n 0) (point-min) (point-max))))
7140 (while (and (not (= limit (point)))
7142 ;; Skip past the current button.
7143 (when (get-text-property (point) 'gnus-callback)
7144 (goto-char (funcall function (point) 'gnus-callback nil limit)))
7145 ;; Go to the next (or previous) button.
7146 (gnus-goto-char (funcall function (point) 'gnus-callback nil limit))
7147 ;; Put point at the start of the button.
7148 (when (and backward (not (get-text-property (point) 'gnus-callback)))
7149 (goto-char (funcall function (point) 'gnus-callback nil limit)))
7150 ;; Skip past intangible buttons.
7151 (when (get-text-property (point) 'intangible)
7155 (gnus-message 5 "No more buttons"))
7158 (defun gnus-article-highlight (&optional force)
7159 "Highlight current article.
7160 This function calls `gnus-article-highlight-headers',
7161 `gnus-article-highlight-citation',
7162 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
7163 do the highlighting. See the documentation for those functions."
7164 (interactive (list 'force))
7165 (gnus-article-highlight-headers)
7166 (gnus-article-highlight-citation force)
7167 (gnus-article-highlight-signature)
7168 (gnus-article-add-buttons force)
7169 (gnus-article-add-buttons-to-head))
7171 (defun gnus-article-highlight-some (&optional force)
7172 "Highlight current article.
7173 This function calls `gnus-article-highlight-headers',
7174 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
7175 do the highlighting. See the documentation for those functions."
7176 (interactive (list 'force))
7177 (gnus-article-highlight-headers)
7178 (gnus-article-highlight-signature)
7179 (gnus-article-add-buttons))
7181 (defun gnus-article-highlight-headers ()
7182 "Highlight article headers as specified by `gnus-header-face-alist'."
7184 (gnus-with-article-headers
7185 (let (regexp header-face field-face from hpoints fpoints)
7186 (dolist (entry gnus-header-face-alist)
7187 (goto-char (point-min))
7188 (setq regexp (concat "^\\("
7189 (if (string-equal "" (nth 0 entry))
7193 header-face (nth 1 entry)
7194 field-face (nth 2 entry))
7195 (while (and (re-search-forward regexp nil t)
7199 (unless (search-forward ":" nil t)
7201 (when (and header-face
7202 (not (memq (point) hpoints)))
7203 (push (point) hpoints)
7204 (gnus-put-text-property from (point) 'face header-face))
7205 (when (and field-face
7206 (not (memq (setq from (point)) fpoints)))
7208 (if (re-search-forward "^[^ \t]" nil t)
7210 (goto-char (point-max)))
7211 (gnus-put-text-property from (point) 'face field-face)))))))
7213 (defun gnus-article-highlight-signature ()
7214 "Highlight the signature in an article.
7215 It does this by highlighting everything after
7216 `gnus-signature-separator' using the face `gnus-signature'."
7218 (when gnus-signature-face
7219 (gnus-with-article-buffer
7220 (let ((inhibit-point-motion-hooks t))
7222 (when (gnus-article-narrow-to-signature)
7223 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
7224 'face gnus-signature-face)))))))
7226 (defun gnus-article-buttonize-signature ()
7227 "Add button to the signature."
7230 (set-buffer gnus-article-buffer)
7231 (let ((inhibit-read-only t)
7232 (inhibit-point-motion-hooks t))
7233 (when (gnus-article-search-signature)
7234 (gnus-article-add-button (match-beginning 0) (match-end 0)
7235 'gnus-signature-toggle
7236 (set-marker (make-marker)
7237 (1+ (match-end 0))))))))
7239 (defun gnus-button-in-region-p (b e prop)
7240 "Say whether PROP exists in the region."
7241 (text-property-not-all b e prop nil))
7243 (defun gnus-article-add-buttons (&optional force)
7244 "Find external references in the article and make buttons of them.
7245 \"External references\" are things like Message-IDs and URLs, as
7246 specified by `gnus-button-alist'."
7247 (interactive (list 'force))
7248 (gnus-with-article-buffer
7249 (let ((inhibit-point-motion-hooks t)
7250 (case-fold-search t)
7251 (alist gnus-button-alist)
7253 ;; Remove all old markers.
7254 (let (marker entry new-list)
7255 (while (setq marker (pop gnus-button-marker-list))
7256 (if (or (< marker (point-min)) (>= marker (point-max)))
7257 (push marker new-list)
7259 (when (setq entry (gnus-button-entry))
7260 (put-text-property (match-beginning (nth 1 entry))
7261 (match-end (nth 1 entry))
7262 'gnus-callback nil))
7263 (set-marker marker nil)))
7264 (setq gnus-button-marker-list new-list))
7265 ;; We skip the headers.
7268 (while (setq entry (pop alist))
7269 (setq regexp (eval (car entry)))
7271 (while (re-search-forward regexp nil t)
7272 (let* ((start (and entry (match-beginning (nth 1 entry))))
7273 (end (and entry (match-end (nth 1 entry))))
7274 (from (match-beginning 0)))
7275 (when (and (or (eq t (nth 2 entry))
7276 (eval (nth 2 entry)))
7277 (not (gnus-button-in-region-p
7278 start end 'gnus-callback)))
7279 ;; That optional form returned non-nil, so we add the
7281 (gnus-article-add-button
7282 start end 'gnus-button-push
7283 (car (push (set-marker (make-marker) from)
7284 gnus-button-marker-list))))))))))
7286 ;; Add buttons to the head of an article.
7287 (defun gnus-article-add-buttons-to-head ()
7288 "Add buttons to the head of the article."
7290 (gnus-with-article-headers
7292 (dolist (entry gnus-header-button-alist)
7293 ;; Each alist entry.
7294 (goto-char (point-min))
7295 (while (re-search-forward (car entry) nil t)
7296 ;; Each header matching the entry.
7297 (setq beg (match-beginning 0))
7298 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
7299 (match-beginning 0))
7302 (while (re-search-forward (eval (nth 1 entry)) end t)
7303 ;; Each match within a header.
7304 (let* ((entry (cdr entry))
7305 (start (match-beginning (nth 1 entry)))
7306 (end (match-end (nth 1 entry)))
7307 (form (nth 2 entry)))
7308 (goto-char (match-end 0))
7310 (gnus-article-add-button
7311 start end (nth 3 entry)
7312 (buffer-substring (match-beginning (nth 4 entry))
7313 (match-end (nth 4 entry)))))))
7314 (goto-char end))))))
7316 ;;; External functions:
7318 (defun gnus-article-add-button (from to fun &optional data)
7319 "Create a button between FROM and TO with callback FUN and data DATA."
7320 (when gnus-article-button-face
7321 (gnus-overlay-put (gnus-make-overlay from to)
7322 'face gnus-article-button-face))
7323 (gnus-add-text-properties
7325 (nconc (and gnus-article-mouse-face
7326 (list gnus-mouse-face-prop gnus-article-mouse-face))
7327 (list 'gnus-callback fun)
7328 (and data (list 'gnus-data data))))
7329 (widget-convert-button 'link from to :action 'gnus-widget-press-button
7330 :button-keymap gnus-widget-button-keymap))
7332 ;;; Internal functions:
7334 (defun gnus-article-set-globals ()
7335 (with-current-buffer gnus-summary-buffer
7336 (gnus-set-global-variables)))
7338 (defun gnus-signature-toggle (end)
7339 (gnus-with-article-buffer
7340 (let ((inhibit-point-motion-hooks t)
7341 (limit (next-single-property-change end 'mime-view-entity
7343 (if (text-property-any end limit 'article-type 'signature)
7345 (gnus-delete-wash-type 'signature)
7346 (gnus-remove-text-properties-when
7347 'article-type 'signature end limit
7348 (cons 'article-type (cons 'signature
7349 gnus-hidden-properties))))
7350 (gnus-add-wash-type 'signature)
7351 (gnus-add-text-properties-when
7352 'article-type nil end limit
7353 (cons 'article-type (cons 'signature
7354 gnus-hidden-properties)))))
7355 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
7356 (gnus-set-mode-line 'article))))
7358 (defun gnus-button-entry ()
7359 ;; Return the first entry in `gnus-button-alist' matching this place.
7360 (let ((alist gnus-button-alist)
7363 (setq entry (pop alist))
7364 (if (looking-at (eval (car entry)))
7369 (defun gnus-button-push (marker)
7370 ;; Push button starting at MARKER.
7373 (let* ((entry (gnus-button-entry))
7374 (inhibit-point-motion-hooks t)
7376 (args (mapcar (lambda (group)
7377 (let ((string (match-string group)))
7378 (set-text-properties
7379 0 (length string) nil string)
7386 (fboundp (symbol-value fun)))
7387 (apply (symbol-value fun) args))
7389 (gnus-message 1 "You must define `%S' to use this button"
7390 (cons fun args)))))))
7392 (defun gnus-parse-news-url (url)
7393 (let (scheme server port group message-id articles)
7396 (goto-char (point-min))
7397 (when (looking-at "\\([A-Za-z]+\\):")
7398 (setq scheme (match-string 1))
7399 (goto-char (match-end 0)))
7400 (when (looking-at "//\\([^:/]+\\)\\(:?\\)\\([0-9]+\\)?/")
7401 (setq server (match-string 1))
7402 (setq port (if (stringp (match-string 3))
7403 (string-to-number (match-string 3))
7405 (goto-char (match-end 0)))
7408 ((looking-at "\\(.*@.*\\)")
7409 (setq message-id (match-string 1)))
7410 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
7411 (setq group (match-string 1)
7412 articles (split-string (match-string 2) "-")))
7413 ((looking-at "\\([^/]+\\)/?")
7414 (setq group (match-string 1)))
7416 (error "Unknown news URL syntax"))))
7417 (list scheme server port group message-id articles)))
7419 (defun gnus-button-handle-news (url)
7421 (destructuring-bind (scheme server port group message-id articles)
7422 (gnus-parse-news-url url)
7426 (set-buffer gnus-summary-buffer)
7428 (let ((gnus-refer-article-method
7429 (nconc (list (list 'nntp server))
7430 gnus-refer-article-method))
7431 (nntp-port-number (or port "nntp")))
7432 (gnus-message 7 "Fetching %s with %s"
7433 message-id gnus-refer-article-method)
7434 (gnus-summary-refer-article message-id))
7435 (gnus-summary-refer-article message-id))))
7437 (gnus-button-fetch-group url)))))
7439 (defun gnus-button-handle-man (url)
7441 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7442 (when (eq gnus-button-man-handler 'woman)
7443 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
7444 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7445 (funcall gnus-button-man-handler url))
7447 (defun gnus-button-handle-info-url (url)
7448 "Fetch an info URL."
7449 (setq url (mm-subst-char-in-string ?+ ?\ url))
7451 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
7452 (gnus-info-find-node
7453 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
7455 ")" (gnus-url-unhex-string (match-string 2 url)))))
7456 ((string-match "([^)\"]+)[^\"]+" url)
7458 (gnus-replace-in-string
7459 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
7460 (gnus-info-find-node url))
7461 (t (error "Can't parse %s" url))))
7463 (defun gnus-button-handle-info-url-gnome (url)
7464 "Fetch GNOME style info URL."
7465 (setq url (mm-subst-char-in-string ?_ ?\ url))
7466 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
7467 (gnus-info-find-node
7469 (gnus-url-unhex-string
7470 (match-string 1 url))
7472 (or (gnus-url-unhex-string
7473 (match-string 2 url))
7475 (error "Can't parse %s" url)))
7477 (defun gnus-button-handle-info-url-kde (url)
7478 "Fetch KDE style info URL."
7479 (gnus-info-find-node (gnus-url-unhex-string url)))
7481 (defun gnus-button-handle-info-keystrokes (url)
7482 "Call `info' when pushing the corresponding URL button."
7483 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
7488 (defun gnus-button-openpgp (url)
7489 "Retrieve and add an OpenPGP key given URL from an OpenPGP header."
7491 (mm-url-insert-file-contents-external url)
7492 (pgg-snarf-keys-region (point-min) (point-max))
7493 (pgg-display-output-buffer nil nil nil)))
7495 (defun gnus-button-message-id (message-id)
7497 (with-current-buffer gnus-summary-buffer
7498 (gnus-summary-refer-article message-id)))
7500 (defun gnus-button-fetch-group (address)
7501 "Fetch GROUP specified by ADDRESS."
7502 (if (not (string-match "[:/]" address))
7503 ;; This is just a simple group url.
7504 (gnus-group-read-ephemeral-group address gnus-select-method)
7507 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
7509 (error "Can't parse %s" address)
7510 (gnus-group-read-ephemeral-group
7511 (match-string 4 address)
7512 `(nntp ,(match-string 1 address)
7513 (nntp-address ,(match-string 1 address))
7514 (nntp-port-number ,(if (match-end 3)
7515 (match-string 3 address)
7518 (and (match-end 6) (list (string-to-number (match-string 6 address))))))))
7520 (defun gnus-url-parse-query-string (query &optional downcase)
7521 (let (retval pairs cur key val)
7522 (setq pairs (split-string query "&"))
7524 (setq cur (car pairs)
7526 (if (not (string-match "=" cur))
7528 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
7529 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
7531 (setq key (downcase key)))
7532 (setq cur (assoc key retval))
7534 (setcdr cur (cons val (cdr cur)))
7535 (setq retval (cons (list key val) retval)))))
7538 (defun gnus-url-mailto (url)
7539 ;; Send mail to someone
7540 (when (string-match "mailto:/*\\(.*\\)" url)
7541 (setq url (substring url (match-beginning 1) nil)))
7542 (let (to args subject func)
7543 (setq args (gnus-url-parse-query-string
7544 (if (string-match "^\\?" url)
7546 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
7547 (concat "to=" (match-string 1 url) "&"
7548 (match-string 2 url))
7549 (concat "to=" url)))
7551 subject (cdr-safe (assoc "subject" args)))
7554 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
7557 (message-position-on-field (caar args)))
7558 (insert (gnus-replace-in-string
7559 (mapconcat 'identity (reverse (cdar args)) ", ")
7561 (setq args (cdr args)))
7564 (message-goto-subject))))
7566 (defun gnus-button-embedded-url (address)
7567 "Activate ADDRESS with `browse-url'."
7568 (browse-url (gnus-strip-whitespace address)))
7570 ;;; Next/prev buttons in the article buffer.
7572 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
7573 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
7575 (defvar gnus-prev-page-map
7576 (let ((map (make-sparse-keymap)))
7577 (define-key map gnus-mouse-2 'gnus-button-prev-page)
7578 (define-key map "\r" 'gnus-button-prev-page)
7581 (defvar gnus-next-page-map
7582 (let ((map (make-sparse-keymap)))
7583 (unless (>= emacs-major-version 21)
7584 ;; XEmacs doesn't care.
7585 (set-keymap-parent map gnus-article-mode-map))
7586 (define-key map gnus-mouse-2 'gnus-button-next-page)
7587 (define-key map "\r" 'gnus-button-next-page)
7590 (defun gnus-insert-prev-page-button ()
7592 (inhibit-read-only t)
7593 (situation (get-text-property (point-min) 'mime-view-situation)))
7595 gnus-prev-page-line-format nil
7596 `(keymap ,gnus-prev-page-map
7598 gnus-callback gnus-article-button-prev-page
7599 article-type annotation
7600 mime-view-situation ,situation))
7601 (widget-convert-button
7603 ;; Exclude a newline.
7606 :action 'gnus-button-prev-page
7607 :button-keymap gnus-prev-page-map)))
7609 (defun gnus-button-next-page (&optional args more-args)
7610 "Go to the next page."
7612 (let ((win (selected-window)))
7613 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7614 (gnus-article-next-page)
7615 (select-window win)))
7617 (defun gnus-button-prev-page (&optional args more-args)
7618 "Go to the prev page."
7620 (let ((win (selected-window)))
7621 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7622 (gnus-article-prev-page)
7623 (select-window win)))
7625 (defun gnus-insert-next-page-button ()
7627 (inhibit-read-only t)
7628 (situation (get-text-property (point-min) 'mime-view-situation)))
7629 (gnus-eval-format gnus-next-page-line-format nil
7630 `(keymap ,gnus-next-page-map
7632 gnus-callback gnus-article-button-next-page
7633 article-type annotation
7634 mime-view-situation ,situation))
7635 (widget-convert-button
7637 ;; Exclude a newline.
7640 :action 'gnus-button-next-page
7641 :button-keymap gnus-next-page-map)))
7643 (defun gnus-article-button-next-page (arg)
7644 "Go to the next page."
7646 (let ((win (selected-window)))
7647 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7648 (gnus-article-next-page)
7649 (select-window win)))
7651 (defun gnus-article-button-prev-page (arg)
7652 "Go to the prev page."
7654 (let ((win (selected-window)))
7655 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7656 (gnus-article-prev-page)
7657 (select-window win)))
7659 (defvar gnus-decode-header-methods
7660 '(mail-decode-encoded-word-region)
7661 "List of methods used to decode headers.
7663 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
7664 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
7665 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
7666 whose names match REGEXP.
7669 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
7670 mail-decode-encoded-word-region
7671 (\"chinese\" . rfc1843-decode-region))
7674 (defvar gnus-decode-header-methods-cache nil)
7676 (defun gnus-multi-decode-header (start end)
7677 "Apply the functions from `gnus-encoded-word-methods' that match."
7678 (unless (and gnus-decode-header-methods-cache
7679 (eq gnus-newsgroup-name
7680 (car gnus-decode-header-methods-cache)))
7681 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
7684 (nconc gnus-decode-header-methods-cache (list x))
7685 (if (and gnus-newsgroup-name
7686 (string-match (car x) gnus-newsgroup-name))
7687 (nconc gnus-decode-header-methods-cache
7689 gnus-decode-header-methods))
7690 (let ((xlist gnus-decode-header-methods-cache))
7693 (narrow-to-region start end)
7695 (funcall (pop xlist) (point-min) (point-max))))))
7698 ;;; Treatment top-level handling.
7701 (defun gnus-treat-article (condition &optional part-number total-parts type)
7702 (let ((length (- (point-max) (point-min)))
7703 (alist gnus-treatment-function-alist)
7704 (article-goto-body-goes-to-point-min-p t)
7708 (let ((list gnus-article-treat-types))
7710 (when (string-match (pop list) type)
7711 (throw 'found t)))))))
7712 (highlightp (gnus-visual-p 'article-highlight 'highlight))
7713 (entity (static-unless (featurep 'xemacs)
7714 (when (eq 'head condition)
7715 (get-text-property (point-min) 'mime-view-entity))))
7716 val elem buttonized)
7717 (gnus-run-hooks 'gnus-part-display-hook)
7718 (unless gnus-inhibit-treatment
7719 (dolist (elem alist)
7722 (when (gnus-buffer-live-p gnus-summary-buffer)
7723 (set-buffer gnus-summary-buffer))
7724 (symbol-value (car elem))))
7725 (when (and (or (consp val)
7727 (gnus-treat-predicate val)
7728 (or (not (get (car elem) 'highlight))
7730 (when (and (not buttonized)
7732 '(gnus-treat-hide-signature
7733 gnus-treat-highlight-signature)))
7734 (gnus-article-buttonize-signature)
7735 (setq buttonized t))
7737 (funcall (cadr elem)))))
7738 ;; FSF Emacsen does not inherit the existing text properties
7739 ;; in the new text, so we should do it for `mime-view-entity'.
7740 (static-unless (featurep 'xemacs)
7742 (put-text-property (point-min) (point-max)
7743 'mime-view-entity entity))))))
7745 ;; Dynamic variables.
7747 (defvar part-number)
7748 (defvar total-parts)
7753 (defun gnus-treat-predicate (val)
7758 (stringp (car val)))
7759 (apply 'gnus-or (mapcar `(lambda (s)
7760 (string-match s ,(or gnus-newsgroup-name "")))
7763 (let ((pred (pop val)))
7766 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
7768 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
7770 (not (gnus-treat-predicate (car val))))
7772 (equal (car val) type))
7774 (error "%S is not a valid predicate" pred)))))
7786 (eq part-number total-parts))
7790 (error "%S is not a valid value" val))))
7792 (defun gnus-article-encrypt-body (protocol &optional n)
7793 "Encrypt the article body."
7796 (or gnus-article-encrypt-protocol
7797 (completing-read "Encrypt protocol: "
7798 gnus-article-encrypt-protocol-alist
7800 current-prefix-arg))
7801 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7803 (error "Can't find the encrypt protocol %s" protocol))
7804 (if (member gnus-newsgroup-name '("nndraft:delayed"
7807 (error "Can't encrypt the article in group %s"
7808 gnus-newsgroup-name))
7809 (gnus-summary-iterate n
7811 (set-buffer gnus-summary-buffer)
7812 (let ((mail-parse-charset gnus-newsgroup-charset)
7813 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7814 (summary-buffer gnus-summary-buffer)
7816 (gnus-set-global-variables)
7817 (when (gnus-group-read-only-p)
7818 (error "The current newsgroup does not support article encrypt"))
7819 (gnus-summary-show-article t)
7821 (or (mail-header-references gnus-current-headers) ""))
7822 (set-buffer gnus-article-buffer)
7823 (let* ((inhibit-read-only t)
7825 (mapcar (lambda (field)
7826 (and (save-restriction
7827 (message-narrow-to-head)
7828 (goto-char (point-min))
7829 (search-forward field nil t))
7831 (message-narrow-to-field)
7833 (delete-region (point-min) (point-max))
7835 '("Content-Type:" "Content-Transfer-Encoding:"
7836 "Content-Disposition:"))))
7837 (message-narrow-to-head)
7838 (message-remove-header "MIME-Version")
7839 (goto-char (point-max))
7840 (setq point (point))
7841 (insert (apply 'concat headers))
7843 (narrow-to-region point (point-max))
7844 (let ((message-options message-options))
7845 (message-options-set 'message-sender user-mail-address)
7846 (message-options-set 'message-recipients user-mail-address)
7847 (message-options-set 'message-sign-encrypt 'not)
7849 (goto-char (point-min))
7850 (insert "MIME-Version: 1.0\n")
7852 (gnus-summary-edit-article-done
7853 references nil summary-buffer t))
7854 (when gnus-keep-backlog
7855 (gnus-backlog-remove-article
7856 (car gnus-article-current) (cdr gnus-article-current)))
7858 (when (get-buffer gnus-original-article-buffer)
7859 (set-buffer gnus-original-article-buffer)
7860 (setq gnus-original-article nil)))
7861 (when gnus-use-cache
7862 (gnus-cache-update-article
7863 (car gnus-article-current) (cdr gnus-article-current))))))))
7865 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7866 "The following specs can be used:
7867 %t The security MIME type
7870 %D Details if button is pressed")
7872 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
7873 "The following specs can be used:
7874 %t The security MIME type
7877 %D Details if button is pressed")
7879 (defvar gnus-mime-security-button-line-format-alist
7880 '((?t gnus-tmp-type ?s)
7881 (?i gnus-tmp-info ?s)
7882 (?d gnus-tmp-details ?s)
7883 (?D gnus-tmp-pressed-details ?s)))
7885 (defvar gnus-mime-security-button-map
7886 (let ((map (make-sparse-keymap)))
7887 (define-key map gnus-mouse-2 'gnus-article-push-button)
7888 (define-key map "\r" 'gnus-article-press-button)
7891 (defvar gnus-mime-security-details-buffer nil)
7893 (defvar gnus-mime-security-button-pressed nil)
7895 (defvar gnus-mime-security-show-details-inline t
7896 "If non-nil, show details in the article buffer.")
7898 (defun gnus-mime-security-verify-or-decrypt (handle)
7899 (mm-remove-parts (cdr handle))
7900 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7901 point (inhibit-read-only t))
7903 (goto-char (car region)))
7905 (narrow-to-region (point) (point))
7906 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7907 (let* ((mm-verify-option 'known)
7908 (mm-decrypt-option 'known)
7909 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7910 (unless (eq nparts (cdr handle))
7911 (mm-destroy-parts (cdr handle))
7912 (setcdr handle nparts))))
7913 (setq point (point))
7914 (gnus-mime-display-security handle)
7915 (goto-char (point-max)))
7917 (delete-region (point) (cdr region))
7918 (set-marker (car region) nil)
7919 (set-marker (cdr region) nil))
7922 (defun gnus-mime-security-show-details (handle)
7923 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7925 (gnus-message 5 "No details.")
7926 (if gnus-mime-security-show-details-inline
7927 (let ((gnus-mime-security-button-pressed
7928 (not (get-text-property (point) 'gnus-mime-details)))
7929 (gnus-mime-security-button-line-format
7930 (get-text-property (point) 'gnus-line-format))
7931 (inhibit-read-only t))
7933 (while (eq (get-text-property (point) 'gnus-line-format)
7934 gnus-mime-security-button-line-format)
7938 (narrow-to-region (point) (point))
7939 (gnus-insert-mime-security-button handle))
7940 (delete-region (point)
7941 (or (text-property-not-all
7944 gnus-mime-security-button-line-format)
7947 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7948 (with-current-buffer gnus-mime-security-details-buffer
7951 (setq gnus-mime-security-details-buffer
7952 (gnus-get-buffer-create "*MIME Security Details*")))
7953 (with-current-buffer gnus-mime-security-details-buffer
7955 (goto-char (point-min)))
7956 (pop-to-buffer gnus-mime-security-details-buffer)))))
7958 (defun gnus-mime-security-press-button (handle)
7960 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7961 (gnus-mime-security-show-details handle)
7962 (gnus-mime-security-verify-or-decrypt handle))))
7964 (defun gnus-insert-mime-security-button (handle &optional displayed)
7965 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7968 (or (nth 2 (assoc protocol mm-verify-function-alist))
7969 (nth 2 (assoc protocol mm-decrypt-function-alist))
7971 (if (equal (car handle) "multipart/signed")
7972 " Signed" " Encrypted")
7975 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7978 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7979 gnus-tmp-pressed-details
7981 (setq gnus-tmp-details
7982 (if gnus-tmp-details
7983 (concat "\n" gnus-tmp-details)
7985 (setq gnus-tmp-pressed-details
7986 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7991 gnus-mime-security-button-line-format
7992 gnus-mime-security-button-line-format-alist
7993 `(keymap ,gnus-mime-security-button-map
7994 gnus-callback gnus-mime-security-press-button
7995 gnus-line-format ,gnus-mime-security-button-line-format
7996 gnus-mime-details ,gnus-mime-security-button-pressed
7997 article-type annotation
8000 ;; Exclude a newline.
8003 (widget-convert-button
8006 :action 'gnus-widget-press-button
8007 :button-keymap gnus-mime-security-button-map
8009 (lambda (widget/window &optional overlay pos)
8010 ;; Needed to properly clear the message due to a bug in
8011 ;; wid-edit (XEmacs only).
8012 (when (boundp 'help-echo-owns-message)
8013 (setq help-echo-owns-message t))
8016 (aref gnus-mouse-2 0))))))
8018 (defun gnus-mime-display-security (handle)
8020 (narrow-to-region (point) (point))
8021 (unless (gnus-unbuttonized-mime-type-p (car handle))
8022 (gnus-insert-mime-security-button handle))
8023 (gnus-mime-display-part (cadr handle))
8026 (unless (gnus-unbuttonized-mime-type-p (car handle))
8027 (let ((gnus-mime-security-button-line-format
8028 gnus-mime-security-button-end-line-format))
8029 (gnus-insert-mime-security-button handle)))
8030 (mm-set-handle-multipart-parameter
8032 (cons (set-marker (make-marker) (point-min))
8033 (set-marker (make-marker) (point-max))))))
8039 (defun gnus-article-header-presentation-method (entity situation)
8040 (mime-insert-header entity)
8041 (article-decode-group-name))
8043 (set-alist 'mime-header-presentation-method-alist
8044 'gnus-original-article-mode
8045 #'gnus-article-header-presentation-method)
8047 (defun gnus-mime-preview-quitting-method ()
8048 (mime-preview-kill-buffer)
8049 (delete-other-windows)
8050 (gnus-article-show-summary)
8051 (gnus-summary-select-article gnus-show-all-headers t))
8053 (set-alist 'mime-preview-quitting-method-alist
8054 'gnus-original-article-mode #'gnus-mime-preview-quitting-method)
8056 (set-alist 'mime-preview-following-method-alist
8057 'gnus-original-article-mode #'gnus-following-method)
8059 (set-alist 'mime-preview-over-to-previous-method-alist
8060 'gnus-original-article-mode
8062 (if (> (point-min) 1)
8063 (gnus-article-prev-page)
8064 (gnus-article-read-summary-keys
8065 nil (gnus-character-to-event ?P)))))
8067 (set-alist 'mime-preview-over-to-next-method-alist
8068 'gnus-original-article-mode'
8070 (if (< (point-max) (buffer-size))
8071 (gnus-article-next-page)
8072 (gnus-article-read-summary-keys
8073 nil (gnus-character-to-event ?N)))))
8083 (run-hooks 'gnus-art-load-hook)
8085 ;;; gnus-art.el ends here