1 ;;; gnus-art.el --- article mode commands for Semi-gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
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))
44 (when (static-if (featurep 'xemacs)
45 (console-on-window-system-p)
47 (require 'mime-image))
50 ;; Avoid byte-compile warnings.
60 (autoload 'gnus-msg-mail "gnus-msg" nil t)
61 (autoload 'gnus-button-mailto "gnus-msg")
62 (autoload 'gnus-button-reply "gnus-msg" nil t)
63 (autoload 'ansi-color-apply-on-region "ansi-color")
65 (defgroup gnus-article nil
67 :link '(custom-manual "(gnus)Article Buffer")
70 (defgroup gnus-article-treat nil
71 "Treating article parts."
72 :link '(custom-manual "(gnus)Article Hiding")
75 (defgroup gnus-article-hiding nil
76 "Hiding article parts."
77 :link '(custom-manual "(gnus)Article Hiding")
80 (defgroup gnus-article-highlight nil
81 "Article highlighting."
82 :link '(custom-manual "(gnus)Article Highlighting")
86 (defgroup gnus-article-signature nil
88 :link '(custom-manual "(gnus)Article Signature")
91 (defgroup gnus-article-headers nil
93 :link '(custom-manual "(gnus)Hiding Headers")
96 (defgroup gnus-article-washing nil
97 "Special commands on articles."
98 :link '(custom-manual "(gnus)Article Washing")
101 (defgroup gnus-article-emphasis nil
102 "Fontisizing articles."
103 :link '(custom-manual "(gnus)Article Fontisizing")
104 :group 'gnus-article)
106 (defgroup gnus-article-saving nil
108 :link '(custom-manual "(gnus)Saving Articles")
109 :group 'gnus-article)
111 (defgroup gnus-article-mime nil
112 "Worshiping the MIME wonder."
113 :link '(custom-manual "(gnus)Using MIME")
114 :group 'gnus-article)
116 (defgroup gnus-article-buttons nil
117 "Pushable buttons in the article buffer."
118 :link '(custom-manual "(gnus)Article Buttons")
119 :group 'gnus-article)
121 (defgroup gnus-article-various nil
122 "Other article options."
123 :link '(custom-manual "(gnus)Misc Article")
124 :group 'gnus-article)
126 (defcustom gnus-ignored-headers
129 (concat "^" header ":"))
130 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
131 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
132 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
133 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
134 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
135 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
136 "X-Attribution" "X-Originating-IP" "Delivered-To"
137 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
138 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
139 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
140 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
141 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
142 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
143 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
144 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
145 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
146 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
147 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
148 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
149 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
150 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
151 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
152 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
153 "List-[A-Za-z]+" "X-Listprocessor-Version"
154 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
155 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
156 "X-Received" "Content-length" "X-precedence"
157 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
158 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
159 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
160 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
161 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
162 "X-Content-length" "X-Posting-Agent" "Original-Received"
163 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
164 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
165 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
166 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
167 "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer"))
168 "*All headers that start with this regexp will be hidden.
169 This variable can also be a list of regexps of headers to be ignored.
170 If `gnus-visible-headers' is non-nil, this variable will be ignored."
171 :type '(choice :custom-show nil
174 :group 'gnus-article-hiding)
176 (defcustom gnus-visible-headers
177 "^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:"
178 "*All headers that do not match this regexp will be hidden.
179 This variable can also be a list of regexp of headers to remain visible.
180 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
181 :type '(repeat :value-to-internal (lambda (widget value)
182 (custom-split-regexp-maybe value))
183 :match (lambda (widget value)
185 (widget-editable-list-match widget value)))
187 :group 'gnus-article-hiding)
189 (defcustom gnus-sorted-header-list
190 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
191 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
192 "*This variable is a list of regular expressions.
193 If it is non-nil, headers that match the regular expressions will
194 be placed first in the article buffer in the sequence specified by
196 :type '(repeat regexp)
197 :group 'gnus-article-hiding)
199 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
200 "Headers that are only to be displayed if they have interesting data.
201 Possible values in this list are:
203 'empty Headers with no content.
204 'newsgroups Newsgroup identical to Gnus group.
205 'to-address To identical to To-address.
206 'to-list To identical to To-list.
207 'cc-list CC identical to To-list.
208 'followup-to Followup-to identical to Newsgroups.
209 'reply-to Reply-to identical to From.
210 'date Date less than four days old.
211 'long-to To and/or Cc longer than 1024 characters.
212 'many-to Multiple To and/or Cc."
213 :type '(set (const :tag "Headers with no content." empty)
214 (const :tag "Newsgroups identical to Gnus group." newsgroups)
215 (const :tag "To identical to To-address." to-address)
216 (const :tag "To identical to To-list." to-list)
217 (const :tag "CC identical to To-list." cc-list)
218 (const :tag "Followup-to identical to Newsgroups." followup-to)
219 (const :tag "Reply-to identical to From." reply-to)
220 (const :tag "Date less than four days old." date)
221 (const :tag "To and/or Cc longer than 1024 characters." long-to)
222 (const :tag "Multiple To and/or Cc headers." many-to))
223 :group 'gnus-article-hiding)
225 (defcustom gnus-article-skip-boring nil
226 "Skip over text that is not worth reading.
227 By default, if you set this t, then Gnus will display citations and
228 signatures, but will never scroll down to show you a page consisting
229 only of boring text. Boring text is controlled by
230 `gnus-article-boring-faces'."
233 :group 'gnus-article-hiding)
235 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
236 "Regexp matching signature separator.
237 This can also be a list of regexps. In that case, it will be checked
238 from head to tail looking for a separator. Searches will be done from
239 the end of the buffer."
240 :type '(repeat string)
241 :group 'gnus-article-signature)
243 (defcustom gnus-signature-limit nil
244 "Provide a limit to what is considered a signature.
245 If it is a number, no signature may not be longer (in characters) than
246 that number. If it is a floating point number, no signature may be
247 longer (in lines) than that number. If it is a function, the function
248 will be called without any parameters, and if it returns nil, there is
249 no signature in the buffer. If it is a string, it will be used as a
250 regexp. If it matches, the text in question is not a signature.
252 This can also be a list of the above values."
253 :type '(choice (integer :value 200)
255 (function :value fun)
256 (regexp :value ".*"))
257 :group 'gnus-article-signature)
259 (defcustom gnus-hidden-properties '(invisible t intangible t)
260 "Property list to use for hiding text."
262 :group 'gnus-article-hiding)
264 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
265 ;; frames in a session.
266 (defcustom gnus-article-x-face-command
271 (if (or (gnus-image-type-available-p 'xface)
272 (gnus-image-type-available-p 'pbm))
273 'gnus-display-x-face-in-from
274 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -"))
275 ((gnus-image-type-available-p 'pbm)
276 'gnus-display-x-face-in-from)
278 (module-installed-p 'x-face-mule))
279 'x-face-mule-gnus-article-display-x-face)
281 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
283 "*String or function to be executed to display an X-Face header.
284 If it is a string, the command will be executed in a sub-shell
285 asynchronously. The compressed face will be piped to this command."
287 ,@(let ((x-face-mule (if (featurep 'xemacs)
289 (module-installed-p 'x-face-mule))))
293 (if (or (gnus-image-type-available-p 'xface)
294 (gnus-image-type-available-p 'pbm))
295 '(function-item gnus-display-x-face-in-from))
298 x-face-mule-gnus-article-display-x-face))
302 :group 'gnus-article-washing)
304 (defcustom gnus-article-x-face-too-ugly nil
305 "Regexp matching posters whose face shouldn't be shown automatically."
306 :type '(choice regexp (const nil))
307 :group 'gnus-article-washing)
309 (defcustom gnus-article-banner-alist nil
310 "Banner alist for stripping.
312 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
314 :type '(repeat (cons symbol regexp))
315 :group 'gnus-article-washing)
317 (gnus-define-group-parameter
320 "Alist of regexps (to match group names) and banner."
321 :variable-group gnus-article-washing
323 '(choice :tag "Banner"
325 (const :tag "Remove signature" signature)
326 (symbol :tag "Item in `gnus-article-banner-alist'" none)
328 (const :tag "None" nil))
330 "If non-nil, specify how to remove `banners' from articles.
332 Symbol `signature' means to remove signatures delimited by
333 `gnus-signature-separator'. Any other symbol is used to look up a
334 regular expression to match the banner in `gnus-article-banner-alist'.
335 A string is used as a regular expression to match the banner
338 (defcustom gnus-article-address-banner-alist nil
339 "Alist of mail addresses and banners.
340 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
341 to match a mail address in the From: header, BANNER is one of a symbol
342 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
343 If ADDRESS matches author's mail address, it will remove things like
344 advertisements. For example:
346 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
350 (regexp :tag "Address")
351 (choice :tag "Banner" :value nil
352 (const :tag "Remove signature" signature)
353 (symbol :tag "Item in `gnus-article-banner-alist'" none)
355 (const :tag "None" nil))))
357 :group 'gnus-article-washing)
359 (defmacro gnus-emphasis-custom-with-format (&rest body)
361 \\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\
362 \\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)"))
365 (defun gnus-emphasis-custom-value-to-external (value)
366 (gnus-emphasis-custom-with-format
367 (if (consp (car value))
368 (list (format format (car (car value)) (cdr (car value)))
370 (if (nth 1 value) 2 3)
374 (defun gnus-emphasis-custom-value-to-internal (value)
375 (gnus-emphasis-custom-with-format
376 (let ((regexp (concat "\\`"
377 (format (regexp-quote format)
378 "\\([^()]+\\)" "\\([^()]+\\)")
381 (if (string-match regexp (setq pattern (car value)))
382 (list (cons (match-string 1 pattern) (match-string 2 pattern))
387 (defcustom gnus-emphasis-alist
389 '(("\\*" "\\*" bold nil 2)
392 ("_/" "/_" underline-italic)
393 ("_\\*" "\\*_" underline-bold)
394 ("\\*/" "/\\*" bold-italic)
395 ("_\\*/" "/\\*_" underline-bold-italic))))
397 (gnus-emphasis-custom-with-format
398 (mapcar (lambda (spec)
399 (list (format format (car spec) (cadr spec))
402 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
404 '(("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
405 2 3 gnus-emphasis-underline))))
406 "*Alist that says how to fontify certain phrases.
407 Each item looks like this:
409 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
411 The first element is a regular expression to be matched. The second
412 is a number that says what regular expression grouping used to find
413 the entire emphasized word. The third is a number that says what
414 regexp grouping should be displayed and highlighted. The fourth
415 is the face used for highlighting."
419 :format "%[Customizing Style%]\n%v"
421 (group :tag "Default"
422 :value ("" 0 0 default)
425 (let ((value (widget-get
426 (cadr (widget-get (widget-get widget :parent)
429 (if (not (eq (nth 2 value) 'default))
433 (gnus-emphasis-custom-value-to-external value))))
434 (widget-group-value-create widget))
436 (integer :format "Match group: %v")
437 (integer :format "Emphasize group: %v")
440 :value (("_" . "_") nil default)
442 (regexp :format "Start regexp: %v")
443 (regexp :format "End regexp: %v"))
444 (boolean :format "Show start and end patterns: %[%v%]\n"
445 :on " On " :off " Off ")
447 :get (lambda (symbol)
448 (mapcar 'gnus-emphasis-custom-value-to-internal
449 (default-value symbol)))
450 :set (lambda (symbol value)
451 (set-default symbol (mapcar 'gnus-emphasis-custom-value-to-external
453 :group 'gnus-article-emphasis)
455 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
456 "A regexp to describe whitespace which should not be emphasized.
457 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
458 The former avoids underlining of leading and trailing whitespace,
459 and the latter avoids underlining any whitespace at all."
461 :group 'gnus-article-emphasis
464 (defface gnus-emphasis-bold '((t (:bold t)))
465 "Face used for displaying strong emphasized text (*word*)."
466 :group 'gnus-article-emphasis)
468 (defface gnus-emphasis-italic '((t (:italic t)))
469 "Face used for displaying italic emphasized text (/word/)."
470 :group 'gnus-article-emphasis)
472 (defface gnus-emphasis-underline '((t (:underline t)))
473 "Face used for displaying underlined emphasized text (_word_)."
474 :group 'gnus-article-emphasis)
476 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
477 "Face used for displaying underlined bold emphasized text (_*word*_)."
478 :group 'gnus-article-emphasis)
480 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
481 "Face used for displaying underlined italic emphasized text (_/word/_)."
482 :group 'gnus-article-emphasis)
484 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
485 "Face used for displaying bold italic emphasized text (/*word*/)."
486 :group 'gnus-article-emphasis)
488 (defface gnus-emphasis-underline-bold-italic
489 '((t (:bold t :italic t :underline t)))
490 "Face used for displaying underlined bold italic emphasized text.
491 Example: (_/*word*/_)."
492 :group 'gnus-article-emphasis)
494 (defface gnus-emphasis-strikethru (if (featurep 'xemacs)
495 '((t (:strikethru t)))
496 '((t (:strike-through t))))
497 "Face used for displaying strike-through text (-word-)."
498 :group 'gnus-article-emphasis)
500 (defface gnus-emphasis-highlight-words
501 '((t (:background "black" :foreground "yellow")))
502 "Face used for displaying highlighted words."
503 :group 'gnus-article-emphasis)
505 (defcustom gnus-article-time-format "%a, %d %b %Y %T %Z"
506 "Format for display of Date headers in article bodies.
507 See `format-time-string' for the possible values.
509 The variable can also be function, which should return a complete Date
510 header. The function is called with one argument, the time, which can
511 be fed to `format-time-string'."
512 :type '(choice string function)
513 :link '(custom-manual "(gnus)Article Date")
514 :group 'gnus-article-washing)
517 (autoload 'mail-extract-address-components "mail-extr"))
519 (defcustom gnus-save-all-headers t
520 "*If non-nil, don't remove any headers before saving."
521 :group 'gnus-article-saving
524 (defcustom gnus-prompt-before-saving 'always
525 "*This variable says how much prompting is to be done when saving articles.
526 If it is nil, no prompting will be done, and the articles will be
527 saved to the default files. If this variable is `always', each and
528 every article that is saved will be preceded by a prompt, even when
529 saving large batches of articles. If this variable is neither nil not
530 `always', there the user will be prompted once for a file name for
531 each invocation of the saving commands."
532 :group 'gnus-article-saving
533 :type '(choice (item always)
534 (item :tag "never" nil)
535 (sexp :tag "once" :format "%t\n" :value t)))
537 (defcustom gnus-saved-headers gnus-visible-headers
538 "Headers to keep if `gnus-save-all-headers' is nil.
539 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
540 If that variable is nil, however, all headers that match this regexp
541 will be kept while the rest will be deleted before saving."
542 :group 'gnus-article-saving
545 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
546 "A function to save articles in your favourite format.
547 The function must be interactively callable (in other words, it must
548 be an Emacs command).
550 Gnus provides the following functions:
552 * gnus-summary-save-in-rmail (Rmail format)
553 * gnus-summary-save-in-mail (Unix mail format)
554 * gnus-summary-save-in-folder (MH folder)
555 * gnus-summary-save-in-file (article format)
556 * gnus-summary-save-body-in-file (article body)
557 * gnus-summary-save-in-vm (use VM's folder format)
558 * gnus-summary-write-to-file (article format -- overwrite)."
559 :group 'gnus-article-saving
560 :type '(radio (function-item gnus-summary-save-in-rmail)
561 (function-item gnus-summary-save-in-mail)
562 (function-item gnus-summary-save-in-folder)
563 (function-item gnus-summary-save-in-file)
564 (function-item gnus-summary-save-body-in-file)
565 (function-item gnus-summary-save-in-vm)
566 (function-item gnus-summary-write-to-file)))
568 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
569 "A function generating a file name to save articles in Rmail format.
570 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
571 :group 'gnus-article-saving
574 (defcustom gnus-mail-save-name 'gnus-plain-save-name
575 "A function generating a file name to save articles in Unix mail format.
576 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
577 :group 'gnus-article-saving
580 (defcustom gnus-folder-save-name 'gnus-folder-save-name
581 "A function generating a file name to save articles in MH folder.
582 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
583 :group 'gnus-article-saving
586 (defcustom gnus-file-save-name 'gnus-numeric-save-name
587 "A function generating a file name to save articles in article format.
588 The function is called with NEWSGROUP, HEADERS, and optional
590 :group 'gnus-article-saving
593 (defcustom gnus-split-methods
594 '((gnus-article-archive-name)
595 (gnus-article-nndoc-name))
596 "*Variable used to suggest where articles are to be saved.
597 For instance, if you would like to save articles related to Gnus in
598 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
599 you could set this variable to something like:
601 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
602 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
604 This variable is an alist where the key is the match and the
605 value is a list of possible files to save in if the match is
608 If the match is a string, it is used as a regexp match on the
609 article. If the match is a symbol, that symbol will be funcalled
610 from the buffer of the article to be saved with the newsgroup as
611 the parameter. If it is a list, it will be evaled in the same
614 If this form or function returns a string, this string will be
615 used as a possible file name; and if it returns a non-nil list,
616 that list will be used as possible file names."
617 :group 'gnus-article-saving
618 :type '(repeat (choice (list :value (fun) function)
619 (cons :value ("" "") regexp (repeat string))
622 (defcustom gnus-article-display-method-for-mime
623 'gnus-article-display-mime-message
624 "Function to display a MIME message.
625 The function is called from the article buffer."
626 :group 'gnus-article-mime
629 (defcustom gnus-article-display-method-for-traditional
630 'gnus-article-display-traditional-message
631 "*Function to display a traditional message.
632 The function is called from the article buffer."
633 :group 'gnus-article-mime
636 (defcustom gnus-page-delimiter "^\^L"
637 "*Regexp describing what to use as article page delimiters.
638 The default value is \"^\^L\", which is a form linefeed at the
639 beginning of a line."
641 :group 'gnus-article-various)
643 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
644 "*The format specification for the article mode line.
645 See `gnus-summary-mode-line-format' for a closer description.
647 The following additional specs are available:
649 %w The article washing status.
650 %m The number of MIME parts in the article."
652 :group 'gnus-article-various)
654 (defcustom gnus-article-mode-hook nil
655 "*A hook for Gnus article mode."
657 :group 'gnus-article-various)
659 (when (featurep 'xemacs)
660 ;; Extracted from gnus-xmas-define in order to preserve user settings
661 (when (fboundp 'turn-off-scroll-in-place)
662 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
663 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
664 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
666 (defcustom gnus-article-menu-hook nil
667 "*Hook run after the creation of the article mode menu."
669 :group 'gnus-article-various)
671 (defcustom gnus-article-prepare-hook nil
672 "*A hook called after an article has been prepared in the article buffer."
674 :group 'gnus-article-various)
676 (defcustom gnus-copy-article-ignored-headers nil
677 "List of headers to be removed when copying an article.
678 Each element is a regular expression."
679 :version "22.0" ;; No Gnus
680 :type '(repeat regexp)
681 :group 'gnus-article-various)
683 (make-obsolete-variable 'gnus-article-hide-pgp-hook
684 "This variable is obsolete in Gnus 5.10.")
686 (defcustom gnus-article-button-face 'bold
687 "Face used for highlighting buttons in the article buffer.
689 An article button is a piece of text that you can activate by pressing
690 `RET' or `mouse-2' above it."
692 :group 'gnus-article-buttons)
694 (defcustom gnus-article-mouse-face 'highlight
695 "Face used for mouse highlighting in the article buffer.
697 Article buttons will be displayed in this face when the cursor is
700 :group 'gnus-article-buttons)
702 (defcustom gnus-signature-face 'gnus-signature-face
703 "Face used for highlighting a signature in the article buffer.
704 Obsolete; use the face `gnus-signature-face' for customizations instead."
706 :group 'gnus-article-highlight
707 :group 'gnus-article-signature)
709 (defface gnus-signature-face
712 "Face used for highlighting a signature in the article buffer."
713 :group 'gnus-article-highlight
714 :group 'gnus-article-signature)
716 (defface gnus-header-from-face
719 (:foreground "spring green"))
722 (:foreground "red3"))
725 "Face used for displaying from headers."
726 :group 'gnus-article-headers
727 :group 'gnus-article-highlight)
729 (defface gnus-header-subject-face
732 (:foreground "SeaGreen3"))
735 (:foreground "red4"))
737 (:bold t :italic t)))
738 "Face used for displaying subject headers."
739 :group 'gnus-article-headers
740 :group 'gnus-article-highlight)
742 (defface gnus-header-newsgroups-face
745 (:foreground "yellow" :italic t))
748 (:foreground "MidnightBlue" :italic t))
751 "Face used for displaying newsgroups headers.
752 In the default setup this face is only used for crossposted
754 :group 'gnus-article-headers
755 :group 'gnus-article-highlight)
757 (defface gnus-header-name-face
760 (:foreground "SeaGreen"))
763 (:foreground "maroon"))
766 "Face used for displaying header names."
767 :group 'gnus-article-headers
768 :group 'gnus-article-highlight)
770 (defface gnus-header-content-face
773 (:foreground "forest green" :italic t))
776 (:foreground "indianred4" :italic t))
779 "Face used for displaying header content."
780 :group 'gnus-article-headers
781 :group 'gnus-article-highlight)
783 (defcustom gnus-header-face-alist
784 '(("From" nil gnus-header-from-face)
785 ("Subject" nil gnus-header-subject-face)
786 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
787 ("" gnus-header-name-face gnus-header-content-face))
788 "*Controls highlighting of article headers.
790 An alist of the form (HEADER NAME CONTENT).
792 HEADER is a regular expression which should match the name of a
793 header and NAME and CONTENT are either face names or nil.
795 The name of each header field will be displayed using the face
796 specified by the first element in the list where HEADER matches
797 the header name and NAME is non-nil. Similarly, the content will
798 be displayed by the first non-nil matching CONTENT face."
799 :group 'gnus-article-headers
800 :group 'gnus-article-highlight
801 :type '(repeat (list (regexp :tag "Header")
803 (item :tag "skip" nil)
804 (face :value default))
805 (choice :tag "Content"
806 (item :tag "skip" nil)
807 (face :value default)))))
809 (defcustom gnus-article-decode-hook
810 '(article-decode-group-name article-decode-idna-rhs)
811 "*Hook run to decode charsets in articles."
812 :group 'gnus-article-headers
815 (defcustom gnus-display-mime-function 'gnus-display-mime
816 "Function to display MIME articles."
817 :group 'gnus-article-mime
820 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
821 "Function used to decode headers.")
823 (defvar gnus-article-dumbquotes-map
843 "Table for MS-to-Latin1 translation.")
845 (defcustom gnus-ignored-mime-types nil
846 "List of MIME types that should be ignored by Gnus."
848 :group 'gnus-article-mime
849 :type '(repeat regexp))
851 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
852 "List of MIME types that should not be given buttons when rendered inline.
853 See also `gnus-buttonized-mime-types' which may override this variable.
854 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
856 :group 'gnus-article-mime
857 :type '(repeat regexp))
859 (defcustom gnus-buttonized-mime-types nil
860 "List of MIME types that should be given buttons when rendered inline.
861 If set, this variable overrides `gnus-unbuttonized-mime-types'.
862 To see e.g. security buttons you could set this to
863 `(\"multipart/signed\")'.
864 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
866 :group 'gnus-article-mime
867 :type '(repeat regexp))
869 (defcustom gnus-inhibit-mime-unbuttonizing nil
870 "If non-nil, all MIME parts get buttons.
871 When nil (the default value), then some MIME parts do not get buttons,
872 as described by the variables `gnus-buttonized-mime-types' and
873 `gnus-unbuttonized-mime-types'."
875 :group 'gnus-article-mime
878 (defcustom gnus-body-boundary-delimiter "_"
879 "String used to delimit header and body.
880 This variable is used by `gnus-article-treat-body-boundary' which can
881 be controlled by `gnus-treat-body-boundary'."
883 :group 'gnus-article-various
884 :type '(choice (item :tag "None" :value nil)
887 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces"
889 "Defines the location of the faces database.
890 For information on obtaining this database of pretty pictures, please
891 see http://www.cs.indiana.edu/picons/ftp/index.html"
893 :type '(repeat directory)
894 :link '(url-link :tag "download"
895 "http://www.cs.indiana.edu/picons/ftp/index.html")
896 :link '(custom-manual "(gnus)Picons")
899 (defun gnus-picons-installed-p ()
900 "Say whether picons are installed on your machine."
901 (let ((installed nil))
902 (dolist (database gnus-picon-databases)
903 (when (file-exists-p database)
907 (defcustom gnus-article-mime-part-function nil
908 "Function called with a MIME handle as the argument.
909 This is meant for people who want to do something automatic based
910 on parts -- for instance, adding Vcard info to a database."
911 :group 'gnus-article-mime
914 (defcustom gnus-mime-multipart-functions nil
915 "An alist of MIME types to functions to display them."
917 :group 'gnus-article-mime
918 :type '(repeat (cons :format "%v" (string :tag "MIME type") function)))
920 (defcustom gnus-article-date-lapsed-new-header nil
921 "Whether the X-Sent and Date headers can coexist.
922 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
923 either replace the old \"Date:\" header (if this variable is nil), or
924 be added below it (otherwise)."
926 :group 'gnus-article-headers
929 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
930 "Function called with a MIME handle as the argument.
931 This is meant for people who want to view first matched part.
932 For `undisplayed-alternative' (default), the first undisplayed
933 part or alternative part is used. For `undisplayed', the first
934 undisplayed part is used. For a function, the first part which
935 the function return t is used. For nil, the first part is
938 :group 'gnus-article-mime
940 (item :tag "first" :value nil)
941 (item :tag "undisplayed" :value undisplayed)
942 (item :tag "undisplayed or alternative"
943 :value undisplayed-alternative)
946 (defcustom gnus-mime-action-alist
947 '(("save to file" . gnus-mime-save-part)
948 ("save and strip" . gnus-mime-save-part-and-strip)
949 ("delete part" . gnus-mime-delete-part)
950 ("display as text" . gnus-mime-inline-part)
951 ("view the part" . gnus-mime-view-part)
952 ("pipe to command" . gnus-mime-pipe-part)
953 ("toggle display" . gnus-article-press-button)
954 ("toggle display" . gnus-article-view-part-as-charset)
955 ("view as type" . gnus-mime-view-part-as-type)
956 ("view internally" . gnus-mime-view-part-internally)
957 ("view externally" . gnus-mime-view-part-externally))
958 "An alist of actions that run on the MIME attachment."
959 :group 'gnus-article-mime
960 :type '(repeat (cons (string :tag "name")
964 ;;; The treatment variables
967 (defvar gnus-part-display-hook nil
968 "Hook called on parts that are to receive treatment.")
970 (defvar gnus-article-treat-custom
971 '(choice (const :tag "Off" nil)
973 (const :tag "Header" head)
974 (const :tag "Last" last)
975 (const :tag "Mime" mime)
976 (integer :tag "Less")
977 (repeat :tag "Groups" regexp)
978 (sexp :tag "Predicate")))
980 (defvar gnus-article-treat-head-custom
981 '(choice (const :tag "Off" nil)
982 (const :tag "Header" head)))
984 (defvar gnus-article-treat-types '("text/plain")
987 (defvar gnus-inhibit-treatment nil
988 "Whether to inhibit treatment.")
990 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
991 "Highlight the signature.
992 Valid values are nil, t, `head', `last', an integer or a predicate.
993 See Info node `(gnus)Customizing Articles'."
994 :group 'gnus-article-treat
995 :link '(custom-manual "(gnus)Customizing Articles")
996 :type gnus-article-treat-custom)
997 (put 'gnus-treat-highlight-signature 'highlight t)
999 (defcustom gnus-treat-buttonize 100000
1001 Valid values are nil, t, `head', `last', an integer or a predicate.
1002 See Info node `(gnus)Customizing Articles'."
1003 :group 'gnus-article-treat
1004 :link '(custom-manual "(gnus)Customizing Articles")
1005 :type gnus-article-treat-custom)
1006 (put 'gnus-treat-buttonize 'highlight t)
1008 (defcustom gnus-treat-buttonize-head 'head
1009 "Add buttons to the head.
1010 Valid values are nil, t, `head', `last', an integer or a predicate.
1011 See Info node `(gnus)Customizing Articles' for details."
1012 :group 'gnus-article-treat
1013 :link '(custom-manual "(gnus)Customizing Articles")
1014 :type gnus-article-treat-head-custom)
1015 (put 'gnus-treat-buttonize-head 'highlight t)
1017 (defcustom gnus-treat-emphasize
1018 (and (or window-system
1022 Valid values are nil, t, `head', `last', an integer or a predicate.
1023 See Info node `(gnus)Customizing Articles' for details."
1024 :group 'gnus-article-treat
1025 :link '(custom-manual "(gnus)Customizing Articles")
1026 :type gnus-article-treat-custom)
1027 (put 'gnus-treat-emphasize 'highlight t)
1029 (defcustom gnus-treat-strip-cr nil
1030 "Remove carriage returns.
1031 Valid values are nil, t, `head', `last', an integer or a predicate.
1032 See Info node `(gnus)Customizing Articles' for details."
1034 :group 'gnus-article-treat
1035 :link '(custom-manual "(gnus)Customizing Articles")
1036 :type gnus-article-treat-custom)
1038 (defcustom gnus-treat-unsplit-urls nil
1039 "Remove newlines from within URLs.
1040 Valid values are nil, t, `head', `last', an integer or a predicate.
1041 See Info node `(gnus)Customizing Articles' for details."
1043 :group 'gnus-article-treat
1044 :link '(custom-manual "(gnus)Customizing Articles")
1045 :type gnus-article-treat-custom)
1047 (defcustom gnus-treat-leading-whitespace nil
1048 "Remove leading whitespace in headers.
1049 Valid values are nil, t, `head', `last', an integer or a predicate.
1050 See Info node `(gnus)Customizing Articles' for details."
1052 :group 'gnus-article-treat
1053 :link '(custom-manual "(gnus)Customizing Articles")
1054 :type gnus-article-treat-custom)
1056 (defcustom gnus-treat-hide-headers 'head
1058 Valid values are nil, t, `head', `last', an integer or a predicate.
1059 See Info node `(gnus)Customizing Articles' for details."
1060 :group 'gnus-article-treat
1061 :link '(custom-manual "(gnus)Customizing Articles")
1062 :type gnus-article-treat-head-custom)
1064 (defcustom gnus-treat-hide-boring-headers nil
1065 "Hide boring headers.
1066 Valid values are nil, t, `head', `last', an integer or a predicate.
1067 See Info node `(gnus)Customizing Articles' for details."
1068 :group 'gnus-article-treat
1069 :link '(custom-manual "(gnus)Customizing Articles")
1070 :type gnus-article-treat-head-custom)
1072 (defcustom gnus-treat-hide-signature nil
1073 "Hide the signature.
1074 Valid values are nil, t, `head', `last', an integer or a predicate.
1075 See Info node `(gnus)Customizing Articles' for details."
1076 :group 'gnus-article-treat
1077 :link '(custom-manual "(gnus)Customizing Articles")
1078 :type gnus-article-treat-custom)
1080 (defcustom gnus-treat-fill-article nil
1082 Valid values are nil, t, `head', `last', an integer or a predicate.
1083 See Info node `(gnus)Customizing Articles' for details."
1084 :group 'gnus-article-treat
1085 :link '(custom-manual "(gnus)Customizing Articles")
1086 :type gnus-article-treat-custom)
1088 (defcustom gnus-treat-hide-citation nil
1090 Valid values are nil, t, `head', `last', an integer or a predicate.
1091 See Info node `(gnus)Customizing Articles' for details."
1092 :group 'gnus-article-treat
1093 :link '(custom-manual "(gnus)Customizing Articles")
1094 :type gnus-article-treat-custom)
1096 (defcustom gnus-treat-hide-citation-maybe nil
1098 Valid values are nil, t, `head', `last', an integer or a predicate.
1099 See Info node `(gnus)Customizing Articles' for details."
1100 :group 'gnus-article-treat
1101 :link '(custom-manual "(gnus)Customizing Articles")
1102 :type gnus-article-treat-custom)
1104 (defcustom gnus-treat-strip-list-identifiers 'head
1105 "Strip list identifiers from `gnus-list-identifiers`.
1106 Valid values are nil, t, `head', `last', an integer or a predicate.
1107 See Info node `(gnus)Customizing Articles' for details."
1109 :group 'gnus-article-treat
1110 :link '(custom-manual "(gnus)Customizing Articles")
1111 :type gnus-article-treat-custom)
1113 (make-obsolete-variable 'gnus-treat-strip-pgp
1114 "This option is obsolete in Gnus 5.10.")
1116 (defcustom gnus-treat-strip-pem nil
1117 "Strip PEM signatures.
1118 Valid values are nil, t, `head', `last', an integer or a predicate.
1119 See Info node `(gnus)Customizing Articles' for details."
1120 :group 'gnus-article-treat
1121 :link '(custom-manual "(gnus)Customizing Articles")
1122 :type gnus-article-treat-custom)
1124 (defcustom gnus-treat-strip-banner t
1125 "Strip banners from articles.
1126 The banner to be stripped is specified in the `banner' group parameter.
1127 Valid values are nil, t, `head', `last', an integer or a predicate.
1128 See Info node `(gnus)Customizing Articles' for details."
1129 :group 'gnus-article-treat
1130 :link '(custom-manual "(gnus)Customizing Articles")
1131 :type gnus-article-treat-custom)
1133 (defcustom gnus-treat-highlight-headers 'head
1134 "Highlight the headers.
1135 Valid values are nil, t, `head', `last', an integer or a predicate.
1136 See Info node `(gnus)Customizing Articles' for details."
1137 :group 'gnus-article-treat
1138 :link '(custom-manual "(gnus)Customizing Articles")
1139 :type gnus-article-treat-head-custom)
1140 (put 'gnus-treat-highlight-headers 'highlight t)
1142 (defcustom gnus-treat-highlight-citation t
1143 "Highlight cited text.
1144 Valid values are nil, t, `head', `last', an integer or a predicate.
1145 See Info node `(gnus)Customizing Articles' for details."
1146 :group 'gnus-article-treat
1147 :link '(custom-manual "(gnus)Customizing Articles")
1148 :type gnus-article-treat-custom)
1149 (put 'gnus-treat-highlight-citation 'highlight t)
1151 (defcustom gnus-treat-date-ut nil
1152 "Display the Date in UT (GMT).
1153 Valid values are nil, t, `head', `last', an integer or a predicate.
1154 See Info node `(gnus)Customizing Articles' for details."
1155 :group 'gnus-article-treat
1156 :link '(custom-manual "(gnus)Customizing Articles")
1157 :type gnus-article-treat-head-custom)
1159 (defcustom gnus-treat-date-local nil
1160 "Display the Date in the local timezone.
1161 Valid values are nil, t, `head', `last', an integer or a predicate.
1162 See Info node `(gnus)Customizing Articles' for details."
1163 :group 'gnus-article-treat
1164 :link '(custom-manual "(gnus)Customizing Articles")
1165 :type gnus-article-treat-head-custom)
1167 (defcustom gnus-treat-date-english nil
1168 "Display the Date in a format that can be read aloud in English.
1169 Valid values are nil, t, `head', `last', an integer or a predicate.
1170 See Info node `(gnus)Customizing Articles' for details."
1172 :group 'gnus-article-treat
1173 :link '(custom-manual "(gnus)Customizing Articles")
1174 :type gnus-article-treat-head-custom)
1176 (defcustom gnus-treat-date-lapsed nil
1177 "Display the Date header in a way that says how much time has elapsed.
1178 Valid values are nil, t, `head', `last', an integer or a predicate.
1179 See Info node `(gnus)Customizing Articles' for details."
1180 :group 'gnus-article-treat
1181 :link '(custom-manual "(gnus)Customizing Articles")
1182 :type gnus-article-treat-head-custom)
1184 (defcustom gnus-treat-date-original nil
1185 "Display the date in the original timezone.
1186 Valid values are nil, t, `head', `last', an integer or a predicate.
1187 See Info node `(gnus)Customizing Articles' for details."
1188 :group 'gnus-article-treat
1189 :link '(custom-manual "(gnus)Customizing Articles")
1190 :type gnus-article-treat-head-custom)
1192 (defcustom gnus-treat-date-iso8601 nil
1193 "Display the date in the ISO8601 format.
1194 Valid values are nil, t, `head', `last', an integer or a predicate.
1195 See Info node `(gnus)Customizing Articles' for details."
1197 :group 'gnus-article-treat
1198 :link '(custom-manual "(gnus)Customizing Articles")
1199 :type gnus-article-treat-head-custom)
1201 (defcustom gnus-treat-date-user-defined nil
1202 "Display the date in a user-defined format.
1203 The format is defined by the `gnus-article-time-format' variable.
1204 Valid values are nil, t, `head', `last', an integer or a predicate.
1205 See Info node `(gnus)Customizing Articles' for details."
1206 :group 'gnus-article-treat
1207 :link '(custom-manual "(gnus)Customizing Articles")
1208 :type gnus-article-treat-head-custom)
1210 (defcustom gnus-treat-strip-headers-in-body t
1211 "Strip the X-No-Archive header line from the beginning of the body.
1212 Valid values are nil, t, `head', `last', an integer or a predicate.
1213 See Info node `(gnus)Customizing Articles' for details."
1215 :group 'gnus-article-treat
1216 :link '(custom-manual "(gnus)Customizing Articles")
1217 :type gnus-article-treat-custom)
1219 (defcustom gnus-treat-strip-trailing-blank-lines nil
1220 "Strip trailing blank lines.
1221 Valid values are nil, t, `head', `last', an integer or a predicate.
1222 See Info node `(gnus)Customizing Articles' for details."
1223 :group 'gnus-article-treat
1224 :link '(custom-manual "(gnus)Customizing Articles")
1225 :type gnus-article-treat-custom)
1227 (defcustom gnus-treat-strip-leading-blank-lines nil
1228 "Strip leading blank lines.
1229 Valid values are nil, t, `head', `last', an integer or a predicate.
1230 See Info node `(gnus)Customizing Articles' for details."
1231 :group 'gnus-article-treat
1232 :link '(custom-manual "(gnus)Customizing Articles")
1233 :type gnus-article-treat-custom)
1235 (defcustom gnus-treat-strip-multiple-blank-lines nil
1236 "Strip multiple blank lines.
1237 Valid values are nil, t, `head', `last', an integer or a predicate.
1238 See Info node `(gnus)Customizing Articles' for details."
1239 :group 'gnus-article-treat
1240 :link '(custom-manual "(gnus)Customizing Articles")
1241 :type gnus-article-treat-custom)
1243 (defcustom gnus-treat-unfold-headers 'head
1244 "Unfold folded header lines.
1245 Valid values are nil, t, `head', `last', an integer or a predicate.
1246 See Info node `(gnus)Customizing Articles' for details."
1248 :group 'gnus-article-treat
1249 :link '(custom-manual "(gnus)Customizing Articles")
1250 :type gnus-article-treat-custom)
1252 (defcustom gnus-treat-fold-headers nil
1254 Valid values are nil, t, `head', `last', an integer or a predicate.
1255 See Info node `(gnus)Customizing Articles' for details."
1257 :group 'gnus-article-treat
1258 :link '(custom-manual "(gnus)Customizing Articles")
1259 :type gnus-article-treat-custom)
1261 (defcustom gnus-treat-fold-newsgroups 'head
1262 "Fold the Newsgroups and Followup-To headers.
1263 Valid values are nil, t, `head', `last', an integer or a predicate.
1264 See Info node `(gnus)Customizing Articles' for details."
1266 :group 'gnus-article-treat
1267 :link '(custom-manual "(gnus)Customizing Articles")
1268 :type gnus-article-treat-custom)
1270 (defcustom gnus-treat-overstrike t
1271 "Treat overstrike highlighting.
1272 Valid values are nil, t, `head', `last', an integer or a predicate.
1273 See Info node `(gnus)Customizing Articles' for details."
1274 :group 'gnus-article-treat
1275 :link '(custom-manual "(gnus)Customizing Articles")
1276 :type gnus-article-treat-custom)
1277 (put 'gnus-treat-overstrike 'highlight t)
1279 (defcustom gnus-treat-ansi-sequences (if (locate-library "ansi-color") t)
1280 "Treat ANSI SGR control sequences.
1281 Valid values are nil, t, `head', `last', an integer or a predicate.
1282 See Info node `(gnus)Customizing Articles' for details."
1283 :group 'gnus-article-treat
1284 :link '(custom-manual "(gnus)Customizing Articles")
1285 :type gnus-article-treat-custom)
1287 (make-obsolete-variable 'gnus-treat-display-xface
1288 'gnus-treat-display-x-face)
1290 (defcustom gnus-treat-display-x-face
1291 (and (not noninteractive)
1292 (or (eq gnus-article-x-face-command
1293 'x-face-mule-gnus-article-display-x-face)
1294 (and (fboundp 'image-type-available-p)
1295 (image-type-available-p 'xbm)
1296 (string-match "^0x" (shell-command-to-string "uncompface"))
1297 (executable-find "icontopbm"))
1298 (and (featurep 'xemacs)
1301 "Display X-Face headers.
1302 Valid values are nil, t, `head', `last', an integer or a predicate.
1303 See Info node `(gnus)Customizing Articles' and Info node
1304 `(gnus)X-Face' for details."
1305 :group 'gnus-article-treat
1307 :link '(custom-manual "(gnus)Customizing Articles")
1308 :link '(custom-manual "(gnus)X-Face")
1309 :type gnus-article-treat-head-custom
1310 :set (lambda (symbol value)
1313 (cond ((or (boundp symbol) (get symbol 'saved-value))
1315 ((boundp 'gnus-treat-display-xface)
1317 ** gnus-treat-display-xface is an obsolete variable;\
1318 use gnus-treat-display-x-face instead")
1319 (default-value 'gnus-treat-display-xface))
1320 ((get 'gnus-treat-display-xface 'saved-value)
1322 ** gnus-treat-display-xface is an obsolete variable;\
1323 use gnus-treat-display-x-face instead")
1324 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1327 (put 'gnus-treat-display-x-face 'highlight t)
1329 (defcustom gnus-article-should-use-smiley-mule
1330 (not (or (featurep 'xemacs)
1331 (gnus-image-type-available-p 'xpm)
1332 (gnus-image-type-available-p 'pbm)))
1333 "Non-nil means use `smiley-mule' to show smileys rather than `smiley'.
1334 `smiley-mule' is boundled in BITMAP-MULE package. You can set it to t
1335 even if your Emacs supports images. It has no effect on XEmacs."
1336 :group 'gnus-article-various
1338 :get (lambda (symbol)
1339 (and (not noninteractive)
1340 (default-value symbol)
1341 (not (featurep 'xemacs))
1342 (module-installed-p 'smiley-mule)
1344 :set (lambda (symbol value)
1345 (set-default symbol (and (not noninteractive)
1347 (not (featurep 'xemacs))
1348 (module-installed-p 'smiley-mule)
1351 (defvar gnus-article-smiley-mule-loaded-p nil
1352 "Internal variable used to say whether `smiley-mule' is loaded (whether
1353 smiley functions are not overridden by `smiley').")
1355 (defcustom gnus-treat-display-face
1356 (and (not noninteractive)
1357 (or (and (fboundp 'image-type-available-p)
1358 (image-type-available-p 'png))
1359 (and (featurep 'xemacs)
1362 "Display Face headers.
1363 Valid values are nil, t, `head', `last', an integer or a predicate.
1364 See Info node `(gnus)Customizing Articles' and Info node
1365 `(gnus)X-Face' for details."
1366 :group 'gnus-article-treat
1368 :link '(custom-manual "(gnus)Customizing Articles")
1369 :link '(custom-manual "(gnus)X-Face")
1370 :type gnus-article-treat-head-custom)
1371 (put 'gnus-treat-display-face 'highlight t)
1373 (defcustom gnus-treat-display-smileys
1374 (if (and (not noninteractive)
1375 (or (and (featurep 'xemacs)
1377 (gnus-image-type-available-p 'xpm)
1378 (gnus-image-type-available-p 'pbm)
1379 (and (not (featurep 'xemacs))
1381 (module-installed-p 'smiley-mule))))
1385 Valid values are nil, t, `head', `last', an integer or a predicate.
1386 See Info node `(gnus)Customizing Articles' and Info node
1387 `(gnus)Smileys' for details."
1388 :group 'gnus-article-treat
1390 :link '(custom-manual "(gnus)Customizing Articles")
1391 :link '(custom-manual "(gnus)Smileys")
1392 :type gnus-article-treat-custom)
1393 (put 'gnus-treat-display-smileys 'highlight t)
1395 (defcustom gnus-treat-from-picon
1396 (if (and (gnus-image-type-available-p 'xpm)
1397 (gnus-picons-installed-p))
1399 "Display picons in the From header.
1400 Valid values are nil, t, `head', `last', an integer or a predicate.
1401 See Info node `(gnus)Customizing Articles' and Info node
1402 `(gnus)Picons' for details."
1404 :group 'gnus-article-treat
1406 :link '(custom-manual "(gnus)Customizing Articles")
1407 :link '(custom-manual "(gnus)Picons")
1408 :type gnus-article-treat-head-custom)
1409 (put 'gnus-treat-from-picon 'highlight t)
1411 (defcustom gnus-treat-mail-picon
1412 (if (and (gnus-image-type-available-p 'xpm)
1413 (gnus-picons-installed-p))
1415 "Display picons in To and Cc headers.
1416 Valid values are nil, t, `head', `last', an integer or a predicate.
1417 See Info node `(gnus)Customizing Articles' and Info node
1418 `(gnus)Picons' for details."
1420 :group 'gnus-article-treat
1422 :link '(custom-manual "(gnus)Customizing Articles")
1423 :link '(custom-manual "(gnus)Picons")
1424 :type gnus-article-treat-head-custom)
1425 (put 'gnus-treat-mail-picon 'highlight t)
1427 (defcustom gnus-treat-newsgroups-picon
1428 (if (and (gnus-image-type-available-p 'xpm)
1429 (gnus-picons-installed-p))
1431 "Display picons in the Newsgroups and Followup-To headers.
1432 Valid values are nil, t, `head', `last', an integer or a predicate.
1433 See Info node `(gnus)Customizing Articles' and Info node
1434 `(gnus)Picons' for details."
1436 :group 'gnus-article-treat
1438 :link '(custom-manual "(gnus)Customizing Articles")
1439 :link '(custom-manual "(gnus)Picons")
1440 :type gnus-article-treat-head-custom)
1441 (put 'gnus-treat-newsgroups-picon 'highlight t)
1443 (defcustom gnus-treat-body-boundary
1444 (if (and (eq window-system 'x)
1445 (or gnus-treat-newsgroups-picon
1446 gnus-treat-mail-picon
1447 gnus-treat-from-picon))
1449 "Draw a boundary at the end of the headers.
1450 Valid values are nil and `head'.
1451 See Info node `(gnus)Customizing Articles' for details."
1453 :group 'gnus-article-treat
1454 :link '(custom-manual "(gnus)Customizing Articles")
1455 :type gnus-article-treat-head-custom)
1457 (defcustom gnus-treat-capitalize-sentences nil
1458 "Capitalize sentence-starting words.
1459 Valid values are nil, t, `head', `last', an integer or a predicate.
1460 See Info node `(gnus)Customizing Articles' for details."
1462 :group 'gnus-article-treat
1463 :link '(custom-manual "(gnus)Customizing Articles")
1464 :type gnus-article-treat-custom)
1466 (defcustom gnus-treat-wash-html nil
1468 Valid values are nil, t, `head', `last', an integer or a predicate.
1469 See Info node `(gnus)Customizing Articles' for details."
1471 :group 'gnus-article-treat
1472 :link '(custom-manual "(gnus)Customizing Articles")
1473 :type gnus-article-treat-custom)
1475 (defcustom gnus-treat-fill-long-lines nil
1477 Valid values are nil, t, `head', `last', an integer or a predicate.
1478 See Info node `(gnus)Customizing Articles' for details."
1479 :group 'gnus-article-treat
1480 :link '(custom-manual "(gnus)Customizing Articles")
1481 :type gnus-article-treat-custom)
1483 (defcustom gnus-treat-play-sounds nil
1485 Valid values are nil, t, `head', `last', an integer or a predicate.
1486 See Info node `(gnus)Customizing Articles' for details."
1488 :group 'gnus-article-treat
1489 :link '(custom-manual "(gnus)Customizing Articles")
1490 :type gnus-article-treat-custom)
1492 (defcustom gnus-treat-decode-article-as-default-mime-charset nil
1493 "Decode an article as `default-mime-charset'. For instance, if you want to
1494 attempt to decode an article even if the value of `gnus-show-mime' is nil,
1495 you could set this variable to something like: nil for don't decode, t for
1496 decode the body, '(or header t) for the whole article, etc."
1497 :group 'gnus-article-treat
1498 :type '(radio (const :tag "Off" nil)
1499 (const :tag "Decode body" t)
1500 (const :tag "Decode all" (or head t))))
1502 (defcustom gnus-treat-translate nil
1503 "Translate articles from one language to another.
1504 Valid values are nil, t, `head', `last', an integer or a predicate.
1505 See Info node `(gnus)Customizing Articles' for details."
1507 :group 'gnus-article-treat
1508 :link '(custom-manual "(gnus)Customizing Articles")
1509 :type gnus-article-treat-custom)
1511 (defcustom gnus-treat-x-pgp-sig nil
1513 To automatically treat X-PGP-Sig, set it to head.
1514 Valid values are nil, t, `head', `last', an integer or a predicate.
1515 See Info node `(gnus)Customizing Articles' for details."
1517 :group 'gnus-article-treat
1518 :group 'mime-security
1519 :type gnus-article-treat-custom)
1521 (defcustom gnus-treat-monafy nil
1522 "Display body part with mona font.
1523 Valid values are nil, t, `head', `last', an integer or a predicate.
1524 See Info node `(gnus)Customizing Articles' for details."
1525 :group 'gnus-article-treat
1526 :group 'mime-security
1527 :link '(custom-manual "(gnus)Customizing Articles")
1528 :type gnus-article-treat-custom)
1530 (defvar gnus-article-encrypt-protocol-alist
1531 '(("PGP" . mml2015-self-encrypt)))
1533 ;; Set to nil if more than one protocol added to
1534 ;; gnus-article-encrypt-protocol-alist.
1535 (defcustom gnus-article-encrypt-protocol "PGP"
1536 "The protocol used for encrypt articles.
1537 It is a string, such as \"PGP\". If nil, ask user."
1540 :group 'mime-security)
1542 (defvar gnus-article-wash-function nil
1543 "Function used for converting HTML into text.")
1545 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1546 (mm-coding-system-p 'utf-8)
1547 (executable-find idna-program))
1548 "Whether IDNA decoding of headers is used when viewing messages.
1549 This requires GNU Libidn, and by default only enabled if it is found."
1551 :group 'gnus-article-headers
1554 (defcustom gnus-article-over-scroll nil
1555 "If non-nil, allow scrolling the article buffer even when there no more text."
1557 :group 'gnus-article
1560 ;;; Internal variables
1562 (defvar gnus-english-month-names
1563 '("January" "February" "March" "April" "May" "June" "July" "August"
1564 "September" "October" "November" "December"))
1566 (defvar gnus-button-regexp nil)
1567 (defvar gnus-button-marker-list nil)
1568 ;; Regexp matching any of the regexps from `gnus-button-alist'.
1570 (defvar gnus-button-last nil)
1571 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
1573 (defvar article-goto-body-goes-to-point-min-p nil)
1574 (defvar gnus-article-wash-types nil)
1575 (defvar gnus-article-emphasis-alist nil)
1576 (defvar gnus-article-image-alist nil)
1578 (defvar gnus-article-mime-handle-alist-1 nil)
1579 (defvar gnus-treatment-function-alist
1580 '((gnus-treat-decode-article-as-default-mime-charset
1581 gnus-article-decode-article-as-default-mime-charset)
1582 (gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1583 (gnus-treat-monafy gnus-article-monafy)
1584 (gnus-treat-strip-banner gnus-article-strip-banner)
1585 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1586 (gnus-treat-buttonize gnus-article-add-buttons)
1587 (gnus-treat-fill-article gnus-article-fill-cited-article)
1588 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1589 (gnus-treat-strip-cr gnus-article-remove-cr)
1590 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1591 (gnus-treat-date-ut gnus-article-date-ut)
1592 (gnus-treat-date-local gnus-article-date-local)
1593 (gnus-treat-date-english gnus-article-date-english)
1594 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1595 (gnus-treat-date-original gnus-article-date-original)
1596 (gnus-treat-date-user-defined gnus-article-date-user)
1597 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1598 (gnus-treat-display-face gnus-article-display-face)
1599 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1600 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1601 (gnus-treat-hide-signature gnus-article-hide-signature)
1602 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1603 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1604 (gnus-treat-strip-pem gnus-article-hide-pem)
1605 (gnus-treat-from-picon gnus-treat-from-picon)
1606 (gnus-treat-mail-picon gnus-treat-mail-picon)
1607 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1608 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1609 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1610 (gnus-treat-strip-trailing-blank-lines
1611 gnus-article-remove-trailing-blank-lines)
1612 (gnus-treat-strip-leading-blank-lines
1613 gnus-article-strip-leading-blank-lines)
1614 (gnus-treat-strip-multiple-blank-lines
1615 gnus-article-strip-multiple-blank-lines)
1616 (gnus-treat-overstrike gnus-article-treat-overstrike)
1617 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences)
1618 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1619 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1620 ;; Displaying X-Face should be done after unfolding headers
1621 ;; to protect bitmap lines.
1622 (gnus-treat-display-x-face gnus-article-display-x-face)
1623 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1624 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1625 (gnus-treat-display-smileys gnus-treat-smiley)
1626 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1627 (gnus-treat-wash-html gnus-article-wash-html)
1628 (gnus-treat-emphasize gnus-article-emphasize)
1629 (gnus-treat-hide-citation gnus-article-hide-citation)
1630 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1631 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1632 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1633 (gnus-treat-play-sounds gnus-earcon-display)))
1635 (defvar gnus-article-mime-handle-alist nil)
1636 (defvar article-lapsed-timer nil)
1637 (defvar gnus-article-current-summary nil)
1639 (defvar gnus-article-mode-syntax-table
1640 (let ((table (copy-syntax-table text-mode-syntax-table)))
1641 ;; This causes the citation match run O(2^n).
1642 ;; (modify-syntax-entry ?- "w" table)
1643 (modify-syntax-entry ?> ")<" table)
1644 (modify-syntax-entry ?< "(>" table)
1645 ;; make M-. in article buffers work for `foo' strings
1646 (modify-syntax-entry ?' " " table)
1647 (modify-syntax-entry ?` " " table)
1649 "Syntax table used in article mode buffers.
1650 Initialized from `text-mode-syntax-table.")
1652 (defvar gnus-save-article-buffer nil)
1654 (defvar gnus-article-mode-line-format-alist
1655 (nconc '((?w (gnus-article-wash-status) ?s)
1656 (?m (gnus-article-mime-part-status) ?s))
1657 gnus-summary-mode-line-format-alist))
1659 (defvar gnus-number-of-articles-to-be-saved nil)
1661 (defvar gnus-inhibit-hiding nil)
1663 (defvar gnus-article-edit-mode nil)
1665 ;;; Macros for dealing with the article buffer.
1667 (defmacro gnus-with-article-headers (&rest forms)
1669 (set-buffer gnus-article-buffer)
1671 (let ((inhibit-read-only t)
1672 (inhibit-point-motion-hooks t)
1673 (case-fold-search t))
1674 (article-narrow-to-head)
1677 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1678 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1680 (defmacro gnus-with-article-buffer (&rest forms)
1682 (set-buffer gnus-article-buffer)
1683 (let ((inhibit-read-only t))
1686 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1687 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1689 (defun gnus-article-goto-header (header)
1690 "Go to HEADER, which is a regular expression."
1691 (re-search-forward (concat "^\\(" header "\\):") nil t))
1693 (defsubst gnus-article-hide-text (b e props)
1694 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1695 (gnus-add-text-properties-when 'article-type nil b e props)
1696 (when (memq 'intangible props)
1698 (max (1- b) (point-min))
1699 b 'intangible (cddr (memq 'intangible props)))))
1701 (defsubst gnus-article-unhide-text (b e)
1702 "Remove hidden text properties from region between B and E."
1703 (remove-text-properties b e gnus-hidden-properties)
1704 (when (memq 'intangible gnus-hidden-properties)
1705 (put-text-property (max (1- b) (point-min))
1706 b 'intangible nil)))
1708 (defun gnus-article-hide-text-type (b e type)
1709 "Hide text of TYPE between B and E."
1710 (gnus-add-wash-type type)
1711 (gnus-article-hide-text
1712 b e (cons 'article-type (cons type gnus-hidden-properties))))
1714 (defun gnus-article-unhide-text-type (b e type)
1715 "Unhide text of TYPE between B and E."
1716 (gnus-delete-wash-type type)
1717 (remove-text-properties
1718 b e (cons 'article-type (cons type gnus-hidden-properties)))
1719 (when (memq 'intangible gnus-hidden-properties)
1720 (put-text-property (max (1- b) (point-min))
1721 b 'intangible nil)))
1723 (defun gnus-article-hide-text-of-type (type)
1724 "Hide text of TYPE in the current buffer."
1726 (let ((b (point-min))
1728 (while (setq b (text-property-any b e 'article-type type))
1729 (add-text-properties b (incf b) gnus-hidden-properties)))))
1731 (defun gnus-article-delete-text-of-type (type)
1732 "Delete text of TYPE in the current buffer."
1734 (let ((b (point-min)))
1735 (while (setq b (text-property-any b (point-max) 'article-type type))
1737 b (or (text-property-not-all b (point-max) 'article-type type)
1740 (defun gnus-article-delete-invisible-text ()
1741 "Delete all invisible text in the current buffer."
1743 (let ((b (point-min)))
1744 (while (setq b (text-property-any b (point-max) 'invisible t))
1746 b (or (text-property-not-all b (point-max) 'invisible t)
1749 (defun gnus-article-text-type-exists-p (type)
1750 "Say whether any text of type TYPE exists in the buffer."
1751 (text-property-any (point-min) (point-max) 'article-type type))
1753 (defsubst gnus-article-header-rank ()
1754 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1755 (let ((list gnus-sorted-header-list)
1758 (if (looking-at (car list))
1760 (setq list (cdr list))
1764 (defun article-hide-headers (&optional arg delete)
1765 "Hide unwanted headers and possibly sort them as well."
1766 (interactive (gnus-article-hidden-arg))
1767 ;; Lars said that this function might be inhibited.
1768 (if (gnus-article-check-hidden-text 'headers arg)
1770 ;; Show boring headers as well.
1771 (gnus-article-show-hidden-text 'boring-headers)
1772 (when (eq 1 (point-min))
1773 (set-window-start (get-buffer-window (current-buffer)) 1)))
1774 (unless gnus-inhibit-hiding
1775 (let ((inhibit-read-only t)
1776 (case-fold-search t)
1777 (max (1+ (length gnus-sorted-header-list)))
1778 (inhibit-point-motion-hooks t)
1779 (cur (current-buffer))
1780 ignored visible beg)
1782 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1783 ;; group parameters, so we should go to the summary buffer.
1786 (progn (set-buffer gnus-summary-buffer) t)
1788 (setq ignored (when (not gnus-visible-headers)
1789 (cond ((stringp gnus-ignored-headers)
1790 gnus-ignored-headers)
1791 ((listp gnus-ignored-headers)
1792 (mapconcat 'identity
1793 gnus-ignored-headers
1795 visible (cond ((stringp gnus-visible-headers)
1796 gnus-visible-headers)
1797 ((and gnus-visible-headers
1798 (listp gnus-visible-headers))
1799 (mapconcat 'identity
1800 gnus-visible-headers
1804 ;; First we narrow to just the headers.
1805 (article-narrow-to-head)
1806 ;; Hide any "From " lines at the beginning of (mail) articles.
1807 (while (looking-at "From ")
1811 (delete-region (point-min) (point))
1812 (gnus-article-hide-text (point-min) (point)
1813 (nconc (list 'article-type 'headers)
1814 gnus-hidden-properties))))
1815 ;; Then treat the rest of the header lines.
1816 ;; Then we use the two regular expressions
1817 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1818 ;; select which header lines is to remain visible in the
1820 (while (re-search-forward "^[^ \t:]*:" nil t)
1822 ;; Mark the rank of the header.
1824 (point) (1+ (point)) 'message-rank
1825 (if (or (and visible (looking-at visible))
1827 (not (looking-at ignored))))
1828 (gnus-article-header-rank)
1831 (message-sort-headers-1)
1832 (when (setq beg (text-property-any
1833 (point-min) (point-max) 'message-rank (+ 2 max)))
1834 ;; We delete or make invisible the unwanted headers.
1835 (gnus-add-wash-type 'headers)
1838 (add-text-properties
1839 (point-min) (+ 5 (point-min))
1840 '(article-type headers dummy-invisible t))
1841 (delete-region beg (point-max)))
1842 (gnus-article-hide-text-type beg (point-max) 'headers)))))))))
1844 (defun article-hide-boring-headers (&optional arg)
1845 "Toggle hiding of headers that aren't very interesting.
1846 If given a negative prefix, always show; if given a positive prefix,
1848 (interactive (gnus-article-hidden-arg))
1849 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1850 (not gnus-show-all-headers))
1853 (let ((inhibit-read-only t)
1854 (inhibit-point-motion-hooks t))
1855 (article-narrow-to-head)
1856 (dolist (elem gnus-boring-article-headers)
1857 (goto-char (point-min))
1859 ;; Hide empty headers.
1861 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1863 (gnus-article-hide-text-type
1867 (if (re-search-forward "^[^ \t]" nil t)
1871 ;; Hide boring Newsgroups header.
1872 ((eq elem 'newsgroups)
1873 (when (gnus-string-equal
1874 (gnus-fetch-field "newsgroups")
1875 (gnus-group-real-name
1876 (if (boundp 'gnus-newsgroup-name)
1879 (gnus-article-hide-header "newsgroups")))
1880 ((eq elem 'to-address)
1881 (let ((to (message-fetch-field "to"))
1883 (gnus-parameter-to-address
1884 (if (boundp 'gnus-newsgroup-name)
1885 gnus-newsgroup-name ""))))
1886 (when (and to to-address
1889 ;; only one address in To
1890 (nth 1 (mail-extract-address-components to))
1892 (gnus-article-hide-header "to"))))
1894 (let ((to (message-fetch-field "to"))
1896 (gnus-parameter-to-list
1897 (if (boundp 'gnus-newsgroup-name)
1898 gnus-newsgroup-name ""))))
1899 (when (and to to-list
1902 ;; only one address in To
1903 (nth 1 (mail-extract-address-components to))
1905 (gnus-article-hide-header "to"))))
1907 (let ((cc (message-fetch-field "cc"))
1909 (gnus-parameter-to-list
1910 (if (boundp 'gnus-newsgroup-name)
1911 gnus-newsgroup-name ""))))
1912 (when (and cc to-list
1915 ;; only one address in CC
1916 (nth 1 (mail-extract-address-components cc))
1918 (gnus-article-hide-header "cc"))))
1919 ((eq elem 'followup-to)
1920 (when (gnus-string-equal
1921 (message-fetch-field "followup-to")
1922 (message-fetch-field "newsgroups"))
1923 (gnus-article-hide-header "followup-to")))
1924 ((eq elem 'reply-to)
1925 (if (gnus-group-find-parameter
1926 gnus-newsgroup-name 'broken-reply-to)
1927 (gnus-article-hide-header "reply-to")
1928 (let ((from (message-fetch-field "from"))
1929 (reply-to (message-fetch-field "reply-to")))
1936 (lambda (x) (downcase (cadr x)))
1937 (mail-extract-address-components from t))
1940 (lambda (x) (downcase (cadr x)))
1941 (mail-extract-address-components reply-to t))
1943 (gnus-article-hide-header "reply-to")))))
1945 (let ((date (message-fetch-field "date")))
1947 (< (days-between (current-time-string) date)
1949 (gnus-article-hide-header "date"))))
1951 (let ((to (message-fetch-field "to"))
1952 (cc (message-fetch-field "cc")))
1953 (when (> (length to) 1024)
1954 (gnus-article-hide-header "to"))
1955 (when (> (length cc) 1024)
1956 (gnus-article-hide-header "cc"))))
1960 (goto-char (point-min))
1961 (while (re-search-forward "^to:" nil t)
1962 (setq to-count (1+ to-count)))
1963 (when (> to-count 1)
1964 (while (> to-count 0)
1965 (goto-char (point-min))
1967 (re-search-forward "^to:" nil nil to-count)
1969 (narrow-to-region (point) (point-max))
1970 (gnus-article-hide-header "to"))
1971 (setq to-count (1- to-count))))
1972 (goto-char (point-min))
1973 (while (re-search-forward "^cc:" nil t)
1974 (setq cc-count (1+ cc-count)))
1975 (when (> cc-count 1)
1976 (while (> cc-count 0)
1977 (goto-char (point-min))
1979 (re-search-forward "^cc:" nil nil cc-count)
1981 (narrow-to-region (point) (point-max))
1982 (gnus-article-hide-header "cc"))
1983 (setq cc-count (1- cc-count)))))))))))))
1985 (defun gnus-article-hide-header (header)
1987 (goto-char (point-min))
1988 (when (re-search-forward (concat "^" header ":") nil t)
1989 (gnus-article-hide-text-type
1993 (if (re-search-forward "^[^ \t]" nil t)
1998 (defvar gnus-article-normalized-header-length 40
1999 "Length of normalized headers.")
2001 (defun article-normalize-headers ()
2002 "Make all header lines 40 characters long."
2004 (let ((inhibit-read-only t)
2008 (article-narrow-to-head)
2011 ((< (setq column (- (point-at-eol) (point)))
2012 gnus-article-normalized-header-length)
2014 (insert (make-string
2015 (- gnus-article-normalized-header-length column)
2017 ((> column gnus-article-normalized-header-length)
2018 (gnus-put-text-property
2020 (forward-char gnus-article-normalized-header-length)
2027 (forward-line 1))))))
2029 (defun article-treat-dumbquotes ()
2030 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
2031 Note that this function guesses whether a character is a sm*rtq**t* or
2032 not, so it should only be used interactively.
2034 Sm*rtq**t*s are M****s***'s unilateral extension to the
2035 iso-8859-1 character map in an attempt to provide more quoting
2036 characters. If you see something like \\222 or \\264 where
2037 you're expecting some kind of apostrophe or quotation mark, then
2040 (article-translate-strings gnus-article-dumbquotes-map))
2042 (defun article-translate-characters (from to)
2043 "Translate all characters in the body of the article according to FROM and TO.
2044 FROM is a string of characters to translate from; to is a string of
2045 characters to translate to."
2047 (when (article-goto-body)
2048 (let ((inhibit-read-only t)
2049 (x (make-string 225 ?x))
2051 (while (< (incf i) (length x))
2054 (while (< i (length from))
2055 (aset x (aref from i) (aref to i))
2057 (translate-region (point) (point-max) x)))))
2059 (defun article-translate-strings (map)
2060 "Translate all string in the body of the article according to MAP.
2061 MAP is an alist where the elements are on the form (\"from\" \"to\")."
2063 (when (article-goto-body)
2064 (let ((inhibit-read-only t))
2067 (while (search-forward (car elem) nil t)
2068 (replace-match (cadr elem)))))))))
2070 (defun article-treat-overstrike ()
2071 "Translate overstrikes into bold text."
2074 (when (article-goto-body)
2075 (let ((inhibit-read-only t))
2076 (while (search-forward "\b" nil t)
2077 (let ((next (char-after))
2081 previous (char-after))
2085 ;; We do the boldification/underlining by hiding the
2086 ;; overstrikes and putting the proper text property
2090 (gnus-article-hide-text-type start (point) 'overstrike)
2091 (put-text-property (point) end 'face 'bold))
2093 (gnus-article-hide-text-type
2094 (1- (point)) (1+ (point)) 'overstrike)
2096 start (1- (point)) 'face 'underline))
2098 (gnus-article-hide-text-type start (point) 'overstrike)
2100 (point) end 'face 'underline)))))))))
2102 (defun article-treat-ansi-sequences ()
2103 "Translate ANSI SGR control sequences into overlays or extents."
2106 (when (article-goto-body)
2107 (let ((inhibit-read-only t))
2108 (ansi-color-apply-on-region (point) (point-max))))))
2110 (defun gnus-article-treat-unfold-headers ()
2111 "Unfold folded message headers.
2112 Only the headers that fit into the current window width will be
2115 (gnus-with-article-headers
2119 (mail-header-narrow-to-field)
2120 (let ((header (buffer-string)))
2123 (goto-char (point-min))
2124 (while (re-search-forward "\n[\t ]" nil t)
2125 (replace-match " " t t)))
2126 (setq length (- (point-max) (point-min) 1)))
2127 (when (< length (window-width))
2128 (while (re-search-forward "\n[\t ]" nil t)
2129 (replace-match " " t t)))
2130 (goto-char (point-max)))))))
2132 (defun gnus-article-treat-fold-headers ()
2133 "Fold message headers."
2135 (gnus-with-article-headers
2138 (mail-header-narrow-to-field)
2139 (mail-header-fold-field)
2140 (goto-char (point-max))))))
2142 (defun gnus-treat-smiley ()
2143 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2145 (unless (featurep 'xemacs)
2146 (when (and (not gnus-article-should-use-smiley-mule)
2147 gnus-article-smiley-mule-loaded-p)
2148 (load "smiley" nil t)
2149 (setq gnus-article-smiley-mule-loaded-p nil))
2150 (when (and gnus-article-should-use-smiley-mule
2151 (not gnus-article-smiley-mule-loaded-p))
2152 (load "smiley-mule" nil t)
2153 (setq gnus-article-smiley-mule-loaded-p t)))
2154 (gnus-with-article-buffer
2155 (if (memq 'smiley gnus-article-wash-types)
2156 (gnus-delete-images 'smiley)
2158 (let ((images (smiley-region (point) (point-max))))
2160 (gnus-add-wash-type 'smiley)
2161 (dolist (image images)
2162 (gnus-add-image 'smiley image)))))))
2164 (defun gnus-article-remove-images ()
2165 "Remove all images from the article buffer."
2167 (gnus-with-article-buffer
2168 (dolist (elem gnus-article-image-alist)
2169 (gnus-delete-images (car elem)))))
2171 (defun gnus-article-treat-fold-newsgroups ()
2172 "Unfold folded message headers.
2173 Only the headers that fit into the current window width will be
2176 (gnus-with-article-headers
2177 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2179 (mail-header-narrow-to-field)
2180 (while (re-search-forward ", *" nil t)
2181 (replace-match ", " t t))
2182 (mail-header-fold-field)
2183 (goto-char (point-max))))))
2185 (defun gnus-article-treat-body-boundary ()
2186 "Place a boundary line at the end of the headers."
2188 (when (and gnus-body-boundary-delimiter
2189 (> (length gnus-body-boundary-delimiter) 0))
2190 (gnus-with-article-headers
2191 (goto-char (point-max))
2192 (let ((start (point)))
2193 (insert "X-Boundary: ")
2194 (gnus-add-text-properties start (point) '(invisible t intangible t))
2196 (while (>= (1- (window-width)) (length str))
2197 (setq str (concat str gnus-body-boundary-delimiter)))
2198 (substring str 0 (1- (window-width))))
2200 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2202 (defun article-fill-long-lines ()
2203 "Fill lines that are wider than the window width."
2206 (let ((inhibit-read-only t)
2207 (width (window-width (get-buffer-window (current-buffer)))))
2210 (let ((adaptive-fill-mode nil)) ;Why? -sm
2213 (when (>= (current-column) (min fill-column width))
2214 (narrow-to-region (min (1+ (point)) (point-max))
2216 (let ((goback (point-marker)))
2217 (fill-paragraph nil)
2218 (goto-char (marker-position goback)))
2220 (forward-line 1)))))))
2222 (defun article-capitalize-sentences ()
2223 "Capitalize the first word in each sentence."
2226 (let ((inhibit-read-only t)
2227 (paragraph-start "^[\n\^L]"))
2231 (forward-sentence)))))
2233 (defun article-remove-cr ()
2234 "Remove trailing CRs and then translate remaining CRs into LFs."
2237 (let ((inhibit-read-only t))
2238 (goto-char (point-min))
2239 (while (re-search-forward "\r+$" nil t)
2240 (replace-match "" t t))
2241 (goto-char (point-min))
2242 (while (search-forward "\r" nil t)
2243 (replace-match "\n" t t)))))
2245 (defun article-remove-trailing-blank-lines ()
2246 "Remove all trailing blank lines from the article."
2249 (let ((inhibit-read-only t))
2250 (goto-char (point-max))
2254 (while (and (not (bobp))
2255 (looking-at "^[ \t]*$")
2256 (not (gnus-annotation-in-region-p
2257 (point) (point-at-eol))))
2263 (defvar gnus-face-properties-alist))
2265 (defun article-display-face ()
2266 "Display any Face headers in the header."
2268 (let ((wash-face-p buffer-read-only))
2269 (gnus-with-article-headers
2270 ;; When displaying parts, this function can be called several times on
2271 ;; the same article, without any intended toggle semantic (as typing `W
2272 ;; D d' would have). So face deletion must occur only when we come from
2273 ;; an interactive command, that is when the *Article* buffer is
2275 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2276 (gnus-delete-images 'face)
2279 (when (and wash-face-p
2281 (goto-char (point-min))
2282 (not (re-search-forward "^Face:[\t ]*" nil t)))
2283 (gnus-buffer-live-p gnus-original-article-buffer))
2284 (set-buffer gnus-original-article-buffer))
2286 (mail-narrow-to-head)
2287 (while (gnus-article-goto-header "Face")
2288 (setq faces (nconc faces (list (mail-header-field-value)))))))
2289 (dolist (face faces)
2290 (let ((png (gnus-convert-face-to-png face))
2294 (apply 'gnus-create-image png 'png t
2295 (cdr (assq 'png gnus-face-properties-alist))))
2296 (gnus-article-goto-header "from")
2298 (insert "From: [no `from' set]\n")
2300 (gnus-add-wash-type 'face)
2301 (gnus-add-image 'face image)
2302 (gnus-put-image image nil 'face))))))
2305 (defun article-display-x-face (&optional force)
2306 "Look for an X-Face header and display it if present."
2307 (interactive (list 'force))
2308 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2309 (gnus-with-article-headers
2310 ;; Delete the old process, if any.
2311 (when (process-status "article-x-face")
2312 (delete-process "article-x-face"))
2313 ;; See the comment in `article-display-face'.
2314 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2315 ;; We have already displayed X-Faces, so we remove them
2317 (gnus-delete-images 'xface)
2319 (let (x-faces from face)
2321 (when (and wash-face-p
2323 (goto-char (point-min))
2324 (not (re-search-forward
2325 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2326 (gnus-buffer-live-p gnus-original-article-buffer))
2327 ;; If type `W f', use gnus-original-article-buffer,
2328 ;; otherwise use the current buffer because displaying
2329 ;; RFC822 parts calls this function too.
2330 (set-buffer gnus-original-article-buffer))
2332 (mail-narrow-to-head)
2333 (while (gnus-article-goto-header "X-Face")
2334 (push (mail-header-field-value) x-faces))
2335 (setq from (message-fetch-field "from"))))
2336 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2337 ;; single external face.
2338 (when (stringp gnus-article-x-face-command)
2339 (setq x-faces (list (car x-faces))))
2340 (while (and (setq face (pop x-faces))
2341 gnus-article-x-face-command
2343 ;; Check whether this face is censored.
2344 (not gnus-article-x-face-too-ugly)
2345 (and gnus-article-x-face-too-ugly from
2346 (not (string-match gnus-article-x-face-too-ugly
2348 ;; We display the face.
2349 (cond ((stringp gnus-article-x-face-command)
2350 ;; The command is a string, so we interpret the command
2351 ;; as a, well, command, and fork it off.
2352 (let ((process-connection-type nil))
2353 (process-kill-without-query
2355 "article-x-face" nil shell-file-name
2356 shell-command-switch gnus-article-x-face-command))
2359 (process-send-region "article-x-face"
2360 (point-min) (point-max)))
2361 (process-send-eof "article-x-face")))
2362 ((functionp gnus-article-x-face-command)
2363 ;; The command is a lisp function, so we call it.
2364 (funcall gnus-article-x-face-command face))
2366 (error "%s is not a function"
2367 gnus-article-x-face-command)))))))))
2369 (defun article-decode-mime-words ()
2370 "Decode all MIME-encoded words in the article."
2372 (gnus-with-article-buffer
2373 (let ((inhibit-point-motion-hooks t)
2374 (mail-parse-charset gnus-newsgroup-charset)
2375 (mail-parse-ignored-charsets
2376 (with-current-buffer gnus-summary-buffer
2377 gnus-newsgroup-ignored-charsets)))
2378 (mail-decode-encoded-word-region (point-min) (point-max)))))
2380 (defun article-decode-charset (&optional prompt)
2381 "Decode charset-encoded text in the article.
2382 If PROMPT (the prefix), prompt for a coding system to use."
2384 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2385 (inhibit-read-only t)
2386 (mail-parse-charset gnus-newsgroup-charset)
2387 (mail-parse-ignored-charsets
2388 (save-excursion (condition-case nil
2389 (set-buffer gnus-summary-buffer)
2391 gnus-newsgroup-ignored-charsets))
2392 ct cte ctl charset format)
2395 (article-narrow-to-head)
2396 (setq ct (message-fetch-field "Content-Type" t)
2397 cte (message-fetch-field "Content-Transfer-Encoding" t)
2398 ctl (and ct (ignore-errors
2399 (mail-header-parse-content-type ct)))
2402 (mm-read-coding-system "Charset to decode: "))
2404 (mail-content-type-get ctl 'charset)))
2405 format (and ctl (mail-content-type-get ctl 'format)))
2407 (setq cte (mail-header-strip cte)))
2408 (if (and ctl (not (string-match "/" (car ctl))))
2410 (goto-char (point-max)))
2413 (narrow-to-region (point) (point-max))
2414 (when (and (eq mail-parse-charset 'gnus-decoded)
2415 (eq (mm-body-7-or-8) '8bit))
2416 ;; The text code could have been decoded.
2417 (setq charset mail-parse-charset))
2418 (when (and (or (not ctl)
2419 (equal (car ctl) "text/plain"))
2420 (not format)) ;; article with format will decode later.
2422 charset (and cte (intern (downcase
2423 (gnus-strip-whitespace cte))))
2426 (defun article-decode-encoded-words ()
2427 "Remove encoded-word encoding from headers."
2428 (let ((charset (save-excursion
2429 (set-buffer gnus-summary-buffer)
2430 default-mime-charset))
2431 (inhibit-read-only t))
2432 (mime-decode-header-in-buffer charset)))
2434 (defun article-decode-group-name ()
2435 "Decode group names in `Newsgroups:'."
2436 (let ((inhibit-point-motion-hooks t)
2437 (inhibit-read-only t)
2438 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2439 (when (and (or gnus-group-name-charset-method-alist
2440 gnus-group-name-charset-group-alist)
2441 (gnus-buffer-live-p gnus-original-article-buffer))
2443 (article-narrow-to-head)
2444 (with-current-buffer gnus-original-article-buffer
2445 (goto-char (point-min)))
2446 (while (re-search-forward
2447 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2448 (replace-match (save-match-data
2449 (gnus-decode-newsgroups
2450 ;; XXX how to use data in article buffer?
2451 (with-current-buffer gnus-original-article-buffer
2453 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2456 gnus-newsgroup-name method))
2458 (goto-char (point-min))
2459 (with-current-buffer gnus-original-article-buffer
2460 (goto-char (point-min)))
2461 (while (re-search-forward
2462 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2463 (replace-match (save-match-data
2464 (gnus-decode-newsgroups
2465 ;; XXX how to use data in article buffer?
2466 (with-current-buffer gnus-original-article-buffer
2468 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2471 gnus-newsgroup-name method))
2474 (autoload 'idna-to-unicode "idna")
2476 (defun article-decode-idna-rhs ()
2477 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2480 (let ((inhibit-point-motion-hooks t)
2481 (inhibit-read-only t))
2482 (article-narrow-to-head)
2483 (goto-char (point-min))
2484 (while (re-search-forward "@.*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2486 (when (save-match-data
2487 (and (setq ace (match-string 1))
2489 (and (re-search-backward "^[^ \t]" nil t)
2490 (looking-at "From\\|To\\|Cc")))
2491 (setq unicode (idna-to-unicode ace))))
2492 (unless (string= ace unicode)
2493 (replace-match unicode nil nil nil 1)))))))))
2495 (defun article-de-quoted-unreadable (&optional force read-charset)
2496 "Translate a quoted-printable-encoded article.
2497 If FORCE, decode the article whether it is marked as quoted-printable
2499 If READ-CHARSET, ask for a coding system."
2500 (interactive (list 'force current-prefix-arg))
2502 (let ((inhibit-read-only t) type charset)
2503 (if (gnus-buffer-live-p gnus-original-article-buffer)
2504 (with-current-buffer gnus-original-article-buffer
2506 (gnus-fetch-field "content-transfer-encoding"))
2507 (let* ((ct (gnus-fetch-field "content-type"))
2510 (mail-header-parse-content-type ct)))))
2511 (setq charset (and ctl
2512 (mail-content-type-get ctl 'charset)))
2513 (if (stringp charset)
2514 (setq charset (intern (downcase charset)))))))
2516 (setq charset (mm-read-coding-system "Charset: " charset)))
2518 (setq charset gnus-newsgroup-charset))
2520 (and type (let ((case-fold-search t))
2521 (string-match "quoted-printable" type))))
2523 (quoted-printable-decode-region
2524 (point) (point-max) (mm-charset-to-coding-system charset))))))
2526 (defun article-de-base64-unreadable (&optional force read-charset)
2527 "Translate a base64 article.
2528 If FORCE, decode the article whether it is marked as base64 not.
2529 If READ-CHARSET, ask for a coding system."
2530 (interactive (list 'force current-prefix-arg))
2532 (let ((inhibit-read-only t) type charset)
2533 (if (gnus-buffer-live-p gnus-original-article-buffer)
2534 (with-current-buffer gnus-original-article-buffer
2536 (gnus-fetch-field "content-transfer-encoding"))
2537 (let* ((ct (gnus-fetch-field "content-type"))
2540 (mail-header-parse-content-type ct)))))
2541 (setq charset (and ctl
2542 (mail-content-type-get ctl 'charset)))
2543 (if (stringp charset)
2544 (setq charset (intern (downcase charset)))))))
2546 (setq charset (mm-read-coding-system "Charset: " charset)))
2548 (setq charset gnus-newsgroup-charset))
2550 (and type (let ((case-fold-search t))
2551 (string-match "base64" type))))
2554 (narrow-to-region (point) (point-max))
2555 (base64-decode-region (point-min) (point-max))
2556 (mm-decode-coding-region
2557 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2562 (defun article-decode-HZ ()
2563 "Translate a HZ-encoded article."
2567 (let ((inhibit-read-only t))
2568 (rfc1843-decode-region (point-min) (point-max)))))
2570 (defun article-unsplit-urls ()
2571 "Remove the newlines that some other mailers insert into URLs."
2574 (let ((inhibit-read-only t))
2575 (goto-char (point-min))
2576 (while (re-search-forward
2577 "\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2578 (replace-match "\\1\\3" t)))
2579 (when (interactive-p)
2580 (gnus-treat-article nil))))
2583 (defun article-wash-html (&optional read-charset)
2584 "Format an HTML article.
2585 If READ-CHARSET, ask for a coding system."
2588 (let ((inhibit-read-only t)
2590 (when (gnus-buffer-live-p gnus-original-article-buffer)
2591 (with-current-buffer gnus-original-article-buffer
2592 (let* ((ct (gnus-fetch-field "content-type"))
2595 (mail-header-parse-content-type ct)))))
2596 (setq charset (and ctl
2597 (mail-content-type-get ctl 'charset)))
2598 (when (stringp charset)
2599 (setq charset (intern (downcase charset)))))))
2601 (setq charset (mm-read-coding-system "Charset: " charset)))
2603 (setq charset gnus-newsgroup-charset))
2605 (save-window-excursion
2607 (narrow-to-region (point) (point-max))
2608 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2609 (entry (assq func mm-text-html-washer-alist)))
2611 (setq func (cdr entry)))
2616 (apply (car func) (cdr func))))))))))
2618 (defun gnus-article-wash-html-with-w3 ()
2619 "Wash the current buffer with w3."
2621 (let ((w3-strict-width (window-width))
2622 (url-standalone-mode t)
2623 (url-gateway-unplugged t)
2624 (w3-honor-stylesheets nil))
2626 (w3-region (point-min) (point-max))
2629 (defun gnus-article-wash-html-with-w3m ()
2630 "Wash the current buffer with emacs-w3m."
2633 (narrow-to-region (point) (point-max))
2634 (let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp)
2635 w3m-force-redisplay)
2636 (w3m-region (point-min) (point-max)))
2637 (when (and mm-inline-text-html-with-w3m-keymap
2638 (boundp 'w3m-minor-mode-map)
2640 (add-text-properties
2641 (point-min) (point-max)
2642 (list 'keymap w3m-minor-mode-map
2643 ;; Put the mark meaning this part was rendered by emacs-w3m.
2644 'mm-inline-text-html-with-w3m t)))))
2646 (defun article-hide-list-identifiers ()
2647 "Remove list identifies from the Subject header.
2648 The `gnus-list-identifiers' variable specifies what to do."
2650 (let ((inhibit-point-motion-hooks t)
2651 (regexp (if (consp gnus-list-identifiers)
2652 (mapconcat 'identity gnus-list-identifiers " *\\|")
2653 gnus-list-identifiers))
2654 (inhibit-read-only t))
2658 (article-narrow-to-head)
2659 (goto-char (point-min))
2660 (while (re-search-forward
2661 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2663 (delete-region (match-beginning 2) (match-end 0))
2664 (beginning-of-line))
2665 (when (re-search-forward
2666 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2667 (delete-region (match-beginning 1) (match-end 1))))))))
2669 (defun article-hide-pem (&optional arg)
2670 "Toggle hiding of any PEM headers and signatures in the current article.
2671 If given a negative prefix, always show; if given a positive prefix,
2673 (interactive (gnus-article-hidden-arg))
2674 (unless (gnus-article-check-hidden-text 'pem arg)
2676 (let ((inhibit-read-only t) end)
2677 (goto-char (point-min))
2678 ;; Hide the horrendously ugly "header".
2679 (when (and (search-forward
2680 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2682 (setq end (1+ (match-beginning 0))))
2683 (gnus-add-wash-type 'pem)
2684 (gnus-article-hide-text-type
2686 (if (search-forward "\n\n" nil t)
2690 ;; Hide the trailer as well
2691 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2693 (gnus-article-hide-text-type
2694 (match-beginning 0) (match-end 0) 'pem)))))))
2696 (defun article-strip-banner ()
2697 "Strip the banners specified by the `banner' group parameter and by
2698 `gnus-article-address-banner-alist'."
2702 (let ((inhibit-point-motion-hooks t))
2703 (when (gnus-parameter-banner gnus-newsgroup-name)
2704 (article-really-strip-banner
2705 (gnus-parameter-banner gnus-newsgroup-name)))
2706 (when gnus-article-address-banner-alist
2707 ;; It is necessary to encode from fields before checking,
2708 ;; because `mail-header-parse-addresses' does not work
2709 ;; (reliably) on decoded headers. And more, it is
2710 ;; impossible to use `gnus-fetch-original-field' here,
2711 ;; because `article-strip-banner' may be called in draft
2712 ;; buffers to preview them.
2713 (let ((from (save-restriction
2715 (article-narrow-to-head)
2716 (mail-fetch-field "from"))))
2719 (caar (mail-header-parse-addresses
2720 (mail-encode-encoded-word-string from)))))
2722 (dolist (pair gnus-article-address-banner-alist)
2723 (when (string-match (car pair) from)
2725 (article-really-strip-banner (cdr pair)))))))))))))
2727 (defun article-really-strip-banner (banner)
2728 "Strip the banner specified by the argument."
2731 (let ((inhibit-point-motion-hooks t)
2732 (gnus-signature-limit nil)
2733 (inhibit-read-only t))
2736 ((eq banner 'signature)
2737 (when (gnus-article-narrow-to-signature)
2740 (delete-region (point) (point-max))))
2742 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2743 (while (re-search-forward banner nil t)
2744 (delete-region (match-beginning 0) (match-end 0)))))
2746 (while (re-search-forward banner nil t)
2747 (delete-region (match-beginning 0) (match-end 0)))))))))
2749 (defun article-babel ()
2750 "Translate article using an online translation service."
2753 (gnus-with-article-buffer
2754 (when (article-goto-body)
2755 (let* ((start (point))
2757 (orig (buffer-substring start end))
2758 (trans (babel-as-string orig)))
2760 (narrow-to-region start end)
2761 (delete-region start end)
2764 (defun article-hide-signature (&optional arg)
2765 "Hide the signature in the current article.
2766 If given a negative prefix, always show; if given a positive prefix,
2768 (interactive (gnus-article-hidden-arg))
2774 (article-goto-body))
2775 (goto-char (point-min)))
2776 (unless (gnus-article-check-hidden-text 'signature arg)
2777 (let ((inhibit-read-only t)
2779 (while (setq button (text-property-any button (point-max)
2781 'gnus-signature-toggle))
2782 (setq button (text-property-not-all button (point-max)
2784 'gnus-signature-toggle))
2785 (when (and button (not (eobp)))
2786 (gnus-article-hide-text-type
2788 (next-single-property-change (1+ button) 'mime-view-entity
2791 (gnus-set-mode-line 'article))
2793 (defun article-strip-headers-in-body ()
2794 "Strip offensive headers from bodies."
2798 (let ((case-fold-search t))
2799 (when (looking-at "x-no-archive:")
2800 (gnus-delete-line)))))
2802 (defun article-strip-leading-blank-lines ()
2803 "Remove all blank lines from the beginning of the article."
2806 (let ((inhibit-point-motion-hooks t)
2807 (inhibit-read-only t))
2808 (when (article-goto-body)
2809 (while (and (not (eobp))
2810 (looking-at "[ \t]*$"))
2811 (gnus-delete-line))))))
2813 (defun article-narrow-to-head ()
2814 "Narrow the buffer to the head of the message.
2815 Point is left at the beginning of the narrowed-to region."
2817 (goto-char (point-min))
2818 (if (search-forward "\n\n" nil 1)
2821 (goto-char (point-min)))
2823 (defun article-goto-body ()
2824 "Place point at the start of the body."
2825 (goto-char (point-min))
2827 ;; This variable is only bound when dealing with separate
2829 (article-goto-body-goes-to-point-min-p
2831 ((search-forward "\n\n" nil t)
2834 (goto-char (point-max))
2837 (defun article-strip-multiple-blank-lines ()
2838 "Replace consecutive blank lines with one empty line."
2841 (let ((inhibit-point-motion-hooks t)
2842 (inhibit-read-only t))
2843 ;; First make all blank lines empty.
2845 (while (re-search-forward "^[ \t]+$" nil t)
2846 (unless (gnus-annotation-in-region-p
2847 (match-beginning 0) (match-end 0))
2848 (replace-match "" nil t)))
2849 ;; Then replace multiple empty lines with a single empty line.
2851 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2852 (unless (gnus-annotation-in-region-p
2853 (match-beginning 0) (match-end 0))
2854 (delete-region (match-beginning 1) (match-end 1)))))))
2856 (defun article-strip-leading-space ()
2857 "Remove all white space from the beginning of the lines in the article."
2860 (let ((inhibit-point-motion-hooks t)
2861 (inhibit-read-only t))
2863 (while (re-search-forward "^[ \t]+" nil t)
2864 (replace-match "" t t)))))
2866 (defun article-strip-trailing-space ()
2867 "Remove all white space from the end of the lines in the article."
2870 (let ((inhibit-point-motion-hooks t)
2871 (inhibit-read-only t))
2873 (while (re-search-forward "[ \t]+$" nil t)
2874 (replace-match "" t t)))))
2876 (defun article-strip-blank-lines ()
2877 "Strip leading, trailing and multiple blank lines."
2879 (article-strip-leading-blank-lines)
2880 (article-remove-trailing-blank-lines)
2881 (article-strip-multiple-blank-lines))
2883 (defun article-strip-all-blank-lines ()
2884 "Strip all blank lines."
2887 (let ((inhibit-point-motion-hooks t)
2888 (inhibit-read-only t))
2890 (while (re-search-forward "^[ \t]*\n" nil t)
2891 (replace-match "" t t)))))
2893 (defun gnus-article-narrow-to-signature ()
2894 "Narrow to the signature; return t if a signature is found, else nil."
2895 (let ((inhibit-point-motion-hooks t))
2896 (when (gnus-article-search-signature)
2898 ;; Check whether we have some limits to what we consider
2899 ;; to be a signature.
2900 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2901 (list gnus-signature-limit)))
2903 (while (setq limit (pop limits))
2904 (if (or (and (integerp limit)
2905 (< (- (point-max) (point)) limit))
2907 (< (count-lines (point) (point-max)) limit))
2908 (and (functionp limit)
2910 (and (stringp limit)
2911 (not (re-search-forward limit nil t))))
2912 () ; This limit did not succeed.
2916 (narrow-to-region (point) (point-max))
2919 (defun gnus-article-search-signature ()
2920 "Search the current buffer for the signature separator.
2921 Put point at the beginning of the signature separator."
2922 (let ((cur (point)))
2923 (goto-char (point-max))
2924 (if (if (stringp gnus-signature-separator)
2925 (re-search-backward gnus-signature-separator nil t)
2926 (let ((seps gnus-signature-separator))
2928 (not (re-search-backward (car seps) nil t)))
2935 (defun gnus-article-hidden-arg ()
2936 "Return the current prefix arg as a number, or 0 if no prefix."
2937 (list (if current-prefix-arg
2938 (prefix-numeric-value current-prefix-arg)
2941 (defun gnus-article-check-hidden-text (type arg)
2942 "Return nil if hiding is necessary.
2943 Arg can be nil or a number. nil and positive means hide, negative
2944 means show, 0 means toggle."
2947 (let ((hide (gnus-article-hidden-text-p type)))
2953 (gnus-article-show-hidden-text type)
2956 (if (eq hide 'hidden)
2958 (gnus-article-show-hidden-text type)
2962 (defun gnus-article-hidden-text-p (type)
2963 "Say whether the current buffer contains hidden text of type TYPE."
2964 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2966 (not (get-text-property pos 'invisible))
2967 (not (get-text-property pos 'dummy-invisible)))
2969 (text-property-any (1+ pos) (point-max) 'article-type type)))
2974 (defun gnus-article-show-hidden-text (type &optional dummy)
2975 "Show all hidden text of type TYPE.
2976 Originally it is hide instead of DUMMY."
2977 (let ((inhibit-read-only t)
2978 (inhibit-point-motion-hooks t))
2979 (gnus-remove-text-properties-when
2981 (point-min) (point-max)
2982 (cons 'article-type (cons type
2983 gnus-hidden-properties)))
2984 (gnus-delete-wash-type type)))
2986 (defconst article-time-units
2987 `((year . ,(* 365.25 24 60 60))
2988 (week . ,(* 7 24 60 60))
2989 (day . ,(* 24 60 60))
2993 "Mapping from time units to seconds.")
2995 (defun gnus-article-forward-header ()
2996 "Move point to the start of the next header.
2997 If the current header is a continuation header, this can be several
3002 (if (looking-at "[ \t]+[^ \t]")
3006 (defun article-date-ut (&optional type highlight header)
3007 "Convert DATE date to universal time in the current article.
3008 If TYPE is `local', convert to local time; if it is `lapsed', output
3009 how much time has lapsed since DATE. For `lapsed', the value of
3010 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
3011 should replace the \"Date:\" one, or should be added below it."
3012 (interactive (list 'ut t))
3013 (let* ((header (or header
3014 (and (eq 1 (point-min))
3015 (mail-header-date (save-excursion
3016 (set-buffer gnus-summary-buffer)
3017 gnus-current-headers)))
3018 (message-fetch-field "date")
3020 (date (if (vectorp header) (mail-header-date header)
3022 (inhibit-point-motion-hooks t)
3023 bface eface date-pos)
3024 (when (and date (not (string= date "")))
3027 (article-narrow-to-head)
3028 (when (or (and (eq type 'lapsed)
3029 gnus-article-date-lapsed-new-header
3030 ;; Attempt to get the face of X-Sent first.
3031 (re-search-forward "^X-Sent:[ \t]" nil t))
3032 (re-search-forward "^Date:[ \t]" nil t)
3033 ;; If Date is missing, try again for X-Sent.
3034 (re-search-forward "^X-Sent:[ \t]" nil t))
3035 (setq bface (get-text-property (point-at-bol) 'face)
3036 date (or (get-text-property (point-at-bol)
3039 eface (get-text-property (1- (point-at-eol))
3041 (let ((inhibit-read-only t))
3042 ;; Delete any old X-Sent headers.
3043 (when (setq date-pos
3044 (text-property-any (point-min) (point-max)
3045 'article-date-lapsed t))
3046 (goto-char (setq date-pos (set-marker (make-marker) date-pos)))
3047 (delete-region (match-beginning 0)
3048 (progn (forward-line 1) (point))))
3049 (goto-char (point-min))
3050 ;; Delete any old Date headers.
3051 (while (re-search-forward "^Date:[ \t]" nil t)
3053 (setq date-pos (match-beginning 0)))
3054 (unless (and (eq type 'lapsed)
3055 gnus-article-date-lapsed-new-header)
3056 (delete-region (match-beginning 0)
3057 (progn (message-next-header) (point)))))
3060 (goto-char date-pos)
3062 ;; Possibly, Date has been deleted.
3064 (when (and (eq type 'lapsed)
3065 gnus-article-date-lapsed-new-header
3066 (looking-at "Date:"))
3068 (goto-char (point-min)))
3069 (insert (article-make-date-line date type))
3070 (when (eq type 'lapsed)
3071 (put-text-property (point-at-bol) (point)
3072 'article-date-lapsed t))
3076 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
3077 (add-text-properties (match-beginning 1) (1+ (match-end 1))
3078 (list 'original-date date 'face bface))
3079 (put-text-property (match-beginning 2) (match-end 2)
3082 (defun article-make-date-line (date type)
3083 "Return a DATE line of TYPE."
3084 (unless (memq type '(local ut original user iso8601 lapsed english))
3085 (error "Unknown conversion type: %s" type))
3087 (let ((time (date-to-time date)))
3089 ;; Convert to the local timezone.
3091 (concat "Date: " (message-make-date time)))
3092 ;; Convert to Universal Time.
3097 (let* ((e (parse-time-string date))
3098 (tm (apply 'encode-time e))
3100 (ls (- (cadr tm) (car (current-time-zone time)))))
3101 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
3102 ((> ls 65535) (list (1+ ms) (- ls 65536)))
3106 ;; Get the original date from the article.
3107 ((eq type 'original)
3108 (concat "Date: " (if (string-match "\n+$" date)
3109 (substring date 0 (match-beginning 0))
3111 ;; Let the user define the format.
3113 (let ((format (or (condition-case nil
3114 (with-current-buffer gnus-summary-buffer
3115 gnus-article-time-format)
3117 gnus-article-time-format)))
3118 (if (functionp format)
3119 (funcall format time)
3120 (concat "Date: " (format-time-string format time)))))
3123 (let ((tz (car (current-time-zone time))))
3126 (format-time-string "%Y%m%dT%H%M%S" time)
3127 (format "%s%02d%02d"
3128 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
3129 (/ (% (abs tz) 3600) 60)))))
3130 ;; Do an X-Sent lapsed format.
3132 ;; If the date is seriously mangled, the timezone functions are
3133 ;; liable to bug out, so we ignore all errors.
3134 (let* ((now (current-time))
3135 (real-time (subtract-time now time))
3136 (real-sec (and real-time
3137 (+ (* (float (car real-time)) 65536)
3139 (sec (and real-time (abs real-sec)))
3149 ;; This is a bit convoluted, but basically we go
3150 ;; through the time units for years, weeks, etc,
3151 ;; and divide things to see whether that results
3152 ;; in positive answers.
3155 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
3156 ;; The (remaining) seconds are too few to
3157 ;; be divided into this time unit.
3159 ;; It's big enough, so we output it.
3160 (setq sec (- sec (* num (cdr unit))))
3162 (concat (if prev ", " "") (int-to-string
3164 " " (symbol-name (car unit))
3165 (if (> num 1) "s" ""))
3167 article-time-units "")
3168 ;; If dates are odd, then it might appear like the
3169 ;; article was sent in the future.
3172 " in the future"))))))
3173 ;; Display the date in proper English
3175 (let ((dtime (decode-time time)))
3178 (number-to-string (nth 3 dtime))
3179 (let ((digit (% (nth 3 dtime) 10)))
3181 ((memq (nth 3 dtime) '(11 12 13)) "th")
3187 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3189 (number-to-string (nth 5 dtime))
3191 (format "%02d" (nth 2 dtime))
3193 (format "%02d" (nth 1 dtime)))))))
3195 (format "Date: %s (from T-gnus)" date))))
3197 (defun article-date-local (&optional highlight)
3198 "Convert the current article date to the local timezone."
3199 (interactive (list t))
3200 (article-date-ut 'local highlight))
3202 (defun article-date-english (&optional highlight)
3203 "Convert the current article date to something that is proper English."
3204 (interactive (list t))
3205 (article-date-ut 'english highlight))
3207 (defun article-date-original (&optional highlight)
3208 "Convert the current article date to what it was originally.
3209 This is only useful if you have used some other date conversion
3210 function and want to see what the date was before converting."
3211 (interactive (list t))
3212 (article-date-ut 'original highlight))
3214 (defun article-date-lapsed (&optional highlight)
3215 "Convert the current article date to time lapsed since it was sent."
3216 (interactive (list t))
3217 (article-date-ut 'lapsed highlight))
3219 (defun article-update-date-lapsed ()
3220 "Function to be run from a timer to update the lapsed time line."
3221 (let (deactivate-mark)
3226 (set-buffer (window-buffer w))
3227 (when (eq major-mode 'gnus-article-mode)
3228 (let ((mark (point-marker)))
3229 (goto-char (point-min))
3230 (when (re-search-forward "^X-Sent:" nil t)
3231 (article-date-lapsed t))
3232 (goto-char (marker-position mark))
3233 (move-marker mark nil))))
3236 (defun gnus-start-date-timer (&optional n)
3237 "Start a timer to update the X-Sent header in the article buffers.
3238 The numerical prefix says how frequently (in seconds) the function
3243 (gnus-stop-date-timer)
3244 (setq article-lapsed-timer
3245 (run-at-time 1 n 'article-update-date-lapsed)))
3247 (defun gnus-stop-date-timer ()
3248 "Stop the X-Sent timer."
3250 (when article-lapsed-timer
3251 (nnheader-cancel-timer article-lapsed-timer)
3252 (setq article-lapsed-timer nil)))
3254 (defun article-date-user (&optional highlight)
3255 "Convert the current article date to the user-defined format.
3256 This format is defined by the `gnus-article-time-format' variable."
3257 (interactive (list t))
3258 (article-date-ut 'user highlight))
3260 (defun article-date-iso8601 (&optional highlight)
3261 "Convert the current article date to ISO8601."
3262 (interactive (list t))
3263 (article-date-ut 'iso8601 highlight))
3265 ;; (defun article-show-all ()
3266 ;; "Show all hidden text in the article buffer."
3270 ;; (let ((inhibit-read-only t))
3271 ;; (gnus-article-unhide-text (point-min) (point-max))
3272 ;; (gnus-remove-text-with-property 'gnus-prev)
3273 ;; (gnus-remove-text-with-property 'gnus-next))))
3275 (defun article-show-all-headers ()
3276 "Show all hidden headers in the article buffer."
3281 (article-narrow-to-head)
3282 (let ((inhibit-read-only t))
3283 (gnus-article-unhide-text (point-min) (point-max))))))
3285 (defun article-remove-leading-whitespace ()
3286 "Remove excessive whitespace from all headers."
3290 (let ((inhibit-read-only t))
3291 (article-narrow-to-head)
3292 (goto-char (point-min))
3293 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3294 (delete-region (match-beginning 1) (match-end 1)))))))
3296 (defun article-emphasize (&optional arg)
3297 "Emphasize text according to `gnus-emphasis-alist'."
3298 (interactive (gnus-article-hidden-arg))
3299 (unless (gnus-article-check-hidden-text 'emphasis arg)
3303 (with-current-buffer gnus-summary-buffer
3304 gnus-article-emphasis-alist)
3306 gnus-emphasis-alist))
3307 (inhibit-read-only t)
3308 (props (append '(article-type emphasis)
3309 gnus-hidden-properties))
3310 regexp elem beg invisible visible face)
3313 (while (setq elem (pop alist))
3315 (setq regexp (car elem)
3316 invisible (nth 1 elem)
3317 visible (nth 2 elem)
3319 (while (re-search-forward regexp nil t)
3320 (when (and (match-beginning visible) (match-beginning invisible))
3321 (gnus-article-hide-text
3322 (match-beginning invisible) (match-end invisible) props)
3323 (gnus-article-unhide-text-type
3324 (match-beginning visible) (match-end visible) 'emphasis)
3325 (gnus-put-overlay-excluding-newlines
3326 (match-beginning visible) (match-end visible) 'face face)
3327 (gnus-add-wash-type 'emphasis)
3328 (goto-char (match-end invisible)))))))))
3330 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3331 "Setup newsgroup emphasis alist."
3332 (unless gnus-article-emphasis-alist
3333 (let ((name (and gnus-newsgroup-name
3334 (gnus-group-real-name gnus-newsgroup-name))))
3335 (make-local-variable 'gnus-article-emphasis-alist)
3336 (setq gnus-article-emphasis-alist
3338 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3339 (while (setq elem (pop alist))
3340 (when (and name (string-match (car elem) name))
3342 highlight (copy-sequence (cdr elem)))))
3344 (copy-sequence highlight-words)
3345 (if gnus-newsgroup-name
3346 (copy-sequence (gnus-group-find-parameter
3347 gnus-newsgroup-name 'highlight-words t)))
3348 gnus-emphasis-alist)))))
3351 (defvar gnus-summary-article-menu)
3352 (defvar gnus-summary-post-menu))
3354 ;;; Saving functions.
3356 (defun gnus-article-save (save-buffer file &optional num)
3357 "Save the currently selected article."
3358 (unless gnus-save-all-headers
3359 ;; Remove headers according to `gnus-saved-headers'.
3360 (let ((gnus-visible-headers
3361 (or gnus-saved-headers gnus-visible-headers))
3362 (gnus-article-buffer save-buffer))
3364 (set-buffer save-buffer)
3365 (article-hide-headers 1 t))))
3366 (save-window-excursion
3367 (if (not gnus-default-article-saver)
3368 (error "No default saver is defined")
3369 ;; !!! Magic! The saving functions all save
3370 ;; `gnus-save-article-buffer' (or so they think), but we
3371 ;; bind that variable to our save-buffer.
3372 (set-buffer gnus-article-buffer)
3373 (let* ((gnus-save-article-buffer save-buffer)
3376 ((not gnus-prompt-before-saving) 'default)
3377 ((eq gnus-prompt-before-saving 'always) nil)
3379 (gnus-number-of-articles-to-be-saved
3380 (when (eq gnus-prompt-before-saving t)
3382 (set-buffer gnus-article-current-summary)
3383 (funcall gnus-default-article-saver filename)))))
3385 (defun gnus-read-save-file-name (prompt &optional filename
3386 function group headers variable)
3388 (funcall function group headers (symbol-value variable)))
3393 ((eq filename 'default)
3399 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3402 (if (and gnus-number-of-articles-to-be-saved
3403 (> gnus-number-of-articles-to-be-saved 1))
3404 (format "these %d articles"
3405 gnus-number-of-articles-to-be-saved)
3408 ;; Let the split methods have their say.
3410 ;; No split name was found.
3413 (concat prompt " (default "
3414 (file-name-nondirectory default-name) ") ")
3415 (file-name-directory default-name)
3417 ;; A single group name is returned.
3418 ((stringp split-name)
3420 (funcall function split-name headers
3421 (symbol-value variable)))
3423 (concat prompt " (default "
3424 (file-name-nondirectory default-name) ") ")
3425 (file-name-directory default-name)
3427 ;; A single split name was found
3428 ((= 1 (length split-name))
3429 (let* ((name (expand-file-name
3431 gnus-article-save-directory))
3432 (dir (cond ((file-directory-p name)
3433 (file-name-as-directory name))
3434 ((file-exists-p name) name)
3435 (t gnus-article-save-directory))))
3437 (concat prompt " (default " name ") ")
3439 ;; A list of splits was found.
3441 (setq split-name (nreverse split-name))
3443 (let ((file-name-history
3444 (nconc split-name file-name-history)))
3448 (concat prompt " (`M-p' for defaults) ")
3449 gnus-article-save-directory
3451 gnus-article-save-directory)))
3452 (car (push result file-name-history)))))))
3453 ;; Create the directory.
3454 (gnus-make-directory (file-name-directory file))
3455 ;; If we have read a directory, we append the default file name.
3456 (when (file-directory-p file)
3457 (setq file (expand-file-name (file-name-nondirectory
3459 (file-name-as-directory file))))
3460 ;; Possibly translate some characters.
3461 (nnheader-translate-file-chars file))))))
3462 (gnus-make-directory (file-name-directory result))
3463 (set variable result)))
3465 (defun gnus-article-archive-name (group)
3466 "Return the first instance of an \"Archive-name\" in the current buffer."
3467 (let ((case-fold-search t))
3468 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3469 (nnheader-concat gnus-article-save-directory
3470 (match-string 1)))))
3472 (defun gnus-article-nndoc-name (group)
3473 "If GROUP is an nndoc group, return the name of the parent group."
3474 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3475 (gnus-group-get-parameter group 'save-article-group)))
3477 (defun gnus-summary-save-in-rmail (&optional filename)
3478 "Append this article to Rmail file.
3479 Optional argument FILENAME specifies file name.
3480 Directory to save to is default to `gnus-article-save-directory'."
3481 (setq filename (gnus-read-save-file-name
3482 "Save %s in rmail file:" filename
3483 gnus-rmail-save-name gnus-newsgroup-name
3484 gnus-current-headers 'gnus-newsgroup-last-rmail))
3485 (gnus-eval-in-buffer-window gnus-save-article-buffer
3489 (gnus-output-to-rmail filename))))
3492 (defun gnus-summary-save-in-mail (&optional filename)
3493 "Append this article to Unix mail file.
3494 Optional argument FILENAME specifies file name.
3495 Directory to save to is default to `gnus-article-save-directory'."
3496 (setq filename (gnus-read-save-file-name
3497 "Save %s in Unix mail file:" filename
3498 gnus-mail-save-name gnus-newsgroup-name
3499 gnus-current-headers 'gnus-newsgroup-last-mail))
3500 (gnus-eval-in-buffer-window gnus-save-article-buffer
3504 (if (and (file-readable-p filename)
3505 (file-regular-p filename)
3506 (mail-file-babyl-p filename))
3507 (rmail-output-to-rmail-file filename t)
3508 (gnus-output-to-mail filename)))))
3511 (defun gnus-summary-save-in-file (&optional filename overwrite)
3512 "Append this article to file.
3513 Optional argument FILENAME specifies file name.
3514 Directory to save to is default to `gnus-article-save-directory'."
3515 (setq filename (gnus-read-save-file-name
3516 "Save %s in file:" filename
3517 gnus-file-save-name gnus-newsgroup-name
3518 gnus-current-headers 'gnus-newsgroup-last-file))
3519 (gnus-eval-in-buffer-window gnus-save-article-buffer
3523 (when (and overwrite
3524 (file-exists-p filename))
3525 (delete-file filename))
3526 (gnus-output-to-file filename))))
3529 (defun gnus-summary-write-to-file (&optional filename)
3530 "Write this article to a file, overwriting it if the file exists.
3531 Optional argument FILENAME specifies file name.
3532 The directory to save in defaults to `gnus-article-save-directory'."
3533 (gnus-summary-save-in-file nil t))
3535 (defun gnus-summary-save-body-in-file (&optional filename)
3536 "Append this article body to a file.
3537 Optional argument FILENAME specifies file name.
3538 The directory to save in defaults to `gnus-article-save-directory'."
3539 (setq filename (gnus-read-save-file-name
3540 "Save %s body in file:" filename
3541 gnus-file-save-name gnus-newsgroup-name
3542 gnus-current-headers 'gnus-newsgroup-last-file))
3543 (gnus-eval-in-buffer-window gnus-save-article-buffer
3547 (when (article-goto-body)
3548 (narrow-to-region (point) (point-max)))
3549 (gnus-output-to-file filename))))
3552 (defun gnus-summary-save-in-pipe (&optional command)
3553 "Pipe this article to subprocess."
3555 (cond ((and (eq command 'default)
3556 gnus-last-shell-command)
3557 gnus-last-shell-command)
3562 "Shell command on %s: "
3563 (if (and gnus-number-of-articles-to-be-saved
3564 (> gnus-number-of-articles-to-be-saved 1))
3565 (format "these %d articles"
3566 gnus-number-of-articles-to-be-saved)
3568 gnus-last-shell-command))))
3569 (when (string-equal command "")
3570 (if gnus-last-shell-command
3571 (setq command gnus-last-shell-command)
3572 (error "A command is required")))
3573 (gnus-eval-in-buffer-window gnus-article-buffer
3576 (shell-command-on-region (point-min) (point-max) command nil)))
3577 (setq gnus-last-shell-command command))
3579 (defun gnus-summary-pipe-to-muttprint (&optional command)
3580 "Pipe this article to muttprint."
3581 (setq command (read-string
3582 "Print using command: " gnus-summary-muttprint-program
3583 nil gnus-summary-muttprint-program))
3584 (gnus-summary-save-in-pipe command))
3586 ;;; Article file names when saving.
3588 (defun gnus-capitalize-newsgroup (newsgroup)
3589 "Capitalize NEWSGROUP name."
3590 (when (not (zerop (length newsgroup)))
3591 (concat (char-to-string (upcase (aref newsgroup 0)))
3592 (substring newsgroup 1))))
3594 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3595 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3596 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3597 Otherwise, it is like ~/News/news/group/num."
3600 (concat (if (gnus-use-long-file-name 'not-save)
3601 (gnus-capitalize-newsgroup newsgroup)
3602 (gnus-newsgroup-directory-form newsgroup))
3603 "/" (int-to-string (mail-header-number headers)))
3604 gnus-article-save-directory)))
3606 (string-equal (file-name-directory default)
3607 (file-name-directory last-file))
3608 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3610 (or last-file default))))
3612 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3613 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3614 If variable `gnus-use-long-file-name' is non-nil, it is
3615 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3618 (concat (if (gnus-use-long-file-name 'not-save)
3620 (gnus-newsgroup-directory-form newsgroup))
3621 "/" (int-to-string (mail-header-number headers)))
3622 gnus-article-save-directory)))
3624 (string-equal (file-name-directory default)
3625 (file-name-directory last-file))
3626 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3628 (or last-file default))))
3630 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3631 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3632 If variable `gnus-use-long-file-name' is non-nil, it is
3633 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3636 (if (gnus-use-long-file-name 'not-save)
3639 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3641 gnus-article-save-directory)))
3643 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3644 "Generate file name from sender."
3645 (let ((from (mail-header-from headers)))
3647 (if (and from (string-match "\\([^ <]+\\)@" from))
3648 (match-string 1 from)
3650 gnus-article-save-directory)))
3652 (defun article-verify-x-pgp-sig ()
3655 (if (gnus-buffer-live-p gnus-original-article-buffer)
3656 (let ((sig (with-current-buffer gnus-original-article-buffer
3657 (gnus-fetch-field "X-PGP-Sig")))
3661 (mml2015-clear-verify-function))
3663 (insert-buffer-substring gnus-original-article-buffer)
3664 (setq items (split-string sig))
3665 (message-narrow-to-head)
3666 (let ((inhibit-point-motion-hooks t)
3667 (case-fold-search t))
3668 ;; Don't verify multiple headers.
3669 (setq headers (mapconcat (lambda (header)
3671 (mail-fetch-field header)
3673 (split-string (nth 1 items) ",") "")))
3674 (delete-region (point-min) (point-max))
3675 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3676 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3681 (if (looking-at "^-")
3684 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3685 (insert "Version: " (car items) "\n\n")
3686 (insert (mapconcat 'identity (cddr items) "\n"))
3687 (insert "\n-----END PGP SIGNATURE-----\n")
3688 (let ((mm-security-handle (list (format "multipart/signed"))))
3689 (mml2015-clean-buffer)
3690 (let ((coding-system-for-write (or gnus-newsgroup-charset
3692 (funcall (mml2015-clear-verify-function)))
3694 (or (mm-handle-multipart-ctl-parameter
3695 mm-security-handle 'gnus-details)
3696 (mm-handle-multipart-ctl-parameter
3697 mm-security-handle 'gnus-info)))))
3699 (let ((inhibit-read-only t) bface eface)
3701 (message-narrow-to-head)
3702 (goto-char (point-max))
3704 (setq bface (get-text-property (point-at-bol) 'face)
3705 eface (get-text-property (1- (point-at-eol)) 'face))
3706 (message-remove-header "X-Gnus-PGP-Verify")
3707 (if (re-search-forward "^X-PGP-Sig:" nil t)
3709 (goto-char (point-max)))
3710 (narrow-to-region (point) (point))
3711 (insert "X-Gnus-PGP-Verify: " info "\n")
3712 (goto-char (point-min))
3715 (if (not (looking-at "^[ \t]"))
3719 (goto-char (point-min))
3720 (when (looking-at "\\([^:]+\\): *")
3721 (put-text-property (match-beginning 1) (1+ (match-end 1))
3723 (put-text-property (match-end 0) (point-max)
3724 'face eface)))))))))
3726 (defun article-verify-cancel-lock ()
3727 "Verify Cancel-Lock header."
3729 (if (gnus-buffer-live-p gnus-original-article-buffer)
3730 (canlock-verify gnus-original-article-buffer)))
3732 (defun article-monafy ()
3733 "Display body part with mona font."
3735 (unless (if (featurep 'xemacs)
3736 (find-face 'gnus-mona-face)
3737 (facep 'gnus-mona-face))
3738 (require 'navi2ch-mona)
3739 (set-face-font (make-face 'gnus-mona-face) navi2ch-mona-font))
3741 (let ((inhibit-read-only t))
3744 (gnus-make-overlay (point) (point-max))
3745 'face 'gnus-mona-face))))
3752 (setq afunc (car func)
3755 gfunc (intern (format "gnus-%s" func))))
3757 (when (fboundp afunc)
3758 `(lambda (&optional interactive &rest args)
3759 ,(documentation afunc t)
3760 (interactive (list t))
3762 (set-buffer gnus-article-buffer)
3764 (call-interactively ',afunc)
3765 (apply ',afunc args))))))))
3766 '(article-hide-headers
3767 article-verify-x-pgp-sig
3768 article-verify-cancel-lock
3770 article-hide-boring-headers
3771 article-treat-overstrike
3772 article-treat-ansi-sequences
3773 article-fill-long-lines
3774 article-capitalize-sentences
3776 article-remove-leading-whitespace
3777 article-display-x-face
3778 article-display-face
3779 article-de-quoted-unreadable
3780 article-de-base64-unreadable
3783 article-unsplit-urls
3784 article-hide-list-identifiers
3785 article-strip-banner
3788 article-hide-signature
3789 article-strip-headers-in-body
3790 article-remove-trailing-blank-lines
3791 article-strip-leading-blank-lines
3792 article-strip-multiple-blank-lines
3793 article-strip-leading-space
3794 article-strip-trailing-space
3795 article-strip-blank-lines
3796 article-strip-all-blank-lines
3798 article-date-english
3799 article-date-iso8601
3800 article-date-original
3802 article-decode-mime-words
3803 article-decode-charset
3804 article-decode-encoded-words
3808 article-treat-dumbquotes
3809 article-normalize-headers
3810 (article-show-all-headers . gnus-article-show-all-headers)
3811 ;; (article-show-all . gnus-article-show-all)
3815 ;;; Gnus article mode
3818 (put 'gnus-article-mode 'mode-class 'special)
3820 (gnus-define-keys gnus-article-mode-map
3821 " " gnus-article-goto-next-page
3822 "\177" gnus-article-goto-prev-page
3823 [delete] gnus-article-goto-prev-page
3824 [backspace] gnus-article-goto-prev-page
3825 "\C-c^" gnus-article-refer-article
3826 "h" gnus-article-show-summary
3827 "s" gnus-article-show-summary
3828 "\C-c\C-m" gnus-article-mail
3829 "?" gnus-article-describe-briefly
3830 "e" gnus-summary-edit-article
3831 "<" beginning-of-buffer
3833 "\C-c\C-i" gnus-info-find-node
3835 "R" gnus-article-reply-with-original
3836 "F" gnus-article-followup-with-original
3837 "\C-hk" gnus-article-describe-key
3838 "\C-hc" gnus-article-describe-key-briefly
3840 "\C-d" gnus-article-read-summary-keys
3841 "\M-*" gnus-article-read-summary-keys
3842 "\M-#" gnus-article-read-summary-keys
3843 "\M-^" gnus-article-read-summary-keys
3844 "\M-g" gnus-article-read-summary-keys)
3846 ;; Define almost undefined keys to `gnus-article-read-summary-keys'.
3850 (push (char-to-string key) keys)
3852 (dolist (elem (accessible-keymaps gnus-summary-mode-map))
3853 (setq key (car elem))
3854 (when (and (> (length key) 0)
3855 (not (eq 'menu-bar (aref key 0)))
3856 (symbolp (lookup-key gnus-summary-mode-map key)))
3859 (unless (lookup-key gnus-article-mode-map key)
3860 (define-key gnus-article-mode-map key 'gnus-article-read-summary-keys))))
3862 (defun gnus-article-make-menu-bar ()
3863 (unless (boundp 'gnus-article-commands-menu)
3864 (gnus-summary-make-menu-bar))
3865 (gnus-turn-off-edit-menu 'article)
3866 (unless (boundp 'gnus-article-article-menu)
3868 gnus-article-article-menu gnus-article-mode-map ""
3870 ["Scroll forwards" gnus-article-goto-next-page t]
3871 ["Scroll backwards" gnus-article-goto-prev-page t]
3872 ["Show summary" gnus-article-show-summary t]
3873 ["Fetch Message-ID at point" gnus-article-refer-article t]
3874 ["Mail to address at point" gnus-article-mail t]
3875 ["Send a bug report" gnus-bug t]))
3878 gnus-article-treatment-menu gnus-article-mode-map ""
3879 ;; Fixme: this should use :active (and maybe :visible).
3881 ["Hide headers" gnus-article-hide-headers t]
3882 ["Hide signature" gnus-article-hide-signature t]
3883 ["Hide citation" gnus-article-hide-citation t]
3884 ["Treat overstrike" gnus-article-treat-overstrike t]
3885 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
3886 ["Remove carriage return" gnus-article-remove-cr t]
3887 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3888 ["Treat html" gnus-article-wash-html t]
3889 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3890 ["Decode HZ" gnus-article-decode-HZ t]))
3892 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3894 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3896 (gnus-run-hooks 'gnus-article-menu-hook)))
3898 (defun gnus-article-mode ()
3899 "Major mode for displaying an article.
3901 All normal editing commands are switched off.
3903 The following commands are available in addition to all summary mode
3905 \\<gnus-article-mode-map>
3906 \\[gnus-article-next-page]\t Scroll the article one page forwards
3907 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3908 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3909 \\[gnus-article-show-summary]\t Display the summary buffer
3910 \\[gnus-article-mail]\t Send a reply to the address near point
3911 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3912 \\[gnus-info-find-node]\t Go to the Gnus info node"
3914 (gnus-simplify-mode-line)
3915 (setq mode-name "Article")
3916 (setq major-mode 'gnus-article-mode)
3917 (make-local-variable 'minor-mode-alist)
3918 (unless (assq 'gnus-show-mime minor-mode-alist)
3919 (push (list 'gnus-show-mime " MIME") minor-mode-alist))
3920 (use-local-map gnus-article-mode-map)
3921 (when (gnus-visual-p 'article-menu 'menu)
3922 (gnus-article-make-menu-bar)
3923 (when gnus-summary-tool-bar-map
3924 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3925 (gnus-update-format-specifications nil 'article-mode)
3926 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3927 (set (make-local-variable 'gnus-page-broken) nil)
3928 (make-local-variable 'gnus-button-marker-list)
3929 (make-local-variable 'gnus-article-current-summary)
3930 (make-local-variable 'gnus-article-mime-handles)
3931 (make-local-variable 'gnus-article-decoded-p)
3932 (make-local-variable 'gnus-article-mime-handle-alist)
3933 (make-local-variable 'gnus-article-wash-types)
3934 (make-local-variable 'gnus-article-image-alist)
3935 (make-local-variable 'gnus-article-charset)
3936 (make-local-variable 'gnus-article-ignored-charsets)
3937 (gnus-set-default-directory)
3938 (buffer-disable-undo)
3939 (setq buffer-read-only t
3940 show-trailing-whitespace nil)
3941 (set-syntax-table gnus-article-mode-syntax-table)
3942 (gnus-run-hooks 'gnus-article-mode-hook))
3944 (defun gnus-article-setup-buffer ()
3945 "Initialize the article buffer."
3946 (let* ((name (if gnus-single-article-buffer "*Article*"
3947 (concat "*Article " gnus-newsgroup-name "*")))
3949 (progn (string-match "\\*Article" name)
3950 (concat " *Original Article"
3951 (substring name (match-end 0))))))
3952 (setq gnus-article-buffer name)
3953 (setq gnus-original-article-buffer original)
3954 (setq gnus-article-mime-handle-alist nil)
3955 ;; This might be a variable local to the summary buffer.
3956 (unless gnus-single-article-buffer
3958 (set-buffer gnus-summary-buffer)
3959 (setq gnus-article-buffer name)
3960 (setq gnus-original-article-buffer original)
3961 (gnus-set-global-variables)))
3962 (gnus-article-setup-highlight-words)
3963 ;; Init original article buffer.
3965 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3966 (set-buffer-multibyte t)
3967 (setq major-mode 'gnus-original-article-mode)
3968 (make-local-variable 'gnus-original-article))
3969 (if (get-buffer name)
3972 (when (and gnus-article-edit-mode
3975 (y-or-n-p "Article mode edit in progress; discard? ")))
3976 (error "Action aborted"))
3977 (set (make-local-variable 'gnus-article-edit-mode) nil)
3978 (buffer-disable-undo)
3979 (setq buffer-read-only t)
3980 ;; This list just keeps growing if we don't reset it.
3981 (setq gnus-button-marker-list nil)
3982 (unless (eq major-mode 'gnus-article-mode)
3983 (gnus-article-mode))
3986 (set-buffer (gnus-get-buffer-create name))
3988 (make-local-variable 'gnus-summary-buffer)
3989 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3990 (current-buffer)))))
3992 ;; Set article window start at LINE, where LINE is the number of lines
3993 ;; from the head of the article.
3994 (defun gnus-article-set-window-start (&optional line)
3996 (gnus-get-buffer-window gnus-article-buffer t)
3998 (set-buffer gnus-article-buffer)
3999 (goto-char (point-min))
4002 (gnus-message 6 "Moved to bookmark")
4003 (search-forward "\n\n" nil t)
4007 ;;; @@ article filters
4010 (defun gnus-article-display-mime-message ()
4011 "Article display method for MIME message."
4012 ;; called from `gnus-original-article-buffer'.
4013 (let (charset all-headers)
4014 (with-current-buffer gnus-summary-buffer
4015 (setq charset default-mime-charset
4016 all-headers gnus-have-all-headers))
4017 (make-local-variable 'default-mime-charset)
4018 (setq default-mime-charset charset)
4019 (with-current-buffer (get-buffer-create gnus-article-buffer)
4020 (make-local-variable 'default-mime-charset)
4021 (setq default-mime-charset charset))
4022 (mime-display-message mime-message-structure
4023 gnus-article-buffer nil gnus-article-mode-map)
4025 (gnus-article-hide-headers nil -1)))
4026 (run-hooks 'gnus-mime-article-prepare-hook))
4028 (defun gnus-article-display-traditional-message ()
4029 "Article display method for traditional message."
4030 (set-buffer gnus-article-buffer)
4031 (let ((inhibit-read-only t))
4033 (insert-buffer-substring gnus-original-article-buffer)))
4035 (defun gnus-article-make-full-mail-header (&optional number charset)
4036 "Create a new mail header structure in a raw article buffer."
4037 (unless (and number charset)
4038 (save-current-buffer
4039 (set-buffer gnus-summary-buffer)
4041 (setq number (or (cdr gnus-article-current) 0)))
4043 (setq charset (or default-mime-charset 'x-ctext)))))
4044 (goto-char (point-min))
4045 (let ((header-end (if (search-forward "\n\n" nil t)
4047 (goto-char (point-max))))
4048 (chars (- (point-max) (point)))
4049 (lines (count-lines (point) (point-max)))
4050 (default-mime-charset charset)
4052 (narrow-to-region (point-min) header-end)
4053 (setq xref (std11-fetch-field "xref"))
4055 (make-full-mail-header
4057 (std11-fetch-field "subject")
4058 (std11-fetch-field "from")
4059 (std11-fetch-field "date")
4060 (std11-fetch-field "message-id")
4061 (std11-fetch-field "references")
4064 (when xref (concat "Xref: " xref)))
4067 (defun gnus-article-prepare (article &optional all-headers header)
4068 "Prepare ARTICLE in article mode buffer.
4069 ARTICLE should either be an article number or a Message-ID.
4070 If ARTICLE is an id, HEADER should be the article headers.
4071 If ALL-HEADERS is non-nil, no headers are hidden."
4073 ;; Make sure we start in a summary buffer.
4074 (unless (eq major-mode 'gnus-summary-mode)
4075 (set-buffer gnus-summary-buffer))
4076 (setq gnus-summary-buffer (current-buffer))
4077 (let* ((gnus-article (if header (mail-header-number header) article))
4078 (summary-buffer (current-buffer))
4079 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
4080 (group gnus-newsgroup-name)
4083 (gnus-article-setup-buffer)
4084 (set-buffer gnus-article-buffer)
4085 ;; Deactivate active regions.
4086 (when (and (boundp 'transient-mark-mode)
4087 transient-mark-mode)
4088 (setq mark-active nil))
4089 (if (not (setq result (let ((inhibit-read-only t))
4090 (gnus-request-article-this-buffer
4092 ;; There is no such article.
4094 (when (and (numberp article)
4095 (not (memq article gnus-newsgroup-sparse)))
4096 (setq gnus-article-current
4097 (cons gnus-newsgroup-name article))
4098 (set-buffer gnus-summary-buffer)
4099 (setq gnus-current-article article)
4100 (if (and (memq article gnus-newsgroup-undownloaded)
4101 (not (gnus-online (gnus-find-method-for-group
4102 gnus-newsgroup-name))))
4104 (gnus-summary-set-agent-mark article)
4105 (message "Message marked for downloading"))
4106 (gnus-summary-mark-article article gnus-canceled-mark)
4107 (unless (memq article gnus-newsgroup-sparse)
4108 (gnus-error 1 "No such article (may have expired or been canceled)")))))
4109 (if (or (eq result 'pseudo)
4110 (eq result 'nneething))
4113 (set-buffer summary-buffer)
4114 (push article gnus-newsgroup-history)
4115 (setq gnus-last-article gnus-current-article
4116 gnus-current-article 0
4117 gnus-current-headers nil
4118 gnus-article-current nil)
4119 (if (eq result 'nneething)
4120 (gnus-configure-windows 'summary)
4121 (gnus-configure-windows 'article))
4122 (gnus-set-global-variables))
4123 (let ((gnus-article-mime-handle-alist-1
4124 gnus-article-mime-handle-alist))
4125 (gnus-set-mode-line 'article)))
4126 ;; The result from the `request' was an actual article -
4127 ;; or at least some text that is now displayed in the
4129 (when (and (numberp article)
4130 (not (eq article gnus-current-article)))
4131 ;; Seems like a new article has been selected.
4132 ;; `gnus-current-article' must be an article number.
4134 (set-buffer summary-buffer)
4135 (push article gnus-newsgroup-history)
4136 (setq gnus-last-article gnus-current-article
4137 gnus-current-article article
4138 gnus-current-headers
4139 (gnus-summary-article-header gnus-current-article)
4140 gnus-article-current
4141 (cons gnus-newsgroup-name gnus-current-article))
4142 (unless (vectorp gnus-current-headers)
4143 (setq gnus-current-headers nil))
4144 (gnus-summary-goto-subject gnus-current-article)
4145 (when (gnus-summary-show-thread)
4146 ;; If the summary buffer really was folded, the
4147 ;; previous goto may not actually have gone to
4148 ;; the right article, but the thread root instead.
4150 (gnus-summary-goto-subject gnus-current-article))
4151 (gnus-run-hooks 'gnus-mark-article-hook)
4152 (gnus-set-mode-line 'summary)
4153 (when (gnus-visual-p 'article-highlight 'highlight)
4154 (gnus-run-hooks 'gnus-visual-mark-article-hook))
4155 ;; Set the global newsgroup variables here.
4156 (gnus-set-global-variables)
4157 (setq gnus-have-all-headers
4158 (or all-headers gnus-show-all-headers))))
4160 (gnus-configure-windows 'article))
4161 (when (or (numberp article)
4163 (gnus-article-prepare-display)
4165 (goto-char (point-min))
4166 (when gnus-break-pages
4167 (gnus-narrow-to-page)))
4168 (let ((gnus-article-mime-handle-alist-1
4169 gnus-article-mime-handle-alist))
4170 (gnus-set-mode-line 'article))
4174 (set-window-point (get-buffer-window (current-buffer)) (point))
4175 (gnus-configure-windows 'article)
4178 (defun gnus-article-prepare-mime-display (&optional number)
4179 (goto-char (point-min))
4180 (when (re-search-forward "^[^\t ]+:" nil t)
4181 (goto-char (match-beginning 0)))
4182 (let ((entity (if (eq 1 (point-min))
4183 (get-text-property 1 'mime-view-entity)
4184 (get-text-property (point) 'mime-view-entity)))
4185 last-entity child-entity next type)
4186 (setq child-entity (mime-entity-children entity))
4188 (setq last-entity (nth (1- (length child-entity))
4190 (setq last-entity entity))
4192 (narrow-to-region (point)
4193 (if (search-forward "\n\n" nil t)
4196 (gnus-treat-article 'head)
4197 (put-text-property (point-min) (point-max) 'article-treated-header t)
4198 (goto-char (point-max)))
4199 (while (and (not (eobp)) entity)
4200 (setq next (set-marker
4202 (next-single-property-change (point) 'mime-view-entity
4204 (let ((types (mime-entity-content-type entity)))
4205 (while (eq 'multipart (mime-content-type-primary-type types))
4206 (setq entity (car (mime-entity-children entity))
4207 types (mime-entity-content-type entity)))
4209 (setq type (format "%s/%s"
4210 (mime-content-type-primary-type types)
4211 (mime-content-type-subtype types)))))
4212 (if (string-equal type "message/rfc822")
4215 (let ((children (mime-entity-children entity))
4218 (setq last-children (nth (1- (length children)) children))
4221 (not (eq last-children
4222 (get-text-property next 'mime-view-entity)))
4224 (next-single-property-change next
4226 nil (point-max)))))))
4227 (setq next (next-single-property-change next 'mime-view-entity
4230 (narrow-to-region (point) next)
4231 (gnus-article-prepare-mime-display)
4232 (goto-char (point-max)))
4233 (setq entity (get-text-property (point) 'mime-view-entity)))
4235 (narrow-to-region (point) next)
4236 ;; Kludge. We have to count true number, but for now,
4237 ;; part number is here only to achieve `last'.
4238 (gnus-treat-article nil 1
4239 (if (eq entity last-entity)
4242 (goto-char (point-max)))
4243 (setq entity (get-text-property next 'mime-view-entity))))))
4246 (defun gnus-article-prepare-display ()
4247 "Make the current buffer look like a nice article."
4248 (let ((gnus-article-buffer (current-buffer))
4250 (inhibit-read-only t))
4251 (unless (eq major-mode 'gnus-article-mode)
4252 (gnus-article-mode))
4253 (setq buffer-read-only nil
4254 gnus-button-marker-list nil
4255 gnus-article-wash-types nil
4256 gnus-article-image-alist nil)
4259 (static-if (featurep 'xemacs)
4260 (map-extents (lambda (extent maparg) (delete-extent extent)))
4261 (let ((lists (overlay-lists)))
4262 (dolist (overlay (nconc (car lists) (cdr lists)))
4263 (delete-overlay overlay)))))
4264 (gnus-run-hooks 'gnus-tmp-internal-hook))
4265 (let ((show-mime (unless (member gnus-newsgroup-name '("nndraft:delayed"
4268 (inhibit-read-only t))
4269 (set-buffer gnus-original-article-buffer)
4271 (setq mime-message-structure gnus-current-headers)
4272 (mime-buffer-entity-set-buffer-internal mime-message-structure
4273 gnus-original-article-buffer)
4274 (mime-entity-set-representation-type-internal mime-message-structure
4275 'mime-buffer-entity)
4276 (luna-send mime-message-structure 'initialize-instance
4277 mime-message-structure)
4279 (let (mime-display-header-hook mime-display-text/plain-hook)
4280 (funcall gnus-article-display-method-for-mime))
4281 (funcall gnus-article-display-method-for-traditional))
4282 ;; Call the treatment functions.
4286 (gnus-article-prepare-mime-display)
4287 (narrow-to-region (goto-char (point-min))
4288 (if (search-forward "\n\n" nil t)
4291 (gnus-treat-article 'head)
4292 (put-text-property (point-min) (point-max) 'article-treated-header t)
4293 (goto-char (point-max))
4295 (narrow-to-region (point) (point-max))
4296 (gnus-treat-article nil))
4297 (put-text-property (point-min) (point-max) 'read-only nil)))
4298 (gnus-run-hooks 'gnus-article-prepare-hook))
4300 (defun gnus-article-decode-article-as-default-mime-charset ()
4301 "Decode an article as `default-mime-charset'. It won't work if the
4302 value of the variable `gnus-show-mime' is non-nil."
4303 (unless (or gnus-show-mime
4304 (member gnus-newsgroup-name '("nndraft:delayed"
4306 (set (make-local-variable 'default-mime-charset)
4307 (with-current-buffer gnus-summary-buffer
4308 default-mime-charset))
4309 (decode-mime-charset-region (point-min) (point-max)
4310 default-mime-charset)))
4313 ;;; Gnus MIME viewing functions
4316 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4317 "Format of the MIME buttons.
4319 Valid specifiers include:
4321 %T MIME type, along with additional info
4322 %n The `name' parameter
4323 %d The description, if any
4324 %l The length of the encoded part
4325 %p The part identifier number
4326 %e Dots if the part isn't displayed
4328 General format specifiers can also be used. See Info node
4329 `(gnus)Formatting Variables'.")
4331 (defvar gnus-mime-button-line-format-alist
4332 '((?t gnus-tmp-type ?s)
4333 (?T gnus-tmp-type-long ?s)
4334 (?n gnus-tmp-name ?s)
4335 (?d gnus-tmp-description ?s)
4337 (?l gnus-tmp-length ?d)
4338 (?e gnus-tmp-dots ?s)))
4340 (defvar gnus-mime-button-commands
4341 '((gnus-article-press-button "\r" "Toggle Display")
4342 (gnus-mime-view-part "v" "View Interactively...")
4343 (gnus-mime-view-part-as-type "t" "View As Type...")
4344 (gnus-mime-view-part-as-charset "C" "View As charset...")
4345 (gnus-mime-save-part "o" "Save...")
4346 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4347 (gnus-mime-delete-part "d" "Delete part")
4348 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4349 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4350 (gnus-mime-view-part-internally "E" "View Internally")
4351 (gnus-mime-view-part-externally "e" "View Externally")
4352 (gnus-mime-print-part "p" "Print")
4353 (gnus-mime-pipe-part "|" "Pipe To Command...")
4354 (gnus-mime-action-on-part "." "Take action on the part...")))
4356 (defun gnus-article-mime-part-status ()
4357 (with-current-buffer gnus-article-buffer
4358 (let ((entity (get-text-property (point-min) 'mime-view-entity))
4361 (setq children (mime-entity-children entity))
4362 (setq children (length children)))
4365 (format " (%d parts)" children))
4368 (defvar gnus-mime-button-map
4369 (let ((map (make-sparse-keymap)))
4370 (define-key map gnus-mouse-2 'gnus-article-push-button)
4371 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4372 (dolist (c gnus-mime-button-commands)
4373 (define-key map (cadr c) (car c)))
4377 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4379 ,@(mapcar (lambda (c)
4380 (vector (caddr c) (car c) :enable t))
4381 gnus-mime-button-commands)))
4383 (defun gnus-mime-button-menu (event prefix)
4384 "Construct a context-sensitive menu of MIME commands."
4385 (interactive "e\nP")
4386 (save-window-excursion
4387 (let ((pos (event-start event)))
4388 (select-window (posn-window pos))
4389 (goto-char (posn-point pos))
4390 (gnus-article-check-buffer)
4391 (popup-menu gnus-mime-button-menu nil prefix))))
4393 (defun gnus-mime-view-all-parts (&optional handles)
4394 "View all the MIME parts."
4396 (with-current-buffer gnus-article-buffer
4397 (let ((handles (or handles gnus-article-mime-handles))
4398 (mail-parse-charset gnus-newsgroup-charset)
4399 (mail-parse-ignored-charsets
4400 (with-current-buffer gnus-summary-buffer
4401 gnus-newsgroup-ignored-charsets)))
4403 (mm-remove-parts handles)
4404 (goto-char (point-min))
4405 (or (search-forward "\n\n") (goto-char (point-max)))
4406 (let ((inhibit-read-only t))
4407 (delete-region (point) (point-max))
4408 (mm-display-parts handles))))))
4411 (defsubst gnus-article-edit-part (handles)
4412 "Edit an article in order to delete a mime part.
4413 This function is exclusively used by `gnus-mime-save-part-and-strip'
4414 and `gnus-mime-delete-part', and not provided at run-time normally."
4415 (gnus-article-edit-article
4418 (let ((mail-parse-charset (or gnus-article-charset
4419 ',gnus-newsgroup-charset))
4420 (mail-parse-ignored-charsets
4421 (or gnus-article-ignored-charsets
4422 ',gnus-newsgroup-ignored-charsets))
4423 (mbl mml-buffer-list))
4424 (setq mml-buffer-list nil)
4425 (insert-buffer gnus-original-article-buffer)
4426 (mime-to-mml ',handles)
4427 (setq gnus-article-mime-handles nil)
4428 (let ((mbl1 mml-buffer-list))
4429 (setq mml-buffer-list mbl)
4430 (set (make-local-variable 'mml-buffer-list) mbl1))
4431 (gnus-make-local-hook 'kill-buffer-hook)
4432 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4433 `(lambda (no-highlight)
4434 (let ((mail-parse-charset (or gnus-article-charset
4435 ',gnus-newsgroup-charset))
4436 (message-options message-options)
4437 (message-options-set-recipient)
4438 (mail-parse-ignored-charsets
4439 (or gnus-article-ignored-charsets
4440 ',gnus-newsgroup-ignored-charsets)))
4442 (mml-destroy-buffers)
4443 (remove-hook 'kill-buffer-hook
4444 'mml-destroy-buffers t)
4445 (kill-local-variable 'mml-buffer-list))
4446 (gnus-summary-edit-article-done
4447 ,(or (mail-header-references gnus-current-headers) "")
4448 ,(gnus-group-read-only-p)
4449 ,gnus-summary-buffer no-highlight)))
4450 (gnus-article-edit-done)
4451 (gnus-summary-expand-window)
4452 (gnus-summary-show-article)))
4454 (defun gnus-mime-save-part-and-strip ()
4455 "Save the MIME part under point then replace it with an external body."
4457 (gnus-article-check-buffer)
4458 (when (gnus-group-read-only-p)
4459 (error "The current group does not support deleting of parts"))
4460 (when (mm-complicated-handles gnus-article-mime-handles)
4462 The current article has a complicated MIME structure, giving up..."))
4463 (when (gnus-yes-or-no-p "\
4464 Deleting parts may malfunction or destroy the article; continue? ")
4465 (let* ((data (get-text-property (point) 'gnus-data))
4467 (handles gnus-article-mime-handles))
4468 (setq file (and data (mm-save-part data)))
4470 (with-current-buffer (mm-handle-buffer data)
4472 (insert "Content-Type: " (mm-handle-media-type data))
4473 (mml-insert-parameter-string (cdr (mm-handle-type data))
4476 (insert "Content-ID: " (message-make-message-id) "\n")
4477 (insert "Content-Transfer-Encoding: binary\n")
4480 (cdr (mm-make-handle nil
4481 `("message/external-body"
4482 (access-type . "LOCAL-FILE")
4484 (set-buffer gnus-summary-buffer)
4485 (gnus-article-edit-part handles)))))
4487 (defun gnus-mime-delete-part ()
4488 "Delete the MIME part under point.
4489 Replace it with some information about the removed part."
4491 (gnus-article-check-buffer)
4492 (when (gnus-group-read-only-p)
4493 (error "The current group does not support deleting of parts"))
4494 (when (mm-complicated-handles gnus-article-mime-handles)
4496 The current article has a complicated MIME structure, giving up..."))
4497 (when (gnus-yes-or-no-p "\
4498 Deleting parts may malfunction or destroy the article; continue? ")
4499 (let* ((data (get-text-property (point) 'gnus-data))
4500 (handles gnus-article-mime-handles)
4504 (mail-decode-encoded-word-string (or (mm-handle-description data)
4507 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4509 (type (mm-handle-media-type data)))
4511 (error "No MIME part under point"))
4512 (with-current-buffer (mm-handle-buffer data)
4513 (let ((bsize (format "%s" (buffer-size))))
4518 "| The following attachment has been deleted:\n"
4520 "| Type: " type "\n"
4521 "| Filename: " filename "\n"
4522 "| Size (encoded): " bsize " Byte\n"
4523 "| Description: " description "\n"
4526 (cdr (mm-make-handle
4527 nil `("text/plain") nil nil
4529 (format "Deleted attachment (%s bytes)" bsize))))))
4530 (set-buffer gnus-summary-buffer)
4531 (gnus-article-edit-part handles))))
4533 (defun gnus-mime-save-part ()
4534 "Save the MIME part under point."
4536 (gnus-article-check-buffer)
4537 (let ((data (get-text-property (point) 'gnus-data)))
4539 (mm-save-part data))))
4541 (defun gnus-mime-pipe-part ()
4542 "Pipe the MIME part under point to a process."
4544 (gnus-article-check-buffer)
4545 (let ((data (get-text-property (point) 'gnus-data)))
4547 (mm-pipe-part data))))
4549 (defun gnus-mime-view-part ()
4550 "Interactively choose a viewing method for the MIME part under point."
4552 (gnus-article-check-buffer)
4553 (let ((data (get-text-property (point) 'gnus-data)))
4555 (setq gnus-article-mime-handles
4557 gnus-article-mime-handles (setq data (copy-sequence data))))
4558 (mm-interactively-view-part data))))
4560 (defun gnus-mime-view-part-as-type-internal ()
4561 (gnus-article-check-buffer)
4562 (let* ((name (mail-content-type-get
4563 (mm-handle-type (get-text-property (point) 'gnus-data))
4565 (def-type (and name (mm-default-file-encoding name))))
4566 (and def-type (cons def-type 0))))
4568 (defun gnus-mime-view-part-as-type (&optional mime-type)
4569 "Choose a MIME media type, and view the part as such."
4572 (setq mime-type (completing-read
4573 "View as MIME type: "
4574 (mapcar #'list (mailcap-mime-types))
4576 (gnus-mime-view-part-as-type-internal))))
4577 (gnus-article-check-buffer)
4578 (let ((handle (get-text-property (point) 'gnus-data)))
4581 (mm-make-handle (mm-handle-buffer handle)
4582 (cons mime-type (cdr (mm-handle-type handle)))
4583 (mm-handle-encoding handle)
4584 (mm-handle-undisplayer handle)
4585 (mm-handle-disposition handle)
4586 (mm-handle-description handle)
4588 (mm-handle-id handle)))
4589 (setq gnus-article-mime-handles
4590 (mm-merge-handles gnus-article-mime-handles handle))
4591 (gnus-mm-display-part handle))))
4594 (require 'jka-compr))
4596 ;; jka-compr.el uses a "sh -c" to direct stderr to err-file, but these days
4597 ;; emacs can do that itself.
4599 (defun gnus-mime-jka-compr-maybe-uncompress ()
4600 "Uncompress the current buffer if `auto-compression-mode' is enabled.
4601 The uncompress method used is derived from `buffer-file-name'."
4602 (when (and (fboundp 'jka-compr-installed-p)
4603 (jka-compr-installed-p))
4604 (let ((info (jka-compr-get-compression-info buffer-file-name)))
4606 (let ((basename (file-name-nondirectory buffer-file-name))
4607 (args (jka-compr-info-uncompress-args info))
4608 (prog (jka-compr-info-uncompress-program info))
4609 (message (jka-compr-info-uncompress-message info))
4610 (err-file (jka-compr-make-temp-name)))
4612 (message "%s %s..." message basename))
4614 (unless (memq (apply 'call-process-region
4615 (point-min) (point-max)
4617 t (list t err-file) nil
4619 jka-compr-acceptable-retval-list)
4620 (jka-compr-error prog args basename message err-file))
4621 (jka-compr-delete-temp-file err-file)))))))
4623 (defun gnus-mime-copy-part (&optional handle)
4624 "Put the MIME part under point into a new buffer.
4625 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4628 (gnus-article-check-buffer)
4629 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4630 (contents (and handle (mm-get-part handle)))
4632 (file-name-nondirectory
4634 (mail-content-type-get (mm-handle-type handle) 'name)
4635 (mail-content-type-get (mm-handle-disposition handle)
4638 (buffer (and base (generate-new-buffer base))))
4640 (switch-to-buffer buffer)
4642 ;; We do it this way to make `normal-mode' set the appropriate mode.
4645 (setq buffer-file-name (expand-file-name base))
4646 (gnus-mime-jka-compr-maybe-uncompress)
4648 (setq buffer-file-name nil))
4649 (goto-char (point-min)))))
4651 (defun gnus-mime-print-part (&optional handle filename)
4652 "Print the MIME part under point."
4653 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4654 (gnus-article-check-buffer)
4655 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4656 (contents (and handle (mm-get-part handle)))
4657 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4658 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4663 (mm-save-part-to-file handle file)
4664 (call-process shell-file-name nil
4665 (generate-new-buffer " *mm*")
4667 shell-command-switch
4669 printer file (mm-handle-type handle))))
4673 (gnus-print-buffer))
4674 (ps-despool filename)))))
4676 (defun gnus-mime-inline-part (&optional handle arg)
4677 "Insert the MIME part under point into the current buffer."
4678 (interactive (list nil current-prefix-arg))
4679 (gnus-article-check-buffer)
4680 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4683 (inhibit-read-only t))
4685 (if (and (not arg) (mm-handle-undisplayer handle))
4686 (mm-remove-part handle)
4687 (setq contents (mm-get-part handle))
4690 (setq charset (or (mail-content-type-get
4691 (mm-handle-type handle) 'charset)
4692 gnus-newsgroup-charset)))
4694 (if (mm-handle-undisplayer handle)
4695 (mm-remove-part handle))
4698 gnus-summary-show-article-charset-alist))
4699 (mm-read-coding-system "Charset: ")))))
4701 (mm-insert-inline handle
4703 (setq charset (mm-charset-to-coding-system
4705 (not (eq charset 'ascii)))
4706 (mm-decode-coding-string contents charset)
4710 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4711 "Insert the MIME part under point into the current buffer using the
4713 (interactive (list nil current-prefix-arg))
4714 (gnus-article-check-buffer)
4715 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4718 (inhibit-read-only t))
4720 (if (mm-handle-undisplayer handle)
4721 (mm-remove-part handle))
4722 (let ((gnus-newsgroup-charset
4724 gnus-summary-show-article-charset-alist))
4725 (mm-read-coding-system "Charset: ")))
4726 (gnus-newsgroup-ignored-charsets 'gnus-all))
4727 (gnus-article-press-button)))))
4729 (defun gnus-mime-view-part-externally (&optional handle)
4730 "View the MIME part under point with an external viewer."
4732 (gnus-article-check-buffer)
4733 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4734 (mm-user-display-methods nil)
4735 (mm-inlined-types nil)
4736 (mail-parse-charset gnus-newsgroup-charset)
4737 (mail-parse-ignored-charsets
4738 (with-current-buffer gnus-summary-buffer
4739 gnus-newsgroup-ignored-charsets)))
4741 (if (mm-handle-undisplayer handle)
4742 (mm-remove-part handle)
4743 (mm-display-part handle)))))
4745 (defun gnus-mime-view-part-internally (&optional handle)
4746 "View the MIME part under point with an internal viewer.
4747 If no internal viewer is available, use an external viewer."
4749 (gnus-article-check-buffer)
4750 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4751 (mm-inlined-types '(".*"))
4752 (mm-inline-large-images t)
4753 (mail-parse-charset gnus-newsgroup-charset)
4754 (mail-parse-ignored-charsets
4755 (with-current-buffer gnus-summary-buffer
4756 gnus-newsgroup-ignored-charsets))
4757 (inhibit-read-only t))
4759 (if (mm-handle-undisplayer handle)
4760 (mm-remove-part handle)
4761 (mm-display-part handle)))))
4763 (defun gnus-mime-action-on-part (&optional action)
4764 "Do something with the MIME attachment at \(point\)."
4766 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4767 (gnus-article-check-buffer)
4768 (let ((action-pair (assoc action gnus-mime-action-alist)))
4770 (funcall (cdr action-pair)))))
4772 (defun gnus-article-part-wrapper (n function)
4773 (with-current-buffer gnus-article-buffer
4774 (when (> n (length gnus-article-mime-handle-alist))
4775 (error "No such part"))
4776 (gnus-article-goto-part n)
4777 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4778 (funcall function handle))))
4780 (defun gnus-article-pipe-part (n)
4781 "Pipe MIME part N, which is the numerical prefix."
4783 (gnus-article-part-wrapper n 'mm-pipe-part))
4785 (defun gnus-article-save-part (n)
4786 "Save MIME part N, which is the numerical prefix."
4788 (gnus-article-part-wrapper n 'mm-save-part))
4790 (defun gnus-article-interactively-view-part (n)
4791 "View MIME part N interactively, which is the numerical prefix."
4793 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4795 (defun gnus-article-copy-part (n)
4796 "Copy MIME part N, which is the numerical prefix."
4798 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4800 (defun gnus-article-view-part-as-charset (n)
4801 "View MIME part N using a specified charset.
4802 N is the numerical prefix."
4804 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4806 (defun gnus-article-view-part-externally (n)
4807 "View MIME part N externally, which is the numerical prefix."
4809 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4811 (defun gnus-article-inline-part (n)
4812 "Inline MIME part N, which is the numerical prefix."
4814 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4816 (defun gnus-article-mime-match-handle-first (condition)
4819 (dolist (ihandle gnus-article-mime-handle-alist)
4821 ((functionp condition)
4822 (funcall condition (cdr ihandle)))
4823 ((eq condition 'undisplayed)
4824 (not (or (mm-handle-undisplayer (cdr ihandle))
4825 (equal (mm-handle-media-type (cdr ihandle))
4826 "multipart/alternative"))))
4827 ((eq condition 'undisplayed-alternative)
4828 (not (mm-handle-undisplayer (cdr ihandle))))
4830 (gnus-article-goto-part (car ihandle))
4831 (or (not n) (< (car ihandle) n)))
4832 (setq n (car ihandle))))
4836 (defun gnus-article-view-part (&optional n)
4837 "View MIME part N, which is the numerical prefix."
4839 (with-current-buffer gnus-article-buffer
4840 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4841 gnus-article-mime-match-handle-function)))
4842 (when (> n (length gnus-article-mime-handle-alist))
4843 (error "No such part"))
4844 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4845 (when (gnus-article-goto-part n)
4846 (if (equal (car handle) "multipart/alternative")
4847 (gnus-article-press-button)
4848 (when (eq (gnus-mm-display-part handle) 'internal)
4849 (gnus-set-window-start)))))))
4851 (defsubst gnus-article-mime-total-parts ()
4852 (if (bufferp (car gnus-article-mime-handles))
4854 (1- (length gnus-article-mime-handles))))
4856 (defun gnus-mm-display-part (handle)
4857 "Display HANDLE and fix MIME button."
4858 (let ((id (get-text-property (point) 'gnus-part))
4860 (inhibit-read-only t))
4863 (let ((window (selected-window))
4864 (mail-parse-charset gnus-newsgroup-charset)
4865 (mail-parse-ignored-charsets
4866 (if (gnus-buffer-live-p gnus-summary-buffer)
4867 (with-current-buffer gnus-summary-buffer
4868 gnus-newsgroup-ignored-charsets)
4872 (let ((win (gnus-get-buffer-window (current-buffer) t))
4875 (select-window win))
4878 (if (mm-handle-displayed-p handle)
4879 ;; This will remove the part.
4880 (mm-display-part handle)
4882 (narrow-to-region (point)
4883 (if (eobp) (point) (1+ (point))))
4884 (mm-display-part handle)
4885 ;; We narrow to the part itself and
4886 ;; then call the treatment functions.
4887 (goto-char (point-min))
4889 (narrow-to-region (point) (point-max))
4892 (gnus-article-mime-total-parts)
4893 (mm-handle-media-type handle)))))
4894 (if (window-live-p window)
4895 (select-window window)))))
4898 (gnus-insert-mime-button
4899 handle id (list (mm-handle-displayed-p handle)))
4900 (goto-char point))))
4902 (defun gnus-article-goto-part (n)
4903 "Go to MIME part N."
4904 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4906 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4907 (let ((gnus-tmp-name
4908 (or (mail-content-type-get (mm-handle-type handle) 'name)
4909 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4910 (mail-content-type-get (mm-handle-type handle) 'url)
4912 (gnus-tmp-type (mm-handle-media-type handle))
4913 (gnus-tmp-description
4914 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4917 (if (if displayed (car displayed)
4918 (mm-handle-displayed-p handle))
4920 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4922 gnus-tmp-type-long b e)
4923 (when (string-match ".*/" gnus-tmp-name)
4924 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4925 (setq gnus-tmp-type-long (concat gnus-tmp-type
4926 (and (not (equal gnus-tmp-name ""))
4927 (concat "; " gnus-tmp-name))))
4928 (unless (equal gnus-tmp-description "")
4929 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4934 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4935 `(keymap ,gnus-mime-button-map
4936 gnus-callback gnus-mm-display-part
4937 gnus-part ,gnus-tmp-id
4938 article-type annotation
4941 ;; Exclude a newline.
4944 (widget-convert-button
4947 :action 'gnus-widget-press-button
4948 :button-keymap gnus-mime-button-map
4950 (lambda (widget/window &optional overlay pos)
4951 ;; Needed to properly clear the message due to a bug in
4952 ;; wid-edit (XEmacs only).
4953 (if (boundp 'help-echo-owns-message)
4954 (setq help-echo-owns-message t))
4956 "%S: %s the MIME part; %S: more options"
4957 (aref gnus-mouse-2 0)
4958 ;; XEmacs will get a single widget arg; Emacs 21 will get
4959 ;; window, overlay, position.
4960 (if (mm-handle-displayed-p
4962 (with-current-buffer (gnus-overlay-buffer overlay)
4963 (widget-get (widget-at (gnus-overlay-start overlay))
4965 (widget-get widget/window :mime-handle)))
4967 (aref gnus-down-mouse-3 0))))))
4969 (defun gnus-widget-press-button (elems el)
4970 (goto-char (widget-get elems :from))
4971 (gnus-article-press-button))
4973 (defvar gnus-displaying-mime nil)
4975 (defun gnus-display-mime (&optional ihandles)
4976 "Display the MIME parts."
4978 (save-selected-window
4979 (let ((window (get-buffer-window gnus-article-buffer))
4982 (select-window window)
4983 ;; We have to do this since selecting the window
4984 ;; may change the point. So we set the window point.
4985 (set-window-point window point)))
4986 (let ((handles ihandles)
4987 (inhibit-read-only t)
4988 handle name type b e display)
4990 ((setq handles (mm-dissect-buffer nil gnus-article-loose-mime))
4991 (when gnus-article-emulate-mime
4992 (mm-uu-dissect-text-parts handles)))
4993 (gnus-article-emulate-mime
4994 (setq handles (mm-uu-dissect))))
4995 (when (and (not ihandles)
4996 (not gnus-displaying-mime))
4997 ;; Top-level call; we clean up.
4998 (when gnus-article-mime-handles
4999 (mm-destroy-parts gnus-article-mime-handles)
5000 (setq gnus-article-mime-handle-alist nil));; A trick.
5001 (setq gnus-article-mime-handles handles)
5002 ;; We allow users to glean info from the handles.
5003 (when gnus-article-mime-part-function
5004 (gnus-mime-part-function handles)))
5006 (or (not (stringp (car handles)))
5009 (when (and (not ihandles)
5010 (not gnus-displaying-mime))
5011 ;; Clean up for mime parts.
5013 (delete-region (point) (point-max)))
5014 (let ((gnus-displaying-mime t))
5015 (gnus-mime-display-part handles)))
5018 (narrow-to-region (point) (point-max))
5019 (gnus-treat-article nil 1 1)
5022 ;; Highlight the headers.
5026 (narrow-to-region (point-min) (point))
5027 (gnus-treat-article 'head))))))))
5029 (defcustom gnus-mime-display-multipart-as-mixed nil
5030 "Display \"multipart\" parts as \"multipart/mixed\".
5032 If t, it overrides nil values of
5033 `gnus-mime-display-multipart-alternative-as-mixed' and
5034 `gnus-mime-display-multipart-related-as-mixed'."
5035 :group 'gnus-article-mime
5038 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
5039 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
5041 :group 'gnus-article-mime
5044 (defcustom gnus-mime-display-multipart-related-as-mixed nil
5045 "Display \"multipart/related\" parts as \"multipart/mixed\".
5047 If displaying \"text/html\" is discouraged \(see
5048 `mm-discouraged-alternatives'\) images or other material inside a
5049 \"multipart/related\" part might be overlooked when this variable is nil."
5051 :group 'gnus-article-mime
5054 (defun gnus-mime-display-part (handle)
5057 ((not (stringp (car handle)))
5058 (gnus-mime-display-single handle))
5059 ;; User-defined multipart
5060 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
5061 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
5063 ;; multipart/alternative
5064 ((and (equal (car handle) "multipart/alternative")
5065 (not (or gnus-mime-display-multipart-as-mixed
5066 gnus-mime-display-multipart-alternative-as-mixed)))
5067 (let ((id (1+ (length gnus-article-mime-handle-alist))))
5068 (push (cons id handle) gnus-article-mime-handle-alist)
5069 (gnus-mime-display-alternative (cdr handle) nil nil id)))
5070 ;; multipart/related
5071 ((and (equal (car handle) "multipart/related")
5072 (not (or gnus-mime-display-multipart-as-mixed
5073 gnus-mime-display-multipart-related-as-mixed)))
5074 ;;;!!!We should find the start part, but we just default
5075 ;;;!!!to the first part.
5076 ;;(gnus-mime-display-part (cadr handle))
5077 ;;;!!! Most multipart/related is an HTML message plus images.
5078 ;;;!!! Unfortunately we are unable to let W3 display those
5079 ;;;!!! included images, so we just display it as a mixed multipart.
5080 ;;(gnus-mime-display-mixed (cdr handle))
5081 ;;;!!! No, w3 can display everything just fine.
5082 (gnus-mime-display-part (cadr handle)))
5083 ((equal (car handle) "multipart/signed")
5084 (gnus-add-wash-type 'signed)
5085 (gnus-mime-display-security handle))
5086 ((equal (car handle) "multipart/encrypted")
5087 (gnus-add-wash-type 'encrypted)
5088 (gnus-mime-display-security handle))
5089 ;; Other multiparts are handled like multipart/mixed.
5091 (gnus-mime-display-mixed (cdr handle)))))
5093 (defun gnus-mime-part-function (handles)
5094 (if (stringp (car handles))
5095 (mapcar 'gnus-mime-part-function (cdr handles))
5096 (funcall gnus-article-mime-part-function handles)))
5098 (defun gnus-mime-display-mixed (handles)
5099 (mapcar 'gnus-mime-display-part handles))
5101 (defun gnus-mime-display-single (handle)
5102 (let ((type (mm-handle-media-type handle))
5103 (ignored gnus-ignored-mime-types)
5110 (when (string-match (pop ignored) type)
5111 (throw 'ignored nil)))
5112 (if (and (setq not-attachment
5113 (and (not (mm-inline-override-p handle))
5114 (or (not (mm-handle-disposition handle))
5115 (equal (car (mm-handle-disposition handle))
5117 (mm-attachment-override-p handle))))
5118 (mm-automatic-display-p handle)
5120 (mm-inlinable-p handle)
5121 (mm-inlined-p handle))
5122 (mm-automatic-external-display-p type)))
5124 (when (equal (mm-handle-media-supertype handle) "text")
5126 (let ((id (1+ (length gnus-article-mime-handle-alist)))
5128 (push (cons id handle) gnus-article-mime-handle-alist)
5129 (when (or (not display)
5130 (not (gnus-unbuttonized-mime-type-p type)))
5131 (gnus-insert-mime-button
5132 handle id (list (or display (and not-attachment text))))
5133 (gnus-article-insert-newline)
5134 ;; Remember modify the number of forward lines.
5142 (let ((mail-parse-charset gnus-newsgroup-charset)
5143 (mail-parse-ignored-charsets
5144 (save-excursion (condition-case ()
5145 (set-buffer gnus-summary-buffer)
5147 gnus-newsgroup-ignored-charsets)))
5148 (mm-display-part handle t))
5149 (goto-char (point-max)))
5150 ((and text not-attachment)
5154 (gnus-article-insert-newline)
5155 (mm-display-inline handle)
5156 (goto-char (point-max))))
5160 (narrow-to-region beg (point))
5163 (gnus-article-mime-total-parts)
5164 (mm-handle-media-type handle)))))))))
5166 (defun gnus-unbuttonized-mime-type-p (type)
5167 "Say whether TYPE is to be unbuttonized."
5168 (unless gnus-inhibit-mime-unbuttonizing
5170 (let ((types gnus-unbuttonized-mime-types))
5172 (when (string-match (pop types) type)
5173 (throw 'found t)))))
5175 (let ((types gnus-buttonized-mime-types))
5177 (when (string-match (pop types) type)
5178 (throw 'found t)))))))))
5180 (defun gnus-article-insert-newline ()
5181 "Insert a newline, but mark it as undeletable."
5182 (gnus-put-text-property
5183 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
5185 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
5186 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
5189 handle (inhibit-read-only t) from props begend not-pref)
5190 (save-window-excursion
5193 (narrow-to-region (car ibegend)
5196 (goto-char (car ibegend))
5199 (delete-region (point-min) (point-max))
5200 (mm-remove-parts handles))
5201 (setq begend (list (point-marker)))
5203 (unless (setq not-pref (cadr (member preferred ihandles)))
5204 (setq not-pref (car ihandles)))
5207 (not (gnus-unbuttonized-mime-type-p
5208 "multipart/alternative")))
5209 (gnus-add-text-properties
5212 (insert (format "%d. " id))
5216 (unless ,(not ibegend)
5217 (setq gnus-article-mime-handle-alist
5218 ',gnus-article-mime-handle-alist))
5219 (gnus-mime-display-alternative
5220 ',ihandles ',not-pref ',begend ,id))
5221 keymap ,gnus-mime-button-map
5222 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5223 face ,gnus-article-button-face
5226 (widget-convert-button 'link from (point)
5227 :action 'gnus-widget-press-button
5228 :button-keymap gnus-widget-button-keymap)
5230 (while (setq handle (pop handles))
5231 (gnus-add-text-properties
5234 (insert (format "(%c) %-18s"
5235 (if (equal handle preferred) ?* ? )
5236 (mm-handle-media-type handle)))
5240 (unless ,(not ibegend)
5241 (setq gnus-article-mime-handle-alist
5242 ',gnus-article-mime-handle-alist))
5243 (gnus-mime-display-alternative
5244 ',ihandles ',handle ',begend ,id))
5245 keymap ,gnus-mime-button-map
5246 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5247 face ,gnus-article-button-face
5250 (widget-convert-button 'link from (point)
5251 :action 'gnus-widget-press-button
5252 :button-keymap gnus-widget-button-keymap)
5256 (if (stringp (car preferred))
5257 (gnus-display-mime preferred)
5258 (let ((mail-parse-charset gnus-newsgroup-charset)
5259 (mail-parse-ignored-charsets
5260 (with-current-buffer gnus-summary-buffer
5261 gnus-newsgroup-ignored-charsets)))
5262 (mm-display-part preferred)
5266 (narrow-to-region (car begend) (point-max))
5268 nil (length gnus-article-mime-handle-alist)
5269 (gnus-article-mime-total-parts)
5270 (mm-handle-media-type handle))))))
5271 (goto-char (point-max))
5272 (setcdr begend (point-marker)))))
5274 (goto-char point))))
5276 (defconst gnus-article-wash-status-strings
5277 (let ((alist '((cite "c" "Possible hidden citation text"
5278 " " "All citation text visible")
5279 (headers "h" "Hidden headers"
5280 " " "All headers visible.")
5281 (pgp "p" "Encrypted or signed message status hidden"
5282 " " "No hidden encryption nor digital signature status")
5283 (signature "s" "Signature has been hidden"
5284 " " "Signature is visible")
5285 (overstrike "o" "Overstrike (^H) characters applied"
5286 " " "No overstrike characters applied")
5287 (gnus-show-mime "m" "Mime processing is activated"
5288 " " "Mime processing is not activated")
5289 (emphasis "e" "/*_Emphasis_*/ characters applied"
5290 " " "No /*_emphasis_*/ characters applied")))
5292 (dolist (entry alist result)
5293 (let ((key (nth 0 entry))
5294 (on (copy-sequence (nth 1 entry)))
5295 (on-help (nth 2 entry))
5296 (off (copy-sequence (nth 3 entry)))
5297 (off-help (nth 4 entry)))
5298 (put-text-property 0 1 'help-echo on-help on)
5299 (put-text-property 0 1 'help-echo off-help off)
5300 (push (list key on off) result))))
5301 "Alist of strings describing wash status in the mode line.
5302 Each entry has the form (KEY ON OF), where the KEY is a symbol
5303 representing the particular washing function, ON is the string to use
5304 in the article mode line when the washing function is active, and OFF
5305 is the string to use when it is inactive.")
5307 (defun gnus-article-wash-status-entry (key value)
5308 (let ((entry (assoc key gnus-article-wash-status-strings)))
5309 (if value (nth 1 entry) (nth 2 entry))))
5311 (defun gnus-article-wash-status ()
5312 "Return a string which display status of article washing."
5313 (with-current-buffer gnus-article-buffer
5314 (let ((cite (memq 'cite gnus-article-wash-types))
5315 (headers (memq 'headers gnus-article-wash-types))
5316 (boring (memq 'boring-headers gnus-article-wash-types))
5317 (pgp (memq 'pgp gnus-article-wash-types))
5318 (pem (memq 'pem gnus-article-wash-types))
5319 (signed (memq 'signed gnus-article-wash-types))
5320 (encrypted (memq 'encrypted gnus-article-wash-types))
5321 (signature (memq 'signature gnus-article-wash-types))
5322 (overstrike (memq 'overstrike gnus-article-wash-types))
5323 (emphasis (memq 'emphasis gnus-article-wash-types)))
5325 (gnus-article-wash-status-entry 'cite cite)
5326 (gnus-article-wash-status-entry 'headers (or headers boring))
5327 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5328 (gnus-article-wash-status-entry 'signature signature)
5329 (gnus-article-wash-status-entry 'overstrike overstrike)
5330 (gnus-article-wash-status-entry 'gnus-show-mime gnus-show-mime)
5331 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5333 (defun gnus-add-wash-type (type)
5334 "Add a washing of TYPE to the current status."
5335 (add-to-list 'gnus-article-wash-types type))
5337 (defun gnus-delete-wash-type (type)
5338 "Add a washing of TYPE to the current status."
5339 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5341 (defun gnus-add-image (category image)
5342 "Add IMAGE of CATEGORY to the list of displayed images."
5343 (let ((entry (assq category gnus-article-image-alist)))
5345 (setq entry (list category))
5346 (push entry gnus-article-image-alist))
5347 (nconc entry (list image))))
5349 (defun gnus-delete-images (category)
5350 "Delete all images in CATEGORY."
5351 (let ((entry (assq category gnus-article-image-alist)))
5352 (dolist (image (cdr entry))
5353 (gnus-remove-image image category))
5354 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5355 (gnus-delete-wash-type category)))
5357 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5359 (defun gnus-article-maybe-hide-headers ()
5360 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5361 Provided for backwards compatibility."
5362 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5363 (not (with-current-buffer gnus-summary-buffer
5364 gnus-have-all-headers)))
5365 (not gnus-inhibit-hiding))
5366 (gnus-article-hide-headers)))
5370 (defun gnus-output-to-file (file-name)
5371 "Append the current article to a file named FILE-NAME."
5372 (let ((artbuf (current-buffer)))
5374 (insert-buffer-substring artbuf)
5375 ;; Append newline at end of the buffer as separator, and then
5377 (goto-char (point-max))
5379 (let ((file-name-coding-system nnmail-pathname-coding-system))
5380 (write-region-as-binary (point-min) (point-max) file-name 'append))
5383 (defun gnus-narrow-to-page (&optional arg)
5384 "Narrow the article buffer to a page.
5385 If given a numerical ARG, move forward ARG pages."
5387 (setq arg (if arg (prefix-numeric-value arg) 0))
5389 (set-buffer gnus-article-buffer)
5390 (goto-char (point-min))
5392 ;; Remove any old next/prev buttons.
5393 (when (gnus-visual-p 'page-marker)
5394 (let ((inhibit-read-only t))
5395 (gnus-remove-text-with-property 'gnus-prev)
5396 (gnus-remove-text-with-property 'gnus-next)))
5399 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5401 (re-search-forward page-delimiter nil 'move arg)))
5402 (goto-char (match-end 0))
5404 (goto-char (point-min))
5405 (setq gnus-page-broken
5406 (and (re-search-forward page-delimiter nil t) t))))
5407 (when gnus-page-broken
5410 (if (re-search-forward page-delimiter nil 'move)
5413 (when (and (gnus-visual-p 'page-marker)
5414 (> (point-min) (save-restriction (widen) (point-min))))
5416 (goto-char (point-min))
5417 (gnus-insert-prev-page-button)))
5418 (when (and (gnus-visual-p 'page-marker)
5419 (< (point-max) (save-restriction (widen) (point-max))))
5421 (goto-char (point-max))
5422 (gnus-insert-next-page-button))))))
5424 ;; Article mode commands
5426 (defun gnus-article-goto-next-page ()
5427 "Show the next page of the article."
5429 (when (gnus-article-next-page)
5430 (goto-char (point-min))
5431 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5434 (defun gnus-article-goto-prev-page ()
5435 "Show the previous page of the article."
5438 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5439 (gnus-article-prev-page nil)))
5441 ;; This is cleaner but currently breaks `gnus-pick-mode':
5443 ;; (defun gnus-article-goto-next-page ()
5444 ;; "Show the next page of the article."
5446 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5447 ;; (gnus-summary-next-page)))
5449 ;; (defun gnus-article-goto-prev-page ()
5450 ;; "Show the next page of the article."
5452 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5453 ;; (gnus-summary-prev-page)))
5455 (defun gnus-article-next-page (&optional lines)
5456 "Show the next page of the current article.
5457 If end of article, return non-nil. Otherwise return nil.
5458 Argument LINES specifies lines to be scrolled up."
5460 (move-to-window-line -1)
5463 (and (pos-visible-in-window-p) ;Not continuation line.
5464 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5465 ;; Nothing in this page.
5466 (if (or (not gnus-page-broken)
5471 (eobp)))) ;Real end-of-buffer?
5473 (when gnus-article-over-scroll
5474 (gnus-article-next-page-1 lines))
5476 (gnus-narrow-to-page 1) ;Go to next page.
5478 ;; More in this page.
5479 (gnus-article-next-page-1 lines)
5482 (defun gnus-article-next-page-1 (lines)
5483 (let ((scroll-in-place nil))
5487 ;; Long lines may cause an end-of-buffer error.
5488 (goto-char (point-max)))))
5489 (move-to-window-line 0))
5491 (defun gnus-article-prev-page (&optional lines)
5492 "Show previous page of current article.
5493 Argument LINES specifies lines to be scrolled down."
5495 (move-to-window-line 0)
5496 (if (and gnus-page-broken
5498 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5500 (gnus-narrow-to-page -1) ;Go to previous page.
5501 (goto-char (point-max))
5503 (let ((scroll-in-place nil))
5507 (beginning-of-buffer
5508 (goto-char (point-min))))
5509 (move-to-window-line 0)))))
5511 (defun gnus-article-only-boring-p ()
5512 "Decide whether there is only boring text remaining in the article.
5513 Something \"interesting\" is a word of at least two letters that does
5514 not have a face in `gnus-article-boring-faces'."
5515 (when (and gnus-article-skip-boring
5516 (boundp 'gnus-article-boring-faces)
5517 (symbol-value 'gnus-article-boring-faces))
5520 (while (re-search-forward "\\b\\w\\w" nil t)
5522 (when (not (gnus-intersection
5523 (gnus-faces-at (point))
5524 (symbol-value 'gnus-article-boring-faces)))
5525 (throw 'only-boring nil)))
5526 (throw 'only-boring t)))))
5528 (defun gnus-article-refer-article ()
5529 "Read article specified by message-id around point."
5532 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
5533 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
5534 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
5535 (let ((msg-id (concat "<" (match-string 0) ">")))
5536 (set-buffer gnus-summary-buffer)
5537 (gnus-summary-refer-article msg-id))
5538 (error "No references around point"))))
5540 (defun gnus-article-show-summary ()
5541 "Reconfigure windows to show summary buffer."
5543 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5544 (error "There is no summary buffer for this article buffer")
5545 (gnus-article-set-globals)
5546 (gnus-configure-windows 'article)
5547 (gnus-summary-goto-subject gnus-current-article)
5548 (gnus-summary-position-point)))
5550 (defun gnus-article-describe-briefly ()
5551 "Describe article mode commands briefly."
5553 (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")))
5555 (defun gnus-article-summary-command ()
5556 "Execute the last keystroke in the summary buffer."
5558 (let ((obuf (current-buffer))
5559 (owin (current-window-configuration))
5561 (switch-to-buffer gnus-article-current-summary 'norecord)
5562 (setq func (lookup-key (current-local-map) (this-command-keys)))
5563 (call-interactively func)
5565 (set-window-configuration owin)
5566 (set-window-point (get-buffer-window (current-buffer)) (point))))
5568 (defun gnus-article-summary-command-nosave ()
5569 "Execute the last keystroke in the summary buffer."
5572 (pop-to-buffer gnus-article-current-summary 'norecord)
5573 (setq func (lookup-key (current-local-map) (this-command-keys)))
5574 (call-interactively func)))
5576 (defun gnus-article-check-buffer ()
5577 "Beep if not in an article buffer."
5578 (unless (eq (get-buffer gnus-article-buffer) (current-buffer))
5579 (error "Command invoked outside of a Gnus article buffer")))
5581 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5582 "Read a summary buffer key sequence and execute it from the article buffer."
5584 (gnus-article-check-buffer)
5586 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5587 "Zc" "ZC" "ZE" "ZJ" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5588 "=" "^" "\M-^" "|"))
5594 '("n" "Gn" "p" "Gp"))
5597 (set-buffer gnus-article-current-summary)
5598 (let (gnus-pick-mode)
5599 (push (or key last-command-event) unread-command-events)
5600 (setq keys (static-if (featurep 'xemacs)
5601 (events-to-keys (read-key-sequence nil))
5602 (read-key-sequence nil)))))
5605 (if (or (member keys nosaves)
5606 (member keys nosave-but-article)
5607 (member keys nosave-in-article))
5609 (save-window-excursion
5610 (pop-to-buffer gnus-article-current-summary 'norecord)
5611 ;; We disable the pick minor mode commands.
5612 (let (gnus-pick-mode)
5613 (setq func (lookup-key (current-local-map) keys))))
5617 (unless (member keys nosave-in-article)
5618 (set-buffer gnus-article-current-summary))
5619 (call-interactively func)
5620 (setq new-sum-point (point)))
5621 (when (member keys nosave-but-article)
5622 (pop-to-buffer gnus-article-buffer 'norecord)))
5623 ;; These commands should restore window configuration.
5624 (let ((obuf (current-buffer))
5625 (owin (current-window-configuration))
5627 win func in-buffer selected new-sum-start new-sum-hscroll)
5628 (cond (not-restore-window
5629 (pop-to-buffer gnus-article-current-summary 'norecord))
5630 ((setq win (get-buffer-window gnus-article-current-summary))
5631 (select-window win))
5633 (switch-to-buffer gnus-article-current-summary 'norecord)))
5634 (setq in-buffer (current-buffer))
5635 ;; We disable the pick minor mode commands.
5636 (if (and (setq func (let (gnus-pick-mode)
5637 (lookup-key (current-local-map) keys)))
5640 (call-interactively func)
5641 (when (eq win (selected-window))
5642 (setq new-sum-point (point)
5643 new-sum-start (window-start win)
5644 new-sum-hscroll (window-hscroll win))
5645 (when (eq in-buffer (current-buffer))
5646 (setq selected (gnus-summary-select-article))
5648 (unless not-restore-window
5649 (set-window-configuration owin))
5650 (when (eq selected 'old)
5652 (set-window-start (get-buffer-window (current-buffer))
5654 (set-window-point (get-buffer-window (current-buffer))
5656 (when (and (not not-restore-window)
5658 (set-window-point win new-sum-point)
5659 (set-window-start win new-sum-start)
5660 (set-window-hscroll win new-sum-hscroll)))))
5661 (set-window-configuration owin)
5664 (defun gnus-article-describe-key (key)
5665 "Display documentation of the function invoked by KEY. KEY is a string."
5666 (interactive "kDescribe key: ")
5667 (gnus-article-check-buffer)
5668 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5670 (set-buffer gnus-article-current-summary)
5671 (let (gnus-pick-mode)
5672 (if (featurep 'xemacs)
5674 (push (elt key 0) unread-command-events)
5675 (setq key (events-to-keys
5676 (read-key-sequence "Describe key: "))))
5677 (setq unread-command-events
5679 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5681 (setq key (read-key-sequence "Describe key: "))))
5683 (describe-key key)))
5685 (defun gnus-article-describe-key-briefly (key &optional insert)
5686 "Display documentation of the function invoked by KEY. KEY is a string."
5687 (interactive "kDescribe key: \nP")
5688 (gnus-article-check-buffer)
5689 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5691 (set-buffer gnus-article-current-summary)
5692 (let (gnus-pick-mode)
5693 (if (featurep 'xemacs)
5695 (push (elt key 0) unread-command-events)
5696 (setq key (events-to-keys
5697 (read-key-sequence "Describe key: "))))
5698 (setq unread-command-events
5700 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5702 (setq key (read-key-sequence "Describe key: "))))
5703 (describe-key-briefly key insert))
5704 (describe-key-briefly key insert)))
5706 (defun gnus-article-reply-with-original (&optional wide)
5707 "Start composing a reply mail to the current message.
5708 The text in the region will be yanked. If the region isn't active,
5709 the entire article will be yanked."
5711 (let ((article (cdr gnus-article-current))
5713 (if (not (gnus-region-active-p))
5714 (with-current-buffer gnus-summary-buffer
5715 (gnus-summary-reply (list (list article)) wide))
5716 (setq contents (buffer-substring (point) (mark t)))
5717 ;; Deactivate active regions.
5718 (when (and (boundp 'transient-mark-mode)
5719 transient-mark-mode)
5720 (setq mark-active nil))
5721 (with-current-buffer gnus-summary-buffer
5723 (list (list article contents)) wide)))))
5725 (defun gnus-article-followup-with-original ()
5726 "Compose a followup to the current article.
5727 The text in the region will be yanked. If the region isn't active,
5728 the entire article will be yanked."
5730 (let ((article (cdr gnus-article-current))
5732 (if (not (gnus-region-active-p))
5733 (with-current-buffer gnus-summary-buffer
5734 (gnus-summary-followup (list (list article))))
5735 (setq contents (buffer-substring (point) (mark t)))
5736 ;; Deactivate active regions.
5737 (when (and (boundp 'transient-mark-mode)
5738 transient-mark-mode)
5739 (setq mark-active nil))
5740 (with-current-buffer gnus-summary-buffer
5741 (gnus-summary-followup
5742 (list (list article contents)))))))
5744 (defun gnus-article-hide (&optional arg force)
5745 "Hide all the gruft in the current article.
5746 This means that signatures, cited text and (some) headers will be
5748 If given a prefix, show the hidden text instead."
5749 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5750 (gnus-article-hide-headers arg)
5751 (gnus-article-hide-list-identifiers arg)
5752 (gnus-article-hide-citation-maybe arg force)
5753 (gnus-article-hide-signature arg))
5755 (defun gnus-article-maybe-highlight ()
5756 "Do some article highlighting if article highlighting is requested."
5757 (when (gnus-visual-p 'article-highlight 'highlight)
5758 (gnus-article-highlight-some)))
5760 (defun gnus-check-group-server ()
5761 ;; Make sure the connection to the server is alive.
5762 (unless (gnus-server-opened
5763 (gnus-find-method-for-group gnus-newsgroup-name))
5764 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5765 (gnus-request-group gnus-newsgroup-name t)))
5768 (autoload 'nneething-get-file-name "nneething"))
5770 (defun gnus-request-article-this-buffer (article group)
5771 "Get an article and insert it into this buffer."
5772 (let (do-update-line sparse-header)
5776 (gnus-kill-all-overlays)
5777 (setq group (or group gnus-newsgroup-name))
5779 ;; Using `gnus-request-article' directly will insert the article into
5780 ;; `nntp-server-buffer' - so we'll save some time by not having to
5781 ;; copy it from the server buffer into the article buffer.
5783 ;; We only request an article by message-id when we do not have the
5784 ;; headers for it, so we'll have to get those.
5785 (when (stringp article)
5786 (gnus-read-header article))
5788 ;; If the article number is negative, that means that this article
5789 ;; doesn't belong in this newsgroup (possibly), so we find its
5790 ;; message-id and request it by id instead of number.
5791 (when (and (numberp article)
5793 (get-buffer gnus-summary-buffer)
5794 (gnus-buffer-exists-p gnus-summary-buffer))
5796 (set-buffer gnus-summary-buffer)
5797 (let ((header (gnus-summary-article-header article)))
5800 ((memq article gnus-newsgroup-sparse)
5801 ;; This is a sparse gap article.
5802 (setq do-update-line article)
5803 (setq article (mail-header-id header))
5804 (setq sparse-header (gnus-read-header article))
5805 (setq gnus-newsgroup-sparse
5806 (delq article gnus-newsgroup-sparse)))
5808 ;; It's a real article.
5809 (setq article (mail-header-id header)))
5811 ;; It is an extracted pseudo-article.
5812 (setq article 'pseudo)
5813 (gnus-request-pseudo-article header))))
5815 (let ((method (gnus-find-method-for-group
5816 gnus-newsgroup-name)))
5817 (when (and (eq (car method) 'nneething)
5819 (let ((dir (nneething-get-file-name
5820 (mail-header-id header))))
5821 (when (and (stringp dir)
5822 (file-directory-p dir))
5823 (setq article 'nneething)
5824 (gnus-group-enter-directory dir))))))))
5827 ;; Refuse to select canceled articles.
5828 ((and (numberp article)
5830 (get-buffer gnus-summary-buffer)
5831 (gnus-buffer-exists-p gnus-summary-buffer)
5832 (eq (cdr (with-current-buffer gnus-summary-buffer
5833 (assq article gnus-newsgroup-reads)))
5834 gnus-canceled-mark))
5836 ;; We first check `gnus-original-article-buffer'.
5837 ((and (get-buffer gnus-original-article-buffer)
5839 (with-current-buffer gnus-original-article-buffer
5840 (and (equal (car gnus-original-article) group)
5841 (eq (cdr gnus-original-article) article))))
5842 (insert-buffer-substring gnus-original-article-buffer)
5844 ;; Check the backlog.
5845 ((and gnus-keep-backlog
5846 (gnus-backlog-request-article group article (current-buffer)))
5848 ;; Check asynchronous pre-fetch.
5849 ((gnus-async-request-fetched-article group article (current-buffer))
5850 (gnus-async-prefetch-next group article gnus-summary-buffer)
5851 (when (and (numberp article) gnus-keep-backlog)
5852 (gnus-backlog-enter-article group article (current-buffer)))
5855 ((and gnus-use-cache
5857 (gnus-cache-request-article article group))
5859 ;; Check the agent cache.
5860 ((gnus-agent-request-article article group)
5862 ;; Get the article and put into the article buffer.
5863 ((or (stringp article)
5865 (let ((gnus-override-method gnus-override-method)
5866 (methods (and (stringp article)
5867 gnus-refer-article-method))
5868 (backend (car (gnus-find-method-for-group
5869 gnus-newsgroup-name)))
5871 (inhibit-read-only t))
5872 (if (or (not (listp methods))
5873 (and (symbolp (car methods))
5874 (assq (car methods) nnoo-definition-alist)))
5875 (setq methods (list methods)))
5876 (when (and (null gnus-override-method)
5878 (setq gnus-override-method (pop methods)))
5880 (when (eq gnus-override-method 'current)
5881 (setq gnus-override-method
5882 (with-current-buffer gnus-summary-buffer
5883 gnus-current-select-method)))
5885 (gnus-kill-all-overlays)
5886 (let ((gnus-newsgroup-name group))
5887 (gnus-check-group-server))
5889 ((gnus-request-article article group (current-buffer))
5890 (when (numberp article)
5891 (gnus-async-prefetch-next group article
5892 gnus-summary-buffer)
5893 (when gnus-keep-backlog
5894 (gnus-backlog-enter-article
5895 group article (current-buffer))))
5896 (setq result 'article))
5898 (setq gnus-override-method (pop methods)))
5899 ((not (string-match "^400 "
5900 (nnheader-get-report backend)))
5901 ;; If we get 400 server disconnect, reconnect and
5902 ;; retry; otherwise, assume the article has expired.
5903 (setq result 'done))))
5904 (and (eq result 'article) 'article)))
5908 ;; Associate this article with the current summary buffer.
5909 (setq gnus-article-current-summary gnus-summary-buffer)
5911 ;; Take the article from the original article buffer
5912 ;; and place it in the buffer it's supposed to be in.
5913 (when (and (get-buffer gnus-article-buffer)
5914 (equal (buffer-name (current-buffer))
5915 (buffer-name (get-buffer gnus-article-buffer))))
5917 (if (get-buffer gnus-original-article-buffer)
5918 (set-buffer gnus-original-article-buffer)
5919 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5920 (buffer-disable-undo)
5921 (setq major-mode 'gnus-original-article-mode)
5922 (setq buffer-read-only t))
5923 (let ((inhibit-read-only t))
5925 (insert-buffer-substring gnus-article-buffer))
5926 (setq gnus-original-article (cons group article)))
5929 (run-hooks 'gnus-article-decode-hook)
5930 ;; Mark article as decoded or not.
5931 (setq gnus-article-decoded-p gnus-article-decode-hook))
5933 ;; Update sparse articles.
5934 (when (and do-update-line
5935 (or (numberp article)
5937 (let ((buf (current-buffer)))
5938 (set-buffer gnus-summary-buffer)
5939 (gnus-summary-update-article do-update-line sparse-header)
5940 (gnus-summary-goto-subject do-update-line nil t)
5941 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5943 (set-buffer buf))))))
5949 (defcustom gnus-article-edit-mode-hook nil
5950 "Hook run in article edit mode buffers."
5951 :group 'gnus-article-various
5954 (defcustom gnus-article-edit-article-setup-function
5955 'gnus-article-mime-edit-article-setup
5956 "Function called to setup an editing article buffer."
5957 :group 'gnus-article-various
5960 (defvar gnus-article-edit-done-function nil)
5962 (defvar gnus-article-edit-mode-map nil)
5964 ;; Should we be using derived.el for this?
5965 (unless gnus-article-edit-mode-map
5966 (setq gnus-article-edit-mode-map (make-keymap))
5967 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5969 (gnus-define-keys gnus-article-edit-mode-map
5970 "\C-c?" describe-mode
5971 "\C-c\C-c" gnus-article-edit-done
5972 "\C-c\C-k" gnus-article-edit-exit
5973 "\C-c\C-f\C-t" message-goto-to
5974 "\C-c\C-f\C-o" message-goto-from
5975 "\C-c\C-f\C-b" message-goto-bcc
5976 ;;"\C-c\C-f\C-w" message-goto-fcc
5977 "\C-c\C-f\C-c" message-goto-cc
5978 "\C-c\C-f\C-s" message-goto-subject
5979 "\C-c\C-f\C-r" message-goto-reply-to
5980 "\C-c\C-f\C-n" message-goto-newsgroups
5981 "\C-c\C-f\C-d" message-goto-distribution
5982 "\C-c\C-f\C-f" message-goto-followup-to
5983 "\C-c\C-f\C-m" message-goto-mail-followup-to
5984 "\C-c\C-f\C-k" message-goto-keywords
5985 "\C-c\C-f\C-u" message-goto-summary
5986 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5987 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5988 "\C-c\C-b" message-goto-body
5989 "\C-c\C-i" message-goto-signature
5991 "\C-c\C-t" message-insert-to
5992 "\C-c\C-n" message-insert-newsgroups
5993 "\C-c\C-o" message-sort-headers
5994 "\C-c\C-e" message-elide-region
5995 "\C-c\C-v" message-delete-not-region
5996 "\C-c\C-z" message-kill-to-signature
5997 "\M-\r" message-newline-and-reformat
5998 "\C-c\C-a" mml-attach-file
5999 "\C-a" message-beginning-of-line
6001 "\M-;" comment-region)
6003 (gnus-define-keys (gnus-article-edit-wash-map
6004 "\C-c\C-w" gnus-article-edit-mode-map)
6005 "f" gnus-article-edit-full-stops))
6008 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
6010 ["Fetch To" message-insert-to t]
6011 ["Fetch Newsgroups" message-insert-newsgroups t]
6013 ["To" message-goto-to t]
6014 ["From" message-goto-from t]
6015 ["Subject" message-goto-subject t]
6016 ["Cc" message-goto-cc t]
6017 ["Reply-To" message-goto-reply-to t]
6018 ["Summary" message-goto-summary t]
6019 ["Keywords" message-goto-keywords t]
6020 ["Newsgroups" message-goto-newsgroups t]
6021 ["Followup-To" message-goto-followup-to t]
6022 ["Mail-Followup-To" message-goto-mail-followup-to t]
6023 ["Distribution" message-goto-distribution t]
6024 ["Body" message-goto-body t]
6025 ["Signature" message-goto-signature t]))
6027 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
6028 "Major mode for editing articles.
6029 This is an extended text-mode.
6031 \\{gnus-article-edit-mode-map}"
6032 (make-local-variable 'gnus-article-edit-done-function)
6033 (make-local-variable 'gnus-prev-winconf)
6034 (set (make-local-variable 'font-lock-defaults)
6035 '(message-font-lock-keywords t))
6036 (set (make-local-variable 'mail-header-separator) "")
6037 (set (make-local-variable 'gnus-article-edit-mode) t)
6038 (easy-menu-add message-mode-field-menu message-mode-map)
6039 (setq buffer-read-only nil)
6040 (buffer-enable-undo)
6043 (defun gnus-article-edit (&optional force)
6044 "Edit the current article.
6045 This will have permanent effect only in mail groups.
6046 If FORCE is non-nil, allow editing of articles even in read-only
6049 (when (and (not force)
6050 (gnus-group-read-only-p))
6051 (error "The current newsgroup does not support article editing"))
6052 (gnus-article-date-original)
6053 (gnus-article-edit-article
6055 `(lambda (no-highlight)
6057 (gnus-summary-edit-article-done
6058 ,(or (mail-header-references gnus-current-headers) "")
6059 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
6061 (defun gnus-article-edit-article (start-func exit-func)
6062 "Start editing the contents of the current article buffer."
6063 (let ((winconf (current-window-configuration)))
6064 (set-buffer gnus-article-buffer)
6065 (let ((message-auto-save-directory
6066 ;; Don't associate the article buffer with a draft file.
6068 (gnus-article-edit-mode))
6069 (funcall start-func)
6070 (set-buffer-modified-p nil)
6071 (gnus-configure-windows 'edit-article)
6072 (setq gnus-article-edit-done-function exit-func)
6073 (setq gnus-prev-winconf winconf)
6074 (when gnus-article-edit-article-setup-function
6075 (funcall gnus-article-edit-article-setup-function))
6076 (gnus-message 6 "C-c C-c to end edits; C-c C-k to exit")))
6078 (defun gnus-article-edit-done (&optional arg)
6079 "Update the article edits and exit."
6081 (let ((func gnus-article-edit-done-function)
6082 (buf (current-buffer))
6083 (start (window-start))
6085 (winconf gnus-prev-winconf))
6086 (remove-hook 'gnus-article-mode-hook
6087 'gnus-article-mime-edit-article-unwind)
6088 (widen) ;; Widen it in case that users narrowed the buffer.
6091 ;; The cache and backlog have to be flushed somewhat.
6092 (when gnus-keep-backlog
6093 (gnus-backlog-remove-article
6094 (car gnus-article-current) (cdr gnus-article-current)))
6095 ;; Flush original article as well.
6097 (when (get-buffer gnus-original-article-buffer)
6098 (set-buffer gnus-original-article-buffer)
6099 (setq gnus-original-article nil)))
6100 (when gnus-use-cache
6101 (gnus-cache-update-article
6102 (car gnus-article-current) (cdr gnus-article-current)))
6103 ;; We remove all text props from the article buffer.
6104 (kill-all-local-variables)
6105 (set-text-properties (point-min) (point-max) nil)
6107 (set-window-configuration winconf)
6109 (set-window-start (get-buffer-window buf) start)
6110 (set-window-point (get-buffer-window buf) (point)))
6111 (gnus-summary-show-article))
6113 (defun gnus-article-edit-exit ()
6114 "Exit the article editing without updating."
6116 (when (or (not (buffer-modified-p))
6117 (yes-or-no-p "Article modified; kill anyway? "))
6118 (let ((curbuf (current-buffer))
6120 (window-start (window-start)))
6122 (if (gnus-buffer-live-p gnus-original-article-buffer)
6123 (insert-buffer-substring gnus-original-article-buffer))
6124 (let ((winconf gnus-prev-winconf))
6125 (kill-all-local-variables)
6127 (set-window-configuration winconf)
6128 ;; Tippy-toe some to make sure that point remains where it was.
6129 (save-current-buffer
6131 (set-window-start (get-buffer-window (current-buffer)) window-start)
6133 (gnus-summary-show-article)))
6135 (defun gnus-article-edit-full-stops ()
6136 "Interactively repair spacing at end of sentences."
6139 (goto-char (point-min))
6140 (search-forward-regexp "^$" nil t)
6141 (let ((case-fold-search nil))
6142 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
6145 ;;; Article editing with MIME-Edit
6148 (defcustom gnus-article-mime-edit-article-setup-hook nil
6149 "Hook run after setting up a MIME editing article buffer."
6150 :group 'gnus-article-various
6153 (defun gnus-article-mime-edit-article-unwind ()
6154 "Unwind `gnus-article-buffer' if article editing was given up."
6155 (remove-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6156 (when (featurep 'font-lock)
6157 (setq font-lock-defaults nil)
6158 (font-lock-mode -1))
6159 (when mime-edit-mode-flag
6160 (mime-edit-exit 'nomime 'no-error)
6163 (defun gnus-article-mime-edit-article-setup ()
6164 "Convert current buffer to MIME-Edit buffer and turn on MIME-Edit mode
6165 after replacing with the original article."
6166 (setq gnus-show-mime t)
6167 (setq gnus-article-edit-done-function
6168 `(lambda (&rest args)
6169 (when mime-edit-mode-flag
6170 (let (mime-edit-insert-user-agent-field)
6173 (goto-char (point-min))
6174 (let (case-fold-search)
6175 (when (re-search-forward
6176 (format "^%s$" (regexp-quote mail-header-separator))
6178 (replace-match "")))
6179 (apply ,gnus-article-edit-done-function args)
6182 (buffer-substring-no-properties (point-min) (point-max))
6183 (set-buffer (get-buffer-create gnus-original-article-buffer))
6185 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6186 (set-buffer gnus-article-buffer)
6187 (gnus-article-prepare-display)))
6188 (substitute-key-definition 'gnus-article-edit-done
6189 'gnus-article-mime-edit-done
6190 gnus-article-edit-mode-map)
6191 (substitute-key-definition 'gnus-article-edit-exit
6192 'gnus-article-mime-edit-exit
6193 gnus-article-edit-mode-map)
6195 (insert-buffer-substring gnus-original-article-buffer)
6196 (unless (member (with-current-buffer gnus-summary-buffer
6197 gnus-newsgroup-name)
6198 '("nndraft:delayed" "nndraft:drafts"))
6199 (let ((ofn (symbol-function 'mime-edit-decode-single-part-in-buffer)))
6200 (fset 'mime-edit-decode-single-part-in-buffer
6201 (lambda (&rest args)
6202 (if (let ((content-type (car args)))
6203 (and (eq 'message (mime-content-type-primary-type
6205 (eq 'rfc822 (mime-content-type-subtype
6207 (setcar (cdr args) 'not-decode-text))
6211 (fset 'mime-edit-decode-single-part-in-buffer ofn))))
6212 (when (featurep 'font-lock)
6213 (set (make-local-variable 'font-lock-defaults)
6214 '(message-font-lock-keywords t))
6215 (font-lock-set-defaults)
6216 (turn-on-font-lock))
6217 (set-buffer-modified-p nil)
6218 (delete-other-windows)
6219 (add-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6220 (gnus-run-hooks 'gnus-article-mime-edit-article-setup-hook))
6222 (defun gnus-article-mime-edit-done (&optional arg)
6223 "Update the article MIME edits and exit."
6225 (when (featurep 'font-lock)
6226 (setq font-lock-defaults nil)
6227 (font-lock-mode -1))
6228 (let ((inhibit-read-only t))
6229 (gnus-article-edit-done arg)))
6231 (defun gnus-article-mime-edit-exit ()
6232 "Exit the article MIME editing without updating."
6234 (when (or (not (buffer-modified-p))
6235 (yes-or-no-p "Article modified; kill anyway? "))
6236 (when (featurep 'font-lock)
6237 (setq font-lock-defaults nil)
6238 (font-lock-mode -1))
6239 (when mime-edit-mode-flag
6240 (let (mime-edit-insert-user-agent-field)
6243 (goto-char (point-min))
6244 (let (case-fold-search)
6245 (when (re-search-forward
6246 (format "^%s$" (regexp-quote mail-header-separator)) nil t)
6247 (replace-match "")))
6248 (let ((winconf gnus-prev-winconf))
6250 (buffer-substring-no-properties (point-min) (point-max))
6251 (set-buffer (get-buffer-create gnus-original-article-buffer))
6253 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6254 (set-buffer gnus-article-buffer)
6255 (gnus-article-prepare-display)
6256 (set-window-configuration winconf))))
6259 ;;; Article highlights
6262 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
6264 ;;; Internal Variables:
6266 (defcustom gnus-button-url-regexp
6267 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
6268 "\\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:]]\\)"
6269 "\\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\\)\\)")
6270 "Regular expression that matches URLs."
6271 :group 'gnus-article-buttons
6274 (defcustom gnus-button-valid-fqdn-regexp
6275 message-valid-fqdn-regexp
6276 "Regular expression that matches a valid FQDN."
6278 :group 'gnus-article-buttons
6281 (defcustom gnus-button-man-handler 'manual-entry
6282 "Function to use for displaying man pages.
6283 The function must take at least one argument with a string naming the
6286 :type '(choice (function-item :tag "Man" manual-entry)
6287 (function-item :tag "Woman" woman)
6288 (function :tag "Other"))
6289 :group 'gnus-article-buttons)
6291 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
6292 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
6293 If the default site is too slow, try to find a CTAN mirror, see
6294 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
6295 the variable `gnus-button-handle-ctan'."
6297 :group 'gnus-article-buttons
6298 :link '(custom-manual "(gnus)Group Parameters")
6299 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
6300 (const "http://tug.ctan.org/tex-archive/")
6301 (const "http://www.dante.de/CTAN/")
6302 (string :tag "Other")))
6304 (defcustom gnus-button-ctan-handler 'browse-url
6305 "Function to use for displaying CTAN links.
6306 The function must take one argument, the string naming the URL."
6308 :type '(choice (function-item :tag "Browse Url" browse-url)
6309 (function :tag "Other"))
6310 :group 'gnus-article-buttons)
6312 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
6313 "Bogus strings removed from CTAN URLs."
6315 :group 'gnus-article-buttons
6316 :type '(choice (const "^/?tex-archive/\\|/")
6317 (regexp :tag "Other")))
6319 (defcustom gnus-button-ctan-directory-regexp
6322 "biblio\\|digests\\|dviware\\|fonts\\|graphics\\|help\\|"
6323 "indexing\\|info\\|language\\|macros\\|support\\|systems\\|"
6324 "tds\\|tools\\|usergrps\\|web\\|nonfree\\|obsolete"
6326 "Regular expression for ctan directories.
6327 It should match all directories in the top level of `gnus-ctan-url'."
6329 :group 'gnus-article-buttons
6332 (defcustom gnus-button-mid-or-mail-regexp
6333 (concat "\\b\\(<?[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t ]*@"
6334 ;; Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
6335 gnus-button-valid-fqdn-regexp
6337 "Regular expression that matches a message ID or a mail address."
6339 :group 'gnus-article-buttons
6342 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
6343 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
6344 Strings like this can be either a message ID or a mail address. If it is one
6345 of the symbols `mid' or `mail', Gnus will always assume that the string is a
6346 message ID or a mail address, respectively. If this variable is set to the
6347 symbol `ask', always query the user what do do. If it is a function, this
6348 function will be called with the string as it's only argument. The function
6349 must return `mid', `mail', `invalid' or `ask'."
6351 :group 'gnus-article-buttons
6352 :type '(choice (function-item :tag "Heuristic function"
6353 gnus-button-mid-or-mail-heuristic)
6358 (defcustom gnus-button-mid-or-mail-heuristic-alist
6359 '((-10.0 . ".+\\$.+@")
6362 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
6363 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
6364 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
6365 (-1.0 . "^[^a-z]+@")
6367 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
6368 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
6369 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
6370 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
6373 (-1.0 . "^[0-9][0-9]")
6375 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
6376 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6377 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
6378 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6380 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
6381 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
6384 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
6386 ;; compensation for TDMA dated mail addresses:
6387 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
6389 (-20.0 . "\\.fsf@") ;; Gnus
6392 (-20.0 . "_-_") ;; Subject change in thread
6394 (-20.0 . "\\.ln@") ;; leafnode
6395 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
6396 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
6398 ;; (5.0 . "") ;; $local_part_len <= 7
6399 (10.0 . "^[^0-9]+@")
6400 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
6401 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
6404 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
6406 (0.5 . "^[A-Z][a-z]")
6407 (0.5 . "^[A-Z][a-z][a-z]")
6408 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
6409 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
6410 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
6412 A negative RATE indicates a message IDs, whereas a positive indicates a mail
6413 address. The REGEXP is processed with `case-fold-search' set to nil."
6415 :group 'gnus-article-buttons
6416 :type '(repeat (cons (number :tag "Rate")
6417 (regexp :tag "Regexp"))))
6419 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
6420 "Guess whether MID-OR-MAIL is a message ID or a mail address.
6421 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
6422 address, `ask' if unsure and `invalid' if the string is invalid."
6423 (let ((case-fold-search nil)
6424 (list gnus-button-mid-or-mail-heuristic-alist)
6425 (result 0) rate regexp lpartlen elem)
6427 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
6428 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
6429 ;; Certain special cases...
6432 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
6433 "^[0-9]+\\.[0-9]+@compuserve\\|"
6434 "@public\\.gmane\\.org")
6436 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
6437 (setq result 'mail))
6438 (when (string-match "@.*@\\| " mid-or-mail)
6439 (gnus-message 8 "`%s' is invalid." mid-or-mail)
6440 (setq result 'invalid))
6441 ;; Nothing more to do, if result is not a number here...
6442 (when (numberp result)
6444 (setq elem (car list)
6448 (when (string-match regexp mid-or-mail)
6449 (setq result (+ result rate))
6451 9 "`%s' matched `%s', rate `%s', result `%s'."
6452 mid-or-mail regexp rate result)))
6453 (when (<= lpartlen 7)
6454 (setq result (+ result 5.0))
6455 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
6456 mid-or-mail result))
6457 (when (>= lpartlen 12)
6458 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
6460 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
6461 ;; Long local part should contain realname if e-mail address,
6462 ;; too many digits: message-id.
6463 ;; $score -= 5.0 + 0.1 * $local_part_len;
6464 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6465 (setq result (+ result rate))
6467 9 "Many digits in `%s', rate `%s', result `%s'."
6468 mid-or-mail rate result))
6469 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6471 ;; Too few vowels [^aeiouy]{4,}.*\@
6472 (setq result (+ result -5.0))
6474 9 "Few vowels in `%s', rate `%s', result `%s'."
6475 mid-or-mail -5.0 result))
6477 (setq result (+ result 5.0))
6479 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6480 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6481 ;; Maybe we should make this a customizable alist: (condition . 'result)
6483 ((symbolp result) result)
6484 ;; Now convert number into proper results:
6485 ((< result -10.0) 'mid)
6486 ((> result 10.0) 'mail)
6489 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6490 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6491 (url-mid (concat "news" ":" mid-or-mail))
6492 (url-mailto (concat "mailto" ":" mid-or-mail)))
6493 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6494 (when (fboundp pref)
6496 ;; get rid of surrounding angles...
6498 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6499 (if (or (eq 'mid guessed) (eq 'mail guessed))
6503 (save-window-excursion
6504 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6507 (cond ((eq pref 'mid)
6508 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6509 (gnus-button-handle-news url-mid))
6511 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6512 (gnus-url-mailto url-mailto))
6513 (t (gnus-message 3 "Invalid string.")))))
6515 (defun gnus-button-handle-custom (url)
6516 "Follow a Custom URL."
6517 (customize-apropos (gnus-url-unhex-string url)))
6519 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6521 ;; FIXME: Maybe we should merge some of the functions that do quite similar
6524 (defun gnus-button-handle-describe-function (url)
6525 "Call `describe-function' when pushing the corresponding URL button."
6528 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6530 (defun gnus-button-handle-describe-variable (url)
6531 "Call `describe-variable' when pushing the corresponding URL button."
6534 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6536 (defun gnus-button-handle-symbol (url)
6537 "Display help on variable or function.
6538 Calls `describe-variable' or `describe-function'."
6539 (let ((sym (intern url)))
6541 ((fboundp sym) (describe-function sym))
6542 ((boundp sym) (describe-variable sym))
6543 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
6545 (defun gnus-button-handle-describe-key (url)
6546 "Call `describe-key' when pushing the corresponding URL button."
6548 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6549 (keys (ignore-errors (eval `(kbd ,key-string)))))
6552 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6554 (defun gnus-button-handle-apropos (url)
6555 "Call `apropos' when pushing the corresponding URL button."
6556 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6558 (defun gnus-button-handle-apropos-command (url)
6559 "Call `apropos' when pushing the corresponding URL button."
6561 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6563 (defun gnus-button-handle-apropos-variable (url)
6564 "Call `apropos' when pushing the corresponding URL button."
6566 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6567 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6569 (defun gnus-button-handle-apropos-documentation (url)
6570 "Call `apropos' when pushing the corresponding URL button."
6572 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6573 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6575 (defun gnus-button-handle-library (url)
6576 "Call `locate-library' when pushing the corresponding URL button."
6577 (gnus-message 9 "url=`%s'" url)
6578 (let* ((lib (locate-library url))
6579 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6581 (gnus-message 1 "Cannot locale library `%s'." url)
6582 (find-file-read-only file))))
6584 (defun gnus-button-handle-ctan (url)
6585 "Call `browse-url' when pushing a CTAN URL button."
6587 gnus-button-ctan-handler
6590 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6592 (defcustom gnus-button-tex-level 5
6593 "*Integer that says how many TeX-related buttons Gnus will show.
6594 The higher the number, the more buttons will appear and the more false
6595 positives are possible. Note that you can set this variable local to
6596 specific groups. Setting it higher in TeX groups is probably a good idea.
6597 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6598 how to set variables in specific groups."
6600 :group 'gnus-article-buttons
6601 :link '(custom-manual "(gnus)Group Parameters")
6604 (defcustom gnus-button-man-level 5
6605 "*Integer that says how many man-related buttons Gnus will show.
6606 The higher the number, the more buttons will appear and the more false
6607 positives are possible. Note that you can set this variable local to
6608 specific groups. Setting it higher in Unix groups is probably a good idea.
6609 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6610 how to set variables in specific groups."
6612 :group 'gnus-article-buttons
6613 :link '(custom-manual "(gnus)Group Parameters")
6616 (defcustom gnus-button-emacs-level 5
6617 "*Integer that says how many emacs-related buttons Gnus will show.
6618 The higher the number, the more buttons will appear and the more false
6619 positives are possible. Note that you can set this variable local to
6620 specific groups. Setting it higher in Emacs or Gnus related groups is
6621 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6622 `gnus-parameters' on how to set variables in specific groups."
6624 :group 'gnus-article-buttons
6625 :link '(custom-manual "(gnus)Group Parameters")
6628 (defcustom gnus-button-message-level 5
6629 "*Integer that says how many buttons for news or mail messages will appear.
6630 The higher the number, the more buttons will appear and the more false
6631 positives are possible."
6632 ;; mail addresses, MIDs, URLs for news, ...
6634 :group 'gnus-article-buttons
6637 (defcustom gnus-button-browse-level 5
6638 "*Integer that says how many buttons for browsing will appear.
6639 The higher the number, the more buttons will appear and the more false
6640 positives are possible."
6641 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6643 :group 'gnus-article-buttons
6646 (defcustom gnus-button-alist
6647 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6648 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6649 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
6650 gnus-button-handle-news 2)
6651 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6652 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6653 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6654 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6655 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
6656 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
6657 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
6658 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6659 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6660 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6661 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6662 ;; RFC 2368 (The mailto URL scheme)
6663 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6664 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6665 ("\\bmailto:\\([^ \n\t]+\\)"
6666 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6668 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6669 gnus-button-ctan-directory-regexp
6670 "[^][>)!;:,'\n\t ]+\\)")
6671 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6672 ((concat "\\btex-archive/\\("
6673 gnus-button-ctan-directory-regexp
6674 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6675 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6678 gnus-button-ctan-directory-regexp
6679 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6680 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6681 ;; This is info (home-grown style) <info://foo/bar+baz>
6682 ("\\binfo://\\([^'\">\n\t ]+\\)"
6683 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6684 ;; Info GNOME style <info:foo#bar_baz>
6685 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6686 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6687 ;; Info KDE style <info:(foo)bar baz>
6688 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6689 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6690 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6691 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6692 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6693 ;; Info links like `C-h i d m CC Mode RET'
6694 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6696 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6697 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6698 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6699 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6700 ;; Emacs help commands
6701 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6702 ;; regexp doesn't match arguments containing ` '.
6703 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6704 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6705 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6706 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6707 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6708 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6709 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6710 ;; The following entries may lead to many false positives so don't enable
6711 ;; them by default (use a high button level).
6712 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
6713 ;; Exclude [.?] for URLs in gmane.emacs.cvs
6714 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6715 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6716 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6717 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6718 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6719 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6720 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6721 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6722 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6723 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6724 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
6725 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6726 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6727 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6728 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6729 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6730 ;; Unlike the other regexps we really have to require quoting
6731 ;; here to determine where it ends.
6732 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6733 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
6734 ("<URL: *\\([^<>]*\\)>"
6735 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6736 ;; RFC 2396 (2.4.3., delims) ...
6737 ("\"URL: *\\([^\"]*\\)\""
6738 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6739 ;; RFC 2396 (2.4.3., delims) ...
6740 ("\"URL: *\\([^\"]*\\)\""
6741 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6743 (gnus-button-url-regexp
6744 0 (>= gnus-button-browse-level 0) browse-url 0)
6746 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
6747 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6748 gnus-button-handle-man 1)
6749 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6750 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
6751 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6752 gnus-button-handle-man 1)
6753 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6754 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6755 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
6756 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6757 ;; MID or mail: To avoid too many false positives we don't try to catch
6758 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6759 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6760 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6761 ;; so that non-ambiguous entries (see above) match first.
6762 (gnus-button-mid-or-mail-regexp
6763 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6764 "*Alist of regexps matching buttons in article bodies.
6766 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6767 REGEXP: is the string (case insensitive) matching text around the button (can
6768 also be Lisp expression evaluating to a string),
6769 BUTTON: is the number of the regexp grouping actually matching the button,
6770 FORM: is a Lisp expression which must eval to true for the button to
6772 CALLBACK: is the function to call when the user push this button, and each
6773 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6775 CALLBACK can also be a variable, in that case the value of that
6776 variable it the real callback function."
6777 :group 'gnus-article-buttons
6778 :type '(repeat (list (choice regexp variable sexp)
6779 (integer :tag "Button")
6781 (function :tag "Callback")
6784 (integer :tag "Regexp group")))))
6786 (defcustom gnus-header-button-alist
6787 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
6788 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6789 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6790 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6791 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6792 0 (>= gnus-button-message-level 0) gnus-button-mailto 0)
6793 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6794 0 (>= gnus-button-browse-level 0) browse-url 0)
6795 ("^Subject:" gnus-button-url-regexp
6796 0 (>= gnus-button-browse-level 0) browse-url 0)
6797 ("^[^:]+:" gnus-button-url-regexp
6798 0 (>= gnus-button-browse-level 0) browse-url 0)
6799 ("^OpenPGP:.*url=" gnus-button-url-regexp
6800 0 (>= gnus-button-browse-level 0) gnus-button-openpgp 0)
6801 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6802 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6803 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6804 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6805 "*Alist of headers and regexps to match buttons in article heads.
6807 This alist is very similar to `gnus-button-alist', except that each
6808 alist has an additional HEADER element first in each entry:
6810 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6812 HEADER is a regexp to match a header. For a fuller explanation, see
6813 `gnus-button-alist'."
6814 :group 'gnus-article-buttons
6815 :group 'gnus-article-headers
6816 :type '(repeat (list (regexp :tag "Header")
6817 (choice regexp variable)
6818 (integer :tag "Button")
6820 (function :tag "Callback")
6823 (integer :tag "Regexp group")))))
6827 (defun gnus-article-push-button (event)
6828 "Check text under the mouse pointer for a callback function.
6829 If the text under the mouse pointer has a `gnus-callback' property,
6830 call it with the value of the `gnus-data' text property."
6832 (set-buffer (window-buffer (posn-window (event-start event))))
6833 (let* ((pos (posn-point (event-start event)))
6834 (data (get-text-property pos 'gnus-data))
6835 (fun (get-text-property pos 'gnus-callback)))
6838 (funcall fun data))))
6840 (defun gnus-article-press-button ()
6841 "Check text at point for a callback function.
6842 If the text at point has a `gnus-callback' property,
6843 call it with the value of the `gnus-data' text property."
6845 (let ((data (get-text-property (point) 'gnus-data))
6846 (fun (get-text-property (point) 'gnus-callback)))
6848 (funcall fun data))))
6850 (defun gnus-article-prev-button (n)
6851 "Move point to N buttons backward.
6852 If N is negative, move forward instead."
6854 (gnus-article-next-button (- n)))
6856 (defun gnus-article-next-button (n)
6857 "Move point to N buttons forward.
6858 If N is negative, move backward instead."
6860 (let ((function (if (< n 0) 'previous-single-property-change
6861 'next-single-property-change))
6862 (inhibit-point-motion-hooks t)
6864 (limit (if (< n 0) (point-min) (point-max))))
6866 (while (and (not (= limit (point)))
6868 ;; Skip past the current button.
6869 (when (get-text-property (point) 'gnus-callback)
6870 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6871 ;; Go to the next (or previous) button.
6872 (gnus-goto-char (funcall function (point) 'gnus-callback nil limit))
6873 ;; Put point at the start of the button.
6874 (when (and backward (not (get-text-property (point) 'gnus-callback)))
6875 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6876 ;; Skip past intangible buttons.
6877 (when (get-text-property (point) 'intangible)
6881 (gnus-message 5 "No more buttons"))
6884 (defun gnus-article-highlight (&optional force)
6885 "Highlight current article.
6886 This function calls `gnus-article-highlight-headers',
6887 `gnus-article-highlight-citation',
6888 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6889 do the highlighting. See the documentation for those functions."
6890 (interactive (list 'force))
6891 (gnus-article-highlight-headers)
6892 (gnus-article-highlight-citation force)
6893 (gnus-article-highlight-signature)
6894 (gnus-article-add-buttons force)
6895 (gnus-article-add-buttons-to-head))
6897 (defun gnus-article-highlight-some (&optional force)
6898 "Highlight current article.
6899 This function calls `gnus-article-highlight-headers',
6900 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6901 do the highlighting. See the documentation for those functions."
6902 (interactive (list 'force))
6903 (gnus-article-highlight-headers)
6904 (gnus-article-highlight-signature)
6905 (gnus-article-add-buttons))
6907 (defun gnus-article-highlight-headers ()
6908 "Highlight article headers as specified by `gnus-header-face-alist'."
6910 (gnus-with-article-headers
6911 (let (regexp header-face field-face from hpoints fpoints)
6912 (dolist (entry gnus-header-face-alist)
6913 (goto-char (point-min))
6914 (setq regexp (concat "^\\("
6915 (if (string-equal "" (nth 0 entry))
6919 header-face (nth 1 entry)
6920 field-face (nth 2 entry))
6921 (while (and (re-search-forward regexp nil t)
6925 (unless (search-forward ":" nil t)
6927 (when (and header-face
6928 (not (memq (point) hpoints)))
6929 (push (point) hpoints)
6930 (gnus-put-text-property from (point) 'face header-face))
6931 (when (and field-face
6932 (not (memq (setq from (point)) fpoints)))
6934 (if (re-search-forward "^[^ \t]" nil t)
6936 (goto-char (point-max)))
6937 (gnus-put-text-property from (point) 'face field-face)))))))
6939 (defun gnus-article-highlight-signature ()
6940 "Highlight the signature in an article.
6941 It does this by highlighting everything after
6942 `gnus-signature-separator' using `gnus-signature-face'."
6944 (when gnus-signature-face
6945 (gnus-with-article-buffer
6946 (let ((inhibit-point-motion-hooks t))
6948 (when (gnus-article-narrow-to-signature)
6949 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6950 'face gnus-signature-face)))))))
6952 (defun gnus-article-buttonize-signature ()
6953 "Add button to the signature."
6956 (set-buffer gnus-article-buffer)
6957 (let ((inhibit-read-only t)
6958 (inhibit-point-motion-hooks t))
6959 (when (gnus-article-search-signature)
6960 (gnus-article-add-button (match-beginning 0) (match-end 0)
6961 'gnus-signature-toggle
6962 (set-marker (make-marker)
6963 (1+ (match-end 0))))))))
6965 (defun gnus-button-in-region-p (b e prop)
6966 "Say whether PROP exists in the region."
6967 (text-property-not-all b e prop nil))
6969 (defun gnus-article-add-buttons (&optional force)
6970 "Find external references in the article and make buttons of them.
6971 \"External references\" are things like Message-IDs and URLs, as
6972 specified by `gnus-button-alist'."
6973 (interactive (list 'force))
6974 (gnus-with-article-buffer
6975 (let ((inhibit-point-motion-hooks t)
6976 (case-fold-search t)
6977 (alist gnus-button-alist)
6979 ;; Remove all old markers.
6980 (let (marker entry new-list)
6981 (while (setq marker (pop gnus-button-marker-list))
6982 (if (or (< marker (point-min)) (>= marker (point-max)))
6983 (push marker new-list)
6985 (when (setq entry (gnus-button-entry))
6986 (put-text-property (match-beginning (nth 1 entry))
6987 (match-end (nth 1 entry))
6988 'gnus-callback nil))
6989 (set-marker marker nil)))
6990 (setq gnus-button-marker-list new-list))
6991 ;; We skip the headers.
6994 (while (setq entry (pop alist))
6995 (setq regexp (eval (car entry)))
6997 (while (re-search-forward regexp nil t)
6998 (let* ((start (and entry (match-beginning (nth 1 entry))))
6999 (end (and entry (match-end (nth 1 entry))))
7000 (from (match-beginning 0)))
7001 (when (and (or (eq t (nth 2 entry))
7002 (eval (nth 2 entry)))
7003 (not (gnus-button-in-region-p
7004 start end 'gnus-callback)))
7005 ;; That optional form returned non-nil, so we add the
7007 (gnus-article-add-button
7008 start end 'gnus-button-push
7009 (car (push (set-marker (make-marker) from)
7010 gnus-button-marker-list))))))))))
7012 ;; Add buttons to the head of an article.
7013 (defun gnus-article-add-buttons-to-head ()
7014 "Add buttons to the head of the article."
7016 (gnus-with-article-headers
7018 (dolist (entry gnus-header-button-alist)
7019 ;; Each alist entry.
7020 (goto-char (point-min))
7021 (while (re-search-forward (car entry) nil t)
7022 ;; Each header matching the entry.
7023 (setq beg (match-beginning 0))
7024 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
7025 (match-beginning 0))
7028 (while (re-search-forward (eval (nth 1 entry)) end t)
7029 ;; Each match within a header.
7030 (let* ((entry (cdr entry))
7031 (start (match-beginning (nth 1 entry)))
7032 (end (match-end (nth 1 entry)))
7033 (form (nth 2 entry)))
7034 (goto-char (match-end 0))
7036 (gnus-article-add-button
7037 start end (nth 3 entry)
7038 (buffer-substring (match-beginning (nth 4 entry))
7039 (match-end (nth 4 entry)))))))
7040 (goto-char end))))))
7042 ;;; External functions:
7044 (defun gnus-article-add-button (from to fun &optional data)
7045 "Create a button between FROM and TO with callback FUN and data DATA."
7046 (when gnus-article-button-face
7047 (gnus-overlay-put (gnus-make-overlay from to)
7048 'face gnus-article-button-face))
7049 (gnus-add-text-properties
7051 (nconc (and gnus-article-mouse-face
7052 (list gnus-mouse-face-prop gnus-article-mouse-face))
7053 (list 'gnus-callback fun)
7054 (and data (list 'gnus-data data))))
7055 (widget-convert-button 'link from to :action 'gnus-widget-press-button
7056 :button-keymap gnus-widget-button-keymap))
7058 ;;; Internal functions:
7060 (defun gnus-article-set-globals ()
7061 (with-current-buffer gnus-summary-buffer
7062 (gnus-set-global-variables)))
7064 (defun gnus-signature-toggle (end)
7065 (gnus-with-article-buffer
7066 (let ((inhibit-point-motion-hooks t)
7067 (limit (next-single-property-change end 'mime-view-entity
7069 (if (text-property-any end limit 'article-type 'signature)
7071 (gnus-delete-wash-type 'signature)
7072 (gnus-remove-text-properties-when
7073 'article-type 'signature end limit
7074 (cons 'article-type (cons 'signature
7075 gnus-hidden-properties))))
7076 (gnus-add-wash-type 'signature)
7077 (gnus-add-text-properties-when
7078 'article-type nil end limit
7079 (cons 'article-type (cons 'signature
7080 gnus-hidden-properties)))))
7081 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
7082 (gnus-set-mode-line 'article))))
7084 (defun gnus-button-entry ()
7085 ;; Return the first entry in `gnus-button-alist' matching this place.
7086 (let ((alist gnus-button-alist)
7089 (setq entry (pop alist))
7090 (if (looking-at (eval (car entry)))
7095 (defun gnus-button-push (marker)
7096 ;; Push button starting at MARKER.
7099 (let* ((entry (gnus-button-entry))
7100 (inhibit-point-motion-hooks t)
7102 (args (mapcar (lambda (group)
7103 (let ((string (match-string group)))
7104 (set-text-properties
7105 0 (length string) nil string)
7112 (fboundp (symbol-value fun)))
7113 (apply (symbol-value fun) args))
7115 (gnus-message 1 "You must define `%S' to use this button"
7116 (cons fun args)))))))
7118 (defun gnus-parse-news-url (url)
7119 (let (scheme server group message-id articles)
7122 (goto-char (point-min))
7123 (when (looking-at "\\([A-Za-z]+\\):")
7124 (setq scheme (match-string 1))
7125 (goto-char (match-end 0)))
7126 (when (looking-at "//\\([^/]+\\)/")
7127 (setq server (match-string 1))
7128 (goto-char (match-end 0)))
7131 ((looking-at "\\(.*@.*\\)")
7132 (setq message-id (match-string 1)))
7133 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
7134 (setq group (match-string 1)
7135 articles (split-string (match-string 2) "-")))
7136 ((looking-at "\\([^/]+\\)/?")
7137 (setq group (match-string 1)))
7139 (error "Unknown news URL syntax"))))
7140 (list scheme server group message-id articles)))
7142 (defun gnus-button-handle-news (url)
7144 (destructuring-bind (scheme server group message-id articles)
7145 (gnus-parse-news-url url)
7149 (set-buffer gnus-summary-buffer)
7151 (let ((gnus-refer-article-method (list (list 'nntp server))))
7152 (gnus-summary-refer-article message-id))
7153 (gnus-summary-refer-article message-id))))
7155 (gnus-button-fetch-group url)))))
7157 (defun gnus-button-handle-man (url)
7159 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7160 (when (eq gnus-button-man-handler 'woman)
7161 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
7162 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7163 (funcall gnus-button-man-handler url))
7165 (defun gnus-button-handle-info-url (url)
7166 "Fetch an info URL."
7167 (setq url (mm-subst-char-in-string ?+ ?\ url))
7169 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
7170 (gnus-info-find-node
7171 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
7173 ")" (gnus-url-unhex-string (match-string 2 url)))))
7174 ((string-match "([^)\"]+)[^\"]+" url)
7176 (gnus-replace-in-string
7177 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
7178 (gnus-info-find-node url))
7179 (t (error "Can't parse %s" url))))
7181 (defun gnus-button-handle-info-url-gnome (url)
7182 "Fetch GNOME style info URL."
7183 (setq url (mm-subst-char-in-string ?_ ?\ url))
7184 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
7185 (gnus-info-find-node
7187 (gnus-url-unhex-string
7188 (match-string 1 url))
7190 (or (gnus-url-unhex-string
7191 (match-string 2 url))
7193 (error "Can't parse %s" url)))
7195 (defun gnus-button-handle-info-url-kde (url)
7196 "Fetch KDE style info URL."
7197 (gnus-info-find-node (gnus-url-unhex-string url)))
7199 (defun gnus-button-handle-info-keystrokes (url)
7200 "Call `info' when pushing the corresponding URL button."
7201 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
7206 (defun gnus-button-openpgp (url)
7207 "Retrieve and add an OpenPGP key given URL from an OpenPGP header."
7209 (mm-url-insert-file-contents-external url)
7210 (pgg-snarf-keys-region (point-min) (point-max))
7211 (pgg-display-output-buffer nil nil nil)))
7213 (defun gnus-button-message-id (message-id)
7215 (with-current-buffer gnus-summary-buffer
7216 (gnus-summary-refer-article message-id)))
7218 (defun gnus-button-fetch-group (address)
7219 "Fetch GROUP specified by ADDRESS."
7220 (if (not (string-match "[:/]" address))
7221 ;; This is just a simple group url.
7222 (gnus-group-read-ephemeral-group address gnus-select-method)
7225 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
7227 (error "Can't parse %s" address)
7228 (gnus-group-read-ephemeral-group
7229 (match-string 4 address)
7230 `(nntp ,(match-string 1 address)
7231 (nntp-address ,(match-string 1 address))
7232 (nntp-port-number ,(if (match-end 3)
7233 (match-string 3 address)
7236 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
7238 (defun gnus-url-parse-query-string (query &optional downcase)
7239 (let (retval pairs cur key val)
7240 (setq pairs (split-string query "&"))
7242 (setq cur (car pairs)
7244 (if (not (string-match "=" cur))
7246 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
7247 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
7249 (setq key (downcase key)))
7250 (setq cur (assoc key retval))
7252 (setcdr cur (cons val (cdr cur)))
7253 (setq retval (cons (list key val) retval)))))
7256 (defun gnus-url-mailto (url)
7257 ;; Send mail to someone
7258 (when (string-match "mailto:/*\\(.*\\)" url)
7259 (setq url (substring url (match-beginning 1) nil)))
7260 (let (to args subject func)
7261 (setq args (gnus-url-parse-query-string
7262 (if (string-match "^\\?" url)
7264 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
7265 (concat "to=" (match-string 1 url) "&"
7266 (match-string 2 url))
7267 (concat "to=" url)))
7269 subject (cdr-safe (assoc "subject" args)))
7272 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
7275 (message-position-on-field (caar args)))
7276 (insert (gnus-replace-in-string
7277 (mapconcat 'identity (reverse (cdar args)) ", ")
7279 (setq args (cdr args)))
7282 (message-goto-subject))))
7284 (defun gnus-button-embedded-url (address)
7285 "Activate ADDRESS with `browse-url'."
7286 (browse-url (gnus-strip-whitespace address)))
7288 ;;; Next/prev buttons in the article buffer.
7290 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
7291 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
7293 (defvar gnus-prev-page-map
7294 (let ((map (make-sparse-keymap)))
7295 (define-key map gnus-mouse-2 'gnus-button-prev-page)
7296 (define-key map "\r" 'gnus-button-prev-page)
7299 (defvar gnus-next-page-map
7300 (let ((map (make-sparse-keymap)))
7301 (unless (>= emacs-major-version 21)
7302 ;; XEmacs doesn't care.
7303 (set-keymap-parent map gnus-article-mode-map))
7304 (define-key map gnus-mouse-2 'gnus-button-next-page)
7305 (define-key map "\r" 'gnus-button-next-page)
7308 (defun gnus-insert-prev-page-button ()
7310 (inhibit-read-only t)
7311 (situation (get-text-property (point-min) 'mime-view-situation)))
7313 gnus-prev-page-line-format nil
7314 `(keymap ,gnus-prev-page-map
7316 gnus-callback gnus-article-button-prev-page
7317 article-type annotation
7318 mime-view-situation ,situation))
7319 (widget-convert-button
7321 ;; Exclude a newline.
7324 :action 'gnus-button-prev-page
7325 :button-keymap gnus-prev-page-map)))
7327 (defun gnus-button-next-page (&optional args more-args)
7328 "Go to the next page."
7330 (let ((win (selected-window)))
7331 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7332 (gnus-article-next-page)
7333 (select-window win)))
7335 (defun gnus-button-prev-page (&optional args more-args)
7336 "Go to the prev page."
7338 (let ((win (selected-window)))
7339 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7340 (gnus-article-prev-page)
7341 (select-window win)))
7343 (defun gnus-insert-next-page-button ()
7345 (inhibit-read-only t)
7346 (situation (get-text-property (point-min) 'mime-view-situation)))
7347 (gnus-eval-format gnus-next-page-line-format nil
7348 `(keymap ,gnus-next-page-map
7350 gnus-callback gnus-article-button-next-page
7351 article-type annotation
7352 mime-view-situation ,situation))
7353 (widget-convert-button
7355 ;; Exclude a newline.
7358 :action 'gnus-button-next-page
7359 :button-keymap gnus-next-page-map)))
7361 (defun gnus-article-button-next-page (arg)
7362 "Go to the next page."
7364 (let ((win (selected-window)))
7365 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7366 (gnus-article-next-page)
7367 (select-window win)))
7369 (defun gnus-article-button-prev-page (arg)
7370 "Go to the prev page."
7372 (let ((win (selected-window)))
7373 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7374 (gnus-article-prev-page)
7375 (select-window win)))
7377 (defvar gnus-decode-header-methods
7378 '(mail-decode-encoded-word-region)
7379 "List of methods used to decode headers.
7381 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
7382 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
7383 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
7384 whose names match REGEXP.
7387 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
7388 mail-decode-encoded-word-region
7389 (\"chinese\" . rfc1843-decode-region))
7392 (defvar gnus-decode-header-methods-cache nil)
7394 (defun gnus-multi-decode-header (start end)
7395 "Apply the functions from `gnus-encoded-word-methods' that match."
7396 (unless (and gnus-decode-header-methods-cache
7397 (eq gnus-newsgroup-name
7398 (car gnus-decode-header-methods-cache)))
7399 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
7402 (nconc gnus-decode-header-methods-cache (list x))
7403 (if (and gnus-newsgroup-name
7404 (string-match (car x) gnus-newsgroup-name))
7405 (nconc gnus-decode-header-methods-cache
7407 gnus-decode-header-methods))
7408 (let ((xlist gnus-decode-header-methods-cache))
7411 (narrow-to-region start end)
7413 (funcall (pop xlist) (point-min) (point-max))))))
7416 ;;; Treatment top-level handling.
7419 (defun gnus-treat-article (condition &optional part-number total-parts type)
7420 (let ((length (- (point-max) (point-min)))
7421 (alist gnus-treatment-function-alist)
7422 (article-goto-body-goes-to-point-min-p t)
7426 (let ((list gnus-article-treat-types))
7428 (when (string-match (pop list) type)
7429 (throw 'found t)))))))
7430 (highlightp (gnus-visual-p 'article-highlight 'highlight))
7431 (entity (static-unless (featurep 'xemacs)
7432 (when (eq 'head condition)
7433 (get-text-property (point-min) 'mime-view-entity))))
7434 val elem buttonized)
7435 (gnus-run-hooks 'gnus-part-display-hook)
7436 (unless gnus-inhibit-treatment
7437 (dolist (elem alist)
7440 (when (gnus-buffer-live-p gnus-summary-buffer)
7441 (set-buffer gnus-summary-buffer))
7442 (symbol-value (car elem))))
7443 (when (and (or (consp val)
7445 (gnus-treat-predicate val)
7446 (or (not (get (car elem) 'highlight))
7448 (when (and (not buttonized)
7450 '(gnus-treat-hide-signature
7451 gnus-treat-highlight-signature)))
7452 (gnus-article-buttonize-signature)
7453 (setq buttonized t))
7455 (funcall (cadr elem)))))
7456 ;; FSF Emacsen does not inherit the existing text properties
7457 ;; in the new text, so we should do it for `mime-view-entity'.
7458 (static-unless (featurep 'xemacs)
7460 (put-text-property (point-min) (point-max)
7461 'mime-view-entity entity))))))
7463 ;; Dynamic variables.
7465 (defvar part-number)
7466 (defvar total-parts)
7471 (defun gnus-treat-predicate (val)
7476 (stringp (car val)))
7477 (apply 'gnus-or (mapcar `(lambda (s)
7478 (string-match s ,(or gnus-newsgroup-name "")))
7481 (let ((pred (pop val)))
7484 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
7486 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
7488 (not (gnus-treat-predicate (car val))))
7490 (equal (car val) type))
7492 (error "%S is not a valid predicate" pred)))))
7502 (eq part-number total-parts))
7506 (error "%S is not a valid value" val))))
7508 (defun gnus-article-encrypt-body (protocol &optional n)
7509 "Encrypt the article body."
7512 (or gnus-article-encrypt-protocol
7513 (completing-read "Encrypt protocol: "
7514 gnus-article-encrypt-protocol-alist
7516 current-prefix-arg))
7517 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7519 (error (format "Can't find the encrypt protocol %s" protocol)))
7520 (if (member gnus-newsgroup-name '("nndraft:delayed"
7523 (error "Can't encrypt the article in group %s"
7524 gnus-newsgroup-name))
7525 (gnus-summary-iterate n
7527 (set-buffer gnus-summary-buffer)
7528 (let ((mail-parse-charset gnus-newsgroup-charset)
7529 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7530 (summary-buffer gnus-summary-buffer)
7532 (gnus-set-global-variables)
7533 (when (gnus-group-read-only-p)
7534 (error "The current newsgroup does not support article encrypt"))
7535 (gnus-summary-show-article t)
7537 (or (mail-header-references gnus-current-headers) ""))
7538 (set-buffer gnus-article-buffer)
7539 (let* ((inhibit-read-only t)
7541 (mapcar (lambda (field)
7542 (and (save-restriction
7543 (message-narrow-to-head)
7544 (goto-char (point-min))
7545 (search-forward field nil t))
7547 (message-narrow-to-field)
7549 (delete-region (point-min) (point-max))
7551 '("Content-Type:" "Content-Transfer-Encoding:"
7552 "Content-Disposition:"))))
7553 (message-narrow-to-head)
7554 (message-remove-header "MIME-Version")
7555 (goto-char (point-max))
7556 (setq point (point))
7557 (insert (apply 'concat headers))
7559 (narrow-to-region point (point-max))
7560 (let ((message-options message-options))
7561 (message-options-set 'message-sender user-mail-address)
7562 (message-options-set 'message-recipients user-mail-address)
7563 (message-options-set 'message-sign-encrypt 'not)
7565 (goto-char (point-min))
7566 (insert "MIME-Version: 1.0\n")
7568 (gnus-summary-edit-article-done
7569 references nil summary-buffer t))
7570 (when gnus-keep-backlog
7571 (gnus-backlog-remove-article
7572 (car gnus-article-current) (cdr gnus-article-current)))
7574 (when (get-buffer gnus-original-article-buffer)
7575 (set-buffer gnus-original-article-buffer)
7576 (setq gnus-original-article nil)))
7577 (when gnus-use-cache
7578 (gnus-cache-update-article
7579 (car gnus-article-current) (cdr gnus-article-current))))))))
7581 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7582 "The following specs can be used:
7583 %t The security MIME type
7586 %D Details if button is pressed")
7588 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
7589 "The following specs can be used:
7590 %t The security MIME type
7593 %D Details if button is pressed")
7595 (defvar gnus-mime-security-button-line-format-alist
7596 '((?t gnus-tmp-type ?s)
7597 (?i gnus-tmp-info ?s)
7598 (?d gnus-tmp-details ?s)
7599 (?D gnus-tmp-pressed-details ?s)))
7601 (defvar gnus-mime-security-button-map
7602 (let ((map (make-sparse-keymap)))
7603 (define-key map gnus-mouse-2 'gnus-article-push-button)
7604 (define-key map "\r" 'gnus-article-press-button)
7607 (defvar gnus-mime-security-details-buffer nil)
7609 (defvar gnus-mime-security-button-pressed nil)
7611 (defvar gnus-mime-security-show-details-inline t
7612 "If non-nil, show details in the article buffer.")
7614 (defun gnus-mime-security-verify-or-decrypt (handle)
7615 (mm-remove-parts (cdr handle))
7616 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7617 point (inhibit-read-only t))
7619 (goto-char (car region)))
7621 (narrow-to-region (point) (point))
7622 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7623 (let* ((mm-verify-option 'known)
7624 (mm-decrypt-option 'known)
7625 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7626 (unless (eq nparts (cdr handle))
7627 (mm-destroy-parts (cdr handle))
7628 (setcdr handle nparts))))
7629 (setq point (point))
7630 (gnus-mime-display-security handle)
7631 (goto-char (point-max)))
7633 (delete-region (point) (cdr region))
7634 (set-marker (car region) nil)
7635 (set-marker (cdr region) nil))
7638 (defun gnus-mime-security-show-details (handle)
7639 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7641 (gnus-message 5 "No details.")
7642 (if gnus-mime-security-show-details-inline
7643 (let ((gnus-mime-security-button-pressed
7644 (not (get-text-property (point) 'gnus-mime-details)))
7645 (gnus-mime-security-button-line-format
7646 (get-text-property (point) 'gnus-line-format))
7647 (inhibit-read-only t))
7649 (while (eq (get-text-property (point) 'gnus-line-format)
7650 gnus-mime-security-button-line-format)
7654 (narrow-to-region (point) (point))
7655 (gnus-insert-mime-security-button handle))
7656 (delete-region (point)
7657 (or (text-property-not-all
7660 gnus-mime-security-button-line-format)
7663 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7664 (with-current-buffer gnus-mime-security-details-buffer
7667 (setq gnus-mime-security-details-buffer
7668 (gnus-get-buffer-create "*MIME Security Details*")))
7669 (with-current-buffer gnus-mime-security-details-buffer
7671 (goto-char (point-min)))
7672 (pop-to-buffer gnus-mime-security-details-buffer)))))
7674 (defun gnus-mime-security-press-button (handle)
7676 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7677 (gnus-mime-security-show-details handle)
7678 (gnus-mime-security-verify-or-decrypt handle))))
7680 (defun gnus-insert-mime-security-button (handle &optional displayed)
7681 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7684 (or (nth 2 (assoc protocol mm-verify-function-alist))
7685 (nth 2 (assoc protocol mm-decrypt-function-alist))
7687 (if (equal (car handle) "multipart/signed")
7688 " Signed" " Encrypted")
7691 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7694 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7695 gnus-tmp-pressed-details
7697 (setq gnus-tmp-details
7698 (if gnus-tmp-details
7699 (concat "\n" gnus-tmp-details)
7701 (setq gnus-tmp-pressed-details
7702 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7707 gnus-mime-security-button-line-format
7708 gnus-mime-security-button-line-format-alist
7709 `(keymap ,gnus-mime-security-button-map
7710 gnus-callback gnus-mime-security-press-button
7711 gnus-line-format ,gnus-mime-security-button-line-format
7712 gnus-mime-details ,gnus-mime-security-button-pressed
7713 article-type annotation
7716 ;; Exclude a newline.
7719 (widget-convert-button
7722 :action 'gnus-widget-press-button
7723 :button-keymap gnus-mime-security-button-map
7725 (lambda (widget/window &optional overlay pos)
7726 ;; Needed to properly clear the message due to a bug in
7727 ;; wid-edit (XEmacs only).
7728 (when (boundp 'help-echo-owns-message)
7729 (setq help-echo-owns-message t))
7732 (aref gnus-mouse-2 0))))))
7734 (defun gnus-mime-display-security (handle)
7736 (narrow-to-region (point) (point))
7737 (unless (gnus-unbuttonized-mime-type-p (car handle))
7738 (gnus-insert-mime-security-button handle))
7739 (gnus-mime-display-mixed (cdr handle))
7742 (unless (gnus-unbuttonized-mime-type-p (car handle))
7743 (let ((gnus-mime-security-button-line-format
7744 gnus-mime-security-button-end-line-format))
7745 (gnus-insert-mime-security-button handle)))
7746 (mm-set-handle-multipart-parameter
7748 (cons (set-marker (make-marker) (point-min))
7749 (set-marker (make-marker) (point-max))))))
7755 (defun gnus-article-header-presentation-method (entity situation)
7756 (mime-insert-header entity)
7757 (article-decode-group-name))
7759 (set-alist 'mime-header-presentation-method-alist
7760 'gnus-original-article-mode
7761 #'gnus-article-header-presentation-method)
7763 (defun gnus-mime-preview-quitting-method ()
7764 (mime-preview-kill-buffer)
7765 (delete-other-windows)
7766 (gnus-article-show-summary)
7767 (gnus-summary-select-article gnus-show-all-headers t))
7769 (set-alist 'mime-preview-quitting-method-alist
7770 'gnus-original-article-mode #'gnus-mime-preview-quitting-method)
7772 (set-alist 'mime-preview-following-method-alist
7773 'gnus-original-article-mode #'gnus-following-method)
7775 (set-alist 'mime-preview-over-to-previous-method-alist
7776 'gnus-original-article-mode
7778 (if (> (point-min) 1)
7779 (gnus-article-prev-page)
7780 (gnus-article-read-summary-keys
7781 nil (gnus-character-to-event ?P)))))
7783 (set-alist 'mime-preview-over-to-next-method-alist
7784 'gnus-original-article-mode'
7786 (if (< (point-max) (buffer-size))
7787 (gnus-article-next-page)
7788 (gnus-article-read-summary-keys
7789 nil (gnus-character-to-event ?N)))))
7799 (run-hooks 'gnus-art-load-hook)
7801 ;;; gnus-art.el ends here