1 ;;; gnus-art.el --- article mode commands for Gnus
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002
4 ;; Free Software Foundation, Inc.
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
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))
43 (defgroup gnus-article nil
45 :link '(custom-manual "(gnus)The Article Buffer")
48 (defgroup gnus-article-treat nil
49 "Treating article parts."
50 :link '(custom-manual "(gnus)Article Hiding")
53 (defgroup gnus-article-hiding nil
54 "Hiding article parts."
55 :link '(custom-manual "(gnus)Article Hiding")
58 (defgroup gnus-article-highlight nil
59 "Article highlighting."
60 :link '(custom-manual "(gnus)Article Highlighting")
64 (defgroup gnus-article-signature nil
66 :link '(custom-manual "(gnus)Article Signature")
69 (defgroup gnus-article-headers nil
71 :link '(custom-manual "(gnus)Hiding Headers")
74 (defgroup gnus-article-washing nil
75 "Special commands on articles."
76 :link '(custom-manual "(gnus)Article Washing")
79 (defgroup gnus-article-emphasis nil
80 "Fontisizing articles."
81 :link '(custom-manual "(gnus)Article Fontisizing")
84 (defgroup gnus-article-saving nil
86 :link '(custom-manual "(gnus)Saving Articles")
89 (defgroup gnus-article-mime nil
90 "Worshiping the MIME wonder."
91 :link '(custom-manual "(gnus)Using MIME")
94 (defgroup gnus-article-buttons nil
95 "Pushable buttons in the article buffer."
96 :link '(custom-manual "(gnus)Article Buttons")
99 (defgroup gnus-article-various nil
100 "Other article options."
101 :link '(custom-manual "(gnus)Misc Article")
102 :group 'gnus-article)
104 (defcustom gnus-ignored-headers
105 '("^Path:" "^Expires:" "^Date-Received:" "^References:" "^Xref:" "^Lines:"
106 "^Relay-Version:" "^Message-ID:" "^Approved:" "^Sender:" "^Received:"
107 "^X-UIDL:" "^MIME-Version:" "^Return-Path:" "^In-Reply-To:"
108 "^Content-Type:" "^Content-Transfer-Encoding:" "^X-WebTV-Signature:"
109 "^X-MimeOLE:" "^X-MSMail-Priority:" "^X-Priority:" "^X-Loop:"
110 "^X-Authentication-Warning:" "^X-MIME-Autoconverted:" "^X-Face:"
111 "^X-Attribution:" "^X-Originating-IP:" "^Delivered-To:"
112 "^NNTP-[-A-Za-z]+:" "^Distribution:" "^X-no-archive:" "^X-Trace:"
113 "^X-Complaints-To:" "^X-NNTP-Posting-Host:" "^X-Orig.*:"
114 "^Abuse-Reports-To:" "^Cache-Post-Path:" "^X-Article-Creation-Date:"
115 "^X-Poster:" "^X-Mail2News-Path:" "^X-Server-Date:" "^X-Cache:"
116 "^Originator:" "^X-Problems-To:" "^X-Auth-User:" "^X-Post-Time:"
117 "^X-Admin:" "^X-UID:" "^Resent-[-A-Za-z]+:" "^X-Mailing-List:"
118 "^Precedence:" "^Original-[-A-Za-z]+:" "^X-filename:" "^X-Orcpt:"
119 "^Old-Received:" "^X-Pgp" "^X-Auth:" "^X-From-Line:"
120 "^X-Gnus-Article-Number:" "^X-Majordomo:" "^X-Url:" "^X-Sender:"
121 "^MBOX-Line" "^Priority:" "^X-Pgp" "^X400-[-A-Za-z]+:"
122 "^Status:" "^X-Gnus-Mail-Source:" "^Cancel-Lock:"
123 "^X-FTN" "^X-EXP32-SerialNo:" "^Encoding:" "^Importance:"
124 "^Autoforwarded:" "^Original-Encoded-Information-Types:" "^X-Ya-Pop3:"
125 "^X-Face-Version:" "^X-Vms-To:" "^X-ML-NAME:" "^X-ML-COUNT:"
126 "^Mailing-List:" "^X-finfo:" "^X-md5sum:" "^X-md5sum-Origin:"
127 "^X-Sun-Charset:" "^X-Accept-Language:" "^X-Envelope-Sender:"
128 "^List-[A-Za-z]+:" "^X-Listprocessor-Version:"
129 "^X-Received:" "^X-Distribute:" "^X-Sequence:" "^X-Juno-Line-Breaks:"
130 "^X-Notes-Item:" "^X-MS-TNEF-Correlator:" "^x-uunet-gateway:"
131 "^X-Received:" "^Content-length:" "X-precedence:")
132 "*All headers that start with this regexp will be hidden.
133 This variable can also be a list of regexps of headers to be ignored.
134 If `gnus-visible-headers' is non-nil, this variable will be ignored."
135 :type '(choice :custom-show nil
138 :group 'gnus-article-hiding)
140 (defcustom gnus-visible-headers
141 "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^[BGF]?Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-From:\\|^X-Sent:"
142 "*All headers that do not match this regexp will be hidden.
143 This variable can also be a list of regexp of headers to remain visible.
144 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
145 :type '(repeat :value-to-internal (lambda (widget value)
146 (custom-split-regexp-maybe value))
147 :match (lambda (widget value)
149 (widget-editable-list-match widget value)))
151 :group 'gnus-article-hiding)
153 (defcustom gnus-sorted-header-list
154 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
155 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
156 "*This variable is a list of regular expressions.
157 If it is non-nil, headers that match the regular expressions will
158 be placed first in the article buffer in the sequence specified by
160 :type '(repeat regexp)
161 :group 'gnus-article-hiding)
163 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
164 "Headers that are only to be displayed if they have interesting data.
165 Possible values in this list are `empty', `newsgroups', `followup-to',
166 `reply-to', `date', `long-to', and `many-to'."
167 :type '(set (const :tag "Headers with no content." empty)
168 (const :tag "Newsgroups with only one group." newsgroups)
169 (const :tag "Followup-to identical to newsgroups." followup-to)
170 (const :tag "Reply-to identical to from." reply-to)
171 (const :tag "Date less than four days old." date)
172 (const :tag "Very long To and/or Cc header." long-to)
173 (const :tag "Multiple To and/or Cc headers." many-to))
174 :group 'gnus-article-hiding)
176 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
177 "Regexp matching signature separator.
178 This can also be a list of regexps. In that case, it will be checked
179 from head to tail looking for a separator. Searches will be done from
180 the end of the buffer."
181 :type '(repeat string)
182 :group 'gnus-article-signature)
184 (defcustom gnus-signature-limit nil
185 "Provide a limit to what is considered a signature.
186 If it is a number, no signature may not be longer (in characters) than
187 that number. If it is a floating point number, no signature may be
188 longer (in lines) than that number. If it is a function, the function
189 will be called without any parameters, and if it returns nil, there is
190 no signature in the buffer. If it is a string, it will be used as a
191 regexp. If it matches, the text in question is not a signature."
192 :type '(choice (integer :value 200)
194 (function :value fun)
195 (regexp :value ".*"))
196 :group 'gnus-article-signature)
198 (defcustom gnus-hidden-properties '(invisible t intangible t)
199 "Property list to use for hiding text."
201 :group 'gnus-article-hiding)
203 ;; Fixme: This isn't the right thing for mixed graphical and and
204 ;; non-graphical frames in a session.
205 ;; gnus-xmas.el overrides this for XEmacs.
206 (defcustom gnus-article-x-face-command
207 (if (and (fboundp 'image-type-available-p)
208 (image-type-available-p 'xbm))
209 'gnus-article-display-xface
210 (if (eq 0 (string-match "#define"
211 (shell-command-to-string "uncompface -X")))
212 "{ echo '/* Width=48, Height=48 */'; uncompface; } | display -"
213 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
215 "*String or function to be executed to display an X-Face header.
216 If it is a string, the command will be executed in a sub-shell
217 asynchronously. The compressed face will be piped to this command."
218 :type '(choice string
219 (function-item gnus-article-display-xface)
222 :group 'gnus-article-washing)
224 (defcustom gnus-article-x-face-too-ugly nil
225 "Regexp matching posters whose face shouldn't be shown automatically."
226 :type '(choice regexp (const nil))
227 :group 'gnus-article-washing)
229 (defcustom gnus-article-banner-alist nil
230 "Banner alist for stripping.
232 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( eGroups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
234 :type '(repeat (cons symbol regexp))
235 :group 'gnus-article-washing)
237 (defcustom gnus-emphasis-alist
239 "\\(\\s-\\|^\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\s-\\|[-,;:\"]\\s-\\|[?!.]+\\s-\\|\\s)\\)")
241 '(("_" "_" underline)
244 ("_/" "/_" underline-italic)
245 ("_\\*" "\\*_" underline-bold)
246 ("\\*/" "/\\*" bold-italic)
247 ("_\\*/" "/\\*_" underline-bold-italic))))
248 `(("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
249 2 3 gnus-emphasis-underline)
253 (format format (car spec) (cadr spec))
254 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
256 "*Alist that says how to fontify certain phrases.
257 Each item looks like this:
259 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
261 The first element is a regular expression to be matched. The second
262 is a number that says what regular expression grouping used to find
263 the entire emphasized word. The third is a number that says what
264 regexp grouping should be displayed and highlighted. The fourth
265 is the face used for highlighting."
266 :type '(repeat (list :value ("" 0 0 default)
268 (integer :tag "Match group")
269 (integer :tag "Emphasize group")
271 :group 'gnus-article-emphasis)
273 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
274 "A regexp to describe whitespace which should not be emphasized.
275 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
276 The former avoids underlining of leading and trailing whitespace,
277 and the latter avoids underlining any whitespace at all."
279 :group 'gnus-article-emphasis
282 (defface gnus-emphasis-bold '((t (:weight bold)))
283 "Face used for displaying strong emphasized text (*word*)."
284 :group 'gnus-article-emphasis)
286 (defface gnus-emphasis-italic '((t (:slant italic)))
287 "Face used for displaying italic emphasized text (/word/)."
288 :group 'gnus-article-emphasis)
290 (defface gnus-emphasis-underline '((t (:underline t)))
291 "Face used for displaying underlined emphasized text (_word_)."
292 :group 'gnus-article-emphasis)
294 (defface gnus-emphasis-underline-bold '((t (:weight bold :underline t)))
295 "Face used for displaying underlined bold emphasized text (_*word*_)."
296 :group 'gnus-article-emphasis)
298 (defface gnus-emphasis-underline-italic '((t (:slant italic :underline t)))
299 "Face used for displaying underlined italic emphasized text (_/word/_)."
300 :group 'gnus-article-emphasis)
302 (defface gnus-emphasis-bold-italic '((t (:weight bold :slant italic)))
303 "Face used for displaying bold italic emphasized text (/*word*/)."
304 :group 'gnus-article-emphasis)
306 (defface gnus-emphasis-underline-bold-italic
307 '((t (:weight bold :slant italic :underline t)))
308 "Face used for displaying underlined bold italic emphasized text.
309 Esample: (_/*word*/_)."
310 :group 'gnus-article-emphasis)
312 (defface gnus-emphasis-highlight-words
313 '((t (:background "black" :foreground "yellow")))
314 "Face used for displaying highlighted words."
315 :group 'gnus-article-emphasis)
317 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
318 "Format for display of Date headers in article bodies.
319 See `format-time-string' for the possible values.
321 The variable can also be function, which should return a complete Date
322 header. The function is called with one argument, the time, which can
323 be fed to `format-time-string'."
324 :type '(choice string symbol)
325 :link '(custom-manual "(gnus)Article Date")
326 :group 'gnus-article-washing)
329 (autoload 'mail-extract-address-components "mail-extr"))
331 (defcustom gnus-save-all-headers t
332 "*If non-nil, don't remove any headers before saving."
333 :group 'gnus-article-saving
336 (defcustom gnus-prompt-before-saving 'always
337 "*This variable says how much prompting is to be done when saving articles.
338 If it is nil, no prompting will be done, and the articles will be
339 saved to the default files. If this variable is `always', each and
340 every article that is saved will be preceded by a prompt, even when
341 saving large batches of articles. If this variable is neither nil not
342 `always', there the user will be prompted once for a file name for
343 each invocation of the saving commands."
344 :group 'gnus-article-saving
345 :type '(choice (item always)
346 (item :tag "never" nil)
347 (sexp :tag "once" :format "%t\n" :value t)))
349 (defcustom gnus-saved-headers gnus-visible-headers
350 "Headers to keep if `gnus-save-all-headers' is nil.
351 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
352 If that variable is nil, however, all headers that match this regexp
353 will be kept while the rest will be deleted before saving."
354 :group 'gnus-article-saving
357 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
358 "A function to save articles in your favourite format.
359 The function must be interactively callable (in other words, it must
360 be an Emacs command).
362 Gnus provides the following functions:
364 * gnus-summary-save-in-rmail (Rmail format)
365 * gnus-summary-save-in-mail (Unix mail format)
366 * gnus-summary-save-in-folder (MH folder)
367 * gnus-summary-save-in-file (article format)
368 * gnus-summary-save-in-vm (use VM's folder format)
369 * gnus-summary-write-to-file (article format -- overwrite)."
370 :group 'gnus-article-saving
371 :type '(radio (function-item gnus-summary-save-in-rmail)
372 (function-item gnus-summary-save-in-mail)
373 (function-item gnus-summary-save-in-folder)
374 (function-item gnus-summary-save-in-file)
375 (function-item gnus-summary-save-in-vm)
376 (function-item gnus-summary-write-to-file)))
378 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
379 "A function generating a file name to save articles in Rmail format.
380 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
381 :group 'gnus-article-saving
384 (defcustom gnus-mail-save-name 'gnus-plain-save-name
385 "A function generating a file name to save articles in Unix mail format.
386 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
387 :group 'gnus-article-saving
390 (defcustom gnus-folder-save-name 'gnus-folder-save-name
391 "A function generating a file name to save articles in MH folder.
392 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
393 :group 'gnus-article-saving
396 (defcustom gnus-file-save-name 'gnus-numeric-save-name
397 "A function generating a file name to save articles in article format.
398 The function is called with NEWSGROUP, HEADERS, and optional
400 :group 'gnus-article-saving
403 (defcustom gnus-split-methods
404 '((gnus-article-archive-name)
405 (gnus-article-nndoc-name))
406 "*Variable used to suggest where articles are to be saved.
407 For instance, if you would like to save articles related to Gnus in
408 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
409 you could set this variable to something like:
411 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
412 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
414 This variable is an alist where the where the key is the match and the
415 value is a list of possible files to save in if the match is non-nil.
417 If the match is a string, it is used as a regexp match on the
418 article. If the match is a symbol, that symbol will be funcalled
419 from the buffer of the article to be saved with the newsgroup as the
420 parameter. If it is a list, it will be evaled in the same buffer.
422 If this form or function returns a string, this string will be used as
423 a possible file name; and if it returns a non-nil list, that list will
424 be used as possible file names."
425 :group 'gnus-article-saving
426 :type '(repeat (choice (list :value (fun) function)
427 (cons :value ("" "") regexp (repeat string))
430 (defcustom gnus-page-delimiter "^\^L"
431 "*Regexp describing what to use as article page delimiters.
432 The default value is \"^\^L\", which is a form linefeed at the
433 beginning of a line."
435 :group 'gnus-article-various)
437 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
438 "*The format specification for the article mode line.
439 See `gnus-summary-mode-line-format' for a closer description.
441 The following additional specs are available:
443 %w The article washing status.
444 %m The number of MIME parts in the article."
446 :group 'gnus-article-various)
448 (defcustom gnus-article-mode-hook nil
449 "*A hook for Gnus article mode."
451 :group 'gnus-article-various)
453 (defcustom gnus-article-menu-hook nil
454 "*Hook run after the creation of the article mode menu."
456 :group 'gnus-article-various)
458 (defcustom gnus-article-prepare-hook nil
459 "*A hook called after an article has been prepared in the article buffer."
461 :group 'gnus-article-various)
463 (defcustom gnus-article-hide-pgp-hook nil
464 "*A hook called after successfully hiding a PGP signature."
466 :group 'gnus-article-various)
468 (defcustom gnus-article-button-face 'bold
469 "Face used for highlighting buttons in the article buffer.
471 An article button is a piece of text that you can activate by pressing
472 `RET' or `mouse-2' above it."
474 :group 'gnus-article-buttons)
476 (defcustom gnus-article-mouse-face 'highlight
477 "Face used for mouse highlighting in the article buffer.
479 Article buttons will be displayed in this face when the cursor is
482 :group 'gnus-article-buttons)
484 (defcustom gnus-signature-face 'gnus-signature-face
485 "Face used for highlighting a signature in the article buffer.
486 Obsolete; use the face `gnus-signature-face' for customizations instead."
488 :group 'gnus-article-highlight
489 :group 'gnus-article-signature)
491 (defface gnus-signature-face
494 "Face used for highlighting a signature in the article buffer."
495 :group 'gnus-article-highlight
496 :group 'gnus-article-signature)
498 (defface gnus-header-from-face
501 (:foreground "spring green"))
504 (:foreground "red3"))
507 "Face used for displaying from headers."
508 :group 'gnus-article-headers
509 :group 'gnus-article-highlight)
511 (defface gnus-header-subject-face
514 (:foreground "SeaGreen3"))
517 (:foreground "red4"))
519 (:weight bold :slant italic)))
520 "Face used for displaying subject headers."
521 :group 'gnus-article-headers
522 :group 'gnus-article-highlight)
524 (defface gnus-header-newsgroups-face
527 (:foreground "yellow" :slant italic))
530 (:foreground "MidnightBlue" :slant italic))
533 "Face used for displaying newsgroups headers."
534 :group 'gnus-article-headers
535 :group 'gnus-article-highlight)
537 (defface gnus-header-name-face
540 (:foreground "SeaGreen"))
543 (:foreground "maroon"))
546 "Face used for displaying header names."
547 :group 'gnus-article-headers
548 :group 'gnus-article-highlight)
550 (defface gnus-header-content-face
553 (:foreground "forest green" :slant italic))
556 (:foreground "indianred4" :slant italic))
558 (:slant italic))) "Face used for displaying header content."
559 :group 'gnus-article-headers
560 :group 'gnus-article-highlight)
562 (defcustom gnus-header-face-alist
563 '(("From" nil gnus-header-from-face)
564 ("Subject" nil gnus-header-subject-face)
565 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
566 ("" gnus-header-name-face gnus-header-content-face))
567 "*Controls highlighting of article header.
569 An alist of the form (HEADER NAME CONTENT).
571 HEADER is a regular expression which should match the name of an
572 header header and NAME and CONTENT are either face names or nil.
574 The name of each header field will be displayed using the face
575 specified by the first element in the list where HEADER match the
576 header name and NAME is non-nil. Similarly, the content will be
577 displayed by the first non-nil matching CONTENT face."
578 :group 'gnus-article-headers
579 :group 'gnus-article-highlight
580 :type '(repeat (list (regexp :tag "Header")
582 (item :tag "skip" nil)
583 (face :value default))
584 (choice :tag "Content"
585 (item :tag "skip" nil)
586 (face :value default)))))
588 (defcustom gnus-article-decode-hook
589 '(article-decode-charset article-decode-encoded-words)
590 "*Hook run to decode charsets in articles."
591 :group 'gnus-article-headers
594 (defcustom gnus-display-mime-function 'gnus-display-mime
595 "Function to display MIME articles."
596 :group 'gnus-article-mime
599 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
600 "Function used to decode headers.")
602 (defvar gnus-article-dumbquotes-map
620 "Table for MS-to-Latin1 translation.")
622 (defcustom gnus-ignored-mime-types nil
623 "List of MIME types that should be ignored by Gnus."
625 :group 'gnus-article-mime
626 :type '(repeat regexp))
628 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
629 "List of MIME types that should not be given buttons when rendered inline."
631 :group 'gnus-article-mime
632 :type '(repeat regexp))
634 (defcustom gnus-article-mime-part-function nil
635 "Function called with a MIME handle as the argument.
636 This is meant for people who want to do something automatic based
637 on parts -- for instance, adding Vcard info to a database."
638 :group 'gnus-article-mime
641 (defcustom gnus-mime-multipart-functions nil
642 "An alist of MIME types to functions to display them."
644 :group 'gnus-article-mime
647 (defcustom gnus-article-date-lapsed-new-header nil
648 "Whether the X-Sent and Date headers can coexist.
649 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
650 either replace the old \"Date:\" header (if this variable is nil), or
651 be added below it (otherwise)."
653 :group 'gnus-article-headers
656 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
657 "Function called with a MIME handle as the argument.
658 This is meant for people who want to view first matched part.
659 For `undisplayed-alternative' (default), the first undisplayed
660 part or alternative part is used. For `undisplayed', the first
661 undisplayed part is used. For a function, the first part which
662 the function return `t' is used. For `nil', the first part is
665 :group 'gnus-article-mime
667 (item :tag "first" :value nil)
668 (item :tag "undisplayed" :value undisplayed)
669 (item :tag "undisplayed or alternative"
670 :value undisplayed-alternative)
673 (defcustom gnus-mime-action-alist
674 '(("save to file" . gnus-mime-save-part)
675 ("display as text" . gnus-mime-inline-part)
676 ("view the part" . gnus-mime-view-part)
677 ("pipe to command" . gnus-mime-pipe-part)
678 ("toggle display" . gnus-article-press-button)
679 ("view as type" . gnus-mime-view-part-as-type)
680 ("internalize type" . gnus-mime-internalize-part)
681 ("externalize type" . gnus-mime-externalize-part))
682 "An alist of actions that run on the MIME attachment."
684 :group 'gnus-article-mime
685 :type '(repeat (cons (string :tag "name")
689 ;;; The treatment variables
692 (defvar gnus-part-display-hook nil
693 "Hook called on parts that are to receive treatment.")
695 (defvar gnus-article-treat-custom
696 '(choice (const :tag "Off" nil)
698 (const :tag "Header" head)
699 (const :tag "Last" last)
700 (integer :tag "Less")
701 (repeat :tag "Groups" regexp)
702 (sexp :tag "Predicate")))
704 (defvar gnus-article-treat-head-custom
705 '(choice (const :tag "Off" nil)
706 (const :tag "Header" head)))
708 (defvar gnus-article-treat-types '("text/plain")
711 (defvar gnus-inhibit-treatment nil
712 "Whether to inhibit treatment.")
714 (defcustom gnus-treat-highlight-signature '(or last (typep "text/x-vcard"))
715 "Highlight the signature.
716 Valid values are nil, t, `head', `last', an integer or a predicate.
717 See the manual for details."
718 :group 'gnus-article-treat
719 :type gnus-article-treat-custom)
720 (put 'gnus-treat-highlight-signature 'highlight t)
722 (defcustom gnus-treat-buttonize 100000
724 Valid values are nil, t, `head', `last', an integer or a predicate.
725 See the manual for details."
726 :group 'gnus-article-treat
727 :type gnus-article-treat-custom)
728 (put 'gnus-treat-buttonize 'highlight t)
730 (defcustom gnus-treat-buttonize-head 'head
731 "Add buttons to the head.
732 Valid values are nil, t, `head', `last', an integer or a predicate.
733 See the manual for details."
734 :group 'gnus-article-treat
735 :type gnus-article-treat-head-custom)
736 (put 'gnus-treat-buttonize-head 'highlight t)
738 (defcustom gnus-treat-emphasize
739 (and (or window-system
741 (>= (string-to-number emacs-version) 21))
744 Valid values are nil, t, `head', `last', an integer or a predicate.
745 See the manual for details."
746 :group 'gnus-article-treat
747 :type gnus-article-treat-custom)
748 (put 'gnus-treat-emphasize 'highlight t)
750 (defcustom gnus-treat-strip-cr nil
751 "Remove carriage returns.
752 Valid values are nil, t, `head', `last', an integer or a predicate.
753 See the manual for details."
754 :group 'gnus-article-treat
755 :type gnus-article-treat-custom)
757 (defcustom gnus-treat-hide-headers 'head
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-head-custom)
764 (defcustom gnus-treat-hide-boring-headers nil
765 "Hide boring headers.
766 Valid values are nil, t, `head', `last', an integer or a predicate.
767 See the manual for details."
768 :group 'gnus-article-treat
769 :type gnus-article-treat-head-custom)
771 (defcustom gnus-treat-hide-signature nil
773 Valid values are nil, t, `head', `last', an integer or a predicate.
774 See the manual for details."
775 :group 'gnus-article-treat
776 :type gnus-article-treat-custom)
778 (defcustom gnus-treat-fill-article nil
780 Valid values are nil, t, `head', `last', an integer or a predicate.
781 See the manual for details."
782 :group 'gnus-article-treat
783 :type gnus-article-treat-custom)
785 (defcustom gnus-treat-hide-citation nil
787 Valid values are nil, t, `head', `last', an integer or a predicate.
788 See the manual for details."
789 :group 'gnus-article-treat
790 :type gnus-article-treat-custom)
792 (defcustom gnus-treat-hide-citation-maybe nil
794 Valid values are nil, t, `head', `last', an integer or a predicate.
795 See the manual for details."
796 :group 'gnus-article-treat
797 :type gnus-article-treat-custom)
799 (defcustom gnus-treat-strip-list-identifiers 'head
800 "Strip list identifiers from `gnus-list-identifiers`.
801 Valid values are nil, t, `head', `last', an integer or a predicate.
802 See the manual for details."
804 :group 'gnus-article-treat
805 :type gnus-article-treat-custom)
807 (defcustom gnus-treat-strip-pgp t
808 "Strip PGP signatures.
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-pem nil
815 "Strip PEM signatures.
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-banner t
822 "Strip banners from articles.
823 The banner to be stripped is specified in the `banner' group parameter.
824 Valid values are nil, t, `head', `last', an integer or a predicate.
825 See the manual for details."
826 :group 'gnus-article-treat
827 :type gnus-article-treat-custom)
829 (defcustom gnus-treat-highlight-headers 'head
830 "Highlight the headers.
831 Valid values are nil, t, `head', `last', an integer or a predicate.
832 See the manual for details."
833 :group 'gnus-article-treat
834 :type gnus-article-treat-head-custom)
835 (put 'gnus-treat-highlight-headers 'highlight t)
837 (defcustom gnus-treat-highlight-citation t
838 "Highlight cited text.
839 Valid values are nil, t, `head', `last', an integer or a predicate.
840 See the manual for details."
841 :group 'gnus-article-treat
842 :type gnus-article-treat-custom)
843 (put 'gnus-treat-highlight-citation 'highlight t)
845 (defcustom gnus-treat-date-ut nil
846 "Display the Date in UT (GMT).
847 Valid values are nil, t, `head', `last', an integer or a predicate.
848 See the manual for details."
849 :group 'gnus-article-treat
850 :type gnus-article-treat-head-custom)
852 (defcustom gnus-treat-date-local nil
853 "Display the Date in the local timezone.
854 Valid values are nil, t, `head', `last', an integer or a predicate.
855 See the manual for details."
856 :group 'gnus-article-treat
857 :type gnus-article-treat-head-custom)
859 (defcustom gnus-treat-date-lapsed nil
860 "Display the Date header in a way that says how much time has elapsed.
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-original nil
867 "Display the date in the original 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-iso8601 nil
874 "Display the date in the ISO8601 format.
875 Valid values are nil, t, `head', `last', an integer or a predicate.
876 See the manual for details."
878 :group 'gnus-article-treat
879 :type gnus-article-treat-head-custom)
881 (defcustom gnus-treat-date-user-defined nil
882 "Display the date in a user-defined format.
883 The format is defined by the `gnus-article-time-format' variable.
884 Valid values are nil, t, `head', `last', an integer or a predicate.
885 See the manual for details."
886 :group 'gnus-article-treat
887 :type gnus-article-treat-head-custom)
889 (defcustom gnus-treat-strip-headers-in-body t
890 "Strip the X-No-Archive header line from the beginning of the body.
891 Valid values are nil, t, `head', `last', an integer or a predicate.
892 See the manual for details."
894 :group 'gnus-article-treat
895 :type gnus-article-treat-custom)
897 (defcustom gnus-treat-strip-trailing-blank-lines nil
898 "Strip trailing blank lines.
899 Valid values are nil, t, `head', `last', an integer or a predicate.
900 See the manual for details."
901 :group 'gnus-article-treat
902 :type gnus-article-treat-custom)
904 (defcustom gnus-treat-strip-leading-blank-lines nil
905 "Strip leading blank lines.
906 Valid values are nil, t, `head', `last', an integer or a predicate.
907 See the manual for details."
908 :group 'gnus-article-treat
909 :type gnus-article-treat-custom)
911 (defcustom gnus-treat-strip-multiple-blank-lines nil
912 "Strip multiple blank lines.
913 Valid values are nil, t, `head', `last', an integer or a predicate.
914 See the manual for details."
915 :group 'gnus-article-treat
916 :type gnus-article-treat-custom)
918 (defcustom gnus-treat-overstrike t
919 "Treat overstrike highlighting.
920 Valid values are nil, t, `head', `last', an integer or a predicate.
921 See the manual for details."
922 :group 'gnus-article-treat
923 :type gnus-article-treat-custom)
924 (put 'gnus-treat-overstrike 'highlight t)
926 (defcustom gnus-treat-display-xface
927 (and (or (and (fboundp 'image-type-available-p)
928 (image-type-available-p 'xbm)
929 (string-match "^0x" (shell-command-to-string "uncompface")))
930 (and (featurep 'xemacs) (featurep 'xface)))
932 "Display X-Face headers.
933 Valid values are nil, t, `head', `last', an integer or a predicate.
934 See the manual for details."
935 :group 'gnus-article-treat
937 :type gnus-article-treat-head-custom)
938 (put 'gnus-treat-display-xface 'highlight t)
940 (defcustom gnus-treat-display-smileys
941 (if (or (and (featurep 'xemacs)
943 (and (fboundp 'image-type-available-p)
944 (image-type-available-p 'pbm)))
947 Valid values are nil, t, `head', `last', an integer or a predicate.
948 See the manual for details."
949 :group 'gnus-article-treat
951 :type gnus-article-treat-custom)
952 (put 'gnus-treat-display-smileys 'highlight t)
954 (defcustom gnus-treat-display-picons (if (featurep 'xemacs) 'head nil)
956 Valid values are nil, t, `head', `last', an integer or a predicate.
957 See the manual for details."
958 :group 'gnus-article-treat
959 :type gnus-article-treat-head-custom)
960 (put 'gnus-treat-display-picons 'highlight t)
962 (defcustom gnus-treat-capitalize-sentences nil
963 "Capitalize sentence-starting words.
964 Valid values are nil, t, `head', `last', an integer or a predicate.
965 See the manual for details."
967 :group 'gnus-article-treat
968 :type gnus-article-treat-custom)
970 (defcustom gnus-treat-fill-long-lines 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-custom)
977 (defcustom gnus-treat-play-sounds nil
979 Valid values are nil, t, `head', `last', an integer or a predicate.
980 See the manual for details."
982 :group 'gnus-article-treat
983 :type gnus-article-treat-custom)
985 (defcustom gnus-treat-translate nil
986 "Translate articles from one language to another.
987 Valid values are nil, t, `head', `last', an integer or a predicate.
988 See the manual for details."
990 :group 'gnus-article-treat
991 :type gnus-article-treat-custom)
993 ;;; Internal variables
995 (defvar article-goto-body-goes-to-point-min-p nil)
996 (defvar gnus-article-wash-types nil)
997 (defvar gnus-article-emphasis-alist nil)
999 (defvar gnus-article-mime-handle-alist-1 nil)
1000 (defvar gnus-treatment-function-alist
1001 '((gnus-treat-strip-banner gnus-article-strip-banner)
1002 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1003 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1004 (gnus-treat-buttonize gnus-article-add-buttons)
1005 (gnus-treat-fill-article gnus-article-fill-cited-article)
1006 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1007 (gnus-treat-strip-cr gnus-article-remove-cr)
1008 (gnus-treat-emphasize gnus-article-emphasize)
1009 (gnus-treat-display-xface gnus-article-display-x-face)
1010 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1011 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1012 (gnus-treat-hide-signature gnus-article-hide-signature)
1013 (gnus-treat-hide-citation gnus-article-hide-citation)
1014 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1015 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1016 (gnus-treat-strip-pgp gnus-article-hide-pgp)
1017 (gnus-treat-strip-pem gnus-article-hide-pem)
1018 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1019 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1020 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1021 (gnus-treat-date-ut gnus-article-date-ut)
1022 (gnus-treat-date-local gnus-article-date-local)
1023 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1024 (gnus-treat-date-original gnus-article-date-original)
1025 (gnus-treat-date-user-defined gnus-article-date-user)
1026 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1027 (gnus-treat-strip-trailing-blank-lines
1028 gnus-article-remove-trailing-blank-lines)
1029 (gnus-treat-strip-leading-blank-lines
1030 gnus-article-strip-leading-blank-lines)
1031 (gnus-treat-strip-multiple-blank-lines
1032 gnus-article-strip-multiple-blank-lines)
1033 (gnus-treat-overstrike gnus-article-treat-overstrike)
1034 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1035 (gnus-treat-display-smileys gnus-smiley-display)
1036 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1037 (gnus-treat-display-picons gnus-article-display-picons)
1038 (gnus-treat-play-sounds gnus-earcon-display)))
1040 (defvar gnus-article-mime-handle-alist nil)
1041 (defvar article-lapsed-timer nil)
1042 (defvar gnus-article-current-summary nil)
1044 (defvar gnus-article-mode-syntax-table
1045 (let ((table (copy-syntax-table text-mode-syntax-table)))
1046 (modify-syntax-entry ?- "w" table)
1047 (modify-syntax-entry ?> ")" table)
1048 (modify-syntax-entry ?< "(" table)
1050 "Syntax table used in article mode buffers.
1051 Initialized from `text-mode-syntax-table.")
1053 (defvar gnus-save-article-buffer nil)
1055 (defvar gnus-article-mode-line-format-alist
1056 (nconc '((?w (gnus-article-wash-status) ?s)
1057 (?m (gnus-article-mime-part-status) ?s))
1058 gnus-summary-mode-line-format-alist))
1060 (defvar gnus-number-of-articles-to-be-saved nil)
1062 (defvar gnus-inhibit-hiding nil)
1064 (defsubst gnus-article-hide-text (b e props)
1065 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1066 (gnus-add-text-properties-when 'article-type nil b e props)
1067 (when (memq 'intangible props)
1069 (max (1- b) (point-min))
1070 b 'intangible (cddr (memq 'intangible props)))))
1072 (defsubst gnus-article-unhide-text (b e)
1073 "Remove hidden text properties from region between B and E."
1074 (remove-text-properties b e gnus-hidden-properties)
1075 (when (memq 'intangible gnus-hidden-properties)
1076 (put-text-property (max (1- b) (point-min))
1077 b 'intangible nil)))
1079 (defun gnus-article-hide-text-type (b e type)
1080 "Hide text of TYPE between B and E."
1081 (push type gnus-article-wash-types)
1082 (gnus-article-hide-text
1083 b e (cons 'article-type (cons type gnus-hidden-properties))))
1085 (defun gnus-article-unhide-text-type (b e type)
1086 "Unhide text of TYPE between B and E."
1087 (setq gnus-article-wash-types
1088 (delq type gnus-article-wash-types))
1089 (remove-text-properties
1090 b e (cons 'article-type (cons type gnus-hidden-properties)))
1091 (when (memq 'intangible gnus-hidden-properties)
1092 (put-text-property (max (1- b) (point-min))
1093 b 'intangible nil)))
1095 (defun gnus-article-hide-text-of-type (type)
1096 "Hide text of TYPE in the current buffer."
1098 (let ((b (point-min))
1100 (while (setq b (text-property-any b e 'article-type type))
1101 (add-text-properties b (incf b) gnus-hidden-properties)))))
1103 (defun gnus-article-delete-text-of-type (type)
1104 "Delete text of TYPE in the current buffer."
1106 (let ((b (point-min)))
1107 (while (setq b (text-property-any b (point-max) 'article-type type))
1109 b (or (text-property-not-all b (point-max) 'article-type type)
1112 (defun gnus-article-delete-invisible-text ()
1113 "Delete all invisible text in the current buffer."
1115 (let ((b (point-min)))
1116 (while (setq b (text-property-any b (point-max) 'invisible t))
1118 b (or (text-property-not-all b (point-max) 'invisible t)
1121 (defun gnus-article-text-type-exists-p (type)
1122 "Say whether any text of type TYPE exists in the buffer."
1123 (text-property-any (point-min) (point-max) 'article-type type))
1125 (defsubst gnus-article-header-rank ()
1126 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1127 (let ((list gnus-sorted-header-list)
1130 (when (looking-at (car list))
1132 (setq list (cdr list))
1136 (defun article-hide-headers (&optional arg delete)
1137 "Hide unwanted headers and possibly sort them as well."
1139 ;; This function might be inhibited.
1140 (unless gnus-inhibit-hiding
1143 (let ((buffer-read-only nil)
1144 (case-fold-search t)
1145 (max (1+ (length gnus-sorted-header-list)))
1146 (ignored (when (not gnus-visible-headers)
1147 (cond ((stringp gnus-ignored-headers)
1148 gnus-ignored-headers)
1149 ((listp gnus-ignored-headers)
1150 (mapconcat 'identity gnus-ignored-headers
1153 (cond ((stringp gnus-visible-headers)
1154 gnus-visible-headers)
1155 ((and gnus-visible-headers
1156 (listp gnus-visible-headers))
1157 (mapconcat 'identity gnus-visible-headers "\\|"))))
1158 (inhibit-point-motion-hooks t)
1160 ;; First we narrow to just the headers.
1161 (article-narrow-to-head)
1162 ;; Hide any "From " lines at the beginning of (mail) articles.
1163 (while (looking-at "From ")
1166 (delete-region (point-min) (point)))
1167 ;; Then treat the rest of the header lines.
1168 ;; Then we use the two regular expressions
1169 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1170 ;; select which header lines is to remain visible in the
1172 (while (re-search-forward "^[^ \t]*:" nil t)
1174 ;; Mark the rank of the header.
1176 (point) (1+ (point)) 'message-rank
1177 (if (or (and visible (looking-at visible))
1179 (not (looking-at ignored))))
1180 (gnus-article-header-rank)
1183 (message-sort-headers-1)
1184 (when (setq beg (text-property-any
1185 (point-min) (point-max) 'message-rank (+ 2 max)))
1186 ;; We delete the unwanted headers.
1187 (push 'headers gnus-article-wash-types)
1188 (add-text-properties (point-min) (+ 5 (point-min))
1189 '(article-type headers dummy-invisible t))
1190 (delete-region beg (point-max))))))))
1192 (defun article-hide-boring-headers (&optional arg)
1193 "Toggle hiding of headers that aren't very interesting.
1194 If given a negative prefix, always show; if given a positive prefix,
1196 (interactive (gnus-article-hidden-arg))
1197 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1198 (not gnus-show-all-headers))
1201 (let ((buffer-read-only nil)
1202 (list gnus-boring-article-headers)
1203 (inhibit-point-motion-hooks t)
1205 (article-narrow-to-head)
1207 (setq elem (pop list))
1208 (goto-char (point-min))
1210 ;; Hide empty headers.
1212 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1214 (gnus-article-hide-text-type
1215 (progn (beginning-of-line) (point))
1218 (if (re-search-forward "^[^ \t]" nil t)
1222 ;; Hide boring Newsgroups header.
1223 ((eq elem 'newsgroups)
1224 (when (equal (gnus-fetch-field "newsgroups")
1225 (gnus-group-real-name
1226 (if (boundp 'gnus-newsgroup-name)
1229 (gnus-article-hide-header "newsgroups")))
1230 ((eq elem 'followup-to)
1231 (when (equal (message-fetch-field "followup-to")
1232 (message-fetch-field "newsgroups"))
1233 (gnus-article-hide-header "followup-to")))
1234 ((eq elem 'reply-to)
1235 (let ((from (message-fetch-field "from"))
1236 (reply-to (message-fetch-field "reply-to")))
1241 (nth 1 (mail-extract-address-components from))
1242 (nth 1 (mail-extract-address-components reply-to)))))
1243 (gnus-article-hide-header "reply-to"))))
1245 (let ((date (message-fetch-field "date")))
1247 (< (days-between (current-time-string) date)
1249 (gnus-article-hide-header "date"))))
1251 (let ((to (message-fetch-field "to"))
1252 (cc (message-fetch-field "cc")))
1253 (when (> (length to) 1024)
1254 (gnus-article-hide-header "to"))
1255 (when (> (length cc) 1024)
1256 (gnus-article-hide-header "cc"))))
1260 (goto-char (point-min))
1261 (while (re-search-forward "^to:" nil t)
1262 (setq to-count (1+ to-count)))
1263 (when (> to-count 1)
1264 (while (> to-count 0)
1265 (goto-char (point-min))
1267 (re-search-forward "^to:" nil nil to-count)
1269 (narrow-to-region (point) (point-max))
1270 (gnus-article-hide-header "to"))
1271 (setq to-count (1- to-count))))
1272 (goto-char (point-min))
1273 (while (re-search-forward "^cc:" nil t)
1274 (setq cc-count (1+ cc-count)))
1275 (when (> cc-count 1)
1276 (while (> cc-count 0)
1277 (goto-char (point-min))
1279 (re-search-forward "^cc:" nil nil cc-count)
1281 (narrow-to-region (point) (point-max))
1282 (gnus-article-hide-header "cc"))
1283 (setq cc-count (1- cc-count)))))))))))))
1285 (defun gnus-article-hide-header (header)
1287 (goto-char (point-min))
1288 (when (re-search-forward (concat "^" header ":") nil t)
1289 (gnus-article-hide-text-type
1290 (progn (beginning-of-line) (point))
1293 (if (re-search-forward "^[^ \t]" nil t)
1298 (defvar gnus-article-normalized-header-length 40
1299 "Length of normalized headers.")
1301 (defun article-normalize-headers ()
1302 "Make all header lines 40 characters long."
1304 (let ((buffer-read-only nil)
1308 (article-narrow-to-head)
1311 ((< (setq column (- (gnus-point-at-eol) (point)))
1312 gnus-article-normalized-header-length)
1314 (insert (make-string
1315 (- gnus-article-normalized-header-length column)
1317 ((> column gnus-article-normalized-header-length)
1318 (gnus-put-text-property
1320 (forward-char gnus-article-normalized-header-length)
1327 (forward-line 1))))))
1329 (defun article-treat-dumbquotes ()
1330 "Translate M****s*** sm*rtq**t*s into proper text.
1331 Note that this function guesses whether a character is a sm*rtq**t* or
1332 not, so it should only be used interactively.
1334 Sm*rtq**t*s are M****s***'s unilateral extension to the character map
1335 in an attempt to provide more quoting characters. If you see
1336 something like \\222 or \\264 where you're expecting some kind of
1337 apostrophe or quotation mark, then try this wash."
1339 (article-translate-strings gnus-article-dumbquotes-map))
1341 (defun article-translate-characters (from to)
1342 "Translate all characters in the body of the article according to FROM and TO.
1343 FROM is a string of characters to translate from; to is a string of
1344 characters to translate to."
1346 (when (article-goto-body)
1347 (let ((buffer-read-only nil)
1348 (x (make-string 225 ?x))
1350 (while (< (incf i) (length x))
1353 (while (< i (length from))
1354 (aset x (aref from i) (aref to i))
1356 (translate-region (point) (point-max) x)))))
1358 (defun article-translate-strings (map)
1359 "Translate all string in the body of the article according to MAP.
1360 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1362 (when (article-goto-body)
1363 (let ((buffer-read-only nil)
1365 (while (setq elem (pop map))
1367 (while (search-forward (car elem) nil t)
1368 (replace-match (cadr elem)))))))))
1370 (defun article-treat-overstrike ()
1371 "Translate overstrikes into bold text."
1374 (when (article-goto-body)
1375 (let ((buffer-read-only nil))
1376 (while (search-forward "\b" nil t)
1377 (let ((next (char-after))
1378 (previous (char-after (- (point) 2))))
1379 ;; We do the boldification/underlining by hiding the
1380 ;; overstrikes and putting the proper text property
1384 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1385 (put-text-property (point) (1+ (point)) 'face 'bold))
1387 (gnus-article-hide-text-type
1388 (1- (point)) (1+ (point)) 'overstrike)
1390 (- (point) 2) (1- (point)) 'face 'underline))
1392 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1394 (point) (1+ (point)) 'face 'underline)))))))))
1396 (defun article-fill-long-lines ()
1397 "Fill lines that are wider than the window width."
1400 (let ((buffer-read-only nil)
1401 (width (window-width (get-buffer-window (current-buffer)))))
1404 (let ((adaptive-fill-mode nil)) ;Why? -sm
1407 (when (>= (current-column) (min fill-column width))
1408 (narrow-to-region (point) (gnus-point-at-bol))
1409 (fill-paragraph nil)
1410 (goto-char (point-max))
1412 (forward-line 1)))))))
1414 (defun article-capitalize-sentences ()
1415 "Capitalize the first word in each sentence."
1418 (let ((buffer-read-only nil)
1419 (paragraph-start "^[\n\^L]"))
1423 (forward-sentence)))))
1425 (defun article-remove-cr ()
1426 "Remove trailing CRs and then translate remaining CRs into LFs."
1429 (let ((buffer-read-only nil))
1430 (goto-char (point-min))
1431 (while (re-search-forward "\r+$" nil t)
1432 (replace-match "" t t))
1433 (goto-char (point-min))
1434 (while (search-forward "\r" nil t)
1435 (replace-match "\n" t t)))))
1437 (defun article-remove-trailing-blank-lines ()
1438 "Remove all trailing blank lines from the article."
1441 (let ((buffer-read-only nil))
1442 (goto-char (point-max))
1446 (while (and (not (bobp))
1447 (looking-at "^[ \t]*$")
1448 (not (gnus-annotation-in-region-p
1449 (point) (gnus-point-at-eol))))
1454 (defun article-display-x-face (&optional force)
1455 "Look for an X-Face header and display it if present."
1456 (interactive (list 'force))
1458 ;; Delete the old process, if any.
1459 (when (process-status "article-x-face")
1460 (delete-process "article-x-face"))
1461 (let ((inhibit-point-motion-hooks t)
1462 (case-fold-search t)
1465 (article-narrow-to-head)
1466 (goto-char (point-min))
1467 (setq from (message-fetch-field "from"))
1468 (goto-char (point-min))
1469 (while (and gnus-article-x-face-command
1472 ;; Check whether this face is censored.
1473 (not gnus-article-x-face-too-ugly)
1474 (and gnus-article-x-face-too-ugly from
1475 (not (string-match gnus-article-x-face-too-ugly
1477 ;; Has to be present.
1478 (re-search-forward "^X-Face: " nil t))
1479 ;; This used to try to do multiple faces (`while' instead of
1480 ;; `when' above), but (a) sending multiple EOFs to xv doesn't
1481 ;; work (b) it can crash some versions of Emacs (c) are
1482 ;; multiple faces really something to encourage?
1483 (when (stringp gnus-article-x-face-command)
1485 ;; We now have the area of the buffer where the X-Face is stored.
1488 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
1489 ;; We display the face.
1490 (if (symbolp gnus-article-x-face-command)
1491 ;; The command is a lisp function, so we call it.
1492 (if (gnus-functionp gnus-article-x-face-command)
1493 (funcall gnus-article-x-face-command beg end)
1494 (error "%s is not a function" gnus-article-x-face-command))
1495 ;; The command is a string, so we interpret the command
1496 ;; as a, well, command, and fork it off.
1497 (let ((process-connection-type nil))
1498 (process-kill-without-query
1500 "article-x-face" nil shell-file-name shell-command-switch
1501 gnus-article-x-face-command))
1502 (process-send-region "article-x-face" beg end)
1503 (process-send-eof "article-x-face"))))))))))
1505 (defun article-decode-mime-words ()
1506 "Decode all MIME-encoded words in the article."
1509 (set-buffer gnus-article-buffer)
1510 (let ((inhibit-point-motion-hooks t)
1512 (mail-parse-charset gnus-newsgroup-charset)
1513 (mail-parse-ignored-charsets
1514 (save-excursion (set-buffer gnus-summary-buffer)
1515 gnus-newsgroup-ignored-charsets)))
1516 (mail-decode-encoded-word-region (point-min) (point-max)))))
1518 (defun article-decode-charset (&optional prompt)
1519 "Decode charset-encoded text in the article.
1520 If PROMPT (the prefix), prompt for a coding system to use."
1522 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
1524 (mail-parse-charset gnus-newsgroup-charset)
1525 (mail-parse-ignored-charsets
1526 (save-excursion (condition-case nil
1527 (set-buffer gnus-summary-buffer)
1529 gnus-newsgroup-ignored-charsets))
1530 ct cte ctl charset format)
1533 (article-narrow-to-head)
1534 (setq ct (message-fetch-field "Content-Type" t)
1535 cte (message-fetch-field "Content-Transfer-Encoding" t)
1536 ctl (and ct (ignore-errors
1537 (mail-header-parse-content-type ct)))
1540 (mm-read-coding-system "Charset to decode: "))
1542 (mail-content-type-get ctl 'charset)))
1543 format (and ctl (mail-content-type-get ctl 'format)))
1545 (setq cte (mail-header-strip cte)))
1546 (if (and ctl (not (string-match "/" (car ctl))))
1548 (goto-char (point-max)))
1551 (narrow-to-region (point) (point-max))
1552 (when (and (eq mail-parse-charset 'gnus-decoded)
1553 (eq (mm-body-7-or-8) '8bit))
1554 ;; The text code could have been decoded.
1555 (setq charset mail-parse-charset))
1556 (when (and (or (not ctl)
1557 (equal (car ctl) "text/plain"))
1558 (not format)) ;; article with format will decode later.
1560 charset (and cte (intern (downcase
1561 (gnus-strip-whitespace cte))))
1564 (defun article-decode-encoded-words ()
1565 "Remove encoded-word encoding from headers."
1566 (let ((inhibit-point-motion-hooks t)
1567 (mail-parse-charset gnus-newsgroup-charset)
1568 (mail-parse-ignored-charsets
1569 (save-excursion (condition-case nil
1570 (set-buffer gnus-summary-buffer)
1572 gnus-newsgroup-ignored-charsets))
1575 (article-narrow-to-head)
1576 (funcall gnus-decode-header-function (point-min) (point-max)))))
1578 (defun article-de-quoted-unreadable (&optional force)
1579 "Translate a quoted-printable-encoded article.
1580 If FORCE, decode the article whether it is marked as quoted-printable
1582 (interactive (list 'force))
1584 (let ((buffer-read-only nil) type charset)
1585 (if (gnus-buffer-live-p gnus-original-article-buffer)
1586 (with-current-buffer gnus-original-article-buffer
1588 (gnus-fetch-field "content-transfer-encoding"))
1589 (let* ((ct (gnus-fetch-field "content-type"))
1592 (mail-header-parse-content-type ct)))))
1593 (setq charset (and ctl
1594 (mail-content-type-get ctl 'charset)))
1595 (if (stringp charset)
1596 (setq charset (intern (downcase charset)))))))
1598 (setq charset gnus-newsgroup-charset))
1600 (and type (let ((case-fold-search t))
1601 (string-match "quoted-printable" type))))
1603 (quoted-printable-decode-region
1604 (point) (point-max) (mm-charset-to-coding-system charset))))))
1606 (defun article-de-base64-unreadable (&optional force)
1607 "Translate a base64 article.
1608 If FORCE, decode the article whether it is marked as base64 not."
1609 (interactive (list 'force))
1611 (let ((buffer-read-only nil) type charset)
1612 (if (gnus-buffer-live-p gnus-original-article-buffer)
1613 (with-current-buffer gnus-original-article-buffer
1615 (gnus-fetch-field "content-transfer-encoding"))
1616 (let* ((ct (gnus-fetch-field "content-type"))
1619 (mail-header-parse-content-type ct)))))
1620 (setq charset (and ctl
1621 (mail-content-type-get ctl 'charset)))
1622 (if (stringp charset)
1623 (setq charset (intern (downcase charset)))))))
1625 (setq charset gnus-newsgroup-charset))
1627 (and type (let ((case-fold-search t))
1628 (string-match "base64" type))))
1631 (narrow-to-region (point) (point-max))
1632 (base64-decode-region (point-min) (point-max))
1633 (mm-decode-coding-region
1634 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
1639 (defun article-decode-HZ ()
1640 "Translate a HZ-encoded article."
1644 (let ((buffer-read-only nil))
1645 (rfc1843-decode-region (point-min) (point-max)))))
1647 (defun article-wash-html ()
1648 "Format an html article."
1651 (let ((buffer-read-only nil)
1653 (if (gnus-buffer-live-p gnus-original-article-buffer)
1654 (with-current-buffer gnus-original-article-buffer
1655 (let* ((ct (gnus-fetch-field "content-type"))
1658 (mail-header-parse-content-type ct)))))
1659 (setq charset (and ctl
1660 (mail-content-type-get ctl 'charset)))
1661 (if (stringp charset)
1662 (setq charset (intern (downcase charset)))))))
1664 (setq charset gnus-newsgroup-charset))
1666 (save-window-excursion
1668 (narrow-to-region (point) (point-max))
1670 (let ((w3-strict-width (window-width))
1671 (url-gateway-unplugged t)
1672 (url-standalone-mode t))
1674 (w3-region (point-min) (point-max))
1677 (defun article-hide-list-identifiers ()
1678 "Remove list identifies from the Subject header.
1679 The `gnus-list-identifiers' variable specifies what to do."
1683 (let ((inhibit-point-motion-hooks t)
1685 (article-narrow-to-head)
1686 (let ((regexp (if (stringp gnus-list-identifiers) gnus-list-identifiers
1687 (mapconcat 'identity gnus-list-identifiers " *\\|"))))
1689 (goto-char (point-min))
1690 (when (re-search-forward
1691 (concat "^Subject: +\\(\\(\\(Re: +\\)?\\(" regexp
1692 " *\\)\\)+\\(Re: +\\)?\\)")
1694 (let ((s (or (match-string 3) (match-string 5))))
1695 (delete-region (match-beginning 1) (match-end 1))
1697 (goto-char (match-beginning 1))
1700 (defun article-hide-pgp ()
1701 "Remove any PGP headers and signatures in the current article."
1705 (let ((inhibit-point-motion-hooks t)
1706 buffer-read-only beg end)
1708 ;; Hide the "header".
1709 (when (re-search-forward "^-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
1710 (push 'pgp gnus-article-wash-types)
1711 (delete-region (match-beginning 0) (match-end 0))
1712 ;; Remove armor headers (rfc2440 6.2)
1713 (delete-region (point) (or (re-search-forward "^[ \t]*\n" nil t)
1716 ;; Hide the actual signature.
1717 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
1718 (setq end (1+ (match-beginning 0)))
1721 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
1723 ;; Perhaps we shouldn't hide to the end of the buffer
1724 ;; if there is no end to the signature?
1726 ;; Hide "- " PGP quotation markers.
1728 (narrow-to-region beg end)
1729 (goto-char (point-min))
1730 (while (re-search-forward "^- " nil t)
1732 (match-beginning 0) (match-end 0)))
1734 (gnus-run-hooks 'gnus-article-hide-pgp-hook))))))
1736 (defun article-hide-pem (&optional arg)
1737 "Toggle hiding of any PEM headers and signatures in the current article.
1738 If given a negative prefix, always show; if given a positive prefix,
1740 (interactive (gnus-article-hidden-arg))
1741 (unless (gnus-article-check-hidden-text 'pem arg)
1743 (let (buffer-read-only end)
1744 (goto-char (point-min))
1745 ;; Hide the horrendously ugly "header".
1746 (when (and (search-forward
1747 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
1749 (setq end (1+ (match-beginning 0))))
1750 (push 'pem gnus-article-wash-types)
1751 (gnus-article-hide-text-type
1753 (if (search-forward "\n\n" nil t)
1757 ;; Hide the trailer as well
1758 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
1760 (gnus-article-hide-text-type
1761 (match-beginning 0) (match-end 0) 'pem)))))))
1763 (defun article-strip-banner ()
1764 "Strip the banner specified by the `banner' group parameter."
1768 (let ((inhibit-point-motion-hooks t)
1769 (banner (gnus-group-find-parameter gnus-newsgroup-name 'banner))
1770 (gnus-signature-limit nil)
1771 buffer-read-only beg end)
1775 ((eq banner 'signature)
1776 (when (gnus-article-narrow-to-signature)
1779 (delete-region (point) (point-max))))
1781 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
1782 (while (re-search-forward banner nil t)
1783 (delete-region (match-beginning 0) (match-end 0)))))
1785 (while (re-search-forward banner nil t)
1786 (delete-region (match-beginning 0) (match-end 0))))))))))
1788 (defun article-babel ()
1789 "Translate article using an online translation service."
1793 (set-buffer gnus-article-buffer)
1794 (when (article-goto-body)
1795 (let* ((buffer-read-only nil)
1798 (orig (buffer-substring start end))
1799 (trans (babel-as-string orig)))
1801 (narrow-to-region start end)
1802 (delete-region start end)
1805 (defun article-hide-signature (&optional arg)
1806 "Hide the signature in the current article.
1807 If given a negative prefix, always show; if given a positive prefix,
1809 (interactive (gnus-article-hidden-arg))
1810 (unless (gnus-article-check-hidden-text 'signature arg)
1813 (let ((buffer-read-only nil))
1814 (when (gnus-article-narrow-to-signature)
1815 (gnus-article-hide-text-type
1816 (point-min) (point-max) 'signature)))))))
1818 (defun article-strip-headers-in-body ()
1819 "Strip offensive headers from bodies."
1823 (let ((case-fold-search t))
1824 (when (looking-at "x-no-archive:")
1825 (gnus-delete-line)))))
1827 (defun article-strip-leading-blank-lines ()
1828 "Remove all blank lines from the beginning of the article."
1831 (let ((inhibit-point-motion-hooks t)
1833 (when (article-goto-body)
1834 (while (and (not (eobp))
1835 (looking-at "[ \t]*$"))
1836 (gnus-delete-line))))))
1838 (defun article-narrow-to-head ()
1839 "Narrow the buffer to the head of the message.
1840 Point is left at the beginning of the narrowed-to region."
1842 (goto-char (point-min))
1843 (if (search-forward "\n\n" nil 1)
1846 (goto-char (point-min)))
1848 (defun article-goto-body ()
1849 "Place point at the start of the body."
1850 (goto-char (point-min))
1852 ;; This variable is only bound when dealing with separate
1854 (article-goto-body-goes-to-point-min-p
1856 ((search-forward "\n\n" nil t)
1859 (goto-char (point-max))
1862 (defun article-strip-multiple-blank-lines ()
1863 "Replace consecutive blank lines with one empty line."
1866 (let ((inhibit-point-motion-hooks t)
1868 ;; First make all blank lines empty.
1870 (while (re-search-forward "^[ \t]+$" nil t)
1871 (unless (gnus-annotation-in-region-p
1872 (match-beginning 0) (match-end 0))
1873 (replace-match "" nil t)))
1874 ;; Then replace multiple empty lines with a single empty line.
1876 (while (re-search-forward "\n\n\n+" nil t)
1877 (unless (gnus-annotation-in-region-p
1878 (match-beginning 0) (match-end 0))
1879 (replace-match "\n\n" t t))))))
1881 (defun article-strip-leading-space ()
1882 "Remove all white space from the beginning of the lines in the article."
1885 (let ((inhibit-point-motion-hooks t)
1888 (while (re-search-forward "^[ \t]+" nil t)
1889 (replace-match "" t t)))))
1891 (defun article-strip-trailing-space ()
1892 "Remove all white space from the end of the lines in the article."
1895 (let ((inhibit-point-motion-hooks t)
1898 (while (re-search-forward "[ \t]+$" nil t)
1899 (replace-match "" t t)))))
1901 (defun article-strip-blank-lines ()
1902 "Strip leading, trailing and multiple blank lines."
1904 (article-strip-leading-blank-lines)
1905 (article-remove-trailing-blank-lines)
1906 (article-strip-multiple-blank-lines))
1908 (defun article-strip-all-blank-lines ()
1909 "Strip all blank lines."
1912 (let ((inhibit-point-motion-hooks t)
1915 (while (re-search-forward "^[ \t]*\n" nil t)
1916 (replace-match "" t t)))))
1918 (defun gnus-article-narrow-to-signature ()
1919 "Narrow to the signature; return t if a signature is found, else nil."
1920 (let ((inhibit-point-motion-hooks t))
1921 (when (gnus-article-search-signature)
1923 ;; Check whether we have some limits to what we consider
1924 ;; to be a signature.
1925 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
1926 (list gnus-signature-limit)))
1928 (while (setq limit (pop limits))
1929 (if (or (and (integerp limit)
1930 (< (- (point-max) (point)) limit))
1932 (< (count-lines (point) (point-max)) limit))
1933 (and (gnus-functionp limit)
1935 (and (stringp limit)
1936 (not (re-search-forward limit nil t))))
1937 () ; This limit did not succeed.
1941 (narrow-to-region (point) (point-max))
1944 (defun gnus-article-search-signature ()
1945 "Search the current buffer for the signature separator.
1946 Put point at the beginning of the signature separator."
1947 (let ((cur (point)))
1948 (goto-char (point-max))
1949 (if (if (stringp gnus-signature-separator)
1950 (re-search-backward gnus-signature-separator nil t)
1951 (let ((seps gnus-signature-separator))
1953 (not (re-search-backward (car seps) nil t)))
1960 (defun gnus-article-hidden-arg ()
1961 "Return the current prefix arg as a number, or 0 if no prefix."
1962 (list (if current-prefix-arg
1963 (prefix-numeric-value current-prefix-arg)
1966 (defun gnus-article-check-hidden-text (type arg)
1967 "Return nil if hiding is necessary.
1968 Arg can be nil or a number. nil and positive means hide, negative
1969 means show, 0 means toggle."
1972 (let ((hide (gnus-article-hidden-text-p type)))
1978 (gnus-article-show-hidden-text type)
1981 (if (eq hide 'hidden)
1983 (gnus-article-show-hidden-text type)
1987 (defun gnus-article-hidden-text-p (type)
1988 "Say whether the current buffer contains hidden text of type TYPE."
1989 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
1991 (not (get-text-property pos 'invisible))
1992 (not (get-text-property pos 'dummy-invisible)))
1994 (text-property-any (1+ pos) (point-max) 'article-type type)))
1999 (defun gnus-article-show-hidden-text (type &optional dummy)
2000 "Show all hidden text of type TYPE.
2001 Originally it is hide instead of DUMMY."
2002 (let ((buffer-read-only nil)
2003 (inhibit-point-motion-hooks t))
2004 (gnus-remove-text-properties-when
2006 (point-min) (point-max)
2007 (cons 'article-type (cons type
2008 gnus-hidden-properties)))))
2010 (defconst article-time-units
2011 `((year . ,(* 365.25 24 60 60))
2012 (week . ,(* 7 24 60 60))
2013 (day . ,(* 24 60 60))
2017 "Mapping from time units to seconds.")
2019 (defun article-date-ut (&optional type highlight header)
2020 "Convert DATE date to universal time in the current article.
2021 If TYPE is `local', convert to local time; if it is `lapsed', output
2022 how much time has lapsed since DATE. For `lapsed', the value of
2023 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2024 should replace the \"Date:\" one, or should be added below it."
2025 (interactive (list 'ut t))
2026 (let* ((header (or header
2027 (message-fetch-field "date")
2029 (tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2032 ((not gnus-article-date-lapsed-new-header)
2038 (date (if (vectorp header) (mail-header-date header)
2040 (inhibit-point-motion-hooks t)
2045 (article-narrow-to-head)
2046 (when (re-search-forward tdate-regexp nil t)
2047 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2048 date (or (get-text-property (gnus-point-at-bol)
2051 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
2053 (when (and date (not (string= date "")))
2054 (goto-char (point-min))
2055 (let ((buffer-read-only nil))
2056 ;; Delete any old Date headers.
2057 (while (re-search-forward date-regexp nil t)
2059 (delete-region (progn (beginning-of-line) (point))
2060 (progn (forward-line 1) (point)))
2061 (delete-region (progn (beginning-of-line) (point))
2062 (progn (end-of-line) (point)))
2063 (setq pos (point))))
2064 (when (and (not pos) (re-search-forward tdate-regexp nil t))
2066 (if pos (goto-char pos))
2067 (insert (article-make-date-line date (or type 'ut)))
2073 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2074 (put-text-property (match-beginning 1) (1+ (match-end 1))
2075 'original-date date)
2076 (put-text-property (match-beginning 1) (1+ (match-end 1))
2078 (put-text-property (match-beginning 2) (match-end 2)
2081 (defun article-make-date-line (date type)
2082 "Return a DATE line of TYPE."
2083 (let ((time (condition-case ()
2087 ;; Convert to the local timezone. We have to slap a
2088 ;; `condition-case' round the calls to the timezone
2089 ;; functions since they aren't particularly resistant to
2092 (let ((tz (car (current-time-zone time))))
2093 (format "Date: %s %s%02d%02d" (current-time-string time)
2094 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2095 (/ (% (abs tz) 3600) 60))))
2096 ;; Convert to Universal Time.
2099 (current-time-string
2100 (let* ((e (parse-time-string date))
2101 (tm (apply 'encode-time e))
2103 (ls (- (cadr tm) (car (current-time-zone time)))))
2104 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2105 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2108 ;; Get the original date from the article.
2109 ((eq type 'original)
2110 (concat "Date: " (if (string-match "\n+$" date)
2111 (substring date 0 (match-beginning 0))
2113 ;; Let the user define the format.
2115 (if (gnus-functionp gnus-article-time-format)
2116 (funcall gnus-article-time-format time)
2119 (format-time-string gnus-article-time-format time))))
2122 (let ((tz (car (current-time-zone time))))
2125 (format-time-string "%Y%m%dT%H%M%S" time)
2126 (format "%s%02d%02d"
2127 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2128 (/ (% (abs tz) 3600) 60)))))
2129 ;; Do an X-Sent lapsed format.
2131 ;; If the date is seriously mangled, the timezone functions are
2132 ;; liable to bug out, so we ignore all errors.
2133 (let* ((now (current-time))
2134 (real-time (subtract-time now time))
2135 (real-sec (and real-time
2136 (+ (* (float (car real-time)) 65536)
2138 (sec (and real-time (abs real-sec)))
2148 ;; This is a bit convoluted, but basically we go
2149 ;; through the time units for years, weeks, etc,
2150 ;; and divide things to see whether that results
2151 ;; in positive answers.
2154 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2155 ;; The (remaining) seconds are too few to
2156 ;; be divided into this time unit.
2158 ;; It's big enough, so we output it.
2159 (setq sec (- sec (* num (cdr unit))))
2161 (concat (if prev ", " "") (int-to-string
2163 " " (symbol-name (car unit))
2164 (if (> num 1) "s" ""))
2166 article-time-units "")
2167 ;; If dates are odd, then it might appear like the
2168 ;; article was sent in the future.
2171 " in the future"))))))
2173 (error "Unknown conversion type: %s" type)))))
2175 (defun article-date-local (&optional highlight)
2176 "Convert the current article date to the local timezone."
2177 (interactive (list t))
2178 (article-date-ut 'local highlight))
2180 (defun article-date-original (&optional highlight)
2181 "Convert the current article date to what it was originally.
2182 This is only useful if you have used some other date conversion
2183 function and want to see what the date was before converting."
2184 (interactive (list t))
2185 (article-date-ut 'original highlight))
2187 (defun article-date-lapsed (&optional highlight)
2188 "Convert the current article date to time lapsed since it was sent."
2189 (interactive (list t))
2190 (article-date-ut 'lapsed highlight))
2192 (defun article-update-date-lapsed ()
2193 "Function to be run from a timer to update the lapsed time line."
2194 (let (deactivate-mark)
2199 (set-buffer (window-buffer w))
2200 (when (eq major-mode 'gnus-article-mode)
2201 (goto-char (point-min))
2202 (when (re-search-forward "^X-Sent:" nil t)
2203 (article-date-lapsed t))))
2206 (defun gnus-start-date-timer (&optional n)
2207 "Start a timer to update the X-Sent header in the article buffers.
2208 The numerical prefix says how frequently (in seconds) the function
2213 (gnus-stop-date-timer)
2214 (setq article-lapsed-timer
2215 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2217 (defun gnus-stop-date-timer ()
2218 "Stop the X-Sent timer."
2220 (when article-lapsed-timer
2221 (nnheader-cancel-timer article-lapsed-timer)
2222 (setq article-lapsed-timer nil)))
2224 (defun article-date-user (&optional highlight)
2225 "Convert the current article date to the user-defined format.
2226 This format is defined by the `gnus-article-time-format' variable."
2227 (interactive (list t))
2228 (article-date-ut 'user highlight))
2230 (defun article-date-iso8601 (&optional highlight)
2231 "Convert the current article date to ISO8601."
2232 (interactive (list t))
2233 (article-date-ut 'iso8601 highlight))
2235 (defun article-show-all ()
2236 "Show all hidden text in the article buffer."
2239 (let ((buffer-read-only nil))
2240 (gnus-article-unhide-text (point-min) (point-max)))))
2242 (defun article-emphasize (&optional arg)
2243 "Emphasize text according to `gnus-emphasis-alist'."
2244 (interactive (gnus-article-hidden-arg))
2245 (unless (gnus-article-check-hidden-text 'emphasis arg)
2249 (with-current-buffer gnus-summary-buffer
2250 gnus-article-emphasis-alist)
2252 gnus-emphasis-alist))
2253 (buffer-read-only nil)
2254 (props (append '(article-type emphasis)
2255 gnus-hidden-properties))
2256 regexp elem beg invisible visible face)
2259 (while (setq elem (pop alist))
2261 (setq regexp (car elem)
2262 invisible (nth 1 elem)
2263 visible (nth 2 elem)
2265 (while (re-search-forward regexp nil t)
2266 (when (and (match-beginning visible) (match-beginning invisible))
2267 (push 'emphasis gnus-article-wash-types)
2268 (gnus-article-hide-text
2269 (match-beginning invisible) (match-end invisible) props)
2270 (gnus-article-unhide-text-type
2271 (match-beginning visible) (match-end visible) 'emphasis)
2272 (gnus-put-text-property-excluding-newlines
2273 (match-beginning visible) (match-end visible) 'face face)
2274 (goto-char (match-end invisible)))))))))
2276 (defun gnus-article-setup-highlight-words (&optional highlight-words)
2277 "Setup newsgroup emphasis alist."
2278 (unless gnus-article-emphasis-alist
2279 (let ((name (and gnus-newsgroup-name
2280 (gnus-group-real-name gnus-newsgroup-name))))
2281 (make-local-variable 'gnus-article-emphasis-alist)
2282 (setq gnus-article-emphasis-alist
2284 (let ((alist gnus-group-highlight-words-alist) elem highlight)
2285 (while (setq elem (pop alist))
2286 (when (and name (string-match (car elem) name))
2288 highlight (copy-sequence (cdr elem)))))
2290 (copy-sequence highlight-words)
2291 (if gnus-newsgroup-name
2292 (copy-sequence (gnus-group-find-parameter
2293 gnus-newsgroup-name 'highlight-words t)))
2294 gnus-emphasis-alist)))))
2297 (defvar gnus-summary-article-menu)
2298 (defvar gnus-summary-post-menu))
2300 ;;; Saving functions.
2302 (defun gnus-article-save (save-buffer file &optional num)
2303 "Save the currently selected article."
2304 (unless gnus-save-all-headers
2305 ;; Remove headers according to `gnus-saved-headers'.
2306 (let ((gnus-visible-headers
2307 (or gnus-saved-headers gnus-visible-headers))
2308 (gnus-article-buffer save-buffer))
2310 (set-buffer save-buffer)
2311 (article-hide-headers 1 t))))
2312 (save-window-excursion
2313 (if (not gnus-default-article-saver)
2314 (error "No default saver is defined")
2315 ;; !!! Magic! The saving functions all save
2316 ;; `gnus-save-article-buffer' (or so they think), but we
2317 ;; bind that variable to our save-buffer.
2318 (set-buffer gnus-article-buffer)
2319 (let* ((gnus-save-article-buffer save-buffer)
2322 ((not gnus-prompt-before-saving) 'default)
2323 ((eq gnus-prompt-before-saving 'always) nil)
2325 (gnus-number-of-articles-to-be-saved
2326 (when (eq gnus-prompt-before-saving t)
2328 (set-buffer gnus-article-current-summary)
2329 (funcall gnus-default-article-saver filename)))))
2331 (defun gnus-read-save-file-name (prompt &optional filename
2332 function group headers variable)
2334 (funcall function group headers (symbol-value variable)))
2339 ((eq filename 'default)
2345 (let* ((split-name (gnus-get-split-value gnus-split-methods))
2348 (if (and gnus-number-of-articles-to-be-saved
2349 (> gnus-number-of-articles-to-be-saved 1))
2350 (format "these %d articles"
2351 gnus-number-of-articles-to-be-saved)
2354 ;; Let the split methods have their say.
2356 ;; No split name was found.
2359 (concat prompt " (default "
2360 (file-name-nondirectory default-name) ") ")
2361 (file-name-directory default-name)
2363 ;; A single group name is returned.
2364 ((stringp split-name)
2366 (funcall function split-name headers
2367 (symbol-value variable)))
2369 (concat prompt " (default "
2370 (file-name-nondirectory default-name) ") ")
2371 (file-name-directory default-name)
2373 ;; A single split name was found
2374 ((= 1 (length split-name))
2375 (let* ((name (expand-file-name
2376 (car split-name) gnus-article-save-directory))
2377 (dir (cond ((file-directory-p name)
2378 (file-name-as-directory name))
2379 ((file-exists-p name) name)
2380 (t gnus-article-save-directory))))
2382 (concat prompt " (default " name ") ")
2384 ;; A list of splits was found.
2386 (setq split-name (nreverse split-name))
2388 (let ((file-name-history
2389 (nconc split-name file-name-history)))
2393 (concat prompt " (`M-p' for defaults) ")
2394 gnus-article-save-directory
2396 gnus-article-save-directory)))
2397 (car (push result file-name-history)))))))
2398 ;; Create the directory.
2399 (gnus-make-directory (file-name-directory file))
2400 ;; If we have read a directory, we append the default file name.
2401 (when (file-directory-p file)
2402 (setq file (expand-file-name (file-name-nondirectory default-name)
2403 (file-name-as-directory file))))
2404 ;; Possibly translate some characters.
2405 (nnheader-translate-file-chars file))))))
2406 (gnus-make-directory (file-name-directory result))
2407 (set variable result)))
2409 (defun gnus-article-archive-name (group)
2410 "Return the first instance of an \"Archive-name\" in the current buffer."
2411 (let ((case-fold-search t))
2412 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
2413 (nnheader-concat gnus-article-save-directory
2414 (match-string 1)))))
2416 (defun gnus-article-nndoc-name (group)
2417 "If GROUP is an nndoc group, return the name of the parent group."
2418 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
2419 (gnus-group-get-parameter group 'save-article-group)))
2421 (defun gnus-summary-save-in-rmail (&optional filename)
2422 "Append this article to Rmail file.
2423 Optional argument FILENAME specifies file name.
2424 Directory to save to is default to `gnus-article-save-directory'."
2425 (setq filename (gnus-read-save-file-name
2426 "Save %s in rmail file:" filename
2427 gnus-rmail-save-name gnus-newsgroup-name
2428 gnus-current-headers 'gnus-newsgroup-last-rmail))
2429 (gnus-eval-in-buffer-window gnus-save-article-buffer
2433 (gnus-output-to-rmail filename))))
2436 (defun gnus-summary-save-in-mail (&optional filename)
2437 "Append this article to Unix mail file.
2438 Optional argument FILENAME specifies file name.
2439 Directory to save to is default to `gnus-article-save-directory'."
2440 (setq filename (gnus-read-save-file-name
2441 "Save %s in Unix mail file:" filename
2442 gnus-mail-save-name gnus-newsgroup-name
2443 gnus-current-headers 'gnus-newsgroup-last-mail))
2444 (gnus-eval-in-buffer-window gnus-save-article-buffer
2448 (if (and (file-readable-p filename)
2449 (mail-file-babyl-p filename))
2450 (rmail-output-to-rmail-file filename t)
2451 (gnus-output-to-mail filename)))))
2454 (defun gnus-summary-save-in-file (&optional filename overwrite)
2455 "Append this article to file.
2456 Optional argument FILENAME specifies file name.
2457 Directory to save to is default to `gnus-article-save-directory'."
2458 (setq filename (gnus-read-save-file-name
2459 "Save %s in file:" filename
2460 gnus-file-save-name gnus-newsgroup-name
2461 gnus-current-headers 'gnus-newsgroup-last-file))
2462 (gnus-eval-in-buffer-window gnus-save-article-buffer
2466 (when (and overwrite
2467 (file-exists-p filename))
2468 (delete-file filename))
2469 (gnus-output-to-file filename))))
2472 (defun gnus-summary-write-to-file (&optional filename)
2473 "Write this article to a file.
2474 Optional argument FILENAME specifies file name.
2475 The directory to save in defaults to `gnus-article-save-directory'."
2476 (gnus-summary-save-in-file nil t))
2478 (defun gnus-summary-save-body-in-file (&optional filename)
2479 "Append this article body to a file.
2480 Optional argument FILENAME specifies file name.
2481 The directory to save in defaults to `gnus-article-save-directory'."
2482 (setq filename (gnus-read-save-file-name
2483 "Save %s body in file:" filename
2484 gnus-file-save-name gnus-newsgroup-name
2485 gnus-current-headers 'gnus-newsgroup-last-file))
2486 (gnus-eval-in-buffer-window gnus-save-article-buffer
2490 (when (article-goto-body)
2491 (narrow-to-region (point) (point-max)))
2492 (gnus-output-to-file filename))))
2495 (defun gnus-summary-save-in-pipe (&optional command)
2496 "Pipe this article to subprocess."
2498 (cond ((and (eq command 'default)
2499 gnus-last-shell-command)
2500 gnus-last-shell-command)
2505 "Shell command on %s: "
2506 (if (and gnus-number-of-articles-to-be-saved
2507 (> gnus-number-of-articles-to-be-saved 1))
2508 (format "these %d articles"
2509 gnus-number-of-articles-to-be-saved)
2511 gnus-last-shell-command))))
2512 (when (string-equal command "")
2513 (if gnus-last-shell-command
2514 (setq command gnus-last-shell-command)
2515 (error "A command is required")))
2516 (gnus-eval-in-buffer-window gnus-article-buffer
2519 (shell-command-on-region (point-min) (point-max) command nil)))
2520 (setq gnus-last-shell-command command))
2522 ;;; Article file names when saving.
2524 (defun gnus-capitalize-newsgroup (newsgroup)
2525 "Capitalize NEWSGROUP name."
2526 (when (not (zerop (length newsgroup)))
2527 (concat (char-to-string (upcase (aref newsgroup 0)))
2528 (substring newsgroup 1))))
2530 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2531 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2532 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
2533 Otherwise, it is like ~/News/news/group/num."
2536 (concat (if (gnus-use-long-file-name 'not-save)
2537 (gnus-capitalize-newsgroup newsgroup)
2538 (gnus-newsgroup-directory-form newsgroup))
2539 "/" (int-to-string (mail-header-number headers)))
2540 gnus-article-save-directory)))
2542 (string-equal (file-name-directory default)
2543 (file-name-directory last-file))
2544 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2546 (or last-file default))))
2548 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2549 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2550 If variable `gnus-use-long-file-name' is non-nil, it is
2551 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2554 (concat (if (gnus-use-long-file-name 'not-save)
2556 (gnus-newsgroup-directory-form newsgroup))
2557 "/" (int-to-string (mail-header-number headers)))
2558 gnus-article-save-directory)))
2560 (string-equal (file-name-directory default)
2561 (file-name-directory last-file))
2562 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2564 (or last-file default))))
2566 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2567 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2568 If variable `gnus-use-long-file-name' is non-nil, it is
2569 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2572 (if (gnus-use-long-file-name 'not-save)
2574 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup)))
2575 gnus-article-save-directory)))
2582 (setq afunc (car func)
2585 gfunc (intern (format "gnus-%s" func))))
2588 `(lambda (&optional interactive &rest args)
2589 ,(documentation afunc t)
2590 (interactive (list t))
2592 (set-buffer gnus-article-buffer)
2594 (call-interactively ',afunc)
2595 (apply ',afunc args))))))))
2596 '(article-hide-headers
2597 article-hide-boring-headers
2598 article-treat-overstrike
2599 article-fill-long-lines
2600 article-capitalize-sentences
2602 article-display-x-face
2603 article-de-quoted-unreadable
2604 article-de-base64-unreadable
2607 article-hide-list-identifiers
2609 article-strip-banner
2612 article-hide-signature
2613 article-strip-headers-in-body
2614 article-remove-trailing-blank-lines
2615 article-strip-leading-blank-lines
2616 article-strip-multiple-blank-lines
2617 article-strip-leading-space
2618 article-strip-trailing-space
2619 article-strip-blank-lines
2620 article-strip-all-blank-lines
2622 article-date-iso8601
2623 article-date-original
2625 article-decode-mime-words
2626 article-decode-charset
2627 article-decode-encoded-words
2631 article-treat-dumbquotes
2632 article-normalize-headers
2633 (article-show-all . gnus-article-show-all-headers))))
2636 ;;; Gnus article mode
2639 (put 'gnus-article-mode 'mode-class 'special)
2641 (set-keymap-parent gnus-article-mode-map widget-keymap)
2643 (gnus-define-keys gnus-article-mode-map
2644 " " gnus-article-goto-next-page
2645 "\177" gnus-article-goto-prev-page
2646 [delete] gnus-article-goto-prev-page
2647 [backspace] gnus-article-goto-prev-page
2648 "\C-c^" gnus-article-refer-article
2649 "h" gnus-article-show-summary
2650 "s" gnus-article-show-summary
2651 "\C-c\C-m" gnus-article-mail
2652 "?" gnus-article-describe-briefly
2653 "e" gnus-summary-edit-article
2654 "<" beginning-of-buffer
2656 "\C-c\C-i" gnus-info-find-node
2658 "\C-hk" gnus-article-describe-key
2659 "\C-hc" gnus-article-describe-key-briefly
2661 "\C-d" gnus-article-read-summary-keys
2662 "\M-*" gnus-article-read-summary-keys
2663 "\M-#" gnus-article-read-summary-keys
2664 "\M-^" gnus-article-read-summary-keys
2665 "\M-g" gnus-article-read-summary-keys)
2667 (substitute-key-definition
2668 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
2670 (defvar gnus-article-post-menu nil)
2672 (defun gnus-article-make-menu-bar ()
2673 (gnus-turn-off-edit-menu 'article)
2674 (unless (boundp 'gnus-article-article-menu)
2676 gnus-article-article-menu gnus-article-mode-map ""
2678 ["Scroll forwards" gnus-article-goto-next-page t]
2679 ["Scroll backwards" gnus-article-goto-prev-page t]
2680 ["Show summary" gnus-article-show-summary t]
2681 ["Fetch Message-ID at point" gnus-article-refer-article t]
2682 ["Mail to address at point" gnus-article-mail t]
2683 ["Send a bug report" gnus-bug t]))
2686 gnus-article-treatment-menu gnus-article-mode-map ""
2687 ;; Fixme: this should use :active (and maybe :visible).
2689 ["Hide headers" gnus-article-hide-headers t]
2690 ["Hide signature" gnus-article-hide-signature t]
2691 ["Hide citation" gnus-article-hide-citation t]
2692 ["Treat overstrike" gnus-article-treat-overstrike t]
2693 ["Remove carriage return" gnus-article-remove-cr t]
2694 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
2695 ["Remove base64" gnus-article-de-base64-unreadable t]
2696 ["Treat html" gnus-article-wash-html t]
2697 ["Decode HZ" gnus-article-decode-HZ t]))
2699 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
2701 (when (boundp 'gnus-summary-post-menu)
2703 ((not (keymapp gnus-summary-post-menu))
2704 (setq gnus-article-post-menu gnus-summary-post-menu))
2705 ((not gnus-article-post-menu)
2706 ;; Don't share post menu.
2707 (setq gnus-article-post-menu
2708 (copy-keymap gnus-summary-post-menu))))
2709 (define-key gnus-article-mode-map [menu-bar post]
2710 (cons "Post" gnus-article-post-menu)))
2712 (gnus-run-hooks 'gnus-article-menu-hook)))
2714 ;; Fixme: do something for the Emacs tool bar in Article mode a la
2717 (defun gnus-article-mode ()
2718 "Major mode for displaying an article.
2720 All normal editing commands are switched off.
2722 The following commands are available in addition to all summary mode
2724 \\<gnus-article-mode-map>
2725 \\[gnus-article-next-page]\t Scroll the article one page forwards
2726 \\[gnus-article-prev-page]\t Scroll the article one page backwards
2727 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
2728 \\[gnus-article-show-summary]\t Display the summary buffer
2729 \\[gnus-article-mail]\t Send a reply to the address near point
2730 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
2731 \\[gnus-info-find-node]\t Go to the Gnus info node"
2733 (gnus-simplify-mode-line)
2734 (setq mode-name "Article")
2735 (setq major-mode 'gnus-article-mode)
2736 (make-local-variable 'minor-mode-alist)
2737 (use-local-map gnus-article-mode-map)
2738 (when (gnus-visual-p 'article-menu 'menu)
2739 (gnus-article-make-menu-bar))
2740 (gnus-update-format-specifications nil 'article-mode)
2741 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
2742 (make-local-variable 'gnus-page-broken)
2743 (make-local-variable 'gnus-button-marker-list)
2744 (make-local-variable 'gnus-article-current-summary)
2745 (make-local-variable 'gnus-article-mime-handles)
2746 (make-local-variable 'gnus-article-decoded-p)
2747 (make-local-variable 'gnus-article-mime-handle-alist)
2748 (make-local-variable 'gnus-article-wash-types)
2749 (gnus-set-default-directory)
2750 (buffer-disable-undo)
2751 (setq buffer-read-only t)
2752 (set-syntax-table gnus-article-mode-syntax-table)
2753 (mm-enable-multibyte)
2754 (gnus-run-hooks 'gnus-article-mode-hook))
2756 (defun gnus-article-setup-buffer ()
2757 "Initialize the article buffer."
2758 (let* ((name (if gnus-single-article-buffer "*Article*"
2759 (concat "*Article " gnus-newsgroup-name "*")))
2761 (progn (string-match "\\*Article" name)
2762 (concat " *Original Article"
2763 (substring name (match-end 0))))))
2764 (setq gnus-article-buffer name)
2765 (setq gnus-original-article-buffer original)
2766 (setq gnus-article-mime-handle-alist nil)
2767 ;; This might be a variable local to the summary buffer.
2768 (unless gnus-single-article-buffer
2770 (set-buffer gnus-summary-buffer)
2771 (setq gnus-article-buffer name)
2772 (setq gnus-original-article-buffer original)
2773 (gnus-set-global-variables)))
2774 (gnus-article-setup-highlight-words)
2775 ;; Init original article buffer.
2777 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
2778 (mm-enable-multibyte)
2779 (setq major-mode 'gnus-original-article-mode)
2780 (make-local-variable 'gnus-original-article))
2781 (if (get-buffer name)
2784 (when gnus-article-mime-handles
2785 (mm-destroy-parts gnus-article-mime-handles)
2786 (setq gnus-article-mime-handles nil))
2787 ;; Set it to nil in article-buffer!
2788 (setq gnus-article-mime-handle-alist nil)
2789 (buffer-disable-undo)
2790 (setq buffer-read-only t)
2791 (unless (eq major-mode 'gnus-article-mode)
2792 (gnus-article-mode))
2795 (set-buffer (gnus-get-buffer-create name))
2797 (make-local-variable 'gnus-summary-buffer)
2798 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2799 (current-buffer)))))
2801 ;; Set article window start at LINE, where LINE is the number of lines
2802 ;; from the head of the article.
2803 (defun gnus-article-set-window-start (&optional line)
2805 (get-buffer-window gnus-article-buffer t)
2807 (set-buffer gnus-article-buffer)
2808 (goto-char (point-min))
2811 (gnus-message 6 "Moved to bookmark")
2812 (search-forward "\n\n" nil t)
2816 (defun gnus-article-prepare (article &optional all-headers header)
2817 "Prepare ARTICLE in article mode buffer.
2818 ARTICLE should either be an article number or a Message-ID.
2819 If ARTICLE is an id, HEADER should be the article headers.
2820 If ALL-HEADERS is non-nil, no headers are hidden."
2822 ;; Make sure we start in a summary buffer.
2823 (unless (eq major-mode 'gnus-summary-mode)
2824 (set-buffer gnus-summary-buffer))
2825 (setq gnus-summary-buffer (current-buffer))
2826 (let* ((gnus-article (if header (mail-header-number header) article))
2827 (summary-buffer (current-buffer))
2828 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
2829 (group gnus-newsgroup-name)
2832 (gnus-article-setup-buffer)
2833 (set-buffer gnus-article-buffer)
2834 ;; Deactivate active regions.
2835 (when (and (boundp 'transient-mark-mode)
2836 transient-mark-mode)
2837 (setq mark-active nil))
2838 (if (not (setq result (let ((buffer-read-only nil))
2839 (gnus-request-article-this-buffer
2841 ;; There is no such article.
2843 (when (and (numberp article)
2844 (not (memq article gnus-newsgroup-sparse)))
2845 (setq gnus-article-current
2846 (cons gnus-newsgroup-name article))
2847 (set-buffer gnus-summary-buffer)
2848 (setq gnus-current-article article)
2849 (if (eq (gnus-article-mark article) gnus-undownloaded-mark)
2851 (gnus-summary-set-agent-mark article)
2852 (message "Message marked for downloading"))
2853 (gnus-summary-mark-article article gnus-canceled-mark)
2854 (unless (memq article gnus-newsgroup-sparse)
2855 (gnus-error 1 "No such article (may have expired or been canceled)")))))
2856 (if (or (eq result 'pseudo)
2857 (eq result 'nneething))
2860 (set-buffer summary-buffer)
2861 (push article gnus-newsgroup-history)
2862 (setq gnus-last-article gnus-current-article
2863 gnus-current-article 0
2864 gnus-current-headers nil
2865 gnus-article-current nil)
2866 (if (eq result 'nneething)
2867 (gnus-configure-windows 'summary)
2868 (gnus-configure-windows 'article))
2869 (gnus-set-global-variables))
2870 (let ((gnus-article-mime-handle-alist-1
2871 gnus-article-mime-handle-alist))
2872 (gnus-set-mode-line 'article)))
2873 ;; The result from the `request' was an actual article -
2874 ;; or at least some text that is now displayed in the
2876 (when (and (numberp article)
2877 (not (eq article gnus-current-article)))
2878 ;; Seems like a new article has been selected.
2879 ;; `gnus-current-article' must be an article number.
2881 (set-buffer summary-buffer)
2882 (push article gnus-newsgroup-history)
2883 (setq gnus-last-article gnus-current-article
2884 gnus-current-article article
2885 gnus-current-headers
2886 (gnus-summary-article-header gnus-current-article)
2887 gnus-article-current
2888 (cons gnus-newsgroup-name gnus-current-article))
2889 (unless (vectorp gnus-current-headers)
2890 (setq gnus-current-headers nil))
2891 (gnus-summary-goto-subject gnus-current-article)
2892 (when (gnus-summary-show-thread)
2893 ;; If the summary buffer really was folded, the
2894 ;; previous goto may not actually have gone to
2895 ;; the right article, but the thread root instead.
2897 (gnus-summary-goto-subject gnus-current-article))
2898 (gnus-run-hooks 'gnus-mark-article-hook)
2899 (gnus-set-mode-line 'summary)
2900 (when (gnus-visual-p 'article-highlight 'highlight)
2901 (gnus-run-hooks 'gnus-visual-mark-article-hook))
2902 ;; Set the global newsgroup variables here.
2903 (gnus-set-global-variables)
2904 (setq gnus-have-all-headers
2905 (or all-headers gnus-show-all-headers))))
2907 (gnus-configure-windows 'article))
2908 (when (or (numberp article)
2910 (gnus-article-prepare-display)
2912 (goto-char (point-min))
2913 (setq gnus-page-broken
2914 (when gnus-break-pages
2915 (gnus-narrow-to-page)
2917 (let ((gnus-article-mime-handle-alist-1
2918 gnus-article-mime-handle-alist))
2919 (gnus-set-mode-line 'article))
2921 (set-window-point (get-buffer-window (current-buffer)) (point))
2922 (gnus-configure-windows 'article)
2926 (defun gnus-article-prepare-display ()
2927 "Make the current buffer look like a nice article."
2928 ;; Hooks for getting information from the article.
2929 ;; This hook must be called before being narrowed.
2930 (let ((gnus-article-buffer (current-buffer))
2932 (unless (eq major-mode 'gnus-article-mode)
2933 (gnus-article-mode))
2934 (setq buffer-read-only nil
2935 gnus-article-wash-types nil)
2936 (gnus-run-hooks 'gnus-tmp-internal-hook)
2937 (when gnus-display-mime-function
2938 (funcall gnus-display-mime-function))
2939 (gnus-run-hooks 'gnus-article-prepare-hook)))
2942 ;;; Gnus MIME viewing functions
2945 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
2946 "The following specs can be used:
2948 %T MIME type, along with additional info
2949 %n The `name' parameter
2950 %d The description, if any
2951 %l The length of the encoded part
2952 %p The part identifier number
2953 %e Dots if the part isn't displayed")
2955 (defvar gnus-mime-button-line-format-alist
2956 '((?t gnus-tmp-type ?s)
2957 (?T gnus-tmp-type-long ?s)
2958 (?n gnus-tmp-name ?s)
2959 (?d gnus-tmp-description ?s)
2961 (?l gnus-tmp-length ?d)
2962 (?e gnus-tmp-dots ?s)))
2964 (defvar gnus-mime-button-commands
2965 '((gnus-article-press-button "\r" "Toggle Display")
2966 (gnus-mime-view-part "v" "View Interactively...")
2967 (gnus-mime-view-part-as-type "t" "View As Type...")
2968 (gnus-mime-save-part "o" "Save...")
2969 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
2970 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
2971 (gnus-mime-internalize-part "E" "View Internally")
2972 (gnus-mime-externalize-part "e" "View Externally")
2973 (gnus-mime-pipe-part "|" "Pipe To Command...")
2974 (gnus-mime-action-on-part "." "Take action on the part")))
2976 (defun gnus-article-mime-part-status ()
2977 (if gnus-article-mime-handle-alist-1
2978 (format " (%d parts)" (length gnus-article-mime-handle-alist-1))
2981 (defvar gnus-mime-button-map
2982 (let ((map (make-sparse-keymap)))
2983 ;; Not for Emacs 21: fixme better.
2984 ;; (set-keymap-parent map gnus-article-mode-map)
2985 (define-key map gnus-mouse-2 'gnus-article-push-button)
2986 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
2987 (dolist (c gnus-mime-button-commands)
2988 (define-key map (cadr c) (car c)))
2991 (defun gnus-mime-button-menu (event)
2992 "Construct a context-sensitive menu of MIME commands."
2995 (mouse-set-point event)
2996 (gnus-article-check-buffer)
2997 (let ((response (x-popup-menu
2999 ("" ,@(mapcar (lambda (c)
3000 (cons (caddr c) (car c)))
3001 gnus-mime-button-commands))))))
3003 (call-interactively response)))))
3005 (defun gnus-mime-view-all-parts (&optional handles)
3006 "View all the MIME parts."
3008 (save-current-buffer
3009 (set-buffer gnus-article-buffer)
3010 (let ((handles (or handles gnus-article-mime-handles))
3011 (mail-parse-charset gnus-newsgroup-charset)
3012 (mail-parse-ignored-charsets
3013 (save-excursion (set-buffer gnus-summary-buffer)
3014 gnus-newsgroup-ignored-charsets)))
3015 (if (stringp (car handles))
3016 (gnus-mime-view-all-parts (cdr handles))
3017 (mapcar 'mm-display-part handles)))))
3019 (defun gnus-mime-save-part ()
3020 "Save the MIME part under point."
3022 (gnus-article-check-buffer)
3023 (let ((data (get-text-property (point) 'gnus-data)))
3024 (mm-save-part data)))
3026 (defun gnus-mime-pipe-part ()
3027 "Pipe the MIME part under point to a process."
3029 (gnus-article-check-buffer)
3030 (let ((data (get-text-property (point) 'gnus-data)))
3031 (mm-pipe-part data)))
3033 (defun gnus-mime-view-part ()
3034 "Interactively choose a viewing method for the MIME part under point."
3036 (gnus-article-check-buffer)
3037 (let ((data (get-text-property (point) 'gnus-data)))
3038 (push (setq data (copy-sequence data)) gnus-article-mime-handles)
3039 (mm-interactively-view-part data)))
3041 (defun gnus-mime-view-part-as-type-internal ()
3042 (gnus-article-check-buffer)
3043 (let* ((name (mail-content-type-get
3044 (mm-handle-type (get-text-property (point) 'gnus-data))
3046 (def-type (and name (mm-default-file-encoding name))))
3047 (and def-type (cons def-type 0))))
3049 (defun gnus-mime-view-part-as-type (mime-type)
3050 "Choose a MIME media type, and view the part as such."
3052 (list (completing-read
3053 "View as MIME type: "
3054 (mapcar #'list (mailcap-mime-types))
3056 (gnus-mime-view-part-as-type-internal))))
3057 (gnus-article-check-buffer)
3058 (let ((handle (get-text-property (point) 'gnus-data)))
3059 (gnus-mm-display-part
3060 (mm-make-handle (mm-handle-buffer handle)
3061 (cons mime-type (cdr (mm-handle-type handle)))
3062 (mm-handle-encoding handle)
3063 (mm-handle-undisplayer handle)
3064 (mm-handle-disposition handle)
3065 (mm-handle-description handle)
3066 (mm-handle-cache handle)
3067 (mm-handle-id handle)))))
3069 (defun gnus-mime-copy-part (&optional handle)
3070 "Put the MIME part under point into a new buffer."
3072 (gnus-article-check-buffer)
3073 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3074 (contents (mm-get-part handle))
3075 (base (file-name-nondirectory
3077 (mail-content-type-get (mm-handle-type handle) 'name)
3078 (mail-content-type-get (mm-handle-type handle)
3081 (buffer (generate-new-buffer base)))
3082 (switch-to-buffer buffer)
3084 ;; We do it this way to make `normal-mode' set the appropriate mode.
3087 (setq buffer-file-name (expand-file-name base))
3089 (setq buffer-file-name nil))
3090 (goto-char (point-min))))
3092 (defun gnus-mime-inline-part (&optional handle arg)
3093 "Insert the MIME part under point into the current buffer."
3094 (interactive (list nil current-prefix-arg))
3095 (gnus-article-check-buffer)
3096 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3100 (if (mm-handle-undisplayer handle)
3101 (mm-remove-part handle)
3102 (setq contents (mm-get-part handle))
3105 (setq charset (or (mail-content-type-get
3106 (mm-handle-type handle) 'charset)
3107 gnus-newsgroup-charset)))
3111 gnus-summary-show-article-charset-alist))
3112 (read-coding-system "Charset: ")))))
3114 (mm-insert-inline handle
3116 (setq charset (mm-charset-to-coding-system
3118 (not (eq charset 'ascii)))
3119 (mm-decode-coding-string contents charset)
3123 (defun gnus-mime-externalize-part (&optional handle)
3124 "View the MIME part under point with an external viewer."
3126 (gnus-article-check-buffer)
3127 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3128 (mm-user-display-methods nil)
3129 (mm-inlined-types nil)
3130 (mail-parse-charset gnus-newsgroup-charset)
3131 (mail-parse-ignored-charsets
3132 (save-excursion (set-buffer gnus-summary-buffer)
3133 gnus-newsgroup-ignored-charsets)))
3134 (if (mm-handle-undisplayer handle)
3135 (mm-remove-part handle)
3136 (mm-display-part handle))))
3138 (defun gnus-mime-internalize-part (&optional handle)
3139 "View the MIME part under point with an internal viewer.
3140 In no internal viewer is available, use an external viewer."
3142 (gnus-article-check-buffer)
3143 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3144 (mm-inlined-types '(".*"))
3145 (mm-inline-large-images t)
3146 (mail-parse-charset gnus-newsgroup-charset)
3147 (mail-parse-ignored-charsets
3148 (save-excursion (set-buffer gnus-summary-buffer)
3149 gnus-newsgroup-ignored-charsets)))
3150 (if (mm-handle-undisplayer handle)
3151 (mm-remove-part handle)
3152 (mm-display-part handle))))
3154 (defun gnus-mime-action-on-part (&optional action)
3155 "Do something with the MIME attachment at \(point\)."
3157 (list (completing-read "Action: " gnus-mime-action-alist)))
3158 (gnus-article-check-buffer)
3159 (let ((action-pair (assoc action gnus-mime-action-alist)))
3161 (funcall (cdr action-pair)))))
3164 (defun gnus-article-part-wrapper (n function)
3165 (save-current-buffer
3166 (set-buffer gnus-article-buffer)
3167 (when (> n (length gnus-article-mime-handle-alist))
3168 (error "No such part"))
3169 (gnus-article-goto-part n)
3170 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
3171 (funcall function handle))))
3173 (defun gnus-article-pipe-part (n)
3174 "Pipe MIME part N, which is the numerical prefix."
3176 (gnus-article-part-wrapper n 'mm-pipe-part))
3178 (defun gnus-article-save-part (n)
3179 "Save MIME part N, which is the numerical prefix."
3181 (gnus-article-part-wrapper n 'mm-save-part))
3183 (defun gnus-article-interactively-view-part (n)
3184 "View MIME part N interactively, which is the numerical prefix."
3186 (gnus-article-part-wrapper n 'mm-interactively-view-part))
3188 (defun gnus-article-copy-part (n)
3189 "Copy MIME part N, which is the numerical prefix."
3191 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
3193 (defun gnus-article-externalize-part (n)
3194 "View MIME part N externally, which is the numerical prefix."
3196 (gnus-article-part-wrapper n 'gnus-mime-externalize-part))
3198 (defun gnus-article-inline-part (n)
3199 "Inline MIME part N, which is the numerical prefix."
3201 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
3203 (defun gnus-article-mime-match-handle-first (condition)
3205 (let ((alist gnus-article-mime-handle-alist) ihandle n)
3206 (while (setq ihandle (pop alist))
3208 ((functionp condition)
3209 (funcall condition (cdr ihandle)))
3210 ((eq condition 'undisplayed)
3211 (not (or (mm-handle-undisplayer (cdr ihandle))
3212 (equal (mm-handle-media-type (cdr ihandle))
3213 "multipart/alternative"))))
3214 ((eq condition 'undisplayed-alternative)
3215 (not (mm-handle-undisplayer (cdr ihandle))))
3217 (gnus-article-goto-part (car ihandle))
3218 (or (not n) (< (car ihandle) n)))
3219 (setq n (car ihandle))))
3223 (defun gnus-article-view-part (&optional n)
3224 "View MIME part N, which is the numerical prefix."
3226 (save-current-buffer
3227 (set-buffer gnus-article-buffer)
3228 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
3229 gnus-article-mime-match-handle-function)))
3230 (when (> n (length gnus-article-mime-handle-alist))
3231 (error "No such part"))
3232 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
3233 (when (gnus-article-goto-part n)
3234 (if (equal (car handle) "multipart/alternative")
3235 (gnus-article-press-button)
3236 (when (eq (gnus-mm-display-part handle) 'internal)
3237 (gnus-set-window-start)))))))
3239 (defsubst gnus-article-mime-total-parts ()
3240 (if (bufferp (car gnus-article-mime-handles))
3242 (1- (length gnus-article-mime-handles))))
3244 (defun gnus-mm-display-part (handle)
3245 "Display HANDLE and fix MIME button."
3246 (let ((id (get-text-property (point) 'gnus-part))
3251 (let ((window (selected-window))
3252 (mail-parse-charset gnus-newsgroup-charset)
3253 (mail-parse-ignored-charsets
3254 (save-excursion (set-buffer gnus-summary-buffer)
3255 gnus-newsgroup-ignored-charsets)))
3258 (let ((win (get-buffer-window (current-buffer) t))
3261 (select-window win))
3264 (if (mm-handle-displayed-p handle)
3265 ;; This will remove the part.
3266 (mm-display-part handle)
3268 (narrow-to-region (point) (1+ (point)))
3269 (mm-display-part handle)
3270 ;; We narrow to the part itself and
3271 ;; then call the treatment functions.
3272 (goto-char (point-min))
3274 (narrow-to-region (point) (point-max))
3277 (gnus-article-mime-total-parts)
3278 (mm-handle-media-type handle)))))
3279 (select-window window))))
3281 (delete-region (gnus-point-at-bol) (progn (forward-line 1) (point)))
3282 (gnus-insert-mime-button
3283 handle id (list (mm-handle-displayed-p handle)))
3284 (goto-char point))))
3286 (defun gnus-article-goto-part (n)
3287 "Go to MIME part N."
3288 (let ((point (text-property-any (point-min) (point-max) 'gnus-part n)))
3290 (goto-char point))))
3292 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
3293 (let ((gnus-tmp-name
3294 (or (mail-content-type-get (mm-handle-type handle)
3296 (mail-content-type-get (mm-handle-disposition handle)
3299 (gnus-tmp-type (mm-handle-media-type handle))
3300 (gnus-tmp-description
3301 (mail-decode-encoded-word-string (or (mm-handle-description handle)
3304 (if (if displayed (car displayed)
3305 (mm-handle-displayed-p handle))
3307 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
3309 gnus-tmp-type-long b e)
3310 (when (string-match ".*/" gnus-tmp-name)
3311 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
3312 (setq gnus-tmp-type-long (concat gnus-tmp-type
3313 (and (not (equal gnus-tmp-name ""))
3314 (concat "; " gnus-tmp-name))))
3315 (or (equal gnus-tmp-description "")
3316 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
3321 gnus-mime-button-line-format gnus-mime-button-line-format-alist
3322 `(keymap ,gnus-mime-button-map
3323 ;; Not for Emacs 21: fixme better.
3324 ;; local-map ,gnus-mime-button-map
3325 gnus-callback gnus-mm-display-part
3326 gnus-part ,gnus-tmp-id
3327 article-type annotation
3330 (widget-convert-button
3333 :action 'gnus-widget-press-button
3334 :button-keymap gnus-mime-button-map
3336 (lambda (widget/window &optional overlay pos)
3337 ;; Needed to properly clear the message due to a bug in
3338 ;; wid-edit (XEmacs only).
3339 (if (boundp 'help-echo-owns-message)
3340 (setq help-echo-owns-message t))
3342 "%S: %s the MIME part; %S: more options"
3343 (aref gnus-mouse-2 0)
3344 ;; XEmacs will get a single widget arg; Emacs 21 will get
3345 ;; window, overlay, position.
3346 (if (mm-handle-displayed-p
3348 (with-current-buffer (gnus-overlay-buffer overlay)
3349 (widget-get (widget-at (gnus-overlay-start overlay))
3351 (widget-get widget/window :mime-handle)))
3353 (aref gnus-down-mouse-3 0))))))
3355 (defun gnus-widget-press-button (elems el)
3356 (goto-char (widget-get elems :from))
3357 (gnus-article-press-button))
3359 (defvar gnus-displaying-mime nil)
3361 (defun gnus-display-mime (&optional ihandles)
3362 "Display the MIME parts."
3364 (save-selected-window
3365 (let ((window (get-buffer-window gnus-article-buffer))
3368 (select-window window)
3369 ;; We have to do this since selecting the window
3370 ;; may change the point. So we set the window point.
3371 (set-window-point window point)))
3372 (let* ((handles (or ihandles (mm-dissect-buffer) (mm-uu-dissect)))
3373 buffer-read-only handle name type b e display)
3374 (when (and (not ihandles)
3375 (not gnus-displaying-mime))
3376 ;; Top-level call; we clean up.
3377 (when gnus-article-mime-handles
3378 (mm-destroy-parts gnus-article-mime-handles)
3379 (setq gnus-article-mime-handle-alist nil));; A trick.
3380 (setq gnus-article-mime-handles handles)
3381 ;; We allow users to glean info from the handles.
3382 (when gnus-article-mime-part-function
3383 (gnus-mime-part-function handles)))
3385 (or (not (stringp (car handles)))
3388 (when (and (not ihandles)
3389 (not gnus-displaying-mime))
3390 ;; Clean up for mime parts.
3392 (delete-region (point) (point-max)))
3393 (let ((gnus-displaying-mime t))
3394 (gnus-mime-display-part handles)))
3397 (narrow-to-region (point) (point-max))
3398 (gnus-treat-article nil 1 1)
3401 ;; Highlight the headers.
3405 (narrow-to-region (point-min) (point))
3406 (gnus-treat-article 'head))))))))
3408 (defvar gnus-mime-display-multipart-as-mixed nil)
3410 (defun gnus-mime-display-part (handle)
3413 ((not (stringp (car handle)))
3414 (gnus-mime-display-single handle))
3415 ;; User-defined multipart
3416 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
3417 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
3419 ;; multipart/alternative
3420 ((and (equal (car handle) "multipart/alternative")
3421 (not gnus-mime-display-multipart-as-mixed))
3422 (let ((id (1+ (length gnus-article-mime-handle-alist))))
3423 (push (cons id handle) gnus-article-mime-handle-alist)
3424 (gnus-mime-display-alternative (cdr handle) nil nil id)))
3425 ;; multipart/related
3426 ((and (equal (car handle) "multipart/related")
3427 (not gnus-mime-display-multipart-as-mixed))
3428 ;;;!!!We should find the start part, but we just default
3429 ;;;!!!to the first part.
3430 (gnus-mime-display-part (cadr handle)))
3431 ;; Other multiparts are handled like multipart/mixed.
3433 (gnus-mime-display-mixed (cdr handle)))))
3435 (defun gnus-mime-part-function (handles)
3436 (if (stringp (car handles))
3437 (mapcar 'gnus-mime-part-function (cdr handles))
3438 (funcall gnus-article-mime-part-function handles)))
3440 (defun gnus-mime-display-mixed (handles)
3441 (mapcar 'gnus-mime-display-part handles))
3443 (defun gnus-mime-display-single (handle)
3444 (let ((type (mm-handle-media-type handle))
3445 (ignored gnus-ignored-mime-types)
3452 (when (string-match (pop ignored) type)
3453 (throw 'ignored nil)))
3454 (if (and (setq not-attachment
3455 (and (not (mm-inline-override-p handle))
3456 (or (not (mm-handle-disposition handle))
3457 (equal (car (mm-handle-disposition handle))
3459 (mm-attachment-override-p handle))))
3460 (mm-automatic-display-p handle)
3461 (or (mm-inlined-p handle)
3462 (mm-automatic-external-display-p type)))
3464 (when (equal (mm-handle-media-supertype handle) "text")
3466 (let ((id (1+ (length gnus-article-mime-handle-alist)))
3468 (push (cons id handle) gnus-article-mime-handle-alist)
3469 (when (or (not display)
3470 (not (gnus-unbuttonized-mime-type-p type)))
3471 ;(gnus-article-insert-newline)
3472 (gnus-insert-mime-button
3473 handle id (list (or display (and not-attachment text))))
3474 (gnus-article-insert-newline)
3475 ;(gnus-article-insert-newline)
3483 (let ((mail-parse-charset gnus-newsgroup-charset)
3484 (mail-parse-ignored-charsets
3485 (save-excursion (condition-case ()
3486 (set-buffer gnus-summary-buffer)
3488 gnus-newsgroup-ignored-charsets)))
3489 (mm-display-part handle t))
3490 (goto-char (point-max)))
3491 ((and text not-attachment)
3495 (gnus-article-insert-newline)
3496 (mm-insert-inline handle (mm-get-part handle))
3497 (goto-char (point-max))))
3501 (narrow-to-region beg (point))
3504 (gnus-article-mime-total-parts)
3505 (mm-handle-media-type handle)))))))))
3507 (defun gnus-unbuttonized-mime-type-p (type)
3508 "Say whether TYPE is to be unbuttonized."
3509 (unless gnus-inhibit-mime-unbuttonizing
3511 (let ((types gnus-unbuttonized-mime-types))
3513 (when (string-match (pop types) type)
3514 (throw 'found t)))))))
3516 (defun gnus-article-insert-newline ()
3517 "Insert a newline, but mark it as undeletable."
3518 (gnus-put-text-property
3519 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
3521 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
3522 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
3525 handle buffer-read-only from props begend not-pref)
3526 (save-window-excursion
3529 (narrow-to-region (car ibegend)
3532 (goto-char (car ibegend))
3535 (delete-region (point-min) (point-max))
3536 (mm-remove-parts handles))
3537 (setq begend (list (point-marker)))
3539 (unless (setq not-pref (cadr (member preferred ihandles)))
3540 (setq not-pref (car ihandles)))
3542 (not (gnus-unbuttonized-mime-type-p
3543 "multipart/alternative")))
3544 (gnus-add-text-properties
3547 (insert (format "%d. " id))
3551 (unless ,(not ibegend)
3552 (setq gnus-article-mime-handle-alist
3553 ',gnus-article-mime-handle-alist))
3554 (gnus-mime-display-alternative
3555 ',ihandles ',not-pref ',begend ,id))
3556 ;; Not for Emacs 21: fixme better.
3557 ;; local-map ,gnus-mime-button-map
3558 ,gnus-mouse-face-prop ,gnus-article-mouse-face
3559 face ,gnus-article-button-face
3560 keymap ,gnus-mime-button-map
3563 (widget-convert-button 'link from (point)
3564 :action 'gnus-widget-press-button
3565 :button-keymap gnus-widget-button-keymap)
3567 (while (setq handle (pop handles))
3568 (gnus-add-text-properties
3571 (insert (format "(%c) %-18s"
3572 (if (equal handle preferred) ?* ? )
3573 (mm-handle-media-type handle)))
3577 (unless ,(not ibegend)
3578 (setq gnus-article-mime-handle-alist
3579 ',gnus-article-mime-handle-alist))
3580 (gnus-mime-display-alternative
3581 ',ihandles ',handle ',begend ,id))
3582 ;; Not for Emacs 21: fixme better.
3583 ;; local-map ,gnus-mime-button-map
3584 ,gnus-mouse-face-prop ,gnus-article-mouse-face
3585 face ,gnus-article-button-face
3586 keymap ,gnus-mime-button-map
3589 (widget-convert-button 'link from (point)
3590 :action 'gnus-widget-press-button
3591 :button-keymap gnus-widget-button-keymap)
3595 (if (stringp (car preferred))
3596 (gnus-display-mime preferred)
3597 (let ((mail-parse-charset gnus-newsgroup-charset)
3598 (mail-parse-ignored-charsets
3599 (save-excursion (set-buffer gnus-summary-buffer)
3600 gnus-newsgroup-ignored-charsets)))
3601 (mm-display-part preferred)
3605 (narrow-to-region (car begend) (point-max))
3607 nil (length gnus-article-mime-handle-alist)
3608 (gnus-article-mime-total-parts)
3609 (mm-handle-media-type handle))))))
3610 (goto-char (point-max))
3611 (setcdr begend (point-marker)))))
3613 (goto-char point))))
3615 (defun gnus-article-wash-status ()
3616 "Return a string which display status of article washing."
3618 (set-buffer gnus-article-buffer)
3619 (let ((cite (memq 'cite gnus-article-wash-types))
3620 (headers (memq 'headers gnus-article-wash-types))
3621 (boring (memq 'boring-headers gnus-article-wash-types))
3622 (pgp (memq 'pgp gnus-article-wash-types))
3623 (pem (memq 'pem gnus-article-wash-types))
3624 (signature (memq 'signature gnus-article-wash-types))
3625 (overstrike (memq 'overstrike gnus-article-wash-types))
3626 (emphasis (memq 'emphasis gnus-article-wash-types)))
3627 (format "%c%c%c%c%c%c"
3629 (if (or headers boring) ?h ? )
3630 (if (or pgp pem) ?p ? )
3631 (if signature ?s ? )
3632 (if overstrike ?o ? )
3633 (if emphasis ?e ? )))))
3635 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
3637 (defun gnus-article-maybe-hide-headers ()
3638 "Hide unwanted headers if `gnus-have-all-headers' is nil.
3639 Provided for backwards compatibility."
3640 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
3641 (not (save-excursion (set-buffer gnus-summary-buffer)
3642 gnus-have-all-headers)))
3643 (not gnus-inhibit-hiding))
3644 (gnus-article-hide-headers)))
3648 (defun gnus-output-to-file (file-name)
3649 "Append the current article to a file named FILE-NAME."
3650 (let ((artbuf (current-buffer)))
3652 (insert-buffer-substring artbuf)
3653 ;; Append newline at end of the buffer as separator, and then
3655 (goto-char (point-max))
3657 (let ((file-name-coding-system nnmail-pathname-coding-system))
3658 (mm-append-to-file (point-min) (point-max) file-name))
3661 (defun gnus-narrow-to-page (&optional arg)
3662 "Narrow the article buffer to a page.
3663 If given a numerical ARG, move forward ARG pages."
3665 (setq arg (if arg (prefix-numeric-value arg) 0))
3667 (set-buffer gnus-article-buffer)
3668 (goto-char (point-min))
3670 ;; Remove any old next/prev buttons.
3671 (when (gnus-visual-p 'page-marker)
3672 (let ((buffer-read-only nil))
3673 (gnus-remove-text-with-property 'gnus-prev)
3674 (gnus-remove-text-with-property 'gnus-next)))
3677 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
3679 (re-search-forward page-delimiter nil 'move arg)))
3680 (goto-char (match-end 0)))
3683 (if (re-search-forward page-delimiter nil 'move)
3686 (when (and (gnus-visual-p 'page-marker)
3687 (not (= (point-min) 1)))
3689 (goto-char (point-min))
3690 (gnus-insert-prev-page-button)))
3691 (when (and (gnus-visual-p 'page-marker)
3692 (< (+ (point-max) 2) (buffer-size)))
3694 (goto-char (point-max))
3695 (gnus-insert-next-page-button)))))
3697 ;; Article mode commands
3699 (defun gnus-article-goto-next-page ()
3700 "Show the next page of the article."
3702 (when (gnus-article-next-page)
3703 (goto-char (point-min))
3704 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
3706 (defun gnus-article-goto-prev-page ()
3707 "Show the next page of the article."
3709 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
3710 (gnus-article-prev-page nil)))
3712 (defun gnus-article-next-page (&optional lines)
3713 "Show the next page of the current article.
3714 If end of article, return non-nil. Otherwise return nil.
3715 Argument LINES specifies lines to be scrolled up."
3717 (move-to-window-line -1)
3720 (and (pos-visible-in-window-p) ;Not continuation line.
3722 ;; Nothing in this page.
3723 (if (or (not gnus-page-broken)
3726 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
3728 (gnus-narrow-to-page 1) ;Go to next page.
3730 ;; More in this page.
3731 (let ((scroll-in-place nil))
3735 ;; Long lines may cause an end-of-buffer error.
3736 (goto-char (point-max)))))
3737 (move-to-window-line 0)
3740 (defun gnus-article-prev-page (&optional lines)
3741 "Show previous page of current article.
3742 Argument LINES specifies lines to be scrolled down."
3744 (move-to-window-line 0)
3745 (if (and gnus-page-broken
3747 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
3749 (gnus-narrow-to-page -1) ;Go to previous page.
3750 (goto-char (point-max))
3752 (let ((scroll-in-place nil))
3756 (beginning-of-buffer
3757 (goto-char (point-min))))
3758 (move-to-window-line 0)))))
3760 (defun gnus-article-refer-article ()
3761 "Read article specified by message-id around point."
3763 (let ((point (point)))
3764 (search-forward ">" nil t) ;Move point to end of "<....>".
3765 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
3766 (let ((message-id (match-string 1)))
3768 (set-buffer gnus-summary-buffer)
3769 (gnus-summary-refer-article message-id))
3771 (error "No references around point"))))
3773 (defun gnus-article-show-summary ()
3774 "Reconfigure windows to show summary buffer."
3776 (if (not (gnus-buffer-live-p gnus-summary-buffer))
3777 (error "There is no summary buffer for this article buffer")
3778 (gnus-article-set-globals)
3779 (gnus-configure-windows 'article)
3780 (gnus-summary-goto-subject gnus-current-article)
3781 (gnus-summary-position-point)))
3783 (defun gnus-article-describe-briefly ()
3784 "Describe article mode commands briefly."
3786 (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")))
3788 (defun gnus-article-summary-command ()
3789 "Execute the last keystroke in the summary buffer."
3791 (let ((obuf (current-buffer))
3792 (owin (current-window-configuration))
3794 (switch-to-buffer gnus-article-current-summary 'norecord)
3795 (setq func (lookup-key (current-local-map) (this-command-keys)))
3796 (call-interactively func)
3798 (set-window-configuration owin)
3799 (set-window-point (get-buffer-window (current-buffer)) (point))))
3801 (defun gnus-article-summary-command-nosave ()
3802 "Execute the last keystroke in the summary buffer."
3805 (pop-to-buffer gnus-article-current-summary 'norecord)
3806 (setq func (lookup-key (current-local-map) (this-command-keys)))
3807 (call-interactively func)))
3809 (defun gnus-article-check-buffer ()
3810 "Beep if not in an article buffer."
3811 (unless (equal major-mode 'gnus-article-mode)
3812 (error "Command invoked outside of a Gnus article buffer")))
3814 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
3815 "Read a summary buffer key sequence and execute it from the article buffer."
3817 (gnus-article-check-buffer)
3819 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
3820 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
3821 "=" "^" "\M-^" "|"))
3827 '("n" "Gn" "p" "Gp"))
3830 (set-buffer gnus-article-current-summary)
3831 (let (gnus-pick-mode)
3832 (push (or key last-command-event) unread-command-events)
3833 (setq keys (if (featurep 'xemacs)
3834 (events-to-keys (read-key-sequence nil))
3835 (read-key-sequence nil)))))
3839 (if (or (member keys nosaves)
3840 (member keys nosave-but-article)
3841 (member keys nosave-in-article))
3843 (save-window-excursion
3844 (pop-to-buffer gnus-article-current-summary 'norecord)
3845 ;; We disable the pick minor mode commands.
3846 (let (gnus-pick-mode)
3847 (setq func (lookup-key (current-local-map) keys))))
3851 (unless (member keys nosave-in-article)
3852 (set-buffer gnus-article-current-summary))
3853 (call-interactively func)
3854 (setq new-sum-point (point)))
3855 (when (member keys nosave-but-article)
3856 (pop-to-buffer gnus-article-buffer 'norecord)))
3857 ;; These commands should restore window configuration.
3858 (let ((obuf (current-buffer))
3859 (owin (current-window-configuration))
3861 (summary gnus-article-current-summary)
3862 func in-buffer selected)
3863 (if not-restore-window
3864 (pop-to-buffer summary 'norecord)
3865 (switch-to-buffer summary 'norecord))
3866 (setq in-buffer (current-buffer))
3867 ;; We disable the pick minor mode commands.
3868 (if (and (setq func (let (gnus-pick-mode)
3869 (lookup-key (current-local-map) keys)))
3872 (call-interactively func)
3873 (setq new-sum-point (point))
3874 (when (eq in-buffer (current-buffer))
3875 (setq selected (gnus-summary-select-article))
3877 (unless not-restore-window
3878 (set-window-configuration owin))
3879 (when (eq selected 'old)
3881 (set-window-start (get-buffer-window (current-buffer))
3883 (set-window-point (get-buffer-window (current-buffer))
3885 (let ((win (get-buffer-window gnus-article-current-summary)))
3887 (set-window-point win new-sum-point)))) )
3888 (switch-to-buffer gnus-article-buffer)
3891 (defun gnus-article-describe-key (key)
3892 "Display documentation of the function invoked by KEY. KEY is a string."
3893 (interactive "kDescribe key: ")
3894 (gnus-article-check-buffer)
3895 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
3897 (set-buffer gnus-article-current-summary)
3898 (let (gnus-pick-mode)
3899 (push (elt key 0) unread-command-events)
3900 (setq key (if (featurep 'xemacs)
3901 (events-to-keys (read-key-sequence "Describe key: "))
3902 (read-key-sequence "Describe key: "))))
3904 (describe-key key)))
3906 (defun gnus-article-describe-key-briefly (key &optional insert)
3907 "Display documentation of the function invoked by KEY. KEY is a string."
3908 (interactive "kDescribe key: \nP")
3909 (gnus-article-check-buffer)
3910 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
3912 (set-buffer gnus-article-current-summary)
3913 (let (gnus-pick-mode)
3914 (push (elt key 0) unread-command-events)
3915 (setq key (if (featurep 'xemacs)
3916 (events-to-keys (read-key-sequence "Describe key: "))
3917 (read-key-sequence "Describe key: "))))
3918 (describe-key-briefly key insert))
3919 (describe-key-briefly key insert)))
3921 (defun gnus-article-hide (&optional arg force)
3922 "Hide all the gruft in the current article.
3923 This means that PGP stuff, signatures, cited text and (some)
3924 headers will be hidden.
3925 If given a prefix, show the hidden text instead."
3926 (interactive (append (gnus-article-hidden-arg) (list 'force)))
3927 (gnus-article-hide-headers arg)
3928 (gnus-article-hide-list-identifiers arg)
3929 (gnus-article-hide-pgp arg)
3930 (gnus-article-hide-citation-maybe arg force)
3931 (gnus-article-hide-signature arg))
3933 (defun gnus-article-maybe-highlight ()
3934 "Do some article highlighting if article highlighting is requested."
3935 (when (gnus-visual-p 'article-highlight 'highlight)
3936 (gnus-article-highlight-some)))
3938 (defun gnus-check-group-server ()
3939 ;; Make sure the connection to the server is alive.
3940 (unless (gnus-server-opened
3941 (gnus-find-method-for-group gnus-newsgroup-name))
3942 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
3943 (gnus-request-group gnus-newsgroup-name t)))
3945 (defun gnus-request-article-this-buffer (article group)
3946 "Get an article and insert it into this buffer."
3947 (let (do-update-line sparse-header)
3951 (gnus-kill-all-overlays)
3952 (setq group (or group gnus-newsgroup-name))
3954 ;; Using `gnus-request-article' directly will insert the article into
3955 ;; `nntp-server-buffer' - so we'll save some time by not having to
3956 ;; copy it from the server buffer into the article buffer.
3958 ;; We only request an article by message-id when we do not have the
3959 ;; headers for it, so we'll have to get those.
3960 (when (stringp article)
3961 (gnus-read-header article))
3963 ;; If the article number is negative, that means that this article
3964 ;; doesn't belong in this newsgroup (possibly), so we find its
3965 ;; message-id and request it by id instead of number.
3966 (when (and (numberp article)
3968 (get-buffer gnus-summary-buffer)
3969 (gnus-buffer-exists-p gnus-summary-buffer))
3971 (set-buffer gnus-summary-buffer)
3972 (let ((header (gnus-summary-article-header article)))
3975 ((memq article gnus-newsgroup-sparse)
3976 ;; This is a sparse gap article.
3977 (setq do-update-line article)
3978 (setq article (mail-header-id header))
3979 (setq sparse-header (gnus-read-header article))
3980 (setq gnus-newsgroup-sparse
3981 (delq article gnus-newsgroup-sparse)))
3983 ;; It's a real article.
3984 (setq article (mail-header-id header)))
3986 ;; It is an extracted pseudo-article.
3987 (setq article 'pseudo)
3988 (gnus-request-pseudo-article header))))
3990 (let ((method (gnus-find-method-for-group
3991 gnus-newsgroup-name)))
3992 (when (and (eq (car method) 'nneething)
3994 (let ((dir (expand-file-name
3995 (mail-header-subject header)
3996 (file-name-as-directory
3997 (or (cadr (assq 'nneething-address method))
3999 (when (file-directory-p dir)
4000 (setq article 'nneething)
4001 (gnus-group-enter-directory dir))))))))
4004 ;; Refuse to select canceled articles.
4005 ((and (numberp article)
4007 (get-buffer gnus-summary-buffer)
4008 (gnus-buffer-exists-p gnus-summary-buffer)
4009 (eq (cdr (save-excursion
4010 (set-buffer gnus-summary-buffer)
4011 (assq article gnus-newsgroup-reads)))
4012 gnus-canceled-mark))
4014 ;; We first check `gnus-original-article-buffer'.
4015 ((and (get-buffer gnus-original-article-buffer)
4018 (set-buffer gnus-original-article-buffer)
4019 (and (equal (car gnus-original-article) group)
4020 (eq (cdr gnus-original-article) article))))
4021 (insert-buffer-substring gnus-original-article-buffer)
4023 ;; Check the backlog.
4024 ((and gnus-keep-backlog
4025 (gnus-backlog-request-article group article (current-buffer)))
4027 ;; Check asynchronous pre-fetch.
4028 ((gnus-async-request-fetched-article group article (current-buffer))
4029 (gnus-async-prefetch-next group article gnus-summary-buffer)
4030 (when (and (numberp article) gnus-keep-backlog)
4031 (gnus-backlog-enter-article group article (current-buffer)))
4034 ((and gnus-use-cache
4036 (gnus-cache-request-article article group))
4038 ;; Get the article and put into the article buffer.
4039 ((or (stringp article)
4041 (let ((gnus-override-method gnus-override-method)
4042 (methods (and (stringp article)
4043 gnus-refer-article-method))
4045 (buffer-read-only nil))
4046 (if (or (not (listp methods))
4047 (and (symbolp (car methods))
4048 (assq (car methods) nnoo-definition-alist)))
4049 (setq methods (list methods)))
4050 (when (and (null gnus-override-method)
4052 (setq gnus-override-method (pop methods)))
4054 (when (eq gnus-override-method 'current)
4055 (setq gnus-override-method
4056 (with-current-buffer gnus-summary-buffer
4057 gnus-current-select-method)))
4059 (gnus-kill-all-overlays)
4060 (let ((gnus-newsgroup-name group))
4061 (gnus-check-group-server))
4062 (when (gnus-request-article article group (current-buffer))
4063 (when (numberp article)
4064 (gnus-async-prefetch-next group article
4065 gnus-summary-buffer)
4066 (when gnus-keep-backlog
4067 (gnus-backlog-enter-article
4068 group article (current-buffer))))
4069 (setq result 'article))
4072 (setq gnus-override-method (pop methods))
4073 (setq result 'done))))
4074 (and (eq result 'article) 'article)))
4078 ;; Associate this article with the current summary buffer.
4079 (setq gnus-article-current-summary gnus-summary-buffer)
4081 ;; Take the article from the original article buffer
4082 ;; and place it in the buffer it's supposed to be in.
4083 (when (and (get-buffer gnus-article-buffer)
4084 (equal (buffer-name (current-buffer))
4085 (buffer-name (get-buffer gnus-article-buffer))))
4087 (if (get-buffer gnus-original-article-buffer)
4088 (set-buffer gnus-original-article-buffer)
4089 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
4090 (buffer-disable-undo)
4091 (setq major-mode 'gnus-original-article-mode)
4092 (setq buffer-read-only t))
4093 (let (buffer-read-only)
4095 (insert-buffer-substring gnus-article-buffer))
4096 (setq gnus-original-article (cons group article)))
4099 (run-hooks 'gnus-article-decode-hook)
4100 ;; Mark article as decoded or not.
4101 (setq gnus-article-decoded-p gnus-article-decode-hook))
4103 ;; Update sparse articles.
4104 (when (and do-update-line
4105 (or (numberp article)
4107 (let ((buf (current-buffer)))
4108 (set-buffer gnus-summary-buffer)
4109 (gnus-summary-update-article do-update-line sparse-header)
4110 (gnus-summary-goto-subject do-update-line nil t)
4111 (set-window-point (get-buffer-window (current-buffer) t)
4113 (set-buffer buf))))))
4119 (defcustom gnus-article-edit-mode-hook nil
4120 "Hook run in article edit mode buffers."
4121 :group 'gnus-article-various
4124 (defvar gnus-article-edit-done-function nil)
4126 (defvar gnus-article-edit-mode-map nil)
4128 ;; Should we be using derived.el for this?
4129 (unless gnus-article-edit-mode-map
4130 (setq gnus-article-edit-mode-map (make-sparse-keymap))
4131 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
4133 (gnus-define-keys gnus-article-edit-mode-map
4134 "\C-c\C-c" gnus-article-edit-done
4135 "\C-c\C-k" gnus-article-edit-exit)
4137 (gnus-define-keys (gnus-article-edit-wash-map
4138 "\C-c\C-w" gnus-article-edit-mode-map)
4139 "f" gnus-article-edit-full-stops))
4141 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
4142 "Major mode for editing articles.
4143 This is an extended text-mode.
4145 \\{gnus-article-edit-mode-map}"
4146 (make-local-variable 'gnus-article-edit-done-function)
4147 (make-local-variable 'gnus-prev-winconf)
4148 (set (make-local-variable 'font-lock-defaults)
4149 '(message-font-lock-keywords t))
4150 (setq buffer-read-only nil)
4151 (buffer-enable-undo)
4154 (defun gnus-article-edit (&optional force)
4155 "Edit the current article.
4156 This will have permanent effect only in mail groups.
4157 If FORCE is non-nil, allow editing of articles even in read-only
4160 (when (and (not force)
4161 (gnus-group-read-only-p))
4162 (error "The current newsgroup does not support article editing"))
4163 (gnus-article-date-original)
4164 (gnus-article-edit-article
4166 `(lambda (no-highlight)
4168 (gnus-summary-edit-article-done
4169 ,(or (mail-header-references gnus-current-headers) "")
4170 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
4172 (defun gnus-article-edit-article (start-func exit-func)
4173 "Start editing the contents of the current article buffer."
4174 (let ((winconf (current-window-configuration)))
4175 (set-buffer gnus-article-buffer)
4176 (gnus-article-edit-mode)
4177 (funcall start-func)
4178 (gnus-configure-windows 'edit-article)
4179 (setq gnus-article-edit-done-function exit-func)
4180 (setq gnus-prev-winconf winconf)
4181 (gnus-message 6 "C-c C-c to end edits")))
4183 (defun gnus-article-edit-done (&optional arg)
4184 "Update the article edits and exit."
4189 (when (article-goto-body)
4190 (let ((lines (count-lines (point) (point-max)))
4191 (length (- (point-max) (point)))
4192 (case-fold-search t)
4193 (body (copy-marker (point))))
4194 (goto-char (point-min))
4195 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
4196 (delete-region (match-beginning 1) (match-end 1))
4197 (insert (number-to-string length)))
4198 (goto-char (point-min))
4199 (when (re-search-forward
4200 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
4201 (delete-region (match-beginning 1) (match-end 1))
4202 (insert (number-to-string length)))
4203 (goto-char (point-min))
4204 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
4205 (delete-region (match-beginning 1) (match-end 1))
4206 (insert (number-to-string lines)))))))
4207 (let ((func gnus-article-edit-done-function)
4208 (buf (current-buffer))
4209 (start (window-start)))
4210 (gnus-article-edit-exit)
4213 (let ((buffer-read-only nil))
4215 ;; The cache and backlog have to be flushed somewhat.
4216 (when gnus-keep-backlog
4217 (gnus-backlog-remove-article
4218 (car gnus-article-current) (cdr gnus-article-current)))
4219 ;; Flush original article as well.
4221 (when (get-buffer gnus-original-article-buffer)
4222 (set-buffer gnus-original-article-buffer)
4223 (setq gnus-original-article nil)))
4224 (when gnus-use-cache
4225 (gnus-cache-update-article
4226 (car gnus-article-current) (cdr gnus-article-current))))
4228 (set-window-start (get-buffer-window buf) start)
4229 (set-window-point (get-buffer-window buf) (point))))
4231 (defun gnus-article-edit-exit ()
4232 "Exit the article editing without updating."
4234 ;; We remove all text props from the article buffer.
4235 (let ((buf (buffer-substring-no-properties (point-min) (point-max)))
4236 (curbuf (current-buffer))
4238 (window-start (window-start)))
4241 (let ((winconf gnus-prev-winconf))
4243 (set-window-configuration winconf)
4244 ;; Tippy-toe some to make sure that point remains where it was.
4245 (save-current-buffer
4247 (set-window-start (get-buffer-window (current-buffer)) window-start)
4250 (defun gnus-article-edit-full-stops ()
4251 "Interactively repair spacing at end of sentences."
4254 (goto-char (point-min))
4255 (search-forward-regexp "^$" nil t)
4256 (let ((case-fold-search nil))
4257 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
4260 ;;; Article highlights
4263 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
4265 ;;; Internal Variables:
4267 (defcustom gnus-button-url-regexp
4268 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
4269 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-zA-Z0-9_.]+:[0-9]*\\)?[-a-zA-Z0-9_=!?#$@~`%&*+|\\/:;.,[:word:]]+[-a-zA-Z0-9_=#$@~`%&*+|\\/[:word:]]\\)"
4270 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-zA-Z0-9_.]+:[0-9]*\\)?\\([-a-zA-Z0-9_=!?#$@~`%&*+|\\/:;.,]\\|\\w\\)+\\([-a-zA-Z0-9_=#$@~`%&*+|\\/]\\|\\w\\)\\)")
4271 "Regular expression that matches URLs."
4272 :group 'gnus-article-buttons
4275 (defcustom gnus-button-alist
4276 `(("<\\(url:[>\n\t ]*?\\)?news:[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
4277 0 t gnus-button-message-id 2)
4278 ("\\bnews:\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t gnus-button-message-id 1)
4279 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
4281 gnus-button-fetch-group 4)
4282 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
4283 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
4284 t gnus-button-message-id 3)
4285 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
4286 ("mailto:\\([-a-zA-Z.@_+0-9%]+\\)" 0 t gnus-url-mailto 1)
4287 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
4288 ;; This is how URLs _should_ be embedded in text...
4289 ("<URL: *\\([^<>]*\\)>" 0 t gnus-button-embedded-url 1)
4291 (,gnus-button-url-regexp 0 t browse-url 0))
4292 "*Alist of regexps matching buttons in article bodies.
4294 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
4295 REGEXP: is the string matching text around the button,
4296 BUTTON: is the number of the regexp grouping actually matching the button,
4297 FORM: is a lisp expression which must eval to true for the button to
4299 CALLBACK: is the function to call when the user push this button, and each
4300 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
4302 CALLBACK can also be a variable, in that case the value of that
4303 variable it the real callback function."
4304 :group 'gnus-article-buttons
4305 :type '(repeat (list regexp
4306 (integer :tag "Button")
4308 (function :tag "Callback")
4311 (integer :tag "Regexp group")))))
4313 (defcustom gnus-header-button-alist
4314 `(("^\\(References\\|Message-I[Dd]\\):" "<[^>]+>"
4315 0 t gnus-button-message-id 0)
4316 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
4317 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
4318 0 t gnus-button-mailto 0)
4319 ("^X-[Uu][Rr][Ll]:" ,gnus-button-url-regexp 0 t browse-url 0)
4320 ("^Subject:" ,gnus-button-url-regexp 0 t browse-url 0)
4321 ("^[^:]+:" ,gnus-button-url-regexp 0 t browse-url 0)
4322 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
4323 gnus-button-message-id 3))
4324 "*Alist of headers and regexps to match buttons in article heads.
4326 This alist is very similar to `gnus-button-alist', except that each
4327 alist has an additional HEADER element first in each entry:
4329 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
4331 HEADER is a regexp to match a header. For a fuller explanation, see
4332 `gnus-button-alist'."
4333 :group 'gnus-article-buttons
4334 :group 'gnus-article-headers
4335 :type '(repeat (list (regexp :tag "Header")
4337 (integer :tag "Button")
4339 (function :tag "Callback")
4342 (integer :tag "Regexp group")))))
4344 (defvar gnus-button-regexp nil)
4345 (defvar gnus-button-marker-list nil)
4346 ;; Regexp matching any of the regexps from `gnus-button-alist'.
4348 (defvar gnus-button-last nil)
4349 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
4353 (defun gnus-article-push-button (event)
4354 "Check text under the mouse pointer for a callback function.
4355 If the text under the mouse pointer has a `gnus-callback' property,
4356 call it with the value of the `gnus-data' text property."
4358 (set-buffer (window-buffer (posn-window (event-start event))))
4359 (let* ((pos (posn-point (event-start event)))
4360 (data (get-text-property pos 'gnus-data))
4361 (fun (get-text-property pos 'gnus-callback)))
4364 (funcall fun data))))
4366 (defun gnus-article-press-button ()
4367 "Check text at point for a callback function.
4368 If the text at point has a `gnus-callback' property,
4369 call it with the value of the `gnus-data' text property."
4371 (let* ((data (get-text-property (point) 'gnus-data))
4372 (fun (get-text-property (point) 'gnus-callback)))
4374 (funcall fun data))))
4376 (defun gnus-article-highlight (&optional force)
4377 "Highlight current article.
4378 This function calls `gnus-article-highlight-headers',
4379 `gnus-article-highlight-citation',
4380 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
4381 do the highlighting. See the documentation for those functions."
4382 (interactive (list 'force))
4383 (gnus-article-highlight-headers)
4384 (gnus-article-highlight-citation force)
4385 (gnus-article-highlight-signature)
4386 (gnus-article-add-buttons force)
4387 (gnus-article-add-buttons-to-head))
4389 (defun gnus-article-highlight-some (&optional force)
4390 "Highlight current article.
4391 This function calls `gnus-article-highlight-headers',
4392 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
4393 do the highlighting. See the documentation for those functions."
4394 (interactive (list 'force))
4395 (gnus-article-highlight-headers)
4396 (gnus-article-highlight-signature)
4397 (gnus-article-add-buttons))
4399 (defun gnus-article-highlight-headers ()
4400 "Highlight article headers as specified by `gnus-header-face-alist'."
4403 (set-buffer gnus-article-buffer)
4405 (let ((alist gnus-header-face-alist)
4406 (buffer-read-only nil)
4407 (case-fold-search t)
4408 (inhibit-point-motion-hooks t)
4409 entry regexp header-face field-face from hpoints fpoints)
4410 (article-narrow-to-head)
4411 (while (setq entry (pop alist))
4412 (goto-char (point-min))
4413 (setq regexp (concat "^\\("
4414 (if (string-equal "" (nth 0 entry))
4418 header-face (nth 1 entry)
4419 field-face (nth 2 entry))
4420 (while (and (re-search-forward regexp nil t)
4424 (unless (search-forward ":" nil t)
4426 (when (and header-face
4427 (not (memq (point) hpoints)))
4428 (push (point) hpoints)
4429 (gnus-put-text-property from (point) 'face header-face))
4430 (when (and field-face
4431 (not (memq (setq from (point)) fpoints)))
4433 (if (re-search-forward "^[^ \t]" nil t)
4435 (goto-char (point-max)))
4436 (gnus-put-text-property from (point) 'face field-face))))))))
4438 (defun gnus-article-highlight-signature ()
4439 "Highlight the signature in an article.
4440 It does this by highlighting everything after
4441 `gnus-signature-separator' using `gnus-signature-face'."
4444 (set-buffer gnus-article-buffer)
4445 (let ((buffer-read-only nil)
4446 (inhibit-point-motion-hooks t))
4448 (when (and gnus-signature-face
4449 (gnus-article-narrow-to-signature))
4450 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
4451 'face gnus-signature-face)
4453 (gnus-article-search-signature)
4454 (let ((start (match-beginning 0))
4455 (end (set-marker (make-marker) (1+ (match-end 0)))))
4456 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
4459 (defun gnus-button-in-region-p (b e prop)
4460 "Say whether PROP exists in the region."
4461 (text-property-not-all b e prop nil))
4463 (defun gnus-article-add-buttons (&optional force)
4464 "Find external references in the article and make buttons of them.
4465 \"External references\" are things like Message-IDs and URLs, as
4466 specified by `gnus-button-alist'."
4467 (interactive (list 'force))
4469 (set-buffer gnus-article-buffer)
4470 (let ((buffer-read-only nil)
4471 (inhibit-point-motion-hooks t)
4472 (case-fold-search t)
4473 (alist gnus-button-alist)
4475 ;; Remove all old markers.
4476 (let (marker entry new-list)
4477 (while (setq marker (pop gnus-button-marker-list))
4478 (if (or (< marker (point-min)) (>= marker (point-max)))
4479 (push marker new-list)
4481 (when (setq entry (gnus-button-entry))
4482 (put-text-property (match-beginning (nth 1 entry))
4483 (match-end (nth 1 entry))
4484 'gnus-callback nil))
4485 (set-marker marker nil)))
4486 (setq gnus-button-marker-list new-list))
4487 ;; We skip the headers.
4490 (while (setq entry (pop alist))
4491 (setq regexp (car entry))
4493 (while (re-search-forward regexp nil t)
4494 (let* ((start (and entry (match-beginning (nth 1 entry))))
4495 (end (and entry (match-end (nth 1 entry))))
4496 (from (match-beginning 0)))
4497 (when (and (or (eq t (nth 2 entry))
4498 (eval (nth 2 entry)))
4499 (not (gnus-button-in-region-p
4500 start end 'gnus-callback)))
4501 ;; That optional form returned non-nil, so we add the
4503 (gnus-article-add-button
4504 start end 'gnus-button-push
4505 (car (push (set-marker (make-marker) from)
4506 gnus-button-marker-list))))))))))
4508 ;; Add buttons to the head of an article.
4509 (defun gnus-article-add-buttons-to-head ()
4510 "Add buttons to the head of the article."
4513 (set-buffer gnus-article-buffer)
4515 (let ((buffer-read-only nil)
4516 (inhibit-point-motion-hooks t)
4517 (case-fold-search t)
4518 (alist gnus-header-button-alist)
4520 (article-narrow-to-head)
4522 ;; Each alist entry.
4523 (setq entry (car alist)
4525 (goto-char (point-min))
4526 (while (re-search-forward (car entry) nil t)
4527 ;; Each header matching the entry.
4528 (setq beg (match-beginning 0))
4529 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
4530 (match-beginning 0))
4533 (while (re-search-forward (nth 1 entry) end t)
4534 ;; Each match within a header.
4535 (let* ((entry (cdr entry))
4536 (start (match-beginning (nth 1 entry)))
4537 (end (match-end (nth 1 entry)))
4538 (form (nth 2 entry)))
4539 (goto-char (match-end 0))
4541 (gnus-article-add-button
4542 start end (nth 3 entry)
4543 (buffer-substring (match-beginning (nth 4 entry))
4544 (match-end (nth 4 entry)))))))
4545 (goto-char end)))))))
4547 ;;; External functions:
4549 (defun gnus-article-add-button (from to fun &optional data)
4550 "Create a button between FROM and TO with callback FUN and data DATA."
4551 (when gnus-article-button-face
4552 (gnus-overlay-put (gnus-make-overlay from to)
4553 'face gnus-article-button-face))
4554 (gnus-add-text-properties
4556 (nconc (and gnus-article-mouse-face
4557 (list gnus-mouse-face-prop gnus-article-mouse-face))
4558 (list 'gnus-callback fun)
4559 (and data (list 'gnus-data data))))
4560 (widget-convert-button 'link from to :action 'gnus-widget-press-button
4561 :button-keymap gnus-widget-button-keymap))
4563 ;;; Internal functions:
4565 (defun gnus-article-set-globals ()
4567 (set-buffer gnus-summary-buffer)
4568 (gnus-set-global-variables)))
4570 (defun gnus-signature-toggle (end)
4572 (set-buffer gnus-article-buffer)
4573 (let ((buffer-read-only nil)
4574 (inhibit-point-motion-hooks t))
4575 (if (text-property-any end (point-max) 'article-type 'signature)
4576 (gnus-remove-text-properties-when
4577 'article-type 'signature end (point-max)
4578 (cons 'article-type (cons 'signature
4579 gnus-hidden-properties)))
4580 (gnus-add-text-properties-when
4581 'article-type nil end (point-max)
4582 (cons 'article-type (cons 'signature
4583 gnus-hidden-properties)))))))
4585 (defun gnus-button-entry ()
4586 ;; Return the first entry in `gnus-button-alist' matching this place.
4587 (let ((alist gnus-button-alist)
4590 (setq entry (pop alist))
4591 (if (looking-at (car entry))
4596 (defun gnus-button-push (marker)
4597 ;; Push button starting at MARKER.
4600 (let* ((entry (gnus-button-entry))
4601 (inhibit-point-motion-hooks t)
4603 (args (mapcar (lambda (group)
4604 (let ((string (match-string group)))
4605 (gnus-set-text-properties
4606 0 (length string) nil string)
4613 (fboundp (symbol-value fun)))
4614 (apply (symbol-value fun) args))
4616 (gnus-message 1 "You must define `%S' to use this button"
4617 (cons fun args)))))))
4619 (defun gnus-button-message-id (message-id)
4622 (set-buffer gnus-summary-buffer)
4623 (gnus-summary-refer-article message-id)))
4625 (defun gnus-button-fetch-group (address)
4626 "Fetch GROUP specified by ADDRESS."
4627 (if (not (string-match "[:/]" address))
4628 ;; This is just a simple group url.
4629 (gnus-group-read-ephemeral-group address gnus-select-method)
4630 (if (not (string-match "^\\([^:/]+\\)\\(:\\([^/]+\\)/\\)?\\(.*\\)$"
4632 (error "Can't parse %s" address)
4633 (gnus-group-read-ephemeral-group
4634 (match-string 4 address)
4635 `(nntp ,(match-string 1 address)
4636 (nntp-address ,(match-string 1 address))
4637 (nntp-port-number ,(if (match-end 3)
4638 (match-string 3 address)
4641 (defun gnus-url-parse-query-string (query &optional downcase)
4642 (let (retval pairs cur key val)
4643 (setq pairs (split-string query "&"))
4645 (setq cur (car pairs)
4647 (if (not (string-match "=" cur))
4649 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
4650 val (gnus-url-unhex-string (substring cur (match-end 0) nil)))
4652 (setq key (downcase key)))
4653 (setq cur (assoc key retval))
4655 (setcdr cur (cons val (cdr cur)))
4656 (setq retval (cons (list key val) retval)))))
4659 (defun gnus-url-unhex (x)
4666 (defun gnus-url-unhex-string (str &optional allow-newlines)
4667 "Remove %XXX embedded spaces, etc in a url.
4668 If optional second argument ALLOW-NEWLINES is non-nil, then allow the
4669 decoding of carriage returns and line feeds in the string, which is normally
4670 forbidden in URL encoding."
4671 (setq str (or str ""))
4673 (case-fold-search t))
4674 (while (string-match "%[0-9a-f][0-9a-f]" str)
4675 (let* ((start (match-beginning 0))
4676 (ch1 (gnus-url-unhex (elt str (+ start 1))))
4678 (gnus-url-unhex (elt str (+ start 2))))))
4680 tmp (substring str 0 start)
4683 (char-to-string code))
4684 ((or (= code ?\n) (= code ?\r))
4686 (t (char-to-string code))))
4687 str (substring str (match-end 0)))))
4688 (setq tmp (concat tmp str))
4691 (defun gnus-url-mailto (url)
4692 ;; Send mail to someone
4693 (when (string-match "mailto:/*\\(.*\\)" url)
4694 (setq url (substring url (match-beginning 1) nil)))
4695 (let (to args subject func)
4696 (if (string-match (regexp-quote "?") url)
4697 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
4698 args (gnus-url-parse-query-string
4699 (substring url (match-end 0) nil) t))
4700 (setq to (gnus-url-unhex-string url)))
4701 (setq args (cons (list "to" to) args)
4702 subject (cdr-safe (assoc "subject" args)))
4705 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
4708 (message-position-on-field (caar args)))
4709 (insert (mapconcat 'identity (cdar args) ", "))
4710 (setq args (cdr args)))
4713 (message-goto-subject))))
4715 (defun gnus-button-mailto (address)
4717 (set-buffer (gnus-copy-article-buffer))
4718 (message-reply address))
4720 (defalias 'gnus-button-reply 'message-reply)
4722 (defun gnus-button-embedded-url (address)
4723 "Activate ADDRESS with `browse-url'."
4724 (browse-url (gnus-strip-whitespace address)))
4726 ;;; Next/prev buttons in the article buffer.
4728 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
4729 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
4731 (defvar gnus-prev-page-map nil)
4732 (unless gnus-prev-page-map
4733 (setq gnus-prev-page-map (make-sparse-keymap))
4734 (define-key gnus-prev-page-map gnus-mouse-2 'gnus-button-prev-page)
4735 (define-key gnus-prev-page-map "\r" 'gnus-button-prev-page))
4737 (defun gnus-insert-prev-page-button ()
4738 (let ((buffer-read-only nil))
4740 gnus-prev-page-line-format nil
4741 `(gnus-prev t local-map ,gnus-prev-page-map
4742 gnus-callback gnus-article-button-prev-page
4743 article-type annotation))))
4745 (defvar gnus-next-page-map nil)
4746 (unless gnus-next-page-map
4747 (setq gnus-next-page-map (make-keymap))
4748 (suppress-keymap gnus-prev-page-map)
4749 (define-key gnus-next-page-map gnus-mouse-2 'gnus-button-next-page)
4750 (define-key gnus-next-page-map "\r" 'gnus-button-next-page))
4752 (defun gnus-button-next-page ()
4753 "Go to the next page."
4755 (let ((win (selected-window)))
4756 (select-window (get-buffer-window gnus-article-buffer t))
4757 (gnus-article-next-page)
4758 (select-window win)))
4760 (defun gnus-button-prev-page ()
4761 "Go to the prev page."
4763 (let ((win (selected-window)))
4764 (select-window (get-buffer-window gnus-article-buffer t))
4765 (gnus-article-prev-page)
4766 (select-window win)))
4768 (defun gnus-insert-next-page-button ()
4769 (let ((buffer-read-only nil))
4770 (gnus-eval-format gnus-next-page-line-format nil
4772 t local-map ,gnus-next-page-map
4773 gnus-callback gnus-article-button-next-page
4774 article-type annotation))))
4776 (defun gnus-article-button-next-page (arg)
4777 "Go to the next page."
4779 (let ((win (selected-window)))
4780 (select-window (get-buffer-window gnus-article-buffer t))
4781 (gnus-article-next-page)
4782 (select-window win)))
4784 (defun gnus-article-button-prev-page (arg)
4785 "Go to the prev page."
4787 (let ((win (selected-window)))
4788 (select-window (get-buffer-window gnus-article-buffer t))
4789 (gnus-article-prev-page)
4790 (select-window win)))
4792 (defvar gnus-decode-header-methods
4793 '(mail-decode-encoded-word-region)
4794 "List of methods used to decode headers.
4796 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
4797 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
4798 (REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
4799 whose names match REGEXP.
4802 ((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
4803 mail-decode-encoded-word-region
4804 (\"chinese\" . rfc1843-decode-region))
4807 (defvar gnus-decode-header-methods-cache nil)
4809 (defun gnus-multi-decode-header (start end)
4810 "Apply the functions from `gnus-encoded-word-methods' that match."
4811 (unless (and gnus-decode-header-methods-cache
4812 (eq gnus-newsgroup-name
4813 (car gnus-decode-header-methods-cache)))
4814 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
4817 (nconc gnus-decode-header-methods-cache (list x))
4818 (if (and gnus-newsgroup-name
4819 (string-match (car x) gnus-newsgroup-name))
4820 (nconc gnus-decode-header-methods-cache
4822 gnus-decode-header-methods))
4823 (let ((xlist gnus-decode-header-methods-cache))
4826 (narrow-to-region start end)
4828 (funcall (pop xlist) (point-min) (point-max))))))
4831 ;;; Treatment top-level handling.
4834 (defun gnus-treat-article (condition &optional part-number total-parts type)
4835 (let ((length (- (point-max) (point-min)))
4836 (alist gnus-treatment-function-alist)
4837 (article-goto-body-goes-to-point-min-p t)
4841 (let ((list gnus-article-treat-types))
4843 (when (string-match (pop list) type)
4844 (throw 'found t)))))))
4845 (highlightp (gnus-visual-p 'article-highlight 'highlight))
4847 (gnus-run-hooks 'gnus-part-display-hook)
4848 (while (setq elem (pop alist))
4851 (if (gnus-buffer-live-p gnus-summary-buffer)
4852 (set-buffer gnus-summary-buffer))
4853 (symbol-value (car elem))))
4854 (when (and (or (consp val)
4856 (gnus-treat-predicate val)
4857 (or (not (get (car elem) 'highlight))
4860 (funcall (cadr elem)))))))
4862 ;; Dynamic variables.
4864 (defvar part-number)
4865 (defvar total-parts)
4870 (defun gnus-treat-predicate (val)
4875 (stringp (car val)))
4876 (apply 'gnus-or (mapcar `(lambda (s)
4877 (string-match s ,(or gnus-newsgroup-name "")))
4880 (let ((pred (pop val)))
4883 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
4885 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
4887 (not (gnus-treat-predicate (car val))))
4889 (equal (car val) type))
4891 (error "%S is not a valid predicate" pred)))))
4899 (eq part-number total-parts))
4903 (error "%S is not a valid value" val))))
4909 (run-hooks 'gnus-art-load-hook)
4911 ;;; gnus-art.el ends here