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 (or gnus-treat-newsgroups-picon
1371 gnus-treat-mail-picon
1372 gnus-treat-from-picon)
1374 "Draw a boundary at the end of the headers.
1375 Valid values are nil and `head'.
1376 See Info node `(gnus)Customizing Articles' for details."
1378 :group 'gnus-article-treat
1379 :link '(custom-manual "(gnus)Customizing Articles")
1380 :type gnus-article-treat-head-custom)
1382 (defcustom gnus-treat-capitalize-sentences nil
1383 "Capitalize sentence-starting words.
1384 Valid values are nil, t, `head', `last', an integer or a predicate.
1385 See Info node `(gnus)Customizing Articles' for details."
1387 :group 'gnus-article-treat
1388 :link '(custom-manual "(gnus)Customizing Articles")
1389 :type gnus-article-treat-custom)
1391 (defcustom gnus-treat-wash-html nil
1393 Valid values are nil, t, `head', `last', an integer or a predicate.
1394 See Info node `(gnus)Customizing Articles' for details."
1396 :group 'gnus-article-treat
1397 :link '(custom-manual "(gnus)Customizing Articles")
1398 :type gnus-article-treat-custom)
1400 (defcustom gnus-treat-fill-long-lines nil
1402 Valid values are nil, t, `head', `last', an integer or a predicate.
1403 See Info node `(gnus)Customizing Articles' for details."
1404 :group 'gnus-article-treat
1405 :link '(custom-manual "(gnus)Customizing Articles")
1406 :type gnus-article-treat-custom)
1408 (defcustom gnus-treat-play-sounds nil
1410 Valid values are nil, t, `head', `last', an integer or a predicate.
1411 See Info node `(gnus)Customizing Articles' for details."
1413 :group 'gnus-article-treat
1414 :link '(custom-manual "(gnus)Customizing Articles")
1415 :type gnus-article-treat-custom)
1417 (defcustom gnus-treat-decode-article-as-default-mime-charset nil
1418 "Decode an article as `default-mime-charset'. For instance, if you want to
1419 attempt to decode an article even if the value of `gnus-show-mime' is nil,
1420 you could set this variable to something like: nil for don't decode, t for
1421 decode the body, '(or header t) for the whole article, etc."
1422 :group 'gnus-article-treat
1423 :type '(radio (const :tag "Off" nil)
1424 (const :tag "Decode body" t)
1425 (const :tag "Decode all" (or head t))))
1427 (defcustom gnus-treat-translate nil
1428 "Translate articles from one language to another.
1429 Valid values are nil, t, `head', `last', an integer or a predicate.
1430 See Info node `(gnus)Customizing Articles' for details."
1432 :group 'gnus-article-treat
1433 :link '(custom-manual "(gnus)Customizing Articles")
1434 :type gnus-article-treat-custom)
1436 (defcustom gnus-treat-x-pgp-sig nil
1438 To automatically treat X-PGP-Sig, set it to head.
1439 Valid values are nil, t, `head', `last', an integer or a predicate.
1440 See Info node `(gnus)Customizing Articles' for details."
1441 :group 'gnus-article-treat
1442 :group 'mime-security
1443 :type gnus-article-treat-custom)
1445 (defcustom gnus-treat-monafy nil
1446 "Display body part with mona font.
1447 Valid values are nil, t, `head', `last', an integer or a predicate.
1448 See Info node `(gnus)Customizing Articles' for details."
1449 :group 'gnus-article-treat
1450 :group 'mime-security
1451 :link '(custom-manual "(gnus)Customizing Articles")
1452 :type gnus-article-treat-custom)
1454 (defvar gnus-article-encrypt-protocol-alist
1455 '(("PGP" . mml2015-self-encrypt)))
1457 ;; Set to nil if more than one protocol added to
1458 ;; gnus-article-encrypt-protocol-alist.
1459 (defcustom gnus-article-encrypt-protocol "PGP"
1460 "The protocol used for encrypt articles.
1461 It is a string, such as \"PGP\". If nil, ask user."
1464 :group 'mime-security)
1466 (defvar gnus-article-wash-function nil
1467 "Function used for converting HTML into text.")
1469 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1470 (mm-coding-system-p 'utf-8)
1471 (executable-find idna-program))
1472 "Whether IDNA decoding of headers is used when viewing messages.
1473 This requires GNU Libidn, and by default only enabled if it is found."
1475 :group 'gnus-article-headers
1478 (defcustom gnus-article-over-scroll nil
1479 "If non-nil, allow scrolling the article buffer even when there no more text."
1481 :group 'gnus-article
1484 ;;; Internal variables
1486 (defvar gnus-english-month-names
1487 '("January" "February" "March" "April" "May" "June" "July" "August"
1488 "September" "October" "November" "December"))
1490 (defvar gnus-button-regexp nil)
1491 (defvar gnus-button-marker-list nil)
1492 ;; Regexp matching any of the regexps from `gnus-button-alist'.
1494 (defvar gnus-button-last nil)
1495 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
1497 (defvar article-goto-body-goes-to-point-min-p nil)
1498 (defvar gnus-article-wash-types nil)
1499 (defvar gnus-article-emphasis-alist nil)
1500 (defvar gnus-article-image-alist nil)
1502 (defvar gnus-article-mime-handle-alist-1 nil)
1503 (defvar gnus-treatment-function-alist
1504 '((gnus-treat-decode-article-as-default-mime-charset
1505 gnus-article-decode-article-as-default-mime-charset)
1506 (gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1507 (gnus-treat-monafy gnus-article-monafy)
1508 (gnus-treat-strip-banner gnus-article-strip-banner)
1509 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1510 (gnus-treat-buttonize gnus-article-add-buttons)
1511 (gnus-treat-fill-article gnus-article-fill-cited-article)
1512 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1513 (gnus-treat-strip-cr gnus-article-remove-cr)
1514 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1515 (gnus-treat-date-ut gnus-article-date-ut)
1516 (gnus-treat-date-local gnus-article-date-local)
1517 (gnus-treat-date-english gnus-article-date-english)
1518 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1519 (gnus-treat-date-original gnus-article-date-original)
1520 (gnus-treat-date-user-defined gnus-article-date-user)
1521 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1522 (gnus-treat-display-face gnus-article-display-face)
1523 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1524 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1525 (gnus-treat-hide-signature gnus-article-hide-signature)
1526 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1527 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1528 (gnus-treat-strip-pem gnus-article-hide-pem)
1529 (gnus-treat-from-picon gnus-treat-from-picon)
1530 (gnus-treat-mail-picon gnus-treat-mail-picon)
1531 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1532 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1533 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1534 (gnus-treat-strip-trailing-blank-lines
1535 gnus-article-remove-trailing-blank-lines)
1536 (gnus-treat-strip-leading-blank-lines
1537 gnus-article-strip-leading-blank-lines)
1538 (gnus-treat-strip-multiple-blank-lines
1539 gnus-article-strip-multiple-blank-lines)
1540 (gnus-treat-overstrike gnus-article-treat-overstrike)
1541 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences)
1542 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1543 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1544 ;; Displaying X-Face should be done after unfolding headers
1545 ;; to protect bitmap lines.
1546 (gnus-treat-display-x-face gnus-article-display-x-face)
1547 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1548 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1549 (gnus-treat-display-smileys gnus-treat-smiley)
1550 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1551 (gnus-treat-wash-html gnus-article-wash-html)
1552 (gnus-treat-emphasize gnus-article-emphasize)
1553 (gnus-treat-hide-citation gnus-article-hide-citation)
1554 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1555 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1556 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1557 (gnus-treat-play-sounds gnus-earcon-display)))
1559 (defvar gnus-article-mime-handle-alist nil)
1560 (defvar article-lapsed-timer nil)
1561 (defvar gnus-article-current-summary nil)
1563 (defvar gnus-article-mode-syntax-table
1564 (let ((table (copy-syntax-table text-mode-syntax-table)))
1565 ;; This causes the citation match run O(2^n).
1566 ;; (modify-syntax-entry ?- "w" table)
1567 (modify-syntax-entry ?> ")<" table)
1568 (modify-syntax-entry ?< "(>" table)
1569 ;; make M-. in article buffers work for `foo' strings
1570 (modify-syntax-entry ?' " " table)
1571 (modify-syntax-entry ?` " " table)
1573 "Syntax table used in article mode buffers.
1574 Initialized from `text-mode-syntax-table.")
1576 (defvar gnus-save-article-buffer nil)
1578 (defvar gnus-article-mode-line-format-alist
1579 (nconc '((?w (gnus-article-wash-status) ?s)
1580 (?m (gnus-article-mime-part-status) ?s))
1581 gnus-summary-mode-line-format-alist))
1583 (defvar gnus-number-of-articles-to-be-saved nil)
1585 (defvar gnus-inhibit-hiding nil)
1587 (defvar gnus-article-edit-mode nil)
1589 ;;; Macros for dealing with the article buffer.
1591 (defmacro gnus-with-article-headers (&rest forms)
1593 (set-buffer gnus-article-buffer)
1595 (let ((inhibit-read-only t)
1596 (inhibit-point-motion-hooks t)
1597 (case-fold-search t))
1598 (article-narrow-to-head)
1601 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1602 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1604 (defmacro gnus-with-article-buffer (&rest forms)
1606 (set-buffer gnus-article-buffer)
1607 (let ((inhibit-read-only t))
1610 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1611 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1613 (defun gnus-article-goto-header (header)
1614 "Go to HEADER, which is a regular expression."
1615 (re-search-forward (concat "^\\(" header "\\):") nil t))
1617 (defsubst gnus-article-hide-text (b e props)
1618 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1619 (gnus-add-text-properties-when 'article-type nil b e props)
1620 (when (memq 'intangible props)
1622 (max (1- b) (point-min))
1623 b 'intangible (cddr (memq 'intangible props)))))
1625 (defsubst gnus-article-unhide-text (b e)
1626 "Remove hidden text properties from region between B and E."
1627 (remove-text-properties b e gnus-hidden-properties)
1628 (when (memq 'intangible gnus-hidden-properties)
1629 (put-text-property (max (1- b) (point-min))
1630 b 'intangible nil)))
1632 (defun gnus-article-hide-text-type (b e type)
1633 "Hide text of TYPE between B and E."
1634 (gnus-add-wash-type type)
1635 (gnus-article-hide-text
1636 b e (cons 'article-type (cons type gnus-hidden-properties))))
1638 (defun gnus-article-unhide-text-type (b e type)
1639 "Unhide text of TYPE between B and E."
1640 (gnus-delete-wash-type type)
1641 (remove-text-properties
1642 b e (cons 'article-type (cons type gnus-hidden-properties)))
1643 (when (memq 'intangible gnus-hidden-properties)
1644 (put-text-property (max (1- b) (point-min))
1645 b 'intangible nil)))
1647 (defun gnus-article-hide-text-of-type (type)
1648 "Hide text of TYPE in the current buffer."
1650 (let ((b (point-min))
1652 (while (setq b (text-property-any b e 'article-type type))
1653 (add-text-properties b (incf b) gnus-hidden-properties)))))
1655 (defun gnus-article-delete-text-of-type (type)
1656 "Delete text of TYPE in the current buffer."
1658 (let ((b (point-min)))
1659 (while (setq b (text-property-any b (point-max) 'article-type type))
1661 b (or (text-property-not-all b (point-max) 'article-type type)
1664 (defun gnus-article-delete-invisible-text ()
1665 "Delete all invisible text in the current buffer."
1667 (let ((b (point-min)))
1668 (while (setq b (text-property-any b (point-max) 'invisible t))
1670 b (or (text-property-not-all b (point-max) 'invisible t)
1673 (defun gnus-article-text-type-exists-p (type)
1674 "Say whether any text of type TYPE exists in the buffer."
1675 (text-property-any (point-min) (point-max) 'article-type type))
1677 (defsubst gnus-article-header-rank ()
1678 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1679 (let ((list gnus-sorted-header-list)
1682 (if (looking-at (car list))
1684 (setq list (cdr list))
1688 (defun article-hide-headers (&optional arg delete)
1689 "Hide unwanted headers and possibly sort them as well."
1690 (interactive (gnus-article-hidden-arg))
1691 ;; Lars said that this function might be inhibited.
1692 (if (gnus-article-check-hidden-text 'headers arg)
1694 ;; Show boring headers as well.
1695 (gnus-article-show-hidden-text 'boring-headers)
1696 (when (eq 1 (point-min))
1697 (set-window-start (get-buffer-window (current-buffer)) 1)))
1698 (unless gnus-inhibit-hiding
1699 (let ((inhibit-read-only t)
1700 (case-fold-search t)
1701 (max (1+ (length gnus-sorted-header-list)))
1702 (inhibit-point-motion-hooks t)
1703 (cur (current-buffer))
1704 ignored visible beg)
1706 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1707 ;; group parameters, so we should go to the summary buffer.
1710 (progn (set-buffer gnus-summary-buffer) t)
1712 (setq ignored (when (not gnus-visible-headers)
1713 (cond ((stringp gnus-ignored-headers)
1714 gnus-ignored-headers)
1715 ((listp gnus-ignored-headers)
1716 (mapconcat 'identity
1717 gnus-ignored-headers
1719 visible (cond ((stringp gnus-visible-headers)
1720 gnus-visible-headers)
1721 ((and gnus-visible-headers
1722 (listp gnus-visible-headers))
1723 (mapconcat 'identity
1724 gnus-visible-headers
1728 ;; First we narrow to just the headers.
1729 (article-narrow-to-head)
1730 ;; Hide any "From " lines at the beginning of (mail) articles.
1731 (while (looking-at "From ")
1735 (delete-region (point-min) (point))
1736 (gnus-article-hide-text (point-min) (point)
1737 (nconc (list 'article-type 'headers)
1738 gnus-hidden-properties))))
1739 ;; Then treat the rest of the header lines.
1740 ;; Then we use the two regular expressions
1741 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1742 ;; select which header lines is to remain visible in the
1744 (while (re-search-forward "^[^ \t:]*:" nil t)
1746 ;; Mark the rank of the header.
1748 (point) (1+ (point)) 'message-rank
1749 (if (or (and visible (looking-at visible))
1751 (not (looking-at ignored))))
1752 (gnus-article-header-rank)
1755 (message-sort-headers-1)
1756 (when (setq beg (text-property-any
1757 (point-min) (point-max) 'message-rank (+ 2 max)))
1758 ;; We delete or make invisible the unwanted headers.
1759 (gnus-add-wash-type 'headers)
1762 (add-text-properties
1763 (point-min) (+ 5 (point-min))
1764 '(article-type headers dummy-invisible t))
1765 (delete-region beg (point-max)))
1766 (gnus-article-hide-text-type beg (point-max) 'headers)))))))))
1768 (defun article-hide-boring-headers (&optional arg)
1769 "Toggle hiding of headers that aren't very interesting.
1770 If given a negative prefix, always show; if given a positive prefix,
1772 (interactive (gnus-article-hidden-arg))
1773 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1774 (not gnus-show-all-headers))
1777 (let ((inhibit-read-only t)
1778 (inhibit-point-motion-hooks t))
1779 (article-narrow-to-head)
1780 (dolist (elem gnus-boring-article-headers)
1781 (goto-char (point-min))
1783 ;; Hide empty headers.
1785 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1787 (gnus-article-hide-text-type
1791 (if (re-search-forward "^[^ \t]" nil t)
1795 ;; Hide boring Newsgroups header.
1796 ((eq elem 'newsgroups)
1797 (when (gnus-string-equal
1798 (gnus-fetch-field "newsgroups")
1799 (gnus-group-real-name
1800 (if (boundp 'gnus-newsgroup-name)
1803 (gnus-article-hide-header "newsgroups")))
1804 ((eq elem 'to-address)
1805 (let ((to (message-fetch-field "to"))
1807 (gnus-parameter-to-address
1808 (if (boundp 'gnus-newsgroup-name)
1809 gnus-newsgroup-name ""))))
1810 (when (and to to-address
1813 ;; only one address in To
1814 (nth 1 (mail-extract-address-components to))
1816 (gnus-article-hide-header "to"))))
1818 (let ((to (message-fetch-field "to"))
1820 (gnus-parameter-to-list
1821 (if (boundp 'gnus-newsgroup-name)
1822 gnus-newsgroup-name ""))))
1823 (when (and to to-list
1826 ;; only one address in To
1827 (nth 1 (mail-extract-address-components to))
1829 (gnus-article-hide-header "to"))))
1831 (let ((cc (message-fetch-field "cc"))
1833 (gnus-parameter-to-list
1834 (if (boundp 'gnus-newsgroup-name)
1835 gnus-newsgroup-name ""))))
1836 (when (and cc to-list
1839 ;; only one address in CC
1840 (nth 1 (mail-extract-address-components cc))
1842 (gnus-article-hide-header "cc"))))
1843 ((eq elem 'followup-to)
1844 (when (gnus-string-equal
1845 (message-fetch-field "followup-to")
1846 (message-fetch-field "newsgroups"))
1847 (gnus-article-hide-header "followup-to")))
1848 ((eq elem 'reply-to)
1849 (if (gnus-group-find-parameter
1850 gnus-newsgroup-name 'broken-reply-to)
1851 (gnus-article-hide-header "reply-to")
1852 (let ((from (message-fetch-field "from"))
1853 (reply-to (message-fetch-field "reply-to")))
1860 (lambda (x) (downcase (cadr x)))
1861 (mail-extract-address-components from t))
1864 (lambda (x) (downcase (cadr x)))
1865 (mail-extract-address-components reply-to t))
1867 (gnus-article-hide-header "reply-to")))))
1869 (let ((date (message-fetch-field "date")))
1871 (< (days-between (current-time-string) date)
1873 (gnus-article-hide-header "date"))))
1875 (let ((to (message-fetch-field "to"))
1876 (cc (message-fetch-field "cc")))
1877 (when (> (length to) 1024)
1878 (gnus-article-hide-header "to"))
1879 (when (> (length cc) 1024)
1880 (gnus-article-hide-header "cc"))))
1884 (goto-char (point-min))
1885 (while (re-search-forward "^to:" nil t)
1886 (setq to-count (1+ to-count)))
1887 (when (> to-count 1)
1888 (while (> to-count 0)
1889 (goto-char (point-min))
1891 (re-search-forward "^to:" nil nil to-count)
1893 (narrow-to-region (point) (point-max))
1894 (gnus-article-hide-header "to"))
1895 (setq to-count (1- to-count))))
1896 (goto-char (point-min))
1897 (while (re-search-forward "^cc:" nil t)
1898 (setq cc-count (1+ cc-count)))
1899 (when (> cc-count 1)
1900 (while (> cc-count 0)
1901 (goto-char (point-min))
1903 (re-search-forward "^cc:" nil nil cc-count)
1905 (narrow-to-region (point) (point-max))
1906 (gnus-article-hide-header "cc"))
1907 (setq cc-count (1- cc-count)))))))))))))
1909 (defun gnus-article-hide-header (header)
1911 (goto-char (point-min))
1912 (when (re-search-forward (concat "^" header ":") nil t)
1913 (gnus-article-hide-text-type
1917 (if (re-search-forward "^[^ \t]" nil t)
1922 (defvar gnus-article-normalized-header-length 40
1923 "Length of normalized headers.")
1925 (defun article-normalize-headers ()
1926 "Make all header lines 40 characters long."
1928 (let ((inhibit-read-only t)
1932 (article-narrow-to-head)
1935 ((< (setq column (- (point-at-eol) (point)))
1936 gnus-article-normalized-header-length)
1938 (insert (make-string
1939 (- gnus-article-normalized-header-length column)
1941 ((> column gnus-article-normalized-header-length)
1942 (gnus-put-text-property
1944 (forward-char gnus-article-normalized-header-length)
1951 (forward-line 1))))))
1953 (defun article-treat-dumbquotes ()
1954 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
1955 Note that this function guesses whether a character is a sm*rtq**t* or
1956 not, so it should only be used interactively.
1958 Sm*rtq**t*s are M****s***'s unilateral extension to the
1959 iso-8859-1 character map in an attempt to provide more quoting
1960 characters. If you see something like \\222 or \\264 where
1961 you're expecting some kind of apostrophe or quotation mark, then
1964 (article-translate-strings gnus-article-dumbquotes-map))
1966 (defun article-translate-characters (from to)
1967 "Translate all characters in the body of the article according to FROM and TO.
1968 FROM is a string of characters to translate from; to is a string of
1969 characters to translate to."
1971 (when (article-goto-body)
1972 (let ((inhibit-read-only t)
1973 (x (make-string 225 ?x))
1975 (while (< (incf i) (length x))
1978 (while (< i (length from))
1979 (aset x (aref from i) (aref to i))
1981 (translate-region (point) (point-max) x)))))
1983 (defun article-translate-strings (map)
1984 "Translate all string in the body of the article according to MAP.
1985 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1987 (when (article-goto-body)
1988 (let ((inhibit-read-only t))
1991 (while (search-forward (car elem) nil t)
1992 (replace-match (cadr elem)))))))))
1994 (defun article-treat-overstrike ()
1995 "Translate overstrikes into bold text."
1998 (when (article-goto-body)
1999 (let ((inhibit-read-only t))
2000 (while (search-forward "\b" nil t)
2001 (let ((next (char-after))
2005 previous (char-after))
2009 ;; We do the boldification/underlining by hiding the
2010 ;; overstrikes and putting the proper text property
2014 (gnus-article-hide-text-type start (point) 'overstrike)
2015 (put-text-property (point) end 'face 'bold))
2017 (gnus-article-hide-text-type
2018 (1- (point)) (1+ (point)) 'overstrike)
2020 start (1- (point)) 'face 'underline))
2022 (gnus-article-hide-text-type start (point) 'overstrike)
2024 (point) end 'face 'underline)))))))))
2026 (defun article-treat-ansi-sequences ()
2027 "Translate ANSI SGR control sequences into overlays or extents."
2030 (when (article-goto-body)
2031 (let ((inhibit-read-only t))
2032 (ansi-color-apply-on-region (point) (point-max))))))
2034 (defun gnus-article-treat-unfold-headers ()
2035 "Unfold folded message headers.
2036 Only the headers that fit into the current window width will be
2039 (gnus-with-article-headers
2043 (mail-header-narrow-to-field)
2044 (let ((header (buffer-string)))
2047 (goto-char (point-min))
2048 (while (re-search-forward "\n[\t ]" nil t)
2049 (replace-match " " t t)))
2050 (setq length (- (point-max) (point-min) 1)))
2051 (when (< length (window-width))
2052 (while (re-search-forward "\n[\t ]" nil t)
2053 (replace-match " " t t)))
2054 (goto-char (point-max)))))))
2056 (defun gnus-article-treat-fold-headers ()
2057 "Fold message headers."
2059 (gnus-with-article-headers
2062 (mail-header-narrow-to-field)
2063 (mail-header-fold-field)
2064 (goto-char (point-max))))))
2066 (defun gnus-treat-smiley ()
2067 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2069 (unless (featurep 'xemacs)
2070 (when (and (not gnus-article-should-use-smiley-mule)
2071 gnus-article-smiley-mule-loaded-p)
2072 (load "smiley" nil t)
2073 (setq gnus-article-smiley-mule-loaded-p nil))
2074 (when (and gnus-article-should-use-smiley-mule
2075 (not gnus-article-smiley-mule-loaded-p))
2076 (load "smiley-mule" nil t)
2077 (setq gnus-article-smiley-mule-loaded-p t)))
2078 (gnus-with-article-buffer
2079 (if (memq 'smiley gnus-article-wash-types)
2080 (gnus-delete-images 'smiley)
2082 (let ((images (smiley-region (point) (point-max))))
2084 (gnus-add-wash-type 'smiley)
2085 (dolist (image images)
2086 (gnus-add-image 'smiley image)))))))
2088 (defun gnus-article-remove-images ()
2089 "Remove all images from the article buffer."
2091 (gnus-with-article-buffer
2092 (dolist (elem gnus-article-image-alist)
2093 (gnus-delete-images (car elem)))))
2095 (defun gnus-article-treat-fold-newsgroups ()
2096 "Unfold folded message headers.
2097 Only the headers that fit into the current window width will be
2100 (gnus-with-article-headers
2101 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2103 (mail-header-narrow-to-field)
2104 (while (re-search-forward ", *" nil t)
2105 (replace-match ", " t t))
2106 (mail-header-fold-field)
2107 (goto-char (point-max))))))
2109 (defun gnus-article-treat-body-boundary ()
2110 "Place a boundary line at the end of the headers."
2112 (when (and gnus-body-boundary-delimiter
2113 (> (length gnus-body-boundary-delimiter) 0))
2114 (gnus-with-article-headers
2115 (goto-char (point-max))
2116 (let ((start (point)))
2117 (insert "X-Boundary: ")
2118 (gnus-add-text-properties start (point) '(invisible t intangible t))
2120 (while (>= (1- (window-width)) (length str))
2121 (setq str (concat str gnus-body-boundary-delimiter)))
2122 (substring str 0 (1- (window-width))))
2124 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2126 (defun article-fill-long-lines ()
2127 "Fill lines that are wider than the window width."
2130 (let ((inhibit-read-only t)
2131 (width (window-width (get-buffer-window (current-buffer)))))
2134 (let ((adaptive-fill-mode nil)) ;Why? -sm
2137 (when (>= (current-column) (min fill-column width))
2138 (narrow-to-region (min (1+ (point)) (point-max))
2140 (let ((goback (point-marker)))
2141 (fill-paragraph nil)
2142 (goto-char (marker-position goback)))
2144 (forward-line 1)))))))
2146 (defun article-capitalize-sentences ()
2147 "Capitalize the first word in each sentence."
2150 (let ((inhibit-read-only t)
2151 (paragraph-start "^[\n\^L]"))
2155 (forward-sentence)))))
2157 (defun article-remove-cr ()
2158 "Remove trailing CRs and then translate remaining CRs into LFs."
2161 (let ((inhibit-read-only t))
2162 (goto-char (point-min))
2163 (while (re-search-forward "\r+$" nil t)
2164 (replace-match "" t t))
2165 (goto-char (point-min))
2166 (while (search-forward "\r" nil t)
2167 (replace-match "\n" t t)))))
2169 (defun article-remove-trailing-blank-lines ()
2170 "Remove all trailing blank lines from the article."
2173 (let ((inhibit-read-only t))
2174 (goto-char (point-max))
2178 (while (and (not (bobp))
2179 (looking-at "^[ \t]*$")
2180 (not (gnus-annotation-in-region-p
2181 (point) (point-at-eol))))
2187 (defvar gnus-face-properties-alist))
2189 (defun article-display-face ()
2190 "Display any Face headers in the header."
2192 (let ((wash-face-p buffer-read-only))
2193 (gnus-with-article-headers
2194 ;; When displaying parts, this function can be called several times on
2195 ;; the same article, without any intended toggle semantic (as typing `W
2196 ;; D d' would have). So face deletion must occur only when we come from
2197 ;; an interactive command, that is when the *Article* buffer is
2199 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2200 (gnus-delete-images 'face)
2203 (when (and wash-face-p
2205 (goto-char (point-min))
2206 (not (re-search-forward "^Face:[\t ]*" nil t)))
2207 (gnus-buffer-live-p gnus-original-article-buffer))
2208 (set-buffer gnus-original-article-buffer))
2210 (mail-narrow-to-head)
2211 (while (gnus-article-goto-header "Face")
2212 (setq faces (nconc faces (list (mail-header-field-value)))))))
2213 (dolist (face faces)
2214 (let ((png (gnus-convert-face-to-png face))
2218 (apply 'gnus-create-image png 'png t
2219 (cdr (assq 'png gnus-face-properties-alist))))
2220 (gnus-article-goto-header "from")
2222 (insert "From: [no `from' set]\n")
2224 (gnus-add-wash-type 'face)
2225 (gnus-add-image 'face image)
2226 (gnus-put-image image nil 'face))))))
2229 (defun article-display-x-face (&optional force)
2230 "Look for an X-Face header and display it if present."
2231 (interactive (list 'force))
2232 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2233 (gnus-with-article-headers
2234 ;; Delete the old process, if any.
2235 (when (process-status "article-x-face")
2236 (delete-process "article-x-face"))
2237 ;; See the comment in `article-display-face'.
2238 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2239 ;; We have already displayed X-Faces, so we remove them
2241 (gnus-delete-images 'xface)
2243 (let (x-faces from face)
2245 (when (and wash-face-p
2247 (goto-char (point-min))
2248 (not (re-search-forward
2249 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2250 (gnus-buffer-live-p gnus-original-article-buffer))
2251 ;; If type `W f', use gnus-original-article-buffer,
2252 ;; otherwise use the current buffer because displaying
2253 ;; RFC822 parts calls this function too.
2254 (set-buffer gnus-original-article-buffer))
2256 (mail-narrow-to-head)
2257 (while (gnus-article-goto-header "X-Face")
2258 (push (mail-header-field-value) x-faces))
2259 (setq from (message-fetch-field "from"))))
2260 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2261 ;; single external face.
2262 (when (stringp gnus-article-x-face-command)
2263 (setq x-faces (list (car x-faces))))
2264 (while (and (setq face (pop x-faces))
2265 gnus-article-x-face-command
2267 ;; Check whether this face is censored.
2268 (not gnus-article-x-face-too-ugly)
2269 (and gnus-article-x-face-too-ugly from
2270 (not (string-match gnus-article-x-face-too-ugly
2272 ;; We display the face.
2273 (cond ((stringp gnus-article-x-face-command)
2274 ;; The command is a string, so we interpret the command
2275 ;; as a, well, command, and fork it off.
2276 (let ((process-connection-type nil))
2277 (process-kill-without-query
2279 "article-x-face" nil shell-file-name
2280 shell-command-switch gnus-article-x-face-command))
2283 (process-send-region "article-x-face"
2284 (point-min) (point-max)))
2285 (process-send-eof "article-x-face")))
2286 ((functionp gnus-article-x-face-command)
2287 ;; The command is a lisp function, so we call it.
2288 (funcall gnus-article-x-face-command face))
2290 (error "%s is not a function"
2291 gnus-article-x-face-command)))))))))
2293 (defun article-decode-mime-words ()
2294 "Decode all MIME-encoded words in the article."
2296 (gnus-with-article-buffer
2297 (let ((inhibit-point-motion-hooks t)
2298 (mail-parse-charset gnus-newsgroup-charset)
2299 (mail-parse-ignored-charsets
2300 (with-current-buffer gnus-summary-buffer
2301 gnus-newsgroup-ignored-charsets)))
2302 (mail-decode-encoded-word-region (point-min) (point-max)))))
2304 (defun article-decode-charset (&optional prompt)
2305 "Decode charset-encoded text in the article.
2306 If PROMPT (the prefix), prompt for a coding system to use."
2308 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2309 (inhibit-read-only t)
2310 (mail-parse-charset gnus-newsgroup-charset)
2311 (mail-parse-ignored-charsets
2312 (save-excursion (condition-case nil
2313 (set-buffer gnus-summary-buffer)
2315 gnus-newsgroup-ignored-charsets))
2316 ct cte ctl charset format)
2319 (article-narrow-to-head)
2320 (setq ct (message-fetch-field "Content-Type" t)
2321 cte (message-fetch-field "Content-Transfer-Encoding" t)
2322 ctl (and ct (ignore-errors
2323 (mail-header-parse-content-type ct)))
2326 (mm-read-coding-system "Charset to decode: "))
2328 (mail-content-type-get ctl 'charset)))
2329 format (and ctl (mail-content-type-get ctl 'format)))
2331 (setq cte (mail-header-strip cte)))
2332 (if (and ctl (not (string-match "/" (car ctl))))
2334 (goto-char (point-max)))
2337 (narrow-to-region (point) (point-max))
2338 (when (and (eq mail-parse-charset 'gnus-decoded)
2339 (eq (mm-body-7-or-8) '8bit))
2340 ;; The text code could have been decoded.
2341 (setq charset mail-parse-charset))
2342 (when (and (or (not ctl)
2343 (equal (car ctl) "text/plain"))
2344 (not format)) ;; article with format will decode later.
2346 charset (and cte (intern (downcase
2347 (gnus-strip-whitespace cte))))
2350 (defun article-decode-encoded-words ()
2351 "Remove encoded-word encoding from headers."
2352 (let ((charset (save-excursion
2353 (set-buffer gnus-summary-buffer)
2354 default-mime-charset))
2355 (inhibit-read-only t))
2356 (mime-decode-header-in-buffer charset)))
2358 (defun article-decode-group-name ()
2359 "Decode group names in `Newsgroups:'."
2360 (let ((inhibit-point-motion-hooks t)
2361 (inhibit-read-only t)
2362 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2363 (when (and (or gnus-group-name-charset-method-alist
2364 gnus-group-name-charset-group-alist)
2365 (gnus-buffer-live-p gnus-original-article-buffer))
2367 (article-narrow-to-head)
2368 (with-current-buffer gnus-original-article-buffer
2369 (goto-char (point-min)))
2370 (while (re-search-forward
2371 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2372 (replace-match (save-match-data
2373 (gnus-decode-newsgroups
2374 ;; XXX how to use data in article buffer?
2375 (with-current-buffer gnus-original-article-buffer
2377 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2380 gnus-newsgroup-name method))
2382 (goto-char (point-min))
2383 (with-current-buffer gnus-original-article-buffer
2384 (goto-char (point-min)))
2385 (while (re-search-forward
2386 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2387 (replace-match (save-match-data
2388 (gnus-decode-newsgroups
2389 ;; XXX how to use data in article buffer?
2390 (with-current-buffer gnus-original-article-buffer
2392 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2395 gnus-newsgroup-name method))
2398 (autoload 'idna-to-unicode "idna")
2400 (defun article-decode-idna-rhs ()
2401 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2404 (let ((inhibit-point-motion-hooks t)
2405 (inhibit-read-only t))
2406 (article-narrow-to-head)
2407 (goto-char (point-min))
2408 (while (re-search-forward "@.*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2410 (when (save-match-data
2411 (and (setq ace (match-string 1))
2413 (and (re-search-backward "^[^ \t]" nil t)
2414 (looking-at "From\\|To\\|Cc")))
2415 (setq unicode (idna-to-unicode ace))))
2416 (unless (string= ace unicode)
2417 (replace-match unicode nil nil nil 1)))))))))
2419 (defun article-de-quoted-unreadable (&optional force read-charset)
2420 "Translate a quoted-printable-encoded article.
2421 If FORCE, decode the article whether it is marked as quoted-printable
2423 If READ-CHARSET, ask for a coding system."
2424 (interactive (list 'force current-prefix-arg))
2426 (let ((inhibit-read-only t) type charset)
2427 (if (gnus-buffer-live-p gnus-original-article-buffer)
2428 (with-current-buffer gnus-original-article-buffer
2430 (gnus-fetch-field "content-transfer-encoding"))
2431 (let* ((ct (gnus-fetch-field "content-type"))
2434 (mail-header-parse-content-type ct)))))
2435 (setq charset (and ctl
2436 (mail-content-type-get ctl 'charset)))
2437 (if (stringp charset)
2438 (setq charset (intern (downcase charset)))))))
2440 (setq charset (mm-read-coding-system "Charset: " charset)))
2442 (setq charset gnus-newsgroup-charset))
2444 (and type (let ((case-fold-search t))
2445 (string-match "quoted-printable" type))))
2447 (quoted-printable-decode-region
2448 (point) (point-max) (mm-charset-to-coding-system charset))))))
2450 (defun article-de-base64-unreadable (&optional force read-charset)
2451 "Translate a base64 article.
2452 If FORCE, decode the article whether it is marked as base64 not.
2453 If READ-CHARSET, ask for a coding system."
2454 (interactive (list 'force current-prefix-arg))
2456 (let ((inhibit-read-only t) type charset)
2457 (if (gnus-buffer-live-p gnus-original-article-buffer)
2458 (with-current-buffer gnus-original-article-buffer
2460 (gnus-fetch-field "content-transfer-encoding"))
2461 (let* ((ct (gnus-fetch-field "content-type"))
2464 (mail-header-parse-content-type ct)))))
2465 (setq charset (and ctl
2466 (mail-content-type-get ctl 'charset)))
2467 (if (stringp charset)
2468 (setq charset (intern (downcase charset)))))))
2470 (setq charset (mm-read-coding-system "Charset: " charset)))
2472 (setq charset gnus-newsgroup-charset))
2474 (and type (let ((case-fold-search t))
2475 (string-match "base64" type))))
2478 (narrow-to-region (point) (point-max))
2479 (base64-decode-region (point-min) (point-max))
2480 (mm-decode-coding-region
2481 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2486 (defun article-decode-HZ ()
2487 "Translate a HZ-encoded article."
2491 (let ((inhibit-read-only t))
2492 (rfc1843-decode-region (point-min) (point-max)))))
2494 (defun article-unsplit-urls ()
2495 "Remove the newlines that some other mailers insert into URLs."
2498 (let ((inhibit-read-only t))
2499 (goto-char (point-min))
2500 (while (re-search-forward
2501 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2502 (replace-match "\\1\\3" t)))
2503 (when (interactive-p)
2504 (gnus-treat-article nil))))
2507 (defun article-wash-html (&optional read-charset)
2508 "Format an HTML article.
2509 If READ-CHARSET, ask for a coding system."
2512 (let ((inhibit-read-only t)
2514 (when (gnus-buffer-live-p gnus-original-article-buffer)
2515 (with-current-buffer gnus-original-article-buffer
2516 (let* ((ct (gnus-fetch-field "content-type"))
2519 (mail-header-parse-content-type ct)))))
2520 (setq charset (and ctl
2521 (mail-content-type-get ctl 'charset)))
2522 (when (stringp charset)
2523 (setq charset (intern (downcase charset)))))))
2525 (setq charset (mm-read-coding-system "Charset: " charset)))
2527 (setq charset gnus-newsgroup-charset))
2529 (save-window-excursion
2531 (narrow-to-region (point) (point-max))
2532 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2533 (entry (assq func mm-text-html-washer-alist)))
2535 (setq func (cdr entry)))
2540 (apply (car func) (cdr func))))))))))
2542 (defun gnus-article-wash-html-with-w3 ()
2543 "Wash the current buffer with w3."
2545 (let ((w3-strict-width (window-width))
2546 (url-standalone-mode t)
2547 (url-gateway-unplugged t)
2548 (w3-honor-stylesheets nil))
2550 (w3-region (point-min) (point-max))
2553 (defun gnus-article-wash-html-with-w3m ()
2554 "Wash the current buffer with emacs-w3m."
2557 (narrow-to-region (point) (point-max))
2558 (let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp)
2559 w3m-force-redisplay)
2560 (w3m-region (point-min) (point-max)))
2561 (when (and mm-inline-text-html-with-w3m-keymap
2562 (boundp 'w3m-minor-mode-map)
2564 (add-text-properties
2565 (point-min) (point-max)
2566 (list 'keymap w3m-minor-mode-map
2567 ;; Put the mark meaning this part was rendered by emacs-w3m.
2568 'mm-inline-text-html-with-w3m t)))))
2570 (defun article-hide-list-identifiers ()
2571 "Remove list identifies from the Subject header.
2572 The `gnus-list-identifiers' variable specifies what to do."
2574 (let ((inhibit-point-motion-hooks t)
2575 (regexp (if (consp gnus-list-identifiers)
2576 (mapconcat 'identity gnus-list-identifiers " *\\|")
2577 gnus-list-identifiers))
2578 (inhibit-read-only t))
2582 (article-narrow-to-head)
2583 (goto-char (point-min))
2584 (while (re-search-forward
2585 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2587 (delete-region (match-beginning 2) (match-end 0))
2588 (beginning-of-line))
2589 (when (re-search-forward
2590 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2591 (delete-region (match-beginning 1) (match-end 1))))))))
2593 (defun article-hide-pem (&optional arg)
2594 "Toggle hiding of any PEM headers and signatures in the current article.
2595 If given a negative prefix, always show; if given a positive prefix,
2597 (interactive (gnus-article-hidden-arg))
2598 (unless (gnus-article-check-hidden-text 'pem arg)
2600 (let ((inhibit-read-only t) end)
2601 (goto-char (point-min))
2602 ;; Hide the horrendously ugly "header".
2603 (when (and (search-forward
2604 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2606 (setq end (1+ (match-beginning 0))))
2607 (gnus-add-wash-type 'pem)
2608 (gnus-article-hide-text-type
2610 (if (search-forward "\n\n" nil t)
2614 ;; Hide the trailer as well
2615 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2617 (gnus-article-hide-text-type
2618 (match-beginning 0) (match-end 0) 'pem)))))))
2620 (defun article-strip-banner ()
2621 "Strip the banners specified by the `banner' group parameter and by
2622 `gnus-article-address-banner-alist'."
2626 (let ((inhibit-point-motion-hooks t))
2627 (when (gnus-parameter-banner gnus-newsgroup-name)
2628 (article-really-strip-banner
2629 (gnus-parameter-banner gnus-newsgroup-name)))
2630 (when gnus-article-address-banner-alist
2631 ;; It is necessary to encode from fields before checking,
2632 ;; because `mail-header-parse-addresses' does not work
2633 ;; (reliably) on decoded headers. And more, it is
2634 ;; impossible to use `gnus-fetch-original-field' here,
2635 ;; because `article-strip-banner' may be called in draft
2636 ;; buffers to preview them.
2637 (let ((from (save-restriction
2639 (article-narrow-to-head)
2640 (mail-fetch-field "from"))))
2643 (caar (mail-header-parse-addresses
2644 (mail-encode-encoded-word-string from)))))
2646 (dolist (pair gnus-article-address-banner-alist)
2647 (when (string-match (car pair) from)
2649 (article-really-strip-banner (cdr pair)))))))))))))
2651 (defun article-really-strip-banner (banner)
2652 "Strip the banner specified by the argument."
2655 (let ((inhibit-point-motion-hooks t)
2656 (gnus-signature-limit nil)
2657 (inhibit-read-only t))
2660 ((eq banner 'signature)
2661 (when (gnus-article-narrow-to-signature)
2664 (delete-region (point) (point-max))))
2666 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2667 (while (re-search-forward banner nil t)
2668 (delete-region (match-beginning 0) (match-end 0)))))
2670 (while (re-search-forward banner nil t)
2671 (delete-region (match-beginning 0) (match-end 0)))))))))
2673 (defun article-babel ()
2674 "Translate article using an online translation service."
2677 (gnus-with-article-buffer
2678 (when (article-goto-body)
2679 (let* ((start (point))
2681 (orig (buffer-substring start end))
2682 (trans (babel-as-string orig)))
2684 (narrow-to-region start end)
2685 (delete-region start end)
2688 (defun article-hide-signature (&optional arg)
2689 "Hide the signature in the current article.
2690 If given a negative prefix, always show; if given a positive prefix,
2692 (interactive (gnus-article-hidden-arg))
2698 (article-goto-body))
2699 (goto-char (point-min)))
2700 (unless (gnus-article-check-hidden-text 'signature arg)
2701 (let ((inhibit-read-only t)
2703 (while (setq button (text-property-any button (point-max)
2705 'gnus-signature-toggle))
2706 (setq button (text-property-not-all button (point-max)
2708 'gnus-signature-toggle))
2709 (when (and button (not (eobp)))
2710 (gnus-article-hide-text-type
2712 (next-single-property-change (1+ button) 'mime-view-entity
2715 (gnus-set-mode-line 'article))
2717 (defun article-strip-headers-in-body ()
2718 "Strip offensive headers from bodies."
2722 (let ((case-fold-search t))
2723 (when (looking-at "x-no-archive:")
2724 (gnus-delete-line)))))
2726 (defun article-strip-leading-blank-lines ()
2727 "Remove all blank lines from the beginning of the article."
2730 (let ((inhibit-point-motion-hooks t)
2731 (inhibit-read-only t))
2732 (when (article-goto-body)
2733 (while (and (not (eobp))
2734 (looking-at "[ \t]*$"))
2735 (gnus-delete-line))))))
2737 (defun article-narrow-to-head ()
2738 "Narrow the buffer to the head of the message.
2739 Point is left at the beginning of the narrowed-to region."
2741 (goto-char (point-min))
2742 (if (search-forward "\n\n" nil 1)
2745 (goto-char (point-min)))
2747 (defun article-goto-body ()
2748 "Place point at the start of the body."
2749 (goto-char (point-min))
2751 ;; This variable is only bound when dealing with separate
2753 (article-goto-body-goes-to-point-min-p
2755 ((search-forward "\n\n" nil t)
2758 (goto-char (point-max))
2761 (defun article-strip-multiple-blank-lines ()
2762 "Replace consecutive blank lines with one empty line."
2765 (let ((inhibit-point-motion-hooks t)
2766 (inhibit-read-only t))
2767 ;; First make all blank lines empty.
2769 (while (re-search-forward "^[ \t]+$" nil t)
2770 (unless (gnus-annotation-in-region-p
2771 (match-beginning 0) (match-end 0))
2772 (replace-match "" nil t)))
2773 ;; Then replace multiple empty lines with a single empty line.
2775 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2776 (unless (gnus-annotation-in-region-p
2777 (match-beginning 0) (match-end 0))
2778 (delete-region (match-beginning 1) (match-end 1)))))))
2780 (defun article-strip-leading-space ()
2781 "Remove all white space from the beginning of the lines in the article."
2784 (let ((inhibit-point-motion-hooks t)
2785 (inhibit-read-only t))
2787 (while (re-search-forward "^[ \t]+" nil t)
2788 (replace-match "" t t)))))
2790 (defun article-strip-trailing-space ()
2791 "Remove all white space from the end of the lines in the article."
2794 (let ((inhibit-point-motion-hooks t)
2795 (inhibit-read-only t))
2797 (while (re-search-forward "[ \t]+$" nil t)
2798 (replace-match "" t t)))))
2800 (defun article-strip-blank-lines ()
2801 "Strip leading, trailing and multiple blank lines."
2803 (article-strip-leading-blank-lines)
2804 (article-remove-trailing-blank-lines)
2805 (article-strip-multiple-blank-lines))
2807 (defun article-strip-all-blank-lines ()
2808 "Strip all blank lines."
2811 (let ((inhibit-point-motion-hooks t)
2812 (inhibit-read-only t))
2814 (while (re-search-forward "^[ \t]*\n" nil t)
2815 (replace-match "" t t)))))
2817 (defun gnus-article-narrow-to-signature ()
2818 "Narrow to the signature; return t if a signature is found, else nil."
2819 (let ((inhibit-point-motion-hooks t))
2820 (when (gnus-article-search-signature)
2822 ;; Check whether we have some limits to what we consider
2823 ;; to be a signature.
2824 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2825 (list gnus-signature-limit)))
2827 (while (setq limit (pop limits))
2828 (if (or (and (integerp limit)
2829 (< (- (point-max) (point)) limit))
2831 (< (count-lines (point) (point-max)) limit))
2832 (and (functionp limit)
2834 (and (stringp limit)
2835 (not (re-search-forward limit nil t))))
2836 () ; This limit did not succeed.
2840 (narrow-to-region (point) (point-max))
2843 (defun gnus-article-search-signature ()
2844 "Search the current buffer for the signature separator.
2845 Put point at the beginning of the signature separator."
2846 (let ((cur (point)))
2847 (goto-char (point-max))
2848 (if (if (stringp gnus-signature-separator)
2849 (re-search-backward gnus-signature-separator nil t)
2850 (let ((seps gnus-signature-separator))
2852 (not (re-search-backward (car seps) nil t)))
2859 (defun gnus-article-hidden-arg ()
2860 "Return the current prefix arg as a number, or 0 if no prefix."
2861 (list (if current-prefix-arg
2862 (prefix-numeric-value current-prefix-arg)
2865 (defun gnus-article-check-hidden-text (type arg)
2866 "Return nil if hiding is necessary.
2867 Arg can be nil or a number. nil and positive means hide, negative
2868 means show, 0 means toggle."
2871 (let ((hide (gnus-article-hidden-text-p type)))
2877 (gnus-article-show-hidden-text type)
2880 (if (eq hide 'hidden)
2882 (gnus-article-show-hidden-text type)
2886 (defun gnus-article-hidden-text-p (type)
2887 "Say whether the current buffer contains hidden text of type TYPE."
2888 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2890 (not (get-text-property pos 'invisible))
2891 (not (get-text-property pos 'dummy-invisible)))
2893 (text-property-any (1+ pos) (point-max) 'article-type type)))
2898 (defun gnus-article-show-hidden-text (type &optional dummy)
2899 "Show all hidden text of type TYPE.
2900 Originally it is hide instead of DUMMY."
2901 (let ((inhibit-read-only t)
2902 (inhibit-point-motion-hooks t))
2903 (gnus-remove-text-properties-when
2905 (point-min) (point-max)
2906 (cons 'article-type (cons type
2907 gnus-hidden-properties)))
2908 (gnus-delete-wash-type type)))
2910 (defconst article-time-units
2911 `((year . ,(* 365.25 24 60 60))
2912 (week . ,(* 7 24 60 60))
2913 (day . ,(* 24 60 60))
2917 "Mapping from time units to seconds.")
2919 (defun gnus-article-forward-header ()
2920 "Move point to the start of the next header.
2921 If the current header is a continuation header, this can be several
2926 (if (looking-at "[ \t]+[^ \t]")
2930 (defun article-date-ut (&optional type highlight header)
2931 "Convert DATE date to universal time in the current article.
2932 If TYPE is `local', convert to local time; if it is `lapsed', output
2933 how much time has lapsed since DATE. For `lapsed', the value of
2934 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2935 should replace the \"Date:\" one, or should be added below it."
2936 (interactive (list 'ut t))
2937 (let* ((header (or header
2938 (and (eq 1 (point-min))
2939 (mail-header-date (save-excursion
2940 (set-buffer gnus-summary-buffer)
2941 gnus-current-headers)))
2942 (message-fetch-field "date")
2944 (date (if (vectorp header) (mail-header-date header)
2946 (inhibit-point-motion-hooks t)
2947 bface eface date-pos)
2948 (when (and date (not (string= date "")))
2951 (article-narrow-to-head)
2952 (when (or (and (eq type 'lapsed)
2953 gnus-article-date-lapsed-new-header
2954 ;; Attempt to get the face of X-Sent first.
2955 (re-search-forward "^X-Sent:[ \t]" nil t))
2956 (re-search-forward "^Date:[ \t]" nil t)
2957 ;; If Date is missing, try again for X-Sent.
2958 (re-search-forward "^X-Sent:[ \t]" nil t))
2959 (setq bface (get-text-property (point-at-bol) 'face)
2960 date (or (get-text-property (point-at-bol)
2963 eface (get-text-property (1- (point-at-eol))
2965 (let ((inhibit-read-only t))
2966 ;; Delete any old X-Sent headers.
2967 (when (setq date-pos
2968 (text-property-any (point-min) (point-max)
2969 'article-date-lapsed t))
2970 (goto-char (setq date-pos (set-marker (make-marker) date-pos)))
2971 (delete-region (match-beginning 0)
2972 (progn (forward-line 1) (point))))
2973 (goto-char (point-min))
2974 ;; Delete any old Date headers.
2975 (while (re-search-forward "^Date:[ \t]" nil t)
2977 (setq date-pos (match-beginning 0)))
2978 (unless (and (eq type 'lapsed)
2979 gnus-article-date-lapsed-new-header)
2980 (delete-region (match-beginning 0)
2981 (progn (message-next-header) (point)))))
2984 (goto-char date-pos)
2986 ;; Possibly, Date has been deleted.
2988 (when (and (eq type 'lapsed)
2989 gnus-article-date-lapsed-new-header
2990 (looking-at "Date:"))
2992 (goto-char (point-min)))
2993 (insert (article-make-date-line date type))
2994 (when (eq type 'lapsed)
2995 (put-text-property (point-at-bol) (point)
2996 'article-date-lapsed t))
3000 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
3001 (add-text-properties (match-beginning 1) (1+ (match-end 1))
3002 (list 'original-date date 'face bface))
3003 (put-text-property (match-beginning 2) (match-end 2)
3006 (defun article-make-date-line (date type)
3007 "Return a DATE line of TYPE."
3008 (unless (memq type '(local ut original user iso8601 lapsed english))
3009 (error "Unknown conversion type: %s" type))
3011 (let ((time (date-to-time date)))
3013 ;; Convert to the local timezone.
3015 (concat "Date: " (message-make-date time)))
3016 ;; Convert to Universal Time.
3021 (let* ((e (parse-time-string date))
3022 (tm (apply 'encode-time e))
3024 (ls (- (cadr tm) (car (current-time-zone time)))))
3025 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
3026 ((> ls 65535) (list (1+ ms) (- ls 65536)))
3030 ;; Get the original date from the article.
3031 ((eq type 'original)
3032 (concat "Date: " (if (string-match "\n+$" date)
3033 (substring date 0 (match-beginning 0))
3035 ;; Let the user define the format.
3037 (let ((format (or (condition-case nil
3038 (with-current-buffer gnus-summary-buffer
3039 gnus-article-time-format)
3041 gnus-article-time-format)))
3042 (if (functionp format)
3043 (funcall format time)
3044 (concat "Date: " (format-time-string format time)))))
3047 (let ((tz (car (current-time-zone time))))
3050 (format-time-string "%Y%m%dT%H%M%S" time)
3051 (format "%s%02d%02d"
3052 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
3053 (/ (% (abs tz) 3600) 60)))))
3054 ;; Do an X-Sent lapsed format.
3056 ;; If the date is seriously mangled, the timezone functions are
3057 ;; liable to bug out, so we ignore all errors.
3058 (let* ((now (current-time))
3059 (real-time (subtract-time now time))
3060 (real-sec (and real-time
3061 (+ (* (float (car real-time)) 65536)
3063 (sec (and real-time (abs real-sec)))
3073 ;; This is a bit convoluted, but basically we go
3074 ;; through the time units for years, weeks, etc,
3075 ;; and divide things to see whether that results
3076 ;; in positive answers.
3079 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
3080 ;; The (remaining) seconds are too few to
3081 ;; be divided into this time unit.
3083 ;; It's big enough, so we output it.
3084 (setq sec (- sec (* num (cdr unit))))
3086 (concat (if prev ", " "") (int-to-string
3088 " " (symbol-name (car unit))
3089 (if (> num 1) "s" ""))
3091 article-time-units "")
3092 ;; If dates are odd, then it might appear like the
3093 ;; article was sent in the future.
3096 " in the future"))))))
3097 ;; Display the date in proper English
3099 (let ((dtime (decode-time time)))
3102 (number-to-string (nth 3 dtime))
3103 (let ((digit (% (nth 3 dtime) 10)))
3105 ((memq (nth 3 dtime) '(11 12 13)) "th")
3111 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3113 (number-to-string (nth 5 dtime))
3115 (format "%02d" (nth 2 dtime))
3117 (format "%02d" (nth 1 dtime)))))))
3119 (format "Date: %s (from T-gnus)" date))))
3121 (defun article-date-local (&optional highlight)
3122 "Convert the current article date to the local timezone."
3123 (interactive (list t))
3124 (article-date-ut 'local highlight))
3126 (defun article-date-english (&optional highlight)
3127 "Convert the current article date to something that is proper English."
3128 (interactive (list t))
3129 (article-date-ut 'english highlight))
3131 (defun article-date-original (&optional highlight)
3132 "Convert the current article date to what it was originally.
3133 This is only useful if you have used some other date conversion
3134 function and want to see what the date was before converting."
3135 (interactive (list t))
3136 (article-date-ut 'original highlight))
3138 (defun article-date-lapsed (&optional highlight)
3139 "Convert the current article date to time lapsed since it was sent."
3140 (interactive (list t))
3141 (article-date-ut 'lapsed highlight))
3143 (defun article-update-date-lapsed ()
3144 "Function to be run from a timer to update the lapsed time line."
3145 (let (deactivate-mark)
3150 (set-buffer (window-buffer w))
3151 (when (eq major-mode 'gnus-article-mode)
3152 (let ((mark (point-marker)))
3153 (goto-char (point-min))
3154 (when (re-search-forward "^X-Sent:" nil t)
3155 (article-date-lapsed t))
3156 (goto-char (marker-position mark))
3157 (move-marker mark nil))))
3160 (defun gnus-start-date-timer (&optional n)
3161 "Start a timer to update the X-Sent header in the article buffers.
3162 The numerical prefix says how frequently (in seconds) the function
3167 (gnus-stop-date-timer)
3168 (setq article-lapsed-timer
3169 (run-at-time 1 n 'article-update-date-lapsed)))
3171 (defun gnus-stop-date-timer ()
3172 "Stop the X-Sent timer."
3174 (when article-lapsed-timer
3175 (nnheader-cancel-timer article-lapsed-timer)
3176 (setq article-lapsed-timer nil)))
3178 (defun article-date-user (&optional highlight)
3179 "Convert the current article date to the user-defined format.
3180 This format is defined by the `gnus-article-time-format' variable."
3181 (interactive (list t))
3182 (article-date-ut 'user highlight))
3184 (defun article-date-iso8601 (&optional highlight)
3185 "Convert the current article date to ISO8601."
3186 (interactive (list t))
3187 (article-date-ut 'iso8601 highlight))
3189 ;; (defun article-show-all ()
3190 ;; "Show all hidden text in the article buffer."
3194 ;; (let ((inhibit-read-only t))
3195 ;; (gnus-article-unhide-text (point-min) (point-max))
3196 ;; (gnus-remove-text-with-property 'gnus-prev)
3197 ;; (gnus-remove-text-with-property 'gnus-next))))
3199 (defun article-show-all-headers ()
3200 "Show all hidden headers in the article buffer."
3205 (article-narrow-to-head)
3206 (let ((inhibit-read-only t))
3207 (gnus-article-unhide-text (point-min) (point-max))))))
3209 (defun article-remove-leading-whitespace ()
3210 "Remove excessive whitespace from all headers."
3214 (let ((inhibit-read-only t))
3215 (article-narrow-to-head)
3216 (goto-char (point-min))
3217 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3218 (delete-region (match-beginning 1) (match-end 1)))))))
3220 (defun article-emphasize (&optional arg)
3221 "Emphasize text according to `gnus-emphasis-alist'."
3222 (interactive (gnus-article-hidden-arg))
3223 (unless (gnus-article-check-hidden-text 'emphasis arg)
3227 (with-current-buffer gnus-summary-buffer
3228 gnus-article-emphasis-alist)
3230 gnus-emphasis-alist))
3231 (inhibit-read-only t)
3232 (props (append '(article-type emphasis)
3233 gnus-hidden-properties))
3234 regexp elem beg invisible visible face)
3237 (while (setq elem (pop alist))
3239 (setq regexp (car elem)
3240 invisible (nth 1 elem)
3241 visible (nth 2 elem)
3243 (while (re-search-forward regexp nil t)
3244 (when (and (match-beginning visible) (match-beginning invisible))
3245 (gnus-article-hide-text
3246 (match-beginning invisible) (match-end invisible) props)
3247 (gnus-article-unhide-text-type
3248 (match-beginning visible) (match-end visible) 'emphasis)
3249 (gnus-put-overlay-excluding-newlines
3250 (match-beginning visible) (match-end visible) 'face face)
3251 (gnus-add-wash-type 'emphasis)
3252 (goto-char (match-end invisible)))))))))
3254 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3255 "Setup newsgroup emphasis alist."
3256 (unless gnus-article-emphasis-alist
3257 (let ((name (and gnus-newsgroup-name
3258 (gnus-group-real-name gnus-newsgroup-name))))
3259 (make-local-variable 'gnus-article-emphasis-alist)
3260 (setq gnus-article-emphasis-alist
3262 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3263 (while (setq elem (pop alist))
3264 (when (and name (string-match (car elem) name))
3266 highlight (copy-sequence (cdr elem)))))
3268 (copy-sequence highlight-words)
3269 (if gnus-newsgroup-name
3270 (copy-sequence (gnus-group-find-parameter
3271 gnus-newsgroup-name 'highlight-words t)))
3272 gnus-emphasis-alist)))))
3275 (defvar gnus-summary-article-menu)
3276 (defvar gnus-summary-post-menu))
3278 ;;; Saving functions.
3280 (defun gnus-article-save (save-buffer file &optional num)
3281 "Save the currently selected article."
3282 (unless gnus-save-all-headers
3283 ;; Remove headers according to `gnus-saved-headers'.
3284 (let ((gnus-visible-headers
3285 (or gnus-saved-headers gnus-visible-headers))
3286 (gnus-article-buffer save-buffer))
3288 (set-buffer save-buffer)
3289 (article-hide-headers 1 t))))
3290 (save-window-excursion
3291 (if (not gnus-default-article-saver)
3292 (error "No default saver is defined")
3293 ;; !!! Magic! The saving functions all save
3294 ;; `gnus-save-article-buffer' (or so they think), but we
3295 ;; bind that variable to our save-buffer.
3296 (set-buffer gnus-article-buffer)
3297 (let* ((gnus-save-article-buffer save-buffer)
3300 ((not gnus-prompt-before-saving) 'default)
3301 ((eq gnus-prompt-before-saving 'always) nil)
3303 (gnus-number-of-articles-to-be-saved
3304 (when (eq gnus-prompt-before-saving t)
3306 (set-buffer gnus-article-current-summary)
3307 (funcall gnus-default-article-saver filename)))))
3309 (defun gnus-read-save-file-name (prompt &optional filename
3310 function group headers variable)
3312 (funcall function group headers (symbol-value variable)))
3317 ((eq filename 'default)
3323 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3326 (if (and gnus-number-of-articles-to-be-saved
3327 (> gnus-number-of-articles-to-be-saved 1))
3328 (format "these %d articles"
3329 gnus-number-of-articles-to-be-saved)
3332 ;; Let the split methods have their say.
3334 ;; No split name was found.
3337 (concat prompt " (default "
3338 (file-name-nondirectory default-name) ") ")
3339 (file-name-directory default-name)
3341 ;; A single group name is returned.
3342 ((stringp split-name)
3344 (funcall function split-name headers
3345 (symbol-value variable)))
3347 (concat prompt " (default "
3348 (file-name-nondirectory default-name) ") ")
3349 (file-name-directory default-name)
3351 ;; A single split name was found
3352 ((= 1 (length split-name))
3353 (let* ((name (expand-file-name
3355 gnus-article-save-directory))
3356 (dir (cond ((file-directory-p name)
3357 (file-name-as-directory name))
3358 ((file-exists-p name) name)
3359 (t gnus-article-save-directory))))
3361 (concat prompt " (default " name ") ")
3363 ;; A list of splits was found.
3365 (setq split-name (nreverse split-name))
3367 (let ((file-name-history
3368 (nconc split-name file-name-history)))
3372 (concat prompt " (`M-p' for defaults) ")
3373 gnus-article-save-directory
3375 gnus-article-save-directory)))
3376 (car (push result file-name-history)))))))
3377 ;; Create the directory.
3378 (gnus-make-directory (file-name-directory file))
3379 ;; If we have read a directory, we append the default file name.
3380 (when (file-directory-p file)
3381 (setq file (expand-file-name (file-name-nondirectory
3383 (file-name-as-directory file))))
3384 ;; Possibly translate some characters.
3385 (nnheader-translate-file-chars file))))))
3386 (gnus-make-directory (file-name-directory result))
3387 (set variable result)))
3389 (defun gnus-article-archive-name (group)
3390 "Return the first instance of an \"Archive-name\" in the current buffer."
3391 (let ((case-fold-search t))
3392 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3393 (nnheader-concat gnus-article-save-directory
3394 (match-string 1)))))
3396 (defun gnus-article-nndoc-name (group)
3397 "If GROUP is an nndoc group, return the name of the parent group."
3398 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3399 (gnus-group-get-parameter group 'save-article-group)))
3401 (defun gnus-summary-save-in-rmail (&optional filename)
3402 "Append this article to Rmail file.
3403 Optional argument FILENAME specifies file name.
3404 Directory to save to is default to `gnus-article-save-directory'."
3405 (setq filename (gnus-read-save-file-name
3406 "Save %s in rmail file:" filename
3407 gnus-rmail-save-name gnus-newsgroup-name
3408 gnus-current-headers 'gnus-newsgroup-last-rmail))
3409 (gnus-eval-in-buffer-window gnus-save-article-buffer
3413 (gnus-output-to-rmail filename))))
3416 (defun gnus-summary-save-in-mail (&optional filename)
3417 "Append this article to Unix mail file.
3418 Optional argument FILENAME specifies file name.
3419 Directory to save to is default to `gnus-article-save-directory'."
3420 (setq filename (gnus-read-save-file-name
3421 "Save %s in Unix mail file:" filename
3422 gnus-mail-save-name gnus-newsgroup-name
3423 gnus-current-headers 'gnus-newsgroup-last-mail))
3424 (gnus-eval-in-buffer-window gnus-save-article-buffer
3428 (if (and (file-readable-p filename)
3429 (file-regular-p filename)
3430 (mail-file-babyl-p filename))
3431 (rmail-output-to-rmail-file filename t)
3432 (gnus-output-to-mail filename)))))
3435 (defun gnus-summary-save-in-file (&optional filename overwrite)
3436 "Append this article to file.
3437 Optional argument FILENAME specifies file name.
3438 Directory to save to is default to `gnus-article-save-directory'."
3439 (setq filename (gnus-read-save-file-name
3440 "Save %s in file:" filename
3441 gnus-file-save-name gnus-newsgroup-name
3442 gnus-current-headers 'gnus-newsgroup-last-file))
3443 (gnus-eval-in-buffer-window gnus-save-article-buffer
3447 (when (and overwrite
3448 (file-exists-p filename))
3449 (delete-file filename))
3450 (gnus-output-to-file filename))))
3453 (defun gnus-summary-write-to-file (&optional filename)
3454 "Write this article to a file, overwriting it if the file exists.
3455 Optional argument FILENAME specifies file name.
3456 The directory to save in defaults to `gnus-article-save-directory'."
3457 (gnus-summary-save-in-file nil t))
3459 (defun gnus-summary-save-body-in-file (&optional filename)
3460 "Append this article body to a file.
3461 Optional argument FILENAME specifies file name.
3462 The directory to save in defaults to `gnus-article-save-directory'."
3463 (setq filename (gnus-read-save-file-name
3464 "Save %s body in file:" filename
3465 gnus-file-save-name gnus-newsgroup-name
3466 gnus-current-headers 'gnus-newsgroup-last-file))
3467 (gnus-eval-in-buffer-window gnus-save-article-buffer
3471 (when (article-goto-body)
3472 (narrow-to-region (point) (point-max)))
3473 (gnus-output-to-file filename))))
3476 (defun gnus-summary-save-in-pipe (&optional command)
3477 "Pipe this article to subprocess."
3479 (cond ((and (eq command 'default)
3480 gnus-last-shell-command)
3481 gnus-last-shell-command)
3486 "Shell command on %s: "
3487 (if (and gnus-number-of-articles-to-be-saved
3488 (> gnus-number-of-articles-to-be-saved 1))
3489 (format "these %d articles"
3490 gnus-number-of-articles-to-be-saved)
3492 gnus-last-shell-command))))
3493 (when (string-equal command "")
3494 (if gnus-last-shell-command
3495 (setq command gnus-last-shell-command)
3496 (error "A command is required")))
3497 (gnus-eval-in-buffer-window gnus-article-buffer
3500 (shell-command-on-region (point-min) (point-max) command nil)))
3501 (setq gnus-last-shell-command command))
3503 (defun gnus-summary-pipe-to-muttprint (&optional command)
3504 "Pipe this article to muttprint."
3505 (setq command (read-string
3506 "Print using command: " gnus-summary-muttprint-program
3507 nil gnus-summary-muttprint-program))
3508 (gnus-summary-save-in-pipe command))
3510 ;;; Article file names when saving.
3512 (defun gnus-capitalize-newsgroup (newsgroup)
3513 "Capitalize NEWSGROUP name."
3514 (when (not (zerop (length newsgroup)))
3515 (concat (char-to-string (upcase (aref newsgroup 0)))
3516 (substring newsgroup 1))))
3518 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3519 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3520 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3521 Otherwise, it is like ~/News/news/group/num."
3524 (concat (if (gnus-use-long-file-name 'not-save)
3525 (gnus-capitalize-newsgroup newsgroup)
3526 (gnus-newsgroup-directory-form newsgroup))
3527 "/" (int-to-string (mail-header-number headers)))
3528 gnus-article-save-directory)))
3530 (string-equal (file-name-directory default)
3531 (file-name-directory last-file))
3532 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3534 (or last-file default))))
3536 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3537 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3538 If variable `gnus-use-long-file-name' is non-nil, it is
3539 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3542 (concat (if (gnus-use-long-file-name 'not-save)
3544 (gnus-newsgroup-directory-form newsgroup))
3545 "/" (int-to-string (mail-header-number headers)))
3546 gnus-article-save-directory)))
3548 (string-equal (file-name-directory default)
3549 (file-name-directory last-file))
3550 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3552 (or last-file default))))
3554 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3555 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3556 If variable `gnus-use-long-file-name' is non-nil, it is
3557 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3560 (if (gnus-use-long-file-name 'not-save)
3563 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3565 gnus-article-save-directory)))
3567 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3568 "Generate file name from sender."
3569 (let ((from (mail-header-from headers)))
3571 (if (and from (string-match "\\([^ <]+\\)@" from))
3572 (match-string 1 from)
3574 gnus-article-save-directory)))
3576 (defun article-verify-x-pgp-sig ()
3579 (if (gnus-buffer-live-p gnus-original-article-buffer)
3580 (let ((sig (with-current-buffer gnus-original-article-buffer
3581 (gnus-fetch-field "X-PGP-Sig")))
3585 (mml2015-clear-verify-function))
3587 (insert-buffer-substring gnus-original-article-buffer)
3588 (setq items (split-string sig))
3589 (message-narrow-to-head)
3590 (let ((inhibit-point-motion-hooks t)
3591 (case-fold-search t))
3592 ;; Don't verify multiple headers.
3593 (setq headers (mapconcat (lambda (header)
3595 (mail-fetch-field header)
3597 (split-string (nth 1 items) ",") "")))
3598 (delete-region (point-min) (point-max))
3599 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3600 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3605 (if (looking-at "^-")
3608 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3609 (insert "Version: " (car items) "\n\n")
3610 (insert (mapconcat 'identity (cddr items) "\n"))
3611 (insert "\n-----END PGP SIGNATURE-----\n")
3612 (let ((mm-security-handle (list (format "multipart/signed"))))
3613 (mml2015-clean-buffer)
3614 (let ((coding-system-for-write (or gnus-newsgroup-charset
3616 (funcall (mml2015-clear-verify-function)))
3618 (or (mm-handle-multipart-ctl-parameter
3619 mm-security-handle 'gnus-details)
3620 (mm-handle-multipart-ctl-parameter
3621 mm-security-handle 'gnus-info)))))
3623 (let ((inhibit-read-only t) bface eface)
3625 (message-narrow-to-head)
3626 (goto-char (point-max))
3628 (setq bface (get-text-property (point-at-bol) 'face)
3629 eface (get-text-property (1- (point-at-eol)) 'face))
3630 (message-remove-header "X-Gnus-PGP-Verify")
3631 (if (re-search-forward "^X-PGP-Sig:" nil t)
3633 (goto-char (point-max)))
3634 (narrow-to-region (point) (point))
3635 (insert "X-Gnus-PGP-Verify: " info "\n")
3636 (goto-char (point-min))
3639 (if (not (looking-at "^[ \t]"))
3643 (goto-char (point-min))
3644 (when (looking-at "\\([^:]+\\): *")
3645 (put-text-property (match-beginning 1) (1+ (match-end 1))
3647 (put-text-property (match-end 0) (point-max)
3648 'face eface)))))))))
3650 (defun article-verify-cancel-lock ()
3651 "Verify Cancel-Lock header."
3653 (if (gnus-buffer-live-p gnus-original-article-buffer)
3654 (canlock-verify gnus-original-article-buffer)))
3656 (defun article-monafy ()
3657 "Display body part with mona font."
3659 (unless (if (featurep 'xemacs)
3660 (find-face 'gnus-mona-face)
3661 (facep 'gnus-mona-face))
3662 (require 'navi2ch-mona)
3663 (set-face-font (make-face 'gnus-mona-face) navi2ch-mona-font))
3665 (let ((inhibit-read-only t))
3668 (gnus-make-overlay (point) (point-max))
3669 'face 'gnus-mona-face))))
3676 (setq afunc (car func)
3679 gfunc (intern (format "gnus-%s" func))))
3681 (when (fboundp afunc)
3682 `(lambda (&optional interactive &rest args)
3683 ,(documentation afunc t)
3684 (interactive (list t))
3686 (set-buffer gnus-article-buffer)
3688 (call-interactively ',afunc)
3689 (apply ',afunc args))))))))
3690 '(article-hide-headers
3691 article-verify-x-pgp-sig
3692 article-verify-cancel-lock
3694 article-hide-boring-headers
3695 article-treat-overstrike
3696 article-treat-ansi-sequences
3697 article-fill-long-lines
3698 article-capitalize-sentences
3700 article-remove-leading-whitespace
3701 article-display-x-face
3702 article-display-face
3703 article-de-quoted-unreadable
3704 article-de-base64-unreadable
3707 article-unsplit-urls
3708 article-hide-list-identifiers
3709 article-strip-banner
3712 article-hide-signature
3713 article-strip-headers-in-body
3714 article-remove-trailing-blank-lines
3715 article-strip-leading-blank-lines
3716 article-strip-multiple-blank-lines
3717 article-strip-leading-space
3718 article-strip-trailing-space
3719 article-strip-blank-lines
3720 article-strip-all-blank-lines
3722 article-date-english
3723 article-date-iso8601
3724 article-date-original
3726 article-decode-mime-words
3727 article-decode-charset
3728 article-decode-encoded-words
3732 article-treat-dumbquotes
3733 article-normalize-headers
3734 (article-show-all-headers . gnus-article-show-all-headers)
3735 ;; (article-show-all . gnus-article-show-all)
3739 ;;; Gnus article mode
3742 (put 'gnus-article-mode 'mode-class 'special)
3744 (gnus-define-keys gnus-article-mode-map
3745 " " gnus-article-goto-next-page
3746 "\177" gnus-article-goto-prev-page
3747 [delete] gnus-article-goto-prev-page
3748 [backspace] gnus-article-goto-prev-page
3749 "\C-c^" gnus-article-refer-article
3750 "h" gnus-article-show-summary
3751 "s" gnus-article-show-summary
3752 "\C-c\C-m" gnus-article-mail
3753 "?" gnus-article-describe-briefly
3754 "e" gnus-summary-edit-article
3755 "<" beginning-of-buffer
3757 "\C-c\C-i" gnus-info-find-node
3759 "R" gnus-article-reply-with-original
3760 "F" gnus-article-followup-with-original
3761 "\C-hk" gnus-article-describe-key
3762 "\C-hc" gnus-article-describe-key-briefly
3764 "\C-d" gnus-article-read-summary-keys
3765 "\M-*" gnus-article-read-summary-keys
3766 "\M-#" gnus-article-read-summary-keys
3767 "\M-^" gnus-article-read-summary-keys
3768 "\M-g" gnus-article-read-summary-keys)
3770 ;; Define almost undefined keys to `gnus-article-read-summary-keys'.
3774 (push (char-to-string key) keys)
3776 (dolist (elem (accessible-keymaps gnus-summary-mode-map))
3777 (setq key (car elem))
3778 (when (and (> (length key) 0)
3779 (not (eq 'menu-bar (aref key 0)))
3780 (symbolp (lookup-key gnus-summary-mode-map key)))
3783 (unless (lookup-key gnus-article-mode-map key)
3784 (define-key gnus-article-mode-map key 'gnus-article-read-summary-keys))))
3786 (defun gnus-article-make-menu-bar ()
3787 (unless (boundp 'gnus-article-commands-menu)
3788 (gnus-summary-make-menu-bar))
3789 (gnus-turn-off-edit-menu 'article)
3790 (unless (boundp 'gnus-article-article-menu)
3792 gnus-article-article-menu gnus-article-mode-map ""
3794 ["Scroll forwards" gnus-article-goto-next-page t]
3795 ["Scroll backwards" gnus-article-goto-prev-page t]
3796 ["Show summary" gnus-article-show-summary t]
3797 ["Fetch Message-ID at point" gnus-article-refer-article t]
3798 ["Mail to address at point" gnus-article-mail t]
3799 ["Send a bug report" gnus-bug t]))
3802 gnus-article-treatment-menu gnus-article-mode-map ""
3803 ;; Fixme: this should use :active (and maybe :visible).
3805 ["Hide headers" gnus-article-hide-headers t]
3806 ["Hide signature" gnus-article-hide-signature t]
3807 ["Hide citation" gnus-article-hide-citation t]
3808 ["Treat overstrike" gnus-article-treat-overstrike t]
3809 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
3810 ["Remove carriage return" gnus-article-remove-cr t]
3811 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3812 ["Treat html" gnus-article-wash-html t]
3813 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3814 ["Decode HZ" gnus-article-decode-HZ t]))
3816 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3818 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3820 (gnus-run-hooks 'gnus-article-menu-hook)))
3822 (defun gnus-article-mode ()
3823 "Major mode for displaying an article.
3825 All normal editing commands are switched off.
3827 The following commands are available in addition to all summary mode
3829 \\<gnus-article-mode-map>
3830 \\[gnus-article-next-page]\t Scroll the article one page forwards
3831 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3832 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3833 \\[gnus-article-show-summary]\t Display the summary buffer
3834 \\[gnus-article-mail]\t Send a reply to the address near point
3835 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3836 \\[gnus-info-find-node]\t Go to the Gnus info node"
3838 (gnus-simplify-mode-line)
3839 (setq mode-name "Article")
3840 (setq major-mode 'gnus-article-mode)
3841 (make-local-variable 'minor-mode-alist)
3842 (unless (assq 'gnus-show-mime minor-mode-alist)
3843 (push (list 'gnus-show-mime " MIME") minor-mode-alist))
3844 (use-local-map gnus-article-mode-map)
3845 (when (gnus-visual-p 'article-menu 'menu)
3846 (gnus-article-make-menu-bar)
3847 (when gnus-summary-tool-bar-map
3848 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3849 (gnus-update-format-specifications nil 'article-mode)
3850 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3851 (set (make-local-variable 'gnus-page-broken) nil)
3852 (make-local-variable 'gnus-button-marker-list)
3853 (make-local-variable 'gnus-article-current-summary)
3854 (make-local-variable 'gnus-article-mime-handles)
3855 (make-local-variable 'gnus-article-decoded-p)
3856 (make-local-variable 'gnus-article-mime-handle-alist)
3857 (make-local-variable 'gnus-article-wash-types)
3858 (make-local-variable 'gnus-article-image-alist)
3859 (make-local-variable 'gnus-article-charset)
3860 (make-local-variable 'gnus-article-ignored-charsets)
3861 (gnus-set-default-directory)
3862 (buffer-disable-undo)
3863 (setq buffer-read-only t
3864 show-trailing-whitespace nil)
3865 (set-syntax-table gnus-article-mode-syntax-table)
3866 (gnus-run-hooks 'gnus-article-mode-hook))
3868 (defun gnus-article-setup-buffer ()
3869 "Initialize the article buffer."
3870 (let* ((name (if gnus-single-article-buffer "*Article*"
3871 (concat "*Article " gnus-newsgroup-name "*")))
3873 (progn (string-match "\\*Article" name)
3874 (concat " *Original Article"
3875 (substring name (match-end 0))))))
3876 (setq gnus-article-buffer name)
3877 (setq gnus-original-article-buffer original)
3878 (setq gnus-article-mime-handle-alist nil)
3879 ;; This might be a variable local to the summary buffer.
3880 (unless gnus-single-article-buffer
3882 (set-buffer gnus-summary-buffer)
3883 (setq gnus-article-buffer name)
3884 (setq gnus-original-article-buffer original)
3885 (gnus-set-global-variables)))
3886 (gnus-article-setup-highlight-words)
3887 ;; Init original article buffer.
3889 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3890 (set-buffer-multibyte t)
3891 (setq major-mode 'gnus-original-article-mode)
3892 (make-local-variable 'gnus-original-article))
3893 (if (get-buffer name)
3896 (when (and gnus-article-edit-mode
3899 (y-or-n-p "Article mode edit in progress; discard? ")))
3900 (error "Action aborted"))
3901 (set (make-local-variable 'gnus-article-edit-mode) nil)
3902 (buffer-disable-undo)
3903 (setq buffer-read-only t)
3904 ;; This list just keeps growing if we don't reset it.
3905 (setq gnus-button-marker-list nil)
3906 (unless (eq major-mode 'gnus-article-mode)
3907 (gnus-article-mode))
3910 (set-buffer (gnus-get-buffer-create name))
3912 (make-local-variable 'gnus-summary-buffer)
3913 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3914 (current-buffer)))))
3916 ;; Set article window start at LINE, where LINE is the number of lines
3917 ;; from the head of the article.
3918 (defun gnus-article-set-window-start (&optional line)
3920 (gnus-get-buffer-window gnus-article-buffer t)
3922 (set-buffer gnus-article-buffer)
3923 (goto-char (point-min))
3926 (gnus-message 6 "Moved to bookmark")
3927 (search-forward "\n\n" nil t)
3931 ;;; @@ article filters
3934 (defun gnus-article-display-mime-message ()
3935 "Article display method for MIME message."
3936 ;; called from `gnus-original-article-buffer'.
3937 (let (charset all-headers)
3938 (with-current-buffer gnus-summary-buffer
3939 (setq charset default-mime-charset
3940 all-headers gnus-have-all-headers))
3941 (make-local-variable 'default-mime-charset)
3942 (setq default-mime-charset charset)
3943 (with-current-buffer (get-buffer-create gnus-article-buffer)
3944 (make-local-variable 'default-mime-charset)
3945 (setq default-mime-charset charset))
3946 (mime-display-message mime-message-structure
3947 gnus-article-buffer nil gnus-article-mode-map)
3949 (gnus-article-hide-headers nil -1)))
3950 (run-hooks 'gnus-mime-article-prepare-hook))
3952 (defun gnus-article-display-traditional-message ()
3953 "Article display method for traditional message."
3954 (set-buffer gnus-article-buffer)
3955 (let ((inhibit-read-only t))
3957 (insert-buffer-substring gnus-original-article-buffer)))
3959 (defun gnus-article-make-full-mail-header (&optional number charset)
3960 "Create a new mail header structure in a raw article buffer."
3961 (unless (and number charset)
3962 (save-current-buffer
3963 (set-buffer gnus-summary-buffer)
3965 (setq number (or (cdr gnus-article-current) 0)))
3967 (setq charset (or default-mime-charset 'x-ctext)))))
3968 (goto-char (point-min))
3969 (let ((header-end (if (search-forward "\n\n" nil t)
3971 (goto-char (point-max))))
3972 (chars (- (point-max) (point)))
3973 (lines (count-lines (point) (point-max)))
3974 (default-mime-charset charset)
3976 (narrow-to-region (point-min) header-end)
3977 (setq xref (std11-fetch-field "xref"))
3979 (make-full-mail-header
3981 (std11-fetch-field "subject")
3982 (std11-fetch-field "from")
3983 (std11-fetch-field "date")
3984 (std11-fetch-field "message-id")
3985 (std11-fetch-field "references")
3988 (when xref (concat "Xref: " xref)))
3991 (defun gnus-article-prepare (article &optional all-headers header)
3992 "Prepare ARTICLE in article mode buffer.
3993 ARTICLE should either be an article number or a Message-ID.
3994 If ARTICLE is an id, HEADER should be the article headers.
3995 If ALL-HEADERS is non-nil, no headers are hidden."
3997 ;; Make sure we start in a summary buffer.
3998 (unless (eq major-mode 'gnus-summary-mode)
3999 (set-buffer gnus-summary-buffer))
4000 (setq gnus-summary-buffer (current-buffer))
4001 (let* ((gnus-article (if header (mail-header-number header) article))
4002 (summary-buffer (current-buffer))
4003 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
4004 (group gnus-newsgroup-name)
4007 (gnus-article-setup-buffer)
4008 (set-buffer gnus-article-buffer)
4009 ;; Deactivate active regions.
4010 (when (and (boundp 'transient-mark-mode)
4011 transient-mark-mode)
4012 (setq mark-active nil))
4013 (if (not (setq result (let ((inhibit-read-only t))
4014 (gnus-request-article-this-buffer
4016 ;; There is no such article.
4018 (when (and (numberp article)
4019 (not (memq article gnus-newsgroup-sparse)))
4020 (setq gnus-article-current
4021 (cons gnus-newsgroup-name article))
4022 (set-buffer gnus-summary-buffer)
4023 (setq gnus-current-article article)
4024 (if (and (memq article gnus-newsgroup-undownloaded)
4025 (not (gnus-online (gnus-find-method-for-group
4026 gnus-newsgroup-name))))
4028 (gnus-summary-set-agent-mark article)
4029 (message "Message marked for downloading"))
4030 (gnus-summary-mark-article article gnus-canceled-mark)
4031 (unless (memq article gnus-newsgroup-sparse)
4032 (gnus-error 1 "No such article (may have expired or been canceled)")))))
4033 (if (or (eq result 'pseudo)
4034 (eq result 'nneething))
4037 (set-buffer summary-buffer)
4038 (push article gnus-newsgroup-history)
4039 (setq gnus-last-article gnus-current-article
4040 gnus-current-article 0
4041 gnus-current-headers nil
4042 gnus-article-current nil)
4043 (if (eq result 'nneething)
4044 (gnus-configure-windows 'summary)
4045 (gnus-configure-windows 'article))
4046 (gnus-set-global-variables))
4047 (let ((gnus-article-mime-handle-alist-1
4048 gnus-article-mime-handle-alist))
4049 (gnus-set-mode-line 'article)))
4050 ;; The result from the `request' was an actual article -
4051 ;; or at least some text that is now displayed in the
4053 (when (and (numberp article)
4054 (not (eq article gnus-current-article)))
4055 ;; Seems like a new article has been selected.
4056 ;; `gnus-current-article' must be an article number.
4058 (set-buffer summary-buffer)
4059 (push article gnus-newsgroup-history)
4060 (setq gnus-last-article gnus-current-article
4061 gnus-current-article article
4062 gnus-current-headers
4063 (gnus-summary-article-header gnus-current-article)
4064 gnus-article-current
4065 (cons gnus-newsgroup-name gnus-current-article))
4066 (unless (vectorp gnus-current-headers)
4067 (setq gnus-current-headers nil))
4068 (gnus-summary-goto-subject gnus-current-article)
4069 (when (gnus-summary-show-thread)
4070 ;; If the summary buffer really was folded, the
4071 ;; previous goto may not actually have gone to
4072 ;; the right article, but the thread root instead.
4074 (gnus-summary-goto-subject gnus-current-article))
4075 (gnus-run-hooks 'gnus-mark-article-hook)
4076 (gnus-set-mode-line 'summary)
4077 (when (gnus-visual-p 'article-highlight 'highlight)
4078 (gnus-run-hooks 'gnus-visual-mark-article-hook))
4079 ;; Set the global newsgroup variables here.
4080 (gnus-set-global-variables)
4081 (setq gnus-have-all-headers
4082 (or all-headers gnus-show-all-headers))))
4084 (gnus-configure-windows 'article))
4085 (when (or (numberp article)
4087 (gnus-article-prepare-display)
4089 (goto-char (point-min))
4090 (when gnus-break-pages
4091 (gnus-narrow-to-page)))
4092 (let ((gnus-article-mime-handle-alist-1
4093 gnus-article-mime-handle-alist))
4094 (gnus-set-mode-line 'article))
4098 (set-window-point (get-buffer-window (current-buffer)) (point))
4099 (gnus-configure-windows 'article)
4102 (defun gnus-article-prepare-mime-display (&optional number)
4103 (goto-char (point-min))
4104 (when (re-search-forward "^[^\t ]+:" nil t)
4105 (goto-char (match-beginning 0)))
4106 (let ((entity (if (eq 1 (point-min))
4107 (get-text-property 1 'mime-view-entity)
4108 (get-text-property (point) 'mime-view-entity)))
4109 last-entity child-entity next type)
4110 (setq child-entity (mime-entity-children entity))
4112 (setq last-entity (nth (1- (length child-entity))
4114 (setq last-entity entity))
4116 (narrow-to-region (point)
4117 (if (search-forward "\n\n" nil t)
4120 (gnus-treat-article 'head)
4121 (put-text-property (point-min) (point-max) 'article-treated-header t)
4122 (goto-char (point-max)))
4123 (while (and (not (eobp)) entity)
4124 (setq next (set-marker
4126 (next-single-property-change (point) 'mime-view-entity
4128 (let ((types (mime-entity-content-type entity)))
4129 (while (eq 'multipart (mime-content-type-primary-type types))
4130 (setq entity (car (mime-entity-children entity))
4131 types (mime-entity-content-type entity)))
4133 (setq type (format "%s/%s"
4134 (mime-content-type-primary-type types)
4135 (mime-content-type-subtype types)))))
4136 (if (string-equal type "message/rfc822")
4139 (let ((children (mime-entity-children entity))
4142 (setq last-children (nth (1- (length children)) children))
4145 (not (eq last-children
4146 (get-text-property next 'mime-view-entity)))
4148 (next-single-property-change next
4150 nil (point-max)))))))
4151 (setq next (next-single-property-change next 'mime-view-entity
4154 (narrow-to-region (point) next)
4155 (gnus-article-prepare-mime-display)
4156 (goto-char (point-max)))
4157 (setq entity (get-text-property (point) 'mime-view-entity)))
4159 (narrow-to-region (point) next)
4160 ;; Kludge. We have to count true number, but for now,
4161 ;; part number is here only to achieve `last'.
4162 (gnus-treat-article nil 1
4163 (if (eq entity last-entity)
4166 (goto-char (point-max)))
4167 (setq entity (get-text-property next 'mime-view-entity))))))
4170 (defun gnus-article-prepare-display ()
4171 "Make the current buffer look like a nice article."
4172 (let ((gnus-article-buffer (current-buffer))
4174 (inhibit-read-only t))
4175 (unless (eq major-mode 'gnus-article-mode)
4176 (gnus-article-mode))
4177 (setq buffer-read-only nil
4178 gnus-button-marker-list nil
4179 gnus-article-wash-types nil
4180 gnus-article-image-alist nil)
4183 (static-if (featurep 'xemacs)
4184 (map-extents (lambda (extent maparg) (delete-extent extent)))
4185 (let ((lists (overlay-lists)))
4186 (dolist (overlay (nconc (car lists) (cdr lists)))
4187 (delete-overlay overlay)))))
4188 (gnus-run-hooks 'gnus-tmp-internal-hook))
4189 (let ((show-mime (unless (member gnus-newsgroup-name '("nndraft:delayed"
4192 (inhibit-read-only t))
4193 (set-buffer gnus-original-article-buffer)
4195 (setq mime-message-structure gnus-current-headers)
4196 (mime-buffer-entity-set-buffer-internal mime-message-structure
4197 gnus-original-article-buffer)
4198 (mime-entity-set-representation-type-internal mime-message-structure
4199 'mime-buffer-entity)
4200 (luna-send mime-message-structure 'initialize-instance
4201 mime-message-structure)
4203 (let (mime-display-header-hook mime-display-text/plain-hook)
4204 (funcall gnus-article-display-method-for-mime))
4205 (funcall gnus-article-display-method-for-traditional))
4206 ;; Call the treatment functions.
4210 (gnus-article-prepare-mime-display)
4211 (narrow-to-region (goto-char (point-min))
4212 (if (search-forward "\n\n" nil t)
4215 (gnus-treat-article 'head)
4216 (put-text-property (point-min) (point-max) 'article-treated-header t)
4217 (goto-char (point-max))
4219 (narrow-to-region (point) (point-max))
4220 (gnus-treat-article nil))
4221 (put-text-property (point-min) (point-max) 'read-only nil)))
4222 (gnus-run-hooks 'gnus-article-prepare-hook))
4224 (defun gnus-article-decode-article-as-default-mime-charset ()
4225 "Decode an article as `default-mime-charset'. It won't work if the
4226 value of the variable `gnus-show-mime' is non-nil."
4227 (unless (or gnus-show-mime
4228 (member gnus-newsgroup-name '("nndraft:delayed"
4230 (set (make-local-variable 'default-mime-charset)
4231 (with-current-buffer gnus-summary-buffer
4232 default-mime-charset))
4233 (decode-mime-charset-region (point-min) (point-max)
4234 default-mime-charset)))
4237 ;;; Gnus MIME viewing functions
4240 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4241 "Format of the MIME buttons.
4243 Valid specifiers include:
4245 %T MIME type, along with additional info
4246 %n The `name' parameter
4247 %d The description, if any
4248 %l The length of the encoded part
4249 %p The part identifier number
4250 %e Dots if the part isn't displayed
4252 General format specifiers can also be used. See Info node
4253 `(gnus)Formatting Variables'.")
4255 (defvar gnus-mime-button-line-format-alist
4256 '((?t gnus-tmp-type ?s)
4257 (?T gnus-tmp-type-long ?s)
4258 (?n gnus-tmp-name ?s)
4259 (?d gnus-tmp-description ?s)
4261 (?l gnus-tmp-length ?d)
4262 (?e gnus-tmp-dots ?s)))
4264 (defvar gnus-mime-button-commands
4265 '((gnus-article-press-button "\r" "Toggle Display")
4266 (gnus-mime-view-part "v" "View Interactively...")
4267 (gnus-mime-view-part-as-type "t" "View As Type...")
4268 (gnus-mime-view-part-as-charset "C" "View As charset...")
4269 (gnus-mime-save-part "o" "Save...")
4270 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4271 (gnus-mime-delete-part "d" "Delete part")
4272 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4273 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4274 (gnus-mime-view-part-internally "E" "View Internally")
4275 (gnus-mime-view-part-externally "e" "View Externally")
4276 (gnus-mime-print-part "p" "Print")
4277 (gnus-mime-pipe-part "|" "Pipe To Command...")
4278 (gnus-mime-action-on-part "." "Take action on the part...")))
4280 (defun gnus-article-mime-part-status ()
4281 (with-current-buffer gnus-article-buffer
4282 (let ((entity (get-text-property (point-min) 'mime-view-entity))
4285 (setq children (mime-entity-children entity))
4286 (setq children (length children)))
4289 (format " (%d parts)" children))
4292 (defvar gnus-mime-button-map
4293 (let ((map (make-sparse-keymap)))
4294 (define-key map gnus-mouse-2 'gnus-article-push-button)
4295 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4296 (dolist (c gnus-mime-button-commands)
4297 (define-key map (cadr c) (car c)))
4301 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4303 ,@(mapcar (lambda (c)
4304 (vector (caddr c) (car c) :enable t))
4305 gnus-mime-button-commands)))
4307 (defun gnus-mime-button-menu (event prefix)
4308 "Construct a context-sensitive menu of MIME commands."
4309 (interactive "e\nP")
4310 (save-window-excursion
4311 (let ((pos (event-start event)))
4312 (select-window (posn-window pos))
4313 (goto-char (posn-point pos))
4314 (gnus-article-check-buffer)
4315 (popup-menu gnus-mime-button-menu nil prefix))))
4317 (defun gnus-mime-view-all-parts (&optional handles)
4318 "View all the MIME parts."
4320 (with-current-buffer gnus-article-buffer
4321 (let ((handles (or handles gnus-article-mime-handles))
4322 (mail-parse-charset gnus-newsgroup-charset)
4323 (mail-parse-ignored-charsets
4324 (with-current-buffer gnus-summary-buffer
4325 gnus-newsgroup-ignored-charsets)))
4327 (mm-remove-parts handles)
4328 (goto-char (point-min))
4329 (or (search-forward "\n\n") (goto-char (point-max)))
4330 (let ((inhibit-read-only t))
4331 (delete-region (point) (point-max))
4332 (mm-display-parts handles))))))
4335 (defsubst gnus-article-edit-part (handles)
4336 "Edit an article in order to delete a mime part.
4337 This function is exclusively used by `gnus-mime-save-part-and-strip'
4338 and `gnus-mime-delete-part', and not provided at run-time normally."
4339 (gnus-article-edit-article
4342 (let ((mail-parse-charset (or gnus-article-charset
4343 ',gnus-newsgroup-charset))
4344 (mail-parse-ignored-charsets
4345 (or gnus-article-ignored-charsets
4346 ',gnus-newsgroup-ignored-charsets))
4347 (mbl mml-buffer-list))
4348 (setq mml-buffer-list nil)
4349 (insert-buffer gnus-original-article-buffer)
4350 (mime-to-mml ',handles)
4351 (setq gnus-article-mime-handles nil)
4352 (let ((mbl1 mml-buffer-list))
4353 (setq mml-buffer-list mbl)
4354 (set (make-local-variable 'mml-buffer-list) mbl1))
4355 (gnus-make-local-hook 'kill-buffer-hook)
4356 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4357 `(lambda (no-highlight)
4358 (let ((mail-parse-charset (or gnus-article-charset
4359 ',gnus-newsgroup-charset))
4360 (message-options message-options)
4361 (message-options-set-recipient)
4362 (mail-parse-ignored-charsets
4363 (or gnus-article-ignored-charsets
4364 ',gnus-newsgroup-ignored-charsets)))
4366 (mml-destroy-buffers)
4367 (remove-hook 'kill-buffer-hook
4368 'mml-destroy-buffers t)
4369 (kill-local-variable 'mml-buffer-list))
4370 (gnus-summary-edit-article-done
4371 ,(or (mail-header-references gnus-current-headers) "")
4372 ,(gnus-group-read-only-p)
4373 ,gnus-summary-buffer no-highlight)))
4374 (gnus-article-edit-done)
4375 (gnus-summary-expand-window)
4376 (gnus-summary-show-article)))
4378 (defun gnus-mime-save-part-and-strip ()
4379 "Save the MIME part under point then replace it with an external body."
4381 (gnus-article-check-buffer)
4382 (when (gnus-group-read-only-p)
4383 (error "The current group does not support deleting of parts"))
4384 (when (mm-complicated-handles gnus-article-mime-handles)
4386 The current article has a complicated MIME structure, giving up..."))
4387 (when (gnus-yes-or-no-p "\
4388 Deleting parts may malfunction or destroy the article; continue? ")
4389 (let* ((data (get-text-property (point) 'gnus-data))
4391 (handles gnus-article-mime-handles))
4392 (setq file (and data (mm-save-part data)))
4394 (with-current-buffer (mm-handle-buffer data)
4396 (insert "Content-Type: " (mm-handle-media-type data))
4397 (mml-insert-parameter-string (cdr (mm-handle-type data))
4400 (insert "Content-ID: " (message-make-message-id) "\n")
4401 (insert "Content-Transfer-Encoding: binary\n")
4404 (cdr (mm-make-handle nil
4405 `("message/external-body"
4406 (access-type . "LOCAL-FILE")
4408 (set-buffer gnus-summary-buffer)
4409 (gnus-article-edit-part handles)))))
4411 (defun gnus-mime-delete-part ()
4412 "Delete the MIME part under point.
4413 Replace it with some information about the removed part."
4415 (gnus-article-check-buffer)
4416 (when (gnus-group-read-only-p)
4417 (error "The current group does not support deleting of parts"))
4418 (when (mm-complicated-handles gnus-article-mime-handles)
4420 The current article has a complicated MIME structure, giving up..."))
4421 (when (gnus-yes-or-no-p "\
4422 Deleting parts may malfunction or destroy the article; continue? ")
4423 (let* ((data (get-text-property (point) 'gnus-data))
4424 (handles gnus-article-mime-handles)
4428 (mail-decode-encoded-word-string (or (mm-handle-description data)
4431 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4433 (type (mm-handle-media-type data)))
4435 (error "No MIME part under point"))
4436 (with-current-buffer (mm-handle-buffer data)
4437 (let ((bsize (format "%s" (buffer-size))))
4442 "| The following attachment has been deleted:\n"
4444 "| Type: " type "\n"
4445 "| Filename: " filename "\n"
4446 "| Size (encoded): " bsize " Byte\n"
4447 "| Description: " description "\n"
4450 (cdr (mm-make-handle
4451 nil `("text/plain") nil nil
4453 (format "Deleted attachment (%s bytes)" bsize))))))
4454 (set-buffer gnus-summary-buffer)
4455 (gnus-article-edit-part handles))))
4457 (defun gnus-mime-save-part ()
4458 "Save the MIME part under point."
4460 (gnus-article-check-buffer)
4461 (let ((data (get-text-property (point) 'gnus-data)))
4463 (mm-save-part data))))
4465 (defun gnus-mime-pipe-part ()
4466 "Pipe the MIME part under point to a process."
4468 (gnus-article-check-buffer)
4469 (let ((data (get-text-property (point) 'gnus-data)))
4471 (mm-pipe-part data))))
4473 (defun gnus-mime-view-part ()
4474 "Interactively choose a viewing method for the MIME part under point."
4476 (gnus-article-check-buffer)
4477 (let ((data (get-text-property (point) 'gnus-data)))
4479 (setq gnus-article-mime-handles
4481 gnus-article-mime-handles (setq data (copy-sequence data))))
4482 (mm-interactively-view-part data))))
4484 (defun gnus-mime-view-part-as-type-internal ()
4485 (gnus-article-check-buffer)
4486 (let* ((name (mail-content-type-get
4487 (mm-handle-type (get-text-property (point) 'gnus-data))
4489 (def-type (and name (mm-default-file-encoding name))))
4490 (and def-type (cons def-type 0))))
4492 (defun gnus-mime-view-part-as-type (&optional mime-type)
4493 "Choose a MIME media type, and view the part as such."
4496 (setq mime-type (completing-read
4497 "View as MIME type: "
4498 (mapcar #'list (mailcap-mime-types))
4500 (gnus-mime-view-part-as-type-internal))))
4501 (gnus-article-check-buffer)
4502 (let ((handle (get-text-property (point) 'gnus-data)))
4505 (mm-make-handle (mm-handle-buffer handle)
4506 (cons mime-type (cdr (mm-handle-type handle)))
4507 (mm-handle-encoding handle)
4508 (mm-handle-undisplayer handle)
4509 (mm-handle-disposition handle)
4510 (mm-handle-description handle)
4512 (mm-handle-id handle)))
4513 (setq gnus-article-mime-handles
4514 (mm-merge-handles gnus-article-mime-handles handle))
4515 (gnus-mm-display-part handle))))
4518 (require 'jka-compr))
4520 ;; jka-compr.el uses a "sh -c" to direct stderr to err-file, but these days
4521 ;; emacs can do that itself.
4523 (defun gnus-mime-jka-compr-maybe-uncompress ()
4524 "Uncompress the current buffer if `auto-compression-mode' is enabled.
4525 The uncompress method used is derived from `buffer-file-name'."
4526 (when (and (fboundp 'jka-compr-installed-p)
4527 (jka-compr-installed-p))
4528 (let ((info (jka-compr-get-compression-info buffer-file-name)))
4530 (let ((basename (file-name-nondirectory buffer-file-name))
4531 (args (jka-compr-info-uncompress-args info))
4532 (prog (jka-compr-info-uncompress-program info))
4533 (message (jka-compr-info-uncompress-message info))
4534 (err-file (jka-compr-make-temp-name)))
4536 (message "%s %s..." message basename))
4538 (unless (memq (apply 'call-process-region
4539 (point-min) (point-max)
4541 t (list t err-file) nil
4543 jka-compr-acceptable-retval-list)
4544 (jka-compr-error prog args basename message err-file))
4545 (jka-compr-delete-temp-file err-file)))))))
4547 (defun gnus-mime-copy-part (&optional handle)
4548 "Put the MIME part under point into a new buffer.
4549 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4552 (gnus-article-check-buffer)
4553 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4554 (contents (and handle (mm-get-part handle)))
4556 (file-name-nondirectory
4558 (mail-content-type-get (mm-handle-type handle) 'name)
4559 (mail-content-type-get (mm-handle-disposition handle)
4562 (buffer (and base (generate-new-buffer base))))
4564 (switch-to-buffer buffer)
4566 ;; We do it this way to make `normal-mode' set the appropriate mode.
4569 (setq buffer-file-name (expand-file-name base))
4570 (gnus-mime-jka-compr-maybe-uncompress)
4572 (setq buffer-file-name nil))
4573 (goto-char (point-min)))))
4575 (defun gnus-mime-print-part (&optional handle filename)
4576 "Print the MIME part under point."
4577 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4578 (gnus-article-check-buffer)
4579 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4580 (contents (and handle (mm-get-part handle)))
4581 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4582 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4587 (mm-save-part-to-file handle file)
4588 (call-process shell-file-name nil
4589 (generate-new-buffer " *mm*")
4591 shell-command-switch
4593 printer file (mm-handle-type handle))))
4597 (gnus-print-buffer))
4598 (ps-despool filename)))))
4600 (defun gnus-mime-inline-part (&optional handle arg)
4601 "Insert the MIME part under point into the current buffer."
4602 (interactive (list nil current-prefix-arg))
4603 (gnus-article-check-buffer)
4604 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4607 (inhibit-read-only t))
4609 (if (and (not arg) (mm-handle-undisplayer handle))
4610 (mm-remove-part handle)
4611 (setq contents (mm-get-part handle))
4614 (setq charset (or (mail-content-type-get
4615 (mm-handle-type handle) 'charset)
4616 gnus-newsgroup-charset)))
4618 (if (mm-handle-undisplayer handle)
4619 (mm-remove-part handle))
4622 gnus-summary-show-article-charset-alist))
4623 (mm-read-coding-system "Charset: ")))))
4625 (mm-insert-inline handle
4627 (setq charset (mm-charset-to-coding-system
4629 (not (eq charset 'ascii)))
4630 (mm-decode-coding-string contents charset)
4634 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4635 "Insert the MIME part under point into the current buffer using the
4637 (interactive (list nil current-prefix-arg))
4638 (gnus-article-check-buffer)
4639 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4642 (inhibit-read-only t))
4644 (if (mm-handle-undisplayer handle)
4645 (mm-remove-part handle))
4646 (let ((gnus-newsgroup-charset
4648 gnus-summary-show-article-charset-alist))
4649 (mm-read-coding-system "Charset: ")))
4650 (gnus-newsgroup-ignored-charsets 'gnus-all))
4651 (gnus-article-press-button)))))
4653 (defun gnus-mime-view-part-externally (&optional handle)
4654 "View the MIME part under point with an external viewer."
4656 (gnus-article-check-buffer)
4657 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4658 (mm-user-display-methods nil)
4659 (mm-inlined-types nil)
4660 (mail-parse-charset gnus-newsgroup-charset)
4661 (mail-parse-ignored-charsets
4662 (with-current-buffer gnus-summary-buffer
4663 gnus-newsgroup-ignored-charsets)))
4665 (if (mm-handle-undisplayer handle)
4666 (mm-remove-part handle)
4667 (mm-display-part handle)))))
4669 (defun gnus-mime-view-part-internally (&optional handle)
4670 "View the MIME part under point with an internal viewer.
4671 If no internal viewer is available, use an external viewer."
4673 (gnus-article-check-buffer)
4674 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4675 (mm-inlined-types '(".*"))
4676 (mm-inline-large-images t)
4677 (mail-parse-charset gnus-newsgroup-charset)
4678 (mail-parse-ignored-charsets
4679 (with-current-buffer gnus-summary-buffer
4680 gnus-newsgroup-ignored-charsets))
4681 (inhibit-read-only t))
4683 (if (mm-handle-undisplayer handle)
4684 (mm-remove-part handle)
4685 (mm-display-part handle)))))
4687 (defun gnus-mime-action-on-part (&optional action)
4688 "Do something with the MIME attachment at \(point\)."
4690 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4691 (gnus-article-check-buffer)
4692 (let ((action-pair (assoc action gnus-mime-action-alist)))
4694 (funcall (cdr action-pair)))))
4696 (defun gnus-article-part-wrapper (n function)
4697 (with-current-buffer gnus-article-buffer
4698 (when (> n (length gnus-article-mime-handle-alist))
4699 (error "No such part"))
4700 (gnus-article-goto-part n)
4701 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4702 (funcall function handle))))
4704 (defun gnus-article-pipe-part (n)
4705 "Pipe MIME part N, which is the numerical prefix."
4707 (gnus-article-part-wrapper n 'mm-pipe-part))
4709 (defun gnus-article-save-part (n)
4710 "Save MIME part N, which is the numerical prefix."
4712 (gnus-article-part-wrapper n 'mm-save-part))
4714 (defun gnus-article-interactively-view-part (n)
4715 "View MIME part N interactively, which is the numerical prefix."
4717 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4719 (defun gnus-article-copy-part (n)
4720 "Copy MIME part N, which is the numerical prefix."
4722 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4724 (defun gnus-article-view-part-as-charset (n)
4725 "View MIME part N using a specified charset.
4726 N is the numerical prefix."
4728 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4730 (defun gnus-article-view-part-externally (n)
4731 "View MIME part N externally, which is the numerical prefix."
4733 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4735 (defun gnus-article-inline-part (n)
4736 "Inline MIME part N, which is the numerical prefix."
4738 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4740 (defun gnus-article-mime-match-handle-first (condition)
4743 (dolist (ihandle gnus-article-mime-handle-alist)
4745 ((functionp condition)
4746 (funcall condition (cdr ihandle)))
4747 ((eq condition 'undisplayed)
4748 (not (or (mm-handle-undisplayer (cdr ihandle))
4749 (equal (mm-handle-media-type (cdr ihandle))
4750 "multipart/alternative"))))
4751 ((eq condition 'undisplayed-alternative)
4752 (not (mm-handle-undisplayer (cdr ihandle))))
4754 (gnus-article-goto-part (car ihandle))
4755 (or (not n) (< (car ihandle) n)))
4756 (setq n (car ihandle))))
4760 (defun gnus-article-view-part (&optional n)
4761 "View MIME part N, which is the numerical prefix."
4763 (with-current-buffer gnus-article-buffer
4764 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4765 gnus-article-mime-match-handle-function)))
4766 (when (> n (length gnus-article-mime-handle-alist))
4767 (error "No such part"))
4768 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4769 (when (gnus-article-goto-part n)
4770 (if (equal (car handle) "multipart/alternative")
4771 (gnus-article-press-button)
4772 (when (eq (gnus-mm-display-part handle) 'internal)
4773 (gnus-set-window-start)))))))
4775 (defsubst gnus-article-mime-total-parts ()
4776 (if (bufferp (car gnus-article-mime-handles))
4778 (1- (length gnus-article-mime-handles))))
4780 (defun gnus-mm-display-part (handle)
4781 "Display HANDLE and fix MIME button."
4782 (let ((id (get-text-property (point) 'gnus-part))
4784 (inhibit-read-only t))
4787 (let ((window (selected-window))
4788 (mail-parse-charset gnus-newsgroup-charset)
4789 (mail-parse-ignored-charsets
4790 (if (gnus-buffer-live-p gnus-summary-buffer)
4791 (with-current-buffer gnus-summary-buffer
4792 gnus-newsgroup-ignored-charsets)
4796 (let ((win (gnus-get-buffer-window (current-buffer) t))
4799 (select-window win))
4802 (if (mm-handle-displayed-p handle)
4803 ;; This will remove the part.
4804 (mm-display-part handle)
4806 (narrow-to-region (point)
4807 (if (eobp) (point) (1+ (point))))
4808 (mm-display-part handle)
4809 ;; We narrow to the part itself and
4810 ;; then call the treatment functions.
4811 (goto-char (point-min))
4813 (narrow-to-region (point) (point-max))
4816 (gnus-article-mime-total-parts)
4817 (mm-handle-media-type handle)))))
4818 (if (window-live-p window)
4819 (select-window window)))))
4822 (gnus-insert-mime-button
4823 handle id (list (mm-handle-displayed-p handle)))
4824 (goto-char point))))
4826 (defun gnus-article-goto-part (n)
4827 "Go to MIME part N."
4828 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4830 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4831 (let ((gnus-tmp-name
4832 (or (mail-content-type-get (mm-handle-type handle) 'name)
4833 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4834 (mail-content-type-get (mm-handle-type handle) 'url)
4836 (gnus-tmp-type (mm-handle-media-type handle))
4837 (gnus-tmp-description
4838 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4841 (if (if displayed (car displayed)
4842 (mm-handle-displayed-p handle))
4844 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4846 gnus-tmp-type-long b e)
4847 (when (string-match ".*/" gnus-tmp-name)
4848 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4849 (setq gnus-tmp-type-long (concat gnus-tmp-type
4850 (and (not (equal gnus-tmp-name ""))
4851 (concat "; " gnus-tmp-name))))
4852 (unless (equal gnus-tmp-description "")
4853 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4858 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4859 `(keymap ,gnus-mime-button-map
4860 gnus-callback gnus-mm-display-part
4861 gnus-part ,gnus-tmp-id
4862 article-type annotation
4865 ;; Exclude a newline.
4868 (widget-convert-button
4871 :action 'gnus-widget-press-button
4872 :button-keymap gnus-mime-button-map
4874 (lambda (widget/window &optional overlay pos)
4875 ;; Needed to properly clear the message due to a bug in
4876 ;; wid-edit (XEmacs only).
4877 (if (boundp 'help-echo-owns-message)
4878 (setq help-echo-owns-message t))
4880 "%S: %s the MIME part; %S: more options"
4881 (aref gnus-mouse-2 0)
4882 ;; XEmacs will get a single widget arg; Emacs 21 will get
4883 ;; window, overlay, position.
4884 (if (mm-handle-displayed-p
4886 (with-current-buffer (gnus-overlay-buffer overlay)
4887 (widget-get (widget-at (gnus-overlay-start overlay))
4889 (widget-get widget/window :mime-handle)))
4891 (aref gnus-down-mouse-3 0))))))
4893 (defun gnus-widget-press-button (elems el)
4894 (goto-char (widget-get elems :from))
4895 (gnus-article-press-button))
4897 (defvar gnus-displaying-mime nil)
4899 (defun gnus-display-mime (&optional ihandles)
4900 "Display the MIME parts."
4902 (save-selected-window
4903 (let ((window (get-buffer-window gnus-article-buffer))
4906 (select-window window)
4907 ;; We have to do this since selecting the window
4908 ;; may change the point. So we set the window point.
4909 (set-window-point window point)))
4910 (let* ((handles (or ihandles
4911 (mm-dissect-buffer nil gnus-article-loose-mime)
4912 (and gnus-article-emulate-mime
4914 (inhibit-read-only t) handle name type b e display)
4915 (when (and (not ihandles)
4916 (not gnus-displaying-mime))
4917 ;; Top-level call; we clean up.
4918 (when gnus-article-mime-handles
4919 (mm-destroy-parts gnus-article-mime-handles)
4920 (setq gnus-article-mime-handle-alist nil));; A trick.
4921 (setq gnus-article-mime-handles handles)
4922 ;; We allow users to glean info from the handles.
4923 (when gnus-article-mime-part-function
4924 (gnus-mime-part-function handles)))
4926 (or (not (stringp (car handles)))
4929 (when (and (not ihandles)
4930 (not gnus-displaying-mime))
4931 ;; Clean up for mime parts.
4933 (delete-region (point) (point-max)))
4934 (let ((gnus-displaying-mime t))
4935 (gnus-mime-display-part handles)))
4938 (narrow-to-region (point) (point-max))
4939 (gnus-treat-article nil 1 1)
4942 ;; Highlight the headers.
4946 (narrow-to-region (point-min) (point))
4947 (gnus-treat-article 'head))))))))
4949 (defcustom gnus-mime-display-multipart-as-mixed nil
4950 "Display \"multipart\" parts as \"multipart/mixed\".
4952 If t, it overrides nil values of
4953 `gnus-mime-display-multipart-alternative-as-mixed' and
4954 `gnus-mime-display-multipart-related-as-mixed'."
4955 :group 'gnus-article-mime
4958 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
4959 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
4961 :group 'gnus-article-mime
4964 (defcustom gnus-mime-display-multipart-related-as-mixed nil
4965 "Display \"multipart/related\" parts as \"multipart/mixed\".
4967 If displaying \"text/html\" is discouraged \(see
4968 `mm-discouraged-alternatives'\) images or other material inside a
4969 \"multipart/related\" part might be overlooked when this variable is nil."
4971 :group 'gnus-article-mime
4974 (defun gnus-mime-display-part (handle)
4977 ((not (stringp (car handle)))
4978 (gnus-mime-display-single handle))
4979 ;; User-defined multipart
4980 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4981 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4983 ;; multipart/alternative
4984 ((and (equal (car handle) "multipart/alternative")
4985 (not (or gnus-mime-display-multipart-as-mixed
4986 gnus-mime-display-multipart-alternative-as-mixed)))
4987 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4988 (push (cons id handle) gnus-article-mime-handle-alist)
4989 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4990 ;; multipart/related
4991 ((and (equal (car handle) "multipart/related")
4992 (not (or gnus-mime-display-multipart-as-mixed
4993 gnus-mime-display-multipart-related-as-mixed)))
4994 ;;;!!!We should find the start part, but we just default
4995 ;;;!!!to the first part.
4996 ;;(gnus-mime-display-part (cadr handle))
4997 ;;;!!! Most multipart/related is an HTML message plus images.
4998 ;;;!!! Unfortunately we are unable to let W3 display those
4999 ;;;!!! included images, so we just display it as a mixed multipart.
5000 ;;(gnus-mime-display-mixed (cdr handle))
5001 ;;;!!! No, w3 can display everything just fine.
5002 (gnus-mime-display-part (cadr handle)))
5003 ((equal (car handle) "multipart/signed")
5004 (gnus-add-wash-type 'signed)
5005 (gnus-mime-display-security handle))
5006 ((equal (car handle) "multipart/encrypted")
5007 (gnus-add-wash-type 'encrypted)
5008 (gnus-mime-display-security handle))
5009 ;; Other multiparts are handled like multipart/mixed.
5011 (gnus-mime-display-mixed (cdr handle)))))
5013 (defun gnus-mime-part-function (handles)
5014 (if (stringp (car handles))
5015 (mapcar 'gnus-mime-part-function (cdr handles))
5016 (funcall gnus-article-mime-part-function handles)))
5018 (defun gnus-mime-display-mixed (handles)
5019 (mapcar 'gnus-mime-display-part handles))
5021 (defun gnus-mime-display-single (handle)
5022 (let ((type (mm-handle-media-type handle))
5023 (ignored gnus-ignored-mime-types)
5030 (when (string-match (pop ignored) type)
5031 (throw 'ignored nil)))
5032 (if (and (setq not-attachment
5033 (and (not (mm-inline-override-p handle))
5034 (or (not (mm-handle-disposition handle))
5035 (equal (car (mm-handle-disposition handle))
5037 (mm-attachment-override-p handle))))
5038 (mm-automatic-display-p handle)
5040 (mm-inlinable-p handle)
5041 (mm-inlined-p handle))
5042 (mm-automatic-external-display-p type)))
5044 (when (equal (mm-handle-media-supertype handle) "text")
5046 (let ((id (1+ (length gnus-article-mime-handle-alist)))
5048 (push (cons id handle) gnus-article-mime-handle-alist)
5049 (when (or (not display)
5050 (not (gnus-unbuttonized-mime-type-p type)))
5051 (gnus-insert-mime-button
5052 handle id (list (or display (and not-attachment text))))
5053 (gnus-article-insert-newline)
5054 ;; Remember modify the number of forward lines.
5062 (let ((mail-parse-charset gnus-newsgroup-charset)
5063 (mail-parse-ignored-charsets
5064 (save-excursion (condition-case ()
5065 (set-buffer gnus-summary-buffer)
5067 gnus-newsgroup-ignored-charsets)))
5068 (mm-display-part handle t))
5069 (goto-char (point-max)))
5070 ((and text not-attachment)
5074 (gnus-article-insert-newline)
5075 (mm-insert-inline handle (mm-get-part handle))
5076 (goto-char (point-max))))
5080 (narrow-to-region beg (point))
5083 (gnus-article-mime-total-parts)
5084 (mm-handle-media-type handle)))))))))
5086 (defun gnus-unbuttonized-mime-type-p (type)
5087 "Say whether TYPE is to be unbuttonized."
5088 (unless gnus-inhibit-mime-unbuttonizing
5090 (let ((types gnus-unbuttonized-mime-types))
5092 (when (string-match (pop types) type)
5093 (throw 'found t)))))
5095 (let ((types gnus-buttonized-mime-types))
5097 (when (string-match (pop types) type)
5098 (throw 'found t)))))))))
5100 (defun gnus-article-insert-newline ()
5101 "Insert a newline, but mark it as undeletable."
5102 (gnus-put-text-property
5103 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
5105 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
5106 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
5109 handle (inhibit-read-only t) from props begend not-pref)
5110 (save-window-excursion
5113 (narrow-to-region (car ibegend)
5116 (goto-char (car ibegend))
5119 (delete-region (point-min) (point-max))
5120 (mm-remove-parts handles))
5121 (setq begend (list (point-marker)))
5123 (unless (setq not-pref (cadr (member preferred ihandles)))
5124 (setq not-pref (car ihandles)))
5127 (not (gnus-unbuttonized-mime-type-p
5128 "multipart/alternative")))
5129 (gnus-add-text-properties
5132 (insert (format "%d. " id))
5136 (unless ,(not ibegend)
5137 (setq gnus-article-mime-handle-alist
5138 ',gnus-article-mime-handle-alist))
5139 (gnus-mime-display-alternative
5140 ',ihandles ',not-pref ',begend ,id))
5141 keymap ,gnus-mime-button-map
5142 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5143 face ,gnus-article-button-face
5146 (widget-convert-button 'link from (point)
5147 :action 'gnus-widget-press-button
5148 :button-keymap gnus-widget-button-keymap)
5150 (while (setq handle (pop handles))
5151 (gnus-add-text-properties
5154 (insert (format "(%c) %-18s"
5155 (if (equal handle preferred) ?* ? )
5156 (mm-handle-media-type handle)))
5160 (unless ,(not ibegend)
5161 (setq gnus-article-mime-handle-alist
5162 ',gnus-article-mime-handle-alist))
5163 (gnus-mime-display-alternative
5164 ',ihandles ',handle ',begend ,id))
5165 keymap ,gnus-mime-button-map
5166 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5167 face ,gnus-article-button-face
5170 (widget-convert-button 'link from (point)
5171 :action 'gnus-widget-press-button
5172 :button-keymap gnus-widget-button-keymap)
5176 (if (stringp (car preferred))
5177 (gnus-display-mime preferred)
5178 (let ((mail-parse-charset gnus-newsgroup-charset)
5179 (mail-parse-ignored-charsets
5180 (with-current-buffer gnus-summary-buffer
5181 gnus-newsgroup-ignored-charsets)))
5182 (mm-display-part preferred)
5186 (narrow-to-region (car begend) (point-max))
5188 nil (length gnus-article-mime-handle-alist)
5189 (gnus-article-mime-total-parts)
5190 (mm-handle-media-type handle))))))
5191 (goto-char (point-max))
5192 (setcdr begend (point-marker)))))
5194 (goto-char point))))
5196 (defconst gnus-article-wash-status-strings
5197 (let ((alist '((cite "c" "Possible hidden citation text"
5198 " " "All citation text visible")
5199 (headers "h" "Hidden headers"
5200 " " "All headers visible.")
5201 (pgp "p" "Encrypted or signed message status hidden"
5202 " " "No hidden encryption nor digital signature status")
5203 (signature "s" "Signature has been hidden"
5204 " " "Signature is visible")
5205 (overstrike "o" "Overstrike (^H) characters applied"
5206 " " "No overstrike characters applied")
5207 (gnus-show-mime "m" "Mime processing is activated"
5208 " " "Mime processing is not activated")
5209 (emphasis "e" "/*_Emphasis_*/ characters applied"
5210 " " "No /*_emphasis_*/ characters applied")))
5212 (dolist (entry alist result)
5213 (let ((key (nth 0 entry))
5214 (on (copy-sequence (nth 1 entry)))
5215 (on-help (nth 2 entry))
5216 (off (copy-sequence (nth 3 entry)))
5217 (off-help (nth 4 entry)))
5218 (put-text-property 0 1 'help-echo on-help on)
5219 (put-text-property 0 1 'help-echo off-help off)
5220 (push (list key on off) result))))
5221 "Alist of strings describing wash status in the mode line.
5222 Each entry has the form (KEY ON OF), where the KEY is a symbol
5223 representing the particular washing function, ON is the string to use
5224 in the article mode line when the washing function is active, and OFF
5225 is the string to use when it is inactive.")
5227 (defun gnus-article-wash-status-entry (key value)
5228 (let ((entry (assoc key gnus-article-wash-status-strings)))
5229 (if value (nth 1 entry) (nth 2 entry))))
5231 (defun gnus-article-wash-status ()
5232 "Return a string which display status of article washing."
5233 (with-current-buffer gnus-article-buffer
5234 (let ((cite (memq 'cite gnus-article-wash-types))
5235 (headers (memq 'headers gnus-article-wash-types))
5236 (boring (memq 'boring-headers gnus-article-wash-types))
5237 (pgp (memq 'pgp gnus-article-wash-types))
5238 (pem (memq 'pem gnus-article-wash-types))
5239 (signed (memq 'signed gnus-article-wash-types))
5240 (encrypted (memq 'encrypted gnus-article-wash-types))
5241 (signature (memq 'signature gnus-article-wash-types))
5242 (overstrike (memq 'overstrike gnus-article-wash-types))
5243 (emphasis (memq 'emphasis gnus-article-wash-types)))
5245 (gnus-article-wash-status-entry 'cite cite)
5246 (gnus-article-wash-status-entry 'headers (or headers boring))
5247 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5248 (gnus-article-wash-status-entry 'signature signature)
5249 (gnus-article-wash-status-entry 'overstrike overstrike)
5250 (gnus-article-wash-status-entry 'gnus-show-mime gnus-show-mime)
5251 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5253 (defun gnus-add-wash-type (type)
5254 "Add a washing of TYPE to the current status."
5255 (add-to-list 'gnus-article-wash-types type))
5257 (defun gnus-delete-wash-type (type)
5258 "Add a washing of TYPE to the current status."
5259 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5261 (defun gnus-add-image (category image)
5262 "Add IMAGE of CATEGORY to the list of displayed images."
5263 (let ((entry (assq category gnus-article-image-alist)))
5265 (setq entry (list category))
5266 (push entry gnus-article-image-alist))
5267 (nconc entry (list image))))
5269 (defun gnus-delete-images (category)
5270 "Delete all images in CATEGORY."
5271 (let ((entry (assq category gnus-article-image-alist)))
5272 (dolist (image (cdr entry))
5273 (gnus-remove-image image category))
5274 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5275 (gnus-delete-wash-type category)))
5277 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5279 (defun gnus-article-maybe-hide-headers ()
5280 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5281 Provided for backwards compatibility."
5282 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5283 (not (with-current-buffer gnus-summary-buffer
5284 gnus-have-all-headers)))
5285 (not gnus-inhibit-hiding))
5286 (gnus-article-hide-headers)))
5290 (defun gnus-output-to-file (file-name)
5291 "Append the current article to a file named FILE-NAME."
5292 (let ((artbuf (current-buffer)))
5294 (insert-buffer-substring artbuf)
5295 ;; Append newline at end of the buffer as separator, and then
5297 (goto-char (point-max))
5299 (let ((file-name-coding-system nnmail-pathname-coding-system))
5300 (write-region-as-binary (point-min) (point-max) file-name 'append))
5303 (defun gnus-narrow-to-page (&optional arg)
5304 "Narrow the article buffer to a page.
5305 If given a numerical ARG, move forward ARG pages."
5307 (setq arg (if arg (prefix-numeric-value arg) 0))
5309 (set-buffer gnus-article-buffer)
5310 (goto-char (point-min))
5312 ;; Remove any old next/prev buttons.
5313 (when (gnus-visual-p 'page-marker)
5314 (let ((inhibit-read-only t))
5315 (gnus-remove-text-with-property 'gnus-prev)
5316 (gnus-remove-text-with-property 'gnus-next)))
5319 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5321 (re-search-forward page-delimiter nil 'move arg)))
5322 (goto-char (match-end 0))
5324 (goto-char (point-min))
5325 (setq gnus-page-broken
5326 (and (re-search-forward page-delimiter nil t) t))))
5327 (when gnus-page-broken
5330 (if (re-search-forward page-delimiter nil 'move)
5333 (when (and (gnus-visual-p 'page-marker)
5334 (> (point-min) (save-restriction (widen) (point-min))))
5336 (goto-char (point-min))
5337 (gnus-insert-prev-page-button)))
5338 (when (and (gnus-visual-p 'page-marker)
5339 (< (+ (point-max) 2) (buffer-size)))
5341 (goto-char (point-max))
5342 (gnus-insert-next-page-button))))))
5344 ;; Article mode commands
5346 (defun gnus-article-goto-next-page ()
5347 "Show the next page of the article."
5349 (when (gnus-article-next-page)
5350 (goto-char (point-min))
5351 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5354 (defun gnus-article-goto-prev-page ()
5355 "Show the previous page of the article."
5358 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5359 (gnus-article-prev-page nil)))
5361 ;; This is cleaner but currently breaks `gnus-pick-mode':
5363 ;; (defun gnus-article-goto-next-page ()
5364 ;; "Show the next page of the article."
5366 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5367 ;; (gnus-summary-next-page)))
5369 ;; (defun gnus-article-goto-prev-page ()
5370 ;; "Show the next page of the article."
5372 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5373 ;; (gnus-summary-prev-page)))
5375 (defun gnus-article-next-page (&optional lines)
5376 "Show the next page of the current article.
5377 If end of article, return non-nil. Otherwise return nil.
5378 Argument LINES specifies lines to be scrolled up."
5380 (move-to-window-line -1)
5383 (and (pos-visible-in-window-p) ;Not continuation line.
5384 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5385 ;; Nothing in this page.
5386 (if (or (not gnus-page-broken)
5391 (eobp)))) ;Real end-of-buffer?
5393 (when gnus-article-over-scroll
5394 (gnus-article-next-page-1 lines))
5396 (gnus-narrow-to-page 1) ;Go to next page.
5398 ;; More in this page.
5399 (gnus-article-next-page-1 lines)
5402 (defun gnus-article-next-page-1 (lines)
5403 (let ((scroll-in-place nil))
5407 ;; Long lines may cause an end-of-buffer error.
5408 (goto-char (point-max)))))
5409 (move-to-window-line 0))
5411 (defun gnus-article-prev-page (&optional lines)
5412 "Show previous page of current article.
5413 Argument LINES specifies lines to be scrolled down."
5415 (move-to-window-line 0)
5416 (if (and gnus-page-broken
5418 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5420 (gnus-narrow-to-page -1) ;Go to previous page.
5421 (goto-char (point-max))
5423 (let ((scroll-in-place nil))
5427 (beginning-of-buffer
5428 (goto-char (point-min))))
5429 (move-to-window-line 0)))))
5431 (defun gnus-article-only-boring-p ()
5432 "Decide whether there is only boring text remaining in the article.
5433 Something \"interesting\" is a word of at least two letters that does
5434 not have a face in `gnus-article-boring-faces'."
5435 (when (and gnus-article-skip-boring
5436 (boundp 'gnus-article-boring-faces)
5437 (symbol-value 'gnus-article-boring-faces))
5440 (while (re-search-forward "\\b\\w\\w" nil t)
5442 (when (not (gnus-intersection
5443 (gnus-faces-at (point))
5444 (symbol-value 'gnus-article-boring-faces)))
5445 (throw 'only-boring nil)))
5446 (throw 'only-boring t)))))
5448 (defun gnus-article-refer-article ()
5449 "Read article specified by message-id around point."
5452 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
5453 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
5454 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
5455 (let ((msg-id (concat "<" (match-string 0) ">")))
5456 (set-buffer gnus-summary-buffer)
5457 (gnus-summary-refer-article msg-id))
5458 (error "No references around point"))))
5460 (defun gnus-article-show-summary ()
5461 "Reconfigure windows to show summary buffer."
5463 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5464 (error "There is no summary buffer for this article buffer")
5465 (gnus-article-set-globals)
5466 (gnus-configure-windows 'article)
5467 (gnus-summary-goto-subject gnus-current-article)
5468 (gnus-summary-position-point)))
5470 (defun gnus-article-describe-briefly ()
5471 "Describe article mode commands briefly."
5473 (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")))
5475 (defun gnus-article-summary-command ()
5476 "Execute the last keystroke in the summary buffer."
5478 (let ((obuf (current-buffer))
5479 (owin (current-window-configuration))
5481 (switch-to-buffer gnus-article-current-summary 'norecord)
5482 (setq func (lookup-key (current-local-map) (this-command-keys)))
5483 (call-interactively func)
5485 (set-window-configuration owin)
5486 (set-window-point (get-buffer-window (current-buffer)) (point))))
5488 (defun gnus-article-summary-command-nosave ()
5489 "Execute the last keystroke in the summary buffer."
5492 (pop-to-buffer gnus-article-current-summary 'norecord)
5493 (setq func (lookup-key (current-local-map) (this-command-keys)))
5494 (call-interactively func)))
5496 (defun gnus-article-check-buffer ()
5497 "Beep if not in an article buffer."
5498 (unless (eq (get-buffer gnus-article-buffer) (current-buffer))
5499 (error "Command invoked outside of a Gnus article buffer")))
5501 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5502 "Read a summary buffer key sequence and execute it from the article buffer."
5504 (gnus-article-check-buffer)
5506 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5507 "Zc" "ZC" "ZE" "ZJ" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5508 "=" "^" "\M-^" "|"))
5514 '("n" "Gn" "p" "Gp"))
5517 (set-buffer gnus-article-current-summary)
5518 (let (gnus-pick-mode)
5519 (push (or key last-command-event) unread-command-events)
5520 (setq keys (static-if (featurep 'xemacs)
5521 (events-to-keys (read-key-sequence nil))
5522 (read-key-sequence nil)))))
5525 (if (or (member keys nosaves)
5526 (member keys nosave-but-article)
5527 (member keys nosave-in-article))
5529 (save-window-excursion
5530 (pop-to-buffer gnus-article-current-summary 'norecord)
5531 ;; We disable the pick minor mode commands.
5532 (let (gnus-pick-mode)
5533 (setq func (lookup-key (current-local-map) keys))))
5537 (unless (member keys nosave-in-article)
5538 (set-buffer gnus-article-current-summary))
5539 (call-interactively func)
5540 (setq new-sum-point (point)))
5541 (when (member keys nosave-but-article)
5542 (pop-to-buffer gnus-article-buffer 'norecord)))
5543 ;; These commands should restore window configuration.
5544 (let ((obuf (current-buffer))
5545 (owin (current-window-configuration))
5547 win func in-buffer selected new-sum-start new-sum-hscroll)
5548 (cond (not-restore-window
5549 (pop-to-buffer gnus-article-current-summary 'norecord))
5550 ((setq win (get-buffer-window gnus-article-current-summary))
5551 (select-window win))
5553 (switch-to-buffer gnus-article-current-summary 'norecord)))
5554 (setq in-buffer (current-buffer))
5555 ;; We disable the pick minor mode commands.
5556 (if (and (setq func (let (gnus-pick-mode)
5557 (lookup-key (current-local-map) keys)))
5560 (call-interactively func)
5561 (when (eq win (selected-window))
5562 (setq new-sum-point (point)
5563 new-sum-start (window-start win)
5564 new-sum-hscroll (window-hscroll win))
5565 (when (eq in-buffer (current-buffer))
5566 (setq selected (gnus-summary-select-article))
5568 (unless not-restore-window
5569 (set-window-configuration owin))
5570 (when (eq selected 'old)
5572 (set-window-start (get-buffer-window (current-buffer))
5574 (set-window-point (get-buffer-window (current-buffer))
5576 (when (and (not not-restore-window)
5578 (set-window-point win new-sum-point)
5579 (set-window-start win new-sum-start)
5580 (set-window-hscroll win new-sum-hscroll)))))
5581 (set-window-configuration owin)
5584 (defun gnus-article-describe-key (key)
5585 "Display documentation of the function invoked by KEY. KEY is a string."
5586 (interactive "kDescribe key: ")
5587 (gnus-article-check-buffer)
5588 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5590 (set-buffer gnus-article-current-summary)
5591 (let (gnus-pick-mode)
5592 (if (featurep 'xemacs)
5594 (push (elt key 0) unread-command-events)
5595 (setq key (events-to-keys
5596 (read-key-sequence "Describe key: "))))
5597 (setq unread-command-events
5599 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5601 (setq key (read-key-sequence "Describe key: "))))
5603 (describe-key key)))
5605 (defun gnus-article-describe-key-briefly (key &optional insert)
5606 "Display documentation of the function invoked by KEY. KEY is a string."
5607 (interactive "kDescribe key: \nP")
5608 (gnus-article-check-buffer)
5609 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5611 (set-buffer gnus-article-current-summary)
5612 (let (gnus-pick-mode)
5613 (if (featurep 'xemacs)
5615 (push (elt key 0) unread-command-events)
5616 (setq key (events-to-keys
5617 (read-key-sequence "Describe key: "))))
5618 (setq unread-command-events
5620 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5622 (setq key (read-key-sequence "Describe key: "))))
5623 (describe-key-briefly key insert))
5624 (describe-key-briefly key insert)))
5626 (defun gnus-article-reply-with-original (&optional wide)
5627 "Start composing a reply mail to the current message.
5628 The text in the region will be yanked. If the region isn't active,
5629 the entire article will be yanked."
5631 (let ((article (cdr gnus-article-current))
5633 (if (not (gnus-region-active-p))
5634 (with-current-buffer gnus-summary-buffer
5635 (gnus-summary-reply (list (list article)) wide))
5636 (setq contents (buffer-substring (point) (mark t)))
5637 ;; Deactivate active regions.
5638 (when (and (boundp 'transient-mark-mode)
5639 transient-mark-mode)
5640 (setq mark-active nil))
5641 (with-current-buffer gnus-summary-buffer
5643 (list (list article contents)) wide)))))
5645 (defun gnus-article-followup-with-original ()
5646 "Compose a followup to the current article.
5647 The text in the region will be yanked. If the region isn't active,
5648 the entire article will be yanked."
5650 (let ((article (cdr gnus-article-current))
5652 (if (not (gnus-region-active-p))
5653 (with-current-buffer gnus-summary-buffer
5654 (gnus-summary-followup (list (list article))))
5655 (setq contents (buffer-substring (point) (mark t)))
5656 ;; Deactivate active regions.
5657 (when (and (boundp 'transient-mark-mode)
5658 transient-mark-mode)
5659 (setq mark-active nil))
5660 (with-current-buffer gnus-summary-buffer
5661 (gnus-summary-followup
5662 (list (list article contents)))))))
5664 (defun gnus-article-hide (&optional arg force)
5665 "Hide all the gruft in the current article.
5666 This means that signatures, cited text and (some) headers will be
5668 If given a prefix, show the hidden text instead."
5669 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5670 (gnus-article-hide-headers arg)
5671 (gnus-article-hide-list-identifiers arg)
5672 (gnus-article-hide-citation-maybe arg force)
5673 (gnus-article-hide-signature arg))
5675 (defun gnus-article-maybe-highlight ()
5676 "Do some article highlighting if article highlighting is requested."
5677 (when (gnus-visual-p 'article-highlight 'highlight)
5678 (gnus-article-highlight-some)))
5680 (defun gnus-check-group-server ()
5681 ;; Make sure the connection to the server is alive.
5682 (unless (gnus-server-opened
5683 (gnus-find-method-for-group gnus-newsgroup-name))
5684 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5685 (gnus-request-group gnus-newsgroup-name t)))
5688 (autoload 'nneething-get-file-name "nneething"))
5690 (defun gnus-request-article-this-buffer (article group)
5691 "Get an article and insert it into this buffer."
5692 (let (do-update-line sparse-header)
5696 (gnus-kill-all-overlays)
5697 (setq group (or group gnus-newsgroup-name))
5699 ;; Using `gnus-request-article' directly will insert the article into
5700 ;; `nntp-server-buffer' - so we'll save some time by not having to
5701 ;; copy it from the server buffer into the article buffer.
5703 ;; We only request an article by message-id when we do not have the
5704 ;; headers for it, so we'll have to get those.
5705 (when (stringp article)
5706 (gnus-read-header article))
5708 ;; If the article number is negative, that means that this article
5709 ;; doesn't belong in this newsgroup (possibly), so we find its
5710 ;; message-id and request it by id instead of number.
5711 (when (and (numberp article)
5713 (get-buffer gnus-summary-buffer)
5714 (gnus-buffer-exists-p gnus-summary-buffer))
5716 (set-buffer gnus-summary-buffer)
5717 (let ((header (gnus-summary-article-header article)))
5720 ((memq article gnus-newsgroup-sparse)
5721 ;; This is a sparse gap article.
5722 (setq do-update-line article)
5723 (setq article (mail-header-id header))
5724 (setq sparse-header (gnus-read-header article))
5725 (setq gnus-newsgroup-sparse
5726 (delq article gnus-newsgroup-sparse)))
5728 ;; It's a real article.
5729 (setq article (mail-header-id header)))
5731 ;; It is an extracted pseudo-article.
5732 (setq article 'pseudo)
5733 (gnus-request-pseudo-article header))))
5735 (let ((method (gnus-find-method-for-group
5736 gnus-newsgroup-name)))
5737 (when (and (eq (car method) 'nneething)
5739 (let ((dir (nneething-get-file-name
5740 (mail-header-id header))))
5741 (when (and (stringp dir)
5742 (file-directory-p dir))
5743 (setq article 'nneething)
5744 (gnus-group-enter-directory dir))))))))
5747 ;; Refuse to select canceled articles.
5748 ((and (numberp article)
5750 (get-buffer gnus-summary-buffer)
5751 (gnus-buffer-exists-p gnus-summary-buffer)
5752 (eq (cdr (with-current-buffer gnus-summary-buffer
5753 (assq article gnus-newsgroup-reads)))
5754 gnus-canceled-mark))
5756 ;; We first check `gnus-original-article-buffer'.
5757 ((and (get-buffer gnus-original-article-buffer)
5759 (with-current-buffer gnus-original-article-buffer
5760 (and (equal (car gnus-original-article) group)
5761 (eq (cdr gnus-original-article) article))))
5762 (insert-buffer-substring gnus-original-article-buffer)
5764 ;; Check the backlog.
5765 ((and gnus-keep-backlog
5766 (gnus-backlog-request-article group article (current-buffer)))
5768 ;; Check asynchronous pre-fetch.
5769 ((gnus-async-request-fetched-article group article (current-buffer))
5770 (gnus-async-prefetch-next group article gnus-summary-buffer)
5771 (when (and (numberp article) gnus-keep-backlog)
5772 (gnus-backlog-enter-article group article (current-buffer)))
5775 ((and gnus-use-cache
5777 (gnus-cache-request-article article group))
5779 ;; Check the agent cache.
5780 ((gnus-agent-request-article article group)
5782 ;; Get the article and put into the article buffer.
5783 ((or (stringp article)
5785 (let ((gnus-override-method gnus-override-method)
5786 (methods (and (stringp article)
5787 gnus-refer-article-method))
5788 (backend (car (gnus-find-method-for-group
5789 gnus-newsgroup-name)))
5791 (inhibit-read-only t))
5792 (if (or (not (listp methods))
5793 (and (symbolp (car methods))
5794 (assq (car methods) nnoo-definition-alist)))
5795 (setq methods (list methods)))
5796 (when (and (null gnus-override-method)
5798 (setq gnus-override-method (pop methods)))
5800 (when (eq gnus-override-method 'current)
5801 (setq gnus-override-method
5802 (with-current-buffer gnus-summary-buffer
5803 gnus-current-select-method)))
5805 (gnus-kill-all-overlays)
5806 (let ((gnus-newsgroup-name group))
5807 (gnus-check-group-server))
5809 ((gnus-request-article article group (current-buffer))
5810 (when (numberp article)
5811 (gnus-async-prefetch-next group article
5812 gnus-summary-buffer)
5813 (when gnus-keep-backlog
5814 (gnus-backlog-enter-article
5815 group article (current-buffer))))
5816 (setq result 'article))
5818 (setq gnus-override-method (pop methods)))
5819 ((not (string-match "^400 "
5820 (nnheader-get-report backend)))
5821 ;; If we get 400 server disconnect, reconnect and
5822 ;; retry; otherwise, assume the article has expired.
5823 (setq result 'done))))
5824 (and (eq result 'article) 'article)))
5828 ;; Associate this article with the current summary buffer.
5829 (setq gnus-article-current-summary gnus-summary-buffer)
5831 ;; Take the article from the original article buffer
5832 ;; and place it in the buffer it's supposed to be in.
5833 (when (and (get-buffer gnus-article-buffer)
5834 (equal (buffer-name (current-buffer))
5835 (buffer-name (get-buffer gnus-article-buffer))))
5837 (if (get-buffer gnus-original-article-buffer)
5838 (set-buffer gnus-original-article-buffer)
5839 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5840 (buffer-disable-undo)
5841 (setq major-mode 'gnus-original-article-mode)
5842 (setq buffer-read-only t))
5843 (let ((inhibit-read-only t))
5845 (insert-buffer-substring gnus-article-buffer))
5846 (setq gnus-original-article (cons group article)))
5849 (run-hooks 'gnus-article-decode-hook)
5850 ;; Mark article as decoded or not.
5851 (setq gnus-article-decoded-p gnus-article-decode-hook))
5853 ;; Update sparse articles.
5854 (when (and do-update-line
5855 (or (numberp article)
5857 (let ((buf (current-buffer)))
5858 (set-buffer gnus-summary-buffer)
5859 (gnus-summary-update-article do-update-line sparse-header)
5860 (gnus-summary-goto-subject do-update-line nil t)
5861 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5863 (set-buffer buf))))))
5869 (defcustom gnus-article-edit-mode-hook nil
5870 "Hook run in article edit mode buffers."
5871 :group 'gnus-article-various
5874 (defcustom gnus-article-edit-article-setup-function
5875 'gnus-article-mime-edit-article-setup
5876 "Function called to setup an editing article buffer."
5877 :group 'gnus-article-various
5880 (defvar gnus-article-edit-done-function nil)
5882 (defvar gnus-article-edit-mode-map nil)
5884 ;; Should we be using derived.el for this?
5885 (unless gnus-article-edit-mode-map
5886 (setq gnus-article-edit-mode-map (make-keymap))
5887 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5889 (gnus-define-keys gnus-article-edit-mode-map
5890 "\C-c?" describe-mode
5891 "\C-c\C-c" gnus-article-edit-done
5892 "\C-c\C-k" gnus-article-edit-exit
5893 "\C-c\C-f\C-t" message-goto-to
5894 "\C-c\C-f\C-o" message-goto-from
5895 "\C-c\C-f\C-b" message-goto-bcc
5896 ;;"\C-c\C-f\C-w" message-goto-fcc
5897 "\C-c\C-f\C-c" message-goto-cc
5898 "\C-c\C-f\C-s" message-goto-subject
5899 "\C-c\C-f\C-r" message-goto-reply-to
5900 "\C-c\C-f\C-n" message-goto-newsgroups
5901 "\C-c\C-f\C-d" message-goto-distribution
5902 "\C-c\C-f\C-f" message-goto-followup-to
5903 "\C-c\C-f\C-m" message-goto-mail-followup-to
5904 "\C-c\C-f\C-k" message-goto-keywords
5905 "\C-c\C-f\C-u" message-goto-summary
5906 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5907 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5908 "\C-c\C-b" message-goto-body
5909 "\C-c\C-i" message-goto-signature
5911 "\C-c\C-t" message-insert-to
5912 "\C-c\C-n" message-insert-newsgroups
5913 "\C-c\C-o" message-sort-headers
5914 "\C-c\C-e" message-elide-region
5915 "\C-c\C-v" message-delete-not-region
5916 "\C-c\C-z" message-kill-to-signature
5917 "\M-\r" message-newline-and-reformat
5918 "\C-c\C-a" mml-attach-file
5919 "\C-a" message-beginning-of-line
5921 "\M-;" comment-region)
5923 (gnus-define-keys (gnus-article-edit-wash-map
5924 "\C-c\C-w" gnus-article-edit-mode-map)
5925 "f" gnus-article-edit-full-stops))
5928 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5930 ["Fetch To" message-insert-to t]
5931 ["Fetch Newsgroups" message-insert-newsgroups t]
5933 ["To" message-goto-to t]
5934 ["From" message-goto-from t]
5935 ["Subject" message-goto-subject t]
5936 ["Cc" message-goto-cc t]
5937 ["Reply-To" message-goto-reply-to t]
5938 ["Summary" message-goto-summary t]
5939 ["Keywords" message-goto-keywords t]
5940 ["Newsgroups" message-goto-newsgroups t]
5941 ["Followup-To" message-goto-followup-to t]
5942 ["Mail-Followup-To" message-goto-mail-followup-to t]
5943 ["Distribution" message-goto-distribution t]
5944 ["Body" message-goto-body t]
5945 ["Signature" message-goto-signature t]))
5947 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
5948 "Major mode for editing articles.
5949 This is an extended text-mode.
5951 \\{gnus-article-edit-mode-map}"
5952 (make-local-variable 'gnus-article-edit-done-function)
5953 (make-local-variable 'gnus-prev-winconf)
5954 (set (make-local-variable 'font-lock-defaults)
5955 '(message-font-lock-keywords t))
5956 (set (make-local-variable 'mail-header-separator) "")
5957 (set (make-local-variable 'gnus-article-edit-mode) t)
5958 (easy-menu-add message-mode-field-menu message-mode-map)
5959 (setq buffer-read-only nil)
5960 (buffer-enable-undo)
5963 (defun gnus-article-edit (&optional force)
5964 "Edit the current article.
5965 This will have permanent effect only in mail groups.
5966 If FORCE is non-nil, allow editing of articles even in read-only
5969 (when (and (not force)
5970 (gnus-group-read-only-p))
5971 (error "The current newsgroup does not support article editing"))
5972 (gnus-article-date-original)
5973 (gnus-article-edit-article
5975 `(lambda (no-highlight)
5977 (gnus-summary-edit-article-done
5978 ,(or (mail-header-references gnus-current-headers) "")
5979 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5981 (defun gnus-article-edit-article (start-func exit-func)
5982 "Start editing the contents of the current article buffer."
5983 (let ((winconf (current-window-configuration)))
5984 (set-buffer gnus-article-buffer)
5985 (gnus-article-edit-mode)
5986 (funcall start-func)
5987 (set-buffer-modified-p nil)
5988 (gnus-configure-windows 'edit-article)
5989 (setq gnus-article-edit-done-function exit-func)
5990 (setq gnus-prev-winconf winconf)
5991 (when gnus-article-edit-article-setup-function
5992 (funcall gnus-article-edit-article-setup-function))
5993 (gnus-message 6 "C-c C-c to end edits; C-c C-k to exit")))
5995 (defun gnus-article-edit-done (&optional arg)
5996 "Update the article edits and exit."
5998 (let ((func gnus-article-edit-done-function)
5999 (buf (current-buffer))
6000 (start (window-start))
6002 (winconf gnus-prev-winconf))
6003 (remove-hook 'gnus-article-mode-hook
6004 'gnus-article-mime-edit-article-unwind)
6005 (widen) ;; Widen it in case that users narrowed the buffer.
6008 ;; The cache and backlog have to be flushed somewhat.
6009 (when gnus-keep-backlog
6010 (gnus-backlog-remove-article
6011 (car gnus-article-current) (cdr gnus-article-current)))
6012 ;; Flush original article as well.
6014 (when (get-buffer gnus-original-article-buffer)
6015 (set-buffer gnus-original-article-buffer)
6016 (setq gnus-original-article nil)))
6017 (when gnus-use-cache
6018 (gnus-cache-update-article
6019 (car gnus-article-current) (cdr gnus-article-current)))
6020 ;; We remove all text props from the article buffer.
6021 (kill-all-local-variables)
6022 (set-text-properties (point-min) (point-max) nil)
6024 (set-window-configuration winconf)
6026 (set-window-start (get-buffer-window buf) start)
6027 (set-window-point (get-buffer-window buf) (point)))
6028 (gnus-summary-show-article))
6030 (defun gnus-article-edit-exit ()
6031 "Exit the article editing without updating."
6033 (when (or (not (buffer-modified-p))
6034 (yes-or-no-p "Article modified; kill anyway? "))
6035 (let ((curbuf (current-buffer))
6037 (window-start (window-start)))
6039 (if (gnus-buffer-live-p gnus-original-article-buffer)
6040 (insert-buffer-substring gnus-original-article-buffer))
6041 (let ((winconf gnus-prev-winconf))
6042 (kill-all-local-variables)
6044 (set-window-configuration winconf)
6045 ;; Tippy-toe some to make sure that point remains where it was.
6046 (save-current-buffer
6048 (set-window-start (get-buffer-window (current-buffer)) window-start)
6050 (gnus-summary-show-article)))
6052 (defun gnus-article-edit-full-stops ()
6053 "Interactively repair spacing at end of sentences."
6056 (goto-char (point-min))
6057 (search-forward-regexp "^$" nil t)
6058 (let ((case-fold-search nil))
6059 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
6062 ;;; Article editing with MIME-Edit
6065 (defcustom gnus-article-mime-edit-article-setup-hook nil
6066 "Hook run after setting up a MIME editing article buffer."
6067 :group 'gnus-article-various
6070 (defun gnus-article-mime-edit-article-unwind ()
6071 "Unwind `gnus-article-buffer' if article editing was given up."
6072 (remove-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6073 (when (featurep 'font-lock)
6074 (setq font-lock-defaults nil)
6075 (font-lock-mode -1))
6076 (when mime-edit-mode-flag
6077 (mime-edit-exit 'nomime 'no-error)
6080 (defun gnus-article-mime-edit-article-setup ()
6081 "Convert current buffer to MIME-Edit buffer and turn on MIME-Edit mode
6082 after replacing with the original article."
6083 (setq gnus-show-mime t)
6084 (setq gnus-article-edit-done-function
6085 `(lambda (&rest args)
6086 (when mime-edit-mode-flag
6087 (let (mime-edit-insert-user-agent-field)
6090 (goto-char (point-min))
6091 (let (case-fold-search)
6092 (when (re-search-forward
6093 (format "^%s$" (regexp-quote mail-header-separator))
6095 (replace-match "")))
6096 (apply ,gnus-article-edit-done-function args)
6099 (buffer-substring-no-properties (point-min) (point-max))
6100 (set-buffer (get-buffer-create gnus-original-article-buffer))
6102 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6103 (set-buffer gnus-article-buffer)
6104 (gnus-article-prepare-display)))
6105 (substitute-key-definition 'gnus-article-edit-done
6106 'gnus-article-mime-edit-done
6107 gnus-article-edit-mode-map)
6108 (substitute-key-definition 'gnus-article-edit-exit
6109 'gnus-article-mime-edit-exit
6110 gnus-article-edit-mode-map)
6112 (insert-buffer-substring gnus-original-article-buffer)
6113 (unless (member (with-current-buffer gnus-summary-buffer
6114 gnus-newsgroup-name)
6115 '("nndraft:delayed" "nndraft:drafts"))
6116 (let ((ofn (symbol-function 'mime-edit-decode-single-part-in-buffer)))
6117 (fset 'mime-edit-decode-single-part-in-buffer
6118 (lambda (&rest args)
6119 (if (let ((content-type (car args)))
6120 (and (eq 'message (mime-content-type-primary-type
6122 (eq 'rfc822 (mime-content-type-subtype
6124 (setcar (cdr args) 'not-decode-text))
6128 (fset 'mime-edit-decode-single-part-in-buffer ofn))))
6129 (when (featurep 'font-lock)
6130 (set (make-local-variable 'font-lock-defaults)
6131 '(message-font-lock-keywords t))
6132 (font-lock-set-defaults)
6133 (turn-on-font-lock))
6134 (set-buffer-modified-p nil)
6135 (delete-other-windows)
6136 (add-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6137 (gnus-run-hooks 'gnus-article-mime-edit-article-setup-hook))
6139 (defun gnus-article-mime-edit-done (&optional arg)
6140 "Update the article MIME edits and exit."
6142 (when (featurep 'font-lock)
6143 (setq font-lock-defaults nil)
6144 (font-lock-mode -1))
6145 (let ((inhibit-read-only t))
6146 (gnus-article-edit-done arg)))
6148 (defun gnus-article-mime-edit-exit ()
6149 "Exit the article MIME editing without updating."
6151 (when (or (not (buffer-modified-p))
6152 (yes-or-no-p "Article modified; kill anyway? "))
6153 (when (featurep 'font-lock)
6154 (setq font-lock-defaults nil)
6155 (font-lock-mode -1))
6156 (when mime-edit-mode-flag
6157 (let (mime-edit-insert-user-agent-field)
6160 (goto-char (point-min))
6161 (let (case-fold-search)
6162 (when (re-search-forward
6163 (format "^%s$" (regexp-quote mail-header-separator)) nil t)
6164 (replace-match "")))
6165 (let ((winconf gnus-prev-winconf))
6167 (buffer-substring-no-properties (point-min) (point-max))
6168 (set-buffer (get-buffer-create gnus-original-article-buffer))
6170 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6171 (set-buffer gnus-article-buffer)
6172 (gnus-article-prepare-display)
6173 (set-window-configuration winconf))))
6176 ;;; Article highlights
6179 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
6181 ;;; Internal Variables:
6183 (defcustom gnus-button-url-regexp
6184 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
6185 "\\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:]]\\)"
6186 "\\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\\)\\)")
6187 "Regular expression that matches URLs."
6188 :group 'gnus-article-buttons
6191 (defcustom gnus-button-valid-fqdn-regexp
6192 message-valid-fqdn-regexp
6193 "Regular expression that matches a valid FQDN."
6195 :group 'gnus-article-buttons
6198 (defcustom gnus-button-man-handler 'manual-entry
6199 "Function to use for displaying man pages.
6200 The function must take at least one argument with a string naming the
6203 :type '(choice (function-item :tag "Man" manual-entry)
6204 (function-item :tag "Woman" woman)
6205 (function :tag "Other"))
6206 :group 'gnus-article-buttons)
6208 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
6209 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
6210 If the default site is too slow, try to find a CTAN mirror, see
6211 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
6212 the variable `gnus-button-handle-ctan'."
6214 :group 'gnus-article-buttons
6215 :link '(custom-manual "(gnus)Group Parameters")
6216 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
6217 (const "http://tug.ctan.org/tex-archive/")
6218 (const "http://www.dante.de/CTAN/")
6219 (string :tag "Other")))
6221 (defcustom gnus-button-ctan-handler 'browse-url
6222 "Function to use for displaying CTAN links.
6223 The function must take one argument, the string naming the URL."
6225 :type '(choice (function-item :tag "Browse Url" browse-url)
6226 (function :tag "Other"))
6227 :group 'gnus-article-buttons)
6229 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
6230 "Bogus strings removed from CTAN URLs."
6232 :group 'gnus-article-buttons
6233 :type '(choice (const "^/?tex-archive/\\|/")
6234 (regexp :tag "Other")))
6236 (defcustom gnus-button-ctan-directory-regexp
6239 "biblio\\|digests\\|dviware\\|fonts\\|graphics\\|help\\|"
6240 "indexing\\|info\\|language\\|macros\\|support\\|systems\\|"
6241 "tds\\|tools\\|usergrps\\|web\\|nonfree\\|obsolete"
6243 "Regular expression for ctan directories.
6244 It should match all directories in the top level of `gnus-ctan-url'."
6246 :group 'gnus-article-buttons
6249 (defcustom gnus-button-mid-or-mail-regexp
6250 (concat "\\b\\(<?[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t ]*@"
6251 ;; Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
6252 gnus-button-valid-fqdn-regexp
6254 "Regular expression that matches a message ID or a mail address."
6256 :group 'gnus-article-buttons
6259 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
6260 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
6261 Strings like this can be either a message ID or a mail address. If it is one
6262 of the symbols `mid' or `mail', Gnus will always assume that the string is a
6263 message ID or a mail address, respectively. If this variable is set to the
6264 symbol `ask', always query the user what do do. If it is a function, this
6265 function will be called with the string as it's only argument. The function
6266 must return `mid', `mail', `invalid' or `ask'."
6268 :group 'gnus-article-buttons
6269 :type '(choice (function-item :tag "Heuristic function"
6270 gnus-button-mid-or-mail-heuristic)
6275 (defcustom gnus-button-mid-or-mail-heuristic-alist
6276 '((-10.0 . ".+\\$.+@")
6279 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
6280 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
6281 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
6282 (-1.0 . "^[^a-z]+@")
6284 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
6285 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
6286 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
6287 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
6290 (-1.0 . "^[0-9][0-9]")
6292 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
6293 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6294 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
6295 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6297 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
6298 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
6301 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
6303 ;; compensation for TDMA dated mail addresses:
6304 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
6306 (-20.0 . "\\.fsf@") ;; Gnus
6309 (-20.0 . "_-_") ;; Subject change in thread
6311 (-20.0 . "\\.ln@") ;; leafnode
6312 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
6313 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
6315 ;; (5.0 . "") ;; $local_part_len <= 7
6316 (10.0 . "^[^0-9]+@")
6317 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
6318 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
6321 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
6323 (0.5 . "^[A-Z][a-z]")
6324 (0.5 . "^[A-Z][a-z][a-z]")
6325 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
6326 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
6327 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
6329 A negative RATE indicates a message IDs, whereas a positive indicates a mail
6330 address. The REGEXP is processed with `case-fold-search' set to nil."
6332 :group 'gnus-article-buttons
6333 :type '(repeat (cons (number :tag "Rate")
6334 (regexp :tag "Regexp"))))
6336 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
6337 "Guess whether MID-OR-MAIL is a message ID or a mail address.
6338 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
6339 address, `ask' if unsure and `invalid' if the string is invalid."
6340 (let ((case-fold-search nil)
6341 (list gnus-button-mid-or-mail-heuristic-alist)
6342 (result 0) rate regexp lpartlen elem)
6344 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
6345 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
6346 ;; Certain special cases...
6349 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
6350 "^[0-9]+\\.[0-9]+@compuserve\\|"
6351 "@public\\.gmane\\.org")
6353 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
6354 (setq result 'mail))
6355 (when (string-match "@.*@\\| " mid-or-mail)
6356 (gnus-message 8 "`%s' is invalid." mid-or-mail)
6357 (setq result 'invalid))
6358 ;; Nothing more to do, if result is not a number here...
6359 (when (numberp result)
6361 (setq elem (car list)
6365 (when (string-match regexp mid-or-mail)
6366 (setq result (+ result rate))
6368 9 "`%s' matched `%s', rate `%s', result `%s'."
6369 mid-or-mail regexp rate result)))
6370 (when (<= lpartlen 7)
6371 (setq result (+ result 5.0))
6372 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
6373 mid-or-mail result))
6374 (when (>= lpartlen 12)
6375 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
6377 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
6378 ;; Long local part should contain realname if e-mail address,
6379 ;; too many digits: message-id.
6380 ;; $score -= 5.0 + 0.1 * $local_part_len;
6381 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6382 (setq result (+ result rate))
6384 9 "Many digits in `%s', rate `%s', result `%s'."
6385 mid-or-mail rate result))
6386 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6388 ;; Too few vowels [^aeiouy]{4,}.*\@
6389 (setq result (+ result -5.0))
6391 9 "Few vowels in `%s', rate `%s', result `%s'."
6392 mid-or-mail -5.0 result))
6394 (setq result (+ result 5.0))
6396 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6397 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6398 ;; Maybe we should make this a customizable alist: (condition . 'result)
6400 ((symbolp result) result)
6401 ;; Now convert number into proper results:
6402 ((< result -10.0) 'mid)
6403 ((> result 10.0) 'mail)
6406 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6407 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6408 (url-mid (concat "news" ":" mid-or-mail))
6409 (url-mailto (concat "mailto" ":" mid-or-mail)))
6410 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6411 (when (fboundp pref)
6413 ;; get rid of surrounding angles...
6415 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6416 (if (or (eq 'mid guessed) (eq 'mail guessed))
6420 (save-window-excursion
6421 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6424 (cond ((eq pref 'mid)
6425 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6426 (gnus-button-handle-news url-mid))
6428 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6429 (gnus-url-mailto url-mailto))
6430 (t (gnus-message 3 "Invalid string.")))))
6432 (defun gnus-button-handle-custom (url)
6433 "Follow a Custom URL."
6434 (customize-apropos (gnus-url-unhex-string url)))
6436 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6438 ;; FIXME: Maybe we should merge some of the functions that do quite similar
6441 (defun gnus-button-handle-describe-function (url)
6442 "Call `describe-function' when pushing the corresponding URL button."
6445 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6447 (defun gnus-button-handle-describe-variable (url)
6448 "Call `describe-variable' when pushing the corresponding URL button."
6451 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6453 (defun gnus-button-handle-symbol (url)
6454 "Display help on variable or function.
6455 Calls `describe-variable' or `describe-function'."
6456 (let ((sym (intern url)))
6458 ((fboundp sym) (describe-function sym))
6459 ((boundp sym) (describe-variable sym))
6460 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
6462 (defun gnus-button-handle-describe-key (url)
6463 "Call `describe-key' when pushing the corresponding URL button."
6465 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6466 (keys (ignore-errors (eval `(kbd ,key-string)))))
6469 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6471 (defun gnus-button-handle-apropos (url)
6472 "Call `apropos' when pushing the corresponding URL button."
6473 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6475 (defun gnus-button-handle-apropos-command (url)
6476 "Call `apropos' when pushing the corresponding URL button."
6478 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6480 (defun gnus-button-handle-apropos-variable (url)
6481 "Call `apropos' when pushing the corresponding URL button."
6483 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6484 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6486 (defun gnus-button-handle-apropos-documentation (url)
6487 "Call `apropos' when pushing the corresponding URL button."
6489 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6490 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6492 (defun gnus-button-handle-library (url)
6493 "Call `locate-library' when pushing the corresponding URL button."
6494 (gnus-message 9 "url=`%s'" url)
6495 (let* ((lib (locate-library url))
6496 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6498 (gnus-message 1 "Cannot locale library `%s'." url)
6499 (find-file-read-only file))))
6501 (defun gnus-button-handle-ctan (url)
6502 "Call `browse-url' when pushing a CTAN URL button."
6504 gnus-button-ctan-handler
6507 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6509 (defcustom gnus-button-tex-level 5
6510 "*Integer that says how many TeX-related buttons Gnus will show.
6511 The higher the number, the more buttons will appear and the more false
6512 positives are possible. Note that you can set this variable local to
6513 specific groups. Setting it higher in TeX groups is probably a good idea.
6514 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6515 how to set variables in specific groups."
6517 :group 'gnus-article-buttons
6518 :link '(custom-manual "(gnus)Group Parameters")
6521 (defcustom gnus-button-man-level 5
6522 "*Integer that says how many man-related buttons Gnus will show.
6523 The higher the number, the more buttons will appear and the more false
6524 positives are possible. Note that you can set this variable local to
6525 specific groups. Setting it higher in Unix groups is probably a good idea.
6526 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6527 how to set variables in specific groups."
6529 :group 'gnus-article-buttons
6530 :link '(custom-manual "(gnus)Group Parameters")
6533 (defcustom gnus-button-emacs-level 5
6534 "*Integer that says how many emacs-related buttons Gnus will show.
6535 The higher the number, the more buttons will appear and the more false
6536 positives are possible. Note that you can set this variable local to
6537 specific groups. Setting it higher in Emacs or Gnus related groups is
6538 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6539 `gnus-parameters' on how to set variables in specific groups."
6541 :group 'gnus-article-buttons
6542 :link '(custom-manual "(gnus)Group Parameters")
6545 (defcustom gnus-button-message-level 5
6546 "*Integer that says how many buttons for news or mail messages will appear.
6547 The higher the number, the more buttons will appear and the more false
6548 positives are possible."
6549 ;; mail addresses, MIDs, URLs for news, ...
6551 :group 'gnus-article-buttons
6554 (defcustom gnus-button-browse-level 5
6555 "*Integer that says how many buttons for browsing will appear.
6556 The higher the number, the more buttons will appear and the more false
6557 positives are possible."
6558 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6560 :group 'gnus-article-buttons
6563 (defcustom gnus-button-alist
6564 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6565 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6566 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
6567 gnus-button-handle-news 2)
6568 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6569 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6570 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6571 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6572 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
6573 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
6574 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
6575 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6576 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6577 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6578 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6579 ;; RFC 2368 (The mailto URL scheme)
6580 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6581 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6582 ("\\bmailto:\\([^ \n\t]+\\)"
6583 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6585 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6586 gnus-button-ctan-directory-regexp
6587 "[^][>)!;:,'\n\t ]+\\)")
6588 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6589 ((concat "\\btex-archive/\\("
6590 gnus-button-ctan-directory-regexp
6591 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6592 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6595 gnus-button-ctan-directory-regexp
6596 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6597 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6598 ;; This is info (home-grown style) <info://foo/bar+baz>
6599 ("\\binfo://\\([^'\">\n\t ]+\\)"
6600 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6601 ;; Info GNOME style <info:foo#bar_baz>
6602 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6603 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6604 ;; Info KDE style <info:(foo)bar baz>
6605 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6606 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6607 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6608 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6609 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6610 ;; Info links like `C-h i d m CC Mode RET'
6611 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6613 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6614 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6615 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6616 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6617 ;; Emacs help commands
6618 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6619 ;; regexp doesn't match arguments containing ` '.
6620 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6621 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6622 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6623 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6624 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6625 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6626 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6627 ;; The following entries may lead to many false positives so don't enable
6628 ;; them by default (use a high button level).
6629 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
6630 ;; Exclude [.?] for URLs in gmane.emacs.cvs
6631 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6632 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6633 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6634 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6635 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6636 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6637 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6638 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6639 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6640 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6641 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
6642 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6643 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6644 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6645 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6646 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6647 ;; Unlike the other regexps we really have to require quoting
6648 ;; here to determine where it ends.
6649 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6650 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
6651 ("<URL: *\\([^<>]*\\)>"
6652 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6653 ;; RFC 2396 (2.4.3., delims) ...
6654 ("\"URL: *\\([^\"]*\\)\""
6655 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6656 ;; RFC 2396 (2.4.3., delims) ...
6657 ("\"URL: *\\([^\"]*\\)\""
6658 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6660 (gnus-button-url-regexp
6661 0 (>= gnus-button-browse-level 0) browse-url 0)
6663 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
6664 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6665 gnus-button-handle-man 1)
6666 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6667 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
6668 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6669 gnus-button-handle-man 1)
6670 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6671 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6672 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
6673 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6674 ;; MID or mail: To avoid too many false positives we don't try to catch
6675 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6676 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6677 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6678 ;; so that non-ambiguous entries (see above) match first.
6679 (gnus-button-mid-or-mail-regexp
6680 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6681 "*Alist of regexps matching buttons in article bodies.
6683 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6684 REGEXP: is the string (case insensitive) matching text around the button (can
6685 also be Lisp expression evaluating to a string),
6686 BUTTON: is the number of the regexp grouping actually matching the button,
6687 FORM: is a Lisp expression which must eval to true for the button to
6689 CALLBACK: is the function to call when the user push this button, and each
6690 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6692 CALLBACK can also be a variable, in that case the value of that
6693 variable it the real callback function."
6694 :group 'gnus-article-buttons
6695 :type '(repeat (list (choice regexp variable sexp)
6696 (integer :tag "Button")
6698 (function :tag "Callback")
6701 (integer :tag "Regexp group")))))
6703 (defcustom gnus-header-button-alist
6704 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
6705 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6706 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6707 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6708 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6709 0 (>= gnus-button-message-level 0) gnus-button-mailto 0)
6710 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6711 0 (>= gnus-button-browse-level 0) browse-url 0)
6712 ("^Subject:" gnus-button-url-regexp
6713 0 (>= gnus-button-browse-level 0) browse-url 0)
6714 ("^[^:]+:" gnus-button-url-regexp
6715 0 (>= gnus-button-browse-level 0) browse-url 0)
6716 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6717 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6718 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6719 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6720 "*Alist of headers and regexps to match buttons in article heads.
6722 This alist is very similar to `gnus-button-alist', except that each
6723 alist has an additional HEADER element first in each entry:
6725 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6727 HEADER is a regexp to match a header. For a fuller explanation, see
6728 `gnus-button-alist'."
6729 :group 'gnus-article-buttons
6730 :group 'gnus-article-headers
6731 :type '(repeat (list (regexp :tag "Header")
6732 (choice regexp variable)
6733 (integer :tag "Button")
6735 (function :tag "Callback")
6738 (integer :tag "Regexp group")))))
6742 (defun gnus-article-push-button (event)
6743 "Check text under the mouse pointer for a callback function.
6744 If the text under the mouse pointer has a `gnus-callback' property,
6745 call it with the value of the `gnus-data' text property."
6747 (set-buffer (window-buffer (posn-window (event-start event))))
6748 (let* ((pos (posn-point (event-start event)))
6749 (data (get-text-property pos 'gnus-data))
6750 (fun (get-text-property pos 'gnus-callback)))
6753 (funcall fun data))))
6755 (defun gnus-article-press-button ()
6756 "Check text at point for a callback function.
6757 If the text at point has a `gnus-callback' property,
6758 call it with the value of the `gnus-data' text property."
6760 (let ((data (get-text-property (point) 'gnus-data))
6761 (fun (get-text-property (point) 'gnus-callback)))
6763 (funcall fun data))))
6765 (defun gnus-article-prev-button (n)
6766 "Move point to N buttons backward.
6767 If N is negative, move forward instead."
6769 (gnus-article-next-button (- n)))
6771 (defun gnus-article-next-button (n)
6772 "Move point to N buttons forward.
6773 If N is negative, move backward instead."
6775 (let ((function (if (< n 0) 'previous-single-property-change
6776 'next-single-property-change))
6777 (inhibit-point-motion-hooks t)
6779 (limit (if (< n 0) (point-min) (point-max))))
6781 (while (and (not (= limit (point)))
6783 ;; Skip past the current button.
6784 (when (get-text-property (point) 'gnus-callback)
6785 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6786 ;; Go to the next (or previous) button.
6787 (gnus-goto-char (funcall function (point) 'gnus-callback nil limit))
6788 ;; Put point at the start of the button.
6789 (when (and backward (not (get-text-property (point) 'gnus-callback)))
6790 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6791 ;; Skip past intangible buttons.
6792 (when (get-text-property (point) 'intangible)
6796 (gnus-message 5 "No more buttons"))
6799 (defun gnus-article-highlight (&optional force)
6800 "Highlight current article.
6801 This function calls `gnus-article-highlight-headers',
6802 `gnus-article-highlight-citation',
6803 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6804 do the highlighting. See the documentation for those functions."
6805 (interactive (list 'force))
6806 (gnus-article-highlight-headers)
6807 (gnus-article-highlight-citation force)
6808 (gnus-article-highlight-signature)
6809 (gnus-article-add-buttons force)
6810 (gnus-article-add-buttons-to-head))
6812 (defun gnus-article-highlight-some (&optional force)
6813 "Highlight current article.
6814 This function calls `gnus-article-highlight-headers',
6815 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6816 do the highlighting. See the documentation for those functions."
6817 (interactive (list 'force))
6818 (gnus-article-highlight-headers)
6819 (gnus-article-highlight-signature)
6820 (gnus-article-add-buttons))
6822 (defun gnus-article-highlight-headers ()
6823 "Highlight article headers as specified by `gnus-header-face-alist'."
6825 (gnus-with-article-headers
6826 (let (regexp header-face field-face from hpoints fpoints)
6827 (dolist (entry gnus-header-face-alist)
6828 (goto-char (point-min))
6829 (setq regexp (concat "^\\("
6830 (if (string-equal "" (nth 0 entry))
6834 header-face (nth 1 entry)
6835 field-face (nth 2 entry))
6836 (while (and (re-search-forward regexp nil t)
6840 (unless (search-forward ":" nil t)
6842 (when (and header-face
6843 (not (memq (point) hpoints)))
6844 (push (point) hpoints)
6845 (gnus-put-text-property from (point) 'face header-face))
6846 (when (and field-face
6847 (not (memq (setq from (point)) fpoints)))
6849 (if (re-search-forward "^[^ \t]" nil t)
6851 (goto-char (point-max)))
6852 (gnus-put-text-property from (point) 'face field-face)))))))
6854 (defun gnus-article-highlight-signature ()
6855 "Highlight the signature in an article.
6856 It does this by highlighting everything after
6857 `gnus-signature-separator' using `gnus-signature-face'."
6859 (when gnus-signature-face
6860 (gnus-with-article-buffer
6861 (let ((inhibit-point-motion-hooks t))
6863 (when (gnus-article-narrow-to-signature)
6864 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6865 'face gnus-signature-face)))))))
6867 (defun gnus-article-buttonize-signature ()
6868 "Add button to the signature."
6871 (set-buffer gnus-article-buffer)
6872 (let ((inhibit-read-only t)
6873 (inhibit-point-motion-hooks t))
6874 (when (gnus-article-search-signature)
6875 (gnus-article-add-button (match-beginning 0) (match-end 0)
6876 'gnus-signature-toggle
6877 (set-marker (make-marker)
6878 (1+ (match-end 0))))))))
6880 (defun gnus-button-in-region-p (b e prop)
6881 "Say whether PROP exists in the region."
6882 (text-property-not-all b e prop nil))
6884 (defun gnus-article-add-buttons (&optional force)
6885 "Find external references in the article and make buttons of them.
6886 \"External references\" are things like Message-IDs and URLs, as
6887 specified by `gnus-button-alist'."
6888 (interactive (list 'force))
6889 (gnus-with-article-buffer
6890 (let ((inhibit-point-motion-hooks t)
6891 (case-fold-search t)
6892 (alist gnus-button-alist)
6894 ;; Remove all old markers.
6895 (let (marker entry new-list)
6896 (while (setq marker (pop gnus-button-marker-list))
6897 (if (or (< marker (point-min)) (>= marker (point-max)))
6898 (push marker new-list)
6900 (when (setq entry (gnus-button-entry))
6901 (put-text-property (match-beginning (nth 1 entry))
6902 (match-end (nth 1 entry))
6903 'gnus-callback nil))
6904 (set-marker marker nil)))
6905 (setq gnus-button-marker-list new-list))
6906 ;; We skip the headers.
6909 (while (setq entry (pop alist))
6910 (setq regexp (eval (car entry)))
6912 (while (re-search-forward regexp nil t)
6913 (let* ((start (and entry (match-beginning (nth 1 entry))))
6914 (end (and entry (match-end (nth 1 entry))))
6915 (from (match-beginning 0)))
6916 (when (and (or (eq t (nth 2 entry))
6917 (eval (nth 2 entry)))
6918 (not (gnus-button-in-region-p
6919 start end 'gnus-callback)))
6920 ;; That optional form returned non-nil, so we add the
6922 (gnus-article-add-button
6923 start end 'gnus-button-push
6924 (car (push (set-marker (make-marker) from)
6925 gnus-button-marker-list))))))))))
6927 ;; Add buttons to the head of an article.
6928 (defun gnus-article-add-buttons-to-head ()
6929 "Add buttons to the head of the article."
6931 (gnus-with-article-headers
6933 (dolist (entry gnus-header-button-alist)
6934 ;; Each alist entry.
6935 (goto-char (point-min))
6936 (while (re-search-forward (car entry) nil t)
6937 ;; Each header matching the entry.
6938 (setq beg (match-beginning 0))
6939 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6940 (match-beginning 0))
6943 (while (re-search-forward (eval (nth 1 entry)) end t)
6944 ;; Each match within a header.
6945 (let* ((entry (cdr entry))
6946 (start (match-beginning (nth 1 entry)))
6947 (end (match-end (nth 1 entry)))
6948 (form (nth 2 entry)))
6949 (goto-char (match-end 0))
6951 (gnus-article-add-button
6952 start end (nth 3 entry)
6953 (buffer-substring (match-beginning (nth 4 entry))
6954 (match-end (nth 4 entry)))))))
6955 (goto-char end))))))
6957 ;;; External functions:
6959 (defun gnus-article-add-button (from to fun &optional data)
6960 "Create a button between FROM and TO with callback FUN and data DATA."
6961 (when gnus-article-button-face
6962 (gnus-overlay-put (gnus-make-overlay from to)
6963 'face gnus-article-button-face))
6964 (gnus-add-text-properties
6966 (nconc (and gnus-article-mouse-face
6967 (list gnus-mouse-face-prop gnus-article-mouse-face))
6968 (list 'gnus-callback fun)
6969 (and data (list 'gnus-data data))))
6970 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6971 :button-keymap gnus-widget-button-keymap))
6973 ;;; Internal functions:
6975 (defun gnus-article-set-globals ()
6976 (with-current-buffer gnus-summary-buffer
6977 (gnus-set-global-variables)))
6979 (defun gnus-signature-toggle (end)
6980 (gnus-with-article-buffer
6981 (let ((inhibit-point-motion-hooks t)
6982 (limit (next-single-property-change end 'mime-view-entity
6984 (if (text-property-any end limit 'article-type 'signature)
6986 (gnus-delete-wash-type 'signature)
6987 (gnus-remove-text-properties-when
6988 'article-type 'signature end limit
6989 (cons 'article-type (cons 'signature
6990 gnus-hidden-properties))))
6991 (gnus-add-wash-type 'signature)
6992 (gnus-add-text-properties-when
6993 'article-type nil end limit
6994 (cons 'article-type (cons 'signature
6995 gnus-hidden-properties)))))
6996 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6997 (gnus-set-mode-line 'article))))
6999 (defun gnus-button-entry ()
7000 ;; Return the first entry in `gnus-button-alist' matching this place.
7001 (let ((alist gnus-button-alist)
7004 (setq entry (pop alist))
7005 (if (looking-at (eval (car entry)))
7010 (defun gnus-button-push (marker)
7011 ;; Push button starting at MARKER.
7014 (let* ((entry (gnus-button-entry))
7015 (inhibit-point-motion-hooks t)
7017 (args (mapcar (lambda (group)
7018 (let ((string (match-string group)))
7019 (set-text-properties
7020 0 (length string) nil string)
7027 (fboundp (symbol-value fun)))
7028 (apply (symbol-value fun) args))
7030 (gnus-message 1 "You must define `%S' to use this button"
7031 (cons fun args)))))))
7033 (defun gnus-parse-news-url (url)
7034 (let (scheme server group message-id articles)
7037 (goto-char (point-min))
7038 (when (looking-at "\\([A-Za-z]+\\):")
7039 (setq scheme (match-string 1))
7040 (goto-char (match-end 0)))
7041 (when (looking-at "//\\([^/]+\\)/")
7042 (setq server (match-string 1))
7043 (goto-char (match-end 0)))
7046 ((looking-at "\\(.*@.*\\)")
7047 (setq message-id (match-string 1)))
7048 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
7049 (setq group (match-string 1)
7050 articles (split-string (match-string 2) "-")))
7051 ((looking-at "\\([^/]+\\)/?")
7052 (setq group (match-string 1)))
7054 (error "Unknown news URL syntax"))))
7055 (list scheme server group message-id articles)))
7057 (defun gnus-button-handle-news (url)
7059 (destructuring-bind (scheme server group message-id articles)
7060 (gnus-parse-news-url url)
7064 (set-buffer gnus-summary-buffer)
7066 (let ((gnus-refer-article-method (list (list 'nntp server))))
7067 (gnus-summary-refer-article message-id))
7068 (gnus-summary-refer-article message-id))))
7070 (gnus-button-fetch-group url)))))
7072 (defun gnus-button-handle-man (url)
7074 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7075 (when (eq gnus-button-man-handler 'woman)
7076 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
7077 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7078 (funcall gnus-button-man-handler url))
7080 (defun gnus-button-handle-info-url (url)
7081 "Fetch an info URL."
7082 (setq url (mm-subst-char-in-string ?+ ?\ url))
7084 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
7085 (gnus-info-find-node
7086 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
7088 ")" (gnus-url-unhex-string (match-string 2 url)))))
7089 ((string-match "([^)\"]+)[^\"]+" url)
7091 (gnus-replace-in-string
7092 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
7093 (gnus-info-find-node url))
7094 (t (error "Can't parse %s" url))))
7096 (defun gnus-button-handle-info-url-gnome (url)
7097 "Fetch GNOME style info URL."
7098 (setq url (mm-subst-char-in-string ?_ ?\ url))
7099 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
7100 (gnus-info-find-node
7102 (gnus-url-unhex-string
7103 (match-string 1 url))
7105 (or (gnus-url-unhex-string
7106 (match-string 2 url))
7108 (error "Can't parse %s" url)))
7110 (defun gnus-button-handle-info-url-kde (url)
7111 "Fetch KDE style info URL."
7112 (gnus-info-find-node (gnus-url-unhex-string url)))
7114 (defun gnus-button-handle-info-keystrokes (url)
7115 "Call `info' when pushing the corresponding URL button."
7116 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
7121 (defun gnus-button-message-id (message-id)
7123 (with-current-buffer gnus-summary-buffer
7124 (gnus-summary-refer-article message-id)))
7126 (defun gnus-button-fetch-group (address)
7127 "Fetch GROUP specified by ADDRESS."
7128 (if (not (string-match "[:/]" address))
7129 ;; This is just a simple group url.
7130 (gnus-group-read-ephemeral-group address gnus-select-method)
7133 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
7135 (error "Can't parse %s" address)
7136 (gnus-group-read-ephemeral-group
7137 (match-string 4 address)
7138 `(nntp ,(match-string 1 address)
7139 (nntp-address ,(match-string 1 address))
7140 (nntp-port-number ,(if (match-end 3)
7141 (match-string 3 address)
7144 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
7146 (defun gnus-url-parse-query-string (query &optional downcase)
7147 (let (retval pairs cur key val)
7148 (setq pairs (split-string query "&"))
7150 (setq cur (car pairs)
7152 (if (not (string-match "=" cur))
7154 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
7155 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
7157 (setq key (downcase key)))
7158 (setq cur (assoc key retval))
7160 (setcdr cur (cons val (cdr cur)))
7161 (setq retval (cons (list key val) retval)))))
7164 (defun gnus-url-mailto (url)
7165 ;; Send mail to someone
7166 (when (string-match "mailto:/*\\(.*\\)" url)
7167 (setq url (substring url (match-beginning 1) nil)))
7168 (let (to args subject func)
7169 (setq args (gnus-url-parse-query-string
7170 (if (string-match "^\\?" url)
7172 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
7173 (concat "to=" (match-string 1 url) "&"
7174 (match-string 2 url))
7175 (concat "to=" url)))
7177 subject (cdr-safe (assoc "subject" args)))
7180 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
7183 (message-position-on-field (caar args)))
7184 (insert (gnus-replace-in-string
7185 (mapconcat 'identity (reverse (cdar args)) ", ")
7187 (setq args (cdr args)))
7190 (message-goto-subject))))
7192 (defun gnus-button-embedded-url (address)
7193 "Activate ADDRESS with `browse-url'."
7194 (browse-url (gnus-strip-whitespace address)))
7196 ;;; Next/prev buttons in the article buffer.
7198 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
7199 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
7201 (defvar gnus-prev-page-map
7202 (let ((map (make-sparse-keymap)))
7203 (define-key map gnus-mouse-2 'gnus-button-prev-page)
7204 (define-key map "\r" 'gnus-button-prev-page)
7207 (defvar gnus-next-page-map
7208 (let ((map (make-sparse-keymap)))
7209 (unless (>= emacs-major-version 21)
7210 ;; XEmacs doesn't care.
7211 (set-keymap-parent map gnus-article-mode-map))
7212 (define-key map gnus-mouse-2 'gnus-button-next-page)
7213 (define-key map "\r" 'gnus-button-next-page)
7216 (defun gnus-insert-prev-page-button ()
7218 (inhibit-read-only t)
7219 (situation (get-text-property (point-min) 'mime-view-situation)))
7221 gnus-prev-page-line-format nil
7222 `(keymap ,gnus-prev-page-map
7224 gnus-callback gnus-article-button-prev-page
7225 article-type annotation
7226 mime-view-situation ,situation))
7227 (widget-convert-button
7229 ;; Exclude a newline.
7232 :action 'gnus-button-prev-page
7233 :button-keymap gnus-prev-page-map)))
7235 (defun gnus-button-next-page (&optional args more-args)
7236 "Go to the next page."
7238 (let ((win (selected-window)))
7239 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7240 (gnus-article-next-page)
7241 (select-window win)))
7243 (defun gnus-button-prev-page (&optional args more-args)
7244 "Go to the prev page."
7246 (let ((win (selected-window)))
7247 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7248 (gnus-article-prev-page)
7249 (select-window win)))
7251 (defun gnus-insert-next-page-button ()
7253 (inhibit-read-only t)
7254 (situation (get-text-property (point-min) 'mime-view-situation)))
7255 (gnus-eval-format gnus-next-page-line-format nil
7256 `(keymap ,gnus-next-page-map
7258 gnus-callback gnus-article-button-next-page
7259 article-type annotation
7260 mime-view-situation ,situation))
7261 (widget-convert-button
7263 ;; Exclude a newline.
7266 :action 'gnus-button-next-page
7267 :button-keymap gnus-next-page-map)))
7269 (defun gnus-article-button-next-page (arg)
7270 "Go to the next page."
7272 (let ((win (selected-window)))
7273 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7274 (gnus-article-next-page)
7275 (select-window win)))
7277 (defun gnus-article-button-prev-page (arg)
7278 "Go to the prev page."
7280 (let ((win (selected-window)))
7281 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7282 (gnus-article-prev-page)
7283 (select-window win)))
7285 (defvar gnus-decode-header-methods
7286 '(mail-decode-encoded-word-region)
7287 "List of methods used to decode headers.
7289 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
7290 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
7291 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
7292 whose names match REGEXP.
7295 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
7296 mail-decode-encoded-word-region
7297 (\"chinese\" . rfc1843-decode-region))
7300 (defvar gnus-decode-header-methods-cache nil)
7302 (defun gnus-multi-decode-header (start end)
7303 "Apply the functions from `gnus-encoded-word-methods' that match."
7304 (unless (and gnus-decode-header-methods-cache
7305 (eq gnus-newsgroup-name
7306 (car gnus-decode-header-methods-cache)))
7307 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
7310 (nconc gnus-decode-header-methods-cache (list x))
7311 (if (and gnus-newsgroup-name
7312 (string-match (car x) gnus-newsgroup-name))
7313 (nconc gnus-decode-header-methods-cache
7315 gnus-decode-header-methods))
7316 (let ((xlist gnus-decode-header-methods-cache))
7319 (narrow-to-region start end)
7321 (funcall (pop xlist) (point-min) (point-max))))))
7324 ;;; Treatment top-level handling.
7327 (defun gnus-treat-article (condition &optional part-number total-parts type)
7328 (let ((length (- (point-max) (point-min)))
7329 (alist gnus-treatment-function-alist)
7330 (article-goto-body-goes-to-point-min-p t)
7334 (let ((list gnus-article-treat-types))
7336 (when (string-match (pop list) type)
7337 (throw 'found t)))))))
7338 (highlightp (gnus-visual-p 'article-highlight 'highlight))
7339 (entity (static-unless (featurep 'xemacs)
7340 (when (eq 'head condition)
7341 (get-text-property (point-min) 'mime-view-entity))))
7342 val elem buttonized)
7343 (gnus-run-hooks 'gnus-part-display-hook)
7344 (unless gnus-inhibit-treatment
7345 (dolist (elem alist)
7348 (when (gnus-buffer-live-p gnus-summary-buffer)
7349 (set-buffer gnus-summary-buffer))
7350 (symbol-value (car elem))))
7351 (when (and (or (consp val)
7353 (gnus-treat-predicate val)
7354 (or (not (get (car elem) 'highlight))
7356 (when (and (not buttonized)
7358 '(gnus-treat-hide-signature
7359 gnus-treat-highlight-signature)))
7360 (gnus-article-buttonize-signature)
7361 (setq buttonized t))
7363 (funcall (cadr elem)))))
7364 ;; FSF Emacsen does not inherit the existing text properties
7365 ;; in the new text, so we should do it for `mime-view-entity'.
7366 (static-unless (featurep 'xemacs)
7368 (put-text-property (point-min) (point-max)
7369 'mime-view-entity entity))))))
7371 ;; Dynamic variables.
7373 (defvar part-number)
7374 (defvar total-parts)
7379 (defun gnus-treat-predicate (val)
7384 (stringp (car val)))
7385 (apply 'gnus-or (mapcar `(lambda (s)
7386 (string-match s ,(or gnus-newsgroup-name "")))
7389 (let ((pred (pop val)))
7392 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
7394 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
7396 (not (gnus-treat-predicate (car val))))
7398 (equal (car val) type))
7400 (error "%S is not a valid predicate" pred)))))
7410 (eq part-number total-parts))
7414 (error "%S is not a valid value" val))))
7416 (defun gnus-article-encrypt-body (protocol &optional n)
7417 "Encrypt the article body."
7420 (or gnus-article-encrypt-protocol
7421 (completing-read "Encrypt protocol: "
7422 gnus-article-encrypt-protocol-alist
7424 current-prefix-arg))
7425 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7427 (error (format "Can't find the encrypt protocol %s" protocol)))
7428 (if (member gnus-newsgroup-name '("nndraft:delayed"
7431 (error "Can't encrypt the article in group %s"
7432 gnus-newsgroup-name))
7433 (gnus-summary-iterate n
7435 (set-buffer gnus-summary-buffer)
7436 (let ((mail-parse-charset gnus-newsgroup-charset)
7437 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7438 (summary-buffer gnus-summary-buffer)
7440 (gnus-set-global-variables)
7441 (when (gnus-group-read-only-p)
7442 (error "The current newsgroup does not support article encrypt"))
7443 (gnus-summary-show-article t)
7445 (or (mail-header-references gnus-current-headers) ""))
7446 (set-buffer gnus-article-buffer)
7447 (let* ((inhibit-read-only t)
7449 (mapcar (lambda (field)
7450 (and (save-restriction
7451 (message-narrow-to-head)
7452 (goto-char (point-min))
7453 (search-forward field nil t))
7455 (message-narrow-to-field)
7457 (delete-region (point-min) (point-max))
7459 '("Content-Type:" "Content-Transfer-Encoding:"
7460 "Content-Disposition:"))))
7461 (message-narrow-to-head)
7462 (message-remove-header "MIME-Version")
7463 (goto-char (point-max))
7464 (setq point (point))
7465 (insert (apply 'concat headers))
7467 (narrow-to-region point (point-max))
7468 (let ((message-options message-options))
7469 (message-options-set 'message-sender user-mail-address)
7470 (message-options-set 'message-recipients user-mail-address)
7471 (message-options-set 'message-sign-encrypt 'not)
7473 (goto-char (point-min))
7474 (insert "MIME-Version: 1.0\n")
7476 (gnus-summary-edit-article-done
7477 references nil summary-buffer t))
7478 (when gnus-keep-backlog
7479 (gnus-backlog-remove-article
7480 (car gnus-article-current) (cdr gnus-article-current)))
7482 (when (get-buffer gnus-original-article-buffer)
7483 (set-buffer gnus-original-article-buffer)
7484 (setq gnus-original-article nil)))
7485 (when gnus-use-cache
7486 (gnus-cache-update-article
7487 (car gnus-article-current) (cdr gnus-article-current))))))))
7489 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7490 "The following specs can be used:
7491 %t The security MIME type
7494 %D Details if button is pressed")
7496 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
7497 "The following specs can be used:
7498 %t The security MIME type
7501 %D Details if button is pressed")
7503 (defvar gnus-mime-security-button-line-format-alist
7504 '((?t gnus-tmp-type ?s)
7505 (?i gnus-tmp-info ?s)
7506 (?d gnus-tmp-details ?s)
7507 (?D gnus-tmp-pressed-details ?s)))
7509 (defvar gnus-mime-security-button-map
7510 (let ((map (make-sparse-keymap)))
7511 (define-key map gnus-mouse-2 'gnus-article-push-button)
7512 (define-key map "\r" 'gnus-article-press-button)
7515 (defvar gnus-mime-security-details-buffer nil)
7517 (defvar gnus-mime-security-button-pressed nil)
7519 (defvar gnus-mime-security-show-details-inline t
7520 "If non-nil, show details in the article buffer.")
7522 (defun gnus-mime-security-verify-or-decrypt (handle)
7523 (mm-remove-parts (cdr handle))
7524 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7525 point (inhibit-read-only t))
7527 (goto-char (car region)))
7529 (narrow-to-region (point) (point))
7530 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7531 (let* ((mm-verify-option 'known)
7532 (mm-decrypt-option 'known)
7533 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7534 (unless (eq nparts (cdr handle))
7535 (mm-destroy-parts (cdr handle))
7536 (setcdr handle nparts))))
7537 (setq point (point))
7538 (gnus-mime-display-security handle)
7539 (goto-char (point-max)))
7541 (delete-region (point) (cdr region))
7542 (set-marker (car region) nil)
7543 (set-marker (cdr region) nil))
7546 (defun gnus-mime-security-show-details (handle)
7547 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7549 (gnus-message 5 "No details.")
7550 (if gnus-mime-security-show-details-inline
7551 (let ((gnus-mime-security-button-pressed
7552 (not (get-text-property (point) 'gnus-mime-details)))
7553 (gnus-mime-security-button-line-format
7554 (get-text-property (point) 'gnus-line-format))
7555 (inhibit-read-only t))
7557 (while (eq (get-text-property (point) 'gnus-line-format)
7558 gnus-mime-security-button-line-format)
7562 (narrow-to-region (point) (point))
7563 (gnus-insert-mime-security-button handle))
7564 (delete-region (point)
7565 (or (text-property-not-all
7568 gnus-mime-security-button-line-format)
7571 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7572 (with-current-buffer gnus-mime-security-details-buffer
7575 (setq gnus-mime-security-details-buffer
7576 (gnus-get-buffer-create "*MIME Security Details*")))
7577 (with-current-buffer gnus-mime-security-details-buffer
7579 (goto-char (point-min)))
7580 (pop-to-buffer gnus-mime-security-details-buffer)))))
7582 (defun gnus-mime-security-press-button (handle)
7584 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7585 (gnus-mime-security-show-details handle)
7586 (gnus-mime-security-verify-or-decrypt handle))))
7588 (defun gnus-insert-mime-security-button (handle &optional displayed)
7589 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7592 (or (nth 2 (assoc protocol mm-verify-function-alist))
7593 (nth 2 (assoc protocol mm-decrypt-function-alist))
7595 (if (equal (car handle) "multipart/signed")
7596 " Signed" " Encrypted")
7599 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7602 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7603 gnus-tmp-pressed-details
7605 (setq gnus-tmp-details
7606 (if gnus-tmp-details
7607 (concat "\n" gnus-tmp-details)
7609 (setq gnus-tmp-pressed-details
7610 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7615 gnus-mime-security-button-line-format
7616 gnus-mime-security-button-line-format-alist
7617 `(keymap ,gnus-mime-security-button-map
7618 gnus-callback gnus-mime-security-press-button
7619 gnus-line-format ,gnus-mime-security-button-line-format
7620 gnus-mime-details ,gnus-mime-security-button-pressed
7621 article-type annotation
7624 ;; Exclude a newline.
7627 (widget-convert-button
7630 :action 'gnus-widget-press-button
7631 :button-keymap gnus-mime-security-button-map
7633 (lambda (widget/window &optional overlay pos)
7634 ;; Needed to properly clear the message due to a bug in
7635 ;; wid-edit (XEmacs only).
7636 (when (boundp 'help-echo-owns-message)
7637 (setq help-echo-owns-message t))
7640 (aref gnus-mouse-2 0))))))
7642 (defun gnus-mime-display-security (handle)
7644 (narrow-to-region (point) (point))
7645 (unless (gnus-unbuttonized-mime-type-p (car handle))
7646 (gnus-insert-mime-security-button handle))
7647 (gnus-mime-display-mixed (cdr handle))
7650 (unless (gnus-unbuttonized-mime-type-p (car handle))
7651 (let ((gnus-mime-security-button-line-format
7652 gnus-mime-security-button-end-line-format))
7653 (gnus-insert-mime-security-button handle)))
7654 (mm-set-handle-multipart-parameter
7656 (cons (set-marker (make-marker) (point-min))
7657 (set-marker (make-marker) (point-max))))))
7663 (defun gnus-article-header-presentation-method (entity situation)
7664 (mime-insert-header entity)
7665 (article-decode-group-name))
7667 (set-alist 'mime-header-presentation-method-alist
7668 'gnus-original-article-mode
7669 #'gnus-article-header-presentation-method)
7671 (defun gnus-mime-preview-quitting-method ()
7672 (mime-preview-kill-buffer)
7673 (delete-other-windows)
7674 (gnus-article-show-summary)
7675 (gnus-summary-select-article gnus-show-all-headers t))
7677 (set-alist 'mime-preview-quitting-method-alist
7678 'gnus-original-article-mode #'gnus-mime-preview-quitting-method)
7680 (set-alist 'mime-preview-following-method-alist
7681 'gnus-original-article-mode #'gnus-following-method)
7683 (set-alist 'mime-preview-over-to-previous-method-alist
7684 'gnus-original-article-mode
7686 (if (> (point-min) 1)
7687 (gnus-article-prev-page)
7688 (gnus-article-read-summary-keys
7689 nil (gnus-character-to-event ?P)))))
7691 (set-alist 'mime-preview-over-to-next-method-alist
7692 'gnus-original-article-mode'
7694 (if (< (point-max) (buffer-size))
7695 (gnus-article-next-page)
7696 (gnus-article-read-summary-keys
7697 nil (gnus-character-to-event ?N)))))
7707 (run-hooks 'gnus-art-load-hook)
7709 ;;; gnus-art.el ends here