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)
521 (autoload 'mail-extract-address-components "mail-extr"))
523 (defcustom gnus-save-all-headers t
524 "*If non-nil, don't remove any headers before saving."
525 :group 'gnus-article-saving
528 (defcustom gnus-prompt-before-saving 'always
529 "*This variable says how much prompting is to be done when saving articles.
530 If it is nil, no prompting will be done, and the articles will be
531 saved to the default files. If this variable is `always', each and
532 every article that is saved will be preceded by a prompt, even when
533 saving large batches of articles. If this variable is neither nil not
534 `always', there the user will be prompted once for a file name for
535 each invocation of the saving commands."
536 :group 'gnus-article-saving
537 :type '(choice (item always)
538 (item :tag "never" nil)
539 (sexp :tag "once" :format "%t\n" :value t)))
541 (defcustom gnus-saved-headers gnus-visible-headers
542 "Headers to keep if `gnus-save-all-headers' is nil.
543 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
544 If that variable is nil, however, all headers that match this regexp
545 will be kept while the rest will be deleted before saving."
546 :group 'gnus-article-saving
549 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
550 "A function to save articles in your favourite format.
551 The function must be interactively callable (in other words, it must
552 be an Emacs command).
554 Gnus provides the following functions:
556 * gnus-summary-save-in-rmail (Rmail format)
557 * gnus-summary-save-in-mail (Unix mail format)
558 * gnus-summary-save-in-folder (MH folder)
559 * gnus-summary-save-in-file (article format)
560 * gnus-summary-save-body-in-file (article body)
561 * gnus-summary-save-in-vm (use VM's folder format)
562 * gnus-summary-write-to-file (article format -- overwrite)."
563 :group 'gnus-article-saving
564 :type '(radio (function-item gnus-summary-save-in-rmail)
565 (function-item gnus-summary-save-in-mail)
566 (function-item gnus-summary-save-in-folder)
567 (function-item gnus-summary-save-in-file)
568 (function-item gnus-summary-save-body-in-file)
569 (function-item gnus-summary-save-in-vm)
570 (function-item gnus-summary-write-to-file)))
572 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
573 "A function generating a file name to save articles in Rmail format.
574 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
575 :group 'gnus-article-saving
578 (defcustom gnus-mail-save-name 'gnus-plain-save-name
579 "A function generating a file name to save articles in Unix mail format.
580 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
581 :group 'gnus-article-saving
584 (defcustom gnus-folder-save-name 'gnus-folder-save-name
585 "A function generating a file name to save articles in MH folder.
586 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
587 :group 'gnus-article-saving
590 (defcustom gnus-file-save-name 'gnus-numeric-save-name
591 "A function generating a file name to save articles in article format.
592 The function is called with NEWSGROUP, HEADERS, and optional
594 :group 'gnus-article-saving
597 (defcustom gnus-split-methods
598 '((gnus-article-archive-name)
599 (gnus-article-nndoc-name))
600 "*Variable used to suggest where articles are to be saved.
601 For instance, if you would like to save articles related to Gnus in
602 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
603 you could set this variable to something like:
605 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
606 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
608 This variable is an alist where the key is the match and the
609 value is a list of possible files to save in if the match is
612 If the match is a string, it is used as a regexp match on the
613 article. If the match is a symbol, that symbol will be funcalled
614 from the buffer of the article to be saved with the newsgroup as
615 the parameter. If it is a list, it will be evaled in the same
618 If this form or function returns a string, this string will be
619 used as a possible file name; and if it returns a non-nil list,
620 that list will be used as possible file names."
621 :group 'gnus-article-saving
622 :type '(repeat (choice (list :value (fun) function)
623 (cons :value ("" "") regexp (repeat string))
626 (defcustom gnus-article-display-method-for-mime
627 'gnus-article-display-mime-message
628 "Function to display a MIME message.
629 The function is called from the article buffer."
630 :group 'gnus-article-mime
633 (defcustom gnus-article-display-method-for-traditional
634 'gnus-article-display-traditional-message
635 "*Function to display a traditional message.
636 The function is called from the article buffer."
637 :group 'gnus-article-mime
640 (defcustom gnus-page-delimiter "^\^L"
641 "*Regexp describing what to use as article page delimiters.
642 The default value is \"^\^L\", which is a form linefeed at the
643 beginning of a line."
645 :group 'gnus-article-various)
647 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
648 "*The format specification for the article mode line.
649 See `gnus-summary-mode-line-format' for a closer description.
651 The following additional specs are available:
653 %w The article washing status.
654 %m The number of MIME parts in the article."
656 :group 'gnus-article-various)
658 (defcustom gnus-article-mode-hook nil
659 "*A hook for Gnus article mode."
661 :group 'gnus-article-various)
663 (when (featurep 'xemacs)
664 ;; Extracted from gnus-xmas-define in order to preserve user settings
665 (when (fboundp 'turn-off-scroll-in-place)
666 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
667 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
668 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
670 (defcustom gnus-article-menu-hook nil
671 "*Hook run after the creation of the article mode menu."
673 :group 'gnus-article-various)
675 (defcustom gnus-article-prepare-hook nil
676 "*A hook called after an article has been prepared in the article buffer."
678 :group 'gnus-article-various)
680 (defcustom gnus-copy-article-ignored-headers nil
681 "List of headers to be removed when copying an article.
682 Each element is a regular expression."
683 :version "23.0" ;; No Gnus
684 :type '(repeat regexp)
685 :group 'gnus-article-various)
687 (make-obsolete-variable 'gnus-article-hide-pgp-hook
688 "This variable is obsolete in Gnus 5.10.")
690 (defcustom gnus-article-button-face 'bold
691 "Face used for highlighting buttons in the article buffer.
693 An article button is a piece of text that you can activate by pressing
694 `RET' or `mouse-2' above it."
696 :group 'gnus-article-buttons)
698 (defcustom gnus-article-mouse-face 'highlight
699 "Face used for mouse highlighting in the article buffer.
701 Article buttons will be displayed in this face when the cursor is
704 :group 'gnus-article-buttons)
706 (defcustom gnus-signature-face 'gnus-signature-face
707 "Face used for highlighting a signature in the article buffer.
708 Obsolete; use the face `gnus-signature-face' for customizations instead."
710 :group 'gnus-article-highlight
711 :group 'gnus-article-signature)
713 (defface gnus-signature-face
716 "Face used for highlighting a signature in the article buffer."
717 :group 'gnus-article-highlight
718 :group 'gnus-article-signature)
720 (defface gnus-header-from-face
723 (:foreground "spring green"))
726 (:foreground "red3"))
729 "Face used for displaying from headers."
730 :group 'gnus-article-headers
731 :group 'gnus-article-highlight)
733 (defface gnus-header-subject-face
736 (:foreground "SeaGreen3"))
739 (:foreground "red4"))
741 (:bold t :italic t)))
742 "Face used for displaying subject headers."
743 :group 'gnus-article-headers
744 :group 'gnus-article-highlight)
746 (defface gnus-header-newsgroups-face
749 (:foreground "yellow" :italic t))
752 (:foreground "MidnightBlue" :italic t))
755 "Face used for displaying newsgroups headers.
756 In the default setup this face is only used for crossposted
758 :group 'gnus-article-headers
759 :group 'gnus-article-highlight)
761 (defface gnus-header-name-face
764 (:foreground "SeaGreen"))
767 (:foreground "maroon"))
770 "Face used for displaying header names."
771 :group 'gnus-article-headers
772 :group 'gnus-article-highlight)
774 (defface gnus-header-content-face
777 (:foreground "forest green" :italic t))
780 (:foreground "indianred4" :italic t))
783 "Face used for displaying header content."
784 :group 'gnus-article-headers
785 :group 'gnus-article-highlight)
787 (defcustom gnus-header-face-alist
788 '(("From" nil gnus-header-from-face)
789 ("Subject" nil gnus-header-subject-face)
790 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
791 ("" gnus-header-name-face gnus-header-content-face))
792 "*Controls highlighting of article headers.
794 An alist of the form (HEADER NAME CONTENT).
796 HEADER is a regular expression which should match the name of a
797 header and NAME and CONTENT are either face names or nil.
799 The name of each header field will be displayed using the face
800 specified by the first element in the list where HEADER matches
801 the header name and NAME is non-nil. Similarly, the content will
802 be displayed by the first non-nil matching CONTENT face."
803 :group 'gnus-article-headers
804 :group 'gnus-article-highlight
805 :type '(repeat (list (regexp :tag "Header")
807 (item :tag "skip" nil)
808 (face :value default))
809 (choice :tag "Content"
810 (item :tag "skip" nil)
811 (face :value default)))))
813 (defcustom gnus-article-decode-hook
814 '(article-decode-group-name article-decode-idna-rhs)
815 "*Hook run to decode charsets in articles."
816 :group 'gnus-article-headers
819 (defcustom gnus-display-mime-function 'gnus-display-mime
820 "Function to display MIME articles."
821 :group 'gnus-article-mime
824 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
825 "Function used to decode headers.")
827 (defvar gnus-article-dumbquotes-map
847 "Table for MS-to-Latin1 translation.")
849 (defcustom gnus-ignored-mime-types nil
850 "List of MIME types that should be ignored by Gnus."
852 :group 'gnus-article-mime
853 :type '(repeat regexp))
855 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
856 "List of MIME types that should not be given buttons when rendered inline.
857 See also `gnus-buttonized-mime-types' which may override this variable.
858 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
860 :group 'gnus-article-mime
861 :type '(repeat regexp))
863 (defcustom gnus-buttonized-mime-types nil
864 "List of MIME types that should be given buttons when rendered inline.
865 If set, this variable overrides `gnus-unbuttonized-mime-types'.
866 To see e.g. security buttons you could set this to
867 `(\"multipart/signed\")'.
868 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
870 :group 'gnus-article-mime
871 :type '(repeat regexp))
873 (defcustom gnus-inhibit-mime-unbuttonizing nil
874 "If non-nil, all MIME parts get buttons.
875 When nil (the default value), then some MIME parts do not get buttons,
876 as described by the variables `gnus-buttonized-mime-types' and
877 `gnus-unbuttonized-mime-types'."
879 :group 'gnus-article-mime
882 (defcustom gnus-body-boundary-delimiter "_"
883 "String used to delimit header and body.
884 This variable is used by `gnus-article-treat-body-boundary' which can
885 be controlled by `gnus-treat-body-boundary'."
887 :group 'gnus-article-various
888 :type '(choice (item :tag "None" :value nil)
891 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces"
893 "Defines the location of the faces database.
894 For information on obtaining this database of pretty pictures, please
895 see http://www.cs.indiana.edu/picons/ftp/index.html"
897 :type '(repeat directory)
898 :link '(url-link :tag "download"
899 "http://www.cs.indiana.edu/picons/ftp/index.html")
900 :link '(custom-manual "(gnus)Picons")
903 (defun gnus-picons-installed-p ()
904 "Say whether picons are installed on your machine."
905 (let ((installed nil))
906 (dolist (database gnus-picon-databases)
907 (when (file-exists-p database)
911 (defcustom gnus-article-mime-part-function nil
912 "Function called with a MIME handle as the argument.
913 This is meant for people who want to do something automatic based
914 on parts -- for instance, adding Vcard info to a database."
915 :group 'gnus-article-mime
918 (defcustom gnus-mime-multipart-functions nil
919 "An alist of MIME types to functions to display them."
921 :group 'gnus-article-mime
922 :type '(repeat (cons :format "%v" (string :tag "MIME type") function)))
924 (defcustom gnus-article-date-lapsed-new-header nil
925 "Whether the X-Sent and Date headers can coexist.
926 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
927 either replace the old \"Date:\" header (if this variable is nil), or
928 be added below it (otherwise)."
930 :group 'gnus-article-headers
933 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
934 "Function called with a MIME handle as the argument.
935 This is meant for people who want to view first matched part.
936 For `undisplayed-alternative' (default), the first undisplayed
937 part or alternative part is used. For `undisplayed', the first
938 undisplayed part is used. For a function, the first part which
939 the function return t is used. For nil, the first part is
942 :group 'gnus-article-mime
944 (item :tag "first" :value nil)
945 (item :tag "undisplayed" :value undisplayed)
946 (item :tag "undisplayed or alternative"
947 :value undisplayed-alternative)
950 (defcustom gnus-mime-action-alist
951 '(("save to file" . gnus-mime-save-part)
952 ("save and strip" . gnus-mime-save-part-and-strip)
953 ("delete part" . gnus-mime-delete-part)
954 ("display as text" . gnus-mime-inline-part)
955 ("view the part" . gnus-mime-view-part)
956 ("pipe to command" . gnus-mime-pipe-part)
957 ("toggle display" . gnus-article-press-button)
958 ("toggle display" . gnus-article-view-part-as-charset)
959 ("view as type" . gnus-mime-view-part-as-type)
960 ("view internally" . gnus-mime-view-part-internally)
961 ("view externally" . gnus-mime-view-part-externally))
962 "An alist of actions that run on the MIME attachment."
963 :group 'gnus-article-mime
964 :type '(repeat (cons (string :tag "name")
968 ;;; The treatment variables
971 (defvar gnus-part-display-hook nil
972 "Hook called on parts that are to receive treatment.")
974 (defvar gnus-article-treat-custom
975 '(choice (const :tag "Off" nil)
977 (const :tag "Header" head)
978 (const :tag "Last" last)
979 (const :tag "Mime" mime)
980 (integer :tag "Less")
981 (repeat :tag "Groups" regexp)
982 (sexp :tag "Predicate")))
984 (defvar gnus-article-treat-head-custom
985 '(choice (const :tag "Off" nil)
986 (const :tag "Header" head)))
988 (defvar gnus-article-treat-types '("text/plain")
991 (defvar gnus-inhibit-treatment nil
992 "Whether to inhibit treatment.")
994 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
995 "Highlight the signature.
996 Valid values are nil, t, `head', `last', an integer or a predicate.
997 See Info node `(gnus)Customizing Articles'."
998 :group 'gnus-article-treat
999 :link '(custom-manual "(gnus)Customizing Articles")
1000 :type gnus-article-treat-custom)
1001 (put 'gnus-treat-highlight-signature 'highlight t)
1003 (defcustom gnus-treat-buttonize 100000
1005 Valid values are nil, t, `head', `last', an integer or a predicate.
1006 See Info node `(gnus)Customizing Articles'."
1007 :group 'gnus-article-treat
1008 :link '(custom-manual "(gnus)Customizing Articles")
1009 :type gnus-article-treat-custom)
1010 (put 'gnus-treat-buttonize 'highlight t)
1012 (defcustom gnus-treat-buttonize-head 'head
1013 "Add buttons to the head.
1014 Valid values are nil, t, `head', `last', an integer or a predicate.
1015 See Info node `(gnus)Customizing Articles' for details."
1016 :group 'gnus-article-treat
1017 :link '(custom-manual "(gnus)Customizing Articles")
1018 :type gnus-article-treat-head-custom)
1019 (put 'gnus-treat-buttonize-head 'highlight t)
1021 (defcustom gnus-treat-emphasize
1022 (and (or window-system
1026 Valid values are nil, t, `head', `last', an integer or a predicate.
1027 See Info node `(gnus)Customizing Articles' for details."
1028 :group 'gnus-article-treat
1029 :link '(custom-manual "(gnus)Customizing Articles")
1030 :type gnus-article-treat-custom)
1031 (put 'gnus-treat-emphasize 'highlight t)
1033 (defcustom gnus-treat-strip-cr nil
1034 "Remove carriage returns.
1035 Valid values are nil, t, `head', `last', an integer or a predicate.
1036 See Info node `(gnus)Customizing Articles' for details."
1038 :group 'gnus-article-treat
1039 :link '(custom-manual "(gnus)Customizing Articles")
1040 :type gnus-article-treat-custom)
1042 (defcustom gnus-treat-unsplit-urls nil
1043 "Remove newlines from within URLs.
1044 Valid values are nil, t, `head', `last', an integer or a predicate.
1045 See Info node `(gnus)Customizing Articles' for details."
1047 :group 'gnus-article-treat
1048 :link '(custom-manual "(gnus)Customizing Articles")
1049 :type gnus-article-treat-custom)
1051 (defcustom gnus-treat-leading-whitespace nil
1052 "Remove leading whitespace in headers.
1053 Valid values are nil, t, `head', `last', an integer or a predicate.
1054 See Info node `(gnus)Customizing Articles' for details."
1056 :group 'gnus-article-treat
1057 :link '(custom-manual "(gnus)Customizing Articles")
1058 :type gnus-article-treat-custom)
1060 (defcustom gnus-treat-hide-headers 'head
1062 Valid values are nil, t, `head', `last', an integer or a predicate.
1063 See Info node `(gnus)Customizing Articles' for details."
1064 :group 'gnus-article-treat
1065 :link '(custom-manual "(gnus)Customizing Articles")
1066 :type gnus-article-treat-head-custom)
1068 (defcustom gnus-treat-hide-boring-headers nil
1069 "Hide boring headers.
1070 Valid values are nil, t, `head', `last', an integer or a predicate.
1071 See Info node `(gnus)Customizing Articles' for details."
1072 :group 'gnus-article-treat
1073 :link '(custom-manual "(gnus)Customizing Articles")
1074 :type gnus-article-treat-head-custom)
1076 (defcustom gnus-treat-hide-signature nil
1077 "Hide the signature.
1078 Valid values are nil, t, `head', `last', an integer or a predicate.
1079 See Info node `(gnus)Customizing Articles' for details."
1080 :group 'gnus-article-treat
1081 :link '(custom-manual "(gnus)Customizing Articles")
1082 :type gnus-article-treat-custom)
1084 (defcustom gnus-treat-fill-article nil
1086 Valid values are nil, t, `head', `last', an integer or a predicate.
1087 See Info node `(gnus)Customizing Articles' for details."
1088 :group 'gnus-article-treat
1089 :link '(custom-manual "(gnus)Customizing Articles")
1090 :type gnus-article-treat-custom)
1092 (defcustom gnus-treat-hide-citation nil
1094 Valid values are nil, t, `head', `last', an integer or a predicate.
1095 See Info node `(gnus)Customizing Articles' for details."
1096 :group 'gnus-article-treat
1097 :link '(custom-manual "(gnus)Customizing Articles")
1098 :type gnus-article-treat-custom)
1100 (defcustom gnus-treat-hide-citation-maybe nil
1102 Valid values are nil, t, `head', `last', an integer or a predicate.
1103 See Info node `(gnus)Customizing Articles' for details."
1104 :group 'gnus-article-treat
1105 :link '(custom-manual "(gnus)Customizing Articles")
1106 :type gnus-article-treat-custom)
1108 (defcustom gnus-treat-strip-list-identifiers 'head
1109 "Strip list identifiers from `gnus-list-identifiers`.
1110 Valid values are nil, t, `head', `last', an integer or a predicate.
1111 See Info node `(gnus)Customizing Articles' for details."
1113 :group 'gnus-article-treat
1114 :link '(custom-manual "(gnus)Customizing Articles")
1115 :type gnus-article-treat-custom)
1117 (make-obsolete-variable 'gnus-treat-strip-pgp
1118 "This option is obsolete in Gnus 5.10.")
1120 (defcustom gnus-treat-strip-pem nil
1121 "Strip PEM signatures.
1122 Valid values are nil, t, `head', `last', an integer or a predicate.
1123 See Info node `(gnus)Customizing Articles' for details."
1124 :group 'gnus-article-treat
1125 :link '(custom-manual "(gnus)Customizing Articles")
1126 :type gnus-article-treat-custom)
1128 (defcustom gnus-treat-strip-banner t
1129 "Strip banners from articles.
1130 The banner to be stripped is specified in the `banner' group parameter.
1131 Valid values are nil, t, `head', `last', an integer or a predicate.
1132 See Info node `(gnus)Customizing Articles' for details."
1133 :group 'gnus-article-treat
1134 :link '(custom-manual "(gnus)Customizing Articles")
1135 :type gnus-article-treat-custom)
1137 (defcustom gnus-treat-highlight-headers 'head
1138 "Highlight the headers.
1139 Valid values are nil, t, `head', `last', an integer or a predicate.
1140 See Info node `(gnus)Customizing Articles' for details."
1141 :group 'gnus-article-treat
1142 :link '(custom-manual "(gnus)Customizing Articles")
1143 :type gnus-article-treat-head-custom)
1144 (put 'gnus-treat-highlight-headers 'highlight t)
1146 (defcustom gnus-treat-highlight-citation t
1147 "Highlight cited text.
1148 Valid values are nil, t, `head', `last', an integer or a predicate.
1149 See Info node `(gnus)Customizing Articles' for details."
1150 :group 'gnus-article-treat
1151 :link '(custom-manual "(gnus)Customizing Articles")
1152 :type gnus-article-treat-custom)
1153 (put 'gnus-treat-highlight-citation 'highlight t)
1155 (defcustom gnus-treat-date-ut nil
1156 "Display the Date in UT (GMT).
1157 Valid values are nil, t, `head', `last', an integer or a predicate.
1158 See Info node `(gnus)Customizing Articles' for details."
1159 :group 'gnus-article-treat
1160 :link '(custom-manual "(gnus)Customizing Articles")
1161 :type gnus-article-treat-head-custom)
1163 (defcustom gnus-treat-date-local nil
1164 "Display the Date in the local timezone.
1165 Valid values are nil, t, `head', `last', an integer or a predicate.
1166 See Info node `(gnus)Customizing Articles' for details."
1167 :group 'gnus-article-treat
1168 :link '(custom-manual "(gnus)Customizing Articles")
1169 :type gnus-article-treat-head-custom)
1171 (defcustom gnus-treat-date-english nil
1172 "Display the Date in a format that can be read aloud in English.
1173 Valid values are nil, t, `head', `last', an integer or a predicate.
1174 See Info node `(gnus)Customizing Articles' for details."
1176 :group 'gnus-article-treat
1177 :link '(custom-manual "(gnus)Customizing Articles")
1178 :type gnus-article-treat-head-custom)
1180 (defcustom gnus-treat-date-lapsed nil
1181 "Display the Date header in a way that says how much time has elapsed.
1182 Valid values are nil, t, `head', `last', an integer or a predicate.
1183 See Info node `(gnus)Customizing Articles' for details."
1184 :group 'gnus-article-treat
1185 :link '(custom-manual "(gnus)Customizing Articles")
1186 :type gnus-article-treat-head-custom)
1188 (defcustom gnus-treat-date-original nil
1189 "Display the date in the original timezone.
1190 Valid values are nil, t, `head', `last', an integer or a predicate.
1191 See Info node `(gnus)Customizing Articles' for details."
1192 :group 'gnus-article-treat
1193 :link '(custom-manual "(gnus)Customizing Articles")
1194 :type gnus-article-treat-head-custom)
1196 (defcustom gnus-treat-date-iso8601 nil
1197 "Display the date in the ISO8601 format.
1198 Valid values are nil, t, `head', `last', an integer or a predicate.
1199 See Info node `(gnus)Customizing Articles' for details."
1201 :group 'gnus-article-treat
1202 :link '(custom-manual "(gnus)Customizing Articles")
1203 :type gnus-article-treat-head-custom)
1205 (defcustom gnus-treat-date-user-defined nil
1206 "Display the date in a user-defined format.
1207 The format is defined by the `gnus-article-time-format' variable.
1208 Valid values are nil, t, `head', `last', an integer or a predicate.
1209 See Info node `(gnus)Customizing Articles' for details."
1210 :group 'gnus-article-treat
1211 :link '(custom-manual "(gnus)Customizing Articles")
1212 :type gnus-article-treat-head-custom)
1214 (defcustom gnus-treat-strip-headers-in-body t
1215 "Strip the X-No-Archive header line from the beginning of the body.
1216 Valid values are nil, t, `head', `last', an integer or a predicate.
1217 See Info node `(gnus)Customizing Articles' for details."
1219 :group 'gnus-article-treat
1220 :link '(custom-manual "(gnus)Customizing Articles")
1221 :type gnus-article-treat-custom)
1223 (defcustom gnus-treat-strip-trailing-blank-lines nil
1224 "Strip trailing blank lines.
1225 Valid values are nil, t, `head', `last', an integer or a predicate.
1226 See Info node `(gnus)Customizing Articles' for details."
1227 :group 'gnus-article-treat
1228 :link '(custom-manual "(gnus)Customizing Articles")
1229 :type gnus-article-treat-custom)
1231 (defcustom gnus-treat-strip-leading-blank-lines nil
1232 "Strip leading blank lines.
1233 Valid values are nil, t, `head', `last', an integer or a predicate.
1234 See Info node `(gnus)Customizing Articles' for details."
1235 :group 'gnus-article-treat
1236 :link '(custom-manual "(gnus)Customizing Articles")
1237 :type gnus-article-treat-custom)
1239 (defcustom gnus-treat-strip-multiple-blank-lines nil
1240 "Strip multiple blank lines.
1241 Valid values are nil, t, `head', `last', an integer or a predicate.
1242 See Info node `(gnus)Customizing Articles' for details."
1243 :group 'gnus-article-treat
1244 :link '(custom-manual "(gnus)Customizing Articles")
1245 :type gnus-article-treat-custom)
1247 (defcustom gnus-treat-unfold-headers 'head
1248 "Unfold folded header lines.
1249 Valid values are nil, t, `head', `last', an integer or a predicate.
1250 See Info node `(gnus)Customizing Articles' for details."
1252 :group 'gnus-article-treat
1253 :link '(custom-manual "(gnus)Customizing Articles")
1254 :type gnus-article-treat-custom)
1256 (defcustom gnus-treat-fold-headers nil
1258 Valid values are nil, t, `head', `last', an integer or a predicate.
1259 See Info node `(gnus)Customizing Articles' for details."
1261 :group 'gnus-article-treat
1262 :link '(custom-manual "(gnus)Customizing Articles")
1263 :type gnus-article-treat-custom)
1265 (defcustom gnus-treat-fold-newsgroups 'head
1266 "Fold the Newsgroups and Followup-To headers.
1267 Valid values are nil, t, `head', `last', an integer or a predicate.
1268 See Info node `(gnus)Customizing Articles' for details."
1270 :group 'gnus-article-treat
1271 :link '(custom-manual "(gnus)Customizing Articles")
1272 :type gnus-article-treat-custom)
1274 (defcustom gnus-treat-overstrike t
1275 "Treat overstrike highlighting.
1276 Valid values are nil, t, `head', `last', an integer or a predicate.
1277 See Info node `(gnus)Customizing Articles' for details."
1278 :group 'gnus-article-treat
1279 :link '(custom-manual "(gnus)Customizing Articles")
1280 :type gnus-article-treat-custom)
1281 (put 'gnus-treat-overstrike 'highlight t)
1283 (defcustom gnus-treat-ansi-sequences (if (locate-library "ansi-color") t)
1284 "Treat ANSI SGR control sequences.
1285 Valid values are nil, t, `head', `last', an integer or a predicate.
1286 See Info node `(gnus)Customizing Articles' for details."
1287 :group 'gnus-article-treat
1288 :link '(custom-manual "(gnus)Customizing Articles")
1289 :type gnus-article-treat-custom)
1291 (make-obsolete-variable 'gnus-treat-display-xface
1292 'gnus-treat-display-x-face)
1294 (defcustom gnus-treat-display-x-face
1295 (and (not noninteractive)
1296 (or (eq gnus-article-x-face-command
1297 'x-face-mule-gnus-article-display-x-face)
1298 (and (fboundp 'image-type-available-p)
1299 (image-type-available-p 'xbm)
1300 (string-match "^0x" (shell-command-to-string "uncompface"))
1301 (executable-find "icontopbm"))
1302 (and (featurep 'xemacs)
1305 "Display X-Face headers.
1306 Valid values are nil, t, `head', `last', an integer or a predicate.
1307 See Info node `(gnus)Customizing Articles' and Info node
1308 `(gnus)X-Face' for details."
1309 :group 'gnus-article-treat
1311 :link '(custom-manual "(gnus)Customizing Articles")
1312 :link '(custom-manual "(gnus)X-Face")
1313 :type gnus-article-treat-head-custom
1314 :set (lambda (symbol value)
1317 (cond ((or (boundp symbol) (get symbol 'saved-value))
1319 ((boundp 'gnus-treat-display-xface)
1321 ** gnus-treat-display-xface is an obsolete variable;\
1322 use gnus-treat-display-x-face instead")
1323 (default-value 'gnus-treat-display-xface))
1324 ((get 'gnus-treat-display-xface 'saved-value)
1326 ** gnus-treat-display-xface is an obsolete variable;\
1327 use gnus-treat-display-x-face instead")
1328 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1331 (put 'gnus-treat-display-x-face 'highlight t)
1333 (defcustom gnus-article-should-use-smiley-mule
1334 (not (or (featurep 'xemacs)
1335 (gnus-image-type-available-p 'xpm)
1336 (gnus-image-type-available-p 'pbm)))
1337 "Non-nil means use `smiley-mule' to show smileys rather than `smiley'.
1338 `smiley-mule' is boundled in BITMAP-MULE package. You can set it to t
1339 even if your Emacs supports images. It has no effect on XEmacs."
1340 :group 'gnus-article-various
1342 :get (lambda (symbol)
1343 (and (not noninteractive)
1344 (default-value symbol)
1345 (not (featurep 'xemacs))
1346 (module-installed-p 'smiley-mule)
1348 :set (lambda (symbol value)
1349 (set-default symbol (and (not noninteractive)
1351 (not (featurep 'xemacs))
1352 (module-installed-p 'smiley-mule)
1355 (defvar gnus-article-smiley-mule-loaded-p nil
1356 "Internal variable used to say whether `smiley-mule' is loaded (whether
1357 smiley functions are not overridden by `smiley').")
1359 (defcustom gnus-treat-display-face
1360 (and (not noninteractive)
1361 (or (and (fboundp 'image-type-available-p)
1362 (image-type-available-p 'png))
1363 (and (featurep 'xemacs)
1366 "Display Face headers.
1367 Valid values are nil, t, `head', `last', an integer or a predicate.
1368 See Info node `(gnus)Customizing Articles' and Info node
1369 `(gnus)X-Face' for details."
1370 :group 'gnus-article-treat
1372 :link '(custom-manual "(gnus)Customizing Articles")
1373 :link '(custom-manual "(gnus)X-Face")
1374 :type gnus-article-treat-head-custom)
1375 (put 'gnus-treat-display-face 'highlight t)
1377 (defcustom gnus-treat-display-smileys
1378 (if (and (not noninteractive)
1379 (or (and (featurep 'xemacs)
1381 (gnus-image-type-available-p 'xpm)
1382 (gnus-image-type-available-p 'pbm)
1383 (and (not (featurep 'xemacs))
1385 (module-installed-p 'smiley-mule))))
1389 Valid values are nil, t, `head', `last', an integer or a predicate.
1390 See Info node `(gnus)Customizing Articles' and Info node
1391 `(gnus)Smileys' for details."
1392 :group 'gnus-article-treat
1394 :link '(custom-manual "(gnus)Customizing Articles")
1395 :link '(custom-manual "(gnus)Smileys")
1396 :type gnus-article-treat-custom)
1397 (put 'gnus-treat-display-smileys 'highlight t)
1399 (defcustom gnus-treat-from-picon
1400 (if (and (gnus-image-type-available-p 'xpm)
1401 (gnus-picons-installed-p))
1403 "Display picons in the From header.
1404 Valid values are nil, t, `head', `last', an integer or a predicate.
1405 See Info node `(gnus)Customizing Articles' and Info node
1406 `(gnus)Picons' for details."
1408 :group 'gnus-article-treat
1410 :link '(custom-manual "(gnus)Customizing Articles")
1411 :link '(custom-manual "(gnus)Picons")
1412 :type gnus-article-treat-head-custom)
1413 (put 'gnus-treat-from-picon 'highlight t)
1415 (defcustom gnus-treat-mail-picon
1416 (if (and (gnus-image-type-available-p 'xpm)
1417 (gnus-picons-installed-p))
1419 "Display picons in To and Cc headers.
1420 Valid values are nil, t, `head', `last', an integer or a predicate.
1421 See Info node `(gnus)Customizing Articles' and Info node
1422 `(gnus)Picons' for details."
1424 :group 'gnus-article-treat
1426 :link '(custom-manual "(gnus)Customizing Articles")
1427 :link '(custom-manual "(gnus)Picons")
1428 :type gnus-article-treat-head-custom)
1429 (put 'gnus-treat-mail-picon 'highlight t)
1431 (defcustom gnus-treat-newsgroups-picon
1432 (if (and (gnus-image-type-available-p 'xpm)
1433 (gnus-picons-installed-p))
1435 "Display picons in the Newsgroups and Followup-To headers.
1436 Valid values are nil, t, `head', `last', an integer or a predicate.
1437 See Info node `(gnus)Customizing Articles' and Info node
1438 `(gnus)Picons' for details."
1440 :group 'gnus-article-treat
1442 :link '(custom-manual "(gnus)Customizing Articles")
1443 :link '(custom-manual "(gnus)Picons")
1444 :type gnus-article-treat-head-custom)
1445 (put 'gnus-treat-newsgroups-picon 'highlight t)
1447 (defcustom gnus-treat-body-boundary
1448 (if (and (eq window-system 'x)
1449 (or gnus-treat-newsgroups-picon
1450 gnus-treat-mail-picon
1451 gnus-treat-from-picon))
1453 "Draw a boundary at the end of the headers.
1454 Valid values are nil and `head'.
1455 See Info node `(gnus)Customizing Articles' for details."
1457 :group 'gnus-article-treat
1458 :link '(custom-manual "(gnus)Customizing Articles")
1459 :type gnus-article-treat-head-custom)
1461 (defcustom gnus-treat-capitalize-sentences nil
1462 "Capitalize sentence-starting words.
1463 Valid values are nil, t, `head', `last', an integer or a predicate.
1464 See Info node `(gnus)Customizing Articles' for details."
1466 :group 'gnus-article-treat
1467 :link '(custom-manual "(gnus)Customizing Articles")
1468 :type gnus-article-treat-custom)
1470 (defcustom gnus-treat-wash-html nil
1472 Valid values are nil, t, `head', `last', an integer or a predicate.
1473 See Info node `(gnus)Customizing Articles' for details."
1475 :group 'gnus-article-treat
1476 :link '(custom-manual "(gnus)Customizing Articles")
1477 :type gnus-article-treat-custom)
1479 (defcustom gnus-treat-fill-long-lines nil
1481 Valid values are nil, t, `head', `last', an integer or a predicate.
1482 See Info node `(gnus)Customizing Articles' for details."
1483 :group 'gnus-article-treat
1484 :link '(custom-manual "(gnus)Customizing Articles")
1485 :type gnus-article-treat-custom)
1487 (defcustom gnus-treat-play-sounds nil
1489 Valid values are nil, t, `head', `last', an integer or a predicate.
1490 See Info node `(gnus)Customizing Articles' for details."
1492 :group 'gnus-article-treat
1493 :link '(custom-manual "(gnus)Customizing Articles")
1494 :type gnus-article-treat-custom)
1496 (defcustom gnus-treat-decode-article-as-default-mime-charset nil
1497 "Decode an article as `default-mime-charset'. For instance, if you want to
1498 attempt to decode an article even if the value of `gnus-show-mime' is nil,
1499 you could set this variable to something like: nil for don't decode, t for
1500 decode the body, '(or header t) for the whole article, etc."
1501 :group 'gnus-article-treat
1502 :type '(radio (const :tag "Off" nil)
1503 (const :tag "Decode body" t)
1504 (const :tag "Decode all" (or head t))))
1506 (defcustom gnus-treat-translate nil
1507 "Translate articles from one language to another.
1508 Valid values are nil, t, `head', `last', an integer or a predicate.
1509 See Info node `(gnus)Customizing Articles' for details."
1511 :group 'gnus-article-treat
1512 :link '(custom-manual "(gnus)Customizing Articles")
1513 :type gnus-article-treat-custom)
1515 (defcustom gnus-treat-x-pgp-sig nil
1517 To automatically treat X-PGP-Sig, set it to head.
1518 Valid values are nil, t, `head', `last', an integer or a predicate.
1519 See Info node `(gnus)Customizing Articles' for details."
1521 :group 'gnus-article-treat
1522 :group 'mime-security
1523 :type gnus-article-treat-custom)
1525 (defcustom gnus-treat-monafy nil
1526 "Display body part with mona font.
1527 Valid values are nil, t, `head', `last', an integer or a predicate.
1528 See Info node `(gnus)Customizing Articles' for details."
1529 :group 'gnus-article-treat
1530 :group 'mime-security
1531 :link '(custom-manual "(gnus)Customizing Articles")
1532 :type gnus-article-treat-custom)
1534 (defvar gnus-article-encrypt-protocol-alist
1535 '(("PGP" . mml2015-self-encrypt)))
1537 ;; Set to nil if more than one protocol added to
1538 ;; gnus-article-encrypt-protocol-alist.
1539 (defcustom gnus-article-encrypt-protocol "PGP"
1540 "The protocol used for encrypt articles.
1541 It is a string, such as \"PGP\". If nil, ask user."
1544 :group 'mime-security)
1546 (defvar gnus-article-wash-function nil
1547 "Function used for converting HTML into text.")
1549 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1550 (mm-coding-system-p 'utf-8)
1551 (executable-find idna-program))
1552 "Whether IDNA decoding of headers is used when viewing messages.
1553 This requires GNU Libidn, and by default only enabled if it is found."
1555 :group 'gnus-article-headers
1558 (defcustom gnus-article-over-scroll nil
1559 "If non-nil, allow scrolling the article buffer even when there no more text."
1561 :group 'gnus-article
1564 ;;; Internal variables
1566 (defvar gnus-english-month-names
1567 '("January" "February" "March" "April" "May" "June" "July" "August"
1568 "September" "October" "November" "December"))
1570 (defvar gnus-button-regexp nil)
1571 (defvar gnus-button-marker-list nil)
1572 ;; Regexp matching any of the regexps from `gnus-button-alist'.
1574 (defvar gnus-button-last nil)
1575 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
1577 (defvar article-goto-body-goes-to-point-min-p nil)
1578 (defvar gnus-article-wash-types nil)
1579 (defvar gnus-article-emphasis-alist nil)
1580 (defvar gnus-article-image-alist nil)
1582 (defvar gnus-article-mime-handle-alist-1 nil)
1583 (defvar gnus-treatment-function-alist
1584 '((gnus-treat-decode-article-as-default-mime-charset
1585 gnus-article-decode-article-as-default-mime-charset)
1586 (gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1587 (gnus-treat-monafy gnus-article-monafy)
1588 (gnus-treat-strip-banner gnus-article-strip-banner)
1589 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1590 (gnus-treat-buttonize gnus-article-add-buttons)
1591 (gnus-treat-fill-article gnus-article-fill-cited-article)
1592 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1593 (gnus-treat-strip-cr gnus-article-remove-cr)
1594 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1595 (gnus-treat-date-ut gnus-article-date-ut)
1596 (gnus-treat-date-local gnus-article-date-local)
1597 (gnus-treat-date-english gnus-article-date-english)
1598 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1599 (gnus-treat-date-original gnus-article-date-original)
1600 (gnus-treat-date-user-defined gnus-article-date-user)
1601 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1602 (gnus-treat-display-face gnus-article-display-face)
1603 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1604 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1605 (gnus-treat-hide-signature gnus-article-hide-signature)
1606 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1607 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1608 (gnus-treat-strip-pem gnus-article-hide-pem)
1609 (gnus-treat-from-picon gnus-treat-from-picon)
1610 (gnus-treat-mail-picon gnus-treat-mail-picon)
1611 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1612 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1613 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1614 (gnus-treat-strip-trailing-blank-lines
1615 gnus-article-remove-trailing-blank-lines)
1616 (gnus-treat-strip-leading-blank-lines
1617 gnus-article-strip-leading-blank-lines)
1618 (gnus-treat-strip-multiple-blank-lines
1619 gnus-article-strip-multiple-blank-lines)
1620 (gnus-treat-overstrike gnus-article-treat-overstrike)
1621 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences)
1622 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1623 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1624 ;; Displaying X-Face should be done after unfolding headers
1625 ;; to protect bitmap lines.
1626 (gnus-treat-display-x-face gnus-article-display-x-face)
1627 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1628 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1629 (gnus-treat-display-smileys gnus-treat-smiley)
1630 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1631 (gnus-treat-wash-html gnus-article-wash-html)
1632 (gnus-treat-emphasize gnus-article-emphasize)
1633 (gnus-treat-hide-citation gnus-article-hide-citation)
1634 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1635 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1636 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1637 (gnus-treat-play-sounds gnus-earcon-display)))
1639 (defvar gnus-article-mime-handle-alist nil)
1640 (defvar article-lapsed-timer nil)
1641 (defvar gnus-article-current-summary nil)
1643 (defvar gnus-article-mode-syntax-table
1644 (let ((table (copy-syntax-table text-mode-syntax-table)))
1645 ;; This causes the citation match run O(2^n).
1646 ;; (modify-syntax-entry ?- "w" table)
1647 (modify-syntax-entry ?> ")<" table)
1648 (modify-syntax-entry ?< "(>" table)
1649 ;; make M-. in article buffers work for `foo' strings
1650 (modify-syntax-entry ?' " " table)
1651 (modify-syntax-entry ?` " " table)
1653 "Syntax table used in article mode buffers.
1654 Initialized from `text-mode-syntax-table.")
1656 (defvar gnus-save-article-buffer nil)
1658 (defvar gnus-article-mode-line-format-alist
1659 (nconc '((?w (gnus-article-wash-status) ?s)
1660 (?m (gnus-article-mime-part-status) ?s))
1661 gnus-summary-mode-line-format-alist))
1663 (defvar gnus-number-of-articles-to-be-saved nil)
1665 (defvar gnus-inhibit-hiding nil)
1667 (defvar gnus-article-edit-mode nil)
1669 ;;; Macros for dealing with the article buffer.
1671 (defmacro gnus-with-article-headers (&rest forms)
1673 (set-buffer gnus-article-buffer)
1675 (let ((inhibit-read-only t)
1676 (inhibit-point-motion-hooks t)
1677 (case-fold-search t))
1678 (article-narrow-to-head)
1681 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1682 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1684 (defmacro gnus-with-article-buffer (&rest forms)
1686 (set-buffer gnus-article-buffer)
1687 (let ((inhibit-read-only t))
1690 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1691 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1693 (defun gnus-article-goto-header (header)
1694 "Go to HEADER, which is a regular expression."
1695 (re-search-forward (concat "^\\(" header "\\):") nil t))
1697 (defsubst gnus-article-hide-text (b e props)
1698 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1699 (gnus-add-text-properties-when 'article-type nil b e props)
1700 (when (memq 'intangible props)
1702 (max (1- b) (point-min))
1703 b 'intangible (cddr (memq 'intangible props)))))
1705 (defsubst gnus-article-unhide-text (b e)
1706 "Remove hidden text properties from region between B and E."
1707 (remove-text-properties b e gnus-hidden-properties)
1708 (when (memq 'intangible gnus-hidden-properties)
1709 (put-text-property (max (1- b) (point-min))
1710 b 'intangible nil)))
1712 (defun gnus-article-hide-text-type (b e type)
1713 "Hide text of TYPE between B and E."
1714 (gnus-add-wash-type type)
1715 (gnus-article-hide-text
1716 b e (cons 'article-type (cons type gnus-hidden-properties))))
1718 (defun gnus-article-unhide-text-type (b e type)
1719 "Unhide text of TYPE between B and E."
1720 (gnus-delete-wash-type type)
1721 (remove-text-properties
1722 b e (cons 'article-type (cons type gnus-hidden-properties)))
1723 (when (memq 'intangible gnus-hidden-properties)
1724 (put-text-property (max (1- b) (point-min))
1725 b 'intangible nil)))
1727 (defun gnus-article-hide-text-of-type (type)
1728 "Hide text of TYPE in the current buffer."
1730 (let ((b (point-min))
1732 (while (setq b (text-property-any b e 'article-type type))
1733 (add-text-properties b (incf b) gnus-hidden-properties)))))
1735 (defun gnus-article-delete-text-of-type (type)
1736 "Delete text of TYPE in the current buffer."
1738 (let ((b (point-min)))
1739 (while (setq b (text-property-any b (point-max) 'article-type type))
1741 b (or (text-property-not-all b (point-max) 'article-type type)
1744 (defun gnus-article-delete-invisible-text ()
1745 "Delete all invisible text in the current buffer."
1747 (let ((b (point-min)))
1748 (while (setq b (text-property-any b (point-max) 'invisible t))
1750 b (or (text-property-not-all b (point-max) 'invisible t)
1753 (defun gnus-article-text-type-exists-p (type)
1754 "Say whether any text of type TYPE exists in the buffer."
1755 (text-property-any (point-min) (point-max) 'article-type type))
1757 (defsubst gnus-article-header-rank ()
1758 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1759 (let ((list gnus-sorted-header-list)
1762 (if (looking-at (car list))
1764 (setq list (cdr list))
1768 (defun article-hide-headers (&optional arg delete)
1769 "Hide unwanted headers and possibly sort them as well."
1770 (interactive (gnus-article-hidden-arg))
1771 ;; Lars said that this function might be inhibited.
1772 (if (gnus-article-check-hidden-text 'headers arg)
1774 ;; Show boring headers as well.
1775 (gnus-article-show-hidden-text 'boring-headers)
1776 (when (eq 1 (point-min))
1777 (set-window-start (get-buffer-window (current-buffer)) 1)))
1778 (unless gnus-inhibit-hiding
1779 (let ((inhibit-read-only t)
1780 (case-fold-search t)
1781 (max (1+ (length gnus-sorted-header-list)))
1782 (inhibit-point-motion-hooks t)
1783 (cur (current-buffer))
1784 ignored visible beg)
1786 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1787 ;; group parameters, so we should go to the summary buffer.
1790 (progn (set-buffer gnus-summary-buffer) t)
1792 (setq ignored (when (not gnus-visible-headers)
1793 (cond ((stringp gnus-ignored-headers)
1794 gnus-ignored-headers)
1795 ((listp gnus-ignored-headers)
1796 (mapconcat 'identity
1797 gnus-ignored-headers
1799 visible (cond ((stringp gnus-visible-headers)
1800 gnus-visible-headers)
1801 ((and gnus-visible-headers
1802 (listp gnus-visible-headers))
1803 (mapconcat 'identity
1804 gnus-visible-headers
1808 ;; First we narrow to just the headers.
1809 (article-narrow-to-head)
1810 ;; Hide any "From " lines at the beginning of (mail) articles.
1811 (while (looking-at "From ")
1815 (delete-region (point-min) (point))
1816 (gnus-article-hide-text (point-min) (point)
1817 (nconc (list 'article-type 'headers)
1818 gnus-hidden-properties))))
1819 ;; Then treat the rest of the header lines.
1820 ;; Then we use the two regular expressions
1821 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1822 ;; select which header lines is to remain visible in the
1824 (while (re-search-forward "^[^ \t:]*:" nil t)
1826 ;; Mark the rank of the header.
1828 (point) (1+ (point)) 'message-rank
1829 (if (or (and visible (looking-at visible))
1831 (not (looking-at ignored))))
1832 (gnus-article-header-rank)
1835 (message-sort-headers-1)
1836 (when (setq beg (text-property-any
1837 (point-min) (point-max) 'message-rank (+ 2 max)))
1838 ;; We delete or make invisible the unwanted headers.
1839 (gnus-add-wash-type 'headers)
1842 (add-text-properties
1843 (point-min) (+ 5 (point-min))
1844 '(article-type headers dummy-invisible t))
1845 (delete-region beg (point-max)))
1846 (gnus-article-hide-text-type beg (point-max) 'headers)))))))))
1848 (defun article-hide-boring-headers (&optional arg)
1849 "Toggle hiding of headers that aren't very interesting.
1850 If given a negative prefix, always show; if given a positive prefix,
1852 (interactive (gnus-article-hidden-arg))
1853 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1854 (not gnus-show-all-headers))
1857 (let ((inhibit-read-only t)
1858 (inhibit-point-motion-hooks t))
1859 (article-narrow-to-head)
1860 (dolist (elem gnus-boring-article-headers)
1861 (goto-char (point-min))
1863 ;; Hide empty headers.
1865 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1867 (gnus-article-hide-text-type
1871 (if (re-search-forward "^[^ \t]" nil t)
1875 ;; Hide boring Newsgroups header.
1876 ((eq elem 'newsgroups)
1877 (when (gnus-string-equal
1878 (gnus-fetch-field "newsgroups")
1879 (gnus-group-real-name
1880 (if (boundp 'gnus-newsgroup-name)
1883 (gnus-article-hide-header "newsgroups")))
1884 ((eq elem 'to-address)
1885 (let ((to (message-fetch-field "to"))
1887 (gnus-parameter-to-address
1888 (if (boundp 'gnus-newsgroup-name)
1889 gnus-newsgroup-name ""))))
1890 (when (and to to-address
1893 ;; only one address in To
1894 (nth 1 (mail-extract-address-components to))
1896 (gnus-article-hide-header "to"))))
1898 (let ((to (message-fetch-field "to"))
1900 (gnus-parameter-to-list
1901 (if (boundp 'gnus-newsgroup-name)
1902 gnus-newsgroup-name ""))))
1903 (when (and to to-list
1906 ;; only one address in To
1907 (nth 1 (mail-extract-address-components to))
1909 (gnus-article-hide-header "to"))))
1911 (let ((cc (message-fetch-field "cc"))
1913 (gnus-parameter-to-list
1914 (if (boundp 'gnus-newsgroup-name)
1915 gnus-newsgroup-name ""))))
1916 (when (and cc to-list
1919 ;; only one address in CC
1920 (nth 1 (mail-extract-address-components cc))
1922 (gnus-article-hide-header "cc"))))
1923 ((eq elem 'followup-to)
1924 (when (gnus-string-equal
1925 (message-fetch-field "followup-to")
1926 (message-fetch-field "newsgroups"))
1927 (gnus-article-hide-header "followup-to")))
1928 ((eq elem 'reply-to)
1929 (if (gnus-group-find-parameter
1930 gnus-newsgroup-name 'broken-reply-to)
1931 (gnus-article-hide-header "reply-to")
1932 (let ((from (message-fetch-field "from"))
1933 (reply-to (message-fetch-field "reply-to")))
1940 (lambda (x) (downcase (cadr x)))
1941 (mail-extract-address-components from t))
1944 (lambda (x) (downcase (cadr x)))
1945 (mail-extract-address-components reply-to t))
1947 (gnus-article-hide-header "reply-to")))))
1949 (let ((date (message-fetch-field "date")))
1951 (< (days-between (current-time-string) date)
1953 (gnus-article-hide-header "date"))))
1955 (let ((to (message-fetch-field "to"))
1956 (cc (message-fetch-field "cc")))
1957 (when (> (length to) 1024)
1958 (gnus-article-hide-header "to"))
1959 (when (> (length cc) 1024)
1960 (gnus-article-hide-header "cc"))))
1964 (goto-char (point-min))
1965 (while (re-search-forward "^to:" nil t)
1966 (setq to-count (1+ to-count)))
1967 (when (> to-count 1)
1968 (while (> to-count 0)
1969 (goto-char (point-min))
1971 (re-search-forward "^to:" nil nil to-count)
1973 (narrow-to-region (point) (point-max))
1974 (gnus-article-hide-header "to"))
1975 (setq to-count (1- to-count))))
1976 (goto-char (point-min))
1977 (while (re-search-forward "^cc:" nil t)
1978 (setq cc-count (1+ cc-count)))
1979 (when (> cc-count 1)
1980 (while (> cc-count 0)
1981 (goto-char (point-min))
1983 (re-search-forward "^cc:" nil nil cc-count)
1985 (narrow-to-region (point) (point-max))
1986 (gnus-article-hide-header "cc"))
1987 (setq cc-count (1- cc-count)))))))))))))
1989 (defun gnus-article-hide-header (header)
1991 (goto-char (point-min))
1992 (when (re-search-forward (concat "^" header ":") nil t)
1993 (gnus-article-hide-text-type
1997 (if (re-search-forward "^[^ \t]" nil t)
2002 (defvar gnus-article-normalized-header-length 40
2003 "Length of normalized headers.")
2005 (defun article-normalize-headers ()
2006 "Make all header lines 40 characters long."
2008 (let ((inhibit-read-only t)
2012 (article-narrow-to-head)
2015 ((< (setq column (- (point-at-eol) (point)))
2016 gnus-article-normalized-header-length)
2018 (insert (make-string
2019 (- gnus-article-normalized-header-length column)
2021 ((> column gnus-article-normalized-header-length)
2022 (gnus-put-text-property
2024 (forward-char gnus-article-normalized-header-length)
2031 (forward-line 1))))))
2033 (defun article-treat-dumbquotes ()
2034 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
2035 Note that this function guesses whether a character is a sm*rtq**t* or
2036 not, so it should only be used interactively.
2038 Sm*rtq**t*s are M****s***'s unilateral extension to the
2039 iso-8859-1 character map in an attempt to provide more quoting
2040 characters. If you see something like \\222 or \\264 where
2041 you're expecting some kind of apostrophe or quotation mark, then
2044 (article-translate-strings gnus-article-dumbquotes-map))
2046 (defun article-translate-characters (from to)
2047 "Translate all characters in the body of the article according to FROM and TO.
2048 FROM is a string of characters to translate from; to is a string of
2049 characters to translate to."
2051 (when (article-goto-body)
2052 (let ((inhibit-read-only t)
2053 (x (make-string 225 ?x))
2055 (while (< (incf i) (length x))
2058 (while (< i (length from))
2059 (aset x (aref from i) (aref to i))
2061 (translate-region (point) (point-max) x)))))
2063 (defun article-translate-strings (map)
2064 "Translate all string in the body of the article according to MAP.
2065 MAP is an alist where the elements are on the form (\"from\" \"to\")."
2067 (when (article-goto-body)
2068 (let ((inhibit-read-only t))
2071 (while (search-forward (car elem) nil t)
2072 (replace-match (cadr elem)))))))))
2074 (defun article-treat-overstrike ()
2075 "Translate overstrikes into bold text."
2078 (when (article-goto-body)
2079 (let ((inhibit-read-only t))
2080 (while (search-forward "\b" nil t)
2081 (let ((next (char-after))
2085 previous (char-after))
2089 ;; We do the boldification/underlining by hiding the
2090 ;; overstrikes and putting the proper text property
2094 (gnus-article-hide-text-type start (point) 'overstrike)
2095 (put-text-property (point) end 'face 'bold))
2097 (gnus-article-hide-text-type
2098 (1- (point)) (1+ (point)) 'overstrike)
2100 start (1- (point)) 'face 'underline))
2102 (gnus-article-hide-text-type start (point) 'overstrike)
2104 (point) end 'face 'underline)))))))))
2106 (defun article-treat-ansi-sequences ()
2107 "Translate ANSI SGR control sequences into overlays or extents."
2110 (when (article-goto-body)
2111 (let ((inhibit-read-only t))
2112 (ansi-color-apply-on-region (point) (point-max))))))
2114 (defun gnus-article-treat-unfold-headers ()
2115 "Unfold folded message headers.
2116 Only the headers that fit into the current window width will be
2119 (gnus-with-article-headers
2123 (mail-header-narrow-to-field)
2124 (let ((header (buffer-string)))
2127 (goto-char (point-min))
2128 (while (re-search-forward "\n[\t ]" nil t)
2129 (replace-match " " t t)))
2130 (setq length (- (point-max) (point-min) 1)))
2131 (when (< length (window-width))
2132 (while (re-search-forward "\n[\t ]" nil t)
2133 (replace-match " " t t)))
2134 (goto-char (point-max)))))))
2136 (defun gnus-article-treat-fold-headers ()
2137 "Fold message headers."
2139 (gnus-with-article-headers
2142 (mail-header-narrow-to-field)
2143 (mail-header-fold-field)
2144 (goto-char (point-max))))))
2146 (defun gnus-treat-smiley ()
2147 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2149 (unless (featurep 'xemacs)
2150 (when (and (not gnus-article-should-use-smiley-mule)
2151 gnus-article-smiley-mule-loaded-p)
2152 (load "smiley" nil t)
2153 (setq gnus-article-smiley-mule-loaded-p nil))
2154 (when (and gnus-article-should-use-smiley-mule
2155 (not gnus-article-smiley-mule-loaded-p))
2156 (load "smiley-mule" nil t)
2157 (setq gnus-article-smiley-mule-loaded-p t)))
2158 (gnus-with-article-buffer
2159 (if (memq 'smiley gnus-article-wash-types)
2160 (gnus-delete-images 'smiley)
2162 (let ((images (smiley-region (point) (point-max))))
2164 (gnus-add-wash-type 'smiley)
2165 (dolist (image images)
2166 (gnus-add-image 'smiley image)))))))
2168 (defun gnus-article-remove-images ()
2169 "Remove all images from the article buffer."
2171 (gnus-with-article-buffer
2172 (dolist (elem gnus-article-image-alist)
2173 (gnus-delete-images (car elem)))))
2175 (defun gnus-article-treat-fold-newsgroups ()
2176 "Unfold folded message headers.
2177 Only the headers that fit into the current window width will be
2180 (gnus-with-article-headers
2181 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2183 (mail-header-narrow-to-field)
2184 (while (re-search-forward ", *" nil t)
2185 (replace-match ", " t t))
2186 (mail-header-fold-field)
2187 (goto-char (point-max))))))
2189 (defun gnus-article-treat-body-boundary ()
2190 "Place a boundary line at the end of the headers."
2192 (when (and gnus-body-boundary-delimiter
2193 (> (length gnus-body-boundary-delimiter) 0))
2194 (gnus-with-article-headers
2195 (goto-char (point-max))
2196 (let ((start (point)))
2197 (insert "X-Boundary: ")
2198 (gnus-add-text-properties start (point) '(invisible t intangible t))
2200 (while (>= (1- (window-width)) (length str))
2201 (setq str (concat str gnus-body-boundary-delimiter)))
2202 (substring str 0 (1- (window-width))))
2204 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2206 (defun article-fill-long-lines ()
2207 "Fill lines that are wider than the window width."
2210 (let ((inhibit-read-only t)
2211 (width (window-width (get-buffer-window (current-buffer)))))
2214 (let ((adaptive-fill-mode nil)) ;Why? -sm
2217 (when (>= (current-column) (min fill-column width))
2218 (narrow-to-region (min (1+ (point)) (point-max))
2220 (let ((goback (point-marker)))
2221 (fill-paragraph nil)
2222 (goto-char (marker-position goback)))
2224 (forward-line 1)))))))
2226 (defun article-capitalize-sentences ()
2227 "Capitalize the first word in each sentence."
2230 (let ((inhibit-read-only t)
2231 (paragraph-start "^[\n\^L]"))
2235 (forward-sentence)))))
2237 (defun article-remove-cr ()
2238 "Remove trailing CRs and then translate remaining CRs into LFs."
2241 (let ((inhibit-read-only t))
2242 (goto-char (point-min))
2243 (while (re-search-forward "\r+$" nil t)
2244 (replace-match "" t t))
2245 (goto-char (point-min))
2246 (while (search-forward "\r" nil t)
2247 (replace-match "\n" t t)))))
2249 (defun article-remove-trailing-blank-lines ()
2250 "Remove all trailing blank lines from the article."
2253 (let ((inhibit-read-only t))
2254 (goto-char (point-max))
2258 (while (and (not (bobp))
2259 (looking-at "^[ \t]*$")
2260 (not (gnus-annotation-in-region-p
2261 (point) (point-at-eol))))
2267 (defvar gnus-face-properties-alist))
2269 (defun article-display-face ()
2270 "Display any Face headers in the header."
2272 (let ((wash-face-p buffer-read-only))
2273 (gnus-with-article-headers
2274 ;; When displaying parts, this function can be called several times on
2275 ;; the same article, without any intended toggle semantic (as typing `W
2276 ;; D d' would have). So face deletion must occur only when we come from
2277 ;; an interactive command, that is when the *Article* buffer is
2279 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2280 (gnus-delete-images 'face)
2283 (when (and wash-face-p
2285 (goto-char (point-min))
2286 (not (re-search-forward "^Face:[\t ]*" nil t)))
2287 (gnus-buffer-live-p gnus-original-article-buffer))
2288 (set-buffer gnus-original-article-buffer))
2290 (mail-narrow-to-head)
2291 (while (gnus-article-goto-header "Face")
2292 (setq faces (nconc faces (list (mail-header-field-value)))))))
2293 (dolist (face faces)
2294 (let ((png (gnus-convert-face-to-png face))
2298 (apply 'gnus-create-image png 'png t
2299 (cdr (assq 'png gnus-face-properties-alist))))
2300 (gnus-article-goto-header "from")
2302 (insert "From: [no `from' set]\n")
2304 (gnus-add-wash-type 'face)
2305 (gnus-add-image 'face image)
2306 (gnus-put-image image nil 'face))))))
2309 (defun article-display-x-face (&optional force)
2310 "Look for an X-Face header and display it if present."
2311 (interactive (list 'force))
2312 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2313 (gnus-with-article-headers
2314 ;; Delete the old process, if any.
2315 (when (process-status "article-x-face")
2316 (delete-process "article-x-face"))
2317 ;; See the comment in `article-display-face'.
2318 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2319 ;; We have already displayed X-Faces, so we remove them
2321 (gnus-delete-images 'xface)
2323 (let (x-faces from face)
2325 (when (and wash-face-p
2327 (goto-char (point-min))
2328 (not (re-search-forward
2329 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2330 (gnus-buffer-live-p gnus-original-article-buffer))
2331 ;; If type `W f', use gnus-original-article-buffer,
2332 ;; otherwise use the current buffer because displaying
2333 ;; RFC822 parts calls this function too.
2334 (set-buffer gnus-original-article-buffer))
2336 (mail-narrow-to-head)
2337 (while (gnus-article-goto-header "X-Face")
2338 (push (mail-header-field-value) x-faces))
2339 (setq from (message-fetch-field "from"))))
2340 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2341 ;; single external face.
2342 (when (stringp gnus-article-x-face-command)
2343 (setq x-faces (list (car x-faces))))
2344 (while (and (setq face (pop x-faces))
2345 gnus-article-x-face-command
2347 ;; Check whether this face is censored.
2348 (not gnus-article-x-face-too-ugly)
2349 (and gnus-article-x-face-too-ugly from
2350 (not (string-match gnus-article-x-face-too-ugly
2352 ;; We display the face.
2353 (cond ((stringp gnus-article-x-face-command)
2354 ;; The command is a string, so we interpret the command
2355 ;; as a, well, command, and fork it off.
2356 (let ((process-connection-type nil))
2357 (process-kill-without-query
2359 "article-x-face" nil shell-file-name
2360 shell-command-switch gnus-article-x-face-command))
2363 (process-send-region "article-x-face"
2364 (point-min) (point-max)))
2365 (process-send-eof "article-x-face")))
2366 ((functionp gnus-article-x-face-command)
2367 ;; The command is a lisp function, so we call it.
2368 (funcall gnus-article-x-face-command face))
2370 (error "%s is not a function"
2371 gnus-article-x-face-command)))))))))
2373 (defun article-decode-mime-words ()
2374 "Decode all MIME-encoded words in the article."
2376 (gnus-with-article-buffer
2377 (let ((inhibit-point-motion-hooks t)
2378 (mail-parse-charset gnus-newsgroup-charset)
2379 (mail-parse-ignored-charsets
2380 (with-current-buffer gnus-summary-buffer
2381 gnus-newsgroup-ignored-charsets)))
2382 (mail-decode-encoded-word-region (point-min) (point-max)))))
2384 (defun article-decode-charset (&optional prompt)
2385 "Decode charset-encoded text in the article.
2386 If PROMPT (the prefix), prompt for a coding system to use."
2388 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2389 (inhibit-read-only t)
2390 (mail-parse-charset gnus-newsgroup-charset)
2391 (mail-parse-ignored-charsets
2392 (save-excursion (condition-case nil
2393 (set-buffer gnus-summary-buffer)
2395 gnus-newsgroup-ignored-charsets))
2396 ct cte ctl charset format)
2399 (article-narrow-to-head)
2400 (setq ct (message-fetch-field "Content-Type" t)
2401 cte (message-fetch-field "Content-Transfer-Encoding" t)
2402 ctl (and ct (ignore-errors
2403 (mail-header-parse-content-type ct)))
2406 (mm-read-coding-system "Charset to decode: "))
2408 (mail-content-type-get ctl 'charset)))
2409 format (and ctl (mail-content-type-get ctl 'format)))
2411 (setq cte (mail-header-strip cte)))
2412 (if (and ctl (not (string-match "/" (car ctl))))
2414 (goto-char (point-max)))
2417 (narrow-to-region (point) (point-max))
2418 (when (and (eq mail-parse-charset 'gnus-decoded)
2419 (eq (mm-body-7-or-8) '8bit))
2420 ;; The text code could have been decoded.
2421 (setq charset mail-parse-charset))
2422 (when (and (or (not ctl)
2423 (equal (car ctl) "text/plain"))
2424 (not format)) ;; article with format will decode later.
2426 charset (and cte (intern (downcase
2427 (gnus-strip-whitespace cte))))
2430 (defun article-decode-encoded-words ()
2431 "Remove encoded-word encoding from headers."
2432 (let ((charset (save-excursion
2433 (set-buffer gnus-summary-buffer)
2434 default-mime-charset))
2435 (inhibit-read-only t))
2436 (mime-decode-header-in-buffer charset)))
2438 (defun article-decode-group-name ()
2439 "Decode group names in `Newsgroups:'."
2440 (let ((inhibit-point-motion-hooks t)
2441 (inhibit-read-only t)
2442 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2443 (when (and (or gnus-group-name-charset-method-alist
2444 gnus-group-name-charset-group-alist)
2445 (gnus-buffer-live-p gnus-original-article-buffer))
2447 (article-narrow-to-head)
2448 (with-current-buffer gnus-original-article-buffer
2449 (goto-char (point-min)))
2450 (while (re-search-forward
2451 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2452 (replace-match (save-match-data
2453 (gnus-decode-newsgroups
2454 ;; XXX how to use data in article buffer?
2455 (with-current-buffer gnus-original-article-buffer
2457 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2460 gnus-newsgroup-name method))
2462 (goto-char (point-min))
2463 (with-current-buffer gnus-original-article-buffer
2464 (goto-char (point-min)))
2465 (while (re-search-forward
2466 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2467 (replace-match (save-match-data
2468 (gnus-decode-newsgroups
2469 ;; XXX how to use data in article buffer?
2470 (with-current-buffer gnus-original-article-buffer
2472 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2475 gnus-newsgroup-name method))
2478 (autoload 'idna-to-unicode "idna")
2480 (defun article-decode-idna-rhs ()
2481 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2484 (let ((inhibit-point-motion-hooks t)
2485 (inhibit-read-only t))
2486 (article-narrow-to-head)
2487 (goto-char (point-min))
2488 (while (re-search-forward "@.*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2490 (when (save-match-data
2491 (and (setq ace (match-string 1))
2493 (and (re-search-backward "^[^ \t]" nil t)
2494 (looking-at "From\\|To\\|Cc")))
2495 (setq unicode (idna-to-unicode ace))))
2496 (unless (string= ace unicode)
2497 (replace-match unicode nil nil nil 1)))))))))
2499 (defun article-de-quoted-unreadable (&optional force read-charset)
2500 "Translate a quoted-printable-encoded article.
2501 If FORCE, decode the article whether it is marked as quoted-printable
2503 If READ-CHARSET, ask for a coding system."
2504 (interactive (list 'force current-prefix-arg))
2506 (let ((inhibit-read-only t) type charset)
2507 (if (gnus-buffer-live-p gnus-original-article-buffer)
2508 (with-current-buffer gnus-original-article-buffer
2510 (gnus-fetch-field "content-transfer-encoding"))
2511 (let* ((ct (gnus-fetch-field "content-type"))
2514 (mail-header-parse-content-type ct)))))
2515 (setq charset (and ctl
2516 (mail-content-type-get ctl 'charset)))
2517 (if (stringp charset)
2518 (setq charset (intern (downcase charset)))))))
2520 (setq charset (mm-read-coding-system "Charset: " charset)))
2522 (setq charset gnus-newsgroup-charset))
2524 (and type (let ((case-fold-search t))
2525 (string-match "quoted-printable" type))))
2527 (quoted-printable-decode-region
2528 (point) (point-max) (mm-charset-to-coding-system charset))))))
2530 (defun article-de-base64-unreadable (&optional force read-charset)
2531 "Translate a base64 article.
2532 If FORCE, decode the article whether it is marked as base64 not.
2533 If READ-CHARSET, ask for a coding system."
2534 (interactive (list 'force current-prefix-arg))
2536 (let ((inhibit-read-only t) type charset)
2537 (if (gnus-buffer-live-p gnus-original-article-buffer)
2538 (with-current-buffer gnus-original-article-buffer
2540 (gnus-fetch-field "content-transfer-encoding"))
2541 (let* ((ct (gnus-fetch-field "content-type"))
2544 (mail-header-parse-content-type ct)))))
2545 (setq charset (and ctl
2546 (mail-content-type-get ctl 'charset)))
2547 (if (stringp charset)
2548 (setq charset (intern (downcase charset)))))))
2550 (setq charset (mm-read-coding-system "Charset: " charset)))
2552 (setq charset gnus-newsgroup-charset))
2554 (and type (let ((case-fold-search t))
2555 (string-match "base64" type))))
2558 (narrow-to-region (point) (point-max))
2559 (base64-decode-region (point-min) (point-max))
2560 (mm-decode-coding-region
2561 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2566 (defun article-decode-HZ ()
2567 "Translate a HZ-encoded article."
2571 (let ((inhibit-read-only t))
2572 (rfc1843-decode-region (point-min) (point-max)))))
2574 (defun article-unsplit-urls ()
2575 "Remove the newlines that some other mailers insert into URLs."
2578 (let ((inhibit-read-only t))
2579 (goto-char (point-min))
2580 (while (re-search-forward
2581 "\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2582 (replace-match "\\1\\3" t)))
2583 (when (interactive-p)
2584 (gnus-treat-article nil))))
2587 (defun article-wash-html (&optional read-charset)
2588 "Format an HTML article.
2589 If READ-CHARSET, ask for a coding system."
2592 (let ((inhibit-read-only t)
2594 (when (gnus-buffer-live-p gnus-original-article-buffer)
2595 (with-current-buffer gnus-original-article-buffer
2596 (let* ((ct (gnus-fetch-field "content-type"))
2599 (mail-header-parse-content-type ct)))))
2600 (setq charset (and ctl
2601 (mail-content-type-get ctl 'charset)))
2602 (when (stringp charset)
2603 (setq charset (intern (downcase charset)))))))
2605 (setq charset (mm-read-coding-system "Charset: " charset)))
2607 (setq charset gnus-newsgroup-charset))
2609 (save-window-excursion
2611 (narrow-to-region (point) (point-max))
2612 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2613 (entry (assq func mm-text-html-washer-alist)))
2615 (setq func (cdr entry)))
2620 (apply (car func) (cdr func))))))))))
2622 (defun gnus-article-wash-html-with-w3 ()
2623 "Wash the current buffer with w3."
2625 (let ((w3-strict-width (window-width))
2626 (url-standalone-mode t)
2627 (url-gateway-unplugged t)
2628 (w3-honor-stylesheets nil))
2630 (w3-region (point-min) (point-max))
2633 (defun gnus-article-wash-html-with-w3m ()
2634 "Wash the current buffer with emacs-w3m."
2637 (narrow-to-region (point) (point-max))
2638 (let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp)
2639 w3m-force-redisplay)
2640 (w3m-region (point-min) (point-max)))
2641 (when (and mm-inline-text-html-with-w3m-keymap
2642 (boundp 'w3m-minor-mode-map)
2644 (add-text-properties
2645 (point-min) (point-max)
2646 (list 'keymap w3m-minor-mode-map
2647 ;; Put the mark meaning this part was rendered by emacs-w3m.
2648 'mm-inline-text-html-with-w3m t)))))
2650 (defun article-hide-list-identifiers ()
2651 "Remove list identifies from the Subject header.
2652 The `gnus-list-identifiers' variable specifies what to do."
2654 (let ((inhibit-point-motion-hooks t)
2655 (regexp (if (consp gnus-list-identifiers)
2656 (mapconcat 'identity gnus-list-identifiers " *\\|")
2657 gnus-list-identifiers))
2658 (inhibit-read-only t))
2662 (article-narrow-to-head)
2663 (goto-char (point-min))
2664 (while (re-search-forward
2665 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2667 (delete-region (match-beginning 2) (match-end 0))
2668 (beginning-of-line))
2669 (when (re-search-forward
2670 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2671 (delete-region (match-beginning 1) (match-end 1))))))))
2673 (defun article-hide-pem (&optional arg)
2674 "Toggle hiding of any PEM headers and signatures in the current article.
2675 If given a negative prefix, always show; if given a positive prefix,
2677 (interactive (gnus-article-hidden-arg))
2678 (unless (gnus-article-check-hidden-text 'pem arg)
2680 (let ((inhibit-read-only t) end)
2681 (goto-char (point-min))
2682 ;; Hide the horrendously ugly "header".
2683 (when (and (search-forward
2684 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2686 (setq end (1+ (match-beginning 0))))
2687 (gnus-add-wash-type 'pem)
2688 (gnus-article-hide-text-type
2690 (if (search-forward "\n\n" nil t)
2694 ;; Hide the trailer as well
2695 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2697 (gnus-article-hide-text-type
2698 (match-beginning 0) (match-end 0) 'pem)))))))
2700 (defun article-strip-banner ()
2701 "Strip the banners specified by the `banner' group parameter and by
2702 `gnus-article-address-banner-alist'."
2706 (let ((inhibit-point-motion-hooks t))
2707 (when (gnus-parameter-banner gnus-newsgroup-name)
2708 (article-really-strip-banner
2709 (gnus-parameter-banner gnus-newsgroup-name)))
2710 (when gnus-article-address-banner-alist
2711 ;; It is necessary to encode from fields before checking,
2712 ;; because `mail-header-parse-addresses' does not work
2713 ;; (reliably) on decoded headers. And more, it is
2714 ;; impossible to use `gnus-fetch-original-field' here,
2715 ;; because `article-strip-banner' may be called in draft
2716 ;; buffers to preview them.
2717 (let ((from (save-restriction
2719 (article-narrow-to-head)
2720 (mail-fetch-field "from"))))
2723 (caar (mail-header-parse-addresses
2724 (mail-encode-encoded-word-string from)))))
2726 (dolist (pair gnus-article-address-banner-alist)
2727 (when (string-match (car pair) from)
2729 (article-really-strip-banner (cdr pair)))))))))))))
2731 (defun article-really-strip-banner (banner)
2732 "Strip the banner specified by the argument."
2735 (let ((inhibit-point-motion-hooks t)
2736 (gnus-signature-limit nil)
2737 (inhibit-read-only t))
2740 ((eq banner 'signature)
2741 (when (gnus-article-narrow-to-signature)
2744 (delete-region (point) (point-max))))
2746 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2747 (while (re-search-forward banner nil t)
2748 (delete-region (match-beginning 0) (match-end 0)))))
2750 (while (re-search-forward banner nil t)
2751 (delete-region (match-beginning 0) (match-end 0)))))))))
2753 (defun article-babel ()
2754 "Translate article using an online translation service."
2757 (gnus-with-article-buffer
2758 (when (article-goto-body)
2759 (let* ((start (point))
2761 (orig (buffer-substring start end))
2762 (trans (babel-as-string orig)))
2764 (narrow-to-region start end)
2765 (delete-region start end)
2768 (defun article-hide-signature (&optional arg)
2769 "Hide the signature in the current article.
2770 If given a negative prefix, always show; if given a positive prefix,
2772 (interactive (gnus-article-hidden-arg))
2778 (article-goto-body))
2779 (goto-char (point-min)))
2780 (unless (gnus-article-check-hidden-text 'signature arg)
2781 (let ((inhibit-read-only t)
2783 (while (setq button (text-property-any button (point-max)
2785 'gnus-signature-toggle))
2786 (setq button (text-property-not-all button (point-max)
2788 'gnus-signature-toggle))
2789 (when (and button (not (eobp)))
2790 (gnus-article-hide-text-type
2792 (next-single-property-change (1+ button) 'mime-view-entity
2795 (gnus-set-mode-line 'article))
2797 (defun article-strip-headers-in-body ()
2798 "Strip offensive headers from bodies."
2802 (let ((case-fold-search t))
2803 (when (looking-at "x-no-archive:")
2804 (gnus-delete-line)))))
2806 (defun article-strip-leading-blank-lines ()
2807 "Remove all blank lines from the beginning of the article."
2810 (let ((inhibit-point-motion-hooks t)
2811 (inhibit-read-only t))
2812 (when (article-goto-body)
2813 (while (and (not (eobp))
2814 (looking-at "[ \t]*$"))
2815 (gnus-delete-line))))))
2817 (defun article-narrow-to-head ()
2818 "Narrow the buffer to the head of the message.
2819 Point is left at the beginning of the narrowed-to region."
2821 (goto-char (point-min))
2822 (if (search-forward "\n\n" nil 1)
2825 (goto-char (point-min)))
2827 (defun article-goto-body ()
2828 "Place point at the start of the body."
2829 (goto-char (point-min))
2831 ;; This variable is only bound when dealing with separate
2833 (article-goto-body-goes-to-point-min-p
2835 ((search-forward "\n\n" nil t)
2838 (goto-char (point-max))
2841 (defun article-strip-multiple-blank-lines ()
2842 "Replace consecutive blank lines with one empty line."
2845 (let ((inhibit-point-motion-hooks t)
2846 (inhibit-read-only t))
2847 ;; First make all blank lines empty.
2849 (while (re-search-forward "^[ \t]+$" nil t)
2850 (unless (gnus-annotation-in-region-p
2851 (match-beginning 0) (match-end 0))
2852 (replace-match "" nil t)))
2853 ;; Then replace multiple empty lines with a single empty line.
2855 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2856 (unless (gnus-annotation-in-region-p
2857 (match-beginning 0) (match-end 0))
2858 (delete-region (match-beginning 1) (match-end 1)))))))
2860 (defun article-strip-leading-space ()
2861 "Remove all white space from the beginning of the lines in the article."
2864 (let ((inhibit-point-motion-hooks t)
2865 (inhibit-read-only t))
2867 (while (re-search-forward "^[ \t]+" nil t)
2868 (replace-match "" t t)))))
2870 (defun article-strip-trailing-space ()
2871 "Remove all white space from the end of the lines in the article."
2874 (let ((inhibit-point-motion-hooks t)
2875 (inhibit-read-only t))
2877 (while (re-search-forward "[ \t]+$" nil t)
2878 (replace-match "" t t)))))
2880 (defun article-strip-blank-lines ()
2881 "Strip leading, trailing and multiple blank lines."
2883 (article-strip-leading-blank-lines)
2884 (article-remove-trailing-blank-lines)
2885 (article-strip-multiple-blank-lines))
2887 (defun article-strip-all-blank-lines ()
2888 "Strip all blank lines."
2891 (let ((inhibit-point-motion-hooks t)
2892 (inhibit-read-only t))
2894 (while (re-search-forward "^[ \t]*\n" nil t)
2895 (replace-match "" t t)))))
2897 (defun gnus-article-narrow-to-signature ()
2898 "Narrow to the signature; return t if a signature is found, else nil."
2899 (let ((inhibit-point-motion-hooks t))
2900 (when (gnus-article-search-signature)
2902 ;; Check whether we have some limits to what we consider
2903 ;; to be a signature.
2904 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2905 (list gnus-signature-limit)))
2907 (while (setq limit (pop limits))
2908 (if (or (and (integerp limit)
2909 (< (- (point-max) (point)) limit))
2911 (< (count-lines (point) (point-max)) limit))
2912 (and (functionp limit)
2914 (and (stringp limit)
2915 (not (re-search-forward limit nil t))))
2916 () ; This limit did not succeed.
2920 (narrow-to-region (point) (point-max))
2923 (defun gnus-article-search-signature ()
2924 "Search the current buffer for the signature separator.
2925 Put point at the beginning of the signature separator."
2926 (let ((cur (point)))
2927 (goto-char (point-max))
2928 (if (if (stringp gnus-signature-separator)
2929 (re-search-backward gnus-signature-separator nil t)
2930 (let ((seps gnus-signature-separator))
2932 (not (re-search-backward (car seps) nil t)))
2939 (defun gnus-article-hidden-arg ()
2940 "Return the current prefix arg as a number, or 0 if no prefix."
2941 (list (if current-prefix-arg
2942 (prefix-numeric-value current-prefix-arg)
2945 (defun gnus-article-check-hidden-text (type arg)
2946 "Return nil if hiding is necessary.
2947 Arg can be nil or a number. nil and positive means hide, negative
2948 means show, 0 means toggle."
2951 (let ((hide (gnus-article-hidden-text-p type)))
2957 (gnus-article-show-hidden-text type)
2960 (if (eq hide 'hidden)
2962 (gnus-article-show-hidden-text type)
2966 (defun gnus-article-hidden-text-p (type)
2967 "Say whether the current buffer contains hidden text of type TYPE."
2968 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2970 (not (get-text-property pos 'invisible))
2971 (not (get-text-property pos 'dummy-invisible)))
2973 (text-property-any (1+ pos) (point-max) 'article-type type)))
2978 (defun gnus-article-show-hidden-text (type &optional dummy)
2979 "Show all hidden text of type TYPE.
2980 Originally it is hide instead of DUMMY."
2981 (let ((inhibit-read-only t)
2982 (inhibit-point-motion-hooks t))
2983 (gnus-remove-text-properties-when
2985 (point-min) (point-max)
2986 (cons 'article-type (cons type
2987 gnus-hidden-properties)))
2988 (gnus-delete-wash-type type)))
2990 (defconst article-time-units
2991 `((year . ,(* 365.25 24 60 60))
2992 (week . ,(* 7 24 60 60))
2993 (day . ,(* 24 60 60))
2997 "Mapping from time units to seconds.")
2999 (defun gnus-article-forward-header ()
3000 "Move point to the start of the next header.
3001 If the current header is a continuation header, this can be several
3006 (if (looking-at "[ \t]+[^ \t]")
3010 (defun article-date-ut (&optional type highlight)
3011 "Convert DATE date to universal time in the current article.
3012 If TYPE is `local', convert to local time; if it is `lapsed', output
3013 how much time has lapsed since DATE. For `lapsed', the value of
3014 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
3015 should replace the \"Date:\" one, or should be added below it."
3016 (interactive (list 'ut t))
3017 (let* ((tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
3018 (date-regexp (if (and gnus-article-date-lapsed-new-header
3022 (case-fold-search t)
3023 (inhibit-read-only t)
3024 (inhibit-point-motion-hooks t)
3025 pos date bface eface)
3029 (goto-char (point-min))
3030 (while (and (or (setq date (get-text-property (setq pos (point))
3032 (and (setq pos (next-single-property-change
3033 (point) 'original-date))
3034 (setq date (get-text-property pos
3036 (not (string-equal date "")))
3039 (or (text-property-any pos (point-max) 'original-date nil)
3041 (goto-char (point-min))
3042 (when (re-search-forward tdate-regexp nil t)
3043 (setq bface (get-text-property (point-at-bol) 'face)
3044 eface (get-text-property (1- (point-at-eol)) 'face)))
3045 (goto-char (point-min))
3047 ;; Delete any old Date headers.
3048 (while (re-search-forward date-regexp nil t)
3050 (delete-region (point-at-bol) (progn
3051 (gnus-article-forward-header)
3053 (delete-region (point-at-bol) (progn
3054 (gnus-article-forward-header)
3057 (setq pos (point))))
3058 (when (and (not pos)
3059 (re-search-forward tdate-regexp nil t))
3061 (gnus-goto-char pos)
3062 (insert (article-make-date-line date (or type 'ut)))
3068 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
3069 (put-text-property (match-beginning 1) (1+ (match-end 1))
3071 (put-text-property (match-beginning 2) (match-end 2)
3073 (put-text-property (point-min) (1- (point-max)) 'original-date date)
3074 (goto-char (point-max))
3077 (defun article-make-date-line (date type)
3078 "Return a DATE line of TYPE."
3079 (unless (memq type '(local ut original user iso8601 lapsed english))
3080 (error "Unknown conversion type: %s" type))
3082 (let ((time (date-to-time date)))
3084 ;; Convert to the local timezone.
3086 (concat "Date: " (message-make-date time)))
3087 ;; Convert to Universal Time.
3092 (let* ((e (parse-time-string date))
3093 (tm (apply 'encode-time e))
3095 (ls (- (cadr tm) (car (current-time-zone time)))))
3096 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
3097 ((> ls 65535) (list (1+ ms) (- ls 65536)))
3101 ;; Get the original date from the article.
3102 ((eq type 'original)
3103 (concat "Date: " (if (string-match "\n+$" date)
3104 (substring date 0 (match-beginning 0))
3106 ;; Let the user define the format.
3108 (let ((format (or (condition-case nil
3109 (with-current-buffer gnus-summary-buffer
3110 gnus-article-time-format)
3112 gnus-article-time-format)))
3113 (if (functionp format)
3114 (funcall format time)
3115 (concat "Date: " (format-time-string format time)))))
3118 (let ((tz (car (current-time-zone time))))
3121 (format-time-string "%Y%m%dT%H%M%S" time)
3122 (format "%s%02d%02d"
3123 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
3124 (/ (% (abs tz) 3600) 60)))))
3125 ;; Do an X-Sent lapsed format.
3127 ;; If the date is seriously mangled, the timezone functions are
3128 ;; liable to bug out, so we ignore all errors.
3129 (let* ((now (current-time))
3130 (real-time (subtract-time now time))
3131 (real-sec (and real-time
3132 (+ (* (float (car real-time)) 65536)
3134 (sec (and real-time (abs real-sec)))
3144 ;; This is a bit convoluted, but basically we go
3145 ;; through the time units for years, weeks, etc,
3146 ;; and divide things to see whether that results
3147 ;; in positive answers.
3150 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
3151 ;; The (remaining) seconds are too few to
3152 ;; be divided into this time unit.
3154 ;; It's big enough, so we output it.
3155 (setq sec (- sec (* num (cdr unit))))
3157 (concat (if prev ", " "") (int-to-string
3159 " " (symbol-name (car unit))
3160 (if (> num 1) "s" ""))
3162 article-time-units "")
3163 ;; If dates are odd, then it might appear like the
3164 ;; article was sent in the future.
3167 " in the future"))))))
3168 ;; Display the date in proper English
3170 (let ((dtime (decode-time time)))
3173 (number-to-string (nth 3 dtime))
3174 (let ((digit (% (nth 3 dtime) 10)))
3176 ((memq (nth 3 dtime) '(11 12 13)) "th")
3182 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3184 (number-to-string (nth 5 dtime))
3186 (format "%02d" (nth 2 dtime))
3188 (format "%02d" (nth 1 dtime)))))))
3190 (format "Date: %s (from T-gnus)" date))))
3192 (defun article-date-local (&optional highlight)
3193 "Convert the current article date to the local timezone."
3194 (interactive (list t))
3195 (article-date-ut 'local highlight))
3197 (defun article-date-english (&optional highlight)
3198 "Convert the current article date to something that is proper English."
3199 (interactive (list t))
3200 (article-date-ut 'english highlight))
3202 (defun article-date-original (&optional highlight)
3203 "Convert the current article date to what it was originally.
3204 This is only useful if you have used some other date conversion
3205 function and want to see what the date was before converting."
3206 (interactive (list t))
3207 (article-date-ut 'original highlight))
3209 (defun article-date-lapsed (&optional highlight)
3210 "Convert the current article date to time lapsed since it was sent."
3211 (interactive (list t))
3212 (article-date-ut 'lapsed highlight))
3214 (defun article-update-date-lapsed ()
3215 "Function to be run from a timer to update the lapsed time line."
3216 (let (deactivate-mark)
3221 (set-buffer (window-buffer w))
3222 (when (eq major-mode 'gnus-article-mode)
3223 (let ((mark (point-marker)))
3224 (goto-char (point-min))
3225 (when (re-search-forward "^X-Sent:" nil t)
3226 (article-date-lapsed t))
3227 (goto-char (marker-position mark))
3228 (move-marker mark nil))))
3231 (defun gnus-start-date-timer (&optional n)
3232 "Start a timer to update the X-Sent header in the article buffers.
3233 The numerical prefix says how frequently (in seconds) the function
3238 (gnus-stop-date-timer)
3239 (setq article-lapsed-timer
3240 (run-at-time 1 n 'article-update-date-lapsed)))
3242 (defun gnus-stop-date-timer ()
3243 "Stop the X-Sent timer."
3245 (when article-lapsed-timer
3246 (nnheader-cancel-timer article-lapsed-timer)
3247 (setq article-lapsed-timer nil)))
3249 (defun article-date-user (&optional highlight)
3250 "Convert the current article date to the user-defined format.
3251 This format is defined by the `gnus-article-time-format' variable."
3252 (interactive (list t))
3253 (article-date-ut 'user highlight))
3255 (defun article-date-iso8601 (&optional highlight)
3256 "Convert the current article date to ISO8601."
3257 (interactive (list t))
3258 (article-date-ut 'iso8601 highlight))
3260 (defun gnus-article-save-original-date ()
3261 "Save the original date as a text property."
3262 ;;(goto-char (point-max))
3263 (skip-chars-backward "\n")
3266 (case-fold-search t))
3267 (goto-char (point-min))
3268 (when (and (re-search-forward "^date:[\t\n ]+" nil t)
3270 (setq start (match-end 0))
3271 (re-search-forward "[\t ]*\n\\(?:[^\t ]\\|\\'\\)" nil t)))
3273 (point-min) end 'original-date
3274 (buffer-substring-no-properties start (match-beginning 0))))))
3276 ;; (defun article-show-all ()
3277 ;; "Show all hidden text in the article buffer."
3281 ;; (let ((inhibit-read-only t))
3282 ;; (gnus-article-unhide-text (point-min) (point-max))
3283 ;; (gnus-remove-text-with-property 'gnus-prev)
3284 ;; (gnus-remove-text-with-property 'gnus-next))))
3286 (defun article-show-all-headers ()
3287 "Show all hidden headers in the article buffer."
3292 (article-narrow-to-head)
3293 (let ((inhibit-read-only t))
3294 (gnus-article-unhide-text (point-min) (point-max))))))
3296 (defun article-remove-leading-whitespace ()
3297 "Remove excessive whitespace from all headers."
3301 (let ((inhibit-read-only t))
3302 (article-narrow-to-head)
3303 (goto-char (point-min))
3304 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3305 (delete-region (match-beginning 1) (match-end 1)))))))
3307 (defun article-emphasize (&optional arg)
3308 "Emphasize text according to `gnus-emphasis-alist'."
3309 (interactive (gnus-article-hidden-arg))
3310 (unless (gnus-article-check-hidden-text 'emphasis arg)
3314 (with-current-buffer gnus-summary-buffer
3315 gnus-article-emphasis-alist)
3317 gnus-emphasis-alist))
3318 (inhibit-read-only t)
3319 (props (append '(article-type emphasis)
3320 gnus-hidden-properties))
3321 regexp elem beg invisible visible face)
3324 (while (setq elem (pop alist))
3326 (setq regexp (car elem)
3327 invisible (nth 1 elem)
3328 visible (nth 2 elem)
3330 (while (re-search-forward regexp nil t)
3331 (when (and (match-beginning visible) (match-beginning invisible))
3332 (gnus-article-hide-text
3333 (match-beginning invisible) (match-end invisible) props)
3334 (gnus-article-unhide-text-type
3335 (match-beginning visible) (match-end visible) 'emphasis)
3336 (gnus-put-overlay-excluding-newlines
3337 (match-beginning visible) (match-end visible) 'face face)
3338 (gnus-add-wash-type 'emphasis)
3339 (goto-char (match-end invisible)))))))))
3341 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3342 "Setup newsgroup emphasis alist."
3343 (unless gnus-article-emphasis-alist
3344 (let ((name (and gnus-newsgroup-name
3345 (gnus-group-real-name gnus-newsgroup-name))))
3346 (make-local-variable 'gnus-article-emphasis-alist)
3347 (setq gnus-article-emphasis-alist
3349 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3350 (while (setq elem (pop alist))
3351 (when (and name (string-match (car elem) name))
3353 highlight (copy-sequence (cdr elem)))))
3355 (copy-sequence highlight-words)
3356 (if gnus-newsgroup-name
3357 (copy-sequence (gnus-group-find-parameter
3358 gnus-newsgroup-name 'highlight-words t)))
3359 gnus-emphasis-alist)))))
3362 (defvar gnus-summary-article-menu)
3363 (defvar gnus-summary-post-menu))
3365 ;;; Saving functions.
3367 (defun gnus-article-save (save-buffer file &optional num)
3368 "Save the currently selected article."
3369 (unless gnus-save-all-headers
3370 ;; Remove headers according to `gnus-saved-headers'.
3371 (let ((gnus-visible-headers
3372 (or gnus-saved-headers gnus-visible-headers))
3373 (gnus-article-buffer save-buffer))
3375 (set-buffer save-buffer)
3376 (article-hide-headers 1 t))))
3377 (save-window-excursion
3378 (if (not gnus-default-article-saver)
3379 (error "No default saver is defined")
3380 ;; !!! Magic! The saving functions all save
3381 ;; `gnus-save-article-buffer' (or so they think), but we
3382 ;; bind that variable to our save-buffer.
3383 (set-buffer gnus-article-buffer)
3384 (let* ((gnus-save-article-buffer save-buffer)
3387 ((not gnus-prompt-before-saving) 'default)
3388 ((eq gnus-prompt-before-saving 'always) nil)
3390 (gnus-number-of-articles-to-be-saved
3391 (when (eq gnus-prompt-before-saving t)
3393 (set-buffer gnus-article-current-summary)
3394 (funcall gnus-default-article-saver filename)))))
3396 (defun gnus-read-save-file-name (prompt &optional filename
3397 function group headers variable)
3399 (funcall function group headers (symbol-value variable)))
3404 ((eq filename 'default)
3410 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3413 (if (and gnus-number-of-articles-to-be-saved
3414 (> gnus-number-of-articles-to-be-saved 1))
3415 (format "these %d articles"
3416 gnus-number-of-articles-to-be-saved)
3419 ;; Let the split methods have their say.
3421 ;; No split name was found.
3424 (concat prompt " (default "
3425 (file-name-nondirectory default-name) ") ")
3426 (file-name-directory default-name)
3428 ;; A single group name is returned.
3429 ((stringp split-name)
3431 (funcall function split-name headers
3432 (symbol-value variable)))
3434 (concat prompt " (default "
3435 (file-name-nondirectory default-name) ") ")
3436 (file-name-directory default-name)
3438 ;; A single split name was found
3439 ((= 1 (length split-name))
3440 (let* ((name (expand-file-name
3442 gnus-article-save-directory))
3443 (dir (cond ((file-directory-p name)
3444 (file-name-as-directory name))
3445 ((file-exists-p name) name)
3446 (t gnus-article-save-directory))))
3448 (concat prompt " (default " name ") ")
3450 ;; A list of splits was found.
3452 (setq split-name (nreverse split-name))
3454 (let ((file-name-history
3455 (nconc split-name file-name-history)))
3459 (concat prompt " (`M-p' for defaults) ")
3460 gnus-article-save-directory
3462 gnus-article-save-directory)))
3463 (car (push result file-name-history)))))))
3464 ;; Create the directory.
3465 (gnus-make-directory (file-name-directory file))
3466 ;; If we have read a directory, we append the default file name.
3467 (when (file-directory-p file)
3468 (setq file (expand-file-name (file-name-nondirectory
3470 (file-name-as-directory file))))
3471 ;; Possibly translate some characters.
3472 (nnheader-translate-file-chars file))))))
3473 (gnus-make-directory (file-name-directory result))
3474 (set variable result)))
3476 (defun gnus-article-archive-name (group)
3477 "Return the first instance of an \"Archive-name\" in the current buffer."
3478 (let ((case-fold-search t))
3479 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3480 (nnheader-concat gnus-article-save-directory
3481 (match-string 1)))))
3483 (defun gnus-article-nndoc-name (group)
3484 "If GROUP is an nndoc group, return the name of the parent group."
3485 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3486 (gnus-group-get-parameter group 'save-article-group)))
3488 (defun gnus-summary-save-in-rmail (&optional filename)
3489 "Append this article to Rmail file.
3490 Optional argument FILENAME specifies file name.
3491 Directory to save to is default to `gnus-article-save-directory'."
3492 (setq filename (gnus-read-save-file-name
3493 "Save %s in rmail file:" filename
3494 gnus-rmail-save-name gnus-newsgroup-name
3495 gnus-current-headers 'gnus-newsgroup-last-rmail))
3496 (gnus-eval-in-buffer-window gnus-save-article-buffer
3500 (gnus-output-to-rmail filename))))
3503 (defun gnus-summary-save-in-mail (&optional filename)
3504 "Append this article to Unix mail file.
3505 Optional argument FILENAME specifies file name.
3506 Directory to save to is default to `gnus-article-save-directory'."
3507 (setq filename (gnus-read-save-file-name
3508 "Save %s in Unix mail file:" filename
3509 gnus-mail-save-name gnus-newsgroup-name
3510 gnus-current-headers 'gnus-newsgroup-last-mail))
3511 (gnus-eval-in-buffer-window gnus-save-article-buffer
3515 (if (and (file-readable-p filename)
3516 (file-regular-p filename)
3517 (mail-file-babyl-p filename))
3518 (rmail-output-to-rmail-file filename t)
3519 (gnus-output-to-mail filename)))))
3522 (defun gnus-summary-save-in-file (&optional filename overwrite)
3523 "Append this article to file.
3524 Optional argument FILENAME specifies file name.
3525 Directory to save to is default to `gnus-article-save-directory'."
3526 (setq filename (gnus-read-save-file-name
3527 "Save %s in file:" filename
3528 gnus-file-save-name gnus-newsgroup-name
3529 gnus-current-headers 'gnus-newsgroup-last-file))
3530 (gnus-eval-in-buffer-window gnus-save-article-buffer
3534 (when (and overwrite
3535 (file-exists-p filename))
3536 (delete-file filename))
3537 (gnus-output-to-file filename))))
3540 (defun gnus-summary-write-to-file (&optional filename)
3541 "Write this article to a file, overwriting it if the file exists.
3542 Optional argument FILENAME specifies file name.
3543 The directory to save in defaults to `gnus-article-save-directory'."
3544 (gnus-summary-save-in-file nil t))
3546 (defun gnus-summary-save-body-in-file (&optional filename)
3547 "Append this article body to a file.
3548 Optional argument FILENAME specifies file name.
3549 The directory to save in defaults to `gnus-article-save-directory'."
3550 (setq filename (gnus-read-save-file-name
3551 "Save %s body in file:" filename
3552 gnus-file-save-name gnus-newsgroup-name
3553 gnus-current-headers 'gnus-newsgroup-last-file))
3554 (gnus-eval-in-buffer-window gnus-save-article-buffer
3558 (when (article-goto-body)
3559 (narrow-to-region (point) (point-max)))
3560 (gnus-output-to-file filename))))
3563 (defun gnus-summary-save-in-pipe (&optional command)
3564 "Pipe this article to subprocess."
3566 (cond ((and (eq command 'default)
3567 gnus-last-shell-command)
3568 gnus-last-shell-command)
3573 "Shell command on %s: "
3574 (if (and gnus-number-of-articles-to-be-saved
3575 (> gnus-number-of-articles-to-be-saved 1))
3576 (format "these %d articles"
3577 gnus-number-of-articles-to-be-saved)
3579 gnus-last-shell-command))))
3580 (when (string-equal command "")
3581 (if gnus-last-shell-command
3582 (setq command gnus-last-shell-command)
3583 (error "A command is required")))
3584 (gnus-eval-in-buffer-window gnus-article-buffer
3587 (shell-command-on-region (point-min) (point-max) command nil)))
3588 (setq gnus-last-shell-command command))
3590 (defun gnus-summary-pipe-to-muttprint (&optional command)
3591 "Pipe this article to muttprint."
3592 (setq command (read-string
3593 "Print using command: " gnus-summary-muttprint-program
3594 nil gnus-summary-muttprint-program))
3595 (gnus-summary-save-in-pipe command))
3597 ;;; Article file names when saving.
3599 (defun gnus-capitalize-newsgroup (newsgroup)
3600 "Capitalize NEWSGROUP name."
3601 (when (not (zerop (length newsgroup)))
3602 (concat (char-to-string (upcase (aref newsgroup 0)))
3603 (substring newsgroup 1))))
3605 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3606 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3607 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3608 Otherwise, it is like ~/News/news/group/num."
3611 (concat (if (gnus-use-long-file-name 'not-save)
3612 (gnus-capitalize-newsgroup newsgroup)
3613 (gnus-newsgroup-directory-form newsgroup))
3614 "/" (int-to-string (mail-header-number headers)))
3615 gnus-article-save-directory)))
3617 (string-equal (file-name-directory default)
3618 (file-name-directory last-file))
3619 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3621 (or last-file default))))
3623 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3624 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3625 If variable `gnus-use-long-file-name' is non-nil, it is
3626 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3629 (concat (if (gnus-use-long-file-name 'not-save)
3631 (gnus-newsgroup-directory-form newsgroup))
3632 "/" (int-to-string (mail-header-number headers)))
3633 gnus-article-save-directory)))
3635 (string-equal (file-name-directory default)
3636 (file-name-directory last-file))
3637 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3639 (or last-file default))))
3641 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3642 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3643 If variable `gnus-use-long-file-name' is non-nil, it is
3644 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3647 (if (gnus-use-long-file-name 'not-save)
3650 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3652 gnus-article-save-directory)))
3654 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3655 "Generate file name from sender."
3656 (let ((from (mail-header-from headers)))
3658 (if (and from (string-match "\\([^ <]+\\)@" from))
3659 (match-string 1 from)
3661 gnus-article-save-directory)))
3663 (defun article-verify-x-pgp-sig ()
3666 (if (gnus-buffer-live-p gnus-original-article-buffer)
3667 (let ((sig (with-current-buffer gnus-original-article-buffer
3668 (gnus-fetch-field "X-PGP-Sig")))
3672 (mml2015-clear-verify-function))
3674 (insert-buffer-substring gnus-original-article-buffer)
3675 (setq items (split-string sig))
3676 (message-narrow-to-head)
3677 (let ((inhibit-point-motion-hooks t)
3678 (case-fold-search t))
3679 ;; Don't verify multiple headers.
3680 (setq headers (mapconcat (lambda (header)
3682 (mail-fetch-field header)
3684 (split-string (nth 1 items) ",") "")))
3685 (delete-region (point-min) (point-max))
3686 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3687 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3692 (if (looking-at "^-")
3695 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3696 (insert "Version: " (car items) "\n\n")
3697 (insert (mapconcat 'identity (cddr items) "\n"))
3698 (insert "\n-----END PGP SIGNATURE-----\n")
3699 (let ((mm-security-handle (list (format "multipart/signed"))))
3700 (mml2015-clean-buffer)
3701 (let ((coding-system-for-write (or gnus-newsgroup-charset
3703 (funcall (mml2015-clear-verify-function)))
3705 (or (mm-handle-multipart-ctl-parameter
3706 mm-security-handle 'gnus-details)
3707 (mm-handle-multipart-ctl-parameter
3708 mm-security-handle 'gnus-info)))))
3710 (let ((inhibit-read-only t) bface eface)
3712 (message-narrow-to-head)
3713 (goto-char (point-max))
3715 (setq bface (get-text-property (point-at-bol) 'face)
3716 eface (get-text-property (1- (point-at-eol)) 'face))
3717 (message-remove-header "X-Gnus-PGP-Verify")
3718 (if (re-search-forward "^X-PGP-Sig:" nil t)
3720 (goto-char (point-max)))
3721 (narrow-to-region (point) (point))
3722 (insert "X-Gnus-PGP-Verify: " info "\n")
3723 (goto-char (point-min))
3726 (if (not (looking-at "^[ \t]"))
3730 (goto-char (point-min))
3731 (when (looking-at "\\([^:]+\\): *")
3732 (put-text-property (match-beginning 1) (1+ (match-end 1))
3734 (put-text-property (match-end 0) (point-max)
3735 'face eface)))))))))
3737 (defun article-verify-cancel-lock ()
3738 "Verify Cancel-Lock header."
3740 (if (gnus-buffer-live-p gnus-original-article-buffer)
3741 (canlock-verify gnus-original-article-buffer)))
3743 (defun article-monafy ()
3744 "Display body part with mona font."
3746 (unless (if (featurep 'xemacs)
3747 (find-face 'gnus-mona-face)
3748 (facep 'gnus-mona-face))
3749 (require 'navi2ch-mona)
3750 (set-face-font (make-face 'gnus-mona-face) navi2ch-mona-font))
3752 (let ((inhibit-read-only t))
3755 (gnus-make-overlay (point) (point-max))
3756 'face 'gnus-mona-face))))
3763 (setq afunc (car func)
3766 gfunc (intern (format "gnus-%s" func))))
3768 (when (fboundp afunc)
3769 `(lambda (&optional interactive &rest args)
3770 ,(documentation afunc t)
3771 (interactive (list t))
3773 (set-buffer gnus-article-buffer)
3775 (call-interactively ',afunc)
3776 (apply ',afunc args))))))))
3777 '(article-hide-headers
3778 article-verify-x-pgp-sig
3779 article-verify-cancel-lock
3781 article-hide-boring-headers
3782 article-treat-overstrike
3783 article-treat-ansi-sequences
3784 article-fill-long-lines
3785 article-capitalize-sentences
3787 article-remove-leading-whitespace
3788 article-display-x-face
3789 article-display-face
3790 article-de-quoted-unreadable
3791 article-de-base64-unreadable
3794 article-unsplit-urls
3795 article-hide-list-identifiers
3796 article-strip-banner
3799 article-hide-signature
3800 article-strip-headers-in-body
3801 article-remove-trailing-blank-lines
3802 article-strip-leading-blank-lines
3803 article-strip-multiple-blank-lines
3804 article-strip-leading-space
3805 article-strip-trailing-space
3806 article-strip-blank-lines
3807 article-strip-all-blank-lines
3809 article-date-english
3810 article-date-iso8601
3811 article-date-original
3813 article-decode-mime-words
3814 article-decode-charset
3815 article-decode-encoded-words
3819 article-treat-dumbquotes
3820 article-normalize-headers
3821 (article-show-all-headers . gnus-article-show-all-headers)
3822 ;; (article-show-all . gnus-article-show-all)
3826 ;;; Gnus article mode
3829 (put 'gnus-article-mode 'mode-class 'special)
3831 (gnus-define-keys gnus-article-mode-map
3832 " " gnus-article-goto-next-page
3833 "\177" gnus-article-goto-prev-page
3834 [delete] gnus-article-goto-prev-page
3835 [backspace] gnus-article-goto-prev-page
3836 "\C-c^" gnus-article-refer-article
3837 "h" gnus-article-show-summary
3838 "s" gnus-article-show-summary
3839 "\C-c\C-m" gnus-article-mail
3840 "?" gnus-article-describe-briefly
3841 "e" gnus-summary-edit-article
3842 "<" beginning-of-buffer
3844 "\C-c\C-i" gnus-info-find-node
3846 "R" gnus-article-reply-with-original
3847 "F" gnus-article-followup-with-original
3848 "\C-hk" gnus-article-describe-key
3849 "\C-hc" gnus-article-describe-key-briefly
3851 "\C-d" gnus-article-read-summary-keys
3852 "\M-*" gnus-article-read-summary-keys
3853 "\M-#" gnus-article-read-summary-keys
3854 "\M-^" gnus-article-read-summary-keys
3855 "\M-g" gnus-article-read-summary-keys)
3857 ;; Define almost undefined keys to `gnus-article-read-summary-keys'.
3861 (push (char-to-string key) keys)
3863 (dolist (elem (accessible-keymaps gnus-summary-mode-map))
3864 (setq key (car elem))
3865 (when (and (> (length key) 0)
3866 (not (eq 'menu-bar (aref key 0)))
3867 (symbolp (lookup-key gnus-summary-mode-map key)))
3870 (unless (lookup-key gnus-article-mode-map key)
3871 (define-key gnus-article-mode-map key 'gnus-article-read-summary-keys))))
3873 (defun gnus-article-make-menu-bar ()
3874 (unless (boundp 'gnus-article-commands-menu)
3875 (gnus-summary-make-menu-bar))
3876 (gnus-turn-off-edit-menu 'article)
3877 (unless (boundp 'gnus-article-article-menu)
3879 gnus-article-article-menu gnus-article-mode-map ""
3881 ["Scroll forwards" gnus-article-goto-next-page t]
3882 ["Scroll backwards" gnus-article-goto-prev-page t]
3883 ["Show summary" gnus-article-show-summary t]
3884 ["Fetch Message-ID at point" gnus-article-refer-article t]
3885 ["Mail to address at point" gnus-article-mail t]
3886 ["Send a bug report" gnus-bug t]))
3889 gnus-article-treatment-menu gnus-article-mode-map ""
3890 ;; Fixme: this should use :active (and maybe :visible).
3892 ["Hide headers" gnus-article-hide-headers t]
3893 ["Hide signature" gnus-article-hide-signature t]
3894 ["Hide citation" gnus-article-hide-citation t]
3895 ["Treat overstrike" gnus-article-treat-overstrike t]
3896 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
3897 ["Remove carriage return" gnus-article-remove-cr t]
3898 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3899 ["Treat html" gnus-article-wash-html t]
3900 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3901 ["Decode HZ" gnus-article-decode-HZ t]))
3903 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3905 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3907 (gnus-run-hooks 'gnus-article-menu-hook)))
3909 (defun gnus-article-mode ()
3910 "Major mode for displaying an article.
3912 All normal editing commands are switched off.
3914 The following commands are available in addition to all summary mode
3916 \\<gnus-article-mode-map>
3917 \\[gnus-article-next-page]\t Scroll the article one page forwards
3918 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3919 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3920 \\[gnus-article-show-summary]\t Display the summary buffer
3921 \\[gnus-article-mail]\t Send a reply to the address near point
3922 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3923 \\[gnus-info-find-node]\t Go to the Gnus info node"
3925 (gnus-simplify-mode-line)
3926 (setq mode-name "Article")
3927 (setq major-mode 'gnus-article-mode)
3928 (make-local-variable 'minor-mode-alist)
3929 (unless (assq 'gnus-show-mime minor-mode-alist)
3930 (push (list 'gnus-show-mime " MIME") minor-mode-alist))
3931 (use-local-map gnus-article-mode-map)
3932 (when (gnus-visual-p 'article-menu 'menu)
3933 (gnus-article-make-menu-bar)
3934 (when gnus-summary-tool-bar-map
3935 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3936 (gnus-update-format-specifications nil 'article-mode)
3937 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3938 (set (make-local-variable 'gnus-page-broken) nil)
3939 (make-local-variable 'gnus-button-marker-list)
3940 (make-local-variable 'gnus-article-current-summary)
3941 (make-local-variable 'gnus-article-mime-handles)
3942 (make-local-variable 'gnus-article-decoded-p)
3943 (make-local-variable 'gnus-article-mime-handle-alist)
3944 (make-local-variable 'gnus-article-wash-types)
3945 (make-local-variable 'gnus-article-image-alist)
3946 (make-local-variable 'gnus-article-charset)
3947 (make-local-variable 'gnus-article-ignored-charsets)
3948 ;; Prevent recent Emacsen from displaying non-break space as "\ ".
3949 (set (make-local-variable 'show-nonbreak-escape) nil)
3950 (gnus-set-default-directory)
3951 (buffer-disable-undo)
3952 (setq buffer-read-only t
3953 show-trailing-whitespace nil)
3954 (set-syntax-table gnus-article-mode-syntax-table)
3955 (gnus-run-hooks 'gnus-article-mode-hook))
3957 (defun gnus-article-setup-buffer ()
3958 "Initialize the article buffer."
3959 (let* ((name (if gnus-single-article-buffer "*Article*"
3960 (concat "*Article " gnus-newsgroup-name "*")))
3962 (progn (string-match "\\*Article" name)
3963 (concat " *Original Article"
3964 (substring name (match-end 0))))))
3965 (setq gnus-article-buffer name)
3966 (setq gnus-original-article-buffer original)
3967 (setq gnus-article-mime-handle-alist nil)
3968 ;; This might be a variable local to the summary buffer.
3969 (unless gnus-single-article-buffer
3971 (set-buffer gnus-summary-buffer)
3972 (setq gnus-article-buffer name)
3973 (setq gnus-original-article-buffer original)
3974 (gnus-set-global-variables)))
3975 (gnus-article-setup-highlight-words)
3976 ;; Init original article buffer.
3978 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3979 (set-buffer-multibyte t)
3980 (setq major-mode 'gnus-original-article-mode)
3981 (make-local-variable 'gnus-original-article))
3982 (if (and (get-buffer name)
3983 (with-current-buffer name
3984 (if gnus-article-edit-mode
3985 (if (y-or-n-p "Article mode edit in progress; discard? ")
3987 (set-buffer-modified-p nil)
3988 (gnus-kill-buffer name)
3991 (error "Action aborted"))
3995 (set (make-local-variable 'gnus-article-edit-mode) nil)
3996 (buffer-disable-undo)
3997 (setq buffer-read-only t)
3998 ;; This list just keeps growing if we don't reset it.
3999 (setq gnus-button-marker-list nil)
4000 (unless (eq major-mode 'gnus-article-mode)
4001 (gnus-article-mode))
4004 (set-buffer (gnus-get-buffer-create name))
4006 (make-local-variable 'gnus-summary-buffer)
4007 (gnus-summary-set-local-parameters gnus-newsgroup-name)
4008 (current-buffer)))))
4010 ;; Set article window start at LINE, where LINE is the number of lines
4011 ;; from the head of the article.
4012 (defun gnus-article-set-window-start (&optional line)
4014 (gnus-get-buffer-window gnus-article-buffer t)
4016 (set-buffer gnus-article-buffer)
4017 (goto-char (point-min))
4020 (gnus-message 6 "Moved to bookmark")
4021 (search-forward "\n\n" nil t)
4025 ;;; @@ article filters
4028 (defun gnus-article-display-mime-message ()
4029 "Article display method for MIME message."
4030 ;; called from `gnus-original-article-buffer'.
4031 (let (charset all-headers)
4032 (with-current-buffer gnus-summary-buffer
4033 (setq charset default-mime-charset
4034 all-headers gnus-have-all-headers))
4035 (make-local-variable 'default-mime-charset)
4036 (setq default-mime-charset charset)
4037 (with-current-buffer (get-buffer-create gnus-article-buffer)
4038 (make-local-variable 'default-mime-charset)
4039 (setq default-mime-charset charset))
4040 (mime-display-message mime-message-structure
4041 gnus-article-buffer nil gnus-article-mode-map)
4043 (gnus-article-hide-headers nil -1)))
4044 (run-hooks 'gnus-mime-article-prepare-hook))
4046 (defun gnus-article-display-traditional-message ()
4047 "Article display method for traditional message."
4048 (set-buffer gnus-article-buffer)
4049 (let ((inhibit-read-only t))
4051 (insert-buffer-substring gnus-original-article-buffer)))
4053 (defun gnus-article-make-full-mail-header (&optional number charset)
4054 "Create a new mail header structure in a raw article buffer."
4055 (unless (and number charset)
4056 (save-current-buffer
4057 (set-buffer gnus-summary-buffer)
4059 (setq number (or (cdr gnus-article-current) 0)))
4061 (setq charset (or default-mime-charset 'x-ctext)))))
4062 (goto-char (point-min))
4063 (let ((header-end (if (search-forward "\n\n" nil t)
4065 (goto-char (point-max))))
4066 (chars (- (point-max) (point)))
4067 (lines (count-lines (point) (point-max)))
4068 (default-mime-charset charset)
4070 (narrow-to-region (point-min) header-end)
4071 (setq xref (std11-fetch-field "xref"))
4073 (make-full-mail-header
4075 (std11-fetch-field "subject")
4076 (std11-fetch-field "from")
4077 (std11-fetch-field "date")
4078 (std11-fetch-field "message-id")
4079 (std11-fetch-field "references")
4082 (when xref (concat "Xref: " xref)))
4085 (defun gnus-article-prepare (article &optional all-headers header)
4086 "Prepare ARTICLE in article mode buffer.
4087 ARTICLE should either be an article number or a Message-ID.
4088 If ARTICLE is an id, HEADER should be the article headers.
4089 If ALL-HEADERS is non-nil, no headers are hidden."
4091 ;; Make sure we start in a summary buffer.
4092 (unless (eq major-mode 'gnus-summary-mode)
4093 (set-buffer gnus-summary-buffer))
4094 (setq gnus-summary-buffer (current-buffer))
4095 (let* ((gnus-article (if header (mail-header-number header) article))
4096 (summary-buffer (current-buffer))
4097 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
4098 (group gnus-newsgroup-name)
4101 (gnus-article-setup-buffer)
4102 (set-buffer gnus-article-buffer)
4103 ;; Deactivate active regions.
4104 (when (and (boundp 'transient-mark-mode)
4105 transient-mark-mode)
4106 (setq mark-active nil))
4107 (if (not (setq result (let ((inhibit-read-only t))
4108 (gnus-request-article-this-buffer
4110 ;; There is no such article.
4112 (when (and (numberp article)
4113 (not (memq article gnus-newsgroup-sparse)))
4114 (setq gnus-article-current
4115 (cons gnus-newsgroup-name article))
4116 (set-buffer gnus-summary-buffer)
4117 (setq gnus-current-article article)
4118 (if (and (memq article gnus-newsgroup-undownloaded)
4119 (not (gnus-online (gnus-find-method-for-group
4120 gnus-newsgroup-name))))
4122 (gnus-summary-set-agent-mark article)
4123 (message "Message marked for downloading"))
4124 (gnus-summary-mark-article article gnus-canceled-mark)
4125 (unless (memq article gnus-newsgroup-sparse)
4126 (gnus-error 1 "No such article (may have expired or been canceled)")))))
4127 (if (or (eq result 'pseudo)
4128 (eq result 'nneething))
4131 (set-buffer summary-buffer)
4132 (push article gnus-newsgroup-history)
4133 (setq gnus-last-article gnus-current-article
4134 gnus-current-article 0
4135 gnus-current-headers nil
4136 gnus-article-current nil)
4137 (if (eq result 'nneething)
4138 (gnus-configure-windows 'summary)
4139 (gnus-configure-windows 'article))
4140 (gnus-set-global-variables))
4141 (let ((gnus-article-mime-handle-alist-1
4142 gnus-article-mime-handle-alist))
4143 (gnus-set-mode-line 'article)))
4144 ;; The result from the `request' was an actual article -
4145 ;; or at least some text that is now displayed in the
4147 (when (and (numberp article)
4148 (not (eq article gnus-current-article)))
4149 ;; Seems like a new article has been selected.
4150 ;; `gnus-current-article' must be an article number.
4152 (set-buffer summary-buffer)
4153 (push article gnus-newsgroup-history)
4154 (setq gnus-last-article gnus-current-article
4155 gnus-current-article article
4156 gnus-current-headers
4157 (gnus-summary-article-header gnus-current-article)
4158 gnus-article-current
4159 (cons gnus-newsgroup-name gnus-current-article))
4160 (unless (vectorp gnus-current-headers)
4161 (setq gnus-current-headers nil))
4162 (gnus-summary-goto-subject gnus-current-article)
4163 (when (gnus-summary-show-thread)
4164 ;; If the summary buffer really was folded, the
4165 ;; previous goto may not actually have gone to
4166 ;; the right article, but the thread root instead.
4168 (gnus-summary-goto-subject gnus-current-article))
4169 (gnus-run-hooks 'gnus-mark-article-hook)
4170 (gnus-set-mode-line 'summary)
4171 (when (gnus-visual-p 'article-highlight 'highlight)
4172 (gnus-run-hooks 'gnus-visual-mark-article-hook))
4173 ;; Set the global newsgroup variables here.
4174 (gnus-set-global-variables)
4175 (setq gnus-have-all-headers
4176 (or all-headers gnus-show-all-headers))))
4178 (gnus-configure-windows 'article))
4179 (when (or (numberp article)
4181 (gnus-article-prepare-display)
4183 (goto-char (point-min))
4184 (when gnus-break-pages
4185 (gnus-narrow-to-page)))
4186 (let ((gnus-article-mime-handle-alist-1
4187 gnus-article-mime-handle-alist))
4188 (gnus-set-mode-line 'article))
4192 (set-window-point (get-buffer-window (current-buffer)) (point))
4193 (gnus-configure-windows 'article)
4196 (defun gnus-article-prepare-mime-display (&optional number)
4197 (goto-char (point-min))
4198 (when (re-search-forward "^[^\t ]+:" nil t)
4199 (goto-char (match-beginning 0)))
4200 (let ((entity (if (eq 1 (point-min))
4201 (get-text-property 1 'mime-view-entity)
4202 (get-text-property (point) 'mime-view-entity)))
4203 last-entity child-entity next type)
4204 (setq child-entity (mime-entity-children entity))
4206 (setq last-entity (nth (1- (length child-entity))
4208 (setq last-entity entity))
4210 (narrow-to-region (point)
4211 (if (search-forward "\n\n" nil t)
4214 (gnus-article-save-original-date)
4215 (gnus-treat-article 'head)
4216 (put-text-property (point-min) (point-max) 'article-treated-header t)
4217 (goto-char (point-max)))
4218 (while (and (not (eobp)) entity)
4219 (setq next (set-marker
4221 (next-single-property-change (point) 'mime-view-entity
4223 (let ((types (mime-entity-content-type entity)))
4224 (while (eq 'multipart (mime-content-type-primary-type types))
4225 (setq entity (car (mime-entity-children entity))
4226 types (mime-entity-content-type entity)))
4228 (setq type (format "%s/%s"
4229 (mime-content-type-primary-type types)
4230 (mime-content-type-subtype types)))))
4231 (if (string-equal type "message/rfc822")
4234 (let ((children (mime-entity-children entity))
4237 (setq last-children (nth (1- (length children)) children))
4240 (not (eq last-children
4241 (get-text-property next 'mime-view-entity)))
4243 (next-single-property-change next
4245 nil (point-max)))))))
4246 (setq next (next-single-property-change next 'mime-view-entity
4249 (narrow-to-region (point) next)
4250 (gnus-article-prepare-mime-display)
4251 (goto-char (point-max)))
4252 (setq entity (get-text-property (point) 'mime-view-entity)))
4254 (narrow-to-region (point) next)
4255 ;; Kludge. We have to count true number, but for now,
4256 ;; part number is here only to achieve `last'.
4257 (gnus-treat-article nil 1
4258 (if (eq entity last-entity)
4261 (goto-char (point-max)))
4262 (setq entity (get-text-property next 'mime-view-entity))))))
4265 (defun gnus-article-prepare-display ()
4266 "Make the current buffer look like a nice article."
4267 (let ((gnus-article-buffer (current-buffer))
4269 (inhibit-read-only t))
4270 (unless (eq major-mode 'gnus-article-mode)
4271 (gnus-article-mode))
4272 (setq buffer-read-only nil
4273 gnus-button-marker-list nil
4274 gnus-article-wash-types nil
4275 gnus-article-image-alist nil)
4278 (static-if (featurep 'xemacs)
4279 (map-extents (lambda (extent maparg) (delete-extent extent)))
4280 (let ((lists (overlay-lists)))
4281 (dolist (overlay (nconc (car lists) (cdr lists)))
4282 (delete-overlay overlay)))))
4283 (gnus-run-hooks 'gnus-tmp-internal-hook))
4284 (let ((show-mime (unless (member gnus-newsgroup-name '("nndraft:delayed"
4287 (inhibit-read-only t))
4288 (set-buffer gnus-original-article-buffer)
4290 (setq mime-message-structure gnus-current-headers)
4291 (mime-buffer-entity-set-buffer-internal mime-message-structure
4292 gnus-original-article-buffer)
4293 (mime-entity-set-representation-type-internal mime-message-structure
4294 'mime-buffer-entity)
4295 (luna-send mime-message-structure 'initialize-instance
4296 mime-message-structure)
4298 (let (mime-display-header-hook mime-display-text/plain-hook)
4299 (funcall gnus-article-display-method-for-mime))
4300 (funcall gnus-article-display-method-for-traditional))
4301 ;; Call the treatment functions.
4305 (gnus-article-prepare-mime-display)
4306 (narrow-to-region (goto-char (point-min))
4307 (if (search-forward "\n\n" nil t)
4310 (gnus-article-save-original-date)
4311 (gnus-treat-article 'head)
4312 (put-text-property (point-min) (point-max) 'article-treated-header t)
4313 (goto-char (point-max))
4315 (narrow-to-region (point) (point-max))
4316 (gnus-treat-article nil))
4317 (put-text-property (point-min) (point-max) 'read-only nil)))
4318 (gnus-run-hooks 'gnus-article-prepare-hook))
4320 (defun gnus-article-decode-article-as-default-mime-charset ()
4321 "Decode an article as `default-mime-charset'. It won't work if the
4322 value of the variable `gnus-show-mime' is non-nil."
4323 (unless (or gnus-show-mime
4324 (member gnus-newsgroup-name '("nndraft:delayed"
4326 (set (make-local-variable 'default-mime-charset)
4327 (with-current-buffer gnus-summary-buffer
4328 default-mime-charset))
4329 (decode-mime-charset-region (point-min) (point-max)
4330 default-mime-charset)))
4333 ;;; Gnus MIME viewing functions
4336 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4337 "Format of the MIME buttons.
4339 Valid specifiers include:
4341 %T MIME type, along with additional info
4342 %n The `name' parameter
4343 %d The description, if any
4344 %l The length of the encoded part
4345 %p The part identifier number
4346 %e Dots if the part isn't displayed
4348 General format specifiers can also be used. See Info node
4349 `(gnus)Formatting Variables'.")
4351 (defvar gnus-mime-button-line-format-alist
4352 '((?t gnus-tmp-type ?s)
4353 (?T gnus-tmp-type-long ?s)
4354 (?n gnus-tmp-name ?s)
4355 (?d gnus-tmp-description ?s)
4357 (?l gnus-tmp-length ?d)
4358 (?e gnus-tmp-dots ?s)))
4360 (defvar gnus-mime-button-commands
4361 '((gnus-article-press-button "\r" "Toggle Display")
4362 (gnus-mime-view-part "v" "View Interactively...")
4363 (gnus-mime-view-part-as-type "t" "View As Type...")
4364 (gnus-mime-view-part-as-charset "C" "View As charset...")
4365 (gnus-mime-save-part "o" "Save...")
4366 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4367 (gnus-mime-delete-part "d" "Delete part")
4368 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4369 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4370 (gnus-mime-view-part-internally "E" "View Internally")
4371 (gnus-mime-view-part-externally "e" "View Externally")
4372 (gnus-mime-print-part "p" "Print")
4373 (gnus-mime-pipe-part "|" "Pipe To Command...")
4374 (gnus-mime-action-on-part "." "Take action on the part...")))
4376 (defun gnus-article-mime-part-status ()
4377 (with-current-buffer gnus-article-buffer
4378 (let ((entity (get-text-property (point-min) 'mime-view-entity))
4381 (setq children (mime-entity-children entity))
4382 (setq children (length children)))
4385 (format " (%d parts)" children))
4388 (defvar gnus-mime-button-map
4389 (let ((map (make-sparse-keymap)))
4390 (define-key map gnus-mouse-2 'gnus-article-push-button)
4391 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4392 (dolist (c gnus-mime-button-commands)
4393 (define-key map (cadr c) (car c)))
4397 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4399 ,@(mapcar (lambda (c)
4400 (vector (caddr c) (car c) :enable t))
4401 gnus-mime-button-commands)))
4403 (defun gnus-mime-button-menu (event prefix)
4404 "Construct a context-sensitive menu of MIME commands."
4405 (interactive "e\nP")
4406 (save-window-excursion
4407 (let ((pos (event-start event)))
4408 (select-window (posn-window pos))
4409 (goto-char (posn-point pos))
4410 (gnus-article-check-buffer)
4411 (popup-menu gnus-mime-button-menu nil prefix))))
4413 (defun gnus-mime-view-all-parts (&optional handles)
4414 "View all the MIME parts."
4416 (with-current-buffer gnus-article-buffer
4417 (let ((handles (or handles gnus-article-mime-handles))
4418 (mail-parse-charset gnus-newsgroup-charset)
4419 (mail-parse-ignored-charsets
4420 (with-current-buffer gnus-summary-buffer
4421 gnus-newsgroup-ignored-charsets)))
4423 (mm-remove-parts handles)
4424 (goto-char (point-min))
4425 (or (search-forward "\n\n") (goto-char (point-max)))
4426 (let ((inhibit-read-only t))
4427 (delete-region (point) (point-max))
4428 (mm-display-parts handles))))))
4431 (defsubst gnus-article-edit-part (handles)
4432 "Edit an article in order to delete a mime part.
4433 This function is exclusively used by `gnus-mime-save-part-and-strip'
4434 and `gnus-mime-delete-part', and not provided at run-time normally."
4435 (gnus-article-edit-article
4438 (let ((mail-parse-charset (or gnus-article-charset
4439 ',gnus-newsgroup-charset))
4440 (mail-parse-ignored-charsets
4441 (or gnus-article-ignored-charsets
4442 ',gnus-newsgroup-ignored-charsets))
4443 (mbl mml-buffer-list))
4444 (setq mml-buffer-list nil)
4445 (insert-buffer gnus-original-article-buffer)
4446 (mime-to-mml ',handles)
4447 (setq gnus-article-mime-handles nil)
4448 (let ((mbl1 mml-buffer-list))
4449 (setq mml-buffer-list mbl)
4450 (set (make-local-variable 'mml-buffer-list) mbl1))
4451 (gnus-make-local-hook 'kill-buffer-hook)
4452 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4453 `(lambda (no-highlight)
4454 (let ((mail-parse-charset (or gnus-article-charset
4455 ',gnus-newsgroup-charset))
4456 (message-options message-options)
4457 (message-options-set-recipient)
4458 (mail-parse-ignored-charsets
4459 (or gnus-article-ignored-charsets
4460 ',gnus-newsgroup-ignored-charsets)))
4462 (mml-destroy-buffers)
4463 (remove-hook 'kill-buffer-hook
4464 'mml-destroy-buffers t)
4465 (kill-local-variable 'mml-buffer-list))
4466 (gnus-summary-edit-article-done
4467 ,(or (mail-header-references gnus-current-headers) "")
4468 ,(gnus-group-read-only-p)
4469 ,gnus-summary-buffer no-highlight)))
4470 (gnus-article-edit-done)
4471 (gnus-summary-expand-window)
4472 (gnus-summary-show-article)))
4474 (defun gnus-mime-save-part-and-strip ()
4475 "Save the MIME part under point then replace it with an external body."
4477 (gnus-article-check-buffer)
4478 (when (gnus-group-read-only-p)
4479 (error "The current group does not support deleting of parts"))
4480 (when (mm-complicated-handles gnus-article-mime-handles)
4482 The current article has a complicated MIME structure, giving up..."))
4483 (when (gnus-yes-or-no-p "\
4484 Deleting parts may malfunction or destroy the article; continue? ")
4485 (let* ((data (get-text-property (point) 'gnus-data))
4487 (handles gnus-article-mime-handles))
4488 (setq file (and data (mm-save-part data)))
4490 (with-current-buffer (mm-handle-buffer data)
4492 (insert "Content-Type: " (mm-handle-media-type data))
4493 (mml-insert-parameter-string (cdr (mm-handle-type data))
4496 (insert "Content-ID: " (message-make-message-id) "\n")
4497 (insert "Content-Transfer-Encoding: binary\n")
4500 (cdr (mm-make-handle nil
4501 `("message/external-body"
4502 (access-type . "LOCAL-FILE")
4504 (set-buffer gnus-summary-buffer)
4505 (gnus-article-edit-part handles)))))
4507 (defun gnus-mime-delete-part ()
4508 "Delete the MIME part under point.
4509 Replace it with some information about the removed part."
4511 (gnus-article-check-buffer)
4512 (when (gnus-group-read-only-p)
4513 (error "The current group does not support deleting of parts"))
4514 (when (mm-complicated-handles gnus-article-mime-handles)
4516 The current article has a complicated MIME structure, giving up..."))
4517 (when (gnus-yes-or-no-p "\
4518 Deleting parts may malfunction or destroy the article; continue? ")
4519 (let* ((data (get-text-property (point) 'gnus-data))
4520 (handles gnus-article-mime-handles)
4524 (mail-decode-encoded-word-string (or (mm-handle-description data)
4527 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4529 (type (mm-handle-media-type data)))
4531 (error "No MIME part under point"))
4532 (with-current-buffer (mm-handle-buffer data)
4533 (let ((bsize (format "%s" (buffer-size))))
4538 "| The following attachment has been deleted:\n"
4540 "| Type: " type "\n"
4541 "| Filename: " filename "\n"
4542 "| Size (encoded): " bsize " Byte\n"
4543 "| Description: " description "\n"
4546 (cdr (mm-make-handle
4547 nil `("text/plain") nil nil
4549 (format "Deleted attachment (%s bytes)" bsize))))))
4550 (set-buffer gnus-summary-buffer)
4551 (gnus-article-edit-part handles))))
4553 (defun gnus-mime-save-part ()
4554 "Save the MIME part under point."
4556 (gnus-article-check-buffer)
4557 (let ((data (get-text-property (point) 'gnus-data)))
4559 (mm-save-part data))))
4561 (defun gnus-mime-pipe-part ()
4562 "Pipe the MIME part under point to a process."
4564 (gnus-article-check-buffer)
4565 (let ((data (get-text-property (point) 'gnus-data)))
4567 (mm-pipe-part data))))
4569 (defun gnus-mime-view-part ()
4570 "Interactively choose a viewing method for the MIME part under point."
4572 (gnus-article-check-buffer)
4573 (let ((data (get-text-property (point) 'gnus-data)))
4575 (setq gnus-article-mime-handles
4577 gnus-article-mime-handles (setq data (copy-sequence data))))
4578 (mm-interactively-view-part data))))
4580 (defun gnus-mime-view-part-as-type-internal ()
4581 (gnus-article-check-buffer)
4582 (let* ((name (mail-content-type-get
4583 (mm-handle-type (get-text-property (point) 'gnus-data))
4585 (def-type (and name (mm-default-file-encoding name))))
4586 (and def-type (cons def-type 0))))
4588 (defun gnus-mime-view-part-as-type (&optional mime-type)
4589 "Choose a MIME media type, and view the part as such."
4592 (setq mime-type (completing-read
4593 "View as MIME type: "
4594 (mapcar #'list (mailcap-mime-types))
4596 (gnus-mime-view-part-as-type-internal))))
4597 (gnus-article-check-buffer)
4598 (let ((handle (get-text-property (point) 'gnus-data)))
4601 (mm-make-handle (mm-handle-buffer handle)
4602 (cons mime-type (cdr (mm-handle-type handle)))
4603 (mm-handle-encoding handle)
4604 (mm-handle-undisplayer handle)
4605 (mm-handle-disposition handle)
4606 (mm-handle-description handle)
4608 (mm-handle-id handle)))
4609 (setq gnus-article-mime-handles
4610 (mm-merge-handles gnus-article-mime-handles handle))
4611 (gnus-mm-display-part handle))))
4613 (defun gnus-mime-copy-part (&optional handle arg)
4614 "Put the MIME part under point into a new buffer.
4615 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4617 (interactive (list nil current-prefix-arg))
4618 (gnus-article-check-buffer)
4620 (setq handle (get-text-property (point) 'gnus-data)))
4622 (let ((filename (or (mail-content-type-get (mm-handle-disposition handle)
4624 (mail-content-type-get (mm-handle-disposition handle)
4626 contents dont-decode charset coding-system)
4627 (mm-with-unibyte-buffer
4628 (mm-insert-part handle)
4629 (setq contents (or (condition-case nil
4630 (mm-decompress-buffer filename nil 'sig)
4632 (setq dont-decode t)
4635 (setq filename (cond (filename (file-name-nondirectory filename))
4636 (dont-decode "*raw data*")
4641 (unless (setq charset (mail-content-type-get
4642 (mm-handle-type handle) 'charset))
4643 (unless (setq coding-system (mm-with-unibyte-buffer
4645 (mm-find-buffer-file-coding-system)))
4646 (setq charset gnus-newsgroup-charset))))
4648 (setq charset (or (cdr (assq arg
4649 gnus-summary-show-article-charset-alist))
4650 (mm-read-coding-system "Charset: ")))))
4651 (switch-to-buffer (generate-new-buffer filename))
4652 (if (or coding-system
4654 (setq coding-system (mm-charset-to-coding-system charset))
4655 (not (eq charset 'ascii))))
4657 (mm-enable-multibyte)
4658 (insert (mm-decode-coding-string contents coding-system))
4659 (setq buffer-file-coding-system
4660 (if (boundp 'last-coding-system-used)
4661 (symbol-value 'last-coding-system-used)
4663 (mm-disable-multibyte)
4665 (setq buffer-file-coding-system mm-binary-coding-system))
4666 ;; We do it this way to make `normal-mode' set the appropriate mode.
4669 (setq buffer-file-name (expand-file-name filename))
4671 (setq buffer-file-name nil))
4672 (goto-char (point-min)))))
4674 (defun gnus-mime-print-part (&optional handle filename)
4675 "Print the MIME part under point."
4676 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4677 (gnus-article-check-buffer)
4678 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4679 (contents (and handle (mm-get-part handle)))
4680 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4681 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4686 (mm-save-part-to-file handle file)
4687 (call-process shell-file-name nil
4688 (generate-new-buffer " *mm*")
4690 shell-command-switch
4692 printer file (mm-handle-type handle))))
4696 (gnus-print-buffer))
4697 (ps-despool filename)))))
4699 (defun gnus-mime-inline-part (&optional handle arg)
4700 "Insert the MIME part under point into the current buffer.
4701 Compressed files like .gz and .bz2 are decompressed."
4702 (interactive (list nil current-prefix-arg))
4703 (gnus-article-check-buffer)
4705 (setq handle (get-text-property (point) 'gnus-data)))
4708 (inhibit-read-only t)
4709 contents charset coding-system)
4710 (if (and (not arg) (mm-handle-undisplayer handle))
4711 (mm-remove-part handle)
4712 (mm-with-unibyte-buffer
4713 (mm-insert-part handle)
4715 (or (mm-decompress-buffer
4716 (or (mail-content-type-get (mm-handle-disposition handle)
4718 (mail-content-type-get (mm-handle-disposition handle)
4724 (unless (setq charset (mail-content-type-get
4725 (mm-handle-type handle) 'charset))
4726 (unless (setq coding-system
4727 (mm-with-unibyte-buffer
4729 (mm-find-buffer-file-coding-system)))
4730 (setq charset gnus-newsgroup-charset))))
4732 (if (mm-handle-undisplayer handle)
4733 (mm-remove-part handle))
4736 gnus-summary-show-article-charset-alist))
4737 (mm-read-coding-system "Charset: "))))
4739 (if (mm-handle-undisplayer handle)
4740 (mm-remove-part handle))))
4744 (if (or coding-system
4747 (mm-charset-to-coding-system charset))
4748 (not (eq charset 'ascii))))
4749 (mm-decode-coding-string contents coding-system)
4750 (mm-string-to-multibyte contents)))
4753 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4754 "Insert the MIME part under point into the current buffer using the
4756 (interactive (list nil current-prefix-arg))
4757 (gnus-article-check-buffer)
4758 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4761 (inhibit-read-only t))
4763 (if (mm-handle-undisplayer handle)
4764 (mm-remove-part handle))
4765 (let ((gnus-newsgroup-charset
4767 gnus-summary-show-article-charset-alist))
4768 (mm-read-coding-system "Charset: ")))
4769 (gnus-newsgroup-ignored-charsets 'gnus-all))
4770 (gnus-article-press-button)))))
4772 (defun gnus-mime-view-part-externally (&optional handle)
4773 "View the MIME part under point with an external viewer."
4775 (gnus-article-check-buffer)
4776 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4777 (mm-user-display-methods nil)
4778 (mm-inlined-types nil)
4779 (mail-parse-charset gnus-newsgroup-charset)
4780 (mail-parse-ignored-charsets
4781 (with-current-buffer gnus-summary-buffer
4782 gnus-newsgroup-ignored-charsets)))
4784 (if (mm-handle-undisplayer handle)
4785 (mm-remove-part handle)
4786 (mm-display-part handle)))))
4788 (defun gnus-mime-view-part-internally (&optional handle)
4789 "View the MIME part under point with an internal viewer.
4790 If no internal viewer is available, use an external viewer."
4792 (gnus-article-check-buffer)
4793 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4794 (mm-inlined-types '(".*"))
4795 (mm-inline-large-images t)
4796 (mail-parse-charset gnus-newsgroup-charset)
4797 (mail-parse-ignored-charsets
4798 (with-current-buffer gnus-summary-buffer
4799 gnus-newsgroup-ignored-charsets))
4800 (inhibit-read-only t))
4802 (if (mm-handle-undisplayer handle)
4803 (mm-remove-part handle)
4804 (mm-display-part handle)))))
4806 (defun gnus-mime-action-on-part (&optional action)
4807 "Do something with the MIME attachment at \(point\)."
4809 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4810 (gnus-article-check-buffer)
4811 (let ((action-pair (assoc action gnus-mime-action-alist)))
4813 (funcall (cdr action-pair)))))
4815 (defun gnus-article-part-wrapper (n function)
4816 (with-current-buffer gnus-article-buffer
4817 (when (> n (length gnus-article-mime-handle-alist))
4818 (error "No such part"))
4819 (gnus-article-goto-part n)
4820 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4821 (funcall function handle))))
4823 (defun gnus-article-pipe-part (n)
4824 "Pipe MIME part N, which is the numerical prefix."
4826 (gnus-article-part-wrapper n 'mm-pipe-part))
4828 (defun gnus-article-save-part (n)
4829 "Save MIME part N, which is the numerical prefix."
4831 (gnus-article-part-wrapper n 'mm-save-part))
4833 (defun gnus-article-interactively-view-part (n)
4834 "View MIME part N interactively, which is the numerical prefix."
4836 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4838 (defun gnus-article-copy-part (n)
4839 "Copy MIME part N, which is the numerical prefix."
4841 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4843 (defun gnus-article-view-part-as-charset (n)
4844 "View MIME part N using a specified charset.
4845 N is the numerical prefix."
4847 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4849 (defun gnus-article-view-part-externally (n)
4850 "View MIME part N externally, which is the numerical prefix."
4852 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4854 (defun gnus-article-inline-part (n)
4855 "Inline MIME part N, which is the numerical prefix."
4857 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4859 (defun gnus-article-mime-match-handle-first (condition)
4862 (dolist (ihandle gnus-article-mime-handle-alist)
4864 ((functionp condition)
4865 (funcall condition (cdr ihandle)))
4866 ((eq condition 'undisplayed)
4867 (not (or (mm-handle-undisplayer (cdr ihandle))
4868 (equal (mm-handle-media-type (cdr ihandle))
4869 "multipart/alternative"))))
4870 ((eq condition 'undisplayed-alternative)
4871 (not (mm-handle-undisplayer (cdr ihandle))))
4873 (gnus-article-goto-part (car ihandle))
4874 (or (not n) (< (car ihandle) n)))
4875 (setq n (car ihandle))))
4879 (defun gnus-article-view-part (&optional n)
4880 "View MIME part N, which is the numerical prefix."
4882 (with-current-buffer gnus-article-buffer
4883 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4884 gnus-article-mime-match-handle-function)))
4885 (when (> n (length gnus-article-mime-handle-alist))
4886 (error "No such part"))
4887 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4888 (when (gnus-article-goto-part n)
4889 (if (equal (car handle) "multipart/alternative")
4890 (gnus-article-press-button)
4891 (when (eq (gnus-mm-display-part handle) 'internal)
4892 (gnus-set-window-start)))))))
4894 (defsubst gnus-article-mime-total-parts ()
4895 (if (bufferp (car gnus-article-mime-handles))
4897 (1- (length gnus-article-mime-handles))))
4899 (defun gnus-mm-display-part (handle)
4900 "Display HANDLE and fix MIME button."
4901 (let ((id (get-text-property (point) 'gnus-part))
4903 (inhibit-read-only t))
4906 (let ((window (selected-window))
4907 (mail-parse-charset gnus-newsgroup-charset)
4908 (mail-parse-ignored-charsets
4909 (if (gnus-buffer-live-p gnus-summary-buffer)
4910 (with-current-buffer gnus-summary-buffer
4911 gnus-newsgroup-ignored-charsets)
4915 (let ((win (gnus-get-buffer-window (current-buffer) t))
4918 (select-window win))
4921 (if (mm-handle-displayed-p handle)
4922 ;; This will remove the part.
4923 (mm-display-part handle)
4925 (narrow-to-region (point)
4926 (if (eobp) (point) (1+ (point))))
4927 (mm-display-part handle)
4928 ;; We narrow to the part itself and
4929 ;; then call the treatment functions.
4930 (goto-char (point-min))
4932 (narrow-to-region (point) (point-max))
4935 (gnus-article-mime-total-parts)
4936 (mm-handle-media-type handle)))))
4937 (if (window-live-p window)
4938 (select-window window)))))
4941 (gnus-insert-mime-button
4942 handle id (list (mm-handle-displayed-p handle)))
4943 (goto-char point))))
4945 (defun gnus-article-goto-part (n)
4946 "Go to MIME part N."
4947 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4949 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4950 (let ((gnus-tmp-name
4951 (or (mail-content-type-get (mm-handle-type handle) 'name)
4952 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4953 (mail-content-type-get (mm-handle-type handle) 'url)
4955 (gnus-tmp-type (mm-handle-media-type handle))
4956 (gnus-tmp-description
4957 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4960 (if (if displayed (car displayed)
4961 (mm-handle-displayed-p handle))
4963 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4965 gnus-tmp-type-long b e)
4966 (when (string-match ".*/" gnus-tmp-name)
4967 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4968 (setq gnus-tmp-type-long (concat gnus-tmp-type
4969 (and (not (equal gnus-tmp-name ""))
4970 (concat "; " gnus-tmp-name))))
4971 (unless (equal gnus-tmp-description "")
4972 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4977 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4978 `(keymap ,gnus-mime-button-map
4979 gnus-callback gnus-mm-display-part
4980 gnus-part ,gnus-tmp-id
4981 article-type annotation
4984 ;; Exclude a newline.
4987 (widget-convert-button
4990 :action 'gnus-widget-press-button
4991 :button-keymap gnus-mime-button-map
4993 (lambda (widget/window &optional overlay pos)
4994 ;; Needed to properly clear the message due to a bug in
4995 ;; wid-edit (XEmacs only).
4996 (if (boundp 'help-echo-owns-message)
4997 (setq help-echo-owns-message t))
4999 "%S: %s the MIME part; %S: more options"
5000 (aref gnus-mouse-2 0)
5001 ;; XEmacs will get a single widget arg; Emacs 21 will get
5002 ;; window, overlay, position.
5003 (if (mm-handle-displayed-p
5005 (with-current-buffer (gnus-overlay-buffer overlay)
5006 (widget-get (widget-at (gnus-overlay-start overlay))
5008 (widget-get widget/window :mime-handle)))
5010 (aref gnus-down-mouse-3 0))))))
5012 (defun gnus-widget-press-button (elems el)
5013 (goto-char (widget-get elems :from))
5014 (gnus-article-press-button))
5016 (defvar gnus-displaying-mime nil)
5018 (defun gnus-display-mime (&optional ihandles)
5019 "Display the MIME parts."
5021 (save-selected-window
5022 (let ((window (get-buffer-window gnus-article-buffer))
5025 (select-window window)
5026 ;; We have to do this since selecting the window
5027 ;; may change the point. So we set the window point.
5028 (set-window-point window point)))
5029 (let ((handles ihandles)
5030 (inhibit-read-only t)
5031 handle name type b e display)
5033 ((setq handles (mm-dissect-buffer nil gnus-article-loose-mime))
5034 (when gnus-article-emulate-mime
5035 (mm-uu-dissect-text-parts handles)))
5036 (gnus-article-emulate-mime
5037 (setq handles (mm-uu-dissect))))
5038 (when (and (not ihandles)
5039 (not gnus-displaying-mime))
5040 ;; Top-level call; we clean up.
5041 (when gnus-article-mime-handles
5042 (mm-destroy-parts gnus-article-mime-handles)
5043 (setq gnus-article-mime-handle-alist nil));; A trick.
5044 (setq gnus-article-mime-handles handles)
5045 ;; We allow users to glean info from the handles.
5046 (when gnus-article-mime-part-function
5047 (gnus-mime-part-function handles)))
5049 (or (not (stringp (car handles)))
5052 (when (and (not ihandles)
5053 (not gnus-displaying-mime))
5054 ;; Clean up for mime parts.
5056 (delete-region (point) (point-max)))
5057 (let ((gnus-displaying-mime t))
5058 (gnus-mime-display-part handles)))
5061 (narrow-to-region (point) (point-max))
5062 (gnus-treat-article nil 1 1)
5065 ;; Highlight the headers.
5069 (narrow-to-region (point-min) (point))
5070 (gnus-article-save-original-date)
5071 (gnus-treat-article 'head))))))))
5073 (defcustom gnus-mime-display-multipart-as-mixed nil
5074 "Display \"multipart\" parts as \"multipart/mixed\".
5076 If t, it overrides nil values of
5077 `gnus-mime-display-multipart-alternative-as-mixed' and
5078 `gnus-mime-display-multipart-related-as-mixed'."
5079 :group 'gnus-article-mime
5082 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
5083 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
5085 :group 'gnus-article-mime
5088 (defcustom gnus-mime-display-multipart-related-as-mixed nil
5089 "Display \"multipart/related\" parts as \"multipart/mixed\".
5091 If displaying \"text/html\" is discouraged \(see
5092 `mm-discouraged-alternatives'\) images or other material inside a
5093 \"multipart/related\" part might be overlooked when this variable is nil."
5095 :group 'gnus-article-mime
5098 (defun gnus-mime-display-part (handle)
5101 ((not (stringp (car handle)))
5102 (gnus-mime-display-single handle))
5103 ;; User-defined multipart
5104 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
5105 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
5107 ;; multipart/alternative
5108 ((and (equal (car handle) "multipart/alternative")
5109 (not (or gnus-mime-display-multipart-as-mixed
5110 gnus-mime-display-multipart-alternative-as-mixed)))
5111 (let ((id (1+ (length gnus-article-mime-handle-alist))))
5112 (push (cons id handle) gnus-article-mime-handle-alist)
5113 (gnus-mime-display-alternative (cdr handle) nil nil id)))
5114 ;; multipart/related
5115 ((and (equal (car handle) "multipart/related")
5116 (not (or gnus-mime-display-multipart-as-mixed
5117 gnus-mime-display-multipart-related-as-mixed)))
5118 ;;;!!!We should find the start part, but we just default
5119 ;;;!!!to the first part.
5120 ;;(gnus-mime-display-part (cadr handle))
5121 ;;;!!! Most multipart/related is an HTML message plus images.
5122 ;;;!!! Unfortunately we are unable to let W3 display those
5123 ;;;!!! included images, so we just display it as a mixed multipart.
5124 ;;(gnus-mime-display-mixed (cdr handle))
5125 ;;;!!! No, w3 can display everything just fine.
5126 (gnus-mime-display-part (cadr handle)))
5127 ((equal (car handle) "multipart/signed")
5128 (gnus-add-wash-type 'signed)
5129 (gnus-mime-display-security handle))
5130 ((equal (car handle) "multipart/encrypted")
5131 (gnus-add-wash-type 'encrypted)
5132 (gnus-mime-display-security handle))
5133 ;; Other multiparts are handled like multipart/mixed.
5135 (gnus-mime-display-mixed (cdr handle)))))
5137 (defun gnus-mime-part-function (handles)
5138 (if (stringp (car handles))
5139 (mapcar 'gnus-mime-part-function (cdr handles))
5140 (funcall gnus-article-mime-part-function handles)))
5142 (defun gnus-mime-display-mixed (handles)
5143 (mapcar 'gnus-mime-display-part handles))
5145 (defun gnus-mime-display-single (handle)
5146 (let ((type (mm-handle-media-type handle))
5147 (ignored gnus-ignored-mime-types)
5154 (when (string-match (pop ignored) type)
5155 (throw 'ignored nil)))
5156 (if (and (setq not-attachment
5157 (and (not (mm-inline-override-p handle))
5158 (or (not (mm-handle-disposition handle))
5159 (equal (car (mm-handle-disposition handle))
5161 (mm-attachment-override-p handle))))
5162 (mm-automatic-display-p handle)
5164 (mm-inlinable-p handle)
5165 (mm-inlined-p handle))
5166 (mm-automatic-external-display-p type)))
5168 (when (equal (mm-handle-media-supertype handle) "text")
5170 (let ((id (1+ (length gnus-article-mime-handle-alist)))
5172 (push (cons id handle) gnus-article-mime-handle-alist)
5173 (when (or (not display)
5174 (not (gnus-unbuttonized-mime-type-p type)))
5175 (gnus-insert-mime-button
5176 handle id (list (or display (and not-attachment text))))
5177 (gnus-article-insert-newline)
5178 ;; Remember modify the number of forward lines.
5186 (let ((mail-parse-charset gnus-newsgroup-charset)
5187 (mail-parse-ignored-charsets
5188 (save-excursion (condition-case ()
5189 (set-buffer gnus-summary-buffer)
5191 gnus-newsgroup-ignored-charsets)))
5192 (mm-display-part handle t))
5193 (goto-char (point-max)))
5194 ((and text not-attachment)
5198 (gnus-article-insert-newline)
5199 (mm-display-inline handle)
5200 (goto-char (point-max))))
5204 (narrow-to-region beg (point))
5207 (gnus-article-mime-total-parts)
5208 (mm-handle-media-type handle)))))))))
5210 (defun gnus-unbuttonized-mime-type-p (type)
5211 "Say whether TYPE is to be unbuttonized."
5212 (unless gnus-inhibit-mime-unbuttonizing
5214 (let ((types gnus-unbuttonized-mime-types))
5216 (when (string-match (pop types) type)
5217 (throw 'found t)))))
5219 (let ((types gnus-buttonized-mime-types))
5221 (when (string-match (pop types) type)
5222 (throw 'found t)))))))))
5224 (defun gnus-article-insert-newline ()
5225 "Insert a newline, but mark it as undeletable."
5226 (gnus-put-text-property
5227 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
5229 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
5230 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
5233 handle (inhibit-read-only t) from props begend not-pref)
5234 (save-window-excursion
5237 (narrow-to-region (car ibegend)
5240 (goto-char (car ibegend))
5243 (delete-region (point-min) (point-max))
5244 (mm-remove-parts handles))
5245 (setq begend (list (point-marker)))
5247 (unless (setq not-pref (cadr (member preferred ihandles)))
5248 (setq not-pref (car ihandles)))
5251 (not (gnus-unbuttonized-mime-type-p
5252 "multipart/alternative")))
5253 (gnus-add-text-properties
5256 (insert (format "%d. " id))
5260 (unless ,(not ibegend)
5261 (setq gnus-article-mime-handle-alist
5262 ',gnus-article-mime-handle-alist))
5263 (gnus-mime-display-alternative
5264 ',ihandles ',not-pref ',begend ,id))
5265 keymap ,gnus-mime-button-map
5266 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5267 face ,gnus-article-button-face
5270 (widget-convert-button 'link from (point)
5271 :action 'gnus-widget-press-button
5272 :button-keymap gnus-widget-button-keymap)
5274 (while (setq handle (pop handles))
5275 (gnus-add-text-properties
5278 (insert (format "(%c) %-18s"
5279 (if (equal handle preferred) ?* ? )
5280 (mm-handle-media-type handle)))
5284 (unless ,(not ibegend)
5285 (setq gnus-article-mime-handle-alist
5286 ',gnus-article-mime-handle-alist))
5287 (gnus-mime-display-alternative
5288 ',ihandles ',handle ',begend ,id))
5289 keymap ,gnus-mime-button-map
5290 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5291 face ,gnus-article-button-face
5294 (widget-convert-button 'link from (point)
5295 :action 'gnus-widget-press-button
5296 :button-keymap gnus-widget-button-keymap)
5300 (if (stringp (car preferred))
5301 (gnus-display-mime preferred)
5302 (let ((mail-parse-charset gnus-newsgroup-charset)
5303 (mail-parse-ignored-charsets
5304 (with-current-buffer gnus-summary-buffer
5305 gnus-newsgroup-ignored-charsets)))
5306 (mm-display-part preferred)
5310 (narrow-to-region (car begend) (point-max))
5312 nil (length gnus-article-mime-handle-alist)
5313 (gnus-article-mime-total-parts)
5314 (mm-handle-media-type handle))))))
5315 (goto-char (point-max))
5316 (setcdr begend (point-marker)))))
5318 (goto-char point))))
5320 (defconst gnus-article-wash-status-strings
5321 (let ((alist '((cite "c" "Possible hidden citation text"
5322 " " "All citation text visible")
5323 (headers "h" "Hidden headers"
5324 " " "All headers visible.")
5325 (pgp "p" "Encrypted or signed message status hidden"
5326 " " "No hidden encryption nor digital signature status")
5327 (signature "s" "Signature has been hidden"
5328 " " "Signature is visible")
5329 (overstrike "o" "Overstrike (^H) characters applied"
5330 " " "No overstrike characters applied")
5331 (gnus-show-mime "m" "Mime processing is activated"
5332 " " "Mime processing is not activated")
5333 (emphasis "e" "/*_Emphasis_*/ characters applied"
5334 " " "No /*_emphasis_*/ characters applied")))
5336 (dolist (entry alist result)
5337 (let ((key (nth 0 entry))
5338 (on (copy-sequence (nth 1 entry)))
5339 (on-help (nth 2 entry))
5340 (off (copy-sequence (nth 3 entry)))
5341 (off-help (nth 4 entry)))
5342 (put-text-property 0 1 'help-echo on-help on)
5343 (put-text-property 0 1 'help-echo off-help off)
5344 (push (list key on off) result))))
5345 "Alist of strings describing wash status in the mode line.
5346 Each entry has the form (KEY ON OF), where the KEY is a symbol
5347 representing the particular washing function, ON is the string to use
5348 in the article mode line when the washing function is active, and OFF
5349 is the string to use when it is inactive.")
5351 (defun gnus-article-wash-status-entry (key value)
5352 (let ((entry (assoc key gnus-article-wash-status-strings)))
5353 (if value (nth 1 entry) (nth 2 entry))))
5355 (defun gnus-article-wash-status ()
5356 "Return a string which display status of article washing."
5357 (with-current-buffer gnus-article-buffer
5358 (let ((cite (memq 'cite gnus-article-wash-types))
5359 (headers (memq 'headers gnus-article-wash-types))
5360 (boring (memq 'boring-headers gnus-article-wash-types))
5361 (pgp (memq 'pgp gnus-article-wash-types))
5362 (pem (memq 'pem gnus-article-wash-types))
5363 (signed (memq 'signed gnus-article-wash-types))
5364 (encrypted (memq 'encrypted gnus-article-wash-types))
5365 (signature (memq 'signature gnus-article-wash-types))
5366 (overstrike (memq 'overstrike gnus-article-wash-types))
5367 (emphasis (memq 'emphasis gnus-article-wash-types)))
5369 (gnus-article-wash-status-entry 'cite cite)
5370 (gnus-article-wash-status-entry 'headers (or headers boring))
5371 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5372 (gnus-article-wash-status-entry 'signature signature)
5373 (gnus-article-wash-status-entry 'overstrike overstrike)
5374 (gnus-article-wash-status-entry 'gnus-show-mime gnus-show-mime)
5375 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5377 (defun gnus-add-wash-type (type)
5378 "Add a washing of TYPE to the current status."
5379 (add-to-list 'gnus-article-wash-types type))
5381 (defun gnus-delete-wash-type (type)
5382 "Add a washing of TYPE to the current status."
5383 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5385 (defun gnus-add-image (category image)
5386 "Add IMAGE of CATEGORY to the list of displayed images."
5387 (let ((entry (assq category gnus-article-image-alist)))
5389 (setq entry (list category))
5390 (push entry gnus-article-image-alist))
5391 (nconc entry (list image))))
5393 (defun gnus-delete-images (category)
5394 "Delete all images in CATEGORY."
5395 (let ((entry (assq category gnus-article-image-alist)))
5396 (dolist (image (cdr entry))
5397 (gnus-remove-image image category))
5398 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5399 (gnus-delete-wash-type category)))
5401 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5403 (defun gnus-article-maybe-hide-headers ()
5404 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5405 Provided for backwards compatibility."
5406 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5407 (not (with-current-buffer gnus-summary-buffer
5408 gnus-have-all-headers)))
5409 (not gnus-inhibit-hiding))
5410 (gnus-article-hide-headers)))
5414 (defun gnus-output-to-file (file-name)
5415 "Append the current article to a file named FILE-NAME."
5416 (let ((artbuf (current-buffer)))
5418 (insert-buffer-substring artbuf)
5419 ;; Append newline at end of the buffer as separator, and then
5421 (goto-char (point-max))
5423 (let ((file-name-coding-system nnmail-pathname-coding-system))
5424 (write-region-as-binary (point-min) (point-max) file-name 'append))
5427 (defun gnus-narrow-to-page (&optional arg)
5428 "Narrow the article buffer to a page.
5429 If given a numerical ARG, move forward ARG pages."
5431 (setq arg (if arg (prefix-numeric-value arg) 0))
5433 (set-buffer gnus-article-buffer)
5434 (goto-char (point-min))
5436 ;; Remove any old next/prev buttons.
5437 (when (gnus-visual-p 'page-marker)
5438 (let ((inhibit-read-only t))
5439 (gnus-remove-text-with-property 'gnus-prev)
5440 (gnus-remove-text-with-property 'gnus-next)))
5443 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5445 (re-search-forward page-delimiter nil 'move arg)))
5446 (goto-char (match-end 0))
5448 (goto-char (point-min))
5449 (setq gnus-page-broken
5450 (and (re-search-forward page-delimiter nil t) t))))
5451 (when gnus-page-broken
5454 (if (re-search-forward page-delimiter nil 'move)
5457 (when (and (gnus-visual-p 'page-marker)
5458 (> (point-min) (save-restriction (widen) (point-min))))
5460 (goto-char (point-min))
5461 (gnus-insert-prev-page-button)))
5462 (when (and (gnus-visual-p 'page-marker)
5463 (< (point-max) (save-restriction (widen) (point-max))))
5465 (goto-char (point-max))
5466 (gnus-insert-next-page-button))))))
5468 ;; Article mode commands
5470 (defun gnus-article-goto-next-page ()
5471 "Show the next page of the article."
5473 (when (gnus-article-next-page)
5474 (goto-char (point-min))
5475 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5478 (defun gnus-article-goto-prev-page ()
5479 "Show the previous page of the article."
5482 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5483 (gnus-article-prev-page nil)))
5485 ;; This is cleaner but currently breaks `gnus-pick-mode':
5487 ;; (defun gnus-article-goto-next-page ()
5488 ;; "Show the next page of the article."
5490 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5491 ;; (gnus-summary-next-page)))
5493 ;; (defun gnus-article-goto-prev-page ()
5494 ;; "Show the next page of the article."
5496 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5497 ;; (gnus-summary-prev-page)))
5499 (defun gnus-article-next-page (&optional lines)
5500 "Show the next page of the current article.
5501 If end of article, return non-nil. Otherwise return nil.
5502 Argument LINES specifies lines to be scrolled up."
5504 (move-to-window-line -1)
5507 (and (pos-visible-in-window-p) ;Not continuation line.
5508 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5509 ;; Nothing in this page.
5510 (if (or (not gnus-page-broken)
5515 (eobp)))) ;Real end-of-buffer?
5517 (when gnus-article-over-scroll
5518 (gnus-article-next-page-1 lines))
5520 (gnus-narrow-to-page 1) ;Go to next page.
5522 ;; More in this page.
5523 (gnus-article-next-page-1 lines)
5526 (defun gnus-article-next-page-1 (lines)
5527 (let ((scroll-in-place nil))
5531 ;; Long lines may cause an end-of-buffer error.
5532 (goto-char (point-max)))))
5533 (move-to-window-line 0))
5535 (defun gnus-article-prev-page (&optional lines)
5536 "Show previous page of current article.
5537 Argument LINES specifies lines to be scrolled down."
5539 (move-to-window-line 0)
5540 (if (and gnus-page-broken
5542 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5544 (gnus-narrow-to-page -1) ;Go to previous page.
5545 (goto-char (point-max))
5547 (let ((scroll-in-place nil))
5551 (beginning-of-buffer
5552 (goto-char (point-min))))
5553 (move-to-window-line 0)))))
5555 (defun gnus-article-only-boring-p ()
5556 "Decide whether there is only boring text remaining in the article.
5557 Something \"interesting\" is a word of at least two letters that does
5558 not have a face in `gnus-article-boring-faces'."
5559 (when (and gnus-article-skip-boring
5560 (boundp 'gnus-article-boring-faces)
5561 (symbol-value 'gnus-article-boring-faces))
5564 (while (re-search-forward "\\b\\w\\w" nil t)
5566 (when (not (gnus-intersection
5567 (gnus-faces-at (point))
5568 (symbol-value 'gnus-article-boring-faces)))
5569 (throw 'only-boring nil)))
5570 (throw 'only-boring t)))))
5572 (defun gnus-article-refer-article ()
5573 "Read article specified by message-id around point."
5576 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
5577 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
5578 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
5579 (let ((msg-id (concat "<" (match-string 0) ">")))
5580 (set-buffer gnus-summary-buffer)
5581 (gnus-summary-refer-article msg-id))
5582 (error "No references around point"))))
5584 (defun gnus-article-show-summary ()
5585 "Reconfigure windows to show summary buffer."
5587 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5588 (error "There is no summary buffer for this article buffer")
5589 (gnus-article-set-globals)
5590 (gnus-configure-windows 'article)
5591 (gnus-summary-goto-subject gnus-current-article)
5592 (gnus-summary-position-point)))
5594 (defun gnus-article-describe-briefly ()
5595 "Describe article mode commands briefly."
5597 (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")))
5599 (defun gnus-article-summary-command ()
5600 "Execute the last keystroke in the summary buffer."
5602 (let ((obuf (current-buffer))
5603 (owin (current-window-configuration))
5605 (switch-to-buffer gnus-article-current-summary 'norecord)
5606 (setq func (lookup-key (current-local-map) (this-command-keys)))
5607 (call-interactively func)
5609 (set-window-configuration owin)
5610 (set-window-point (get-buffer-window (current-buffer)) (point))))
5612 (defun gnus-article-summary-command-nosave ()
5613 "Execute the last keystroke in the summary buffer."
5616 (pop-to-buffer gnus-article-current-summary 'norecord)
5617 (setq func (lookup-key (current-local-map) (this-command-keys)))
5618 (call-interactively func)))
5620 (defun gnus-article-check-buffer ()
5621 "Beep if not in an article buffer."
5622 (unless (eq (get-buffer gnus-article-buffer) (current-buffer))
5623 (error "Command invoked outside of a Gnus article buffer")))
5625 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5626 "Read a summary buffer key sequence and execute it from the article buffer."
5628 (gnus-article-check-buffer)
5630 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5631 "Zc" "ZC" "ZE" "ZJ" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5632 "=" "^" "\M-^" "|"))
5638 '("n" "Gn" "p" "Gp"))
5641 (set-buffer gnus-article-current-summary)
5642 (let (gnus-pick-mode)
5643 (push (or key last-command-event) unread-command-events)
5644 (setq keys (static-if (featurep 'xemacs)
5645 (events-to-keys (read-key-sequence nil))
5646 (read-key-sequence nil)))))
5649 (if (or (member keys nosaves)
5650 (member keys nosave-but-article)
5651 (member keys nosave-in-article))
5653 (save-window-excursion
5654 (pop-to-buffer gnus-article-current-summary 'norecord)
5655 ;; We disable the pick minor mode commands.
5656 (let (gnus-pick-mode)
5657 (setq func (lookup-key (current-local-map) keys))))
5661 (unless (member keys nosave-in-article)
5662 (set-buffer gnus-article-current-summary))
5663 (call-interactively func)
5664 (setq new-sum-point (point)))
5665 (when (member keys nosave-but-article)
5666 (pop-to-buffer gnus-article-buffer 'norecord)))
5667 ;; These commands should restore window configuration.
5668 (let ((obuf (current-buffer))
5669 (owin (current-window-configuration))
5671 win func in-buffer selected new-sum-start new-sum-hscroll)
5672 (cond (not-restore-window
5673 (pop-to-buffer gnus-article-current-summary 'norecord))
5674 ((setq win (get-buffer-window gnus-article-current-summary))
5675 (select-window win))
5677 (switch-to-buffer gnus-article-current-summary 'norecord)))
5678 (setq in-buffer (current-buffer))
5679 ;; We disable the pick minor mode commands.
5680 (if (and (setq func (let (gnus-pick-mode)
5681 (lookup-key (current-local-map) keys)))
5684 (call-interactively func)
5685 (when (eq win (selected-window))
5686 (setq new-sum-point (point)
5687 new-sum-start (window-start win)
5688 new-sum-hscroll (window-hscroll win)))
5689 (when (eq in-buffer (current-buffer))
5690 (setq selected (gnus-summary-select-article))
5692 (unless not-restore-window
5693 (set-window-configuration owin))
5694 (when (eq selected 'old)
5696 (set-window-start (get-buffer-window (current-buffer))
5698 (set-window-point (get-buffer-window (current-buffer))
5700 (when (and (not not-restore-window)
5702 (set-window-point win new-sum-point)
5703 (set-window-start win new-sum-start)
5704 (set-window-hscroll win new-sum-hscroll))))
5705 (set-window-configuration owin)
5708 (defun gnus-article-describe-key (key)
5709 "Display documentation of the function invoked by KEY. KEY is a string."
5710 (interactive "kDescribe key: ")
5711 (gnus-article-check-buffer)
5712 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5714 (set-buffer gnus-article-current-summary)
5715 (let (gnus-pick-mode)
5716 (if (featurep 'xemacs)
5718 (push (elt key 0) unread-command-events)
5719 (setq key (events-to-keys
5720 (read-key-sequence "Describe key: "))))
5721 (setq unread-command-events
5723 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5725 (setq key (read-key-sequence "Describe key: "))))
5727 (describe-key key)))
5729 (defun gnus-article-describe-key-briefly (key &optional insert)
5730 "Display documentation of the function invoked by KEY. KEY is a string."
5731 (interactive "kDescribe key: \nP")
5732 (gnus-article-check-buffer)
5733 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5735 (set-buffer gnus-article-current-summary)
5736 (let (gnus-pick-mode)
5737 (if (featurep 'xemacs)
5739 (push (elt key 0) unread-command-events)
5740 (setq key (events-to-keys
5741 (read-key-sequence "Describe key: "))))
5742 (setq unread-command-events
5744 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5746 (setq key (read-key-sequence "Describe key: "))))
5747 (describe-key-briefly key insert))
5748 (describe-key-briefly key insert)))
5750 (defun gnus-article-reply-with-original (&optional wide)
5751 "Start composing a reply mail to the current message.
5752 The text in the region will be yanked. If the region isn't active,
5753 the entire article will be yanked."
5755 (let ((article (cdr gnus-article-current))
5757 (if (not (gnus-region-active-p))
5758 (with-current-buffer gnus-summary-buffer
5759 (gnus-summary-reply (list (list article)) wide))
5760 (setq contents (buffer-substring (point) (mark t)))
5761 ;; Deactivate active regions.
5762 (when (and (boundp 'transient-mark-mode)
5763 transient-mark-mode)
5764 (setq mark-active nil))
5765 (with-current-buffer gnus-summary-buffer
5767 (list (list article contents)) wide)))))
5769 (defun gnus-article-followup-with-original ()
5770 "Compose a followup to the current article.
5771 The text in the region will be yanked. If the region isn't active,
5772 the entire article will be yanked."
5774 (let ((article (cdr gnus-article-current))
5776 (if (not (gnus-region-active-p))
5777 (with-current-buffer gnus-summary-buffer
5778 (gnus-summary-followup (list (list article))))
5779 (setq contents (buffer-substring (point) (mark t)))
5780 ;; Deactivate active regions.
5781 (when (and (boundp 'transient-mark-mode)
5782 transient-mark-mode)
5783 (setq mark-active nil))
5784 (with-current-buffer gnus-summary-buffer
5785 (gnus-summary-followup
5786 (list (list article contents)))))))
5788 (defun gnus-article-hide (&optional arg force)
5789 "Hide all the gruft in the current article.
5790 This means that signatures, cited text and (some) headers will be
5792 If given a prefix, show the hidden text instead."
5793 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5794 (gnus-article-hide-headers arg)
5795 (gnus-article-hide-list-identifiers arg)
5796 (gnus-article-hide-citation-maybe arg force)
5797 (gnus-article-hide-signature arg))
5799 (defun gnus-article-maybe-highlight ()
5800 "Do some article highlighting if article highlighting is requested."
5801 (when (gnus-visual-p 'article-highlight 'highlight)
5802 (gnus-article-highlight-some)))
5804 (defun gnus-check-group-server ()
5805 ;; Make sure the connection to the server is alive.
5806 (unless (gnus-server-opened
5807 (gnus-find-method-for-group gnus-newsgroup-name))
5808 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5809 (gnus-request-group gnus-newsgroup-name t)))
5812 (autoload 'nneething-get-file-name "nneething"))
5814 (defun gnus-request-article-this-buffer (article group)
5815 "Get an article and insert it into this buffer."
5816 (let (do-update-line sparse-header)
5820 (gnus-kill-all-overlays)
5821 (setq group (or group gnus-newsgroup-name))
5823 ;; Using `gnus-request-article' directly will insert the article into
5824 ;; `nntp-server-buffer' - so we'll save some time by not having to
5825 ;; copy it from the server buffer into the article buffer.
5827 ;; We only request an article by message-id when we do not have the
5828 ;; headers for it, so we'll have to get those.
5829 (when (stringp article)
5830 (gnus-read-header article))
5832 ;; If the article number is negative, that means that this article
5833 ;; doesn't belong in this newsgroup (possibly), so we find its
5834 ;; message-id and request it by id instead of number.
5835 (when (and (numberp article)
5837 (get-buffer gnus-summary-buffer)
5838 (gnus-buffer-exists-p gnus-summary-buffer))
5840 (set-buffer gnus-summary-buffer)
5841 (let ((header (gnus-summary-article-header article)))
5844 ((memq article gnus-newsgroup-sparse)
5845 ;; This is a sparse gap article.
5846 (setq do-update-line article)
5847 (setq article (mail-header-id header))
5848 (setq sparse-header (gnus-read-header article))
5849 (setq gnus-newsgroup-sparse
5850 (delq article gnus-newsgroup-sparse)))
5852 ;; It's a real article.
5853 (setq article (mail-header-id header)))
5855 ;; It is an extracted pseudo-article.
5856 (setq article 'pseudo)
5857 (gnus-request-pseudo-article header))))
5859 (let ((method (gnus-find-method-for-group
5860 gnus-newsgroup-name)))
5861 (when (and (eq (car method) 'nneething)
5863 (let ((dir (nneething-get-file-name
5864 (mail-header-id header))))
5865 (when (and (stringp dir)
5866 (file-directory-p dir))
5867 (setq article 'nneething)
5868 (gnus-group-enter-directory dir))))))))
5871 ;; Refuse to select canceled articles.
5872 ((and (numberp article)
5874 (get-buffer gnus-summary-buffer)
5875 (gnus-buffer-exists-p gnus-summary-buffer)
5876 (eq (cdr (with-current-buffer gnus-summary-buffer
5877 (assq article gnus-newsgroup-reads)))
5878 gnus-canceled-mark))
5880 ;; We first check `gnus-original-article-buffer'.
5881 ((and (get-buffer gnus-original-article-buffer)
5883 (with-current-buffer gnus-original-article-buffer
5884 (and (equal (car gnus-original-article) group)
5885 (eq (cdr gnus-original-article) article))))
5886 (insert-buffer-substring gnus-original-article-buffer)
5888 ;; Check the backlog.
5889 ((and gnus-keep-backlog
5890 (gnus-backlog-request-article group article (current-buffer)))
5892 ;; Check asynchronous pre-fetch.
5893 ((gnus-async-request-fetched-article group article (current-buffer))
5894 (gnus-async-prefetch-next group article gnus-summary-buffer)
5895 (when (and (numberp article) gnus-keep-backlog)
5896 (gnus-backlog-enter-article group article (current-buffer)))
5899 ((and gnus-use-cache
5901 (gnus-cache-request-article article group))
5903 ;; Check the agent cache.
5904 ((gnus-agent-request-article article group)
5906 ;; Get the article and put into the article buffer.
5907 ((or (stringp article)
5909 (let ((gnus-override-method gnus-override-method)
5910 (methods (and (stringp article)
5911 gnus-refer-article-method))
5912 (backend (car (gnus-find-method-for-group
5913 gnus-newsgroup-name)))
5915 (inhibit-read-only t))
5916 (if (or (not (listp methods))
5917 (and (symbolp (car methods))
5918 (assq (car methods) nnoo-definition-alist)))
5919 (setq methods (list methods)))
5920 (when (and (null gnus-override-method)
5922 (setq gnus-override-method (pop methods)))
5924 (when (eq gnus-override-method 'current)
5925 (setq gnus-override-method
5926 (with-current-buffer gnus-summary-buffer
5927 gnus-current-select-method)))
5929 (gnus-kill-all-overlays)
5930 (let ((gnus-newsgroup-name group))
5931 (gnus-check-group-server))
5933 ((gnus-request-article article group (current-buffer))
5934 (when (numberp article)
5935 (gnus-async-prefetch-next group article
5936 gnus-summary-buffer)
5937 (when gnus-keep-backlog
5938 (gnus-backlog-enter-article
5939 group article (current-buffer))))
5940 (setq result 'article))
5942 (setq gnus-override-method (pop methods)))
5943 ((not (string-match "^400 "
5944 (nnheader-get-report backend)))
5945 ;; If we get 400 server disconnect, reconnect and
5946 ;; retry; otherwise, assume the article has expired.
5947 (setq result 'done))))
5948 (and (eq result 'article) 'article)))
5952 ;; Associate this article with the current summary buffer.
5953 (setq gnus-article-current-summary gnus-summary-buffer)
5955 ;; Take the article from the original article buffer
5956 ;; and place it in the buffer it's supposed to be in.
5957 (when (and (get-buffer gnus-article-buffer)
5958 (equal (buffer-name (current-buffer))
5959 (buffer-name (get-buffer gnus-article-buffer))))
5961 (if (get-buffer gnus-original-article-buffer)
5962 (set-buffer gnus-original-article-buffer)
5963 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5964 (buffer-disable-undo)
5965 (setq major-mode 'gnus-original-article-mode)
5966 (setq buffer-read-only t))
5967 (let ((inhibit-read-only t))
5969 (insert-buffer-substring gnus-article-buffer))
5970 (setq gnus-original-article (cons group article)))
5973 (run-hooks 'gnus-article-decode-hook)
5974 ;; Mark article as decoded or not.
5975 (setq gnus-article-decoded-p gnus-article-decode-hook))
5977 ;; Update sparse articles.
5978 (when (and do-update-line
5979 (or (numberp article)
5981 (let ((buf (current-buffer)))
5982 (set-buffer gnus-summary-buffer)
5983 (gnus-summary-update-article do-update-line sparse-header)
5984 (gnus-summary-goto-subject do-update-line nil t)
5985 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5987 (set-buffer buf))))))
5993 (defcustom gnus-article-edit-mode-hook nil
5994 "Hook run in article edit mode buffers."
5995 :group 'gnus-article-various
5998 (defcustom gnus-article-edit-article-setup-function
5999 'gnus-article-mime-edit-article-setup
6000 "Function called to setup an editing article buffer."
6001 :group 'gnus-article-various
6004 (defvar gnus-article-edit-done-function nil)
6006 (defvar gnus-article-edit-mode-map nil)
6008 ;; Should we be using derived.el for this?
6009 (unless gnus-article-edit-mode-map
6010 (setq gnus-article-edit-mode-map (make-keymap))
6011 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
6013 (gnus-define-keys gnus-article-edit-mode-map
6014 "\C-c?" describe-mode
6015 "\C-c\C-c" gnus-article-edit-done
6016 "\C-c\C-k" gnus-article-edit-exit
6017 "\C-c\C-f\C-t" message-goto-to
6018 "\C-c\C-f\C-o" message-goto-from
6019 "\C-c\C-f\C-b" message-goto-bcc
6020 ;;"\C-c\C-f\C-w" message-goto-fcc
6021 "\C-c\C-f\C-c" message-goto-cc
6022 "\C-c\C-f\C-s" message-goto-subject
6023 "\C-c\C-f\C-r" message-goto-reply-to
6024 "\C-c\C-f\C-n" message-goto-newsgroups
6025 "\C-c\C-f\C-d" message-goto-distribution
6026 "\C-c\C-f\C-f" message-goto-followup-to
6027 "\C-c\C-f\C-m" message-goto-mail-followup-to
6028 "\C-c\C-f\C-k" message-goto-keywords
6029 "\C-c\C-f\C-u" message-goto-summary
6030 "\C-c\C-f\C-i" message-insert-or-toggle-importance
6031 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
6032 "\C-c\C-b" message-goto-body
6033 "\C-c\C-i" message-goto-signature
6035 "\C-c\C-t" message-insert-to
6036 "\C-c\C-n" message-insert-newsgroups
6037 "\C-c\C-o" message-sort-headers
6038 "\C-c\C-e" message-elide-region
6039 "\C-c\C-v" message-delete-not-region
6040 "\C-c\C-z" message-kill-to-signature
6041 "\M-\r" message-newline-and-reformat
6042 "\C-c\C-a" mml-attach-file
6043 "\C-a" message-beginning-of-line
6045 "\M-;" comment-region)
6047 (gnus-define-keys (gnus-article-edit-wash-map
6048 "\C-c\C-w" gnus-article-edit-mode-map)
6049 "f" gnus-article-edit-full-stops))
6052 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
6054 ["Fetch To" message-insert-to t]
6055 ["Fetch Newsgroups" message-insert-newsgroups t]
6057 ["To" message-goto-to t]
6058 ["From" message-goto-from t]
6059 ["Subject" message-goto-subject t]
6060 ["Cc" message-goto-cc t]
6061 ["Reply-To" message-goto-reply-to t]
6062 ["Summary" message-goto-summary t]
6063 ["Keywords" message-goto-keywords t]
6064 ["Newsgroups" message-goto-newsgroups t]
6065 ["Followup-To" message-goto-followup-to t]
6066 ["Mail-Followup-To" message-goto-mail-followup-to t]
6067 ["Distribution" message-goto-distribution t]
6068 ["Body" message-goto-body t]
6069 ["Signature" message-goto-signature t]))
6071 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
6072 "Major mode for editing articles.
6073 This is an extended text-mode.
6075 \\{gnus-article-edit-mode-map}"
6076 (make-local-variable 'gnus-article-edit-done-function)
6077 (make-local-variable 'gnus-prev-winconf)
6078 (set (make-local-variable 'font-lock-defaults)
6079 '(message-font-lock-keywords t))
6080 (set (make-local-variable 'mail-header-separator) "")
6081 (set (make-local-variable 'gnus-article-edit-mode) t)
6082 (easy-menu-add message-mode-field-menu message-mode-map)
6083 (setq buffer-read-only nil)
6084 (buffer-enable-undo)
6087 (defun gnus-article-edit (&optional force)
6088 "Edit the current article.
6089 This will have permanent effect only in mail groups.
6090 If FORCE is non-nil, allow editing of articles even in read-only
6093 (when (and (not force)
6094 (gnus-group-read-only-p))
6095 (error "The current newsgroup does not support article editing"))
6096 (gnus-article-date-original)
6097 (gnus-article-edit-article
6099 `(lambda (no-highlight)
6101 (gnus-summary-edit-article-done
6102 ,(or (mail-header-references gnus-current-headers) "")
6103 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
6105 (defun gnus-article-edit-article (start-func exit-func)
6106 "Start editing the contents of the current article buffer."
6107 (let ((winconf (current-window-configuration)))
6108 (set-buffer gnus-article-buffer)
6109 (let ((message-auto-save-directory
6110 ;; Don't associate the article buffer with a draft file.
6112 (gnus-article-edit-mode))
6113 (funcall start-func)
6114 (set-buffer-modified-p nil)
6115 (gnus-configure-windows 'edit-article)
6116 (setq gnus-article-edit-done-function exit-func)
6117 (setq gnus-prev-winconf winconf)
6118 (when gnus-article-edit-article-setup-function
6119 (funcall gnus-article-edit-article-setup-function))
6120 (gnus-message 6 "C-c C-c to end edits; C-c C-k to exit")))
6122 (defun gnus-article-edit-done (&optional arg)
6123 "Update the article edits and exit."
6125 (let ((func gnus-article-edit-done-function)
6126 (buf (current-buffer))
6127 (start (window-start))
6129 (winconf gnus-prev-winconf))
6130 (remove-hook 'gnus-article-mode-hook
6131 'gnus-article-mime-edit-article-unwind)
6132 (widen) ;; Widen it in case that users narrowed the buffer.
6135 ;; The cache and backlog have to be flushed somewhat.
6136 (when gnus-keep-backlog
6137 (gnus-backlog-remove-article
6138 (car gnus-article-current) (cdr gnus-article-current)))
6139 ;; Flush original article as well.
6141 (when (get-buffer gnus-original-article-buffer)
6142 (set-buffer gnus-original-article-buffer)
6143 (setq gnus-original-article nil)))
6144 (when gnus-use-cache
6145 (gnus-cache-update-article
6146 (car gnus-article-current) (cdr gnus-article-current)))
6147 ;; We remove all text props from the article buffer.
6148 (kill-all-local-variables)
6149 (set-text-properties (point-min) (point-max) nil)
6151 (set-window-configuration winconf)
6153 (set-window-start (get-buffer-window buf) start)
6154 (set-window-point (get-buffer-window buf) (point)))
6155 (gnus-summary-show-article))
6157 (defun gnus-article-edit-exit ()
6158 "Exit the article editing without updating."
6160 (when (or (not (buffer-modified-p))
6161 (yes-or-no-p "Article modified; kill anyway? "))
6162 (let ((curbuf (current-buffer))
6164 (window-start (window-start)))
6166 (if (gnus-buffer-live-p gnus-original-article-buffer)
6167 (insert-buffer-substring gnus-original-article-buffer))
6168 (let ((winconf gnus-prev-winconf))
6169 (kill-all-local-variables)
6171 (set-window-configuration winconf)
6172 ;; Tippy-toe some to make sure that point remains where it was.
6173 (save-current-buffer
6175 (set-window-start (get-buffer-window (current-buffer)) window-start)
6177 (gnus-summary-show-article)))
6179 (defun gnus-article-edit-full-stops ()
6180 "Interactively repair spacing at end of sentences."
6183 (goto-char (point-min))
6184 (search-forward-regexp "^$" nil t)
6185 (let ((case-fold-search nil))
6186 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
6189 ;;; Article editing with MIME-Edit
6192 (defcustom gnus-article-mime-edit-article-setup-hook nil
6193 "Hook run after setting up a MIME editing article buffer."
6194 :group 'gnus-article-various
6197 (defun gnus-article-mime-edit-article-unwind ()
6198 "Unwind `gnus-article-buffer' if article editing was given up."
6199 (remove-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6200 (when (featurep 'font-lock)
6201 (setq font-lock-defaults nil)
6202 (font-lock-mode -1))
6203 (when mime-edit-mode-flag
6204 (mime-edit-exit 'nomime 'no-error)
6207 (defun gnus-article-mime-edit-article-setup ()
6208 "Convert current buffer to MIME-Edit buffer and turn on MIME-Edit mode
6209 after replacing with the original article."
6210 (setq gnus-show-mime t)
6211 (setq gnus-article-edit-done-function
6212 `(lambda (&rest args)
6213 (when mime-edit-mode-flag
6214 (let (mime-edit-insert-user-agent-field)
6217 (goto-char (point-min))
6218 (let (case-fold-search)
6219 (when (re-search-forward
6220 (format "^%s$" (regexp-quote mail-header-separator))
6222 (replace-match "")))
6223 (apply ,gnus-article-edit-done-function args)
6226 (buffer-substring-no-properties (point-min) (point-max))
6227 (set-buffer (get-buffer-create gnus-original-article-buffer))
6229 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6230 (set-buffer gnus-article-buffer)
6231 (gnus-article-prepare-display)))
6232 (substitute-key-definition 'gnus-article-edit-done
6233 'gnus-article-mime-edit-done
6234 gnus-article-edit-mode-map)
6235 (substitute-key-definition 'gnus-article-edit-exit
6236 'gnus-article-mime-edit-exit
6237 gnus-article-edit-mode-map)
6239 (insert-buffer-substring gnus-original-article-buffer)
6240 (unless (member (with-current-buffer gnus-summary-buffer
6241 gnus-newsgroup-name)
6242 '("nndraft:delayed" "nndraft:drafts"))
6243 (let ((ofn (symbol-function 'mime-edit-decode-single-part-in-buffer)))
6244 (fset 'mime-edit-decode-single-part-in-buffer
6245 (lambda (&rest args)
6246 (if (let ((content-type (car args)))
6247 (and (eq 'message (mime-content-type-primary-type
6249 (eq 'rfc822 (mime-content-type-subtype
6251 (setcar (cdr args) 'not-decode-text))
6255 (fset 'mime-edit-decode-single-part-in-buffer ofn))))
6256 (when (featurep 'font-lock)
6257 (set (make-local-variable 'font-lock-defaults)
6258 '(message-font-lock-keywords t))
6259 (font-lock-set-defaults)
6260 (turn-on-font-lock))
6261 (set-buffer-modified-p nil)
6262 (delete-other-windows)
6263 (add-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6264 (gnus-run-hooks 'gnus-article-mime-edit-article-setup-hook))
6266 (defun gnus-article-mime-edit-done (&optional arg)
6267 "Update the article MIME edits and exit."
6269 (when (featurep 'font-lock)
6270 (setq font-lock-defaults nil)
6271 (font-lock-mode -1))
6272 (let ((inhibit-read-only t))
6273 (gnus-article-edit-done arg)))
6275 (defun gnus-article-mime-edit-exit ()
6276 "Exit the article MIME editing without updating."
6278 (when (or (not (buffer-modified-p))
6279 (yes-or-no-p "Article modified; kill anyway? "))
6280 (when (featurep 'font-lock)
6281 (setq font-lock-defaults nil)
6282 (font-lock-mode -1))
6283 (when mime-edit-mode-flag
6284 (let (mime-edit-insert-user-agent-field)
6287 (goto-char (point-min))
6288 (let (case-fold-search)
6289 (when (re-search-forward
6290 (format "^%s$" (regexp-quote mail-header-separator)) nil t)
6291 (replace-match "")))
6292 (let ((winconf gnus-prev-winconf))
6294 (buffer-substring-no-properties (point-min) (point-max))
6295 (set-buffer (get-buffer-create gnus-original-article-buffer))
6297 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6298 (set-buffer gnus-article-buffer)
6299 (gnus-article-prepare-display)
6300 (set-window-configuration winconf))))
6303 ;;; Article highlights
6306 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
6308 ;;; Internal Variables:
6310 (defcustom gnus-button-url-regexp
6311 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
6312 "\\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:]]\\)"
6313 "\\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\\)\\)")
6314 "Regular expression that matches URLs."
6315 :group 'gnus-article-buttons
6318 (defcustom gnus-button-valid-fqdn-regexp
6319 message-valid-fqdn-regexp
6320 "Regular expression that matches a valid FQDN."
6322 :group 'gnus-article-buttons
6325 (defcustom gnus-button-man-handler 'manual-entry
6326 "Function to use for displaying man pages.
6327 The function must take at least one argument with a string naming the
6330 :type '(choice (function-item :tag "Man" manual-entry)
6331 (function-item :tag "Woman" woman)
6332 (function :tag "Other"))
6333 :group 'gnus-article-buttons)
6335 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
6336 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
6337 If the default site is too slow, try to find a CTAN mirror, see
6338 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
6339 the variable `gnus-button-handle-ctan'."
6341 :group 'gnus-article-buttons
6342 :link '(custom-manual "(gnus)Group Parameters")
6343 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
6344 (const "http://tug.ctan.org/tex-archive/")
6345 (const "http://www.dante.de/CTAN/")
6346 (string :tag "Other")))
6348 (defcustom gnus-button-ctan-handler 'browse-url
6349 "Function to use for displaying CTAN links.
6350 The function must take one argument, the string naming the URL."
6352 :type '(choice (function-item :tag "Browse Url" browse-url)
6353 (function :tag "Other"))
6354 :group 'gnus-article-buttons)
6356 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
6357 "Bogus strings removed from CTAN URLs."
6359 :group 'gnus-article-buttons
6360 :type '(choice (const "^/?tex-archive/\\|/")
6361 (regexp :tag "Other")))
6363 (defcustom gnus-button-ctan-directory-regexp
6366 "biblio\\|digests\\|dviware\\|fonts\\|graphics\\|help\\|"
6367 "indexing\\|info\\|language\\|macros\\|support\\|systems\\|"
6368 "tds\\|tools\\|usergrps\\|web\\|nonfree\\|obsolete"
6370 "Regular expression for ctan directories.
6371 It should match all directories in the top level of `gnus-ctan-url'."
6373 :group 'gnus-article-buttons
6376 (defcustom gnus-button-mid-or-mail-regexp
6377 (concat "\\b\\(<?[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t ]*@"
6378 ;; Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
6379 gnus-button-valid-fqdn-regexp
6381 "Regular expression that matches a message ID or a mail address."
6383 :group 'gnus-article-buttons
6386 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
6387 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
6388 Strings like this can be either a message ID or a mail address. If it is one
6389 of the symbols `mid' or `mail', Gnus will always assume that the string is a
6390 message ID or a mail address, respectively. If this variable is set to the
6391 symbol `ask', always query the user what do do. If it is a function, this
6392 function will be called with the string as it's only argument. The function
6393 must return `mid', `mail', `invalid' or `ask'."
6395 :group 'gnus-article-buttons
6396 :type '(choice (function-item :tag "Heuristic function"
6397 gnus-button-mid-or-mail-heuristic)
6402 (defcustom gnus-button-mid-or-mail-heuristic-alist
6403 '((-10.0 . ".+\\$.+@")
6406 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
6407 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
6408 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
6409 (-1.0 . "^[^a-z]+@")
6411 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
6412 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
6413 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
6414 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
6417 (-1.0 . "^[0-9][0-9]")
6419 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
6420 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6421 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
6422 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6424 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
6425 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
6428 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
6430 ;; compensation for TDMA dated mail addresses:
6431 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
6433 (-20.0 . "\\.fsf@") ;; Gnus
6436 (-20.0 . "_-_") ;; Subject change in thread
6438 (-20.0 . "\\.ln@") ;; leafnode
6439 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
6440 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
6442 ;; (5.0 . "") ;; $local_part_len <= 7
6443 (10.0 . "^[^0-9]+@")
6444 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
6445 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
6448 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
6450 (0.5 . "^[A-Z][a-z]")
6451 (0.5 . "^[A-Z][a-z][a-z]")
6452 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
6453 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
6454 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
6456 A negative RATE indicates a message IDs, whereas a positive indicates a mail
6457 address. The REGEXP is processed with `case-fold-search' set to nil."
6459 :group 'gnus-article-buttons
6460 :type '(repeat (cons (number :tag "Rate")
6461 (regexp :tag "Regexp"))))
6463 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
6464 "Guess whether MID-OR-MAIL is a message ID or a mail address.
6465 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
6466 address, `ask' if unsure and `invalid' if the string is invalid."
6467 (let ((case-fold-search nil)
6468 (list gnus-button-mid-or-mail-heuristic-alist)
6469 (result 0) rate regexp lpartlen elem)
6471 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
6472 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
6473 ;; Certain special cases...
6476 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
6477 "^[0-9]+\\.[0-9]+@compuserve\\|"
6478 "@public\\.gmane\\.org")
6480 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
6481 (setq result 'mail))
6482 (when (string-match "@.*@\\| " mid-or-mail)
6483 (gnus-message 8 "`%s' is invalid." mid-or-mail)
6484 (setq result 'invalid))
6485 ;; Nothing more to do, if result is not a number here...
6486 (when (numberp result)
6488 (setq elem (car list)
6492 (when (string-match regexp mid-or-mail)
6493 (setq result (+ result rate))
6495 9 "`%s' matched `%s', rate `%s', result `%s'."
6496 mid-or-mail regexp rate result)))
6497 (when (<= lpartlen 7)
6498 (setq result (+ result 5.0))
6499 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
6500 mid-or-mail result))
6501 (when (>= lpartlen 12)
6502 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
6504 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
6505 ;; Long local part should contain realname if e-mail address,
6506 ;; too many digits: message-id.
6507 ;; $score -= 5.0 + 0.1 * $local_part_len;
6508 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6509 (setq result (+ result rate))
6511 9 "Many digits in `%s', rate `%s', result `%s'."
6512 mid-or-mail rate result))
6513 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6515 ;; Too few vowels [^aeiouy]{4,}.*\@
6516 (setq result (+ result -5.0))
6518 9 "Few vowels in `%s', rate `%s', result `%s'."
6519 mid-or-mail -5.0 result))
6521 (setq result (+ result 5.0))
6523 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6524 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6525 ;; Maybe we should make this a customizable alist: (condition . 'result)
6527 ((symbolp result) result)
6528 ;; Now convert number into proper results:
6529 ((< result -10.0) 'mid)
6530 ((> result 10.0) 'mail)
6533 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6534 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6535 (url-mid (concat "news" ":" mid-or-mail))
6536 (url-mailto (concat "mailto" ":" mid-or-mail)))
6537 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6538 (when (fboundp pref)
6540 ;; get rid of surrounding angles...
6542 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6543 (if (or (eq 'mid guessed) (eq 'mail guessed))
6547 (save-window-excursion
6548 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6551 (cond ((eq pref 'mid)
6552 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6553 (gnus-button-handle-news url-mid))
6555 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6556 (gnus-url-mailto url-mailto))
6557 (t (gnus-message 3 "Invalid string.")))))
6559 (defun gnus-button-handle-custom (url)
6560 "Follow a Custom URL."
6561 (customize-apropos (gnus-url-unhex-string url)))
6563 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6565 ;; FIXME: Maybe we should merge some of the functions that do quite similar
6568 (defun gnus-button-handle-describe-function (url)
6569 "Call `describe-function' when pushing the corresponding URL button."
6572 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6574 (defun gnus-button-handle-describe-variable (url)
6575 "Call `describe-variable' when pushing the corresponding URL button."
6578 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6580 (defun gnus-button-handle-symbol (url)
6581 "Display help on variable or function.
6582 Calls `describe-variable' or `describe-function'."
6583 (let ((sym (intern url)))
6585 ((fboundp sym) (describe-function sym))
6586 ((boundp sym) (describe-variable sym))
6587 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
6589 (defun gnus-button-handle-describe-key (url)
6590 "Call `describe-key' when pushing the corresponding URL button."
6592 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6593 (keys (ignore-errors (eval `(kbd ,key-string)))))
6596 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6598 (defun gnus-button-handle-apropos (url)
6599 "Call `apropos' when pushing the corresponding URL button."
6600 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6602 (defun gnus-button-handle-apropos-command (url)
6603 "Call `apropos' when pushing the corresponding URL button."
6605 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6607 (defun gnus-button-handle-apropos-variable (url)
6608 "Call `apropos' when pushing the corresponding URL button."
6610 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6611 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6613 (defun gnus-button-handle-apropos-documentation (url)
6614 "Call `apropos' when pushing the corresponding URL button."
6616 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6617 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6619 (defun gnus-button-handle-library (url)
6620 "Call `locate-library' when pushing the corresponding URL button."
6621 (gnus-message 9 "url=`%s'" url)
6622 (let* ((lib (locate-library url))
6623 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6625 (gnus-message 1 "Cannot locale library `%s'." url)
6626 (find-file-read-only file))))
6628 (defun gnus-button-handle-ctan (url)
6629 "Call `browse-url' when pushing a CTAN URL button."
6631 gnus-button-ctan-handler
6634 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6636 (defcustom gnus-button-tex-level 5
6637 "*Integer that says how many TeX-related buttons Gnus will show.
6638 The higher the number, the more buttons will appear and the more false
6639 positives are possible. Note that you can set this variable local to
6640 specific groups. Setting it higher in TeX groups is probably a good idea.
6641 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6642 how to set variables in specific groups."
6644 :group 'gnus-article-buttons
6645 :link '(custom-manual "(gnus)Group Parameters")
6648 (defcustom gnus-button-man-level 5
6649 "*Integer that says how many man-related buttons Gnus will show.
6650 The higher the number, the more buttons will appear and the more false
6651 positives are possible. Note that you can set this variable local to
6652 specific groups. Setting it higher in Unix groups is probably a good idea.
6653 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6654 how to set variables in specific groups."
6656 :group 'gnus-article-buttons
6657 :link '(custom-manual "(gnus)Group Parameters")
6660 (defcustom gnus-button-emacs-level 5
6661 "*Integer that says how many emacs-related buttons Gnus will show.
6662 The higher the number, the more buttons will appear and the more false
6663 positives are possible. Note that you can set this variable local to
6664 specific groups. Setting it higher in Emacs or Gnus related groups is
6665 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6666 `gnus-parameters' on how to set variables in specific groups."
6668 :group 'gnus-article-buttons
6669 :link '(custom-manual "(gnus)Group Parameters")
6672 (defcustom gnus-button-message-level 5
6673 "*Integer that says how many buttons for news or mail messages will appear.
6674 The higher the number, the more buttons will appear and the more false
6675 positives are possible."
6676 ;; mail addresses, MIDs, URLs for news, ...
6678 :group 'gnus-article-buttons
6681 (defcustom gnus-button-browse-level 5
6682 "*Integer that says how many buttons for browsing will appear.
6683 The higher the number, the more buttons will appear and the more false
6684 positives are possible."
6685 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6687 :group 'gnus-article-buttons
6690 (defcustom gnus-button-alist
6691 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6692 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6693 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
6694 gnus-button-handle-news 2)
6695 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6696 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6697 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6698 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6699 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
6700 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
6701 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
6702 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6703 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6704 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6705 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6706 ;; RFC 2368 (The mailto URL scheme)
6707 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6708 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6709 ("\\bmailto:\\([^ \n\t]+\\)"
6710 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6712 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6713 gnus-button-ctan-directory-regexp
6714 "[^][>)!;:,'\n\t ]+\\)")
6715 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6716 ((concat "\\btex-archive/\\("
6717 gnus-button-ctan-directory-regexp
6718 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6719 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6722 gnus-button-ctan-directory-regexp
6723 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6724 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6725 ;; This is info (home-grown style) <info://foo/bar+baz>
6726 ("\\binfo://\\([^'\">\n\t ]+\\)"
6727 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6728 ;; Info GNOME style <info:foo#bar_baz>
6729 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6730 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6731 ;; Info KDE style <info:(foo)bar baz>
6732 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6733 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6734 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6735 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6736 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6737 ;; Info links like `C-h i d m CC Mode RET'
6738 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6740 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6741 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6742 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6743 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6744 ;; Emacs help commands
6745 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6746 ;; regexp doesn't match arguments containing ` '.
6747 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6748 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6749 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6750 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6751 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6752 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6753 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6754 ;; The following entries may lead to many false positives so don't enable
6755 ;; them by default (use a high button level).
6756 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
6757 ;; Exclude [.?] for URLs in gmane.emacs.cvs
6758 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6759 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6760 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6761 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6762 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6763 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6764 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6765 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6766 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6767 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6768 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
6769 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6770 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6771 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6772 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6773 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6774 ;; Unlike the other regexps we really have to require quoting
6775 ;; here to determine where it ends.
6776 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6777 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
6778 ("<URL: *\\([^<>]*\\)>"
6779 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6780 ;; RFC 2396 (2.4.3., delims) ...
6781 ("\"URL: *\\([^\"]*\\)\""
6782 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6783 ;; RFC 2396 (2.4.3., delims) ...
6784 ("\"URL: *\\([^\"]*\\)\""
6785 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6787 (gnus-button-url-regexp
6788 0 (>= gnus-button-browse-level 0) browse-url 0)
6790 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
6791 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6792 gnus-button-handle-man 1)
6793 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6794 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
6795 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6796 gnus-button-handle-man 1)
6797 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6798 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6799 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
6800 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6801 ;; MID or mail: To avoid too many false positives we don't try to catch
6802 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6803 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6804 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6805 ;; so that non-ambiguous entries (see above) match first.
6806 (gnus-button-mid-or-mail-regexp
6807 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6808 "*Alist of regexps matching buttons in article bodies.
6810 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6811 REGEXP: is the string (case insensitive) matching text around the button (can
6812 also be Lisp expression evaluating to a string),
6813 BUTTON: is the number of the regexp grouping actually matching the button,
6814 FORM: is a Lisp expression which must eval to true for the button to
6816 CALLBACK: is the function to call when the user push this button, and each
6817 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6819 CALLBACK can also be a variable, in that case the value of that
6820 variable it the real callback function."
6821 :group 'gnus-article-buttons
6822 :type '(repeat (list (choice regexp variable sexp)
6823 (integer :tag "Button")
6825 (function :tag "Callback")
6828 (integer :tag "Regexp group")))))
6830 (defcustom gnus-header-button-alist
6831 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
6832 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6833 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6834 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6835 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6836 0 (>= gnus-button-message-level 0) gnus-msg-mail 0)
6837 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6838 0 (>= gnus-button-browse-level 0) browse-url 0)
6839 ("^Subject:" gnus-button-url-regexp
6840 0 (>= gnus-button-browse-level 0) browse-url 0)
6841 ("^[^:]+:" gnus-button-url-regexp
6842 0 (>= gnus-button-browse-level 0) browse-url 0)
6843 ("^OpenPGP:.*url=" gnus-button-url-regexp
6844 0 (>= gnus-button-browse-level 0) gnus-button-openpgp 0)
6845 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6846 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6847 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6848 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6849 "*Alist of headers and regexps to match buttons in article heads.
6851 This alist is very similar to `gnus-button-alist', except that each
6852 alist has an additional HEADER element first in each entry:
6854 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6856 HEADER is a regexp to match a header. For a fuller explanation, see
6857 `gnus-button-alist'."
6858 :group 'gnus-article-buttons
6859 :group 'gnus-article-headers
6860 :type '(repeat (list (regexp :tag "Header")
6861 (choice regexp variable)
6862 (integer :tag "Button")
6864 (function :tag "Callback")
6867 (integer :tag "Regexp group")))))
6871 (defun gnus-article-push-button (event)
6872 "Check text under the mouse pointer for a callback function.
6873 If the text under the mouse pointer has a `gnus-callback' property,
6874 call it with the value of the `gnus-data' text property."
6876 (set-buffer (window-buffer (posn-window (event-start event))))
6877 (let* ((pos (posn-point (event-start event)))
6878 (data (get-text-property pos 'gnus-data))
6879 (fun (get-text-property pos 'gnus-callback)))
6882 (funcall fun data))))
6884 (defun gnus-article-press-button ()
6885 "Check text at point for a callback function.
6886 If the text at point has a `gnus-callback' property,
6887 call it with the value of the `gnus-data' text property."
6889 (let ((data (get-text-property (point) 'gnus-data))
6890 (fun (get-text-property (point) 'gnus-callback)))
6892 (funcall fun data))))
6894 (defun gnus-article-prev-button (n)
6895 "Move point to N buttons backward.
6896 If N is negative, move forward instead."
6898 (gnus-article-next-button (- n)))
6900 (defun gnus-article-next-button (n)
6901 "Move point to N buttons forward.
6902 If N is negative, move backward instead."
6904 (let ((function (if (< n 0) 'previous-single-property-change
6905 'next-single-property-change))
6906 (inhibit-point-motion-hooks t)
6908 (limit (if (< n 0) (point-min) (point-max))))
6910 (while (and (not (= limit (point)))
6912 ;; Skip past the current button.
6913 (when (get-text-property (point) 'gnus-callback)
6914 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6915 ;; Go to the next (or previous) button.
6916 (gnus-goto-char (funcall function (point) 'gnus-callback nil limit))
6917 ;; Put point at the start of the button.
6918 (when (and backward (not (get-text-property (point) 'gnus-callback)))
6919 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6920 ;; Skip past intangible buttons.
6921 (when (get-text-property (point) 'intangible)
6925 (gnus-message 5 "No more buttons"))
6928 (defun gnus-article-highlight (&optional force)
6929 "Highlight current article.
6930 This function calls `gnus-article-highlight-headers',
6931 `gnus-article-highlight-citation',
6932 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6933 do the highlighting. See the documentation for those functions."
6934 (interactive (list 'force))
6935 (gnus-article-highlight-headers)
6936 (gnus-article-highlight-citation force)
6937 (gnus-article-highlight-signature)
6938 (gnus-article-add-buttons force)
6939 (gnus-article-add-buttons-to-head))
6941 (defun gnus-article-highlight-some (&optional force)
6942 "Highlight current article.
6943 This function calls `gnus-article-highlight-headers',
6944 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6945 do the highlighting. See the documentation for those functions."
6946 (interactive (list 'force))
6947 (gnus-article-highlight-headers)
6948 (gnus-article-highlight-signature)
6949 (gnus-article-add-buttons))
6951 (defun gnus-article-highlight-headers ()
6952 "Highlight article headers as specified by `gnus-header-face-alist'."
6954 (gnus-with-article-headers
6955 (let (regexp header-face field-face from hpoints fpoints)
6956 (dolist (entry gnus-header-face-alist)
6957 (goto-char (point-min))
6958 (setq regexp (concat "^\\("
6959 (if (string-equal "" (nth 0 entry))
6963 header-face (nth 1 entry)
6964 field-face (nth 2 entry))
6965 (while (and (re-search-forward regexp nil t)
6969 (unless (search-forward ":" nil t)
6971 (when (and header-face
6972 (not (memq (point) hpoints)))
6973 (push (point) hpoints)
6974 (gnus-put-text-property from (point) 'face header-face))
6975 (when (and field-face
6976 (not (memq (setq from (point)) fpoints)))
6978 (if (re-search-forward "^[^ \t]" nil t)
6980 (goto-char (point-max)))
6981 (gnus-put-text-property from (point) 'face field-face)))))))
6983 (defun gnus-article-highlight-signature ()
6984 "Highlight the signature in an article.
6985 It does this by highlighting everything after
6986 `gnus-signature-separator' using `gnus-signature-face'."
6988 (when gnus-signature-face
6989 (gnus-with-article-buffer
6990 (let ((inhibit-point-motion-hooks t))
6992 (when (gnus-article-narrow-to-signature)
6993 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6994 'face gnus-signature-face)))))))
6996 (defun gnus-article-buttonize-signature ()
6997 "Add button to the signature."
7000 (set-buffer gnus-article-buffer)
7001 (let ((inhibit-read-only t)
7002 (inhibit-point-motion-hooks t))
7003 (when (gnus-article-search-signature)
7004 (gnus-article-add-button (match-beginning 0) (match-end 0)
7005 'gnus-signature-toggle
7006 (set-marker (make-marker)
7007 (1+ (match-end 0))))))))
7009 (defun gnus-button-in-region-p (b e prop)
7010 "Say whether PROP exists in the region."
7011 (text-property-not-all b e prop nil))
7013 (defun gnus-article-add-buttons (&optional force)
7014 "Find external references in the article and make buttons of them.
7015 \"External references\" are things like Message-IDs and URLs, as
7016 specified by `gnus-button-alist'."
7017 (interactive (list 'force))
7018 (gnus-with-article-buffer
7019 (let ((inhibit-point-motion-hooks t)
7020 (case-fold-search t)
7021 (alist gnus-button-alist)
7023 ;; Remove all old markers.
7024 (let (marker entry new-list)
7025 (while (setq marker (pop gnus-button-marker-list))
7026 (if (or (< marker (point-min)) (>= marker (point-max)))
7027 (push marker new-list)
7029 (when (setq entry (gnus-button-entry))
7030 (put-text-property (match-beginning (nth 1 entry))
7031 (match-end (nth 1 entry))
7032 'gnus-callback nil))
7033 (set-marker marker nil)))
7034 (setq gnus-button-marker-list new-list))
7035 ;; We skip the headers.
7038 (while (setq entry (pop alist))
7039 (setq regexp (eval (car entry)))
7041 (while (re-search-forward regexp nil t)
7042 (let* ((start (and entry (match-beginning (nth 1 entry))))
7043 (end (and entry (match-end (nth 1 entry))))
7044 (from (match-beginning 0)))
7045 (when (and (or (eq t (nth 2 entry))
7046 (eval (nth 2 entry)))
7047 (not (gnus-button-in-region-p
7048 start end 'gnus-callback)))
7049 ;; That optional form returned non-nil, so we add the
7051 (gnus-article-add-button
7052 start end 'gnus-button-push
7053 (car (push (set-marker (make-marker) from)
7054 gnus-button-marker-list))))))))))
7056 ;; Add buttons to the head of an article.
7057 (defun gnus-article-add-buttons-to-head ()
7058 "Add buttons to the head of the article."
7060 (gnus-with-article-headers
7062 (dolist (entry gnus-header-button-alist)
7063 ;; Each alist entry.
7064 (goto-char (point-min))
7065 (while (re-search-forward (car entry) nil t)
7066 ;; Each header matching the entry.
7067 (setq beg (match-beginning 0))
7068 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
7069 (match-beginning 0))
7072 (while (re-search-forward (eval (nth 1 entry)) end t)
7073 ;; Each match within a header.
7074 (let* ((entry (cdr entry))
7075 (start (match-beginning (nth 1 entry)))
7076 (end (match-end (nth 1 entry)))
7077 (form (nth 2 entry)))
7078 (goto-char (match-end 0))
7080 (gnus-article-add-button
7081 start end (nth 3 entry)
7082 (buffer-substring (match-beginning (nth 4 entry))
7083 (match-end (nth 4 entry)))))))
7084 (goto-char end))))))
7086 ;;; External functions:
7088 (defun gnus-article-add-button (from to fun &optional data)
7089 "Create a button between FROM and TO with callback FUN and data DATA."
7090 (when gnus-article-button-face
7091 (gnus-overlay-put (gnus-make-overlay from to)
7092 'face gnus-article-button-face))
7093 (gnus-add-text-properties
7095 (nconc (and gnus-article-mouse-face
7096 (list gnus-mouse-face-prop gnus-article-mouse-face))
7097 (list 'gnus-callback fun)
7098 (and data (list 'gnus-data data))))
7099 (widget-convert-button 'link from to :action 'gnus-widget-press-button
7100 :button-keymap gnus-widget-button-keymap))
7102 ;;; Internal functions:
7104 (defun gnus-article-set-globals ()
7105 (with-current-buffer gnus-summary-buffer
7106 (gnus-set-global-variables)))
7108 (defun gnus-signature-toggle (end)
7109 (gnus-with-article-buffer
7110 (let ((inhibit-point-motion-hooks t)
7111 (limit (next-single-property-change end 'mime-view-entity
7113 (if (text-property-any end limit 'article-type 'signature)
7115 (gnus-delete-wash-type 'signature)
7116 (gnus-remove-text-properties-when
7117 'article-type 'signature end limit
7118 (cons 'article-type (cons 'signature
7119 gnus-hidden-properties))))
7120 (gnus-add-wash-type 'signature)
7121 (gnus-add-text-properties-when
7122 'article-type nil end limit
7123 (cons 'article-type (cons 'signature
7124 gnus-hidden-properties)))))
7125 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
7126 (gnus-set-mode-line 'article))))
7128 (defun gnus-button-entry ()
7129 ;; Return the first entry in `gnus-button-alist' matching this place.
7130 (let ((alist gnus-button-alist)
7133 (setq entry (pop alist))
7134 (if (looking-at (eval (car entry)))
7139 (defun gnus-button-push (marker)
7140 ;; Push button starting at MARKER.
7143 (let* ((entry (gnus-button-entry))
7144 (inhibit-point-motion-hooks t)
7146 (args (mapcar (lambda (group)
7147 (let ((string (match-string group)))
7148 (set-text-properties
7149 0 (length string) nil string)
7156 (fboundp (symbol-value fun)))
7157 (apply (symbol-value fun) args))
7159 (gnus-message 1 "You must define `%S' to use this button"
7160 (cons fun args)))))))
7162 (defun gnus-parse-news-url (url)
7163 (let (scheme server port group message-id articles)
7166 (goto-char (point-min))
7167 (when (looking-at "\\([A-Za-z]+\\):")
7168 (setq scheme (match-string 1))
7169 (goto-char (match-end 0)))
7170 (when (looking-at "//\\([^:/]+\\)\\(:?\\)\\([0-9]+\\)?/")
7171 (setq server (match-string 1))
7172 (setq port (if (stringp (match-string 3))
7173 (string-to-number (match-string 3))
7175 (goto-char (match-end 0)))
7178 ((looking-at "\\(.*@.*\\)")
7179 (setq message-id (match-string 1)))
7180 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
7181 (setq group (match-string 1)
7182 articles (split-string (match-string 2) "-")))
7183 ((looking-at "\\([^/]+\\)/?")
7184 (setq group (match-string 1)))
7186 (error "Unknown news URL syntax"))))
7187 (list scheme server port group message-id articles)))
7189 (defun gnus-button-handle-news (url)
7191 (destructuring-bind (scheme server port group message-id articles)
7192 (gnus-parse-news-url url)
7196 (set-buffer gnus-summary-buffer)
7198 (let ((gnus-refer-article-method
7199 (nconc (list (list 'nntp server))
7200 gnus-refer-article-method))
7201 (nntp-port-number (or port "nntp")))
7202 (gnus-message 7 "Fetching %s with %s"
7203 message-id gnus-refer-article-method)
7204 (gnus-summary-refer-article message-id))
7205 (gnus-summary-refer-article message-id))))
7207 (gnus-button-fetch-group url)))))
7209 (defun gnus-button-handle-man (url)
7211 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7212 (when (eq gnus-button-man-handler 'woman)
7213 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
7214 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7215 (funcall gnus-button-man-handler url))
7217 (defun gnus-button-handle-info-url (url)
7218 "Fetch an info URL."
7219 (setq url (mm-subst-char-in-string ?+ ?\ url))
7221 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
7222 (gnus-info-find-node
7223 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
7225 ")" (gnus-url-unhex-string (match-string 2 url)))))
7226 ((string-match "([^)\"]+)[^\"]+" url)
7228 (gnus-replace-in-string
7229 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
7230 (gnus-info-find-node url))
7231 (t (error "Can't parse %s" url))))
7233 (defun gnus-button-handle-info-url-gnome (url)
7234 "Fetch GNOME style info URL."
7235 (setq url (mm-subst-char-in-string ?_ ?\ url))
7236 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
7237 (gnus-info-find-node
7239 (gnus-url-unhex-string
7240 (match-string 1 url))
7242 (or (gnus-url-unhex-string
7243 (match-string 2 url))
7245 (error "Can't parse %s" url)))
7247 (defun gnus-button-handle-info-url-kde (url)
7248 "Fetch KDE style info URL."
7249 (gnus-info-find-node (gnus-url-unhex-string url)))
7251 (defun gnus-button-handle-info-keystrokes (url)
7252 "Call `info' when pushing the corresponding URL button."
7253 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
7258 (defun gnus-button-openpgp (url)
7259 "Retrieve and add an OpenPGP key given URL from an OpenPGP header."
7261 (mm-url-insert-file-contents-external url)
7262 (pgg-snarf-keys-region (point-min) (point-max))
7263 (pgg-display-output-buffer nil nil nil)))
7265 (defun gnus-button-message-id (message-id)
7267 (with-current-buffer gnus-summary-buffer
7268 (gnus-summary-refer-article message-id)))
7270 (defun gnus-button-fetch-group (address)
7271 "Fetch GROUP specified by ADDRESS."
7272 (if (not (string-match "[:/]" address))
7273 ;; This is just a simple group url.
7274 (gnus-group-read-ephemeral-group address gnus-select-method)
7277 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
7279 (error "Can't parse %s" address)
7280 (gnus-group-read-ephemeral-group
7281 (match-string 4 address)
7282 `(nntp ,(match-string 1 address)
7283 (nntp-address ,(match-string 1 address))
7284 (nntp-port-number ,(if (match-end 3)
7285 (match-string 3 address)
7288 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
7290 (defun gnus-url-parse-query-string (query &optional downcase)
7291 (let (retval pairs cur key val)
7292 (setq pairs (split-string query "&"))
7294 (setq cur (car pairs)
7296 (if (not (string-match "=" cur))
7298 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
7299 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
7301 (setq key (downcase key)))
7302 (setq cur (assoc key retval))
7304 (setcdr cur (cons val (cdr cur)))
7305 (setq retval (cons (list key val) retval)))))
7308 (defun gnus-url-mailto (url)
7309 ;; Send mail to someone
7310 (when (string-match "mailto:/*\\(.*\\)" url)
7311 (setq url (substring url (match-beginning 1) nil)))
7312 (let (to args subject func)
7313 (setq args (gnus-url-parse-query-string
7314 (if (string-match "^\\?" url)
7316 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
7317 (concat "to=" (match-string 1 url) "&"
7318 (match-string 2 url))
7319 (concat "to=" url)))
7321 subject (cdr-safe (assoc "subject" args)))
7324 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
7327 (message-position-on-field (caar args)))
7328 (insert (gnus-replace-in-string
7329 (mapconcat 'identity (reverse (cdar args)) ", ")
7331 (setq args (cdr args)))
7334 (message-goto-subject))))
7336 (defun gnus-button-embedded-url (address)
7337 "Activate ADDRESS with `browse-url'."
7338 (browse-url (gnus-strip-whitespace address)))
7340 ;;; Next/prev buttons in the article buffer.
7342 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
7343 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
7345 (defvar gnus-prev-page-map
7346 (let ((map (make-sparse-keymap)))
7347 (define-key map gnus-mouse-2 'gnus-button-prev-page)
7348 (define-key map "\r" 'gnus-button-prev-page)
7351 (defvar gnus-next-page-map
7352 (let ((map (make-sparse-keymap)))
7353 (unless (>= emacs-major-version 21)
7354 ;; XEmacs doesn't care.
7355 (set-keymap-parent map gnus-article-mode-map))
7356 (define-key map gnus-mouse-2 'gnus-button-next-page)
7357 (define-key map "\r" 'gnus-button-next-page)
7360 (defun gnus-insert-prev-page-button ()
7362 (inhibit-read-only t)
7363 (situation (get-text-property (point-min) 'mime-view-situation)))
7365 gnus-prev-page-line-format nil
7366 `(keymap ,gnus-prev-page-map
7368 gnus-callback gnus-article-button-prev-page
7369 article-type annotation
7370 mime-view-situation ,situation))
7371 (widget-convert-button
7373 ;; Exclude a newline.
7376 :action 'gnus-button-prev-page
7377 :button-keymap gnus-prev-page-map)))
7379 (defun gnus-button-next-page (&optional args more-args)
7380 "Go to the next page."
7382 (let ((win (selected-window)))
7383 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7384 (gnus-article-next-page)
7385 (select-window win)))
7387 (defun gnus-button-prev-page (&optional args more-args)
7388 "Go to the prev page."
7390 (let ((win (selected-window)))
7391 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7392 (gnus-article-prev-page)
7393 (select-window win)))
7395 (defun gnus-insert-next-page-button ()
7397 (inhibit-read-only t)
7398 (situation (get-text-property (point-min) 'mime-view-situation)))
7399 (gnus-eval-format gnus-next-page-line-format nil
7400 `(keymap ,gnus-next-page-map
7402 gnus-callback gnus-article-button-next-page
7403 article-type annotation
7404 mime-view-situation ,situation))
7405 (widget-convert-button
7407 ;; Exclude a newline.
7410 :action 'gnus-button-next-page
7411 :button-keymap gnus-next-page-map)))
7413 (defun gnus-article-button-next-page (arg)
7414 "Go to the next page."
7416 (let ((win (selected-window)))
7417 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7418 (gnus-article-next-page)
7419 (select-window win)))
7421 (defun gnus-article-button-prev-page (arg)
7422 "Go to the prev page."
7424 (let ((win (selected-window)))
7425 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7426 (gnus-article-prev-page)
7427 (select-window win)))
7429 (defvar gnus-decode-header-methods
7430 '(mail-decode-encoded-word-region)
7431 "List of methods used to decode headers.
7433 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
7434 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
7435 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
7436 whose names match REGEXP.
7439 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
7440 mail-decode-encoded-word-region
7441 (\"chinese\" . rfc1843-decode-region))
7444 (defvar gnus-decode-header-methods-cache nil)
7446 (defun gnus-multi-decode-header (start end)
7447 "Apply the functions from `gnus-encoded-word-methods' that match."
7448 (unless (and gnus-decode-header-methods-cache
7449 (eq gnus-newsgroup-name
7450 (car gnus-decode-header-methods-cache)))
7451 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
7454 (nconc gnus-decode-header-methods-cache (list x))
7455 (if (and gnus-newsgroup-name
7456 (string-match (car x) gnus-newsgroup-name))
7457 (nconc gnus-decode-header-methods-cache
7459 gnus-decode-header-methods))
7460 (let ((xlist gnus-decode-header-methods-cache))
7463 (narrow-to-region start end)
7465 (funcall (pop xlist) (point-min) (point-max))))))
7468 ;;; Treatment top-level handling.
7471 (defun gnus-treat-article (condition &optional part-number total-parts type)
7472 (let ((length (- (point-max) (point-min)))
7473 (alist gnus-treatment-function-alist)
7474 (article-goto-body-goes-to-point-min-p t)
7478 (let ((list gnus-article-treat-types))
7480 (when (string-match (pop list) type)
7481 (throw 'found t)))))))
7482 (highlightp (gnus-visual-p 'article-highlight 'highlight))
7483 (entity (static-unless (featurep 'xemacs)
7484 (when (eq 'head condition)
7485 (get-text-property (point-min) 'mime-view-entity))))
7486 val elem buttonized)
7487 (gnus-run-hooks 'gnus-part-display-hook)
7488 (unless gnus-inhibit-treatment
7489 (dolist (elem alist)
7492 (when (gnus-buffer-live-p gnus-summary-buffer)
7493 (set-buffer gnus-summary-buffer))
7494 (symbol-value (car elem))))
7495 (when (and (or (consp val)
7497 (gnus-treat-predicate val)
7498 (or (not (get (car elem) 'highlight))
7500 (when (and (not buttonized)
7502 '(gnus-treat-hide-signature
7503 gnus-treat-highlight-signature)))
7504 (gnus-article-buttonize-signature)
7505 (setq buttonized t))
7507 (funcall (cadr elem)))))
7508 ;; FSF Emacsen does not inherit the existing text properties
7509 ;; in the new text, so we should do it for `mime-view-entity'.
7510 (static-unless (featurep 'xemacs)
7512 (put-text-property (point-min) (point-max)
7513 'mime-view-entity entity))))))
7515 ;; Dynamic variables.
7517 (defvar part-number)
7518 (defvar total-parts)
7523 (defun gnus-treat-predicate (val)
7528 (stringp (car val)))
7529 (apply 'gnus-or (mapcar `(lambda (s)
7530 (string-match s ,(or gnus-newsgroup-name "")))
7533 (let ((pred (pop val)))
7536 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
7538 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
7540 (not (gnus-treat-predicate (car val))))
7542 (equal (car val) type))
7544 (error "%S is not a valid predicate" pred)))))
7554 (eq part-number total-parts))
7558 (error "%S is not a valid value" val))))
7560 (defun gnus-article-encrypt-body (protocol &optional n)
7561 "Encrypt the article body."
7564 (or gnus-article-encrypt-protocol
7565 (completing-read "Encrypt protocol: "
7566 gnus-article-encrypt-protocol-alist
7568 current-prefix-arg))
7569 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7571 (error (format "Can't find the encrypt protocol %s" protocol)))
7572 (if (member gnus-newsgroup-name '("nndraft:delayed"
7575 (error "Can't encrypt the article in group %s"
7576 gnus-newsgroup-name))
7577 (gnus-summary-iterate n
7579 (set-buffer gnus-summary-buffer)
7580 (let ((mail-parse-charset gnus-newsgroup-charset)
7581 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7582 (summary-buffer gnus-summary-buffer)
7584 (gnus-set-global-variables)
7585 (when (gnus-group-read-only-p)
7586 (error "The current newsgroup does not support article encrypt"))
7587 (gnus-summary-show-article t)
7589 (or (mail-header-references gnus-current-headers) ""))
7590 (set-buffer gnus-article-buffer)
7591 (let* ((inhibit-read-only t)
7593 (mapcar (lambda (field)
7594 (and (save-restriction
7595 (message-narrow-to-head)
7596 (goto-char (point-min))
7597 (search-forward field nil t))
7599 (message-narrow-to-field)
7601 (delete-region (point-min) (point-max))
7603 '("Content-Type:" "Content-Transfer-Encoding:"
7604 "Content-Disposition:"))))
7605 (message-narrow-to-head)
7606 (message-remove-header "MIME-Version")
7607 (goto-char (point-max))
7608 (setq point (point))
7609 (insert (apply 'concat headers))
7611 (narrow-to-region point (point-max))
7612 (let ((message-options message-options))
7613 (message-options-set 'message-sender user-mail-address)
7614 (message-options-set 'message-recipients user-mail-address)
7615 (message-options-set 'message-sign-encrypt 'not)
7617 (goto-char (point-min))
7618 (insert "MIME-Version: 1.0\n")
7620 (gnus-summary-edit-article-done
7621 references nil summary-buffer t))
7622 (when gnus-keep-backlog
7623 (gnus-backlog-remove-article
7624 (car gnus-article-current) (cdr gnus-article-current)))
7626 (when (get-buffer gnus-original-article-buffer)
7627 (set-buffer gnus-original-article-buffer)
7628 (setq gnus-original-article nil)))
7629 (when gnus-use-cache
7630 (gnus-cache-update-article
7631 (car gnus-article-current) (cdr gnus-article-current))))))))
7633 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7634 "The following specs can be used:
7635 %t The security MIME type
7638 %D Details if button is pressed")
7640 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
7641 "The following specs can be used:
7642 %t The security MIME type
7645 %D Details if button is pressed")
7647 (defvar gnus-mime-security-button-line-format-alist
7648 '((?t gnus-tmp-type ?s)
7649 (?i gnus-tmp-info ?s)
7650 (?d gnus-tmp-details ?s)
7651 (?D gnus-tmp-pressed-details ?s)))
7653 (defvar gnus-mime-security-button-map
7654 (let ((map (make-sparse-keymap)))
7655 (define-key map gnus-mouse-2 'gnus-article-push-button)
7656 (define-key map "\r" 'gnus-article-press-button)
7659 (defvar gnus-mime-security-details-buffer nil)
7661 (defvar gnus-mime-security-button-pressed nil)
7663 (defvar gnus-mime-security-show-details-inline t
7664 "If non-nil, show details in the article buffer.")
7666 (defun gnus-mime-security-verify-or-decrypt (handle)
7667 (mm-remove-parts (cdr handle))
7668 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7669 point (inhibit-read-only t))
7671 (goto-char (car region)))
7673 (narrow-to-region (point) (point))
7674 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7675 (let* ((mm-verify-option 'known)
7676 (mm-decrypt-option 'known)
7677 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7678 (unless (eq nparts (cdr handle))
7679 (mm-destroy-parts (cdr handle))
7680 (setcdr handle nparts))))
7681 (setq point (point))
7682 (gnus-mime-display-security handle)
7683 (goto-char (point-max)))
7685 (delete-region (point) (cdr region))
7686 (set-marker (car region) nil)
7687 (set-marker (cdr region) nil))
7690 (defun gnus-mime-security-show-details (handle)
7691 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7693 (gnus-message 5 "No details.")
7694 (if gnus-mime-security-show-details-inline
7695 (let ((gnus-mime-security-button-pressed
7696 (not (get-text-property (point) 'gnus-mime-details)))
7697 (gnus-mime-security-button-line-format
7698 (get-text-property (point) 'gnus-line-format))
7699 (inhibit-read-only t))
7701 (while (eq (get-text-property (point) 'gnus-line-format)
7702 gnus-mime-security-button-line-format)
7706 (narrow-to-region (point) (point))
7707 (gnus-insert-mime-security-button handle))
7708 (delete-region (point)
7709 (or (text-property-not-all
7712 gnus-mime-security-button-line-format)
7715 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7716 (with-current-buffer gnus-mime-security-details-buffer
7719 (setq gnus-mime-security-details-buffer
7720 (gnus-get-buffer-create "*MIME Security Details*")))
7721 (with-current-buffer gnus-mime-security-details-buffer
7723 (goto-char (point-min)))
7724 (pop-to-buffer gnus-mime-security-details-buffer)))))
7726 (defun gnus-mime-security-press-button (handle)
7728 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7729 (gnus-mime-security-show-details handle)
7730 (gnus-mime-security-verify-or-decrypt handle))))
7732 (defun gnus-insert-mime-security-button (handle &optional displayed)
7733 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7736 (or (nth 2 (assoc protocol mm-verify-function-alist))
7737 (nth 2 (assoc protocol mm-decrypt-function-alist))
7739 (if (equal (car handle) "multipart/signed")
7740 " Signed" " Encrypted")
7743 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7746 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7747 gnus-tmp-pressed-details
7749 (setq gnus-tmp-details
7750 (if gnus-tmp-details
7751 (concat "\n" gnus-tmp-details)
7753 (setq gnus-tmp-pressed-details
7754 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7759 gnus-mime-security-button-line-format
7760 gnus-mime-security-button-line-format-alist
7761 `(keymap ,gnus-mime-security-button-map
7762 gnus-callback gnus-mime-security-press-button
7763 gnus-line-format ,gnus-mime-security-button-line-format
7764 gnus-mime-details ,gnus-mime-security-button-pressed
7765 article-type annotation
7768 ;; Exclude a newline.
7771 (widget-convert-button
7774 :action 'gnus-widget-press-button
7775 :button-keymap gnus-mime-security-button-map
7777 (lambda (widget/window &optional overlay pos)
7778 ;; Needed to properly clear the message due to a bug in
7779 ;; wid-edit (XEmacs only).
7780 (when (boundp 'help-echo-owns-message)
7781 (setq help-echo-owns-message t))
7784 (aref gnus-mouse-2 0))))))
7786 (defun gnus-mime-display-security (handle)
7788 (narrow-to-region (point) (point))
7789 (unless (gnus-unbuttonized-mime-type-p (car handle))
7790 (gnus-insert-mime-security-button handle))
7791 (gnus-mime-display-mixed (cdr handle))
7794 (unless (gnus-unbuttonized-mime-type-p (car handle))
7795 (let ((gnus-mime-security-button-line-format
7796 gnus-mime-security-button-end-line-format))
7797 (gnus-insert-mime-security-button handle)))
7798 (mm-set-handle-multipart-parameter
7800 (cons (set-marker (make-marker) (point-min))
7801 (set-marker (make-marker) (point-max))))))
7807 (defun gnus-article-header-presentation-method (entity situation)
7808 (mime-insert-header entity)
7809 (article-decode-group-name))
7811 (set-alist 'mime-header-presentation-method-alist
7812 'gnus-original-article-mode
7813 #'gnus-article-header-presentation-method)
7815 (defun gnus-mime-preview-quitting-method ()
7816 (mime-preview-kill-buffer)
7817 (delete-other-windows)
7818 (gnus-article-show-summary)
7819 (gnus-summary-select-article gnus-show-all-headers t))
7821 (set-alist 'mime-preview-quitting-method-alist
7822 'gnus-original-article-mode #'gnus-mime-preview-quitting-method)
7824 (set-alist 'mime-preview-following-method-alist
7825 'gnus-original-article-mode #'gnus-following-method)
7827 (set-alist 'mime-preview-over-to-previous-method-alist
7828 'gnus-original-article-mode
7830 (if (> (point-min) 1)
7831 (gnus-article-prev-page)
7832 (gnus-article-read-summary-keys
7833 nil (gnus-character-to-event ?P)))))
7835 (set-alist 'mime-preview-over-to-next-method-alist
7836 'gnus-original-article-mode'
7838 (if (< (point-max) (buffer-size))
7839 (gnus-article-next-page)
7840 (gnus-article-read-summary-keys
7841 nil (gnus-character-to-event ?N)))))
7851 (run-hooks 'gnus-art-load-hook)
7853 ;;; gnus-art.el ends here