1 ;;; gnus-art.el --- article mode commands for Semi-gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
5 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
6 ;; Katsumi Yamaoka <yamaoka@jpl.org>
7 ;; Keywords: mail, news, MIME
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
30 (eval-when-compile (require 'cl))
31 (eval-when-compile (require 'static))
42 ;; Avoid byte-compile warnings.
51 (defgroup gnus-article nil
53 :link '(custom-manual "(gnus)The Article Buffer")
56 (defgroup gnus-article-treat nil
57 "Treating article parts."
58 :link '(custom-manual "(gnus)Article Hiding")
61 (defgroup gnus-article-hiding nil
62 "Hiding article parts."
63 :link '(custom-manual "(gnus)Article Hiding")
66 (defgroup gnus-article-highlight nil
67 "Article highlighting."
68 :link '(custom-manual "(gnus)Article Highlighting")
72 (defgroup gnus-article-signature nil
74 :link '(custom-manual "(gnus)Article Signature")
77 (defgroup gnus-article-headers nil
79 :link '(custom-manual "(gnus)Hiding Headers")
82 (defgroup gnus-article-washing nil
83 "Special commands on articles."
84 :link '(custom-manual "(gnus)Article Washing")
87 (defgroup gnus-article-emphasis nil
88 "Fontisizing articles."
89 :link '(custom-manual "(gnus)Article Fontisizing")
92 (defgroup gnus-article-saving nil
94 :link '(custom-manual "(gnus)Saving Articles")
97 (defgroup gnus-article-mime nil
98 "Worshiping the MIME wonder."
99 :link '(custom-manual "(gnus)Using MIME")
100 :group 'gnus-article)
102 (defgroup gnus-article-buttons nil
103 "Pushable buttons in the article buffer."
104 :link '(custom-manual "(gnus)Article Buttons")
105 :group 'gnus-article)
107 (defgroup gnus-article-various nil
108 "Other article options."
109 :link '(custom-manual "(gnus)Misc Article")
110 :group 'gnus-article)
112 (defcustom gnus-ignored-headers
113 '("^Path:" "^Expires:" "^Date-Received:" "^References:" "^Xref:" "^Lines:"
114 "^Relay-Version:" "^Message-ID:" "^Approved:" "^Sender:" "^Received:"
115 "^X-UIDL:" "^MIME-Version:" "^Return-Path:" "^In-Reply-To:"
116 "^Content-Type:" "^Content-Transfer-Encoding:" "^X-WebTV-Signature:"
117 "^X-MimeOLE:" "^X-MSMail-Priority:" "^X-Priority:" "^X-Loop:"
118 "^X-Authentication-Warning:" "^X-MIME-Autoconverted:" "^X-Face:"
119 "^X-Attribution:" "^X-Originating-IP:" "^Delivered-To:"
120 "^NNTP-[-A-Za-z]+:" "^Distribution:" "^X-no-archive:" "^X-Trace:"
121 "^X-Complaints-To:" "^X-NNTP-Posting-Host:" "^X-Orig.*:"
122 "^Abuse-Reports-To:" "^Cache-Post-Path:" "^X-Article-Creation-Date:"
123 "^X-Poster:" "^X-Mail2News-Path:" "^X-Server-Date:" "^X-Cache:"
124 "^Originator:" "^X-Problems-To:" "^X-Auth-User:" "^X-Post-Time:"
125 "^X-Admin:" "^X-UID:" "^Resent-[-A-Za-z]+:" "^X-Mailing-List:"
126 "^Precedence:" "^Original-[-A-Za-z]+:" "^X-filename:" "^X-Orcpt:"
127 "^Old-Received:" "^X-Pgp" "^X-Auth:" "^X-From-Line:"
128 "^X-Gnus-Article-Number:" "^X-Majordomo:" "^X-Url:" "^X-Sender:"
129 "^MBOX-Line" "^Priority:" "^X-Pgp" "^X400-[-A-Za-z]+:"
130 "^Status:" "^X-Gnus-Mail-Source:" "^Cancel-Lock:"
131 "^X-FTN" "^X-EXP32-SerialNo:" "^Encoding:" "^Importance:"
132 "^Autoforwarded:" "^Original-Encoded-Information-Types:" "^X-Ya-Pop3:"
133 "^X-Face-Version:" "^X-Vms-To:" "^X-ML-NAME:" "^X-ML-COUNT:"
134 "^Mailing-List:" "^X-finfo:" "^X-md5sum:" "^X-md5sum-Origin:"
135 "^X-Sun-Charset:" "^X-Accept-Language:" "^X-Envelope-Sender:"
136 "^List-[A-Za-z]+:" "^X-Listprocessor-Version:"
137 "^X-Received:" "^X-Distribute:" "^X-Sequence:" "^X-Juno-Line-Breaks:"
138 "^X-Notes-Item:" "^X-MS-TNEF-Correlator:" "^x-uunet-gateway:"
139 "^X-Received:" "^Content-length:" "X-precedence:")
140 "*All headers that start with this regexp will be hidden.
141 This variable can also be a list of regexps of headers to be ignored.
142 If `gnus-visible-headers' is non-nil, this variable will be ignored."
143 :type '(choice :custom-show nil
146 :group 'gnus-article-hiding)
148 (defcustom gnus-visible-headers
149 "^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:"
150 "*All headers that do not match this regexp will be hidden.
151 This variable can also be a list of regexp of headers to remain visible.
152 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
153 :type '(repeat :value-to-internal (lambda (widget value)
154 (custom-split-regexp-maybe value))
155 :match (lambda (widget value)
157 (widget-editable-list-match widget value)))
159 :group 'gnus-article-hiding)
161 (defcustom gnus-sorted-header-list
162 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
163 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
164 "*This variable is a list of regular expressions.
165 If it is non-nil, headers that match the regular expressions will
166 be placed first in the article buffer in the sequence specified by
168 :type '(repeat regexp)
169 :group 'gnus-article-hiding)
171 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
172 "Headers that are only to be displayed if they have interesting data.
173 Possible values in this list are `empty', `newsgroups', `followup-to',
174 `reply-to', `date', `long-to', and `many-to'."
175 :type '(set (const :tag "Headers with no content." empty)
176 (const :tag "Newsgroups with only one group." newsgroups)
177 (const :tag "Followup-to identical to newsgroups." followup-to)
178 (const :tag "Reply-to identical to from." reply-to)
179 (const :tag "Date less than four days old." date)
180 (const :tag "Very long To and/or Cc header." long-to)
181 (const :tag "Multiple To and/or Cc headers." many-to))
182 :group 'gnus-article-hiding)
184 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
185 "Regexp matching signature separator.
186 This can also be a list of regexps. In that case, it will be checked
187 from head to tail looking for a separator. Searches will be done from
188 the end of the buffer."
189 :type '(repeat string)
190 :group 'gnus-article-signature)
192 (defcustom gnus-signature-limit nil
193 "Provide a limit to what is considered a signature.
194 If it is a number, no signature may not be longer (in characters) than
195 that number. If it is a floating point number, no signature may be
196 longer (in lines) than that number. If it is a function, the function
197 will be called without any parameters, and if it returns nil, there is
198 no signature in the buffer. If it is a string, it will be used as a
199 regexp. If it matches, the text in question is not a signature."
200 :type '(choice (integer :value 200)
202 (function :value fun)
203 (regexp :value ".*"))
204 :group 'gnus-article-signature)
206 (defcustom gnus-hidden-properties '(invisible t intangible t)
207 "Property list to use for hiding text."
209 :group 'gnus-article-hiding)
211 (defcustom gnus-article-x-face-command
213 ;; Fixme: This isn't the right thing for mixed graphical and and
214 ;; non-graphical frames in a session.
215 ;; gnus-xmas.el overrides this for XEmacs.
216 ((and (fboundp 'image-type-available-p)
217 (image-type-available-p 'xbm))
218 'gnus-article-display-xface)
219 ((and (not (featurep 'xemacs))
221 (module-installed-p 'x-face-mule))
222 'x-face-mule-gnus-article-display-x-face)
223 (gnus-article-compface-xbm
224 "{ echo '/* Width=48, Height=48 */'; uncompface; } | display -")
226 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
228 "*String or function to be executed to display an X-Face header.
229 If it is a string, the command will be executed in a sub-shell
230 asynchronously. The compressed face will be piped to this command."
231 :type '(choice string
232 (function-item gnus-article-display-xface)
233 (function-item x-face-mule-gnus-article-display-x-face)
235 :group 'gnus-article-washing)
237 (defcustom gnus-article-x-face-too-ugly nil
238 "Regexp matching posters whose face shouldn't be shown automatically."
239 :type '(choice regexp (const nil))
240 :group 'gnus-article-washing)
242 (defcustom gnus-article-banner-alist nil
243 "Banner alist for stripping.
245 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( eGroups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
246 :type '(repeat (cons symbol regexp))
247 :group 'gnus-article-washing)
249 (defcustom gnus-emphasis-alist
251 "\\(\\s-\\|^\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\s-\\|[-,;:\"]\\s-\\|[?!.]+\\s-\\|\\s)\\)")
253 '(("_" "_" underline)
256 ("_/" "/_" underline-italic)
257 ("_\\*" "\\*_" underline-bold)
258 ("\\*/" "/\\*" bold-italic)
259 ("_\\*/" "/\\*_" underline-bold-italic))))
260 `(("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
261 2 3 gnus-emphasis-underline)
265 (format format (car spec) (car (cdr spec)))
266 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
268 "*Alist that says how to fontify certain phrases.
269 Each item looks like this:
271 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
273 The first element is a regular expression to be matched. The second
274 is a number that says what regular expression grouping used to find
275 the entire emphasized word. The third is a number that says what
276 regexp grouping should be displayed and highlighted. The fourth
277 is the face used for highlighting."
278 :type '(repeat (list :value ("" 0 0 default)
280 (integer :tag "Match group")
281 (integer :tag "Emphasize group")
283 :group 'gnus-article-emphasis)
285 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
286 "A regexp to describe whitespace which should not be emphasized.
287 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
288 The former avoids underlining of leading and trailing whitespace,
289 and the latter avoids underlining any whitespace at all."
290 :group 'gnus-article-emphasis
293 (defface gnus-emphasis-bold '((t (:bold t)))
294 "Face used for displaying strong emphasized text (*word*)."
295 :group 'gnus-article-emphasis)
297 (defface gnus-emphasis-italic '((t (:italic t)))
298 "Face used for displaying italic emphasized text (/word/)."
299 :group 'gnus-article-emphasis)
301 (defface gnus-emphasis-underline '((t (:underline t)))
302 "Face used for displaying underlined emphasized text (_word_)."
303 :group 'gnus-article-emphasis)
305 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
306 "Face used for displaying underlined bold emphasized text (_*word*_)."
307 :group 'gnus-article-emphasis)
309 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
310 "Face used for displaying underlined italic emphasized text (_/word/_)."
311 :group 'gnus-article-emphasis)
313 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
314 "Face used for displaying bold italic emphasized text (/*word*/)."
315 :group 'gnus-article-emphasis)
317 (defface gnus-emphasis-underline-bold-italic
318 '((t (:bold t :italic t :underline t)))
319 "Face used for displaying underlined bold italic emphasized text.
320 Esample: (_/*word*/_)."
321 :group 'gnus-article-emphasis)
323 (defface gnus-emphasis-highlight-words
324 '((t (:background "black" :foreground "yellow")))
325 "Face used for displaying highlighted words."
326 :group 'gnus-article-emphasis)
328 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
329 "Format for display of Date headers in article bodies.
330 See `format-time-string' for the possible values.
332 The variable can also be function, which should return a complete Date
333 header. The function is called with one argument, the time, which can
334 be fed to `format-time-string'."
335 :type '(choice string symbol)
336 :link '(custom-manual "(gnus)Article Date")
337 :group 'gnus-article-washing)
340 (autoload 'mail-extract-address-components "mail-extr"))
342 (defcustom gnus-save-all-headers t
343 "*If non-nil, don't remove any headers before saving."
344 :group 'gnus-article-saving
347 (defcustom gnus-prompt-before-saving 'always
348 "*This variable says how much prompting is to be done when saving articles.
349 If it is nil, no prompting will be done, and the articles will be
350 saved to the default files. If this variable is `always', each and
351 every article that is saved will be preceded by a prompt, even when
352 saving large batches of articles. If this variable is neither nil not
353 `always', there the user will be prompted once for a file name for
354 each invocation of the saving commands."
355 :group 'gnus-article-saving
356 :type '(choice (item always)
357 (item :tag "never" nil)
358 (sexp :tag "once" :format "%t\n" :value t)))
360 (defcustom gnus-saved-headers gnus-visible-headers
361 "Headers to keep if `gnus-save-all-headers' is nil.
362 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
363 If that variable is nil, however, all headers that match this regexp
364 will be kept while the rest will be deleted before saving."
365 :group 'gnus-article-saving
368 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
369 "A function to save articles in your favourite format.
370 The function must be interactively callable (in other words, it must
371 be an Emacs command).
373 Gnus provides the following functions:
375 * gnus-summary-save-in-rmail (Rmail format)
376 * gnus-summary-save-in-mail (Unix mail format)
377 * gnus-summary-save-in-folder (MH folder)
378 * gnus-summary-save-in-file (article format)
379 * gnus-summary-save-in-vm (use VM's folder format)
380 * gnus-summary-write-to-file (article format -- overwrite)."
381 :group 'gnus-article-saving
382 :type '(radio (function-item gnus-summary-save-in-rmail)
383 (function-item gnus-summary-save-in-mail)
384 (function-item gnus-summary-save-in-folder)
385 (function-item gnus-summary-save-in-file)
386 (function-item gnus-summary-save-in-vm)
387 (function-item gnus-summary-write-to-file)))
389 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
390 "A function generating a file name to save articles in Rmail format.
391 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
392 :group 'gnus-article-saving
395 (defcustom gnus-mail-save-name 'gnus-plain-save-name
396 "A function generating a file name to save articles in Unix mail format.
397 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
398 :group 'gnus-article-saving
401 (defcustom gnus-folder-save-name 'gnus-folder-save-name
402 "A function generating a file name to save articles in MH folder.
403 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
404 :group 'gnus-article-saving
407 (defcustom gnus-file-save-name 'gnus-numeric-save-name
408 "A function generating a file name to save articles in article format.
409 The function is called with NEWSGROUP, HEADERS, and optional
411 :group 'gnus-article-saving
414 (defcustom gnus-split-methods
415 '((gnus-article-archive-name)
416 (gnus-article-nndoc-name))
417 "*Variable used to suggest where articles are to be saved.
418 For instance, if you would like to save articles related to Gnus in
419 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
420 you could set this variable to something like:
422 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
423 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
425 This variable is an alist where the where the key is the match and the
426 value is a list of possible files to save in if the match is non-nil.
428 If the match is a string, it is used as a regexp match on the
429 article. If the match is a symbol, that symbol will be funcalled
430 from the buffer of the article to be saved with the newsgroup as the
431 parameter. If it is a list, it will be evaled in the same buffer.
433 If this form or function returns a string, this string will be used as
434 a possible file name; and if it returns a non-nil list, that list will
435 be used as possible file names."
436 :group 'gnus-article-saving
437 :type '(repeat (choice (list :value (fun) function)
438 (cons :value ("" "") regexp (repeat string))
441 (defcustom gnus-article-display-method-for-mime
442 'gnus-article-display-mime-message
443 "Function to display a MIME message.
444 The function is called from the article buffer."
445 :group 'gnus-article-mime
448 (defcustom gnus-article-display-method-for-traditional
449 'gnus-article-display-traditional-message
450 "*Function to display a traditional message.
451 The function is called from the article buffer."
452 :group 'gnus-article-mime
455 (defcustom gnus-page-delimiter "^\^L"
456 "*Regexp describing what to use as article page delimiters.
457 The default value is \"^\^L\", which is a form linefeed at the
458 beginning of a line."
460 :group 'gnus-article-various)
462 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
463 "*The format specification for the article mode line.
464 See `gnus-summary-mode-line-format' for a closer description.
466 The following additional specs are available:
468 %w The article washing status.
469 %m The number of MIME parts in the article."
471 :group 'gnus-article-various)
473 (defcustom gnus-article-mode-hook nil
474 "*A hook for Gnus article mode."
476 :group 'gnus-article-various)
478 (defcustom gnus-article-menu-hook nil
479 "*Hook run after the creation of the article mode menu."
481 :group 'gnus-article-various)
483 (defcustom gnus-article-prepare-hook nil
484 "*A hook called after an article has been prepared in the article buffer."
486 :group 'gnus-article-various)
488 (defcustom gnus-article-hide-pgp-hook nil
489 "*A hook called after successfully hiding a PGP signature."
491 :group 'gnus-article-various)
493 (defcustom gnus-article-button-face 'bold
494 "Face used for highlighting buttons in the article buffer.
496 An article button is a piece of text that you can activate by pressing
497 `RET' or `mouse-2' above it."
499 :group 'gnus-article-buttons)
501 (defcustom gnus-article-mouse-face 'highlight
502 "Face used for mouse highlighting in the article buffer.
504 Article buttons will be displayed in this face when the cursor is
507 :group 'gnus-article-buttons)
509 (defcustom gnus-signature-face 'gnus-signature-face
510 "Face used for highlighting a signature in the article buffer.
511 Obsolete; use the face `gnus-signature-face' for customizations instead."
513 :group 'gnus-article-highlight
514 :group 'gnus-article-signature)
516 (defface gnus-signature-face
519 "Face used for highlighting a signature in the article buffer."
520 :group 'gnus-article-highlight
521 :group 'gnus-article-signature)
523 (defface gnus-header-from-face
526 (:foreground "spring green"))
529 (:foreground "red3"))
532 "Face used for displaying from headers."
533 :group 'gnus-article-headers
534 :group 'gnus-article-highlight)
536 (defface gnus-header-subject-face
539 (:foreground "SeaGreen3"))
542 (:foreground "red4"))
544 (:bold t :italic t)))
545 "Face used for displaying subject headers."
546 :group 'gnus-article-headers
547 :group 'gnus-article-highlight)
549 (defface gnus-header-newsgroups-face
552 (:foreground "yellow" :italic t))
555 (:foreground "MidnightBlue" :italic t))
558 "Face used for displaying newsgroups headers."
559 :group 'gnus-article-headers
560 :group 'gnus-article-highlight)
562 (defface gnus-header-name-face
565 (:foreground "SeaGreen"))
568 (:foreground "maroon"))
571 "Face used for displaying header names."
572 :group 'gnus-article-headers
573 :group 'gnus-article-highlight)
575 (defface gnus-header-content-face
578 (:foreground "forest green" :italic t))
581 (:foreground "indianred4" :italic t))
583 (:italic t))) "Face used for displaying header content."
584 :group 'gnus-article-headers
585 :group 'gnus-article-highlight)
587 (defcustom gnus-header-face-alist
588 '(("From" nil gnus-header-from-face)
589 ("Subject" nil gnus-header-subject-face)
590 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
591 ("" gnus-header-name-face gnus-header-content-face))
592 "*Controls highlighting of article header.
594 An alist of the form (HEADER NAME CONTENT).
596 HEADER is a regular expression which should match the name of an
597 header header and NAME and CONTENT are either face names or nil.
599 The name of each header field will be displayed using the face
600 specified by the first element in the list where HEADER match the
601 header name and NAME is non-nil. Similarly, the content will be
602 displayed by the first non-nil matching CONTENT face."
603 :group 'gnus-article-headers
604 :group 'gnus-article-highlight
605 :type '(repeat (list (regexp :tag "Header")
607 (item :tag "skip" nil)
608 (face :value default))
609 (choice :tag "Content"
610 (item :tag "skip" nil)
611 (face :value default)))))
613 (defcustom gnus-article-decode-hook nil
614 "*Hook run to decode charsets in articles."
615 :group 'gnus-article-headers
618 (defcustom gnus-display-mime-function 'gnus-display-mime
619 "Function to display MIME articles."
620 :group 'gnus-article-mime
623 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
624 "Function used to decode headers.")
626 (defvar gnus-article-dumbquotes-map
644 "Table for MS-to-Latin1 translation.")
646 (defcustom gnus-ignored-mime-types nil
647 "List of MIME types that should be ignored by Gnus."
648 :group 'gnus-article-mime
649 :type '(repeat regexp))
651 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
652 "List of MIME types that should not be given buttons when rendered inline."
653 :group 'gnus-article-mime
654 :type '(repeat regexp))
656 (defcustom gnus-article-mime-part-function nil
657 "Function called with a MIME handle as the argument.
658 This is meant for people who want to do something automatic based
659 on parts -- for instance, adding Vcard info to a database."
660 :group 'gnus-article-mime
663 (defcustom gnus-mime-multipart-functions nil
664 "An alist of MIME types to functions to display them.")
666 (defcustom gnus-article-date-lapsed-new-header nil
667 "Whether the X-Sent and Date headers can coexist.
668 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
669 either replace the old \"Date:\" header (if this variable is nil), or
670 be added below it (otherwise)."
671 :group 'gnus-article-headers
674 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
675 "Function called with a MIME handle as the argument.
676 This is meant for people who want to view first matched part.
677 For `undisplayed-alternative' (default), the first undisplayed
678 part or alternative part is used. For `undisplayed', the first
679 undisplayed part is used. For a function, the first part which
680 the function return `t' is used. For `nil', the first part is
682 :group 'gnus-article-mime
684 (item :tag "first" :value nil)
685 (item :tag "undisplayed" :value undisplayed)
686 (item :tag "undisplayed or alternative"
687 :value undisplayed-alternative)
690 (defcustom gnus-mime-action-alist
691 '(("save to file" . gnus-mime-save-part)
692 ("save and strip" . gnus-mime-save-part-and-strip)
693 ("display as text" . gnus-mime-inline-part)
694 ("view the part" . gnus-mime-view-part)
695 ("pipe to command" . gnus-mime-pipe-part)
696 ("toggle display" . gnus-article-press-button)
697 ("toggle display" . gnus-article-view-part-as-charset)
698 ("view as type" . gnus-mime-view-part-as-type)
699 ("internalize type" . gnus-mime-internalize-part)
700 ("externalize type" . gnus-mime-externalize-part))
701 "An alist of actions that run on the MIME attachment."
702 :group 'gnus-article-mime
703 :type '(repeat (cons (string :tag "name")
707 ;;; The treatment variables
710 (defvar gnus-part-display-hook nil
711 "Hook called on parts that are to receive treatment.")
713 (defvar gnus-article-treat-custom
714 '(choice (const :tag "Off" nil)
716 (const :tag "Header" head)
717 (const :tag "Last" last)
718 (const :tag "Mime" mime)
719 (integer :tag "Less")
720 (repeat :tag "Groups" regexp)
721 (sexp :tag "Predicate")))
723 (defvar gnus-article-treat-head-custom
724 '(choice (const :tag "Off" nil)
725 (const :tag "Header" head)))
727 (defvar gnus-article-treat-types '("text/plain")
730 (defvar gnus-inhibit-treatment nil
731 "Whether to inhibit treatment.")
733 (defcustom gnus-treat-highlight-signature '(or last (typep "text/x-vcard"))
734 "Highlight the signature.
735 Valid values are nil, t, `head', `last', an integer or a predicate.
736 See the manual for details."
737 :group 'gnus-article-treat
738 :type gnus-article-treat-custom)
739 (put 'gnus-treat-highlight-signature 'highlight t)
741 (defcustom gnus-treat-buttonize 100000
743 Valid values are nil, t, `head', `last', an integer or a predicate.
744 See the manual for details."
745 :group 'gnus-article-treat
746 :type gnus-article-treat-custom)
747 (put 'gnus-treat-buttonize 'highlight t)
749 (defcustom gnus-treat-buttonize-head 'head
750 "Add buttons to the head.
751 Valid values are nil, t, `head', `last', an integer or a predicate.
752 See the manual for details."
753 :group 'gnus-article-treat
754 :type gnus-article-treat-head-custom)
755 (put 'gnus-treat-buttonize-head 'highlight t)
757 (defcustom gnus-treat-emphasize nil
759 Valid values are nil, t, `head', `last', an integer or a predicate.
760 See the manual for details."
761 :group 'gnus-article-treat
762 :type gnus-article-treat-custom)
763 (put 'gnus-treat-emphasize 'highlight t)
765 (defcustom gnus-treat-strip-cr nil
766 "Remove carriage returns.
767 Valid values are nil, t, `head', `last', an integer or a predicate.
768 See the manual for details."
769 :group 'gnus-article-treat
770 :type gnus-article-treat-custom)
772 (defcustom gnus-treat-hide-headers 'head
774 Valid values are nil, t, `head', `last', an integer or a predicate.
775 See the manual for details."
776 :group 'gnus-article-treat
777 :type gnus-article-treat-head-custom)
779 (defcustom gnus-treat-hide-boring-headers nil
780 "Hide boring headers.
781 Valid values are nil, t, `head', `last', an integer or a predicate.
782 See the manual for details."
783 :group 'gnus-article-treat
784 :type gnus-article-treat-head-custom)
786 (defcustom gnus-treat-hide-signature nil
788 Valid values are nil, t, `head', `last', an integer or a predicate.
789 See the manual for details."
790 :group 'gnus-article-treat
791 :type gnus-article-treat-custom)
793 (defcustom gnus-treat-fill-article nil
795 Valid values are nil, t, `head', `last', an integer or a predicate.
796 See the manual for details."
797 :group 'gnus-article-treat
798 :type gnus-article-treat-custom)
800 (defcustom gnus-treat-hide-citation nil
802 Valid values are nil, t, `head', `last', an integer or a predicate.
803 See the manual for details."
804 :group 'gnus-article-treat
805 :type gnus-article-treat-custom)
807 (defcustom gnus-treat-hide-citation-maybe nil
809 Valid values are nil, t, `head', `last', an integer or a predicate.
810 See the manual for details."
811 :group 'gnus-article-treat
812 :type gnus-article-treat-custom)
814 (defcustom gnus-treat-strip-list-identifiers 'head
815 "Strip list identifiers from `gnus-list-identifiers`.
816 Valid values are nil, t, `head', `last', an integer or a predicate.
817 See the manual for details."
818 :group 'gnus-article-treat
819 :type gnus-article-treat-custom)
821 (defcustom gnus-treat-strip-pgp t
822 "Strip PGP signatures.
823 Valid values are nil, t, `head', `last', an integer or a predicate.
824 See the manual for details."
825 :group 'gnus-article-treat
826 :type gnus-article-treat-custom)
828 (defcustom gnus-treat-strip-pem nil
829 "Strip PEM signatures.
830 Valid values are nil, t, `head', `last', an integer or a predicate.
831 See the manual for details."
832 :group 'gnus-article-treat
833 :type gnus-article-treat-custom)
835 (defcustom gnus-treat-strip-banner t
836 "Strip banners from articles.
837 The banner to be stripped is specified in the `banner' group parameter.
838 Valid values are nil, t, `head', `last', an integer or a predicate.
839 See the manual for details."
840 :group 'gnus-article-treat
841 :type gnus-article-treat-custom)
843 (defcustom gnus-treat-highlight-headers 'head
844 "Highlight the headers.
845 Valid values are nil, t, `head', `last', an integer or a predicate.
846 See the manual for details."
847 :group 'gnus-article-treat
848 :type gnus-article-treat-head-custom)
849 (put 'gnus-treat-highlight-headers 'highlight t)
851 (defcustom gnus-treat-highlight-citation t
852 "Highlight cited text.
853 Valid values are nil, t, `head', `last', an integer or a predicate.
854 See the manual for details."
855 :group 'gnus-article-treat
856 :type gnus-article-treat-custom)
857 (put 'gnus-treat-highlight-citation 'highlight t)
859 (defcustom gnus-treat-date-ut nil
860 "Display the Date in UT (GMT).
861 Valid values are nil, t, `head', `last', an integer or a predicate.
862 See the manual for details."
863 :group 'gnus-article-treat
864 :type gnus-article-treat-head-custom)
866 (defcustom gnus-treat-date-local nil
867 "Display the Date in the local timezone.
868 Valid values are nil, t, `head', `last', an integer or a predicate.
869 See the manual for details."
870 :group 'gnus-article-treat
871 :type gnus-article-treat-head-custom)
873 (defcustom gnus-treat-date-lapsed nil
874 "Display the Date header in a way that says how much time has elapsed.
875 Valid values are nil, t, `head', `last', an integer or a predicate.
876 See the manual for details."
877 :group 'gnus-article-treat
878 :type gnus-article-treat-head-custom)
880 (defcustom gnus-treat-date-original nil
881 "Display the date in the original timezone.
882 Valid values are nil, t, `head', `last', an integer or a predicate.
883 See the manual for details."
884 :group 'gnus-article-treat
885 :type gnus-article-treat-head-custom)
887 (defcustom gnus-treat-date-iso8601 nil
888 "Display the date in the ISO8601 format.
889 Valid values are nil, t, `head', `last', an integer or a predicate.
890 See the manual for details."
891 :group 'gnus-article-treat
892 :type gnus-article-treat-head-custom)
894 (defcustom gnus-treat-date-user-defined nil
895 "Display the date in a user-defined format.
896 The format is defined by the `gnus-article-time-format' variable.
897 Valid values are nil, t, `head', `last', an integer or a predicate.
898 See the manual for details."
899 :group 'gnus-article-treat
900 :type gnus-article-treat-head-custom)
902 (defcustom gnus-treat-strip-headers-in-body t
903 "Strip the X-No-Archive header line from the beginning of the body.
904 Valid values are nil, t, `head', `last', an integer or a predicate.
905 See the manual for details."
906 :group 'gnus-article-treat
907 :type gnus-article-treat-custom)
909 (defcustom gnus-treat-strip-trailing-blank-lines nil
910 "Strip trailing blank lines.
911 Valid values are nil, t, `head', `last', an integer or a predicate.
912 See the manual for details."
913 :group 'gnus-article-treat
914 :type gnus-article-treat-custom)
916 (defcustom gnus-treat-strip-leading-blank-lines nil
917 "Strip leading blank lines.
918 Valid values are nil, t, `head', `last', an integer or a predicate.
919 See the manual for details."
920 :group 'gnus-article-treat
921 :type gnus-article-treat-custom)
923 (defcustom gnus-treat-strip-multiple-blank-lines nil
924 "Strip multiple blank lines.
925 Valid values are nil, t, `head', `last', an integer or a predicate.
926 See the manual for details."
927 :group 'gnus-article-treat
928 :type gnus-article-treat-custom)
930 (defcustom gnus-treat-overstrike t
931 "Treat overstrike highlighting.
932 Valid values are nil, t, `head', `last', an integer or a predicate.
933 See the manual for details."
934 :group 'gnus-article-treat
935 :type gnus-article-treat-custom)
936 (put 'gnus-treat-overstrike 'highlight t)
938 (defcustom gnus-treat-display-xface
939 (and (or (and (fboundp 'image-type-available-p)
940 (image-type-available-p 'xbm)
941 (string-match "^0x" (shell-command-to-string "uncompface")))
942 (and (featurep 'xemacs) (featurep 'xface))
943 (eq 'x-face-mule-gnus-article-display-x-face
944 gnus-article-x-face-command))
946 "Display X-Face headers.
947 Valid values are nil, t, `head', `last', an integer or a predicate.
948 See the manual for details."
949 :group 'gnus-article-treat
950 :type gnus-article-treat-head-custom)
951 (put 'gnus-treat-display-xface 'highlight t)
953 (defcustom gnus-treat-display-smileys
954 (if (or (and (featurep 'xemacs)
956 (and (fboundp 'image-type-available-p)
957 (image-type-available-p 'pbm))
958 (and (not (featurep 'xemacs))
960 (module-installed-p 'gnus-bitmap)))
964 Valid values are nil, t, `head', `last', an integer or a predicate.
965 See the manual for details."
966 :group 'gnus-article-treat
967 :type gnus-article-treat-custom)
968 (put 'gnus-treat-display-smileys 'highlight t)
970 (defcustom gnus-treat-display-picons (if (featurep 'xemacs) 'head nil)
972 Valid values are nil, t, `head', `last', an integer or a predicate.
973 See the manual for details."
974 :group 'gnus-article-treat
975 :type gnus-article-treat-head-custom)
976 (put 'gnus-treat-display-picons 'highlight t)
978 (defcustom gnus-treat-capitalize-sentences nil
979 "Capitalize sentence-starting words.
980 Valid values are nil, t, `head', `last', an integer or a predicate.
981 See the manual for details."
982 :group 'gnus-article-treat
983 :type gnus-article-treat-custom)
985 (defcustom gnus-treat-fill-long-lines nil
987 Valid values are nil, t, `head', `last', an integer or a predicate.
988 See the manual for details."
989 :group 'gnus-article-treat
990 :type gnus-article-treat-custom)
992 (defcustom gnus-treat-play-sounds nil
994 Valid values are nil, t, `head', `last', an integer or a predicate.
995 See the manual for details."
996 :group 'gnus-article-treat
997 :type gnus-article-treat-custom)
999 (defcustom gnus-treat-decode-article-as-default-mime-charset nil
1000 "Decode an article as `default-mime-charset'. For instance, if you want to
1001 attempt to decode an article even if the value of `gnus-show-mime' is nil,
1002 you could set this variable to something like: nil for don't decode, t for
1003 decode the body, '(or header t) for the whole article, etc."
1004 :group 'gnus-article-treat
1005 :type '(radio (const :tag "Off" nil)
1006 (const :tag "Decode body" t)
1007 (const :tag "Decode all" (or head t))))
1009 (defcustom gnus-treat-translate nil
1010 "Translate articles from one language to another.
1011 Valid values are nil, t, `head', `last', an integer or a predicate.
1012 See the manual for details."
1013 :group 'gnus-article-treat
1014 :type gnus-article-treat-custom)
1016 (defvar gnus-article-encrypt-protocol-alist
1017 '(("PGP" . mml2015-self-encrypt)))
1019 ;; Set to nil if more than one protocol added to
1020 ;; gnus-article-encrypt-protocol-alist.
1021 (defcustom gnus-article-encrypt-protocol "PGP"
1022 "The protocol used for encrypt articles.
1023 It is a string, such as \"PGP\". If nil, ask user."
1025 :group 'mime-security)
1027 ;;; Internal variables
1029 (defvar article-goto-body-goes-to-point-min-p nil)
1030 (defvar gnus-article-wash-types nil)
1031 (defvar gnus-article-emphasis-alist nil)
1033 (defvar gnus-article-mime-handle-alist-1 nil)
1034 (defvar gnus-treatment-function-alist
1035 '((gnus-treat-decode-article-as-default-mime-charset
1036 gnus-article-decode-article-as-default-mime-charset)
1037 (gnus-treat-strip-banner gnus-article-strip-banner)
1038 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1039 (gnus-treat-buttonize gnus-article-add-buttons)
1040 (gnus-treat-fill-article gnus-article-fill-cited-article)
1041 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1042 (gnus-treat-strip-cr gnus-article-remove-cr)
1043 (gnus-treat-display-xface gnus-article-display-x-face)
1044 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1045 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1046 (gnus-treat-hide-signature gnus-article-hide-signature)
1047 (gnus-treat-hide-citation gnus-article-hide-citation)
1048 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1049 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1050 (gnus-treat-strip-pgp gnus-article-hide-pgp)
1051 (gnus-treat-strip-pem gnus-article-hide-pem)
1052 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1053 (gnus-treat-emphasize gnus-article-emphasize)
1054 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1055 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1056 (gnus-treat-date-ut gnus-article-date-ut)
1057 (gnus-treat-date-local gnus-article-date-local)
1058 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1059 (gnus-treat-date-original gnus-article-date-original)
1060 (gnus-treat-date-user-defined gnus-article-date-user)
1061 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1062 (gnus-treat-strip-trailing-blank-lines
1063 gnus-article-remove-trailing-blank-lines)
1064 (gnus-treat-strip-leading-blank-lines
1065 gnus-article-strip-leading-blank-lines)
1066 (gnus-treat-strip-multiple-blank-lines
1067 gnus-article-strip-multiple-blank-lines)
1068 (gnus-treat-overstrike gnus-article-treat-overstrike)
1069 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1070 (gnus-treat-display-smileys gnus-article-smiley-display)
1071 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1072 (gnus-treat-display-picons gnus-article-display-picons)
1073 (gnus-treat-play-sounds gnus-earcon-display)))
1075 (defvar gnus-article-mime-handle-alist nil)
1076 (defvar article-lapsed-timer nil)
1077 (defvar gnus-article-current-summary nil)
1079 (defvar gnus-article-mode-syntax-table
1080 (let ((table (copy-syntax-table text-mode-syntax-table)))
1081 (modify-syntax-entry ?- "w" table)
1082 (modify-syntax-entry ?> ")" table)
1083 (modify-syntax-entry ?< "(" table)
1085 "Syntax table used in article mode buffers.
1086 Initialized from `text-mode-syntax-table.")
1088 (defvar gnus-save-article-buffer nil)
1090 (defvar gnus-article-mode-line-format-alist
1091 (nconc '((?w (gnus-article-wash-status) ?s)
1092 (?m (gnus-article-mime-part-status) ?s))
1093 gnus-summary-mode-line-format-alist))
1095 (defvar gnus-number-of-articles-to-be-saved nil)
1097 (defvar gnus-inhibit-hiding nil)
1099 (defsubst gnus-article-hide-text (b e props)
1100 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1101 (add-text-properties b e props)
1102 (when (memq 'intangible props)
1104 (max (1- b) (point-min))
1105 b 'intangible (cddr (memq 'intangible props)))))
1106 (defsubst gnus-article-unhide-text (b e)
1107 "Remove hidden text properties from region between B and E."
1108 (remove-text-properties b e gnus-hidden-properties)
1109 (when (memq 'intangible gnus-hidden-properties)
1110 (put-text-property (max (1- b) (point-min))
1111 b 'intangible nil)))
1113 (defun gnus-article-hide-text-type (b e type)
1114 "Hide text of TYPE between B and E."
1115 (push type gnus-article-wash-types)
1116 (gnus-article-hide-text
1117 b e (cons 'article-type (cons type gnus-hidden-properties))))
1119 (defun gnus-article-unhide-text-type (b e type)
1120 "Unhide text of TYPE between B and E."
1121 (setq gnus-article-wash-types
1122 (delq type gnus-article-wash-types))
1123 (remove-text-properties
1124 b e (cons 'article-type (cons type gnus-hidden-properties)))
1125 (when (memq 'intangible gnus-hidden-properties)
1126 (put-text-property (max (1- b) (point-min))
1127 b 'intangible nil)))
1129 (defun gnus-article-hide-text-of-type (type)
1130 "Hide text of TYPE in the current buffer."
1132 (let ((b (point-min))
1134 (while (setq b (text-property-any b e 'article-type type))
1135 (add-text-properties b (incf b) gnus-hidden-properties)))))
1137 (defun gnus-article-delete-text-of-type (type)
1138 "Delete text of TYPE in the current buffer."
1140 (let ((b (point-min)))
1141 (while (setq b (text-property-any b (point-max) 'article-type type))
1143 b (or (text-property-not-all b (point-max) 'article-type type)
1146 (defun gnus-article-delete-invisible-text ()
1147 "Delete all invisible text in the current buffer."
1149 (let ((b (point-min)))
1150 (while (setq b (text-property-any b (point-max) 'invisible t))
1152 b (or (text-property-not-all b (point-max) 'invisible t)
1155 (defun gnus-article-text-type-exists-p (type)
1156 "Say whether any text of type TYPE exists in the buffer."
1157 (text-property-any (point-min) (point-max) 'article-type type))
1159 (defsubst gnus-article-header-rank ()
1160 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1161 (let ((list gnus-sorted-header-list)
1164 (when (looking-at (car list))
1166 (setq list (cdr list))
1170 (defun article-hide-headers (&optional arg delete)
1171 "Hide unwanted headers and possibly sort them as well."
1172 (interactive (gnus-article-hidden-arg))
1173 ;; Lars said that this function might be inhibited.
1174 (if (gnus-article-check-hidden-text 'headers arg)
1176 ;; Show boring headers as well.
1177 (gnus-article-show-hidden-text 'boring-headers)
1178 (when (eq 1 (point-min))
1179 (set-window-start (get-buffer-window (current-buffer)) 1)))
1180 (unless gnus-inhibit-hiding
1183 (let ((buffer-read-only nil)
1184 (inhibit-read-only t)
1185 (case-fold-search t)
1186 (max (1+ (length gnus-sorted-header-list)))
1187 (ignored (when (not gnus-visible-headers)
1188 (cond ((stringp gnus-ignored-headers)
1189 gnus-ignored-headers)
1190 ((listp gnus-ignored-headers)
1191 (mapconcat 'identity gnus-ignored-headers
1194 (cond ((stringp gnus-visible-headers)
1195 gnus-visible-headers)
1196 ((and gnus-visible-headers
1197 (listp gnus-visible-headers))
1198 (mapconcat 'identity gnus-visible-headers "\\|"))))
1199 (inhibit-point-motion-hooks t)
1201 ;; First we narrow to just the headers.
1202 (article-narrow-to-head)
1203 ;; Hide any "From " lines at the beginning of (mail) articles.
1204 (while (looking-at "From ")
1208 (delete-region (point-min) (point))
1209 (gnus-article-hide-text (point-min) (point)
1210 (nconc (list 'article-type 'headers)
1211 gnus-hidden-properties))))
1212 ;; Then treat the rest of the header lines.
1213 ;; Then we use the two regular expressions
1214 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1215 ;; select which header lines is to remain visible in the
1217 (while (re-search-forward "^[^ \t]*:" nil t)
1219 ;; Mark the rank of the header.
1221 (point) (1+ (point)) 'message-rank
1222 (if (or (and visible (looking-at visible))
1224 (not (looking-at ignored))))
1225 (gnus-article-header-rank)
1228 (message-sort-headers-1)
1229 (when (setq beg (text-property-any
1230 (point-min) (point-max) 'message-rank (+ 2 max)))
1231 ;; We delete or make invisible the unwanted headers.
1232 (push 'headers gnus-article-wash-types)
1235 (add-text-properties
1236 (point-min) (+ 5 (point-min))
1237 '(article-type headers dummy-invisible t))
1238 (delete-region beg (point-max)))
1239 (gnus-article-hide-text-type beg (point-max) 'headers))))))))
1242 (defun article-hide-boring-headers (&optional arg)
1243 "Toggle hiding of headers that aren't very interesting.
1244 If given a negative prefix, always show; if given a positive prefix,
1246 (interactive (gnus-article-hidden-arg))
1247 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1248 (not gnus-show-all-headers))
1251 (let ((buffer-read-only nil)
1252 (list gnus-boring-article-headers)
1253 (inhibit-point-motion-hooks t)
1255 (article-narrow-to-head)
1257 (setq elem (pop list))
1258 (goto-char (point-min))
1260 ;; Hide empty headers.
1262 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1264 (gnus-article-hide-text-type
1265 (progn (beginning-of-line) (point))
1268 (if (re-search-forward "^[^ \t]" nil t)
1272 ;; Hide boring Newsgroups header.
1273 ((eq elem 'newsgroups)
1274 (when (equal (gnus-fetch-field "newsgroups")
1275 (gnus-group-real-name
1276 (if (boundp 'gnus-newsgroup-name)
1279 (gnus-article-hide-header "newsgroups")))
1280 ((eq elem 'followup-to)
1281 (when (equal (message-fetch-field "followup-to")
1282 (message-fetch-field "newsgroups"))
1283 (gnus-article-hide-header "followup-to")))
1284 ((eq elem 'reply-to)
1285 (let ((from (message-fetch-field "from"))
1286 (reply-to (message-fetch-field "reply-to")))
1291 (nth 1 (funcall gnus-extract-address-components from))
1292 (nth 1 (funcall gnus-extract-address-components reply-to)))))
1293 (gnus-article-hide-header "reply-to"))))
1295 (let ((date (message-fetch-field "date")))
1297 (< (days-between (current-time-string) date)
1299 (gnus-article-hide-header "date"))))
1301 (let ((to (message-fetch-field "to"))
1302 (cc (message-fetch-field "cc")))
1303 (when (> (length to) 1024)
1304 (gnus-article-hide-header "to"))
1305 (when (> (length cc) 1024)
1306 (gnus-article-hide-header "cc"))))
1310 (goto-char (point-min))
1311 (while (re-search-forward "^to:" nil t)
1312 (setq to-count (1+ to-count)))
1313 (when (> to-count 1)
1314 (while (> to-count 0)
1315 (goto-char (point-min))
1317 (re-search-forward "^to:" nil nil to-count)
1319 (narrow-to-region (point) (point-max))
1320 (gnus-article-hide-header "to"))
1321 (setq to-count (1- to-count))))
1322 (goto-char (point-min))
1323 (while (re-search-forward "^cc:" nil t)
1324 (setq cc-count (1+ cc-count)))
1325 (when (> cc-count 1)
1326 (while (> cc-count 0)
1327 (goto-char (point-min))
1329 (re-search-forward "^cc:" nil nil cc-count)
1331 (narrow-to-region (point) (point-max))
1332 (gnus-article-hide-header "cc"))
1333 (setq cc-count (1- cc-count)))))))))))))
1335 (defun gnus-article-hide-header (header)
1337 (goto-char (point-min))
1338 (when (re-search-forward (concat "^" header ":") nil t)
1339 (gnus-article-hide-text-type
1340 (progn (beginning-of-line) (point))
1343 (if (re-search-forward "^[^ \t]" nil t)
1348 (defun article-toggle-headers (&optional arg)
1349 "Toggle hiding of headers. If given a negative prefix, always show;
1350 if given a positive prefix, always hide."
1351 (interactive (gnus-article-hidden-arg))
1352 (let ((force (when (numberp arg)
1353 (cond ((> arg 0) 'always-hide)
1354 ((< arg 0) 'always-show))))
1355 (window (get-buffer-window gnus-article-buffer))
1356 (header-end (point-min))
1357 header-start field-end field-start
1358 (inhibit-point-motion-hooks t)
1359 (inhibit-read-only t)
1363 (while (and (setq header-start
1364 (text-property-any header-end (point-max)
1365 'article-treated-header t))
1367 (text-property-not-all header-start (point-max)
1368 'article-treated-header t)))
1369 (setq field-end header-start)
1371 (;; Hide exposed invisible fields.
1372 (and (not (eq 'always-show force))
1374 (text-property-any field-end header-end
1375 'exposed-invisible-field t)))
1376 (while (and field-start
1377 (setq field-end (text-property-not-all
1378 field-start header-end
1379 'exposed-invisible-field t)))
1380 (add-text-properties field-start field-end gnus-hidden-properties)
1381 (setq field-start (text-property-any field-end header-end
1382 'exposed-invisible-field t)))
1383 (put-text-property header-start header-end
1384 'exposed-invisible-field nil))
1385 (;; Expose invisible fields.
1386 (and (not (eq 'always-hide force))
1388 (text-property-any field-end header-end 'invisible t)))
1389 (while (and field-start
1390 (setq field-end (text-property-not-all
1391 field-start header-end
1393 ;; If the invisible text is not terminated with newline, we
1394 ;; won't expose it. Because it may be created by x-face-mule.
1395 ;; BTW, XEmacs sometimes fail in putting a invisible text
1396 ;; property with `gnus-article-hide-text' (really?). In that
1397 ;; case, the invisible text might be started from the middle of
1398 ;; a line so we will expose the sort of thing.
1399 (when (or (not (or (eq header-start field-start)
1400 (eq ?\n (char-before field-start))))
1401 (eq ?\n (char-before field-end)))
1402 (remove-text-properties field-start field-end
1403 gnus-hidden-properties)
1404 (put-text-property field-start field-end
1405 'exposed-invisible-field t))
1406 (setq field-start (text-property-any field-end header-end
1409 (not (eq 'always-show force))
1410 (narrow-to-region header-start header-end)
1411 (article-hide-headers)
1412 ;; Re-display X-Face image under XEmacs.
1413 (when (and (featurep 'xemacs)
1414 (gnus-functionp gnus-article-x-face-command))
1415 (let ((func (cadr (assq 'gnus-treat-display-xface
1416 gnus-treatment-function-alist)))
1418 (when (and (not gnus-inhibit-treatment)
1420 (gnus-treat-predicate gnus-treat-display-xface))
1422 (put-text-property header-start header-end 'read-only nil))))
1425 (goto-char (point-min))
1427 (set-window-start window (point-min))))))
1429 (defvar gnus-article-normalized-header-length 40
1430 "Length of normalized headers.")
1432 (defun article-normalize-headers ()
1433 "Make all header lines 40 characters long."
1435 (let ((buffer-read-only nil)
1439 (article-narrow-to-head)
1442 ((< (setq column (- (gnus-point-at-eol) (point)))
1443 gnus-article-normalized-header-length)
1445 (insert (make-string
1446 (- gnus-article-normalized-header-length column)
1448 ((> column gnus-article-normalized-header-length)
1449 (gnus-put-text-property
1451 (forward-char gnus-article-normalized-header-length)
1458 (forward-line 1))))))
1460 (defun article-treat-dumbquotes ()
1461 "Translate M******** sm*rtq**t*s into proper text.
1462 Note that this function guesses whether a character is a sm*rtq**t* or
1463 not, so it should only be used interactively."
1465 (article-translate-strings gnus-article-dumbquotes-map))
1467 (defun article-translate-characters (from to)
1468 "Translate all characters in the body of the article according to FROM and TO.
1469 FROM is a string of characters to translate from; to is a string of
1470 characters to translate to."
1472 (when (article-goto-body)
1473 (let ((buffer-read-only nil)
1474 (x (make-string 225 ?x))
1476 (while (< (incf i) (length x))
1479 (while (< i (length from))
1480 (aset x (aref from i) (aref to i))
1482 (translate-region (point) (point-max) x)))))
1484 (defun article-translate-strings (map)
1485 "Translate all string in the body of the article according to MAP.
1486 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1488 (when (article-goto-body)
1489 (let ((buffer-read-only nil)
1491 (while (setq elem (pop map))
1493 (while (search-forward (car elem) nil t)
1494 (replace-match (cadr elem)))))))))
1496 (defun article-treat-overstrike ()
1497 "Translate overstrikes into bold text."
1500 (when (article-goto-body)
1501 (let ((buffer-read-only nil))
1502 (while (search-forward "\b" nil t)
1503 (let ((next (char-after))
1507 previous (char-after))
1511 ;; We do the boldification/underlining by hiding the
1512 ;; overstrikes and putting the proper text property
1516 (gnus-article-hide-text-type start (point) 'overstrike)
1517 (put-text-property (point) end 'face 'bold))
1519 (gnus-article-hide-text-type
1520 (1- (point)) (1+ (point)) 'overstrike)
1522 start (1- (point)) 'face 'underline))
1524 (gnus-article-hide-text-type start (point) 'overstrike)
1526 (point) end 'face 'underline)))))))))
1528 (defun article-fill-long-lines ()
1529 "Fill lines that are wider than the window width."
1532 (let ((buffer-read-only nil)
1533 (width (window-width (get-buffer-window (current-buffer)))))
1536 (let ((adaptive-fill-mode nil))
1539 (when (>= (current-column) (min fill-column width))
1540 (narrow-to-region (point) (gnus-point-at-bol))
1541 (fill-paragraph nil)
1542 (goto-char (point-max))
1544 (forward-line 1)))))))
1546 (defun article-capitalize-sentences ()
1547 "Capitalize the first word in each sentence."
1550 (let ((buffer-read-only nil)
1551 (paragraph-start "^[\n\^L]"))
1555 (forward-sentence)))))
1557 (defun article-remove-cr ()
1558 "Remove trailing CRs and then translate remaining CRs into LFs."
1561 (let ((buffer-read-only nil))
1562 (goto-char (point-min))
1563 (while (re-search-forward "\r+$" nil t)
1564 (replace-match "" t t))
1565 (goto-char (point-min))
1566 (while (search-forward "\r" nil t)
1567 (replace-match "\n" t t)))))
1569 (defun article-remove-trailing-blank-lines ()
1570 "Remove all trailing blank lines from the article."
1573 (let ((buffer-read-only nil))
1574 (goto-char (point-max))
1578 (while (and (not (bobp))
1579 (looking-at "^[ \t]*$")
1580 (not (gnus-annotation-in-region-p
1581 (point) (gnus-point-at-eol))))
1586 (defun article-display-x-face (&optional force)
1587 "Look for an X-Face header and display it if present."
1588 (interactive (list 'force))
1590 ;; Delete the old process, if any.
1591 (when (process-status "article-x-face")
1592 (delete-process "article-x-face"))
1593 (let ((inhibit-point-motion-hooks t)
1594 (case-fold-search t)
1597 (article-narrow-to-head)
1598 (goto-char (point-min))
1599 (setq from (message-fetch-field "from"))
1600 (goto-char (point-min))
1601 (while (and gnus-article-x-face-command
1604 ;; Check whether this face is censored.
1605 (not gnus-article-x-face-too-ugly)
1606 (and gnus-article-x-face-too-ugly from
1607 (not (string-match gnus-article-x-face-too-ugly
1609 ;; Has to be present.
1610 (re-search-forward "^X-Face:[ \t]*" nil t))
1611 ;; This used to try to do multiple faces (`while' instead of
1612 ;; `when' above), but (a) sending multiple EOFs to xv doesn't
1613 ;; work (b) it can crash some versions of Emacs (c) are
1614 ;; multiple faces really something to encourage?
1615 (when (stringp gnus-article-x-face-command)
1617 ;; We now have the area of the buffer where the X-Face is stored.
1620 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
1621 ;; We display the face.
1622 (if (symbolp gnus-article-x-face-command)
1623 ;; The command is a lisp function, so we call it.
1624 (if (gnus-functionp gnus-article-x-face-command)
1625 (funcall gnus-article-x-face-command beg end)
1626 (error "%s is not a function" gnus-article-x-face-command))
1627 ;; The command is a string, so we interpret the command
1628 ;; as a, well, command, and fork it off.
1629 (let ((process-connection-type nil))
1630 (process-kill-without-query
1632 "article-x-face" nil shell-file-name shell-command-switch
1633 gnus-article-x-face-command))
1634 (process-send-region "article-x-face" beg end)
1635 (process-send-eof "article-x-face"))))))))))
1637 (defun article-decode-mime-words ()
1638 "Decode all MIME-encoded words in the article."
1641 (set-buffer gnus-article-buffer)
1642 (let ((inhibit-point-motion-hooks t)
1644 (mail-parse-charset gnus-newsgroup-charset)
1645 (mail-parse-ignored-charsets
1646 (save-excursion (set-buffer gnus-summary-buffer)
1647 gnus-newsgroup-ignored-charsets)))
1648 (mail-decode-encoded-word-region (point-min) (point-max)))))
1650 (defun article-decode-charset (&optional prompt)
1651 "Decode charset-encoded text in the article.
1652 If PROMPT (the prefix), prompt for a coding system to use."
1654 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
1656 (mail-parse-charset gnus-newsgroup-charset)
1657 (mail-parse-ignored-charsets
1658 (save-excursion (condition-case nil
1659 (set-buffer gnus-summary-buffer)
1661 gnus-newsgroup-ignored-charsets))
1662 ct cte ctl charset format)
1665 (article-narrow-to-head)
1666 (setq ct (message-fetch-field "Content-Type" t)
1667 cte (message-fetch-field "Content-Transfer-Encoding" t)
1668 ctl (and ct (ignore-errors
1669 (mail-header-parse-content-type ct)))
1672 (mm-read-coding-system "Charset to decode: "))
1674 (mail-content-type-get ctl 'charset)))
1675 format (and ctl (mail-content-type-get ctl 'format)))
1677 (setq cte (mail-header-strip cte)))
1678 (if (and ctl (not (string-match "/" (car ctl))))
1680 (goto-char (point-max)))
1683 (narrow-to-region (point) (point-max))
1684 (when (and (eq mail-parse-charset 'gnus-decoded)
1685 (eq (mm-body-7-or-8) '8bit))
1686 ;; The text code could have been decoded.
1687 (setq charset mail-parse-charset))
1688 (when (and (or (not ctl)
1689 (equal (car ctl) "text/plain"))
1690 (not format)) ;; article with format will decode later.
1692 charset (and cte (intern (downcase
1693 (gnus-strip-whitespace cte))))
1696 (defun article-decode-encoded-words ()
1697 "Remove encoded-word encoding from headers."
1698 (let (buffer-read-only)
1699 (let ((charset (save-excursion
1700 (set-buffer gnus-summary-buffer)
1701 default-mime-charset)))
1702 (mime-decode-header-in-buffer charset)
1705 (defun article-de-quoted-unreadable (&optional force)
1706 "Translate a quoted-printable-encoded article.
1707 If FORCE, decode the article whether it is marked as quoted-printable
1709 (interactive (list 'force))
1711 (let ((buffer-read-only nil) type charset)
1712 (if (gnus-buffer-live-p gnus-original-article-buffer)
1713 (with-current-buffer gnus-original-article-buffer
1715 (gnus-fetch-field "content-transfer-encoding"))
1716 (let* ((ct (gnus-fetch-field "content-type"))
1719 (mail-header-parse-content-type ct)))))
1720 (setq charset (and ctl
1721 (mail-content-type-get ctl 'charset)))
1722 (if (stringp charset)
1723 (setq charset (intern (downcase charset)))))))
1725 (setq charset gnus-newsgroup-charset))
1727 (and type (let ((case-fold-search t))
1728 (string-match "quoted-printable" type))))
1730 (quoted-printable-decode-region
1731 (point) (point-max) (mm-charset-to-coding-system charset))))))
1733 (defun article-de-base64-unreadable (&optional force)
1734 "Translate a base64 article.
1735 If FORCE, decode the article whether it is marked as base64 not."
1736 (interactive (list 'force))
1738 (let ((buffer-read-only nil) type charset)
1739 (if (gnus-buffer-live-p gnus-original-article-buffer)
1740 (with-current-buffer gnus-original-article-buffer
1742 (gnus-fetch-field "content-transfer-encoding"))
1743 (let* ((ct (gnus-fetch-field "content-type"))
1746 (mail-header-parse-content-type ct)))))
1747 (setq charset (and ctl
1748 (mail-content-type-get ctl 'charset)))
1749 (if (stringp charset)
1750 (setq charset (intern (downcase charset)))))))
1752 (setq charset gnus-newsgroup-charset))
1754 (and type (let ((case-fold-search t))
1755 (string-match "base64" type))))
1758 (narrow-to-region (point) (point-max))
1759 (base64-decode-region (point-min) (point-max))
1760 (mm-decode-coding-region
1761 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
1766 (defun article-decode-HZ ()
1767 "Translate a HZ-encoded article."
1771 (let ((buffer-read-only nil))
1772 (rfc1843-decode-region (point-min) (point-max)))))
1774 (defun article-wash-html ()
1775 "Format an html article."
1778 (let ((buffer-read-only nil)
1780 (if (gnus-buffer-live-p gnus-original-article-buffer)
1781 (with-current-buffer gnus-original-article-buffer
1782 (let* ((ct (gnus-fetch-field "content-type"))
1785 (mail-header-parse-content-type ct)))))
1786 (setq charset (and ctl
1787 (mail-content-type-get ctl 'charset)))
1788 (if (stringp charset)
1789 (setq charset (intern (downcase charset)))))))
1791 (setq charset gnus-newsgroup-charset))
1793 (save-window-excursion
1795 (narrow-to-region (point) (point-max))
1797 (let ((w3-strict-width (window-width))
1798 (url-standalone-mode t))
1800 (w3-region (point-min) (point-max))
1803 (defun article-hide-list-identifiers ()
1804 "Remove list identifies from the Subject header.
1805 The `gnus-list-identifiers' variable specifies what to do."
1809 (let ((inhibit-point-motion-hooks t)
1811 (article-narrow-to-head)
1812 (let ((regexp (if (stringp gnus-list-identifiers) gnus-list-identifiers
1813 (mapconcat 'identity gnus-list-identifiers " *\\|"))))
1815 (goto-char (point-min))
1816 (when (re-search-forward
1817 (concat "^Subject: +\\(\\(\\(Re: +\\)?\\(" regexp
1818 " *\\)\\)+\\(Re: +\\)?\\)")
1820 (let ((s (or (match-string 3) (match-string 5))))
1821 (delete-region (match-beginning 1) (match-end 1))
1823 (goto-char (match-beginning 1))
1826 (defun article-hide-pgp ()
1827 "Remove any PGP headers and signatures in the current article."
1831 (let ((inhibit-point-motion-hooks t)
1832 buffer-read-only beg end)
1834 ;; Hide the "header".
1835 (when (re-search-forward "^-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
1836 (push 'pgp gnus-article-wash-types)
1837 (delete-region (match-beginning 0) (match-end 0))
1838 ;; Remove armor headers (rfc2440 6.2)
1839 (delete-region (point) (or (re-search-forward "^[ \t]*\n" nil t)
1842 ;; Hide the actual signature.
1843 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
1844 (setq end (1+ (match-beginning 0)))
1847 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
1849 ;; Perhaps we shouldn't hide to the end of the buffer
1850 ;; if there is no end to the signature?
1852 ;; Hide "- " PGP quotation markers.
1854 (narrow-to-region beg end)
1855 (goto-char (point-min))
1856 (while (re-search-forward "^- " nil t)
1858 (match-beginning 0) (match-end 0)))
1860 (gnus-run-hooks 'gnus-article-hide-pgp-hook))))))
1862 (defun article-hide-pem (&optional arg)
1863 "Toggle hiding of any PEM headers and signatures in the current article.
1864 If given a negative prefix, always show; if given a positive prefix,
1866 (interactive (gnus-article-hidden-arg))
1867 (unless (gnus-article-check-hidden-text 'pem arg)
1869 (let (buffer-read-only end)
1870 (goto-char (point-min))
1871 ;; Hide the horrendously ugly "header".
1872 (when (and (search-forward
1873 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
1875 (setq end (1+ (match-beginning 0))))
1876 (push 'pem gnus-article-wash-types)
1877 (gnus-article-hide-text-type
1879 (if (search-forward "\n\n" nil t)
1883 ;; Hide the trailer as well
1884 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
1886 (gnus-article-hide-text-type
1887 (match-beginning 0) (match-end 0) 'pem)))))))
1889 (defun article-strip-banner ()
1890 "Strip the banner specified by the `banner' group parameter."
1894 (let ((inhibit-point-motion-hooks t)
1895 (banner (gnus-group-find-parameter gnus-newsgroup-name 'banner))
1896 (gnus-signature-limit nil)
1897 buffer-read-only beg end)
1901 ((eq banner 'signature)
1902 (when (gnus-article-narrow-to-signature)
1905 (delete-region (point) (point-max))))
1907 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
1908 (while (re-search-forward banner nil t)
1909 (delete-region (match-beginning 0) (match-end 0)))))
1911 (while (re-search-forward banner nil t)
1912 (delete-region (match-beginning 0) (match-end 0))))))))))
1914 (defun article-babel ()
1915 "Translate article using an online translation service."
1919 (set-buffer gnus-article-buffer)
1920 (when (article-goto-body)
1921 (let* ((buffer-read-only nil)
1924 (orig (buffer-substring start end))
1925 (trans (babel-as-string orig)))
1927 (narrow-to-region start end)
1928 (delete-region start end)
1931 (defun article-hide-signature (&optional arg)
1932 "Hide the signature in the current article.
1933 If given a negative prefix, always show; if given a positive prefix,
1935 (interactive (gnus-article-hidden-arg))
1941 (article-goto-body))
1942 (goto-char (point-min)))
1943 (unless (gnus-article-check-hidden-text 'signature arg)
1944 (let ((buffer-read-only nil)
1946 (while (setq button (text-property-any button (point-max)
1948 'gnus-signature-toggle))
1949 (setq button (text-property-not-all button (point-max)
1951 'gnus-signature-toggle))
1952 (when (and button (not (eobp)))
1953 (gnus-article-hide-text-type
1955 (next-single-property-change (1+ button) 'mime-view-entity
1959 (defun article-strip-headers-in-body ()
1960 "Strip offensive headers from bodies."
1964 (let ((case-fold-search t))
1965 (when (looking-at "x-no-archive:")
1966 (gnus-delete-line)))))
1968 (defun article-strip-leading-blank-lines ()
1969 "Remove all blank lines from the beginning of the article."
1972 (let ((inhibit-point-motion-hooks t)
1974 (when (article-goto-body)
1975 (while (and (not (eobp))
1976 (looking-at "[ \t]*$"))
1977 (gnus-delete-line))))))
1979 (defun article-narrow-to-head ()
1980 "Narrow the buffer to the head of the message.
1981 Point is left at the beginning of the narrowed-to region."
1983 (goto-char (point-min))
1984 (if (search-forward "\n\n" nil 1)
1987 (goto-char (point-min)))
1989 (defun article-goto-body ()
1990 "Place point at the start of the body."
1991 (goto-char (point-min))
1993 ;; This variable is only bound when dealing with separate
1995 (article-goto-body-goes-to-point-min-p
1997 ((search-forward "\n\n" nil t)
2000 (goto-char (point-max))
2003 (defun article-strip-multiple-blank-lines ()
2004 "Replace consecutive blank lines with one empty line."
2007 (let ((inhibit-point-motion-hooks t)
2009 ;; First make all blank lines empty.
2011 (while (re-search-forward "^[ \t]+$" nil t)
2012 (unless (gnus-annotation-in-region-p
2013 (match-beginning 0) (match-end 0))
2014 (replace-match "" nil t)))
2015 ;; Then replace multiple empty lines with a single empty line.
2017 (while (re-search-forward "\n\n\n+" nil t)
2018 (unless (gnus-annotation-in-region-p
2019 (match-beginning 0) (match-end 0))
2020 (replace-match "\n\n" t t))))))
2022 (defun article-strip-leading-space ()
2023 "Remove all white space from the beginning of the lines in the article."
2026 (let ((inhibit-point-motion-hooks t)
2029 (while (re-search-forward "^[ \t]+" nil t)
2030 (replace-match "" t t)))))
2032 (defun article-strip-trailing-space ()
2033 "Remove all white space from the end of the lines in the article."
2036 (let ((inhibit-point-motion-hooks t)
2039 (while (re-search-forward "[ \t]+$" nil t)
2040 (replace-match "" t t)))))
2042 (defun article-strip-blank-lines ()
2043 "Strip leading, trailing and multiple blank lines."
2045 (article-strip-leading-blank-lines)
2046 (article-remove-trailing-blank-lines)
2047 (article-strip-multiple-blank-lines))
2049 (defun article-strip-all-blank-lines ()
2050 "Strip all blank lines."
2053 (let ((inhibit-point-motion-hooks t)
2056 (while (re-search-forward "^[ \t]*\n" nil t)
2057 (replace-match "" t t)))))
2059 (defun gnus-article-narrow-to-signature ()
2060 "Narrow to the signature; return t if a signature is found, else nil."
2061 (let ((inhibit-point-motion-hooks t))
2062 (when (gnus-article-search-signature)
2064 ;; Check whether we have some limits to what we consider
2065 ;; to be a signature.
2066 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2067 (list gnus-signature-limit)))
2069 (while (setq limit (pop limits))
2070 (if (or (and (integerp limit)
2071 (< (- (point-max) (point)) limit))
2073 (< (count-lines (point) (point-max)) limit))
2074 (and (gnus-functionp limit)
2076 (and (stringp limit)
2077 (not (re-search-forward limit nil t))))
2078 () ; This limit did not succeed.
2082 (narrow-to-region (point) (point-max))
2085 (defun gnus-article-search-signature ()
2086 "Search the current buffer for the signature separator.
2087 Put point at the beginning of the signature separator."
2088 (let ((cur (point)))
2089 (goto-char (point-max))
2090 (if (if (stringp gnus-signature-separator)
2091 (re-search-backward gnus-signature-separator nil t)
2092 (let ((seps gnus-signature-separator))
2094 (not (re-search-backward (car seps) nil t)))
2101 (defun gnus-article-hidden-arg ()
2102 "Return the current prefix arg as a number, or 0 if no prefix."
2103 (list (if current-prefix-arg
2104 (prefix-numeric-value current-prefix-arg)
2107 (defun gnus-article-check-hidden-text (type arg)
2108 "Return nil if hiding is necessary.
2109 Arg can be nil or a number. Nil and positive means hide, negative
2110 means show, 0 means toggle."
2113 (let ((hide (gnus-article-hidden-text-p type)))
2119 (gnus-article-show-hidden-text type))
2121 (if (eq hide 'hidden)
2122 (gnus-article-show-hidden-text type)
2125 (defun gnus-article-hidden-text-p (type)
2126 "Say whether the current buffer contains hidden text of type TYPE."
2127 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2129 (not (get-text-property pos 'invisible))
2130 (not (get-text-property pos 'dummy-invisible)))
2132 (text-property-any (1+ pos) (point-max) 'article-type type)))
2137 (defun gnus-article-show-hidden-text (type &optional hide)
2138 "Show all hidden text of type TYPE.
2139 If HIDE, hide the text instead."
2141 (let ((buffer-read-only nil)
2142 (inhibit-point-motion-hooks t)
2145 (while (setq beg (text-property-any end (point-max) 'article-type type))
2148 (text-property-not-all beg (point-max) 'article-type type)
2151 (gnus-article-hide-text beg end gnus-hidden-properties)
2152 (gnus-article-unhide-text beg end))
2156 (defconst article-time-units
2157 `((year . ,(* 365.25 24 60 60))
2158 (week . ,(* 7 24 60 60))
2159 (day . ,(* 24 60 60))
2163 "Mapping from time units to seconds.")
2165 (defun article-date-ut (&optional type highlight header)
2166 "Convert DATE date to universal time in the current article.
2167 If TYPE is `local', convert to local time; if it is `lapsed', output
2168 how much time has lapsed since DATE. For `lapsed', the value of
2169 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2170 should replace the \"Date:\" one, or should be added below it."
2171 (interactive (list 'ut t))
2172 (let* ((header (or header
2173 (and (eq 1 (point-min))
2174 (mail-header-date (save-excursion
2175 (set-buffer gnus-summary-buffer)
2176 gnus-current-headers)))
2177 (message-fetch-field "date")
2179 (date (if (vectorp header) (mail-header-date header)
2181 (inhibit-point-motion-hooks t)
2182 bface eface date-pos)
2183 (when (and date (not (string= date "")))
2186 (article-narrow-to-head)
2187 (when (or (and (eq type 'lapsed)
2188 gnus-article-date-lapsed-new-header
2189 ;; Attempt to get the face of X-Sent first.
2190 (re-search-forward "^X-Sent:[ \t]" nil t))
2191 (re-search-forward "^Date:[ \t]" nil t)
2192 ;; If Date is missing, try again for X-Sent.
2193 (re-search-forward "^X-Sent:[ \t]" nil t))
2194 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2195 date (or (get-text-property (gnus-point-at-bol)
2198 eface (get-text-property (1- (gnus-point-at-eol))
2200 (let ((buffer-read-only nil))
2201 ;; Delete any old X-Sent headers.
2202 (when (setq date-pos
2203 (text-property-any (point-min) (point-max)
2204 'article-date-lapsed t))
2205 (goto-char (setq date-pos (set-marker (make-marker) date-pos)))
2206 (delete-region (match-beginning 0)
2207 (progn (forward-line 1) (point))))
2208 (goto-char (point-min))
2209 ;; Delete any old Date headers.
2210 (while (re-search-forward "^Date:[ \t]" nil t)
2212 (setq date-pos (match-beginning 0)))
2213 (unless (and (eq type 'lapsed)
2214 gnus-article-date-lapsed-new-header)
2215 (delete-region (match-beginning 0)
2216 (progn (message-next-header) (point)))))
2219 (goto-char date-pos)
2221 ;; Possibly, Date has been deleted.
2223 (when (and (eq type 'lapsed)
2224 gnus-article-date-lapsed-new-header
2225 (looking-at "Date:"))
2227 (goto-char (point-min)))
2228 (insert (article-make-date-line date type))
2229 (when (eq type 'lapsed)
2230 (put-text-property (gnus-point-at-bol) (point)
2231 'article-date-lapsed t))
2235 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2236 (put-text-property (match-beginning 1) (1+ (match-end 1))
2237 'original-date date)
2238 (put-text-property (match-beginning 1) (1+ (match-end 1))
2240 (put-text-property (match-beginning 2) (match-end 2)
2243 (defun article-make-date-line (date type)
2244 "Return a DATE line of TYPE."
2245 (let ((time (condition-case ()
2249 ;; Convert to the local timezone. We have to slap a
2250 ;; `condition-case' round the calls to the timezone
2251 ;; functions since they aren't particularly resistant to
2254 (let ((tz (car (current-time-zone time))))
2255 (format "Date: %s %s%02d%02d" (current-time-string time)
2256 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2257 (/ (% (abs tz) 3600) 60))))
2258 ;; Convert to Universal Time.
2261 (current-time-string
2262 (let* ((e (parse-time-string date))
2263 (tm (apply 'encode-time e))
2265 (ls (- (cadr tm) (car (current-time-zone time)))))
2266 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2267 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2270 ;; Get the original date from the article.
2271 ((eq type 'original)
2272 (concat "Date: " (if (string-match "\n+$" date)
2273 (substring date 0 (match-beginning 0))
2275 ;; Let the user define the format.
2277 (if (gnus-functionp gnus-article-time-format)
2278 (funcall gnus-article-time-format time)
2281 (format-time-string gnus-article-time-format time))))
2284 (let ((tz (car (current-time-zone time))))
2287 (format-time-string "%Y%m%dT%H%M%S" time)
2288 (format "%s%02d%02d"
2289 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2290 (/ (% (abs tz) 3600) 60)))))
2291 ;; Do an X-Sent lapsed format.
2293 ;; If the date is seriously mangled, the timezone functions are
2294 ;; liable to bug out, so we ignore all errors.
2295 (let* ((now (current-time))
2296 (real-time (subtract-time now time))
2297 (real-sec (and real-time
2298 (+ (* (float (car real-time)) 65536)
2300 (sec (and real-time (abs real-sec)))
2310 ;; This is a bit convoluted, but basically we go
2311 ;; through the time units for years, weeks, etc,
2312 ;; and divide things to see whether that results
2313 ;; in positive answers.
2316 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2317 ;; The (remaining) seconds are too few to
2318 ;; be divided into this time unit.
2320 ;; It's big enough, so we output it.
2321 (setq sec (- sec (* num (cdr unit))))
2323 (concat (if prev ", " "") (int-to-string
2325 " " (symbol-name (car unit))
2326 (if (> num 1) "s" ""))
2328 article-time-units "")
2329 ;; If dates are odd, then it might appear like the
2330 ;; article was sent in the future.
2333 " in the future"))))))
2335 (error "Unknown conversion type: %s" type)))))
2337 (defun article-date-local (&optional highlight)
2338 "Convert the current article date to the local timezone."
2339 (interactive (list t))
2340 (article-date-ut 'local highlight))
2342 (defun article-date-original (&optional highlight)
2343 "Convert the current article date to what it was originally.
2344 This is only useful if you have used some other date conversion
2345 function and want to see what the date was before converting."
2346 (interactive (list t))
2347 (article-date-ut 'original highlight))
2349 (defun article-date-lapsed (&optional highlight)
2350 "Convert the current article date to time lapsed since it was sent."
2351 (interactive (list t))
2352 (article-date-ut 'lapsed highlight))
2354 (defun article-update-date-lapsed ()
2355 "Function to be run from a timer to update the lapsed time line."
2356 (let (deactivate-mark)
2361 (set-buffer (window-buffer w))
2362 (when (eq major-mode 'gnus-article-mode)
2363 (goto-char (point-min))
2364 (when (re-search-forward "^X-Sent:" nil t)
2365 (article-date-lapsed t))))
2368 (defun gnus-start-date-timer (&optional n)
2369 "Start a timer to update the X-Sent header in the article buffers.
2370 The numerical prefix says how frequently (in seconds) the function
2375 (gnus-stop-date-timer)
2376 (setq article-lapsed-timer
2377 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2379 (defun gnus-stop-date-timer ()
2380 "Stop the X-Sent timer."
2382 (when article-lapsed-timer
2383 (nnheader-cancel-timer article-lapsed-timer)
2384 (setq article-lapsed-timer nil)))
2386 (defun article-date-user (&optional highlight)
2387 "Convert the current article date to the user-defined format.
2388 This format is defined by the `gnus-article-time-format' variable."
2389 (interactive (list t))
2390 (article-date-ut 'user highlight))
2392 (defun article-date-iso8601 (&optional highlight)
2393 "Convert the current article date to ISO8601."
2394 (interactive (list t))
2395 (article-date-ut 'iso8601 highlight))
2397 (defun article-show-all ()
2398 "Show all hidden text in the article buffer."
2402 (let ((buffer-read-only nil))
2403 (gnus-article-unhide-text (point-min) (point-max))
2404 (gnus-remove-text-with-property 'gnus-prev)
2405 (gnus-remove-text-with-property 'gnus-next))))
2407 (defun article-show-all-headers ()
2408 "Show all hidden headers in the article buffer."
2413 (article-narrow-to-head)
2414 (let ((buffer-read-only nil))
2415 (gnus-article-unhide-text (point-min) (point-max))))))
2417 (defun article-emphasize (&optional arg)
2418 "Emphasize text according to `gnus-emphasis-alist'."
2419 (interactive (gnus-article-hidden-arg))
2420 (unless (gnus-article-check-hidden-text 'emphasis arg)
2424 (with-current-buffer gnus-summary-buffer
2425 gnus-article-emphasis-alist)
2427 gnus-emphasis-alist))
2428 (buffer-read-only nil)
2429 (props (append '(article-type emphasis)
2430 gnus-hidden-properties))
2431 regexp elem beg invisible visible face)
2434 (while (setq elem (pop alist))
2436 (setq regexp (car elem)
2437 invisible (nth 1 elem)
2438 visible (nth 2 elem)
2440 (while (re-search-forward regexp nil t)
2441 (when (and (match-beginning visible) (match-beginning invisible))
2442 (push 'emphasis gnus-article-wash-types)
2443 (gnus-article-hide-text
2444 (match-beginning invisible) (match-end invisible) props)
2445 (gnus-article-unhide-text-type
2446 (match-beginning visible) (match-end visible) 'emphasis)
2447 (gnus-put-text-property-excluding-newlines
2448 (match-beginning visible) (match-end visible) 'face face)
2449 (goto-char (match-end invisible)))))))))
2451 (defun gnus-article-setup-highlight-words (&optional highlight-words)
2452 "Setup newsgroup emphasis alist."
2453 (unless gnus-article-emphasis-alist
2454 (let ((name (and gnus-newsgroup-name
2455 (gnus-group-real-name gnus-newsgroup-name))))
2456 (make-local-variable 'gnus-article-emphasis-alist)
2457 (setq gnus-article-emphasis-alist
2459 (let ((alist gnus-group-highlight-words-alist) elem highlight)
2460 (while (setq elem (pop alist))
2461 (when (and name (string-match (car elem) name))
2463 highlight (copy-sequence (cdr elem)))))
2465 (copy-sequence highlight-words)
2466 (if gnus-newsgroup-name
2467 (copy-sequence (gnus-group-find-parameter
2468 gnus-newsgroup-name 'highlight-words t)))
2469 gnus-emphasis-alist)))))
2471 (defvar gnus-summary-article-menu)
2472 (defvar gnus-summary-post-menu)
2474 ;;; Saving functions.
2476 (defun gnus-article-save (save-buffer file &optional num)
2477 "Save the currently selected article."
2478 (unless gnus-save-all-headers
2479 ;; Remove headers according to `gnus-saved-headers'.
2480 (let ((gnus-visible-headers
2481 (or gnus-saved-headers gnus-visible-headers))
2482 (gnus-article-buffer save-buffer))
2484 (set-buffer save-buffer)
2485 (article-hide-headers 1 t))))
2486 (save-window-excursion
2487 (if (not gnus-default-article-saver)
2488 (error "No default saver is defined")
2489 ;; !!! Magic! The saving functions all save
2490 ;; `gnus-save-article-buffer' (or so they think), but we
2491 ;; bind that variable to our save-buffer.
2492 (set-buffer gnus-article-buffer)
2493 (let* ((gnus-save-article-buffer save-buffer)
2496 ((not gnus-prompt-before-saving) 'default)
2497 ((eq gnus-prompt-before-saving 'always) nil)
2499 (gnus-number-of-articles-to-be-saved
2500 (when (eq gnus-prompt-before-saving t)
2502 (set-buffer gnus-article-current-summary)
2503 (funcall gnus-default-article-saver filename)))))
2505 (defun gnus-read-save-file-name (prompt &optional filename
2506 function group headers variable)
2508 (funcall function group headers (symbol-value variable)))
2513 ((eq filename 'default)
2519 (let* ((split-name (gnus-get-split-value gnus-split-methods))
2522 (if (and gnus-number-of-articles-to-be-saved
2523 (> gnus-number-of-articles-to-be-saved 1))
2524 (format "these %d articles"
2525 gnus-number-of-articles-to-be-saved)
2528 ;; Let the split methods have their say.
2530 ;; No split name was found.
2533 (concat prompt " (default "
2534 (file-name-nondirectory default-name) ") ")
2535 (file-name-directory default-name)
2537 ;; A single group name is returned.
2538 ((stringp split-name)
2540 (funcall function split-name headers
2541 (symbol-value variable)))
2543 (concat prompt " (default "
2544 (file-name-nondirectory default-name) ") ")
2545 (file-name-directory default-name)
2547 ;; A single split name was found
2548 ((= 1 (length split-name))
2549 (let* ((name (expand-file-name
2551 gnus-article-save-directory))
2552 (dir (cond ((file-directory-p name)
2553 (file-name-as-directory name))
2554 ((file-exists-p name) name)
2555 (t gnus-article-save-directory))))
2557 (concat prompt " (default " name ") ")
2559 ;; A list of splits was found.
2561 (setq split-name (nreverse split-name))
2563 (let ((file-name-history
2564 (nconc split-name file-name-history)))
2568 (concat prompt " (`M-p' for defaults) ")
2569 gnus-article-save-directory
2571 gnus-article-save-directory)))
2572 (car (push result file-name-history)))))))
2573 ;; Create the directory.
2574 (gnus-make-directory (file-name-directory file))
2575 ;; If we have read a directory, we append the default file name.
2576 (when (file-directory-p file)
2577 (setq file (expand-file-name (file-name-nondirectory
2579 (file-name-as-directory file))))
2580 ;; Possibly translate some characters.
2581 (nnheader-translate-file-chars file))))))
2582 (gnus-make-directory (file-name-directory result))
2583 (set variable result)))
2585 (defun gnus-article-archive-name (group)
2586 "Return the first instance of an \"Archive-name\" in the current buffer."
2587 (let ((case-fold-search t))
2588 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
2589 (nnheader-concat gnus-article-save-directory
2590 (match-string 1)))))
2592 (defun gnus-article-nndoc-name (group)
2593 "If GROUP is an nndoc group, return the name of the parent group."
2594 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
2595 (gnus-group-get-parameter group 'save-article-group)))
2597 (defun gnus-summary-save-in-rmail (&optional filename)
2598 "Append this article to Rmail file.
2599 Optional argument FILENAME specifies file name.
2600 Directory to save to is default to `gnus-article-save-directory'."
2601 (setq filename (gnus-read-save-file-name
2602 "Save %s in rmail file:" filename
2603 gnus-rmail-save-name gnus-newsgroup-name
2604 gnus-current-headers 'gnus-newsgroup-last-rmail))
2605 (gnus-eval-in-buffer-window gnus-save-article-buffer
2609 (gnus-output-to-rmail filename))))
2612 (defun gnus-summary-save-in-mail (&optional filename)
2613 "Append this article to Unix mail file.
2614 Optional argument FILENAME specifies file name.
2615 Directory to save to is default to `gnus-article-save-directory'."
2616 (setq filename (gnus-read-save-file-name
2617 "Save %s in Unix mail file:" filename
2618 gnus-mail-save-name gnus-newsgroup-name
2619 gnus-current-headers 'gnus-newsgroup-last-mail))
2620 (gnus-eval-in-buffer-window gnus-save-article-buffer
2624 (if (and (file-readable-p filename)
2625 (mail-file-babyl-p filename))
2626 (rmail-output-to-rmail-file filename t)
2627 (gnus-output-to-mail filename)))))
2630 (defun gnus-summary-save-in-file (&optional filename overwrite)
2631 "Append this article to file.
2632 Optional argument FILENAME specifies file name.
2633 Directory to save to is default to `gnus-article-save-directory'."
2634 (setq filename (gnus-read-save-file-name
2635 "Save %s in file:" filename
2636 gnus-file-save-name gnus-newsgroup-name
2637 gnus-current-headers 'gnus-newsgroup-last-file))
2638 (gnus-eval-in-buffer-window gnus-save-article-buffer
2642 (when (and overwrite
2643 (file-exists-p filename))
2644 (delete-file filename))
2645 (gnus-output-to-file filename))))
2648 (defun gnus-summary-write-to-file (&optional filename)
2649 "Write this article to a file.
2650 Optional argument FILENAME specifies file name.
2651 The directory to save in defaults to `gnus-article-save-directory'."
2652 (gnus-summary-save-in-file nil t))
2654 (defun gnus-summary-save-body-in-file (&optional filename)
2655 "Append this article body to a file.
2656 Optional argument FILENAME specifies file name.
2657 The directory to save in defaults to `gnus-article-save-directory'."
2658 (setq filename (gnus-read-save-file-name
2659 "Save %s body in file:" filename
2660 gnus-file-save-name gnus-newsgroup-name
2661 gnus-current-headers 'gnus-newsgroup-last-file))
2662 (gnus-eval-in-buffer-window gnus-save-article-buffer
2666 (when (article-goto-body)
2667 (narrow-to-region (point) (point-max)))
2668 (gnus-output-to-file filename))))
2671 (defun gnus-summary-save-in-pipe (&optional command)
2672 "Pipe this article to subprocess."
2674 (cond ((and (eq command 'default)
2675 gnus-last-shell-command)
2676 gnus-last-shell-command)
2680 "Shell command on %s: "
2681 (if (and gnus-number-of-articles-to-be-saved
2682 (> gnus-number-of-articles-to-be-saved 1))
2683 (format "these %d articles"
2684 gnus-number-of-articles-to-be-saved)
2686 gnus-last-shell-command))))
2687 (when (string-equal command "")
2688 (setq command gnus-last-shell-command))
2689 (gnus-eval-in-buffer-window gnus-article-buffer
2692 (shell-command-on-region (point-min) (point-max) command nil)))
2693 (setq gnus-last-shell-command command))
2695 ;;; Article file names when saving.
2697 (defun gnus-capitalize-newsgroup (newsgroup)
2698 "Capitalize NEWSGROUP name."
2699 (when (not (zerop (length newsgroup)))
2700 (concat (char-to-string (upcase (aref newsgroup 0)))
2701 (substring newsgroup 1))))
2703 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2704 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2705 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
2706 Otherwise, it is like ~/News/news/group/num."
2709 (concat (if (gnus-use-long-file-name 'not-save)
2710 (gnus-capitalize-newsgroup newsgroup)
2711 (gnus-newsgroup-directory-form newsgroup))
2712 "/" (int-to-string (mail-header-number headers)))
2713 gnus-article-save-directory)))
2715 (string-equal (file-name-directory default)
2716 (file-name-directory last-file))
2717 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2719 (or last-file default))))
2721 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2722 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2723 If variable `gnus-use-long-file-name' is non-nil, it is
2724 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2727 (concat (if (gnus-use-long-file-name 'not-save)
2729 (gnus-newsgroup-directory-form newsgroup))
2730 "/" (int-to-string (mail-header-number headers)))
2731 gnus-article-save-directory)))
2733 (string-equal (file-name-directory default)
2734 (file-name-directory last-file))
2735 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2737 (or last-file default))))
2739 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2740 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2741 If variable `gnus-use-long-file-name' is non-nil, it is
2742 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2745 (if (gnus-use-long-file-name 'not-save)
2747 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup)))
2748 gnus-article-save-directory)))
2755 (setq afunc (car func)
2758 gfunc (intern (format "gnus-%s" func))))
2761 `(lambda (&optional interactive &rest args)
2762 ,(documentation afunc t)
2763 (interactive (list t))
2765 (set-buffer gnus-article-buffer)
2767 (call-interactively ',afunc)
2768 (apply ',afunc args))))))))
2769 '(article-hide-headers
2770 article-hide-boring-headers
2771 article-toggle-headers
2772 article-treat-overstrike
2773 article-fill-long-lines
2774 article-capitalize-sentences
2776 article-display-x-face
2777 article-de-quoted-unreadable
2778 article-de-base64-unreadable
2781 article-hide-list-identifiers
2783 article-strip-banner
2786 article-hide-signature
2787 article-strip-headers-in-body
2788 article-remove-trailing-blank-lines
2789 article-strip-leading-blank-lines
2790 article-strip-multiple-blank-lines
2791 article-strip-leading-space
2792 article-strip-trailing-space
2793 article-strip-blank-lines
2794 article-strip-all-blank-lines
2796 article-date-iso8601
2797 article-date-original
2799 article-decode-mime-words
2800 article-decode-charset
2801 article-decode-encoded-words
2805 article-treat-dumbquotes
2806 article-normalize-headers
2807 (article-show-all-headers . gnus-article-show-all-headers)
2808 (article-show-all . gnus-article-show-all))))
2811 ;;; Gnus article mode
2814 (put 'gnus-article-mode 'mode-class 'special)
2816 (gnus-define-keys gnus-article-mode-map
2817 " " gnus-article-goto-next-page
2818 "\177" gnus-article-goto-prev-page
2819 [delete] gnus-article-goto-prev-page
2820 [backspace] gnus-article-goto-prev-page
2821 "\C-c^" gnus-article-refer-article
2822 "h" gnus-article-show-summary
2823 "s" gnus-article-show-summary
2824 "\C-c\C-m" gnus-article-mail
2825 "?" gnus-article-describe-briefly
2826 "e" gnus-summary-edit-article
2827 "<" beginning-of-buffer
2829 "\C-c\C-i" gnus-info-find-node
2832 "\C-d" gnus-article-read-summary-keys
2833 "\M-*" gnus-article-read-summary-keys
2834 "\M-#" gnus-article-read-summary-keys
2835 "\M-^" gnus-article-read-summary-keys
2836 "\M-g" gnus-article-read-summary-keys)
2838 ;; Define almost undefined keys to `gnus-article-read-summary-keys'.
2841 (unless (lookup-key gnus-article-mode-map key)
2842 (define-key gnus-article-mode-map key
2843 'gnus-article-read-summary-keys)))
2848 (let ((key (car elt)))
2849 (and (> (length key) 0)
2850 (not (eq 'menu-bar (aref key 0)))
2851 (symbolp (lookup-key gnus-summary-mode-map key))
2853 (accessible-keymaps gnus-summary-mode-map))
2857 (push (char-to-string c) keys)
2861 (defun gnus-article-make-menu-bar ()
2862 (gnus-turn-off-edit-menu 'article)
2863 (unless (boundp 'gnus-article-article-menu)
2865 gnus-article-article-menu gnus-article-mode-map ""
2867 ["Scroll forwards" gnus-article-goto-next-page t]
2868 ["Scroll backwards" gnus-article-goto-prev-page t]
2869 ["Show summary" gnus-article-show-summary t]
2870 ["Fetch Message-ID at point" gnus-article-refer-article t]
2871 ["Mail to address at point" gnus-article-mail t]
2872 ["Send a bug report" gnus-bug t]))
2875 gnus-article-treatment-menu gnus-article-mode-map ""
2877 ["Hide headers" gnus-article-toggle-headers t]
2878 ["Hide signature" gnus-article-hide-signature t]
2879 ["Hide citation" gnus-article-hide-citation t]
2880 ["Treat overstrike" gnus-article-treat-overstrike t]
2881 ["Remove carriage return" gnus-article-remove-cr t]
2882 ["Decode HZ" gnus-article-decode-HZ t]))
2884 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
2886 (when (boundp 'gnus-summary-post-menu)
2887 (define-key gnus-article-mode-map [menu-bar post]
2888 (cons "Post" gnus-summary-post-menu)))
2890 (gnus-run-hooks 'gnus-article-menu-hook)))
2892 (defun gnus-article-mode ()
2893 "Major mode for displaying an article.
2895 All normal editing commands are switched off.
2897 The following commands are available in addition to all summary mode
2899 \\<gnus-article-mode-map>
2900 \\[gnus-article-next-page]\t Scroll the article one page forwards
2901 \\[gnus-article-prev-page]\t Scroll the article one page backwards
2902 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
2903 \\[gnus-article-show-summary]\t Display the summary buffer
2904 \\[gnus-article-mail]\t Send a reply to the address near point
2905 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
2906 \\[gnus-info-find-node]\t Go to the Gnus info node"
2908 (when (gnus-visual-p 'article-menu 'menu)
2909 (gnus-article-make-menu-bar))
2910 (gnus-simplify-mode-line)
2911 (setq mode-name "Article")
2912 (setq major-mode 'gnus-article-mode)
2913 (make-local-variable 'minor-mode-alist)
2914 (unless (assq 'gnus-show-mime minor-mode-alist)
2915 (push (list 'gnus-show-mime " MIME") minor-mode-alist))
2916 (use-local-map gnus-article-mode-map)
2917 (gnus-update-format-specifications nil 'article-mode)
2918 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
2919 (make-local-variable 'gnus-page-broken)
2920 (make-local-variable 'gnus-button-marker-list)
2921 (make-local-variable 'gnus-article-current-summary)
2922 (make-local-variable 'gnus-article-mime-handles)
2923 (make-local-variable 'gnus-article-decoded-p)
2924 (make-local-variable 'gnus-article-mime-handle-alist)
2925 (make-local-variable 'gnus-article-wash-types)
2926 (make-local-variable 'gnus-article-charset)
2927 (make-local-variable 'gnus-article-ignored-charsets)
2928 (gnus-set-default-directory)
2929 (buffer-disable-undo)
2930 (setq buffer-read-only t)
2931 (set-syntax-table gnus-article-mode-syntax-table)
2932 (gnus-run-hooks 'gnus-article-mode-hook))
2934 (defun gnus-article-setup-buffer ()
2935 "Initialize the article buffer."
2936 (let* ((name (if gnus-single-article-buffer "*Article*"
2937 (concat "*Article " gnus-newsgroup-name "*")))
2939 (progn (string-match "\\*Article" name)
2940 (concat " *Original Article"
2941 (substring name (match-end 0))))))
2942 (setq gnus-article-buffer name)
2943 (setq gnus-original-article-buffer original)
2944 (setq gnus-article-mime-handle-alist nil)
2945 ;; This might be a variable local to the summary buffer.
2946 (unless gnus-single-article-buffer
2948 (set-buffer gnus-summary-buffer)
2949 (setq gnus-article-buffer name)
2950 (setq gnus-original-article-buffer original)
2951 (gnus-set-global-variables)))
2952 (gnus-article-setup-highlight-words)
2953 ;; Init original article buffer.
2955 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
2956 (set-buffer-multibyte nil)
2957 (setq major-mode 'gnus-original-article-mode)
2958 (make-local-variable 'gnus-original-article))
2959 (if (get-buffer name)
2962 (buffer-disable-undo)
2963 (setq buffer-read-only t)
2964 (unless (eq major-mode 'gnus-article-mode)
2965 (gnus-article-mode))
2968 (set-buffer (gnus-get-buffer-create name))
2970 (make-local-variable 'gnus-summary-buffer)
2971 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2972 (current-buffer)))))
2974 ;; Set article window start at LINE, where LINE is the number of lines
2975 ;; from the head of the article.
2976 (defun gnus-article-set-window-start (&optional line)
2978 (get-buffer-window gnus-article-buffer t)
2980 (set-buffer gnus-article-buffer)
2981 (goto-char (point-min))
2984 (gnus-message 6 "Moved to bookmark")
2985 (search-forward "\n\n" nil t)
2989 ;;; @@ article filters
2992 (defun gnus-article-display-mime-message ()
2993 "Article display method for MIME message."
2994 ;; called from `gnus-original-article-buffer'.
2995 (let (charset all-headers)
2996 (with-current-buffer gnus-summary-buffer
2997 (setq charset default-mime-charset
2998 all-headers gnus-have-all-headers))
2999 (make-local-variable 'default-mime-charset)
3000 (setq default-mime-charset charset)
3001 (with-current-buffer (get-buffer-create gnus-article-buffer)
3002 (make-local-variable 'default-mime-charset)
3003 (setq default-mime-charset charset))
3004 (mime-display-message mime-message-structure
3005 gnus-article-buffer nil gnus-article-mode-map)
3007 (gnus-article-hide-headers nil -1)))
3008 (run-hooks 'gnus-mime-article-prepare-hook))
3010 (defun gnus-article-display-traditional-message ()
3011 "Article display method for traditional message."
3012 (set-buffer gnus-article-buffer)
3013 (let (buffer-read-only)
3015 (insert-buffer-substring gnus-original-article-buffer)))
3017 (defun gnus-article-make-full-mail-header (&optional number charset)
3018 "Create a new mail header structure in a raw article buffer."
3019 (unless (and number charset)
3020 (save-current-buffer
3021 (set-buffer gnus-summary-buffer)
3023 (setq number (or (cdr gnus-article-current) 0)))
3025 (setq charset (or default-mime-charset 'x-ctext)))))
3026 (goto-char (point-min))
3027 (let ((header-end (if (search-forward "\n\n" nil t)
3029 (goto-char (point-max))))
3030 (chars (- (point-max) (point)))
3031 (lines (count-lines (point) (point-max)))
3032 (default-mime-charset charset)
3034 (narrow-to-region (point-min) header-end)
3035 (setq xref (std11-fetch-field "xref"))
3037 (make-full-mail-header
3039 (std11-fetch-field "subject")
3040 (std11-fetch-field "from")
3041 (std11-fetch-field "date")
3042 (std11-fetch-field "message-id")
3043 (std11-fetch-field "references")
3046 (when xref (concat "Xref: " xref)))
3049 (defun gnus-article-prepare (article &optional all-headers header)
3050 "Prepare ARTICLE in article mode buffer.
3051 ARTICLE should either be an article number or a Message-ID.
3052 If ARTICLE is an id, HEADER should be the article headers.
3053 If ALL-HEADERS is non-nil, no headers are hidden."
3055 ;; Make sure we start in a summary buffer.
3056 (unless (eq major-mode 'gnus-summary-mode)
3057 (set-buffer gnus-summary-buffer))
3058 (setq gnus-summary-buffer (current-buffer))
3059 (let* ((gnus-article (if header (mail-header-number header) article))
3060 (summary-buffer (current-buffer))
3061 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3062 (group gnus-newsgroup-name)
3065 (gnus-article-setup-buffer)
3066 (set-buffer gnus-original-article-buffer)
3067 ;; Deactivate active regions.
3068 (when (and (boundp 'transient-mark-mode)
3069 transient-mark-mode)
3070 (setq mark-active nil))
3071 (if (not (setq result (let ((buffer-read-only nil))
3072 (gnus-request-article-this-buffer
3074 ;; There is no such article.
3076 (when (and (numberp article)
3077 (not (memq article gnus-newsgroup-sparse)))
3078 (setq gnus-article-current
3079 (cons gnus-newsgroup-name article))
3080 (set-buffer gnus-summary-buffer)
3081 (setq gnus-current-article article)
3082 (if (eq (gnus-article-mark article) gnus-undownloaded-mark)
3084 (gnus-summary-set-agent-mark article)
3085 (message "Message marked for downloading"))
3086 (gnus-summary-mark-article article gnus-canceled-mark)
3087 (unless (memq article gnus-newsgroup-sparse)
3088 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3089 (if (or (eq result 'pseudo)
3090 (eq result 'nneething))
3093 (set-buffer summary-buffer)
3094 (push article gnus-newsgroup-history)
3095 (setq gnus-last-article gnus-current-article
3096 gnus-current-article 0
3097 gnus-current-headers nil
3098 gnus-article-current nil)
3099 (if (eq result 'nneething)
3100 (gnus-configure-windows 'summary)
3101 (gnus-configure-windows 'article))
3102 (gnus-set-global-variables))
3103 (let ((gnus-article-mime-handle-alist-1
3104 gnus-article-mime-handle-alist))
3105 (gnus-set-mode-line 'article)))
3106 ;; The result from the `request' was an actual article -
3107 ;; or at least some text that is now displayed in the
3109 (when (and (numberp article)
3110 (not (eq article gnus-current-article)))
3111 ;; Seems like a new article has been selected.
3112 ;; `gnus-current-article' must be an article number.
3114 (set-buffer summary-buffer)
3115 (push article gnus-newsgroup-history)
3116 (setq gnus-last-article gnus-current-article
3117 gnus-current-article article
3118 gnus-current-headers
3119 (gnus-summary-article-header gnus-current-article)
3120 gnus-article-current
3121 (cons gnus-newsgroup-name gnus-current-article))
3122 (unless (vectorp gnus-current-headers)
3123 (setq gnus-current-headers nil))
3124 (gnus-summary-goto-subject gnus-current-article)
3125 (when (gnus-summary-show-thread)
3126 ;; If the summary buffer really was folded, the
3127 ;; previous goto may not actually have gone to
3128 ;; the right article, but the thread root instead.
3130 (gnus-summary-goto-subject gnus-current-article))
3131 (gnus-run-hooks 'gnus-mark-article-hook)
3132 (gnus-set-mode-line 'summary)
3133 (when (gnus-visual-p 'article-highlight 'highlight)
3134 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3135 ;; Set the global newsgroup variables here.
3136 (gnus-set-global-variables)
3137 (setq gnus-have-all-headers
3138 (or all-headers gnus-show-all-headers))))
3140 (gnus-configure-windows 'article))
3141 (when (or (numberp article)
3143 (gnus-article-prepare-display)
3145 (goto-char (point-min))
3146 (setq gnus-page-broken
3147 (when gnus-break-pages
3148 (gnus-narrow-to-page)
3150 (let ((gnus-article-mime-handle-alist-1
3151 gnus-article-mime-handle-alist))
3152 (gnus-set-mode-line 'article))
3154 (set-window-point (get-buffer-window (current-buffer)) (point))
3155 (gnus-configure-windows 'article)
3158 (defun gnus-article-prepare-mime-display (&optional number)
3159 (goto-char (point-min))
3160 (when (re-search-forward "^[^\t ]+:" nil t)
3161 (goto-char (match-beginning 0)))
3162 (let ((entity (if (eq 1 (point-min))
3163 (get-text-property 1 'mime-view-entity)
3164 (get-text-property (point) 'mime-view-entity)))
3165 last-entity child-entity next type)
3166 (setq child-entity (mime-entity-children entity))
3168 (setq last-entity (nth (1- (length child-entity))
3170 (setq last-entity entity))
3172 (narrow-to-region (point)
3173 (if (search-forward "\n\n" nil t)
3176 (gnus-treat-article 'head)
3177 (put-text-property (point-min) (point-max) 'article-treated-header t)
3178 (goto-char (point-max)))
3179 (while (and (not (eobp)) entity)
3180 (setq next (set-marker
3182 (next-single-property-change (point) 'mime-view-entity
3184 (let ((types (mime-entity-content-type entity)))
3185 (while (eq 'multipart (mime-content-type-primary-type types))
3186 (setq entity (car (mime-entity-children entity))
3187 types (mime-entity-content-type entity)))
3189 (setq type (format "%s/%s"
3190 (mime-content-type-primary-type types)
3191 (mime-content-type-subtype types)))))
3192 (if (string-equal type "message/rfc822")
3195 (let ((children (mime-entity-children entity))
3198 (setq last-children (nth (1- (length children)) children))
3201 (not (eq last-children
3202 (get-text-property next 'mime-view-entity)))
3204 (next-single-property-change next
3206 nil (point-max)))))))
3207 (setq next (next-single-property-change next 'mime-view-entity
3210 (narrow-to-region (point) next)
3211 (gnus-article-prepare-mime-display)
3212 (goto-char (point-max)))
3213 (setq entity (get-text-property (point) 'mime-view-entity)))
3215 (narrow-to-region (point) next)
3216 ;; Kludge. We have to count true number, but for now,
3217 ;; part number is here only to achieve `last'.
3218 (gnus-treat-article nil 1
3219 (if (eq entity last-entity)
3222 (goto-char (point-max)))
3223 (setq entity (get-text-property next 'mime-view-entity))))))
3226 (defun gnus-article-prepare-display ()
3227 "Make the current buffer look like a nice article."
3228 (setq gnus-article-wash-types nil)
3229 (gnus-run-hooks 'gnus-tmp-internal-hook)
3230 (gnus-run-hooks 'gnus-article-prepare-hook)
3232 (let (mime-display-header-hook mime-display-text/plain-hook)
3233 (funcall (if gnus-show-mime
3235 (setq mime-message-structure gnus-current-headers)
3236 (mime-buffer-entity-set-buffer-internal
3237 mime-message-structure
3238 gnus-original-article-buffer)
3239 (mime-entity-set-representation-type-internal
3240 mime-message-structure 'mime-buffer-entity)
3241 (luna-send mime-message-structure
3242 'initialize-instance
3243 mime-message-structure)
3244 gnus-article-display-method-for-mime)
3245 gnus-article-display-method-for-traditional)))
3246 ;; Associate this article with the current summary buffer.
3247 (setq gnus-article-current-summary gnus-summary-buffer)
3248 ;; Call the treatment functions.
3249 (let ((inhibit-read-only t)
3254 (gnus-article-prepare-mime-display)
3255 (narrow-to-region (goto-char (point-min))
3256 (if (search-forward "\n\n" nil t)
3259 (gnus-treat-article 'head)
3260 (put-text-property (point-min) (point-max) 'article-treated-header t)
3261 (goto-char (point-max))
3263 (narrow-to-region (point) (point-max))
3264 (gnus-treat-article nil))
3265 (put-text-property (point-min) (point-max) 'read-only nil)))
3266 ;; Perform the article display hooks. Incidentally, this hook is
3267 ;; an obsolete variable by now.
3268 (gnus-run-hooks 'gnus-article-display-hook))
3270 (defun gnus-article-decode-article-as-default-mime-charset ()
3271 "Decode an article as `default-mime-charset'. It won't work if the
3272 value of the variable `gnus-show-mime' is non-nil."
3273 (unless gnus-show-mime
3274 (decode-mime-charset-region (point-min) (point-max)
3275 (with-current-buffer gnus-summary-buffer
3276 default-mime-charset))))
3279 ;;; Gnus MIME viewing functions
3282 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3283 "The following specs can be used:
3285 %T MIME type, along with additional info
3286 %n The `name' parameter
3287 %d The description, if any
3288 %l The length of the encoded part
3289 %p The part identifier number
3290 %e Dots if the part isn't displayed")
3292 (defvar gnus-mime-button-line-format-alist
3293 '((?t gnus-tmp-type ?s)
3294 (?T gnus-tmp-type-long ?s)
3295 (?n gnus-tmp-name ?s)
3296 (?d gnus-tmp-description ?s)
3298 (?l gnus-tmp-length ?d)
3299 (?e gnus-tmp-dots ?s)))
3301 (defvar gnus-mime-button-commands
3302 '((gnus-article-press-button "\r" "Toggle Display")
3303 (gnus-mime-view-part "v" "View Interactively...")
3304 (gnus-mime-view-part-as-type "t" "View As Type...")
3305 (gnus-mime-view-part-as-charset "C" "View As charset...")
3306 (gnus-mime-save-part "o" "Save...")
3307 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
3308 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
3309 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
3310 (gnus-mime-internalize-part "E" "View Internally")
3311 (gnus-mime-externalize-part "e" "View Externally")
3312 (gnus-mime-pipe-part "|" "Pipe To Command...")
3313 (gnus-mime-action-on-part "." "Take action on the part")))
3315 (defun gnus-article-mime-part-status ()
3316 (with-current-buffer gnus-article-buffer
3317 (let ((entity (get-text-property (point-min) 'mime-view-entity)))
3318 (if (and entity (mime-entity-children entity))
3319 (format " (%d parts)" (length (mime-entity-children entity)))
3322 (defvar gnus-mime-button-map
3323 (let ((map (make-sparse-keymap)))
3324 (set-keymap-parent map gnus-article-mode-map)
3325 (define-key map gnus-mouse-2 'gnus-article-push-button)
3326 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
3327 (dolist (c gnus-mime-button-commands)
3328 (define-key map (cadr c) (car c)))
3331 (defun gnus-mime-button-menu (event)
3332 "Construct a context-sensitive menu of MIME commands."
3335 (let ((pos (event-start event)))
3336 (set-buffer (window-buffer (posn-window pos)))
3337 (goto-char (posn-point pos))
3338 (gnus-article-check-buffer)
3339 (let ((response (x-popup-menu
3341 ("" ,@(mapcar (lambda (c)
3342 (cons (caddr c) (car c)))
3343 gnus-mime-button-commands))))))
3345 (call-interactively response))))))
3347 (defun gnus-mime-view-all-parts (&optional handles)
3348 "View all the MIME parts."
3350 (save-current-buffer
3351 (set-buffer gnus-article-buffer)
3352 (let ((handles (or handles gnus-article-mime-handles))
3353 (mail-parse-charset gnus-newsgroup-charset)
3354 (mail-parse-ignored-charsets
3355 (save-excursion (set-buffer gnus-summary-buffer)
3356 gnus-newsgroup-ignored-charsets)))
3357 (if (stringp (car handles))
3358 (gnus-mime-view-all-parts (cdr handles))
3359 (mapcar 'mm-display-part handles)))))
3361 (defun gnus-mime-save-part-and-strip ()
3362 "Save the MIME part under point then replace it with an external body."
3364 (gnus-article-check-buffer)
3365 (let* ((data (get-text-property (point) 'gnus-data))
3366 (file (mm-save-part data))
3369 (with-current-buffer (mm-handle-buffer data)
3371 (insert "Content-Type: " (mm-handle-media-type data))
3372 (mml-insert-parameter-string (cdr (mm-handle-type data))
3375 (insert "Content-ID: " (message-make-message-id) "\n")
3376 (insert "Content-Transfer-Encoding: binary\n")
3379 (cdr (mm-make-handle nil
3380 `("message/external-body"
3381 (access-type . "LOCAL-FILE")
3383 (set-buffer gnus-summary-buffer)
3384 (gnus-article-edit-article
3387 (let ((mail-parse-charset (or gnus-article-charset
3388 ',gnus-newsgroup-charset))
3389 (mail-parse-ignored-charsets
3390 (or gnus-article-ignored-charsets
3391 ',gnus-newsgroup-ignored-charsets))
3392 (mbl mml-buffer-list))
3393 (setq mml-buffer-list nil)
3394 (insert-buffer gnus-original-article-buffer)
3395 (mime-to-mml gnus-article-mime-handles)
3396 (setq gnus-article-mime-handles nil)
3397 (make-local-hook 'kill-buffer-hook)
3398 (let ((mbl1 mml-buffer-list))
3399 (setq mml-buffer-list mbl)
3400 (set (make-local-variable 'mml-buffer-list) mbl1))
3401 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
3402 `(lambda (no-highlight)
3403 (let ((mail-parse-charset (or gnus-article-charset
3404 ',gnus-newsgroup-charset))
3405 (message-options message-options)
3406 (message-options-set-recipient)
3407 (mail-parse-ignored-charsets
3408 (or gnus-article-ignored-charsets
3409 ',gnus-newsgroup-ignored-charsets)))
3411 (mml-destroy-buffers)
3412 (remove-hook 'kill-buffer-hook
3413 'mml-destroy-buffers t)
3414 (kill-local-variable 'mml-buffer-list))
3415 (gnus-summary-edit-article-done
3416 ,(or (mail-header-references gnus-current-headers) "")
3417 ,(gnus-group-read-only-p)
3418 ,gnus-summary-buffer no-highlight))))))
3420 (defun gnus-mime-save-part ()
3421 "Save the MIME part under point."
3423 (gnus-article-check-buffer)
3424 (let ((data (get-text-property (point) 'gnus-data)))
3425 (mm-save-part data)))
3427 (defun gnus-mime-pipe-part ()
3428 "Pipe the MIME part under point to a process."
3430 (gnus-article-check-buffer)
3431 (let ((data (get-text-property (point) 'gnus-data)))
3432 (mm-pipe-part data)))
3434 (defun gnus-mime-view-part ()
3435 "Interactively choose a viewing method for the MIME part under point."
3437 (gnus-article-check-buffer)
3438 (let ((data (get-text-property (point) 'gnus-data)))
3439 (mm-interactively-view-part data)))
3441 (defun gnus-mime-view-part-as-type-internal ()
3442 (gnus-article-check-buffer)
3443 (let* ((name (mail-content-type-get
3444 (mm-handle-type (get-text-property (point) 'gnus-data))
3446 (def-type (and name (mm-default-file-encoding name))))
3447 (and def-type (cons def-type 0))))
3449 (defun gnus-mime-view-part-as-type (mime-type)
3450 "Choose a MIME media type, and view the part as such."
3452 (list (completing-read
3453 "View as MIME type: "
3454 (mapcar #'list (mailcap-mime-types))
3456 (gnus-mime-view-part-as-type-internal))))
3457 (gnus-article-check-buffer)
3458 (let ((handle (get-text-property (point) 'gnus-data)))
3459 (gnus-mm-display-part
3460 (mm-make-handle (mm-handle-buffer handle)
3461 (cons mime-type (cdr (mm-handle-type handle)))
3462 (mm-handle-encoding handle)
3463 (mm-handle-undisplayer handle)
3464 (mm-handle-disposition handle)
3465 (mm-handle-description handle)
3466 (mm-handle-cache handle)
3467 (mm-handle-id handle)))))
3469 (defun gnus-mime-copy-part (&optional handle)
3470 "Put the the MIME part under point into a new buffer."
3472 (gnus-article-check-buffer)
3473 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3474 (contents (mm-get-part handle))|
3475 (base (file-name-nondirectory
3477 (mail-content-type-get (mm-handle-type handle) 'name)
3478 (mail-content-type-get (mm-handle-type handle)
3481 (buffer (generate-new-buffer base)))
3482 (switch-to-buffer buffer)
3484 ;; We do it this way to make `normal-mode' set the appropriate mode.
3487 (setq buffer-file-name (expand-file-name base))
3489 (setq buffer-file-name nil))
3490 (goto-char (point-min))))
3492 (defun gnus-mime-inline-part (&optional handle arg)
3493 "Insert the MIME part under point into the current buffer."
3494 (interactive (list nil current-prefix-arg))
3495 (gnus-article-check-buffer)
3496 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3500 (if (and (not arg) (mm-handle-undisplayer handle))
3501 (mm-remove-part handle)
3502 (setq contents (mm-get-part handle))
3505 (setq charset (or (mail-content-type-get
3506 (mm-handle-type handle) 'charset)
3507 gnus-newsgroup-charset)))
3509 (if (mm-handle-undisplayer handle)
3510 (mm-remove-part handle))
3513 gnus-summary-show-article-charset-alist))
3514 (read-coding-system "Charset: ")))))
3516 (mm-insert-inline handle
3518 (setq charset (mm-charset-to-coding-system
3520 (not (eq charset 'ascii)))
3521 (mm-decode-coding-string contents charset)
3525 (defun gnus-mime-view-part-as-charset (&optional handle arg)
3526 "Insert the MIME part under point into the current buffer."
3527 (interactive (list nil current-prefix-arg))
3528 (gnus-article-check-buffer)
3529 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3533 (if (mm-handle-undisplayer handle)
3534 (mm-remove-part handle))
3535 (let ((gnus-newsgroup-charset
3537 gnus-summary-show-article-charset-alist))
3538 (read-coding-system "Charset: ")))
3539 (gnus-newsgroup-ignored-charsets 'gnus-all))
3540 (gnus-article-press-button))))
3542 (defun gnus-mime-externalize-part (&optional handle)
3543 "View the MIME part under point with an external viewer."
3545 (gnus-article-check-buffer)
3546 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3547 (mm-user-display-methods nil)
3548 (mm-inlined-types nil)
3549 (mail-parse-charset gnus-newsgroup-charset)
3550 (mail-parse-ignored-charsets
3551 (save-excursion (set-buffer gnus-summary-buffer)
3552 gnus-newsgroup-ignored-charsets)))
3553 (if (mm-handle-undisplayer handle)
3554 (mm-remove-part handle)
3555 (mm-display-part handle))))
3557 (defun gnus-mime-internalize-part (&optional handle)
3558 "View the MIME part under point with an internal viewer.
3559 In no internal viewer is available, use an external viewer."
3561 (gnus-article-check-buffer)
3562 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3563 (mm-inlined-types '(".*"))
3564 (mm-inline-large-images t)
3565 (mail-parse-charset gnus-newsgroup-charset)
3566 (mail-parse-ignored-charsets
3567 (save-excursion (set-buffer gnus-summary-buffer)
3568 gnus-newsgroup-ignored-charsets)))
3569 (if (mm-handle-undisplayer handle)
3570 (mm-remove-part handle)
3571 (mm-display-part handle))))
3573 (defun gnus-mime-action-on-part (&optional action)
3574 "Do something with the MIME attachment at \(point\)."
3576 (list (completing-read "Action: " gnus-mime-action-alist)))
3577 (gnus-article-check-buffer)
3578 (let ((action-pair (assoc action gnus-mime-action-alist)))
3580 (funcall (cdr action-pair)))))
3583 (defun gnus-article-part-wrapper (n function)
3584 (save-current-buffer
3585 (set-buffer gnus-article-buffer)
3586 (when (> n (length gnus-article-mime-handle-alist))
3587 (error "No such part"))
3588 (gnus-article-goto-part n)
3589 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
3590 (funcall function handle))))
3592 (defun gnus-article-pipe-part (n)
3593 "Pipe MIME part N, which is the numerical prefix."
3595 (gnus-article-part-wrapper n 'mm-pipe-part))
3597 (defun gnus-article-save-part (n)
3598 "Save MIME part N, which is the numerical prefix."
3600 (gnus-article-part-wrapper n 'mm-save-part))
3602 (defun gnus-article-interactively-view-part (n)
3603 "View MIME part N interactively, which is the numerical prefix."
3605 (gnus-article-part-wrapper n 'mm-interactively-view-part))
3607 (defun gnus-article-copy-part (n)
3608 "Copy MIME part N, which is the numerical prefix."
3610 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
3612 (defun gnus-article-view-part-as-charset (n)
3613 "Copy MIME part N, which is the numerical prefix."
3615 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
3617 (defun gnus-article-externalize-part (n)
3618 "View MIME part N externally, which is the numerical prefix."
3620 (gnus-article-part-wrapper n 'gnus-mime-externalize-part))
3622 (defun gnus-article-inline-part (n)
3623 "Inline MIME part N, which is the numerical prefix."
3625 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
3627 (defun gnus-article-mime-match-handle-first (condition)
3629 (let ((alist gnus-article-mime-handle-alist) ihandle n)
3630 (while (setq ihandle (pop alist))
3632 ((functionp condition)
3633 (funcall condition (cdr ihandle)))
3634 ((eq condition 'undisplayed)
3635 (not (or (mm-handle-undisplayer (cdr ihandle))
3636 (equal (mm-handle-media-type (cdr ihandle))
3637 "multipart/alternative"))))
3638 ((eq condition 'undisplayed-alternative)
3639 (not (mm-handle-undisplayer (cdr ihandle))))
3641 (gnus-article-goto-part (car ihandle))
3642 (or (not n) (< (car ihandle) n)))
3643 (setq n (car ihandle))))
3647 (defun gnus-article-view-part (&optional n)
3648 "View MIME part N, which is the numerical prefix."
3650 (save-current-buffer
3651 (set-buffer gnus-article-buffer)
3652 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
3653 gnus-article-mime-match-handle-function)))
3654 (when (> n (length gnus-article-mime-handle-alist))
3655 (error "No such part"))
3656 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
3657 (when (gnus-article-goto-part n)
3658 (if (equal (car handle) "multipart/alternative")
3659 (gnus-article-press-button)
3660 (when (eq (gnus-mm-display-part handle) 'internal)
3661 (gnus-set-window-start)))))))
3663 (defsubst gnus-article-mime-total-parts ()
3664 (if (bufferp (car gnus-article-mime-handles))
3666 (1- (length gnus-article-mime-handles))))
3668 (defun gnus-mm-display-part (handle)
3669 "Display HANDLE and fix MIME button."
3670 (let ((id (get-text-property (point) 'gnus-part))
3675 (let ((window (selected-window))
3676 (mail-parse-charset gnus-newsgroup-charset)
3677 (mail-parse-ignored-charsets
3678 (save-excursion (set-buffer gnus-summary-buffer)
3679 gnus-newsgroup-ignored-charsets)))
3682 (let ((win (get-buffer-window (current-buffer) t))
3685 (select-window win))
3688 (if (mm-handle-displayed-p handle)
3689 ;; This will remove the part.
3690 (mm-display-part handle)
3692 (narrow-to-region (point) (1+ (point)))
3693 (mm-display-part handle)
3694 ;; We narrow to the part itself and
3695 ;; then call the treatment functions.
3696 (goto-char (point-min))
3698 (narrow-to-region (point) (point-max))
3701 (gnus-article-mime-total-parts)
3702 (mm-handle-media-type handle)))))
3703 (select-window window))))
3705 (delete-region (gnus-point-at-bol) (progn (forward-line 1) (point)))
3706 (gnus-insert-mime-button
3707 handle id (list (mm-handle-displayed-p handle)))
3708 (goto-char point))))
3710 (defun gnus-article-goto-part (n)
3711 "Go to MIME part N."
3712 (let ((point (text-property-any (point-min) (point-max) 'gnus-part n)))
3714 (goto-char point))))
3716 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
3717 (let ((gnus-tmp-name
3718 (or (mail-content-type-get (mm-handle-type handle)
3720 (mail-content-type-get (mm-handle-disposition handle)
3722 (mail-content-type-get (mm-handle-type handle)
3725 (gnus-tmp-type (mm-handle-media-type handle))
3726 (gnus-tmp-description
3727 (mail-decode-encoded-word-string (or (mm-handle-description handle)
3730 (if (if displayed (car displayed)
3731 (mm-handle-displayed-p handle))
3733 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
3735 gnus-tmp-type-long b e)
3736 (when (string-match ".*/" gnus-tmp-name)
3737 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
3738 (setq gnus-tmp-type-long (concat gnus-tmp-type
3739 (and (not (equal gnus-tmp-name ""))
3740 (concat "; " gnus-tmp-name))))
3741 (or (equal gnus-tmp-description "")
3742 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
3747 gnus-mime-button-line-format gnus-mime-button-line-format-alist
3748 `(local-map ,gnus-mime-button-map
3749 keymap ,gnus-mime-button-map
3750 gnus-callback gnus-mm-display-part
3751 gnus-part ,gnus-tmp-id
3752 article-type annotation
3755 (widget-convert-button
3758 :action 'gnus-widget-press-button
3759 :button-keymap gnus-mime-button-map
3761 (lambda (widget/window &optional overlay pos)
3762 ;; Needed to properly clear the message due to a bug in
3763 ;; wid-edit (XEmacs only).
3764 (if (boundp 'help-echo-owns-message)
3765 (setq help-echo-owns-message t))
3767 "%S: %s the MIME part; %S: more options"
3768 (aref gnus-mouse-2 0)
3769 ;; XEmacs will get a single widget arg; Emacs 21 will get
3770 ;; window, overlay, position.
3771 (if (mm-handle-displayed-p
3773 (with-current-buffer (gnus-overlay-buffer overlay)
3774 (widget-get (widget-at (gnus-overlay-start overlay))
3776 (widget-get widget/window :mime-handle)))
3778 (aref gnus-down-mouse-3 0))))))
3780 (defun gnus-widget-press-button (elems el)
3781 (goto-char (widget-get elems :from))
3782 (gnus-article-press-button))
3784 (defvar gnus-displaying-mime nil)
3786 (defun gnus-display-mime (&optional ihandles)
3787 "Display the MIME parts."
3789 (save-selected-window
3790 (let ((window (get-buffer-window gnus-article-buffer))
3793 (select-window window)
3794 ;; We have to do this since selecting the window
3795 ;; may change the point. So we set the window point.
3796 (set-window-point window point)))
3797 (let* ((handles (or ihandles (mm-dissect-buffer) (mm-uu-dissect)))
3798 buffer-read-only handle name type b e display)
3799 (when (and (not ihandles)
3800 (not gnus-displaying-mime))
3801 ;; Top-level call; we clean up.
3802 (when gnus-article-mime-handles
3803 (mm-destroy-parts gnus-article-mime-handles)
3804 (setq gnus-article-mime-handle-alist nil));; A trick.
3805 (setq gnus-article-mime-handles handles)
3806 ;; We allow users to glean info from the handles.
3807 (when gnus-article-mime-part-function
3808 (gnus-mime-part-function handles)))
3810 (or (not (stringp (car handles)))
3813 (when (and (not ihandles)
3814 (not gnus-displaying-mime))
3815 ;; Clean up for mime parts.
3817 (delete-region (point) (point-max)))
3818 (let ((gnus-displaying-mime t))
3819 (gnus-mime-display-part handles)))
3822 (narrow-to-region (point) (point-max))
3823 (gnus-treat-article nil 1 1)
3826 ;; Highlight the headers.
3830 (narrow-to-region (point-min) (point))
3831 (gnus-treat-article 'head))))))))
3833 (defvar gnus-mime-display-multipart-as-mixed nil)
3835 (defun gnus-mime-display-part (handle)
3838 ((not (stringp (car handle)))
3839 (gnus-mime-display-single handle))
3840 ;; User-defined multipart
3841 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
3842 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
3844 ;; multipart/alternative
3845 ((and (equal (car handle) "multipart/alternative")
3846 (not gnus-mime-display-multipart-as-mixed))
3847 (let ((id (1+ (length gnus-article-mime-handle-alist))))
3848 (push (cons id handle) gnus-article-mime-handle-alist)
3849 (gnus-mime-display-alternative (cdr handle) nil nil id)))
3850 ;; multipart/related
3851 ((and (equal (car handle) "multipart/related")
3852 (not gnus-mime-display-multipart-as-mixed))
3853 ;;;!!!We should find the start part, but we just default
3854 ;;;!!!to the first part.
3855 (gnus-mime-display-part (cadr handle)))
3856 ;; Other multiparts are handled like multipart/mixed.
3857 ((equal (car handle) "multipart/signed")
3858 (or (memq 'signed gnus-article-wash-types)
3859 (push 'signed gnus-article-wash-types))
3860 (gnus-mime-display-mixed (cdr handle)))
3861 ((equal (car handle) "multipart/encrypted")
3862 (or (memq 'encrypted gnus-article-wash-types)
3863 (push 'encrypted gnus-article-wash-types))
3864 (gnus-mime-display-mixed (cdr handle)))
3866 (gnus-mime-display-mixed (cdr handle)))))
3868 (defun gnus-mime-part-function (handles)
3869 (if (stringp (car handles))
3870 (mapcar 'gnus-mime-part-function (cdr handles))
3871 (funcall gnus-article-mime-part-function handles)))
3873 (defun gnus-mime-display-mixed (handles)
3874 (mapcar 'gnus-mime-display-part handles))
3876 (defun gnus-mime-display-single (handle)
3877 (let ((type (mm-handle-media-type handle))
3878 (ignored gnus-ignored-mime-types)
3885 (when (string-match (pop ignored) type)
3886 (throw 'ignored nil)))
3887 (if (and (setq not-attachment
3888 (and (not (mm-inline-override-p handle))
3889 (or (not (mm-handle-disposition handle))
3890 (equal (car (mm-handle-disposition handle))
3892 (mm-attachment-override-p handle))))
3893 (mm-automatic-display-p handle)
3894 (or (mm-inlined-p handle)
3895 (mm-automatic-external-display-p type)))
3897 (when (equal (mm-handle-media-supertype handle) "text")
3899 (let ((id (1+ (length gnus-article-mime-handle-alist)))
3901 (push (cons id handle) gnus-article-mime-handle-alist)
3902 (when (or (not display)
3903 (not (gnus-unbuttonized-mime-type-p type)))
3904 ;(gnus-article-insert-newline)
3905 (gnus-insert-mime-button
3906 handle id (list (or display (and not-attachment text))))
3907 (gnus-article-insert-newline)
3908 ;(gnus-article-insert-newline)
3909 ;; Remember modify the number of forward lines.
3917 (let ((mail-parse-charset gnus-newsgroup-charset)
3918 (mail-parse-ignored-charsets
3919 (save-excursion (condition-case ()
3920 (set-buffer gnus-summary-buffer)
3922 gnus-newsgroup-ignored-charsets)))
3923 (mm-display-part handle t))
3924 (goto-char (point-max)))
3925 ((and text not-attachment)
3929 (gnus-article-insert-newline)
3930 (mm-insert-inline handle (mm-get-part handle))
3931 (goto-char (point-max))))
3935 (narrow-to-region beg (point))
3938 (gnus-article-mime-total-parts)
3939 (mm-handle-media-type handle)))))))))
3941 (defun gnus-unbuttonized-mime-type-p (type)
3942 "Say whether TYPE is to be unbuttonized."
3943 (unless gnus-inhibit-mime-unbuttonizing
3945 (let ((types gnus-unbuttonized-mime-types))
3947 (when (string-match (pop types) type)
3948 (throw 'found t)))))))
3950 (defun gnus-article-insert-newline ()
3951 "Insert a newline, but mark it as undeletable."
3952 (gnus-put-text-property
3953 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
3955 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
3956 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
3959 handle buffer-read-only from props begend not-pref)
3960 (save-window-excursion
3963 (narrow-to-region (car ibegend)
3966 (goto-char (car ibegend))
3969 (delete-region (point-min) (point-max))
3970 (mm-remove-parts handles))
3971 (setq begend (list (point-marker)))
3973 (unless (setq not-pref (cadr (member preferred ihandles)))
3974 (setq not-pref (car ihandles)))
3976 (not (gnus-unbuttonized-mime-type-p
3977 "multipart/alternative")))
3978 (gnus-add-text-properties
3981 (insert (format "%d. " id))
3985 (unless ,(not ibegend)
3986 (setq gnus-article-mime-handle-alist
3987 ',gnus-article-mime-handle-alist))
3988 (gnus-mime-display-alternative
3989 ',ihandles ',not-pref ',begend ,id))
3990 local-map ,gnus-mime-button-map
3991 ,gnus-mouse-face-prop ,gnus-article-mouse-face
3992 face ,gnus-article-button-face
3993 keymap ,gnus-mime-button-map
3996 (widget-convert-button 'link from (point)
3997 :action 'gnus-widget-press-button
3998 :button-keymap gnus-widget-button-keymap)
4000 (while (setq handle (pop handles))
4001 (gnus-add-text-properties
4004 (insert (format "(%c) %-18s"
4005 (if (equal handle preferred) ?* ? )
4006 (mm-handle-media-type handle)))
4010 (unless ,(not ibegend)
4011 (setq gnus-article-mime-handle-alist
4012 ',gnus-article-mime-handle-alist))
4013 (gnus-mime-display-alternative
4014 ',ihandles ',handle ',begend ,id))
4015 local-map ,gnus-mime-button-map
4016 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4017 face ,gnus-article-button-face
4018 keymap ,gnus-mime-button-map
4021 (widget-convert-button 'link from (point)
4022 :action 'gnus-widget-press-button
4023 :button-keymap gnus-widget-button-keymap)
4027 (if (stringp (car preferred))
4028 (gnus-display-mime preferred)
4029 (let ((mail-parse-charset gnus-newsgroup-charset)
4030 (mail-parse-ignored-charsets
4031 (save-excursion (set-buffer gnus-summary-buffer)
4032 gnus-newsgroup-ignored-charsets)))
4033 (mm-display-part preferred)
4037 (narrow-to-region (car begend) (point-max))
4039 nil (length gnus-article-mime-handle-alist)
4040 (gnus-article-mime-total-parts)
4041 (mm-handle-media-type handle))))))
4042 (goto-char (point-max))
4043 (setcdr begend (point-marker)))))
4045 (goto-char point))))
4047 (defun gnus-article-wash-status ()
4048 "Return a string which display status of article washing."
4050 (set-buffer gnus-article-buffer)
4051 (let ((cite (memq 'cite gnus-article-wash-types))
4052 (headers (memq 'headers gnus-article-wash-types))
4053 (boring (memq 'boring-headers gnus-article-wash-types))
4054 (pgp (memq 'pgp gnus-article-wash-types))
4055 (pem (memq 'pem gnus-article-wash-types))
4056 (signed (memq 'signed gnus-article-wash-types))
4057 (encrypted (memq 'encrypted gnus-article-wash-types))
4058 (signature (memq 'signature gnus-article-wash-types))
4059 (overstrike (memq 'overstrike gnus-article-wash-types))
4060 (emphasis (memq 'emphasis gnus-article-wash-types)))
4061 (format "%c%c%c%c%c%c%c"
4063 (if (or headers boring) ?h ? )
4064 (if (or pgp pem signed encrypted) ?p ? )
4065 (if signature ?s ? )
4066 (if overstrike ?o ? )
4067 (if gnus-show-mime ?m ? )
4068 (if emphasis ?e ? )))))
4070 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
4072 (defun gnus-article-maybe-hide-headers ()
4073 "Hide unwanted headers if `gnus-have-all-headers' is nil.
4074 Provided for backwards compatibility."
4075 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
4076 (not (save-excursion (set-buffer gnus-summary-buffer)
4077 gnus-have-all-headers)))
4078 (not gnus-inhibit-hiding))
4079 (gnus-article-hide-headers)))
4083 (defun gnus-output-to-file (file-name)
4084 "Append the current article to a file named FILE-NAME."
4085 (let ((artbuf (current-buffer)))
4087 (insert-buffer-substring artbuf)
4088 ;; Append newline at end of the buffer as separator, and then
4090 (goto-char (point-max))
4092 (write-region-as-binary (point-min) (point-max) file-name 'append)
4095 (defun gnus-narrow-to-page (&optional arg)
4096 "Narrow the article buffer to a page.
4097 If given a numerical ARG, move forward ARG pages."
4099 (setq arg (if arg (prefix-numeric-value arg) 0))
4101 (set-buffer gnus-article-buffer)
4102 (goto-char (point-min))
4104 ;; Remove any old next/prev buttons.
4105 (when (gnus-visual-p 'page-marker)
4106 (let ((buffer-read-only nil))
4107 (gnus-remove-text-with-property 'gnus-prev)
4108 (gnus-remove-text-with-property 'gnus-next)))
4111 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
4113 (re-search-forward page-delimiter nil 'move arg)))
4114 (goto-char (match-end 0)))
4117 (if (re-search-forward page-delimiter nil 'move)
4120 (when (and (gnus-visual-p 'page-marker)
4121 (not (= (point-min) 1)))
4123 (goto-char (point-min))
4124 (gnus-insert-prev-page-button)))
4125 (when (and (gnus-visual-p 'page-marker)
4126 (< (+ (point-max) 2) (buffer-size)))
4128 (goto-char (point-max))
4129 (gnus-insert-next-page-button)))))
4131 ;; Article mode commands
4133 (defun gnus-article-goto-next-page ()
4134 "Show the next page of the article."
4136 (when (gnus-article-next-page)
4137 (goto-char (point-min))
4138 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
4140 (defun gnus-article-goto-prev-page ()
4141 "Show the next page of the article."
4143 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
4144 (gnus-article-prev-page nil)))
4146 (defun gnus-article-next-page (&optional lines)
4147 "Show the next page of the current article.
4148 If end of article, return non-nil. Otherwise return nil.
4149 Argument LINES specifies lines to be scrolled up."
4151 (let ((start (window-start))
4152 end-of-buffer end-of-page)
4154 (move-to-window-line -1)
4155 (if (<= (point) start)
4158 (setq start (point)))
4161 (unless (or (cond ((eq (1+ (buffer-size)) (point))
4162 (and (pos-visible-in-window-p)
4163 (setq end-of-buffer t)))
4165 (setq end-of-page t)))
4167 (move-to-window-line lines)
4168 (unless (search-backward "\n\n" nil t)
4169 (setq start (point)))))
4170 (cond (end-of-buffer t)
4172 (gnus-narrow-to-page 1)
4176 (set-window-start (selected-window) start)
4177 (let (window-pixel-scroll-increment)
4181 (defun gnus-article-prev-page (&optional lines)
4182 "Show previous page of current article.
4183 Argument LINES specifies lines to be scrolled down."
4185 (let (beginning-of-buffer beginning-of-page)
4187 (move-to-window-line 0)
4188 (cond ((eq 1 (point))
4189 (setq beginning-of-buffer t))
4191 (setq beginning-of-page t))))
4192 (cond (beginning-of-buffer)
4194 (gnus-narrow-to-page -1))
4197 (let (window-pixel-scroll-increment)
4198 (scroll-down lines))
4199 (beginning-of-buffer
4200 (goto-char (point-min))))))))
4202 (defun gnus-article-refer-article ()
4203 "Read article specified by message-id around point."
4205 (let ((point (point)))
4206 (search-forward ">" nil t) ;Move point to end of "<....>".
4207 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
4208 (let ((message-id (match-string 1)))
4210 (set-buffer gnus-summary-buffer)
4211 (gnus-summary-refer-article message-id))
4213 (error "No references around point"))))
4215 (defun gnus-article-show-summary ()
4216 "Reconfigure windows to show summary buffer."
4218 (if (not (gnus-buffer-live-p gnus-summary-buffer))
4219 (error "There is no summary buffer for this article buffer")
4220 (gnus-article-set-globals)
4221 (gnus-configure-windows 'article)
4222 (gnus-summary-goto-subject gnus-current-article)
4223 (gnus-summary-position-point)))
4225 (defun gnus-article-describe-briefly ()
4226 "Describe article mode commands briefly."
4228 (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")))
4230 (defun gnus-article-summary-command ()
4231 "Execute the last keystroke in the summary buffer."
4233 (let ((obuf (current-buffer))
4234 (owin (current-window-configuration))
4236 (switch-to-buffer gnus-article-current-summary 'norecord)
4237 (setq func (lookup-key (current-local-map) (this-command-keys)))
4238 (call-interactively func)
4240 (set-window-configuration owin)
4241 (set-window-point (get-buffer-window (current-buffer)) (point))))
4243 (defun gnus-article-summary-command-nosave ()
4244 "Execute the last keystroke in the summary buffer."
4247 (pop-to-buffer gnus-article-current-summary 'norecord)
4248 (setq func (lookup-key (current-local-map) (this-command-keys)))
4249 (call-interactively func)))
4251 (defun gnus-article-check-buffer ()
4252 "Beep if not in an article buffer."
4253 (unless (eq (get-buffer gnus-article-buffer) (current-buffer))
4254 (error "Command invoked outside of a Gnus article buffer")))
4256 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
4257 "Read a summary buffer key sequence and execute it from the article buffer."
4259 (gnus-article-check-buffer)
4261 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
4262 "Zc" "ZC" "ZE" "ZJ" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
4263 "=" "^" "\M-^" "|"))
4269 '("n" "Gn" "p" "Gp"))
4272 (set-buffer gnus-article-current-summary)
4273 (let (gnus-pick-mode)
4274 (push (or key last-command-event) unread-command-events)
4275 (setq keys (static-if (featurep 'xemacs)
4276 (events-to-keys (read-key-sequence nil))
4277 (read-key-sequence nil)))))
4280 (if (or (member keys nosaves)
4281 (member keys nosave-but-article)
4282 (member keys nosave-in-article))
4284 (save-window-excursion
4285 (pop-to-buffer gnus-article-current-summary 'norecord)
4286 ;; We disable the pick minor mode commands.
4287 (let (gnus-pick-mode)
4288 (setq func (lookup-key (current-local-map) keys))))
4292 (unless (member keys nosave-in-article)
4293 (set-buffer gnus-article-current-summary))
4294 (call-interactively func)
4295 (setq new-sum-point (point)))
4296 (when (member keys nosave-but-article)
4297 (pop-to-buffer gnus-article-buffer 'norecord)))
4298 ;; These commands should restore window configuration.
4299 (let ((obuf (current-buffer))
4300 (owin (current-window-configuration))
4302 (summary gnus-article-current-summary)
4303 func in-buffer selected)
4304 (if not-restore-window
4305 (pop-to-buffer summary 'norecord)
4306 (switch-to-buffer summary 'norecord))
4307 (setq in-buffer (current-buffer))
4308 ;; We disable the pick minor mode commands.
4309 (if (setq func (let (gnus-pick-mode)
4310 (lookup-key (current-local-map) keys)))
4312 (call-interactively func)
4313 (setq new-sum-point (point)))
4315 (when (eq in-buffer (current-buffer))
4316 (setq selected (gnus-summary-select-article))
4318 (unless not-restore-window
4319 (set-window-configuration owin))
4320 (when (eq selected 'old)
4322 (set-window-start (get-buffer-window (current-buffer))
4324 (set-window-point (get-buffer-window (current-buffer))
4326 (let ((win (get-buffer-window gnus-article-current-summary)))
4328 (set-window-point win new-sum-point))))))))
4330 (defun gnus-article-hide (&optional arg force)
4331 "Hide all the gruft in the current article.
4332 This means that PGP stuff, signatures, cited text and (some)
4333 headers will be hidden.
4334 If given a prefix, show the hidden text instead."
4335 (interactive (append (gnus-article-hidden-arg) (list 'force)))
4336 (gnus-article-hide-headers arg)
4337 (gnus-article-hide-list-identifiers arg)
4338 (gnus-article-hide-pgp arg)
4339 (gnus-article-hide-citation-maybe arg force)
4340 (gnus-article-hide-signature arg))
4342 (defun gnus-article-maybe-highlight ()
4343 "Do some article highlighting if article highlighting is requested."
4344 (when (gnus-visual-p 'article-highlight 'highlight)
4345 (gnus-article-highlight-some)))
4347 (defun gnus-check-group-server ()
4348 ;; Make sure the connection to the server is alive.
4349 (unless (gnus-server-opened
4350 (gnus-find-method-for-group gnus-newsgroup-name))
4351 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
4352 (gnus-request-group gnus-newsgroup-name t)))
4354 (defun gnus-request-article-this-buffer (article group)
4355 "Get an article and insert it into this buffer."
4356 (let (do-update-line sparse-header)
4360 (gnus-kill-all-overlays)
4361 (setq group (or group gnus-newsgroup-name))
4363 ;; Using `gnus-request-article' directly will insert the article into
4364 ;; `nntp-server-buffer' - so we'll save some time by not having to
4365 ;; copy it from the server buffer into the article buffer.
4367 ;; We only request an article by message-id when we do not have the
4368 ;; headers for it, so we'll have to get those.
4369 (when (stringp article)
4370 (gnus-read-header article))
4372 ;; If the article number is negative, that means that this article
4373 ;; doesn't belong in this newsgroup (possibly), so we find its
4374 ;; message-id and request it by id instead of number.
4375 (when (and (numberp article)
4377 (get-buffer gnus-summary-buffer)
4378 (gnus-buffer-exists-p gnus-summary-buffer))
4380 (set-buffer gnus-summary-buffer)
4381 (let ((header (gnus-summary-article-header article)))
4384 ((memq article gnus-newsgroup-sparse)
4385 ;; This is a sparse gap article.
4386 (setq do-update-line article)
4387 (setq article (mail-header-id header))
4388 (setq sparse-header (gnus-read-header article))
4389 (setq gnus-newsgroup-sparse
4390 (delq article gnus-newsgroup-sparse)))
4392 ;; It's a real article.
4393 (setq article (mail-header-id header)))
4395 ;; It is an extracted pseudo-article.
4396 (setq article 'pseudo)
4397 (gnus-request-pseudo-article header))))
4399 (let ((method (gnus-find-method-for-group
4400 gnus-newsgroup-name)))
4401 (when (and (eq (car method) 'nneething)
4403 (let ((dir (expand-file-name
4404 (mail-header-subject header)
4405 (file-name-as-directory
4406 (or (cadr (assq 'nneething-address method))
4408 (when (file-directory-p dir)
4409 (setq article 'nneething)
4410 (gnus-group-enter-directory dir))))))))
4413 ;; Refuse to select canceled articles.
4414 ((and (numberp article)
4416 (get-buffer gnus-summary-buffer)
4417 (gnus-buffer-exists-p gnus-summary-buffer)
4418 (eq (cdr (save-excursion
4419 (set-buffer gnus-summary-buffer)
4420 (assq article gnus-newsgroup-reads)))
4421 gnus-canceled-mark))
4423 ;; Check the backlog.
4424 ((and gnus-keep-backlog
4425 (gnus-backlog-request-article group article (current-buffer)))
4427 ;; Check asynchronous pre-fetch.
4428 ((gnus-async-request-fetched-article group article (current-buffer))
4429 (gnus-async-prefetch-next group article gnus-summary-buffer)
4430 (when (and (numberp article) gnus-keep-backlog)
4431 (gnus-backlog-enter-article group article (current-buffer)))
4434 ((and gnus-use-cache
4436 (gnus-cache-request-article article group))
4438 ;; Get the article and put into the article buffer.
4439 ((or (stringp article)
4441 (let ((gnus-override-method gnus-override-method)
4442 (methods (and (stringp article)
4443 gnus-refer-article-method))
4445 (buffer-read-only nil))
4446 (if (or (not (listp methods))
4447 (and (symbolp (car methods))
4448 (assq (car methods) nnoo-definition-alist)))
4449 (setq methods (list methods)))
4450 (when (and (null gnus-override-method)
4452 (setq gnus-override-method (pop methods)))
4454 (when (eq gnus-override-method 'current)
4455 (setq gnus-override-method gnus-current-select-method))
4457 (gnus-kill-all-overlays)
4458 (let ((gnus-newsgroup-name group))
4459 (gnus-check-group-server))
4460 (when (gnus-request-article article group (current-buffer))
4461 (when (numberp article)
4462 (gnus-async-prefetch-next group article
4463 gnus-summary-buffer)
4464 (when gnus-keep-backlog
4465 (gnus-backlog-enter-article
4466 group article (current-buffer))))
4467 (setq result 'article))
4470 (setq gnus-override-method (pop methods))
4471 (setq result 'done))))
4472 (and (eq result 'article) 'article)))
4476 ;; Associate this article with the current summary buffer.
4477 (setq gnus-article-current-summary gnus-summary-buffer)
4479 ;; Take the article from the original article buffer
4480 ;; and place it in the buffer it's supposed to be in.
4481 (when (and (get-buffer gnus-article-buffer)
4482 (equal (buffer-name (current-buffer))
4483 (buffer-name (get-buffer gnus-article-buffer))))
4485 (if (get-buffer gnus-original-article-buffer)
4486 (set-buffer gnus-original-article-buffer)
4487 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
4488 (set-buffer-multibyte nil)
4489 (buffer-disable-undo)
4490 (setq major-mode 'gnus-original-article-mode)
4491 (setq buffer-read-only t))
4492 (let (buffer-read-only)
4494 (insert-buffer-substring gnus-article-buffer))
4495 (setq gnus-original-article (cons group article)))
4498 (run-hooks 'gnus-article-decode-hook)
4499 ;; Mark article as decoded or not.
4500 (setq gnus-article-decoded-p gnus-article-decode-hook))
4502 ;; Update sparse articles.
4503 (when (and do-update-line
4504 (or (numberp article)
4506 (let ((buf (current-buffer)))
4507 (set-buffer gnus-summary-buffer)
4508 (gnus-summary-update-article do-update-line sparse-header)
4509 (gnus-summary-goto-subject do-update-line nil t)
4510 (set-window-point (get-buffer-window (current-buffer) t)
4512 (set-buffer buf))))))
4518 (defcustom gnus-article-edit-mode-hook nil
4519 "Hook run in article edit mode buffers."
4520 :group 'gnus-article-various
4523 (defcustom gnus-article-edit-article-setup-function
4524 'gnus-article-mime-edit-article-setup
4525 "Function called to setup an editing article buffer."
4526 :group 'gnus-article-various
4529 (defvar gnus-article-edit-done-function nil)
4531 (defvar gnus-article-edit-mode-map nil)
4533 ;; Should we be using derived.el for this?
4534 (unless gnus-article-edit-mode-map
4535 (setq gnus-article-edit-mode-map (make-sparse-keymap))
4536 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
4538 (gnus-define-keys gnus-article-edit-mode-map
4539 "\C-c\C-c" gnus-article-edit-done
4540 "\C-c\C-k" gnus-article-edit-exit)
4542 (gnus-define-keys (gnus-article-edit-wash-map
4543 "\C-c\C-w" gnus-article-edit-mode-map)
4544 "f" gnus-article-edit-full-stops))
4546 (defun gnus-article-edit-mode ()
4547 "Major mode for editing articles.
4548 This is an extended text-mode.
4550 \\{gnus-article-edit-mode-map}"
4552 (setq major-mode 'gnus-article-edit-mode)
4553 (setq mode-name "Article Edit")
4554 (use-local-map gnus-article-edit-mode-map)
4555 (make-local-variable 'gnus-article-edit-done-function)
4556 (make-local-variable 'gnus-prev-winconf)
4557 (setq buffer-read-only nil)
4558 (buffer-enable-undo)
4560 (gnus-run-hooks 'text-mode-hook 'gnus-article-edit-mode-hook))
4562 (defun gnus-article-edit (&optional force)
4563 "Edit the current article.
4564 This will have permanent effect only in mail groups.
4565 If FORCE is non-nil, allow editing of articles even in read-only
4568 (when (and (not force)
4569 (gnus-group-read-only-p))
4570 (error "The current newsgroup does not support article editing"))
4571 (gnus-article-date-original)
4572 (gnus-article-edit-article
4574 `(lambda (no-highlight)
4576 (gnus-summary-edit-article-done
4577 ,(or (mail-header-references gnus-current-headers) "")
4578 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
4580 (defun gnus-article-edit-article (start-func exit-func)
4581 "Start editing the contents of the current article buffer."
4582 (let ((winconf (current-window-configuration)))
4583 (set-buffer gnus-article-buffer)
4584 (gnus-article-edit-mode)
4585 (funcall start-func)
4586 (gnus-configure-windows 'edit-article)
4587 (setq gnus-article-edit-done-function exit-func)
4588 (setq gnus-prev-winconf winconf)
4589 (when gnus-article-edit-article-setup-function
4590 (funcall gnus-article-edit-article-setup-function))
4591 (gnus-message 6 "C-c C-c to end edits")))
4593 (defun gnus-article-edit-done (&optional arg)
4594 "Update the article edits and exit."
4596 (let ((func gnus-article-edit-done-function)
4597 (buf (current-buffer))
4598 (start (window-start)))
4599 (remove-hook 'gnus-article-mode-hook
4600 'gnus-article-mime-edit-article-unwind)
4601 (gnus-article-edit-exit)
4604 (let ((buffer-read-only nil))
4606 ;; The cache and backlog have to be flushed somewhat.
4607 (when gnus-keep-backlog
4608 (gnus-backlog-remove-article
4609 (car gnus-article-current) (cdr gnus-article-current)))
4610 ;; Flush original article as well.
4612 (when (get-buffer gnus-original-article-buffer)
4613 (set-buffer gnus-original-article-buffer)
4614 (setq gnus-original-article nil)))
4615 (when gnus-use-cache
4616 (gnus-cache-update-article
4617 (car gnus-article-current) (cdr gnus-article-current))))
4619 (set-window-start (get-buffer-window buf) start)
4620 (set-window-point (get-buffer-window buf) (point))))
4622 (defun gnus-article-edit-exit ()
4623 "Exit the article editing without updating."
4625 ;; We remove all text props from the article buffer.
4626 (let ((buf (buffer-substring-no-properties (point-min) (point-max)))
4627 (curbuf (current-buffer))
4629 (window-start (window-start)))
4632 (let ((winconf gnus-prev-winconf))
4634 (set-window-configuration winconf)
4635 ;; Tippy-toe some to make sure that point remains where it was.
4636 (save-current-buffer
4638 (set-window-start (get-buffer-window (current-buffer)) window-start)
4641 (defun gnus-article-edit-full-stops ()
4642 "Interactively repair spacing at end of sentences."
4645 (goto-char (point-min))
4646 (search-forward-regexp "^$" nil t)
4647 (let ((case-fold-search nil))
4648 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
4651 ;;; Article editing with MIME-Edit
4654 (defcustom gnus-article-mime-edit-article-setup-hook nil
4655 "Hook run after setting up a MIME editing article buffer."
4656 :group 'gnus-article-various
4659 (defun gnus-article-mime-edit-article-unwind ()
4660 "Unwind `gnus-article-buffer' if article editing was given up."
4661 (remove-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
4662 (when mime-edit-mode-flag
4663 (mime-edit-exit 'nomime 'no-error)
4665 (when (featurep 'font-lock)
4666 (setq font-lock-defaults nil)
4667 (font-lock-mode 0)))
4669 (defun gnus-article-mime-edit-article-setup ()
4670 "Convert current buffer to MIME-Edit buffer and turn on MIME-Edit mode
4671 after replacing with the original article."
4672 (setq gnus-show-mime t)
4673 (setq gnus-article-edit-done-function
4674 `(lambda (&rest args)
4675 (when mime-edit-mode-flag
4678 (goto-char (point-min))
4679 (let (case-fold-search)
4680 (when (re-search-forward
4681 (format "^%s$" (regexp-quote mail-header-separator))
4683 (replace-match "")))
4684 (when (featurep 'font-lock)
4685 (setq font-lock-defaults nil)
4687 (apply ,gnus-article-edit-done-function args)
4688 (set-buffer gnus-original-article-buffer)
4690 (insert-buffer gnus-article-buffer)
4691 (setq gnus-current-headers (gnus-article-make-full-mail-header))
4692 (gnus-article-prepare-display)))
4693 (substitute-key-definition
4694 'gnus-article-edit-exit 'gnus-article-mime-edit-exit
4695 gnus-article-edit-mode-map)
4697 (insert-buffer gnus-original-article-buffer)
4699 (when (featurep 'font-lock)
4700 (set (make-local-variable 'font-lock-defaults)
4701 '(message-font-lock-keywords t))
4702 (font-lock-set-defaults)
4703 (turn-on-font-lock))
4704 (add-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
4705 (gnus-run-hooks 'gnus-article-mime-edit-article-setup-hook))
4707 (defun gnus-article-mime-edit-exit ()
4708 "Exit the article MIME editing without updating."
4710 (let ((winconf gnus-prev-winconf)
4712 (when mime-edit-mode-flag
4715 (goto-char (point-min))
4716 (let (case-fold-search)
4717 (when (re-search-forward
4718 (format "^%s$" (regexp-quote mail-header-separator)) nil t)
4719 (replace-match "")))
4720 (when (featurep 'font-lock)
4721 (setq font-lock-defaults nil)
4723 ;; We remove all text props from the article buffer.
4724 (setq buf (format "%s" (buffer-string)))
4725 (set-buffer (get-buffer-create gnus-original-article-buffer))
4728 (setq gnus-current-headers (gnus-article-make-full-mail-header))
4729 (gnus-article-prepare-display)
4730 (set-window-configuration winconf)))
4733 ;;; Article highlights
4736 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
4738 ;;; Internal Variables:
4740 (defcustom gnus-button-url-regexp "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|news\\|telnet\\|wais\\|mailto\\):\\)\\(//[-a-zA-Z0-9_.]+:[0-9]*\\)?\\([-a-zA-Z0-9_=!?#$@~`%&*+|\\/:;.,]\\|\\w\\)+\\([-a-zA-Z0-9_=#$@~`%&*+|\\/]\\|\\w\\)\\)"
4741 "Regular expression that matches URLs."
4742 :group 'gnus-article-buttons
4745 (defcustom gnus-button-alist
4746 `(("<\\(url:[>\n\t ]*?\\)?news:[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
4747 0 t gnus-button-message-id 2)
4748 ("\\bnews:\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t gnus-button-message-id 1)
4749 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
4751 gnus-button-fetch-group 4)
4752 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
4753 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
4754 t gnus-button-message-id 3)
4755 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
4756 ("mailto:\\([-a-zA-Z.@_+0-9%]+\\)" 0 t gnus-url-mailto 1)
4757 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
4758 ;; This is how URLs _should_ be embedded in text...
4759 ("<URL: *\\([^<>]*\\)>" 0 t gnus-button-embedded-url 1)
4761 (,gnus-button-url-regexp 0 t browse-url 0))
4762 "*Alist of regexps matching buttons in article bodies.
4764 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
4765 REGEXP: is the string matching text around the button,
4766 BUTTON: is the number of the regexp grouping actually matching the button,
4767 FORM: is a lisp expression which must eval to true for the button to
4769 CALLBACK: is the function to call when the user push this button, and each
4770 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
4772 CALLBACK can also be a variable, in that case the value of that
4773 variable it the real callback function."
4774 :group 'gnus-article-buttons
4775 :type '(repeat (list regexp
4776 (integer :tag "Button")
4778 (function :tag "Callback")
4781 (integer :tag "Regexp group")))))
4783 (defcustom gnus-header-button-alist
4784 `(("^\\(References\\|Message-I[Dd]\\):" "<[^>]+>"
4785 0 t gnus-button-message-id 0)
4786 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
4787 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
4788 0 t gnus-button-mailto 0)
4789 ("^X-[Uu][Rr][Ll]:" ,gnus-button-url-regexp 0 t browse-url 0)
4790 ("^Subject:" ,gnus-button-url-regexp 0 t browse-url 0)
4791 ("^[^:]+:" ,gnus-button-url-regexp 0 t browse-url 0)
4792 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
4793 gnus-button-message-id 3))
4794 "*Alist of headers and regexps to match buttons in article heads.
4796 This alist is very similar to `gnus-button-alist', except that each
4797 alist has an additional HEADER element first in each entry:
4799 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
4801 HEADER is a regexp to match a header. For a fuller explanation, see
4802 `gnus-button-alist'."
4803 :group 'gnus-article-buttons
4804 :group 'gnus-article-headers
4805 :type '(repeat (list (regexp :tag "Header")
4807 (integer :tag "Button")
4809 (function :tag "Callback")
4812 (integer :tag "Regexp group")))))
4814 (defvar gnus-button-regexp nil)
4815 (defvar gnus-button-marker-list nil)
4816 ;; Regexp matching any of the regexps from `gnus-button-alist'.
4818 (defvar gnus-button-last nil)
4819 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
4823 (defun gnus-article-push-button (event)
4824 "Check text under the mouse pointer for a callback function.
4825 If the text under the mouse pointer has a `gnus-callback' property,
4826 call it with the value of the `gnus-data' text property."
4828 (set-buffer (window-buffer (posn-window (event-start event))))
4829 (let* ((pos (posn-point (event-start event)))
4830 (data (get-text-property pos 'gnus-data))
4831 (fun (get-text-property pos 'gnus-callback)))
4834 (funcall fun data))))
4836 (defun gnus-article-press-button ()
4837 "Check text at point for a callback function.
4838 If the text at point has a `gnus-callback' property,
4839 call it with the value of the `gnus-data' text property."
4841 (let* ((data (get-text-property (point) 'gnus-data))
4842 (fun (get-text-property (point) 'gnus-callback)))
4844 (funcall fun data))))
4846 (defun gnus-article-prev-button (n)
4847 "Move point to N buttons backward.
4848 If N is negative, move forward instead."
4850 (gnus-article-next-button (- n)))
4852 (defun gnus-article-next-button (n)
4853 "Move point to N buttons forward.
4854 If N is negative, move backward instead."
4856 (let ((function (if (< n 0) 'previous-single-property-change
4857 'next-single-property-change))
4858 (inhibit-point-motion-hooks t)
4860 (limit (if (< n 0) (point-min) (point-max))))
4862 (while (and (not (= limit (point)))
4864 ;; Skip past the current button.
4865 (when (get-text-property (point) 'gnus-callback)
4866 (goto-char (funcall function (point) 'gnus-callback nil limit)))
4867 ;; Go to the next (or previous) button.
4868 (gnus-goto-char (funcall function (point) 'gnus-callback nil limit))
4869 ;; Put point at the start of the button.
4870 (when (and backward (not (get-text-property (point) 'gnus-callback)))
4871 (goto-char (funcall function (point) 'gnus-callback nil limit)))
4872 ;; Skip past intangible buttons.
4873 (when (get-text-property (point) 'intangible)
4877 (gnus-message 5 "No more buttons"))
4880 (defun gnus-article-highlight (&optional force)
4881 "Highlight current article.
4882 This function calls `gnus-article-highlight-headers',
4883 `gnus-article-highlight-citation',
4884 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
4885 do the highlighting. See the documentation for those functions."
4886 (interactive (list 'force))
4887 (gnus-article-highlight-headers)
4888 (gnus-article-highlight-citation force)
4889 (gnus-article-highlight-signature)
4890 (gnus-article-add-buttons force)
4891 (gnus-article-add-buttons-to-head))
4893 (defun gnus-article-highlight-some (&optional force)
4894 "Highlight current article.
4895 This function calls `gnus-article-highlight-headers',
4896 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
4897 do the highlighting. See the documentation for those functions."
4898 (interactive (list 'force))
4899 (gnus-article-highlight-headers)
4900 (gnus-article-highlight-signature)
4901 (gnus-article-add-buttons))
4903 (defun gnus-article-highlight-headers ()
4904 "Highlight article headers as specified by `gnus-header-face-alist'."
4907 (set-buffer gnus-article-buffer)
4909 (let ((alist gnus-header-face-alist)
4910 (buffer-read-only nil)
4911 (case-fold-search t)
4912 (inhibit-point-motion-hooks t)
4913 entry regexp header-face field-face from hpoints fpoints)
4914 (article-narrow-to-head)
4915 (while (setq entry (pop alist))
4916 (goto-char (point-min))
4917 (setq regexp (concat "^\\("
4918 (if (string-equal "" (nth 0 entry))
4922 header-face (nth 1 entry)
4923 field-face (nth 2 entry))
4924 (while (and (re-search-forward regexp nil t)
4928 (unless (search-forward ":" nil t)
4930 (when (and header-face
4931 (not (memq (point) hpoints)))
4932 (push (point) hpoints)
4933 (gnus-put-text-property from (point) 'face header-face))
4934 (when (and field-face
4935 (not (memq (setq from (point)) fpoints)))
4937 (if (re-search-forward "^[^ \t]" nil t)
4939 (goto-char (point-max)))
4940 (gnus-put-text-property from (point) 'face field-face))))))))
4942 (defun gnus-article-highlight-signature ()
4943 "Highlight the signature in an article.
4944 It does this by highlighting everything after
4945 `gnus-signature-separator' using `gnus-signature-face'."
4947 (when gnus-signature-face
4949 (set-buffer gnus-article-buffer)
4950 (let ((buffer-read-only nil)
4951 (inhibit-point-motion-hooks t))
4953 (when (gnus-article-narrow-to-signature)
4954 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
4955 'face gnus-signature-face)))))))
4957 (defun gnus-article-buttonize-signature ()
4958 "Add button to the signature."
4961 (set-buffer gnus-article-buffer)
4962 (let ((buffer-read-only nil)
4963 (inhibit-point-motion-hooks t))
4964 (when (gnus-article-search-signature)
4965 (gnus-article-add-button (match-beginning 0) (match-end 0)
4966 'gnus-signature-toggle
4967 (set-marker (make-marker)
4968 (1+ (match-end 0))))))))
4970 (defun gnus-button-in-region-p (b e prop)
4971 "Say whether PROP exists in the region."
4972 (text-property-not-all b e prop nil))
4974 (defun gnus-article-add-buttons (&optional force)
4975 "Find external references in the article and make buttons of them.
4976 \"External references\" are things like Message-IDs and URLs, as
4977 specified by `gnus-button-alist'."
4978 (interactive (list 'force))
4980 (set-buffer gnus-article-buffer)
4981 (let ((buffer-read-only nil)
4982 (inhibit-point-motion-hooks t)
4983 (case-fold-search t)
4984 (alist gnus-button-alist)
4986 ;; Remove all old markers.
4987 (let (marker entry new-list)
4988 (while (setq marker (pop gnus-button-marker-list))
4989 (if (or (< marker (point-min)) (>= marker (point-max)))
4990 (push marker new-list)
4992 (when (setq entry (gnus-button-entry))
4993 (put-text-property (match-beginning (nth 1 entry))
4994 (match-end (nth 1 entry))
4995 'gnus-callback nil))
4996 (set-marker marker nil)))
4997 (setq gnus-button-marker-list new-list))
4998 ;; We skip the headers.
5001 (while (setq entry (pop alist))
5002 (setq regexp (car entry))
5004 (while (re-search-forward regexp nil t)
5005 (let* ((start (and entry (match-beginning (nth 1 entry))))
5006 (end (and entry (match-end (nth 1 entry))))
5007 (from (match-beginning 0)))
5008 (when (and (or (eq t (nth 2 entry))
5009 (eval (nth 2 entry)))
5010 (not (gnus-button-in-region-p
5011 start end 'gnus-callback)))
5012 ;; That optional form returned non-nil, so we add the
5014 (gnus-article-add-button
5015 start end 'gnus-button-push
5016 (car (push (set-marker (make-marker) from)
5017 gnus-button-marker-list))))))))))
5019 ;; Add buttons to the head of an article.
5020 (defun gnus-article-add-buttons-to-head ()
5021 "Add buttons to the head of the article."
5024 (set-buffer gnus-article-buffer)
5026 (let ((buffer-read-only nil)
5027 (inhibit-point-motion-hooks t)
5028 (case-fold-search t)
5029 (alist gnus-header-button-alist)
5031 (article-narrow-to-head)
5033 ;; Each alist entry.
5034 (setq entry (car alist)
5036 (goto-char (point-min))
5037 (while (re-search-forward (car entry) nil t)
5038 ;; Each header matching the entry.
5039 (setq beg (match-beginning 0))
5040 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
5041 (match-beginning 0))
5044 (while (re-search-forward (nth 1 entry) end t)
5045 ;; Each match within a header.
5046 (let* ((entry (cdr entry))
5047 (start (match-beginning (nth 1 entry)))
5048 (end (match-end (nth 1 entry)))
5049 (form (nth 2 entry)))
5050 (goto-char (match-end 0))
5052 (gnus-article-add-button
5053 start end (nth 3 entry)
5054 (buffer-substring (match-beginning (nth 4 entry))
5055 (match-end (nth 4 entry)))))))
5056 (goto-char end)))))))
5058 ;;; External functions:
5060 (defun gnus-article-add-button (from to fun &optional data)
5061 "Create a button between FROM and TO with callback FUN and data DATA."
5062 (when gnus-article-button-face
5063 (gnus-overlay-put (gnus-make-overlay from to)
5064 'face gnus-article-button-face))
5065 (gnus-add-text-properties
5067 (nconc (and gnus-article-mouse-face
5068 (list gnus-mouse-face-prop gnus-article-mouse-face))
5069 (list 'gnus-callback fun)
5070 (and data (list 'gnus-data data))))
5071 (widget-convert-button 'link from to :action 'gnus-widget-press-button
5072 ;; Quote `:button-keymap' for Mule 2.3
5073 ;; but it won't work.
5074 ':button-keymap gnus-widget-button-keymap))
5076 ;;; Internal functions:
5078 (defun gnus-article-set-globals ()
5080 (set-buffer gnus-summary-buffer)
5081 (gnus-set-global-variables)))
5083 (defun gnus-signature-toggle (end)
5085 (set-buffer gnus-article-buffer)
5086 (let ((buffer-read-only nil)
5087 (inhibit-point-motion-hooks t)
5088 (limit (next-single-property-change end 'mime-view-entity
5090 (if (get-text-property end 'invisible)
5091 (gnus-article-unhide-text end limit)
5092 (gnus-article-hide-text end limit gnus-hidden-properties)))))
5094 (defun gnus-button-entry ()
5095 ;; Return the first entry in `gnus-button-alist' matching this place.
5096 (let ((alist gnus-button-alist)
5099 (setq entry (pop alist))
5100 (if (looking-at (car entry))
5105 (defun gnus-button-push (marker)
5106 ;; Push button starting at MARKER.
5109 (let* ((entry (gnus-button-entry))
5110 (inhibit-point-motion-hooks t)
5112 (args (mapcar (lambda (group)
5113 (let ((string (match-string group)))
5114 (gnus-set-text-properties
5115 0 (length string) nil string)
5122 (fboundp (symbol-value fun)))
5123 (apply (symbol-value fun) args))
5125 (gnus-message 1 "You must define `%S' to use this button"
5126 (cons fun args)))))))
5128 (defun gnus-button-message-id (message-id)
5131 (set-buffer gnus-summary-buffer)
5132 (gnus-summary-refer-article message-id)))
5134 (defun gnus-button-fetch-group (address)
5135 "Fetch GROUP specified by ADDRESS."
5136 (if (not (string-match "[:/]" address))
5137 ;; This is just a simple group url.
5138 (gnus-group-read-ephemeral-group address gnus-select-method)
5139 (if (not (string-match "^\\([^:/]+\\)\\(:\\([^/]+\\)/\\)?\\(.*\\)$"
5141 (error "Can't parse %s" address)
5142 (gnus-group-read-ephemeral-group
5143 (match-string 4 address)
5144 `(nntp ,(match-string 1 address)
5145 (nntp-address ,(match-string 1 address))
5146 (nntp-port-number ,(if (match-end 3)
5147 (match-string 3 address)
5150 (defun gnus-url-parse-query-string (query &optional downcase)
5151 (let (retval pairs cur key val)
5152 (setq pairs (split-string query "&"))
5154 (setq cur (car pairs)
5156 (if (not (string-match "=" cur))
5158 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
5159 val (gnus-url-unhex-string (substring cur (match-end 0) nil)))
5161 (setq key (downcase key)))
5162 (setq cur (assoc key retval))
5164 (setcdr cur (cons val (cdr cur)))
5165 (setq retval (cons (list key val) retval)))))
5168 (defun gnus-url-unhex (x)
5175 (defun gnus-url-unhex-string (str &optional allow-newlines)
5176 "Remove %XXX embedded spaces, etc in a url.
5177 If optional second argument ALLOW-NEWLINES is non-nil, then allow the
5178 decoding of carriage returns and line feeds in the string, which is normally
5179 forbidden in URL encoding."
5180 (setq str (or str ""))
5182 (case-fold-search t))
5183 (while (string-match "%[0-9a-f][0-9a-f]" str)
5184 (let* ((start (match-beginning 0))
5185 (ch1 (gnus-url-unhex (elt str (+ start 1))))
5187 (gnus-url-unhex (elt str (+ start 2))))))
5189 tmp (substring str 0 start)
5192 (char-to-string code))
5193 ((or (= code ?\n) (= code ?\r))
5195 (t (char-to-string code))))
5196 str (substring str (match-end 0)))))
5197 (setq tmp (concat tmp str))
5200 (defun gnus-url-mailto (url)
5201 ;; Send mail to someone
5202 (when (string-match "mailto:/*\\(.*\\)" url)
5203 (setq url (substring url (match-beginning 1) nil)))
5204 (let (to args subject func)
5205 (if (string-match (regexp-quote "?") url)
5206 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
5207 args (gnus-url-parse-query-string
5208 (substring url (match-end 0) nil) t))
5209 (setq to (gnus-url-unhex-string url)))
5210 (setq args (cons (list "to" to) args)
5211 subject (cdr-safe (assoc "subject" args)))
5212 (gnus-setup-message 'reply
5215 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
5218 (message-position-on-field (caar args)))
5219 (insert (mapconcat 'identity (cdar args) ", "))
5220 (setq args (cdr args)))
5223 (message-goto-subject)))))
5225 (defun gnus-button-mailto (address)
5227 (set-buffer (gnus-copy-article-buffer))
5228 (message-reply address))
5230 (defalias 'gnus-button-reply 'message-reply)
5232 (defun gnus-button-embedded-url (address)
5233 "Activate ADDRESS with `browse-url'."
5234 (browse-url (gnus-strip-whitespace address)))
5236 (defun gnus-article-smiley-display ()
5237 "Display \"smileys\" as small graphical icons."
5238 (smiley-toggle-buffer 1 (current-buffer) (point-min) (point-max)))
5240 ;;; Next/prev buttons in the article buffer.
5242 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
5243 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
5245 (defvar gnus-prev-page-map nil)
5246 (unless gnus-prev-page-map
5247 (setq gnus-prev-page-map (make-sparse-keymap))
5248 (define-key gnus-prev-page-map gnus-mouse-2 'gnus-button-prev-page)
5249 (define-key gnus-prev-page-map "\r" 'gnus-button-prev-page))
5251 (static-if (featurep 'xemacs)
5252 (defun gnus-insert-prev-page-button ()
5253 (let ((buffer-read-only nil))
5255 gnus-prev-page-line-format nil
5256 `(gnus-prev t local-map ,gnus-prev-page-map
5257 gnus-callback gnus-article-button-prev-page
5258 article-type annotation))))
5259 (defun gnus-insert-prev-page-button ()
5260 (let ((buffer-read-only nil)
5261 (situation (get-text-property (point-min) 'mime-view-situation)))
5262 (set-keymap-parent gnus-prev-page-map (current-local-map))
5264 gnus-prev-page-line-format nil
5265 `(gnus-prev t local-map ,gnus-prev-page-map
5266 gnus-callback gnus-article-button-prev-page
5267 article-type annotation
5268 mime-view-situation ,situation))))
5271 (defvar gnus-next-page-map nil)
5272 (unless gnus-next-page-map
5273 (setq gnus-next-page-map (make-sparse-keymap))
5274 (define-key gnus-next-page-map gnus-mouse-2 'gnus-button-next-page)
5275 (define-key gnus-next-page-map "\r" 'gnus-button-next-page))
5277 (defun gnus-button-next-page ()
5278 "Go to the next page."
5280 (let ((win (selected-window)))
5281 (select-window (get-buffer-window gnus-article-buffer t))
5282 (gnus-article-next-page)
5283 (select-window win)))
5285 (defun gnus-button-prev-page ()
5286 "Go to the prev page."
5288 (let ((win (selected-window)))
5289 (select-window (get-buffer-window gnus-article-buffer t))
5290 (gnus-article-prev-page)
5291 (select-window win)))
5293 (static-if (featurep 'xemacs)
5294 (defun gnus-insert-next-page-button ()
5295 (let ((buffer-read-only nil))
5296 (gnus-eval-format gnus-next-page-line-format nil
5298 t local-map ,gnus-next-page-map
5299 gnus-callback gnus-article-button-next-page
5300 article-type annotation))))
5301 (defun gnus-insert-next-page-button ()
5302 (let ((buffer-read-only nil)
5303 (situation (get-text-property (point-min) 'mime-view-situation)))
5304 (set-keymap-parent gnus-next-page-map (current-local-map))
5305 (gnus-eval-format gnus-next-page-line-format nil
5307 t local-map ,gnus-next-page-map
5308 gnus-callback gnus-article-button-next-page
5309 article-type annotation
5310 mime-view-situation ,situation))))
5313 (defun gnus-article-button-next-page (arg)
5314 "Go to the next page."
5316 (let ((win (selected-window)))
5317 (select-window (get-buffer-window gnus-article-buffer t))
5318 (gnus-article-next-page)
5319 (select-window win)))
5321 (defun gnus-article-button-prev-page (arg)
5322 "Go to the prev page."
5324 (let ((win (selected-window)))
5325 (select-window (get-buffer-window gnus-article-buffer t))
5326 (gnus-article-prev-page)
5327 (select-window win)))
5329 (defvar gnus-decode-header-methods
5330 '(mail-decode-encoded-word-region)
5331 "List of methods used to decode headers.
5333 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
5334 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
5335 (REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
5336 whose names match REGEXP.
5339 ((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
5340 mail-decode-encoded-word-region
5341 (\"chinese\" . rfc1843-decode-region))
5344 (defvar gnus-decode-header-methods-cache nil)
5346 (defun gnus-multi-decode-header (start end)
5347 "Apply the functions from `gnus-encoded-word-methods' that match."
5348 (unless (and gnus-decode-header-methods-cache
5349 (eq gnus-newsgroup-name
5350 (car gnus-decode-header-methods-cache)))
5351 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
5354 (nconc gnus-decode-header-methods-cache (list x))
5355 (if (and gnus-newsgroup-name
5356 (string-match (car x) gnus-newsgroup-name))
5357 (nconc gnus-decode-header-methods-cache
5359 gnus-decode-header-methods))
5360 (let ((xlist gnus-decode-header-methods-cache))
5363 (narrow-to-region start end)
5365 (funcall (pop xlist) (point-min) (point-max))))))
5368 ;;; Treatment top-level handling.
5371 (defun gnus-treat-article (condition &optional part-number total-parts type)
5372 (let ((length (- (point-max) (point-min)))
5373 (alist gnus-treatment-function-alist)
5374 (article-goto-body-goes-to-point-min-p t)
5378 (let ((list gnus-article-treat-types))
5380 (when (string-match (pop list) type)
5381 (throw 'found t)))))))
5382 (highlightp (gnus-visual-p 'article-highlight 'highlight))
5383 (entity (static-unless (featurep 'xemacs)
5384 (when (eq 'head condition)
5385 (get-text-property (point-min) 'mime-view-entity))))
5386 val elem buttonized)
5387 (gnus-run-hooks 'gnus-part-display-hook)
5388 (unless gnus-inhibit-treatment
5389 (while (setq elem (pop alist))
5392 (if (gnus-buffer-live-p gnus-summary-buffer)
5393 (set-buffer gnus-summary-buffer))
5394 (symbol-value (car elem))))
5395 (when (and (or (consp val)
5397 (gnus-treat-predicate val)
5398 (or (not (get (car elem) 'highlight))
5400 (when (and (not buttonized)
5402 '(gnus-treat-hide-signature
5403 gnus-treat-highlight-signature)))
5404 (gnus-article-buttonize-signature)
5405 (setq buttonized t))
5407 (funcall (cadr elem)))))
5408 ;; FSF Emacsen does not inherit the existing text properties
5409 ;; in the new text, so we should do it for `mime-view-entity'.
5410 (static-unless (featurep 'xemacs)
5412 (put-text-property (point-min) (point-max)
5413 'mime-view-entity entity))))))
5415 ;; Dynamic variables.
5417 (defvar part-number)
5418 (defvar total-parts)
5423 (defun gnus-treat-predicate (val)
5428 (stringp (car val)))
5429 (apply 'gnus-or (mapcar `(lambda (s)
5430 (string-match s ,(or gnus-newsgroup-name "")))
5433 (let ((pred (pop val)))
5436 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
5438 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
5440 (not (gnus-treat-predicate (car val))))
5442 (equal (car val) type))
5444 (error "%S is not a valid predicate" pred)))))
5454 (eq part-number total-parts))
5458 (error "%S is not a valid value" val))))
5460 (defun gnus-article-encrypt-body (protocol &optional n)
5461 "Encrypt the article body."
5464 (or gnus-article-encrypt-protocol
5465 (completing-read "Encrypt protocol: "
5466 gnus-article-encrypt-protocol-alist
5468 current-prefix-arg))
5469 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
5471 (error (format "Can't find the encrypt protocol %s" protocol)))
5472 (if (equal gnus-newsgroup-name "nndraft:drafts")
5473 (error "Can't encrypt the article in group nndraft:drafts."))
5474 (if (equal gnus-newsgroup-name "nndraft:queue")
5475 (error "Don't encrypt the article in group nndraft:queue."))
5476 (gnus-summary-iterate n
5478 (set-buffer gnus-summary-buffer)
5479 (let ((mail-parse-charset gnus-newsgroup-charset)
5480 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5481 (summary-buffer gnus-summary-buffer)
5483 (gnus-set-global-variables)
5484 (when (gnus-group-read-only-p)
5485 (error "The current newsgroup does not support article encrypt"))
5486 (gnus-summary-show-article t)
5488 (or (mail-header-references gnus-current-headers) ""))
5489 (set-buffer gnus-article-buffer)
5490 (let* ((buffer-read-only nil)
5492 (mapcar (lambda (field)
5493 (and (save-restriction
5494 (message-narrow-to-head)
5495 (goto-char (point-min))
5496 (search-forward field nil t))
5498 (message-narrow-to-field)
5499 (buffer-substring (point-min) (point-max))
5500 (delete-region (point-min) (point-max))
5502 '("Content-Type:" "Content-Transfer-Encoding:"
5503 "Content-Disposition:"))))
5504 (message-narrow-to-head)
5505 (message-remove-header "MIME-Version")
5506 (goto-char (point-max))
5507 (setq point (point))
5508 (insert (apply 'concat headers))
5510 (narrow-to-region point (point-max))
5511 (let ((message-options message-options))
5512 (message-options-set 'message-sender user-mail-address)
5513 (message-options-set 'message-recipients user-mail-address)
5514 (message-options-set 'message-sign-encrypt 'not)
5516 (goto-char (point-min))
5517 (insert "MIME-Version: 1.0\n")
5519 (gnus-summary-edit-article-done
5520 references nil summary-buffer t))
5521 (when gnus-keep-backlog
5522 (gnus-backlog-remove-article
5523 (car gnus-article-current) (cdr gnus-article-current)))
5525 (when (get-buffer gnus-original-article-buffer)
5526 (set-buffer gnus-original-article-buffer)
5527 (setq gnus-original-article nil)))
5528 (when gnus-use-cache
5529 (gnus-cache-update-article
5530 (car gnus-article-current) (cdr gnus-article-current))))))))
5536 (defun gnus-article-header-presentation-method (entity situation)
5537 (mime-insert-header entity)
5540 (set-alist 'mime-header-presentation-method-alist
5541 'gnus-original-article-mode
5542 #'gnus-article-header-presentation-method)
5544 (defun gnus-mime-preview-quitting-method ()
5545 (mime-preview-kill-buffer)
5546 (delete-other-windows)
5547 (gnus-article-show-summary)
5548 (gnus-summary-select-article gnus-show-all-headers t))
5550 (set-alist 'mime-preview-quitting-method-alist
5551 'gnus-original-article-mode #'gnus-mime-preview-quitting-method)
5553 (set-alist 'mime-preview-following-method-alist
5554 'gnus-original-article-mode #'gnus-following-method)
5556 (set-alist 'mime-preview-over-to-previous-method-alist
5557 'gnus-original-article-mode
5559 (if (> (point-min) 1)
5560 (gnus-article-prev-page)
5561 (gnus-article-read-summary-keys
5562 nil (gnus-character-to-event ?P)))))
5564 (set-alist 'mime-preview-over-to-next-method-alist
5565 'gnus-original-article-mode'
5567 (if (< (point-max) (buffer-size))
5568 (gnus-article-next-page)
5569 (gnus-article-read-summary-keys
5570 nil (gnus-character-to-event ?N)))))
5580 (run-hooks 'gnus-art-load-hook)
5582 ;;; gnus-art.el ends here