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))))
356 :group 'gnus-article-washing)
358 (defcustom gnus-emphasis-alist
360 "\\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)")
365 ("_/" "/_" underline-italic)
366 ("_\\*" "\\*_" underline-bold)
367 ("\\*/" "/\\*" bold-italic)
368 ("_\\*/" "/\\*_" underline-bold-italic))))
372 (format format (car spec) (car (cdr spec)))
373 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
375 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
376 2 3 gnus-emphasis-underline)))
377 "*Alist that says how to fontify certain phrases.
378 Each item looks like this:
380 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
382 The first element is a regular expression to be matched. The second
383 is a number that says what regular expression grouping used to find
384 the entire emphasized word. The third is a number that says what
385 regexp grouping should be displayed and highlighted. The fourth
386 is the face used for highlighting."
387 :type '(repeat (list :value ("" 0 0 default)
389 (integer :tag "Match group")
390 (integer :tag "Emphasize group")
392 :group 'gnus-article-emphasis)
394 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
395 "A regexp to describe whitespace which should not be emphasized.
396 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
397 The former avoids underlining of leading and trailing whitespace,
398 and the latter avoids underlining any whitespace at all."
400 :group 'gnus-article-emphasis
403 (defface gnus-emphasis-bold '((t (:bold t)))
404 "Face used for displaying strong emphasized text (*word*)."
405 :group 'gnus-article-emphasis)
407 (defface gnus-emphasis-italic '((t (:italic t)))
408 "Face used for displaying italic emphasized text (/word/)."
409 :group 'gnus-article-emphasis)
411 (defface gnus-emphasis-underline '((t (:underline t)))
412 "Face used for displaying underlined emphasized text (_word_)."
413 :group 'gnus-article-emphasis)
415 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
416 "Face used for displaying underlined bold emphasized text (_*word*_)."
417 :group 'gnus-article-emphasis)
419 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
420 "Face used for displaying underlined italic emphasized text (_/word/_)."
421 :group 'gnus-article-emphasis)
423 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
424 "Face used for displaying bold italic emphasized text (/*word*/)."
425 :group 'gnus-article-emphasis)
427 (defface gnus-emphasis-underline-bold-italic
428 '((t (:bold t :italic t :underline t)))
429 "Face used for displaying underlined bold italic emphasized text.
430 Example: (_/*word*/_)."
431 :group 'gnus-article-emphasis)
433 (defface gnus-emphasis-strikethru (if (featurep 'xemacs)
434 '((t (:strikethru t)))
435 '((t (:strike-through t))))
436 "Face used for displaying strike-through text (-word-)."
437 :group 'gnus-article-emphasis)
439 (defface gnus-emphasis-highlight-words
440 '((t (:background "black" :foreground "yellow")))
441 "Face used for displaying highlighted words."
442 :group 'gnus-article-emphasis)
444 (defcustom gnus-article-time-format "%a, %d %b %Y %T %Z"
445 "Format for display of Date headers in article bodies.
446 See `format-time-string' for the possible values.
448 The variable can also be function, which should return a complete Date
449 header. The function is called with one argument, the time, which can
450 be fed to `format-time-string'."
451 :type '(choice string function)
452 :link '(custom-manual "(gnus)Article Date")
453 :group 'gnus-article-washing)
456 (autoload 'mail-extract-address-components "mail-extr"))
458 (defcustom gnus-save-all-headers t
459 "*If non-nil, don't remove any headers before saving."
460 :group 'gnus-article-saving
463 (defcustom gnus-prompt-before-saving 'always
464 "*This variable says how much prompting is to be done when saving articles.
465 If it is nil, no prompting will be done, and the articles will be
466 saved to the default files. If this variable is `always', each and
467 every article that is saved will be preceded by a prompt, even when
468 saving large batches of articles. If this variable is neither nil not
469 `always', there the user will be prompted once for a file name for
470 each invocation of the saving commands."
471 :group 'gnus-article-saving
472 :type '(choice (item always)
473 (item :tag "never" nil)
474 (sexp :tag "once" :format "%t\n" :value t)))
476 (defcustom gnus-saved-headers gnus-visible-headers
477 "Headers to keep if `gnus-save-all-headers' is nil.
478 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
479 If that variable is nil, however, all headers that match this regexp
480 will be kept while the rest will be deleted before saving."
481 :group 'gnus-article-saving
484 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
485 "A function to save articles in your favourite format.
486 The function must be interactively callable (in other words, it must
487 be an Emacs command).
489 Gnus provides the following functions:
491 * gnus-summary-save-in-rmail (Rmail format)
492 * gnus-summary-save-in-mail (Unix mail format)
493 * gnus-summary-save-in-folder (MH folder)
494 * gnus-summary-save-in-file (article format)
495 * gnus-summary-save-body-in-file (article body)
496 * gnus-summary-save-in-vm (use VM's folder format)
497 * gnus-summary-write-to-file (article format -- overwrite)."
498 :group 'gnus-article-saving
499 :type '(radio (function-item gnus-summary-save-in-rmail)
500 (function-item gnus-summary-save-in-mail)
501 (function-item gnus-summary-save-in-folder)
502 (function-item gnus-summary-save-in-file)
503 (function-item gnus-summary-save-body-in-file)
504 (function-item gnus-summary-save-in-vm)
505 (function-item gnus-summary-write-to-file)))
507 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
508 "A function generating a file name to save articles in Rmail format.
509 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
510 :group 'gnus-article-saving
513 (defcustom gnus-mail-save-name 'gnus-plain-save-name
514 "A function generating a file name to save articles in Unix mail format.
515 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
516 :group 'gnus-article-saving
519 (defcustom gnus-folder-save-name 'gnus-folder-save-name
520 "A function generating a file name to save articles in MH folder.
521 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
522 :group 'gnus-article-saving
525 (defcustom gnus-file-save-name 'gnus-numeric-save-name
526 "A function generating a file name to save articles in article format.
527 The function is called with NEWSGROUP, HEADERS, and optional
529 :group 'gnus-article-saving
532 (defcustom gnus-split-methods
533 '((gnus-article-archive-name)
534 (gnus-article-nndoc-name))
535 "*Variable used to suggest where articles are to be saved.
536 For instance, if you would like to save articles related to Gnus in
537 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
538 you could set this variable to something like:
540 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
541 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
543 This variable is an alist where the where the key is the match and the
544 value is a list of possible files to save in if the match is non-nil.
546 If the match is a string, it is used as a regexp match on the
547 article. If the match is a symbol, that symbol will be funcalled
548 from the buffer of the article to be saved with the newsgroup as the
549 parameter. If it is a list, it will be evaled in the same buffer.
551 If this form or function returns a string, this string will be used as
552 a possible file name; and if it returns a non-nil list, that list will
553 be used as possible file names."
554 :group 'gnus-article-saving
555 :type '(repeat (choice (list :value (fun) function)
556 (cons :value ("" "") regexp (repeat string))
559 (defcustom gnus-article-display-method-for-mime
560 'gnus-article-display-mime-message
561 "Function to display a MIME message.
562 The function is called from the article buffer."
563 :group 'gnus-article-mime
566 (defcustom gnus-article-display-method-for-traditional
567 'gnus-article-display-traditional-message
568 "*Function to display a traditional message.
569 The function is called from the article buffer."
570 :group 'gnus-article-mime
573 (defcustom gnus-page-delimiter "^\^L"
574 "*Regexp describing what to use as article page delimiters.
575 The default value is \"^\^L\", which is a form linefeed at the
576 beginning of a line."
578 :group 'gnus-article-various)
580 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
581 "*The format specification for the article mode line.
582 See `gnus-summary-mode-line-format' for a closer description.
584 The following additional specs are available:
586 %w The article washing status.
587 %m The number of MIME parts in the article."
589 :group 'gnus-article-various)
591 (defcustom gnus-article-mode-hook nil
592 "*A hook for Gnus article mode."
594 :group 'gnus-article-various)
596 (when (featurep 'xemacs)
597 ;; Extracted from gnus-xmas-define in order to preserve user settings
598 (when (fboundp 'turn-off-scroll-in-place)
599 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
600 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
601 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
603 (defcustom gnus-article-menu-hook nil
604 "*Hook run after the creation of the article mode menu."
606 :group 'gnus-article-various)
608 (defcustom gnus-article-prepare-hook nil
609 "*A hook called after an article has been prepared in the article buffer."
611 :group 'gnus-article-various)
613 (make-obsolete-variable 'gnus-article-hide-pgp-hook
614 "This variable is obsolete in Gnus 5.10.")
616 (defcustom gnus-article-button-face 'bold
617 "Face used for highlighting buttons in the article buffer.
619 An article button is a piece of text that you can activate by pressing
620 `RET' or `mouse-2' above it."
622 :group 'gnus-article-buttons)
624 (defcustom gnus-article-mouse-face 'highlight
625 "Face used for mouse highlighting in the article buffer.
627 Article buttons will be displayed in this face when the cursor is
630 :group 'gnus-article-buttons)
632 (defcustom gnus-signature-face 'gnus-signature-face
633 "Face used for highlighting a signature in the article buffer.
634 Obsolete; use the face `gnus-signature-face' for customizations instead."
636 :group 'gnus-article-highlight
637 :group 'gnus-article-signature)
639 (defface gnus-signature-face
642 "Face used for highlighting a signature in the article buffer."
643 :group 'gnus-article-highlight
644 :group 'gnus-article-signature)
646 (defface gnus-header-from-face
649 (:foreground "spring green"))
652 (:foreground "red3"))
655 "Face used for displaying from headers."
656 :group 'gnus-article-headers
657 :group 'gnus-article-highlight)
659 (defface gnus-header-subject-face
662 (:foreground "SeaGreen3"))
665 (:foreground "red4"))
667 (:bold t :italic t)))
668 "Face used for displaying subject headers."
669 :group 'gnus-article-headers
670 :group 'gnus-article-highlight)
672 (defface gnus-header-newsgroups-face
675 (:foreground "yellow" :italic t))
678 (:foreground "MidnightBlue" :italic t))
681 "Face used for displaying newsgroups headers.
682 In the default setup this face is only used for crossposted
684 :group 'gnus-article-headers
685 :group 'gnus-article-highlight)
687 (defface gnus-header-name-face
690 (:foreground "SeaGreen"))
693 (:foreground "maroon"))
696 "Face used for displaying header names."
697 :group 'gnus-article-headers
698 :group 'gnus-article-highlight)
700 (defface gnus-header-content-face
703 (:foreground "forest green" :italic t))
706 (:foreground "indianred4" :italic t))
709 "Face used for displaying header content."
710 :group 'gnus-article-headers
711 :group 'gnus-article-highlight)
713 (defcustom gnus-header-face-alist
714 '(("From" nil gnus-header-from-face)
715 ("Subject" nil gnus-header-subject-face)
716 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
717 ("" gnus-header-name-face gnus-header-content-face))
718 "*Controls highlighting of article headers.
720 An alist of the form (HEADER NAME CONTENT).
722 HEADER is a regular expression which should match the name of a
723 header and NAME and CONTENT are either face names or nil.
725 The name of each header field will be displayed using the face
726 specified by the first element in the list where HEADER matches
727 the header name and NAME is non-nil. Similarly, the content will
728 be displayed by the first non-nil matching CONTENT face."
729 :group 'gnus-article-headers
730 :group 'gnus-article-highlight
731 :type '(repeat (list (regexp :tag "Header")
733 (item :tag "skip" nil)
734 (face :value default))
735 (choice :tag "Content"
736 (item :tag "skip" nil)
737 (face :value default)))))
739 (defcustom gnus-article-decode-hook
740 '(article-decode-group-name article-decode-idna-rhs)
741 "*Hook run to decode charsets in articles."
742 :group 'gnus-article-headers
745 (defcustom gnus-display-mime-function 'gnus-display-mime
746 "Function to display MIME articles."
747 :group 'gnus-article-mime
750 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
751 "Function used to decode headers.")
753 (defvar gnus-article-dumbquotes-map
773 "Table for MS-to-Latin1 translation.")
775 (defcustom gnus-ignored-mime-types nil
776 "List of MIME types that should be ignored by Gnus."
778 :group 'gnus-article-mime
779 :type '(repeat regexp))
781 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
782 "List of MIME types that should not be given buttons when rendered inline.
783 See also `gnus-buttonized-mime-types' which may override this variable.
784 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
786 :group 'gnus-article-mime
787 :type '(repeat regexp))
789 (defcustom gnus-buttonized-mime-types nil
790 "List of MIME types that should be given buttons when rendered inline.
791 If set, this variable overrides `gnus-unbuttonized-mime-types'.
792 To see e.g. security buttons you could set this to
793 `(\"multipart/signed\")'.
794 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
796 :group 'gnus-article-mime
797 :type '(repeat regexp))
799 (defcustom gnus-inhibit-mime-unbuttonizing nil
800 "If non-nil, all MIME parts get buttons.
801 When nil (the default value), then some MIME parts do not get buttons,
802 as described by the variables `gnus-buttonized-mime-types' and
803 `gnus-unbuttonized-mime-types'."
805 :group 'gnus-article-mime
808 (defcustom gnus-body-boundary-delimiter "_"
809 "String used to delimit header and body.
810 This variable is used by `gnus-article-treat-body-boundary' which can
811 be controlled by `gnus-treat-body-boundary'."
813 :group 'gnus-article-various
814 :type '(choice (item :tag "None" :value nil)
817 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces"
819 "Defines the location of the faces database.
820 For information on obtaining this database of pretty pictures, please
821 see http://www.cs.indiana.edu/picons/ftp/index.html"
823 :type '(repeat directory)
824 :link '(url-link :tag "download"
825 "http://www.cs.indiana.edu/picons/ftp/index.html")
826 :link '(custom-manual "(gnus)Picons")
829 (defun gnus-picons-installed-p ()
830 "Say whether picons are installed on your machine."
831 (let ((installed nil))
832 (dolist (database gnus-picon-databases)
833 (when (file-exists-p database)
837 (defcustom gnus-article-mime-part-function nil
838 "Function called with a MIME handle as the argument.
839 This is meant for people who want to do something automatic based
840 on parts -- for instance, adding Vcard info to a database."
841 :group 'gnus-article-mime
844 (defcustom gnus-mime-multipart-functions nil
845 "An alist of MIME types to functions to display them."
847 :group 'gnus-article-mime
848 :type '(repeat (cons :format "%v" (string :tag "MIME type") function)))
850 (defcustom gnus-article-date-lapsed-new-header nil
851 "Whether the X-Sent and Date headers can coexist.
852 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
853 either replace the old \"Date:\" header (if this variable is nil), or
854 be added below it (otherwise)."
856 :group 'gnus-article-headers
859 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
860 "Function called with a MIME handle as the argument.
861 This is meant for people who want to view first matched part.
862 For `undisplayed-alternative' (default), the first undisplayed
863 part or alternative part is used. For `undisplayed', the first
864 undisplayed part is used. For a function, the first part which
865 the function return t is used. For nil, the first part is
868 :group 'gnus-article-mime
870 (item :tag "first" :value nil)
871 (item :tag "undisplayed" :value undisplayed)
872 (item :tag "undisplayed or alternative"
873 :value undisplayed-alternative)
876 (defcustom gnus-mime-action-alist
877 '(("save to file" . gnus-mime-save-part)
878 ("save and strip" . gnus-mime-save-part-and-strip)
879 ("delete part" . gnus-mime-delete-part)
880 ("display as text" . gnus-mime-inline-part)
881 ("view the part" . gnus-mime-view-part)
882 ("pipe to command" . gnus-mime-pipe-part)
883 ("toggle display" . gnus-article-press-button)
884 ("toggle display" . gnus-article-view-part-as-charset)
885 ("view as type" . gnus-mime-view-part-as-type)
886 ("view internally" . gnus-mime-view-part-internally)
887 ("view externally" . gnus-mime-view-part-externally))
888 "An alist of actions that run on the MIME attachment."
889 :group 'gnus-article-mime
890 :type '(repeat (cons (string :tag "name")
894 ;;; The treatment variables
897 (defvar gnus-part-display-hook nil
898 "Hook called on parts that are to receive treatment.")
900 (defvar gnus-article-treat-custom
901 '(choice (const :tag "Off" nil)
903 (const :tag "Header" head)
904 (const :tag "Last" last)
905 (const :tag "Mime" mime)
906 (integer :tag "Less")
907 (repeat :tag "Groups" regexp)
908 (sexp :tag "Predicate")))
910 (defvar gnus-article-treat-head-custom
911 '(choice (const :tag "Off" nil)
912 (const :tag "Header" head)))
914 (defvar gnus-article-treat-types '("text/plain")
917 (defvar gnus-inhibit-treatment nil
918 "Whether to inhibit treatment.")
920 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
921 "Highlight the signature.
922 Valid values are nil, t, `head', `last', an integer or a predicate.
923 See Info node `(gnus)Customizing Articles'."
924 :group 'gnus-article-treat
925 :link '(custom-manual "(gnus)Customizing Articles")
926 :type gnus-article-treat-custom)
927 (put 'gnus-treat-highlight-signature 'highlight t)
929 (defcustom gnus-treat-buttonize 100000
931 Valid values are nil, t, `head', `last', an integer or a predicate.
932 See Info node `(gnus)Customizing Articles'."
933 :group 'gnus-article-treat
934 :link '(custom-manual "(gnus)Customizing Articles")
935 :type gnus-article-treat-custom)
936 (put 'gnus-treat-buttonize 'highlight t)
938 (defcustom gnus-treat-buttonize-head 'head
939 "Add buttons to the head.
940 Valid values are nil, t, `head', `last', an integer or a predicate.
941 See Info node `(gnus)Customizing Articles' for details."
942 :group 'gnus-article-treat
943 :link '(custom-manual "(gnus)Customizing Articles")
944 :type gnus-article-treat-head-custom)
945 (put 'gnus-treat-buttonize-head 'highlight t)
947 (defcustom gnus-treat-emphasize
948 (and (or window-system
952 Valid values are nil, t, `head', `last', an integer or a predicate.
953 See Info node `(gnus)Customizing Articles' for details."
954 :group 'gnus-article-treat
955 :link '(custom-manual "(gnus)Customizing Articles")
956 :type gnus-article-treat-custom)
957 (put 'gnus-treat-emphasize 'highlight t)
959 (defcustom gnus-treat-strip-cr nil
960 "Remove carriage returns.
961 Valid values are nil, t, `head', `last', an integer or a predicate.
962 See Info node `(gnus)Customizing Articles' for details."
964 :group 'gnus-article-treat
965 :link '(custom-manual "(gnus)Customizing Articles")
966 :type gnus-article-treat-custom)
968 (defcustom gnus-treat-unsplit-urls nil
969 "Remove newlines from within URLs.
970 Valid values are nil, t, `head', `last', an integer or a predicate.
971 See Info node `(gnus)Customizing Articles' for details."
972 :group 'gnus-article-treat
973 :link '(custom-manual "(gnus)Customizing Articles")
974 :type gnus-article-treat-custom)
976 (defcustom gnus-treat-leading-whitespace nil
977 "Remove leading whitespace in headers.
978 Valid values are nil, t, `head', `last', an integer or a predicate.
979 See Info node `(gnus)Customizing Articles' for details."
981 :group 'gnus-article-treat
982 :link '(custom-manual "(gnus)Customizing Articles")
983 :type gnus-article-treat-custom)
985 (defcustom gnus-treat-hide-headers 'head
987 Valid values are nil, t, `head', `last', an integer or a predicate.
988 See Info node `(gnus)Customizing Articles' for details."
989 :group 'gnus-article-treat
990 :link '(custom-manual "(gnus)Customizing Articles")
991 :type gnus-article-treat-head-custom)
993 (defcustom gnus-treat-hide-boring-headers nil
994 "Hide boring headers.
995 Valid values are nil, t, `head', `last', an integer or a predicate.
996 See Info node `(gnus)Customizing Articles' for details."
997 :group 'gnus-article-treat
998 :link '(custom-manual "(gnus)Customizing Articles")
999 :type gnus-article-treat-head-custom)
1001 (defcustom gnus-treat-hide-signature nil
1002 "Hide the signature.
1003 Valid values are nil, t, `head', `last', an integer or a predicate.
1004 See Info node `(gnus)Customizing Articles' for details."
1005 :group 'gnus-article-treat
1006 :link '(custom-manual "(gnus)Customizing Articles")
1007 :type gnus-article-treat-custom)
1009 (defcustom gnus-treat-fill-article nil
1011 Valid values are nil, t, `head', `last', an integer or a predicate.
1012 See Info node `(gnus)Customizing Articles' for details."
1013 :group 'gnus-article-treat
1014 :link '(custom-manual "(gnus)Customizing Articles")
1015 :type gnus-article-treat-custom)
1017 (defcustom gnus-treat-hide-citation nil
1019 Valid values are nil, t, `head', `last', an integer or a predicate.
1020 See Info node `(gnus)Customizing Articles' for details."
1021 :group 'gnus-article-treat
1022 :link '(custom-manual "(gnus)Customizing Articles")
1023 :type gnus-article-treat-custom)
1025 (defcustom gnus-treat-hide-citation-maybe nil
1027 Valid values are nil, t, `head', `last', an integer or a predicate.
1028 See Info node `(gnus)Customizing Articles' for details."
1029 :group 'gnus-article-treat
1030 :link '(custom-manual "(gnus)Customizing Articles")
1031 :type gnus-article-treat-custom)
1033 (defcustom gnus-treat-strip-list-identifiers 'head
1034 "Strip list identifiers from `gnus-list-identifiers`.
1035 Valid values are nil, t, `head', `last', an integer or a predicate.
1036 See Info node `(gnus)Customizing Articles' for details."
1038 :group 'gnus-article-treat
1039 :link '(custom-manual "(gnus)Customizing Articles")
1040 :type gnus-article-treat-custom)
1042 (make-obsolete-variable 'gnus-treat-strip-pgp
1043 "This option is obsolete in Gnus 5.10.")
1045 (defcustom gnus-treat-strip-pem nil
1046 "Strip PEM signatures.
1047 Valid values are nil, t, `head', `last', an integer or a predicate.
1048 See Info node `(gnus)Customizing Articles' for details."
1049 :group 'gnus-article-treat
1050 :link '(custom-manual "(gnus)Customizing Articles")
1051 :type gnus-article-treat-custom)
1053 (defcustom gnus-treat-strip-banner t
1054 "Strip banners from articles.
1055 The banner to be stripped is specified in the `banner' group parameter.
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-custom)
1062 (defcustom gnus-treat-highlight-headers 'head
1063 "Highlight the 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)
1069 (put 'gnus-treat-highlight-headers 'highlight t)
1071 (defcustom gnus-treat-highlight-citation t
1072 "Highlight cited text.
1073 Valid values are nil, t, `head', `last', an integer or a predicate.
1074 See Info node `(gnus)Customizing Articles' for details."
1075 :group 'gnus-article-treat
1076 :link '(custom-manual "(gnus)Customizing Articles")
1077 :type gnus-article-treat-custom)
1078 (put 'gnus-treat-highlight-citation 'highlight t)
1080 (defcustom gnus-treat-date-ut nil
1081 "Display the Date in UT (GMT).
1082 Valid values are nil, t, `head', `last', an integer or a predicate.
1083 See Info node `(gnus)Customizing Articles' for details."
1084 :group 'gnus-article-treat
1085 :link '(custom-manual "(gnus)Customizing Articles")
1086 :type gnus-article-treat-head-custom)
1088 (defcustom gnus-treat-date-local nil
1089 "Display the Date in the local timezone.
1090 Valid values are nil, t, `head', `last', an integer or a predicate.
1091 See Info node `(gnus)Customizing Articles' for details."
1092 :group 'gnus-article-treat
1093 :link '(custom-manual "(gnus)Customizing Articles")
1094 :type gnus-article-treat-head-custom)
1096 (defcustom gnus-treat-date-english nil
1097 "Display the Date in a format that can be read aloud in English.
1098 Valid values are nil, t, `head', `last', an integer or a predicate.
1099 See Info node `(gnus)Customizing Articles' for details."
1101 :group 'gnus-article-treat
1102 :link '(custom-manual "(gnus)Customizing Articles")
1103 :type gnus-article-treat-head-custom)
1105 (defcustom gnus-treat-date-lapsed nil
1106 "Display the Date header in a way that says how much time has elapsed.
1107 Valid values are nil, t, `head', `last', an integer or a predicate.
1108 See Info node `(gnus)Customizing Articles' for details."
1109 :group 'gnus-article-treat
1110 :link '(custom-manual "(gnus)Customizing Articles")
1111 :type gnus-article-treat-head-custom)
1113 (defcustom gnus-treat-date-original nil
1114 "Display the date in the original timezone.
1115 Valid values are nil, t, `head', `last', an integer or a predicate.
1116 See Info node `(gnus)Customizing Articles' for details."
1117 :group 'gnus-article-treat
1118 :link '(custom-manual "(gnus)Customizing Articles")
1119 :type gnus-article-treat-head-custom)
1121 (defcustom gnus-treat-date-iso8601 nil
1122 "Display the date in the ISO8601 format.
1123 Valid values are nil, t, `head', `last', an integer or a predicate.
1124 See Info node `(gnus)Customizing Articles' for details."
1126 :group 'gnus-article-treat
1127 :link '(custom-manual "(gnus)Customizing Articles")
1128 :type gnus-article-treat-head-custom)
1130 (defcustom gnus-treat-date-user-defined nil
1131 "Display the date in a user-defined format.
1132 The format is defined by the `gnus-article-time-format' variable.
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)
1139 (defcustom gnus-treat-strip-headers-in-body t
1140 "Strip the X-No-Archive header line from the beginning of the body.
1141 Valid values are nil, t, `head', `last', an integer or a predicate.
1142 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)
1148 (defcustom gnus-treat-strip-trailing-blank-lines nil
1149 "Strip trailing blank lines.
1150 Valid values are nil, t, `head', `last', an integer or a predicate.
1151 See Info node `(gnus)Customizing Articles' for details."
1152 :group 'gnus-article-treat
1153 :link '(custom-manual "(gnus)Customizing Articles")
1154 :type gnus-article-treat-custom)
1156 (defcustom gnus-treat-strip-leading-blank-lines nil
1157 "Strip leading blank lines.
1158 Valid values are nil, t, `head', `last', an integer or a predicate.
1159 See Info node `(gnus)Customizing Articles' for details."
1160 :group 'gnus-article-treat
1161 :link '(custom-manual "(gnus)Customizing Articles")
1162 :type gnus-article-treat-custom)
1164 (defcustom gnus-treat-strip-multiple-blank-lines nil
1165 "Strip multiple blank lines.
1166 Valid values are nil, t, `head', `last', an integer or a predicate.
1167 See Info node `(gnus)Customizing Articles' for details."
1168 :group 'gnus-article-treat
1169 :link '(custom-manual "(gnus)Customizing Articles")
1170 :type gnus-article-treat-custom)
1172 (defcustom gnus-treat-unfold-headers 'head
1173 "Unfold folded header lines.
1174 Valid values are nil, t, `head', `last', an integer or a predicate.
1175 See Info node `(gnus)Customizing Articles' for details."
1176 :group 'gnus-article-treat
1177 :link '(custom-manual "(gnus)Customizing Articles")
1178 :type gnus-article-treat-custom)
1180 (defcustom gnus-treat-fold-headers nil
1182 Valid values are nil, t, `head', `last', an integer or a predicate.
1183 See Info node `(gnus)Customizing Articles' for details."
1185 :group 'gnus-article-treat
1186 :link '(custom-manual "(gnus)Customizing Articles")
1187 :type gnus-article-treat-custom)
1189 (defcustom gnus-treat-fold-newsgroups 'head
1190 "Fold the Newsgroups and Followup-To headers.
1191 Valid values are nil, t, `head', `last', an integer or a predicate.
1192 See Info node `(gnus)Customizing Articles' for details."
1194 :group 'gnus-article-treat
1195 :link '(custom-manual "(gnus)Customizing Articles")
1196 :type gnus-article-treat-custom)
1198 (defcustom gnus-treat-overstrike t
1199 "Treat overstrike highlighting.
1200 Valid values are nil, t, `head', `last', an integer or a predicate.
1201 See Info node `(gnus)Customizing Articles' for details."
1202 :group 'gnus-article-treat
1203 :link '(custom-manual "(gnus)Customizing Articles")
1204 :type gnus-article-treat-custom)
1205 (put 'gnus-treat-overstrike 'highlight t)
1207 (defcustom gnus-treat-ansi-sequences (if (locate-library "ansi-color") t)
1208 "Treat ANSI SGR control sequences.
1209 Valid values are nil, t, `head', `last', an integer or a predicate.
1210 See Info node `(gnus)Customizing Articles' for details."
1211 :group 'gnus-article-treat
1212 :link '(custom-manual "(gnus)Customizing Articles")
1213 :type gnus-article-treat-custom)
1215 (make-obsolete-variable 'gnus-treat-display-xface
1216 'gnus-treat-display-x-face)
1218 (defcustom gnus-treat-display-x-face
1219 (and (not noninteractive)
1220 (or (eq gnus-article-x-face-command
1221 'x-face-mule-gnus-article-display-x-face)
1222 (and (fboundp 'image-type-available-p)
1223 (image-type-available-p 'xbm)
1224 (string-match "^0x" (shell-command-to-string "uncompface"))
1225 (executable-find "icontopbm"))
1226 (and (featurep 'xemacs)
1229 "Display X-Face headers.
1230 Valid values are nil, t, `head', `last', an integer or a predicate.
1231 See Info node `(gnus)Customizing Articles' and Info node
1232 `(gnus)X-Face' for details."
1233 :group 'gnus-article-treat
1235 :link '(custom-manual "(gnus)Customizing Articles")
1236 :link '(custom-manual "(gnus)X-Face")
1237 :type gnus-article-treat-head-custom
1238 :set (lambda (symbol value)
1241 (cond ((or (boundp symbol) (get symbol 'saved-value))
1243 ((boundp 'gnus-treat-display-xface)
1245 ** gnus-treat-display-xface is an obsolete variable;\
1246 use gnus-treat-display-x-face instead")
1247 (default-value 'gnus-treat-display-xface))
1248 ((get 'gnus-treat-display-xface 'saved-value)
1250 ** gnus-treat-display-xface is an obsolete variable;\
1251 use gnus-treat-display-x-face instead")
1252 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1255 (put 'gnus-treat-display-x-face 'highlight t)
1257 (defcustom gnus-article-should-use-smiley-mule
1258 (not (or (featurep 'xemacs)
1259 (gnus-image-type-available-p 'xpm)
1260 (gnus-image-type-available-p 'pbm)))
1261 "Non-nil means use `smiley-mule' to show smileys rather than `smiley'.
1262 `smiley-mule' is boundled in BITMAP-MULE package. You can set it to t
1263 even if your Emacs supports images. It has no effect on XEmacs."
1264 :group 'gnus-article-various
1266 :get (lambda (symbol)
1267 (and (not noninteractive)
1268 (default-value symbol)
1269 (not (featurep 'xemacs))
1270 (module-installed-p 'smiley-mule)
1272 :set (lambda (symbol value)
1273 (set-default symbol (and (not noninteractive)
1275 (not (featurep 'xemacs))
1276 (module-installed-p 'smiley-mule)
1279 (defvar gnus-article-smiley-mule-loaded-p nil
1280 "Internal variable used to say whether `smiley-mule' is loaded (whether
1281 smiley functions are not overridden by `smiley').")
1283 (defcustom gnus-treat-display-face
1284 (and (not noninteractive)
1285 (or (and (fboundp 'image-type-available-p)
1286 (image-type-available-p 'png))
1287 (and (featurep 'xemacs)
1290 "Display Face headers.
1291 Valid values are nil, t, `head', `last', an integer or a predicate.
1292 See Info node `(gnus)Customizing Articles' and Info node
1293 `(gnus)X-Face' for details."
1294 :group 'gnus-article-treat
1296 :link '(custom-manual "(gnus)Customizing Articles")
1297 :link '(custom-manual "(gnus)X-Face")
1298 :type gnus-article-treat-head-custom)
1299 (put 'gnus-treat-display-face 'highlight t)
1301 (defcustom gnus-treat-display-smileys
1302 (if (and (not noninteractive)
1303 (or (and (featurep 'xemacs)
1305 (gnus-image-type-available-p 'xpm)
1306 (gnus-image-type-available-p 'pbm)
1307 (and (not (featurep 'xemacs))
1309 (module-installed-p 'smiley-mule))))
1313 Valid values are nil, t, `head', `last', an integer or a predicate.
1314 See Info node `(gnus)Customizing Articles' and Info node
1315 `(gnus)Smileys' for details."
1316 :group 'gnus-article-treat
1318 :link '(custom-manual "(gnus)Customizing Articles")
1319 :link '(custom-manual "(gnus)Smileys")
1320 :type gnus-article-treat-custom)
1321 (put 'gnus-treat-display-smileys 'highlight t)
1323 (defcustom gnus-treat-from-picon
1324 (if (and (gnus-image-type-available-p 'xpm)
1325 (gnus-picons-installed-p))
1327 "Display picons in the From header.
1328 Valid values are nil, t, `head', `last', an integer or a predicate.
1329 See Info node `(gnus)Customizing Articles' and Info node
1330 `(gnus)Picons' for details."
1331 :group 'gnus-article-treat
1333 :link '(custom-manual "(gnus)Customizing Articles")
1334 :link '(custom-manual "(gnus)Picons")
1335 :type gnus-article-treat-head-custom)
1336 (put 'gnus-treat-from-picon 'highlight t)
1338 (defcustom gnus-treat-mail-picon
1339 (if (and (gnus-image-type-available-p 'xpm)
1340 (gnus-picons-installed-p))
1342 "Display picons in To and Cc headers.
1343 Valid values are nil, t, `head', `last', an integer or a predicate.
1344 See Info node `(gnus)Customizing Articles' and Info node
1345 `(gnus)Picons' for details."
1346 :group 'gnus-article-treat
1348 :link '(custom-manual "(gnus)Customizing Articles")
1349 :link '(custom-manual "(gnus)Picons")
1350 :type gnus-article-treat-head-custom)
1351 (put 'gnus-treat-mail-picon 'highlight t)
1353 (defcustom gnus-treat-newsgroups-picon
1354 (if (and (gnus-image-type-available-p 'xpm)
1355 (gnus-picons-installed-p))
1357 "Display picons in the Newsgroups and Followup-To headers.
1358 Valid values are nil, t, `head', `last', an integer or a predicate.
1359 See Info node `(gnus)Customizing Articles' and Info node
1360 `(gnus)Picons' for details."
1362 :group 'gnus-article-treat
1364 :link '(custom-manual "(gnus)Customizing Articles")
1365 :link '(custom-manual "(gnus)Picons")
1366 :type gnus-article-treat-head-custom)
1367 (put 'gnus-treat-newsgroups-picon 'highlight t)
1369 (defcustom gnus-treat-body-boundary
1370 (if (and (eq window-system 'x)
1371 (or gnus-treat-newsgroups-picon
1372 gnus-treat-mail-picon
1373 gnus-treat-from-picon))
1375 "Draw a boundary at the end of the headers.
1376 Valid values are nil and `head'.
1377 See Info node `(gnus)Customizing Articles' for details."
1379 :group 'gnus-article-treat
1380 :link '(custom-manual "(gnus)Customizing Articles")
1381 :type gnus-article-treat-head-custom)
1383 (defcustom gnus-treat-capitalize-sentences nil
1384 "Capitalize sentence-starting words.
1385 Valid values are nil, t, `head', `last', an integer or a predicate.
1386 See Info node `(gnus)Customizing Articles' for details."
1388 :group 'gnus-article-treat
1389 :link '(custom-manual "(gnus)Customizing Articles")
1390 :type gnus-article-treat-custom)
1392 (defcustom gnus-treat-wash-html nil
1394 Valid values are nil, t, `head', `last', an integer or a predicate.
1395 See Info node `(gnus)Customizing Articles' for details."
1397 :group 'gnus-article-treat
1398 :link '(custom-manual "(gnus)Customizing Articles")
1399 :type gnus-article-treat-custom)
1401 (defcustom gnus-treat-fill-long-lines nil
1403 Valid values are nil, t, `head', `last', an integer or a predicate.
1404 See Info node `(gnus)Customizing Articles' for details."
1405 :group 'gnus-article-treat
1406 :link '(custom-manual "(gnus)Customizing Articles")
1407 :type gnus-article-treat-custom)
1409 (defcustom gnus-treat-play-sounds nil
1411 Valid values are nil, t, `head', `last', an integer or a predicate.
1412 See Info node `(gnus)Customizing Articles' for details."
1414 :group 'gnus-article-treat
1415 :link '(custom-manual "(gnus)Customizing Articles")
1416 :type gnus-article-treat-custom)
1418 (defcustom gnus-treat-decode-article-as-default-mime-charset nil
1419 "Decode an article as `default-mime-charset'. For instance, if you want to
1420 attempt to decode an article even if the value of `gnus-show-mime' is nil,
1421 you could set this variable to something like: nil for don't decode, t for
1422 decode the body, '(or header t) for the whole article, etc."
1423 :group 'gnus-article-treat
1424 :type '(radio (const :tag "Off" nil)
1425 (const :tag "Decode body" t)
1426 (const :tag "Decode all" (or head t))))
1428 (defcustom gnus-treat-translate nil
1429 "Translate articles from one language to another.
1430 Valid values are nil, t, `head', `last', an integer or a predicate.
1431 See Info node `(gnus)Customizing Articles' for details."
1433 :group 'gnus-article-treat
1434 :link '(custom-manual "(gnus)Customizing Articles")
1435 :type gnus-article-treat-custom)
1437 (defcustom gnus-treat-x-pgp-sig nil
1439 To automatically treat X-PGP-Sig, set it to head.
1440 Valid values are nil, t, `head', `last', an integer or a predicate.
1441 See Info node `(gnus)Customizing Articles' for details."
1442 :group 'gnus-article-treat
1443 :group 'mime-security
1444 :type gnus-article-treat-custom)
1446 (defcustom gnus-treat-monafy nil
1447 "Display body part with mona font.
1448 Valid values are nil, t, `head', `last', an integer or a predicate.
1449 See Info node `(gnus)Customizing Articles' for details."
1450 :group 'gnus-article-treat
1451 :group 'mime-security
1452 :link '(custom-manual "(gnus)Customizing Articles")
1453 :type gnus-article-treat-custom)
1455 (defvar gnus-article-encrypt-protocol-alist
1456 '(("PGP" . mml2015-self-encrypt)))
1458 ;; Set to nil if more than one protocol added to
1459 ;; gnus-article-encrypt-protocol-alist.
1460 (defcustom gnus-article-encrypt-protocol "PGP"
1461 "The protocol used for encrypt articles.
1462 It is a string, such as \"PGP\". If nil, ask user."
1465 :group 'mime-security)
1467 (defvar gnus-article-wash-function nil
1468 "Function used for converting HTML into text.")
1470 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1471 (mm-coding-system-p 'utf-8)
1472 (executable-find idna-program))
1473 "Whether IDNA decoding of headers is used when viewing messages.
1474 This requires GNU Libidn, and by default only enabled if it is found."
1476 :group 'gnus-article-headers
1479 (defcustom gnus-article-over-scroll nil
1480 "If non-nil, allow scrolling the article buffer even when there no more text."
1482 :group 'gnus-article
1485 ;;; Internal variables
1487 (defvar gnus-english-month-names
1488 '("January" "February" "March" "April" "May" "June" "July" "August"
1489 "September" "October" "November" "December"))
1491 (defvar gnus-button-regexp nil)
1492 (defvar gnus-button-marker-list nil)
1493 ;; Regexp matching any of the regexps from `gnus-button-alist'.
1495 (defvar gnus-button-last nil)
1496 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
1498 (defvar article-goto-body-goes-to-point-min-p nil)
1499 (defvar gnus-article-wash-types nil)
1500 (defvar gnus-article-emphasis-alist nil)
1501 (defvar gnus-article-image-alist nil)
1503 (defvar gnus-article-mime-handle-alist-1 nil)
1504 (defvar gnus-treatment-function-alist
1505 '((gnus-treat-decode-article-as-default-mime-charset
1506 gnus-article-decode-article-as-default-mime-charset)
1507 (gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1508 (gnus-treat-monafy gnus-article-monafy)
1509 (gnus-treat-strip-banner gnus-article-strip-banner)
1510 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1511 (gnus-treat-buttonize gnus-article-add-buttons)
1512 (gnus-treat-fill-article gnus-article-fill-cited-article)
1513 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1514 (gnus-treat-strip-cr gnus-article-remove-cr)
1515 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1516 (gnus-treat-date-ut gnus-article-date-ut)
1517 (gnus-treat-date-local gnus-article-date-local)
1518 (gnus-treat-date-english gnus-article-date-english)
1519 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1520 (gnus-treat-date-original gnus-article-date-original)
1521 (gnus-treat-date-user-defined gnus-article-date-user)
1522 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1523 (gnus-treat-display-face gnus-article-display-face)
1524 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1525 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1526 (gnus-treat-hide-signature gnus-article-hide-signature)
1527 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1528 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1529 (gnus-treat-strip-pem gnus-article-hide-pem)
1530 (gnus-treat-from-picon gnus-treat-from-picon)
1531 (gnus-treat-mail-picon gnus-treat-mail-picon)
1532 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1533 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1534 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1535 (gnus-treat-strip-trailing-blank-lines
1536 gnus-article-remove-trailing-blank-lines)
1537 (gnus-treat-strip-leading-blank-lines
1538 gnus-article-strip-leading-blank-lines)
1539 (gnus-treat-strip-multiple-blank-lines
1540 gnus-article-strip-multiple-blank-lines)
1541 (gnus-treat-overstrike gnus-article-treat-overstrike)
1542 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences)
1543 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1544 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1545 ;; Displaying X-Face should be done after unfolding headers
1546 ;; to protect bitmap lines.
1547 (gnus-treat-display-x-face gnus-article-display-x-face)
1548 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1549 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1550 (gnus-treat-display-smileys gnus-treat-smiley)
1551 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1552 (gnus-treat-wash-html gnus-article-wash-html)
1553 (gnus-treat-emphasize gnus-article-emphasize)
1554 (gnus-treat-hide-citation gnus-article-hide-citation)
1555 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1556 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1557 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1558 (gnus-treat-play-sounds gnus-earcon-display)))
1560 (defvar gnus-article-mime-handle-alist nil)
1561 (defvar article-lapsed-timer nil)
1562 (defvar gnus-article-current-summary nil)
1564 (defvar gnus-article-mode-syntax-table
1565 (let ((table (copy-syntax-table text-mode-syntax-table)))
1566 ;; This causes the citation match run O(2^n).
1567 ;; (modify-syntax-entry ?- "w" table)
1568 (modify-syntax-entry ?> ")<" table)
1569 (modify-syntax-entry ?< "(>" table)
1570 ;; make M-. in article buffers work for `foo' strings
1571 (modify-syntax-entry ?' " " table)
1572 (modify-syntax-entry ?` " " table)
1574 "Syntax table used in article mode buffers.
1575 Initialized from `text-mode-syntax-table.")
1577 (defvar gnus-save-article-buffer nil)
1579 (defvar gnus-article-mode-line-format-alist
1580 (nconc '((?w (gnus-article-wash-status) ?s)
1581 (?m (gnus-article-mime-part-status) ?s))
1582 gnus-summary-mode-line-format-alist))
1584 (defvar gnus-number-of-articles-to-be-saved nil)
1586 (defvar gnus-inhibit-hiding nil)
1588 (defvar gnus-article-edit-mode nil)
1590 ;;; Macros for dealing with the article buffer.
1592 (defmacro gnus-with-article-headers (&rest forms)
1594 (set-buffer gnus-article-buffer)
1596 (let ((inhibit-read-only t)
1597 (inhibit-point-motion-hooks t)
1598 (case-fold-search t))
1599 (article-narrow-to-head)
1602 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1603 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1605 (defmacro gnus-with-article-buffer (&rest forms)
1607 (set-buffer gnus-article-buffer)
1608 (let ((inhibit-read-only t))
1611 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1612 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1614 (defun gnus-article-goto-header (header)
1615 "Go to HEADER, which is a regular expression."
1616 (re-search-forward (concat "^\\(" header "\\):") nil t))
1618 (defsubst gnus-article-hide-text (b e props)
1619 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1620 (gnus-add-text-properties-when 'article-type nil b e props)
1621 (when (memq 'intangible props)
1623 (max (1- b) (point-min))
1624 b 'intangible (cddr (memq 'intangible props)))))
1626 (defsubst gnus-article-unhide-text (b e)
1627 "Remove hidden text properties from region between B and E."
1628 (remove-text-properties b e gnus-hidden-properties)
1629 (when (memq 'intangible gnus-hidden-properties)
1630 (put-text-property (max (1- b) (point-min))
1631 b 'intangible nil)))
1633 (defun gnus-article-hide-text-type (b e type)
1634 "Hide text of TYPE between B and E."
1635 (gnus-add-wash-type type)
1636 (gnus-article-hide-text
1637 b e (cons 'article-type (cons type gnus-hidden-properties))))
1639 (defun gnus-article-unhide-text-type (b e type)
1640 "Unhide text of TYPE between B and E."
1641 (gnus-delete-wash-type type)
1642 (remove-text-properties
1643 b e (cons 'article-type (cons type gnus-hidden-properties)))
1644 (when (memq 'intangible gnus-hidden-properties)
1645 (put-text-property (max (1- b) (point-min))
1646 b 'intangible nil)))
1648 (defun gnus-article-hide-text-of-type (type)
1649 "Hide text of TYPE in the current buffer."
1651 (let ((b (point-min))
1653 (while (setq b (text-property-any b e 'article-type type))
1654 (add-text-properties b (incf b) gnus-hidden-properties)))))
1656 (defun gnus-article-delete-text-of-type (type)
1657 "Delete text of TYPE in the current buffer."
1659 (let ((b (point-min)))
1660 (while (setq b (text-property-any b (point-max) 'article-type type))
1662 b (or (text-property-not-all b (point-max) 'article-type type)
1665 (defun gnus-article-delete-invisible-text ()
1666 "Delete all invisible text in the current buffer."
1668 (let ((b (point-min)))
1669 (while (setq b (text-property-any b (point-max) 'invisible t))
1671 b (or (text-property-not-all b (point-max) 'invisible t)
1674 (defun gnus-article-text-type-exists-p (type)
1675 "Say whether any text of type TYPE exists in the buffer."
1676 (text-property-any (point-min) (point-max) 'article-type type))
1678 (defsubst gnus-article-header-rank ()
1679 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1680 (let ((list gnus-sorted-header-list)
1683 (if (looking-at (car list))
1685 (setq list (cdr list))
1689 (defun article-hide-headers (&optional arg delete)
1690 "Hide unwanted headers and possibly sort them as well."
1691 (interactive (gnus-article-hidden-arg))
1692 ;; Lars said that this function might be inhibited.
1693 (if (gnus-article-check-hidden-text 'headers arg)
1695 ;; Show boring headers as well.
1696 (gnus-article-show-hidden-text 'boring-headers)
1697 (when (eq 1 (point-min))
1698 (set-window-start (get-buffer-window (current-buffer)) 1)))
1699 (unless gnus-inhibit-hiding
1700 (let ((inhibit-read-only t)
1701 (case-fold-search t)
1702 (max (1+ (length gnus-sorted-header-list)))
1703 (inhibit-point-motion-hooks t)
1704 (cur (current-buffer))
1705 ignored visible beg)
1707 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1708 ;; group parameters, so we should go to the summary buffer.
1711 (progn (set-buffer gnus-summary-buffer) t)
1713 (setq ignored (when (not gnus-visible-headers)
1714 (cond ((stringp gnus-ignored-headers)
1715 gnus-ignored-headers)
1716 ((listp gnus-ignored-headers)
1717 (mapconcat 'identity
1718 gnus-ignored-headers
1720 visible (cond ((stringp gnus-visible-headers)
1721 gnus-visible-headers)
1722 ((and gnus-visible-headers
1723 (listp gnus-visible-headers))
1724 (mapconcat 'identity
1725 gnus-visible-headers
1729 ;; First we narrow to just the headers.
1730 (article-narrow-to-head)
1731 ;; Hide any "From " lines at the beginning of (mail) articles.
1732 (while (looking-at "From ")
1736 (delete-region (point-min) (point))
1737 (gnus-article-hide-text (point-min) (point)
1738 (nconc (list 'article-type 'headers)
1739 gnus-hidden-properties))))
1740 ;; Then treat the rest of the header lines.
1741 ;; Then we use the two regular expressions
1742 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1743 ;; select which header lines is to remain visible in the
1745 (while (re-search-forward "^[^ \t:]*:" nil t)
1747 ;; Mark the rank of the header.
1749 (point) (1+ (point)) 'message-rank
1750 (if (or (and visible (looking-at visible))
1752 (not (looking-at ignored))))
1753 (gnus-article-header-rank)
1756 (message-sort-headers-1)
1757 (when (setq beg (text-property-any
1758 (point-min) (point-max) 'message-rank (+ 2 max)))
1759 ;; We delete or make invisible the unwanted headers.
1760 (gnus-add-wash-type 'headers)
1763 (add-text-properties
1764 (point-min) (+ 5 (point-min))
1765 '(article-type headers dummy-invisible t))
1766 (delete-region beg (point-max)))
1767 (gnus-article-hide-text-type beg (point-max) 'headers)))))))))
1769 (defun article-hide-boring-headers (&optional arg)
1770 "Toggle hiding of headers that aren't very interesting.
1771 If given a negative prefix, always show; if given a positive prefix,
1773 (interactive (gnus-article-hidden-arg))
1774 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1775 (not gnus-show-all-headers))
1778 (let ((inhibit-read-only t)
1779 (inhibit-point-motion-hooks t))
1780 (article-narrow-to-head)
1781 (dolist (elem gnus-boring-article-headers)
1782 (goto-char (point-min))
1784 ;; Hide empty headers.
1786 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1788 (gnus-article-hide-text-type
1792 (if (re-search-forward "^[^ \t]" nil t)
1796 ;; Hide boring Newsgroups header.
1797 ((eq elem 'newsgroups)
1798 (when (gnus-string-equal
1799 (gnus-fetch-field "newsgroups")
1800 (gnus-group-real-name
1801 (if (boundp 'gnus-newsgroup-name)
1804 (gnus-article-hide-header "newsgroups")))
1805 ((eq elem 'to-address)
1806 (let ((to (message-fetch-field "to"))
1808 (gnus-parameter-to-address
1809 (if (boundp 'gnus-newsgroup-name)
1810 gnus-newsgroup-name ""))))
1811 (when (and to to-address
1814 ;; only one address in To
1815 (nth 1 (mail-extract-address-components to))
1817 (gnus-article-hide-header "to"))))
1819 (let ((to (message-fetch-field "to"))
1821 (gnus-parameter-to-list
1822 (if (boundp 'gnus-newsgroup-name)
1823 gnus-newsgroup-name ""))))
1824 (when (and to to-list
1827 ;; only one address in To
1828 (nth 1 (mail-extract-address-components to))
1830 (gnus-article-hide-header "to"))))
1832 (let ((cc (message-fetch-field "cc"))
1834 (gnus-parameter-to-list
1835 (if (boundp 'gnus-newsgroup-name)
1836 gnus-newsgroup-name ""))))
1837 (when (and cc to-list
1840 ;; only one address in CC
1841 (nth 1 (mail-extract-address-components cc))
1843 (gnus-article-hide-header "cc"))))
1844 ((eq elem 'followup-to)
1845 (when (gnus-string-equal
1846 (message-fetch-field "followup-to")
1847 (message-fetch-field "newsgroups"))
1848 (gnus-article-hide-header "followup-to")))
1849 ((eq elem 'reply-to)
1850 (if (gnus-group-find-parameter
1851 gnus-newsgroup-name 'broken-reply-to)
1852 (gnus-article-hide-header "reply-to")
1853 (let ((from (message-fetch-field "from"))
1854 (reply-to (message-fetch-field "reply-to")))
1861 (lambda (x) (downcase (cadr x)))
1862 (mail-extract-address-components from t))
1865 (lambda (x) (downcase (cadr x)))
1866 (mail-extract-address-components reply-to t))
1868 (gnus-article-hide-header "reply-to")))))
1870 (let ((date (message-fetch-field "date")))
1872 (< (days-between (current-time-string) date)
1874 (gnus-article-hide-header "date"))))
1876 (let ((to (message-fetch-field "to"))
1877 (cc (message-fetch-field "cc")))
1878 (when (> (length to) 1024)
1879 (gnus-article-hide-header "to"))
1880 (when (> (length cc) 1024)
1881 (gnus-article-hide-header "cc"))))
1885 (goto-char (point-min))
1886 (while (re-search-forward "^to:" nil t)
1887 (setq to-count (1+ to-count)))
1888 (when (> to-count 1)
1889 (while (> to-count 0)
1890 (goto-char (point-min))
1892 (re-search-forward "^to:" nil nil to-count)
1894 (narrow-to-region (point) (point-max))
1895 (gnus-article-hide-header "to"))
1896 (setq to-count (1- to-count))))
1897 (goto-char (point-min))
1898 (while (re-search-forward "^cc:" nil t)
1899 (setq cc-count (1+ cc-count)))
1900 (when (> cc-count 1)
1901 (while (> cc-count 0)
1902 (goto-char (point-min))
1904 (re-search-forward "^cc:" nil nil cc-count)
1906 (narrow-to-region (point) (point-max))
1907 (gnus-article-hide-header "cc"))
1908 (setq cc-count (1- cc-count)))))))))))))
1910 (defun gnus-article-hide-header (header)
1912 (goto-char (point-min))
1913 (when (re-search-forward (concat "^" header ":") nil t)
1914 (gnus-article-hide-text-type
1918 (if (re-search-forward "^[^ \t]" nil t)
1923 (defvar gnus-article-normalized-header-length 40
1924 "Length of normalized headers.")
1926 (defun article-normalize-headers ()
1927 "Make all header lines 40 characters long."
1929 (let ((inhibit-read-only t)
1933 (article-narrow-to-head)
1936 ((< (setq column (- (point-at-eol) (point)))
1937 gnus-article-normalized-header-length)
1939 (insert (make-string
1940 (- gnus-article-normalized-header-length column)
1942 ((> column gnus-article-normalized-header-length)
1943 (gnus-put-text-property
1945 (forward-char gnus-article-normalized-header-length)
1952 (forward-line 1))))))
1954 (defun article-treat-dumbquotes ()
1955 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
1956 Note that this function guesses whether a character is a sm*rtq**t* or
1957 not, so it should only be used interactively.
1959 Sm*rtq**t*s are M****s***'s unilateral extension to the
1960 iso-8859-1 character map in an attempt to provide more quoting
1961 characters. If you see something like \\222 or \\264 where
1962 you're expecting some kind of apostrophe or quotation mark, then
1965 (article-translate-strings gnus-article-dumbquotes-map))
1967 (defun article-translate-characters (from to)
1968 "Translate all characters in the body of the article according to FROM and TO.
1969 FROM is a string of characters to translate from; to is a string of
1970 characters to translate to."
1972 (when (article-goto-body)
1973 (let ((inhibit-read-only t)
1974 (x (make-string 225 ?x))
1976 (while (< (incf i) (length x))
1979 (while (< i (length from))
1980 (aset x (aref from i) (aref to i))
1982 (translate-region (point) (point-max) x)))))
1984 (defun article-translate-strings (map)
1985 "Translate all string in the body of the article according to MAP.
1986 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1988 (when (article-goto-body)
1989 (let ((inhibit-read-only t))
1992 (while (search-forward (car elem) nil t)
1993 (replace-match (cadr elem)))))))))
1995 (defun article-treat-overstrike ()
1996 "Translate overstrikes into bold text."
1999 (when (article-goto-body)
2000 (let ((inhibit-read-only t))
2001 (while (search-forward "\b" nil t)
2002 (let ((next (char-after))
2006 previous (char-after))
2010 ;; We do the boldification/underlining by hiding the
2011 ;; overstrikes and putting the proper text property
2015 (gnus-article-hide-text-type start (point) 'overstrike)
2016 (put-text-property (point) end 'face 'bold))
2018 (gnus-article-hide-text-type
2019 (1- (point)) (1+ (point)) 'overstrike)
2021 start (1- (point)) 'face 'underline))
2023 (gnus-article-hide-text-type start (point) 'overstrike)
2025 (point) end 'face 'underline)))))))))
2027 (defun article-treat-ansi-sequences ()
2028 "Translate ANSI SGR control sequences into overlays or extents."
2031 (when (article-goto-body)
2032 (let ((inhibit-read-only t))
2033 (ansi-color-apply-on-region (point) (point-max))))))
2035 (defun gnus-article-treat-unfold-headers ()
2036 "Unfold folded message headers.
2037 Only the headers that fit into the current window width will be
2040 (gnus-with-article-headers
2044 (mail-header-narrow-to-field)
2045 (let ((header (buffer-string)))
2048 (goto-char (point-min))
2049 (while (re-search-forward "\n[\t ]" nil t)
2050 (replace-match " " t t)))
2051 (setq length (- (point-max) (point-min) 1)))
2052 (when (< length (window-width))
2053 (while (re-search-forward "\n[\t ]" nil t)
2054 (replace-match " " t t)))
2055 (goto-char (point-max)))))))
2057 (defun gnus-article-treat-fold-headers ()
2058 "Fold message headers."
2060 (gnus-with-article-headers
2063 (mail-header-narrow-to-field)
2064 (mail-header-fold-field)
2065 (goto-char (point-max))))))
2067 (defun gnus-treat-smiley ()
2068 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2070 (unless (featurep 'xemacs)
2071 (when (and (not gnus-article-should-use-smiley-mule)
2072 gnus-article-smiley-mule-loaded-p)
2073 (load "smiley" nil t)
2074 (setq gnus-article-smiley-mule-loaded-p nil))
2075 (when (and gnus-article-should-use-smiley-mule
2076 (not gnus-article-smiley-mule-loaded-p))
2077 (load "smiley-mule" nil t)
2078 (setq gnus-article-smiley-mule-loaded-p t)))
2079 (gnus-with-article-buffer
2080 (if (memq 'smiley gnus-article-wash-types)
2081 (gnus-delete-images 'smiley)
2083 (let ((images (smiley-region (point) (point-max))))
2085 (gnus-add-wash-type 'smiley)
2086 (dolist (image images)
2087 (gnus-add-image 'smiley image)))))))
2089 (defun gnus-article-remove-images ()
2090 "Remove all images from the article buffer."
2092 (gnus-with-article-buffer
2093 (dolist (elem gnus-article-image-alist)
2094 (gnus-delete-images (car elem)))))
2096 (defun gnus-article-treat-fold-newsgroups ()
2097 "Unfold folded message headers.
2098 Only the headers that fit into the current window width will be
2101 (gnus-with-article-headers
2102 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2104 (mail-header-narrow-to-field)
2105 (while (re-search-forward ", *" nil t)
2106 (replace-match ", " t t))
2107 (mail-header-fold-field)
2108 (goto-char (point-max))))))
2110 (defun gnus-article-treat-body-boundary ()
2111 "Place a boundary line at the end of the headers."
2113 (when (and gnus-body-boundary-delimiter
2114 (> (length gnus-body-boundary-delimiter) 0))
2115 (gnus-with-article-headers
2116 (goto-char (point-max))
2117 (let ((start (point)))
2118 (insert "X-Boundary: ")
2119 (gnus-add-text-properties start (point) '(invisible t intangible t))
2121 (while (>= (1- (window-width)) (length str))
2122 (setq str (concat str gnus-body-boundary-delimiter)))
2123 (substring str 0 (1- (window-width))))
2125 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2127 (defun article-fill-long-lines ()
2128 "Fill lines that are wider than the window width."
2131 (let ((inhibit-read-only t)
2132 (width (window-width (get-buffer-window (current-buffer)))))
2135 (let ((adaptive-fill-mode nil)) ;Why? -sm
2138 (when (>= (current-column) (min fill-column width))
2139 (narrow-to-region (min (1+ (point)) (point-max))
2141 (let ((goback (point-marker)))
2142 (fill-paragraph nil)
2143 (goto-char (marker-position goback)))
2145 (forward-line 1)))))))
2147 (defun article-capitalize-sentences ()
2148 "Capitalize the first word in each sentence."
2151 (let ((inhibit-read-only t)
2152 (paragraph-start "^[\n\^L]"))
2156 (forward-sentence)))))
2158 (defun article-remove-cr ()
2159 "Remove trailing CRs and then translate remaining CRs into LFs."
2162 (let ((inhibit-read-only t))
2163 (goto-char (point-min))
2164 (while (re-search-forward "\r+$" nil t)
2165 (replace-match "" t t))
2166 (goto-char (point-min))
2167 (while (search-forward "\r" nil t)
2168 (replace-match "\n" t t)))))
2170 (defun article-remove-trailing-blank-lines ()
2171 "Remove all trailing blank lines from the article."
2174 (let ((inhibit-read-only t))
2175 (goto-char (point-max))
2179 (while (and (not (bobp))
2180 (looking-at "^[ \t]*$")
2181 (not (gnus-annotation-in-region-p
2182 (point) (point-at-eol))))
2188 (defvar gnus-face-properties-alist))
2190 (defun article-display-face ()
2191 "Display any Face headers in the header."
2193 (let ((wash-face-p buffer-read-only))
2194 (gnus-with-article-headers
2195 ;; When displaying parts, this function can be called several times on
2196 ;; the same article, without any intended toggle semantic (as typing `W
2197 ;; D d' would have). So face deletion must occur only when we come from
2198 ;; an interactive command, that is when the *Article* buffer is
2200 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2201 (gnus-delete-images 'face)
2204 (when (and wash-face-p
2206 (goto-char (point-min))
2207 (not (re-search-forward "^Face:[\t ]*" nil t)))
2208 (gnus-buffer-live-p gnus-original-article-buffer))
2209 (set-buffer gnus-original-article-buffer))
2211 (mail-narrow-to-head)
2212 (while (gnus-article-goto-header "Face")
2213 (setq faces (nconc faces (list (mail-header-field-value)))))))
2214 (dolist (face faces)
2215 (let ((png (gnus-convert-face-to-png face))
2219 (apply 'gnus-create-image png 'png t
2220 (cdr (assq 'png gnus-face-properties-alist))))
2221 (gnus-article-goto-header "from")
2223 (insert "From: [no `from' set]\n")
2225 (gnus-add-wash-type 'face)
2226 (gnus-add-image 'face image)
2227 (gnus-put-image image nil 'face))))))
2230 (defun article-display-x-face (&optional force)
2231 "Look for an X-Face header and display it if present."
2232 (interactive (list 'force))
2233 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2234 (gnus-with-article-headers
2235 ;; Delete the old process, if any.
2236 (when (process-status "article-x-face")
2237 (delete-process "article-x-face"))
2238 ;; See the comment in `article-display-face'.
2239 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2240 ;; We have already displayed X-Faces, so we remove them
2242 (gnus-delete-images 'xface)
2244 (let (x-faces from face)
2246 (when (and wash-face-p
2248 (goto-char (point-min))
2249 (not (re-search-forward
2250 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2251 (gnus-buffer-live-p gnus-original-article-buffer))
2252 ;; If type `W f', use gnus-original-article-buffer,
2253 ;; otherwise use the current buffer because displaying
2254 ;; RFC822 parts calls this function too.
2255 (set-buffer gnus-original-article-buffer))
2257 (mail-narrow-to-head)
2258 (while (gnus-article-goto-header "X-Face")
2259 (push (mail-header-field-value) x-faces))
2260 (setq from (message-fetch-field "from"))))
2261 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2262 ;; single external face.
2263 (when (stringp gnus-article-x-face-command)
2264 (setq x-faces (list (car x-faces))))
2265 (while (and (setq face (pop x-faces))
2266 gnus-article-x-face-command
2268 ;; Check whether this face is censored.
2269 (not gnus-article-x-face-too-ugly)
2270 (and gnus-article-x-face-too-ugly from
2271 (not (string-match gnus-article-x-face-too-ugly
2273 ;; We display the face.
2274 (cond ((stringp gnus-article-x-face-command)
2275 ;; The command is a string, so we interpret the command
2276 ;; as a, well, command, and fork it off.
2277 (let ((process-connection-type nil))
2278 (process-kill-without-query
2280 "article-x-face" nil shell-file-name
2281 shell-command-switch gnus-article-x-face-command))
2284 (process-send-region "article-x-face"
2285 (point-min) (point-max)))
2286 (process-send-eof "article-x-face")))
2287 ((functionp gnus-article-x-face-command)
2288 ;; The command is a lisp function, so we call it.
2289 (funcall gnus-article-x-face-command face))
2291 (error "%s is not a function"
2292 gnus-article-x-face-command)))))))))
2294 (defun article-decode-mime-words ()
2295 "Decode all MIME-encoded words in the article."
2297 (gnus-with-article-buffer
2298 (let ((inhibit-point-motion-hooks t)
2299 (mail-parse-charset gnus-newsgroup-charset)
2300 (mail-parse-ignored-charsets
2301 (with-current-buffer gnus-summary-buffer
2302 gnus-newsgroup-ignored-charsets)))
2303 (mail-decode-encoded-word-region (point-min) (point-max)))))
2305 (defun article-decode-charset (&optional prompt)
2306 "Decode charset-encoded text in the article.
2307 If PROMPT (the prefix), prompt for a coding system to use."
2309 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2310 (inhibit-read-only t)
2311 (mail-parse-charset gnus-newsgroup-charset)
2312 (mail-parse-ignored-charsets
2313 (save-excursion (condition-case nil
2314 (set-buffer gnus-summary-buffer)
2316 gnus-newsgroup-ignored-charsets))
2317 ct cte ctl charset format)
2320 (article-narrow-to-head)
2321 (setq ct (message-fetch-field "Content-Type" t)
2322 cte (message-fetch-field "Content-Transfer-Encoding" t)
2323 ctl (and ct (ignore-errors
2324 (mail-header-parse-content-type ct)))
2327 (mm-read-coding-system "Charset to decode: "))
2329 (mail-content-type-get ctl 'charset)))
2330 format (and ctl (mail-content-type-get ctl 'format)))
2332 (setq cte (mail-header-strip cte)))
2333 (if (and ctl (not (string-match "/" (car ctl))))
2335 (goto-char (point-max)))
2338 (narrow-to-region (point) (point-max))
2339 (when (and (eq mail-parse-charset 'gnus-decoded)
2340 (eq (mm-body-7-or-8) '8bit))
2341 ;; The text code could have been decoded.
2342 (setq charset mail-parse-charset))
2343 (when (and (or (not ctl)
2344 (equal (car ctl) "text/plain"))
2345 (not format)) ;; article with format will decode later.
2347 charset (and cte (intern (downcase
2348 (gnus-strip-whitespace cte))))
2351 (defun article-decode-encoded-words ()
2352 "Remove encoded-word encoding from headers."
2353 (let ((charset (save-excursion
2354 (set-buffer gnus-summary-buffer)
2355 default-mime-charset))
2356 (inhibit-read-only t))
2357 (mime-decode-header-in-buffer charset)))
2359 (defun article-decode-group-name ()
2360 "Decode group names in `Newsgroups:'."
2361 (let ((inhibit-point-motion-hooks t)
2362 (inhibit-read-only t)
2363 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2364 (when (and (or gnus-group-name-charset-method-alist
2365 gnus-group-name-charset-group-alist)
2366 (gnus-buffer-live-p gnus-original-article-buffer))
2368 (article-narrow-to-head)
2369 (with-current-buffer gnus-original-article-buffer
2370 (goto-char (point-min)))
2371 (while (re-search-forward
2372 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2373 (replace-match (save-match-data
2374 (gnus-decode-newsgroups
2375 ;; XXX how to use data in article buffer?
2376 (with-current-buffer gnus-original-article-buffer
2378 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2381 gnus-newsgroup-name method))
2383 (goto-char (point-min))
2384 (with-current-buffer gnus-original-article-buffer
2385 (goto-char (point-min)))
2386 (while (re-search-forward
2387 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2388 (replace-match (save-match-data
2389 (gnus-decode-newsgroups
2390 ;; XXX how to use data in article buffer?
2391 (with-current-buffer gnus-original-article-buffer
2393 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2396 gnus-newsgroup-name method))
2399 (autoload 'idna-to-unicode "idna")
2401 (defun article-decode-idna-rhs ()
2402 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2405 (let ((inhibit-point-motion-hooks t)
2406 (inhibit-read-only t))
2407 (article-narrow-to-head)
2408 (goto-char (point-min))
2409 (while (re-search-forward "@.*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2411 (when (save-match-data
2412 (and (setq ace (match-string 1))
2414 (and (re-search-backward "^[^ \t]" nil t)
2415 (looking-at "From\\|To\\|Cc")))
2416 (setq unicode (idna-to-unicode ace))))
2417 (unless (string= ace unicode)
2418 (replace-match unicode nil nil nil 1)))))))))
2420 (defun article-de-quoted-unreadable (&optional force read-charset)
2421 "Translate a quoted-printable-encoded article.
2422 If FORCE, decode the article whether it is marked as quoted-printable
2424 If READ-CHARSET, ask for a coding system."
2425 (interactive (list 'force current-prefix-arg))
2427 (let ((inhibit-read-only t) type charset)
2428 (if (gnus-buffer-live-p gnus-original-article-buffer)
2429 (with-current-buffer gnus-original-article-buffer
2431 (gnus-fetch-field "content-transfer-encoding"))
2432 (let* ((ct (gnus-fetch-field "content-type"))
2435 (mail-header-parse-content-type ct)))))
2436 (setq charset (and ctl
2437 (mail-content-type-get ctl 'charset)))
2438 (if (stringp charset)
2439 (setq charset (intern (downcase charset)))))))
2441 (setq charset (mm-read-coding-system "Charset: " charset)))
2443 (setq charset gnus-newsgroup-charset))
2445 (and type (let ((case-fold-search t))
2446 (string-match "quoted-printable" type))))
2448 (quoted-printable-decode-region
2449 (point) (point-max) (mm-charset-to-coding-system charset))))))
2451 (defun article-de-base64-unreadable (&optional force read-charset)
2452 "Translate a base64 article.
2453 If FORCE, decode the article whether it is marked as base64 not.
2454 If READ-CHARSET, ask for a coding system."
2455 (interactive (list 'force current-prefix-arg))
2457 (let ((inhibit-read-only t) type charset)
2458 (if (gnus-buffer-live-p gnus-original-article-buffer)
2459 (with-current-buffer gnus-original-article-buffer
2461 (gnus-fetch-field "content-transfer-encoding"))
2462 (let* ((ct (gnus-fetch-field "content-type"))
2465 (mail-header-parse-content-type ct)))))
2466 (setq charset (and ctl
2467 (mail-content-type-get ctl 'charset)))
2468 (if (stringp charset)
2469 (setq charset (intern (downcase charset)))))))
2471 (setq charset (mm-read-coding-system "Charset: " charset)))
2473 (setq charset gnus-newsgroup-charset))
2475 (and type (let ((case-fold-search t))
2476 (string-match "base64" type))))
2479 (narrow-to-region (point) (point-max))
2480 (base64-decode-region (point-min) (point-max))
2481 (mm-decode-coding-region
2482 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2487 (defun article-decode-HZ ()
2488 "Translate a HZ-encoded article."
2492 (let ((inhibit-read-only t))
2493 (rfc1843-decode-region (point-min) (point-max)))))
2495 (defun article-unsplit-urls ()
2496 "Remove the newlines that some other mailers insert into URLs."
2499 (let ((inhibit-read-only t))
2500 (goto-char (point-min))
2501 (while (re-search-forward
2502 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2503 (replace-match "\\1\\3" t)))
2504 (when (interactive-p)
2505 (gnus-treat-article nil))))
2508 (defun article-wash-html (&optional read-charset)
2509 "Format an HTML article.
2510 If READ-CHARSET, ask for a coding system."
2513 (let ((inhibit-read-only t)
2515 (when (gnus-buffer-live-p gnus-original-article-buffer)
2516 (with-current-buffer gnus-original-article-buffer
2517 (let* ((ct (gnus-fetch-field "content-type"))
2520 (mail-header-parse-content-type ct)))))
2521 (setq charset (and ctl
2522 (mail-content-type-get ctl 'charset)))
2523 (when (stringp charset)
2524 (setq charset (intern (downcase charset)))))))
2526 (setq charset (mm-read-coding-system "Charset: " charset)))
2528 (setq charset gnus-newsgroup-charset))
2530 (save-window-excursion
2532 (narrow-to-region (point) (point-max))
2533 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2534 (entry (assq func mm-text-html-washer-alist)))
2536 (setq func (cdr entry)))
2541 (apply (car func) (cdr func))))))))))
2543 (defun gnus-article-wash-html-with-w3 ()
2544 "Wash the current buffer with w3."
2546 (let ((w3-strict-width (window-width))
2547 (url-standalone-mode t)
2548 (url-gateway-unplugged t)
2549 (w3-honor-stylesheets nil))
2551 (w3-region (point-min) (point-max))
2554 (defun gnus-article-wash-html-with-w3m ()
2555 "Wash the current buffer with emacs-w3m."
2558 (narrow-to-region (point) (point-max))
2559 (let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp)
2560 w3m-force-redisplay)
2561 (w3m-region (point-min) (point-max)))
2562 (when (and mm-inline-text-html-with-w3m-keymap
2563 (boundp 'w3m-minor-mode-map)
2565 (add-text-properties
2566 (point-min) (point-max)
2567 (list 'keymap w3m-minor-mode-map
2568 ;; Put the mark meaning this part was rendered by emacs-w3m.
2569 'mm-inline-text-html-with-w3m t)))))
2571 (defun article-hide-list-identifiers ()
2572 "Remove list identifies from the Subject header.
2573 The `gnus-list-identifiers' variable specifies what to do."
2575 (let ((inhibit-point-motion-hooks t)
2576 (regexp (if (consp gnus-list-identifiers)
2577 (mapconcat 'identity gnus-list-identifiers " *\\|")
2578 gnus-list-identifiers))
2579 (inhibit-read-only t))
2583 (article-narrow-to-head)
2584 (goto-char (point-min))
2585 (while (re-search-forward
2586 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2588 (delete-region (match-beginning 2) (match-end 0))
2589 (beginning-of-line))
2590 (when (re-search-forward
2591 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2592 (delete-region (match-beginning 1) (match-end 1))))))))
2594 (defun article-hide-pem (&optional arg)
2595 "Toggle hiding of any PEM headers and signatures in the current article.
2596 If given a negative prefix, always show; if given a positive prefix,
2598 (interactive (gnus-article-hidden-arg))
2599 (unless (gnus-article-check-hidden-text 'pem arg)
2601 (let ((inhibit-read-only t) end)
2602 (goto-char (point-min))
2603 ;; Hide the horrendously ugly "header".
2604 (when (and (search-forward
2605 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2607 (setq end (1+ (match-beginning 0))))
2608 (gnus-add-wash-type 'pem)
2609 (gnus-article-hide-text-type
2611 (if (search-forward "\n\n" nil t)
2615 ;; Hide the trailer as well
2616 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2618 (gnus-article-hide-text-type
2619 (match-beginning 0) (match-end 0) 'pem)))))))
2621 (defun article-strip-banner ()
2622 "Strip the banners specified by the `banner' group parameter and by
2623 `gnus-article-address-banner-alist'."
2627 (let ((inhibit-point-motion-hooks t))
2628 (when (gnus-parameter-banner gnus-newsgroup-name)
2629 (article-really-strip-banner
2630 (gnus-parameter-banner gnus-newsgroup-name)))
2631 (when gnus-article-address-banner-alist
2632 ;; It is necessary to encode from fields before checking,
2633 ;; because `mail-header-parse-addresses' does not work
2634 ;; (reliably) on decoded headers. And more, it is
2635 ;; impossible to use `gnus-fetch-original-field' here,
2636 ;; because `article-strip-banner' may be called in draft
2637 ;; buffers to preview them.
2638 (let ((from (save-restriction
2640 (article-narrow-to-head)
2641 (mail-fetch-field "from"))))
2644 (caar (mail-header-parse-addresses
2645 (mail-encode-encoded-word-string from)))))
2647 (dolist (pair gnus-article-address-banner-alist)
2648 (when (string-match (car pair) from)
2650 (article-really-strip-banner (cdr pair)))))))))))))
2652 (defun article-really-strip-banner (banner)
2653 "Strip the banner specified by the argument."
2656 (let ((inhibit-point-motion-hooks t)
2657 (gnus-signature-limit nil)
2658 (inhibit-read-only t))
2661 ((eq banner 'signature)
2662 (when (gnus-article-narrow-to-signature)
2665 (delete-region (point) (point-max))))
2667 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2668 (while (re-search-forward banner nil t)
2669 (delete-region (match-beginning 0) (match-end 0)))))
2671 (while (re-search-forward banner nil t)
2672 (delete-region (match-beginning 0) (match-end 0)))))))))
2674 (defun article-babel ()
2675 "Translate article using an online translation service."
2678 (gnus-with-article-buffer
2679 (when (article-goto-body)
2680 (let* ((start (point))
2682 (orig (buffer-substring start end))
2683 (trans (babel-as-string orig)))
2685 (narrow-to-region start end)
2686 (delete-region start end)
2689 (defun article-hide-signature (&optional arg)
2690 "Hide the signature in the current article.
2691 If given a negative prefix, always show; if given a positive prefix,
2693 (interactive (gnus-article-hidden-arg))
2699 (article-goto-body))
2700 (goto-char (point-min)))
2701 (unless (gnus-article-check-hidden-text 'signature arg)
2702 (let ((inhibit-read-only t)
2704 (while (setq button (text-property-any button (point-max)
2706 'gnus-signature-toggle))
2707 (setq button (text-property-not-all button (point-max)
2709 'gnus-signature-toggle))
2710 (when (and button (not (eobp)))
2711 (gnus-article-hide-text-type
2713 (next-single-property-change (1+ button) 'mime-view-entity
2716 (gnus-set-mode-line 'article))
2718 (defun article-strip-headers-in-body ()
2719 "Strip offensive headers from bodies."
2723 (let ((case-fold-search t))
2724 (when (looking-at "x-no-archive:")
2725 (gnus-delete-line)))))
2727 (defun article-strip-leading-blank-lines ()
2728 "Remove all blank lines from the beginning of the article."
2731 (let ((inhibit-point-motion-hooks t)
2732 (inhibit-read-only t))
2733 (when (article-goto-body)
2734 (while (and (not (eobp))
2735 (looking-at "[ \t]*$"))
2736 (gnus-delete-line))))))
2738 (defun article-narrow-to-head ()
2739 "Narrow the buffer to the head of the message.
2740 Point is left at the beginning of the narrowed-to region."
2742 (goto-char (point-min))
2743 (if (search-forward "\n\n" nil 1)
2746 (goto-char (point-min)))
2748 (defun article-goto-body ()
2749 "Place point at the start of the body."
2750 (goto-char (point-min))
2752 ;; This variable is only bound when dealing with separate
2754 (article-goto-body-goes-to-point-min-p
2756 ((search-forward "\n\n" nil t)
2759 (goto-char (point-max))
2762 (defun article-strip-multiple-blank-lines ()
2763 "Replace consecutive blank lines with one empty line."
2766 (let ((inhibit-point-motion-hooks t)
2767 (inhibit-read-only t))
2768 ;; First make all blank lines empty.
2770 (while (re-search-forward "^[ \t]+$" nil t)
2771 (unless (gnus-annotation-in-region-p
2772 (match-beginning 0) (match-end 0))
2773 (replace-match "" nil t)))
2774 ;; Then replace multiple empty lines with a single empty line.
2776 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2777 (unless (gnus-annotation-in-region-p
2778 (match-beginning 0) (match-end 0))
2779 (delete-region (match-beginning 1) (match-end 1)))))))
2781 (defun article-strip-leading-space ()
2782 "Remove all white space from the beginning of the lines in the article."
2785 (let ((inhibit-point-motion-hooks t)
2786 (inhibit-read-only t))
2788 (while (re-search-forward "^[ \t]+" nil t)
2789 (replace-match "" t t)))))
2791 (defun article-strip-trailing-space ()
2792 "Remove all white space from the end of the lines in the article."
2795 (let ((inhibit-point-motion-hooks t)
2796 (inhibit-read-only t))
2798 (while (re-search-forward "[ \t]+$" nil t)
2799 (replace-match "" t t)))))
2801 (defun article-strip-blank-lines ()
2802 "Strip leading, trailing and multiple blank lines."
2804 (article-strip-leading-blank-lines)
2805 (article-remove-trailing-blank-lines)
2806 (article-strip-multiple-blank-lines))
2808 (defun article-strip-all-blank-lines ()
2809 "Strip all blank lines."
2812 (let ((inhibit-point-motion-hooks t)
2813 (inhibit-read-only t))
2815 (while (re-search-forward "^[ \t]*\n" nil t)
2816 (replace-match "" t t)))))
2818 (defun gnus-article-narrow-to-signature ()
2819 "Narrow to the signature; return t if a signature is found, else nil."
2820 (let ((inhibit-point-motion-hooks t))
2821 (when (gnus-article-search-signature)
2823 ;; Check whether we have some limits to what we consider
2824 ;; to be a signature.
2825 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2826 (list gnus-signature-limit)))
2828 (while (setq limit (pop limits))
2829 (if (or (and (integerp limit)
2830 (< (- (point-max) (point)) limit))
2832 (< (count-lines (point) (point-max)) limit))
2833 (and (functionp limit)
2835 (and (stringp limit)
2836 (not (re-search-forward limit nil t))))
2837 () ; This limit did not succeed.
2841 (narrow-to-region (point) (point-max))
2844 (defun gnus-article-search-signature ()
2845 "Search the current buffer for the signature separator.
2846 Put point at the beginning of the signature separator."
2847 (let ((cur (point)))
2848 (goto-char (point-max))
2849 (if (if (stringp gnus-signature-separator)
2850 (re-search-backward gnus-signature-separator nil t)
2851 (let ((seps gnus-signature-separator))
2853 (not (re-search-backward (car seps) nil t)))
2860 (defun gnus-article-hidden-arg ()
2861 "Return the current prefix arg as a number, or 0 if no prefix."
2862 (list (if current-prefix-arg
2863 (prefix-numeric-value current-prefix-arg)
2866 (defun gnus-article-check-hidden-text (type arg)
2867 "Return nil if hiding is necessary.
2868 Arg can be nil or a number. nil and positive means hide, negative
2869 means show, 0 means toggle."
2872 (let ((hide (gnus-article-hidden-text-p type)))
2878 (gnus-article-show-hidden-text type)
2881 (if (eq hide 'hidden)
2883 (gnus-article-show-hidden-text type)
2887 (defun gnus-article-hidden-text-p (type)
2888 "Say whether the current buffer contains hidden text of type TYPE."
2889 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2891 (not (get-text-property pos 'invisible))
2892 (not (get-text-property pos 'dummy-invisible)))
2894 (text-property-any (1+ pos) (point-max) 'article-type type)))
2899 (defun gnus-article-show-hidden-text (type &optional dummy)
2900 "Show all hidden text of type TYPE.
2901 Originally it is hide instead of DUMMY."
2902 (let ((inhibit-read-only t)
2903 (inhibit-point-motion-hooks t))
2904 (gnus-remove-text-properties-when
2906 (point-min) (point-max)
2907 (cons 'article-type (cons type
2908 gnus-hidden-properties)))
2909 (gnus-delete-wash-type type)))
2911 (defconst article-time-units
2912 `((year . ,(* 365.25 24 60 60))
2913 (week . ,(* 7 24 60 60))
2914 (day . ,(* 24 60 60))
2918 "Mapping from time units to seconds.")
2920 (defun gnus-article-forward-header ()
2921 "Move point to the start of the next header.
2922 If the current header is a continuation header, this can be several
2927 (if (looking-at "[ \t]+[^ \t]")
2931 (defun article-date-ut (&optional type highlight header)
2932 "Convert DATE date to universal time in the current article.
2933 If TYPE is `local', convert to local time; if it is `lapsed', output
2934 how much time has lapsed since DATE. For `lapsed', the value of
2935 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2936 should replace the \"Date:\" one, or should be added below it."
2937 (interactive (list 'ut t))
2938 (let* ((header (or header
2939 (and (eq 1 (point-min))
2940 (mail-header-date (save-excursion
2941 (set-buffer gnus-summary-buffer)
2942 gnus-current-headers)))
2943 (message-fetch-field "date")
2945 (date (if (vectorp header) (mail-header-date header)
2947 (inhibit-point-motion-hooks t)
2948 bface eface date-pos)
2949 (when (and date (not (string= date "")))
2952 (article-narrow-to-head)
2953 (when (or (and (eq type 'lapsed)
2954 gnus-article-date-lapsed-new-header
2955 ;; Attempt to get the face of X-Sent first.
2956 (re-search-forward "^X-Sent:[ \t]" nil t))
2957 (re-search-forward "^Date:[ \t]" nil t)
2958 ;; If Date is missing, try again for X-Sent.
2959 (re-search-forward "^X-Sent:[ \t]" nil t))
2960 (setq bface (get-text-property (point-at-bol) 'face)
2961 date (or (get-text-property (point-at-bol)
2964 eface (get-text-property (1- (point-at-eol))
2966 (let ((inhibit-read-only t))
2967 ;; Delete any old X-Sent headers.
2968 (when (setq date-pos
2969 (text-property-any (point-min) (point-max)
2970 'article-date-lapsed t))
2971 (goto-char (setq date-pos (set-marker (make-marker) date-pos)))
2972 (delete-region (match-beginning 0)
2973 (progn (forward-line 1) (point))))
2974 (goto-char (point-min))
2975 ;; Delete any old Date headers.
2976 (while (re-search-forward "^Date:[ \t]" nil t)
2978 (setq date-pos (match-beginning 0)))
2979 (unless (and (eq type 'lapsed)
2980 gnus-article-date-lapsed-new-header)
2981 (delete-region (match-beginning 0)
2982 (progn (message-next-header) (point)))))
2985 (goto-char date-pos)
2987 ;; Possibly, Date has been deleted.
2989 (when (and (eq type 'lapsed)
2990 gnus-article-date-lapsed-new-header
2991 (looking-at "Date:"))
2993 (goto-char (point-min)))
2994 (insert (article-make-date-line date type))
2995 (when (eq type 'lapsed)
2996 (put-text-property (point-at-bol) (point)
2997 'article-date-lapsed t))
3001 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
3002 (add-text-properties (match-beginning 1) (1+ (match-end 1))
3003 (list 'original-date date 'face bface))
3004 (put-text-property (match-beginning 2) (match-end 2)
3007 (defun article-make-date-line (date type)
3008 "Return a DATE line of TYPE."
3009 (unless (memq type '(local ut original user iso8601 lapsed english))
3010 (error "Unknown conversion type: %s" type))
3012 (let ((time (date-to-time date)))
3014 ;; Convert to the local timezone.
3016 (concat "Date: " (message-make-date time)))
3017 ;; Convert to Universal Time.
3022 (let* ((e (parse-time-string date))
3023 (tm (apply 'encode-time e))
3025 (ls (- (cadr tm) (car (current-time-zone time)))))
3026 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
3027 ((> ls 65535) (list (1+ ms) (- ls 65536)))
3031 ;; Get the original date from the article.
3032 ((eq type 'original)
3033 (concat "Date: " (if (string-match "\n+$" date)
3034 (substring date 0 (match-beginning 0))
3036 ;; Let the user define the format.
3038 (let ((format (or (condition-case nil
3039 (with-current-buffer gnus-summary-buffer
3040 gnus-article-time-format)
3042 gnus-article-time-format)))
3043 (if (functionp format)
3044 (funcall format time)
3045 (concat "Date: " (format-time-string format time)))))
3048 (let ((tz (car (current-time-zone time))))
3051 (format-time-string "%Y%m%dT%H%M%S" time)
3052 (format "%s%02d%02d"
3053 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
3054 (/ (% (abs tz) 3600) 60)))))
3055 ;; Do an X-Sent lapsed format.
3057 ;; If the date is seriously mangled, the timezone functions are
3058 ;; liable to bug out, so we ignore all errors.
3059 (let* ((now (current-time))
3060 (real-time (subtract-time now time))
3061 (real-sec (and real-time
3062 (+ (* (float (car real-time)) 65536)
3064 (sec (and real-time (abs real-sec)))
3074 ;; This is a bit convoluted, but basically we go
3075 ;; through the time units for years, weeks, etc,
3076 ;; and divide things to see whether that results
3077 ;; in positive answers.
3080 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
3081 ;; The (remaining) seconds are too few to
3082 ;; be divided into this time unit.
3084 ;; It's big enough, so we output it.
3085 (setq sec (- sec (* num (cdr unit))))
3087 (concat (if prev ", " "") (int-to-string
3089 " " (symbol-name (car unit))
3090 (if (> num 1) "s" ""))
3092 article-time-units "")
3093 ;; If dates are odd, then it might appear like the
3094 ;; article was sent in the future.
3097 " in the future"))))))
3098 ;; Display the date in proper English
3100 (let ((dtime (decode-time time)))
3103 (number-to-string (nth 3 dtime))
3104 (let ((digit (% (nth 3 dtime) 10)))
3106 ((memq (nth 3 dtime) '(11 12 13)) "th")
3112 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3114 (number-to-string (nth 5 dtime))
3116 (format "%02d" (nth 2 dtime))
3118 (format "%02d" (nth 1 dtime)))))))
3120 (format "Date: %s (from T-gnus)" date))))
3122 (defun article-date-local (&optional highlight)
3123 "Convert the current article date to the local timezone."
3124 (interactive (list t))
3125 (article-date-ut 'local highlight))
3127 (defun article-date-english (&optional highlight)
3128 "Convert the current article date to something that is proper English."
3129 (interactive (list t))
3130 (article-date-ut 'english highlight))
3132 (defun article-date-original (&optional highlight)
3133 "Convert the current article date to what it was originally.
3134 This is only useful if you have used some other date conversion
3135 function and want to see what the date was before converting."
3136 (interactive (list t))
3137 (article-date-ut 'original highlight))
3139 (defun article-date-lapsed (&optional highlight)
3140 "Convert the current article date to time lapsed since it was sent."
3141 (interactive (list t))
3142 (article-date-ut 'lapsed highlight))
3144 (defun article-update-date-lapsed ()
3145 "Function to be run from a timer to update the lapsed time line."
3146 (let (deactivate-mark)
3151 (set-buffer (window-buffer w))
3152 (when (eq major-mode 'gnus-article-mode)
3153 (let ((mark (point-marker)))
3154 (goto-char (point-min))
3155 (when (re-search-forward "^X-Sent:" nil t)
3156 (article-date-lapsed t))
3157 (goto-char (marker-position mark))
3158 (move-marker mark nil))))
3161 (defun gnus-start-date-timer (&optional n)
3162 "Start a timer to update the X-Sent header in the article buffers.
3163 The numerical prefix says how frequently (in seconds) the function
3168 (gnus-stop-date-timer)
3169 (setq article-lapsed-timer
3170 (run-at-time 1 n 'article-update-date-lapsed)))
3172 (defun gnus-stop-date-timer ()
3173 "Stop the X-Sent timer."
3175 (when article-lapsed-timer
3176 (nnheader-cancel-timer article-lapsed-timer)
3177 (setq article-lapsed-timer nil)))
3179 (defun article-date-user (&optional highlight)
3180 "Convert the current article date to the user-defined format.
3181 This format is defined by the `gnus-article-time-format' variable."
3182 (interactive (list t))
3183 (article-date-ut 'user highlight))
3185 (defun article-date-iso8601 (&optional highlight)
3186 "Convert the current article date to ISO8601."
3187 (interactive (list t))
3188 (article-date-ut 'iso8601 highlight))
3190 ;; (defun article-show-all ()
3191 ;; "Show all hidden text in the article buffer."
3195 ;; (let ((inhibit-read-only t))
3196 ;; (gnus-article-unhide-text (point-min) (point-max))
3197 ;; (gnus-remove-text-with-property 'gnus-prev)
3198 ;; (gnus-remove-text-with-property 'gnus-next))))
3200 (defun article-show-all-headers ()
3201 "Show all hidden headers in the article buffer."
3206 (article-narrow-to-head)
3207 (let ((inhibit-read-only t))
3208 (gnus-article-unhide-text (point-min) (point-max))))))
3210 (defun article-remove-leading-whitespace ()
3211 "Remove excessive whitespace from all headers."
3215 (let ((inhibit-read-only t))
3216 (article-narrow-to-head)
3217 (goto-char (point-min))
3218 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3219 (delete-region (match-beginning 1) (match-end 1)))))))
3221 (defun article-emphasize (&optional arg)
3222 "Emphasize text according to `gnus-emphasis-alist'."
3223 (interactive (gnus-article-hidden-arg))
3224 (unless (gnus-article-check-hidden-text 'emphasis arg)
3228 (with-current-buffer gnus-summary-buffer
3229 gnus-article-emphasis-alist)
3231 gnus-emphasis-alist))
3232 (inhibit-read-only t)
3233 (props (append '(article-type emphasis)
3234 gnus-hidden-properties))
3235 regexp elem beg invisible visible face)
3238 (while (setq elem (pop alist))
3240 (setq regexp (car elem)
3241 invisible (nth 1 elem)
3242 visible (nth 2 elem)
3244 (while (re-search-forward regexp nil t)
3245 (when (and (match-beginning visible) (match-beginning invisible))
3246 (gnus-article-hide-text
3247 (match-beginning invisible) (match-end invisible) props)
3248 (gnus-article-unhide-text-type
3249 (match-beginning visible) (match-end visible) 'emphasis)
3250 (gnus-put-overlay-excluding-newlines
3251 (match-beginning visible) (match-end visible) 'face face)
3252 (gnus-add-wash-type 'emphasis)
3253 (goto-char (match-end invisible)))))))))
3255 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3256 "Setup newsgroup emphasis alist."
3257 (unless gnus-article-emphasis-alist
3258 (let ((name (and gnus-newsgroup-name
3259 (gnus-group-real-name gnus-newsgroup-name))))
3260 (make-local-variable 'gnus-article-emphasis-alist)
3261 (setq gnus-article-emphasis-alist
3263 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3264 (while (setq elem (pop alist))
3265 (when (and name (string-match (car elem) name))
3267 highlight (copy-sequence (cdr elem)))))
3269 (copy-sequence highlight-words)
3270 (if gnus-newsgroup-name
3271 (copy-sequence (gnus-group-find-parameter
3272 gnus-newsgroup-name 'highlight-words t)))
3273 gnus-emphasis-alist)))))
3276 (defvar gnus-summary-article-menu)
3277 (defvar gnus-summary-post-menu))
3279 ;;; Saving functions.
3281 (defun gnus-article-save (save-buffer file &optional num)
3282 "Save the currently selected article."
3283 (unless gnus-save-all-headers
3284 ;; Remove headers according to `gnus-saved-headers'.
3285 (let ((gnus-visible-headers
3286 (or gnus-saved-headers gnus-visible-headers))
3287 (gnus-article-buffer save-buffer))
3289 (set-buffer save-buffer)
3290 (article-hide-headers 1 t))))
3291 (save-window-excursion
3292 (if (not gnus-default-article-saver)
3293 (error "No default saver is defined")
3294 ;; !!! Magic! The saving functions all save
3295 ;; `gnus-save-article-buffer' (or so they think), but we
3296 ;; bind that variable to our save-buffer.
3297 (set-buffer gnus-article-buffer)
3298 (let* ((gnus-save-article-buffer save-buffer)
3301 ((not gnus-prompt-before-saving) 'default)
3302 ((eq gnus-prompt-before-saving 'always) nil)
3304 (gnus-number-of-articles-to-be-saved
3305 (when (eq gnus-prompt-before-saving t)
3307 (set-buffer gnus-article-current-summary)
3308 (funcall gnus-default-article-saver filename)))))
3310 (defun gnus-read-save-file-name (prompt &optional filename
3311 function group headers variable)
3313 (funcall function group headers (symbol-value variable)))
3318 ((eq filename 'default)
3324 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3327 (if (and gnus-number-of-articles-to-be-saved
3328 (> gnus-number-of-articles-to-be-saved 1))
3329 (format "these %d articles"
3330 gnus-number-of-articles-to-be-saved)
3333 ;; Let the split methods have their say.
3335 ;; No split name was found.
3338 (concat prompt " (default "
3339 (file-name-nondirectory default-name) ") ")
3340 (file-name-directory default-name)
3342 ;; A single group name is returned.
3343 ((stringp split-name)
3345 (funcall function split-name headers
3346 (symbol-value variable)))
3348 (concat prompt " (default "
3349 (file-name-nondirectory default-name) ") ")
3350 (file-name-directory default-name)
3352 ;; A single split name was found
3353 ((= 1 (length split-name))
3354 (let* ((name (expand-file-name
3356 gnus-article-save-directory))
3357 (dir (cond ((file-directory-p name)
3358 (file-name-as-directory name))
3359 ((file-exists-p name) name)
3360 (t gnus-article-save-directory))))
3362 (concat prompt " (default " name ") ")
3364 ;; A list of splits was found.
3366 (setq split-name (nreverse split-name))
3368 (let ((file-name-history
3369 (nconc split-name file-name-history)))
3373 (concat prompt " (`M-p' for defaults) ")
3374 gnus-article-save-directory
3376 gnus-article-save-directory)))
3377 (car (push result file-name-history)))))))
3378 ;; Create the directory.
3379 (gnus-make-directory (file-name-directory file))
3380 ;; If we have read a directory, we append the default file name.
3381 (when (file-directory-p file)
3382 (setq file (expand-file-name (file-name-nondirectory
3384 (file-name-as-directory file))))
3385 ;; Possibly translate some characters.
3386 (nnheader-translate-file-chars file))))))
3387 (gnus-make-directory (file-name-directory result))
3388 (set variable result)))
3390 (defun gnus-article-archive-name (group)
3391 "Return the first instance of an \"Archive-name\" in the current buffer."
3392 (let ((case-fold-search t))
3393 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3394 (nnheader-concat gnus-article-save-directory
3395 (match-string 1)))))
3397 (defun gnus-article-nndoc-name (group)
3398 "If GROUP is an nndoc group, return the name of the parent group."
3399 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3400 (gnus-group-get-parameter group 'save-article-group)))
3402 (defun gnus-summary-save-in-rmail (&optional filename)
3403 "Append this article to Rmail file.
3404 Optional argument FILENAME specifies file name.
3405 Directory to save to is default to `gnus-article-save-directory'."
3406 (setq filename (gnus-read-save-file-name
3407 "Save %s in rmail file:" filename
3408 gnus-rmail-save-name gnus-newsgroup-name
3409 gnus-current-headers 'gnus-newsgroup-last-rmail))
3410 (gnus-eval-in-buffer-window gnus-save-article-buffer
3414 (gnus-output-to-rmail filename))))
3417 (defun gnus-summary-save-in-mail (&optional filename)
3418 "Append this article to Unix mail file.
3419 Optional argument FILENAME specifies file name.
3420 Directory to save to is default to `gnus-article-save-directory'."
3421 (setq filename (gnus-read-save-file-name
3422 "Save %s in Unix mail file:" filename
3423 gnus-mail-save-name gnus-newsgroup-name
3424 gnus-current-headers 'gnus-newsgroup-last-mail))
3425 (gnus-eval-in-buffer-window gnus-save-article-buffer
3429 (if (and (file-readable-p filename)
3430 (file-regular-p filename)
3431 (mail-file-babyl-p filename))
3432 (rmail-output-to-rmail-file filename t)
3433 (gnus-output-to-mail filename)))))
3436 (defun gnus-summary-save-in-file (&optional filename overwrite)
3437 "Append this article to file.
3438 Optional argument FILENAME specifies file name.
3439 Directory to save to is default to `gnus-article-save-directory'."
3440 (setq filename (gnus-read-save-file-name
3441 "Save %s in file:" filename
3442 gnus-file-save-name gnus-newsgroup-name
3443 gnus-current-headers 'gnus-newsgroup-last-file))
3444 (gnus-eval-in-buffer-window gnus-save-article-buffer
3448 (when (and overwrite
3449 (file-exists-p filename))
3450 (delete-file filename))
3451 (gnus-output-to-file filename))))
3454 (defun gnus-summary-write-to-file (&optional filename)
3455 "Write this article to a file, overwriting it if the file exists.
3456 Optional argument FILENAME specifies file name.
3457 The directory to save in defaults to `gnus-article-save-directory'."
3458 (gnus-summary-save-in-file nil t))
3460 (defun gnus-summary-save-body-in-file (&optional filename)
3461 "Append this article body to a file.
3462 Optional argument FILENAME specifies file name.
3463 The directory to save in defaults to `gnus-article-save-directory'."
3464 (setq filename (gnus-read-save-file-name
3465 "Save %s body in file:" filename
3466 gnus-file-save-name gnus-newsgroup-name
3467 gnus-current-headers 'gnus-newsgroup-last-file))
3468 (gnus-eval-in-buffer-window gnus-save-article-buffer
3472 (when (article-goto-body)
3473 (narrow-to-region (point) (point-max)))
3474 (gnus-output-to-file filename))))
3477 (defun gnus-summary-save-in-pipe (&optional command)
3478 "Pipe this article to subprocess."
3480 (cond ((and (eq command 'default)
3481 gnus-last-shell-command)
3482 gnus-last-shell-command)
3487 "Shell command on %s: "
3488 (if (and gnus-number-of-articles-to-be-saved
3489 (> gnus-number-of-articles-to-be-saved 1))
3490 (format "these %d articles"
3491 gnus-number-of-articles-to-be-saved)
3493 gnus-last-shell-command))))
3494 (when (string-equal command "")
3495 (if gnus-last-shell-command
3496 (setq command gnus-last-shell-command)
3497 (error "A command is required")))
3498 (gnus-eval-in-buffer-window gnus-article-buffer
3501 (shell-command-on-region (point-min) (point-max) command nil)))
3502 (setq gnus-last-shell-command command))
3504 (defun gnus-summary-pipe-to-muttprint (&optional command)
3505 "Pipe this article to muttprint."
3506 (setq command (read-string
3507 "Print using command: " gnus-summary-muttprint-program
3508 nil gnus-summary-muttprint-program))
3509 (gnus-summary-save-in-pipe command))
3511 ;;; Article file names when saving.
3513 (defun gnus-capitalize-newsgroup (newsgroup)
3514 "Capitalize NEWSGROUP name."
3515 (when (not (zerop (length newsgroup)))
3516 (concat (char-to-string (upcase (aref newsgroup 0)))
3517 (substring newsgroup 1))))
3519 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3520 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3521 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3522 Otherwise, it is like ~/News/news/group/num."
3525 (concat (if (gnus-use-long-file-name 'not-save)
3526 (gnus-capitalize-newsgroup newsgroup)
3527 (gnus-newsgroup-directory-form newsgroup))
3528 "/" (int-to-string (mail-header-number headers)))
3529 gnus-article-save-directory)))
3531 (string-equal (file-name-directory default)
3532 (file-name-directory last-file))
3533 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3535 (or last-file default))))
3537 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3538 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3539 If variable `gnus-use-long-file-name' is non-nil, it is
3540 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3543 (concat (if (gnus-use-long-file-name 'not-save)
3545 (gnus-newsgroup-directory-form newsgroup))
3546 "/" (int-to-string (mail-header-number headers)))
3547 gnus-article-save-directory)))
3549 (string-equal (file-name-directory default)
3550 (file-name-directory last-file))
3551 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3553 (or last-file default))))
3555 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3556 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3557 If variable `gnus-use-long-file-name' is non-nil, it is
3558 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3561 (if (gnus-use-long-file-name 'not-save)
3564 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3566 gnus-article-save-directory)))
3568 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3569 "Generate file name from sender."
3570 (let ((from (mail-header-from headers)))
3572 (if (and from (string-match "\\([^ <]+\\)@" from))
3573 (match-string 1 from)
3575 gnus-article-save-directory)))
3577 (defun article-verify-x-pgp-sig ()
3580 (if (gnus-buffer-live-p gnus-original-article-buffer)
3581 (let ((sig (with-current-buffer gnus-original-article-buffer
3582 (gnus-fetch-field "X-PGP-Sig")))
3586 (mml2015-clear-verify-function))
3588 (insert-buffer-substring gnus-original-article-buffer)
3589 (setq items (split-string sig))
3590 (message-narrow-to-head)
3591 (let ((inhibit-point-motion-hooks t)
3592 (case-fold-search t))
3593 ;; Don't verify multiple headers.
3594 (setq headers (mapconcat (lambda (header)
3596 (mail-fetch-field header)
3598 (split-string (nth 1 items) ",") "")))
3599 (delete-region (point-min) (point-max))
3600 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3601 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3606 (if (looking-at "^-")
3609 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3610 (insert "Version: " (car items) "\n\n")
3611 (insert (mapconcat 'identity (cddr items) "\n"))
3612 (insert "\n-----END PGP SIGNATURE-----\n")
3613 (let ((mm-security-handle (list (format "multipart/signed"))))
3614 (mml2015-clean-buffer)
3615 (let ((coding-system-for-write (or gnus-newsgroup-charset
3617 (funcall (mml2015-clear-verify-function)))
3619 (or (mm-handle-multipart-ctl-parameter
3620 mm-security-handle 'gnus-details)
3621 (mm-handle-multipart-ctl-parameter
3622 mm-security-handle 'gnus-info)))))
3624 (let ((inhibit-read-only t) bface eface)
3626 (message-narrow-to-head)
3627 (goto-char (point-max))
3629 (setq bface (get-text-property (point-at-bol) 'face)
3630 eface (get-text-property (1- (point-at-eol)) 'face))
3631 (message-remove-header "X-Gnus-PGP-Verify")
3632 (if (re-search-forward "^X-PGP-Sig:" nil t)
3634 (goto-char (point-max)))
3635 (narrow-to-region (point) (point))
3636 (insert "X-Gnus-PGP-Verify: " info "\n")
3637 (goto-char (point-min))
3640 (if (not (looking-at "^[ \t]"))
3644 (goto-char (point-min))
3645 (when (looking-at "\\([^:]+\\): *")
3646 (put-text-property (match-beginning 1) (1+ (match-end 1))
3648 (put-text-property (match-end 0) (point-max)
3649 'face eface)))))))))
3651 (defun article-verify-cancel-lock ()
3652 "Verify Cancel-Lock header."
3654 (if (gnus-buffer-live-p gnus-original-article-buffer)
3655 (canlock-verify gnus-original-article-buffer)))
3657 (defun article-monafy ()
3658 "Display body part with mona font."
3660 (unless (if (featurep 'xemacs)
3661 (find-face 'gnus-mona-face)
3662 (facep 'gnus-mona-face))
3663 (require 'navi2ch-mona)
3664 (set-face-font (make-face 'gnus-mona-face) navi2ch-mona-font))
3666 (let ((inhibit-read-only t))
3669 (gnus-make-overlay (point) (point-max))
3670 'face 'gnus-mona-face))))
3677 (setq afunc (car func)
3680 gfunc (intern (format "gnus-%s" func))))
3682 (when (fboundp afunc)
3683 `(lambda (&optional interactive &rest args)
3684 ,(documentation afunc t)
3685 (interactive (list t))
3687 (set-buffer gnus-article-buffer)
3689 (call-interactively ',afunc)
3690 (apply ',afunc args))))))))
3691 '(article-hide-headers
3692 article-verify-x-pgp-sig
3693 article-verify-cancel-lock
3695 article-hide-boring-headers
3696 article-treat-overstrike
3697 article-treat-ansi-sequences
3698 article-fill-long-lines
3699 article-capitalize-sentences
3701 article-remove-leading-whitespace
3702 article-display-x-face
3703 article-display-face
3704 article-de-quoted-unreadable
3705 article-de-base64-unreadable
3708 article-unsplit-urls
3709 article-hide-list-identifiers
3710 article-strip-banner
3713 article-hide-signature
3714 article-strip-headers-in-body
3715 article-remove-trailing-blank-lines
3716 article-strip-leading-blank-lines
3717 article-strip-multiple-blank-lines
3718 article-strip-leading-space
3719 article-strip-trailing-space
3720 article-strip-blank-lines
3721 article-strip-all-blank-lines
3723 article-date-english
3724 article-date-iso8601
3725 article-date-original
3727 article-decode-mime-words
3728 article-decode-charset
3729 article-decode-encoded-words
3733 article-treat-dumbquotes
3734 article-normalize-headers
3735 (article-show-all-headers . gnus-article-show-all-headers)
3736 ;; (article-show-all . gnus-article-show-all)
3740 ;;; Gnus article mode
3743 (put 'gnus-article-mode 'mode-class 'special)
3745 (gnus-define-keys gnus-article-mode-map
3746 " " gnus-article-goto-next-page
3747 "\177" gnus-article-goto-prev-page
3748 [delete] gnus-article-goto-prev-page
3749 [backspace] gnus-article-goto-prev-page
3750 "\C-c^" gnus-article-refer-article
3751 "h" gnus-article-show-summary
3752 "s" gnus-article-show-summary
3753 "\C-c\C-m" gnus-article-mail
3754 "?" gnus-article-describe-briefly
3755 "e" gnus-summary-edit-article
3756 "<" beginning-of-buffer
3758 "\C-c\C-i" gnus-info-find-node
3760 "R" gnus-article-reply-with-original
3761 "F" gnus-article-followup-with-original
3762 "\C-hk" gnus-article-describe-key
3763 "\C-hc" gnus-article-describe-key-briefly
3765 "\C-d" gnus-article-read-summary-keys
3766 "\M-*" gnus-article-read-summary-keys
3767 "\M-#" gnus-article-read-summary-keys
3768 "\M-^" gnus-article-read-summary-keys
3769 "\M-g" gnus-article-read-summary-keys)
3771 ;; Define almost undefined keys to `gnus-article-read-summary-keys'.
3775 (push (char-to-string key) keys)
3777 (dolist (elem (accessible-keymaps gnus-summary-mode-map))
3778 (setq key (car elem))
3779 (when (and (> (length key) 0)
3780 (not (eq 'menu-bar (aref key 0)))
3781 (symbolp (lookup-key gnus-summary-mode-map key)))
3784 (unless (lookup-key gnus-article-mode-map key)
3785 (define-key gnus-article-mode-map key 'gnus-article-read-summary-keys))))
3787 (defun gnus-article-make-menu-bar ()
3788 (unless (boundp 'gnus-article-commands-menu)
3789 (gnus-summary-make-menu-bar))
3790 (gnus-turn-off-edit-menu 'article)
3791 (unless (boundp 'gnus-article-article-menu)
3793 gnus-article-article-menu gnus-article-mode-map ""
3795 ["Scroll forwards" gnus-article-goto-next-page t]
3796 ["Scroll backwards" gnus-article-goto-prev-page t]
3797 ["Show summary" gnus-article-show-summary t]
3798 ["Fetch Message-ID at point" gnus-article-refer-article t]
3799 ["Mail to address at point" gnus-article-mail t]
3800 ["Send a bug report" gnus-bug t]))
3803 gnus-article-treatment-menu gnus-article-mode-map ""
3804 ;; Fixme: this should use :active (and maybe :visible).
3806 ["Hide headers" gnus-article-hide-headers t]
3807 ["Hide signature" gnus-article-hide-signature t]
3808 ["Hide citation" gnus-article-hide-citation t]
3809 ["Treat overstrike" gnus-article-treat-overstrike t]
3810 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
3811 ["Remove carriage return" gnus-article-remove-cr t]
3812 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3813 ["Treat html" gnus-article-wash-html t]
3814 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3815 ["Decode HZ" gnus-article-decode-HZ t]))
3817 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3819 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3821 (gnus-run-hooks 'gnus-article-menu-hook)))
3823 (defun gnus-article-mode ()
3824 "Major mode for displaying an article.
3826 All normal editing commands are switched off.
3828 The following commands are available in addition to all summary mode
3830 \\<gnus-article-mode-map>
3831 \\[gnus-article-next-page]\t Scroll the article one page forwards
3832 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3833 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3834 \\[gnus-article-show-summary]\t Display the summary buffer
3835 \\[gnus-article-mail]\t Send a reply to the address near point
3836 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3837 \\[gnus-info-find-node]\t Go to the Gnus info node"
3839 (gnus-simplify-mode-line)
3840 (setq mode-name "Article")
3841 (setq major-mode 'gnus-article-mode)
3842 (make-local-variable 'minor-mode-alist)
3843 (unless (assq 'gnus-show-mime minor-mode-alist)
3844 (push (list 'gnus-show-mime " MIME") minor-mode-alist))
3845 (use-local-map gnus-article-mode-map)
3846 (when (gnus-visual-p 'article-menu 'menu)
3847 (gnus-article-make-menu-bar)
3848 (when gnus-summary-tool-bar-map
3849 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3850 (gnus-update-format-specifications nil 'article-mode)
3851 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3852 (set (make-local-variable 'gnus-page-broken) nil)
3853 (make-local-variable 'gnus-button-marker-list)
3854 (make-local-variable 'gnus-article-current-summary)
3855 (make-local-variable 'gnus-article-mime-handles)
3856 (make-local-variable 'gnus-article-decoded-p)
3857 (make-local-variable 'gnus-article-mime-handle-alist)
3858 (make-local-variable 'gnus-article-wash-types)
3859 (make-local-variable 'gnus-article-image-alist)
3860 (make-local-variable 'gnus-article-charset)
3861 (make-local-variable 'gnus-article-ignored-charsets)
3862 (gnus-set-default-directory)
3863 (buffer-disable-undo)
3864 (setq buffer-read-only t
3865 show-trailing-whitespace nil)
3866 (set-syntax-table gnus-article-mode-syntax-table)
3867 (gnus-run-hooks 'gnus-article-mode-hook))
3869 (defun gnus-article-setup-buffer ()
3870 "Initialize the article buffer."
3871 (let* ((name (if gnus-single-article-buffer "*Article*"
3872 (concat "*Article " gnus-newsgroup-name "*")))
3874 (progn (string-match "\\*Article" name)
3875 (concat " *Original Article"
3876 (substring name (match-end 0))))))
3877 (setq gnus-article-buffer name)
3878 (setq gnus-original-article-buffer original)
3879 (setq gnus-article-mime-handle-alist nil)
3880 ;; This might be a variable local to the summary buffer.
3881 (unless gnus-single-article-buffer
3883 (set-buffer gnus-summary-buffer)
3884 (setq gnus-article-buffer name)
3885 (setq gnus-original-article-buffer original)
3886 (gnus-set-global-variables)))
3887 (gnus-article-setup-highlight-words)
3888 ;; Init original article buffer.
3890 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3891 (set-buffer-multibyte t)
3892 (setq major-mode 'gnus-original-article-mode)
3893 (make-local-variable 'gnus-original-article))
3894 (if (get-buffer name)
3897 (when (and gnus-article-edit-mode
3900 (y-or-n-p "Article mode edit in progress; discard? ")))
3901 (error "Action aborted"))
3902 (set (make-local-variable 'gnus-article-edit-mode) nil)
3903 (buffer-disable-undo)
3904 (setq buffer-read-only t)
3905 ;; This list just keeps growing if we don't reset it.
3906 (setq gnus-button-marker-list nil)
3907 (unless (eq major-mode 'gnus-article-mode)
3908 (gnus-article-mode))
3911 (set-buffer (gnus-get-buffer-create name))
3913 (make-local-variable 'gnus-summary-buffer)
3914 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3915 (current-buffer)))))
3917 ;; Set article window start at LINE, where LINE is the number of lines
3918 ;; from the head of the article.
3919 (defun gnus-article-set-window-start (&optional line)
3921 (gnus-get-buffer-window gnus-article-buffer t)
3923 (set-buffer gnus-article-buffer)
3924 (goto-char (point-min))
3927 (gnus-message 6 "Moved to bookmark")
3928 (search-forward "\n\n" nil t)
3932 ;;; @@ article filters
3935 (defun gnus-article-display-mime-message ()
3936 "Article display method for MIME message."
3937 ;; called from `gnus-original-article-buffer'.
3938 (let (charset all-headers)
3939 (with-current-buffer gnus-summary-buffer
3940 (setq charset default-mime-charset
3941 all-headers gnus-have-all-headers))
3942 (make-local-variable 'default-mime-charset)
3943 (setq default-mime-charset charset)
3944 (with-current-buffer (get-buffer-create gnus-article-buffer)
3945 (make-local-variable 'default-mime-charset)
3946 (setq default-mime-charset charset))
3947 (mime-display-message mime-message-structure
3948 gnus-article-buffer nil gnus-article-mode-map)
3950 (gnus-article-hide-headers nil -1)))
3951 (run-hooks 'gnus-mime-article-prepare-hook))
3953 (defun gnus-article-display-traditional-message ()
3954 "Article display method for traditional message."
3955 (set-buffer gnus-article-buffer)
3956 (let ((inhibit-read-only t))
3958 (insert-buffer-substring gnus-original-article-buffer)))
3960 (defun gnus-article-make-full-mail-header (&optional number charset)
3961 "Create a new mail header structure in a raw article buffer."
3962 (unless (and number charset)
3963 (save-current-buffer
3964 (set-buffer gnus-summary-buffer)
3966 (setq number (or (cdr gnus-article-current) 0)))
3968 (setq charset (or default-mime-charset 'x-ctext)))))
3969 (goto-char (point-min))
3970 (let ((header-end (if (search-forward "\n\n" nil t)
3972 (goto-char (point-max))))
3973 (chars (- (point-max) (point)))
3974 (lines (count-lines (point) (point-max)))
3975 (default-mime-charset charset)
3977 (narrow-to-region (point-min) header-end)
3978 (setq xref (std11-fetch-field "xref"))
3980 (make-full-mail-header
3982 (std11-fetch-field "subject")
3983 (std11-fetch-field "from")
3984 (std11-fetch-field "date")
3985 (std11-fetch-field "message-id")
3986 (std11-fetch-field "references")
3989 (when xref (concat "Xref: " xref)))
3992 (defun gnus-article-prepare (article &optional all-headers header)
3993 "Prepare ARTICLE in article mode buffer.
3994 ARTICLE should either be an article number or a Message-ID.
3995 If ARTICLE is an id, HEADER should be the article headers.
3996 If ALL-HEADERS is non-nil, no headers are hidden."
3998 ;; Make sure we start in a summary buffer.
3999 (unless (eq major-mode 'gnus-summary-mode)
4000 (set-buffer gnus-summary-buffer))
4001 (setq gnus-summary-buffer (current-buffer))
4002 (let* ((gnus-article (if header (mail-header-number header) article))
4003 (summary-buffer (current-buffer))
4004 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
4005 (group gnus-newsgroup-name)
4008 (gnus-article-setup-buffer)
4009 (set-buffer gnus-article-buffer)
4010 ;; Deactivate active regions.
4011 (when (and (boundp 'transient-mark-mode)
4012 transient-mark-mode)
4013 (setq mark-active nil))
4014 (if (not (setq result (let ((inhibit-read-only t))
4015 (gnus-request-article-this-buffer
4017 ;; There is no such article.
4019 (when (and (numberp article)
4020 (not (memq article gnus-newsgroup-sparse)))
4021 (setq gnus-article-current
4022 (cons gnus-newsgroup-name article))
4023 (set-buffer gnus-summary-buffer)
4024 (setq gnus-current-article article)
4025 (if (and (memq article gnus-newsgroup-undownloaded)
4026 (not (gnus-online (gnus-find-method-for-group
4027 gnus-newsgroup-name))))
4029 (gnus-summary-set-agent-mark article)
4030 (message "Message marked for downloading"))
4031 (gnus-summary-mark-article article gnus-canceled-mark)
4032 (unless (memq article gnus-newsgroup-sparse)
4033 (gnus-error 1 "No such article (may have expired or been canceled)")))))
4034 (if (or (eq result 'pseudo)
4035 (eq result 'nneething))
4038 (set-buffer summary-buffer)
4039 (push article gnus-newsgroup-history)
4040 (setq gnus-last-article gnus-current-article
4041 gnus-current-article 0
4042 gnus-current-headers nil
4043 gnus-article-current nil)
4044 (if (eq result 'nneething)
4045 (gnus-configure-windows 'summary)
4046 (gnus-configure-windows 'article))
4047 (gnus-set-global-variables))
4048 (let ((gnus-article-mime-handle-alist-1
4049 gnus-article-mime-handle-alist))
4050 (gnus-set-mode-line 'article)))
4051 ;; The result from the `request' was an actual article -
4052 ;; or at least some text that is now displayed in the
4054 (when (and (numberp article)
4055 (not (eq article gnus-current-article)))
4056 ;; Seems like a new article has been selected.
4057 ;; `gnus-current-article' must be an article number.
4059 (set-buffer summary-buffer)
4060 (push article gnus-newsgroup-history)
4061 (setq gnus-last-article gnus-current-article
4062 gnus-current-article article
4063 gnus-current-headers
4064 (gnus-summary-article-header gnus-current-article)
4065 gnus-article-current
4066 (cons gnus-newsgroup-name gnus-current-article))
4067 (unless (vectorp gnus-current-headers)
4068 (setq gnus-current-headers nil))
4069 (gnus-summary-goto-subject gnus-current-article)
4070 (when (gnus-summary-show-thread)
4071 ;; If the summary buffer really was folded, the
4072 ;; previous goto may not actually have gone to
4073 ;; the right article, but the thread root instead.
4075 (gnus-summary-goto-subject gnus-current-article))
4076 (gnus-run-hooks 'gnus-mark-article-hook)
4077 (gnus-set-mode-line 'summary)
4078 (when (gnus-visual-p 'article-highlight 'highlight)
4079 (gnus-run-hooks 'gnus-visual-mark-article-hook))
4080 ;; Set the global newsgroup variables here.
4081 (gnus-set-global-variables)
4082 (setq gnus-have-all-headers
4083 (or all-headers gnus-show-all-headers))))
4085 (gnus-configure-windows 'article))
4086 (when (or (numberp article)
4088 (gnus-article-prepare-display)
4090 (goto-char (point-min))
4091 (when gnus-break-pages
4092 (gnus-narrow-to-page)))
4093 (let ((gnus-article-mime-handle-alist-1
4094 gnus-article-mime-handle-alist))
4095 (gnus-set-mode-line 'article))
4099 (set-window-point (get-buffer-window (current-buffer)) (point))
4100 (gnus-configure-windows 'article)
4103 (defun gnus-article-prepare-mime-display (&optional number)
4104 (goto-char (point-min))
4105 (when (re-search-forward "^[^\t ]+:" nil t)
4106 (goto-char (match-beginning 0)))
4107 (let ((entity (if (eq 1 (point-min))
4108 (get-text-property 1 'mime-view-entity)
4109 (get-text-property (point) 'mime-view-entity)))
4110 last-entity child-entity next type)
4111 (setq child-entity (mime-entity-children entity))
4113 (setq last-entity (nth (1- (length child-entity))
4115 (setq last-entity entity))
4117 (narrow-to-region (point)
4118 (if (search-forward "\n\n" nil t)
4121 (gnus-treat-article 'head)
4122 (put-text-property (point-min) (point-max) 'article-treated-header t)
4123 (goto-char (point-max)))
4124 (while (and (not (eobp)) entity)
4125 (setq next (set-marker
4127 (next-single-property-change (point) 'mime-view-entity
4129 (let ((types (mime-entity-content-type entity)))
4130 (while (eq 'multipart (mime-content-type-primary-type types))
4131 (setq entity (car (mime-entity-children entity))
4132 types (mime-entity-content-type entity)))
4134 (setq type (format "%s/%s"
4135 (mime-content-type-primary-type types)
4136 (mime-content-type-subtype types)))))
4137 (if (string-equal type "message/rfc822")
4140 (let ((children (mime-entity-children entity))
4143 (setq last-children (nth (1- (length children)) children))
4146 (not (eq last-children
4147 (get-text-property next 'mime-view-entity)))
4149 (next-single-property-change next
4151 nil (point-max)))))))
4152 (setq next (next-single-property-change next 'mime-view-entity
4155 (narrow-to-region (point) next)
4156 (gnus-article-prepare-mime-display)
4157 (goto-char (point-max)))
4158 (setq entity (get-text-property (point) 'mime-view-entity)))
4160 (narrow-to-region (point) next)
4161 ;; Kludge. We have to count true number, but for now,
4162 ;; part number is here only to achieve `last'.
4163 (gnus-treat-article nil 1
4164 (if (eq entity last-entity)
4167 (goto-char (point-max)))
4168 (setq entity (get-text-property next 'mime-view-entity))))))
4171 (defun gnus-article-prepare-display ()
4172 "Make the current buffer look like a nice article."
4173 (let ((gnus-article-buffer (current-buffer))
4175 (inhibit-read-only t))
4176 (unless (eq major-mode 'gnus-article-mode)
4177 (gnus-article-mode))
4178 (setq buffer-read-only nil
4179 gnus-button-marker-list nil
4180 gnus-article-wash-types nil
4181 gnus-article-image-alist nil)
4184 (static-if (featurep 'xemacs)
4185 (map-extents (lambda (extent maparg) (delete-extent extent)))
4186 (let ((lists (overlay-lists)))
4187 (dolist (overlay (nconc (car lists) (cdr lists)))
4188 (delete-overlay overlay)))))
4189 (gnus-run-hooks 'gnus-tmp-internal-hook))
4190 (let ((show-mime (unless (member gnus-newsgroup-name '("nndraft:delayed"
4193 (inhibit-read-only t))
4194 (set-buffer gnus-original-article-buffer)
4196 (setq mime-message-structure gnus-current-headers)
4197 (mime-buffer-entity-set-buffer-internal mime-message-structure
4198 gnus-original-article-buffer)
4199 (mime-entity-set-representation-type-internal mime-message-structure
4200 'mime-buffer-entity)
4201 (luna-send mime-message-structure 'initialize-instance
4202 mime-message-structure)
4204 (let (mime-display-header-hook mime-display-text/plain-hook)
4205 (funcall gnus-article-display-method-for-mime))
4206 (funcall gnus-article-display-method-for-traditional))
4207 ;; Call the treatment functions.
4211 (gnus-article-prepare-mime-display)
4212 (narrow-to-region (goto-char (point-min))
4213 (if (search-forward "\n\n" nil t)
4216 (gnus-treat-article 'head)
4217 (put-text-property (point-min) (point-max) 'article-treated-header t)
4218 (goto-char (point-max))
4220 (narrow-to-region (point) (point-max))
4221 (gnus-treat-article nil))
4222 (put-text-property (point-min) (point-max) 'read-only nil)))
4223 (gnus-run-hooks 'gnus-article-prepare-hook))
4225 (defun gnus-article-decode-article-as-default-mime-charset ()
4226 "Decode an article as `default-mime-charset'. It won't work if the
4227 value of the variable `gnus-show-mime' is non-nil."
4228 (unless (or gnus-show-mime
4229 (member gnus-newsgroup-name '("nndraft:delayed"
4231 (set (make-local-variable 'default-mime-charset)
4232 (with-current-buffer gnus-summary-buffer
4233 default-mime-charset))
4234 (decode-mime-charset-region (point-min) (point-max)
4235 default-mime-charset)))
4238 ;;; Gnus MIME viewing functions
4241 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4242 "Format of the MIME buttons.
4244 Valid specifiers include:
4246 %T MIME type, along with additional info
4247 %n The `name' parameter
4248 %d The description, if any
4249 %l The length of the encoded part
4250 %p The part identifier number
4251 %e Dots if the part isn't displayed
4253 General format specifiers can also be used. See Info node
4254 `(gnus)Formatting Variables'.")
4256 (defvar gnus-mime-button-line-format-alist
4257 '((?t gnus-tmp-type ?s)
4258 (?T gnus-tmp-type-long ?s)
4259 (?n gnus-tmp-name ?s)
4260 (?d gnus-tmp-description ?s)
4262 (?l gnus-tmp-length ?d)
4263 (?e gnus-tmp-dots ?s)))
4265 (defvar gnus-mime-button-commands
4266 '((gnus-article-press-button "\r" "Toggle Display")
4267 (gnus-mime-view-part "v" "View Interactively...")
4268 (gnus-mime-view-part-as-type "t" "View As Type...")
4269 (gnus-mime-view-part-as-charset "C" "View As charset...")
4270 (gnus-mime-save-part "o" "Save...")
4271 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4272 (gnus-mime-delete-part "d" "Delete part")
4273 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4274 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4275 (gnus-mime-view-part-internally "E" "View Internally")
4276 (gnus-mime-view-part-externally "e" "View Externally")
4277 (gnus-mime-print-part "p" "Print")
4278 (gnus-mime-pipe-part "|" "Pipe To Command...")
4279 (gnus-mime-action-on-part "." "Take action on the part...")))
4281 (defun gnus-article-mime-part-status ()
4282 (with-current-buffer gnus-article-buffer
4283 (let ((entity (get-text-property (point-min) 'mime-view-entity))
4286 (setq children (mime-entity-children entity))
4287 (setq children (length children)))
4290 (format " (%d parts)" children))
4293 (defvar gnus-mime-button-map
4294 (let ((map (make-sparse-keymap)))
4295 (define-key map gnus-mouse-2 'gnus-article-push-button)
4296 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4297 (dolist (c gnus-mime-button-commands)
4298 (define-key map (cadr c) (car c)))
4302 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4304 ,@(mapcar (lambda (c)
4305 (vector (caddr c) (car c) :enable t))
4306 gnus-mime-button-commands)))
4308 (defun gnus-mime-button-menu (event prefix)
4309 "Construct a context-sensitive menu of MIME commands."
4310 (interactive "e\nP")
4311 (save-window-excursion
4312 (let ((pos (event-start event)))
4313 (select-window (posn-window pos))
4314 (goto-char (posn-point pos))
4315 (gnus-article-check-buffer)
4316 (popup-menu gnus-mime-button-menu nil prefix))))
4318 (defun gnus-mime-view-all-parts (&optional handles)
4319 "View all the MIME parts."
4321 (with-current-buffer gnus-article-buffer
4322 (let ((handles (or handles gnus-article-mime-handles))
4323 (mail-parse-charset gnus-newsgroup-charset)
4324 (mail-parse-ignored-charsets
4325 (with-current-buffer gnus-summary-buffer
4326 gnus-newsgroup-ignored-charsets)))
4328 (mm-remove-parts handles)
4329 (goto-char (point-min))
4330 (or (search-forward "\n\n") (goto-char (point-max)))
4331 (let ((inhibit-read-only t))
4332 (delete-region (point) (point-max))
4333 (mm-display-parts handles))))))
4336 (defsubst gnus-article-edit-part (handles)
4337 "Edit an article in order to delete a mime part.
4338 This function is exclusively used by `gnus-mime-save-part-and-strip'
4339 and `gnus-mime-delete-part', and not provided at run-time normally."
4340 (gnus-article-edit-article
4343 (let ((mail-parse-charset (or gnus-article-charset
4344 ',gnus-newsgroup-charset))
4345 (mail-parse-ignored-charsets
4346 (or gnus-article-ignored-charsets
4347 ',gnus-newsgroup-ignored-charsets))
4348 (mbl mml-buffer-list))
4349 (setq mml-buffer-list nil)
4350 (insert-buffer gnus-original-article-buffer)
4351 (mime-to-mml ',handles)
4352 (setq gnus-article-mime-handles nil)
4353 (let ((mbl1 mml-buffer-list))
4354 (setq mml-buffer-list mbl)
4355 (set (make-local-variable 'mml-buffer-list) mbl1))
4356 (gnus-make-local-hook 'kill-buffer-hook)
4357 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4358 `(lambda (no-highlight)
4359 (let ((mail-parse-charset (or gnus-article-charset
4360 ',gnus-newsgroup-charset))
4361 (message-options message-options)
4362 (message-options-set-recipient)
4363 (mail-parse-ignored-charsets
4364 (or gnus-article-ignored-charsets
4365 ',gnus-newsgroup-ignored-charsets)))
4367 (mml-destroy-buffers)
4368 (remove-hook 'kill-buffer-hook
4369 'mml-destroy-buffers t)
4370 (kill-local-variable 'mml-buffer-list))
4371 (gnus-summary-edit-article-done
4372 ,(or (mail-header-references gnus-current-headers) "")
4373 ,(gnus-group-read-only-p)
4374 ,gnus-summary-buffer no-highlight)))
4375 (gnus-article-edit-done)
4376 (gnus-summary-expand-window)
4377 (gnus-summary-show-article)))
4379 (defun gnus-mime-save-part-and-strip ()
4380 "Save the MIME part under point then replace it with an external body."
4382 (gnus-article-check-buffer)
4383 (when (gnus-group-read-only-p)
4384 (error "The current group does not support deleting of parts"))
4385 (when (mm-complicated-handles gnus-article-mime-handles)
4387 The current article has a complicated MIME structure, giving up..."))
4388 (when (gnus-yes-or-no-p "\
4389 Deleting parts may malfunction or destroy the article; continue? ")
4390 (let* ((data (get-text-property (point) 'gnus-data))
4392 (handles gnus-article-mime-handles))
4393 (setq file (and data (mm-save-part data)))
4395 (with-current-buffer (mm-handle-buffer data)
4397 (insert "Content-Type: " (mm-handle-media-type data))
4398 (mml-insert-parameter-string (cdr (mm-handle-type data))
4401 (insert "Content-ID: " (message-make-message-id) "\n")
4402 (insert "Content-Transfer-Encoding: binary\n")
4405 (cdr (mm-make-handle nil
4406 `("message/external-body"
4407 (access-type . "LOCAL-FILE")
4409 (set-buffer gnus-summary-buffer)
4410 (gnus-article-edit-part handles)))))
4412 (defun gnus-mime-delete-part ()
4413 "Delete the MIME part under point.
4414 Replace it with some information about the removed part."
4416 (gnus-article-check-buffer)
4417 (when (gnus-group-read-only-p)
4418 (error "The current group does not support deleting of parts"))
4419 (when (mm-complicated-handles gnus-article-mime-handles)
4421 The current article has a complicated MIME structure, giving up..."))
4422 (when (gnus-yes-or-no-p "\
4423 Deleting parts may malfunction or destroy the article; continue? ")
4424 (let* ((data (get-text-property (point) 'gnus-data))
4425 (handles gnus-article-mime-handles)
4429 (mail-decode-encoded-word-string (or (mm-handle-description data)
4432 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4434 (type (mm-handle-media-type data)))
4436 (error "No MIME part under point"))
4437 (with-current-buffer (mm-handle-buffer data)
4438 (let ((bsize (format "%s" (buffer-size))))
4443 "| The following attachment has been deleted:\n"
4445 "| Type: " type "\n"
4446 "| Filename: " filename "\n"
4447 "| Size (encoded): " bsize " Byte\n"
4448 "| Description: " description "\n"
4451 (cdr (mm-make-handle
4452 nil `("text/plain") nil nil
4454 (format "Deleted attachment (%s bytes)" bsize))))))
4455 (set-buffer gnus-summary-buffer)
4456 (gnus-article-edit-part handles))))
4458 (defun gnus-mime-save-part ()
4459 "Save the MIME part under point."
4461 (gnus-article-check-buffer)
4462 (let ((data (get-text-property (point) 'gnus-data)))
4464 (mm-save-part data))))
4466 (defun gnus-mime-pipe-part ()
4467 "Pipe the MIME part under point to a process."
4469 (gnus-article-check-buffer)
4470 (let ((data (get-text-property (point) 'gnus-data)))
4472 (mm-pipe-part data))))
4474 (defun gnus-mime-view-part ()
4475 "Interactively choose a viewing method for the MIME part under point."
4477 (gnus-article-check-buffer)
4478 (let ((data (get-text-property (point) 'gnus-data)))
4480 (setq gnus-article-mime-handles
4482 gnus-article-mime-handles (setq data (copy-sequence data))))
4483 (mm-interactively-view-part data))))
4485 (defun gnus-mime-view-part-as-type-internal ()
4486 (gnus-article-check-buffer)
4487 (let* ((name (mail-content-type-get
4488 (mm-handle-type (get-text-property (point) 'gnus-data))
4490 (def-type (and name (mm-default-file-encoding name))))
4491 (and def-type (cons def-type 0))))
4493 (defun gnus-mime-view-part-as-type (&optional mime-type)
4494 "Choose a MIME media type, and view the part as such."
4497 (setq mime-type (completing-read
4498 "View as MIME type: "
4499 (mapcar #'list (mailcap-mime-types))
4501 (gnus-mime-view-part-as-type-internal))))
4502 (gnus-article-check-buffer)
4503 (let ((handle (get-text-property (point) 'gnus-data)))
4506 (mm-make-handle (mm-handle-buffer handle)
4507 (cons mime-type (cdr (mm-handle-type handle)))
4508 (mm-handle-encoding handle)
4509 (mm-handle-undisplayer handle)
4510 (mm-handle-disposition handle)
4511 (mm-handle-description handle)
4513 (mm-handle-id handle)))
4514 (setq gnus-article-mime-handles
4515 (mm-merge-handles gnus-article-mime-handles handle))
4516 (gnus-mm-display-part handle))))
4519 (require 'jka-compr))
4521 ;; jka-compr.el uses a "sh -c" to direct stderr to err-file, but these days
4522 ;; emacs can do that itself.
4524 (defun gnus-mime-jka-compr-maybe-uncompress ()
4525 "Uncompress the current buffer if `auto-compression-mode' is enabled.
4526 The uncompress method used is derived from `buffer-file-name'."
4527 (when (and (fboundp 'jka-compr-installed-p)
4528 (jka-compr-installed-p))
4529 (let ((info (jka-compr-get-compression-info buffer-file-name)))
4531 (let ((basename (file-name-nondirectory buffer-file-name))
4532 (args (jka-compr-info-uncompress-args info))
4533 (prog (jka-compr-info-uncompress-program info))
4534 (message (jka-compr-info-uncompress-message info))
4535 (err-file (jka-compr-make-temp-name)))
4537 (message "%s %s..." message basename))
4539 (unless (memq (apply 'call-process-region
4540 (point-min) (point-max)
4542 t (list t err-file) nil
4544 jka-compr-acceptable-retval-list)
4545 (jka-compr-error prog args basename message err-file))
4546 (jka-compr-delete-temp-file err-file)))))))
4548 (defun gnus-mime-copy-part (&optional handle)
4549 "Put the MIME part under point into a new buffer.
4550 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4553 (gnus-article-check-buffer)
4554 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4555 (contents (and handle (mm-get-part handle)))
4557 (file-name-nondirectory
4559 (mail-content-type-get (mm-handle-type handle) 'name)
4560 (mail-content-type-get (mm-handle-disposition handle)
4563 (buffer (and base (generate-new-buffer base))))
4565 (switch-to-buffer buffer)
4567 ;; We do it this way to make `normal-mode' set the appropriate mode.
4570 (setq buffer-file-name (expand-file-name base))
4571 (gnus-mime-jka-compr-maybe-uncompress)
4573 (setq buffer-file-name nil))
4574 (goto-char (point-min)))))
4576 (defun gnus-mime-print-part (&optional handle filename)
4577 "Print the MIME part under point."
4578 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4579 (gnus-article-check-buffer)
4580 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4581 (contents (and handle (mm-get-part handle)))
4582 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4583 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4588 (mm-save-part-to-file handle file)
4589 (call-process shell-file-name nil
4590 (generate-new-buffer " *mm*")
4592 shell-command-switch
4594 printer file (mm-handle-type handle))))
4598 (gnus-print-buffer))
4599 (ps-despool filename)))))
4601 (defun gnus-mime-inline-part (&optional handle arg)
4602 "Insert the MIME part under point into the current buffer."
4603 (interactive (list nil current-prefix-arg))
4604 (gnus-article-check-buffer)
4605 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4608 (inhibit-read-only t))
4610 (if (and (not arg) (mm-handle-undisplayer handle))
4611 (mm-remove-part handle)
4612 (setq contents (mm-get-part handle))
4615 (setq charset (or (mail-content-type-get
4616 (mm-handle-type handle) 'charset)
4617 gnus-newsgroup-charset)))
4619 (if (mm-handle-undisplayer handle)
4620 (mm-remove-part handle))
4623 gnus-summary-show-article-charset-alist))
4624 (mm-read-coding-system "Charset: ")))))
4626 (mm-insert-inline handle
4628 (setq charset (mm-charset-to-coding-system
4630 (not (eq charset 'ascii)))
4631 (mm-decode-coding-string contents charset)
4635 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4636 "Insert the MIME part under point into the current buffer using the
4638 (interactive (list nil current-prefix-arg))
4639 (gnus-article-check-buffer)
4640 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4643 (inhibit-read-only t))
4645 (if (mm-handle-undisplayer handle)
4646 (mm-remove-part handle))
4647 (let ((gnus-newsgroup-charset
4649 gnus-summary-show-article-charset-alist))
4650 (mm-read-coding-system "Charset: ")))
4651 (gnus-newsgroup-ignored-charsets 'gnus-all))
4652 (gnus-article-press-button)))))
4654 (defun gnus-mime-view-part-externally (&optional handle)
4655 "View the MIME part under point with an external viewer."
4657 (gnus-article-check-buffer)
4658 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4659 (mm-user-display-methods nil)
4660 (mm-inlined-types nil)
4661 (mail-parse-charset gnus-newsgroup-charset)
4662 (mail-parse-ignored-charsets
4663 (with-current-buffer gnus-summary-buffer
4664 gnus-newsgroup-ignored-charsets)))
4666 (if (mm-handle-undisplayer handle)
4667 (mm-remove-part handle)
4668 (mm-display-part handle)))))
4670 (defun gnus-mime-view-part-internally (&optional handle)
4671 "View the MIME part under point with an internal viewer.
4672 If no internal viewer is available, use an external viewer."
4674 (gnus-article-check-buffer)
4675 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4676 (mm-inlined-types '(".*"))
4677 (mm-inline-large-images t)
4678 (mail-parse-charset gnus-newsgroup-charset)
4679 (mail-parse-ignored-charsets
4680 (with-current-buffer gnus-summary-buffer
4681 gnus-newsgroup-ignored-charsets))
4682 (inhibit-read-only t))
4684 (if (mm-handle-undisplayer handle)
4685 (mm-remove-part handle)
4686 (mm-display-part handle)))))
4688 (defun gnus-mime-action-on-part (&optional action)
4689 "Do something with the MIME attachment at \(point\)."
4691 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4692 (gnus-article-check-buffer)
4693 (let ((action-pair (assoc action gnus-mime-action-alist)))
4695 (funcall (cdr action-pair)))))
4697 (defun gnus-article-part-wrapper (n function)
4698 (with-current-buffer gnus-article-buffer
4699 (when (> n (length gnus-article-mime-handle-alist))
4700 (error "No such part"))
4701 (gnus-article-goto-part n)
4702 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4703 (funcall function handle))))
4705 (defun gnus-article-pipe-part (n)
4706 "Pipe MIME part N, which is the numerical prefix."
4708 (gnus-article-part-wrapper n 'mm-pipe-part))
4710 (defun gnus-article-save-part (n)
4711 "Save MIME part N, which is the numerical prefix."
4713 (gnus-article-part-wrapper n 'mm-save-part))
4715 (defun gnus-article-interactively-view-part (n)
4716 "View MIME part N interactively, which is the numerical prefix."
4718 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4720 (defun gnus-article-copy-part (n)
4721 "Copy MIME part N, which is the numerical prefix."
4723 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4725 (defun gnus-article-view-part-as-charset (n)
4726 "View MIME part N using a specified charset.
4727 N is the numerical prefix."
4729 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4731 (defun gnus-article-view-part-externally (n)
4732 "View MIME part N externally, which is the numerical prefix."
4734 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4736 (defun gnus-article-inline-part (n)
4737 "Inline MIME part N, which is the numerical prefix."
4739 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4741 (defun gnus-article-mime-match-handle-first (condition)
4744 (dolist (ihandle gnus-article-mime-handle-alist)
4746 ((functionp condition)
4747 (funcall condition (cdr ihandle)))
4748 ((eq condition 'undisplayed)
4749 (not (or (mm-handle-undisplayer (cdr ihandle))
4750 (equal (mm-handle-media-type (cdr ihandle))
4751 "multipart/alternative"))))
4752 ((eq condition 'undisplayed-alternative)
4753 (not (mm-handle-undisplayer (cdr ihandle))))
4755 (gnus-article-goto-part (car ihandle))
4756 (or (not n) (< (car ihandle) n)))
4757 (setq n (car ihandle))))
4761 (defun gnus-article-view-part (&optional n)
4762 "View MIME part N, which is the numerical prefix."
4764 (with-current-buffer gnus-article-buffer
4765 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4766 gnus-article-mime-match-handle-function)))
4767 (when (> n (length gnus-article-mime-handle-alist))
4768 (error "No such part"))
4769 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4770 (when (gnus-article-goto-part n)
4771 (if (equal (car handle) "multipart/alternative")
4772 (gnus-article-press-button)
4773 (when (eq (gnus-mm-display-part handle) 'internal)
4774 (gnus-set-window-start)))))))
4776 (defsubst gnus-article-mime-total-parts ()
4777 (if (bufferp (car gnus-article-mime-handles))
4779 (1- (length gnus-article-mime-handles))))
4781 (defun gnus-mm-display-part (handle)
4782 "Display HANDLE and fix MIME button."
4783 (let ((id (get-text-property (point) 'gnus-part))
4785 (inhibit-read-only t))
4788 (let ((window (selected-window))
4789 (mail-parse-charset gnus-newsgroup-charset)
4790 (mail-parse-ignored-charsets
4791 (if (gnus-buffer-live-p gnus-summary-buffer)
4792 (with-current-buffer gnus-summary-buffer
4793 gnus-newsgroup-ignored-charsets)
4797 (let ((win (gnus-get-buffer-window (current-buffer) t))
4800 (select-window win))
4803 (if (mm-handle-displayed-p handle)
4804 ;; This will remove the part.
4805 (mm-display-part handle)
4807 (narrow-to-region (point)
4808 (if (eobp) (point) (1+ (point))))
4809 (mm-display-part handle)
4810 ;; We narrow to the part itself and
4811 ;; then call the treatment functions.
4812 (goto-char (point-min))
4814 (narrow-to-region (point) (point-max))
4817 (gnus-article-mime-total-parts)
4818 (mm-handle-media-type handle)))))
4819 (if (window-live-p window)
4820 (select-window window)))))
4823 (gnus-insert-mime-button
4824 handle id (list (mm-handle-displayed-p handle)))
4825 (goto-char point))))
4827 (defun gnus-article-goto-part (n)
4828 "Go to MIME part N."
4829 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4831 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4832 (let ((gnus-tmp-name
4833 (or (mail-content-type-get (mm-handle-type handle) 'name)
4834 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4835 (mail-content-type-get (mm-handle-type handle) 'url)
4837 (gnus-tmp-type (mm-handle-media-type handle))
4838 (gnus-tmp-description
4839 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4842 (if (if displayed (car displayed)
4843 (mm-handle-displayed-p handle))
4845 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4847 gnus-tmp-type-long b e)
4848 (when (string-match ".*/" gnus-tmp-name)
4849 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4850 (setq gnus-tmp-type-long (concat gnus-tmp-type
4851 (and (not (equal gnus-tmp-name ""))
4852 (concat "; " gnus-tmp-name))))
4853 (unless (equal gnus-tmp-description "")
4854 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4859 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4860 `(keymap ,gnus-mime-button-map
4861 gnus-callback gnus-mm-display-part
4862 gnus-part ,gnus-tmp-id
4863 article-type annotation
4866 ;; Exclude a newline.
4869 (widget-convert-button
4872 :action 'gnus-widget-press-button
4873 :button-keymap gnus-mime-button-map
4875 (lambda (widget/window &optional overlay pos)
4876 ;; Needed to properly clear the message due to a bug in
4877 ;; wid-edit (XEmacs only).
4878 (if (boundp 'help-echo-owns-message)
4879 (setq help-echo-owns-message t))
4881 "%S: %s the MIME part; %S: more options"
4882 (aref gnus-mouse-2 0)
4883 ;; XEmacs will get a single widget arg; Emacs 21 will get
4884 ;; window, overlay, position.
4885 (if (mm-handle-displayed-p
4887 (with-current-buffer (gnus-overlay-buffer overlay)
4888 (widget-get (widget-at (gnus-overlay-start overlay))
4890 (widget-get widget/window :mime-handle)))
4892 (aref gnus-down-mouse-3 0))))))
4894 (defun gnus-widget-press-button (elems el)
4895 (goto-char (widget-get elems :from))
4896 (gnus-article-press-button))
4898 (defvar gnus-displaying-mime nil)
4900 (defun gnus-display-mime (&optional ihandles)
4901 "Display the MIME parts."
4903 (save-selected-window
4904 (let ((window (get-buffer-window gnus-article-buffer))
4907 (select-window window)
4908 ;; We have to do this since selecting the window
4909 ;; may change the point. So we set the window point.
4910 (set-window-point window point)))
4911 (let ((handles ihandles)
4912 (inhibit-read-only t)
4913 handle name type b e display)
4915 ((setq handles (mm-dissect-buffer nil gnus-article-loose-mime))
4916 (when gnus-article-emulate-mime
4917 (mm-uu-dissect-text-parts handles)))
4918 (gnus-article-emulate-mime
4919 (setq handles (mm-uu-dissect))))
4920 (when (and (not ihandles)
4921 (not gnus-displaying-mime))
4922 ;; Top-level call; we clean up.
4923 (when gnus-article-mime-handles
4924 (mm-destroy-parts gnus-article-mime-handles)
4925 (setq gnus-article-mime-handle-alist nil));; A trick.
4926 (setq gnus-article-mime-handles handles)
4927 ;; We allow users to glean info from the handles.
4928 (when gnus-article-mime-part-function
4929 (gnus-mime-part-function handles)))
4931 (or (not (stringp (car handles)))
4934 (when (and (not ihandles)
4935 (not gnus-displaying-mime))
4936 ;; Clean up for mime parts.
4938 (delete-region (point) (point-max)))
4939 (let ((gnus-displaying-mime t))
4940 (gnus-mime-display-part handles)))
4943 (narrow-to-region (point) (point-max))
4944 (gnus-treat-article nil 1 1)
4947 ;; Highlight the headers.
4951 (narrow-to-region (point-min) (point))
4952 (gnus-treat-article 'head))))))))
4954 (defcustom gnus-mime-display-multipart-as-mixed nil
4955 "Display \"multipart\" parts as \"multipart/mixed\".
4957 If t, it overrides nil values of
4958 `gnus-mime-display-multipart-alternative-as-mixed' and
4959 `gnus-mime-display-multipart-related-as-mixed'."
4960 :group 'gnus-article-mime
4963 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
4964 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
4966 :group 'gnus-article-mime
4969 (defcustom gnus-mime-display-multipart-related-as-mixed nil
4970 "Display \"multipart/related\" parts as \"multipart/mixed\".
4972 If displaying \"text/html\" is discouraged \(see
4973 `mm-discouraged-alternatives'\) images or other material inside a
4974 \"multipart/related\" part might be overlooked when this variable is nil."
4976 :group 'gnus-article-mime
4979 (defun gnus-mime-display-part (handle)
4982 ((not (stringp (car handle)))
4983 (gnus-mime-display-single handle))
4984 ;; User-defined multipart
4985 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4986 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4988 ;; multipart/alternative
4989 ((and (equal (car handle) "multipart/alternative")
4990 (not (or gnus-mime-display-multipart-as-mixed
4991 gnus-mime-display-multipart-alternative-as-mixed)))
4992 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4993 (push (cons id handle) gnus-article-mime-handle-alist)
4994 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4995 ;; multipart/related
4996 ((and (equal (car handle) "multipart/related")
4997 (not (or gnus-mime-display-multipart-as-mixed
4998 gnus-mime-display-multipart-related-as-mixed)))
4999 ;;;!!!We should find the start part, but we just default
5000 ;;;!!!to the first part.
5001 ;;(gnus-mime-display-part (cadr handle))
5002 ;;;!!! Most multipart/related is an HTML message plus images.
5003 ;;;!!! Unfortunately we are unable to let W3 display those
5004 ;;;!!! included images, so we just display it as a mixed multipart.
5005 ;;(gnus-mime-display-mixed (cdr handle))
5006 ;;;!!! No, w3 can display everything just fine.
5007 (gnus-mime-display-part (cadr handle)))
5008 ((equal (car handle) "multipart/signed")
5009 (gnus-add-wash-type 'signed)
5010 (gnus-mime-display-security handle))
5011 ((equal (car handle) "multipart/encrypted")
5012 (gnus-add-wash-type 'encrypted)
5013 (gnus-mime-display-security handle))
5014 ;; Other multiparts are handled like multipart/mixed.
5016 (gnus-mime-display-mixed (cdr handle)))))
5018 (defun gnus-mime-part-function (handles)
5019 (if (stringp (car handles))
5020 (mapcar 'gnus-mime-part-function (cdr handles))
5021 (funcall gnus-article-mime-part-function handles)))
5023 (defun gnus-mime-display-mixed (handles)
5024 (mapcar 'gnus-mime-display-part handles))
5026 (defun gnus-mime-display-single (handle)
5027 (let ((type (mm-handle-media-type handle))
5028 (ignored gnus-ignored-mime-types)
5035 (when (string-match (pop ignored) type)
5036 (throw 'ignored nil)))
5037 (if (and (setq not-attachment
5038 (and (not (mm-inline-override-p handle))
5039 (or (not (mm-handle-disposition handle))
5040 (equal (car (mm-handle-disposition handle))
5042 (mm-attachment-override-p handle))))
5043 (mm-automatic-display-p handle)
5045 (mm-inlinable-p handle)
5046 (mm-inlined-p handle))
5047 (mm-automatic-external-display-p type)))
5049 (when (equal (mm-handle-media-supertype handle) "text")
5051 (let ((id (1+ (length gnus-article-mime-handle-alist)))
5053 (push (cons id handle) gnus-article-mime-handle-alist)
5054 (when (or (not display)
5055 (not (gnus-unbuttonized-mime-type-p type)))
5056 (gnus-insert-mime-button
5057 handle id (list (or display (and not-attachment text))))
5058 (gnus-article-insert-newline)
5059 ;; Remember modify the number of forward lines.
5067 (let ((mail-parse-charset gnus-newsgroup-charset)
5068 (mail-parse-ignored-charsets
5069 (save-excursion (condition-case ()
5070 (set-buffer gnus-summary-buffer)
5072 gnus-newsgroup-ignored-charsets)))
5073 (mm-display-part handle t))
5074 (goto-char (point-max)))
5075 ((and text not-attachment)
5079 (gnus-article-insert-newline)
5080 (mm-display-inline handle)
5081 (goto-char (point-max))))
5085 (narrow-to-region beg (point))
5088 (gnus-article-mime-total-parts)
5089 (mm-handle-media-type handle)))))))))
5091 (defun gnus-unbuttonized-mime-type-p (type)
5092 "Say whether TYPE is to be unbuttonized."
5093 (unless gnus-inhibit-mime-unbuttonizing
5095 (let ((types gnus-unbuttonized-mime-types))
5097 (when (string-match (pop types) type)
5098 (throw 'found t)))))
5100 (let ((types gnus-buttonized-mime-types))
5102 (when (string-match (pop types) type)
5103 (throw 'found t)))))))))
5105 (defun gnus-article-insert-newline ()
5106 "Insert a newline, but mark it as undeletable."
5107 (gnus-put-text-property
5108 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
5110 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
5111 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
5114 handle (inhibit-read-only t) from props begend not-pref)
5115 (save-window-excursion
5118 (narrow-to-region (car ibegend)
5121 (goto-char (car ibegend))
5124 (delete-region (point-min) (point-max))
5125 (mm-remove-parts handles))
5126 (setq begend (list (point-marker)))
5128 (unless (setq not-pref (cadr (member preferred ihandles)))
5129 (setq not-pref (car ihandles)))
5132 (not (gnus-unbuttonized-mime-type-p
5133 "multipart/alternative")))
5134 (gnus-add-text-properties
5137 (insert (format "%d. " id))
5141 (unless ,(not ibegend)
5142 (setq gnus-article-mime-handle-alist
5143 ',gnus-article-mime-handle-alist))
5144 (gnus-mime-display-alternative
5145 ',ihandles ',not-pref ',begend ,id))
5146 keymap ,gnus-mime-button-map
5147 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5148 face ,gnus-article-button-face
5151 (widget-convert-button 'link from (point)
5152 :action 'gnus-widget-press-button
5153 :button-keymap gnus-widget-button-keymap)
5155 (while (setq handle (pop handles))
5156 (gnus-add-text-properties
5159 (insert (format "(%c) %-18s"
5160 (if (equal handle preferred) ?* ? )
5161 (mm-handle-media-type handle)))
5165 (unless ,(not ibegend)
5166 (setq gnus-article-mime-handle-alist
5167 ',gnus-article-mime-handle-alist))
5168 (gnus-mime-display-alternative
5169 ',ihandles ',handle ',begend ,id))
5170 keymap ,gnus-mime-button-map
5171 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5172 face ,gnus-article-button-face
5175 (widget-convert-button 'link from (point)
5176 :action 'gnus-widget-press-button
5177 :button-keymap gnus-widget-button-keymap)
5181 (if (stringp (car preferred))
5182 (gnus-display-mime preferred)
5183 (let ((mail-parse-charset gnus-newsgroup-charset)
5184 (mail-parse-ignored-charsets
5185 (with-current-buffer gnus-summary-buffer
5186 gnus-newsgroup-ignored-charsets)))
5187 (mm-display-part preferred)
5191 (narrow-to-region (car begend) (point-max))
5193 nil (length gnus-article-mime-handle-alist)
5194 (gnus-article-mime-total-parts)
5195 (mm-handle-media-type handle))))))
5196 (goto-char (point-max))
5197 (setcdr begend (point-marker)))))
5199 (goto-char point))))
5201 (defconst gnus-article-wash-status-strings
5202 (let ((alist '((cite "c" "Possible hidden citation text"
5203 " " "All citation text visible")
5204 (headers "h" "Hidden headers"
5205 " " "All headers visible.")
5206 (pgp "p" "Encrypted or signed message status hidden"
5207 " " "No hidden encryption nor digital signature status")
5208 (signature "s" "Signature has been hidden"
5209 " " "Signature is visible")
5210 (overstrike "o" "Overstrike (^H) characters applied"
5211 " " "No overstrike characters applied")
5212 (gnus-show-mime "m" "Mime processing is activated"
5213 " " "Mime processing is not activated")
5214 (emphasis "e" "/*_Emphasis_*/ characters applied"
5215 " " "No /*_emphasis_*/ characters applied")))
5217 (dolist (entry alist result)
5218 (let ((key (nth 0 entry))
5219 (on (copy-sequence (nth 1 entry)))
5220 (on-help (nth 2 entry))
5221 (off (copy-sequence (nth 3 entry)))
5222 (off-help (nth 4 entry)))
5223 (put-text-property 0 1 'help-echo on-help on)
5224 (put-text-property 0 1 'help-echo off-help off)
5225 (push (list key on off) result))))
5226 "Alist of strings describing wash status in the mode line.
5227 Each entry has the form (KEY ON OF), where the KEY is a symbol
5228 representing the particular washing function, ON is the string to use
5229 in the article mode line when the washing function is active, and OFF
5230 is the string to use when it is inactive.")
5232 (defun gnus-article-wash-status-entry (key value)
5233 (let ((entry (assoc key gnus-article-wash-status-strings)))
5234 (if value (nth 1 entry) (nth 2 entry))))
5236 (defun gnus-article-wash-status ()
5237 "Return a string which display status of article washing."
5238 (with-current-buffer gnus-article-buffer
5239 (let ((cite (memq 'cite gnus-article-wash-types))
5240 (headers (memq 'headers gnus-article-wash-types))
5241 (boring (memq 'boring-headers gnus-article-wash-types))
5242 (pgp (memq 'pgp gnus-article-wash-types))
5243 (pem (memq 'pem gnus-article-wash-types))
5244 (signed (memq 'signed gnus-article-wash-types))
5245 (encrypted (memq 'encrypted gnus-article-wash-types))
5246 (signature (memq 'signature gnus-article-wash-types))
5247 (overstrike (memq 'overstrike gnus-article-wash-types))
5248 (emphasis (memq 'emphasis gnus-article-wash-types)))
5250 (gnus-article-wash-status-entry 'cite cite)
5251 (gnus-article-wash-status-entry 'headers (or headers boring))
5252 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5253 (gnus-article-wash-status-entry 'signature signature)
5254 (gnus-article-wash-status-entry 'overstrike overstrike)
5255 (gnus-article-wash-status-entry 'gnus-show-mime gnus-show-mime)
5256 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5258 (defun gnus-add-wash-type (type)
5259 "Add a washing of TYPE to the current status."
5260 (add-to-list 'gnus-article-wash-types type))
5262 (defun gnus-delete-wash-type (type)
5263 "Add a washing of TYPE to the current status."
5264 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5266 (defun gnus-add-image (category image)
5267 "Add IMAGE of CATEGORY to the list of displayed images."
5268 (let ((entry (assq category gnus-article-image-alist)))
5270 (setq entry (list category))
5271 (push entry gnus-article-image-alist))
5272 (nconc entry (list image))))
5274 (defun gnus-delete-images (category)
5275 "Delete all images in CATEGORY."
5276 (let ((entry (assq category gnus-article-image-alist)))
5277 (dolist (image (cdr entry))
5278 (gnus-remove-image image category))
5279 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5280 (gnus-delete-wash-type category)))
5282 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5284 (defun gnus-article-maybe-hide-headers ()
5285 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5286 Provided for backwards compatibility."
5287 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5288 (not (with-current-buffer gnus-summary-buffer
5289 gnus-have-all-headers)))
5290 (not gnus-inhibit-hiding))
5291 (gnus-article-hide-headers)))
5295 (defun gnus-output-to-file (file-name)
5296 "Append the current article to a file named FILE-NAME."
5297 (let ((artbuf (current-buffer)))
5299 (insert-buffer-substring artbuf)
5300 ;; Append newline at end of the buffer as separator, and then
5302 (goto-char (point-max))
5304 (let ((file-name-coding-system nnmail-pathname-coding-system))
5305 (write-region-as-binary (point-min) (point-max) file-name 'append))
5308 (defun gnus-narrow-to-page (&optional arg)
5309 "Narrow the article buffer to a page.
5310 If given a numerical ARG, move forward ARG pages."
5312 (setq arg (if arg (prefix-numeric-value arg) 0))
5314 (set-buffer gnus-article-buffer)
5315 (goto-char (point-min))
5317 ;; Remove any old next/prev buttons.
5318 (when (gnus-visual-p 'page-marker)
5319 (let ((inhibit-read-only t))
5320 (gnus-remove-text-with-property 'gnus-prev)
5321 (gnus-remove-text-with-property 'gnus-next)))
5324 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5326 (re-search-forward page-delimiter nil 'move arg)))
5327 (goto-char (match-end 0))
5329 (goto-char (point-min))
5330 (setq gnus-page-broken
5331 (and (re-search-forward page-delimiter nil t) t))))
5332 (when gnus-page-broken
5335 (if (re-search-forward page-delimiter nil 'move)
5338 (when (and (gnus-visual-p 'page-marker)
5339 (> (point-min) (save-restriction (widen) (point-min))))
5341 (goto-char (point-min))
5342 (gnus-insert-prev-page-button)))
5343 (when (and (gnus-visual-p 'page-marker)
5344 (< (+ (point-max) 2) (buffer-size)))
5346 (goto-char (point-max))
5347 (gnus-insert-next-page-button))))))
5349 ;; Article mode commands
5351 (defun gnus-article-goto-next-page ()
5352 "Show the next page of the article."
5354 (when (gnus-article-next-page)
5355 (goto-char (point-min))
5356 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5359 (defun gnus-article-goto-prev-page ()
5360 "Show the previous page of the article."
5363 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5364 (gnus-article-prev-page nil)))
5366 ;; This is cleaner but currently breaks `gnus-pick-mode':
5368 ;; (defun gnus-article-goto-next-page ()
5369 ;; "Show the next page of the article."
5371 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5372 ;; (gnus-summary-next-page)))
5374 ;; (defun gnus-article-goto-prev-page ()
5375 ;; "Show the next page of the article."
5377 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5378 ;; (gnus-summary-prev-page)))
5380 (defun gnus-article-next-page (&optional lines)
5381 "Show the next page of the current article.
5382 If end of article, return non-nil. Otherwise return nil.
5383 Argument LINES specifies lines to be scrolled up."
5385 (move-to-window-line -1)
5388 (and (pos-visible-in-window-p) ;Not continuation line.
5389 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5390 ;; Nothing in this page.
5391 (if (or (not gnus-page-broken)
5396 (eobp)))) ;Real end-of-buffer?
5398 (when gnus-article-over-scroll
5399 (gnus-article-next-page-1 lines))
5401 (gnus-narrow-to-page 1) ;Go to next page.
5403 ;; More in this page.
5404 (gnus-article-next-page-1 lines)
5407 (defun gnus-article-next-page-1 (lines)
5408 (let ((scroll-in-place nil))
5412 ;; Long lines may cause an end-of-buffer error.
5413 (goto-char (point-max)))))
5414 (move-to-window-line 0))
5416 (defun gnus-article-prev-page (&optional lines)
5417 "Show previous page of current article.
5418 Argument LINES specifies lines to be scrolled down."
5420 (move-to-window-line 0)
5421 (if (and gnus-page-broken
5423 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5425 (gnus-narrow-to-page -1) ;Go to previous page.
5426 (goto-char (point-max))
5428 (let ((scroll-in-place nil))
5432 (beginning-of-buffer
5433 (goto-char (point-min))))
5434 (move-to-window-line 0)))))
5436 (defun gnus-article-only-boring-p ()
5437 "Decide whether there is only boring text remaining in the article.
5438 Something \"interesting\" is a word of at least two letters that does
5439 not have a face in `gnus-article-boring-faces'."
5440 (when (and gnus-article-skip-boring
5441 (boundp 'gnus-article-boring-faces)
5442 (symbol-value 'gnus-article-boring-faces))
5445 (while (re-search-forward "\\b\\w\\w" nil t)
5447 (when (not (gnus-intersection
5448 (gnus-faces-at (point))
5449 (symbol-value 'gnus-article-boring-faces)))
5450 (throw 'only-boring nil)))
5451 (throw 'only-boring t)))))
5453 (defun gnus-article-refer-article ()
5454 "Read article specified by message-id around point."
5457 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
5458 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
5459 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
5460 (let ((msg-id (concat "<" (match-string 0) ">")))
5461 (set-buffer gnus-summary-buffer)
5462 (gnus-summary-refer-article msg-id))
5463 (error "No references around point"))))
5465 (defun gnus-article-show-summary ()
5466 "Reconfigure windows to show summary buffer."
5468 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5469 (error "There is no summary buffer for this article buffer")
5470 (gnus-article-set-globals)
5471 (gnus-configure-windows 'article)
5472 (gnus-summary-goto-subject gnus-current-article)
5473 (gnus-summary-position-point)))
5475 (defun gnus-article-describe-briefly ()
5476 "Describe article mode commands briefly."
5478 (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")))
5480 (defun gnus-article-summary-command ()
5481 "Execute the last keystroke in the summary buffer."
5483 (let ((obuf (current-buffer))
5484 (owin (current-window-configuration))
5486 (switch-to-buffer gnus-article-current-summary 'norecord)
5487 (setq func (lookup-key (current-local-map) (this-command-keys)))
5488 (call-interactively func)
5490 (set-window-configuration owin)
5491 (set-window-point (get-buffer-window (current-buffer)) (point))))
5493 (defun gnus-article-summary-command-nosave ()
5494 "Execute the last keystroke in the summary buffer."
5497 (pop-to-buffer gnus-article-current-summary 'norecord)
5498 (setq func (lookup-key (current-local-map) (this-command-keys)))
5499 (call-interactively func)))
5501 (defun gnus-article-check-buffer ()
5502 "Beep if not in an article buffer."
5503 (unless (eq (get-buffer gnus-article-buffer) (current-buffer))
5504 (error "Command invoked outside of a Gnus article buffer")))
5506 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5507 "Read a summary buffer key sequence and execute it from the article buffer."
5509 (gnus-article-check-buffer)
5511 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5512 "Zc" "ZC" "ZE" "ZJ" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5513 "=" "^" "\M-^" "|"))
5519 '("n" "Gn" "p" "Gp"))
5522 (set-buffer gnus-article-current-summary)
5523 (let (gnus-pick-mode)
5524 (push (or key last-command-event) unread-command-events)
5525 (setq keys (static-if (featurep 'xemacs)
5526 (events-to-keys (read-key-sequence nil))
5527 (read-key-sequence nil)))))
5530 (if (or (member keys nosaves)
5531 (member keys nosave-but-article)
5532 (member keys nosave-in-article))
5534 (save-window-excursion
5535 (pop-to-buffer gnus-article-current-summary 'norecord)
5536 ;; We disable the pick minor mode commands.
5537 (let (gnus-pick-mode)
5538 (setq func (lookup-key (current-local-map) keys))))
5542 (unless (member keys nosave-in-article)
5543 (set-buffer gnus-article-current-summary))
5544 (call-interactively func)
5545 (setq new-sum-point (point)))
5546 (when (member keys nosave-but-article)
5547 (pop-to-buffer gnus-article-buffer 'norecord)))
5548 ;; These commands should restore window configuration.
5549 (let ((obuf (current-buffer))
5550 (owin (current-window-configuration))
5552 win func in-buffer selected new-sum-start new-sum-hscroll)
5553 (cond (not-restore-window
5554 (pop-to-buffer gnus-article-current-summary 'norecord))
5555 ((setq win (get-buffer-window gnus-article-current-summary))
5556 (select-window win))
5558 (switch-to-buffer gnus-article-current-summary 'norecord)))
5559 (setq in-buffer (current-buffer))
5560 ;; We disable the pick minor mode commands.
5561 (if (and (setq func (let (gnus-pick-mode)
5562 (lookup-key (current-local-map) keys)))
5565 (call-interactively func)
5566 (when (eq win (selected-window))
5567 (setq new-sum-point (point)
5568 new-sum-start (window-start win)
5569 new-sum-hscroll (window-hscroll win))
5570 (when (eq in-buffer (current-buffer))
5571 (setq selected (gnus-summary-select-article))
5573 (unless not-restore-window
5574 (set-window-configuration owin))
5575 (when (eq selected 'old)
5577 (set-window-start (get-buffer-window (current-buffer))
5579 (set-window-point (get-buffer-window (current-buffer))
5581 (when (and (not not-restore-window)
5583 (set-window-point win new-sum-point)
5584 (set-window-start win new-sum-start)
5585 (set-window-hscroll win new-sum-hscroll)))))
5586 (set-window-configuration owin)
5589 (defun gnus-article-describe-key (key)
5590 "Display documentation of the function invoked by KEY. KEY is a string."
5591 (interactive "kDescribe key: ")
5592 (gnus-article-check-buffer)
5593 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5595 (set-buffer gnus-article-current-summary)
5596 (let (gnus-pick-mode)
5597 (if (featurep 'xemacs)
5599 (push (elt key 0) unread-command-events)
5600 (setq key (events-to-keys
5601 (read-key-sequence "Describe key: "))))
5602 (setq unread-command-events
5604 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5606 (setq key (read-key-sequence "Describe key: "))))
5608 (describe-key key)))
5610 (defun gnus-article-describe-key-briefly (key &optional insert)
5611 "Display documentation of the function invoked by KEY. KEY is a string."
5612 (interactive "kDescribe key: \nP")
5613 (gnus-article-check-buffer)
5614 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5616 (set-buffer gnus-article-current-summary)
5617 (let (gnus-pick-mode)
5618 (if (featurep 'xemacs)
5620 (push (elt key 0) unread-command-events)
5621 (setq key (events-to-keys
5622 (read-key-sequence "Describe key: "))))
5623 (setq unread-command-events
5625 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5627 (setq key (read-key-sequence "Describe key: "))))
5628 (describe-key-briefly key insert))
5629 (describe-key-briefly key insert)))
5631 (defun gnus-article-reply-with-original (&optional wide)
5632 "Start composing a reply mail to the current message.
5633 The text in the region will be yanked. If the region isn't active,
5634 the entire article will be yanked."
5636 (let ((article (cdr gnus-article-current))
5638 (if (not (gnus-region-active-p))
5639 (with-current-buffer gnus-summary-buffer
5640 (gnus-summary-reply (list (list article)) wide))
5641 (setq contents (buffer-substring (point) (mark t)))
5642 ;; Deactivate active regions.
5643 (when (and (boundp 'transient-mark-mode)
5644 transient-mark-mode)
5645 (setq mark-active nil))
5646 (with-current-buffer gnus-summary-buffer
5648 (list (list article contents)) wide)))))
5650 (defun gnus-article-followup-with-original ()
5651 "Compose a followup to the current article.
5652 The text in the region will be yanked. If the region isn't active,
5653 the entire article will be yanked."
5655 (let ((article (cdr gnus-article-current))
5657 (if (not (gnus-region-active-p))
5658 (with-current-buffer gnus-summary-buffer
5659 (gnus-summary-followup (list (list article))))
5660 (setq contents (buffer-substring (point) (mark t)))
5661 ;; Deactivate active regions.
5662 (when (and (boundp 'transient-mark-mode)
5663 transient-mark-mode)
5664 (setq mark-active nil))
5665 (with-current-buffer gnus-summary-buffer
5666 (gnus-summary-followup
5667 (list (list article contents)))))))
5669 (defun gnus-article-hide (&optional arg force)
5670 "Hide all the gruft in the current article.
5671 This means that signatures, cited text and (some) headers will be
5673 If given a prefix, show the hidden text instead."
5674 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5675 (gnus-article-hide-headers arg)
5676 (gnus-article-hide-list-identifiers arg)
5677 (gnus-article-hide-citation-maybe arg force)
5678 (gnus-article-hide-signature arg))
5680 (defun gnus-article-maybe-highlight ()
5681 "Do some article highlighting if article highlighting is requested."
5682 (when (gnus-visual-p 'article-highlight 'highlight)
5683 (gnus-article-highlight-some)))
5685 (defun gnus-check-group-server ()
5686 ;; Make sure the connection to the server is alive.
5687 (unless (gnus-server-opened
5688 (gnus-find-method-for-group gnus-newsgroup-name))
5689 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5690 (gnus-request-group gnus-newsgroup-name t)))
5693 (autoload 'nneething-get-file-name "nneething"))
5695 (defun gnus-request-article-this-buffer (article group)
5696 "Get an article and insert it into this buffer."
5697 (let (do-update-line sparse-header)
5701 (gnus-kill-all-overlays)
5702 (setq group (or group gnus-newsgroup-name))
5704 ;; Using `gnus-request-article' directly will insert the article into
5705 ;; `nntp-server-buffer' - so we'll save some time by not having to
5706 ;; copy it from the server buffer into the article buffer.
5708 ;; We only request an article by message-id when we do not have the
5709 ;; headers for it, so we'll have to get those.
5710 (when (stringp article)
5711 (gnus-read-header article))
5713 ;; If the article number is negative, that means that this article
5714 ;; doesn't belong in this newsgroup (possibly), so we find its
5715 ;; message-id and request it by id instead of number.
5716 (when (and (numberp article)
5718 (get-buffer gnus-summary-buffer)
5719 (gnus-buffer-exists-p gnus-summary-buffer))
5721 (set-buffer gnus-summary-buffer)
5722 (let ((header (gnus-summary-article-header article)))
5725 ((memq article gnus-newsgroup-sparse)
5726 ;; This is a sparse gap article.
5727 (setq do-update-line article)
5728 (setq article (mail-header-id header))
5729 (setq sparse-header (gnus-read-header article))
5730 (setq gnus-newsgroup-sparse
5731 (delq article gnus-newsgroup-sparse)))
5733 ;; It's a real article.
5734 (setq article (mail-header-id header)))
5736 ;; It is an extracted pseudo-article.
5737 (setq article 'pseudo)
5738 (gnus-request-pseudo-article header))))
5740 (let ((method (gnus-find-method-for-group
5741 gnus-newsgroup-name)))
5742 (when (and (eq (car method) 'nneething)
5744 (let ((dir (nneething-get-file-name
5745 (mail-header-id header))))
5746 (when (and (stringp dir)
5747 (file-directory-p dir))
5748 (setq article 'nneething)
5749 (gnus-group-enter-directory dir))))))))
5752 ;; Refuse to select canceled articles.
5753 ((and (numberp article)
5755 (get-buffer gnus-summary-buffer)
5756 (gnus-buffer-exists-p gnus-summary-buffer)
5757 (eq (cdr (with-current-buffer gnus-summary-buffer
5758 (assq article gnus-newsgroup-reads)))
5759 gnus-canceled-mark))
5761 ;; We first check `gnus-original-article-buffer'.
5762 ((and (get-buffer gnus-original-article-buffer)
5764 (with-current-buffer gnus-original-article-buffer
5765 (and (equal (car gnus-original-article) group)
5766 (eq (cdr gnus-original-article) article))))
5767 (insert-buffer-substring gnus-original-article-buffer)
5769 ;; Check the backlog.
5770 ((and gnus-keep-backlog
5771 (gnus-backlog-request-article group article (current-buffer)))
5773 ;; Check asynchronous pre-fetch.
5774 ((gnus-async-request-fetched-article group article (current-buffer))
5775 (gnus-async-prefetch-next group article gnus-summary-buffer)
5776 (when (and (numberp article) gnus-keep-backlog)
5777 (gnus-backlog-enter-article group article (current-buffer)))
5780 ((and gnus-use-cache
5782 (gnus-cache-request-article article group))
5784 ;; Check the agent cache.
5785 ((gnus-agent-request-article article group)
5787 ;; Get the article and put into the article buffer.
5788 ((or (stringp article)
5790 (let ((gnus-override-method gnus-override-method)
5791 (methods (and (stringp article)
5792 gnus-refer-article-method))
5793 (backend (car (gnus-find-method-for-group
5794 gnus-newsgroup-name)))
5796 (inhibit-read-only t))
5797 (if (or (not (listp methods))
5798 (and (symbolp (car methods))
5799 (assq (car methods) nnoo-definition-alist)))
5800 (setq methods (list methods)))
5801 (when (and (null gnus-override-method)
5803 (setq gnus-override-method (pop methods)))
5805 (when (eq gnus-override-method 'current)
5806 (setq gnus-override-method
5807 (with-current-buffer gnus-summary-buffer
5808 gnus-current-select-method)))
5810 (gnus-kill-all-overlays)
5811 (let ((gnus-newsgroup-name group))
5812 (gnus-check-group-server))
5814 ((gnus-request-article article group (current-buffer))
5815 (when (numberp article)
5816 (gnus-async-prefetch-next group article
5817 gnus-summary-buffer)
5818 (when gnus-keep-backlog
5819 (gnus-backlog-enter-article
5820 group article (current-buffer))))
5821 (setq result 'article))
5823 (setq gnus-override-method (pop methods)))
5824 ((not (string-match "^400 "
5825 (nnheader-get-report backend)))
5826 ;; If we get 400 server disconnect, reconnect and
5827 ;; retry; otherwise, assume the article has expired.
5828 (setq result 'done))))
5829 (and (eq result 'article) 'article)))
5833 ;; Associate this article with the current summary buffer.
5834 (setq gnus-article-current-summary gnus-summary-buffer)
5836 ;; Take the article from the original article buffer
5837 ;; and place it in the buffer it's supposed to be in.
5838 (when (and (get-buffer gnus-article-buffer)
5839 (equal (buffer-name (current-buffer))
5840 (buffer-name (get-buffer gnus-article-buffer))))
5842 (if (get-buffer gnus-original-article-buffer)
5843 (set-buffer gnus-original-article-buffer)
5844 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5845 (buffer-disable-undo)
5846 (setq major-mode 'gnus-original-article-mode)
5847 (setq buffer-read-only t))
5848 (let ((inhibit-read-only t))
5850 (insert-buffer-substring gnus-article-buffer))
5851 (setq gnus-original-article (cons group article)))
5854 (run-hooks 'gnus-article-decode-hook)
5855 ;; Mark article as decoded or not.
5856 (setq gnus-article-decoded-p gnus-article-decode-hook))
5858 ;; Update sparse articles.
5859 (when (and do-update-line
5860 (or (numberp article)
5862 (let ((buf (current-buffer)))
5863 (set-buffer gnus-summary-buffer)
5864 (gnus-summary-update-article do-update-line sparse-header)
5865 (gnus-summary-goto-subject do-update-line nil t)
5866 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5868 (set-buffer buf))))))
5874 (defcustom gnus-article-edit-mode-hook nil
5875 "Hook run in article edit mode buffers."
5876 :group 'gnus-article-various
5879 (defcustom gnus-article-edit-article-setup-function
5880 'gnus-article-mime-edit-article-setup
5881 "Function called to setup an editing article buffer."
5882 :group 'gnus-article-various
5885 (defvar gnus-article-edit-done-function nil)
5887 (defvar gnus-article-edit-mode-map nil)
5889 ;; Should we be using derived.el for this?
5890 (unless gnus-article-edit-mode-map
5891 (setq gnus-article-edit-mode-map (make-keymap))
5892 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5894 (gnus-define-keys gnus-article-edit-mode-map
5895 "\C-c?" describe-mode
5896 "\C-c\C-c" gnus-article-edit-done
5897 "\C-c\C-k" gnus-article-edit-exit
5898 "\C-c\C-f\C-t" message-goto-to
5899 "\C-c\C-f\C-o" message-goto-from
5900 "\C-c\C-f\C-b" message-goto-bcc
5901 ;;"\C-c\C-f\C-w" message-goto-fcc
5902 "\C-c\C-f\C-c" message-goto-cc
5903 "\C-c\C-f\C-s" message-goto-subject
5904 "\C-c\C-f\C-r" message-goto-reply-to
5905 "\C-c\C-f\C-n" message-goto-newsgroups
5906 "\C-c\C-f\C-d" message-goto-distribution
5907 "\C-c\C-f\C-f" message-goto-followup-to
5908 "\C-c\C-f\C-m" message-goto-mail-followup-to
5909 "\C-c\C-f\C-k" message-goto-keywords
5910 "\C-c\C-f\C-u" message-goto-summary
5911 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5912 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5913 "\C-c\C-b" message-goto-body
5914 "\C-c\C-i" message-goto-signature
5916 "\C-c\C-t" message-insert-to
5917 "\C-c\C-n" message-insert-newsgroups
5918 "\C-c\C-o" message-sort-headers
5919 "\C-c\C-e" message-elide-region
5920 "\C-c\C-v" message-delete-not-region
5921 "\C-c\C-z" message-kill-to-signature
5922 "\M-\r" message-newline-and-reformat
5923 "\C-c\C-a" mml-attach-file
5924 "\C-a" message-beginning-of-line
5926 "\M-;" comment-region)
5928 (gnus-define-keys (gnus-article-edit-wash-map
5929 "\C-c\C-w" gnus-article-edit-mode-map)
5930 "f" gnus-article-edit-full-stops))
5933 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5935 ["Fetch To" message-insert-to t]
5936 ["Fetch Newsgroups" message-insert-newsgroups t]
5938 ["To" message-goto-to t]
5939 ["From" message-goto-from t]
5940 ["Subject" message-goto-subject t]
5941 ["Cc" message-goto-cc t]
5942 ["Reply-To" message-goto-reply-to t]
5943 ["Summary" message-goto-summary t]
5944 ["Keywords" message-goto-keywords t]
5945 ["Newsgroups" message-goto-newsgroups t]
5946 ["Followup-To" message-goto-followup-to t]
5947 ["Mail-Followup-To" message-goto-mail-followup-to t]
5948 ["Distribution" message-goto-distribution t]
5949 ["Body" message-goto-body t]
5950 ["Signature" message-goto-signature t]))
5952 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
5953 "Major mode for editing articles.
5954 This is an extended text-mode.
5956 \\{gnus-article-edit-mode-map}"
5957 (make-local-variable 'gnus-article-edit-done-function)
5958 (make-local-variable 'gnus-prev-winconf)
5959 (set (make-local-variable 'font-lock-defaults)
5960 '(message-font-lock-keywords t))
5961 (set (make-local-variable 'mail-header-separator) "")
5962 (set (make-local-variable 'gnus-article-edit-mode) t)
5963 (easy-menu-add message-mode-field-menu message-mode-map)
5964 (setq buffer-read-only nil)
5965 (buffer-enable-undo)
5968 (defun gnus-article-edit (&optional force)
5969 "Edit the current article.
5970 This will have permanent effect only in mail groups.
5971 If FORCE is non-nil, allow editing of articles even in read-only
5974 (when (and (not force)
5975 (gnus-group-read-only-p))
5976 (error "The current newsgroup does not support article editing"))
5977 (gnus-article-date-original)
5978 (gnus-article-edit-article
5980 `(lambda (no-highlight)
5982 (gnus-summary-edit-article-done
5983 ,(or (mail-header-references gnus-current-headers) "")
5984 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5986 (defun gnus-article-edit-article (start-func exit-func)
5987 "Start editing the contents of the current article buffer."
5988 (let ((winconf (current-window-configuration)))
5989 (set-buffer gnus-article-buffer)
5990 (gnus-article-edit-mode)
5991 (funcall start-func)
5992 (set-buffer-modified-p nil)
5993 (gnus-configure-windows 'edit-article)
5994 (setq gnus-article-edit-done-function exit-func)
5995 (setq gnus-prev-winconf winconf)
5996 (when gnus-article-edit-article-setup-function
5997 (funcall gnus-article-edit-article-setup-function))
5998 (gnus-message 6 "C-c C-c to end edits; C-c C-k to exit")))
6000 (defun gnus-article-edit-done (&optional arg)
6001 "Update the article edits and exit."
6003 (let ((func gnus-article-edit-done-function)
6004 (buf (current-buffer))
6005 (start (window-start))
6007 (winconf gnus-prev-winconf))
6008 (remove-hook 'gnus-article-mode-hook
6009 'gnus-article-mime-edit-article-unwind)
6010 (widen) ;; Widen it in case that users narrowed the buffer.
6013 ;; The cache and backlog have to be flushed somewhat.
6014 (when gnus-keep-backlog
6015 (gnus-backlog-remove-article
6016 (car gnus-article-current) (cdr gnus-article-current)))
6017 ;; Flush original article as well.
6019 (when (get-buffer gnus-original-article-buffer)
6020 (set-buffer gnus-original-article-buffer)
6021 (setq gnus-original-article nil)))
6022 (when gnus-use-cache
6023 (gnus-cache-update-article
6024 (car gnus-article-current) (cdr gnus-article-current)))
6025 ;; We remove all text props from the article buffer.
6026 (kill-all-local-variables)
6027 (set-text-properties (point-min) (point-max) nil)
6029 (set-window-configuration winconf)
6031 (set-window-start (get-buffer-window buf) start)
6032 (set-window-point (get-buffer-window buf) (point)))
6033 (gnus-summary-show-article))
6035 (defun gnus-article-edit-exit ()
6036 "Exit the article editing without updating."
6038 (when (or (not (buffer-modified-p))
6039 (yes-or-no-p "Article modified; kill anyway? "))
6040 (let ((curbuf (current-buffer))
6042 (window-start (window-start)))
6044 (if (gnus-buffer-live-p gnus-original-article-buffer)
6045 (insert-buffer-substring gnus-original-article-buffer))
6046 (let ((winconf gnus-prev-winconf))
6047 (kill-all-local-variables)
6049 (set-window-configuration winconf)
6050 ;; Tippy-toe some to make sure that point remains where it was.
6051 (save-current-buffer
6053 (set-window-start (get-buffer-window (current-buffer)) window-start)
6055 (gnus-summary-show-article)))
6057 (defun gnus-article-edit-full-stops ()
6058 "Interactively repair spacing at end of sentences."
6061 (goto-char (point-min))
6062 (search-forward-regexp "^$" nil t)
6063 (let ((case-fold-search nil))
6064 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
6067 ;;; Article editing with MIME-Edit
6070 (defcustom gnus-article-mime-edit-article-setup-hook nil
6071 "Hook run after setting up a MIME editing article buffer."
6072 :group 'gnus-article-various
6075 (defun gnus-article-mime-edit-article-unwind ()
6076 "Unwind `gnus-article-buffer' if article editing was given up."
6077 (remove-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6078 (when (featurep 'font-lock)
6079 (setq font-lock-defaults nil)
6080 (font-lock-mode -1))
6081 (when mime-edit-mode-flag
6082 (mime-edit-exit 'nomime 'no-error)
6085 (defun gnus-article-mime-edit-article-setup ()
6086 "Convert current buffer to MIME-Edit buffer and turn on MIME-Edit mode
6087 after replacing with the original article."
6088 (setq gnus-show-mime t)
6089 (setq gnus-article-edit-done-function
6090 `(lambda (&rest args)
6091 (when mime-edit-mode-flag
6092 (let (mime-edit-insert-user-agent-field)
6095 (goto-char (point-min))
6096 (let (case-fold-search)
6097 (when (re-search-forward
6098 (format "^%s$" (regexp-quote mail-header-separator))
6100 (replace-match "")))
6101 (apply ,gnus-article-edit-done-function args)
6104 (buffer-substring-no-properties (point-min) (point-max))
6105 (set-buffer (get-buffer-create gnus-original-article-buffer))
6107 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6108 (set-buffer gnus-article-buffer)
6109 (gnus-article-prepare-display)))
6110 (substitute-key-definition 'gnus-article-edit-done
6111 'gnus-article-mime-edit-done
6112 gnus-article-edit-mode-map)
6113 (substitute-key-definition 'gnus-article-edit-exit
6114 'gnus-article-mime-edit-exit
6115 gnus-article-edit-mode-map)
6117 (insert-buffer-substring gnus-original-article-buffer)
6118 (unless (member (with-current-buffer gnus-summary-buffer
6119 gnus-newsgroup-name)
6120 '("nndraft:delayed" "nndraft:drafts"))
6121 (let ((ofn (symbol-function 'mime-edit-decode-single-part-in-buffer)))
6122 (fset 'mime-edit-decode-single-part-in-buffer
6123 (lambda (&rest args)
6124 (if (let ((content-type (car args)))
6125 (and (eq 'message (mime-content-type-primary-type
6127 (eq 'rfc822 (mime-content-type-subtype
6129 (setcar (cdr args) 'not-decode-text))
6133 (fset 'mime-edit-decode-single-part-in-buffer ofn))))
6134 (when (featurep 'font-lock)
6135 (set (make-local-variable 'font-lock-defaults)
6136 '(message-font-lock-keywords t))
6137 (font-lock-set-defaults)
6138 (turn-on-font-lock))
6139 (set-buffer-modified-p nil)
6140 (delete-other-windows)
6141 (add-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6142 (gnus-run-hooks 'gnus-article-mime-edit-article-setup-hook))
6144 (defun gnus-article-mime-edit-done (&optional arg)
6145 "Update the article MIME edits and exit."
6147 (when (featurep 'font-lock)
6148 (setq font-lock-defaults nil)
6149 (font-lock-mode -1))
6150 (let ((inhibit-read-only t))
6151 (gnus-article-edit-done arg)))
6153 (defun gnus-article-mime-edit-exit ()
6154 "Exit the article MIME editing without updating."
6156 (when (or (not (buffer-modified-p))
6157 (yes-or-no-p "Article modified; kill anyway? "))
6158 (when (featurep 'font-lock)
6159 (setq font-lock-defaults nil)
6160 (font-lock-mode -1))
6161 (when mime-edit-mode-flag
6162 (let (mime-edit-insert-user-agent-field)
6165 (goto-char (point-min))
6166 (let (case-fold-search)
6167 (when (re-search-forward
6168 (format "^%s$" (regexp-quote mail-header-separator)) nil t)
6169 (replace-match "")))
6170 (let ((winconf gnus-prev-winconf))
6172 (buffer-substring-no-properties (point-min) (point-max))
6173 (set-buffer (get-buffer-create gnus-original-article-buffer))
6175 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6176 (set-buffer gnus-article-buffer)
6177 (gnus-article-prepare-display)
6178 (set-window-configuration winconf))))
6181 ;;; Article highlights
6184 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
6186 ;;; Internal Variables:
6188 (defcustom gnus-button-url-regexp
6189 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
6190 "\\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:]]\\)"
6191 "\\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\\)\\)")
6192 "Regular expression that matches URLs."
6193 :group 'gnus-article-buttons
6196 (defcustom gnus-button-valid-fqdn-regexp
6197 message-valid-fqdn-regexp
6198 "Regular expression that matches a valid FQDN."
6200 :group 'gnus-article-buttons
6203 (defcustom gnus-button-man-handler 'manual-entry
6204 "Function to use for displaying man pages.
6205 The function must take at least one argument with a string naming the
6208 :type '(choice (function-item :tag "Man" manual-entry)
6209 (function-item :tag "Woman" woman)
6210 (function :tag "Other"))
6211 :group 'gnus-article-buttons)
6213 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
6214 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
6215 If the default site is too slow, try to find a CTAN mirror, see
6216 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
6217 the variable `gnus-button-handle-ctan'."
6219 :group 'gnus-article-buttons
6220 :link '(custom-manual "(gnus)Group Parameters")
6221 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
6222 (const "http://tug.ctan.org/tex-archive/")
6223 (const "http://www.dante.de/CTAN/")
6224 (string :tag "Other")))
6226 (defcustom gnus-button-ctan-handler 'browse-url
6227 "Function to use for displaying CTAN links.
6228 The function must take one argument, the string naming the URL."
6230 :type '(choice (function-item :tag "Browse Url" browse-url)
6231 (function :tag "Other"))
6232 :group 'gnus-article-buttons)
6234 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
6235 "Bogus strings removed from CTAN URLs."
6237 :group 'gnus-article-buttons
6238 :type '(choice (const "^/?tex-archive/\\|/")
6239 (regexp :tag "Other")))
6241 (defcustom gnus-button-ctan-directory-regexp
6244 "biblio\\|digests\\|dviware\\|fonts\\|graphics\\|help\\|"
6245 "indexing\\|info\\|language\\|macros\\|support\\|systems\\|"
6246 "tds\\|tools\\|usergrps\\|web\\|nonfree\\|obsolete"
6248 "Regular expression for ctan directories.
6249 It should match all directories in the top level of `gnus-ctan-url'."
6251 :group 'gnus-article-buttons
6254 (defcustom gnus-button-mid-or-mail-regexp
6255 (concat "\\b\\(<?[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t ]*@"
6256 ;; Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
6257 gnus-button-valid-fqdn-regexp
6259 "Regular expression that matches a message ID or a mail address."
6261 :group 'gnus-article-buttons
6264 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
6265 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
6266 Strings like this can be either a message ID or a mail address. If it is one
6267 of the symbols `mid' or `mail', Gnus will always assume that the string is a
6268 message ID or a mail address, respectively. If this variable is set to the
6269 symbol `ask', always query the user what do do. If it is a function, this
6270 function will be called with the string as it's only argument. The function
6271 must return `mid', `mail', `invalid' or `ask'."
6273 :group 'gnus-article-buttons
6274 :type '(choice (function-item :tag "Heuristic function"
6275 gnus-button-mid-or-mail-heuristic)
6280 (defcustom gnus-button-mid-or-mail-heuristic-alist
6281 '((-10.0 . ".+\\$.+@")
6284 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
6285 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
6286 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
6287 (-1.0 . "^[^a-z]+@")
6289 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
6290 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
6291 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
6292 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
6295 (-1.0 . "^[0-9][0-9]")
6297 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
6298 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6299 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
6300 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6302 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
6303 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
6306 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
6308 ;; compensation for TDMA dated mail addresses:
6309 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
6311 (-20.0 . "\\.fsf@") ;; Gnus
6314 (-20.0 . "_-_") ;; Subject change in thread
6316 (-20.0 . "\\.ln@") ;; leafnode
6317 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
6318 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
6320 ;; (5.0 . "") ;; $local_part_len <= 7
6321 (10.0 . "^[^0-9]+@")
6322 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
6323 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
6326 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
6328 (0.5 . "^[A-Z][a-z]")
6329 (0.5 . "^[A-Z][a-z][a-z]")
6330 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
6331 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
6332 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
6334 A negative RATE indicates a message IDs, whereas a positive indicates a mail
6335 address. The REGEXP is processed with `case-fold-search' set to nil."
6337 :group 'gnus-article-buttons
6338 :type '(repeat (cons (number :tag "Rate")
6339 (regexp :tag "Regexp"))))
6341 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
6342 "Guess whether MID-OR-MAIL is a message ID or a mail address.
6343 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
6344 address, `ask' if unsure and `invalid' if the string is invalid."
6345 (let ((case-fold-search nil)
6346 (list gnus-button-mid-or-mail-heuristic-alist)
6347 (result 0) rate regexp lpartlen elem)
6349 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
6350 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
6351 ;; Certain special cases...
6354 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
6355 "^[0-9]+\\.[0-9]+@compuserve\\|"
6356 "@public\\.gmane\\.org")
6358 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
6359 (setq result 'mail))
6360 (when (string-match "@.*@\\| " mid-or-mail)
6361 (gnus-message 8 "`%s' is invalid." mid-or-mail)
6362 (setq result 'invalid))
6363 ;; Nothing more to do, if result is not a number here...
6364 (when (numberp result)
6366 (setq elem (car list)
6370 (when (string-match regexp mid-or-mail)
6371 (setq result (+ result rate))
6373 9 "`%s' matched `%s', rate `%s', result `%s'."
6374 mid-or-mail regexp rate result)))
6375 (when (<= lpartlen 7)
6376 (setq result (+ result 5.0))
6377 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
6378 mid-or-mail result))
6379 (when (>= lpartlen 12)
6380 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
6382 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
6383 ;; Long local part should contain realname if e-mail address,
6384 ;; too many digits: message-id.
6385 ;; $score -= 5.0 + 0.1 * $local_part_len;
6386 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6387 (setq result (+ result rate))
6389 9 "Many digits in `%s', rate `%s', result `%s'."
6390 mid-or-mail rate result))
6391 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6393 ;; Too few vowels [^aeiouy]{4,}.*\@
6394 (setq result (+ result -5.0))
6396 9 "Few vowels in `%s', rate `%s', result `%s'."
6397 mid-or-mail -5.0 result))
6399 (setq result (+ result 5.0))
6401 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6402 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6403 ;; Maybe we should make this a customizable alist: (condition . 'result)
6405 ((symbolp result) result)
6406 ;; Now convert number into proper results:
6407 ((< result -10.0) 'mid)
6408 ((> result 10.0) 'mail)
6411 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6412 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6413 (url-mid (concat "news" ":" mid-or-mail))
6414 (url-mailto (concat "mailto" ":" mid-or-mail)))
6415 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6416 (when (fboundp pref)
6418 ;; get rid of surrounding angles...
6420 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6421 (if (or (eq 'mid guessed) (eq 'mail guessed))
6425 (save-window-excursion
6426 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6429 (cond ((eq pref 'mid)
6430 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6431 (gnus-button-handle-news url-mid))
6433 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6434 (gnus-url-mailto url-mailto))
6435 (t (gnus-message 3 "Invalid string.")))))
6437 (defun gnus-button-handle-custom (url)
6438 "Follow a Custom URL."
6439 (customize-apropos (gnus-url-unhex-string url)))
6441 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6443 ;; FIXME: Maybe we should merge some of the functions that do quite similar
6446 (defun gnus-button-handle-describe-function (url)
6447 "Call `describe-function' when pushing the corresponding URL button."
6450 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6452 (defun gnus-button-handle-describe-variable (url)
6453 "Call `describe-variable' when pushing the corresponding URL button."
6456 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6458 (defun gnus-button-handle-symbol (url)
6459 "Display help on variable or function.
6460 Calls `describe-variable' or `describe-function'."
6461 (let ((sym (intern url)))
6463 ((fboundp sym) (describe-function sym))
6464 ((boundp sym) (describe-variable sym))
6465 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
6467 (defun gnus-button-handle-describe-key (url)
6468 "Call `describe-key' when pushing the corresponding URL button."
6470 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6471 (keys (ignore-errors (eval `(kbd ,key-string)))))
6474 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6476 (defun gnus-button-handle-apropos (url)
6477 "Call `apropos' when pushing the corresponding URL button."
6478 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6480 (defun gnus-button-handle-apropos-command (url)
6481 "Call `apropos' when pushing the corresponding URL button."
6483 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6485 (defun gnus-button-handle-apropos-variable (url)
6486 "Call `apropos' when pushing the corresponding URL button."
6488 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6489 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6491 (defun gnus-button-handle-apropos-documentation (url)
6492 "Call `apropos' when pushing the corresponding URL button."
6494 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6495 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6497 (defun gnus-button-handle-library (url)
6498 "Call `locate-library' when pushing the corresponding URL button."
6499 (gnus-message 9 "url=`%s'" url)
6500 (let* ((lib (locate-library url))
6501 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6503 (gnus-message 1 "Cannot locale library `%s'." url)
6504 (find-file-read-only file))))
6506 (defun gnus-button-handle-ctan (url)
6507 "Call `browse-url' when pushing a CTAN URL button."
6509 gnus-button-ctan-handler
6512 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6514 (defcustom gnus-button-tex-level 5
6515 "*Integer that says how many TeX-related buttons Gnus will show.
6516 The higher the number, the more buttons will appear and the more false
6517 positives are possible. Note that you can set this variable local to
6518 specific groups. Setting it higher in TeX groups is probably a good idea.
6519 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6520 how to set variables in specific groups."
6522 :group 'gnus-article-buttons
6523 :link '(custom-manual "(gnus)Group Parameters")
6526 (defcustom gnus-button-man-level 5
6527 "*Integer that says how many man-related buttons Gnus will show.
6528 The higher the number, the more buttons will appear and the more false
6529 positives are possible. Note that you can set this variable local to
6530 specific groups. Setting it higher in Unix groups is probably a good idea.
6531 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6532 how to set variables in specific groups."
6534 :group 'gnus-article-buttons
6535 :link '(custom-manual "(gnus)Group Parameters")
6538 (defcustom gnus-button-emacs-level 5
6539 "*Integer that says how many emacs-related buttons Gnus will show.
6540 The higher the number, the more buttons will appear and the more false
6541 positives are possible. Note that you can set this variable local to
6542 specific groups. Setting it higher in Emacs or Gnus related groups is
6543 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6544 `gnus-parameters' on how to set variables in specific groups."
6546 :group 'gnus-article-buttons
6547 :link '(custom-manual "(gnus)Group Parameters")
6550 (defcustom gnus-button-message-level 5
6551 "*Integer that says how many buttons for news or mail messages will appear.
6552 The higher the number, the more buttons will appear and the more false
6553 positives are possible."
6554 ;; mail addresses, MIDs, URLs for news, ...
6556 :group 'gnus-article-buttons
6559 (defcustom gnus-button-browse-level 5
6560 "*Integer that says how many buttons for browsing will appear.
6561 The higher the number, the more buttons will appear and the more false
6562 positives are possible."
6563 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6565 :group 'gnus-article-buttons
6568 (defcustom gnus-button-alist
6569 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6570 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6571 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
6572 gnus-button-handle-news 2)
6573 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6574 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6575 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6576 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6577 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
6578 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
6579 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
6580 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6581 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6582 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6583 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6584 ;; RFC 2368 (The mailto URL scheme)
6585 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6586 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6587 ("\\bmailto:\\([^ \n\t]+\\)"
6588 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6590 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6591 gnus-button-ctan-directory-regexp
6592 "[^][>)!;:,'\n\t ]+\\)")
6593 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6594 ((concat "\\btex-archive/\\("
6595 gnus-button-ctan-directory-regexp
6596 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6597 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6600 gnus-button-ctan-directory-regexp
6601 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6602 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6603 ;; This is info (home-grown style) <info://foo/bar+baz>
6604 ("\\binfo://\\([^'\">\n\t ]+\\)"
6605 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6606 ;; Info GNOME style <info:foo#bar_baz>
6607 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6608 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6609 ;; Info KDE style <info:(foo)bar baz>
6610 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6611 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6612 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6613 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6614 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6615 ;; Info links like `C-h i d m CC Mode RET'
6616 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6618 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6619 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6620 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6621 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6622 ;; Emacs help commands
6623 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6624 ;; regexp doesn't match arguments containing ` '.
6625 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6626 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6627 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6628 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6629 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6630 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6631 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6632 ;; The following entries may lead to many false positives so don't enable
6633 ;; them by default (use a high button level).
6634 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
6635 ;; Exclude [.?] for URLs in gmane.emacs.cvs
6636 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6637 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6638 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6639 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6640 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6641 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6642 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6643 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6644 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6645 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6646 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
6647 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6648 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6649 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6650 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6651 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6652 ;; Unlike the other regexps we really have to require quoting
6653 ;; here to determine where it ends.
6654 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6655 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
6656 ("<URL: *\\([^<>]*\\)>"
6657 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6658 ;; RFC 2396 (2.4.3., delims) ...
6659 ("\"URL: *\\([^\"]*\\)\""
6660 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6661 ;; RFC 2396 (2.4.3., delims) ...
6662 ("\"URL: *\\([^\"]*\\)\""
6663 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6665 (gnus-button-url-regexp
6666 0 (>= gnus-button-browse-level 0) browse-url 0)
6668 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
6669 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6670 gnus-button-handle-man 1)
6671 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6672 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
6673 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6674 gnus-button-handle-man 1)
6675 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6676 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6677 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
6678 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6679 ;; MID or mail: To avoid too many false positives we don't try to catch
6680 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6681 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6682 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6683 ;; so that non-ambiguous entries (see above) match first.
6684 (gnus-button-mid-or-mail-regexp
6685 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6686 "*Alist of regexps matching buttons in article bodies.
6688 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6689 REGEXP: is the string (case insensitive) matching text around the button (can
6690 also be Lisp expression evaluating to a string),
6691 BUTTON: is the number of the regexp grouping actually matching the button,
6692 FORM: is a Lisp expression which must eval to true for the button to
6694 CALLBACK: is the function to call when the user push this button, and each
6695 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6697 CALLBACK can also be a variable, in that case the value of that
6698 variable it the real callback function."
6699 :group 'gnus-article-buttons
6700 :type '(repeat (list (choice regexp variable sexp)
6701 (integer :tag "Button")
6703 (function :tag "Callback")
6706 (integer :tag "Regexp group")))))
6708 (defcustom gnus-header-button-alist
6709 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
6710 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6711 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6712 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6713 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6714 0 (>= gnus-button-message-level 0) gnus-button-mailto 0)
6715 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6716 0 (>= gnus-button-browse-level 0) browse-url 0)
6717 ("^Subject:" gnus-button-url-regexp
6718 0 (>= gnus-button-browse-level 0) browse-url 0)
6719 ("^[^:]+:" gnus-button-url-regexp
6720 0 (>= gnus-button-browse-level 0) browse-url 0)
6721 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6722 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6723 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6724 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6725 "*Alist of headers and regexps to match buttons in article heads.
6727 This alist is very similar to `gnus-button-alist', except that each
6728 alist has an additional HEADER element first in each entry:
6730 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6732 HEADER is a regexp to match a header. For a fuller explanation, see
6733 `gnus-button-alist'."
6734 :group 'gnus-article-buttons
6735 :group 'gnus-article-headers
6736 :type '(repeat (list (regexp :tag "Header")
6737 (choice regexp variable)
6738 (integer :tag "Button")
6740 (function :tag "Callback")
6743 (integer :tag "Regexp group")))))
6747 (defun gnus-article-push-button (event)
6748 "Check text under the mouse pointer for a callback function.
6749 If the text under the mouse pointer has a `gnus-callback' property,
6750 call it with the value of the `gnus-data' text property."
6752 (set-buffer (window-buffer (posn-window (event-start event))))
6753 (let* ((pos (posn-point (event-start event)))
6754 (data (get-text-property pos 'gnus-data))
6755 (fun (get-text-property pos 'gnus-callback)))
6758 (funcall fun data))))
6760 (defun gnus-article-press-button ()
6761 "Check text at point for a callback function.
6762 If the text at point has a `gnus-callback' property,
6763 call it with the value of the `gnus-data' text property."
6765 (let ((data (get-text-property (point) 'gnus-data))
6766 (fun (get-text-property (point) 'gnus-callback)))
6768 (funcall fun data))))
6770 (defun gnus-article-prev-button (n)
6771 "Move point to N buttons backward.
6772 If N is negative, move forward instead."
6774 (gnus-article-next-button (- n)))
6776 (defun gnus-article-next-button (n)
6777 "Move point to N buttons forward.
6778 If N is negative, move backward instead."
6780 (let ((function (if (< n 0) 'previous-single-property-change
6781 'next-single-property-change))
6782 (inhibit-point-motion-hooks t)
6784 (limit (if (< n 0) (point-min) (point-max))))
6786 (while (and (not (= limit (point)))
6788 ;; Skip past the current button.
6789 (when (get-text-property (point) 'gnus-callback)
6790 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6791 ;; Go to the next (or previous) button.
6792 (gnus-goto-char (funcall function (point) 'gnus-callback nil limit))
6793 ;; Put point at the start of the button.
6794 (when (and backward (not (get-text-property (point) 'gnus-callback)))
6795 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6796 ;; Skip past intangible buttons.
6797 (when (get-text-property (point) 'intangible)
6801 (gnus-message 5 "No more buttons"))
6804 (defun gnus-article-highlight (&optional force)
6805 "Highlight current article.
6806 This function calls `gnus-article-highlight-headers',
6807 `gnus-article-highlight-citation',
6808 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6809 do the highlighting. See the documentation for those functions."
6810 (interactive (list 'force))
6811 (gnus-article-highlight-headers)
6812 (gnus-article-highlight-citation force)
6813 (gnus-article-highlight-signature)
6814 (gnus-article-add-buttons force)
6815 (gnus-article-add-buttons-to-head))
6817 (defun gnus-article-highlight-some (&optional force)
6818 "Highlight current article.
6819 This function calls `gnus-article-highlight-headers',
6820 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6821 do the highlighting. See the documentation for those functions."
6822 (interactive (list 'force))
6823 (gnus-article-highlight-headers)
6824 (gnus-article-highlight-signature)
6825 (gnus-article-add-buttons))
6827 (defun gnus-article-highlight-headers ()
6828 "Highlight article headers as specified by `gnus-header-face-alist'."
6830 (gnus-with-article-headers
6831 (let (regexp header-face field-face from hpoints fpoints)
6832 (dolist (entry gnus-header-face-alist)
6833 (goto-char (point-min))
6834 (setq regexp (concat "^\\("
6835 (if (string-equal "" (nth 0 entry))
6839 header-face (nth 1 entry)
6840 field-face (nth 2 entry))
6841 (while (and (re-search-forward regexp nil t)
6845 (unless (search-forward ":" nil t)
6847 (when (and header-face
6848 (not (memq (point) hpoints)))
6849 (push (point) hpoints)
6850 (gnus-put-text-property from (point) 'face header-face))
6851 (when (and field-face
6852 (not (memq (setq from (point)) fpoints)))
6854 (if (re-search-forward "^[^ \t]" nil t)
6856 (goto-char (point-max)))
6857 (gnus-put-text-property from (point) 'face field-face)))))))
6859 (defun gnus-article-highlight-signature ()
6860 "Highlight the signature in an article.
6861 It does this by highlighting everything after
6862 `gnus-signature-separator' using `gnus-signature-face'."
6864 (when gnus-signature-face
6865 (gnus-with-article-buffer
6866 (let ((inhibit-point-motion-hooks t))
6868 (when (gnus-article-narrow-to-signature)
6869 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6870 'face gnus-signature-face)))))))
6872 (defun gnus-article-buttonize-signature ()
6873 "Add button to the signature."
6876 (set-buffer gnus-article-buffer)
6877 (let ((inhibit-read-only t)
6878 (inhibit-point-motion-hooks t))
6879 (when (gnus-article-search-signature)
6880 (gnus-article-add-button (match-beginning 0) (match-end 0)
6881 'gnus-signature-toggle
6882 (set-marker (make-marker)
6883 (1+ (match-end 0))))))))
6885 (defun gnus-button-in-region-p (b e prop)
6886 "Say whether PROP exists in the region."
6887 (text-property-not-all b e prop nil))
6889 (defun gnus-article-add-buttons (&optional force)
6890 "Find external references in the article and make buttons of them.
6891 \"External references\" are things like Message-IDs and URLs, as
6892 specified by `gnus-button-alist'."
6893 (interactive (list 'force))
6894 (gnus-with-article-buffer
6895 (let ((inhibit-point-motion-hooks t)
6896 (case-fold-search t)
6897 (alist gnus-button-alist)
6899 ;; Remove all old markers.
6900 (let (marker entry new-list)
6901 (while (setq marker (pop gnus-button-marker-list))
6902 (if (or (< marker (point-min)) (>= marker (point-max)))
6903 (push marker new-list)
6905 (when (setq entry (gnus-button-entry))
6906 (put-text-property (match-beginning (nth 1 entry))
6907 (match-end (nth 1 entry))
6908 'gnus-callback nil))
6909 (set-marker marker nil)))
6910 (setq gnus-button-marker-list new-list))
6911 ;; We skip the headers.
6914 (while (setq entry (pop alist))
6915 (setq regexp (eval (car entry)))
6917 (while (re-search-forward regexp nil t)
6918 (let* ((start (and entry (match-beginning (nth 1 entry))))
6919 (end (and entry (match-end (nth 1 entry))))
6920 (from (match-beginning 0)))
6921 (when (and (or (eq t (nth 2 entry))
6922 (eval (nth 2 entry)))
6923 (not (gnus-button-in-region-p
6924 start end 'gnus-callback)))
6925 ;; That optional form returned non-nil, so we add the
6927 (gnus-article-add-button
6928 start end 'gnus-button-push
6929 (car (push (set-marker (make-marker) from)
6930 gnus-button-marker-list))))))))))
6932 ;; Add buttons to the head of an article.
6933 (defun gnus-article-add-buttons-to-head ()
6934 "Add buttons to the head of the article."
6936 (gnus-with-article-headers
6938 (dolist (entry gnus-header-button-alist)
6939 ;; Each alist entry.
6940 (goto-char (point-min))
6941 (while (re-search-forward (car entry) nil t)
6942 ;; Each header matching the entry.
6943 (setq beg (match-beginning 0))
6944 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6945 (match-beginning 0))
6948 (while (re-search-forward (eval (nth 1 entry)) end t)
6949 ;; Each match within a header.
6950 (let* ((entry (cdr entry))
6951 (start (match-beginning (nth 1 entry)))
6952 (end (match-end (nth 1 entry)))
6953 (form (nth 2 entry)))
6954 (goto-char (match-end 0))
6956 (gnus-article-add-button
6957 start end (nth 3 entry)
6958 (buffer-substring (match-beginning (nth 4 entry))
6959 (match-end (nth 4 entry)))))))
6960 (goto-char end))))))
6962 ;;; External functions:
6964 (defun gnus-article-add-button (from to fun &optional data)
6965 "Create a button between FROM and TO with callback FUN and data DATA."
6966 (when gnus-article-button-face
6967 (gnus-overlay-put (gnus-make-overlay from to)
6968 'face gnus-article-button-face))
6969 (gnus-add-text-properties
6971 (nconc (and gnus-article-mouse-face
6972 (list gnus-mouse-face-prop gnus-article-mouse-face))
6973 (list 'gnus-callback fun)
6974 (and data (list 'gnus-data data))))
6975 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6976 :button-keymap gnus-widget-button-keymap))
6978 ;;; Internal functions:
6980 (defun gnus-article-set-globals ()
6981 (with-current-buffer gnus-summary-buffer
6982 (gnus-set-global-variables)))
6984 (defun gnus-signature-toggle (end)
6985 (gnus-with-article-buffer
6986 (let ((inhibit-point-motion-hooks t)
6987 (limit (next-single-property-change end 'mime-view-entity
6989 (if (text-property-any end limit 'article-type 'signature)
6991 (gnus-delete-wash-type 'signature)
6992 (gnus-remove-text-properties-when
6993 'article-type 'signature end limit
6994 (cons 'article-type (cons 'signature
6995 gnus-hidden-properties))))
6996 (gnus-add-wash-type 'signature)
6997 (gnus-add-text-properties-when
6998 'article-type nil end limit
6999 (cons 'article-type (cons 'signature
7000 gnus-hidden-properties)))))
7001 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
7002 (gnus-set-mode-line 'article))))
7004 (defun gnus-button-entry ()
7005 ;; Return the first entry in `gnus-button-alist' matching this place.
7006 (let ((alist gnus-button-alist)
7009 (setq entry (pop alist))
7010 (if (looking-at (eval (car entry)))
7015 (defun gnus-button-push (marker)
7016 ;; Push button starting at MARKER.
7019 (let* ((entry (gnus-button-entry))
7020 (inhibit-point-motion-hooks t)
7022 (args (mapcar (lambda (group)
7023 (let ((string (match-string group)))
7024 (set-text-properties
7025 0 (length string) nil string)
7032 (fboundp (symbol-value fun)))
7033 (apply (symbol-value fun) args))
7035 (gnus-message 1 "You must define `%S' to use this button"
7036 (cons fun args)))))))
7038 (defun gnus-parse-news-url (url)
7039 (let (scheme server group message-id articles)
7042 (goto-char (point-min))
7043 (when (looking-at "\\([A-Za-z]+\\):")
7044 (setq scheme (match-string 1))
7045 (goto-char (match-end 0)))
7046 (when (looking-at "//\\([^/]+\\)/")
7047 (setq server (match-string 1))
7048 (goto-char (match-end 0)))
7051 ((looking-at "\\(.*@.*\\)")
7052 (setq message-id (match-string 1)))
7053 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
7054 (setq group (match-string 1)
7055 articles (split-string (match-string 2) "-")))
7056 ((looking-at "\\([^/]+\\)/?")
7057 (setq group (match-string 1)))
7059 (error "Unknown news URL syntax"))))
7060 (list scheme server group message-id articles)))
7062 (defun gnus-button-handle-news (url)
7064 (destructuring-bind (scheme server group message-id articles)
7065 (gnus-parse-news-url url)
7069 (set-buffer gnus-summary-buffer)
7071 (let ((gnus-refer-article-method (list (list 'nntp server))))
7072 (gnus-summary-refer-article message-id))
7073 (gnus-summary-refer-article message-id))))
7075 (gnus-button-fetch-group url)))))
7077 (defun gnus-button-handle-man (url)
7079 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7080 (when (eq gnus-button-man-handler 'woman)
7081 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
7082 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7083 (funcall gnus-button-man-handler url))
7085 (defun gnus-button-handle-info-url (url)
7086 "Fetch an info URL."
7087 (setq url (mm-subst-char-in-string ?+ ?\ url))
7089 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
7090 (gnus-info-find-node
7091 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
7093 ")" (gnus-url-unhex-string (match-string 2 url)))))
7094 ((string-match "([^)\"]+)[^\"]+" url)
7096 (gnus-replace-in-string
7097 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
7098 (gnus-info-find-node url))
7099 (t (error "Can't parse %s" url))))
7101 (defun gnus-button-handle-info-url-gnome (url)
7102 "Fetch GNOME style info URL."
7103 (setq url (mm-subst-char-in-string ?_ ?\ url))
7104 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
7105 (gnus-info-find-node
7107 (gnus-url-unhex-string
7108 (match-string 1 url))
7110 (or (gnus-url-unhex-string
7111 (match-string 2 url))
7113 (error "Can't parse %s" url)))
7115 (defun gnus-button-handle-info-url-kde (url)
7116 "Fetch KDE style info URL."
7117 (gnus-info-find-node (gnus-url-unhex-string url)))
7119 (defun gnus-button-handle-info-keystrokes (url)
7120 "Call `info' when pushing the corresponding URL button."
7121 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
7126 (defun gnus-button-message-id (message-id)
7128 (with-current-buffer gnus-summary-buffer
7129 (gnus-summary-refer-article message-id)))
7131 (defun gnus-button-fetch-group (address)
7132 "Fetch GROUP specified by ADDRESS."
7133 (if (not (string-match "[:/]" address))
7134 ;; This is just a simple group url.
7135 (gnus-group-read-ephemeral-group address gnus-select-method)
7138 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
7140 (error "Can't parse %s" address)
7141 (gnus-group-read-ephemeral-group
7142 (match-string 4 address)
7143 `(nntp ,(match-string 1 address)
7144 (nntp-address ,(match-string 1 address))
7145 (nntp-port-number ,(if (match-end 3)
7146 (match-string 3 address)
7149 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
7151 (defun gnus-url-parse-query-string (query &optional downcase)
7152 (let (retval pairs cur key val)
7153 (setq pairs (split-string query "&"))
7155 (setq cur (car pairs)
7157 (if (not (string-match "=" cur))
7159 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
7160 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
7162 (setq key (downcase key)))
7163 (setq cur (assoc key retval))
7165 (setcdr cur (cons val (cdr cur)))
7166 (setq retval (cons (list key val) retval)))))
7169 (defun gnus-url-mailto (url)
7170 ;; Send mail to someone
7171 (when (string-match "mailto:/*\\(.*\\)" url)
7172 (setq url (substring url (match-beginning 1) nil)))
7173 (let (to args subject func)
7174 (setq args (gnus-url-parse-query-string
7175 (if (string-match "^\\?" url)
7177 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
7178 (concat "to=" (match-string 1 url) "&"
7179 (match-string 2 url))
7180 (concat "to=" url)))
7182 subject (cdr-safe (assoc "subject" args)))
7185 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
7188 (message-position-on-field (caar args)))
7189 (insert (gnus-replace-in-string
7190 (mapconcat 'identity (reverse (cdar args)) ", ")
7192 (setq args (cdr args)))
7195 (message-goto-subject))))
7197 (defun gnus-button-embedded-url (address)
7198 "Activate ADDRESS with `browse-url'."
7199 (browse-url (gnus-strip-whitespace address)))
7201 ;;; Next/prev buttons in the article buffer.
7203 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
7204 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
7206 (defvar gnus-prev-page-map
7207 (let ((map (make-sparse-keymap)))
7208 (define-key map gnus-mouse-2 'gnus-button-prev-page)
7209 (define-key map "\r" 'gnus-button-prev-page)
7212 (defvar gnus-next-page-map
7213 (let ((map (make-sparse-keymap)))
7214 (unless (>= emacs-major-version 21)
7215 ;; XEmacs doesn't care.
7216 (set-keymap-parent map gnus-article-mode-map))
7217 (define-key map gnus-mouse-2 'gnus-button-next-page)
7218 (define-key map "\r" 'gnus-button-next-page)
7221 (defun gnus-insert-prev-page-button ()
7223 (inhibit-read-only t)
7224 (situation (get-text-property (point-min) 'mime-view-situation)))
7226 gnus-prev-page-line-format nil
7227 `(keymap ,gnus-prev-page-map
7229 gnus-callback gnus-article-button-prev-page
7230 article-type annotation
7231 mime-view-situation ,situation))
7232 (widget-convert-button
7234 ;; Exclude a newline.
7237 :action 'gnus-button-prev-page
7238 :button-keymap gnus-prev-page-map)))
7240 (defun gnus-button-next-page (&optional args more-args)
7241 "Go to the next page."
7243 (let ((win (selected-window)))
7244 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7245 (gnus-article-next-page)
7246 (select-window win)))
7248 (defun gnus-button-prev-page (&optional args more-args)
7249 "Go to the prev page."
7251 (let ((win (selected-window)))
7252 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7253 (gnus-article-prev-page)
7254 (select-window win)))
7256 (defun gnus-insert-next-page-button ()
7258 (inhibit-read-only t)
7259 (situation (get-text-property (point-min) 'mime-view-situation)))
7260 (gnus-eval-format gnus-next-page-line-format nil
7261 `(keymap ,gnus-next-page-map
7263 gnus-callback gnus-article-button-next-page
7264 article-type annotation
7265 mime-view-situation ,situation))
7266 (widget-convert-button
7268 ;; Exclude a newline.
7271 :action 'gnus-button-next-page
7272 :button-keymap gnus-next-page-map)))
7274 (defun gnus-article-button-next-page (arg)
7275 "Go to the next page."
7277 (let ((win (selected-window)))
7278 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7279 (gnus-article-next-page)
7280 (select-window win)))
7282 (defun gnus-article-button-prev-page (arg)
7283 "Go to the prev page."
7285 (let ((win (selected-window)))
7286 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7287 (gnus-article-prev-page)
7288 (select-window win)))
7290 (defvar gnus-decode-header-methods
7291 '(mail-decode-encoded-word-region)
7292 "List of methods used to decode headers.
7294 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
7295 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
7296 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
7297 whose names match REGEXP.
7300 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
7301 mail-decode-encoded-word-region
7302 (\"chinese\" . rfc1843-decode-region))
7305 (defvar gnus-decode-header-methods-cache nil)
7307 (defun gnus-multi-decode-header (start end)
7308 "Apply the functions from `gnus-encoded-word-methods' that match."
7309 (unless (and gnus-decode-header-methods-cache
7310 (eq gnus-newsgroup-name
7311 (car gnus-decode-header-methods-cache)))
7312 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
7315 (nconc gnus-decode-header-methods-cache (list x))
7316 (if (and gnus-newsgroup-name
7317 (string-match (car x) gnus-newsgroup-name))
7318 (nconc gnus-decode-header-methods-cache
7320 gnus-decode-header-methods))
7321 (let ((xlist gnus-decode-header-methods-cache))
7324 (narrow-to-region start end)
7326 (funcall (pop xlist) (point-min) (point-max))))))
7329 ;;; Treatment top-level handling.
7332 (defun gnus-treat-article (condition &optional part-number total-parts type)
7333 (let ((length (- (point-max) (point-min)))
7334 (alist gnus-treatment-function-alist)
7335 (article-goto-body-goes-to-point-min-p t)
7339 (let ((list gnus-article-treat-types))
7341 (when (string-match (pop list) type)
7342 (throw 'found t)))))))
7343 (highlightp (gnus-visual-p 'article-highlight 'highlight))
7344 (entity (static-unless (featurep 'xemacs)
7345 (when (eq 'head condition)
7346 (get-text-property (point-min) 'mime-view-entity))))
7347 val elem buttonized)
7348 (gnus-run-hooks 'gnus-part-display-hook)
7349 (unless gnus-inhibit-treatment
7350 (dolist (elem alist)
7353 (when (gnus-buffer-live-p gnus-summary-buffer)
7354 (set-buffer gnus-summary-buffer))
7355 (symbol-value (car elem))))
7356 (when (and (or (consp val)
7358 (gnus-treat-predicate val)
7359 (or (not (get (car elem) 'highlight))
7361 (when (and (not buttonized)
7363 '(gnus-treat-hide-signature
7364 gnus-treat-highlight-signature)))
7365 (gnus-article-buttonize-signature)
7366 (setq buttonized t))
7368 (funcall (cadr elem)))))
7369 ;; FSF Emacsen does not inherit the existing text properties
7370 ;; in the new text, so we should do it for `mime-view-entity'.
7371 (static-unless (featurep 'xemacs)
7373 (put-text-property (point-min) (point-max)
7374 'mime-view-entity entity))))))
7376 ;; Dynamic variables.
7378 (defvar part-number)
7379 (defvar total-parts)
7384 (defun gnus-treat-predicate (val)
7389 (stringp (car val)))
7390 (apply 'gnus-or (mapcar `(lambda (s)
7391 (string-match s ,(or gnus-newsgroup-name "")))
7394 (let ((pred (pop val)))
7397 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
7399 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
7401 (not (gnus-treat-predicate (car val))))
7403 (equal (car val) type))
7405 (error "%S is not a valid predicate" pred)))))
7415 (eq part-number total-parts))
7419 (error "%S is not a valid value" val))))
7421 (defun gnus-article-encrypt-body (protocol &optional n)
7422 "Encrypt the article body."
7425 (or gnus-article-encrypt-protocol
7426 (completing-read "Encrypt protocol: "
7427 gnus-article-encrypt-protocol-alist
7429 current-prefix-arg))
7430 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7432 (error (format "Can't find the encrypt protocol %s" protocol)))
7433 (if (member gnus-newsgroup-name '("nndraft:delayed"
7436 (error "Can't encrypt the article in group %s"
7437 gnus-newsgroup-name))
7438 (gnus-summary-iterate n
7440 (set-buffer gnus-summary-buffer)
7441 (let ((mail-parse-charset gnus-newsgroup-charset)
7442 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7443 (summary-buffer gnus-summary-buffer)
7445 (gnus-set-global-variables)
7446 (when (gnus-group-read-only-p)
7447 (error "The current newsgroup does not support article encrypt"))
7448 (gnus-summary-show-article t)
7450 (or (mail-header-references gnus-current-headers) ""))
7451 (set-buffer gnus-article-buffer)
7452 (let* ((inhibit-read-only t)
7454 (mapcar (lambda (field)
7455 (and (save-restriction
7456 (message-narrow-to-head)
7457 (goto-char (point-min))
7458 (search-forward field nil t))
7460 (message-narrow-to-field)
7462 (delete-region (point-min) (point-max))
7464 '("Content-Type:" "Content-Transfer-Encoding:"
7465 "Content-Disposition:"))))
7466 (message-narrow-to-head)
7467 (message-remove-header "MIME-Version")
7468 (goto-char (point-max))
7469 (setq point (point))
7470 (insert (apply 'concat headers))
7472 (narrow-to-region point (point-max))
7473 (let ((message-options message-options))
7474 (message-options-set 'message-sender user-mail-address)
7475 (message-options-set 'message-recipients user-mail-address)
7476 (message-options-set 'message-sign-encrypt 'not)
7478 (goto-char (point-min))
7479 (insert "MIME-Version: 1.0\n")
7481 (gnus-summary-edit-article-done
7482 references nil summary-buffer t))
7483 (when gnus-keep-backlog
7484 (gnus-backlog-remove-article
7485 (car gnus-article-current) (cdr gnus-article-current)))
7487 (when (get-buffer gnus-original-article-buffer)
7488 (set-buffer gnus-original-article-buffer)
7489 (setq gnus-original-article nil)))
7490 (when gnus-use-cache
7491 (gnus-cache-update-article
7492 (car gnus-article-current) (cdr gnus-article-current))))))))
7494 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7495 "The following specs can be used:
7496 %t The security MIME type
7499 %D Details if button is pressed")
7501 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
7502 "The following specs can be used:
7503 %t The security MIME type
7506 %D Details if button is pressed")
7508 (defvar gnus-mime-security-button-line-format-alist
7509 '((?t gnus-tmp-type ?s)
7510 (?i gnus-tmp-info ?s)
7511 (?d gnus-tmp-details ?s)
7512 (?D gnus-tmp-pressed-details ?s)))
7514 (defvar gnus-mime-security-button-map
7515 (let ((map (make-sparse-keymap)))
7516 (define-key map gnus-mouse-2 'gnus-article-push-button)
7517 (define-key map "\r" 'gnus-article-press-button)
7520 (defvar gnus-mime-security-details-buffer nil)
7522 (defvar gnus-mime-security-button-pressed nil)
7524 (defvar gnus-mime-security-show-details-inline t
7525 "If non-nil, show details in the article buffer.")
7527 (defun gnus-mime-security-verify-or-decrypt (handle)
7528 (mm-remove-parts (cdr handle))
7529 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7530 point (inhibit-read-only t))
7532 (goto-char (car region)))
7534 (narrow-to-region (point) (point))
7535 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7536 (let* ((mm-verify-option 'known)
7537 (mm-decrypt-option 'known)
7538 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7539 (unless (eq nparts (cdr handle))
7540 (mm-destroy-parts (cdr handle))
7541 (setcdr handle nparts))))
7542 (setq point (point))
7543 (gnus-mime-display-security handle)
7544 (goto-char (point-max)))
7546 (delete-region (point) (cdr region))
7547 (set-marker (car region) nil)
7548 (set-marker (cdr region) nil))
7551 (defun gnus-mime-security-show-details (handle)
7552 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7554 (gnus-message 5 "No details.")
7555 (if gnus-mime-security-show-details-inline
7556 (let ((gnus-mime-security-button-pressed
7557 (not (get-text-property (point) 'gnus-mime-details)))
7558 (gnus-mime-security-button-line-format
7559 (get-text-property (point) 'gnus-line-format))
7560 (inhibit-read-only t))
7562 (while (eq (get-text-property (point) 'gnus-line-format)
7563 gnus-mime-security-button-line-format)
7567 (narrow-to-region (point) (point))
7568 (gnus-insert-mime-security-button handle))
7569 (delete-region (point)
7570 (or (text-property-not-all
7573 gnus-mime-security-button-line-format)
7576 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7577 (with-current-buffer gnus-mime-security-details-buffer
7580 (setq gnus-mime-security-details-buffer
7581 (gnus-get-buffer-create "*MIME Security Details*")))
7582 (with-current-buffer gnus-mime-security-details-buffer
7584 (goto-char (point-min)))
7585 (pop-to-buffer gnus-mime-security-details-buffer)))))
7587 (defun gnus-mime-security-press-button (handle)
7589 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7590 (gnus-mime-security-show-details handle)
7591 (gnus-mime-security-verify-or-decrypt handle))))
7593 (defun gnus-insert-mime-security-button (handle &optional displayed)
7594 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7597 (or (nth 2 (assoc protocol mm-verify-function-alist))
7598 (nth 2 (assoc protocol mm-decrypt-function-alist))
7600 (if (equal (car handle) "multipart/signed")
7601 " Signed" " Encrypted")
7604 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7607 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7608 gnus-tmp-pressed-details
7610 (setq gnus-tmp-details
7611 (if gnus-tmp-details
7612 (concat "\n" gnus-tmp-details)
7614 (setq gnus-tmp-pressed-details
7615 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7620 gnus-mime-security-button-line-format
7621 gnus-mime-security-button-line-format-alist
7622 `(keymap ,gnus-mime-security-button-map
7623 gnus-callback gnus-mime-security-press-button
7624 gnus-line-format ,gnus-mime-security-button-line-format
7625 gnus-mime-details ,gnus-mime-security-button-pressed
7626 article-type annotation
7629 ;; Exclude a newline.
7632 (widget-convert-button
7635 :action 'gnus-widget-press-button
7636 :button-keymap gnus-mime-security-button-map
7638 (lambda (widget/window &optional overlay pos)
7639 ;; Needed to properly clear the message due to a bug in
7640 ;; wid-edit (XEmacs only).
7641 (when (boundp 'help-echo-owns-message)
7642 (setq help-echo-owns-message t))
7645 (aref gnus-mouse-2 0))))))
7647 (defun gnus-mime-display-security (handle)
7649 (narrow-to-region (point) (point))
7650 (unless (gnus-unbuttonized-mime-type-p (car handle))
7651 (gnus-insert-mime-security-button handle))
7652 (gnus-mime-display-mixed (cdr handle))
7655 (unless (gnus-unbuttonized-mime-type-p (car handle))
7656 (let ((gnus-mime-security-button-line-format
7657 gnus-mime-security-button-end-line-format))
7658 (gnus-insert-mime-security-button handle)))
7659 (mm-set-handle-multipart-parameter
7661 (cons (set-marker (make-marker) (point-min))
7662 (set-marker (make-marker) (point-max))))))
7668 (defun gnus-article-header-presentation-method (entity situation)
7669 (mime-insert-header entity)
7670 (article-decode-group-name))
7672 (set-alist 'mime-header-presentation-method-alist
7673 'gnus-original-article-mode
7674 #'gnus-article-header-presentation-method)
7676 (defun gnus-mime-preview-quitting-method ()
7677 (mime-preview-kill-buffer)
7678 (delete-other-windows)
7679 (gnus-article-show-summary)
7680 (gnus-summary-select-article gnus-show-all-headers t))
7682 (set-alist 'mime-preview-quitting-method-alist
7683 'gnus-original-article-mode #'gnus-mime-preview-quitting-method)
7685 (set-alist 'mime-preview-following-method-alist
7686 'gnus-original-article-mode #'gnus-following-method)
7688 (set-alist 'mime-preview-over-to-previous-method-alist
7689 'gnus-original-article-mode
7691 (if (> (point-min) 1)
7692 (gnus-article-prev-page)
7693 (gnus-article-read-summary-keys
7694 nil (gnus-character-to-event ?P)))))
7696 (set-alist 'mime-preview-over-to-next-method-alist
7697 'gnus-original-article-mode'
7699 (if (< (point-max) (buffer-size))
7700 (gnus-article-next-page)
7701 (gnus-article-read-summary-keys
7702 nil (gnus-character-to-event ?N)))))
7712 (run-hooks 'gnus-art-load-hook)
7714 ;;; gnus-art.el ends here