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))
435 (regexp :format "%t: %v\n" :size 1)
436 (integer :format "Match group: %v\n" :size 0)
437 (integer :format "Emphasize group: %v\n" :size 0)
440 :value (("_" . "_") nil default)
442 (regexp :format "Start regexp: %v\n" :size 0)
443 (regexp :format "End regexp: %v\n" :size 0))
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 where the key is the match and the
605 value is a list of possible files to save in if the match is non-nil.
607 If the match is a string, it is used as a regexp match on the
608 article. If the match is a symbol, that symbol will be funcalled
609 from the buffer of the article to be saved with the newsgroup as the
610 parameter. If it is a list, it will be evaled in the same buffer.
612 If this form or function returns a string, this string will be used as
613 a possible file name; and if it returns a non-nil list, that list will
614 be used as possible file names."
615 :group 'gnus-article-saving
616 :type '(repeat (choice (list :value (fun) function)
617 (cons :value ("" "") regexp (repeat string))
620 (defcustom gnus-article-display-method-for-mime
621 'gnus-article-display-mime-message
622 "Function to display a MIME message.
623 The function is called from the article buffer."
624 :group 'gnus-article-mime
627 (defcustom gnus-article-display-method-for-traditional
628 'gnus-article-display-traditional-message
629 "*Function to display a traditional message.
630 The function is called from the article buffer."
631 :group 'gnus-article-mime
634 (defcustom gnus-page-delimiter "^\^L"
635 "*Regexp describing what to use as article page delimiters.
636 The default value is \"^\^L\", which is a form linefeed at the
637 beginning of a line."
639 :group 'gnus-article-various)
641 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
642 "*The format specification for the article mode line.
643 See `gnus-summary-mode-line-format' for a closer description.
645 The following additional specs are available:
647 %w The article washing status.
648 %m The number of MIME parts in the article."
650 :group 'gnus-article-various)
652 (defcustom gnus-article-mode-hook nil
653 "*A hook for Gnus article mode."
655 :group 'gnus-article-various)
657 (when (featurep 'xemacs)
658 ;; Extracted from gnus-xmas-define in order to preserve user settings
659 (when (fboundp 'turn-off-scroll-in-place)
660 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
661 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
662 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
664 (defcustom gnus-article-menu-hook nil
665 "*Hook run after the creation of the article mode menu."
667 :group 'gnus-article-various)
669 (defcustom gnus-article-prepare-hook nil
670 "*A hook called after an article has been prepared in the article buffer."
672 :group 'gnus-article-various)
674 (defcustom gnus-copy-article-ignored-headers nil
675 "List of headers to be removed when copying an article.
676 Each element is a regular expression."
677 :version "22.0" ;; No Gnus
678 :type '(repeat regexp)
679 :group 'gnus-article-various)
681 (make-obsolete-variable 'gnus-article-hide-pgp-hook
682 "This variable is obsolete in Gnus 5.10.")
684 (defcustom gnus-article-button-face 'bold
685 "Face used for highlighting buttons in the article buffer.
687 An article button is a piece of text that you can activate by pressing
688 `RET' or `mouse-2' above it."
690 :group 'gnus-article-buttons)
692 (defcustom gnus-article-mouse-face 'highlight
693 "Face used for mouse highlighting in the article buffer.
695 Article buttons will be displayed in this face when the cursor is
698 :group 'gnus-article-buttons)
700 (defcustom gnus-signature-face 'gnus-signature-face
701 "Face used for highlighting a signature in the article buffer.
702 Obsolete; use the face `gnus-signature-face' for customizations instead."
704 :group 'gnus-article-highlight
705 :group 'gnus-article-signature)
707 (defface gnus-signature-face
710 "Face used for highlighting a signature in the article buffer."
711 :group 'gnus-article-highlight
712 :group 'gnus-article-signature)
714 (defface gnus-header-from-face
717 (:foreground "spring green"))
720 (:foreground "red3"))
723 "Face used for displaying from headers."
724 :group 'gnus-article-headers
725 :group 'gnus-article-highlight)
727 (defface gnus-header-subject-face
730 (:foreground "SeaGreen3"))
733 (:foreground "red4"))
735 (:bold t :italic t)))
736 "Face used for displaying subject headers."
737 :group 'gnus-article-headers
738 :group 'gnus-article-highlight)
740 (defface gnus-header-newsgroups-face
743 (:foreground "yellow" :italic t))
746 (:foreground "MidnightBlue" :italic t))
749 "Face used for displaying newsgroups headers.
750 In the default setup this face is only used for crossposted
752 :group 'gnus-article-headers
753 :group 'gnus-article-highlight)
755 (defface gnus-header-name-face
758 (:foreground "SeaGreen"))
761 (:foreground "maroon"))
764 "Face used for displaying header names."
765 :group 'gnus-article-headers
766 :group 'gnus-article-highlight)
768 (defface gnus-header-content-face
771 (:foreground "forest green" :italic t))
774 (:foreground "indianred4" :italic t))
777 "Face used for displaying header content."
778 :group 'gnus-article-headers
779 :group 'gnus-article-highlight)
781 (defcustom gnus-header-face-alist
782 '(("From" nil gnus-header-from-face)
783 ("Subject" nil gnus-header-subject-face)
784 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
785 ("" gnus-header-name-face gnus-header-content-face))
786 "*Controls highlighting of article headers.
788 An alist of the form (HEADER NAME CONTENT).
790 HEADER is a regular expression which should match the name of a
791 header and NAME and CONTENT are either face names or nil.
793 The name of each header field will be displayed using the face
794 specified by the first element in the list where HEADER matches
795 the header name and NAME is non-nil. Similarly, the content will
796 be displayed by the first non-nil matching CONTENT face."
797 :group 'gnus-article-headers
798 :group 'gnus-article-highlight
799 :type '(repeat (list (regexp :tag "Header")
801 (item :tag "skip" nil)
802 (face :value default))
803 (choice :tag "Content"
804 (item :tag "skip" nil)
805 (face :value default)))))
807 (defcustom gnus-article-decode-hook
808 '(article-decode-group-name article-decode-idna-rhs)
809 "*Hook run to decode charsets in articles."
810 :group 'gnus-article-headers
813 (defcustom gnus-display-mime-function 'gnus-display-mime
814 "Function to display MIME articles."
815 :group 'gnus-article-mime
818 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
819 "Function used to decode headers.")
821 (defvar gnus-article-dumbquotes-map
841 "Table for MS-to-Latin1 translation.")
843 (defcustom gnus-ignored-mime-types nil
844 "List of MIME types that should be ignored by Gnus."
846 :group 'gnus-article-mime
847 :type '(repeat regexp))
849 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
850 "List of MIME types that should not be given buttons when rendered inline.
851 See also `gnus-buttonized-mime-types' which may override this variable.
852 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
854 :group 'gnus-article-mime
855 :type '(repeat regexp))
857 (defcustom gnus-buttonized-mime-types nil
858 "List of MIME types that should be given buttons when rendered inline.
859 If set, this variable overrides `gnus-unbuttonized-mime-types'.
860 To see e.g. security buttons you could set this to
861 `(\"multipart/signed\")'.
862 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
864 :group 'gnus-article-mime
865 :type '(repeat regexp))
867 (defcustom gnus-inhibit-mime-unbuttonizing nil
868 "If non-nil, all MIME parts get buttons.
869 When nil (the default value), then some MIME parts do not get buttons,
870 as described by the variables `gnus-buttonized-mime-types' and
871 `gnus-unbuttonized-mime-types'."
873 :group 'gnus-article-mime
876 (defcustom gnus-body-boundary-delimiter "_"
877 "String used to delimit header and body.
878 This variable is used by `gnus-article-treat-body-boundary' which can
879 be controlled by `gnus-treat-body-boundary'."
881 :group 'gnus-article-various
882 :type '(choice (item :tag "None" :value nil)
885 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces"
887 "Defines the location of the faces database.
888 For information on obtaining this database of pretty pictures, please
889 see http://www.cs.indiana.edu/picons/ftp/index.html"
891 :type '(repeat directory)
892 :link '(url-link :tag "download"
893 "http://www.cs.indiana.edu/picons/ftp/index.html")
894 :link '(custom-manual "(gnus)Picons")
897 (defun gnus-picons-installed-p ()
898 "Say whether picons are installed on your machine."
899 (let ((installed nil))
900 (dolist (database gnus-picon-databases)
901 (when (file-exists-p database)
905 (defcustom gnus-article-mime-part-function nil
906 "Function called with a MIME handle as the argument.
907 This is meant for people who want to do something automatic based
908 on parts -- for instance, adding Vcard info to a database."
909 :group 'gnus-article-mime
912 (defcustom gnus-mime-multipart-functions nil
913 "An alist of MIME types to functions to display them."
915 :group 'gnus-article-mime
916 :type '(repeat (cons :format "%v" (string :tag "MIME type") function)))
918 (defcustom gnus-article-date-lapsed-new-header nil
919 "Whether the X-Sent and Date headers can coexist.
920 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
921 either replace the old \"Date:\" header (if this variable is nil), or
922 be added below it (otherwise)."
924 :group 'gnus-article-headers
927 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
928 "Function called with a MIME handle as the argument.
929 This is meant for people who want to view first matched part.
930 For `undisplayed-alternative' (default), the first undisplayed
931 part or alternative part is used. For `undisplayed', the first
932 undisplayed part is used. For a function, the first part which
933 the function return t is used. For nil, the first part is
936 :group 'gnus-article-mime
938 (item :tag "first" :value nil)
939 (item :tag "undisplayed" :value undisplayed)
940 (item :tag "undisplayed or alternative"
941 :value undisplayed-alternative)
944 (defcustom gnus-mime-action-alist
945 '(("save to file" . gnus-mime-save-part)
946 ("save and strip" . gnus-mime-save-part-and-strip)
947 ("delete part" . gnus-mime-delete-part)
948 ("display as text" . gnus-mime-inline-part)
949 ("view the part" . gnus-mime-view-part)
950 ("pipe to command" . gnus-mime-pipe-part)
951 ("toggle display" . gnus-article-press-button)
952 ("toggle display" . gnus-article-view-part-as-charset)
953 ("view as type" . gnus-mime-view-part-as-type)
954 ("view internally" . gnus-mime-view-part-internally)
955 ("view externally" . gnus-mime-view-part-externally))
956 "An alist of actions that run on the MIME attachment."
957 :group 'gnus-article-mime
958 :type '(repeat (cons (string :tag "name")
962 ;;; The treatment variables
965 (defvar gnus-part-display-hook nil
966 "Hook called on parts that are to receive treatment.")
968 (defvar gnus-article-treat-custom
969 '(choice (const :tag "Off" nil)
971 (const :tag "Header" head)
972 (const :tag "Last" last)
973 (const :tag "Mime" mime)
974 (integer :tag "Less")
975 (repeat :tag "Groups" regexp)
976 (sexp :tag "Predicate")))
978 (defvar gnus-article-treat-head-custom
979 '(choice (const :tag "Off" nil)
980 (const :tag "Header" head)))
982 (defvar gnus-article-treat-types '("text/plain")
985 (defvar gnus-inhibit-treatment nil
986 "Whether to inhibit treatment.")
988 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
989 "Highlight the signature.
990 Valid values are nil, t, `head', `last', an integer or a predicate.
991 See Info node `(gnus)Customizing Articles'."
992 :group 'gnus-article-treat
993 :link '(custom-manual "(gnus)Customizing Articles")
994 :type gnus-article-treat-custom)
995 (put 'gnus-treat-highlight-signature 'highlight t)
997 (defcustom gnus-treat-buttonize 100000
999 Valid values are nil, t, `head', `last', an integer or a predicate.
1000 See Info node `(gnus)Customizing Articles'."
1001 :group 'gnus-article-treat
1002 :link '(custom-manual "(gnus)Customizing Articles")
1003 :type gnus-article-treat-custom)
1004 (put 'gnus-treat-buttonize 'highlight t)
1006 (defcustom gnus-treat-buttonize-head 'head
1007 "Add buttons to the head.
1008 Valid values are nil, t, `head', `last', an integer or a predicate.
1009 See Info node `(gnus)Customizing Articles' for details."
1010 :group 'gnus-article-treat
1011 :link '(custom-manual "(gnus)Customizing Articles")
1012 :type gnus-article-treat-head-custom)
1013 (put 'gnus-treat-buttonize-head 'highlight t)
1015 (defcustom gnus-treat-emphasize
1016 (and (or window-system
1020 Valid values are nil, t, `head', `last', an integer or a predicate.
1021 See Info node `(gnus)Customizing Articles' for details."
1022 :group 'gnus-article-treat
1023 :link '(custom-manual "(gnus)Customizing Articles")
1024 :type gnus-article-treat-custom)
1025 (put 'gnus-treat-emphasize 'highlight t)
1027 (defcustom gnus-treat-strip-cr nil
1028 "Remove carriage returns.
1029 Valid values are nil, t, `head', `last', an integer or a predicate.
1030 See Info node `(gnus)Customizing Articles' for details."
1032 :group 'gnus-article-treat
1033 :link '(custom-manual "(gnus)Customizing Articles")
1034 :type gnus-article-treat-custom)
1036 (defcustom gnus-treat-unsplit-urls nil
1037 "Remove newlines from within URLs.
1038 Valid values are nil, t, `head', `last', an integer or a predicate.
1039 See Info node `(gnus)Customizing Articles' for details."
1041 :group 'gnus-article-treat
1042 :link '(custom-manual "(gnus)Customizing Articles")
1043 :type gnus-article-treat-custom)
1045 (defcustom gnus-treat-leading-whitespace nil
1046 "Remove leading whitespace in headers.
1047 Valid values are nil, t, `head', `last', an integer or a predicate.
1048 See Info node `(gnus)Customizing Articles' for details."
1050 :group 'gnus-article-treat
1051 :link '(custom-manual "(gnus)Customizing Articles")
1052 :type gnus-article-treat-custom)
1054 (defcustom gnus-treat-hide-headers 'head
1056 Valid values are nil, t, `head', `last', an integer or a predicate.
1057 See Info node `(gnus)Customizing Articles' for details."
1058 :group 'gnus-article-treat
1059 :link '(custom-manual "(gnus)Customizing Articles")
1060 :type gnus-article-treat-head-custom)
1062 (defcustom gnus-treat-hide-boring-headers nil
1063 "Hide boring headers.
1064 Valid values are nil, t, `head', `last', an integer or a predicate.
1065 See Info node `(gnus)Customizing Articles' for details."
1066 :group 'gnus-article-treat
1067 :link '(custom-manual "(gnus)Customizing Articles")
1068 :type gnus-article-treat-head-custom)
1070 (defcustom gnus-treat-hide-signature nil
1071 "Hide the signature.
1072 Valid values are nil, t, `head', `last', an integer or a predicate.
1073 See Info node `(gnus)Customizing Articles' for details."
1074 :group 'gnus-article-treat
1075 :link '(custom-manual "(gnus)Customizing Articles")
1076 :type gnus-article-treat-custom)
1078 (defcustom gnus-treat-fill-article nil
1080 Valid values are nil, t, `head', `last', an integer or a predicate.
1081 See Info node `(gnus)Customizing Articles' for details."
1082 :group 'gnus-article-treat
1083 :link '(custom-manual "(gnus)Customizing Articles")
1084 :type gnus-article-treat-custom)
1086 (defcustom gnus-treat-hide-citation nil
1088 Valid values are nil, t, `head', `last', an integer or a predicate.
1089 See Info node `(gnus)Customizing Articles' for details."
1090 :group 'gnus-article-treat
1091 :link '(custom-manual "(gnus)Customizing Articles")
1092 :type gnus-article-treat-custom)
1094 (defcustom gnus-treat-hide-citation-maybe nil
1096 Valid values are nil, t, `head', `last', an integer or a predicate.
1097 See Info node `(gnus)Customizing Articles' for details."
1098 :group 'gnus-article-treat
1099 :link '(custom-manual "(gnus)Customizing Articles")
1100 :type gnus-article-treat-custom)
1102 (defcustom gnus-treat-strip-list-identifiers 'head
1103 "Strip list identifiers from `gnus-list-identifiers`.
1104 Valid values are nil, t, `head', `last', an integer or a predicate.
1105 See Info node `(gnus)Customizing Articles' for details."
1107 :group 'gnus-article-treat
1108 :link '(custom-manual "(gnus)Customizing Articles")
1109 :type gnus-article-treat-custom)
1111 (make-obsolete-variable 'gnus-treat-strip-pgp
1112 "This option is obsolete in Gnus 5.10.")
1114 (defcustom gnus-treat-strip-pem nil
1115 "Strip PEM signatures.
1116 Valid values are nil, t, `head', `last', an integer or a predicate.
1117 See Info node `(gnus)Customizing Articles' for details."
1118 :group 'gnus-article-treat
1119 :link '(custom-manual "(gnus)Customizing Articles")
1120 :type gnus-article-treat-custom)
1122 (defcustom gnus-treat-strip-banner t
1123 "Strip banners from articles.
1124 The banner to be stripped is specified in the `banner' group parameter.
1125 Valid values are nil, t, `head', `last', an integer or a predicate.
1126 See Info node `(gnus)Customizing Articles' for details."
1127 :group 'gnus-article-treat
1128 :link '(custom-manual "(gnus)Customizing Articles")
1129 :type gnus-article-treat-custom)
1131 (defcustom gnus-treat-highlight-headers 'head
1132 "Highlight the headers.
1133 Valid values are nil, t, `head', `last', an integer or a predicate.
1134 See Info node `(gnus)Customizing Articles' for details."
1135 :group 'gnus-article-treat
1136 :link '(custom-manual "(gnus)Customizing Articles")
1137 :type gnus-article-treat-head-custom)
1138 (put 'gnus-treat-highlight-headers 'highlight t)
1140 (defcustom gnus-treat-highlight-citation t
1141 "Highlight cited text.
1142 Valid values are nil, t, `head', `last', an integer or a predicate.
1143 See Info node `(gnus)Customizing Articles' for details."
1144 :group 'gnus-article-treat
1145 :link '(custom-manual "(gnus)Customizing Articles")
1146 :type gnus-article-treat-custom)
1147 (put 'gnus-treat-highlight-citation 'highlight t)
1149 (defcustom gnus-treat-date-ut nil
1150 "Display the Date in UT (GMT).
1151 Valid values are nil, t, `head', `last', an integer or a predicate.
1152 See Info node `(gnus)Customizing Articles' for details."
1153 :group 'gnus-article-treat
1154 :link '(custom-manual "(gnus)Customizing Articles")
1155 :type gnus-article-treat-head-custom)
1157 (defcustom gnus-treat-date-local nil
1158 "Display the Date in the local timezone.
1159 Valid values are nil, t, `head', `last', an integer or a predicate.
1160 See Info node `(gnus)Customizing Articles' for details."
1161 :group 'gnus-article-treat
1162 :link '(custom-manual "(gnus)Customizing Articles")
1163 :type gnus-article-treat-head-custom)
1165 (defcustom gnus-treat-date-english nil
1166 "Display the Date in a format that can be read aloud in English.
1167 Valid values are nil, t, `head', `last', an integer or a predicate.
1168 See Info node `(gnus)Customizing Articles' for details."
1170 :group 'gnus-article-treat
1171 :link '(custom-manual "(gnus)Customizing Articles")
1172 :type gnus-article-treat-head-custom)
1174 (defcustom gnus-treat-date-lapsed nil
1175 "Display the Date header in a way that says how much time has elapsed.
1176 Valid values are nil, t, `head', `last', an integer or a predicate.
1177 See Info node `(gnus)Customizing Articles' for details."
1178 :group 'gnus-article-treat
1179 :link '(custom-manual "(gnus)Customizing Articles")
1180 :type gnus-article-treat-head-custom)
1182 (defcustom gnus-treat-date-original nil
1183 "Display the date in the original timezone.
1184 Valid values are nil, t, `head', `last', an integer or a predicate.
1185 See Info node `(gnus)Customizing Articles' for details."
1186 :group 'gnus-article-treat
1187 :link '(custom-manual "(gnus)Customizing Articles")
1188 :type gnus-article-treat-head-custom)
1190 (defcustom gnus-treat-date-iso8601 nil
1191 "Display the date in the ISO8601 format.
1192 Valid values are nil, t, `head', `last', an integer or a predicate.
1193 See Info node `(gnus)Customizing Articles' for details."
1195 :group 'gnus-article-treat
1196 :link '(custom-manual "(gnus)Customizing Articles")
1197 :type gnus-article-treat-head-custom)
1199 (defcustom gnus-treat-date-user-defined nil
1200 "Display the date in a user-defined format.
1201 The format is defined by the `gnus-article-time-format' variable.
1202 Valid values are nil, t, `head', `last', an integer or a predicate.
1203 See Info node `(gnus)Customizing Articles' for details."
1204 :group 'gnus-article-treat
1205 :link '(custom-manual "(gnus)Customizing Articles")
1206 :type gnus-article-treat-head-custom)
1208 (defcustom gnus-treat-strip-headers-in-body t
1209 "Strip the X-No-Archive header line from the beginning of the body.
1210 Valid values are nil, t, `head', `last', an integer or a predicate.
1211 See Info node `(gnus)Customizing Articles' for details."
1213 :group 'gnus-article-treat
1214 :link '(custom-manual "(gnus)Customizing Articles")
1215 :type gnus-article-treat-custom)
1217 (defcustom gnus-treat-strip-trailing-blank-lines nil
1218 "Strip trailing blank lines.
1219 Valid values are nil, t, `head', `last', an integer or a predicate.
1220 See Info node `(gnus)Customizing Articles' for details."
1221 :group 'gnus-article-treat
1222 :link '(custom-manual "(gnus)Customizing Articles")
1223 :type gnus-article-treat-custom)
1225 (defcustom gnus-treat-strip-leading-blank-lines nil
1226 "Strip leading blank lines.
1227 Valid values are nil, t, `head', `last', an integer or a predicate.
1228 See Info node `(gnus)Customizing Articles' for details."
1229 :group 'gnus-article-treat
1230 :link '(custom-manual "(gnus)Customizing Articles")
1231 :type gnus-article-treat-custom)
1233 (defcustom gnus-treat-strip-multiple-blank-lines nil
1234 "Strip multiple blank lines.
1235 Valid values are nil, t, `head', `last', an integer or a predicate.
1236 See Info node `(gnus)Customizing Articles' for details."
1237 :group 'gnus-article-treat
1238 :link '(custom-manual "(gnus)Customizing Articles")
1239 :type gnus-article-treat-custom)
1241 (defcustom gnus-treat-unfold-headers 'head
1242 "Unfold folded header lines.
1243 Valid values are nil, t, `head', `last', an integer or a predicate.
1244 See Info node `(gnus)Customizing Articles' for details."
1246 :group 'gnus-article-treat
1247 :link '(custom-manual "(gnus)Customizing Articles")
1248 :type gnus-article-treat-custom)
1250 (defcustom gnus-treat-fold-headers nil
1252 Valid values are nil, t, `head', `last', an integer or a predicate.
1253 See Info node `(gnus)Customizing Articles' for details."
1255 :group 'gnus-article-treat
1256 :link '(custom-manual "(gnus)Customizing Articles")
1257 :type gnus-article-treat-custom)
1259 (defcustom gnus-treat-fold-newsgroups 'head
1260 "Fold the Newsgroups and Followup-To headers.
1261 Valid values are nil, t, `head', `last', an integer or a predicate.
1262 See Info node `(gnus)Customizing Articles' for details."
1264 :group 'gnus-article-treat
1265 :link '(custom-manual "(gnus)Customizing Articles")
1266 :type gnus-article-treat-custom)
1268 (defcustom gnus-treat-overstrike t
1269 "Treat overstrike highlighting.
1270 Valid values are nil, t, `head', `last', an integer or a predicate.
1271 See Info node `(gnus)Customizing Articles' for details."
1272 :group 'gnus-article-treat
1273 :link '(custom-manual "(gnus)Customizing Articles")
1274 :type gnus-article-treat-custom)
1275 (put 'gnus-treat-overstrike 'highlight t)
1277 (defcustom gnus-treat-ansi-sequences (if (locate-library "ansi-color") t)
1278 "Treat ANSI SGR control sequences.
1279 Valid values are nil, t, `head', `last', an integer or a predicate.
1280 See Info node `(gnus)Customizing Articles' for details."
1281 :group 'gnus-article-treat
1282 :link '(custom-manual "(gnus)Customizing Articles")
1283 :type gnus-article-treat-custom)
1285 (make-obsolete-variable 'gnus-treat-display-xface
1286 'gnus-treat-display-x-face)
1288 (defcustom gnus-treat-display-x-face
1289 (and (not noninteractive)
1290 (or (eq gnus-article-x-face-command
1291 'x-face-mule-gnus-article-display-x-face)
1292 (and (fboundp 'image-type-available-p)
1293 (image-type-available-p 'xbm)
1294 (string-match "^0x" (shell-command-to-string "uncompface"))
1295 (executable-find "icontopbm"))
1296 (and (featurep 'xemacs)
1299 "Display X-Face headers.
1300 Valid values are nil, t, `head', `last', an integer or a predicate.
1301 See Info node `(gnus)Customizing Articles' and Info node
1302 `(gnus)X-Face' for details."
1303 :group 'gnus-article-treat
1305 :link '(custom-manual "(gnus)Customizing Articles")
1306 :link '(custom-manual "(gnus)X-Face")
1307 :type gnus-article-treat-head-custom
1308 :set (lambda (symbol value)
1311 (cond ((or (boundp symbol) (get symbol 'saved-value))
1313 ((boundp 'gnus-treat-display-xface)
1315 ** gnus-treat-display-xface is an obsolete variable;\
1316 use gnus-treat-display-x-face instead")
1317 (default-value 'gnus-treat-display-xface))
1318 ((get 'gnus-treat-display-xface 'saved-value)
1320 ** gnus-treat-display-xface is an obsolete variable;\
1321 use gnus-treat-display-x-face instead")
1322 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1325 (put 'gnus-treat-display-x-face 'highlight t)
1327 (defcustom gnus-article-should-use-smiley-mule
1328 (not (or (featurep 'xemacs)
1329 (gnus-image-type-available-p 'xpm)
1330 (gnus-image-type-available-p 'pbm)))
1331 "Non-nil means use `smiley-mule' to show smileys rather than `smiley'.
1332 `smiley-mule' is boundled in BITMAP-MULE package. You can set it to t
1333 even if your Emacs supports images. It has no effect on XEmacs."
1334 :group 'gnus-article-various
1336 :get (lambda (symbol)
1337 (and (not noninteractive)
1338 (default-value symbol)
1339 (not (featurep 'xemacs))
1340 (module-installed-p 'smiley-mule)
1342 :set (lambda (symbol value)
1343 (set-default symbol (and (not noninteractive)
1345 (not (featurep 'xemacs))
1346 (module-installed-p 'smiley-mule)
1349 (defvar gnus-article-smiley-mule-loaded-p nil
1350 "Internal variable used to say whether `smiley-mule' is loaded (whether
1351 smiley functions are not overridden by `smiley').")
1353 (defcustom gnus-treat-display-face
1354 (and (not noninteractive)
1355 (or (and (fboundp 'image-type-available-p)
1356 (image-type-available-p 'png))
1357 (and (featurep 'xemacs)
1360 "Display Face headers.
1361 Valid values are nil, t, `head', `last', an integer or a predicate.
1362 See Info node `(gnus)Customizing Articles' and Info node
1363 `(gnus)X-Face' for details."
1364 :group 'gnus-article-treat
1366 :link '(custom-manual "(gnus)Customizing Articles")
1367 :link '(custom-manual "(gnus)X-Face")
1368 :type gnus-article-treat-head-custom)
1369 (put 'gnus-treat-display-face 'highlight t)
1371 (defcustom gnus-treat-display-smileys
1372 (if (and (not noninteractive)
1373 (or (and (featurep 'xemacs)
1375 (gnus-image-type-available-p 'xpm)
1376 (gnus-image-type-available-p 'pbm)
1377 (and (not (featurep 'xemacs))
1379 (module-installed-p 'smiley-mule))))
1383 Valid values are nil, t, `head', `last', an integer or a predicate.
1384 See Info node `(gnus)Customizing Articles' and Info node
1385 `(gnus)Smileys' for details."
1386 :group 'gnus-article-treat
1388 :link '(custom-manual "(gnus)Customizing Articles")
1389 :link '(custom-manual "(gnus)Smileys")
1390 :type gnus-article-treat-custom)
1391 (put 'gnus-treat-display-smileys 'highlight t)
1393 (defcustom gnus-treat-from-picon
1394 (if (and (gnus-image-type-available-p 'xpm)
1395 (gnus-picons-installed-p))
1397 "Display picons in the From header.
1398 Valid values are nil, t, `head', `last', an integer or a predicate.
1399 See Info node `(gnus)Customizing Articles' and Info node
1400 `(gnus)Picons' for details."
1402 :group 'gnus-article-treat
1404 :link '(custom-manual "(gnus)Customizing Articles")
1405 :link '(custom-manual "(gnus)Picons")
1406 :type gnus-article-treat-head-custom)
1407 (put 'gnus-treat-from-picon 'highlight t)
1409 (defcustom gnus-treat-mail-picon
1410 (if (and (gnus-image-type-available-p 'xpm)
1411 (gnus-picons-installed-p))
1413 "Display picons in To and Cc headers.
1414 Valid values are nil, t, `head', `last', an integer or a predicate.
1415 See Info node `(gnus)Customizing Articles' and Info node
1416 `(gnus)Picons' for details."
1418 :group 'gnus-article-treat
1420 :link '(custom-manual "(gnus)Customizing Articles")
1421 :link '(custom-manual "(gnus)Picons")
1422 :type gnus-article-treat-head-custom)
1423 (put 'gnus-treat-mail-picon 'highlight t)
1425 (defcustom gnus-treat-newsgroups-picon
1426 (if (and (gnus-image-type-available-p 'xpm)
1427 (gnus-picons-installed-p))
1429 "Display picons in the Newsgroups and Followup-To headers.
1430 Valid values are nil, t, `head', `last', an integer or a predicate.
1431 See Info node `(gnus)Customizing Articles' and Info node
1432 `(gnus)Picons' for details."
1434 :group 'gnus-article-treat
1436 :link '(custom-manual "(gnus)Customizing Articles")
1437 :link '(custom-manual "(gnus)Picons")
1438 :type gnus-article-treat-head-custom)
1439 (put 'gnus-treat-newsgroups-picon 'highlight t)
1441 (defcustom gnus-treat-body-boundary
1442 (if (and (eq window-system 'x)
1443 (or gnus-treat-newsgroups-picon
1444 gnus-treat-mail-picon
1445 gnus-treat-from-picon))
1447 "Draw a boundary at the end of the headers.
1448 Valid values are nil and `head'.
1449 See Info node `(gnus)Customizing Articles' for details."
1451 :group 'gnus-article-treat
1452 :link '(custom-manual "(gnus)Customizing Articles")
1453 :type gnus-article-treat-head-custom)
1455 (defcustom gnus-treat-capitalize-sentences nil
1456 "Capitalize sentence-starting words.
1457 Valid values are nil, t, `head', `last', an integer or a predicate.
1458 See Info node `(gnus)Customizing Articles' for details."
1460 :group 'gnus-article-treat
1461 :link '(custom-manual "(gnus)Customizing Articles")
1462 :type gnus-article-treat-custom)
1464 (defcustom gnus-treat-wash-html nil
1466 Valid values are nil, t, `head', `last', an integer or a predicate.
1467 See Info node `(gnus)Customizing Articles' for details."
1469 :group 'gnus-article-treat
1470 :link '(custom-manual "(gnus)Customizing Articles")
1471 :type gnus-article-treat-custom)
1473 (defcustom gnus-treat-fill-long-lines nil
1475 Valid values are nil, t, `head', `last', an integer or a predicate.
1476 See Info node `(gnus)Customizing Articles' for details."
1477 :group 'gnus-article-treat
1478 :link '(custom-manual "(gnus)Customizing Articles")
1479 :type gnus-article-treat-custom)
1481 (defcustom gnus-treat-play-sounds nil
1483 Valid values are nil, t, `head', `last', an integer or a predicate.
1484 See Info node `(gnus)Customizing Articles' for details."
1486 :group 'gnus-article-treat
1487 :link '(custom-manual "(gnus)Customizing Articles")
1488 :type gnus-article-treat-custom)
1490 (defcustom gnus-treat-decode-article-as-default-mime-charset nil
1491 "Decode an article as `default-mime-charset'. For instance, if you want to
1492 attempt to decode an article even if the value of `gnus-show-mime' is nil,
1493 you could set this variable to something like: nil for don't decode, t for
1494 decode the body, '(or header t) for the whole article, etc."
1495 :group 'gnus-article-treat
1496 :type '(radio (const :tag "Off" nil)
1497 (const :tag "Decode body" t)
1498 (const :tag "Decode all" (or head t))))
1500 (defcustom gnus-treat-translate nil
1501 "Translate articles from one language to another.
1502 Valid values are nil, t, `head', `last', an integer or a predicate.
1503 See Info node `(gnus)Customizing Articles' for details."
1505 :group 'gnus-article-treat
1506 :link '(custom-manual "(gnus)Customizing Articles")
1507 :type gnus-article-treat-custom)
1509 (defcustom gnus-treat-x-pgp-sig nil
1511 To automatically treat X-PGP-Sig, set it to head.
1512 Valid values are nil, t, `head', `last', an integer or a predicate.
1513 See Info node `(gnus)Customizing Articles' for details."
1515 :group 'gnus-article-treat
1516 :group 'mime-security
1517 :type gnus-article-treat-custom)
1519 (defcustom gnus-treat-monafy nil
1520 "Display body part with mona font.
1521 Valid values are nil, t, `head', `last', an integer or a predicate.
1522 See Info node `(gnus)Customizing Articles' for details."
1523 :group 'gnus-article-treat
1524 :group 'mime-security
1525 :link '(custom-manual "(gnus)Customizing Articles")
1526 :type gnus-article-treat-custom)
1528 (defvar gnus-article-encrypt-protocol-alist
1529 '(("PGP" . mml2015-self-encrypt)))
1531 ;; Set to nil if more than one protocol added to
1532 ;; gnus-article-encrypt-protocol-alist.
1533 (defcustom gnus-article-encrypt-protocol "PGP"
1534 "The protocol used for encrypt articles.
1535 It is a string, such as \"PGP\". If nil, ask user."
1538 :group 'mime-security)
1540 (defvar gnus-article-wash-function nil
1541 "Function used for converting HTML into text.")
1543 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1544 (mm-coding-system-p 'utf-8)
1545 (executable-find idna-program))
1546 "Whether IDNA decoding of headers is used when viewing messages.
1547 This requires GNU Libidn, and by default only enabled if it is found."
1549 :group 'gnus-article-headers
1552 (defcustom gnus-article-over-scroll nil
1553 "If non-nil, allow scrolling the article buffer even when there no more text."
1555 :group 'gnus-article
1558 ;;; Internal variables
1560 (defvar gnus-english-month-names
1561 '("January" "February" "March" "April" "May" "June" "July" "August"
1562 "September" "October" "November" "December"))
1564 (defvar gnus-button-regexp nil)
1565 (defvar gnus-button-marker-list nil)
1566 ;; Regexp matching any of the regexps from `gnus-button-alist'.
1568 (defvar gnus-button-last nil)
1569 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
1571 (defvar article-goto-body-goes-to-point-min-p nil)
1572 (defvar gnus-article-wash-types nil)
1573 (defvar gnus-article-emphasis-alist nil)
1574 (defvar gnus-article-image-alist nil)
1576 (defvar gnus-article-mime-handle-alist-1 nil)
1577 (defvar gnus-treatment-function-alist
1578 '((gnus-treat-decode-article-as-default-mime-charset
1579 gnus-article-decode-article-as-default-mime-charset)
1580 (gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1581 (gnus-treat-monafy gnus-article-monafy)
1582 (gnus-treat-strip-banner gnus-article-strip-banner)
1583 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1584 (gnus-treat-buttonize gnus-article-add-buttons)
1585 (gnus-treat-fill-article gnus-article-fill-cited-article)
1586 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1587 (gnus-treat-strip-cr gnus-article-remove-cr)
1588 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1589 (gnus-treat-date-ut gnus-article-date-ut)
1590 (gnus-treat-date-local gnus-article-date-local)
1591 (gnus-treat-date-english gnus-article-date-english)
1592 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1593 (gnus-treat-date-original gnus-article-date-original)
1594 (gnus-treat-date-user-defined gnus-article-date-user)
1595 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1596 (gnus-treat-display-face gnus-article-display-face)
1597 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1598 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1599 (gnus-treat-hide-signature gnus-article-hide-signature)
1600 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1601 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1602 (gnus-treat-strip-pem gnus-article-hide-pem)
1603 (gnus-treat-from-picon gnus-treat-from-picon)
1604 (gnus-treat-mail-picon gnus-treat-mail-picon)
1605 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1606 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1607 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1608 (gnus-treat-strip-trailing-blank-lines
1609 gnus-article-remove-trailing-blank-lines)
1610 (gnus-treat-strip-leading-blank-lines
1611 gnus-article-strip-leading-blank-lines)
1612 (gnus-treat-strip-multiple-blank-lines
1613 gnus-article-strip-multiple-blank-lines)
1614 (gnus-treat-overstrike gnus-article-treat-overstrike)
1615 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences)
1616 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1617 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1618 ;; Displaying X-Face should be done after unfolding headers
1619 ;; to protect bitmap lines.
1620 (gnus-treat-display-x-face gnus-article-display-x-face)
1621 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1622 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1623 (gnus-treat-display-smileys gnus-treat-smiley)
1624 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1625 (gnus-treat-wash-html gnus-article-wash-html)
1626 (gnus-treat-emphasize gnus-article-emphasize)
1627 (gnus-treat-hide-citation gnus-article-hide-citation)
1628 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1629 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1630 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1631 (gnus-treat-play-sounds gnus-earcon-display)))
1633 (defvar gnus-article-mime-handle-alist nil)
1634 (defvar article-lapsed-timer nil)
1635 (defvar gnus-article-current-summary nil)
1637 (defvar gnus-article-mode-syntax-table
1638 (let ((table (copy-syntax-table text-mode-syntax-table)))
1639 ;; This causes the citation match run O(2^n).
1640 ;; (modify-syntax-entry ?- "w" table)
1641 (modify-syntax-entry ?> ")<" table)
1642 (modify-syntax-entry ?< "(>" table)
1643 ;; make M-. in article buffers work for `foo' strings
1644 (modify-syntax-entry ?' " " table)
1645 (modify-syntax-entry ?` " " table)
1647 "Syntax table used in article mode buffers.
1648 Initialized from `text-mode-syntax-table.")
1650 (defvar gnus-save-article-buffer nil)
1652 (defvar gnus-article-mode-line-format-alist
1653 (nconc '((?w (gnus-article-wash-status) ?s)
1654 (?m (gnus-article-mime-part-status) ?s))
1655 gnus-summary-mode-line-format-alist))
1657 (defvar gnus-number-of-articles-to-be-saved nil)
1659 (defvar gnus-inhibit-hiding nil)
1661 (defvar gnus-article-edit-mode nil)
1663 ;;; Macros for dealing with the article buffer.
1665 (defmacro gnus-with-article-headers (&rest forms)
1667 (set-buffer gnus-article-buffer)
1669 (let ((inhibit-read-only t)
1670 (inhibit-point-motion-hooks t)
1671 (case-fold-search t))
1672 (article-narrow-to-head)
1675 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1676 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1678 (defmacro gnus-with-article-buffer (&rest forms)
1680 (set-buffer gnus-article-buffer)
1681 (let ((inhibit-read-only t))
1684 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1685 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1687 (defun gnus-article-goto-header (header)
1688 "Go to HEADER, which is a regular expression."
1689 (re-search-forward (concat "^\\(" header "\\):") nil t))
1691 (defsubst gnus-article-hide-text (b e props)
1692 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1693 (gnus-add-text-properties-when 'article-type nil b e props)
1694 (when (memq 'intangible props)
1696 (max (1- b) (point-min))
1697 b 'intangible (cddr (memq 'intangible props)))))
1699 (defsubst gnus-article-unhide-text (b e)
1700 "Remove hidden text properties from region between B and E."
1701 (remove-text-properties b e gnus-hidden-properties)
1702 (when (memq 'intangible gnus-hidden-properties)
1703 (put-text-property (max (1- b) (point-min))
1704 b 'intangible nil)))
1706 (defun gnus-article-hide-text-type (b e type)
1707 "Hide text of TYPE between B and E."
1708 (gnus-add-wash-type type)
1709 (gnus-article-hide-text
1710 b e (cons 'article-type (cons type gnus-hidden-properties))))
1712 (defun gnus-article-unhide-text-type (b e type)
1713 "Unhide text of TYPE between B and E."
1714 (gnus-delete-wash-type type)
1715 (remove-text-properties
1716 b e (cons 'article-type (cons type gnus-hidden-properties)))
1717 (when (memq 'intangible gnus-hidden-properties)
1718 (put-text-property (max (1- b) (point-min))
1719 b 'intangible nil)))
1721 (defun gnus-article-hide-text-of-type (type)
1722 "Hide text of TYPE in the current buffer."
1724 (let ((b (point-min))
1726 (while (setq b (text-property-any b e 'article-type type))
1727 (add-text-properties b (incf b) gnus-hidden-properties)))))
1729 (defun gnus-article-delete-text-of-type (type)
1730 "Delete text of TYPE in the current buffer."
1732 (let ((b (point-min)))
1733 (while (setq b (text-property-any b (point-max) 'article-type type))
1735 b (or (text-property-not-all b (point-max) 'article-type type)
1738 (defun gnus-article-delete-invisible-text ()
1739 "Delete all invisible text in the current buffer."
1741 (let ((b (point-min)))
1742 (while (setq b (text-property-any b (point-max) 'invisible t))
1744 b (or (text-property-not-all b (point-max) 'invisible t)
1747 (defun gnus-article-text-type-exists-p (type)
1748 "Say whether any text of type TYPE exists in the buffer."
1749 (text-property-any (point-min) (point-max) 'article-type type))
1751 (defsubst gnus-article-header-rank ()
1752 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1753 (let ((list gnus-sorted-header-list)
1756 (if (looking-at (car list))
1758 (setq list (cdr list))
1762 (defun article-hide-headers (&optional arg delete)
1763 "Hide unwanted headers and possibly sort them as well."
1764 (interactive (gnus-article-hidden-arg))
1765 ;; Lars said that this function might be inhibited.
1766 (if (gnus-article-check-hidden-text 'headers arg)
1768 ;; Show boring headers as well.
1769 (gnus-article-show-hidden-text 'boring-headers)
1770 (when (eq 1 (point-min))
1771 (set-window-start (get-buffer-window (current-buffer)) 1)))
1772 (unless gnus-inhibit-hiding
1773 (let ((inhibit-read-only t)
1774 (case-fold-search t)
1775 (max (1+ (length gnus-sorted-header-list)))
1776 (inhibit-point-motion-hooks t)
1777 (cur (current-buffer))
1778 ignored visible beg)
1780 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1781 ;; group parameters, so we should go to the summary buffer.
1784 (progn (set-buffer gnus-summary-buffer) t)
1786 (setq ignored (when (not gnus-visible-headers)
1787 (cond ((stringp gnus-ignored-headers)
1788 gnus-ignored-headers)
1789 ((listp gnus-ignored-headers)
1790 (mapconcat 'identity
1791 gnus-ignored-headers
1793 visible (cond ((stringp gnus-visible-headers)
1794 gnus-visible-headers)
1795 ((and gnus-visible-headers
1796 (listp gnus-visible-headers))
1797 (mapconcat 'identity
1798 gnus-visible-headers
1802 ;; First we narrow to just the headers.
1803 (article-narrow-to-head)
1804 ;; Hide any "From " lines at the beginning of (mail) articles.
1805 (while (looking-at "From ")
1809 (delete-region (point-min) (point))
1810 (gnus-article-hide-text (point-min) (point)
1811 (nconc (list 'article-type 'headers)
1812 gnus-hidden-properties))))
1813 ;; Then treat the rest of the header lines.
1814 ;; Then we use the two regular expressions
1815 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1816 ;; select which header lines is to remain visible in the
1818 (while (re-search-forward "^[^ \t:]*:" nil t)
1820 ;; Mark the rank of the header.
1822 (point) (1+ (point)) 'message-rank
1823 (if (or (and visible (looking-at visible))
1825 (not (looking-at ignored))))
1826 (gnus-article-header-rank)
1829 (message-sort-headers-1)
1830 (when (setq beg (text-property-any
1831 (point-min) (point-max) 'message-rank (+ 2 max)))
1832 ;; We delete or make invisible the unwanted headers.
1833 (gnus-add-wash-type 'headers)
1836 (add-text-properties
1837 (point-min) (+ 5 (point-min))
1838 '(article-type headers dummy-invisible t))
1839 (delete-region beg (point-max)))
1840 (gnus-article-hide-text-type beg (point-max) 'headers)))))))))
1842 (defun article-hide-boring-headers (&optional arg)
1843 "Toggle hiding of headers that aren't very interesting.
1844 If given a negative prefix, always show; if given a positive prefix,
1846 (interactive (gnus-article-hidden-arg))
1847 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1848 (not gnus-show-all-headers))
1851 (let ((inhibit-read-only t)
1852 (inhibit-point-motion-hooks t))
1853 (article-narrow-to-head)
1854 (dolist (elem gnus-boring-article-headers)
1855 (goto-char (point-min))
1857 ;; Hide empty headers.
1859 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1861 (gnus-article-hide-text-type
1865 (if (re-search-forward "^[^ \t]" nil t)
1869 ;; Hide boring Newsgroups header.
1870 ((eq elem 'newsgroups)
1871 (when (gnus-string-equal
1872 (gnus-fetch-field "newsgroups")
1873 (gnus-group-real-name
1874 (if (boundp 'gnus-newsgroup-name)
1877 (gnus-article-hide-header "newsgroups")))
1878 ((eq elem 'to-address)
1879 (let ((to (message-fetch-field "to"))
1881 (gnus-parameter-to-address
1882 (if (boundp 'gnus-newsgroup-name)
1883 gnus-newsgroup-name ""))))
1884 (when (and to to-address
1887 ;; only one address in To
1888 (nth 1 (mail-extract-address-components to))
1890 (gnus-article-hide-header "to"))))
1892 (let ((to (message-fetch-field "to"))
1894 (gnus-parameter-to-list
1895 (if (boundp 'gnus-newsgroup-name)
1896 gnus-newsgroup-name ""))))
1897 (when (and to to-list
1900 ;; only one address in To
1901 (nth 1 (mail-extract-address-components to))
1903 (gnus-article-hide-header "to"))))
1905 (let ((cc (message-fetch-field "cc"))
1907 (gnus-parameter-to-list
1908 (if (boundp 'gnus-newsgroup-name)
1909 gnus-newsgroup-name ""))))
1910 (when (and cc to-list
1913 ;; only one address in CC
1914 (nth 1 (mail-extract-address-components cc))
1916 (gnus-article-hide-header "cc"))))
1917 ((eq elem 'followup-to)
1918 (when (gnus-string-equal
1919 (message-fetch-field "followup-to")
1920 (message-fetch-field "newsgroups"))
1921 (gnus-article-hide-header "followup-to")))
1922 ((eq elem 'reply-to)
1923 (if (gnus-group-find-parameter
1924 gnus-newsgroup-name 'broken-reply-to)
1925 (gnus-article-hide-header "reply-to")
1926 (let ((from (message-fetch-field "from"))
1927 (reply-to (message-fetch-field "reply-to")))
1934 (lambda (x) (downcase (cadr x)))
1935 (mail-extract-address-components from t))
1938 (lambda (x) (downcase (cadr x)))
1939 (mail-extract-address-components reply-to t))
1941 (gnus-article-hide-header "reply-to")))))
1943 (let ((date (message-fetch-field "date")))
1945 (< (days-between (current-time-string) date)
1947 (gnus-article-hide-header "date"))))
1949 (let ((to (message-fetch-field "to"))
1950 (cc (message-fetch-field "cc")))
1951 (when (> (length to) 1024)
1952 (gnus-article-hide-header "to"))
1953 (when (> (length cc) 1024)
1954 (gnus-article-hide-header "cc"))))
1958 (goto-char (point-min))
1959 (while (re-search-forward "^to:" nil t)
1960 (setq to-count (1+ to-count)))
1961 (when (> to-count 1)
1962 (while (> to-count 0)
1963 (goto-char (point-min))
1965 (re-search-forward "^to:" nil nil to-count)
1967 (narrow-to-region (point) (point-max))
1968 (gnus-article-hide-header "to"))
1969 (setq to-count (1- to-count))))
1970 (goto-char (point-min))
1971 (while (re-search-forward "^cc:" nil t)
1972 (setq cc-count (1+ cc-count)))
1973 (when (> cc-count 1)
1974 (while (> cc-count 0)
1975 (goto-char (point-min))
1977 (re-search-forward "^cc:" nil nil cc-count)
1979 (narrow-to-region (point) (point-max))
1980 (gnus-article-hide-header "cc"))
1981 (setq cc-count (1- cc-count)))))))))))))
1983 (defun gnus-article-hide-header (header)
1985 (goto-char (point-min))
1986 (when (re-search-forward (concat "^" header ":") nil t)
1987 (gnus-article-hide-text-type
1991 (if (re-search-forward "^[^ \t]" nil t)
1996 (defvar gnus-article-normalized-header-length 40
1997 "Length of normalized headers.")
1999 (defun article-normalize-headers ()
2000 "Make all header lines 40 characters long."
2002 (let ((inhibit-read-only t)
2006 (article-narrow-to-head)
2009 ((< (setq column (- (point-at-eol) (point)))
2010 gnus-article-normalized-header-length)
2012 (insert (make-string
2013 (- gnus-article-normalized-header-length column)
2015 ((> column gnus-article-normalized-header-length)
2016 (gnus-put-text-property
2018 (forward-char gnus-article-normalized-header-length)
2025 (forward-line 1))))))
2027 (defun article-treat-dumbquotes ()
2028 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
2029 Note that this function guesses whether a character is a sm*rtq**t* or
2030 not, so it should only be used interactively.
2032 Sm*rtq**t*s are M****s***'s unilateral extension to the
2033 iso-8859-1 character map in an attempt to provide more quoting
2034 characters. If you see something like \\222 or \\264 where
2035 you're expecting some kind of apostrophe or quotation mark, then
2038 (article-translate-strings gnus-article-dumbquotes-map))
2040 (defun article-translate-characters (from to)
2041 "Translate all characters in the body of the article according to FROM and TO.
2042 FROM is a string of characters to translate from; to is a string of
2043 characters to translate to."
2045 (when (article-goto-body)
2046 (let ((inhibit-read-only t)
2047 (x (make-string 225 ?x))
2049 (while (< (incf i) (length x))
2052 (while (< i (length from))
2053 (aset x (aref from i) (aref to i))
2055 (translate-region (point) (point-max) x)))))
2057 (defun article-translate-strings (map)
2058 "Translate all string in the body of the article according to MAP.
2059 MAP is an alist where the elements are on the form (\"from\" \"to\")."
2061 (when (article-goto-body)
2062 (let ((inhibit-read-only t))
2065 (while (search-forward (car elem) nil t)
2066 (replace-match (cadr elem)))))))))
2068 (defun article-treat-overstrike ()
2069 "Translate overstrikes into bold text."
2072 (when (article-goto-body)
2073 (let ((inhibit-read-only t))
2074 (while (search-forward "\b" nil t)
2075 (let ((next (char-after))
2079 previous (char-after))
2083 ;; We do the boldification/underlining by hiding the
2084 ;; overstrikes and putting the proper text property
2088 (gnus-article-hide-text-type start (point) 'overstrike)
2089 (put-text-property (point) end 'face 'bold))
2091 (gnus-article-hide-text-type
2092 (1- (point)) (1+ (point)) 'overstrike)
2094 start (1- (point)) 'face 'underline))
2096 (gnus-article-hide-text-type start (point) 'overstrike)
2098 (point) end 'face 'underline)))))))))
2100 (defun article-treat-ansi-sequences ()
2101 "Translate ANSI SGR control sequences into overlays or extents."
2104 (when (article-goto-body)
2105 (let ((inhibit-read-only t))
2106 (ansi-color-apply-on-region (point) (point-max))))))
2108 (defun gnus-article-treat-unfold-headers ()
2109 "Unfold folded message headers.
2110 Only the headers that fit into the current window width will be
2113 (gnus-with-article-headers
2117 (mail-header-narrow-to-field)
2118 (let ((header (buffer-string)))
2121 (goto-char (point-min))
2122 (while (re-search-forward "\n[\t ]" nil t)
2123 (replace-match " " t t)))
2124 (setq length (- (point-max) (point-min) 1)))
2125 (when (< length (window-width))
2126 (while (re-search-forward "\n[\t ]" nil t)
2127 (replace-match " " t t)))
2128 (goto-char (point-max)))))))
2130 (defun gnus-article-treat-fold-headers ()
2131 "Fold message headers."
2133 (gnus-with-article-headers
2136 (mail-header-narrow-to-field)
2137 (mail-header-fold-field)
2138 (goto-char (point-max))))))
2140 (defun gnus-treat-smiley ()
2141 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2143 (unless (featurep 'xemacs)
2144 (when (and (not gnus-article-should-use-smiley-mule)
2145 gnus-article-smiley-mule-loaded-p)
2146 (load "smiley" nil t)
2147 (setq gnus-article-smiley-mule-loaded-p nil))
2148 (when (and gnus-article-should-use-smiley-mule
2149 (not gnus-article-smiley-mule-loaded-p))
2150 (load "smiley-mule" nil t)
2151 (setq gnus-article-smiley-mule-loaded-p t)))
2152 (gnus-with-article-buffer
2153 (if (memq 'smiley gnus-article-wash-types)
2154 (gnus-delete-images 'smiley)
2156 (let ((images (smiley-region (point) (point-max))))
2158 (gnus-add-wash-type 'smiley)
2159 (dolist (image images)
2160 (gnus-add-image 'smiley image)))))))
2162 (defun gnus-article-remove-images ()
2163 "Remove all images from the article buffer."
2165 (gnus-with-article-buffer
2166 (dolist (elem gnus-article-image-alist)
2167 (gnus-delete-images (car elem)))))
2169 (defun gnus-article-treat-fold-newsgroups ()
2170 "Unfold folded message headers.
2171 Only the headers that fit into the current window width will be
2174 (gnus-with-article-headers
2175 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2177 (mail-header-narrow-to-field)
2178 (while (re-search-forward ", *" nil t)
2179 (replace-match ", " t t))
2180 (mail-header-fold-field)
2181 (goto-char (point-max))))))
2183 (defun gnus-article-treat-body-boundary ()
2184 "Place a boundary line at the end of the headers."
2186 (when (and gnus-body-boundary-delimiter
2187 (> (length gnus-body-boundary-delimiter) 0))
2188 (gnus-with-article-headers
2189 (goto-char (point-max))
2190 (let ((start (point)))
2191 (insert "X-Boundary: ")
2192 (gnus-add-text-properties start (point) '(invisible t intangible t))
2194 (while (>= (1- (window-width)) (length str))
2195 (setq str (concat str gnus-body-boundary-delimiter)))
2196 (substring str 0 (1- (window-width))))
2198 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2200 (defun article-fill-long-lines ()
2201 "Fill lines that are wider than the window width."
2204 (let ((inhibit-read-only t)
2205 (width (window-width (get-buffer-window (current-buffer)))))
2208 (let ((adaptive-fill-mode nil)) ;Why? -sm
2211 (when (>= (current-column) (min fill-column width))
2212 (narrow-to-region (min (1+ (point)) (point-max))
2214 (let ((goback (point-marker)))
2215 (fill-paragraph nil)
2216 (goto-char (marker-position goback)))
2218 (forward-line 1)))))))
2220 (defun article-capitalize-sentences ()
2221 "Capitalize the first word in each sentence."
2224 (let ((inhibit-read-only t)
2225 (paragraph-start "^[\n\^L]"))
2229 (forward-sentence)))))
2231 (defun article-remove-cr ()
2232 "Remove trailing CRs and then translate remaining CRs into LFs."
2235 (let ((inhibit-read-only t))
2236 (goto-char (point-min))
2237 (while (re-search-forward "\r+$" nil t)
2238 (replace-match "" t t))
2239 (goto-char (point-min))
2240 (while (search-forward "\r" nil t)
2241 (replace-match "\n" t t)))))
2243 (defun article-remove-trailing-blank-lines ()
2244 "Remove all trailing blank lines from the article."
2247 (let ((inhibit-read-only t))
2248 (goto-char (point-max))
2252 (while (and (not (bobp))
2253 (looking-at "^[ \t]*$")
2254 (not (gnus-annotation-in-region-p
2255 (point) (point-at-eol))))
2261 (defvar gnus-face-properties-alist))
2263 (defun article-display-face ()
2264 "Display any Face headers in the header."
2266 (let ((wash-face-p buffer-read-only))
2267 (gnus-with-article-headers
2268 ;; When displaying parts, this function can be called several times on
2269 ;; the same article, without any intended toggle semantic (as typing `W
2270 ;; D d' would have). So face deletion must occur only when we come from
2271 ;; an interactive command, that is when the *Article* buffer is
2273 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2274 (gnus-delete-images 'face)
2277 (when (and wash-face-p
2279 (goto-char (point-min))
2280 (not (re-search-forward "^Face:[\t ]*" nil t)))
2281 (gnus-buffer-live-p gnus-original-article-buffer))
2282 (set-buffer gnus-original-article-buffer))
2284 (mail-narrow-to-head)
2285 (while (gnus-article-goto-header "Face")
2286 (setq faces (nconc faces (list (mail-header-field-value)))))))
2287 (dolist (face faces)
2288 (let ((png (gnus-convert-face-to-png face))
2292 (apply 'gnus-create-image png 'png t
2293 (cdr (assq 'png gnus-face-properties-alist))))
2294 (gnus-article-goto-header "from")
2296 (insert "From: [no `from' set]\n")
2298 (gnus-add-wash-type 'face)
2299 (gnus-add-image 'face image)
2300 (gnus-put-image image nil 'face))))))
2303 (defun article-display-x-face (&optional force)
2304 "Look for an X-Face header and display it if present."
2305 (interactive (list 'force))
2306 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2307 (gnus-with-article-headers
2308 ;; Delete the old process, if any.
2309 (when (process-status "article-x-face")
2310 (delete-process "article-x-face"))
2311 ;; See the comment in `article-display-face'.
2312 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2313 ;; We have already displayed X-Faces, so we remove them
2315 (gnus-delete-images 'xface)
2317 (let (x-faces from face)
2319 (when (and wash-face-p
2321 (goto-char (point-min))
2322 (not (re-search-forward
2323 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2324 (gnus-buffer-live-p gnus-original-article-buffer))
2325 ;; If type `W f', use gnus-original-article-buffer,
2326 ;; otherwise use the current buffer because displaying
2327 ;; RFC822 parts calls this function too.
2328 (set-buffer gnus-original-article-buffer))
2330 (mail-narrow-to-head)
2331 (while (gnus-article-goto-header "X-Face")
2332 (push (mail-header-field-value) x-faces))
2333 (setq from (message-fetch-field "from"))))
2334 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2335 ;; single external face.
2336 (when (stringp gnus-article-x-face-command)
2337 (setq x-faces (list (car x-faces))))
2338 (while (and (setq face (pop x-faces))
2339 gnus-article-x-face-command
2341 ;; Check whether this face is censored.
2342 (not gnus-article-x-face-too-ugly)
2343 (and gnus-article-x-face-too-ugly from
2344 (not (string-match gnus-article-x-face-too-ugly
2346 ;; We display the face.
2347 (cond ((stringp gnus-article-x-face-command)
2348 ;; The command is a string, so we interpret the command
2349 ;; as a, well, command, and fork it off.
2350 (let ((process-connection-type nil))
2351 (process-kill-without-query
2353 "article-x-face" nil shell-file-name
2354 shell-command-switch gnus-article-x-face-command))
2357 (process-send-region "article-x-face"
2358 (point-min) (point-max)))
2359 (process-send-eof "article-x-face")))
2360 ((functionp gnus-article-x-face-command)
2361 ;; The command is a lisp function, so we call it.
2362 (funcall gnus-article-x-face-command face))
2364 (error "%s is not a function"
2365 gnus-article-x-face-command)))))))))
2367 (defun article-decode-mime-words ()
2368 "Decode all MIME-encoded words in the article."
2370 (gnus-with-article-buffer
2371 (let ((inhibit-point-motion-hooks t)
2372 (mail-parse-charset gnus-newsgroup-charset)
2373 (mail-parse-ignored-charsets
2374 (with-current-buffer gnus-summary-buffer
2375 gnus-newsgroup-ignored-charsets)))
2376 (mail-decode-encoded-word-region (point-min) (point-max)))))
2378 (defun article-decode-charset (&optional prompt)
2379 "Decode charset-encoded text in the article.
2380 If PROMPT (the prefix), prompt for a coding system to use."
2382 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2383 (inhibit-read-only t)
2384 (mail-parse-charset gnus-newsgroup-charset)
2385 (mail-parse-ignored-charsets
2386 (save-excursion (condition-case nil
2387 (set-buffer gnus-summary-buffer)
2389 gnus-newsgroup-ignored-charsets))
2390 ct cte ctl charset format)
2393 (article-narrow-to-head)
2394 (setq ct (message-fetch-field "Content-Type" t)
2395 cte (message-fetch-field "Content-Transfer-Encoding" t)
2396 ctl (and ct (ignore-errors
2397 (mail-header-parse-content-type ct)))
2400 (mm-read-coding-system "Charset to decode: "))
2402 (mail-content-type-get ctl 'charset)))
2403 format (and ctl (mail-content-type-get ctl 'format)))
2405 (setq cte (mail-header-strip cte)))
2406 (if (and ctl (not (string-match "/" (car ctl))))
2408 (goto-char (point-max)))
2411 (narrow-to-region (point) (point-max))
2412 (when (and (eq mail-parse-charset 'gnus-decoded)
2413 (eq (mm-body-7-or-8) '8bit))
2414 ;; The text code could have been decoded.
2415 (setq charset mail-parse-charset))
2416 (when (and (or (not ctl)
2417 (equal (car ctl) "text/plain"))
2418 (not format)) ;; article with format will decode later.
2420 charset (and cte (intern (downcase
2421 (gnus-strip-whitespace cte))))
2424 (defun article-decode-encoded-words ()
2425 "Remove encoded-word encoding from headers."
2426 (let ((charset (save-excursion
2427 (set-buffer gnus-summary-buffer)
2428 default-mime-charset))
2429 (inhibit-read-only t))
2430 (mime-decode-header-in-buffer charset)))
2432 (defun article-decode-group-name ()
2433 "Decode group names in `Newsgroups:'."
2434 (let ((inhibit-point-motion-hooks t)
2435 (inhibit-read-only t)
2436 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2437 (when (and (or gnus-group-name-charset-method-alist
2438 gnus-group-name-charset-group-alist)
2439 (gnus-buffer-live-p gnus-original-article-buffer))
2441 (article-narrow-to-head)
2442 (with-current-buffer gnus-original-article-buffer
2443 (goto-char (point-min)))
2444 (while (re-search-forward
2445 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2446 (replace-match (save-match-data
2447 (gnus-decode-newsgroups
2448 ;; XXX how to use data in article buffer?
2449 (with-current-buffer gnus-original-article-buffer
2451 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2454 gnus-newsgroup-name method))
2456 (goto-char (point-min))
2457 (with-current-buffer gnus-original-article-buffer
2458 (goto-char (point-min)))
2459 (while (re-search-forward
2460 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2461 (replace-match (save-match-data
2462 (gnus-decode-newsgroups
2463 ;; XXX how to use data in article buffer?
2464 (with-current-buffer gnus-original-article-buffer
2466 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2469 gnus-newsgroup-name method))
2472 (autoload 'idna-to-unicode "idna")
2474 (defun article-decode-idna-rhs ()
2475 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2478 (let ((inhibit-point-motion-hooks t)
2479 (inhibit-read-only t))
2480 (article-narrow-to-head)
2481 (goto-char (point-min))
2482 (while (re-search-forward "@.*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2484 (when (save-match-data
2485 (and (setq ace (match-string 1))
2487 (and (re-search-backward "^[^ \t]" nil t)
2488 (looking-at "From\\|To\\|Cc")))
2489 (setq unicode (idna-to-unicode ace))))
2490 (unless (string= ace unicode)
2491 (replace-match unicode nil nil nil 1)))))))))
2493 (defun article-de-quoted-unreadable (&optional force read-charset)
2494 "Translate a quoted-printable-encoded article.
2495 If FORCE, decode the article whether it is marked as quoted-printable
2497 If READ-CHARSET, ask for a coding system."
2498 (interactive (list 'force current-prefix-arg))
2500 (let ((inhibit-read-only t) type charset)
2501 (if (gnus-buffer-live-p gnus-original-article-buffer)
2502 (with-current-buffer gnus-original-article-buffer
2504 (gnus-fetch-field "content-transfer-encoding"))
2505 (let* ((ct (gnus-fetch-field "content-type"))
2508 (mail-header-parse-content-type ct)))))
2509 (setq charset (and ctl
2510 (mail-content-type-get ctl 'charset)))
2511 (if (stringp charset)
2512 (setq charset (intern (downcase charset)))))))
2514 (setq charset (mm-read-coding-system "Charset: " charset)))
2516 (setq charset gnus-newsgroup-charset))
2518 (and type (let ((case-fold-search t))
2519 (string-match "quoted-printable" type))))
2521 (quoted-printable-decode-region
2522 (point) (point-max) (mm-charset-to-coding-system charset))))))
2524 (defun article-de-base64-unreadable (&optional force read-charset)
2525 "Translate a base64 article.
2526 If FORCE, decode the article whether it is marked as base64 not.
2527 If READ-CHARSET, ask for a coding system."
2528 (interactive (list 'force current-prefix-arg))
2530 (let ((inhibit-read-only t) type charset)
2531 (if (gnus-buffer-live-p gnus-original-article-buffer)
2532 (with-current-buffer gnus-original-article-buffer
2534 (gnus-fetch-field "content-transfer-encoding"))
2535 (let* ((ct (gnus-fetch-field "content-type"))
2538 (mail-header-parse-content-type ct)))))
2539 (setq charset (and ctl
2540 (mail-content-type-get ctl 'charset)))
2541 (if (stringp charset)
2542 (setq charset (intern (downcase charset)))))))
2544 (setq charset (mm-read-coding-system "Charset: " charset)))
2546 (setq charset gnus-newsgroup-charset))
2548 (and type (let ((case-fold-search t))
2549 (string-match "base64" type))))
2552 (narrow-to-region (point) (point-max))
2553 (base64-decode-region (point-min) (point-max))
2554 (mm-decode-coding-region
2555 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2560 (defun article-decode-HZ ()
2561 "Translate a HZ-encoded article."
2565 (let ((inhibit-read-only t))
2566 (rfc1843-decode-region (point-min) (point-max)))))
2568 (defun article-unsplit-urls ()
2569 "Remove the newlines that some other mailers insert into URLs."
2572 (let ((inhibit-read-only t))
2573 (goto-char (point-min))
2574 (while (re-search-forward
2575 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2576 (replace-match "\\1\\3" t)))
2577 (when (interactive-p)
2578 (gnus-treat-article nil))))
2581 (defun article-wash-html (&optional read-charset)
2582 "Format an HTML article.
2583 If READ-CHARSET, ask for a coding system."
2586 (let ((inhibit-read-only t)
2588 (when (gnus-buffer-live-p gnus-original-article-buffer)
2589 (with-current-buffer gnus-original-article-buffer
2590 (let* ((ct (gnus-fetch-field "content-type"))
2593 (mail-header-parse-content-type ct)))))
2594 (setq charset (and ctl
2595 (mail-content-type-get ctl 'charset)))
2596 (when (stringp charset)
2597 (setq charset (intern (downcase charset)))))))
2599 (setq charset (mm-read-coding-system "Charset: " charset)))
2601 (setq charset gnus-newsgroup-charset))
2603 (save-window-excursion
2605 (narrow-to-region (point) (point-max))
2606 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2607 (entry (assq func mm-text-html-washer-alist)))
2609 (setq func (cdr entry)))
2614 (apply (car func) (cdr func))))))))))
2616 (defun gnus-article-wash-html-with-w3 ()
2617 "Wash the current buffer with w3."
2619 (let ((w3-strict-width (window-width))
2620 (url-standalone-mode t)
2621 (url-gateway-unplugged t)
2622 (w3-honor-stylesheets nil))
2624 (w3-region (point-min) (point-max))
2627 (defun gnus-article-wash-html-with-w3m ()
2628 "Wash the current buffer with emacs-w3m."
2631 (narrow-to-region (point) (point-max))
2632 (let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp)
2633 w3m-force-redisplay)
2634 (w3m-region (point-min) (point-max)))
2635 (when (and mm-inline-text-html-with-w3m-keymap
2636 (boundp 'w3m-minor-mode-map)
2638 (add-text-properties
2639 (point-min) (point-max)
2640 (list 'keymap w3m-minor-mode-map
2641 ;; Put the mark meaning this part was rendered by emacs-w3m.
2642 'mm-inline-text-html-with-w3m t)))))
2644 (defun article-hide-list-identifiers ()
2645 "Remove list identifies from the Subject header.
2646 The `gnus-list-identifiers' variable specifies what to do."
2648 (let ((inhibit-point-motion-hooks t)
2649 (regexp (if (consp gnus-list-identifiers)
2650 (mapconcat 'identity gnus-list-identifiers " *\\|")
2651 gnus-list-identifiers))
2652 (inhibit-read-only t))
2656 (article-narrow-to-head)
2657 (goto-char (point-min))
2658 (while (re-search-forward
2659 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2661 (delete-region (match-beginning 2) (match-end 0))
2662 (beginning-of-line))
2663 (when (re-search-forward
2664 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2665 (delete-region (match-beginning 1) (match-end 1))))))))
2667 (defun article-hide-pem (&optional arg)
2668 "Toggle hiding of any PEM headers and signatures in the current article.
2669 If given a negative prefix, always show; if given a positive prefix,
2671 (interactive (gnus-article-hidden-arg))
2672 (unless (gnus-article-check-hidden-text 'pem arg)
2674 (let ((inhibit-read-only t) end)
2675 (goto-char (point-min))
2676 ;; Hide the horrendously ugly "header".
2677 (when (and (search-forward
2678 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2680 (setq end (1+ (match-beginning 0))))
2681 (gnus-add-wash-type 'pem)
2682 (gnus-article-hide-text-type
2684 (if (search-forward "\n\n" nil t)
2688 ;; Hide the trailer as well
2689 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2691 (gnus-article-hide-text-type
2692 (match-beginning 0) (match-end 0) 'pem)))))))
2694 (defun article-strip-banner ()
2695 "Strip the banners specified by the `banner' group parameter and by
2696 `gnus-article-address-banner-alist'."
2700 (let ((inhibit-point-motion-hooks t))
2701 (when (gnus-parameter-banner gnus-newsgroup-name)
2702 (article-really-strip-banner
2703 (gnus-parameter-banner gnus-newsgroup-name)))
2704 (when gnus-article-address-banner-alist
2705 ;; It is necessary to encode from fields before checking,
2706 ;; because `mail-header-parse-addresses' does not work
2707 ;; (reliably) on decoded headers. And more, it is
2708 ;; impossible to use `gnus-fetch-original-field' here,
2709 ;; because `article-strip-banner' may be called in draft
2710 ;; buffers to preview them.
2711 (let ((from (save-restriction
2713 (article-narrow-to-head)
2714 (mail-fetch-field "from"))))
2717 (caar (mail-header-parse-addresses
2718 (mail-encode-encoded-word-string from)))))
2720 (dolist (pair gnus-article-address-banner-alist)
2721 (when (string-match (car pair) from)
2723 (article-really-strip-banner (cdr pair)))))))))))))
2725 (defun article-really-strip-banner (banner)
2726 "Strip the banner specified by the argument."
2729 (let ((inhibit-point-motion-hooks t)
2730 (gnus-signature-limit nil)
2731 (inhibit-read-only t))
2734 ((eq banner 'signature)
2735 (when (gnus-article-narrow-to-signature)
2738 (delete-region (point) (point-max))))
2740 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2741 (while (re-search-forward banner nil t)
2742 (delete-region (match-beginning 0) (match-end 0)))))
2744 (while (re-search-forward banner nil t)
2745 (delete-region (match-beginning 0) (match-end 0)))))))))
2747 (defun article-babel ()
2748 "Translate article using an online translation service."
2751 (gnus-with-article-buffer
2752 (when (article-goto-body)
2753 (let* ((start (point))
2755 (orig (buffer-substring start end))
2756 (trans (babel-as-string orig)))
2758 (narrow-to-region start end)
2759 (delete-region start end)
2762 (defun article-hide-signature (&optional arg)
2763 "Hide the signature in the current article.
2764 If given a negative prefix, always show; if given a positive prefix,
2766 (interactive (gnus-article-hidden-arg))
2772 (article-goto-body))
2773 (goto-char (point-min)))
2774 (unless (gnus-article-check-hidden-text 'signature arg)
2775 (let ((inhibit-read-only t)
2777 (while (setq button (text-property-any button (point-max)
2779 'gnus-signature-toggle))
2780 (setq button (text-property-not-all button (point-max)
2782 'gnus-signature-toggle))
2783 (when (and button (not (eobp)))
2784 (gnus-article-hide-text-type
2786 (next-single-property-change (1+ button) 'mime-view-entity
2789 (gnus-set-mode-line 'article))
2791 (defun article-strip-headers-in-body ()
2792 "Strip offensive headers from bodies."
2796 (let ((case-fold-search t))
2797 (when (looking-at "x-no-archive:")
2798 (gnus-delete-line)))))
2800 (defun article-strip-leading-blank-lines ()
2801 "Remove all blank lines from the beginning of the article."
2804 (let ((inhibit-point-motion-hooks t)
2805 (inhibit-read-only t))
2806 (when (article-goto-body)
2807 (while (and (not (eobp))
2808 (looking-at "[ \t]*$"))
2809 (gnus-delete-line))))))
2811 (defun article-narrow-to-head ()
2812 "Narrow the buffer to the head of the message.
2813 Point is left at the beginning of the narrowed-to region."
2815 (goto-char (point-min))
2816 (if (search-forward "\n\n" nil 1)
2819 (goto-char (point-min)))
2821 (defun article-goto-body ()
2822 "Place point at the start of the body."
2823 (goto-char (point-min))
2825 ;; This variable is only bound when dealing with separate
2827 (article-goto-body-goes-to-point-min-p
2829 ((search-forward "\n\n" nil t)
2832 (goto-char (point-max))
2835 (defun article-strip-multiple-blank-lines ()
2836 "Replace consecutive blank lines with one empty line."
2839 (let ((inhibit-point-motion-hooks t)
2840 (inhibit-read-only t))
2841 ;; First make all blank lines empty.
2843 (while (re-search-forward "^[ \t]+$" nil t)
2844 (unless (gnus-annotation-in-region-p
2845 (match-beginning 0) (match-end 0))
2846 (replace-match "" nil t)))
2847 ;; Then replace multiple empty lines with a single empty line.
2849 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2850 (unless (gnus-annotation-in-region-p
2851 (match-beginning 0) (match-end 0))
2852 (delete-region (match-beginning 1) (match-end 1)))))))
2854 (defun article-strip-leading-space ()
2855 "Remove all white space from the beginning of the lines in the article."
2858 (let ((inhibit-point-motion-hooks t)
2859 (inhibit-read-only t))
2861 (while (re-search-forward "^[ \t]+" nil t)
2862 (replace-match "" t t)))))
2864 (defun article-strip-trailing-space ()
2865 "Remove all white space from the end of the lines in the article."
2868 (let ((inhibit-point-motion-hooks t)
2869 (inhibit-read-only t))
2871 (while (re-search-forward "[ \t]+$" nil t)
2872 (replace-match "" t t)))))
2874 (defun article-strip-blank-lines ()
2875 "Strip leading, trailing and multiple blank lines."
2877 (article-strip-leading-blank-lines)
2878 (article-remove-trailing-blank-lines)
2879 (article-strip-multiple-blank-lines))
2881 (defun article-strip-all-blank-lines ()
2882 "Strip all blank lines."
2885 (let ((inhibit-point-motion-hooks t)
2886 (inhibit-read-only t))
2888 (while (re-search-forward "^[ \t]*\n" nil t)
2889 (replace-match "" t t)))))
2891 (defun gnus-article-narrow-to-signature ()
2892 "Narrow to the signature; return t if a signature is found, else nil."
2893 (let ((inhibit-point-motion-hooks t))
2894 (when (gnus-article-search-signature)
2896 ;; Check whether we have some limits to what we consider
2897 ;; to be a signature.
2898 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2899 (list gnus-signature-limit)))
2901 (while (setq limit (pop limits))
2902 (if (or (and (integerp limit)
2903 (< (- (point-max) (point)) limit))
2905 (< (count-lines (point) (point-max)) limit))
2906 (and (functionp limit)
2908 (and (stringp limit)
2909 (not (re-search-forward limit nil t))))
2910 () ; This limit did not succeed.
2914 (narrow-to-region (point) (point-max))
2917 (defun gnus-article-search-signature ()
2918 "Search the current buffer for the signature separator.
2919 Put point at the beginning of the signature separator."
2920 (let ((cur (point)))
2921 (goto-char (point-max))
2922 (if (if (stringp gnus-signature-separator)
2923 (re-search-backward gnus-signature-separator nil t)
2924 (let ((seps gnus-signature-separator))
2926 (not (re-search-backward (car seps) nil t)))
2933 (defun gnus-article-hidden-arg ()
2934 "Return the current prefix arg as a number, or 0 if no prefix."
2935 (list (if current-prefix-arg
2936 (prefix-numeric-value current-prefix-arg)
2939 (defun gnus-article-check-hidden-text (type arg)
2940 "Return nil if hiding is necessary.
2941 Arg can be nil or a number. nil and positive means hide, negative
2942 means show, 0 means toggle."
2945 (let ((hide (gnus-article-hidden-text-p type)))
2951 (gnus-article-show-hidden-text type)
2954 (if (eq hide 'hidden)
2956 (gnus-article-show-hidden-text type)
2960 (defun gnus-article-hidden-text-p (type)
2961 "Say whether the current buffer contains hidden text of type TYPE."
2962 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2964 (not (get-text-property pos 'invisible))
2965 (not (get-text-property pos 'dummy-invisible)))
2967 (text-property-any (1+ pos) (point-max) 'article-type type)))
2972 (defun gnus-article-show-hidden-text (type &optional dummy)
2973 "Show all hidden text of type TYPE.
2974 Originally it is hide instead of DUMMY."
2975 (let ((inhibit-read-only t)
2976 (inhibit-point-motion-hooks t))
2977 (gnus-remove-text-properties-when
2979 (point-min) (point-max)
2980 (cons 'article-type (cons type
2981 gnus-hidden-properties)))
2982 (gnus-delete-wash-type type)))
2984 (defconst article-time-units
2985 `((year . ,(* 365.25 24 60 60))
2986 (week . ,(* 7 24 60 60))
2987 (day . ,(* 24 60 60))
2991 "Mapping from time units to seconds.")
2993 (defun gnus-article-forward-header ()
2994 "Move point to the start of the next header.
2995 If the current header is a continuation header, this can be several
3000 (if (looking-at "[ \t]+[^ \t]")
3004 (defun article-date-ut (&optional type highlight header)
3005 "Convert DATE date to universal time in the current article.
3006 If TYPE is `local', convert to local time; if it is `lapsed', output
3007 how much time has lapsed since DATE. For `lapsed', the value of
3008 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
3009 should replace the \"Date:\" one, or should be added below it."
3010 (interactive (list 'ut t))
3011 (let* ((header (or header
3012 (and (eq 1 (point-min))
3013 (mail-header-date (save-excursion
3014 (set-buffer gnus-summary-buffer)
3015 gnus-current-headers)))
3016 (message-fetch-field "date")
3018 (date (if (vectorp header) (mail-header-date header)
3020 (inhibit-point-motion-hooks t)
3021 bface eface date-pos)
3022 (when (and date (not (string= date "")))
3025 (article-narrow-to-head)
3026 (when (or (and (eq type 'lapsed)
3027 gnus-article-date-lapsed-new-header
3028 ;; Attempt to get the face of X-Sent first.
3029 (re-search-forward "^X-Sent:[ \t]" nil t))
3030 (re-search-forward "^Date:[ \t]" nil t)
3031 ;; If Date is missing, try again for X-Sent.
3032 (re-search-forward "^X-Sent:[ \t]" nil t))
3033 (setq bface (get-text-property (point-at-bol) 'face)
3034 date (or (get-text-property (point-at-bol)
3037 eface (get-text-property (1- (point-at-eol))
3039 (let ((inhibit-read-only t))
3040 ;; Delete any old X-Sent headers.
3041 (when (setq date-pos
3042 (text-property-any (point-min) (point-max)
3043 'article-date-lapsed t))
3044 (goto-char (setq date-pos (set-marker (make-marker) date-pos)))
3045 (delete-region (match-beginning 0)
3046 (progn (forward-line 1) (point))))
3047 (goto-char (point-min))
3048 ;; Delete any old Date headers.
3049 (while (re-search-forward "^Date:[ \t]" nil t)
3051 (setq date-pos (match-beginning 0)))
3052 (unless (and (eq type 'lapsed)
3053 gnus-article-date-lapsed-new-header)
3054 (delete-region (match-beginning 0)
3055 (progn (message-next-header) (point)))))
3058 (goto-char date-pos)
3060 ;; Possibly, Date has been deleted.
3062 (when (and (eq type 'lapsed)
3063 gnus-article-date-lapsed-new-header
3064 (looking-at "Date:"))
3066 (goto-char (point-min)))
3067 (insert (article-make-date-line date type))
3068 (when (eq type 'lapsed)
3069 (put-text-property (point-at-bol) (point)
3070 'article-date-lapsed t))
3074 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
3075 (add-text-properties (match-beginning 1) (1+ (match-end 1))
3076 (list 'original-date date 'face bface))
3077 (put-text-property (match-beginning 2) (match-end 2)
3080 (defun article-make-date-line (date type)
3081 "Return a DATE line of TYPE."
3082 (unless (memq type '(local ut original user iso8601 lapsed english))
3083 (error "Unknown conversion type: %s" type))
3085 (let ((time (date-to-time date)))
3087 ;; Convert to the local timezone.
3089 (concat "Date: " (message-make-date time)))
3090 ;; Convert to Universal Time.
3095 (let* ((e (parse-time-string date))
3096 (tm (apply 'encode-time e))
3098 (ls (- (cadr tm) (car (current-time-zone time)))))
3099 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
3100 ((> ls 65535) (list (1+ ms) (- ls 65536)))
3104 ;; Get the original date from the article.
3105 ((eq type 'original)
3106 (concat "Date: " (if (string-match "\n+$" date)
3107 (substring date 0 (match-beginning 0))
3109 ;; Let the user define the format.
3111 (let ((format (or (condition-case nil
3112 (with-current-buffer gnus-summary-buffer
3113 gnus-article-time-format)
3115 gnus-article-time-format)))
3116 (if (functionp format)
3117 (funcall format time)
3118 (concat "Date: " (format-time-string format time)))))
3121 (let ((tz (car (current-time-zone time))))
3124 (format-time-string "%Y%m%dT%H%M%S" time)
3125 (format "%s%02d%02d"
3126 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
3127 (/ (% (abs tz) 3600) 60)))))
3128 ;; Do an X-Sent lapsed format.
3130 ;; If the date is seriously mangled, the timezone functions are
3131 ;; liable to bug out, so we ignore all errors.
3132 (let* ((now (current-time))
3133 (real-time (subtract-time now time))
3134 (real-sec (and real-time
3135 (+ (* (float (car real-time)) 65536)
3137 (sec (and real-time (abs real-sec)))
3147 ;; This is a bit convoluted, but basically we go
3148 ;; through the time units for years, weeks, etc,
3149 ;; and divide things to see whether that results
3150 ;; in positive answers.
3153 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
3154 ;; The (remaining) seconds are too few to
3155 ;; be divided into this time unit.
3157 ;; It's big enough, so we output it.
3158 (setq sec (- sec (* num (cdr unit))))
3160 (concat (if prev ", " "") (int-to-string
3162 " " (symbol-name (car unit))
3163 (if (> num 1) "s" ""))
3165 article-time-units "")
3166 ;; If dates are odd, then it might appear like the
3167 ;; article was sent in the future.
3170 " in the future"))))))
3171 ;; Display the date in proper English
3173 (let ((dtime (decode-time time)))
3176 (number-to-string (nth 3 dtime))
3177 (let ((digit (% (nth 3 dtime) 10)))
3179 ((memq (nth 3 dtime) '(11 12 13)) "th")
3185 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3187 (number-to-string (nth 5 dtime))
3189 (format "%02d" (nth 2 dtime))
3191 (format "%02d" (nth 1 dtime)))))))
3193 (format "Date: %s (from T-gnus)" date))))
3195 (defun article-date-local (&optional highlight)
3196 "Convert the current article date to the local timezone."
3197 (interactive (list t))
3198 (article-date-ut 'local highlight))
3200 (defun article-date-english (&optional highlight)
3201 "Convert the current article date to something that is proper English."
3202 (interactive (list t))
3203 (article-date-ut 'english highlight))
3205 (defun article-date-original (&optional highlight)
3206 "Convert the current article date to what it was originally.
3207 This is only useful if you have used some other date conversion
3208 function and want to see what the date was before converting."
3209 (interactive (list t))
3210 (article-date-ut 'original highlight))
3212 (defun article-date-lapsed (&optional highlight)
3213 "Convert the current article date to time lapsed since it was sent."
3214 (interactive (list t))
3215 (article-date-ut 'lapsed highlight))
3217 (defun article-update-date-lapsed ()
3218 "Function to be run from a timer to update the lapsed time line."
3219 (let (deactivate-mark)
3224 (set-buffer (window-buffer w))
3225 (when (eq major-mode 'gnus-article-mode)
3226 (let ((mark (point-marker)))
3227 (goto-char (point-min))
3228 (when (re-search-forward "^X-Sent:" nil t)
3229 (article-date-lapsed t))
3230 (goto-char (marker-position mark))
3231 (move-marker mark nil))))
3234 (defun gnus-start-date-timer (&optional n)
3235 "Start a timer to update the X-Sent header in the article buffers.
3236 The numerical prefix says how frequently (in seconds) the function
3241 (gnus-stop-date-timer)
3242 (setq article-lapsed-timer
3243 (run-at-time 1 n 'article-update-date-lapsed)))
3245 (defun gnus-stop-date-timer ()
3246 "Stop the X-Sent timer."
3248 (when article-lapsed-timer
3249 (nnheader-cancel-timer article-lapsed-timer)
3250 (setq article-lapsed-timer nil)))
3252 (defun article-date-user (&optional highlight)
3253 "Convert the current article date to the user-defined format.
3254 This format is defined by the `gnus-article-time-format' variable."
3255 (interactive (list t))
3256 (article-date-ut 'user highlight))
3258 (defun article-date-iso8601 (&optional highlight)
3259 "Convert the current article date to ISO8601."
3260 (interactive (list t))
3261 (article-date-ut 'iso8601 highlight))
3263 ;; (defun article-show-all ()
3264 ;; "Show all hidden text in the article buffer."
3268 ;; (let ((inhibit-read-only t))
3269 ;; (gnus-article-unhide-text (point-min) (point-max))
3270 ;; (gnus-remove-text-with-property 'gnus-prev)
3271 ;; (gnus-remove-text-with-property 'gnus-next))))
3273 (defun article-show-all-headers ()
3274 "Show all hidden headers in the article buffer."
3279 (article-narrow-to-head)
3280 (let ((inhibit-read-only t))
3281 (gnus-article-unhide-text (point-min) (point-max))))))
3283 (defun article-remove-leading-whitespace ()
3284 "Remove excessive whitespace from all headers."
3288 (let ((inhibit-read-only t))
3289 (article-narrow-to-head)
3290 (goto-char (point-min))
3291 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3292 (delete-region (match-beginning 1) (match-end 1)))))))
3294 (defun article-emphasize (&optional arg)
3295 "Emphasize text according to `gnus-emphasis-alist'."
3296 (interactive (gnus-article-hidden-arg))
3297 (unless (gnus-article-check-hidden-text 'emphasis arg)
3301 (with-current-buffer gnus-summary-buffer
3302 gnus-article-emphasis-alist)
3304 gnus-emphasis-alist))
3305 (inhibit-read-only t)
3306 (props (append '(article-type emphasis)
3307 gnus-hidden-properties))
3308 regexp elem beg invisible visible face)
3311 (while (setq elem (pop alist))
3313 (setq regexp (car elem)
3314 invisible (nth 1 elem)
3315 visible (nth 2 elem)
3317 (while (re-search-forward regexp nil t)
3318 (when (and (match-beginning visible) (match-beginning invisible))
3319 (gnus-article-hide-text
3320 (match-beginning invisible) (match-end invisible) props)
3321 (gnus-article-unhide-text-type
3322 (match-beginning visible) (match-end visible) 'emphasis)
3323 (gnus-put-overlay-excluding-newlines
3324 (match-beginning visible) (match-end visible) 'face face)
3325 (gnus-add-wash-type 'emphasis)
3326 (goto-char (match-end invisible)))))))))
3328 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3329 "Setup newsgroup emphasis alist."
3330 (unless gnus-article-emphasis-alist
3331 (let ((name (and gnus-newsgroup-name
3332 (gnus-group-real-name gnus-newsgroup-name))))
3333 (make-local-variable 'gnus-article-emphasis-alist)
3334 (setq gnus-article-emphasis-alist
3336 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3337 (while (setq elem (pop alist))
3338 (when (and name (string-match (car elem) name))
3340 highlight (copy-sequence (cdr elem)))))
3342 (copy-sequence highlight-words)
3343 (if gnus-newsgroup-name
3344 (copy-sequence (gnus-group-find-parameter
3345 gnus-newsgroup-name 'highlight-words t)))
3346 gnus-emphasis-alist)))))
3349 (defvar gnus-summary-article-menu)
3350 (defvar gnus-summary-post-menu))
3352 ;;; Saving functions.
3354 (defun gnus-article-save (save-buffer file &optional num)
3355 "Save the currently selected article."
3356 (unless gnus-save-all-headers
3357 ;; Remove headers according to `gnus-saved-headers'.
3358 (let ((gnus-visible-headers
3359 (or gnus-saved-headers gnus-visible-headers))
3360 (gnus-article-buffer save-buffer))
3362 (set-buffer save-buffer)
3363 (article-hide-headers 1 t))))
3364 (save-window-excursion
3365 (if (not gnus-default-article-saver)
3366 (error "No default saver is defined")
3367 ;; !!! Magic! The saving functions all save
3368 ;; `gnus-save-article-buffer' (or so they think), but we
3369 ;; bind that variable to our save-buffer.
3370 (set-buffer gnus-article-buffer)
3371 (let* ((gnus-save-article-buffer save-buffer)
3374 ((not gnus-prompt-before-saving) 'default)
3375 ((eq gnus-prompt-before-saving 'always) nil)
3377 (gnus-number-of-articles-to-be-saved
3378 (when (eq gnus-prompt-before-saving t)
3380 (set-buffer gnus-article-current-summary)
3381 (funcall gnus-default-article-saver filename)))))
3383 (defun gnus-read-save-file-name (prompt &optional filename
3384 function group headers variable)
3386 (funcall function group headers (symbol-value variable)))
3391 ((eq filename 'default)
3397 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3400 (if (and gnus-number-of-articles-to-be-saved
3401 (> gnus-number-of-articles-to-be-saved 1))
3402 (format "these %d articles"
3403 gnus-number-of-articles-to-be-saved)
3406 ;; Let the split methods have their say.
3408 ;; No split name was found.
3411 (concat prompt " (default "
3412 (file-name-nondirectory default-name) ") ")
3413 (file-name-directory default-name)
3415 ;; A single group name is returned.
3416 ((stringp split-name)
3418 (funcall function split-name headers
3419 (symbol-value variable)))
3421 (concat prompt " (default "
3422 (file-name-nondirectory default-name) ") ")
3423 (file-name-directory default-name)
3425 ;; A single split name was found
3426 ((= 1 (length split-name))
3427 (let* ((name (expand-file-name
3429 gnus-article-save-directory))
3430 (dir (cond ((file-directory-p name)
3431 (file-name-as-directory name))
3432 ((file-exists-p name) name)
3433 (t gnus-article-save-directory))))
3435 (concat prompt " (default " name ") ")
3437 ;; A list of splits was found.
3439 (setq split-name (nreverse split-name))
3441 (let ((file-name-history
3442 (nconc split-name file-name-history)))
3446 (concat prompt " (`M-p' for defaults) ")
3447 gnus-article-save-directory
3449 gnus-article-save-directory)))
3450 (car (push result file-name-history)))))))
3451 ;; Create the directory.
3452 (gnus-make-directory (file-name-directory file))
3453 ;; If we have read a directory, we append the default file name.
3454 (when (file-directory-p file)
3455 (setq file (expand-file-name (file-name-nondirectory
3457 (file-name-as-directory file))))
3458 ;; Possibly translate some characters.
3459 (nnheader-translate-file-chars file))))))
3460 (gnus-make-directory (file-name-directory result))
3461 (set variable result)))
3463 (defun gnus-article-archive-name (group)
3464 "Return the first instance of an \"Archive-name\" in the current buffer."
3465 (let ((case-fold-search t))
3466 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3467 (nnheader-concat gnus-article-save-directory
3468 (match-string 1)))))
3470 (defun gnus-article-nndoc-name (group)
3471 "If GROUP is an nndoc group, return the name of the parent group."
3472 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3473 (gnus-group-get-parameter group 'save-article-group)))
3475 (defun gnus-summary-save-in-rmail (&optional filename)
3476 "Append this article to Rmail file.
3477 Optional argument FILENAME specifies file name.
3478 Directory to save to is default to `gnus-article-save-directory'."
3479 (setq filename (gnus-read-save-file-name
3480 "Save %s in rmail file:" filename
3481 gnus-rmail-save-name gnus-newsgroup-name
3482 gnus-current-headers 'gnus-newsgroup-last-rmail))
3483 (gnus-eval-in-buffer-window gnus-save-article-buffer
3487 (gnus-output-to-rmail filename))))
3490 (defun gnus-summary-save-in-mail (&optional filename)
3491 "Append this article to Unix mail file.
3492 Optional argument FILENAME specifies file name.
3493 Directory to save to is default to `gnus-article-save-directory'."
3494 (setq filename (gnus-read-save-file-name
3495 "Save %s in Unix mail file:" filename
3496 gnus-mail-save-name gnus-newsgroup-name
3497 gnus-current-headers 'gnus-newsgroup-last-mail))
3498 (gnus-eval-in-buffer-window gnus-save-article-buffer
3502 (if (and (file-readable-p filename)
3503 (file-regular-p filename)
3504 (mail-file-babyl-p filename))
3505 (rmail-output-to-rmail-file filename t)
3506 (gnus-output-to-mail filename)))))
3509 (defun gnus-summary-save-in-file (&optional filename overwrite)
3510 "Append this article to file.
3511 Optional argument FILENAME specifies file name.
3512 Directory to save to is default to `gnus-article-save-directory'."
3513 (setq filename (gnus-read-save-file-name
3514 "Save %s in file:" filename
3515 gnus-file-save-name gnus-newsgroup-name
3516 gnus-current-headers 'gnus-newsgroup-last-file))
3517 (gnus-eval-in-buffer-window gnus-save-article-buffer
3521 (when (and overwrite
3522 (file-exists-p filename))
3523 (delete-file filename))
3524 (gnus-output-to-file filename))))
3527 (defun gnus-summary-write-to-file (&optional filename)
3528 "Write this article to a file, overwriting it if the file exists.
3529 Optional argument FILENAME specifies file name.
3530 The directory to save in defaults to `gnus-article-save-directory'."
3531 (gnus-summary-save-in-file nil t))
3533 (defun gnus-summary-save-body-in-file (&optional filename)
3534 "Append this article body to a file.
3535 Optional argument FILENAME specifies file name.
3536 The directory to save in defaults to `gnus-article-save-directory'."
3537 (setq filename (gnus-read-save-file-name
3538 "Save %s body in file:" filename
3539 gnus-file-save-name gnus-newsgroup-name
3540 gnus-current-headers 'gnus-newsgroup-last-file))
3541 (gnus-eval-in-buffer-window gnus-save-article-buffer
3545 (when (article-goto-body)
3546 (narrow-to-region (point) (point-max)))
3547 (gnus-output-to-file filename))))
3550 (defun gnus-summary-save-in-pipe (&optional command)
3551 "Pipe this article to subprocess."
3553 (cond ((and (eq command 'default)
3554 gnus-last-shell-command)
3555 gnus-last-shell-command)
3560 "Shell command on %s: "
3561 (if (and gnus-number-of-articles-to-be-saved
3562 (> gnus-number-of-articles-to-be-saved 1))
3563 (format "these %d articles"
3564 gnus-number-of-articles-to-be-saved)
3566 gnus-last-shell-command))))
3567 (when (string-equal command "")
3568 (if gnus-last-shell-command
3569 (setq command gnus-last-shell-command)
3570 (error "A command is required")))
3571 (gnus-eval-in-buffer-window gnus-article-buffer
3574 (shell-command-on-region (point-min) (point-max) command nil)))
3575 (setq gnus-last-shell-command command))
3577 (defun gnus-summary-pipe-to-muttprint (&optional command)
3578 "Pipe this article to muttprint."
3579 (setq command (read-string
3580 "Print using command: " gnus-summary-muttprint-program
3581 nil gnus-summary-muttprint-program))
3582 (gnus-summary-save-in-pipe command))
3584 ;;; Article file names when saving.
3586 (defun gnus-capitalize-newsgroup (newsgroup)
3587 "Capitalize NEWSGROUP name."
3588 (when (not (zerop (length newsgroup)))
3589 (concat (char-to-string (upcase (aref newsgroup 0)))
3590 (substring newsgroup 1))))
3592 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3593 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3594 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3595 Otherwise, it is like ~/News/news/group/num."
3598 (concat (if (gnus-use-long-file-name 'not-save)
3599 (gnus-capitalize-newsgroup newsgroup)
3600 (gnus-newsgroup-directory-form newsgroup))
3601 "/" (int-to-string (mail-header-number headers)))
3602 gnus-article-save-directory)))
3604 (string-equal (file-name-directory default)
3605 (file-name-directory last-file))
3606 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3608 (or last-file default))))
3610 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3611 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3612 If variable `gnus-use-long-file-name' is non-nil, it is
3613 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3616 (concat (if (gnus-use-long-file-name 'not-save)
3618 (gnus-newsgroup-directory-form newsgroup))
3619 "/" (int-to-string (mail-header-number headers)))
3620 gnus-article-save-directory)))
3622 (string-equal (file-name-directory default)
3623 (file-name-directory last-file))
3624 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3626 (or last-file default))))
3628 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3629 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3630 If variable `gnus-use-long-file-name' is non-nil, it is
3631 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3634 (if (gnus-use-long-file-name 'not-save)
3637 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3639 gnus-article-save-directory)))
3641 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3642 "Generate file name from sender."
3643 (let ((from (mail-header-from headers)))
3645 (if (and from (string-match "\\([^ <]+\\)@" from))
3646 (match-string 1 from)
3648 gnus-article-save-directory)))
3650 (defun article-verify-x-pgp-sig ()
3653 (if (gnus-buffer-live-p gnus-original-article-buffer)
3654 (let ((sig (with-current-buffer gnus-original-article-buffer
3655 (gnus-fetch-field "X-PGP-Sig")))
3659 (mml2015-clear-verify-function))
3661 (insert-buffer-substring gnus-original-article-buffer)
3662 (setq items (split-string sig))
3663 (message-narrow-to-head)
3664 (let ((inhibit-point-motion-hooks t)
3665 (case-fold-search t))
3666 ;; Don't verify multiple headers.
3667 (setq headers (mapconcat (lambda (header)
3669 (mail-fetch-field header)
3671 (split-string (nth 1 items) ",") "")))
3672 (delete-region (point-min) (point-max))
3673 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3674 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3679 (if (looking-at "^-")
3682 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3683 (insert "Version: " (car items) "\n\n")
3684 (insert (mapconcat 'identity (cddr items) "\n"))
3685 (insert "\n-----END PGP SIGNATURE-----\n")
3686 (let ((mm-security-handle (list (format "multipart/signed"))))
3687 (mml2015-clean-buffer)
3688 (let ((coding-system-for-write (or gnus-newsgroup-charset
3690 (funcall (mml2015-clear-verify-function)))
3692 (or (mm-handle-multipart-ctl-parameter
3693 mm-security-handle 'gnus-details)
3694 (mm-handle-multipart-ctl-parameter
3695 mm-security-handle 'gnus-info)))))
3697 (let ((inhibit-read-only t) bface eface)
3699 (message-narrow-to-head)
3700 (goto-char (point-max))
3702 (setq bface (get-text-property (point-at-bol) 'face)
3703 eface (get-text-property (1- (point-at-eol)) 'face))
3704 (message-remove-header "X-Gnus-PGP-Verify")
3705 (if (re-search-forward "^X-PGP-Sig:" nil t)
3707 (goto-char (point-max)))
3708 (narrow-to-region (point) (point))
3709 (insert "X-Gnus-PGP-Verify: " info "\n")
3710 (goto-char (point-min))
3713 (if (not (looking-at "^[ \t]"))
3717 (goto-char (point-min))
3718 (when (looking-at "\\([^:]+\\): *")
3719 (put-text-property (match-beginning 1) (1+ (match-end 1))
3721 (put-text-property (match-end 0) (point-max)
3722 'face eface)))))))))
3724 (defun article-verify-cancel-lock ()
3725 "Verify Cancel-Lock header."
3727 (if (gnus-buffer-live-p gnus-original-article-buffer)
3728 (canlock-verify gnus-original-article-buffer)))
3730 (defun article-monafy ()
3731 "Display body part with mona font."
3733 (unless (if (featurep 'xemacs)
3734 (find-face 'gnus-mona-face)
3735 (facep 'gnus-mona-face))
3736 (require 'navi2ch-mona)
3737 (set-face-font (make-face 'gnus-mona-face) navi2ch-mona-font))
3739 (let ((inhibit-read-only t))
3742 (gnus-make-overlay (point) (point-max))
3743 'face 'gnus-mona-face))))
3750 (setq afunc (car func)
3753 gfunc (intern (format "gnus-%s" func))))
3755 (when (fboundp afunc)
3756 `(lambda (&optional interactive &rest args)
3757 ,(documentation afunc t)
3758 (interactive (list t))
3760 (set-buffer gnus-article-buffer)
3762 (call-interactively ',afunc)
3763 (apply ',afunc args))))))))
3764 '(article-hide-headers
3765 article-verify-x-pgp-sig
3766 article-verify-cancel-lock
3768 article-hide-boring-headers
3769 article-treat-overstrike
3770 article-treat-ansi-sequences
3771 article-fill-long-lines
3772 article-capitalize-sentences
3774 article-remove-leading-whitespace
3775 article-display-x-face
3776 article-display-face
3777 article-de-quoted-unreadable
3778 article-de-base64-unreadable
3781 article-unsplit-urls
3782 article-hide-list-identifiers
3783 article-strip-banner
3786 article-hide-signature
3787 article-strip-headers-in-body
3788 article-remove-trailing-blank-lines
3789 article-strip-leading-blank-lines
3790 article-strip-multiple-blank-lines
3791 article-strip-leading-space
3792 article-strip-trailing-space
3793 article-strip-blank-lines
3794 article-strip-all-blank-lines
3796 article-date-english
3797 article-date-iso8601
3798 article-date-original
3800 article-decode-mime-words
3801 article-decode-charset
3802 article-decode-encoded-words
3806 article-treat-dumbquotes
3807 article-normalize-headers
3808 (article-show-all-headers . gnus-article-show-all-headers)
3809 ;; (article-show-all . gnus-article-show-all)
3813 ;;; Gnus article mode
3816 (put 'gnus-article-mode 'mode-class 'special)
3818 (gnus-define-keys gnus-article-mode-map
3819 " " gnus-article-goto-next-page
3820 "\177" gnus-article-goto-prev-page
3821 [delete] gnus-article-goto-prev-page
3822 [backspace] gnus-article-goto-prev-page
3823 "\C-c^" gnus-article-refer-article
3824 "h" gnus-article-show-summary
3825 "s" gnus-article-show-summary
3826 "\C-c\C-m" gnus-article-mail
3827 "?" gnus-article-describe-briefly
3828 "e" gnus-summary-edit-article
3829 "<" beginning-of-buffer
3831 "\C-c\C-i" gnus-info-find-node
3833 "R" gnus-article-reply-with-original
3834 "F" gnus-article-followup-with-original
3835 "\C-hk" gnus-article-describe-key
3836 "\C-hc" gnus-article-describe-key-briefly
3838 "\C-d" gnus-article-read-summary-keys
3839 "\M-*" gnus-article-read-summary-keys
3840 "\M-#" gnus-article-read-summary-keys
3841 "\M-^" gnus-article-read-summary-keys
3842 "\M-g" gnus-article-read-summary-keys)
3844 ;; Define almost undefined keys to `gnus-article-read-summary-keys'.
3848 (push (char-to-string key) keys)
3850 (dolist (elem (accessible-keymaps gnus-summary-mode-map))
3851 (setq key (car elem))
3852 (when (and (> (length key) 0)
3853 (not (eq 'menu-bar (aref key 0)))
3854 (symbolp (lookup-key gnus-summary-mode-map key)))
3857 (unless (lookup-key gnus-article-mode-map key)
3858 (define-key gnus-article-mode-map key 'gnus-article-read-summary-keys))))
3860 (defun gnus-article-make-menu-bar ()
3861 (unless (boundp 'gnus-article-commands-menu)
3862 (gnus-summary-make-menu-bar))
3863 (gnus-turn-off-edit-menu 'article)
3864 (unless (boundp 'gnus-article-article-menu)
3866 gnus-article-article-menu gnus-article-mode-map ""
3868 ["Scroll forwards" gnus-article-goto-next-page t]
3869 ["Scroll backwards" gnus-article-goto-prev-page t]
3870 ["Show summary" gnus-article-show-summary t]
3871 ["Fetch Message-ID at point" gnus-article-refer-article t]
3872 ["Mail to address at point" gnus-article-mail t]
3873 ["Send a bug report" gnus-bug t]))
3876 gnus-article-treatment-menu gnus-article-mode-map ""
3877 ;; Fixme: this should use :active (and maybe :visible).
3879 ["Hide headers" gnus-article-hide-headers t]
3880 ["Hide signature" gnus-article-hide-signature t]
3881 ["Hide citation" gnus-article-hide-citation t]
3882 ["Treat overstrike" gnus-article-treat-overstrike t]
3883 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
3884 ["Remove carriage return" gnus-article-remove-cr t]
3885 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3886 ["Treat html" gnus-article-wash-html t]
3887 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3888 ["Decode HZ" gnus-article-decode-HZ t]))
3890 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3892 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3894 (gnus-run-hooks 'gnus-article-menu-hook)))
3896 (defun gnus-article-mode ()
3897 "Major mode for displaying an article.
3899 All normal editing commands are switched off.
3901 The following commands are available in addition to all summary mode
3903 \\<gnus-article-mode-map>
3904 \\[gnus-article-next-page]\t Scroll the article one page forwards
3905 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3906 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3907 \\[gnus-article-show-summary]\t Display the summary buffer
3908 \\[gnus-article-mail]\t Send a reply to the address near point
3909 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3910 \\[gnus-info-find-node]\t Go to the Gnus info node"
3912 (gnus-simplify-mode-line)
3913 (setq mode-name "Article")
3914 (setq major-mode 'gnus-article-mode)
3915 (make-local-variable 'minor-mode-alist)
3916 (unless (assq 'gnus-show-mime minor-mode-alist)
3917 (push (list 'gnus-show-mime " MIME") minor-mode-alist))
3918 (use-local-map gnus-article-mode-map)
3919 (when (gnus-visual-p 'article-menu 'menu)
3920 (gnus-article-make-menu-bar)
3921 (when gnus-summary-tool-bar-map
3922 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3923 (gnus-update-format-specifications nil 'article-mode)
3924 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3925 (set (make-local-variable 'gnus-page-broken) nil)
3926 (make-local-variable 'gnus-button-marker-list)
3927 (make-local-variable 'gnus-article-current-summary)
3928 (make-local-variable 'gnus-article-mime-handles)
3929 (make-local-variable 'gnus-article-decoded-p)
3930 (make-local-variable 'gnus-article-mime-handle-alist)
3931 (make-local-variable 'gnus-article-wash-types)
3932 (make-local-variable 'gnus-article-image-alist)
3933 (make-local-variable 'gnus-article-charset)
3934 (make-local-variable 'gnus-article-ignored-charsets)
3935 (gnus-set-default-directory)
3936 (buffer-disable-undo)
3937 (setq buffer-read-only t
3938 show-trailing-whitespace nil)
3939 (set-syntax-table gnus-article-mode-syntax-table)
3940 (gnus-run-hooks 'gnus-article-mode-hook))
3942 (defun gnus-article-setup-buffer ()
3943 "Initialize the article buffer."
3944 (let* ((name (if gnus-single-article-buffer "*Article*"
3945 (concat "*Article " gnus-newsgroup-name "*")))
3947 (progn (string-match "\\*Article" name)
3948 (concat " *Original Article"
3949 (substring name (match-end 0))))))
3950 (setq gnus-article-buffer name)
3951 (setq gnus-original-article-buffer original)
3952 (setq gnus-article-mime-handle-alist nil)
3953 ;; This might be a variable local to the summary buffer.
3954 (unless gnus-single-article-buffer
3956 (set-buffer gnus-summary-buffer)
3957 (setq gnus-article-buffer name)
3958 (setq gnus-original-article-buffer original)
3959 (gnus-set-global-variables)))
3960 (gnus-article-setup-highlight-words)
3961 ;; Init original article buffer.
3963 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3964 (set-buffer-multibyte t)
3965 (setq major-mode 'gnus-original-article-mode)
3966 (make-local-variable 'gnus-original-article))
3967 (if (get-buffer name)
3970 (when (and gnus-article-edit-mode
3973 (y-or-n-p "Article mode edit in progress; discard? ")))
3974 (error "Action aborted"))
3975 (set (make-local-variable 'gnus-article-edit-mode) nil)
3976 (buffer-disable-undo)
3977 (setq buffer-read-only t)
3978 ;; This list just keeps growing if we don't reset it.
3979 (setq gnus-button-marker-list nil)
3980 (unless (eq major-mode 'gnus-article-mode)
3981 (gnus-article-mode))
3984 (set-buffer (gnus-get-buffer-create name))
3986 (make-local-variable 'gnus-summary-buffer)
3987 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3988 (current-buffer)))))
3990 ;; Set article window start at LINE, where LINE is the number of lines
3991 ;; from the head of the article.
3992 (defun gnus-article-set-window-start (&optional line)
3994 (gnus-get-buffer-window gnus-article-buffer t)
3996 (set-buffer gnus-article-buffer)
3997 (goto-char (point-min))
4000 (gnus-message 6 "Moved to bookmark")
4001 (search-forward "\n\n" nil t)
4005 ;;; @@ article filters
4008 (defun gnus-article-display-mime-message ()
4009 "Article display method for MIME message."
4010 ;; called from `gnus-original-article-buffer'.
4011 (let (charset all-headers)
4012 (with-current-buffer gnus-summary-buffer
4013 (setq charset default-mime-charset
4014 all-headers gnus-have-all-headers))
4015 (make-local-variable 'default-mime-charset)
4016 (setq default-mime-charset charset)
4017 (with-current-buffer (get-buffer-create gnus-article-buffer)
4018 (make-local-variable 'default-mime-charset)
4019 (setq default-mime-charset charset))
4020 (mime-display-message mime-message-structure
4021 gnus-article-buffer nil gnus-article-mode-map)
4023 (gnus-article-hide-headers nil -1)))
4024 (run-hooks 'gnus-mime-article-prepare-hook))
4026 (defun gnus-article-display-traditional-message ()
4027 "Article display method for traditional message."
4028 (set-buffer gnus-article-buffer)
4029 (let ((inhibit-read-only t))
4031 (insert-buffer-substring gnus-original-article-buffer)))
4033 (defun gnus-article-make-full-mail-header (&optional number charset)
4034 "Create a new mail header structure in a raw article buffer."
4035 (unless (and number charset)
4036 (save-current-buffer
4037 (set-buffer gnus-summary-buffer)
4039 (setq number (or (cdr gnus-article-current) 0)))
4041 (setq charset (or default-mime-charset 'x-ctext)))))
4042 (goto-char (point-min))
4043 (let ((header-end (if (search-forward "\n\n" nil t)
4045 (goto-char (point-max))))
4046 (chars (- (point-max) (point)))
4047 (lines (count-lines (point) (point-max)))
4048 (default-mime-charset charset)
4050 (narrow-to-region (point-min) header-end)
4051 (setq xref (std11-fetch-field "xref"))
4053 (make-full-mail-header
4055 (std11-fetch-field "subject")
4056 (std11-fetch-field "from")
4057 (std11-fetch-field "date")
4058 (std11-fetch-field "message-id")
4059 (std11-fetch-field "references")
4062 (when xref (concat "Xref: " xref)))
4065 (defun gnus-article-prepare (article &optional all-headers header)
4066 "Prepare ARTICLE in article mode buffer.
4067 ARTICLE should either be an article number or a Message-ID.
4068 If ARTICLE is an id, HEADER should be the article headers.
4069 If ALL-HEADERS is non-nil, no headers are hidden."
4071 ;; Make sure we start in a summary buffer.
4072 (unless (eq major-mode 'gnus-summary-mode)
4073 (set-buffer gnus-summary-buffer))
4074 (setq gnus-summary-buffer (current-buffer))
4075 (let* ((gnus-article (if header (mail-header-number header) article))
4076 (summary-buffer (current-buffer))
4077 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
4078 (group gnus-newsgroup-name)
4081 (gnus-article-setup-buffer)
4082 (set-buffer gnus-article-buffer)
4083 ;; Deactivate active regions.
4084 (when (and (boundp 'transient-mark-mode)
4085 transient-mark-mode)
4086 (setq mark-active nil))
4087 (if (not (setq result (let ((inhibit-read-only t))
4088 (gnus-request-article-this-buffer
4090 ;; There is no such article.
4092 (when (and (numberp article)
4093 (not (memq article gnus-newsgroup-sparse)))
4094 (setq gnus-article-current
4095 (cons gnus-newsgroup-name article))
4096 (set-buffer gnus-summary-buffer)
4097 (setq gnus-current-article article)
4098 (if (and (memq article gnus-newsgroup-undownloaded)
4099 (not (gnus-online (gnus-find-method-for-group
4100 gnus-newsgroup-name))))
4102 (gnus-summary-set-agent-mark article)
4103 (message "Message marked for downloading"))
4104 (gnus-summary-mark-article article gnus-canceled-mark)
4105 (unless (memq article gnus-newsgroup-sparse)
4106 (gnus-error 1 "No such article (may have expired or been canceled)")))))
4107 (if (or (eq result 'pseudo)
4108 (eq result 'nneething))
4111 (set-buffer summary-buffer)
4112 (push article gnus-newsgroup-history)
4113 (setq gnus-last-article gnus-current-article
4114 gnus-current-article 0
4115 gnus-current-headers nil
4116 gnus-article-current nil)
4117 (if (eq result 'nneething)
4118 (gnus-configure-windows 'summary)
4119 (gnus-configure-windows 'article))
4120 (gnus-set-global-variables))
4121 (let ((gnus-article-mime-handle-alist-1
4122 gnus-article-mime-handle-alist))
4123 (gnus-set-mode-line 'article)))
4124 ;; The result from the `request' was an actual article -
4125 ;; or at least some text that is now displayed in the
4127 (when (and (numberp article)
4128 (not (eq article gnus-current-article)))
4129 ;; Seems like a new article has been selected.
4130 ;; `gnus-current-article' must be an article number.
4132 (set-buffer summary-buffer)
4133 (push article gnus-newsgroup-history)
4134 (setq gnus-last-article gnus-current-article
4135 gnus-current-article article
4136 gnus-current-headers
4137 (gnus-summary-article-header gnus-current-article)
4138 gnus-article-current
4139 (cons gnus-newsgroup-name gnus-current-article))
4140 (unless (vectorp gnus-current-headers)
4141 (setq gnus-current-headers nil))
4142 (gnus-summary-goto-subject gnus-current-article)
4143 (when (gnus-summary-show-thread)
4144 ;; If the summary buffer really was folded, the
4145 ;; previous goto may not actually have gone to
4146 ;; the right article, but the thread root instead.
4148 (gnus-summary-goto-subject gnus-current-article))
4149 (gnus-run-hooks 'gnus-mark-article-hook)
4150 (gnus-set-mode-line 'summary)
4151 (when (gnus-visual-p 'article-highlight 'highlight)
4152 (gnus-run-hooks 'gnus-visual-mark-article-hook))
4153 ;; Set the global newsgroup variables here.
4154 (gnus-set-global-variables)
4155 (setq gnus-have-all-headers
4156 (or all-headers gnus-show-all-headers))))
4158 (gnus-configure-windows 'article))
4159 (when (or (numberp article)
4161 (gnus-article-prepare-display)
4163 (goto-char (point-min))
4164 (when gnus-break-pages
4165 (gnus-narrow-to-page)))
4166 (let ((gnus-article-mime-handle-alist-1
4167 gnus-article-mime-handle-alist))
4168 (gnus-set-mode-line 'article))
4172 (set-window-point (get-buffer-window (current-buffer)) (point))
4173 (gnus-configure-windows 'article)
4176 (defun gnus-article-prepare-mime-display (&optional number)
4177 (goto-char (point-min))
4178 (when (re-search-forward "^[^\t ]+:" nil t)
4179 (goto-char (match-beginning 0)))
4180 (let ((entity (if (eq 1 (point-min))
4181 (get-text-property 1 'mime-view-entity)
4182 (get-text-property (point) 'mime-view-entity)))
4183 last-entity child-entity next type)
4184 (setq child-entity (mime-entity-children entity))
4186 (setq last-entity (nth (1- (length child-entity))
4188 (setq last-entity entity))
4190 (narrow-to-region (point)
4191 (if (search-forward "\n\n" nil t)
4194 (gnus-treat-article 'head)
4195 (put-text-property (point-min) (point-max) 'article-treated-header t)
4196 (goto-char (point-max)))
4197 (while (and (not (eobp)) entity)
4198 (setq next (set-marker
4200 (next-single-property-change (point) 'mime-view-entity
4202 (let ((types (mime-entity-content-type entity)))
4203 (while (eq 'multipart (mime-content-type-primary-type types))
4204 (setq entity (car (mime-entity-children entity))
4205 types (mime-entity-content-type entity)))
4207 (setq type (format "%s/%s"
4208 (mime-content-type-primary-type types)
4209 (mime-content-type-subtype types)))))
4210 (if (string-equal type "message/rfc822")
4213 (let ((children (mime-entity-children entity))
4216 (setq last-children (nth (1- (length children)) children))
4219 (not (eq last-children
4220 (get-text-property next 'mime-view-entity)))
4222 (next-single-property-change next
4224 nil (point-max)))))))
4225 (setq next (next-single-property-change next 'mime-view-entity
4228 (narrow-to-region (point) next)
4229 (gnus-article-prepare-mime-display)
4230 (goto-char (point-max)))
4231 (setq entity (get-text-property (point) 'mime-view-entity)))
4233 (narrow-to-region (point) next)
4234 ;; Kludge. We have to count true number, but for now,
4235 ;; part number is here only to achieve `last'.
4236 (gnus-treat-article nil 1
4237 (if (eq entity last-entity)
4240 (goto-char (point-max)))
4241 (setq entity (get-text-property next 'mime-view-entity))))))
4244 (defun gnus-article-prepare-display ()
4245 "Make the current buffer look like a nice article."
4246 (let ((gnus-article-buffer (current-buffer))
4248 (inhibit-read-only t))
4249 (unless (eq major-mode 'gnus-article-mode)
4250 (gnus-article-mode))
4251 (setq buffer-read-only nil
4252 gnus-button-marker-list nil
4253 gnus-article-wash-types nil
4254 gnus-article-image-alist nil)
4257 (static-if (featurep 'xemacs)
4258 (map-extents (lambda (extent maparg) (delete-extent extent)))
4259 (let ((lists (overlay-lists)))
4260 (dolist (overlay (nconc (car lists) (cdr lists)))
4261 (delete-overlay overlay)))))
4262 (gnus-run-hooks 'gnus-tmp-internal-hook))
4263 (let ((show-mime (unless (member gnus-newsgroup-name '("nndraft:delayed"
4266 (inhibit-read-only t))
4267 (set-buffer gnus-original-article-buffer)
4269 (setq mime-message-structure gnus-current-headers)
4270 (mime-buffer-entity-set-buffer-internal mime-message-structure
4271 gnus-original-article-buffer)
4272 (mime-entity-set-representation-type-internal mime-message-structure
4273 'mime-buffer-entity)
4274 (luna-send mime-message-structure 'initialize-instance
4275 mime-message-structure)
4277 (let (mime-display-header-hook mime-display-text/plain-hook)
4278 (funcall gnus-article-display-method-for-mime))
4279 (funcall gnus-article-display-method-for-traditional))
4280 ;; Call the treatment functions.
4284 (gnus-article-prepare-mime-display)
4285 (narrow-to-region (goto-char (point-min))
4286 (if (search-forward "\n\n" nil t)
4289 (gnus-treat-article 'head)
4290 (put-text-property (point-min) (point-max) 'article-treated-header t)
4291 (goto-char (point-max))
4293 (narrow-to-region (point) (point-max))
4294 (gnus-treat-article nil))
4295 (put-text-property (point-min) (point-max) 'read-only nil)))
4296 (gnus-run-hooks 'gnus-article-prepare-hook))
4298 (defun gnus-article-decode-article-as-default-mime-charset ()
4299 "Decode an article as `default-mime-charset'. It won't work if the
4300 value of the variable `gnus-show-mime' is non-nil."
4301 (unless (or gnus-show-mime
4302 (member gnus-newsgroup-name '("nndraft:delayed"
4304 (set (make-local-variable 'default-mime-charset)
4305 (with-current-buffer gnus-summary-buffer
4306 default-mime-charset))
4307 (decode-mime-charset-region (point-min) (point-max)
4308 default-mime-charset)))
4311 ;;; Gnus MIME viewing functions
4314 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4315 "Format of the MIME buttons.
4317 Valid specifiers include:
4319 %T MIME type, along with additional info
4320 %n The `name' parameter
4321 %d The description, if any
4322 %l The length of the encoded part
4323 %p The part identifier number
4324 %e Dots if the part isn't displayed
4326 General format specifiers can also be used. See Info node
4327 `(gnus)Formatting Variables'.")
4329 (defvar gnus-mime-button-line-format-alist
4330 '((?t gnus-tmp-type ?s)
4331 (?T gnus-tmp-type-long ?s)
4332 (?n gnus-tmp-name ?s)
4333 (?d gnus-tmp-description ?s)
4335 (?l gnus-tmp-length ?d)
4336 (?e gnus-tmp-dots ?s)))
4338 (defvar gnus-mime-button-commands
4339 '((gnus-article-press-button "\r" "Toggle Display")
4340 (gnus-mime-view-part "v" "View Interactively...")
4341 (gnus-mime-view-part-as-type "t" "View As Type...")
4342 (gnus-mime-view-part-as-charset "C" "View As charset...")
4343 (gnus-mime-save-part "o" "Save...")
4344 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4345 (gnus-mime-delete-part "d" "Delete part")
4346 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4347 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4348 (gnus-mime-view-part-internally "E" "View Internally")
4349 (gnus-mime-view-part-externally "e" "View Externally")
4350 (gnus-mime-print-part "p" "Print")
4351 (gnus-mime-pipe-part "|" "Pipe To Command...")
4352 (gnus-mime-action-on-part "." "Take action on the part...")))
4354 (defun gnus-article-mime-part-status ()
4355 (with-current-buffer gnus-article-buffer
4356 (let ((entity (get-text-property (point-min) 'mime-view-entity))
4359 (setq children (mime-entity-children entity))
4360 (setq children (length children)))
4363 (format " (%d parts)" children))
4366 (defvar gnus-mime-button-map
4367 (let ((map (make-sparse-keymap)))
4368 (define-key map gnus-mouse-2 'gnus-article-push-button)
4369 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4370 (dolist (c gnus-mime-button-commands)
4371 (define-key map (cadr c) (car c)))
4375 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4377 ,@(mapcar (lambda (c)
4378 (vector (caddr c) (car c) :enable t))
4379 gnus-mime-button-commands)))
4381 (defun gnus-mime-button-menu (event prefix)
4382 "Construct a context-sensitive menu of MIME commands."
4383 (interactive "e\nP")
4384 (save-window-excursion
4385 (let ((pos (event-start event)))
4386 (select-window (posn-window pos))
4387 (goto-char (posn-point pos))
4388 (gnus-article-check-buffer)
4389 (popup-menu gnus-mime-button-menu nil prefix))))
4391 (defun gnus-mime-view-all-parts (&optional handles)
4392 "View all the MIME parts."
4394 (with-current-buffer gnus-article-buffer
4395 (let ((handles (or handles gnus-article-mime-handles))
4396 (mail-parse-charset gnus-newsgroup-charset)
4397 (mail-parse-ignored-charsets
4398 (with-current-buffer gnus-summary-buffer
4399 gnus-newsgroup-ignored-charsets)))
4401 (mm-remove-parts handles)
4402 (goto-char (point-min))
4403 (or (search-forward "\n\n") (goto-char (point-max)))
4404 (let ((inhibit-read-only t))
4405 (delete-region (point) (point-max))
4406 (mm-display-parts handles))))))
4409 (defsubst gnus-article-edit-part (handles)
4410 "Edit an article in order to delete a mime part.
4411 This function is exclusively used by `gnus-mime-save-part-and-strip'
4412 and `gnus-mime-delete-part', and not provided at run-time normally."
4413 (gnus-article-edit-article
4416 (let ((mail-parse-charset (or gnus-article-charset
4417 ',gnus-newsgroup-charset))
4418 (mail-parse-ignored-charsets
4419 (or gnus-article-ignored-charsets
4420 ',gnus-newsgroup-ignored-charsets))
4421 (mbl mml-buffer-list))
4422 (setq mml-buffer-list nil)
4423 (insert-buffer gnus-original-article-buffer)
4424 (mime-to-mml ',handles)
4425 (setq gnus-article-mime-handles nil)
4426 (let ((mbl1 mml-buffer-list))
4427 (setq mml-buffer-list mbl)
4428 (set (make-local-variable 'mml-buffer-list) mbl1))
4429 (gnus-make-local-hook 'kill-buffer-hook)
4430 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4431 `(lambda (no-highlight)
4432 (let ((mail-parse-charset (or gnus-article-charset
4433 ',gnus-newsgroup-charset))
4434 (message-options message-options)
4435 (message-options-set-recipient)
4436 (mail-parse-ignored-charsets
4437 (or gnus-article-ignored-charsets
4438 ',gnus-newsgroup-ignored-charsets)))
4440 (mml-destroy-buffers)
4441 (remove-hook 'kill-buffer-hook
4442 'mml-destroy-buffers t)
4443 (kill-local-variable 'mml-buffer-list))
4444 (gnus-summary-edit-article-done
4445 ,(or (mail-header-references gnus-current-headers) "")
4446 ,(gnus-group-read-only-p)
4447 ,gnus-summary-buffer no-highlight)))
4448 (gnus-article-edit-done)
4449 (gnus-summary-expand-window)
4450 (gnus-summary-show-article)))
4452 (defun gnus-mime-save-part-and-strip ()
4453 "Save the MIME part under point then replace it with an external body."
4455 (gnus-article-check-buffer)
4456 (when (gnus-group-read-only-p)
4457 (error "The current group does not support deleting of parts"))
4458 (when (mm-complicated-handles gnus-article-mime-handles)
4460 The current article has a complicated MIME structure, giving up..."))
4461 (when (gnus-yes-or-no-p "\
4462 Deleting parts may malfunction or destroy the article; continue? ")
4463 (let* ((data (get-text-property (point) 'gnus-data))
4465 (handles gnus-article-mime-handles))
4466 (setq file (and data (mm-save-part data)))
4468 (with-current-buffer (mm-handle-buffer data)
4470 (insert "Content-Type: " (mm-handle-media-type data))
4471 (mml-insert-parameter-string (cdr (mm-handle-type data))
4474 (insert "Content-ID: " (message-make-message-id) "\n")
4475 (insert "Content-Transfer-Encoding: binary\n")
4478 (cdr (mm-make-handle nil
4479 `("message/external-body"
4480 (access-type . "LOCAL-FILE")
4482 (set-buffer gnus-summary-buffer)
4483 (gnus-article-edit-part handles)))))
4485 (defun gnus-mime-delete-part ()
4486 "Delete the MIME part under point.
4487 Replace it with some information about the removed part."
4489 (gnus-article-check-buffer)
4490 (when (gnus-group-read-only-p)
4491 (error "The current group does not support deleting of parts"))
4492 (when (mm-complicated-handles gnus-article-mime-handles)
4494 The current article has a complicated MIME structure, giving up..."))
4495 (when (gnus-yes-or-no-p "\
4496 Deleting parts may malfunction or destroy the article; continue? ")
4497 (let* ((data (get-text-property (point) 'gnus-data))
4498 (handles gnus-article-mime-handles)
4502 (mail-decode-encoded-word-string (or (mm-handle-description data)
4505 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4507 (type (mm-handle-media-type data)))
4509 (error "No MIME part under point"))
4510 (with-current-buffer (mm-handle-buffer data)
4511 (let ((bsize (format "%s" (buffer-size))))
4516 "| The following attachment has been deleted:\n"
4518 "| Type: " type "\n"
4519 "| Filename: " filename "\n"
4520 "| Size (encoded): " bsize " Byte\n"
4521 "| Description: " description "\n"
4524 (cdr (mm-make-handle
4525 nil `("text/plain") nil nil
4527 (format "Deleted attachment (%s bytes)" bsize))))))
4528 (set-buffer gnus-summary-buffer)
4529 (gnus-article-edit-part handles))))
4531 (defun gnus-mime-save-part ()
4532 "Save the MIME part under point."
4534 (gnus-article-check-buffer)
4535 (let ((data (get-text-property (point) 'gnus-data)))
4537 (mm-save-part data))))
4539 (defun gnus-mime-pipe-part ()
4540 "Pipe the MIME part under point to a process."
4542 (gnus-article-check-buffer)
4543 (let ((data (get-text-property (point) 'gnus-data)))
4545 (mm-pipe-part data))))
4547 (defun gnus-mime-view-part ()
4548 "Interactively choose a viewing method for the MIME part under point."
4550 (gnus-article-check-buffer)
4551 (let ((data (get-text-property (point) 'gnus-data)))
4553 (setq gnus-article-mime-handles
4555 gnus-article-mime-handles (setq data (copy-sequence data))))
4556 (mm-interactively-view-part data))))
4558 (defun gnus-mime-view-part-as-type-internal ()
4559 (gnus-article-check-buffer)
4560 (let* ((name (mail-content-type-get
4561 (mm-handle-type (get-text-property (point) 'gnus-data))
4563 (def-type (and name (mm-default-file-encoding name))))
4564 (and def-type (cons def-type 0))))
4566 (defun gnus-mime-view-part-as-type (&optional mime-type)
4567 "Choose a MIME media type, and view the part as such."
4570 (setq mime-type (completing-read
4571 "View as MIME type: "
4572 (mapcar #'list (mailcap-mime-types))
4574 (gnus-mime-view-part-as-type-internal))))
4575 (gnus-article-check-buffer)
4576 (let ((handle (get-text-property (point) 'gnus-data)))
4579 (mm-make-handle (mm-handle-buffer handle)
4580 (cons mime-type (cdr (mm-handle-type handle)))
4581 (mm-handle-encoding handle)
4582 (mm-handle-undisplayer handle)
4583 (mm-handle-disposition handle)
4584 (mm-handle-description handle)
4586 (mm-handle-id handle)))
4587 (setq gnus-article-mime-handles
4588 (mm-merge-handles gnus-article-mime-handles handle))
4589 (gnus-mm-display-part handle))))
4592 (require 'jka-compr))
4594 ;; jka-compr.el uses a "sh -c" to direct stderr to err-file, but these days
4595 ;; emacs can do that itself.
4597 (defun gnus-mime-jka-compr-maybe-uncompress ()
4598 "Uncompress the current buffer if `auto-compression-mode' is enabled.
4599 The uncompress method used is derived from `buffer-file-name'."
4600 (when (and (fboundp 'jka-compr-installed-p)
4601 (jka-compr-installed-p))
4602 (let ((info (jka-compr-get-compression-info buffer-file-name)))
4604 (let ((basename (file-name-nondirectory buffer-file-name))
4605 (args (jka-compr-info-uncompress-args info))
4606 (prog (jka-compr-info-uncompress-program info))
4607 (message (jka-compr-info-uncompress-message info))
4608 (err-file (jka-compr-make-temp-name)))
4610 (message "%s %s..." message basename))
4612 (unless (memq (apply 'call-process-region
4613 (point-min) (point-max)
4615 t (list t err-file) nil
4617 jka-compr-acceptable-retval-list)
4618 (jka-compr-error prog args basename message err-file))
4619 (jka-compr-delete-temp-file err-file)))))))
4621 (defun gnus-mime-copy-part (&optional handle)
4622 "Put the MIME part under point into a new buffer.
4623 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4626 (gnus-article-check-buffer)
4627 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4628 (contents (and handle (mm-get-part handle)))
4630 (file-name-nondirectory
4632 (mail-content-type-get (mm-handle-type handle) 'name)
4633 (mail-content-type-get (mm-handle-disposition handle)
4636 (buffer (and base (generate-new-buffer base))))
4638 (switch-to-buffer buffer)
4640 ;; We do it this way to make `normal-mode' set the appropriate mode.
4643 (setq buffer-file-name (expand-file-name base))
4644 (gnus-mime-jka-compr-maybe-uncompress)
4646 (setq buffer-file-name nil))
4647 (goto-char (point-min)))))
4649 (defun gnus-mime-print-part (&optional handle filename)
4650 "Print the MIME part under point."
4651 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4652 (gnus-article-check-buffer)
4653 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4654 (contents (and handle (mm-get-part handle)))
4655 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4656 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4661 (mm-save-part-to-file handle file)
4662 (call-process shell-file-name nil
4663 (generate-new-buffer " *mm*")
4665 shell-command-switch
4667 printer file (mm-handle-type handle))))
4671 (gnus-print-buffer))
4672 (ps-despool filename)))))
4674 (defun gnus-mime-inline-part (&optional handle arg)
4675 "Insert the MIME part under point into the current buffer."
4676 (interactive (list nil current-prefix-arg))
4677 (gnus-article-check-buffer)
4678 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4681 (inhibit-read-only t))
4683 (if (and (not arg) (mm-handle-undisplayer handle))
4684 (mm-remove-part handle)
4685 (setq contents (mm-get-part handle))
4688 (setq charset (or (mail-content-type-get
4689 (mm-handle-type handle) 'charset)
4690 gnus-newsgroup-charset)))
4692 (if (mm-handle-undisplayer handle)
4693 (mm-remove-part handle))
4696 gnus-summary-show-article-charset-alist))
4697 (mm-read-coding-system "Charset: ")))))
4699 (mm-insert-inline handle
4701 (setq charset (mm-charset-to-coding-system
4703 (not (eq charset 'ascii)))
4704 (mm-decode-coding-string contents charset)
4708 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4709 "Insert the MIME part under point into the current buffer using the
4711 (interactive (list nil current-prefix-arg))
4712 (gnus-article-check-buffer)
4713 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4716 (inhibit-read-only t))
4718 (if (mm-handle-undisplayer handle)
4719 (mm-remove-part handle))
4720 (let ((gnus-newsgroup-charset
4722 gnus-summary-show-article-charset-alist))
4723 (mm-read-coding-system "Charset: ")))
4724 (gnus-newsgroup-ignored-charsets 'gnus-all))
4725 (gnus-article-press-button)))))
4727 (defun gnus-mime-view-part-externally (&optional handle)
4728 "View the MIME part under point with an external viewer."
4730 (gnus-article-check-buffer)
4731 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4732 (mm-user-display-methods nil)
4733 (mm-inlined-types nil)
4734 (mail-parse-charset gnus-newsgroup-charset)
4735 (mail-parse-ignored-charsets
4736 (with-current-buffer gnus-summary-buffer
4737 gnus-newsgroup-ignored-charsets)))
4739 (if (mm-handle-undisplayer handle)
4740 (mm-remove-part handle)
4741 (mm-display-part handle)))))
4743 (defun gnus-mime-view-part-internally (&optional handle)
4744 "View the MIME part under point with an internal viewer.
4745 If no internal viewer is available, use an external viewer."
4747 (gnus-article-check-buffer)
4748 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4749 (mm-inlined-types '(".*"))
4750 (mm-inline-large-images t)
4751 (mail-parse-charset gnus-newsgroup-charset)
4752 (mail-parse-ignored-charsets
4753 (with-current-buffer gnus-summary-buffer
4754 gnus-newsgroup-ignored-charsets))
4755 (inhibit-read-only t))
4757 (if (mm-handle-undisplayer handle)
4758 (mm-remove-part handle)
4759 (mm-display-part handle)))))
4761 (defun gnus-mime-action-on-part (&optional action)
4762 "Do something with the MIME attachment at \(point\)."
4764 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4765 (gnus-article-check-buffer)
4766 (let ((action-pair (assoc action gnus-mime-action-alist)))
4768 (funcall (cdr action-pair)))))
4770 (defun gnus-article-part-wrapper (n function)
4771 (with-current-buffer gnus-article-buffer
4772 (when (> n (length gnus-article-mime-handle-alist))
4773 (error "No such part"))
4774 (gnus-article-goto-part n)
4775 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4776 (funcall function handle))))
4778 (defun gnus-article-pipe-part (n)
4779 "Pipe MIME part N, which is the numerical prefix."
4781 (gnus-article-part-wrapper n 'mm-pipe-part))
4783 (defun gnus-article-save-part (n)
4784 "Save MIME part N, which is the numerical prefix."
4786 (gnus-article-part-wrapper n 'mm-save-part))
4788 (defun gnus-article-interactively-view-part (n)
4789 "View MIME part N interactively, which is the numerical prefix."
4791 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4793 (defun gnus-article-copy-part (n)
4794 "Copy MIME part N, which is the numerical prefix."
4796 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4798 (defun gnus-article-view-part-as-charset (n)
4799 "View MIME part N using a specified charset.
4800 N is the numerical prefix."
4802 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4804 (defun gnus-article-view-part-externally (n)
4805 "View MIME part N externally, which is the numerical prefix."
4807 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4809 (defun gnus-article-inline-part (n)
4810 "Inline MIME part N, which is the numerical prefix."
4812 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4814 (defun gnus-article-mime-match-handle-first (condition)
4817 (dolist (ihandle gnus-article-mime-handle-alist)
4819 ((functionp condition)
4820 (funcall condition (cdr ihandle)))
4821 ((eq condition 'undisplayed)
4822 (not (or (mm-handle-undisplayer (cdr ihandle))
4823 (equal (mm-handle-media-type (cdr ihandle))
4824 "multipart/alternative"))))
4825 ((eq condition 'undisplayed-alternative)
4826 (not (mm-handle-undisplayer (cdr ihandle))))
4828 (gnus-article-goto-part (car ihandle))
4829 (or (not n) (< (car ihandle) n)))
4830 (setq n (car ihandle))))
4834 (defun gnus-article-view-part (&optional n)
4835 "View MIME part N, which is the numerical prefix."
4837 (with-current-buffer gnus-article-buffer
4838 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4839 gnus-article-mime-match-handle-function)))
4840 (when (> n (length gnus-article-mime-handle-alist))
4841 (error "No such part"))
4842 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4843 (when (gnus-article-goto-part n)
4844 (if (equal (car handle) "multipart/alternative")
4845 (gnus-article-press-button)
4846 (when (eq (gnus-mm-display-part handle) 'internal)
4847 (gnus-set-window-start)))))))
4849 (defsubst gnus-article-mime-total-parts ()
4850 (if (bufferp (car gnus-article-mime-handles))
4852 (1- (length gnus-article-mime-handles))))
4854 (defun gnus-mm-display-part (handle)
4855 "Display HANDLE and fix MIME button."
4856 (let ((id (get-text-property (point) 'gnus-part))
4858 (inhibit-read-only t))
4861 (let ((window (selected-window))
4862 (mail-parse-charset gnus-newsgroup-charset)
4863 (mail-parse-ignored-charsets
4864 (if (gnus-buffer-live-p gnus-summary-buffer)
4865 (with-current-buffer gnus-summary-buffer
4866 gnus-newsgroup-ignored-charsets)
4870 (let ((win (gnus-get-buffer-window (current-buffer) t))
4873 (select-window win))
4876 (if (mm-handle-displayed-p handle)
4877 ;; This will remove the part.
4878 (mm-display-part handle)
4880 (narrow-to-region (point)
4881 (if (eobp) (point) (1+ (point))))
4882 (mm-display-part handle)
4883 ;; We narrow to the part itself and
4884 ;; then call the treatment functions.
4885 (goto-char (point-min))
4887 (narrow-to-region (point) (point-max))
4890 (gnus-article-mime-total-parts)
4891 (mm-handle-media-type handle)))))
4892 (if (window-live-p window)
4893 (select-window window)))))
4896 (gnus-insert-mime-button
4897 handle id (list (mm-handle-displayed-p handle)))
4898 (goto-char point))))
4900 (defun gnus-article-goto-part (n)
4901 "Go to MIME part N."
4902 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4904 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4905 (let ((gnus-tmp-name
4906 (or (mail-content-type-get (mm-handle-type handle) 'name)
4907 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4908 (mail-content-type-get (mm-handle-type handle) 'url)
4910 (gnus-tmp-type (mm-handle-media-type handle))
4911 (gnus-tmp-description
4912 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4915 (if (if displayed (car displayed)
4916 (mm-handle-displayed-p handle))
4918 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4920 gnus-tmp-type-long b e)
4921 (when (string-match ".*/" gnus-tmp-name)
4922 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4923 (setq gnus-tmp-type-long (concat gnus-tmp-type
4924 (and (not (equal gnus-tmp-name ""))
4925 (concat "; " gnus-tmp-name))))
4926 (unless (equal gnus-tmp-description "")
4927 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4932 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4933 `(keymap ,gnus-mime-button-map
4934 gnus-callback gnus-mm-display-part
4935 gnus-part ,gnus-tmp-id
4936 article-type annotation
4939 ;; Exclude a newline.
4942 (widget-convert-button
4945 :action 'gnus-widget-press-button
4946 :button-keymap gnus-mime-button-map
4948 (lambda (widget/window &optional overlay pos)
4949 ;; Needed to properly clear the message due to a bug in
4950 ;; wid-edit (XEmacs only).
4951 (if (boundp 'help-echo-owns-message)
4952 (setq help-echo-owns-message t))
4954 "%S: %s the MIME part; %S: more options"
4955 (aref gnus-mouse-2 0)
4956 ;; XEmacs will get a single widget arg; Emacs 21 will get
4957 ;; window, overlay, position.
4958 (if (mm-handle-displayed-p
4960 (with-current-buffer (gnus-overlay-buffer overlay)
4961 (widget-get (widget-at (gnus-overlay-start overlay))
4963 (widget-get widget/window :mime-handle)))
4965 (aref gnus-down-mouse-3 0))))))
4967 (defun gnus-widget-press-button (elems el)
4968 (goto-char (widget-get elems :from))
4969 (gnus-article-press-button))
4971 (defvar gnus-displaying-mime nil)
4973 (defun gnus-display-mime (&optional ihandles)
4974 "Display the MIME parts."
4976 (save-selected-window
4977 (let ((window (get-buffer-window gnus-article-buffer))
4980 (select-window window)
4981 ;; We have to do this since selecting the window
4982 ;; may change the point. So we set the window point.
4983 (set-window-point window point)))
4984 (let ((handles ihandles)
4985 (inhibit-read-only t)
4986 handle name type b e display)
4988 ((setq handles (mm-dissect-buffer nil gnus-article-loose-mime))
4989 (when gnus-article-emulate-mime
4990 (mm-uu-dissect-text-parts handles)))
4991 (gnus-article-emulate-mime
4992 (setq handles (mm-uu-dissect))))
4993 (when (and (not ihandles)
4994 (not gnus-displaying-mime))
4995 ;; Top-level call; we clean up.
4996 (when gnus-article-mime-handles
4997 (mm-destroy-parts gnus-article-mime-handles)
4998 (setq gnus-article-mime-handle-alist nil));; A trick.
4999 (setq gnus-article-mime-handles handles)
5000 ;; We allow users to glean info from the handles.
5001 (when gnus-article-mime-part-function
5002 (gnus-mime-part-function handles)))
5004 (or (not (stringp (car handles)))
5007 (when (and (not ihandles)
5008 (not gnus-displaying-mime))
5009 ;; Clean up for mime parts.
5011 (delete-region (point) (point-max)))
5012 (let ((gnus-displaying-mime t))
5013 (gnus-mime-display-part handles)))
5016 (narrow-to-region (point) (point-max))
5017 (gnus-treat-article nil 1 1)
5020 ;; Highlight the headers.
5024 (narrow-to-region (point-min) (point))
5025 (gnus-treat-article 'head))))))))
5027 (defcustom gnus-mime-display-multipart-as-mixed nil
5028 "Display \"multipart\" parts as \"multipart/mixed\".
5030 If t, it overrides nil values of
5031 `gnus-mime-display-multipart-alternative-as-mixed' and
5032 `gnus-mime-display-multipart-related-as-mixed'."
5033 :group 'gnus-article-mime
5036 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
5037 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
5039 :group 'gnus-article-mime
5042 (defcustom gnus-mime-display-multipart-related-as-mixed nil
5043 "Display \"multipart/related\" parts as \"multipart/mixed\".
5045 If displaying \"text/html\" is discouraged \(see
5046 `mm-discouraged-alternatives'\) images or other material inside a
5047 \"multipart/related\" part might be overlooked when this variable is nil."
5049 :group 'gnus-article-mime
5052 (defun gnus-mime-display-part (handle)
5055 ((not (stringp (car handle)))
5056 (gnus-mime-display-single handle))
5057 ;; User-defined multipart
5058 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
5059 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
5061 ;; multipart/alternative
5062 ((and (equal (car handle) "multipart/alternative")
5063 (not (or gnus-mime-display-multipart-as-mixed
5064 gnus-mime-display-multipart-alternative-as-mixed)))
5065 (let ((id (1+ (length gnus-article-mime-handle-alist))))
5066 (push (cons id handle) gnus-article-mime-handle-alist)
5067 (gnus-mime-display-alternative (cdr handle) nil nil id)))
5068 ;; multipart/related
5069 ((and (equal (car handle) "multipart/related")
5070 (not (or gnus-mime-display-multipart-as-mixed
5071 gnus-mime-display-multipart-related-as-mixed)))
5072 ;;;!!!We should find the start part, but we just default
5073 ;;;!!!to the first part.
5074 ;;(gnus-mime-display-part (cadr handle))
5075 ;;;!!! Most multipart/related is an HTML message plus images.
5076 ;;;!!! Unfortunately we are unable to let W3 display those
5077 ;;;!!! included images, so we just display it as a mixed multipart.
5078 ;;(gnus-mime-display-mixed (cdr handle))
5079 ;;;!!! No, w3 can display everything just fine.
5080 (gnus-mime-display-part (cadr handle)))
5081 ((equal (car handle) "multipart/signed")
5082 (gnus-add-wash-type 'signed)
5083 (gnus-mime-display-security handle))
5084 ((equal (car handle) "multipart/encrypted")
5085 (gnus-add-wash-type 'encrypted)
5086 (gnus-mime-display-security handle))
5087 ;; Other multiparts are handled like multipart/mixed.
5089 (gnus-mime-display-mixed (cdr handle)))))
5091 (defun gnus-mime-part-function (handles)
5092 (if (stringp (car handles))
5093 (mapcar 'gnus-mime-part-function (cdr handles))
5094 (funcall gnus-article-mime-part-function handles)))
5096 (defun gnus-mime-display-mixed (handles)
5097 (mapcar 'gnus-mime-display-part handles))
5099 (defun gnus-mime-display-single (handle)
5100 (let ((type (mm-handle-media-type handle))
5101 (ignored gnus-ignored-mime-types)
5108 (when (string-match (pop ignored) type)
5109 (throw 'ignored nil)))
5110 (if (and (setq not-attachment
5111 (and (not (mm-inline-override-p handle))
5112 (or (not (mm-handle-disposition handle))
5113 (equal (car (mm-handle-disposition handle))
5115 (mm-attachment-override-p handle))))
5116 (mm-automatic-display-p handle)
5118 (mm-inlinable-p handle)
5119 (mm-inlined-p handle))
5120 (mm-automatic-external-display-p type)))
5122 (when (equal (mm-handle-media-supertype handle) "text")
5124 (let ((id (1+ (length gnus-article-mime-handle-alist)))
5126 (push (cons id handle) gnus-article-mime-handle-alist)
5127 (when (or (not display)
5128 (not (gnus-unbuttonized-mime-type-p type)))
5129 (gnus-insert-mime-button
5130 handle id (list (or display (and not-attachment text))))
5131 (gnus-article-insert-newline)
5132 ;; Remember modify the number of forward lines.
5140 (let ((mail-parse-charset gnus-newsgroup-charset)
5141 (mail-parse-ignored-charsets
5142 (save-excursion (condition-case ()
5143 (set-buffer gnus-summary-buffer)
5145 gnus-newsgroup-ignored-charsets)))
5146 (mm-display-part handle t))
5147 (goto-char (point-max)))
5148 ((and text not-attachment)
5152 (gnus-article-insert-newline)
5153 (mm-display-inline handle)
5154 (goto-char (point-max))))
5158 (narrow-to-region beg (point))
5161 (gnus-article-mime-total-parts)
5162 (mm-handle-media-type handle)))))))))
5164 (defun gnus-unbuttonized-mime-type-p (type)
5165 "Say whether TYPE is to be unbuttonized."
5166 (unless gnus-inhibit-mime-unbuttonizing
5168 (let ((types gnus-unbuttonized-mime-types))
5170 (when (string-match (pop types) type)
5171 (throw 'found t)))))
5173 (let ((types gnus-buttonized-mime-types))
5175 (when (string-match (pop types) type)
5176 (throw 'found t)))))))))
5178 (defun gnus-article-insert-newline ()
5179 "Insert a newline, but mark it as undeletable."
5180 (gnus-put-text-property
5181 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
5183 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
5184 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
5187 handle (inhibit-read-only t) from props begend not-pref)
5188 (save-window-excursion
5191 (narrow-to-region (car ibegend)
5194 (goto-char (car ibegend))
5197 (delete-region (point-min) (point-max))
5198 (mm-remove-parts handles))
5199 (setq begend (list (point-marker)))
5201 (unless (setq not-pref (cadr (member preferred ihandles)))
5202 (setq not-pref (car ihandles)))
5205 (not (gnus-unbuttonized-mime-type-p
5206 "multipart/alternative")))
5207 (gnus-add-text-properties
5210 (insert (format "%d. " id))
5214 (unless ,(not ibegend)
5215 (setq gnus-article-mime-handle-alist
5216 ',gnus-article-mime-handle-alist))
5217 (gnus-mime-display-alternative
5218 ',ihandles ',not-pref ',begend ,id))
5219 keymap ,gnus-mime-button-map
5220 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5221 face ,gnus-article-button-face
5224 (widget-convert-button 'link from (point)
5225 :action 'gnus-widget-press-button
5226 :button-keymap gnus-widget-button-keymap)
5228 (while (setq handle (pop handles))
5229 (gnus-add-text-properties
5232 (insert (format "(%c) %-18s"
5233 (if (equal handle preferred) ?* ? )
5234 (mm-handle-media-type handle)))
5238 (unless ,(not ibegend)
5239 (setq gnus-article-mime-handle-alist
5240 ',gnus-article-mime-handle-alist))
5241 (gnus-mime-display-alternative
5242 ',ihandles ',handle ',begend ,id))
5243 keymap ,gnus-mime-button-map
5244 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5245 face ,gnus-article-button-face
5248 (widget-convert-button 'link from (point)
5249 :action 'gnus-widget-press-button
5250 :button-keymap gnus-widget-button-keymap)
5254 (if (stringp (car preferred))
5255 (gnus-display-mime preferred)
5256 (let ((mail-parse-charset gnus-newsgroup-charset)
5257 (mail-parse-ignored-charsets
5258 (with-current-buffer gnus-summary-buffer
5259 gnus-newsgroup-ignored-charsets)))
5260 (mm-display-part preferred)
5264 (narrow-to-region (car begend) (point-max))
5266 nil (length gnus-article-mime-handle-alist)
5267 (gnus-article-mime-total-parts)
5268 (mm-handle-media-type handle))))))
5269 (goto-char (point-max))
5270 (setcdr begend (point-marker)))))
5272 (goto-char point))))
5274 (defconst gnus-article-wash-status-strings
5275 (let ((alist '((cite "c" "Possible hidden citation text"
5276 " " "All citation text visible")
5277 (headers "h" "Hidden headers"
5278 " " "All headers visible.")
5279 (pgp "p" "Encrypted or signed message status hidden"
5280 " " "No hidden encryption nor digital signature status")
5281 (signature "s" "Signature has been hidden"
5282 " " "Signature is visible")
5283 (overstrike "o" "Overstrike (^H) characters applied"
5284 " " "No overstrike characters applied")
5285 (gnus-show-mime "m" "Mime processing is activated"
5286 " " "Mime processing is not activated")
5287 (emphasis "e" "/*_Emphasis_*/ characters applied"
5288 " " "No /*_emphasis_*/ characters applied")))
5290 (dolist (entry alist result)
5291 (let ((key (nth 0 entry))
5292 (on (copy-sequence (nth 1 entry)))
5293 (on-help (nth 2 entry))
5294 (off (copy-sequence (nth 3 entry)))
5295 (off-help (nth 4 entry)))
5296 (put-text-property 0 1 'help-echo on-help on)
5297 (put-text-property 0 1 'help-echo off-help off)
5298 (push (list key on off) result))))
5299 "Alist of strings describing wash status in the mode line.
5300 Each entry has the form (KEY ON OF), where the KEY is a symbol
5301 representing the particular washing function, ON is the string to use
5302 in the article mode line when the washing function is active, and OFF
5303 is the string to use when it is inactive.")
5305 (defun gnus-article-wash-status-entry (key value)
5306 (let ((entry (assoc key gnus-article-wash-status-strings)))
5307 (if value (nth 1 entry) (nth 2 entry))))
5309 (defun gnus-article-wash-status ()
5310 "Return a string which display status of article washing."
5311 (with-current-buffer gnus-article-buffer
5312 (let ((cite (memq 'cite gnus-article-wash-types))
5313 (headers (memq 'headers gnus-article-wash-types))
5314 (boring (memq 'boring-headers gnus-article-wash-types))
5315 (pgp (memq 'pgp gnus-article-wash-types))
5316 (pem (memq 'pem gnus-article-wash-types))
5317 (signed (memq 'signed gnus-article-wash-types))
5318 (encrypted (memq 'encrypted gnus-article-wash-types))
5319 (signature (memq 'signature gnus-article-wash-types))
5320 (overstrike (memq 'overstrike gnus-article-wash-types))
5321 (emphasis (memq 'emphasis gnus-article-wash-types)))
5323 (gnus-article-wash-status-entry 'cite cite)
5324 (gnus-article-wash-status-entry 'headers (or headers boring))
5325 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5326 (gnus-article-wash-status-entry 'signature signature)
5327 (gnus-article-wash-status-entry 'overstrike overstrike)
5328 (gnus-article-wash-status-entry 'gnus-show-mime gnus-show-mime)
5329 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5331 (defun gnus-add-wash-type (type)
5332 "Add a washing of TYPE to the current status."
5333 (add-to-list 'gnus-article-wash-types type))
5335 (defun gnus-delete-wash-type (type)
5336 "Add a washing of TYPE to the current status."
5337 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5339 (defun gnus-add-image (category image)
5340 "Add IMAGE of CATEGORY to the list of displayed images."
5341 (let ((entry (assq category gnus-article-image-alist)))
5343 (setq entry (list category))
5344 (push entry gnus-article-image-alist))
5345 (nconc entry (list image))))
5347 (defun gnus-delete-images (category)
5348 "Delete all images in CATEGORY."
5349 (let ((entry (assq category gnus-article-image-alist)))
5350 (dolist (image (cdr entry))
5351 (gnus-remove-image image category))
5352 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5353 (gnus-delete-wash-type category)))
5355 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5357 (defun gnus-article-maybe-hide-headers ()
5358 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5359 Provided for backwards compatibility."
5360 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5361 (not (with-current-buffer gnus-summary-buffer
5362 gnus-have-all-headers)))
5363 (not gnus-inhibit-hiding))
5364 (gnus-article-hide-headers)))
5368 (defun gnus-output-to-file (file-name)
5369 "Append the current article to a file named FILE-NAME."
5370 (let ((artbuf (current-buffer)))
5372 (insert-buffer-substring artbuf)
5373 ;; Append newline at end of the buffer as separator, and then
5375 (goto-char (point-max))
5377 (let ((file-name-coding-system nnmail-pathname-coding-system))
5378 (write-region-as-binary (point-min) (point-max) file-name 'append))
5381 (defun gnus-narrow-to-page (&optional arg)
5382 "Narrow the article buffer to a page.
5383 If given a numerical ARG, move forward ARG pages."
5385 (setq arg (if arg (prefix-numeric-value arg) 0))
5387 (set-buffer gnus-article-buffer)
5388 (goto-char (point-min))
5390 ;; Remove any old next/prev buttons.
5391 (when (gnus-visual-p 'page-marker)
5392 (let ((inhibit-read-only t))
5393 (gnus-remove-text-with-property 'gnus-prev)
5394 (gnus-remove-text-with-property 'gnus-next)))
5397 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5399 (re-search-forward page-delimiter nil 'move arg)))
5400 (goto-char (match-end 0))
5402 (goto-char (point-min))
5403 (setq gnus-page-broken
5404 (and (re-search-forward page-delimiter nil t) t))))
5405 (when gnus-page-broken
5408 (if (re-search-forward page-delimiter nil 'move)
5411 (when (and (gnus-visual-p 'page-marker)
5412 (> (point-min) (save-restriction (widen) (point-min))))
5414 (goto-char (point-min))
5415 (gnus-insert-prev-page-button)))
5416 (when (and (gnus-visual-p 'page-marker)
5417 (< (+ (point-max) 2) (buffer-size)))
5419 (goto-char (point-max))
5420 (gnus-insert-next-page-button))))))
5422 ;; Article mode commands
5424 (defun gnus-article-goto-next-page ()
5425 "Show the next page of the article."
5427 (when (gnus-article-next-page)
5428 (goto-char (point-min))
5429 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5432 (defun gnus-article-goto-prev-page ()
5433 "Show the previous page of the article."
5436 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5437 (gnus-article-prev-page nil)))
5439 ;; This is cleaner but currently breaks `gnus-pick-mode':
5441 ;; (defun gnus-article-goto-next-page ()
5442 ;; "Show the next page of the article."
5444 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5445 ;; (gnus-summary-next-page)))
5447 ;; (defun gnus-article-goto-prev-page ()
5448 ;; "Show the next page of the article."
5450 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5451 ;; (gnus-summary-prev-page)))
5453 (defun gnus-article-next-page (&optional lines)
5454 "Show the next page of the current article.
5455 If end of article, return non-nil. Otherwise return nil.
5456 Argument LINES specifies lines to be scrolled up."
5458 (move-to-window-line -1)
5461 (and (pos-visible-in-window-p) ;Not continuation line.
5462 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5463 ;; Nothing in this page.
5464 (if (or (not gnus-page-broken)
5469 (eobp)))) ;Real end-of-buffer?
5471 (when gnus-article-over-scroll
5472 (gnus-article-next-page-1 lines))
5474 (gnus-narrow-to-page 1) ;Go to next page.
5476 ;; More in this page.
5477 (gnus-article-next-page-1 lines)
5480 (defun gnus-article-next-page-1 (lines)
5481 (let ((scroll-in-place nil))
5485 ;; Long lines may cause an end-of-buffer error.
5486 (goto-char (point-max)))))
5487 (move-to-window-line 0))
5489 (defun gnus-article-prev-page (&optional lines)
5490 "Show previous page of current article.
5491 Argument LINES specifies lines to be scrolled down."
5493 (move-to-window-line 0)
5494 (if (and gnus-page-broken
5496 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5498 (gnus-narrow-to-page -1) ;Go to previous page.
5499 (goto-char (point-max))
5501 (let ((scroll-in-place nil))
5505 (beginning-of-buffer
5506 (goto-char (point-min))))
5507 (move-to-window-line 0)))))
5509 (defun gnus-article-only-boring-p ()
5510 "Decide whether there is only boring text remaining in the article.
5511 Something \"interesting\" is a word of at least two letters that does
5512 not have a face in `gnus-article-boring-faces'."
5513 (when (and gnus-article-skip-boring
5514 (boundp 'gnus-article-boring-faces)
5515 (symbol-value 'gnus-article-boring-faces))
5518 (while (re-search-forward "\\b\\w\\w" nil t)
5520 (when (not (gnus-intersection
5521 (gnus-faces-at (point))
5522 (symbol-value 'gnus-article-boring-faces)))
5523 (throw 'only-boring nil)))
5524 (throw 'only-boring t)))))
5526 (defun gnus-article-refer-article ()
5527 "Read article specified by message-id around point."
5530 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
5531 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
5532 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
5533 (let ((msg-id (concat "<" (match-string 0) ">")))
5534 (set-buffer gnus-summary-buffer)
5535 (gnus-summary-refer-article msg-id))
5536 (error "No references around point"))))
5538 (defun gnus-article-show-summary ()
5539 "Reconfigure windows to show summary buffer."
5541 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5542 (error "There is no summary buffer for this article buffer")
5543 (gnus-article-set-globals)
5544 (gnus-configure-windows 'article)
5545 (gnus-summary-goto-subject gnus-current-article)
5546 (gnus-summary-position-point)))
5548 (defun gnus-article-describe-briefly ()
5549 "Describe article mode commands briefly."
5551 (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")))
5553 (defun gnus-article-summary-command ()
5554 "Execute the last keystroke in the summary buffer."
5556 (let ((obuf (current-buffer))
5557 (owin (current-window-configuration))
5559 (switch-to-buffer gnus-article-current-summary 'norecord)
5560 (setq func (lookup-key (current-local-map) (this-command-keys)))
5561 (call-interactively func)
5563 (set-window-configuration owin)
5564 (set-window-point (get-buffer-window (current-buffer)) (point))))
5566 (defun gnus-article-summary-command-nosave ()
5567 "Execute the last keystroke in the summary buffer."
5570 (pop-to-buffer gnus-article-current-summary 'norecord)
5571 (setq func (lookup-key (current-local-map) (this-command-keys)))
5572 (call-interactively func)))
5574 (defun gnus-article-check-buffer ()
5575 "Beep if not in an article buffer."
5576 (unless (eq (get-buffer gnus-article-buffer) (current-buffer))
5577 (error "Command invoked outside of a Gnus article buffer")))
5579 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5580 "Read a summary buffer key sequence and execute it from the article buffer."
5582 (gnus-article-check-buffer)
5584 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5585 "Zc" "ZC" "ZE" "ZJ" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5586 "=" "^" "\M-^" "|"))
5592 '("n" "Gn" "p" "Gp"))
5595 (set-buffer gnus-article-current-summary)
5596 (let (gnus-pick-mode)
5597 (push (or key last-command-event) unread-command-events)
5598 (setq keys (static-if (featurep 'xemacs)
5599 (events-to-keys (read-key-sequence nil))
5600 (read-key-sequence nil)))))
5603 (if (or (member keys nosaves)
5604 (member keys nosave-but-article)
5605 (member keys nosave-in-article))
5607 (save-window-excursion
5608 (pop-to-buffer gnus-article-current-summary 'norecord)
5609 ;; We disable the pick minor mode commands.
5610 (let (gnus-pick-mode)
5611 (setq func (lookup-key (current-local-map) keys))))
5615 (unless (member keys nosave-in-article)
5616 (set-buffer gnus-article-current-summary))
5617 (call-interactively func)
5618 (setq new-sum-point (point)))
5619 (when (member keys nosave-but-article)
5620 (pop-to-buffer gnus-article-buffer 'norecord)))
5621 ;; These commands should restore window configuration.
5622 (let ((obuf (current-buffer))
5623 (owin (current-window-configuration))
5625 win func in-buffer selected new-sum-start new-sum-hscroll)
5626 (cond (not-restore-window
5627 (pop-to-buffer gnus-article-current-summary 'norecord))
5628 ((setq win (get-buffer-window gnus-article-current-summary))
5629 (select-window win))
5631 (switch-to-buffer gnus-article-current-summary 'norecord)))
5632 (setq in-buffer (current-buffer))
5633 ;; We disable the pick minor mode commands.
5634 (if (and (setq func (let (gnus-pick-mode)
5635 (lookup-key (current-local-map) keys)))
5638 (call-interactively func)
5639 (when (eq win (selected-window))
5640 (setq new-sum-point (point)
5641 new-sum-start (window-start win)
5642 new-sum-hscroll (window-hscroll win))
5643 (when (eq in-buffer (current-buffer))
5644 (setq selected (gnus-summary-select-article))
5646 (unless not-restore-window
5647 (set-window-configuration owin))
5648 (when (eq selected 'old)
5650 (set-window-start (get-buffer-window (current-buffer))
5652 (set-window-point (get-buffer-window (current-buffer))
5654 (when (and (not not-restore-window)
5656 (set-window-point win new-sum-point)
5657 (set-window-start win new-sum-start)
5658 (set-window-hscroll win new-sum-hscroll)))))
5659 (set-window-configuration owin)
5662 (defun gnus-article-describe-key (key)
5663 "Display documentation of the function invoked by KEY. KEY is a string."
5664 (interactive "kDescribe key: ")
5665 (gnus-article-check-buffer)
5666 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5668 (set-buffer gnus-article-current-summary)
5669 (let (gnus-pick-mode)
5670 (if (featurep 'xemacs)
5672 (push (elt key 0) unread-command-events)
5673 (setq key (events-to-keys
5674 (read-key-sequence "Describe key: "))))
5675 (setq unread-command-events
5677 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5679 (setq key (read-key-sequence "Describe key: "))))
5681 (describe-key key)))
5683 (defun gnus-article-describe-key-briefly (key &optional insert)
5684 "Display documentation of the function invoked by KEY. KEY is a string."
5685 (interactive "kDescribe key: \nP")
5686 (gnus-article-check-buffer)
5687 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5689 (set-buffer gnus-article-current-summary)
5690 (let (gnus-pick-mode)
5691 (if (featurep 'xemacs)
5693 (push (elt key 0) unread-command-events)
5694 (setq key (events-to-keys
5695 (read-key-sequence "Describe key: "))))
5696 (setq unread-command-events
5698 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5700 (setq key (read-key-sequence "Describe key: "))))
5701 (describe-key-briefly key insert))
5702 (describe-key-briefly key insert)))
5704 (defun gnus-article-reply-with-original (&optional wide)
5705 "Start composing a reply mail to the current message.
5706 The text in the region will be yanked. If the region isn't active,
5707 the entire article will be yanked."
5709 (let ((article (cdr gnus-article-current))
5711 (if (not (gnus-region-active-p))
5712 (with-current-buffer gnus-summary-buffer
5713 (gnus-summary-reply (list (list article)) wide))
5714 (setq contents (buffer-substring (point) (mark t)))
5715 ;; Deactivate active regions.
5716 (when (and (boundp 'transient-mark-mode)
5717 transient-mark-mode)
5718 (setq mark-active nil))
5719 (with-current-buffer gnus-summary-buffer
5721 (list (list article contents)) wide)))))
5723 (defun gnus-article-followup-with-original ()
5724 "Compose a followup to the current article.
5725 The text in the region will be yanked. If the region isn't active,
5726 the entire article will be yanked."
5728 (let ((article (cdr gnus-article-current))
5730 (if (not (gnus-region-active-p))
5731 (with-current-buffer gnus-summary-buffer
5732 (gnus-summary-followup (list (list article))))
5733 (setq contents (buffer-substring (point) (mark t)))
5734 ;; Deactivate active regions.
5735 (when (and (boundp 'transient-mark-mode)
5736 transient-mark-mode)
5737 (setq mark-active nil))
5738 (with-current-buffer gnus-summary-buffer
5739 (gnus-summary-followup
5740 (list (list article contents)))))))
5742 (defun gnus-article-hide (&optional arg force)
5743 "Hide all the gruft in the current article.
5744 This means that signatures, cited text and (some) headers will be
5746 If given a prefix, show the hidden text instead."
5747 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5748 (gnus-article-hide-headers arg)
5749 (gnus-article-hide-list-identifiers arg)
5750 (gnus-article-hide-citation-maybe arg force)
5751 (gnus-article-hide-signature arg))
5753 (defun gnus-article-maybe-highlight ()
5754 "Do some article highlighting if article highlighting is requested."
5755 (when (gnus-visual-p 'article-highlight 'highlight)
5756 (gnus-article-highlight-some)))
5758 (defun gnus-check-group-server ()
5759 ;; Make sure the connection to the server is alive.
5760 (unless (gnus-server-opened
5761 (gnus-find-method-for-group gnus-newsgroup-name))
5762 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5763 (gnus-request-group gnus-newsgroup-name t)))
5766 (autoload 'nneething-get-file-name "nneething"))
5768 (defun gnus-request-article-this-buffer (article group)
5769 "Get an article and insert it into this buffer."
5770 (let (do-update-line sparse-header)
5774 (gnus-kill-all-overlays)
5775 (setq group (or group gnus-newsgroup-name))
5777 ;; Using `gnus-request-article' directly will insert the article into
5778 ;; `nntp-server-buffer' - so we'll save some time by not having to
5779 ;; copy it from the server buffer into the article buffer.
5781 ;; We only request an article by message-id when we do not have the
5782 ;; headers for it, so we'll have to get those.
5783 (when (stringp article)
5784 (gnus-read-header article))
5786 ;; If the article number is negative, that means that this article
5787 ;; doesn't belong in this newsgroup (possibly), so we find its
5788 ;; message-id and request it by id instead of number.
5789 (when (and (numberp article)
5791 (get-buffer gnus-summary-buffer)
5792 (gnus-buffer-exists-p gnus-summary-buffer))
5794 (set-buffer gnus-summary-buffer)
5795 (let ((header (gnus-summary-article-header article)))
5798 ((memq article gnus-newsgroup-sparse)
5799 ;; This is a sparse gap article.
5800 (setq do-update-line article)
5801 (setq article (mail-header-id header))
5802 (setq sparse-header (gnus-read-header article))
5803 (setq gnus-newsgroup-sparse
5804 (delq article gnus-newsgroup-sparse)))
5806 ;; It's a real article.
5807 (setq article (mail-header-id header)))
5809 ;; It is an extracted pseudo-article.
5810 (setq article 'pseudo)
5811 (gnus-request-pseudo-article header))))
5813 (let ((method (gnus-find-method-for-group
5814 gnus-newsgroup-name)))
5815 (when (and (eq (car method) 'nneething)
5817 (let ((dir (nneething-get-file-name
5818 (mail-header-id header))))
5819 (when (and (stringp dir)
5820 (file-directory-p dir))
5821 (setq article 'nneething)
5822 (gnus-group-enter-directory dir))))))))
5825 ;; Refuse to select canceled articles.
5826 ((and (numberp article)
5828 (get-buffer gnus-summary-buffer)
5829 (gnus-buffer-exists-p gnus-summary-buffer)
5830 (eq (cdr (with-current-buffer gnus-summary-buffer
5831 (assq article gnus-newsgroup-reads)))
5832 gnus-canceled-mark))
5834 ;; We first check `gnus-original-article-buffer'.
5835 ((and (get-buffer gnus-original-article-buffer)
5837 (with-current-buffer gnus-original-article-buffer
5838 (and (equal (car gnus-original-article) group)
5839 (eq (cdr gnus-original-article) article))))
5840 (insert-buffer-substring gnus-original-article-buffer)
5842 ;; Check the backlog.
5843 ((and gnus-keep-backlog
5844 (gnus-backlog-request-article group article (current-buffer)))
5846 ;; Check asynchronous pre-fetch.
5847 ((gnus-async-request-fetched-article group article (current-buffer))
5848 (gnus-async-prefetch-next group article gnus-summary-buffer)
5849 (when (and (numberp article) gnus-keep-backlog)
5850 (gnus-backlog-enter-article group article (current-buffer)))
5853 ((and gnus-use-cache
5855 (gnus-cache-request-article article group))
5857 ;; Check the agent cache.
5858 ((gnus-agent-request-article article group)
5860 ;; Get the article and put into the article buffer.
5861 ((or (stringp article)
5863 (let ((gnus-override-method gnus-override-method)
5864 (methods (and (stringp article)
5865 gnus-refer-article-method))
5866 (backend (car (gnus-find-method-for-group
5867 gnus-newsgroup-name)))
5869 (inhibit-read-only t))
5870 (if (or (not (listp methods))
5871 (and (symbolp (car methods))
5872 (assq (car methods) nnoo-definition-alist)))
5873 (setq methods (list methods)))
5874 (when (and (null gnus-override-method)
5876 (setq gnus-override-method (pop methods)))
5878 (when (eq gnus-override-method 'current)
5879 (setq gnus-override-method
5880 (with-current-buffer gnus-summary-buffer
5881 gnus-current-select-method)))
5883 (gnus-kill-all-overlays)
5884 (let ((gnus-newsgroup-name group))
5885 (gnus-check-group-server))
5887 ((gnus-request-article article group (current-buffer))
5888 (when (numberp article)
5889 (gnus-async-prefetch-next group article
5890 gnus-summary-buffer)
5891 (when gnus-keep-backlog
5892 (gnus-backlog-enter-article
5893 group article (current-buffer))))
5894 (setq result 'article))
5896 (setq gnus-override-method (pop methods)))
5897 ((not (string-match "^400 "
5898 (nnheader-get-report backend)))
5899 ;; If we get 400 server disconnect, reconnect and
5900 ;; retry; otherwise, assume the article has expired.
5901 (setq result 'done))))
5902 (and (eq result 'article) 'article)))
5906 ;; Associate this article with the current summary buffer.
5907 (setq gnus-article-current-summary gnus-summary-buffer)
5909 ;; Take the article from the original article buffer
5910 ;; and place it in the buffer it's supposed to be in.
5911 (when (and (get-buffer gnus-article-buffer)
5912 (equal (buffer-name (current-buffer))
5913 (buffer-name (get-buffer gnus-article-buffer))))
5915 (if (get-buffer gnus-original-article-buffer)
5916 (set-buffer gnus-original-article-buffer)
5917 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5918 (buffer-disable-undo)
5919 (setq major-mode 'gnus-original-article-mode)
5920 (setq buffer-read-only t))
5921 (let ((inhibit-read-only t))
5923 (insert-buffer-substring gnus-article-buffer))
5924 (setq gnus-original-article (cons group article)))
5927 (run-hooks 'gnus-article-decode-hook)
5928 ;; Mark article as decoded or not.
5929 (setq gnus-article-decoded-p gnus-article-decode-hook))
5931 ;; Update sparse articles.
5932 (when (and do-update-line
5933 (or (numberp article)
5935 (let ((buf (current-buffer)))
5936 (set-buffer gnus-summary-buffer)
5937 (gnus-summary-update-article do-update-line sparse-header)
5938 (gnus-summary-goto-subject do-update-line nil t)
5939 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5941 (set-buffer buf))))))
5947 (defcustom gnus-article-edit-mode-hook nil
5948 "Hook run in article edit mode buffers."
5949 :group 'gnus-article-various
5952 (defcustom gnus-article-edit-article-setup-function
5953 'gnus-article-mime-edit-article-setup
5954 "Function called to setup an editing article buffer."
5955 :group 'gnus-article-various
5958 (defvar gnus-article-edit-done-function nil)
5960 (defvar gnus-article-edit-mode-map nil)
5962 ;; Should we be using derived.el for this?
5963 (unless gnus-article-edit-mode-map
5964 (setq gnus-article-edit-mode-map (make-keymap))
5965 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5967 (gnus-define-keys gnus-article-edit-mode-map
5968 "\C-c?" describe-mode
5969 "\C-c\C-c" gnus-article-edit-done
5970 "\C-c\C-k" gnus-article-edit-exit
5971 "\C-c\C-f\C-t" message-goto-to
5972 "\C-c\C-f\C-o" message-goto-from
5973 "\C-c\C-f\C-b" message-goto-bcc
5974 ;;"\C-c\C-f\C-w" message-goto-fcc
5975 "\C-c\C-f\C-c" message-goto-cc
5976 "\C-c\C-f\C-s" message-goto-subject
5977 "\C-c\C-f\C-r" message-goto-reply-to
5978 "\C-c\C-f\C-n" message-goto-newsgroups
5979 "\C-c\C-f\C-d" message-goto-distribution
5980 "\C-c\C-f\C-f" message-goto-followup-to
5981 "\C-c\C-f\C-m" message-goto-mail-followup-to
5982 "\C-c\C-f\C-k" message-goto-keywords
5983 "\C-c\C-f\C-u" message-goto-summary
5984 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5985 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5986 "\C-c\C-b" message-goto-body
5987 "\C-c\C-i" message-goto-signature
5989 "\C-c\C-t" message-insert-to
5990 "\C-c\C-n" message-insert-newsgroups
5991 "\C-c\C-o" message-sort-headers
5992 "\C-c\C-e" message-elide-region
5993 "\C-c\C-v" message-delete-not-region
5994 "\C-c\C-z" message-kill-to-signature
5995 "\M-\r" message-newline-and-reformat
5996 "\C-c\C-a" mml-attach-file
5997 "\C-a" message-beginning-of-line
5999 "\M-;" comment-region)
6001 (gnus-define-keys (gnus-article-edit-wash-map
6002 "\C-c\C-w" gnus-article-edit-mode-map)
6003 "f" gnus-article-edit-full-stops))
6006 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
6008 ["Fetch To" message-insert-to t]
6009 ["Fetch Newsgroups" message-insert-newsgroups t]
6011 ["To" message-goto-to t]
6012 ["From" message-goto-from t]
6013 ["Subject" message-goto-subject t]
6014 ["Cc" message-goto-cc t]
6015 ["Reply-To" message-goto-reply-to t]
6016 ["Summary" message-goto-summary t]
6017 ["Keywords" message-goto-keywords t]
6018 ["Newsgroups" message-goto-newsgroups t]
6019 ["Followup-To" message-goto-followup-to t]
6020 ["Mail-Followup-To" message-goto-mail-followup-to t]
6021 ["Distribution" message-goto-distribution t]
6022 ["Body" message-goto-body t]
6023 ["Signature" message-goto-signature t]))
6025 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
6026 "Major mode for editing articles.
6027 This is an extended text-mode.
6029 \\{gnus-article-edit-mode-map}"
6030 (make-local-variable 'gnus-article-edit-done-function)
6031 (make-local-variable 'gnus-prev-winconf)
6032 (set (make-local-variable 'font-lock-defaults)
6033 '(message-font-lock-keywords t))
6034 (set (make-local-variable 'mail-header-separator) "")
6035 (set (make-local-variable 'gnus-article-edit-mode) t)
6036 (easy-menu-add message-mode-field-menu message-mode-map)
6037 (setq buffer-read-only nil)
6038 (buffer-enable-undo)
6041 (defun gnus-article-edit (&optional force)
6042 "Edit the current article.
6043 This will have permanent effect only in mail groups.
6044 If FORCE is non-nil, allow editing of articles even in read-only
6047 (when (and (not force)
6048 (gnus-group-read-only-p))
6049 (error "The current newsgroup does not support article editing"))
6050 (gnus-article-date-original)
6051 (gnus-article-edit-article
6053 `(lambda (no-highlight)
6055 (gnus-summary-edit-article-done
6056 ,(or (mail-header-references gnus-current-headers) "")
6057 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
6059 (defun gnus-article-edit-article (start-func exit-func)
6060 "Start editing the contents of the current article buffer."
6061 (let ((winconf (current-window-configuration)))
6062 (set-buffer gnus-article-buffer)
6063 (let ((message-auto-save-directory
6064 ;; Don't associate the article buffer with a draft file.
6066 (gnus-article-edit-mode))
6067 (funcall start-func)
6068 (set-buffer-modified-p nil)
6069 (gnus-configure-windows 'edit-article)
6070 (setq gnus-article-edit-done-function exit-func)
6071 (setq gnus-prev-winconf winconf)
6072 (when gnus-article-edit-article-setup-function
6073 (funcall gnus-article-edit-article-setup-function))
6074 (gnus-message 6 "C-c C-c to end edits; C-c C-k to exit")))
6076 (defun gnus-article-edit-done (&optional arg)
6077 "Update the article edits and exit."
6079 (let ((func gnus-article-edit-done-function)
6080 (buf (current-buffer))
6081 (start (window-start))
6083 (winconf gnus-prev-winconf))
6084 (remove-hook 'gnus-article-mode-hook
6085 'gnus-article-mime-edit-article-unwind)
6086 (widen) ;; Widen it in case that users narrowed the buffer.
6089 ;; The cache and backlog have to be flushed somewhat.
6090 (when gnus-keep-backlog
6091 (gnus-backlog-remove-article
6092 (car gnus-article-current) (cdr gnus-article-current)))
6093 ;; Flush original article as well.
6095 (when (get-buffer gnus-original-article-buffer)
6096 (set-buffer gnus-original-article-buffer)
6097 (setq gnus-original-article nil)))
6098 (when gnus-use-cache
6099 (gnus-cache-update-article
6100 (car gnus-article-current) (cdr gnus-article-current)))
6101 ;; We remove all text props from the article buffer.
6102 (kill-all-local-variables)
6103 (set-text-properties (point-min) (point-max) nil)
6105 (set-window-configuration winconf)
6107 (set-window-start (get-buffer-window buf) start)
6108 (set-window-point (get-buffer-window buf) (point)))
6109 (gnus-summary-show-article))
6111 (defun gnus-article-edit-exit ()
6112 "Exit the article editing without updating."
6114 (when (or (not (buffer-modified-p))
6115 (yes-or-no-p "Article modified; kill anyway? "))
6116 (let ((curbuf (current-buffer))
6118 (window-start (window-start)))
6120 (if (gnus-buffer-live-p gnus-original-article-buffer)
6121 (insert-buffer-substring gnus-original-article-buffer))
6122 (let ((winconf gnus-prev-winconf))
6123 (kill-all-local-variables)
6125 (set-window-configuration winconf)
6126 ;; Tippy-toe some to make sure that point remains where it was.
6127 (save-current-buffer
6129 (set-window-start (get-buffer-window (current-buffer)) window-start)
6131 (gnus-summary-show-article)))
6133 (defun gnus-article-edit-full-stops ()
6134 "Interactively repair spacing at end of sentences."
6137 (goto-char (point-min))
6138 (search-forward-regexp "^$" nil t)
6139 (let ((case-fold-search nil))
6140 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
6143 ;;; Article editing with MIME-Edit
6146 (defcustom gnus-article-mime-edit-article-setup-hook nil
6147 "Hook run after setting up a MIME editing article buffer."
6148 :group 'gnus-article-various
6151 (defun gnus-article-mime-edit-article-unwind ()
6152 "Unwind `gnus-article-buffer' if article editing was given up."
6153 (remove-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6154 (when (featurep 'font-lock)
6155 (setq font-lock-defaults nil)
6156 (font-lock-mode -1))
6157 (when mime-edit-mode-flag
6158 (mime-edit-exit 'nomime 'no-error)
6161 (defun gnus-article-mime-edit-article-setup ()
6162 "Convert current buffer to MIME-Edit buffer and turn on MIME-Edit mode
6163 after replacing with the original article."
6164 (setq gnus-show-mime t)
6165 (setq gnus-article-edit-done-function
6166 `(lambda (&rest args)
6167 (when mime-edit-mode-flag
6168 (let (mime-edit-insert-user-agent-field)
6171 (goto-char (point-min))
6172 (let (case-fold-search)
6173 (when (re-search-forward
6174 (format "^%s$" (regexp-quote mail-header-separator))
6176 (replace-match "")))
6177 (apply ,gnus-article-edit-done-function args)
6180 (buffer-substring-no-properties (point-min) (point-max))
6181 (set-buffer (get-buffer-create gnus-original-article-buffer))
6183 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6184 (set-buffer gnus-article-buffer)
6185 (gnus-article-prepare-display)))
6186 (substitute-key-definition 'gnus-article-edit-done
6187 'gnus-article-mime-edit-done
6188 gnus-article-edit-mode-map)
6189 (substitute-key-definition 'gnus-article-edit-exit
6190 'gnus-article-mime-edit-exit
6191 gnus-article-edit-mode-map)
6193 (insert-buffer-substring gnus-original-article-buffer)
6194 (unless (member (with-current-buffer gnus-summary-buffer
6195 gnus-newsgroup-name)
6196 '("nndraft:delayed" "nndraft:drafts"))
6197 (let ((ofn (symbol-function 'mime-edit-decode-single-part-in-buffer)))
6198 (fset 'mime-edit-decode-single-part-in-buffer
6199 (lambda (&rest args)
6200 (if (let ((content-type (car args)))
6201 (and (eq 'message (mime-content-type-primary-type
6203 (eq 'rfc822 (mime-content-type-subtype
6205 (setcar (cdr args) 'not-decode-text))
6209 (fset 'mime-edit-decode-single-part-in-buffer ofn))))
6210 (when (featurep 'font-lock)
6211 (set (make-local-variable 'font-lock-defaults)
6212 '(message-font-lock-keywords t))
6213 (font-lock-set-defaults)
6214 (turn-on-font-lock))
6215 (set-buffer-modified-p nil)
6216 (delete-other-windows)
6217 (add-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6218 (gnus-run-hooks 'gnus-article-mime-edit-article-setup-hook))
6220 (defun gnus-article-mime-edit-done (&optional arg)
6221 "Update the article MIME edits and exit."
6223 (when (featurep 'font-lock)
6224 (setq font-lock-defaults nil)
6225 (font-lock-mode -1))
6226 (let ((inhibit-read-only t))
6227 (gnus-article-edit-done arg)))
6229 (defun gnus-article-mime-edit-exit ()
6230 "Exit the article MIME editing without updating."
6232 (when (or (not (buffer-modified-p))
6233 (yes-or-no-p "Article modified; kill anyway? "))
6234 (when (featurep 'font-lock)
6235 (setq font-lock-defaults nil)
6236 (font-lock-mode -1))
6237 (when mime-edit-mode-flag
6238 (let (mime-edit-insert-user-agent-field)
6241 (goto-char (point-min))
6242 (let (case-fold-search)
6243 (when (re-search-forward
6244 (format "^%s$" (regexp-quote mail-header-separator)) nil t)
6245 (replace-match "")))
6246 (let ((winconf gnus-prev-winconf))
6248 (buffer-substring-no-properties (point-min) (point-max))
6249 (set-buffer (get-buffer-create gnus-original-article-buffer))
6251 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6252 (set-buffer gnus-article-buffer)
6253 (gnus-article-prepare-display)
6254 (set-window-configuration winconf))))
6257 ;;; Article highlights
6260 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
6262 ;;; Internal Variables:
6264 (defcustom gnus-button-url-regexp
6265 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
6266 "\\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:]]\\)"
6267 "\\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\\)\\)")
6268 "Regular expression that matches URLs."
6269 :group 'gnus-article-buttons
6272 (defcustom gnus-button-valid-fqdn-regexp
6273 message-valid-fqdn-regexp
6274 "Regular expression that matches a valid FQDN."
6276 :group 'gnus-article-buttons
6279 (defcustom gnus-button-man-handler 'manual-entry
6280 "Function to use for displaying man pages.
6281 The function must take at least one argument with a string naming the
6284 :type '(choice (function-item :tag "Man" manual-entry)
6285 (function-item :tag "Woman" woman)
6286 (function :tag "Other"))
6287 :group 'gnus-article-buttons)
6289 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
6290 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
6291 If the default site is too slow, try to find a CTAN mirror, see
6292 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
6293 the variable `gnus-button-handle-ctan'."
6295 :group 'gnus-article-buttons
6296 :link '(custom-manual "(gnus)Group Parameters")
6297 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
6298 (const "http://tug.ctan.org/tex-archive/")
6299 (const "http://www.dante.de/CTAN/")
6300 (string :tag "Other")))
6302 (defcustom gnus-button-ctan-handler 'browse-url
6303 "Function to use for displaying CTAN links.
6304 The function must take one argument, the string naming the URL."
6306 :type '(choice (function-item :tag "Browse Url" browse-url)
6307 (function :tag "Other"))
6308 :group 'gnus-article-buttons)
6310 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
6311 "Bogus strings removed from CTAN URLs."
6313 :group 'gnus-article-buttons
6314 :type '(choice (const "^/?tex-archive/\\|/")
6315 (regexp :tag "Other")))
6317 (defcustom gnus-button-ctan-directory-regexp
6320 "biblio\\|digests\\|dviware\\|fonts\\|graphics\\|help\\|"
6321 "indexing\\|info\\|language\\|macros\\|support\\|systems\\|"
6322 "tds\\|tools\\|usergrps\\|web\\|nonfree\\|obsolete"
6324 "Regular expression for ctan directories.
6325 It should match all directories in the top level of `gnus-ctan-url'."
6327 :group 'gnus-article-buttons
6330 (defcustom gnus-button-mid-or-mail-regexp
6331 (concat "\\b\\(<?[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t ]*@"
6332 ;; Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
6333 gnus-button-valid-fqdn-regexp
6335 "Regular expression that matches a message ID or a mail address."
6337 :group 'gnus-article-buttons
6340 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
6341 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
6342 Strings like this can be either a message ID or a mail address. If it is one
6343 of the symbols `mid' or `mail', Gnus will always assume that the string is a
6344 message ID or a mail address, respectively. If this variable is set to the
6345 symbol `ask', always query the user what do do. If it is a function, this
6346 function will be called with the string as it's only argument. The function
6347 must return `mid', `mail', `invalid' or `ask'."
6349 :group 'gnus-article-buttons
6350 :type '(choice (function-item :tag "Heuristic function"
6351 gnus-button-mid-or-mail-heuristic)
6356 (defcustom gnus-button-mid-or-mail-heuristic-alist
6357 '((-10.0 . ".+\\$.+@")
6360 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
6361 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
6362 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
6363 (-1.0 . "^[^a-z]+@")
6365 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
6366 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
6367 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
6368 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
6371 (-1.0 . "^[0-9][0-9]")
6373 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
6374 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6375 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
6376 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6378 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
6379 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
6382 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
6384 ;; compensation for TDMA dated mail addresses:
6385 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
6387 (-20.0 . "\\.fsf@") ;; Gnus
6390 (-20.0 . "_-_") ;; Subject change in thread
6392 (-20.0 . "\\.ln@") ;; leafnode
6393 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
6394 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
6396 ;; (5.0 . "") ;; $local_part_len <= 7
6397 (10.0 . "^[^0-9]+@")
6398 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
6399 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
6402 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
6404 (0.5 . "^[A-Z][a-z]")
6405 (0.5 . "^[A-Z][a-z][a-z]")
6406 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
6407 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
6408 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
6410 A negative RATE indicates a message IDs, whereas a positive indicates a mail
6411 address. The REGEXP is processed with `case-fold-search' set to nil."
6413 :group 'gnus-article-buttons
6414 :type '(repeat (cons (number :tag "Rate")
6415 (regexp :tag "Regexp"))))
6417 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
6418 "Guess whether MID-OR-MAIL is a message ID or a mail address.
6419 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
6420 address, `ask' if unsure and `invalid' if the string is invalid."
6421 (let ((case-fold-search nil)
6422 (list gnus-button-mid-or-mail-heuristic-alist)
6423 (result 0) rate regexp lpartlen elem)
6425 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
6426 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
6427 ;; Certain special cases...
6430 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
6431 "^[0-9]+\\.[0-9]+@compuserve\\|"
6432 "@public\\.gmane\\.org")
6434 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
6435 (setq result 'mail))
6436 (when (string-match "@.*@\\| " mid-or-mail)
6437 (gnus-message 8 "`%s' is invalid." mid-or-mail)
6438 (setq result 'invalid))
6439 ;; Nothing more to do, if result is not a number here...
6440 (when (numberp result)
6442 (setq elem (car list)
6446 (when (string-match regexp mid-or-mail)
6447 (setq result (+ result rate))
6449 9 "`%s' matched `%s', rate `%s', result `%s'."
6450 mid-or-mail regexp rate result)))
6451 (when (<= lpartlen 7)
6452 (setq result (+ result 5.0))
6453 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
6454 mid-or-mail result))
6455 (when (>= lpartlen 12)
6456 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
6458 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
6459 ;; Long local part should contain realname if e-mail address,
6460 ;; too many digits: message-id.
6461 ;; $score -= 5.0 + 0.1 * $local_part_len;
6462 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6463 (setq result (+ result rate))
6465 9 "Many digits in `%s', rate `%s', result `%s'."
6466 mid-or-mail rate result))
6467 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6469 ;; Too few vowels [^aeiouy]{4,}.*\@
6470 (setq result (+ result -5.0))
6472 9 "Few vowels in `%s', rate `%s', result `%s'."
6473 mid-or-mail -5.0 result))
6475 (setq result (+ result 5.0))
6477 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6478 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6479 ;; Maybe we should make this a customizable alist: (condition . 'result)
6481 ((symbolp result) result)
6482 ;; Now convert number into proper results:
6483 ((< result -10.0) 'mid)
6484 ((> result 10.0) 'mail)
6487 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6488 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6489 (url-mid (concat "news" ":" mid-or-mail))
6490 (url-mailto (concat "mailto" ":" mid-or-mail)))
6491 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6492 (when (fboundp pref)
6494 ;; get rid of surrounding angles...
6496 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6497 (if (or (eq 'mid guessed) (eq 'mail guessed))
6501 (save-window-excursion
6502 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6505 (cond ((eq pref 'mid)
6506 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6507 (gnus-button-handle-news url-mid))
6509 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6510 (gnus-url-mailto url-mailto))
6511 (t (gnus-message 3 "Invalid string.")))))
6513 (defun gnus-button-handle-custom (url)
6514 "Follow a Custom URL."
6515 (customize-apropos (gnus-url-unhex-string url)))
6517 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6519 ;; FIXME: Maybe we should merge some of the functions that do quite similar
6522 (defun gnus-button-handle-describe-function (url)
6523 "Call `describe-function' when pushing the corresponding URL button."
6526 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6528 (defun gnus-button-handle-describe-variable (url)
6529 "Call `describe-variable' when pushing the corresponding URL button."
6532 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6534 (defun gnus-button-handle-symbol (url)
6535 "Display help on variable or function.
6536 Calls `describe-variable' or `describe-function'."
6537 (let ((sym (intern url)))
6539 ((fboundp sym) (describe-function sym))
6540 ((boundp sym) (describe-variable sym))
6541 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
6543 (defun gnus-button-handle-describe-key (url)
6544 "Call `describe-key' when pushing the corresponding URL button."
6546 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6547 (keys (ignore-errors (eval `(kbd ,key-string)))))
6550 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6552 (defun gnus-button-handle-apropos (url)
6553 "Call `apropos' when pushing the corresponding URL button."
6554 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6556 (defun gnus-button-handle-apropos-command (url)
6557 "Call `apropos' when pushing the corresponding URL button."
6559 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6561 (defun gnus-button-handle-apropos-variable (url)
6562 "Call `apropos' when pushing the corresponding URL button."
6564 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6565 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6567 (defun gnus-button-handle-apropos-documentation (url)
6568 "Call `apropos' when pushing the corresponding URL button."
6570 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6571 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6573 (defun gnus-button-handle-library (url)
6574 "Call `locate-library' when pushing the corresponding URL button."
6575 (gnus-message 9 "url=`%s'" url)
6576 (let* ((lib (locate-library url))
6577 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6579 (gnus-message 1 "Cannot locale library `%s'." url)
6580 (find-file-read-only file))))
6582 (defun gnus-button-handle-ctan (url)
6583 "Call `browse-url' when pushing a CTAN URL button."
6585 gnus-button-ctan-handler
6588 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6590 (defcustom gnus-button-tex-level 5
6591 "*Integer that says how many TeX-related buttons Gnus will show.
6592 The higher the number, the more buttons will appear and the more false
6593 positives are possible. Note that you can set this variable local to
6594 specific groups. Setting it higher in TeX groups is probably a good idea.
6595 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6596 how to set variables in specific groups."
6598 :group 'gnus-article-buttons
6599 :link '(custom-manual "(gnus)Group Parameters")
6602 (defcustom gnus-button-man-level 5
6603 "*Integer that says how many man-related buttons Gnus will show.
6604 The higher the number, the more buttons will appear and the more false
6605 positives are possible. Note that you can set this variable local to
6606 specific groups. Setting it higher in Unix groups is probably a good idea.
6607 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6608 how to set variables in specific groups."
6610 :group 'gnus-article-buttons
6611 :link '(custom-manual "(gnus)Group Parameters")
6614 (defcustom gnus-button-emacs-level 5
6615 "*Integer that says how many emacs-related buttons Gnus will show.
6616 The higher the number, the more buttons will appear and the more false
6617 positives are possible. Note that you can set this variable local to
6618 specific groups. Setting it higher in Emacs or Gnus related groups is
6619 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6620 `gnus-parameters' on how to set variables in specific groups."
6622 :group 'gnus-article-buttons
6623 :link '(custom-manual "(gnus)Group Parameters")
6626 (defcustom gnus-button-message-level 5
6627 "*Integer that says how many buttons for news or mail messages will appear.
6628 The higher the number, the more buttons will appear and the more false
6629 positives are possible."
6630 ;; mail addresses, MIDs, URLs for news, ...
6632 :group 'gnus-article-buttons
6635 (defcustom gnus-button-browse-level 5
6636 "*Integer that says how many buttons for browsing will appear.
6637 The higher the number, the more buttons will appear and the more false
6638 positives are possible."
6639 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6641 :group 'gnus-article-buttons
6644 (defcustom gnus-button-alist
6645 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6646 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6647 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
6648 gnus-button-handle-news 2)
6649 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6650 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6651 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6652 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6653 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
6654 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
6655 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
6656 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6657 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6658 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6659 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6660 ;; RFC 2368 (The mailto URL scheme)
6661 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6662 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6663 ("\\bmailto:\\([^ \n\t]+\\)"
6664 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6666 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6667 gnus-button-ctan-directory-regexp
6668 "[^][>)!;:,'\n\t ]+\\)")
6669 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6670 ((concat "\\btex-archive/\\("
6671 gnus-button-ctan-directory-regexp
6672 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6673 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6676 gnus-button-ctan-directory-regexp
6677 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6678 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6679 ;; This is info (home-grown style) <info://foo/bar+baz>
6680 ("\\binfo://\\([^'\">\n\t ]+\\)"
6681 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6682 ;; Info GNOME style <info:foo#bar_baz>
6683 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6684 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6685 ;; Info KDE style <info:(foo)bar baz>
6686 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6687 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6688 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6689 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6690 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6691 ;; Info links like `C-h i d m CC Mode RET'
6692 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6694 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6695 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6696 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6697 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6698 ;; Emacs help commands
6699 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6700 ;; regexp doesn't match arguments containing ` '.
6701 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6702 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6703 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6704 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6705 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6706 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6707 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6708 ;; The following entries may lead to many false positives so don't enable
6709 ;; them by default (use a high button level).
6710 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
6711 ;; Exclude [.?] for URLs in gmane.emacs.cvs
6712 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6713 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6714 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6715 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6716 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6717 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6718 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6719 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6720 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6721 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6722 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
6723 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6724 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6725 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6726 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6727 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6728 ;; Unlike the other regexps we really have to require quoting
6729 ;; here to determine where it ends.
6730 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6731 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
6732 ("<URL: *\\([^<>]*\\)>"
6733 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6734 ;; RFC 2396 (2.4.3., delims) ...
6735 ("\"URL: *\\([^\"]*\\)\""
6736 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6737 ;; RFC 2396 (2.4.3., delims) ...
6738 ("\"URL: *\\([^\"]*\\)\""
6739 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6741 (gnus-button-url-regexp
6742 0 (>= gnus-button-browse-level 0) browse-url 0)
6744 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
6745 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6746 gnus-button-handle-man 1)
6747 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6748 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
6749 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6750 gnus-button-handle-man 1)
6751 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6752 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6753 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
6754 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6755 ;; MID or mail: To avoid too many false positives we don't try to catch
6756 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6757 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6758 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6759 ;; so that non-ambiguous entries (see above) match first.
6760 (gnus-button-mid-or-mail-regexp
6761 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6762 "*Alist of regexps matching buttons in article bodies.
6764 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6765 REGEXP: is the string (case insensitive) matching text around the button (can
6766 also be Lisp expression evaluating to a string),
6767 BUTTON: is the number of the regexp grouping actually matching the button,
6768 FORM: is a Lisp expression which must eval to true for the button to
6770 CALLBACK: is the function to call when the user push this button, and each
6771 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6773 CALLBACK can also be a variable, in that case the value of that
6774 variable it the real callback function."
6775 :group 'gnus-article-buttons
6776 :type '(repeat (list (choice regexp variable sexp)
6777 (integer :tag "Button")
6779 (function :tag "Callback")
6782 (integer :tag "Regexp group")))))
6784 (defcustom gnus-header-button-alist
6785 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
6786 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6787 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6788 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6789 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6790 0 (>= gnus-button-message-level 0) gnus-button-mailto 0)
6791 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6792 0 (>= gnus-button-browse-level 0) browse-url 0)
6793 ("^Subject:" gnus-button-url-regexp
6794 0 (>= gnus-button-browse-level 0) browse-url 0)
6795 ("^[^:]+:" gnus-button-url-regexp
6796 0 (>= gnus-button-browse-level 0) browse-url 0)
6797 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6798 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6799 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6800 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6801 "*Alist of headers and regexps to match buttons in article heads.
6803 This alist is very similar to `gnus-button-alist', except that each
6804 alist has an additional HEADER element first in each entry:
6806 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6808 HEADER is a regexp to match a header. For a fuller explanation, see
6809 `gnus-button-alist'."
6810 :group 'gnus-article-buttons
6811 :group 'gnus-article-headers
6812 :type '(repeat (list (regexp :tag "Header")
6813 (choice regexp variable)
6814 (integer :tag "Button")
6816 (function :tag "Callback")
6819 (integer :tag "Regexp group")))))
6823 (defun gnus-article-push-button (event)
6824 "Check text under the mouse pointer for a callback function.
6825 If the text under the mouse pointer has a `gnus-callback' property,
6826 call it with the value of the `gnus-data' text property."
6828 (set-buffer (window-buffer (posn-window (event-start event))))
6829 (let* ((pos (posn-point (event-start event)))
6830 (data (get-text-property pos 'gnus-data))
6831 (fun (get-text-property pos 'gnus-callback)))
6834 (funcall fun data))))
6836 (defun gnus-article-press-button ()
6837 "Check text at point for a callback function.
6838 If the text at point has a `gnus-callback' property,
6839 call it with the value of the `gnus-data' text property."
6841 (let ((data (get-text-property (point) 'gnus-data))
6842 (fun (get-text-property (point) 'gnus-callback)))
6844 (funcall fun data))))
6846 (defun gnus-article-prev-button (n)
6847 "Move point to N buttons backward.
6848 If N is negative, move forward instead."
6850 (gnus-article-next-button (- n)))
6852 (defun gnus-article-next-button (n)
6853 "Move point to N buttons forward.
6854 If N is negative, move backward instead."
6856 (let ((function (if (< n 0) 'previous-single-property-change
6857 'next-single-property-change))
6858 (inhibit-point-motion-hooks t)
6860 (limit (if (< n 0) (point-min) (point-max))))
6862 (while (and (not (= limit (point)))
6864 ;; Skip past the current button.
6865 (when (get-text-property (point) 'gnus-callback)
6866 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6867 ;; Go to the next (or previous) button.
6868 (gnus-goto-char (funcall function (point) 'gnus-callback nil limit))
6869 ;; Put point at the start of the button.
6870 (when (and backward (not (get-text-property (point) 'gnus-callback)))
6871 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6872 ;; Skip past intangible buttons.
6873 (when (get-text-property (point) 'intangible)
6877 (gnus-message 5 "No more buttons"))
6880 (defun gnus-article-highlight (&optional force)
6881 "Highlight current article.
6882 This function calls `gnus-article-highlight-headers',
6883 `gnus-article-highlight-citation',
6884 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6885 do the highlighting. See the documentation for those functions."
6886 (interactive (list 'force))
6887 (gnus-article-highlight-headers)
6888 (gnus-article-highlight-citation force)
6889 (gnus-article-highlight-signature)
6890 (gnus-article-add-buttons force)
6891 (gnus-article-add-buttons-to-head))
6893 (defun gnus-article-highlight-some (&optional force)
6894 "Highlight current article.
6895 This function calls `gnus-article-highlight-headers',
6896 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6897 do the highlighting. See the documentation for those functions."
6898 (interactive (list 'force))
6899 (gnus-article-highlight-headers)
6900 (gnus-article-highlight-signature)
6901 (gnus-article-add-buttons))
6903 (defun gnus-article-highlight-headers ()
6904 "Highlight article headers as specified by `gnus-header-face-alist'."
6906 (gnus-with-article-headers
6907 (let (regexp header-face field-face from hpoints fpoints)
6908 (dolist (entry gnus-header-face-alist)
6909 (goto-char (point-min))
6910 (setq regexp (concat "^\\("
6911 (if (string-equal "" (nth 0 entry))
6915 header-face (nth 1 entry)
6916 field-face (nth 2 entry))
6917 (while (and (re-search-forward regexp nil t)
6921 (unless (search-forward ":" nil t)
6923 (when (and header-face
6924 (not (memq (point) hpoints)))
6925 (push (point) hpoints)
6926 (gnus-put-text-property from (point) 'face header-face))
6927 (when (and field-face
6928 (not (memq (setq from (point)) fpoints)))
6930 (if (re-search-forward "^[^ \t]" nil t)
6932 (goto-char (point-max)))
6933 (gnus-put-text-property from (point) 'face field-face)))))))
6935 (defun gnus-article-highlight-signature ()
6936 "Highlight the signature in an article.
6937 It does this by highlighting everything after
6938 `gnus-signature-separator' using `gnus-signature-face'."
6940 (when gnus-signature-face
6941 (gnus-with-article-buffer
6942 (let ((inhibit-point-motion-hooks t))
6944 (when (gnus-article-narrow-to-signature)
6945 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6946 'face gnus-signature-face)))))))
6948 (defun gnus-article-buttonize-signature ()
6949 "Add button to the signature."
6952 (set-buffer gnus-article-buffer)
6953 (let ((inhibit-read-only t)
6954 (inhibit-point-motion-hooks t))
6955 (when (gnus-article-search-signature)
6956 (gnus-article-add-button (match-beginning 0) (match-end 0)
6957 'gnus-signature-toggle
6958 (set-marker (make-marker)
6959 (1+ (match-end 0))))))))
6961 (defun gnus-button-in-region-p (b e prop)
6962 "Say whether PROP exists in the region."
6963 (text-property-not-all b e prop nil))
6965 (defun gnus-article-add-buttons (&optional force)
6966 "Find external references in the article and make buttons of them.
6967 \"External references\" are things like Message-IDs and URLs, as
6968 specified by `gnus-button-alist'."
6969 (interactive (list 'force))
6970 (gnus-with-article-buffer
6971 (let ((inhibit-point-motion-hooks t)
6972 (case-fold-search t)
6973 (alist gnus-button-alist)
6975 ;; Remove all old markers.
6976 (let (marker entry new-list)
6977 (while (setq marker (pop gnus-button-marker-list))
6978 (if (or (< marker (point-min)) (>= marker (point-max)))
6979 (push marker new-list)
6981 (when (setq entry (gnus-button-entry))
6982 (put-text-property (match-beginning (nth 1 entry))
6983 (match-end (nth 1 entry))
6984 'gnus-callback nil))
6985 (set-marker marker nil)))
6986 (setq gnus-button-marker-list new-list))
6987 ;; We skip the headers.
6990 (while (setq entry (pop alist))
6991 (setq regexp (eval (car entry)))
6993 (while (re-search-forward regexp nil t)
6994 (let* ((start (and entry (match-beginning (nth 1 entry))))
6995 (end (and entry (match-end (nth 1 entry))))
6996 (from (match-beginning 0)))
6997 (when (and (or (eq t (nth 2 entry))
6998 (eval (nth 2 entry)))
6999 (not (gnus-button-in-region-p
7000 start end 'gnus-callback)))
7001 ;; That optional form returned non-nil, so we add the
7003 (gnus-article-add-button
7004 start end 'gnus-button-push
7005 (car (push (set-marker (make-marker) from)
7006 gnus-button-marker-list))))))))))
7008 ;; Add buttons to the head of an article.
7009 (defun gnus-article-add-buttons-to-head ()
7010 "Add buttons to the head of the article."
7012 (gnus-with-article-headers
7014 (dolist (entry gnus-header-button-alist)
7015 ;; Each alist entry.
7016 (goto-char (point-min))
7017 (while (re-search-forward (car entry) nil t)
7018 ;; Each header matching the entry.
7019 (setq beg (match-beginning 0))
7020 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
7021 (match-beginning 0))
7024 (while (re-search-forward (eval (nth 1 entry)) end t)
7025 ;; Each match within a header.
7026 (let* ((entry (cdr entry))
7027 (start (match-beginning (nth 1 entry)))
7028 (end (match-end (nth 1 entry)))
7029 (form (nth 2 entry)))
7030 (goto-char (match-end 0))
7032 (gnus-article-add-button
7033 start end (nth 3 entry)
7034 (buffer-substring (match-beginning (nth 4 entry))
7035 (match-end (nth 4 entry)))))))
7036 (goto-char end))))))
7038 ;;; External functions:
7040 (defun gnus-article-add-button (from to fun &optional data)
7041 "Create a button between FROM and TO with callback FUN and data DATA."
7042 (when gnus-article-button-face
7043 (gnus-overlay-put (gnus-make-overlay from to)
7044 'face gnus-article-button-face))
7045 (gnus-add-text-properties
7047 (nconc (and gnus-article-mouse-face
7048 (list gnus-mouse-face-prop gnus-article-mouse-face))
7049 (list 'gnus-callback fun)
7050 (and data (list 'gnus-data data))))
7051 (widget-convert-button 'link from to :action 'gnus-widget-press-button
7052 :button-keymap gnus-widget-button-keymap))
7054 ;;; Internal functions:
7056 (defun gnus-article-set-globals ()
7057 (with-current-buffer gnus-summary-buffer
7058 (gnus-set-global-variables)))
7060 (defun gnus-signature-toggle (end)
7061 (gnus-with-article-buffer
7062 (let ((inhibit-point-motion-hooks t)
7063 (limit (next-single-property-change end 'mime-view-entity
7065 (if (text-property-any end limit 'article-type 'signature)
7067 (gnus-delete-wash-type 'signature)
7068 (gnus-remove-text-properties-when
7069 'article-type 'signature end limit
7070 (cons 'article-type (cons 'signature
7071 gnus-hidden-properties))))
7072 (gnus-add-wash-type 'signature)
7073 (gnus-add-text-properties-when
7074 'article-type nil end limit
7075 (cons 'article-type (cons 'signature
7076 gnus-hidden-properties)))))
7077 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
7078 (gnus-set-mode-line 'article))))
7080 (defun gnus-button-entry ()
7081 ;; Return the first entry in `gnus-button-alist' matching this place.
7082 (let ((alist gnus-button-alist)
7085 (setq entry (pop alist))
7086 (if (looking-at (eval (car entry)))
7091 (defun gnus-button-push (marker)
7092 ;; Push button starting at MARKER.
7095 (let* ((entry (gnus-button-entry))
7096 (inhibit-point-motion-hooks t)
7098 (args (mapcar (lambda (group)
7099 (let ((string (match-string group)))
7100 (set-text-properties
7101 0 (length string) nil string)
7108 (fboundp (symbol-value fun)))
7109 (apply (symbol-value fun) args))
7111 (gnus-message 1 "You must define `%S' to use this button"
7112 (cons fun args)))))))
7114 (defun gnus-parse-news-url (url)
7115 (let (scheme server group message-id articles)
7118 (goto-char (point-min))
7119 (when (looking-at "\\([A-Za-z]+\\):")
7120 (setq scheme (match-string 1))
7121 (goto-char (match-end 0)))
7122 (when (looking-at "//\\([^/]+\\)/")
7123 (setq server (match-string 1))
7124 (goto-char (match-end 0)))
7127 ((looking-at "\\(.*@.*\\)")
7128 (setq message-id (match-string 1)))
7129 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
7130 (setq group (match-string 1)
7131 articles (split-string (match-string 2) "-")))
7132 ((looking-at "\\([^/]+\\)/?")
7133 (setq group (match-string 1)))
7135 (error "Unknown news URL syntax"))))
7136 (list scheme server group message-id articles)))
7138 (defun gnus-button-handle-news (url)
7140 (destructuring-bind (scheme server group message-id articles)
7141 (gnus-parse-news-url url)
7145 (set-buffer gnus-summary-buffer)
7147 (let ((gnus-refer-article-method (list (list 'nntp server))))
7148 (gnus-summary-refer-article message-id))
7149 (gnus-summary-refer-article message-id))))
7151 (gnus-button-fetch-group url)))))
7153 (defun gnus-button-handle-man (url)
7155 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7156 (when (eq gnus-button-man-handler 'woman)
7157 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
7158 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7159 (funcall gnus-button-man-handler url))
7161 (defun gnus-button-handle-info-url (url)
7162 "Fetch an info URL."
7163 (setq url (mm-subst-char-in-string ?+ ?\ url))
7165 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
7166 (gnus-info-find-node
7167 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
7169 ")" (gnus-url-unhex-string (match-string 2 url)))))
7170 ((string-match "([^)\"]+)[^\"]+" url)
7172 (gnus-replace-in-string
7173 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
7174 (gnus-info-find-node url))
7175 (t (error "Can't parse %s" url))))
7177 (defun gnus-button-handle-info-url-gnome (url)
7178 "Fetch GNOME style info URL."
7179 (setq url (mm-subst-char-in-string ?_ ?\ url))
7180 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
7181 (gnus-info-find-node
7183 (gnus-url-unhex-string
7184 (match-string 1 url))
7186 (or (gnus-url-unhex-string
7187 (match-string 2 url))
7189 (error "Can't parse %s" url)))
7191 (defun gnus-button-handle-info-url-kde (url)
7192 "Fetch KDE style info URL."
7193 (gnus-info-find-node (gnus-url-unhex-string url)))
7195 (defun gnus-button-handle-info-keystrokes (url)
7196 "Call `info' when pushing the corresponding URL button."
7197 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
7202 (defun gnus-button-message-id (message-id)
7204 (with-current-buffer gnus-summary-buffer
7205 (gnus-summary-refer-article message-id)))
7207 (defun gnus-button-fetch-group (address)
7208 "Fetch GROUP specified by ADDRESS."
7209 (if (not (string-match "[:/]" address))
7210 ;; This is just a simple group url.
7211 (gnus-group-read-ephemeral-group address gnus-select-method)
7214 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
7216 (error "Can't parse %s" address)
7217 (gnus-group-read-ephemeral-group
7218 (match-string 4 address)
7219 `(nntp ,(match-string 1 address)
7220 (nntp-address ,(match-string 1 address))
7221 (nntp-port-number ,(if (match-end 3)
7222 (match-string 3 address)
7225 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
7227 (defun gnus-url-parse-query-string (query &optional downcase)
7228 (let (retval pairs cur key val)
7229 (setq pairs (split-string query "&"))
7231 (setq cur (car pairs)
7233 (if (not (string-match "=" cur))
7235 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
7236 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
7238 (setq key (downcase key)))
7239 (setq cur (assoc key retval))
7241 (setcdr cur (cons val (cdr cur)))
7242 (setq retval (cons (list key val) retval)))))
7245 (defun gnus-url-mailto (url)
7246 ;; Send mail to someone
7247 (when (string-match "mailto:/*\\(.*\\)" url)
7248 (setq url (substring url (match-beginning 1) nil)))
7249 (let (to args subject func)
7250 (setq args (gnus-url-parse-query-string
7251 (if (string-match "^\\?" url)
7253 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
7254 (concat "to=" (match-string 1 url) "&"
7255 (match-string 2 url))
7256 (concat "to=" url)))
7258 subject (cdr-safe (assoc "subject" args)))
7261 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
7264 (message-position-on-field (caar args)))
7265 (insert (gnus-replace-in-string
7266 (mapconcat 'identity (reverse (cdar args)) ", ")
7268 (setq args (cdr args)))
7271 (message-goto-subject))))
7273 (defun gnus-button-embedded-url (address)
7274 "Activate ADDRESS with `browse-url'."
7275 (browse-url (gnus-strip-whitespace address)))
7277 ;;; Next/prev buttons in the article buffer.
7279 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
7280 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
7282 (defvar gnus-prev-page-map
7283 (let ((map (make-sparse-keymap)))
7284 (define-key map gnus-mouse-2 'gnus-button-prev-page)
7285 (define-key map "\r" 'gnus-button-prev-page)
7288 (defvar gnus-next-page-map
7289 (let ((map (make-sparse-keymap)))
7290 (unless (>= emacs-major-version 21)
7291 ;; XEmacs doesn't care.
7292 (set-keymap-parent map gnus-article-mode-map))
7293 (define-key map gnus-mouse-2 'gnus-button-next-page)
7294 (define-key map "\r" 'gnus-button-next-page)
7297 (defun gnus-insert-prev-page-button ()
7299 (inhibit-read-only t)
7300 (situation (get-text-property (point-min) 'mime-view-situation)))
7302 gnus-prev-page-line-format nil
7303 `(keymap ,gnus-prev-page-map
7305 gnus-callback gnus-article-button-prev-page
7306 article-type annotation
7307 mime-view-situation ,situation))
7308 (widget-convert-button
7310 ;; Exclude a newline.
7313 :action 'gnus-button-prev-page
7314 :button-keymap gnus-prev-page-map)))
7316 (defun gnus-button-next-page (&optional args more-args)
7317 "Go to the next page."
7319 (let ((win (selected-window)))
7320 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7321 (gnus-article-next-page)
7322 (select-window win)))
7324 (defun gnus-button-prev-page (&optional args more-args)
7325 "Go to the prev page."
7327 (let ((win (selected-window)))
7328 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7329 (gnus-article-prev-page)
7330 (select-window win)))
7332 (defun gnus-insert-next-page-button ()
7334 (inhibit-read-only t)
7335 (situation (get-text-property (point-min) 'mime-view-situation)))
7336 (gnus-eval-format gnus-next-page-line-format nil
7337 `(keymap ,gnus-next-page-map
7339 gnus-callback gnus-article-button-next-page
7340 article-type annotation
7341 mime-view-situation ,situation))
7342 (widget-convert-button
7344 ;; Exclude a newline.
7347 :action 'gnus-button-next-page
7348 :button-keymap gnus-next-page-map)))
7350 (defun gnus-article-button-next-page (arg)
7351 "Go to the next page."
7353 (let ((win (selected-window)))
7354 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7355 (gnus-article-next-page)
7356 (select-window win)))
7358 (defun gnus-article-button-prev-page (arg)
7359 "Go to the prev page."
7361 (let ((win (selected-window)))
7362 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7363 (gnus-article-prev-page)
7364 (select-window win)))
7366 (defvar gnus-decode-header-methods
7367 '(mail-decode-encoded-word-region)
7368 "List of methods used to decode headers.
7370 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
7371 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
7372 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
7373 whose names match REGEXP.
7376 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
7377 mail-decode-encoded-word-region
7378 (\"chinese\" . rfc1843-decode-region))
7381 (defvar gnus-decode-header-methods-cache nil)
7383 (defun gnus-multi-decode-header (start end)
7384 "Apply the functions from `gnus-encoded-word-methods' that match."
7385 (unless (and gnus-decode-header-methods-cache
7386 (eq gnus-newsgroup-name
7387 (car gnus-decode-header-methods-cache)))
7388 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
7391 (nconc gnus-decode-header-methods-cache (list x))
7392 (if (and gnus-newsgroup-name
7393 (string-match (car x) gnus-newsgroup-name))
7394 (nconc gnus-decode-header-methods-cache
7396 gnus-decode-header-methods))
7397 (let ((xlist gnus-decode-header-methods-cache))
7400 (narrow-to-region start end)
7402 (funcall (pop xlist) (point-min) (point-max))))))
7405 ;;; Treatment top-level handling.
7408 (defun gnus-treat-article (condition &optional part-number total-parts type)
7409 (let ((length (- (point-max) (point-min)))
7410 (alist gnus-treatment-function-alist)
7411 (article-goto-body-goes-to-point-min-p t)
7415 (let ((list gnus-article-treat-types))
7417 (when (string-match (pop list) type)
7418 (throw 'found t)))))))
7419 (highlightp (gnus-visual-p 'article-highlight 'highlight))
7420 (entity (static-unless (featurep 'xemacs)
7421 (when (eq 'head condition)
7422 (get-text-property (point-min) 'mime-view-entity))))
7423 val elem buttonized)
7424 (gnus-run-hooks 'gnus-part-display-hook)
7425 (unless gnus-inhibit-treatment
7426 (dolist (elem alist)
7429 (when (gnus-buffer-live-p gnus-summary-buffer)
7430 (set-buffer gnus-summary-buffer))
7431 (symbol-value (car elem))))
7432 (when (and (or (consp val)
7434 (gnus-treat-predicate val)
7435 (or (not (get (car elem) 'highlight))
7437 (when (and (not buttonized)
7439 '(gnus-treat-hide-signature
7440 gnus-treat-highlight-signature)))
7441 (gnus-article-buttonize-signature)
7442 (setq buttonized t))
7444 (funcall (cadr elem)))))
7445 ;; FSF Emacsen does not inherit the existing text properties
7446 ;; in the new text, so we should do it for `mime-view-entity'.
7447 (static-unless (featurep 'xemacs)
7449 (put-text-property (point-min) (point-max)
7450 'mime-view-entity entity))))))
7452 ;; Dynamic variables.
7454 (defvar part-number)
7455 (defvar total-parts)
7460 (defun gnus-treat-predicate (val)
7465 (stringp (car val)))
7466 (apply 'gnus-or (mapcar `(lambda (s)
7467 (string-match s ,(or gnus-newsgroup-name "")))
7470 (let ((pred (pop val)))
7473 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
7475 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
7477 (not (gnus-treat-predicate (car val))))
7479 (equal (car val) type))
7481 (error "%S is not a valid predicate" pred)))))
7491 (eq part-number total-parts))
7495 (error "%S is not a valid value" val))))
7497 (defun gnus-article-encrypt-body (protocol &optional n)
7498 "Encrypt the article body."
7501 (or gnus-article-encrypt-protocol
7502 (completing-read "Encrypt protocol: "
7503 gnus-article-encrypt-protocol-alist
7505 current-prefix-arg))
7506 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7508 (error (format "Can't find the encrypt protocol %s" protocol)))
7509 (if (member gnus-newsgroup-name '("nndraft:delayed"
7512 (error "Can't encrypt the article in group %s"
7513 gnus-newsgroup-name))
7514 (gnus-summary-iterate n
7516 (set-buffer gnus-summary-buffer)
7517 (let ((mail-parse-charset gnus-newsgroup-charset)
7518 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7519 (summary-buffer gnus-summary-buffer)
7521 (gnus-set-global-variables)
7522 (when (gnus-group-read-only-p)
7523 (error "The current newsgroup does not support article encrypt"))
7524 (gnus-summary-show-article t)
7526 (or (mail-header-references gnus-current-headers) ""))
7527 (set-buffer gnus-article-buffer)
7528 (let* ((inhibit-read-only t)
7530 (mapcar (lambda (field)
7531 (and (save-restriction
7532 (message-narrow-to-head)
7533 (goto-char (point-min))
7534 (search-forward field nil t))
7536 (message-narrow-to-field)
7538 (delete-region (point-min) (point-max))
7540 '("Content-Type:" "Content-Transfer-Encoding:"
7541 "Content-Disposition:"))))
7542 (message-narrow-to-head)
7543 (message-remove-header "MIME-Version")
7544 (goto-char (point-max))
7545 (setq point (point))
7546 (insert (apply 'concat headers))
7548 (narrow-to-region point (point-max))
7549 (let ((message-options message-options))
7550 (message-options-set 'message-sender user-mail-address)
7551 (message-options-set 'message-recipients user-mail-address)
7552 (message-options-set 'message-sign-encrypt 'not)
7554 (goto-char (point-min))
7555 (insert "MIME-Version: 1.0\n")
7557 (gnus-summary-edit-article-done
7558 references nil summary-buffer t))
7559 (when gnus-keep-backlog
7560 (gnus-backlog-remove-article
7561 (car gnus-article-current) (cdr gnus-article-current)))
7563 (when (get-buffer gnus-original-article-buffer)
7564 (set-buffer gnus-original-article-buffer)
7565 (setq gnus-original-article nil)))
7566 (when gnus-use-cache
7567 (gnus-cache-update-article
7568 (car gnus-article-current) (cdr gnus-article-current))))))))
7570 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7571 "The following specs can be used:
7572 %t The security MIME type
7575 %D Details if button is pressed")
7577 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
7578 "The following specs can be used:
7579 %t The security MIME type
7582 %D Details if button is pressed")
7584 (defvar gnus-mime-security-button-line-format-alist
7585 '((?t gnus-tmp-type ?s)
7586 (?i gnus-tmp-info ?s)
7587 (?d gnus-tmp-details ?s)
7588 (?D gnus-tmp-pressed-details ?s)))
7590 (defvar gnus-mime-security-button-map
7591 (let ((map (make-sparse-keymap)))
7592 (define-key map gnus-mouse-2 'gnus-article-push-button)
7593 (define-key map "\r" 'gnus-article-press-button)
7596 (defvar gnus-mime-security-details-buffer nil)
7598 (defvar gnus-mime-security-button-pressed nil)
7600 (defvar gnus-mime-security-show-details-inline t
7601 "If non-nil, show details in the article buffer.")
7603 (defun gnus-mime-security-verify-or-decrypt (handle)
7604 (mm-remove-parts (cdr handle))
7605 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7606 point (inhibit-read-only t))
7608 (goto-char (car region)))
7610 (narrow-to-region (point) (point))
7611 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7612 (let* ((mm-verify-option 'known)
7613 (mm-decrypt-option 'known)
7614 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7615 (unless (eq nparts (cdr handle))
7616 (mm-destroy-parts (cdr handle))
7617 (setcdr handle nparts))))
7618 (setq point (point))
7619 (gnus-mime-display-security handle)
7620 (goto-char (point-max)))
7622 (delete-region (point) (cdr region))
7623 (set-marker (car region) nil)
7624 (set-marker (cdr region) nil))
7627 (defun gnus-mime-security-show-details (handle)
7628 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7630 (gnus-message 5 "No details.")
7631 (if gnus-mime-security-show-details-inline
7632 (let ((gnus-mime-security-button-pressed
7633 (not (get-text-property (point) 'gnus-mime-details)))
7634 (gnus-mime-security-button-line-format
7635 (get-text-property (point) 'gnus-line-format))
7636 (inhibit-read-only t))
7638 (while (eq (get-text-property (point) 'gnus-line-format)
7639 gnus-mime-security-button-line-format)
7643 (narrow-to-region (point) (point))
7644 (gnus-insert-mime-security-button handle))
7645 (delete-region (point)
7646 (or (text-property-not-all
7649 gnus-mime-security-button-line-format)
7652 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7653 (with-current-buffer gnus-mime-security-details-buffer
7656 (setq gnus-mime-security-details-buffer
7657 (gnus-get-buffer-create "*MIME Security Details*")))
7658 (with-current-buffer gnus-mime-security-details-buffer
7660 (goto-char (point-min)))
7661 (pop-to-buffer gnus-mime-security-details-buffer)))))
7663 (defun gnus-mime-security-press-button (handle)
7665 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7666 (gnus-mime-security-show-details handle)
7667 (gnus-mime-security-verify-or-decrypt handle))))
7669 (defun gnus-insert-mime-security-button (handle &optional displayed)
7670 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7673 (or (nth 2 (assoc protocol mm-verify-function-alist))
7674 (nth 2 (assoc protocol mm-decrypt-function-alist))
7676 (if (equal (car handle) "multipart/signed")
7677 " Signed" " Encrypted")
7680 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7683 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7684 gnus-tmp-pressed-details
7686 (setq gnus-tmp-details
7687 (if gnus-tmp-details
7688 (concat "\n" gnus-tmp-details)
7690 (setq gnus-tmp-pressed-details
7691 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7696 gnus-mime-security-button-line-format
7697 gnus-mime-security-button-line-format-alist
7698 `(keymap ,gnus-mime-security-button-map
7699 gnus-callback gnus-mime-security-press-button
7700 gnus-line-format ,gnus-mime-security-button-line-format
7701 gnus-mime-details ,gnus-mime-security-button-pressed
7702 article-type annotation
7705 ;; Exclude a newline.
7708 (widget-convert-button
7711 :action 'gnus-widget-press-button
7712 :button-keymap gnus-mime-security-button-map
7714 (lambda (widget/window &optional overlay pos)
7715 ;; Needed to properly clear the message due to a bug in
7716 ;; wid-edit (XEmacs only).
7717 (when (boundp 'help-echo-owns-message)
7718 (setq help-echo-owns-message t))
7721 (aref gnus-mouse-2 0))))))
7723 (defun gnus-mime-display-security (handle)
7725 (narrow-to-region (point) (point))
7726 (unless (gnus-unbuttonized-mime-type-p (car handle))
7727 (gnus-insert-mime-security-button handle))
7728 (gnus-mime-display-mixed (cdr handle))
7731 (unless (gnus-unbuttonized-mime-type-p (car handle))
7732 (let ((gnus-mime-security-button-line-format
7733 gnus-mime-security-button-end-line-format))
7734 (gnus-insert-mime-security-button handle)))
7735 (mm-set-handle-multipart-parameter
7737 (cons (set-marker (make-marker) (point-min))
7738 (set-marker (make-marker) (point-max))))))
7744 (defun gnus-article-header-presentation-method (entity situation)
7745 (mime-insert-header entity)
7746 (article-decode-group-name))
7748 (set-alist 'mime-header-presentation-method-alist
7749 'gnus-original-article-mode
7750 #'gnus-article-header-presentation-method)
7752 (defun gnus-mime-preview-quitting-method ()
7753 (mime-preview-kill-buffer)
7754 (delete-other-windows)
7755 (gnus-article-show-summary)
7756 (gnus-summary-select-article gnus-show-all-headers t))
7758 (set-alist 'mime-preview-quitting-method-alist
7759 'gnus-original-article-mode #'gnus-mime-preview-quitting-method)
7761 (set-alist 'mime-preview-following-method-alist
7762 'gnus-original-article-mode #'gnus-following-method)
7764 (set-alist 'mime-preview-over-to-previous-method-alist
7765 'gnus-original-article-mode
7767 (if (> (point-min) 1)
7768 (gnus-article-prev-page)
7769 (gnus-article-read-summary-keys
7770 nil (gnus-character-to-event ?P)))))
7772 (set-alist 'mime-preview-over-to-next-method-alist
7773 'gnus-original-article-mode'
7775 (if (< (point-max) (buffer-size))
7776 (gnus-article-next-page)
7777 (gnus-article-read-summary-keys
7778 nil (gnus-character-to-event ?N)))))
7788 (run-hooks 'gnus-art-load-hook)
7790 ;;; gnus-art.el ends here