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 From:, To: and Cc: headers in current buffer."
2506 (let ((inhibit-point-motion-hooks t)
2507 (inhibit-read-only t))
2508 (article-narrow-to-head)
2509 (goto-char (point-min))
2510 (while (re-search-forward "@.*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2512 (when (save-match-data
2513 (and (setq ace (match-string 1))
2515 (and (re-search-backward "^[^ \t]" nil t)
2516 (looking-at "From\\|To\\|Cc")))
2517 (setq unicode (idna-to-unicode ace))))
2518 (unless (string= ace unicode)
2519 (replace-match unicode nil nil nil 1)))))))))
2521 (defun article-de-quoted-unreadable (&optional force read-charset)
2522 "Translate a quoted-printable-encoded article.
2523 If FORCE, decode the article whether it is marked as quoted-printable
2525 If READ-CHARSET, ask for a coding system."
2526 (interactive (list 'force current-prefix-arg))
2528 (let ((inhibit-read-only t) type charset)
2529 (if (gnus-buffer-live-p gnus-original-article-buffer)
2530 (with-current-buffer gnus-original-article-buffer
2532 (gnus-fetch-field "content-transfer-encoding"))
2533 (let* ((ct (gnus-fetch-field "content-type"))
2536 (mail-header-parse-content-type ct)))))
2537 (setq charset (and ctl
2538 (mail-content-type-get ctl 'charset)))
2539 (if (stringp charset)
2540 (setq charset (intern (downcase charset)))))))
2542 (setq charset (mm-read-coding-system "Charset: " charset)))
2544 (setq charset gnus-newsgroup-charset))
2546 (and type (let ((case-fold-search t))
2547 (string-match "quoted-printable" type))))
2549 (quoted-printable-decode-region
2550 (point) (point-max) (mm-charset-to-coding-system charset))))))
2552 (defun article-de-base64-unreadable (&optional force read-charset)
2553 "Translate a base64 article.
2554 If FORCE, decode the article whether it is marked as base64 not.
2555 If READ-CHARSET, ask for a coding system."
2556 (interactive (list 'force current-prefix-arg))
2558 (let ((inhibit-read-only t) type charset)
2559 (if (gnus-buffer-live-p gnus-original-article-buffer)
2560 (with-current-buffer gnus-original-article-buffer
2562 (gnus-fetch-field "content-transfer-encoding"))
2563 (let* ((ct (gnus-fetch-field "content-type"))
2566 (mail-header-parse-content-type ct)))))
2567 (setq charset (and ctl
2568 (mail-content-type-get ctl 'charset)))
2569 (if (stringp charset)
2570 (setq charset (intern (downcase charset)))))))
2572 (setq charset (mm-read-coding-system "Charset: " charset)))
2574 (setq charset gnus-newsgroup-charset))
2576 (and type (let ((case-fold-search t))
2577 (string-match "base64" type))))
2580 (narrow-to-region (point) (point-max))
2581 (base64-decode-region (point-min) (point-max))
2582 (mm-decode-coding-region
2583 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2588 (defun article-decode-HZ ()
2589 "Translate a HZ-encoded article."
2593 (let ((inhibit-read-only t))
2594 (rfc1843-decode-region (point-min) (point-max)))))
2596 (defun article-unsplit-urls ()
2597 "Remove the newlines that some other mailers insert into URLs."
2600 (let ((inhibit-read-only t))
2601 (goto-char (point-min))
2602 (while (re-search-forward
2603 "\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2604 (replace-match "\\1\\3" t)))
2605 (when (interactive-p)
2606 (gnus-treat-article nil))))
2609 (defun article-wash-html (&optional read-charset)
2610 "Format an HTML article.
2611 If READ-CHARSET, ask for a coding system."
2614 (let ((inhibit-read-only t)
2616 (when (gnus-buffer-live-p gnus-original-article-buffer)
2617 (with-current-buffer gnus-original-article-buffer
2618 (let* ((ct (gnus-fetch-field "content-type"))
2621 (mail-header-parse-content-type ct)))))
2622 (setq charset (and ctl
2623 (mail-content-type-get ctl 'charset)))
2624 (when (stringp charset)
2625 (setq charset (intern (downcase charset)))))))
2627 (setq charset (mm-read-coding-system "Charset: " charset)))
2629 (setq charset gnus-newsgroup-charset))
2631 (save-window-excursion
2633 (narrow-to-region (point) (point-max))
2634 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2635 (entry (assq func mm-text-html-washer-alist)))
2637 (setq func (cdr entry)))
2642 (apply (car func) (cdr func))))))))))
2644 (defun gnus-article-wash-html-with-w3 ()
2645 "Wash the current buffer with w3."
2647 (let ((w3-strict-width (window-width))
2648 (url-standalone-mode t)
2649 (url-gateway-unplugged t)
2650 (w3-honor-stylesheets nil))
2652 (w3-region (point-min) (point-max))
2655 (defun gnus-article-wash-html-with-w3m ()
2656 "Wash the current buffer with emacs-w3m."
2659 (narrow-to-region (point) (point-max))
2660 (let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp)
2661 w3m-force-redisplay)
2662 (w3m-region (point-min) (point-max)))
2663 (when (and mm-inline-text-html-with-w3m-keymap
2664 (boundp 'w3m-minor-mode-map)
2666 (add-text-properties
2667 (point-min) (point-max)
2668 (list 'keymap w3m-minor-mode-map
2669 ;; Put the mark meaning this part was rendered by emacs-w3m.
2670 'mm-inline-text-html-with-w3m t)))))
2672 (defun article-hide-list-identifiers ()
2673 "Remove list identifies from the Subject header.
2674 The `gnus-list-identifiers' variable specifies what to do."
2676 (let ((inhibit-point-motion-hooks t)
2677 (regexp (if (consp gnus-list-identifiers)
2678 (mapconcat 'identity gnus-list-identifiers " *\\|")
2679 gnus-list-identifiers))
2680 (inhibit-read-only t))
2684 (article-narrow-to-head)
2685 (goto-char (point-min))
2686 (while (re-search-forward
2687 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2689 (delete-region (match-beginning 2) (match-end 0))
2690 (beginning-of-line))
2691 (when (re-search-forward
2692 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2693 (delete-region (match-beginning 1) (match-end 1))))))))
2695 (defun article-hide-pem (&optional arg)
2696 "Toggle hiding of any PEM headers and signatures in the current article.
2697 If given a negative prefix, always show; if given a positive prefix,
2699 (interactive (gnus-article-hidden-arg))
2700 (unless (gnus-article-check-hidden-text 'pem arg)
2702 (let ((inhibit-read-only t) end)
2703 (goto-char (point-min))
2704 ;; Hide the horrendously ugly "header".
2705 (when (and (search-forward
2706 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2708 (setq end (1+ (match-beginning 0))))
2709 (gnus-add-wash-type 'pem)
2710 (gnus-article-hide-text-type
2712 (if (search-forward "\n\n" nil t)
2716 ;; Hide the trailer as well
2717 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2719 (gnus-article-hide-text-type
2720 (match-beginning 0) (match-end 0) 'pem)))))))
2722 (defun article-strip-banner ()
2723 "Strip the banners specified by the `banner' group parameter and by
2724 `gnus-article-address-banner-alist'."
2728 (let ((inhibit-point-motion-hooks t))
2729 (when (gnus-parameter-banner gnus-newsgroup-name)
2730 (article-really-strip-banner
2731 (gnus-parameter-banner gnus-newsgroup-name)))
2732 (when gnus-article-address-banner-alist
2733 ;; It is necessary to encode from fields before checking,
2734 ;; because `mail-header-parse-addresses' does not work
2735 ;; (reliably) on decoded headers. And more, it is
2736 ;; impossible to use `gnus-fetch-original-field' here,
2737 ;; because `article-strip-banner' may be called in draft
2738 ;; buffers to preview them.
2739 (let ((from (save-restriction
2741 (article-narrow-to-head)
2742 (mail-fetch-field "from"))))
2745 (caar (mail-header-parse-addresses
2746 (mail-encode-encoded-word-string from)))))
2748 (dolist (pair gnus-article-address-banner-alist)
2749 (when (string-match (car pair) from)
2751 (article-really-strip-banner (cdr pair)))))))))))))
2753 (defun article-really-strip-banner (banner)
2754 "Strip the banner specified by the argument."
2757 (let ((inhibit-point-motion-hooks t)
2758 (gnus-signature-limit nil)
2759 (inhibit-read-only t))
2762 ((eq banner 'signature)
2763 (when (gnus-article-narrow-to-signature)
2766 (delete-region (point) (point-max))))
2768 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2769 (while (re-search-forward banner nil t)
2770 (delete-region (match-beginning 0) (match-end 0)))))
2772 (while (re-search-forward banner nil t)
2773 (delete-region (match-beginning 0) (match-end 0)))))))))
2775 (defun article-babel ()
2776 "Translate article using an online translation service."
2779 (gnus-with-article-buffer
2780 (when (article-goto-body)
2781 (let* ((start (point))
2783 (orig (buffer-substring start end))
2784 (trans (babel-as-string orig)))
2786 (narrow-to-region start end)
2787 (delete-region start end)
2790 (defun article-hide-signature (&optional arg)
2791 "Hide the signature in the current article.
2792 If given a negative prefix, always show; if given a positive prefix,
2794 (interactive (gnus-article-hidden-arg))
2800 (article-goto-body))
2801 (goto-char (point-min)))
2802 (unless (gnus-article-check-hidden-text 'signature arg)
2803 (let ((inhibit-read-only t)
2805 (while (setq button (text-property-any button (point-max)
2807 'gnus-signature-toggle))
2808 (setq button (text-property-not-all button (point-max)
2810 'gnus-signature-toggle))
2811 (when (and button (not (eobp)))
2812 (gnus-article-hide-text-type
2814 (next-single-property-change (1+ button) 'mime-view-entity
2817 (gnus-set-mode-line 'article))
2819 (defun article-strip-headers-in-body ()
2820 "Strip offensive headers from bodies."
2824 (let ((case-fold-search t))
2825 (when (looking-at "x-no-archive:")
2826 (gnus-delete-line)))))
2828 (defun article-strip-leading-blank-lines ()
2829 "Remove all blank lines from the beginning of the article."
2832 (let ((inhibit-point-motion-hooks t)
2833 (inhibit-read-only t))
2834 (when (article-goto-body)
2835 (while (and (not (eobp))
2836 (looking-at "[ \t]*$"))
2837 (gnus-delete-line))))))
2839 (defun article-narrow-to-head ()
2840 "Narrow the buffer to the head of the message.
2841 Point is left at the beginning of the narrowed-to region."
2843 (goto-char (point-min))
2844 (if (search-forward "\n\n" nil 1)
2847 (goto-char (point-min)))
2849 (defun article-goto-body ()
2850 "Place point at the start of the body."
2851 (goto-char (point-min))
2853 ;; This variable is only bound when dealing with separate
2855 (article-goto-body-goes-to-point-min-p
2857 ((search-forward "\n\n" nil t)
2860 (goto-char (point-max))
2863 (defun article-strip-multiple-blank-lines ()
2864 "Replace consecutive blank lines with one empty line."
2867 (let ((inhibit-point-motion-hooks t)
2868 (inhibit-read-only t))
2869 ;; First make all blank lines empty.
2871 (while (re-search-forward "^[ \t]+$" nil t)
2872 (unless (gnus-annotation-in-region-p
2873 (match-beginning 0) (match-end 0))
2874 (replace-match "" nil t)))
2875 ;; Then replace multiple empty lines with a single empty line.
2877 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2878 (unless (gnus-annotation-in-region-p
2879 (match-beginning 0) (match-end 0))
2880 (delete-region (match-beginning 1) (match-end 1)))))))
2882 (defun article-strip-leading-space ()
2883 "Remove all white space from the beginning of the lines in the article."
2886 (let ((inhibit-point-motion-hooks t)
2887 (inhibit-read-only t))
2889 (while (re-search-forward "^[ \t]+" nil t)
2890 (replace-match "" t t)))))
2892 (defun article-strip-trailing-space ()
2893 "Remove all white space from the end of the lines in the article."
2896 (let ((inhibit-point-motion-hooks t)
2897 (inhibit-read-only t))
2899 (while (re-search-forward "[ \t]+$" nil t)
2900 (replace-match "" t t)))))
2902 (defun article-strip-blank-lines ()
2903 "Strip leading, trailing and multiple blank lines."
2905 (article-strip-leading-blank-lines)
2906 (article-remove-trailing-blank-lines)
2907 (article-strip-multiple-blank-lines))
2909 (defun article-strip-all-blank-lines ()
2910 "Strip all blank lines."
2913 (let ((inhibit-point-motion-hooks t)
2914 (inhibit-read-only t))
2916 (while (re-search-forward "^[ \t]*\n" nil t)
2917 (replace-match "" t t)))))
2919 (defun gnus-article-narrow-to-signature ()
2920 "Narrow to the signature; return t if a signature is found, else nil."
2921 (let ((inhibit-point-motion-hooks t))
2922 (when (gnus-article-search-signature)
2924 ;; Check whether we have some limits to what we consider
2925 ;; to be a signature.
2926 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2927 (list gnus-signature-limit)))
2929 (while (setq limit (pop limits))
2930 (if (or (and (integerp limit)
2931 (< (- (point-max) (point)) limit))
2933 (< (count-lines (point) (point-max)) limit))
2934 (and (functionp limit)
2936 (and (stringp limit)
2937 (not (re-search-forward limit nil t))))
2938 () ; This limit did not succeed.
2942 (narrow-to-region (point) (point-max))
2945 (defun gnus-article-search-signature ()
2946 "Search the current buffer for the signature separator.
2947 Put point at the beginning of the signature separator."
2948 (let ((cur (point)))
2949 (goto-char (point-max))
2950 (if (if (stringp gnus-signature-separator)
2951 (re-search-backward gnus-signature-separator nil t)
2952 (let ((seps gnus-signature-separator))
2954 (not (re-search-backward (car seps) nil t)))
2961 (defun gnus-article-hidden-arg ()
2962 "Return the current prefix arg as a number, or 0 if no prefix."
2963 (list (if current-prefix-arg
2964 (prefix-numeric-value current-prefix-arg)
2967 (defun gnus-article-check-hidden-text (type arg)
2968 "Return nil if hiding is necessary.
2969 Arg can be nil or a number. nil and positive means hide, negative
2970 means show, 0 means toggle."
2973 (let ((hide (gnus-article-hidden-text-p type)))
2979 (gnus-article-show-hidden-text type)
2982 (if (eq hide 'hidden)
2984 (gnus-article-show-hidden-text type)
2988 (defun gnus-article-hidden-text-p (type)
2989 "Say whether the current buffer contains hidden text of type TYPE."
2990 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2992 (not (get-text-property pos 'invisible))
2993 (not (get-text-property pos 'dummy-invisible)))
2995 (text-property-any (1+ pos) (point-max) 'article-type type)))
3000 (defun gnus-article-show-hidden-text (type &optional dummy)
3001 "Show all hidden text of type TYPE.
3002 Originally it is hide instead of DUMMY."
3003 (let ((inhibit-read-only t)
3004 (inhibit-point-motion-hooks t))
3005 (gnus-remove-text-properties-when
3007 (point-min) (point-max)
3008 (cons 'article-type (cons type
3009 gnus-hidden-properties)))
3010 (gnus-delete-wash-type type)))
3012 (defconst article-time-units
3013 `((year . ,(* 365.25 24 60 60))
3014 (week . ,(* 7 24 60 60))
3015 (day . ,(* 24 60 60))
3019 "Mapping from time units to seconds.")
3021 (defun gnus-article-forward-header ()
3022 "Move point to the start of the next header.
3023 If the current header is a continuation header, this can be several
3028 (if (looking-at "[ \t]+[^ \t]")
3032 (defun article-date-ut (&optional type highlight)
3033 "Convert DATE date to universal time in the current article.
3034 If TYPE is `local', convert to local time; if it is `lapsed', output
3035 how much time has lapsed since DATE. For `lapsed', the value of
3036 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
3037 should replace the \"Date:\" one, or should be added below it."
3038 (interactive (list 'ut t))
3039 (let* ((tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
3040 (date-regexp (cond ((not gnus-article-date-lapsed-new-header)
3044 (article-lapsed-timer
3048 (case-fold-search t)
3049 (inhibit-read-only t)
3050 (inhibit-point-motion-hooks t)
3051 pos date bface eface)
3055 (goto-char (point-min))
3056 (while (or (setq date (get-text-property (setq pos (point))
3058 (when (setq pos (next-single-property-change
3059 (point) 'original-date))
3060 (setq date (get-text-property pos 'original-date))
3062 (narrow-to-region pos (or (text-property-any pos (point-max)
3065 (goto-char (point-min))
3066 (when (re-search-forward tdate-regexp nil t)
3067 (setq bface (get-text-property (point-at-bol) 'face)
3068 eface (get-text-property (1- (point-at-eol)) 'face)))
3069 (goto-char (point-min))
3071 ;; Delete any old Date headers.
3072 (while (re-search-forward date-regexp nil t)
3074 (delete-region (point-at-bol) (progn
3075 (gnus-article-forward-header)
3077 (delete-region (point-at-bol) (progn
3078 (gnus-article-forward-header)
3081 (setq pos (point))))
3082 (when (and (not pos)
3083 (re-search-forward tdate-regexp nil t))
3085 (gnus-goto-char pos)
3086 (insert (article-make-date-line date (or type 'ut)))
3092 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
3093 (put-text-property (match-beginning 1) (1+ (match-end 1))
3095 (put-text-property (match-beginning 2) (match-end 2)
3097 (put-text-property (point-min) (1- (point-max)) 'original-date date)
3098 (goto-char (point-max))
3101 (defun article-make-date-line (date type)
3102 "Return a DATE line of TYPE."
3103 (unless (memq type '(local ut original user iso8601 lapsed english))
3104 (error "Unknown conversion type: %s" type))
3106 (let ((time (date-to-time date)))
3108 ;; Convert to the local timezone.
3110 (concat "Date: " (message-make-date time)))
3111 ;; Convert to Universal Time.
3116 (let* ((e (parse-time-string date))
3117 (tm (apply 'encode-time e))
3119 (ls (- (cadr tm) (car (current-time-zone time)))))
3120 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
3121 ((> ls 65535) (list (1+ ms) (- ls 65536)))
3125 ;; Get the original date from the article.
3126 ((eq type 'original)
3127 (concat "Date: " (if (string-match "\n+$" date)
3128 (substring date 0 (match-beginning 0))
3130 ;; Let the user define the format.
3132 (let ((format (or (condition-case nil
3133 (with-current-buffer gnus-summary-buffer
3134 gnus-article-time-format)
3136 gnus-article-time-format)))
3137 (if (functionp format)
3138 (funcall format time)
3139 (concat "Date: " (format-time-string format time)))))
3142 (let ((tz (car (current-time-zone time))))
3145 (format-time-string "%Y%m%dT%H%M%S" time)
3146 (format "%s%02d%02d"
3147 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
3148 (/ (% (abs tz) 3600) 60)))))
3149 ;; Do an X-Sent lapsed format.
3151 ;; If the date is seriously mangled, the timezone functions are
3152 ;; liable to bug out, so we ignore all errors.
3153 (let* ((now (current-time))
3154 (real-time (subtract-time now time))
3155 (real-sec (and real-time
3156 (+ (* (float (car real-time)) 65536)
3158 (sec (and real-time (abs real-sec)))
3168 ;; This is a bit convoluted, but basically we go
3169 ;; through the time units for years, weeks, etc,
3170 ;; and divide things to see whether that results
3171 ;; in positive answers.
3174 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
3175 ;; The (remaining) seconds are too few to
3176 ;; be divided into this time unit.
3178 ;; It's big enough, so we output it.
3179 (setq sec (- sec (* num (cdr unit))))
3181 (concat (if prev ", " "") (int-to-string
3183 " " (symbol-name (car unit))
3184 (if (> num 1) "s" ""))
3186 article-time-units "")
3187 ;; If dates are odd, then it might appear like the
3188 ;; article was sent in the future.
3191 " in the future"))))))
3192 ;; Display the date in proper English
3194 (let ((dtime (decode-time time)))
3197 (number-to-string (nth 3 dtime))
3198 (let ((digit (% (nth 3 dtime) 10)))
3200 ((memq (nth 3 dtime) '(11 12 13)) "th")
3206 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3208 (number-to-string (nth 5 dtime))
3210 (format "%02d" (nth 2 dtime))
3212 (format "%02d" (nth 1 dtime)))))))
3214 (format "Date: %s (from T-gnus)" date))))
3216 (defun article-date-local (&optional highlight)
3217 "Convert the current article date to the local timezone."
3218 (interactive (list t))
3219 (article-date-ut 'local highlight))
3221 (defun article-date-english (&optional highlight)
3222 "Convert the current article date to something that is proper English."
3223 (interactive (list t))
3224 (article-date-ut 'english highlight))
3226 (defun article-date-original (&optional highlight)
3227 "Convert the current article date to what it was originally.
3228 This is only useful if you have used some other date conversion
3229 function and want to see what the date was before converting."
3230 (interactive (list t))
3231 (article-date-ut 'original highlight))
3233 (defun article-date-lapsed (&optional highlight)
3234 "Convert the current article date to time lapsed since it was sent."
3235 (interactive (list t))
3236 (article-date-ut 'lapsed highlight))
3238 (defun article-update-date-lapsed ()
3239 "Function to be run from a timer to update the lapsed time line."
3241 (let (deactivate-mark)
3246 (set-buffer (window-buffer w))
3247 (when (or (and (eq major-mode 'mime-view-mode)
3248 (eq (mime-preview-original-major-mode)
3249 'gnus-original-article-mode))
3250 (eq major-mode 'gnus-article-mode))
3251 (let ((mark (point-marker)))
3252 (goto-char (point-min))
3253 (when (re-search-forward "^X-Sent:" nil t)
3254 (article-date-lapsed t))
3255 (goto-char (marker-position mark))
3256 (move-marker mark nil))))
3259 (defun gnus-start-date-timer (&optional n)
3260 "Start a timer to update the X-Sent header in the article buffers.
3261 The numerical prefix says how frequently (in seconds) the function
3266 (gnus-stop-date-timer)
3267 (setq article-lapsed-timer
3268 (run-at-time 1 n 'article-update-date-lapsed)))
3270 (defun gnus-stop-date-timer ()
3271 "Stop the X-Sent timer."
3273 (when article-lapsed-timer
3274 (nnheader-cancel-timer article-lapsed-timer)
3275 (setq article-lapsed-timer nil)))
3277 (defun article-date-user (&optional highlight)
3278 "Convert the current article date to the user-defined format.
3279 This format is defined by the `gnus-article-time-format' variable."
3280 (interactive (list t))
3281 (article-date-ut 'user highlight))
3283 (defun article-date-iso8601 (&optional highlight)
3284 "Convert the current article date to ISO8601."
3285 (interactive (list t))
3286 (article-date-ut 'iso8601 highlight))
3288 (defmacro gnus-article-save-original-date (&rest forms)
3289 "Save the original date as a text property and evaluate FORMS."
3290 `(let* ((case-fold-search t)
3292 (goto-char (point-min))
3293 (when (and (re-search-forward "^date:[\t\n ]+" nil t)
3296 (date (when (and start
3297 (re-search-forward "[\t ]*\n\\(?:[^\t ]\\|\\'\\)"
3299 (buffer-substring-no-properties start
3300 (match-beginning 0)))))
3301 (goto-char (point-max))
3302 (skip-chars-backward "\n")
3303 (put-text-property (point-min) (point) 'original-date date)
3305 (goto-char (point-max))
3306 (skip-chars-backward "\n")
3307 (put-text-property (point-min) (point) 'original-date date)))
3309 ;; (defun article-show-all ()
3310 ;; "Show all hidden text in the article buffer."
3314 ;; (let ((inhibit-read-only t))
3315 ;; (gnus-article-unhide-text (point-min) (point-max))
3316 ;; (gnus-remove-text-with-property 'gnus-prev)
3317 ;; (gnus-remove-text-with-property 'gnus-next))))
3319 (defun article-show-all-headers ()
3320 "Show all hidden headers in the article buffer."
3325 (article-narrow-to-head)
3326 (let ((inhibit-read-only t))
3327 (gnus-article-unhide-text (point-min) (point-max))))))
3329 (defun article-remove-leading-whitespace ()
3330 "Remove excessive whitespace from all headers."
3334 (let ((inhibit-read-only t))
3335 (article-narrow-to-head)
3336 (goto-char (point-min))
3337 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3338 (delete-region (match-beginning 1) (match-end 1)))))))
3340 (defun article-emphasize (&optional arg)
3341 "Emphasize text according to `gnus-emphasis-alist'."
3342 (interactive (gnus-article-hidden-arg))
3343 (unless (gnus-article-check-hidden-text 'emphasis arg)
3347 (with-current-buffer gnus-summary-buffer
3348 gnus-article-emphasis-alist)
3350 gnus-emphasis-alist))
3351 (inhibit-read-only t)
3352 (props (append '(article-type emphasis)
3353 gnus-hidden-properties))
3354 regexp elem beg invisible visible face)
3357 (while (setq elem (pop alist))
3359 (setq regexp (car elem)
3360 invisible (nth 1 elem)
3361 visible (nth 2 elem)
3363 (while (re-search-forward regexp nil t)
3364 (when (and (match-beginning visible) (match-beginning invisible))
3365 (gnus-article-hide-text
3366 (match-beginning invisible) (match-end invisible) props)
3367 (gnus-article-unhide-text-type
3368 (match-beginning visible) (match-end visible) 'emphasis)
3369 (gnus-put-overlay-excluding-newlines
3370 (match-beginning visible) (match-end visible) 'face face)
3371 (gnus-add-wash-type 'emphasis)
3372 (goto-char (match-end invisible)))))))))
3374 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3375 "Setup newsgroup emphasis alist."
3376 (unless gnus-article-emphasis-alist
3377 (let ((name (and gnus-newsgroup-name
3378 (gnus-group-real-name gnus-newsgroup-name))))
3379 (make-local-variable 'gnus-article-emphasis-alist)
3380 (setq gnus-article-emphasis-alist
3382 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3383 (while (setq elem (pop alist))
3384 (when (and name (string-match (car elem) name))
3386 highlight (copy-sequence (cdr elem)))))
3388 (copy-sequence highlight-words)
3389 (if gnus-newsgroup-name
3390 (copy-sequence (gnus-group-find-parameter
3391 gnus-newsgroup-name 'highlight-words t)))
3392 gnus-emphasis-alist)))))
3395 (defvar gnus-summary-article-menu)
3396 (defvar gnus-summary-post-menu))
3398 ;;; Saving functions.
3400 (defun gnus-article-save (save-buffer file &optional num)
3401 "Save the currently selected article."
3402 (unless gnus-save-all-headers
3403 ;; Remove headers according to `gnus-saved-headers'.
3404 (let ((gnus-visible-headers
3405 (or gnus-saved-headers gnus-visible-headers))
3406 (gnus-article-buffer save-buffer))
3408 (set-buffer save-buffer)
3409 (article-hide-headers 1 t))))
3410 (save-window-excursion
3411 (if (not gnus-default-article-saver)
3412 (error "No default saver is defined")
3413 ;; !!! Magic! The saving functions all save
3414 ;; `gnus-save-article-buffer' (or so they think), but we
3415 ;; bind that variable to our save-buffer.
3416 (set-buffer gnus-article-buffer)
3417 (let* ((gnus-save-article-buffer save-buffer)
3420 ((not gnus-prompt-before-saving) 'default)
3421 ((eq gnus-prompt-before-saving 'always) nil)
3423 (gnus-number-of-articles-to-be-saved
3424 (when (eq gnus-prompt-before-saving t)
3426 (set-buffer gnus-article-current-summary)
3427 (funcall gnus-default-article-saver filename)))))
3429 (defun gnus-read-save-file-name (prompt &optional filename
3430 function group headers variable)
3432 (funcall function group headers (symbol-value variable)))
3437 ((eq filename 'default)
3443 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3446 (if (and gnus-number-of-articles-to-be-saved
3447 (> gnus-number-of-articles-to-be-saved 1))
3448 (format "these %d articles"
3449 gnus-number-of-articles-to-be-saved)
3452 ;; Let the split methods have their say.
3454 ;; No split name was found.
3457 (concat prompt " (default "
3458 (file-name-nondirectory default-name) ") ")
3459 (file-name-directory default-name)
3461 ;; A single group name is returned.
3462 ((stringp split-name)
3464 (funcall function split-name headers
3465 (symbol-value variable)))
3467 (concat prompt " (default "
3468 (file-name-nondirectory default-name) ") ")
3469 (file-name-directory default-name)
3471 ;; A single split name was found
3472 ((= 1 (length split-name))
3473 (let* ((name (expand-file-name
3475 gnus-article-save-directory))
3476 (dir (cond ((file-directory-p name)
3477 (file-name-as-directory name))
3478 ((file-exists-p name) name)
3479 (t gnus-article-save-directory))))
3481 (concat prompt " (default " name ") ")
3483 ;; A list of splits was found.
3485 (setq split-name (nreverse split-name))
3487 (let ((file-name-history
3488 (nconc split-name file-name-history)))
3492 (concat prompt " (`M-p' for defaults) ")
3493 gnus-article-save-directory
3495 gnus-article-save-directory)))
3496 (car (push result file-name-history)))))))
3497 ;; Create the directory.
3498 (gnus-make-directory (file-name-directory file))
3499 ;; If we have read a directory, we append the default file name.
3500 (when (file-directory-p file)
3501 (setq file (expand-file-name (file-name-nondirectory
3503 (file-name-as-directory file))))
3504 ;; Possibly translate some characters.
3505 (nnheader-translate-file-chars file))))))
3506 (gnus-make-directory (file-name-directory result))
3507 (set variable result)))
3509 (defun gnus-article-archive-name (group)
3510 "Return the first instance of an \"Archive-name\" in the current buffer."
3511 (let ((case-fold-search t))
3512 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3513 (nnheader-concat gnus-article-save-directory
3514 (match-string 1)))))
3516 (defun gnus-article-nndoc-name (group)
3517 "If GROUP is an nndoc group, return the name of the parent group."
3518 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3519 (gnus-group-get-parameter group 'save-article-group)))
3521 (defun gnus-summary-save-in-rmail (&optional filename)
3522 "Append this article to Rmail file.
3523 Optional argument FILENAME specifies file name.
3524 Directory to save to is default to `gnus-article-save-directory'."
3525 (setq filename (gnus-read-save-file-name
3526 "Save %s in rmail file:" filename
3527 gnus-rmail-save-name gnus-newsgroup-name
3528 gnus-current-headers 'gnus-newsgroup-last-rmail))
3529 (gnus-eval-in-buffer-window gnus-save-article-buffer
3533 (gnus-output-to-rmail filename))))
3536 (defun gnus-summary-save-in-mail (&optional filename)
3537 "Append this article to Unix mail file.
3538 Optional argument FILENAME specifies file name.
3539 Directory to save to is default to `gnus-article-save-directory'."
3540 (setq filename (gnus-read-save-file-name
3541 "Save %s in Unix mail file:" filename
3542 gnus-mail-save-name gnus-newsgroup-name
3543 gnus-current-headers 'gnus-newsgroup-last-mail))
3544 (gnus-eval-in-buffer-window gnus-save-article-buffer
3548 (if (and (file-readable-p filename)
3549 (file-regular-p filename)
3550 (mail-file-babyl-p filename))
3551 (rmail-output-to-rmail-file filename t)
3552 (gnus-output-to-mail filename)))))
3555 (defun gnus-summary-save-in-file (&optional filename overwrite)
3556 "Append this article to file.
3557 Optional argument FILENAME specifies file name.
3558 Directory to save to is default to `gnus-article-save-directory'."
3559 (setq filename (gnus-read-save-file-name
3560 "Save %s in file:" filename
3561 gnus-file-save-name gnus-newsgroup-name
3562 gnus-current-headers 'gnus-newsgroup-last-file))
3563 (gnus-eval-in-buffer-window gnus-save-article-buffer
3567 (when (and overwrite
3568 (file-exists-p filename))
3569 (delete-file filename))
3570 (gnus-output-to-file filename))))
3573 (defun gnus-summary-write-to-file (&optional filename)
3574 "Write this article to a file, overwriting it if the file exists.
3575 Optional argument FILENAME specifies file name.
3576 The directory to save in defaults to `gnus-article-save-directory'."
3577 (gnus-summary-save-in-file nil t))
3579 (defun gnus-summary-save-body-in-file (&optional filename)
3580 "Append this article body to a file.
3581 Optional argument FILENAME specifies file name.
3582 The directory to save in defaults to `gnus-article-save-directory'."
3583 (setq filename (gnus-read-save-file-name
3584 "Save %s body in file:" filename
3585 gnus-file-save-name gnus-newsgroup-name
3586 gnus-current-headers 'gnus-newsgroup-last-file))
3587 (gnus-eval-in-buffer-window gnus-save-article-buffer
3591 (when (article-goto-body)
3592 (narrow-to-region (point) (point-max)))
3593 (gnus-output-to-file filename))))
3596 (defun gnus-summary-save-in-pipe (&optional command)
3597 "Pipe this article to subprocess."
3599 (cond ((and (eq command 'default)
3600 gnus-last-shell-command)
3601 gnus-last-shell-command)
3606 "Shell command on %s: "
3607 (if (and gnus-number-of-articles-to-be-saved
3608 (> gnus-number-of-articles-to-be-saved 1))
3609 (format "these %d articles"
3610 gnus-number-of-articles-to-be-saved)
3612 gnus-last-shell-command))))
3613 (when (string-equal command "")
3614 (if gnus-last-shell-command
3615 (setq command gnus-last-shell-command)
3616 (error "A command is required")))
3617 (gnus-eval-in-buffer-window gnus-article-buffer
3620 (shell-command-on-region (point-min) (point-max) command nil)))
3621 (setq gnus-last-shell-command command))
3623 (defun gnus-summary-pipe-to-muttprint (&optional command)
3624 "Pipe this article to muttprint."
3625 (setq command (read-string
3626 "Print using command: " gnus-summary-muttprint-program
3627 nil gnus-summary-muttprint-program))
3628 (gnus-summary-save-in-pipe command))
3630 ;;; Article file names when saving.
3632 (defun gnus-capitalize-newsgroup (newsgroup)
3633 "Capitalize NEWSGROUP name."
3634 (when (not (zerop (length newsgroup)))
3635 (concat (char-to-string (upcase (aref newsgroup 0)))
3636 (substring newsgroup 1))))
3638 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3639 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3640 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3641 Otherwise, it is like ~/News/news/group/num."
3644 (concat (if (gnus-use-long-file-name 'not-save)
3645 (gnus-capitalize-newsgroup newsgroup)
3646 (gnus-newsgroup-directory-form newsgroup))
3647 "/" (int-to-string (mail-header-number headers)))
3648 gnus-article-save-directory)))
3650 (string-equal (file-name-directory default)
3651 (file-name-directory last-file))
3652 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3654 (or last-file default))))
3656 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3657 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3658 If variable `gnus-use-long-file-name' is non-nil, it is
3659 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3662 (concat (if (gnus-use-long-file-name 'not-save)
3664 (gnus-newsgroup-directory-form newsgroup))
3665 "/" (int-to-string (mail-header-number headers)))
3666 gnus-article-save-directory)))
3668 (string-equal (file-name-directory default)
3669 (file-name-directory last-file))
3670 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3672 (or last-file default))))
3674 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3675 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3676 If variable `gnus-use-long-file-name' is non-nil, it is
3677 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3680 (if (gnus-use-long-file-name 'not-save)
3683 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3685 gnus-article-save-directory)))
3687 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3688 "Generate file name from sender."
3689 (let ((from (mail-header-from headers)))
3691 (if (and from (string-match "\\([^ <]+\\)@" from))
3692 (match-string 1 from)
3694 gnus-article-save-directory)))
3696 (defun article-verify-x-pgp-sig ()
3699 (if (gnus-buffer-live-p gnus-original-article-buffer)
3700 (let ((sig (with-current-buffer gnus-original-article-buffer
3701 (gnus-fetch-field "X-PGP-Sig")))
3705 (mml2015-clear-verify-function))
3707 (insert-buffer-substring gnus-original-article-buffer)
3708 (setq items (split-string sig))
3709 (message-narrow-to-head)
3710 (let ((inhibit-point-motion-hooks t)
3711 (case-fold-search t))
3712 ;; Don't verify multiple headers.
3713 (setq headers (mapconcat (lambda (header)
3715 (mail-fetch-field header)
3717 (split-string (nth 1 items) ",") "")))
3718 (delete-region (point-min) (point-max))
3719 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3720 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3725 (if (looking-at "^-")
3728 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3729 (insert "Version: " (car items) "\n\n")
3730 (insert (mapconcat 'identity (cddr items) "\n"))
3731 (insert "\n-----END PGP SIGNATURE-----\n")
3732 (let ((mm-security-handle (list (format "multipart/signed"))))
3733 (mml2015-clean-buffer)
3734 (let ((coding-system-for-write (or gnus-newsgroup-charset
3736 (funcall (mml2015-clear-verify-function)))
3738 (or (mm-handle-multipart-ctl-parameter
3739 mm-security-handle 'gnus-details)
3740 (mm-handle-multipart-ctl-parameter
3741 mm-security-handle 'gnus-info)))))
3743 (let ((inhibit-read-only t) bface eface)
3745 (message-narrow-to-head)
3746 (goto-char (point-max))
3748 (setq bface (get-text-property (point-at-bol) 'face)
3749 eface (get-text-property (1- (point-at-eol)) 'face))
3750 (message-remove-header "X-Gnus-PGP-Verify")
3751 (if (re-search-forward "^X-PGP-Sig:" nil t)
3753 (goto-char (point-max)))
3754 (narrow-to-region (point) (point))
3755 (insert "X-Gnus-PGP-Verify: " info "\n")
3756 (goto-char (point-min))
3759 (if (not (looking-at "^[ \t]"))
3763 (goto-char (point-min))
3764 (when (looking-at "\\([^:]+\\): *")
3765 (put-text-property (match-beginning 1) (1+ (match-end 1))
3767 (put-text-property (match-end 0) (point-max)
3768 'face eface)))))))))
3770 (defun article-verify-cancel-lock ()
3771 "Verify Cancel-Lock header."
3773 (if (gnus-buffer-live-p gnus-original-article-buffer)
3774 (canlock-verify gnus-original-article-buffer)))
3776 (defun article-monafy ()
3777 "Display body part with mona font."
3779 (unless (if (featurep 'xemacs)
3780 (find-face 'gnus-mona-face)
3781 (facep 'gnus-mona-face))
3782 (require 'navi2ch-mona)
3783 (set-face-font (make-face 'gnus-mona-face) navi2ch-mona-font))
3785 (let ((inhibit-read-only t))
3788 (gnus-make-overlay (point) (point-max))
3789 'face 'gnus-mona-face))))
3796 (setq afunc (car func)
3799 gfunc (intern (format "gnus-%s" func))))
3801 (when (fboundp afunc)
3802 `(lambda (&optional interactive &rest args)
3803 ,(documentation afunc t)
3804 (interactive (list t))
3806 (set-buffer gnus-article-buffer)
3808 (call-interactively ',afunc)
3809 (apply ',afunc args))))))))
3810 '(article-hide-headers
3811 article-verify-x-pgp-sig
3812 article-verify-cancel-lock
3814 article-hide-boring-headers
3815 article-treat-overstrike
3816 article-treat-ansi-sequences
3817 article-fill-long-lines
3818 article-capitalize-sentences
3820 article-remove-leading-whitespace
3821 article-display-x-face
3822 article-display-face
3823 article-de-quoted-unreadable
3824 article-de-base64-unreadable
3827 article-unsplit-urls
3828 article-hide-list-identifiers
3829 article-strip-banner
3832 article-hide-signature
3833 article-strip-headers-in-body
3834 article-remove-trailing-blank-lines
3835 article-strip-leading-blank-lines
3836 article-strip-multiple-blank-lines
3837 article-strip-leading-space
3838 article-strip-trailing-space
3839 article-strip-blank-lines
3840 article-strip-all-blank-lines
3842 article-date-english
3843 article-date-iso8601
3844 article-date-original
3846 article-decode-mime-words
3847 article-decode-charset
3848 article-decode-encoded-words
3852 article-treat-dumbquotes
3853 article-normalize-headers
3854 (article-show-all-headers . gnus-article-show-all-headers)
3855 ;; (article-show-all . gnus-article-show-all)
3859 ;;; Gnus article mode
3862 (put 'gnus-article-mode 'mode-class 'special)
3864 (gnus-define-keys gnus-article-mode-map
3865 " " gnus-article-goto-next-page
3866 "\177" gnus-article-goto-prev-page
3867 [delete] gnus-article-goto-prev-page
3868 [backspace] gnus-article-goto-prev-page
3869 "\C-c^" gnus-article-refer-article
3870 "h" gnus-article-show-summary
3871 "s" gnus-article-show-summary
3872 "\C-c\C-m" gnus-article-mail
3873 "?" gnus-article-describe-briefly
3874 "e" gnus-summary-edit-article
3875 "<" beginning-of-buffer
3877 "\C-c\C-i" gnus-info-find-node
3879 "R" gnus-article-reply-with-original
3880 "F" gnus-article-followup-with-original
3881 "\C-hk" gnus-article-describe-key
3882 "\C-hc" gnus-article-describe-key-briefly
3884 "\C-d" gnus-article-read-summary-keys
3885 "\M-*" gnus-article-read-summary-keys
3886 "\M-#" gnus-article-read-summary-keys
3887 "\M-^" gnus-article-read-summary-keys
3888 "\M-g" gnus-article-read-summary-keys)
3890 ;; Define almost undefined keys to `gnus-article-read-summary-keys'.
3894 (push (char-to-string key) keys)
3896 (dolist (elem (accessible-keymaps gnus-summary-mode-map))
3897 (setq key (car elem))
3898 (when (and (> (length key) 0)
3899 (not (eq 'menu-bar (aref key 0)))
3900 (symbolp (lookup-key gnus-summary-mode-map key)))
3903 (unless (lookup-key gnus-article-mode-map key)
3904 (define-key gnus-article-mode-map key 'gnus-article-read-summary-keys))))
3906 (defun gnus-article-make-menu-bar ()
3907 (unless (boundp 'gnus-article-commands-menu)
3908 (gnus-summary-make-menu-bar))
3909 (gnus-turn-off-edit-menu 'article)
3910 (unless (boundp 'gnus-article-article-menu)
3912 gnus-article-article-menu gnus-article-mode-map ""
3914 ["Scroll forwards" gnus-article-goto-next-page t]
3915 ["Scroll backwards" gnus-article-goto-prev-page t]
3916 ["Show summary" gnus-article-show-summary t]
3917 ["Fetch Message-ID at point" gnus-article-refer-article t]
3918 ["Mail to address at point" gnus-article-mail t]
3919 ["Send a bug report" gnus-bug t]))
3922 gnus-article-treatment-menu gnus-article-mode-map ""
3923 ;; Fixme: this should use :active (and maybe :visible).
3925 ["Hide headers" gnus-article-hide-headers t]
3926 ["Hide signature" gnus-article-hide-signature t]
3927 ["Hide citation" gnus-article-hide-citation t]
3928 ["Treat overstrike" gnus-article-treat-overstrike t]
3929 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
3930 ["Remove carriage return" gnus-article-remove-cr t]
3931 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3932 ["Treat html" gnus-article-wash-html t]
3933 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3934 ["Decode HZ" gnus-article-decode-HZ t]))
3936 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3938 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3940 (gnus-run-hooks 'gnus-article-menu-hook)))
3942 (defun gnus-article-mode ()
3943 "Major mode for displaying an article.
3945 All normal editing commands are switched off.
3947 The following commands are available in addition to all summary mode
3949 \\<gnus-article-mode-map>
3950 \\[gnus-article-next-page]\t Scroll the article one page forwards
3951 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3952 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3953 \\[gnus-article-show-summary]\t Display the summary buffer
3954 \\[gnus-article-mail]\t Send a reply to the address near point
3955 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3956 \\[gnus-info-find-node]\t Go to the Gnus info node"
3958 (kill-all-local-variables)
3959 (gnus-simplify-mode-line)
3960 (setq mode-name "Article")
3961 (setq major-mode 'gnus-article-mode)
3962 (make-local-variable 'minor-mode-alist)
3963 (unless (assq 'gnus-show-mime minor-mode-alist)
3964 (push (list 'gnus-show-mime " MIME") minor-mode-alist))
3965 (use-local-map gnus-article-mode-map)
3966 (when (gnus-visual-p 'article-menu 'menu)
3967 (gnus-article-make-menu-bar)
3968 (when gnus-summary-tool-bar-map
3969 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3970 (gnus-update-format-specifications nil 'article-mode)
3971 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3972 (set (make-local-variable 'gnus-page-broken) nil)
3973 (make-local-variable 'gnus-button-marker-list)
3974 (make-local-variable 'gnus-article-current-summary)
3975 (make-local-variable 'gnus-article-mime-handles)
3976 (make-local-variable 'gnus-article-decoded-p)
3977 (make-local-variable 'gnus-article-mime-handle-alist)
3978 (make-local-variable 'gnus-article-wash-types)
3979 (make-local-variable 'gnus-article-image-alist)
3980 (make-local-variable 'gnus-article-charset)
3981 (make-local-variable 'gnus-article-ignored-charsets)
3982 ;; Prevent recent Emacsen from displaying non-break space as "\ ".
3983 (set (make-local-variable 'nobreak-char-display) nil)
3984 (gnus-set-default-directory)
3985 (buffer-disable-undo)
3986 (setq buffer-read-only t
3987 show-trailing-whitespace nil)
3988 (set-syntax-table gnus-article-mode-syntax-table)
3989 (gnus-run-mode-hooks 'gnus-article-mode-hook))
3991 (defun gnus-article-setup-buffer ()
3992 "Initialize the article buffer."
3993 (let* ((name (if gnus-single-article-buffer "*Article*"
3994 (concat "*Article " gnus-newsgroup-name "*")))
3996 (progn (string-match "\\*Article" name)
3997 (concat " *Original Article"
3998 (substring name (match-end 0))))))
3999 (setq gnus-article-buffer name)
4000 (setq gnus-original-article-buffer original)
4001 (setq gnus-article-mime-handle-alist nil)
4002 ;; This might be a variable local to the summary buffer.
4003 (unless gnus-single-article-buffer
4005 (set-buffer gnus-summary-buffer)
4006 (setq gnus-article-buffer name)
4007 (setq gnus-original-article-buffer original)
4008 (gnus-set-global-variables)))
4009 (gnus-article-setup-highlight-words)
4010 ;; Init original article buffer.
4012 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
4013 (set-buffer-multibyte t)
4014 (setq major-mode 'gnus-original-article-mode)
4015 (make-local-variable 'gnus-original-article))
4016 (if (and (get-buffer name)
4017 (with-current-buffer name
4018 (if gnus-article-edit-mode
4019 (if (y-or-n-p "Article mode edit in progress; discard? ")
4021 (set-buffer-modified-p nil)
4022 (gnus-kill-buffer name)
4025 (error "Action aborted"))
4029 (set (make-local-variable 'gnus-article-edit-mode) nil)
4030 (buffer-disable-undo)
4031 (setq buffer-read-only t)
4032 ;; This list just keeps growing if we don't reset it.
4033 (setq gnus-button-marker-list nil)
4034 (unless (eq major-mode 'gnus-article-mode)
4035 (gnus-article-mode))
4038 (set-buffer (gnus-get-buffer-create name))
4040 (make-local-variable 'gnus-summary-buffer)
4041 (gnus-summary-set-local-parameters gnus-newsgroup-name)
4042 (current-buffer)))))
4044 ;; Set article window start at LINE, where LINE is the number of lines
4045 ;; from the head of the article.
4046 (defun gnus-article-set-window-start (&optional line)
4048 (gnus-get-buffer-window gnus-article-buffer t)
4050 (set-buffer gnus-article-buffer)
4051 (goto-char (point-min))
4054 (gnus-message 6 "Moved to bookmark")
4055 (search-forward "\n\n" nil t)
4059 ;;; @@ article filters
4062 (defun gnus-article-display-mime-message ()
4063 "Article display method for MIME message."
4064 ;; called from `gnus-original-article-buffer'.
4065 (let (charset all-headers)
4066 (with-current-buffer gnus-summary-buffer
4067 (setq charset default-mime-charset
4068 all-headers gnus-have-all-headers))
4069 (make-local-variable 'default-mime-charset)
4070 (setq default-mime-charset charset)
4071 (with-current-buffer (get-buffer-create gnus-article-buffer)
4072 (make-local-variable 'default-mime-charset)
4073 (setq default-mime-charset charset))
4074 (mime-display-message mime-message-structure
4075 gnus-article-buffer nil gnus-article-mode-map)
4077 (gnus-article-hide-headers nil -1)))
4078 (run-hooks 'gnus-mime-article-prepare-hook))
4080 (defun gnus-article-display-traditional-message ()
4081 "Article display method for traditional message."
4082 (set-buffer gnus-article-buffer)
4083 (let ((inhibit-read-only t))
4085 (insert-buffer-substring gnus-original-article-buffer)))
4087 (defun gnus-article-make-full-mail-header (&optional number charset)
4088 "Create a new mail header structure in a raw article buffer."
4089 (unless (and number charset)
4090 (save-current-buffer
4091 (set-buffer gnus-summary-buffer)
4093 (setq number (or (cdr gnus-article-current) 0)))
4095 (setq charset (or default-mime-charset 'x-ctext)))))
4096 (goto-char (point-min))
4097 (let ((header-end (if (search-forward "\n\n" nil t)
4099 (goto-char (point-max))))
4100 (chars (- (point-max) (point)))
4101 (lines (count-lines (point) (point-max)))
4102 (default-mime-charset charset)
4104 (narrow-to-region (point-min) header-end)
4105 (setq xref (std11-fetch-field "xref"))
4107 (make-full-mail-header
4109 (std11-fetch-field "subject")
4110 (std11-fetch-field "from")
4111 (std11-fetch-field "date")
4112 (std11-fetch-field "message-id")
4113 (std11-fetch-field "references")
4116 (when xref (concat "Xref: " xref)))
4119 (defun gnus-article-prepare (article &optional all-headers header)
4120 "Prepare ARTICLE in article mode buffer.
4121 ARTICLE should either be an article number or a Message-ID.
4122 If ARTICLE is an id, HEADER should be the article headers.
4123 If ALL-HEADERS is non-nil, no headers are hidden."
4125 ;; Make sure we start in a summary buffer.
4126 (unless (eq major-mode 'gnus-summary-mode)
4127 (set-buffer gnus-summary-buffer))
4128 (setq gnus-summary-buffer (current-buffer))
4129 (let* ((gnus-article (if header (mail-header-number header) article))
4130 (summary-buffer (current-buffer))
4131 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
4132 (group gnus-newsgroup-name)
4135 (gnus-article-setup-buffer)
4136 (set-buffer gnus-article-buffer)
4137 ;; Deactivate active regions.
4138 (when (and (boundp 'transient-mark-mode)
4139 transient-mark-mode)
4140 (setq mark-active nil))
4141 (if (not (setq result (let ((inhibit-read-only t))
4142 (gnus-request-article-this-buffer
4144 ;; There is no such article.
4146 (when (and (numberp article)
4147 (not (memq article gnus-newsgroup-sparse)))
4148 (setq gnus-article-current
4149 (cons gnus-newsgroup-name article))
4150 (set-buffer gnus-summary-buffer)
4151 (setq gnus-current-article article)
4152 (if (and (memq article gnus-newsgroup-undownloaded)
4153 (not (gnus-online (gnus-find-method-for-group
4154 gnus-newsgroup-name))))
4156 (gnus-summary-set-agent-mark article)
4157 (message "Message marked for downloading"))
4158 (gnus-summary-mark-article article gnus-canceled-mark)
4159 (unless (memq article gnus-newsgroup-sparse)
4160 (gnus-error 1 "No such article (may have expired or been canceled)")))))
4161 (if (or (eq result 'pseudo)
4162 (eq result 'nneething))
4165 (set-buffer summary-buffer)
4166 (push article gnus-newsgroup-history)
4167 (setq gnus-last-article gnus-current-article
4168 gnus-current-article 0
4169 gnus-current-headers nil
4170 gnus-article-current nil)
4171 (if (eq result 'nneething)
4172 (gnus-configure-windows 'summary)
4173 (gnus-configure-windows 'article))
4174 (gnus-set-global-variables))
4175 (let ((gnus-article-mime-handle-alist-1
4176 gnus-article-mime-handle-alist))
4177 (gnus-set-mode-line 'article)))
4178 ;; The result from the `request' was an actual article -
4179 ;; or at least some text that is now displayed in the
4181 (when (and (numberp article)
4182 (not (eq article gnus-current-article)))
4183 ;; Seems like a new article has been selected.
4184 ;; `gnus-current-article' must be an article number.
4186 (set-buffer summary-buffer)
4187 (push article gnus-newsgroup-history)
4188 (setq gnus-last-article gnus-current-article
4189 gnus-current-article article
4190 gnus-current-headers
4191 (gnus-summary-article-header gnus-current-article)
4192 gnus-article-current
4193 (cons gnus-newsgroup-name gnus-current-article))
4194 (unless (vectorp gnus-current-headers)
4195 (setq gnus-current-headers nil))
4196 (gnus-summary-goto-subject gnus-current-article)
4197 (when (gnus-summary-show-thread)
4198 ;; If the summary buffer really was folded, the
4199 ;; previous goto may not actually have gone to
4200 ;; the right article, but the thread root instead.
4202 (gnus-summary-goto-subject gnus-current-article))
4203 (gnus-run-hooks 'gnus-mark-article-hook)
4204 (gnus-set-mode-line 'summary)
4205 (when (gnus-visual-p 'article-highlight 'highlight)
4206 (gnus-run-hooks 'gnus-visual-mark-article-hook))
4207 ;; Set the global newsgroup variables here.
4208 (gnus-set-global-variables)
4209 (setq gnus-have-all-headers
4210 (or all-headers gnus-show-all-headers))))
4212 (gnus-configure-windows 'article))
4213 (when (or (numberp article)
4215 (gnus-article-prepare-display)
4217 (goto-char (point-min))
4218 (when gnus-break-pages
4219 (gnus-narrow-to-page)))
4220 (let ((gnus-article-mime-handle-alist-1
4221 gnus-article-mime-handle-alist))
4222 (gnus-set-mode-line 'article))
4226 (set-window-point (get-buffer-window (current-buffer)) (point))
4227 (gnus-configure-windows 'article)
4230 (defun gnus-article-prepare-mime-display (&optional number)
4231 (goto-char (point-min))
4232 (when (re-search-forward "^[^\t ]+:" nil t)
4233 (goto-char (match-beginning 0)))
4234 (let ((entity (if (eq 1 (point-min))
4235 (get-text-property 1 'mime-view-entity)
4236 (get-text-property (point) 'mime-view-entity)))
4237 last-entity child-entity next type)
4238 (setq child-entity (mime-entity-children entity))
4240 (setq last-entity (nth (1- (length child-entity))
4242 (setq last-entity entity))
4244 (narrow-to-region (point)
4245 (if (search-forward "\n\n" nil t)
4248 (gnus-article-save-original-date (gnus-treat-article 'head))
4249 (put-text-property (point-min) (point-max) 'article-treated-header t)
4250 (goto-char (point-max)))
4251 (while (and (not (eobp)) entity)
4252 (setq next (set-marker
4254 (next-single-property-change (point) 'mime-view-entity
4256 (let ((types (mime-entity-content-type entity)))
4257 (while (eq 'multipart (mime-content-type-primary-type types))
4258 (setq entity (car (mime-entity-children entity))
4259 types (mime-entity-content-type entity)))
4261 (setq type (format "%s/%s"
4262 (mime-content-type-primary-type types)
4263 (mime-content-type-subtype types)))))
4264 (if (string-equal type "message/rfc822")
4267 (let ((children (mime-entity-children entity))
4270 (setq last-children (nth (1- (length children)) children))
4273 (not (eq last-children
4274 (get-text-property next 'mime-view-entity)))
4276 (next-single-property-change next
4278 nil (point-max)))))))
4279 (setq next (next-single-property-change next 'mime-view-entity
4282 (narrow-to-region (point) next)
4283 (gnus-article-prepare-mime-display)
4284 (goto-char (point-max)))
4285 (setq entity (get-text-property (point) 'mime-view-entity)))
4287 (narrow-to-region (point) next)
4288 ;; Kludge. We have to count true number, but for now,
4289 ;; part number is here only to achieve `last'.
4290 (gnus-treat-article nil 1
4291 (if (eq entity last-entity)
4294 (goto-char (point-max)))
4295 (setq entity (get-text-property next 'mime-view-entity))))))
4298 (defun gnus-article-prepare-display ()
4299 "Make the current buffer look like a nice article."
4300 (let ((gnus-article-buffer (current-buffer))
4302 (inhibit-read-only t))
4303 (unless (eq major-mode 'gnus-article-mode)
4304 (gnus-article-mode))
4305 (setq buffer-read-only nil
4306 gnus-button-marker-list nil
4307 gnus-article-wash-types nil
4308 gnus-article-image-alist nil)
4311 (static-if (featurep 'xemacs)
4312 (map-extents (lambda (extent maparg) (delete-extent extent)))
4313 (let ((lists (overlay-lists)))
4314 (dolist (overlay (nconc (car lists) (cdr lists)))
4315 (delete-overlay overlay)))))
4316 (gnus-run-hooks 'gnus-tmp-internal-hook))
4317 (let ((show-mime (unless (member gnus-newsgroup-name '("nndraft:delayed"
4320 (inhibit-read-only t))
4321 (set-buffer gnus-original-article-buffer)
4323 (setq mime-message-structure gnus-current-headers)
4324 (mime-buffer-entity-set-buffer-internal mime-message-structure
4325 gnus-original-article-buffer)
4326 (mime-entity-set-representation-type-internal mime-message-structure
4327 'mime-buffer-entity)
4328 (luna-send mime-message-structure 'initialize-instance
4329 mime-message-structure)
4331 (let (mime-display-header-hook mime-display-text/plain-hook)
4332 (funcall gnus-article-display-method-for-mime))
4333 (funcall gnus-article-display-method-for-traditional))
4334 ;; Call the treatment functions.
4338 (gnus-article-prepare-mime-display)
4339 (narrow-to-region (goto-char (point-min))
4340 (if (search-forward "\n\n" nil t)
4343 (gnus-article-save-original-date (gnus-treat-article 'head))
4344 (put-text-property (point-min) (point-max) 'article-treated-header t)
4345 (goto-char (point-max))
4347 (narrow-to-region (point) (point-max))
4348 (gnus-treat-article nil))
4349 (put-text-property (point-min) (point-max) 'read-only nil)))
4350 (gnus-run-hooks 'gnus-article-prepare-hook))
4352 (defun gnus-article-decode-article-as-default-mime-charset ()
4353 "Decode an article as `default-mime-charset'. It won't work if the
4354 value of the variable `gnus-show-mime' is non-nil."
4355 (unless (or gnus-show-mime
4356 (member gnus-newsgroup-name '("nndraft:delayed"
4358 (set (make-local-variable 'default-mime-charset)
4359 (with-current-buffer gnus-summary-buffer
4360 default-mime-charset))
4361 (decode-mime-charset-region (point-min) (point-max)
4362 default-mime-charset)))
4365 ;;; Gnus MIME viewing functions
4368 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4369 "Format of the MIME buttons.
4371 Valid specifiers include:
4373 %T MIME type, along with additional info
4374 %n The `name' parameter
4375 %d The description, if any
4376 %l The length of the encoded part
4377 %p The part identifier number
4378 %e Dots if the part isn't displayed
4380 General format specifiers can also be used. See Info node
4381 `(gnus)Formatting Variables'.")
4383 (defvar gnus-mime-button-line-format-alist
4384 '((?t gnus-tmp-type ?s)
4385 (?T gnus-tmp-type-long ?s)
4386 (?n gnus-tmp-name ?s)
4387 (?d gnus-tmp-description ?s)
4389 (?l gnus-tmp-length ?d)
4390 (?e gnus-tmp-dots ?s)))
4392 (defvar gnus-mime-button-commands
4393 '((gnus-article-press-button "\r" "Toggle Display")
4394 (gnus-mime-view-part "v" "View Interactively...")
4395 (gnus-mime-view-part-as-type "t" "View As Type...")
4396 (gnus-mime-view-part-as-charset "C" "View As charset...")
4397 (gnus-mime-save-part "o" "Save...")
4398 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4399 (gnus-mime-replace-part "r" "Replace part")
4400 (gnus-mime-delete-part "d" "Delete part")
4401 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4402 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4403 (gnus-mime-view-part-internally "E" "View Internally") ;; Why `E'?
4404 (gnus-mime-view-part-externally "e" "View Externally")
4405 (gnus-mime-print-part "p" "Print")
4406 (gnus-mime-pipe-part "|" "Pipe To Command...")
4407 (gnus-mime-action-on-part "." "Take action on the part...")))
4409 (defun gnus-article-mime-part-status ()
4410 (with-current-buffer gnus-article-buffer
4411 (let ((entity (get-text-property (point-min) 'mime-view-entity))
4414 (setq children (mime-entity-children entity))
4415 (setq children (length children)))
4418 (format " (%d parts)" children))
4421 (defvar gnus-mime-button-map
4422 (let ((map (make-sparse-keymap)))
4423 (define-key map gnus-mouse-2 'gnus-article-push-button)
4424 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4425 (dolist (c gnus-mime-button-commands)
4426 (define-key map (cadr c) (car c)))
4430 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4432 ,@(mapcar (lambda (c)
4433 (vector (caddr c) (car c) :enable t))
4434 gnus-mime-button-commands)))
4436 (defun gnus-mime-button-menu (event prefix)
4437 "Construct a context-sensitive menu of MIME commands."
4438 (interactive "e\nP")
4439 (save-window-excursion
4440 (let ((pos (event-start event)))
4441 (select-window (posn-window pos))
4442 (goto-char (posn-point pos))
4443 (gnus-article-check-buffer)
4444 (popup-menu gnus-mime-button-menu nil prefix))))
4446 (defun gnus-mime-view-all-parts (&optional handles)
4447 "View all the MIME parts."
4449 (with-current-buffer gnus-article-buffer
4450 (let ((handles (or handles gnus-article-mime-handles))
4451 (mail-parse-charset gnus-newsgroup-charset)
4452 (mail-parse-ignored-charsets
4453 (with-current-buffer gnus-summary-buffer
4454 gnus-newsgroup-ignored-charsets)))
4456 (mm-remove-parts handles)
4457 (goto-char (point-min))
4458 (or (search-forward "\n\n") (goto-char (point-max)))
4459 (let ((inhibit-read-only t))
4460 (delete-region (point) (point-max))
4461 (mm-display-parts handles))))))
4463 (defun gnus-article-jump-to-part (n)
4464 "Jump to MIME part N."
4466 (pop-to-buffer gnus-article-buffer)
4467 ;; FIXME: why is it necessary?
4469 (let ((parts (length gnus-article-mime-handle-alist)))
4472 (read-string ;; Emacs 21 doesn't have `read-number'.
4473 (format "Jump to part (2..%s): " parts)))))
4474 (unless (and (integerp n) (<= n parts) (>= n 1))
4477 (gnus-message 7 "Invalid part `%s', using %s instead."
4480 (gnus-message 9 "Jumping to part %s." n)
4481 (cond ((>= gnus-auto-select-part 1)
4482 (while (and (<= n parts)
4483 (not (gnus-article-goto-part n)))
4485 ((< gnus-auto-select-part 0)
4486 (while (and (>= n 1)
4487 (not (gnus-article-goto-part n)))
4490 (gnus-article-goto-part n)))))
4493 (defsubst gnus-article-edit-part (handles &optional current-id)
4494 "Edit an article in order to delete a mime part.
4495 This function is exclusively used by `gnus-mime-save-part-and-strip'
4496 and `gnus-mime-delete-part', and not provided at run-time normally."
4497 (gnus-article-edit-article
4499 (buffer-disable-undo)
4501 (let ((mail-parse-charset (or gnus-article-charset
4502 ',gnus-newsgroup-charset))
4503 (mail-parse-ignored-charsets
4504 (or gnus-article-ignored-charsets
4505 ',gnus-newsgroup-ignored-charsets))
4506 (mbl mml-buffer-list))
4507 (setq mml-buffer-list nil)
4508 (insert-buffer-substring gnus-original-article-buffer)
4509 (mime-to-mml ',handles)
4510 (setq gnus-article-mime-handles nil)
4511 (let ((mbl1 mml-buffer-list))
4512 (setq mml-buffer-list mbl)
4513 (set (make-local-variable 'mml-buffer-list) mbl1))
4514 (gnus-make-local-hook 'kill-buffer-hook)
4515 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4516 `(lambda (no-highlight)
4517 (let ((mail-parse-charset (or gnus-article-charset
4518 ',gnus-newsgroup-charset))
4519 (message-options message-options)
4520 (message-options-set-recipient)
4521 (mail-parse-ignored-charsets
4522 (or gnus-article-ignored-charsets
4523 ',gnus-newsgroup-ignored-charsets)))
4525 (mml-destroy-buffers)
4526 (remove-hook 'kill-buffer-hook
4527 'mml-destroy-buffers t)
4528 (kill-local-variable 'mml-buffer-list))
4529 (gnus-summary-edit-article-done
4530 ,(or (mail-header-references gnus-current-headers) "")
4531 ,(gnus-group-read-only-p)
4532 ,gnus-summary-buffer no-highlight))
4534 (gnus-article-edit-done)
4535 (gnus-summary-expand-window)
4536 (gnus-summary-show-article)
4537 (when (and current-id (integerp gnus-auto-select-part))
4538 (gnus-article-jump-to-part
4539 (+ current-id gnus-auto-select-part)))))
4541 (defun gnus-mime-replace-part (file)
4542 "Replace MIME part under point with an external body."
4543 ;; Useful if file has already been saved to disk
4547 (read-file-name "Replace MIME part with file: "
4548 (or mm-default-directory default-directory)
4550 (gnus-mime-save-part-and-strip file))
4552 (defun gnus-mime-save-part-and-strip (&optional file)
4553 "Save the MIME part under point then replace it with an external body.
4554 If FILE is given, use it for the external part."
4556 (gnus-article-check-buffer)
4557 (when (gnus-group-read-only-p)
4558 (error "The current group does not support deleting of parts"))
4559 (when (mm-complicated-handles gnus-article-mime-handles)
4561 The current article has a complicated MIME structure, giving up..."))
4562 (let* ((data (get-text-property (point) 'gnus-data))
4563 (id (get-text-property (point) 'gnus-part))
4565 (handles gnus-article-mime-handles))
4568 (and data (mm-save-part data "Delete MIME part and save to: "))))
4570 (with-current-buffer (mm-handle-buffer data)
4572 (insert "Content-Type: " (mm-handle-media-type data))
4573 (mml-insert-parameter-string (cdr (mm-handle-type data))
4576 (insert "Content-ID: " (message-make-message-id) "\n")
4577 (insert "Content-Transfer-Encoding: binary\n")
4580 (cdr (mm-make-handle nil
4581 `("message/external-body"
4582 (access-type . "LOCAL-FILE")
4584 ;; (set-buffer gnus-summary-buffer)
4585 (gnus-article-edit-part handles id))))
4587 ;; A function like `gnus-summary-save-parts' (`X m', `<MIME> <Extract all
4588 ;; parts...>') but with stripping would be nice.
4590 (defun gnus-mime-delete-part ()
4591 "Delete the MIME part under point.
4592 Replace it with some information about the removed part."
4594 (gnus-article-check-buffer)
4595 (when (gnus-group-read-only-p)
4596 (error "The current group does not support deleting of parts"))
4597 (when (mm-complicated-handles gnus-article-mime-handles)
4599 The current article has a complicated MIME structure, giving up..."))
4600 (when (or gnus-expert-user
4601 (gnus-yes-or-no-p "\
4602 Deleting parts may malfunction or destroy the article; continue? "))
4603 (let* ((data (get-text-property (point) 'gnus-data))
4604 (id (get-text-property (point) 'gnus-part))
4605 (handles gnus-article-mime-handles)
4609 (mail-decode-encoded-word-string (or (mm-handle-description data)
4612 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4614 (type (mm-handle-media-type data)))
4616 (error "No MIME part under point"))
4617 (with-current-buffer (mm-handle-buffer data)
4618 (let ((bsize (format "%s" (buffer-size))))
4623 "| The following attachment has been deleted:\n"
4625 "| Type: " type "\n"
4626 "| Filename: " filename "\n"
4627 "| Size (encoded): " bsize " Byte\n"
4628 "| Description: " description "\n"
4631 (cdr (mm-make-handle
4632 nil `("text/plain") nil nil
4634 (format "Deleted attachment (%s bytes)" bsize))))))
4635 ;; (set-buffer gnus-summary-buffer)
4636 (gnus-article-edit-part handles id))))
4638 (defun gnus-mime-save-part ()
4639 "Save the MIME part under point."
4641 (gnus-article-check-buffer)
4642 (let ((data (get-text-property (point) 'gnus-data)))
4644 (mm-save-part data))))
4646 (defun gnus-mime-pipe-part ()
4647 "Pipe the MIME part under point to a process."
4649 (gnus-article-check-buffer)
4650 (let ((data (get-text-property (point) 'gnus-data)))
4652 (mm-pipe-part data))))
4654 (defun gnus-mime-view-part ()
4655 "Interactively choose a viewing method for the MIME part under point."
4657 (gnus-article-check-buffer)
4658 (let ((data (get-text-property (point) 'gnus-data)))
4660 (setq gnus-article-mime-handles
4662 gnus-article-mime-handles (setq data (copy-sequence data))))
4663 (mm-interactively-view-part data))))
4665 (defun gnus-mime-view-part-as-type-internal ()
4666 (gnus-article-check-buffer)
4667 (let* ((name (mail-content-type-get
4668 (mm-handle-type (get-text-property (point) 'gnus-data))
4670 (def-type (and name (mm-default-file-encoding name))))
4671 (and def-type (cons def-type 0))))
4673 (defun gnus-mime-view-part-as-type (&optional mime-type)
4674 "Choose a MIME media type, and view the part as such."
4677 (setq mime-type (completing-read
4678 "View as MIME type: "
4679 (mapcar #'list (mailcap-mime-types))
4681 (gnus-mime-view-part-as-type-internal))))
4682 (gnus-article-check-buffer)
4683 (let ((handle (get-text-property (point) 'gnus-data)))
4686 (mm-make-handle (mm-handle-buffer handle)
4687 (cons mime-type (cdr (mm-handle-type handle)))
4688 (mm-handle-encoding handle)
4689 (mm-handle-undisplayer handle)
4690 (mm-handle-disposition handle)
4691 (mm-handle-description handle)
4693 (mm-handle-id handle)))
4694 (setq gnus-article-mime-handles
4695 (mm-merge-handles gnus-article-mime-handles handle))
4696 (gnus-mm-display-part handle))))
4698 (defun gnus-mime-copy-part (&optional handle arg)
4699 "Put the MIME part under point into a new buffer.
4700 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4702 (interactive (list nil current-prefix-arg))
4703 (gnus-article-check-buffer)
4705 (setq handle (get-text-property (point) 'gnus-data)))
4707 (let ((filename (or (mail-content-type-get (mm-handle-disposition handle)
4709 (mail-content-type-get (mm-handle-disposition handle)
4711 contents dont-decode charset coding-system)
4712 (mm-with-unibyte-buffer
4713 (mm-insert-part handle)
4714 (setq contents (or (condition-case nil
4715 (mm-decompress-buffer filename nil 'sig)
4717 (setq dont-decode t)
4720 (setq filename (cond (filename (file-name-nondirectory filename))
4721 (dont-decode "*raw data*")
4726 (unless (setq charset (mail-content-type-get
4727 (mm-handle-type handle) 'charset))
4728 (unless (setq coding-system (mm-with-unibyte-buffer
4730 (mm-find-buffer-file-coding-system)))
4731 (setq charset gnus-newsgroup-charset))))
4733 (setq charset (or (cdr (assq arg
4734 gnus-summary-show-article-charset-alist))
4735 (mm-read-coding-system "Charset: ")))))
4736 (switch-to-buffer (generate-new-buffer filename))
4737 (if (or coding-system
4739 (setq coding-system (mm-charset-to-coding-system charset))
4740 (not (eq charset 'ascii))))
4742 (mm-enable-multibyte)
4743 (insert (mm-decode-coding-string contents coding-system))
4744 (setq buffer-file-coding-system
4745 (if (boundp 'last-coding-system-used)
4746 (symbol-value 'last-coding-system-used)
4748 (mm-disable-multibyte)
4750 (setq buffer-file-coding-system mm-binary-coding-system))
4751 ;; We do it this way to make `normal-mode' set the appropriate mode.
4754 (setq buffer-file-name (expand-file-name filename))
4756 (setq buffer-file-name nil))
4757 (goto-char (point-min)))))
4759 (defun gnus-mime-print-part (&optional handle filename)
4760 "Print the MIME part under point."
4761 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4762 (gnus-article-check-buffer)
4763 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4764 (contents (and handle (mm-get-part handle)))
4765 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4766 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4771 (mm-save-part-to-file handle file)
4772 (call-process shell-file-name nil
4773 (generate-new-buffer " *mm*")
4775 shell-command-switch
4777 printer file (mm-handle-type handle))))
4781 (gnus-print-buffer))
4782 (ps-despool filename)))))
4784 (defun gnus-mime-inline-part (&optional handle arg)
4785 "Insert the MIME part under point into the current buffer.
4786 Compressed files like .gz and .bz2 are decompressed."
4787 (interactive (list nil current-prefix-arg))
4788 (gnus-article-check-buffer)
4790 (setq handle (get-text-property (point) 'gnus-data)))
4793 (inhibit-read-only t)
4794 contents charset coding-system)
4795 (if (and (not arg) (mm-handle-undisplayer handle))
4796 (mm-remove-part handle)
4797 (mm-with-unibyte-buffer
4798 (mm-insert-part handle)
4800 (or (mm-decompress-buffer
4801 (or (mail-content-type-get (mm-handle-disposition handle)
4803 (mail-content-type-get (mm-handle-disposition handle)
4809 (unless (setq charset (mail-content-type-get
4810 (mm-handle-type handle) 'charset))
4811 (unless (setq coding-system
4812 (mm-with-unibyte-buffer
4814 (mm-find-buffer-file-coding-system)))
4815 (setq charset gnus-newsgroup-charset))))
4817 (if (mm-handle-undisplayer handle)
4818 (mm-remove-part handle))
4821 gnus-summary-show-article-charset-alist))
4822 (mm-read-coding-system "Charset: "))))
4824 (if (mm-handle-undisplayer handle)
4825 (mm-remove-part handle))))
4829 (if (or coding-system
4832 (mm-charset-to-coding-system charset))
4833 (not (eq coding-system 'ascii))))
4834 (mm-decode-coding-string contents coding-system)
4835 (mm-string-to-multibyte contents)))
4838 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4839 "Insert the MIME part under point into the current buffer using the
4841 (interactive (list nil current-prefix-arg))
4842 (gnus-article-check-buffer)
4843 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4846 (inhibit-read-only t))
4848 (if (mm-handle-undisplayer handle)
4849 (mm-remove-part handle))
4850 (let ((gnus-newsgroup-charset
4852 gnus-summary-show-article-charset-alist))
4853 (mm-read-coding-system "Charset: ")))
4854 (gnus-newsgroup-ignored-charsets 'gnus-all))
4855 (gnus-article-press-button)))))
4857 (defun gnus-mime-view-part-externally (&optional handle)
4858 "View the MIME part under point with an external viewer."
4860 (gnus-article-check-buffer)
4861 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4862 (mm-user-display-methods nil)
4863 (mm-inlined-types nil)
4864 (mail-parse-charset gnus-newsgroup-charset)
4865 (mail-parse-ignored-charsets
4866 (with-current-buffer gnus-summary-buffer
4867 gnus-newsgroup-ignored-charsets)))
4869 (if (mm-handle-undisplayer handle)
4870 (mm-remove-part handle)
4871 (mm-display-part handle)))))
4873 (defun gnus-mime-view-part-internally (&optional handle)
4874 "View the MIME part under point with an internal viewer.
4875 If no internal viewer is available, use an external viewer."
4877 (gnus-article-check-buffer)
4878 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4879 (mm-inlined-types '(".*"))
4880 (mm-inline-large-images t)
4881 (mail-parse-charset gnus-newsgroup-charset)
4882 (mail-parse-ignored-charsets
4883 (with-current-buffer gnus-summary-buffer
4884 gnus-newsgroup-ignored-charsets))
4885 (inhibit-read-only t))
4887 (if (mm-handle-undisplayer handle)
4888 (mm-remove-part handle)
4889 (mm-display-part handle)))))
4891 (defun gnus-mime-action-on-part (&optional action)
4892 "Do something with the MIME attachment at \(point\)."
4894 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4895 (gnus-article-check-buffer)
4896 (let ((action-pair (assoc action gnus-mime-action-alist)))
4898 (funcall (cdr action-pair)))))
4900 (defun gnus-article-part-wrapper (n function &optional no-handle interactive)
4901 "Call FUNCTION on MIME part N.
4902 Unless NO-HANDLE, call FUNCTION with N-th MIME handle as it's only argument.
4903 If INTERACTIVE, call FUNCTION interactivly."
4905 ;; Check whether the article is displayed.
4906 (unless (and (gnus-buffer-live-p gnus-article-buffer)
4907 (setq window (get-buffer-window gnus-article-buffer t))
4908 (frame-visible-p (setq frame (window-frame window))))
4909 (error "No article is displayed"))
4910 (with-current-buffer gnus-article-buffer
4911 ;; Check whether the article displays the right contents.
4912 (unless (with-current-buffer gnus-summary-buffer
4913 (eq gnus-current-article (gnus-summary-article-number)))
4914 (error "You should select the right article first"))
4915 ;; Check whether the specified part exists.
4916 (when (> n (length gnus-article-mime-handle-alist))
4917 (error "No such part")))
4920 ;; To select the window is needed so that the cursor
4921 ;; might be visible on the MIME button.
4922 (select-window (prog1
4924 (setq window (selected-window))
4925 ;; Article may be displayed in the other frame.
4926 (gnus-select-frame-set-input-focus
4929 (setq frame (selected-frame))))))
4930 (when (gnus-article-goto-part n)
4931 ;; We point the cursor and the arrow at the MIME button
4932 ;; when the `function' prompt the user for something.
4933 (let ((cursor-in-non-selected-windows t)
4934 (overlay-arrow-string "=>")
4935 (overlay-arrow-position (point-marker)))
4938 ((and no-handle interactive)
4939 (call-interactively function))
4945 (cdr (assq n gnus-article-mime-handle-alist))))
4948 (cdr (assq n gnus-article-mime-handle-alist)))))
4949 (set-marker overlay-arrow-position nil)
4950 (unless gnus-auto-select-part
4951 (gnus-select-frame-set-input-focus frame)
4952 (select-window window))))
4954 (if gnus-inhibit-mime-unbuttonizing
4955 ;; This is the default though the program shouldn't reach here.
4956 (error "No such part")
4957 ;; The part which doesn't have the MIME button is selected.
4958 ;; So, we display all the buttons and redo it.
4959 (let ((gnus-inhibit-mime-unbuttonizing t))
4960 (gnus-summary-show-article)
4961 (gnus-article-part-wrapper n function no-handle))))))
4963 (defun gnus-article-pipe-part (n)
4964 "Pipe MIME part N, which is the numerical prefix."
4966 (gnus-article-part-wrapper n 'mm-pipe-part))
4968 (defun gnus-article-save-part (n)
4969 "Save MIME part N, which is the numerical prefix."
4971 (gnus-article-part-wrapper n 'mm-save-part))
4973 (defun gnus-article-interactively-view-part (n)
4974 "View MIME part N interactively, which is the numerical prefix."
4976 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4978 (defun gnus-article-copy-part (n)
4979 "Copy MIME part N, which is the numerical prefix."
4981 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4983 (defun gnus-article-view-part-as-charset (n)
4984 "View MIME part N using a specified charset.
4985 N is the numerical prefix."
4987 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4989 (defun gnus-article-view-part-externally (n)
4990 "View MIME part N externally, which is the numerical prefix."
4992 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4994 (defun gnus-article-inline-part (n)
4995 "Inline MIME part N, which is the numerical prefix."
4997 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4999 (defun gnus-article-save-part-and-strip (n)
5000 "Save MIME part N and replace it with an external body.
5001 N is the numerical prefix."
5003 (gnus-article-part-wrapper n 'gnus-mime-save-part-and-strip t))
5005 (defun gnus-article-replace-part (n)
5006 "Replace MIME part N with an external body.
5007 N is the numerical prefix."
5009 (gnus-article-part-wrapper n 'gnus-mime-replace-part t t))
5011 (defun gnus-article-delete-part (n)
5012 "Delete MIME part N and add some information about the removed part.
5013 N is the numerical prefix."
5015 (gnus-article-part-wrapper n 'gnus-mime-delete-part t))
5017 (defun gnus-article-mime-match-handle-first (condition)
5020 (dolist (ihandle gnus-article-mime-handle-alist)
5022 ((functionp condition)
5023 (funcall condition (cdr ihandle)))
5024 ((eq condition 'undisplayed)
5025 (not (or (mm-handle-undisplayer (cdr ihandle))
5026 (equal (mm-handle-media-type (cdr ihandle))
5027 "multipart/alternative"))))
5028 ((eq condition 'undisplayed-alternative)
5029 (not (mm-handle-undisplayer (cdr ihandle))))
5031 (gnus-article-goto-part (car ihandle))
5032 (or (not n) (< (car ihandle) n)))
5033 (setq n (car ihandle))))
5037 (defun gnus-article-view-part (&optional n)
5038 "View MIME part N, which is the numerical prefix."
5040 (with-current-buffer gnus-article-buffer
5041 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
5042 gnus-article-mime-match-handle-function)))
5043 (when (> n (length gnus-article-mime-handle-alist))
5044 (error "No such part"))
5045 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
5046 (when (gnus-article-goto-part n)
5047 (if (equal (car handle) "multipart/alternative")
5048 (gnus-article-press-button)
5049 (when (eq (gnus-mm-display-part handle) 'internal)
5050 (gnus-set-window-start)))))))
5052 (defsubst gnus-article-mime-total-parts ()
5053 (if (bufferp (car gnus-article-mime-handles))
5055 (1- (length gnus-article-mime-handles))))
5057 (defun gnus-mm-display-part (handle)
5058 "Display HANDLE and fix MIME button."
5059 (let ((id (get-text-property (point) 'gnus-part))
5061 (inhibit-read-only t))
5064 (let ((window (selected-window))
5065 (mail-parse-charset gnus-newsgroup-charset)
5066 (mail-parse-ignored-charsets
5067 (if (gnus-buffer-live-p gnus-summary-buffer)
5068 (with-current-buffer gnus-summary-buffer
5069 gnus-newsgroup-ignored-charsets)
5073 (let ((win (gnus-get-buffer-window (current-buffer) t))
5076 (select-window win))
5079 (if (mm-handle-displayed-p handle)
5080 ;; This will remove the part.
5081 (mm-display-part handle)
5083 (narrow-to-region (point)
5084 (if (eobp) (point) (1+ (point))))
5085 (mm-display-part handle)
5086 ;; We narrow to the part itself and
5087 ;; then call the treatment functions.
5088 (goto-char (point-min))
5090 (narrow-to-region (point) (point-max))
5093 (gnus-article-mime-total-parts)
5094 (mm-handle-media-type handle)))))
5095 (if (window-live-p window)
5096 (select-window window)))))
5099 (gnus-insert-mime-button
5100 handle id (list (mm-handle-displayed-p handle)))
5101 (goto-char point))))
5103 (defun gnus-article-goto-part (n)
5104 "Go to MIME part N."
5105 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
5107 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
5108 (let ((gnus-tmp-name
5109 (or (mail-content-type-get (mm-handle-type handle) 'name)
5110 (mail-content-type-get (mm-handle-disposition handle) 'filename)
5111 (mail-content-type-get (mm-handle-type handle) 'url)
5113 (gnus-tmp-type (mm-handle-media-type handle))
5114 (gnus-tmp-description
5115 (mail-decode-encoded-word-string (or (mm-handle-description handle)
5118 (if (if displayed (car displayed)
5119 (mm-handle-displayed-p handle))
5121 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
5123 gnus-tmp-type-long b e)
5124 (when (string-match ".*/" gnus-tmp-name)
5125 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
5126 (setq gnus-tmp-type-long (concat gnus-tmp-type
5127 (and (not (equal gnus-tmp-name ""))
5128 (concat "; " gnus-tmp-name))))
5129 (unless (equal gnus-tmp-description "")
5130 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
5135 gnus-mime-button-line-format gnus-mime-button-line-format-alist
5136 `(keymap ,gnus-mime-button-map
5137 gnus-callback gnus-mm-display-part
5138 gnus-part ,gnus-tmp-id
5139 article-type annotation
5142 ;; Exclude a newline.
5145 (widget-convert-button
5148 :action 'gnus-widget-press-button
5149 :button-keymap gnus-mime-button-map
5151 (lambda (widget/window &optional overlay pos)
5152 ;; Needed to properly clear the message due to a bug in
5153 ;; wid-edit (XEmacs only).
5154 (if (boundp 'help-echo-owns-message)
5155 (setq help-echo-owns-message t))
5157 "%S: %s the MIME part; %S: more options"
5158 (aref gnus-mouse-2 0)
5159 ;; XEmacs will get a single widget arg; Emacs 21 will get
5160 ;; window, overlay, position.
5161 (if (mm-handle-displayed-p
5163 (with-current-buffer (gnus-overlay-buffer overlay)
5164 (widget-get (widget-at (gnus-overlay-start overlay))
5166 (widget-get widget/window :mime-handle)))
5168 (aref gnus-down-mouse-3 0))))))
5170 (defun gnus-widget-press-button (elems el)
5171 (goto-char (widget-get elems :from))
5172 (gnus-article-press-button))
5174 (defvar gnus-displaying-mime nil)
5176 (defun gnus-display-mime (&optional ihandles)
5177 "Display the MIME parts."
5179 (save-selected-window
5180 (let ((window (get-buffer-window gnus-article-buffer))
5183 (select-window window)
5184 ;; We have to do this since selecting the window
5185 ;; may change the point. So we set the window point.
5186 (set-window-point window point)))
5187 (let ((handles ihandles)
5188 (inhibit-read-only t)
5191 ((setq handles (mm-dissect-buffer nil gnus-article-loose-mime))
5192 (when gnus-article-emulate-mime
5193 (mm-uu-dissect-text-parts handles)))
5194 (gnus-article-emulate-mime
5195 (setq handles (mm-uu-dissect))))
5196 (when (and (not ihandles)
5197 (not gnus-displaying-mime))
5198 ;; Top-level call; we clean up.
5199 (when gnus-article-mime-handles
5200 (mm-destroy-parts gnus-article-mime-handles)
5201 (setq gnus-article-mime-handle-alist nil));; A trick.
5202 (setq gnus-article-mime-handles handles)
5203 ;; We allow users to glean info from the handles.
5204 (when gnus-article-mime-part-function
5205 (gnus-mime-part-function handles)))
5207 (or (not (stringp (car handles)))
5210 (when (and (not ihandles)
5211 (not gnus-displaying-mime))
5212 ;; Clean up for mime parts.
5214 (delete-region (point) (point-max)))
5215 (let ((gnus-displaying-mime t))
5216 (gnus-mime-display-part handles)))
5219 (narrow-to-region (point) (point-max))
5220 (gnus-treat-article nil 1 1)
5223 ;; Highlight the headers.
5227 (narrow-to-region (point-min) (point))
5228 (gnus-article-save-original-date
5229 (gnus-treat-article 'head)))))))))
5231 (defcustom gnus-mime-display-multipart-as-mixed nil
5232 "Display \"multipart\" parts as \"multipart/mixed\".
5234 If t, it overrides nil values of
5235 `gnus-mime-display-multipart-alternative-as-mixed' and
5236 `gnus-mime-display-multipart-related-as-mixed'."
5237 :group 'gnus-article-mime
5240 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
5241 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
5243 :group 'gnus-article-mime
5246 (defcustom gnus-mime-display-multipart-related-as-mixed nil
5247 "Display \"multipart/related\" parts as \"multipart/mixed\".
5249 If displaying \"text/html\" is discouraged \(see
5250 `mm-discouraged-alternatives'\) images or other material inside a
5251 \"multipart/related\" part might be overlooked when this variable is nil."
5253 :group 'gnus-article-mime
5256 (defun gnus-mime-display-part (handle)
5258 ;; Maybe a broken MIME message.
5261 ((not (stringp (car handle)))
5262 (gnus-mime-display-single handle))
5263 ;; User-defined multipart
5264 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
5265 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
5267 ;; multipart/alternative
5268 ((and (equal (car handle) "multipart/alternative")
5269 (not (or gnus-mime-display-multipart-as-mixed
5270 gnus-mime-display-multipart-alternative-as-mixed)))
5271 (let ((id (1+ (length gnus-article-mime-handle-alist))))
5272 (push (cons id handle) gnus-article-mime-handle-alist)
5273 (gnus-mime-display-alternative (cdr handle) nil nil id)))
5274 ;; multipart/related
5275 ((and (equal (car handle) "multipart/related")
5276 (not (or gnus-mime-display-multipart-as-mixed
5277 gnus-mime-display-multipart-related-as-mixed)))
5278 ;;;!!!We should find the start part, but we just default
5279 ;;;!!!to the first part.
5280 ;;(gnus-mime-display-part (cadr handle))
5281 ;;;!!! Most multipart/related is an HTML message plus images.
5282 ;;;!!! Unfortunately we are unable to let W3 display those
5283 ;;;!!! included images, so we just display it as a mixed multipart.
5284 ;;(gnus-mime-display-mixed (cdr handle))
5285 ;;;!!! No, w3 can display everything just fine.
5286 (gnus-mime-display-part (cadr handle)))
5287 ((equal (car handle) "multipart/signed")
5288 (gnus-add-wash-type 'signed)
5289 (gnus-mime-display-security handle))
5290 ((equal (car handle) "multipart/encrypted")
5291 (gnus-add-wash-type 'encrypted)
5292 (gnus-mime-display-security handle))
5293 ;; Other multiparts are handled like multipart/mixed.
5295 (gnus-mime-display-mixed (cdr handle)))))
5297 (defun gnus-mime-part-function (handles)
5298 (if (stringp (car handles))
5299 (mapcar 'gnus-mime-part-function (cdr handles))
5300 (funcall gnus-article-mime-part-function handles)))
5302 (defun gnus-mime-display-mixed (handles)
5303 (mapcar 'gnus-mime-display-part handles))
5305 (defun gnus-mime-display-single (handle)
5306 (let ((type (mm-handle-media-type handle))
5307 (ignored gnus-ignored-mime-types)
5314 (when (string-match (pop ignored) type)
5315 (throw 'ignored nil)))
5316 (if (and (setq not-attachment
5317 (and (not (mm-inline-override-p handle))
5318 (or (not (mm-handle-disposition handle))
5319 (equal (car (mm-handle-disposition handle))
5321 (mm-attachment-override-p handle))))
5322 (mm-automatic-display-p handle)
5324 (mm-inlinable-p handle)
5325 (mm-inlined-p handle))
5326 (mm-automatic-external-display-p type)))
5328 (when (equal (mm-handle-media-supertype handle) "text")
5330 (let ((id (1+ (length gnus-article-mime-handle-alist)))
5332 (push (cons id handle) gnus-article-mime-handle-alist)
5333 (when (or (not display)
5334 (not (gnus-unbuttonized-mime-type-p type)))
5335 (gnus-insert-mime-button
5336 handle id (list (or display (and not-attachment text))))
5337 (gnus-article-insert-newline)
5338 ;; Remember modify the number of forward lines.
5346 (let ((mail-parse-charset gnus-newsgroup-charset)
5347 (mail-parse-ignored-charsets
5348 (save-excursion (condition-case ()
5349 (set-buffer gnus-summary-buffer)
5351 gnus-newsgroup-ignored-charsets)))
5352 (mm-display-part handle t))
5353 (goto-char (point-max)))
5354 ((and text not-attachment)
5358 (gnus-article-insert-newline)
5359 (mm-insert-inline handle
5361 (mail-content-type-get
5362 (mm-handle-type handle) 'charset)))
5363 (if (eq charset 'gnus-decoded)
5364 (mm-get-part handle)
5365 (mm-decode-string (mm-get-part handle)
5367 (goto-char (point-max))))
5371 (narrow-to-region beg (point))
5374 (gnus-article-mime-total-parts)
5375 (mm-handle-media-type handle)))))))))
5377 (defun gnus-unbuttonized-mime-type-p (type)
5378 "Say whether TYPE is to be unbuttonized."
5379 (unless gnus-inhibit-mime-unbuttonizing
5381 (let ((types gnus-unbuttonized-mime-types))
5383 (when (string-match (pop types) type)
5384 (throw 'found t)))))
5386 (let ((types gnus-buttonized-mime-types))
5388 (when (string-match (pop types) type)
5389 (throw 'found t)))))))))
5391 (defun gnus-article-insert-newline ()
5392 "Insert a newline, but mark it as undeletable."
5393 (gnus-put-text-property
5394 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
5396 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
5397 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
5400 handle (inhibit-read-only t) from props begend not-pref)
5401 (save-window-excursion
5404 (narrow-to-region (car ibegend)
5407 (goto-char (car ibegend))
5410 (delete-region (point-min) (point-max))
5411 (mm-remove-parts handles))
5412 (setq begend (list (point-marker)))
5414 (unless (setq not-pref (cadr (member preferred ihandles)))
5415 (setq not-pref (car ihandles)))
5418 (not (gnus-unbuttonized-mime-type-p
5419 "multipart/alternative")))
5420 (gnus-add-text-properties
5423 (insert (format "%d. " id))
5427 (unless ,(not ibegend)
5428 (setq gnus-article-mime-handle-alist
5429 ',gnus-article-mime-handle-alist))
5430 (gnus-mime-display-alternative
5431 ',ihandles ',not-pref ',begend ,id))
5432 keymap ,gnus-mime-button-map
5433 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5434 face ,gnus-article-button-face
5437 (widget-convert-button 'link from (point)
5438 :action 'gnus-widget-press-button
5439 :button-keymap gnus-widget-button-keymap)
5441 (while (setq handle (pop handles))
5442 (gnus-add-text-properties
5445 (insert (format "(%c) %-18s"
5446 (if (equal handle preferred) ?* ? )
5447 (mm-handle-media-type handle)))
5451 (unless ,(not ibegend)
5452 (setq gnus-article-mime-handle-alist
5453 ',gnus-article-mime-handle-alist))
5454 (gnus-mime-display-alternative
5455 ',ihandles ',handle ',begend ,id))
5456 keymap ,gnus-mime-button-map
5457 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5458 face ,gnus-article-button-face
5461 (widget-convert-button 'link from (point)
5462 :action 'gnus-widget-press-button
5463 :button-keymap gnus-widget-button-keymap)
5467 (if (stringp (car preferred))
5468 (gnus-display-mime preferred)
5469 (let ((mail-parse-charset gnus-newsgroup-charset)
5470 (mail-parse-ignored-charsets
5471 (with-current-buffer gnus-summary-buffer
5472 gnus-newsgroup-ignored-charsets)))
5473 (mm-display-part preferred)
5477 (narrow-to-region (car begend) (point-max))
5479 nil (length gnus-article-mime-handle-alist)
5480 (gnus-article-mime-total-parts)
5481 (mm-handle-media-type handle))))))
5482 (goto-char (point-max))
5483 (setcdr begend (point-marker)))))
5485 (goto-char point))))
5487 (defconst gnus-article-wash-status-strings
5488 (let ((alist '((cite "c" "Possible hidden citation text"
5489 " " "All citation text visible")
5490 (headers "h" "Hidden headers"
5491 " " "All headers visible.")
5492 (pgp "p" "Encrypted or signed message status hidden"
5493 " " "No hidden encryption nor digital signature status")
5494 (signature "s" "Signature has been hidden"
5495 " " "Signature is visible")
5496 (overstrike "o" "Overstrike (^H) characters applied"
5497 " " "No overstrike characters applied")
5498 (gnus-show-mime "m" "Mime processing is activated"
5499 " " "Mime processing is not activated")
5500 (emphasis "e" "/*_Emphasis_*/ characters applied"
5501 " " "No /*_emphasis_*/ characters applied")))
5503 (dolist (entry alist result)
5504 (let ((key (nth 0 entry))
5505 (on (copy-sequence (nth 1 entry)))
5506 (on-help (nth 2 entry))
5507 (off (copy-sequence (nth 3 entry)))
5508 (off-help (nth 4 entry)))
5509 (put-text-property 0 1 'help-echo on-help on)
5510 (put-text-property 0 1 'help-echo off-help off)
5511 (push (list key on off) result))))
5512 "Alist of strings describing wash status in the mode line.
5513 Each entry has the form (KEY ON OF), where the KEY is a symbol
5514 representing the particular washing function, ON is the string to use
5515 in the article mode line when the washing function is active, and OFF
5516 is the string to use when it is inactive.")
5518 (defun gnus-article-wash-status-entry (key value)
5519 (let ((entry (assoc key gnus-article-wash-status-strings)))
5520 (if value (nth 1 entry) (nth 2 entry))))
5522 (defun gnus-article-wash-status ()
5523 "Return a string which display status of article washing."
5524 (with-current-buffer gnus-article-buffer
5525 (let ((cite (memq 'cite gnus-article-wash-types))
5526 (headers (memq 'headers gnus-article-wash-types))
5527 (boring (memq 'boring-headers gnus-article-wash-types))
5528 (pgp (memq 'pgp gnus-article-wash-types))
5529 (pem (memq 'pem gnus-article-wash-types))
5530 (signed (memq 'signed gnus-article-wash-types))
5531 (encrypted (memq 'encrypted gnus-article-wash-types))
5532 (signature (memq 'signature gnus-article-wash-types))
5533 (overstrike (memq 'overstrike gnus-article-wash-types))
5534 (emphasis (memq 'emphasis gnus-article-wash-types)))
5536 (gnus-article-wash-status-entry 'cite cite)
5537 (gnus-article-wash-status-entry 'headers (or headers boring))
5538 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5539 (gnus-article-wash-status-entry 'signature signature)
5540 (gnus-article-wash-status-entry 'overstrike overstrike)
5541 (gnus-article-wash-status-entry 'gnus-show-mime gnus-show-mime)
5542 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5544 (defun gnus-add-wash-type (type)
5545 "Add a washing of TYPE to the current status."
5546 (add-to-list 'gnus-article-wash-types type))
5548 (defun gnus-delete-wash-type (type)
5549 "Add a washing of TYPE to the current status."
5550 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5552 (defun gnus-add-image (category image)
5553 "Add IMAGE of CATEGORY to the list of displayed images."
5554 (let ((entry (assq category gnus-article-image-alist)))
5556 (setq entry (list category))
5557 (push entry gnus-article-image-alist))
5558 (nconc entry (list image))))
5560 (defun gnus-delete-images (category)
5561 "Delete all images in CATEGORY."
5562 (let ((entry (assq category gnus-article-image-alist)))
5563 (dolist (image (cdr entry))
5564 (gnus-remove-image image category))
5565 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5566 (gnus-delete-wash-type category)))
5568 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5570 (defun gnus-article-maybe-hide-headers ()
5571 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5572 Provided for backwards compatibility."
5573 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5574 (not (with-current-buffer gnus-summary-buffer
5575 gnus-have-all-headers)))
5576 (not gnus-inhibit-hiding))
5577 (gnus-article-hide-headers)))
5581 (defun gnus-output-to-file (file-name)
5582 "Append the current article to a file named FILE-NAME."
5583 (let ((artbuf (current-buffer)))
5585 (insert-buffer-substring artbuf)
5586 ;; Append newline at end of the buffer as separator, and then
5588 (goto-char (point-max))
5590 (let ((file-name-coding-system nnmail-pathname-coding-system))
5591 (write-region-as-binary (point-min) (point-max) file-name 'append))
5594 (defun gnus-narrow-to-page (&optional arg)
5595 "Narrow the article buffer to a page.
5596 If given a numerical ARG, move forward ARG pages."
5598 (setq arg (if arg (prefix-numeric-value arg) 0))
5600 (set-buffer gnus-article-buffer)
5601 (goto-char (point-min))
5603 ;; Remove any old next/prev buttons.
5604 (when (gnus-visual-p 'page-marker)
5605 (let ((inhibit-read-only t))
5606 (gnus-remove-text-with-property 'gnus-prev)
5607 (gnus-remove-text-with-property 'gnus-next)))
5610 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5612 (re-search-forward page-delimiter nil 'move arg)))
5613 (goto-char (match-end 0))
5615 (goto-char (point-min))
5616 (setq gnus-page-broken
5617 (and (re-search-forward page-delimiter nil t) t))))
5618 (when gnus-page-broken
5621 (if (re-search-forward page-delimiter nil 'move)
5624 (when (and (gnus-visual-p 'page-marker)
5625 (> (point-min) (save-restriction (widen) (point-min))))
5627 (goto-char (point-min))
5628 (gnus-insert-prev-page-button)))
5629 (when (and (gnus-visual-p 'page-marker)
5630 (< (point-max) (save-restriction (widen) (point-max))))
5632 (goto-char (point-max))
5633 (gnus-insert-next-page-button))))))
5635 ;; Article mode commands
5637 (defun gnus-article-goto-next-page ()
5638 "Show the next page of the article."
5640 (when (gnus-article-next-page)
5641 (goto-char (point-min))
5642 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5645 (defun gnus-article-goto-prev-page ()
5646 "Show the previous page of the article."
5649 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5650 (gnus-article-prev-page nil)))
5652 ;; This is cleaner but currently breaks `gnus-pick-mode':
5654 ;; (defun gnus-article-goto-next-page ()
5655 ;; "Show the next page of the article."
5657 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5658 ;; (gnus-summary-next-page)))
5660 ;; (defun gnus-article-goto-prev-page ()
5661 ;; "Show the next page of the article."
5663 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5664 ;; (gnus-summary-prev-page)))
5666 (defun gnus-article-next-page (&optional lines)
5667 "Show the next page of the current article.
5668 If end of article, return non-nil. Otherwise return nil.
5669 Argument LINES specifies lines to be scrolled up."
5671 (move-to-window-line -1)
5674 (and (pos-visible-in-window-p) ;Not continuation line.
5675 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5676 ;; Nothing in this page.
5677 (if (or (not gnus-page-broken)
5682 (eobp)))) ;Real end-of-buffer?
5684 (when gnus-article-over-scroll
5685 (gnus-article-next-page-1 lines))
5687 (gnus-narrow-to-page 1) ;Go to next page.
5689 ;; More in this page.
5690 (gnus-article-next-page-1 lines)
5693 (defmacro gnus-article-beginning-of-window ()
5694 "Move point to the beginning of the window.
5695 In Emacs, the point is placed at the line number which `scroll-margin'
5697 (if (featurep 'xemacs)
5698 '(move-to-window-line 0)
5699 '(move-to-window-line
5700 (min (max 0 scroll-margin)
5701 (max 1 (- (window-height)
5702 (if mode-line-format 1 0)
5703 (if header-line-format 1 0)))))))
5705 (defun gnus-article-next-page-1 (lines)
5706 (when (and (not (featurep 'xemacs))
5709 (numberp (symbol-value 'scroll-margin))
5710 (> (symbol-value 'scroll-margin) 0))
5711 ;; Protect against the bug that Emacs 21.x hangs up when scrolling up for
5712 ;; too many number of lines if `scroll-margin' is set as two or greater.
5713 (setq lines (min lines
5714 (max 0 (- (count-lines (window-start) (point-max))
5715 (symbol-value 'scroll-margin))))))
5717 (let ((scroll-in-place nil))
5720 ;; Long lines may cause an end-of-buffer error.
5721 (goto-char (point-max))))
5722 (gnus-article-beginning-of-window))
5724 (defun gnus-article-prev-page (&optional lines)
5725 "Show previous page of current article.
5726 Argument LINES specifies lines to be scrolled down."
5728 (move-to-window-line 0)
5729 (if (and gnus-page-broken
5731 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5733 (gnus-narrow-to-page -1) ;Go to previous page.
5734 (goto-char (point-max))
5738 (let ((scroll-in-place nil))
5739 (scroll-down lines))
5740 (beginning-of-buffer
5741 (goto-char (point-min))))
5742 (gnus-article-beginning-of-window))))
5744 (defun gnus-article-only-boring-p ()
5745 "Decide whether there is only boring text remaining in the article.
5746 Something \"interesting\" is a word of at least two letters that does
5747 not have a face in `gnus-article-boring-faces'."
5748 (when (and gnus-article-skip-boring
5749 (boundp 'gnus-article-boring-faces)
5750 (symbol-value 'gnus-article-boring-faces))
5753 (while (re-search-forward "\\b\\w\\w" nil t)
5755 (when (not (gnus-intersection
5756 (gnus-faces-at (point))
5757 (symbol-value 'gnus-article-boring-faces)))
5758 (throw 'only-boring nil)))
5759 (throw 'only-boring t)))))
5761 (defun gnus-article-refer-article ()
5762 "Read article specified by message-id around point."
5765 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
5766 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
5767 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
5768 (let ((msg-id (concat "<" (match-string 0) ">")))
5769 (set-buffer gnus-summary-buffer)
5770 (gnus-summary-refer-article msg-id))
5771 (error "No references around point"))))
5773 (defun gnus-article-show-summary ()
5774 "Reconfigure windows to show summary buffer."
5776 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5777 (error "There is no summary buffer for this article buffer")
5778 (gnus-article-set-globals)
5779 (gnus-configure-windows 'article)
5780 (gnus-summary-goto-subject gnus-current-article)
5781 (gnus-summary-position-point)))
5783 (defun gnus-article-describe-briefly ()
5784 "Describe article mode commands briefly."
5786 (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")))
5788 (defun gnus-article-summary-command ()
5789 "Execute the last keystroke in the summary buffer."
5791 (let ((obuf (current-buffer))
5792 (owin (current-window-configuration))
5794 (switch-to-buffer gnus-article-current-summary 'norecord)
5795 (setq func (lookup-key (current-local-map) (this-command-keys)))
5796 (call-interactively func)
5798 (set-window-configuration owin)
5799 (set-window-point (get-buffer-window (current-buffer)) (point))))
5801 (defun gnus-article-summary-command-nosave ()
5802 "Execute the last keystroke in the summary buffer."
5805 (pop-to-buffer gnus-article-current-summary 'norecord)
5806 (setq func (lookup-key (current-local-map) (this-command-keys)))
5807 (call-interactively func)))
5809 (defun gnus-article-check-buffer ()
5810 "Beep if not in an article buffer."
5811 (unless (eq (get-buffer gnus-article-buffer) (current-buffer))
5812 (error "Command invoked outside of a Gnus article buffer")))
5814 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5815 "Read a summary buffer key sequence and execute it from the article buffer."
5817 (gnus-article-check-buffer)
5819 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5820 "Zc" "ZC" "ZE" "ZJ" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5821 "=" "^" "\M-^" "|"))
5827 '("n" "Gn" "p" "Gp"))
5830 (set-buffer gnus-article-current-summary)
5831 (let (gnus-pick-mode)
5832 (push (or key last-command-event) unread-command-events)
5833 (setq keys (static-if (featurep 'xemacs)
5834 (events-to-keys (read-key-sequence nil))
5835 (read-key-sequence nil)))))
5838 (if (or (member keys nosaves)
5839 (member keys nosave-but-article)
5840 (member keys nosave-in-article))
5842 (save-window-excursion
5843 (pop-to-buffer gnus-article-current-summary 'norecord)
5844 ;; We disable the pick minor mode commands.
5845 (let (gnus-pick-mode)
5846 (setq func (lookup-key (current-local-map) keys))))
5850 (unless (member keys nosave-in-article)
5851 (set-buffer gnus-article-current-summary))
5852 (call-interactively func)
5853 (setq new-sum-point (point)))
5854 (when (member keys nosave-but-article)
5855 (pop-to-buffer gnus-article-buffer 'norecord)))
5856 ;; These commands should restore window configuration.
5857 (let ((obuf (current-buffer))
5858 (owin (current-window-configuration))
5860 win func in-buffer selected new-sum-start new-sum-hscroll)
5861 (cond (not-restore-window
5862 (pop-to-buffer gnus-article-current-summary 'norecord))
5863 ((setq win (get-buffer-window gnus-article-current-summary))
5864 (select-window win))
5866 (switch-to-buffer gnus-article-current-summary 'norecord)))
5867 (setq in-buffer (current-buffer))
5868 ;; We disable the pick minor mode commands.
5869 (if (and (setq func (let (gnus-pick-mode)
5870 (lookup-key (current-local-map) keys)))
5873 (call-interactively func)
5874 (when (eq win (selected-window))
5875 (setq new-sum-point (point)
5876 new-sum-start (window-start win)
5877 new-sum-hscroll (window-hscroll win)))
5878 (when (eq in-buffer (current-buffer))
5879 (setq selected (gnus-summary-select-article))
5881 (unless not-restore-window
5882 (set-window-configuration owin))
5883 (when (eq selected 'old)
5885 (set-window-start (get-buffer-window (current-buffer))
5887 (set-window-point (get-buffer-window (current-buffer))
5889 (when (and (not not-restore-window)
5891 (set-window-point win new-sum-point)
5892 (set-window-start win new-sum-start)
5893 (set-window-hscroll win new-sum-hscroll))))
5894 (set-window-configuration owin)
5897 (defun gnus-article-describe-key (key)
5898 "Display documentation of the function invoked by KEY. KEY is a string."
5899 (interactive "kDescribe key: ")
5900 (gnus-article-check-buffer)
5901 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5903 (set-buffer gnus-article-current-summary)
5904 (let (gnus-pick-mode)
5905 (if (featurep 'xemacs)
5907 (push (elt key 0) unread-command-events)
5908 (setq key (events-to-keys
5909 (read-key-sequence "Describe key: "))))
5910 (setq unread-command-events
5912 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5914 (setq key (read-key-sequence "Describe key: "))))
5916 (describe-key key)))
5918 (defun gnus-article-describe-key-briefly (key &optional insert)
5919 "Display documentation of the function invoked by KEY. KEY is a string."
5920 (interactive "kDescribe key: \nP")
5921 (gnus-article-check-buffer)
5922 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5924 (set-buffer gnus-article-current-summary)
5925 (let (gnus-pick-mode)
5926 (if (featurep 'xemacs)
5928 (push (elt key 0) unread-command-events)
5929 (setq key (events-to-keys
5930 (read-key-sequence "Describe key: "))))
5931 (setq unread-command-events
5933 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5935 (setq key (read-key-sequence "Describe key: "))))
5936 (describe-key-briefly key insert))
5937 (describe-key-briefly key insert)))
5939 (defun gnus-article-reply-with-original (&optional wide)
5940 "Start composing a reply mail to the current message.
5941 The text in the region will be yanked. If the region isn't active,
5942 the entire article will be yanked."
5944 (let ((article (cdr gnus-article-current))
5946 (if (not (gnus-region-active-p))
5947 (with-current-buffer gnus-summary-buffer
5948 (gnus-summary-reply (list (list article)) wide))
5949 (setq contents (buffer-substring (point) (mark t)))
5950 ;; Deactivate active regions.
5951 (when (and (boundp 'transient-mark-mode)
5952 transient-mark-mode)
5953 (setq mark-active nil))
5954 (with-current-buffer gnus-summary-buffer
5956 (list (list article contents)) wide)))))
5958 (defun gnus-article-followup-with-original ()
5959 "Compose a followup to the current article.
5960 The text in the region will be yanked. If the region isn't active,
5961 the entire article will be yanked."
5963 (let ((article (cdr gnus-article-current))
5965 (if (not (gnus-region-active-p))
5966 (with-current-buffer gnus-summary-buffer
5967 (gnus-summary-followup (list (list article))))
5968 (setq contents (buffer-substring (point) (mark t)))
5969 ;; Deactivate active regions.
5970 (when (and (boundp 'transient-mark-mode)
5971 transient-mark-mode)
5972 (setq mark-active nil))
5973 (with-current-buffer gnus-summary-buffer
5974 (gnus-summary-followup
5975 (list (list article contents)))))))
5977 (defun gnus-article-hide (&optional arg force)
5978 "Hide all the gruft in the current article.
5979 This means that signatures, cited text and (some) headers will be
5981 If given a prefix, show the hidden text instead."
5982 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5983 (gnus-article-hide-headers arg)
5984 (gnus-article-hide-list-identifiers arg)
5985 (gnus-article-hide-citation-maybe arg force)
5986 (gnus-article-hide-signature arg))
5988 (defun gnus-article-maybe-highlight ()
5989 "Do some article highlighting if article highlighting is requested."
5990 (when (gnus-visual-p 'article-highlight 'highlight)
5991 (gnus-article-highlight-some)))
5993 (defun gnus-check-group-server ()
5994 ;; Make sure the connection to the server is alive.
5995 (unless (gnus-server-opened
5996 (gnus-find-method-for-group gnus-newsgroup-name))
5997 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5998 (gnus-request-group gnus-newsgroup-name t)))
6001 (autoload 'nneething-get-file-name "nneething"))
6003 (defun gnus-request-article-this-buffer (article group)
6004 "Get an article and insert it into this buffer."
6005 (let (do-update-line sparse-header)
6009 (gnus-kill-all-overlays)
6010 (setq group (or group gnus-newsgroup-name))
6012 ;; Using `gnus-request-article' directly will insert the article into
6013 ;; `nntp-server-buffer' - so we'll save some time by not having to
6014 ;; copy it from the server buffer into the article buffer.
6016 ;; We only request an article by message-id when we do not have the
6017 ;; headers for it, so we'll have to get those.
6018 (when (stringp article)
6019 (gnus-read-header article))
6021 ;; If the article number is negative, that means that this article
6022 ;; doesn't belong in this newsgroup (possibly), so we find its
6023 ;; message-id and request it by id instead of number.
6024 (when (and (numberp article)
6026 (get-buffer gnus-summary-buffer)
6027 (gnus-buffer-exists-p gnus-summary-buffer))
6029 (set-buffer gnus-summary-buffer)
6030 (let ((header (gnus-summary-article-header article)))
6033 ((memq article gnus-newsgroup-sparse)
6034 ;; This is a sparse gap article.
6035 (setq do-update-line article)
6036 (setq article (mail-header-id header))
6037 (setq sparse-header (gnus-read-header article))
6038 (setq gnus-newsgroup-sparse
6039 (delq article gnus-newsgroup-sparse)))
6041 ;; It's a real article.
6042 (setq article (mail-header-id header)))
6044 ;; It is an extracted pseudo-article.
6045 (setq article 'pseudo)
6046 (gnus-request-pseudo-article header))))
6048 (let ((method (gnus-find-method-for-group
6049 gnus-newsgroup-name)))
6050 (when (and (eq (car method) 'nneething)
6052 (let ((dir (nneething-get-file-name
6053 (mail-header-id header))))
6054 (when (and (stringp dir)
6055 (file-directory-p dir))
6056 (setq article 'nneething)
6057 (gnus-group-enter-directory dir))))))))
6060 ;; Refuse to select canceled articles.
6061 ((and (numberp article)
6063 (get-buffer gnus-summary-buffer)
6064 (gnus-buffer-exists-p gnus-summary-buffer)
6065 (eq (cdr (with-current-buffer gnus-summary-buffer
6066 (assq article gnus-newsgroup-reads)))
6067 gnus-canceled-mark))
6069 ;; We first check `gnus-original-article-buffer'.
6070 ((and (get-buffer gnus-original-article-buffer)
6072 (with-current-buffer gnus-original-article-buffer
6073 (and (equal (car gnus-original-article) group)
6074 (eq (cdr gnus-original-article) article))))
6075 (insert-buffer-substring gnus-original-article-buffer)
6077 ;; Check the backlog.
6078 ((and gnus-keep-backlog
6079 (gnus-backlog-request-article group article (current-buffer)))
6081 ;; Check asynchronous pre-fetch.
6082 ((gnus-async-request-fetched-article group article (current-buffer))
6083 (gnus-async-prefetch-next group article gnus-summary-buffer)
6084 (when (and (numberp article) gnus-keep-backlog)
6085 (gnus-backlog-enter-article group article (current-buffer)))
6088 ((and gnus-use-cache
6090 (gnus-cache-request-article article group))
6092 ;; Check the agent cache.
6093 ((gnus-agent-request-article article group)
6095 ;; Get the article and put into the article buffer.
6096 ((or (stringp article)
6098 (let ((gnus-override-method gnus-override-method)
6099 (methods (and (stringp article)
6100 gnus-refer-article-method))
6101 (backend (car (gnus-find-method-for-group
6102 gnus-newsgroup-name)))
6104 (inhibit-read-only t))
6105 (if (or (not (listp methods))
6106 (and (symbolp (car methods))
6107 (assq (car methods) nnoo-definition-alist)))
6108 (setq methods (list methods)))
6109 (when (and (null gnus-override-method)
6111 (setq gnus-override-method (pop methods)))
6113 (when (eq gnus-override-method 'current)
6114 (setq gnus-override-method
6115 (with-current-buffer gnus-summary-buffer
6116 gnus-current-select-method)))
6118 (gnus-kill-all-overlays)
6119 (let ((gnus-newsgroup-name group))
6120 (gnus-check-group-server))
6122 ((gnus-request-article article group (current-buffer))
6123 (when (numberp article)
6124 (gnus-async-prefetch-next group article
6125 gnus-summary-buffer)
6126 (when gnus-keep-backlog
6127 (gnus-backlog-enter-article
6128 group article (current-buffer))))
6129 (setq result 'article))
6131 (setq gnus-override-method (pop methods)))
6132 ((not (string-match "^400 "
6133 (nnheader-get-report backend)))
6134 ;; If we get 400 server disconnect, reconnect and
6135 ;; retry; otherwise, assume the article has expired.
6136 (setq result 'done))))
6137 (and (eq result 'article) 'article)))
6141 ;; Associate this article with the current summary buffer.
6142 (setq gnus-article-current-summary gnus-summary-buffer)
6144 ;; Take the article from the original article buffer
6145 ;; and place it in the buffer it's supposed to be in.
6146 (when (and (get-buffer gnus-article-buffer)
6147 (equal (buffer-name (current-buffer))
6148 (buffer-name (get-buffer gnus-article-buffer))))
6150 (if (get-buffer gnus-original-article-buffer)
6151 (set-buffer gnus-original-article-buffer)
6152 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
6153 (buffer-disable-undo)
6154 (setq major-mode 'gnus-original-article-mode)
6155 (setq buffer-read-only t))
6156 (let ((inhibit-read-only t))
6158 (insert-buffer-substring gnus-article-buffer))
6159 (setq gnus-original-article (cons group article)))
6162 (run-hooks 'gnus-article-decode-hook)
6163 ;; Mark article as decoded or not.
6164 (setq gnus-article-decoded-p gnus-article-decode-hook))
6166 ;; Update sparse articles.
6167 (when (and do-update-line
6168 (or (numberp article)
6170 (let ((buf (current-buffer)))
6171 (set-buffer gnus-summary-buffer)
6172 (gnus-summary-update-article do-update-line sparse-header)
6173 (gnus-summary-goto-subject do-update-line nil t)
6174 (set-window-point (gnus-get-buffer-window (current-buffer) t)
6176 (set-buffer buf))))))
6182 (defcustom gnus-article-edit-mode-hook nil
6183 "Hook run in article edit mode buffers."
6184 :group 'gnus-article-various
6187 (defcustom gnus-article-edit-article-setup-function
6188 'gnus-article-mime-edit-article-setup
6189 "Function called to setup an editing article buffer."
6190 :group 'gnus-article-various
6193 (defvar gnus-article-edit-done-function nil)
6195 (defvar gnus-article-edit-mode-map nil)
6197 ;; Should we be using derived.el for this?
6198 (unless gnus-article-edit-mode-map
6199 (setq gnus-article-edit-mode-map (make-keymap))
6200 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
6202 (gnus-define-keys gnus-article-edit-mode-map
6203 "\C-c?" describe-mode
6204 "\C-c\C-c" gnus-article-edit-done
6205 "\C-c\C-k" gnus-article-edit-exit
6206 "\C-c\C-f\C-t" message-goto-to
6207 "\C-c\C-f\C-o" message-goto-from
6208 "\C-c\C-f\C-b" message-goto-bcc
6209 ;;"\C-c\C-f\C-w" message-goto-fcc
6210 "\C-c\C-f\C-c" message-goto-cc
6211 "\C-c\C-f\C-s" message-goto-subject
6212 "\C-c\C-f\C-r" message-goto-reply-to
6213 "\C-c\C-f\C-n" message-goto-newsgroups
6214 "\C-c\C-f\C-d" message-goto-distribution
6215 "\C-c\C-f\C-f" message-goto-followup-to
6216 "\C-c\C-f\C-m" message-goto-mail-followup-to
6217 "\C-c\C-f\C-k" message-goto-keywords
6218 "\C-c\C-f\C-u" message-goto-summary
6219 "\C-c\C-f\C-i" message-insert-or-toggle-importance
6220 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
6221 "\C-c\C-b" message-goto-body
6222 "\C-c\C-i" message-goto-signature
6224 "\C-c\C-t" message-insert-to
6225 "\C-c\C-n" message-insert-newsgroups
6226 "\C-c\C-o" message-sort-headers
6227 "\C-c\C-e" message-elide-region
6228 "\C-c\C-v" message-delete-not-region
6229 "\C-c\C-z" message-kill-to-signature
6230 "\M-\r" message-newline-and-reformat
6231 "\C-c\C-a" mml-attach-file
6232 "\C-a" message-beginning-of-line
6234 "\M-;" comment-region)
6236 (gnus-define-keys (gnus-article-edit-wash-map
6237 "\C-c\C-w" gnus-article-edit-mode-map)
6238 "f" gnus-article-edit-full-stops))
6241 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
6243 ["Fetch To" message-insert-to t]
6244 ["Fetch Newsgroups" message-insert-newsgroups t]
6246 ["To" message-goto-to t]
6247 ["From" message-goto-from t]
6248 ["Subject" message-goto-subject t]
6249 ["Cc" message-goto-cc t]
6250 ["Reply-To" message-goto-reply-to t]
6251 ["Summary" message-goto-summary t]
6252 ["Keywords" message-goto-keywords t]
6253 ["Newsgroups" message-goto-newsgroups t]
6254 ["Followup-To" message-goto-followup-to t]
6255 ["Mail-Followup-To" message-goto-mail-followup-to t]
6256 ["Distribution" message-goto-distribution t]
6257 ["Body" message-goto-body t]
6258 ["Signature" message-goto-signature t]))
6260 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
6261 "Major mode for editing articles.
6262 This is an extended text-mode.
6264 \\{gnus-article-edit-mode-map}"
6265 (make-local-variable 'gnus-article-edit-done-function)
6266 (make-local-variable 'gnus-prev-winconf)
6267 (set (make-local-variable 'font-lock-defaults)
6268 '(message-font-lock-keywords t))
6269 (set (make-local-variable 'mail-header-separator) "")
6270 (set (make-local-variable 'gnus-article-edit-mode) t)
6271 (easy-menu-add message-mode-field-menu message-mode-map)
6272 (setq buffer-read-only nil)
6273 (buffer-enable-undo)
6276 (defun gnus-article-edit (&optional force)
6277 "Edit the current article.
6278 This will have permanent effect only in mail groups.
6279 If FORCE is non-nil, allow editing of articles even in read-only
6282 (when (and (not force)
6283 (gnus-group-read-only-p))
6284 (error "The current newsgroup does not support article editing"))
6285 (gnus-article-date-original)
6286 (gnus-article-edit-article
6288 `(lambda (no-highlight)
6290 (gnus-summary-edit-article-done
6291 ,(or (mail-header-references gnus-current-headers) "")
6292 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
6294 (defun gnus-article-edit-article (start-func exit-func &optional quiet)
6295 "Start editing the contents of the current article buffer."
6296 (let ((winconf (current-window-configuration)))
6297 (set-buffer gnus-article-buffer)
6298 (let ((message-auto-save-directory
6299 ;; Don't associate the article buffer with a draft file.
6301 (gnus-article-edit-mode))
6302 (funcall start-func)
6303 (set-buffer-modified-p nil)
6304 (gnus-configure-windows 'edit-article)
6305 (setq gnus-article-edit-done-function exit-func)
6306 (setq gnus-prev-winconf winconf)
6307 (when gnus-article-edit-article-setup-function
6308 (funcall gnus-article-edit-article-setup-function))
6310 (gnus-message 6 "C-c C-c to end edits; C-c C-k to exit"))))
6312 (defun gnus-article-edit-done (&optional arg)
6313 "Update the article edits and exit."
6315 (let ((func gnus-article-edit-done-function)
6316 (buf (current-buffer))
6317 (start (window-start))
6319 (winconf gnus-prev-winconf))
6320 (remove-hook 'gnus-article-mode-hook
6321 'gnus-article-mime-edit-article-unwind)
6322 (widen) ;; Widen it in case that users narrowed the buffer.
6325 ;; The cache and backlog have to be flushed somewhat.
6326 (when gnus-keep-backlog
6327 (gnus-backlog-remove-article
6328 (car gnus-article-current) (cdr gnus-article-current)))
6329 ;; Flush original article as well.
6331 (when (get-buffer gnus-original-article-buffer)
6332 (set-buffer gnus-original-article-buffer)
6333 (setq gnus-original-article nil)))
6334 (when gnus-use-cache
6335 (gnus-cache-update-article
6336 (car gnus-article-current) (cdr gnus-article-current)))
6337 ;; We remove all text props from the article buffer.
6338 (kill-all-local-variables)
6339 (set-text-properties (point-min) (point-max) nil)
6341 (set-window-configuration winconf)
6343 (set-window-start (get-buffer-window buf) start)
6344 (set-window-point (get-buffer-window buf) (point)))
6345 (gnus-summary-show-article))
6347 (defun gnus-article-edit-exit ()
6348 "Exit the article editing without updating."
6350 (when (or (not (buffer-modified-p))
6351 (yes-or-no-p "Article modified; kill anyway? "))
6352 (let ((curbuf (current-buffer))
6354 (window-start (window-start)))
6356 (if (gnus-buffer-live-p gnus-original-article-buffer)
6357 (insert-buffer-substring gnus-original-article-buffer))
6358 (let ((winconf gnus-prev-winconf))
6359 (kill-all-local-variables)
6361 (set-window-configuration winconf)
6362 ;; Tippy-toe some to make sure that point remains where it was.
6363 (save-current-buffer
6365 (set-window-start (get-buffer-window (current-buffer)) window-start)
6367 (gnus-summary-show-article)))
6369 (defun gnus-article-edit-full-stops ()
6370 "Interactively repair spacing at end of sentences."
6373 (goto-char (point-min))
6374 (search-forward-regexp "^$" nil t)
6375 (let ((case-fold-search nil))
6376 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
6379 ;;; Article editing with MIME-Edit
6382 (defcustom gnus-article-mime-edit-article-setup-hook nil
6383 "Hook run after setting up a MIME editing article buffer."
6384 :group 'gnus-article-various
6387 (defun gnus-article-mime-edit-article-unwind ()
6388 "Unwind `gnus-article-buffer' if article editing was given up."
6389 (remove-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6390 (when (featurep 'font-lock)
6391 (setq font-lock-defaults nil)
6392 (font-lock-mode -1))
6393 (when mime-edit-mode-flag
6394 (mime-edit-exit 'nomime 'no-error)
6397 (defun gnus-article-mime-edit-article-setup ()
6398 "Convert current buffer to MIME-Edit buffer and turn on MIME-Edit mode
6399 after replacing with the original article."
6400 (setq gnus-show-mime t)
6401 (setq gnus-article-edit-done-function
6402 `(lambda (&rest args)
6403 (when mime-edit-mode-flag
6404 (let (mime-edit-insert-user-agent-field)
6407 (goto-char (point-min))
6408 (let (case-fold-search)
6409 (when (re-search-forward
6410 (format "^%s$" (regexp-quote mail-header-separator))
6412 (replace-match "")))
6413 (apply ,gnus-article-edit-done-function args)
6416 (buffer-substring-no-properties (point-min) (point-max))
6417 (set-buffer (get-buffer-create gnus-original-article-buffer))
6419 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6420 (set-buffer gnus-article-buffer)
6421 (gnus-article-prepare-display)))
6422 (substitute-key-definition 'gnus-article-edit-done
6423 'gnus-article-mime-edit-done
6424 gnus-article-edit-mode-map)
6425 (substitute-key-definition 'gnus-article-edit-exit
6426 'gnus-article-mime-edit-exit
6427 gnus-article-edit-mode-map)
6429 (insert-buffer-substring gnus-original-article-buffer)
6430 (unless (member (with-current-buffer gnus-summary-buffer
6431 gnus-newsgroup-name)
6432 '("nndraft:delayed" "nndraft:drafts"))
6433 (let ((ofn (symbol-function 'mime-edit-decode-single-part-in-buffer)))
6434 (fset 'mime-edit-decode-single-part-in-buffer
6435 (lambda (&rest args)
6436 (if (let ((content-type (car args)))
6437 (and (eq 'message (mime-content-type-primary-type
6439 (eq 'rfc822 (mime-content-type-subtype
6441 (setcar (cdr args) 'not-decode-text))
6445 (fset 'mime-edit-decode-single-part-in-buffer ofn))))
6446 (when (featurep 'font-lock)
6447 (set (make-local-variable 'font-lock-defaults)
6448 '(message-font-lock-keywords t))
6449 (font-lock-set-defaults)
6450 (turn-on-font-lock))
6451 (set-buffer-modified-p nil)
6452 (delete-other-windows)
6453 (add-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6454 (gnus-run-hooks 'gnus-article-mime-edit-article-setup-hook))
6456 (defun gnus-article-mime-edit-done (&optional arg)
6457 "Update the article MIME edits and exit."
6459 (when (featurep 'font-lock)
6460 (setq font-lock-defaults nil)
6461 (font-lock-mode -1))
6462 (let ((inhibit-read-only t))
6463 (gnus-article-edit-done arg)))
6465 (defun gnus-article-mime-edit-exit ()
6466 "Exit the article MIME editing without updating."
6468 (when (or (not (buffer-modified-p))
6469 (yes-or-no-p "Article modified; kill anyway? "))
6470 (when (featurep 'font-lock)
6471 (setq font-lock-defaults nil)
6472 (font-lock-mode -1))
6473 (when mime-edit-mode-flag
6474 (let (mime-edit-insert-user-agent-field)
6477 (goto-char (point-min))
6478 (let (case-fold-search)
6479 (when (re-search-forward
6480 (format "^%s$" (regexp-quote mail-header-separator)) nil t)
6481 (replace-match "")))
6482 (let ((winconf gnus-prev-winconf))
6484 (buffer-substring-no-properties (point-min) (point-max))
6485 (set-buffer (get-buffer-create gnus-original-article-buffer))
6487 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6488 (set-buffer gnus-article-buffer)
6489 (gnus-article-prepare-display)
6490 (set-window-configuration winconf))))
6493 ;;; Article highlights
6496 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
6498 ;;; Internal Variables:
6500 (defcustom gnus-button-url-regexp
6501 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
6502 "\\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:]]\\)"
6503 "\\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\\)\\)")
6504 "Regular expression that matches URLs."
6505 :group 'gnus-article-buttons
6508 (defcustom gnus-button-valid-fqdn-regexp
6509 message-valid-fqdn-regexp
6510 "Regular expression that matches a valid FQDN."
6512 :group 'gnus-article-buttons
6515 ;; Regexp suggested by Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
6516 (defcustom gnus-button-valid-localpart-regexp
6517 "[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t ]*"
6518 "Regular expression that matches a localpart of mail addresses or MIDs."
6520 :group 'gnus-article-buttons
6523 (defcustom gnus-button-man-handler 'manual-entry
6524 "Function to use for displaying man pages.
6525 The function must take at least one argument with a string naming the
6528 :type '(choice (function-item :tag "Man" manual-entry)
6529 (function-item :tag "Woman" woman)
6530 (function :tag "Other"))
6531 :group 'gnus-article-buttons)
6533 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
6534 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
6535 If the default site is too slow, try to find a CTAN mirror, see
6536 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
6537 the variable `gnus-button-handle-ctan'."
6539 :group 'gnus-article-buttons
6540 :link '(custom-manual "(gnus)Group Parameters")
6541 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
6542 (const "http://tug.ctan.org/tex-archive/")
6543 (const "http://www.dante.de/CTAN/")
6544 (string :tag "Other")))
6546 (defcustom gnus-button-ctan-handler 'browse-url
6547 "Function to use for displaying CTAN links.
6548 The function must take one argument, the string naming the URL."
6550 :type '(choice (function-item :tag "Browse Url" browse-url)
6551 (function :tag "Other"))
6552 :group 'gnus-article-buttons)
6554 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
6555 "Bogus strings removed from CTAN URLs."
6557 :group 'gnus-article-buttons
6558 :type '(choice (const "^/?tex-archive/\\|/")
6559 (regexp :tag "Other")))
6561 (defcustom gnus-button-ctan-directory-regexp
6563 (list "archive-tools" "biblio" "bibliography" "digests" "documentation"
6564 "dviware" "fonts" "graphics" "help" "indexing" "info" "language"
6565 "languages" "macros" "nonfree" "obsolete" "support" "systems"
6566 "tds" "tools" "usergrps" "web") t)
6567 "Regular expression for ctan directories.
6568 It should match all directories in the top level of `gnus-ctan-url'."
6570 :group 'gnus-article-buttons
6573 (defcustom gnus-button-mid-or-mail-regexp
6574 (concat "\\b\\(<?" gnus-button-valid-localpart-regexp "@"
6575 gnus-button-valid-fqdn-regexp
6577 "Regular expression that matches a message ID or a mail address."
6579 :group 'gnus-article-buttons
6582 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
6583 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
6584 Strings like this can be either a message ID or a mail address. If it is one
6585 of the symbols `mid' or `mail', Gnus will always assume that the string is a
6586 message ID or a mail address, respectively. If this variable is set to the
6587 symbol `ask', always query the user what do do. If it is a function, this
6588 function will be called with the string as it's only argument. The function
6589 must return `mid', `mail', `invalid' or `ask'."
6591 :group 'gnus-article-buttons
6592 :type '(choice (function-item :tag "Heuristic function"
6593 gnus-button-mid-or-mail-heuristic)
6598 (defcustom gnus-button-mid-or-mail-heuristic-alist
6599 '((-10.0 . ".+\\$.+@")
6602 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
6603 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
6604 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
6605 (-1.0 . "^[^a-z]+@")
6607 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
6608 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
6609 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
6610 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
6613 (-1.0 . "^[0-9][0-9]")
6615 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
6616 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6617 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
6618 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6620 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
6621 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
6624 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
6626 ;; compensation for TDMA dated mail addresses:
6627 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
6629 (-20.0 . "\\.fsf@") ;; Gnus
6632 (-20.0 . "_-_") ;; Subject change in thread
6634 (-20.0 . "\\.ln@") ;; leafnode
6635 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
6636 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
6638 ;; (5.0 . "") ;; $local_part_len <= 7
6639 (10.0 . "^[^0-9]+@")
6640 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
6641 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
6644 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
6646 (0.5 . "^[A-Z][a-z]")
6647 (0.5 . "^[A-Z][a-z][a-z]")
6648 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
6649 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
6650 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
6652 A negative RATE indicates a message IDs, whereas a positive indicates a mail
6653 address. The REGEXP is processed with `case-fold-search' set to nil."
6655 :group 'gnus-article-buttons
6656 :type '(repeat (cons (number :tag "Rate")
6657 (regexp :tag "Regexp"))))
6659 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
6660 "Guess whether MID-OR-MAIL is a message ID or a mail address.
6661 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
6662 address, `ask' if unsure and `invalid' if the string is invalid."
6663 (let ((case-fold-search nil)
6664 (list gnus-button-mid-or-mail-heuristic-alist)
6665 (result 0) rate regexp lpartlen elem)
6667 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
6668 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
6669 ;; Certain special cases...
6672 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
6673 "^[0-9]+\\.[0-9]+@compuserve\\|"
6674 "@public\\.gmane\\.org")
6676 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
6677 (setq result 'mail))
6678 (when (string-match "@.*@\\| " mid-or-mail)
6679 (gnus-message 8 "`%s' is invalid." mid-or-mail)
6680 (setq result 'invalid))
6681 ;; Nothing more to do, if result is not a number here...
6682 (when (numberp result)
6684 (setq elem (car list)
6688 (when (string-match regexp mid-or-mail)
6689 (setq result (+ result rate))
6691 9 "`%s' matched `%s', rate `%s', result `%s'."
6692 mid-or-mail regexp rate result)))
6693 (when (<= lpartlen 7)
6694 (setq result (+ result 5.0))
6695 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
6696 mid-or-mail result))
6697 (when (>= lpartlen 12)
6698 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
6700 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
6701 ;; Long local part should contain realname if e-mail address,
6702 ;; too many digits: message-id.
6703 ;; $score -= 5.0 + 0.1 * $local_part_len;
6704 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6705 (setq result (+ result rate))
6707 9 "Many digits in `%s', rate `%s', result `%s'."
6708 mid-or-mail rate result))
6709 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6711 ;; Too few vowels [^aeiouy]{4,}.*\@
6712 (setq result (+ result -5.0))
6714 9 "Few vowels in `%s', rate `%s', result `%s'."
6715 mid-or-mail -5.0 result))
6717 (setq result (+ result 5.0))
6719 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6720 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6721 ;; Maybe we should make this a customizable alist: (condition . 'result)
6723 ((symbolp result) result)
6724 ;; Now convert number into proper results:
6725 ((< result -10.0) 'mid)
6726 ((> result 10.0) 'mail)
6729 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6730 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6731 (url-mid (concat "news" ":" mid-or-mail))
6732 (url-mailto (concat "mailto" ":" mid-or-mail)))
6733 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6734 (when (fboundp pref)
6736 ;; get rid of surrounding angles...
6738 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6739 (if (or (eq 'mid guessed) (eq 'mail guessed))
6743 (save-window-excursion
6744 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6747 (cond ((eq pref 'mid)
6748 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6749 (gnus-button-handle-news url-mid))
6751 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6752 (gnus-url-mailto url-mailto))
6753 (t (gnus-message 3 "Invalid string.")))))
6755 (defun gnus-button-handle-custom (url)
6756 "Follow a Custom URL."
6757 (customize-apropos (gnus-url-unhex-string url)))
6759 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6761 ;; FIXME: Maybe we should merge some of the functions that do quite similar
6764 (defun gnus-button-handle-describe-function (url)
6765 "Call `describe-function' when pushing the corresponding URL button."
6768 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6770 (defun gnus-button-handle-describe-variable (url)
6771 "Call `describe-variable' when pushing the corresponding URL button."
6774 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6776 (defun gnus-button-handle-symbol (url)
6777 "Display help on variable or function.
6778 Calls `describe-variable' or `describe-function'."
6779 (let ((sym (intern url)))
6781 ((fboundp sym) (describe-function sym))
6782 ((boundp sym) (describe-variable sym))
6783 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
6785 (defun gnus-button-handle-describe-key (url)
6786 "Call `describe-key' when pushing the corresponding URL button."
6788 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6789 (keys (ignore-errors (eval `(kbd ,key-string)))))
6792 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6794 (defun gnus-button-handle-apropos (url)
6795 "Call `apropos' when pushing the corresponding URL button."
6796 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6798 (defun gnus-button-handle-apropos-command (url)
6799 "Call `apropos' when pushing the corresponding URL button."
6801 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6803 (defun gnus-button-handle-apropos-variable (url)
6804 "Call `apropos' when pushing the corresponding URL button."
6806 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6807 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6809 (defun gnus-button-handle-apropos-documentation (url)
6810 "Call `apropos' when pushing the corresponding URL button."
6812 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6813 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6815 (defun gnus-button-handle-library (url)
6816 "Call `locate-library' when pushing the corresponding URL button."
6817 (gnus-message 9 "url=`%s'" url)
6818 (let* ((lib (locate-library url))
6819 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6821 (gnus-message 1 "Cannot locale library `%s'." url)
6822 (find-file-read-only file))))
6824 (defun gnus-button-handle-ctan (url)
6825 "Call `browse-url' when pushing a CTAN URL button."
6827 gnus-button-ctan-handler
6830 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6832 (defcustom gnus-button-tex-level 5
6833 "*Integer that says how many TeX-related buttons Gnus will show.
6834 The higher the number, the more buttons will appear and the more false
6835 positives are possible. Note that you can set this variable local to
6836 specific groups. Setting it higher in TeX groups is probably a good idea.
6837 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6838 how to set variables in specific groups."
6840 :group 'gnus-article-buttons
6841 :link '(custom-manual "(gnus)Group Parameters")
6844 (defcustom gnus-button-man-level 5
6845 "*Integer that says how many man-related buttons Gnus will show.
6846 The higher the number, the more buttons will appear and the more false
6847 positives are possible. Note that you can set this variable local to
6848 specific groups. Setting it higher in Unix groups is probably a good idea.
6849 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6850 how to set variables in specific groups."
6852 :group 'gnus-article-buttons
6853 :link '(custom-manual "(gnus)Group Parameters")
6856 (defcustom gnus-button-emacs-level 5
6857 "*Integer that says how many emacs-related buttons Gnus will show.
6858 The higher the number, the more buttons will appear and the more false
6859 positives are possible. Note that you can set this variable local to
6860 specific groups. Setting it higher in Emacs or Gnus related groups is
6861 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6862 `gnus-parameters' on how to set variables in specific groups."
6864 :group 'gnus-article-buttons
6865 :link '(custom-manual "(gnus)Group Parameters")
6868 (defcustom gnus-button-message-level 5
6869 "*Integer that says how many buttons for news or mail messages will appear.
6870 The higher the number, the more buttons will appear and the more false
6871 positives are possible."
6872 ;; mail addresses, MIDs, URLs for news, ...
6874 :group 'gnus-article-buttons
6877 (defcustom gnus-button-browse-level 5
6878 "*Integer that says how many buttons for browsing will appear.
6879 The higher the number, the more buttons will appear and the more false
6880 positives are possible."
6881 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6883 :group 'gnus-article-buttons
6886 (defcustom gnus-button-alist
6887 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6888 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6889 ((concat "\\b\\(nntp\\|news\\):\\("
6890 gnus-button-valid-localpart-regexp "@[a-z0-9.-]+[a-z]\\)")
6891 0 t gnus-button-handle-news 2)
6892 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6893 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6894 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6895 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6896 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
6897 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
6898 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
6899 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6900 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6901 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6902 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6903 ;; RFC 2368 (The mailto URL scheme)
6904 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6905 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6906 ("\\bmailto:\\([^ \n\t]+\\)"
6907 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6909 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6910 gnus-button-ctan-directory-regexp
6911 "[^][>)!;:,'\n\t ]+\\)")
6912 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6913 ((concat "\\btex-archive/\\("
6914 gnus-button-ctan-directory-regexp
6915 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6916 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6919 gnus-button-ctan-directory-regexp
6920 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6921 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6922 ;; This is info (home-grown style) <info://foo/bar+baz>
6923 ("\\binfo://\\([^'\">\n\t ]+\\)"
6924 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6925 ;; Info GNOME style <info:foo#bar_baz>
6926 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6927 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6928 ;; Info KDE style <info:(foo)bar baz>
6929 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6930 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6931 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6932 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6933 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6934 ;; Info links like `C-h i d m CC Mode RET'
6935 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6937 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6938 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6939 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6940 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6941 ;; Emacs help commands
6942 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6943 ;; regexp doesn't match arguments containing ` '.
6944 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6945 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6946 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6947 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6948 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6949 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6950 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6951 ;; The following entries may lead to many false positives so don't enable
6952 ;; them by default (use a high button level).
6953 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
6954 ;; Exclude [.?] for URLs in gmane.emacs.cvs
6955 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6956 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6957 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6958 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6959 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6960 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6961 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6962 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6963 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6964 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6965 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
6966 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6967 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6968 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6969 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6970 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6971 ;; Unlike the other regexps we really have to require quoting
6972 ;; here to determine where it ends.
6973 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6974 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
6975 ("<URL: *\\([^<>]*\\)>"
6976 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6977 ;; RFC 2396 (2.4.3., delims) ...
6978 ("\"URL: *\\([^\"]*\\)\""
6979 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6980 ;; RFC 2396 (2.4.3., delims) ...
6981 ("\"URL: *\\([^\"]*\\)\""
6982 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6984 (gnus-button-url-regexp
6985 0 (>= gnus-button-browse-level 0) browse-url 0)
6987 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
6988 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6989 gnus-button-handle-man 1)
6990 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6991 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
6992 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6993 gnus-button-handle-man 1)
6994 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6995 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6996 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
6997 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6998 ;; MID or mail: To avoid too many false positives we don't try to catch
6999 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
7000 ;; at least one dot. TLD must contain two or three chars or be a know TLD
7001 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
7002 ;; so that non-ambiguous entries (see above) match first.
7003 (gnus-button-mid-or-mail-regexp
7004 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
7005 "*Alist of regexps matching buttons in article bodies.
7007 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
7008 REGEXP: is the string (case insensitive) matching text around the button (can
7009 also be Lisp expression evaluating to a string),
7010 BUTTON: is the number of the regexp grouping actually matching the button,
7011 FORM: is a Lisp expression which must eval to true for the button to
7013 CALLBACK: is the function to call when the user push this button, and each
7014 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
7016 CALLBACK can also be a variable, in that case the value of that
7017 variable it the real callback function."
7018 :group 'gnus-article-buttons
7019 :type '(repeat (list (choice regexp variable sexp)
7020 (integer :tag "Button")
7022 (function :tag "Callback")
7025 (integer :tag "Regexp group")))))
7027 (defcustom gnus-header-button-alist
7028 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
7029 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
7030 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
7031 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
7032 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
7033 0 (>= gnus-button-message-level 0) gnus-msg-mail 0)
7034 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
7035 0 (>= gnus-button-browse-level 0) browse-url 0)
7036 ("^Subject:" gnus-button-url-regexp
7037 0 (>= gnus-button-browse-level 0) browse-url 0)
7038 ("^[^:]+:" gnus-button-url-regexp
7039 0 (>= gnus-button-browse-level 0) browse-url 0)
7040 ("^OpenPGP:.*url=" gnus-button-url-regexp
7041 0 (>= gnus-button-browse-level 0) gnus-button-openpgp 0)
7042 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
7043 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
7044 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
7045 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
7046 "*Alist of headers and regexps to match buttons in article heads.
7048 This alist is very similar to `gnus-button-alist', except that each
7049 alist has an additional HEADER element first in each entry:
7051 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
7053 HEADER is a regexp to match a header. For a fuller explanation, see
7054 `gnus-button-alist'."
7055 :group 'gnus-article-buttons
7056 :group 'gnus-article-headers
7057 :type '(repeat (list (regexp :tag "Header")
7058 (choice regexp variable)
7059 (integer :tag "Button")
7061 (function :tag "Callback")
7064 (integer :tag "Regexp group")))))
7068 (defun gnus-article-push-button (event)
7069 "Check text under the mouse pointer for a callback function.
7070 If the text under the mouse pointer has a `gnus-callback' property,
7071 call it with the value of the `gnus-data' text property."
7073 (set-buffer (window-buffer (posn-window (event-start event))))
7074 (let* ((pos (posn-point (event-start event)))
7075 (data (get-text-property pos 'gnus-data))
7076 (fun (get-text-property pos 'gnus-callback)))
7079 (funcall fun data))))
7081 (defun gnus-article-press-button ()
7082 "Check text at point for a callback function.
7083 If the text at point has a `gnus-callback' property,
7084 call it with the value of the `gnus-data' text property."
7086 (let ((data (get-text-property (point) 'gnus-data))
7087 (fun (get-text-property (point) 'gnus-callback)))
7089 (funcall fun data))))
7091 (defun gnus-article-prev-button (n)
7092 "Move point to N buttons backward.
7093 If N is negative, move forward instead."
7095 (gnus-article-next-button (- n)))
7097 (defun gnus-article-next-button (n)
7098 "Move point to N buttons forward.
7099 If N is negative, move backward instead."
7101 (let ((function (if (< n 0) 'previous-single-property-change
7102 'next-single-property-change))
7103 (inhibit-point-motion-hooks t)
7105 (limit (if (< n 0) (point-min) (point-max))))
7107 (while (and (not (= limit (point)))
7109 ;; Skip past the current button.
7110 (when (get-text-property (point) 'gnus-callback)
7111 (goto-char (funcall function (point) 'gnus-callback nil limit)))
7112 ;; Go to the next (or previous) button.
7113 (gnus-goto-char (funcall function (point) 'gnus-callback nil limit))
7114 ;; Put point at the start of the button.
7115 (when (and backward (not (get-text-property (point) 'gnus-callback)))
7116 (goto-char (funcall function (point) 'gnus-callback nil limit)))
7117 ;; Skip past intangible buttons.
7118 (when (get-text-property (point) 'intangible)
7122 (gnus-message 5 "No more buttons"))
7125 (defun gnus-article-highlight (&optional force)
7126 "Highlight current article.
7127 This function calls `gnus-article-highlight-headers',
7128 `gnus-article-highlight-citation',
7129 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
7130 do the highlighting. See the documentation for those functions."
7131 (interactive (list 'force))
7132 (gnus-article-highlight-headers)
7133 (gnus-article-highlight-citation force)
7134 (gnus-article-highlight-signature)
7135 (gnus-article-add-buttons force)
7136 (gnus-article-add-buttons-to-head))
7138 (defun gnus-article-highlight-some (&optional force)
7139 "Highlight current article.
7140 This function calls `gnus-article-highlight-headers',
7141 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
7142 do the highlighting. See the documentation for those functions."
7143 (interactive (list 'force))
7144 (gnus-article-highlight-headers)
7145 (gnus-article-highlight-signature)
7146 (gnus-article-add-buttons))
7148 (defun gnus-article-highlight-headers ()
7149 "Highlight article headers as specified by `gnus-header-face-alist'."
7151 (gnus-with-article-headers
7152 (let (regexp header-face field-face from hpoints fpoints)
7153 (dolist (entry gnus-header-face-alist)
7154 (goto-char (point-min))
7155 (setq regexp (concat "^\\("
7156 (if (string-equal "" (nth 0 entry))
7160 header-face (nth 1 entry)
7161 field-face (nth 2 entry))
7162 (while (and (re-search-forward regexp nil t)
7166 (unless (search-forward ":" nil t)
7168 (when (and header-face
7169 (not (memq (point) hpoints)))
7170 (push (point) hpoints)
7171 (gnus-put-text-property from (point) 'face header-face))
7172 (when (and field-face
7173 (not (memq (setq from (point)) fpoints)))
7175 (if (re-search-forward "^[^ \t]" nil t)
7177 (goto-char (point-max)))
7178 (gnus-put-text-property from (point) 'face field-face)))))))
7180 (defun gnus-article-highlight-signature ()
7181 "Highlight the signature in an article.
7182 It does this by highlighting everything after
7183 `gnus-signature-separator' using the face `gnus-signature'."
7185 (when gnus-signature-face
7186 (gnus-with-article-buffer
7187 (let ((inhibit-point-motion-hooks t))
7189 (when (gnus-article-narrow-to-signature)
7190 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
7191 'face gnus-signature-face)))))))
7193 (defun gnus-article-buttonize-signature ()
7194 "Add button to the signature."
7197 (set-buffer gnus-article-buffer)
7198 (let ((inhibit-read-only t)
7199 (inhibit-point-motion-hooks t))
7200 (when (gnus-article-search-signature)
7201 (gnus-article-add-button (match-beginning 0) (match-end 0)
7202 'gnus-signature-toggle
7203 (set-marker (make-marker)
7204 (1+ (match-end 0))))))))
7206 (defun gnus-button-in-region-p (b e prop)
7207 "Say whether PROP exists in the region."
7208 (text-property-not-all b e prop nil))
7210 (defun gnus-article-add-buttons (&optional force)
7211 "Find external references in the article and make buttons of them.
7212 \"External references\" are things like Message-IDs and URLs, as
7213 specified by `gnus-button-alist'."
7214 (interactive (list 'force))
7215 (gnus-with-article-buffer
7216 (let ((inhibit-point-motion-hooks t)
7217 (case-fold-search t)
7218 (alist gnus-button-alist)
7220 ;; Remove all old markers.
7221 (let (marker entry new-list)
7222 (while (setq marker (pop gnus-button-marker-list))
7223 (if (or (< marker (point-min)) (>= marker (point-max)))
7224 (push marker new-list)
7226 (when (setq entry (gnus-button-entry))
7227 (put-text-property (match-beginning (nth 1 entry))
7228 (match-end (nth 1 entry))
7229 'gnus-callback nil))
7230 (set-marker marker nil)))
7231 (setq gnus-button-marker-list new-list))
7232 ;; We skip the headers.
7235 (while (setq entry (pop alist))
7236 (setq regexp (eval (car entry)))
7238 (while (re-search-forward regexp nil t)
7239 (let* ((start (and entry (match-beginning (nth 1 entry))))
7240 (end (and entry (match-end (nth 1 entry))))
7241 (from (match-beginning 0)))
7242 (when (and (or (eq t (nth 2 entry))
7243 (eval (nth 2 entry)))
7244 (not (gnus-button-in-region-p
7245 start end 'gnus-callback)))
7246 ;; That optional form returned non-nil, so we add the
7248 (gnus-article-add-button
7249 start end 'gnus-button-push
7250 (car (push (set-marker (make-marker) from)
7251 gnus-button-marker-list))))))))))
7253 ;; Add buttons to the head of an article.
7254 (defun gnus-article-add-buttons-to-head ()
7255 "Add buttons to the head of the article."
7257 (gnus-with-article-headers
7259 (dolist (entry gnus-header-button-alist)
7260 ;; Each alist entry.
7261 (goto-char (point-min))
7262 (while (re-search-forward (car entry) nil t)
7263 ;; Each header matching the entry.
7264 (setq beg (match-beginning 0))
7265 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
7266 (match-beginning 0))
7269 (while (re-search-forward (eval (nth 1 entry)) end t)
7270 ;; Each match within a header.
7271 (let* ((entry (cdr entry))
7272 (start (match-beginning (nth 1 entry)))
7273 (end (match-end (nth 1 entry)))
7274 (form (nth 2 entry)))
7275 (goto-char (match-end 0))
7277 (gnus-article-add-button
7278 start end (nth 3 entry)
7279 (buffer-substring (match-beginning (nth 4 entry))
7280 (match-end (nth 4 entry)))))))
7281 (goto-char end))))))
7283 ;;; External functions:
7285 (defun gnus-article-add-button (from to fun &optional data)
7286 "Create a button between FROM and TO with callback FUN and data DATA."
7287 (when gnus-article-button-face
7288 (gnus-overlay-put (gnus-make-overlay from to)
7289 'face gnus-article-button-face))
7290 (gnus-add-text-properties
7292 (nconc (and gnus-article-mouse-face
7293 (list gnus-mouse-face-prop gnus-article-mouse-face))
7294 (list 'gnus-callback fun)
7295 (and data (list 'gnus-data data))))
7296 (widget-convert-button 'link from to :action 'gnus-widget-press-button
7297 :button-keymap gnus-widget-button-keymap))
7299 ;;; Internal functions:
7301 (defun gnus-article-set-globals ()
7302 (with-current-buffer gnus-summary-buffer
7303 (gnus-set-global-variables)))
7305 (defun gnus-signature-toggle (end)
7306 (gnus-with-article-buffer
7307 (let ((inhibit-point-motion-hooks t)
7308 (limit (next-single-property-change end 'mime-view-entity
7310 (if (text-property-any end limit 'article-type 'signature)
7312 (gnus-delete-wash-type 'signature)
7313 (gnus-remove-text-properties-when
7314 'article-type 'signature end limit
7315 (cons 'article-type (cons 'signature
7316 gnus-hidden-properties))))
7317 (gnus-add-wash-type 'signature)
7318 (gnus-add-text-properties-when
7319 'article-type nil end limit
7320 (cons 'article-type (cons 'signature
7321 gnus-hidden-properties)))))
7322 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
7323 (gnus-set-mode-line 'article))))
7325 (defun gnus-button-entry ()
7326 ;; Return the first entry in `gnus-button-alist' matching this place.
7327 (let ((alist gnus-button-alist)
7330 (setq entry (pop alist))
7331 (if (looking-at (eval (car entry)))
7336 (defun gnus-button-push (marker)
7337 ;; Push button starting at MARKER.
7340 (let* ((entry (gnus-button-entry))
7341 (inhibit-point-motion-hooks t)
7343 (args (mapcar (lambda (group)
7344 (let ((string (match-string group)))
7345 (set-text-properties
7346 0 (length string) nil string)
7353 (fboundp (symbol-value fun)))
7354 (apply (symbol-value fun) args))
7356 (gnus-message 1 "You must define `%S' to use this button"
7357 (cons fun args)))))))
7359 (defun gnus-parse-news-url (url)
7360 (let (scheme server port group message-id articles)
7363 (goto-char (point-min))
7364 (when (looking-at "\\([A-Za-z]+\\):")
7365 (setq scheme (match-string 1))
7366 (goto-char (match-end 0)))
7367 (when (looking-at "//\\([^:/]+\\)\\(:?\\)\\([0-9]+\\)?/")
7368 (setq server (match-string 1))
7369 (setq port (if (stringp (match-string 3))
7370 (string-to-number (match-string 3))
7372 (goto-char (match-end 0)))
7375 ((looking-at "\\(.*@.*\\)")
7376 (setq message-id (match-string 1)))
7377 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
7378 (setq group (match-string 1)
7379 articles (split-string (match-string 2) "-")))
7380 ((looking-at "\\([^/]+\\)/?")
7381 (setq group (match-string 1)))
7383 (error "Unknown news URL syntax"))))
7384 (list scheme server port group message-id articles)))
7386 (defun gnus-button-handle-news (url)
7388 (destructuring-bind (scheme server port group message-id articles)
7389 (gnus-parse-news-url url)
7393 (set-buffer gnus-summary-buffer)
7395 (let ((gnus-refer-article-method
7396 (nconc (list (list 'nntp server))
7397 gnus-refer-article-method))
7398 (nntp-port-number (or port "nntp")))
7399 (gnus-message 7 "Fetching %s with %s"
7400 message-id gnus-refer-article-method)
7401 (gnus-summary-refer-article message-id))
7402 (gnus-summary-refer-article message-id))))
7404 (gnus-button-fetch-group url)))))
7406 (defun gnus-button-handle-man (url)
7408 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7409 (when (eq gnus-button-man-handler 'woman)
7410 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
7411 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7412 (funcall gnus-button-man-handler url))
7414 (defun gnus-button-handle-info-url (url)
7415 "Fetch an info URL."
7416 (setq url (mm-subst-char-in-string ?+ ?\ url))
7418 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
7419 (gnus-info-find-node
7420 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
7422 ")" (gnus-url-unhex-string (match-string 2 url)))))
7423 ((string-match "([^)\"]+)[^\"]+" url)
7425 (gnus-replace-in-string
7426 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
7427 (gnus-info-find-node url))
7428 (t (error "Can't parse %s" url))))
7430 (defun gnus-button-handle-info-url-gnome (url)
7431 "Fetch GNOME style info URL."
7432 (setq url (mm-subst-char-in-string ?_ ?\ url))
7433 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
7434 (gnus-info-find-node
7436 (gnus-url-unhex-string
7437 (match-string 1 url))
7439 (or (gnus-url-unhex-string
7440 (match-string 2 url))
7442 (error "Can't parse %s" url)))
7444 (defun gnus-button-handle-info-url-kde (url)
7445 "Fetch KDE style info URL."
7446 (gnus-info-find-node (gnus-url-unhex-string url)))
7448 (defun gnus-button-handle-info-keystrokes (url)
7449 "Call `info' when pushing the corresponding URL button."
7450 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
7455 (defun gnus-button-openpgp (url)
7456 "Retrieve and add an OpenPGP key given URL from an OpenPGP header."
7458 (mm-url-insert-file-contents-external url)
7459 (pgg-snarf-keys-region (point-min) (point-max))
7460 (pgg-display-output-buffer nil nil nil)))
7462 (defun gnus-button-message-id (message-id)
7464 (with-current-buffer gnus-summary-buffer
7465 (gnus-summary-refer-article message-id)))
7467 (defun gnus-button-fetch-group (address)
7468 "Fetch GROUP specified by ADDRESS."
7469 (if (not (string-match "[:/]" address))
7470 ;; This is just a simple group url.
7471 (gnus-group-read-ephemeral-group address gnus-select-method)
7474 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
7476 (error "Can't parse %s" address)
7477 (gnus-group-read-ephemeral-group
7478 (match-string 4 address)
7479 `(nntp ,(match-string 1 address)
7480 (nntp-address ,(match-string 1 address))
7481 (nntp-port-number ,(if (match-end 3)
7482 (match-string 3 address)
7485 (and (match-end 6) (list (string-to-number (match-string 6 address))))))))
7487 (defun gnus-url-parse-query-string (query &optional downcase)
7488 (let (retval pairs cur key val)
7489 (setq pairs (split-string query "&"))
7491 (setq cur (car pairs)
7493 (if (not (string-match "=" cur))
7495 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
7496 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
7498 (setq key (downcase key)))
7499 (setq cur (assoc key retval))
7501 (setcdr cur (cons val (cdr cur)))
7502 (setq retval (cons (list key val) retval)))))
7505 (defun gnus-url-mailto (url)
7506 ;; Send mail to someone
7507 (when (string-match "mailto:/*\\(.*\\)" url)
7508 (setq url (substring url (match-beginning 1) nil)))
7509 (let (to args subject func)
7510 (setq args (gnus-url-parse-query-string
7511 (if (string-match "^\\?" url)
7513 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
7514 (concat "to=" (match-string 1 url) "&"
7515 (match-string 2 url))
7516 (concat "to=" url)))
7518 subject (cdr-safe (assoc "subject" args)))
7521 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
7524 (message-position-on-field (caar args)))
7525 (insert (gnus-replace-in-string
7526 (mapconcat 'identity (reverse (cdar args)) ", ")
7528 (setq args (cdr args)))
7531 (message-goto-subject))))
7533 (defun gnus-button-embedded-url (address)
7534 "Activate ADDRESS with `browse-url'."
7535 (browse-url (gnus-strip-whitespace address)))
7537 ;;; Next/prev buttons in the article buffer.
7539 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
7540 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
7542 (defvar gnus-prev-page-map
7543 (let ((map (make-sparse-keymap)))
7544 (define-key map gnus-mouse-2 'gnus-button-prev-page)
7545 (define-key map "\r" 'gnus-button-prev-page)
7548 (defvar gnus-next-page-map
7549 (let ((map (make-sparse-keymap)))
7550 (unless (>= emacs-major-version 21)
7551 ;; XEmacs doesn't care.
7552 (set-keymap-parent map gnus-article-mode-map))
7553 (define-key map gnus-mouse-2 'gnus-button-next-page)
7554 (define-key map "\r" 'gnus-button-next-page)
7557 (defun gnus-insert-prev-page-button ()
7559 (inhibit-read-only t)
7560 (situation (get-text-property (point-min) 'mime-view-situation)))
7562 gnus-prev-page-line-format nil
7563 `(keymap ,gnus-prev-page-map
7565 gnus-callback gnus-article-button-prev-page
7566 article-type annotation
7567 mime-view-situation ,situation))
7568 (widget-convert-button
7570 ;; Exclude a newline.
7573 :action 'gnus-button-prev-page
7574 :button-keymap gnus-prev-page-map)))
7576 (defun gnus-button-next-page (&optional args more-args)
7577 "Go to the next page."
7579 (let ((win (selected-window)))
7580 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7581 (gnus-article-next-page)
7582 (select-window win)))
7584 (defun gnus-button-prev-page (&optional args more-args)
7585 "Go to the prev page."
7587 (let ((win (selected-window)))
7588 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7589 (gnus-article-prev-page)
7590 (select-window win)))
7592 (defun gnus-insert-next-page-button ()
7594 (inhibit-read-only t)
7595 (situation (get-text-property (point-min) 'mime-view-situation)))
7596 (gnus-eval-format gnus-next-page-line-format nil
7597 `(keymap ,gnus-next-page-map
7599 gnus-callback gnus-article-button-next-page
7600 article-type annotation
7601 mime-view-situation ,situation))
7602 (widget-convert-button
7604 ;; Exclude a newline.
7607 :action 'gnus-button-next-page
7608 :button-keymap gnus-next-page-map)))
7610 (defun gnus-article-button-next-page (arg)
7611 "Go to the next page."
7613 (let ((win (selected-window)))
7614 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7615 (gnus-article-next-page)
7616 (select-window win)))
7618 (defun gnus-article-button-prev-page (arg)
7619 "Go to the prev page."
7621 (let ((win (selected-window)))
7622 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7623 (gnus-article-prev-page)
7624 (select-window win)))
7626 (defvar gnus-decode-header-methods
7627 '(mail-decode-encoded-word-region)
7628 "List of methods used to decode headers.
7630 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
7631 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
7632 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
7633 whose names match REGEXP.
7636 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
7637 mail-decode-encoded-word-region
7638 (\"chinese\" . rfc1843-decode-region))
7641 (defvar gnus-decode-header-methods-cache nil)
7643 (defun gnus-multi-decode-header (start end)
7644 "Apply the functions from `gnus-encoded-word-methods' that match."
7645 (unless (and gnus-decode-header-methods-cache
7646 (eq gnus-newsgroup-name
7647 (car gnus-decode-header-methods-cache)))
7648 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
7651 (nconc gnus-decode-header-methods-cache (list x))
7652 (if (and gnus-newsgroup-name
7653 (string-match (car x) gnus-newsgroup-name))
7654 (nconc gnus-decode-header-methods-cache
7656 gnus-decode-header-methods))
7657 (let ((xlist gnus-decode-header-methods-cache))
7660 (narrow-to-region start end)
7662 (funcall (pop xlist) (point-min) (point-max))))))
7665 ;;; Treatment top-level handling.
7668 (defun gnus-treat-article (condition &optional part-number total-parts type)
7669 (let ((length (- (point-max) (point-min)))
7670 (alist gnus-treatment-function-alist)
7671 (article-goto-body-goes-to-point-min-p t)
7675 (let ((list gnus-article-treat-types))
7677 (when (string-match (pop list) type)
7678 (throw 'found t)))))))
7679 (highlightp (gnus-visual-p 'article-highlight 'highlight))
7680 (entity (static-unless (featurep 'xemacs)
7681 (when (eq 'head condition)
7682 (get-text-property (point-min) 'mime-view-entity))))
7683 val elem buttonized)
7684 (gnus-run-hooks 'gnus-part-display-hook)
7685 (unless gnus-inhibit-treatment
7686 (dolist (elem alist)
7689 (when (gnus-buffer-live-p gnus-summary-buffer)
7690 (set-buffer gnus-summary-buffer))
7691 (symbol-value (car elem))))
7692 (when (and (or (consp val)
7694 (gnus-treat-predicate val)
7695 (or (not (get (car elem) 'highlight))
7697 (when (and (not buttonized)
7699 '(gnus-treat-hide-signature
7700 gnus-treat-highlight-signature)))
7701 (gnus-article-buttonize-signature)
7702 (setq buttonized t))
7704 (funcall (cadr elem)))))
7705 ;; FSF Emacsen does not inherit the existing text properties
7706 ;; in the new text, so we should do it for `mime-view-entity'.
7707 (static-unless (featurep 'xemacs)
7709 (put-text-property (point-min) (point-max)
7710 'mime-view-entity entity))))))
7712 ;; Dynamic variables.
7714 (defvar part-number)
7715 (defvar total-parts)
7720 (defun gnus-treat-predicate (val)
7725 (stringp (car val)))
7726 (apply 'gnus-or (mapcar `(lambda (s)
7727 (string-match s ,(or gnus-newsgroup-name "")))
7730 (let ((pred (pop val)))
7733 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
7735 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
7737 (not (gnus-treat-predicate (car val))))
7739 (equal (car val) type))
7741 (error "%S is not a valid predicate" pred)))))
7751 (eq part-number total-parts))
7755 (error "%S is not a valid value" val))))
7757 (defun gnus-article-encrypt-body (protocol &optional n)
7758 "Encrypt the article body."
7761 (or gnus-article-encrypt-protocol
7762 (completing-read "Encrypt protocol: "
7763 gnus-article-encrypt-protocol-alist
7765 current-prefix-arg))
7766 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7768 (error "Can't find the encrypt protocol %s" protocol))
7769 (if (member gnus-newsgroup-name '("nndraft:delayed"
7772 (error "Can't encrypt the article in group %s"
7773 gnus-newsgroup-name))
7774 (gnus-summary-iterate n
7776 (set-buffer gnus-summary-buffer)
7777 (let ((mail-parse-charset gnus-newsgroup-charset)
7778 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7779 (summary-buffer gnus-summary-buffer)
7781 (gnus-set-global-variables)
7782 (when (gnus-group-read-only-p)
7783 (error "The current newsgroup does not support article encrypt"))
7784 (gnus-summary-show-article t)
7786 (or (mail-header-references gnus-current-headers) ""))
7787 (set-buffer gnus-article-buffer)
7788 (let* ((inhibit-read-only t)
7790 (mapcar (lambda (field)
7791 (and (save-restriction
7792 (message-narrow-to-head)
7793 (goto-char (point-min))
7794 (search-forward field nil t))
7796 (message-narrow-to-field)
7798 (delete-region (point-min) (point-max))
7800 '("Content-Type:" "Content-Transfer-Encoding:"
7801 "Content-Disposition:"))))
7802 (message-narrow-to-head)
7803 (message-remove-header "MIME-Version")
7804 (goto-char (point-max))
7805 (setq point (point))
7806 (insert (apply 'concat headers))
7808 (narrow-to-region point (point-max))
7809 (let ((message-options message-options))
7810 (message-options-set 'message-sender user-mail-address)
7811 (message-options-set 'message-recipients user-mail-address)
7812 (message-options-set 'message-sign-encrypt 'not)
7814 (goto-char (point-min))
7815 (insert "MIME-Version: 1.0\n")
7817 (gnus-summary-edit-article-done
7818 references nil summary-buffer t))
7819 (when gnus-keep-backlog
7820 (gnus-backlog-remove-article
7821 (car gnus-article-current) (cdr gnus-article-current)))
7823 (when (get-buffer gnus-original-article-buffer)
7824 (set-buffer gnus-original-article-buffer)
7825 (setq gnus-original-article nil)))
7826 (when gnus-use-cache
7827 (gnus-cache-update-article
7828 (car gnus-article-current) (cdr gnus-article-current))))))))
7830 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7831 "The following specs can be used:
7832 %t The security MIME type
7835 %D Details if button is pressed")
7837 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%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-line-format-alist
7845 '((?t gnus-tmp-type ?s)
7846 (?i gnus-tmp-info ?s)
7847 (?d gnus-tmp-details ?s)
7848 (?D gnus-tmp-pressed-details ?s)))
7850 (defvar gnus-mime-security-button-map
7851 (let ((map (make-sparse-keymap)))
7852 (define-key map gnus-mouse-2 'gnus-article-push-button)
7853 (define-key map "\r" 'gnus-article-press-button)
7856 (defvar gnus-mime-security-details-buffer nil)
7858 (defvar gnus-mime-security-button-pressed nil)
7860 (defvar gnus-mime-security-show-details-inline t
7861 "If non-nil, show details in the article buffer.")
7863 (defun gnus-mime-security-verify-or-decrypt (handle)
7864 (mm-remove-parts (cdr handle))
7865 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7866 point (inhibit-read-only t))
7868 (goto-char (car region)))
7870 (narrow-to-region (point) (point))
7871 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7872 (let* ((mm-verify-option 'known)
7873 (mm-decrypt-option 'known)
7874 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7875 (unless (eq nparts (cdr handle))
7876 (mm-destroy-parts (cdr handle))
7877 (setcdr handle nparts))))
7878 (setq point (point))
7879 (gnus-mime-display-security handle)
7880 (goto-char (point-max)))
7882 (delete-region (point) (cdr region))
7883 (set-marker (car region) nil)
7884 (set-marker (cdr region) nil))
7887 (defun gnus-mime-security-show-details (handle)
7888 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7890 (gnus-message 5 "No details.")
7891 (if gnus-mime-security-show-details-inline
7892 (let ((gnus-mime-security-button-pressed
7893 (not (get-text-property (point) 'gnus-mime-details)))
7894 (gnus-mime-security-button-line-format
7895 (get-text-property (point) 'gnus-line-format))
7896 (inhibit-read-only t))
7898 (while (eq (get-text-property (point) 'gnus-line-format)
7899 gnus-mime-security-button-line-format)
7903 (narrow-to-region (point) (point))
7904 (gnus-insert-mime-security-button handle))
7905 (delete-region (point)
7906 (or (text-property-not-all
7909 gnus-mime-security-button-line-format)
7912 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7913 (with-current-buffer gnus-mime-security-details-buffer
7916 (setq gnus-mime-security-details-buffer
7917 (gnus-get-buffer-create "*MIME Security Details*")))
7918 (with-current-buffer gnus-mime-security-details-buffer
7920 (goto-char (point-min)))
7921 (pop-to-buffer gnus-mime-security-details-buffer)))))
7923 (defun gnus-mime-security-press-button (handle)
7925 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7926 (gnus-mime-security-show-details handle)
7927 (gnus-mime-security-verify-or-decrypt handle))))
7929 (defun gnus-insert-mime-security-button (handle &optional displayed)
7930 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7933 (or (nth 2 (assoc protocol mm-verify-function-alist))
7934 (nth 2 (assoc protocol mm-decrypt-function-alist))
7936 (if (equal (car handle) "multipart/signed")
7937 " Signed" " Encrypted")
7940 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7943 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7944 gnus-tmp-pressed-details
7946 (setq gnus-tmp-details
7947 (if gnus-tmp-details
7948 (concat "\n" gnus-tmp-details)
7950 (setq gnus-tmp-pressed-details
7951 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7956 gnus-mime-security-button-line-format
7957 gnus-mime-security-button-line-format-alist
7958 `(keymap ,gnus-mime-security-button-map
7959 gnus-callback gnus-mime-security-press-button
7960 gnus-line-format ,gnus-mime-security-button-line-format
7961 gnus-mime-details ,gnus-mime-security-button-pressed
7962 article-type annotation
7965 ;; Exclude a newline.
7968 (widget-convert-button
7971 :action 'gnus-widget-press-button
7972 :button-keymap gnus-mime-security-button-map
7974 (lambda (widget/window &optional overlay pos)
7975 ;; Needed to properly clear the message due to a bug in
7976 ;; wid-edit (XEmacs only).
7977 (when (boundp 'help-echo-owns-message)
7978 (setq help-echo-owns-message t))
7981 (aref gnus-mouse-2 0))))))
7983 (defun gnus-mime-display-security (handle)
7985 (narrow-to-region (point) (point))
7986 (unless (gnus-unbuttonized-mime-type-p (car handle))
7987 (gnus-insert-mime-security-button handle))
7988 (gnus-mime-display-part (cadr handle))
7991 (unless (gnus-unbuttonized-mime-type-p (car handle))
7992 (let ((gnus-mime-security-button-line-format
7993 gnus-mime-security-button-end-line-format))
7994 (gnus-insert-mime-security-button handle)))
7995 (mm-set-handle-multipart-parameter
7997 (cons (set-marker (make-marker) (point-min))
7998 (set-marker (make-marker) (point-max))))))
8004 (defun gnus-article-header-presentation-method (entity situation)
8005 (mime-insert-header entity)
8006 (article-decode-group-name))
8008 (set-alist 'mime-header-presentation-method-alist
8009 'gnus-original-article-mode
8010 #'gnus-article-header-presentation-method)
8012 (defun gnus-mime-preview-quitting-method ()
8013 (mime-preview-kill-buffer)
8014 (delete-other-windows)
8015 (gnus-article-show-summary)
8016 (gnus-summary-select-article gnus-show-all-headers t))
8018 (set-alist 'mime-preview-quitting-method-alist
8019 'gnus-original-article-mode #'gnus-mime-preview-quitting-method)
8021 (set-alist 'mime-preview-following-method-alist
8022 'gnus-original-article-mode #'gnus-following-method)
8024 (set-alist 'mime-preview-over-to-previous-method-alist
8025 'gnus-original-article-mode
8027 (if (> (point-min) 1)
8028 (gnus-article-prev-page)
8029 (gnus-article-read-summary-keys
8030 nil (gnus-character-to-event ?P)))))
8032 (set-alist 'mime-preview-over-to-next-method-alist
8033 'gnus-original-article-mode'
8035 (if (< (point-max) (buffer-size))
8036 (gnus-article-next-page)
8037 (gnus-article-read-summary-keys
8038 nil (gnus-character-to-event ?N)))))
8048 (run-hooks 'gnus-art-load-hook)
8050 ;;; gnus-art.el ends here