1 ;;; gnus-art.el --- article mode commands for Semi-gnus
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005 Free Software Foundation, Inc.
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
7 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
8 ;; Katsumi Yamaoka <yamaoka@jpl.org>
9 ;; Keywords: mail, news, MIME
11 ;; This file is part of GNU Emacs.
13 ;; GNU Emacs is free software; you can redistribute it and/or modify
14 ;; it under the terms of the GNU General Public License as published by
15 ;; the Free Software Foundation; either version 2, or (at your option)
18 ;; GNU Emacs is distributed in the hope that it will be useful,
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;; GNU General Public License for more details.
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the
25 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
26 ;; Boston, MA 02110-1301, USA.
36 (defvar w3m-minor-mode-map))
40 ;; Avoid the "Recursive load suspected" error in Emacs 21.1.
42 (let ((recursive-load-depth-limit 100))
49 (when (static-if (featurep 'xemacs)
50 (console-on-window-system-p)
52 (require 'mime-image))
55 ;; Avoid byte-compile warnings.
65 (autoload 'gnus-msg-mail "gnus-msg" nil t)
66 (autoload 'gnus-button-mailto "gnus-msg")
67 (autoload 'gnus-button-reply "gnus-msg" nil t)
68 (autoload 'parse-time-string "parse-time" nil nil)
69 (autoload 'ansi-color-apply-on-region "ansi-color")
71 (defgroup gnus-article nil
73 :link '(custom-manual "(gnus)Article Buffer")
76 (defgroup gnus-article-treat nil
77 "Treating article parts."
78 :link '(custom-manual "(gnus)Article Hiding")
81 (defgroup gnus-article-hiding nil
82 "Hiding article parts."
83 :link '(custom-manual "(gnus)Article Hiding")
86 (defgroup gnus-article-highlight nil
87 "Article highlighting."
88 :link '(custom-manual "(gnus)Article Highlighting")
92 (defgroup gnus-article-signature nil
94 :link '(custom-manual "(gnus)Article Signature")
97 (defgroup gnus-article-headers nil
99 :link '(custom-manual "(gnus)Hiding Headers")
100 :group 'gnus-article)
102 (defgroup gnus-article-washing nil
103 "Special commands on articles."
104 :link '(custom-manual "(gnus)Article Washing")
105 :group 'gnus-article)
107 (defgroup gnus-article-emphasis nil
108 "Fontisizing articles."
109 :link '(custom-manual "(gnus)Article Fontisizing")
110 :group 'gnus-article)
112 (defgroup gnus-article-saving nil
114 :link '(custom-manual "(gnus)Saving Articles")
115 :group 'gnus-article)
117 (defgroup gnus-article-mime nil
118 "Worshiping the MIME wonder."
119 :link '(custom-manual "(gnus)Using MIME")
120 :group 'gnus-article)
122 (defgroup gnus-article-buttons nil
123 "Pushable buttons in the article buffer."
124 :link '(custom-manual "(gnus)Article Buttons")
125 :group 'gnus-article)
127 (defgroup gnus-article-various nil
128 "Other article options."
129 :link '(custom-manual "(gnus)Misc Article")
130 :group 'gnus-article)
132 (defcustom gnus-ignored-headers
135 (concat "^" header ":"))
136 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
137 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
138 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
139 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
140 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
141 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
142 "X-Attribution" "X-Originating-IP" "Delivered-To"
143 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
144 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
145 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
146 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
147 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
148 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
149 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
150 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
151 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
152 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
153 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
154 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
155 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
156 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
157 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
158 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
159 "List-[A-Za-z]+" "X-Listprocessor-Version"
160 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
161 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
162 "X-Received" "Content-length" "X-precedence"
163 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
164 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
165 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
166 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
167 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
168 "X-Content-length" "X-Posting-Agent" "Original-Received"
169 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
170 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
171 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
172 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
173 "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer"))
174 "*All headers that start with this regexp will be hidden.
175 This variable can also be a list of regexps of headers to be ignored.
176 If `gnus-visible-headers' is non-nil, this variable will be ignored."
177 :type '(choice :custom-show nil
180 :group 'gnus-article-hiding)
182 (defcustom gnus-visible-headers
183 "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^[BGF]?Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Mail-Followup-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-From:\\|^X-Sent:"
184 "*All headers that do not match this regexp will be hidden.
185 This variable can also be a list of regexp of headers to remain visible.
186 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
187 :type '(repeat :value-to-internal (lambda (widget value)
188 (custom-split-regexp-maybe value))
189 :match (lambda (widget value)
191 (widget-editable-list-match widget value)))
193 :group 'gnus-article-hiding)
195 (defcustom gnus-sorted-header-list
196 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
197 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
198 "*This variable is a list of regular expressions.
199 If it is non-nil, headers that match the regular expressions will
200 be placed first in the article buffer in the sequence specified by
202 :type '(repeat regexp)
203 :group 'gnus-article-hiding)
205 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
206 "Headers that are only to be displayed if they have interesting data.
207 Possible values in this list are:
209 'empty Headers with no content.
210 'newsgroups Newsgroup identical to Gnus group.
211 'to-address To identical to To-address.
212 'to-list To identical to To-list.
213 'cc-list CC identical to To-list.
214 'followup-to Followup-to identical to Newsgroups.
215 'reply-to Reply-to identical to From.
216 'date Date less than four days old.
217 'long-to To and/or Cc longer than 1024 characters.
218 'many-to Multiple To and/or Cc."
219 :type '(set (const :tag "Headers with no content." empty)
220 (const :tag "Newsgroups identical to Gnus group." newsgroups)
221 (const :tag "To identical to To-address." to-address)
222 (const :tag "To identical to To-list." to-list)
223 (const :tag "CC identical to To-list." cc-list)
224 (const :tag "Followup-to identical to Newsgroups." followup-to)
225 (const :tag "Reply-to identical to From." reply-to)
226 (const :tag "Date less than four days old." date)
227 (const :tag "To and/or Cc longer than 1024 characters." long-to)
228 (const :tag "Multiple To and/or Cc headers." many-to))
229 :group 'gnus-article-hiding)
231 (defcustom gnus-article-skip-boring nil
232 "Skip over text that is not worth reading.
233 By default, if you set this t, then Gnus will display citations and
234 signatures, but will never scroll down to show you a page consisting
235 only of boring text. Boring text is controlled by
236 `gnus-article-boring-faces'."
239 :group 'gnus-article-hiding)
241 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
242 "Regexp matching signature separator.
243 This can also be a list of regexps. In that case, it will be checked
244 from head to tail looking for a separator. Searches will be done from
245 the end of the buffer."
246 :type '(repeat string)
247 :group 'gnus-article-signature)
249 (defcustom gnus-signature-limit nil
250 "Provide a limit to what is considered a signature.
251 If it is a number, no signature may not be longer (in characters) than
252 that number. If it is a floating point number, no signature may be
253 longer (in lines) than that number. If it is a function, the function
254 will be called without any parameters, and if it returns nil, there is
255 no signature in the buffer. If it is a string, it will be used as a
256 regexp. If it matches, the text in question is not a signature.
258 This can also be a list of the above values."
259 :type '(choice (const nil)
262 (function :value fun)
263 (regexp :value ".*"))
264 :group 'gnus-article-signature)
266 (defcustom gnus-hidden-properties '(invisible t intangible t)
267 "Property list to use for hiding text."
269 :group 'gnus-article-hiding)
271 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
272 ;; frames in a session.
273 (defcustom gnus-article-x-face-command
278 (if (or (gnus-image-type-available-p 'xface)
279 (gnus-image-type-available-p 'pbm))
280 'gnus-display-x-face-in-from
281 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -"))
282 ((gnus-image-type-available-p 'pbm)
283 'gnus-display-x-face-in-from)
285 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
287 "*String or function to be executed to display an X-Face header.
288 If it is a string, the command will be executed in a sub-shell
289 asynchronously. The compressed face will be piped to this command."
291 :format "%{%t%}:\n%[Value Menu%] %v"
295 (if (or (gnus-image-type-available-p 'xface)
296 (gnus-image-type-available-p 'pbm))
297 '(function-item gnus-display-x-face-in-from))
301 :group 'gnus-article-washing)
303 (defcustom gnus-article-x-face-too-ugly nil
304 "Regexp matching posters whose face shouldn't be shown automatically."
305 :type '(choice regexp (const nil))
306 :group 'gnus-article-washing)
308 (defcustom gnus-article-banner-alist nil
309 "Banner alist for stripping.
311 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
313 :type '(repeat (cons symbol regexp))
314 :group 'gnus-article-washing)
316 (gnus-define-group-parameter
319 "Alist of regexps (to match group names) and banner."
320 :variable-group gnus-article-washing
322 '(choice :tag "Banner"
324 (const :tag "Remove signature" signature)
325 (symbol :tag "Item in `gnus-article-banner-alist'" none)
327 (const :tag "None" nil))
329 "If non-nil, specify how to remove `banners' from articles.
331 Symbol `signature' means to remove signatures delimited by
332 `gnus-signature-separator'. Any other symbol is used to look up a
333 regular expression to match the banner in `gnus-article-banner-alist'.
334 A string is used as a regular expression to match the banner
337 (defcustom gnus-article-address-banner-alist nil
338 "Alist of mail addresses and banners.
339 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
340 to match a mail address in the From: header, BANNER is one of a symbol
341 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
342 If ADDRESS matches author's mail address, it will remove things like
343 advertisements. For example:
345 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
349 (regexp :tag "Address")
350 (choice :tag "Banner" :value nil
351 (const :tag "Remove signature" signature)
352 (symbol :tag "Item in `gnus-article-banner-alist'" none)
354 (const :tag "None" nil))))
356 :group 'gnus-article-washing)
358 (defmacro gnus-emphasis-custom-with-format (&rest body)
360 \\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\
361 \\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)"))
364 (defun gnus-emphasis-custom-value-to-external (value)
365 (gnus-emphasis-custom-with-format
366 (if (consp (car value))
367 (list (format format (car (car value)) (cdr (car value)))
369 (if (nth 1 value) 2 3)
373 (defun gnus-emphasis-custom-value-to-internal (value)
374 (gnus-emphasis-custom-with-format
375 (let ((regexp (concat "\\`"
376 (format (regexp-quote format)
377 "\\([^()]+\\)" "\\([^()]+\\)")
380 (if (string-match regexp (setq pattern (car value)))
381 (list (cons (match-string 1 pattern) (match-string 2 pattern))
386 (defcustom gnus-emphasis-alist
388 '(("\\*" "\\*" bold nil 2)
391 ("_/" "/_" underline-italic)
392 ("_\\*" "\\*_" underline-bold)
393 ("\\*/" "/\\*" bold-italic)
394 ("_\\*/" "/\\*_" underline-bold-italic))))
396 (gnus-emphasis-custom-with-format
397 (mapcar (lambda (spec)
398 (list (format format (car spec) (cadr spec))
401 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
403 '(;; I've never seen anyone use this strikethru convention whereas I've
404 ;; several times seen it triggered by normal text. --Stef
405 ;; Miles suggests that this form is sometimes used but for italics,
406 ;; so maybe we should map it to `italic'.
407 ;; ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
408 ;; 2 3 gnus-emphasis-strikethru)
409 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
410 2 3 gnus-emphasis-underline))))
411 "*Alist that says how to fontify certain phrases.
412 Each item looks like this:
414 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
416 The first element is a regular expression to be matched. The second
417 is a number that says what regular expression grouping used to find
418 the entire emphasized word. The third is a number that says what
419 regexp grouping should be displayed and highlighted. The fourth
420 is the face used for highlighting."
424 :format "%[Customizing Style%]\n%v"
426 (group :tag "Default"
427 :value ("" 0 0 default)
430 (let ((value (widget-get
431 (cadr (widget-get (widget-get widget :parent)
434 (if (not (eq (nth 2 value) 'default))
438 (gnus-emphasis-custom-value-to-external value))))
439 (widget-group-value-create widget))
441 (integer :format "Match group: %v")
442 (integer :format "Emphasize group: %v")
445 :value (("_" . "_") nil default)
447 (regexp :format "Start regexp: %v")
448 (regexp :format "End regexp: %v"))
449 (boolean :format "Show start and end patterns: %[%v%]\n"
450 :on " On " :off " Off ")
452 :get (lambda (symbol)
453 (mapcar 'gnus-emphasis-custom-value-to-internal
454 (default-value symbol)))
455 :set (lambda (symbol value)
456 (set-default symbol (mapcar 'gnus-emphasis-custom-value-to-external
458 :group 'gnus-article-emphasis)
460 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
461 "A regexp to describe whitespace which should not be emphasized.
462 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
463 The former avoids underlining of leading and trailing whitespace,
464 and the latter avoids underlining any whitespace at all."
466 :group 'gnus-article-emphasis
469 (defface gnus-emphasis-bold '((t (:bold t)))
470 "Face used for displaying strong emphasized text (*word*)."
471 :group 'gnus-article-emphasis)
473 (defface gnus-emphasis-italic '((t (:italic t)))
474 "Face used for displaying italic emphasized text (/word/)."
475 :group 'gnus-article-emphasis)
477 (defface gnus-emphasis-underline '((t (:underline t)))
478 "Face used for displaying underlined emphasized text (_word_)."
479 :group 'gnus-article-emphasis)
481 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
482 "Face used for displaying underlined bold emphasized text (_*word*_)."
483 :group 'gnus-article-emphasis)
485 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
486 "Face used for displaying underlined italic emphasized text (_/word/_)."
487 :group 'gnus-article-emphasis)
489 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
490 "Face used for displaying bold italic emphasized text (/*word*/)."
491 :group 'gnus-article-emphasis)
493 (defface gnus-emphasis-underline-bold-italic
494 '((t (:bold t :italic t :underline t)))
495 "Face used for displaying underlined bold italic emphasized text.
496 Example: (_/*word*/_)."
497 :group 'gnus-article-emphasis)
499 (defface gnus-emphasis-strikethru (if (featurep 'xemacs)
500 '((t (:strikethru t)))
501 '((t (:strike-through t))))
502 "Face used for displaying strike-through text (-word-)."
503 :group 'gnus-article-emphasis)
505 (defface gnus-emphasis-highlight-words
506 '((t (:background "black" :foreground "yellow")))
507 "Face used for displaying highlighted words."
508 :group 'gnus-article-emphasis)
510 (defcustom gnus-article-time-format "%a, %d %b %Y %T %Z"
511 "Format for display of Date headers in article bodies.
512 See `format-time-string' for the possible values.
514 The variable can also be function, which should return a complete Date
515 header. The function is called with one argument, the time, which can
516 be fed to `format-time-string'."
517 :type '(choice string function)
518 :link '(custom-manual "(gnus)Article Date")
519 :group 'gnus-article-washing)
521 (defcustom gnus-save-all-headers t
522 "*If non-nil, don't remove any headers before saving."
523 :group 'gnus-article-saving
526 (defcustom gnus-prompt-before-saving 'always
527 "*This variable says how much prompting is to be done when saving articles.
528 If it is nil, no prompting will be done, and the articles will be
529 saved to the default files. If this variable is `always', each and
530 every article that is saved will be preceded by a prompt, even when
531 saving large batches of articles. If this variable is neither nil not
532 `always', there the user will be prompted once for a file name for
533 each invocation of the saving commands."
534 :group 'gnus-article-saving
535 :type '(choice (item always)
536 (item :tag "never" nil)
537 (sexp :tag "once" :format "%t\n" :value t)))
539 (defcustom gnus-saved-headers gnus-visible-headers
540 "Headers to keep if `gnus-save-all-headers' is nil.
541 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
542 If that variable is nil, however, all headers that match this regexp
543 will be kept while the rest will be deleted before saving."
544 :group 'gnus-article-saving
547 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
548 "A function to save articles in your favourite format.
549 The function must be interactively callable (in other words, it must
550 be an Emacs command).
552 Gnus provides the following functions:
554 * gnus-summary-save-in-rmail (Rmail format)
555 * gnus-summary-save-in-mail (Unix mail format)
556 * gnus-summary-save-in-folder (MH folder)
557 * gnus-summary-save-in-file (article format)
558 * gnus-summary-save-body-in-file (article body)
559 * gnus-summary-save-in-vm (use VM's folder format)
560 * gnus-summary-write-to-file (article format -- overwrite)."
561 :group 'gnus-article-saving
562 :type '(radio (function-item gnus-summary-save-in-rmail)
563 (function-item gnus-summary-save-in-mail)
564 (function-item gnus-summary-save-in-folder)
565 (function-item gnus-summary-save-in-file)
566 (function-item gnus-summary-save-body-in-file)
567 (function-item gnus-summary-save-in-vm)
568 (function-item gnus-summary-write-to-file)))
570 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
571 "A function generating a file name to save articles in Rmail format.
572 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
573 :group 'gnus-article-saving
576 (defcustom gnus-mail-save-name 'gnus-plain-save-name
577 "A function generating a file name to save articles in Unix mail format.
578 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
579 :group 'gnus-article-saving
582 (defcustom gnus-folder-save-name 'gnus-folder-save-name
583 "A function generating a file name to save articles in MH folder.
584 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
585 :group 'gnus-article-saving
588 (defcustom gnus-file-save-name 'gnus-numeric-save-name
589 "A function generating a file name to save articles in article format.
590 The function is called with NEWSGROUP, HEADERS, and optional
592 :group 'gnus-article-saving
595 (defcustom gnus-split-methods
596 '((gnus-article-archive-name)
597 (gnus-article-nndoc-name))
598 "*Variable used to suggest where articles are to be saved.
599 For instance, if you would like to save articles related to Gnus in
600 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
601 you could set this variable to something like:
603 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
604 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
606 This variable is an alist where the key is the match and the
607 value is a list of possible files to save in if the match is
610 If the match is a string, it is used as a regexp match on the
611 article. If the match is a symbol, that symbol will be funcalled
612 from the buffer of the article to be saved with the newsgroup as
613 the parameter. If it is a list, it will be evaled in the same
616 If this form or function returns a string, this string will be
617 used as a possible file name; and if it returns a non-nil list,
618 that list will be used as possible file names."
619 :group 'gnus-article-saving
620 :type '(repeat (choice (list :value (fun) function)
621 (cons :value ("" "") regexp (repeat string))
624 (defcustom gnus-article-display-method-for-mime
625 'gnus-article-display-mime-message
626 "Function to display a MIME message.
627 The function is called from the article buffer."
628 :group 'gnus-article-mime
631 (defcustom gnus-article-display-method-for-traditional
632 'gnus-article-display-traditional-message
633 "*Function to display a traditional message.
634 The function is called from the article buffer."
635 :group 'gnus-article-mime
638 (defcustom gnus-page-delimiter "^\^L"
639 "*Regexp describing what to use as article page delimiters.
640 The default value is \"^\^L\", which is a form linefeed at the
641 beginning of a line."
643 :group 'gnus-article-various)
645 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
646 "*The format specification for the article mode line.
647 See `gnus-summary-mode-line-format' for a closer description.
649 The following additional specs are available:
651 %w The article washing status.
652 %m The number of MIME parts in the article."
654 :group 'gnus-article-various)
656 (defcustom gnus-article-mode-hook nil
657 "*A hook for Gnus article mode."
659 :group 'gnus-article-various)
661 (when (featurep 'xemacs)
662 ;; Extracted from gnus-xmas-define in order to preserve user settings
663 (when (fboundp 'turn-off-scroll-in-place)
664 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
665 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
666 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
668 (defcustom gnus-article-menu-hook nil
669 "*Hook run after the creation of the article mode menu."
671 :group 'gnus-article-various)
673 (defcustom gnus-article-prepare-hook nil
674 "*A hook called after an article has been prepared in the article buffer."
676 :group 'gnus-article-various)
678 (defcustom gnus-copy-article-ignored-headers nil
679 "List of headers to be removed when copying an article.
680 Each element is a regular expression."
681 :version "23.0" ;; No Gnus
682 :type '(repeat regexp)
683 :group 'gnus-article-various)
685 (make-obsolete-variable 'gnus-article-hide-pgp-hook
686 "This variable is obsolete in Gnus 5.10.")
688 (defcustom gnus-article-button-face 'bold
689 "Face used for highlighting buttons in the article buffer.
691 An article button is a piece of text that you can activate by pressing
692 `RET' or `mouse-2' above it."
694 :group 'gnus-article-buttons)
696 (defcustom gnus-article-mouse-face 'highlight
697 "Face used for mouse highlighting in the article buffer.
699 Article buttons will be displayed in this face when the cursor is
702 :group 'gnus-article-buttons)
704 (defcustom gnus-signature-face 'gnus-signature
705 "Face used for highlighting a signature in the article buffer.
706 Obsolete; use the face `gnus-signature' for customizations instead."
708 :group 'gnus-article-highlight
709 :group 'gnus-article-signature)
711 (defface gnus-signature
714 "Face used for highlighting a signature in the article buffer."
715 :group 'gnus-article-highlight
716 :group 'gnus-article-signature)
717 ;; backward-compatibility alias
718 (put 'gnus-signature-face 'face-alias 'gnus-signature)
720 (defface gnus-header-from
723 (:foreground "spring green"))
726 (:foreground "red3"))
729 "Face used for displaying from headers."
730 :group 'gnus-article-headers
731 :group 'gnus-article-highlight)
732 ;; backward-compatibility alias
733 (put 'gnus-header-from-face 'face-alias 'gnus-header-from)
735 (defface gnus-header-subject
738 (:foreground "SeaGreen3"))
741 (:foreground "red4"))
743 (:bold t :italic t)))
744 "Face used for displaying subject headers."
745 :group 'gnus-article-headers
746 :group 'gnus-article-highlight)
747 ;; backward-compatibility alias
748 (put 'gnus-header-subject-face 'face-alias 'gnus-header-subject)
750 (defface gnus-header-newsgroups
753 (:foreground "yellow" :italic t))
756 (:foreground "MidnightBlue" :italic t))
759 "Face used for displaying newsgroups headers.
760 In the default setup this face is only used for crossposted
762 :group 'gnus-article-headers
763 :group 'gnus-article-highlight)
764 ;; backward-compatibility alias
765 (put 'gnus-header-newsgroups-face 'face-alias 'gnus-header-newsgroups)
767 (defface gnus-header-name
770 (:foreground "SeaGreen"))
773 (:foreground "maroon"))
776 "Face used for displaying header names."
777 :group 'gnus-article-headers
778 :group 'gnus-article-highlight)
779 ;; backward-compatibility alias
780 (put 'gnus-header-name-face 'face-alias 'gnus-header-name)
782 (defface gnus-header-content
785 (:foreground "forest green" :italic t))
788 (:foreground "indianred4" :italic t))
791 "Face used for displaying header content."
792 :group 'gnus-article-headers
793 :group 'gnus-article-highlight)
794 ;; backward-compatibility alias
795 (put 'gnus-header-content-face 'face-alias 'gnus-header-content)
797 (defcustom gnus-header-face-alist
798 '(("From" nil gnus-header-from)
799 ("Subject" nil gnus-header-subject)
800 ("Newsgroups:.*," nil gnus-header-newsgroups)
801 ("" gnus-header-name gnus-header-content))
802 "*Controls highlighting of article headers.
804 An alist of the form (HEADER NAME CONTENT).
806 HEADER is a regular expression which should match the name of a
807 header and NAME and CONTENT are either face names or nil.
809 The name of each header field will be displayed using the face
810 specified by the first element in the list where HEADER matches
811 the header name and NAME is non-nil. Similarly, the content will
812 be displayed by the first non-nil matching CONTENT face."
813 :group 'gnus-article-headers
814 :group 'gnus-article-highlight
815 :type '(repeat (list (regexp :tag "Header")
817 (item :tag "skip" nil)
818 (face :value default))
819 (choice :tag "Content"
820 (item :tag "skip" nil)
821 (face :value default)))))
823 (defcustom gnus-article-decode-hook
824 '(article-decode-group-name article-decode-idna-rhs)
825 "*Hook run to decode charsets in articles."
826 :group 'gnus-article-headers
829 (defcustom gnus-display-mime-function 'gnus-display-mime
830 "Function to display MIME articles."
831 :group 'gnus-article-mime
834 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
835 "Function used to decode headers.")
837 (defvar gnus-article-dumbquotes-map
857 "Table for MS-to-Latin1 translation.")
859 (defcustom gnus-ignored-mime-types nil
860 "List of MIME types that should be ignored by Gnus."
862 :group 'gnus-article-mime
863 :type '(repeat regexp))
865 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
866 "List of MIME types that should not be given buttons when rendered inline.
867 See also `gnus-buttonized-mime-types' which may override this variable.
868 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
870 :group 'gnus-article-mime
871 :type '(repeat regexp))
873 (defcustom gnus-buttonized-mime-types nil
874 "List of MIME types that should be given buttons when rendered inline.
875 If set, this variable overrides `gnus-unbuttonized-mime-types'.
876 To see e.g. security buttons you could set this to
877 `(\"multipart/signed\")'.
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-inhibit-mime-unbuttonizing nil
884 "If non-nil, all MIME parts get buttons.
885 When nil (the default value), then some MIME parts do not get buttons,
886 as described by the variables `gnus-buttonized-mime-types' and
887 `gnus-unbuttonized-mime-types'."
889 :group 'gnus-article-mime
892 (defcustom gnus-body-boundary-delimiter "_"
893 "String used to delimit header and body.
894 This variable is used by `gnus-article-treat-body-boundary' which can
895 be controlled by `gnus-treat-body-boundary'."
897 :group 'gnus-article-various
898 :type '(choice (item :tag "None" :value nil)
901 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces"
903 "Defines the location of the faces database.
904 For information on obtaining this database of pretty pictures, please
905 see http://www.cs.indiana.edu/picons/ftp/index.html"
907 :type '(repeat directory)
908 :link '(url-link :tag "download"
909 "http://www.cs.indiana.edu/picons/ftp/index.html")
910 :link '(custom-manual "(gnus)Picons")
913 (defun gnus-picons-installed-p ()
914 "Say whether picons are installed on your machine."
915 (let ((installed nil))
916 (dolist (database gnus-picon-databases)
917 (when (file-exists-p database)
921 (defcustom gnus-article-mime-part-function nil
922 "Function called with a MIME handle as the argument.
923 This is meant for people who want to do something automatic based
924 on parts -- for instance, adding Vcard info to a database."
925 :group 'gnus-article-mime
926 :type '(choice (const nil)
929 (defcustom gnus-mime-multipart-functions nil
930 "An alist of MIME types to functions to display them."
932 :group 'gnus-article-mime
933 :type '(repeat (cons :format "%v" (string :tag "MIME type") function)))
935 (defcustom gnus-article-date-lapsed-new-header nil
936 "Whether the X-Sent and Date headers can coexist.
937 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
938 either replace the old \"Date:\" header (if this variable is nil), or
939 be added below it (otherwise)."
941 :group 'gnus-article-headers
944 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
945 "Function called with a MIME handle as the argument.
946 This is meant for people who want to view first matched part.
947 For `undisplayed-alternative' (default), the first undisplayed
948 part or alternative part is used. For `undisplayed', the first
949 undisplayed part is used. For a function, the first part which
950 the function return t is used. For nil, the first part is
953 :group 'gnus-article-mime
955 (item :tag "first" :value nil)
956 (item :tag "undisplayed" :value undisplayed)
957 (item :tag "undisplayed or alternative"
958 :value undisplayed-alternative)
961 (defcustom gnus-mime-action-alist
962 '(("save to file" . gnus-mime-save-part)
963 ("save and strip" . gnus-mime-save-part-and-strip)
964 ("delete part" . gnus-mime-delete-part)
965 ("display as text" . gnus-mime-inline-part)
966 ("view the part" . gnus-mime-view-part)
967 ("pipe to command" . gnus-mime-pipe-part)
968 ("toggle display" . gnus-article-press-button)
969 ("toggle display" . gnus-article-view-part-as-charset)
970 ("view as type" . gnus-mime-view-part-as-type)
971 ("view internally" . gnus-mime-view-part-internally)
972 ("view externally" . gnus-mime-view-part-externally))
973 "An alist of actions that run on the MIME attachment."
974 :group 'gnus-article-mime
975 :type '(repeat (cons (string :tag "name")
978 (defcustom gnus-auto-select-part 1
979 "Advance to next MIME part when deleting or stripping parts.
981 When 0, point will be placed on the same part as before. When
982 positive (negative), move point forward (backwards) this many
983 parts. When nil, redisplay article."
984 :version "23.0" ;; No Gnus
985 :group 'gnus-article-mime
986 :type '(choice (const nil :tag "Redisplay article.")
987 (const 1 :tag "Next part.")
988 (const 0 :tag "Current part.")
992 ;;; The treatment variables
995 (defvar gnus-part-display-hook nil
996 "Hook called on parts that are to receive treatment.")
998 (defvar gnus-article-treat-custom
999 '(choice (const :tag "Off" nil)
1001 (const :tag "Header" head)
1002 (const :tag "Last" last)
1003 (const :tag "Mime" mime)
1004 (integer :tag "Less")
1005 (repeat :tag "Groups" regexp)
1006 (sexp :tag "Predicate")))
1008 (defvar gnus-article-treat-head-custom
1009 '(choice (const :tag "Off" nil)
1010 (const :tag "Header" head)))
1012 (defvar gnus-article-treat-types '("text/plain")
1015 (defvar gnus-inhibit-treatment nil
1016 "Whether to inhibit treatment.")
1018 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
1019 "Highlight the signature.
1020 Valid values are nil, t, `head', `last', an integer or a predicate.
1021 See Info node `(gnus)Customizing Articles'."
1022 :group 'gnus-article-treat
1023 :link '(custom-manual "(gnus)Customizing Articles")
1024 :type gnus-article-treat-custom)
1025 (put 'gnus-treat-highlight-signature 'highlight t)
1027 (defcustom gnus-treat-buttonize 100000
1029 Valid values are nil, t, `head', `last', an integer or a predicate.
1030 See Info node `(gnus)Customizing Articles'."
1031 :group 'gnus-article-treat
1032 :link '(custom-manual "(gnus)Customizing Articles")
1033 :type gnus-article-treat-custom)
1034 (put 'gnus-treat-buttonize 'highlight t)
1036 (defcustom gnus-treat-buttonize-head 'head
1037 "Add buttons to the head.
1038 Valid values are nil, t, `head', `last', an integer or a predicate.
1039 See Info node `(gnus)Customizing Articles' for details."
1040 :group 'gnus-article-treat
1041 :link '(custom-manual "(gnus)Customizing Articles")
1042 :type gnus-article-treat-head-custom)
1043 (put 'gnus-treat-buttonize-head 'highlight t)
1045 (defcustom gnus-treat-emphasize
1046 (and (or window-system
1050 Valid values are nil, t, `head', `last', an integer or a predicate.
1051 See Info node `(gnus)Customizing Articles' for details."
1052 :group 'gnus-article-treat
1053 :link '(custom-manual "(gnus)Customizing Articles")
1054 :type gnus-article-treat-custom)
1055 (put 'gnus-treat-emphasize 'highlight t)
1057 (defcustom gnus-treat-strip-cr nil
1058 "Remove carriage returns.
1059 Valid values are nil, t, `head', `last', an integer or a predicate.
1060 See Info node `(gnus)Customizing Articles' for details."
1062 :group 'gnus-article-treat
1063 :link '(custom-manual "(gnus)Customizing Articles")
1064 :type gnus-article-treat-custom)
1066 (defcustom gnus-treat-unsplit-urls nil
1067 "Remove newlines from within URLs.
1068 Valid values are nil, t, `head', `last', an integer or a predicate.
1069 See Info node `(gnus)Customizing Articles' for details."
1071 :group 'gnus-article-treat
1072 :link '(custom-manual "(gnus)Customizing Articles")
1073 :type gnus-article-treat-custom)
1075 (defcustom gnus-treat-leading-whitespace nil
1076 "Remove leading whitespace in headers.
1077 Valid values are nil, t, `head', `last', an integer or a predicate.
1078 See Info node `(gnus)Customizing Articles' for details."
1080 :group 'gnus-article-treat
1081 :link '(custom-manual "(gnus)Customizing Articles")
1082 :type gnus-article-treat-custom)
1084 (defcustom gnus-treat-hide-headers 'head
1086 Valid values are nil, t, `head', `last', an integer or a predicate.
1087 See Info node `(gnus)Customizing Articles' for details."
1088 :group 'gnus-article-treat
1089 :link '(custom-manual "(gnus)Customizing Articles")
1090 :type gnus-article-treat-head-custom)
1092 (defcustom gnus-treat-hide-boring-headers nil
1093 "Hide boring headers.
1094 Valid values are nil, t, `head', `last', an integer or a predicate.
1095 See Info node `(gnus)Customizing Articles' for details."
1096 :group 'gnus-article-treat
1097 :link '(custom-manual "(gnus)Customizing Articles")
1098 :type gnus-article-treat-head-custom)
1100 (defcustom gnus-treat-hide-signature nil
1101 "Hide the signature.
1102 Valid values are nil, t, `head', `last', an integer or a predicate.
1103 See Info node `(gnus)Customizing Articles' for details."
1104 :group 'gnus-article-treat
1105 :link '(custom-manual "(gnus)Customizing Articles")
1106 :type gnus-article-treat-custom)
1108 (defcustom gnus-treat-fill-article nil
1110 Valid values are nil, t, `head', `last', an integer or a predicate.
1111 See Info node `(gnus)Customizing Articles' for details."
1112 :group 'gnus-article-treat
1113 :link '(custom-manual "(gnus)Customizing Articles")
1114 :type gnus-article-treat-custom)
1116 (defcustom gnus-treat-hide-citation nil
1118 Valid values are nil, t, `head', `last', an integer or a predicate.
1119 See Info node `(gnus)Customizing Articles' for details."
1120 :group 'gnus-article-treat
1121 :link '(custom-manual "(gnus)Customizing Articles")
1122 :type gnus-article-treat-custom)
1124 (defcustom gnus-treat-hide-citation-maybe nil
1126 Valid values are nil, t, `head', `last', an integer or a predicate.
1127 See Info node `(gnus)Customizing Articles' for details."
1128 :group 'gnus-article-treat
1129 :link '(custom-manual "(gnus)Customizing Articles")
1130 :type gnus-article-treat-custom)
1132 (defcustom gnus-treat-strip-list-identifiers 'head
1133 "Strip list identifiers from `gnus-list-identifiers`.
1134 Valid values are nil, t, `head', `last', an integer or a predicate.
1135 See Info node `(gnus)Customizing Articles' for details."
1137 :group 'gnus-article-treat
1138 :link '(custom-manual "(gnus)Customizing Articles")
1139 :type gnus-article-treat-custom)
1141 (make-obsolete-variable 'gnus-treat-strip-pgp
1142 "This option is obsolete in Gnus 5.10.")
1144 (defcustom gnus-treat-strip-pem nil
1145 "Strip PEM signatures.
1146 Valid values are nil, t, `head', `last', an integer or a predicate.
1147 See Info node `(gnus)Customizing Articles' for details."
1148 :group 'gnus-article-treat
1149 :link '(custom-manual "(gnus)Customizing Articles")
1150 :type gnus-article-treat-custom)
1152 (defcustom gnus-treat-strip-banner t
1153 "Strip banners from articles.
1154 The banner to be stripped is specified in the `banner' group parameter.
1155 Valid values are nil, t, `head', `last', an integer or a predicate.
1156 See Info node `(gnus)Customizing Articles' for details."
1157 :group 'gnus-article-treat
1158 :link '(custom-manual "(gnus)Customizing Articles")
1159 :type gnus-article-treat-custom)
1161 (defcustom gnus-treat-highlight-headers 'head
1162 "Highlight the headers.
1163 Valid values are nil, t, `head', `last', an integer or a predicate.
1164 See Info node `(gnus)Customizing Articles' for details."
1165 :group 'gnus-article-treat
1166 :link '(custom-manual "(gnus)Customizing Articles")
1167 :type gnus-article-treat-head-custom)
1168 (put 'gnus-treat-highlight-headers 'highlight t)
1170 (defcustom gnus-treat-highlight-citation t
1171 "Highlight cited text.
1172 Valid values are nil, t, `head', `last', an integer or a predicate.
1173 See Info node `(gnus)Customizing Articles' for details."
1174 :group 'gnus-article-treat
1175 :link '(custom-manual "(gnus)Customizing Articles")
1176 :type gnus-article-treat-custom)
1177 (put 'gnus-treat-highlight-citation 'highlight t)
1179 (defcustom gnus-treat-date-ut nil
1180 "Display the Date in UT (GMT).
1181 Valid values are nil, t, `head', `last', an integer or a predicate.
1182 See Info node `(gnus)Customizing Articles' for details."
1183 :group 'gnus-article-treat
1184 :link '(custom-manual "(gnus)Customizing Articles")
1185 :type gnus-article-treat-head-custom)
1187 (defcustom gnus-treat-date-local nil
1188 "Display the Date in the local timezone.
1189 Valid values are nil, t, `head', `last', an integer or a predicate.
1190 See Info node `(gnus)Customizing Articles' for details."
1191 :group 'gnus-article-treat
1192 :link '(custom-manual "(gnus)Customizing Articles")
1193 :type gnus-article-treat-head-custom)
1195 (defcustom gnus-treat-date-english nil
1196 "Display the Date in a format that can be read aloud in English.
1197 Valid values are nil, t, `head', `last', an integer or a predicate.
1198 See Info node `(gnus)Customizing Articles' for details."
1200 :group 'gnus-article-treat
1201 :link '(custom-manual "(gnus)Customizing Articles")
1202 :type gnus-article-treat-head-custom)
1204 (defcustom gnus-treat-date-lapsed nil
1205 "Display the Date header in a way that says how much time has elapsed.
1206 Valid values are nil, t, `head', `last', an integer or a predicate.
1207 See Info node `(gnus)Customizing Articles' for details."
1208 :group 'gnus-article-treat
1209 :link '(custom-manual "(gnus)Customizing Articles")
1210 :type gnus-article-treat-head-custom)
1212 (defcustom gnus-treat-date-original nil
1213 "Display the date in the original timezone.
1214 Valid values are nil, t, `head', `last', an integer or a predicate.
1215 See Info node `(gnus)Customizing Articles' for details."
1216 :group 'gnus-article-treat
1217 :link '(custom-manual "(gnus)Customizing Articles")
1218 :type gnus-article-treat-head-custom)
1220 (defcustom gnus-treat-date-iso8601 nil
1221 "Display the date in the ISO8601 format.
1222 Valid values are nil, t, `head', `last', an integer or a predicate.
1223 See Info node `(gnus)Customizing Articles' for details."
1225 :group 'gnus-article-treat
1226 :link '(custom-manual "(gnus)Customizing Articles")
1227 :type gnus-article-treat-head-custom)
1229 (defcustom gnus-treat-date-user-defined nil
1230 "Display the date in a user-defined format.
1231 The format is defined by the `gnus-article-time-format' variable.
1232 Valid values are nil, t, `head', `last', an integer or a predicate.
1233 See Info node `(gnus)Customizing Articles' for details."
1234 :group 'gnus-article-treat
1235 :link '(custom-manual "(gnus)Customizing Articles")
1236 :type gnus-article-treat-head-custom)
1238 (defcustom gnus-treat-strip-headers-in-body t
1239 "Strip the X-No-Archive header line from the beginning of the body.
1240 Valid values are nil, t, `head', `last', an integer or a predicate.
1241 See Info node `(gnus)Customizing Articles' for details."
1243 :group 'gnus-article-treat
1244 :link '(custom-manual "(gnus)Customizing Articles")
1245 :type gnus-article-treat-custom)
1247 (defcustom gnus-treat-strip-trailing-blank-lines nil
1248 "Strip trailing blank lines.
1249 Valid values are nil, t, `head', `last', an integer or a predicate.
1250 See Info node `(gnus)Customizing Articles' for details."
1251 :group 'gnus-article-treat
1252 :link '(custom-manual "(gnus)Customizing Articles")
1253 :type gnus-article-treat-custom)
1255 (defcustom gnus-treat-strip-leading-blank-lines nil
1256 "Strip leading blank lines.
1257 Valid values are nil, t, `head', `last', an integer or a predicate.
1258 See Info node `(gnus)Customizing Articles' for details."
1259 :group 'gnus-article-treat
1260 :link '(custom-manual "(gnus)Customizing Articles")
1261 :type gnus-article-treat-custom)
1263 (defcustom gnus-treat-strip-multiple-blank-lines nil
1264 "Strip multiple blank lines.
1265 Valid values are nil, t, `head', `last', an integer or a predicate.
1266 See Info node `(gnus)Customizing Articles' for details."
1267 :group 'gnus-article-treat
1268 :link '(custom-manual "(gnus)Customizing Articles")
1269 :type gnus-article-treat-custom)
1271 (defcustom gnus-treat-unfold-headers 'head
1272 "Unfold folded header lines.
1273 Valid values are nil, t, `head', `last', an integer or a predicate.
1274 See Info node `(gnus)Customizing Articles' for details."
1276 :group 'gnus-article-treat
1277 :link '(custom-manual "(gnus)Customizing Articles")
1278 :type gnus-article-treat-custom)
1280 (defcustom gnus-treat-fold-headers nil
1282 Valid values are nil, t, `head', `last', an integer or a predicate.
1283 See Info node `(gnus)Customizing Articles' for details."
1285 :group 'gnus-article-treat
1286 :link '(custom-manual "(gnus)Customizing Articles")
1287 :type gnus-article-treat-custom)
1289 (defcustom gnus-treat-fold-newsgroups 'head
1290 "Fold the Newsgroups and Followup-To headers.
1291 Valid values are nil, t, `head', `last', an integer or a predicate.
1292 See Info node `(gnus)Customizing Articles' for details."
1294 :group 'gnus-article-treat
1295 :link '(custom-manual "(gnus)Customizing Articles")
1296 :type gnus-article-treat-custom)
1298 (defcustom gnus-treat-overstrike t
1299 "Treat overstrike highlighting.
1300 Valid values are nil, t, `head', `last', an integer or a predicate.
1301 See Info node `(gnus)Customizing Articles' for details."
1302 :group 'gnus-article-treat
1303 :link '(custom-manual "(gnus)Customizing Articles")
1304 :type gnus-article-treat-custom)
1305 (put 'gnus-treat-overstrike 'highlight t)
1307 (defcustom gnus-treat-ansi-sequences (if (locate-library "ansi-color") t)
1308 "Treat ANSI SGR control sequences.
1309 Valid values are nil, t, `head', `last', an integer or a predicate.
1310 See Info node `(gnus)Customizing Articles' for details."
1311 :group 'gnus-article-treat
1312 :link '(custom-manual "(gnus)Customizing Articles")
1313 :type gnus-article-treat-custom)
1315 (make-obsolete-variable 'gnus-treat-display-xface
1316 'gnus-treat-display-x-face)
1318 (defcustom gnus-treat-display-x-face
1319 (and (not noninteractive)
1320 (or (and (fboundp 'image-type-available-p)
1321 (image-type-available-p 'xbm)
1322 (string-match "^0x" (shell-command-to-string "uncompface"))
1323 (executable-find "icontopbm"))
1324 (and (featurep 'xemacs)
1327 "Display X-Face headers.
1328 Valid values are nil, t, `head', `last', an integer or a predicate.
1329 See Info node `(gnus)Customizing Articles' and Info node
1330 `(gnus)X-Face' for details."
1331 :group 'gnus-article-treat
1333 :link '(custom-manual "(gnus)Customizing Articles")
1334 :link '(custom-manual "(gnus)X-Face")
1335 :type gnus-article-treat-head-custom
1336 :set (lambda (symbol value)
1339 (cond ((or (boundp symbol) (get symbol 'saved-value))
1341 ((boundp 'gnus-treat-display-xface)
1343 ** gnus-treat-display-xface is an obsolete variable;\
1344 use gnus-treat-display-x-face instead")
1345 (default-value 'gnus-treat-display-xface))
1346 ((get 'gnus-treat-display-xface 'saved-value)
1348 ** gnus-treat-display-xface is an obsolete variable;\
1349 use gnus-treat-display-x-face instead")
1350 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1353 (put 'gnus-treat-display-x-face 'highlight t)
1355 (defcustom gnus-article-should-use-smiley-mule
1356 (not (or (featurep 'xemacs)
1357 (gnus-image-type-available-p 'xpm)
1358 (gnus-image-type-available-p 'pbm)))
1359 "Non-nil means use `smiley-mule' to show smileys rather than `smiley'.
1360 `smiley-mule' is boundled in BITMAP-MULE package. You can set it to t
1361 even if your Emacs supports images. It has no effect on XEmacs."
1362 :group 'gnus-article-various
1364 :get (lambda (symbol)
1365 (and (not noninteractive)
1366 (default-value symbol)
1367 (not (featurep 'xemacs))
1368 (module-installed-p 'smiley-mule)
1370 :set (lambda (symbol value)
1371 (set-default symbol (and (not noninteractive)
1373 (not (featurep 'xemacs))
1374 (module-installed-p 'smiley-mule)
1377 (defvar gnus-article-smiley-mule-loaded-p nil
1378 "Internal variable used to say whether `smiley-mule' is loaded (whether
1379 smiley functions are not overridden by `smiley').")
1381 (defcustom gnus-treat-display-face
1382 (and (not noninteractive)
1383 (or (and (fboundp 'image-type-available-p)
1384 (image-type-available-p 'png))
1385 (and (featurep 'xemacs)
1388 "Display Face headers.
1389 Valid values are nil, t, `head', `last', an integer or a predicate.
1390 See Info node `(gnus)Customizing Articles' and Info node
1391 `(gnus)X-Face' for details."
1392 :group 'gnus-article-treat
1394 :link '(custom-manual "(gnus)Customizing Articles")
1395 :link '(custom-manual "(gnus)X-Face")
1396 :type gnus-article-treat-head-custom)
1397 (put 'gnus-treat-display-face 'highlight t)
1399 (defcustom gnus-treat-display-smileys
1400 (if (and (not noninteractive)
1401 (or (and (featurep 'xemacs)
1403 (gnus-image-type-available-p 'xpm)
1404 (gnus-image-type-available-p 'pbm)
1405 (and (not (featurep 'xemacs))
1407 (module-installed-p 'smiley-mule))))
1411 Valid values are nil, t, `head', `last', an integer or a predicate.
1412 See Info node `(gnus)Customizing Articles' and Info node
1413 `(gnus)Smileys' for details."
1414 :group 'gnus-article-treat
1416 :link '(custom-manual "(gnus)Customizing Articles")
1417 :link '(custom-manual "(gnus)Smileys")
1418 :type gnus-article-treat-custom)
1419 (put 'gnus-treat-display-smileys 'highlight t)
1421 (defcustom gnus-treat-from-picon
1422 (if (and (gnus-image-type-available-p 'xpm)
1423 (gnus-picons-installed-p))
1425 "Display picons in the From header.
1426 Valid values are nil, t, `head', `last', an integer or a predicate.
1427 See Info node `(gnus)Customizing Articles' and Info node
1428 `(gnus)Picons' for details."
1430 :group 'gnus-article-treat
1432 :link '(custom-manual "(gnus)Customizing Articles")
1433 :link '(custom-manual "(gnus)Picons")
1434 :type gnus-article-treat-head-custom)
1435 (put 'gnus-treat-from-picon 'highlight t)
1437 (defcustom gnus-treat-mail-picon
1438 (if (and (gnus-image-type-available-p 'xpm)
1439 (gnus-picons-installed-p))
1441 "Display picons in To and Cc headers.
1442 Valid values are nil, t, `head', `last', an integer or a predicate.
1443 See Info node `(gnus)Customizing Articles' and Info node
1444 `(gnus)Picons' for details."
1446 :group 'gnus-article-treat
1448 :link '(custom-manual "(gnus)Customizing Articles")
1449 :link '(custom-manual "(gnus)Picons")
1450 :type gnus-article-treat-head-custom)
1451 (put 'gnus-treat-mail-picon 'highlight t)
1453 (defcustom gnus-treat-newsgroups-picon
1454 (if (and (gnus-image-type-available-p 'xpm)
1455 (gnus-picons-installed-p))
1457 "Display picons in the Newsgroups and Followup-To headers.
1458 Valid values are nil, t, `head', `last', an integer or a predicate.
1459 See Info node `(gnus)Customizing Articles' and Info node
1460 `(gnus)Picons' for details."
1462 :group 'gnus-article-treat
1464 :link '(custom-manual "(gnus)Customizing Articles")
1465 :link '(custom-manual "(gnus)Picons")
1466 :type gnus-article-treat-head-custom)
1467 (put 'gnus-treat-newsgroups-picon 'highlight t)
1469 (defcustom gnus-treat-body-boundary
1470 (if (and (eq window-system 'x)
1471 (or gnus-treat-newsgroups-picon
1472 gnus-treat-mail-picon
1473 gnus-treat-from-picon))
1475 "Draw a boundary at the end of the headers.
1476 Valid values are nil and `head'.
1477 See Info node `(gnus)Customizing Articles' for details."
1479 :group 'gnus-article-treat
1480 :link '(custom-manual "(gnus)Customizing Articles")
1481 :type gnus-article-treat-head-custom)
1483 (defcustom gnus-treat-capitalize-sentences nil
1484 "Capitalize sentence-starting words.
1485 Valid values are nil, t, `head', `last', an integer or a predicate.
1486 See Info node `(gnus)Customizing Articles' for details."
1488 :group 'gnus-article-treat
1489 :link '(custom-manual "(gnus)Customizing Articles")
1490 :type gnus-article-treat-custom)
1492 (defcustom gnus-treat-wash-html nil
1494 Valid values are nil, t, `head', `last', an integer or a predicate.
1495 See Info node `(gnus)Customizing Articles' for details."
1497 :group 'gnus-article-treat
1498 :link '(custom-manual "(gnus)Customizing Articles")
1499 :type gnus-article-treat-custom)
1501 (defcustom gnus-treat-fill-long-lines nil
1503 Valid values are nil, t, `head', `last', an integer or a predicate.
1504 See Info node `(gnus)Customizing Articles' for details."
1505 :group 'gnus-article-treat
1506 :link '(custom-manual "(gnus)Customizing Articles")
1507 :type gnus-article-treat-custom)
1509 (defcustom gnus-treat-play-sounds nil
1511 Valid values are nil, t, `head', `last', an integer or a predicate.
1512 See Info node `(gnus)Customizing Articles' for details."
1514 :group 'gnus-article-treat
1515 :link '(custom-manual "(gnus)Customizing Articles")
1516 :type gnus-article-treat-custom)
1518 (defcustom gnus-treat-decode-article-as-default-mime-charset nil
1519 "Decode an article as `default-mime-charset'. For instance, if you want to
1520 attempt to decode an article even if the value of `gnus-show-mime' is nil,
1521 you could set this variable to something like: nil for don't decode, t for
1522 decode the body, '(or header t) for the whole article, etc."
1523 :group 'gnus-article-treat
1524 :type '(radio (const :tag "Off" nil)
1525 (const :tag "Decode body" t)
1526 (const :tag "Decode all" (or head t))))
1528 (defcustom gnus-treat-translate nil
1529 "Translate articles from one language to another.
1530 Valid values are nil, t, `head', `last', an integer or a predicate.
1531 See Info node `(gnus)Customizing Articles' for details."
1533 :group 'gnus-article-treat
1534 :link '(custom-manual "(gnus)Customizing Articles")
1535 :type gnus-article-treat-custom)
1537 (defcustom gnus-treat-x-pgp-sig nil
1539 To automatically treat X-PGP-Sig, set it to head.
1540 Valid values are nil, t, `head', `last', an integer or a predicate.
1541 See Info node `(gnus)Customizing Articles' for details."
1543 :group 'gnus-article-treat
1544 :group 'mime-security
1545 :type gnus-article-treat-custom)
1547 (defcustom gnus-treat-monafy nil
1548 "Display body part with mona font.
1549 Valid values are nil, t, `head', `last', an integer or a predicate.
1550 See Info node `(gnus)Customizing Articles' for details."
1551 :group 'gnus-article-treat
1552 :group 'mime-security
1553 :link '(custom-manual "(gnus)Customizing Articles")
1554 :type gnus-article-treat-custom)
1556 (defvar gnus-article-encrypt-protocol-alist
1557 '(("PGP" . mml2015-self-encrypt)))
1559 ;; Set to nil if more than one protocol added to
1560 ;; gnus-article-encrypt-protocol-alist.
1561 (defcustom gnus-article-encrypt-protocol "PGP"
1562 "The protocol used for encrypt articles.
1563 It is a string, such as \"PGP\". If nil, ask user."
1566 :group 'mime-security)
1568 (defvar gnus-article-wash-function nil
1569 "Function used for converting HTML into text.")
1571 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1572 (mm-coding-system-p 'utf-8)
1573 (executable-find idna-program))
1574 "Whether IDNA decoding of headers is used when viewing messages.
1575 This requires GNU Libidn, and by default only enabled if it is found."
1577 :group 'gnus-article-headers
1580 (defcustom gnus-article-over-scroll nil
1581 "If non-nil, allow scrolling the article buffer even when there no more text."
1583 :group 'gnus-article
1586 ;;; Internal variables
1588 (defvar gnus-english-month-names
1589 '("January" "February" "March" "April" "May" "June" "July" "August"
1590 "September" "October" "November" "December"))
1592 (defvar gnus-button-regexp nil)
1593 (defvar gnus-button-marker-list nil)
1594 ;; Regexp matching any of the regexps from `gnus-button-alist'.
1596 (defvar gnus-button-last nil)
1597 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
1599 (defvar article-goto-body-goes-to-point-min-p nil)
1600 (defvar gnus-article-wash-types nil)
1601 (defvar gnus-article-emphasis-alist nil)
1602 (defvar gnus-article-image-alist nil)
1604 (defvar gnus-article-mime-handle-alist-1 nil)
1605 (defvar gnus-treatment-function-alist
1606 '((gnus-treat-decode-article-as-default-mime-charset
1607 gnus-article-decode-article-as-default-mime-charset)
1608 (gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1609 (gnus-treat-monafy gnus-article-monafy)
1610 (gnus-treat-strip-banner gnus-article-strip-banner)
1611 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1612 (gnus-treat-buttonize gnus-article-add-buttons)
1613 (gnus-treat-fill-article gnus-article-fill-cited-article)
1614 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1615 (gnus-treat-strip-cr gnus-article-remove-cr)
1616 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1617 (gnus-treat-date-ut gnus-article-date-ut)
1618 (gnus-treat-date-local gnus-article-date-local)
1619 (gnus-treat-date-english gnus-article-date-english)
1620 (gnus-treat-date-original gnus-article-date-original)
1621 (gnus-treat-date-user-defined gnus-article-date-user)
1622 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1623 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1624 (gnus-treat-display-face gnus-article-display-face)
1625 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1626 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1627 (gnus-treat-hide-signature gnus-article-hide-signature)
1628 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1629 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1630 (gnus-treat-strip-pem gnus-article-hide-pem)
1631 (gnus-treat-from-picon gnus-treat-from-picon)
1632 (gnus-treat-mail-picon gnus-treat-mail-picon)
1633 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1634 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1635 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1636 (gnus-treat-strip-trailing-blank-lines
1637 gnus-article-remove-trailing-blank-lines)
1638 (gnus-treat-strip-leading-blank-lines
1639 gnus-article-strip-leading-blank-lines)
1640 (gnus-treat-strip-multiple-blank-lines
1641 gnus-article-strip-multiple-blank-lines)
1642 (gnus-treat-overstrike gnus-article-treat-overstrike)
1643 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences)
1644 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1645 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1646 ;; Displaying X-Face should be done after unfolding headers
1647 ;; to protect bitmap lines.
1648 (gnus-treat-display-x-face gnus-article-display-x-face)
1649 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1650 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1651 (gnus-treat-display-smileys gnus-treat-smiley)
1652 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1653 (gnus-treat-wash-html gnus-article-wash-html)
1654 (gnus-treat-emphasize gnus-article-emphasize)
1655 (gnus-treat-hide-citation gnus-article-hide-citation)
1656 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1657 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1658 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1659 (gnus-treat-play-sounds gnus-earcon-display)))
1661 (defvar gnus-article-mime-handle-alist nil)
1662 (defvar article-lapsed-timer nil)
1663 (defvar gnus-article-current-summary nil)
1665 (defvar gnus-article-mode-syntax-table
1666 (let ((table (copy-syntax-table text-mode-syntax-table)))
1667 ;; This causes the citation match run O(2^n).
1668 ;; (modify-syntax-entry ?- "w" table)
1669 (modify-syntax-entry ?> ")<" table)
1670 (modify-syntax-entry ?< "(>" table)
1671 ;; make M-. in article buffers work for `foo' strings
1672 (modify-syntax-entry ?' " " table)
1673 (modify-syntax-entry ?` " " table)
1675 "Syntax table used in article mode buffers.
1676 Initialized from `text-mode-syntax-table.")
1678 (defvar gnus-save-article-buffer nil)
1680 (defvar gnus-article-mode-line-format-alist
1681 (nconc '((?w (gnus-article-wash-status) ?s)
1682 (?m (gnus-article-mime-part-status) ?s))
1683 gnus-summary-mode-line-format-alist))
1685 (defvar gnus-number-of-articles-to-be-saved nil)
1687 (defvar gnus-inhibit-hiding nil)
1689 (defvar gnus-article-edit-mode nil)
1691 ;;; Macros for dealing with the article buffer.
1693 (defmacro gnus-with-article-headers (&rest forms)
1695 (set-buffer gnus-article-buffer)
1697 (let ((inhibit-read-only t)
1698 (inhibit-point-motion-hooks t)
1699 (case-fold-search t))
1700 (article-narrow-to-head)
1703 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1704 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1706 (defmacro gnus-with-article-buffer (&rest forms)
1708 (set-buffer gnus-article-buffer)
1709 (let ((inhibit-read-only t))
1712 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1713 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1715 (defun gnus-article-goto-header (header)
1716 "Go to HEADER, which is a regular expression."
1717 (re-search-forward (concat "^\\(" header "\\):") nil t))
1719 (defsubst gnus-article-hide-text (b e props)
1720 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1721 (gnus-add-text-properties-when 'article-type nil b e props)
1722 (when (memq 'intangible props)
1724 (max (1- b) (point-min))
1725 b 'intangible (cddr (memq 'intangible props)))))
1727 (defsubst gnus-article-unhide-text (b e)
1728 "Remove hidden text properties from region between B and E."
1729 (remove-text-properties b e gnus-hidden-properties)
1730 (when (memq 'intangible gnus-hidden-properties)
1731 (put-text-property (max (1- b) (point-min))
1732 b 'intangible nil)))
1734 (defun gnus-article-hide-text-type (b e type)
1735 "Hide text of TYPE between B and E."
1736 (gnus-add-wash-type type)
1737 (gnus-article-hide-text
1738 b e (cons 'article-type (cons type gnus-hidden-properties))))
1740 (defun gnus-article-unhide-text-type (b e type)
1741 "Unhide text of TYPE between B and E."
1742 (gnus-delete-wash-type type)
1743 (remove-text-properties
1744 b e (cons 'article-type (cons type gnus-hidden-properties)))
1745 (when (memq 'intangible gnus-hidden-properties)
1746 (put-text-property (max (1- b) (point-min))
1747 b 'intangible nil)))
1749 (defun gnus-article-hide-text-of-type (type)
1750 "Hide text of TYPE in the current buffer."
1752 (let ((b (point-min))
1754 (while (setq b (text-property-any b e 'article-type type))
1755 (add-text-properties b (incf b) gnus-hidden-properties)))))
1757 (defun gnus-article-delete-text-of-type (type)
1758 "Delete text of TYPE in the current buffer."
1760 (let ((b (point-min)))
1761 (while (setq b (text-property-any b (point-max) 'article-type type))
1763 b (or (text-property-not-all b (point-max) 'article-type type)
1766 (defun gnus-article-delete-invisible-text ()
1767 "Delete all invisible text in the current buffer."
1769 (let ((b (point-min)))
1770 (while (setq b (text-property-any b (point-max) 'invisible t))
1772 b (or (text-property-not-all b (point-max) 'invisible t)
1775 (defun gnus-article-text-type-exists-p (type)
1776 "Say whether any text of type TYPE exists in the buffer."
1777 (text-property-any (point-min) (point-max) 'article-type type))
1779 (defsubst gnus-article-header-rank ()
1780 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1781 (let ((list gnus-sorted-header-list)
1784 (if (looking-at (car list))
1786 (setq list (cdr list))
1790 (defun article-hide-headers (&optional arg delete)
1791 "Hide unwanted headers and possibly sort them as well."
1792 (interactive (gnus-article-hidden-arg))
1793 ;; Lars said that this function might be inhibited.
1794 (if (gnus-article-check-hidden-text 'headers arg)
1796 ;; Show boring headers as well.
1797 (gnus-article-show-hidden-text 'boring-headers)
1798 (when (eq 1 (point-min))
1799 (set-window-start (get-buffer-window (current-buffer)) 1)))
1800 (unless gnus-inhibit-hiding
1801 (let ((inhibit-read-only t)
1802 (case-fold-search t)
1803 (max (1+ (length gnus-sorted-header-list)))
1804 (inhibit-point-motion-hooks t)
1805 (cur (current-buffer))
1806 ignored visible beg)
1808 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1809 ;; group parameters, so we should go to the summary buffer.
1812 (progn (set-buffer gnus-summary-buffer) t)
1814 (setq ignored (when (not gnus-visible-headers)
1815 (cond ((stringp gnus-ignored-headers)
1816 gnus-ignored-headers)
1817 ((listp gnus-ignored-headers)
1818 (mapconcat 'identity
1819 gnus-ignored-headers
1821 visible (cond ((stringp gnus-visible-headers)
1822 gnus-visible-headers)
1823 ((and gnus-visible-headers
1824 (listp gnus-visible-headers))
1825 (mapconcat 'identity
1826 gnus-visible-headers
1830 ;; First we narrow to just the headers.
1831 (article-narrow-to-head)
1832 ;; Hide any "From " lines at the beginning of (mail) articles.
1833 (while (looking-at "From ")
1837 (delete-region (point-min) (point))
1838 (gnus-article-hide-text (point-min) (point)
1839 (nconc (list 'article-type 'headers)
1840 gnus-hidden-properties))))
1841 ;; Then treat the rest of the header lines.
1842 ;; Then we use the two regular expressions
1843 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1844 ;; select which header lines is to remain visible in the
1846 (while (re-search-forward "^[^ \t:]*:" nil t)
1848 ;; Mark the rank of the header.
1850 (point) (1+ (point)) 'message-rank
1851 (if (or (and visible (looking-at visible))
1853 (not (looking-at ignored))))
1854 (gnus-article-header-rank)
1857 (message-sort-headers-1)
1858 (when (setq beg (text-property-any
1859 (point-min) (point-max) 'message-rank (+ 2 max)))
1860 ;; We delete or make invisible the unwanted headers.
1861 (gnus-add-wash-type 'headers)
1864 (add-text-properties
1865 (point-min) (+ 5 (point-min))
1866 '(article-type headers dummy-invisible t))
1867 (delete-region beg (point-max)))
1868 (gnus-article-hide-text-type beg (point-max) 'headers)))))))))
1870 (defun article-hide-boring-headers (&optional arg)
1871 "Toggle hiding of headers that aren't very interesting.
1872 If given a negative prefix, always show; if given a positive prefix,
1874 (interactive (gnus-article-hidden-arg))
1875 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1876 (not gnus-show-all-headers))
1879 (let ((inhibit-read-only t)
1880 (inhibit-point-motion-hooks t))
1881 (article-narrow-to-head)
1882 (dolist (elem gnus-boring-article-headers)
1883 (goto-char (point-min))
1885 ;; Hide empty headers.
1887 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1889 (gnus-article-hide-text-type
1893 (if (re-search-forward "^[^ \t]" nil t)
1897 ;; Hide boring Newsgroups header.
1898 ((eq elem 'newsgroups)
1899 (when (gnus-string-equal
1900 (gnus-fetch-field "newsgroups")
1901 (gnus-group-real-name
1902 (if (boundp 'gnus-newsgroup-name)
1905 (gnus-article-hide-header "newsgroups")))
1906 ((eq elem 'to-address)
1907 (let ((to (message-fetch-field "to"))
1909 (gnus-parameter-to-address
1910 (if (boundp 'gnus-newsgroup-name)
1911 gnus-newsgroup-name ""))))
1912 (when (and to to-address
1915 ;; only one address in To
1916 (nth 1 (mail-extract-address-components to))
1918 (gnus-article-hide-header "to"))))
1920 (let ((to (message-fetch-field "to"))
1922 (gnus-parameter-to-list
1923 (if (boundp 'gnus-newsgroup-name)
1924 gnus-newsgroup-name ""))))
1925 (when (and to to-list
1928 ;; only one address in To
1929 (nth 1 (mail-extract-address-components to))
1931 (gnus-article-hide-header "to"))))
1933 (let ((cc (message-fetch-field "cc"))
1935 (gnus-parameter-to-list
1936 (if (boundp 'gnus-newsgroup-name)
1937 gnus-newsgroup-name ""))))
1938 (when (and cc to-list
1941 ;; only one address in CC
1942 (nth 1 (mail-extract-address-components cc))
1944 (gnus-article-hide-header "cc"))))
1945 ((eq elem 'followup-to)
1946 (when (gnus-string-equal
1947 (message-fetch-field "followup-to")
1948 (message-fetch-field "newsgroups"))
1949 (gnus-article-hide-header "followup-to")))
1950 ((eq elem 'reply-to)
1951 (if (gnus-group-find-parameter
1952 gnus-newsgroup-name 'broken-reply-to)
1953 (gnus-article-hide-header "reply-to")
1954 (let ((from (message-fetch-field "from"))
1955 (reply-to (message-fetch-field "reply-to")))
1962 (lambda (x) (downcase (cadr x)))
1963 (mail-extract-address-components from t))
1966 (lambda (x) (downcase (cadr x)))
1967 (mail-extract-address-components reply-to t))
1969 (gnus-article-hide-header "reply-to")))))
1971 (let ((date (message-fetch-field "date")))
1973 (< (days-between (current-time-string) date)
1975 (gnus-article-hide-header "date"))))
1977 (let ((to (message-fetch-field "to"))
1978 (cc (message-fetch-field "cc")))
1979 (when (> (length to) 1024)
1980 (gnus-article-hide-header "to"))
1981 (when (> (length cc) 1024)
1982 (gnus-article-hide-header "cc"))))
1986 (goto-char (point-min))
1987 (while (re-search-forward "^to:" nil t)
1988 (setq to-count (1+ to-count)))
1989 (when (> to-count 1)
1990 (while (> to-count 0)
1991 (goto-char (point-min))
1993 (re-search-forward "^to:" nil nil to-count)
1995 (narrow-to-region (point) (point-max))
1996 (gnus-article-hide-header "to"))
1997 (setq to-count (1- to-count))))
1998 (goto-char (point-min))
1999 (while (re-search-forward "^cc:" nil t)
2000 (setq cc-count (1+ cc-count)))
2001 (when (> cc-count 1)
2002 (while (> cc-count 0)
2003 (goto-char (point-min))
2005 (re-search-forward "^cc:" nil nil cc-count)
2007 (narrow-to-region (point) (point-max))
2008 (gnus-article-hide-header "cc"))
2009 (setq cc-count (1- cc-count)))))))))))))
2011 (defun gnus-article-hide-header (header)
2013 (goto-char (point-min))
2014 (when (re-search-forward (concat "^" header ":") nil t)
2015 (gnus-article-hide-text-type
2019 (if (re-search-forward "^[^ \t]" nil t)
2024 (defvar gnus-article-normalized-header-length 40
2025 "Length of normalized headers.")
2027 (defun article-normalize-headers ()
2028 "Make all header lines 40 characters long."
2030 (let ((inhibit-read-only t)
2034 (article-narrow-to-head)
2037 ((< (setq column (- (point-at-eol) (point)))
2038 gnus-article-normalized-header-length)
2040 (insert (make-string
2041 (- gnus-article-normalized-header-length column)
2043 ((> column gnus-article-normalized-header-length)
2044 (gnus-put-text-property
2046 (forward-char gnus-article-normalized-header-length)
2053 (forward-line 1))))))
2055 (defun article-treat-dumbquotes ()
2056 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
2057 Note that this function guesses whether a character is a sm*rtq**t* or
2058 not, so it should only be used interactively.
2060 Sm*rtq**t*s are M****s***'s unilateral extension to the
2061 iso-8859-1 character map in an attempt to provide more quoting
2062 characters. If you see something like \\222 or \\264 where
2063 you're expecting some kind of apostrophe or quotation mark, then
2066 (article-translate-strings gnus-article-dumbquotes-map))
2068 (defun article-translate-characters (from to)
2069 "Translate all characters in the body of the article according to FROM and TO.
2070 FROM is a string of characters to translate from; to is a string of
2071 characters to translate to."
2073 (when (article-goto-body)
2074 (let ((inhibit-read-only t)
2075 (x (make-string 225 ?x))
2077 (while (< (incf i) (length x))
2080 (while (< i (length from))
2081 (aset x (aref from i) (aref to i))
2083 (translate-region (point) (point-max) x)))))
2085 (defun article-translate-strings (map)
2086 "Translate all string in the body of the article according to MAP.
2087 MAP is an alist where the elements are on the form (\"from\" \"to\")."
2089 (when (article-goto-body)
2090 (let ((inhibit-read-only t))
2093 (while (search-forward (car elem) nil t)
2094 (replace-match (cadr elem)))))))))
2096 (defun article-treat-overstrike ()
2097 "Translate overstrikes into bold text."
2100 (when (article-goto-body)
2101 (let ((inhibit-read-only t))
2102 (while (search-forward "\b" nil t)
2103 (let ((next (char-after))
2107 previous (char-after))
2111 ;; We do the boldification/underlining by hiding the
2112 ;; overstrikes and putting the proper text property
2116 (gnus-article-hide-text-type start (point) 'overstrike)
2117 (put-text-property (point) end 'face 'bold))
2119 (gnus-article-hide-text-type
2120 (1- (point)) (1+ (point)) 'overstrike)
2122 start (1- (point)) 'face 'underline))
2124 (gnus-article-hide-text-type start (point) 'overstrike)
2126 (point) end 'face 'underline)))))))))
2128 (defun article-treat-ansi-sequences ()
2129 "Translate ANSI SGR control sequences into overlays or extents."
2132 (when (article-goto-body)
2133 (let ((inhibit-read-only t))
2134 (ansi-color-apply-on-region (point) (point-max))))))
2136 (defun gnus-article-treat-unfold-headers ()
2137 "Unfold folded message headers.
2138 Only the headers that fit into the current window width will be
2141 (gnus-with-article-headers
2145 (mail-header-narrow-to-field)
2146 (let ((header (buffer-string)))
2149 (goto-char (point-min))
2150 (while (re-search-forward "\n[\t ]" nil t)
2151 (replace-match " " t t)))
2152 (setq length (- (point-max) (point-min) 1)))
2153 (when (< length (window-width))
2154 (while (re-search-forward "\n[\t ]" nil t)
2155 (replace-match " " t t)))
2156 (goto-char (point-max)))))))
2158 (defun gnus-article-treat-fold-headers ()
2159 "Fold message headers."
2161 (gnus-with-article-headers
2164 (mail-header-narrow-to-field)
2165 (mail-header-fold-field)
2166 (goto-char (point-max))))))
2168 (defun gnus-treat-smiley ()
2169 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2171 (unless (featurep 'xemacs)
2172 (when (and (not gnus-article-should-use-smiley-mule)
2173 gnus-article-smiley-mule-loaded-p)
2174 (load "smiley" nil t)
2175 (setq gnus-article-smiley-mule-loaded-p nil))
2176 (when (and gnus-article-should-use-smiley-mule
2177 (not gnus-article-smiley-mule-loaded-p))
2178 (load "smiley-mule" nil t)
2179 (setq gnus-article-smiley-mule-loaded-p t)))
2180 (gnus-with-article-buffer
2181 (if (memq 'smiley gnus-article-wash-types)
2182 (gnus-delete-images 'smiley)
2184 (let ((images (smiley-region (point) (point-max))))
2186 (gnus-add-wash-type 'smiley)
2187 (dolist (image images)
2188 (gnus-add-image 'smiley image)))))))
2190 (defun gnus-article-remove-images ()
2191 "Remove all images from the article buffer."
2193 (gnus-with-article-buffer
2194 (dolist (elem gnus-article-image-alist)
2195 (gnus-delete-images (car elem)))))
2197 (defun gnus-article-treat-fold-newsgroups ()
2198 "Unfold folded message headers.
2199 Only the headers that fit into the current window width will be
2202 (gnus-with-article-headers
2203 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2205 (mail-header-narrow-to-field)
2206 (while (re-search-forward ", *" nil t)
2207 (replace-match ", " t t))
2208 (mail-header-fold-field)
2209 (goto-char (point-max))))))
2211 (defun gnus-article-treat-body-boundary ()
2212 "Place a boundary line at the end of the headers."
2214 (when (and gnus-body-boundary-delimiter
2215 (> (length gnus-body-boundary-delimiter) 0))
2216 (gnus-with-article-headers
2217 (goto-char (point-max))
2218 (let ((start (point)))
2219 (insert "X-Boundary: ")
2220 (gnus-add-text-properties start (point) '(invisible t intangible t))
2222 (while (>= (1- (window-width)) (length str))
2223 (setq str (concat str gnus-body-boundary-delimiter)))
2224 (substring str 0 (1- (window-width))))
2226 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2228 (defun article-fill-long-lines ()
2229 "Fill lines that are wider than the window width."
2232 (let ((inhibit-read-only t)
2233 (width (window-width (get-buffer-window (current-buffer)))))
2236 (let ((adaptive-fill-mode nil)) ;Why? -sm
2239 (when (>= (current-column) (min fill-column width))
2240 (narrow-to-region (min (1+ (point)) (point-max))
2242 (let ((goback (point-marker)))
2243 (fill-paragraph nil)
2244 (goto-char (marker-position goback)))
2246 (forward-line 1)))))))
2248 (defun article-capitalize-sentences ()
2249 "Capitalize the first word in each sentence."
2252 (let ((inhibit-read-only t)
2253 (paragraph-start "^[\n\^L]"))
2257 (forward-sentence)))))
2259 (defun article-remove-cr ()
2260 "Remove trailing CRs and then translate remaining CRs into LFs."
2263 (let ((inhibit-read-only t))
2264 (goto-char (point-min))
2265 (while (re-search-forward "\r+$" nil t)
2266 (replace-match "" t t))
2267 (goto-char (point-min))
2268 (while (search-forward "\r" nil t)
2269 (replace-match "\n" t t)))))
2271 (defun article-remove-trailing-blank-lines ()
2272 "Remove all trailing blank lines from the article."
2275 (let ((inhibit-read-only t))
2276 (goto-char (point-max))
2280 (while (and (not (bobp))
2281 (looking-at "^[ \t]*$")
2282 (not (gnus-annotation-in-region-p
2283 (point) (point-at-eol))))
2289 (defvar gnus-face-properties-alist))
2291 (defun article-display-face ()
2292 "Display any Face headers in the header."
2294 (let ((wash-face-p buffer-read-only))
2295 (gnus-with-article-headers
2296 ;; When displaying parts, this function can be called several times on
2297 ;; the same article, without any intended toggle semantic (as typing `W
2298 ;; D d' would have). So face deletion must occur only when we come from
2299 ;; an interactive command, that is when the *Article* buffer is
2301 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2302 (gnus-delete-images 'face)
2303 (let (face faces from)
2304 (save-current-buffer
2305 (when (and wash-face-p
2306 (gnus-buffer-live-p gnus-original-article-buffer)
2307 (not (re-search-forward "^Face:[\t ]*" nil t)))
2308 (set-buffer gnus-original-article-buffer))
2310 (mail-narrow-to-head)
2311 (while (gnus-article-goto-header "Face")
2312 (push (mail-header-field-value) faces))))
2314 (goto-char (point-min))
2315 (let ((from (gnus-article-goto-header "from"))
2320 (insert "[no `from' set]\n"))
2322 (when (setq png (gnus-convert-face-to-png (pop faces)))
2324 (apply 'gnus-create-image png 'png t
2325 (cdr (assq 'png gnus-face-properties-alist))))
2327 (gnus-add-wash-type 'face)
2328 (gnus-add-image 'face image)
2329 (gnus-put-image image nil 'face))))))))))
2331 (defun article-display-x-face (&optional force)
2332 "Look for an X-Face header and display it if present."
2333 (interactive (list 'force))
2334 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2335 (gnus-with-article-headers
2336 ;; Delete the old process, if any.
2337 (when (process-status "article-x-face")
2338 (delete-process "article-x-face"))
2339 ;; See the comment in `article-display-face'.
2340 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2341 ;; We have already displayed X-Faces, so we remove them
2343 (gnus-delete-images 'xface)
2345 (let (x-faces from face)
2346 (save-current-buffer
2347 (when (and wash-face-p
2348 (gnus-buffer-live-p gnus-original-article-buffer)
2349 (not (re-search-forward "^X-Face:[\t ]*" nil t)))
2350 ;; If type `W f', use gnus-original-article-buffer,
2351 ;; otherwise use the current buffer because displaying
2352 ;; RFC822 parts calls this function too.
2353 (set-buffer gnus-original-article-buffer))
2355 (mail-narrow-to-head)
2356 (while (gnus-article-goto-header "X-Face")
2357 (push (mail-header-field-value) x-faces))
2358 (setq from (message-fetch-field "from"))))
2359 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2360 ;; single external face.
2361 (when (stringp gnus-article-x-face-command)
2362 (setq x-faces (list (car x-faces))))
2364 gnus-article-x-face-command
2366 ;; Check whether this face is censored.
2367 (not gnus-article-x-face-too-ugly)
2369 (not (string-match gnus-article-x-face-too-ugly
2371 (while (setq face (pop x-faces))
2372 ;; We display the face.
2373 (cond ((stringp gnus-article-x-face-command)
2374 ;; The command is a string, so we interpret the command
2375 ;; as a, well, command, and fork it off.
2376 (let ((process-connection-type nil))
2377 (gnus-set-process-query-on-exit-flag
2379 "article-x-face" nil shell-file-name
2380 shell-command-switch gnus-article-x-face-command)
2384 (process-send-region "article-x-face"
2385 (point-min) (point-max)))
2386 (process-send-eof "article-x-face")))
2387 ((functionp gnus-article-x-face-command)
2388 ;; The command is a lisp function, so we call it.
2389 (funcall gnus-article-x-face-command face))
2391 (error "%s is not a function"
2392 gnus-article-x-face-command))))))))))
2394 (defun article-decode-mime-words ()
2395 "Decode all MIME-encoded words in the article."
2397 (gnus-with-article-buffer
2398 (let ((inhibit-point-motion-hooks t)
2399 (mail-parse-charset gnus-newsgroup-charset)
2400 (mail-parse-ignored-charsets
2401 (with-current-buffer gnus-summary-buffer
2402 gnus-newsgroup-ignored-charsets)))
2403 (mail-decode-encoded-word-region (point-min) (point-max)))))
2405 (defun article-decode-charset (&optional prompt)
2406 "Decode charset-encoded text in the article.
2407 If PROMPT (the prefix), prompt for a coding system to use."
2409 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2410 (inhibit-read-only t)
2411 (mail-parse-charset gnus-newsgroup-charset)
2412 (mail-parse-ignored-charsets
2413 (save-excursion (condition-case nil
2414 (set-buffer gnus-summary-buffer)
2416 gnus-newsgroup-ignored-charsets))
2417 ct cte ctl charset format)
2420 (article-narrow-to-head)
2421 (setq ct (message-fetch-field "Content-Type" t)
2422 cte (message-fetch-field "Content-Transfer-Encoding" t)
2423 ctl (and ct (ignore-errors
2424 (mail-header-parse-content-type ct)))
2427 (mm-read-coding-system "Charset to decode: "))
2429 (mail-content-type-get ctl 'charset)))
2430 format (and ctl (mail-content-type-get ctl 'format)))
2432 (setq cte (mail-header-strip cte)))
2433 (if (and ctl (not (string-match "/" (car ctl))))
2435 (goto-char (point-max)))
2438 (narrow-to-region (point) (point-max))
2439 (when (and (eq mail-parse-charset 'gnus-decoded)
2440 (eq (mm-body-7-or-8) '8bit))
2441 ;; The text code could have been decoded.
2442 (setq charset mail-parse-charset))
2443 (when (and (or (not ctl)
2444 (equal (car ctl) "text/plain"))
2445 (not format)) ;; article with format will decode later.
2447 charset (and cte (intern (downcase
2448 (gnus-strip-whitespace cte))))
2451 (defun article-decode-encoded-words ()
2452 "Remove encoded-word encoding from headers."
2453 (let ((charset (save-excursion
2454 (set-buffer gnus-summary-buffer)
2455 default-mime-charset))
2456 (inhibit-read-only t))
2457 (mime-decode-header-in-buffer charset)))
2459 (defun article-decode-group-name ()
2460 "Decode group names in `Newsgroups:'."
2461 (let ((inhibit-point-motion-hooks t)
2462 (inhibit-read-only t)
2463 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2464 (when (and (or gnus-group-name-charset-method-alist
2465 gnus-group-name-charset-group-alist)
2466 (gnus-buffer-live-p gnus-original-article-buffer))
2468 (article-narrow-to-head)
2469 (with-current-buffer gnus-original-article-buffer
2470 (goto-char (point-min)))
2471 (while (re-search-forward
2472 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2473 (replace-match (save-match-data
2474 (gnus-decode-newsgroups
2475 ;; XXX how to use data in article buffer?
2476 (with-current-buffer gnus-original-article-buffer
2478 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2481 gnus-newsgroup-name method))
2483 (goto-char (point-min))
2484 (with-current-buffer gnus-original-article-buffer
2485 (goto-char (point-min)))
2486 (while (re-search-forward
2487 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2488 (replace-match (save-match-data
2489 (gnus-decode-newsgroups
2490 ;; XXX how to use data in article buffer?
2491 (with-current-buffer gnus-original-article-buffer
2493 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2496 gnus-newsgroup-name method))
2499 (autoload 'idna-to-unicode "idna")
2501 (defun article-decode-idna-rhs ()
2502 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2505 (let ((inhibit-point-motion-hooks t)
2506 (inhibit-read-only t))
2507 (article-narrow-to-head)
2508 (goto-char (point-min))
2509 (while (re-search-forward "@.*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2511 (when (save-match-data
2512 (and (setq ace (match-string 1))
2514 (and (re-search-backward "^[^ \t]" nil t)
2515 (looking-at "From\\|To\\|Cc")))
2516 (setq unicode (idna-to-unicode ace))))
2517 (unless (string= ace unicode)
2518 (replace-match unicode nil nil nil 1)))))))))
2520 (defun article-de-quoted-unreadable (&optional force read-charset)
2521 "Translate a quoted-printable-encoded article.
2522 If FORCE, decode the article whether it is marked as quoted-printable
2524 If READ-CHARSET, ask for a coding system."
2525 (interactive (list 'force current-prefix-arg))
2527 (let ((inhibit-read-only t) type charset)
2528 (if (gnus-buffer-live-p gnus-original-article-buffer)
2529 (with-current-buffer gnus-original-article-buffer
2531 (gnus-fetch-field "content-transfer-encoding"))
2532 (let* ((ct (gnus-fetch-field "content-type"))
2535 (mail-header-parse-content-type ct)))))
2536 (setq charset (and ctl
2537 (mail-content-type-get ctl 'charset)))
2538 (if (stringp charset)
2539 (setq charset (intern (downcase charset)))))))
2541 (setq charset (mm-read-coding-system "Charset: " charset)))
2543 (setq charset gnus-newsgroup-charset))
2545 (and type (let ((case-fold-search t))
2546 (string-match "quoted-printable" type))))
2548 (quoted-printable-decode-region
2549 (point) (point-max) (mm-charset-to-coding-system charset))))))
2551 (defun article-de-base64-unreadable (&optional force read-charset)
2552 "Translate a base64 article.
2553 If FORCE, decode the article whether it is marked as base64 not.
2554 If READ-CHARSET, ask for a coding system."
2555 (interactive (list 'force current-prefix-arg))
2557 (let ((inhibit-read-only t) type charset)
2558 (if (gnus-buffer-live-p gnus-original-article-buffer)
2559 (with-current-buffer gnus-original-article-buffer
2561 (gnus-fetch-field "content-transfer-encoding"))
2562 (let* ((ct (gnus-fetch-field "content-type"))
2565 (mail-header-parse-content-type ct)))))
2566 (setq charset (and ctl
2567 (mail-content-type-get ctl 'charset)))
2568 (if (stringp charset)
2569 (setq charset (intern (downcase charset)))))))
2571 (setq charset (mm-read-coding-system "Charset: " charset)))
2573 (setq charset gnus-newsgroup-charset))
2575 (and type (let ((case-fold-search t))
2576 (string-match "base64" type))))
2579 (narrow-to-region (point) (point-max))
2580 (base64-decode-region (point-min) (point-max))
2581 (mm-decode-coding-region
2582 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2587 (defun article-decode-HZ ()
2588 "Translate a HZ-encoded article."
2592 (let ((inhibit-read-only t))
2593 (rfc1843-decode-region (point-min) (point-max)))))
2595 (defun article-unsplit-urls ()
2596 "Remove the newlines that some other mailers insert into URLs."
2599 (let ((inhibit-read-only t))
2600 (goto-char (point-min))
2601 (while (re-search-forward
2602 "\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2603 (replace-match "\\1\\3" t)))
2604 (when (interactive-p)
2605 (gnus-treat-article nil))))
2608 (defun article-wash-html (&optional read-charset)
2609 "Format an HTML article.
2610 If READ-CHARSET, ask for a coding system."
2613 (let ((inhibit-read-only t)
2615 (when (gnus-buffer-live-p gnus-original-article-buffer)
2616 (with-current-buffer gnus-original-article-buffer
2617 (let* ((ct (gnus-fetch-field "content-type"))
2620 (mail-header-parse-content-type ct)))))
2621 (setq charset (and ctl
2622 (mail-content-type-get ctl 'charset)))
2623 (when (stringp charset)
2624 (setq charset (intern (downcase charset)))))))
2626 (setq charset (mm-read-coding-system "Charset: " charset)))
2628 (setq charset gnus-newsgroup-charset))
2630 (save-window-excursion
2632 (narrow-to-region (point) (point-max))
2633 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2634 (entry (assq func mm-text-html-washer-alist)))
2636 (setq func (cdr entry)))
2641 (apply (car func) (cdr func))))))))))
2643 (defun gnus-article-wash-html-with-w3 ()
2644 "Wash the current buffer with w3."
2646 (let ((w3-strict-width (window-width))
2647 (url-standalone-mode t)
2648 (url-gateway-unplugged t)
2649 (w3-honor-stylesheets nil))
2651 (w3-region (point-min) (point-max))
2654 (defun gnus-article-wash-html-with-w3m ()
2655 "Wash the current buffer with emacs-w3m."
2658 (narrow-to-region (point) (point-max))
2659 (let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp)
2660 w3m-force-redisplay)
2661 (w3m-region (point-min) (point-max)))
2662 (when (and mm-inline-text-html-with-w3m-keymap
2663 (boundp 'w3m-minor-mode-map)
2665 (add-text-properties
2666 (point-min) (point-max)
2667 (list 'keymap w3m-minor-mode-map
2668 ;; Put the mark meaning this part was rendered by emacs-w3m.
2669 'mm-inline-text-html-with-w3m t)))))
2671 (defun article-hide-list-identifiers ()
2672 "Remove list identifies from the Subject header.
2673 The `gnus-list-identifiers' variable specifies what to do."
2675 (let ((inhibit-point-motion-hooks t)
2676 (regexp (if (consp gnus-list-identifiers)
2677 (mapconcat 'identity gnus-list-identifiers " *\\|")
2678 gnus-list-identifiers))
2679 (inhibit-read-only t))
2683 (article-narrow-to-head)
2684 (goto-char (point-min))
2685 (while (re-search-forward
2686 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2688 (delete-region (match-beginning 2) (match-end 0))
2689 (beginning-of-line))
2690 (when (re-search-forward
2691 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2692 (delete-region (match-beginning 1) (match-end 1))))))))
2694 (defun article-hide-pem (&optional arg)
2695 "Toggle hiding of any PEM headers and signatures in the current article.
2696 If given a negative prefix, always show; if given a positive prefix,
2698 (interactive (gnus-article-hidden-arg))
2699 (unless (gnus-article-check-hidden-text 'pem arg)
2701 (let ((inhibit-read-only t) end)
2702 (goto-char (point-min))
2703 ;; Hide the horrendously ugly "header".
2704 (when (and (search-forward
2705 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2707 (setq end (1+ (match-beginning 0))))
2708 (gnus-add-wash-type 'pem)
2709 (gnus-article-hide-text-type
2711 (if (search-forward "\n\n" nil t)
2715 ;; Hide the trailer as well
2716 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2718 (gnus-article-hide-text-type
2719 (match-beginning 0) (match-end 0) 'pem)))))))
2721 (defun article-strip-banner ()
2722 "Strip the banners specified by the `banner' group parameter and by
2723 `gnus-article-address-banner-alist'."
2727 (let ((inhibit-point-motion-hooks t))
2728 (when (gnus-parameter-banner gnus-newsgroup-name)
2729 (article-really-strip-banner
2730 (gnus-parameter-banner gnus-newsgroup-name)))
2731 (when gnus-article-address-banner-alist
2732 ;; It is necessary to encode from fields before checking,
2733 ;; because `mail-header-parse-addresses' does not work
2734 ;; (reliably) on decoded headers. And more, it is
2735 ;; impossible to use `gnus-fetch-original-field' here,
2736 ;; because `article-strip-banner' may be called in draft
2737 ;; buffers to preview them.
2738 (let ((from (save-restriction
2740 (article-narrow-to-head)
2741 (mail-fetch-field "from"))))
2744 (caar (mail-header-parse-addresses
2745 (mail-encode-encoded-word-string from)))))
2747 (dolist (pair gnus-article-address-banner-alist)
2748 (when (string-match (car pair) from)
2750 (article-really-strip-banner (cdr pair)))))))))))))
2752 (defun article-really-strip-banner (banner)
2753 "Strip the banner specified by the argument."
2756 (let ((inhibit-point-motion-hooks t)
2757 (gnus-signature-limit nil)
2758 (inhibit-read-only t))
2761 ((eq banner 'signature)
2762 (when (gnus-article-narrow-to-signature)
2765 (delete-region (point) (point-max))))
2767 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2768 (while (re-search-forward banner nil t)
2769 (delete-region (match-beginning 0) (match-end 0)))))
2771 (while (re-search-forward banner nil t)
2772 (delete-region (match-beginning 0) (match-end 0)))))))))
2774 (defun article-babel ()
2775 "Translate article using an online translation service."
2778 (gnus-with-article-buffer
2779 (when (article-goto-body)
2780 (let* ((start (point))
2782 (orig (buffer-substring start end))
2783 (trans (babel-as-string orig)))
2785 (narrow-to-region start end)
2786 (delete-region start end)
2789 (defun article-hide-signature (&optional arg)
2790 "Hide the signature in the current article.
2791 If given a negative prefix, always show; if given a positive prefix,
2793 (interactive (gnus-article-hidden-arg))
2799 (article-goto-body))
2800 (goto-char (point-min)))
2801 (unless (gnus-article-check-hidden-text 'signature arg)
2802 (let ((inhibit-read-only t)
2804 (while (setq button (text-property-any button (point-max)
2806 'gnus-signature-toggle))
2807 (setq button (text-property-not-all button (point-max)
2809 'gnus-signature-toggle))
2810 (when (and button (not (eobp)))
2811 (gnus-article-hide-text-type
2813 (next-single-property-change (1+ button) 'mime-view-entity
2816 (gnus-set-mode-line 'article))
2818 (defun article-strip-headers-in-body ()
2819 "Strip offensive headers from bodies."
2823 (let ((case-fold-search t))
2824 (when (looking-at "x-no-archive:")
2825 (gnus-delete-line)))))
2827 (defun article-strip-leading-blank-lines ()
2828 "Remove all blank lines from the beginning of the article."
2831 (let ((inhibit-point-motion-hooks t)
2832 (inhibit-read-only t))
2833 (when (article-goto-body)
2834 (while (and (not (eobp))
2835 (looking-at "[ \t]*$"))
2836 (gnus-delete-line))))))
2838 (defun article-narrow-to-head ()
2839 "Narrow the buffer to the head of the message.
2840 Point is left at the beginning of the narrowed-to region."
2842 (goto-char (point-min))
2843 (if (search-forward "\n\n" nil 1)
2846 (goto-char (point-min)))
2848 (defun article-goto-body ()
2849 "Place point at the start of the body."
2850 (goto-char (point-min))
2852 ;; This variable is only bound when dealing with separate
2854 (article-goto-body-goes-to-point-min-p
2856 ((search-forward "\n\n" nil t)
2859 (goto-char (point-max))
2862 (defun article-strip-multiple-blank-lines ()
2863 "Replace consecutive blank lines with one empty line."
2866 (let ((inhibit-point-motion-hooks t)
2867 (inhibit-read-only t))
2868 ;; First make all blank lines empty.
2870 (while (re-search-forward "^[ \t]+$" nil t)
2871 (unless (gnus-annotation-in-region-p
2872 (match-beginning 0) (match-end 0))
2873 (replace-match "" nil t)))
2874 ;; Then replace multiple empty lines with a single empty line.
2876 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2877 (unless (gnus-annotation-in-region-p
2878 (match-beginning 0) (match-end 0))
2879 (delete-region (match-beginning 1) (match-end 1)))))))
2881 (defun article-strip-leading-space ()
2882 "Remove all white space from the beginning of the lines in the article."
2885 (let ((inhibit-point-motion-hooks t)
2886 (inhibit-read-only t))
2888 (while (re-search-forward "^[ \t]+" nil t)
2889 (replace-match "" t t)))))
2891 (defun article-strip-trailing-space ()
2892 "Remove all white space from the end of the lines in the article."
2895 (let ((inhibit-point-motion-hooks t)
2896 (inhibit-read-only t))
2898 (while (re-search-forward "[ \t]+$" nil t)
2899 (replace-match "" t t)))))
2901 (defun article-strip-blank-lines ()
2902 "Strip leading, trailing and multiple blank lines."
2904 (article-strip-leading-blank-lines)
2905 (article-remove-trailing-blank-lines)
2906 (article-strip-multiple-blank-lines))
2908 (defun article-strip-all-blank-lines ()
2909 "Strip all blank lines."
2912 (let ((inhibit-point-motion-hooks t)
2913 (inhibit-read-only t))
2915 (while (re-search-forward "^[ \t]*\n" nil t)
2916 (replace-match "" t t)))))
2918 (defun gnus-article-narrow-to-signature ()
2919 "Narrow to the signature; return t if a signature is found, else nil."
2920 (let ((inhibit-point-motion-hooks t))
2921 (when (gnus-article-search-signature)
2923 ;; Check whether we have some limits to what we consider
2924 ;; to be a signature.
2925 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2926 (list gnus-signature-limit)))
2928 (while (setq limit (pop limits))
2929 (if (or (and (integerp limit)
2930 (< (- (point-max) (point)) limit))
2932 (< (count-lines (point) (point-max)) limit))
2933 (and (functionp limit)
2935 (and (stringp limit)
2936 (not (re-search-forward limit nil t))))
2937 () ; This limit did not succeed.
2941 (narrow-to-region (point) (point-max))
2944 (defun gnus-article-search-signature ()
2945 "Search the current buffer for the signature separator.
2946 Put point at the beginning of the signature separator."
2947 (let ((cur (point)))
2948 (goto-char (point-max))
2949 (if (if (stringp gnus-signature-separator)
2950 (re-search-backward gnus-signature-separator nil t)
2951 (let ((seps gnus-signature-separator))
2953 (not (re-search-backward (car seps) nil t)))
2960 (defun gnus-article-hidden-arg ()
2961 "Return the current prefix arg as a number, or 0 if no prefix."
2962 (list (if current-prefix-arg
2963 (prefix-numeric-value current-prefix-arg)
2966 (defun gnus-article-check-hidden-text (type arg)
2967 "Return nil if hiding is necessary.
2968 Arg can be nil or a number. nil and positive means hide, negative
2969 means show, 0 means toggle."
2972 (let ((hide (gnus-article-hidden-text-p type)))
2978 (gnus-article-show-hidden-text type)
2981 (if (eq hide 'hidden)
2983 (gnus-article-show-hidden-text type)
2987 (defun gnus-article-hidden-text-p (type)
2988 "Say whether the current buffer contains hidden text of type TYPE."
2989 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2991 (not (get-text-property pos 'invisible))
2992 (not (get-text-property pos 'dummy-invisible)))
2994 (text-property-any (1+ pos) (point-max) 'article-type type)))
2999 (defun gnus-article-show-hidden-text (type &optional dummy)
3000 "Show all hidden text of type TYPE.
3001 Originally it is hide instead of DUMMY."
3002 (let ((inhibit-read-only t)
3003 (inhibit-point-motion-hooks t))
3004 (gnus-remove-text-properties-when
3006 (point-min) (point-max)
3007 (cons 'article-type (cons type
3008 gnus-hidden-properties)))
3009 (gnus-delete-wash-type type)))
3011 (defconst article-time-units
3012 `((year . ,(* 365.25 24 60 60))
3013 (week . ,(* 7 24 60 60))
3014 (day . ,(* 24 60 60))
3018 "Mapping from time units to seconds.")
3020 (defun gnus-article-forward-header ()
3021 "Move point to the start of the next header.
3022 If the current header is a continuation header, this can be several
3027 (if (looking-at "[ \t]+[^ \t]")
3031 (defun article-date-ut (&optional type highlight)
3032 "Convert DATE date to universal time in the current article.
3033 If TYPE is `local', convert to local time; if it is `lapsed', output
3034 how much time has lapsed since DATE. For `lapsed', the value of
3035 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
3036 should replace the \"Date:\" one, or should be added below it."
3037 (interactive (list 'ut t))
3038 (let* ((tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
3039 (date-regexp (cond ((not gnus-article-date-lapsed-new-header)
3043 (article-lapsed-timer
3047 (case-fold-search t)
3048 (inhibit-read-only t)
3049 (inhibit-point-motion-hooks t)
3050 pos date bface eface)
3054 (goto-char (point-min))
3055 (while (or (setq date (get-text-property (setq pos (point))
3057 (when (setq pos (next-single-property-change
3058 (point) 'original-date))
3059 (setq date (get-text-property pos 'original-date))
3061 (narrow-to-region pos (or (text-property-any pos (point-max)
3064 (goto-char (point-min))
3065 (when (re-search-forward tdate-regexp nil t)
3066 (setq bface (get-text-property (point-at-bol) 'face)
3067 eface (get-text-property (1- (point-at-eol)) 'face)))
3068 (goto-char (point-min))
3070 ;; Delete any old Date headers.
3071 (while (re-search-forward date-regexp nil t)
3073 (delete-region (point-at-bol) (progn
3074 (gnus-article-forward-header)
3076 (delete-region (point-at-bol) (progn
3077 (gnus-article-forward-header)
3080 (setq pos (point))))
3081 (when (and (not pos)
3082 (re-search-forward tdate-regexp nil t))
3084 (gnus-goto-char pos)
3085 (insert (article-make-date-line date (or type 'ut)))
3091 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
3092 (put-text-property (match-beginning 1) (1+ (match-end 1))
3094 (put-text-property (match-beginning 2) (match-end 2)
3096 (put-text-property (point-min) (1- (point-max)) 'original-date date)
3097 (goto-char (point-max))
3100 (defun article-make-date-line (date type)
3101 "Return a DATE line of TYPE."
3102 (unless (memq type '(local ut original user iso8601 lapsed english))
3103 (error "Unknown conversion type: %s" type))
3105 (let ((time (date-to-time date)))
3107 ;; Convert to the local timezone.
3109 (concat "Date: " (message-make-date time)))
3110 ;; Convert to Universal Time.
3115 (let* ((e (parse-time-string date))
3116 (tm (apply 'encode-time e))
3118 (ls (- (cadr tm) (car (current-time-zone time)))))
3119 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
3120 ((> ls 65535) (list (1+ ms) (- ls 65536)))
3124 ;; Get the original date from the article.
3125 ((eq type 'original)
3126 (concat "Date: " (if (string-match "\n+$" date)
3127 (substring date 0 (match-beginning 0))
3129 ;; Let the user define the format.
3131 (let ((format (or (condition-case nil
3132 (with-current-buffer gnus-summary-buffer
3133 gnus-article-time-format)
3135 gnus-article-time-format)))
3136 (if (functionp format)
3137 (funcall format time)
3138 (concat "Date: " (format-time-string format time)))))
3141 (let ((tz (car (current-time-zone time))))
3144 (format-time-string "%Y%m%dT%H%M%S" time)
3145 (format "%s%02d%02d"
3146 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
3147 (/ (% (abs tz) 3600) 60)))))
3148 ;; Do an X-Sent lapsed format.
3150 ;; If the date is seriously mangled, the timezone functions are
3151 ;; liable to bug out, so we ignore all errors.
3152 (let* ((now (current-time))
3153 (real-time (subtract-time now time))
3154 (real-sec (and real-time
3155 (+ (* (float (car real-time)) 65536)
3157 (sec (and real-time (abs real-sec)))
3167 ;; This is a bit convoluted, but basically we go
3168 ;; through the time units for years, weeks, etc,
3169 ;; and divide things to see whether that results
3170 ;; in positive answers.
3173 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
3174 ;; The (remaining) seconds are too few to
3175 ;; be divided into this time unit.
3177 ;; It's big enough, so we output it.
3178 (setq sec (- sec (* num (cdr unit))))
3180 (concat (if prev ", " "") (int-to-string
3182 " " (symbol-name (car unit))
3183 (if (> num 1) "s" ""))
3185 article-time-units "")
3186 ;; If dates are odd, then it might appear like the
3187 ;; article was sent in the future.
3190 " in the future"))))))
3191 ;; Display the date in proper English
3193 (let ((dtime (decode-time time)))
3196 (number-to-string (nth 3 dtime))
3197 (let ((digit (% (nth 3 dtime) 10)))
3199 ((memq (nth 3 dtime) '(11 12 13)) "th")
3205 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3207 (number-to-string (nth 5 dtime))
3209 (format "%02d" (nth 2 dtime))
3211 (format "%02d" (nth 1 dtime)))))))
3213 (format "Date: %s (from T-gnus)" date))))
3215 (defun article-date-local (&optional highlight)
3216 "Convert the current article date to the local timezone."
3217 (interactive (list t))
3218 (article-date-ut 'local highlight))
3220 (defun article-date-english (&optional highlight)
3221 "Convert the current article date to something that is proper English."
3222 (interactive (list t))
3223 (article-date-ut 'english highlight))
3225 (defun article-date-original (&optional highlight)
3226 "Convert the current article date to what it was originally.
3227 This is only useful if you have used some other date conversion
3228 function and want to see what the date was before converting."
3229 (interactive (list t))
3230 (article-date-ut 'original highlight))
3232 (defun article-date-lapsed (&optional highlight)
3233 "Convert the current article date to time lapsed since it was sent."
3234 (interactive (list t))
3235 (article-date-ut 'lapsed highlight))
3237 (defun article-update-date-lapsed ()
3238 "Function to be run from a timer to update the lapsed time line."
3240 (let (deactivate-mark)
3245 (set-buffer (window-buffer w))
3246 (when (or (and (eq major-mode 'mime-view-mode)
3247 (eq (mime-preview-original-major-mode)
3248 'gnus-original-article-mode))
3249 (eq major-mode 'gnus-article-mode))
3250 (let ((mark (point-marker)))
3251 (goto-char (point-min))
3252 (when (re-search-forward "^X-Sent:" nil t)
3253 (article-date-lapsed t))
3254 (goto-char (marker-position mark))
3255 (move-marker mark nil))))
3258 (defun gnus-start-date-timer (&optional n)
3259 "Start a timer to update the X-Sent header in the article buffers.
3260 The numerical prefix says how frequently (in seconds) the function
3265 (gnus-stop-date-timer)
3266 (setq article-lapsed-timer
3267 (run-at-time 1 n 'article-update-date-lapsed)))
3269 (defun gnus-stop-date-timer ()
3270 "Stop the X-Sent timer."
3272 (when article-lapsed-timer
3273 (nnheader-cancel-timer article-lapsed-timer)
3274 (setq article-lapsed-timer nil)))
3276 (defun article-date-user (&optional highlight)
3277 "Convert the current article date to the user-defined format.
3278 This format is defined by the `gnus-article-time-format' variable."
3279 (interactive (list t))
3280 (article-date-ut 'user highlight))
3282 (defun article-date-iso8601 (&optional highlight)
3283 "Convert the current article date to ISO8601."
3284 (interactive (list t))
3285 (article-date-ut 'iso8601 highlight))
3287 (defmacro gnus-article-save-original-date (&rest forms)
3288 "Save the original date as a text property and evaluate FORMS."
3289 `(let* ((case-fold-search t)
3291 (goto-char (point-min))
3292 (when (and (re-search-forward "^date:[\t\n ]+" nil t)
3295 (date (when (and start
3296 (re-search-forward "[\t ]*\n\\(?:[^\t ]\\|\\'\\)"
3298 (buffer-substring-no-properties start
3299 (match-beginning 0)))))
3300 (goto-char (point-max))
3301 (skip-chars-backward "\n")
3302 (put-text-property (point-min) (point) 'original-date date)
3304 (goto-char (point-max))
3305 (skip-chars-backward "\n")
3306 (put-text-property (point-min) (point) 'original-date date)))
3308 ;; (defun article-show-all ()
3309 ;; "Show all hidden text in the article buffer."
3313 ;; (let ((inhibit-read-only t))
3314 ;; (gnus-article-unhide-text (point-min) (point-max))
3315 ;; (gnus-remove-text-with-property 'gnus-prev)
3316 ;; (gnus-remove-text-with-property 'gnus-next))))
3318 (defun article-show-all-headers ()
3319 "Show all hidden headers in the article buffer."
3324 (article-narrow-to-head)
3325 (let ((inhibit-read-only t))
3326 (gnus-article-unhide-text (point-min) (point-max))))))
3328 (defun article-remove-leading-whitespace ()
3329 "Remove excessive whitespace from all headers."
3333 (let ((inhibit-read-only t))
3334 (article-narrow-to-head)
3335 (goto-char (point-min))
3336 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3337 (delete-region (match-beginning 1) (match-end 1)))))))
3339 (defun article-emphasize (&optional arg)
3340 "Emphasize text according to `gnus-emphasis-alist'."
3341 (interactive (gnus-article-hidden-arg))
3342 (unless (gnus-article-check-hidden-text 'emphasis arg)
3346 (with-current-buffer gnus-summary-buffer
3347 gnus-article-emphasis-alist)
3349 gnus-emphasis-alist))
3350 (inhibit-read-only t)
3351 (props (append '(article-type emphasis)
3352 gnus-hidden-properties))
3353 regexp elem beg invisible visible face)
3356 (while (setq elem (pop alist))
3358 (setq regexp (car elem)
3359 invisible (nth 1 elem)
3360 visible (nth 2 elem)
3362 (while (re-search-forward regexp nil t)
3363 (when (and (match-beginning visible) (match-beginning invisible))
3364 (gnus-article-hide-text
3365 (match-beginning invisible) (match-end invisible) props)
3366 (gnus-article-unhide-text-type
3367 (match-beginning visible) (match-end visible) 'emphasis)
3368 (gnus-put-overlay-excluding-newlines
3369 (match-beginning visible) (match-end visible) 'face face)
3370 (gnus-add-wash-type 'emphasis)
3371 (goto-char (match-end invisible)))))))))
3373 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3374 "Setup newsgroup emphasis alist."
3375 (unless gnus-article-emphasis-alist
3376 (let ((name (and gnus-newsgroup-name
3377 (gnus-group-real-name gnus-newsgroup-name))))
3378 (make-local-variable 'gnus-article-emphasis-alist)
3379 (setq gnus-article-emphasis-alist
3381 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3382 (while (setq elem (pop alist))
3383 (when (and name (string-match (car elem) name))
3385 highlight (copy-sequence (cdr elem)))))
3387 (copy-sequence highlight-words)
3388 (if gnus-newsgroup-name
3389 (copy-sequence (gnus-group-find-parameter
3390 gnus-newsgroup-name 'highlight-words t)))
3391 gnus-emphasis-alist)))))
3394 (defvar gnus-summary-article-menu)
3395 (defvar gnus-summary-post-menu))
3397 ;;; Saving functions.
3399 (defun gnus-article-save (save-buffer file &optional num)
3400 "Save the currently selected article."
3401 (unless gnus-save-all-headers
3402 ;; Remove headers according to `gnus-saved-headers'.
3403 (let ((gnus-visible-headers
3404 (or gnus-saved-headers gnus-visible-headers))
3405 (gnus-article-buffer save-buffer))
3407 (set-buffer save-buffer)
3408 (article-hide-headers 1 t))))
3409 (save-window-excursion
3410 (if (not gnus-default-article-saver)
3411 (error "No default saver is defined")
3412 ;; !!! Magic! The saving functions all save
3413 ;; `gnus-save-article-buffer' (or so they think), but we
3414 ;; bind that variable to our save-buffer.
3415 (set-buffer gnus-article-buffer)
3416 (let* ((gnus-save-article-buffer save-buffer)
3419 ((not gnus-prompt-before-saving) 'default)
3420 ((eq gnus-prompt-before-saving 'always) nil)
3422 (gnus-number-of-articles-to-be-saved
3423 (when (eq gnus-prompt-before-saving t)
3425 (set-buffer gnus-article-current-summary)
3426 (funcall gnus-default-article-saver filename)))))
3428 (defun gnus-read-save-file-name (prompt &optional filename
3429 function group headers variable)
3431 (funcall function group headers (symbol-value variable)))
3436 ((eq filename 'default)
3442 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3445 (if (and gnus-number-of-articles-to-be-saved
3446 (> gnus-number-of-articles-to-be-saved 1))
3447 (format "these %d articles"
3448 gnus-number-of-articles-to-be-saved)
3451 ;; Let the split methods have their say.
3453 ;; No split name was found.
3456 (concat prompt " (default "
3457 (file-name-nondirectory default-name) ") ")
3458 (file-name-directory default-name)
3460 ;; A single group name is returned.
3461 ((stringp split-name)
3463 (funcall function split-name headers
3464 (symbol-value variable)))
3466 (concat prompt " (default "
3467 (file-name-nondirectory default-name) ") ")
3468 (file-name-directory default-name)
3470 ;; A single split name was found
3471 ((= 1 (length split-name))
3472 (let* ((name (expand-file-name
3474 gnus-article-save-directory))
3475 (dir (cond ((file-directory-p name)
3476 (file-name-as-directory name))
3477 ((file-exists-p name) name)
3478 (t gnus-article-save-directory))))
3480 (concat prompt " (default " name ") ")
3482 ;; A list of splits was found.
3484 (setq split-name (nreverse split-name))
3486 (let ((file-name-history
3487 (nconc split-name file-name-history)))
3491 (concat prompt " (`M-p' for defaults) ")
3492 gnus-article-save-directory
3494 gnus-article-save-directory)))
3495 (car (push result file-name-history)))))))
3496 ;; Create the directory.
3497 (gnus-make-directory (file-name-directory file))
3498 ;; If we have read a directory, we append the default file name.
3499 (when (file-directory-p file)
3500 (setq file (expand-file-name (file-name-nondirectory
3502 (file-name-as-directory file))))
3503 ;; Possibly translate some characters.
3504 (nnheader-translate-file-chars file))))))
3505 (gnus-make-directory (file-name-directory result))
3506 (set variable result)))
3508 (defun gnus-article-archive-name (group)
3509 "Return the first instance of an \"Archive-name\" in the current buffer."
3510 (let ((case-fold-search t))
3511 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3512 (nnheader-concat gnus-article-save-directory
3513 (match-string 1)))))
3515 (defun gnus-article-nndoc-name (group)
3516 "If GROUP is an nndoc group, return the name of the parent group."
3517 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3518 (gnus-group-get-parameter group 'save-article-group)))
3520 (defun gnus-summary-save-in-rmail (&optional filename)
3521 "Append this article to Rmail file.
3522 Optional argument FILENAME specifies file name.
3523 Directory to save to is default to `gnus-article-save-directory'."
3524 (setq filename (gnus-read-save-file-name
3525 "Save %s in rmail file:" filename
3526 gnus-rmail-save-name gnus-newsgroup-name
3527 gnus-current-headers 'gnus-newsgroup-last-rmail))
3528 (gnus-eval-in-buffer-window gnus-save-article-buffer
3532 (gnus-output-to-rmail filename))))
3535 (defun gnus-summary-save-in-mail (&optional filename)
3536 "Append this article to Unix mail file.
3537 Optional argument FILENAME specifies file name.
3538 Directory to save to is default to `gnus-article-save-directory'."
3539 (setq filename (gnus-read-save-file-name
3540 "Save %s in Unix mail file:" filename
3541 gnus-mail-save-name gnus-newsgroup-name
3542 gnus-current-headers 'gnus-newsgroup-last-mail))
3543 (gnus-eval-in-buffer-window gnus-save-article-buffer
3547 (if (and (file-readable-p filename)
3548 (file-regular-p filename)
3549 (mail-file-babyl-p filename))
3550 (rmail-output-to-rmail-file filename t)
3551 (gnus-output-to-mail filename)))))
3554 (defun gnus-summary-save-in-file (&optional filename overwrite)
3555 "Append this article to file.
3556 Optional argument FILENAME specifies file name.
3557 Directory to save to is default to `gnus-article-save-directory'."
3558 (setq filename (gnus-read-save-file-name
3559 "Save %s in file:" filename
3560 gnus-file-save-name gnus-newsgroup-name
3561 gnus-current-headers 'gnus-newsgroup-last-file))
3562 (gnus-eval-in-buffer-window gnus-save-article-buffer
3566 (when (and overwrite
3567 (file-exists-p filename))
3568 (delete-file filename))
3569 (gnus-output-to-file filename))))
3572 (defun gnus-summary-write-to-file (&optional filename)
3573 "Write this article to a file, overwriting it if the file exists.
3574 Optional argument FILENAME specifies file name.
3575 The directory to save in defaults to `gnus-article-save-directory'."
3576 (gnus-summary-save-in-file nil t))
3578 (defun gnus-summary-save-body-in-file (&optional filename)
3579 "Append this article body to a file.
3580 Optional argument FILENAME specifies file name.
3581 The directory to save in defaults to `gnus-article-save-directory'."
3582 (setq filename (gnus-read-save-file-name
3583 "Save %s body in file:" filename
3584 gnus-file-save-name gnus-newsgroup-name
3585 gnus-current-headers 'gnus-newsgroup-last-file))
3586 (gnus-eval-in-buffer-window gnus-save-article-buffer
3590 (when (article-goto-body)
3591 (narrow-to-region (point) (point-max)))
3592 (gnus-output-to-file filename))))
3595 (defun gnus-summary-save-in-pipe (&optional command)
3596 "Pipe this article to subprocess."
3598 (cond ((and (eq command 'default)
3599 gnus-last-shell-command)
3600 gnus-last-shell-command)
3605 "Shell command on %s: "
3606 (if (and gnus-number-of-articles-to-be-saved
3607 (> gnus-number-of-articles-to-be-saved 1))
3608 (format "these %d articles"
3609 gnus-number-of-articles-to-be-saved)
3611 gnus-last-shell-command))))
3612 (when (string-equal command "")
3613 (if gnus-last-shell-command
3614 (setq command gnus-last-shell-command)
3615 (error "A command is required")))
3616 (gnus-eval-in-buffer-window gnus-article-buffer
3619 (shell-command-on-region (point-min) (point-max) command nil)))
3620 (setq gnus-last-shell-command command))
3622 (defun gnus-summary-pipe-to-muttprint (&optional command)
3623 "Pipe this article to muttprint."
3624 (setq command (read-string
3625 "Print using command: " gnus-summary-muttprint-program
3626 nil gnus-summary-muttprint-program))
3627 (gnus-summary-save-in-pipe command))
3629 ;;; Article file names when saving.
3631 (defun gnus-capitalize-newsgroup (newsgroup)
3632 "Capitalize NEWSGROUP name."
3633 (when (not (zerop (length newsgroup)))
3634 (concat (char-to-string (upcase (aref newsgroup 0)))
3635 (substring newsgroup 1))))
3637 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3638 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3639 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3640 Otherwise, it is like ~/News/news/group/num."
3643 (concat (if (gnus-use-long-file-name 'not-save)
3644 (gnus-capitalize-newsgroup newsgroup)
3645 (gnus-newsgroup-directory-form newsgroup))
3646 "/" (int-to-string (mail-header-number headers)))
3647 gnus-article-save-directory)))
3649 (string-equal (file-name-directory default)
3650 (file-name-directory last-file))
3651 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3653 (or last-file default))))
3655 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3656 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3657 If variable `gnus-use-long-file-name' is non-nil, it is
3658 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3661 (concat (if (gnus-use-long-file-name 'not-save)
3663 (gnus-newsgroup-directory-form newsgroup))
3664 "/" (int-to-string (mail-header-number headers)))
3665 gnus-article-save-directory)))
3667 (string-equal (file-name-directory default)
3668 (file-name-directory last-file))
3669 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3671 (or last-file default))))
3673 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3674 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3675 If variable `gnus-use-long-file-name' is non-nil, it is
3676 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3679 (if (gnus-use-long-file-name 'not-save)
3682 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3684 gnus-article-save-directory)))
3686 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3687 "Generate file name from sender."
3688 (let ((from (mail-header-from headers)))
3690 (if (and from (string-match "\\([^ <]+\\)@" from))
3691 (match-string 1 from)
3693 gnus-article-save-directory)))
3695 (defun article-verify-x-pgp-sig ()
3698 (if (gnus-buffer-live-p gnus-original-article-buffer)
3699 (let ((sig (with-current-buffer gnus-original-article-buffer
3700 (gnus-fetch-field "X-PGP-Sig")))
3704 (mml2015-clear-verify-function))
3706 (insert-buffer-substring gnus-original-article-buffer)
3707 (setq items (split-string sig))
3708 (message-narrow-to-head)
3709 (let ((inhibit-point-motion-hooks t)
3710 (case-fold-search t))
3711 ;; Don't verify multiple headers.
3712 (setq headers (mapconcat (lambda (header)
3714 (mail-fetch-field header)
3716 (split-string (nth 1 items) ",") "")))
3717 (delete-region (point-min) (point-max))
3718 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3719 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3724 (if (looking-at "^-")
3727 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3728 (insert "Version: " (car items) "\n\n")
3729 (insert (mapconcat 'identity (cddr items) "\n"))
3730 (insert "\n-----END PGP SIGNATURE-----\n")
3731 (let ((mm-security-handle (list (format "multipart/signed"))))
3732 (mml2015-clean-buffer)
3733 (let ((coding-system-for-write (or gnus-newsgroup-charset
3735 (funcall (mml2015-clear-verify-function)))
3737 (or (mm-handle-multipart-ctl-parameter
3738 mm-security-handle 'gnus-details)
3739 (mm-handle-multipart-ctl-parameter
3740 mm-security-handle 'gnus-info)))))
3742 (let ((inhibit-read-only t) bface eface)
3744 (message-narrow-to-head)
3745 (goto-char (point-max))
3747 (setq bface (get-text-property (point-at-bol) 'face)
3748 eface (get-text-property (1- (point-at-eol)) 'face))
3749 (message-remove-header "X-Gnus-PGP-Verify")
3750 (if (re-search-forward "^X-PGP-Sig:" nil t)
3752 (goto-char (point-max)))
3753 (narrow-to-region (point) (point))
3754 (insert "X-Gnus-PGP-Verify: " info "\n")
3755 (goto-char (point-min))
3758 (if (not (looking-at "^[ \t]"))
3762 (goto-char (point-min))
3763 (when (looking-at "\\([^:]+\\): *")
3764 (put-text-property (match-beginning 1) (1+ (match-end 1))
3766 (put-text-property (match-end 0) (point-max)
3767 'face eface)))))))))
3769 (defun article-verify-cancel-lock ()
3770 "Verify Cancel-Lock header."
3772 (if (gnus-buffer-live-p gnus-original-article-buffer)
3773 (canlock-verify gnus-original-article-buffer)))
3775 (defun article-monafy ()
3776 "Display body part with mona font."
3778 (unless (if (featurep 'xemacs)
3779 (find-face 'gnus-mona-face)
3780 (facep 'gnus-mona-face))
3781 (require 'navi2ch-mona)
3782 (set-face-font (make-face 'gnus-mona-face) navi2ch-mona-font))
3784 (let ((inhibit-read-only t))
3787 (gnus-make-overlay (point) (point-max))
3788 'face 'gnus-mona-face))))
3795 (setq afunc (car func)
3798 gfunc (intern (format "gnus-%s" func))))
3800 (when (fboundp afunc)
3801 `(lambda (&optional interactive &rest args)
3802 ,(documentation afunc t)
3803 (interactive (list t))
3805 (set-buffer gnus-article-buffer)
3807 (call-interactively ',afunc)
3808 (apply ',afunc args))))))))
3809 '(article-hide-headers
3810 article-verify-x-pgp-sig
3811 article-verify-cancel-lock
3813 article-hide-boring-headers
3814 article-treat-overstrike
3815 article-treat-ansi-sequences
3816 article-fill-long-lines
3817 article-capitalize-sentences
3819 article-remove-leading-whitespace
3820 article-display-x-face
3821 article-display-face
3822 article-de-quoted-unreadable
3823 article-de-base64-unreadable
3826 article-unsplit-urls
3827 article-hide-list-identifiers
3828 article-strip-banner
3831 article-hide-signature
3832 article-strip-headers-in-body
3833 article-remove-trailing-blank-lines
3834 article-strip-leading-blank-lines
3835 article-strip-multiple-blank-lines
3836 article-strip-leading-space
3837 article-strip-trailing-space
3838 article-strip-blank-lines
3839 article-strip-all-blank-lines
3841 article-date-english
3842 article-date-iso8601
3843 article-date-original
3845 article-decode-mime-words
3846 article-decode-charset
3847 article-decode-encoded-words
3851 article-treat-dumbquotes
3852 article-normalize-headers
3853 (article-show-all-headers . gnus-article-show-all-headers)
3854 ;; (article-show-all . gnus-article-show-all)
3858 ;;; Gnus article mode
3861 (put 'gnus-article-mode 'mode-class 'special)
3863 (gnus-define-keys gnus-article-mode-map
3864 " " gnus-article-goto-next-page
3865 "\177" gnus-article-goto-prev-page
3866 [delete] gnus-article-goto-prev-page
3867 [backspace] gnus-article-goto-prev-page
3868 "\C-c^" gnus-article-refer-article
3869 "h" gnus-article-show-summary
3870 "s" gnus-article-show-summary
3871 "\C-c\C-m" gnus-article-mail
3872 "?" gnus-article-describe-briefly
3873 "e" gnus-summary-edit-article
3874 "<" beginning-of-buffer
3876 "\C-c\C-i" gnus-info-find-node
3878 "R" gnus-article-reply-with-original
3879 "F" gnus-article-followup-with-original
3880 "\C-hk" gnus-article-describe-key
3881 "\C-hc" gnus-article-describe-key-briefly
3883 "\C-d" gnus-article-read-summary-keys
3884 "\M-*" gnus-article-read-summary-keys
3885 "\M-#" gnus-article-read-summary-keys
3886 "\M-^" gnus-article-read-summary-keys
3887 "\M-g" gnus-article-read-summary-keys)
3889 ;; Define almost undefined keys to `gnus-article-read-summary-keys'.
3893 (push (char-to-string key) keys)
3895 (dolist (elem (accessible-keymaps gnus-summary-mode-map))
3896 (setq key (car elem))
3897 (when (and (> (length key) 0)
3898 (not (eq 'menu-bar (aref key 0)))
3899 (symbolp (lookup-key gnus-summary-mode-map key)))
3902 (unless (lookup-key gnus-article-mode-map key)
3903 (define-key gnus-article-mode-map key 'gnus-article-read-summary-keys))))
3905 (defun gnus-article-make-menu-bar ()
3906 (unless (boundp 'gnus-article-commands-menu)
3907 (gnus-summary-make-menu-bar))
3908 (gnus-turn-off-edit-menu 'article)
3909 (unless (boundp 'gnus-article-article-menu)
3911 gnus-article-article-menu gnus-article-mode-map ""
3913 ["Scroll forwards" gnus-article-goto-next-page t]
3914 ["Scroll backwards" gnus-article-goto-prev-page t]
3915 ["Show summary" gnus-article-show-summary t]
3916 ["Fetch Message-ID at point" gnus-article-refer-article t]
3917 ["Mail to address at point" gnus-article-mail t]
3918 ["Send a bug report" gnus-bug t]))
3921 gnus-article-treatment-menu gnus-article-mode-map ""
3922 ;; Fixme: this should use :active (and maybe :visible).
3924 ["Hide headers" gnus-article-hide-headers t]
3925 ["Hide signature" gnus-article-hide-signature t]
3926 ["Hide citation" gnus-article-hide-citation t]
3927 ["Treat overstrike" gnus-article-treat-overstrike t]
3928 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
3929 ["Remove carriage return" gnus-article-remove-cr t]
3930 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3931 ["Treat html" gnus-article-wash-html t]
3932 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3933 ["Decode HZ" gnus-article-decode-HZ t]))
3935 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3937 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3939 (gnus-run-hooks 'gnus-article-menu-hook)))
3941 (defun gnus-article-mode ()
3942 "Major mode for displaying an article.
3944 All normal editing commands are switched off.
3946 The following commands are available in addition to all summary mode
3948 \\<gnus-article-mode-map>
3949 \\[gnus-article-next-page]\t Scroll the article one page forwards
3950 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3951 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3952 \\[gnus-article-show-summary]\t Display the summary buffer
3953 \\[gnus-article-mail]\t Send a reply to the address near point
3954 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3955 \\[gnus-info-find-node]\t Go to the Gnus info node"
3957 (kill-all-local-variables)
3958 (gnus-simplify-mode-line)
3959 (setq mode-name "Article")
3960 (setq major-mode 'gnus-article-mode)
3961 (make-local-variable 'minor-mode-alist)
3962 (unless (assq 'gnus-show-mime minor-mode-alist)
3963 (push (list 'gnus-show-mime " MIME") minor-mode-alist))
3964 (use-local-map gnus-article-mode-map)
3965 (when (gnus-visual-p 'article-menu 'menu)
3966 (gnus-article-make-menu-bar)
3967 (when gnus-summary-tool-bar-map
3968 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3969 (gnus-update-format-specifications nil 'article-mode)
3970 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3971 (set (make-local-variable 'gnus-page-broken) nil)
3972 (make-local-variable 'gnus-button-marker-list)
3973 (make-local-variable 'gnus-article-current-summary)
3974 (make-local-variable 'gnus-article-mime-handles)
3975 (make-local-variable 'gnus-article-decoded-p)
3976 (make-local-variable 'gnus-article-mime-handle-alist)
3977 (make-local-variable 'gnus-article-wash-types)
3978 (make-local-variable 'gnus-article-image-alist)
3979 (make-local-variable 'gnus-article-charset)
3980 (make-local-variable 'gnus-article-ignored-charsets)
3981 ;; Prevent recent Emacsen from displaying non-break space as "\ ".
3982 (set (make-local-variable 'nobreak-char-display) nil)
3983 (gnus-set-default-directory)
3984 (buffer-disable-undo)
3985 (setq buffer-read-only t
3986 show-trailing-whitespace nil)
3987 (set-syntax-table gnus-article-mode-syntax-table)
3988 (gnus-run-mode-hooks 'gnus-article-mode-hook))
3990 (defun gnus-article-setup-buffer ()
3991 "Initialize the article buffer."
3992 (let* ((name (if gnus-single-article-buffer "*Article*"
3993 (concat "*Article " gnus-newsgroup-name "*")))
3995 (progn (string-match "\\*Article" name)
3996 (concat " *Original Article"
3997 (substring name (match-end 0))))))
3998 (setq gnus-article-buffer name)
3999 (setq gnus-original-article-buffer original)
4000 (setq gnus-article-mime-handle-alist nil)
4001 ;; This might be a variable local to the summary buffer.
4002 (unless gnus-single-article-buffer
4004 (set-buffer gnus-summary-buffer)
4005 (setq gnus-article-buffer name)
4006 (setq gnus-original-article-buffer original)
4007 (gnus-set-global-variables)))
4008 (gnus-article-setup-highlight-words)
4009 ;; Init original article buffer.
4011 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
4012 (set-buffer-multibyte t)
4013 (setq major-mode 'gnus-original-article-mode)
4014 (make-local-variable 'gnus-original-article))
4015 (if (and (get-buffer name)
4016 (with-current-buffer name
4017 (if gnus-article-edit-mode
4018 (if (y-or-n-p "Article mode edit in progress; discard? ")
4020 (set-buffer-modified-p nil)
4021 (gnus-kill-buffer name)
4024 (error "Action aborted"))
4028 (set (make-local-variable 'gnus-article-edit-mode) nil)
4029 (buffer-disable-undo)
4030 (setq buffer-read-only t)
4031 ;; This list just keeps growing if we don't reset it.
4032 (setq gnus-button-marker-list nil)
4033 (unless (eq major-mode 'gnus-article-mode)
4034 (gnus-article-mode))
4037 (set-buffer (gnus-get-buffer-create name))
4039 (make-local-variable 'gnus-summary-buffer)
4040 (gnus-summary-set-local-parameters gnus-newsgroup-name)
4041 (current-buffer)))))
4043 ;; Set article window start at LINE, where LINE is the number of lines
4044 ;; from the head of the article.
4045 (defun gnus-article-set-window-start (&optional line)
4047 (gnus-get-buffer-window gnus-article-buffer t)
4049 (set-buffer gnus-article-buffer)
4050 (goto-char (point-min))
4053 (gnus-message 6 "Moved to bookmark")
4054 (search-forward "\n\n" nil t)
4058 ;;; @@ article filters
4061 (defun gnus-article-display-mime-message ()
4062 "Article display method for MIME message."
4063 ;; called from `gnus-original-article-buffer'.
4064 (let (charset all-headers)
4065 (with-current-buffer gnus-summary-buffer
4066 (setq charset default-mime-charset
4067 all-headers gnus-have-all-headers))
4068 (make-local-variable 'default-mime-charset)
4069 (setq default-mime-charset charset)
4070 (with-current-buffer (get-buffer-create gnus-article-buffer)
4071 (make-local-variable 'default-mime-charset)
4072 (setq default-mime-charset charset))
4073 (mime-display-message mime-message-structure
4074 gnus-article-buffer nil gnus-article-mode-map)
4076 (gnus-article-hide-headers nil -1)))
4077 (run-hooks 'gnus-mime-article-prepare-hook))
4079 (defun gnus-article-display-traditional-message ()
4080 "Article display method for traditional message."
4081 (set-buffer gnus-article-buffer)
4082 (let ((inhibit-read-only t))
4084 (insert-buffer-substring gnus-original-article-buffer)))
4086 (defun gnus-article-make-full-mail-header (&optional number charset)
4087 "Create a new mail header structure in a raw article buffer."
4088 (unless (and number charset)
4089 (save-current-buffer
4090 (set-buffer gnus-summary-buffer)
4092 (setq number (or (cdr gnus-article-current) 0)))
4094 (setq charset (or default-mime-charset 'x-ctext)))))
4095 (goto-char (point-min))
4096 (let ((header-end (if (search-forward "\n\n" nil t)
4098 (goto-char (point-max))))
4099 (chars (- (point-max) (point)))
4100 (lines (count-lines (point) (point-max)))
4101 (default-mime-charset charset)
4103 (narrow-to-region (point-min) header-end)
4104 (setq xref (std11-fetch-field "xref"))
4106 (make-full-mail-header
4108 (std11-fetch-field "subject")
4109 (std11-fetch-field "from")
4110 (std11-fetch-field "date")
4111 (std11-fetch-field "message-id")
4112 (std11-fetch-field "references")
4115 (when xref (concat "Xref: " xref)))
4118 (defun gnus-article-prepare (article &optional all-headers header)
4119 "Prepare ARTICLE in article mode buffer.
4120 ARTICLE should either be an article number or a Message-ID.
4121 If ARTICLE is an id, HEADER should be the article headers.
4122 If ALL-HEADERS is non-nil, no headers are hidden."
4124 ;; Make sure we start in a summary buffer.
4125 (unless (eq major-mode 'gnus-summary-mode)
4126 (set-buffer gnus-summary-buffer))
4127 (setq gnus-summary-buffer (current-buffer))
4128 (let* ((gnus-article (if header (mail-header-number header) article))
4129 (summary-buffer (current-buffer))
4130 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
4131 (group gnus-newsgroup-name)
4134 (gnus-article-setup-buffer)
4135 (set-buffer gnus-article-buffer)
4136 ;; Deactivate active regions.
4137 (when (and (boundp 'transient-mark-mode)
4138 transient-mark-mode)
4139 (setq mark-active nil))
4140 (if (not (setq result (let ((inhibit-read-only t))
4141 (gnus-request-article-this-buffer
4143 ;; There is no such article.
4145 (when (and (numberp article)
4146 (not (memq article gnus-newsgroup-sparse)))
4147 (setq gnus-article-current
4148 (cons gnus-newsgroup-name article))
4149 (set-buffer gnus-summary-buffer)
4150 (setq gnus-current-article article)
4151 (if (and (memq article gnus-newsgroup-undownloaded)
4152 (not (gnus-online (gnus-find-method-for-group
4153 gnus-newsgroup-name))))
4155 (gnus-summary-set-agent-mark article)
4156 (message "Message marked for downloading"))
4157 (gnus-summary-mark-article article gnus-canceled-mark)
4158 (unless (memq article gnus-newsgroup-sparse)
4159 (gnus-error 1 "No such article (may have expired or been canceled)")))))
4160 (if (or (eq result 'pseudo)
4161 (eq result 'nneething))
4164 (set-buffer summary-buffer)
4165 (push article gnus-newsgroup-history)
4166 (setq gnus-last-article gnus-current-article
4167 gnus-current-article 0
4168 gnus-current-headers nil
4169 gnus-article-current nil)
4170 (if (eq result 'nneething)
4171 (gnus-configure-windows 'summary)
4172 (gnus-configure-windows 'article))
4173 (gnus-set-global-variables))
4174 (let ((gnus-article-mime-handle-alist-1
4175 gnus-article-mime-handle-alist))
4176 (gnus-set-mode-line 'article)))
4177 ;; The result from the `request' was an actual article -
4178 ;; or at least some text that is now displayed in the
4180 (when (and (numberp article)
4181 (not (eq article gnus-current-article)))
4182 ;; Seems like a new article has been selected.
4183 ;; `gnus-current-article' must be an article number.
4185 (set-buffer summary-buffer)
4186 (push article gnus-newsgroup-history)
4187 (setq gnus-last-article gnus-current-article
4188 gnus-current-article article
4189 gnus-current-headers
4190 (gnus-summary-article-header gnus-current-article)
4191 gnus-article-current
4192 (cons gnus-newsgroup-name gnus-current-article))
4193 (unless (vectorp gnus-current-headers)
4194 (setq gnus-current-headers nil))
4195 (gnus-summary-goto-subject gnus-current-article)
4196 (when (gnus-summary-show-thread)
4197 ;; If the summary buffer really was folded, the
4198 ;; previous goto may not actually have gone to
4199 ;; the right article, but the thread root instead.
4201 (gnus-summary-goto-subject gnus-current-article))
4202 (gnus-run-hooks 'gnus-mark-article-hook)
4203 (gnus-set-mode-line 'summary)
4204 (when (gnus-visual-p 'article-highlight 'highlight)
4205 (gnus-run-hooks 'gnus-visual-mark-article-hook))
4206 ;; Set the global newsgroup variables here.
4207 (gnus-set-global-variables)
4208 (setq gnus-have-all-headers
4209 (or all-headers gnus-show-all-headers))))
4211 (gnus-configure-windows 'article))
4212 (when (or (numberp article)
4214 (gnus-article-prepare-display)
4216 (goto-char (point-min))
4217 (when gnus-break-pages
4218 (gnus-narrow-to-page)))
4219 (let ((gnus-article-mime-handle-alist-1
4220 gnus-article-mime-handle-alist))
4221 (gnus-set-mode-line 'article))
4225 (set-window-point (get-buffer-window (current-buffer)) (point))
4226 (gnus-configure-windows 'article)
4229 (defun gnus-article-prepare-mime-display (&optional number)
4230 (goto-char (point-min))
4231 (when (re-search-forward "^[^\t ]+:" nil t)
4232 (goto-char (match-beginning 0)))
4233 (let ((entity (if (eq 1 (point-min))
4234 (get-text-property 1 'mime-view-entity)
4235 (get-text-property (point) 'mime-view-entity)))
4236 last-entity child-entity next type)
4237 (setq child-entity (mime-entity-children entity))
4239 (setq last-entity (nth (1- (length child-entity))
4241 (setq last-entity entity))
4243 (narrow-to-region (point)
4244 (if (search-forward "\n\n" nil t)
4247 (gnus-article-save-original-date (gnus-treat-article 'head))
4248 (put-text-property (point-min) (point-max) 'article-treated-header t)
4249 (goto-char (point-max)))
4250 (while (and (not (eobp)) entity)
4251 (setq next (set-marker
4253 (next-single-property-change (point) 'mime-view-entity
4255 (let ((types (mime-entity-content-type entity)))
4256 (while (eq 'multipart (mime-content-type-primary-type types))
4257 (setq entity (car (mime-entity-children entity))
4258 types (mime-entity-content-type entity)))
4260 (setq type (format "%s/%s"
4261 (mime-content-type-primary-type types)
4262 (mime-content-type-subtype types)))))
4263 (if (string-equal type "message/rfc822")
4266 (let ((children (mime-entity-children entity))
4269 (setq last-children (nth (1- (length children)) children))
4272 (not (eq last-children
4273 (get-text-property next 'mime-view-entity)))
4275 (next-single-property-change next
4277 nil (point-max)))))))
4278 (setq next (next-single-property-change next 'mime-view-entity
4281 (narrow-to-region (point) next)
4282 (gnus-article-prepare-mime-display)
4283 (goto-char (point-max)))
4284 (setq entity (get-text-property (point) 'mime-view-entity)))
4286 (narrow-to-region (point) next)
4287 ;; Kludge. We have to count true number, but for now,
4288 ;; part number is here only to achieve `last'.
4289 (gnus-treat-article nil 1
4290 (if (eq entity last-entity)
4293 (goto-char (point-max)))
4294 (setq entity (get-text-property next 'mime-view-entity))))))
4297 (defun gnus-article-prepare-display ()
4298 "Make the current buffer look like a nice article."
4299 (let ((gnus-article-buffer (current-buffer))
4301 (inhibit-read-only t))
4302 (unless (eq major-mode 'gnus-article-mode)
4303 (gnus-article-mode))
4304 (setq buffer-read-only nil
4305 gnus-button-marker-list nil
4306 gnus-article-wash-types nil
4307 gnus-article-image-alist nil)
4310 (static-if (featurep 'xemacs)
4311 (map-extents (lambda (extent maparg) (delete-extent extent)))
4312 (let ((lists (overlay-lists)))
4313 (dolist (overlay (nconc (car lists) (cdr lists)))
4314 (delete-overlay overlay)))))
4315 (gnus-run-hooks 'gnus-tmp-internal-hook))
4316 (let ((show-mime (unless (member gnus-newsgroup-name '("nndraft:delayed"
4319 (inhibit-read-only t))
4320 (set-buffer gnus-original-article-buffer)
4322 (setq mime-message-structure gnus-current-headers)
4323 (mime-buffer-entity-set-buffer-internal mime-message-structure
4324 gnus-original-article-buffer)
4325 (mime-entity-set-representation-type-internal mime-message-structure
4326 'mime-buffer-entity)
4327 (luna-send mime-message-structure 'initialize-instance
4328 mime-message-structure)
4330 (let (mime-display-header-hook mime-display-text/plain-hook)
4331 (funcall gnus-article-display-method-for-mime))
4332 (funcall gnus-article-display-method-for-traditional))
4333 ;; Call the treatment functions.
4337 (gnus-article-prepare-mime-display)
4338 (narrow-to-region (goto-char (point-min))
4339 (if (search-forward "\n\n" nil t)
4342 (gnus-article-save-original-date (gnus-treat-article 'head))
4343 (put-text-property (point-min) (point-max) 'article-treated-header t)
4344 (goto-char (point-max))
4346 (narrow-to-region (point) (point-max))
4347 (gnus-treat-article nil))
4348 (put-text-property (point-min) (point-max) 'read-only nil)))
4349 (gnus-run-hooks 'gnus-article-prepare-hook))
4351 (defun gnus-article-decode-article-as-default-mime-charset ()
4352 "Decode an article as `default-mime-charset'. It won't work if the
4353 value of the variable `gnus-show-mime' is non-nil."
4354 (unless (or gnus-show-mime
4355 (member gnus-newsgroup-name '("nndraft:delayed"
4357 (set (make-local-variable 'default-mime-charset)
4358 (with-current-buffer gnus-summary-buffer
4359 default-mime-charset))
4360 (decode-mime-charset-region (point-min) (point-max)
4361 default-mime-charset)))
4364 ;;; Gnus MIME viewing functions
4367 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4368 "Format of the MIME buttons.
4370 Valid specifiers include:
4372 %T MIME type, along with additional info
4373 %n The `name' parameter
4374 %d The description, if any
4375 %l The length of the encoded part
4376 %p The part identifier number
4377 %e Dots if the part isn't displayed
4379 General format specifiers can also be used. See Info node
4380 `(gnus)Formatting Variables'.")
4382 (defvar gnus-mime-button-line-format-alist
4383 '((?t gnus-tmp-type ?s)
4384 (?T gnus-tmp-type-long ?s)
4385 (?n gnus-tmp-name ?s)
4386 (?d gnus-tmp-description ?s)
4388 (?l gnus-tmp-length ?d)
4389 (?e gnus-tmp-dots ?s)))
4391 (defvar gnus-mime-button-commands
4392 '((gnus-article-press-button "\r" "Toggle Display")
4393 (gnus-mime-view-part "v" "View Interactively...")
4394 (gnus-mime-view-part-as-type "t" "View As Type...")
4395 (gnus-mime-view-part-as-charset "C" "View As charset...")
4396 (gnus-mime-save-part "o" "Save...")
4397 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4398 (gnus-mime-delete-part "d" "Delete part")
4399 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4400 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4401 (gnus-mime-view-part-internally "E" "View Internally")
4402 (gnus-mime-view-part-externally "e" "View Externally")
4403 (gnus-mime-print-part "p" "Print")
4404 (gnus-mime-pipe-part "|" "Pipe To Command...")
4405 (gnus-mime-action-on-part "." "Take action on the part...")))
4407 (defun gnus-article-mime-part-status ()
4408 (with-current-buffer gnus-article-buffer
4409 (let ((entity (get-text-property (point-min) 'mime-view-entity))
4412 (setq children (mime-entity-children entity))
4413 (setq children (length children)))
4416 (format " (%d parts)" children))
4419 (defvar gnus-mime-button-map
4420 (let ((map (make-sparse-keymap)))
4421 (define-key map gnus-mouse-2 'gnus-article-push-button)
4422 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4423 (dolist (c gnus-mime-button-commands)
4424 (define-key map (cadr c) (car c)))
4428 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4430 ,@(mapcar (lambda (c)
4431 (vector (caddr c) (car c) :enable t))
4432 gnus-mime-button-commands)))
4434 (defun gnus-mime-button-menu (event prefix)
4435 "Construct a context-sensitive menu of MIME commands."
4436 (interactive "e\nP")
4437 (save-window-excursion
4438 (let ((pos (event-start event)))
4439 (select-window (posn-window pos))
4440 (goto-char (posn-point pos))
4441 (gnus-article-check-buffer)
4442 (popup-menu gnus-mime-button-menu nil prefix))))
4444 (defun gnus-mime-view-all-parts (&optional handles)
4445 "View all the MIME parts."
4447 (with-current-buffer gnus-article-buffer
4448 (let ((handles (or handles gnus-article-mime-handles))
4449 (mail-parse-charset gnus-newsgroup-charset)
4450 (mail-parse-ignored-charsets
4451 (with-current-buffer gnus-summary-buffer
4452 gnus-newsgroup-ignored-charsets)))
4454 (mm-remove-parts handles)
4455 (goto-char (point-min))
4456 (or (search-forward "\n\n") (goto-char (point-max)))
4457 (let ((inhibit-read-only t))
4458 (delete-region (point) (point-max))
4459 (mm-display-parts handles))))))
4461 (defun gnus-article-jump-to-part (n)
4462 "Jump to MIME part N."
4464 (pop-to-buffer gnus-article-buffer)
4465 ;; FIXME: why is it necessary?
4467 (let ((parts (length gnus-article-mime-handle-alist)))
4470 (read-string ;; Emacs 21 doesn't have `read-number'.
4471 (format "Jump to part (2..%s): " parts)))))
4472 (unless (and (integerp n) (<= n parts) (>= n 1))
4475 (gnus-message 7 "Invalid part `%s', using %s instead."
4478 (gnus-message 9 "Jumping to part %s." n)
4479 (cond ((>= gnus-auto-select-part 1)
4480 (while (and (<= n parts)
4481 (not (gnus-article-goto-part n)))
4483 ((< gnus-auto-select-part 0)
4484 (while (and (>= n 1)
4485 (not (gnus-article-goto-part n)))
4488 (gnus-article-goto-part n)))))
4491 (defsubst gnus-article-edit-part (handles &optional current-id)
4492 "Edit an article in order to delete a mime part.
4493 This function is exclusively used by `gnus-mime-save-part-and-strip'
4494 and `gnus-mime-delete-part', and not provided at run-time normally."
4495 (gnus-article-edit-article
4497 (buffer-disable-undo)
4499 (let ((mail-parse-charset (or gnus-article-charset
4500 ',gnus-newsgroup-charset))
4501 (mail-parse-ignored-charsets
4502 (or gnus-article-ignored-charsets
4503 ',gnus-newsgroup-ignored-charsets))
4504 (mbl mml-buffer-list))
4505 (setq mml-buffer-list nil)
4506 (insert-buffer-substring gnus-original-article-buffer)
4507 (mime-to-mml ',handles)
4508 (setq gnus-article-mime-handles nil)
4509 (let ((mbl1 mml-buffer-list))
4510 (setq mml-buffer-list mbl)
4511 (set (make-local-variable 'mml-buffer-list) mbl1))
4512 (gnus-make-local-hook 'kill-buffer-hook)
4513 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4514 `(lambda (no-highlight)
4515 (let ((mail-parse-charset (or gnus-article-charset
4516 ',gnus-newsgroup-charset))
4517 (message-options message-options)
4518 (message-options-set-recipient)
4519 (mail-parse-ignored-charsets
4520 (or gnus-article-ignored-charsets
4521 ',gnus-newsgroup-ignored-charsets)))
4523 (mml-destroy-buffers)
4524 (remove-hook 'kill-buffer-hook
4525 'mml-destroy-buffers t)
4526 (kill-local-variable 'mml-buffer-list))
4527 (gnus-summary-edit-article-done
4528 ,(or (mail-header-references gnus-current-headers) "")
4529 ,(gnus-group-read-only-p)
4530 ,gnus-summary-buffer no-highlight))
4532 (gnus-article-edit-done)
4533 (gnus-summary-expand-window)
4534 (gnus-summary-show-article)
4535 (when (and current-id (integerp gnus-auto-select-part))
4536 (gnus-article-jump-to-part
4537 (+ current-id gnus-auto-select-part)))))
4539 (defun gnus-mime-save-part-and-strip ()
4540 "Save the MIME part under point then replace it with an external body."
4542 (gnus-article-check-buffer)
4543 (when (gnus-group-read-only-p)
4544 (error "The current group does not support deleting of parts"))
4545 (when (mm-complicated-handles gnus-article-mime-handles)
4547 The current article has a complicated MIME structure, giving up..."))
4548 (let* ((data (get-text-property (point) 'gnus-data))
4549 (id (get-text-property (point) 'gnus-part))
4551 (handles gnus-article-mime-handles))
4552 (setq file (and data (mm-save-part data "Delete MIME part and save to: ")))
4554 (with-current-buffer (mm-handle-buffer data)
4556 (insert "Content-Type: " (mm-handle-media-type data))
4557 (mml-insert-parameter-string (cdr (mm-handle-type data))
4560 (insert "Content-ID: " (message-make-message-id) "\n")
4561 (insert "Content-Transfer-Encoding: binary\n")
4564 (cdr (mm-make-handle nil
4565 `("message/external-body"
4566 (access-type . "LOCAL-FILE")
4568 ;; (set-buffer gnus-summary-buffer)
4569 (gnus-article-edit-part handles id))))
4571 (defun gnus-mime-delete-part ()
4572 "Delete the MIME part under point.
4573 Replace it with some information about the removed part."
4575 (gnus-article-check-buffer)
4576 (when (gnus-group-read-only-p)
4577 (error "The current group does not support deleting of parts"))
4578 (when (mm-complicated-handles gnus-article-mime-handles)
4580 The current article has a complicated MIME structure, giving up..."))
4581 (when (or gnus-expert-user
4582 (gnus-yes-or-no-p "\
4583 Deleting parts may malfunction or destroy the article; continue? "))
4584 (let* ((data (get-text-property (point) 'gnus-data))
4585 (id (get-text-property (point) 'gnus-part))
4586 (handles gnus-article-mime-handles)
4590 (mail-decode-encoded-word-string (or (mm-handle-description data)
4593 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4595 (type (mm-handle-media-type data)))
4597 (error "No MIME part under point"))
4598 (with-current-buffer (mm-handle-buffer data)
4599 (let ((bsize (format "%s" (buffer-size))))
4604 "| The following attachment has been deleted:\n"
4606 "| Type: " type "\n"
4607 "| Filename: " filename "\n"
4608 "| Size (encoded): " bsize " Byte\n"
4609 "| Description: " description "\n"
4612 (cdr (mm-make-handle
4613 nil `("text/plain") nil nil
4615 (format "Deleted attachment (%s bytes)" bsize))))))
4616 ;; (set-buffer gnus-summary-buffer)
4617 (gnus-article-edit-part handles id))))
4619 (defun gnus-mime-save-part ()
4620 "Save the MIME part under point."
4622 (gnus-article-check-buffer)
4623 (let ((data (get-text-property (point) 'gnus-data)))
4625 (mm-save-part data))))
4627 (defun gnus-mime-pipe-part ()
4628 "Pipe the MIME part under point to a process."
4630 (gnus-article-check-buffer)
4631 (let ((data (get-text-property (point) 'gnus-data)))
4633 (mm-pipe-part data))))
4635 (defun gnus-mime-view-part ()
4636 "Interactively choose a viewing method for the MIME part under point."
4638 (gnus-article-check-buffer)
4639 (let ((data (get-text-property (point) 'gnus-data)))
4641 (setq gnus-article-mime-handles
4643 gnus-article-mime-handles (setq data (copy-sequence data))))
4644 (mm-interactively-view-part data))))
4646 (defun gnus-mime-view-part-as-type-internal ()
4647 (gnus-article-check-buffer)
4648 (let* ((name (mail-content-type-get
4649 (mm-handle-type (get-text-property (point) 'gnus-data))
4651 (def-type (and name (mm-default-file-encoding name))))
4652 (and def-type (cons def-type 0))))
4654 (defun gnus-mime-view-part-as-type (&optional mime-type)
4655 "Choose a MIME media type, and view the part as such."
4658 (setq mime-type (completing-read
4659 "View as MIME type: "
4660 (mapcar #'list (mailcap-mime-types))
4662 (gnus-mime-view-part-as-type-internal))))
4663 (gnus-article-check-buffer)
4664 (let ((handle (get-text-property (point) 'gnus-data)))
4667 (mm-make-handle (mm-handle-buffer handle)
4668 (cons mime-type (cdr (mm-handle-type handle)))
4669 (mm-handle-encoding handle)
4670 (mm-handle-undisplayer handle)
4671 (mm-handle-disposition handle)
4672 (mm-handle-description handle)
4674 (mm-handle-id handle)))
4675 (setq gnus-article-mime-handles
4676 (mm-merge-handles gnus-article-mime-handles handle))
4677 (gnus-mm-display-part handle))))
4679 (defun gnus-mime-copy-part (&optional handle arg)
4680 "Put the MIME part under point into a new buffer.
4681 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4683 (interactive (list nil current-prefix-arg))
4684 (gnus-article-check-buffer)
4686 (setq handle (get-text-property (point) 'gnus-data)))
4688 (let ((filename (or (mail-content-type-get (mm-handle-disposition handle)
4690 (mail-content-type-get (mm-handle-disposition handle)
4692 contents dont-decode charset coding-system)
4693 (mm-with-unibyte-buffer
4694 (mm-insert-part handle)
4695 (setq contents (or (condition-case nil
4696 (mm-decompress-buffer filename nil 'sig)
4698 (setq dont-decode t)
4701 (setq filename (cond (filename (file-name-nondirectory filename))
4702 (dont-decode "*raw data*")
4707 (unless (setq charset (mail-content-type-get
4708 (mm-handle-type handle) 'charset))
4709 (unless (setq coding-system (mm-with-unibyte-buffer
4711 (mm-find-buffer-file-coding-system)))
4712 (setq charset gnus-newsgroup-charset))))
4714 (setq charset (or (cdr (assq arg
4715 gnus-summary-show-article-charset-alist))
4716 (mm-read-coding-system "Charset: ")))))
4717 (switch-to-buffer (generate-new-buffer filename))
4718 (if (or coding-system
4720 (setq coding-system (mm-charset-to-coding-system charset))
4721 (not (eq charset 'ascii))))
4723 (mm-enable-multibyte)
4724 (insert (mm-decode-coding-string contents coding-system))
4725 (setq buffer-file-coding-system
4726 (if (boundp 'last-coding-system-used)
4727 (symbol-value 'last-coding-system-used)
4729 (mm-disable-multibyte)
4731 (setq buffer-file-coding-system mm-binary-coding-system))
4732 ;; We do it this way to make `normal-mode' set the appropriate mode.
4735 (setq buffer-file-name (expand-file-name filename))
4737 (setq buffer-file-name nil))
4738 (goto-char (point-min)))))
4740 (defun gnus-mime-print-part (&optional handle filename)
4741 "Print the MIME part under point."
4742 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4743 (gnus-article-check-buffer)
4744 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4745 (contents (and handle (mm-get-part handle)))
4746 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4747 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4752 (mm-save-part-to-file handle file)
4753 (call-process shell-file-name nil
4754 (generate-new-buffer " *mm*")
4756 shell-command-switch
4758 printer file (mm-handle-type handle))))
4762 (gnus-print-buffer))
4763 (ps-despool filename)))))
4765 (defun gnus-mime-inline-part (&optional handle arg)
4766 "Insert the MIME part under point into the current buffer.
4767 Compressed files like .gz and .bz2 are decompressed."
4768 (interactive (list nil current-prefix-arg))
4769 (gnus-article-check-buffer)
4771 (setq handle (get-text-property (point) 'gnus-data)))
4774 (inhibit-read-only t)
4775 contents charset coding-system)
4776 (if (and (not arg) (mm-handle-undisplayer handle))
4777 (mm-remove-part handle)
4778 (mm-with-unibyte-buffer
4779 (mm-insert-part handle)
4781 (or (mm-decompress-buffer
4782 (or (mail-content-type-get (mm-handle-disposition handle)
4784 (mail-content-type-get (mm-handle-disposition handle)
4790 (unless (setq charset (mail-content-type-get
4791 (mm-handle-type handle) 'charset))
4792 (unless (setq coding-system
4793 (mm-with-unibyte-buffer
4795 (mm-find-buffer-file-coding-system)))
4796 (setq charset gnus-newsgroup-charset))))
4798 (if (mm-handle-undisplayer handle)
4799 (mm-remove-part handle))
4802 gnus-summary-show-article-charset-alist))
4803 (mm-read-coding-system "Charset: "))))
4805 (if (mm-handle-undisplayer handle)
4806 (mm-remove-part handle))))
4810 (if (or coding-system
4813 (mm-charset-to-coding-system charset))
4814 (not (eq coding-system 'ascii))))
4815 (mm-decode-coding-string contents coding-system)
4816 (mm-string-to-multibyte contents)))
4819 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4820 "Insert the MIME part under point into the current buffer using the
4822 (interactive (list nil current-prefix-arg))
4823 (gnus-article-check-buffer)
4824 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4827 (inhibit-read-only t))
4829 (if (mm-handle-undisplayer handle)
4830 (mm-remove-part handle))
4831 (let ((gnus-newsgroup-charset
4833 gnus-summary-show-article-charset-alist))
4834 (mm-read-coding-system "Charset: ")))
4835 (gnus-newsgroup-ignored-charsets 'gnus-all))
4836 (gnus-article-press-button)))))
4838 (defun gnus-mime-view-part-externally (&optional handle)
4839 "View the MIME part under point with an external viewer."
4841 (gnus-article-check-buffer)
4842 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4843 (mm-user-display-methods nil)
4844 (mm-inlined-types nil)
4845 (mail-parse-charset gnus-newsgroup-charset)
4846 (mail-parse-ignored-charsets
4847 (with-current-buffer gnus-summary-buffer
4848 gnus-newsgroup-ignored-charsets)))
4850 (if (mm-handle-undisplayer handle)
4851 (mm-remove-part handle)
4852 (mm-display-part handle)))))
4854 (defun gnus-mime-view-part-internally (&optional handle)
4855 "View the MIME part under point with an internal viewer.
4856 If no internal viewer is available, use an external viewer."
4858 (gnus-article-check-buffer)
4859 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4860 (mm-inlined-types '(".*"))
4861 (mm-inline-large-images t)
4862 (mail-parse-charset gnus-newsgroup-charset)
4863 (mail-parse-ignored-charsets
4864 (with-current-buffer gnus-summary-buffer
4865 gnus-newsgroup-ignored-charsets))
4866 (inhibit-read-only t))
4868 (if (mm-handle-undisplayer handle)
4869 (mm-remove-part handle)
4870 (mm-display-part handle)))))
4872 (defun gnus-mime-action-on-part (&optional action)
4873 "Do something with the MIME attachment at \(point\)."
4875 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4876 (gnus-article-check-buffer)
4877 (let ((action-pair (assoc action gnus-mime-action-alist)))
4879 (funcall (cdr action-pair)))))
4881 (defun gnus-article-part-wrapper (n function &optional no-handle)
4883 ;; Check whether the article is displayed.
4884 (unless (and (gnus-buffer-live-p gnus-article-buffer)
4885 (setq window (get-buffer-window gnus-article-buffer t))
4886 (frame-visible-p (setq frame (window-frame window))))
4887 (error "No article is displayed"))
4888 (with-current-buffer gnus-article-buffer
4889 ;; Check whether the article displays the right contents.
4890 (unless (with-current-buffer gnus-summary-buffer
4891 (eq gnus-current-article (gnus-summary-article-number)))
4892 (error "You should select the right article first"))
4893 ;; Check whether the specified part exists.
4894 (when (> n (length gnus-article-mime-handle-alist))
4895 (error "No such part")))
4898 ;; To select the window is needed so that the cursor
4899 ;; might be visible on the MIME button.
4900 (select-window (prog1
4902 (setq window (selected-window))
4903 ;; Article may be displayed in the other frame.
4904 (gnus-select-frame-set-input-focus
4907 (setq frame (selected-frame))))))
4908 (when (gnus-article-goto-part n)
4909 ;; We point the cursor and the arrow at the MIME button
4910 ;; when the `function' prompt the user for something.
4911 (let ((cursor-in-non-selected-windows t)
4912 (overlay-arrow-string "=>")
4913 (overlay-arrow-position (point-marker)))
4918 (cdr (assq n gnus-article-mime-handle-alist))))
4919 (set-marker overlay-arrow-position nil)
4920 (unless gnus-auto-select-part
4921 (gnus-select-frame-set-input-focus frame)
4922 (select-window window))))
4924 (if gnus-inhibit-mime-unbuttonizing
4925 ;; This is the default though the program shouldn't reach here.
4926 (error "No such part")
4927 ;; The part which doesn't have the MIME button is selected.
4928 ;; So, we display all the buttons and redo it.
4929 (let ((gnus-inhibit-mime-unbuttonizing t))
4930 (gnus-summary-show-article)
4931 (gnus-article-part-wrapper n function no-handle))))))
4933 (defun gnus-article-pipe-part (n)
4934 "Pipe MIME part N, which is the numerical prefix."
4936 (gnus-article-part-wrapper n 'mm-pipe-part))
4938 (defun gnus-article-save-part (n)
4939 "Save MIME part N, which is the numerical prefix."
4941 (gnus-article-part-wrapper n 'mm-save-part))
4943 (defun gnus-article-interactively-view-part (n)
4944 "View MIME part N interactively, which is the numerical prefix."
4946 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4948 (defun gnus-article-copy-part (n)
4949 "Copy MIME part N, which is the numerical prefix."
4951 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4953 (defun gnus-article-view-part-as-charset (n)
4954 "View MIME part N using a specified charset.
4955 N is the numerical prefix."
4957 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4959 (defun gnus-article-view-part-externally (n)
4960 "View MIME part N externally, which is the numerical prefix."
4962 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4964 (defun gnus-article-inline-part (n)
4965 "Inline MIME part N, which is the numerical prefix."
4967 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4969 (defun gnus-article-save-part-and-strip (n)
4970 "Save MIME part N and replace it with an external body.
4971 N is the numerical prefix."
4973 (gnus-article-part-wrapper n 'gnus-mime-save-part-and-strip t))
4975 (defun gnus-article-delete-part (n)
4976 "Delete MIME part N and add some information about the removed part.
4977 N is the numerical prefix."
4979 (gnus-article-part-wrapper n 'gnus-mime-delete-part t))
4981 (defun gnus-article-mime-match-handle-first (condition)
4984 (dolist (ihandle gnus-article-mime-handle-alist)
4986 ((functionp condition)
4987 (funcall condition (cdr ihandle)))
4988 ((eq condition 'undisplayed)
4989 (not (or (mm-handle-undisplayer (cdr ihandle))
4990 (equal (mm-handle-media-type (cdr ihandle))
4991 "multipart/alternative"))))
4992 ((eq condition 'undisplayed-alternative)
4993 (not (mm-handle-undisplayer (cdr ihandle))))
4995 (gnus-article-goto-part (car ihandle))
4996 (or (not n) (< (car ihandle) n)))
4997 (setq n (car ihandle))))
5001 (defun gnus-article-view-part (&optional n)
5002 "View MIME part N, which is the numerical prefix."
5004 (with-current-buffer gnus-article-buffer
5005 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
5006 gnus-article-mime-match-handle-function)))
5007 (when (> n (length gnus-article-mime-handle-alist))
5008 (error "No such part"))
5009 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
5010 (when (gnus-article-goto-part n)
5011 (if (equal (car handle) "multipart/alternative")
5012 (gnus-article-press-button)
5013 (when (eq (gnus-mm-display-part handle) 'internal)
5014 (gnus-set-window-start)))))))
5016 (defsubst gnus-article-mime-total-parts ()
5017 (if (bufferp (car gnus-article-mime-handles))
5019 (1- (length gnus-article-mime-handles))))
5021 (defun gnus-mm-display-part (handle)
5022 "Display HANDLE and fix MIME button."
5023 (let ((id (get-text-property (point) 'gnus-part))
5025 (inhibit-read-only t))
5028 (let ((window (selected-window))
5029 (mail-parse-charset gnus-newsgroup-charset)
5030 (mail-parse-ignored-charsets
5031 (if (gnus-buffer-live-p gnus-summary-buffer)
5032 (with-current-buffer gnus-summary-buffer
5033 gnus-newsgroup-ignored-charsets)
5037 (let ((win (gnus-get-buffer-window (current-buffer) t))
5040 (select-window win))
5043 (if (mm-handle-displayed-p handle)
5044 ;; This will remove the part.
5045 (mm-display-part handle)
5047 (narrow-to-region (point)
5048 (if (eobp) (point) (1+ (point))))
5049 (mm-display-part handle)
5050 ;; We narrow to the part itself and
5051 ;; then call the treatment functions.
5052 (goto-char (point-min))
5054 (narrow-to-region (point) (point-max))
5057 (gnus-article-mime-total-parts)
5058 (mm-handle-media-type handle)))))
5059 (if (window-live-p window)
5060 (select-window window)))))
5063 (gnus-insert-mime-button
5064 handle id (list (mm-handle-displayed-p handle)))
5065 (goto-char point))))
5067 (defun gnus-article-goto-part (n)
5068 "Go to MIME part N."
5069 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
5071 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
5072 (let ((gnus-tmp-name
5073 (or (mail-content-type-get (mm-handle-type handle) 'name)
5074 (mail-content-type-get (mm-handle-disposition handle) 'filename)
5075 (mail-content-type-get (mm-handle-type handle) 'url)
5077 (gnus-tmp-type (mm-handle-media-type handle))
5078 (gnus-tmp-description
5079 (mail-decode-encoded-word-string (or (mm-handle-description handle)
5082 (if (if displayed (car displayed)
5083 (mm-handle-displayed-p handle))
5085 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
5087 gnus-tmp-type-long b e)
5088 (when (string-match ".*/" gnus-tmp-name)
5089 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
5090 (setq gnus-tmp-type-long (concat gnus-tmp-type
5091 (and (not (equal gnus-tmp-name ""))
5092 (concat "; " gnus-tmp-name))))
5093 (unless (equal gnus-tmp-description "")
5094 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
5099 gnus-mime-button-line-format gnus-mime-button-line-format-alist
5100 `(keymap ,gnus-mime-button-map
5101 gnus-callback gnus-mm-display-part
5102 gnus-part ,gnus-tmp-id
5103 article-type annotation
5106 ;; Exclude a newline.
5109 (widget-convert-button
5112 :action 'gnus-widget-press-button
5113 :button-keymap gnus-mime-button-map
5115 (lambda (widget/window &optional overlay pos)
5116 ;; Needed to properly clear the message due to a bug in
5117 ;; wid-edit (XEmacs only).
5118 (if (boundp 'help-echo-owns-message)
5119 (setq help-echo-owns-message t))
5121 "%S: %s the MIME part; %S: more options"
5122 (aref gnus-mouse-2 0)
5123 ;; XEmacs will get a single widget arg; Emacs 21 will get
5124 ;; window, overlay, position.
5125 (if (mm-handle-displayed-p
5127 (with-current-buffer (gnus-overlay-buffer overlay)
5128 (widget-get (widget-at (gnus-overlay-start overlay))
5130 (widget-get widget/window :mime-handle)))
5132 (aref gnus-down-mouse-3 0))))))
5134 (defun gnus-widget-press-button (elems el)
5135 (goto-char (widget-get elems :from))
5136 (gnus-article-press-button))
5138 (defvar gnus-displaying-mime nil)
5140 (defun gnus-display-mime (&optional ihandles)
5141 "Display the MIME parts."
5143 (save-selected-window
5144 (let ((window (get-buffer-window gnus-article-buffer))
5147 (select-window window)
5148 ;; We have to do this since selecting the window
5149 ;; may change the point. So we set the window point.
5150 (set-window-point window point)))
5151 (let ((handles ihandles)
5152 (inhibit-read-only t)
5155 ((setq handles (mm-dissect-buffer nil gnus-article-loose-mime))
5156 (when gnus-article-emulate-mime
5157 (mm-uu-dissect-text-parts handles)))
5158 (gnus-article-emulate-mime
5159 (setq handles (mm-uu-dissect))))
5160 (when (and (not ihandles)
5161 (not gnus-displaying-mime))
5162 ;; Top-level call; we clean up.
5163 (when gnus-article-mime-handles
5164 (mm-destroy-parts gnus-article-mime-handles)
5165 (setq gnus-article-mime-handle-alist nil));; A trick.
5166 (setq gnus-article-mime-handles handles)
5167 ;; We allow users to glean info from the handles.
5168 (when gnus-article-mime-part-function
5169 (gnus-mime-part-function handles)))
5171 (or (not (stringp (car handles)))
5174 (when (and (not ihandles)
5175 (not gnus-displaying-mime))
5176 ;; Clean up for mime parts.
5178 (delete-region (point) (point-max)))
5179 (let ((gnus-displaying-mime t))
5180 (gnus-mime-display-part handles)))
5183 (narrow-to-region (point) (point-max))
5184 (gnus-treat-article nil 1 1)
5187 ;; Highlight the headers.
5191 (narrow-to-region (point-min) (point))
5192 (gnus-article-save-original-date
5193 (gnus-treat-article 'head)))))))))
5195 (defcustom gnus-mime-display-multipart-as-mixed nil
5196 "Display \"multipart\" parts as \"multipart/mixed\".
5198 If t, it overrides nil values of
5199 `gnus-mime-display-multipart-alternative-as-mixed' and
5200 `gnus-mime-display-multipart-related-as-mixed'."
5201 :group 'gnus-article-mime
5204 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
5205 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
5207 :group 'gnus-article-mime
5210 (defcustom gnus-mime-display-multipart-related-as-mixed nil
5211 "Display \"multipart/related\" parts as \"multipart/mixed\".
5213 If displaying \"text/html\" is discouraged \(see
5214 `mm-discouraged-alternatives'\) images or other material inside a
5215 \"multipart/related\" part might be overlooked when this variable is nil."
5217 :group 'gnus-article-mime
5220 (defun gnus-mime-display-part (handle)
5223 ((not (stringp (car handle)))
5224 (gnus-mime-display-single handle))
5225 ;; User-defined multipart
5226 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
5227 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
5229 ;; multipart/alternative
5230 ((and (equal (car handle) "multipart/alternative")
5231 (not (or gnus-mime-display-multipart-as-mixed
5232 gnus-mime-display-multipart-alternative-as-mixed)))
5233 (let ((id (1+ (length gnus-article-mime-handle-alist))))
5234 (push (cons id handle) gnus-article-mime-handle-alist)
5235 (gnus-mime-display-alternative (cdr handle) nil nil id)))
5236 ;; multipart/related
5237 ((and (equal (car handle) "multipart/related")
5238 (not (or gnus-mime-display-multipart-as-mixed
5239 gnus-mime-display-multipart-related-as-mixed)))
5240 ;;;!!!We should find the start part, but we just default
5241 ;;;!!!to the first part.
5242 ;;(gnus-mime-display-part (cadr handle))
5243 ;;;!!! Most multipart/related is an HTML message plus images.
5244 ;;;!!! Unfortunately we are unable to let W3 display those
5245 ;;;!!! included images, so we just display it as a mixed multipart.
5246 ;;(gnus-mime-display-mixed (cdr handle))
5247 ;;;!!! No, w3 can display everything just fine.
5248 (gnus-mime-display-part (cadr handle)))
5249 ((equal (car handle) "multipart/signed")
5250 (gnus-add-wash-type 'signed)
5251 (gnus-mime-display-security handle))
5252 ((equal (car handle) "multipart/encrypted")
5253 (gnus-add-wash-type 'encrypted)
5254 (gnus-mime-display-security handle))
5255 ;; Other multiparts are handled like multipart/mixed.
5257 (gnus-mime-display-mixed (cdr handle)))))
5259 (defun gnus-mime-part-function (handles)
5260 (if (stringp (car handles))
5261 (mapcar 'gnus-mime-part-function (cdr handles))
5262 (funcall gnus-article-mime-part-function handles)))
5264 (defun gnus-mime-display-mixed (handles)
5265 (mapcar 'gnus-mime-display-part handles))
5267 (defun gnus-mime-display-single (handle)
5268 (let ((type (mm-handle-media-type handle))
5269 (ignored gnus-ignored-mime-types)
5276 (when (string-match (pop ignored) type)
5277 (throw 'ignored nil)))
5278 (if (and (setq not-attachment
5279 (and (not (mm-inline-override-p handle))
5280 (or (not (mm-handle-disposition handle))
5281 (equal (car (mm-handle-disposition handle))
5283 (mm-attachment-override-p handle))))
5284 (mm-automatic-display-p handle)
5286 (mm-inlinable-p handle)
5287 (mm-inlined-p handle))
5288 (mm-automatic-external-display-p type)))
5290 (when (equal (mm-handle-media-supertype handle) "text")
5292 (let ((id (1+ (length gnus-article-mime-handle-alist)))
5294 (push (cons id handle) gnus-article-mime-handle-alist)
5295 (when (or (not display)
5296 (not (gnus-unbuttonized-mime-type-p type)))
5297 (gnus-insert-mime-button
5298 handle id (list (or display (and not-attachment text))))
5299 (gnus-article-insert-newline)
5300 ;; Remember modify the number of forward lines.
5308 (let ((mail-parse-charset gnus-newsgroup-charset)
5309 (mail-parse-ignored-charsets
5310 (save-excursion (condition-case ()
5311 (set-buffer gnus-summary-buffer)
5313 gnus-newsgroup-ignored-charsets)))
5314 (mm-display-part handle t))
5315 (goto-char (point-max)))
5316 ((and text not-attachment)
5320 (gnus-article-insert-newline)
5321 (mm-display-inline handle)
5322 (goto-char (point-max))))
5326 (narrow-to-region beg (point))
5329 (gnus-article-mime-total-parts)
5330 (mm-handle-media-type handle)))))))))
5332 (defun gnus-unbuttonized-mime-type-p (type)
5333 "Say whether TYPE is to be unbuttonized."
5334 (unless gnus-inhibit-mime-unbuttonizing
5336 (let ((types gnus-unbuttonized-mime-types))
5338 (when (string-match (pop types) type)
5339 (throw 'found t)))))
5341 (let ((types gnus-buttonized-mime-types))
5343 (when (string-match (pop types) type)
5344 (throw 'found t)))))))))
5346 (defun gnus-article-insert-newline ()
5347 "Insert a newline, but mark it as undeletable."
5348 (gnus-put-text-property
5349 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
5351 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
5352 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
5355 handle (inhibit-read-only t) from props begend not-pref)
5356 (save-window-excursion
5359 (narrow-to-region (car ibegend)
5362 (goto-char (car ibegend))
5365 (delete-region (point-min) (point-max))
5366 (mm-remove-parts handles))
5367 (setq begend (list (point-marker)))
5369 (unless (setq not-pref (cadr (member preferred ihandles)))
5370 (setq not-pref (car ihandles)))
5373 (not (gnus-unbuttonized-mime-type-p
5374 "multipart/alternative")))
5375 (gnus-add-text-properties
5378 (insert (format "%d. " id))
5382 (unless ,(not ibegend)
5383 (setq gnus-article-mime-handle-alist
5384 ',gnus-article-mime-handle-alist))
5385 (gnus-mime-display-alternative
5386 ',ihandles ',not-pref ',begend ,id))
5387 keymap ,gnus-mime-button-map
5388 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5389 face ,gnus-article-button-face
5392 (widget-convert-button 'link from (point)
5393 :action 'gnus-widget-press-button
5394 :button-keymap gnus-widget-button-keymap)
5396 (while (setq handle (pop handles))
5397 (gnus-add-text-properties
5400 (insert (format "(%c) %-18s"
5401 (if (equal handle preferred) ?* ? )
5402 (mm-handle-media-type handle)))
5406 (unless ,(not ibegend)
5407 (setq gnus-article-mime-handle-alist
5408 ',gnus-article-mime-handle-alist))
5409 (gnus-mime-display-alternative
5410 ',ihandles ',handle ',begend ,id))
5411 keymap ,gnus-mime-button-map
5412 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5413 face ,gnus-article-button-face
5416 (widget-convert-button 'link from (point)
5417 :action 'gnus-widget-press-button
5418 :button-keymap gnus-widget-button-keymap)
5422 (if (stringp (car preferred))
5423 (gnus-display-mime preferred)
5424 (let ((mail-parse-charset gnus-newsgroup-charset)
5425 (mail-parse-ignored-charsets
5426 (with-current-buffer gnus-summary-buffer
5427 gnus-newsgroup-ignored-charsets)))
5428 (mm-display-part preferred)
5432 (narrow-to-region (car begend) (point-max))
5434 nil (length gnus-article-mime-handle-alist)
5435 (gnus-article-mime-total-parts)
5436 (mm-handle-media-type handle))))))
5437 (goto-char (point-max))
5438 (setcdr begend (point-marker)))))
5440 (goto-char point))))
5442 (defconst gnus-article-wash-status-strings
5443 (let ((alist '((cite "c" "Possible hidden citation text"
5444 " " "All citation text visible")
5445 (headers "h" "Hidden headers"
5446 " " "All headers visible.")
5447 (pgp "p" "Encrypted or signed message status hidden"
5448 " " "No hidden encryption nor digital signature status")
5449 (signature "s" "Signature has been hidden"
5450 " " "Signature is visible")
5451 (overstrike "o" "Overstrike (^H) characters applied"
5452 " " "No overstrike characters applied")
5453 (gnus-show-mime "m" "Mime processing is activated"
5454 " " "Mime processing is not activated")
5455 (emphasis "e" "/*_Emphasis_*/ characters applied"
5456 " " "No /*_emphasis_*/ characters applied")))
5458 (dolist (entry alist result)
5459 (let ((key (nth 0 entry))
5460 (on (copy-sequence (nth 1 entry)))
5461 (on-help (nth 2 entry))
5462 (off (copy-sequence (nth 3 entry)))
5463 (off-help (nth 4 entry)))
5464 (put-text-property 0 1 'help-echo on-help on)
5465 (put-text-property 0 1 'help-echo off-help off)
5466 (push (list key on off) result))))
5467 "Alist of strings describing wash status in the mode line.
5468 Each entry has the form (KEY ON OF), where the KEY is a symbol
5469 representing the particular washing function, ON is the string to use
5470 in the article mode line when the washing function is active, and OFF
5471 is the string to use when it is inactive.")
5473 (defun gnus-article-wash-status-entry (key value)
5474 (let ((entry (assoc key gnus-article-wash-status-strings)))
5475 (if value (nth 1 entry) (nth 2 entry))))
5477 (defun gnus-article-wash-status ()
5478 "Return a string which display status of article washing."
5479 (with-current-buffer gnus-article-buffer
5480 (let ((cite (memq 'cite gnus-article-wash-types))
5481 (headers (memq 'headers gnus-article-wash-types))
5482 (boring (memq 'boring-headers gnus-article-wash-types))
5483 (pgp (memq 'pgp gnus-article-wash-types))
5484 (pem (memq 'pem gnus-article-wash-types))
5485 (signed (memq 'signed gnus-article-wash-types))
5486 (encrypted (memq 'encrypted gnus-article-wash-types))
5487 (signature (memq 'signature gnus-article-wash-types))
5488 (overstrike (memq 'overstrike gnus-article-wash-types))
5489 (emphasis (memq 'emphasis gnus-article-wash-types)))
5491 (gnus-article-wash-status-entry 'cite cite)
5492 (gnus-article-wash-status-entry 'headers (or headers boring))
5493 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5494 (gnus-article-wash-status-entry 'signature signature)
5495 (gnus-article-wash-status-entry 'overstrike overstrike)
5496 (gnus-article-wash-status-entry 'gnus-show-mime gnus-show-mime)
5497 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5499 (defun gnus-add-wash-type (type)
5500 "Add a washing of TYPE to the current status."
5501 (add-to-list 'gnus-article-wash-types type))
5503 (defun gnus-delete-wash-type (type)
5504 "Add a washing of TYPE to the current status."
5505 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5507 (defun gnus-add-image (category image)
5508 "Add IMAGE of CATEGORY to the list of displayed images."
5509 (let ((entry (assq category gnus-article-image-alist)))
5511 (setq entry (list category))
5512 (push entry gnus-article-image-alist))
5513 (nconc entry (list image))))
5515 (defun gnus-delete-images (category)
5516 "Delete all images in CATEGORY."
5517 (let ((entry (assq category gnus-article-image-alist)))
5518 (dolist (image (cdr entry))
5519 (gnus-remove-image image category))
5520 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5521 (gnus-delete-wash-type category)))
5523 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5525 (defun gnus-article-maybe-hide-headers ()
5526 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5527 Provided for backwards compatibility."
5528 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5529 (not (with-current-buffer gnus-summary-buffer
5530 gnus-have-all-headers)))
5531 (not gnus-inhibit-hiding))
5532 (gnus-article-hide-headers)))
5536 (defun gnus-output-to-file (file-name)
5537 "Append the current article to a file named FILE-NAME."
5538 (let ((artbuf (current-buffer)))
5540 (insert-buffer-substring artbuf)
5541 ;; Append newline at end of the buffer as separator, and then
5543 (goto-char (point-max))
5545 (let ((file-name-coding-system nnmail-pathname-coding-system))
5546 (write-region-as-binary (point-min) (point-max) file-name 'append))
5549 (defun gnus-narrow-to-page (&optional arg)
5550 "Narrow the article buffer to a page.
5551 If given a numerical ARG, move forward ARG pages."
5553 (setq arg (if arg (prefix-numeric-value arg) 0))
5555 (set-buffer gnus-article-buffer)
5556 (goto-char (point-min))
5558 ;; Remove any old next/prev buttons.
5559 (when (gnus-visual-p 'page-marker)
5560 (let ((inhibit-read-only t))
5561 (gnus-remove-text-with-property 'gnus-prev)
5562 (gnus-remove-text-with-property 'gnus-next)))
5565 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5567 (re-search-forward page-delimiter nil 'move arg)))
5568 (goto-char (match-end 0))
5570 (goto-char (point-min))
5571 (setq gnus-page-broken
5572 (and (re-search-forward page-delimiter nil t) t))))
5573 (when gnus-page-broken
5576 (if (re-search-forward page-delimiter nil 'move)
5579 (when (and (gnus-visual-p 'page-marker)
5580 (> (point-min) (save-restriction (widen) (point-min))))
5582 (goto-char (point-min))
5583 (gnus-insert-prev-page-button)))
5584 (when (and (gnus-visual-p 'page-marker)
5585 (< (point-max) (save-restriction (widen) (point-max))))
5587 (goto-char (point-max))
5588 (gnus-insert-next-page-button))))))
5590 ;; Article mode commands
5592 (defun gnus-article-goto-next-page ()
5593 "Show the next page of the article."
5595 (when (gnus-article-next-page)
5596 (goto-char (point-min))
5597 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5600 (defun gnus-article-goto-prev-page ()
5601 "Show the previous page of the article."
5604 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5605 (gnus-article-prev-page nil)))
5607 ;; This is cleaner but currently breaks `gnus-pick-mode':
5609 ;; (defun gnus-article-goto-next-page ()
5610 ;; "Show the next page of the article."
5612 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5613 ;; (gnus-summary-next-page)))
5615 ;; (defun gnus-article-goto-prev-page ()
5616 ;; "Show the next page of the article."
5618 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5619 ;; (gnus-summary-prev-page)))
5621 (defun gnus-article-next-page (&optional lines)
5622 "Show the next page of the current article.
5623 If end of article, return non-nil. Otherwise return nil.
5624 Argument LINES specifies lines to be scrolled up."
5626 (move-to-window-line -1)
5629 (and (pos-visible-in-window-p) ;Not continuation line.
5630 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5631 ;; Nothing in this page.
5632 (if (or (not gnus-page-broken)
5637 (eobp)))) ;Real end-of-buffer?
5639 (when gnus-article-over-scroll
5640 (gnus-article-next-page-1 lines))
5642 (gnus-narrow-to-page 1) ;Go to next page.
5644 ;; More in this page.
5645 (gnus-article-next-page-1 lines)
5648 (defmacro gnus-article-beginning-of-window ()
5649 "Move point to the beginning of the window.
5650 In Emacs, the point is placed at the line number which `scroll-margin'
5652 (if (featurep 'xemacs)
5653 '(move-to-window-line 0)
5654 '(move-to-window-line
5655 (min (max 0 scroll-margin)
5656 (max 1 (- (window-height)
5657 (if mode-line-format 1 0)
5658 (if header-line-format 1 0)))))))
5660 (defun gnus-article-next-page-1 (lines)
5661 (when (and (not (featurep 'xemacs))
5664 (numberp (symbol-value 'scroll-margin))
5665 (> (symbol-value 'scroll-margin) 0))
5666 ;; Protect against the bug that Emacs 21.x hangs up when scrolling up for
5667 ;; too many number of lines if `scroll-margin' is set as two or greater.
5668 (setq lines (min lines
5669 (max 0 (- (count-lines (window-start) (point-max))
5670 (symbol-value 'scroll-margin))))))
5672 (let ((scroll-in-place nil))
5675 ;; Long lines may cause an end-of-buffer error.
5676 (goto-char (point-max))))
5677 (gnus-article-beginning-of-window))
5679 (defun gnus-article-prev-page (&optional lines)
5680 "Show previous page of current article.
5681 Argument LINES specifies lines to be scrolled down."
5683 (move-to-window-line 0)
5684 (if (and gnus-page-broken
5686 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5688 (gnus-narrow-to-page -1) ;Go to previous page.
5689 (goto-char (point-max))
5693 (let ((scroll-in-place nil))
5694 (scroll-down lines))
5695 (beginning-of-buffer
5696 (goto-char (point-min))))
5697 (gnus-article-beginning-of-window))))
5699 (defun gnus-article-only-boring-p ()
5700 "Decide whether there is only boring text remaining in the article.
5701 Something \"interesting\" is a word of at least two letters that does
5702 not have a face in `gnus-article-boring-faces'."
5703 (when (and gnus-article-skip-boring
5704 (boundp 'gnus-article-boring-faces)
5705 (symbol-value 'gnus-article-boring-faces))
5708 (while (re-search-forward "\\b\\w\\w" nil t)
5710 (when (not (gnus-intersection
5711 (gnus-faces-at (point))
5712 (symbol-value 'gnus-article-boring-faces)))
5713 (throw 'only-boring nil)))
5714 (throw 'only-boring t)))))
5716 (defun gnus-article-refer-article ()
5717 "Read article specified by message-id around point."
5720 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
5721 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
5722 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
5723 (let ((msg-id (concat "<" (match-string 0) ">")))
5724 (set-buffer gnus-summary-buffer)
5725 (gnus-summary-refer-article msg-id))
5726 (error "No references around point"))))
5728 (defun gnus-article-show-summary ()
5729 "Reconfigure windows to show summary buffer."
5731 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5732 (error "There is no summary buffer for this article buffer")
5733 (gnus-article-set-globals)
5734 (gnus-configure-windows 'article)
5735 (gnus-summary-goto-subject gnus-current-article)
5736 (gnus-summary-position-point)))
5738 (defun gnus-article-describe-briefly ()
5739 "Describe article mode commands briefly."
5741 (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")))
5743 (defun gnus-article-summary-command ()
5744 "Execute the last keystroke in the summary buffer."
5746 (let ((obuf (current-buffer))
5747 (owin (current-window-configuration))
5749 (switch-to-buffer gnus-article-current-summary 'norecord)
5750 (setq func (lookup-key (current-local-map) (this-command-keys)))
5751 (call-interactively func)
5753 (set-window-configuration owin)
5754 (set-window-point (get-buffer-window (current-buffer)) (point))))
5756 (defun gnus-article-summary-command-nosave ()
5757 "Execute the last keystroke in the summary buffer."
5760 (pop-to-buffer gnus-article-current-summary 'norecord)
5761 (setq func (lookup-key (current-local-map) (this-command-keys)))
5762 (call-interactively func)))
5764 (defun gnus-article-check-buffer ()
5765 "Beep if not in an article buffer."
5766 (unless (eq (get-buffer gnus-article-buffer) (current-buffer))
5767 (error "Command invoked outside of a Gnus article buffer")))
5769 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5770 "Read a summary buffer key sequence and execute it from the article buffer."
5772 (gnus-article-check-buffer)
5774 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5775 "Zc" "ZC" "ZE" "ZJ" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5776 "=" "^" "\M-^" "|"))
5782 '("n" "Gn" "p" "Gp"))
5785 (set-buffer gnus-article-current-summary)
5786 (let (gnus-pick-mode)
5787 (push (or key last-command-event) unread-command-events)
5788 (setq keys (static-if (featurep 'xemacs)
5789 (events-to-keys (read-key-sequence nil))
5790 (read-key-sequence nil)))))
5793 (if (or (member keys nosaves)
5794 (member keys nosave-but-article)
5795 (member keys nosave-in-article))
5797 (save-window-excursion
5798 (pop-to-buffer gnus-article-current-summary 'norecord)
5799 ;; We disable the pick minor mode commands.
5800 (let (gnus-pick-mode)
5801 (setq func (lookup-key (current-local-map) keys))))
5805 (unless (member keys nosave-in-article)
5806 (set-buffer gnus-article-current-summary))
5807 (call-interactively func)
5808 (setq new-sum-point (point)))
5809 (when (member keys nosave-but-article)
5810 (pop-to-buffer gnus-article-buffer 'norecord)))
5811 ;; These commands should restore window configuration.
5812 (let ((obuf (current-buffer))
5813 (owin (current-window-configuration))
5815 win func in-buffer selected new-sum-start new-sum-hscroll)
5816 (cond (not-restore-window
5817 (pop-to-buffer gnus-article-current-summary 'norecord))
5818 ((setq win (get-buffer-window gnus-article-current-summary))
5819 (select-window win))
5821 (switch-to-buffer gnus-article-current-summary 'norecord)))
5822 (setq in-buffer (current-buffer))
5823 ;; We disable the pick minor mode commands.
5824 (if (and (setq func (let (gnus-pick-mode)
5825 (lookup-key (current-local-map) keys)))
5828 (call-interactively func)
5829 (when (eq win (selected-window))
5830 (setq new-sum-point (point)
5831 new-sum-start (window-start win)
5832 new-sum-hscroll (window-hscroll win)))
5833 (when (eq in-buffer (current-buffer))
5834 (setq selected (gnus-summary-select-article))
5836 (unless not-restore-window
5837 (set-window-configuration owin))
5838 (when (eq selected 'old)
5840 (set-window-start (get-buffer-window (current-buffer))
5842 (set-window-point (get-buffer-window (current-buffer))
5844 (when (and (not not-restore-window)
5846 (set-window-point win new-sum-point)
5847 (set-window-start win new-sum-start)
5848 (set-window-hscroll win new-sum-hscroll))))
5849 (set-window-configuration owin)
5852 (defun gnus-article-describe-key (key)
5853 "Display documentation of the function invoked by KEY. KEY is a string."
5854 (interactive "kDescribe key: ")
5855 (gnus-article-check-buffer)
5856 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5858 (set-buffer gnus-article-current-summary)
5859 (let (gnus-pick-mode)
5860 (if (featurep 'xemacs)
5862 (push (elt key 0) unread-command-events)
5863 (setq key (events-to-keys
5864 (read-key-sequence "Describe key: "))))
5865 (setq unread-command-events
5867 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5869 (setq key (read-key-sequence "Describe key: "))))
5871 (describe-key key)))
5873 (defun gnus-article-describe-key-briefly (key &optional insert)
5874 "Display documentation of the function invoked by KEY. KEY is a string."
5875 (interactive "kDescribe key: \nP")
5876 (gnus-article-check-buffer)
5877 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5879 (set-buffer gnus-article-current-summary)
5880 (let (gnus-pick-mode)
5881 (if (featurep 'xemacs)
5883 (push (elt key 0) unread-command-events)
5884 (setq key (events-to-keys
5885 (read-key-sequence "Describe key: "))))
5886 (setq unread-command-events
5888 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5890 (setq key (read-key-sequence "Describe key: "))))
5891 (describe-key-briefly key insert))
5892 (describe-key-briefly key insert)))
5894 (defun gnus-article-reply-with-original (&optional wide)
5895 "Start composing a reply mail to the current message.
5896 The text in the region will be yanked. If the region isn't active,
5897 the entire article will be yanked."
5899 (let ((article (cdr gnus-article-current))
5901 (if (not (gnus-region-active-p))
5902 (with-current-buffer gnus-summary-buffer
5903 (gnus-summary-reply (list (list article)) wide))
5904 (setq contents (buffer-substring (point) (mark t)))
5905 ;; Deactivate active regions.
5906 (when (and (boundp 'transient-mark-mode)
5907 transient-mark-mode)
5908 (setq mark-active nil))
5909 (with-current-buffer gnus-summary-buffer
5911 (list (list article contents)) wide)))))
5913 (defun gnus-article-followup-with-original ()
5914 "Compose a followup to the current article.
5915 The text in the region will be yanked. If the region isn't active,
5916 the entire article will be yanked."
5918 (let ((article (cdr gnus-article-current))
5920 (if (not (gnus-region-active-p))
5921 (with-current-buffer gnus-summary-buffer
5922 (gnus-summary-followup (list (list article))))
5923 (setq contents (buffer-substring (point) (mark t)))
5924 ;; Deactivate active regions.
5925 (when (and (boundp 'transient-mark-mode)
5926 transient-mark-mode)
5927 (setq mark-active nil))
5928 (with-current-buffer gnus-summary-buffer
5929 (gnus-summary-followup
5930 (list (list article contents)))))))
5932 (defun gnus-article-hide (&optional arg force)
5933 "Hide all the gruft in the current article.
5934 This means that signatures, cited text and (some) headers will be
5936 If given a prefix, show the hidden text instead."
5937 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5938 (gnus-article-hide-headers arg)
5939 (gnus-article-hide-list-identifiers arg)
5940 (gnus-article-hide-citation-maybe arg force)
5941 (gnus-article-hide-signature arg))
5943 (defun gnus-article-maybe-highlight ()
5944 "Do some article highlighting if article highlighting is requested."
5945 (when (gnus-visual-p 'article-highlight 'highlight)
5946 (gnus-article-highlight-some)))
5948 (defun gnus-check-group-server ()
5949 ;; Make sure the connection to the server is alive.
5950 (unless (gnus-server-opened
5951 (gnus-find-method-for-group gnus-newsgroup-name))
5952 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5953 (gnus-request-group gnus-newsgroup-name t)))
5956 (autoload 'nneething-get-file-name "nneething"))
5958 (defun gnus-request-article-this-buffer (article group)
5959 "Get an article and insert it into this buffer."
5960 (let (do-update-line sparse-header)
5964 (gnus-kill-all-overlays)
5965 (setq group (or group gnus-newsgroup-name))
5967 ;; Using `gnus-request-article' directly will insert the article into
5968 ;; `nntp-server-buffer' - so we'll save some time by not having to
5969 ;; copy it from the server buffer into the article buffer.
5971 ;; We only request an article by message-id when we do not have the
5972 ;; headers for it, so we'll have to get those.
5973 (when (stringp article)
5974 (gnus-read-header article))
5976 ;; If the article number is negative, that means that this article
5977 ;; doesn't belong in this newsgroup (possibly), so we find its
5978 ;; message-id and request it by id instead of number.
5979 (when (and (numberp article)
5981 (get-buffer gnus-summary-buffer)
5982 (gnus-buffer-exists-p gnus-summary-buffer))
5984 (set-buffer gnus-summary-buffer)
5985 (let ((header (gnus-summary-article-header article)))
5988 ((memq article gnus-newsgroup-sparse)
5989 ;; This is a sparse gap article.
5990 (setq do-update-line article)
5991 (setq article (mail-header-id header))
5992 (setq sparse-header (gnus-read-header article))
5993 (setq gnus-newsgroup-sparse
5994 (delq article gnus-newsgroup-sparse)))
5996 ;; It's a real article.
5997 (setq article (mail-header-id header)))
5999 ;; It is an extracted pseudo-article.
6000 (setq article 'pseudo)
6001 (gnus-request-pseudo-article header))))
6003 (let ((method (gnus-find-method-for-group
6004 gnus-newsgroup-name)))
6005 (when (and (eq (car method) 'nneething)
6007 (let ((dir (nneething-get-file-name
6008 (mail-header-id header))))
6009 (when (and (stringp dir)
6010 (file-directory-p dir))
6011 (setq article 'nneething)
6012 (gnus-group-enter-directory dir))))))))
6015 ;; Refuse to select canceled articles.
6016 ((and (numberp article)
6018 (get-buffer gnus-summary-buffer)
6019 (gnus-buffer-exists-p gnus-summary-buffer)
6020 (eq (cdr (with-current-buffer gnus-summary-buffer
6021 (assq article gnus-newsgroup-reads)))
6022 gnus-canceled-mark))
6024 ;; We first check `gnus-original-article-buffer'.
6025 ((and (get-buffer gnus-original-article-buffer)
6027 (with-current-buffer gnus-original-article-buffer
6028 (and (equal (car gnus-original-article) group)
6029 (eq (cdr gnus-original-article) article))))
6030 (insert-buffer-substring gnus-original-article-buffer)
6032 ;; Check the backlog.
6033 ((and gnus-keep-backlog
6034 (gnus-backlog-request-article group article (current-buffer)))
6036 ;; Check asynchronous pre-fetch.
6037 ((gnus-async-request-fetched-article group article (current-buffer))
6038 (gnus-async-prefetch-next group article gnus-summary-buffer)
6039 (when (and (numberp article) gnus-keep-backlog)
6040 (gnus-backlog-enter-article group article (current-buffer)))
6043 ((and gnus-use-cache
6045 (gnus-cache-request-article article group))
6047 ;; Check the agent cache.
6048 ((gnus-agent-request-article article group)
6050 ;; Get the article and put into the article buffer.
6051 ((or (stringp article)
6053 (let ((gnus-override-method gnus-override-method)
6054 (methods (and (stringp article)
6055 gnus-refer-article-method))
6056 (backend (car (gnus-find-method-for-group
6057 gnus-newsgroup-name)))
6059 (inhibit-read-only t))
6060 (if (or (not (listp methods))
6061 (and (symbolp (car methods))
6062 (assq (car methods) nnoo-definition-alist)))
6063 (setq methods (list methods)))
6064 (when (and (null gnus-override-method)
6066 (setq gnus-override-method (pop methods)))
6068 (when (eq gnus-override-method 'current)
6069 (setq gnus-override-method
6070 (with-current-buffer gnus-summary-buffer
6071 gnus-current-select-method)))
6073 (gnus-kill-all-overlays)
6074 (let ((gnus-newsgroup-name group))
6075 (gnus-check-group-server))
6077 ((gnus-request-article article group (current-buffer))
6078 (when (numberp article)
6079 (gnus-async-prefetch-next group article
6080 gnus-summary-buffer)
6081 (when gnus-keep-backlog
6082 (gnus-backlog-enter-article
6083 group article (current-buffer))))
6084 (setq result 'article))
6086 (setq gnus-override-method (pop methods)))
6087 ((not (string-match "^400 "
6088 (nnheader-get-report backend)))
6089 ;; If we get 400 server disconnect, reconnect and
6090 ;; retry; otherwise, assume the article has expired.
6091 (setq result 'done))))
6092 (and (eq result 'article) 'article)))
6096 ;; Associate this article with the current summary buffer.
6097 (setq gnus-article-current-summary gnus-summary-buffer)
6099 ;; Take the article from the original article buffer
6100 ;; and place it in the buffer it's supposed to be in.
6101 (when (and (get-buffer gnus-article-buffer)
6102 (equal (buffer-name (current-buffer))
6103 (buffer-name (get-buffer gnus-article-buffer))))
6105 (if (get-buffer gnus-original-article-buffer)
6106 (set-buffer gnus-original-article-buffer)
6107 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
6108 (buffer-disable-undo)
6109 (setq major-mode 'gnus-original-article-mode)
6110 (setq buffer-read-only t))
6111 (let ((inhibit-read-only t))
6113 (insert-buffer-substring gnus-article-buffer))
6114 (setq gnus-original-article (cons group article)))
6117 (run-hooks 'gnus-article-decode-hook)
6118 ;; Mark article as decoded or not.
6119 (setq gnus-article-decoded-p gnus-article-decode-hook))
6121 ;; Update sparse articles.
6122 (when (and do-update-line
6123 (or (numberp article)
6125 (let ((buf (current-buffer)))
6126 (set-buffer gnus-summary-buffer)
6127 (gnus-summary-update-article do-update-line sparse-header)
6128 (gnus-summary-goto-subject do-update-line nil t)
6129 (set-window-point (gnus-get-buffer-window (current-buffer) t)
6131 (set-buffer buf))))))
6137 (defcustom gnus-article-edit-mode-hook nil
6138 "Hook run in article edit mode buffers."
6139 :group 'gnus-article-various
6142 (defcustom gnus-article-edit-article-setup-function
6143 'gnus-article-mime-edit-article-setup
6144 "Function called to setup an editing article buffer."
6145 :group 'gnus-article-various
6148 (defvar gnus-article-edit-done-function nil)
6150 (defvar gnus-article-edit-mode-map nil)
6152 ;; Should we be using derived.el for this?
6153 (unless gnus-article-edit-mode-map
6154 (setq gnus-article-edit-mode-map (make-keymap))
6155 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
6157 (gnus-define-keys gnus-article-edit-mode-map
6158 "\C-c?" describe-mode
6159 "\C-c\C-c" gnus-article-edit-done
6160 "\C-c\C-k" gnus-article-edit-exit
6161 "\C-c\C-f\C-t" message-goto-to
6162 "\C-c\C-f\C-o" message-goto-from
6163 "\C-c\C-f\C-b" message-goto-bcc
6164 ;;"\C-c\C-f\C-w" message-goto-fcc
6165 "\C-c\C-f\C-c" message-goto-cc
6166 "\C-c\C-f\C-s" message-goto-subject
6167 "\C-c\C-f\C-r" message-goto-reply-to
6168 "\C-c\C-f\C-n" message-goto-newsgroups
6169 "\C-c\C-f\C-d" message-goto-distribution
6170 "\C-c\C-f\C-f" message-goto-followup-to
6171 "\C-c\C-f\C-m" message-goto-mail-followup-to
6172 "\C-c\C-f\C-k" message-goto-keywords
6173 "\C-c\C-f\C-u" message-goto-summary
6174 "\C-c\C-f\C-i" message-insert-or-toggle-importance
6175 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
6176 "\C-c\C-b" message-goto-body
6177 "\C-c\C-i" message-goto-signature
6179 "\C-c\C-t" message-insert-to
6180 "\C-c\C-n" message-insert-newsgroups
6181 "\C-c\C-o" message-sort-headers
6182 "\C-c\C-e" message-elide-region
6183 "\C-c\C-v" message-delete-not-region
6184 "\C-c\C-z" message-kill-to-signature
6185 "\M-\r" message-newline-and-reformat
6186 "\C-c\C-a" mml-attach-file
6187 "\C-a" message-beginning-of-line
6189 "\M-;" comment-region)
6191 (gnus-define-keys (gnus-article-edit-wash-map
6192 "\C-c\C-w" gnus-article-edit-mode-map)
6193 "f" gnus-article-edit-full-stops))
6196 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
6198 ["Fetch To" message-insert-to t]
6199 ["Fetch Newsgroups" message-insert-newsgroups t]
6201 ["To" message-goto-to t]
6202 ["From" message-goto-from t]
6203 ["Subject" message-goto-subject t]
6204 ["Cc" message-goto-cc t]
6205 ["Reply-To" message-goto-reply-to t]
6206 ["Summary" message-goto-summary t]
6207 ["Keywords" message-goto-keywords t]
6208 ["Newsgroups" message-goto-newsgroups t]
6209 ["Followup-To" message-goto-followup-to t]
6210 ["Mail-Followup-To" message-goto-mail-followup-to t]
6211 ["Distribution" message-goto-distribution t]
6212 ["Body" message-goto-body t]
6213 ["Signature" message-goto-signature t]))
6215 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
6216 "Major mode for editing articles.
6217 This is an extended text-mode.
6219 \\{gnus-article-edit-mode-map}"
6220 (make-local-variable 'gnus-article-edit-done-function)
6221 (make-local-variable 'gnus-prev-winconf)
6222 (set (make-local-variable 'font-lock-defaults)
6223 '(message-font-lock-keywords t))
6224 (set (make-local-variable 'mail-header-separator) "")
6225 (set (make-local-variable 'gnus-article-edit-mode) t)
6226 (easy-menu-add message-mode-field-menu message-mode-map)
6227 (setq buffer-read-only nil)
6228 (buffer-enable-undo)
6231 (defun gnus-article-edit (&optional force)
6232 "Edit the current article.
6233 This will have permanent effect only in mail groups.
6234 If FORCE is non-nil, allow editing of articles even in read-only
6237 (when (and (not force)
6238 (gnus-group-read-only-p))
6239 (error "The current newsgroup does not support article editing"))
6240 (gnus-article-date-original)
6241 (gnus-article-edit-article
6243 `(lambda (no-highlight)
6245 (gnus-summary-edit-article-done
6246 ,(or (mail-header-references gnus-current-headers) "")
6247 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
6249 (defun gnus-article-edit-article (start-func exit-func &optional quiet)
6250 "Start editing the contents of the current article buffer."
6251 (let ((winconf (current-window-configuration)))
6252 (set-buffer gnus-article-buffer)
6253 (let ((message-auto-save-directory
6254 ;; Don't associate the article buffer with a draft file.
6256 (gnus-article-edit-mode))
6257 (funcall start-func)
6258 (set-buffer-modified-p nil)
6259 (gnus-configure-windows 'edit-article)
6260 (setq gnus-article-edit-done-function exit-func)
6261 (setq gnus-prev-winconf winconf)
6262 (when gnus-article-edit-article-setup-function
6263 (funcall gnus-article-edit-article-setup-function))
6265 (gnus-message 6 "C-c C-c to end edits; C-c C-k to exit"))))
6267 (defun gnus-article-edit-done (&optional arg)
6268 "Update the article edits and exit."
6270 (let ((func gnus-article-edit-done-function)
6271 (buf (current-buffer))
6272 (start (window-start))
6274 (winconf gnus-prev-winconf))
6275 (remove-hook 'gnus-article-mode-hook
6276 'gnus-article-mime-edit-article-unwind)
6277 (widen) ;; Widen it in case that users narrowed the buffer.
6280 ;; The cache and backlog have to be flushed somewhat.
6281 (when gnus-keep-backlog
6282 (gnus-backlog-remove-article
6283 (car gnus-article-current) (cdr gnus-article-current)))
6284 ;; Flush original article as well.
6286 (when (get-buffer gnus-original-article-buffer)
6287 (set-buffer gnus-original-article-buffer)
6288 (setq gnus-original-article nil)))
6289 (when gnus-use-cache
6290 (gnus-cache-update-article
6291 (car gnus-article-current) (cdr gnus-article-current)))
6292 ;; We remove all text props from the article buffer.
6293 (kill-all-local-variables)
6294 (set-text-properties (point-min) (point-max) nil)
6296 (set-window-configuration winconf)
6298 (set-window-start (get-buffer-window buf) start)
6299 (set-window-point (get-buffer-window buf) (point)))
6300 (gnus-summary-show-article))
6302 (defun gnus-article-edit-exit ()
6303 "Exit the article editing without updating."
6305 (when (or (not (buffer-modified-p))
6306 (yes-or-no-p "Article modified; kill anyway? "))
6307 (let ((curbuf (current-buffer))
6309 (window-start (window-start)))
6311 (if (gnus-buffer-live-p gnus-original-article-buffer)
6312 (insert-buffer-substring gnus-original-article-buffer))
6313 (let ((winconf gnus-prev-winconf))
6314 (kill-all-local-variables)
6316 (set-window-configuration winconf)
6317 ;; Tippy-toe some to make sure that point remains where it was.
6318 (save-current-buffer
6320 (set-window-start (get-buffer-window (current-buffer)) window-start)
6322 (gnus-summary-show-article)))
6324 (defun gnus-article-edit-full-stops ()
6325 "Interactively repair spacing at end of sentences."
6328 (goto-char (point-min))
6329 (search-forward-regexp "^$" nil t)
6330 (let ((case-fold-search nil))
6331 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
6334 ;;; Article editing with MIME-Edit
6337 (defcustom gnus-article-mime-edit-article-setup-hook nil
6338 "Hook run after setting up a MIME editing article buffer."
6339 :group 'gnus-article-various
6342 (defun gnus-article-mime-edit-article-unwind ()
6343 "Unwind `gnus-article-buffer' if article editing was given up."
6344 (remove-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6345 (when (featurep 'font-lock)
6346 (setq font-lock-defaults nil)
6347 (font-lock-mode -1))
6348 (when mime-edit-mode-flag
6349 (mime-edit-exit 'nomime 'no-error)
6352 (defun gnus-article-mime-edit-article-setup ()
6353 "Convert current buffer to MIME-Edit buffer and turn on MIME-Edit mode
6354 after replacing with the original article."
6355 (setq gnus-show-mime t)
6356 (setq gnus-article-edit-done-function
6357 `(lambda (&rest args)
6358 (when mime-edit-mode-flag
6359 (let (mime-edit-insert-user-agent-field)
6362 (goto-char (point-min))
6363 (let (case-fold-search)
6364 (when (re-search-forward
6365 (format "^%s$" (regexp-quote mail-header-separator))
6367 (replace-match "")))
6368 (apply ,gnus-article-edit-done-function args)
6371 (buffer-substring-no-properties (point-min) (point-max))
6372 (set-buffer (get-buffer-create gnus-original-article-buffer))
6374 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6375 (set-buffer gnus-article-buffer)
6376 (gnus-article-prepare-display)))
6377 (substitute-key-definition 'gnus-article-edit-done
6378 'gnus-article-mime-edit-done
6379 gnus-article-edit-mode-map)
6380 (substitute-key-definition 'gnus-article-edit-exit
6381 'gnus-article-mime-edit-exit
6382 gnus-article-edit-mode-map)
6384 (insert-buffer-substring gnus-original-article-buffer)
6385 (unless (member (with-current-buffer gnus-summary-buffer
6386 gnus-newsgroup-name)
6387 '("nndraft:delayed" "nndraft:drafts"))
6388 (let ((ofn (symbol-function 'mime-edit-decode-single-part-in-buffer)))
6389 (fset 'mime-edit-decode-single-part-in-buffer
6390 (lambda (&rest args)
6391 (if (let ((content-type (car args)))
6392 (and (eq 'message (mime-content-type-primary-type
6394 (eq 'rfc822 (mime-content-type-subtype
6396 (setcar (cdr args) 'not-decode-text))
6400 (fset 'mime-edit-decode-single-part-in-buffer ofn))))
6401 (when (featurep 'font-lock)
6402 (set (make-local-variable 'font-lock-defaults)
6403 '(message-font-lock-keywords t))
6404 (font-lock-set-defaults)
6405 (turn-on-font-lock))
6406 (set-buffer-modified-p nil)
6407 (delete-other-windows)
6408 (add-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6409 (gnus-run-hooks 'gnus-article-mime-edit-article-setup-hook))
6411 (defun gnus-article-mime-edit-done (&optional arg)
6412 "Update the article MIME edits and exit."
6414 (when (featurep 'font-lock)
6415 (setq font-lock-defaults nil)
6416 (font-lock-mode -1))
6417 (let ((inhibit-read-only t))
6418 (gnus-article-edit-done arg)))
6420 (defun gnus-article-mime-edit-exit ()
6421 "Exit the article MIME editing without updating."
6423 (when (or (not (buffer-modified-p))
6424 (yes-or-no-p "Article modified; kill anyway? "))
6425 (when (featurep 'font-lock)
6426 (setq font-lock-defaults nil)
6427 (font-lock-mode -1))
6428 (when mime-edit-mode-flag
6429 (let (mime-edit-insert-user-agent-field)
6432 (goto-char (point-min))
6433 (let (case-fold-search)
6434 (when (re-search-forward
6435 (format "^%s$" (regexp-quote mail-header-separator)) nil t)
6436 (replace-match "")))
6437 (let ((winconf gnus-prev-winconf))
6439 (buffer-substring-no-properties (point-min) (point-max))
6440 (set-buffer (get-buffer-create gnus-original-article-buffer))
6442 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6443 (set-buffer gnus-article-buffer)
6444 (gnus-article-prepare-display)
6445 (set-window-configuration winconf))))
6448 ;;; Article highlights
6451 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
6453 ;;; Internal Variables:
6455 (defcustom gnus-button-url-regexp
6456 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
6457 "\\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:]]\\)"
6458 "\\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\\)\\)")
6459 "Regular expression that matches URLs."
6460 :group 'gnus-article-buttons
6463 (defcustom gnus-button-valid-fqdn-regexp
6464 message-valid-fqdn-regexp
6465 "Regular expression that matches a valid FQDN."
6467 :group 'gnus-article-buttons
6470 ;; Regexp suggested by Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
6471 (defcustom gnus-button-valid-localpart-regexp
6472 "[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t ]*"
6473 "Regular expression that matches a localpart of mail addresses or MIDs."
6475 :group 'gnus-article-buttons
6478 (defcustom gnus-button-man-handler 'manual-entry
6479 "Function to use for displaying man pages.
6480 The function must take at least one argument with a string naming the
6483 :type '(choice (function-item :tag "Man" manual-entry)
6484 (function-item :tag "Woman" woman)
6485 (function :tag "Other"))
6486 :group 'gnus-article-buttons)
6488 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
6489 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
6490 If the default site is too slow, try to find a CTAN mirror, see
6491 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
6492 the variable `gnus-button-handle-ctan'."
6494 :group 'gnus-article-buttons
6495 :link '(custom-manual "(gnus)Group Parameters")
6496 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
6497 (const "http://tug.ctan.org/tex-archive/")
6498 (const "http://www.dante.de/CTAN/")
6499 (string :tag "Other")))
6501 (defcustom gnus-button-ctan-handler 'browse-url
6502 "Function to use for displaying CTAN links.
6503 The function must take one argument, the string naming the URL."
6505 :type '(choice (function-item :tag "Browse Url" browse-url)
6506 (function :tag "Other"))
6507 :group 'gnus-article-buttons)
6509 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
6510 "Bogus strings removed from CTAN URLs."
6512 :group 'gnus-article-buttons
6513 :type '(choice (const "^/?tex-archive/\\|/")
6514 (regexp :tag "Other")))
6516 (defcustom gnus-button-ctan-directory-regexp
6518 (list "archive-tools" "biblio" "bibliography" "digests" "documentation"
6519 "dviware" "fonts" "graphics" "help" "indexing" "info" "language"
6520 "languages" "macros" "nonfree" "obsolete" "support" "systems"
6521 "tds" "tools" "usergrps" "web") t)
6522 "Regular expression for ctan directories.
6523 It should match all directories in the top level of `gnus-ctan-url'."
6525 :group 'gnus-article-buttons
6528 (defcustom gnus-button-mid-or-mail-regexp
6529 (concat "\\b\\(<?" gnus-button-valid-localpart-regexp "@"
6530 gnus-button-valid-fqdn-regexp
6532 "Regular expression that matches a message ID or a mail address."
6534 :group 'gnus-article-buttons
6537 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
6538 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
6539 Strings like this can be either a message ID or a mail address. If it is one
6540 of the symbols `mid' or `mail', Gnus will always assume that the string is a
6541 message ID or a mail address, respectively. If this variable is set to the
6542 symbol `ask', always query the user what do do. If it is a function, this
6543 function will be called with the string as it's only argument. The function
6544 must return `mid', `mail', `invalid' or `ask'."
6546 :group 'gnus-article-buttons
6547 :type '(choice (function-item :tag "Heuristic function"
6548 gnus-button-mid-or-mail-heuristic)
6553 (defcustom gnus-button-mid-or-mail-heuristic-alist
6554 '((-10.0 . ".+\\$.+@")
6557 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
6558 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
6559 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
6560 (-1.0 . "^[^a-z]+@")
6562 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
6563 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
6564 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
6565 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
6568 (-1.0 . "^[0-9][0-9]")
6570 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
6571 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6572 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
6573 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6575 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
6576 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
6579 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
6581 ;; compensation for TDMA dated mail addresses:
6582 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
6584 (-20.0 . "\\.fsf@") ;; Gnus
6587 (-20.0 . "_-_") ;; Subject change in thread
6589 (-20.0 . "\\.ln@") ;; leafnode
6590 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
6591 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
6593 ;; (5.0 . "") ;; $local_part_len <= 7
6594 (10.0 . "^[^0-9]+@")
6595 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
6596 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
6599 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
6601 (0.5 . "^[A-Z][a-z]")
6602 (0.5 . "^[A-Z][a-z][a-z]")
6603 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
6604 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
6605 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
6607 A negative RATE indicates a message IDs, whereas a positive indicates a mail
6608 address. The REGEXP is processed with `case-fold-search' set to nil."
6610 :group 'gnus-article-buttons
6611 :type '(repeat (cons (number :tag "Rate")
6612 (regexp :tag "Regexp"))))
6614 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
6615 "Guess whether MID-OR-MAIL is a message ID or a mail address.
6616 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
6617 address, `ask' if unsure and `invalid' if the string is invalid."
6618 (let ((case-fold-search nil)
6619 (list gnus-button-mid-or-mail-heuristic-alist)
6620 (result 0) rate regexp lpartlen elem)
6622 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
6623 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
6624 ;; Certain special cases...
6627 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
6628 "^[0-9]+\\.[0-9]+@compuserve\\|"
6629 "@public\\.gmane\\.org")
6631 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
6632 (setq result 'mail))
6633 (when (string-match "@.*@\\| " mid-or-mail)
6634 (gnus-message 8 "`%s' is invalid." mid-or-mail)
6635 (setq result 'invalid))
6636 ;; Nothing more to do, if result is not a number here...
6637 (when (numberp result)
6639 (setq elem (car list)
6643 (when (string-match regexp mid-or-mail)
6644 (setq result (+ result rate))
6646 9 "`%s' matched `%s', rate `%s', result `%s'."
6647 mid-or-mail regexp rate result)))
6648 (when (<= lpartlen 7)
6649 (setq result (+ result 5.0))
6650 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
6651 mid-or-mail result))
6652 (when (>= lpartlen 12)
6653 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
6655 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
6656 ;; Long local part should contain realname if e-mail address,
6657 ;; too many digits: message-id.
6658 ;; $score -= 5.0 + 0.1 * $local_part_len;
6659 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6660 (setq result (+ result rate))
6662 9 "Many digits in `%s', rate `%s', result `%s'."
6663 mid-or-mail rate result))
6664 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6666 ;; Too few vowels [^aeiouy]{4,}.*\@
6667 (setq result (+ result -5.0))
6669 9 "Few vowels in `%s', rate `%s', result `%s'."
6670 mid-or-mail -5.0 result))
6672 (setq result (+ result 5.0))
6674 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6675 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6676 ;; Maybe we should make this a customizable alist: (condition . 'result)
6678 ((symbolp result) result)
6679 ;; Now convert number into proper results:
6680 ((< result -10.0) 'mid)
6681 ((> result 10.0) 'mail)
6684 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6685 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6686 (url-mid (concat "news" ":" mid-or-mail))
6687 (url-mailto (concat "mailto" ":" mid-or-mail)))
6688 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6689 (when (fboundp pref)
6691 ;; get rid of surrounding angles...
6693 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6694 (if (or (eq 'mid guessed) (eq 'mail guessed))
6698 (save-window-excursion
6699 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6702 (cond ((eq pref 'mid)
6703 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6704 (gnus-button-handle-news url-mid))
6706 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6707 (gnus-url-mailto url-mailto))
6708 (t (gnus-message 3 "Invalid string.")))))
6710 (defun gnus-button-handle-custom (url)
6711 "Follow a Custom URL."
6712 (customize-apropos (gnus-url-unhex-string url)))
6714 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6716 ;; FIXME: Maybe we should merge some of the functions that do quite similar
6719 (defun gnus-button-handle-describe-function (url)
6720 "Call `describe-function' when pushing the corresponding URL button."
6723 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6725 (defun gnus-button-handle-describe-variable (url)
6726 "Call `describe-variable' when pushing the corresponding URL button."
6729 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6731 (defun gnus-button-handle-symbol (url)
6732 "Display help on variable or function.
6733 Calls `describe-variable' or `describe-function'."
6734 (let ((sym (intern url)))
6736 ((fboundp sym) (describe-function sym))
6737 ((boundp sym) (describe-variable sym))
6738 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
6740 (defun gnus-button-handle-describe-key (url)
6741 "Call `describe-key' when pushing the corresponding URL button."
6743 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6744 (keys (ignore-errors (eval `(kbd ,key-string)))))
6747 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6749 (defun gnus-button-handle-apropos (url)
6750 "Call `apropos' when pushing the corresponding URL button."
6751 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6753 (defun gnus-button-handle-apropos-command (url)
6754 "Call `apropos' when pushing the corresponding URL button."
6756 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6758 (defun gnus-button-handle-apropos-variable (url)
6759 "Call `apropos' when pushing the corresponding URL button."
6761 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6762 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6764 (defun gnus-button-handle-apropos-documentation (url)
6765 "Call `apropos' when pushing the corresponding URL button."
6767 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6768 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6770 (defun gnus-button-handle-library (url)
6771 "Call `locate-library' when pushing the corresponding URL button."
6772 (gnus-message 9 "url=`%s'" url)
6773 (let* ((lib (locate-library url))
6774 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6776 (gnus-message 1 "Cannot locale library `%s'." url)
6777 (find-file-read-only file))))
6779 (defun gnus-button-handle-ctan (url)
6780 "Call `browse-url' when pushing a CTAN URL button."
6782 gnus-button-ctan-handler
6785 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6787 (defcustom gnus-button-tex-level 5
6788 "*Integer that says how many TeX-related buttons Gnus will show.
6789 The higher the number, the more buttons will appear and the more false
6790 positives are possible. Note that you can set this variable local to
6791 specific groups. Setting it higher in TeX groups is probably a good idea.
6792 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6793 how to set variables in specific groups."
6795 :group 'gnus-article-buttons
6796 :link '(custom-manual "(gnus)Group Parameters")
6799 (defcustom gnus-button-man-level 5
6800 "*Integer that says how many man-related buttons Gnus will show.
6801 The higher the number, the more buttons will appear and the more false
6802 positives are possible. Note that you can set this variable local to
6803 specific groups. Setting it higher in Unix groups is probably a good idea.
6804 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6805 how to set variables in specific groups."
6807 :group 'gnus-article-buttons
6808 :link '(custom-manual "(gnus)Group Parameters")
6811 (defcustom gnus-button-emacs-level 5
6812 "*Integer that says how many emacs-related buttons Gnus will show.
6813 The higher the number, the more buttons will appear and the more false
6814 positives are possible. Note that you can set this variable local to
6815 specific groups. Setting it higher in Emacs or Gnus related groups is
6816 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6817 `gnus-parameters' on how to set variables in specific groups."
6819 :group 'gnus-article-buttons
6820 :link '(custom-manual "(gnus)Group Parameters")
6823 (defcustom gnus-button-message-level 5
6824 "*Integer that says how many buttons for news or mail messages will appear.
6825 The higher the number, the more buttons will appear and the more false
6826 positives are possible."
6827 ;; mail addresses, MIDs, URLs for news, ...
6829 :group 'gnus-article-buttons
6832 (defcustom gnus-button-browse-level 5
6833 "*Integer that says how many buttons for browsing will appear.
6834 The higher the number, the more buttons will appear and the more false
6835 positives are possible."
6836 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6838 :group 'gnus-article-buttons
6841 (defcustom gnus-button-alist
6842 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6843 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6844 ((concat "\\b\\(nntp\\|news\\):\\("
6845 gnus-button-valid-localpart-regexp "@[a-z0-9.-]+[a-z]\\)")
6846 0 t gnus-button-handle-news 2)
6847 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6848 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6849 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6850 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6851 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
6852 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
6853 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
6854 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6855 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6856 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6857 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6858 ;; RFC 2368 (The mailto URL scheme)
6859 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6860 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6861 ("\\bmailto:\\([^ \n\t]+\\)"
6862 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6864 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6865 gnus-button-ctan-directory-regexp
6866 "[^][>)!;:,'\n\t ]+\\)")
6867 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6868 ((concat "\\btex-archive/\\("
6869 gnus-button-ctan-directory-regexp
6870 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6871 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6874 gnus-button-ctan-directory-regexp
6875 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6876 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6877 ;; This is info (home-grown style) <info://foo/bar+baz>
6878 ("\\binfo://\\([^'\">\n\t ]+\\)"
6879 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6880 ;; Info GNOME style <info:foo#bar_baz>
6881 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6882 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6883 ;; Info KDE style <info:(foo)bar baz>
6884 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6885 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6886 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6887 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6888 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6889 ;; Info links like `C-h i d m CC Mode RET'
6890 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6892 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6893 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6894 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6895 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6896 ;; Emacs help commands
6897 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6898 ;; regexp doesn't match arguments containing ` '.
6899 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6900 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6901 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6902 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6903 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6904 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6905 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6906 ;; The following entries may lead to many false positives so don't enable
6907 ;; them by default (use a high button level).
6908 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
6909 ;; Exclude [.?] for URLs in gmane.emacs.cvs
6910 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6911 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6912 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6913 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6914 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6915 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6916 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6917 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6918 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6919 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6920 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
6921 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6922 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6923 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6924 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6925 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6926 ;; Unlike the other regexps we really have to require quoting
6927 ;; here to determine where it ends.
6928 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6929 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
6930 ("<URL: *\\([^<>]*\\)>"
6931 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6932 ;; RFC 2396 (2.4.3., delims) ...
6933 ("\"URL: *\\([^\"]*\\)\""
6934 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6935 ;; RFC 2396 (2.4.3., delims) ...
6936 ("\"URL: *\\([^\"]*\\)\""
6937 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6939 (gnus-button-url-regexp
6940 0 (>= gnus-button-browse-level 0) browse-url 0)
6942 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
6943 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6944 gnus-button-handle-man 1)
6945 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6946 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
6947 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6948 gnus-button-handle-man 1)
6949 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6950 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6951 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
6952 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6953 ;; MID or mail: To avoid too many false positives we don't try to catch
6954 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6955 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6956 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6957 ;; so that non-ambiguous entries (see above) match first.
6958 (gnus-button-mid-or-mail-regexp
6959 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6960 "*Alist of regexps matching buttons in article bodies.
6962 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6963 REGEXP: is the string (case insensitive) matching text around the button (can
6964 also be Lisp expression evaluating to a string),
6965 BUTTON: is the number of the regexp grouping actually matching the button,
6966 FORM: is a Lisp expression which must eval to true for the button to
6968 CALLBACK: is the function to call when the user push this button, and each
6969 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6971 CALLBACK can also be a variable, in that case the value of that
6972 variable it the real callback function."
6973 :group 'gnus-article-buttons
6974 :type '(repeat (list (choice regexp variable sexp)
6975 (integer :tag "Button")
6977 (function :tag "Callback")
6980 (integer :tag "Regexp group")))))
6982 (defcustom gnus-header-button-alist
6983 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
6984 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6985 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6986 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6987 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6988 0 (>= gnus-button-message-level 0) gnus-msg-mail 0)
6989 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6990 0 (>= gnus-button-browse-level 0) browse-url 0)
6991 ("^Subject:" gnus-button-url-regexp
6992 0 (>= gnus-button-browse-level 0) browse-url 0)
6993 ("^[^:]+:" gnus-button-url-regexp
6994 0 (>= gnus-button-browse-level 0) browse-url 0)
6995 ("^OpenPGP:.*url=" gnus-button-url-regexp
6996 0 (>= gnus-button-browse-level 0) gnus-button-openpgp 0)
6997 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6998 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6999 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
7000 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
7001 "*Alist of headers and regexps to match buttons in article heads.
7003 This alist is very similar to `gnus-button-alist', except that each
7004 alist has an additional HEADER element first in each entry:
7006 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
7008 HEADER is a regexp to match a header. For a fuller explanation, see
7009 `gnus-button-alist'."
7010 :group 'gnus-article-buttons
7011 :group 'gnus-article-headers
7012 :type '(repeat (list (regexp :tag "Header")
7013 (choice regexp variable)
7014 (integer :tag "Button")
7016 (function :tag "Callback")
7019 (integer :tag "Regexp group")))))
7023 (defun gnus-article-push-button (event)
7024 "Check text under the mouse pointer for a callback function.
7025 If the text under the mouse pointer has a `gnus-callback' property,
7026 call it with the value of the `gnus-data' text property."
7028 (set-buffer (window-buffer (posn-window (event-start event))))
7029 (let* ((pos (posn-point (event-start event)))
7030 (data (get-text-property pos 'gnus-data))
7031 (fun (get-text-property pos 'gnus-callback)))
7034 (funcall fun data))))
7036 (defun gnus-article-press-button ()
7037 "Check text at point for a callback function.
7038 If the text at point has a `gnus-callback' property,
7039 call it with the value of the `gnus-data' text property."
7041 (let ((data (get-text-property (point) 'gnus-data))
7042 (fun (get-text-property (point) 'gnus-callback)))
7044 (funcall fun data))))
7046 (defun gnus-article-prev-button (n)
7047 "Move point to N buttons backward.
7048 If N is negative, move forward instead."
7050 (gnus-article-next-button (- n)))
7052 (defun gnus-article-next-button (n)
7053 "Move point to N buttons forward.
7054 If N is negative, move backward instead."
7056 (let ((function (if (< n 0) 'previous-single-property-change
7057 'next-single-property-change))
7058 (inhibit-point-motion-hooks t)
7060 (limit (if (< n 0) (point-min) (point-max))))
7062 (while (and (not (= limit (point)))
7064 ;; Skip past the current button.
7065 (when (get-text-property (point) 'gnus-callback)
7066 (goto-char (funcall function (point) 'gnus-callback nil limit)))
7067 ;; Go to the next (or previous) button.
7068 (gnus-goto-char (funcall function (point) 'gnus-callback nil limit))
7069 ;; Put point at the start of the button.
7070 (when (and backward (not (get-text-property (point) 'gnus-callback)))
7071 (goto-char (funcall function (point) 'gnus-callback nil limit)))
7072 ;; Skip past intangible buttons.
7073 (when (get-text-property (point) 'intangible)
7077 (gnus-message 5 "No more buttons"))
7080 (defun gnus-article-highlight (&optional force)
7081 "Highlight current article.
7082 This function calls `gnus-article-highlight-headers',
7083 `gnus-article-highlight-citation',
7084 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
7085 do the highlighting. See the documentation for those functions."
7086 (interactive (list 'force))
7087 (gnus-article-highlight-headers)
7088 (gnus-article-highlight-citation force)
7089 (gnus-article-highlight-signature)
7090 (gnus-article-add-buttons force)
7091 (gnus-article-add-buttons-to-head))
7093 (defun gnus-article-highlight-some (&optional force)
7094 "Highlight current article.
7095 This function calls `gnus-article-highlight-headers',
7096 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
7097 do the highlighting. See the documentation for those functions."
7098 (interactive (list 'force))
7099 (gnus-article-highlight-headers)
7100 (gnus-article-highlight-signature)
7101 (gnus-article-add-buttons))
7103 (defun gnus-article-highlight-headers ()
7104 "Highlight article headers as specified by `gnus-header-face-alist'."
7106 (gnus-with-article-headers
7107 (let (regexp header-face field-face from hpoints fpoints)
7108 (dolist (entry gnus-header-face-alist)
7109 (goto-char (point-min))
7110 (setq regexp (concat "^\\("
7111 (if (string-equal "" (nth 0 entry))
7115 header-face (nth 1 entry)
7116 field-face (nth 2 entry))
7117 (while (and (re-search-forward regexp nil t)
7121 (unless (search-forward ":" nil t)
7123 (when (and header-face
7124 (not (memq (point) hpoints)))
7125 (push (point) hpoints)
7126 (gnus-put-text-property from (point) 'face header-face))
7127 (when (and field-face
7128 (not (memq (setq from (point)) fpoints)))
7130 (if (re-search-forward "^[^ \t]" nil t)
7132 (goto-char (point-max)))
7133 (gnus-put-text-property from (point) 'face field-face)))))))
7135 (defun gnus-article-highlight-signature ()
7136 "Highlight the signature in an article.
7137 It does this by highlighting everything after
7138 `gnus-signature-separator' using the face `gnus-signature'."
7140 (when gnus-signature-face
7141 (gnus-with-article-buffer
7142 (let ((inhibit-point-motion-hooks t))
7144 (when (gnus-article-narrow-to-signature)
7145 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
7146 'face gnus-signature-face)))))))
7148 (defun gnus-article-buttonize-signature ()
7149 "Add button to the signature."
7152 (set-buffer gnus-article-buffer)
7153 (let ((inhibit-read-only t)
7154 (inhibit-point-motion-hooks t))
7155 (when (gnus-article-search-signature)
7156 (gnus-article-add-button (match-beginning 0) (match-end 0)
7157 'gnus-signature-toggle
7158 (set-marker (make-marker)
7159 (1+ (match-end 0))))))))
7161 (defun gnus-button-in-region-p (b e prop)
7162 "Say whether PROP exists in the region."
7163 (text-property-not-all b e prop nil))
7165 (defun gnus-article-add-buttons (&optional force)
7166 "Find external references in the article and make buttons of them.
7167 \"External references\" are things like Message-IDs and URLs, as
7168 specified by `gnus-button-alist'."
7169 (interactive (list 'force))
7170 (gnus-with-article-buffer
7171 (let ((inhibit-point-motion-hooks t)
7172 (case-fold-search t)
7173 (alist gnus-button-alist)
7175 ;; Remove all old markers.
7176 (let (marker entry new-list)
7177 (while (setq marker (pop gnus-button-marker-list))
7178 (if (or (< marker (point-min)) (>= marker (point-max)))
7179 (push marker new-list)
7181 (when (setq entry (gnus-button-entry))
7182 (put-text-property (match-beginning (nth 1 entry))
7183 (match-end (nth 1 entry))
7184 'gnus-callback nil))
7185 (set-marker marker nil)))
7186 (setq gnus-button-marker-list new-list))
7187 ;; We skip the headers.
7190 (while (setq entry (pop alist))
7191 (setq regexp (eval (car entry)))
7193 (while (re-search-forward regexp nil t)
7194 (let* ((start (and entry (match-beginning (nth 1 entry))))
7195 (end (and entry (match-end (nth 1 entry))))
7196 (from (match-beginning 0)))
7197 (when (and (or (eq t (nth 2 entry))
7198 (eval (nth 2 entry)))
7199 (not (gnus-button-in-region-p
7200 start end 'gnus-callback)))
7201 ;; That optional form returned non-nil, so we add the
7203 (gnus-article-add-button
7204 start end 'gnus-button-push
7205 (car (push (set-marker (make-marker) from)
7206 gnus-button-marker-list))))))))))
7208 ;; Add buttons to the head of an article.
7209 (defun gnus-article-add-buttons-to-head ()
7210 "Add buttons to the head of the article."
7212 (gnus-with-article-headers
7214 (dolist (entry gnus-header-button-alist)
7215 ;; Each alist entry.
7216 (goto-char (point-min))
7217 (while (re-search-forward (car entry) nil t)
7218 ;; Each header matching the entry.
7219 (setq beg (match-beginning 0))
7220 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
7221 (match-beginning 0))
7224 (while (re-search-forward (eval (nth 1 entry)) end t)
7225 ;; Each match within a header.
7226 (let* ((entry (cdr entry))
7227 (start (match-beginning (nth 1 entry)))
7228 (end (match-end (nth 1 entry)))
7229 (form (nth 2 entry)))
7230 (goto-char (match-end 0))
7232 (gnus-article-add-button
7233 start end (nth 3 entry)
7234 (buffer-substring (match-beginning (nth 4 entry))
7235 (match-end (nth 4 entry)))))))
7236 (goto-char end))))))
7238 ;;; External functions:
7240 (defun gnus-article-add-button (from to fun &optional data)
7241 "Create a button between FROM and TO with callback FUN and data DATA."
7242 (when gnus-article-button-face
7243 (gnus-overlay-put (gnus-make-overlay from to)
7244 'face gnus-article-button-face))
7245 (gnus-add-text-properties
7247 (nconc (and gnus-article-mouse-face
7248 (list gnus-mouse-face-prop gnus-article-mouse-face))
7249 (list 'gnus-callback fun)
7250 (and data (list 'gnus-data data))))
7251 (widget-convert-button 'link from to :action 'gnus-widget-press-button
7252 :button-keymap gnus-widget-button-keymap))
7254 ;;; Internal functions:
7256 (defun gnus-article-set-globals ()
7257 (with-current-buffer gnus-summary-buffer
7258 (gnus-set-global-variables)))
7260 (defun gnus-signature-toggle (end)
7261 (gnus-with-article-buffer
7262 (let ((inhibit-point-motion-hooks t)
7263 (limit (next-single-property-change end 'mime-view-entity
7265 (if (text-property-any end limit 'article-type 'signature)
7267 (gnus-delete-wash-type 'signature)
7268 (gnus-remove-text-properties-when
7269 'article-type 'signature end limit
7270 (cons 'article-type (cons 'signature
7271 gnus-hidden-properties))))
7272 (gnus-add-wash-type 'signature)
7273 (gnus-add-text-properties-when
7274 'article-type nil end limit
7275 (cons 'article-type (cons 'signature
7276 gnus-hidden-properties)))))
7277 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
7278 (gnus-set-mode-line 'article))))
7280 (defun gnus-button-entry ()
7281 ;; Return the first entry in `gnus-button-alist' matching this place.
7282 (let ((alist gnus-button-alist)
7285 (setq entry (pop alist))
7286 (if (looking-at (eval (car entry)))
7291 (defun gnus-button-push (marker)
7292 ;; Push button starting at MARKER.
7295 (let* ((entry (gnus-button-entry))
7296 (inhibit-point-motion-hooks t)
7298 (args (mapcar (lambda (group)
7299 (let ((string (match-string group)))
7300 (set-text-properties
7301 0 (length string) nil string)
7308 (fboundp (symbol-value fun)))
7309 (apply (symbol-value fun) args))
7311 (gnus-message 1 "You must define `%S' to use this button"
7312 (cons fun args)))))))
7314 (defun gnus-parse-news-url (url)
7315 (let (scheme server port group message-id articles)
7318 (goto-char (point-min))
7319 (when (looking-at "\\([A-Za-z]+\\):")
7320 (setq scheme (match-string 1))
7321 (goto-char (match-end 0)))
7322 (when (looking-at "//\\([^:/]+\\)\\(:?\\)\\([0-9]+\\)?/")
7323 (setq server (match-string 1))
7324 (setq port (if (stringp (match-string 3))
7325 (string-to-number (match-string 3))
7327 (goto-char (match-end 0)))
7330 ((looking-at "\\(.*@.*\\)")
7331 (setq message-id (match-string 1)))
7332 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
7333 (setq group (match-string 1)
7334 articles (split-string (match-string 2) "-")))
7335 ((looking-at "\\([^/]+\\)/?")
7336 (setq group (match-string 1)))
7338 (error "Unknown news URL syntax"))))
7339 (list scheme server port group message-id articles)))
7341 (defun gnus-button-handle-news (url)
7343 (destructuring-bind (scheme server port group message-id articles)
7344 (gnus-parse-news-url url)
7348 (set-buffer gnus-summary-buffer)
7350 (let ((gnus-refer-article-method
7351 (nconc (list (list 'nntp server))
7352 gnus-refer-article-method))
7353 (nntp-port-number (or port "nntp")))
7354 (gnus-message 7 "Fetching %s with %s"
7355 message-id gnus-refer-article-method)
7356 (gnus-summary-refer-article message-id))
7357 (gnus-summary-refer-article message-id))))
7359 (gnus-button-fetch-group url)))))
7361 (defun gnus-button-handle-man (url)
7363 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7364 (when (eq gnus-button-man-handler 'woman)
7365 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
7366 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7367 (funcall gnus-button-man-handler url))
7369 (defun gnus-button-handle-info-url (url)
7370 "Fetch an info URL."
7371 (setq url (mm-subst-char-in-string ?+ ?\ url))
7373 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
7374 (gnus-info-find-node
7375 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
7377 ")" (gnus-url-unhex-string (match-string 2 url)))))
7378 ((string-match "([^)\"]+)[^\"]+" url)
7380 (gnus-replace-in-string
7381 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
7382 (gnus-info-find-node url))
7383 (t (error "Can't parse %s" url))))
7385 (defun gnus-button-handle-info-url-gnome (url)
7386 "Fetch GNOME style info URL."
7387 (setq url (mm-subst-char-in-string ?_ ?\ url))
7388 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
7389 (gnus-info-find-node
7391 (gnus-url-unhex-string
7392 (match-string 1 url))
7394 (or (gnus-url-unhex-string
7395 (match-string 2 url))
7397 (error "Can't parse %s" url)))
7399 (defun gnus-button-handle-info-url-kde (url)
7400 "Fetch KDE style info URL."
7401 (gnus-info-find-node (gnus-url-unhex-string url)))
7403 (defun gnus-button-handle-info-keystrokes (url)
7404 "Call `info' when pushing the corresponding URL button."
7405 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
7410 (defun gnus-button-openpgp (url)
7411 "Retrieve and add an OpenPGP key given URL from an OpenPGP header."
7413 (mm-url-insert-file-contents-external url)
7414 (pgg-snarf-keys-region (point-min) (point-max))
7415 (pgg-display-output-buffer nil nil nil)))
7417 (defun gnus-button-message-id (message-id)
7419 (with-current-buffer gnus-summary-buffer
7420 (gnus-summary-refer-article message-id)))
7422 (defun gnus-button-fetch-group (address)
7423 "Fetch GROUP specified by ADDRESS."
7424 (if (not (string-match "[:/]" address))
7425 ;; This is just a simple group url.
7426 (gnus-group-read-ephemeral-group address gnus-select-method)
7429 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
7431 (error "Can't parse %s" address)
7432 (gnus-group-read-ephemeral-group
7433 (match-string 4 address)
7434 `(nntp ,(match-string 1 address)
7435 (nntp-address ,(match-string 1 address))
7436 (nntp-port-number ,(if (match-end 3)
7437 (match-string 3 address)
7440 (and (match-end 6) (list (string-to-number (match-string 6 address))))))))
7442 (defun gnus-url-parse-query-string (query &optional downcase)
7443 (let (retval pairs cur key val)
7444 (setq pairs (split-string query "&"))
7446 (setq cur (car pairs)
7448 (if (not (string-match "=" cur))
7450 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
7451 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
7453 (setq key (downcase key)))
7454 (setq cur (assoc key retval))
7456 (setcdr cur (cons val (cdr cur)))
7457 (setq retval (cons (list key val) retval)))))
7460 (defun gnus-url-mailto (url)
7461 ;; Send mail to someone
7462 (when (string-match "mailto:/*\\(.*\\)" url)
7463 (setq url (substring url (match-beginning 1) nil)))
7464 (let (to args subject func)
7465 (setq args (gnus-url-parse-query-string
7466 (if (string-match "^\\?" url)
7468 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
7469 (concat "to=" (match-string 1 url) "&"
7470 (match-string 2 url))
7471 (concat "to=" url)))
7473 subject (cdr-safe (assoc "subject" args)))
7476 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
7479 (message-position-on-field (caar args)))
7480 (insert (gnus-replace-in-string
7481 (mapconcat 'identity (reverse (cdar args)) ", ")
7483 (setq args (cdr args)))
7486 (message-goto-subject))))
7488 (defun gnus-button-embedded-url (address)
7489 "Activate ADDRESS with `browse-url'."
7490 (browse-url (gnus-strip-whitespace address)))
7492 ;;; Next/prev buttons in the article buffer.
7494 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
7495 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
7497 (defvar gnus-prev-page-map
7498 (let ((map (make-sparse-keymap)))
7499 (define-key map gnus-mouse-2 'gnus-button-prev-page)
7500 (define-key map "\r" 'gnus-button-prev-page)
7503 (defvar gnus-next-page-map
7504 (let ((map (make-sparse-keymap)))
7505 (unless (>= emacs-major-version 21)
7506 ;; XEmacs doesn't care.
7507 (set-keymap-parent map gnus-article-mode-map))
7508 (define-key map gnus-mouse-2 'gnus-button-next-page)
7509 (define-key map "\r" 'gnus-button-next-page)
7512 (defun gnus-insert-prev-page-button ()
7514 (inhibit-read-only t)
7515 (situation (get-text-property (point-min) 'mime-view-situation)))
7517 gnus-prev-page-line-format nil
7518 `(keymap ,gnus-prev-page-map
7520 gnus-callback gnus-article-button-prev-page
7521 article-type annotation
7522 mime-view-situation ,situation))
7523 (widget-convert-button
7525 ;; Exclude a newline.
7528 :action 'gnus-button-prev-page
7529 :button-keymap gnus-prev-page-map)))
7531 (defun gnus-button-next-page (&optional args more-args)
7532 "Go to the next page."
7534 (let ((win (selected-window)))
7535 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7536 (gnus-article-next-page)
7537 (select-window win)))
7539 (defun gnus-button-prev-page (&optional args more-args)
7540 "Go to the prev page."
7542 (let ((win (selected-window)))
7543 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7544 (gnus-article-prev-page)
7545 (select-window win)))
7547 (defun gnus-insert-next-page-button ()
7549 (inhibit-read-only t)
7550 (situation (get-text-property (point-min) 'mime-view-situation)))
7551 (gnus-eval-format gnus-next-page-line-format nil
7552 `(keymap ,gnus-next-page-map
7554 gnus-callback gnus-article-button-next-page
7555 article-type annotation
7556 mime-view-situation ,situation))
7557 (widget-convert-button
7559 ;; Exclude a newline.
7562 :action 'gnus-button-next-page
7563 :button-keymap gnus-next-page-map)))
7565 (defun gnus-article-button-next-page (arg)
7566 "Go to the next page."
7568 (let ((win (selected-window)))
7569 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7570 (gnus-article-next-page)
7571 (select-window win)))
7573 (defun gnus-article-button-prev-page (arg)
7574 "Go to the prev page."
7576 (let ((win (selected-window)))
7577 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7578 (gnus-article-prev-page)
7579 (select-window win)))
7581 (defvar gnus-decode-header-methods
7582 '(mail-decode-encoded-word-region)
7583 "List of methods used to decode headers.
7585 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
7586 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
7587 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
7588 whose names match REGEXP.
7591 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
7592 mail-decode-encoded-word-region
7593 (\"chinese\" . rfc1843-decode-region))
7596 (defvar gnus-decode-header-methods-cache nil)
7598 (defun gnus-multi-decode-header (start end)
7599 "Apply the functions from `gnus-encoded-word-methods' that match."
7600 (unless (and gnus-decode-header-methods-cache
7601 (eq gnus-newsgroup-name
7602 (car gnus-decode-header-methods-cache)))
7603 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
7606 (nconc gnus-decode-header-methods-cache (list x))
7607 (if (and gnus-newsgroup-name
7608 (string-match (car x) gnus-newsgroup-name))
7609 (nconc gnus-decode-header-methods-cache
7611 gnus-decode-header-methods))
7612 (let ((xlist gnus-decode-header-methods-cache))
7615 (narrow-to-region start end)
7617 (funcall (pop xlist) (point-min) (point-max))))))
7620 ;;; Treatment top-level handling.
7623 (defun gnus-treat-article (condition &optional part-number total-parts type)
7624 (let ((length (- (point-max) (point-min)))
7625 (alist gnus-treatment-function-alist)
7626 (article-goto-body-goes-to-point-min-p t)
7630 (let ((list gnus-article-treat-types))
7632 (when (string-match (pop list) type)
7633 (throw 'found t)))))))
7634 (highlightp (gnus-visual-p 'article-highlight 'highlight))
7635 (entity (static-unless (featurep 'xemacs)
7636 (when (eq 'head condition)
7637 (get-text-property (point-min) 'mime-view-entity))))
7638 val elem buttonized)
7639 (gnus-run-hooks 'gnus-part-display-hook)
7640 (unless gnus-inhibit-treatment
7641 (dolist (elem alist)
7644 (when (gnus-buffer-live-p gnus-summary-buffer)
7645 (set-buffer gnus-summary-buffer))
7646 (symbol-value (car elem))))
7647 (when (and (or (consp val)
7649 (gnus-treat-predicate val)
7650 (or (not (get (car elem) 'highlight))
7652 (when (and (not buttonized)
7654 '(gnus-treat-hide-signature
7655 gnus-treat-highlight-signature)))
7656 (gnus-article-buttonize-signature)
7657 (setq buttonized t))
7659 (funcall (cadr elem)))))
7660 ;; FSF Emacsen does not inherit the existing text properties
7661 ;; in the new text, so we should do it for `mime-view-entity'.
7662 (static-unless (featurep 'xemacs)
7664 (put-text-property (point-min) (point-max)
7665 'mime-view-entity entity))))))
7667 ;; Dynamic variables.
7669 (defvar part-number)
7670 (defvar total-parts)
7675 (defun gnus-treat-predicate (val)
7680 (stringp (car val)))
7681 (apply 'gnus-or (mapcar `(lambda (s)
7682 (string-match s ,(or gnus-newsgroup-name "")))
7685 (let ((pred (pop val)))
7688 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
7690 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
7692 (not (gnus-treat-predicate (car val))))
7694 (equal (car val) type))
7696 (error "%S is not a valid predicate" pred)))))
7706 (eq part-number total-parts))
7710 (error "%S is not a valid value" val))))
7712 (defun gnus-article-encrypt-body (protocol &optional n)
7713 "Encrypt the article body."
7716 (or gnus-article-encrypt-protocol
7717 (completing-read "Encrypt protocol: "
7718 gnus-article-encrypt-protocol-alist
7720 current-prefix-arg))
7721 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7723 (error "Can't find the encrypt protocol %s" protocol))
7724 (if (member gnus-newsgroup-name '("nndraft:delayed"
7727 (error "Can't encrypt the article in group %s"
7728 gnus-newsgroup-name))
7729 (gnus-summary-iterate n
7731 (set-buffer gnus-summary-buffer)
7732 (let ((mail-parse-charset gnus-newsgroup-charset)
7733 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7734 (summary-buffer gnus-summary-buffer)
7736 (gnus-set-global-variables)
7737 (when (gnus-group-read-only-p)
7738 (error "The current newsgroup does not support article encrypt"))
7739 (gnus-summary-show-article t)
7741 (or (mail-header-references gnus-current-headers) ""))
7742 (set-buffer gnus-article-buffer)
7743 (let* ((inhibit-read-only t)
7745 (mapcar (lambda (field)
7746 (and (save-restriction
7747 (message-narrow-to-head)
7748 (goto-char (point-min))
7749 (search-forward field nil t))
7751 (message-narrow-to-field)
7753 (delete-region (point-min) (point-max))
7755 '("Content-Type:" "Content-Transfer-Encoding:"
7756 "Content-Disposition:"))))
7757 (message-narrow-to-head)
7758 (message-remove-header "MIME-Version")
7759 (goto-char (point-max))
7760 (setq point (point))
7761 (insert (apply 'concat headers))
7763 (narrow-to-region point (point-max))
7764 (let ((message-options message-options))
7765 (message-options-set 'message-sender user-mail-address)
7766 (message-options-set 'message-recipients user-mail-address)
7767 (message-options-set 'message-sign-encrypt 'not)
7769 (goto-char (point-min))
7770 (insert "MIME-Version: 1.0\n")
7772 (gnus-summary-edit-article-done
7773 references nil summary-buffer t))
7774 (when gnus-keep-backlog
7775 (gnus-backlog-remove-article
7776 (car gnus-article-current) (cdr gnus-article-current)))
7778 (when (get-buffer gnus-original-article-buffer)
7779 (set-buffer gnus-original-article-buffer)
7780 (setq gnus-original-article nil)))
7781 (when gnus-use-cache
7782 (gnus-cache-update-article
7783 (car gnus-article-current) (cdr gnus-article-current))))))))
7785 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7786 "The following specs can be used:
7787 %t The security MIME type
7790 %D Details if button is pressed")
7792 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
7793 "The following specs can be used:
7794 %t The security MIME type
7797 %D Details if button is pressed")
7799 (defvar gnus-mime-security-button-line-format-alist
7800 '((?t gnus-tmp-type ?s)
7801 (?i gnus-tmp-info ?s)
7802 (?d gnus-tmp-details ?s)
7803 (?D gnus-tmp-pressed-details ?s)))
7805 (defvar gnus-mime-security-button-map
7806 (let ((map (make-sparse-keymap)))
7807 (define-key map gnus-mouse-2 'gnus-article-push-button)
7808 (define-key map "\r" 'gnus-article-press-button)
7811 (defvar gnus-mime-security-details-buffer nil)
7813 (defvar gnus-mime-security-button-pressed nil)
7815 (defvar gnus-mime-security-show-details-inline t
7816 "If non-nil, show details in the article buffer.")
7818 (defun gnus-mime-security-verify-or-decrypt (handle)
7819 (mm-remove-parts (cdr handle))
7820 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7821 point (inhibit-read-only t))
7823 (goto-char (car region)))
7825 (narrow-to-region (point) (point))
7826 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7827 (let* ((mm-verify-option 'known)
7828 (mm-decrypt-option 'known)
7829 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7830 (unless (eq nparts (cdr handle))
7831 (mm-destroy-parts (cdr handle))
7832 (setcdr handle nparts))))
7833 (setq point (point))
7834 (gnus-mime-display-security handle)
7835 (goto-char (point-max)))
7837 (delete-region (point) (cdr region))
7838 (set-marker (car region) nil)
7839 (set-marker (cdr region) nil))
7842 (defun gnus-mime-security-show-details (handle)
7843 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7845 (gnus-message 5 "No details.")
7846 (if gnus-mime-security-show-details-inline
7847 (let ((gnus-mime-security-button-pressed
7848 (not (get-text-property (point) 'gnus-mime-details)))
7849 (gnus-mime-security-button-line-format
7850 (get-text-property (point) 'gnus-line-format))
7851 (inhibit-read-only t))
7853 (while (eq (get-text-property (point) 'gnus-line-format)
7854 gnus-mime-security-button-line-format)
7858 (narrow-to-region (point) (point))
7859 (gnus-insert-mime-security-button handle))
7860 (delete-region (point)
7861 (or (text-property-not-all
7864 gnus-mime-security-button-line-format)
7867 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7868 (with-current-buffer gnus-mime-security-details-buffer
7871 (setq gnus-mime-security-details-buffer
7872 (gnus-get-buffer-create "*MIME Security Details*")))
7873 (with-current-buffer gnus-mime-security-details-buffer
7875 (goto-char (point-min)))
7876 (pop-to-buffer gnus-mime-security-details-buffer)))))
7878 (defun gnus-mime-security-press-button (handle)
7880 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7881 (gnus-mime-security-show-details handle)
7882 (gnus-mime-security-verify-or-decrypt handle))))
7884 (defun gnus-insert-mime-security-button (handle &optional displayed)
7885 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7888 (or (nth 2 (assoc protocol mm-verify-function-alist))
7889 (nth 2 (assoc protocol mm-decrypt-function-alist))
7891 (if (equal (car handle) "multipart/signed")
7892 " Signed" " Encrypted")
7895 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7898 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7899 gnus-tmp-pressed-details
7901 (setq gnus-tmp-details
7902 (if gnus-tmp-details
7903 (concat "\n" gnus-tmp-details)
7905 (setq gnus-tmp-pressed-details
7906 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7911 gnus-mime-security-button-line-format
7912 gnus-mime-security-button-line-format-alist
7913 `(keymap ,gnus-mime-security-button-map
7914 gnus-callback gnus-mime-security-press-button
7915 gnus-line-format ,gnus-mime-security-button-line-format
7916 gnus-mime-details ,gnus-mime-security-button-pressed
7917 article-type annotation
7920 ;; Exclude a newline.
7923 (widget-convert-button
7926 :action 'gnus-widget-press-button
7927 :button-keymap gnus-mime-security-button-map
7929 (lambda (widget/window &optional overlay pos)
7930 ;; Needed to properly clear the message due to a bug in
7931 ;; wid-edit (XEmacs only).
7932 (when (boundp 'help-echo-owns-message)
7933 (setq help-echo-owns-message t))
7936 (aref gnus-mouse-2 0))))))
7938 (defun gnus-mime-display-security (handle)
7940 (narrow-to-region (point) (point))
7941 (unless (gnus-unbuttonized-mime-type-p (car handle))
7942 (gnus-insert-mime-security-button handle))
7943 (gnus-mime-display-part (cadr handle))
7946 (unless (gnus-unbuttonized-mime-type-p (car handle))
7947 (let ((gnus-mime-security-button-line-format
7948 gnus-mime-security-button-end-line-format))
7949 (gnus-insert-mime-security-button handle)))
7950 (mm-set-handle-multipart-parameter
7952 (cons (set-marker (make-marker) (point-min))
7953 (set-marker (make-marker) (point-max))))))
7959 (defun gnus-article-header-presentation-method (entity situation)
7960 (mime-insert-header entity)
7961 (article-decode-group-name))
7963 (set-alist 'mime-header-presentation-method-alist
7964 'gnus-original-article-mode
7965 #'gnus-article-header-presentation-method)
7967 (defun gnus-mime-preview-quitting-method ()
7968 (mime-preview-kill-buffer)
7969 (delete-other-windows)
7970 (gnus-article-show-summary)
7971 (gnus-summary-select-article gnus-show-all-headers t))
7973 (set-alist 'mime-preview-quitting-method-alist
7974 'gnus-original-article-mode #'gnus-mime-preview-quitting-method)
7976 (set-alist 'mime-preview-following-method-alist
7977 'gnus-original-article-mode #'gnus-following-method)
7979 (set-alist 'mime-preview-over-to-previous-method-alist
7980 'gnus-original-article-mode
7982 (if (> (point-min) 1)
7983 (gnus-article-prev-page)
7984 (gnus-article-read-summary-keys
7985 nil (gnus-character-to-event ?P)))))
7987 (set-alist 'mime-preview-over-to-next-method-alist
7988 'gnus-original-article-mode'
7990 (if (< (point-max) (buffer-size))
7991 (gnus-article-next-page)
7992 (gnus-article-read-summary-keys
7993 nil (gnus-character-to-event ?N)))))
8003 (run-hooks 'gnus-art-load-hook)
8005 ;;; gnus-art.el ends here