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 '(repeat string)
247 :group 'gnus-article-signature)
249 (defcustom gnus-signature-limit nil
250 "Provide a limit to what is considered a signature.
251 If it is a number, no signature may not be longer (in characters) than
252 that number. If it is a floating point number, no signature may be
253 longer (in lines) than that number. If it is a function, the function
254 will be called without any parameters, and if it returns nil, there is
255 no signature in the buffer. If it is a string, it will be used as a
256 regexp. If it matches, the text in question is not a signature.
258 This can also be a list of the above values."
259 :type '(choice (const nil)
262 (function :value fun)
263 (regexp :value ".*"))
264 :group 'gnus-article-signature)
266 (defcustom gnus-hidden-properties '(invisible t intangible t)
267 "Property list to use for hiding text."
269 :group 'gnus-article-hiding)
271 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
272 ;; frames in a session.
273 (defcustom gnus-article-x-face-command
278 (if (or (gnus-image-type-available-p 'xface)
279 (gnus-image-type-available-p 'pbm))
280 'gnus-display-x-face-in-from
281 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -"))
282 ((gnus-image-type-available-p 'pbm)
283 'gnus-display-x-face-in-from)
285 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
287 "*String or function to be executed to display an X-Face header.
288 If it is a string, the command will be executed in a sub-shell
289 asynchronously. The compressed face will be piped to this command."
291 :format "%{%t%}:\n%[Value Menu%] %v"
295 (if (or (gnus-image-type-available-p 'xface)
296 (gnus-image-type-available-p 'pbm))
297 '(function-item gnus-display-x-face-in-from))
301 :group 'gnus-article-washing)
303 (defcustom gnus-article-x-face-too-ugly nil
304 "Regexp matching posters whose face shouldn't be shown automatically."
305 :type '(choice regexp (const nil))
306 :group 'gnus-article-washing)
308 (defcustom gnus-article-banner-alist nil
309 "Banner alist for stripping.
311 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
313 :type '(repeat (cons symbol regexp))
314 :group 'gnus-article-washing)
316 (gnus-define-group-parameter
319 "Alist of regexps (to match group names) and banner."
320 :variable-group gnus-article-washing
322 '(choice :tag "Banner"
324 (const :tag "Remove signature" signature)
325 (symbol :tag "Item in `gnus-article-banner-alist'" none)
327 (const :tag "None" nil))
329 "If non-nil, specify how to remove `banners' from articles.
331 Symbol `signature' means to remove signatures delimited by
332 `gnus-signature-separator'. Any other symbol is used to look up a
333 regular expression to match the banner in `gnus-article-banner-alist'.
334 A string is used as a regular expression to match the banner
337 (defcustom gnus-article-address-banner-alist nil
338 "Alist of mail addresses and banners.
339 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
340 to match a mail address in the From: header, BANNER is one of a symbol
341 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
342 If ADDRESS matches author's mail address, it will remove things like
343 advertisements. For example:
345 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
349 (regexp :tag "Address")
350 (choice :tag "Banner" :value nil
351 (const :tag "Remove signature" signature)
352 (symbol :tag "Item in `gnus-article-banner-alist'" none)
354 (const :tag "None" nil))))
356 :group 'gnus-article-washing)
358 (defmacro gnus-emphasis-custom-with-format (&rest body)
360 \\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\
361 \\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)"))
364 (defun gnus-emphasis-custom-value-to-external (value)
365 (gnus-emphasis-custom-with-format
366 (if (consp (car value))
367 (list (format format (car (car value)) (cdr (car value)))
369 (if (nth 1 value) 2 3)
373 (defun gnus-emphasis-custom-value-to-internal (value)
374 (gnus-emphasis-custom-with-format
375 (let ((regexp (concat "\\`"
376 (format (regexp-quote format)
377 "\\([^()]+\\)" "\\([^()]+\\)")
380 (if (string-match regexp (setq pattern (car value)))
381 (list (cons (match-string 1 pattern) (match-string 2 pattern))
386 (defcustom gnus-emphasis-alist
388 '(("\\*" "\\*" bold nil 2)
391 ("_/" "/_" underline-italic)
392 ("_\\*" "\\*_" underline-bold)
393 ("\\*/" "/\\*" bold-italic)
394 ("_\\*/" "/\\*_" underline-bold-italic))))
396 (gnus-emphasis-custom-with-format
397 (mapcar (lambda (spec)
398 (list (format format (car spec) (cadr spec))
401 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
403 '(;; I've never seen anyone use this strikethru convention whereas I've
404 ;; several times seen it triggered by normal text. --Stef
405 ;; Miles suggests that this form is sometimes used but for italics,
406 ;; so maybe we should map it to `italic'.
407 ;; ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
408 ;; 2 3 gnus-emphasis-strikethru)
409 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
410 2 3 gnus-emphasis-underline))))
411 "*Alist that says how to fontify certain phrases.
412 Each item looks like this:
414 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
416 The first element is a regular expression to be matched. The second
417 is a number that says what regular expression grouping used to find
418 the entire emphasized word. The third is a number that says what
419 regexp grouping should be displayed and highlighted. The fourth
420 is the face used for highlighting."
424 :format "%[Customizing Style%]\n%v"
426 (group :tag "Default"
427 :value ("" 0 0 default)
430 (let ((value (widget-get
431 (cadr (widget-get (widget-get widget :parent)
434 (if (not (eq (nth 2 value) 'default))
438 (gnus-emphasis-custom-value-to-external value))))
439 (widget-group-value-create widget))
441 (integer :format "Match group: %v")
442 (integer :format "Emphasize group: %v")
445 :value (("_" . "_") nil default)
447 (regexp :format "Start regexp: %v")
448 (regexp :format "End regexp: %v"))
449 (boolean :format "Show start and end patterns: %[%v%]\n"
450 :on " On " :off " Off ")
452 :get (lambda (symbol)
453 (mapcar 'gnus-emphasis-custom-value-to-internal
454 (default-value symbol)))
455 :set (lambda (symbol value)
456 (set-default symbol (mapcar 'gnus-emphasis-custom-value-to-external
458 :group 'gnus-article-emphasis)
460 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
461 "A regexp to describe whitespace which should not be emphasized.
462 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
463 The former avoids underlining of leading and trailing whitespace,
464 and the latter avoids underlining any whitespace at all."
466 :group 'gnus-article-emphasis
469 (defface gnus-emphasis-bold '((t (:bold t)))
470 "Face used for displaying strong emphasized text (*word*)."
471 :group 'gnus-article-emphasis)
473 (defface gnus-emphasis-italic '((t (:italic t)))
474 "Face used for displaying italic emphasized text (/word/)."
475 :group 'gnus-article-emphasis)
477 (defface gnus-emphasis-underline '((t (:underline t)))
478 "Face used for displaying underlined emphasized text (_word_)."
479 :group 'gnus-article-emphasis)
481 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
482 "Face used for displaying underlined bold emphasized text (_*word*_)."
483 :group 'gnus-article-emphasis)
485 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
486 "Face used for displaying underlined italic emphasized text (_/word/_)."
487 :group 'gnus-article-emphasis)
489 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
490 "Face used for displaying bold italic emphasized text (/*word*/)."
491 :group 'gnus-article-emphasis)
493 (defface gnus-emphasis-underline-bold-italic
494 '((t (:bold t :italic t :underline t)))
495 "Face used for displaying underlined bold italic emphasized text.
496 Example: (_/*word*/_)."
497 :group 'gnus-article-emphasis)
499 (defface gnus-emphasis-strikethru (if (featurep 'xemacs)
500 '((t (:strikethru t)))
501 '((t (:strike-through t))))
502 "Face used for displaying strike-through text (-word-)."
503 :group 'gnus-article-emphasis)
505 (defface gnus-emphasis-highlight-words
506 '((t (:background "black" :foreground "yellow")))
507 "Face used for displaying highlighted words."
508 :group 'gnus-article-emphasis)
510 (defcustom gnus-article-time-format "%a, %d %b %Y %T %Z"
511 "Format for display of Date headers in article bodies.
512 See `format-time-string' for the possible values.
514 The variable can also be function, which should return a complete Date
515 header. The function is called with one argument, the time, which can
516 be fed to `format-time-string'."
517 :type '(choice string function)
518 :link '(custom-manual "(gnus)Article Date")
519 :group 'gnus-article-washing)
521 (defcustom gnus-save-all-headers t
522 "*If non-nil, don't remove any headers before saving."
523 :group 'gnus-article-saving
526 (defcustom gnus-prompt-before-saving 'always
527 "*This variable says how much prompting is to be done when saving articles.
528 If it is nil, no prompting will be done, and the articles will be
529 saved to the default files. If this variable is `always', each and
530 every article that is saved will be preceded by a prompt, even when
531 saving large batches of articles. If this variable is neither nil not
532 `always', there the user will be prompted once for a file name for
533 each invocation of the saving commands."
534 :group 'gnus-article-saving
535 :type '(choice (item always)
536 (item :tag "never" nil)
537 (sexp :tag "once" :format "%t\n" :value t)))
539 (defcustom gnus-saved-headers gnus-visible-headers
540 "Headers to keep if `gnus-save-all-headers' is nil.
541 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
542 If that variable is nil, however, all headers that match this regexp
543 will be kept while the rest will be deleted before saving."
544 :group 'gnus-article-saving
547 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
548 "A function to save articles in your favourite format.
549 The function must be interactively callable (in other words, it must
550 be an Emacs command).
552 Gnus provides the following functions:
554 * gnus-summary-save-in-rmail (Rmail format)
555 * gnus-summary-save-in-mail (Unix mail format)
556 * gnus-summary-save-in-folder (MH folder)
557 * gnus-summary-save-in-file (article format)
558 * gnus-summary-save-body-in-file (article body)
559 * gnus-summary-save-in-vm (use VM's folder format)
560 * gnus-summary-write-to-file (article format -- overwrite)."
561 :group 'gnus-article-saving
562 :type '(radio (function-item gnus-summary-save-in-rmail)
563 (function-item gnus-summary-save-in-mail)
564 (function-item gnus-summary-save-in-folder)
565 (function-item gnus-summary-save-in-file)
566 (function-item gnus-summary-save-body-in-file)
567 (function-item gnus-summary-save-in-vm)
568 (function-item gnus-summary-write-to-file)))
570 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
571 "A function generating a file name to save articles in Rmail format.
572 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
573 :group 'gnus-article-saving
576 (defcustom gnus-mail-save-name 'gnus-plain-save-name
577 "A function generating a file name to save articles in Unix mail format.
578 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
579 :group 'gnus-article-saving
582 (defcustom gnus-folder-save-name 'gnus-folder-save-name
583 "A function generating a file name to save articles in MH folder.
584 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
585 :group 'gnus-article-saving
588 (defcustom gnus-file-save-name 'gnus-numeric-save-name
589 "A function generating a file name to save articles in article format.
590 The function is called with NEWSGROUP, HEADERS, and optional
592 :group 'gnus-article-saving
595 (defcustom gnus-split-methods
596 '((gnus-article-archive-name)
597 (gnus-article-nndoc-name))
598 "*Variable used to suggest where articles are to be saved.
599 For instance, if you would like to save articles related to Gnus in
600 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
601 you could set this variable to something like:
603 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
604 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
606 This variable is an alist where the key is the match and the
607 value is a list of possible files to save in if the match is
610 If the match is a string, it is used as a regexp match on the
611 article. If the match is a symbol, that symbol will be funcalled
612 from the buffer of the article to be saved with the newsgroup as
613 the parameter. If it is a list, it will be evaled in the same
616 If this form or function returns a string, this string will be
617 used as a possible file name; and if it returns a non-nil list,
618 that list will be used as possible file names."
619 :group 'gnus-article-saving
620 :type '(repeat (choice (list :value (fun) function)
621 (cons :value ("" "") regexp (repeat string))
624 (defcustom gnus-article-display-method-for-mime
625 'gnus-article-display-mime-message
626 "Function to display a MIME message.
627 The function is called from the article buffer."
628 :group 'gnus-article-mime
631 (defcustom gnus-article-display-method-for-traditional
632 'gnus-article-display-traditional-message
633 "*Function to display a traditional message.
634 The function is called from the article buffer."
635 :group 'gnus-article-mime
638 (defcustom gnus-page-delimiter "^\^L"
639 "*Regexp describing what to use as article page delimiters.
640 The default value is \"^\^L\", which is a form linefeed at the
641 beginning of a line."
643 :group 'gnus-article-various)
645 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
646 "*The format specification for the article mode line.
647 See `gnus-summary-mode-line-format' for a closer description.
649 The following additional specs are available:
651 %w The article washing status.
652 %m The number of MIME parts in the article."
654 :group 'gnus-article-various)
656 (defcustom gnus-article-mode-hook nil
657 "*A hook for Gnus article mode."
659 :group 'gnus-article-various)
661 (when (featurep 'xemacs)
662 ;; Extracted from gnus-xmas-define in order to preserve user settings
663 (when (fboundp 'turn-off-scroll-in-place)
664 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
665 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
666 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
668 (defcustom gnus-article-menu-hook nil
669 "*Hook run after the creation of the article mode menu."
671 :group 'gnus-article-various)
673 (defcustom gnus-article-prepare-hook nil
674 "*A hook called after an article has been prepared in the article buffer."
676 :group 'gnus-article-various)
678 (defcustom gnus-copy-article-ignored-headers nil
679 "List of headers to be removed when copying an article.
680 Each element is a regular expression."
681 :version "23.0" ;; No Gnus
682 :type '(repeat regexp)
683 :group 'gnus-article-various)
685 (make-obsolete-variable 'gnus-article-hide-pgp-hook
686 "This variable is obsolete in Gnus 5.10.")
688 (defcustom gnus-article-button-face 'bold
689 "Face used for highlighting buttons in the article buffer.
691 An article button is a piece of text that you can activate by pressing
692 `RET' or `mouse-2' above it."
694 :group 'gnus-article-buttons)
696 (defcustom gnus-article-mouse-face 'highlight
697 "Face used for mouse highlighting in the article buffer.
699 Article buttons will be displayed in this face when the cursor is
702 :group 'gnus-article-buttons)
704 (defcustom gnus-signature-face 'gnus-signature
705 "Face used for highlighting a signature in the article buffer.
706 Obsolete; use the face `gnus-signature' for customizations instead."
708 :group 'gnus-article-highlight
709 :group 'gnus-article-signature)
711 (defface gnus-signature
714 "Face used for highlighting a signature in the article buffer."
715 :group 'gnus-article-highlight
716 :group 'gnus-article-signature)
717 ;; backward-compatibility alias
718 (put 'gnus-signature-face 'face-alias 'gnus-signature)
720 (defface gnus-header-from
723 (:foreground "spring green"))
726 (:foreground "red3"))
729 "Face used for displaying from headers."
730 :group 'gnus-article-headers
731 :group 'gnus-article-highlight)
732 ;; backward-compatibility alias
733 (put 'gnus-header-from-face 'face-alias 'gnus-header-from)
735 (defface gnus-header-subject
738 (:foreground "SeaGreen3"))
741 (:foreground "red4"))
743 (:bold t :italic t)))
744 "Face used for displaying subject headers."
745 :group 'gnus-article-headers
746 :group 'gnus-article-highlight)
747 ;; backward-compatibility alias
748 (put 'gnus-header-subject-face 'face-alias 'gnus-header-subject)
750 (defface gnus-header-newsgroups
753 (:foreground "yellow" :italic t))
756 (:foreground "MidnightBlue" :italic t))
759 "Face used for displaying newsgroups headers.
760 In the default setup this face is only used for crossposted
762 :group 'gnus-article-headers
763 :group 'gnus-article-highlight)
764 ;; backward-compatibility alias
765 (put 'gnus-header-newsgroups-face 'face-alias 'gnus-header-newsgroups)
767 (defface gnus-header-name
770 (:foreground "SeaGreen"))
773 (:foreground "maroon"))
776 "Face used for displaying header names."
777 :group 'gnus-article-headers
778 :group 'gnus-article-highlight)
779 ;; backward-compatibility alias
780 (put 'gnus-header-name-face 'face-alias 'gnus-header-name)
782 (defface gnus-header-content
785 (:foreground "forest green" :italic t))
788 (:foreground "indianred4" :italic t))
791 "Face used for displaying header content."
792 :group 'gnus-article-headers
793 :group 'gnus-article-highlight)
794 ;; backward-compatibility alias
795 (put 'gnus-header-content-face 'face-alias 'gnus-header-content)
797 (defcustom gnus-header-face-alist
798 '(("From" nil gnus-header-from)
799 ("Subject" nil gnus-header-subject)
800 ("Newsgroups:.*," nil gnus-header-newsgroups)
801 ("" gnus-header-name gnus-header-content))
802 "*Controls highlighting of article headers.
804 An alist of the form (HEADER NAME CONTENT).
806 HEADER is a regular expression which should match the name of a
807 header and NAME and CONTENT are either face names or nil.
809 The name of each header field will be displayed using the face
810 specified by the first element in the list where HEADER matches
811 the header name and NAME is non-nil. Similarly, the content will
812 be displayed by the first non-nil matching CONTENT face."
813 :group 'gnus-article-headers
814 :group 'gnus-article-highlight
815 :type '(repeat (list (regexp :tag "Header")
817 (item :tag "skip" nil)
818 (face :value default))
819 (choice :tag "Content"
820 (item :tag "skip" nil)
821 (face :value default)))))
823 (defcustom gnus-article-decode-hook
824 '(article-decode-group-name article-decode-idna-rhs)
825 "*Hook run to decode charsets in articles."
826 :group 'gnus-article-headers
829 (defcustom gnus-display-mime-function 'gnus-display-mime
830 "Function to display MIME articles."
831 :group 'gnus-article-mime
834 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
835 "Function used to decode headers.")
837 (defvar gnus-article-dumbquotes-map
857 "Table for MS-to-Latin1 translation.")
859 (defcustom gnus-ignored-mime-types nil
860 "List of MIME types that should be ignored by Gnus."
862 :group 'gnus-article-mime
863 :type '(repeat regexp))
865 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
866 "List of MIME types that should not be given buttons when rendered inline.
867 See also `gnus-buttonized-mime-types' which may override this variable.
868 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
870 :group 'gnus-article-mime
871 :type '(repeat regexp))
873 (defcustom gnus-buttonized-mime-types nil
874 "List of MIME types that should be given buttons when rendered inline.
875 If set, this variable overrides `gnus-unbuttonized-mime-types'.
876 To see e.g. security buttons you could set this to
877 `(\"multipart/signed\")'. You could also add \"multipart/alternative\" to
878 this list to display radio buttons that allow you to choose one of two
879 media types those mails include. See also `mm-discouraged-alternatives'.
880 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
882 :group 'gnus-article-mime
883 :type '(repeat regexp))
885 (defcustom gnus-inhibit-mime-unbuttonizing nil
886 "If non-nil, all MIME parts get buttons.
887 When nil (the default value), then some MIME parts do not get buttons,
888 as described by the variables `gnus-buttonized-mime-types' and
889 `gnus-unbuttonized-mime-types'."
891 :group 'gnus-article-mime
894 (defcustom gnus-body-boundary-delimiter "_"
895 "String used to delimit header and body.
896 This variable is used by `gnus-article-treat-body-boundary' which can
897 be controlled by `gnus-treat-body-boundary'."
899 :group 'gnus-article-various
900 :type '(choice (item :tag "None" :value nil)
903 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces"
905 "Defines the location of the faces database.
906 For information on obtaining this database of pretty pictures, please
907 see http://www.cs.indiana.edu/picons/ftp/index.html"
909 :type '(repeat directory)
910 :link '(url-link :tag "download"
911 "http://www.cs.indiana.edu/picons/ftp/index.html")
912 :link '(custom-manual "(gnus)Picons")
915 (defun gnus-picons-installed-p ()
916 "Say whether picons are installed on your machine."
917 (let ((installed nil))
918 (dolist (database gnus-picon-databases)
919 (when (file-exists-p database)
923 (defcustom gnus-article-mime-part-function nil
924 "Function called with a MIME handle as the argument.
925 This is meant for people who want to do something automatic based
926 on parts -- for instance, adding Vcard info to a database."
927 :group 'gnus-article-mime
928 :type '(choice (const nil)
931 (defcustom gnus-mime-multipart-functions nil
932 "An alist of MIME types to functions to display them."
934 :group 'gnus-article-mime
935 :type '(repeat (cons :format "%v" (string :tag "MIME type") function)))
937 (defcustom gnus-article-date-lapsed-new-header nil
938 "Whether the X-Sent and Date headers can coexist.
939 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
940 either replace the old \"Date:\" header (if this variable is nil), or
941 be added below it (otherwise)."
943 :group 'gnus-article-headers
946 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
947 "Function called with a MIME handle as the argument.
948 This is meant for people who want to view first matched part.
949 For `undisplayed-alternative' (default), the first undisplayed
950 part or alternative part is used. For `undisplayed', the first
951 undisplayed part is used. For a function, the first part which
952 the function return t is used. For nil, the first part is
955 :group 'gnus-article-mime
957 (item :tag "first" :value nil)
958 (item :tag "undisplayed" :value undisplayed)
959 (item :tag "undisplayed or alternative"
960 :value undisplayed-alternative)
963 (defcustom gnus-mime-action-alist
964 '(("save to file" . gnus-mime-save-part)
965 ("save and strip" . gnus-mime-save-part-and-strip)
966 ("replace with file" . gnus-mime-replace-part)
967 ("delete part" . gnus-mime-delete-part)
968 ("display as text" . gnus-mime-inline-part)
969 ("view the part" . gnus-mime-view-part)
970 ("pipe to command" . gnus-mime-pipe-part)
971 ("toggle display" . gnus-article-press-button)
972 ("toggle display" . gnus-article-view-part-as-charset)
973 ("view as type" . gnus-mime-view-part-as-type)
974 ("view internally" . gnus-mime-view-part-internally)
975 ("view externally" . gnus-mime-view-part-externally))
976 "An alist of actions that run on the MIME attachment."
977 :group 'gnus-article-mime
978 :type '(repeat (cons (string :tag "name")
981 (defcustom gnus-auto-select-part 1
982 "Advance to next MIME part when deleting or stripping parts.
984 When 0, point will be placed on the same part as before. When
985 positive (negative), move point forward (backwards) this many
986 parts. When nil, redisplay article."
987 :version "23.0" ;; No Gnus
988 :group 'gnus-article-mime
989 :type '(choice (const nil :tag "Redisplay article.")
990 (const 1 :tag "Next part.")
991 (const 0 :tag "Current part.")
995 ;;; The treatment variables
998 (defvar gnus-part-display-hook nil
999 "Hook called on parts that are to receive treatment.")
1001 (defvar gnus-article-treat-custom
1002 '(choice (const :tag "Off" nil)
1004 (const :tag "Header" head)
1005 (const :tag "First" first)
1006 (const :tag "Last" last)
1007 (const :tag "Mime" mime)
1008 (integer :tag "Less")
1009 (repeat :tag "Groups" regexp)
1010 (sexp :tag "Predicate")))
1012 (defvar gnus-article-treat-head-custom
1013 '(choice (const :tag "Off" nil)
1014 (const :tag "Header" head)))
1016 (defvar gnus-article-treat-types '("text/plain")
1019 (defvar gnus-inhibit-treatment nil
1020 "Whether to inhibit treatment.")
1022 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
1023 "Highlight the signature.
1024 Valid values are nil, t, `head', `first', `last', an integer or a
1025 predicate. See Info node `(gnus)Customizing Articles'."
1026 :group 'gnus-article-treat
1027 :link '(custom-manual "(gnus)Customizing Articles")
1028 :type gnus-article-treat-custom)
1029 (put 'gnus-treat-highlight-signature 'highlight t)
1031 (defcustom gnus-treat-buttonize 100000
1033 Valid values are nil, t, `head', `first', `last', an integer or a
1034 predicate. See Info node `(gnus)Customizing Articles'."
1035 :group 'gnus-article-treat
1036 :link '(custom-manual "(gnus)Customizing Articles")
1037 :type gnus-article-treat-custom)
1038 (put 'gnus-treat-buttonize 'highlight t)
1040 (defcustom gnus-treat-buttonize-head 'head
1041 "Add buttons to the head.
1042 Valid values are nil, t, `head', `first', `last', an integer or a
1043 predicate. See Info node `(gnus)Customizing Articles'."
1044 :group 'gnus-article-treat
1045 :link '(custom-manual "(gnus)Customizing Articles")
1046 :type gnus-article-treat-head-custom)
1047 (put 'gnus-treat-buttonize-head 'highlight t)
1049 (defcustom gnus-treat-emphasize
1050 (and (or window-system
1054 Valid values are nil, t, `head', `first', `last', an integer or a
1055 predicate. See Info node `(gnus)Customizing Articles'."
1056 :group 'gnus-article-treat
1057 :link '(custom-manual "(gnus)Customizing Articles")
1058 :type gnus-article-treat-custom)
1059 (put 'gnus-treat-emphasize 'highlight t)
1061 (defcustom gnus-treat-strip-cr nil
1062 "Remove carriage returns.
1063 Valid values are nil, t, `head', `first', `last', an integer or a
1064 predicate. See Info node `(gnus)Customizing Articles'."
1066 :group 'gnus-article-treat
1067 :link '(custom-manual "(gnus)Customizing Articles")
1068 :type gnus-article-treat-custom)
1070 (defcustom gnus-treat-unsplit-urls nil
1071 "Remove newlines from within URLs.
1072 Valid values are nil, t, `head', `first', `last', an integer or a
1073 predicate. See Info node `(gnus)Customizing Articles'."
1075 :group 'gnus-article-treat
1076 :link '(custom-manual "(gnus)Customizing Articles")
1077 :type gnus-article-treat-custom)
1079 (defcustom gnus-treat-leading-whitespace nil
1080 "Remove leading whitespace in headers.
1081 Valid values are nil, t, `head', `first', `last', an integer or a
1082 predicate. See Info node `(gnus)Customizing Articles'."
1084 :group 'gnus-article-treat
1085 :link '(custom-manual "(gnus)Customizing Articles")
1086 :type gnus-article-treat-custom)
1088 (defcustom gnus-treat-hide-headers 'head
1090 Valid values are nil, t, `head', `first', `last', an integer or a
1091 predicate. See Info node `(gnus)Customizing Articles'."
1092 :group 'gnus-article-treat
1093 :link '(custom-manual "(gnus)Customizing Articles")
1094 :type gnus-article-treat-head-custom)
1096 (defcustom gnus-treat-hide-boring-headers nil
1097 "Hide boring headers.
1098 Valid values are nil, t, `head', `first', `last', an integer or a
1099 predicate. See Info node `(gnus)Customizing Articles'."
1100 :group 'gnus-article-treat
1101 :link '(custom-manual "(gnus)Customizing Articles")
1102 :type gnus-article-treat-head-custom)
1104 (defcustom gnus-treat-hide-signature nil
1105 "Hide the signature.
1106 Valid values are nil, t, `head', `first', `last', an integer or a
1107 predicate. See Info node `(gnus)Customizing Articles'."
1108 :group 'gnus-article-treat
1109 :link '(custom-manual "(gnus)Customizing Articles")
1110 :type gnus-article-treat-custom)
1112 (defcustom gnus-treat-fill-article nil
1114 Valid values are nil, t, `head', `first', `last', an integer or a
1115 predicate. See Info node `(gnus)Customizing Articles'."
1116 :group 'gnus-article-treat
1117 :link '(custom-manual "(gnus)Customizing Articles")
1118 :type gnus-article-treat-custom)
1120 (defcustom gnus-treat-hide-citation nil
1122 Valid values are nil, t, `head', `first', `last', an integer or a
1123 predicate. See Info node `(gnus)Customizing Articles'."
1124 :group 'gnus-article-treat
1125 :link '(custom-manual "(gnus)Customizing Articles")
1126 :type gnus-article-treat-custom)
1128 (defcustom gnus-treat-hide-citation-maybe nil
1130 Valid values are nil, t, `head', `first', `last', an integer or a
1131 predicate. See Info node `(gnus)Customizing Articles'."
1132 :group 'gnus-article-treat
1133 :link '(custom-manual "(gnus)Customizing Articles")
1134 :type gnus-article-treat-custom)
1136 (defcustom gnus-treat-strip-list-identifiers 'head
1137 "Strip list identifiers from `gnus-list-identifiers`.
1138 Valid values are nil, t, `head', `first', `last', an integer or a
1139 predicate. See Info node `(gnus)Customizing Articles'."
1141 :group 'gnus-article-treat
1142 :link '(custom-manual "(gnus)Customizing Articles")
1143 :type gnus-article-treat-custom)
1145 (make-obsolete-variable 'gnus-treat-strip-pgp
1146 "This option is obsolete in Gnus 5.10.")
1148 (defcustom gnus-treat-strip-pem nil
1149 "Strip PEM signatures.
1150 Valid values are nil, t, `head', `first', `last', an integer or a
1151 predicate. See Info node `(gnus)Customizing Articles'."
1152 :group 'gnus-article-treat
1153 :link '(custom-manual "(gnus)Customizing Articles")
1154 :type gnus-article-treat-custom)
1156 (defcustom gnus-treat-strip-banner t
1157 "Strip banners from articles.
1158 The banner to be stripped is specified in the `banner' group parameter.
1159 Valid values are nil, t, `head', `first', `last', an integer or a
1160 predicate. See Info node `(gnus)Customizing Articles'."
1161 :group 'gnus-article-treat
1162 :link '(custom-manual "(gnus)Customizing Articles")
1163 :type gnus-article-treat-custom)
1165 (defcustom gnus-treat-highlight-headers 'head
1166 "Highlight the headers.
1167 Valid values are nil, t, `head', `first', `last', an integer or a
1168 predicate. See Info node `(gnus)Customizing Articles'."
1169 :group 'gnus-article-treat
1170 :link '(custom-manual "(gnus)Customizing Articles")
1171 :type gnus-article-treat-head-custom)
1172 (put 'gnus-treat-highlight-headers 'highlight t)
1174 (defcustom gnus-treat-highlight-citation t
1175 "Highlight cited text.
1176 Valid values are nil, t, `head', `first', `last', an integer or a
1177 predicate. See Info node `(gnus)Customizing Articles'."
1178 :group 'gnus-article-treat
1179 :link '(custom-manual "(gnus)Customizing Articles")
1180 :type gnus-article-treat-custom)
1181 (put 'gnus-treat-highlight-citation 'highlight t)
1183 (defcustom gnus-treat-date-ut nil
1184 "Display the Date in UT (GMT).
1185 Valid values are nil, t, `head', `first', `last', an integer or a
1186 predicate. See Info node `(gnus)Customizing Articles'."
1187 :group 'gnus-article-treat
1188 :link '(custom-manual "(gnus)Customizing Articles")
1189 :type gnus-article-treat-head-custom)
1191 (defcustom gnus-treat-date-local nil
1192 "Display the Date in the local timezone.
1193 Valid values are nil, t, `head', `first', `last', an integer or a
1194 predicate. See Info node `(gnus)Customizing Articles'."
1195 :group 'gnus-article-treat
1196 :link '(custom-manual "(gnus)Customizing Articles")
1197 :type gnus-article-treat-head-custom)
1199 (defcustom gnus-treat-date-english nil
1200 "Display the Date in a format that can be read aloud in English.
1201 Valid values are nil, t, `head', `first', `last', an integer or a
1202 predicate. See Info node `(gnus)Customizing Articles'."
1204 :group 'gnus-article-treat
1205 :link '(custom-manual "(gnus)Customizing Articles")
1206 :type gnus-article-treat-head-custom)
1208 (defcustom gnus-treat-date-lapsed nil
1209 "Display the Date header in a way that says how much time has elapsed.
1210 Valid values are nil, t, `head', `first', `last', an integer or a
1211 predicate. See Info node `(gnus)Customizing Articles'."
1212 :group 'gnus-article-treat
1213 :link '(custom-manual "(gnus)Customizing Articles")
1214 :type gnus-article-treat-head-custom)
1216 (defcustom gnus-treat-date-original nil
1217 "Display the date in the original timezone.
1218 Valid values are nil, t, `head', `first', `last', an integer or a
1219 predicate. See Info node `(gnus)Customizing Articles'."
1220 :group 'gnus-article-treat
1221 :link '(custom-manual "(gnus)Customizing Articles")
1222 :type gnus-article-treat-head-custom)
1224 (defcustom gnus-treat-date-iso8601 nil
1225 "Display the date in the ISO8601 format.
1226 Valid values are nil, t, `head', `first', `last', an integer or a
1227 predicate. See Info node `(gnus)Customizing Articles'."
1229 :group 'gnus-article-treat
1230 :link '(custom-manual "(gnus)Customizing Articles")
1231 :type gnus-article-treat-head-custom)
1233 (defcustom gnus-treat-date-user-defined nil
1234 "Display the date in a user-defined format.
1235 The format is defined by the `gnus-article-time-format' variable.
1236 Valid values are nil, t, `head', `first', `last', an integer or a
1237 predicate. See Info node `(gnus)Customizing Articles'."
1238 :group 'gnus-article-treat
1239 :link '(custom-manual "(gnus)Customizing Articles")
1240 :type gnus-article-treat-head-custom)
1242 (defcustom gnus-treat-strip-headers-in-body t
1243 "Strip the X-No-Archive header line from the beginning of the body.
1244 Valid values are nil, t, `head', `first', `last', an integer or a
1245 predicate. See Info node `(gnus)Customizing Articles'."
1247 :group 'gnus-article-treat
1248 :link '(custom-manual "(gnus)Customizing Articles")
1249 :type gnus-article-treat-custom)
1251 (defcustom gnus-treat-strip-trailing-blank-lines nil
1252 "Strip trailing blank lines.
1253 Valid values are nil, t, `head', `first', `last', an integer or a
1254 predicate. See Info node `(gnus)Customizing Articles'.
1256 When set to t, it also strips trailing blanks in all MIME parts.
1257 Consider to use `last' instead."
1258 :group 'gnus-article-treat
1259 :link '(custom-manual "(gnus)Customizing Articles")
1260 :type gnus-article-treat-custom)
1262 (defcustom gnus-treat-strip-leading-blank-lines nil
1263 "Strip leading blank lines.
1264 Valid values are nil, t, `head', `first', `last', an integer or a
1265 predicate. See Info node `(gnus)Customizing Articles'.
1267 When set to t, it also strips trailing blanks in all MIME parts."
1268 :group 'gnus-article-treat
1269 :link '(custom-manual "(gnus)Customizing Articles")
1270 :type gnus-article-treat-custom)
1272 (defcustom gnus-treat-strip-multiple-blank-lines nil
1273 "Strip multiple blank lines.
1274 Valid values are nil, t, `head', `first', `last', an integer or a
1275 predicate. See Info node `(gnus)Customizing Articles'."
1276 :group 'gnus-article-treat
1277 :link '(custom-manual "(gnus)Customizing Articles")
1278 :type gnus-article-treat-custom)
1280 (defcustom gnus-treat-unfold-headers 'head
1281 "Unfold folded header lines.
1282 Valid values are nil, t, `head', `first', `last', an integer or a
1283 predicate. See Info node `(gnus)Customizing Articles'."
1285 :group 'gnus-article-treat
1286 :link '(custom-manual "(gnus)Customizing Articles")
1287 :type gnus-article-treat-custom)
1289 (defcustom gnus-treat-fold-headers nil
1291 Valid values are nil, t, `head', `first', `last', an integer or a
1292 predicate. See Info node `(gnus)Customizing Articles'."
1294 :group 'gnus-article-treat
1295 :link '(custom-manual "(gnus)Customizing Articles")
1296 :type gnus-article-treat-custom)
1298 (defcustom gnus-treat-fold-newsgroups 'head
1299 "Fold the Newsgroups and Followup-To headers.
1300 Valid values are nil, t, `head', `first', `last', an integer or a
1301 predicate. See Info node `(gnus)Customizing Articles'."
1303 :group 'gnus-article-treat
1304 :link '(custom-manual "(gnus)Customizing Articles")
1305 :type gnus-article-treat-custom)
1307 (defcustom gnus-treat-overstrike t
1308 "Treat overstrike highlighting.
1309 Valid values are nil, t, `head', `first', `last', an integer or a
1310 predicate. See Info node `(gnus)Customizing Articles'."
1311 :group 'gnus-article-treat
1312 :link '(custom-manual "(gnus)Customizing Articles")
1313 :type gnus-article-treat-custom)
1314 (put 'gnus-treat-overstrike 'highlight t)
1316 (defcustom gnus-treat-ansi-sequences (if (locate-library "ansi-color") t)
1317 "Treat ANSI SGR control sequences.
1318 Valid values are nil, t, `head', `first', `last', an integer or a
1319 predicate. See Info node `(gnus)Customizing Articles'."
1320 :group 'gnus-article-treat
1321 :link '(custom-manual "(gnus)Customizing Articles")
1322 :type gnus-article-treat-custom)
1324 (make-obsolete-variable 'gnus-treat-display-xface
1325 'gnus-treat-display-x-face)
1327 (defcustom gnus-treat-display-x-face
1328 (and (not noninteractive)
1329 (or (and (fboundp 'image-type-available-p)
1330 (image-type-available-p 'xbm)
1331 (string-match "^0x" (shell-command-to-string "uncompface"))
1332 (executable-find "icontopbm"))
1333 (and (featurep 'xemacs)
1336 "Display X-Face headers.
1337 Valid values are nil, t, `head', `first', `last', an integer or a
1338 predicate. See Info node `(gnus)Customizing Articles' and Info
1339 node `(gnus)X-Face' for details."
1340 :group 'gnus-article-treat
1342 :link '(custom-manual "(gnus)Customizing Articles")
1343 :link '(custom-manual "(gnus)X-Face")
1344 :type gnus-article-treat-head-custom
1345 :set (lambda (symbol value)
1348 (cond ((or (boundp symbol) (get symbol 'saved-value))
1350 ((boundp 'gnus-treat-display-xface)
1352 ** gnus-treat-display-xface is an obsolete variable;\
1353 use gnus-treat-display-x-face instead")
1354 (default-value 'gnus-treat-display-xface))
1355 ((get 'gnus-treat-display-xface 'saved-value)
1357 ** gnus-treat-display-xface is an obsolete variable;\
1358 use gnus-treat-display-x-face instead")
1359 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1362 (put 'gnus-treat-display-x-face 'highlight t)
1364 (defcustom gnus-article-should-use-smiley-mule
1365 (not (or (featurep 'xemacs)
1366 (gnus-image-type-available-p 'xpm)
1367 (gnus-image-type-available-p 'pbm)))
1368 "Non-nil means use `smiley-mule' to show smileys rather than `smiley'.
1369 `smiley-mule' is boundled in BITMAP-MULE package. You can set it to t
1370 even if your Emacs supports images. It has no effect on XEmacs."
1371 :group 'gnus-article-various
1373 :get (lambda (symbol)
1374 (and (not noninteractive)
1375 (default-value symbol)
1376 (not (featurep 'xemacs))
1377 (module-installed-p 'smiley-mule)
1379 :set (lambda (symbol value)
1380 (set-default symbol (and (not noninteractive)
1382 (not (featurep 'xemacs))
1383 (module-installed-p 'smiley-mule)
1386 (defvar gnus-article-smiley-mule-loaded-p nil
1387 "Internal variable used to say whether `smiley-mule' is loaded (whether
1388 smiley functions are not overridden by `smiley').")
1390 (defcustom gnus-treat-display-face
1391 (and (not noninteractive)
1392 (or (and (fboundp 'image-type-available-p)
1393 (image-type-available-p 'png))
1394 (and (featurep 'xemacs)
1397 "Display Face headers.
1398 Valid values are nil, t, `head', `first', `last', an integer or a
1399 predicate. See Info node `(gnus)Customizing Articles' and Info
1400 node `(gnus)X-Face' for details."
1401 :group 'gnus-article-treat
1403 :link '(custom-manual "(gnus)Customizing Articles")
1404 :link '(custom-manual "(gnus)X-Face")
1405 :type gnus-article-treat-head-custom)
1406 (put 'gnus-treat-display-face 'highlight t)
1408 (defcustom gnus-treat-display-smileys
1409 (if (and (not noninteractive)
1410 (or (and (featurep 'xemacs)
1412 (gnus-image-type-available-p 'xpm)
1413 (gnus-image-type-available-p 'pbm)
1414 (and (not (featurep 'xemacs))
1416 (module-installed-p 'smiley-mule))))
1420 Valid values are nil, t, `head', `first', `last', an integer or a
1421 predicate. See Info node `(gnus)Customizing Articles' and Info
1422 node `(gnus)Smileys' for details."
1423 :group 'gnus-article-treat
1425 :link '(custom-manual "(gnus)Customizing Articles")
1426 :link '(custom-manual "(gnus)Smileys")
1427 :type gnus-article-treat-custom)
1428 (put 'gnus-treat-display-smileys 'highlight t)
1430 (defcustom gnus-treat-from-picon
1431 (if (and (gnus-image-type-available-p 'xpm)
1432 (gnus-picons-installed-p))
1434 "Display picons in the From header.
1435 Valid values are nil, t, `head', `first', `last', an integer or a
1436 predicate. See Info node `(gnus)Customizing Articles' and Info
1437 node `(gnus)Picons' for details."
1439 :group 'gnus-article-treat
1441 :link '(custom-manual "(gnus)Customizing Articles")
1442 :link '(custom-manual "(gnus)Picons")
1443 :type gnus-article-treat-head-custom)
1444 (put 'gnus-treat-from-picon 'highlight t)
1446 (defcustom gnus-treat-mail-picon
1447 (if (and (gnus-image-type-available-p 'xpm)
1448 (gnus-picons-installed-p))
1450 "Display picons in To and Cc headers.
1451 Valid values are nil, t, `head', `first', `last', an integer or a
1452 predicate. See Info node `(gnus)Customizing Articles' and Info
1453 node `(gnus)Picons' for details."
1455 :group 'gnus-article-treat
1457 :link '(custom-manual "(gnus)Customizing Articles")
1458 :link '(custom-manual "(gnus)Picons")
1459 :type gnus-article-treat-head-custom)
1460 (put 'gnus-treat-mail-picon 'highlight t)
1462 (defcustom gnus-treat-newsgroups-picon
1463 (if (and (gnus-image-type-available-p 'xpm)
1464 (gnus-picons-installed-p))
1466 "Display picons in the Newsgroups and Followup-To headers.
1467 Valid values are nil, t, `head', `first', `last', an integer or a
1468 predicate. See Info node `(gnus)Customizing Articles' and Info
1469 node `(gnus)Picons' for details."
1471 :group 'gnus-article-treat
1473 :link '(custom-manual "(gnus)Customizing Articles")
1474 :link '(custom-manual "(gnus)Picons")
1475 :type gnus-article-treat-head-custom)
1476 (put 'gnus-treat-newsgroups-picon 'highlight t)
1478 (defcustom gnus-treat-body-boundary
1479 (if (and (eq window-system 'x)
1480 (or gnus-treat-newsgroups-picon
1481 gnus-treat-mail-picon
1482 gnus-treat-from-picon))
1484 "Draw a boundary at the end of the headers.
1485 Valid values are nil and `head'.
1486 See Info node `(gnus)Customizing Articles' for details."
1488 :group 'gnus-article-treat
1489 :link '(custom-manual "(gnus)Customizing Articles")
1490 :type gnus-article-treat-head-custom)
1492 (defcustom gnus-treat-capitalize-sentences nil
1493 "Capitalize sentence-starting words.
1494 Valid values are nil, t, `head', `first', `last', an integer or a
1495 predicate. See Info node `(gnus)Customizing Articles'."
1497 :group 'gnus-article-treat
1498 :link '(custom-manual "(gnus)Customizing Articles")
1499 :type gnus-article-treat-custom)
1501 (defcustom gnus-treat-wash-html nil
1503 Valid values are nil, t, `head', `first', `last', an integer or a
1504 predicate. See Info node `(gnus)Customizing Articles'."
1506 :group 'gnus-article-treat
1507 :link '(custom-manual "(gnus)Customizing Articles")
1508 :type gnus-article-treat-custom)
1510 (defcustom gnus-treat-fill-long-lines nil
1512 Valid values are nil, t, `head', `first', `last', an integer or a
1513 predicate. See Info node `(gnus)Customizing Articles'."
1514 :group 'gnus-article-treat
1515 :link '(custom-manual "(gnus)Customizing Articles")
1516 :type gnus-article-treat-custom)
1518 (defcustom gnus-treat-play-sounds nil
1520 Valid values are nil, t, `head', `first', `last', an integer or a
1521 predicate. See Info node `(gnus)Customizing Articles'."
1523 :group 'gnus-article-treat
1524 :link '(custom-manual "(gnus)Customizing Articles")
1525 :type gnus-article-treat-custom)
1527 (defcustom gnus-treat-decode-article-as-default-mime-charset nil
1528 "Decode an article as `default-mime-charset'. For instance, if you want to
1529 attempt to decode an article even if the value of `gnus-show-mime' is nil,
1530 you could set this variable to something like: nil for don't decode, t for
1531 decode the body, '(or header t) for the whole article, etc."
1532 :group 'gnus-article-treat
1533 :type '(radio (const :tag "Off" nil)
1534 (const :tag "Decode body" t)
1535 (const :tag "Decode all" (or head t))))
1537 (defcustom gnus-treat-translate nil
1538 "Translate articles from one language to another.
1539 Valid values are nil, t, `head', `first', `last', an integer or a
1540 predicate. See Info node `(gnus)Customizing Articles'."
1542 :group 'gnus-article-treat
1543 :link '(custom-manual "(gnus)Customizing Articles")
1544 :type gnus-article-treat-custom)
1546 (defcustom gnus-treat-x-pgp-sig nil
1548 To automatically treat X-PGP-Sig, set it to head.
1549 Valid values are nil, t, `head', `first', `last', an integer or a
1550 predicate. See Info node `(gnus)Customizing Articles'."
1552 :group 'gnus-article-treat
1553 :group 'mime-security
1554 :type gnus-article-treat-custom)
1556 (defcustom gnus-treat-monafy nil
1557 "Display body part with mona font.
1558 Valid values are nil, t, `head', `last', an integer or a predicate.
1559 See Info node `(gnus)Customizing Articles' for details."
1560 :group 'gnus-article-treat
1561 :group 'mime-security
1562 :link '(custom-manual "(gnus)Customizing Articles")
1563 :type gnus-article-treat-custom)
1565 (defvar gnus-article-encrypt-protocol-alist
1566 '(("PGP" . mml2015-self-encrypt)))
1568 ;; Set to nil if more than one protocol added to
1569 ;; gnus-article-encrypt-protocol-alist.
1570 (defcustom gnus-article-encrypt-protocol "PGP"
1571 "The protocol used for encrypt articles.
1572 It is a string, such as \"PGP\". If nil, ask user."
1575 :group 'mime-security)
1577 (defvar gnus-article-wash-function nil
1578 "Function used for converting HTML into text.")
1580 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1581 (mm-coding-system-p 'utf-8)
1582 (executable-find idna-program))
1583 "Whether IDNA decoding of headers is used when viewing messages.
1584 This requires GNU Libidn, and by default only enabled if it is found."
1586 :group 'gnus-article-headers
1589 (defcustom gnus-article-over-scroll nil
1590 "If non-nil, allow scrolling the article buffer even when there no more text."
1592 :group 'gnus-article
1595 ;;; Internal variables
1597 (defvar gnus-english-month-names
1598 '("January" "February" "March" "April" "May" "June" "July" "August"
1599 "September" "October" "November" "December"))
1601 (defvar gnus-button-regexp nil)
1602 (defvar gnus-button-marker-list nil)
1603 ;; Regexp matching any of the regexps from `gnus-button-alist'.
1605 (defvar gnus-button-last nil)
1606 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
1608 (defvar article-goto-body-goes-to-point-min-p nil)
1609 (defvar gnus-article-wash-types nil)
1610 (defvar gnus-article-emphasis-alist nil)
1611 (defvar gnus-article-image-alist nil)
1613 (defvar gnus-article-mime-handle-alist-1 nil)
1614 (defvar gnus-treatment-function-alist
1615 '((gnus-treat-decode-article-as-default-mime-charset
1616 gnus-article-decode-article-as-default-mime-charset)
1617 (gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1618 (gnus-treat-monafy gnus-article-monafy)
1619 (gnus-treat-strip-banner gnus-article-strip-banner)
1620 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1621 (gnus-treat-buttonize gnus-article-add-buttons)
1622 (gnus-treat-fill-article gnus-article-fill-cited-article)
1623 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1624 (gnus-treat-strip-cr gnus-article-remove-cr)
1625 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1626 (gnus-treat-date-ut gnus-article-date-ut)
1627 (gnus-treat-date-local gnus-article-date-local)
1628 (gnus-treat-date-english gnus-article-date-english)
1629 (gnus-treat-date-original gnus-article-date-original)
1630 (gnus-treat-date-user-defined gnus-article-date-user)
1631 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1632 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1633 (gnus-treat-display-face gnus-article-display-face)
1634 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1635 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1636 (gnus-treat-hide-signature gnus-article-hide-signature)
1637 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1638 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1639 (gnus-treat-strip-pem gnus-article-hide-pem)
1640 (gnus-treat-from-picon gnus-treat-from-picon)
1641 (gnus-treat-mail-picon gnus-treat-mail-picon)
1642 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1643 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1644 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1645 (gnus-treat-strip-trailing-blank-lines
1646 gnus-article-remove-trailing-blank-lines)
1647 (gnus-treat-strip-leading-blank-lines
1648 gnus-article-strip-leading-blank-lines)
1649 (gnus-treat-strip-multiple-blank-lines
1650 gnus-article-strip-multiple-blank-lines)
1651 (gnus-treat-overstrike gnus-article-treat-overstrike)
1652 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences)
1653 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1654 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1655 ;; Displaying X-Face should be done after unfolding headers
1656 ;; to protect bitmap lines.
1657 (gnus-treat-display-x-face gnus-article-display-x-face)
1658 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1659 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1660 (gnus-treat-display-smileys gnus-treat-smiley)
1661 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1662 (gnus-treat-wash-html gnus-article-wash-html)
1663 (gnus-treat-emphasize gnus-article-emphasize)
1664 (gnus-treat-hide-citation gnus-article-hide-citation)
1665 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1666 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1667 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1668 (gnus-treat-play-sounds gnus-earcon-display)))
1670 (defvar gnus-article-mime-handle-alist nil)
1671 (defvar article-lapsed-timer nil)
1672 (defvar gnus-article-current-summary nil)
1674 (defvar gnus-article-mode-syntax-table
1675 (let ((table (copy-syntax-table text-mode-syntax-table)))
1676 ;; This causes the citation match run O(2^n).
1677 ;; (modify-syntax-entry ?- "w" table)
1678 (modify-syntax-entry ?> ")<" table)
1679 (modify-syntax-entry ?< "(>" table)
1680 ;; make M-. in article buffers work for `foo' strings
1681 (modify-syntax-entry ?' " " table)
1682 (modify-syntax-entry ?` " " table)
1684 "Syntax table used in article mode buffers.
1685 Initialized from `text-mode-syntax-table.")
1687 (defvar gnus-save-article-buffer nil)
1689 (defvar gnus-article-mode-line-format-alist
1690 (nconc '((?w (gnus-article-wash-status) ?s)
1691 (?m (gnus-article-mime-part-status) ?s))
1692 gnus-summary-mode-line-format-alist))
1694 (defvar gnus-number-of-articles-to-be-saved nil)
1696 (defvar gnus-inhibit-hiding nil)
1698 (defvar gnus-article-edit-mode nil)
1700 ;;; Macros for dealing with the article buffer.
1702 (defmacro gnus-with-article-headers (&rest forms)
1704 (set-buffer gnus-article-buffer)
1706 (let ((inhibit-read-only t)
1707 (inhibit-point-motion-hooks t)
1708 (case-fold-search t))
1709 (article-narrow-to-head)
1712 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1713 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1715 (defmacro gnus-with-article-buffer (&rest forms)
1717 (set-buffer gnus-article-buffer)
1718 (let ((inhibit-read-only t))
1721 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1722 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1724 (defun gnus-article-goto-header (header)
1725 "Go to HEADER, which is a regular expression."
1726 (re-search-forward (concat "^\\(" header "\\):") nil t))
1728 (defsubst gnus-article-hide-text (b e props)
1729 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1730 (gnus-add-text-properties-when 'article-type nil b e props)
1731 (when (memq 'intangible props)
1733 (max (1- b) (point-min))
1734 b 'intangible (cddr (memq 'intangible props)))))
1736 (defsubst gnus-article-unhide-text (b e)
1737 "Remove hidden text properties from region between B and E."
1738 (remove-text-properties b e gnus-hidden-properties)
1739 (when (memq 'intangible gnus-hidden-properties)
1740 (put-text-property (max (1- b) (point-min))
1741 b 'intangible nil)))
1743 (defun gnus-article-hide-text-type (b e type)
1744 "Hide text of TYPE between B and E."
1745 (gnus-add-wash-type type)
1746 (gnus-article-hide-text
1747 b e (cons 'article-type (cons type gnus-hidden-properties))))
1749 (defun gnus-article-unhide-text-type (b e type)
1750 "Unhide text of TYPE between B and E."
1751 (gnus-delete-wash-type type)
1752 (remove-text-properties
1753 b e (cons 'article-type (cons type gnus-hidden-properties)))
1754 (when (memq 'intangible gnus-hidden-properties)
1755 (put-text-property (max (1- b) (point-min))
1756 b 'intangible nil)))
1758 (defun gnus-article-hide-text-of-type (type)
1759 "Hide text of TYPE in the current buffer."
1761 (let ((b (point-min))
1763 (while (setq b (text-property-any b e 'article-type type))
1764 (add-text-properties b (incf b) gnus-hidden-properties)))))
1766 (defun gnus-article-delete-text-of-type (type)
1767 "Delete text of TYPE in the current buffer."
1769 (let ((b (point-min)))
1770 (while (setq b (text-property-any b (point-max) 'article-type type))
1772 b (or (text-property-not-all b (point-max) 'article-type type)
1775 (defun gnus-article-delete-invisible-text ()
1776 "Delete all invisible text in the current buffer."
1778 (let ((b (point-min)))
1779 (while (setq b (text-property-any b (point-max) 'invisible t))
1781 b (or (text-property-not-all b (point-max) 'invisible t)
1784 (defun gnus-article-text-type-exists-p (type)
1785 "Say whether any text of type TYPE exists in the buffer."
1786 (text-property-any (point-min) (point-max) 'article-type type))
1788 (defsubst gnus-article-header-rank ()
1789 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1790 (let ((list gnus-sorted-header-list)
1793 (if (looking-at (car list))
1795 (setq list (cdr list))
1799 (defun article-hide-headers (&optional arg delete)
1800 "Hide unwanted headers and possibly sort them as well."
1801 (interactive (gnus-article-hidden-arg))
1802 ;; Lars said that this function might be inhibited.
1803 (if (gnus-article-check-hidden-text 'headers arg)
1805 ;; Show boring headers as well.
1806 (gnus-article-show-hidden-text 'boring-headers)
1807 (when (eq 1 (point-min))
1808 (set-window-start (get-buffer-window (current-buffer)) 1)))
1809 (unless gnus-inhibit-hiding
1810 (let ((inhibit-read-only t)
1811 (case-fold-search t)
1812 (max (1+ (length gnus-sorted-header-list)))
1813 (inhibit-point-motion-hooks t)
1814 (cur (current-buffer))
1815 ignored visible beg)
1817 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1818 ;; group parameters, so we should go to the summary buffer.
1821 (progn (set-buffer gnus-summary-buffer) t)
1823 (setq ignored (when (not gnus-visible-headers)
1824 (cond ((stringp gnus-ignored-headers)
1825 gnus-ignored-headers)
1826 ((listp gnus-ignored-headers)
1827 (mapconcat 'identity
1828 gnus-ignored-headers
1830 visible (cond ((stringp gnus-visible-headers)
1831 gnus-visible-headers)
1832 ((and gnus-visible-headers
1833 (listp gnus-visible-headers))
1834 (mapconcat 'identity
1835 gnus-visible-headers
1839 ;; First we narrow to just the headers.
1840 (article-narrow-to-head)
1841 ;; Hide any "From " lines at the beginning of (mail) articles.
1842 (while (looking-at "From ")
1846 (delete-region (point-min) (point))
1847 (gnus-article-hide-text (point-min) (point)
1848 (nconc (list 'article-type 'headers)
1849 gnus-hidden-properties))))
1850 ;; Then treat the rest of the header lines.
1851 ;; Then we use the two regular expressions
1852 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1853 ;; select which header lines is to remain visible in the
1855 (while (re-search-forward "^[^ \t:]*:" nil t)
1857 ;; Mark the rank of the header.
1859 (point) (1+ (point)) 'message-rank
1860 (if (or (and visible (looking-at visible))
1862 (not (looking-at ignored))))
1863 (gnus-article-header-rank)
1866 (message-sort-headers-1)
1867 (when (setq beg (text-property-any
1868 (point-min) (point-max) 'message-rank (+ 2 max)))
1869 ;; We delete or make invisible the unwanted headers.
1870 (gnus-add-wash-type 'headers)
1873 (add-text-properties
1874 (point-min) (+ 5 (point-min))
1875 '(article-type headers dummy-invisible t))
1876 (delete-region beg (point-max)))
1877 (gnus-article-hide-text-type beg (point-max) 'headers)))))))))
1879 (defun article-hide-boring-headers (&optional arg)
1880 "Toggle hiding of headers that aren't very interesting.
1881 If given a negative prefix, always show; if given a positive prefix,
1883 (interactive (gnus-article-hidden-arg))
1884 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1885 (not gnus-show-all-headers))
1888 (let ((inhibit-read-only t)
1889 (inhibit-point-motion-hooks t))
1890 (article-narrow-to-head)
1891 (dolist (elem gnus-boring-article-headers)
1892 (goto-char (point-min))
1894 ;; Hide empty headers.
1896 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1898 (gnus-article-hide-text-type
1902 (if (re-search-forward "^[^ \t]" nil t)
1906 ;; Hide boring Newsgroups header.
1907 ((eq elem 'newsgroups)
1908 (when (gnus-string-equal
1909 (gnus-fetch-field "newsgroups")
1910 (gnus-group-real-name
1911 (if (boundp 'gnus-newsgroup-name)
1914 (gnus-article-hide-header "newsgroups")))
1915 ((eq elem 'to-address)
1916 (let ((to (message-fetch-field "to"))
1918 (gnus-parameter-to-address
1919 (if (boundp 'gnus-newsgroup-name)
1920 gnus-newsgroup-name ""))))
1921 (when (and to to-address
1924 ;; only one address in To
1925 (nth 1 (mail-extract-address-components to))
1927 (gnus-article-hide-header "to"))))
1929 (let ((to (message-fetch-field "to"))
1931 (gnus-parameter-to-list
1932 (if (boundp 'gnus-newsgroup-name)
1933 gnus-newsgroup-name ""))))
1934 (when (and to to-list
1937 ;; only one address in To
1938 (nth 1 (mail-extract-address-components to))
1940 (gnus-article-hide-header "to"))))
1942 (let ((cc (message-fetch-field "cc"))
1944 (gnus-parameter-to-list
1945 (if (boundp 'gnus-newsgroup-name)
1946 gnus-newsgroup-name ""))))
1947 (when (and cc to-list
1950 ;; only one address in CC
1951 (nth 1 (mail-extract-address-components cc))
1953 (gnus-article-hide-header "cc"))))
1954 ((eq elem 'followup-to)
1955 (when (gnus-string-equal
1956 (message-fetch-field "followup-to")
1957 (message-fetch-field "newsgroups"))
1958 (gnus-article-hide-header "followup-to")))
1959 ((eq elem 'reply-to)
1960 (if (gnus-group-find-parameter
1961 gnus-newsgroup-name 'broken-reply-to)
1962 (gnus-article-hide-header "reply-to")
1963 (let ((from (message-fetch-field "from"))
1964 (reply-to (message-fetch-field "reply-to")))
1971 (lambda (x) (downcase (cadr x)))
1972 (mail-extract-address-components from t))
1975 (lambda (x) (downcase (cadr x)))
1976 (mail-extract-address-components reply-to t))
1978 (gnus-article-hide-header "reply-to")))))
1980 (let ((date (message-fetch-field "date")))
1982 (< (days-between (current-time-string) date)
1984 (gnus-article-hide-header "date"))))
1986 (let ((to (message-fetch-field "to"))
1987 (cc (message-fetch-field "cc")))
1988 (when (> (length to) 1024)
1989 (gnus-article-hide-header "to"))
1990 (when (> (length cc) 1024)
1991 (gnus-article-hide-header "cc"))))
1995 (goto-char (point-min))
1996 (while (re-search-forward "^to:" nil t)
1997 (setq to-count (1+ to-count)))
1998 (when (> to-count 1)
1999 (while (> to-count 0)
2000 (goto-char (point-min))
2002 (re-search-forward "^to:" nil nil to-count)
2004 (narrow-to-region (point) (point-max))
2005 (gnus-article-hide-header "to"))
2006 (setq to-count (1- to-count))))
2007 (goto-char (point-min))
2008 (while (re-search-forward "^cc:" nil t)
2009 (setq cc-count (1+ cc-count)))
2010 (when (> cc-count 1)
2011 (while (> cc-count 0)
2012 (goto-char (point-min))
2014 (re-search-forward "^cc:" nil nil cc-count)
2016 (narrow-to-region (point) (point-max))
2017 (gnus-article-hide-header "cc"))
2018 (setq cc-count (1- cc-count)))))))))))))
2020 (defun gnus-article-hide-header (header)
2022 (goto-char (point-min))
2023 (when (re-search-forward (concat "^" header ":") nil t)
2024 (gnus-article-hide-text-type
2028 (if (re-search-forward "^[^ \t]" nil t)
2033 (defvar gnus-article-normalized-header-length 40
2034 "Length of normalized headers.")
2036 (defun article-normalize-headers ()
2037 "Make all header lines 40 characters long."
2039 (let ((inhibit-read-only t)
2043 (article-narrow-to-head)
2046 ((< (setq column (- (point-at-eol) (point)))
2047 gnus-article-normalized-header-length)
2049 (insert (make-string
2050 (- gnus-article-normalized-header-length column)
2052 ((> column gnus-article-normalized-header-length)
2053 (gnus-put-text-property
2055 (forward-char gnus-article-normalized-header-length)
2062 (forward-line 1))))))
2064 (defun article-treat-dumbquotes ()
2065 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
2066 Note that this function guesses whether a character is a sm*rtq**t* or
2067 not, so it should only be used interactively.
2069 Sm*rtq**t*s are M****s***'s unilateral extension to the
2070 iso-8859-1 character map in an attempt to provide more quoting
2071 characters. If you see something like \\222 or \\264 where
2072 you're expecting some kind of apostrophe or quotation mark, then
2075 (article-translate-strings gnus-article-dumbquotes-map))
2077 (defun article-translate-characters (from to)
2078 "Translate all characters in the body of the article according to FROM and TO.
2079 FROM is a string of characters to translate from; to is a string of
2080 characters to translate to."
2082 (when (article-goto-body)
2083 (let ((inhibit-read-only t)
2084 (x (make-string 225 ?x))
2086 (while (< (incf i) (length x))
2089 (while (< i (length from))
2090 (aset x (aref from i) (aref to i))
2092 (translate-region (point) (point-max) x)))))
2094 (defun article-translate-strings (map)
2095 "Translate all string in the body of the article according to MAP.
2096 MAP is an alist where the elements are on the form (\"from\" \"to\")."
2098 (when (article-goto-body)
2099 (let ((inhibit-read-only t))
2102 (while (search-forward (car elem) nil t)
2103 (replace-match (cadr elem)))))))))
2105 (defun article-treat-overstrike ()
2106 "Translate overstrikes into bold text."
2109 (when (article-goto-body)
2110 (let ((inhibit-read-only t))
2111 (while (search-forward "\b" nil t)
2112 (let ((next (char-after))
2116 previous (char-after))
2120 ;; We do the boldification/underlining by hiding the
2121 ;; overstrikes and putting the proper text property
2125 (gnus-article-hide-text-type start (point) 'overstrike)
2126 (put-text-property (point) end 'face 'bold))
2128 (gnus-article-hide-text-type
2129 (1- (point)) (1+ (point)) 'overstrike)
2131 start (1- (point)) 'face 'underline))
2133 (gnus-article-hide-text-type start (point) 'overstrike)
2135 (point) end 'face 'underline)))))))))
2137 (defun article-treat-ansi-sequences ()
2138 "Translate ANSI SGR control sequences into overlays or extents."
2141 (when (article-goto-body)
2142 (let ((inhibit-read-only t))
2143 (ansi-color-apply-on-region (point) (point-max))))))
2145 (defun gnus-article-treat-unfold-headers ()
2146 "Unfold folded message headers.
2147 Only the headers that fit into the current window width will be
2150 (gnus-with-article-headers
2154 (mail-header-narrow-to-field)
2155 (let ((header (buffer-string)))
2158 (goto-char (point-min))
2159 (while (re-search-forward "\n[\t ]" nil t)
2160 (replace-match " " t t)))
2161 (setq length (- (point-max) (point-min) 1)))
2162 (when (< length (window-width))
2163 (while (re-search-forward "\n[\t ]" nil t)
2164 (replace-match " " t t)))
2165 (goto-char (point-max)))))))
2167 (defun gnus-article-treat-fold-headers ()
2168 "Fold message headers."
2170 (gnus-with-article-headers
2173 (mail-header-narrow-to-field)
2174 (mail-header-fold-field)
2175 (goto-char (point-max))))))
2177 (defun gnus-treat-smiley ()
2178 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2180 (unless (featurep 'xemacs)
2181 (when (and (not gnus-article-should-use-smiley-mule)
2182 gnus-article-smiley-mule-loaded-p)
2183 (load "smiley" nil t)
2184 (setq gnus-article-smiley-mule-loaded-p nil))
2185 (when (and gnus-article-should-use-smiley-mule
2186 (not gnus-article-smiley-mule-loaded-p))
2187 (load "smiley-mule" nil t)
2188 (setq gnus-article-smiley-mule-loaded-p t)))
2189 (gnus-with-article-buffer
2190 (if (memq 'smiley gnus-article-wash-types)
2191 (gnus-delete-images 'smiley)
2193 (let ((images (smiley-region (point) (point-max))))
2195 (gnus-add-wash-type 'smiley)
2196 (dolist (image images)
2197 (gnus-add-image 'smiley image)))))))
2199 (defun gnus-article-remove-images ()
2200 "Remove all images from the article buffer."
2202 (gnus-with-article-buffer
2203 (dolist (elem gnus-article-image-alist)
2204 (gnus-delete-images (car elem)))))
2206 (defun gnus-article-treat-fold-newsgroups ()
2207 "Unfold folded message headers.
2208 Only the headers that fit into the current window width will be
2211 (gnus-with-article-headers
2212 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2214 (mail-header-narrow-to-field)
2215 (while (re-search-forward ", *" nil t)
2216 (replace-match ", " t t))
2217 (mail-header-fold-field)
2218 (goto-char (point-max))))))
2220 (defun gnus-article-treat-body-boundary ()
2221 "Place a boundary line at the end of the headers."
2223 (when (and gnus-body-boundary-delimiter
2224 (> (length gnus-body-boundary-delimiter) 0))
2225 (gnus-with-article-headers
2226 (goto-char (point-max))
2227 (let ((start (point)))
2228 (insert "X-Boundary: ")
2229 (gnus-add-text-properties start (point) '(invisible t intangible t))
2231 (while (>= (1- (window-width)) (length str))
2232 (setq str (concat str gnus-body-boundary-delimiter)))
2233 (substring str 0 (1- (window-width))))
2235 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2237 (defun article-fill-long-lines ()
2238 "Fill lines that are wider than the window width."
2241 (let ((inhibit-read-only t)
2242 (width (window-width (get-buffer-window (current-buffer)))))
2245 (let ((adaptive-fill-mode nil)) ;Why? -sm
2248 (when (>= (current-column) (min fill-column width))
2249 (narrow-to-region (min (1+ (point)) (point-max))
2251 (let ((goback (point-marker)))
2252 (fill-paragraph nil)
2253 (goto-char (marker-position goback)))
2255 (forward-line 1)))))))
2257 (defun article-capitalize-sentences ()
2258 "Capitalize the first word in each sentence."
2261 (let ((inhibit-read-only t)
2262 (paragraph-start "^[\n\^L]"))
2266 (forward-sentence)))))
2268 (defun article-remove-cr ()
2269 "Remove trailing CRs and then translate remaining CRs into LFs."
2272 (let ((inhibit-read-only t))
2273 (goto-char (point-min))
2274 (while (re-search-forward "\r+$" nil t)
2275 (replace-match "" t t))
2276 (goto-char (point-min))
2277 (while (search-forward "\r" nil t)
2278 (replace-match "\n" t t)))))
2280 (defun article-remove-trailing-blank-lines ()
2281 "Remove all trailing blank lines from the article."
2284 (let ((inhibit-read-only t))
2285 (goto-char (point-max))
2289 (while (and (not (bobp))
2290 (looking-at "^[ \t]*$")
2291 (not (gnus-annotation-in-region-p
2292 (point) (point-at-eol))))
2298 (defvar gnus-face-properties-alist))
2300 (defun article-display-face ()
2301 "Display any Face headers in the header."
2303 (let ((wash-face-p buffer-read-only))
2304 (gnus-with-article-headers
2305 ;; When displaying parts, this function can be called several times on
2306 ;; the same article, without any intended toggle semantic (as typing `W
2307 ;; D d' would have). So face deletion must occur only when we come from
2308 ;; an interactive command, that is when the *Article* buffer is
2310 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2311 (gnus-delete-images 'face)
2312 (let (face faces from)
2313 (save-current-buffer
2314 (when (and wash-face-p
2315 (gnus-buffer-live-p gnus-original-article-buffer)
2316 (not (re-search-forward "^Face:[\t ]*" nil t)))
2317 (set-buffer gnus-original-article-buffer))
2319 (mail-narrow-to-head)
2320 (while (gnus-article-goto-header "Face")
2321 (push (mail-header-field-value) faces))))
2323 (goto-char (point-min))
2324 (let ((from (gnus-article-goto-header "from"))
2329 (insert "[no `from' set]\n"))
2331 (when (setq png (gnus-convert-face-to-png (pop faces)))
2333 (apply 'gnus-create-image png 'png t
2334 (cdr (assq 'png gnus-face-properties-alist))))
2336 (gnus-add-wash-type 'face)
2337 (gnus-add-image 'face image)
2338 (gnus-put-image image nil 'face))))))))))
2340 (defun article-display-x-face (&optional force)
2341 "Look for an X-Face header and display it if present."
2342 (interactive (list 'force))
2343 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2344 (gnus-with-article-headers
2345 ;; Delete the old process, if any.
2346 (when (process-status "article-x-face")
2347 (delete-process "article-x-face"))
2348 ;; See the comment in `article-display-face'.
2349 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2350 ;; We have already displayed X-Faces, so we remove them
2352 (gnus-delete-images 'xface)
2354 (let (x-faces from face)
2355 (save-current-buffer
2356 (when (and wash-face-p
2357 (gnus-buffer-live-p gnus-original-article-buffer)
2358 (not (re-search-forward "^X-Face:[\t ]*" nil t)))
2359 ;; If type `W f', use gnus-original-article-buffer,
2360 ;; otherwise use the current buffer because displaying
2361 ;; RFC822 parts calls this function too.
2362 (set-buffer gnus-original-article-buffer))
2364 (mail-narrow-to-head)
2365 (while (gnus-article-goto-header "X-Face")
2366 (push (mail-header-field-value) x-faces))
2367 (setq from (message-fetch-field "from"))))
2368 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2369 ;; single external face.
2370 (when (stringp gnus-article-x-face-command)
2371 (setq x-faces (list (car x-faces))))
2373 gnus-article-x-face-command
2375 ;; Check whether this face is censored.
2376 (not gnus-article-x-face-too-ugly)
2378 (not (string-match gnus-article-x-face-too-ugly
2380 (while (setq face (pop x-faces))
2381 ;; We display the face.
2382 (cond ((stringp gnus-article-x-face-command)
2383 ;; The command is a string, so we interpret the command
2384 ;; as a, well, command, and fork it off.
2385 (let ((process-connection-type nil))
2386 (gnus-set-process-query-on-exit-flag
2388 "article-x-face" nil shell-file-name
2389 shell-command-switch gnus-article-x-face-command)
2393 (process-send-region "article-x-face"
2394 (point-min) (point-max)))
2395 (process-send-eof "article-x-face")))
2396 ((functionp gnus-article-x-face-command)
2397 ;; The command is a lisp function, so we call it.
2398 (funcall gnus-article-x-face-command face))
2400 (error "%s is not a function"
2401 gnus-article-x-face-command))))))))))
2403 (defun article-decode-mime-words ()
2404 "Decode all MIME-encoded words in the article."
2406 (gnus-with-article-buffer
2407 (let ((inhibit-point-motion-hooks t)
2408 (mail-parse-charset gnus-newsgroup-charset)
2409 (mail-parse-ignored-charsets
2410 (with-current-buffer gnus-summary-buffer
2411 gnus-newsgroup-ignored-charsets)))
2412 (mail-decode-encoded-word-region (point-min) (point-max)))))
2414 (defun article-decode-charset (&optional prompt)
2415 "Decode charset-encoded text in the article.
2416 If PROMPT (the prefix), prompt for a coding system to use."
2418 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2419 (inhibit-read-only t)
2420 (mail-parse-charset gnus-newsgroup-charset)
2421 (mail-parse-ignored-charsets
2422 (save-excursion (condition-case nil
2423 (set-buffer gnus-summary-buffer)
2425 gnus-newsgroup-ignored-charsets))
2426 ct cte ctl charset format)
2429 (article-narrow-to-head)
2430 (setq ct (message-fetch-field "Content-Type" t)
2431 cte (message-fetch-field "Content-Transfer-Encoding" t)
2432 ctl (and ct (ignore-errors
2433 (mail-header-parse-content-type ct)))
2436 (mm-read-coding-system "Charset to decode: "))
2438 (mail-content-type-get ctl 'charset)))
2439 format (and ctl (mail-content-type-get ctl 'format)))
2441 (setq cte (mail-header-strip cte)))
2442 (if (and ctl (not (string-match "/" (car ctl))))
2444 (goto-char (point-max)))
2447 (narrow-to-region (point) (point-max))
2448 (when (and (eq mail-parse-charset 'gnus-decoded)
2449 (eq (mm-body-7-or-8) '8bit))
2450 ;; The text code could have been decoded.
2451 (setq charset mail-parse-charset))
2452 (when (and (or (not ctl)
2453 (equal (car ctl) "text/plain"))
2454 (not format)) ;; article with format will decode later.
2456 charset (and cte (intern (downcase
2457 (gnus-strip-whitespace cte))))
2460 (defun article-decode-encoded-words ()
2461 "Remove encoded-word encoding from headers."
2462 (let ((charset (save-excursion
2463 (set-buffer gnus-summary-buffer)
2464 default-mime-charset))
2465 (inhibit-read-only t))
2466 (mime-decode-header-in-buffer charset)))
2468 (defun article-decode-group-name ()
2469 "Decode group names in `Newsgroups:'."
2470 (let ((inhibit-point-motion-hooks t)
2471 (inhibit-read-only t)
2472 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2473 (when (and (or gnus-group-name-charset-method-alist
2474 gnus-group-name-charset-group-alist)
2475 (gnus-buffer-live-p gnus-original-article-buffer))
2477 (article-narrow-to-head)
2478 (with-current-buffer gnus-original-article-buffer
2479 (goto-char (point-min)))
2480 (while (re-search-forward
2481 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2482 (replace-match (save-match-data
2483 (gnus-decode-newsgroups
2484 ;; XXX how to use data in article buffer?
2485 (with-current-buffer gnus-original-article-buffer
2487 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2490 gnus-newsgroup-name method))
2492 (goto-char (point-min))
2493 (with-current-buffer gnus-original-article-buffer
2494 (goto-char (point-min)))
2495 (while (re-search-forward
2496 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2497 (replace-match (save-match-data
2498 (gnus-decode-newsgroups
2499 ;; XXX how to use data in article buffer?
2500 (with-current-buffer gnus-original-article-buffer
2502 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2505 gnus-newsgroup-name method))
2508 (autoload 'idna-to-unicode "idna")
2510 (defun article-decode-idna-rhs ()
2511 "Decode IDNA strings in RHS in various headers in current buffer.
2512 The following headers are decoded: From:, To:, Cc:, Reply-To:,
2513 Mail-Reply-To: and Mail-Followup-To:."
2516 (let ((inhibit-point-motion-hooks t)
2517 (inhibit-read-only t))
2518 (article-narrow-to-head)
2519 (goto-char (point-min))
2520 (while (re-search-forward "@[^ \t\n\r,>]*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2522 (when (save-match-data
2523 (and (setq ace (match-string 1))
2525 (and (re-search-backward "^[^ \t]" nil t)
2526 (looking-at "From\\|To\\|Cc\\|Reply-To\\|Mail-Reply-To\\|Mail-Followup-To")))
2527 (setq unicode (idna-to-unicode ace))))
2528 (unless (string= ace unicode)
2529 (replace-match unicode nil nil nil 1)))))))))
2531 (defun article-de-quoted-unreadable (&optional force read-charset)
2532 "Translate a quoted-printable-encoded article.
2533 If FORCE, decode the article whether it is marked as quoted-printable
2535 If READ-CHARSET, ask for a coding system."
2536 (interactive (list 'force current-prefix-arg))
2538 (let ((inhibit-read-only t) type charset)
2539 (if (gnus-buffer-live-p gnus-original-article-buffer)
2540 (with-current-buffer gnus-original-article-buffer
2542 (gnus-fetch-field "content-transfer-encoding"))
2543 (let* ((ct (gnus-fetch-field "content-type"))
2546 (mail-header-parse-content-type ct)))))
2547 (setq charset (and ctl
2548 (mail-content-type-get ctl 'charset)))
2549 (if (stringp charset)
2550 (setq charset (intern (downcase charset)))))))
2552 (setq charset (mm-read-coding-system "Charset: " charset)))
2554 (setq charset gnus-newsgroup-charset))
2556 (and type (let ((case-fold-search t))
2557 (string-match "quoted-printable" type))))
2559 (quoted-printable-decode-region
2560 (point) (point-max) (mm-charset-to-coding-system charset))))))
2562 (defun article-de-base64-unreadable (&optional force read-charset)
2563 "Translate a base64 article.
2564 If FORCE, decode the article whether it is marked as base64 not.
2565 If READ-CHARSET, ask for a coding system."
2566 (interactive (list 'force current-prefix-arg))
2568 (let ((inhibit-read-only t) type charset)
2569 (if (gnus-buffer-live-p gnus-original-article-buffer)
2570 (with-current-buffer gnus-original-article-buffer
2572 (gnus-fetch-field "content-transfer-encoding"))
2573 (let* ((ct (gnus-fetch-field "content-type"))
2576 (mail-header-parse-content-type ct)))))
2577 (setq charset (and ctl
2578 (mail-content-type-get ctl 'charset)))
2579 (if (stringp charset)
2580 (setq charset (intern (downcase charset)))))))
2582 (setq charset (mm-read-coding-system "Charset: " charset)))
2584 (setq charset gnus-newsgroup-charset))
2586 (and type (let ((case-fold-search t))
2587 (string-match "base64" type))))
2590 (narrow-to-region (point) (point-max))
2591 (base64-decode-region (point-min) (point-max))
2592 (mm-decode-coding-region
2593 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2598 (defun article-decode-HZ ()
2599 "Translate a HZ-encoded article."
2603 (let ((inhibit-read-only t))
2604 (rfc1843-decode-region (point-min) (point-max)))))
2606 (defun article-unsplit-urls ()
2607 "Remove the newlines that some other mailers insert into URLs."
2610 (let ((inhibit-read-only t))
2611 (goto-char (point-min))
2612 (while (re-search-forward
2613 "\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2614 (replace-match "\\1\\3" t)))
2615 (when (interactive-p)
2616 (gnus-treat-article nil))))
2619 (defun article-wash-html (&optional read-charset)
2620 "Format an HTML article.
2621 If READ-CHARSET, ask for a coding system."
2624 (let ((inhibit-read-only t)
2626 (when (gnus-buffer-live-p gnus-original-article-buffer)
2627 (with-current-buffer gnus-original-article-buffer
2628 (let* ((ct (gnus-fetch-field "content-type"))
2631 (mail-header-parse-content-type ct)))))
2632 (setq charset (and ctl
2633 (mail-content-type-get ctl 'charset)))
2634 (when (stringp charset)
2635 (setq charset (intern (downcase charset)))))))
2637 (setq charset (mm-read-coding-system "Charset: " charset)))
2639 (setq charset gnus-newsgroup-charset))
2641 (save-window-excursion
2643 (narrow-to-region (point) (point-max))
2644 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2645 (entry (assq func mm-text-html-washer-alist)))
2647 (setq func (cdr entry)))
2652 (apply (car func) (cdr func))))))))))
2654 (defun gnus-article-wash-html-with-w3 ()
2655 "Wash the current buffer with w3."
2657 (let ((w3-strict-width (window-width))
2658 (url-standalone-mode t)
2659 (url-gateway-unplugged t)
2660 (w3-honor-stylesheets nil))
2662 (w3-region (point-min) (point-max))
2665 (defun gnus-article-wash-html-with-w3m ()
2666 "Wash the current buffer with emacs-w3m."
2669 (narrow-to-region (point) (point-max))
2670 (let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp)
2671 w3m-force-redisplay)
2672 (w3m-region (point-min) (point-max)))
2673 (when (and mm-inline-text-html-with-w3m-keymap
2674 (boundp 'w3m-minor-mode-map)
2676 (add-text-properties
2677 (point-min) (point-max)
2678 (list 'keymap w3m-minor-mode-map
2679 ;; Put the mark meaning this part was rendered by emacs-w3m.
2680 'mm-inline-text-html-with-w3m t)))))
2682 (defun article-hide-list-identifiers ()
2683 "Remove list identifies from the Subject header.
2684 The `gnus-list-identifiers' variable specifies what to do."
2686 (let ((inhibit-point-motion-hooks t)
2687 (regexp (if (consp gnus-list-identifiers)
2688 (mapconcat 'identity gnus-list-identifiers " *\\|")
2689 gnus-list-identifiers))
2690 (inhibit-read-only t))
2694 (article-narrow-to-head)
2695 (goto-char (point-min))
2696 (while (re-search-forward
2697 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2699 (delete-region (match-beginning 2) (match-end 0))
2700 (beginning-of-line))
2701 (when (re-search-forward
2702 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2703 (delete-region (match-beginning 1) (match-end 1))))))))
2705 (defun article-hide-pem (&optional arg)
2706 "Toggle hiding of any PEM headers and signatures in the current article.
2707 If given a negative prefix, always show; if given a positive prefix,
2709 (interactive (gnus-article-hidden-arg))
2710 (unless (gnus-article-check-hidden-text 'pem arg)
2712 (let ((inhibit-read-only t) end)
2713 (goto-char (point-min))
2714 ;; Hide the horrendously ugly "header".
2715 (when (and (search-forward
2716 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2718 (setq end (1+ (match-beginning 0))))
2719 (gnus-add-wash-type 'pem)
2720 (gnus-article-hide-text-type
2722 (if (search-forward "\n\n" nil t)
2726 ;; Hide the trailer as well
2727 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2729 (gnus-article-hide-text-type
2730 (match-beginning 0) (match-end 0) 'pem)))))))
2732 (defun article-strip-banner ()
2733 "Strip the banners specified by the `banner' group parameter and by
2734 `gnus-article-address-banner-alist'."
2738 (let ((inhibit-point-motion-hooks t))
2739 (when (gnus-parameter-banner gnus-newsgroup-name)
2740 (article-really-strip-banner
2741 (gnus-parameter-banner gnus-newsgroup-name)))
2742 (when gnus-article-address-banner-alist
2743 ;; It is necessary to encode from fields before checking,
2744 ;; because `mail-header-parse-addresses' does not work
2745 ;; (reliably) on decoded headers. And more, it is
2746 ;; impossible to use `gnus-fetch-original-field' here,
2747 ;; because `article-strip-banner' may be called in draft
2748 ;; buffers to preview them.
2749 (let ((from (save-restriction
2751 (article-narrow-to-head)
2752 (mail-fetch-field "from"))))
2755 (caar (mail-header-parse-addresses
2756 (mail-encode-encoded-word-string from)))))
2758 (dolist (pair gnus-article-address-banner-alist)
2759 (when (string-match (car pair) from)
2761 (article-really-strip-banner (cdr pair)))))))))))))
2763 (defun article-really-strip-banner (banner)
2764 "Strip the banner specified by the argument."
2767 (let ((inhibit-point-motion-hooks t)
2768 (gnus-signature-limit nil)
2769 (inhibit-read-only t))
2772 ((eq banner 'signature)
2773 (when (gnus-article-narrow-to-signature)
2776 (delete-region (point) (point-max))))
2778 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2779 (while (re-search-forward banner nil t)
2780 (delete-region (match-beginning 0) (match-end 0)))))
2782 (while (re-search-forward banner nil t)
2783 (delete-region (match-beginning 0) (match-end 0)))))))))
2785 (defun article-babel ()
2786 "Translate article using an online translation service."
2789 (gnus-with-article-buffer
2790 (when (article-goto-body)
2791 (let* ((start (point))
2793 (orig (buffer-substring start end))
2794 (trans (babel-as-string orig)))
2796 (narrow-to-region start end)
2797 (delete-region start end)
2800 (defun article-hide-signature (&optional arg)
2801 "Hide the signature in the current article.
2802 If given a negative prefix, always show; if given a positive prefix,
2804 (interactive (gnus-article-hidden-arg))
2810 (article-goto-body))
2811 (goto-char (point-min)))
2812 (unless (gnus-article-check-hidden-text 'signature arg)
2813 (let ((inhibit-read-only t)
2815 (while (setq button (text-property-any button (point-max)
2817 'gnus-signature-toggle))
2818 (setq button (text-property-not-all button (point-max)
2820 'gnus-signature-toggle))
2821 (when (and button (not (eobp)))
2822 (gnus-article-hide-text-type
2824 (next-single-property-change (1+ button) 'mime-view-entity
2827 (gnus-set-mode-line 'article))
2829 (defun article-strip-headers-in-body ()
2830 "Strip offensive headers from bodies."
2834 (let ((case-fold-search t))
2835 (when (looking-at "x-no-archive:")
2836 (gnus-delete-line)))))
2838 (defun article-strip-leading-blank-lines ()
2839 "Remove all blank lines from the beginning of the article."
2842 (let ((inhibit-point-motion-hooks t)
2843 (inhibit-read-only t))
2844 (when (article-goto-body)
2845 (while (and (not (eobp))
2846 (looking-at "[ \t]*$"))
2847 (gnus-delete-line))))))
2849 (defun article-narrow-to-head ()
2850 "Narrow the buffer to the head of the message.
2851 Point is left at the beginning of the narrowed-to region."
2853 (goto-char (point-min))
2854 (if (search-forward "\n\n" nil 1)
2857 (goto-char (point-min)))
2859 (defun article-goto-body ()
2860 "Place point at the start of the body."
2861 (goto-char (point-min))
2863 ;; This variable is only bound when dealing with separate
2865 (article-goto-body-goes-to-point-min-p
2867 ((search-forward "\n\n" nil t)
2870 (goto-char (point-max))
2873 (defun article-strip-multiple-blank-lines ()
2874 "Replace consecutive blank lines with one empty line."
2877 (let ((inhibit-point-motion-hooks t)
2878 (inhibit-read-only t))
2879 ;; First make all blank lines empty.
2881 (while (re-search-forward "^[ \t]+$" nil t)
2882 (unless (gnus-annotation-in-region-p
2883 (match-beginning 0) (match-end 0))
2884 (replace-match "" nil t)))
2885 ;; Then replace multiple empty lines with a single empty line.
2887 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2888 (unless (gnus-annotation-in-region-p
2889 (match-beginning 0) (match-end 0))
2890 (delete-region (match-beginning 1) (match-end 1)))))))
2892 (defun article-strip-leading-space ()
2893 "Remove all white space from the beginning of the lines in the article."
2896 (let ((inhibit-point-motion-hooks t)
2897 (inhibit-read-only t))
2899 (while (re-search-forward "^[ \t]+" nil t)
2900 (replace-match "" t t)))))
2902 (defun article-strip-trailing-space ()
2903 "Remove all white space from the end of the lines in the article."
2906 (let ((inhibit-point-motion-hooks t)
2907 (inhibit-read-only t))
2909 (while (re-search-forward "[ \t]+$" nil t)
2910 (replace-match "" t t)))))
2912 (defun article-strip-blank-lines ()
2913 "Strip leading, trailing and multiple blank lines."
2915 (article-strip-leading-blank-lines)
2916 (article-remove-trailing-blank-lines)
2917 (article-strip-multiple-blank-lines))
2919 (defun article-strip-all-blank-lines ()
2920 "Strip all blank lines."
2923 (let ((inhibit-point-motion-hooks t)
2924 (inhibit-read-only t))
2926 (while (re-search-forward "^[ \t]*\n" nil t)
2927 (replace-match "" t t)))))
2929 (defun gnus-article-narrow-to-signature ()
2930 "Narrow to the signature; return t if a signature is found, else nil."
2931 (let ((inhibit-point-motion-hooks t))
2932 (when (gnus-article-search-signature)
2934 ;; Check whether we have some limits to what we consider
2935 ;; to be a signature.
2936 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2937 (list gnus-signature-limit)))
2939 (while (setq limit (pop limits))
2940 (if (or (and (integerp limit)
2941 (< (- (point-max) (point)) limit))
2943 (< (count-lines (point) (point-max)) limit))
2944 (and (functionp limit)
2946 (and (stringp limit)
2947 (not (re-search-forward limit nil t))))
2948 () ; This limit did not succeed.
2952 (narrow-to-region (point) (point-max))
2955 (defun gnus-article-search-signature ()
2956 "Search the current buffer for the signature separator.
2957 Put point at the beginning of the signature separator."
2958 (let ((cur (point)))
2959 (goto-char (point-max))
2960 (if (if (stringp gnus-signature-separator)
2961 (re-search-backward gnus-signature-separator nil t)
2962 (let ((seps gnus-signature-separator))
2964 (not (re-search-backward (car seps) nil t)))
2971 (defun gnus-article-hidden-arg ()
2972 "Return the current prefix arg as a number, or 0 if no prefix."
2973 (list (if current-prefix-arg
2974 (prefix-numeric-value current-prefix-arg)
2977 (defun gnus-article-check-hidden-text (type arg)
2978 "Return nil if hiding is necessary.
2979 Arg can be nil or a number. nil and positive means hide, negative
2980 means show, 0 means toggle."
2983 (let ((hide (gnus-article-hidden-text-p type)))
2989 (gnus-article-show-hidden-text type)
2992 (if (eq hide 'hidden)
2994 (gnus-article-show-hidden-text type)
2998 (defun gnus-article-hidden-text-p (type)
2999 "Say whether the current buffer contains hidden text of type TYPE."
3000 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
3002 (not (get-text-property pos 'invisible))
3003 (not (get-text-property pos 'dummy-invisible)))
3005 (text-property-any (1+ pos) (point-max) 'article-type type)))
3010 (defun gnus-article-show-hidden-text (type &optional dummy)
3011 "Show all hidden text of type TYPE.
3012 Originally it is hide instead of DUMMY."
3013 (let ((inhibit-read-only t)
3014 (inhibit-point-motion-hooks t))
3015 (gnus-remove-text-properties-when
3017 (point-min) (point-max)
3018 (cons 'article-type (cons type
3019 gnus-hidden-properties)))
3020 (gnus-delete-wash-type type)))
3022 (defconst article-time-units
3023 `((year . ,(* 365.25 24 60 60))
3024 (week . ,(* 7 24 60 60))
3025 (day . ,(* 24 60 60))
3029 "Mapping from time units to seconds.")
3031 (defun gnus-article-forward-header ()
3032 "Move point to the start of the next header.
3033 If the current header is a continuation header, this can be several
3038 (if (looking-at "[ \t]+[^ \t]")
3042 (defun article-date-ut (&optional type highlight)
3043 "Convert DATE date to universal time in the current article.
3044 If TYPE is `local', convert to local time; if it is `lapsed', output
3045 how much time has lapsed since DATE. For `lapsed', the value of
3046 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
3047 should replace the \"Date:\" one, or should be added below it."
3048 (interactive (list 'ut t))
3049 (let* ((tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
3050 (date-regexp (cond ((not gnus-article-date-lapsed-new-header)
3054 (article-lapsed-timer
3058 (case-fold-search t)
3059 (inhibit-read-only t)
3060 (inhibit-point-motion-hooks t)
3061 pos date bface eface)
3065 (goto-char (point-min))
3066 (while (or (setq date (get-text-property (setq pos (point))
3068 (when (setq pos (next-single-property-change
3069 (point) 'original-date))
3070 (setq date (get-text-property pos 'original-date))
3072 (narrow-to-region pos (or (text-property-any pos (point-max)
3075 (goto-char (point-min))
3076 (when (re-search-forward tdate-regexp nil t)
3077 (setq bface (get-text-property (point-at-bol) 'face)
3078 eface (get-text-property (1- (point-at-eol)) 'face)))
3079 (goto-char (point-min))
3081 ;; Delete any old Date headers.
3082 (while (re-search-forward date-regexp nil t)
3084 (delete-region (point-at-bol) (progn
3085 (gnus-article-forward-header)
3087 (delete-region (point-at-bol) (progn
3088 (gnus-article-forward-header)
3091 (setq pos (point))))
3092 (when (and (not pos)
3093 (re-search-forward tdate-regexp nil t))
3095 (gnus-goto-char pos)
3096 (insert (article-make-date-line date (or type 'ut)))
3102 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
3103 (put-text-property (match-beginning 1) (1+ (match-end 1))
3105 (put-text-property (match-beginning 2) (match-end 2)
3107 (put-text-property (point-min) (1- (point-max)) 'original-date date)
3108 (goto-char (point-max))
3111 (defun article-make-date-line (date type)
3112 "Return a DATE line of TYPE."
3113 (unless (memq type '(local ut original user iso8601 lapsed english))
3114 (error "Unknown conversion type: %s" type))
3116 (let ((time (date-to-time date)))
3118 ;; Convert to the local timezone.
3120 (concat "Date: " (message-make-date time)))
3121 ;; Convert to Universal Time.
3126 (let* ((e (parse-time-string date))
3127 (tm (apply 'encode-time e))
3129 (ls (- (cadr tm) (car (current-time-zone time)))))
3130 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
3131 ((> ls 65535) (list (1+ ms) (- ls 65536)))
3135 ;; Get the original date from the article.
3136 ((eq type 'original)
3137 (concat "Date: " (if (string-match "\n+$" date)
3138 (substring date 0 (match-beginning 0))
3140 ;; Let the user define the format.
3142 (let ((format (or (condition-case nil
3143 (with-current-buffer gnus-summary-buffer
3144 gnus-article-time-format)
3146 gnus-article-time-format)))
3147 (if (functionp format)
3148 (funcall format time)
3149 (concat "Date: " (format-time-string format time)))))
3152 (let ((tz (car (current-time-zone time))))
3155 (format-time-string "%Y%m%dT%H%M%S" time)
3156 (format "%s%02d%02d"
3157 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
3158 (/ (% (abs tz) 3600) 60)))))
3159 ;; Do an X-Sent lapsed format.
3161 ;; If the date is seriously mangled, the timezone functions are
3162 ;; liable to bug out, so we ignore all errors.
3163 (let* ((now (current-time))
3164 (real-time (subtract-time now time))
3165 (real-sec (and real-time
3166 (+ (* (float (car real-time)) 65536)
3168 (sec (and real-time (abs real-sec)))
3178 ;; This is a bit convoluted, but basically we go
3179 ;; through the time units for years, weeks, etc,
3180 ;; and divide things to see whether that results
3181 ;; in positive answers.
3184 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
3185 ;; The (remaining) seconds are too few to
3186 ;; be divided into this time unit.
3188 ;; It's big enough, so we output it.
3189 (setq sec (- sec (* num (cdr unit))))
3191 (concat (if prev ", " "") (int-to-string
3193 " " (symbol-name (car unit))
3194 (if (> num 1) "s" ""))
3196 article-time-units "")
3197 ;; If dates are odd, then it might appear like the
3198 ;; article was sent in the future.
3201 " in the future"))))))
3202 ;; Display the date in proper English
3204 (let ((dtime (decode-time time)))
3207 (number-to-string (nth 3 dtime))
3208 (let ((digit (% (nth 3 dtime) 10)))
3210 ((memq (nth 3 dtime) '(11 12 13)) "th")
3216 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3218 (number-to-string (nth 5 dtime))
3220 (format "%02d" (nth 2 dtime))
3222 (format "%02d" (nth 1 dtime)))))))
3224 (format "Date: %s (from T-gnus)" date))))
3226 (defun article-date-local (&optional highlight)
3227 "Convert the current article date to the local timezone."
3228 (interactive (list t))
3229 (article-date-ut 'local highlight))
3231 (defun article-date-english (&optional highlight)
3232 "Convert the current article date to something that is proper English."
3233 (interactive (list t))
3234 (article-date-ut 'english highlight))
3236 (defun article-date-original (&optional highlight)
3237 "Convert the current article date to what it was originally.
3238 This is only useful if you have used some other date conversion
3239 function and want to see what the date was before converting."
3240 (interactive (list t))
3241 (article-date-ut 'original highlight))
3243 (defun article-date-lapsed (&optional highlight)
3244 "Convert the current article date to time lapsed since it was sent."
3245 (interactive (list t))
3246 (article-date-ut 'lapsed highlight))
3248 (defun article-update-date-lapsed ()
3249 "Function to be run from a timer to update the lapsed time line."
3251 (let (deactivate-mark)
3256 (set-buffer (window-buffer w))
3257 (when (or (and (eq major-mode 'mime-view-mode)
3258 (eq (mime-preview-original-major-mode)
3259 'gnus-original-article-mode))
3260 (eq major-mode 'gnus-article-mode))
3261 (let ((mark (point-marker)))
3262 (goto-char (point-min))
3263 (when (re-search-forward "^X-Sent:" nil t)
3264 (article-date-lapsed t))
3265 (goto-char (marker-position mark))
3266 (move-marker mark nil))))
3269 (defun gnus-start-date-timer (&optional n)
3270 "Start a timer to update the X-Sent header in the article buffers.
3271 The numerical prefix says how frequently (in seconds) the function
3276 (gnus-stop-date-timer)
3277 (setq article-lapsed-timer
3278 (run-at-time 1 n 'article-update-date-lapsed)))
3280 (defun gnus-stop-date-timer ()
3281 "Stop the X-Sent timer."
3283 (when article-lapsed-timer
3284 (nnheader-cancel-timer article-lapsed-timer)
3285 (setq article-lapsed-timer nil)))
3287 (defun article-date-user (&optional highlight)
3288 "Convert the current article date to the user-defined format.
3289 This format is defined by the `gnus-article-time-format' variable."
3290 (interactive (list t))
3291 (article-date-ut 'user highlight))
3293 (defun article-date-iso8601 (&optional highlight)
3294 "Convert the current article date to ISO8601."
3295 (interactive (list t))
3296 (article-date-ut 'iso8601 highlight))
3298 (defmacro gnus-article-save-original-date (&rest forms)
3299 "Save the original date as a text property and evaluate FORMS."
3300 `(let* ((case-fold-search t)
3302 (goto-char (point-min))
3303 (when (and (re-search-forward "^date:[\t\n ]+" nil t)
3306 (date (when (and start
3307 (re-search-forward "[\t ]*\n\\(?:[^\t ]\\|\\'\\)"
3309 (buffer-substring-no-properties start
3310 (match-beginning 0)))))
3311 (goto-char (point-max))
3312 (skip-chars-backward "\n")
3313 (put-text-property (point-min) (point) 'original-date date)
3315 (goto-char (point-max))
3316 (skip-chars-backward "\n")
3317 (put-text-property (point-min) (point) 'original-date date)))
3319 ;; (defun article-show-all ()
3320 ;; "Show all hidden text in the article buffer."
3324 ;; (let ((inhibit-read-only t))
3325 ;; (gnus-article-unhide-text (point-min) (point-max))
3326 ;; (gnus-remove-text-with-property 'gnus-prev)
3327 ;; (gnus-remove-text-with-property 'gnus-next))))
3329 (defun article-show-all-headers ()
3330 "Show all hidden headers in the article buffer."
3335 (article-narrow-to-head)
3336 (let ((inhibit-read-only t))
3337 (gnus-article-unhide-text (point-min) (point-max))))))
3339 (defun article-remove-leading-whitespace ()
3340 "Remove excessive whitespace from all headers."
3344 (let ((inhibit-read-only t))
3345 (article-narrow-to-head)
3346 (goto-char (point-min))
3347 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3348 (delete-region (match-beginning 1) (match-end 1)))))))
3350 (defun article-emphasize (&optional arg)
3351 "Emphasize text according to `gnus-emphasis-alist'."
3352 (interactive (gnus-article-hidden-arg))
3353 (unless (gnus-article-check-hidden-text 'emphasis arg)
3357 (with-current-buffer gnus-summary-buffer
3358 gnus-article-emphasis-alist)
3360 gnus-emphasis-alist))
3361 (inhibit-read-only t)
3362 (props (append '(article-type emphasis)
3363 gnus-hidden-properties))
3364 regexp elem beg invisible visible face)
3367 (while (setq elem (pop alist))
3369 (setq regexp (car elem)
3370 invisible (nth 1 elem)
3371 visible (nth 2 elem)
3373 (while (re-search-forward regexp nil t)
3374 (when (and (match-beginning visible) (match-beginning invisible))
3375 (gnus-article-hide-text
3376 (match-beginning invisible) (match-end invisible) props)
3377 (gnus-article-unhide-text-type
3378 (match-beginning visible) (match-end visible) 'emphasis)
3379 (gnus-put-overlay-excluding-newlines
3380 (match-beginning visible) (match-end visible) 'face face)
3381 (gnus-add-wash-type 'emphasis)
3382 (goto-char (match-end invisible)))))))))
3384 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3385 "Setup newsgroup emphasis alist."
3386 (unless gnus-article-emphasis-alist
3387 (let ((name (and gnus-newsgroup-name
3388 (gnus-group-real-name gnus-newsgroup-name))))
3389 (make-local-variable 'gnus-article-emphasis-alist)
3390 (setq gnus-article-emphasis-alist
3392 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3393 (while (setq elem (pop alist))
3394 (when (and name (string-match (car elem) name))
3396 highlight (copy-sequence (cdr elem)))))
3398 (copy-sequence highlight-words)
3399 (if gnus-newsgroup-name
3400 (copy-sequence (gnus-group-find-parameter
3401 gnus-newsgroup-name 'highlight-words t)))
3402 gnus-emphasis-alist)))))
3405 (defvar gnus-summary-article-menu)
3406 (defvar gnus-summary-post-menu))
3408 ;;; Saving functions.
3410 (defun gnus-article-save (save-buffer file &optional num)
3411 "Save the currently selected article."
3412 (unless gnus-save-all-headers
3413 ;; Remove headers according to `gnus-saved-headers'.
3414 (let ((gnus-visible-headers
3415 (or gnus-saved-headers gnus-visible-headers))
3416 (gnus-article-buffer save-buffer))
3418 (set-buffer save-buffer)
3419 (article-hide-headers 1 t))))
3420 (save-window-excursion
3421 (if (not gnus-default-article-saver)
3422 (error "No default saver is defined")
3423 ;; !!! Magic! The saving functions all save
3424 ;; `gnus-save-article-buffer' (or so they think), but we
3425 ;; bind that variable to our save-buffer.
3426 (set-buffer gnus-article-buffer)
3427 (let* ((gnus-save-article-buffer save-buffer)
3430 ((not gnus-prompt-before-saving) 'default)
3431 ((eq gnus-prompt-before-saving 'always) nil)
3433 (gnus-number-of-articles-to-be-saved
3434 (when (eq gnus-prompt-before-saving t)
3436 (set-buffer gnus-article-current-summary)
3437 (funcall gnus-default-article-saver filename)))))
3439 (defun gnus-read-save-file-name (prompt &optional filename
3440 function group headers variable)
3442 (funcall function group headers (symbol-value variable)))
3447 ((eq filename 'default)
3453 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3456 (if (and gnus-number-of-articles-to-be-saved
3457 (> gnus-number-of-articles-to-be-saved 1))
3458 (format "these %d articles"
3459 gnus-number-of-articles-to-be-saved)
3462 ;; Let the split methods have their say.
3464 ;; No split name was found.
3467 (concat prompt " (default "
3468 (file-name-nondirectory default-name) "): ")
3469 (file-name-directory default-name)
3471 ;; A single group name is returned.
3472 ((stringp split-name)
3474 (funcall function split-name headers
3475 (symbol-value variable)))
3477 (concat prompt " (default "
3478 (file-name-nondirectory default-name) "): ")
3479 (file-name-directory default-name)
3481 ;; A single split name was found
3482 ((= 1 (length split-name))
3483 (let* ((name (expand-file-name
3485 gnus-article-save-directory))
3486 (dir (cond ((file-directory-p name)
3487 (file-name-as-directory name))
3488 ((file-exists-p name) name)
3489 (t gnus-article-save-directory))))
3491 (concat prompt " (default " name "): ")
3493 ;; A list of splits was found.
3495 (setq split-name (nreverse split-name))
3497 (let ((file-name-history
3498 (nconc split-name file-name-history)))
3502 (concat prompt " (`M-p' for defaults): ")
3503 gnus-article-save-directory
3505 gnus-article-save-directory)))
3506 (car (push result file-name-history)))))))
3507 ;; Create the directory.
3508 (gnus-make-directory (file-name-directory file))
3509 ;; If we have read a directory, we append the default file name.
3510 (when (file-directory-p file)
3511 (setq file (expand-file-name (file-name-nondirectory
3513 (file-name-as-directory file))))
3514 ;; Possibly translate some characters.
3515 (nnheader-translate-file-chars file))))))
3516 (gnus-make-directory (file-name-directory result))
3517 (set variable result)))
3519 (defun gnus-article-archive-name (group)
3520 "Return the first instance of an \"Archive-name\" in the current buffer."
3521 (let ((case-fold-search t))
3522 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3523 (nnheader-concat gnus-article-save-directory
3524 (match-string 1)))))
3526 (defun gnus-article-nndoc-name (group)
3527 "If GROUP is an nndoc group, return the name of the parent group."
3528 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3529 (gnus-group-get-parameter group 'save-article-group)))
3531 (defun gnus-summary-save-in-rmail (&optional filename)
3532 "Append this article to Rmail file.
3533 Optional argument FILENAME specifies file name.
3534 Directory to save to is default to `gnus-article-save-directory'."
3535 (setq filename (gnus-read-save-file-name
3536 "Save %s in rmail file" filename
3537 gnus-rmail-save-name gnus-newsgroup-name
3538 gnus-current-headers 'gnus-newsgroup-last-rmail))
3539 (gnus-eval-in-buffer-window gnus-save-article-buffer
3543 (gnus-output-to-rmail filename))))
3546 (defun gnus-summary-save-in-mail (&optional filename)
3547 "Append this article to Unix mail file.
3548 Optional argument FILENAME specifies file name.
3549 Directory to save to is default to `gnus-article-save-directory'."
3550 (setq filename (gnus-read-save-file-name
3551 "Save %s in Unix mail file" filename
3552 gnus-mail-save-name gnus-newsgroup-name
3553 gnus-current-headers 'gnus-newsgroup-last-mail))
3554 (gnus-eval-in-buffer-window gnus-save-article-buffer
3558 (if (and (file-readable-p filename)
3559 (file-regular-p filename)
3560 (mail-file-babyl-p filename))
3561 (rmail-output-to-rmail-file filename t)
3562 (gnus-output-to-mail filename)))))
3565 (defun gnus-summary-save-in-file (&optional filename overwrite)
3566 "Append this article to file.
3567 Optional argument FILENAME specifies file name.
3568 Directory to save to is default to `gnus-article-save-directory'."
3569 (setq filename (gnus-read-save-file-name
3570 "Save %s in file" filename
3571 gnus-file-save-name gnus-newsgroup-name
3572 gnus-current-headers 'gnus-newsgroup-last-file))
3573 (gnus-eval-in-buffer-window gnus-save-article-buffer
3577 (when (and overwrite
3578 (file-exists-p filename))
3579 (delete-file filename))
3580 (gnus-output-to-file filename))))
3583 (defun gnus-summary-write-to-file (&optional filename)
3584 "Write this article to a file, overwriting it if the file exists.
3585 Optional argument FILENAME specifies file name.
3586 The directory to save in defaults to `gnus-article-save-directory'."
3587 (gnus-summary-save-in-file nil t))
3589 (defun gnus-summary-save-body-in-file (&optional filename)
3590 "Append this article body to a file.
3591 Optional argument FILENAME specifies file name.
3592 The directory to save in defaults to `gnus-article-save-directory'."
3593 (setq filename (gnus-read-save-file-name
3594 "Save %s body in file" filename
3595 gnus-file-save-name gnus-newsgroup-name
3596 gnus-current-headers 'gnus-newsgroup-last-file))
3597 (gnus-eval-in-buffer-window gnus-save-article-buffer
3601 (when (article-goto-body)
3602 (narrow-to-region (point) (point-max)))
3603 (gnus-output-to-file filename))))
3606 (defun gnus-summary-save-in-pipe (&optional command)
3607 "Pipe this article to subprocess."
3609 (cond ((and (eq command 'default)
3610 gnus-last-shell-command)
3611 gnus-last-shell-command)
3616 "Shell command on %s: "
3617 (if (and gnus-number-of-articles-to-be-saved
3618 (> gnus-number-of-articles-to-be-saved 1))
3619 (format "these %d articles"
3620 gnus-number-of-articles-to-be-saved)
3622 gnus-last-shell-command))))
3623 (when (string-equal command "")
3624 (if gnus-last-shell-command
3625 (setq command gnus-last-shell-command)
3626 (error "A command is required")))
3627 (gnus-eval-in-buffer-window gnus-article-buffer
3630 (shell-command-on-region (point-min) (point-max) command nil)))
3631 (setq gnus-last-shell-command command))
3633 (defun gnus-summary-pipe-to-muttprint (&optional command)
3634 "Pipe this article to muttprint."
3635 (setq command (read-string
3636 "Print using command: " gnus-summary-muttprint-program
3637 nil gnus-summary-muttprint-program))
3638 (gnus-summary-save-in-pipe command))
3640 ;;; Article file names when saving.
3642 (defun gnus-capitalize-newsgroup (newsgroup)
3643 "Capitalize NEWSGROUP name."
3644 (when (not (zerop (length newsgroup)))
3645 (concat (char-to-string (upcase (aref newsgroup 0)))
3646 (substring newsgroup 1))))
3648 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3649 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3650 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3651 Otherwise, it is like ~/News/news/group/num."
3654 (concat (if (gnus-use-long-file-name 'not-save)
3655 (gnus-capitalize-newsgroup newsgroup)
3656 (gnus-newsgroup-directory-form newsgroup))
3657 "/" (int-to-string (mail-header-number headers)))
3658 gnus-article-save-directory)))
3660 (string-equal (file-name-directory default)
3661 (file-name-directory last-file))
3662 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3664 (or last-file default))))
3666 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3667 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3668 If variable `gnus-use-long-file-name' is non-nil, it is
3669 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3672 (concat (if (gnus-use-long-file-name 'not-save)
3674 (gnus-newsgroup-directory-form newsgroup))
3675 "/" (int-to-string (mail-header-number headers)))
3676 gnus-article-save-directory)))
3678 (string-equal (file-name-directory default)
3679 (file-name-directory last-file))
3680 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3682 (or last-file default))))
3684 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3685 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3686 If variable `gnus-use-long-file-name' is non-nil, it is
3687 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3690 (if (gnus-use-long-file-name 'not-save)
3693 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3695 gnus-article-save-directory)))
3697 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3698 "Generate file name from sender."
3699 (let ((from (mail-header-from headers)))
3701 (if (and from (string-match "\\([^ <]+\\)@" from))
3702 (match-string 1 from)
3704 gnus-article-save-directory)))
3706 (defun article-verify-x-pgp-sig ()
3709 (if (gnus-buffer-live-p gnus-original-article-buffer)
3710 (let ((sig (with-current-buffer gnus-original-article-buffer
3711 (gnus-fetch-field "X-PGP-Sig")))
3715 (mml2015-clear-verify-function))
3717 (insert-buffer-substring gnus-original-article-buffer)
3718 (setq items (split-string sig))
3719 (message-narrow-to-head)
3720 (let ((inhibit-point-motion-hooks t)
3721 (case-fold-search t))
3722 ;; Don't verify multiple headers.
3723 (setq headers (mapconcat (lambda (header)
3725 (mail-fetch-field header)
3727 (split-string (nth 1 items) ",") "")))
3728 (delete-region (point-min) (point-max))
3729 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3730 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3735 (if (looking-at "^-")
3738 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3739 (insert "Version: " (car items) "\n\n")
3740 (insert (mapconcat 'identity (cddr items) "\n"))
3741 (insert "\n-----END PGP SIGNATURE-----\n")
3742 (let ((mm-security-handle (list (format "multipart/signed"))))
3743 (mml2015-clean-buffer)
3744 (let ((coding-system-for-write (or gnus-newsgroup-charset
3746 (funcall (mml2015-clear-verify-function)))
3748 (or (mm-handle-multipart-ctl-parameter
3749 mm-security-handle 'gnus-details)
3750 (mm-handle-multipart-ctl-parameter
3751 mm-security-handle 'gnus-info)))))
3753 (let ((inhibit-read-only t) bface eface)
3755 (message-narrow-to-head)
3756 (goto-char (point-max))
3758 (setq bface (get-text-property (point-at-bol) 'face)
3759 eface (get-text-property (1- (point-at-eol)) 'face))
3760 (message-remove-header "X-Gnus-PGP-Verify")
3761 (if (re-search-forward "^X-PGP-Sig:" nil t)
3763 (goto-char (point-max)))
3764 (narrow-to-region (point) (point))
3765 (insert "X-Gnus-PGP-Verify: " info "\n")
3766 (goto-char (point-min))
3769 (if (not (looking-at "^[ \t]"))
3773 (goto-char (point-min))
3774 (when (looking-at "\\([^:]+\\): *")
3775 (put-text-property (match-beginning 1) (1+ (match-end 1))
3777 (put-text-property (match-end 0) (point-max)
3778 'face eface)))))))))
3780 (defun article-verify-cancel-lock ()
3781 "Verify Cancel-Lock header."
3783 (if (gnus-buffer-live-p gnus-original-article-buffer)
3784 (canlock-verify gnus-original-article-buffer)))
3786 (defun article-monafy ()
3787 "Display body part with mona font."
3789 (unless (if (featurep 'xemacs)
3790 (find-face 'gnus-mona-face)
3791 (facep 'gnus-mona-face))
3792 (require 'navi2ch-mona)
3793 (set-face-font (make-face 'gnus-mona-face) navi2ch-mona-font))
3795 (let ((inhibit-read-only t))
3798 (gnus-make-overlay (point) (point-max))
3799 'face 'gnus-mona-face))))
3806 (setq afunc (car func)
3809 gfunc (intern (format "gnus-%s" func))))
3811 (when (fboundp afunc)
3812 `(lambda (&optional interactive &rest args)
3813 ,(documentation afunc t)
3814 (interactive (list t))
3816 (set-buffer gnus-article-buffer)
3818 (call-interactively ',afunc)
3819 (apply ',afunc args))))))))
3820 '(article-hide-headers
3821 article-verify-x-pgp-sig
3822 article-verify-cancel-lock
3824 article-hide-boring-headers
3825 article-treat-overstrike
3826 article-treat-ansi-sequences
3827 article-fill-long-lines
3828 article-capitalize-sentences
3830 article-remove-leading-whitespace
3831 article-display-x-face
3832 article-display-face
3833 article-de-quoted-unreadable
3834 article-de-base64-unreadable
3837 article-unsplit-urls
3838 article-hide-list-identifiers
3839 article-strip-banner
3842 article-hide-signature
3843 article-strip-headers-in-body
3844 article-remove-trailing-blank-lines
3845 article-strip-leading-blank-lines
3846 article-strip-multiple-blank-lines
3847 article-strip-leading-space
3848 article-strip-trailing-space
3849 article-strip-blank-lines
3850 article-strip-all-blank-lines
3852 article-date-english
3853 article-date-iso8601
3854 article-date-original
3856 article-decode-mime-words
3857 article-decode-charset
3858 article-decode-encoded-words
3862 article-treat-dumbquotes
3863 article-normalize-headers
3864 (article-show-all-headers . gnus-article-show-all-headers)
3865 ;; (article-show-all . gnus-article-show-all)
3869 ;;; Gnus article mode
3872 (put 'gnus-article-mode 'mode-class 'special)
3874 (gnus-define-keys gnus-article-mode-map
3875 " " gnus-article-goto-next-page
3876 "\177" gnus-article-goto-prev-page
3877 [delete] gnus-article-goto-prev-page
3878 [backspace] gnus-article-goto-prev-page
3879 "\C-c^" gnus-article-refer-article
3880 "h" gnus-article-show-summary
3881 "s" gnus-article-show-summary
3882 "\C-c\C-m" gnus-article-mail
3883 "?" gnus-article-describe-briefly
3884 "e" gnus-summary-edit-article
3885 "<" beginning-of-buffer
3887 "\C-c\C-i" gnus-info-find-node
3889 "R" gnus-article-reply-with-original
3890 "F" gnus-article-followup-with-original
3891 "\C-hk" gnus-article-describe-key
3892 "\C-hc" gnus-article-describe-key-briefly
3894 "\C-d" gnus-article-read-summary-keys
3895 "\M-*" gnus-article-read-summary-keys
3896 "\M-#" gnus-article-read-summary-keys
3897 "\M-^" gnus-article-read-summary-keys
3898 "\M-g" gnus-article-read-summary-keys)
3900 ;; Define almost undefined keys to `gnus-article-read-summary-keys'.
3904 (push (char-to-string key) keys)
3906 (dolist (elem (accessible-keymaps gnus-summary-mode-map))
3907 (setq key (car elem))
3908 (when (and (> (length key) 0)
3909 (not (eq 'menu-bar (aref key 0)))
3910 (symbolp (lookup-key gnus-summary-mode-map key)))
3913 (unless (lookup-key gnus-article-mode-map key)
3914 (define-key gnus-article-mode-map key 'gnus-article-read-summary-keys))))
3916 (defun gnus-article-make-menu-bar ()
3917 (unless (boundp 'gnus-article-commands-menu)
3918 (gnus-summary-make-menu-bar))
3919 (gnus-turn-off-edit-menu 'article)
3920 (unless (boundp 'gnus-article-article-menu)
3922 gnus-article-article-menu gnus-article-mode-map ""
3924 ["Scroll forwards" gnus-article-goto-next-page t]
3925 ["Scroll backwards" gnus-article-goto-prev-page t]
3926 ["Show summary" gnus-article-show-summary t]
3927 ["Fetch Message-ID at point" gnus-article-refer-article t]
3928 ["Mail to address at point" gnus-article-mail t]
3929 ["Send a bug report" gnus-bug t]))
3932 gnus-article-treatment-menu gnus-article-mode-map ""
3933 ;; Fixme: this should use :active (and maybe :visible).
3935 ["Hide headers" gnus-article-hide-headers t]
3936 ["Hide signature" gnus-article-hide-signature t]
3937 ["Hide citation" gnus-article-hide-citation t]
3938 ["Treat overstrike" gnus-article-treat-overstrike t]
3939 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
3940 ["Remove carriage return" gnus-article-remove-cr t]
3941 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3942 ["Treat html" gnus-article-wash-html t]
3943 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3944 ["Decode HZ" gnus-article-decode-HZ t]))
3946 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3948 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3950 (gnus-run-hooks 'gnus-article-menu-hook)))
3952 (defun gnus-article-mode ()
3953 "Major mode for displaying an article.
3955 All normal editing commands are switched off.
3957 The following commands are available in addition to all summary mode
3959 \\<gnus-article-mode-map>
3960 \\[gnus-article-next-page]\t Scroll the article one page forwards
3961 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3962 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3963 \\[gnus-article-show-summary]\t Display the summary buffer
3964 \\[gnus-article-mail]\t Send a reply to the address near point
3965 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3966 \\[gnus-info-find-node]\t Go to the Gnus info node"
3968 (kill-all-local-variables)
3969 (gnus-simplify-mode-line)
3970 (setq mode-name "Article")
3971 (setq major-mode 'gnus-article-mode)
3972 (make-local-variable 'minor-mode-alist)
3973 (unless (assq 'gnus-show-mime minor-mode-alist)
3974 (push (list 'gnus-show-mime " MIME") minor-mode-alist))
3975 (use-local-map gnus-article-mode-map)
3976 (when (gnus-visual-p 'article-menu 'menu)
3977 (gnus-article-make-menu-bar)
3978 (when gnus-summary-tool-bar-map
3979 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3980 (gnus-update-format-specifications nil 'article-mode)
3981 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3982 (set (make-local-variable 'gnus-page-broken) nil)
3983 (make-local-variable 'gnus-button-marker-list)
3984 (make-local-variable 'gnus-article-current-summary)
3985 (make-local-variable 'gnus-article-mime-handles)
3986 (make-local-variable 'gnus-article-decoded-p)
3987 (make-local-variable 'gnus-article-mime-handle-alist)
3988 (make-local-variable 'gnus-article-wash-types)
3989 (make-local-variable 'gnus-article-image-alist)
3990 (make-local-variable 'gnus-article-charset)
3991 (make-local-variable 'gnus-article-ignored-charsets)
3992 ;; Prevent recent Emacsen from displaying non-break space as "\ ".
3993 (set (make-local-variable 'nobreak-char-display) nil)
3994 (gnus-set-default-directory)
3995 (buffer-disable-undo)
3996 (setq buffer-read-only t
3997 show-trailing-whitespace nil)
3998 (set-syntax-table gnus-article-mode-syntax-table)
3999 (gnus-run-mode-hooks 'gnus-article-mode-hook))
4001 (defun gnus-article-setup-buffer ()
4002 "Initialize the article buffer."
4003 (let* ((name (if gnus-single-article-buffer "*Article*"
4004 (concat "*Article " gnus-newsgroup-name "*")))
4006 (progn (string-match "\\*Article" name)
4007 (concat " *Original Article"
4008 (substring name (match-end 0))))))
4009 (setq gnus-article-buffer name)
4010 (setq gnus-original-article-buffer original)
4011 (setq gnus-article-mime-handle-alist nil)
4012 ;; This might be a variable local to the summary buffer.
4013 (unless gnus-single-article-buffer
4015 (set-buffer gnus-summary-buffer)
4016 (setq gnus-article-buffer name)
4017 (setq gnus-original-article-buffer original)
4018 (gnus-set-global-variables)))
4019 (gnus-article-setup-highlight-words)
4020 ;; Init original article buffer.
4022 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
4023 (set-buffer-multibyte t)
4024 (setq major-mode 'gnus-original-article-mode)
4025 (make-local-variable 'gnus-original-article))
4026 (if (and (get-buffer name)
4027 (with-current-buffer name
4028 (if gnus-article-edit-mode
4029 (if (y-or-n-p "Article mode edit in progress; discard? ")
4031 (set-buffer-modified-p nil)
4032 (gnus-kill-buffer name)
4035 (error "Action aborted"))
4039 (set (make-local-variable 'gnus-article-edit-mode) nil)
4040 (buffer-disable-undo)
4041 (setq buffer-read-only t)
4042 ;; This list just keeps growing if we don't reset it.
4043 (setq gnus-button-marker-list nil)
4044 (unless (eq major-mode 'gnus-article-mode)
4045 (gnus-article-mode))
4048 (set-buffer (gnus-get-buffer-create name))
4050 (make-local-variable 'gnus-summary-buffer)
4051 (gnus-summary-set-local-parameters gnus-newsgroup-name)
4052 (current-buffer)))))
4054 ;; Set article window start at LINE, where LINE is the number of lines
4055 ;; from the head of the article.
4056 (defun gnus-article-set-window-start (&optional line)
4058 (gnus-get-buffer-window gnus-article-buffer t)
4060 (set-buffer gnus-article-buffer)
4061 (goto-char (point-min))
4064 (gnus-message 6 "Moved to bookmark")
4065 (search-forward "\n\n" nil t)
4069 ;;; @@ article filters
4072 (defun gnus-article-display-mime-message ()
4073 "Article display method for MIME message."
4074 ;; called from `gnus-original-article-buffer'.
4075 (let (charset all-headers)
4076 (with-current-buffer gnus-summary-buffer
4077 (setq charset default-mime-charset
4078 all-headers gnus-have-all-headers))
4079 (make-local-variable 'default-mime-charset)
4080 (setq default-mime-charset charset)
4081 (with-current-buffer (get-buffer-create gnus-article-buffer)
4082 (make-local-variable 'default-mime-charset)
4083 (setq default-mime-charset charset))
4084 (mime-display-message mime-message-structure
4085 gnus-article-buffer nil gnus-article-mode-map)
4087 (gnus-article-hide-headers nil -1)))
4088 (run-hooks 'gnus-mime-article-prepare-hook))
4090 (defun gnus-article-display-traditional-message ()
4091 "Article display method for traditional message."
4092 (set-buffer gnus-article-buffer)
4093 (let ((inhibit-read-only t))
4095 (insert-buffer-substring gnus-original-article-buffer)))
4097 (defun gnus-article-make-full-mail-header (&optional number charset)
4098 "Create a new mail header structure in a raw article buffer."
4099 (unless (and number charset)
4100 (save-current-buffer
4101 (set-buffer gnus-summary-buffer)
4103 (setq number (or (cdr gnus-article-current) 0)))
4105 (setq charset (or default-mime-charset 'x-ctext)))))
4106 (goto-char (point-min))
4107 (let ((header-end (if (search-forward "\n\n" nil t)
4109 (goto-char (point-max))))
4110 (chars (- (point-max) (point)))
4111 (lines (count-lines (point) (point-max)))
4112 (default-mime-charset charset)
4114 (narrow-to-region (point-min) header-end)
4115 (setq xref (std11-fetch-field "xref"))
4117 (make-full-mail-header
4119 (std11-fetch-field "subject")
4120 (std11-fetch-field "from")
4121 (std11-fetch-field "date")
4122 (std11-fetch-field "message-id")
4123 (std11-fetch-field "references")
4126 (when xref (concat "Xref: " xref)))
4129 (defun gnus-article-prepare (article &optional all-headers header)
4130 "Prepare ARTICLE in article mode buffer.
4131 ARTICLE should either be an article number or a Message-ID.
4132 If ARTICLE is an id, HEADER should be the article headers.
4133 If ALL-HEADERS is non-nil, no headers are hidden."
4135 ;; Make sure we start in a summary buffer.
4136 (unless (eq major-mode 'gnus-summary-mode)
4137 (set-buffer gnus-summary-buffer))
4138 (setq gnus-summary-buffer (current-buffer))
4139 (let* ((gnus-article (if header (mail-header-number header) article))
4140 (summary-buffer (current-buffer))
4141 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
4142 (group gnus-newsgroup-name)
4145 (gnus-article-setup-buffer)
4146 (set-buffer gnus-article-buffer)
4147 ;; Deactivate active regions.
4148 (when (and (boundp 'transient-mark-mode)
4149 transient-mark-mode)
4150 (setq mark-active nil))
4151 (if (not (setq result (let ((inhibit-read-only t))
4152 (gnus-request-article-this-buffer
4154 ;; There is no such article.
4156 (when (and (numberp article)
4157 (not (memq article gnus-newsgroup-sparse)))
4158 (setq gnus-article-current
4159 (cons gnus-newsgroup-name article))
4160 (set-buffer gnus-summary-buffer)
4161 (setq gnus-current-article article)
4162 (if (and (memq article gnus-newsgroup-undownloaded)
4163 (not (gnus-online (gnus-find-method-for-group
4164 gnus-newsgroup-name))))
4166 (gnus-summary-set-agent-mark article)
4167 (message "Message marked for downloading"))
4168 (gnus-summary-mark-article article gnus-canceled-mark)
4169 (unless (memq article gnus-newsgroup-sparse)
4170 (gnus-error 1 "No such article (may have expired or been canceled)")))))
4171 (if (or (eq result 'pseudo)
4172 (eq result 'nneething))
4175 (set-buffer summary-buffer)
4176 (push article gnus-newsgroup-history)
4177 (setq gnus-last-article gnus-current-article
4178 gnus-current-article 0
4179 gnus-current-headers nil
4180 gnus-article-current nil)
4181 (if (eq result 'nneething)
4182 (gnus-configure-windows 'summary)
4183 (gnus-configure-windows 'article))
4184 (gnus-set-global-variables))
4185 (let ((gnus-article-mime-handle-alist-1
4186 gnus-article-mime-handle-alist))
4187 (gnus-set-mode-line 'article)))
4188 ;; The result from the `request' was an actual article -
4189 ;; or at least some text that is now displayed in the
4191 (when (and (numberp article)
4192 (not (eq article gnus-current-article)))
4193 ;; Seems like a new article has been selected.
4194 ;; `gnus-current-article' must be an article number.
4196 (set-buffer summary-buffer)
4197 (push article gnus-newsgroup-history)
4198 (setq gnus-last-article gnus-current-article
4199 gnus-current-article article
4200 gnus-current-headers
4201 (gnus-summary-article-header gnus-current-article)
4202 gnus-article-current
4203 (cons gnus-newsgroup-name gnus-current-article))
4204 (unless (vectorp gnus-current-headers)
4205 (setq gnus-current-headers nil))
4206 (gnus-summary-goto-subject gnus-current-article)
4207 (when (gnus-summary-show-thread)
4208 ;; If the summary buffer really was folded, the
4209 ;; previous goto may not actually have gone to
4210 ;; the right article, but the thread root instead.
4212 (gnus-summary-goto-subject gnus-current-article))
4213 (gnus-run-hooks 'gnus-mark-article-hook)
4214 (gnus-set-mode-line 'summary)
4215 (when (gnus-visual-p 'article-highlight 'highlight)
4216 (gnus-run-hooks 'gnus-visual-mark-article-hook))
4217 ;; Set the global newsgroup variables here.
4218 (gnus-set-global-variables)
4219 (setq gnus-have-all-headers
4220 (or all-headers gnus-show-all-headers))))
4222 (gnus-configure-windows 'article))
4223 (when (or (numberp article)
4225 (gnus-article-prepare-display)
4227 (goto-char (point-min))
4228 (when gnus-break-pages
4229 (gnus-narrow-to-page)))
4230 (let ((gnus-article-mime-handle-alist-1
4231 gnus-article-mime-handle-alist))
4232 (gnus-set-mode-line 'article))
4236 (set-window-point (get-buffer-window (current-buffer)) (point))
4237 (gnus-configure-windows 'article)
4240 (defun gnus-article-prepare-mime-display (&optional number)
4241 (goto-char (point-min))
4242 (when (re-search-forward "^[^\t ]+:" nil t)
4243 (goto-char (match-beginning 0)))
4244 (let ((entity (if (eq 1 (point-min))
4245 (get-text-property 1 'mime-view-entity)
4246 (get-text-property (point) 'mime-view-entity)))
4247 last-entity child-entity next type)
4248 (setq child-entity (mime-entity-children entity))
4250 (setq last-entity (nth (1- (length child-entity))
4252 (setq last-entity entity))
4254 (narrow-to-region (point)
4255 (if (search-forward "\n\n" nil t)
4258 (gnus-article-save-original-date (gnus-treat-article 'head))
4259 (put-text-property (point-min) (point-max) 'article-treated-header t)
4260 (goto-char (point-max)))
4261 (while (and (not (eobp)) entity)
4262 (setq next (set-marker
4264 (next-single-property-change (point) 'mime-view-entity
4266 (let ((types (mime-entity-content-type entity)))
4267 (while (eq 'multipart (mime-content-type-primary-type types))
4268 (setq entity (car (mime-entity-children entity))
4269 types (mime-entity-content-type entity)))
4271 (setq type (format "%s/%s"
4272 (mime-content-type-primary-type types)
4273 (mime-content-type-subtype types)))))
4274 (if (string-equal type "message/rfc822")
4277 (let ((children (mime-entity-children entity))
4280 (setq last-children (nth (1- (length children)) children))
4283 (not (eq last-children
4284 (get-text-property next 'mime-view-entity)))
4286 (next-single-property-change next
4288 nil (point-max)))))))
4289 (setq next (next-single-property-change next 'mime-view-entity
4292 (narrow-to-region (point) next)
4293 (gnus-article-prepare-mime-display)
4294 (goto-char (point-max)))
4295 (setq entity (get-text-property (point) 'mime-view-entity)))
4297 (narrow-to-region (point) next)
4298 ;; Kludge. We have to count true number, but for now,
4299 ;; part number is here only to achieve `last'.
4300 (gnus-treat-article nil 1
4301 (if (eq entity last-entity)
4304 (goto-char (point-max)))
4305 (setq entity (get-text-property next 'mime-view-entity))))))
4308 (defun gnus-article-prepare-display ()
4309 "Make the current buffer look like a nice article."
4310 (let ((gnus-article-buffer (current-buffer))
4312 (inhibit-read-only t))
4313 (unless (eq major-mode 'gnus-article-mode)
4314 (gnus-article-mode))
4315 (setq buffer-read-only nil
4316 gnus-button-marker-list nil
4317 gnus-article-wash-types nil
4318 gnus-article-image-alist nil)
4321 (static-if (featurep 'xemacs)
4322 (map-extents (lambda (extent maparg) (delete-extent extent)))
4323 (let ((lists (overlay-lists)))
4324 (dolist (overlay (nconc (car lists) (cdr lists)))
4325 (delete-overlay overlay)))))
4326 (gnus-run-hooks 'gnus-tmp-internal-hook))
4327 (let ((show-mime (unless (member gnus-newsgroup-name '("nndraft:delayed"
4330 (inhibit-read-only t))
4331 (set-buffer gnus-original-article-buffer)
4333 (setq mime-message-structure gnus-current-headers)
4334 (mime-buffer-entity-set-buffer-internal mime-message-structure
4335 gnus-original-article-buffer)
4336 (mime-entity-set-representation-type-internal mime-message-structure
4337 'mime-buffer-entity)
4338 (luna-send mime-message-structure 'initialize-instance
4339 mime-message-structure)
4341 (let (mime-display-header-hook mime-display-text/plain-hook)
4342 (funcall gnus-article-display-method-for-mime))
4343 (funcall gnus-article-display-method-for-traditional))
4344 ;; Call the treatment functions.
4348 (gnus-article-prepare-mime-display)
4349 (narrow-to-region (goto-char (point-min))
4350 (if (search-forward "\n\n" nil t)
4353 (gnus-article-save-original-date (gnus-treat-article 'head))
4354 (put-text-property (point-min) (point-max) 'article-treated-header t)
4355 (goto-char (point-max))
4357 (narrow-to-region (point) (point-max))
4358 (gnus-treat-article nil))
4359 (put-text-property (point-min) (point-max) 'read-only nil)))
4360 (gnus-run-hooks 'gnus-article-prepare-hook))
4362 (defun gnus-article-decode-article-as-default-mime-charset ()
4363 "Decode an article as `default-mime-charset'. It won't work if the
4364 value of the variable `gnus-show-mime' is non-nil."
4365 (unless (or gnus-show-mime
4366 (member gnus-newsgroup-name '("nndraft:delayed"
4368 (set (make-local-variable 'default-mime-charset)
4369 (with-current-buffer gnus-summary-buffer
4370 default-mime-charset))
4371 (decode-mime-charset-region (point-min) (point-max)
4372 default-mime-charset)))
4375 ;;; Gnus MIME viewing functions
4378 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4379 "Format of the MIME buttons.
4381 Valid specifiers include:
4383 %T MIME type, along with additional info
4384 %n The `name' parameter
4385 %d The description, if any
4386 %l The length of the encoded part
4387 %p The part identifier number
4388 %e Dots if the part isn't displayed
4390 General format specifiers can also be used. See Info node
4391 `(gnus)Formatting Variables'.")
4393 (defvar gnus-mime-button-line-format-alist
4394 '((?t gnus-tmp-type ?s)
4395 (?T gnus-tmp-type-long ?s)
4396 (?n gnus-tmp-name ?s)
4397 (?d gnus-tmp-description ?s)
4399 (?l gnus-tmp-length ?d)
4400 (?e gnus-tmp-dots ?s)))
4402 (defvar gnus-mime-button-commands
4403 '((gnus-article-press-button "\r" "Toggle Display")
4404 (gnus-mime-view-part "v" "View Interactively...")
4405 (gnus-mime-view-part-as-type "t" "View As Type...")
4406 (gnus-mime-view-part-as-charset "C" "View As charset...")
4407 (gnus-mime-save-part "o" "Save...")
4408 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4409 (gnus-mime-replace-part "r" "Replace part")
4410 (gnus-mime-delete-part "d" "Delete part")
4411 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4412 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4413 (gnus-mime-view-part-internally "E" "View Internally") ;; Why `E'?
4414 (gnus-mime-view-part-externally "e" "View Externally")
4415 (gnus-mime-print-part "p" "Print")
4416 (gnus-mime-pipe-part "|" "Pipe To Command...")
4417 (gnus-mime-action-on-part "." "Take action on the part...")))
4419 (defun gnus-article-mime-part-status ()
4420 (with-current-buffer gnus-article-buffer
4421 (let ((entity (get-text-property (point-min) 'mime-view-entity))
4424 (setq children (mime-entity-children entity))
4425 (setq children (length children)))
4428 (format " (%d parts)" children))
4431 (defvar gnus-mime-button-map
4432 (let ((map (make-sparse-keymap)))
4433 (define-key map gnus-mouse-2 'gnus-article-push-button)
4434 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4435 (dolist (c gnus-mime-button-commands)
4436 (define-key map (cadr c) (car c)))
4440 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4442 ,@(mapcar (lambda (c)
4443 (vector (caddr c) (car c) :enable t))
4444 gnus-mime-button-commands)))
4446 (defun gnus-mime-button-menu (event prefix)
4447 "Construct a context-sensitive menu of MIME commands."
4448 (interactive "e\nP")
4449 (save-window-excursion
4450 (let ((pos (event-start event)))
4451 (select-window (posn-window pos))
4452 (goto-char (posn-point pos))
4453 (gnus-article-check-buffer)
4454 (popup-menu gnus-mime-button-menu nil prefix))))
4456 (defun gnus-mime-view-all-parts (&optional handles)
4457 "View all the MIME parts."
4459 (with-current-buffer gnus-article-buffer
4460 (let ((handles (or handles gnus-article-mime-handles))
4461 (mail-parse-charset gnus-newsgroup-charset)
4462 (mail-parse-ignored-charsets
4463 (with-current-buffer gnus-summary-buffer
4464 gnus-newsgroup-ignored-charsets)))
4466 (mm-remove-parts handles)
4467 (goto-char (point-min))
4468 (or (search-forward "\n\n") (goto-char (point-max)))
4469 (let ((inhibit-read-only t))
4470 (delete-region (point) (point-max))
4471 (mm-display-parts handles))))))
4473 (defun gnus-article-jump-to-part (n)
4474 "Jump to MIME part N."
4476 (pop-to-buffer gnus-article-buffer)
4477 ;; FIXME: why is it necessary?
4479 (let ((parts (length gnus-article-mime-handle-alist)))
4482 (read-string ;; Emacs 21 doesn't have `read-number'.
4483 (format "Jump to part (2..%s): " parts)))))
4484 (unless (and (integerp n) (<= n parts) (>= n 1))
4487 (gnus-message 7 "Invalid part `%s', using %s instead."
4490 (gnus-message 9 "Jumping to part %s." n)
4491 (cond ((>= gnus-auto-select-part 1)
4492 (while (and (<= n parts)
4493 (not (gnus-article-goto-part n)))
4495 ((< gnus-auto-select-part 0)
4496 (while (and (>= n 1)
4497 (not (gnus-article-goto-part n)))
4500 (gnus-article-goto-part n)))))
4503 (defsubst gnus-article-edit-part (handles &optional current-id)
4504 "Edit an article in order to delete a mime part.
4505 This function is exclusively used by `gnus-mime-save-part-and-strip'
4506 and `gnus-mime-delete-part', and not provided at run-time normally."
4507 (gnus-article-edit-article
4509 (buffer-disable-undo)
4511 (let ((mail-parse-charset (or gnus-article-charset
4512 ',gnus-newsgroup-charset))
4513 (mail-parse-ignored-charsets
4514 (or gnus-article-ignored-charsets
4515 ',gnus-newsgroup-ignored-charsets))
4516 (mbl mml-buffer-list))
4517 (setq mml-buffer-list nil)
4518 (insert-buffer-substring gnus-original-article-buffer)
4519 (mime-to-mml ',handles)
4520 (setq gnus-article-mime-handles nil)
4521 (let ((mbl1 mml-buffer-list))
4522 (setq mml-buffer-list mbl)
4523 (set (make-local-variable 'mml-buffer-list) mbl1))
4524 (gnus-make-local-hook 'kill-buffer-hook)
4525 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4526 `(lambda (no-highlight)
4527 (let ((mail-parse-charset (or gnus-article-charset
4528 ',gnus-newsgroup-charset))
4529 (message-options message-options)
4530 (message-options-set-recipient)
4531 (mail-parse-ignored-charsets
4532 (or gnus-article-ignored-charsets
4533 ',gnus-newsgroup-ignored-charsets)))
4535 (mml-destroy-buffers)
4536 (remove-hook 'kill-buffer-hook
4537 'mml-destroy-buffers t)
4538 (kill-local-variable 'mml-buffer-list))
4539 (gnus-summary-edit-article-done
4540 ,(or (mail-header-references gnus-current-headers) "")
4541 ,(gnus-group-read-only-p)
4542 ,gnus-summary-buffer no-highlight))
4544 (gnus-article-edit-done)
4545 (gnus-summary-expand-window)
4546 (gnus-summary-show-article)
4547 (when (and current-id (integerp gnus-auto-select-part))
4548 (gnus-article-jump-to-part
4549 (+ current-id gnus-auto-select-part)))))
4551 (defun gnus-mime-replace-part (file)
4552 "Replace MIME part under point with an external body."
4553 ;; Useful if file has already been saved to disk
4557 (read-file-name "Replace MIME part with file: "
4558 (or mm-default-directory default-directory)
4560 (gnus-mime-save-part-and-strip file))
4562 (defun gnus-mime-save-part-and-strip (&optional file)
4563 "Save the MIME part under point then replace it with an external body.
4564 If FILE is given, use it for the external part."
4566 (gnus-article-check-buffer)
4567 (when (gnus-group-read-only-p)
4568 (error "The current group does not support deleting of parts"))
4569 (when (mm-complicated-handles gnus-article-mime-handles)
4571 The current article has a complicated MIME structure, giving up..."))
4572 (let* ((data (get-text-property (point) 'gnus-data))
4573 (id (get-text-property (point) 'gnus-part))
4575 (handles gnus-article-mime-handles))
4578 (and data (mm-save-part data "Delete MIME part and save to: "))))
4580 (with-current-buffer (mm-handle-buffer data)
4582 (insert "Content-Type: " (mm-handle-media-type data))
4583 (mml-insert-parameter-string (cdr (mm-handle-type data))
4586 (insert "Content-ID: " (message-make-message-id) "\n")
4587 (insert "Content-Transfer-Encoding: binary\n")
4590 (cdr (mm-make-handle nil
4591 `("message/external-body"
4592 (access-type . "LOCAL-FILE")
4594 ;; (set-buffer gnus-summary-buffer)
4595 (gnus-article-edit-part handles id))))
4597 ;; A function like `gnus-summary-save-parts' (`X m', `<MIME> <Extract all
4598 ;; parts...>') but with stripping would be nice.
4600 (defun gnus-mime-delete-part ()
4601 "Delete the MIME part under point.
4602 Replace it with some information about the removed part."
4604 (gnus-article-check-buffer)
4605 (when (gnus-group-read-only-p)
4606 (error "The current group does not support deleting of parts"))
4607 (when (mm-complicated-handles gnus-article-mime-handles)
4609 The current article has a complicated MIME structure, giving up..."))
4610 (when (or gnus-expert-user
4611 (gnus-yes-or-no-p "\
4612 Deleting parts may malfunction or destroy the article; continue? "))
4613 (let* ((data (get-text-property (point) 'gnus-data))
4614 (id (get-text-property (point) 'gnus-part))
4615 (handles gnus-article-mime-handles)
4619 (mail-decode-encoded-word-string (or (mm-handle-description data)
4622 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4624 (type (mm-handle-media-type data)))
4626 (error "No MIME part under point"))
4627 (with-current-buffer (mm-handle-buffer data)
4628 (let ((bsize (format "%s" (buffer-size))))
4633 "| The following attachment has been deleted:\n"
4635 "| Type: " type "\n"
4636 "| Filename: " filename "\n"
4637 "| Size (encoded): " bsize " Byte\n"
4638 "| Description: " description "\n"
4641 (cdr (mm-make-handle
4642 nil `("text/plain") nil nil
4644 (format "Deleted attachment (%s bytes)" bsize))))))
4645 ;; (set-buffer gnus-summary-buffer)
4646 (gnus-article-edit-part handles id))))
4648 (defun gnus-mime-save-part ()
4649 "Save the MIME part under point."
4651 (gnus-article-check-buffer)
4652 (let ((data (get-text-property (point) 'gnus-data)))
4654 (mm-save-part data))))
4656 (defun gnus-mime-pipe-part ()
4657 "Pipe the MIME part under point to a process."
4659 (gnus-article-check-buffer)
4660 (let ((data (get-text-property (point) 'gnus-data)))
4662 (mm-pipe-part data))))
4664 (defun gnus-mime-view-part ()
4665 "Interactively choose a viewing method for the MIME part under point."
4667 (gnus-article-check-buffer)
4668 (let ((data (get-text-property (point) 'gnus-data)))
4670 (setq gnus-article-mime-handles
4672 gnus-article-mime-handles (setq data (copy-sequence data))))
4673 (mm-interactively-view-part data))))
4675 (defun gnus-mime-view-part-as-type-internal ()
4676 (gnus-article-check-buffer)
4677 (let* ((handle (get-text-property (point) 'gnus-data))
4679 ;; Content-Type: foo/bar; name=...
4680 (mail-content-type-get (mm-handle-type handle) 'name)
4681 ;; Content-Disposition: attachment; filename=...
4682 (cdr (assq 'filename (cdr (mm-handle-disposition handle))))))
4683 (def-type (and name (mm-default-file-encoding name))))
4684 (and def-type (cons def-type 0))))
4686 (defun gnus-mime-view-part-as-type (&optional mime-type)
4687 "Choose a MIME media type, and view the part as such."
4691 (let ((default (gnus-mime-view-part-as-type-internal)))
4693 (format "View as MIME type (default %s): "
4695 (mapcar #'list (mailcap-mime-types))
4698 (gnus-article-check-buffer)
4699 (let ((handle (get-text-property (point) 'gnus-data)))
4702 (mm-make-handle (mm-handle-buffer handle)
4703 (cons mime-type (cdr (mm-handle-type handle)))
4704 (mm-handle-encoding handle)
4705 (mm-handle-undisplayer handle)
4706 (mm-handle-disposition handle)
4707 (mm-handle-description handle)
4709 (mm-handle-id handle)))
4710 (setq gnus-article-mime-handles
4711 (mm-merge-handles gnus-article-mime-handles handle))
4712 (gnus-mm-display-part handle))))
4714 (defun gnus-mime-copy-part (&optional handle arg)
4715 "Put the MIME part under point into a new buffer.
4716 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4718 (interactive (list nil current-prefix-arg))
4719 (gnus-article-check-buffer)
4721 (setq handle (get-text-property (point) 'gnus-data)))
4723 (let ((filename (or (mail-content-type-get (mm-handle-disposition handle)
4725 (mail-content-type-get (mm-handle-disposition handle)
4727 contents dont-decode charset coding-system)
4728 (mm-with-unibyte-buffer
4729 (mm-insert-part handle)
4730 (setq contents (or (condition-case nil
4731 (mm-decompress-buffer filename nil 'sig)
4733 (setq dont-decode t)
4736 (setq filename (cond (filename (file-name-nondirectory filename))
4737 (dont-decode "*raw data*")
4742 (unless (setq charset (mail-content-type-get
4743 (mm-handle-type handle) 'charset))
4744 (unless (setq coding-system (mm-with-unibyte-buffer
4746 (mm-find-buffer-file-coding-system)))
4747 (setq charset gnus-newsgroup-charset))))
4749 (setq charset (or (cdr (assq arg
4750 gnus-summary-show-article-charset-alist))
4751 (mm-read-coding-system "Charset: ")))))
4752 (switch-to-buffer (generate-new-buffer filename))
4753 (if (or coding-system
4755 (setq coding-system (mm-charset-to-coding-system charset))
4756 (not (eq charset 'ascii))))
4758 (mm-enable-multibyte)
4759 (insert (mm-decode-coding-string contents coding-system))
4760 (setq buffer-file-coding-system
4761 (if (boundp 'last-coding-system-used)
4762 (symbol-value 'last-coding-system-used)
4764 (mm-disable-multibyte)
4766 (setq buffer-file-coding-system mm-binary-coding-system))
4767 ;; We do it this way to make `normal-mode' set the appropriate mode.
4770 (setq buffer-file-name (expand-file-name filename))
4772 (setq buffer-file-name nil))
4773 (goto-char (point-min)))))
4775 (defun gnus-mime-print-part (&optional handle filename)
4776 "Print the MIME part under point."
4777 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4778 (gnus-article-check-buffer)
4779 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4780 (contents (and handle (mm-get-part handle)))
4781 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4782 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4787 (mm-save-part-to-file handle file)
4788 (call-process shell-file-name nil
4789 (generate-new-buffer " *mm*")
4791 shell-command-switch
4793 printer file (mm-handle-type handle))))
4797 (gnus-print-buffer))
4798 (ps-despool filename)))))
4800 (defun gnus-mime-inline-part (&optional handle arg)
4801 "Insert the MIME part under point into the current buffer.
4802 Compressed files like .gz and .bz2 are decompressed."
4803 (interactive (list nil current-prefix-arg))
4804 (gnus-article-check-buffer)
4806 (setq handle (get-text-property (point) 'gnus-data)))
4809 (inhibit-read-only t)
4810 contents charset coding-system)
4811 (if (and (not arg) (mm-handle-undisplayer handle))
4812 (mm-remove-part handle)
4813 (mm-with-unibyte-buffer
4814 (mm-insert-part handle)
4816 (or (mm-decompress-buffer
4817 (or (mail-content-type-get (mm-handle-disposition handle)
4819 (mail-content-type-get (mm-handle-disposition handle)
4825 (unless (setq charset (mail-content-type-get
4826 (mm-handle-type handle) 'charset))
4827 (unless (setq coding-system
4828 (mm-with-unibyte-buffer
4830 (mm-find-buffer-file-coding-system)))
4831 (setq charset gnus-newsgroup-charset))))
4833 (if (mm-handle-undisplayer handle)
4834 (mm-remove-part handle))
4837 gnus-summary-show-article-charset-alist))
4838 (mm-read-coding-system "Charset: "))))
4840 (if (mm-handle-undisplayer handle)
4841 (mm-remove-part handle))))
4845 (if (or coding-system
4848 (mm-charset-to-coding-system charset))
4849 (not (eq coding-system 'ascii))))
4850 (mm-decode-coding-string contents coding-system)
4851 (mm-string-to-multibyte contents)))
4854 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4855 "Insert the MIME part under point into the current buffer using the
4857 (interactive (list nil current-prefix-arg))
4858 (gnus-article-check-buffer)
4859 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4862 (inhibit-read-only t))
4864 (if (mm-handle-undisplayer handle)
4865 (mm-remove-part handle))
4866 (let ((gnus-newsgroup-charset
4868 gnus-summary-show-article-charset-alist))
4869 (mm-read-coding-system "Charset: ")))
4870 (gnus-newsgroup-ignored-charsets 'gnus-all))
4871 (gnus-article-press-button)))))
4873 (defun gnus-mime-view-part-externally (&optional handle)
4874 "View the MIME part under point with an external viewer."
4876 (gnus-article-check-buffer)
4877 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4878 (mm-user-display-methods nil)
4879 (mm-inlined-types nil)
4880 (mail-parse-charset gnus-newsgroup-charset)
4881 (mail-parse-ignored-charsets
4882 (with-current-buffer gnus-summary-buffer
4883 gnus-newsgroup-ignored-charsets)))
4885 (if (mm-handle-undisplayer handle)
4886 (mm-remove-part handle)
4887 (mm-display-part handle)))))
4889 (defun gnus-mime-view-part-internally (&optional handle)
4890 "View the MIME part under point with an internal viewer.
4891 If no internal viewer is available, use an external viewer."
4893 (gnus-article-check-buffer)
4894 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4895 (mm-inlined-types '(".*"))
4896 (mm-inline-large-images t)
4897 (mail-parse-charset gnus-newsgroup-charset)
4898 (mail-parse-ignored-charsets
4899 (with-current-buffer gnus-summary-buffer
4900 gnus-newsgroup-ignored-charsets))
4901 (inhibit-read-only t))
4903 (if (mm-handle-undisplayer handle)
4904 (mm-remove-part handle)
4905 (mm-display-part handle)))))
4907 (defun gnus-mime-action-on-part (&optional action)
4908 "Do something with the MIME attachment at \(point\)."
4910 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4911 (gnus-article-check-buffer)
4912 (let ((action-pair (assoc action gnus-mime-action-alist)))
4914 (funcall (cdr action-pair)))))
4916 (defun gnus-article-part-wrapper (n function &optional no-handle interactive)
4917 "Call FUNCTION on MIME part N.
4918 Unless NO-HANDLE, call FUNCTION with N-th MIME handle as it's only argument.
4919 If INTERACTIVE, call FUNCTION interactivly."
4921 ;; Check whether the article is displayed.
4922 (unless (and (gnus-buffer-live-p gnus-article-buffer)
4923 (setq window (get-buffer-window gnus-article-buffer t))
4924 (frame-visible-p (setq frame (window-frame window))))
4925 (error "No article is displayed"))
4926 (with-current-buffer gnus-article-buffer
4927 ;; Check whether the article displays the right contents.
4928 (unless (with-current-buffer gnus-summary-buffer
4929 (eq gnus-current-article (gnus-summary-article-number)))
4930 (error "You should select the right article first"))
4931 ;; Check whether the specified part exists.
4932 (when (> n (length gnus-article-mime-handle-alist))
4933 (error "No such part")))
4936 ;; To select the window is needed so that the cursor
4937 ;; might be visible on the MIME button.
4938 (select-window (prog1
4940 (setq window (selected-window))
4941 ;; Article may be displayed in the other frame.
4942 (gnus-select-frame-set-input-focus
4945 (setq frame (selected-frame))))))
4946 (when (gnus-article-goto-part n)
4947 ;; We point the cursor and the arrow at the MIME button
4948 ;; when the `function' prompt the user for something.
4949 (let ((cursor-in-non-selected-windows t)
4950 (overlay-arrow-string "=>")
4951 (overlay-arrow-position (point-marker)))
4954 ((and no-handle interactive)
4955 (call-interactively function))
4961 (cdr (assq n gnus-article-mime-handle-alist))))
4964 (cdr (assq n gnus-article-mime-handle-alist)))))
4965 (set-marker overlay-arrow-position nil)
4966 (unless gnus-auto-select-part
4967 (gnus-select-frame-set-input-focus frame)
4968 (select-window window))))
4970 (if gnus-inhibit-mime-unbuttonizing
4971 ;; This is the default though the program shouldn't reach here.
4972 (error "No such part")
4973 ;; The part which doesn't have the MIME button is selected.
4974 ;; So, we display all the buttons and redo it.
4975 (let ((gnus-inhibit-mime-unbuttonizing t))
4976 (gnus-summary-show-article)
4977 (gnus-article-part-wrapper n function no-handle))))))
4979 (defun gnus-article-pipe-part (n)
4980 "Pipe MIME part N, which is the numerical prefix."
4982 (gnus-article-part-wrapper n 'mm-pipe-part))
4984 (defun gnus-article-save-part (n)
4985 "Save MIME part N, which is the numerical prefix."
4987 (gnus-article-part-wrapper n 'mm-save-part))
4989 (defun gnus-article-interactively-view-part (n)
4990 "View MIME part N interactively, which is the numerical prefix."
4992 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4994 (defun gnus-article-copy-part (n)
4995 "Copy MIME part N, which is the numerical prefix."
4997 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4999 (defun gnus-article-view-part-as-charset (n)
5000 "View MIME part N using a specified charset.
5001 N is the numerical prefix."
5003 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
5005 (defun gnus-article-view-part-externally (n)
5006 "View MIME part N externally, which is the numerical prefix."
5008 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
5010 (defun gnus-article-inline-part (n)
5011 "Inline MIME part N, which is the numerical prefix."
5013 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
5015 (defun gnus-article-save-part-and-strip (n)
5016 "Save MIME part N and replace it with an external body.
5017 N is the numerical prefix."
5019 (gnus-article-part-wrapper n 'gnus-mime-save-part-and-strip t))
5021 (defun gnus-article-replace-part (n)
5022 "Replace MIME part N with an external body.
5023 N is the numerical prefix."
5025 (gnus-article-part-wrapper n 'gnus-mime-replace-part t t))
5027 (defun gnus-article-delete-part (n)
5028 "Delete MIME part N and add some information about the removed part.
5029 N is the numerical prefix."
5031 (gnus-article-part-wrapper n 'gnus-mime-delete-part t))
5033 (defun gnus-article-mime-match-handle-first (condition)
5036 (dolist (ihandle gnus-article-mime-handle-alist)
5038 ((functionp condition)
5039 (funcall condition (cdr ihandle)))
5040 ((eq condition 'undisplayed)
5041 (not (or (mm-handle-undisplayer (cdr ihandle))
5042 (equal (mm-handle-media-type (cdr ihandle))
5043 "multipart/alternative"))))
5044 ((eq condition 'undisplayed-alternative)
5045 (not (mm-handle-undisplayer (cdr ihandle))))
5047 (gnus-article-goto-part (car ihandle))
5048 (or (not n) (< (car ihandle) n)))
5049 (setq n (car ihandle))))
5053 (defun gnus-article-view-part (&optional n)
5054 "View MIME part N, which is the numerical prefix."
5056 (with-current-buffer gnus-article-buffer
5057 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
5058 gnus-article-mime-match-handle-function)))
5059 (when (> n (length gnus-article-mime-handle-alist))
5060 (error "No such part"))
5061 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
5062 (when (gnus-article-goto-part n)
5063 (if (equal (car handle) "multipart/alternative")
5064 (gnus-article-press-button)
5065 (when (eq (gnus-mm-display-part handle) 'internal)
5066 (gnus-set-window-start)))))))
5068 (defsubst gnus-article-mime-total-parts ()
5069 (if (bufferp (car gnus-article-mime-handles))
5071 (1- (length gnus-article-mime-handles))))
5073 (defun gnus-mm-display-part (handle)
5074 "Display HANDLE and fix MIME button."
5075 (let ((id (get-text-property (point) 'gnus-part))
5077 (inhibit-read-only t))
5080 (let ((window (selected-window))
5081 (mail-parse-charset gnus-newsgroup-charset)
5082 (mail-parse-ignored-charsets
5083 (if (gnus-buffer-live-p gnus-summary-buffer)
5084 (with-current-buffer gnus-summary-buffer
5085 gnus-newsgroup-ignored-charsets)
5089 (let ((win (gnus-get-buffer-window (current-buffer) t))
5092 (select-window win))
5095 (if (mm-handle-displayed-p handle)
5096 ;; This will remove the part.
5097 (mm-display-part handle)
5099 (narrow-to-region (point)
5100 (if (eobp) (point) (1+ (point))))
5101 (mm-display-part handle)
5102 ;; We narrow to the part itself and
5103 ;; then call the treatment functions.
5104 (goto-char (point-min))
5106 (narrow-to-region (point) (point-max))
5109 (gnus-article-mime-total-parts)
5110 (mm-handle-media-type handle)))))
5111 (if (window-live-p window)
5112 (select-window window)))))
5115 (gnus-insert-mime-button
5116 handle id (list (mm-handle-displayed-p handle)))
5117 (goto-char point))))
5119 (defun gnus-article-goto-part (n)
5120 "Go to MIME part N."
5121 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
5123 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
5124 (let ((gnus-tmp-name
5125 (or (mail-content-type-get (mm-handle-type handle) 'name)
5126 (mail-content-type-get (mm-handle-disposition handle) 'filename)
5127 (mail-content-type-get (mm-handle-type handle) 'url)
5129 (gnus-tmp-type (mm-handle-media-type handle))
5130 (gnus-tmp-description
5131 (mail-decode-encoded-word-string (or (mm-handle-description handle)
5134 (if (if displayed (car displayed)
5135 (mm-handle-displayed-p handle))
5137 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
5139 gnus-tmp-type-long b e)
5140 (when (string-match ".*/" gnus-tmp-name)
5141 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
5142 (setq gnus-tmp-type-long (concat gnus-tmp-type
5143 (and (not (equal gnus-tmp-name ""))
5144 (concat "; " gnus-tmp-name))))
5145 (unless (equal gnus-tmp-description "")
5146 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
5151 gnus-mime-button-line-format gnus-mime-button-line-format-alist
5152 `(keymap ,gnus-mime-button-map
5153 gnus-callback gnus-mm-display-part
5154 gnus-part ,gnus-tmp-id
5155 article-type annotation
5158 ;; Exclude a newline.
5161 (widget-convert-button
5164 :action 'gnus-widget-press-button
5165 :button-keymap gnus-mime-button-map
5167 (lambda (widget/window &optional overlay pos)
5168 ;; Needed to properly clear the message due to a bug in
5169 ;; wid-edit (XEmacs only).
5170 (if (boundp 'help-echo-owns-message)
5171 (setq help-echo-owns-message t))
5173 "%S: %s the MIME part; %S: more options"
5174 (aref gnus-mouse-2 0)
5175 ;; XEmacs will get a single widget arg; Emacs 21 will get
5176 ;; window, overlay, position.
5177 (if (mm-handle-displayed-p
5179 (with-current-buffer (gnus-overlay-buffer overlay)
5180 (widget-get (widget-at (gnus-overlay-start overlay))
5182 (widget-get widget/window :mime-handle)))
5184 (aref gnus-down-mouse-3 0))))))
5186 (defun gnus-widget-press-button (elems el)
5187 (goto-char (widget-get elems :from))
5188 (gnus-article-press-button))
5190 (defvar gnus-displaying-mime nil)
5192 (defun gnus-display-mime (&optional ihandles)
5193 "Display the MIME parts."
5195 (save-selected-window
5196 (let ((window (get-buffer-window gnus-article-buffer))
5199 (select-window window)
5200 ;; We have to do this since selecting the window
5201 ;; may change the point. So we set the window point.
5202 (set-window-point window point)))
5203 (let ((handles ihandles)
5204 (inhibit-read-only t)
5207 ((setq handles (mm-dissect-buffer nil gnus-article-loose-mime))
5208 (when gnus-article-emulate-mime
5209 (mm-uu-dissect-text-parts handles)))
5210 (gnus-article-emulate-mime
5211 (setq handles (mm-uu-dissect))))
5212 (when (and (not ihandles)
5213 (not gnus-displaying-mime))
5214 ;; Top-level call; we clean up.
5215 (when gnus-article-mime-handles
5216 (mm-destroy-parts gnus-article-mime-handles)
5217 (setq gnus-article-mime-handle-alist nil));; A trick.
5218 (setq gnus-article-mime-handles handles)
5219 ;; We allow users to glean info from the handles.
5220 (when gnus-article-mime-part-function
5221 (gnus-mime-part-function handles)))
5223 (or (not (stringp (car handles)))
5226 (when (and (not ihandles)
5227 (not gnus-displaying-mime))
5228 ;; Clean up for mime parts.
5230 (delete-region (point) (point-max)))
5231 (let ((gnus-displaying-mime t))
5232 (gnus-mime-display-part handles)))
5235 (narrow-to-region (point) (point-max))
5236 (gnus-treat-article nil 1 1)
5239 ;; Highlight the headers.
5243 (narrow-to-region (point-min) (point))
5244 (gnus-article-save-original-date
5245 (gnus-treat-article 'head)))))))))
5247 (defcustom gnus-mime-display-multipart-as-mixed nil
5248 "Display \"multipart\" parts as \"multipart/mixed\".
5250 If t, it overrides nil values of
5251 `gnus-mime-display-multipart-alternative-as-mixed' and
5252 `gnus-mime-display-multipart-related-as-mixed'."
5253 :group 'gnus-article-mime
5256 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
5257 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
5259 :group 'gnus-article-mime
5262 (defcustom gnus-mime-display-multipart-related-as-mixed nil
5263 "Display \"multipart/related\" parts as \"multipart/mixed\".
5265 If displaying \"text/html\" is discouraged \(see
5266 `mm-discouraged-alternatives'\) images or other material inside a
5267 \"multipart/related\" part might be overlooked when this variable is nil."
5269 :group 'gnus-article-mime
5272 (defun gnus-mime-display-part (handle)
5274 ;; Maybe a broken MIME message.
5277 ((not (stringp (car handle)))
5278 (gnus-mime-display-single handle))
5279 ;; User-defined multipart
5280 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
5281 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
5283 ;; multipart/alternative
5284 ((and (equal (car handle) "multipart/alternative")
5285 (not (or gnus-mime-display-multipart-as-mixed
5286 gnus-mime-display-multipart-alternative-as-mixed)))
5287 (let ((id (1+ (length gnus-article-mime-handle-alist))))
5288 (push (cons id handle) gnus-article-mime-handle-alist)
5289 (gnus-mime-display-alternative (cdr handle) nil nil id)))
5290 ;; multipart/related
5291 ((and (equal (car handle) "multipart/related")
5292 (not (or gnus-mime-display-multipart-as-mixed
5293 gnus-mime-display-multipart-related-as-mixed)))
5294 ;;;!!!We should find the start part, but we just default
5295 ;;;!!!to the first part.
5296 ;;(gnus-mime-display-part (cadr handle))
5297 ;;;!!! Most multipart/related is an HTML message plus images.
5298 ;;;!!! Unfortunately we are unable to let W3 display those
5299 ;;;!!! included images, so we just display it as a mixed multipart.
5300 ;;(gnus-mime-display-mixed (cdr handle))
5301 ;;;!!! No, w3 can display everything just fine.
5302 (gnus-mime-display-part (cadr handle)))
5303 ((equal (car handle) "multipart/signed")
5304 (gnus-add-wash-type 'signed)
5305 (gnus-mime-display-security handle))
5306 ((equal (car handle) "multipart/encrypted")
5307 (gnus-add-wash-type 'encrypted)
5308 (gnus-mime-display-security handle))
5309 ;; Other multiparts are handled like multipart/mixed.
5311 (gnus-mime-display-mixed (cdr handle)))))
5313 (defun gnus-mime-part-function (handles)
5314 (if (stringp (car handles))
5315 (mapcar 'gnus-mime-part-function (cdr handles))
5316 (funcall gnus-article-mime-part-function handles)))
5318 (defun gnus-mime-display-mixed (handles)
5319 (mapcar 'gnus-mime-display-part handles))
5321 (defun gnus-mime-display-single (handle)
5322 (let ((type (mm-handle-media-type handle))
5323 (ignored gnus-ignored-mime-types)
5330 (when (string-match (pop ignored) type)
5331 (throw 'ignored nil)))
5332 (if (and (setq not-attachment
5333 (and (not (mm-inline-override-p handle))
5334 (or (not (mm-handle-disposition handle))
5335 (equal (car (mm-handle-disposition handle))
5337 (mm-attachment-override-p handle))))
5338 (mm-automatic-display-p handle)
5340 (mm-inlinable-p handle)
5341 (mm-inlined-p handle))
5342 (mm-automatic-external-display-p type)))
5344 (when (equal (mm-handle-media-supertype handle) "text")
5346 (let ((id (1+ (length gnus-article-mime-handle-alist)))
5348 (push (cons id handle) gnus-article-mime-handle-alist)
5349 (when (or (not display)
5350 (not (gnus-unbuttonized-mime-type-p type)))
5351 (gnus-insert-mime-button
5352 handle id (list (or display (and not-attachment text))))
5353 (gnus-article-insert-newline)
5354 ;; Remember modify the number of forward lines.
5362 (let ((mail-parse-charset gnus-newsgroup-charset)
5363 (mail-parse-ignored-charsets
5364 (save-excursion (condition-case ()
5365 (set-buffer gnus-summary-buffer)
5367 gnus-newsgroup-ignored-charsets)))
5368 (mm-display-part handle t))
5369 (goto-char (point-max)))
5370 ((and text not-attachment)
5374 (gnus-article-insert-newline)
5377 (let ((charset (mail-content-type-get (mm-handle-type handle)
5379 (cond ((not charset)
5380 (mm-string-as-multibyte (mm-get-part handle)))
5381 ((eq charset 'gnus-decoded)
5382 (with-current-buffer (mm-handle-buffer handle)
5385 (mm-decode-string (mm-get-part handle) charset)))))
5386 (goto-char (point-max))))
5390 (narrow-to-region beg (point))
5393 (gnus-article-mime-total-parts)
5394 (mm-handle-media-type handle)))))))))
5396 (defun gnus-unbuttonized-mime-type-p (type)
5397 "Say whether TYPE is to be unbuttonized."
5398 (unless gnus-inhibit-mime-unbuttonizing
5400 (let ((types gnus-unbuttonized-mime-types))
5402 (when (string-match (pop types) type)
5403 (throw 'found t)))))
5405 (let ((types gnus-buttonized-mime-types))
5407 (when (string-match (pop types) type)
5408 (throw 'found t)))))))))
5410 (defun gnus-article-insert-newline ()
5411 "Insert a newline, but mark it as undeletable."
5412 (gnus-put-text-property
5413 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
5415 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
5416 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
5419 handle (inhibit-read-only t) from props begend not-pref)
5420 (save-window-excursion
5423 (narrow-to-region (car ibegend)
5426 (goto-char (car ibegend))
5429 (delete-region (point-min) (point-max))
5430 (mm-remove-parts handles))
5431 (setq begend (list (point-marker)))
5433 (unless (setq not-pref (cadr (member preferred ihandles)))
5434 (setq not-pref (car ihandles)))
5437 (not (gnus-unbuttonized-mime-type-p
5438 "multipart/alternative")))
5439 (gnus-add-text-properties
5442 (insert (format "%d. " id))
5446 (unless ,(not ibegend)
5447 (setq gnus-article-mime-handle-alist
5448 ',gnus-article-mime-handle-alist))
5449 (gnus-mime-display-alternative
5450 ',ihandles ',not-pref ',begend ,id))
5451 keymap ,gnus-mime-button-map
5452 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5453 face ,gnus-article-button-face
5456 (widget-convert-button 'link from (point)
5457 :action 'gnus-widget-press-button
5458 :button-keymap gnus-widget-button-keymap)
5460 (while (setq handle (pop handles))
5461 (gnus-add-text-properties
5464 (insert (format "(%c) %-18s"
5465 (if (equal handle preferred) ?* ? )
5466 (mm-handle-media-type handle)))
5470 (unless ,(not ibegend)
5471 (setq gnus-article-mime-handle-alist
5472 ',gnus-article-mime-handle-alist))
5473 (gnus-mime-display-alternative
5474 ',ihandles ',handle ',begend ,id))
5475 keymap ,gnus-mime-button-map
5476 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5477 face ,gnus-article-button-face
5480 (widget-convert-button 'link from (point)
5481 :action 'gnus-widget-press-button
5482 :button-keymap gnus-widget-button-keymap)
5486 (if (stringp (car preferred))
5487 (gnus-display-mime preferred)
5488 (let ((mail-parse-charset gnus-newsgroup-charset)
5489 (mail-parse-ignored-charsets
5490 (with-current-buffer gnus-summary-buffer
5491 gnus-newsgroup-ignored-charsets)))
5492 (mm-display-part preferred)
5496 (narrow-to-region (car begend) (point-max))
5498 nil (length gnus-article-mime-handle-alist)
5499 (gnus-article-mime-total-parts)
5500 (mm-handle-media-type handle))))))
5501 (goto-char (point-max))
5502 (setcdr begend (point-marker)))))
5504 (goto-char point))))
5506 (defconst gnus-article-wash-status-strings
5507 (let ((alist '((cite "c" "Possible hidden citation text"
5508 " " "All citation text visible")
5509 (headers "h" "Hidden headers"
5510 " " "All headers visible.")
5511 (pgp "p" "Encrypted or signed message status hidden"
5512 " " "No hidden encryption nor digital signature status")
5513 (signature "s" "Signature has been hidden"
5514 " " "Signature is visible")
5515 (overstrike "o" "Overstrike (^H) characters applied"
5516 " " "No overstrike characters applied")
5517 (gnus-show-mime "m" "Mime processing is activated"
5518 " " "Mime processing is not activated")
5519 (emphasis "e" "/*_Emphasis_*/ characters applied"
5520 " " "No /*_emphasis_*/ characters applied")))
5522 (dolist (entry alist result)
5523 (let ((key (nth 0 entry))
5524 (on (copy-sequence (nth 1 entry)))
5525 (on-help (nth 2 entry))
5526 (off (copy-sequence (nth 3 entry)))
5527 (off-help (nth 4 entry)))
5528 (put-text-property 0 1 'help-echo on-help on)
5529 (put-text-property 0 1 'help-echo off-help off)
5530 (push (list key on off) result))))
5531 "Alist of strings describing wash status in the mode line.
5532 Each entry has the form (KEY ON OF), where the KEY is a symbol
5533 representing the particular washing function, ON is the string to use
5534 in the article mode line when the washing function is active, and OFF
5535 is the string to use when it is inactive.")
5537 (defun gnus-article-wash-status-entry (key value)
5538 (let ((entry (assoc key gnus-article-wash-status-strings)))
5539 (if value (nth 1 entry) (nth 2 entry))))
5541 (defun gnus-article-wash-status ()
5542 "Return a string which display status of article washing."
5543 (with-current-buffer gnus-article-buffer
5544 (let ((cite (memq 'cite gnus-article-wash-types))
5545 (headers (memq 'headers gnus-article-wash-types))
5546 (boring (memq 'boring-headers gnus-article-wash-types))
5547 (pgp (memq 'pgp gnus-article-wash-types))
5548 (pem (memq 'pem gnus-article-wash-types))
5549 (signed (memq 'signed gnus-article-wash-types))
5550 (encrypted (memq 'encrypted gnus-article-wash-types))
5551 (signature (memq 'signature gnus-article-wash-types))
5552 (overstrike (memq 'overstrike gnus-article-wash-types))
5553 (emphasis (memq 'emphasis gnus-article-wash-types)))
5555 (gnus-article-wash-status-entry 'cite cite)
5556 (gnus-article-wash-status-entry 'headers (or headers boring))
5557 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5558 (gnus-article-wash-status-entry 'signature signature)
5559 (gnus-article-wash-status-entry 'overstrike overstrike)
5560 (gnus-article-wash-status-entry 'gnus-show-mime gnus-show-mime)
5561 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5563 (defun gnus-add-wash-type (type)
5564 "Add a washing of TYPE to the current status."
5565 (add-to-list 'gnus-article-wash-types type))
5567 (defun gnus-delete-wash-type (type)
5568 "Add a washing of TYPE to the current status."
5569 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5571 (defun gnus-add-image (category image)
5572 "Add IMAGE of CATEGORY to the list of displayed images."
5573 (let ((entry (assq category gnus-article-image-alist)))
5575 (setq entry (list category))
5576 (push entry gnus-article-image-alist))
5577 (nconc entry (list image))))
5579 (defun gnus-delete-images (category)
5580 "Delete all images in CATEGORY."
5581 (let ((entry (assq category gnus-article-image-alist)))
5582 (dolist (image (cdr entry))
5583 (gnus-remove-image image category))
5584 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5585 (gnus-delete-wash-type category)))
5587 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5589 (defun gnus-article-maybe-hide-headers ()
5590 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5591 Provided for backwards compatibility."
5592 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5593 (not (with-current-buffer gnus-summary-buffer
5594 gnus-have-all-headers)))
5595 (not gnus-inhibit-hiding))
5596 (gnus-article-hide-headers)))
5600 (defun gnus-output-to-file (file-name)
5601 "Append the current article to a file named FILE-NAME."
5602 (let ((artbuf (current-buffer)))
5604 (insert-buffer-substring artbuf)
5605 ;; Append newline at end of the buffer as separator, and then
5607 (goto-char (point-max))
5609 (let ((file-name-coding-system nnmail-pathname-coding-system))
5610 (write-region-as-binary (point-min) (point-max) file-name 'append))
5613 (defun gnus-narrow-to-page (&optional arg)
5614 "Narrow the article buffer to a page.
5615 If given a numerical ARG, move forward ARG pages."
5617 (setq arg (if arg (prefix-numeric-value arg) 0))
5619 (set-buffer gnus-article-buffer)
5620 (goto-char (point-min))
5622 ;; Remove any old next/prev buttons.
5623 (when (gnus-visual-p 'page-marker)
5624 (let ((inhibit-read-only t))
5625 (gnus-remove-text-with-property 'gnus-prev)
5626 (gnus-remove-text-with-property 'gnus-next)))
5629 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5631 (re-search-forward page-delimiter nil 'move arg)))
5632 (goto-char (match-end 0))
5634 (goto-char (point-min))
5635 (setq gnus-page-broken
5636 (and (re-search-forward page-delimiter nil t) t))))
5637 (when gnus-page-broken
5640 (if (re-search-forward page-delimiter nil 'move)
5643 (when (and (gnus-visual-p 'page-marker)
5644 (> (point-min) (save-restriction (widen) (point-min))))
5646 (goto-char (point-min))
5647 (gnus-insert-prev-page-button)))
5648 (when (and (gnus-visual-p 'page-marker)
5649 (< (point-max) (save-restriction (widen) (point-max))))
5651 (goto-char (point-max))
5652 (gnus-insert-next-page-button))))))
5654 ;; Article mode commands
5656 (defun gnus-article-goto-next-page ()
5657 "Show the next page of the article."
5659 (when (gnus-article-next-page)
5660 (goto-char (point-min))
5661 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5664 (defun gnus-article-goto-prev-page ()
5665 "Show the previous page of the article."
5668 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5669 (gnus-article-prev-page nil)))
5671 ;; This is cleaner but currently breaks `gnus-pick-mode':
5673 ;; (defun gnus-article-goto-next-page ()
5674 ;; "Show the next page of the article."
5676 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5677 ;; (gnus-summary-next-page)))
5679 ;; (defun gnus-article-goto-prev-page ()
5680 ;; "Show the next page of the article."
5682 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5683 ;; (gnus-summary-prev-page)))
5685 (defun gnus-article-next-page (&optional lines)
5686 "Show the next page of the current article.
5687 If end of article, return non-nil. Otherwise return nil.
5688 Argument LINES specifies lines to be scrolled up."
5690 (move-to-window-line -1)
5693 (and (pos-visible-in-window-p) ;Not continuation line.
5694 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5695 ;; Nothing in this page.
5696 (if (or (not gnus-page-broken)
5701 (eobp)))) ;Real end-of-buffer?
5703 (when gnus-article-over-scroll
5704 (gnus-article-next-page-1 lines))
5706 (gnus-narrow-to-page 1) ;Go to next page.
5708 ;; More in this page.
5709 (gnus-article-next-page-1 lines)
5712 (defmacro gnus-article-beginning-of-window ()
5713 "Move point to the beginning of the window.
5714 In Emacs, the point is placed at the line number which `scroll-margin'
5716 (if (featurep 'xemacs)
5717 '(move-to-window-line 0)
5718 '(move-to-window-line
5719 (min (max 0 scroll-margin)
5720 (max 1 (- (window-height)
5721 (if mode-line-format 1 0)
5722 (if header-line-format 1 0)))))))
5724 (defun gnus-article-next-page-1 (lines)
5725 (when (and (not (featurep 'xemacs))
5728 (numberp (symbol-value 'scroll-margin))
5729 (> (symbol-value 'scroll-margin) 0))
5730 ;; Protect against the bug that Emacs 21.x hangs up when scrolling up for
5731 ;; too many number of lines if `scroll-margin' is set as two or greater.
5732 (setq lines (min lines
5733 (max 0 (- (count-lines (window-start) (point-max))
5734 (symbol-value 'scroll-margin))))))
5736 (let ((scroll-in-place nil))
5739 ;; Long lines may cause an end-of-buffer error.
5740 (goto-char (point-max))))
5741 (gnus-article-beginning-of-window))
5743 (defun gnus-article-prev-page (&optional lines)
5744 "Show previous page of current article.
5745 Argument LINES specifies lines to be scrolled down."
5747 (move-to-window-line 0)
5748 (if (and gnus-page-broken
5750 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5752 (gnus-narrow-to-page -1) ;Go to previous page.
5753 (goto-char (point-max))
5757 (let ((scroll-in-place nil))
5758 (scroll-down lines))
5759 (beginning-of-buffer
5760 (goto-char (point-min))))
5761 (gnus-article-beginning-of-window))))
5763 (defun gnus-article-only-boring-p ()
5764 "Decide whether there is only boring text remaining in the article.
5765 Something \"interesting\" is a word of at least two letters that does
5766 not have a face in `gnus-article-boring-faces'."
5767 (when (and gnus-article-skip-boring
5768 (boundp 'gnus-article-boring-faces)
5769 (symbol-value 'gnus-article-boring-faces))
5772 (while (re-search-forward "\\b\\w\\w" nil t)
5774 (when (not (gnus-intersection
5775 (gnus-faces-at (point))
5776 (symbol-value 'gnus-article-boring-faces)))
5777 (throw 'only-boring nil)))
5778 (throw 'only-boring t)))))
5780 (defun gnus-article-refer-article ()
5781 "Read article specified by message-id around point."
5784 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
5785 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
5786 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
5787 (let ((msg-id (concat "<" (match-string 0) ">")))
5788 (set-buffer gnus-summary-buffer)
5789 (gnus-summary-refer-article msg-id))
5790 (error "No references around point"))))
5792 (defun gnus-article-show-summary ()
5793 "Reconfigure windows to show summary buffer."
5795 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5796 (error "There is no summary buffer for this article buffer")
5797 (gnus-article-set-globals)
5798 (gnus-configure-windows 'article)
5799 (gnus-summary-goto-subject gnus-current-article)
5800 (gnus-summary-position-point)))
5802 (defun gnus-article-describe-briefly ()
5803 "Describe article mode commands briefly."
5805 (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")))
5807 (defun gnus-article-summary-command ()
5808 "Execute the last keystroke in the summary buffer."
5810 (let ((obuf (current-buffer))
5811 (owin (current-window-configuration))
5813 (switch-to-buffer gnus-article-current-summary 'norecord)
5814 (setq func (lookup-key (current-local-map) (this-command-keys)))
5815 (call-interactively func)
5817 (set-window-configuration owin)
5818 (set-window-point (get-buffer-window (current-buffer)) (point))))
5820 (defun gnus-article-summary-command-nosave ()
5821 "Execute the last keystroke in the summary buffer."
5824 (pop-to-buffer gnus-article-current-summary 'norecord)
5825 (setq func (lookup-key (current-local-map) (this-command-keys)))
5826 (call-interactively func)))
5828 (defun gnus-article-check-buffer ()
5829 "Beep if not in an article buffer."
5830 (unless (eq (get-buffer gnus-article-buffer) (current-buffer))
5831 (error "Command invoked outside of a Gnus article buffer")))
5833 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5834 "Read a summary buffer key sequence and execute it from the article buffer."
5836 (gnus-article-check-buffer)
5838 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5839 "Zc" "ZC" "ZE" "ZJ" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5840 "=" "^" "\M-^" "|"))
5846 '("n" "Gn" "p" "Gp"))
5849 (set-buffer gnus-article-current-summary)
5850 (let (gnus-pick-mode)
5851 (push (or key last-command-event) unread-command-events)
5852 (setq keys (static-if (featurep 'xemacs)
5853 (events-to-keys (read-key-sequence nil))
5854 (read-key-sequence nil)))))
5857 (if (or (member keys nosaves)
5858 (member keys nosave-but-article)
5859 (member keys nosave-in-article))
5861 (save-window-excursion
5862 (pop-to-buffer gnus-article-current-summary 'norecord)
5863 ;; We disable the pick minor mode commands.
5864 (let (gnus-pick-mode)
5865 (setq func (lookup-key (current-local-map) keys))))
5869 (unless (member keys nosave-in-article)
5870 (set-buffer gnus-article-current-summary))
5871 (call-interactively func)
5872 (setq new-sum-point (point)))
5873 (when (member keys nosave-but-article)
5874 (pop-to-buffer gnus-article-buffer 'norecord)))
5875 ;; These commands should restore window configuration.
5876 (let ((obuf (current-buffer))
5877 (owin (current-window-configuration))
5879 win func in-buffer selected new-sum-start new-sum-hscroll)
5880 (cond (not-restore-window
5881 (pop-to-buffer gnus-article-current-summary 'norecord))
5882 ((setq win (get-buffer-window gnus-article-current-summary))
5883 (select-window win))
5885 (switch-to-buffer gnus-article-current-summary 'norecord)))
5886 (setq in-buffer (current-buffer))
5887 ;; We disable the pick minor mode commands.
5888 (if (and (setq func (let (gnus-pick-mode)
5889 (lookup-key (current-local-map) keys)))
5892 (call-interactively func)
5893 (when (eq win (selected-window))
5894 (setq new-sum-point (point)
5895 new-sum-start (window-start win)
5896 new-sum-hscroll (window-hscroll win)))
5897 (when (eq in-buffer (current-buffer))
5898 (setq selected (gnus-summary-select-article))
5900 (unless not-restore-window
5901 (set-window-configuration owin))
5902 (when (eq selected 'old)
5904 (set-window-start (get-buffer-window (current-buffer))
5906 (set-window-point (get-buffer-window (current-buffer))
5908 (when (and (not not-restore-window)
5910 (set-window-point win new-sum-point)
5911 (set-window-start win new-sum-start)
5912 (set-window-hscroll win new-sum-hscroll))))
5913 (set-window-configuration owin)
5916 (defun gnus-article-describe-key (key)
5917 "Display documentation of the function invoked by KEY. KEY is a string."
5918 (interactive "kDescribe key: ")
5919 (gnus-article-check-buffer)
5920 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5922 (set-buffer gnus-article-current-summary)
5923 (let (gnus-pick-mode)
5924 (if (featurep 'xemacs)
5926 (push (elt key 0) unread-command-events)
5927 (setq key (events-to-keys
5928 (read-key-sequence "Describe key: "))))
5929 (setq unread-command-events
5931 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5933 (setq key (read-key-sequence "Describe key: "))))
5935 (describe-key key)))
5937 (defun gnus-article-describe-key-briefly (key &optional insert)
5938 "Display documentation of the function invoked by KEY. KEY is a string."
5939 (interactive "kDescribe key: \nP")
5940 (gnus-article-check-buffer)
5941 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5943 (set-buffer gnus-article-current-summary)
5944 (let (gnus-pick-mode)
5945 (if (featurep 'xemacs)
5947 (push (elt key 0) unread-command-events)
5948 (setq key (events-to-keys
5949 (read-key-sequence "Describe key: "))))
5950 (setq unread-command-events
5952 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5954 (setq key (read-key-sequence "Describe key: "))))
5955 (describe-key-briefly key insert))
5956 (describe-key-briefly key insert)))
5958 (defun gnus-article-reply-with-original (&optional wide)
5959 "Start composing a reply mail to the current message.
5960 The text in the region will be yanked. If the region isn't active,
5961 the entire article will be yanked."
5963 (let ((article (cdr gnus-article-current))
5965 (if (not (gnus-region-active-p))
5966 (with-current-buffer gnus-summary-buffer
5967 (gnus-summary-reply (list (list article)) wide))
5968 (setq contents (buffer-substring (point) (mark t)))
5969 ;; Deactivate active regions.
5970 (when (and (boundp 'transient-mark-mode)
5971 transient-mark-mode)
5972 (setq mark-active nil))
5973 (with-current-buffer gnus-summary-buffer
5975 (list (list article contents)) wide)))))
5977 (defun gnus-article-followup-with-original ()
5978 "Compose a followup to the current article.
5979 The text in the region will be yanked. If the region isn't active,
5980 the entire article will be yanked."
5982 (let ((article (cdr gnus-article-current))
5984 (if (not (gnus-region-active-p))
5985 (with-current-buffer gnus-summary-buffer
5986 (gnus-summary-followup (list (list article))))
5987 (setq contents (buffer-substring (point) (mark t)))
5988 ;; Deactivate active regions.
5989 (when (and (boundp 'transient-mark-mode)
5990 transient-mark-mode)
5991 (setq mark-active nil))
5992 (with-current-buffer gnus-summary-buffer
5993 (gnus-summary-followup
5994 (list (list article contents)))))))
5996 (defun gnus-article-hide (&optional arg force)
5997 "Hide all the gruft in the current article.
5998 This means that signatures, cited text and (some) headers will be
6000 If given a prefix, show the hidden text instead."
6001 (interactive (append (gnus-article-hidden-arg) (list 'force)))
6002 (gnus-article-hide-headers arg)
6003 (gnus-article-hide-list-identifiers arg)
6004 (gnus-article-hide-citation-maybe arg force)
6005 (gnus-article-hide-signature arg))
6007 (defun gnus-article-maybe-highlight ()
6008 "Do some article highlighting if article highlighting is requested."
6009 (when (gnus-visual-p 'article-highlight 'highlight)
6010 (gnus-article-highlight-some)))
6012 (defun gnus-check-group-server ()
6013 ;; Make sure the connection to the server is alive.
6014 (unless (gnus-server-opened
6015 (gnus-find-method-for-group gnus-newsgroup-name))
6016 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
6017 (gnus-request-group gnus-newsgroup-name t)))
6020 (autoload 'nneething-get-file-name "nneething"))
6022 (defun gnus-request-article-this-buffer (article group)
6023 "Get an article and insert it into this buffer."
6024 (let (do-update-line sparse-header)
6028 (gnus-kill-all-overlays)
6029 (setq group (or group gnus-newsgroup-name))
6031 ;; Using `gnus-request-article' directly will insert the article into
6032 ;; `nntp-server-buffer' - so we'll save some time by not having to
6033 ;; copy it from the server buffer into the article buffer.
6035 ;; We only request an article by message-id when we do not have the
6036 ;; headers for it, so we'll have to get those.
6037 (when (stringp article)
6038 (gnus-read-header article))
6040 ;; If the article number is negative, that means that this article
6041 ;; doesn't belong in this newsgroup (possibly), so we find its
6042 ;; message-id and request it by id instead of number.
6043 (when (and (numberp article)
6045 (get-buffer gnus-summary-buffer)
6046 (gnus-buffer-exists-p gnus-summary-buffer))
6048 (set-buffer gnus-summary-buffer)
6049 (let ((header (gnus-summary-article-header article)))
6052 ((memq article gnus-newsgroup-sparse)
6053 ;; This is a sparse gap article.
6054 (setq do-update-line article)
6055 (setq article (mail-header-id header))
6056 (setq sparse-header (gnus-read-header article))
6057 (setq gnus-newsgroup-sparse
6058 (delq article gnus-newsgroup-sparse)))
6060 ;; It's a real article.
6061 (setq article (mail-header-id header)))
6063 ;; It is an extracted pseudo-article.
6064 (setq article 'pseudo)
6065 (gnus-request-pseudo-article header))))
6067 (let ((method (gnus-find-method-for-group
6068 gnus-newsgroup-name)))
6069 (when (and (eq (car method) 'nneething)
6071 (let ((dir (nneething-get-file-name
6072 (mail-header-id header))))
6073 (when (and (stringp dir)
6074 (file-directory-p dir))
6075 (setq article 'nneething)
6076 (gnus-group-enter-directory dir))))))))
6079 ;; Refuse to select canceled articles.
6080 ((and (numberp article)
6082 (get-buffer gnus-summary-buffer)
6083 (gnus-buffer-exists-p gnus-summary-buffer)
6084 (eq (cdr (with-current-buffer gnus-summary-buffer
6085 (assq article gnus-newsgroup-reads)))
6086 gnus-canceled-mark))
6088 ;; We first check `gnus-original-article-buffer'.
6089 ((and (get-buffer gnus-original-article-buffer)
6091 (with-current-buffer gnus-original-article-buffer
6092 (and (equal (car gnus-original-article) group)
6093 (eq (cdr gnus-original-article) article))))
6094 (insert-buffer-substring gnus-original-article-buffer)
6096 ;; Check the backlog.
6097 ((and gnus-keep-backlog
6098 (gnus-backlog-request-article group article (current-buffer)))
6100 ;; Check asynchronous pre-fetch.
6101 ((gnus-async-request-fetched-article group article (current-buffer))
6102 (gnus-async-prefetch-next group article gnus-summary-buffer)
6103 (when (and (numberp article) gnus-keep-backlog)
6104 (gnus-backlog-enter-article group article (current-buffer)))
6107 ((and gnus-use-cache
6109 (gnus-cache-request-article article group))
6111 ;; Check the agent cache.
6112 ((gnus-agent-request-article article group)
6114 ;; Get the article and put into the article buffer.
6115 ((or (stringp article)
6117 (let ((gnus-override-method gnus-override-method)
6118 (methods (and (stringp article)
6119 gnus-refer-article-method))
6120 (backend (car (gnus-find-method-for-group
6121 gnus-newsgroup-name)))
6123 (inhibit-read-only t))
6124 (if (or (not (listp methods))
6125 (and (symbolp (car methods))
6126 (assq (car methods) nnoo-definition-alist)))
6127 (setq methods (list methods)))
6128 (when (and (null gnus-override-method)
6130 (setq gnus-override-method (pop methods)))
6132 (when (eq gnus-override-method 'current)
6133 (setq gnus-override-method
6134 (with-current-buffer gnus-summary-buffer
6135 gnus-current-select-method)))
6137 (gnus-kill-all-overlays)
6138 (let ((gnus-newsgroup-name group))
6139 (gnus-check-group-server))
6141 ((gnus-request-article article group (current-buffer))
6142 (when (numberp article)
6143 (gnus-async-prefetch-next group article
6144 gnus-summary-buffer)
6145 (when gnus-keep-backlog
6146 (gnus-backlog-enter-article
6147 group article (current-buffer))))
6148 (setq result 'article))
6150 (setq gnus-override-method (pop methods)))
6151 ((not (string-match "^400 "
6152 (nnheader-get-report backend)))
6153 ;; If we get 400 server disconnect, reconnect and
6154 ;; retry; otherwise, assume the article has expired.
6155 (setq result 'done))))
6156 (and (eq result 'article) 'article)))
6160 ;; Associate this article with the current summary buffer.
6161 (setq gnus-article-current-summary gnus-summary-buffer)
6163 ;; Take the article from the original article buffer
6164 ;; and place it in the buffer it's supposed to be in.
6165 (when (and (get-buffer gnus-article-buffer)
6166 (equal (buffer-name (current-buffer))
6167 (buffer-name (get-buffer gnus-article-buffer))))
6169 (if (get-buffer gnus-original-article-buffer)
6170 (set-buffer gnus-original-article-buffer)
6171 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
6172 (buffer-disable-undo)
6173 (setq major-mode 'gnus-original-article-mode)
6174 (setq buffer-read-only t))
6175 (let ((inhibit-read-only t))
6177 (insert-buffer-substring gnus-article-buffer))
6178 (setq gnus-original-article (cons group article)))
6181 (run-hooks 'gnus-article-decode-hook)
6182 ;; Mark article as decoded or not.
6183 (setq gnus-article-decoded-p gnus-article-decode-hook))
6185 ;; Update sparse articles.
6186 (when (and do-update-line
6187 (or (numberp article)
6189 (let ((buf (current-buffer)))
6190 (set-buffer gnus-summary-buffer)
6191 (gnus-summary-update-article do-update-line sparse-header)
6192 (gnus-summary-goto-subject do-update-line nil t)
6193 (set-window-point (gnus-get-buffer-window (current-buffer) t)
6195 (set-buffer buf))))))
6201 (defcustom gnus-article-edit-mode-hook nil
6202 "Hook run in article edit mode buffers."
6203 :group 'gnus-article-various
6206 (defcustom gnus-article-edit-article-setup-function
6207 'gnus-article-mime-edit-article-setup
6208 "Function called to setup an editing article buffer."
6209 :group 'gnus-article-various
6212 (defvar gnus-article-edit-done-function nil)
6214 (defvar gnus-article-edit-mode-map nil)
6216 ;; Should we be using derived.el for this?
6217 (unless gnus-article-edit-mode-map
6218 (setq gnus-article-edit-mode-map (make-keymap))
6219 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
6221 (gnus-define-keys gnus-article-edit-mode-map
6222 "\C-c?" describe-mode
6223 "\C-c\C-c" gnus-article-edit-done
6224 "\C-c\C-k" gnus-article-edit-exit
6225 "\C-c\C-f\C-t" message-goto-to
6226 "\C-c\C-f\C-o" message-goto-from
6227 "\C-c\C-f\C-b" message-goto-bcc
6228 ;;"\C-c\C-f\C-w" message-goto-fcc
6229 "\C-c\C-f\C-c" message-goto-cc
6230 "\C-c\C-f\C-s" message-goto-subject
6231 "\C-c\C-f\C-r" message-goto-reply-to
6232 "\C-c\C-f\C-n" message-goto-newsgroups
6233 "\C-c\C-f\C-d" message-goto-distribution
6234 "\C-c\C-f\C-f" message-goto-followup-to
6235 "\C-c\C-f\C-m" message-goto-mail-followup-to
6236 "\C-c\C-f\C-k" message-goto-keywords
6237 "\C-c\C-f\C-u" message-goto-summary
6238 "\C-c\C-f\C-i" message-insert-or-toggle-importance
6239 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
6240 "\C-c\C-b" message-goto-body
6241 "\C-c\C-i" message-goto-signature
6243 "\C-c\C-t" message-insert-to
6244 "\C-c\C-n" message-insert-newsgroups
6245 "\C-c\C-o" message-sort-headers
6246 "\C-c\C-e" message-elide-region
6247 "\C-c\C-v" message-delete-not-region
6248 "\C-c\C-z" message-kill-to-signature
6249 "\M-\r" message-newline-and-reformat
6250 "\C-c\C-a" mml-attach-file
6251 "\C-a" message-beginning-of-line
6253 "\M-;" comment-region)
6255 (gnus-define-keys (gnus-article-edit-wash-map
6256 "\C-c\C-w" gnus-article-edit-mode-map)
6257 "f" gnus-article-edit-full-stops))
6260 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
6262 ["Fetch To" message-insert-to t]
6263 ["Fetch Newsgroups" message-insert-newsgroups t]
6265 ["To" message-goto-to t]
6266 ["From" message-goto-from t]
6267 ["Subject" message-goto-subject t]
6268 ["Cc" message-goto-cc t]
6269 ["Reply-To" message-goto-reply-to t]
6270 ["Summary" message-goto-summary t]
6271 ["Keywords" message-goto-keywords t]
6272 ["Newsgroups" message-goto-newsgroups t]
6273 ["Followup-To" message-goto-followup-to t]
6274 ["Mail-Followup-To" message-goto-mail-followup-to t]
6275 ["Distribution" message-goto-distribution t]
6276 ["Body" message-goto-body t]
6277 ["Signature" message-goto-signature t]))
6279 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
6280 "Major mode for editing articles.
6281 This is an extended text-mode.
6283 \\{gnus-article-edit-mode-map}"
6284 (make-local-variable 'gnus-article-edit-done-function)
6285 (make-local-variable 'gnus-prev-winconf)
6286 (set (make-local-variable 'font-lock-defaults)
6287 '(message-font-lock-keywords t))
6288 (set (make-local-variable 'mail-header-separator) "")
6289 (set (make-local-variable 'gnus-article-edit-mode) t)
6290 (easy-menu-add message-mode-field-menu message-mode-map)
6291 (setq buffer-read-only nil)
6292 (buffer-enable-undo)
6295 (defun gnus-article-edit (&optional force)
6296 "Edit the current article.
6297 This will have permanent effect only in mail groups.
6298 If FORCE is non-nil, allow editing of articles even in read-only
6301 (when (and (not force)
6302 (gnus-group-read-only-p))
6303 (error "The current newsgroup does not support article editing"))
6304 (gnus-article-date-original)
6305 (gnus-article-edit-article
6307 `(lambda (no-highlight)
6309 (gnus-summary-edit-article-done
6310 ,(or (mail-header-references gnus-current-headers) "")
6311 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
6313 (defun gnus-article-edit-article (start-func exit-func &optional quiet)
6314 "Start editing the contents of the current article buffer."
6315 (let ((winconf (current-window-configuration)))
6316 (set-buffer gnus-article-buffer)
6317 (let ((message-auto-save-directory
6318 ;; Don't associate the article buffer with a draft file.
6320 (gnus-article-edit-mode))
6321 (funcall start-func)
6322 (set-buffer-modified-p nil)
6323 (gnus-configure-windows 'edit-article)
6324 (setq gnus-article-edit-done-function exit-func)
6325 (setq gnus-prev-winconf winconf)
6326 (when gnus-article-edit-article-setup-function
6327 (funcall gnus-article-edit-article-setup-function))
6329 (gnus-message 6 "C-c C-c to end edits; C-c C-k to exit"))))
6331 (defun gnus-article-edit-done (&optional arg)
6332 "Update the article edits and exit."
6334 (let ((func gnus-article-edit-done-function)
6335 (buf (current-buffer))
6336 (start (window-start))
6338 (winconf gnus-prev-winconf))
6339 (remove-hook 'gnus-article-mode-hook
6340 'gnus-article-mime-edit-article-unwind)
6341 (widen) ;; Widen it in case that users narrowed the buffer.
6344 ;; The cache and backlog have to be flushed somewhat.
6345 (when gnus-keep-backlog
6346 (gnus-backlog-remove-article
6347 (car gnus-article-current) (cdr gnus-article-current)))
6348 ;; Flush original article as well.
6350 (when (get-buffer gnus-original-article-buffer)
6351 (set-buffer gnus-original-article-buffer)
6352 (setq gnus-original-article nil)))
6353 (when gnus-use-cache
6354 (gnus-cache-update-article
6355 (car gnus-article-current) (cdr gnus-article-current)))
6356 ;; We remove all text props from the article buffer.
6357 (kill-all-local-variables)
6358 (set-text-properties (point-min) (point-max) nil)
6360 (set-window-configuration winconf)
6362 (set-window-start (get-buffer-window buf) start)
6363 (set-window-point (get-buffer-window buf) (point)))
6364 (gnus-summary-show-article))
6366 (defun gnus-article-edit-exit ()
6367 "Exit the article editing without updating."
6369 (when (or (not (buffer-modified-p))
6370 (yes-or-no-p "Article modified; kill anyway? "))
6371 (let ((curbuf (current-buffer))
6373 (window-start (window-start)))
6375 (if (gnus-buffer-live-p gnus-original-article-buffer)
6376 (insert-buffer-substring gnus-original-article-buffer))
6377 (let ((winconf gnus-prev-winconf))
6378 (kill-all-local-variables)
6380 (set-window-configuration winconf)
6381 ;; Tippy-toe some to make sure that point remains where it was.
6382 (save-current-buffer
6384 (set-window-start (get-buffer-window (current-buffer)) window-start)
6386 (gnus-summary-show-article)))
6388 (defun gnus-article-edit-full-stops ()
6389 "Interactively repair spacing at end of sentences."
6392 (goto-char (point-min))
6393 (search-forward-regexp "^$" nil t)
6394 (let ((case-fold-search nil))
6395 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
6398 ;;; Article editing with MIME-Edit
6401 (defcustom gnus-article-mime-edit-article-setup-hook nil
6402 "Hook run after setting up a MIME editing article buffer."
6403 :group 'gnus-article-various
6406 (defun gnus-article-mime-edit-article-unwind ()
6407 "Unwind `gnus-article-buffer' if article editing was given up."
6408 (remove-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6409 (when (featurep 'font-lock)
6410 (setq font-lock-defaults nil)
6411 (font-lock-mode -1))
6412 (when mime-edit-mode-flag
6413 (mime-edit-exit 'nomime 'no-error)
6416 (defun gnus-article-mime-edit-article-setup ()
6417 "Convert current buffer to MIME-Edit buffer and turn on MIME-Edit mode
6418 after replacing with the original article."
6419 (setq gnus-show-mime t)
6420 (setq gnus-article-edit-done-function
6421 `(lambda (&rest args)
6422 (when mime-edit-mode-flag
6423 (let (mime-edit-insert-user-agent-field)
6426 (goto-char (point-min))
6427 (let (case-fold-search)
6428 (when (re-search-forward
6429 (format "^%s$" (regexp-quote mail-header-separator))
6431 (replace-match "")))
6432 (apply ,gnus-article-edit-done-function args)
6435 (buffer-substring-no-properties (point-min) (point-max))
6436 (set-buffer (get-buffer-create gnus-original-article-buffer))
6438 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6439 (set-buffer gnus-article-buffer)
6440 (gnus-article-prepare-display)))
6441 (substitute-key-definition 'gnus-article-edit-done
6442 'gnus-article-mime-edit-done
6443 gnus-article-edit-mode-map)
6444 (substitute-key-definition 'gnus-article-edit-exit
6445 'gnus-article-mime-edit-exit
6446 gnus-article-edit-mode-map)
6448 (insert-buffer-substring gnus-original-article-buffer)
6449 (unless (member (with-current-buffer gnus-summary-buffer
6450 gnus-newsgroup-name)
6451 '("nndraft:delayed" "nndraft:drafts"))
6452 (let ((ofn (symbol-function 'mime-edit-decode-single-part-in-buffer)))
6453 (fset 'mime-edit-decode-single-part-in-buffer
6454 (lambda (&rest args)
6455 (if (let ((content-type (car args)))
6456 (and (eq 'message (mime-content-type-primary-type
6458 (eq 'rfc822 (mime-content-type-subtype
6460 (setcar (cdr args) 'not-decode-text))
6464 (fset 'mime-edit-decode-single-part-in-buffer ofn))))
6465 (when (featurep 'font-lock)
6466 (set (make-local-variable 'font-lock-defaults)
6467 '(message-font-lock-keywords t))
6468 (font-lock-set-defaults)
6469 (turn-on-font-lock))
6470 (set-buffer-modified-p nil)
6471 (delete-other-windows)
6472 (add-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6473 (gnus-run-hooks 'gnus-article-mime-edit-article-setup-hook))
6475 (defun gnus-article-mime-edit-done (&optional arg)
6476 "Update the article MIME edits and exit."
6478 (when (featurep 'font-lock)
6479 (setq font-lock-defaults nil)
6480 (font-lock-mode -1))
6481 (let ((inhibit-read-only t))
6482 (gnus-article-edit-done arg)))
6484 (defun gnus-article-mime-edit-exit ()
6485 "Exit the article MIME editing without updating."
6487 (when (or (not (buffer-modified-p))
6488 (yes-or-no-p "Article modified; kill anyway? "))
6489 (when (featurep 'font-lock)
6490 (setq font-lock-defaults nil)
6491 (font-lock-mode -1))
6492 (when mime-edit-mode-flag
6493 (let (mime-edit-insert-user-agent-field)
6496 (goto-char (point-min))
6497 (let (case-fold-search)
6498 (when (re-search-forward
6499 (format "^%s$" (regexp-quote mail-header-separator)) nil t)
6500 (replace-match "")))
6501 (let ((winconf gnus-prev-winconf))
6503 (buffer-substring-no-properties (point-min) (point-max))
6504 (set-buffer (get-buffer-create gnus-original-article-buffer))
6506 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6507 (set-buffer gnus-article-buffer)
6508 (gnus-article-prepare-display)
6509 (set-window-configuration winconf))))
6512 ;;; Article highlights
6515 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
6517 ;;; Internal Variables:
6519 (defcustom gnus-button-url-regexp
6520 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
6521 "\\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:]]\\)"
6522 "\\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\\)\\)")
6523 "Regular expression that matches URLs."
6524 :group 'gnus-article-buttons
6527 (defcustom gnus-button-valid-fqdn-regexp
6528 message-valid-fqdn-regexp
6529 "Regular expression that matches a valid FQDN."
6531 :group 'gnus-article-buttons
6534 ;; Regexp suggested by Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
6535 (defcustom gnus-button-valid-localpart-regexp
6536 "[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t ]*"
6537 "Regular expression that matches a localpart of mail addresses or MIDs."
6539 :group 'gnus-article-buttons
6542 (defcustom gnus-button-man-handler 'manual-entry
6543 "Function to use for displaying man pages.
6544 The function must take at least one argument with a string naming the
6547 :type '(choice (function-item :tag "Man" manual-entry)
6548 (function-item :tag "Woman" woman)
6549 (function :tag "Other"))
6550 :group 'gnus-article-buttons)
6552 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
6553 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
6554 If the default site is too slow, try to find a CTAN mirror, see
6555 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
6556 the variable `gnus-button-handle-ctan'."
6558 :group 'gnus-article-buttons
6559 :link '(custom-manual "(gnus)Group Parameters")
6560 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
6561 (const "http://tug.ctan.org/tex-archive/")
6562 (const "http://www.dante.de/CTAN/")
6563 (string :tag "Other")))
6565 (defcustom gnus-button-ctan-handler 'browse-url
6566 "Function to use for displaying CTAN links.
6567 The function must take one argument, the string naming the URL."
6569 :type '(choice (function-item :tag "Browse Url" browse-url)
6570 (function :tag "Other"))
6571 :group 'gnus-article-buttons)
6573 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
6574 "Bogus strings removed from CTAN URLs."
6576 :group 'gnus-article-buttons
6577 :type '(choice (const "^/?tex-archive/\\|/")
6578 (regexp :tag "Other")))
6580 (defcustom gnus-button-ctan-directory-regexp
6582 (list "archive-tools" "biblio" "bibliography" "digests" "documentation"
6583 "dviware" "fonts" "graphics" "help" "indexing" "info" "language"
6584 "languages" "macros" "nonfree" "obsolete" "support" "systems"
6585 "tds" "tools" "usergrps" "web") t)
6586 "Regular expression for ctan directories.
6587 It should match all directories in the top level of `gnus-ctan-url'."
6589 :group 'gnus-article-buttons
6592 (defcustom gnus-button-mid-or-mail-regexp
6593 (concat "\\b\\(<?" gnus-button-valid-localpart-regexp "@"
6594 gnus-button-valid-fqdn-regexp
6596 "Regular expression that matches a message ID or a mail address."
6598 :group 'gnus-article-buttons
6601 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
6602 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
6603 Strings like this can be either a message ID or a mail address. If it is one
6604 of the symbols `mid' or `mail', Gnus will always assume that the string is a
6605 message ID or a mail address, respectively. If this variable is set to the
6606 symbol `ask', always query the user what do do. If it is a function, this
6607 function will be called with the string as it's only argument. The function
6608 must return `mid', `mail', `invalid' or `ask'."
6610 :group 'gnus-article-buttons
6611 :type '(choice (function-item :tag "Heuristic function"
6612 gnus-button-mid-or-mail-heuristic)
6617 (defcustom gnus-button-mid-or-mail-heuristic-alist
6618 '((-10.0 . ".+\\$.+@")
6621 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
6622 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
6623 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
6624 (-1.0 . "^[^a-z]+@")
6626 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
6627 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
6628 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
6629 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
6632 (-1.0 . "^[0-9][0-9]")
6634 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
6635 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6636 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
6637 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6639 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
6640 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
6643 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
6645 ;; compensation for TDMA dated mail addresses:
6646 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
6648 (-20.0 . "\\.fsf@") ;; Gnus
6651 (-20.0 . "_-_") ;; Subject change in thread
6653 (-20.0 . "\\.ln@") ;; leafnode
6654 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
6655 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
6657 ;; (5.0 . "") ;; $local_part_len <= 7
6658 (10.0 . "^[^0-9]+@")
6659 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
6660 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
6663 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
6665 (0.5 . "^[A-Z][a-z]")
6666 (0.5 . "^[A-Z][a-z][a-z]")
6667 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
6668 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
6669 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
6671 A negative RATE indicates a message IDs, whereas a positive indicates a mail
6672 address. The REGEXP is processed with `case-fold-search' set to nil."
6674 :group 'gnus-article-buttons
6675 :type '(repeat (cons (number :tag "Rate")
6676 (regexp :tag "Regexp"))))
6678 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
6679 "Guess whether MID-OR-MAIL is a message ID or a mail address.
6680 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
6681 address, `ask' if unsure and `invalid' if the string is invalid."
6682 (let ((case-fold-search nil)
6683 (list gnus-button-mid-or-mail-heuristic-alist)
6684 (result 0) rate regexp lpartlen elem)
6686 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
6687 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
6688 ;; Certain special cases...
6691 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
6692 "^[0-9]+\\.[0-9]+@compuserve\\|"
6693 "@public\\.gmane\\.org")
6695 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
6696 (setq result 'mail))
6697 (when (string-match "@.*@\\| " mid-or-mail)
6698 (gnus-message 8 "`%s' is invalid." mid-or-mail)
6699 (setq result 'invalid))
6700 ;; Nothing more to do, if result is not a number here...
6701 (when (numberp result)
6703 (setq elem (car list)
6707 (when (string-match regexp mid-or-mail)
6708 (setq result (+ result rate))
6710 9 "`%s' matched `%s', rate `%s', result `%s'."
6711 mid-or-mail regexp rate result)))
6712 (when (<= lpartlen 7)
6713 (setq result (+ result 5.0))
6714 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
6715 mid-or-mail result))
6716 (when (>= lpartlen 12)
6717 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
6719 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
6720 ;; Long local part should contain realname if e-mail address,
6721 ;; too many digits: message-id.
6722 ;; $score -= 5.0 + 0.1 * $local_part_len;
6723 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6724 (setq result (+ result rate))
6726 9 "Many digits in `%s', rate `%s', result `%s'."
6727 mid-or-mail rate result))
6728 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6730 ;; Too few vowels [^aeiouy]{4,}.*\@
6731 (setq result (+ result -5.0))
6733 9 "Few vowels in `%s', rate `%s', result `%s'."
6734 mid-or-mail -5.0 result))
6736 (setq result (+ result 5.0))
6738 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6739 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6740 ;; Maybe we should make this a customizable alist: (condition . 'result)
6742 ((symbolp result) result)
6743 ;; Now convert number into proper results:
6744 ((< result -10.0) 'mid)
6745 ((> result 10.0) 'mail)
6748 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6749 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6750 (url-mid (concat "news" ":" mid-or-mail))
6751 (url-mailto (concat "mailto" ":" mid-or-mail)))
6752 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6753 (when (fboundp pref)
6755 ;; get rid of surrounding angles...
6757 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6758 (if (or (eq 'mid guessed) (eq 'mail guessed))
6762 (save-window-excursion
6763 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6766 (cond ((eq pref 'mid)
6767 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6768 (gnus-button-handle-news url-mid))
6770 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6771 (gnus-url-mailto url-mailto))
6772 (t (gnus-message 3 "Invalid string.")))))
6774 (defun gnus-button-handle-custom (url)
6775 "Follow a Custom URL."
6776 (customize-apropos (gnus-url-unhex-string url)))
6778 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6780 ;; FIXME: Maybe we should merge some of the functions that do quite similar
6783 (defun gnus-button-handle-describe-function (url)
6784 "Call `describe-function' when pushing the corresponding URL button."
6787 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6789 (defun gnus-button-handle-describe-variable (url)
6790 "Call `describe-variable' when pushing the corresponding URL button."
6793 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6795 (defun gnus-button-handle-symbol (url)
6796 "Display help on variable or function.
6797 Calls `describe-variable' or `describe-function'."
6798 (let ((sym (intern url)))
6800 ((fboundp sym) (describe-function sym))
6801 ((boundp sym) (describe-variable sym))
6802 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
6804 (defun gnus-button-handle-describe-key (url)
6805 "Call `describe-key' when pushing the corresponding URL button."
6807 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6808 (keys (ignore-errors (eval `(kbd ,key-string)))))
6811 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6813 (defun gnus-button-handle-apropos (url)
6814 "Call `apropos' when pushing the corresponding URL button."
6815 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6817 (defun gnus-button-handle-apropos-command (url)
6818 "Call `apropos' when pushing the corresponding URL button."
6820 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6822 (defun gnus-button-handle-apropos-variable (url)
6823 "Call `apropos' when pushing the corresponding URL button."
6825 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6826 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6828 (defun gnus-button-handle-apropos-documentation (url)
6829 "Call `apropos' when pushing the corresponding URL button."
6831 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6832 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6834 (defun gnus-button-handle-library (url)
6835 "Call `locate-library' when pushing the corresponding URL button."
6836 (gnus-message 9 "url=`%s'" url)
6837 (let* ((lib (locate-library url))
6838 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6840 (gnus-message 1 "Cannot locale library `%s'." url)
6841 (find-file-read-only file))))
6843 (defun gnus-button-handle-ctan (url)
6844 "Call `browse-url' when pushing a CTAN URL button."
6846 gnus-button-ctan-handler
6849 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6851 (defcustom gnus-button-tex-level 5
6852 "*Integer that says how many TeX-related buttons Gnus will show.
6853 The higher the number, the more buttons will appear and the more false
6854 positives are possible. Note that you can set this variable local to
6855 specific groups. Setting it higher in TeX groups is probably a good idea.
6856 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6857 how to set variables in specific groups."
6859 :group 'gnus-article-buttons
6860 :link '(custom-manual "(gnus)Group Parameters")
6863 (defcustom gnus-button-man-level 5
6864 "*Integer that says how many man-related buttons Gnus will show.
6865 The higher the number, the more buttons will appear and the more false
6866 positives are possible. Note that you can set this variable local to
6867 specific groups. Setting it higher in Unix groups is probably a good idea.
6868 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6869 how to set variables in specific groups."
6871 :group 'gnus-article-buttons
6872 :link '(custom-manual "(gnus)Group Parameters")
6875 (defcustom gnus-button-emacs-level 5
6876 "*Integer that says how many emacs-related buttons Gnus will show.
6877 The higher the number, the more buttons will appear and the more false
6878 positives are possible. Note that you can set this variable local to
6879 specific groups. Setting it higher in Emacs or Gnus related groups is
6880 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6881 `gnus-parameters' on how to set variables in specific groups."
6883 :group 'gnus-article-buttons
6884 :link '(custom-manual "(gnus)Group Parameters")
6887 (defcustom gnus-button-message-level 5
6888 "*Integer that says how many buttons for news or mail messages will appear.
6889 The higher the number, the more buttons will appear and the more false
6890 positives are possible."
6891 ;; mail addresses, MIDs, URLs for news, ...
6893 :group 'gnus-article-buttons
6896 (defcustom gnus-button-browse-level 5
6897 "*Integer that says how many buttons for browsing will appear.
6898 The higher the number, the more buttons will appear and the more false
6899 positives are possible."
6900 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6902 :group 'gnus-article-buttons
6905 (defcustom gnus-button-alist
6906 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6907 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6908 ((concat "\\b\\(nntp\\|news\\):\\("
6909 gnus-button-valid-localpart-regexp "@[a-z0-9.-]+[a-z]\\)")
6910 0 t gnus-button-handle-news 2)
6911 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6912 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6913 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6914 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6915 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
6916 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
6917 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
6918 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6919 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6920 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6921 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6922 ;; RFC 2368 (The mailto URL scheme)
6923 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6924 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6925 ("\\bmailto:\\([^ \n\t]+\\)"
6926 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6928 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6929 gnus-button-ctan-directory-regexp
6930 "[^][>)!;:,'\n\t ]+\\)")
6931 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6932 ((concat "\\btex-archive/\\("
6933 gnus-button-ctan-directory-regexp
6934 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6935 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6938 gnus-button-ctan-directory-regexp
6939 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6940 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6941 ;; This is info (home-grown style) <info://foo/bar+baz>
6942 ("\\binfo://\\([^'\">\n\t ]+\\)"
6943 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6944 ;; Info GNOME style <info:foo#bar_baz>
6945 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6946 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6947 ;; Info KDE style <info:(foo)bar baz>
6948 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6949 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6950 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6951 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6952 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6953 ;; Info links like `C-h i d m CC Mode RET'
6954 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6956 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6957 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6958 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6959 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6960 ;; Emacs help commands
6961 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6962 ;; regexp doesn't match arguments containing ` '.
6963 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6964 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6965 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6966 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6967 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6968 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6969 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6970 ;; The following entries may lead to many false positives so don't enable
6971 ;; them by default (use a high button level).
6972 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
6973 ;; Exclude [.?] for URLs in gmane.emacs.cvs
6974 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6975 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6976 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6977 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6978 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6979 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6980 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6981 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6982 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6983 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6984 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
6985 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6986 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6987 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6988 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6989 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6990 ;; Unlike the other regexps we really have to require quoting
6991 ;; here to determine where it ends.
6992 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6993 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
6994 ("<URL: *\\([^<>]*\\)>"
6995 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6996 ;; RFC 2396 (2.4.3., delims) ...
6997 ("\"URL: *\\([^\"]*\\)\""
6998 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6999 ;; RFC 2396 (2.4.3., delims) ...
7000 ("\"URL: *\\([^\"]*\\)\""
7001 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
7003 (gnus-button-url-regexp
7004 0 (>= gnus-button-browse-level 0) browse-url 0)
7006 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
7007 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
7008 gnus-button-handle-man 1)
7009 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
7010 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
7011 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
7012 gnus-button-handle-man 1)
7013 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
7014 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
7015 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
7016 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
7017 ;; MID or mail: To avoid too many false positives we don't try to catch
7018 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
7019 ;; at least one dot. TLD must contain two or three chars or be a know TLD
7020 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
7021 ;; so that non-ambiguous entries (see above) match first.
7022 (gnus-button-mid-or-mail-regexp
7023 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
7024 "*Alist of regexps matching buttons in article bodies.
7026 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
7027 REGEXP: is the string (case insensitive) matching text around the button (can
7028 also be Lisp expression evaluating to a string),
7029 BUTTON: is the number of the regexp grouping actually matching the button,
7030 FORM: is a Lisp expression which must eval to true for the button to
7032 CALLBACK: is the function to call when the user push this button, and each
7033 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
7035 CALLBACK can also be a variable, in that case the value of that
7036 variable it the real callback function."
7037 :group 'gnus-article-buttons
7038 :type '(repeat (list (choice regexp variable sexp)
7039 (integer :tag "Button")
7041 (function :tag "Callback")
7044 (integer :tag "Regexp group")))))
7046 (defcustom gnus-header-button-alist
7047 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
7048 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
7049 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
7050 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
7051 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
7052 0 (>= gnus-button-message-level 0) gnus-msg-mail 0)
7053 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
7054 0 (>= gnus-button-browse-level 0) browse-url 0)
7055 ("^Subject:" gnus-button-url-regexp
7056 0 (>= gnus-button-browse-level 0) browse-url 0)
7057 ("^[^:]+:" gnus-button-url-regexp
7058 0 (>= gnus-button-browse-level 0) browse-url 0)
7059 ("^OpenPGP:.*url=" gnus-button-url-regexp
7060 0 (>= gnus-button-browse-level 0) gnus-button-openpgp 0)
7061 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
7062 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
7063 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
7064 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
7065 "*Alist of headers and regexps to match buttons in article heads.
7067 This alist is very similar to `gnus-button-alist', except that each
7068 alist has an additional HEADER element first in each entry:
7070 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
7072 HEADER is a regexp to match a header. For a fuller explanation, see
7073 `gnus-button-alist'."
7074 :group 'gnus-article-buttons
7075 :group 'gnus-article-headers
7076 :type '(repeat (list (regexp :tag "Header")
7077 (choice regexp variable)
7078 (integer :tag "Button")
7080 (function :tag "Callback")
7083 (integer :tag "Regexp group")))))
7087 (defun gnus-article-push-button (event)
7088 "Check text under the mouse pointer for a callback function.
7089 If the text under the mouse pointer has a `gnus-callback' property,
7090 call it with the value of the `gnus-data' text property."
7092 (set-buffer (window-buffer (posn-window (event-start event))))
7093 (let* ((pos (posn-point (event-start event)))
7094 (data (get-text-property pos 'gnus-data))
7095 (fun (get-text-property pos 'gnus-callback)))
7098 (funcall fun data))))
7100 (defun gnus-article-press-button ()
7101 "Check text at point for a callback function.
7102 If the text at point has a `gnus-callback' property,
7103 call it with the value of the `gnus-data' text property."
7105 (let ((data (get-text-property (point) 'gnus-data))
7106 (fun (get-text-property (point) 'gnus-callback)))
7108 (funcall fun data))))
7110 (defun gnus-article-prev-button (n)
7111 "Move point to N buttons backward.
7112 If N is negative, move forward instead."
7114 (gnus-article-next-button (- n)))
7116 (defun gnus-article-next-button (n)
7117 "Move point to N buttons forward.
7118 If N is negative, move backward instead."
7120 (let ((function (if (< n 0) 'previous-single-property-change
7121 'next-single-property-change))
7122 (inhibit-point-motion-hooks t)
7124 (limit (if (< n 0) (point-min) (point-max))))
7126 (while (and (not (= limit (point)))
7128 ;; Skip past the current button.
7129 (when (get-text-property (point) 'gnus-callback)
7130 (goto-char (funcall function (point) 'gnus-callback nil limit)))
7131 ;; Go to the next (or previous) button.
7132 (gnus-goto-char (funcall function (point) 'gnus-callback nil limit))
7133 ;; Put point at the start of the button.
7134 (when (and backward (not (get-text-property (point) 'gnus-callback)))
7135 (goto-char (funcall function (point) 'gnus-callback nil limit)))
7136 ;; Skip past intangible buttons.
7137 (when (get-text-property (point) 'intangible)
7141 (gnus-message 5 "No more buttons"))
7144 (defun gnus-article-highlight (&optional force)
7145 "Highlight current article.
7146 This function calls `gnus-article-highlight-headers',
7147 `gnus-article-highlight-citation',
7148 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
7149 do the highlighting. See the documentation for those functions."
7150 (interactive (list 'force))
7151 (gnus-article-highlight-headers)
7152 (gnus-article-highlight-citation force)
7153 (gnus-article-highlight-signature)
7154 (gnus-article-add-buttons force)
7155 (gnus-article-add-buttons-to-head))
7157 (defun gnus-article-highlight-some (&optional force)
7158 "Highlight current article.
7159 This function calls `gnus-article-highlight-headers',
7160 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
7161 do the highlighting. See the documentation for those functions."
7162 (interactive (list 'force))
7163 (gnus-article-highlight-headers)
7164 (gnus-article-highlight-signature)
7165 (gnus-article-add-buttons))
7167 (defun gnus-article-highlight-headers ()
7168 "Highlight article headers as specified by `gnus-header-face-alist'."
7170 (gnus-with-article-headers
7171 (let (regexp header-face field-face from hpoints fpoints)
7172 (dolist (entry gnus-header-face-alist)
7173 (goto-char (point-min))
7174 (setq regexp (concat "^\\("
7175 (if (string-equal "" (nth 0 entry))
7179 header-face (nth 1 entry)
7180 field-face (nth 2 entry))
7181 (while (and (re-search-forward regexp nil t)
7185 (unless (search-forward ":" nil t)
7187 (when (and header-face
7188 (not (memq (point) hpoints)))
7189 (push (point) hpoints)
7190 (gnus-put-text-property from (point) 'face header-face))
7191 (when (and field-face
7192 (not (memq (setq from (point)) fpoints)))
7194 (if (re-search-forward "^[^ \t]" nil t)
7196 (goto-char (point-max)))
7197 (gnus-put-text-property from (point) 'face field-face)))))))
7199 (defun gnus-article-highlight-signature ()
7200 "Highlight the signature in an article.
7201 It does this by highlighting everything after
7202 `gnus-signature-separator' using the face `gnus-signature'."
7204 (when gnus-signature-face
7205 (gnus-with-article-buffer
7206 (let ((inhibit-point-motion-hooks t))
7208 (when (gnus-article-narrow-to-signature)
7209 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
7210 'face gnus-signature-face)))))))
7212 (defun gnus-article-buttonize-signature ()
7213 "Add button to the signature."
7216 (set-buffer gnus-article-buffer)
7217 (let ((inhibit-read-only t)
7218 (inhibit-point-motion-hooks t))
7219 (when (gnus-article-search-signature)
7220 (gnus-article-add-button (match-beginning 0) (match-end 0)
7221 'gnus-signature-toggle
7222 (set-marker (make-marker)
7223 (1+ (match-end 0))))))))
7225 (defun gnus-button-in-region-p (b e prop)
7226 "Say whether PROP exists in the region."
7227 (text-property-not-all b e prop nil))
7229 (defun gnus-article-add-buttons (&optional force)
7230 "Find external references in the article and make buttons of them.
7231 \"External references\" are things like Message-IDs and URLs, as
7232 specified by `gnus-button-alist'."
7233 (interactive (list 'force))
7234 (gnus-with-article-buffer
7235 (let ((inhibit-point-motion-hooks t)
7236 (case-fold-search t)
7237 (alist gnus-button-alist)
7239 ;; Remove all old markers.
7240 (let (marker entry new-list)
7241 (while (setq marker (pop gnus-button-marker-list))
7242 (if (or (< marker (point-min)) (>= marker (point-max)))
7243 (push marker new-list)
7245 (when (setq entry (gnus-button-entry))
7246 (put-text-property (match-beginning (nth 1 entry))
7247 (match-end (nth 1 entry))
7248 'gnus-callback nil))
7249 (set-marker marker nil)))
7250 (setq gnus-button-marker-list new-list))
7251 ;; We skip the headers.
7254 (while (setq entry (pop alist))
7255 (setq regexp (eval (car entry)))
7257 (while (re-search-forward regexp nil t)
7258 (let* ((start (and entry (match-beginning (nth 1 entry))))
7259 (end (and entry (match-end (nth 1 entry))))
7260 (from (match-beginning 0)))
7261 (when (and (or (eq t (nth 2 entry))
7262 (eval (nth 2 entry)))
7263 (not (gnus-button-in-region-p
7264 start end 'gnus-callback)))
7265 ;; That optional form returned non-nil, so we add the
7267 (gnus-article-add-button
7268 start end 'gnus-button-push
7269 (car (push (set-marker (make-marker) from)
7270 gnus-button-marker-list))))))))))
7272 ;; Add buttons to the head of an article.
7273 (defun gnus-article-add-buttons-to-head ()
7274 "Add buttons to the head of the article."
7276 (gnus-with-article-headers
7278 (dolist (entry gnus-header-button-alist)
7279 ;; Each alist entry.
7280 (goto-char (point-min))
7281 (while (re-search-forward (car entry) nil t)
7282 ;; Each header matching the entry.
7283 (setq beg (match-beginning 0))
7284 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
7285 (match-beginning 0))
7288 (while (re-search-forward (eval (nth 1 entry)) end t)
7289 ;; Each match within a header.
7290 (let* ((entry (cdr entry))
7291 (start (match-beginning (nth 1 entry)))
7292 (end (match-end (nth 1 entry)))
7293 (form (nth 2 entry)))
7294 (goto-char (match-end 0))
7296 (gnus-article-add-button
7297 start end (nth 3 entry)
7298 (buffer-substring (match-beginning (nth 4 entry))
7299 (match-end (nth 4 entry)))))))
7300 (goto-char end))))))
7302 ;;; External functions:
7304 (defun gnus-article-add-button (from to fun &optional data)
7305 "Create a button between FROM and TO with callback FUN and data DATA."
7306 (when gnus-article-button-face
7307 (gnus-overlay-put (gnus-make-overlay from to)
7308 'face gnus-article-button-face))
7309 (gnus-add-text-properties
7311 (nconc (and gnus-article-mouse-face
7312 (list gnus-mouse-face-prop gnus-article-mouse-face))
7313 (list 'gnus-callback fun)
7314 (and data (list 'gnus-data data))))
7315 (widget-convert-button 'link from to :action 'gnus-widget-press-button
7316 :button-keymap gnus-widget-button-keymap))
7318 ;;; Internal functions:
7320 (defun gnus-article-set-globals ()
7321 (with-current-buffer gnus-summary-buffer
7322 (gnus-set-global-variables)))
7324 (defun gnus-signature-toggle (end)
7325 (gnus-with-article-buffer
7326 (let ((inhibit-point-motion-hooks t)
7327 (limit (next-single-property-change end 'mime-view-entity
7329 (if (text-property-any end limit 'article-type 'signature)
7331 (gnus-delete-wash-type 'signature)
7332 (gnus-remove-text-properties-when
7333 'article-type 'signature end limit
7334 (cons 'article-type (cons 'signature
7335 gnus-hidden-properties))))
7336 (gnus-add-wash-type 'signature)
7337 (gnus-add-text-properties-when
7338 'article-type nil end limit
7339 (cons 'article-type (cons 'signature
7340 gnus-hidden-properties)))))
7341 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
7342 (gnus-set-mode-line 'article))))
7344 (defun gnus-button-entry ()
7345 ;; Return the first entry in `gnus-button-alist' matching this place.
7346 (let ((alist gnus-button-alist)
7349 (setq entry (pop alist))
7350 (if (looking-at (eval (car entry)))
7355 (defun gnus-button-push (marker)
7356 ;; Push button starting at MARKER.
7359 (let* ((entry (gnus-button-entry))
7360 (inhibit-point-motion-hooks t)
7362 (args (mapcar (lambda (group)
7363 (let ((string (match-string group)))
7364 (set-text-properties
7365 0 (length string) nil string)
7372 (fboundp (symbol-value fun)))
7373 (apply (symbol-value fun) args))
7375 (gnus-message 1 "You must define `%S' to use this button"
7376 (cons fun args)))))))
7378 (defun gnus-parse-news-url (url)
7379 (let (scheme server port group message-id articles)
7382 (goto-char (point-min))
7383 (when (looking-at "\\([A-Za-z]+\\):")
7384 (setq scheme (match-string 1))
7385 (goto-char (match-end 0)))
7386 (when (looking-at "//\\([^:/]+\\)\\(:?\\)\\([0-9]+\\)?/")
7387 (setq server (match-string 1))
7388 (setq port (if (stringp (match-string 3))
7389 (string-to-number (match-string 3))
7391 (goto-char (match-end 0)))
7394 ((looking-at "\\(.*@.*\\)")
7395 (setq message-id (match-string 1)))
7396 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
7397 (setq group (match-string 1)
7398 articles (split-string (match-string 2) "-")))
7399 ((looking-at "\\([^/]+\\)/?")
7400 (setq group (match-string 1)))
7402 (error "Unknown news URL syntax"))))
7403 (list scheme server port group message-id articles)))
7405 (defun gnus-button-handle-news (url)
7407 (destructuring-bind (scheme server port group message-id articles)
7408 (gnus-parse-news-url url)
7412 (set-buffer gnus-summary-buffer)
7414 (let ((gnus-refer-article-method
7415 (nconc (list (list 'nntp server))
7416 gnus-refer-article-method))
7417 (nntp-port-number (or port "nntp")))
7418 (gnus-message 7 "Fetching %s with %s"
7419 message-id gnus-refer-article-method)
7420 (gnus-summary-refer-article message-id))
7421 (gnus-summary-refer-article message-id))))
7423 (gnus-button-fetch-group url)))))
7425 (defun gnus-button-handle-man (url)
7427 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7428 (when (eq gnus-button-man-handler 'woman)
7429 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
7430 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7431 (funcall gnus-button-man-handler url))
7433 (defun gnus-button-handle-info-url (url)
7434 "Fetch an info URL."
7435 (setq url (mm-subst-char-in-string ?+ ?\ url))
7437 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
7438 (gnus-info-find-node
7439 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
7441 ")" (gnus-url-unhex-string (match-string 2 url)))))
7442 ((string-match "([^)\"]+)[^\"]+" url)
7444 (gnus-replace-in-string
7445 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
7446 (gnus-info-find-node url))
7447 (t (error "Can't parse %s" url))))
7449 (defun gnus-button-handle-info-url-gnome (url)
7450 "Fetch GNOME style info URL."
7451 (setq url (mm-subst-char-in-string ?_ ?\ url))
7452 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
7453 (gnus-info-find-node
7455 (gnus-url-unhex-string
7456 (match-string 1 url))
7458 (or (gnus-url-unhex-string
7459 (match-string 2 url))
7461 (error "Can't parse %s" url)))
7463 (defun gnus-button-handle-info-url-kde (url)
7464 "Fetch KDE style info URL."
7465 (gnus-info-find-node (gnus-url-unhex-string url)))
7467 (defun gnus-button-handle-info-keystrokes (url)
7468 "Call `info' when pushing the corresponding URL button."
7469 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
7474 (defun gnus-button-openpgp (url)
7475 "Retrieve and add an OpenPGP key given URL from an OpenPGP header."
7477 (mm-url-insert-file-contents-external url)
7478 (pgg-snarf-keys-region (point-min) (point-max))
7479 (pgg-display-output-buffer nil nil nil)))
7481 (defun gnus-button-message-id (message-id)
7483 (with-current-buffer gnus-summary-buffer
7484 (gnus-summary-refer-article message-id)))
7486 (defun gnus-button-fetch-group (address)
7487 "Fetch GROUP specified by ADDRESS."
7488 (if (not (string-match "[:/]" address))
7489 ;; This is just a simple group url.
7490 (gnus-group-read-ephemeral-group address gnus-select-method)
7493 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
7495 (error "Can't parse %s" address)
7496 (gnus-group-read-ephemeral-group
7497 (match-string 4 address)
7498 `(nntp ,(match-string 1 address)
7499 (nntp-address ,(match-string 1 address))
7500 (nntp-port-number ,(if (match-end 3)
7501 (match-string 3 address)
7504 (and (match-end 6) (list (string-to-number (match-string 6 address))))))))
7506 (defun gnus-url-parse-query-string (query &optional downcase)
7507 (let (retval pairs cur key val)
7508 (setq pairs (split-string query "&"))
7510 (setq cur (car pairs)
7512 (if (not (string-match "=" cur))
7514 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
7515 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
7517 (setq key (downcase key)))
7518 (setq cur (assoc key retval))
7520 (setcdr cur (cons val (cdr cur)))
7521 (setq retval (cons (list key val) retval)))))
7524 (defun gnus-url-mailto (url)
7525 ;; Send mail to someone
7526 (when (string-match "mailto:/*\\(.*\\)" url)
7527 (setq url (substring url (match-beginning 1) nil)))
7528 (let (to args subject func)
7529 (setq args (gnus-url-parse-query-string
7530 (if (string-match "^\\?" url)
7532 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
7533 (concat "to=" (match-string 1 url) "&"
7534 (match-string 2 url))
7535 (concat "to=" url)))
7537 subject (cdr-safe (assoc "subject" args)))
7540 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
7543 (message-position-on-field (caar args)))
7544 (insert (gnus-replace-in-string
7545 (mapconcat 'identity (reverse (cdar args)) ", ")
7547 (setq args (cdr args)))
7550 (message-goto-subject))))
7552 (defun gnus-button-embedded-url (address)
7553 "Activate ADDRESS with `browse-url'."
7554 (browse-url (gnus-strip-whitespace address)))
7556 ;;; Next/prev buttons in the article buffer.
7558 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
7559 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
7561 (defvar gnus-prev-page-map
7562 (let ((map (make-sparse-keymap)))
7563 (define-key map gnus-mouse-2 'gnus-button-prev-page)
7564 (define-key map "\r" 'gnus-button-prev-page)
7567 (defvar gnus-next-page-map
7568 (let ((map (make-sparse-keymap)))
7569 (unless (>= emacs-major-version 21)
7570 ;; XEmacs doesn't care.
7571 (set-keymap-parent map gnus-article-mode-map))
7572 (define-key map gnus-mouse-2 'gnus-button-next-page)
7573 (define-key map "\r" 'gnus-button-next-page)
7576 (defun gnus-insert-prev-page-button ()
7578 (inhibit-read-only t)
7579 (situation (get-text-property (point-min) 'mime-view-situation)))
7581 gnus-prev-page-line-format nil
7582 `(keymap ,gnus-prev-page-map
7584 gnus-callback gnus-article-button-prev-page
7585 article-type annotation
7586 mime-view-situation ,situation))
7587 (widget-convert-button
7589 ;; Exclude a newline.
7592 :action 'gnus-button-prev-page
7593 :button-keymap gnus-prev-page-map)))
7595 (defun gnus-button-next-page (&optional args more-args)
7596 "Go to the next page."
7598 (let ((win (selected-window)))
7599 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7600 (gnus-article-next-page)
7601 (select-window win)))
7603 (defun gnus-button-prev-page (&optional args more-args)
7604 "Go to the prev page."
7606 (let ((win (selected-window)))
7607 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7608 (gnus-article-prev-page)
7609 (select-window win)))
7611 (defun gnus-insert-next-page-button ()
7613 (inhibit-read-only t)
7614 (situation (get-text-property (point-min) 'mime-view-situation)))
7615 (gnus-eval-format gnus-next-page-line-format nil
7616 `(keymap ,gnus-next-page-map
7618 gnus-callback gnus-article-button-next-page
7619 article-type annotation
7620 mime-view-situation ,situation))
7621 (widget-convert-button
7623 ;; Exclude a newline.
7626 :action 'gnus-button-next-page
7627 :button-keymap gnus-next-page-map)))
7629 (defun gnus-article-button-next-page (arg)
7630 "Go to the next page."
7632 (let ((win (selected-window)))
7633 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7634 (gnus-article-next-page)
7635 (select-window win)))
7637 (defun gnus-article-button-prev-page (arg)
7638 "Go to the prev page."
7640 (let ((win (selected-window)))
7641 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7642 (gnus-article-prev-page)
7643 (select-window win)))
7645 (defvar gnus-decode-header-methods
7646 '(mail-decode-encoded-word-region)
7647 "List of methods used to decode headers.
7649 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
7650 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
7651 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
7652 whose names match REGEXP.
7655 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
7656 mail-decode-encoded-word-region
7657 (\"chinese\" . rfc1843-decode-region))
7660 (defvar gnus-decode-header-methods-cache nil)
7662 (defun gnus-multi-decode-header (start end)
7663 "Apply the functions from `gnus-encoded-word-methods' that match."
7664 (unless (and gnus-decode-header-methods-cache
7665 (eq gnus-newsgroup-name
7666 (car gnus-decode-header-methods-cache)))
7667 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
7670 (nconc gnus-decode-header-methods-cache (list x))
7671 (if (and gnus-newsgroup-name
7672 (string-match (car x) gnus-newsgroup-name))
7673 (nconc gnus-decode-header-methods-cache
7675 gnus-decode-header-methods))
7676 (let ((xlist gnus-decode-header-methods-cache))
7679 (narrow-to-region start end)
7681 (funcall (pop xlist) (point-min) (point-max))))))
7684 ;;; Treatment top-level handling.
7687 (defun gnus-treat-article (condition &optional part-number total-parts type)
7688 (let ((length (- (point-max) (point-min)))
7689 (alist gnus-treatment-function-alist)
7690 (article-goto-body-goes-to-point-min-p t)
7694 (let ((list gnus-article-treat-types))
7696 (when (string-match (pop list) type)
7697 (throw 'found t)))))))
7698 (highlightp (gnus-visual-p 'article-highlight 'highlight))
7699 (entity (static-unless (featurep 'xemacs)
7700 (when (eq 'head condition)
7701 (get-text-property (point-min) 'mime-view-entity))))
7702 val elem buttonized)
7703 (gnus-run-hooks 'gnus-part-display-hook)
7704 (unless gnus-inhibit-treatment
7705 (dolist (elem alist)
7708 (when (gnus-buffer-live-p gnus-summary-buffer)
7709 (set-buffer gnus-summary-buffer))
7710 (symbol-value (car elem))))
7711 (when (and (or (consp val)
7713 (gnus-treat-predicate val)
7714 (or (not (get (car elem) 'highlight))
7716 (when (and (not buttonized)
7718 '(gnus-treat-hide-signature
7719 gnus-treat-highlight-signature)))
7720 (gnus-article-buttonize-signature)
7721 (setq buttonized t))
7723 (funcall (cadr elem)))))
7724 ;; FSF Emacsen does not inherit the existing text properties
7725 ;; in the new text, so we should do it for `mime-view-entity'.
7726 (static-unless (featurep 'xemacs)
7728 (put-text-property (point-min) (point-max)
7729 'mime-view-entity entity))))))
7731 ;; Dynamic variables.
7733 (defvar part-number)
7734 (defvar total-parts)
7739 (defun gnus-treat-predicate (val)
7744 (stringp (car val)))
7745 (apply 'gnus-or (mapcar `(lambda (s)
7746 (string-match s ,(or gnus-newsgroup-name "")))
7749 (let ((pred (pop val)))
7752 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
7754 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
7756 (not (gnus-treat-predicate (car val))))
7758 (equal (car val) type))
7760 (error "%S is not a valid predicate" pred)))))
7772 (eq part-number total-parts))
7776 (error "%S is not a valid value" val))))
7778 (defun gnus-article-encrypt-body (protocol &optional n)
7779 "Encrypt the article body."
7782 (or gnus-article-encrypt-protocol
7783 (completing-read "Encrypt protocol: "
7784 gnus-article-encrypt-protocol-alist
7786 current-prefix-arg))
7787 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7789 (error "Can't find the encrypt protocol %s" protocol))
7790 (if (member gnus-newsgroup-name '("nndraft:delayed"
7793 (error "Can't encrypt the article in group %s"
7794 gnus-newsgroup-name))
7795 (gnus-summary-iterate n
7797 (set-buffer gnus-summary-buffer)
7798 (let ((mail-parse-charset gnus-newsgroup-charset)
7799 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7800 (summary-buffer gnus-summary-buffer)
7802 (gnus-set-global-variables)
7803 (when (gnus-group-read-only-p)
7804 (error "The current newsgroup does not support article encrypt"))
7805 (gnus-summary-show-article t)
7807 (or (mail-header-references gnus-current-headers) ""))
7808 (set-buffer gnus-article-buffer)
7809 (let* ((inhibit-read-only t)
7811 (mapcar (lambda (field)
7812 (and (save-restriction
7813 (message-narrow-to-head)
7814 (goto-char (point-min))
7815 (search-forward field nil t))
7817 (message-narrow-to-field)
7819 (delete-region (point-min) (point-max))
7821 '("Content-Type:" "Content-Transfer-Encoding:"
7822 "Content-Disposition:"))))
7823 (message-narrow-to-head)
7824 (message-remove-header "MIME-Version")
7825 (goto-char (point-max))
7826 (setq point (point))
7827 (insert (apply 'concat headers))
7829 (narrow-to-region point (point-max))
7830 (let ((message-options message-options))
7831 (message-options-set 'message-sender user-mail-address)
7832 (message-options-set 'message-recipients user-mail-address)
7833 (message-options-set 'message-sign-encrypt 'not)
7835 (goto-char (point-min))
7836 (insert "MIME-Version: 1.0\n")
7838 (gnus-summary-edit-article-done
7839 references nil summary-buffer t))
7840 (when gnus-keep-backlog
7841 (gnus-backlog-remove-article
7842 (car gnus-article-current) (cdr gnus-article-current)))
7844 (when (get-buffer gnus-original-article-buffer)
7845 (set-buffer gnus-original-article-buffer)
7846 (setq gnus-original-article nil)))
7847 (when gnus-use-cache
7848 (gnus-cache-update-article
7849 (car gnus-article-current) (cdr gnus-article-current))))))))
7851 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7852 "The following specs can be used:
7853 %t The security MIME type
7856 %D Details if button is pressed")
7858 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
7859 "The following specs can be used:
7860 %t The security MIME type
7863 %D Details if button is pressed")
7865 (defvar gnus-mime-security-button-line-format-alist
7866 '((?t gnus-tmp-type ?s)
7867 (?i gnus-tmp-info ?s)
7868 (?d gnus-tmp-details ?s)
7869 (?D gnus-tmp-pressed-details ?s)))
7871 (defvar gnus-mime-security-button-map
7872 (let ((map (make-sparse-keymap)))
7873 (define-key map gnus-mouse-2 'gnus-article-push-button)
7874 (define-key map "\r" 'gnus-article-press-button)
7877 (defvar gnus-mime-security-details-buffer nil)
7879 (defvar gnus-mime-security-button-pressed nil)
7881 (defvar gnus-mime-security-show-details-inline t
7882 "If non-nil, show details in the article buffer.")
7884 (defun gnus-mime-security-verify-or-decrypt (handle)
7885 (mm-remove-parts (cdr handle))
7886 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7887 point (inhibit-read-only t))
7889 (goto-char (car region)))
7891 (narrow-to-region (point) (point))
7892 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7893 (let* ((mm-verify-option 'known)
7894 (mm-decrypt-option 'known)
7895 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7896 (unless (eq nparts (cdr handle))
7897 (mm-destroy-parts (cdr handle))
7898 (setcdr handle nparts))))
7899 (setq point (point))
7900 (gnus-mime-display-security handle)
7901 (goto-char (point-max)))
7903 (delete-region (point) (cdr region))
7904 (set-marker (car region) nil)
7905 (set-marker (cdr region) nil))
7908 (defun gnus-mime-security-show-details (handle)
7909 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7911 (gnus-message 5 "No details.")
7912 (if gnus-mime-security-show-details-inline
7913 (let ((gnus-mime-security-button-pressed
7914 (not (get-text-property (point) 'gnus-mime-details)))
7915 (gnus-mime-security-button-line-format
7916 (get-text-property (point) 'gnus-line-format))
7917 (inhibit-read-only t))
7919 (while (eq (get-text-property (point) 'gnus-line-format)
7920 gnus-mime-security-button-line-format)
7924 (narrow-to-region (point) (point))
7925 (gnus-insert-mime-security-button handle))
7926 (delete-region (point)
7927 (or (text-property-not-all
7930 gnus-mime-security-button-line-format)
7933 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7934 (with-current-buffer gnus-mime-security-details-buffer
7937 (setq gnus-mime-security-details-buffer
7938 (gnus-get-buffer-create "*MIME Security Details*")))
7939 (with-current-buffer gnus-mime-security-details-buffer
7941 (goto-char (point-min)))
7942 (pop-to-buffer gnus-mime-security-details-buffer)))))
7944 (defun gnus-mime-security-press-button (handle)
7946 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7947 (gnus-mime-security-show-details handle)
7948 (gnus-mime-security-verify-or-decrypt handle))))
7950 (defun gnus-insert-mime-security-button (handle &optional displayed)
7951 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7954 (or (nth 2 (assoc protocol mm-verify-function-alist))
7955 (nth 2 (assoc protocol mm-decrypt-function-alist))
7957 (if (equal (car handle) "multipart/signed")
7958 " Signed" " Encrypted")
7961 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7964 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7965 gnus-tmp-pressed-details
7967 (setq gnus-tmp-details
7968 (if gnus-tmp-details
7969 (concat "\n" gnus-tmp-details)
7971 (setq gnus-tmp-pressed-details
7972 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7977 gnus-mime-security-button-line-format
7978 gnus-mime-security-button-line-format-alist
7979 `(keymap ,gnus-mime-security-button-map
7980 gnus-callback gnus-mime-security-press-button
7981 gnus-line-format ,gnus-mime-security-button-line-format
7982 gnus-mime-details ,gnus-mime-security-button-pressed
7983 article-type annotation
7986 ;; Exclude a newline.
7989 (widget-convert-button
7992 :action 'gnus-widget-press-button
7993 :button-keymap gnus-mime-security-button-map
7995 (lambda (widget/window &optional overlay pos)
7996 ;; Needed to properly clear the message due to a bug in
7997 ;; wid-edit (XEmacs only).
7998 (when (boundp 'help-echo-owns-message)
7999 (setq help-echo-owns-message t))
8002 (aref gnus-mouse-2 0))))))
8004 (defun gnus-mime-display-security (handle)
8006 (narrow-to-region (point) (point))
8007 (unless (gnus-unbuttonized-mime-type-p (car handle))
8008 (gnus-insert-mime-security-button handle))
8009 (gnus-mime-display-part (cadr handle))
8012 (unless (gnus-unbuttonized-mime-type-p (car handle))
8013 (let ((gnus-mime-security-button-line-format
8014 gnus-mime-security-button-end-line-format))
8015 (gnus-insert-mime-security-button handle)))
8016 (mm-set-handle-multipart-parameter
8018 (cons (set-marker (make-marker) (point-min))
8019 (set-marker (make-marker) (point-max))))))
8025 (defun gnus-article-header-presentation-method (entity situation)
8026 (mime-insert-header entity)
8027 (article-decode-group-name))
8029 (set-alist 'mime-header-presentation-method-alist
8030 'gnus-original-article-mode
8031 #'gnus-article-header-presentation-method)
8033 (defun gnus-mime-preview-quitting-method ()
8034 (mime-preview-kill-buffer)
8035 (delete-other-windows)
8036 (gnus-article-show-summary)
8037 (gnus-summary-select-article gnus-show-all-headers t))
8039 (set-alist 'mime-preview-quitting-method-alist
8040 'gnus-original-article-mode #'gnus-mime-preview-quitting-method)
8042 (set-alist 'mime-preview-following-method-alist
8043 'gnus-original-article-mode #'gnus-following-method)
8045 (set-alist 'mime-preview-over-to-previous-method-alist
8046 'gnus-original-article-mode
8048 (if (> (point-min) 1)
8049 (gnus-article-prev-page)
8050 (gnus-article-read-summary-keys
8051 nil (gnus-character-to-event ?P)))))
8053 (set-alist 'mime-preview-over-to-next-method-alist
8054 'gnus-original-article-mode'
8056 (if (< (point-max) (buffer-size))
8057 (gnus-article-next-page)
8058 (gnus-article-read-summary-keys
8059 nil (gnus-character-to-event ?N)))))
8069 (run-hooks 'gnus-art-load-hook)
8071 ;;; gnus-art.el ends here