1 ;;; gnus-art.el --- article mode commands for Semi-gnus
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005, 2006 Free Software Foundation, Inc.
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
7 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
8 ;; Katsumi Yamaoka <yamaoka@jpl.org>
9 ;; Keywords: mail, news, MIME
11 ;; This file is part of GNU Emacs.
13 ;; GNU Emacs is free software; you can redistribute it and/or modify
14 ;; it under the terms of the GNU General Public License as published by
15 ;; the Free Software Foundation; either version 2, or (at your option)
18 ;; GNU Emacs is distributed in the hope that it will be useful,
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;; GNU General Public License for more details.
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the
25 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
26 ;; Boston, MA 02110-1301, USA.
36 (defvar w3m-minor-mode-map))
40 ;; Avoid the "Recursive load suspected" error in Emacs 21.1.
42 (let ((recursive-load-depth-limit 100))
49 (when (static-if (featurep 'xemacs)
50 (console-on-window-system-p)
52 (require 'mime-image))
55 ;; Avoid byte-compile warnings.
65 (autoload 'gnus-msg-mail "gnus-msg" nil t)
66 (autoload 'gnus-button-mailto "gnus-msg")
67 (autoload 'gnus-button-reply "gnus-msg" nil t)
68 (autoload 'parse-time-string "parse-time" nil nil)
69 (autoload 'ansi-color-apply-on-region "ansi-color")
70 (autoload 'mm-url-insert-file-contents-external "mm-url")
71 (autoload 'mm-extern-cache-contents "mm-extern")
73 (defgroup gnus-article nil
75 :link '(custom-manual "(gnus)Article Buffer")
78 (defgroup gnus-article-treat nil
79 "Treating article parts."
80 :link '(custom-manual "(gnus)Article Hiding")
83 (defgroup gnus-article-hiding nil
84 "Hiding article parts."
85 :link '(custom-manual "(gnus)Article Hiding")
88 (defgroup gnus-article-highlight nil
89 "Article highlighting."
90 :link '(custom-manual "(gnus)Article Highlighting")
94 (defgroup gnus-article-signature nil
96 :link '(custom-manual "(gnus)Article Signature")
99 (defgroup gnus-article-headers nil
101 :link '(custom-manual "(gnus)Hiding Headers")
102 :group 'gnus-article)
104 (defgroup gnus-article-washing nil
105 "Special commands on articles."
106 :link '(custom-manual "(gnus)Article Washing")
107 :group 'gnus-article)
109 (defgroup gnus-article-emphasis nil
110 "Fontisizing articles."
111 :link '(custom-manual "(gnus)Article Fontisizing")
112 :group 'gnus-article)
114 (defgroup gnus-article-saving nil
116 :link '(custom-manual "(gnus)Saving Articles")
117 :group 'gnus-article)
119 (defgroup gnus-article-mime nil
120 "Worshiping the MIME wonder."
121 :link '(custom-manual "(gnus)Using MIME")
122 :group 'gnus-article)
124 (defgroup gnus-article-buttons nil
125 "Pushable buttons in the article buffer."
126 :link '(custom-manual "(gnus)Article Buttons")
127 :group 'gnus-article)
129 (defgroup gnus-article-various nil
130 "Other article options."
131 :link '(custom-manual "(gnus)Misc Article")
132 :group 'gnus-article)
134 (defcustom gnus-ignored-headers
137 (concat "^" header ":"))
138 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
139 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
140 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
141 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
142 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
143 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
144 "X-Attribution" "X-Originating-IP" "Delivered-To"
145 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
146 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
147 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
148 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
149 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
150 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
151 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
152 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
153 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
154 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
155 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
156 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
157 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
158 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
159 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
160 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
161 "List-[A-Za-z]+" "X-Listprocessor-Version"
162 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
163 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
164 "X-Received" "Content-length" "X-precedence"
165 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
166 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
167 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
168 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
169 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
170 "X-Content-length" "X-Posting-Agent" "Original-Received"
171 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
172 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
173 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
174 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
175 "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer"))
176 "*All headers that start with this regexp will be hidden.
177 This variable can also be a list of regexps of headers to be ignored.
178 If `gnus-visible-headers' is non-nil, this variable will be ignored."
179 :type '(choice :custom-show nil
182 :group 'gnus-article-hiding)
184 (defcustom gnus-visible-headers
185 "^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:"
186 "*All headers that do not match this regexp will be hidden.
187 This variable can also be a list of regexp of headers to remain visible.
188 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
189 :type '(repeat :value-to-internal (lambda (widget value)
190 (custom-split-regexp-maybe value))
191 :match (lambda (widget value)
193 (widget-editable-list-match widget value)))
195 :group 'gnus-article-hiding)
197 (defcustom gnus-sorted-header-list
198 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
199 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
200 "*This variable is a list of regular expressions.
201 If it is non-nil, headers that match the regular expressions will
202 be placed first in the article buffer in the sequence specified by
204 :type '(repeat regexp)
205 :group 'gnus-article-hiding)
207 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
208 "Headers that are only to be displayed if they have interesting data.
209 Possible values in this list are:
211 'empty Headers with no content.
212 'newsgroups Newsgroup identical to Gnus group.
213 'to-address To identical to To-address.
214 'to-list To identical to To-list.
215 'cc-list CC identical to To-list.
216 'followup-to Followup-to identical to Newsgroups.
217 'reply-to Reply-to identical to From.
218 'date Date less than four days old.
219 'long-to To and/or Cc longer than 1024 characters.
220 'many-to Multiple To and/or Cc."
221 :type '(set (const :tag "Headers with no content." empty)
222 (const :tag "Newsgroups identical to Gnus group." newsgroups)
223 (const :tag "To identical to To-address." to-address)
224 (const :tag "To identical to To-list." to-list)
225 (const :tag "CC identical to To-list." cc-list)
226 (const :tag "Followup-to identical to Newsgroups." followup-to)
227 (const :tag "Reply-to identical to From." reply-to)
228 (const :tag "Date less than four days old." date)
229 (const :tag "To and/or Cc longer than 1024 characters." long-to)
230 (const :tag "Multiple To and/or Cc headers." many-to))
231 :group 'gnus-article-hiding)
233 (defcustom gnus-article-skip-boring nil
234 "Skip over text that is not worth reading.
235 By default, if you set this t, then Gnus will display citations and
236 signatures, but will never scroll down to show you a page consisting
237 only of boring text. Boring text is controlled by
238 `gnus-article-boring-faces'."
241 :group 'gnus-article-hiding)
243 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
244 "Regexp matching signature separator.
245 This can also be a list of regexps. In that case, it will be checked
246 from head to tail looking for a separator. Searches will be done from
247 the end of the buffer."
248 :type '(choice :format "%{%t%}: %[Value Menu%]\n%v"
250 (repeat :tag "List of regexp" regexp))
251 :group 'gnus-article-signature)
253 (defcustom gnus-signature-limit nil
254 "Provide a limit to what is considered a signature.
255 If it is a number, no signature may not be longer (in characters) than
256 that number. If it is a floating point number, no signature may be
257 longer (in lines) than that number. If it is a function, the function
258 will be called without any parameters, and if it returns nil, there is
259 no signature in the buffer. If it is a string, it will be used as a
260 regexp. If it matches, the text in question is not a signature.
262 This can also be a list of the above values."
263 :type '(choice (const nil)
266 (function :value fun)
267 (regexp :value ".*"))
268 :group 'gnus-article-signature)
270 (defcustom gnus-hidden-properties '(invisible t intangible t)
271 "Property list to use for hiding text."
273 :group 'gnus-article-hiding)
275 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
276 ;; frames in a session.
277 (defcustom gnus-article-x-face-command
282 (if (or (gnus-image-type-available-p 'xface)
283 (gnus-image-type-available-p 'pbm))
284 'gnus-display-x-face-in-from
285 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -"))
286 ((gnus-image-type-available-p 'pbm)
287 'gnus-display-x-face-in-from)
289 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
291 "*String or function to be executed to display an X-Face header.
292 If it is a string, the command will be executed in a sub-shell
293 asynchronously. The compressed face will be piped to this command."
295 :format "%{%t%}:\n%[Value Menu%] %v"
299 (if (or (gnus-image-type-available-p 'xface)
300 (gnus-image-type-available-p 'pbm))
301 '(function-item gnus-display-x-face-in-from))
305 :group 'gnus-article-washing)
307 (defcustom gnus-article-x-face-too-ugly nil
308 "Regexp matching posters whose face shouldn't be shown automatically."
309 :type '(choice regexp (const nil))
310 :group 'gnus-article-washing)
312 (defcustom gnus-article-banner-alist nil
313 "Banner alist for stripping.
315 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
317 :type '(repeat (cons symbol regexp))
318 :group 'gnus-article-washing)
320 (gnus-define-group-parameter
323 "Alist of regexps (to match group names) and banner."
324 :variable-group gnus-article-washing
326 '(choice :tag "Banner"
328 (const :tag "Remove signature" signature)
329 (symbol :tag "Item in `gnus-article-banner-alist'" none)
331 (const :tag "None" nil))
333 "If non-nil, specify how to remove `banners' from articles.
335 Symbol `signature' means to remove signatures delimited by
336 `gnus-signature-separator'. Any other symbol is used to look up a
337 regular expression to match the banner in `gnus-article-banner-alist'.
338 A string is used as a regular expression to match the banner
341 (defcustom gnus-article-address-banner-alist nil
342 "Alist of mail addresses and banners.
343 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
344 to match a mail address in the From: header, BANNER is one of a symbol
345 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
346 If ADDRESS matches author's mail address, it will remove things like
347 advertisements. For example:
349 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
353 (regexp :tag "Address")
354 (choice :tag "Banner" :value nil
355 (const :tag "Remove signature" signature)
356 (symbol :tag "Item in `gnus-article-banner-alist'" none)
358 (const :tag "None" nil))))
360 :group 'gnus-article-washing)
362 (defmacro gnus-emphasis-custom-with-format (&rest body)
364 \\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\
365 \\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)"))
368 (defun gnus-emphasis-custom-value-to-external (value)
369 (gnus-emphasis-custom-with-format
370 (if (consp (car value))
371 (list (format format (car (car value)) (cdr (car value)))
373 (if (nth 1 value) 2 3)
377 (defun gnus-emphasis-custom-value-to-internal (value)
378 (gnus-emphasis-custom-with-format
379 (let ((regexp (concat "\\`"
380 (format (regexp-quote format)
381 "\\([^()]+\\)" "\\([^()]+\\)")
384 (if (string-match regexp (setq pattern (car value)))
385 (list (cons (match-string 1 pattern) (match-string 2 pattern))
390 (defcustom gnus-emphasis-alist
392 '(("\\*" "\\*" bold nil 2)
395 ("_/" "/_" underline-italic)
396 ("_\\*" "\\*_" underline-bold)
397 ("\\*/" "/\\*" bold-italic)
398 ("_\\*/" "/\\*_" underline-bold-italic))))
400 (gnus-emphasis-custom-with-format
401 (mapcar (lambda (spec)
402 (list (format format (car spec) (cadr spec))
405 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
407 '(;; I've never seen anyone use this strikethru convention whereas I've
408 ;; several times seen it triggered by normal text. --Stef
409 ;; Miles suggests that this form is sometimes used but for italics,
410 ;; so maybe we should map it to `italic'.
411 ;; ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
412 ;; 2 3 gnus-emphasis-strikethru)
413 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
414 2 3 gnus-emphasis-underline))))
415 "*Alist that says how to fontify certain phrases.
416 Each item looks like this:
418 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
420 The first element is a regular expression to be matched. The second
421 is a number that says what regular expression grouping used to find
422 the entire emphasized word. The third is a number that says what
423 regexp grouping should be displayed and highlighted. The fourth
424 is the face used for highlighting."
428 :format "%[Customizing Style%]\n%v"
430 (group :tag "Default"
431 :value ("" 0 0 default)
434 (let ((value (widget-get
435 (cadr (widget-get (widget-get widget :parent)
438 (if (not (eq (nth 2 value) 'default))
442 (gnus-emphasis-custom-value-to-external value))))
443 (widget-group-value-create widget))
445 (integer :format "Match group: %v")
446 (integer :format "Emphasize group: %v")
449 :value (("_" . "_") nil default)
451 (regexp :format "Start regexp: %v")
452 (regexp :format "End regexp: %v"))
453 (boolean :format "Show start and end patterns: %[%v%]\n"
454 :on " On " :off " Off ")
456 :get (lambda (symbol)
457 (mapcar 'gnus-emphasis-custom-value-to-internal
458 (default-value symbol)))
459 :set (lambda (symbol value)
460 (set-default symbol (mapcar 'gnus-emphasis-custom-value-to-external
462 :group 'gnus-article-emphasis)
464 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
465 "A regexp to describe whitespace which should not be emphasized.
466 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
467 The former avoids underlining of leading and trailing whitespace,
468 and the latter avoids underlining any whitespace at all."
470 :group 'gnus-article-emphasis
473 (defface gnus-emphasis-bold '((t (:bold t)))
474 "Face used for displaying strong emphasized text (*word*)."
475 :group 'gnus-article-emphasis)
477 (defface gnus-emphasis-italic '((t (:italic t)))
478 "Face used for displaying italic emphasized text (/word/)."
479 :group 'gnus-article-emphasis)
481 (defface gnus-emphasis-underline '((t (:underline t)))
482 "Face used for displaying underlined emphasized text (_word_)."
483 :group 'gnus-article-emphasis)
485 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
486 "Face used for displaying underlined bold emphasized text (_*word*_)."
487 :group 'gnus-article-emphasis)
489 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
490 "Face used for displaying underlined italic emphasized text (_/word/_)."
491 :group 'gnus-article-emphasis)
493 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
494 "Face used for displaying bold italic emphasized text (/*word*/)."
495 :group 'gnus-article-emphasis)
497 (defface gnus-emphasis-underline-bold-italic
498 '((t (:bold t :italic t :underline t)))
499 "Face used for displaying underlined bold italic emphasized text.
500 Example: (_/*word*/_)."
501 :group 'gnus-article-emphasis)
503 (defface gnus-emphasis-strikethru (if (featurep 'xemacs)
504 '((t (:strikethru t)))
505 '((t (:strike-through t))))
506 "Face used for displaying strike-through text (-word-)."
507 :group 'gnus-article-emphasis)
509 (defface gnus-emphasis-highlight-words
510 '((t (:background "black" :foreground "yellow")))
511 "Face used for displaying highlighted words."
512 :group 'gnus-article-emphasis)
514 (defcustom gnus-article-time-format "%a, %d %b %Y %T %Z"
515 "Format for display of Date headers in article bodies.
516 See `format-time-string' for the possible values.
518 The variable can also be function, which should return a complete Date
519 header. The function is called with one argument, the time, which can
520 be fed to `format-time-string'."
521 :type '(choice string function)
522 :link '(custom-manual "(gnus)Article Date")
523 :group 'gnus-article-washing)
525 (defcustom gnus-save-all-headers t
526 "*If non-nil, don't remove any headers before saving."
527 :group 'gnus-article-saving
530 (defcustom gnus-prompt-before-saving 'always
531 "*This variable says how much prompting is to be done when saving articles.
532 If it is nil, no prompting will be done, and the articles will be
533 saved to the default files. If this variable is `always', each and
534 every article that is saved will be preceded by a prompt, even when
535 saving large batches of articles. If this variable is neither nil not
536 `always', there the user will be prompted once for a file name for
537 each invocation of the saving commands."
538 :group 'gnus-article-saving
539 :type '(choice (item always)
540 (item :tag "never" nil)
541 (sexp :tag "once" :format "%t\n" :value t)))
543 (defcustom gnus-saved-headers gnus-visible-headers
544 "Headers to keep if `gnus-save-all-headers' is nil.
545 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
546 If that variable is nil, however, all headers that match this regexp
547 will be kept while the rest will be deleted before saving."
548 :group 'gnus-article-saving
551 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
552 "A function to save articles in your favourite format.
553 The function must be interactively callable (in other words, it must
554 be an Emacs command).
556 Gnus provides the following functions:
558 * gnus-summary-save-in-rmail (Rmail format)
559 * gnus-summary-save-in-mail (Unix mail format)
560 * gnus-summary-save-in-folder (MH folder)
561 * gnus-summary-save-in-file (article format)
562 * gnus-summary-save-body-in-file (article body)
563 * gnus-summary-save-in-vm (use VM's folder format)
564 * gnus-summary-write-to-file (article format -- overwrite)."
565 :group 'gnus-article-saving
566 :type '(radio (function-item gnus-summary-save-in-rmail)
567 (function-item gnus-summary-save-in-mail)
568 (function-item gnus-summary-save-in-folder)
569 (function-item gnus-summary-save-in-file)
570 (function-item gnus-summary-save-body-in-file)
571 (function-item gnus-summary-save-in-vm)
572 (function-item gnus-summary-write-to-file)
575 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
576 "A function generating a file name to save articles in Rmail format.
577 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
578 :group 'gnus-article-saving
581 (defcustom gnus-mail-save-name 'gnus-plain-save-name
582 "A function generating a file name to save articles in Unix mail format.
583 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
584 :group 'gnus-article-saving
587 (defcustom gnus-folder-save-name 'gnus-folder-save-name
588 "A function generating a file name to save articles in MH folder.
589 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
590 :group 'gnus-article-saving
593 (defcustom gnus-file-save-name 'gnus-numeric-save-name
594 "A function generating a file name to save articles in article format.
595 The function is called with NEWSGROUP, HEADERS, and optional
597 :group 'gnus-article-saving
600 (defcustom gnus-split-methods
601 '((gnus-article-archive-name)
602 (gnus-article-nndoc-name))
603 "*Variable used to suggest where articles are to be saved.
604 For instance, if you would like to save articles related to Gnus in
605 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
606 you could set this variable to something like:
608 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
609 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
611 This variable is an alist where the key is the match and the
612 value is a list of possible files to save in if the match is
615 If the match is a string, it is used as a regexp match on the
616 article. If the match is a symbol, that symbol will be funcalled
617 from the buffer of the article to be saved with the newsgroup as
618 the parameter. If it is a list, it will be evaled in the same
621 If this form or function returns a string, this string will be
622 used as a possible file name; and if it returns a non-nil list,
623 that list will be used as possible file names."
624 :group 'gnus-article-saving
625 :type '(repeat (choice (list :value (fun) function)
626 (cons :value ("" "") regexp (repeat string))
629 (defcustom gnus-article-display-method-for-mime
630 'gnus-article-display-mime-message
631 "Function to display a MIME message.
632 The function is called from the article buffer."
633 :group 'gnus-article-mime
636 (defcustom gnus-article-display-method-for-traditional
637 'gnus-article-display-traditional-message
638 "*Function to display a traditional message.
639 The function is called from the article buffer."
640 :group 'gnus-article-mime
643 (defcustom gnus-page-delimiter "^\^L"
644 "*Regexp describing what to use as article page delimiters.
645 The default value is \"^\^L\", which is a form linefeed at the
646 beginning of a line."
648 :group 'gnus-article-various)
650 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
651 "*The format specification for the article mode line.
652 See `gnus-summary-mode-line-format' for a closer description.
654 The following additional specs are available:
656 %w The article washing status.
657 %m The number of MIME parts in the article."
659 :group 'gnus-article-various)
661 (defcustom gnus-article-mode-hook nil
662 "*A hook for Gnus article mode."
664 :group 'gnus-article-various)
666 (when (featurep 'xemacs)
667 ;; Extracted from gnus-xmas-define in order to preserve user settings
668 (when (fboundp 'turn-off-scroll-in-place)
669 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
670 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
671 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
673 (defcustom gnus-article-menu-hook nil
674 "*Hook run after the creation of the article mode menu."
676 :group 'gnus-article-various)
678 (defcustom gnus-article-prepare-hook nil
679 "*A hook called after an article has been prepared in the article buffer."
681 :group 'gnus-article-various)
683 (defcustom gnus-copy-article-ignored-headers nil
684 "List of headers to be removed when copying an article.
685 Each element is a regular expression."
686 :version "23.0" ;; No Gnus
687 :type '(repeat regexp)
688 :group 'gnus-article-various)
690 (make-obsolete-variable 'gnus-article-hide-pgp-hook
691 "This variable is obsolete in Gnus 5.10.")
694 '((t (:weight bold)))
695 "Face used for highlighting a button in the article buffer."
696 :group 'gnus-article-buttons)
698 (defcustom gnus-article-button-face 'gnus-button
699 "Face used for highlighting buttons in the article buffer.
701 An article button is a piece of text that you can activate by pressing
702 `RET' or `mouse-2' above it."
704 :group 'gnus-article-buttons)
706 (defcustom gnus-article-mouse-face 'highlight
707 "Face used for mouse highlighting in the article buffer.
709 Article buttons will be displayed in this face when the cursor is
712 :group 'gnus-article-buttons)
714 (defcustom gnus-signature-face 'gnus-signature
715 "Face used for highlighting a signature in the article buffer.
716 Obsolete; use the face `gnus-signature' for customizations instead."
718 :group 'gnus-article-highlight
719 :group 'gnus-article-signature)
721 (defface gnus-signature
724 "Face used for highlighting a signature in the article buffer."
725 :group 'gnus-article-highlight
726 :group 'gnus-article-signature)
727 ;; backward-compatibility alias
728 (put 'gnus-signature-face 'face-alias 'gnus-signature)
730 (defface gnus-header-from
733 (:foreground "spring green"))
736 (:foreground "red3"))
739 "Face used for displaying from headers."
740 :group 'gnus-article-headers
741 :group 'gnus-article-highlight)
742 ;; backward-compatibility alias
743 (put 'gnus-header-from-face 'face-alias 'gnus-header-from)
745 (defface gnus-header-subject
748 (:foreground "SeaGreen3"))
751 (:foreground "red4"))
753 (:bold t :italic t)))
754 "Face used for displaying subject headers."
755 :group 'gnus-article-headers
756 :group 'gnus-article-highlight)
757 ;; backward-compatibility alias
758 (put 'gnus-header-subject-face 'face-alias 'gnus-header-subject)
760 (defface gnus-header-newsgroups
763 (:foreground "yellow" :italic t))
766 (:foreground "MidnightBlue" :italic t))
769 "Face used for displaying newsgroups headers.
770 In the default setup this face is only used for crossposted
772 :group 'gnus-article-headers
773 :group 'gnus-article-highlight)
774 ;; backward-compatibility alias
775 (put 'gnus-header-newsgroups-face 'face-alias 'gnus-header-newsgroups)
777 (defface gnus-header-name
780 (:foreground "SeaGreen"))
783 (:foreground "maroon"))
786 "Face used for displaying header names."
787 :group 'gnus-article-headers
788 :group 'gnus-article-highlight)
789 ;; backward-compatibility alias
790 (put 'gnus-header-name-face 'face-alias 'gnus-header-name)
792 (defface gnus-header-content
795 (:foreground "forest green" :italic t))
798 (:foreground "indianred4" :italic t))
801 "Face used for displaying header content."
802 :group 'gnus-article-headers
803 :group 'gnus-article-highlight)
804 ;; backward-compatibility alias
805 (put 'gnus-header-content-face 'face-alias 'gnus-header-content)
807 (defcustom gnus-header-face-alist
808 '(("From" nil gnus-header-from)
809 ("Subject" nil gnus-header-subject)
810 ("Newsgroups:.*," nil gnus-header-newsgroups)
811 ("" gnus-header-name gnus-header-content))
812 "*Controls highlighting of article headers.
814 An alist of the form (HEADER NAME CONTENT).
816 HEADER is a regular expression which should match the name of a
817 header and NAME and CONTENT are either face names or nil.
819 The name of each header field will be displayed using the face
820 specified by the first element in the list where HEADER matches
821 the header name and NAME is non-nil. Similarly, the content will
822 be displayed by the first non-nil matching CONTENT face."
823 :group 'gnus-article-headers
824 :group 'gnus-article-highlight
825 :type '(repeat (list (regexp :tag "Header")
827 (item :tag "skip" nil)
828 (face :value default))
829 (choice :tag "Content"
830 (item :tag "skip" nil)
831 (face :value default)))))
833 (defcustom gnus-article-decode-hook
834 '(article-decode-group-name article-decode-idna-rhs)
835 "*Hook run to decode charsets in articles."
836 :group 'gnus-article-headers
839 (defcustom gnus-display-mime-function 'gnus-display-mime
840 "Function to display MIME articles."
841 :group 'gnus-article-mime
844 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
845 "Function used to decode headers.")
847 (defvar gnus-article-dumbquotes-map
867 "Table for MS-to-Latin1 translation.")
869 (defcustom gnus-ignored-mime-types nil
870 "List of MIME types that should be ignored by Gnus."
872 :group 'gnus-article-mime
873 :type '(repeat regexp))
875 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
876 "List of MIME types that should not be given buttons when rendered inline.
877 See also `gnus-buttonized-mime-types' which may override this variable.
878 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
880 :group 'gnus-article-mime
881 :type '(repeat regexp))
883 (defcustom gnus-buttonized-mime-types nil
884 "List of MIME types that should be given buttons when rendered inline.
885 If set, this variable overrides `gnus-unbuttonized-mime-types'.
886 To see e.g. security buttons you could set this to
887 `(\"multipart/signed\")'. You could also add \"multipart/alternative\" to
888 this list to display radio buttons that allow you to choose one of two
889 media types those mails include. See also `mm-discouraged-alternatives'.
890 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
892 :group 'gnus-article-mime
893 :type '(repeat regexp))
895 (defcustom gnus-inhibit-mime-unbuttonizing nil
896 "If non-nil, all MIME parts get buttons.
897 When nil (the default value), then some MIME parts do not get buttons,
898 as described by the variables `gnus-buttonized-mime-types' and
899 `gnus-unbuttonized-mime-types'."
901 :group 'gnus-article-mime
904 (defcustom gnus-body-boundary-delimiter "_"
905 "String used to delimit header and body.
906 This variable is used by `gnus-article-treat-body-boundary' which can
907 be controlled by `gnus-treat-body-boundary'."
909 :group 'gnus-article-various
910 :type '(choice (item :tag "None" :value nil)
913 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces"
915 "Defines the location of the faces database.
916 For information on obtaining this database of pretty pictures, please
917 see http://www.cs.indiana.edu/picons/ftp/index.html"
919 :type '(repeat directory)
920 :link '(url-link :tag "download"
921 "http://www.cs.indiana.edu/picons/ftp/index.html")
922 :link '(custom-manual "(gnus)Picons")
925 (defun gnus-picons-installed-p ()
926 "Say whether picons are installed on your machine."
927 (let ((installed nil))
928 (dolist (database gnus-picon-databases)
929 (when (file-exists-p database)
933 (defcustom gnus-article-mime-part-function nil
934 "Function called with a MIME handle as the argument.
935 This is meant for people who want to do something automatic based
936 on parts -- for instance, adding Vcard info to a database."
937 :group 'gnus-article-mime
938 :type '(choice (const nil)
941 (defcustom gnus-mime-multipart-functions nil
942 "An alist of MIME types to functions to display them."
944 :group 'gnus-article-mime
945 :type '(repeat (cons :format "%v" (string :tag "MIME type") function)))
947 (defcustom gnus-article-date-lapsed-new-header nil
948 "Whether the X-Sent and Date headers can coexist.
949 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
950 either replace the old \"Date:\" header (if this variable is nil), or
951 be added below it (otherwise)."
953 :group 'gnus-article-headers
956 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
957 "Function called with a MIME handle as the argument.
958 This is meant for people who want to view first matched part.
959 For `undisplayed-alternative' (default), the first undisplayed
960 part or alternative part is used. For `undisplayed', the first
961 undisplayed part is used. For a function, the first part which
962 the function return t is used. For nil, the first part is
965 :group 'gnus-article-mime
967 (item :tag "first" :value nil)
968 (item :tag "undisplayed" :value undisplayed)
969 (item :tag "undisplayed or alternative"
970 :value undisplayed-alternative)
973 (defcustom gnus-mime-action-alist
974 '(("save to file" . gnus-mime-save-part)
975 ("save and strip" . gnus-mime-save-part-and-strip)
976 ("replace with file" . gnus-mime-replace-part)
977 ("delete part" . gnus-mime-delete-part)
978 ("display as text" . gnus-mime-inline-part)
979 ("view the part" . gnus-mime-view-part)
980 ("pipe to command" . gnus-mime-pipe-part)
981 ("toggle display" . gnus-article-press-button)
982 ("toggle display" . gnus-article-view-part-as-charset)
983 ("view as type" . gnus-mime-view-part-as-type)
984 ("view internally" . gnus-mime-view-part-internally)
985 ("view externally" . gnus-mime-view-part-externally))
986 "An alist of actions that run on the MIME attachment."
987 :group 'gnus-article-mime
988 :type '(repeat (cons (string :tag "name")
991 (defcustom gnus-auto-select-part 1
992 "Advance to next MIME part when deleting or stripping parts.
994 When 0, point will be placed on the same part as before. When
995 positive (negative), move point forward (backwards) this many
996 parts. When nil, redisplay article."
997 :version "23.0" ;; No Gnus
998 :group 'gnus-article-mime
999 :type '(choice (const nil :tag "Redisplay article.")
1000 (const 1 :tag "Next part.")
1001 (const 0 :tag "Current part.")
1005 ;;; The treatment variables
1008 (defvar gnus-part-display-hook nil
1009 "Hook called on parts that are to receive treatment.")
1011 (defvar gnus-article-treat-custom
1012 '(choice (const :tag "Off" nil)
1014 (const :tag "Header" head)
1015 (const :tag "First" first)
1016 (const :tag "Last" last)
1017 (const :tag "Mime" mime)
1018 (integer :tag "Less")
1019 (repeat :tag "Groups" regexp)
1020 (sexp :tag "Predicate")))
1022 (defvar gnus-article-treat-head-custom
1023 '(choice (const :tag "Off" nil)
1024 (const :tag "Header" head)))
1026 (defvar gnus-article-treat-types '("text/plain")
1029 (defvar gnus-inhibit-treatment nil
1030 "Whether to inhibit treatment.")
1032 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
1033 "Highlight the signature.
1034 Valid values are nil, t, `head', `first', `last', an integer or a
1035 predicate. See Info node `(gnus)Customizing Articles'."
1036 :group 'gnus-article-treat
1037 :link '(custom-manual "(gnus)Customizing Articles")
1038 :type gnus-article-treat-custom)
1039 (put 'gnus-treat-highlight-signature 'highlight t)
1041 (defcustom gnus-treat-buttonize 100000
1043 Valid values are nil, t, `head', `first', `last', an integer or a
1044 predicate. See Info node `(gnus)Customizing Articles'."
1045 :group 'gnus-article-treat
1046 :link '(custom-manual "(gnus)Customizing Articles")
1047 :type gnus-article-treat-custom)
1048 (put 'gnus-treat-buttonize 'highlight t)
1050 (defcustom gnus-treat-buttonize-head 'head
1051 "Add buttons to the head.
1052 Valid values are nil, t, `head', `first', `last', an integer or a
1053 predicate. See Info node `(gnus)Customizing Articles'."
1054 :group 'gnus-article-treat
1055 :link '(custom-manual "(gnus)Customizing Articles")
1056 :type gnus-article-treat-head-custom)
1057 (put 'gnus-treat-buttonize-head 'highlight t)
1059 (defcustom gnus-treat-emphasize
1060 (and (or window-system
1064 Valid values are nil, t, `head', `first', `last', an integer or a
1065 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)
1069 (put 'gnus-treat-emphasize 'highlight t)
1071 (defcustom gnus-treat-strip-cr nil
1072 "Remove carriage returns.
1073 Valid values are nil, t, `head', `first', `last', an integer or a
1074 predicate. See Info node `(gnus)Customizing Articles'."
1076 :group 'gnus-article-treat
1077 :link '(custom-manual "(gnus)Customizing Articles")
1078 :type gnus-article-treat-custom)
1080 (defcustom gnus-treat-unsplit-urls nil
1081 "Remove newlines from within URLs.
1082 Valid values are nil, t, `head', `first', `last', an integer or a
1083 predicate. See Info node `(gnus)Customizing Articles'."
1085 :group 'gnus-article-treat
1086 :link '(custom-manual "(gnus)Customizing Articles")
1087 :type gnus-article-treat-custom)
1089 (defcustom gnus-treat-leading-whitespace nil
1090 "Remove leading whitespace in headers.
1091 Valid values are nil, t, `head', `first', `last', an integer or a
1092 predicate. See Info node `(gnus)Customizing Articles'."
1094 :group 'gnus-article-treat
1095 :link '(custom-manual "(gnus)Customizing Articles")
1096 :type gnus-article-treat-custom)
1098 (defcustom gnus-treat-hide-headers 'head
1100 Valid values are nil, t, `head', `first', `last', an integer or a
1101 predicate. See Info node `(gnus)Customizing Articles'."
1102 :group 'gnus-article-treat
1103 :link '(custom-manual "(gnus)Customizing Articles")
1104 :type gnus-article-treat-head-custom)
1106 (defcustom gnus-treat-hide-boring-headers nil
1107 "Hide boring headers.
1108 Valid values are nil, t, `head', `first', `last', an integer or a
1109 predicate. See Info node `(gnus)Customizing Articles'."
1110 :group 'gnus-article-treat
1111 :link '(custom-manual "(gnus)Customizing Articles")
1112 :type gnus-article-treat-head-custom)
1114 (defcustom gnus-treat-hide-signature nil
1115 "Hide the signature.
1116 Valid values are nil, t, `head', `first', `last', an integer or a
1117 predicate. See Info node `(gnus)Customizing Articles'."
1118 :group 'gnus-article-treat
1119 :link '(custom-manual "(gnus)Customizing Articles")
1120 :type gnus-article-treat-custom)
1122 (defcustom gnus-treat-fill-article nil
1124 Valid values are nil, t, `head', `first', `last', an integer or a
1125 predicate. See Info node `(gnus)Customizing Articles'."
1126 :group 'gnus-article-treat
1127 :link '(custom-manual "(gnus)Customizing Articles")
1128 :type gnus-article-treat-custom)
1130 (defcustom gnus-treat-hide-citation nil
1132 Valid values are nil, t, `head', `first', `last', an integer or a
1133 predicate. See Info node `(gnus)Customizing Articles'."
1134 :group 'gnus-article-treat
1135 :link '(custom-manual "(gnus)Customizing Articles")
1136 :type gnus-article-treat-custom)
1138 (defcustom gnus-treat-hide-citation-maybe nil
1140 Valid values are nil, t, `head', `first', `last', an integer or a
1141 predicate. See Info node `(gnus)Customizing Articles'."
1142 :group 'gnus-article-treat
1143 :link '(custom-manual "(gnus)Customizing Articles")
1144 :type gnus-article-treat-custom)
1146 (defcustom gnus-treat-strip-list-identifiers 'head
1147 "Strip list identifiers from `gnus-list-identifiers`.
1148 Valid values are nil, t, `head', `first', `last', an integer or a
1149 predicate. See Info node `(gnus)Customizing Articles'."
1151 :group 'gnus-article-treat
1152 :link '(custom-manual "(gnus)Customizing Articles")
1153 :type gnus-article-treat-custom)
1155 (make-obsolete-variable 'gnus-treat-strip-pgp
1156 "This option is obsolete in Gnus 5.10.")
1158 (defcustom gnus-treat-strip-pem nil
1159 "Strip PEM signatures.
1160 Valid values are nil, t, `head', `first', `last', an integer or a
1161 predicate. See Info node `(gnus)Customizing Articles'."
1162 :group 'gnus-article-treat
1163 :link '(custom-manual "(gnus)Customizing Articles")
1164 :type gnus-article-treat-custom)
1166 (defcustom gnus-treat-strip-banner t
1167 "Strip banners from articles.
1168 The banner to be stripped is specified in the `banner' group parameter.
1169 Valid values are nil, t, `head', `first', `last', an integer or a
1170 predicate. See Info node `(gnus)Customizing Articles'."
1171 :group 'gnus-article-treat
1172 :link '(custom-manual "(gnus)Customizing Articles")
1173 :type gnus-article-treat-custom)
1175 (defcustom gnus-treat-highlight-headers 'head
1176 "Highlight the headers.
1177 Valid values are nil, t, `head', `first', `last', an integer or a
1178 predicate. See Info node `(gnus)Customizing Articles'."
1179 :group 'gnus-article-treat
1180 :link '(custom-manual "(gnus)Customizing Articles")
1181 :type gnus-article-treat-head-custom)
1182 (put 'gnus-treat-highlight-headers 'highlight t)
1184 (defcustom gnus-treat-highlight-citation t
1185 "Highlight cited text.
1186 Valid values are nil, t, `head', `first', `last', an integer or a
1187 predicate. See Info node `(gnus)Customizing Articles'."
1188 :group 'gnus-article-treat
1189 :link '(custom-manual "(gnus)Customizing Articles")
1190 :type gnus-article-treat-custom)
1191 (put 'gnus-treat-highlight-citation 'highlight t)
1193 (defcustom gnus-treat-date-ut nil
1194 "Display the Date in UT (GMT).
1195 Valid values are nil, t, `head', `first', `last', an integer or a
1196 predicate. See Info node `(gnus)Customizing Articles'."
1197 :group 'gnus-article-treat
1198 :link '(custom-manual "(gnus)Customizing Articles")
1199 :type gnus-article-treat-head-custom)
1201 (defcustom gnus-treat-date-local nil
1202 "Display the Date in the local timezone.
1203 Valid values are nil, t, `head', `first', `last', an integer or a
1204 predicate. See Info node `(gnus)Customizing Articles'."
1205 :group 'gnus-article-treat
1206 :link '(custom-manual "(gnus)Customizing Articles")
1207 :type gnus-article-treat-head-custom)
1209 (defcustom gnus-treat-date-english nil
1210 "Display the Date in a format that can be read aloud in English.
1211 Valid values are nil, t, `head', `first', `last', an integer or a
1212 predicate. See Info node `(gnus)Customizing Articles'."
1214 :group 'gnus-article-treat
1215 :link '(custom-manual "(gnus)Customizing Articles")
1216 :type gnus-article-treat-head-custom)
1218 (defcustom gnus-treat-date-lapsed nil
1219 "Display the Date header in a way that says how much time has elapsed.
1220 Valid values are nil, t, `head', `first', `last', an integer or a
1221 predicate. See Info node `(gnus)Customizing Articles'."
1222 :group 'gnus-article-treat
1223 :link '(custom-manual "(gnus)Customizing Articles")
1224 :type gnus-article-treat-head-custom)
1226 (defcustom gnus-treat-date-original nil
1227 "Display the date in the original timezone.
1228 Valid values are nil, t, `head', `first', `last', an integer or a
1229 predicate. See Info node `(gnus)Customizing Articles'."
1230 :group 'gnus-article-treat
1231 :link '(custom-manual "(gnus)Customizing Articles")
1232 :type gnus-article-treat-head-custom)
1234 (defcustom gnus-treat-date-iso8601 nil
1235 "Display the date in the ISO8601 format.
1236 Valid values are nil, t, `head', `first', `last', an integer or a
1237 predicate. See Info node `(gnus)Customizing Articles'."
1239 :group 'gnus-article-treat
1240 :link '(custom-manual "(gnus)Customizing Articles")
1241 :type gnus-article-treat-head-custom)
1243 (defcustom gnus-treat-date-user-defined nil
1244 "Display the date in a user-defined format.
1245 The format is defined by the `gnus-article-time-format' variable.
1246 Valid values are nil, t, `head', `first', `last', an integer or a
1247 predicate. See Info node `(gnus)Customizing Articles'."
1248 :group 'gnus-article-treat
1249 :link '(custom-manual "(gnus)Customizing Articles")
1250 :type gnus-article-treat-head-custom)
1252 (defcustom gnus-treat-strip-headers-in-body t
1253 "Strip the X-No-Archive header line from the beginning of the body.
1254 Valid values are nil, t, `head', `first', `last', an integer or a
1255 predicate. See Info node `(gnus)Customizing Articles'."
1257 :group 'gnus-article-treat
1258 :link '(custom-manual "(gnus)Customizing Articles")
1259 :type gnus-article-treat-custom)
1261 (defcustom gnus-treat-strip-trailing-blank-lines nil
1262 "Strip trailing blank lines.
1263 Valid values are nil, t, `head', `first', `last', an integer or a
1264 predicate. See Info node `(gnus)Customizing Articles'.
1266 When set to t, it also strips trailing blanks in all MIME parts.
1267 Consider to use `last' instead."
1268 :group 'gnus-article-treat
1269 :link '(custom-manual "(gnus)Customizing Articles")
1270 :type gnus-article-treat-custom)
1272 (defcustom gnus-treat-strip-leading-blank-lines nil
1273 "Strip leading blank lines.
1274 Valid values are nil, t, `head', `first', `last', an integer or a
1275 predicate. See Info node `(gnus)Customizing Articles'.
1277 When set to t, it also strips trailing blanks in all MIME parts."
1278 :group 'gnus-article-treat
1279 :link '(custom-manual "(gnus)Customizing Articles")
1280 :type gnus-article-treat-custom)
1282 (defcustom gnus-treat-strip-multiple-blank-lines nil
1283 "Strip multiple blank lines.
1284 Valid values are nil, t, `head', `first', `last', an integer or a
1285 predicate. See Info node `(gnus)Customizing Articles'."
1286 :group 'gnus-article-treat
1287 :link '(custom-manual "(gnus)Customizing Articles")
1288 :type gnus-article-treat-custom)
1290 (defcustom gnus-treat-unfold-headers 'head
1291 "Unfold folded header lines.
1292 Valid values are nil, t, `head', `first', `last', an integer or a
1293 predicate. See Info node `(gnus)Customizing Articles'."
1295 :group 'gnus-article-treat
1296 :link '(custom-manual "(gnus)Customizing Articles")
1297 :type gnus-article-treat-custom)
1299 (defcustom gnus-treat-fold-headers nil
1301 Valid values are nil, t, `head', `first', `last', an integer or a
1302 predicate. See Info node `(gnus)Customizing Articles'."
1304 :group 'gnus-article-treat
1305 :link '(custom-manual "(gnus)Customizing Articles")
1306 :type gnus-article-treat-custom)
1308 (defcustom gnus-treat-fold-newsgroups 'head
1309 "Fold the Newsgroups and Followup-To headers.
1310 Valid values are nil, t, `head', `first', `last', an integer or a
1311 predicate. See Info node `(gnus)Customizing Articles'."
1313 :group 'gnus-article-treat
1314 :link '(custom-manual "(gnus)Customizing Articles")
1315 :type gnus-article-treat-custom)
1317 (defcustom gnus-treat-overstrike t
1318 "Treat overstrike highlighting.
1319 Valid values are nil, t, `head', `first', `last', an integer or a
1320 predicate. See Info node `(gnus)Customizing Articles'."
1321 :group 'gnus-article-treat
1322 :link '(custom-manual "(gnus)Customizing Articles")
1323 :type gnus-article-treat-custom)
1324 (put 'gnus-treat-overstrike 'highlight t)
1326 (defcustom gnus-treat-ansi-sequences (if (locate-library "ansi-color") t)
1327 "Treat ANSI SGR control sequences.
1328 Valid values are nil, t, `head', `first', `last', an integer or a
1329 predicate. See Info node `(gnus)Customizing Articles'."
1330 :group 'gnus-article-treat
1331 :link '(custom-manual "(gnus)Customizing Articles")
1332 :type gnus-article-treat-custom)
1334 (make-obsolete-variable 'gnus-treat-display-xface
1335 'gnus-treat-display-x-face)
1337 (defcustom gnus-treat-display-x-face
1338 (and (not noninteractive)
1339 (or (and (fboundp 'image-type-available-p)
1340 (image-type-available-p 'xbm)
1341 (string-match "^0x" (shell-command-to-string "uncompface"))
1342 (executable-find "icontopbm"))
1343 (and (featurep 'xemacs)
1346 "Display X-Face headers.
1347 Valid values are nil, t, `head', `first', `last', an integer or a
1348 predicate. See Info node `(gnus)Customizing Articles' and Info
1349 node `(gnus)X-Face' for details."
1350 :group 'gnus-article-treat
1352 :link '(custom-manual "(gnus)Customizing Articles")
1353 :link '(custom-manual "(gnus)X-Face")
1354 :type gnus-article-treat-head-custom
1355 :set (lambda (symbol value)
1358 (cond ((or (boundp symbol) (get symbol 'saved-value))
1360 ((boundp 'gnus-treat-display-xface)
1362 ** gnus-treat-display-xface is an obsolete variable;\
1363 use gnus-treat-display-x-face instead")
1364 (default-value 'gnus-treat-display-xface))
1365 ((get 'gnus-treat-display-xface 'saved-value)
1367 ** gnus-treat-display-xface is an obsolete variable;\
1368 use gnus-treat-display-x-face instead")
1369 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1372 (put 'gnus-treat-display-x-face 'highlight t)
1374 (defcustom gnus-article-should-use-smiley-mule
1375 (not (or (featurep 'xemacs)
1376 (gnus-image-type-available-p 'xpm)
1377 (gnus-image-type-available-p 'pbm)))
1378 "Non-nil means use `smiley-mule' to show smileys rather than `smiley'.
1379 `smiley-mule' is boundled in BITMAP-MULE package. You can set it to t
1380 even if your Emacs supports images. It has no effect on XEmacs."
1381 :group 'gnus-article-various
1383 :get (lambda (symbol)
1384 (and (not noninteractive)
1385 (default-value symbol)
1386 (not (featurep 'xemacs))
1387 (module-installed-p 'smiley-mule)
1389 :set (lambda (symbol value)
1390 (set-default symbol (and (not noninteractive)
1392 (not (featurep 'xemacs))
1393 (module-installed-p 'smiley-mule)
1396 (defvar gnus-article-smiley-mule-loaded-p nil
1397 "Internal variable used to say whether `smiley-mule' is loaded (whether
1398 smiley functions are not overridden by `smiley').")
1400 (defcustom gnus-treat-display-face
1401 (and (not noninteractive)
1402 (or (and (fboundp 'image-type-available-p)
1403 (image-type-available-p 'png))
1404 (and (featurep 'xemacs)
1407 "Display Face headers.
1408 Valid values are nil, t, `head', `first', `last', an integer or a
1409 predicate. See Info node `(gnus)Customizing Articles' and Info
1410 node `(gnus)X-Face' for details."
1411 :group 'gnus-article-treat
1413 :link '(custom-manual "(gnus)Customizing Articles")
1414 :link '(custom-manual "(gnus)X-Face")
1415 :type gnus-article-treat-head-custom)
1416 (put 'gnus-treat-display-face 'highlight t)
1418 (defcustom gnus-treat-display-smileys
1419 (if (and (not noninteractive)
1420 (or (and (featurep 'xemacs)
1422 (gnus-image-type-available-p 'xpm)
1423 (gnus-image-type-available-p 'pbm)
1424 (and (not (featurep 'xemacs))
1426 (module-installed-p 'smiley-mule))))
1430 Valid values are nil, t, `head', `first', `last', an integer or a
1431 predicate. See Info node `(gnus)Customizing Articles' and Info
1432 node `(gnus)Smileys' for details."
1433 :group 'gnus-article-treat
1435 :link '(custom-manual "(gnus)Customizing Articles")
1436 :link '(custom-manual "(gnus)Smileys")
1437 :type gnus-article-treat-custom)
1438 (put 'gnus-treat-display-smileys 'highlight t)
1440 (defcustom gnus-treat-from-picon
1441 (if (and (gnus-image-type-available-p 'xpm)
1442 (gnus-picons-installed-p))
1444 "Display picons in the From header.
1445 Valid values are nil, t, `head', `first', `last', an integer or a
1446 predicate. See Info node `(gnus)Customizing Articles' and Info
1447 node `(gnus)Picons' for details."
1449 :group 'gnus-article-treat
1451 :link '(custom-manual "(gnus)Customizing Articles")
1452 :link '(custom-manual "(gnus)Picons")
1453 :type gnus-article-treat-head-custom)
1454 (put 'gnus-treat-from-picon 'highlight t)
1456 (defcustom gnus-treat-mail-picon
1457 (if (and (gnus-image-type-available-p 'xpm)
1458 (gnus-picons-installed-p))
1460 "Display picons in To and Cc headers.
1461 Valid values are nil, t, `head', `first', `last', an integer or a
1462 predicate. See Info node `(gnus)Customizing Articles' and Info
1463 node `(gnus)Picons' for details."
1465 :group 'gnus-article-treat
1467 :link '(custom-manual "(gnus)Customizing Articles")
1468 :link '(custom-manual "(gnus)Picons")
1469 :type gnus-article-treat-head-custom)
1470 (put 'gnus-treat-mail-picon 'highlight t)
1472 (defcustom gnus-treat-newsgroups-picon
1473 (if (and (gnus-image-type-available-p 'xpm)
1474 (gnus-picons-installed-p))
1476 "Display picons in the Newsgroups and Followup-To headers.
1477 Valid values are nil, t, `head', `first', `last', an integer or a
1478 predicate. See Info node `(gnus)Customizing Articles' and Info
1479 node `(gnus)Picons' for details."
1481 :group 'gnus-article-treat
1483 :link '(custom-manual "(gnus)Customizing Articles")
1484 :link '(custom-manual "(gnus)Picons")
1485 :type gnus-article-treat-head-custom)
1486 (put 'gnus-treat-newsgroups-picon 'highlight t)
1488 (defcustom gnus-treat-body-boundary
1489 (if (and (eq window-system 'x)
1490 (or gnus-treat-newsgroups-picon
1491 gnus-treat-mail-picon
1492 gnus-treat-from-picon))
1494 "Draw a boundary at the end of the headers.
1495 Valid values are nil and `head'.
1496 See Info node `(gnus)Customizing Articles' for details."
1498 :group 'gnus-article-treat
1499 :link '(custom-manual "(gnus)Customizing Articles")
1500 :type gnus-article-treat-head-custom)
1502 (defcustom gnus-treat-capitalize-sentences nil
1503 "Capitalize sentence-starting words.
1504 Valid values are nil, t, `head', `first', `last', an integer or a
1505 predicate. See Info node `(gnus)Customizing Articles'."
1507 :group 'gnus-article-treat
1508 :link '(custom-manual "(gnus)Customizing Articles")
1509 :type gnus-article-treat-custom)
1511 (defcustom gnus-treat-wash-html nil
1513 Valid values are nil, t, `head', `first', `last', an integer or a
1514 predicate. See Info node `(gnus)Customizing Articles'."
1516 :group 'gnus-article-treat
1517 :link '(custom-manual "(gnus)Customizing Articles")
1518 :type gnus-article-treat-custom)
1520 (defcustom gnus-treat-fill-long-lines nil
1522 Valid values are nil, t, `head', `first', `last', an integer or a
1523 predicate. See Info node `(gnus)Customizing Articles'."
1524 :group 'gnus-article-treat
1525 :link '(custom-manual "(gnus)Customizing Articles")
1526 :type gnus-article-treat-custom)
1528 (defcustom gnus-treat-play-sounds nil
1530 Valid values are nil, t, `head', `first', `last', an integer or a
1531 predicate. See Info node `(gnus)Customizing Articles'."
1533 :group 'gnus-article-treat
1534 :link '(custom-manual "(gnus)Customizing Articles")
1535 :type gnus-article-treat-custom)
1537 (defcustom gnus-treat-decode-article-as-default-mime-charset nil
1538 "Decode an article as `default-mime-charset'. For instance, if you want to
1539 attempt to decode an article even if the value of `gnus-show-mime' is nil,
1540 you could set this variable to something like: nil for don't decode, t for
1541 decode the body, '(or header t) for the whole article, etc."
1542 :group 'gnus-article-treat
1543 :type '(radio (const :tag "Off" nil)
1544 (const :tag "Decode body" t)
1545 (const :tag "Decode all" (or head t))))
1547 (defcustom gnus-treat-translate nil
1548 "Translate articles from one language to another.
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 :link '(custom-manual "(gnus)Customizing Articles")
1554 :type gnus-article-treat-custom)
1556 (defcustom gnus-treat-x-pgp-sig nil
1558 To automatically treat X-PGP-Sig, set it to head.
1559 Valid values are nil, t, `head', `first', `last', an integer or a
1560 predicate. See Info node `(gnus)Customizing Articles'."
1562 :group 'gnus-article-treat
1563 :group 'mime-security
1564 :type gnus-article-treat-custom)
1566 (defcustom gnus-treat-monafy nil
1567 "Display body part with mona font.
1568 Valid values are nil, t, `head', `last', an integer or a predicate.
1569 See Info node `(gnus)Customizing Articles' for details."
1570 :group 'gnus-article-treat
1571 :group 'mime-security
1572 :link '(custom-manual "(gnus)Customizing Articles")
1573 :type gnus-article-treat-custom)
1575 (defvar gnus-article-encrypt-protocol-alist
1576 '(("PGP" . mml2015-self-encrypt)))
1578 ;; Set to nil if more than one protocol added to
1579 ;; gnus-article-encrypt-protocol-alist.
1580 (defcustom gnus-article-encrypt-protocol "PGP"
1581 "The protocol used for encrypt articles.
1582 It is a string, such as \"PGP\". If nil, ask user."
1585 :group 'mime-security)
1587 (defvar gnus-article-wash-function nil
1588 "Function used for converting HTML into text.")
1590 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1591 (mm-coding-system-p 'utf-8)
1592 (executable-find idna-program))
1593 "Whether IDNA decoding of headers is used when viewing messages.
1594 This requires GNU Libidn, and by default only enabled if it is found."
1596 :group 'gnus-article-headers
1599 (defcustom gnus-article-over-scroll nil
1600 "If non-nil, allow scrolling the article buffer even when there no more text."
1602 :group 'gnus-article
1605 ;;; Internal variables
1607 (defvar gnus-english-month-names
1608 '("January" "February" "March" "April" "May" "June" "July" "August"
1609 "September" "October" "November" "December"))
1611 (defvar gnus-button-regexp nil)
1612 (defvar gnus-button-marker-list nil)
1613 ;; Regexp matching any of the regexps from `gnus-button-alist'.
1615 (defvar gnus-button-last nil)
1616 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
1618 (defvar article-goto-body-goes-to-point-min-p nil)
1619 (defvar gnus-article-wash-types nil)
1620 (defvar gnus-article-emphasis-alist nil)
1621 (defvar gnus-article-image-alist nil)
1623 (defvar gnus-article-mime-handle-alist-1 nil)
1624 (defvar gnus-treatment-function-alist
1625 '((gnus-treat-decode-article-as-default-mime-charset
1626 gnus-article-decode-article-as-default-mime-charset)
1627 (gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1628 (gnus-treat-monafy gnus-article-monafy)
1629 (gnus-treat-strip-banner gnus-article-strip-banner)
1630 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1631 (gnus-treat-buttonize gnus-article-add-buttons)
1632 (gnus-treat-fill-article gnus-article-fill-cited-article)
1633 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1634 (gnus-treat-strip-cr gnus-article-remove-cr)
1635 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1636 (gnus-treat-date-ut gnus-article-date-ut)
1637 (gnus-treat-date-local gnus-article-date-local)
1638 (gnus-treat-date-english gnus-article-date-english)
1639 (gnus-treat-date-original gnus-article-date-original)
1640 (gnus-treat-date-user-defined gnus-article-date-user)
1641 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1642 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1643 (gnus-treat-display-face gnus-article-display-face)
1644 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1645 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1646 (gnus-treat-hide-signature gnus-article-hide-signature)
1647 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1648 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1649 (gnus-treat-strip-pem gnus-article-hide-pem)
1650 (gnus-treat-from-picon gnus-treat-from-picon)
1651 (gnus-treat-mail-picon gnus-treat-mail-picon)
1652 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1653 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1654 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1655 (gnus-treat-strip-trailing-blank-lines
1656 gnus-article-remove-trailing-blank-lines)
1657 (gnus-treat-strip-leading-blank-lines
1658 gnus-article-strip-leading-blank-lines)
1659 (gnus-treat-strip-multiple-blank-lines
1660 gnus-article-strip-multiple-blank-lines)
1661 (gnus-treat-overstrike gnus-article-treat-overstrike)
1662 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences)
1663 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1664 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1665 ;; Displaying X-Face should be done after unfolding headers
1666 ;; to protect bitmap lines.
1667 (gnus-treat-display-x-face gnus-article-display-x-face)
1668 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1669 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1670 (gnus-treat-display-smileys gnus-treat-smiley)
1671 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1672 (gnus-treat-wash-html gnus-article-wash-html)
1673 (gnus-treat-emphasize gnus-article-emphasize)
1674 (gnus-treat-hide-citation gnus-article-hide-citation)
1675 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1676 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1677 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1678 (gnus-treat-play-sounds gnus-earcon-display)))
1680 (defvar gnus-article-mime-handle-alist nil)
1681 (defvar article-lapsed-timer nil)
1682 (defvar gnus-article-current-summary nil)
1684 (defvar gnus-article-mode-syntax-table
1685 (let ((table (copy-syntax-table text-mode-syntax-table)))
1686 ;; This causes the citation match run O(2^n).
1687 ;; (modify-syntax-entry ?- "w" table)
1688 (modify-syntax-entry ?> ")<" table)
1689 (modify-syntax-entry ?< "(>" table)
1690 ;; make M-. in article buffers work for `foo' strings
1691 (modify-syntax-entry ?' " " table)
1692 (modify-syntax-entry ?` " " table)
1694 "Syntax table used in article mode buffers.
1695 Initialized from `text-mode-syntax-table.")
1697 (defvar gnus-save-article-buffer nil)
1699 (defvar gnus-article-mode-line-format-alist
1700 (nconc '((?w (gnus-article-wash-status) ?s)
1701 (?m (gnus-article-mime-part-status) ?s))
1702 gnus-summary-mode-line-format-alist))
1704 (defvar gnus-number-of-articles-to-be-saved nil)
1706 (defvar gnus-inhibit-hiding nil)
1708 (defvar gnus-article-edit-mode nil)
1710 ;;; Macros for dealing with the article buffer.
1712 (defmacro gnus-with-article-headers (&rest forms)
1714 (set-buffer gnus-article-buffer)
1716 (let ((inhibit-read-only t)
1717 (inhibit-point-motion-hooks t)
1718 (case-fold-search t))
1719 (article-narrow-to-head)
1722 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1723 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1725 (defmacro gnus-with-article-buffer (&rest forms)
1727 (set-buffer gnus-article-buffer)
1728 (let ((inhibit-read-only t))
1731 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1732 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1734 (defun gnus-article-goto-header (header)
1735 "Go to HEADER, which is a regular expression."
1736 (re-search-forward (concat "^\\(" header "\\):") nil t))
1738 (defsubst gnus-article-hide-text (b e props)
1739 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1740 (gnus-add-text-properties-when 'article-type nil b e props)
1741 (when (memq 'intangible props)
1743 (max (1- b) (point-min))
1744 b 'intangible (cddr (memq 'intangible props)))))
1746 (defsubst gnus-article-unhide-text (b e)
1747 "Remove hidden text properties from region between B and E."
1748 (remove-text-properties b e gnus-hidden-properties)
1749 (when (memq 'intangible gnus-hidden-properties)
1750 (put-text-property (max (1- b) (point-min))
1751 b 'intangible nil)))
1753 (defun gnus-article-hide-text-type (b e type)
1754 "Hide text of TYPE between B and E."
1755 (gnus-add-wash-type type)
1756 (gnus-article-hide-text
1757 b e (cons 'article-type (cons type gnus-hidden-properties))))
1759 (defun gnus-article-unhide-text-type (b e type)
1760 "Unhide text of TYPE between B and E."
1761 (gnus-delete-wash-type type)
1762 (remove-text-properties
1763 b e (cons 'article-type (cons type gnus-hidden-properties)))
1764 (when (memq 'intangible gnus-hidden-properties)
1765 (put-text-property (max (1- b) (point-min))
1766 b 'intangible nil)))
1768 (defun gnus-article-hide-text-of-type (type)
1769 "Hide text of TYPE in the current buffer."
1771 (let ((b (point-min))
1773 (while (setq b (text-property-any b e 'article-type type))
1774 (add-text-properties b (incf b) gnus-hidden-properties)))))
1776 (defun gnus-article-delete-text-of-type (type)
1777 "Delete text of TYPE in the current buffer."
1779 (let ((b (point-min)))
1780 (if (eq type 'multipart)
1781 ;; Remove MIME buttons associated with multipart/alternative parts.
1784 (while (if (get-text-property (point) 'gnus-part)
1786 (when (setq b (next-single-property-change (point)
1791 (skip-chars-forward "\n")
1792 (when (eq (get-text-property b 'article-type) 'multipart)
1793 (delete-region b (point)))))
1794 (while (setq b (text-property-any b (point-max) 'article-type type))
1796 b (or (text-property-not-all b (point-max) 'article-type type)
1799 (defun gnus-article-delete-invisible-text ()
1800 "Delete all invisible text in the current buffer."
1802 (let ((b (point-min)))
1803 (while (setq b (text-property-any b (point-max) 'invisible t))
1805 b (or (text-property-not-all b (point-max) 'invisible t)
1808 (defun gnus-article-text-type-exists-p (type)
1809 "Say whether any text of type TYPE exists in the buffer."
1810 (text-property-any (point-min) (point-max) 'article-type type))
1812 (defsubst gnus-article-header-rank ()
1813 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1814 (let ((list gnus-sorted-header-list)
1817 (if (looking-at (car list))
1819 (setq list (cdr list))
1823 (defun article-hide-headers (&optional arg delete)
1824 "Hide unwanted headers and possibly sort them as well."
1825 (interactive (gnus-article-hidden-arg))
1826 ;; Lars said that this function might be inhibited.
1827 (if (gnus-article-check-hidden-text 'headers arg)
1829 ;; Show boring headers as well.
1830 (gnus-article-show-hidden-text 'boring-headers)
1831 (when (eq 1 (point-min))
1832 (set-window-start (get-buffer-window (current-buffer)) 1)))
1833 (unless gnus-inhibit-hiding
1834 (let ((inhibit-read-only t)
1835 (case-fold-search t)
1836 (max (1+ (length gnus-sorted-header-list)))
1837 (inhibit-point-motion-hooks t)
1838 (cur (current-buffer))
1839 ignored visible beg)
1841 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1842 ;; group parameters, so we should go to the summary buffer.
1845 (progn (set-buffer gnus-summary-buffer) t)
1847 (setq ignored (when (not gnus-visible-headers)
1848 (cond ((stringp gnus-ignored-headers)
1849 gnus-ignored-headers)
1850 ((listp gnus-ignored-headers)
1851 (mapconcat 'identity
1852 gnus-ignored-headers
1854 visible (cond ((stringp gnus-visible-headers)
1855 gnus-visible-headers)
1856 ((and gnus-visible-headers
1857 (listp gnus-visible-headers))
1858 (mapconcat 'identity
1859 gnus-visible-headers
1863 ;; First we narrow to just the headers.
1864 (article-narrow-to-head)
1865 ;; Hide any "From " lines at the beginning of (mail) articles.
1866 (while (looking-at "From ")
1870 (delete-region (point-min) (point))
1871 (gnus-article-hide-text (point-min) (point)
1872 (nconc (list 'article-type 'headers)
1873 gnus-hidden-properties))))
1874 ;; Then treat the rest of the header lines.
1875 ;; Then we use the two regular expressions
1876 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1877 ;; select which header lines is to remain visible in the
1879 (while (re-search-forward "^[^ \t:]*:" nil t)
1881 ;; Mark the rank of the header.
1883 (point) (1+ (point)) 'message-rank
1884 (if (or (and visible (looking-at visible))
1886 (not (looking-at ignored))))
1887 (gnus-article-header-rank)
1890 (message-sort-headers-1)
1891 (when (setq beg (text-property-any
1892 (point-min) (point-max) 'message-rank (+ 2 max)))
1893 ;; We delete or make invisible the unwanted headers.
1894 (gnus-add-wash-type 'headers)
1897 (add-text-properties
1898 (point-min) (+ 5 (point-min))
1899 '(article-type headers dummy-invisible t))
1900 (delete-region beg (point-max)))
1901 (gnus-article-hide-text-type beg (point-max) 'headers)))))))))
1903 (defun article-hide-boring-headers (&optional arg)
1904 "Toggle hiding of headers that aren't very interesting.
1905 If given a negative prefix, always show; if given a positive prefix,
1907 (interactive (gnus-article-hidden-arg))
1908 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1909 (not gnus-show-all-headers))
1912 (let ((inhibit-read-only t)
1913 (inhibit-point-motion-hooks t))
1914 (article-narrow-to-head)
1915 (dolist (elem gnus-boring-article-headers)
1916 (goto-char (point-min))
1918 ;; Hide empty headers.
1920 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1922 (gnus-article-hide-text-type
1926 (if (re-search-forward "^[^ \t]" nil t)
1930 ;; Hide boring Newsgroups header.
1931 ((eq elem 'newsgroups)
1932 (when (gnus-string-equal
1933 (gnus-fetch-field "newsgroups")
1934 (gnus-group-real-name
1935 (if (boundp 'gnus-newsgroup-name)
1938 (gnus-article-hide-header "newsgroups")))
1939 ((eq elem 'to-address)
1940 (let ((to (message-fetch-field "to"))
1942 (gnus-parameter-to-address
1943 (if (boundp 'gnus-newsgroup-name)
1944 gnus-newsgroup-name ""))))
1945 (when (and to to-address
1948 ;; only one address in To
1949 (nth 1 (mail-extract-address-components to))
1951 (gnus-article-hide-header "to"))))
1953 (let ((to (message-fetch-field "to"))
1955 (gnus-parameter-to-list
1956 (if (boundp 'gnus-newsgroup-name)
1957 gnus-newsgroup-name ""))))
1958 (when (and to to-list
1961 ;; only one address in To
1962 (nth 1 (mail-extract-address-components to))
1964 (gnus-article-hide-header "to"))))
1966 (let ((cc (message-fetch-field "cc"))
1968 (gnus-parameter-to-list
1969 (if (boundp 'gnus-newsgroup-name)
1970 gnus-newsgroup-name ""))))
1971 (when (and cc to-list
1974 ;; only one address in CC
1975 (nth 1 (mail-extract-address-components cc))
1977 (gnus-article-hide-header "cc"))))
1978 ((eq elem 'followup-to)
1979 (when (gnus-string-equal
1980 (message-fetch-field "followup-to")
1981 (message-fetch-field "newsgroups"))
1982 (gnus-article-hide-header "followup-to")))
1983 ((eq elem 'reply-to)
1984 (if (gnus-group-find-parameter
1985 gnus-newsgroup-name 'broken-reply-to)
1986 (gnus-article-hide-header "reply-to")
1987 (let ((from (message-fetch-field "from"))
1988 (reply-to (message-fetch-field "reply-to")))
1995 (lambda (x) (downcase (cadr x)))
1996 (mail-extract-address-components from t))
1999 (lambda (x) (downcase (cadr x)))
2000 (mail-extract-address-components reply-to t))
2002 (gnus-article-hide-header "reply-to")))))
2004 (let ((date (message-fetch-field "date")))
2006 (< (days-between (current-time-string) date)
2008 (gnus-article-hide-header "date"))))
2010 (let ((to (message-fetch-field "to"))
2011 (cc (message-fetch-field "cc")))
2012 (when (> (length to) 1024)
2013 (gnus-article-hide-header "to"))
2014 (when (> (length cc) 1024)
2015 (gnus-article-hide-header "cc"))))
2019 (goto-char (point-min))
2020 (while (re-search-forward "^to:" nil t)
2021 (setq to-count (1+ to-count)))
2022 (when (> to-count 1)
2023 (while (> to-count 0)
2024 (goto-char (point-min))
2026 (re-search-forward "^to:" nil nil to-count)
2028 (narrow-to-region (point) (point-max))
2029 (gnus-article-hide-header "to"))
2030 (setq to-count (1- to-count))))
2031 (goto-char (point-min))
2032 (while (re-search-forward "^cc:" nil t)
2033 (setq cc-count (1+ cc-count)))
2034 (when (> cc-count 1)
2035 (while (> cc-count 0)
2036 (goto-char (point-min))
2038 (re-search-forward "^cc:" nil nil cc-count)
2040 (narrow-to-region (point) (point-max))
2041 (gnus-article-hide-header "cc"))
2042 (setq cc-count (1- cc-count)))))))))))))
2044 (defun gnus-article-hide-header (header)
2046 (goto-char (point-min))
2047 (when (re-search-forward (concat "^" header ":") nil t)
2048 (gnus-article-hide-text-type
2052 (if (re-search-forward "^[^ \t]" nil t)
2057 (defvar gnus-article-normalized-header-length 40
2058 "Length of normalized headers.")
2060 (defun article-normalize-headers ()
2061 "Make all header lines 40 characters long."
2063 (let ((inhibit-read-only t)
2067 (article-narrow-to-head)
2070 ((< (setq column (- (point-at-eol) (point)))
2071 gnus-article-normalized-header-length)
2073 (insert (make-string
2074 (- gnus-article-normalized-header-length column)
2076 ((> column gnus-article-normalized-header-length)
2077 (gnus-put-text-property
2079 (forward-char gnus-article-normalized-header-length)
2086 (forward-line 1))))))
2088 (defun article-treat-dumbquotes ()
2089 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
2090 Note that this function guesses whether a character is a sm*rtq**t* or
2091 not, so it should only be used interactively.
2093 Sm*rtq**t*s are M****s***'s unilateral extension to the
2094 iso-8859-1 character map in an attempt to provide more quoting
2095 characters. If you see something like \\222 or \\264 where
2096 you're expecting some kind of apostrophe or quotation mark, then
2099 (article-translate-strings gnus-article-dumbquotes-map))
2101 (defun article-translate-characters (from to)
2102 "Translate all characters in the body of the article according to FROM and TO.
2103 FROM is a string of characters to translate from; to is a string of
2104 characters to translate to."
2106 (when (article-goto-body)
2107 (let ((inhibit-read-only t)
2108 (x (make-string 225 ?x))
2110 (while (< (incf i) (length x))
2113 (while (< i (length from))
2114 (aset x (aref from i) (aref to i))
2116 (translate-region (point) (point-max) x)))))
2118 (defun article-translate-strings (map)
2119 "Translate all string in the body of the article according to MAP.
2120 MAP is an alist where the elements are on the form (\"from\" \"to\")."
2122 (when (article-goto-body)
2123 (let ((inhibit-read-only t))
2126 (while (search-forward (car elem) nil t)
2127 (replace-match (cadr elem)))))))))
2129 (defun article-treat-overstrike ()
2130 "Translate overstrikes into bold text."
2133 (when (article-goto-body)
2134 (let ((inhibit-read-only t))
2135 (while (search-forward "\b" nil t)
2136 (let ((next (char-after))
2140 previous (char-after))
2144 ;; We do the boldification/underlining by hiding the
2145 ;; overstrikes and putting the proper text property
2149 (gnus-article-hide-text-type start (point) 'overstrike)
2150 (put-text-property (point) end 'face 'bold))
2152 (gnus-article-hide-text-type
2153 (1- (point)) (1+ (point)) 'overstrike)
2155 start (1- (point)) 'face 'underline))
2157 (gnus-article-hide-text-type start (point) 'overstrike)
2159 (point) end 'face 'underline)))))))))
2161 (defun article-treat-ansi-sequences ()
2162 "Translate ANSI SGR control sequences into overlays or extents."
2165 (when (article-goto-body)
2166 (let ((inhibit-read-only t))
2167 (ansi-color-apply-on-region (point) (point-max))))))
2169 (defun gnus-article-treat-unfold-headers ()
2170 "Unfold folded message headers.
2171 Only the headers that fit into the current window width will be
2174 (gnus-with-article-headers
2178 (mail-header-narrow-to-field)
2179 (let ((header (buffer-string)))
2182 (goto-char (point-min))
2183 (while (re-search-forward "\n[\t ]" nil t)
2184 (replace-match " " t t)))
2185 (setq length (- (point-max) (point-min) 1)))
2186 (when (< length (window-width))
2187 (while (re-search-forward "\n[\t ]" nil t)
2188 (replace-match " " t t)))
2189 (goto-char (point-max)))))))
2191 (defun gnus-article-treat-fold-headers ()
2192 "Fold message headers."
2194 (gnus-with-article-headers
2197 (mail-header-narrow-to-field)
2198 (mail-header-fold-field)
2199 (goto-char (point-max))))))
2201 (defun gnus-treat-smiley ()
2202 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2204 (unless (featurep 'xemacs)
2205 (when (and (not gnus-article-should-use-smiley-mule)
2206 gnus-article-smiley-mule-loaded-p)
2207 (load "smiley" nil t)
2208 (setq gnus-article-smiley-mule-loaded-p nil))
2209 (when (and gnus-article-should-use-smiley-mule
2210 (not gnus-article-smiley-mule-loaded-p))
2211 (load "smiley-mule" nil t)
2212 (setq gnus-article-smiley-mule-loaded-p t)))
2213 (gnus-with-article-buffer
2214 (if (memq 'smiley gnus-article-wash-types)
2215 (gnus-delete-images 'smiley)
2217 (let ((images (smiley-region (point) (point-max))))
2219 (gnus-add-wash-type 'smiley)
2220 (dolist (image images)
2221 (gnus-add-image 'smiley image)))))))
2223 (defun gnus-article-remove-images ()
2224 "Remove all images from the article buffer."
2226 (gnus-with-article-buffer
2227 (dolist (elem gnus-article-image-alist)
2228 (gnus-delete-images (car elem)))))
2230 (defun gnus-article-treat-fold-newsgroups ()
2231 "Unfold folded message headers.
2232 Only the headers that fit into the current window width will be
2235 (gnus-with-article-headers
2236 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2238 (mail-header-narrow-to-field)
2239 (while (re-search-forward ", *" nil t)
2240 (replace-match ", " t t))
2241 (mail-header-fold-field)
2242 (goto-char (point-max))))))
2244 (defun gnus-article-treat-body-boundary ()
2245 "Place a boundary line at the end of the headers."
2247 (when (and gnus-body-boundary-delimiter
2248 (> (length gnus-body-boundary-delimiter) 0))
2249 (gnus-with-article-headers
2250 (goto-char (point-max))
2251 (let ((start (point)))
2252 (insert "X-Boundary: ")
2253 (gnus-add-text-properties start (point) '(invisible t intangible t))
2255 (while (>= (1- (window-width)) (length str))
2256 (setq str (concat str gnus-body-boundary-delimiter)))
2257 (substring str 0 (1- (window-width))))
2259 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2261 (defun article-fill-long-lines ()
2262 "Fill lines that are wider than the window width."
2265 (let ((inhibit-read-only t)
2266 (width (window-width (get-buffer-window (current-buffer)))))
2269 (let ((adaptive-fill-mode nil)) ;Why? -sm
2272 (when (>= (current-column) (min fill-column width))
2273 (narrow-to-region (min (1+ (point)) (point-max))
2275 (let ((goback (point-marker)))
2276 (fill-paragraph nil)
2277 (goto-char (marker-position goback)))
2279 (forward-line 1)))))))
2281 (defun article-capitalize-sentences ()
2282 "Capitalize the first word in each sentence."
2285 (let ((inhibit-read-only t)
2286 (paragraph-start "^[\n\^L]"))
2290 (forward-sentence)))))
2292 (defun article-remove-cr ()
2293 "Remove trailing CRs and then translate remaining CRs into LFs."
2296 (let ((inhibit-read-only t))
2297 (goto-char (point-min))
2298 (while (re-search-forward "\r+$" nil t)
2299 (replace-match "" t t))
2300 (goto-char (point-min))
2301 (while (search-forward "\r" nil t)
2302 (replace-match "\n" t t)))))
2304 (defun article-remove-trailing-blank-lines ()
2305 "Remove all trailing blank lines from the article."
2308 (let ((inhibit-read-only t))
2309 (goto-char (point-max))
2313 (while (and (not (bobp))
2314 (looking-at "^[ \t]*$")
2315 (not (gnus-annotation-in-region-p
2316 (point) (point-at-eol))))
2322 (defvar gnus-face-properties-alist))
2324 (defun article-display-face ()
2325 "Display any Face headers in the header."
2327 (let ((wash-face-p buffer-read-only))
2328 (gnus-with-article-headers
2329 ;; When displaying parts, this function can be called several times on
2330 ;; the same article, without any intended toggle semantic (as typing `W
2331 ;; D d' would have). So face deletion must occur only when we come from
2332 ;; an interactive command, that is when the *Article* buffer is
2334 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2335 (gnus-delete-images 'face)
2336 (let (face faces from)
2337 (save-current-buffer
2338 (when (and wash-face-p
2339 (gnus-buffer-live-p gnus-original-article-buffer)
2340 (not (re-search-forward "^Face:[\t ]*" nil t)))
2341 (set-buffer gnus-original-article-buffer))
2343 (mail-narrow-to-head)
2344 (while (gnus-article-goto-header "Face")
2345 (push (mail-header-field-value) faces))))
2347 (goto-char (point-min))
2348 (let ((from (gnus-article-goto-header "from"))
2353 (insert "[no `from' set]\n"))
2355 (when (setq png (gnus-convert-face-to-png (pop faces)))
2357 (apply 'gnus-create-image png 'png t
2358 (cdr (assq 'png gnus-face-properties-alist))))
2360 (gnus-add-wash-type 'face)
2361 (gnus-add-image 'face image)
2362 (gnus-put-image image nil 'face))))))))))
2364 (defun article-display-x-face (&optional force)
2365 "Look for an X-Face header and display it if present."
2366 (interactive (list 'force))
2367 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2368 (gnus-with-article-headers
2369 ;; Delete the old process, if any.
2370 (when (process-status "article-x-face")
2371 (delete-process "article-x-face"))
2372 ;; See the comment in `article-display-face'.
2373 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2374 ;; We have already displayed X-Faces, so we remove them
2376 (gnus-delete-images 'xface)
2378 (let (x-faces from face)
2379 (save-current-buffer
2380 (when (and wash-face-p
2381 (gnus-buffer-live-p gnus-original-article-buffer)
2382 (not (re-search-forward "^X-Face:[\t ]*" nil t)))
2383 ;; If type `W f', use gnus-original-article-buffer,
2384 ;; otherwise use the current buffer because displaying
2385 ;; RFC822 parts calls this function too.
2386 (set-buffer gnus-original-article-buffer))
2388 (mail-narrow-to-head)
2389 (while (gnus-article-goto-header "X-Face")
2390 (push (mail-header-field-value) x-faces))
2391 (setq from (message-fetch-field "from"))))
2392 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2393 ;; single external face.
2394 (when (stringp gnus-article-x-face-command)
2395 (setq x-faces (list (car x-faces))))
2397 gnus-article-x-face-command
2399 ;; Check whether this face is censored.
2400 (not gnus-article-x-face-too-ugly)
2402 (not (string-match gnus-article-x-face-too-ugly
2404 (while (setq face (pop x-faces))
2405 ;; We display the face.
2406 (cond ((stringp gnus-article-x-face-command)
2407 ;; The command is a string, so we interpret the command
2408 ;; as a, well, command, and fork it off.
2409 (let ((process-connection-type nil))
2410 (gnus-set-process-query-on-exit-flag
2412 "article-x-face" nil shell-file-name
2413 shell-command-switch gnus-article-x-face-command)
2417 (process-send-region "article-x-face"
2418 (point-min) (point-max)))
2419 (process-send-eof "article-x-face")))
2420 ((functionp gnus-article-x-face-command)
2421 ;; The command is a lisp function, so we call it.
2422 (funcall gnus-article-x-face-command face))
2424 (error "%s is not a function"
2425 gnus-article-x-face-command))))))))))
2427 (defun article-decode-mime-words ()
2428 "Decode all MIME-encoded words in the article."
2430 (gnus-with-article-buffer
2431 (let ((inhibit-point-motion-hooks t)
2432 (mail-parse-charset gnus-newsgroup-charset)
2433 (mail-parse-ignored-charsets
2434 (with-current-buffer gnus-summary-buffer
2435 gnus-newsgroup-ignored-charsets)))
2436 (mail-decode-encoded-word-region (point-min) (point-max)))))
2438 (defun article-decode-charset (&optional prompt)
2439 "Decode charset-encoded text in the article.
2440 If PROMPT (the prefix), prompt for a coding system to use."
2442 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2443 (inhibit-read-only t)
2444 (mail-parse-charset gnus-newsgroup-charset)
2445 (mail-parse-ignored-charsets
2446 (save-excursion (condition-case nil
2447 (set-buffer gnus-summary-buffer)
2449 gnus-newsgroup-ignored-charsets))
2450 ct cte ctl charset format)
2453 (article-narrow-to-head)
2454 (setq ct (message-fetch-field "Content-Type" t)
2455 cte (message-fetch-field "Content-Transfer-Encoding" t)
2456 ctl (and ct (mail-header-parse-content-type ct))
2459 (mm-read-coding-system "Charset to decode: "))
2461 (mail-content-type-get ctl 'charset)))
2462 format (and ctl (mail-content-type-get ctl 'format)))
2464 (setq cte (mail-header-strip cte)))
2465 (if (and ctl (not (string-match "/" (car ctl))))
2467 (goto-char (point-max)))
2470 (narrow-to-region (point) (point-max))
2471 (when (and (eq mail-parse-charset 'gnus-decoded)
2472 (eq (mm-body-7-or-8) '8bit))
2473 ;; The text code could have been decoded.
2474 (setq charset mail-parse-charset))
2475 (when (and (or (not ctl)
2476 (equal (car ctl) "text/plain"))
2477 (not format)) ;; article with format will decode later.
2479 charset (and cte (intern (downcase
2480 (gnus-strip-whitespace cte))))
2483 (defun article-decode-encoded-words ()
2484 "Remove encoded-word encoding from headers."
2485 (let ((charset (save-excursion
2486 (set-buffer gnus-summary-buffer)
2487 default-mime-charset))
2488 (inhibit-read-only t))
2489 (mime-decode-header-in-buffer charset)))
2491 (defun article-decode-group-name ()
2492 "Decode group names in `Newsgroups:'."
2493 (let ((inhibit-point-motion-hooks t)
2494 (inhibit-read-only t)
2495 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2496 (when (and (or gnus-group-name-charset-method-alist
2497 gnus-group-name-charset-group-alist)
2498 (gnus-buffer-live-p gnus-original-article-buffer))
2500 (article-narrow-to-head)
2501 (with-current-buffer gnus-original-article-buffer
2502 (goto-char (point-min)))
2503 (while (re-search-forward
2504 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2505 (replace-match (save-match-data
2506 (gnus-decode-newsgroups
2507 ;; XXX how to use data in article buffer?
2508 (with-current-buffer gnus-original-article-buffer
2510 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2513 gnus-newsgroup-name method))
2515 (goto-char (point-min))
2516 (with-current-buffer gnus-original-article-buffer
2517 (goto-char (point-min)))
2518 (while (re-search-forward
2519 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2520 (replace-match (save-match-data
2521 (gnus-decode-newsgroups
2522 ;; XXX how to use data in article buffer?
2523 (with-current-buffer gnus-original-article-buffer
2525 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2528 gnus-newsgroup-name method))
2531 (autoload 'idna-to-unicode "idna")
2533 (defun article-decode-idna-rhs ()
2534 "Decode IDNA strings in RHS in various headers in current buffer.
2535 The following headers are decoded: From:, To:, Cc:, Reply-To:,
2536 Mail-Reply-To: and Mail-Followup-To:."
2539 (let ((inhibit-point-motion-hooks t)
2540 (inhibit-read-only t))
2541 (article-narrow-to-head)
2542 (goto-char (point-min))
2543 (while (re-search-forward "@[^ \t\n\r,>]*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2545 (when (save-match-data
2546 (and (setq ace (match-string 1))
2548 (and (re-search-backward "^[^ \t]" nil t)
2549 (looking-at "From\\|To\\|Cc\\|Reply-To\\|Mail-Reply-To\\|Mail-Followup-To")))
2550 (setq unicode (idna-to-unicode ace))))
2551 (unless (string= ace unicode)
2552 (replace-match unicode nil nil nil 1)))))))))
2554 (defun article-de-quoted-unreadable (&optional force read-charset)
2555 "Translate a quoted-printable-encoded article.
2556 If FORCE, decode the article whether it is marked as quoted-printable
2558 If READ-CHARSET, ask for a coding system."
2559 (interactive (list 'force current-prefix-arg))
2561 (let ((inhibit-read-only t) type charset)
2562 (if (gnus-buffer-live-p gnus-original-article-buffer)
2563 (with-current-buffer gnus-original-article-buffer
2565 (gnus-fetch-field "content-transfer-encoding"))
2566 (let* ((ct (gnus-fetch-field "content-type"))
2567 (ctl (and ct (mail-header-parse-content-type ct))))
2568 (setq charset (and ctl
2569 (mail-content-type-get ctl 'charset)))
2570 (if (stringp charset)
2571 (setq charset (intern (downcase charset)))))))
2573 (setq charset (mm-read-coding-system "Charset: " charset)))
2575 (setq charset gnus-newsgroup-charset))
2577 (and type (let ((case-fold-search t))
2578 (string-match "quoted-printable" type))))
2580 (quoted-printable-decode-region
2581 (point) (point-max) (mm-charset-to-coding-system charset))))))
2583 (defun article-de-base64-unreadable (&optional force read-charset)
2584 "Translate a base64 article.
2585 If FORCE, decode the article whether it is marked as base64 not.
2586 If READ-CHARSET, ask for a coding system."
2587 (interactive (list 'force current-prefix-arg))
2589 (let ((inhibit-read-only t) type charset)
2590 (if (gnus-buffer-live-p gnus-original-article-buffer)
2591 (with-current-buffer gnus-original-article-buffer
2593 (gnus-fetch-field "content-transfer-encoding"))
2594 (let* ((ct (gnus-fetch-field "content-type"))
2595 (ctl (and ct (mail-header-parse-content-type ct))))
2596 (setq charset (and ctl
2597 (mail-content-type-get ctl 'charset)))
2598 (if (stringp charset)
2599 (setq charset (intern (downcase charset)))))))
2601 (setq charset (mm-read-coding-system "Charset: " charset)))
2603 (setq charset gnus-newsgroup-charset))
2605 (and type (let ((case-fold-search t))
2606 (string-match "base64" type))))
2609 (narrow-to-region (point) (point-max))
2610 (base64-decode-region (point-min) (point-max))
2611 (mm-decode-coding-region
2612 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2617 (defun article-decode-HZ ()
2618 "Translate a HZ-encoded article."
2622 (let ((inhibit-read-only t))
2623 (rfc1843-decode-region (point-min) (point-max)))))
2625 (defun article-unsplit-urls ()
2626 "Remove the newlines that some other mailers insert into URLs."
2629 (let ((inhibit-read-only t))
2630 (goto-char (point-min))
2631 (while (re-search-forward
2632 "\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2633 (replace-match "\\1\\3" t)))
2634 (when (interactive-p)
2635 (gnus-treat-article nil))))
2638 (defun article-wash-html (&optional read-charset)
2639 "Format an HTML article.
2640 If READ-CHARSET, ask for a coding system. If it is a number, the
2641 charset defined in `gnus-summary-show-article-charset-alist' is used."
2644 (let ((inhibit-read-only t)
2647 (if (or (and (numberp read-charset)
2651 gnus-summary-show-article-charset-alist))))
2652 (setq charset (mm-read-coding-system "Charset: ")))
2653 (let ((gnus-summary-show-article-charset-alist
2654 (list (cons 1 charset))))
2655 (with-current-buffer gnus-summary-buffer
2656 (gnus-summary-show-article 1)))
2657 (error "No charset is given"))
2658 (when (gnus-buffer-live-p gnus-original-article-buffer)
2659 (with-current-buffer gnus-original-article-buffer
2660 (let* ((ct (gnus-fetch-field "content-type"))
2661 (ctl (and ct (mail-header-parse-content-type ct))))
2662 (setq charset (and ctl
2663 (mail-content-type-get ctl 'charset)))
2664 (when (stringp charset)
2665 (setq charset (intern (downcase charset)))))))
2667 (setq charset gnus-newsgroup-charset)))
2669 (save-window-excursion
2671 (narrow-to-region (point) (point-max))
2672 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2673 (entry (assq func mm-text-html-washer-alist)))
2675 (setq func (cdr entry)))
2680 (apply (car func) (cdr func))))))))))
2682 (defun gnus-article-wash-html-with-w3 ()
2683 "Wash the current buffer with w3."
2685 (let ((w3-strict-width (window-width))
2686 (url-standalone-mode t)
2687 (url-gateway-unplugged t)
2688 (w3-honor-stylesheets nil))
2690 (w3-region (point-min) (point-max))
2693 (defun gnus-article-wash-html-with-w3m ()
2694 "Wash the current buffer with emacs-w3m."
2696 (let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp)
2697 w3m-force-redisplay)
2698 (w3m-region (point-min) (point-max)))
2699 (when (and mm-inline-text-html-with-w3m-keymap
2700 (boundp 'w3m-minor-mode-map)
2702 (add-text-properties
2703 (point-min) (point-max)
2704 (list 'keymap w3m-minor-mode-map
2705 ;; Put the mark meaning this part was rendered by emacs-w3m.
2706 'mm-inline-text-html-with-w3m t))))
2708 (eval-when-compile (defvar charset)) ;; Bound by `article-wash-html'.
2710 (defun gnus-article-wash-html-with-w3m-standalone ()
2711 "Wash the current buffer with w3m."
2712 (if (mm-w3m-standalone-supports-m17n-p)
2714 (unless (mm-coding-system-p charset) ;; Bound by `article-wash-html'.
2716 (setq charset 'iso-8859-1))
2717 (let ((coding-system-for-write charset)
2718 (coding-system-for-read charset))
2719 (call-process-region
2720 (point-min) (point-max)
2721 "w3m" t t nil "-dump" "-T" "text/html"
2722 "-I" (symbol-name charset) "-O" (symbol-name charset))))
2723 (mm-inline-wash-with-stdin nil "w3m" "-dump" "-T" "text/html")))
2725 (defvar gnus-article-browse-html-temp-list nil
2726 "List of temporary files created by `gnus-article-browse-html-parts'.
2727 Internal variable.")
2729 (defcustom gnus-article-browse-delete-temp 'ask
2730 "What to do with temporary files from `gnus-article-browse-html-parts'.
2731 If nil, don't delete temporary files. If it is t, delete them on
2732 exit from the summary buffer. If it is the symbol `file', query
2733 on each file, if it is `ask' ask once when exiting from the
2735 :group 'gnus-article
2736 :type '(choice (const :tag "Don't delete" nil)
2737 (const :tag "Don't ask" t)
2738 (const :tag "Ask" ask)
2739 (const :tag "Ask for each file" file)))
2741 ;; Cf. mm-postponed-undisplay-list / mm-destroy-postponed-undisplay-list.
2743 (defun gnus-article-browse-delete-temp-files (&optional how)
2744 "Delete temp-files created by `gnus-article-browse-html-parts'."
2745 (when (and gnus-article-browse-html-temp-list
2747 (setq how gnus-article-browse-delete-temp)))
2748 (when (and (eq how 'ask)
2750 "Delete all %s temporary HTML file(s)? "
2751 (length gnus-article-browse-html-temp-list)))
2753 (dolist (file gnus-article-browse-html-temp-list)
2754 (when (and (file-exists-p file)
2756 ;; `how' is neither `nil', `ask' nor `t' (i.e. `file'):
2758 (format "Delete temporary HTML file `%s'? " file))))
2759 (delete-file file)))
2760 ;; Also remove file from the list when not deleted or if file doesn't
2762 (setq gnus-article-browse-html-temp-list nil))
2763 gnus-article-browse-html-temp-list)
2765 (defun gnus-article-browse-html-parts (list)
2766 "View all \"text/html\" parts from LIST.
2767 Recurse into multiparts."
2768 ;; Internal function used by `gnus-article-browse-html-article'.
2770 ;; Find and show the html-parts.
2771 (dolist (handle list)
2772 ;; If HTML, show it:
2773 (when (listp handle)
2774 (cond ((and (bufferp (car handle))
2775 (string-match "text/html" (car (mm-handle-type handle))))
2776 (let ((tmp-file (mm-make-temp-file
2777 ;; Do we need to care for 8.3 filenames?
2778 "mm-" nil ".html")))
2779 (mm-save-part-to-file handle tmp-file)
2780 (add-to-list 'gnus-article-browse-html-temp-list tmp-file)
2781 (add-hook 'gnus-summary-prepare-exit-hook
2782 'gnus-article-browse-delete-temp-files)
2783 (add-hook 'gnus-exit-gnus-hook
2785 (gnus-article-browse-delete-temp-files t)))
2786 (browse-url tmp-file)
2788 ;; If multipart, recurse
2789 ((and (stringp (car handle))
2790 (string-match "^multipart/" (car handle))
2793 (gnus-article-browse-html-parts handle))))))))
2796 ;; TODO: Key binding
2797 (defun gnus-article-browse-html-article ()
2798 "View \"text/html\" parts of the current article with a WWW browser."
2800 (save-window-excursion
2801 ;; Open raw article and select the buffer
2802 (gnus-summary-show-article t)
2803 (gnus-summary-select-article-buffer)
2804 (let ((parts (mm-dissect-buffer t t)))
2805 ;; If singlepart, enforce a list.
2806 (when (and (bufferp (car parts))
2807 (stringp (car (mm-handle-type parts))))
2808 (setq parts (list parts)))
2810 (unless (gnus-article-browse-html-parts parts)
2811 (gnus-error 3 "Mail doesn't contain a \"text/html\" part!"))
2812 (gnus-summary-show-article))))
2814 (defun article-hide-list-identifiers ()
2815 "Remove list identifies from the Subject header.
2816 The `gnus-list-identifiers' variable specifies what to do."
2818 (let ((inhibit-point-motion-hooks t)
2819 (regexp (if (consp gnus-list-identifiers)
2820 (mapconcat 'identity gnus-list-identifiers " *\\|")
2821 gnus-list-identifiers))
2822 (inhibit-read-only t))
2826 (article-narrow-to-head)
2827 (goto-char (point-min))
2828 (while (re-search-forward
2829 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2831 (delete-region (match-beginning 2) (match-end 0))
2832 (beginning-of-line))
2833 (when (re-search-forward
2834 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2835 (delete-region (match-beginning 1) (match-end 1))))))))
2837 (defun article-hide-pem (&optional arg)
2838 "Toggle hiding of any PEM headers and signatures in the current article.
2839 If given a negative prefix, always show; if given a positive prefix,
2841 (interactive (gnus-article-hidden-arg))
2842 (unless (gnus-article-check-hidden-text 'pem arg)
2844 (let ((inhibit-read-only t) end)
2845 (goto-char (point-min))
2846 ;; Hide the horrendously ugly "header".
2847 (when (and (search-forward
2848 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2850 (setq end (1+ (match-beginning 0))))
2851 (gnus-add-wash-type 'pem)
2852 (gnus-article-hide-text-type
2854 (if (search-forward "\n\n" nil t)
2858 ;; Hide the trailer as well
2859 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2861 (gnus-article-hide-text-type
2862 (match-beginning 0) (match-end 0) 'pem)))))))
2864 (defun article-strip-banner ()
2865 "Strip the banners specified by the `banner' group parameter and by
2866 `gnus-article-address-banner-alist'."
2870 (let ((inhibit-point-motion-hooks t))
2871 (when (gnus-parameter-banner gnus-newsgroup-name)
2872 (article-really-strip-banner
2873 (gnus-parameter-banner gnus-newsgroup-name)))
2874 (when gnus-article-address-banner-alist
2875 ;; Note that the From header is decoded here, so it is
2876 ;; required that the *-extract-address-components function
2877 ;; supports non-ASCII text.
2878 (let ((from (save-restriction
2880 (article-narrow-to-head)
2881 (mail-fetch-field "from"))))
2884 (cadr (funcall gnus-extract-address-components
2887 (dolist (pair gnus-article-address-banner-alist)
2888 (when (string-match (car pair) from)
2890 (article-really-strip-banner (cdr pair)))))))))))))
2892 (defun article-really-strip-banner (banner)
2893 "Strip the banner specified by the argument."
2896 (let ((inhibit-point-motion-hooks t)
2897 (gnus-signature-limit nil)
2898 (inhibit-read-only t))
2901 ((eq banner 'signature)
2902 (when (gnus-article-narrow-to-signature)
2905 (delete-region (point) (point-max))))
2907 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2908 (while (re-search-forward banner nil t)
2909 (delete-region (match-beginning 0) (match-end 0)))))
2911 (while (re-search-forward banner nil t)
2912 (delete-region (match-beginning 0) (match-end 0)))))))))
2914 (defun article-babel ()
2915 "Translate article using an online translation service."
2918 (gnus-with-article-buffer
2919 (when (article-goto-body)
2920 (let* ((start (point))
2922 (orig (buffer-substring start end))
2923 (trans (babel-as-string orig)))
2925 (narrow-to-region start end)
2926 (delete-region start end)
2929 (defun article-hide-signature (&optional arg)
2930 "Hide the signature in the current article.
2931 If given a negative prefix, always show; if given a positive prefix,
2933 (interactive (gnus-article-hidden-arg))
2939 (article-goto-body))
2940 (goto-char (point-min)))
2941 (unless (gnus-article-check-hidden-text 'signature arg)
2942 (let ((inhibit-read-only t)
2944 (while (setq button (text-property-any button (point-max)
2946 'gnus-signature-toggle))
2947 (setq button (text-property-not-all button (point-max)
2949 'gnus-signature-toggle))
2950 (when (and button (not (eobp)))
2951 (gnus-article-hide-text-type
2953 (next-single-property-change (1+ button) 'mime-view-entity
2956 (gnus-set-mode-line 'article))
2958 (defun article-strip-headers-in-body ()
2959 "Strip offensive headers from bodies."
2963 (let ((case-fold-search t))
2964 (when (looking-at "x-no-archive:")
2965 (gnus-delete-line)))))
2967 (defun article-strip-leading-blank-lines ()
2968 "Remove all blank lines from the beginning of the article."
2971 (let ((inhibit-point-motion-hooks t)
2972 (inhibit-read-only t))
2973 (when (article-goto-body)
2974 (while (and (not (eobp))
2975 (looking-at "[ \t]*$"))
2976 (gnus-delete-line))))))
2978 (defun article-narrow-to-head ()
2979 "Narrow the buffer to the head of the message.
2980 Point is left at the beginning of the narrowed-to region."
2982 (goto-char (point-min))
2983 (if (search-forward "\n\n" nil 1)
2986 (goto-char (point-min)))
2988 (defun article-goto-body ()
2989 "Place point at the start of the body."
2990 (goto-char (point-min))
2992 ;; This variable is only bound when dealing with separate
2994 (article-goto-body-goes-to-point-min-p
2996 ((search-forward "\n\n" nil t)
2999 (goto-char (point-max))
3002 (defun article-strip-multiple-blank-lines ()
3003 "Replace consecutive blank lines with one empty line."
3006 (let ((inhibit-point-motion-hooks t)
3007 (inhibit-read-only t))
3008 ;; First make all blank lines empty.
3010 (while (re-search-forward "^[ \t]+$" nil t)
3011 (unless (gnus-annotation-in-region-p
3012 (match-beginning 0) (match-end 0))
3013 (replace-match "" nil t)))
3014 ;; Then replace multiple empty lines with a single empty line.
3016 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
3017 (unless (gnus-annotation-in-region-p
3018 (match-beginning 0) (match-end 0))
3019 (delete-region (match-beginning 1) (match-end 1)))))))
3021 (defun article-strip-leading-space ()
3022 "Remove all white space from the beginning of the lines in the article."
3025 (let ((inhibit-point-motion-hooks t)
3026 (inhibit-read-only t))
3028 (while (re-search-forward "^[ \t]+" nil t)
3029 (replace-match "" t t)))))
3031 (defun article-strip-trailing-space ()
3032 "Remove all white space from the end of the lines in the article."
3035 (let ((inhibit-point-motion-hooks t)
3036 (inhibit-read-only t))
3038 (while (re-search-forward "[ \t]+$" nil t)
3039 (replace-match "" t t)))))
3041 (defun article-strip-blank-lines ()
3042 "Strip leading, trailing and multiple blank lines."
3044 (article-strip-leading-blank-lines)
3045 (article-remove-trailing-blank-lines)
3046 (article-strip-multiple-blank-lines))
3048 (defun article-strip-all-blank-lines ()
3049 "Strip all blank lines."
3052 (let ((inhibit-point-motion-hooks t)
3053 (inhibit-read-only t))
3055 (while (re-search-forward "^[ \t]*\n" nil t)
3056 (replace-match "" t t)))))
3058 (defun gnus-article-narrow-to-signature ()
3059 "Narrow to the signature; return t if a signature is found, else nil."
3060 (let ((inhibit-point-motion-hooks t))
3061 (when (gnus-article-search-signature)
3063 ;; Check whether we have some limits to what we consider
3064 ;; to be a signature.
3065 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
3066 (list gnus-signature-limit)))
3068 (while (setq limit (pop limits))
3069 (if (or (and (integerp limit)
3070 (< (- (point-max) (point)) limit))
3072 (< (count-lines (point) (point-max)) limit))
3073 (and (functionp limit)
3075 (and (stringp limit)
3076 (not (re-search-forward limit nil t))))
3077 () ; This limit did not succeed.
3081 (narrow-to-region (point) (point-max))
3084 (defun gnus-article-search-signature ()
3085 "Search the current buffer for the signature separator.
3086 Put point at the beginning of the signature separator."
3087 (let ((cur (point)))
3088 (goto-char (point-max))
3089 (if (if (stringp gnus-signature-separator)
3090 (re-search-backward gnus-signature-separator nil t)
3091 (let ((seps gnus-signature-separator))
3093 (not (re-search-backward (car seps) nil t)))
3100 (defun gnus-article-hidden-arg ()
3101 "Return the current prefix arg as a number, or 0 if no prefix."
3102 (list (if current-prefix-arg
3103 (prefix-numeric-value current-prefix-arg)
3106 (defun gnus-article-check-hidden-text (type arg)
3107 "Return nil if hiding is necessary.
3108 Arg can be nil or a number. nil and positive means hide, negative
3109 means show, 0 means toggle."
3112 (let ((hide (gnus-article-hidden-text-p type)))
3118 (gnus-article-show-hidden-text type)
3121 (if (eq hide 'hidden)
3123 (gnus-article-show-hidden-text type)
3127 (defun gnus-article-hidden-text-p (type)
3128 "Say whether the current buffer contains hidden text of type TYPE."
3129 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
3131 (not (get-text-property pos 'invisible))
3132 (not (get-text-property pos 'dummy-invisible)))
3134 (text-property-any (1+ pos) (point-max) 'article-type type)))
3139 (defun gnus-article-show-hidden-text (type &optional dummy)
3140 "Show all hidden text of type TYPE.
3141 Originally it is hide instead of DUMMY."
3142 (let ((inhibit-read-only t)
3143 (inhibit-point-motion-hooks t))
3144 (gnus-remove-text-properties-when
3146 (point-min) (point-max)
3147 (cons 'article-type (cons type
3148 gnus-hidden-properties)))
3149 (gnus-delete-wash-type type)))
3151 (defconst article-time-units
3152 `((year . ,(* 365.25 24 60 60))
3153 (week . ,(* 7 24 60 60))
3154 (day . ,(* 24 60 60))
3158 "Mapping from time units to seconds.")
3160 (defun gnus-article-forward-header ()
3161 "Move point to the start of the next header.
3162 If the current header is a continuation header, this can be several
3167 (if (looking-at "[ \t]+[^ \t]")
3171 (defun article-date-ut (&optional type highlight)
3172 "Convert DATE date to universal time in the current article.
3173 If TYPE is `local', convert to local time; if it is `lapsed', output
3174 how much time has lapsed since DATE. For `lapsed', the value of
3175 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
3176 should replace the \"Date:\" one, or should be added below it."
3177 (interactive (list 'ut t))
3178 (let* ((tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
3179 (date-regexp (cond ((not gnus-article-date-lapsed-new-header)
3183 (article-lapsed-timer
3187 (case-fold-search t)
3188 (inhibit-read-only t)
3189 (inhibit-point-motion-hooks t)
3190 pos date bface eface)
3194 (goto-char (point-min))
3195 (while (or (setq date (get-text-property (setq pos (point))
3197 (when (setq pos (next-single-property-change
3198 (point) 'original-date))
3199 (setq date (get-text-property pos 'original-date))
3201 (narrow-to-region pos (or (text-property-any pos (point-max)
3204 (goto-char (point-min))
3205 (when (re-search-forward tdate-regexp nil t)
3206 (setq bface (get-text-property (point-at-bol) 'face)
3207 eface (get-text-property (1- (point-at-eol)) 'face)))
3208 (goto-char (point-min))
3210 ;; Delete any old Date headers.
3211 (while (re-search-forward date-regexp nil t)
3213 (delete-region (point-at-bol) (progn
3214 (gnus-article-forward-header)
3216 (delete-region (point-at-bol) (progn
3217 (gnus-article-forward-header)
3220 (setq pos (point))))
3221 (when (and (not pos)
3222 (re-search-forward tdate-regexp nil t))
3224 (gnus-goto-char pos)
3225 (insert (article-make-date-line date (or type 'ut)))
3231 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
3232 (put-text-property (match-beginning 1) (1+ (match-end 1))
3234 (put-text-property (match-beginning 2) (match-end 2)
3236 (put-text-property (point-min) (1- (point-max)) 'original-date date)
3237 (goto-char (point-max))
3240 (defun article-make-date-line (date type)
3241 "Return a DATE line of TYPE."
3242 (unless (memq type '(local ut original user iso8601 lapsed english))
3243 (error "Unknown conversion type: %s" type))
3245 (let ((time (date-to-time date)))
3247 ;; Convert to the local timezone.
3249 (concat "Date: " (message-make-date time)))
3250 ;; Convert to Universal Time.
3255 (let* ((e (parse-time-string date))
3256 (tm (apply 'encode-time e))
3258 (ls (- (cadr tm) (car (current-time-zone time)))))
3259 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
3260 ((> ls 65535) (list (1+ ms) (- ls 65536)))
3264 ;; Get the original date from the article.
3265 ((eq type 'original)
3266 (concat "Date: " (if (string-match "\n+$" date)
3267 (substring date 0 (match-beginning 0))
3269 ;; Let the user define the format.
3271 (let ((format (or (condition-case nil
3272 (with-current-buffer gnus-summary-buffer
3273 gnus-article-time-format)
3275 gnus-article-time-format)))
3276 (if (functionp format)
3277 (funcall format time)
3278 (concat "Date: " (format-time-string format time)))))
3281 (let ((tz (car (current-time-zone time))))
3284 (format-time-string "%Y%m%dT%H%M%S" time)
3285 (format "%s%02d%02d"
3286 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
3287 (/ (% (abs tz) 3600) 60)))))
3288 ;; Do an X-Sent lapsed format.
3290 ;; If the date is seriously mangled, the timezone functions are
3291 ;; liable to bug out, so we ignore all errors.
3292 (let* ((now (current-time))
3293 (real-time (subtract-time now time))
3294 (real-sec (and real-time
3295 (+ (* (float (car real-time)) 65536)
3297 (sec (and real-time (abs real-sec)))
3307 ;; This is a bit convoluted, but basically we go
3308 ;; through the time units for years, weeks, etc,
3309 ;; and divide things to see whether that results
3310 ;; in positive answers.
3313 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
3314 ;; The (remaining) seconds are too few to
3315 ;; be divided into this time unit.
3317 ;; It's big enough, so we output it.
3318 (setq sec (- sec (* num (cdr unit))))
3320 (concat (if prev ", " "") (int-to-string
3322 " " (symbol-name (car unit))
3323 (if (> num 1) "s" ""))
3325 article-time-units "")
3326 ;; If dates are odd, then it might appear like the
3327 ;; article was sent in the future.
3330 " in the future"))))))
3331 ;; Display the date in proper English
3333 (let ((dtime (decode-time time)))
3336 (number-to-string (nth 3 dtime))
3337 (let ((digit (% (nth 3 dtime) 10)))
3339 ((memq (nth 3 dtime) '(11 12 13)) "th")
3345 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3347 (number-to-string (nth 5 dtime))
3349 (format "%02d" (nth 2 dtime))
3351 (format "%02d" (nth 1 dtime)))))))
3353 (format "Date: %s (from T-gnus)" date))))
3355 (defun article-date-local (&optional highlight)
3356 "Convert the current article date to the local timezone."
3357 (interactive (list t))
3358 (article-date-ut 'local highlight))
3360 (defun article-date-english (&optional highlight)
3361 "Convert the current article date to something that is proper English."
3362 (interactive (list t))
3363 (article-date-ut 'english highlight))
3365 (defun article-date-original (&optional highlight)
3366 "Convert the current article date to what it was originally.
3367 This is only useful if you have used some other date conversion
3368 function and want to see what the date was before converting."
3369 (interactive (list t))
3370 (article-date-ut 'original highlight))
3372 (defun article-date-lapsed (&optional highlight)
3373 "Convert the current article date to time lapsed since it was sent."
3374 (interactive (list t))
3375 (article-date-ut 'lapsed highlight))
3377 (defun article-update-date-lapsed ()
3378 "Function to be run from a timer to update the lapsed time line."
3380 (let (deactivate-mark)
3385 (set-buffer (window-buffer w))
3386 (when (or (and (eq major-mode 'mime-view-mode)
3387 (eq (mime-preview-original-major-mode)
3388 'gnus-original-article-mode))
3389 (eq major-mode 'gnus-article-mode))
3390 (let ((mark (point-marker)))
3391 (goto-char (point-min))
3392 (when (re-search-forward "^X-Sent:" nil t)
3393 (article-date-lapsed t))
3394 (goto-char (marker-position mark))
3395 (move-marker mark nil))))
3398 (defun gnus-start-date-timer (&optional n)
3399 "Start a timer to update the X-Sent header in the article buffers.
3400 The numerical prefix says how frequently (in seconds) the function
3405 (gnus-stop-date-timer)
3406 (setq article-lapsed-timer
3407 (run-at-time 1 n 'article-update-date-lapsed)))
3409 (defun gnus-stop-date-timer ()
3410 "Stop the X-Sent timer."
3412 (when article-lapsed-timer
3413 (nnheader-cancel-timer article-lapsed-timer)
3414 (setq article-lapsed-timer nil)))
3416 (defun article-date-user (&optional highlight)
3417 "Convert the current article date to the user-defined format.
3418 This format is defined by the `gnus-article-time-format' variable."
3419 (interactive (list t))
3420 (article-date-ut 'user highlight))
3422 (defun article-date-iso8601 (&optional highlight)
3423 "Convert the current article date to ISO8601."
3424 (interactive (list t))
3425 (article-date-ut 'iso8601 highlight))
3427 (defmacro gnus-article-save-original-date (&rest forms)
3428 "Save the original date as a text property and evaluate FORMS."
3429 `(let* ((case-fold-search t)
3431 (goto-char (point-min))
3432 (when (and (re-search-forward "^date:[\t\n ]+" nil t)
3435 (date (when (and start
3436 (re-search-forward "[\t ]*\n\\(?:[^\t ]\\|\\'\\)"
3438 (buffer-substring-no-properties start
3439 (match-beginning 0)))))
3440 (goto-char (point-max))
3441 (skip-chars-backward "\n")
3442 (put-text-property (point-min) (point) 'original-date date)
3444 (goto-char (point-max))
3445 (skip-chars-backward "\n")
3446 (put-text-property (point-min) (point) 'original-date date)))
3448 ;; (defun article-show-all ()
3449 ;; "Show all hidden text in the article buffer."
3453 ;; (let ((inhibit-read-only t))
3454 ;; (gnus-article-unhide-text (point-min) (point-max))
3455 ;; (gnus-remove-text-with-property 'gnus-prev)
3456 ;; (gnus-remove-text-with-property 'gnus-next))))
3458 (defun article-show-all-headers ()
3459 "Show all hidden headers in the article buffer."
3464 (article-narrow-to-head)
3465 (let ((inhibit-read-only t))
3466 (gnus-article-unhide-text (point-min) (point-max))))))
3468 (defun article-remove-leading-whitespace ()
3469 "Remove excessive whitespace from all headers."
3473 (let ((inhibit-read-only t))
3474 (article-narrow-to-head)
3475 (goto-char (point-min))
3476 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3477 (delete-region (match-beginning 1) (match-end 1)))))))
3479 (defun article-emphasize (&optional arg)
3480 "Emphasize text according to `gnus-emphasis-alist'."
3481 (interactive (gnus-article-hidden-arg))
3482 (unless (gnus-article-check-hidden-text 'emphasis arg)
3486 (with-current-buffer gnus-summary-buffer
3487 gnus-article-emphasis-alist)
3489 gnus-emphasis-alist))
3490 (inhibit-read-only t)
3491 (props (append '(article-type emphasis)
3492 gnus-hidden-properties))
3493 regexp elem beg invisible visible face)
3496 (while (setq elem (pop alist))
3498 (setq regexp (car elem)
3499 invisible (nth 1 elem)
3500 visible (nth 2 elem)
3502 (while (re-search-forward regexp nil t)
3503 (when (and (match-beginning visible) (match-beginning invisible))
3504 (gnus-article-hide-text
3505 (match-beginning invisible) (match-end invisible) props)
3506 (gnus-article-unhide-text-type
3507 (match-beginning visible) (match-end visible) 'emphasis)
3508 (gnus-put-overlay-excluding-newlines
3509 (match-beginning visible) (match-end visible) 'face face)
3510 (gnus-add-wash-type 'emphasis)
3511 (goto-char (match-end invisible)))))))))
3513 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3514 "Setup newsgroup emphasis alist."
3515 (unless gnus-article-emphasis-alist
3516 (let ((name (and gnus-newsgroup-name
3517 (gnus-group-real-name gnus-newsgroup-name))))
3518 (make-local-variable 'gnus-article-emphasis-alist)
3519 (setq gnus-article-emphasis-alist
3521 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3522 (while (setq elem (pop alist))
3523 (when (and name (string-match (car elem) name))
3525 highlight (copy-sequence (cdr elem)))))
3527 (copy-sequence highlight-words)
3528 (if gnus-newsgroup-name
3529 (copy-sequence (gnus-group-find-parameter
3530 gnus-newsgroup-name 'highlight-words t)))
3531 gnus-emphasis-alist)))))
3534 (defvar gnus-summary-article-menu)
3535 (defvar gnus-summary-post-menu))
3537 ;;; Saving functions.
3539 (defun gnus-article-save (save-buffer file &optional num)
3540 "Save the currently selected article."
3541 (unless gnus-save-all-headers
3542 ;; Remove headers according to `gnus-saved-headers'.
3543 (let ((gnus-visible-headers
3544 (or gnus-saved-headers gnus-visible-headers))
3545 (gnus-article-buffer save-buffer))
3547 (set-buffer save-buffer)
3548 (article-hide-headers 1 t))))
3549 (save-window-excursion
3550 (if (not gnus-default-article-saver)
3551 (error "No default saver is defined")
3552 ;; !!! Magic! The saving functions all save
3553 ;; `gnus-save-article-buffer' (or so they think), but we
3554 ;; bind that variable to our save-buffer.
3555 (set-buffer gnus-article-buffer)
3556 (let* ((gnus-save-article-buffer save-buffer)
3559 ((not gnus-prompt-before-saving) 'default)
3560 ((eq gnus-prompt-before-saving 'always) nil)
3562 (gnus-number-of-articles-to-be-saved
3563 (when (eq gnus-prompt-before-saving t)
3565 (set-buffer gnus-article-current-summary)
3566 (funcall gnus-default-article-saver filename)))))
3568 (defun gnus-read-save-file-name (prompt &optional filename
3569 function group headers variable)
3571 (funcall function group headers (symbol-value variable)))
3576 ((eq filename 'default)
3582 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3585 (if (and gnus-number-of-articles-to-be-saved
3586 (> gnus-number-of-articles-to-be-saved 1))
3587 (format "these %d articles"
3588 gnus-number-of-articles-to-be-saved)
3591 ;; Let the split methods have their say.
3593 ;; No split name was found.
3596 (concat prompt " (default "
3597 (file-name-nondirectory default-name) "): ")
3598 (file-name-directory default-name)
3600 ;; A single group name is returned.
3601 ((stringp split-name)
3603 (funcall function split-name headers
3604 (symbol-value variable)))
3606 (concat prompt " (default "
3607 (file-name-nondirectory default-name) "): ")
3608 (file-name-directory default-name)
3610 ;; A single split name was found
3611 ((= 1 (length split-name))
3612 (let* ((name (expand-file-name
3614 gnus-article-save-directory))
3615 (dir (cond ((file-directory-p name)
3616 (file-name-as-directory name))
3617 ((file-exists-p name) name)
3618 (t gnus-article-save-directory))))
3620 (concat prompt " (default " name "): ")
3622 ;; A list of splits was found.
3624 (setq split-name (nreverse split-name))
3626 (let ((file-name-history
3627 (nconc split-name file-name-history)))
3631 (concat prompt " (`M-p' for defaults): ")
3632 gnus-article-save-directory
3634 gnus-article-save-directory)))
3635 (car (push result file-name-history)))))))
3636 ;; Create the directory.
3637 (gnus-make-directory (file-name-directory file))
3638 ;; If we have read a directory, we append the default file name.
3639 (when (file-directory-p file)
3640 (setq file (expand-file-name (file-name-nondirectory
3642 (file-name-as-directory file))))
3643 ;; Possibly translate some characters.
3644 (nnheader-translate-file-chars file))))))
3645 (gnus-make-directory (file-name-directory result))
3646 (set variable result)))
3648 (defun gnus-article-archive-name (group)
3649 "Return the first instance of an \"Archive-name\" in the current buffer."
3650 (let ((case-fold-search t))
3651 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3652 (nnheader-concat gnus-article-save-directory
3653 (match-string 1)))))
3655 (defun gnus-article-nndoc-name (group)
3656 "If GROUP is an nndoc group, return the name of the parent group."
3657 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3658 (gnus-group-get-parameter group 'save-article-group)))
3660 (defun gnus-summary-save-in-rmail (&optional filename)
3661 "Append this article to Rmail file.
3662 Optional argument FILENAME specifies file name.
3663 Directory to save to is default to `gnus-article-save-directory'."
3664 (setq filename (gnus-read-save-file-name
3665 "Save %s in rmail file" filename
3666 gnus-rmail-save-name gnus-newsgroup-name
3667 gnus-current-headers 'gnus-newsgroup-last-rmail))
3668 (gnus-eval-in-buffer-window gnus-save-article-buffer
3672 (gnus-output-to-rmail filename))))
3675 (defun gnus-summary-save-in-mail (&optional filename)
3676 "Append this article to Unix mail file.
3677 Optional argument FILENAME specifies file name.
3678 Directory to save to is default to `gnus-article-save-directory'."
3679 (setq filename (gnus-read-save-file-name
3680 "Save %s in Unix mail file" filename
3681 gnus-mail-save-name gnus-newsgroup-name
3682 gnus-current-headers 'gnus-newsgroup-last-mail))
3683 (gnus-eval-in-buffer-window gnus-save-article-buffer
3687 (if (and (file-readable-p filename)
3688 (file-regular-p filename)
3689 (mail-file-babyl-p filename))
3690 (rmail-output-to-rmail-file filename t)
3691 (gnus-output-to-mail filename)))))
3694 (defun gnus-summary-save-in-file (&optional filename overwrite)
3695 "Append this article to file.
3696 Optional argument FILENAME specifies file name.
3697 Directory to save to is default to `gnus-article-save-directory'."
3698 (setq filename (gnus-read-save-file-name
3699 "Save %s in file" filename
3700 gnus-file-save-name gnus-newsgroup-name
3701 gnus-current-headers 'gnus-newsgroup-last-file))
3702 (gnus-eval-in-buffer-window gnus-save-article-buffer
3706 (when (and overwrite
3707 (file-exists-p filename))
3708 (delete-file filename))
3709 (gnus-output-to-file filename))))
3712 (defun gnus-summary-write-to-file (&optional filename)
3713 "Write this article to a file, overwriting it if the file exists.
3714 Optional argument FILENAME specifies file name.
3715 The directory to save in defaults to `gnus-article-save-directory'."
3716 (gnus-summary-save-in-file nil t))
3718 (defun gnus-summary-save-body-in-file (&optional filename)
3719 "Append this article body to a file.
3720 Optional argument FILENAME specifies file name.
3721 The directory to save in defaults to `gnus-article-save-directory'."
3722 (setq filename (gnus-read-save-file-name
3723 "Save %s body in file" filename
3724 gnus-file-save-name gnus-newsgroup-name
3725 gnus-current-headers 'gnus-newsgroup-last-file))
3726 (gnus-eval-in-buffer-window gnus-save-article-buffer
3730 (when (article-goto-body)
3731 (narrow-to-region (point) (point-max)))
3732 (gnus-output-to-file filename))))
3735 (defun gnus-summary-save-in-pipe (&optional command)
3736 "Pipe this article to subprocess."
3738 (cond ((and (eq command 'default)
3739 gnus-last-shell-command)
3740 gnus-last-shell-command)
3745 "Shell command on %s: "
3746 (if (and gnus-number-of-articles-to-be-saved
3747 (> gnus-number-of-articles-to-be-saved 1))
3748 (format "these %d articles"
3749 gnus-number-of-articles-to-be-saved)
3751 gnus-last-shell-command))))
3752 (when (string-equal command "")
3753 (if gnus-last-shell-command
3754 (setq command gnus-last-shell-command)
3755 (error "A command is required")))
3756 (gnus-eval-in-buffer-window gnus-article-buffer
3759 (shell-command-on-region (point-min) (point-max) command nil)))
3760 (setq gnus-last-shell-command command))
3762 (defun gnus-summary-pipe-to-muttprint (&optional command)
3763 "Pipe this article to muttprint."
3764 (setq command (read-string
3765 "Print using command: " gnus-summary-muttprint-program
3766 nil gnus-summary-muttprint-program))
3767 (gnus-summary-save-in-pipe command))
3769 ;;; Article file names when saving.
3771 (defun gnus-capitalize-newsgroup (newsgroup)
3772 "Capitalize NEWSGROUP name."
3773 (when (not (zerop (length newsgroup)))
3774 (concat (char-to-string (upcase (aref newsgroup 0)))
3775 (substring newsgroup 1))))
3777 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3778 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3779 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3780 Otherwise, it is like ~/News/news/group/num."
3783 (concat (if (gnus-use-long-file-name 'not-save)
3784 (gnus-capitalize-newsgroup newsgroup)
3785 (gnus-newsgroup-directory-form newsgroup))
3786 "/" (int-to-string (mail-header-number headers)))
3787 gnus-article-save-directory)))
3789 (string-equal (file-name-directory default)
3790 (file-name-directory last-file))
3791 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3793 (or last-file default))))
3795 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3796 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3797 If variable `gnus-use-long-file-name' is non-nil, it is
3798 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3801 (concat (if (gnus-use-long-file-name 'not-save)
3803 (gnus-newsgroup-directory-form newsgroup))
3804 "/" (int-to-string (mail-header-number headers)))
3805 gnus-article-save-directory)))
3807 (string-equal (file-name-directory default)
3808 (file-name-directory last-file))
3809 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3811 (or last-file default))))
3813 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3814 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3815 If variable `gnus-use-long-file-name' is non-nil, it is
3816 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3819 (if (gnus-use-long-file-name 'not-save)
3822 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3824 gnus-article-save-directory)))
3826 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3827 "Generate file name from sender."
3828 (let ((from (mail-header-from headers)))
3830 (if (and from (string-match "\\([^ <]+\\)@" from))
3831 (match-string 1 from)
3833 gnus-article-save-directory)))
3835 (defun article-verify-x-pgp-sig ()
3838 (if (gnus-buffer-live-p gnus-original-article-buffer)
3839 (let ((sig (with-current-buffer gnus-original-article-buffer
3840 (gnus-fetch-field "X-PGP-Sig")))
3844 (mml2015-clear-verify-function))
3846 (insert-buffer-substring gnus-original-article-buffer)
3847 (setq items (split-string sig))
3848 (message-narrow-to-head)
3849 (let ((inhibit-point-motion-hooks t)
3850 (case-fold-search t))
3851 ;; Don't verify multiple headers.
3852 (setq headers (mapconcat (lambda (header)
3854 (mail-fetch-field header)
3856 (split-string (nth 1 items) ",") "")))
3857 (delete-region (point-min) (point-max))
3858 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3859 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3864 (if (looking-at "^-")
3867 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3868 (insert "Version: " (car items) "\n\n")
3869 (insert (mapconcat 'identity (cddr items) "\n"))
3870 (insert "\n-----END PGP SIGNATURE-----\n")
3871 (let ((mm-security-handle (list (format "multipart/signed"))))
3872 (mml2015-clean-buffer)
3873 (let ((coding-system-for-write (or gnus-newsgroup-charset
3875 (funcall (mml2015-clear-verify-function)))
3877 (or (mm-handle-multipart-ctl-parameter
3878 mm-security-handle 'gnus-details)
3879 (mm-handle-multipart-ctl-parameter
3880 mm-security-handle 'gnus-info)))))
3882 (let ((inhibit-read-only t) bface eface)
3884 (message-narrow-to-head)
3885 (goto-char (point-max))
3887 (setq bface (get-text-property (point-at-bol) 'face)
3888 eface (get-text-property (1- (point-at-eol)) 'face))
3889 (message-remove-header "X-Gnus-PGP-Verify")
3890 (if (re-search-forward "^X-PGP-Sig:" nil t)
3892 (goto-char (point-max)))
3893 (narrow-to-region (point) (point))
3894 (insert "X-Gnus-PGP-Verify: " info "\n")
3895 (goto-char (point-min))
3898 (if (not (looking-at "^[ \t]"))
3902 (goto-char (point-min))
3903 (when (looking-at "\\([^:]+\\): *")
3904 (put-text-property (match-beginning 1) (1+ (match-end 1))
3906 (put-text-property (match-end 0) (point-max)
3907 'face eface)))))))))
3909 (defun article-verify-cancel-lock ()
3910 "Verify Cancel-Lock header."
3912 (if (gnus-buffer-live-p gnus-original-article-buffer)
3913 (canlock-verify gnus-original-article-buffer)))
3915 (defun article-monafy ()
3916 "Display body part with mona font."
3918 (unless (if (featurep 'xemacs)
3919 (find-face 'gnus-mona-face)
3920 (facep 'gnus-mona-face))
3921 (require 'navi2ch-mona)
3922 (set-face-font (make-face 'gnus-mona-face) navi2ch-mona-font))
3924 (let ((inhibit-read-only t))
3927 (gnus-make-overlay (point) (point-max))
3928 'face 'gnus-mona-face))))
3935 (setq afunc (car func)
3938 gfunc (intern (format "gnus-%s" func))))
3940 (when (fboundp afunc)
3941 `(lambda (&optional interactive &rest args)
3942 ,(documentation afunc t)
3943 (interactive (list t))
3945 (set-buffer gnus-article-buffer)
3947 (call-interactively ',afunc)
3948 (apply ',afunc args))))))))
3949 '(article-hide-headers
3950 article-verify-x-pgp-sig
3951 article-verify-cancel-lock
3953 article-hide-boring-headers
3954 article-treat-overstrike
3955 article-treat-ansi-sequences
3956 article-fill-long-lines
3957 article-capitalize-sentences
3959 article-remove-leading-whitespace
3960 article-display-x-face
3961 article-display-face
3962 article-de-quoted-unreadable
3963 article-de-base64-unreadable
3966 article-unsplit-urls
3967 article-hide-list-identifiers
3968 article-strip-banner
3971 article-hide-signature
3972 article-strip-headers-in-body
3973 article-remove-trailing-blank-lines
3974 article-strip-leading-blank-lines
3975 article-strip-multiple-blank-lines
3976 article-strip-leading-space
3977 article-strip-trailing-space
3978 article-strip-blank-lines
3979 article-strip-all-blank-lines
3981 article-date-english
3982 article-date-iso8601
3983 article-date-original
3985 article-decode-mime-words
3986 article-decode-charset
3987 article-decode-encoded-words
3991 article-treat-dumbquotes
3992 article-normalize-headers
3993 (article-show-all-headers . gnus-article-show-all-headers)
3994 ;; (article-show-all . gnus-article-show-all)
3998 ;;; Gnus article mode
4001 (put 'gnus-article-mode 'mode-class 'special)
4003 (gnus-define-keys gnus-article-mode-map
4004 " " gnus-article-goto-next-page
4005 "\177" gnus-article-goto-prev-page
4006 [delete] gnus-article-goto-prev-page
4007 [backspace] gnus-article-goto-prev-page
4008 "\C-c^" gnus-article-refer-article
4009 "h" gnus-article-show-summary
4010 "s" gnus-article-show-summary
4011 "\C-c\C-m" gnus-article-mail
4012 "?" gnus-article-describe-briefly
4013 "e" gnus-summary-edit-article
4014 "<" beginning-of-buffer
4016 "\C-c\C-i" gnus-info-find-node
4018 "R" gnus-article-reply-with-original
4019 "F" gnus-article-followup-with-original
4020 "\C-hk" gnus-article-describe-key
4021 "\C-hc" gnus-article-describe-key-briefly
4023 "\C-d" gnus-article-read-summary-keys
4024 "\M-*" gnus-article-read-summary-keys
4025 "\M-#" gnus-article-read-summary-keys
4026 "\M-^" gnus-article-read-summary-keys
4027 "\M-g" gnus-article-read-summary-keys)
4029 ;; Define almost undefined keys to `gnus-article-read-summary-keys'.
4033 (push (char-to-string key) keys)
4035 (dolist (elem (accessible-keymaps gnus-summary-mode-map))
4036 (setq key (car elem))
4037 (when (and (> (length key) 0)
4038 (not (eq 'menu-bar (aref key 0)))
4039 (symbolp (lookup-key gnus-summary-mode-map key)))
4042 (unless (lookup-key gnus-article-mode-map key)
4043 (define-key gnus-article-mode-map key 'gnus-article-read-summary-keys))))
4045 (defun gnus-article-make-menu-bar ()
4046 (unless (boundp 'gnus-article-commands-menu)
4047 (gnus-summary-make-menu-bar))
4048 (gnus-turn-off-edit-menu 'article)
4049 (unless (boundp 'gnus-article-article-menu)
4051 gnus-article-article-menu gnus-article-mode-map ""
4053 ["Scroll forwards" gnus-article-goto-next-page t]
4054 ["Scroll backwards" gnus-article-goto-prev-page t]
4055 ["Show summary" gnus-article-show-summary t]
4056 ["Fetch Message-ID at point" gnus-article-refer-article t]
4057 ["Mail to address at point" gnus-article-mail t]
4058 ["Send a bug report" gnus-bug t]))
4061 gnus-article-treatment-menu gnus-article-mode-map ""
4062 ;; Fixme: this should use :active (and maybe :visible).
4064 ["Hide headers" gnus-article-hide-headers t]
4065 ["Hide signature" gnus-article-hide-signature t]
4066 ["Hide citation" gnus-article-hide-citation t]
4067 ["Treat overstrike" gnus-article-treat-overstrike t]
4068 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
4069 ["Remove carriage return" gnus-article-remove-cr t]
4070 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
4071 ["Treat html" gnus-article-wash-html t]
4072 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
4073 ["Decode HZ" gnus-article-decode-HZ t]))
4075 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
4077 ;; Note "Post" menu is defined in gnus-sum.el for consistency
4079 (gnus-run-hooks 'gnus-article-menu-hook)))
4081 (defun gnus-article-mode ()
4082 "Major mode for displaying an article.
4084 All normal editing commands are switched off.
4086 The following commands are available in addition to all summary mode
4088 \\<gnus-article-mode-map>
4089 \\[gnus-article-next-page]\t Scroll the article one page forwards
4090 \\[gnus-article-prev-page]\t Scroll the article one page backwards
4091 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
4092 \\[gnus-article-show-summary]\t Display the summary buffer
4093 \\[gnus-article-mail]\t Send a reply to the address near point
4094 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
4095 \\[gnus-info-find-node]\t Go to the Gnus info node"
4097 (kill-all-local-variables)
4098 (gnus-simplify-mode-line)
4099 (setq mode-name "Article")
4100 (setq major-mode 'gnus-article-mode)
4101 (make-local-variable 'minor-mode-alist)
4102 (unless (assq 'gnus-show-mime minor-mode-alist)
4103 (push (list 'gnus-show-mime " MIME") minor-mode-alist))
4104 (use-local-map gnus-article-mode-map)
4105 (when (gnus-visual-p 'article-menu 'menu)
4106 (gnus-article-make-menu-bar)
4107 (when gnus-summary-tool-bar-map
4108 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
4109 (gnus-update-format-specifications nil 'article-mode)
4110 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
4111 (set (make-local-variable 'gnus-page-broken) nil)
4112 (make-local-variable 'gnus-button-marker-list)
4113 (make-local-variable 'gnus-article-current-summary)
4114 (make-local-variable 'gnus-article-mime-handles)
4115 (make-local-variable 'gnus-article-decoded-p)
4116 (make-local-variable 'gnus-article-mime-handle-alist)
4117 (make-local-variable 'gnus-article-wash-types)
4118 (make-local-variable 'gnus-article-image-alist)
4119 (make-local-variable 'gnus-article-charset)
4120 (make-local-variable 'gnus-article-ignored-charsets)
4121 ;; Prevent recent Emacsen from displaying non-break space as "\ ".
4122 (set (make-local-variable 'nobreak-char-display) nil)
4123 (gnus-set-default-directory)
4124 (buffer-disable-undo)
4125 (setq buffer-read-only t
4126 show-trailing-whitespace nil)
4127 (set-syntax-table gnus-article-mode-syntax-table)
4128 (gnus-run-mode-hooks 'gnus-article-mode-hook))
4130 (defun gnus-article-setup-buffer ()
4131 "Initialize the article buffer."
4132 (let* ((name (if gnus-single-article-buffer "*Article*"
4133 (concat "*Article " gnus-newsgroup-name "*")))
4135 (progn (string-match "\\*Article" name)
4136 (concat " *Original Article"
4137 (substring name (match-end 0))))))
4138 (setq gnus-article-buffer name)
4139 (setq gnus-original-article-buffer original)
4140 (setq gnus-article-mime-handle-alist nil)
4141 ;; This might be a variable local to the summary buffer.
4142 (unless gnus-single-article-buffer
4144 (set-buffer gnus-summary-buffer)
4145 (setq gnus-article-buffer name)
4146 (setq gnus-original-article-buffer original)
4147 (gnus-set-global-variables)))
4148 (gnus-article-setup-highlight-words)
4149 ;; Init original article buffer.
4151 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
4152 (set-buffer-multibyte t)
4153 (setq major-mode 'gnus-original-article-mode)
4154 (make-local-variable 'gnus-original-article))
4155 (if (and (get-buffer name)
4156 (with-current-buffer name
4157 (if gnus-article-edit-mode
4158 (if (y-or-n-p "Article mode edit in progress; discard? ")
4160 (set-buffer-modified-p nil)
4161 (gnus-kill-buffer name)
4164 (error "Action aborted"))
4168 (set (make-local-variable 'gnus-article-edit-mode) nil)
4169 (buffer-disable-undo)
4170 (setq buffer-read-only t)
4171 ;; This list just keeps growing if we don't reset it.
4172 (setq gnus-button-marker-list nil)
4173 (unless (eq major-mode 'gnus-article-mode)
4174 (gnus-article-mode))
4177 (set-buffer (gnus-get-buffer-create name))
4179 (make-local-variable 'gnus-summary-buffer)
4180 (gnus-summary-set-local-parameters gnus-newsgroup-name)
4181 (current-buffer)))))
4183 ;; Set article window start at LINE, where LINE is the number of lines
4184 ;; from the head of the article.
4185 (defun gnus-article-set-window-start (&optional line)
4187 (gnus-get-buffer-window gnus-article-buffer t)
4189 (set-buffer gnus-article-buffer)
4190 (goto-char (point-min))
4193 (gnus-message 6 "Moved to bookmark")
4194 (search-forward "\n\n" nil t)
4198 ;;; @@ article filters
4201 (defun gnus-article-display-mime-message ()
4202 "Article display method for MIME message."
4203 ;; called from `gnus-original-article-buffer'.
4204 (let (charset all-headers)
4205 (with-current-buffer gnus-summary-buffer
4206 (setq charset default-mime-charset
4207 all-headers gnus-have-all-headers))
4208 (make-local-variable 'default-mime-charset)
4209 (setq default-mime-charset charset)
4210 (with-current-buffer (get-buffer-create gnus-article-buffer)
4211 (make-local-variable 'default-mime-charset)
4212 (setq default-mime-charset charset))
4213 (mime-display-message mime-message-structure
4214 gnus-article-buffer nil gnus-article-mode-map)
4216 (gnus-article-hide-headers nil -1)))
4217 (run-hooks 'gnus-mime-article-prepare-hook))
4219 (defun gnus-article-display-traditional-message ()
4220 "Article display method for traditional message."
4221 (set-buffer gnus-article-buffer)
4222 (let ((inhibit-read-only t))
4224 (insert-buffer-substring gnus-original-article-buffer)))
4226 (defun gnus-article-make-full-mail-header (&optional number charset)
4227 "Create a new mail header structure in a raw article buffer."
4228 (unless (and number charset)
4229 (save-current-buffer
4230 (set-buffer gnus-summary-buffer)
4232 (setq number (or (cdr gnus-article-current) 0)))
4234 (setq charset (or default-mime-charset 'x-ctext)))))
4235 (goto-char (point-min))
4236 (let ((header-end (if (search-forward "\n\n" nil t)
4238 (goto-char (point-max))))
4239 (chars (- (point-max) (point)))
4240 (lines (count-lines (point) (point-max)))
4241 (default-mime-charset charset)
4243 (narrow-to-region (point-min) header-end)
4244 (setq xref (std11-fetch-field "xref"))
4246 (make-full-mail-header
4248 (std11-fetch-field "subject")
4249 (std11-fetch-field "from")
4250 (std11-fetch-field "date")
4251 (std11-fetch-field "message-id")
4252 (std11-fetch-field "references")
4255 (when xref (concat "Xref: " xref)))
4258 (defun gnus-article-prepare (article &optional all-headers header)
4259 "Prepare ARTICLE in article mode buffer.
4260 ARTICLE should either be an article number or a Message-ID.
4261 If ARTICLE is an id, HEADER should be the article headers.
4262 If ALL-HEADERS is non-nil, no headers are hidden."
4264 ;; Make sure we start in a summary buffer.
4265 (unless (eq major-mode 'gnus-summary-mode)
4266 (set-buffer gnus-summary-buffer))
4267 (setq gnus-summary-buffer (current-buffer))
4268 (let* ((gnus-article (if header (mail-header-number header) article))
4269 (summary-buffer (current-buffer))
4270 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
4271 (group gnus-newsgroup-name)
4274 (gnus-article-setup-buffer)
4275 (set-buffer gnus-article-buffer)
4276 ;; Deactivate active regions.
4277 (when (and (boundp 'transient-mark-mode)
4278 transient-mark-mode)
4279 (setq mark-active nil))
4280 (if (not (setq result (let ((inhibit-read-only t))
4281 (gnus-request-article-this-buffer
4283 ;; There is no such article.
4285 (when (and (numberp article)
4286 (not (memq article gnus-newsgroup-sparse)))
4287 (setq gnus-article-current
4288 (cons gnus-newsgroup-name article))
4289 (set-buffer gnus-summary-buffer)
4290 (setq gnus-current-article article)
4291 (if (and (memq article gnus-newsgroup-undownloaded)
4292 (not (gnus-online (gnus-find-method-for-group
4293 gnus-newsgroup-name))))
4295 (gnus-summary-set-agent-mark article)
4296 (message "Message marked for downloading"))
4297 (gnus-summary-mark-article article gnus-canceled-mark)
4298 (unless (memq article gnus-newsgroup-sparse)
4299 (gnus-error 1 "No such article (may have expired or been canceled)")))))
4300 (if (or (eq result 'pseudo)
4301 (eq result 'nneething))
4304 (set-buffer summary-buffer)
4305 (push article gnus-newsgroup-history)
4306 (setq gnus-last-article gnus-current-article
4307 gnus-current-article 0
4308 gnus-current-headers nil
4309 gnus-article-current nil)
4310 (if (eq result 'nneething)
4311 (gnus-configure-windows 'summary)
4312 (gnus-configure-windows 'article))
4313 (gnus-set-global-variables))
4314 (let ((gnus-article-mime-handle-alist-1
4315 gnus-article-mime-handle-alist))
4316 (gnus-set-mode-line 'article)))
4317 ;; The result from the `request' was an actual article -
4318 ;; or at least some text that is now displayed in the
4320 (when (and (numberp article)
4321 (not (eq article gnus-current-article)))
4322 ;; Seems like a new article has been selected.
4323 ;; `gnus-current-article' must be an article number.
4325 (set-buffer summary-buffer)
4326 (push article gnus-newsgroup-history)
4327 (setq gnus-last-article gnus-current-article
4328 gnus-current-article article
4329 gnus-current-headers
4330 (gnus-summary-article-header gnus-current-article)
4331 gnus-article-current
4332 (cons gnus-newsgroup-name gnus-current-article))
4333 (unless (vectorp gnus-current-headers)
4334 (setq gnus-current-headers nil))
4335 (gnus-summary-goto-subject gnus-current-article)
4336 (when (gnus-summary-show-thread)
4337 ;; If the summary buffer really was folded, the
4338 ;; previous goto may not actually have gone to
4339 ;; the right article, but the thread root instead.
4341 (gnus-summary-goto-subject gnus-current-article))
4342 (gnus-run-hooks 'gnus-mark-article-hook)
4343 (gnus-set-mode-line 'summary)
4344 (when (gnus-visual-p 'article-highlight 'highlight)
4345 (gnus-run-hooks 'gnus-visual-mark-article-hook))
4346 ;; Set the global newsgroup variables here.
4347 (gnus-set-global-variables)
4348 (setq gnus-have-all-headers
4349 (or all-headers gnus-show-all-headers))))
4351 (gnus-configure-windows 'article))
4352 (when (or (numberp article)
4354 (gnus-article-prepare-display)
4356 (goto-char (point-min))
4357 (when gnus-break-pages
4358 (gnus-narrow-to-page)))
4359 (let ((gnus-article-mime-handle-alist-1
4360 gnus-article-mime-handle-alist))
4361 (gnus-set-mode-line 'article))
4365 (set-window-point (get-buffer-window (current-buffer)) (point))
4366 (gnus-configure-windows 'article)
4369 (defun gnus-article-prepare-mime-display (&optional number)
4370 (goto-char (point-min))
4371 (when (re-search-forward "^[^\t ]+:" nil t)
4372 (goto-char (match-beginning 0)))
4373 (let ((entity (if (eq 1 (point-min))
4374 (get-text-property 1 'mime-view-entity)
4375 (get-text-property (point) 'mime-view-entity)))
4376 last-entity child-entity next type)
4377 (setq child-entity (mime-entity-children entity))
4379 (setq last-entity (nth (1- (length child-entity))
4381 (setq last-entity entity))
4383 (narrow-to-region (point)
4384 (if (search-forward "\n\n" nil t)
4387 (gnus-article-save-original-date (gnus-treat-article 'head))
4388 (put-text-property (point-min) (point-max) 'article-treated-header t)
4389 (goto-char (point-max)))
4390 (while (and (not (eobp)) entity)
4391 (setq next (set-marker
4393 (next-single-property-change (point) 'mime-view-entity
4395 (let ((types (mime-entity-content-type entity)))
4396 (while (eq 'multipart (mime-content-type-primary-type types))
4397 (setq entity (car (mime-entity-children entity))
4398 types (mime-entity-content-type entity)))
4400 (setq type (format "%s/%s"
4401 (mime-content-type-primary-type types)
4402 (mime-content-type-subtype types)))))
4403 (if (string-equal type "message/rfc822")
4406 (let ((children (mime-entity-children entity))
4409 (setq last-children (nth (1- (length children)) children))
4412 (not (eq last-children
4413 (get-text-property next 'mime-view-entity)))
4415 (next-single-property-change next
4417 nil (point-max)))))))
4418 (setq next (next-single-property-change next 'mime-view-entity
4421 (narrow-to-region (point) next)
4422 (gnus-article-prepare-mime-display)
4423 (goto-char (point-max)))
4424 (setq entity (get-text-property (point) 'mime-view-entity)))
4426 (narrow-to-region (point) next)
4427 ;; Kludge. We have to count true number, but for now,
4428 ;; part number is here only to achieve `last'.
4429 (gnus-treat-article nil 1
4430 (if (eq entity last-entity)
4433 (goto-char (point-max)))
4434 (setq entity (get-text-property next 'mime-view-entity))))))
4437 (defun gnus-article-prepare-display ()
4438 "Make the current buffer look like a nice article."
4439 (let ((gnus-article-buffer (current-buffer))
4441 (inhibit-read-only t))
4442 (unless (eq major-mode 'gnus-article-mode)
4443 (gnus-article-mode))
4444 (setq buffer-read-only nil
4445 gnus-button-marker-list nil
4446 gnus-article-wash-types nil
4447 gnus-article-image-alist nil)
4450 (static-if (featurep 'xemacs)
4451 (map-extents (lambda (extent maparg) (delete-extent extent)))
4452 (let ((lists (overlay-lists)))
4453 (dolist (overlay (nconc (car lists) (cdr lists)))
4454 (delete-overlay overlay)))))
4455 (gnus-run-hooks 'gnus-tmp-internal-hook))
4456 (let ((show-mime (unless (member gnus-newsgroup-name '("nndraft:delayed"
4459 (inhibit-read-only t))
4460 (set-buffer gnus-original-article-buffer)
4462 (setq mime-message-structure gnus-current-headers)
4463 (mime-buffer-entity-set-buffer-internal mime-message-structure
4464 gnus-original-article-buffer)
4465 (mime-entity-set-representation-type-internal mime-message-structure
4466 'mime-buffer-entity)
4467 (luna-send mime-message-structure 'initialize-instance
4468 mime-message-structure)
4470 (let (mime-display-header-hook mime-display-text/plain-hook)
4471 (funcall gnus-article-display-method-for-mime))
4472 (funcall gnus-article-display-method-for-traditional))
4473 ;; Call the treatment functions.
4477 (gnus-article-prepare-mime-display)
4478 (narrow-to-region (goto-char (point-min))
4479 (if (search-forward "\n\n" nil t)
4482 (gnus-article-save-original-date (gnus-treat-article 'head))
4483 (put-text-property (point-min) (point-max) 'article-treated-header t)
4484 (goto-char (point-max))
4486 (narrow-to-region (point) (point-max))
4487 (gnus-treat-article nil))
4488 (put-text-property (point-min) (point-max) 'read-only nil)))
4489 (gnus-run-hooks 'gnus-article-prepare-hook))
4491 (defun gnus-article-decode-article-as-default-mime-charset ()
4492 "Decode an article as `default-mime-charset'. It won't work if the
4493 value of the variable `gnus-show-mime' is non-nil."
4494 (unless (or gnus-show-mime
4495 (member gnus-newsgroup-name '("nndraft:delayed"
4497 (set (make-local-variable 'default-mime-charset)
4498 (with-current-buffer gnus-summary-buffer
4499 default-mime-charset))
4500 (decode-mime-charset-region (point-min) (point-max)
4501 default-mime-charset)))
4504 ;;; Gnus MIME viewing functions
4507 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4508 "Format of the MIME buttons.
4510 Valid specifiers include:
4512 %T MIME type, along with additional info
4513 %n The `name' parameter
4514 %d The description, if any
4515 %l The length of the encoded part
4516 %p The part identifier number
4517 %e Dots if the part isn't displayed
4519 General format specifiers can also be used. See Info node
4520 `(gnus)Formatting Variables'.")
4522 (defvar gnus-mime-button-line-format-alist
4523 '((?t gnus-tmp-type ?s)
4524 (?T gnus-tmp-type-long ?s)
4525 (?n gnus-tmp-name ?s)
4526 (?d gnus-tmp-description ?s)
4528 (?l gnus-tmp-length ?d)
4529 (?e gnus-tmp-dots ?s)))
4531 (defvar gnus-mime-button-commands
4532 '((gnus-article-press-button "\r" "Toggle Display")
4533 (gnus-mime-view-part "v" "View Interactively...")
4534 (gnus-mime-view-part-as-type "t" "View As Type...")
4535 (gnus-mime-view-part-as-charset "C" "View As charset...")
4536 (gnus-mime-save-part "o" "Save...")
4537 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4538 (gnus-mime-replace-part "r" "Replace part")
4539 (gnus-mime-delete-part "d" "Delete part")
4540 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4541 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4542 (gnus-mime-view-part-internally "E" "View Internally") ;; Why `E'?
4543 (gnus-mime-view-part-externally "e" "View Externally")
4544 (gnus-mime-print-part "p" "Print")
4545 (gnus-mime-pipe-part "|" "Pipe To Command...")
4546 (gnus-mime-action-on-part "." "Take action on the part...")))
4548 (defun gnus-article-mime-part-status ()
4549 (with-current-buffer gnus-article-buffer
4550 (let ((entity (get-text-property (point-min) 'mime-view-entity))
4553 (setq children (mime-entity-children entity))
4554 (setq children (length children)))
4557 (format " (%d parts)" children))
4560 (defvar gnus-mime-button-map
4561 (let ((map (make-sparse-keymap)))
4562 (define-key map gnus-mouse-2 'gnus-article-push-button)
4563 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4564 (dolist (c gnus-mime-button-commands)
4565 (define-key map (cadr c) (car c)))
4569 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4571 ,@(mapcar (lambda (c)
4572 (vector (caddr c) (car c) :enable t))
4573 gnus-mime-button-commands)))
4575 (defun gnus-mime-button-menu (event prefix)
4576 "Construct a context-sensitive menu of MIME commands."
4577 (interactive "e\nP")
4578 (save-window-excursion
4579 (let ((pos (event-start event)))
4580 (select-window (posn-window pos))
4581 (goto-char (posn-point pos))
4582 (gnus-article-check-buffer)
4583 (popup-menu gnus-mime-button-menu nil prefix))))
4585 (defun gnus-mime-view-all-parts (&optional handles)
4586 "View all the MIME parts."
4588 (with-current-buffer gnus-article-buffer
4589 (let ((handles (or handles gnus-article-mime-handles))
4590 (mail-parse-charset gnus-newsgroup-charset)
4591 (mail-parse-ignored-charsets
4592 (with-current-buffer gnus-summary-buffer
4593 gnus-newsgroup-ignored-charsets)))
4595 (mm-remove-parts handles)
4596 (goto-char (point-min))
4597 (or (search-forward "\n\n") (goto-char (point-max)))
4598 (let ((inhibit-read-only t))
4599 (delete-region (point) (point-max))
4600 (mm-display-parts handles))))))
4602 (defun gnus-article-jump-to-part (n)
4603 "Jump to MIME part N."
4605 (pop-to-buffer gnus-article-buffer)
4606 ;; FIXME: why is it necessary?
4608 (let ((parts (length gnus-article-mime-handle-alist)))
4611 (read-string ;; Emacs 21 doesn't have `read-number'.
4612 (format "Jump to part (2..%s): " parts)))))
4613 (unless (and (integerp n) (<= n parts) (>= n 1))
4616 (gnus-message 7 "Invalid part `%s', using %s instead."
4619 (gnus-message 9 "Jumping to part %s." n)
4620 (cond ((>= gnus-auto-select-part 1)
4621 (while (and (<= n parts)
4622 (not (gnus-article-goto-part n)))
4624 ((< gnus-auto-select-part 0)
4625 (while (and (>= n 1)
4626 (not (gnus-article-goto-part n)))
4629 (gnus-article-goto-part n)))))
4632 (defsubst gnus-article-edit-part (handles &optional current-id)
4633 "Edit an article in order to delete a mime part.
4634 This function is exclusively used by `gnus-mime-save-part-and-strip'
4635 and `gnus-mime-delete-part', and not provided at run-time normally."
4636 (gnus-article-edit-article
4638 (buffer-disable-undo)
4640 (let ((mail-parse-charset (or gnus-article-charset
4641 ',gnus-newsgroup-charset))
4642 (mail-parse-ignored-charsets
4643 (or gnus-article-ignored-charsets
4644 ',gnus-newsgroup-ignored-charsets))
4645 (mbl mml-buffer-list))
4646 (setq mml-buffer-list nil)
4647 (insert-buffer-substring gnus-original-article-buffer)
4648 (mime-to-mml ',handles)
4649 (setq gnus-article-mime-handles nil)
4650 (let ((mbl1 mml-buffer-list))
4651 (setq mml-buffer-list mbl)
4652 (set (make-local-variable 'mml-buffer-list) mbl1))
4653 (gnus-make-local-hook 'kill-buffer-hook)
4654 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4655 `(lambda (no-highlight)
4656 (let ((mail-parse-charset (or gnus-article-charset
4657 ',gnus-newsgroup-charset))
4658 (message-options message-options)
4659 (message-options-set-recipient)
4660 (mail-parse-ignored-charsets
4661 (or gnus-article-ignored-charsets
4662 ',gnus-newsgroup-ignored-charsets)))
4664 (mml-destroy-buffers)
4665 (remove-hook 'kill-buffer-hook
4666 'mml-destroy-buffers t)
4667 (kill-local-variable 'mml-buffer-list))
4668 (gnus-summary-edit-article-done
4669 ,(or (mail-header-references gnus-current-headers) "")
4670 ,(gnus-group-read-only-p)
4671 ,gnus-summary-buffer no-highlight))
4673 (gnus-article-edit-done)
4674 (gnus-summary-expand-window)
4675 (gnus-summary-show-article)
4676 (when (and current-id (integerp gnus-auto-select-part))
4677 (gnus-article-jump-to-part
4678 (+ current-id gnus-auto-select-part)))))
4680 (defun gnus-mime-replace-part (file)
4681 "Replace MIME part under point with an external body."
4682 ;; Useful if file has already been saved to disk
4686 (read-file-name "Replace MIME part with file: "
4687 (or mm-default-directory default-directory)
4689 (gnus-mime-save-part-and-strip file))
4691 (defun gnus-mime-save-part-and-strip (&optional file)
4692 "Save the MIME part under point then replace it with an external body.
4693 If FILE is given, use it for the external part."
4695 (gnus-article-check-buffer)
4696 (when (gnus-group-read-only-p)
4697 (error "The current group does not support deleting of parts"))
4698 (when (mm-complicated-handles gnus-article-mime-handles)
4700 The current article has a complicated MIME structure, giving up..."))
4701 (let* ((data (get-text-property (point) 'gnus-data))
4702 (id (get-text-property (point) 'gnus-part))
4704 (handles gnus-article-mime-handles))
4707 (and data (mm-save-part data "Delete MIME part and save to: "))))
4709 (with-current-buffer (mm-handle-buffer data)
4711 (insert "Content-Type: " (mm-handle-media-type data))
4712 (mml-insert-parameter-string (cdr (mm-handle-type data))
4714 ;; Add a filename for the sake of saving the part again.
4715 (mml-insert-parameter
4716 (mail-header-encode-parameter "name" (file-name-nondirectory file)))
4718 (insert "Content-ID: " (message-make-message-id) "\n")
4719 (insert "Content-Transfer-Encoding: binary\n")
4722 (cdr (mm-make-handle nil
4723 `("message/external-body"
4724 (access-type . "LOCAL-FILE")
4726 ;; (set-buffer gnus-summary-buffer)
4727 (gnus-article-edit-part handles id))))
4729 ;; A function like `gnus-summary-save-parts' (`X m', `<MIME> <Extract all
4730 ;; parts...>') but with stripping would be nice.
4732 (defun gnus-mime-delete-part ()
4733 "Delete the MIME part under point.
4734 Replace it with some information about the removed part."
4736 (gnus-article-check-buffer)
4737 (when (gnus-group-read-only-p)
4738 (error "The current group does not support deleting of parts"))
4739 (when (mm-complicated-handles gnus-article-mime-handles)
4741 The current article has a complicated MIME structure, giving up..."))
4742 (when (or gnus-expert-user
4743 (gnus-yes-or-no-p "\
4744 Deleting parts may malfunction or destroy the article; continue? "))
4745 (let* ((data (get-text-property (point) 'gnus-data))
4746 (id (get-text-property (point) 'gnus-part))
4747 (handles gnus-article-mime-handles)
4751 (mail-decode-encoded-word-string (or (mm-handle-description data)
4754 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4756 (type (mm-handle-media-type data)))
4758 (error "No MIME part under point"))
4759 (with-current-buffer (mm-handle-buffer data)
4760 (let ((bsize (format "%s" (buffer-size))))
4765 "| The following attachment has been deleted:\n"
4767 "| Type: " type "\n"
4768 "| Filename: " filename "\n"
4769 "| Size (encoded): " bsize " Byte\n"
4770 "| Description: " description "\n"
4773 (cdr (mm-make-handle
4774 nil `("text/plain") nil nil
4776 (format "Deleted attachment (%s bytes)" bsize))))))
4777 ;; (set-buffer gnus-summary-buffer)
4778 (gnus-article-edit-part handles id))))
4780 (defun gnus-mime-save-part ()
4781 "Save the MIME part under point."
4783 (gnus-article-check-buffer)
4784 (let ((data (get-text-property (point) 'gnus-data)))
4786 (mm-save-part data))))
4788 (defun gnus-mime-pipe-part ()
4789 "Pipe the MIME part under point to a process."
4791 (gnus-article-check-buffer)
4792 (let ((data (get-text-property (point) 'gnus-data)))
4794 (mm-pipe-part data))))
4796 (defun gnus-mime-view-part ()
4797 "Interactively choose a viewing method for the MIME part under point."
4799 (gnus-article-check-buffer)
4800 (let ((data (get-text-property (point) 'gnus-data)))
4802 (setq gnus-article-mime-handles
4804 gnus-article-mime-handles (setq data (copy-sequence data))))
4805 (mm-interactively-view-part data))))
4807 (defun gnus-mime-view-part-as-type-internal ()
4808 (gnus-article-check-buffer)
4809 (let* ((handle (get-text-property (point) 'gnus-data))
4811 ;; Content-Type: foo/bar; name=...
4812 (mail-content-type-get (mm-handle-type handle) 'name)
4813 ;; Content-Disposition: attachment; filename=...
4814 (cdr (assq 'filename (cdr (mm-handle-disposition handle))))))
4815 (def-type (and name (mm-default-file-encoding name))))
4816 (and def-type (cons def-type 0))))
4818 (defun gnus-mime-view-part-as-type (&optional mime-type)
4819 "Choose a MIME media type, and view the part as such."
4823 (let ((default (gnus-mime-view-part-as-type-internal)))
4825 (format "View as MIME type (default %s): "
4827 (mapcar #'list (mailcap-mime-types))
4830 (gnus-article-check-buffer)
4831 (let ((handle (get-text-property (point) 'gnus-data)))
4833 (when (equal (mm-handle-media-type handle) "message/external-body")
4834 (unless (mm-handle-cache handle)
4835 (mm-extern-cache-contents handle))
4836 (setq handle (mm-handle-cache handle)))
4838 (mm-make-handle (mm-handle-buffer handle)
4839 (cons mime-type (cdr (mm-handle-type handle)))
4840 (mm-handle-encoding handle)
4841 (mm-handle-undisplayer handle)
4842 (mm-handle-disposition handle)
4843 (mm-handle-description handle)
4845 (mm-handle-id handle)))
4846 (setq gnus-article-mime-handles
4847 (mm-merge-handles gnus-article-mime-handles handle))
4848 (gnus-mm-display-part handle))))
4850 (defun gnus-mime-copy-part (&optional handle arg)
4851 "Put the MIME part under point into a new buffer.
4852 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4854 (interactive (list nil current-prefix-arg))
4855 (gnus-article-check-buffer)
4857 (setq handle (get-text-property (point) 'gnus-data)))
4859 (let ((filename (or (mail-content-type-get (mm-handle-disposition handle)
4861 (mail-content-type-get (mm-handle-disposition handle)
4863 contents dont-decode charset coding-system)
4864 (mm-with-unibyte-buffer
4865 (mm-insert-part handle)
4866 (setq contents (or (condition-case nil
4867 (mm-decompress-buffer filename nil 'sig)
4869 (setq dont-decode t)
4872 (setq filename (cond (filename (file-name-nondirectory filename))
4873 (dont-decode "*raw data*")
4878 (unless (setq charset (mail-content-type-get
4879 (mm-handle-type handle) 'charset))
4880 (unless (setq coding-system (mm-with-unibyte-buffer
4882 (mm-find-buffer-file-coding-system)))
4883 (setq charset gnus-newsgroup-charset))))
4885 (setq charset (or (cdr (assq arg
4886 gnus-summary-show-article-charset-alist))
4887 (mm-read-coding-system "Charset: ")))))
4888 (switch-to-buffer (generate-new-buffer filename))
4889 (if (or coding-system
4891 (setq coding-system (mm-charset-to-coding-system charset))
4892 (not (eq charset 'ascii))))
4894 (mm-enable-multibyte)
4895 (insert (mm-decode-coding-string contents coding-system))
4896 (setq buffer-file-coding-system
4897 (if (boundp 'last-coding-system-used)
4898 (symbol-value 'last-coding-system-used)
4900 (mm-disable-multibyte)
4902 (setq buffer-file-coding-system mm-binary-coding-system))
4903 ;; We do it this way to make `normal-mode' set the appropriate mode.
4906 (setq buffer-file-name (expand-file-name filename))
4908 (setq buffer-file-name nil))
4909 (goto-char (point-min)))))
4911 (defun gnus-mime-print-part (&optional handle filename)
4912 "Print the MIME part under point."
4913 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4914 (gnus-article-check-buffer)
4915 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4916 (contents (and handle (mm-get-part handle)))
4917 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4918 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4923 (mm-save-part-to-file handle file)
4924 (call-process shell-file-name nil
4925 (generate-new-buffer " *mm*")
4927 shell-command-switch
4929 printer file (mm-handle-type handle))))
4933 (gnus-print-buffer))
4934 (ps-despool filename)))))
4936 (defun gnus-mime-inline-part (&optional handle arg)
4937 "Insert the MIME part under point into the current buffer.
4938 Compressed files like .gz and .bz2 are decompressed."
4939 (interactive (list nil current-prefix-arg))
4940 (gnus-article-check-buffer)
4942 (setq handle (get-text-property (point) 'gnus-data)))
4945 (inhibit-read-only t)
4946 contents charset coding-system)
4947 (if (and (not arg) (mm-handle-undisplayer handle))
4948 (mm-remove-part handle)
4949 (mm-with-unibyte-buffer
4950 (mm-insert-part handle)
4952 (or (mm-decompress-buffer
4953 (or (mail-content-type-get (mm-handle-disposition handle)
4955 (mail-content-type-get (mm-handle-disposition handle)
4961 (unless (setq charset (mail-content-type-get
4962 (mm-handle-type handle) 'charset))
4963 (unless (setq coding-system
4964 (mm-with-unibyte-buffer
4966 (mm-find-buffer-file-coding-system)))
4967 (setq charset gnus-newsgroup-charset))))
4969 (if (mm-handle-undisplayer handle)
4970 (mm-remove-part handle))
4973 gnus-summary-show-article-charset-alist))
4974 (mm-read-coding-system "Charset: "))))
4976 (if (mm-handle-undisplayer handle)
4977 (mm-remove-part handle))))
4981 (if (or coding-system
4984 (mm-charset-to-coding-system charset))
4985 (not (eq coding-system 'ascii))))
4986 (mm-decode-coding-string contents coding-system)
4987 (mm-string-to-multibyte contents)))
4990 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4991 "Insert the MIME part under point into the current buffer using the
4993 (interactive (list nil current-prefix-arg))
4994 (gnus-article-check-buffer)
4995 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4998 (inhibit-read-only t))
5000 (if (mm-handle-undisplayer handle)
5001 (mm-remove-part handle))
5002 (let ((gnus-newsgroup-charset
5004 gnus-summary-show-article-charset-alist))
5005 (mm-read-coding-system "Charset: ")))
5006 (gnus-newsgroup-ignored-charsets 'gnus-all))
5007 (gnus-article-press-button)))))
5009 (defun gnus-mime-view-part-externally (&optional handle)
5010 "View the MIME part under point with an external viewer."
5012 (gnus-article-check-buffer)
5013 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
5014 (mm-user-display-methods nil)
5015 (mm-inlined-types nil)
5016 (mail-parse-charset gnus-newsgroup-charset)
5017 (mail-parse-ignored-charsets
5018 (with-current-buffer gnus-summary-buffer
5019 gnus-newsgroup-ignored-charsets)))
5021 (if (mm-handle-undisplayer handle)
5022 (mm-remove-part handle)
5023 (mm-display-part handle)))))
5025 (defun gnus-mime-view-part-internally (&optional handle)
5026 "View the MIME part under point with an internal viewer.
5027 If no internal viewer is available, use an external viewer."
5029 (gnus-article-check-buffer)
5030 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
5031 (mm-inlined-types '(".*"))
5032 (mm-inline-large-images t)
5033 (mail-parse-charset gnus-newsgroup-charset)
5034 (mail-parse-ignored-charsets
5035 (with-current-buffer gnus-summary-buffer
5036 gnus-newsgroup-ignored-charsets))
5037 (inhibit-read-only t))
5039 (if (mm-handle-undisplayer handle)
5040 (mm-remove-part handle)
5041 (mm-display-part handle)))))
5043 (defun gnus-mime-action-on-part (&optional action)
5044 "Do something with the MIME attachment at \(point\)."
5046 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
5047 (gnus-article-check-buffer)
5048 (let ((action-pair (assoc action gnus-mime-action-alist)))
5050 (funcall (cdr action-pair)))))
5052 (defun gnus-article-part-wrapper (n function &optional no-handle interactive)
5053 "Call FUNCTION on MIME part N.
5054 Unless NO-HANDLE, call FUNCTION with N-th MIME handle as it's only argument.
5055 If INTERACTIVE, call FUNCTION interactivly."
5057 ;; Check whether the article is displayed.
5058 (unless (and (gnus-buffer-live-p gnus-article-buffer)
5059 (setq window (get-buffer-window gnus-article-buffer t))
5060 (frame-visible-p (setq frame (window-frame window))))
5061 (error "No article is displayed"))
5062 (with-current-buffer gnus-article-buffer
5063 ;; Check whether the article displays the right contents.
5064 (unless (with-current-buffer gnus-summary-buffer
5065 (eq gnus-current-article (gnus-summary-article-number)))
5066 (error "You should select the right article first"))
5067 ;; Check whether the specified part exists.
5068 (when (> n (length gnus-article-mime-handle-alist))
5069 (error "No such part")))
5072 ;; To select the window is needed so that the cursor
5073 ;; might be visible on the MIME button.
5074 (select-window (prog1
5076 (setq window (selected-window))
5077 ;; Article may be displayed in the other frame.
5078 (gnus-select-frame-set-input-focus
5081 (setq frame (selected-frame))))))
5082 (when (gnus-article-goto-part n)
5083 ;; We point the cursor and the arrow at the MIME button
5084 ;; when the `function' prompt the user for something.
5085 (let ((cursor-in-non-selected-windows t)
5086 (overlay-arrow-string "=>")
5087 (overlay-arrow-position (point-marker)))
5090 ((and no-handle interactive)
5091 (call-interactively function))
5097 (cdr (assq n gnus-article-mime-handle-alist))))
5100 (cdr (assq n gnus-article-mime-handle-alist)))))
5101 (set-marker overlay-arrow-position nil)
5102 (unless gnus-auto-select-part
5103 (gnus-select-frame-set-input-focus frame)
5104 (select-window window))))
5106 (if gnus-inhibit-mime-unbuttonizing
5107 ;; This is the default though the program shouldn't reach here.
5108 (error "No such part")
5109 ;; The part which doesn't have the MIME button is selected.
5110 ;; So, we display all the buttons and redo it.
5111 (let ((gnus-inhibit-mime-unbuttonizing t))
5112 (gnus-summary-show-article)
5113 (gnus-article-part-wrapper n function no-handle))))))
5115 (defun gnus-article-pipe-part (n)
5116 "Pipe MIME part N, which is the numerical prefix."
5118 (gnus-article-part-wrapper n 'mm-pipe-part))
5120 (defun gnus-article-save-part (n)
5121 "Save MIME part N, which is the numerical prefix."
5123 (gnus-article-part-wrapper n 'mm-save-part))
5125 (defun gnus-article-interactively-view-part (n)
5126 "View MIME part N interactively, which is the numerical prefix."
5128 (gnus-article-part-wrapper n 'mm-interactively-view-part))
5130 (defun gnus-article-copy-part (n)
5131 "Copy MIME part N, which is the numerical prefix."
5133 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
5135 (defun gnus-article-view-part-as-charset (n)
5136 "View MIME part N using a specified charset.
5137 N is the numerical prefix."
5139 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
5141 (defun gnus-article-view-part-externally (n)
5142 "View MIME part N externally, which is the numerical prefix."
5144 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
5146 (defun gnus-article-inline-part (n)
5147 "Inline MIME part N, which is the numerical prefix."
5149 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
5151 (defun gnus-article-save-part-and-strip (n)
5152 "Save MIME part N and replace it with an external body.
5153 N is the numerical prefix."
5155 (gnus-article-part-wrapper n 'gnus-mime-save-part-and-strip t))
5157 (defun gnus-article-replace-part (n)
5158 "Replace MIME part N with an external body.
5159 N is the numerical prefix."
5161 (gnus-article-part-wrapper n 'gnus-mime-replace-part t t))
5163 (defun gnus-article-delete-part (n)
5164 "Delete MIME part N and add some information about the removed part.
5165 N is the numerical prefix."
5167 (gnus-article-part-wrapper n 'gnus-mime-delete-part t))
5169 (defun gnus-article-mime-match-handle-first (condition)
5172 (dolist (ihandle gnus-article-mime-handle-alist)
5174 ((functionp condition)
5175 (funcall condition (cdr ihandle)))
5176 ((eq condition 'undisplayed)
5177 (not (or (mm-handle-undisplayer (cdr ihandle))
5178 (equal (mm-handle-media-type (cdr ihandle))
5179 "multipart/alternative"))))
5180 ((eq condition 'undisplayed-alternative)
5181 (not (mm-handle-undisplayer (cdr ihandle))))
5183 (gnus-article-goto-part (car ihandle))
5184 (or (not n) (< (car ihandle) n)))
5185 (setq n (car ihandle))))
5189 (defun gnus-article-view-part (&optional n)
5190 "View MIME part N, which is the numerical prefix."
5192 (with-current-buffer gnus-article-buffer
5193 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
5194 gnus-article-mime-match-handle-function)))
5195 (when (> n (length gnus-article-mime-handle-alist))
5196 (error "No such part"))
5197 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
5198 (when (gnus-article-goto-part n)
5199 (if (equal (car handle) "multipart/alternative")
5200 (gnus-article-press-button)
5201 (when (eq (gnus-mm-display-part handle) 'internal)
5202 (gnus-set-window-start)))))))
5204 (defsubst gnus-article-mime-total-parts ()
5205 (if (bufferp (car gnus-article-mime-handles))
5207 (1- (length gnus-article-mime-handles))))
5209 (defun gnus-mm-display-part (handle)
5210 "Display HANDLE and fix MIME button."
5211 (let ((id (get-text-property (point) 'gnus-part))
5213 (inhibit-read-only t))
5216 (let ((window (selected-window))
5217 (mail-parse-charset gnus-newsgroup-charset)
5218 (mail-parse-ignored-charsets
5219 (if (gnus-buffer-live-p gnus-summary-buffer)
5220 (with-current-buffer gnus-summary-buffer
5221 gnus-newsgroup-ignored-charsets)
5225 (let ((win (gnus-get-buffer-window (current-buffer) t))
5228 (select-window win))
5231 (if (mm-handle-displayed-p handle)
5232 ;; This will remove the part.
5233 (mm-display-part handle)
5235 (narrow-to-region (point)
5236 (if (eobp) (point) (1+ (point))))
5237 (mm-display-part handle)
5238 ;; We narrow to the part itself and
5239 ;; then call the treatment functions.
5240 (goto-char (point-min))
5242 (narrow-to-region (point) (point-max))
5245 (gnus-article-mime-total-parts)
5246 (mm-handle-media-type handle)))))
5247 (if (window-live-p window)
5248 (select-window window)))))
5251 (gnus-insert-mime-button
5252 handle id (list (mm-handle-displayed-p handle)))
5253 (goto-char point))))
5255 (defun gnus-article-goto-part (n)
5256 "Go to MIME part N."
5257 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
5259 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
5260 (let ((gnus-tmp-name
5261 (or (mail-content-type-get (mm-handle-type handle) 'name)
5262 (mail-content-type-get (mm-handle-disposition handle) 'filename)
5263 (mail-content-type-get (mm-handle-type handle) 'url)
5265 (gnus-tmp-type (mm-handle-media-type handle))
5266 (gnus-tmp-description
5267 (mail-decode-encoded-word-string (or (mm-handle-description handle)
5270 (if (if displayed (car displayed)
5271 (mm-handle-displayed-p handle))
5273 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
5275 gnus-tmp-type-long b e)
5276 (when (string-match ".*/" gnus-tmp-name)
5277 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
5278 (setq gnus-tmp-type-long (concat gnus-tmp-type
5279 (and (not (equal gnus-tmp-name ""))
5280 (concat "; " gnus-tmp-name))))
5281 (unless (equal gnus-tmp-description "")
5282 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
5287 gnus-mime-button-line-format gnus-mime-button-line-format-alist
5288 `(keymap ,gnus-mime-button-map
5289 gnus-callback gnus-mm-display-part
5290 gnus-part ,gnus-tmp-id
5291 article-type annotation
5294 ;; Exclude a newline.
5297 (widget-convert-button
5300 :action 'gnus-widget-press-button
5301 :button-keymap gnus-mime-button-map
5303 (lambda (widget/window &optional overlay pos)
5304 ;; Needed to properly clear the message due to a bug in
5305 ;; wid-edit (XEmacs only).
5306 (if (boundp 'help-echo-owns-message)
5307 (setq help-echo-owns-message t))
5309 "%S: %s the MIME part; %S: more options"
5310 (aref gnus-mouse-2 0)
5311 ;; XEmacs will get a single widget arg; Emacs 21 will get
5312 ;; window, overlay, position.
5313 (if (mm-handle-displayed-p
5315 (with-current-buffer (gnus-overlay-buffer overlay)
5316 (widget-get (widget-at (gnus-overlay-start overlay))
5318 (widget-get widget/window :mime-handle)))
5320 (aref gnus-down-mouse-3 0))))))
5322 (defun gnus-widget-press-button (elems el)
5323 (goto-char (widget-get elems :from))
5324 (gnus-article-press-button))
5326 (defvar gnus-displaying-mime nil)
5328 (defun gnus-display-mime (&optional ihandles)
5329 "Display the MIME parts."
5331 (save-selected-window
5332 (let ((window (get-buffer-window gnus-article-buffer))
5335 (select-window window)
5336 ;; We have to do this since selecting the window
5337 ;; may change the point. So we set the window point.
5338 (set-window-point window point)))
5339 (let ((handles ihandles)
5340 (inhibit-read-only t)
5343 ((setq handles (mm-dissect-buffer nil gnus-article-loose-mime))
5344 (when gnus-article-emulate-mime
5345 (mm-uu-dissect-text-parts handles)))
5346 (gnus-article-emulate-mime
5347 (setq handles (mm-uu-dissect))))
5348 (when (and (not ihandles)
5349 (not gnus-displaying-mime))
5350 ;; Top-level call; we clean up.
5351 (when gnus-article-mime-handles
5352 (mm-destroy-parts gnus-article-mime-handles)
5353 (setq gnus-article-mime-handle-alist nil));; A trick.
5354 (setq gnus-article-mime-handles handles)
5355 ;; We allow users to glean info from the handles.
5356 (when gnus-article-mime-part-function
5357 (gnus-mime-part-function handles)))
5359 (or (not (stringp (car handles)))
5362 (when (and (not ihandles)
5363 (not gnus-displaying-mime))
5364 ;; Clean up for mime parts.
5366 (delete-region (point) (point-max)))
5367 (let ((gnus-displaying-mime t))
5368 (gnus-mime-display-part handles)))
5371 (narrow-to-region (point) (point-max))
5372 (gnus-treat-article nil 1 1)
5375 ;; Highlight the headers.
5379 (narrow-to-region (point-min) (point))
5380 (gnus-article-save-original-date
5381 (gnus-treat-article 'head)))))))))
5383 (defcustom gnus-mime-display-multipart-as-mixed nil
5384 "Display \"multipart\" parts as \"multipart/mixed\".
5386 If t, it overrides nil values of
5387 `gnus-mime-display-multipart-alternative-as-mixed' and
5388 `gnus-mime-display-multipart-related-as-mixed'."
5389 :group 'gnus-article-mime
5392 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
5393 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
5395 :group 'gnus-article-mime
5398 (defcustom gnus-mime-display-multipart-related-as-mixed nil
5399 "Display \"multipart/related\" parts as \"multipart/mixed\".
5401 If displaying \"text/html\" is discouraged \(see
5402 `mm-discouraged-alternatives'\) images or other material inside a
5403 \"multipart/related\" part might be overlooked when this variable is nil."
5405 :group 'gnus-article-mime
5408 (defun gnus-mime-display-part (handle)
5410 ;; Maybe a broken MIME message.
5413 ((not (stringp (car handle)))
5414 (gnus-mime-display-single handle))
5415 ;; User-defined multipart
5416 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
5417 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
5419 ;; multipart/alternative
5420 ((and (equal (car handle) "multipart/alternative")
5421 (not (or gnus-mime-display-multipart-as-mixed
5422 gnus-mime-display-multipart-alternative-as-mixed)))
5423 (let ((id (1+ (length gnus-article-mime-handle-alist))))
5424 (push (cons id handle) gnus-article-mime-handle-alist)
5425 (gnus-mime-display-alternative (cdr handle) nil nil id)))
5426 ;; multipart/related
5427 ((and (equal (car handle) "multipart/related")
5428 (not (or gnus-mime-display-multipart-as-mixed
5429 gnus-mime-display-multipart-related-as-mixed)))
5430 ;;;!!!We should find the start part, but we just default
5431 ;;;!!!to the first part.
5432 ;;(gnus-mime-display-part (cadr handle))
5433 ;;;!!! Most multipart/related is an HTML message plus images.
5434 ;;;!!! Unfortunately we are unable to let W3 display those
5435 ;;;!!! included images, so we just display it as a mixed multipart.
5436 ;;(gnus-mime-display-mixed (cdr handle))
5437 ;;;!!! No, w3 can display everything just fine.
5438 (gnus-mime-display-part (cadr handle)))
5439 ((equal (car handle) "multipart/signed")
5440 (gnus-add-wash-type 'signed)
5441 (gnus-mime-display-security handle))
5442 ((equal (car handle) "multipart/encrypted")
5443 (gnus-add-wash-type 'encrypted)
5444 (gnus-mime-display-security handle))
5445 ;; Other multiparts are handled like multipart/mixed.
5447 (gnus-mime-display-mixed (cdr handle)))))
5449 (defun gnus-mime-part-function (handles)
5450 (if (stringp (car handles))
5451 (mapcar 'gnus-mime-part-function (cdr handles))
5452 (funcall gnus-article-mime-part-function handles)))
5454 (defun gnus-mime-display-mixed (handles)
5455 (mapcar 'gnus-mime-display-part handles))
5457 (defun gnus-mime-display-single (handle)
5458 (let ((type (mm-handle-media-type handle))
5459 (ignored gnus-ignored-mime-types)
5466 (when (string-match (pop ignored) type)
5467 (throw 'ignored nil)))
5468 (if (and (setq not-attachment
5469 (and (not (mm-inline-override-p handle))
5470 (or (not (mm-handle-disposition handle))
5471 (equal (car (mm-handle-disposition handle))
5473 (mm-attachment-override-p handle))))
5474 (mm-automatic-display-p handle)
5476 (mm-inlinable-p handle)
5477 (mm-inlined-p handle))
5478 (mm-automatic-external-display-p type)))
5480 (when (equal (mm-handle-media-supertype handle) "text")
5482 (let ((id (1+ (length gnus-article-mime-handle-alist)))
5484 (push (cons id handle) gnus-article-mime-handle-alist)
5486 (equal (mm-handle-media-supertype handle) "message"))
5489 (cond ((not (bolp)) 2)
5490 ((or (bobp) (eq (char-before (1- (point))) ?\n)) 0)
5492 (when (or (not display)
5493 (not (gnus-unbuttonized-mime-type-p type)))
5494 (gnus-insert-mime-button
5495 handle id (list (or display (and not-attachment text))))
5496 (gnus-article-insert-newline)
5497 ;; Remember modify the number of forward lines.
5505 (let ((mail-parse-charset gnus-newsgroup-charset)
5506 (mail-parse-ignored-charsets
5507 (save-excursion (condition-case ()
5508 (set-buffer gnus-summary-buffer)
5510 gnus-newsgroup-ignored-charsets)))
5511 (mm-display-part handle t))
5512 (goto-char (point-max)))
5513 ((and text not-attachment)
5517 (gnus-article-insert-newline)
5520 (let ((charset (mail-content-type-get (mm-handle-type handle)
5522 (cond ((not charset)
5523 (mm-string-as-multibyte (mm-get-part handle)))
5524 ((eq charset 'gnus-decoded)
5525 (with-current-buffer (mm-handle-buffer handle)
5528 (mm-decode-string (mm-get-part handle) charset)))))
5529 (goto-char (point-max))))
5533 (narrow-to-region beg (point))
5536 (gnus-article-mime-total-parts)
5537 (mm-handle-media-type handle)))))))))
5539 (defun gnus-unbuttonized-mime-type-p (type)
5540 "Say whether TYPE is to be unbuttonized."
5541 (unless gnus-inhibit-mime-unbuttonizing
5543 (let ((types gnus-unbuttonized-mime-types))
5545 (when (string-match (pop types) type)
5546 (throw 'found t)))))
5548 (let ((types gnus-buttonized-mime-types))
5550 (when (string-match (pop types) type)
5551 (throw 'found t)))))))))
5553 (defun gnus-article-insert-newline ()
5554 "Insert a newline, but mark it as undeletable."
5555 (gnus-put-text-property
5556 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
5558 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
5559 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
5562 handle (inhibit-read-only t) from props begend not-pref)
5563 (save-window-excursion
5566 (narrow-to-region (car ibegend)
5569 (goto-char (car ibegend))
5572 (delete-region (point-min) (point-max))
5573 (mm-remove-parts handles))
5574 (setq begend (list (point-marker)))
5576 (unless (setq not-pref (cadr (member preferred ihandles)))
5577 (setq not-pref (car ihandles)))
5580 (not (gnus-unbuttonized-mime-type-p
5581 "multipart/alternative")))
5582 (gnus-add-text-properties
5585 (insert (format "%d. " id))
5589 (unless ,(not ibegend)
5590 (setq gnus-article-mime-handle-alist
5591 ',gnus-article-mime-handle-alist))
5592 (gnus-mime-display-alternative
5593 ',ihandles ',not-pref ',begend ,id))
5594 keymap ,gnus-mime-button-map
5595 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5596 face ,gnus-article-button-face
5598 article-type multipart))
5599 (widget-convert-button 'link from (point)
5600 :action 'gnus-widget-press-button
5601 :button-keymap gnus-widget-button-keymap)
5603 (while (setq handle (pop handles))
5604 (gnus-add-text-properties
5607 (insert (format "(%c) %-18s"
5608 (if (equal handle preferred) ?* ? )
5609 (mm-handle-media-type handle)))
5613 (unless ,(not ibegend)
5614 (setq gnus-article-mime-handle-alist
5615 ',gnus-article-mime-handle-alist))
5616 (gnus-mime-display-alternative
5617 ',ihandles ',handle ',begend ,id))
5618 keymap ,gnus-mime-button-map
5619 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5620 face ,gnus-article-button-face
5623 (widget-convert-button 'link from (point)
5624 :action 'gnus-widget-press-button
5625 :button-keymap gnus-widget-button-keymap)
5629 (if (stringp (car preferred))
5630 (gnus-display-mime preferred)
5631 (let ((mail-parse-charset gnus-newsgroup-charset)
5632 (mail-parse-ignored-charsets
5633 (with-current-buffer gnus-summary-buffer
5634 gnus-newsgroup-ignored-charsets)))
5635 (mm-display-part preferred)
5639 (narrow-to-region (car begend) (point-max))
5641 nil (length gnus-article-mime-handle-alist)
5642 (gnus-article-mime-total-parts)
5643 (mm-handle-media-type handle))))))
5644 (goto-char (point-max))
5645 (setcdr begend (point-marker)))))
5647 (goto-char point))))
5649 (defconst gnus-article-wash-status-strings
5650 (let ((alist '((cite "c" "Possible hidden citation text"
5651 " " "All citation text visible")
5652 (headers "h" "Hidden headers"
5653 " " "All headers visible.")
5654 (pgp "p" "Encrypted or signed message status hidden"
5655 " " "No hidden encryption nor digital signature status")
5656 (signature "s" "Signature has been hidden"
5657 " " "Signature is visible")
5658 (overstrike "o" "Overstrike (^H) characters applied"
5659 " " "No overstrike characters applied")
5660 (gnus-show-mime "m" "Mime processing is activated"
5661 " " "Mime processing is not activated")
5662 (emphasis "e" "/*_Emphasis_*/ characters applied"
5663 " " "No /*_emphasis_*/ characters applied")))
5665 (dolist (entry alist result)
5666 (let ((key (nth 0 entry))
5667 (on (copy-sequence (nth 1 entry)))
5668 (on-help (nth 2 entry))
5669 (off (copy-sequence (nth 3 entry)))
5670 (off-help (nth 4 entry)))
5671 (put-text-property 0 1 'help-echo on-help on)
5672 (put-text-property 0 1 'help-echo off-help off)
5673 (push (list key on off) result))))
5674 "Alist of strings describing wash status in the mode line.
5675 Each entry has the form (KEY ON OF), where the KEY is a symbol
5676 representing the particular washing function, ON is the string to use
5677 in the article mode line when the washing function is active, and OFF
5678 is the string to use when it is inactive.")
5680 (defun gnus-article-wash-status-entry (key value)
5681 (let ((entry (assoc key gnus-article-wash-status-strings)))
5682 (if value (nth 1 entry) (nth 2 entry))))
5684 (defun gnus-article-wash-status ()
5685 "Return a string which display status of article washing."
5686 (with-current-buffer gnus-article-buffer
5687 (let ((cite (memq 'cite gnus-article-wash-types))
5688 (headers (memq 'headers gnus-article-wash-types))
5689 (boring (memq 'boring-headers gnus-article-wash-types))
5690 (pgp (memq 'pgp gnus-article-wash-types))
5691 (pem (memq 'pem gnus-article-wash-types))
5692 (signed (memq 'signed gnus-article-wash-types))
5693 (encrypted (memq 'encrypted gnus-article-wash-types))
5694 (signature (memq 'signature gnus-article-wash-types))
5695 (overstrike (memq 'overstrike gnus-article-wash-types))
5696 (emphasis (memq 'emphasis gnus-article-wash-types)))
5698 (gnus-article-wash-status-entry 'cite cite)
5699 (gnus-article-wash-status-entry 'headers (or headers boring))
5700 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5701 (gnus-article-wash-status-entry 'signature signature)
5702 (gnus-article-wash-status-entry 'overstrike overstrike)
5703 (gnus-article-wash-status-entry 'gnus-show-mime gnus-show-mime)
5704 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5706 (defun gnus-add-wash-type (type)
5707 "Add a washing of TYPE to the current status."
5708 (add-to-list 'gnus-article-wash-types type))
5710 (defun gnus-delete-wash-type (type)
5711 "Add a washing of TYPE to the current status."
5712 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5714 (defun gnus-add-image (category image)
5715 "Add IMAGE of CATEGORY to the list of displayed images."
5716 (let ((entry (assq category gnus-article-image-alist)))
5718 (setq entry (list category))
5719 (push entry gnus-article-image-alist))
5720 (nconc entry (list image))))
5722 (defun gnus-delete-images (category)
5723 "Delete all images in CATEGORY."
5724 (let ((entry (assq category gnus-article-image-alist)))
5725 (dolist (image (cdr entry))
5726 (gnus-remove-image image category))
5727 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5728 (gnus-delete-wash-type category)))
5730 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5732 (defun gnus-article-maybe-hide-headers ()
5733 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5734 Provided for backwards compatibility."
5735 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5736 (not (with-current-buffer gnus-summary-buffer
5737 gnus-have-all-headers)))
5738 (not gnus-inhibit-hiding))
5739 (gnus-article-hide-headers)))
5743 (defun gnus-output-to-file (file-name)
5744 "Append the current article to a file named FILE-NAME."
5745 (let ((artbuf (current-buffer)))
5747 (insert-buffer-substring artbuf)
5748 ;; Append newline at end of the buffer as separator, and then
5750 (goto-char (point-max))
5752 (let ((file-name-coding-system nnmail-pathname-coding-system))
5753 (write-region-as-binary (point-min) (point-max) file-name 'append))
5756 (defun gnus-narrow-to-page (&optional arg)
5757 "Narrow the article buffer to a page.
5758 If given a numerical ARG, move forward ARG pages."
5760 (setq arg (if arg (prefix-numeric-value arg) 0))
5762 (set-buffer gnus-article-buffer)
5763 (goto-char (point-min))
5765 ;; Remove any old next/prev buttons.
5766 (when (gnus-visual-p 'page-marker)
5767 (let ((inhibit-read-only t))
5768 (gnus-remove-text-with-property 'gnus-prev)
5769 (gnus-remove-text-with-property 'gnus-next)))
5772 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5774 (re-search-forward page-delimiter nil 'move arg)))
5775 (goto-char (match-end 0))
5777 (goto-char (point-min))
5778 (setq gnus-page-broken
5779 (and (re-search-forward page-delimiter nil t) t))))
5780 (when gnus-page-broken
5783 (if (re-search-forward page-delimiter nil 'move)
5786 (when (and (gnus-visual-p 'page-marker)
5787 (> (point-min) (save-restriction (widen) (point-min))))
5789 (goto-char (point-min))
5790 (gnus-insert-prev-page-button)))
5791 (when (and (gnus-visual-p 'page-marker)
5792 (< (point-max) (save-restriction (widen) (point-max))))
5794 (goto-char (point-max))
5795 (gnus-insert-next-page-button))))))
5797 ;; Article mode commands
5799 (defun gnus-article-goto-next-page ()
5800 "Show the next page of the article."
5802 (when (gnus-article-next-page)
5803 (goto-char (point-min))
5804 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5807 (defun gnus-article-goto-prev-page ()
5808 "Show the previous page of the article."
5811 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5812 (gnus-article-prev-page nil)))
5814 ;; This is cleaner but currently breaks `gnus-pick-mode':
5816 ;; (defun gnus-article-goto-next-page ()
5817 ;; "Show the next page of the article."
5819 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5820 ;; (gnus-summary-next-page)))
5822 ;; (defun gnus-article-goto-prev-page ()
5823 ;; "Show the next page of the article."
5825 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5826 ;; (gnus-summary-prev-page)))
5828 (defun gnus-article-next-page (&optional lines)
5829 "Show the next page of the current article.
5830 If end of article, return non-nil. Otherwise return nil.
5831 Argument LINES specifies lines to be scrolled up."
5833 (move-to-window-line -1)
5836 (and (pos-visible-in-window-p) ;Not continuation line.
5837 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5838 ;; Nothing in this page.
5839 (if (or (not gnus-page-broken)
5844 (eobp)))) ;Real end-of-buffer?
5846 (when gnus-article-over-scroll
5847 (gnus-article-next-page-1 lines))
5849 (gnus-narrow-to-page 1) ;Go to next page.
5851 ;; More in this page.
5852 (gnus-article-next-page-1 lines)
5855 (defmacro gnus-article-beginning-of-window ()
5856 "Move point to the beginning of the window.
5857 In Emacs, the point is placed at the line number which `scroll-margin'
5859 (if (featurep 'xemacs)
5860 '(move-to-window-line 0)
5861 '(move-to-window-line
5862 (min (max 0 scroll-margin)
5863 (max 1 (- (window-height)
5864 (if mode-line-format 1 0)
5865 (if header-line-format 1 0)))))))
5867 (defun gnus-article-next-page-1 (lines)
5868 (when (and (not (featurep 'xemacs))
5871 (numberp (symbol-value 'scroll-margin))
5872 (> (symbol-value 'scroll-margin) 0))
5873 ;; Protect against the bug that Emacs 21.x hangs up when scrolling up for
5874 ;; too many number of lines if `scroll-margin' is set as two or greater.
5875 (setq lines (min lines
5876 (max 0 (- (count-lines (window-start) (point-max))
5877 (symbol-value 'scroll-margin))))))
5879 (let ((scroll-in-place nil))
5882 ;; Long lines may cause an end-of-buffer error.
5883 (goto-char (point-max))))
5884 (gnus-article-beginning-of-window))
5886 (defun gnus-article-prev-page (&optional lines)
5887 "Show previous page of current article.
5888 Argument LINES specifies lines to be scrolled down."
5890 (move-to-window-line 0)
5891 (if (and gnus-page-broken
5893 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5895 (gnus-narrow-to-page -1) ;Go to previous page.
5896 (goto-char (point-max))
5900 (let ((scroll-in-place nil))
5901 (scroll-down lines))
5902 (beginning-of-buffer
5903 (goto-char (point-min))))
5904 (gnus-article-beginning-of-window))))
5906 (defun gnus-article-only-boring-p ()
5907 "Decide whether there is only boring text remaining in the article.
5908 Something \"interesting\" is a word of at least two letters that does
5909 not have a face in `gnus-article-boring-faces'."
5910 (when (and gnus-article-skip-boring
5911 (boundp 'gnus-article-boring-faces)
5912 (symbol-value 'gnus-article-boring-faces))
5914 (let ((inhibit-point-motion-hooks t))
5916 (while (re-search-forward "\\b\\w\\w" nil t)
5918 (when (not (gnus-intersection
5919 (gnus-faces-at (point))
5920 (symbol-value 'gnus-article-boring-faces)))
5921 (throw 'only-boring nil)))
5922 (throw 'only-boring t))))))
5924 (defun gnus-article-refer-article ()
5925 "Read article specified by message-id around point."
5928 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
5929 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
5930 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
5931 (let ((msg-id (concat "<" (match-string 0) ">")))
5932 (set-buffer gnus-summary-buffer)
5933 (gnus-summary-refer-article msg-id))
5934 (error "No references around point"))))
5936 (defun gnus-article-show-summary ()
5937 "Reconfigure windows to show summary buffer."
5939 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5940 (error "There is no summary buffer for this article buffer")
5941 (gnus-article-set-globals)
5942 (gnus-configure-windows 'article)
5943 (gnus-summary-goto-subject gnus-current-article)
5944 (gnus-summary-position-point)))
5946 (defun gnus-article-describe-briefly ()
5947 "Describe article mode commands briefly."
5949 (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")))
5951 (defun gnus-article-summary-command ()
5952 "Execute the last keystroke in the summary buffer."
5954 (let ((obuf (current-buffer))
5955 (owin (current-window-configuration))
5957 (switch-to-buffer gnus-article-current-summary 'norecord)
5958 (setq func (lookup-key (current-local-map) (this-command-keys)))
5959 (call-interactively func)
5961 (set-window-configuration owin)
5962 (set-window-point (get-buffer-window (current-buffer)) (point))))
5964 (defun gnus-article-summary-command-nosave ()
5965 "Execute the last keystroke in the summary buffer."
5968 (pop-to-buffer gnus-article-current-summary 'norecord)
5969 (setq func (lookup-key (current-local-map) (this-command-keys)))
5970 (call-interactively func)))
5972 (defun gnus-article-check-buffer ()
5973 "Beep if not in an article buffer."
5974 (unless (eq (get-buffer gnus-article-buffer) (current-buffer))
5975 (error "Command invoked outside of a Gnus article buffer")))
5977 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5978 "Read a summary buffer key sequence and execute it from the article buffer."
5980 (gnus-article-check-buffer)
5982 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5983 "Zc" "ZC" "ZE" "ZJ" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5984 "=" "^" "\M-^" "|"))
5990 '("n" "Gn" "p" "Gp"))
5993 (set-buffer gnus-article-current-summary)
5994 (let (gnus-pick-mode)
5995 (push (or key last-command-event) unread-command-events)
5996 (setq keys (static-if (featurep 'xemacs)
5997 (events-to-keys (read-key-sequence nil))
5998 (read-key-sequence nil)))))
6001 (if (or (member keys nosaves)
6002 (member keys nosave-but-article)
6003 (member keys nosave-in-article))
6005 (save-window-excursion
6006 (pop-to-buffer gnus-article-current-summary 'norecord)
6007 ;; We disable the pick minor mode commands.
6008 (let (gnus-pick-mode)
6009 (setq func (lookup-key (current-local-map) keys))))
6013 (unless (member keys nosave-in-article)
6014 (set-buffer gnus-article-current-summary))
6015 (call-interactively func)
6016 (setq new-sum-point (point)))
6017 (when (member keys nosave-but-article)
6018 (pop-to-buffer gnus-article-buffer 'norecord)))
6019 ;; These commands should restore window configuration.
6020 (let ((obuf (current-buffer))
6021 (owin (current-window-configuration))
6023 win func in-buffer selected new-sum-start new-sum-hscroll)
6024 (cond (not-restore-window
6025 (pop-to-buffer gnus-article-current-summary 'norecord))
6026 ((setq win (get-buffer-window gnus-article-current-summary))
6027 (select-window win))
6029 (switch-to-buffer gnus-article-current-summary 'norecord)))
6030 (setq in-buffer (current-buffer))
6031 ;; We disable the pick minor mode commands.
6032 (if (and (setq func (let (gnus-pick-mode)
6033 (lookup-key (current-local-map) keys)))
6036 (call-interactively func)
6037 (when (eq win (selected-window))
6038 (setq new-sum-point (point)
6039 new-sum-start (window-start win)
6040 new-sum-hscroll (window-hscroll win)))
6041 (when (eq in-buffer (current-buffer))
6042 (setq selected (gnus-summary-select-article))
6044 (unless not-restore-window
6045 (set-window-configuration owin))
6046 (when (eq selected 'old)
6048 (set-window-start (get-buffer-window (current-buffer))
6050 (set-window-point (get-buffer-window (current-buffer))
6052 (when (and (not not-restore-window)
6054 (set-window-point win new-sum-point)
6055 (set-window-start win new-sum-start)
6056 (set-window-hscroll win new-sum-hscroll))))
6057 (set-window-configuration owin)
6060 (defun gnus-article-describe-key (key)
6061 "Display documentation of the function invoked by KEY. KEY is a string."
6062 (interactive "kDescribe key: ")
6063 (gnus-article-check-buffer)
6064 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
6066 (set-buffer gnus-article-current-summary)
6067 (let (gnus-pick-mode)
6068 (if (featurep 'xemacs)
6070 (push (elt key 0) unread-command-events)
6071 (setq key (events-to-keys
6072 (read-key-sequence "Describe key: "))))
6073 (setq unread-command-events
6075 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
6077 (setq key (read-key-sequence "Describe key: "))))
6079 (describe-key key)))
6081 (defun gnus-article-describe-key-briefly (key &optional insert)
6082 "Display documentation of the function invoked by KEY. KEY is a string."
6083 (interactive "kDescribe key: \nP")
6084 (gnus-article-check-buffer)
6085 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
6087 (set-buffer gnus-article-current-summary)
6088 (let (gnus-pick-mode)
6089 (if (featurep 'xemacs)
6091 (push (elt key 0) unread-command-events)
6092 (setq key (events-to-keys
6093 (read-key-sequence "Describe key: "))))
6094 (setq unread-command-events
6096 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
6098 (setq key (read-key-sequence "Describe key: "))))
6099 (describe-key-briefly key insert))
6100 (describe-key-briefly key insert)))
6102 (defun gnus-article-reply-with-original (&optional wide)
6103 "Start composing a reply mail to the current message.
6104 The text in the region will be yanked. If the region isn't active,
6105 the entire article will be yanked."
6107 (let ((article (cdr gnus-article-current))
6109 (if (not (gnus-region-active-p))
6110 (with-current-buffer gnus-summary-buffer
6111 (gnus-summary-reply (list (list article)) wide))
6112 (setq contents (buffer-substring (point) (mark t)))
6113 ;; Deactivate active regions.
6114 (when (and (boundp 'transient-mark-mode)
6115 transient-mark-mode)
6116 (setq mark-active nil))
6117 (with-current-buffer gnus-summary-buffer
6119 (list (list article contents)) wide)))))
6121 (defun gnus-article-followup-with-original ()
6122 "Compose a followup to the current article.
6123 The text in the region will be yanked. If the region isn't active,
6124 the entire article will be yanked."
6126 (let ((article (cdr gnus-article-current))
6128 (if (not (gnus-region-active-p))
6129 (with-current-buffer gnus-summary-buffer
6130 (gnus-summary-followup (list (list article))))
6131 (setq contents (buffer-substring (point) (mark t)))
6132 ;; Deactivate active regions.
6133 (when (and (boundp 'transient-mark-mode)
6134 transient-mark-mode)
6135 (setq mark-active nil))
6136 (with-current-buffer gnus-summary-buffer
6137 (gnus-summary-followup
6138 (list (list article contents)))))))
6140 (defun gnus-article-hide (&optional arg force)
6141 "Hide all the gruft in the current article.
6142 This means that signatures, cited text and (some) headers will be
6144 If given a prefix, show the hidden text instead."
6145 (interactive (append (gnus-article-hidden-arg) (list 'force)))
6146 (gnus-article-hide-headers arg)
6147 (gnus-article-hide-list-identifiers arg)
6148 (gnus-article-hide-citation-maybe arg force)
6149 (gnus-article-hide-signature arg))
6151 (defun gnus-article-maybe-highlight ()
6152 "Do some article highlighting if article highlighting is requested."
6153 (when (gnus-visual-p 'article-highlight 'highlight)
6154 (gnus-article-highlight-some)))
6156 (defun gnus-check-group-server ()
6157 ;; Make sure the connection to the server is alive.
6158 (unless (gnus-server-opened
6159 (gnus-find-method-for-group gnus-newsgroup-name))
6160 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
6161 (gnus-request-group gnus-newsgroup-name t)))
6164 (autoload 'nneething-get-file-name "nneething"))
6166 (defun gnus-request-article-this-buffer (article group)
6167 "Get an article and insert it into this buffer."
6168 (let (do-update-line sparse-header)
6172 (gnus-kill-all-overlays)
6173 (setq group (or group gnus-newsgroup-name))
6175 ;; Using `gnus-request-article' directly will insert the article into
6176 ;; `nntp-server-buffer' - so we'll save some time by not having to
6177 ;; copy it from the server buffer into the article buffer.
6179 ;; We only request an article by message-id when we do not have the
6180 ;; headers for it, so we'll have to get those.
6181 (when (stringp article)
6182 (gnus-read-header article))
6184 ;; If the article number is negative, that means that this article
6185 ;; doesn't belong in this newsgroup (possibly), so we find its
6186 ;; message-id and request it by id instead of number.
6187 (when (and (numberp article)
6189 (get-buffer gnus-summary-buffer)
6190 (gnus-buffer-exists-p gnus-summary-buffer))
6192 (set-buffer gnus-summary-buffer)
6193 (let ((header (gnus-summary-article-header article)))
6196 ((memq article gnus-newsgroup-sparse)
6197 ;; This is a sparse gap article.
6198 (setq do-update-line article)
6199 (setq article (mail-header-id header))
6200 (setq sparse-header (gnus-read-header article))
6201 (setq gnus-newsgroup-sparse
6202 (delq article gnus-newsgroup-sparse)))
6204 ;; It's a real article.
6205 (setq article (mail-header-id header)))
6207 ;; It is an extracted pseudo-article.
6208 (setq article 'pseudo)
6209 (gnus-request-pseudo-article header))))
6211 (let ((method (gnus-find-method-for-group
6212 gnus-newsgroup-name)))
6213 (when (and (eq (car method) 'nneething)
6215 (let ((dir (nneething-get-file-name
6216 (mail-header-id header))))
6217 (when (and (stringp dir)
6218 (file-directory-p dir))
6219 (setq article 'nneething)
6220 (gnus-group-enter-directory dir))))))))
6223 ;; Refuse to select canceled articles.
6224 ((and (numberp article)
6226 (get-buffer gnus-summary-buffer)
6227 (gnus-buffer-exists-p gnus-summary-buffer)
6228 (eq (cdr (with-current-buffer gnus-summary-buffer
6229 (assq article gnus-newsgroup-reads)))
6230 gnus-canceled-mark))
6232 ;; We first check `gnus-original-article-buffer'.
6233 ((and (get-buffer gnus-original-article-buffer)
6235 (with-current-buffer gnus-original-article-buffer
6236 (and (equal (car gnus-original-article) group)
6237 (eq (cdr gnus-original-article) article))))
6238 (insert-buffer-substring gnus-original-article-buffer)
6240 ;; Check the backlog.
6241 ((and gnus-keep-backlog
6242 (gnus-backlog-request-article group article (current-buffer)))
6244 ;; Check asynchronous pre-fetch.
6245 ((gnus-async-request-fetched-article group article (current-buffer))
6246 (gnus-async-prefetch-next group article gnus-summary-buffer)
6247 (when (and (numberp article) gnus-keep-backlog)
6248 (gnus-backlog-enter-article group article (current-buffer)))
6251 ((and gnus-use-cache
6253 (gnus-cache-request-article article group))
6255 ;; Check the agent cache.
6256 ((gnus-agent-request-article article group)
6258 ;; Get the article and put into the article buffer.
6259 ((or (stringp article)
6261 (let ((gnus-override-method gnus-override-method)
6262 (methods (and (stringp article)
6263 gnus-refer-article-method))
6264 (backend (car (gnus-find-method-for-group
6265 gnus-newsgroup-name)))
6267 (inhibit-read-only t))
6268 (if (or (not (listp methods))
6269 (and (symbolp (car methods))
6270 (assq (car methods) nnoo-definition-alist)))
6271 (setq methods (list methods)))
6272 (when (and (null gnus-override-method)
6274 (setq gnus-override-method (pop methods)))
6276 (when (eq gnus-override-method 'current)
6277 (setq gnus-override-method
6278 (with-current-buffer gnus-summary-buffer
6279 gnus-current-select-method)))
6281 (gnus-kill-all-overlays)
6282 (let ((gnus-newsgroup-name group))
6283 (gnus-check-group-server))
6285 ((gnus-request-article article group (current-buffer))
6286 (when (numberp article)
6287 (gnus-async-prefetch-next group article
6288 gnus-summary-buffer)
6289 (when gnus-keep-backlog
6290 (gnus-backlog-enter-article
6291 group article (current-buffer))))
6292 (setq result 'article))
6294 (setq gnus-override-method (pop methods)))
6295 ((not (string-match "^400 "
6296 (nnheader-get-report backend)))
6297 ;; If we get 400 server disconnect, reconnect and
6298 ;; retry; otherwise, assume the article has expired.
6299 (setq result 'done))))
6300 (and (eq result 'article) 'article)))
6304 ;; Associate this article with the current summary buffer.
6305 (setq gnus-article-current-summary gnus-summary-buffer)
6307 ;; Take the article from the original article buffer
6308 ;; and place it in the buffer it's supposed to be in.
6309 (when (and (get-buffer gnus-article-buffer)
6310 (equal (buffer-name (current-buffer))
6311 (buffer-name (get-buffer gnus-article-buffer))))
6313 (if (get-buffer gnus-original-article-buffer)
6314 (set-buffer gnus-original-article-buffer)
6315 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
6316 (buffer-disable-undo)
6317 (setq major-mode 'gnus-original-article-mode)
6318 (setq buffer-read-only t))
6319 (let ((inhibit-read-only t))
6321 (insert-buffer-substring gnus-article-buffer))
6322 (setq gnus-original-article (cons group article)))
6325 (run-hooks 'gnus-article-decode-hook)
6326 ;; Mark article as decoded or not.
6327 (setq gnus-article-decoded-p gnus-article-decode-hook))
6329 ;; Update sparse articles.
6330 (when (and do-update-line
6331 (or (numberp article)
6333 (let ((buf (current-buffer)))
6334 (set-buffer gnus-summary-buffer)
6335 (gnus-summary-update-article do-update-line sparse-header)
6336 (gnus-summary-goto-subject do-update-line nil t)
6337 (set-window-point (gnus-get-buffer-window (current-buffer) t)
6339 (set-buffer buf))))))
6345 (defcustom gnus-article-edit-mode-hook nil
6346 "Hook run in article edit mode buffers."
6347 :group 'gnus-article-various
6350 (defcustom gnus-article-edit-article-setup-function
6351 'gnus-article-mime-edit-article-setup
6352 "Function called to setup an editing article buffer."
6353 :group 'gnus-article-various
6356 (defvar gnus-article-edit-done-function nil)
6358 (defvar gnus-article-edit-mode-map nil)
6360 ;; Should we be using derived.el for this?
6361 (unless gnus-article-edit-mode-map
6362 (setq gnus-article-edit-mode-map (make-keymap))
6363 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
6365 (gnus-define-keys gnus-article-edit-mode-map
6366 "\C-c?" describe-mode
6367 "\C-c\C-c" gnus-article-edit-done
6368 "\C-c\C-k" gnus-article-edit-exit
6369 "\C-c\C-f\C-t" message-goto-to
6370 "\C-c\C-f\C-o" message-goto-from
6371 "\C-c\C-f\C-b" message-goto-bcc
6372 ;;"\C-c\C-f\C-w" message-goto-fcc
6373 "\C-c\C-f\C-c" message-goto-cc
6374 "\C-c\C-f\C-s" message-goto-subject
6375 "\C-c\C-f\C-r" message-goto-reply-to
6376 "\C-c\C-f\C-n" message-goto-newsgroups
6377 "\C-c\C-f\C-d" message-goto-distribution
6378 "\C-c\C-f\C-f" message-goto-followup-to
6379 "\C-c\C-f\C-m" message-goto-mail-followup-to
6380 "\C-c\C-f\C-k" message-goto-keywords
6381 "\C-c\C-f\C-u" message-goto-summary
6382 "\C-c\C-f\C-i" message-insert-or-toggle-importance
6383 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
6384 "\C-c\C-b" message-goto-body
6385 "\C-c\C-i" message-goto-signature
6387 "\C-c\C-t" message-insert-to
6388 "\C-c\C-n" message-insert-newsgroups
6389 "\C-c\C-o" message-sort-headers
6390 "\C-c\C-e" message-elide-region
6391 "\C-c\C-v" message-delete-not-region
6392 "\C-c\C-z" message-kill-to-signature
6393 "\M-\r" message-newline-and-reformat
6394 "\C-c\C-a" mml-attach-file
6395 "\C-a" message-beginning-of-line
6397 "\M-;" comment-region)
6399 (gnus-define-keys (gnus-article-edit-wash-map
6400 "\C-c\C-w" gnus-article-edit-mode-map)
6401 "f" gnus-article-edit-full-stops))
6404 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
6406 ["Fetch To" message-insert-to t]
6407 ["Fetch Newsgroups" message-insert-newsgroups t]
6409 ["To" message-goto-to t]
6410 ["From" message-goto-from t]
6411 ["Subject" message-goto-subject t]
6412 ["Cc" message-goto-cc t]
6413 ["Reply-To" message-goto-reply-to t]
6414 ["Summary" message-goto-summary t]
6415 ["Keywords" message-goto-keywords t]
6416 ["Newsgroups" message-goto-newsgroups t]
6417 ["Followup-To" message-goto-followup-to t]
6418 ["Mail-Followup-To" message-goto-mail-followup-to t]
6419 ["Distribution" message-goto-distribution t]
6420 ["Body" message-goto-body t]
6421 ["Signature" message-goto-signature t]))
6423 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
6424 "Major mode for editing articles.
6425 This is an extended text-mode.
6427 \\{gnus-article-edit-mode-map}"
6428 (make-local-variable 'gnus-article-edit-done-function)
6429 (make-local-variable 'gnus-prev-winconf)
6430 (set (make-local-variable 'font-lock-defaults)
6431 '(message-font-lock-keywords t))
6432 (set (make-local-variable 'mail-header-separator) "")
6433 (set (make-local-variable 'gnus-article-edit-mode) t)
6434 (easy-menu-add message-mode-field-menu message-mode-map)
6435 (setq buffer-read-only nil)
6436 (buffer-enable-undo)
6439 (defun gnus-article-edit (&optional force)
6440 "Edit the current article.
6441 This will have permanent effect only in mail groups.
6442 If FORCE is non-nil, allow editing of articles even in read-only
6445 (when (and (not force)
6446 (gnus-group-read-only-p))
6447 (error "The current newsgroup does not support article editing"))
6448 (gnus-article-date-original)
6449 (gnus-article-edit-article
6451 `(lambda (no-highlight)
6453 (gnus-summary-edit-article-done
6454 ,(or (mail-header-references gnus-current-headers) "")
6455 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
6457 (defun gnus-article-edit-article (start-func exit-func &optional quiet)
6458 "Start editing the contents of the current article buffer."
6459 (let ((winconf (current-window-configuration)))
6460 (set-buffer gnus-article-buffer)
6461 (let ((message-auto-save-directory
6462 ;; Don't associate the article buffer with a draft file.
6464 (gnus-article-edit-mode))
6465 (funcall start-func)
6466 (set-buffer-modified-p nil)
6467 (gnus-configure-windows 'edit-article)
6468 (setq gnus-article-edit-done-function exit-func)
6469 (setq gnus-prev-winconf winconf)
6470 (when gnus-article-edit-article-setup-function
6471 (funcall gnus-article-edit-article-setup-function))
6473 (gnus-message 6 "C-c C-c to end edits; C-c C-k to exit"))))
6475 (defun gnus-article-edit-done (&optional arg)
6476 "Update the article edits and exit."
6478 (let ((func gnus-article-edit-done-function)
6479 (buf (current-buffer))
6480 (start (window-start))
6482 (winconf gnus-prev-winconf))
6483 (remove-hook 'gnus-article-mode-hook
6484 'gnus-article-mime-edit-article-unwind)
6485 (widen) ;; Widen it in case that users narrowed the buffer.
6488 ;; The cache and backlog have to be flushed somewhat.
6489 (when gnus-keep-backlog
6490 (gnus-backlog-remove-article
6491 (car gnus-article-current) (cdr gnus-article-current)))
6492 ;; Flush original article as well.
6494 (when (get-buffer gnus-original-article-buffer)
6495 (set-buffer gnus-original-article-buffer)
6496 (setq gnus-original-article nil)))
6497 (when gnus-use-cache
6498 (gnus-cache-update-article
6499 (car gnus-article-current) (cdr gnus-article-current)))
6500 ;; We remove all text props from the article buffer.
6501 (kill-all-local-variables)
6502 (set-text-properties (point-min) (point-max) nil)
6504 (set-window-configuration winconf)
6506 (set-window-start (get-buffer-window buf) start)
6507 (set-window-point (get-buffer-window buf) (point)))
6508 (gnus-summary-show-article))
6510 (defun gnus-article-edit-exit ()
6511 "Exit the article editing without updating."
6513 (when (or (not (buffer-modified-p))
6514 (yes-or-no-p "Article modified; kill anyway? "))
6515 (let ((curbuf (current-buffer))
6517 (window-start (window-start)))
6519 (if (gnus-buffer-live-p gnus-original-article-buffer)
6520 (insert-buffer-substring gnus-original-article-buffer))
6521 (let ((winconf gnus-prev-winconf))
6522 (kill-all-local-variables)
6524 (set-window-configuration winconf)
6525 ;; Tippy-toe some to make sure that point remains where it was.
6526 (save-current-buffer
6528 (set-window-start (get-buffer-window (current-buffer)) window-start)
6530 (gnus-summary-show-article)))
6532 (defun gnus-article-edit-full-stops ()
6533 "Interactively repair spacing at end of sentences."
6536 (goto-char (point-min))
6537 (search-forward-regexp "^$" nil t)
6538 (let ((case-fold-search nil))
6539 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
6542 ;;; Article editing with MIME-Edit
6545 (defcustom gnus-article-mime-edit-article-setup-hook nil
6546 "Hook run after setting up a MIME editing article buffer."
6547 :group 'gnus-article-various
6550 (defun gnus-article-mime-edit-article-unwind ()
6551 "Unwind `gnus-article-buffer' if article editing was given up."
6552 (remove-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6553 (when (featurep 'font-lock)
6554 (setq font-lock-defaults nil)
6555 (font-lock-mode -1))
6556 (when mime-edit-mode-flag
6557 (mime-edit-exit 'nomime 'no-error)
6560 (defun gnus-article-mime-edit-article-setup ()
6561 "Convert current buffer to MIME-Edit buffer and turn on MIME-Edit mode
6562 after replacing with the original article."
6563 (setq gnus-show-mime t)
6564 (setq gnus-article-edit-done-function
6565 `(lambda (&rest args)
6566 (when mime-edit-mode-flag
6567 (let (mime-edit-insert-user-agent-field)
6570 (goto-char (point-min))
6571 (let (case-fold-search)
6572 (when (re-search-forward
6573 (format "^%s$" (regexp-quote mail-header-separator))
6575 (replace-match "")))
6576 (apply ,gnus-article-edit-done-function args)
6579 (buffer-substring-no-properties (point-min) (point-max))
6580 (set-buffer (get-buffer-create gnus-original-article-buffer))
6582 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6583 (set-buffer gnus-article-buffer)
6584 (gnus-article-prepare-display)))
6585 (substitute-key-definition 'gnus-article-edit-done
6586 'gnus-article-mime-edit-done
6587 gnus-article-edit-mode-map)
6588 (substitute-key-definition 'gnus-article-edit-exit
6589 'gnus-article-mime-edit-exit
6590 gnus-article-edit-mode-map)
6592 (insert-buffer-substring gnus-original-article-buffer)
6593 (unless (member (with-current-buffer gnus-summary-buffer
6594 gnus-newsgroup-name)
6595 '("nndraft:delayed" "nndraft:drafts"))
6596 (let ((ofn (symbol-function 'mime-edit-decode-single-part-in-buffer)))
6597 (fset 'mime-edit-decode-single-part-in-buffer
6598 (lambda (&rest args)
6599 (if (let ((content-type (car args)))
6600 (and (eq 'message (mime-content-type-primary-type
6602 (eq 'rfc822 (mime-content-type-subtype
6604 (setcar (cdr args) 'not-decode-text))
6608 (fset 'mime-edit-decode-single-part-in-buffer ofn))))
6609 (when (featurep 'font-lock)
6610 (set (make-local-variable 'font-lock-defaults)
6611 '(message-font-lock-keywords t))
6612 (font-lock-set-defaults)
6613 (turn-on-font-lock))
6614 (set-buffer-modified-p nil)
6615 (delete-other-windows)
6616 (add-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6617 (gnus-run-hooks 'gnus-article-mime-edit-article-setup-hook))
6619 (defun gnus-article-mime-edit-done (&optional arg)
6620 "Update the article MIME edits and exit."
6622 (when (featurep 'font-lock)
6623 (setq font-lock-defaults nil)
6624 (font-lock-mode -1))
6625 (let ((inhibit-read-only t))
6626 (gnus-article-edit-done arg)))
6628 (defun gnus-article-mime-edit-exit ()
6629 "Exit the article MIME editing without updating."
6631 (when (or (not (buffer-modified-p))
6632 (yes-or-no-p "Article modified; kill anyway? "))
6633 (when (featurep 'font-lock)
6634 (setq font-lock-defaults nil)
6635 (font-lock-mode -1))
6636 (when mime-edit-mode-flag
6637 (let (mime-edit-insert-user-agent-field)
6640 (goto-char (point-min))
6641 (let (case-fold-search)
6642 (when (re-search-forward
6643 (format "^%s$" (regexp-quote mail-header-separator)) nil t)
6644 (replace-match "")))
6645 (let ((winconf gnus-prev-winconf))
6647 (buffer-substring-no-properties (point-min) (point-max))
6648 (set-buffer (get-buffer-create gnus-original-article-buffer))
6650 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6651 (set-buffer gnus-article-buffer)
6652 (gnus-article-prepare-display)
6653 (set-window-configuration winconf))))
6656 ;;; Article highlights
6659 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
6661 ;;; Internal Variables:
6663 (defcustom gnus-button-url-regexp
6664 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
6665 "\\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:]]\\)"
6666 "\\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\\)\\)")
6667 "Regular expression that matches URLs."
6668 :group 'gnus-article-buttons
6671 (defcustom gnus-button-valid-fqdn-regexp
6672 message-valid-fqdn-regexp
6673 "Regular expression that matches a valid FQDN."
6675 :group 'gnus-article-buttons
6678 ;; Regexp suggested by Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
6679 (defcustom gnus-button-valid-localpart-regexp
6680 "[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t ]*"
6681 "Regular expression that matches a localpart of mail addresses or MIDs."
6683 :group 'gnus-article-buttons
6686 (defcustom gnus-button-man-handler 'manual-entry
6687 "Function to use for displaying man pages.
6688 The function must take at least one argument with a string naming the
6691 :type '(choice (function-item :tag "Man" manual-entry)
6692 (function-item :tag "Woman" woman)
6693 (function :tag "Other"))
6694 :group 'gnus-article-buttons)
6696 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
6697 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
6698 If the default site is too slow, try to find a CTAN mirror, see
6699 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
6700 the variable `gnus-button-handle-ctan'."
6702 :group 'gnus-article-buttons
6703 :link '(custom-manual "(gnus)Group Parameters")
6704 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
6705 (const "http://tug.ctan.org/tex-archive/")
6706 (const "http://www.dante.de/CTAN/")
6707 (string :tag "Other")))
6709 (defcustom gnus-button-ctan-handler 'browse-url
6710 "Function to use for displaying CTAN links.
6711 The function must take one argument, the string naming the URL."
6713 :type '(choice (function-item :tag "Browse Url" browse-url)
6714 (function :tag "Other"))
6715 :group 'gnus-article-buttons)
6717 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
6718 "Bogus strings removed from CTAN URLs."
6720 :group 'gnus-article-buttons
6721 :type '(choice (const "^/?tex-archive/\\|/")
6722 (regexp :tag "Other")))
6724 (defcustom gnus-button-ctan-directory-regexp
6726 (list "archive-tools" "biblio" "bibliography" "digests" "documentation"
6727 "dviware" "fonts" "graphics" "help" "indexing" "info" "language"
6728 "languages" "macros" "nonfree" "obsolete" "support" "systems"
6729 "tds" "tools" "usergrps" "web") t)
6730 "Regular expression for ctan directories.
6731 It should match all directories in the top level of `gnus-ctan-url'."
6733 :group 'gnus-article-buttons
6736 (defcustom gnus-button-mid-or-mail-regexp
6737 (concat "\\b\\(<?" gnus-button-valid-localpart-regexp "@"
6738 gnus-button-valid-fqdn-regexp
6740 "Regular expression that matches a message ID or a mail address."
6742 :group 'gnus-article-buttons
6745 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
6746 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
6747 Strings like this can be either a message ID or a mail address. If it is one
6748 of the symbols `mid' or `mail', Gnus will always assume that the string is a
6749 message ID or a mail address, respectively. If this variable is set to the
6750 symbol `ask', always query the user what do do. If it is a function, this
6751 function will be called with the string as it's only argument. The function
6752 must return `mid', `mail', `invalid' or `ask'."
6754 :group 'gnus-article-buttons
6755 :type '(choice (function-item :tag "Heuristic function"
6756 gnus-button-mid-or-mail-heuristic)
6761 (defcustom gnus-button-mid-or-mail-heuristic-alist
6762 '((-10.0 . ".+\\$.+@")
6765 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
6766 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
6767 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
6768 (-1.0 . "^[^a-z]+@")
6770 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
6771 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
6772 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
6773 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
6776 (-1.0 . "^[0-9][0-9]")
6778 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
6779 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6780 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
6781 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6783 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
6784 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
6787 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
6789 ;; compensation for TDMA dated mail addresses:
6790 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
6792 (-20.0 . "\\.fsf@") ;; Gnus
6795 (-20.0 . "_-_") ;; Subject change in thread
6797 (-20.0 . "\\.ln@") ;; leafnode
6798 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
6799 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
6801 ;; (5.0 . "") ;; $local_part_len <= 7
6802 (10.0 . "^[^0-9]+@")
6803 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
6804 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
6807 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
6809 (0.5 . "^[A-Z][a-z]")
6810 (0.5 . "^[A-Z][a-z][a-z]")
6811 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
6812 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
6813 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
6815 A negative RATE indicates a message IDs, whereas a positive indicates a mail
6816 address. The REGEXP is processed with `case-fold-search' set to nil."
6818 :group 'gnus-article-buttons
6819 :type '(repeat (cons (number :tag "Rate")
6820 (regexp :tag "Regexp"))))
6822 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
6823 "Guess whether MID-OR-MAIL is a message ID or a mail address.
6824 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
6825 address, `ask' if unsure and `invalid' if the string is invalid."
6826 (let ((case-fold-search nil)
6827 (list gnus-button-mid-or-mail-heuristic-alist)
6828 (result 0) rate regexp lpartlen elem)
6830 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
6831 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
6832 ;; Certain special cases...
6835 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
6836 "^[0-9]+\\.[0-9]+@compuserve\\|"
6837 "@public\\.gmane\\.org")
6839 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
6840 (setq result 'mail))
6841 (when (string-match "@.*@\\| " mid-or-mail)
6842 (gnus-message 8 "`%s' is invalid." mid-or-mail)
6843 (setq result 'invalid))
6844 ;; Nothing more to do, if result is not a number here...
6845 (when (numberp result)
6847 (setq elem (car list)
6851 (when (string-match regexp mid-or-mail)
6852 (setq result (+ result rate))
6854 9 "`%s' matched `%s', rate `%s', result `%s'."
6855 mid-or-mail regexp rate result)))
6856 (when (<= lpartlen 7)
6857 (setq result (+ result 5.0))
6858 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
6859 mid-or-mail result))
6860 (when (>= lpartlen 12)
6861 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
6863 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
6864 ;; Long local part should contain realname if e-mail address,
6865 ;; too many digits: message-id.
6866 ;; $score -= 5.0 + 0.1 * $local_part_len;
6867 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6868 (setq result (+ result rate))
6870 9 "Many digits in `%s', rate `%s', result `%s'."
6871 mid-or-mail rate result))
6872 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6874 ;; Too few vowels [^aeiouy]{4,}.*\@
6875 (setq result (+ result -5.0))
6877 9 "Few vowels in `%s', rate `%s', result `%s'."
6878 mid-or-mail -5.0 result))
6880 (setq result (+ result 5.0))
6882 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6883 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6884 ;; Maybe we should make this a customizable alist: (condition . 'result)
6886 ((symbolp result) result)
6887 ;; Now convert number into proper results:
6888 ((< result -10.0) 'mid)
6889 ((> result 10.0) 'mail)
6892 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6893 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6894 (url-mid (concat "news" ":" mid-or-mail))
6895 (url-mailto (concat "mailto" ":" mid-or-mail)))
6896 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6897 (when (fboundp pref)
6899 ;; get rid of surrounding angles...
6901 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6902 (if (or (eq 'mid guessed) (eq 'mail guessed))
6906 (save-window-excursion
6907 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6910 (cond ((eq pref 'mid)
6911 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6912 (gnus-button-handle-news url-mid))
6914 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6915 (gnus-url-mailto url-mailto))
6916 (t (gnus-message 3 "Invalid string.")))))
6918 (defun gnus-button-handle-custom (fun arg)
6919 "Call function FUN on argument ARG.
6920 Both FUN and ARG are supposed to be strings. ARG will be passed
6921 as a symbol to FUN."
6922 (funcall (intern fun) (intern arg)))
6924 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6926 ;; FIXME: Maybe we should merge some of the functions that do quite similar
6929 (defun gnus-button-handle-describe-function (url)
6930 "Call `describe-function' when pushing the corresponding URL button."
6933 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6935 (defun gnus-button-handle-describe-variable (url)
6936 "Call `describe-variable' when pushing the corresponding URL button."
6939 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6941 (defun gnus-button-handle-symbol (url)
6942 "Display help on variable or function.
6943 Calls `describe-variable' or `describe-function'."
6944 (let ((sym (intern url)))
6946 ((fboundp sym) (describe-function sym))
6947 ((boundp sym) (describe-variable sym))
6948 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
6950 (defun gnus-button-handle-describe-key (url)
6951 "Call `describe-key' when pushing the corresponding URL button."
6953 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6954 (keys (ignore-errors (eval `(kbd ,key-string)))))
6957 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6959 (defun gnus-button-handle-apropos (url)
6960 "Call `apropos' when pushing the corresponding URL button."
6961 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6963 (defun gnus-button-handle-apropos-command (url)
6964 "Call `apropos' when pushing the corresponding URL button."
6966 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6968 (defun gnus-button-handle-apropos-variable (url)
6969 "Call `apropos' when pushing the corresponding URL button."
6971 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6972 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6974 (defun gnus-button-handle-apropos-documentation (url)
6975 "Call `apropos' when pushing the corresponding URL button."
6977 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6978 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6980 (defun gnus-button-handle-library (url)
6981 "Call `locate-library' when pushing the corresponding URL button."
6982 (gnus-message 9 "url=`%s'" url)
6983 (let* ((lib (locate-library url))
6984 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6986 (gnus-message 1 "Cannot locale library `%s'." url)
6987 (find-file-read-only file))))
6989 (defun gnus-button-handle-ctan (url)
6990 "Call `browse-url' when pushing a CTAN URL button."
6992 gnus-button-ctan-handler
6995 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6997 (defcustom gnus-button-tex-level 5
6998 "*Integer that says how many TeX-related buttons Gnus will show.
6999 The higher the number, the more buttons will appear and the more false
7000 positives are possible. Note that you can set this variable local to
7001 specific groups. Setting it higher in TeX groups is probably a good idea.
7002 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
7003 how to set variables in specific groups."
7005 :group 'gnus-article-buttons
7006 :link '(custom-manual "(gnus)Group Parameters")
7009 (defcustom gnus-button-man-level 5
7010 "*Integer that says how many man-related buttons Gnus will show.
7011 The higher the number, the more buttons will appear and the more false
7012 positives are possible. Note that you can set this variable local to
7013 specific groups. Setting it higher in Unix groups is probably a good idea.
7014 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
7015 how to set variables in specific groups."
7017 :group 'gnus-article-buttons
7018 :link '(custom-manual "(gnus)Group Parameters")
7021 (defcustom gnus-button-emacs-level 5
7022 "*Integer that says how many emacs-related buttons Gnus will show.
7023 The higher the number, the more buttons will appear and the more false
7024 positives are possible. Note that you can set this variable local to
7025 specific groups. Setting it higher in Emacs or Gnus related groups is
7026 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
7027 `gnus-parameters' on how to set variables in specific groups."
7029 :group 'gnus-article-buttons
7030 :link '(custom-manual "(gnus)Group Parameters")
7033 (defcustom gnus-button-message-level 5
7034 "*Integer that says how many buttons for news or mail messages will appear.
7035 The higher the number, the more buttons will appear and the more false
7036 positives are possible."
7037 ;; mail addresses, MIDs, URLs for news, ...
7039 :group 'gnus-article-buttons
7042 (defcustom gnus-button-browse-level 5
7043 "*Integer that says how many buttons for browsing will appear.
7044 The higher the number, the more buttons will appear and the more false
7045 positives are possible."
7046 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
7048 :group 'gnus-article-buttons
7051 (defcustom gnus-button-alist
7052 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
7053 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
7054 ((concat "\\b\\(nntp\\|news\\):\\("
7055 gnus-button-valid-localpart-regexp "@[a-z0-9.-]+[a-z]\\)")
7056 0 t gnus-button-handle-news 2)
7057 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
7058 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
7059 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
7060 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
7061 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
7062 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
7063 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
7064 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
7065 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
7066 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
7067 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
7068 ;; RFC 2368 (The mailto URL scheme)
7069 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
7070 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
7071 ("\\bmailto:\\([^ \n\t]+\\)"
7072 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
7074 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
7075 gnus-button-ctan-directory-regexp
7076 "[^][>)!;:,'\n\t ]+\\)")
7077 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
7078 ((concat "\\btex-archive/\\("
7079 gnus-button-ctan-directory-regexp
7080 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
7081 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
7084 gnus-button-ctan-directory-regexp
7085 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
7086 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
7087 ;; This is info (home-grown style) <info://foo/bar+baz>
7088 ("\\binfo://\\([^'\">\n\t ]+\\)"
7089 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
7090 ;; Info GNOME style <info:foo#bar_baz>
7091 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
7092 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
7093 ;; Info KDE style <info:(foo)bar baz>
7094 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
7095 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
7096 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
7097 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
7098 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
7099 ;; Info links like `C-h i d m CC Mode RET'
7100 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
7102 ("M-x[ \t\n]\\(customize-[^ ]+\\)[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
7103 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1 2)
7104 ;; Emacs help commands
7105 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
7106 ;; regexp doesn't match arguments containing ` '.
7107 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
7108 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
7109 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
7110 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
7111 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
7112 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
7113 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
7114 ;; The following entries may lead to many false positives so don't enable
7115 ;; them by default (use a high button level).
7116 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
7117 ;; Exclude [.?] for URLs in gmane.emacs.cvs
7118 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
7119 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
7120 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
7121 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
7122 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
7123 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
7124 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
7125 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
7126 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
7127 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
7128 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
7129 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
7130 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
7131 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
7132 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
7133 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
7134 ;; Unlike the other regexps we really have to require quoting
7135 ;; here to determine where it ends.
7136 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
7137 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
7138 ("<URL: *\\([^<>]*\\)>"
7139 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
7140 ;; RFC 2396 (2.4.3., delims) ...
7141 ("\"URL: *\\([^\"]*\\)\""
7142 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
7143 ;; RFC 2396 (2.4.3., delims) ...
7144 ("\"URL: *\\([^\"]*\\)\""
7145 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
7147 (gnus-button-url-regexp
7148 0 (>= gnus-button-browse-level 0) browse-url 0)
7150 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
7151 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
7152 gnus-button-handle-man 1)
7153 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
7154 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
7155 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
7156 gnus-button-handle-man 1)
7157 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
7158 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
7159 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
7160 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
7161 ;; MID or mail: To avoid too many false positives we don't try to catch
7162 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
7163 ;; at least one dot. TLD must contain two or three chars or be a know TLD
7164 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
7165 ;; so that non-ambiguous entries (see above) match first.
7166 (gnus-button-mid-or-mail-regexp
7167 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
7168 "*Alist of regexps matching buttons in article bodies.
7170 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
7171 REGEXP: is the string (case insensitive) matching text around the button (can
7172 also be Lisp expression evaluating to a string),
7173 BUTTON: is the number of the regexp grouping actually matching the button,
7174 FORM: is a Lisp expression which must eval to true for the button to
7176 CALLBACK: is the function to call when the user push this button, and each
7177 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
7179 CALLBACK can also be a variable, in that case the value of that
7180 variable it the real callback function."
7181 :group 'gnus-article-buttons
7182 :type '(repeat (list (choice regexp variable sexp)
7183 (integer :tag "Button")
7185 (function :tag "Callback")
7188 (integer :tag "Regexp group")))))
7190 (defcustom gnus-header-button-alist
7191 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
7192 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
7193 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
7194 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
7195 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
7196 0 (>= gnus-button-message-level 0) gnus-msg-mail 0)
7197 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
7198 0 (>= gnus-button-browse-level 0) browse-url 0)
7199 ("^Subject:" gnus-button-url-regexp
7200 0 (>= gnus-button-browse-level 0) browse-url 0)
7201 ("^[^:]+:" gnus-button-url-regexp
7202 0 (>= gnus-button-browse-level 0) browse-url 0)
7203 ("^OpenPGP:.*url=" gnus-button-url-regexp
7204 0 (>= gnus-button-browse-level 0) gnus-button-openpgp 0)
7205 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
7206 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
7207 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
7208 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
7209 "*Alist of headers and regexps to match buttons in article heads.
7211 This alist is very similar to `gnus-button-alist', except that each
7212 alist has an additional HEADER element first in each entry:
7214 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
7216 HEADER is a regexp to match a header. For a fuller explanation, see
7217 `gnus-button-alist'."
7218 :group 'gnus-article-buttons
7219 :group 'gnus-article-headers
7220 :type '(repeat (list (regexp :tag "Header")
7221 (choice regexp variable)
7222 (integer :tag "Button")
7224 (function :tag "Callback")
7227 (integer :tag "Regexp group")))))
7231 (defun gnus-article-push-button (event)
7232 "Check text under the mouse pointer for a callback function.
7233 If the text under the mouse pointer has a `gnus-callback' property,
7234 call it with the value of the `gnus-data' text property."
7236 (set-buffer (window-buffer (posn-window (event-start event))))
7237 (let* ((pos (posn-point (event-start event)))
7238 (data (get-text-property pos 'gnus-data))
7239 (fun (get-text-property pos 'gnus-callback)))
7242 (funcall fun data))))
7244 (defun gnus-article-press-button ()
7245 "Check text at point for a callback function.
7246 If the text at point has a `gnus-callback' property,
7247 call it with the value of the `gnus-data' text property."
7249 (let ((data (get-text-property (point) 'gnus-data))
7250 (fun (get-text-property (point) 'gnus-callback)))
7252 (funcall fun data))))
7254 (defun gnus-article-prev-button (n)
7255 "Move point to N buttons backward.
7256 If N is negative, move forward instead."
7258 (gnus-article-next-button (- n)))
7260 (defun gnus-article-next-button (n)
7261 "Move point to N buttons forward.
7262 If N is negative, move backward instead."
7264 (let ((function (if (< n 0) 'previous-single-property-change
7265 'next-single-property-change))
7266 (inhibit-point-motion-hooks t)
7268 (limit (if (< n 0) (point-min) (point-max))))
7270 (while (and (not (= limit (point)))
7272 ;; Skip past the current button.
7273 (when (get-text-property (point) 'gnus-callback)
7274 (goto-char (funcall function (point) 'gnus-callback nil limit)))
7275 ;; Go to the next (or previous) button.
7276 (gnus-goto-char (funcall function (point) 'gnus-callback nil limit))
7277 ;; Put point at the start of the button.
7278 (when (and backward (not (get-text-property (point) 'gnus-callback)))
7279 (goto-char (funcall function (point) 'gnus-callback nil limit)))
7280 ;; Skip past intangible buttons.
7281 (when (get-text-property (point) 'intangible)
7285 (gnus-message 5 "No more buttons"))
7288 (defun gnus-article-highlight (&optional force)
7289 "Highlight current article.
7290 This function calls `gnus-article-highlight-headers',
7291 `gnus-article-highlight-citation',
7292 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
7293 do the highlighting. See the documentation for those functions."
7294 (interactive (list 'force))
7295 (gnus-article-highlight-headers)
7296 (gnus-article-highlight-citation force)
7297 (gnus-article-highlight-signature)
7298 (gnus-article-add-buttons force)
7299 (gnus-article-add-buttons-to-head))
7301 (defun gnus-article-highlight-some (&optional force)
7302 "Highlight current article.
7303 This function calls `gnus-article-highlight-headers',
7304 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
7305 do the highlighting. See the documentation for those functions."
7306 (interactive (list 'force))
7307 (gnus-article-highlight-headers)
7308 (gnus-article-highlight-signature)
7309 (gnus-article-add-buttons))
7311 (defun gnus-article-highlight-headers ()
7312 "Highlight article headers as specified by `gnus-header-face-alist'."
7314 (gnus-with-article-headers
7315 (let (regexp header-face field-face from hpoints fpoints)
7316 (dolist (entry gnus-header-face-alist)
7317 (goto-char (point-min))
7318 (setq regexp (concat "^\\("
7319 (if (string-equal "" (nth 0 entry))
7323 header-face (nth 1 entry)
7324 field-face (nth 2 entry))
7325 (while (and (re-search-forward regexp nil t)
7329 (unless (search-forward ":" nil t)
7331 (when (and header-face
7332 (not (memq (point) hpoints)))
7333 (push (point) hpoints)
7334 (gnus-put-text-property from (point) 'face header-face))
7335 (when (and field-face
7336 (not (memq (setq from (point)) fpoints)))
7338 (if (re-search-forward "^[^ \t]" nil t)
7340 (goto-char (point-max)))
7341 (gnus-put-text-property from (point) 'face field-face)))))))
7343 (defun gnus-article-highlight-signature ()
7344 "Highlight the signature in an article.
7345 It does this by highlighting everything after
7346 `gnus-signature-separator' using the face `gnus-signature'."
7348 (when gnus-signature-face
7349 (gnus-with-article-buffer
7350 (let ((inhibit-point-motion-hooks t))
7352 (when (gnus-article-narrow-to-signature)
7353 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
7354 'face gnus-signature-face)))))))
7356 (defun gnus-article-buttonize-signature ()
7357 "Add button to the signature."
7360 (set-buffer gnus-article-buffer)
7361 (let ((inhibit-read-only t)
7362 (inhibit-point-motion-hooks t))
7363 (when (gnus-article-search-signature)
7364 (gnus-article-add-button (match-beginning 0) (match-end 0)
7365 'gnus-signature-toggle
7366 (set-marker (make-marker)
7367 (1+ (match-end 0))))))))
7369 (defun gnus-button-in-region-p (b e prop)
7370 "Say whether PROP exists in the region."
7371 (text-property-not-all b e prop nil))
7373 (defun gnus-article-add-buttons (&optional force)
7374 "Find external references in the article and make buttons of them.
7375 \"External references\" are things like Message-IDs and URLs, as
7376 specified by `gnus-button-alist'."
7377 (interactive (list 'force))
7378 (gnus-with-article-buffer
7379 (let ((inhibit-point-motion-hooks t)
7380 (case-fold-search t)
7381 (alist gnus-button-alist)
7383 ;; Remove all old markers.
7384 (let (marker entry new-list)
7385 (while (setq marker (pop gnus-button-marker-list))
7386 (if (or (< marker (point-min)) (>= marker (point-max)))
7387 (push marker new-list)
7389 (when (setq entry (gnus-button-entry))
7390 (put-text-property (match-beginning (nth 1 entry))
7391 (match-end (nth 1 entry))
7392 'gnus-callback nil))
7393 (set-marker marker nil)))
7394 (setq gnus-button-marker-list new-list))
7395 ;; We skip the headers.
7398 (while (setq entry (pop alist))
7399 (setq regexp (eval (car entry)))
7401 (while (re-search-forward regexp nil t)
7402 (let* ((start (and entry (match-beginning (nth 1 entry))))
7403 (end (and entry (match-end (nth 1 entry))))
7404 (from (match-beginning 0)))
7405 (when (and (or (eq t (nth 2 entry))
7406 (eval (nth 2 entry)))
7407 (not (gnus-button-in-region-p
7408 start end 'gnus-callback)))
7409 ;; That optional form returned non-nil, so we add the
7411 (gnus-article-add-button
7412 start end 'gnus-button-push
7413 (car (push (set-marker (make-marker) from)
7414 gnus-button-marker-list))))))))))
7416 ;; Add buttons to the head of an article.
7417 (defun gnus-article-add-buttons-to-head ()
7418 "Add buttons to the head of the article."
7420 (gnus-with-article-headers
7422 (dolist (entry gnus-header-button-alist)
7423 ;; Each alist entry.
7424 (goto-char (point-min))
7425 (while (re-search-forward (car entry) nil t)
7426 ;; Each header matching the entry.
7427 (setq beg (match-beginning 0))
7428 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
7429 (match-beginning 0))
7432 (while (re-search-forward (eval (nth 1 entry)) end t)
7433 ;; Each match within a header.
7434 (let* ((entry (cdr entry))
7435 (start (match-beginning (nth 1 entry)))
7436 (end (match-end (nth 1 entry)))
7437 (form (nth 2 entry)))
7438 (goto-char (match-end 0))
7440 (gnus-article-add-button
7441 start end (nth 3 entry)
7442 (buffer-substring (match-beginning (nth 4 entry))
7443 (match-end (nth 4 entry)))))))
7444 (goto-char end))))))
7446 ;;; External functions:
7448 (defun gnus-article-add-button (from to fun &optional data)
7449 "Create a button between FROM and TO with callback FUN and data DATA."
7450 (when gnus-article-button-face
7451 (gnus-overlay-put (gnus-make-overlay from to)
7452 'face gnus-article-button-face))
7453 (gnus-add-text-properties
7455 (nconc (and gnus-article-mouse-face
7456 (list gnus-mouse-face-prop gnus-article-mouse-face))
7457 (list 'gnus-callback fun)
7458 (and data (list 'gnus-data data))))
7459 (widget-convert-button 'link from to :action 'gnus-widget-press-button
7460 :button-keymap gnus-widget-button-keymap))
7462 ;;; Internal functions:
7464 (defun gnus-article-set-globals ()
7465 (with-current-buffer gnus-summary-buffer
7466 (gnus-set-global-variables)))
7468 (defun gnus-signature-toggle (end)
7469 (gnus-with-article-buffer
7470 (let ((inhibit-point-motion-hooks t)
7471 (limit (next-single-property-change end 'mime-view-entity
7473 (if (text-property-any end limit 'article-type 'signature)
7475 (gnus-delete-wash-type 'signature)
7476 (gnus-remove-text-properties-when
7477 'article-type 'signature end limit
7478 (cons 'article-type (cons 'signature
7479 gnus-hidden-properties))))
7480 (gnus-add-wash-type 'signature)
7481 (gnus-add-text-properties-when
7482 'article-type nil end limit
7483 (cons 'article-type (cons 'signature
7484 gnus-hidden-properties)))))
7485 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
7486 (gnus-set-mode-line 'article))))
7488 (defun gnus-button-entry ()
7489 ;; Return the first entry in `gnus-button-alist' matching this place.
7490 (let ((alist gnus-button-alist)
7493 (setq entry (pop alist))
7494 (if (looking-at (eval (car entry)))
7499 (defun gnus-button-push (marker)
7500 ;; Push button starting at MARKER.
7503 (let* ((entry (gnus-button-entry))
7504 (inhibit-point-motion-hooks t)
7506 (args (mapcar (lambda (group)
7507 (let ((string (match-string group)))
7508 (set-text-properties
7509 0 (length string) nil string)
7516 (fboundp (symbol-value fun)))
7517 (apply (symbol-value fun) args))
7519 (gnus-message 1 "You must define `%S' to use this button"
7520 (cons fun args)))))))
7522 (defun gnus-parse-news-url (url)
7523 (let (scheme server port group message-id articles)
7526 (goto-char (point-min))
7527 (when (looking-at "\\([A-Za-z]+\\):")
7528 (setq scheme (match-string 1))
7529 (goto-char (match-end 0)))
7530 (when (looking-at "//\\([^:/]+\\)\\(:?\\)\\([0-9]+\\)?/")
7531 (setq server (match-string 1))
7532 (setq port (if (stringp (match-string 3))
7533 (string-to-number (match-string 3))
7535 (goto-char (match-end 0)))
7538 ((looking-at "\\(.*@.*\\)")
7539 (setq message-id (match-string 1)))
7540 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
7541 (setq group (match-string 1)
7542 articles (split-string (match-string 2) "-")))
7543 ((looking-at "\\([^/]+\\)/?")
7544 (setq group (match-string 1)))
7546 (error "Unknown news URL syntax"))))
7547 (list scheme server port group message-id articles)))
7549 (defun gnus-button-handle-news (url)
7551 (destructuring-bind (scheme server port group message-id articles)
7552 (gnus-parse-news-url url)
7556 (set-buffer gnus-summary-buffer)
7558 (let ((gnus-refer-article-method
7559 (nconc (list (list 'nntp server))
7560 gnus-refer-article-method))
7561 (nntp-port-number (or port "nntp")))
7562 (gnus-message 7 "Fetching %s with %s"
7563 message-id gnus-refer-article-method)
7564 (gnus-summary-refer-article message-id))
7565 (gnus-summary-refer-article message-id))))
7567 (gnus-button-fetch-group url)))))
7569 (defun gnus-button-handle-man (url)
7571 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7572 (when (eq gnus-button-man-handler 'woman)
7573 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
7574 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7575 (funcall gnus-button-man-handler url))
7577 (defun gnus-button-handle-info-url (url)
7578 "Fetch an info URL."
7579 (setq url (mm-subst-char-in-string ?+ ?\ url))
7581 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
7582 (gnus-info-find-node
7583 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
7585 ")" (gnus-url-unhex-string (match-string 2 url)))))
7586 ((string-match "([^)\"]+)[^\"]+" url)
7588 (gnus-replace-in-string
7589 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
7590 (gnus-info-find-node url))
7591 (t (error "Can't parse %s" url))))
7593 (defun gnus-button-handle-info-url-gnome (url)
7594 "Fetch GNOME style info URL."
7595 (setq url (mm-subst-char-in-string ?_ ?\ url))
7596 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
7597 (gnus-info-find-node
7599 (gnus-url-unhex-string
7600 (match-string 1 url))
7602 (or (gnus-url-unhex-string
7603 (match-string 2 url))
7605 (error "Can't parse %s" url)))
7607 (defun gnus-button-handle-info-url-kde (url)
7608 "Fetch KDE style info URL."
7609 (gnus-info-find-node (gnus-url-unhex-string url)))
7611 (defun gnus-button-handle-info-keystrokes (url)
7612 "Call `info' when pushing the corresponding URL button."
7613 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
7618 (defun gnus-button-openpgp (url)
7619 "Retrieve and add an OpenPGP key given URL from an OpenPGP header."
7621 (mm-url-insert-file-contents-external url)
7622 (pgg-snarf-keys-region (point-min) (point-max))
7623 (pgg-display-output-buffer nil nil nil)))
7625 (defun gnus-button-message-id (message-id)
7627 (with-current-buffer gnus-summary-buffer
7628 (gnus-summary-refer-article message-id)))
7630 (defun gnus-button-fetch-group (address)
7631 "Fetch GROUP specified by ADDRESS."
7632 (if (not (string-match "[:/]" address))
7633 ;; This is just a simple group url.
7634 (gnus-group-read-ephemeral-group address gnus-select-method)
7637 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
7639 (error "Can't parse %s" address)
7640 (gnus-group-read-ephemeral-group
7641 (match-string 4 address)
7642 `(nntp ,(match-string 1 address)
7643 (nntp-address ,(match-string 1 address))
7644 (nntp-port-number ,(if (match-end 3)
7645 (match-string 3 address)
7648 (and (match-end 6) (list (string-to-number (match-string 6 address))))))))
7650 (defun gnus-url-parse-query-string (query &optional downcase)
7651 (let (retval pairs cur key val)
7652 (setq pairs (split-string query "&"))
7654 (setq cur (car pairs)
7656 (if (not (string-match "=" cur))
7658 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
7659 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
7661 (setq key (downcase key)))
7662 (setq cur (assoc key retval))
7664 (setcdr cur (cons val (cdr cur)))
7665 (setq retval (cons (list key val) retval)))))
7668 (defun gnus-url-mailto (url)
7669 ;; Send mail to someone
7670 (when (string-match "mailto:/*\\(.*\\)" url)
7671 (setq url (substring url (match-beginning 1) nil)))
7672 (let (to args subject func)
7673 (setq args (gnus-url-parse-query-string
7674 (if (string-match "^\\?" url)
7676 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
7677 (concat "to=" (match-string 1 url) "&"
7678 (match-string 2 url))
7679 (concat "to=" url)))
7681 subject (cdr-safe (assoc "subject" args)))
7684 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
7687 (message-position-on-field (caar args)))
7688 (insert (gnus-replace-in-string
7689 (mapconcat 'identity (reverse (cdar args)) ", ")
7691 (setq args (cdr args)))
7694 (message-goto-subject))))
7696 (defun gnus-button-embedded-url (address)
7697 "Activate ADDRESS with `browse-url'."
7698 (browse-url (gnus-strip-whitespace address)))
7700 ;;; Next/prev buttons in the article buffer.
7702 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
7703 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
7705 (defvar gnus-prev-page-map
7706 (let ((map (make-sparse-keymap)))
7707 (define-key map gnus-mouse-2 'gnus-button-prev-page)
7708 (define-key map "\r" 'gnus-button-prev-page)
7711 (defvar gnus-next-page-map
7712 (let ((map (make-sparse-keymap)))
7713 (unless (>= emacs-major-version 21)
7714 ;; XEmacs doesn't care.
7715 (set-keymap-parent map gnus-article-mode-map))
7716 (define-key map gnus-mouse-2 'gnus-button-next-page)
7717 (define-key map "\r" 'gnus-button-next-page)
7720 (defun gnus-insert-prev-page-button ()
7722 (inhibit-read-only t)
7723 (situation (get-text-property (point-min) 'mime-view-situation)))
7725 gnus-prev-page-line-format nil
7726 `(keymap ,gnus-prev-page-map
7728 gnus-callback gnus-article-button-prev-page
7729 article-type annotation
7730 mime-view-situation ,situation))
7731 (widget-convert-button
7733 ;; Exclude a newline.
7736 :action 'gnus-button-prev-page
7737 :button-keymap gnus-prev-page-map)))
7739 (defun gnus-button-next-page (&optional args more-args)
7740 "Go to the next page."
7742 (let ((win (selected-window)))
7743 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7744 (gnus-article-next-page)
7745 (select-window win)))
7747 (defun gnus-button-prev-page (&optional args more-args)
7748 "Go to the prev page."
7750 (let ((win (selected-window)))
7751 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7752 (gnus-article-prev-page)
7753 (select-window win)))
7755 (defun gnus-insert-next-page-button ()
7757 (inhibit-read-only t)
7758 (situation (get-text-property (point-min) 'mime-view-situation)))
7759 (gnus-eval-format gnus-next-page-line-format nil
7760 `(keymap ,gnus-next-page-map
7762 gnus-callback gnus-article-button-next-page
7763 article-type annotation
7764 mime-view-situation ,situation))
7765 (widget-convert-button
7767 ;; Exclude a newline.
7770 :action 'gnus-button-next-page
7771 :button-keymap gnus-next-page-map)))
7773 (defun gnus-article-button-next-page (arg)
7774 "Go to the next page."
7776 (let ((win (selected-window)))
7777 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7778 (gnus-article-next-page)
7779 (select-window win)))
7781 (defun gnus-article-button-prev-page (arg)
7782 "Go to the prev page."
7784 (let ((win (selected-window)))
7785 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7786 (gnus-article-prev-page)
7787 (select-window win)))
7789 (defvar gnus-decode-header-methods
7790 '(mail-decode-encoded-word-region)
7791 "List of methods used to decode headers.
7793 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
7794 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
7795 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
7796 whose names match REGEXP.
7799 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
7800 mail-decode-encoded-word-region
7801 (\"chinese\" . rfc1843-decode-region))
7804 (defvar gnus-decode-header-methods-cache nil)
7806 (defun gnus-multi-decode-header (start end)
7807 "Apply the functions from `gnus-encoded-word-methods' that match."
7808 (unless (and gnus-decode-header-methods-cache
7809 (eq gnus-newsgroup-name
7810 (car gnus-decode-header-methods-cache)))
7811 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
7814 (nconc gnus-decode-header-methods-cache (list x))
7815 (if (and gnus-newsgroup-name
7816 (string-match (car x) gnus-newsgroup-name))
7817 (nconc gnus-decode-header-methods-cache
7819 gnus-decode-header-methods))
7820 (let ((xlist gnus-decode-header-methods-cache))
7823 (narrow-to-region start end)
7825 (funcall (pop xlist) (point-min) (point-max))))))
7828 ;;; Treatment top-level handling.
7831 (defun gnus-treat-article (condition &optional part-number total-parts type)
7832 (let ((length (- (point-max) (point-min)))
7833 (alist gnus-treatment-function-alist)
7834 (article-goto-body-goes-to-point-min-p t)
7838 (let ((list gnus-article-treat-types))
7840 (when (string-match (pop list) type)
7841 (throw 'found t)))))))
7842 (highlightp (gnus-visual-p 'article-highlight 'highlight))
7843 (entity (static-unless (featurep 'xemacs)
7844 (when (eq 'head condition)
7845 (get-text-property (point-min) 'mime-view-entity))))
7846 val elem buttonized)
7847 (gnus-run-hooks 'gnus-part-display-hook)
7848 (unless gnus-inhibit-treatment
7849 (dolist (elem alist)
7852 (when (gnus-buffer-live-p gnus-summary-buffer)
7853 (set-buffer gnus-summary-buffer))
7854 (symbol-value (car elem))))
7855 (when (and (or (consp val)
7857 (gnus-treat-predicate val)
7858 (or (not (get (car elem) 'highlight))
7860 (when (and (not buttonized)
7862 '(gnus-treat-hide-signature
7863 gnus-treat-highlight-signature)))
7864 (gnus-article-buttonize-signature)
7865 (setq buttonized t))
7867 (funcall (cadr elem)))))
7868 ;; FSF Emacsen does not inherit the existing text properties
7869 ;; in the new text, so we should do it for `mime-view-entity'.
7870 (static-unless (featurep 'xemacs)
7872 (put-text-property (point-min) (point-max)
7873 'mime-view-entity entity))))))
7875 ;; Dynamic variables.
7877 (defvar part-number)
7878 (defvar total-parts)
7883 (defun gnus-treat-predicate (val)
7888 (stringp (car val)))
7889 (apply 'gnus-or (mapcar `(lambda (s)
7890 (string-match s ,(or gnus-newsgroup-name "")))
7893 (let ((pred (pop val)))
7896 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
7898 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
7900 (not (gnus-treat-predicate (car val))))
7902 (equal (car val) type))
7904 (error "%S is not a valid predicate" pred)))))
7916 (eq part-number total-parts))
7920 (error "%S is not a valid value" val))))
7922 (defun gnus-article-encrypt-body (protocol &optional n)
7923 "Encrypt the article body."
7926 (or gnus-article-encrypt-protocol
7927 (completing-read "Encrypt protocol: "
7928 gnus-article-encrypt-protocol-alist
7930 current-prefix-arg))
7931 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7933 (error "Can't find the encrypt protocol %s" protocol))
7934 (if (member gnus-newsgroup-name '("nndraft:delayed"
7937 (error "Can't encrypt the article in group %s"
7938 gnus-newsgroup-name))
7939 (gnus-summary-iterate n
7941 (set-buffer gnus-summary-buffer)
7942 (let ((mail-parse-charset gnus-newsgroup-charset)
7943 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7944 (summary-buffer gnus-summary-buffer)
7946 (gnus-set-global-variables)
7947 (when (gnus-group-read-only-p)
7948 (error "The current newsgroup does not support article encrypt"))
7949 (gnus-summary-show-article t)
7951 (or (mail-header-references gnus-current-headers) ""))
7952 (set-buffer gnus-article-buffer)
7953 (let* ((inhibit-read-only t)
7955 (mapcar (lambda (field)
7956 (and (save-restriction
7957 (message-narrow-to-head)
7958 (goto-char (point-min))
7959 (search-forward field nil t))
7961 (message-narrow-to-field)
7963 (delete-region (point-min) (point-max))
7965 '("Content-Type:" "Content-Transfer-Encoding:"
7966 "Content-Disposition:"))))
7967 (message-narrow-to-head)
7968 (message-remove-header "MIME-Version")
7969 (goto-char (point-max))
7970 (setq point (point))
7971 (insert (apply 'concat headers))
7973 (narrow-to-region point (point-max))
7974 (let ((message-options message-options))
7975 (message-options-set 'message-sender user-mail-address)
7976 (message-options-set 'message-recipients user-mail-address)
7977 (message-options-set 'message-sign-encrypt 'not)
7979 (goto-char (point-min))
7980 (insert "MIME-Version: 1.0\n")
7982 (gnus-summary-edit-article-done
7983 references nil summary-buffer t))
7984 (when gnus-keep-backlog
7985 (gnus-backlog-remove-article
7986 (car gnus-article-current) (cdr gnus-article-current)))
7988 (when (get-buffer gnus-original-article-buffer)
7989 (set-buffer gnus-original-article-buffer)
7990 (setq gnus-original-article nil)))
7991 (when gnus-use-cache
7992 (gnus-cache-update-article
7993 (car gnus-article-current) (cdr gnus-article-current))))))))
7995 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7996 "The following specs can be used:
7997 %t The security MIME type
8000 %D Details if button is pressed")
8002 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
8003 "The following specs can be used:
8004 %t The security MIME type
8007 %D Details if button is pressed")
8009 (defvar gnus-mime-security-button-line-format-alist
8010 '((?t gnus-tmp-type ?s)
8011 (?i gnus-tmp-info ?s)
8012 (?d gnus-tmp-details ?s)
8013 (?D gnus-tmp-pressed-details ?s)))
8015 (defvar gnus-mime-security-button-commands
8016 '((gnus-article-press-button "\r" "Show Detail")
8020 (gnus-mime-security-save-part "o" "Save...")
8029 (gnus-mime-security-pipe-part "|" "Pipe To Command...")
8032 (defvar gnus-mime-security-button-map
8033 (let ((map (make-sparse-keymap)))
8034 (define-key map gnus-mouse-2 'gnus-article-push-button)
8035 (define-key map gnus-down-mouse-3 'gnus-mime-security-button-menu)
8036 (dolist (c gnus-mime-security-button-commands)
8037 (define-key map (cadr c) (car c)))
8041 gnus-mime-security-button-menu gnus-mime-security-button-map
8042 "Security button menu."
8046 (unless (eq (car c) 'undefined)
8047 (vector (caddr c) (car c) :enable t)))
8048 gnus-mime-security-button-commands))))
8050 (defun gnus-mime-security-button-menu (event prefix)
8051 "Construct a context-sensitive menu of security commands."
8052 (interactive "e\nP")
8053 (save-window-excursion
8054 (let ((pos (event-start event)))
8055 (select-window (posn-window pos))
8056 (goto-char (posn-point pos))
8057 (gnus-article-check-buffer)
8058 (popup-menu gnus-mime-security-button-menu nil prefix))))
8060 (defvar gnus-mime-security-details-buffer nil)
8062 (defvar gnus-mime-security-button-pressed nil)
8064 (defvar gnus-mime-security-show-details-inline t
8065 "If non-nil, show details in the article buffer.")
8067 (defun gnus-mime-security-verify-or-decrypt (handle)
8068 (mm-remove-parts (cdr handle))
8069 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
8070 point (inhibit-read-only t))
8072 (goto-char (car region)))
8074 (narrow-to-region (point) (point))
8075 (with-current-buffer (mm-handle-multipart-original-buffer handle)
8076 (let* ((mm-verify-option 'known)
8077 (mm-decrypt-option 'known)
8078 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
8079 (unless (eq nparts (cdr handle))
8080 (mm-destroy-parts (cdr handle))
8081 (setcdr handle nparts))))
8082 (setq point (point))
8083 (gnus-mime-display-security handle)
8084 (goto-char (point-max)))
8086 (delete-region (point) (cdr region))
8087 (set-marker (car region) nil)
8088 (set-marker (cdr region) nil))
8091 (defun gnus-mime-security-show-details (handle)
8092 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
8094 (gnus-message 5 "No details.")
8095 (if gnus-mime-security-show-details-inline
8096 (let ((gnus-mime-security-button-pressed
8097 (not (get-text-property (point) 'gnus-mime-details)))
8098 (gnus-mime-security-button-line-format
8099 (get-text-property (point) 'gnus-line-format))
8100 (inhibit-read-only t))
8102 (while (eq (get-text-property (point) 'gnus-line-format)
8103 gnus-mime-security-button-line-format)
8107 (narrow-to-region (point) (point))
8108 (gnus-insert-mime-security-button handle))
8109 (delete-region (point)
8110 (or (text-property-not-all
8113 gnus-mime-security-button-line-format)
8116 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
8117 (with-current-buffer gnus-mime-security-details-buffer
8120 (setq gnus-mime-security-details-buffer
8121 (gnus-get-buffer-create "*MIME Security Details*")))
8122 (with-current-buffer gnus-mime-security-details-buffer
8124 (goto-char (point-min)))
8125 (pop-to-buffer gnus-mime-security-details-buffer)))))
8127 (defun gnus-mime-security-press-button (handle)
8129 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
8130 (gnus-mime-security-show-details handle)
8131 (gnus-mime-security-verify-or-decrypt handle))))
8133 (defun gnus-insert-mime-security-button (handle &optional displayed)
8134 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
8137 (or (nth 2 (assoc protocol mm-verify-function-alist))
8138 (nth 2 (assoc protocol mm-decrypt-function-alist))
8140 (if (equal (car handle) "multipart/signed")
8141 " Signed" " Encrypted")
8144 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
8147 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
8148 gnus-tmp-pressed-details
8150 (setq gnus-tmp-details
8151 (if gnus-tmp-details
8152 (concat "\n" gnus-tmp-details)
8154 (setq gnus-tmp-pressed-details
8155 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
8160 gnus-mime-security-button-line-format
8161 gnus-mime-security-button-line-format-alist
8162 `(keymap ,gnus-mime-security-button-map
8163 gnus-callback gnus-mime-security-press-button
8164 gnus-line-format ,gnus-mime-security-button-line-format
8165 gnus-mime-details ,gnus-mime-security-button-pressed
8166 article-type annotation
8169 ;; Exclude a newline.
8172 (widget-convert-button
8175 :action 'gnus-widget-press-button
8176 :button-keymap gnus-mime-security-button-map
8178 (lambda (widget/window &optional overlay pos)
8179 ;; Needed to properly clear the message due to a bug in
8180 ;; wid-edit (XEmacs only).
8181 (when (boundp 'help-echo-owns-message)
8182 (setq help-echo-owns-message t))
8184 "%S: show detail; %S: more options"
8185 (aref gnus-mouse-2 0)
8186 (aref gnus-down-mouse-3 0))))))
8188 (defun gnus-mime-display-security (handle)
8190 (narrow-to-region (point) (point))
8191 (unless (gnus-unbuttonized-mime-type-p (car handle))
8192 (gnus-insert-mime-security-button handle))
8193 (gnus-mime-display-part (cadr handle))
8196 (unless (gnus-unbuttonized-mime-type-p (car handle))
8197 (let ((gnus-mime-security-button-line-format
8198 gnus-mime-security-button-end-line-format))
8199 (gnus-insert-mime-security-button handle)))
8200 (mm-set-handle-multipart-parameter
8202 (cons (set-marker (make-marker) (point-min))
8203 (set-marker (make-marker) (point-max))))))
8209 (defun gnus-article-header-presentation-method (entity situation)
8210 (mime-insert-header entity)
8211 (article-decode-group-name))
8213 (set-alist 'mime-header-presentation-method-alist
8214 'gnus-original-article-mode
8215 #'gnus-article-header-presentation-method)
8217 (defun gnus-mime-preview-quitting-method ()
8218 (mime-preview-kill-buffer)
8219 (delete-other-windows)
8220 (gnus-article-show-summary)
8221 (gnus-summary-select-article gnus-show-all-headers t))
8223 (set-alist 'mime-preview-quitting-method-alist
8224 'gnus-original-article-mode #'gnus-mime-preview-quitting-method)
8226 (set-alist 'mime-preview-following-method-alist
8227 'gnus-original-article-mode #'gnus-following-method)
8229 (set-alist 'mime-preview-over-to-previous-method-alist
8230 'gnus-original-article-mode
8232 (if (> (point-min) 1)
8233 (gnus-article-prev-page)
8234 (gnus-article-read-summary-keys
8235 nil (gnus-character-to-event ?P)))))
8237 (set-alist 'mime-preview-over-to-next-method-alist
8238 'gnus-original-article-mode'
8240 (if (< (point-max) (buffer-size))
8241 (gnus-article-next-page)
8242 (gnus-article-read-summary-keys
8243 nil (gnus-character-to-event ?N)))))
8249 (defun gnus-mime-security-run-function (function)
8250 "Run FUNCTION with the security part under point."
8251 (gnus-article-check-buffer)
8252 (let ((data (get-text-property (point) 'gnus-data))
8254 (when (and (stringp (car-safe data))
8255 (setq buffer (mm-handle-multipart-original-buffer data))
8256 (setq handle (cadr data)))
8257 (if (bufferp (mm-handle-buffer handle))
8259 (setq handle (cons buffer (copy-sequence (cdr handle))))
8260 (mm-handle-set-undisplayer handle nil))
8261 (setq handle (mm-make-handle
8263 (mm-handle-multipart-ctl-parameter handle 'protocol)
8264 nil nil nil nil nil nil)))
8265 (funcall function handle))))
8267 (defun gnus-mime-security-save-part ()
8268 "Save the security part under point."
8270 (gnus-mime-security-run-function 'mm-save-part))
8272 (defun gnus-mime-security-pipe-part ()
8273 "Pipe the security part under point to a process."
8275 (gnus-mime-security-run-function 'mm-pipe-part))
8281 (run-hooks 'gnus-art-load-hook)
8283 ;;; gnus-art.el ends here