1 ;;; gnus-art.el --- article mode commands for Semi-gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
7 ;; Katsumi Yamaoka <yamaoka@jpl.org>
8 ;; Keywords: mail, news, MIME
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
34 (defvar tool-bar-map))
38 ;; Avoid the "Recursive load suspected" error in Emacs 21.1.
40 (let ((recursive-load-depth-limit 100))
47 (when (static-if (featurep 'xemacs)
48 (console-on-window-system-p)
50 (require 'mime-image))
53 ;; Avoid byte-compile warnings.
63 (autoload 'gnus-msg-mail "gnus-msg" nil t)
64 (autoload 'gnus-button-mailto "gnus-msg")
65 (autoload 'gnus-button-reply "gnus-msg" nil t)
66 (autoload 'parse-time-string "parse-time" nil nil)
67 (autoload 'ansi-color-apply-on-region "ansi-color")
69 (defgroup gnus-article nil
71 :link '(custom-manual "(gnus)Article Buffer")
74 (defgroup gnus-article-treat nil
75 "Treating article parts."
76 :link '(custom-manual "(gnus)Article Hiding")
79 (defgroup gnus-article-hiding nil
80 "Hiding article parts."
81 :link '(custom-manual "(gnus)Article Hiding")
84 (defgroup gnus-article-highlight nil
85 "Article highlighting."
86 :link '(custom-manual "(gnus)Article Highlighting")
90 (defgroup gnus-article-signature nil
92 :link '(custom-manual "(gnus)Article Signature")
95 (defgroup gnus-article-headers nil
97 :link '(custom-manual "(gnus)Hiding Headers")
100 (defgroup gnus-article-washing nil
101 "Special commands on articles."
102 :link '(custom-manual "(gnus)Article Washing")
103 :group 'gnus-article)
105 (defgroup gnus-article-emphasis nil
106 "Fontisizing articles."
107 :link '(custom-manual "(gnus)Article Fontisizing")
108 :group 'gnus-article)
110 (defgroup gnus-article-saving nil
112 :link '(custom-manual "(gnus)Saving Articles")
113 :group 'gnus-article)
115 (defgroup gnus-article-mime nil
116 "Worshiping the MIME wonder."
117 :link '(custom-manual "(gnus)Using MIME")
118 :group 'gnus-article)
120 (defgroup gnus-article-buttons nil
121 "Pushable buttons in the article buffer."
122 :link '(custom-manual "(gnus)Article Buttons")
123 :group 'gnus-article)
125 (defgroup gnus-article-various nil
126 "Other article options."
127 :link '(custom-manual "(gnus)Misc Article")
128 :group 'gnus-article)
130 (defcustom gnus-ignored-headers
133 (concat "^" header ":"))
134 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
135 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
136 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
137 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
138 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
139 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
140 "X-Attribution" "X-Originating-IP" "Delivered-To"
141 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
142 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
143 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
144 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
145 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
146 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
147 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
148 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
149 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
150 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
151 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
152 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
153 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
154 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
155 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
156 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
157 "List-[A-Za-z]+" "X-Listprocessor-Version"
158 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
159 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
160 "X-Received" "Content-length" "X-precedence"
161 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
162 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
163 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
164 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
165 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
166 "X-Content-length" "X-Posting-Agent" "Original-Received"
167 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
168 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
169 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
170 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
171 "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer"))
172 "*All headers that start with this regexp will be hidden.
173 This variable can also be a list of regexps of headers to be ignored.
174 If `gnus-visible-headers' is non-nil, this variable will be ignored."
175 :type '(choice :custom-show nil
178 :group 'gnus-article-hiding)
180 (defcustom gnus-visible-headers
181 "^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:"
182 "*All headers that do not match this regexp will be hidden.
183 This variable can also be a list of regexp of headers to remain visible.
184 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
185 :type '(repeat :value-to-internal (lambda (widget value)
186 (custom-split-regexp-maybe value))
187 :match (lambda (widget value)
189 (widget-editable-list-match widget value)))
191 :group 'gnus-article-hiding)
193 (defcustom gnus-sorted-header-list
194 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
195 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
196 "*This variable is a list of regular expressions.
197 If it is non-nil, headers that match the regular expressions will
198 be placed first in the article buffer in the sequence specified by
200 :type '(repeat regexp)
201 :group 'gnus-article-hiding)
203 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
204 "Headers that are only to be displayed if they have interesting data.
205 Possible values in this list are:
207 'empty Headers with no content.
208 'newsgroups Newsgroup identical to Gnus group.
209 'to-address To identical to To-address.
210 'to-list To identical to To-list.
211 'cc-list CC identical to To-list.
212 'followup-to Followup-to identical to Newsgroups.
213 'reply-to Reply-to identical to From.
214 'date Date less than four days old.
215 'long-to To and/or Cc longer than 1024 characters.
216 'many-to Multiple To and/or Cc."
217 :type '(set (const :tag "Headers with no content." empty)
218 (const :tag "Newsgroups identical to Gnus group." newsgroups)
219 (const :tag "To identical to To-address." to-address)
220 (const :tag "To identical to To-list." to-list)
221 (const :tag "CC identical to To-list." cc-list)
222 (const :tag "Followup-to identical to Newsgroups." followup-to)
223 (const :tag "Reply-to identical to From." reply-to)
224 (const :tag "Date less than four days old." date)
225 (const :tag "To and/or Cc longer than 1024 characters." long-to)
226 (const :tag "Multiple To and/or Cc headers." many-to))
227 :group 'gnus-article-hiding)
229 (defcustom gnus-article-skip-boring nil
230 "Skip over text that is not worth reading.
231 By default, if you set this t, then Gnus will display citations and
232 signatures, but will never scroll down to show you a page consisting
233 only of boring text. Boring text is controlled by
234 `gnus-article-boring-faces'."
237 :group 'gnus-article-hiding)
239 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
240 "Regexp matching signature separator.
241 This can also be a list of regexps. In that case, it will be checked
242 from head to tail looking for a separator. Searches will be done from
243 the end of the buffer."
244 :type '(repeat string)
245 :group 'gnus-article-signature)
247 (defcustom gnus-signature-limit nil
248 "Provide a limit to what is considered a signature.
249 If it is a number, no signature may not be longer (in characters) than
250 that number. If it is a floating point number, no signature may be
251 longer (in lines) than that number. If it is a function, the function
252 will be called without any parameters, and if it returns nil, there is
253 no signature in the buffer. If it is a string, it will be used as a
254 regexp. If it matches, the text in question is not a signature.
256 This can also be a list of the above values."
257 :type '(choice (integer :value 200)
259 (function :value fun)
260 (regexp :value ".*"))
261 :group 'gnus-article-signature)
263 (defcustom gnus-hidden-properties '(invisible t intangible t)
264 "Property list to use for hiding text."
266 :group 'gnus-article-hiding)
268 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
269 ;; frames in a session.
270 (defcustom gnus-article-x-face-command
275 (if (or (gnus-image-type-available-p 'xface)
276 (gnus-image-type-available-p 'pbm))
277 'gnus-display-x-face-in-from
278 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -"))
279 ((gnus-image-type-available-p 'pbm)
280 'gnus-display-x-face-in-from)
282 (module-installed-p 'x-face-mule))
283 'x-face-mule-gnus-article-display-x-face)
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 ,@(let ((x-face-mule (if (featurep 'xemacs)
293 (module-installed-p 'x-face-mule))))
297 (if (or (gnus-image-type-available-p 'xface)
298 (gnus-image-type-available-p 'pbm))
299 '(function-item gnus-display-x-face-in-from))
302 x-face-mule-gnus-article-display-x-face))
306 :group 'gnus-article-washing)
308 (defcustom gnus-article-x-face-too-ugly nil
309 "Regexp matching posters whose face shouldn't be shown automatically."
310 :type '(choice regexp (const nil))
311 :group 'gnus-article-washing)
313 (defcustom gnus-article-banner-alist nil
314 "Banner alist for stripping.
316 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
318 :type '(repeat (cons symbol regexp))
319 :group 'gnus-article-washing)
321 (gnus-define-group-parameter
324 "Alist of regexps (to match group names) and banner."
325 :variable-group gnus-article-washing
327 '(choice :tag "Banner"
329 (const :tag "Remove signature" signature)
330 (symbol :tag "Item in `gnus-article-banner-alist'" none)
332 (const :tag "None" nil))
334 "If non-nil, specify how to remove `banners' from articles.
336 Symbol `signature' means to remove signatures delimited by
337 `gnus-signature-separator'. Any other symbol is used to look up a
338 regular expression to match the banner in `gnus-article-banner-alist'.
339 A string is used as a regular expression to match the banner
342 (defcustom gnus-article-address-banner-alist nil
343 "Alist of mail addresses and banners.
344 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
345 to match a mail address in the From: header, BANNER is one of a symbol
346 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
347 If ADDRESS matches author's mail address, it will remove things like
348 advertisements. For example:
350 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
354 (regexp :tag "Address")
355 (choice :tag "Banner" :value nil
356 (const :tag "Remove signature" signature)
357 (symbol :tag "Item in `gnus-article-banner-alist'" none)
359 (const :tag "None" nil))))
361 :group 'gnus-article-washing)
363 (defmacro gnus-emphasis-custom-with-format (&rest body)
365 \\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\
366 \\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)"))
369 (defun gnus-emphasis-custom-value-to-external (value)
370 (gnus-emphasis-custom-with-format
371 (if (consp (car value))
372 (list (format format (car (car value)) (cdr (car value)))
374 (if (nth 1 value) 2 3)
378 (defun gnus-emphasis-custom-value-to-internal (value)
379 (gnus-emphasis-custom-with-format
380 (let ((regexp (concat "\\`"
381 (format (regexp-quote format)
382 "\\([^()]+\\)" "\\([^()]+\\)")
385 (if (string-match regexp (setq pattern (car value)))
386 (list (cons (match-string 1 pattern) (match-string 2 pattern))
391 (defcustom gnus-emphasis-alist
393 '(("\\*" "\\*" bold nil 2)
396 ("_/" "/_" underline-italic)
397 ("_\\*" "\\*_" underline-bold)
398 ("\\*/" "/\\*" bold-italic)
399 ("_\\*/" "/\\*_" underline-bold-italic))))
401 (gnus-emphasis-custom-with-format
402 (mapcar (lambda (spec)
403 (list (format format (car spec) (cadr spec))
406 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
408 '(("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
409 2 3 gnus-emphasis-underline))))
410 "*Alist that says how to fontify certain phrases.
411 Each item looks like this:
413 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
415 The first element is a regular expression to be matched. The second
416 is a number that says what regular expression grouping used to find
417 the entire emphasized word. The third is a number that says what
418 regexp grouping should be displayed and highlighted. The fourth
419 is the face used for highlighting."
423 :format "%[Customizing Style%]\n%v"
425 (group :tag "Default"
426 :value ("" 0 0 default)
429 (let ((value (widget-get
430 (cadr (widget-get (widget-get widget :parent)
433 (if (not (eq (nth 2 value) 'default))
437 (gnus-emphasis-custom-value-to-external value))))
438 (widget-group-value-create widget))
440 (integer :format "Match group: %v")
441 (integer :format "Emphasize group: %v")
444 :value (("_" . "_") nil default)
446 (regexp :format "Start regexp: %v")
447 (regexp :format "End regexp: %v"))
448 (boolean :format "Show start and end patterns: %[%v%]\n"
449 :on " On " :off " Off ")
451 :get (lambda (symbol)
452 (mapcar 'gnus-emphasis-custom-value-to-internal
453 (default-value symbol)))
454 :set (lambda (symbol value)
455 (set-default symbol (mapcar 'gnus-emphasis-custom-value-to-external
457 :group 'gnus-article-emphasis)
459 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
460 "A regexp to describe whitespace which should not be emphasized.
461 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
462 The former avoids underlining of leading and trailing whitespace,
463 and the latter avoids underlining any whitespace at all."
465 :group 'gnus-article-emphasis
468 (defface gnus-emphasis-bold '((t (:bold t)))
469 "Face used for displaying strong emphasized text (*word*)."
470 :group 'gnus-article-emphasis)
472 (defface gnus-emphasis-italic '((t (:italic t)))
473 "Face used for displaying italic emphasized text (/word/)."
474 :group 'gnus-article-emphasis)
476 (defface gnus-emphasis-underline '((t (:underline t)))
477 "Face used for displaying underlined emphasized text (_word_)."
478 :group 'gnus-article-emphasis)
480 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
481 "Face used for displaying underlined bold emphasized text (_*word*_)."
482 :group 'gnus-article-emphasis)
484 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
485 "Face used for displaying underlined italic emphasized text (_/word/_)."
486 :group 'gnus-article-emphasis)
488 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
489 "Face used for displaying bold italic emphasized text (/*word*/)."
490 :group 'gnus-article-emphasis)
492 (defface gnus-emphasis-underline-bold-italic
493 '((t (:bold t :italic t :underline t)))
494 "Face used for displaying underlined bold italic emphasized text.
495 Example: (_/*word*/_)."
496 :group 'gnus-article-emphasis)
498 (defface gnus-emphasis-strikethru (if (featurep 'xemacs)
499 '((t (:strikethru t)))
500 '((t (:strike-through t))))
501 "Face used for displaying strike-through text (-word-)."
502 :group 'gnus-article-emphasis)
504 (defface gnus-emphasis-highlight-words
505 '((t (:background "black" :foreground "yellow")))
506 "Face used for displaying highlighted words."
507 :group 'gnus-article-emphasis)
509 (defcustom gnus-article-time-format "%a, %d %b %Y %T %Z"
510 "Format for display of Date headers in article bodies.
511 See `format-time-string' for the possible values.
513 The variable can also be function, which should return a complete Date
514 header. The function is called with one argument, the time, which can
515 be fed to `format-time-string'."
516 :type '(choice string function)
517 :link '(custom-manual "(gnus)Article Date")
518 :group 'gnus-article-washing)
520 (defcustom gnus-save-all-headers t
521 "*If non-nil, don't remove any headers before saving."
522 :group 'gnus-article-saving
525 (defcustom gnus-prompt-before-saving 'always
526 "*This variable says how much prompting is to be done when saving articles.
527 If it is nil, no prompting will be done, and the articles will be
528 saved to the default files. If this variable is `always', each and
529 every article that is saved will be preceded by a prompt, even when
530 saving large batches of articles. If this variable is neither nil not
531 `always', there the user will be prompted once for a file name for
532 each invocation of the saving commands."
533 :group 'gnus-article-saving
534 :type '(choice (item always)
535 (item :tag "never" nil)
536 (sexp :tag "once" :format "%t\n" :value t)))
538 (defcustom gnus-saved-headers gnus-visible-headers
539 "Headers to keep if `gnus-save-all-headers' is nil.
540 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
541 If that variable is nil, however, all headers that match this regexp
542 will be kept while the rest will be deleted before saving."
543 :group 'gnus-article-saving
546 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
547 "A function to save articles in your favourite format.
548 The function must be interactively callable (in other words, it must
549 be an Emacs command).
551 Gnus provides the following functions:
553 * gnus-summary-save-in-rmail (Rmail format)
554 * gnus-summary-save-in-mail (Unix mail format)
555 * gnus-summary-save-in-folder (MH folder)
556 * gnus-summary-save-in-file (article format)
557 * gnus-summary-save-body-in-file (article body)
558 * gnus-summary-save-in-vm (use VM's folder format)
559 * gnus-summary-write-to-file (article format -- overwrite)."
560 :group 'gnus-article-saving
561 :type '(radio (function-item gnus-summary-save-in-rmail)
562 (function-item gnus-summary-save-in-mail)
563 (function-item gnus-summary-save-in-folder)
564 (function-item gnus-summary-save-in-file)
565 (function-item gnus-summary-save-body-in-file)
566 (function-item gnus-summary-save-in-vm)
567 (function-item gnus-summary-write-to-file)))
569 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
570 "A function generating a file name to save articles in Rmail format.
571 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
572 :group 'gnus-article-saving
575 (defcustom gnus-mail-save-name 'gnus-plain-save-name
576 "A function generating a file name to save articles in Unix mail format.
577 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
578 :group 'gnus-article-saving
581 (defcustom gnus-folder-save-name 'gnus-folder-save-name
582 "A function generating a file name to save articles in MH folder.
583 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
584 :group 'gnus-article-saving
587 (defcustom gnus-file-save-name 'gnus-numeric-save-name
588 "A function generating a file name to save articles in article format.
589 The function is called with NEWSGROUP, HEADERS, and optional
591 :group 'gnus-article-saving
594 (defcustom gnus-split-methods
595 '((gnus-article-archive-name)
596 (gnus-article-nndoc-name))
597 "*Variable used to suggest where articles are to be saved.
598 For instance, if you would like to save articles related to Gnus in
599 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
600 you could set this variable to something like:
602 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
603 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
605 This variable is an alist where the key is the match and the
606 value is a list of possible files to save in if the match is
609 If the match is a string, it is used as a regexp match on the
610 article. If the match is a symbol, that symbol will be funcalled
611 from the buffer of the article to be saved with the newsgroup as
612 the parameter. If it is a list, it will be evaled in the same
615 If this form or function returns a string, this string will be
616 used as a possible file name; and if it returns a non-nil list,
617 that list will be used as possible file names."
618 :group 'gnus-article-saving
619 :type '(repeat (choice (list :value (fun) function)
620 (cons :value ("" "") regexp (repeat string))
623 (defcustom gnus-article-display-method-for-mime
624 'gnus-article-display-mime-message
625 "Function to display a MIME message.
626 The function is called from the article buffer."
627 :group 'gnus-article-mime
630 (defcustom gnus-article-display-method-for-traditional
631 'gnus-article-display-traditional-message
632 "*Function to display a traditional message.
633 The function is called from the article buffer."
634 :group 'gnus-article-mime
637 (defcustom gnus-page-delimiter "^\^L"
638 "*Regexp describing what to use as article page delimiters.
639 The default value is \"^\^L\", which is a form linefeed at the
640 beginning of a line."
642 :group 'gnus-article-various)
644 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
645 "*The format specification for the article mode line.
646 See `gnus-summary-mode-line-format' for a closer description.
648 The following additional specs are available:
650 %w The article washing status.
651 %m The number of MIME parts in the article."
653 :group 'gnus-article-various)
655 (defcustom gnus-article-mode-hook nil
656 "*A hook for Gnus article mode."
658 :group 'gnus-article-various)
660 (when (featurep 'xemacs)
661 ;; Extracted from gnus-xmas-define in order to preserve user settings
662 (when (fboundp 'turn-off-scroll-in-place)
663 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
664 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
665 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
667 (defcustom gnus-article-menu-hook nil
668 "*Hook run after the creation of the article mode menu."
670 :group 'gnus-article-various)
672 (defcustom gnus-article-prepare-hook nil
673 "*A hook called after an article has been prepared in the article buffer."
675 :group 'gnus-article-various)
677 (defcustom gnus-copy-article-ignored-headers nil
678 "List of headers to be removed when copying an article.
679 Each element is a regular expression."
680 :version "23.0" ;; No Gnus
681 :type '(repeat regexp)
682 :group 'gnus-article-various)
684 (make-obsolete-variable 'gnus-article-hide-pgp-hook
685 "This variable is obsolete in Gnus 5.10.")
687 (defcustom gnus-article-button-face 'bold
688 "Face used for highlighting buttons in the article buffer.
690 An article button is a piece of text that you can activate by pressing
691 `RET' or `mouse-2' above it."
693 :group 'gnus-article-buttons)
695 (defcustom gnus-article-mouse-face 'highlight
696 "Face used for mouse highlighting in the article buffer.
698 Article buttons will be displayed in this face when the cursor is
701 :group 'gnus-article-buttons)
703 (defcustom gnus-signature-face 'gnus-signature-face
704 "Face used for highlighting a signature in the article buffer.
705 Obsolete; use the face `gnus-signature-face' for customizations instead."
707 :group 'gnus-article-highlight
708 :group 'gnus-article-signature)
710 (defface gnus-signature-face
713 "Face used for highlighting a signature in the article buffer."
714 :group 'gnus-article-highlight
715 :group 'gnus-article-signature)
717 (defface gnus-header-from-face
720 (:foreground "spring green"))
723 (:foreground "red3"))
726 "Face used for displaying from headers."
727 :group 'gnus-article-headers
728 :group 'gnus-article-highlight)
730 (defface gnus-header-subject-face
733 (:foreground "SeaGreen3"))
736 (:foreground "red4"))
738 (:bold t :italic t)))
739 "Face used for displaying subject headers."
740 :group 'gnus-article-headers
741 :group 'gnus-article-highlight)
743 (defface gnus-header-newsgroups-face
746 (:foreground "yellow" :italic t))
749 (:foreground "MidnightBlue" :italic t))
752 "Face used for displaying newsgroups headers.
753 In the default setup this face is only used for crossposted
755 :group 'gnus-article-headers
756 :group 'gnus-article-highlight)
758 (defface gnus-header-name-face
761 (:foreground "SeaGreen"))
764 (:foreground "maroon"))
767 "Face used for displaying header names."
768 :group 'gnus-article-headers
769 :group 'gnus-article-highlight)
771 (defface gnus-header-content-face
774 (:foreground "forest green" :italic t))
777 (:foreground "indianred4" :italic t))
780 "Face used for displaying header content."
781 :group 'gnus-article-headers
782 :group 'gnus-article-highlight)
784 (defcustom gnus-header-face-alist
785 '(("From" nil gnus-header-from-face)
786 ("Subject" nil gnus-header-subject-face)
787 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
788 ("" gnus-header-name-face gnus-header-content-face))
789 "*Controls highlighting of article headers.
791 An alist of the form (HEADER NAME CONTENT).
793 HEADER is a regular expression which should match the name of a
794 header and NAME and CONTENT are either face names or nil.
796 The name of each header field will be displayed using the face
797 specified by the first element in the list where HEADER matches
798 the header name and NAME is non-nil. Similarly, the content will
799 be displayed by the first non-nil matching CONTENT face."
800 :group 'gnus-article-headers
801 :group 'gnus-article-highlight
802 :type '(repeat (list (regexp :tag "Header")
804 (item :tag "skip" nil)
805 (face :value default))
806 (choice :tag "Content"
807 (item :tag "skip" nil)
808 (face :value default)))))
810 (defcustom gnus-article-decode-hook
811 '(article-decode-group-name article-decode-idna-rhs)
812 "*Hook run to decode charsets in articles."
813 :group 'gnus-article-headers
816 (defcustom gnus-display-mime-function 'gnus-display-mime
817 "Function to display MIME articles."
818 :group 'gnus-article-mime
821 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
822 "Function used to decode headers.")
824 (defvar gnus-article-dumbquotes-map
844 "Table for MS-to-Latin1 translation.")
846 (defcustom gnus-ignored-mime-types nil
847 "List of MIME types that should be ignored by Gnus."
849 :group 'gnus-article-mime
850 :type '(repeat regexp))
852 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
853 "List of MIME types that should not be given buttons when rendered inline.
854 See also `gnus-buttonized-mime-types' which may override this variable.
855 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
857 :group 'gnus-article-mime
858 :type '(repeat regexp))
860 (defcustom gnus-buttonized-mime-types nil
861 "List of MIME types that should be given buttons when rendered inline.
862 If set, this variable overrides `gnus-unbuttonized-mime-types'.
863 To see e.g. security buttons you could set this to
864 `(\"multipart/signed\")'.
865 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
867 :group 'gnus-article-mime
868 :type '(repeat regexp))
870 (defcustom gnus-inhibit-mime-unbuttonizing nil
871 "If non-nil, all MIME parts get buttons.
872 When nil (the default value), then some MIME parts do not get buttons,
873 as described by the variables `gnus-buttonized-mime-types' and
874 `gnus-unbuttonized-mime-types'."
876 :group 'gnus-article-mime
879 (defcustom gnus-body-boundary-delimiter "_"
880 "String used to delimit header and body.
881 This variable is used by `gnus-article-treat-body-boundary' which can
882 be controlled by `gnus-treat-body-boundary'."
884 :group 'gnus-article-various
885 :type '(choice (item :tag "None" :value nil)
888 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces"
890 "Defines the location of the faces database.
891 For information on obtaining this database of pretty pictures, please
892 see http://www.cs.indiana.edu/picons/ftp/index.html"
894 :type '(repeat directory)
895 :link '(url-link :tag "download"
896 "http://www.cs.indiana.edu/picons/ftp/index.html")
897 :link '(custom-manual "(gnus)Picons")
900 (defun gnus-picons-installed-p ()
901 "Say whether picons are installed on your machine."
902 (let ((installed nil))
903 (dolist (database gnus-picon-databases)
904 (when (file-exists-p database)
908 (defcustom gnus-article-mime-part-function nil
909 "Function called with a MIME handle as the argument.
910 This is meant for people who want to do something automatic based
911 on parts -- for instance, adding Vcard info to a database."
912 :group 'gnus-article-mime
915 (defcustom gnus-mime-multipart-functions nil
916 "An alist of MIME types to functions to display them."
918 :group 'gnus-article-mime
919 :type '(repeat (cons :format "%v" (string :tag "MIME type") function)))
921 (defcustom gnus-article-date-lapsed-new-header nil
922 "Whether the X-Sent and Date headers can coexist.
923 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
924 either replace the old \"Date:\" header (if this variable is nil), or
925 be added below it (otherwise)."
927 :group 'gnus-article-headers
930 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
931 "Function called with a MIME handle as the argument.
932 This is meant for people who want to view first matched part.
933 For `undisplayed-alternative' (default), the first undisplayed
934 part or alternative part is used. For `undisplayed', the first
935 undisplayed part is used. For a function, the first part which
936 the function return t is used. For nil, the first part is
939 :group 'gnus-article-mime
941 (item :tag "first" :value nil)
942 (item :tag "undisplayed" :value undisplayed)
943 (item :tag "undisplayed or alternative"
944 :value undisplayed-alternative)
947 (defcustom gnus-mime-action-alist
948 '(("save to file" . gnus-mime-save-part)
949 ("save and strip" . gnus-mime-save-part-and-strip)
950 ("delete part" . gnus-mime-delete-part)
951 ("display as text" . gnus-mime-inline-part)
952 ("view the part" . gnus-mime-view-part)
953 ("pipe to command" . gnus-mime-pipe-part)
954 ("toggle display" . gnus-article-press-button)
955 ("toggle display" . gnus-article-view-part-as-charset)
956 ("view as type" . gnus-mime-view-part-as-type)
957 ("view internally" . gnus-mime-view-part-internally)
958 ("view externally" . gnus-mime-view-part-externally))
959 "An alist of actions that run on the MIME attachment."
960 :group 'gnus-article-mime
961 :type '(repeat (cons (string :tag "name")
965 ;;; The treatment variables
968 (defvar gnus-part-display-hook nil
969 "Hook called on parts that are to receive treatment.")
971 (defvar gnus-article-treat-custom
972 '(choice (const :tag "Off" nil)
974 (const :tag "Header" head)
975 (const :tag "Last" last)
976 (const :tag "Mime" mime)
977 (integer :tag "Less")
978 (repeat :tag "Groups" regexp)
979 (sexp :tag "Predicate")))
981 (defvar gnus-article-treat-head-custom
982 '(choice (const :tag "Off" nil)
983 (const :tag "Header" head)))
985 (defvar gnus-article-treat-types '("text/plain")
988 (defvar gnus-inhibit-treatment nil
989 "Whether to inhibit treatment.")
991 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
992 "Highlight the signature.
993 Valid values are nil, t, `head', `last', an integer or a predicate.
994 See Info node `(gnus)Customizing Articles'."
995 :group 'gnus-article-treat
996 :link '(custom-manual "(gnus)Customizing Articles")
997 :type gnus-article-treat-custom)
998 (put 'gnus-treat-highlight-signature 'highlight t)
1000 (defcustom gnus-treat-buttonize 100000
1002 Valid values are nil, t, `head', `last', an integer or a predicate.
1003 See Info node `(gnus)Customizing Articles'."
1004 :group 'gnus-article-treat
1005 :link '(custom-manual "(gnus)Customizing Articles")
1006 :type gnus-article-treat-custom)
1007 (put 'gnus-treat-buttonize 'highlight t)
1009 (defcustom gnus-treat-buttonize-head 'head
1010 "Add buttons to the head.
1011 Valid values are nil, t, `head', `last', an integer or a predicate.
1012 See Info node `(gnus)Customizing Articles' for details."
1013 :group 'gnus-article-treat
1014 :link '(custom-manual "(gnus)Customizing Articles")
1015 :type gnus-article-treat-head-custom)
1016 (put 'gnus-treat-buttonize-head 'highlight t)
1018 (defcustom gnus-treat-emphasize
1019 (and (or window-system
1023 Valid values are nil, t, `head', `last', an integer or a predicate.
1024 See Info node `(gnus)Customizing Articles' for details."
1025 :group 'gnus-article-treat
1026 :link '(custom-manual "(gnus)Customizing Articles")
1027 :type gnus-article-treat-custom)
1028 (put 'gnus-treat-emphasize 'highlight t)
1030 (defcustom gnus-treat-strip-cr nil
1031 "Remove carriage returns.
1032 Valid values are nil, t, `head', `last', an integer or a predicate.
1033 See Info node `(gnus)Customizing Articles' for details."
1035 :group 'gnus-article-treat
1036 :link '(custom-manual "(gnus)Customizing Articles")
1037 :type gnus-article-treat-custom)
1039 (defcustom gnus-treat-unsplit-urls nil
1040 "Remove newlines from within URLs.
1041 Valid values are nil, t, `head', `last', an integer or a predicate.
1042 See Info node `(gnus)Customizing Articles' for details."
1044 :group 'gnus-article-treat
1045 :link '(custom-manual "(gnus)Customizing Articles")
1046 :type gnus-article-treat-custom)
1048 (defcustom gnus-treat-leading-whitespace nil
1049 "Remove leading whitespace in headers.
1050 Valid values are nil, t, `head', `last', an integer or a predicate.
1051 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)
1057 (defcustom gnus-treat-hide-headers 'head
1059 Valid values are nil, t, `head', `last', an integer or a predicate.
1060 See Info node `(gnus)Customizing Articles' for details."
1061 :group 'gnus-article-treat
1062 :link '(custom-manual "(gnus)Customizing Articles")
1063 :type gnus-article-treat-head-custom)
1065 (defcustom gnus-treat-hide-boring-headers nil
1066 "Hide boring headers.
1067 Valid values are nil, t, `head', `last', an integer or a predicate.
1068 See Info node `(gnus)Customizing Articles' for details."
1069 :group 'gnus-article-treat
1070 :link '(custom-manual "(gnus)Customizing Articles")
1071 :type gnus-article-treat-head-custom)
1073 (defcustom gnus-treat-hide-signature nil
1074 "Hide the signature.
1075 Valid values are nil, t, `head', `last', an integer or a predicate.
1076 See Info node `(gnus)Customizing Articles' for details."
1077 :group 'gnus-article-treat
1078 :link '(custom-manual "(gnus)Customizing Articles")
1079 :type gnus-article-treat-custom)
1081 (defcustom gnus-treat-fill-article nil
1083 Valid values are nil, t, `head', `last', an integer or a predicate.
1084 See Info node `(gnus)Customizing Articles' for details."
1085 :group 'gnus-article-treat
1086 :link '(custom-manual "(gnus)Customizing Articles")
1087 :type gnus-article-treat-custom)
1089 (defcustom gnus-treat-hide-citation nil
1091 Valid values are nil, t, `head', `last', an integer or a predicate.
1092 See Info node `(gnus)Customizing Articles' for details."
1093 :group 'gnus-article-treat
1094 :link '(custom-manual "(gnus)Customizing Articles")
1095 :type gnus-article-treat-custom)
1097 (defcustom gnus-treat-hide-citation-maybe nil
1099 Valid values are nil, t, `head', `last', an integer or a predicate.
1100 See Info node `(gnus)Customizing Articles' for details."
1101 :group 'gnus-article-treat
1102 :link '(custom-manual "(gnus)Customizing Articles")
1103 :type gnus-article-treat-custom)
1105 (defcustom gnus-treat-strip-list-identifiers 'head
1106 "Strip list identifiers from `gnus-list-identifiers`.
1107 Valid values are nil, t, `head', `last', an integer or a predicate.
1108 See Info node `(gnus)Customizing Articles' for details."
1110 :group 'gnus-article-treat
1111 :link '(custom-manual "(gnus)Customizing Articles")
1112 :type gnus-article-treat-custom)
1114 (make-obsolete-variable 'gnus-treat-strip-pgp
1115 "This option is obsolete in Gnus 5.10.")
1117 (defcustom gnus-treat-strip-pem nil
1118 "Strip PEM signatures.
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-strip-banner t
1126 "Strip banners from articles.
1127 The banner to be stripped is specified in the `banner' group parameter.
1128 Valid values are nil, t, `head', `last', an integer or a predicate.
1129 See Info node `(gnus)Customizing Articles' for details."
1130 :group 'gnus-article-treat
1131 :link '(custom-manual "(gnus)Customizing Articles")
1132 :type gnus-article-treat-custom)
1134 (defcustom gnus-treat-highlight-headers 'head
1135 "Highlight the headers.
1136 Valid values are nil, t, `head', `last', an integer or a predicate.
1137 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-head-custom)
1141 (put 'gnus-treat-highlight-headers 'highlight t)
1143 (defcustom gnus-treat-highlight-citation t
1144 "Highlight cited text.
1145 Valid values are nil, t, `head', `last', an integer or a predicate.
1146 See Info node `(gnus)Customizing Articles' for details."
1147 :group 'gnus-article-treat
1148 :link '(custom-manual "(gnus)Customizing Articles")
1149 :type gnus-article-treat-custom)
1150 (put 'gnus-treat-highlight-citation 'highlight t)
1152 (defcustom gnus-treat-date-ut nil
1153 "Display the Date in UT (GMT).
1154 Valid values are nil, t, `head', `last', an integer or a predicate.
1155 See Info node `(gnus)Customizing Articles' for details."
1156 :group 'gnus-article-treat
1157 :link '(custom-manual "(gnus)Customizing Articles")
1158 :type gnus-article-treat-head-custom)
1160 (defcustom gnus-treat-date-local nil
1161 "Display the Date in the local timezone.
1162 Valid values are nil, t, `head', `last', an integer or a predicate.
1163 See Info node `(gnus)Customizing Articles' for details."
1164 :group 'gnus-article-treat
1165 :link '(custom-manual "(gnus)Customizing Articles")
1166 :type gnus-article-treat-head-custom)
1168 (defcustom gnus-treat-date-english nil
1169 "Display the Date in a format that can be read aloud in English.
1170 Valid values are nil, t, `head', `last', an integer or a predicate.
1171 See Info node `(gnus)Customizing Articles' for details."
1173 :group 'gnus-article-treat
1174 :link '(custom-manual "(gnus)Customizing Articles")
1175 :type gnus-article-treat-head-custom)
1177 (defcustom gnus-treat-date-lapsed nil
1178 "Display the Date header in a way that says how much time has elapsed.
1179 Valid values are nil, t, `head', `last', an integer or a predicate.
1180 See Info node `(gnus)Customizing Articles' for details."
1181 :group 'gnus-article-treat
1182 :link '(custom-manual "(gnus)Customizing Articles")
1183 :type gnus-article-treat-head-custom)
1185 (defcustom gnus-treat-date-original nil
1186 "Display the date in the original timezone.
1187 Valid values are nil, t, `head', `last', an integer or a predicate.
1188 See Info node `(gnus)Customizing Articles' for details."
1189 :group 'gnus-article-treat
1190 :link '(custom-manual "(gnus)Customizing Articles")
1191 :type gnus-article-treat-head-custom)
1193 (defcustom gnus-treat-date-iso8601 nil
1194 "Display the date in the ISO8601 format.
1195 Valid values are nil, t, `head', `last', an integer or a predicate.
1196 See Info node `(gnus)Customizing Articles' for details."
1198 :group 'gnus-article-treat
1199 :link '(custom-manual "(gnus)Customizing Articles")
1200 :type gnus-article-treat-head-custom)
1202 (defcustom gnus-treat-date-user-defined nil
1203 "Display the date in a user-defined format.
1204 The format is defined by the `gnus-article-time-format' variable.
1205 Valid values are nil, t, `head', `last', an integer or a predicate.
1206 See Info node `(gnus)Customizing Articles' for details."
1207 :group 'gnus-article-treat
1208 :link '(custom-manual "(gnus)Customizing Articles")
1209 :type gnus-article-treat-head-custom)
1211 (defcustom gnus-treat-strip-headers-in-body t
1212 "Strip the X-No-Archive header line from the beginning of the body.
1213 Valid values are nil, t, `head', `last', an integer or a predicate.
1214 See Info node `(gnus)Customizing Articles' for details."
1216 :group 'gnus-article-treat
1217 :link '(custom-manual "(gnus)Customizing Articles")
1218 :type gnus-article-treat-custom)
1220 (defcustom gnus-treat-strip-trailing-blank-lines nil
1221 "Strip trailing blank lines.
1222 Valid values are nil, t, `head', `last', an integer or a predicate.
1223 See Info node `(gnus)Customizing Articles' for details."
1224 :group 'gnus-article-treat
1225 :link '(custom-manual "(gnus)Customizing Articles")
1226 :type gnus-article-treat-custom)
1228 (defcustom gnus-treat-strip-leading-blank-lines nil
1229 "Strip leading blank lines.
1230 Valid values are nil, t, `head', `last', an integer or a predicate.
1231 See Info node `(gnus)Customizing Articles' for details."
1232 :group 'gnus-article-treat
1233 :link '(custom-manual "(gnus)Customizing Articles")
1234 :type gnus-article-treat-custom)
1236 (defcustom gnus-treat-strip-multiple-blank-lines nil
1237 "Strip multiple blank lines.
1238 Valid values are nil, t, `head', `last', an integer or a predicate.
1239 See Info node `(gnus)Customizing Articles' for details."
1240 :group 'gnus-article-treat
1241 :link '(custom-manual "(gnus)Customizing Articles")
1242 :type gnus-article-treat-custom)
1244 (defcustom gnus-treat-unfold-headers 'head
1245 "Unfold folded header lines.
1246 Valid values are nil, t, `head', `last', an integer or a predicate.
1247 See Info node `(gnus)Customizing Articles' for details."
1249 :group 'gnus-article-treat
1250 :link '(custom-manual "(gnus)Customizing Articles")
1251 :type gnus-article-treat-custom)
1253 (defcustom gnus-treat-fold-headers nil
1255 Valid values are nil, t, `head', `last', an integer or a predicate.
1256 See Info node `(gnus)Customizing Articles' for details."
1258 :group 'gnus-article-treat
1259 :link '(custom-manual "(gnus)Customizing Articles")
1260 :type gnus-article-treat-custom)
1262 (defcustom gnus-treat-fold-newsgroups 'head
1263 "Fold the Newsgroups and Followup-To headers.
1264 Valid values are nil, t, `head', `last', an integer or a predicate.
1265 See Info node `(gnus)Customizing Articles' for details."
1267 :group 'gnus-article-treat
1268 :link '(custom-manual "(gnus)Customizing Articles")
1269 :type gnus-article-treat-custom)
1271 (defcustom gnus-treat-overstrike t
1272 "Treat overstrike highlighting.
1273 Valid values are nil, t, `head', `last', an integer or a predicate.
1274 See Info node `(gnus)Customizing Articles' for details."
1275 :group 'gnus-article-treat
1276 :link '(custom-manual "(gnus)Customizing Articles")
1277 :type gnus-article-treat-custom)
1278 (put 'gnus-treat-overstrike 'highlight t)
1280 (defcustom gnus-treat-ansi-sequences (if (locate-library "ansi-color") t)
1281 "Treat ANSI SGR control sequences.
1282 Valid values are nil, t, `head', `last', an integer or a predicate.
1283 See Info node `(gnus)Customizing Articles' for details."
1284 :group 'gnus-article-treat
1285 :link '(custom-manual "(gnus)Customizing Articles")
1286 :type gnus-article-treat-custom)
1288 (make-obsolete-variable 'gnus-treat-display-xface
1289 'gnus-treat-display-x-face)
1291 (defcustom gnus-treat-display-x-face
1292 (and (not noninteractive)
1293 (or (eq gnus-article-x-face-command
1294 'x-face-mule-gnus-article-display-x-face)
1295 (and (fboundp 'image-type-available-p)
1296 (image-type-available-p 'xbm)
1297 (string-match "^0x" (shell-command-to-string "uncompface"))
1298 (executable-find "icontopbm"))
1299 (and (featurep 'xemacs)
1302 "Display X-Face headers.
1303 Valid values are nil, t, `head', `last', an integer or a predicate.
1304 See Info node `(gnus)Customizing Articles' and Info node
1305 `(gnus)X-Face' for details."
1306 :group 'gnus-article-treat
1308 :link '(custom-manual "(gnus)Customizing Articles")
1309 :link '(custom-manual "(gnus)X-Face")
1310 :type gnus-article-treat-head-custom
1311 :set (lambda (symbol value)
1314 (cond ((or (boundp symbol) (get symbol 'saved-value))
1316 ((boundp 'gnus-treat-display-xface)
1318 ** gnus-treat-display-xface is an obsolete variable;\
1319 use gnus-treat-display-x-face instead")
1320 (default-value 'gnus-treat-display-xface))
1321 ((get 'gnus-treat-display-xface 'saved-value)
1323 ** gnus-treat-display-xface is an obsolete variable;\
1324 use gnus-treat-display-x-face instead")
1325 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1328 (put 'gnus-treat-display-x-face 'highlight t)
1330 (defcustom gnus-article-should-use-smiley-mule
1331 (not (or (featurep 'xemacs)
1332 (gnus-image-type-available-p 'xpm)
1333 (gnus-image-type-available-p 'pbm)))
1334 "Non-nil means use `smiley-mule' to show smileys rather than `smiley'.
1335 `smiley-mule' is boundled in BITMAP-MULE package. You can set it to t
1336 even if your Emacs supports images. It has no effect on XEmacs."
1337 :group 'gnus-article-various
1339 :get (lambda (symbol)
1340 (and (not noninteractive)
1341 (default-value symbol)
1342 (not (featurep 'xemacs))
1343 (module-installed-p 'smiley-mule)
1345 :set (lambda (symbol value)
1346 (set-default symbol (and (not noninteractive)
1348 (not (featurep 'xemacs))
1349 (module-installed-p 'smiley-mule)
1352 (defvar gnus-article-smiley-mule-loaded-p nil
1353 "Internal variable used to say whether `smiley-mule' is loaded (whether
1354 smiley functions are not overridden by `smiley').")
1356 (defcustom gnus-treat-display-face
1357 (and (not noninteractive)
1358 (or (and (fboundp 'image-type-available-p)
1359 (image-type-available-p 'png))
1360 (and (featurep 'xemacs)
1363 "Display Face headers.
1364 Valid values are nil, t, `head', `last', an integer or a predicate.
1365 See Info node `(gnus)Customizing Articles' and Info node
1366 `(gnus)X-Face' for details."
1367 :group 'gnus-article-treat
1369 :link '(custom-manual "(gnus)Customizing Articles")
1370 :link '(custom-manual "(gnus)X-Face")
1371 :type gnus-article-treat-head-custom)
1372 (put 'gnus-treat-display-face 'highlight t)
1374 (defcustom gnus-treat-display-smileys
1375 (if (and (not noninteractive)
1376 (or (and (featurep 'xemacs)
1378 (gnus-image-type-available-p 'xpm)
1379 (gnus-image-type-available-p 'pbm)
1380 (and (not (featurep 'xemacs))
1382 (module-installed-p 'smiley-mule))))
1386 Valid values are nil, t, `head', `last', an integer or a predicate.
1387 See Info node `(gnus)Customizing Articles' and Info node
1388 `(gnus)Smileys' for details."
1389 :group 'gnus-article-treat
1391 :link '(custom-manual "(gnus)Customizing Articles")
1392 :link '(custom-manual "(gnus)Smileys")
1393 :type gnus-article-treat-custom)
1394 (put 'gnus-treat-display-smileys 'highlight t)
1396 (defcustom gnus-treat-from-picon
1397 (if (and (gnus-image-type-available-p 'xpm)
1398 (gnus-picons-installed-p))
1400 "Display picons in the From header.
1401 Valid values are nil, t, `head', `last', an integer or a predicate.
1402 See Info node `(gnus)Customizing Articles' and Info node
1403 `(gnus)Picons' for details."
1405 :group 'gnus-article-treat
1407 :link '(custom-manual "(gnus)Customizing Articles")
1408 :link '(custom-manual "(gnus)Picons")
1409 :type gnus-article-treat-head-custom)
1410 (put 'gnus-treat-from-picon 'highlight t)
1412 (defcustom gnus-treat-mail-picon
1413 (if (and (gnus-image-type-available-p 'xpm)
1414 (gnus-picons-installed-p))
1416 "Display picons in To and Cc headers.
1417 Valid values are nil, t, `head', `last', an integer or a predicate.
1418 See Info node `(gnus)Customizing Articles' and Info node
1419 `(gnus)Picons' for details."
1421 :group 'gnus-article-treat
1423 :link '(custom-manual "(gnus)Customizing Articles")
1424 :link '(custom-manual "(gnus)Picons")
1425 :type gnus-article-treat-head-custom)
1426 (put 'gnus-treat-mail-picon 'highlight t)
1428 (defcustom gnus-treat-newsgroups-picon
1429 (if (and (gnus-image-type-available-p 'xpm)
1430 (gnus-picons-installed-p))
1432 "Display picons in the Newsgroups and Followup-To headers.
1433 Valid values are nil, t, `head', `last', an integer or a predicate.
1434 See Info node `(gnus)Customizing Articles' and Info node
1435 `(gnus)Picons' for details."
1437 :group 'gnus-article-treat
1439 :link '(custom-manual "(gnus)Customizing Articles")
1440 :link '(custom-manual "(gnus)Picons")
1441 :type gnus-article-treat-head-custom)
1442 (put 'gnus-treat-newsgroups-picon 'highlight t)
1444 (defcustom gnus-treat-body-boundary
1445 (if (and (eq window-system 'x)
1446 (or gnus-treat-newsgroups-picon
1447 gnus-treat-mail-picon
1448 gnus-treat-from-picon))
1450 "Draw a boundary at the end of the headers.
1451 Valid values are nil and `head'.
1452 See Info node `(gnus)Customizing Articles' for details."
1454 :group 'gnus-article-treat
1455 :link '(custom-manual "(gnus)Customizing Articles")
1456 :type gnus-article-treat-head-custom)
1458 (defcustom gnus-treat-capitalize-sentences nil
1459 "Capitalize sentence-starting words.
1460 Valid values are nil, t, `head', `last', an integer or a predicate.
1461 See Info node `(gnus)Customizing Articles' for details."
1463 :group 'gnus-article-treat
1464 :link '(custom-manual "(gnus)Customizing Articles")
1465 :type gnus-article-treat-custom)
1467 (defcustom gnus-treat-wash-html nil
1469 Valid values are nil, t, `head', `last', an integer or a predicate.
1470 See Info node `(gnus)Customizing Articles' for details."
1472 :group 'gnus-article-treat
1473 :link '(custom-manual "(gnus)Customizing Articles")
1474 :type gnus-article-treat-custom)
1476 (defcustom gnus-treat-fill-long-lines nil
1478 Valid values are nil, t, `head', `last', an integer or a predicate.
1479 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-custom)
1484 (defcustom gnus-treat-play-sounds nil
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-decode-article-as-default-mime-charset nil
1494 "Decode an article as `default-mime-charset'. For instance, if you want to
1495 attempt to decode an article even if the value of `gnus-show-mime' is nil,
1496 you could set this variable to something like: nil for don't decode, t for
1497 decode the body, '(or header t) for the whole article, etc."
1498 :group 'gnus-article-treat
1499 :type '(radio (const :tag "Off" nil)
1500 (const :tag "Decode body" t)
1501 (const :tag "Decode all" (or head t))))
1503 (defcustom gnus-treat-translate nil
1504 "Translate articles from one language to another.
1505 Valid values are nil, t, `head', `last', an integer or a predicate.
1506 See Info node `(gnus)Customizing Articles' for details."
1508 :group 'gnus-article-treat
1509 :link '(custom-manual "(gnus)Customizing Articles")
1510 :type gnus-article-treat-custom)
1512 (defcustom gnus-treat-x-pgp-sig nil
1514 To automatically treat X-PGP-Sig, set it to head.
1515 Valid values are nil, t, `head', `last', an integer or a predicate.
1516 See Info node `(gnus)Customizing Articles' for details."
1518 :group 'gnus-article-treat
1519 :group 'mime-security
1520 :type gnus-article-treat-custom)
1522 (defcustom gnus-treat-monafy nil
1523 "Display body part with mona font.
1524 Valid values are nil, t, `head', `last', an integer or a predicate.
1525 See Info node `(gnus)Customizing Articles' for details."
1526 :group 'gnus-article-treat
1527 :group 'mime-security
1528 :link '(custom-manual "(gnus)Customizing Articles")
1529 :type gnus-article-treat-custom)
1531 (defvar gnus-article-encrypt-protocol-alist
1532 '(("PGP" . mml2015-self-encrypt)))
1534 ;; Set to nil if more than one protocol added to
1535 ;; gnus-article-encrypt-protocol-alist.
1536 (defcustom gnus-article-encrypt-protocol "PGP"
1537 "The protocol used for encrypt articles.
1538 It is a string, such as \"PGP\". If nil, ask user."
1541 :group 'mime-security)
1543 (defvar gnus-article-wash-function nil
1544 "Function used for converting HTML into text.")
1546 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1547 (mm-coding-system-p 'utf-8)
1548 (executable-find idna-program))
1549 "Whether IDNA decoding of headers is used when viewing messages.
1550 This requires GNU Libidn, and by default only enabled if it is found."
1552 :group 'gnus-article-headers
1555 (defcustom gnus-article-over-scroll nil
1556 "If non-nil, allow scrolling the article buffer even when there no more text."
1558 :group 'gnus-article
1561 ;;; Internal variables
1563 (defvar gnus-english-month-names
1564 '("January" "February" "March" "April" "May" "June" "July" "August"
1565 "September" "October" "November" "December"))
1567 (defvar gnus-button-regexp nil)
1568 (defvar gnus-button-marker-list nil)
1569 ;; Regexp matching any of the regexps from `gnus-button-alist'.
1571 (defvar gnus-button-last nil)
1572 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
1574 (defvar article-goto-body-goes-to-point-min-p nil)
1575 (defvar gnus-article-wash-types nil)
1576 (defvar gnus-article-emphasis-alist nil)
1577 (defvar gnus-article-image-alist nil)
1579 (defvar gnus-article-mime-handle-alist-1 nil)
1580 (defvar gnus-treatment-function-alist
1581 '((gnus-treat-decode-article-as-default-mime-charset
1582 gnus-article-decode-article-as-default-mime-charset)
1583 (gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1584 (gnus-treat-monafy gnus-article-monafy)
1585 (gnus-treat-strip-banner gnus-article-strip-banner)
1586 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1587 (gnus-treat-buttonize gnus-article-add-buttons)
1588 (gnus-treat-fill-article gnus-article-fill-cited-article)
1589 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1590 (gnus-treat-strip-cr gnus-article-remove-cr)
1591 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1592 (gnus-treat-date-ut gnus-article-date-ut)
1593 (gnus-treat-date-local gnus-article-date-local)
1594 (gnus-treat-date-english gnus-article-date-english)
1595 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1596 (gnus-treat-date-original gnus-article-date-original)
1597 (gnus-treat-date-user-defined gnus-article-date-user)
1598 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1599 (gnus-treat-display-face gnus-article-display-face)
1600 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1601 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1602 (gnus-treat-hide-signature gnus-article-hide-signature)
1603 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1604 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1605 (gnus-treat-strip-pem gnus-article-hide-pem)
1606 (gnus-treat-from-picon gnus-treat-from-picon)
1607 (gnus-treat-mail-picon gnus-treat-mail-picon)
1608 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1609 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1610 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1611 (gnus-treat-strip-trailing-blank-lines
1612 gnus-article-remove-trailing-blank-lines)
1613 (gnus-treat-strip-leading-blank-lines
1614 gnus-article-strip-leading-blank-lines)
1615 (gnus-treat-strip-multiple-blank-lines
1616 gnus-article-strip-multiple-blank-lines)
1617 (gnus-treat-overstrike gnus-article-treat-overstrike)
1618 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences)
1619 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1620 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1621 ;; Displaying X-Face should be done after unfolding headers
1622 ;; to protect bitmap lines.
1623 (gnus-treat-display-x-face gnus-article-display-x-face)
1624 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1625 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1626 (gnus-treat-display-smileys gnus-treat-smiley)
1627 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1628 (gnus-treat-wash-html gnus-article-wash-html)
1629 (gnus-treat-emphasize gnus-article-emphasize)
1630 (gnus-treat-hide-citation gnus-article-hide-citation)
1631 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1632 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1633 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1634 (gnus-treat-play-sounds gnus-earcon-display)))
1636 (defvar gnus-article-mime-handle-alist nil)
1637 (defvar article-lapsed-timer nil)
1638 (defvar gnus-article-current-summary nil)
1640 (defvar gnus-article-mode-syntax-table
1641 (let ((table (copy-syntax-table text-mode-syntax-table)))
1642 ;; This causes the citation match run O(2^n).
1643 ;; (modify-syntax-entry ?- "w" table)
1644 (modify-syntax-entry ?> ")<" table)
1645 (modify-syntax-entry ?< "(>" table)
1646 ;; make M-. in article buffers work for `foo' strings
1647 (modify-syntax-entry ?' " " table)
1648 (modify-syntax-entry ?` " " table)
1650 "Syntax table used in article mode buffers.
1651 Initialized from `text-mode-syntax-table.")
1653 (defvar gnus-save-article-buffer nil)
1655 (defvar gnus-article-mode-line-format-alist
1656 (nconc '((?w (gnus-article-wash-status) ?s)
1657 (?m (gnus-article-mime-part-status) ?s))
1658 gnus-summary-mode-line-format-alist))
1660 (defvar gnus-number-of-articles-to-be-saved nil)
1662 (defvar gnus-inhibit-hiding nil)
1664 (defvar gnus-article-edit-mode nil)
1666 ;;; Macros for dealing with the article buffer.
1668 (defmacro gnus-with-article-headers (&rest forms)
1670 (set-buffer gnus-article-buffer)
1672 (let ((inhibit-read-only t)
1673 (inhibit-point-motion-hooks t)
1674 (case-fold-search t))
1675 (article-narrow-to-head)
1678 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1679 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1681 (defmacro gnus-with-article-buffer (&rest forms)
1683 (set-buffer gnus-article-buffer)
1684 (let ((inhibit-read-only t))
1687 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1688 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1690 (defun gnus-article-goto-header (header)
1691 "Go to HEADER, which is a regular expression."
1692 (re-search-forward (concat "^\\(" header "\\):") nil t))
1694 (defsubst gnus-article-hide-text (b e props)
1695 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1696 (gnus-add-text-properties-when 'article-type nil b e props)
1697 (when (memq 'intangible props)
1699 (max (1- b) (point-min))
1700 b 'intangible (cddr (memq 'intangible props)))))
1702 (defsubst gnus-article-unhide-text (b e)
1703 "Remove hidden text properties from region between B and E."
1704 (remove-text-properties b e gnus-hidden-properties)
1705 (when (memq 'intangible gnus-hidden-properties)
1706 (put-text-property (max (1- b) (point-min))
1707 b 'intangible nil)))
1709 (defun gnus-article-hide-text-type (b e type)
1710 "Hide text of TYPE between B and E."
1711 (gnus-add-wash-type type)
1712 (gnus-article-hide-text
1713 b e (cons 'article-type (cons type gnus-hidden-properties))))
1715 (defun gnus-article-unhide-text-type (b e type)
1716 "Unhide text of TYPE between B and E."
1717 (gnus-delete-wash-type type)
1718 (remove-text-properties
1719 b e (cons 'article-type (cons type gnus-hidden-properties)))
1720 (when (memq 'intangible gnus-hidden-properties)
1721 (put-text-property (max (1- b) (point-min))
1722 b 'intangible nil)))
1724 (defun gnus-article-hide-text-of-type (type)
1725 "Hide text of TYPE in the current buffer."
1727 (let ((b (point-min))
1729 (while (setq b (text-property-any b e 'article-type type))
1730 (add-text-properties b (incf b) gnus-hidden-properties)))))
1732 (defun gnus-article-delete-text-of-type (type)
1733 "Delete text of TYPE in the current buffer."
1735 (let ((b (point-min)))
1736 (while (setq b (text-property-any b (point-max) 'article-type type))
1738 b (or (text-property-not-all b (point-max) 'article-type type)
1741 (defun gnus-article-delete-invisible-text ()
1742 "Delete all invisible text in the current buffer."
1744 (let ((b (point-min)))
1745 (while (setq b (text-property-any b (point-max) 'invisible t))
1747 b (or (text-property-not-all b (point-max) 'invisible t)
1750 (defun gnus-article-text-type-exists-p (type)
1751 "Say whether any text of type TYPE exists in the buffer."
1752 (text-property-any (point-min) (point-max) 'article-type type))
1754 (defsubst gnus-article-header-rank ()
1755 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1756 (let ((list gnus-sorted-header-list)
1759 (if (looking-at (car list))
1761 (setq list (cdr list))
1765 (defun article-hide-headers (&optional arg delete)
1766 "Hide unwanted headers and possibly sort them as well."
1767 (interactive (gnus-article-hidden-arg))
1768 ;; Lars said that this function might be inhibited.
1769 (if (gnus-article-check-hidden-text 'headers arg)
1771 ;; Show boring headers as well.
1772 (gnus-article-show-hidden-text 'boring-headers)
1773 (when (eq 1 (point-min))
1774 (set-window-start (get-buffer-window (current-buffer)) 1)))
1775 (unless gnus-inhibit-hiding
1776 (let ((inhibit-read-only t)
1777 (case-fold-search t)
1778 (max (1+ (length gnus-sorted-header-list)))
1779 (inhibit-point-motion-hooks t)
1780 (cur (current-buffer))
1781 ignored visible beg)
1783 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1784 ;; group parameters, so we should go to the summary buffer.
1787 (progn (set-buffer gnus-summary-buffer) t)
1789 (setq ignored (when (not gnus-visible-headers)
1790 (cond ((stringp gnus-ignored-headers)
1791 gnus-ignored-headers)
1792 ((listp gnus-ignored-headers)
1793 (mapconcat 'identity
1794 gnus-ignored-headers
1796 visible (cond ((stringp gnus-visible-headers)
1797 gnus-visible-headers)
1798 ((and gnus-visible-headers
1799 (listp gnus-visible-headers))
1800 (mapconcat 'identity
1801 gnus-visible-headers
1805 ;; First we narrow to just the headers.
1806 (article-narrow-to-head)
1807 ;; Hide any "From " lines at the beginning of (mail) articles.
1808 (while (looking-at "From ")
1812 (delete-region (point-min) (point))
1813 (gnus-article-hide-text (point-min) (point)
1814 (nconc (list 'article-type 'headers)
1815 gnus-hidden-properties))))
1816 ;; Then treat the rest of the header lines.
1817 ;; Then we use the two regular expressions
1818 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1819 ;; select which header lines is to remain visible in the
1821 (while (re-search-forward "^[^ \t:]*:" nil t)
1823 ;; Mark the rank of the header.
1825 (point) (1+ (point)) 'message-rank
1826 (if (or (and visible (looking-at visible))
1828 (not (looking-at ignored))))
1829 (gnus-article-header-rank)
1832 (message-sort-headers-1)
1833 (when (setq beg (text-property-any
1834 (point-min) (point-max) 'message-rank (+ 2 max)))
1835 ;; We delete or make invisible the unwanted headers.
1836 (gnus-add-wash-type 'headers)
1839 (add-text-properties
1840 (point-min) (+ 5 (point-min))
1841 '(article-type headers dummy-invisible t))
1842 (delete-region beg (point-max)))
1843 (gnus-article-hide-text-type beg (point-max) 'headers)))))))))
1845 (defun article-hide-boring-headers (&optional arg)
1846 "Toggle hiding of headers that aren't very interesting.
1847 If given a negative prefix, always show; if given a positive prefix,
1849 (interactive (gnus-article-hidden-arg))
1850 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1851 (not gnus-show-all-headers))
1854 (let ((inhibit-read-only t)
1855 (inhibit-point-motion-hooks t))
1856 (article-narrow-to-head)
1857 (dolist (elem gnus-boring-article-headers)
1858 (goto-char (point-min))
1860 ;; Hide empty headers.
1862 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1864 (gnus-article-hide-text-type
1868 (if (re-search-forward "^[^ \t]" nil t)
1872 ;; Hide boring Newsgroups header.
1873 ((eq elem 'newsgroups)
1874 (when (gnus-string-equal
1875 (gnus-fetch-field "newsgroups")
1876 (gnus-group-real-name
1877 (if (boundp 'gnus-newsgroup-name)
1880 (gnus-article-hide-header "newsgroups")))
1881 ((eq elem 'to-address)
1882 (let ((to (message-fetch-field "to"))
1884 (gnus-parameter-to-address
1885 (if (boundp 'gnus-newsgroup-name)
1886 gnus-newsgroup-name ""))))
1887 (when (and to to-address
1890 ;; only one address in To
1891 (nth 1 (mail-extract-address-components to))
1893 (gnus-article-hide-header "to"))))
1895 (let ((to (message-fetch-field "to"))
1897 (gnus-parameter-to-list
1898 (if (boundp 'gnus-newsgroup-name)
1899 gnus-newsgroup-name ""))))
1900 (when (and to to-list
1903 ;; only one address in To
1904 (nth 1 (mail-extract-address-components to))
1906 (gnus-article-hide-header "to"))))
1908 (let ((cc (message-fetch-field "cc"))
1910 (gnus-parameter-to-list
1911 (if (boundp 'gnus-newsgroup-name)
1912 gnus-newsgroup-name ""))))
1913 (when (and cc to-list
1916 ;; only one address in CC
1917 (nth 1 (mail-extract-address-components cc))
1919 (gnus-article-hide-header "cc"))))
1920 ((eq elem 'followup-to)
1921 (when (gnus-string-equal
1922 (message-fetch-field "followup-to")
1923 (message-fetch-field "newsgroups"))
1924 (gnus-article-hide-header "followup-to")))
1925 ((eq elem 'reply-to)
1926 (if (gnus-group-find-parameter
1927 gnus-newsgroup-name 'broken-reply-to)
1928 (gnus-article-hide-header "reply-to")
1929 (let ((from (message-fetch-field "from"))
1930 (reply-to (message-fetch-field "reply-to")))
1937 (lambda (x) (downcase (cadr x)))
1938 (mail-extract-address-components from t))
1941 (lambda (x) (downcase (cadr x)))
1942 (mail-extract-address-components reply-to t))
1944 (gnus-article-hide-header "reply-to")))))
1946 (let ((date (message-fetch-field "date")))
1948 (< (days-between (current-time-string) date)
1950 (gnus-article-hide-header "date"))))
1952 (let ((to (message-fetch-field "to"))
1953 (cc (message-fetch-field "cc")))
1954 (when (> (length to) 1024)
1955 (gnus-article-hide-header "to"))
1956 (when (> (length cc) 1024)
1957 (gnus-article-hide-header "cc"))))
1961 (goto-char (point-min))
1962 (while (re-search-forward "^to:" nil t)
1963 (setq to-count (1+ to-count)))
1964 (when (> to-count 1)
1965 (while (> to-count 0)
1966 (goto-char (point-min))
1968 (re-search-forward "^to:" nil nil to-count)
1970 (narrow-to-region (point) (point-max))
1971 (gnus-article-hide-header "to"))
1972 (setq to-count (1- to-count))))
1973 (goto-char (point-min))
1974 (while (re-search-forward "^cc:" nil t)
1975 (setq cc-count (1+ cc-count)))
1976 (when (> cc-count 1)
1977 (while (> cc-count 0)
1978 (goto-char (point-min))
1980 (re-search-forward "^cc:" nil nil cc-count)
1982 (narrow-to-region (point) (point-max))
1983 (gnus-article-hide-header "cc"))
1984 (setq cc-count (1- cc-count)))))))))))))
1986 (defun gnus-article-hide-header (header)
1988 (goto-char (point-min))
1989 (when (re-search-forward (concat "^" header ":") nil t)
1990 (gnus-article-hide-text-type
1994 (if (re-search-forward "^[^ \t]" nil t)
1999 (defvar gnus-article-normalized-header-length 40
2000 "Length of normalized headers.")
2002 (defun article-normalize-headers ()
2003 "Make all header lines 40 characters long."
2005 (let ((inhibit-read-only t)
2009 (article-narrow-to-head)
2012 ((< (setq column (- (point-at-eol) (point)))
2013 gnus-article-normalized-header-length)
2015 (insert (make-string
2016 (- gnus-article-normalized-header-length column)
2018 ((> column gnus-article-normalized-header-length)
2019 (gnus-put-text-property
2021 (forward-char gnus-article-normalized-header-length)
2028 (forward-line 1))))))
2030 (defun article-treat-dumbquotes ()
2031 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
2032 Note that this function guesses whether a character is a sm*rtq**t* or
2033 not, so it should only be used interactively.
2035 Sm*rtq**t*s are M****s***'s unilateral extension to the
2036 iso-8859-1 character map in an attempt to provide more quoting
2037 characters. If you see something like \\222 or \\264 where
2038 you're expecting some kind of apostrophe or quotation mark, then
2041 (article-translate-strings gnus-article-dumbquotes-map))
2043 (defun article-translate-characters (from to)
2044 "Translate all characters in the body of the article according to FROM and TO.
2045 FROM is a string of characters to translate from; to is a string of
2046 characters to translate to."
2048 (when (article-goto-body)
2049 (let ((inhibit-read-only t)
2050 (x (make-string 225 ?x))
2052 (while (< (incf i) (length x))
2055 (while (< i (length from))
2056 (aset x (aref from i) (aref to i))
2058 (translate-region (point) (point-max) x)))))
2060 (defun article-translate-strings (map)
2061 "Translate all string in the body of the article according to MAP.
2062 MAP is an alist where the elements are on the form (\"from\" \"to\")."
2064 (when (article-goto-body)
2065 (let ((inhibit-read-only t))
2068 (while (search-forward (car elem) nil t)
2069 (replace-match (cadr elem)))))))))
2071 (defun article-treat-overstrike ()
2072 "Translate overstrikes into bold text."
2075 (when (article-goto-body)
2076 (let ((inhibit-read-only t))
2077 (while (search-forward "\b" nil t)
2078 (let ((next (char-after))
2082 previous (char-after))
2086 ;; We do the boldification/underlining by hiding the
2087 ;; overstrikes and putting the proper text property
2091 (gnus-article-hide-text-type start (point) 'overstrike)
2092 (put-text-property (point) end 'face 'bold))
2094 (gnus-article-hide-text-type
2095 (1- (point)) (1+ (point)) 'overstrike)
2097 start (1- (point)) 'face 'underline))
2099 (gnus-article-hide-text-type start (point) 'overstrike)
2101 (point) end 'face 'underline)))))))))
2103 (defun article-treat-ansi-sequences ()
2104 "Translate ANSI SGR control sequences into overlays or extents."
2107 (when (article-goto-body)
2108 (let ((inhibit-read-only t))
2109 (ansi-color-apply-on-region (point) (point-max))))))
2111 (defun gnus-article-treat-unfold-headers ()
2112 "Unfold folded message headers.
2113 Only the headers that fit into the current window width will be
2116 (gnus-with-article-headers
2120 (mail-header-narrow-to-field)
2121 (let ((header (buffer-string)))
2124 (goto-char (point-min))
2125 (while (re-search-forward "\n[\t ]" nil t)
2126 (replace-match " " t t)))
2127 (setq length (- (point-max) (point-min) 1)))
2128 (when (< length (window-width))
2129 (while (re-search-forward "\n[\t ]" nil t)
2130 (replace-match " " t t)))
2131 (goto-char (point-max)))))))
2133 (defun gnus-article-treat-fold-headers ()
2134 "Fold message headers."
2136 (gnus-with-article-headers
2139 (mail-header-narrow-to-field)
2140 (mail-header-fold-field)
2141 (goto-char (point-max))))))
2143 (defun gnus-treat-smiley ()
2144 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2146 (unless (featurep 'xemacs)
2147 (when (and (not gnus-article-should-use-smiley-mule)
2148 gnus-article-smiley-mule-loaded-p)
2149 (load "smiley" nil t)
2150 (setq gnus-article-smiley-mule-loaded-p nil))
2151 (when (and gnus-article-should-use-smiley-mule
2152 (not gnus-article-smiley-mule-loaded-p))
2153 (load "smiley-mule" nil t)
2154 (setq gnus-article-smiley-mule-loaded-p t)))
2155 (gnus-with-article-buffer
2156 (if (memq 'smiley gnus-article-wash-types)
2157 (gnus-delete-images 'smiley)
2159 (let ((images (smiley-region (point) (point-max))))
2161 (gnus-add-wash-type 'smiley)
2162 (dolist (image images)
2163 (gnus-add-image 'smiley image)))))))
2165 (defun gnus-article-remove-images ()
2166 "Remove all images from the article buffer."
2168 (gnus-with-article-buffer
2169 (dolist (elem gnus-article-image-alist)
2170 (gnus-delete-images (car elem)))))
2172 (defun gnus-article-treat-fold-newsgroups ()
2173 "Unfold folded message headers.
2174 Only the headers that fit into the current window width will be
2177 (gnus-with-article-headers
2178 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2180 (mail-header-narrow-to-field)
2181 (while (re-search-forward ", *" nil t)
2182 (replace-match ", " t t))
2183 (mail-header-fold-field)
2184 (goto-char (point-max))))))
2186 (defun gnus-article-treat-body-boundary ()
2187 "Place a boundary line at the end of the headers."
2189 (when (and gnus-body-boundary-delimiter
2190 (> (length gnus-body-boundary-delimiter) 0))
2191 (gnus-with-article-headers
2192 (goto-char (point-max))
2193 (let ((start (point)))
2194 (insert "X-Boundary: ")
2195 (gnus-add-text-properties start (point) '(invisible t intangible t))
2197 (while (>= (1- (window-width)) (length str))
2198 (setq str (concat str gnus-body-boundary-delimiter)))
2199 (substring str 0 (1- (window-width))))
2201 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2203 (defun article-fill-long-lines ()
2204 "Fill lines that are wider than the window width."
2207 (let ((inhibit-read-only t)
2208 (width (window-width (get-buffer-window (current-buffer)))))
2211 (let ((adaptive-fill-mode nil)) ;Why? -sm
2214 (when (>= (current-column) (min fill-column width))
2215 (narrow-to-region (min (1+ (point)) (point-max))
2217 (let ((goback (point-marker)))
2218 (fill-paragraph nil)
2219 (goto-char (marker-position goback)))
2221 (forward-line 1)))))))
2223 (defun article-capitalize-sentences ()
2224 "Capitalize the first word in each sentence."
2227 (let ((inhibit-read-only t)
2228 (paragraph-start "^[\n\^L]"))
2232 (forward-sentence)))))
2234 (defun article-remove-cr ()
2235 "Remove trailing CRs and then translate remaining CRs into LFs."
2238 (let ((inhibit-read-only t))
2239 (goto-char (point-min))
2240 (while (re-search-forward "\r+$" nil t)
2241 (replace-match "" t t))
2242 (goto-char (point-min))
2243 (while (search-forward "\r" nil t)
2244 (replace-match "\n" t t)))))
2246 (defun article-remove-trailing-blank-lines ()
2247 "Remove all trailing blank lines from the article."
2250 (let ((inhibit-read-only t))
2251 (goto-char (point-max))
2255 (while (and (not (bobp))
2256 (looking-at "^[ \t]*$")
2257 (not (gnus-annotation-in-region-p
2258 (point) (point-at-eol))))
2264 (defvar gnus-face-properties-alist))
2266 (defun article-display-face ()
2267 "Display any Face headers in the header."
2269 (let ((wash-face-p buffer-read-only))
2270 (gnus-with-article-headers
2271 ;; When displaying parts, this function can be called several times on
2272 ;; the same article, without any intended toggle semantic (as typing `W
2273 ;; D d' would have). So face deletion must occur only when we come from
2274 ;; an interactive command, that is when the *Article* buffer is
2276 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2277 (gnus-delete-images 'face)
2280 (when (and wash-face-p
2282 (goto-char (point-min))
2283 (not (re-search-forward "^Face:[\t ]*" nil t)))
2284 (gnus-buffer-live-p gnus-original-article-buffer))
2285 (set-buffer gnus-original-article-buffer))
2287 (mail-narrow-to-head)
2288 (while (gnus-article-goto-header "Face")
2289 (setq faces (nconc faces (list (mail-header-field-value)))))))
2290 (dolist (face faces)
2291 (let ((png (gnus-convert-face-to-png face))
2295 (apply 'gnus-create-image png 'png t
2296 (cdr (assq 'png gnus-face-properties-alist))))
2297 (gnus-article-goto-header "from")
2299 (insert "From: [no `from' set]\n")
2301 (gnus-add-wash-type 'face)
2302 (gnus-add-image 'face image)
2303 (gnus-put-image image nil 'face))))))
2306 (defun article-display-x-face (&optional force)
2307 "Look for an X-Face header and display it if present."
2308 (interactive (list 'force))
2309 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2310 (gnus-with-article-headers
2311 ;; Delete the old process, if any.
2312 (when (process-status "article-x-face")
2313 (delete-process "article-x-face"))
2314 ;; See the comment in `article-display-face'.
2315 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2316 ;; We have already displayed X-Faces, so we remove them
2318 (gnus-delete-images 'xface)
2320 (let (x-faces from face)
2322 (when (and wash-face-p
2324 (goto-char (point-min))
2325 (not (re-search-forward
2326 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2327 (gnus-buffer-live-p gnus-original-article-buffer))
2328 ;; If type `W f', use gnus-original-article-buffer,
2329 ;; otherwise use the current buffer because displaying
2330 ;; RFC822 parts calls this function too.
2331 (set-buffer gnus-original-article-buffer))
2333 (mail-narrow-to-head)
2334 (while (gnus-article-goto-header "X-Face")
2335 (push (mail-header-field-value) x-faces))
2336 (setq from (message-fetch-field "from"))))
2337 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2338 ;; single external face.
2339 (when (stringp gnus-article-x-face-command)
2340 (setq x-faces (list (car x-faces))))
2341 (while (and (setq face (pop x-faces))
2342 gnus-article-x-face-command
2344 ;; Check whether this face is censored.
2345 (not gnus-article-x-face-too-ugly)
2346 (and gnus-article-x-face-too-ugly from
2347 (not (string-match gnus-article-x-face-too-ugly
2349 ;; We display the face.
2350 (cond ((stringp gnus-article-x-face-command)
2351 ;; The command is a string, so we interpret the command
2352 ;; as a, well, command, and fork it off.
2353 (let ((process-connection-type nil))
2354 (process-kill-without-query
2356 "article-x-face" nil shell-file-name
2357 shell-command-switch gnus-article-x-face-command))
2360 (process-send-region "article-x-face"
2361 (point-min) (point-max)))
2362 (process-send-eof "article-x-face")))
2363 ((functionp gnus-article-x-face-command)
2364 ;; The command is a lisp function, so we call it.
2365 (funcall gnus-article-x-face-command face))
2367 (error "%s is not a function"
2368 gnus-article-x-face-command)))))))))
2370 (defun article-decode-mime-words ()
2371 "Decode all MIME-encoded words in the article."
2373 (gnus-with-article-buffer
2374 (let ((inhibit-point-motion-hooks t)
2375 (mail-parse-charset gnus-newsgroup-charset)
2376 (mail-parse-ignored-charsets
2377 (with-current-buffer gnus-summary-buffer
2378 gnus-newsgroup-ignored-charsets)))
2379 (mail-decode-encoded-word-region (point-min) (point-max)))))
2381 (defun article-decode-charset (&optional prompt)
2382 "Decode charset-encoded text in the article.
2383 If PROMPT (the prefix), prompt for a coding system to use."
2385 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2386 (inhibit-read-only t)
2387 (mail-parse-charset gnus-newsgroup-charset)
2388 (mail-parse-ignored-charsets
2389 (save-excursion (condition-case nil
2390 (set-buffer gnus-summary-buffer)
2392 gnus-newsgroup-ignored-charsets))
2393 ct cte ctl charset format)
2396 (article-narrow-to-head)
2397 (setq ct (message-fetch-field "Content-Type" t)
2398 cte (message-fetch-field "Content-Transfer-Encoding" t)
2399 ctl (and ct (ignore-errors
2400 (mail-header-parse-content-type ct)))
2403 (mm-read-coding-system "Charset to decode: "))
2405 (mail-content-type-get ctl 'charset)))
2406 format (and ctl (mail-content-type-get ctl 'format)))
2408 (setq cte (mail-header-strip cte)))
2409 (if (and ctl (not (string-match "/" (car ctl))))
2411 (goto-char (point-max)))
2414 (narrow-to-region (point) (point-max))
2415 (when (and (eq mail-parse-charset 'gnus-decoded)
2416 (eq (mm-body-7-or-8) '8bit))
2417 ;; The text code could have been decoded.
2418 (setq charset mail-parse-charset))
2419 (when (and (or (not ctl)
2420 (equal (car ctl) "text/plain"))
2421 (not format)) ;; article with format will decode later.
2423 charset (and cte (intern (downcase
2424 (gnus-strip-whitespace cte))))
2427 (defun article-decode-encoded-words ()
2428 "Remove encoded-word encoding from headers."
2429 (let ((charset (save-excursion
2430 (set-buffer gnus-summary-buffer)
2431 default-mime-charset))
2432 (inhibit-read-only t))
2433 (mime-decode-header-in-buffer charset)))
2435 (defun article-decode-group-name ()
2436 "Decode group names in `Newsgroups:'."
2437 (let ((inhibit-point-motion-hooks t)
2438 (inhibit-read-only t)
2439 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2440 (when (and (or gnus-group-name-charset-method-alist
2441 gnus-group-name-charset-group-alist)
2442 (gnus-buffer-live-p gnus-original-article-buffer))
2444 (article-narrow-to-head)
2445 (with-current-buffer gnus-original-article-buffer
2446 (goto-char (point-min)))
2447 (while (re-search-forward
2448 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2449 (replace-match (save-match-data
2450 (gnus-decode-newsgroups
2451 ;; XXX how to use data in article buffer?
2452 (with-current-buffer gnus-original-article-buffer
2454 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2457 gnus-newsgroup-name method))
2459 (goto-char (point-min))
2460 (with-current-buffer gnus-original-article-buffer
2461 (goto-char (point-min)))
2462 (while (re-search-forward
2463 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2464 (replace-match (save-match-data
2465 (gnus-decode-newsgroups
2466 ;; XXX how to use data in article buffer?
2467 (with-current-buffer gnus-original-article-buffer
2469 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2472 gnus-newsgroup-name method))
2475 (autoload 'idna-to-unicode "idna")
2477 (defun article-decode-idna-rhs ()
2478 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2481 (let ((inhibit-point-motion-hooks t)
2482 (inhibit-read-only t))
2483 (article-narrow-to-head)
2484 (goto-char (point-min))
2485 (while (re-search-forward "@.*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2487 (when (save-match-data
2488 (and (setq ace (match-string 1))
2490 (and (re-search-backward "^[^ \t]" nil t)
2491 (looking-at "From\\|To\\|Cc")))
2492 (setq unicode (idna-to-unicode ace))))
2493 (unless (string= ace unicode)
2494 (replace-match unicode nil nil nil 1)))))))))
2496 (defun article-de-quoted-unreadable (&optional force read-charset)
2497 "Translate a quoted-printable-encoded article.
2498 If FORCE, decode the article whether it is marked as quoted-printable
2500 If READ-CHARSET, ask for a coding system."
2501 (interactive (list 'force current-prefix-arg))
2503 (let ((inhibit-read-only t) type charset)
2504 (if (gnus-buffer-live-p gnus-original-article-buffer)
2505 (with-current-buffer gnus-original-article-buffer
2507 (gnus-fetch-field "content-transfer-encoding"))
2508 (let* ((ct (gnus-fetch-field "content-type"))
2511 (mail-header-parse-content-type ct)))))
2512 (setq charset (and ctl
2513 (mail-content-type-get ctl 'charset)))
2514 (if (stringp charset)
2515 (setq charset (intern (downcase charset)))))))
2517 (setq charset (mm-read-coding-system "Charset: " charset)))
2519 (setq charset gnus-newsgroup-charset))
2521 (and type (let ((case-fold-search t))
2522 (string-match "quoted-printable" type))))
2524 (quoted-printable-decode-region
2525 (point) (point-max) (mm-charset-to-coding-system charset))))))
2527 (defun article-de-base64-unreadable (&optional force read-charset)
2528 "Translate a base64 article.
2529 If FORCE, decode the article whether it is marked as base64 not.
2530 If READ-CHARSET, ask for a coding system."
2531 (interactive (list 'force current-prefix-arg))
2533 (let ((inhibit-read-only t) type charset)
2534 (if (gnus-buffer-live-p gnus-original-article-buffer)
2535 (with-current-buffer gnus-original-article-buffer
2537 (gnus-fetch-field "content-transfer-encoding"))
2538 (let* ((ct (gnus-fetch-field "content-type"))
2541 (mail-header-parse-content-type ct)))))
2542 (setq charset (and ctl
2543 (mail-content-type-get ctl 'charset)))
2544 (if (stringp charset)
2545 (setq charset (intern (downcase charset)))))))
2547 (setq charset (mm-read-coding-system "Charset: " charset)))
2549 (setq charset gnus-newsgroup-charset))
2551 (and type (let ((case-fold-search t))
2552 (string-match "base64" type))))
2555 (narrow-to-region (point) (point-max))
2556 (base64-decode-region (point-min) (point-max))
2557 (mm-decode-coding-region
2558 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2563 (defun article-decode-HZ ()
2564 "Translate a HZ-encoded article."
2568 (let ((inhibit-read-only t))
2569 (rfc1843-decode-region (point-min) (point-max)))))
2571 (defun article-unsplit-urls ()
2572 "Remove the newlines that some other mailers insert into URLs."
2575 (let ((inhibit-read-only t))
2576 (goto-char (point-min))
2577 (while (re-search-forward
2578 "\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2579 (replace-match "\\1\\3" t)))
2580 (when (interactive-p)
2581 (gnus-treat-article nil))))
2584 (defun article-wash-html (&optional read-charset)
2585 "Format an HTML article.
2586 If READ-CHARSET, ask for a coding system."
2589 (let ((inhibit-read-only t)
2591 (when (gnus-buffer-live-p gnus-original-article-buffer)
2592 (with-current-buffer gnus-original-article-buffer
2593 (let* ((ct (gnus-fetch-field "content-type"))
2596 (mail-header-parse-content-type ct)))))
2597 (setq charset (and ctl
2598 (mail-content-type-get ctl 'charset)))
2599 (when (stringp charset)
2600 (setq charset (intern (downcase charset)))))))
2602 (setq charset (mm-read-coding-system "Charset: " charset)))
2604 (setq charset gnus-newsgroup-charset))
2606 (save-window-excursion
2608 (narrow-to-region (point) (point-max))
2609 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2610 (entry (assq func mm-text-html-washer-alist)))
2612 (setq func (cdr entry)))
2617 (apply (car func) (cdr func))))))))))
2619 (defun gnus-article-wash-html-with-w3 ()
2620 "Wash the current buffer with w3."
2622 (let ((w3-strict-width (window-width))
2623 (url-standalone-mode t)
2624 (url-gateway-unplugged t)
2625 (w3-honor-stylesheets nil))
2627 (w3-region (point-min) (point-max))
2630 (defun gnus-article-wash-html-with-w3m ()
2631 "Wash the current buffer with emacs-w3m."
2634 (narrow-to-region (point) (point-max))
2635 (let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp)
2636 w3m-force-redisplay)
2637 (w3m-region (point-min) (point-max)))
2638 (when (and mm-inline-text-html-with-w3m-keymap
2639 (boundp 'w3m-minor-mode-map)
2641 (add-text-properties
2642 (point-min) (point-max)
2643 (list 'keymap w3m-minor-mode-map
2644 ;; Put the mark meaning this part was rendered by emacs-w3m.
2645 'mm-inline-text-html-with-w3m t)))))
2647 (defun article-hide-list-identifiers ()
2648 "Remove list identifies from the Subject header.
2649 The `gnus-list-identifiers' variable specifies what to do."
2651 (let ((inhibit-point-motion-hooks t)
2652 (regexp (if (consp gnus-list-identifiers)
2653 (mapconcat 'identity gnus-list-identifiers " *\\|")
2654 gnus-list-identifiers))
2655 (inhibit-read-only t))
2659 (article-narrow-to-head)
2660 (goto-char (point-min))
2661 (while (re-search-forward
2662 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2664 (delete-region (match-beginning 2) (match-end 0))
2665 (beginning-of-line))
2666 (when (re-search-forward
2667 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2668 (delete-region (match-beginning 1) (match-end 1))))))))
2670 (defun article-hide-pem (&optional arg)
2671 "Toggle hiding of any PEM headers and signatures in the current article.
2672 If given a negative prefix, always show; if given a positive prefix,
2674 (interactive (gnus-article-hidden-arg))
2675 (unless (gnus-article-check-hidden-text 'pem arg)
2677 (let ((inhibit-read-only t) end)
2678 (goto-char (point-min))
2679 ;; Hide the horrendously ugly "header".
2680 (when (and (search-forward
2681 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2683 (setq end (1+ (match-beginning 0))))
2684 (gnus-add-wash-type 'pem)
2685 (gnus-article-hide-text-type
2687 (if (search-forward "\n\n" nil t)
2691 ;; Hide the trailer as well
2692 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2694 (gnus-article-hide-text-type
2695 (match-beginning 0) (match-end 0) 'pem)))))))
2697 (defun article-strip-banner ()
2698 "Strip the banners specified by the `banner' group parameter and by
2699 `gnus-article-address-banner-alist'."
2703 (let ((inhibit-point-motion-hooks t))
2704 (when (gnus-parameter-banner gnus-newsgroup-name)
2705 (article-really-strip-banner
2706 (gnus-parameter-banner gnus-newsgroup-name)))
2707 (when gnus-article-address-banner-alist
2708 ;; It is necessary to encode from fields before checking,
2709 ;; because `mail-header-parse-addresses' does not work
2710 ;; (reliably) on decoded headers. And more, it is
2711 ;; impossible to use `gnus-fetch-original-field' here,
2712 ;; because `article-strip-banner' may be called in draft
2713 ;; buffers to preview them.
2714 (let ((from (save-restriction
2716 (article-narrow-to-head)
2717 (mail-fetch-field "from"))))
2720 (caar (mail-header-parse-addresses
2721 (mail-encode-encoded-word-string from)))))
2723 (dolist (pair gnus-article-address-banner-alist)
2724 (when (string-match (car pair) from)
2726 (article-really-strip-banner (cdr pair)))))))))))))
2728 (defun article-really-strip-banner (banner)
2729 "Strip the banner specified by the argument."
2732 (let ((inhibit-point-motion-hooks t)
2733 (gnus-signature-limit nil)
2734 (inhibit-read-only t))
2737 ((eq banner 'signature)
2738 (when (gnus-article-narrow-to-signature)
2741 (delete-region (point) (point-max))))
2743 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2744 (while (re-search-forward banner nil t)
2745 (delete-region (match-beginning 0) (match-end 0)))))
2747 (while (re-search-forward banner nil t)
2748 (delete-region (match-beginning 0) (match-end 0)))))))))
2750 (defun article-babel ()
2751 "Translate article using an online translation service."
2754 (gnus-with-article-buffer
2755 (when (article-goto-body)
2756 (let* ((start (point))
2758 (orig (buffer-substring start end))
2759 (trans (babel-as-string orig)))
2761 (narrow-to-region start end)
2762 (delete-region start end)
2765 (defun article-hide-signature (&optional arg)
2766 "Hide the signature in the current article.
2767 If given a negative prefix, always show; if given a positive prefix,
2769 (interactive (gnus-article-hidden-arg))
2775 (article-goto-body))
2776 (goto-char (point-min)))
2777 (unless (gnus-article-check-hidden-text 'signature arg)
2778 (let ((inhibit-read-only t)
2780 (while (setq button (text-property-any button (point-max)
2782 'gnus-signature-toggle))
2783 (setq button (text-property-not-all button (point-max)
2785 'gnus-signature-toggle))
2786 (when (and button (not (eobp)))
2787 (gnus-article-hide-text-type
2789 (next-single-property-change (1+ button) 'mime-view-entity
2792 (gnus-set-mode-line 'article))
2794 (defun article-strip-headers-in-body ()
2795 "Strip offensive headers from bodies."
2799 (let ((case-fold-search t))
2800 (when (looking-at "x-no-archive:")
2801 (gnus-delete-line)))))
2803 (defun article-strip-leading-blank-lines ()
2804 "Remove all blank lines from the beginning of the article."
2807 (let ((inhibit-point-motion-hooks t)
2808 (inhibit-read-only t))
2809 (when (article-goto-body)
2810 (while (and (not (eobp))
2811 (looking-at "[ \t]*$"))
2812 (gnus-delete-line))))))
2814 (defun article-narrow-to-head ()
2815 "Narrow the buffer to the head of the message.
2816 Point is left at the beginning of the narrowed-to region."
2818 (goto-char (point-min))
2819 (if (search-forward "\n\n" nil 1)
2822 (goto-char (point-min)))
2824 (defun article-goto-body ()
2825 "Place point at the start of the body."
2826 (goto-char (point-min))
2828 ;; This variable is only bound when dealing with separate
2830 (article-goto-body-goes-to-point-min-p
2832 ((search-forward "\n\n" nil t)
2835 (goto-char (point-max))
2838 (defun article-strip-multiple-blank-lines ()
2839 "Replace consecutive blank lines with one empty line."
2842 (let ((inhibit-point-motion-hooks t)
2843 (inhibit-read-only t))
2844 ;; First make all blank lines empty.
2846 (while (re-search-forward "^[ \t]+$" nil t)
2847 (unless (gnus-annotation-in-region-p
2848 (match-beginning 0) (match-end 0))
2849 (replace-match "" nil t)))
2850 ;; Then replace multiple empty lines with a single empty line.
2852 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2853 (unless (gnus-annotation-in-region-p
2854 (match-beginning 0) (match-end 0))
2855 (delete-region (match-beginning 1) (match-end 1)))))))
2857 (defun article-strip-leading-space ()
2858 "Remove all white space from the beginning of the lines in the article."
2861 (let ((inhibit-point-motion-hooks t)
2862 (inhibit-read-only t))
2864 (while (re-search-forward "^[ \t]+" nil t)
2865 (replace-match "" t t)))))
2867 (defun article-strip-trailing-space ()
2868 "Remove all white space from the end of the lines in the article."
2871 (let ((inhibit-point-motion-hooks t)
2872 (inhibit-read-only t))
2874 (while (re-search-forward "[ \t]+$" nil t)
2875 (replace-match "" t t)))))
2877 (defun article-strip-blank-lines ()
2878 "Strip leading, trailing and multiple blank lines."
2880 (article-strip-leading-blank-lines)
2881 (article-remove-trailing-blank-lines)
2882 (article-strip-multiple-blank-lines))
2884 (defun article-strip-all-blank-lines ()
2885 "Strip all blank lines."
2888 (let ((inhibit-point-motion-hooks t)
2889 (inhibit-read-only t))
2891 (while (re-search-forward "^[ \t]*\n" nil t)
2892 (replace-match "" t t)))))
2894 (defun gnus-article-narrow-to-signature ()
2895 "Narrow to the signature; return t if a signature is found, else nil."
2896 (let ((inhibit-point-motion-hooks t))
2897 (when (gnus-article-search-signature)
2899 ;; Check whether we have some limits to what we consider
2900 ;; to be a signature.
2901 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2902 (list gnus-signature-limit)))
2904 (while (setq limit (pop limits))
2905 (if (or (and (integerp limit)
2906 (< (- (point-max) (point)) limit))
2908 (< (count-lines (point) (point-max)) limit))
2909 (and (functionp limit)
2911 (and (stringp limit)
2912 (not (re-search-forward limit nil t))))
2913 () ; This limit did not succeed.
2917 (narrow-to-region (point) (point-max))
2920 (defun gnus-article-search-signature ()
2921 "Search the current buffer for the signature separator.
2922 Put point at the beginning of the signature separator."
2923 (let ((cur (point)))
2924 (goto-char (point-max))
2925 (if (if (stringp gnus-signature-separator)
2926 (re-search-backward gnus-signature-separator nil t)
2927 (let ((seps gnus-signature-separator))
2929 (not (re-search-backward (car seps) nil t)))
2936 (defun gnus-article-hidden-arg ()
2937 "Return the current prefix arg as a number, or 0 if no prefix."
2938 (list (if current-prefix-arg
2939 (prefix-numeric-value current-prefix-arg)
2942 (defun gnus-article-check-hidden-text (type arg)
2943 "Return nil if hiding is necessary.
2944 Arg can be nil or a number. nil and positive means hide, negative
2945 means show, 0 means toggle."
2948 (let ((hide (gnus-article-hidden-text-p type)))
2954 (gnus-article-show-hidden-text type)
2957 (if (eq hide 'hidden)
2959 (gnus-article-show-hidden-text type)
2963 (defun gnus-article-hidden-text-p (type)
2964 "Say whether the current buffer contains hidden text of type TYPE."
2965 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2967 (not (get-text-property pos 'invisible))
2968 (not (get-text-property pos 'dummy-invisible)))
2970 (text-property-any (1+ pos) (point-max) 'article-type type)))
2975 (defun gnus-article-show-hidden-text (type &optional dummy)
2976 "Show all hidden text of type TYPE.
2977 Originally it is hide instead of DUMMY."
2978 (let ((inhibit-read-only t)
2979 (inhibit-point-motion-hooks t))
2980 (gnus-remove-text-properties-when
2982 (point-min) (point-max)
2983 (cons 'article-type (cons type
2984 gnus-hidden-properties)))
2985 (gnus-delete-wash-type type)))
2987 (defconst article-time-units
2988 `((year . ,(* 365.25 24 60 60))
2989 (week . ,(* 7 24 60 60))
2990 (day . ,(* 24 60 60))
2994 "Mapping from time units to seconds.")
2996 (defun gnus-article-forward-header ()
2997 "Move point to the start of the next header.
2998 If the current header is a continuation header, this can be several
3003 (if (looking-at "[ \t]+[^ \t]")
3007 (defun article-date-ut (&optional type highlight)
3008 "Convert DATE date to universal time in the current article.
3009 If TYPE is `local', convert to local time; if it is `lapsed', output
3010 how much time has lapsed since DATE. For `lapsed', the value of
3011 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
3012 should replace the \"Date:\" one, or should be added below it."
3013 (interactive (list 'ut t))
3014 (let* ((tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
3015 (date-regexp (cond ((not gnus-article-date-lapsed-new-header)
3019 (article-lapsed-timer
3023 (case-fold-search t)
3024 (inhibit-read-only t)
3025 (inhibit-point-motion-hooks t)
3026 pos date bface eface)
3030 (goto-char (point-min))
3031 (while (or (setq date (get-text-property (setq pos (point))
3033 (when (setq pos (next-single-property-change
3034 (point) 'original-date))
3035 (setq date (get-text-property pos 'original-date))
3037 (narrow-to-region pos (or (text-property-any pos (point-max)
3040 (goto-char (point-min))
3041 (when (re-search-forward tdate-regexp nil t)
3042 (setq bface (get-text-property (point-at-bol) 'face)
3043 eface (get-text-property (1- (point-at-eol)) 'face)))
3044 (goto-char (point-min))
3046 ;; Delete any old Date headers.
3047 (while (re-search-forward date-regexp nil t)
3049 (delete-region (point-at-bol) (progn
3050 (gnus-article-forward-header)
3052 (delete-region (point-at-bol) (progn
3053 (gnus-article-forward-header)
3056 (setq pos (point))))
3057 (when (and (not pos)
3058 (re-search-forward tdate-regexp nil t))
3060 (gnus-goto-char pos)
3061 (insert (article-make-date-line date (or type 'ut)))
3067 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
3068 (put-text-property (match-beginning 1) (1+ (match-end 1))
3070 (put-text-property (match-beginning 2) (match-end 2)
3072 (put-text-property (point-min) (1- (point-max)) 'original-date date)
3073 (goto-char (point-max))
3076 (defun article-make-date-line (date type)
3077 "Return a DATE line of TYPE."
3078 (unless (memq type '(local ut original user iso8601 lapsed english))
3079 (error "Unknown conversion type: %s" type))
3081 (let ((time (date-to-time date)))
3083 ;; Convert to the local timezone.
3085 (concat "Date: " (message-make-date time)))
3086 ;; Convert to Universal Time.
3091 (let* ((e (parse-time-string date))
3092 (tm (apply 'encode-time e))
3094 (ls (- (cadr tm) (car (current-time-zone time)))))
3095 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
3096 ((> ls 65535) (list (1+ ms) (- ls 65536)))
3100 ;; Get the original date from the article.
3101 ((eq type 'original)
3102 (concat "Date: " (if (string-match "\n+$" date)
3103 (substring date 0 (match-beginning 0))
3105 ;; Let the user define the format.
3107 (let ((format (or (condition-case nil
3108 (with-current-buffer gnus-summary-buffer
3109 gnus-article-time-format)
3111 gnus-article-time-format)))
3112 (if (functionp format)
3113 (funcall format time)
3114 (concat "Date: " (format-time-string format time)))))
3117 (let ((tz (car (current-time-zone time))))
3120 (format-time-string "%Y%m%dT%H%M%S" time)
3121 (format "%s%02d%02d"
3122 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
3123 (/ (% (abs tz) 3600) 60)))))
3124 ;; Do an X-Sent lapsed format.
3126 ;; If the date is seriously mangled, the timezone functions are
3127 ;; liable to bug out, so we ignore all errors.
3128 (let* ((now (current-time))
3129 (real-time (subtract-time now time))
3130 (real-sec (and real-time
3131 (+ (* (float (car real-time)) 65536)
3133 (sec (and real-time (abs real-sec)))
3143 ;; This is a bit convoluted, but basically we go
3144 ;; through the time units for years, weeks, etc,
3145 ;; and divide things to see whether that results
3146 ;; in positive answers.
3149 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
3150 ;; The (remaining) seconds are too few to
3151 ;; be divided into this time unit.
3153 ;; It's big enough, so we output it.
3154 (setq sec (- sec (* num (cdr unit))))
3156 (concat (if prev ", " "") (int-to-string
3158 " " (symbol-name (car unit))
3159 (if (> num 1) "s" ""))
3161 article-time-units "")
3162 ;; If dates are odd, then it might appear like the
3163 ;; article was sent in the future.
3166 " in the future"))))))
3167 ;; Display the date in proper English
3169 (let ((dtime (decode-time time)))
3172 (number-to-string (nth 3 dtime))
3173 (let ((digit (% (nth 3 dtime) 10)))
3175 ((memq (nth 3 dtime) '(11 12 13)) "th")
3181 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3183 (number-to-string (nth 5 dtime))
3185 (format "%02d" (nth 2 dtime))
3187 (format "%02d" (nth 1 dtime)))))))
3189 (format "Date: %s (from T-gnus)" date))))
3191 (defun article-date-local (&optional highlight)
3192 "Convert the current article date to the local timezone."
3193 (interactive (list t))
3194 (article-date-ut 'local highlight))
3196 (defun article-date-english (&optional highlight)
3197 "Convert the current article date to something that is proper English."
3198 (interactive (list t))
3199 (article-date-ut 'english highlight))
3201 (defun article-date-original (&optional highlight)
3202 "Convert the current article date to what it was originally.
3203 This is only useful if you have used some other date conversion
3204 function and want to see what the date was before converting."
3205 (interactive (list t))
3206 (article-date-ut 'original highlight))
3208 (defun article-date-lapsed (&optional highlight)
3209 "Convert the current article date to time lapsed since it was sent."
3210 (interactive (list t))
3211 (article-date-ut 'lapsed highlight))
3213 (defun article-update-date-lapsed ()
3214 "Function to be run from a timer to update the lapsed time line."
3215 (let (deactivate-mark)
3220 (set-buffer (window-buffer w))
3221 (when (or (and (eq major-mode 'mime-view-mode)
3222 (eq (mime-preview-original-major-mode)
3223 'gnus-original-article-mode))
3224 (eq major-mode 'gnus-article-mode))
3225 (let ((mark (point-marker)))
3226 (goto-char (point-min))
3227 (when (re-search-forward "^X-Sent:" nil t)
3228 (article-date-lapsed t))
3229 (goto-char (marker-position mark))
3230 (move-marker mark nil))))
3233 (defun gnus-start-date-timer (&optional n)
3234 "Start a timer to update the X-Sent header in the article buffers.
3235 The numerical prefix says how frequently (in seconds) the function
3240 (gnus-stop-date-timer)
3241 (setq article-lapsed-timer
3242 (run-at-time 1 n 'article-update-date-lapsed)))
3244 (defun gnus-stop-date-timer ()
3245 "Stop the X-Sent timer."
3247 (when article-lapsed-timer
3248 (nnheader-cancel-timer article-lapsed-timer)
3249 (setq article-lapsed-timer nil)))
3251 (defun article-date-user (&optional highlight)
3252 "Convert the current article date to the user-defined format.
3253 This format is defined by the `gnus-article-time-format' variable."
3254 (interactive (list t))
3255 (article-date-ut 'user highlight))
3257 (defun article-date-iso8601 (&optional highlight)
3258 "Convert the current article date to ISO8601."
3259 (interactive (list t))
3260 (article-date-ut 'iso8601 highlight))
3262 (defmacro gnus-article-save-original-date (&rest forms)
3263 "Save the original date as a text property and evaluate FORMS."
3264 `(let* ((case-fold-search t)
3266 (goto-char (point-min))
3267 (when (and (re-search-forward "^date:[\t\n ]+" nil t)
3270 (date (when (and start
3271 (re-search-forward "[\t ]*\n\\(?:[^\t ]\\|\\'\\)"
3273 (buffer-substring-no-properties start
3274 (match-beginning 0)))))
3275 (goto-char (point-max))
3276 (skip-chars-backward "\n")
3277 (put-text-property (point-min) (point) 'original-date date)
3279 (goto-char (point-max))
3280 (skip-chars-backward "\n")
3281 (put-text-property (point-min) (point) 'original-date date)))
3283 ;; (defun article-show-all ()
3284 ;; "Show all hidden text in the article buffer."
3288 ;; (let ((inhibit-read-only t))
3289 ;; (gnus-article-unhide-text (point-min) (point-max))
3290 ;; (gnus-remove-text-with-property 'gnus-prev)
3291 ;; (gnus-remove-text-with-property 'gnus-next))))
3293 (defun article-show-all-headers ()
3294 "Show all hidden headers in the article buffer."
3299 (article-narrow-to-head)
3300 (let ((inhibit-read-only t))
3301 (gnus-article-unhide-text (point-min) (point-max))))))
3303 (defun article-remove-leading-whitespace ()
3304 "Remove excessive whitespace from all headers."
3308 (let ((inhibit-read-only t))
3309 (article-narrow-to-head)
3310 (goto-char (point-min))
3311 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3312 (delete-region (match-beginning 1) (match-end 1)))))))
3314 (defun article-emphasize (&optional arg)
3315 "Emphasize text according to `gnus-emphasis-alist'."
3316 (interactive (gnus-article-hidden-arg))
3317 (unless (gnus-article-check-hidden-text 'emphasis arg)
3321 (with-current-buffer gnus-summary-buffer
3322 gnus-article-emphasis-alist)
3324 gnus-emphasis-alist))
3325 (inhibit-read-only t)
3326 (props (append '(article-type emphasis)
3327 gnus-hidden-properties))
3328 regexp elem beg invisible visible face)
3331 (while (setq elem (pop alist))
3333 (setq regexp (car elem)
3334 invisible (nth 1 elem)
3335 visible (nth 2 elem)
3337 (while (re-search-forward regexp nil t)
3338 (when (and (match-beginning visible) (match-beginning invisible))
3339 (gnus-article-hide-text
3340 (match-beginning invisible) (match-end invisible) props)
3341 (gnus-article-unhide-text-type
3342 (match-beginning visible) (match-end visible) 'emphasis)
3343 (gnus-put-overlay-excluding-newlines
3344 (match-beginning visible) (match-end visible) 'face face)
3345 (gnus-add-wash-type 'emphasis)
3346 (goto-char (match-end invisible)))))))))
3348 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3349 "Setup newsgroup emphasis alist."
3350 (unless gnus-article-emphasis-alist
3351 (let ((name (and gnus-newsgroup-name
3352 (gnus-group-real-name gnus-newsgroup-name))))
3353 (make-local-variable 'gnus-article-emphasis-alist)
3354 (setq gnus-article-emphasis-alist
3356 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3357 (while (setq elem (pop alist))
3358 (when (and name (string-match (car elem) name))
3360 highlight (copy-sequence (cdr elem)))))
3362 (copy-sequence highlight-words)
3363 (if gnus-newsgroup-name
3364 (copy-sequence (gnus-group-find-parameter
3365 gnus-newsgroup-name 'highlight-words t)))
3366 gnus-emphasis-alist)))))
3369 (defvar gnus-summary-article-menu)
3370 (defvar gnus-summary-post-menu))
3372 ;;; Saving functions.
3374 (defun gnus-article-save (save-buffer file &optional num)
3375 "Save the currently selected article."
3376 (unless gnus-save-all-headers
3377 ;; Remove headers according to `gnus-saved-headers'.
3378 (let ((gnus-visible-headers
3379 (or gnus-saved-headers gnus-visible-headers))
3380 (gnus-article-buffer save-buffer))
3382 (set-buffer save-buffer)
3383 (article-hide-headers 1 t))))
3384 (save-window-excursion
3385 (if (not gnus-default-article-saver)
3386 (error "No default saver is defined")
3387 ;; !!! Magic! The saving functions all save
3388 ;; `gnus-save-article-buffer' (or so they think), but we
3389 ;; bind that variable to our save-buffer.
3390 (set-buffer gnus-article-buffer)
3391 (let* ((gnus-save-article-buffer save-buffer)
3394 ((not gnus-prompt-before-saving) 'default)
3395 ((eq gnus-prompt-before-saving 'always) nil)
3397 (gnus-number-of-articles-to-be-saved
3398 (when (eq gnus-prompt-before-saving t)
3400 (set-buffer gnus-article-current-summary)
3401 (funcall gnus-default-article-saver filename)))))
3403 (defun gnus-read-save-file-name (prompt &optional filename
3404 function group headers variable)
3406 (funcall function group headers (symbol-value variable)))
3411 ((eq filename 'default)
3417 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3420 (if (and gnus-number-of-articles-to-be-saved
3421 (> gnus-number-of-articles-to-be-saved 1))
3422 (format "these %d articles"
3423 gnus-number-of-articles-to-be-saved)
3426 ;; Let the split methods have their say.
3428 ;; No split name was found.
3431 (concat prompt " (default "
3432 (file-name-nondirectory default-name) ") ")
3433 (file-name-directory default-name)
3435 ;; A single group name is returned.
3436 ((stringp split-name)
3438 (funcall function split-name headers
3439 (symbol-value variable)))
3441 (concat prompt " (default "
3442 (file-name-nondirectory default-name) ") ")
3443 (file-name-directory default-name)
3445 ;; A single split name was found
3446 ((= 1 (length split-name))
3447 (let* ((name (expand-file-name
3449 gnus-article-save-directory))
3450 (dir (cond ((file-directory-p name)
3451 (file-name-as-directory name))
3452 ((file-exists-p name) name)
3453 (t gnus-article-save-directory))))
3455 (concat prompt " (default " name ") ")
3457 ;; A list of splits was found.
3459 (setq split-name (nreverse split-name))
3461 (let ((file-name-history
3462 (nconc split-name file-name-history)))
3466 (concat prompt " (`M-p' for defaults) ")
3467 gnus-article-save-directory
3469 gnus-article-save-directory)))
3470 (car (push result file-name-history)))))))
3471 ;; Create the directory.
3472 (gnus-make-directory (file-name-directory file))
3473 ;; If we have read a directory, we append the default file name.
3474 (when (file-directory-p file)
3475 (setq file (expand-file-name (file-name-nondirectory
3477 (file-name-as-directory file))))
3478 ;; Possibly translate some characters.
3479 (nnheader-translate-file-chars file))))))
3480 (gnus-make-directory (file-name-directory result))
3481 (set variable result)))
3483 (defun gnus-article-archive-name (group)
3484 "Return the first instance of an \"Archive-name\" in the current buffer."
3485 (let ((case-fold-search t))
3486 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3487 (nnheader-concat gnus-article-save-directory
3488 (match-string 1)))))
3490 (defun gnus-article-nndoc-name (group)
3491 "If GROUP is an nndoc group, return the name of the parent group."
3492 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3493 (gnus-group-get-parameter group 'save-article-group)))
3495 (defun gnus-summary-save-in-rmail (&optional filename)
3496 "Append this article to Rmail file.
3497 Optional argument FILENAME specifies file name.
3498 Directory to save to is default to `gnus-article-save-directory'."
3499 (setq filename (gnus-read-save-file-name
3500 "Save %s in rmail file:" filename
3501 gnus-rmail-save-name gnus-newsgroup-name
3502 gnus-current-headers 'gnus-newsgroup-last-rmail))
3503 (gnus-eval-in-buffer-window gnus-save-article-buffer
3507 (gnus-output-to-rmail filename))))
3510 (defun gnus-summary-save-in-mail (&optional filename)
3511 "Append this article to Unix mail file.
3512 Optional argument FILENAME specifies file name.
3513 Directory to save to is default to `gnus-article-save-directory'."
3514 (setq filename (gnus-read-save-file-name
3515 "Save %s in Unix mail file:" filename
3516 gnus-mail-save-name gnus-newsgroup-name
3517 gnus-current-headers 'gnus-newsgroup-last-mail))
3518 (gnus-eval-in-buffer-window gnus-save-article-buffer
3522 (if (and (file-readable-p filename)
3523 (file-regular-p filename)
3524 (mail-file-babyl-p filename))
3525 (rmail-output-to-rmail-file filename t)
3526 (gnus-output-to-mail filename)))))
3529 (defun gnus-summary-save-in-file (&optional filename overwrite)
3530 "Append this article to file.
3531 Optional argument FILENAME specifies file name.
3532 Directory to save to is default to `gnus-article-save-directory'."
3533 (setq filename (gnus-read-save-file-name
3534 "Save %s in file:" filename
3535 gnus-file-save-name gnus-newsgroup-name
3536 gnus-current-headers 'gnus-newsgroup-last-file))
3537 (gnus-eval-in-buffer-window gnus-save-article-buffer
3541 (when (and overwrite
3542 (file-exists-p filename))
3543 (delete-file filename))
3544 (gnus-output-to-file filename))))
3547 (defun gnus-summary-write-to-file (&optional filename)
3548 "Write this article to a file, overwriting it if the file exists.
3549 Optional argument FILENAME specifies file name.
3550 The directory to save in defaults to `gnus-article-save-directory'."
3551 (gnus-summary-save-in-file nil t))
3553 (defun gnus-summary-save-body-in-file (&optional filename)
3554 "Append this article body to a file.
3555 Optional argument FILENAME specifies file name.
3556 The directory to save in defaults to `gnus-article-save-directory'."
3557 (setq filename (gnus-read-save-file-name
3558 "Save %s body in file:" filename
3559 gnus-file-save-name gnus-newsgroup-name
3560 gnus-current-headers 'gnus-newsgroup-last-file))
3561 (gnus-eval-in-buffer-window gnus-save-article-buffer
3565 (when (article-goto-body)
3566 (narrow-to-region (point) (point-max)))
3567 (gnus-output-to-file filename))))
3570 (defun gnus-summary-save-in-pipe (&optional command)
3571 "Pipe this article to subprocess."
3573 (cond ((and (eq command 'default)
3574 gnus-last-shell-command)
3575 gnus-last-shell-command)
3580 "Shell command on %s: "
3581 (if (and gnus-number-of-articles-to-be-saved
3582 (> gnus-number-of-articles-to-be-saved 1))
3583 (format "these %d articles"
3584 gnus-number-of-articles-to-be-saved)
3586 gnus-last-shell-command))))
3587 (when (string-equal command "")
3588 (if gnus-last-shell-command
3589 (setq command gnus-last-shell-command)
3590 (error "A command is required")))
3591 (gnus-eval-in-buffer-window gnus-article-buffer
3594 (shell-command-on-region (point-min) (point-max) command nil)))
3595 (setq gnus-last-shell-command command))
3597 (defun gnus-summary-pipe-to-muttprint (&optional command)
3598 "Pipe this article to muttprint."
3599 (setq command (read-string
3600 "Print using command: " gnus-summary-muttprint-program
3601 nil gnus-summary-muttprint-program))
3602 (gnus-summary-save-in-pipe command))
3604 ;;; Article file names when saving.
3606 (defun gnus-capitalize-newsgroup (newsgroup)
3607 "Capitalize NEWSGROUP name."
3608 (when (not (zerop (length newsgroup)))
3609 (concat (char-to-string (upcase (aref newsgroup 0)))
3610 (substring newsgroup 1))))
3612 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3613 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3614 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3615 Otherwise, it is like ~/News/news/group/num."
3618 (concat (if (gnus-use-long-file-name 'not-save)
3619 (gnus-capitalize-newsgroup newsgroup)
3620 (gnus-newsgroup-directory-form newsgroup))
3621 "/" (int-to-string (mail-header-number headers)))
3622 gnus-article-save-directory)))
3624 (string-equal (file-name-directory default)
3625 (file-name-directory last-file))
3626 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3628 (or last-file default))))
3630 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3631 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3632 If variable `gnus-use-long-file-name' is non-nil, it is
3633 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3636 (concat (if (gnus-use-long-file-name 'not-save)
3638 (gnus-newsgroup-directory-form newsgroup))
3639 "/" (int-to-string (mail-header-number headers)))
3640 gnus-article-save-directory)))
3642 (string-equal (file-name-directory default)
3643 (file-name-directory last-file))
3644 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3646 (or last-file default))))
3648 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3649 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3650 If variable `gnus-use-long-file-name' is non-nil, it is
3651 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3654 (if (gnus-use-long-file-name 'not-save)
3657 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3659 gnus-article-save-directory)))
3661 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3662 "Generate file name from sender."
3663 (let ((from (mail-header-from headers)))
3665 (if (and from (string-match "\\([^ <]+\\)@" from))
3666 (match-string 1 from)
3668 gnus-article-save-directory)))
3670 (defun article-verify-x-pgp-sig ()
3673 (if (gnus-buffer-live-p gnus-original-article-buffer)
3674 (let ((sig (with-current-buffer gnus-original-article-buffer
3675 (gnus-fetch-field "X-PGP-Sig")))
3679 (mml2015-clear-verify-function))
3681 (insert-buffer-substring gnus-original-article-buffer)
3682 (setq items (split-string sig))
3683 (message-narrow-to-head)
3684 (let ((inhibit-point-motion-hooks t)
3685 (case-fold-search t))
3686 ;; Don't verify multiple headers.
3687 (setq headers (mapconcat (lambda (header)
3689 (mail-fetch-field header)
3691 (split-string (nth 1 items) ",") "")))
3692 (delete-region (point-min) (point-max))
3693 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3694 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3699 (if (looking-at "^-")
3702 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3703 (insert "Version: " (car items) "\n\n")
3704 (insert (mapconcat 'identity (cddr items) "\n"))
3705 (insert "\n-----END PGP SIGNATURE-----\n")
3706 (let ((mm-security-handle (list (format "multipart/signed"))))
3707 (mml2015-clean-buffer)
3708 (let ((coding-system-for-write (or gnus-newsgroup-charset
3710 (funcall (mml2015-clear-verify-function)))
3712 (or (mm-handle-multipart-ctl-parameter
3713 mm-security-handle 'gnus-details)
3714 (mm-handle-multipart-ctl-parameter
3715 mm-security-handle 'gnus-info)))))
3717 (let ((inhibit-read-only t) bface eface)
3719 (message-narrow-to-head)
3720 (goto-char (point-max))
3722 (setq bface (get-text-property (point-at-bol) 'face)
3723 eface (get-text-property (1- (point-at-eol)) 'face))
3724 (message-remove-header "X-Gnus-PGP-Verify")
3725 (if (re-search-forward "^X-PGP-Sig:" nil t)
3727 (goto-char (point-max)))
3728 (narrow-to-region (point) (point))
3729 (insert "X-Gnus-PGP-Verify: " info "\n")
3730 (goto-char (point-min))
3733 (if (not (looking-at "^[ \t]"))
3737 (goto-char (point-min))
3738 (when (looking-at "\\([^:]+\\): *")
3739 (put-text-property (match-beginning 1) (1+ (match-end 1))
3741 (put-text-property (match-end 0) (point-max)
3742 'face eface)))))))))
3744 (defun article-verify-cancel-lock ()
3745 "Verify Cancel-Lock header."
3747 (if (gnus-buffer-live-p gnus-original-article-buffer)
3748 (canlock-verify gnus-original-article-buffer)))
3750 (defun article-monafy ()
3751 "Display body part with mona font."
3753 (unless (if (featurep 'xemacs)
3754 (find-face 'gnus-mona-face)
3755 (facep 'gnus-mona-face))
3756 (require 'navi2ch-mona)
3757 (set-face-font (make-face 'gnus-mona-face) navi2ch-mona-font))
3759 (let ((inhibit-read-only t))
3762 (gnus-make-overlay (point) (point-max))
3763 'face 'gnus-mona-face))))
3770 (setq afunc (car func)
3773 gfunc (intern (format "gnus-%s" func))))
3775 (when (fboundp afunc)
3776 `(lambda (&optional interactive &rest args)
3777 ,(documentation afunc t)
3778 (interactive (list t))
3780 (set-buffer gnus-article-buffer)
3782 (call-interactively ',afunc)
3783 (apply ',afunc args))))))))
3784 '(article-hide-headers
3785 article-verify-x-pgp-sig
3786 article-verify-cancel-lock
3788 article-hide-boring-headers
3789 article-treat-overstrike
3790 article-treat-ansi-sequences
3791 article-fill-long-lines
3792 article-capitalize-sentences
3794 article-remove-leading-whitespace
3795 article-display-x-face
3796 article-display-face
3797 article-de-quoted-unreadable
3798 article-de-base64-unreadable
3801 article-unsplit-urls
3802 article-hide-list-identifiers
3803 article-strip-banner
3806 article-hide-signature
3807 article-strip-headers-in-body
3808 article-remove-trailing-blank-lines
3809 article-strip-leading-blank-lines
3810 article-strip-multiple-blank-lines
3811 article-strip-leading-space
3812 article-strip-trailing-space
3813 article-strip-blank-lines
3814 article-strip-all-blank-lines
3816 article-date-english
3817 article-date-iso8601
3818 article-date-original
3820 article-decode-mime-words
3821 article-decode-charset
3822 article-decode-encoded-words
3826 article-treat-dumbquotes
3827 article-normalize-headers
3828 (article-show-all-headers . gnus-article-show-all-headers)
3829 ;; (article-show-all . gnus-article-show-all)
3833 ;;; Gnus article mode
3836 (put 'gnus-article-mode 'mode-class 'special)
3838 (gnus-define-keys gnus-article-mode-map
3839 " " gnus-article-goto-next-page
3840 "\177" gnus-article-goto-prev-page
3841 [delete] gnus-article-goto-prev-page
3842 [backspace] gnus-article-goto-prev-page
3843 "\C-c^" gnus-article-refer-article
3844 "h" gnus-article-show-summary
3845 "s" gnus-article-show-summary
3846 "\C-c\C-m" gnus-article-mail
3847 "?" gnus-article-describe-briefly
3848 "e" gnus-summary-edit-article
3849 "<" beginning-of-buffer
3851 "\C-c\C-i" gnus-info-find-node
3853 "R" gnus-article-reply-with-original
3854 "F" gnus-article-followup-with-original
3855 "\C-hk" gnus-article-describe-key
3856 "\C-hc" gnus-article-describe-key-briefly
3858 "\C-d" gnus-article-read-summary-keys
3859 "\M-*" gnus-article-read-summary-keys
3860 "\M-#" gnus-article-read-summary-keys
3861 "\M-^" gnus-article-read-summary-keys
3862 "\M-g" gnus-article-read-summary-keys)
3864 ;; Define almost undefined keys to `gnus-article-read-summary-keys'.
3868 (push (char-to-string key) keys)
3870 (dolist (elem (accessible-keymaps gnus-summary-mode-map))
3871 (setq key (car elem))
3872 (when (and (> (length key) 0)
3873 (not (eq 'menu-bar (aref key 0)))
3874 (symbolp (lookup-key gnus-summary-mode-map key)))
3877 (unless (lookup-key gnus-article-mode-map key)
3878 (define-key gnus-article-mode-map key 'gnus-article-read-summary-keys))))
3880 (defun gnus-article-make-menu-bar ()
3881 (unless (boundp 'gnus-article-commands-menu)
3882 (gnus-summary-make-menu-bar))
3883 (gnus-turn-off-edit-menu 'article)
3884 (unless (boundp 'gnus-article-article-menu)
3886 gnus-article-article-menu gnus-article-mode-map ""
3888 ["Scroll forwards" gnus-article-goto-next-page t]
3889 ["Scroll backwards" gnus-article-goto-prev-page t]
3890 ["Show summary" gnus-article-show-summary t]
3891 ["Fetch Message-ID at point" gnus-article-refer-article t]
3892 ["Mail to address at point" gnus-article-mail t]
3893 ["Send a bug report" gnus-bug t]))
3896 gnus-article-treatment-menu gnus-article-mode-map ""
3897 ;; Fixme: this should use :active (and maybe :visible).
3899 ["Hide headers" gnus-article-hide-headers t]
3900 ["Hide signature" gnus-article-hide-signature t]
3901 ["Hide citation" gnus-article-hide-citation t]
3902 ["Treat overstrike" gnus-article-treat-overstrike t]
3903 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
3904 ["Remove carriage return" gnus-article-remove-cr t]
3905 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3906 ["Treat html" gnus-article-wash-html t]
3907 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3908 ["Decode HZ" gnus-article-decode-HZ t]))
3910 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3912 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3914 (gnus-run-hooks 'gnus-article-menu-hook)))
3916 (defun gnus-article-mode ()
3917 "Major mode for displaying an article.
3919 All normal editing commands are switched off.
3921 The following commands are available in addition to all summary mode
3923 \\<gnus-article-mode-map>
3924 \\[gnus-article-next-page]\t Scroll the article one page forwards
3925 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3926 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3927 \\[gnus-article-show-summary]\t Display the summary buffer
3928 \\[gnus-article-mail]\t Send a reply to the address near point
3929 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3930 \\[gnus-info-find-node]\t Go to the Gnus info node"
3932 (gnus-simplify-mode-line)
3933 (setq mode-name "Article")
3934 (setq major-mode 'gnus-article-mode)
3935 (make-local-variable 'minor-mode-alist)
3936 (unless (assq 'gnus-show-mime minor-mode-alist)
3937 (push (list 'gnus-show-mime " MIME") minor-mode-alist))
3938 (use-local-map gnus-article-mode-map)
3939 (when (gnus-visual-p 'article-menu 'menu)
3940 (gnus-article-make-menu-bar)
3941 (when gnus-summary-tool-bar-map
3942 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3943 (gnus-update-format-specifications nil 'article-mode)
3944 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3945 (set (make-local-variable 'gnus-page-broken) nil)
3946 (make-local-variable 'gnus-button-marker-list)
3947 (make-local-variable 'gnus-article-current-summary)
3948 (make-local-variable 'gnus-article-mime-handles)
3949 (make-local-variable 'gnus-article-decoded-p)
3950 (make-local-variable 'gnus-article-mime-handle-alist)
3951 (make-local-variable 'gnus-article-wash-types)
3952 (make-local-variable 'gnus-article-image-alist)
3953 (make-local-variable 'gnus-article-charset)
3954 (make-local-variable 'gnus-article-ignored-charsets)
3955 ;; Prevent recent Emacsen from displaying non-break space as "\ ".
3956 (set (make-local-variable 'show-nonbreak-escape) nil)
3957 (gnus-set-default-directory)
3958 (buffer-disable-undo)
3959 (setq buffer-read-only t
3960 show-trailing-whitespace nil)
3961 (set-syntax-table gnus-article-mode-syntax-table)
3962 (gnus-run-hooks 'gnus-article-mode-hook))
3964 (defun gnus-article-setup-buffer ()
3965 "Initialize the article buffer."
3966 (let* ((name (if gnus-single-article-buffer "*Article*"
3967 (concat "*Article " gnus-newsgroup-name "*")))
3969 (progn (string-match "\\*Article" name)
3970 (concat " *Original Article"
3971 (substring name (match-end 0))))))
3972 (setq gnus-article-buffer name)
3973 (setq gnus-original-article-buffer original)
3974 (setq gnus-article-mime-handle-alist nil)
3975 ;; This might be a variable local to the summary buffer.
3976 (unless gnus-single-article-buffer
3978 (set-buffer gnus-summary-buffer)
3979 (setq gnus-article-buffer name)
3980 (setq gnus-original-article-buffer original)
3981 (gnus-set-global-variables)))
3982 (gnus-article-setup-highlight-words)
3983 ;; Init original article buffer.
3985 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3986 (set-buffer-multibyte t)
3987 (setq major-mode 'gnus-original-article-mode)
3988 (make-local-variable 'gnus-original-article))
3989 (if (and (get-buffer name)
3990 (with-current-buffer name
3991 (if gnus-article-edit-mode
3992 (if (y-or-n-p "Article mode edit in progress; discard? ")
3994 (set-buffer-modified-p nil)
3995 (gnus-kill-buffer name)
3998 (error "Action aborted"))
4002 (set (make-local-variable 'gnus-article-edit-mode) nil)
4003 (buffer-disable-undo)
4004 (setq buffer-read-only t)
4005 ;; This list just keeps growing if we don't reset it.
4006 (setq gnus-button-marker-list nil)
4007 (unless (eq major-mode 'gnus-article-mode)
4008 (gnus-article-mode))
4011 (set-buffer (gnus-get-buffer-create name))
4013 (make-local-variable 'gnus-summary-buffer)
4014 (gnus-summary-set-local-parameters gnus-newsgroup-name)
4015 (current-buffer)))))
4017 ;; Set article window start at LINE, where LINE is the number of lines
4018 ;; from the head of the article.
4019 (defun gnus-article-set-window-start (&optional line)
4021 (gnus-get-buffer-window gnus-article-buffer t)
4023 (set-buffer gnus-article-buffer)
4024 (goto-char (point-min))
4027 (gnus-message 6 "Moved to bookmark")
4028 (search-forward "\n\n" nil t)
4032 ;;; @@ article filters
4035 (defun gnus-article-display-mime-message ()
4036 "Article display method for MIME message."
4037 ;; called from `gnus-original-article-buffer'.
4038 (let (charset all-headers)
4039 (with-current-buffer gnus-summary-buffer
4040 (setq charset default-mime-charset
4041 all-headers gnus-have-all-headers))
4042 (make-local-variable 'default-mime-charset)
4043 (setq default-mime-charset charset)
4044 (with-current-buffer (get-buffer-create gnus-article-buffer)
4045 (make-local-variable 'default-mime-charset)
4046 (setq default-mime-charset charset))
4047 (mime-display-message mime-message-structure
4048 gnus-article-buffer nil gnus-article-mode-map)
4050 (gnus-article-hide-headers nil -1)))
4051 (run-hooks 'gnus-mime-article-prepare-hook))
4053 (defun gnus-article-display-traditional-message ()
4054 "Article display method for traditional message."
4055 (set-buffer gnus-article-buffer)
4056 (let ((inhibit-read-only t))
4058 (insert-buffer-substring gnus-original-article-buffer)))
4060 (defun gnus-article-make-full-mail-header (&optional number charset)
4061 "Create a new mail header structure in a raw article buffer."
4062 (unless (and number charset)
4063 (save-current-buffer
4064 (set-buffer gnus-summary-buffer)
4066 (setq number (or (cdr gnus-article-current) 0)))
4068 (setq charset (or default-mime-charset 'x-ctext)))))
4069 (goto-char (point-min))
4070 (let ((header-end (if (search-forward "\n\n" nil t)
4072 (goto-char (point-max))))
4073 (chars (- (point-max) (point)))
4074 (lines (count-lines (point) (point-max)))
4075 (default-mime-charset charset)
4077 (narrow-to-region (point-min) header-end)
4078 (setq xref (std11-fetch-field "xref"))
4080 (make-full-mail-header
4082 (std11-fetch-field "subject")
4083 (std11-fetch-field "from")
4084 (std11-fetch-field "date")
4085 (std11-fetch-field "message-id")
4086 (std11-fetch-field "references")
4089 (when xref (concat "Xref: " xref)))
4092 (defun gnus-article-prepare (article &optional all-headers header)
4093 "Prepare ARTICLE in article mode buffer.
4094 ARTICLE should either be an article number or a Message-ID.
4095 If ARTICLE is an id, HEADER should be the article headers.
4096 If ALL-HEADERS is non-nil, no headers are hidden."
4098 ;; Make sure we start in a summary buffer.
4099 (unless (eq major-mode 'gnus-summary-mode)
4100 (set-buffer gnus-summary-buffer))
4101 (setq gnus-summary-buffer (current-buffer))
4102 (let* ((gnus-article (if header (mail-header-number header) article))
4103 (summary-buffer (current-buffer))
4104 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
4105 (group gnus-newsgroup-name)
4108 (gnus-article-setup-buffer)
4109 (set-buffer gnus-article-buffer)
4110 ;; Deactivate active regions.
4111 (when (and (boundp 'transient-mark-mode)
4112 transient-mark-mode)
4113 (setq mark-active nil))
4114 (if (not (setq result (let ((inhibit-read-only t))
4115 (gnus-request-article-this-buffer
4117 ;; There is no such article.
4119 (when (and (numberp article)
4120 (not (memq article gnus-newsgroup-sparse)))
4121 (setq gnus-article-current
4122 (cons gnus-newsgroup-name article))
4123 (set-buffer gnus-summary-buffer)
4124 (setq gnus-current-article article)
4125 (if (and (memq article gnus-newsgroup-undownloaded)
4126 (not (gnus-online (gnus-find-method-for-group
4127 gnus-newsgroup-name))))
4129 (gnus-summary-set-agent-mark article)
4130 (message "Message marked for downloading"))
4131 (gnus-summary-mark-article article gnus-canceled-mark)
4132 (unless (memq article gnus-newsgroup-sparse)
4133 (gnus-error 1 "No such article (may have expired or been canceled)")))))
4134 (if (or (eq result 'pseudo)
4135 (eq result 'nneething))
4138 (set-buffer summary-buffer)
4139 (push article gnus-newsgroup-history)
4140 (setq gnus-last-article gnus-current-article
4141 gnus-current-article 0
4142 gnus-current-headers nil
4143 gnus-article-current nil)
4144 (if (eq result 'nneething)
4145 (gnus-configure-windows 'summary)
4146 (gnus-configure-windows 'article))
4147 (gnus-set-global-variables))
4148 (let ((gnus-article-mime-handle-alist-1
4149 gnus-article-mime-handle-alist))
4150 (gnus-set-mode-line 'article)))
4151 ;; The result from the `request' was an actual article -
4152 ;; or at least some text that is now displayed in the
4154 (when (and (numberp article)
4155 (not (eq article gnus-current-article)))
4156 ;; Seems like a new article has been selected.
4157 ;; `gnus-current-article' must be an article number.
4159 (set-buffer summary-buffer)
4160 (push article gnus-newsgroup-history)
4161 (setq gnus-last-article gnus-current-article
4162 gnus-current-article article
4163 gnus-current-headers
4164 (gnus-summary-article-header gnus-current-article)
4165 gnus-article-current
4166 (cons gnus-newsgroup-name gnus-current-article))
4167 (unless (vectorp gnus-current-headers)
4168 (setq gnus-current-headers nil))
4169 (gnus-summary-goto-subject gnus-current-article)
4170 (when (gnus-summary-show-thread)
4171 ;; If the summary buffer really was folded, the
4172 ;; previous goto may not actually have gone to
4173 ;; the right article, but the thread root instead.
4175 (gnus-summary-goto-subject gnus-current-article))
4176 (gnus-run-hooks 'gnus-mark-article-hook)
4177 (gnus-set-mode-line 'summary)
4178 (when (gnus-visual-p 'article-highlight 'highlight)
4179 (gnus-run-hooks 'gnus-visual-mark-article-hook))
4180 ;; Set the global newsgroup variables here.
4181 (gnus-set-global-variables)
4182 (setq gnus-have-all-headers
4183 (or all-headers gnus-show-all-headers))))
4185 (gnus-configure-windows 'article))
4186 (when (or (numberp article)
4188 (gnus-article-prepare-display)
4190 (goto-char (point-min))
4191 (when gnus-break-pages
4192 (gnus-narrow-to-page)))
4193 (let ((gnus-article-mime-handle-alist-1
4194 gnus-article-mime-handle-alist))
4195 (gnus-set-mode-line 'article))
4199 (set-window-point (get-buffer-window (current-buffer)) (point))
4200 (gnus-configure-windows 'article)
4203 (defun gnus-article-prepare-mime-display (&optional number)
4204 (goto-char (point-min))
4205 (when (re-search-forward "^[^\t ]+:" nil t)
4206 (goto-char (match-beginning 0)))
4207 (let ((entity (if (eq 1 (point-min))
4208 (get-text-property 1 'mime-view-entity)
4209 (get-text-property (point) 'mime-view-entity)))
4210 last-entity child-entity next type)
4211 (setq child-entity (mime-entity-children entity))
4213 (setq last-entity (nth (1- (length child-entity))
4215 (setq last-entity entity))
4217 (narrow-to-region (point)
4218 (if (search-forward "\n\n" nil t)
4221 (gnus-article-save-original-date (gnus-treat-article 'head))
4222 (put-text-property (point-min) (point-max) 'article-treated-header t)
4223 (goto-char (point-max)))
4224 (while (and (not (eobp)) entity)
4225 (setq next (set-marker
4227 (next-single-property-change (point) 'mime-view-entity
4229 (let ((types (mime-entity-content-type entity)))
4230 (while (eq 'multipart (mime-content-type-primary-type types))
4231 (setq entity (car (mime-entity-children entity))
4232 types (mime-entity-content-type entity)))
4234 (setq type (format "%s/%s"
4235 (mime-content-type-primary-type types)
4236 (mime-content-type-subtype types)))))
4237 (if (string-equal type "message/rfc822")
4240 (let ((children (mime-entity-children entity))
4243 (setq last-children (nth (1- (length children)) children))
4246 (not (eq last-children
4247 (get-text-property next 'mime-view-entity)))
4249 (next-single-property-change next
4251 nil (point-max)))))))
4252 (setq next (next-single-property-change next 'mime-view-entity
4255 (narrow-to-region (point) next)
4256 (gnus-article-prepare-mime-display)
4257 (goto-char (point-max)))
4258 (setq entity (get-text-property (point) 'mime-view-entity)))
4260 (narrow-to-region (point) next)
4261 ;; Kludge. We have to count true number, but for now,
4262 ;; part number is here only to achieve `last'.
4263 (gnus-treat-article nil 1
4264 (if (eq entity last-entity)
4267 (goto-char (point-max)))
4268 (setq entity (get-text-property next 'mime-view-entity))))))
4271 (defun gnus-article-prepare-display ()
4272 "Make the current buffer look like a nice article."
4273 (let ((gnus-article-buffer (current-buffer))
4275 (inhibit-read-only t))
4276 (unless (eq major-mode 'gnus-article-mode)
4277 (gnus-article-mode))
4278 (setq buffer-read-only nil
4279 gnus-button-marker-list nil
4280 gnus-article-wash-types nil
4281 gnus-article-image-alist nil)
4284 (static-if (featurep 'xemacs)
4285 (map-extents (lambda (extent maparg) (delete-extent extent)))
4286 (let ((lists (overlay-lists)))
4287 (dolist (overlay (nconc (car lists) (cdr lists)))
4288 (delete-overlay overlay)))))
4289 (gnus-run-hooks 'gnus-tmp-internal-hook))
4290 (let ((show-mime (unless (member gnus-newsgroup-name '("nndraft:delayed"
4293 (inhibit-read-only t))
4294 (set-buffer gnus-original-article-buffer)
4296 (setq mime-message-structure gnus-current-headers)
4297 (mime-buffer-entity-set-buffer-internal mime-message-structure
4298 gnus-original-article-buffer)
4299 (mime-entity-set-representation-type-internal mime-message-structure
4300 'mime-buffer-entity)
4301 (luna-send mime-message-structure 'initialize-instance
4302 mime-message-structure)
4304 (let (mime-display-header-hook mime-display-text/plain-hook)
4305 (funcall gnus-article-display-method-for-mime))
4306 (funcall gnus-article-display-method-for-traditional))
4307 ;; Call the treatment functions.
4311 (gnus-article-prepare-mime-display)
4312 (narrow-to-region (goto-char (point-min))
4313 (if (search-forward "\n\n" nil t)
4316 (gnus-article-save-original-date (gnus-treat-article 'head))
4317 (put-text-property (point-min) (point-max) 'article-treated-header t)
4318 (goto-char (point-max))
4320 (narrow-to-region (point) (point-max))
4321 (gnus-treat-article nil))
4322 (put-text-property (point-min) (point-max) 'read-only nil)))
4323 (gnus-run-hooks 'gnus-article-prepare-hook))
4325 (defun gnus-article-decode-article-as-default-mime-charset ()
4326 "Decode an article as `default-mime-charset'. It won't work if the
4327 value of the variable `gnus-show-mime' is non-nil."
4328 (unless (or gnus-show-mime
4329 (member gnus-newsgroup-name '("nndraft:delayed"
4331 (set (make-local-variable 'default-mime-charset)
4332 (with-current-buffer gnus-summary-buffer
4333 default-mime-charset))
4334 (decode-mime-charset-region (point-min) (point-max)
4335 default-mime-charset)))
4338 ;;; Gnus MIME viewing functions
4341 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4342 "Format of the MIME buttons.
4344 Valid specifiers include:
4346 %T MIME type, along with additional info
4347 %n The `name' parameter
4348 %d The description, if any
4349 %l The length of the encoded part
4350 %p The part identifier number
4351 %e Dots if the part isn't displayed
4353 General format specifiers can also be used. See Info node
4354 `(gnus)Formatting Variables'.")
4356 (defvar gnus-mime-button-line-format-alist
4357 '((?t gnus-tmp-type ?s)
4358 (?T gnus-tmp-type-long ?s)
4359 (?n gnus-tmp-name ?s)
4360 (?d gnus-tmp-description ?s)
4362 (?l gnus-tmp-length ?d)
4363 (?e gnus-tmp-dots ?s)))
4365 (defvar gnus-mime-button-commands
4366 '((gnus-article-press-button "\r" "Toggle Display")
4367 (gnus-mime-view-part "v" "View Interactively...")
4368 (gnus-mime-view-part-as-type "t" "View As Type...")
4369 (gnus-mime-view-part-as-charset "C" "View As charset...")
4370 (gnus-mime-save-part "o" "Save...")
4371 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4372 (gnus-mime-delete-part "d" "Delete part")
4373 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4374 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4375 (gnus-mime-view-part-internally "E" "View Internally")
4376 (gnus-mime-view-part-externally "e" "View Externally")
4377 (gnus-mime-print-part "p" "Print")
4378 (gnus-mime-pipe-part "|" "Pipe To Command...")
4379 (gnus-mime-action-on-part "." "Take action on the part...")))
4381 (defun gnus-article-mime-part-status ()
4382 (with-current-buffer gnus-article-buffer
4383 (let ((entity (get-text-property (point-min) 'mime-view-entity))
4386 (setq children (mime-entity-children entity))
4387 (setq children (length children)))
4390 (format " (%d parts)" children))
4393 (defvar gnus-mime-button-map
4394 (let ((map (make-sparse-keymap)))
4395 (define-key map gnus-mouse-2 'gnus-article-push-button)
4396 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4397 (dolist (c gnus-mime-button-commands)
4398 (define-key map (cadr c) (car c)))
4402 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4404 ,@(mapcar (lambda (c)
4405 (vector (caddr c) (car c) :enable t))
4406 gnus-mime-button-commands)))
4408 (defun gnus-mime-button-menu (event prefix)
4409 "Construct a context-sensitive menu of MIME commands."
4410 (interactive "e\nP")
4411 (save-window-excursion
4412 (let ((pos (event-start event)))
4413 (select-window (posn-window pos))
4414 (goto-char (posn-point pos))
4415 (gnus-article-check-buffer)
4416 (popup-menu gnus-mime-button-menu nil prefix))))
4418 (defun gnus-mime-view-all-parts (&optional handles)
4419 "View all the MIME parts."
4421 (with-current-buffer gnus-article-buffer
4422 (let ((handles (or handles gnus-article-mime-handles))
4423 (mail-parse-charset gnus-newsgroup-charset)
4424 (mail-parse-ignored-charsets
4425 (with-current-buffer gnus-summary-buffer
4426 gnus-newsgroup-ignored-charsets)))
4428 (mm-remove-parts handles)
4429 (goto-char (point-min))
4430 (or (search-forward "\n\n") (goto-char (point-max)))
4431 (let ((inhibit-read-only t))
4432 (delete-region (point) (point-max))
4433 (mm-display-parts handles))))))
4436 (defsubst gnus-article-edit-part (handles)
4437 "Edit an article in order to delete a mime part.
4438 This function is exclusively used by `gnus-mime-save-part-and-strip'
4439 and `gnus-mime-delete-part', and not provided at run-time normally."
4440 (gnus-article-edit-article
4442 (buffer-disable-undo)
4444 (let ((mail-parse-charset (or gnus-article-charset
4445 ',gnus-newsgroup-charset))
4446 (mail-parse-ignored-charsets
4447 (or gnus-article-ignored-charsets
4448 ',gnus-newsgroup-ignored-charsets))
4449 (mbl mml-buffer-list))
4450 (setq mml-buffer-list nil)
4451 (insert-buffer gnus-original-article-buffer)
4452 (mime-to-mml ',handles)
4453 (setq gnus-article-mime-handles nil)
4454 (let ((mbl1 mml-buffer-list))
4455 (setq mml-buffer-list mbl)
4456 (set (make-local-variable 'mml-buffer-list) mbl1))
4457 (gnus-make-local-hook 'kill-buffer-hook)
4458 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4459 `(lambda (no-highlight)
4460 (let ((mail-parse-charset (or gnus-article-charset
4461 ',gnus-newsgroup-charset))
4462 (message-options message-options)
4463 (message-options-set-recipient)
4464 (mail-parse-ignored-charsets
4465 (or gnus-article-ignored-charsets
4466 ',gnus-newsgroup-ignored-charsets)))
4468 (mml-destroy-buffers)
4469 (remove-hook 'kill-buffer-hook
4470 'mml-destroy-buffers t)
4471 (kill-local-variable 'mml-buffer-list))
4472 (gnus-summary-edit-article-done
4473 ,(or (mail-header-references gnus-current-headers) "")
4474 ,(gnus-group-read-only-p)
4475 ,gnus-summary-buffer no-highlight)))
4476 (gnus-article-edit-done)
4477 (gnus-summary-expand-window)
4478 (gnus-summary-show-article)))
4480 (defun gnus-mime-save-part-and-strip ()
4481 "Save the MIME part under point then replace it with an external body."
4483 (gnus-article-check-buffer)
4484 (when (gnus-group-read-only-p)
4485 (error "The current group does not support deleting of parts"))
4486 (when (mm-complicated-handles gnus-article-mime-handles)
4488 The current article has a complicated MIME structure, giving up..."))
4489 (when (gnus-yes-or-no-p "\
4490 Deleting parts may malfunction or destroy the article; continue? ")
4491 (let* ((data (get-text-property (point) 'gnus-data))
4493 (handles gnus-article-mime-handles))
4494 (setq file (and data (mm-save-part data)))
4496 (with-current-buffer (mm-handle-buffer data)
4498 (insert "Content-Type: " (mm-handle-media-type data))
4499 (mml-insert-parameter-string (cdr (mm-handle-type data))
4502 (insert "Content-ID: " (message-make-message-id) "\n")
4503 (insert "Content-Transfer-Encoding: binary\n")
4506 (cdr (mm-make-handle nil
4507 `("message/external-body"
4508 (access-type . "LOCAL-FILE")
4510 (set-buffer gnus-summary-buffer)
4511 (gnus-article-edit-part handles)))))
4513 (defun gnus-mime-delete-part ()
4514 "Delete the MIME part under point.
4515 Replace it with some information about the removed part."
4517 (gnus-article-check-buffer)
4518 (when (gnus-group-read-only-p)
4519 (error "The current group does not support deleting of parts"))
4520 (when (mm-complicated-handles gnus-article-mime-handles)
4522 The current article has a complicated MIME structure, giving up..."))
4523 (when (gnus-yes-or-no-p "\
4524 Deleting parts may malfunction or destroy the article; continue? ")
4525 (let* ((data (get-text-property (point) 'gnus-data))
4526 (handles gnus-article-mime-handles)
4530 (mail-decode-encoded-word-string (or (mm-handle-description data)
4533 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4535 (type (mm-handle-media-type data)))
4537 (error "No MIME part under point"))
4538 (with-current-buffer (mm-handle-buffer data)
4539 (let ((bsize (format "%s" (buffer-size))))
4544 "| The following attachment has been deleted:\n"
4546 "| Type: " type "\n"
4547 "| Filename: " filename "\n"
4548 "| Size (encoded): " bsize " Byte\n"
4549 "| Description: " description "\n"
4552 (cdr (mm-make-handle
4553 nil `("text/plain") nil nil
4555 (format "Deleted attachment (%s bytes)" bsize))))))
4556 (set-buffer gnus-summary-buffer)
4557 (gnus-article-edit-part handles))))
4559 (defun gnus-mime-save-part ()
4560 "Save the MIME part under point."
4562 (gnus-article-check-buffer)
4563 (let ((data (get-text-property (point) 'gnus-data)))
4565 (mm-save-part data))))
4567 (defun gnus-mime-pipe-part ()
4568 "Pipe the MIME part under point to a process."
4570 (gnus-article-check-buffer)
4571 (let ((data (get-text-property (point) 'gnus-data)))
4573 (mm-pipe-part data))))
4575 (defun gnus-mime-view-part ()
4576 "Interactively choose a viewing method for the MIME part under point."
4578 (gnus-article-check-buffer)
4579 (let ((data (get-text-property (point) 'gnus-data)))
4581 (setq gnus-article-mime-handles
4583 gnus-article-mime-handles (setq data (copy-sequence data))))
4584 (mm-interactively-view-part data))))
4586 (defun gnus-mime-view-part-as-type-internal ()
4587 (gnus-article-check-buffer)
4588 (let* ((name (mail-content-type-get
4589 (mm-handle-type (get-text-property (point) 'gnus-data))
4591 (def-type (and name (mm-default-file-encoding name))))
4592 (and def-type (cons def-type 0))))
4594 (defun gnus-mime-view-part-as-type (&optional mime-type)
4595 "Choose a MIME media type, and view the part as such."
4598 (setq mime-type (completing-read
4599 "View as MIME type: "
4600 (mapcar #'list (mailcap-mime-types))
4602 (gnus-mime-view-part-as-type-internal))))
4603 (gnus-article-check-buffer)
4604 (let ((handle (get-text-property (point) 'gnus-data)))
4607 (mm-make-handle (mm-handle-buffer handle)
4608 (cons mime-type (cdr (mm-handle-type handle)))
4609 (mm-handle-encoding handle)
4610 (mm-handle-undisplayer handle)
4611 (mm-handle-disposition handle)
4612 (mm-handle-description handle)
4614 (mm-handle-id handle)))
4615 (setq gnus-article-mime-handles
4616 (mm-merge-handles gnus-article-mime-handles handle))
4617 (gnus-mm-display-part handle))))
4619 (defun gnus-mime-copy-part (&optional handle arg)
4620 "Put the MIME part under point into a new buffer.
4621 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4623 (interactive (list nil current-prefix-arg))
4624 (gnus-article-check-buffer)
4626 (setq handle (get-text-property (point) 'gnus-data)))
4628 (let ((filename (or (mail-content-type-get (mm-handle-disposition handle)
4630 (mail-content-type-get (mm-handle-disposition handle)
4632 contents dont-decode charset coding-system)
4633 (mm-with-unibyte-buffer
4634 (mm-insert-part handle)
4635 (setq contents (or (condition-case nil
4636 (mm-decompress-buffer filename nil 'sig)
4638 (setq dont-decode t)
4641 (setq filename (cond (filename (file-name-nondirectory filename))
4642 (dont-decode "*raw data*")
4647 (unless (setq charset (mail-content-type-get
4648 (mm-handle-type handle) 'charset))
4649 (unless (setq coding-system (mm-with-unibyte-buffer
4651 (mm-find-buffer-file-coding-system)))
4652 (setq charset gnus-newsgroup-charset))))
4654 (setq charset (or (cdr (assq arg
4655 gnus-summary-show-article-charset-alist))
4656 (mm-read-coding-system "Charset: ")))))
4657 (switch-to-buffer (generate-new-buffer filename))
4658 (if (or coding-system
4660 (setq coding-system (mm-charset-to-coding-system charset))
4661 (not (eq charset 'ascii))))
4663 (mm-enable-multibyte)
4664 (insert (mm-decode-coding-string contents coding-system))
4665 (setq buffer-file-coding-system
4666 (if (boundp 'last-coding-system-used)
4667 (symbol-value 'last-coding-system-used)
4669 (mm-disable-multibyte)
4671 (setq buffer-file-coding-system mm-binary-coding-system))
4672 ;; We do it this way to make `normal-mode' set the appropriate mode.
4675 (setq buffer-file-name (expand-file-name filename))
4677 (setq buffer-file-name nil))
4678 (goto-char (point-min)))))
4680 (defun gnus-mime-print-part (&optional handle filename)
4681 "Print the MIME part under point."
4682 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4683 (gnus-article-check-buffer)
4684 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4685 (contents (and handle (mm-get-part handle)))
4686 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4687 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4692 (mm-save-part-to-file handle file)
4693 (call-process shell-file-name nil
4694 (generate-new-buffer " *mm*")
4696 shell-command-switch
4698 printer file (mm-handle-type handle))))
4702 (gnus-print-buffer))
4703 (ps-despool filename)))))
4705 (defun gnus-mime-inline-part (&optional handle arg)
4706 "Insert the MIME part under point into the current buffer.
4707 Compressed files like .gz and .bz2 are decompressed."
4708 (interactive (list nil current-prefix-arg))
4709 (gnus-article-check-buffer)
4711 (setq handle (get-text-property (point) 'gnus-data)))
4714 (inhibit-read-only t)
4715 contents charset coding-system)
4716 (if (and (not arg) (mm-handle-undisplayer handle))
4717 (mm-remove-part handle)
4718 (mm-with-unibyte-buffer
4719 (mm-insert-part handle)
4721 (or (mm-decompress-buffer
4722 (or (mail-content-type-get (mm-handle-disposition handle)
4724 (mail-content-type-get (mm-handle-disposition handle)
4730 (unless (setq charset (mail-content-type-get
4731 (mm-handle-type handle) 'charset))
4732 (unless (setq coding-system
4733 (mm-with-unibyte-buffer
4735 (mm-find-buffer-file-coding-system)))
4736 (setq charset gnus-newsgroup-charset))))
4738 (if (mm-handle-undisplayer handle)
4739 (mm-remove-part handle))
4742 gnus-summary-show-article-charset-alist))
4743 (mm-read-coding-system "Charset: "))))
4745 (if (mm-handle-undisplayer handle)
4746 (mm-remove-part handle))))
4750 (if (or coding-system
4753 (mm-charset-to-coding-system charset))
4754 (not (eq charset 'ascii))))
4755 (mm-decode-coding-string contents coding-system)
4756 (mm-string-to-multibyte contents)))
4759 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4760 "Insert the MIME part under point into the current buffer using the
4762 (interactive (list nil current-prefix-arg))
4763 (gnus-article-check-buffer)
4764 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4767 (inhibit-read-only t))
4769 (if (mm-handle-undisplayer handle)
4770 (mm-remove-part handle))
4771 (let ((gnus-newsgroup-charset
4773 gnus-summary-show-article-charset-alist))
4774 (mm-read-coding-system "Charset: ")))
4775 (gnus-newsgroup-ignored-charsets 'gnus-all))
4776 (gnus-article-press-button)))))
4778 (defun gnus-mime-view-part-externally (&optional handle)
4779 "View the MIME part under point with an external viewer."
4781 (gnus-article-check-buffer)
4782 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4783 (mm-user-display-methods nil)
4784 (mm-inlined-types nil)
4785 (mail-parse-charset gnus-newsgroup-charset)
4786 (mail-parse-ignored-charsets
4787 (with-current-buffer gnus-summary-buffer
4788 gnus-newsgroup-ignored-charsets)))
4790 (if (mm-handle-undisplayer handle)
4791 (mm-remove-part handle)
4792 (mm-display-part handle)))))
4794 (defun gnus-mime-view-part-internally (&optional handle)
4795 "View the MIME part under point with an internal viewer.
4796 If no internal viewer is available, use an external viewer."
4798 (gnus-article-check-buffer)
4799 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4800 (mm-inlined-types '(".*"))
4801 (mm-inline-large-images t)
4802 (mail-parse-charset gnus-newsgroup-charset)
4803 (mail-parse-ignored-charsets
4804 (with-current-buffer gnus-summary-buffer
4805 gnus-newsgroup-ignored-charsets))
4806 (inhibit-read-only t))
4808 (if (mm-handle-undisplayer handle)
4809 (mm-remove-part handle)
4810 (mm-display-part handle)))))
4812 (defun gnus-mime-action-on-part (&optional action)
4813 "Do something with the MIME attachment at \(point\)."
4815 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4816 (gnus-article-check-buffer)
4817 (let ((action-pair (assoc action gnus-mime-action-alist)))
4819 (funcall (cdr action-pair)))))
4821 (defun gnus-article-part-wrapper (n function)
4822 (with-current-buffer gnus-article-buffer
4823 (when (> n (length gnus-article-mime-handle-alist))
4824 (error "No such part"))
4825 (gnus-article-goto-part n)
4826 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4827 (funcall function handle))))
4829 (defun gnus-article-pipe-part (n)
4830 "Pipe MIME part N, which is the numerical prefix."
4832 (gnus-article-part-wrapper n 'mm-pipe-part))
4834 (defun gnus-article-save-part (n)
4835 "Save MIME part N, which is the numerical prefix."
4837 (gnus-article-part-wrapper n 'mm-save-part))
4839 (defun gnus-article-interactively-view-part (n)
4840 "View MIME part N interactively, which is the numerical prefix."
4842 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4844 (defun gnus-article-copy-part (n)
4845 "Copy MIME part N, which is the numerical prefix."
4847 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4849 (defun gnus-article-view-part-as-charset (n)
4850 "View MIME part N using a specified charset.
4851 N is the numerical prefix."
4853 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4855 (defun gnus-article-view-part-externally (n)
4856 "View MIME part N externally, which is the numerical prefix."
4858 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4860 (defun gnus-article-inline-part (n)
4861 "Inline MIME part N, which is the numerical prefix."
4863 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4865 (defun gnus-article-mime-match-handle-first (condition)
4868 (dolist (ihandle gnus-article-mime-handle-alist)
4870 ((functionp condition)
4871 (funcall condition (cdr ihandle)))
4872 ((eq condition 'undisplayed)
4873 (not (or (mm-handle-undisplayer (cdr ihandle))
4874 (equal (mm-handle-media-type (cdr ihandle))
4875 "multipart/alternative"))))
4876 ((eq condition 'undisplayed-alternative)
4877 (not (mm-handle-undisplayer (cdr ihandle))))
4879 (gnus-article-goto-part (car ihandle))
4880 (or (not n) (< (car ihandle) n)))
4881 (setq n (car ihandle))))
4885 (defun gnus-article-view-part (&optional n)
4886 "View MIME part N, which is the numerical prefix."
4888 (with-current-buffer gnus-article-buffer
4889 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4890 gnus-article-mime-match-handle-function)))
4891 (when (> n (length gnus-article-mime-handle-alist))
4892 (error "No such part"))
4893 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4894 (when (gnus-article-goto-part n)
4895 (if (equal (car handle) "multipart/alternative")
4896 (gnus-article-press-button)
4897 (when (eq (gnus-mm-display-part handle) 'internal)
4898 (gnus-set-window-start)))))))
4900 (defsubst gnus-article-mime-total-parts ()
4901 (if (bufferp (car gnus-article-mime-handles))
4903 (1- (length gnus-article-mime-handles))))
4905 (defun gnus-mm-display-part (handle)
4906 "Display HANDLE and fix MIME button."
4907 (let ((id (get-text-property (point) 'gnus-part))
4909 (inhibit-read-only t))
4912 (let ((window (selected-window))
4913 (mail-parse-charset gnus-newsgroup-charset)
4914 (mail-parse-ignored-charsets
4915 (if (gnus-buffer-live-p gnus-summary-buffer)
4916 (with-current-buffer gnus-summary-buffer
4917 gnus-newsgroup-ignored-charsets)
4921 (let ((win (gnus-get-buffer-window (current-buffer) t))
4924 (select-window win))
4927 (if (mm-handle-displayed-p handle)
4928 ;; This will remove the part.
4929 (mm-display-part handle)
4931 (narrow-to-region (point)
4932 (if (eobp) (point) (1+ (point))))
4933 (mm-display-part handle)
4934 ;; We narrow to the part itself and
4935 ;; then call the treatment functions.
4936 (goto-char (point-min))
4938 (narrow-to-region (point) (point-max))
4941 (gnus-article-mime-total-parts)
4942 (mm-handle-media-type handle)))))
4943 (if (window-live-p window)
4944 (select-window window)))))
4947 (gnus-insert-mime-button
4948 handle id (list (mm-handle-displayed-p handle)))
4949 (goto-char point))))
4951 (defun gnus-article-goto-part (n)
4952 "Go to MIME part N."
4953 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4955 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4956 (let ((gnus-tmp-name
4957 (or (mail-content-type-get (mm-handle-type handle) 'name)
4958 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4959 (mail-content-type-get (mm-handle-type handle) 'url)
4961 (gnus-tmp-type (mm-handle-media-type handle))
4962 (gnus-tmp-description
4963 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4966 (if (if displayed (car displayed)
4967 (mm-handle-displayed-p handle))
4969 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4971 gnus-tmp-type-long b e)
4972 (when (string-match ".*/" gnus-tmp-name)
4973 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4974 (setq gnus-tmp-type-long (concat gnus-tmp-type
4975 (and (not (equal gnus-tmp-name ""))
4976 (concat "; " gnus-tmp-name))))
4977 (unless (equal gnus-tmp-description "")
4978 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4983 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4984 `(keymap ,gnus-mime-button-map
4985 gnus-callback gnus-mm-display-part
4986 gnus-part ,gnus-tmp-id
4987 article-type annotation
4990 ;; Exclude a newline.
4993 (widget-convert-button
4996 :action 'gnus-widget-press-button
4997 :button-keymap gnus-mime-button-map
4999 (lambda (widget/window &optional overlay pos)
5000 ;; Needed to properly clear the message due to a bug in
5001 ;; wid-edit (XEmacs only).
5002 (if (boundp 'help-echo-owns-message)
5003 (setq help-echo-owns-message t))
5005 "%S: %s the MIME part; %S: more options"
5006 (aref gnus-mouse-2 0)
5007 ;; XEmacs will get a single widget arg; Emacs 21 will get
5008 ;; window, overlay, position.
5009 (if (mm-handle-displayed-p
5011 (with-current-buffer (gnus-overlay-buffer overlay)
5012 (widget-get (widget-at (gnus-overlay-start overlay))
5014 (widget-get widget/window :mime-handle)))
5016 (aref gnus-down-mouse-3 0))))))
5018 (defun gnus-widget-press-button (elems el)
5019 (goto-char (widget-get elems :from))
5020 (gnus-article-press-button))
5022 (defvar gnus-displaying-mime nil)
5024 (defun gnus-display-mime (&optional ihandles)
5025 "Display the MIME parts."
5027 (save-selected-window
5028 (let ((window (get-buffer-window gnus-article-buffer))
5031 (select-window window)
5032 ;; We have to do this since selecting the window
5033 ;; may change the point. So we set the window point.
5034 (set-window-point window point)))
5035 (let ((handles ihandles)
5036 (inhibit-read-only t)
5039 ((setq handles (mm-dissect-buffer nil gnus-article-loose-mime))
5040 (when gnus-article-emulate-mime
5041 (mm-uu-dissect-text-parts handles)))
5042 (gnus-article-emulate-mime
5043 (setq handles (mm-uu-dissect))))
5044 (when (and (not ihandles)
5045 (not gnus-displaying-mime))
5046 ;; Top-level call; we clean up.
5047 (when gnus-article-mime-handles
5048 (mm-destroy-parts gnus-article-mime-handles)
5049 (setq gnus-article-mime-handle-alist nil));; A trick.
5050 (setq gnus-article-mime-handles handles)
5051 ;; We allow users to glean info from the handles.
5052 (when gnus-article-mime-part-function
5053 (gnus-mime-part-function handles)))
5055 (or (not (stringp (car handles)))
5058 (when (and (not ihandles)
5059 (not gnus-displaying-mime))
5060 ;; Clean up for mime parts.
5062 (delete-region (point) (point-max)))
5063 (let ((gnus-displaying-mime t))
5064 (gnus-mime-display-part handles)))
5067 (narrow-to-region (point) (point-max))
5068 (gnus-treat-article nil 1 1)
5071 ;; Highlight the headers.
5075 (narrow-to-region (point-min) (point))
5076 (gnus-article-save-original-date
5077 (gnus-treat-article 'head)))))))))
5079 (defcustom gnus-mime-display-multipart-as-mixed nil
5080 "Display \"multipart\" parts as \"multipart/mixed\".
5082 If t, it overrides nil values of
5083 `gnus-mime-display-multipart-alternative-as-mixed' and
5084 `gnus-mime-display-multipart-related-as-mixed'."
5085 :group 'gnus-article-mime
5088 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
5089 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
5091 :group 'gnus-article-mime
5094 (defcustom gnus-mime-display-multipart-related-as-mixed nil
5095 "Display \"multipart/related\" parts as \"multipart/mixed\".
5097 If displaying \"text/html\" is discouraged \(see
5098 `mm-discouraged-alternatives'\) images or other material inside a
5099 \"multipart/related\" part might be overlooked when this variable is nil."
5101 :group 'gnus-article-mime
5104 (defun gnus-mime-display-part (handle)
5107 ((not (stringp (car handle)))
5108 (gnus-mime-display-single handle))
5109 ;; User-defined multipart
5110 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
5111 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
5113 ;; multipart/alternative
5114 ((and (equal (car handle) "multipart/alternative")
5115 (not (or gnus-mime-display-multipart-as-mixed
5116 gnus-mime-display-multipart-alternative-as-mixed)))
5117 (let ((id (1+ (length gnus-article-mime-handle-alist))))
5118 (push (cons id handle) gnus-article-mime-handle-alist)
5119 (gnus-mime-display-alternative (cdr handle) nil nil id)))
5120 ;; multipart/related
5121 ((and (equal (car handle) "multipart/related")
5122 (not (or gnus-mime-display-multipart-as-mixed
5123 gnus-mime-display-multipart-related-as-mixed)))
5124 ;;;!!!We should find the start part, but we just default
5125 ;;;!!!to the first part.
5126 ;;(gnus-mime-display-part (cadr handle))
5127 ;;;!!! Most multipart/related is an HTML message plus images.
5128 ;;;!!! Unfortunately we are unable to let W3 display those
5129 ;;;!!! included images, so we just display it as a mixed multipart.
5130 ;;(gnus-mime-display-mixed (cdr handle))
5131 ;;;!!! No, w3 can display everything just fine.
5132 (gnus-mime-display-part (cadr handle)))
5133 ((equal (car handle) "multipart/signed")
5134 (gnus-add-wash-type 'signed)
5135 (gnus-mime-display-security handle))
5136 ((equal (car handle) "multipart/encrypted")
5137 (gnus-add-wash-type 'encrypted)
5138 (gnus-mime-display-security handle))
5139 ;; Other multiparts are handled like multipart/mixed.
5141 (gnus-mime-display-mixed (cdr handle)))))
5143 (defun gnus-mime-part-function (handles)
5144 (if (stringp (car handles))
5145 (mapcar 'gnus-mime-part-function (cdr handles))
5146 (funcall gnus-article-mime-part-function handles)))
5148 (defun gnus-mime-display-mixed (handles)
5149 (mapcar 'gnus-mime-display-part handles))
5151 (defun gnus-mime-display-single (handle)
5152 (let ((type (mm-handle-media-type handle))
5153 (ignored gnus-ignored-mime-types)
5160 (when (string-match (pop ignored) type)
5161 (throw 'ignored nil)))
5162 (if (and (setq not-attachment
5163 (and (not (mm-inline-override-p handle))
5164 (or (not (mm-handle-disposition handle))
5165 (equal (car (mm-handle-disposition handle))
5167 (mm-attachment-override-p handle))))
5168 (mm-automatic-display-p handle)
5170 (mm-inlinable-p handle)
5171 (mm-inlined-p handle))
5172 (mm-automatic-external-display-p type)))
5174 (when (equal (mm-handle-media-supertype handle) "text")
5176 (let ((id (1+ (length gnus-article-mime-handle-alist)))
5178 (push (cons id handle) gnus-article-mime-handle-alist)
5179 (when (or (not display)
5180 (not (gnus-unbuttonized-mime-type-p type)))
5181 (gnus-insert-mime-button
5182 handle id (list (or display (and not-attachment text))))
5183 (gnus-article-insert-newline)
5184 ;; Remember modify the number of forward lines.
5192 (let ((mail-parse-charset gnus-newsgroup-charset)
5193 (mail-parse-ignored-charsets
5194 (save-excursion (condition-case ()
5195 (set-buffer gnus-summary-buffer)
5197 gnus-newsgroup-ignored-charsets)))
5198 (mm-display-part handle t))
5199 (goto-char (point-max)))
5200 ((and text not-attachment)
5204 (gnus-article-insert-newline)
5205 (mm-display-inline handle)
5206 (goto-char (point-max))))
5210 (narrow-to-region beg (point))
5213 (gnus-article-mime-total-parts)
5214 (mm-handle-media-type handle)))))))))
5216 (defun gnus-unbuttonized-mime-type-p (type)
5217 "Say whether TYPE is to be unbuttonized."
5218 (unless gnus-inhibit-mime-unbuttonizing
5220 (let ((types gnus-unbuttonized-mime-types))
5222 (when (string-match (pop types) type)
5223 (throw 'found t)))))
5225 (let ((types gnus-buttonized-mime-types))
5227 (when (string-match (pop types) type)
5228 (throw 'found t)))))))))
5230 (defun gnus-article-insert-newline ()
5231 "Insert a newline, but mark it as undeletable."
5232 (gnus-put-text-property
5233 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
5235 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
5236 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
5239 handle (inhibit-read-only t) from props begend not-pref)
5240 (save-window-excursion
5243 (narrow-to-region (car ibegend)
5246 (goto-char (car ibegend))
5249 (delete-region (point-min) (point-max))
5250 (mm-remove-parts handles))
5251 (setq begend (list (point-marker)))
5253 (unless (setq not-pref (cadr (member preferred ihandles)))
5254 (setq not-pref (car ihandles)))
5257 (not (gnus-unbuttonized-mime-type-p
5258 "multipart/alternative")))
5259 (gnus-add-text-properties
5262 (insert (format "%d. " id))
5266 (unless ,(not ibegend)
5267 (setq gnus-article-mime-handle-alist
5268 ',gnus-article-mime-handle-alist))
5269 (gnus-mime-display-alternative
5270 ',ihandles ',not-pref ',begend ,id))
5271 keymap ,gnus-mime-button-map
5272 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5273 face ,gnus-article-button-face
5276 (widget-convert-button 'link from (point)
5277 :action 'gnus-widget-press-button
5278 :button-keymap gnus-widget-button-keymap)
5280 (while (setq handle (pop handles))
5281 (gnus-add-text-properties
5284 (insert (format "(%c) %-18s"
5285 (if (equal handle preferred) ?* ? )
5286 (mm-handle-media-type handle)))
5290 (unless ,(not ibegend)
5291 (setq gnus-article-mime-handle-alist
5292 ',gnus-article-mime-handle-alist))
5293 (gnus-mime-display-alternative
5294 ',ihandles ',handle ',begend ,id))
5295 keymap ,gnus-mime-button-map
5296 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5297 face ,gnus-article-button-face
5300 (widget-convert-button 'link from (point)
5301 :action 'gnus-widget-press-button
5302 :button-keymap gnus-widget-button-keymap)
5306 (if (stringp (car preferred))
5307 (gnus-display-mime preferred)
5308 (let ((mail-parse-charset gnus-newsgroup-charset)
5309 (mail-parse-ignored-charsets
5310 (with-current-buffer gnus-summary-buffer
5311 gnus-newsgroup-ignored-charsets)))
5312 (mm-display-part preferred)
5316 (narrow-to-region (car begend) (point-max))
5318 nil (length gnus-article-mime-handle-alist)
5319 (gnus-article-mime-total-parts)
5320 (mm-handle-media-type handle))))))
5321 (goto-char (point-max))
5322 (setcdr begend (point-marker)))))
5324 (goto-char point))))
5326 (defconst gnus-article-wash-status-strings
5327 (let ((alist '((cite "c" "Possible hidden citation text"
5328 " " "All citation text visible")
5329 (headers "h" "Hidden headers"
5330 " " "All headers visible.")
5331 (pgp "p" "Encrypted or signed message status hidden"
5332 " " "No hidden encryption nor digital signature status")
5333 (signature "s" "Signature has been hidden"
5334 " " "Signature is visible")
5335 (overstrike "o" "Overstrike (^H) characters applied"
5336 " " "No overstrike characters applied")
5337 (gnus-show-mime "m" "Mime processing is activated"
5338 " " "Mime processing is not activated")
5339 (emphasis "e" "/*_Emphasis_*/ characters applied"
5340 " " "No /*_emphasis_*/ characters applied")))
5342 (dolist (entry alist result)
5343 (let ((key (nth 0 entry))
5344 (on (copy-sequence (nth 1 entry)))
5345 (on-help (nth 2 entry))
5346 (off (copy-sequence (nth 3 entry)))
5347 (off-help (nth 4 entry)))
5348 (put-text-property 0 1 'help-echo on-help on)
5349 (put-text-property 0 1 'help-echo off-help off)
5350 (push (list key on off) result))))
5351 "Alist of strings describing wash status in the mode line.
5352 Each entry has the form (KEY ON OF), where the KEY is a symbol
5353 representing the particular washing function, ON is the string to use
5354 in the article mode line when the washing function is active, and OFF
5355 is the string to use when it is inactive.")
5357 (defun gnus-article-wash-status-entry (key value)
5358 (let ((entry (assoc key gnus-article-wash-status-strings)))
5359 (if value (nth 1 entry) (nth 2 entry))))
5361 (defun gnus-article-wash-status ()
5362 "Return a string which display status of article washing."
5363 (with-current-buffer gnus-article-buffer
5364 (let ((cite (memq 'cite gnus-article-wash-types))
5365 (headers (memq 'headers gnus-article-wash-types))
5366 (boring (memq 'boring-headers gnus-article-wash-types))
5367 (pgp (memq 'pgp gnus-article-wash-types))
5368 (pem (memq 'pem gnus-article-wash-types))
5369 (signed (memq 'signed gnus-article-wash-types))
5370 (encrypted (memq 'encrypted gnus-article-wash-types))
5371 (signature (memq 'signature gnus-article-wash-types))
5372 (overstrike (memq 'overstrike gnus-article-wash-types))
5373 (emphasis (memq 'emphasis gnus-article-wash-types)))
5375 (gnus-article-wash-status-entry 'cite cite)
5376 (gnus-article-wash-status-entry 'headers (or headers boring))
5377 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5378 (gnus-article-wash-status-entry 'signature signature)
5379 (gnus-article-wash-status-entry 'overstrike overstrike)
5380 (gnus-article-wash-status-entry 'gnus-show-mime gnus-show-mime)
5381 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5383 (defun gnus-add-wash-type (type)
5384 "Add a washing of TYPE to the current status."
5385 (add-to-list 'gnus-article-wash-types type))
5387 (defun gnus-delete-wash-type (type)
5388 "Add a washing of TYPE to the current status."
5389 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5391 (defun gnus-add-image (category image)
5392 "Add IMAGE of CATEGORY to the list of displayed images."
5393 (let ((entry (assq category gnus-article-image-alist)))
5395 (setq entry (list category))
5396 (push entry gnus-article-image-alist))
5397 (nconc entry (list image))))
5399 (defun gnus-delete-images (category)
5400 "Delete all images in CATEGORY."
5401 (let ((entry (assq category gnus-article-image-alist)))
5402 (dolist (image (cdr entry))
5403 (gnus-remove-image image category))
5404 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5405 (gnus-delete-wash-type category)))
5407 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5409 (defun gnus-article-maybe-hide-headers ()
5410 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5411 Provided for backwards compatibility."
5412 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5413 (not (with-current-buffer gnus-summary-buffer
5414 gnus-have-all-headers)))
5415 (not gnus-inhibit-hiding))
5416 (gnus-article-hide-headers)))
5420 (defun gnus-output-to-file (file-name)
5421 "Append the current article to a file named FILE-NAME."
5422 (let ((artbuf (current-buffer)))
5424 (insert-buffer-substring artbuf)
5425 ;; Append newline at end of the buffer as separator, and then
5427 (goto-char (point-max))
5429 (let ((file-name-coding-system nnmail-pathname-coding-system))
5430 (write-region-as-binary (point-min) (point-max) file-name 'append))
5433 (defun gnus-narrow-to-page (&optional arg)
5434 "Narrow the article buffer to a page.
5435 If given a numerical ARG, move forward ARG pages."
5437 (setq arg (if arg (prefix-numeric-value arg) 0))
5439 (set-buffer gnus-article-buffer)
5440 (goto-char (point-min))
5442 ;; Remove any old next/prev buttons.
5443 (when (gnus-visual-p 'page-marker)
5444 (let ((inhibit-read-only t))
5445 (gnus-remove-text-with-property 'gnus-prev)
5446 (gnus-remove-text-with-property 'gnus-next)))
5449 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5451 (re-search-forward page-delimiter nil 'move arg)))
5452 (goto-char (match-end 0))
5454 (goto-char (point-min))
5455 (setq gnus-page-broken
5456 (and (re-search-forward page-delimiter nil t) t))))
5457 (when gnus-page-broken
5460 (if (re-search-forward page-delimiter nil 'move)
5463 (when (and (gnus-visual-p 'page-marker)
5464 (> (point-min) (save-restriction (widen) (point-min))))
5466 (goto-char (point-min))
5467 (gnus-insert-prev-page-button)))
5468 (when (and (gnus-visual-p 'page-marker)
5469 (< (point-max) (save-restriction (widen) (point-max))))
5471 (goto-char (point-max))
5472 (gnus-insert-next-page-button))))))
5474 ;; Article mode commands
5476 (defun gnus-article-goto-next-page ()
5477 "Show the next page of the article."
5479 (when (gnus-article-next-page)
5480 (goto-char (point-min))
5481 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5484 (defun gnus-article-goto-prev-page ()
5485 "Show the previous page of the article."
5488 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5489 (gnus-article-prev-page nil)))
5491 ;; This is cleaner but currently breaks `gnus-pick-mode':
5493 ;; (defun gnus-article-goto-next-page ()
5494 ;; "Show the next page of the article."
5496 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5497 ;; (gnus-summary-next-page)))
5499 ;; (defun gnus-article-goto-prev-page ()
5500 ;; "Show the next page of the article."
5502 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5503 ;; (gnus-summary-prev-page)))
5505 (defun gnus-article-next-page (&optional lines)
5506 "Show the next page of the current article.
5507 If end of article, return non-nil. Otherwise return nil.
5508 Argument LINES specifies lines to be scrolled up."
5510 (move-to-window-line -1)
5513 (and (pos-visible-in-window-p) ;Not continuation line.
5514 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5515 ;; Nothing in this page.
5516 (if (or (not gnus-page-broken)
5521 (eobp)))) ;Real end-of-buffer?
5523 (when gnus-article-over-scroll
5524 (gnus-article-next-page-1 lines))
5526 (gnus-narrow-to-page 1) ;Go to next page.
5528 ;; More in this page.
5529 (gnus-article-next-page-1 lines)
5532 (defun gnus-article-next-page-1 (lines)
5533 (let ((scroll-in-place nil))
5537 ;; Long lines may cause an end-of-buffer error.
5538 (goto-char (point-max)))))
5539 (move-to-window-line 0))
5541 (defun gnus-article-prev-page (&optional lines)
5542 "Show previous page of current article.
5543 Argument LINES specifies lines to be scrolled down."
5545 (move-to-window-line 0)
5546 (if (and gnus-page-broken
5548 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5550 (gnus-narrow-to-page -1) ;Go to previous page.
5551 (goto-char (point-max))
5553 (let ((scroll-in-place nil))
5557 (beginning-of-buffer
5558 (goto-char (point-min))))
5559 (move-to-window-line 0)))))
5561 (defun gnus-article-only-boring-p ()
5562 "Decide whether there is only boring text remaining in the article.
5563 Something \"interesting\" is a word of at least two letters that does
5564 not have a face in `gnus-article-boring-faces'."
5565 (when (and gnus-article-skip-boring
5566 (boundp 'gnus-article-boring-faces)
5567 (symbol-value 'gnus-article-boring-faces))
5570 (while (re-search-forward "\\b\\w\\w" nil t)
5572 (when (not (gnus-intersection
5573 (gnus-faces-at (point))
5574 (symbol-value 'gnus-article-boring-faces)))
5575 (throw 'only-boring nil)))
5576 (throw 'only-boring t)))))
5578 (defun gnus-article-refer-article ()
5579 "Read article specified by message-id around point."
5582 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
5583 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
5584 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
5585 (let ((msg-id (concat "<" (match-string 0) ">")))
5586 (set-buffer gnus-summary-buffer)
5587 (gnus-summary-refer-article msg-id))
5588 (error "No references around point"))))
5590 (defun gnus-article-show-summary ()
5591 "Reconfigure windows to show summary buffer."
5593 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5594 (error "There is no summary buffer for this article buffer")
5595 (gnus-article-set-globals)
5596 (gnus-configure-windows 'article)
5597 (gnus-summary-goto-subject gnus-current-article)
5598 (gnus-summary-position-point)))
5600 (defun gnus-article-describe-briefly ()
5601 "Describe article mode commands briefly."
5603 (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")))
5605 (defun gnus-article-summary-command ()
5606 "Execute the last keystroke in the summary buffer."
5608 (let ((obuf (current-buffer))
5609 (owin (current-window-configuration))
5611 (switch-to-buffer gnus-article-current-summary 'norecord)
5612 (setq func (lookup-key (current-local-map) (this-command-keys)))
5613 (call-interactively func)
5615 (set-window-configuration owin)
5616 (set-window-point (get-buffer-window (current-buffer)) (point))))
5618 (defun gnus-article-summary-command-nosave ()
5619 "Execute the last keystroke in the summary buffer."
5622 (pop-to-buffer gnus-article-current-summary 'norecord)
5623 (setq func (lookup-key (current-local-map) (this-command-keys)))
5624 (call-interactively func)))
5626 (defun gnus-article-check-buffer ()
5627 "Beep if not in an article buffer."
5628 (unless (eq (get-buffer gnus-article-buffer) (current-buffer))
5629 (error "Command invoked outside of a Gnus article buffer")))
5631 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5632 "Read a summary buffer key sequence and execute it from the article buffer."
5634 (gnus-article-check-buffer)
5636 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5637 "Zc" "ZC" "ZE" "ZJ" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5638 "=" "^" "\M-^" "|"))
5644 '("n" "Gn" "p" "Gp"))
5647 (set-buffer gnus-article-current-summary)
5648 (let (gnus-pick-mode)
5649 (push (or key last-command-event) unread-command-events)
5650 (setq keys (static-if (featurep 'xemacs)
5651 (events-to-keys (read-key-sequence nil))
5652 (read-key-sequence nil)))))
5655 (if (or (member keys nosaves)
5656 (member keys nosave-but-article)
5657 (member keys nosave-in-article))
5659 (save-window-excursion
5660 (pop-to-buffer gnus-article-current-summary 'norecord)
5661 ;; We disable the pick minor mode commands.
5662 (let (gnus-pick-mode)
5663 (setq func (lookup-key (current-local-map) keys))))
5667 (unless (member keys nosave-in-article)
5668 (set-buffer gnus-article-current-summary))
5669 (call-interactively func)
5670 (setq new-sum-point (point)))
5671 (when (member keys nosave-but-article)
5672 (pop-to-buffer gnus-article-buffer 'norecord)))
5673 ;; These commands should restore window configuration.
5674 (let ((obuf (current-buffer))
5675 (owin (current-window-configuration))
5677 win func in-buffer selected new-sum-start new-sum-hscroll)
5678 (cond (not-restore-window
5679 (pop-to-buffer gnus-article-current-summary 'norecord))
5680 ((setq win (get-buffer-window gnus-article-current-summary))
5681 (select-window win))
5683 (switch-to-buffer gnus-article-current-summary 'norecord)))
5684 (setq in-buffer (current-buffer))
5685 ;; We disable the pick minor mode commands.
5686 (if (and (setq func (let (gnus-pick-mode)
5687 (lookup-key (current-local-map) keys)))
5690 (call-interactively func)
5691 (when (eq win (selected-window))
5692 (setq new-sum-point (point)
5693 new-sum-start (window-start win)
5694 new-sum-hscroll (window-hscroll win)))
5695 (when (eq in-buffer (current-buffer))
5696 (setq selected (gnus-summary-select-article))
5698 (unless not-restore-window
5699 (set-window-configuration owin))
5700 (when (eq selected 'old)
5702 (set-window-start (get-buffer-window (current-buffer))
5704 (set-window-point (get-buffer-window (current-buffer))
5706 (when (and (not not-restore-window)
5708 (set-window-point win new-sum-point)
5709 (set-window-start win new-sum-start)
5710 (set-window-hscroll win new-sum-hscroll))))
5711 (set-window-configuration owin)
5714 (defun gnus-article-describe-key (key)
5715 "Display documentation of the function invoked by KEY. KEY is a string."
5716 (interactive "kDescribe key: ")
5717 (gnus-article-check-buffer)
5718 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5720 (set-buffer gnus-article-current-summary)
5721 (let (gnus-pick-mode)
5722 (if (featurep 'xemacs)
5724 (push (elt key 0) unread-command-events)
5725 (setq key (events-to-keys
5726 (read-key-sequence "Describe key: "))))
5727 (setq unread-command-events
5729 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5731 (setq key (read-key-sequence "Describe key: "))))
5733 (describe-key key)))
5735 (defun gnus-article-describe-key-briefly (key &optional insert)
5736 "Display documentation of the function invoked by KEY. KEY is a string."
5737 (interactive "kDescribe key: \nP")
5738 (gnus-article-check-buffer)
5739 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5741 (set-buffer gnus-article-current-summary)
5742 (let (gnus-pick-mode)
5743 (if (featurep 'xemacs)
5745 (push (elt key 0) unread-command-events)
5746 (setq key (events-to-keys
5747 (read-key-sequence "Describe key: "))))
5748 (setq unread-command-events
5750 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5752 (setq key (read-key-sequence "Describe key: "))))
5753 (describe-key-briefly key insert))
5754 (describe-key-briefly key insert)))
5756 (defun gnus-article-reply-with-original (&optional wide)
5757 "Start composing a reply mail to the current message.
5758 The text in the region will be yanked. If the region isn't active,
5759 the entire article will be yanked."
5761 (let ((article (cdr gnus-article-current))
5763 (if (not (gnus-region-active-p))
5764 (with-current-buffer gnus-summary-buffer
5765 (gnus-summary-reply (list (list article)) wide))
5766 (setq contents (buffer-substring (point) (mark t)))
5767 ;; Deactivate active regions.
5768 (when (and (boundp 'transient-mark-mode)
5769 transient-mark-mode)
5770 (setq mark-active nil))
5771 (with-current-buffer gnus-summary-buffer
5773 (list (list article contents)) wide)))))
5775 (defun gnus-article-followup-with-original ()
5776 "Compose a followup to the current article.
5777 The text in the region will be yanked. If the region isn't active,
5778 the entire article will be yanked."
5780 (let ((article (cdr gnus-article-current))
5782 (if (not (gnus-region-active-p))
5783 (with-current-buffer gnus-summary-buffer
5784 (gnus-summary-followup (list (list article))))
5785 (setq contents (buffer-substring (point) (mark t)))
5786 ;; Deactivate active regions.
5787 (when (and (boundp 'transient-mark-mode)
5788 transient-mark-mode)
5789 (setq mark-active nil))
5790 (with-current-buffer gnus-summary-buffer
5791 (gnus-summary-followup
5792 (list (list article contents)))))))
5794 (defun gnus-article-hide (&optional arg force)
5795 "Hide all the gruft in the current article.
5796 This means that signatures, cited text and (some) headers will be
5798 If given a prefix, show the hidden text instead."
5799 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5800 (gnus-article-hide-headers arg)
5801 (gnus-article-hide-list-identifiers arg)
5802 (gnus-article-hide-citation-maybe arg force)
5803 (gnus-article-hide-signature arg))
5805 (defun gnus-article-maybe-highlight ()
5806 "Do some article highlighting if article highlighting is requested."
5807 (when (gnus-visual-p 'article-highlight 'highlight)
5808 (gnus-article-highlight-some)))
5810 (defun gnus-check-group-server ()
5811 ;; Make sure the connection to the server is alive.
5812 (unless (gnus-server-opened
5813 (gnus-find-method-for-group gnus-newsgroup-name))
5814 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5815 (gnus-request-group gnus-newsgroup-name t)))
5818 (autoload 'nneething-get-file-name "nneething"))
5820 (defun gnus-request-article-this-buffer (article group)
5821 "Get an article and insert it into this buffer."
5822 (let (do-update-line sparse-header)
5826 (gnus-kill-all-overlays)
5827 (setq group (or group gnus-newsgroup-name))
5829 ;; Using `gnus-request-article' directly will insert the article into
5830 ;; `nntp-server-buffer' - so we'll save some time by not having to
5831 ;; copy it from the server buffer into the article buffer.
5833 ;; We only request an article by message-id when we do not have the
5834 ;; headers for it, so we'll have to get those.
5835 (when (stringp article)
5836 (gnus-read-header article))
5838 ;; If the article number is negative, that means that this article
5839 ;; doesn't belong in this newsgroup (possibly), so we find its
5840 ;; message-id and request it by id instead of number.
5841 (when (and (numberp article)
5843 (get-buffer gnus-summary-buffer)
5844 (gnus-buffer-exists-p gnus-summary-buffer))
5846 (set-buffer gnus-summary-buffer)
5847 (let ((header (gnus-summary-article-header article)))
5850 ((memq article gnus-newsgroup-sparse)
5851 ;; This is a sparse gap article.
5852 (setq do-update-line article)
5853 (setq article (mail-header-id header))
5854 (setq sparse-header (gnus-read-header article))
5855 (setq gnus-newsgroup-sparse
5856 (delq article gnus-newsgroup-sparse)))
5858 ;; It's a real article.
5859 (setq article (mail-header-id header)))
5861 ;; It is an extracted pseudo-article.
5862 (setq article 'pseudo)
5863 (gnus-request-pseudo-article header))))
5865 (let ((method (gnus-find-method-for-group
5866 gnus-newsgroup-name)))
5867 (when (and (eq (car method) 'nneething)
5869 (let ((dir (nneething-get-file-name
5870 (mail-header-id header))))
5871 (when (and (stringp dir)
5872 (file-directory-p dir))
5873 (setq article 'nneething)
5874 (gnus-group-enter-directory dir))))))))
5877 ;; Refuse to select canceled articles.
5878 ((and (numberp article)
5880 (get-buffer gnus-summary-buffer)
5881 (gnus-buffer-exists-p gnus-summary-buffer)
5882 (eq (cdr (with-current-buffer gnus-summary-buffer
5883 (assq article gnus-newsgroup-reads)))
5884 gnus-canceled-mark))
5886 ;; We first check `gnus-original-article-buffer'.
5887 ((and (get-buffer gnus-original-article-buffer)
5889 (with-current-buffer gnus-original-article-buffer
5890 (and (equal (car gnus-original-article) group)
5891 (eq (cdr gnus-original-article) article))))
5892 (insert-buffer-substring gnus-original-article-buffer)
5894 ;; Check the backlog.
5895 ((and gnus-keep-backlog
5896 (gnus-backlog-request-article group article (current-buffer)))
5898 ;; Check asynchronous pre-fetch.
5899 ((gnus-async-request-fetched-article group article (current-buffer))
5900 (gnus-async-prefetch-next group article gnus-summary-buffer)
5901 (when (and (numberp article) gnus-keep-backlog)
5902 (gnus-backlog-enter-article group article (current-buffer)))
5905 ((and gnus-use-cache
5907 (gnus-cache-request-article article group))
5909 ;; Check the agent cache.
5910 ((gnus-agent-request-article article group)
5912 ;; Get the article and put into the article buffer.
5913 ((or (stringp article)
5915 (let ((gnus-override-method gnus-override-method)
5916 (methods (and (stringp article)
5917 gnus-refer-article-method))
5918 (backend (car (gnus-find-method-for-group
5919 gnus-newsgroup-name)))
5921 (inhibit-read-only t))
5922 (if (or (not (listp methods))
5923 (and (symbolp (car methods))
5924 (assq (car methods) nnoo-definition-alist)))
5925 (setq methods (list methods)))
5926 (when (and (null gnus-override-method)
5928 (setq gnus-override-method (pop methods)))
5930 (when (eq gnus-override-method 'current)
5931 (setq gnus-override-method
5932 (with-current-buffer gnus-summary-buffer
5933 gnus-current-select-method)))
5935 (gnus-kill-all-overlays)
5936 (let ((gnus-newsgroup-name group))
5937 (gnus-check-group-server))
5939 ((gnus-request-article article group (current-buffer))
5940 (when (numberp article)
5941 (gnus-async-prefetch-next group article
5942 gnus-summary-buffer)
5943 (when gnus-keep-backlog
5944 (gnus-backlog-enter-article
5945 group article (current-buffer))))
5946 (setq result 'article))
5948 (setq gnus-override-method (pop methods)))
5949 ((not (string-match "^400 "
5950 (nnheader-get-report backend)))
5951 ;; If we get 400 server disconnect, reconnect and
5952 ;; retry; otherwise, assume the article has expired.
5953 (setq result 'done))))
5954 (and (eq result 'article) 'article)))
5958 ;; Associate this article with the current summary buffer.
5959 (setq gnus-article-current-summary gnus-summary-buffer)
5961 ;; Take the article from the original article buffer
5962 ;; and place it in the buffer it's supposed to be in.
5963 (when (and (get-buffer gnus-article-buffer)
5964 (equal (buffer-name (current-buffer))
5965 (buffer-name (get-buffer gnus-article-buffer))))
5967 (if (get-buffer gnus-original-article-buffer)
5968 (set-buffer gnus-original-article-buffer)
5969 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5970 (buffer-disable-undo)
5971 (setq major-mode 'gnus-original-article-mode)
5972 (setq buffer-read-only t))
5973 (let ((inhibit-read-only t))
5975 (insert-buffer-substring gnus-article-buffer))
5976 (setq gnus-original-article (cons group article)))
5979 (run-hooks 'gnus-article-decode-hook)
5980 ;; Mark article as decoded or not.
5981 (setq gnus-article-decoded-p gnus-article-decode-hook))
5983 ;; Update sparse articles.
5984 (when (and do-update-line
5985 (or (numberp article)
5987 (let ((buf (current-buffer)))
5988 (set-buffer gnus-summary-buffer)
5989 (gnus-summary-update-article do-update-line sparse-header)
5990 (gnus-summary-goto-subject do-update-line nil t)
5991 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5993 (set-buffer buf))))))
5999 (defcustom gnus-article-edit-mode-hook nil
6000 "Hook run in article edit mode buffers."
6001 :group 'gnus-article-various
6004 (defcustom gnus-article-edit-article-setup-function
6005 'gnus-article-mime-edit-article-setup
6006 "Function called to setup an editing article buffer."
6007 :group 'gnus-article-various
6010 (defvar gnus-article-edit-done-function nil)
6012 (defvar gnus-article-edit-mode-map nil)
6014 ;; Should we be using derived.el for this?
6015 (unless gnus-article-edit-mode-map
6016 (setq gnus-article-edit-mode-map (make-keymap))
6017 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
6019 (gnus-define-keys gnus-article-edit-mode-map
6020 "\C-c?" describe-mode
6021 "\C-c\C-c" gnus-article-edit-done
6022 "\C-c\C-k" gnus-article-edit-exit
6023 "\C-c\C-f\C-t" message-goto-to
6024 "\C-c\C-f\C-o" message-goto-from
6025 "\C-c\C-f\C-b" message-goto-bcc
6026 ;;"\C-c\C-f\C-w" message-goto-fcc
6027 "\C-c\C-f\C-c" message-goto-cc
6028 "\C-c\C-f\C-s" message-goto-subject
6029 "\C-c\C-f\C-r" message-goto-reply-to
6030 "\C-c\C-f\C-n" message-goto-newsgroups
6031 "\C-c\C-f\C-d" message-goto-distribution
6032 "\C-c\C-f\C-f" message-goto-followup-to
6033 "\C-c\C-f\C-m" message-goto-mail-followup-to
6034 "\C-c\C-f\C-k" message-goto-keywords
6035 "\C-c\C-f\C-u" message-goto-summary
6036 "\C-c\C-f\C-i" message-insert-or-toggle-importance
6037 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
6038 "\C-c\C-b" message-goto-body
6039 "\C-c\C-i" message-goto-signature
6041 "\C-c\C-t" message-insert-to
6042 "\C-c\C-n" message-insert-newsgroups
6043 "\C-c\C-o" message-sort-headers
6044 "\C-c\C-e" message-elide-region
6045 "\C-c\C-v" message-delete-not-region
6046 "\C-c\C-z" message-kill-to-signature
6047 "\M-\r" message-newline-and-reformat
6048 "\C-c\C-a" mml-attach-file
6049 "\C-a" message-beginning-of-line
6051 "\M-;" comment-region)
6053 (gnus-define-keys (gnus-article-edit-wash-map
6054 "\C-c\C-w" gnus-article-edit-mode-map)
6055 "f" gnus-article-edit-full-stops))
6058 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
6060 ["Fetch To" message-insert-to t]
6061 ["Fetch Newsgroups" message-insert-newsgroups t]
6063 ["To" message-goto-to t]
6064 ["From" message-goto-from t]
6065 ["Subject" message-goto-subject t]
6066 ["Cc" message-goto-cc t]
6067 ["Reply-To" message-goto-reply-to t]
6068 ["Summary" message-goto-summary t]
6069 ["Keywords" message-goto-keywords t]
6070 ["Newsgroups" message-goto-newsgroups t]
6071 ["Followup-To" message-goto-followup-to t]
6072 ["Mail-Followup-To" message-goto-mail-followup-to t]
6073 ["Distribution" message-goto-distribution t]
6074 ["Body" message-goto-body t]
6075 ["Signature" message-goto-signature t]))
6077 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
6078 "Major mode for editing articles.
6079 This is an extended text-mode.
6081 \\{gnus-article-edit-mode-map}"
6082 (make-local-variable 'gnus-article-edit-done-function)
6083 (make-local-variable 'gnus-prev-winconf)
6084 (set (make-local-variable 'font-lock-defaults)
6085 '(message-font-lock-keywords t))
6086 (set (make-local-variable 'mail-header-separator) "")
6087 (set (make-local-variable 'gnus-article-edit-mode) t)
6088 (easy-menu-add message-mode-field-menu message-mode-map)
6089 (setq buffer-read-only nil)
6090 (buffer-enable-undo)
6093 (defun gnus-article-edit (&optional force)
6094 "Edit the current article.
6095 This will have permanent effect only in mail groups.
6096 If FORCE is non-nil, allow editing of articles even in read-only
6099 (when (and (not force)
6100 (gnus-group-read-only-p))
6101 (error "The current newsgroup does not support article editing"))
6102 (gnus-article-date-original)
6103 (gnus-article-edit-article
6105 `(lambda (no-highlight)
6107 (gnus-summary-edit-article-done
6108 ,(or (mail-header-references gnus-current-headers) "")
6109 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
6111 (defun gnus-article-edit-article (start-func exit-func)
6112 "Start editing the contents of the current article buffer."
6113 (let ((winconf (current-window-configuration)))
6114 (set-buffer gnus-article-buffer)
6115 (let ((message-auto-save-directory
6116 ;; Don't associate the article buffer with a draft file.
6118 (gnus-article-edit-mode))
6119 (funcall start-func)
6120 (set-buffer-modified-p nil)
6121 (gnus-configure-windows 'edit-article)
6122 (setq gnus-article-edit-done-function exit-func)
6123 (setq gnus-prev-winconf winconf)
6124 (when gnus-article-edit-article-setup-function
6125 (funcall gnus-article-edit-article-setup-function))
6126 (gnus-message 6 "C-c C-c to end edits; C-c C-k to exit")))
6128 (defun gnus-article-edit-done (&optional arg)
6129 "Update the article edits and exit."
6131 (let ((func gnus-article-edit-done-function)
6132 (buf (current-buffer))
6133 (start (window-start))
6135 (winconf gnus-prev-winconf))
6136 (remove-hook 'gnus-article-mode-hook
6137 'gnus-article-mime-edit-article-unwind)
6138 (widen) ;; Widen it in case that users narrowed the buffer.
6141 ;; The cache and backlog have to be flushed somewhat.
6142 (when gnus-keep-backlog
6143 (gnus-backlog-remove-article
6144 (car gnus-article-current) (cdr gnus-article-current)))
6145 ;; Flush original article as well.
6147 (when (get-buffer gnus-original-article-buffer)
6148 (set-buffer gnus-original-article-buffer)
6149 (setq gnus-original-article nil)))
6150 (when gnus-use-cache
6151 (gnus-cache-update-article
6152 (car gnus-article-current) (cdr gnus-article-current)))
6153 ;; We remove all text props from the article buffer.
6154 (kill-all-local-variables)
6155 (set-text-properties (point-min) (point-max) nil)
6157 (set-window-configuration winconf)
6159 (set-window-start (get-buffer-window buf) start)
6160 (set-window-point (get-buffer-window buf) (point)))
6161 (gnus-summary-show-article))
6163 (defun gnus-article-edit-exit ()
6164 "Exit the article editing without updating."
6166 (when (or (not (buffer-modified-p))
6167 (yes-or-no-p "Article modified; kill anyway? "))
6168 (let ((curbuf (current-buffer))
6170 (window-start (window-start)))
6172 (if (gnus-buffer-live-p gnus-original-article-buffer)
6173 (insert-buffer-substring gnus-original-article-buffer))
6174 (let ((winconf gnus-prev-winconf))
6175 (kill-all-local-variables)
6177 (set-window-configuration winconf)
6178 ;; Tippy-toe some to make sure that point remains where it was.
6179 (save-current-buffer
6181 (set-window-start (get-buffer-window (current-buffer)) window-start)
6183 (gnus-summary-show-article)))
6185 (defun gnus-article-edit-full-stops ()
6186 "Interactively repair spacing at end of sentences."
6189 (goto-char (point-min))
6190 (search-forward-regexp "^$" nil t)
6191 (let ((case-fold-search nil))
6192 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
6195 ;;; Article editing with MIME-Edit
6198 (defcustom gnus-article-mime-edit-article-setup-hook nil
6199 "Hook run after setting up a MIME editing article buffer."
6200 :group 'gnus-article-various
6203 (defun gnus-article-mime-edit-article-unwind ()
6204 "Unwind `gnus-article-buffer' if article editing was given up."
6205 (remove-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6206 (when (featurep 'font-lock)
6207 (setq font-lock-defaults nil)
6208 (font-lock-mode -1))
6209 (when mime-edit-mode-flag
6210 (mime-edit-exit 'nomime 'no-error)
6213 (defun gnus-article-mime-edit-article-setup ()
6214 "Convert current buffer to MIME-Edit buffer and turn on MIME-Edit mode
6215 after replacing with the original article."
6216 (setq gnus-show-mime t)
6217 (setq gnus-article-edit-done-function
6218 `(lambda (&rest args)
6219 (when mime-edit-mode-flag
6220 (let (mime-edit-insert-user-agent-field)
6223 (goto-char (point-min))
6224 (let (case-fold-search)
6225 (when (re-search-forward
6226 (format "^%s$" (regexp-quote mail-header-separator))
6228 (replace-match "")))
6229 (apply ,gnus-article-edit-done-function args)
6232 (buffer-substring-no-properties (point-min) (point-max))
6233 (set-buffer (get-buffer-create gnus-original-article-buffer))
6235 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6236 (set-buffer gnus-article-buffer)
6237 (gnus-article-prepare-display)))
6238 (substitute-key-definition 'gnus-article-edit-done
6239 'gnus-article-mime-edit-done
6240 gnus-article-edit-mode-map)
6241 (substitute-key-definition 'gnus-article-edit-exit
6242 'gnus-article-mime-edit-exit
6243 gnus-article-edit-mode-map)
6245 (insert-buffer-substring gnus-original-article-buffer)
6246 (unless (member (with-current-buffer gnus-summary-buffer
6247 gnus-newsgroup-name)
6248 '("nndraft:delayed" "nndraft:drafts"))
6249 (let ((ofn (symbol-function 'mime-edit-decode-single-part-in-buffer)))
6250 (fset 'mime-edit-decode-single-part-in-buffer
6251 (lambda (&rest args)
6252 (if (let ((content-type (car args)))
6253 (and (eq 'message (mime-content-type-primary-type
6255 (eq 'rfc822 (mime-content-type-subtype
6257 (setcar (cdr args) 'not-decode-text))
6261 (fset 'mime-edit-decode-single-part-in-buffer ofn))))
6262 (when (featurep 'font-lock)
6263 (set (make-local-variable 'font-lock-defaults)
6264 '(message-font-lock-keywords t))
6265 (font-lock-set-defaults)
6266 (turn-on-font-lock))
6267 (set-buffer-modified-p nil)
6268 (delete-other-windows)
6269 (add-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6270 (gnus-run-hooks 'gnus-article-mime-edit-article-setup-hook))
6272 (defun gnus-article-mime-edit-done (&optional arg)
6273 "Update the article MIME edits and exit."
6275 (when (featurep 'font-lock)
6276 (setq font-lock-defaults nil)
6277 (font-lock-mode -1))
6278 (let ((inhibit-read-only t))
6279 (gnus-article-edit-done arg)))
6281 (defun gnus-article-mime-edit-exit ()
6282 "Exit the article MIME editing without updating."
6284 (when (or (not (buffer-modified-p))
6285 (yes-or-no-p "Article modified; kill anyway? "))
6286 (when (featurep 'font-lock)
6287 (setq font-lock-defaults nil)
6288 (font-lock-mode -1))
6289 (when mime-edit-mode-flag
6290 (let (mime-edit-insert-user-agent-field)
6293 (goto-char (point-min))
6294 (let (case-fold-search)
6295 (when (re-search-forward
6296 (format "^%s$" (regexp-quote mail-header-separator)) nil t)
6297 (replace-match "")))
6298 (let ((winconf gnus-prev-winconf))
6300 (buffer-substring-no-properties (point-min) (point-max))
6301 (set-buffer (get-buffer-create gnus-original-article-buffer))
6303 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6304 (set-buffer gnus-article-buffer)
6305 (gnus-article-prepare-display)
6306 (set-window-configuration winconf))))
6309 ;;; Article highlights
6312 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
6314 ;;; Internal Variables:
6316 (defcustom gnus-button-url-regexp
6317 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
6318 "\\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:]]\\)"
6319 "\\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\\)\\)")
6320 "Regular expression that matches URLs."
6321 :group 'gnus-article-buttons
6324 (defcustom gnus-button-valid-fqdn-regexp
6325 message-valid-fqdn-regexp
6326 "Regular expression that matches a valid FQDN."
6328 :group 'gnus-article-buttons
6331 (defcustom gnus-button-man-handler 'manual-entry
6332 "Function to use for displaying man pages.
6333 The function must take at least one argument with a string naming the
6336 :type '(choice (function-item :tag "Man" manual-entry)
6337 (function-item :tag "Woman" woman)
6338 (function :tag "Other"))
6339 :group 'gnus-article-buttons)
6341 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
6342 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
6343 If the default site is too slow, try to find a CTAN mirror, see
6344 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
6345 the variable `gnus-button-handle-ctan'."
6347 :group 'gnus-article-buttons
6348 :link '(custom-manual "(gnus)Group Parameters")
6349 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
6350 (const "http://tug.ctan.org/tex-archive/")
6351 (const "http://www.dante.de/CTAN/")
6352 (string :tag "Other")))
6354 (defcustom gnus-button-ctan-handler 'browse-url
6355 "Function to use for displaying CTAN links.
6356 The function must take one argument, the string naming the URL."
6358 :type '(choice (function-item :tag "Browse Url" browse-url)
6359 (function :tag "Other"))
6360 :group 'gnus-article-buttons)
6362 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
6363 "Bogus strings removed from CTAN URLs."
6365 :group 'gnus-article-buttons
6366 :type '(choice (const "^/?tex-archive/\\|/")
6367 (regexp :tag "Other")))
6369 (defcustom gnus-button-ctan-directory-regexp
6372 "biblio\\|digests\\|dviware\\|fonts\\|graphics\\|help\\|"
6373 "indexing\\|info\\|language\\|macros\\|support\\|systems\\|"
6374 "tds\\|tools\\|usergrps\\|web\\|nonfree\\|obsolete"
6376 "Regular expression for ctan directories.
6377 It should match all directories in the top level of `gnus-ctan-url'."
6379 :group 'gnus-article-buttons
6382 (defcustom gnus-button-mid-or-mail-regexp
6383 (concat "\\b\\(<?[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t ]*@"
6384 ;; Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
6385 gnus-button-valid-fqdn-regexp
6387 "Regular expression that matches a message ID or a mail address."
6389 :group 'gnus-article-buttons
6392 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
6393 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
6394 Strings like this can be either a message ID or a mail address. If it is one
6395 of the symbols `mid' or `mail', Gnus will always assume that the string is a
6396 message ID or a mail address, respectively. If this variable is set to the
6397 symbol `ask', always query the user what do do. If it is a function, this
6398 function will be called with the string as it's only argument. The function
6399 must return `mid', `mail', `invalid' or `ask'."
6401 :group 'gnus-article-buttons
6402 :type '(choice (function-item :tag "Heuristic function"
6403 gnus-button-mid-or-mail-heuristic)
6408 (defcustom gnus-button-mid-or-mail-heuristic-alist
6409 '((-10.0 . ".+\\$.+@")
6412 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
6413 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
6414 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
6415 (-1.0 . "^[^a-z]+@")
6417 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
6418 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
6419 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
6420 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
6423 (-1.0 . "^[0-9][0-9]")
6425 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
6426 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6427 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
6428 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6430 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
6431 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
6434 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
6436 ;; compensation for TDMA dated mail addresses:
6437 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
6439 (-20.0 . "\\.fsf@") ;; Gnus
6442 (-20.0 . "_-_") ;; Subject change in thread
6444 (-20.0 . "\\.ln@") ;; leafnode
6445 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
6446 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
6448 ;; (5.0 . "") ;; $local_part_len <= 7
6449 (10.0 . "^[^0-9]+@")
6450 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
6451 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
6454 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
6456 (0.5 . "^[A-Z][a-z]")
6457 (0.5 . "^[A-Z][a-z][a-z]")
6458 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
6459 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
6460 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
6462 A negative RATE indicates a message IDs, whereas a positive indicates a mail
6463 address. The REGEXP is processed with `case-fold-search' set to nil."
6465 :group 'gnus-article-buttons
6466 :type '(repeat (cons (number :tag "Rate")
6467 (regexp :tag "Regexp"))))
6469 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
6470 "Guess whether MID-OR-MAIL is a message ID or a mail address.
6471 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
6472 address, `ask' if unsure and `invalid' if the string is invalid."
6473 (let ((case-fold-search nil)
6474 (list gnus-button-mid-or-mail-heuristic-alist)
6475 (result 0) rate regexp lpartlen elem)
6477 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
6478 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
6479 ;; Certain special cases...
6482 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
6483 "^[0-9]+\\.[0-9]+@compuserve\\|"
6484 "@public\\.gmane\\.org")
6486 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
6487 (setq result 'mail))
6488 (when (string-match "@.*@\\| " mid-or-mail)
6489 (gnus-message 8 "`%s' is invalid." mid-or-mail)
6490 (setq result 'invalid))
6491 ;; Nothing more to do, if result is not a number here...
6492 (when (numberp result)
6494 (setq elem (car list)
6498 (when (string-match regexp mid-or-mail)
6499 (setq result (+ result rate))
6501 9 "`%s' matched `%s', rate `%s', result `%s'."
6502 mid-or-mail regexp rate result)))
6503 (when (<= lpartlen 7)
6504 (setq result (+ result 5.0))
6505 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
6506 mid-or-mail result))
6507 (when (>= lpartlen 12)
6508 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
6510 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
6511 ;; Long local part should contain realname if e-mail address,
6512 ;; too many digits: message-id.
6513 ;; $score -= 5.0 + 0.1 * $local_part_len;
6514 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6515 (setq result (+ result rate))
6517 9 "Many digits in `%s', rate `%s', result `%s'."
6518 mid-or-mail rate result))
6519 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6521 ;; Too few vowels [^aeiouy]{4,}.*\@
6522 (setq result (+ result -5.0))
6524 9 "Few vowels in `%s', rate `%s', result `%s'."
6525 mid-or-mail -5.0 result))
6527 (setq result (+ result 5.0))
6529 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6530 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6531 ;; Maybe we should make this a customizable alist: (condition . 'result)
6533 ((symbolp result) result)
6534 ;; Now convert number into proper results:
6535 ((< result -10.0) 'mid)
6536 ((> result 10.0) 'mail)
6539 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6540 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6541 (url-mid (concat "news" ":" mid-or-mail))
6542 (url-mailto (concat "mailto" ":" mid-or-mail)))
6543 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6544 (when (fboundp pref)
6546 ;; get rid of surrounding angles...
6548 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6549 (if (or (eq 'mid guessed) (eq 'mail guessed))
6553 (save-window-excursion
6554 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6557 (cond ((eq pref 'mid)
6558 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6559 (gnus-button-handle-news url-mid))
6561 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6562 (gnus-url-mailto url-mailto))
6563 (t (gnus-message 3 "Invalid string.")))))
6565 (defun gnus-button-handle-custom (url)
6566 "Follow a Custom URL."
6567 (customize-apropos (gnus-url-unhex-string url)))
6569 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6571 ;; FIXME: Maybe we should merge some of the functions that do quite similar
6574 (defun gnus-button-handle-describe-function (url)
6575 "Call `describe-function' when pushing the corresponding URL button."
6578 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6580 (defun gnus-button-handle-describe-variable (url)
6581 "Call `describe-variable' when pushing the corresponding URL button."
6584 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6586 (defun gnus-button-handle-symbol (url)
6587 "Display help on variable or function.
6588 Calls `describe-variable' or `describe-function'."
6589 (let ((sym (intern url)))
6591 ((fboundp sym) (describe-function sym))
6592 ((boundp sym) (describe-variable sym))
6593 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
6595 (defun gnus-button-handle-describe-key (url)
6596 "Call `describe-key' when pushing the corresponding URL button."
6598 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6599 (keys (ignore-errors (eval `(kbd ,key-string)))))
6602 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6604 (defun gnus-button-handle-apropos (url)
6605 "Call `apropos' when pushing the corresponding URL button."
6606 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6608 (defun gnus-button-handle-apropos-command (url)
6609 "Call `apropos' when pushing the corresponding URL button."
6611 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6613 (defun gnus-button-handle-apropos-variable (url)
6614 "Call `apropos' when pushing the corresponding URL button."
6616 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6617 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6619 (defun gnus-button-handle-apropos-documentation (url)
6620 "Call `apropos' when pushing the corresponding URL button."
6622 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6623 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6625 (defun gnus-button-handle-library (url)
6626 "Call `locate-library' when pushing the corresponding URL button."
6627 (gnus-message 9 "url=`%s'" url)
6628 (let* ((lib (locate-library url))
6629 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6631 (gnus-message 1 "Cannot locale library `%s'." url)
6632 (find-file-read-only file))))
6634 (defun gnus-button-handle-ctan (url)
6635 "Call `browse-url' when pushing a CTAN URL button."
6637 gnus-button-ctan-handler
6640 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6642 (defcustom gnus-button-tex-level 5
6643 "*Integer that says how many TeX-related buttons Gnus will show.
6644 The higher the number, the more buttons will appear and the more false
6645 positives are possible. Note that you can set this variable local to
6646 specific groups. Setting it higher in TeX groups is probably a good idea.
6647 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6648 how to set variables in specific groups."
6650 :group 'gnus-article-buttons
6651 :link '(custom-manual "(gnus)Group Parameters")
6654 (defcustom gnus-button-man-level 5
6655 "*Integer that says how many man-related buttons Gnus will show.
6656 The higher the number, the more buttons will appear and the more false
6657 positives are possible. Note that you can set this variable local to
6658 specific groups. Setting it higher in Unix groups is probably a good idea.
6659 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6660 how to set variables in specific groups."
6662 :group 'gnus-article-buttons
6663 :link '(custom-manual "(gnus)Group Parameters")
6666 (defcustom gnus-button-emacs-level 5
6667 "*Integer that says how many emacs-related buttons Gnus will show.
6668 The higher the number, the more buttons will appear and the more false
6669 positives are possible. Note that you can set this variable local to
6670 specific groups. Setting it higher in Emacs or Gnus related groups is
6671 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6672 `gnus-parameters' on how to set variables in specific groups."
6674 :group 'gnus-article-buttons
6675 :link '(custom-manual "(gnus)Group Parameters")
6678 (defcustom gnus-button-message-level 5
6679 "*Integer that says how many buttons for news or mail messages will appear.
6680 The higher the number, the more buttons will appear and the more false
6681 positives are possible."
6682 ;; mail addresses, MIDs, URLs for news, ...
6684 :group 'gnus-article-buttons
6687 (defcustom gnus-button-browse-level 5
6688 "*Integer that says how many buttons for browsing will appear.
6689 The higher the number, the more buttons will appear and the more false
6690 positives are possible."
6691 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6693 :group 'gnus-article-buttons
6696 (defcustom gnus-button-alist
6697 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6698 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6699 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
6700 gnus-button-handle-news 2)
6701 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6702 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6703 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6704 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6705 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
6706 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
6707 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
6708 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6709 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6710 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6711 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6712 ;; RFC 2368 (The mailto URL scheme)
6713 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6714 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6715 ("\\bmailto:\\([^ \n\t]+\\)"
6716 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6718 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6719 gnus-button-ctan-directory-regexp
6720 "[^][>)!;:,'\n\t ]+\\)")
6721 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6722 ((concat "\\btex-archive/\\("
6723 gnus-button-ctan-directory-regexp
6724 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6725 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6728 gnus-button-ctan-directory-regexp
6729 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6730 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6731 ;; This is info (home-grown style) <info://foo/bar+baz>
6732 ("\\binfo://\\([^'\">\n\t ]+\\)"
6733 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6734 ;; Info GNOME style <info:foo#bar_baz>
6735 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6736 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6737 ;; Info KDE style <info:(foo)bar baz>
6738 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6739 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6740 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6741 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6742 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6743 ;; Info links like `C-h i d m CC Mode RET'
6744 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6746 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6747 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6748 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6749 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6750 ;; Emacs help commands
6751 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6752 ;; regexp doesn't match arguments containing ` '.
6753 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6754 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6755 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6756 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6757 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6758 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6759 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6760 ;; The following entries may lead to many false positives so don't enable
6761 ;; them by default (use a high button level).
6762 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
6763 ;; Exclude [.?] for URLs in gmane.emacs.cvs
6764 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6765 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6766 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6767 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6768 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6769 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6770 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6771 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6772 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6773 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6774 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
6775 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6776 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6777 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6778 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6779 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6780 ;; Unlike the other regexps we really have to require quoting
6781 ;; here to determine where it ends.
6782 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6783 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
6784 ("<URL: *\\([^<>]*\\)>"
6785 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6786 ;; RFC 2396 (2.4.3., delims) ...
6787 ("\"URL: *\\([^\"]*\\)\""
6788 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6789 ;; RFC 2396 (2.4.3., delims) ...
6790 ("\"URL: *\\([^\"]*\\)\""
6791 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6793 (gnus-button-url-regexp
6794 0 (>= gnus-button-browse-level 0) browse-url 0)
6796 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
6797 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6798 gnus-button-handle-man 1)
6799 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6800 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
6801 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6802 gnus-button-handle-man 1)
6803 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6804 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6805 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
6806 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6807 ;; MID or mail: To avoid too many false positives we don't try to catch
6808 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6809 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6810 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6811 ;; so that non-ambiguous entries (see above) match first.
6812 (gnus-button-mid-or-mail-regexp
6813 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6814 "*Alist of regexps matching buttons in article bodies.
6816 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6817 REGEXP: is the string (case insensitive) matching text around the button (can
6818 also be Lisp expression evaluating to a string),
6819 BUTTON: is the number of the regexp grouping actually matching the button,
6820 FORM: is a Lisp expression which must eval to true for the button to
6822 CALLBACK: is the function to call when the user push this button, and each
6823 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6825 CALLBACK can also be a variable, in that case the value of that
6826 variable it the real callback function."
6827 :group 'gnus-article-buttons
6828 :type '(repeat (list (choice regexp variable sexp)
6829 (integer :tag "Button")
6831 (function :tag "Callback")
6834 (integer :tag "Regexp group")))))
6836 (defcustom gnus-header-button-alist
6837 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
6838 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6839 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6840 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6841 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6842 0 (>= gnus-button-message-level 0) gnus-msg-mail 0)
6843 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6844 0 (>= gnus-button-browse-level 0) browse-url 0)
6845 ("^Subject:" gnus-button-url-regexp
6846 0 (>= gnus-button-browse-level 0) browse-url 0)
6847 ("^[^:]+:" gnus-button-url-regexp
6848 0 (>= gnus-button-browse-level 0) browse-url 0)
6849 ("^OpenPGP:.*url=" gnus-button-url-regexp
6850 0 (>= gnus-button-browse-level 0) gnus-button-openpgp 0)
6851 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6852 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6853 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6854 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6855 "*Alist of headers and regexps to match buttons in article heads.
6857 This alist is very similar to `gnus-button-alist', except that each
6858 alist has an additional HEADER element first in each entry:
6860 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6862 HEADER is a regexp to match a header. For a fuller explanation, see
6863 `gnus-button-alist'."
6864 :group 'gnus-article-buttons
6865 :group 'gnus-article-headers
6866 :type '(repeat (list (regexp :tag "Header")
6867 (choice regexp variable)
6868 (integer :tag "Button")
6870 (function :tag "Callback")
6873 (integer :tag "Regexp group")))))
6877 (defun gnus-article-push-button (event)
6878 "Check text under the mouse pointer for a callback function.
6879 If the text under the mouse pointer has a `gnus-callback' property,
6880 call it with the value of the `gnus-data' text property."
6882 (set-buffer (window-buffer (posn-window (event-start event))))
6883 (let* ((pos (posn-point (event-start event)))
6884 (data (get-text-property pos 'gnus-data))
6885 (fun (get-text-property pos 'gnus-callback)))
6888 (funcall fun data))))
6890 (defun gnus-article-press-button ()
6891 "Check text at point for a callback function.
6892 If the text at point has a `gnus-callback' property,
6893 call it with the value of the `gnus-data' text property."
6895 (let ((data (get-text-property (point) 'gnus-data))
6896 (fun (get-text-property (point) 'gnus-callback)))
6898 (funcall fun data))))
6900 (defun gnus-article-prev-button (n)
6901 "Move point to N buttons backward.
6902 If N is negative, move forward instead."
6904 (gnus-article-next-button (- n)))
6906 (defun gnus-article-next-button (n)
6907 "Move point to N buttons forward.
6908 If N is negative, move backward instead."
6910 (let ((function (if (< n 0) 'previous-single-property-change
6911 'next-single-property-change))
6912 (inhibit-point-motion-hooks t)
6914 (limit (if (< n 0) (point-min) (point-max))))
6916 (while (and (not (= limit (point)))
6918 ;; Skip past the current button.
6919 (when (get-text-property (point) 'gnus-callback)
6920 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6921 ;; Go to the next (or previous) button.
6922 (gnus-goto-char (funcall function (point) 'gnus-callback nil limit))
6923 ;; Put point at the start of the button.
6924 (when (and backward (not (get-text-property (point) 'gnus-callback)))
6925 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6926 ;; Skip past intangible buttons.
6927 (when (get-text-property (point) 'intangible)
6931 (gnus-message 5 "No more buttons"))
6934 (defun gnus-article-highlight (&optional force)
6935 "Highlight current article.
6936 This function calls `gnus-article-highlight-headers',
6937 `gnus-article-highlight-citation',
6938 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6939 do the highlighting. See the documentation for those functions."
6940 (interactive (list 'force))
6941 (gnus-article-highlight-headers)
6942 (gnus-article-highlight-citation force)
6943 (gnus-article-highlight-signature)
6944 (gnus-article-add-buttons force)
6945 (gnus-article-add-buttons-to-head))
6947 (defun gnus-article-highlight-some (&optional force)
6948 "Highlight current article.
6949 This function calls `gnus-article-highlight-headers',
6950 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6951 do the highlighting. See the documentation for those functions."
6952 (interactive (list 'force))
6953 (gnus-article-highlight-headers)
6954 (gnus-article-highlight-signature)
6955 (gnus-article-add-buttons))
6957 (defun gnus-article-highlight-headers ()
6958 "Highlight article headers as specified by `gnus-header-face-alist'."
6960 (gnus-with-article-headers
6961 (let (regexp header-face field-face from hpoints fpoints)
6962 (dolist (entry gnus-header-face-alist)
6963 (goto-char (point-min))
6964 (setq regexp (concat "^\\("
6965 (if (string-equal "" (nth 0 entry))
6969 header-face (nth 1 entry)
6970 field-face (nth 2 entry))
6971 (while (and (re-search-forward regexp nil t)
6975 (unless (search-forward ":" nil t)
6977 (when (and header-face
6978 (not (memq (point) hpoints)))
6979 (push (point) hpoints)
6980 (gnus-put-text-property from (point) 'face header-face))
6981 (when (and field-face
6982 (not (memq (setq from (point)) fpoints)))
6984 (if (re-search-forward "^[^ \t]" nil t)
6986 (goto-char (point-max)))
6987 (gnus-put-text-property from (point) 'face field-face)))))))
6989 (defun gnus-article-highlight-signature ()
6990 "Highlight the signature in an article.
6991 It does this by highlighting everything after
6992 `gnus-signature-separator' using `gnus-signature-face'."
6994 (when gnus-signature-face
6995 (gnus-with-article-buffer
6996 (let ((inhibit-point-motion-hooks t))
6998 (when (gnus-article-narrow-to-signature)
6999 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
7000 'face gnus-signature-face)))))))
7002 (defun gnus-article-buttonize-signature ()
7003 "Add button to the signature."
7006 (set-buffer gnus-article-buffer)
7007 (let ((inhibit-read-only t)
7008 (inhibit-point-motion-hooks t))
7009 (when (gnus-article-search-signature)
7010 (gnus-article-add-button (match-beginning 0) (match-end 0)
7011 'gnus-signature-toggle
7012 (set-marker (make-marker)
7013 (1+ (match-end 0))))))))
7015 (defun gnus-button-in-region-p (b e prop)
7016 "Say whether PROP exists in the region."
7017 (text-property-not-all b e prop nil))
7019 (defun gnus-article-add-buttons (&optional force)
7020 "Find external references in the article and make buttons of them.
7021 \"External references\" are things like Message-IDs and URLs, as
7022 specified by `gnus-button-alist'."
7023 (interactive (list 'force))
7024 (gnus-with-article-buffer
7025 (let ((inhibit-point-motion-hooks t)
7026 (case-fold-search t)
7027 (alist gnus-button-alist)
7029 ;; Remove all old markers.
7030 (let (marker entry new-list)
7031 (while (setq marker (pop gnus-button-marker-list))
7032 (if (or (< marker (point-min)) (>= marker (point-max)))
7033 (push marker new-list)
7035 (when (setq entry (gnus-button-entry))
7036 (put-text-property (match-beginning (nth 1 entry))
7037 (match-end (nth 1 entry))
7038 'gnus-callback nil))
7039 (set-marker marker nil)))
7040 (setq gnus-button-marker-list new-list))
7041 ;; We skip the headers.
7044 (while (setq entry (pop alist))
7045 (setq regexp (eval (car entry)))
7047 (while (re-search-forward regexp nil t)
7048 (let* ((start (and entry (match-beginning (nth 1 entry))))
7049 (end (and entry (match-end (nth 1 entry))))
7050 (from (match-beginning 0)))
7051 (when (and (or (eq t (nth 2 entry))
7052 (eval (nth 2 entry)))
7053 (not (gnus-button-in-region-p
7054 start end 'gnus-callback)))
7055 ;; That optional form returned non-nil, so we add the
7057 (gnus-article-add-button
7058 start end 'gnus-button-push
7059 (car (push (set-marker (make-marker) from)
7060 gnus-button-marker-list))))))))))
7062 ;; Add buttons to the head of an article.
7063 (defun gnus-article-add-buttons-to-head ()
7064 "Add buttons to the head of the article."
7066 (gnus-with-article-headers
7068 (dolist (entry gnus-header-button-alist)
7069 ;; Each alist entry.
7070 (goto-char (point-min))
7071 (while (re-search-forward (car entry) nil t)
7072 ;; Each header matching the entry.
7073 (setq beg (match-beginning 0))
7074 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
7075 (match-beginning 0))
7078 (while (re-search-forward (eval (nth 1 entry)) end t)
7079 ;; Each match within a header.
7080 (let* ((entry (cdr entry))
7081 (start (match-beginning (nth 1 entry)))
7082 (end (match-end (nth 1 entry)))
7083 (form (nth 2 entry)))
7084 (goto-char (match-end 0))
7086 (gnus-article-add-button
7087 start end (nth 3 entry)
7088 (buffer-substring (match-beginning (nth 4 entry))
7089 (match-end (nth 4 entry)))))))
7090 (goto-char end))))))
7092 ;;; External functions:
7094 (defun gnus-article-add-button (from to fun &optional data)
7095 "Create a button between FROM and TO with callback FUN and data DATA."
7096 (when gnus-article-button-face
7097 (gnus-overlay-put (gnus-make-overlay from to)
7098 'face gnus-article-button-face))
7099 (gnus-add-text-properties
7101 (nconc (and gnus-article-mouse-face
7102 (list gnus-mouse-face-prop gnus-article-mouse-face))
7103 (list 'gnus-callback fun)
7104 (and data (list 'gnus-data data))))
7105 (widget-convert-button 'link from to :action 'gnus-widget-press-button
7106 :button-keymap gnus-widget-button-keymap))
7108 ;;; Internal functions:
7110 (defun gnus-article-set-globals ()
7111 (with-current-buffer gnus-summary-buffer
7112 (gnus-set-global-variables)))
7114 (defun gnus-signature-toggle (end)
7115 (gnus-with-article-buffer
7116 (let ((inhibit-point-motion-hooks t)
7117 (limit (next-single-property-change end 'mime-view-entity
7119 (if (text-property-any end limit 'article-type 'signature)
7121 (gnus-delete-wash-type 'signature)
7122 (gnus-remove-text-properties-when
7123 'article-type 'signature end limit
7124 (cons 'article-type (cons 'signature
7125 gnus-hidden-properties))))
7126 (gnus-add-wash-type 'signature)
7127 (gnus-add-text-properties-when
7128 'article-type nil end limit
7129 (cons 'article-type (cons 'signature
7130 gnus-hidden-properties)))))
7131 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
7132 (gnus-set-mode-line 'article))))
7134 (defun gnus-button-entry ()
7135 ;; Return the first entry in `gnus-button-alist' matching this place.
7136 (let ((alist gnus-button-alist)
7139 (setq entry (pop alist))
7140 (if (looking-at (eval (car entry)))
7145 (defun gnus-button-push (marker)
7146 ;; Push button starting at MARKER.
7149 (let* ((entry (gnus-button-entry))
7150 (inhibit-point-motion-hooks t)
7152 (args (mapcar (lambda (group)
7153 (let ((string (match-string group)))
7154 (set-text-properties
7155 0 (length string) nil string)
7162 (fboundp (symbol-value fun)))
7163 (apply (symbol-value fun) args))
7165 (gnus-message 1 "You must define `%S' to use this button"
7166 (cons fun args)))))))
7168 (defun gnus-parse-news-url (url)
7169 (let (scheme server port group message-id articles)
7172 (goto-char (point-min))
7173 (when (looking-at "\\([A-Za-z]+\\):")
7174 (setq scheme (match-string 1))
7175 (goto-char (match-end 0)))
7176 (when (looking-at "//\\([^:/]+\\)\\(:?\\)\\([0-9]+\\)?/")
7177 (setq server (match-string 1))
7178 (setq port (if (stringp (match-string 3))
7179 (string-to-number (match-string 3))
7181 (goto-char (match-end 0)))
7184 ((looking-at "\\(.*@.*\\)")
7185 (setq message-id (match-string 1)))
7186 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
7187 (setq group (match-string 1)
7188 articles (split-string (match-string 2) "-")))
7189 ((looking-at "\\([^/]+\\)/?")
7190 (setq group (match-string 1)))
7192 (error "Unknown news URL syntax"))))
7193 (list scheme server port group message-id articles)))
7195 (defun gnus-button-handle-news (url)
7197 (destructuring-bind (scheme server port group message-id articles)
7198 (gnus-parse-news-url url)
7202 (set-buffer gnus-summary-buffer)
7204 (let ((gnus-refer-article-method
7205 (nconc (list (list 'nntp server))
7206 gnus-refer-article-method))
7207 (nntp-port-number (or port "nntp")))
7208 (gnus-message 7 "Fetching %s with %s"
7209 message-id gnus-refer-article-method)
7210 (gnus-summary-refer-article message-id))
7211 (gnus-summary-refer-article message-id))))
7213 (gnus-button-fetch-group url)))))
7215 (defun gnus-button-handle-man (url)
7217 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7218 (when (eq gnus-button-man-handler 'woman)
7219 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
7220 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7221 (funcall gnus-button-man-handler url))
7223 (defun gnus-button-handle-info-url (url)
7224 "Fetch an info URL."
7225 (setq url (mm-subst-char-in-string ?+ ?\ url))
7227 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
7228 (gnus-info-find-node
7229 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
7231 ")" (gnus-url-unhex-string (match-string 2 url)))))
7232 ((string-match "([^)\"]+)[^\"]+" url)
7234 (gnus-replace-in-string
7235 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
7236 (gnus-info-find-node url))
7237 (t (error "Can't parse %s" url))))
7239 (defun gnus-button-handle-info-url-gnome (url)
7240 "Fetch GNOME style info URL."
7241 (setq url (mm-subst-char-in-string ?_ ?\ url))
7242 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
7243 (gnus-info-find-node
7245 (gnus-url-unhex-string
7246 (match-string 1 url))
7248 (or (gnus-url-unhex-string
7249 (match-string 2 url))
7251 (error "Can't parse %s" url)))
7253 (defun gnus-button-handle-info-url-kde (url)
7254 "Fetch KDE style info URL."
7255 (gnus-info-find-node (gnus-url-unhex-string url)))
7257 (defun gnus-button-handle-info-keystrokes (url)
7258 "Call `info' when pushing the corresponding URL button."
7259 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
7264 (defun gnus-button-openpgp (url)
7265 "Retrieve and add an OpenPGP key given URL from an OpenPGP header."
7267 (mm-url-insert-file-contents-external url)
7268 (pgg-snarf-keys-region (point-min) (point-max))
7269 (pgg-display-output-buffer nil nil nil)))
7271 (defun gnus-button-message-id (message-id)
7273 (with-current-buffer gnus-summary-buffer
7274 (gnus-summary-refer-article message-id)))
7276 (defun gnus-button-fetch-group (address)
7277 "Fetch GROUP specified by ADDRESS."
7278 (if (not (string-match "[:/]" address))
7279 ;; This is just a simple group url.
7280 (gnus-group-read-ephemeral-group address gnus-select-method)
7283 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
7285 (error "Can't parse %s" address)
7286 (gnus-group-read-ephemeral-group
7287 (match-string 4 address)
7288 `(nntp ,(match-string 1 address)
7289 (nntp-address ,(match-string 1 address))
7290 (nntp-port-number ,(if (match-end 3)
7291 (match-string 3 address)
7294 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
7296 (defun gnus-url-parse-query-string (query &optional downcase)
7297 (let (retval pairs cur key val)
7298 (setq pairs (split-string query "&"))
7300 (setq cur (car pairs)
7302 (if (not (string-match "=" cur))
7304 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
7305 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
7307 (setq key (downcase key)))
7308 (setq cur (assoc key retval))
7310 (setcdr cur (cons val (cdr cur)))
7311 (setq retval (cons (list key val) retval)))))
7314 (defun gnus-url-mailto (url)
7315 ;; Send mail to someone
7316 (when (string-match "mailto:/*\\(.*\\)" url)
7317 (setq url (substring url (match-beginning 1) nil)))
7318 (let (to args subject func)
7319 (setq args (gnus-url-parse-query-string
7320 (if (string-match "^\\?" url)
7322 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
7323 (concat "to=" (match-string 1 url) "&"
7324 (match-string 2 url))
7325 (concat "to=" url)))
7327 subject (cdr-safe (assoc "subject" args)))
7330 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
7333 (message-position-on-field (caar args)))
7334 (insert (gnus-replace-in-string
7335 (mapconcat 'identity (reverse (cdar args)) ", ")
7337 (setq args (cdr args)))
7340 (message-goto-subject))))
7342 (defun gnus-button-embedded-url (address)
7343 "Activate ADDRESS with `browse-url'."
7344 (browse-url (gnus-strip-whitespace address)))
7346 ;;; Next/prev buttons in the article buffer.
7348 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
7349 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
7351 (defvar gnus-prev-page-map
7352 (let ((map (make-sparse-keymap)))
7353 (define-key map gnus-mouse-2 'gnus-button-prev-page)
7354 (define-key map "\r" 'gnus-button-prev-page)
7357 (defvar gnus-next-page-map
7358 (let ((map (make-sparse-keymap)))
7359 (unless (>= emacs-major-version 21)
7360 ;; XEmacs doesn't care.
7361 (set-keymap-parent map gnus-article-mode-map))
7362 (define-key map gnus-mouse-2 'gnus-button-next-page)
7363 (define-key map "\r" 'gnus-button-next-page)
7366 (defun gnus-insert-prev-page-button ()
7368 (inhibit-read-only t)
7369 (situation (get-text-property (point-min) 'mime-view-situation)))
7371 gnus-prev-page-line-format nil
7372 `(keymap ,gnus-prev-page-map
7374 gnus-callback gnus-article-button-prev-page
7375 article-type annotation
7376 mime-view-situation ,situation))
7377 (widget-convert-button
7379 ;; Exclude a newline.
7382 :action 'gnus-button-prev-page
7383 :button-keymap gnus-prev-page-map)))
7385 (defun gnus-button-next-page (&optional args more-args)
7386 "Go to the next page."
7388 (let ((win (selected-window)))
7389 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7390 (gnus-article-next-page)
7391 (select-window win)))
7393 (defun gnus-button-prev-page (&optional args more-args)
7394 "Go to the prev page."
7396 (let ((win (selected-window)))
7397 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7398 (gnus-article-prev-page)
7399 (select-window win)))
7401 (defun gnus-insert-next-page-button ()
7403 (inhibit-read-only t)
7404 (situation (get-text-property (point-min) 'mime-view-situation)))
7405 (gnus-eval-format gnus-next-page-line-format nil
7406 `(keymap ,gnus-next-page-map
7408 gnus-callback gnus-article-button-next-page
7409 article-type annotation
7410 mime-view-situation ,situation))
7411 (widget-convert-button
7413 ;; Exclude a newline.
7416 :action 'gnus-button-next-page
7417 :button-keymap gnus-next-page-map)))
7419 (defun gnus-article-button-next-page (arg)
7420 "Go to the next page."
7422 (let ((win (selected-window)))
7423 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7424 (gnus-article-next-page)
7425 (select-window win)))
7427 (defun gnus-article-button-prev-page (arg)
7428 "Go to the prev page."
7430 (let ((win (selected-window)))
7431 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7432 (gnus-article-prev-page)
7433 (select-window win)))
7435 (defvar gnus-decode-header-methods
7436 '(mail-decode-encoded-word-region)
7437 "List of methods used to decode headers.
7439 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
7440 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
7441 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
7442 whose names match REGEXP.
7445 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
7446 mail-decode-encoded-word-region
7447 (\"chinese\" . rfc1843-decode-region))
7450 (defvar gnus-decode-header-methods-cache nil)
7452 (defun gnus-multi-decode-header (start end)
7453 "Apply the functions from `gnus-encoded-word-methods' that match."
7454 (unless (and gnus-decode-header-methods-cache
7455 (eq gnus-newsgroup-name
7456 (car gnus-decode-header-methods-cache)))
7457 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
7460 (nconc gnus-decode-header-methods-cache (list x))
7461 (if (and gnus-newsgroup-name
7462 (string-match (car x) gnus-newsgroup-name))
7463 (nconc gnus-decode-header-methods-cache
7465 gnus-decode-header-methods))
7466 (let ((xlist gnus-decode-header-methods-cache))
7469 (narrow-to-region start end)
7471 (funcall (pop xlist) (point-min) (point-max))))))
7474 ;;; Treatment top-level handling.
7477 (defun gnus-treat-article (condition &optional part-number total-parts type)
7478 (let ((length (- (point-max) (point-min)))
7479 (alist gnus-treatment-function-alist)
7480 (article-goto-body-goes-to-point-min-p t)
7484 (let ((list gnus-article-treat-types))
7486 (when (string-match (pop list) type)
7487 (throw 'found t)))))))
7488 (highlightp (gnus-visual-p 'article-highlight 'highlight))
7489 (entity (static-unless (featurep 'xemacs)
7490 (when (eq 'head condition)
7491 (get-text-property (point-min) 'mime-view-entity))))
7492 val elem buttonized)
7493 (gnus-run-hooks 'gnus-part-display-hook)
7494 (unless gnus-inhibit-treatment
7495 (dolist (elem alist)
7498 (when (gnus-buffer-live-p gnus-summary-buffer)
7499 (set-buffer gnus-summary-buffer))
7500 (symbol-value (car elem))))
7501 (when (and (or (consp val)
7503 (gnus-treat-predicate val)
7504 (or (not (get (car elem) 'highlight))
7506 (when (and (not buttonized)
7508 '(gnus-treat-hide-signature
7509 gnus-treat-highlight-signature)))
7510 (gnus-article-buttonize-signature)
7511 (setq buttonized t))
7513 (funcall (cadr elem)))))
7514 ;; FSF Emacsen does not inherit the existing text properties
7515 ;; in the new text, so we should do it for `mime-view-entity'.
7516 (static-unless (featurep 'xemacs)
7518 (put-text-property (point-min) (point-max)
7519 'mime-view-entity entity))))))
7521 ;; Dynamic variables.
7523 (defvar part-number)
7524 (defvar total-parts)
7529 (defun gnus-treat-predicate (val)
7534 (stringp (car val)))
7535 (apply 'gnus-or (mapcar `(lambda (s)
7536 (string-match s ,(or gnus-newsgroup-name "")))
7539 (let ((pred (pop val)))
7542 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
7544 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
7546 (not (gnus-treat-predicate (car val))))
7548 (equal (car val) type))
7550 (error "%S is not a valid predicate" pred)))))
7560 (eq part-number total-parts))
7564 (error "%S is not a valid value" val))))
7566 (defun gnus-article-encrypt-body (protocol &optional n)
7567 "Encrypt the article body."
7570 (or gnus-article-encrypt-protocol
7571 (completing-read "Encrypt protocol: "
7572 gnus-article-encrypt-protocol-alist
7574 current-prefix-arg))
7575 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7577 (error (format "Can't find the encrypt protocol %s" protocol)))
7578 (if (member gnus-newsgroup-name '("nndraft:delayed"
7581 (error "Can't encrypt the article in group %s"
7582 gnus-newsgroup-name))
7583 (gnus-summary-iterate n
7585 (set-buffer gnus-summary-buffer)
7586 (let ((mail-parse-charset gnus-newsgroup-charset)
7587 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7588 (summary-buffer gnus-summary-buffer)
7590 (gnus-set-global-variables)
7591 (when (gnus-group-read-only-p)
7592 (error "The current newsgroup does not support article encrypt"))
7593 (gnus-summary-show-article t)
7595 (or (mail-header-references gnus-current-headers) ""))
7596 (set-buffer gnus-article-buffer)
7597 (let* ((inhibit-read-only t)
7599 (mapcar (lambda (field)
7600 (and (save-restriction
7601 (message-narrow-to-head)
7602 (goto-char (point-min))
7603 (search-forward field nil t))
7605 (message-narrow-to-field)
7607 (delete-region (point-min) (point-max))
7609 '("Content-Type:" "Content-Transfer-Encoding:"
7610 "Content-Disposition:"))))
7611 (message-narrow-to-head)
7612 (message-remove-header "MIME-Version")
7613 (goto-char (point-max))
7614 (setq point (point))
7615 (insert (apply 'concat headers))
7617 (narrow-to-region point (point-max))
7618 (let ((message-options message-options))
7619 (message-options-set 'message-sender user-mail-address)
7620 (message-options-set 'message-recipients user-mail-address)
7621 (message-options-set 'message-sign-encrypt 'not)
7623 (goto-char (point-min))
7624 (insert "MIME-Version: 1.0\n")
7626 (gnus-summary-edit-article-done
7627 references nil summary-buffer t))
7628 (when gnus-keep-backlog
7629 (gnus-backlog-remove-article
7630 (car gnus-article-current) (cdr gnus-article-current)))
7632 (when (get-buffer gnus-original-article-buffer)
7633 (set-buffer gnus-original-article-buffer)
7634 (setq gnus-original-article nil)))
7635 (when gnus-use-cache
7636 (gnus-cache-update-article
7637 (car gnus-article-current) (cdr gnus-article-current))))))))
7639 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7640 "The following specs can be used:
7641 %t The security MIME type
7644 %D Details if button is pressed")
7646 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
7647 "The following specs can be used:
7648 %t The security MIME type
7651 %D Details if button is pressed")
7653 (defvar gnus-mime-security-button-line-format-alist
7654 '((?t gnus-tmp-type ?s)
7655 (?i gnus-tmp-info ?s)
7656 (?d gnus-tmp-details ?s)
7657 (?D gnus-tmp-pressed-details ?s)))
7659 (defvar gnus-mime-security-button-map
7660 (let ((map (make-sparse-keymap)))
7661 (define-key map gnus-mouse-2 'gnus-article-push-button)
7662 (define-key map "\r" 'gnus-article-press-button)
7665 (defvar gnus-mime-security-details-buffer nil)
7667 (defvar gnus-mime-security-button-pressed nil)
7669 (defvar gnus-mime-security-show-details-inline t
7670 "If non-nil, show details in the article buffer.")
7672 (defun gnus-mime-security-verify-or-decrypt (handle)
7673 (mm-remove-parts (cdr handle))
7674 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7675 point (inhibit-read-only t))
7677 (goto-char (car region)))
7679 (narrow-to-region (point) (point))
7680 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7681 (let* ((mm-verify-option 'known)
7682 (mm-decrypt-option 'known)
7683 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7684 (unless (eq nparts (cdr handle))
7685 (mm-destroy-parts (cdr handle))
7686 (setcdr handle nparts))))
7687 (setq point (point))
7688 (gnus-mime-display-security handle)
7689 (goto-char (point-max)))
7691 (delete-region (point) (cdr region))
7692 (set-marker (car region) nil)
7693 (set-marker (cdr region) nil))
7696 (defun gnus-mime-security-show-details (handle)
7697 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7699 (gnus-message 5 "No details.")
7700 (if gnus-mime-security-show-details-inline
7701 (let ((gnus-mime-security-button-pressed
7702 (not (get-text-property (point) 'gnus-mime-details)))
7703 (gnus-mime-security-button-line-format
7704 (get-text-property (point) 'gnus-line-format))
7705 (inhibit-read-only t))
7707 (while (eq (get-text-property (point) 'gnus-line-format)
7708 gnus-mime-security-button-line-format)
7712 (narrow-to-region (point) (point))
7713 (gnus-insert-mime-security-button handle))
7714 (delete-region (point)
7715 (or (text-property-not-all
7718 gnus-mime-security-button-line-format)
7721 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7722 (with-current-buffer gnus-mime-security-details-buffer
7725 (setq gnus-mime-security-details-buffer
7726 (gnus-get-buffer-create "*MIME Security Details*")))
7727 (with-current-buffer gnus-mime-security-details-buffer
7729 (goto-char (point-min)))
7730 (pop-to-buffer gnus-mime-security-details-buffer)))))
7732 (defun gnus-mime-security-press-button (handle)
7734 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7735 (gnus-mime-security-show-details handle)
7736 (gnus-mime-security-verify-or-decrypt handle))))
7738 (defun gnus-insert-mime-security-button (handle &optional displayed)
7739 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7742 (or (nth 2 (assoc protocol mm-verify-function-alist))
7743 (nth 2 (assoc protocol mm-decrypt-function-alist))
7745 (if (equal (car handle) "multipart/signed")
7746 " Signed" " Encrypted")
7749 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7752 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7753 gnus-tmp-pressed-details
7755 (setq gnus-tmp-details
7756 (if gnus-tmp-details
7757 (concat "\n" gnus-tmp-details)
7759 (setq gnus-tmp-pressed-details
7760 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7765 gnus-mime-security-button-line-format
7766 gnus-mime-security-button-line-format-alist
7767 `(keymap ,gnus-mime-security-button-map
7768 gnus-callback gnus-mime-security-press-button
7769 gnus-line-format ,gnus-mime-security-button-line-format
7770 gnus-mime-details ,gnus-mime-security-button-pressed
7771 article-type annotation
7774 ;; Exclude a newline.
7777 (widget-convert-button
7780 :action 'gnus-widget-press-button
7781 :button-keymap gnus-mime-security-button-map
7783 (lambda (widget/window &optional overlay pos)
7784 ;; Needed to properly clear the message due to a bug in
7785 ;; wid-edit (XEmacs only).
7786 (when (boundp 'help-echo-owns-message)
7787 (setq help-echo-owns-message t))
7790 (aref gnus-mouse-2 0))))))
7792 (defun gnus-mime-display-security (handle)
7794 (narrow-to-region (point) (point))
7795 (unless (gnus-unbuttonized-mime-type-p (car handle))
7796 (gnus-insert-mime-security-button handle))
7797 (gnus-mime-display-mixed (cdr handle))
7800 (unless (gnus-unbuttonized-mime-type-p (car handle))
7801 (let ((gnus-mime-security-button-line-format
7802 gnus-mime-security-button-end-line-format))
7803 (gnus-insert-mime-security-button handle)))
7804 (mm-set-handle-multipart-parameter
7806 (cons (set-marker (make-marker) (point-min))
7807 (set-marker (make-marker) (point-max))))))
7813 (defun gnus-article-header-presentation-method (entity situation)
7814 (mime-insert-header entity)
7815 (article-decode-group-name))
7817 (set-alist 'mime-header-presentation-method-alist
7818 'gnus-original-article-mode
7819 #'gnus-article-header-presentation-method)
7821 (defun gnus-mime-preview-quitting-method ()
7822 (mime-preview-kill-buffer)
7823 (delete-other-windows)
7824 (gnus-article-show-summary)
7825 (gnus-summary-select-article gnus-show-all-headers t))
7827 (set-alist 'mime-preview-quitting-method-alist
7828 'gnus-original-article-mode #'gnus-mime-preview-quitting-method)
7830 (set-alist 'mime-preview-following-method-alist
7831 'gnus-original-article-mode #'gnus-following-method)
7833 (set-alist 'mime-preview-over-to-previous-method-alist
7834 'gnus-original-article-mode
7836 (if (> (point-min) 1)
7837 (gnus-article-prev-page)
7838 (gnus-article-read-summary-keys
7839 nil (gnus-character-to-event ?P)))))
7841 (set-alist 'mime-preview-over-to-next-method-alist
7842 'gnus-original-article-mode'
7844 (if (< (point-max) (buffer-size))
7845 (gnus-article-next-page)
7846 (gnus-article-read-summary-keys
7847 nil (gnus-character-to-event ?N)))))
7857 (run-hooks 'gnus-art-load-hook)
7859 ;;; gnus-art.el ends here