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 ("replace with file" . gnus-mime-replace-part)
965 ("delete part" . gnus-mime-delete-part)
966 ("display as text" . gnus-mime-inline-part)
967 ("view the part" . gnus-mime-view-part)
968 ("pipe to command" . gnus-mime-pipe-part)
969 ("toggle display" . gnus-article-press-button)
970 ("toggle display" . gnus-article-view-part-as-charset)
971 ("view as type" . gnus-mime-view-part-as-type)
972 ("view internally" . gnus-mime-view-part-internally)
973 ("view externally" . gnus-mime-view-part-externally))
974 "An alist of actions that run on the MIME attachment."
975 :group 'gnus-article-mime
976 :type '(repeat (cons (string :tag "name")
979 (defcustom gnus-auto-select-part 1
980 "Advance to next MIME part when deleting or stripping parts.
982 When 0, point will be placed on the same part as before. When
983 positive (negative), move point forward (backwards) this many
984 parts. When nil, redisplay article."
985 :version "23.0" ;; No Gnus
986 :group 'gnus-article-mime
987 :type '(choice (const nil :tag "Redisplay article.")
988 (const 1 :tag "Next part.")
989 (const 0 :tag "Current part.")
993 ;;; The treatment variables
996 (defvar gnus-part-display-hook nil
997 "Hook called on parts that are to receive treatment.")
999 (defvar gnus-article-treat-custom
1000 '(choice (const :tag "Off" nil)
1002 (const :tag "Header" head)
1003 (const :tag "Last" last)
1004 (const :tag "Mime" mime)
1005 (integer :tag "Less")
1006 (repeat :tag "Groups" regexp)
1007 (sexp :tag "Predicate")))
1009 (defvar gnus-article-treat-head-custom
1010 '(choice (const :tag "Off" nil)
1011 (const :tag "Header" head)))
1013 (defvar gnus-article-treat-types '("text/plain")
1016 (defvar gnus-inhibit-treatment nil
1017 "Whether to inhibit treatment.")
1019 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
1020 "Highlight the signature.
1021 Valid values are nil, t, `head', `last', an integer or a predicate.
1022 See Info node `(gnus)Customizing Articles'."
1023 :group 'gnus-article-treat
1024 :link '(custom-manual "(gnus)Customizing Articles")
1025 :type gnus-article-treat-custom)
1026 (put 'gnus-treat-highlight-signature 'highlight t)
1028 (defcustom gnus-treat-buttonize 100000
1030 Valid values are nil, t, `head', `last', an integer or a predicate.
1031 See Info node `(gnus)Customizing Articles'."
1032 :group 'gnus-article-treat
1033 :link '(custom-manual "(gnus)Customizing Articles")
1034 :type gnus-article-treat-custom)
1035 (put 'gnus-treat-buttonize 'highlight t)
1037 (defcustom gnus-treat-buttonize-head 'head
1038 "Add buttons to the head.
1039 Valid values are nil, t, `head', `last', an integer or a predicate.
1040 See Info node `(gnus)Customizing Articles' for details."
1041 :group 'gnus-article-treat
1042 :link '(custom-manual "(gnus)Customizing Articles")
1043 :type gnus-article-treat-head-custom)
1044 (put 'gnus-treat-buttonize-head 'highlight t)
1046 (defcustom gnus-treat-emphasize
1047 (and (or window-system
1051 Valid values are nil, t, `head', `last', an integer or a predicate.
1052 See Info node `(gnus)Customizing Articles' for details."
1053 :group 'gnus-article-treat
1054 :link '(custom-manual "(gnus)Customizing Articles")
1055 :type gnus-article-treat-custom)
1056 (put 'gnus-treat-emphasize 'highlight t)
1058 (defcustom gnus-treat-strip-cr nil
1059 "Remove carriage returns.
1060 Valid values are nil, t, `head', `last', an integer or a predicate.
1061 See Info node `(gnus)Customizing Articles' for details."
1063 :group 'gnus-article-treat
1064 :link '(custom-manual "(gnus)Customizing Articles")
1065 :type gnus-article-treat-custom)
1067 (defcustom gnus-treat-unsplit-urls nil
1068 "Remove newlines from within URLs.
1069 Valid values are nil, t, `head', `last', an integer or a predicate.
1070 See Info node `(gnus)Customizing Articles' for details."
1072 :group 'gnus-article-treat
1073 :link '(custom-manual "(gnus)Customizing Articles")
1074 :type gnus-article-treat-custom)
1076 (defcustom gnus-treat-leading-whitespace nil
1077 "Remove leading whitespace in headers.
1078 Valid values are nil, t, `head', `last', an integer or a predicate.
1079 See Info node `(gnus)Customizing Articles' for details."
1081 :group 'gnus-article-treat
1082 :link '(custom-manual "(gnus)Customizing Articles")
1083 :type gnus-article-treat-custom)
1085 (defcustom gnus-treat-hide-headers 'head
1087 Valid values are nil, t, `head', `last', an integer or a predicate.
1088 See Info node `(gnus)Customizing Articles' for details."
1089 :group 'gnus-article-treat
1090 :link '(custom-manual "(gnus)Customizing Articles")
1091 :type gnus-article-treat-head-custom)
1093 (defcustom gnus-treat-hide-boring-headers nil
1094 "Hide boring headers.
1095 Valid values are nil, t, `head', `last', an integer or a predicate.
1096 See Info node `(gnus)Customizing Articles' for details."
1097 :group 'gnus-article-treat
1098 :link '(custom-manual "(gnus)Customizing Articles")
1099 :type gnus-article-treat-head-custom)
1101 (defcustom gnus-treat-hide-signature nil
1102 "Hide the signature.
1103 Valid values are nil, t, `head', `last', an integer or a predicate.
1104 See Info node `(gnus)Customizing Articles' for details."
1105 :group 'gnus-article-treat
1106 :link '(custom-manual "(gnus)Customizing Articles")
1107 :type gnus-article-treat-custom)
1109 (defcustom gnus-treat-fill-article nil
1111 Valid values are nil, t, `head', `last', an integer or a predicate.
1112 See Info node `(gnus)Customizing Articles' for details."
1113 :group 'gnus-article-treat
1114 :link '(custom-manual "(gnus)Customizing Articles")
1115 :type gnus-article-treat-custom)
1117 (defcustom gnus-treat-hide-citation nil
1119 Valid values are nil, t, `head', `last', an integer or a predicate.
1120 See Info node `(gnus)Customizing Articles' for details."
1121 :group 'gnus-article-treat
1122 :link '(custom-manual "(gnus)Customizing Articles")
1123 :type gnus-article-treat-custom)
1125 (defcustom gnus-treat-hide-citation-maybe nil
1127 Valid values are nil, t, `head', `last', an integer or a predicate.
1128 See Info node `(gnus)Customizing Articles' for details."
1129 :group 'gnus-article-treat
1130 :link '(custom-manual "(gnus)Customizing Articles")
1131 :type gnus-article-treat-custom)
1133 (defcustom gnus-treat-strip-list-identifiers 'head
1134 "Strip list identifiers from `gnus-list-identifiers`.
1135 Valid values are nil, t, `head', `last', an integer or a predicate.
1136 See Info node `(gnus)Customizing Articles' for details."
1138 :group 'gnus-article-treat
1139 :link '(custom-manual "(gnus)Customizing Articles")
1140 :type gnus-article-treat-custom)
1142 (make-obsolete-variable 'gnus-treat-strip-pgp
1143 "This option is obsolete in Gnus 5.10.")
1145 (defcustom gnus-treat-strip-pem nil
1146 "Strip PEM signatures.
1147 Valid values are nil, t, `head', `last', an integer or a predicate.
1148 See Info node `(gnus)Customizing Articles' for details."
1149 :group 'gnus-article-treat
1150 :link '(custom-manual "(gnus)Customizing Articles")
1151 :type gnus-article-treat-custom)
1153 (defcustom gnus-treat-strip-banner t
1154 "Strip banners from articles.
1155 The banner to be stripped is specified in the `banner' group parameter.
1156 Valid values are nil, t, `head', `last', an integer or a predicate.
1157 See Info node `(gnus)Customizing Articles' for details."
1158 :group 'gnus-article-treat
1159 :link '(custom-manual "(gnus)Customizing Articles")
1160 :type gnus-article-treat-custom)
1162 (defcustom gnus-treat-highlight-headers 'head
1163 "Highlight the headers.
1164 Valid values are nil, t, `head', `last', an integer or a predicate.
1165 See Info node `(gnus)Customizing Articles' for details."
1166 :group 'gnus-article-treat
1167 :link '(custom-manual "(gnus)Customizing Articles")
1168 :type gnus-article-treat-head-custom)
1169 (put 'gnus-treat-highlight-headers 'highlight t)
1171 (defcustom gnus-treat-highlight-citation t
1172 "Highlight cited text.
1173 Valid values are nil, t, `head', `last', an integer or a predicate.
1174 See Info node `(gnus)Customizing Articles' for details."
1175 :group 'gnus-article-treat
1176 :link '(custom-manual "(gnus)Customizing Articles")
1177 :type gnus-article-treat-custom)
1178 (put 'gnus-treat-highlight-citation 'highlight t)
1180 (defcustom gnus-treat-date-ut nil
1181 "Display the Date in UT (GMT).
1182 Valid values are nil, t, `head', `last', an integer or a predicate.
1183 See Info node `(gnus)Customizing Articles' for details."
1184 :group 'gnus-article-treat
1185 :link '(custom-manual "(gnus)Customizing Articles")
1186 :type gnus-article-treat-head-custom)
1188 (defcustom gnus-treat-date-local nil
1189 "Display the Date in the local timezone.
1190 Valid values are nil, t, `head', `last', an integer or a predicate.
1191 See Info node `(gnus)Customizing Articles' for details."
1192 :group 'gnus-article-treat
1193 :link '(custom-manual "(gnus)Customizing Articles")
1194 :type gnus-article-treat-head-custom)
1196 (defcustom gnus-treat-date-english nil
1197 "Display the Date in a format that can be read aloud in English.
1198 Valid values are nil, t, `head', `last', an integer or a predicate.
1199 See Info node `(gnus)Customizing Articles' for details."
1201 :group 'gnus-article-treat
1202 :link '(custom-manual "(gnus)Customizing Articles")
1203 :type gnus-article-treat-head-custom)
1205 (defcustom gnus-treat-date-lapsed nil
1206 "Display the Date header in a way that says how much time has elapsed.
1207 Valid values are nil, t, `head', `last', an integer or a predicate.
1208 See Info node `(gnus)Customizing Articles' for details."
1209 :group 'gnus-article-treat
1210 :link '(custom-manual "(gnus)Customizing Articles")
1211 :type gnus-article-treat-head-custom)
1213 (defcustom gnus-treat-date-original nil
1214 "Display the date in the original timezone.
1215 Valid values are nil, t, `head', `last', an integer or a predicate.
1216 See Info node `(gnus)Customizing Articles' for details."
1217 :group 'gnus-article-treat
1218 :link '(custom-manual "(gnus)Customizing Articles")
1219 :type gnus-article-treat-head-custom)
1221 (defcustom gnus-treat-date-iso8601 nil
1222 "Display the date in the ISO8601 format.
1223 Valid values are nil, t, `head', `last', an integer or a predicate.
1224 See Info node `(gnus)Customizing Articles' for details."
1226 :group 'gnus-article-treat
1227 :link '(custom-manual "(gnus)Customizing Articles")
1228 :type gnus-article-treat-head-custom)
1230 (defcustom gnus-treat-date-user-defined nil
1231 "Display the date in a user-defined format.
1232 The format is defined by the `gnus-article-time-format' variable.
1233 Valid values are nil, t, `head', `last', an integer or a predicate.
1234 See Info node `(gnus)Customizing Articles' for details."
1235 :group 'gnus-article-treat
1236 :link '(custom-manual "(gnus)Customizing Articles")
1237 :type gnus-article-treat-head-custom)
1239 (defcustom gnus-treat-strip-headers-in-body t
1240 "Strip the X-No-Archive header line from the beginning of the body.
1241 Valid values are nil, t, `head', `last', an integer or a predicate.
1242 See Info node `(gnus)Customizing Articles' for details."
1244 :group 'gnus-article-treat
1245 :link '(custom-manual "(gnus)Customizing Articles")
1246 :type gnus-article-treat-custom)
1248 (defcustom gnus-treat-strip-trailing-blank-lines nil
1249 "Strip trailing blank lines.
1250 Valid values are nil, t, `head', `last', an integer or a predicate.
1251 See Info node `(gnus)Customizing Articles' for details."
1252 :group 'gnus-article-treat
1253 :link '(custom-manual "(gnus)Customizing Articles")
1254 :type gnus-article-treat-custom)
1256 (defcustom gnus-treat-strip-leading-blank-lines nil
1257 "Strip leading blank lines.
1258 Valid values are nil, t, `head', `last', an integer or a predicate.
1259 See Info node `(gnus)Customizing Articles' for details."
1260 :group 'gnus-article-treat
1261 :link '(custom-manual "(gnus)Customizing Articles")
1262 :type gnus-article-treat-custom)
1264 (defcustom gnus-treat-strip-multiple-blank-lines nil
1265 "Strip multiple blank lines.
1266 Valid values are nil, t, `head', `last', an integer or a predicate.
1267 See Info node `(gnus)Customizing Articles' for details."
1268 :group 'gnus-article-treat
1269 :link '(custom-manual "(gnus)Customizing Articles")
1270 :type gnus-article-treat-custom)
1272 (defcustom gnus-treat-unfold-headers 'head
1273 "Unfold folded header lines.
1274 Valid values are nil, t, `head', `last', an integer or a predicate.
1275 See Info node `(gnus)Customizing Articles' for details."
1277 :group 'gnus-article-treat
1278 :link '(custom-manual "(gnus)Customizing Articles")
1279 :type gnus-article-treat-custom)
1281 (defcustom gnus-treat-fold-headers nil
1283 Valid values are nil, t, `head', `last', an integer or a predicate.
1284 See Info node `(gnus)Customizing Articles' for details."
1286 :group 'gnus-article-treat
1287 :link '(custom-manual "(gnus)Customizing Articles")
1288 :type gnus-article-treat-custom)
1290 (defcustom gnus-treat-fold-newsgroups 'head
1291 "Fold the Newsgroups and Followup-To headers.
1292 Valid values are nil, t, `head', `last', an integer or a predicate.
1293 See Info node `(gnus)Customizing Articles' for details."
1295 :group 'gnus-article-treat
1296 :link '(custom-manual "(gnus)Customizing Articles")
1297 :type gnus-article-treat-custom)
1299 (defcustom gnus-treat-overstrike t
1300 "Treat overstrike highlighting.
1301 Valid values are nil, t, `head', `last', an integer or a predicate.
1302 See Info node `(gnus)Customizing Articles' for details."
1303 :group 'gnus-article-treat
1304 :link '(custom-manual "(gnus)Customizing Articles")
1305 :type gnus-article-treat-custom)
1306 (put 'gnus-treat-overstrike 'highlight t)
1308 (defcustom gnus-treat-ansi-sequences (if (locate-library "ansi-color") t)
1309 "Treat ANSI SGR control sequences.
1310 Valid values are nil, t, `head', `last', an integer or a predicate.
1311 See Info node `(gnus)Customizing Articles' for details."
1312 :group 'gnus-article-treat
1313 :link '(custom-manual "(gnus)Customizing Articles")
1314 :type gnus-article-treat-custom)
1316 (make-obsolete-variable 'gnus-treat-display-xface
1317 'gnus-treat-display-x-face)
1319 (defcustom gnus-treat-display-x-face
1320 (and (not noninteractive)
1321 (or (and (fboundp 'image-type-available-p)
1322 (image-type-available-p 'xbm)
1323 (string-match "^0x" (shell-command-to-string "uncompface"))
1324 (executable-find "icontopbm"))
1325 (and (featurep 'xemacs)
1328 "Display X-Face headers.
1329 Valid values are nil, t, `head', `last', an integer or a predicate.
1330 See Info node `(gnus)Customizing Articles' and Info node
1331 `(gnus)X-Face' for details."
1332 :group 'gnus-article-treat
1334 :link '(custom-manual "(gnus)Customizing Articles")
1335 :link '(custom-manual "(gnus)X-Face")
1336 :type gnus-article-treat-head-custom
1337 :set (lambda (symbol value)
1340 (cond ((or (boundp symbol) (get symbol 'saved-value))
1342 ((boundp 'gnus-treat-display-xface)
1344 ** gnus-treat-display-xface is an obsolete variable;\
1345 use gnus-treat-display-x-face instead")
1346 (default-value 'gnus-treat-display-xface))
1347 ((get 'gnus-treat-display-xface 'saved-value)
1349 ** gnus-treat-display-xface is an obsolete variable;\
1350 use gnus-treat-display-x-face instead")
1351 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1354 (put 'gnus-treat-display-x-face 'highlight t)
1356 (defcustom gnus-article-should-use-smiley-mule
1357 (not (or (featurep 'xemacs)
1358 (gnus-image-type-available-p 'xpm)
1359 (gnus-image-type-available-p 'pbm)))
1360 "Non-nil means use `smiley-mule' to show smileys rather than `smiley'.
1361 `smiley-mule' is boundled in BITMAP-MULE package. You can set it to t
1362 even if your Emacs supports images. It has no effect on XEmacs."
1363 :group 'gnus-article-various
1365 :get (lambda (symbol)
1366 (and (not noninteractive)
1367 (default-value symbol)
1368 (not (featurep 'xemacs))
1369 (module-installed-p 'smiley-mule)
1371 :set (lambda (symbol value)
1372 (set-default symbol (and (not noninteractive)
1374 (not (featurep 'xemacs))
1375 (module-installed-p 'smiley-mule)
1378 (defvar gnus-article-smiley-mule-loaded-p nil
1379 "Internal variable used to say whether `smiley-mule' is loaded (whether
1380 smiley functions are not overridden by `smiley').")
1382 (defcustom gnus-treat-display-face
1383 (and (not noninteractive)
1384 (or (and (fboundp 'image-type-available-p)
1385 (image-type-available-p 'png))
1386 (and (featurep 'xemacs)
1389 "Display Face headers.
1390 Valid values are nil, t, `head', `last', an integer or a predicate.
1391 See Info node `(gnus)Customizing Articles' and Info node
1392 `(gnus)X-Face' for details."
1393 :group 'gnus-article-treat
1395 :link '(custom-manual "(gnus)Customizing Articles")
1396 :link '(custom-manual "(gnus)X-Face")
1397 :type gnus-article-treat-head-custom)
1398 (put 'gnus-treat-display-face 'highlight t)
1400 (defcustom gnus-treat-display-smileys
1401 (if (and (not noninteractive)
1402 (or (and (featurep 'xemacs)
1404 (gnus-image-type-available-p 'xpm)
1405 (gnus-image-type-available-p 'pbm)
1406 (and (not (featurep 'xemacs))
1408 (module-installed-p 'smiley-mule))))
1412 Valid values are nil, t, `head', `last', an integer or a predicate.
1413 See Info node `(gnus)Customizing Articles' and Info node
1414 `(gnus)Smileys' for details."
1415 :group 'gnus-article-treat
1417 :link '(custom-manual "(gnus)Customizing Articles")
1418 :link '(custom-manual "(gnus)Smileys")
1419 :type gnus-article-treat-custom)
1420 (put 'gnus-treat-display-smileys 'highlight t)
1422 (defcustom gnus-treat-from-picon
1423 (if (and (gnus-image-type-available-p 'xpm)
1424 (gnus-picons-installed-p))
1426 "Display picons in the From header.
1427 Valid values are nil, t, `head', `last', an integer or a predicate.
1428 See Info node `(gnus)Customizing Articles' and Info node
1429 `(gnus)Picons' for details."
1431 :group 'gnus-article-treat
1433 :link '(custom-manual "(gnus)Customizing Articles")
1434 :link '(custom-manual "(gnus)Picons")
1435 :type gnus-article-treat-head-custom)
1436 (put 'gnus-treat-from-picon 'highlight t)
1438 (defcustom gnus-treat-mail-picon
1439 (if (and (gnus-image-type-available-p 'xpm)
1440 (gnus-picons-installed-p))
1442 "Display picons in To and Cc headers.
1443 Valid values are nil, t, `head', `last', an integer or a predicate.
1444 See Info node `(gnus)Customizing Articles' and Info node
1445 `(gnus)Picons' for details."
1447 :group 'gnus-article-treat
1449 :link '(custom-manual "(gnus)Customizing Articles")
1450 :link '(custom-manual "(gnus)Picons")
1451 :type gnus-article-treat-head-custom)
1452 (put 'gnus-treat-mail-picon 'highlight t)
1454 (defcustom gnus-treat-newsgroups-picon
1455 (if (and (gnus-image-type-available-p 'xpm)
1456 (gnus-picons-installed-p))
1458 "Display picons in the Newsgroups and Followup-To headers.
1459 Valid values are nil, t, `head', `last', an integer or a predicate.
1460 See Info node `(gnus)Customizing Articles' and Info node
1461 `(gnus)Picons' for details."
1463 :group 'gnus-article-treat
1465 :link '(custom-manual "(gnus)Customizing Articles")
1466 :link '(custom-manual "(gnus)Picons")
1467 :type gnus-article-treat-head-custom)
1468 (put 'gnus-treat-newsgroups-picon 'highlight t)
1470 (defcustom gnus-treat-body-boundary
1471 (if (and (eq window-system 'x)
1472 (or gnus-treat-newsgroups-picon
1473 gnus-treat-mail-picon
1474 gnus-treat-from-picon))
1476 "Draw a boundary at the end of the headers.
1477 Valid values are nil and `head'.
1478 See Info node `(gnus)Customizing Articles' for details."
1480 :group 'gnus-article-treat
1481 :link '(custom-manual "(gnus)Customizing Articles")
1482 :type gnus-article-treat-head-custom)
1484 (defcustom gnus-treat-capitalize-sentences nil
1485 "Capitalize sentence-starting words.
1486 Valid values are nil, t, `head', `last', an integer or a predicate.
1487 See Info node `(gnus)Customizing Articles' for details."
1489 :group 'gnus-article-treat
1490 :link '(custom-manual "(gnus)Customizing Articles")
1491 :type gnus-article-treat-custom)
1493 (defcustom gnus-treat-wash-html nil
1495 Valid values are nil, t, `head', `last', an integer or a predicate.
1496 See Info node `(gnus)Customizing Articles' for details."
1498 :group 'gnus-article-treat
1499 :link '(custom-manual "(gnus)Customizing Articles")
1500 :type gnus-article-treat-custom)
1502 (defcustom gnus-treat-fill-long-lines nil
1504 Valid values are nil, t, `head', `last', an integer or a predicate.
1505 See Info node `(gnus)Customizing Articles' for details."
1506 :group 'gnus-article-treat
1507 :link '(custom-manual "(gnus)Customizing Articles")
1508 :type gnus-article-treat-custom)
1510 (defcustom gnus-treat-play-sounds nil
1512 Valid values are nil, t, `head', `last', an integer or a predicate.
1513 See Info node `(gnus)Customizing Articles' for details."
1515 :group 'gnus-article-treat
1516 :link '(custom-manual "(gnus)Customizing Articles")
1517 :type gnus-article-treat-custom)
1519 (defcustom gnus-treat-decode-article-as-default-mime-charset nil
1520 "Decode an article as `default-mime-charset'. For instance, if you want to
1521 attempt to decode an article even if the value of `gnus-show-mime' is nil,
1522 you could set this variable to something like: nil for don't decode, t for
1523 decode the body, '(or header t) for the whole article, etc."
1524 :group 'gnus-article-treat
1525 :type '(radio (const :tag "Off" nil)
1526 (const :tag "Decode body" t)
1527 (const :tag "Decode all" (or head t))))
1529 (defcustom gnus-treat-translate nil
1530 "Translate articles from one language to another.
1531 Valid values are nil, t, `head', `last', an integer or a predicate.
1532 See Info node `(gnus)Customizing Articles' for details."
1534 :group 'gnus-article-treat
1535 :link '(custom-manual "(gnus)Customizing Articles")
1536 :type gnus-article-treat-custom)
1538 (defcustom gnus-treat-x-pgp-sig nil
1540 To automatically treat X-PGP-Sig, set it to head.
1541 Valid values are nil, t, `head', `last', an integer or a predicate.
1542 See Info node `(gnus)Customizing Articles' for details."
1544 :group 'gnus-article-treat
1545 :group 'mime-security
1546 :type gnus-article-treat-custom)
1548 (defcustom gnus-treat-monafy nil
1549 "Display body part with mona font.
1550 Valid values are nil, t, `head', `last', an integer or a predicate.
1551 See Info node `(gnus)Customizing Articles' for details."
1552 :group 'gnus-article-treat
1553 :group 'mime-security
1554 :link '(custom-manual "(gnus)Customizing Articles")
1555 :type gnus-article-treat-custom)
1557 (defvar gnus-article-encrypt-protocol-alist
1558 '(("PGP" . mml2015-self-encrypt)))
1560 ;; Set to nil if more than one protocol added to
1561 ;; gnus-article-encrypt-protocol-alist.
1562 (defcustom gnus-article-encrypt-protocol "PGP"
1563 "The protocol used for encrypt articles.
1564 It is a string, such as \"PGP\". If nil, ask user."
1567 :group 'mime-security)
1569 (defvar gnus-article-wash-function nil
1570 "Function used for converting HTML into text.")
1572 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1573 (mm-coding-system-p 'utf-8)
1574 (executable-find idna-program))
1575 "Whether IDNA decoding of headers is used when viewing messages.
1576 This requires GNU Libidn, and by default only enabled if it is found."
1578 :group 'gnus-article-headers
1581 (defcustom gnus-article-over-scroll nil
1582 "If non-nil, allow scrolling the article buffer even when there no more text."
1584 :group 'gnus-article
1587 ;;; Internal variables
1589 (defvar gnus-english-month-names
1590 '("January" "February" "March" "April" "May" "June" "July" "August"
1591 "September" "October" "November" "December"))
1593 (defvar gnus-button-regexp nil)
1594 (defvar gnus-button-marker-list nil)
1595 ;; Regexp matching any of the regexps from `gnus-button-alist'.
1597 (defvar gnus-button-last nil)
1598 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
1600 (defvar article-goto-body-goes-to-point-min-p nil)
1601 (defvar gnus-article-wash-types nil)
1602 (defvar gnus-article-emphasis-alist nil)
1603 (defvar gnus-article-image-alist nil)
1605 (defvar gnus-article-mime-handle-alist-1 nil)
1606 (defvar gnus-treatment-function-alist
1607 '((gnus-treat-decode-article-as-default-mime-charset
1608 gnus-article-decode-article-as-default-mime-charset)
1609 (gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1610 (gnus-treat-monafy gnus-article-monafy)
1611 (gnus-treat-strip-banner gnus-article-strip-banner)
1612 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1613 (gnus-treat-buttonize gnus-article-add-buttons)
1614 (gnus-treat-fill-article gnus-article-fill-cited-article)
1615 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1616 (gnus-treat-strip-cr gnus-article-remove-cr)
1617 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1618 (gnus-treat-date-ut gnus-article-date-ut)
1619 (gnus-treat-date-local gnus-article-date-local)
1620 (gnus-treat-date-english gnus-article-date-english)
1621 (gnus-treat-date-original gnus-article-date-original)
1622 (gnus-treat-date-user-defined gnus-article-date-user)
1623 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1624 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1625 (gnus-treat-display-face gnus-article-display-face)
1626 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1627 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1628 (gnus-treat-hide-signature gnus-article-hide-signature)
1629 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1630 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1631 (gnus-treat-strip-pem gnus-article-hide-pem)
1632 (gnus-treat-from-picon gnus-treat-from-picon)
1633 (gnus-treat-mail-picon gnus-treat-mail-picon)
1634 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1635 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1636 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1637 (gnus-treat-strip-trailing-blank-lines
1638 gnus-article-remove-trailing-blank-lines)
1639 (gnus-treat-strip-leading-blank-lines
1640 gnus-article-strip-leading-blank-lines)
1641 (gnus-treat-strip-multiple-blank-lines
1642 gnus-article-strip-multiple-blank-lines)
1643 (gnus-treat-overstrike gnus-article-treat-overstrike)
1644 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences)
1645 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1646 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1647 ;; Displaying X-Face should be done after unfolding headers
1648 ;; to protect bitmap lines.
1649 (gnus-treat-display-x-face gnus-article-display-x-face)
1650 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1651 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1652 (gnus-treat-display-smileys gnus-treat-smiley)
1653 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1654 (gnus-treat-wash-html gnus-article-wash-html)
1655 (gnus-treat-emphasize gnus-article-emphasize)
1656 (gnus-treat-hide-citation gnus-article-hide-citation)
1657 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1658 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1659 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1660 (gnus-treat-play-sounds gnus-earcon-display)))
1662 (defvar gnus-article-mime-handle-alist nil)
1663 (defvar article-lapsed-timer nil)
1664 (defvar gnus-article-current-summary nil)
1666 (defvar gnus-article-mode-syntax-table
1667 (let ((table (copy-syntax-table text-mode-syntax-table)))
1668 ;; This causes the citation match run O(2^n).
1669 ;; (modify-syntax-entry ?- "w" table)
1670 (modify-syntax-entry ?> ")<" table)
1671 (modify-syntax-entry ?< "(>" table)
1672 ;; make M-. in article buffers work for `foo' strings
1673 (modify-syntax-entry ?' " " table)
1674 (modify-syntax-entry ?` " " table)
1676 "Syntax table used in article mode buffers.
1677 Initialized from `text-mode-syntax-table.")
1679 (defvar gnus-save-article-buffer nil)
1681 (defvar gnus-article-mode-line-format-alist
1682 (nconc '((?w (gnus-article-wash-status) ?s)
1683 (?m (gnus-article-mime-part-status) ?s))
1684 gnus-summary-mode-line-format-alist))
1686 (defvar gnus-number-of-articles-to-be-saved nil)
1688 (defvar gnus-inhibit-hiding nil)
1690 (defvar gnus-article-edit-mode nil)
1692 ;;; Macros for dealing with the article buffer.
1694 (defmacro gnus-with-article-headers (&rest forms)
1696 (set-buffer gnus-article-buffer)
1698 (let ((inhibit-read-only t)
1699 (inhibit-point-motion-hooks t)
1700 (case-fold-search t))
1701 (article-narrow-to-head)
1704 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1705 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1707 (defmacro gnus-with-article-buffer (&rest forms)
1709 (set-buffer gnus-article-buffer)
1710 (let ((inhibit-read-only t))
1713 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1714 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1716 (defun gnus-article-goto-header (header)
1717 "Go to HEADER, which is a regular expression."
1718 (re-search-forward (concat "^\\(" header "\\):") nil t))
1720 (defsubst gnus-article-hide-text (b e props)
1721 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1722 (gnus-add-text-properties-when 'article-type nil b e props)
1723 (when (memq 'intangible props)
1725 (max (1- b) (point-min))
1726 b 'intangible (cddr (memq 'intangible props)))))
1728 (defsubst gnus-article-unhide-text (b e)
1729 "Remove hidden text properties from region between B and E."
1730 (remove-text-properties b e gnus-hidden-properties)
1731 (when (memq 'intangible gnus-hidden-properties)
1732 (put-text-property (max (1- b) (point-min))
1733 b 'intangible nil)))
1735 (defun gnus-article-hide-text-type (b e type)
1736 "Hide text of TYPE between B and E."
1737 (gnus-add-wash-type type)
1738 (gnus-article-hide-text
1739 b e (cons 'article-type (cons type gnus-hidden-properties))))
1741 (defun gnus-article-unhide-text-type (b e type)
1742 "Unhide text of TYPE between B and E."
1743 (gnus-delete-wash-type type)
1744 (remove-text-properties
1745 b e (cons 'article-type (cons type gnus-hidden-properties)))
1746 (when (memq 'intangible gnus-hidden-properties)
1747 (put-text-property (max (1- b) (point-min))
1748 b 'intangible nil)))
1750 (defun gnus-article-hide-text-of-type (type)
1751 "Hide text of TYPE in the current buffer."
1753 (let ((b (point-min))
1755 (while (setq b (text-property-any b e 'article-type type))
1756 (add-text-properties b (incf b) gnus-hidden-properties)))))
1758 (defun gnus-article-delete-text-of-type (type)
1759 "Delete text of TYPE in the current buffer."
1761 (let ((b (point-min)))
1762 (while (setq b (text-property-any b (point-max) 'article-type type))
1764 b (or (text-property-not-all b (point-max) 'article-type type)
1767 (defun gnus-article-delete-invisible-text ()
1768 "Delete all invisible text in the current buffer."
1770 (let ((b (point-min)))
1771 (while (setq b (text-property-any b (point-max) 'invisible t))
1773 b (or (text-property-not-all b (point-max) 'invisible t)
1776 (defun gnus-article-text-type-exists-p (type)
1777 "Say whether any text of type TYPE exists in the buffer."
1778 (text-property-any (point-min) (point-max) 'article-type type))
1780 (defsubst gnus-article-header-rank ()
1781 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1782 (let ((list gnus-sorted-header-list)
1785 (if (looking-at (car list))
1787 (setq list (cdr list))
1791 (defun article-hide-headers (&optional arg delete)
1792 "Hide unwanted headers and possibly sort them as well."
1793 (interactive (gnus-article-hidden-arg))
1794 ;; Lars said that this function might be inhibited.
1795 (if (gnus-article-check-hidden-text 'headers arg)
1797 ;; Show boring headers as well.
1798 (gnus-article-show-hidden-text 'boring-headers)
1799 (when (eq 1 (point-min))
1800 (set-window-start (get-buffer-window (current-buffer)) 1)))
1801 (unless gnus-inhibit-hiding
1802 (let ((inhibit-read-only t)
1803 (case-fold-search t)
1804 (max (1+ (length gnus-sorted-header-list)))
1805 (inhibit-point-motion-hooks t)
1806 (cur (current-buffer))
1807 ignored visible beg)
1809 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1810 ;; group parameters, so we should go to the summary buffer.
1813 (progn (set-buffer gnus-summary-buffer) t)
1815 (setq ignored (when (not gnus-visible-headers)
1816 (cond ((stringp gnus-ignored-headers)
1817 gnus-ignored-headers)
1818 ((listp gnus-ignored-headers)
1819 (mapconcat 'identity
1820 gnus-ignored-headers
1822 visible (cond ((stringp gnus-visible-headers)
1823 gnus-visible-headers)
1824 ((and gnus-visible-headers
1825 (listp gnus-visible-headers))
1826 (mapconcat 'identity
1827 gnus-visible-headers
1831 ;; First we narrow to just the headers.
1832 (article-narrow-to-head)
1833 ;; Hide any "From " lines at the beginning of (mail) articles.
1834 (while (looking-at "From ")
1838 (delete-region (point-min) (point))
1839 (gnus-article-hide-text (point-min) (point)
1840 (nconc (list 'article-type 'headers)
1841 gnus-hidden-properties))))
1842 ;; Then treat the rest of the header lines.
1843 ;; Then we use the two regular expressions
1844 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1845 ;; select which header lines is to remain visible in the
1847 (while (re-search-forward "^[^ \t:]*:" nil t)
1849 ;; Mark the rank of the header.
1851 (point) (1+ (point)) 'message-rank
1852 (if (or (and visible (looking-at visible))
1854 (not (looking-at ignored))))
1855 (gnus-article-header-rank)
1858 (message-sort-headers-1)
1859 (when (setq beg (text-property-any
1860 (point-min) (point-max) 'message-rank (+ 2 max)))
1861 ;; We delete or make invisible the unwanted headers.
1862 (gnus-add-wash-type 'headers)
1865 (add-text-properties
1866 (point-min) (+ 5 (point-min))
1867 '(article-type headers dummy-invisible t))
1868 (delete-region beg (point-max)))
1869 (gnus-article-hide-text-type beg (point-max) 'headers)))))))))
1871 (defun article-hide-boring-headers (&optional arg)
1872 "Toggle hiding of headers that aren't very interesting.
1873 If given a negative prefix, always show; if given a positive prefix,
1875 (interactive (gnus-article-hidden-arg))
1876 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1877 (not gnus-show-all-headers))
1880 (let ((inhibit-read-only t)
1881 (inhibit-point-motion-hooks t))
1882 (article-narrow-to-head)
1883 (dolist (elem gnus-boring-article-headers)
1884 (goto-char (point-min))
1886 ;; Hide empty headers.
1888 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1890 (gnus-article-hide-text-type
1894 (if (re-search-forward "^[^ \t]" nil t)
1898 ;; Hide boring Newsgroups header.
1899 ((eq elem 'newsgroups)
1900 (when (gnus-string-equal
1901 (gnus-fetch-field "newsgroups")
1902 (gnus-group-real-name
1903 (if (boundp 'gnus-newsgroup-name)
1906 (gnus-article-hide-header "newsgroups")))
1907 ((eq elem 'to-address)
1908 (let ((to (message-fetch-field "to"))
1910 (gnus-parameter-to-address
1911 (if (boundp 'gnus-newsgroup-name)
1912 gnus-newsgroup-name ""))))
1913 (when (and to to-address
1916 ;; only one address in To
1917 (nth 1 (mail-extract-address-components to))
1919 (gnus-article-hide-header "to"))))
1921 (let ((to (message-fetch-field "to"))
1923 (gnus-parameter-to-list
1924 (if (boundp 'gnus-newsgroup-name)
1925 gnus-newsgroup-name ""))))
1926 (when (and to to-list
1929 ;; only one address in To
1930 (nth 1 (mail-extract-address-components to))
1932 (gnus-article-hide-header "to"))))
1934 (let ((cc (message-fetch-field "cc"))
1936 (gnus-parameter-to-list
1937 (if (boundp 'gnus-newsgroup-name)
1938 gnus-newsgroup-name ""))))
1939 (when (and cc to-list
1942 ;; only one address in CC
1943 (nth 1 (mail-extract-address-components cc))
1945 (gnus-article-hide-header "cc"))))
1946 ((eq elem 'followup-to)
1947 (when (gnus-string-equal
1948 (message-fetch-field "followup-to")
1949 (message-fetch-field "newsgroups"))
1950 (gnus-article-hide-header "followup-to")))
1951 ((eq elem 'reply-to)
1952 (if (gnus-group-find-parameter
1953 gnus-newsgroup-name 'broken-reply-to)
1954 (gnus-article-hide-header "reply-to")
1955 (let ((from (message-fetch-field "from"))
1956 (reply-to (message-fetch-field "reply-to")))
1963 (lambda (x) (downcase (cadr x)))
1964 (mail-extract-address-components from t))
1967 (lambda (x) (downcase (cadr x)))
1968 (mail-extract-address-components reply-to t))
1970 (gnus-article-hide-header "reply-to")))))
1972 (let ((date (message-fetch-field "date")))
1974 (< (days-between (current-time-string) date)
1976 (gnus-article-hide-header "date"))))
1978 (let ((to (message-fetch-field "to"))
1979 (cc (message-fetch-field "cc")))
1980 (when (> (length to) 1024)
1981 (gnus-article-hide-header "to"))
1982 (when (> (length cc) 1024)
1983 (gnus-article-hide-header "cc"))))
1987 (goto-char (point-min))
1988 (while (re-search-forward "^to:" nil t)
1989 (setq to-count (1+ to-count)))
1990 (when (> to-count 1)
1991 (while (> to-count 0)
1992 (goto-char (point-min))
1994 (re-search-forward "^to:" nil nil to-count)
1996 (narrow-to-region (point) (point-max))
1997 (gnus-article-hide-header "to"))
1998 (setq to-count (1- to-count))))
1999 (goto-char (point-min))
2000 (while (re-search-forward "^cc:" nil t)
2001 (setq cc-count (1+ cc-count)))
2002 (when (> cc-count 1)
2003 (while (> cc-count 0)
2004 (goto-char (point-min))
2006 (re-search-forward "^cc:" nil nil cc-count)
2008 (narrow-to-region (point) (point-max))
2009 (gnus-article-hide-header "cc"))
2010 (setq cc-count (1- cc-count)))))))))))))
2012 (defun gnus-article-hide-header (header)
2014 (goto-char (point-min))
2015 (when (re-search-forward (concat "^" header ":") nil t)
2016 (gnus-article-hide-text-type
2020 (if (re-search-forward "^[^ \t]" nil t)
2025 (defvar gnus-article-normalized-header-length 40
2026 "Length of normalized headers.")
2028 (defun article-normalize-headers ()
2029 "Make all header lines 40 characters long."
2031 (let ((inhibit-read-only t)
2035 (article-narrow-to-head)
2038 ((< (setq column (- (point-at-eol) (point)))
2039 gnus-article-normalized-header-length)
2041 (insert (make-string
2042 (- gnus-article-normalized-header-length column)
2044 ((> column gnus-article-normalized-header-length)
2045 (gnus-put-text-property
2047 (forward-char gnus-article-normalized-header-length)
2054 (forward-line 1))))))
2056 (defun article-treat-dumbquotes ()
2057 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
2058 Note that this function guesses whether a character is a sm*rtq**t* or
2059 not, so it should only be used interactively.
2061 Sm*rtq**t*s are M****s***'s unilateral extension to the
2062 iso-8859-1 character map in an attempt to provide more quoting
2063 characters. If you see something like \\222 or \\264 where
2064 you're expecting some kind of apostrophe or quotation mark, then
2067 (article-translate-strings gnus-article-dumbquotes-map))
2069 (defun article-translate-characters (from to)
2070 "Translate all characters in the body of the article according to FROM and TO.
2071 FROM is a string of characters to translate from; to is a string of
2072 characters to translate to."
2074 (when (article-goto-body)
2075 (let ((inhibit-read-only t)
2076 (x (make-string 225 ?x))
2078 (while (< (incf i) (length x))
2081 (while (< i (length from))
2082 (aset x (aref from i) (aref to i))
2084 (translate-region (point) (point-max) x)))))
2086 (defun article-translate-strings (map)
2087 "Translate all string in the body of the article according to MAP.
2088 MAP is an alist where the elements are on the form (\"from\" \"to\")."
2090 (when (article-goto-body)
2091 (let ((inhibit-read-only t))
2094 (while (search-forward (car elem) nil t)
2095 (replace-match (cadr elem)))))))))
2097 (defun article-treat-overstrike ()
2098 "Translate overstrikes into bold text."
2101 (when (article-goto-body)
2102 (let ((inhibit-read-only t))
2103 (while (search-forward "\b" nil t)
2104 (let ((next (char-after))
2108 previous (char-after))
2112 ;; We do the boldification/underlining by hiding the
2113 ;; overstrikes and putting the proper text property
2117 (gnus-article-hide-text-type start (point) 'overstrike)
2118 (put-text-property (point) end 'face 'bold))
2120 (gnus-article-hide-text-type
2121 (1- (point)) (1+ (point)) 'overstrike)
2123 start (1- (point)) 'face 'underline))
2125 (gnus-article-hide-text-type start (point) 'overstrike)
2127 (point) end 'face 'underline)))))))))
2129 (defun article-treat-ansi-sequences ()
2130 "Translate ANSI SGR control sequences into overlays or extents."
2133 (when (article-goto-body)
2134 (let ((inhibit-read-only t))
2135 (ansi-color-apply-on-region (point) (point-max))))))
2137 (defun gnus-article-treat-unfold-headers ()
2138 "Unfold folded message headers.
2139 Only the headers that fit into the current window width will be
2142 (gnus-with-article-headers
2146 (mail-header-narrow-to-field)
2147 (let ((header (buffer-string)))
2150 (goto-char (point-min))
2151 (while (re-search-forward "\n[\t ]" nil t)
2152 (replace-match " " t t)))
2153 (setq length (- (point-max) (point-min) 1)))
2154 (when (< length (window-width))
2155 (while (re-search-forward "\n[\t ]" nil t)
2156 (replace-match " " t t)))
2157 (goto-char (point-max)))))))
2159 (defun gnus-article-treat-fold-headers ()
2160 "Fold message headers."
2162 (gnus-with-article-headers
2165 (mail-header-narrow-to-field)
2166 (mail-header-fold-field)
2167 (goto-char (point-max))))))
2169 (defun gnus-treat-smiley ()
2170 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2172 (unless (featurep 'xemacs)
2173 (when (and (not gnus-article-should-use-smiley-mule)
2174 gnus-article-smiley-mule-loaded-p)
2175 (load "smiley" nil t)
2176 (setq gnus-article-smiley-mule-loaded-p nil))
2177 (when (and gnus-article-should-use-smiley-mule
2178 (not gnus-article-smiley-mule-loaded-p))
2179 (load "smiley-mule" nil t)
2180 (setq gnus-article-smiley-mule-loaded-p t)))
2181 (gnus-with-article-buffer
2182 (if (memq 'smiley gnus-article-wash-types)
2183 (gnus-delete-images 'smiley)
2185 (let ((images (smiley-region (point) (point-max))))
2187 (gnus-add-wash-type 'smiley)
2188 (dolist (image images)
2189 (gnus-add-image 'smiley image)))))))
2191 (defun gnus-article-remove-images ()
2192 "Remove all images from the article buffer."
2194 (gnus-with-article-buffer
2195 (dolist (elem gnus-article-image-alist)
2196 (gnus-delete-images (car elem)))))
2198 (defun gnus-article-treat-fold-newsgroups ()
2199 "Unfold folded message headers.
2200 Only the headers that fit into the current window width will be
2203 (gnus-with-article-headers
2204 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2206 (mail-header-narrow-to-field)
2207 (while (re-search-forward ", *" nil t)
2208 (replace-match ", " t t))
2209 (mail-header-fold-field)
2210 (goto-char (point-max))))))
2212 (defun gnus-article-treat-body-boundary ()
2213 "Place a boundary line at the end of the headers."
2215 (when (and gnus-body-boundary-delimiter
2216 (> (length gnus-body-boundary-delimiter) 0))
2217 (gnus-with-article-headers
2218 (goto-char (point-max))
2219 (let ((start (point)))
2220 (insert "X-Boundary: ")
2221 (gnus-add-text-properties start (point) '(invisible t intangible t))
2223 (while (>= (1- (window-width)) (length str))
2224 (setq str (concat str gnus-body-boundary-delimiter)))
2225 (substring str 0 (1- (window-width))))
2227 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2229 (defun article-fill-long-lines ()
2230 "Fill lines that are wider than the window width."
2233 (let ((inhibit-read-only t)
2234 (width (window-width (get-buffer-window (current-buffer)))))
2237 (let ((adaptive-fill-mode nil)) ;Why? -sm
2240 (when (>= (current-column) (min fill-column width))
2241 (narrow-to-region (min (1+ (point)) (point-max))
2243 (let ((goback (point-marker)))
2244 (fill-paragraph nil)
2245 (goto-char (marker-position goback)))
2247 (forward-line 1)))))))
2249 (defun article-capitalize-sentences ()
2250 "Capitalize the first word in each sentence."
2253 (let ((inhibit-read-only t)
2254 (paragraph-start "^[\n\^L]"))
2258 (forward-sentence)))))
2260 (defun article-remove-cr ()
2261 "Remove trailing CRs and then translate remaining CRs into LFs."
2264 (let ((inhibit-read-only t))
2265 (goto-char (point-min))
2266 (while (re-search-forward "\r+$" nil t)
2267 (replace-match "" t t))
2268 (goto-char (point-min))
2269 (while (search-forward "\r" nil t)
2270 (replace-match "\n" t t)))))
2272 (defun article-remove-trailing-blank-lines ()
2273 "Remove all trailing blank lines from the article."
2276 (let ((inhibit-read-only t))
2277 (goto-char (point-max))
2281 (while (and (not (bobp))
2282 (looking-at "^[ \t]*$")
2283 (not (gnus-annotation-in-region-p
2284 (point) (point-at-eol))))
2290 (defvar gnus-face-properties-alist))
2292 (defun article-display-face ()
2293 "Display any Face headers in the header."
2295 (let ((wash-face-p buffer-read-only))
2296 (gnus-with-article-headers
2297 ;; When displaying parts, this function can be called several times on
2298 ;; the same article, without any intended toggle semantic (as typing `W
2299 ;; D d' would have). So face deletion must occur only when we come from
2300 ;; an interactive command, that is when the *Article* buffer is
2302 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2303 (gnus-delete-images 'face)
2304 (let (face faces from)
2305 (save-current-buffer
2306 (when (and wash-face-p
2307 (gnus-buffer-live-p gnus-original-article-buffer)
2308 (not (re-search-forward "^Face:[\t ]*" nil t)))
2309 (set-buffer gnus-original-article-buffer))
2311 (mail-narrow-to-head)
2312 (while (gnus-article-goto-header "Face")
2313 (push (mail-header-field-value) faces))))
2315 (goto-char (point-min))
2316 (let ((from (gnus-article-goto-header "from"))
2321 (insert "[no `from' set]\n"))
2323 (when (setq png (gnus-convert-face-to-png (pop faces)))
2325 (apply 'gnus-create-image png 'png t
2326 (cdr (assq 'png gnus-face-properties-alist))))
2328 (gnus-add-wash-type 'face)
2329 (gnus-add-image 'face image)
2330 (gnus-put-image image nil 'face))))))))))
2332 (defun article-display-x-face (&optional force)
2333 "Look for an X-Face header and display it if present."
2334 (interactive (list 'force))
2335 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2336 (gnus-with-article-headers
2337 ;; Delete the old process, if any.
2338 (when (process-status "article-x-face")
2339 (delete-process "article-x-face"))
2340 ;; See the comment in `article-display-face'.
2341 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2342 ;; We have already displayed X-Faces, so we remove them
2344 (gnus-delete-images 'xface)
2346 (let (x-faces from face)
2347 (save-current-buffer
2348 (when (and wash-face-p
2349 (gnus-buffer-live-p gnus-original-article-buffer)
2350 (not (re-search-forward "^X-Face:[\t ]*" nil t)))
2351 ;; If type `W f', use gnus-original-article-buffer,
2352 ;; otherwise use the current buffer because displaying
2353 ;; RFC822 parts calls this function too.
2354 (set-buffer gnus-original-article-buffer))
2356 (mail-narrow-to-head)
2357 (while (gnus-article-goto-header "X-Face")
2358 (push (mail-header-field-value) x-faces))
2359 (setq from (message-fetch-field "from"))))
2360 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2361 ;; single external face.
2362 (when (stringp gnus-article-x-face-command)
2363 (setq x-faces (list (car x-faces))))
2365 gnus-article-x-face-command
2367 ;; Check whether this face is censored.
2368 (not gnus-article-x-face-too-ugly)
2370 (not (string-match gnus-article-x-face-too-ugly
2372 (while (setq face (pop x-faces))
2373 ;; We display the face.
2374 (cond ((stringp gnus-article-x-face-command)
2375 ;; The command is a string, so we interpret the command
2376 ;; as a, well, command, and fork it off.
2377 (let ((process-connection-type nil))
2378 (gnus-set-process-query-on-exit-flag
2380 "article-x-face" nil shell-file-name
2381 shell-command-switch gnus-article-x-face-command)
2385 (process-send-region "article-x-face"
2386 (point-min) (point-max)))
2387 (process-send-eof "article-x-face")))
2388 ((functionp gnus-article-x-face-command)
2389 ;; The command is a lisp function, so we call it.
2390 (funcall gnus-article-x-face-command face))
2392 (error "%s is not a function"
2393 gnus-article-x-face-command))))))))))
2395 (defun article-decode-mime-words ()
2396 "Decode all MIME-encoded words in the article."
2398 (gnus-with-article-buffer
2399 (let ((inhibit-point-motion-hooks t)
2400 (mail-parse-charset gnus-newsgroup-charset)
2401 (mail-parse-ignored-charsets
2402 (with-current-buffer gnus-summary-buffer
2403 gnus-newsgroup-ignored-charsets)))
2404 (mail-decode-encoded-word-region (point-min) (point-max)))))
2406 (defun article-decode-charset (&optional prompt)
2407 "Decode charset-encoded text in the article.
2408 If PROMPT (the prefix), prompt for a coding system to use."
2410 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2411 (inhibit-read-only t)
2412 (mail-parse-charset gnus-newsgroup-charset)
2413 (mail-parse-ignored-charsets
2414 (save-excursion (condition-case nil
2415 (set-buffer gnus-summary-buffer)
2417 gnus-newsgroup-ignored-charsets))
2418 ct cte ctl charset format)
2421 (article-narrow-to-head)
2422 (setq ct (message-fetch-field "Content-Type" t)
2423 cte (message-fetch-field "Content-Transfer-Encoding" t)
2424 ctl (and ct (ignore-errors
2425 (mail-header-parse-content-type ct)))
2428 (mm-read-coding-system "Charset to decode: "))
2430 (mail-content-type-get ctl 'charset)))
2431 format (and ctl (mail-content-type-get ctl 'format)))
2433 (setq cte (mail-header-strip cte)))
2434 (if (and ctl (not (string-match "/" (car ctl))))
2436 (goto-char (point-max)))
2439 (narrow-to-region (point) (point-max))
2440 (when (and (eq mail-parse-charset 'gnus-decoded)
2441 (eq (mm-body-7-or-8) '8bit))
2442 ;; The text code could have been decoded.
2443 (setq charset mail-parse-charset))
2444 (when (and (or (not ctl)
2445 (equal (car ctl) "text/plain"))
2446 (not format)) ;; article with format will decode later.
2448 charset (and cte (intern (downcase
2449 (gnus-strip-whitespace cte))))
2452 (defun article-decode-encoded-words ()
2453 "Remove encoded-word encoding from headers."
2454 (let ((charset (save-excursion
2455 (set-buffer gnus-summary-buffer)
2456 default-mime-charset))
2457 (inhibit-read-only t))
2458 (mime-decode-header-in-buffer charset)))
2460 (defun article-decode-group-name ()
2461 "Decode group names in `Newsgroups:'."
2462 (let ((inhibit-point-motion-hooks t)
2463 (inhibit-read-only t)
2464 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2465 (when (and (or gnus-group-name-charset-method-alist
2466 gnus-group-name-charset-group-alist)
2467 (gnus-buffer-live-p gnus-original-article-buffer))
2469 (article-narrow-to-head)
2470 (with-current-buffer gnus-original-article-buffer
2471 (goto-char (point-min)))
2472 (while (re-search-forward
2473 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2474 (replace-match (save-match-data
2475 (gnus-decode-newsgroups
2476 ;; XXX how to use data in article buffer?
2477 (with-current-buffer gnus-original-article-buffer
2479 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2482 gnus-newsgroup-name method))
2484 (goto-char (point-min))
2485 (with-current-buffer gnus-original-article-buffer
2486 (goto-char (point-min)))
2487 (while (re-search-forward
2488 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2489 (replace-match (save-match-data
2490 (gnus-decode-newsgroups
2491 ;; XXX how to use data in article buffer?
2492 (with-current-buffer gnus-original-article-buffer
2494 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2497 gnus-newsgroup-name method))
2500 (autoload 'idna-to-unicode "idna")
2502 (defun article-decode-idna-rhs ()
2503 "Decode IDNA strings in RHS in various headers in current buffer.
2504 The following headers are decoded: From:, To:, Cc:, Reply-To:,
2505 Mail-Reply-To: and Mail-Followup-To:."
2508 (let ((inhibit-point-motion-hooks t)
2509 (inhibit-read-only t))
2510 (article-narrow-to-head)
2511 (goto-char (point-min))
2512 (while (re-search-forward "@[^ \t\n\r,>]*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2514 (when (save-match-data
2515 (and (setq ace (match-string 1))
2517 (and (re-search-backward "^[^ \t]" nil t)
2518 (looking-at "From\\|To\\|Cc\\|Reply-To\\|Mail-Reply-To\\|Mail-Followup-To")))
2519 (setq unicode (idna-to-unicode ace))))
2520 (unless (string= ace unicode)
2521 (replace-match unicode nil nil nil 1)))))))))
2523 (defun article-de-quoted-unreadable (&optional force read-charset)
2524 "Translate a quoted-printable-encoded article.
2525 If FORCE, decode the article whether it is marked as quoted-printable
2527 If READ-CHARSET, ask for a coding system."
2528 (interactive (list 'force current-prefix-arg))
2530 (let ((inhibit-read-only t) type charset)
2531 (if (gnus-buffer-live-p gnus-original-article-buffer)
2532 (with-current-buffer gnus-original-article-buffer
2534 (gnus-fetch-field "content-transfer-encoding"))
2535 (let* ((ct (gnus-fetch-field "content-type"))
2538 (mail-header-parse-content-type ct)))))
2539 (setq charset (and ctl
2540 (mail-content-type-get ctl 'charset)))
2541 (if (stringp charset)
2542 (setq charset (intern (downcase charset)))))))
2544 (setq charset (mm-read-coding-system "Charset: " charset)))
2546 (setq charset gnus-newsgroup-charset))
2548 (and type (let ((case-fold-search t))
2549 (string-match "quoted-printable" type))))
2551 (quoted-printable-decode-region
2552 (point) (point-max) (mm-charset-to-coding-system charset))))))
2554 (defun article-de-base64-unreadable (&optional force read-charset)
2555 "Translate a base64 article.
2556 If FORCE, decode the article whether it is marked as base64 not.
2557 If READ-CHARSET, ask for a coding system."
2558 (interactive (list 'force current-prefix-arg))
2560 (let ((inhibit-read-only t) type charset)
2561 (if (gnus-buffer-live-p gnus-original-article-buffer)
2562 (with-current-buffer gnus-original-article-buffer
2564 (gnus-fetch-field "content-transfer-encoding"))
2565 (let* ((ct (gnus-fetch-field "content-type"))
2568 (mail-header-parse-content-type ct)))))
2569 (setq charset (and ctl
2570 (mail-content-type-get ctl 'charset)))
2571 (if (stringp charset)
2572 (setq charset (intern (downcase charset)))))))
2574 (setq charset (mm-read-coding-system "Charset: " charset)))
2576 (setq charset gnus-newsgroup-charset))
2578 (and type (let ((case-fold-search t))
2579 (string-match "base64" type))))
2582 (narrow-to-region (point) (point-max))
2583 (base64-decode-region (point-min) (point-max))
2584 (mm-decode-coding-region
2585 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2590 (defun article-decode-HZ ()
2591 "Translate a HZ-encoded article."
2595 (let ((inhibit-read-only t))
2596 (rfc1843-decode-region (point-min) (point-max)))))
2598 (defun article-unsplit-urls ()
2599 "Remove the newlines that some other mailers insert into URLs."
2602 (let ((inhibit-read-only t))
2603 (goto-char (point-min))
2604 (while (re-search-forward
2605 "\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2606 (replace-match "\\1\\3" t)))
2607 (when (interactive-p)
2608 (gnus-treat-article nil))))
2611 (defun article-wash-html (&optional read-charset)
2612 "Format an HTML article.
2613 If READ-CHARSET, ask for a coding system."
2616 (let ((inhibit-read-only t)
2618 (when (gnus-buffer-live-p gnus-original-article-buffer)
2619 (with-current-buffer gnus-original-article-buffer
2620 (let* ((ct (gnus-fetch-field "content-type"))
2623 (mail-header-parse-content-type ct)))))
2624 (setq charset (and ctl
2625 (mail-content-type-get ctl 'charset)))
2626 (when (stringp charset)
2627 (setq charset (intern (downcase charset)))))))
2629 (setq charset (mm-read-coding-system "Charset: " charset)))
2631 (setq charset gnus-newsgroup-charset))
2633 (save-window-excursion
2635 (narrow-to-region (point) (point-max))
2636 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2637 (entry (assq func mm-text-html-washer-alist)))
2639 (setq func (cdr entry)))
2644 (apply (car func) (cdr func))))))))))
2646 (defun gnus-article-wash-html-with-w3 ()
2647 "Wash the current buffer with w3."
2649 (let ((w3-strict-width (window-width))
2650 (url-standalone-mode t)
2651 (url-gateway-unplugged t)
2652 (w3-honor-stylesheets nil))
2654 (w3-region (point-min) (point-max))
2657 (defun gnus-article-wash-html-with-w3m ()
2658 "Wash the current buffer with emacs-w3m."
2661 (narrow-to-region (point) (point-max))
2662 (let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp)
2663 w3m-force-redisplay)
2664 (w3m-region (point-min) (point-max)))
2665 (when (and mm-inline-text-html-with-w3m-keymap
2666 (boundp 'w3m-minor-mode-map)
2668 (add-text-properties
2669 (point-min) (point-max)
2670 (list 'keymap w3m-minor-mode-map
2671 ;; Put the mark meaning this part was rendered by emacs-w3m.
2672 'mm-inline-text-html-with-w3m t)))))
2674 (defun article-hide-list-identifiers ()
2675 "Remove list identifies from the Subject header.
2676 The `gnus-list-identifiers' variable specifies what to do."
2678 (let ((inhibit-point-motion-hooks t)
2679 (regexp (if (consp gnus-list-identifiers)
2680 (mapconcat 'identity gnus-list-identifiers " *\\|")
2681 gnus-list-identifiers))
2682 (inhibit-read-only t))
2686 (article-narrow-to-head)
2687 (goto-char (point-min))
2688 (while (re-search-forward
2689 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2691 (delete-region (match-beginning 2) (match-end 0))
2692 (beginning-of-line))
2693 (when (re-search-forward
2694 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2695 (delete-region (match-beginning 1) (match-end 1))))))))
2697 (defun article-hide-pem (&optional arg)
2698 "Toggle hiding of any PEM headers and signatures in the current article.
2699 If given a negative prefix, always show; if given a positive prefix,
2701 (interactive (gnus-article-hidden-arg))
2702 (unless (gnus-article-check-hidden-text 'pem arg)
2704 (let ((inhibit-read-only t) end)
2705 (goto-char (point-min))
2706 ;; Hide the horrendously ugly "header".
2707 (when (and (search-forward
2708 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2710 (setq end (1+ (match-beginning 0))))
2711 (gnus-add-wash-type 'pem)
2712 (gnus-article-hide-text-type
2714 (if (search-forward "\n\n" nil t)
2718 ;; Hide the trailer as well
2719 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2721 (gnus-article-hide-text-type
2722 (match-beginning 0) (match-end 0) 'pem)))))))
2724 (defun article-strip-banner ()
2725 "Strip the banners specified by the `banner' group parameter and by
2726 `gnus-article-address-banner-alist'."
2730 (let ((inhibit-point-motion-hooks t))
2731 (when (gnus-parameter-banner gnus-newsgroup-name)
2732 (article-really-strip-banner
2733 (gnus-parameter-banner gnus-newsgroup-name)))
2734 (when gnus-article-address-banner-alist
2735 ;; It is necessary to encode from fields before checking,
2736 ;; because `mail-header-parse-addresses' does not work
2737 ;; (reliably) on decoded headers. And more, it is
2738 ;; impossible to use `gnus-fetch-original-field' here,
2739 ;; because `article-strip-banner' may be called in draft
2740 ;; buffers to preview them.
2741 (let ((from (save-restriction
2743 (article-narrow-to-head)
2744 (mail-fetch-field "from"))))
2747 (caar (mail-header-parse-addresses
2748 (mail-encode-encoded-word-string from)))))
2750 (dolist (pair gnus-article-address-banner-alist)
2751 (when (string-match (car pair) from)
2753 (article-really-strip-banner (cdr pair)))))))))))))
2755 (defun article-really-strip-banner (banner)
2756 "Strip the banner specified by the argument."
2759 (let ((inhibit-point-motion-hooks t)
2760 (gnus-signature-limit nil)
2761 (inhibit-read-only t))
2764 ((eq banner 'signature)
2765 (when (gnus-article-narrow-to-signature)
2768 (delete-region (point) (point-max))))
2770 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2771 (while (re-search-forward banner nil t)
2772 (delete-region (match-beginning 0) (match-end 0)))))
2774 (while (re-search-forward banner nil t)
2775 (delete-region (match-beginning 0) (match-end 0)))))))))
2777 (defun article-babel ()
2778 "Translate article using an online translation service."
2781 (gnus-with-article-buffer
2782 (when (article-goto-body)
2783 (let* ((start (point))
2785 (orig (buffer-substring start end))
2786 (trans (babel-as-string orig)))
2788 (narrow-to-region start end)
2789 (delete-region start end)
2792 (defun article-hide-signature (&optional arg)
2793 "Hide the signature in the current article.
2794 If given a negative prefix, always show; if given a positive prefix,
2796 (interactive (gnus-article-hidden-arg))
2802 (article-goto-body))
2803 (goto-char (point-min)))
2804 (unless (gnus-article-check-hidden-text 'signature arg)
2805 (let ((inhibit-read-only t)
2807 (while (setq button (text-property-any button (point-max)
2809 'gnus-signature-toggle))
2810 (setq button (text-property-not-all button (point-max)
2812 'gnus-signature-toggle))
2813 (when (and button (not (eobp)))
2814 (gnus-article-hide-text-type
2816 (next-single-property-change (1+ button) 'mime-view-entity
2819 (gnus-set-mode-line 'article))
2821 (defun article-strip-headers-in-body ()
2822 "Strip offensive headers from bodies."
2826 (let ((case-fold-search t))
2827 (when (looking-at "x-no-archive:")
2828 (gnus-delete-line)))))
2830 (defun article-strip-leading-blank-lines ()
2831 "Remove all blank lines from the beginning of the article."
2834 (let ((inhibit-point-motion-hooks t)
2835 (inhibit-read-only t))
2836 (when (article-goto-body)
2837 (while (and (not (eobp))
2838 (looking-at "[ \t]*$"))
2839 (gnus-delete-line))))))
2841 (defun article-narrow-to-head ()
2842 "Narrow the buffer to the head of the message.
2843 Point is left at the beginning of the narrowed-to region."
2845 (goto-char (point-min))
2846 (if (search-forward "\n\n" nil 1)
2849 (goto-char (point-min)))
2851 (defun article-goto-body ()
2852 "Place point at the start of the body."
2853 (goto-char (point-min))
2855 ;; This variable is only bound when dealing with separate
2857 (article-goto-body-goes-to-point-min-p
2859 ((search-forward "\n\n" nil t)
2862 (goto-char (point-max))
2865 (defun article-strip-multiple-blank-lines ()
2866 "Replace consecutive blank lines with one empty line."
2869 (let ((inhibit-point-motion-hooks t)
2870 (inhibit-read-only t))
2871 ;; First make all blank lines empty.
2873 (while (re-search-forward "^[ \t]+$" nil t)
2874 (unless (gnus-annotation-in-region-p
2875 (match-beginning 0) (match-end 0))
2876 (replace-match "" nil t)))
2877 ;; Then replace multiple empty lines with a single empty line.
2879 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2880 (unless (gnus-annotation-in-region-p
2881 (match-beginning 0) (match-end 0))
2882 (delete-region (match-beginning 1) (match-end 1)))))))
2884 (defun article-strip-leading-space ()
2885 "Remove all white space from the beginning of the lines in the article."
2888 (let ((inhibit-point-motion-hooks t)
2889 (inhibit-read-only t))
2891 (while (re-search-forward "^[ \t]+" nil t)
2892 (replace-match "" t t)))))
2894 (defun article-strip-trailing-space ()
2895 "Remove all white space from the end of the lines in the article."
2898 (let ((inhibit-point-motion-hooks t)
2899 (inhibit-read-only t))
2901 (while (re-search-forward "[ \t]+$" nil t)
2902 (replace-match "" t t)))))
2904 (defun article-strip-blank-lines ()
2905 "Strip leading, trailing and multiple blank lines."
2907 (article-strip-leading-blank-lines)
2908 (article-remove-trailing-blank-lines)
2909 (article-strip-multiple-blank-lines))
2911 (defun article-strip-all-blank-lines ()
2912 "Strip all blank lines."
2915 (let ((inhibit-point-motion-hooks t)
2916 (inhibit-read-only t))
2918 (while (re-search-forward "^[ \t]*\n" nil t)
2919 (replace-match "" t t)))))
2921 (defun gnus-article-narrow-to-signature ()
2922 "Narrow to the signature; return t if a signature is found, else nil."
2923 (let ((inhibit-point-motion-hooks t))
2924 (when (gnus-article-search-signature)
2926 ;; Check whether we have some limits to what we consider
2927 ;; to be a signature.
2928 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2929 (list gnus-signature-limit)))
2931 (while (setq limit (pop limits))
2932 (if (or (and (integerp limit)
2933 (< (- (point-max) (point)) limit))
2935 (< (count-lines (point) (point-max)) limit))
2936 (and (functionp limit)
2938 (and (stringp limit)
2939 (not (re-search-forward limit nil t))))
2940 () ; This limit did not succeed.
2944 (narrow-to-region (point) (point-max))
2947 (defun gnus-article-search-signature ()
2948 "Search the current buffer for the signature separator.
2949 Put point at the beginning of the signature separator."
2950 (let ((cur (point)))
2951 (goto-char (point-max))
2952 (if (if (stringp gnus-signature-separator)
2953 (re-search-backward gnus-signature-separator nil t)
2954 (let ((seps gnus-signature-separator))
2956 (not (re-search-backward (car seps) nil t)))
2963 (defun gnus-article-hidden-arg ()
2964 "Return the current prefix arg as a number, or 0 if no prefix."
2965 (list (if current-prefix-arg
2966 (prefix-numeric-value current-prefix-arg)
2969 (defun gnus-article-check-hidden-text (type arg)
2970 "Return nil if hiding is necessary.
2971 Arg can be nil or a number. nil and positive means hide, negative
2972 means show, 0 means toggle."
2975 (let ((hide (gnus-article-hidden-text-p type)))
2981 (gnus-article-show-hidden-text type)
2984 (if (eq hide 'hidden)
2986 (gnus-article-show-hidden-text type)
2990 (defun gnus-article-hidden-text-p (type)
2991 "Say whether the current buffer contains hidden text of type TYPE."
2992 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2994 (not (get-text-property pos 'invisible))
2995 (not (get-text-property pos 'dummy-invisible)))
2997 (text-property-any (1+ pos) (point-max) 'article-type type)))
3002 (defun gnus-article-show-hidden-text (type &optional dummy)
3003 "Show all hidden text of type TYPE.
3004 Originally it is hide instead of DUMMY."
3005 (let ((inhibit-read-only t)
3006 (inhibit-point-motion-hooks t))
3007 (gnus-remove-text-properties-when
3009 (point-min) (point-max)
3010 (cons 'article-type (cons type
3011 gnus-hidden-properties)))
3012 (gnus-delete-wash-type type)))
3014 (defconst article-time-units
3015 `((year . ,(* 365.25 24 60 60))
3016 (week . ,(* 7 24 60 60))
3017 (day . ,(* 24 60 60))
3021 "Mapping from time units to seconds.")
3023 (defun gnus-article-forward-header ()
3024 "Move point to the start of the next header.
3025 If the current header is a continuation header, this can be several
3030 (if (looking-at "[ \t]+[^ \t]")
3034 (defun article-date-ut (&optional type highlight)
3035 "Convert DATE date to universal time in the current article.
3036 If TYPE is `local', convert to local time; if it is `lapsed', output
3037 how much time has lapsed since DATE. For `lapsed', the value of
3038 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
3039 should replace the \"Date:\" one, or should be added below it."
3040 (interactive (list 'ut t))
3041 (let* ((tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
3042 (date-regexp (cond ((not gnus-article-date-lapsed-new-header)
3046 (article-lapsed-timer
3050 (case-fold-search t)
3051 (inhibit-read-only t)
3052 (inhibit-point-motion-hooks t)
3053 pos date bface eface)
3057 (goto-char (point-min))
3058 (while (or (setq date (get-text-property (setq pos (point))
3060 (when (setq pos (next-single-property-change
3061 (point) 'original-date))
3062 (setq date (get-text-property pos 'original-date))
3064 (narrow-to-region pos (or (text-property-any pos (point-max)
3067 (goto-char (point-min))
3068 (when (re-search-forward tdate-regexp nil t)
3069 (setq bface (get-text-property (point-at-bol) 'face)
3070 eface (get-text-property (1- (point-at-eol)) 'face)))
3071 (goto-char (point-min))
3073 ;; Delete any old Date headers.
3074 (while (re-search-forward date-regexp nil t)
3076 (delete-region (point-at-bol) (progn
3077 (gnus-article-forward-header)
3079 (delete-region (point-at-bol) (progn
3080 (gnus-article-forward-header)
3083 (setq pos (point))))
3084 (when (and (not pos)
3085 (re-search-forward tdate-regexp nil t))
3087 (gnus-goto-char pos)
3088 (insert (article-make-date-line date (or type 'ut)))
3094 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
3095 (put-text-property (match-beginning 1) (1+ (match-end 1))
3097 (put-text-property (match-beginning 2) (match-end 2)
3099 (put-text-property (point-min) (1- (point-max)) 'original-date date)
3100 (goto-char (point-max))
3103 (defun article-make-date-line (date type)
3104 "Return a DATE line of TYPE."
3105 (unless (memq type '(local ut original user iso8601 lapsed english))
3106 (error "Unknown conversion type: %s" type))
3108 (let ((time (date-to-time date)))
3110 ;; Convert to the local timezone.
3112 (concat "Date: " (message-make-date time)))
3113 ;; Convert to Universal Time.
3118 (let* ((e (parse-time-string date))
3119 (tm (apply 'encode-time e))
3121 (ls (- (cadr tm) (car (current-time-zone time)))))
3122 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
3123 ((> ls 65535) (list (1+ ms) (- ls 65536)))
3127 ;; Get the original date from the article.
3128 ((eq type 'original)
3129 (concat "Date: " (if (string-match "\n+$" date)
3130 (substring date 0 (match-beginning 0))
3132 ;; Let the user define the format.
3134 (let ((format (or (condition-case nil
3135 (with-current-buffer gnus-summary-buffer
3136 gnus-article-time-format)
3138 gnus-article-time-format)))
3139 (if (functionp format)
3140 (funcall format time)
3141 (concat "Date: " (format-time-string format time)))))
3144 (let ((tz (car (current-time-zone time))))
3147 (format-time-string "%Y%m%dT%H%M%S" time)
3148 (format "%s%02d%02d"
3149 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
3150 (/ (% (abs tz) 3600) 60)))))
3151 ;; Do an X-Sent lapsed format.
3153 ;; If the date is seriously mangled, the timezone functions are
3154 ;; liable to bug out, so we ignore all errors.
3155 (let* ((now (current-time))
3156 (real-time (subtract-time now time))
3157 (real-sec (and real-time
3158 (+ (* (float (car real-time)) 65536)
3160 (sec (and real-time (abs real-sec)))
3170 ;; This is a bit convoluted, but basically we go
3171 ;; through the time units for years, weeks, etc,
3172 ;; and divide things to see whether that results
3173 ;; in positive answers.
3176 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
3177 ;; The (remaining) seconds are too few to
3178 ;; be divided into this time unit.
3180 ;; It's big enough, so we output it.
3181 (setq sec (- sec (* num (cdr unit))))
3183 (concat (if prev ", " "") (int-to-string
3185 " " (symbol-name (car unit))
3186 (if (> num 1) "s" ""))
3188 article-time-units "")
3189 ;; If dates are odd, then it might appear like the
3190 ;; article was sent in the future.
3193 " in the future"))))))
3194 ;; Display the date in proper English
3196 (let ((dtime (decode-time time)))
3199 (number-to-string (nth 3 dtime))
3200 (let ((digit (% (nth 3 dtime) 10)))
3202 ((memq (nth 3 dtime) '(11 12 13)) "th")
3208 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3210 (number-to-string (nth 5 dtime))
3212 (format "%02d" (nth 2 dtime))
3214 (format "%02d" (nth 1 dtime)))))))
3216 (format "Date: %s (from T-gnus)" date))))
3218 (defun article-date-local (&optional highlight)
3219 "Convert the current article date to the local timezone."
3220 (interactive (list t))
3221 (article-date-ut 'local highlight))
3223 (defun article-date-english (&optional highlight)
3224 "Convert the current article date to something that is proper English."
3225 (interactive (list t))
3226 (article-date-ut 'english highlight))
3228 (defun article-date-original (&optional highlight)
3229 "Convert the current article date to what it was originally.
3230 This is only useful if you have used some other date conversion
3231 function and want to see what the date was before converting."
3232 (interactive (list t))
3233 (article-date-ut 'original highlight))
3235 (defun article-date-lapsed (&optional highlight)
3236 "Convert the current article date to time lapsed since it was sent."
3237 (interactive (list t))
3238 (article-date-ut 'lapsed highlight))
3240 (defun article-update-date-lapsed ()
3241 "Function to be run from a timer to update the lapsed time line."
3243 (let (deactivate-mark)
3248 (set-buffer (window-buffer w))
3249 (when (or (and (eq major-mode 'mime-view-mode)
3250 (eq (mime-preview-original-major-mode)
3251 'gnus-original-article-mode))
3252 (eq major-mode 'gnus-article-mode))
3253 (let ((mark (point-marker)))
3254 (goto-char (point-min))
3255 (when (re-search-forward "^X-Sent:" nil t)
3256 (article-date-lapsed t))
3257 (goto-char (marker-position mark))
3258 (move-marker mark nil))))
3261 (defun gnus-start-date-timer (&optional n)
3262 "Start a timer to update the X-Sent header in the article buffers.
3263 The numerical prefix says how frequently (in seconds) the function
3268 (gnus-stop-date-timer)
3269 (setq article-lapsed-timer
3270 (run-at-time 1 n 'article-update-date-lapsed)))
3272 (defun gnus-stop-date-timer ()
3273 "Stop the X-Sent timer."
3275 (when article-lapsed-timer
3276 (nnheader-cancel-timer article-lapsed-timer)
3277 (setq article-lapsed-timer nil)))
3279 (defun article-date-user (&optional highlight)
3280 "Convert the current article date to the user-defined format.
3281 This format is defined by the `gnus-article-time-format' variable."
3282 (interactive (list t))
3283 (article-date-ut 'user highlight))
3285 (defun article-date-iso8601 (&optional highlight)
3286 "Convert the current article date to ISO8601."
3287 (interactive (list t))
3288 (article-date-ut 'iso8601 highlight))
3290 (defmacro gnus-article-save-original-date (&rest forms)
3291 "Save the original date as a text property and evaluate FORMS."
3292 `(let* ((case-fold-search t)
3294 (goto-char (point-min))
3295 (when (and (re-search-forward "^date:[\t\n ]+" nil t)
3298 (date (when (and start
3299 (re-search-forward "[\t ]*\n\\(?:[^\t ]\\|\\'\\)"
3301 (buffer-substring-no-properties start
3302 (match-beginning 0)))))
3303 (goto-char (point-max))
3304 (skip-chars-backward "\n")
3305 (put-text-property (point-min) (point) 'original-date date)
3307 (goto-char (point-max))
3308 (skip-chars-backward "\n")
3309 (put-text-property (point-min) (point) 'original-date date)))
3311 ;; (defun article-show-all ()
3312 ;; "Show all hidden text in the article buffer."
3316 ;; (let ((inhibit-read-only t))
3317 ;; (gnus-article-unhide-text (point-min) (point-max))
3318 ;; (gnus-remove-text-with-property 'gnus-prev)
3319 ;; (gnus-remove-text-with-property 'gnus-next))))
3321 (defun article-show-all-headers ()
3322 "Show all hidden headers in the article buffer."
3327 (article-narrow-to-head)
3328 (let ((inhibit-read-only t))
3329 (gnus-article-unhide-text (point-min) (point-max))))))
3331 (defun article-remove-leading-whitespace ()
3332 "Remove excessive whitespace from all headers."
3336 (let ((inhibit-read-only t))
3337 (article-narrow-to-head)
3338 (goto-char (point-min))
3339 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3340 (delete-region (match-beginning 1) (match-end 1)))))))
3342 (defun article-emphasize (&optional arg)
3343 "Emphasize text according to `gnus-emphasis-alist'."
3344 (interactive (gnus-article-hidden-arg))
3345 (unless (gnus-article-check-hidden-text 'emphasis arg)
3349 (with-current-buffer gnus-summary-buffer
3350 gnus-article-emphasis-alist)
3352 gnus-emphasis-alist))
3353 (inhibit-read-only t)
3354 (props (append '(article-type emphasis)
3355 gnus-hidden-properties))
3356 regexp elem beg invisible visible face)
3359 (while (setq elem (pop alist))
3361 (setq regexp (car elem)
3362 invisible (nth 1 elem)
3363 visible (nth 2 elem)
3365 (while (re-search-forward regexp nil t)
3366 (when (and (match-beginning visible) (match-beginning invisible))
3367 (gnus-article-hide-text
3368 (match-beginning invisible) (match-end invisible) props)
3369 (gnus-article-unhide-text-type
3370 (match-beginning visible) (match-end visible) 'emphasis)
3371 (gnus-put-overlay-excluding-newlines
3372 (match-beginning visible) (match-end visible) 'face face)
3373 (gnus-add-wash-type 'emphasis)
3374 (goto-char (match-end invisible)))))))))
3376 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3377 "Setup newsgroup emphasis alist."
3378 (unless gnus-article-emphasis-alist
3379 (let ((name (and gnus-newsgroup-name
3380 (gnus-group-real-name gnus-newsgroup-name))))
3381 (make-local-variable 'gnus-article-emphasis-alist)
3382 (setq gnus-article-emphasis-alist
3384 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3385 (while (setq elem (pop alist))
3386 (when (and name (string-match (car elem) name))
3388 highlight (copy-sequence (cdr elem)))))
3390 (copy-sequence highlight-words)
3391 (if gnus-newsgroup-name
3392 (copy-sequence (gnus-group-find-parameter
3393 gnus-newsgroup-name 'highlight-words t)))
3394 gnus-emphasis-alist)))))
3397 (defvar gnus-summary-article-menu)
3398 (defvar gnus-summary-post-menu))
3400 ;;; Saving functions.
3402 (defun gnus-article-save (save-buffer file &optional num)
3403 "Save the currently selected article."
3404 (unless gnus-save-all-headers
3405 ;; Remove headers according to `gnus-saved-headers'.
3406 (let ((gnus-visible-headers
3407 (or gnus-saved-headers gnus-visible-headers))
3408 (gnus-article-buffer save-buffer))
3410 (set-buffer save-buffer)
3411 (article-hide-headers 1 t))))
3412 (save-window-excursion
3413 (if (not gnus-default-article-saver)
3414 (error "No default saver is defined")
3415 ;; !!! Magic! The saving functions all save
3416 ;; `gnus-save-article-buffer' (or so they think), but we
3417 ;; bind that variable to our save-buffer.
3418 (set-buffer gnus-article-buffer)
3419 (let* ((gnus-save-article-buffer save-buffer)
3422 ((not gnus-prompt-before-saving) 'default)
3423 ((eq gnus-prompt-before-saving 'always) nil)
3425 (gnus-number-of-articles-to-be-saved
3426 (when (eq gnus-prompt-before-saving t)
3428 (set-buffer gnus-article-current-summary)
3429 (funcall gnus-default-article-saver filename)))))
3431 (defun gnus-read-save-file-name (prompt &optional filename
3432 function group headers variable)
3434 (funcall function group headers (symbol-value variable)))
3439 ((eq filename 'default)
3445 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3448 (if (and gnus-number-of-articles-to-be-saved
3449 (> gnus-number-of-articles-to-be-saved 1))
3450 (format "these %d articles"
3451 gnus-number-of-articles-to-be-saved)
3454 ;; Let the split methods have their say.
3456 ;; No split name was found.
3459 (concat prompt " (default "
3460 (file-name-nondirectory default-name) "): ")
3461 (file-name-directory default-name)
3463 ;; A single group name is returned.
3464 ((stringp split-name)
3466 (funcall function split-name headers
3467 (symbol-value variable)))
3469 (concat prompt " (default "
3470 (file-name-nondirectory default-name) "): ")
3471 (file-name-directory default-name)
3473 ;; A single split name was found
3474 ((= 1 (length split-name))
3475 (let* ((name (expand-file-name
3477 gnus-article-save-directory))
3478 (dir (cond ((file-directory-p name)
3479 (file-name-as-directory name))
3480 ((file-exists-p name) name)
3481 (t gnus-article-save-directory))))
3483 (concat prompt " (default " name "): ")
3485 ;; A list of splits was found.
3487 (setq split-name (nreverse split-name))
3489 (let ((file-name-history
3490 (nconc split-name file-name-history)))
3494 (concat prompt " (`M-p' for defaults): ")
3495 gnus-article-save-directory
3497 gnus-article-save-directory)))
3498 (car (push result file-name-history)))))))
3499 ;; Create the directory.
3500 (gnus-make-directory (file-name-directory file))
3501 ;; If we have read a directory, we append the default file name.
3502 (when (file-directory-p file)
3503 (setq file (expand-file-name (file-name-nondirectory
3505 (file-name-as-directory file))))
3506 ;; Possibly translate some characters.
3507 (nnheader-translate-file-chars file))))))
3508 (gnus-make-directory (file-name-directory result))
3509 (set variable result)))
3511 (defun gnus-article-archive-name (group)
3512 "Return the first instance of an \"Archive-name\" in the current buffer."
3513 (let ((case-fold-search t))
3514 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3515 (nnheader-concat gnus-article-save-directory
3516 (match-string 1)))))
3518 (defun gnus-article-nndoc-name (group)
3519 "If GROUP is an nndoc group, return the name of the parent group."
3520 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3521 (gnus-group-get-parameter group 'save-article-group)))
3523 (defun gnus-summary-save-in-rmail (&optional filename)
3524 "Append this article to Rmail file.
3525 Optional argument FILENAME specifies file name.
3526 Directory to save to is default to `gnus-article-save-directory'."
3527 (setq filename (gnus-read-save-file-name
3528 "Save %s in rmail file" filename
3529 gnus-rmail-save-name gnus-newsgroup-name
3530 gnus-current-headers 'gnus-newsgroup-last-rmail))
3531 (gnus-eval-in-buffer-window gnus-save-article-buffer
3535 (gnus-output-to-rmail filename))))
3538 (defun gnus-summary-save-in-mail (&optional filename)
3539 "Append this article to Unix mail file.
3540 Optional argument FILENAME specifies file name.
3541 Directory to save to is default to `gnus-article-save-directory'."
3542 (setq filename (gnus-read-save-file-name
3543 "Save %s in Unix mail file" filename
3544 gnus-mail-save-name gnus-newsgroup-name
3545 gnus-current-headers 'gnus-newsgroup-last-mail))
3546 (gnus-eval-in-buffer-window gnus-save-article-buffer
3550 (if (and (file-readable-p filename)
3551 (file-regular-p filename)
3552 (mail-file-babyl-p filename))
3553 (rmail-output-to-rmail-file filename t)
3554 (gnus-output-to-mail filename)))))
3557 (defun gnus-summary-save-in-file (&optional filename overwrite)
3558 "Append this article to file.
3559 Optional argument FILENAME specifies file name.
3560 Directory to save to is default to `gnus-article-save-directory'."
3561 (setq filename (gnus-read-save-file-name
3562 "Save %s in file" filename
3563 gnus-file-save-name gnus-newsgroup-name
3564 gnus-current-headers 'gnus-newsgroup-last-file))
3565 (gnus-eval-in-buffer-window gnus-save-article-buffer
3569 (when (and overwrite
3570 (file-exists-p filename))
3571 (delete-file filename))
3572 (gnus-output-to-file filename))))
3575 (defun gnus-summary-write-to-file (&optional filename)
3576 "Write this article to a file, overwriting it if the file exists.
3577 Optional argument FILENAME specifies file name.
3578 The directory to save in defaults to `gnus-article-save-directory'."
3579 (gnus-summary-save-in-file nil t))
3581 (defun gnus-summary-save-body-in-file (&optional filename)
3582 "Append this article body to a file.
3583 Optional argument FILENAME specifies file name.
3584 The directory to save in defaults to `gnus-article-save-directory'."
3585 (setq filename (gnus-read-save-file-name
3586 "Save %s body in file" filename
3587 gnus-file-save-name gnus-newsgroup-name
3588 gnus-current-headers 'gnus-newsgroup-last-file))
3589 (gnus-eval-in-buffer-window gnus-save-article-buffer
3593 (when (article-goto-body)
3594 (narrow-to-region (point) (point-max)))
3595 (gnus-output-to-file filename))))
3598 (defun gnus-summary-save-in-pipe (&optional command)
3599 "Pipe this article to subprocess."
3601 (cond ((and (eq command 'default)
3602 gnus-last-shell-command)
3603 gnus-last-shell-command)
3608 "Shell command on %s: "
3609 (if (and gnus-number-of-articles-to-be-saved
3610 (> gnus-number-of-articles-to-be-saved 1))
3611 (format "these %d articles"
3612 gnus-number-of-articles-to-be-saved)
3614 gnus-last-shell-command))))
3615 (when (string-equal command "")
3616 (if gnus-last-shell-command
3617 (setq command gnus-last-shell-command)
3618 (error "A command is required")))
3619 (gnus-eval-in-buffer-window gnus-article-buffer
3622 (shell-command-on-region (point-min) (point-max) command nil)))
3623 (setq gnus-last-shell-command command))
3625 (defun gnus-summary-pipe-to-muttprint (&optional command)
3626 "Pipe this article to muttprint."
3627 (setq command (read-string
3628 "Print using command: " gnus-summary-muttprint-program
3629 nil gnus-summary-muttprint-program))
3630 (gnus-summary-save-in-pipe command))
3632 ;;; Article file names when saving.
3634 (defun gnus-capitalize-newsgroup (newsgroup)
3635 "Capitalize NEWSGROUP name."
3636 (when (not (zerop (length newsgroup)))
3637 (concat (char-to-string (upcase (aref newsgroup 0)))
3638 (substring newsgroup 1))))
3640 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3641 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3642 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3643 Otherwise, it is like ~/News/news/group/num."
3646 (concat (if (gnus-use-long-file-name 'not-save)
3647 (gnus-capitalize-newsgroup newsgroup)
3648 (gnus-newsgroup-directory-form newsgroup))
3649 "/" (int-to-string (mail-header-number headers)))
3650 gnus-article-save-directory)))
3652 (string-equal (file-name-directory default)
3653 (file-name-directory last-file))
3654 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3656 (or last-file default))))
3658 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3659 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3660 If variable `gnus-use-long-file-name' is non-nil, it is
3661 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3664 (concat (if (gnus-use-long-file-name 'not-save)
3666 (gnus-newsgroup-directory-form newsgroup))
3667 "/" (int-to-string (mail-header-number headers)))
3668 gnus-article-save-directory)))
3670 (string-equal (file-name-directory default)
3671 (file-name-directory last-file))
3672 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3674 (or last-file default))))
3676 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3677 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3678 If variable `gnus-use-long-file-name' is non-nil, it is
3679 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3682 (if (gnus-use-long-file-name 'not-save)
3685 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3687 gnus-article-save-directory)))
3689 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3690 "Generate file name from sender."
3691 (let ((from (mail-header-from headers)))
3693 (if (and from (string-match "\\([^ <]+\\)@" from))
3694 (match-string 1 from)
3696 gnus-article-save-directory)))
3698 (defun article-verify-x-pgp-sig ()
3701 (if (gnus-buffer-live-p gnus-original-article-buffer)
3702 (let ((sig (with-current-buffer gnus-original-article-buffer
3703 (gnus-fetch-field "X-PGP-Sig")))
3707 (mml2015-clear-verify-function))
3709 (insert-buffer-substring gnus-original-article-buffer)
3710 (setq items (split-string sig))
3711 (message-narrow-to-head)
3712 (let ((inhibit-point-motion-hooks t)
3713 (case-fold-search t))
3714 ;; Don't verify multiple headers.
3715 (setq headers (mapconcat (lambda (header)
3717 (mail-fetch-field header)
3719 (split-string (nth 1 items) ",") "")))
3720 (delete-region (point-min) (point-max))
3721 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3722 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3727 (if (looking-at "^-")
3730 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3731 (insert "Version: " (car items) "\n\n")
3732 (insert (mapconcat 'identity (cddr items) "\n"))
3733 (insert "\n-----END PGP SIGNATURE-----\n")
3734 (let ((mm-security-handle (list (format "multipart/signed"))))
3735 (mml2015-clean-buffer)
3736 (let ((coding-system-for-write (or gnus-newsgroup-charset
3738 (funcall (mml2015-clear-verify-function)))
3740 (or (mm-handle-multipart-ctl-parameter
3741 mm-security-handle 'gnus-details)
3742 (mm-handle-multipart-ctl-parameter
3743 mm-security-handle 'gnus-info)))))
3745 (let ((inhibit-read-only t) bface eface)
3747 (message-narrow-to-head)
3748 (goto-char (point-max))
3750 (setq bface (get-text-property (point-at-bol) 'face)
3751 eface (get-text-property (1- (point-at-eol)) 'face))
3752 (message-remove-header "X-Gnus-PGP-Verify")
3753 (if (re-search-forward "^X-PGP-Sig:" nil t)
3755 (goto-char (point-max)))
3756 (narrow-to-region (point) (point))
3757 (insert "X-Gnus-PGP-Verify: " info "\n")
3758 (goto-char (point-min))
3761 (if (not (looking-at "^[ \t]"))
3765 (goto-char (point-min))
3766 (when (looking-at "\\([^:]+\\): *")
3767 (put-text-property (match-beginning 1) (1+ (match-end 1))
3769 (put-text-property (match-end 0) (point-max)
3770 'face eface)))))))))
3772 (defun article-verify-cancel-lock ()
3773 "Verify Cancel-Lock header."
3775 (if (gnus-buffer-live-p gnus-original-article-buffer)
3776 (canlock-verify gnus-original-article-buffer)))
3778 (defun article-monafy ()
3779 "Display body part with mona font."
3781 (unless (if (featurep 'xemacs)
3782 (find-face 'gnus-mona-face)
3783 (facep 'gnus-mona-face))
3784 (require 'navi2ch-mona)
3785 (set-face-font (make-face 'gnus-mona-face) navi2ch-mona-font))
3787 (let ((inhibit-read-only t))
3790 (gnus-make-overlay (point) (point-max))
3791 'face 'gnus-mona-face))))
3798 (setq afunc (car func)
3801 gfunc (intern (format "gnus-%s" func))))
3803 (when (fboundp afunc)
3804 `(lambda (&optional interactive &rest args)
3805 ,(documentation afunc t)
3806 (interactive (list t))
3808 (set-buffer gnus-article-buffer)
3810 (call-interactively ',afunc)
3811 (apply ',afunc args))))))))
3812 '(article-hide-headers
3813 article-verify-x-pgp-sig
3814 article-verify-cancel-lock
3816 article-hide-boring-headers
3817 article-treat-overstrike
3818 article-treat-ansi-sequences
3819 article-fill-long-lines
3820 article-capitalize-sentences
3822 article-remove-leading-whitespace
3823 article-display-x-face
3824 article-display-face
3825 article-de-quoted-unreadable
3826 article-de-base64-unreadable
3829 article-unsplit-urls
3830 article-hide-list-identifiers
3831 article-strip-banner
3834 article-hide-signature
3835 article-strip-headers-in-body
3836 article-remove-trailing-blank-lines
3837 article-strip-leading-blank-lines
3838 article-strip-multiple-blank-lines
3839 article-strip-leading-space
3840 article-strip-trailing-space
3841 article-strip-blank-lines
3842 article-strip-all-blank-lines
3844 article-date-english
3845 article-date-iso8601
3846 article-date-original
3848 article-decode-mime-words
3849 article-decode-charset
3850 article-decode-encoded-words
3854 article-treat-dumbquotes
3855 article-normalize-headers
3856 (article-show-all-headers . gnus-article-show-all-headers)
3857 ;; (article-show-all . gnus-article-show-all)
3861 ;;; Gnus article mode
3864 (put 'gnus-article-mode 'mode-class 'special)
3866 (gnus-define-keys gnus-article-mode-map
3867 " " gnus-article-goto-next-page
3868 "\177" gnus-article-goto-prev-page
3869 [delete] gnus-article-goto-prev-page
3870 [backspace] gnus-article-goto-prev-page
3871 "\C-c^" gnus-article-refer-article
3872 "h" gnus-article-show-summary
3873 "s" gnus-article-show-summary
3874 "\C-c\C-m" gnus-article-mail
3875 "?" gnus-article-describe-briefly
3876 "e" gnus-summary-edit-article
3877 "<" beginning-of-buffer
3879 "\C-c\C-i" gnus-info-find-node
3881 "R" gnus-article-reply-with-original
3882 "F" gnus-article-followup-with-original
3883 "\C-hk" gnus-article-describe-key
3884 "\C-hc" gnus-article-describe-key-briefly
3886 "\C-d" gnus-article-read-summary-keys
3887 "\M-*" gnus-article-read-summary-keys
3888 "\M-#" gnus-article-read-summary-keys
3889 "\M-^" gnus-article-read-summary-keys
3890 "\M-g" gnus-article-read-summary-keys)
3892 ;; Define almost undefined keys to `gnus-article-read-summary-keys'.
3896 (push (char-to-string key) keys)
3898 (dolist (elem (accessible-keymaps gnus-summary-mode-map))
3899 (setq key (car elem))
3900 (when (and (> (length key) 0)
3901 (not (eq 'menu-bar (aref key 0)))
3902 (symbolp (lookup-key gnus-summary-mode-map key)))
3905 (unless (lookup-key gnus-article-mode-map key)
3906 (define-key gnus-article-mode-map key 'gnus-article-read-summary-keys))))
3908 (defun gnus-article-make-menu-bar ()
3909 (unless (boundp 'gnus-article-commands-menu)
3910 (gnus-summary-make-menu-bar))
3911 (gnus-turn-off-edit-menu 'article)
3912 (unless (boundp 'gnus-article-article-menu)
3914 gnus-article-article-menu gnus-article-mode-map ""
3916 ["Scroll forwards" gnus-article-goto-next-page t]
3917 ["Scroll backwards" gnus-article-goto-prev-page t]
3918 ["Show summary" gnus-article-show-summary t]
3919 ["Fetch Message-ID at point" gnus-article-refer-article t]
3920 ["Mail to address at point" gnus-article-mail t]
3921 ["Send a bug report" gnus-bug t]))
3924 gnus-article-treatment-menu gnus-article-mode-map ""
3925 ;; Fixme: this should use :active (and maybe :visible).
3927 ["Hide headers" gnus-article-hide-headers t]
3928 ["Hide signature" gnus-article-hide-signature t]
3929 ["Hide citation" gnus-article-hide-citation t]
3930 ["Treat overstrike" gnus-article-treat-overstrike t]
3931 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
3932 ["Remove carriage return" gnus-article-remove-cr t]
3933 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3934 ["Treat html" gnus-article-wash-html t]
3935 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3936 ["Decode HZ" gnus-article-decode-HZ t]))
3938 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3940 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3942 (gnus-run-hooks 'gnus-article-menu-hook)))
3944 (defun gnus-article-mode ()
3945 "Major mode for displaying an article.
3947 All normal editing commands are switched off.
3949 The following commands are available in addition to all summary mode
3951 \\<gnus-article-mode-map>
3952 \\[gnus-article-next-page]\t Scroll the article one page forwards
3953 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3954 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3955 \\[gnus-article-show-summary]\t Display the summary buffer
3956 \\[gnus-article-mail]\t Send a reply to the address near point
3957 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3958 \\[gnus-info-find-node]\t Go to the Gnus info node"
3960 (kill-all-local-variables)
3961 (gnus-simplify-mode-line)
3962 (setq mode-name "Article")
3963 (setq major-mode 'gnus-article-mode)
3964 (make-local-variable 'minor-mode-alist)
3965 (unless (assq 'gnus-show-mime minor-mode-alist)
3966 (push (list 'gnus-show-mime " MIME") minor-mode-alist))
3967 (use-local-map gnus-article-mode-map)
3968 (when (gnus-visual-p 'article-menu 'menu)
3969 (gnus-article-make-menu-bar)
3970 (when gnus-summary-tool-bar-map
3971 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3972 (gnus-update-format-specifications nil 'article-mode)
3973 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3974 (set (make-local-variable 'gnus-page-broken) nil)
3975 (make-local-variable 'gnus-button-marker-list)
3976 (make-local-variable 'gnus-article-current-summary)
3977 (make-local-variable 'gnus-article-mime-handles)
3978 (make-local-variable 'gnus-article-decoded-p)
3979 (make-local-variable 'gnus-article-mime-handle-alist)
3980 (make-local-variable 'gnus-article-wash-types)
3981 (make-local-variable 'gnus-article-image-alist)
3982 (make-local-variable 'gnus-article-charset)
3983 (make-local-variable 'gnus-article-ignored-charsets)
3984 ;; Prevent recent Emacsen from displaying non-break space as "\ ".
3985 (set (make-local-variable 'nobreak-char-display) nil)
3986 (gnus-set-default-directory)
3987 (buffer-disable-undo)
3988 (setq buffer-read-only t
3989 show-trailing-whitespace nil)
3990 (set-syntax-table gnus-article-mode-syntax-table)
3991 (gnus-run-mode-hooks 'gnus-article-mode-hook))
3993 (defun gnus-article-setup-buffer ()
3994 "Initialize the article buffer."
3995 (let* ((name (if gnus-single-article-buffer "*Article*"
3996 (concat "*Article " gnus-newsgroup-name "*")))
3998 (progn (string-match "\\*Article" name)
3999 (concat " *Original Article"
4000 (substring name (match-end 0))))))
4001 (setq gnus-article-buffer name)
4002 (setq gnus-original-article-buffer original)
4003 (setq gnus-article-mime-handle-alist nil)
4004 ;; This might be a variable local to the summary buffer.
4005 (unless gnus-single-article-buffer
4007 (set-buffer gnus-summary-buffer)
4008 (setq gnus-article-buffer name)
4009 (setq gnus-original-article-buffer original)
4010 (gnus-set-global-variables)))
4011 (gnus-article-setup-highlight-words)
4012 ;; Init original article buffer.
4014 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
4015 (set-buffer-multibyte t)
4016 (setq major-mode 'gnus-original-article-mode)
4017 (make-local-variable 'gnus-original-article))
4018 (if (and (get-buffer name)
4019 (with-current-buffer name
4020 (if gnus-article-edit-mode
4021 (if (y-or-n-p "Article mode edit in progress; discard? ")
4023 (set-buffer-modified-p nil)
4024 (gnus-kill-buffer name)
4027 (error "Action aborted"))
4031 (set (make-local-variable 'gnus-article-edit-mode) nil)
4032 (buffer-disable-undo)
4033 (setq buffer-read-only t)
4034 ;; This list just keeps growing if we don't reset it.
4035 (setq gnus-button-marker-list nil)
4036 (unless (eq major-mode 'gnus-article-mode)
4037 (gnus-article-mode))
4040 (set-buffer (gnus-get-buffer-create name))
4042 (make-local-variable 'gnus-summary-buffer)
4043 (gnus-summary-set-local-parameters gnus-newsgroup-name)
4044 (current-buffer)))))
4046 ;; Set article window start at LINE, where LINE is the number of lines
4047 ;; from the head of the article.
4048 (defun gnus-article-set-window-start (&optional line)
4050 (gnus-get-buffer-window gnus-article-buffer t)
4052 (set-buffer gnus-article-buffer)
4053 (goto-char (point-min))
4056 (gnus-message 6 "Moved to bookmark")
4057 (search-forward "\n\n" nil t)
4061 ;;; @@ article filters
4064 (defun gnus-article-display-mime-message ()
4065 "Article display method for MIME message."
4066 ;; called from `gnus-original-article-buffer'.
4067 (let (charset all-headers)
4068 (with-current-buffer gnus-summary-buffer
4069 (setq charset default-mime-charset
4070 all-headers gnus-have-all-headers))
4071 (make-local-variable 'default-mime-charset)
4072 (setq default-mime-charset charset)
4073 (with-current-buffer (get-buffer-create gnus-article-buffer)
4074 (make-local-variable 'default-mime-charset)
4075 (setq default-mime-charset charset))
4076 (mime-display-message mime-message-structure
4077 gnus-article-buffer nil gnus-article-mode-map)
4079 (gnus-article-hide-headers nil -1)))
4080 (run-hooks 'gnus-mime-article-prepare-hook))
4082 (defun gnus-article-display-traditional-message ()
4083 "Article display method for traditional message."
4084 (set-buffer gnus-article-buffer)
4085 (let ((inhibit-read-only t))
4087 (insert-buffer-substring gnus-original-article-buffer)))
4089 (defun gnus-article-make-full-mail-header (&optional number charset)
4090 "Create a new mail header structure in a raw article buffer."
4091 (unless (and number charset)
4092 (save-current-buffer
4093 (set-buffer gnus-summary-buffer)
4095 (setq number (or (cdr gnus-article-current) 0)))
4097 (setq charset (or default-mime-charset 'x-ctext)))))
4098 (goto-char (point-min))
4099 (let ((header-end (if (search-forward "\n\n" nil t)
4101 (goto-char (point-max))))
4102 (chars (- (point-max) (point)))
4103 (lines (count-lines (point) (point-max)))
4104 (default-mime-charset charset)
4106 (narrow-to-region (point-min) header-end)
4107 (setq xref (std11-fetch-field "xref"))
4109 (make-full-mail-header
4111 (std11-fetch-field "subject")
4112 (std11-fetch-field "from")
4113 (std11-fetch-field "date")
4114 (std11-fetch-field "message-id")
4115 (std11-fetch-field "references")
4118 (when xref (concat "Xref: " xref)))
4121 (defun gnus-article-prepare (article &optional all-headers header)
4122 "Prepare ARTICLE in article mode buffer.
4123 ARTICLE should either be an article number or a Message-ID.
4124 If ARTICLE is an id, HEADER should be the article headers.
4125 If ALL-HEADERS is non-nil, no headers are hidden."
4127 ;; Make sure we start in a summary buffer.
4128 (unless (eq major-mode 'gnus-summary-mode)
4129 (set-buffer gnus-summary-buffer))
4130 (setq gnus-summary-buffer (current-buffer))
4131 (let* ((gnus-article (if header (mail-header-number header) article))
4132 (summary-buffer (current-buffer))
4133 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
4134 (group gnus-newsgroup-name)
4137 (gnus-article-setup-buffer)
4138 (set-buffer gnus-article-buffer)
4139 ;; Deactivate active regions.
4140 (when (and (boundp 'transient-mark-mode)
4141 transient-mark-mode)
4142 (setq mark-active nil))
4143 (if (not (setq result (let ((inhibit-read-only t))
4144 (gnus-request-article-this-buffer
4146 ;; There is no such article.
4148 (when (and (numberp article)
4149 (not (memq article gnus-newsgroup-sparse)))
4150 (setq gnus-article-current
4151 (cons gnus-newsgroup-name article))
4152 (set-buffer gnus-summary-buffer)
4153 (setq gnus-current-article article)
4154 (if (and (memq article gnus-newsgroup-undownloaded)
4155 (not (gnus-online (gnus-find-method-for-group
4156 gnus-newsgroup-name))))
4158 (gnus-summary-set-agent-mark article)
4159 (message "Message marked for downloading"))
4160 (gnus-summary-mark-article article gnus-canceled-mark)
4161 (unless (memq article gnus-newsgroup-sparse)
4162 (gnus-error 1 "No such article (may have expired or been canceled)")))))
4163 (if (or (eq result 'pseudo)
4164 (eq result 'nneething))
4167 (set-buffer summary-buffer)
4168 (push article gnus-newsgroup-history)
4169 (setq gnus-last-article gnus-current-article
4170 gnus-current-article 0
4171 gnus-current-headers nil
4172 gnus-article-current nil)
4173 (if (eq result 'nneething)
4174 (gnus-configure-windows 'summary)
4175 (gnus-configure-windows 'article))
4176 (gnus-set-global-variables))
4177 (let ((gnus-article-mime-handle-alist-1
4178 gnus-article-mime-handle-alist))
4179 (gnus-set-mode-line 'article)))
4180 ;; The result from the `request' was an actual article -
4181 ;; or at least some text that is now displayed in the
4183 (when (and (numberp article)
4184 (not (eq article gnus-current-article)))
4185 ;; Seems like a new article has been selected.
4186 ;; `gnus-current-article' must be an article number.
4188 (set-buffer summary-buffer)
4189 (push article gnus-newsgroup-history)
4190 (setq gnus-last-article gnus-current-article
4191 gnus-current-article article
4192 gnus-current-headers
4193 (gnus-summary-article-header gnus-current-article)
4194 gnus-article-current
4195 (cons gnus-newsgroup-name gnus-current-article))
4196 (unless (vectorp gnus-current-headers)
4197 (setq gnus-current-headers nil))
4198 (gnus-summary-goto-subject gnus-current-article)
4199 (when (gnus-summary-show-thread)
4200 ;; If the summary buffer really was folded, the
4201 ;; previous goto may not actually have gone to
4202 ;; the right article, but the thread root instead.
4204 (gnus-summary-goto-subject gnus-current-article))
4205 (gnus-run-hooks 'gnus-mark-article-hook)
4206 (gnus-set-mode-line 'summary)
4207 (when (gnus-visual-p 'article-highlight 'highlight)
4208 (gnus-run-hooks 'gnus-visual-mark-article-hook))
4209 ;; Set the global newsgroup variables here.
4210 (gnus-set-global-variables)
4211 (setq gnus-have-all-headers
4212 (or all-headers gnus-show-all-headers))))
4214 (gnus-configure-windows 'article))
4215 (when (or (numberp article)
4217 (gnus-article-prepare-display)
4219 (goto-char (point-min))
4220 (when gnus-break-pages
4221 (gnus-narrow-to-page)))
4222 (let ((gnus-article-mime-handle-alist-1
4223 gnus-article-mime-handle-alist))
4224 (gnus-set-mode-line 'article))
4228 (set-window-point (get-buffer-window (current-buffer)) (point))
4229 (gnus-configure-windows 'article)
4232 (defun gnus-article-prepare-mime-display (&optional number)
4233 (goto-char (point-min))
4234 (when (re-search-forward "^[^\t ]+:" nil t)
4235 (goto-char (match-beginning 0)))
4236 (let ((entity (if (eq 1 (point-min))
4237 (get-text-property 1 'mime-view-entity)
4238 (get-text-property (point) 'mime-view-entity)))
4239 last-entity child-entity next type)
4240 (setq child-entity (mime-entity-children entity))
4242 (setq last-entity (nth (1- (length child-entity))
4244 (setq last-entity entity))
4246 (narrow-to-region (point)
4247 (if (search-forward "\n\n" nil t)
4250 (gnus-article-save-original-date (gnus-treat-article 'head))
4251 (put-text-property (point-min) (point-max) 'article-treated-header t)
4252 (goto-char (point-max)))
4253 (while (and (not (eobp)) entity)
4254 (setq next (set-marker
4256 (next-single-property-change (point) 'mime-view-entity
4258 (let ((types (mime-entity-content-type entity)))
4259 (while (eq 'multipart (mime-content-type-primary-type types))
4260 (setq entity (car (mime-entity-children entity))
4261 types (mime-entity-content-type entity)))
4263 (setq type (format "%s/%s"
4264 (mime-content-type-primary-type types)
4265 (mime-content-type-subtype types)))))
4266 (if (string-equal type "message/rfc822")
4269 (let ((children (mime-entity-children entity))
4272 (setq last-children (nth (1- (length children)) children))
4275 (not (eq last-children
4276 (get-text-property next 'mime-view-entity)))
4278 (next-single-property-change next
4280 nil (point-max)))))))
4281 (setq next (next-single-property-change next 'mime-view-entity
4284 (narrow-to-region (point) next)
4285 (gnus-article-prepare-mime-display)
4286 (goto-char (point-max)))
4287 (setq entity (get-text-property (point) 'mime-view-entity)))
4289 (narrow-to-region (point) next)
4290 ;; Kludge. We have to count true number, but for now,
4291 ;; part number is here only to achieve `last'.
4292 (gnus-treat-article nil 1
4293 (if (eq entity last-entity)
4296 (goto-char (point-max)))
4297 (setq entity (get-text-property next 'mime-view-entity))))))
4300 (defun gnus-article-prepare-display ()
4301 "Make the current buffer look like a nice article."
4302 (let ((gnus-article-buffer (current-buffer))
4304 (inhibit-read-only t))
4305 (unless (eq major-mode 'gnus-article-mode)
4306 (gnus-article-mode))
4307 (setq buffer-read-only nil
4308 gnus-button-marker-list nil
4309 gnus-article-wash-types nil
4310 gnus-article-image-alist nil)
4313 (static-if (featurep 'xemacs)
4314 (map-extents (lambda (extent maparg) (delete-extent extent)))
4315 (let ((lists (overlay-lists)))
4316 (dolist (overlay (nconc (car lists) (cdr lists)))
4317 (delete-overlay overlay)))))
4318 (gnus-run-hooks 'gnus-tmp-internal-hook))
4319 (let ((show-mime (unless (member gnus-newsgroup-name '("nndraft:delayed"
4322 (inhibit-read-only t))
4323 (set-buffer gnus-original-article-buffer)
4325 (setq mime-message-structure gnus-current-headers)
4326 (mime-buffer-entity-set-buffer-internal mime-message-structure
4327 gnus-original-article-buffer)
4328 (mime-entity-set-representation-type-internal mime-message-structure
4329 'mime-buffer-entity)
4330 (luna-send mime-message-structure 'initialize-instance
4331 mime-message-structure)
4333 (let (mime-display-header-hook mime-display-text/plain-hook)
4334 (funcall gnus-article-display-method-for-mime))
4335 (funcall gnus-article-display-method-for-traditional))
4336 ;; Call the treatment functions.
4340 (gnus-article-prepare-mime-display)
4341 (narrow-to-region (goto-char (point-min))
4342 (if (search-forward "\n\n" nil t)
4345 (gnus-article-save-original-date (gnus-treat-article 'head))
4346 (put-text-property (point-min) (point-max) 'article-treated-header t)
4347 (goto-char (point-max))
4349 (narrow-to-region (point) (point-max))
4350 (gnus-treat-article nil))
4351 (put-text-property (point-min) (point-max) 'read-only nil)))
4352 (gnus-run-hooks 'gnus-article-prepare-hook))
4354 (defun gnus-article-decode-article-as-default-mime-charset ()
4355 "Decode an article as `default-mime-charset'. It won't work if the
4356 value of the variable `gnus-show-mime' is non-nil."
4357 (unless (or gnus-show-mime
4358 (member gnus-newsgroup-name '("nndraft:delayed"
4360 (set (make-local-variable 'default-mime-charset)
4361 (with-current-buffer gnus-summary-buffer
4362 default-mime-charset))
4363 (decode-mime-charset-region (point-min) (point-max)
4364 default-mime-charset)))
4367 ;;; Gnus MIME viewing functions
4370 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4371 "Format of the MIME buttons.
4373 Valid specifiers include:
4375 %T MIME type, along with additional info
4376 %n The `name' parameter
4377 %d The description, if any
4378 %l The length of the encoded part
4379 %p The part identifier number
4380 %e Dots if the part isn't displayed
4382 General format specifiers can also be used. See Info node
4383 `(gnus)Formatting Variables'.")
4385 (defvar gnus-mime-button-line-format-alist
4386 '((?t gnus-tmp-type ?s)
4387 (?T gnus-tmp-type-long ?s)
4388 (?n gnus-tmp-name ?s)
4389 (?d gnus-tmp-description ?s)
4391 (?l gnus-tmp-length ?d)
4392 (?e gnus-tmp-dots ?s)))
4394 (defvar gnus-mime-button-commands
4395 '((gnus-article-press-button "\r" "Toggle Display")
4396 (gnus-mime-view-part "v" "View Interactively...")
4397 (gnus-mime-view-part-as-type "t" "View As Type...")
4398 (gnus-mime-view-part-as-charset "C" "View As charset...")
4399 (gnus-mime-save-part "o" "Save...")
4400 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4401 (gnus-mime-replace-part "r" "Replace part")
4402 (gnus-mime-delete-part "d" "Delete part")
4403 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4404 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4405 (gnus-mime-view-part-internally "E" "View Internally") ;; Why `E'?
4406 (gnus-mime-view-part-externally "e" "View Externally")
4407 (gnus-mime-print-part "p" "Print")
4408 (gnus-mime-pipe-part "|" "Pipe To Command...")
4409 (gnus-mime-action-on-part "." "Take action on the part...")))
4411 (defun gnus-article-mime-part-status ()
4412 (with-current-buffer gnus-article-buffer
4413 (let ((entity (get-text-property (point-min) 'mime-view-entity))
4416 (setq children (mime-entity-children entity))
4417 (setq children (length children)))
4420 (format " (%d parts)" children))
4423 (defvar gnus-mime-button-map
4424 (let ((map (make-sparse-keymap)))
4425 (define-key map gnus-mouse-2 'gnus-article-push-button)
4426 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4427 (dolist (c gnus-mime-button-commands)
4428 (define-key map (cadr c) (car c)))
4432 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4434 ,@(mapcar (lambda (c)
4435 (vector (caddr c) (car c) :enable t))
4436 gnus-mime-button-commands)))
4438 (defun gnus-mime-button-menu (event prefix)
4439 "Construct a context-sensitive menu of MIME commands."
4440 (interactive "e\nP")
4441 (save-window-excursion
4442 (let ((pos (event-start event)))
4443 (select-window (posn-window pos))
4444 (goto-char (posn-point pos))
4445 (gnus-article-check-buffer)
4446 (popup-menu gnus-mime-button-menu nil prefix))))
4448 (defun gnus-mime-view-all-parts (&optional handles)
4449 "View all the MIME parts."
4451 (with-current-buffer gnus-article-buffer
4452 (let ((handles (or handles gnus-article-mime-handles))
4453 (mail-parse-charset gnus-newsgroup-charset)
4454 (mail-parse-ignored-charsets
4455 (with-current-buffer gnus-summary-buffer
4456 gnus-newsgroup-ignored-charsets)))
4458 (mm-remove-parts handles)
4459 (goto-char (point-min))
4460 (or (search-forward "\n\n") (goto-char (point-max)))
4461 (let ((inhibit-read-only t))
4462 (delete-region (point) (point-max))
4463 (mm-display-parts handles))))))
4465 (defun gnus-article-jump-to-part (n)
4466 "Jump to MIME part N."
4468 (pop-to-buffer gnus-article-buffer)
4469 ;; FIXME: why is it necessary?
4471 (let ((parts (length gnus-article-mime-handle-alist)))
4474 (read-string ;; Emacs 21 doesn't have `read-number'.
4475 (format "Jump to part (2..%s): " parts)))))
4476 (unless (and (integerp n) (<= n parts) (>= n 1))
4479 (gnus-message 7 "Invalid part `%s', using %s instead."
4482 (gnus-message 9 "Jumping to part %s." n)
4483 (cond ((>= gnus-auto-select-part 1)
4484 (while (and (<= n parts)
4485 (not (gnus-article-goto-part n)))
4487 ((< gnus-auto-select-part 0)
4488 (while (and (>= n 1)
4489 (not (gnus-article-goto-part n)))
4492 (gnus-article-goto-part n)))))
4495 (defsubst gnus-article-edit-part (handles &optional current-id)
4496 "Edit an article in order to delete a mime part.
4497 This function is exclusively used by `gnus-mime-save-part-and-strip'
4498 and `gnus-mime-delete-part', and not provided at run-time normally."
4499 (gnus-article-edit-article
4501 (buffer-disable-undo)
4503 (let ((mail-parse-charset (or gnus-article-charset
4504 ',gnus-newsgroup-charset))
4505 (mail-parse-ignored-charsets
4506 (or gnus-article-ignored-charsets
4507 ',gnus-newsgroup-ignored-charsets))
4508 (mbl mml-buffer-list))
4509 (setq mml-buffer-list nil)
4510 (insert-buffer-substring gnus-original-article-buffer)
4511 (mime-to-mml ',handles)
4512 (setq gnus-article-mime-handles nil)
4513 (let ((mbl1 mml-buffer-list))
4514 (setq mml-buffer-list mbl)
4515 (set (make-local-variable 'mml-buffer-list) mbl1))
4516 (gnus-make-local-hook 'kill-buffer-hook)
4517 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4518 `(lambda (no-highlight)
4519 (let ((mail-parse-charset (or gnus-article-charset
4520 ',gnus-newsgroup-charset))
4521 (message-options message-options)
4522 (message-options-set-recipient)
4523 (mail-parse-ignored-charsets
4524 (or gnus-article-ignored-charsets
4525 ',gnus-newsgroup-ignored-charsets)))
4527 (mml-destroy-buffers)
4528 (remove-hook 'kill-buffer-hook
4529 'mml-destroy-buffers t)
4530 (kill-local-variable 'mml-buffer-list))
4531 (gnus-summary-edit-article-done
4532 ,(or (mail-header-references gnus-current-headers) "")
4533 ,(gnus-group-read-only-p)
4534 ,gnus-summary-buffer no-highlight))
4536 (gnus-article-edit-done)
4537 (gnus-summary-expand-window)
4538 (gnus-summary-show-article)
4539 (when (and current-id (integerp gnus-auto-select-part))
4540 (gnus-article-jump-to-part
4541 (+ current-id gnus-auto-select-part)))))
4543 (defun gnus-mime-replace-part (file)
4544 "Replace MIME part under point with an external body."
4545 ;; Useful if file has already been saved to disk
4549 (read-file-name "Replace MIME part with file: "
4550 (or mm-default-directory default-directory)
4552 (gnus-mime-save-part-and-strip file))
4554 (defun gnus-mime-save-part-and-strip (&optional file)
4555 "Save the MIME part under point then replace it with an external body.
4556 If FILE is given, use it for the external part."
4558 (gnus-article-check-buffer)
4559 (when (gnus-group-read-only-p)
4560 (error "The current group does not support deleting of parts"))
4561 (when (mm-complicated-handles gnus-article-mime-handles)
4563 The current article has a complicated MIME structure, giving up..."))
4564 (let* ((data (get-text-property (point) 'gnus-data))
4565 (id (get-text-property (point) 'gnus-part))
4567 (handles gnus-article-mime-handles))
4570 (and data (mm-save-part data "Delete MIME part and save to: "))))
4572 (with-current-buffer (mm-handle-buffer data)
4574 (insert "Content-Type: " (mm-handle-media-type data))
4575 (mml-insert-parameter-string (cdr (mm-handle-type data))
4578 (insert "Content-ID: " (message-make-message-id) "\n")
4579 (insert "Content-Transfer-Encoding: binary\n")
4582 (cdr (mm-make-handle nil
4583 `("message/external-body"
4584 (access-type . "LOCAL-FILE")
4586 ;; (set-buffer gnus-summary-buffer)
4587 (gnus-article-edit-part handles id))))
4589 ;; A function like `gnus-summary-save-parts' (`X m', `<MIME> <Extract all
4590 ;; parts...>') but with stripping would be nice.
4592 (defun gnus-mime-delete-part ()
4593 "Delete the MIME part under point.
4594 Replace it with some information about the removed part."
4596 (gnus-article-check-buffer)
4597 (when (gnus-group-read-only-p)
4598 (error "The current group does not support deleting of parts"))
4599 (when (mm-complicated-handles gnus-article-mime-handles)
4601 The current article has a complicated MIME structure, giving up..."))
4602 (when (or gnus-expert-user
4603 (gnus-yes-or-no-p "\
4604 Deleting parts may malfunction or destroy the article; continue? "))
4605 (let* ((data (get-text-property (point) 'gnus-data))
4606 (id (get-text-property (point) 'gnus-part))
4607 (handles gnus-article-mime-handles)
4611 (mail-decode-encoded-word-string (or (mm-handle-description data)
4614 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4616 (type (mm-handle-media-type data)))
4618 (error "No MIME part under point"))
4619 (with-current-buffer (mm-handle-buffer data)
4620 (let ((bsize (format "%s" (buffer-size))))
4625 "| The following attachment has been deleted:\n"
4627 "| Type: " type "\n"
4628 "| Filename: " filename "\n"
4629 "| Size (encoded): " bsize " Byte\n"
4630 "| Description: " description "\n"
4633 (cdr (mm-make-handle
4634 nil `("text/plain") nil nil
4636 (format "Deleted attachment (%s bytes)" bsize))))))
4637 ;; (set-buffer gnus-summary-buffer)
4638 (gnus-article-edit-part handles id))))
4640 (defun gnus-mime-save-part ()
4641 "Save the MIME part under point."
4643 (gnus-article-check-buffer)
4644 (let ((data (get-text-property (point) 'gnus-data)))
4646 (mm-save-part data))))
4648 (defun gnus-mime-pipe-part ()
4649 "Pipe the MIME part under point to a process."
4651 (gnus-article-check-buffer)
4652 (let ((data (get-text-property (point) 'gnus-data)))
4654 (mm-pipe-part data))))
4656 (defun gnus-mime-view-part ()
4657 "Interactively choose a viewing method for the MIME part under point."
4659 (gnus-article-check-buffer)
4660 (let ((data (get-text-property (point) 'gnus-data)))
4662 (setq gnus-article-mime-handles
4664 gnus-article-mime-handles (setq data (copy-sequence data))))
4665 (mm-interactively-view-part data))))
4667 (defun gnus-mime-view-part-as-type-internal ()
4668 (gnus-article-check-buffer)
4669 (let* ((name (mail-content-type-get
4670 (mm-handle-type (get-text-property (point) 'gnus-data))
4672 (def-type (and name (mm-default-file-encoding name))))
4673 (and def-type (cons def-type 0))))
4675 (defun gnus-mime-view-part-as-type (&optional mime-type)
4676 "Choose a MIME media type, and view the part as such."
4679 (setq mime-type (completing-read
4680 "View as MIME type: "
4681 (mapcar #'list (mailcap-mime-types))
4683 (gnus-mime-view-part-as-type-internal))))
4684 (gnus-article-check-buffer)
4685 (let ((handle (get-text-property (point) 'gnus-data)))
4688 (mm-make-handle (mm-handle-buffer handle)
4689 (cons mime-type (cdr (mm-handle-type handle)))
4690 (mm-handle-encoding handle)
4691 (mm-handle-undisplayer handle)
4692 (mm-handle-disposition handle)
4693 (mm-handle-description handle)
4695 (mm-handle-id handle)))
4696 (setq gnus-article-mime-handles
4697 (mm-merge-handles gnus-article-mime-handles handle))
4698 (gnus-mm-display-part handle))))
4700 (defun gnus-mime-copy-part (&optional handle arg)
4701 "Put the MIME part under point into a new buffer.
4702 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4704 (interactive (list nil current-prefix-arg))
4705 (gnus-article-check-buffer)
4707 (setq handle (get-text-property (point) 'gnus-data)))
4709 (let ((filename (or (mail-content-type-get (mm-handle-disposition handle)
4711 (mail-content-type-get (mm-handle-disposition handle)
4713 contents dont-decode charset coding-system)
4714 (mm-with-unibyte-buffer
4715 (mm-insert-part handle)
4716 (setq contents (or (condition-case nil
4717 (mm-decompress-buffer filename nil 'sig)
4719 (setq dont-decode t)
4722 (setq filename (cond (filename (file-name-nondirectory filename))
4723 (dont-decode "*raw data*")
4728 (unless (setq charset (mail-content-type-get
4729 (mm-handle-type handle) 'charset))
4730 (unless (setq coding-system (mm-with-unibyte-buffer
4732 (mm-find-buffer-file-coding-system)))
4733 (setq charset gnus-newsgroup-charset))))
4735 (setq charset (or (cdr (assq arg
4736 gnus-summary-show-article-charset-alist))
4737 (mm-read-coding-system "Charset: ")))))
4738 (switch-to-buffer (generate-new-buffer filename))
4739 (if (or coding-system
4741 (setq coding-system (mm-charset-to-coding-system charset))
4742 (not (eq charset 'ascii))))
4744 (mm-enable-multibyte)
4745 (insert (mm-decode-coding-string contents coding-system))
4746 (setq buffer-file-coding-system
4747 (if (boundp 'last-coding-system-used)
4748 (symbol-value 'last-coding-system-used)
4750 (mm-disable-multibyte)
4752 (setq buffer-file-coding-system mm-binary-coding-system))
4753 ;; We do it this way to make `normal-mode' set the appropriate mode.
4756 (setq buffer-file-name (expand-file-name filename))
4758 (setq buffer-file-name nil))
4759 (goto-char (point-min)))))
4761 (defun gnus-mime-print-part (&optional handle filename)
4762 "Print the MIME part under point."
4763 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4764 (gnus-article-check-buffer)
4765 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4766 (contents (and handle (mm-get-part handle)))
4767 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4768 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4773 (mm-save-part-to-file handle file)
4774 (call-process shell-file-name nil
4775 (generate-new-buffer " *mm*")
4777 shell-command-switch
4779 printer file (mm-handle-type handle))))
4783 (gnus-print-buffer))
4784 (ps-despool filename)))))
4786 (defun gnus-mime-inline-part (&optional handle arg)
4787 "Insert the MIME part under point into the current buffer.
4788 Compressed files like .gz and .bz2 are decompressed."
4789 (interactive (list nil current-prefix-arg))
4790 (gnus-article-check-buffer)
4792 (setq handle (get-text-property (point) 'gnus-data)))
4795 (inhibit-read-only t)
4796 contents charset coding-system)
4797 (if (and (not arg) (mm-handle-undisplayer handle))
4798 (mm-remove-part handle)
4799 (mm-with-unibyte-buffer
4800 (mm-insert-part handle)
4802 (or (mm-decompress-buffer
4803 (or (mail-content-type-get (mm-handle-disposition handle)
4805 (mail-content-type-get (mm-handle-disposition handle)
4811 (unless (setq charset (mail-content-type-get
4812 (mm-handle-type handle) 'charset))
4813 (unless (setq coding-system
4814 (mm-with-unibyte-buffer
4816 (mm-find-buffer-file-coding-system)))
4817 (setq charset gnus-newsgroup-charset))))
4819 (if (mm-handle-undisplayer handle)
4820 (mm-remove-part handle))
4823 gnus-summary-show-article-charset-alist))
4824 (mm-read-coding-system "Charset: "))))
4826 (if (mm-handle-undisplayer handle)
4827 (mm-remove-part handle))))
4831 (if (or coding-system
4834 (mm-charset-to-coding-system charset))
4835 (not (eq coding-system 'ascii))))
4836 (mm-decode-coding-string contents coding-system)
4837 (mm-string-to-multibyte contents)))
4840 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4841 "Insert the MIME part under point into the current buffer using the
4843 (interactive (list nil current-prefix-arg))
4844 (gnus-article-check-buffer)
4845 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4848 (inhibit-read-only t))
4850 (if (mm-handle-undisplayer handle)
4851 (mm-remove-part handle))
4852 (let ((gnus-newsgroup-charset
4854 gnus-summary-show-article-charset-alist))
4855 (mm-read-coding-system "Charset: ")))
4856 (gnus-newsgroup-ignored-charsets 'gnus-all))
4857 (gnus-article-press-button)))))
4859 (defun gnus-mime-view-part-externally (&optional handle)
4860 "View the MIME part under point with an external viewer."
4862 (gnus-article-check-buffer)
4863 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4864 (mm-user-display-methods nil)
4865 (mm-inlined-types nil)
4866 (mail-parse-charset gnus-newsgroup-charset)
4867 (mail-parse-ignored-charsets
4868 (with-current-buffer gnus-summary-buffer
4869 gnus-newsgroup-ignored-charsets)))
4871 (if (mm-handle-undisplayer handle)
4872 (mm-remove-part handle)
4873 (mm-display-part handle)))))
4875 (defun gnus-mime-view-part-internally (&optional handle)
4876 "View the MIME part under point with an internal viewer.
4877 If no internal viewer is available, use an external viewer."
4879 (gnus-article-check-buffer)
4880 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4881 (mm-inlined-types '(".*"))
4882 (mm-inline-large-images t)
4883 (mail-parse-charset gnus-newsgroup-charset)
4884 (mail-parse-ignored-charsets
4885 (with-current-buffer gnus-summary-buffer
4886 gnus-newsgroup-ignored-charsets))
4887 (inhibit-read-only t))
4889 (if (mm-handle-undisplayer handle)
4890 (mm-remove-part handle)
4891 (mm-display-part handle)))))
4893 (defun gnus-mime-action-on-part (&optional action)
4894 "Do something with the MIME attachment at \(point\)."
4896 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4897 (gnus-article-check-buffer)
4898 (let ((action-pair (assoc action gnus-mime-action-alist)))
4900 (funcall (cdr action-pair)))))
4902 (defun gnus-article-part-wrapper (n function &optional no-handle interactive)
4903 "Call FUNCTION on MIME part N.
4904 Unless NO-HANDLE, call FUNCTION with N-th MIME handle as it's only argument.
4905 If INTERACTIVE, call FUNCTION interactivly."
4907 ;; Check whether the article is displayed.
4908 (unless (and (gnus-buffer-live-p gnus-article-buffer)
4909 (setq window (get-buffer-window gnus-article-buffer t))
4910 (frame-visible-p (setq frame (window-frame window))))
4911 (error "No article is displayed"))
4912 (with-current-buffer gnus-article-buffer
4913 ;; Check whether the article displays the right contents.
4914 (unless (with-current-buffer gnus-summary-buffer
4915 (eq gnus-current-article (gnus-summary-article-number)))
4916 (error "You should select the right article first"))
4917 ;; Check whether the specified part exists.
4918 (when (> n (length gnus-article-mime-handle-alist))
4919 (error "No such part")))
4922 ;; To select the window is needed so that the cursor
4923 ;; might be visible on the MIME button.
4924 (select-window (prog1
4926 (setq window (selected-window))
4927 ;; Article may be displayed in the other frame.
4928 (gnus-select-frame-set-input-focus
4931 (setq frame (selected-frame))))))
4932 (when (gnus-article-goto-part n)
4933 ;; We point the cursor and the arrow at the MIME button
4934 ;; when the `function' prompt the user for something.
4935 (let ((cursor-in-non-selected-windows t)
4936 (overlay-arrow-string "=>")
4937 (overlay-arrow-position (point-marker)))
4940 ((and no-handle interactive)
4941 (call-interactively function))
4947 (cdr (assq n gnus-article-mime-handle-alist))))
4950 (cdr (assq n gnus-article-mime-handle-alist)))))
4951 (set-marker overlay-arrow-position nil)
4952 (unless gnus-auto-select-part
4953 (gnus-select-frame-set-input-focus frame)
4954 (select-window window))))
4956 (if gnus-inhibit-mime-unbuttonizing
4957 ;; This is the default though the program shouldn't reach here.
4958 (error "No such part")
4959 ;; The part which doesn't have the MIME button is selected.
4960 ;; So, we display all the buttons and redo it.
4961 (let ((gnus-inhibit-mime-unbuttonizing t))
4962 (gnus-summary-show-article)
4963 (gnus-article-part-wrapper n function no-handle))))))
4965 (defun gnus-article-pipe-part (n)
4966 "Pipe MIME part N, which is the numerical prefix."
4968 (gnus-article-part-wrapper n 'mm-pipe-part))
4970 (defun gnus-article-save-part (n)
4971 "Save MIME part N, which is the numerical prefix."
4973 (gnus-article-part-wrapper n 'mm-save-part))
4975 (defun gnus-article-interactively-view-part (n)
4976 "View MIME part N interactively, which is the numerical prefix."
4978 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4980 (defun gnus-article-copy-part (n)
4981 "Copy MIME part N, which is the numerical prefix."
4983 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4985 (defun gnus-article-view-part-as-charset (n)
4986 "View MIME part N using a specified charset.
4987 N is the numerical prefix."
4989 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4991 (defun gnus-article-view-part-externally (n)
4992 "View MIME part N externally, which is the numerical prefix."
4994 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4996 (defun gnus-article-inline-part (n)
4997 "Inline MIME part N, which is the numerical prefix."
4999 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
5001 (defun gnus-article-save-part-and-strip (n)
5002 "Save MIME part N and replace it with an external body.
5003 N is the numerical prefix."
5005 (gnus-article-part-wrapper n 'gnus-mime-save-part-and-strip t))
5007 (defun gnus-article-replace-part (n)
5008 "Replace MIME part N with an external body.
5009 N is the numerical prefix."
5011 (gnus-article-part-wrapper n 'gnus-mime-replace-part t t))
5013 (defun gnus-article-delete-part (n)
5014 "Delete MIME part N and add some information about the removed part.
5015 N is the numerical prefix."
5017 (gnus-article-part-wrapper n 'gnus-mime-delete-part t))
5019 (defun gnus-article-mime-match-handle-first (condition)
5022 (dolist (ihandle gnus-article-mime-handle-alist)
5024 ((functionp condition)
5025 (funcall condition (cdr ihandle)))
5026 ((eq condition 'undisplayed)
5027 (not (or (mm-handle-undisplayer (cdr ihandle))
5028 (equal (mm-handle-media-type (cdr ihandle))
5029 "multipart/alternative"))))
5030 ((eq condition 'undisplayed-alternative)
5031 (not (mm-handle-undisplayer (cdr ihandle))))
5033 (gnus-article-goto-part (car ihandle))
5034 (or (not n) (< (car ihandle) n)))
5035 (setq n (car ihandle))))
5039 (defun gnus-article-view-part (&optional n)
5040 "View MIME part N, which is the numerical prefix."
5042 (with-current-buffer gnus-article-buffer
5043 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
5044 gnus-article-mime-match-handle-function)))
5045 (when (> n (length gnus-article-mime-handle-alist))
5046 (error "No such part"))
5047 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
5048 (when (gnus-article-goto-part n)
5049 (if (equal (car handle) "multipart/alternative")
5050 (gnus-article-press-button)
5051 (when (eq (gnus-mm-display-part handle) 'internal)
5052 (gnus-set-window-start)))))))
5054 (defsubst gnus-article-mime-total-parts ()
5055 (if (bufferp (car gnus-article-mime-handles))
5057 (1- (length gnus-article-mime-handles))))
5059 (defun gnus-mm-display-part (handle)
5060 "Display HANDLE and fix MIME button."
5061 (let ((id (get-text-property (point) 'gnus-part))
5063 (inhibit-read-only t))
5066 (let ((window (selected-window))
5067 (mail-parse-charset gnus-newsgroup-charset)
5068 (mail-parse-ignored-charsets
5069 (if (gnus-buffer-live-p gnus-summary-buffer)
5070 (with-current-buffer gnus-summary-buffer
5071 gnus-newsgroup-ignored-charsets)
5075 (let ((win (gnus-get-buffer-window (current-buffer) t))
5078 (select-window win))
5081 (if (mm-handle-displayed-p handle)
5082 ;; This will remove the part.
5083 (mm-display-part handle)
5085 (narrow-to-region (point)
5086 (if (eobp) (point) (1+ (point))))
5087 (mm-display-part handle)
5088 ;; We narrow to the part itself and
5089 ;; then call the treatment functions.
5090 (goto-char (point-min))
5092 (narrow-to-region (point) (point-max))
5095 (gnus-article-mime-total-parts)
5096 (mm-handle-media-type handle)))))
5097 (if (window-live-p window)
5098 (select-window window)))))
5101 (gnus-insert-mime-button
5102 handle id (list (mm-handle-displayed-p handle)))
5103 (goto-char point))))
5105 (defun gnus-article-goto-part (n)
5106 "Go to MIME part N."
5107 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
5109 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
5110 (let ((gnus-tmp-name
5111 (or (mail-content-type-get (mm-handle-type handle) 'name)
5112 (mail-content-type-get (mm-handle-disposition handle) 'filename)
5113 (mail-content-type-get (mm-handle-type handle) 'url)
5115 (gnus-tmp-type (mm-handle-media-type handle))
5116 (gnus-tmp-description
5117 (mail-decode-encoded-word-string (or (mm-handle-description handle)
5120 (if (if displayed (car displayed)
5121 (mm-handle-displayed-p handle))
5123 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
5125 gnus-tmp-type-long b e)
5126 (when (string-match ".*/" gnus-tmp-name)
5127 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
5128 (setq gnus-tmp-type-long (concat gnus-tmp-type
5129 (and (not (equal gnus-tmp-name ""))
5130 (concat "; " gnus-tmp-name))))
5131 (unless (equal gnus-tmp-description "")
5132 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
5137 gnus-mime-button-line-format gnus-mime-button-line-format-alist
5138 `(keymap ,gnus-mime-button-map
5139 gnus-callback gnus-mm-display-part
5140 gnus-part ,gnus-tmp-id
5141 article-type annotation
5144 ;; Exclude a newline.
5147 (widget-convert-button
5150 :action 'gnus-widget-press-button
5151 :button-keymap gnus-mime-button-map
5153 (lambda (widget/window &optional overlay pos)
5154 ;; Needed to properly clear the message due to a bug in
5155 ;; wid-edit (XEmacs only).
5156 (if (boundp 'help-echo-owns-message)
5157 (setq help-echo-owns-message t))
5159 "%S: %s the MIME part; %S: more options"
5160 (aref gnus-mouse-2 0)
5161 ;; XEmacs will get a single widget arg; Emacs 21 will get
5162 ;; window, overlay, position.
5163 (if (mm-handle-displayed-p
5165 (with-current-buffer (gnus-overlay-buffer overlay)
5166 (widget-get (widget-at (gnus-overlay-start overlay))
5168 (widget-get widget/window :mime-handle)))
5170 (aref gnus-down-mouse-3 0))))))
5172 (defun gnus-widget-press-button (elems el)
5173 (goto-char (widget-get elems :from))
5174 (gnus-article-press-button))
5176 (defvar gnus-displaying-mime nil)
5178 (defun gnus-display-mime (&optional ihandles)
5179 "Display the MIME parts."
5181 (save-selected-window
5182 (let ((window (get-buffer-window gnus-article-buffer))
5185 (select-window window)
5186 ;; We have to do this since selecting the window
5187 ;; may change the point. So we set the window point.
5188 (set-window-point window point)))
5189 (let ((handles ihandles)
5190 (inhibit-read-only t)
5193 ((setq handles (mm-dissect-buffer nil gnus-article-loose-mime))
5194 (when gnus-article-emulate-mime
5195 (mm-uu-dissect-text-parts handles)))
5196 (gnus-article-emulate-mime
5197 (setq handles (mm-uu-dissect))))
5198 (when (and (not ihandles)
5199 (not gnus-displaying-mime))
5200 ;; Top-level call; we clean up.
5201 (when gnus-article-mime-handles
5202 (mm-destroy-parts gnus-article-mime-handles)
5203 (setq gnus-article-mime-handle-alist nil));; A trick.
5204 (setq gnus-article-mime-handles handles)
5205 ;; We allow users to glean info from the handles.
5206 (when gnus-article-mime-part-function
5207 (gnus-mime-part-function handles)))
5209 (or (not (stringp (car handles)))
5212 (when (and (not ihandles)
5213 (not gnus-displaying-mime))
5214 ;; Clean up for mime parts.
5216 (delete-region (point) (point-max)))
5217 (let ((gnus-displaying-mime t))
5218 (gnus-mime-display-part handles)))
5221 (narrow-to-region (point) (point-max))
5222 (gnus-treat-article nil 1 1)
5225 ;; Highlight the headers.
5229 (narrow-to-region (point-min) (point))
5230 (gnus-article-save-original-date
5231 (gnus-treat-article 'head)))))))))
5233 (defcustom gnus-mime-display-multipart-as-mixed nil
5234 "Display \"multipart\" parts as \"multipart/mixed\".
5236 If t, it overrides nil values of
5237 `gnus-mime-display-multipart-alternative-as-mixed' and
5238 `gnus-mime-display-multipart-related-as-mixed'."
5239 :group 'gnus-article-mime
5242 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
5243 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
5245 :group 'gnus-article-mime
5248 (defcustom gnus-mime-display-multipart-related-as-mixed nil
5249 "Display \"multipart/related\" parts as \"multipart/mixed\".
5251 If displaying \"text/html\" is discouraged \(see
5252 `mm-discouraged-alternatives'\) images or other material inside a
5253 \"multipart/related\" part might be overlooked when this variable is nil."
5255 :group 'gnus-article-mime
5258 (defun gnus-mime-display-part (handle)
5260 ;; Maybe a broken MIME message.
5263 ((not (stringp (car handle)))
5264 (gnus-mime-display-single handle))
5265 ;; User-defined multipart
5266 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
5267 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
5269 ;; multipart/alternative
5270 ((and (equal (car handle) "multipart/alternative")
5271 (not (or gnus-mime-display-multipart-as-mixed
5272 gnus-mime-display-multipart-alternative-as-mixed)))
5273 (let ((id (1+ (length gnus-article-mime-handle-alist))))
5274 (push (cons id handle) gnus-article-mime-handle-alist)
5275 (gnus-mime-display-alternative (cdr handle) nil nil id)))
5276 ;; multipart/related
5277 ((and (equal (car handle) "multipart/related")
5278 (not (or gnus-mime-display-multipart-as-mixed
5279 gnus-mime-display-multipart-related-as-mixed)))
5280 ;;;!!!We should find the start part, but we just default
5281 ;;;!!!to the first part.
5282 ;;(gnus-mime-display-part (cadr handle))
5283 ;;;!!! Most multipart/related is an HTML message plus images.
5284 ;;;!!! Unfortunately we are unable to let W3 display those
5285 ;;;!!! included images, so we just display it as a mixed multipart.
5286 ;;(gnus-mime-display-mixed (cdr handle))
5287 ;;;!!! No, w3 can display everything just fine.
5288 (gnus-mime-display-part (cadr handle)))
5289 ((equal (car handle) "multipart/signed")
5290 (gnus-add-wash-type 'signed)
5291 (gnus-mime-display-security handle))
5292 ((equal (car handle) "multipart/encrypted")
5293 (gnus-add-wash-type 'encrypted)
5294 (gnus-mime-display-security handle))
5295 ;; Other multiparts are handled like multipart/mixed.
5297 (gnus-mime-display-mixed (cdr handle)))))
5299 (defun gnus-mime-part-function (handles)
5300 (if (stringp (car handles))
5301 (mapcar 'gnus-mime-part-function (cdr handles))
5302 (funcall gnus-article-mime-part-function handles)))
5304 (defun gnus-mime-display-mixed (handles)
5305 (mapcar 'gnus-mime-display-part handles))
5307 (defun gnus-mime-display-single (handle)
5308 (let ((type (mm-handle-media-type handle))
5309 (ignored gnus-ignored-mime-types)
5316 (when (string-match (pop ignored) type)
5317 (throw 'ignored nil)))
5318 (if (and (setq not-attachment
5319 (and (not (mm-inline-override-p handle))
5320 (or (not (mm-handle-disposition handle))
5321 (equal (car (mm-handle-disposition handle))
5323 (mm-attachment-override-p handle))))
5324 (mm-automatic-display-p handle)
5326 (mm-inlinable-p handle)
5327 (mm-inlined-p handle))
5328 (mm-automatic-external-display-p type)))
5330 (when (equal (mm-handle-media-supertype handle) "text")
5332 (let ((id (1+ (length gnus-article-mime-handle-alist)))
5334 (push (cons id handle) gnus-article-mime-handle-alist)
5335 (when (or (not display)
5336 (not (gnus-unbuttonized-mime-type-p type)))
5337 (gnus-insert-mime-button
5338 handle id (list (or display (and not-attachment text))))
5339 (gnus-article-insert-newline)
5340 ;; Remember modify the number of forward lines.
5348 (let ((mail-parse-charset gnus-newsgroup-charset)
5349 (mail-parse-ignored-charsets
5350 (save-excursion (condition-case ()
5351 (set-buffer gnus-summary-buffer)
5353 gnus-newsgroup-ignored-charsets)))
5354 (mm-display-part handle t))
5355 (goto-char (point-max)))
5356 ((and text not-attachment)
5360 (gnus-article-insert-newline)
5363 (let ((charset (mail-content-type-get (mm-handle-type handle)
5365 (cond ((not charset)
5366 (mm-string-as-multibyte (mm-get-part handle)))
5367 ((eq charset 'gnus-decoded)
5368 (with-current-buffer (mm-handle-buffer handle)
5371 (mm-decode-string (mm-get-part handle) charset)))))
5372 (goto-char (point-max))))
5376 (narrow-to-region beg (point))
5379 (gnus-article-mime-total-parts)
5380 (mm-handle-media-type handle)))))))))
5382 (defun gnus-unbuttonized-mime-type-p (type)
5383 "Say whether TYPE is to be unbuttonized."
5384 (unless gnus-inhibit-mime-unbuttonizing
5386 (let ((types gnus-unbuttonized-mime-types))
5388 (when (string-match (pop types) type)
5389 (throw 'found t)))))
5391 (let ((types gnus-buttonized-mime-types))
5393 (when (string-match (pop types) type)
5394 (throw 'found t)))))))))
5396 (defun gnus-article-insert-newline ()
5397 "Insert a newline, but mark it as undeletable."
5398 (gnus-put-text-property
5399 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
5401 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
5402 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
5405 handle (inhibit-read-only t) from props begend not-pref)
5406 (save-window-excursion
5409 (narrow-to-region (car ibegend)
5412 (goto-char (car ibegend))
5415 (delete-region (point-min) (point-max))
5416 (mm-remove-parts handles))
5417 (setq begend (list (point-marker)))
5419 (unless (setq not-pref (cadr (member preferred ihandles)))
5420 (setq not-pref (car ihandles)))
5423 (not (gnus-unbuttonized-mime-type-p
5424 "multipart/alternative")))
5425 (gnus-add-text-properties
5428 (insert (format "%d. " id))
5432 (unless ,(not ibegend)
5433 (setq gnus-article-mime-handle-alist
5434 ',gnus-article-mime-handle-alist))
5435 (gnus-mime-display-alternative
5436 ',ihandles ',not-pref ',begend ,id))
5437 keymap ,gnus-mime-button-map
5438 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5439 face ,gnus-article-button-face
5442 (widget-convert-button 'link from (point)
5443 :action 'gnus-widget-press-button
5444 :button-keymap gnus-widget-button-keymap)
5446 (while (setq handle (pop handles))
5447 (gnus-add-text-properties
5450 (insert (format "(%c) %-18s"
5451 (if (equal handle preferred) ?* ? )
5452 (mm-handle-media-type handle)))
5456 (unless ,(not ibegend)
5457 (setq gnus-article-mime-handle-alist
5458 ',gnus-article-mime-handle-alist))
5459 (gnus-mime-display-alternative
5460 ',ihandles ',handle ',begend ,id))
5461 keymap ,gnus-mime-button-map
5462 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5463 face ,gnus-article-button-face
5466 (widget-convert-button 'link from (point)
5467 :action 'gnus-widget-press-button
5468 :button-keymap gnus-widget-button-keymap)
5472 (if (stringp (car preferred))
5473 (gnus-display-mime preferred)
5474 (let ((mail-parse-charset gnus-newsgroup-charset)
5475 (mail-parse-ignored-charsets
5476 (with-current-buffer gnus-summary-buffer
5477 gnus-newsgroup-ignored-charsets)))
5478 (mm-display-part preferred)
5482 (narrow-to-region (car begend) (point-max))
5484 nil (length gnus-article-mime-handle-alist)
5485 (gnus-article-mime-total-parts)
5486 (mm-handle-media-type handle))))))
5487 (goto-char (point-max))
5488 (setcdr begend (point-marker)))))
5490 (goto-char point))))
5492 (defconst gnus-article-wash-status-strings
5493 (let ((alist '((cite "c" "Possible hidden citation text"
5494 " " "All citation text visible")
5495 (headers "h" "Hidden headers"
5496 " " "All headers visible.")
5497 (pgp "p" "Encrypted or signed message status hidden"
5498 " " "No hidden encryption nor digital signature status")
5499 (signature "s" "Signature has been hidden"
5500 " " "Signature is visible")
5501 (overstrike "o" "Overstrike (^H) characters applied"
5502 " " "No overstrike characters applied")
5503 (gnus-show-mime "m" "Mime processing is activated"
5504 " " "Mime processing is not activated")
5505 (emphasis "e" "/*_Emphasis_*/ characters applied"
5506 " " "No /*_emphasis_*/ characters applied")))
5508 (dolist (entry alist result)
5509 (let ((key (nth 0 entry))
5510 (on (copy-sequence (nth 1 entry)))
5511 (on-help (nth 2 entry))
5512 (off (copy-sequence (nth 3 entry)))
5513 (off-help (nth 4 entry)))
5514 (put-text-property 0 1 'help-echo on-help on)
5515 (put-text-property 0 1 'help-echo off-help off)
5516 (push (list key on off) result))))
5517 "Alist of strings describing wash status in the mode line.
5518 Each entry has the form (KEY ON OF), where the KEY is a symbol
5519 representing the particular washing function, ON is the string to use
5520 in the article mode line when the washing function is active, and OFF
5521 is the string to use when it is inactive.")
5523 (defun gnus-article-wash-status-entry (key value)
5524 (let ((entry (assoc key gnus-article-wash-status-strings)))
5525 (if value (nth 1 entry) (nth 2 entry))))
5527 (defun gnus-article-wash-status ()
5528 "Return a string which display status of article washing."
5529 (with-current-buffer gnus-article-buffer
5530 (let ((cite (memq 'cite gnus-article-wash-types))
5531 (headers (memq 'headers gnus-article-wash-types))
5532 (boring (memq 'boring-headers gnus-article-wash-types))
5533 (pgp (memq 'pgp gnus-article-wash-types))
5534 (pem (memq 'pem gnus-article-wash-types))
5535 (signed (memq 'signed gnus-article-wash-types))
5536 (encrypted (memq 'encrypted gnus-article-wash-types))
5537 (signature (memq 'signature gnus-article-wash-types))
5538 (overstrike (memq 'overstrike gnus-article-wash-types))
5539 (emphasis (memq 'emphasis gnus-article-wash-types)))
5541 (gnus-article-wash-status-entry 'cite cite)
5542 (gnus-article-wash-status-entry 'headers (or headers boring))
5543 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5544 (gnus-article-wash-status-entry 'signature signature)
5545 (gnus-article-wash-status-entry 'overstrike overstrike)
5546 (gnus-article-wash-status-entry 'gnus-show-mime gnus-show-mime)
5547 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5549 (defun gnus-add-wash-type (type)
5550 "Add a washing of TYPE to the current status."
5551 (add-to-list 'gnus-article-wash-types type))
5553 (defun gnus-delete-wash-type (type)
5554 "Add a washing of TYPE to the current status."
5555 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5557 (defun gnus-add-image (category image)
5558 "Add IMAGE of CATEGORY to the list of displayed images."
5559 (let ((entry (assq category gnus-article-image-alist)))
5561 (setq entry (list category))
5562 (push entry gnus-article-image-alist))
5563 (nconc entry (list image))))
5565 (defun gnus-delete-images (category)
5566 "Delete all images in CATEGORY."
5567 (let ((entry (assq category gnus-article-image-alist)))
5568 (dolist (image (cdr entry))
5569 (gnus-remove-image image category))
5570 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5571 (gnus-delete-wash-type category)))
5573 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5575 (defun gnus-article-maybe-hide-headers ()
5576 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5577 Provided for backwards compatibility."
5578 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5579 (not (with-current-buffer gnus-summary-buffer
5580 gnus-have-all-headers)))
5581 (not gnus-inhibit-hiding))
5582 (gnus-article-hide-headers)))
5586 (defun gnus-output-to-file (file-name)
5587 "Append the current article to a file named FILE-NAME."
5588 (let ((artbuf (current-buffer)))
5590 (insert-buffer-substring artbuf)
5591 ;; Append newline at end of the buffer as separator, and then
5593 (goto-char (point-max))
5595 (let ((file-name-coding-system nnmail-pathname-coding-system))
5596 (write-region-as-binary (point-min) (point-max) file-name 'append))
5599 (defun gnus-narrow-to-page (&optional arg)
5600 "Narrow the article buffer to a page.
5601 If given a numerical ARG, move forward ARG pages."
5603 (setq arg (if arg (prefix-numeric-value arg) 0))
5605 (set-buffer gnus-article-buffer)
5606 (goto-char (point-min))
5608 ;; Remove any old next/prev buttons.
5609 (when (gnus-visual-p 'page-marker)
5610 (let ((inhibit-read-only t))
5611 (gnus-remove-text-with-property 'gnus-prev)
5612 (gnus-remove-text-with-property 'gnus-next)))
5615 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5617 (re-search-forward page-delimiter nil 'move arg)))
5618 (goto-char (match-end 0))
5620 (goto-char (point-min))
5621 (setq gnus-page-broken
5622 (and (re-search-forward page-delimiter nil t) t))))
5623 (when gnus-page-broken
5626 (if (re-search-forward page-delimiter nil 'move)
5629 (when (and (gnus-visual-p 'page-marker)
5630 (> (point-min) (save-restriction (widen) (point-min))))
5632 (goto-char (point-min))
5633 (gnus-insert-prev-page-button)))
5634 (when (and (gnus-visual-p 'page-marker)
5635 (< (point-max) (save-restriction (widen) (point-max))))
5637 (goto-char (point-max))
5638 (gnus-insert-next-page-button))))))
5640 ;; Article mode commands
5642 (defun gnus-article-goto-next-page ()
5643 "Show the next page of the article."
5645 (when (gnus-article-next-page)
5646 (goto-char (point-min))
5647 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5650 (defun gnus-article-goto-prev-page ()
5651 "Show the previous page of the article."
5654 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5655 (gnus-article-prev-page nil)))
5657 ;; This is cleaner but currently breaks `gnus-pick-mode':
5659 ;; (defun gnus-article-goto-next-page ()
5660 ;; "Show the next page of the article."
5662 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5663 ;; (gnus-summary-next-page)))
5665 ;; (defun gnus-article-goto-prev-page ()
5666 ;; "Show the next page of the article."
5668 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5669 ;; (gnus-summary-prev-page)))
5671 (defun gnus-article-next-page (&optional lines)
5672 "Show the next page of the current article.
5673 If end of article, return non-nil. Otherwise return nil.
5674 Argument LINES specifies lines to be scrolled up."
5676 (move-to-window-line -1)
5679 (and (pos-visible-in-window-p) ;Not continuation line.
5680 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5681 ;; Nothing in this page.
5682 (if (or (not gnus-page-broken)
5687 (eobp)))) ;Real end-of-buffer?
5689 (when gnus-article-over-scroll
5690 (gnus-article-next-page-1 lines))
5692 (gnus-narrow-to-page 1) ;Go to next page.
5694 ;; More in this page.
5695 (gnus-article-next-page-1 lines)
5698 (defmacro gnus-article-beginning-of-window ()
5699 "Move point to the beginning of the window.
5700 In Emacs, the point is placed at the line number which `scroll-margin'
5702 (if (featurep 'xemacs)
5703 '(move-to-window-line 0)
5704 '(move-to-window-line
5705 (min (max 0 scroll-margin)
5706 (max 1 (- (window-height)
5707 (if mode-line-format 1 0)
5708 (if header-line-format 1 0)))))))
5710 (defun gnus-article-next-page-1 (lines)
5711 (when (and (not (featurep 'xemacs))
5714 (numberp (symbol-value 'scroll-margin))
5715 (> (symbol-value 'scroll-margin) 0))
5716 ;; Protect against the bug that Emacs 21.x hangs up when scrolling up for
5717 ;; too many number of lines if `scroll-margin' is set as two or greater.
5718 (setq lines (min lines
5719 (max 0 (- (count-lines (window-start) (point-max))
5720 (symbol-value 'scroll-margin))))))
5722 (let ((scroll-in-place nil))
5725 ;; Long lines may cause an end-of-buffer error.
5726 (goto-char (point-max))))
5727 (gnus-article-beginning-of-window))
5729 (defun gnus-article-prev-page (&optional lines)
5730 "Show previous page of current article.
5731 Argument LINES specifies lines to be scrolled down."
5733 (move-to-window-line 0)
5734 (if (and gnus-page-broken
5736 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5738 (gnus-narrow-to-page -1) ;Go to previous page.
5739 (goto-char (point-max))
5743 (let ((scroll-in-place nil))
5744 (scroll-down lines))
5745 (beginning-of-buffer
5746 (goto-char (point-min))))
5747 (gnus-article-beginning-of-window))))
5749 (defun gnus-article-only-boring-p ()
5750 "Decide whether there is only boring text remaining in the article.
5751 Something \"interesting\" is a word of at least two letters that does
5752 not have a face in `gnus-article-boring-faces'."
5753 (when (and gnus-article-skip-boring
5754 (boundp 'gnus-article-boring-faces)
5755 (symbol-value 'gnus-article-boring-faces))
5758 (while (re-search-forward "\\b\\w\\w" nil t)
5760 (when (not (gnus-intersection
5761 (gnus-faces-at (point))
5762 (symbol-value 'gnus-article-boring-faces)))
5763 (throw 'only-boring nil)))
5764 (throw 'only-boring t)))))
5766 (defun gnus-article-refer-article ()
5767 "Read article specified by message-id around point."
5770 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
5771 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
5772 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
5773 (let ((msg-id (concat "<" (match-string 0) ">")))
5774 (set-buffer gnus-summary-buffer)
5775 (gnus-summary-refer-article msg-id))
5776 (error "No references around point"))))
5778 (defun gnus-article-show-summary ()
5779 "Reconfigure windows to show summary buffer."
5781 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5782 (error "There is no summary buffer for this article buffer")
5783 (gnus-article-set-globals)
5784 (gnus-configure-windows 'article)
5785 (gnus-summary-goto-subject gnus-current-article)
5786 (gnus-summary-position-point)))
5788 (defun gnus-article-describe-briefly ()
5789 "Describe article mode commands briefly."
5791 (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")))
5793 (defun gnus-article-summary-command ()
5794 "Execute the last keystroke in the summary buffer."
5796 (let ((obuf (current-buffer))
5797 (owin (current-window-configuration))
5799 (switch-to-buffer gnus-article-current-summary 'norecord)
5800 (setq func (lookup-key (current-local-map) (this-command-keys)))
5801 (call-interactively func)
5803 (set-window-configuration owin)
5804 (set-window-point (get-buffer-window (current-buffer)) (point))))
5806 (defun gnus-article-summary-command-nosave ()
5807 "Execute the last keystroke in the summary buffer."
5810 (pop-to-buffer gnus-article-current-summary 'norecord)
5811 (setq func (lookup-key (current-local-map) (this-command-keys)))
5812 (call-interactively func)))
5814 (defun gnus-article-check-buffer ()
5815 "Beep if not in an article buffer."
5816 (unless (eq (get-buffer gnus-article-buffer) (current-buffer))
5817 (error "Command invoked outside of a Gnus article buffer")))
5819 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5820 "Read a summary buffer key sequence and execute it from the article buffer."
5822 (gnus-article-check-buffer)
5824 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5825 "Zc" "ZC" "ZE" "ZJ" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5826 "=" "^" "\M-^" "|"))
5832 '("n" "Gn" "p" "Gp"))
5835 (set-buffer gnus-article-current-summary)
5836 (let (gnus-pick-mode)
5837 (push (or key last-command-event) unread-command-events)
5838 (setq keys (static-if (featurep 'xemacs)
5839 (events-to-keys (read-key-sequence nil))
5840 (read-key-sequence nil)))))
5843 (if (or (member keys nosaves)
5844 (member keys nosave-but-article)
5845 (member keys nosave-in-article))
5847 (save-window-excursion
5848 (pop-to-buffer gnus-article-current-summary 'norecord)
5849 ;; We disable the pick minor mode commands.
5850 (let (gnus-pick-mode)
5851 (setq func (lookup-key (current-local-map) keys))))
5855 (unless (member keys nosave-in-article)
5856 (set-buffer gnus-article-current-summary))
5857 (call-interactively func)
5858 (setq new-sum-point (point)))
5859 (when (member keys nosave-but-article)
5860 (pop-to-buffer gnus-article-buffer 'norecord)))
5861 ;; These commands should restore window configuration.
5862 (let ((obuf (current-buffer))
5863 (owin (current-window-configuration))
5865 win func in-buffer selected new-sum-start new-sum-hscroll)
5866 (cond (not-restore-window
5867 (pop-to-buffer gnus-article-current-summary 'norecord))
5868 ((setq win (get-buffer-window gnus-article-current-summary))
5869 (select-window win))
5871 (switch-to-buffer gnus-article-current-summary 'norecord)))
5872 (setq in-buffer (current-buffer))
5873 ;; We disable the pick minor mode commands.
5874 (if (and (setq func (let (gnus-pick-mode)
5875 (lookup-key (current-local-map) keys)))
5878 (call-interactively func)
5879 (when (eq win (selected-window))
5880 (setq new-sum-point (point)
5881 new-sum-start (window-start win)
5882 new-sum-hscroll (window-hscroll win)))
5883 (when (eq in-buffer (current-buffer))
5884 (setq selected (gnus-summary-select-article))
5886 (unless not-restore-window
5887 (set-window-configuration owin))
5888 (when (eq selected 'old)
5890 (set-window-start (get-buffer-window (current-buffer))
5892 (set-window-point (get-buffer-window (current-buffer))
5894 (when (and (not not-restore-window)
5896 (set-window-point win new-sum-point)
5897 (set-window-start win new-sum-start)
5898 (set-window-hscroll win new-sum-hscroll))))
5899 (set-window-configuration owin)
5902 (defun gnus-article-describe-key (key)
5903 "Display documentation of the function invoked by KEY. KEY is a string."
5904 (interactive "kDescribe key: ")
5905 (gnus-article-check-buffer)
5906 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5908 (set-buffer gnus-article-current-summary)
5909 (let (gnus-pick-mode)
5910 (if (featurep 'xemacs)
5912 (push (elt key 0) unread-command-events)
5913 (setq key (events-to-keys
5914 (read-key-sequence "Describe key: "))))
5915 (setq unread-command-events
5917 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5919 (setq key (read-key-sequence "Describe key: "))))
5921 (describe-key key)))
5923 (defun gnus-article-describe-key-briefly (key &optional insert)
5924 "Display documentation of the function invoked by KEY. KEY is a string."
5925 (interactive "kDescribe key: \nP")
5926 (gnus-article-check-buffer)
5927 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5929 (set-buffer gnus-article-current-summary)
5930 (let (gnus-pick-mode)
5931 (if (featurep 'xemacs)
5933 (push (elt key 0) unread-command-events)
5934 (setq key (events-to-keys
5935 (read-key-sequence "Describe key: "))))
5936 (setq unread-command-events
5938 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5940 (setq key (read-key-sequence "Describe key: "))))
5941 (describe-key-briefly key insert))
5942 (describe-key-briefly key insert)))
5944 (defun gnus-article-reply-with-original (&optional wide)
5945 "Start composing a reply mail to the current message.
5946 The text in the region will be yanked. If the region isn't active,
5947 the entire article will be yanked."
5949 (let ((article (cdr gnus-article-current))
5951 (if (not (gnus-region-active-p))
5952 (with-current-buffer gnus-summary-buffer
5953 (gnus-summary-reply (list (list article)) wide))
5954 (setq contents (buffer-substring (point) (mark t)))
5955 ;; Deactivate active regions.
5956 (when (and (boundp 'transient-mark-mode)
5957 transient-mark-mode)
5958 (setq mark-active nil))
5959 (with-current-buffer gnus-summary-buffer
5961 (list (list article contents)) wide)))))
5963 (defun gnus-article-followup-with-original ()
5964 "Compose a followup to the current article.
5965 The text in the region will be yanked. If the region isn't active,
5966 the entire article will be yanked."
5968 (let ((article (cdr gnus-article-current))
5970 (if (not (gnus-region-active-p))
5971 (with-current-buffer gnus-summary-buffer
5972 (gnus-summary-followup (list (list article))))
5973 (setq contents (buffer-substring (point) (mark t)))
5974 ;; Deactivate active regions.
5975 (when (and (boundp 'transient-mark-mode)
5976 transient-mark-mode)
5977 (setq mark-active nil))
5978 (with-current-buffer gnus-summary-buffer
5979 (gnus-summary-followup
5980 (list (list article contents)))))))
5982 (defun gnus-article-hide (&optional arg force)
5983 "Hide all the gruft in the current article.
5984 This means that signatures, cited text and (some) headers will be
5986 If given a prefix, show the hidden text instead."
5987 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5988 (gnus-article-hide-headers arg)
5989 (gnus-article-hide-list-identifiers arg)
5990 (gnus-article-hide-citation-maybe arg force)
5991 (gnus-article-hide-signature arg))
5993 (defun gnus-article-maybe-highlight ()
5994 "Do some article highlighting if article highlighting is requested."
5995 (when (gnus-visual-p 'article-highlight 'highlight)
5996 (gnus-article-highlight-some)))
5998 (defun gnus-check-group-server ()
5999 ;; Make sure the connection to the server is alive.
6000 (unless (gnus-server-opened
6001 (gnus-find-method-for-group gnus-newsgroup-name))
6002 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
6003 (gnus-request-group gnus-newsgroup-name t)))
6006 (autoload 'nneething-get-file-name "nneething"))
6008 (defun gnus-request-article-this-buffer (article group)
6009 "Get an article and insert it into this buffer."
6010 (let (do-update-line sparse-header)
6014 (gnus-kill-all-overlays)
6015 (setq group (or group gnus-newsgroup-name))
6017 ;; Using `gnus-request-article' directly will insert the article into
6018 ;; `nntp-server-buffer' - so we'll save some time by not having to
6019 ;; copy it from the server buffer into the article buffer.
6021 ;; We only request an article by message-id when we do not have the
6022 ;; headers for it, so we'll have to get those.
6023 (when (stringp article)
6024 (gnus-read-header article))
6026 ;; If the article number is negative, that means that this article
6027 ;; doesn't belong in this newsgroup (possibly), so we find its
6028 ;; message-id and request it by id instead of number.
6029 (when (and (numberp article)
6031 (get-buffer gnus-summary-buffer)
6032 (gnus-buffer-exists-p gnus-summary-buffer))
6034 (set-buffer gnus-summary-buffer)
6035 (let ((header (gnus-summary-article-header article)))
6038 ((memq article gnus-newsgroup-sparse)
6039 ;; This is a sparse gap article.
6040 (setq do-update-line article)
6041 (setq article (mail-header-id header))
6042 (setq sparse-header (gnus-read-header article))
6043 (setq gnus-newsgroup-sparse
6044 (delq article gnus-newsgroup-sparse)))
6046 ;; It's a real article.
6047 (setq article (mail-header-id header)))
6049 ;; It is an extracted pseudo-article.
6050 (setq article 'pseudo)
6051 (gnus-request-pseudo-article header))))
6053 (let ((method (gnus-find-method-for-group
6054 gnus-newsgroup-name)))
6055 (when (and (eq (car method) 'nneething)
6057 (let ((dir (nneething-get-file-name
6058 (mail-header-id header))))
6059 (when (and (stringp dir)
6060 (file-directory-p dir))
6061 (setq article 'nneething)
6062 (gnus-group-enter-directory dir))))))))
6065 ;; Refuse to select canceled articles.
6066 ((and (numberp article)
6068 (get-buffer gnus-summary-buffer)
6069 (gnus-buffer-exists-p gnus-summary-buffer)
6070 (eq (cdr (with-current-buffer gnus-summary-buffer
6071 (assq article gnus-newsgroup-reads)))
6072 gnus-canceled-mark))
6074 ;; We first check `gnus-original-article-buffer'.
6075 ((and (get-buffer gnus-original-article-buffer)
6077 (with-current-buffer gnus-original-article-buffer
6078 (and (equal (car gnus-original-article) group)
6079 (eq (cdr gnus-original-article) article))))
6080 (insert-buffer-substring gnus-original-article-buffer)
6082 ;; Check the backlog.
6083 ((and gnus-keep-backlog
6084 (gnus-backlog-request-article group article (current-buffer)))
6086 ;; Check asynchronous pre-fetch.
6087 ((gnus-async-request-fetched-article group article (current-buffer))
6088 (gnus-async-prefetch-next group article gnus-summary-buffer)
6089 (when (and (numberp article) gnus-keep-backlog)
6090 (gnus-backlog-enter-article group article (current-buffer)))
6093 ((and gnus-use-cache
6095 (gnus-cache-request-article article group))
6097 ;; Check the agent cache.
6098 ((gnus-agent-request-article article group)
6100 ;; Get the article and put into the article buffer.
6101 ((or (stringp article)
6103 (let ((gnus-override-method gnus-override-method)
6104 (methods (and (stringp article)
6105 gnus-refer-article-method))
6106 (backend (car (gnus-find-method-for-group
6107 gnus-newsgroup-name)))
6109 (inhibit-read-only t))
6110 (if (or (not (listp methods))
6111 (and (symbolp (car methods))
6112 (assq (car methods) nnoo-definition-alist)))
6113 (setq methods (list methods)))
6114 (when (and (null gnus-override-method)
6116 (setq gnus-override-method (pop methods)))
6118 (when (eq gnus-override-method 'current)
6119 (setq gnus-override-method
6120 (with-current-buffer gnus-summary-buffer
6121 gnus-current-select-method)))
6123 (gnus-kill-all-overlays)
6124 (let ((gnus-newsgroup-name group))
6125 (gnus-check-group-server))
6127 ((gnus-request-article article group (current-buffer))
6128 (when (numberp article)
6129 (gnus-async-prefetch-next group article
6130 gnus-summary-buffer)
6131 (when gnus-keep-backlog
6132 (gnus-backlog-enter-article
6133 group article (current-buffer))))
6134 (setq result 'article))
6136 (setq gnus-override-method (pop methods)))
6137 ((not (string-match "^400 "
6138 (nnheader-get-report backend)))
6139 ;; If we get 400 server disconnect, reconnect and
6140 ;; retry; otherwise, assume the article has expired.
6141 (setq result 'done))))
6142 (and (eq result 'article) 'article)))
6146 ;; Associate this article with the current summary buffer.
6147 (setq gnus-article-current-summary gnus-summary-buffer)
6149 ;; Take the article from the original article buffer
6150 ;; and place it in the buffer it's supposed to be in.
6151 (when (and (get-buffer gnus-article-buffer)
6152 (equal (buffer-name (current-buffer))
6153 (buffer-name (get-buffer gnus-article-buffer))))
6155 (if (get-buffer gnus-original-article-buffer)
6156 (set-buffer gnus-original-article-buffer)
6157 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
6158 (buffer-disable-undo)
6159 (setq major-mode 'gnus-original-article-mode)
6160 (setq buffer-read-only t))
6161 (let ((inhibit-read-only t))
6163 (insert-buffer-substring gnus-article-buffer))
6164 (setq gnus-original-article (cons group article)))
6167 (run-hooks 'gnus-article-decode-hook)
6168 ;; Mark article as decoded or not.
6169 (setq gnus-article-decoded-p gnus-article-decode-hook))
6171 ;; Update sparse articles.
6172 (when (and do-update-line
6173 (or (numberp article)
6175 (let ((buf (current-buffer)))
6176 (set-buffer gnus-summary-buffer)
6177 (gnus-summary-update-article do-update-line sparse-header)
6178 (gnus-summary-goto-subject do-update-line nil t)
6179 (set-window-point (gnus-get-buffer-window (current-buffer) t)
6181 (set-buffer buf))))))
6187 (defcustom gnus-article-edit-mode-hook nil
6188 "Hook run in article edit mode buffers."
6189 :group 'gnus-article-various
6192 (defcustom gnus-article-edit-article-setup-function
6193 'gnus-article-mime-edit-article-setup
6194 "Function called to setup an editing article buffer."
6195 :group 'gnus-article-various
6198 (defvar gnus-article-edit-done-function nil)
6200 (defvar gnus-article-edit-mode-map nil)
6202 ;; Should we be using derived.el for this?
6203 (unless gnus-article-edit-mode-map
6204 (setq gnus-article-edit-mode-map (make-keymap))
6205 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
6207 (gnus-define-keys gnus-article-edit-mode-map
6208 "\C-c?" describe-mode
6209 "\C-c\C-c" gnus-article-edit-done
6210 "\C-c\C-k" gnus-article-edit-exit
6211 "\C-c\C-f\C-t" message-goto-to
6212 "\C-c\C-f\C-o" message-goto-from
6213 "\C-c\C-f\C-b" message-goto-bcc
6214 ;;"\C-c\C-f\C-w" message-goto-fcc
6215 "\C-c\C-f\C-c" message-goto-cc
6216 "\C-c\C-f\C-s" message-goto-subject
6217 "\C-c\C-f\C-r" message-goto-reply-to
6218 "\C-c\C-f\C-n" message-goto-newsgroups
6219 "\C-c\C-f\C-d" message-goto-distribution
6220 "\C-c\C-f\C-f" message-goto-followup-to
6221 "\C-c\C-f\C-m" message-goto-mail-followup-to
6222 "\C-c\C-f\C-k" message-goto-keywords
6223 "\C-c\C-f\C-u" message-goto-summary
6224 "\C-c\C-f\C-i" message-insert-or-toggle-importance
6225 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
6226 "\C-c\C-b" message-goto-body
6227 "\C-c\C-i" message-goto-signature
6229 "\C-c\C-t" message-insert-to
6230 "\C-c\C-n" message-insert-newsgroups
6231 "\C-c\C-o" message-sort-headers
6232 "\C-c\C-e" message-elide-region
6233 "\C-c\C-v" message-delete-not-region
6234 "\C-c\C-z" message-kill-to-signature
6235 "\M-\r" message-newline-and-reformat
6236 "\C-c\C-a" mml-attach-file
6237 "\C-a" message-beginning-of-line
6239 "\M-;" comment-region)
6241 (gnus-define-keys (gnus-article-edit-wash-map
6242 "\C-c\C-w" gnus-article-edit-mode-map)
6243 "f" gnus-article-edit-full-stops))
6246 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
6248 ["Fetch To" message-insert-to t]
6249 ["Fetch Newsgroups" message-insert-newsgroups t]
6251 ["To" message-goto-to t]
6252 ["From" message-goto-from t]
6253 ["Subject" message-goto-subject t]
6254 ["Cc" message-goto-cc t]
6255 ["Reply-To" message-goto-reply-to t]
6256 ["Summary" message-goto-summary t]
6257 ["Keywords" message-goto-keywords t]
6258 ["Newsgroups" message-goto-newsgroups t]
6259 ["Followup-To" message-goto-followup-to t]
6260 ["Mail-Followup-To" message-goto-mail-followup-to t]
6261 ["Distribution" message-goto-distribution t]
6262 ["Body" message-goto-body t]
6263 ["Signature" message-goto-signature t]))
6265 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
6266 "Major mode for editing articles.
6267 This is an extended text-mode.
6269 \\{gnus-article-edit-mode-map}"
6270 (make-local-variable 'gnus-article-edit-done-function)
6271 (make-local-variable 'gnus-prev-winconf)
6272 (set (make-local-variable 'font-lock-defaults)
6273 '(message-font-lock-keywords t))
6274 (set (make-local-variable 'mail-header-separator) "")
6275 (set (make-local-variable 'gnus-article-edit-mode) t)
6276 (easy-menu-add message-mode-field-menu message-mode-map)
6277 (setq buffer-read-only nil)
6278 (buffer-enable-undo)
6281 (defun gnus-article-edit (&optional force)
6282 "Edit the current article.
6283 This will have permanent effect only in mail groups.
6284 If FORCE is non-nil, allow editing of articles even in read-only
6287 (when (and (not force)
6288 (gnus-group-read-only-p))
6289 (error "The current newsgroup does not support article editing"))
6290 (gnus-article-date-original)
6291 (gnus-article-edit-article
6293 `(lambda (no-highlight)
6295 (gnus-summary-edit-article-done
6296 ,(or (mail-header-references gnus-current-headers) "")
6297 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
6299 (defun gnus-article-edit-article (start-func exit-func &optional quiet)
6300 "Start editing the contents of the current article buffer."
6301 (let ((winconf (current-window-configuration)))
6302 (set-buffer gnus-article-buffer)
6303 (let ((message-auto-save-directory
6304 ;; Don't associate the article buffer with a draft file.
6306 (gnus-article-edit-mode))
6307 (funcall start-func)
6308 (set-buffer-modified-p nil)
6309 (gnus-configure-windows 'edit-article)
6310 (setq gnus-article-edit-done-function exit-func)
6311 (setq gnus-prev-winconf winconf)
6312 (when gnus-article-edit-article-setup-function
6313 (funcall gnus-article-edit-article-setup-function))
6315 (gnus-message 6 "C-c C-c to end edits; C-c C-k to exit"))))
6317 (defun gnus-article-edit-done (&optional arg)
6318 "Update the article edits and exit."
6320 (let ((func gnus-article-edit-done-function)
6321 (buf (current-buffer))
6322 (start (window-start))
6324 (winconf gnus-prev-winconf))
6325 (remove-hook 'gnus-article-mode-hook
6326 'gnus-article-mime-edit-article-unwind)
6327 (widen) ;; Widen it in case that users narrowed the buffer.
6330 ;; The cache and backlog have to be flushed somewhat.
6331 (when gnus-keep-backlog
6332 (gnus-backlog-remove-article
6333 (car gnus-article-current) (cdr gnus-article-current)))
6334 ;; Flush original article as well.
6336 (when (get-buffer gnus-original-article-buffer)
6337 (set-buffer gnus-original-article-buffer)
6338 (setq gnus-original-article nil)))
6339 (when gnus-use-cache
6340 (gnus-cache-update-article
6341 (car gnus-article-current) (cdr gnus-article-current)))
6342 ;; We remove all text props from the article buffer.
6343 (kill-all-local-variables)
6344 (set-text-properties (point-min) (point-max) nil)
6346 (set-window-configuration winconf)
6348 (set-window-start (get-buffer-window buf) start)
6349 (set-window-point (get-buffer-window buf) (point)))
6350 (gnus-summary-show-article))
6352 (defun gnus-article-edit-exit ()
6353 "Exit the article editing without updating."
6355 (when (or (not (buffer-modified-p))
6356 (yes-or-no-p "Article modified; kill anyway? "))
6357 (let ((curbuf (current-buffer))
6359 (window-start (window-start)))
6361 (if (gnus-buffer-live-p gnus-original-article-buffer)
6362 (insert-buffer-substring gnus-original-article-buffer))
6363 (let ((winconf gnus-prev-winconf))
6364 (kill-all-local-variables)
6366 (set-window-configuration winconf)
6367 ;; Tippy-toe some to make sure that point remains where it was.
6368 (save-current-buffer
6370 (set-window-start (get-buffer-window (current-buffer)) window-start)
6372 (gnus-summary-show-article)))
6374 (defun gnus-article-edit-full-stops ()
6375 "Interactively repair spacing at end of sentences."
6378 (goto-char (point-min))
6379 (search-forward-regexp "^$" nil t)
6380 (let ((case-fold-search nil))
6381 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
6384 ;;; Article editing with MIME-Edit
6387 (defcustom gnus-article-mime-edit-article-setup-hook nil
6388 "Hook run after setting up a MIME editing article buffer."
6389 :group 'gnus-article-various
6392 (defun gnus-article-mime-edit-article-unwind ()
6393 "Unwind `gnus-article-buffer' if article editing was given up."
6394 (remove-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6395 (when (featurep 'font-lock)
6396 (setq font-lock-defaults nil)
6397 (font-lock-mode -1))
6398 (when mime-edit-mode-flag
6399 (mime-edit-exit 'nomime 'no-error)
6402 (defun gnus-article-mime-edit-article-setup ()
6403 "Convert current buffer to MIME-Edit buffer and turn on MIME-Edit mode
6404 after replacing with the original article."
6405 (setq gnus-show-mime t)
6406 (setq gnus-article-edit-done-function
6407 `(lambda (&rest args)
6408 (when mime-edit-mode-flag
6409 (let (mime-edit-insert-user-agent-field)
6412 (goto-char (point-min))
6413 (let (case-fold-search)
6414 (when (re-search-forward
6415 (format "^%s$" (regexp-quote mail-header-separator))
6417 (replace-match "")))
6418 (apply ,gnus-article-edit-done-function args)
6421 (buffer-substring-no-properties (point-min) (point-max))
6422 (set-buffer (get-buffer-create gnus-original-article-buffer))
6424 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6425 (set-buffer gnus-article-buffer)
6426 (gnus-article-prepare-display)))
6427 (substitute-key-definition 'gnus-article-edit-done
6428 'gnus-article-mime-edit-done
6429 gnus-article-edit-mode-map)
6430 (substitute-key-definition 'gnus-article-edit-exit
6431 'gnus-article-mime-edit-exit
6432 gnus-article-edit-mode-map)
6434 (insert-buffer-substring gnus-original-article-buffer)
6435 (unless (member (with-current-buffer gnus-summary-buffer
6436 gnus-newsgroup-name)
6437 '("nndraft:delayed" "nndraft:drafts"))
6438 (let ((ofn (symbol-function 'mime-edit-decode-single-part-in-buffer)))
6439 (fset 'mime-edit-decode-single-part-in-buffer
6440 (lambda (&rest args)
6441 (if (let ((content-type (car args)))
6442 (and (eq 'message (mime-content-type-primary-type
6444 (eq 'rfc822 (mime-content-type-subtype
6446 (setcar (cdr args) 'not-decode-text))
6450 (fset 'mime-edit-decode-single-part-in-buffer ofn))))
6451 (when (featurep 'font-lock)
6452 (set (make-local-variable 'font-lock-defaults)
6453 '(message-font-lock-keywords t))
6454 (font-lock-set-defaults)
6455 (turn-on-font-lock))
6456 (set-buffer-modified-p nil)
6457 (delete-other-windows)
6458 (add-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6459 (gnus-run-hooks 'gnus-article-mime-edit-article-setup-hook))
6461 (defun gnus-article-mime-edit-done (&optional arg)
6462 "Update the article MIME edits and exit."
6464 (when (featurep 'font-lock)
6465 (setq font-lock-defaults nil)
6466 (font-lock-mode -1))
6467 (let ((inhibit-read-only t))
6468 (gnus-article-edit-done arg)))
6470 (defun gnus-article-mime-edit-exit ()
6471 "Exit the article MIME editing without updating."
6473 (when (or (not (buffer-modified-p))
6474 (yes-or-no-p "Article modified; kill anyway? "))
6475 (when (featurep 'font-lock)
6476 (setq font-lock-defaults nil)
6477 (font-lock-mode -1))
6478 (when mime-edit-mode-flag
6479 (let (mime-edit-insert-user-agent-field)
6482 (goto-char (point-min))
6483 (let (case-fold-search)
6484 (when (re-search-forward
6485 (format "^%s$" (regexp-quote mail-header-separator)) nil t)
6486 (replace-match "")))
6487 (let ((winconf gnus-prev-winconf))
6489 (buffer-substring-no-properties (point-min) (point-max))
6490 (set-buffer (get-buffer-create gnus-original-article-buffer))
6492 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6493 (set-buffer gnus-article-buffer)
6494 (gnus-article-prepare-display)
6495 (set-window-configuration winconf))))
6498 ;;; Article highlights
6501 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
6503 ;;; Internal Variables:
6505 (defcustom gnus-button-url-regexp
6506 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
6507 "\\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:]]\\)"
6508 "\\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\\)\\)")
6509 "Regular expression that matches URLs."
6510 :group 'gnus-article-buttons
6513 (defcustom gnus-button-valid-fqdn-regexp
6514 message-valid-fqdn-regexp
6515 "Regular expression that matches a valid FQDN."
6517 :group 'gnus-article-buttons
6520 ;; Regexp suggested by Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
6521 (defcustom gnus-button-valid-localpart-regexp
6522 "[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t ]*"
6523 "Regular expression that matches a localpart of mail addresses or MIDs."
6525 :group 'gnus-article-buttons
6528 (defcustom gnus-button-man-handler 'manual-entry
6529 "Function to use for displaying man pages.
6530 The function must take at least one argument with a string naming the
6533 :type '(choice (function-item :tag "Man" manual-entry)
6534 (function-item :tag "Woman" woman)
6535 (function :tag "Other"))
6536 :group 'gnus-article-buttons)
6538 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
6539 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
6540 If the default site is too slow, try to find a CTAN mirror, see
6541 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
6542 the variable `gnus-button-handle-ctan'."
6544 :group 'gnus-article-buttons
6545 :link '(custom-manual "(gnus)Group Parameters")
6546 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
6547 (const "http://tug.ctan.org/tex-archive/")
6548 (const "http://www.dante.de/CTAN/")
6549 (string :tag "Other")))
6551 (defcustom gnus-button-ctan-handler 'browse-url
6552 "Function to use for displaying CTAN links.
6553 The function must take one argument, the string naming the URL."
6555 :type '(choice (function-item :tag "Browse Url" browse-url)
6556 (function :tag "Other"))
6557 :group 'gnus-article-buttons)
6559 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
6560 "Bogus strings removed from CTAN URLs."
6562 :group 'gnus-article-buttons
6563 :type '(choice (const "^/?tex-archive/\\|/")
6564 (regexp :tag "Other")))
6566 (defcustom gnus-button-ctan-directory-regexp
6568 (list "archive-tools" "biblio" "bibliography" "digests" "documentation"
6569 "dviware" "fonts" "graphics" "help" "indexing" "info" "language"
6570 "languages" "macros" "nonfree" "obsolete" "support" "systems"
6571 "tds" "tools" "usergrps" "web") t)
6572 "Regular expression for ctan directories.
6573 It should match all directories in the top level of `gnus-ctan-url'."
6575 :group 'gnus-article-buttons
6578 (defcustom gnus-button-mid-or-mail-regexp
6579 (concat "\\b\\(<?" gnus-button-valid-localpart-regexp "@"
6580 gnus-button-valid-fqdn-regexp
6582 "Regular expression that matches a message ID or a mail address."
6584 :group 'gnus-article-buttons
6587 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
6588 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
6589 Strings like this can be either a message ID or a mail address. If it is one
6590 of the symbols `mid' or `mail', Gnus will always assume that the string is a
6591 message ID or a mail address, respectively. If this variable is set to the
6592 symbol `ask', always query the user what do do. If it is a function, this
6593 function will be called with the string as it's only argument. The function
6594 must return `mid', `mail', `invalid' or `ask'."
6596 :group 'gnus-article-buttons
6597 :type '(choice (function-item :tag "Heuristic function"
6598 gnus-button-mid-or-mail-heuristic)
6603 (defcustom gnus-button-mid-or-mail-heuristic-alist
6604 '((-10.0 . ".+\\$.+@")
6607 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
6608 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
6609 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
6610 (-1.0 . "^[^a-z]+@")
6612 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
6613 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
6614 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
6615 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
6618 (-1.0 . "^[0-9][0-9]")
6620 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
6621 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6622 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
6623 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6625 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
6626 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
6629 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
6631 ;; compensation for TDMA dated mail addresses:
6632 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
6634 (-20.0 . "\\.fsf@") ;; Gnus
6637 (-20.0 . "_-_") ;; Subject change in thread
6639 (-20.0 . "\\.ln@") ;; leafnode
6640 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
6641 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
6643 ;; (5.0 . "") ;; $local_part_len <= 7
6644 (10.0 . "^[^0-9]+@")
6645 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
6646 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
6649 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
6651 (0.5 . "^[A-Z][a-z]")
6652 (0.5 . "^[A-Z][a-z][a-z]")
6653 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
6654 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
6655 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
6657 A negative RATE indicates a message IDs, whereas a positive indicates a mail
6658 address. The REGEXP is processed with `case-fold-search' set to nil."
6660 :group 'gnus-article-buttons
6661 :type '(repeat (cons (number :tag "Rate")
6662 (regexp :tag "Regexp"))))
6664 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
6665 "Guess whether MID-OR-MAIL is a message ID or a mail address.
6666 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
6667 address, `ask' if unsure and `invalid' if the string is invalid."
6668 (let ((case-fold-search nil)
6669 (list gnus-button-mid-or-mail-heuristic-alist)
6670 (result 0) rate regexp lpartlen elem)
6672 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
6673 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
6674 ;; Certain special cases...
6677 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
6678 "^[0-9]+\\.[0-9]+@compuserve\\|"
6679 "@public\\.gmane\\.org")
6681 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
6682 (setq result 'mail))
6683 (when (string-match "@.*@\\| " mid-or-mail)
6684 (gnus-message 8 "`%s' is invalid." mid-or-mail)
6685 (setq result 'invalid))
6686 ;; Nothing more to do, if result is not a number here...
6687 (when (numberp result)
6689 (setq elem (car list)
6693 (when (string-match regexp mid-or-mail)
6694 (setq result (+ result rate))
6696 9 "`%s' matched `%s', rate `%s', result `%s'."
6697 mid-or-mail regexp rate result)))
6698 (when (<= lpartlen 7)
6699 (setq result (+ result 5.0))
6700 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
6701 mid-or-mail result))
6702 (when (>= lpartlen 12)
6703 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
6705 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
6706 ;; Long local part should contain realname if e-mail address,
6707 ;; too many digits: message-id.
6708 ;; $score -= 5.0 + 0.1 * $local_part_len;
6709 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6710 (setq result (+ result rate))
6712 9 "Many digits in `%s', rate `%s', result `%s'."
6713 mid-or-mail rate result))
6714 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6716 ;; Too few vowels [^aeiouy]{4,}.*\@
6717 (setq result (+ result -5.0))
6719 9 "Few vowels in `%s', rate `%s', result `%s'."
6720 mid-or-mail -5.0 result))
6722 (setq result (+ result 5.0))
6724 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6725 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6726 ;; Maybe we should make this a customizable alist: (condition . 'result)
6728 ((symbolp result) result)
6729 ;; Now convert number into proper results:
6730 ((< result -10.0) 'mid)
6731 ((> result 10.0) 'mail)
6734 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6735 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6736 (url-mid (concat "news" ":" mid-or-mail))
6737 (url-mailto (concat "mailto" ":" mid-or-mail)))
6738 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6739 (when (fboundp pref)
6741 ;; get rid of surrounding angles...
6743 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6744 (if (or (eq 'mid guessed) (eq 'mail guessed))
6748 (save-window-excursion
6749 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6752 (cond ((eq pref 'mid)
6753 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6754 (gnus-button-handle-news url-mid))
6756 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6757 (gnus-url-mailto url-mailto))
6758 (t (gnus-message 3 "Invalid string.")))))
6760 (defun gnus-button-handle-custom (url)
6761 "Follow a Custom URL."
6762 (customize-apropos (gnus-url-unhex-string url)))
6764 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6766 ;; FIXME: Maybe we should merge some of the functions that do quite similar
6769 (defun gnus-button-handle-describe-function (url)
6770 "Call `describe-function' when pushing the corresponding URL button."
6773 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6775 (defun gnus-button-handle-describe-variable (url)
6776 "Call `describe-variable' when pushing the corresponding URL button."
6779 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6781 (defun gnus-button-handle-symbol (url)
6782 "Display help on variable or function.
6783 Calls `describe-variable' or `describe-function'."
6784 (let ((sym (intern url)))
6786 ((fboundp sym) (describe-function sym))
6787 ((boundp sym) (describe-variable sym))
6788 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
6790 (defun gnus-button-handle-describe-key (url)
6791 "Call `describe-key' when pushing the corresponding URL button."
6793 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6794 (keys (ignore-errors (eval `(kbd ,key-string)))))
6797 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6799 (defun gnus-button-handle-apropos (url)
6800 "Call `apropos' when pushing the corresponding URL button."
6801 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6803 (defun gnus-button-handle-apropos-command (url)
6804 "Call `apropos' when pushing the corresponding URL button."
6806 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6808 (defun gnus-button-handle-apropos-variable (url)
6809 "Call `apropos' when pushing the corresponding URL button."
6811 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6812 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6814 (defun gnus-button-handle-apropos-documentation (url)
6815 "Call `apropos' when pushing the corresponding URL button."
6817 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6818 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6820 (defun gnus-button-handle-library (url)
6821 "Call `locate-library' when pushing the corresponding URL button."
6822 (gnus-message 9 "url=`%s'" url)
6823 (let* ((lib (locate-library url))
6824 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6826 (gnus-message 1 "Cannot locale library `%s'." url)
6827 (find-file-read-only file))))
6829 (defun gnus-button-handle-ctan (url)
6830 "Call `browse-url' when pushing a CTAN URL button."
6832 gnus-button-ctan-handler
6835 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6837 (defcustom gnus-button-tex-level 5
6838 "*Integer that says how many TeX-related buttons Gnus will show.
6839 The higher the number, the more buttons will appear and the more false
6840 positives are possible. Note that you can set this variable local to
6841 specific groups. Setting it higher in TeX groups is probably a good idea.
6842 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6843 how to set variables in specific groups."
6845 :group 'gnus-article-buttons
6846 :link '(custom-manual "(gnus)Group Parameters")
6849 (defcustom gnus-button-man-level 5
6850 "*Integer that says how many man-related buttons Gnus will show.
6851 The higher the number, the more buttons will appear and the more false
6852 positives are possible. Note that you can set this variable local to
6853 specific groups. Setting it higher in Unix groups is probably a good idea.
6854 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6855 how to set variables in specific groups."
6857 :group 'gnus-article-buttons
6858 :link '(custom-manual "(gnus)Group Parameters")
6861 (defcustom gnus-button-emacs-level 5
6862 "*Integer that says how many emacs-related buttons Gnus will show.
6863 The higher the number, the more buttons will appear and the more false
6864 positives are possible. Note that you can set this variable local to
6865 specific groups. Setting it higher in Emacs or Gnus related groups is
6866 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6867 `gnus-parameters' on how to set variables in specific groups."
6869 :group 'gnus-article-buttons
6870 :link '(custom-manual "(gnus)Group Parameters")
6873 (defcustom gnus-button-message-level 5
6874 "*Integer that says how many buttons for news or mail messages will appear.
6875 The higher the number, the more buttons will appear and the more false
6876 positives are possible."
6877 ;; mail addresses, MIDs, URLs for news, ...
6879 :group 'gnus-article-buttons
6882 (defcustom gnus-button-browse-level 5
6883 "*Integer that says how many buttons for browsing will appear.
6884 The higher the number, the more buttons will appear and the more false
6885 positives are possible."
6886 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6888 :group 'gnus-article-buttons
6891 (defcustom gnus-button-alist
6892 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6893 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6894 ((concat "\\b\\(nntp\\|news\\):\\("
6895 gnus-button-valid-localpart-regexp "@[a-z0-9.-]+[a-z]\\)")
6896 0 t gnus-button-handle-news 2)
6897 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6898 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6899 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6900 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6901 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
6902 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
6903 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
6904 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6905 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6906 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6907 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6908 ;; RFC 2368 (The mailto URL scheme)
6909 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6910 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6911 ("\\bmailto:\\([^ \n\t]+\\)"
6912 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6914 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6915 gnus-button-ctan-directory-regexp
6916 "[^][>)!;:,'\n\t ]+\\)")
6917 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6918 ((concat "\\btex-archive/\\("
6919 gnus-button-ctan-directory-regexp
6920 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6921 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6924 gnus-button-ctan-directory-regexp
6925 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6926 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6927 ;; This is info (home-grown style) <info://foo/bar+baz>
6928 ("\\binfo://\\([^'\">\n\t ]+\\)"
6929 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6930 ;; Info GNOME style <info:foo#bar_baz>
6931 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6932 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6933 ;; Info KDE style <info:(foo)bar baz>
6934 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6935 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6936 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6937 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6938 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6939 ;; Info links like `C-h i d m CC Mode RET'
6940 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6942 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6943 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6944 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6945 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6946 ;; Emacs help commands
6947 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6948 ;; regexp doesn't match arguments containing ` '.
6949 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6950 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6951 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6952 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6953 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6954 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6955 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6956 ;; The following entries may lead to many false positives so don't enable
6957 ;; them by default (use a high button level).
6958 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
6959 ;; Exclude [.?] for URLs in gmane.emacs.cvs
6960 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6961 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6962 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6963 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6964 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6965 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6966 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6967 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6968 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6969 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6970 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
6971 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6972 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6973 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6974 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6975 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6976 ;; Unlike the other regexps we really have to require quoting
6977 ;; here to determine where it ends.
6978 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6979 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
6980 ("<URL: *\\([^<>]*\\)>"
6981 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6982 ;; RFC 2396 (2.4.3., delims) ...
6983 ("\"URL: *\\([^\"]*\\)\""
6984 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6985 ;; RFC 2396 (2.4.3., delims) ...
6986 ("\"URL: *\\([^\"]*\\)\""
6987 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6989 (gnus-button-url-regexp
6990 0 (>= gnus-button-browse-level 0) browse-url 0)
6992 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
6993 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6994 gnus-button-handle-man 1)
6995 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6996 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
6997 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6998 gnus-button-handle-man 1)
6999 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
7000 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
7001 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
7002 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
7003 ;; MID or mail: To avoid too many false positives we don't try to catch
7004 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
7005 ;; at least one dot. TLD must contain two or three chars or be a know TLD
7006 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
7007 ;; so that non-ambiguous entries (see above) match first.
7008 (gnus-button-mid-or-mail-regexp
7009 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
7010 "*Alist of regexps matching buttons in article bodies.
7012 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
7013 REGEXP: is the string (case insensitive) matching text around the button (can
7014 also be Lisp expression evaluating to a string),
7015 BUTTON: is the number of the regexp grouping actually matching the button,
7016 FORM: is a Lisp expression which must eval to true for the button to
7018 CALLBACK: is the function to call when the user push this button, and each
7019 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
7021 CALLBACK can also be a variable, in that case the value of that
7022 variable it the real callback function."
7023 :group 'gnus-article-buttons
7024 :type '(repeat (list (choice regexp variable sexp)
7025 (integer :tag "Button")
7027 (function :tag "Callback")
7030 (integer :tag "Regexp group")))))
7032 (defcustom gnus-header-button-alist
7033 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
7034 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
7035 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
7036 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
7037 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
7038 0 (>= gnus-button-message-level 0) gnus-msg-mail 0)
7039 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
7040 0 (>= gnus-button-browse-level 0) browse-url 0)
7041 ("^Subject:" gnus-button-url-regexp
7042 0 (>= gnus-button-browse-level 0) browse-url 0)
7043 ("^[^:]+:" gnus-button-url-regexp
7044 0 (>= gnus-button-browse-level 0) browse-url 0)
7045 ("^OpenPGP:.*url=" gnus-button-url-regexp
7046 0 (>= gnus-button-browse-level 0) gnus-button-openpgp 0)
7047 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
7048 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
7049 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
7050 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
7051 "*Alist of headers and regexps to match buttons in article heads.
7053 This alist is very similar to `gnus-button-alist', except that each
7054 alist has an additional HEADER element first in each entry:
7056 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
7058 HEADER is a regexp to match a header. For a fuller explanation, see
7059 `gnus-button-alist'."
7060 :group 'gnus-article-buttons
7061 :group 'gnus-article-headers
7062 :type '(repeat (list (regexp :tag "Header")
7063 (choice regexp variable)
7064 (integer :tag "Button")
7066 (function :tag "Callback")
7069 (integer :tag "Regexp group")))))
7073 (defun gnus-article-push-button (event)
7074 "Check text under the mouse pointer for a callback function.
7075 If the text under the mouse pointer has a `gnus-callback' property,
7076 call it with the value of the `gnus-data' text property."
7078 (set-buffer (window-buffer (posn-window (event-start event))))
7079 (let* ((pos (posn-point (event-start event)))
7080 (data (get-text-property pos 'gnus-data))
7081 (fun (get-text-property pos 'gnus-callback)))
7084 (funcall fun data))))
7086 (defun gnus-article-press-button ()
7087 "Check text at point for a callback function.
7088 If the text at point has a `gnus-callback' property,
7089 call it with the value of the `gnus-data' text property."
7091 (let ((data (get-text-property (point) 'gnus-data))
7092 (fun (get-text-property (point) 'gnus-callback)))
7094 (funcall fun data))))
7096 (defun gnus-article-prev-button (n)
7097 "Move point to N buttons backward.
7098 If N is negative, move forward instead."
7100 (gnus-article-next-button (- n)))
7102 (defun gnus-article-next-button (n)
7103 "Move point to N buttons forward.
7104 If N is negative, move backward instead."
7106 (let ((function (if (< n 0) 'previous-single-property-change
7107 'next-single-property-change))
7108 (inhibit-point-motion-hooks t)
7110 (limit (if (< n 0) (point-min) (point-max))))
7112 (while (and (not (= limit (point)))
7114 ;; Skip past the current button.
7115 (when (get-text-property (point) 'gnus-callback)
7116 (goto-char (funcall function (point) 'gnus-callback nil limit)))
7117 ;; Go to the next (or previous) button.
7118 (gnus-goto-char (funcall function (point) 'gnus-callback nil limit))
7119 ;; Put point at the start of the button.
7120 (when (and backward (not (get-text-property (point) 'gnus-callback)))
7121 (goto-char (funcall function (point) 'gnus-callback nil limit)))
7122 ;; Skip past intangible buttons.
7123 (when (get-text-property (point) 'intangible)
7127 (gnus-message 5 "No more buttons"))
7130 (defun gnus-article-highlight (&optional force)
7131 "Highlight current article.
7132 This function calls `gnus-article-highlight-headers',
7133 `gnus-article-highlight-citation',
7134 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
7135 do the highlighting. See the documentation for those functions."
7136 (interactive (list 'force))
7137 (gnus-article-highlight-headers)
7138 (gnus-article-highlight-citation force)
7139 (gnus-article-highlight-signature)
7140 (gnus-article-add-buttons force)
7141 (gnus-article-add-buttons-to-head))
7143 (defun gnus-article-highlight-some (&optional force)
7144 "Highlight current article.
7145 This function calls `gnus-article-highlight-headers',
7146 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
7147 do the highlighting. See the documentation for those functions."
7148 (interactive (list 'force))
7149 (gnus-article-highlight-headers)
7150 (gnus-article-highlight-signature)
7151 (gnus-article-add-buttons))
7153 (defun gnus-article-highlight-headers ()
7154 "Highlight article headers as specified by `gnus-header-face-alist'."
7156 (gnus-with-article-headers
7157 (let (regexp header-face field-face from hpoints fpoints)
7158 (dolist (entry gnus-header-face-alist)
7159 (goto-char (point-min))
7160 (setq regexp (concat "^\\("
7161 (if (string-equal "" (nth 0 entry))
7165 header-face (nth 1 entry)
7166 field-face (nth 2 entry))
7167 (while (and (re-search-forward regexp nil t)
7171 (unless (search-forward ":" nil t)
7173 (when (and header-face
7174 (not (memq (point) hpoints)))
7175 (push (point) hpoints)
7176 (gnus-put-text-property from (point) 'face header-face))
7177 (when (and field-face
7178 (not (memq (setq from (point)) fpoints)))
7180 (if (re-search-forward "^[^ \t]" nil t)
7182 (goto-char (point-max)))
7183 (gnus-put-text-property from (point) 'face field-face)))))))
7185 (defun gnus-article-highlight-signature ()
7186 "Highlight the signature in an article.
7187 It does this by highlighting everything after
7188 `gnus-signature-separator' using the face `gnus-signature'."
7190 (when gnus-signature-face
7191 (gnus-with-article-buffer
7192 (let ((inhibit-point-motion-hooks t))
7194 (when (gnus-article-narrow-to-signature)
7195 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
7196 'face gnus-signature-face)))))))
7198 (defun gnus-article-buttonize-signature ()
7199 "Add button to the signature."
7202 (set-buffer gnus-article-buffer)
7203 (let ((inhibit-read-only t)
7204 (inhibit-point-motion-hooks t))
7205 (when (gnus-article-search-signature)
7206 (gnus-article-add-button (match-beginning 0) (match-end 0)
7207 'gnus-signature-toggle
7208 (set-marker (make-marker)
7209 (1+ (match-end 0))))))))
7211 (defun gnus-button-in-region-p (b e prop)
7212 "Say whether PROP exists in the region."
7213 (text-property-not-all b e prop nil))
7215 (defun gnus-article-add-buttons (&optional force)
7216 "Find external references in the article and make buttons of them.
7217 \"External references\" are things like Message-IDs and URLs, as
7218 specified by `gnus-button-alist'."
7219 (interactive (list 'force))
7220 (gnus-with-article-buffer
7221 (let ((inhibit-point-motion-hooks t)
7222 (case-fold-search t)
7223 (alist gnus-button-alist)
7225 ;; Remove all old markers.
7226 (let (marker entry new-list)
7227 (while (setq marker (pop gnus-button-marker-list))
7228 (if (or (< marker (point-min)) (>= marker (point-max)))
7229 (push marker new-list)
7231 (when (setq entry (gnus-button-entry))
7232 (put-text-property (match-beginning (nth 1 entry))
7233 (match-end (nth 1 entry))
7234 'gnus-callback nil))
7235 (set-marker marker nil)))
7236 (setq gnus-button-marker-list new-list))
7237 ;; We skip the headers.
7240 (while (setq entry (pop alist))
7241 (setq regexp (eval (car entry)))
7243 (while (re-search-forward regexp nil t)
7244 (let* ((start (and entry (match-beginning (nth 1 entry))))
7245 (end (and entry (match-end (nth 1 entry))))
7246 (from (match-beginning 0)))
7247 (when (and (or (eq t (nth 2 entry))
7248 (eval (nth 2 entry)))
7249 (not (gnus-button-in-region-p
7250 start end 'gnus-callback)))
7251 ;; That optional form returned non-nil, so we add the
7253 (gnus-article-add-button
7254 start end 'gnus-button-push
7255 (car (push (set-marker (make-marker) from)
7256 gnus-button-marker-list))))))))))
7258 ;; Add buttons to the head of an article.
7259 (defun gnus-article-add-buttons-to-head ()
7260 "Add buttons to the head of the article."
7262 (gnus-with-article-headers
7264 (dolist (entry gnus-header-button-alist)
7265 ;; Each alist entry.
7266 (goto-char (point-min))
7267 (while (re-search-forward (car entry) nil t)
7268 ;; Each header matching the entry.
7269 (setq beg (match-beginning 0))
7270 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
7271 (match-beginning 0))
7274 (while (re-search-forward (eval (nth 1 entry)) end t)
7275 ;; Each match within a header.
7276 (let* ((entry (cdr entry))
7277 (start (match-beginning (nth 1 entry)))
7278 (end (match-end (nth 1 entry)))
7279 (form (nth 2 entry)))
7280 (goto-char (match-end 0))
7282 (gnus-article-add-button
7283 start end (nth 3 entry)
7284 (buffer-substring (match-beginning (nth 4 entry))
7285 (match-end (nth 4 entry)))))))
7286 (goto-char end))))))
7288 ;;; External functions:
7290 (defun gnus-article-add-button (from to fun &optional data)
7291 "Create a button between FROM and TO with callback FUN and data DATA."
7292 (when gnus-article-button-face
7293 (gnus-overlay-put (gnus-make-overlay from to)
7294 'face gnus-article-button-face))
7295 (gnus-add-text-properties
7297 (nconc (and gnus-article-mouse-face
7298 (list gnus-mouse-face-prop gnus-article-mouse-face))
7299 (list 'gnus-callback fun)
7300 (and data (list 'gnus-data data))))
7301 (widget-convert-button 'link from to :action 'gnus-widget-press-button
7302 :button-keymap gnus-widget-button-keymap))
7304 ;;; Internal functions:
7306 (defun gnus-article-set-globals ()
7307 (with-current-buffer gnus-summary-buffer
7308 (gnus-set-global-variables)))
7310 (defun gnus-signature-toggle (end)
7311 (gnus-with-article-buffer
7312 (let ((inhibit-point-motion-hooks t)
7313 (limit (next-single-property-change end 'mime-view-entity
7315 (if (text-property-any end limit 'article-type 'signature)
7317 (gnus-delete-wash-type 'signature)
7318 (gnus-remove-text-properties-when
7319 'article-type 'signature end limit
7320 (cons 'article-type (cons 'signature
7321 gnus-hidden-properties))))
7322 (gnus-add-wash-type 'signature)
7323 (gnus-add-text-properties-when
7324 'article-type nil end limit
7325 (cons 'article-type (cons 'signature
7326 gnus-hidden-properties)))))
7327 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
7328 (gnus-set-mode-line 'article))))
7330 (defun gnus-button-entry ()
7331 ;; Return the first entry in `gnus-button-alist' matching this place.
7332 (let ((alist gnus-button-alist)
7335 (setq entry (pop alist))
7336 (if (looking-at (eval (car entry)))
7341 (defun gnus-button-push (marker)
7342 ;; Push button starting at MARKER.
7345 (let* ((entry (gnus-button-entry))
7346 (inhibit-point-motion-hooks t)
7348 (args (mapcar (lambda (group)
7349 (let ((string (match-string group)))
7350 (set-text-properties
7351 0 (length string) nil string)
7358 (fboundp (symbol-value fun)))
7359 (apply (symbol-value fun) args))
7361 (gnus-message 1 "You must define `%S' to use this button"
7362 (cons fun args)))))))
7364 (defun gnus-parse-news-url (url)
7365 (let (scheme server port group message-id articles)
7368 (goto-char (point-min))
7369 (when (looking-at "\\([A-Za-z]+\\):")
7370 (setq scheme (match-string 1))
7371 (goto-char (match-end 0)))
7372 (when (looking-at "//\\([^:/]+\\)\\(:?\\)\\([0-9]+\\)?/")
7373 (setq server (match-string 1))
7374 (setq port (if (stringp (match-string 3))
7375 (string-to-number (match-string 3))
7377 (goto-char (match-end 0)))
7380 ((looking-at "\\(.*@.*\\)")
7381 (setq message-id (match-string 1)))
7382 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
7383 (setq group (match-string 1)
7384 articles (split-string (match-string 2) "-")))
7385 ((looking-at "\\([^/]+\\)/?")
7386 (setq group (match-string 1)))
7388 (error "Unknown news URL syntax"))))
7389 (list scheme server port group message-id articles)))
7391 (defun gnus-button-handle-news (url)
7393 (destructuring-bind (scheme server port group message-id articles)
7394 (gnus-parse-news-url url)
7398 (set-buffer gnus-summary-buffer)
7400 (let ((gnus-refer-article-method
7401 (nconc (list (list 'nntp server))
7402 gnus-refer-article-method))
7403 (nntp-port-number (or port "nntp")))
7404 (gnus-message 7 "Fetching %s with %s"
7405 message-id gnus-refer-article-method)
7406 (gnus-summary-refer-article message-id))
7407 (gnus-summary-refer-article message-id))))
7409 (gnus-button-fetch-group url)))))
7411 (defun gnus-button-handle-man (url)
7413 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7414 (when (eq gnus-button-man-handler 'woman)
7415 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
7416 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7417 (funcall gnus-button-man-handler url))
7419 (defun gnus-button-handle-info-url (url)
7420 "Fetch an info URL."
7421 (setq url (mm-subst-char-in-string ?+ ?\ url))
7423 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
7424 (gnus-info-find-node
7425 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
7427 ")" (gnus-url-unhex-string (match-string 2 url)))))
7428 ((string-match "([^)\"]+)[^\"]+" url)
7430 (gnus-replace-in-string
7431 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
7432 (gnus-info-find-node url))
7433 (t (error "Can't parse %s" url))))
7435 (defun gnus-button-handle-info-url-gnome (url)
7436 "Fetch GNOME style info URL."
7437 (setq url (mm-subst-char-in-string ?_ ?\ url))
7438 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
7439 (gnus-info-find-node
7441 (gnus-url-unhex-string
7442 (match-string 1 url))
7444 (or (gnus-url-unhex-string
7445 (match-string 2 url))
7447 (error "Can't parse %s" url)))
7449 (defun gnus-button-handle-info-url-kde (url)
7450 "Fetch KDE style info URL."
7451 (gnus-info-find-node (gnus-url-unhex-string url)))
7453 (defun gnus-button-handle-info-keystrokes (url)
7454 "Call `info' when pushing the corresponding URL button."
7455 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
7460 (defun gnus-button-openpgp (url)
7461 "Retrieve and add an OpenPGP key given URL from an OpenPGP header."
7463 (mm-url-insert-file-contents-external url)
7464 (pgg-snarf-keys-region (point-min) (point-max))
7465 (pgg-display-output-buffer nil nil nil)))
7467 (defun gnus-button-message-id (message-id)
7469 (with-current-buffer gnus-summary-buffer
7470 (gnus-summary-refer-article message-id)))
7472 (defun gnus-button-fetch-group (address)
7473 "Fetch GROUP specified by ADDRESS."
7474 (if (not (string-match "[:/]" address))
7475 ;; This is just a simple group url.
7476 (gnus-group-read-ephemeral-group address gnus-select-method)
7479 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
7481 (error "Can't parse %s" address)
7482 (gnus-group-read-ephemeral-group
7483 (match-string 4 address)
7484 `(nntp ,(match-string 1 address)
7485 (nntp-address ,(match-string 1 address))
7486 (nntp-port-number ,(if (match-end 3)
7487 (match-string 3 address)
7490 (and (match-end 6) (list (string-to-number (match-string 6 address))))))))
7492 (defun gnus-url-parse-query-string (query &optional downcase)
7493 (let (retval pairs cur key val)
7494 (setq pairs (split-string query "&"))
7496 (setq cur (car pairs)
7498 (if (not (string-match "=" cur))
7500 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
7501 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
7503 (setq key (downcase key)))
7504 (setq cur (assoc key retval))
7506 (setcdr cur (cons val (cdr cur)))
7507 (setq retval (cons (list key val) retval)))))
7510 (defun gnus-url-mailto (url)
7511 ;; Send mail to someone
7512 (when (string-match "mailto:/*\\(.*\\)" url)
7513 (setq url (substring url (match-beginning 1) nil)))
7514 (let (to args subject func)
7515 (setq args (gnus-url-parse-query-string
7516 (if (string-match "^\\?" url)
7518 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
7519 (concat "to=" (match-string 1 url) "&"
7520 (match-string 2 url))
7521 (concat "to=" url)))
7523 subject (cdr-safe (assoc "subject" args)))
7526 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
7529 (message-position-on-field (caar args)))
7530 (insert (gnus-replace-in-string
7531 (mapconcat 'identity (reverse (cdar args)) ", ")
7533 (setq args (cdr args)))
7536 (message-goto-subject))))
7538 (defun gnus-button-embedded-url (address)
7539 "Activate ADDRESS with `browse-url'."
7540 (browse-url (gnus-strip-whitespace address)))
7542 ;;; Next/prev buttons in the article buffer.
7544 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
7545 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
7547 (defvar gnus-prev-page-map
7548 (let ((map (make-sparse-keymap)))
7549 (define-key map gnus-mouse-2 'gnus-button-prev-page)
7550 (define-key map "\r" 'gnus-button-prev-page)
7553 (defvar gnus-next-page-map
7554 (let ((map (make-sparse-keymap)))
7555 (unless (>= emacs-major-version 21)
7556 ;; XEmacs doesn't care.
7557 (set-keymap-parent map gnus-article-mode-map))
7558 (define-key map gnus-mouse-2 'gnus-button-next-page)
7559 (define-key map "\r" 'gnus-button-next-page)
7562 (defun gnus-insert-prev-page-button ()
7564 (inhibit-read-only t)
7565 (situation (get-text-property (point-min) 'mime-view-situation)))
7567 gnus-prev-page-line-format nil
7568 `(keymap ,gnus-prev-page-map
7570 gnus-callback gnus-article-button-prev-page
7571 article-type annotation
7572 mime-view-situation ,situation))
7573 (widget-convert-button
7575 ;; Exclude a newline.
7578 :action 'gnus-button-prev-page
7579 :button-keymap gnus-prev-page-map)))
7581 (defun gnus-button-next-page (&optional args more-args)
7582 "Go to the next page."
7584 (let ((win (selected-window)))
7585 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7586 (gnus-article-next-page)
7587 (select-window win)))
7589 (defun gnus-button-prev-page (&optional args more-args)
7590 "Go to the prev page."
7592 (let ((win (selected-window)))
7593 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7594 (gnus-article-prev-page)
7595 (select-window win)))
7597 (defun gnus-insert-next-page-button ()
7599 (inhibit-read-only t)
7600 (situation (get-text-property (point-min) 'mime-view-situation)))
7601 (gnus-eval-format gnus-next-page-line-format nil
7602 `(keymap ,gnus-next-page-map
7604 gnus-callback gnus-article-button-next-page
7605 article-type annotation
7606 mime-view-situation ,situation))
7607 (widget-convert-button
7609 ;; Exclude a newline.
7612 :action 'gnus-button-next-page
7613 :button-keymap gnus-next-page-map)))
7615 (defun gnus-article-button-next-page (arg)
7616 "Go to the next page."
7618 (let ((win (selected-window)))
7619 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7620 (gnus-article-next-page)
7621 (select-window win)))
7623 (defun gnus-article-button-prev-page (arg)
7624 "Go to the prev page."
7626 (let ((win (selected-window)))
7627 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7628 (gnus-article-prev-page)
7629 (select-window win)))
7631 (defvar gnus-decode-header-methods
7632 '(mail-decode-encoded-word-region)
7633 "List of methods used to decode headers.
7635 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
7636 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
7637 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
7638 whose names match REGEXP.
7641 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
7642 mail-decode-encoded-word-region
7643 (\"chinese\" . rfc1843-decode-region))
7646 (defvar gnus-decode-header-methods-cache nil)
7648 (defun gnus-multi-decode-header (start end)
7649 "Apply the functions from `gnus-encoded-word-methods' that match."
7650 (unless (and gnus-decode-header-methods-cache
7651 (eq gnus-newsgroup-name
7652 (car gnus-decode-header-methods-cache)))
7653 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
7656 (nconc gnus-decode-header-methods-cache (list x))
7657 (if (and gnus-newsgroup-name
7658 (string-match (car x) gnus-newsgroup-name))
7659 (nconc gnus-decode-header-methods-cache
7661 gnus-decode-header-methods))
7662 (let ((xlist gnus-decode-header-methods-cache))
7665 (narrow-to-region start end)
7667 (funcall (pop xlist) (point-min) (point-max))))))
7670 ;;; Treatment top-level handling.
7673 (defun gnus-treat-article (condition &optional part-number total-parts type)
7674 (let ((length (- (point-max) (point-min)))
7675 (alist gnus-treatment-function-alist)
7676 (article-goto-body-goes-to-point-min-p t)
7680 (let ((list gnus-article-treat-types))
7682 (when (string-match (pop list) type)
7683 (throw 'found t)))))))
7684 (highlightp (gnus-visual-p 'article-highlight 'highlight))
7685 (entity (static-unless (featurep 'xemacs)
7686 (when (eq 'head condition)
7687 (get-text-property (point-min) 'mime-view-entity))))
7688 val elem buttonized)
7689 (gnus-run-hooks 'gnus-part-display-hook)
7690 (unless gnus-inhibit-treatment
7691 (dolist (elem alist)
7694 (when (gnus-buffer-live-p gnus-summary-buffer)
7695 (set-buffer gnus-summary-buffer))
7696 (symbol-value (car elem))))
7697 (when (and (or (consp val)
7699 (gnus-treat-predicate val)
7700 (or (not (get (car elem) 'highlight))
7702 (when (and (not buttonized)
7704 '(gnus-treat-hide-signature
7705 gnus-treat-highlight-signature)))
7706 (gnus-article-buttonize-signature)
7707 (setq buttonized t))
7709 (funcall (cadr elem)))))
7710 ;; FSF Emacsen does not inherit the existing text properties
7711 ;; in the new text, so we should do it for `mime-view-entity'.
7712 (static-unless (featurep 'xemacs)
7714 (put-text-property (point-min) (point-max)
7715 'mime-view-entity entity))))))
7717 ;; Dynamic variables.
7719 (defvar part-number)
7720 (defvar total-parts)
7725 (defun gnus-treat-predicate (val)
7730 (stringp (car val)))
7731 (apply 'gnus-or (mapcar `(lambda (s)
7732 (string-match s ,(or gnus-newsgroup-name "")))
7735 (let ((pred (pop val)))
7738 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
7740 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
7742 (not (gnus-treat-predicate (car val))))
7744 (equal (car val) type))
7746 (error "%S is not a valid predicate" pred)))))
7758 (eq part-number total-parts))
7762 (error "%S is not a valid value" val))))
7764 (defun gnus-article-encrypt-body (protocol &optional n)
7765 "Encrypt the article body."
7768 (or gnus-article-encrypt-protocol
7769 (completing-read "Encrypt protocol: "
7770 gnus-article-encrypt-protocol-alist
7772 current-prefix-arg))
7773 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7775 (error "Can't find the encrypt protocol %s" protocol))
7776 (if (member gnus-newsgroup-name '("nndraft:delayed"
7779 (error "Can't encrypt the article in group %s"
7780 gnus-newsgroup-name))
7781 (gnus-summary-iterate n
7783 (set-buffer gnus-summary-buffer)
7784 (let ((mail-parse-charset gnus-newsgroup-charset)
7785 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7786 (summary-buffer gnus-summary-buffer)
7788 (gnus-set-global-variables)
7789 (when (gnus-group-read-only-p)
7790 (error "The current newsgroup does not support article encrypt"))
7791 (gnus-summary-show-article t)
7793 (or (mail-header-references gnus-current-headers) ""))
7794 (set-buffer gnus-article-buffer)
7795 (let* ((inhibit-read-only t)
7797 (mapcar (lambda (field)
7798 (and (save-restriction
7799 (message-narrow-to-head)
7800 (goto-char (point-min))
7801 (search-forward field nil t))
7803 (message-narrow-to-field)
7805 (delete-region (point-min) (point-max))
7807 '("Content-Type:" "Content-Transfer-Encoding:"
7808 "Content-Disposition:"))))
7809 (message-narrow-to-head)
7810 (message-remove-header "MIME-Version")
7811 (goto-char (point-max))
7812 (setq point (point))
7813 (insert (apply 'concat headers))
7815 (narrow-to-region point (point-max))
7816 (let ((message-options message-options))
7817 (message-options-set 'message-sender user-mail-address)
7818 (message-options-set 'message-recipients user-mail-address)
7819 (message-options-set 'message-sign-encrypt 'not)
7821 (goto-char (point-min))
7822 (insert "MIME-Version: 1.0\n")
7824 (gnus-summary-edit-article-done
7825 references nil summary-buffer t))
7826 (when gnus-keep-backlog
7827 (gnus-backlog-remove-article
7828 (car gnus-article-current) (cdr gnus-article-current)))
7830 (when (get-buffer gnus-original-article-buffer)
7831 (set-buffer gnus-original-article-buffer)
7832 (setq gnus-original-article nil)))
7833 (when gnus-use-cache
7834 (gnus-cache-update-article
7835 (car gnus-article-current) (cdr gnus-article-current))))))))
7837 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7838 "The following specs can be used:
7839 %t The security MIME type
7842 %D Details if button is pressed")
7844 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
7845 "The following specs can be used:
7846 %t The security MIME type
7849 %D Details if button is pressed")
7851 (defvar gnus-mime-security-button-line-format-alist
7852 '((?t gnus-tmp-type ?s)
7853 (?i gnus-tmp-info ?s)
7854 (?d gnus-tmp-details ?s)
7855 (?D gnus-tmp-pressed-details ?s)))
7857 (defvar gnus-mime-security-button-map
7858 (let ((map (make-sparse-keymap)))
7859 (define-key map gnus-mouse-2 'gnus-article-push-button)
7860 (define-key map "\r" 'gnus-article-press-button)
7863 (defvar gnus-mime-security-details-buffer nil)
7865 (defvar gnus-mime-security-button-pressed nil)
7867 (defvar gnus-mime-security-show-details-inline t
7868 "If non-nil, show details in the article buffer.")
7870 (defun gnus-mime-security-verify-or-decrypt (handle)
7871 (mm-remove-parts (cdr handle))
7872 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7873 point (inhibit-read-only t))
7875 (goto-char (car region)))
7877 (narrow-to-region (point) (point))
7878 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7879 (let* ((mm-verify-option 'known)
7880 (mm-decrypt-option 'known)
7881 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7882 (unless (eq nparts (cdr handle))
7883 (mm-destroy-parts (cdr handle))
7884 (setcdr handle nparts))))
7885 (setq point (point))
7886 (gnus-mime-display-security handle)
7887 (goto-char (point-max)))
7889 (delete-region (point) (cdr region))
7890 (set-marker (car region) nil)
7891 (set-marker (cdr region) nil))
7894 (defun gnus-mime-security-show-details (handle)
7895 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7897 (gnus-message 5 "No details.")
7898 (if gnus-mime-security-show-details-inline
7899 (let ((gnus-mime-security-button-pressed
7900 (not (get-text-property (point) 'gnus-mime-details)))
7901 (gnus-mime-security-button-line-format
7902 (get-text-property (point) 'gnus-line-format))
7903 (inhibit-read-only t))
7905 (while (eq (get-text-property (point) 'gnus-line-format)
7906 gnus-mime-security-button-line-format)
7910 (narrow-to-region (point) (point))
7911 (gnus-insert-mime-security-button handle))
7912 (delete-region (point)
7913 (or (text-property-not-all
7916 gnus-mime-security-button-line-format)
7919 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7920 (with-current-buffer gnus-mime-security-details-buffer
7923 (setq gnus-mime-security-details-buffer
7924 (gnus-get-buffer-create "*MIME Security Details*")))
7925 (with-current-buffer gnus-mime-security-details-buffer
7927 (goto-char (point-min)))
7928 (pop-to-buffer gnus-mime-security-details-buffer)))))
7930 (defun gnus-mime-security-press-button (handle)
7932 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7933 (gnus-mime-security-show-details handle)
7934 (gnus-mime-security-verify-or-decrypt handle))))
7936 (defun gnus-insert-mime-security-button (handle &optional displayed)
7937 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7940 (or (nth 2 (assoc protocol mm-verify-function-alist))
7941 (nth 2 (assoc protocol mm-decrypt-function-alist))
7943 (if (equal (car handle) "multipart/signed")
7944 " Signed" " Encrypted")
7947 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7950 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7951 gnus-tmp-pressed-details
7953 (setq gnus-tmp-details
7954 (if gnus-tmp-details
7955 (concat "\n" gnus-tmp-details)
7957 (setq gnus-tmp-pressed-details
7958 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7963 gnus-mime-security-button-line-format
7964 gnus-mime-security-button-line-format-alist
7965 `(keymap ,gnus-mime-security-button-map
7966 gnus-callback gnus-mime-security-press-button
7967 gnus-line-format ,gnus-mime-security-button-line-format
7968 gnus-mime-details ,gnus-mime-security-button-pressed
7969 article-type annotation
7972 ;; Exclude a newline.
7975 (widget-convert-button
7978 :action 'gnus-widget-press-button
7979 :button-keymap gnus-mime-security-button-map
7981 (lambda (widget/window &optional overlay pos)
7982 ;; Needed to properly clear the message due to a bug in
7983 ;; wid-edit (XEmacs only).
7984 (when (boundp 'help-echo-owns-message)
7985 (setq help-echo-owns-message t))
7988 (aref gnus-mouse-2 0))))))
7990 (defun gnus-mime-display-security (handle)
7992 (narrow-to-region (point) (point))
7993 (unless (gnus-unbuttonized-mime-type-p (car handle))
7994 (gnus-insert-mime-security-button handle))
7995 (gnus-mime-display-part (cadr handle))
7998 (unless (gnus-unbuttonized-mime-type-p (car handle))
7999 (let ((gnus-mime-security-button-line-format
8000 gnus-mime-security-button-end-line-format))
8001 (gnus-insert-mime-security-button handle)))
8002 (mm-set-handle-multipart-parameter
8004 (cons (set-marker (make-marker) (point-min))
8005 (set-marker (make-marker) (point-max))))))
8011 (defun gnus-article-header-presentation-method (entity situation)
8012 (mime-insert-header entity)
8013 (article-decode-group-name))
8015 (set-alist 'mime-header-presentation-method-alist
8016 'gnus-original-article-mode
8017 #'gnus-article-header-presentation-method)
8019 (defun gnus-mime-preview-quitting-method ()
8020 (mime-preview-kill-buffer)
8021 (delete-other-windows)
8022 (gnus-article-show-summary)
8023 (gnus-summary-select-article gnus-show-all-headers t))
8025 (set-alist 'mime-preview-quitting-method-alist
8026 'gnus-original-article-mode #'gnus-mime-preview-quitting-method)
8028 (set-alist 'mime-preview-following-method-alist
8029 'gnus-original-article-mode #'gnus-following-method)
8031 (set-alist 'mime-preview-over-to-previous-method-alist
8032 'gnus-original-article-mode
8034 (if (> (point-min) 1)
8035 (gnus-article-prev-page)
8036 (gnus-article-read-summary-keys
8037 nil (gnus-character-to-event ?P)))))
8039 (set-alist 'mime-preview-over-to-next-method-alist
8040 'gnus-original-article-mode'
8042 (if (< (point-max) (buffer-size))
8043 (gnus-article-next-page)
8044 (gnus-article-read-summary-keys
8045 nil (gnus-character-to-event ?N)))))
8055 (run-hooks 'gnus-art-load-hook)
8057 ;;; gnus-art.el ends here