1 ;;; gnus-art.el --- article mode commands for Semi-gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
5 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
6 ;; Katsumi Yamaoka <yamaoka@jpl.org>
7 ;; Keywords: mail, news, MIME
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
30 (eval-when-compile (require 'cl))
31 (eval-when-compile (require 'static))
41 ;; Avoid byte-compile warnings.
51 (defgroup gnus-article nil
53 :link '(custom-manual "(gnus)The Article Buffer")
56 (defgroup gnus-article-treat nil
57 "Treating article parts."
58 :link '(custom-manual "(gnus)Article Hiding")
61 (defgroup gnus-article-hiding nil
62 "Hiding article parts."
63 :link '(custom-manual "(gnus)Article Hiding")
66 (defgroup gnus-article-highlight nil
67 "Article highlighting."
68 :link '(custom-manual "(gnus)Article Highlighting")
72 (defgroup gnus-article-signature nil
74 :link '(custom-manual "(gnus)Article Signature")
77 (defgroup gnus-article-headers nil
79 :link '(custom-manual "(gnus)Hiding Headers")
82 (defgroup gnus-article-washing nil
83 "Special commands on articles."
84 :link '(custom-manual "(gnus)Article Washing")
87 (defgroup gnus-article-emphasis nil
88 "Fontisizing articles."
89 :link '(custom-manual "(gnus)Article Fontisizing")
92 (defgroup gnus-article-saving nil
94 :link '(custom-manual "(gnus)Saving Articles")
97 (defgroup gnus-article-mime nil
98 "Worshiping the MIME wonder."
99 :link '(custom-manual "(gnus)Using MIME")
100 :group 'gnus-article)
102 (defgroup gnus-article-buttons nil
103 "Pushable buttons in the article buffer."
104 :link '(custom-manual "(gnus)Article Buttons")
105 :group 'gnus-article)
107 (defgroup gnus-article-various nil
108 "Other article options."
109 :link '(custom-manual "(gnus)Misc Article")
110 :group 'gnus-article)
112 (defcustom gnus-ignored-headers
113 '("^Path:" "^Expires:" "^Date-Received:" "^References:" "^Xref:" "^Lines:"
114 "^Relay-Version:" "^Message-ID:" "^Approved:" "^Sender:" "^Received:"
115 "^X-UIDL:" "^MIME-Version:" "^Return-Path:" "^In-Reply-To:"
116 "^Content-Type:" "^Content-Transfer-Encoding:" "^X-WebTV-Signature:"
117 "^X-MimeOLE:" "^X-MSMail-Priority:" "^X-Priority:" "^X-Loop:"
118 "^X-Authentication-Warning:" "^X-MIME-Autoconverted:" "^X-Face:"
119 "^X-Attribution:" "^X-Originating-IP:" "^Delivered-To:"
120 "^NNTP-[-A-Za-z]+:" "^Distribution:" "^X-no-archive:" "^X-Trace:"
121 "^X-Complaints-To:" "^X-NNTP-Posting-Host:" "^X-Orig.*:"
122 "^Abuse-Reports-To:" "^Cache-Post-Path:" "^X-Article-Creation-Date:"
123 "^X-Poster:" "^X-Mail2News-Path:" "^X-Server-Date:" "^X-Cache:"
124 "^Originator:" "^X-Problems-To:" "^X-Auth-User:" "^X-Post-Time:"
125 "^X-Admin:" "^X-UID:" "^Resent-[-A-Za-z]+:" "^X-Mailing-List:"
126 "^Precedence:" "^Original-[-A-Za-z]+:" "^X-filename:" "^X-Orcpt:"
127 "^Old-Received:" "^X-Pgp" "^X-Auth:" "^X-From-Line:"
128 "^X-Gnus-Article-Number:" "^X-Majordomo:" "^X-Url:" "^X-Sender:"
129 "^MBOX-Line" "^Priority:" "^X-Pgp" "^X400-[-A-Za-z]+:"
130 "^Status:" "^X-Gnus-Mail-Source:" "^Cancel-Lock:"
131 "^X-FTN" "^X-EXP32-SerialNo:" "^Encoding:" "^Importance:"
132 "^Autoforwarded:" "^Original-Encoded-Information-Types:" "^X-Ya-Pop3:"
133 "^X-Face-Version:" "^X-Vms-To:" "^X-ML-NAME:" "^X-ML-COUNT:"
134 "^Mailing-List:" "^X-finfo:" "^X-md5sum:" "^X-md5sum-Origin:"
135 "^X-Sun-Charset:" "^X-Accept-Language:" "^X-Envelope-Sender:"
136 "^List-[A-Za-z]+:" "^X-Listprocessor-Version:"
137 "^X-Received:" "^X-Distribute:" "^X-Sequence:" "^X-Juno-Line-Breaks:"
138 "^X-Notes-Item:" "^X-MS-TNEF-Correlator:" "^x-uunet-gateway:"
139 "^X-Received:" "^Content-length:" "X-precedence:")
140 "*All headers that start with this regexp will be hidden.
141 This variable can also be a list of regexps of headers to be ignored.
142 If `gnus-visible-headers' is non-nil, this variable will be ignored."
143 :type '(choice :custom-show nil
146 :group 'gnus-article-hiding)
148 (defcustom gnus-visible-headers
149 "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^[BGF]?Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-From:\\|^X-Sent:"
150 "*All headers that do not match this regexp will be hidden.
151 This variable can also be a list of regexp of headers to remain visible.
152 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
153 :type '(repeat :value-to-internal (lambda (widget value)
154 (custom-split-regexp-maybe value))
155 :match (lambda (widget value)
157 (widget-editable-list-match widget value)))
159 :group 'gnus-article-hiding)
161 (defcustom gnus-sorted-header-list
162 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
163 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
164 "*This variable is a list of regular expressions.
165 If it is non-nil, headers that match the regular expressions will
166 be placed first in the article buffer in the sequence specified by
168 :type '(repeat regexp)
169 :group 'gnus-article-hiding)
171 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
172 "Headers that are only to be displayed if they have interesting data.
173 Possible values in this list are `empty', `newsgroups', `followup-to',
174 `reply-to', `date', `long-to', and `many-to'."
175 :type '(set (const :tag "Headers with no content." empty)
176 (const :tag "Newsgroups with only one group." newsgroups)
177 (const :tag "Followup-to identical to newsgroups." followup-to)
178 (const :tag "Reply-to identical to from." reply-to)
179 (const :tag "Date less than four days old." date)
180 (const :tag "Very long To and/or Cc header." long-to)
181 (const :tag "Multiple To and/or Cc headers." many-to))
182 :group 'gnus-article-hiding)
184 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
185 "Regexp matching signature separator.
186 This can also be a list of regexps. In that case, it will be checked
187 from head to tail looking for a separator. Searches will be done from
188 the end of the buffer."
189 :type '(repeat string)
190 :group 'gnus-article-signature)
192 (defcustom gnus-signature-limit nil
193 "Provide a limit to what is considered a signature.
194 If it is a number, no signature may not be longer (in characters) than
195 that number. If it is a floating point number, no signature may be
196 longer (in lines) than that number. If it is a function, the function
197 will be called without any parameters, and if it returns nil, there is
198 no signature in the buffer. If it is a string, it will be used as a
199 regexp. If it matches, the text in question is not a signature."
200 :type '(choice (integer :value 200)
202 (function :value fun)
203 (regexp :value ".*"))
204 :group 'gnus-article-signature)
206 (defcustom gnus-hidden-properties '(invisible t intangible t)
207 "Property list to use for hiding text."
209 :group 'gnus-article-hiding)
211 (defcustom gnus-article-x-face-command
213 ((and (fboundp 'image-type-available-p)
214 (image-type-available-p 'xbm))
215 'gnus-article-display-xface)
216 ((and (not gnus-xemacs)
218 (module-installed-p 'x-face-mule))
219 'x-face-mule-gnus-article-display-x-face)
221 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | display -"))
222 "*String or function to be executed to display an X-Face header.
223 If it is a string, the command will be executed in a sub-shell
224 asynchronously. The compressed face will be piped to this command."
225 :type '(choice string
226 (function-item gnus-article-display-xface)
227 (function-item x-face-mule-gnus-article-display-x-face)
229 :group 'gnus-article-washing)
231 (defcustom gnus-article-x-face-too-ugly nil
232 "Regexp matching posters whose face shouldn't be shown automatically."
233 :type '(choice regexp (const nil))
234 :group 'gnus-article-washing)
236 (defcustom gnus-emphasis-alist
238 "\\(\\s-\\|^\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\s-\\|[-,;:\"]\\s-\\|[?!.]+\\s-\\|\\s)\\)")
240 '(("_" "_" underline)
243 ("_/" "/_" underline-italic)
244 ("_\\*" "\\*_" underline-bold)
245 ("\\*/" "/\\*" bold-italic)
246 ("_\\*/" "/\\*_" underline-bold-italic))))
247 `(("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
248 2 3 gnus-emphasis-underline)
252 (format format (car spec) (car (cdr spec)))
253 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
255 "*Alist that says how to fontify certain phrases.
256 Each item looks like this:
258 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
260 The first element is a regular expression to be matched. The second
261 is a number that says what regular expression grouping used to find
262 the entire emphasized word. The third is a number that says what
263 regexp grouping should be displayed and highlighted. The fourth
264 is the face used for highlighting."
265 :type '(repeat (list :value ("" 0 0 default)
267 (integer :tag "Match group")
268 (integer :tag "Emphasize group")
270 :group 'gnus-article-emphasis)
272 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
273 "A regexp to describe whitespace which should not be emphasized.
274 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
275 The former avoids underlining of leading and trailing whitespace,
276 and the latter avoids underlining any whitespace at all."
277 :group 'gnus-article-emphasis
280 (defface gnus-emphasis-bold '((t (:bold t)))
281 "Face used for displaying strong emphasized text (*word*)."
282 :group 'gnus-article-emphasis)
284 (defface gnus-emphasis-italic '((t (:italic t)))
285 "Face used for displaying italic emphasized text (/word/)."
286 :group 'gnus-article-emphasis)
288 (defface gnus-emphasis-underline '((t (:underline t)))
289 "Face used for displaying underlined emphasized text (_word_)."
290 :group 'gnus-article-emphasis)
292 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
293 "Face used for displaying underlined bold emphasized text (_*word*_)."
294 :group 'gnus-article-emphasis)
296 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
297 "Face used for displaying underlined italic emphasized text (_/word/_)."
298 :group 'gnus-article-emphasis)
300 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
301 "Face used for displaying bold italic emphasized text (/*word*/)."
302 :group 'gnus-article-emphasis)
304 (defface gnus-emphasis-underline-bold-italic
305 '((t (:bold t :italic t :underline t)))
306 "Face used for displaying underlined bold italic emphasized text.
307 Esample: (_/*word*/_)."
308 :group 'gnus-article-emphasis)
310 (defface gnus-emphasis-highlight-words
311 '((t (:background "black" :foreground "yellow")))
312 "Face used for displaying highlighted words."
313 :group 'gnus-article-emphasis)
315 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
316 "Format for display of Date headers in article bodies.
317 See `format-time-string' for the possible values.
319 The variable can also be function, which should return a complete Date
320 header. The function is called with one argument, the time, which can
321 be fed to `format-time-string'."
322 :type '(choice string symbol)
323 :link '(custom-manual "(gnus)Article Date")
324 :group 'gnus-article-washing)
327 (autoload 'mail-extract-address-components "mail-extr"))
329 (defcustom gnus-save-all-headers t
330 "*If non-nil, don't remove any headers before saving."
331 :group 'gnus-article-saving
334 (defcustom gnus-prompt-before-saving 'always
335 "*This variable says how much prompting is to be done when saving articles.
336 If it is nil, no prompting will be done, and the articles will be
337 saved to the default files. If this variable is `always', each and
338 every article that is saved will be preceded by a prompt, even when
339 saving large batches of articles. If this variable is neither nil not
340 `always', there the user will be prompted once for a file name for
341 each invocation of the saving commands."
342 :group 'gnus-article-saving
343 :type '(choice (item always)
344 (item :tag "never" nil)
345 (sexp :tag "once" :format "%t\n" :value t)))
347 (defcustom gnus-saved-headers gnus-visible-headers
348 "Headers to keep if `gnus-save-all-headers' is nil.
349 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
350 If that variable is nil, however, all headers that match this regexp
351 will be kept while the rest will be deleted before saving."
352 :group 'gnus-article-saving
355 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
356 "A function to save articles in your favourite format.
357 The function must be interactively callable (in other words, it must
358 be an Emacs command).
360 Gnus provides the following functions:
362 * gnus-summary-save-in-rmail (Rmail format)
363 * gnus-summary-save-in-mail (Unix mail format)
364 * gnus-summary-save-in-folder (MH folder)
365 * gnus-summary-save-in-file (article format)
366 * gnus-summary-save-in-vm (use VM's folder format)
367 * gnus-summary-write-to-file (article format -- overwrite)."
368 :group 'gnus-article-saving
369 :type '(radio (function-item gnus-summary-save-in-rmail)
370 (function-item gnus-summary-save-in-mail)
371 (function-item gnus-summary-save-in-folder)
372 (function-item gnus-summary-save-in-file)
373 (function-item gnus-summary-save-in-vm)
374 (function-item gnus-summary-write-to-file)))
376 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
377 "A function generating a file name to save articles in Rmail format.
378 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
379 :group 'gnus-article-saving
382 (defcustom gnus-mail-save-name 'gnus-plain-save-name
383 "A function generating a file name to save articles in Unix mail format.
384 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
385 :group 'gnus-article-saving
388 (defcustom gnus-folder-save-name 'gnus-folder-save-name
389 "A function generating a file name to save articles in MH folder.
390 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
391 :group 'gnus-article-saving
394 (defcustom gnus-file-save-name 'gnus-numeric-save-name
395 "A function generating a file name to save articles in article format.
396 The function is called with NEWSGROUP, HEADERS, and optional
398 :group 'gnus-article-saving
401 (defcustom gnus-split-methods
402 '((gnus-article-archive-name)
403 (gnus-article-nndoc-name))
404 "*Variable used to suggest where articles are to be saved.
405 For instance, if you would like to save articles related to Gnus in
406 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
407 you could set this variable to something like:
409 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
410 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
412 This variable is an alist where the where the key is the match and the
413 value is a list of possible files to save in if the match is non-nil.
415 If the match is a string, it is used as a regexp match on the
416 article. If the match is a symbol, that symbol will be funcalled
417 from the buffer of the article to be saved with the newsgroup as the
418 parameter. If it is a list, it will be evaled in the same buffer.
420 If this form or function returns a string, this string will be used as
421 a possible file name; and if it returns a non-nil list, that list will
422 be used as possible file names."
423 :group 'gnus-article-saving
424 :type '(repeat (choice (list :value (fun) function)
425 (cons :value ("" "") regexp (repeat string))
428 (defcustom gnus-article-display-method-for-mime
429 'gnus-article-display-mime-message
430 "Function to display a MIME message.
431 The function is called from the article buffer."
432 :group 'gnus-article-mime
435 (defcustom gnus-article-display-method-for-traditional
436 'gnus-article-display-traditional-message
437 "*Function to display a traditional message.
438 The function is called from the article buffer."
439 :group 'gnus-article-mime
442 (defcustom gnus-page-delimiter "^\^L"
443 "*Regexp describing what to use as article page delimiters.
444 The default value is \"^\^L\", which is a form linefeed at the
445 beginning of a line."
447 :group 'gnus-article-various)
449 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
450 "*The format specification for the article mode line.
451 See `gnus-summary-mode-line-format' for a closer description.
453 The following additional specs are available:
455 %w The article washing status.
456 %m The number of MIME parts in the article."
458 :group 'gnus-article-various)
460 (defcustom gnus-article-mode-hook nil
461 "*A hook for Gnus article mode."
463 :group 'gnus-article-various)
465 (defcustom gnus-article-menu-hook nil
466 "*Hook run after the creation of the article mode menu."
468 :group 'gnus-article-various)
470 (defcustom gnus-article-prepare-hook nil
471 "*A hook called after an article has been prepared in the article buffer."
473 :group 'gnus-article-various)
475 (defcustom gnus-article-hide-pgp-hook nil
476 "*A hook called after successfully hiding a PGP signature."
478 :group 'gnus-article-various)
480 (defcustom gnus-article-button-face 'bold
481 "Face used for highlighting buttons in the article buffer.
483 An article button is a piece of text that you can activate by pressing
484 `RET' or `mouse-2' above it."
486 :group 'gnus-article-buttons)
488 (defcustom gnus-article-mouse-face 'highlight
489 "Face used for mouse highlighting in the article buffer.
491 Article buttons will be displayed in this face when the cursor is
494 :group 'gnus-article-buttons)
496 (defcustom gnus-signature-face 'gnus-signature-face
497 "Face used for highlighting a signature in the article buffer.
498 Obsolete; use the face `gnus-signature-face' for customizations instead."
500 :group 'gnus-article-highlight
501 :group 'gnus-article-signature)
503 (defface gnus-signature-face
505 "Face used for highlighting a signature in the article buffer."
506 :group 'gnus-article-highlight
507 :group 'gnus-article-signature)
509 (defface gnus-header-from-face
512 (:foreground "spring green"))
515 (:foreground "red3"))
518 "Face used for displaying from headers."
519 :group 'gnus-article-headers
520 :group 'gnus-article-highlight)
522 (defface gnus-header-subject-face
525 (:foreground "SeaGreen3"))
528 (:foreground "red4"))
530 (:bold t :italic t)))
531 "Face used for displaying subject headers."
532 :group 'gnus-article-headers
533 :group 'gnus-article-highlight)
535 (defface gnus-header-newsgroups-face
538 (:foreground "yellow" :italic t))
541 (:foreground "MidnightBlue" :italic t))
544 "Face used for displaying newsgroups headers."
545 :group 'gnus-article-headers
546 :group 'gnus-article-highlight)
548 (defface gnus-header-name-face
551 (:foreground "SeaGreen"))
554 (:foreground "maroon"))
557 "Face used for displaying header names."
558 :group 'gnus-article-headers
559 :group 'gnus-article-highlight)
561 (defface gnus-header-content-face
564 (:foreground "forest green" :italic t))
567 (:foreground "indianred4" :italic t))
569 (:italic t))) "Face used for displaying header content."
570 :group 'gnus-article-headers
571 :group 'gnus-article-highlight)
573 (defcustom gnus-header-face-alist
574 '(("From" nil gnus-header-from-face)
575 ("Subject" nil gnus-header-subject-face)
576 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
577 ("" gnus-header-name-face gnus-header-content-face))
578 "*Controls highlighting of article header.
580 An alist of the form (HEADER NAME CONTENT).
582 HEADER is a regular expression which should match the name of an
583 header header and NAME and CONTENT are either face names or nil.
585 The name of each header field will be displayed using the face
586 specified by the first element in the list where HEADER match the
587 header name and NAME is non-nil. Similarly, the content will be
588 displayed by the first non-nil matching CONTENT face."
589 :group 'gnus-article-headers
590 :group 'gnus-article-highlight
591 :type '(repeat (list (regexp :tag "Header")
593 (item :tag "skip" nil)
594 (face :value default))
595 (choice :tag "Content"
596 (item :tag "skip" nil)
597 (face :value default)))))
599 (defcustom gnus-article-decode-hook nil
600 "*Hook run to decode charsets in articles."
601 :group 'gnus-article-headers
604 (defcustom gnus-display-mime-function 'gnus-display-mime
605 "Function to display MIME articles."
606 :group 'gnus-article-mime
609 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
610 "Function used to decode headers.")
612 (defvar gnus-article-dumbquotes-map
630 "Table for MS-to-Latin1 translation.")
632 (defcustom gnus-ignored-mime-types nil
633 "List of MIME types that should be ignored by Gnus."
634 :group 'gnus-article-mime
635 :type '(repeat regexp))
637 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
638 "List of MIME types that should not be given buttons when rendered inline."
639 :group 'gnus-article-mime
640 :type '(repeat regexp))
642 (defcustom gnus-article-mime-part-function nil
643 "Function called with a MIME handle as the argument.
644 This is meant for people who want to do something automatic based
645 on parts -- for instance, adding Vcard info to a database."
646 :group 'gnus-article-mime
649 (defcustom gnus-mime-multipart-functions nil
650 "An alist of MIME types to functions to display them.")
652 (defcustom gnus-article-date-lapsed-new-header nil
653 "Whether the X-Sent and Date headers can coexist.
654 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
655 either replace the old \"Date:\" header (if this variable is nil), or
656 be added below it (otherwise)."
657 :group 'gnus-article-headers
660 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
661 "Function called with a MIME handle as the argument.
662 This is meant for people who want to view first matched part.
663 For `undisplayed-alternative' (default), the first undisplayed
664 part or alternative part is used. For `undisplayed', the first
665 undisplayed part is used. For a function, the first part which
666 the function return `t' is used. For `nil', the first part is
668 :group 'gnus-article-mime
670 (item :tag "first" :value nil)
671 (item :tag "undisplayed" :value undisplayed)
672 (item :tag "undisplayed or alternative"
673 :value undisplayed-alternative)
677 ;;; The treatment variables
680 (defvar gnus-part-display-hook nil
681 "Hook called on parts that are to receive treatment.")
683 (defvar gnus-article-treat-custom
684 '(choice (const :tag "Off" nil)
686 (const :tag "Header" head)
687 (const :tag "Last" last)
688 (const :tag "Mime" mime)
689 (integer :tag "Less")
690 (repeat :tag "Groups" regexp)
691 (sexp :tag "Predicate")))
693 (defvar gnus-article-treat-head-custom
694 '(choice (const :tag "Off" nil)
695 (const :tag "Header" head)))
697 (defvar gnus-article-treat-types '("text/plain")
700 (defvar gnus-inhibit-treatment nil
701 "Whether to inhibit treatment.")
703 (defcustom gnus-treat-highlight-signature '(or last (typep "text/x-vcard"))
704 "Highlight the signature.
705 Valid values are nil, t, `head', `last', an integer or a predicate.
706 See the manual for details."
707 :group 'gnus-article-treat
708 :type gnus-article-treat-custom)
709 (put 'gnus-treat-highlight-signature 'highlight t)
711 (defcustom gnus-treat-buttonize 100000
713 Valid values are nil, t, `head', `last', an integer or a predicate.
714 See the manual for details."
715 :group 'gnus-article-treat
716 :type gnus-article-treat-custom)
717 (put 'gnus-treat-buttonize 'highlight t)
719 (defcustom gnus-treat-buttonize-head 'head
720 "Add buttons to the head.
721 Valid values are nil, t, `head', `last', an integer or a predicate.
722 See the manual for details."
723 :group 'gnus-article-treat
724 :type gnus-article-treat-head-custom)
725 (put 'gnus-treat-buttonize-head 'highlight t)
727 (defcustom gnus-treat-emphasize nil
729 Valid values are nil, t, `head', `last', an integer or a predicate.
730 See the manual for details."
731 :group 'gnus-article-treat
732 :type gnus-article-treat-custom)
733 (put 'gnus-treat-emphasize 'highlight t)
735 (defcustom gnus-treat-strip-cr nil
736 "Remove carriage returns.
737 Valid values are nil, t, `head', `last', an integer or a predicate.
738 See the manual for details."
739 :group 'gnus-article-treat
740 :type gnus-article-treat-custom)
742 (defcustom gnus-treat-hide-headers 'head
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-head-custom)
749 (defcustom gnus-treat-hide-boring-headers nil
750 "Hide boring headers.
751 Valid values are nil, t, `head', `last', an integer or a predicate.
752 See the manual for details."
753 :group 'gnus-article-treat
754 :type gnus-article-treat-head-custom)
756 (defcustom gnus-treat-hide-signature nil
758 Valid values are nil, t, `head', `last', an integer or a predicate.
759 See the manual for details."
760 :group 'gnus-article-treat
761 :type gnus-article-treat-custom)
763 (defcustom gnus-treat-fill-article nil
765 Valid values are nil, t, `head', `last', an integer or a predicate.
766 See the manual for details."
767 :group 'gnus-article-treat
768 :type gnus-article-treat-custom)
770 (defcustom gnus-treat-hide-citation nil
772 Valid values are nil, t, `head', `last', an integer or a predicate.
773 See the manual for details."
774 :group 'gnus-article-treat
775 :type gnus-article-treat-custom)
777 (defcustom gnus-treat-strip-list-identifiers 'head
778 "Strip list identifiers from `gnus-list-identifiers`.
779 Valid values are nil, t, `head', `last', an integer or a predicate.
780 See the manual for details."
781 :group 'gnus-article-treat
782 :type gnus-article-treat-custom)
784 (defcustom gnus-treat-strip-pgp t
785 "Strip PGP signatures.
786 Valid values are nil, t, `head', `last', an integer or a predicate.
787 See the manual for details."
788 :group 'gnus-article-treat
789 :type gnus-article-treat-custom)
791 (defcustom gnus-treat-strip-pem nil
792 "Strip PEM signatures.
793 Valid values are nil, t, `head', `last', an integer or a predicate.
794 See the manual for details."
795 :group 'gnus-article-treat
796 :type gnus-article-treat-custom)
798 (defcustom gnus-treat-strip-banner t
799 "Strip banners from articles.
800 The banner to be stripped is specified in the `banner' group parameter.
801 Valid values are nil, t, `head', `last', an integer or a predicate.
802 See the manual for details."
803 :group 'gnus-article-treat
804 :type gnus-article-treat-custom)
806 (defcustom gnus-treat-highlight-headers 'head
807 "Highlight the headers.
808 Valid values are nil, t, `head', `last', an integer or a predicate.
809 See the manual for details."
810 :group 'gnus-article-treat
811 :type gnus-article-treat-head-custom)
812 (put 'gnus-treat-highlight-headers 'highlight t)
814 (defcustom gnus-treat-highlight-citation t
815 "Highlight cited text.
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)
820 (put 'gnus-treat-highlight-citation 'highlight t)
822 (defcustom gnus-treat-date-ut nil
823 "Display the Date in UT (GMT).
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-head-custom)
829 (defcustom gnus-treat-date-local nil
830 "Display the Date in the local timezone.
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)
836 (defcustom gnus-treat-date-lapsed nil
837 "Display the Date header in a way that says how much time has elapsed.
838 Valid values are nil, t, `head', `last', an integer or a predicate.
839 See the manual for details."
840 :group 'gnus-article-treat
841 :type gnus-article-treat-head-custom)
843 (defcustom gnus-treat-date-original nil
844 "Display the date in the original timezone.
845 Valid values are nil, t, `head', `last', an integer or a predicate.
846 See the manual for details."
847 :group 'gnus-article-treat
848 :type gnus-article-treat-head-custom)
850 (defcustom gnus-treat-date-iso8601 nil
851 "Display the date in the ISO8601 format.
852 Valid values are nil, t, `head', `last', an integer or a predicate.
853 See the manual for details."
854 :group 'gnus-article-treat
855 :type gnus-article-treat-head-custom)
857 (defcustom gnus-treat-date-user-defined nil
858 "Display the date in a user-defined format.
859 The format is defined by the `gnus-article-time-format' variable.
860 Valid values are nil, t, `head', `last', an integer or a predicate.
861 See the manual for details."
862 :group 'gnus-article-treat
863 :type gnus-article-treat-head-custom)
865 (defcustom gnus-treat-strip-headers-in-body t
866 "Strip the X-No-Archive header line from the beginning of the body.
867 Valid values are nil, t, `head', `last', an integer or a predicate.
868 See the manual for details."
869 :group 'gnus-article-treat
870 :type gnus-article-treat-custom)
872 (defcustom gnus-treat-strip-trailing-blank-lines nil
873 "Strip trailing blank lines.
874 Valid values are nil, t, `head', `last', an integer or a predicate.
875 See the manual for details."
876 :group 'gnus-article-treat
877 :type gnus-article-treat-custom)
879 (defcustom gnus-treat-strip-leading-blank-lines nil
880 "Strip leading blank lines.
881 Valid values are nil, t, `head', `last', an integer or a predicate.
882 See the manual for details."
883 :group 'gnus-article-treat
884 :type gnus-article-treat-custom)
886 (defcustom gnus-treat-strip-multiple-blank-lines nil
887 "Strip multiple blank lines.
888 Valid values are nil, t, `head', `last', an integer or a predicate.
889 See the manual for details."
890 :group 'gnus-article-treat
891 :type gnus-article-treat-custom)
893 (defcustom gnus-treat-overstrike t
894 "Treat overstrike highlighting.
895 Valid values are nil, t, `head', `last', an integer or a predicate.
896 See the manual for details."
897 :group 'gnus-article-treat
898 :type gnus-article-treat-custom)
899 (put 'gnus-treat-overstrike 'highlight t)
901 (defcustom gnus-treat-display-xface
902 (if (or (and gnus-xemacs (featurep 'xface))
903 (eq 'x-face-mule-gnus-article-display-x-face
904 gnus-article-x-face-command))
907 "Display X-Face headers.
908 Valid values are nil, t, `head', `last', an integer or a predicate.
909 See the manual for details."
910 :group 'gnus-article-treat
911 :type gnus-article-treat-head-custom)
912 (put 'gnus-treat-display-xface 'highlight t)
914 (defcustom gnus-treat-display-smileys
915 (if (or (and gnus-xemacs (featurep 'xpm))
916 (and (not gnus-xemacs)
918 (module-installed-p 'gnus-bitmap)))
922 Valid values are nil, t, `head', `last', an integer or a predicate.
923 See the manual for details."
924 :group 'gnus-article-treat
925 :type gnus-article-treat-custom)
926 (put 'gnus-treat-display-smileys 'highlight t)
928 (defcustom gnus-treat-display-picons (if gnus-xemacs 'head nil)
930 Valid values are nil, t, `head', `last', an integer or a predicate.
931 See the manual for details."
932 :group 'gnus-article-treat
933 :type gnus-article-treat-head-custom)
934 (put 'gnus-treat-display-picons 'highlight t)
936 (defcustom gnus-treat-capitalize-sentences nil
937 "Capitalize sentence-starting words.
938 Valid values are nil, t, `head', `last', an integer or a predicate.
939 See the manual for details."
940 :group 'gnus-article-treat
941 :type gnus-article-treat-custom)
943 (defcustom gnus-treat-fill-long-lines nil
945 Valid values are nil, t, `head', `last', an integer or a predicate.
946 See the manual for details."
947 :group 'gnus-article-treat
948 :type gnus-article-treat-custom)
950 (defcustom gnus-treat-play-sounds nil
952 Valid values are nil, t, `head', `last', an integer or a predicate.
953 See the manual for details."
954 :group 'gnus-article-treat
955 :type gnus-article-treat-custom)
957 (defcustom gnus-treat-decode-article-as-default-mime-charset nil
958 "Decode an article as `default-mime-charset'. For instance, if you want to
959 attempt to decode an article even if the value of `gnus-show-mime' is nil,
960 you could set this variable to something like: nil for don't decode, t for
961 decode the body, '(or header t) for the whole article, etc."
962 :group 'gnus-article-treat
963 :type '(radio (const :tag "Off" nil)
964 (const :tag "Decode body" t)
965 (const :tag "Decode all" (or head t))))
967 (defcustom gnus-treat-translate nil
968 "Translate articles from one language to another.
969 Valid values are nil, t, `head', `last', an integer or a predicate.
970 See the manual for details."
971 :group 'gnus-article-treat
972 :type gnus-article-treat-custom)
974 ;;; Internal variables
976 (defvar article-goto-body-goes-to-point-min-p nil)
977 (defvar gnus-article-wash-types nil)
978 (defvar gnus-article-emphasis-alist nil)
980 (defvar gnus-article-mime-handle-alist-1 nil)
981 (defvar gnus-treatment-function-alist
982 '((gnus-treat-decode-article-as-default-mime-charset
983 gnus-article-decode-article-as-default-mime-charset)
984 (gnus-treat-strip-banner gnus-article-strip-banner)
985 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
986 (gnus-treat-buttonize gnus-article-add-buttons)
987 (gnus-treat-fill-article gnus-article-fill-cited-article)
988 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
989 (gnus-treat-strip-cr gnus-article-remove-cr)
990 (gnus-treat-display-xface gnus-article-display-x-face)
991 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
992 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
993 (gnus-treat-hide-signature gnus-article-hide-signature)
994 (gnus-treat-hide-citation gnus-article-hide-citation)
995 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
996 (gnus-treat-strip-pgp gnus-article-hide-pgp)
997 (gnus-treat-strip-pem gnus-article-hide-pem)
998 (gnus-treat-highlight-headers gnus-article-highlight-headers)
999 (gnus-treat-emphasize gnus-article-emphasize)
1000 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1001 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1002 (gnus-treat-date-ut gnus-article-date-ut)
1003 (gnus-treat-date-local gnus-article-date-local)
1004 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1005 (gnus-treat-date-original gnus-article-date-original)
1006 (gnus-treat-date-user-defined gnus-article-date-user)
1007 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1008 (gnus-treat-strip-trailing-blank-lines
1009 gnus-article-remove-trailing-blank-lines)
1010 (gnus-treat-strip-leading-blank-lines
1011 gnus-article-strip-leading-blank-lines)
1012 (gnus-treat-strip-multiple-blank-lines
1013 gnus-article-strip-multiple-blank-lines)
1014 (gnus-treat-overstrike gnus-article-treat-overstrike)
1015 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1016 (gnus-treat-display-smileys gnus-article-smiley-display)
1017 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1018 (gnus-treat-display-picons gnus-article-display-picons)
1019 (gnus-treat-play-sounds gnus-earcon-display)))
1021 (defvar gnus-article-mime-handle-alist nil)
1022 (defvar article-lapsed-timer nil)
1023 (defvar gnus-article-current-summary nil)
1025 (defvar gnus-article-mode-syntax-table
1026 (let ((table (copy-syntax-table text-mode-syntax-table)))
1027 (modify-syntax-entry ?- "w" table)
1028 (modify-syntax-entry ?> ")" table)
1029 (modify-syntax-entry ?< "(" table)
1031 "Syntax table used in article mode buffers.
1032 Initialized from `text-mode-syntax-table.")
1034 (defvar gnus-save-article-buffer nil)
1036 (defvar gnus-article-mode-line-format-alist
1037 (nconc '((?w (gnus-article-wash-status) ?s)
1038 (?m (gnus-article-mime-part-status) ?s))
1039 gnus-summary-mode-line-format-alist))
1041 (defvar gnus-number-of-articles-to-be-saved nil)
1043 (defvar gnus-inhibit-hiding nil)
1045 (defsubst gnus-article-hide-text (b e props)
1046 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1047 (add-text-properties b e props)
1048 (when (memq 'intangible props)
1050 (max (1- b) (point-min))
1051 b 'intangible (cddr (memq 'intangible props)))))
1052 (defsubst gnus-article-unhide-text (b e)
1053 "Remove hidden text properties from region between B and E."
1054 (remove-text-properties b e gnus-hidden-properties)
1055 (when (memq 'intangible gnus-hidden-properties)
1056 (put-text-property (max (1- b) (point-min))
1057 b 'intangible nil)))
1059 (defun gnus-article-hide-text-type (b e type)
1060 "Hide text of TYPE between B and E."
1061 (push type gnus-article-wash-types)
1062 (gnus-article-hide-text
1063 b e (cons 'article-type (cons type gnus-hidden-properties))))
1065 (defun gnus-article-unhide-text-type (b e type)
1066 "Unhide text of TYPE between B and E."
1067 (setq gnus-article-wash-types
1068 (delq type gnus-article-wash-types))
1069 (remove-text-properties
1070 b e (cons 'article-type (cons type gnus-hidden-properties)))
1071 (when (memq 'intangible gnus-hidden-properties)
1072 (put-text-property (max (1- b) (point-min))
1073 b 'intangible nil)))
1075 (defun gnus-article-hide-text-of-type (type)
1076 "Hide text of TYPE in the current buffer."
1078 (let ((b (point-min))
1080 (while (setq b (text-property-any b e 'article-type type))
1081 (add-text-properties b (incf b) gnus-hidden-properties)))))
1083 (defun gnus-article-delete-text-of-type (type)
1084 "Delete text of TYPE in the current buffer."
1086 (let ((b (point-min)))
1087 (while (setq b (text-property-any b (point-max) 'article-type type))
1089 b (or (text-property-not-all b (point-max) 'article-type type)
1092 (defun gnus-article-delete-invisible-text ()
1093 "Delete all invisible text in the current buffer."
1095 (let ((b (point-min)))
1096 (while (setq b (text-property-any b (point-max) 'invisible t))
1098 b (or (text-property-not-all b (point-max) 'invisible t)
1101 (defun gnus-article-text-type-exists-p (type)
1102 "Say whether any text of type TYPE exists in the buffer."
1103 (text-property-any (point-min) (point-max) 'article-type type))
1105 (defsubst gnus-article-header-rank ()
1106 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1107 (let ((list gnus-sorted-header-list)
1110 (when (looking-at (car list))
1112 (setq list (cdr list))
1116 (defun article-hide-headers (&optional arg delete)
1117 "Hide unwanted headers and possibly sort them as well."
1118 (interactive (gnus-article-hidden-arg))
1119 ;; Lars said that this function might be inhibited.
1120 (if (gnus-article-check-hidden-text 'headers arg)
1122 ;; Show boring headers as well.
1123 (gnus-article-show-hidden-text 'boring-headers)
1124 (when (eq 1 (point-min))
1125 (set-window-start (get-buffer-window (current-buffer)) 1)))
1126 (unless gnus-inhibit-hiding
1129 (let ((buffer-read-only nil)
1130 (inhibit-read-only t)
1131 (case-fold-search t)
1132 (max (1+ (length gnus-sorted-header-list)))
1133 (ignored (when (not gnus-visible-headers)
1134 (cond ((stringp gnus-ignored-headers)
1135 gnus-ignored-headers)
1136 ((listp gnus-ignored-headers)
1137 (mapconcat 'identity gnus-ignored-headers
1140 (cond ((stringp gnus-visible-headers)
1141 gnus-visible-headers)
1142 ((and gnus-visible-headers
1143 (listp gnus-visible-headers))
1144 (mapconcat 'identity gnus-visible-headers "\\|"))))
1145 (inhibit-point-motion-hooks t)
1147 ;; First we narrow to just the headers.
1148 (article-narrow-to-head)
1149 ;; Hide any "From " lines at the beginning of (mail) articles.
1150 (while (looking-at "From ")
1154 (delete-region (point-min) (point))
1155 (gnus-article-hide-text (point-min) (point)
1156 (nconc (list 'article-type 'headers)
1157 gnus-hidden-properties))))
1158 ;; Then treat the rest of the header lines.
1159 ;; Then we use the two regular expressions
1160 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1161 ;; select which header lines is to remain visible in the
1163 (while (re-search-forward "^[^ \t]*:" nil t)
1165 ;; Mark the rank of the header.
1167 (point) (1+ (point)) 'message-rank
1168 (if (or (and visible (looking-at visible))
1170 (not (looking-at ignored))))
1171 (gnus-article-header-rank)
1174 (message-sort-headers-1)
1175 (when (setq beg (text-property-any
1176 (point-min) (point-max) 'message-rank (+ 2 max)))
1177 ;; We delete or make invisible the unwanted headers.
1178 (push 'headers gnus-article-wash-types)
1181 (add-text-properties
1182 (point-min) (+ 5 (point-min))
1183 '(article-type headers dummy-invisible t))
1184 (delete-region beg (point-max)))
1185 (gnus-article-hide-text-type beg (point-max) 'headers))))))))
1188 (defun article-hide-boring-headers (&optional arg)
1189 "Toggle hiding of headers that aren't very interesting.
1190 If given a negative prefix, always show; if given a positive prefix,
1192 (interactive (gnus-article-hidden-arg))
1193 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1194 (not gnus-show-all-headers))
1197 (let ((buffer-read-only nil)
1198 (list gnus-boring-article-headers)
1199 (inhibit-point-motion-hooks t)
1201 (article-narrow-to-head)
1203 (setq elem (pop list))
1204 (goto-char (point-min))
1206 ;; Hide empty headers.
1208 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1210 (gnus-article-hide-text-type
1211 (progn (beginning-of-line) (point))
1214 (if (re-search-forward "^[^ \t]" nil t)
1218 ;; Hide boring Newsgroups header.
1219 ((eq elem 'newsgroups)
1220 (when (equal (gnus-fetch-field "newsgroups")
1221 (gnus-group-real-name
1222 (if (boundp 'gnus-newsgroup-name)
1225 (gnus-article-hide-header "newsgroups")))
1226 ((eq elem 'followup-to)
1227 (when (equal (message-fetch-field "followup-to")
1228 (message-fetch-field "newsgroups"))
1229 (gnus-article-hide-header "followup-to")))
1230 ((eq elem 'reply-to)
1231 (let ((from (message-fetch-field "from"))
1232 (reply-to (message-fetch-field "reply-to")))
1237 (nth 1 (funcall gnus-extract-address-components from))
1238 (nth 1 (funcall gnus-extract-address-components reply-to)))))
1239 (gnus-article-hide-header "reply-to"))))
1241 (let ((date (message-fetch-field "date")))
1243 (< (days-between (current-time-string) date)
1245 (gnus-article-hide-header "date"))))
1247 (let ((to (message-fetch-field "to"))
1248 (cc (message-fetch-field "cc")))
1249 (when (> (length to) 1024)
1250 (gnus-article-hide-header "to"))
1251 (when (> (length cc) 1024)
1252 (gnus-article-hide-header "cc"))))
1256 (goto-char (point-min))
1257 (while (re-search-forward "^to:" nil t)
1258 (setq to-count (1+ to-count)))
1259 (when (> to-count 1)
1260 (while (> to-count 0)
1261 (goto-char (point-min))
1263 (re-search-forward "^to:" nil nil to-count)
1265 (narrow-to-region (point) (point-max))
1266 (gnus-article-hide-header "to"))
1267 (setq to-count (1- to-count))))
1268 (goto-char (point-min))
1269 (while (re-search-forward "^cc:" nil t)
1270 (setq cc-count (1+ cc-count)))
1271 (when (> cc-count 1)
1272 (while (> cc-count 0)
1273 (goto-char (point-min))
1275 (re-search-forward "^cc:" nil nil cc-count)
1277 (narrow-to-region (point) (point-max))
1278 (gnus-article-hide-header "cc"))
1279 (setq cc-count (1- cc-count)))))))))))))
1281 (defun gnus-article-hide-header (header)
1283 (goto-char (point-min))
1284 (when (re-search-forward (concat "^" header ":") nil t)
1285 (gnus-article-hide-text-type
1286 (progn (beginning-of-line) (point))
1289 (if (re-search-forward "^[^ \t]" nil t)
1294 (defun article-toggle-headers (&optional arg)
1295 "Toggle hiding of headers. If given a negative prefix, always show;
1296 if given a positive prefix, always hide."
1297 (interactive (gnus-article-hidden-arg))
1298 (let ((force (when (numberp arg)
1299 (cond ((> arg 0) 'always-hide)
1300 ((< arg 0) 'always-show))))
1301 (window (get-buffer-window gnus-article-buffer))
1302 (header-end (point-min))
1303 header-start field-end field-start
1304 (inhibit-point-motion-hooks t)
1305 (inhibit-read-only t)
1309 (while (and (setq header-start
1310 (text-property-any header-end (point-max)
1311 'article-treated-header t))
1313 (text-property-not-all header-start (point-max)
1314 'article-treated-header t)))
1315 (setq field-end header-start)
1317 (;; Hide exposed invisible fields.
1318 (and (not (eq 'always-show force))
1320 (text-property-any field-end header-end
1321 'exposed-invisible-field t)))
1322 (while (and field-start
1323 (setq field-end (text-property-not-all
1324 field-start header-end
1325 'exposed-invisible-field t)))
1326 (add-text-properties field-start field-end gnus-hidden-properties)
1327 (setq field-start (text-property-any field-end header-end
1328 'exposed-invisible-field t)))
1329 (put-text-property header-start header-end
1330 'exposed-invisible-field nil))
1331 (;; Expose invisible fields.
1332 (and (not (eq 'always-hide force))
1334 (text-property-any field-end header-end 'invisible t)))
1335 (while (and field-start
1336 (setq field-end (text-property-not-all
1337 field-start header-end
1339 ;; If the invisible text is not terminated with newline, we
1340 ;; won't expose it. Because it may be created by x-face-mule.
1341 ;; BTW, XEmacs sometimes fail in putting a invisible text
1342 ;; property with `gnus-article-hide-text' (really?). In that
1343 ;; case, the invisible text might be started from the middle of
1344 ;; a line so we will expose the sort of thing.
1345 (when (or (not (or (eq header-start field-start)
1346 (eq ?\n (char-before field-start))))
1347 (eq ?\n (char-before field-end)))
1348 (remove-text-properties field-start field-end
1349 gnus-hidden-properties)
1350 (put-text-property field-start field-end
1351 'exposed-invisible-field t))
1352 (setq field-start (text-property-any field-end header-end
1355 (not (eq 'always-show force))
1356 (narrow-to-region header-start header-end)
1357 (article-hide-headers)
1358 ;; Re-display X-Face image under XEmacs.
1359 (when (and gnus-xemacs
1360 (gnus-functionp gnus-article-x-face-command))
1361 (let ((func (cadr (assq 'gnus-treat-display-xface
1362 gnus-treatment-function-alist)))
1364 (when (and (not gnus-inhibit-treatment)
1366 (gnus-treat-predicate gnus-treat-display-xface))
1368 (put-text-property header-start header-end 'read-only nil))))
1371 (goto-char (point-min))
1373 (set-window-start window (point-min))))))
1375 (defvar gnus-article-normalized-header-length 40
1376 "Length of normalized headers.")
1378 (defun article-normalize-headers ()
1379 "Make all header lines 40 characters long."
1381 (let ((buffer-read-only nil)
1385 (article-narrow-to-head)
1388 ((< (setq column (- (gnus-point-at-eol) (point)))
1389 gnus-article-normalized-header-length)
1391 (insert (make-string
1392 (- gnus-article-normalized-header-length column)
1394 ((> column gnus-article-normalized-header-length)
1395 (gnus-put-text-property
1397 (forward-char gnus-article-normalized-header-length)
1404 (forward-line 1))))))
1406 (defun article-treat-dumbquotes ()
1407 "Translate M******** sm*rtq**t*s into proper text.
1408 Note that this function guesses whether a character is a sm*rtq**t* or
1409 not, so it should only be used interactively."
1411 (article-translate-strings gnus-article-dumbquotes-map))
1413 (defun article-translate-characters (from to)
1414 "Translate all characters in the body of the article according to FROM and TO.
1415 FROM is a string of characters to translate from; to is a string of
1416 characters to translate to."
1418 (when (article-goto-body)
1419 (let ((buffer-read-only nil)
1420 (x (make-string 225 ?x))
1422 (while (< (incf i) (length x))
1425 (while (< i (length from))
1426 (aset x (aref from i) (aref to i))
1428 (translate-region (point) (point-max) x)))))
1430 (defun article-translate-strings (map)
1431 "Translate all string in the body of the article according to MAP.
1432 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1434 (when (article-goto-body)
1435 (let ((buffer-read-only nil)
1437 (while (setq elem (pop map))
1439 (while (search-forward (car elem) nil t)
1440 (replace-match (cadr elem)))))))))
1442 (defun article-treat-overstrike ()
1443 "Translate overstrikes into bold text."
1446 (when (article-goto-body)
1447 (let ((buffer-read-only nil))
1448 (while (search-forward "\b" nil t)
1449 (let ((next (char-after))
1453 previous (char-after))
1457 ;; We do the boldification/underlining by hiding the
1458 ;; overstrikes and putting the proper text property
1462 (gnus-article-hide-text-type start (point) 'overstrike)
1463 (put-text-property (point) end 'face 'bold))
1465 (gnus-article-hide-text-type
1466 (1- (point)) (1+ (point)) 'overstrike)
1468 start (1- (point)) 'face 'underline))
1470 (gnus-article-hide-text-type start (point) 'overstrike)
1472 (point) end 'face 'underline)))))))))
1474 (defun article-fill-long-lines ()
1475 "Fill lines that are wider than the window width."
1478 (let ((buffer-read-only nil)
1479 (width (window-width (get-buffer-window (current-buffer)))))
1482 (let ((adaptive-fill-mode nil))
1485 (when (>= (current-column) (min fill-column width))
1486 (narrow-to-region (point) (gnus-point-at-bol))
1487 (fill-paragraph nil)
1488 (goto-char (point-max))
1490 (forward-line 1)))))))
1492 (defun article-capitalize-sentences ()
1493 "Capitalize the first word in each sentence."
1496 (let ((buffer-read-only nil)
1497 (paragraph-start "^[\n\^L]"))
1501 (forward-sentence)))))
1503 (defun article-remove-cr ()
1504 "Remove trailing CRs and then translate remaining CRs into LFs."
1507 (let ((buffer-read-only nil))
1508 (goto-char (point-min))
1509 (while (re-search-forward "\r+$" nil t)
1510 (replace-match "" t t))
1511 (goto-char (point-min))
1512 (while (search-forward "\r" nil t)
1513 (replace-match "\n" t t)))))
1515 (defun article-remove-trailing-blank-lines ()
1516 "Remove all trailing blank lines from the article."
1519 (let ((buffer-read-only nil))
1520 (goto-char (point-max))
1524 (while (and (not (bobp))
1525 (looking-at "^[ \t]*$")
1526 (not (gnus-annotation-in-region-p
1527 (point) (gnus-point-at-eol))))
1532 (defun article-display-x-face (&optional force)
1533 "Look for an X-Face header and display it if present."
1534 (interactive (list 'force))
1536 ;; Delete the old process, if any.
1537 (when (process-status "article-x-face")
1538 (delete-process "article-x-face"))
1539 (let ((inhibit-point-motion-hooks t)
1540 (case-fold-search t)
1543 (article-narrow-to-head)
1544 (goto-char (point-min))
1545 (setq from (message-fetch-field "from"))
1546 (goto-char (point-min))
1547 (while (and gnus-article-x-face-command
1550 ;; Check whether this face is censored.
1551 (not gnus-article-x-face-too-ugly)
1552 (and gnus-article-x-face-too-ugly from
1553 (not (string-match gnus-article-x-face-too-ugly
1555 ;; Has to be present.
1556 (re-search-forward "^X-Face:[ \t]*" nil t))
1557 ;; This used to try to do multiple faces (`while' instead of
1558 ;; `when' above), but (a) sending multiple EOFs to xv doesn't
1559 ;; work (b) it can crash some versions of Emacs (c) are
1560 ;; multiple faces really something to encourage?
1561 (when (stringp gnus-article-x-face-command)
1563 ;; We now have the area of the buffer where the X-Face is stored.
1566 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
1567 ;; We display the face.
1568 (if (symbolp gnus-article-x-face-command)
1569 ;; The command is a lisp function, so we call it.
1570 (if (gnus-functionp gnus-article-x-face-command)
1571 (funcall gnus-article-x-face-command beg end)
1572 (error "%s is not a function" gnus-article-x-face-command))
1573 ;; The command is a string, so we interpret the command
1574 ;; as a, well, command, and fork it off.
1575 (let ((process-connection-type nil))
1576 (process-kill-without-query
1578 "article-x-face" nil shell-file-name shell-command-switch
1579 gnus-article-x-face-command))
1580 (process-send-region "article-x-face" beg end)
1581 (process-send-eof "article-x-face"))))))))))
1583 (defun article-decode-mime-words ()
1584 "Decode all MIME-encoded words in the article."
1587 (set-buffer gnus-article-buffer)
1588 (let ((inhibit-point-motion-hooks t)
1590 (mail-parse-charset gnus-newsgroup-charset)
1591 (mail-parse-ignored-charsets
1592 (save-excursion (set-buffer gnus-summary-buffer)
1593 gnus-newsgroup-ignored-charsets)))
1594 (mail-decode-encoded-word-region (point-min) (point-max)))))
1596 (defun article-decode-charset (&optional prompt)
1597 "Decode charset-encoded text in the article.
1598 If PROMPT (the prefix), prompt for a coding system to use."
1600 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
1602 (mail-parse-charset gnus-newsgroup-charset)
1603 (mail-parse-ignored-charsets
1604 (save-excursion (condition-case nil
1605 (set-buffer gnus-summary-buffer)
1607 gnus-newsgroup-ignored-charsets))
1608 ct cte ctl charset format)
1611 (article-narrow-to-head)
1612 (setq ct (message-fetch-field "Content-Type" t)
1613 cte (message-fetch-field "Content-Transfer-Encoding" t)
1614 ctl (and ct (ignore-errors
1615 (mail-header-parse-content-type ct)))
1618 (mm-read-coding-system "Charset to decode: "))
1620 (mail-content-type-get ctl 'charset)))
1621 format (and ctl (mail-content-type-get ctl 'format)))
1623 (setq cte (mail-header-strip cte)))
1624 (if (and ctl (not (string-match "/" (car ctl))))
1626 (goto-char (point-max)))
1629 (narrow-to-region (point) (point-max))
1630 (when (and (or (not ctl)
1631 (equal (car ctl) "text/plain"))
1632 (not format)) ;; article with format will decode later.
1634 charset (and cte (intern (downcase
1635 (gnus-strip-whitespace cte))))
1638 (defun article-decode-encoded-words ()
1639 "Remove encoded-word encoding from headers."
1640 (let (buffer-read-only)
1641 (let ((charset (save-excursion
1642 (set-buffer gnus-summary-buffer)
1643 default-mime-charset)))
1644 (mime-decode-header-in-buffer charset)
1647 (defun article-de-quoted-unreadable (&optional force)
1648 "Translate a quoted-printable-encoded article.
1649 If FORCE, decode the article whether it is marked as quoted-printable
1651 (interactive (list 'force))
1653 (let ((buffer-read-only nil)
1654 (type (gnus-fetch-field "content-transfer-encoding"))
1655 (charset gnus-newsgroup-charset))
1657 (and type (string-match "quoted-printable" (downcase type))))
1659 (quoted-printable-decode-region (point) (point-max) charset)))))
1661 (defun article-de-base64-unreadable (&optional force)
1662 "Translate a base64 article.
1663 If FORCE, decode the article whether it is marked as base64 not."
1664 (interactive (list 'force))
1666 (let ((buffer-read-only nil)
1667 (type (gnus-fetch-field "content-transfer-encoding"))
1668 (charset gnus-newsgroup-charset))
1670 (and type (string-match "quoted-printable" (downcase type))))
1673 (narrow-to-region (point) (point-max))
1674 (base64-decode-region (point-min) (point-max))
1675 (if (mm-coding-system-p charset)
1676 (mm-decode-coding-region (point-min) (point-max) charset)))))))
1681 (defun article-decode-HZ ()
1682 "Translate a HZ-encoded article."
1686 (let ((buffer-read-only nil))
1687 (rfc1843-decode-region (point-min) (point-max)))))
1689 (defun article-wash-html ()
1690 "Format an html article."
1693 (let ((buffer-read-only nil)
1694 (charset gnus-newsgroup-charset))
1696 (save-window-excursion
1698 (narrow-to-region (point) (point-max))
1700 (let ((w3-strict-width (window-width))
1701 (url-standalone-mode t))
1703 (w3-region (point-min) (point-max))
1706 (defun article-hide-list-identifiers ()
1707 "Remove list identifies from the Subject header.
1708 The `gnus-list-identifiers' variable specifies what to do."
1712 (let ((inhibit-point-motion-hooks t)
1714 (article-narrow-to-head)
1715 (let ((regexp (if (stringp gnus-list-identifiers) gnus-list-identifiers
1716 (mapconcat 'identity gnus-list-identifiers " *\\|"))))
1718 (goto-char (point-min))
1719 (when (re-search-forward
1720 (concat "^Subject: +\\(\\(\\(Re: +\\)?\\(" regexp
1721 " *\\)\\)+\\(Re: +\\)?\\)")
1723 (let ((s (or (match-string 3) (match-string 5))))
1724 (delete-region (match-beginning 1) (match-end 1))
1726 (goto-char (match-beginning 1))
1729 (defun article-hide-pgp ()
1730 "Remove any PGP headers and signatures in the current article."
1734 (let ((inhibit-point-motion-hooks t)
1735 buffer-read-only beg end)
1737 ;; Hide the "header".
1738 (when (re-search-forward "^-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
1739 (push 'pgp gnus-article-wash-types)
1740 (delete-region (match-beginning 0) (match-end 0))
1741 ;; Remove armor headers (rfc2440 6.2)
1742 (delete-region (point) (or (re-search-forward "^[ \t]*\n" nil t)
1745 ;; Hide the actual signature.
1746 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
1747 (setq end (1+ (match-beginning 0)))
1750 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
1752 ;; Perhaps we shouldn't hide to the end of the buffer
1753 ;; if there is no end to the signature?
1755 ;; Hide "- " PGP quotation markers.
1757 (narrow-to-region beg end)
1758 (goto-char (point-min))
1759 (while (re-search-forward "^- " nil t)
1761 (match-beginning 0) (match-end 0)))
1763 (gnus-run-hooks 'gnus-article-hide-pgp-hook))))))
1765 (defun article-hide-pem (&optional arg)
1766 "Toggle hiding of any PEM headers and signatures in the current article.
1767 If given a negative prefix, always show; if given a positive prefix,
1769 (interactive (gnus-article-hidden-arg))
1770 (unless (gnus-article-check-hidden-text 'pem arg)
1772 (let (buffer-read-only end)
1773 (goto-char (point-min))
1774 ;; Hide the horrendously ugly "header".
1775 (when (and (search-forward
1776 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
1778 (setq end (1+ (match-beginning 0))))
1779 (push 'pem gnus-article-wash-types)
1780 (gnus-article-hide-text-type
1782 (if (search-forward "\n\n" nil t)
1786 ;; Hide the trailer as well
1787 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
1789 (gnus-article-hide-text-type
1790 (match-beginning 0) (match-end 0) 'pem)))))))
1792 (defun article-strip-banner ()
1793 "Strip the banner specified by the `banner' group parameter."
1797 (let ((inhibit-point-motion-hooks t)
1798 (banner (gnus-group-get-parameter gnus-newsgroup-name 'banner))
1799 (gnus-signature-limit nil)
1800 buffer-read-only beg end)
1804 ((eq banner 'signature)
1805 (when (gnus-article-narrow-to-signature)
1808 (delete-region (point) (point-max))))
1810 (while (re-search-forward banner nil t)
1811 (delete-region (match-beginning 0) (match-end 0))))))))))
1813 (defun article-babel ()
1814 "Translate article using an online translation service."
1818 (set-buffer gnus-article-buffer)
1819 (when (article-goto-body)
1820 (let* ((buffer-read-only nil)
1823 (orig (buffer-substring start end))
1824 (trans (babel-as-string orig)))
1826 (narrow-to-region start end)
1827 (delete-region start end)
1830 (defun article-hide-signature (&optional arg)
1831 "Hide the signature in the current article.
1832 If given a negative prefix, always show; if given a positive prefix,
1834 (interactive (gnus-article-hidden-arg))
1840 (article-goto-body))
1841 (goto-char (point-min)))
1842 (unless (gnus-article-check-hidden-text 'signature arg)
1843 (let ((buffer-read-only nil)
1845 (while (setq button (text-property-any button (point-max)
1847 'gnus-signature-toggle))
1848 (setq button (text-property-not-all button (point-max)
1850 'gnus-signature-toggle))
1851 (when (and button (not (eobp)))
1852 (gnus-article-hide-text-type
1854 (next-single-property-change (1+ button) 'mime-view-entity
1858 (defun article-strip-headers-in-body ()
1859 "Strip offensive headers from bodies."
1863 (let ((case-fold-search t))
1864 (when (looking-at "x-no-archive:")
1865 (gnus-delete-line)))))
1867 (defun article-strip-leading-blank-lines ()
1868 "Remove all blank lines from the beginning of the article."
1871 (let ((inhibit-point-motion-hooks t)
1873 (when (article-goto-body)
1874 (while (and (not (eobp))
1875 (looking-at "[ \t]*$"))
1876 (gnus-delete-line))))))
1878 (defun article-narrow-to-head ()
1879 "Narrow the buffer to the head of the message.
1880 Point is left at the beginning of the narrowed-to region."
1882 (goto-char (point-min))
1883 (if (search-forward "\n\n" nil 1)
1886 (goto-char (point-min)))
1888 (defun article-goto-body ()
1889 "Place point at the start of the body."
1890 (goto-char (point-min))
1892 ;; This variable is only bound when dealing with separate
1894 (article-goto-body-goes-to-point-min-p
1896 ((search-forward "\n\n" nil t)
1899 (goto-char (point-max))
1902 (defun article-strip-multiple-blank-lines ()
1903 "Replace consecutive blank lines with one empty line."
1906 (let ((inhibit-point-motion-hooks t)
1908 ;; First make all blank lines empty.
1910 (while (re-search-forward "^[ \t]+$" nil t)
1911 (unless (gnus-annotation-in-region-p
1912 (match-beginning 0) (match-end 0))
1913 (replace-match "" nil t)))
1914 ;; Then replace multiple empty lines with a single empty line.
1916 (while (re-search-forward "\n\n\n+" nil t)
1917 (unless (gnus-annotation-in-region-p
1918 (match-beginning 0) (match-end 0))
1919 (replace-match "\n\n" t t))))))
1921 (defun article-strip-leading-space ()
1922 "Remove all white space from the beginning of the lines in the article."
1925 (let ((inhibit-point-motion-hooks t)
1928 (while (re-search-forward "^[ \t]+" nil t)
1929 (replace-match "" t t)))))
1931 (defun article-strip-trailing-space ()
1932 "Remove all white space from the end of the lines in the article."
1935 (let ((inhibit-point-motion-hooks t)
1938 (while (re-search-forward "[ \t]+$" nil t)
1939 (replace-match "" t t)))))
1941 (defun article-strip-blank-lines ()
1942 "Strip leading, trailing and multiple blank lines."
1944 (article-strip-leading-blank-lines)
1945 (article-remove-trailing-blank-lines)
1946 (article-strip-multiple-blank-lines))
1948 (defun article-strip-all-blank-lines ()
1949 "Strip all blank lines."
1952 (let ((inhibit-point-motion-hooks t)
1955 (while (re-search-forward "^[ \t]*\n" nil t)
1956 (replace-match "" t t)))))
1958 (defun gnus-article-narrow-to-signature ()
1959 "Narrow to the signature; return t if a signature is found, else nil."
1960 (let ((inhibit-point-motion-hooks t))
1961 (when (gnus-article-search-signature)
1963 ;; Check whether we have some limits to what we consider
1964 ;; to be a signature.
1965 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
1966 (list gnus-signature-limit)))
1968 (while (setq limit (pop limits))
1969 (if (or (and (integerp limit)
1970 (< (- (point-max) (point)) limit))
1972 (< (count-lines (point) (point-max)) limit))
1973 (and (gnus-functionp limit)
1975 (and (stringp limit)
1976 (not (re-search-forward limit nil t))))
1977 () ; This limit did not succeed.
1981 (narrow-to-region (point) (point-max))
1984 (defun gnus-article-search-signature ()
1985 "Search the current buffer for the signature separator.
1986 Put point at the beginning of the signature separator."
1987 (let ((cur (point)))
1988 (goto-char (point-max))
1989 (if (if (stringp gnus-signature-separator)
1990 (re-search-backward gnus-signature-separator nil t)
1991 (let ((seps gnus-signature-separator))
1993 (not (re-search-backward (car seps) nil t)))
2000 (defun gnus-article-hidden-arg ()
2001 "Return the current prefix arg as a number, or 0 if no prefix."
2002 (list (if current-prefix-arg
2003 (prefix-numeric-value current-prefix-arg)
2006 (defun gnus-article-check-hidden-text (type arg)
2007 "Return nil if hiding is necessary.
2008 Arg can be nil or a number. Nil and positive means hide, negative
2009 means show, 0 means toggle."
2012 (let ((hide (gnus-article-hidden-text-p type)))
2018 (gnus-article-show-hidden-text type))
2020 (if (eq hide 'hidden)
2021 (gnus-article-show-hidden-text type)
2024 (defun gnus-article-hidden-text-p (type)
2025 "Say whether the current buffer contains hidden text of type TYPE."
2026 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2028 (not (get-text-property pos 'invisible))
2029 (not (get-text-property pos 'dummy-invisible)))
2031 (text-property-any (1+ pos) (point-max) 'article-type type)))
2036 (defun gnus-article-show-hidden-text (type &optional hide)
2037 "Show all hidden text of type TYPE.
2038 If HIDE, hide the text instead."
2040 (let ((buffer-read-only nil)
2041 (inhibit-point-motion-hooks t)
2044 (while (setq beg (text-property-any end (point-max) 'article-type type))
2047 (text-property-not-all beg (point-max) 'article-type type)
2050 (gnus-article-hide-text beg end gnus-hidden-properties)
2051 (gnus-article-unhide-text beg end))
2055 (defconst article-time-units
2056 `((year . ,(* 365.25 24 60 60))
2057 (week . ,(* 7 24 60 60))
2058 (day . ,(* 24 60 60))
2062 "Mapping from time units to seconds.")
2064 (defun article-date-ut (&optional type highlight header)
2065 "Convert DATE date to universal time in the current article.
2066 If TYPE is `local', convert to local time; if it is `lapsed', output
2067 how much time has lapsed since DATE. For `lapsed', the value of
2068 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2069 should replace the \"Date:\" one, or should be added below it."
2070 (interactive (list 'ut t))
2071 (let* ((header (or header
2072 (and (eq 1 (point-min))
2073 (mail-header-date (save-excursion
2074 (set-buffer gnus-summary-buffer)
2075 gnus-current-headers)))
2076 (message-fetch-field "date")
2078 (date (if (vectorp header) (mail-header-date header)
2080 (inhibit-point-motion-hooks t)
2081 bface eface date-pos)
2082 (when (and date (not (string= date "")))
2085 (article-narrow-to-head)
2086 (when (or (and (eq type 'lapsed)
2087 gnus-article-date-lapsed-new-header
2088 ;; Attempt to get the face of X-Sent first.
2089 (re-search-forward "^X-Sent:[ \t]" nil t))
2090 (re-search-forward "^Date:[ \t]" nil t)
2091 ;; If Date is missing, try again for X-Sent.
2092 (re-search-forward "^X-Sent:[ \t]" nil t))
2093 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2094 date (or (get-text-property (gnus-point-at-bol)
2097 eface (get-text-property (1- (gnus-point-at-eol))
2099 (let ((buffer-read-only nil))
2100 ;; Delete any old X-Sent headers.
2101 (when (setq date-pos
2102 (text-property-any (point-min) (point-max)
2103 'article-date-lapsed t))
2104 (goto-char (setq date-pos (set-marker (make-marker) date-pos)))
2105 (delete-region (match-beginning 0)
2106 (progn (forward-line 1) (point))))
2107 (goto-char (point-min))
2108 ;; Delete any old Date headers.
2109 (while (re-search-forward "^Date:[ \t]" nil t)
2111 (setq date-pos (match-beginning 0)))
2112 (unless (and (eq type 'lapsed)
2113 gnus-article-date-lapsed-new-header)
2114 (delete-region (match-beginning 0)
2115 (progn (message-next-header) (point)))))
2118 (goto-char date-pos)
2120 ;; Possibly, Date has been deleted.
2122 (when (and (eq type 'lapsed)
2123 gnus-article-date-lapsed-new-header
2124 (looking-at "Date:"))
2126 (goto-char (point-min)))
2127 (insert (article-make-date-line date type))
2128 (when (eq type 'lapsed)
2129 (put-text-property (gnus-point-at-bol) (point)
2130 'article-date-lapsed t))
2134 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2135 (put-text-property (match-beginning 1) (1+ (match-end 1))
2136 'original-date date)
2137 (put-text-property (match-beginning 1) (1+ (match-end 1))
2139 (put-text-property (match-beginning 2) (match-end 2)
2142 (defun article-make-date-line (date type)
2143 "Return a DATE line of TYPE."
2144 (let ((time (condition-case ()
2148 ;; Convert to the local timezone. We have to slap a
2149 ;; `condition-case' round the calls to the timezone
2150 ;; functions since they aren't particularly resistant to
2153 (let ((tz (car (current-time-zone time))))
2154 (format "Date: %s %s%02d%02d" (current-time-string time)
2155 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2156 (/ (% (abs tz) 3600) 60))))
2157 ;; Convert to Universal Time.
2160 (current-time-string
2161 (let* ((e (parse-time-string date))
2162 (tm (apply 'encode-time e))
2164 (ls (- (cadr tm) (car (current-time-zone time)))))
2165 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2166 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2169 ;; Get the original date from the article.
2170 ((eq type 'original)
2171 (concat "Date: " (if (string-match "\n+$" date)
2172 (substring date 0 (match-beginning 0))
2174 ;; Let the user define the format.
2176 (if (gnus-functionp gnus-article-time-format)
2177 (funcall gnus-article-time-format time)
2180 (format-time-string gnus-article-time-format time))))
2183 (let ((tz (car (current-time-zone time))))
2186 (format-time-string "%Y%m%dT%H%M%S" time)
2187 (format "%s%02d%02d"
2188 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2189 (/ (% (abs tz) 3600) 60)))))
2190 ;; Do an X-Sent lapsed format.
2192 ;; If the date is seriously mangled, the timezone functions are
2193 ;; liable to bug out, so we ignore all errors.
2194 (let* ((now (current-time))
2195 (real-time (subtract-time now time))
2196 (real-sec (and real-time
2197 (+ (* (float (car real-time)) 65536)
2199 (sec (and real-time (abs real-sec)))
2209 ;; This is a bit convoluted, but basically we go
2210 ;; through the time units for years, weeks, etc,
2211 ;; and divide things to see whether that results
2212 ;; in positive answers.
2215 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2216 ;; The (remaining) seconds are too few to
2217 ;; be divided into this time unit.
2219 ;; It's big enough, so we output it.
2220 (setq sec (- sec (* num (cdr unit))))
2222 (concat (if prev ", " "") (int-to-string
2224 " " (symbol-name (car unit))
2225 (if (> num 1) "s" ""))
2227 article-time-units "")
2228 ;; If dates are odd, then it might appear like the
2229 ;; article was sent in the future.
2232 " in the future"))))))
2234 (error "Unknown conversion type: %s" type)))))
2236 (defun article-date-local (&optional highlight)
2237 "Convert the current article date to the local timezone."
2238 (interactive (list t))
2239 (article-date-ut 'local highlight))
2241 (defun article-date-original (&optional highlight)
2242 "Convert the current article date to what it was originally.
2243 This is only useful if you have used some other date conversion
2244 function and want to see what the date was before converting."
2245 (interactive (list t))
2246 (article-date-ut 'original highlight))
2248 (defun article-date-lapsed (&optional highlight)
2249 "Convert the current article date to time lapsed since it was sent."
2250 (interactive (list t))
2251 (article-date-ut 'lapsed highlight))
2253 (defun article-update-date-lapsed ()
2254 "Function to be run from a timer to update the lapsed time line."
2255 (let (deactivate-mark)
2260 (set-buffer (window-buffer w))
2261 (when (eq major-mode 'gnus-article-mode)
2262 (goto-char (point-min))
2263 (when (re-search-forward "^X-Sent:" nil t)
2264 (article-date-lapsed t))))
2267 (defun gnus-start-date-timer (&optional n)
2268 "Start a timer to update the X-Sent header in the article buffers.
2269 The numerical prefix says how frequently (in seconds) the function
2274 (gnus-stop-date-timer)
2275 (setq article-lapsed-timer
2276 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2278 (defun gnus-stop-date-timer ()
2279 "Stop the X-Sent timer."
2281 (when article-lapsed-timer
2282 (nnheader-cancel-timer article-lapsed-timer)
2283 (setq article-lapsed-timer nil)))
2285 (defun article-date-user (&optional highlight)
2286 "Convert the current article date to the user-defined format.
2287 This format is defined by the `gnus-article-time-format' variable."
2288 (interactive (list t))
2289 (article-date-ut 'user highlight))
2291 (defun article-date-iso8601 (&optional highlight)
2292 "Convert the current article date to ISO8601."
2293 (interactive (list t))
2294 (article-date-ut 'iso8601 highlight))
2296 (defun article-show-all ()
2297 "Show all hidden text in the article buffer."
2301 (let ((buffer-read-only nil))
2302 (gnus-article-unhide-text (point-min) (point-max))
2303 (gnus-remove-text-with-property 'gnus-prev)
2304 (gnus-remove-text-with-property 'gnus-next))))
2306 (defun article-show-all-headers ()
2307 "Show all hidden headers in the article buffer."
2312 (article-narrow-to-head)
2313 (let ((buffer-read-only nil))
2314 (gnus-article-unhide-text (point-min) (point-max))))))
2316 (defun article-emphasize (&optional arg)
2317 "Emphasize text according to `gnus-emphasis-alist'."
2318 (interactive (gnus-article-hidden-arg))
2319 (unless (gnus-article-check-hidden-text 'emphasis arg)
2323 (with-current-buffer gnus-summary-buffer
2324 gnus-article-emphasis-alist)
2326 gnus-emphasis-alist))
2327 (buffer-read-only nil)
2328 (props (append '(article-type emphasis)
2329 gnus-hidden-properties))
2330 regexp elem beg invisible visible face)
2333 (while (setq elem (pop alist))
2335 (setq regexp (car elem)
2336 invisible (nth 1 elem)
2337 visible (nth 2 elem)
2339 (while (re-search-forward regexp nil t)
2340 (when (and (match-beginning visible) (match-beginning invisible))
2341 (push 'emphasis gnus-article-wash-types)
2342 (gnus-article-hide-text
2343 (match-beginning invisible) (match-end invisible) props)
2344 (gnus-article-unhide-text-type
2345 (match-beginning visible) (match-end visible) 'emphasis)
2346 (gnus-put-text-property-excluding-newlines
2347 (match-beginning visible) (match-end visible) 'face face)
2348 (goto-char (match-end invisible)))))))))
2350 (defun gnus-article-setup-highlight-words (&optional highlight-words)
2351 "Setup newsgroup emphasis alist."
2352 (unless gnus-article-emphasis-alist
2353 (let ((name (and gnus-newsgroup-name
2354 (gnus-group-real-name gnus-newsgroup-name))))
2355 (make-local-variable 'gnus-article-emphasis-alist)
2356 (setq gnus-article-emphasis-alist
2358 (let ((alist gnus-group-highlight-words-alist) elem highlight)
2359 (while (setq elem (pop alist))
2360 (when (and name (string-match (car elem) name))
2362 highlight (copy-sequence (cdr elem)))))
2364 (copy-sequence highlight-words)
2365 (if gnus-newsgroup-name
2366 (copy-sequence (gnus-group-find-parameter
2367 gnus-newsgroup-name 'highlight-words t)))
2368 gnus-emphasis-alist)))))
2370 (defvar gnus-summary-article-menu)
2371 (defvar gnus-summary-post-menu)
2373 ;;; Saving functions.
2375 (defun gnus-article-save (save-buffer file &optional num)
2376 "Save the currently selected article."
2377 (unless gnus-save-all-headers
2378 ;; Remove headers according to `gnus-saved-headers'.
2379 (let ((gnus-visible-headers
2380 (or gnus-saved-headers gnus-visible-headers))
2381 (gnus-article-buffer save-buffer))
2383 (set-buffer save-buffer)
2384 (article-hide-headers 1 t))))
2385 (save-window-excursion
2386 (if (not gnus-default-article-saver)
2387 (error "No default saver is defined")
2388 ;; !!! Magic! The saving functions all save
2389 ;; `gnus-save-article-buffer' (or so they think), but we
2390 ;; bind that variable to our save-buffer.
2391 (set-buffer gnus-article-buffer)
2392 (let* ((gnus-save-article-buffer save-buffer)
2395 ((not gnus-prompt-before-saving) 'default)
2396 ((eq gnus-prompt-before-saving 'always) nil)
2398 (gnus-number-of-articles-to-be-saved
2399 (when (eq gnus-prompt-before-saving t)
2401 (set-buffer gnus-article-current-summary)
2402 (funcall gnus-default-article-saver filename)))))
2404 (defun gnus-read-save-file-name (prompt &optional filename
2405 function group headers variable)
2407 (funcall function group headers (symbol-value variable)))
2412 ((eq filename 'default)
2418 (let* ((split-name (gnus-get-split-value gnus-split-methods))
2421 (if (and gnus-number-of-articles-to-be-saved
2422 (> gnus-number-of-articles-to-be-saved 1))
2423 (format "these %d articles"
2424 gnus-number-of-articles-to-be-saved)
2427 ;; Let the split methods have their say.
2429 ;; No split name was found.
2432 (concat prompt " (default "
2433 (file-name-nondirectory default-name) ") ")
2434 (file-name-directory default-name)
2436 ;; A single group name is returned.
2437 ((stringp split-name)
2439 (funcall function split-name headers
2440 (symbol-value variable)))
2442 (concat prompt " (default "
2443 (file-name-nondirectory default-name) ") ")
2444 (file-name-directory default-name)
2446 ;; A single split name was found
2447 ((= 1 (length split-name))
2448 (let* ((name (expand-file-name
2449 (car split-name) gnus-article-save-directory))
2450 (dir (cond ((file-directory-p name)
2451 (file-name-as-directory name))
2452 ((file-exists-p name) name)
2453 (t gnus-article-save-directory))))
2455 (concat prompt " (default " name ") ")
2457 ;; A list of splits was found.
2459 (setq split-name (nreverse split-name))
2461 (let ((file-name-history
2462 (nconc split-name file-name-history)))
2466 (concat prompt " (`M-p' for defaults) ")
2467 gnus-article-save-directory
2469 gnus-article-save-directory)))
2470 (car (push result file-name-history)))))))
2471 ;; Create the directory.
2472 (gnus-make-directory (file-name-directory file))
2473 ;; If we have read a directory, we append the default file name.
2474 (when (file-directory-p file)
2475 (setq file (concat (file-name-as-directory file)
2476 (file-name-nondirectory default-name))))
2477 ;; Possibly translate some characters.
2478 (nnheader-translate-file-chars file)))))
2479 (gnus-make-directory (file-name-directory result))
2480 (set variable result)))
2482 (defun gnus-article-archive-name (group)
2483 "Return the first instance of an \"Archive-name\" in the current buffer."
2484 (let ((case-fold-search t))
2485 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
2486 (nnheader-concat gnus-article-save-directory
2487 (match-string 1)))))
2489 (defun gnus-article-nndoc-name (group)
2490 "If GROUP is an nndoc group, return the name of the parent group."
2491 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
2492 (gnus-group-get-parameter group 'save-article-group)))
2494 (defun gnus-summary-save-in-rmail (&optional filename)
2495 "Append this article to Rmail file.
2496 Optional argument FILENAME specifies file name.
2497 Directory to save to is default to `gnus-article-save-directory'."
2498 (setq filename (gnus-read-save-file-name
2499 "Save %s in rmail file:" filename
2500 gnus-rmail-save-name gnus-newsgroup-name
2501 gnus-current-headers 'gnus-newsgroup-last-rmail))
2502 (gnus-eval-in-buffer-window gnus-save-article-buffer
2506 (gnus-output-to-rmail filename))))
2509 (defun gnus-summary-save-in-mail (&optional filename)
2510 "Append this article to Unix mail file.
2511 Optional argument FILENAME specifies file name.
2512 Directory to save to is default to `gnus-article-save-directory'."
2513 (setq filename (gnus-read-save-file-name
2514 "Save %s in Unix mail file:" filename
2515 gnus-mail-save-name gnus-newsgroup-name
2516 gnus-current-headers 'gnus-newsgroup-last-mail))
2517 (gnus-eval-in-buffer-window gnus-save-article-buffer
2521 (if (and (file-readable-p filename)
2522 (mail-file-babyl-p filename))
2523 (rmail-output-to-rmail-file filename t)
2524 (gnus-output-to-mail filename)))))
2527 (defun gnus-summary-save-in-file (&optional filename overwrite)
2528 "Append this article to file.
2529 Optional argument FILENAME specifies file name.
2530 Directory to save to is default to `gnus-article-save-directory'."
2531 (setq filename (gnus-read-save-file-name
2532 "Save %s in file:" filename
2533 gnus-file-save-name gnus-newsgroup-name
2534 gnus-current-headers 'gnus-newsgroup-last-file))
2535 (gnus-eval-in-buffer-window gnus-save-article-buffer
2539 (when (and overwrite
2540 (file-exists-p filename))
2541 (delete-file filename))
2542 (gnus-output-to-file filename))))
2545 (defun gnus-summary-write-to-file (&optional filename)
2546 "Write this article to a file.
2547 Optional argument FILENAME specifies file name.
2548 The directory to save in defaults to `gnus-article-save-directory'."
2549 (gnus-summary-save-in-file nil t))
2551 (defun gnus-summary-save-body-in-file (&optional filename)
2552 "Append this article body to a file.
2553 Optional argument FILENAME specifies file name.
2554 The directory to save in defaults to `gnus-article-save-directory'."
2555 (setq filename (gnus-read-save-file-name
2556 "Save %s body in file:" filename
2557 gnus-file-save-name gnus-newsgroup-name
2558 gnus-current-headers 'gnus-newsgroup-last-file))
2559 (gnus-eval-in-buffer-window gnus-save-article-buffer
2563 (when (article-goto-body)
2564 (narrow-to-region (point) (point-max)))
2565 (gnus-output-to-file filename))))
2568 (defun gnus-summary-save-in-pipe (&optional command)
2569 "Pipe this article to subprocess."
2571 (cond ((and (eq command 'default)
2572 gnus-last-shell-command)
2573 gnus-last-shell-command)
2577 "Shell command on %s: "
2578 (if (and gnus-number-of-articles-to-be-saved
2579 (> gnus-number-of-articles-to-be-saved 1))
2580 (format "these %d articles"
2581 gnus-number-of-articles-to-be-saved)
2583 gnus-last-shell-command))))
2584 (when (string-equal command "")
2585 (setq command gnus-last-shell-command))
2586 (gnus-eval-in-buffer-window gnus-article-buffer
2589 (shell-command-on-region (point-min) (point-max) command nil)))
2590 (setq gnus-last-shell-command command))
2592 ;;; Article file names when saving.
2594 (defun gnus-capitalize-newsgroup (newsgroup)
2595 "Capitalize NEWSGROUP name."
2596 (when (not (zerop (length newsgroup)))
2597 (concat (char-to-string (upcase (aref newsgroup 0)))
2598 (substring newsgroup 1))))
2600 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2601 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2602 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
2603 Otherwise, it is like ~/News/news/group/num."
2606 (concat (if (gnus-use-long-file-name 'not-save)
2607 (gnus-capitalize-newsgroup newsgroup)
2608 (gnus-newsgroup-directory-form newsgroup))
2609 "/" (int-to-string (mail-header-number headers)))
2610 gnus-article-save-directory)))
2612 (string-equal (file-name-directory default)
2613 (file-name-directory last-file))
2614 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2616 (or last-file default))))
2618 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2619 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2620 If variable `gnus-use-long-file-name' is non-nil, it is
2621 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2624 (concat (if (gnus-use-long-file-name 'not-save)
2626 (gnus-newsgroup-directory-form newsgroup))
2627 "/" (int-to-string (mail-header-number headers)))
2628 gnus-article-save-directory)))
2630 (string-equal (file-name-directory default)
2631 (file-name-directory last-file))
2632 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2634 (or last-file default))))
2636 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
2637 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2638 If variable `gnus-use-long-file-name' is non-nil, it is
2639 ~/News/News.group. Otherwise, it is like ~/News/news/group/news."
2642 (if (gnus-use-long-file-name 'not-save)
2643 (gnus-capitalize-newsgroup newsgroup)
2644 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2645 gnus-article-save-directory)))
2647 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2648 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2649 If variable `gnus-use-long-file-name' is non-nil, it is
2650 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2653 (if (gnus-use-long-file-name 'not-save)
2655 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2656 gnus-article-save-directory)))
2663 (setq afunc (car func)
2666 gfunc (intern (format "gnus-%s" func))))
2669 `(lambda (&optional interactive &rest args)
2670 ,(documentation afunc t)
2671 (interactive (list t))
2673 (set-buffer gnus-article-buffer)
2675 (call-interactively ',afunc)
2676 (apply ',afunc args))))))))
2677 '(article-hide-headers
2678 article-hide-boring-headers
2679 article-toggle-headers
2680 article-treat-overstrike
2681 article-fill-long-lines
2682 article-capitalize-sentences
2684 article-display-x-face
2685 article-de-quoted-unreadable
2686 article-de-base64-unreadable
2689 article-hide-list-identifiers
2691 article-strip-banner
2694 article-hide-signature
2695 article-strip-headers-in-body
2696 article-remove-trailing-blank-lines
2697 article-strip-leading-blank-lines
2698 article-strip-multiple-blank-lines
2699 article-strip-leading-space
2700 article-strip-trailing-space
2701 article-strip-blank-lines
2702 article-strip-all-blank-lines
2704 article-date-iso8601
2705 article-date-original
2707 article-decode-mime-words
2708 article-decode-charset
2709 article-decode-encoded-words
2713 article-treat-dumbquotes
2714 article-normalize-headers
2715 (article-show-all-headers . gnus-article-show-all-headers)
2716 (article-show-all . gnus-article-show-all))))
2719 ;;; Gnus article mode
2722 (put 'gnus-article-mode 'mode-class 'special)
2724 (gnus-define-keys gnus-article-mode-map
2725 " " gnus-article-goto-next-page
2726 "\177" gnus-article-goto-prev-page
2727 [delete] gnus-article-goto-prev-page
2728 [backspace] gnus-article-goto-prev-page
2729 "\C-c^" gnus-article-refer-article
2730 "h" gnus-article-show-summary
2731 "s" gnus-article-show-summary
2732 "\C-c\C-m" gnus-article-mail
2733 "?" gnus-article-describe-briefly
2734 "e" gnus-summary-edit-article
2735 "<" beginning-of-buffer
2737 "\C-c\C-i" gnus-info-find-node
2740 "\C-d" gnus-article-read-summary-keys
2741 "\M-*" gnus-article-read-summary-keys
2742 "\M-#" gnus-article-read-summary-keys
2743 "\M-^" gnus-article-read-summary-keys
2744 "\M-g" gnus-article-read-summary-keys)
2746 ;; Define almost undefined keys to `gnus-article-read-summary-keys'.
2749 (unless (lookup-key gnus-article-mode-map key)
2750 (define-key gnus-article-mode-map key
2751 'gnus-article-read-summary-keys)))
2756 (let ((key (car elt)))
2757 (and (> (length key) 0)
2758 (not (eq 'menu-bar (aref key 0)))
2759 (symbolp (lookup-key gnus-summary-mode-map key))
2761 (accessible-keymaps gnus-summary-mode-map))
2765 (push (char-to-string c) keys)
2769 (defun gnus-article-make-menu-bar ()
2770 (gnus-turn-off-edit-menu 'article)
2771 (unless (boundp 'gnus-article-article-menu)
2773 gnus-article-article-menu gnus-article-mode-map ""
2775 ["Scroll forwards" gnus-article-goto-next-page t]
2776 ["Scroll backwards" gnus-article-goto-prev-page t]
2777 ["Show summary" gnus-article-show-summary t]
2778 ["Fetch Message-ID at point" gnus-article-refer-article t]
2779 ["Mail to address at point" gnus-article-mail t]
2780 ["Send a bug report" gnus-bug t]))
2783 gnus-article-treatment-menu gnus-article-mode-map ""
2785 ["Hide headers" gnus-article-toggle-headers t]
2786 ["Hide signature" gnus-article-hide-signature t]
2787 ["Hide citation" gnus-article-hide-citation t]
2788 ["Treat overstrike" gnus-article-treat-overstrike t]
2789 ["Remove carriage return" gnus-article-remove-cr t]
2790 ["Decode HZ" gnus-article-decode-HZ t]))
2792 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
2794 (when (boundp 'gnus-summary-post-menu)
2795 (define-key gnus-article-mode-map [menu-bar post]
2796 (cons "Post" gnus-summary-post-menu)))
2798 (gnus-run-hooks 'gnus-article-menu-hook)))
2800 (defun gnus-article-mode ()
2801 "Major mode for displaying an article.
2803 All normal editing commands are switched off.
2805 The following commands are available in addition to all summary mode
2807 \\<gnus-article-mode-map>
2808 \\[gnus-article-next-page]\t Scroll the article one page forwards
2809 \\[gnus-article-prev-page]\t Scroll the article one page backwards
2810 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
2811 \\[gnus-article-show-summary]\t Display the summary buffer
2812 \\[gnus-article-mail]\t Send a reply to the address near point
2813 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
2814 \\[gnus-info-find-node]\t Go to the Gnus info node"
2816 (when (gnus-visual-p 'article-menu 'menu)
2817 (gnus-article-make-menu-bar))
2818 (gnus-simplify-mode-line)
2819 (setq mode-name "Article")
2820 (setq major-mode 'gnus-article-mode)
2821 (make-local-variable 'minor-mode-alist)
2822 (unless (assq 'gnus-show-mime minor-mode-alist)
2823 (push (list 'gnus-show-mime " MIME") minor-mode-alist))
2824 (use-local-map gnus-article-mode-map)
2825 (gnus-update-format-specifications nil 'article-mode)
2826 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
2827 (make-local-variable 'gnus-page-broken)
2828 (make-local-variable 'gnus-button-marker-list)
2829 (make-local-variable 'gnus-article-current-summary)
2830 (make-local-variable 'gnus-article-mime-handles)
2831 (make-local-variable 'gnus-article-decoded-p)
2832 (make-local-variable 'gnus-article-mime-handle-alist)
2833 (make-local-variable 'gnus-article-wash-types)
2834 (gnus-set-default-directory)
2835 (buffer-disable-undo)
2836 (setq buffer-read-only t)
2837 (set-syntax-table gnus-article-mode-syntax-table)
2838 (gnus-run-hooks 'gnus-article-mode-hook))
2840 (defun gnus-article-setup-buffer ()
2841 "Initialize the article buffer."
2842 (let* ((name (if gnus-single-article-buffer "*Article*"
2843 (concat "*Article " gnus-newsgroup-name "*")))
2845 (progn (string-match "\\*Article" name)
2846 (concat " *Original Article"
2847 (substring name (match-end 0))))))
2848 (setq gnus-article-buffer name)
2849 (setq gnus-original-article-buffer original)
2850 (setq gnus-article-mime-handle-alist nil)
2851 ;; This might be a variable local to the summary buffer.
2852 (unless gnus-single-article-buffer
2854 (set-buffer gnus-summary-buffer)
2855 (setq gnus-article-buffer name)
2856 (setq gnus-original-article-buffer original)
2857 (gnus-set-global-variables)))
2858 (gnus-article-setup-highlight-words)
2859 ;; Init original article buffer.
2861 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
2862 (setq major-mode 'gnus-original-article-mode)
2863 (make-local-variable 'gnus-original-article))
2864 (if (get-buffer name)
2867 (buffer-disable-undo)
2868 (setq buffer-read-only t)
2869 (unless (eq major-mode 'gnus-article-mode)
2870 (gnus-article-mode))
2873 (set-buffer (gnus-get-buffer-create name))
2875 (make-local-variable 'gnus-summary-buffer)
2876 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2877 (current-buffer)))))
2879 ;; Set article window start at LINE, where LINE is the number of lines
2880 ;; from the head of the article.
2881 (defun gnus-article-set-window-start (&optional line)
2883 (get-buffer-window gnus-article-buffer t)
2885 (set-buffer gnus-article-buffer)
2886 (goto-char (point-min))
2889 (gnus-message 6 "Moved to bookmark")
2890 (search-forward "\n\n" nil t)
2894 ;;; @@ article filters
2897 (defun gnus-article-display-mime-message ()
2898 "Article display method for MIME message."
2899 ;; called from `gnus-original-article-buffer'.
2900 (let (charset all-headers)
2901 (with-current-buffer gnus-summary-buffer
2902 (setq charset default-mime-charset
2903 all-headers gnus-have-all-headers))
2904 (make-local-variable 'default-mime-charset)
2905 (setq default-mime-charset charset)
2906 (with-current-buffer (get-buffer-create gnus-article-buffer)
2907 (make-local-variable 'default-mime-charset)
2908 (setq default-mime-charset charset))
2909 (mime-display-message mime-message-structure
2910 gnus-article-buffer nil gnus-article-mode-map)
2912 (gnus-article-hide-headers nil -1))
2914 ;; `mime-display-message' changes current buffer to `gnus-article-buffer'.
2915 (make-local-variable 'mime-button-mother-dispatcher)
2916 (setq mime-button-mother-dispatcher
2917 (function gnus-article-push-button))
2918 (run-hooks 'gnus-mime-article-prepare-hook))
2920 (defun gnus-article-display-traditional-message ()
2921 "Article display method for traditional message."
2922 (set-buffer gnus-article-buffer)
2923 (let (buffer-read-only)
2925 (insert-buffer-substring gnus-original-article-buffer)))
2927 (defun gnus-article-make-full-mail-header (&optional number charset)
2928 "Create a new mail header structure in a raw article buffer."
2929 (unless (and number charset)
2930 (save-current-buffer
2931 (set-buffer gnus-summary-buffer)
2933 (setq number (or (cdr gnus-article-current) 0)))
2935 (setq charset (or default-mime-charset 'x-ctext)))))
2936 (goto-char (point-min))
2937 (let ((header-end (if (search-forward "\n\n" nil t)
2939 (goto-char (point-max))))
2940 (chars (- (point-max) (point)))
2941 (lines (count-lines (point) (point-max)))
2942 (default-mime-charset charset)
2944 (narrow-to-region (point-min) header-end)
2945 (setq xref (std11-fetch-field "xref"))
2947 (make-full-mail-header
2949 (std11-fetch-field "subject")
2950 (std11-fetch-field "from")
2951 (std11-fetch-field "date")
2952 (std11-fetch-field "message-id")
2953 (std11-fetch-field "references")
2956 (when xref (concat "Xref: " xref)))
2959 (defun gnus-article-prepare (article &optional all-headers header)
2960 "Prepare ARTICLE in article mode buffer.
2961 ARTICLE should either be an article number or a Message-ID.
2962 If ARTICLE is an id, HEADER should be the article headers.
2963 If ALL-HEADERS is non-nil, no headers are hidden."
2965 ;; Make sure we start in a summary buffer.
2966 (unless (eq major-mode 'gnus-summary-mode)
2967 (set-buffer gnus-summary-buffer))
2968 (setq gnus-summary-buffer (current-buffer))
2969 (let* ((gnus-article (if header (mail-header-number header) article))
2970 (summary-buffer (current-buffer))
2971 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
2972 (group gnus-newsgroup-name)
2975 (gnus-article-setup-buffer)
2976 (set-buffer gnus-original-article-buffer)
2977 ;; Deactivate active regions.
2978 (when (and (boundp 'transient-mark-mode)
2979 transient-mark-mode)
2980 (setq mark-active nil))
2981 (if (not (setq result (let ((buffer-read-only nil))
2982 (gnus-request-article-this-buffer
2984 ;; There is no such article.
2986 (when (and (numberp article)
2987 (not (memq article gnus-newsgroup-sparse)))
2988 (setq gnus-article-current
2989 (cons gnus-newsgroup-name article))
2990 (set-buffer gnus-summary-buffer)
2991 (setq gnus-current-article article)
2992 (if (eq (gnus-article-mark article) gnus-undownloaded-mark)
2994 (gnus-summary-set-agent-mark article)
2995 (message "Message marked for downloading"))
2996 (gnus-summary-mark-article article gnus-canceled-mark)
2997 (unless (memq article gnus-newsgroup-sparse)
2998 (gnus-error 1 "No such article (may have expired or been canceled)")))))
2999 (if (or (eq result 'pseudo)
3000 (eq result 'nneething))
3003 (set-buffer summary-buffer)
3004 (push article gnus-newsgroup-history)
3005 (setq gnus-last-article gnus-current-article
3006 gnus-current-article 0
3007 gnus-current-headers nil
3008 gnus-article-current nil)
3009 (if (eq result 'nneething)
3010 (gnus-configure-windows 'summary)
3011 (gnus-configure-windows 'article))
3012 (gnus-set-global-variables))
3013 (let ((gnus-article-mime-handle-alist-1
3014 gnus-article-mime-handle-alist))
3015 (gnus-set-mode-line 'article)))
3016 ;; The result from the `request' was an actual article -
3017 ;; or at least some text that is now displayed in the
3019 (when (and (numberp article)
3020 (not (eq article gnus-current-article)))
3021 ;; Seems like a new article has been selected.
3022 ;; `gnus-current-article' must be an article number.
3024 (set-buffer summary-buffer)
3025 (push article gnus-newsgroup-history)
3026 (setq gnus-last-article gnus-current-article
3027 gnus-current-article article
3028 gnus-current-headers
3029 (gnus-summary-article-header gnus-current-article)
3030 gnus-article-current
3031 (cons gnus-newsgroup-name gnus-current-article))
3032 (unless (vectorp gnus-current-headers)
3033 (setq gnus-current-headers nil))
3034 (gnus-summary-goto-subject gnus-current-article)
3035 (when (gnus-summary-show-thread)
3036 ;; If the summary buffer really was folded, the
3037 ;; previous goto may not actually have gone to
3038 ;; the right article, but the thread root instead.
3040 (gnus-summary-goto-subject gnus-current-article))
3041 (gnus-run-hooks 'gnus-mark-article-hook)
3042 (gnus-set-mode-line 'summary)
3043 (when (gnus-visual-p 'article-highlight 'highlight)
3044 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3045 ;; Set the global newsgroup variables here.
3046 (gnus-set-global-variables)
3047 (setq gnus-have-all-headers
3048 (or all-headers gnus-show-all-headers))))
3049 (when (or (numberp article)
3051 (gnus-article-prepare-display)
3053 (goto-char (point-min))
3054 (setq gnus-page-broken
3055 (when gnus-break-pages
3056 (gnus-narrow-to-page)
3058 (let ((gnus-article-mime-handle-alist-1
3059 gnus-article-mime-handle-alist))
3060 (gnus-set-mode-line 'article))
3062 (set-window-point (get-buffer-window (current-buffer)) (point))
3063 (gnus-configure-windows 'article)
3066 (defun gnus-article-prepare-mime-display (&optional number)
3067 (goto-char (point-min))
3068 (when (re-search-forward "^[^\t ]+:" nil t)
3069 (goto-char (match-beginning 0)))
3070 (let ((entity (if (eq 1 (point-min))
3071 (get-text-property 1 'mime-view-entity)
3072 (get-text-property (point) 'mime-view-entity)))
3073 last-entity child-entity next type)
3074 (setq child-entity (mime-entity-children entity))
3076 (setq last-entity (nth (1- (length child-entity))
3078 (setq last-entity entity))
3080 (narrow-to-region (point)
3081 (if (search-forward "\n\n" nil t)
3084 (gnus-treat-article 'head)
3085 (put-text-property (point-min) (point-max) 'article-treated-header t)
3086 (goto-char (point-max)))
3087 (while (and (not (eobp)) entity)
3088 (setq next (set-marker
3090 (next-single-property-change (point) 'mime-view-entity
3092 (let ((types (mime-entity-content-type entity)))
3093 (while (eq 'multipart (mime-content-type-primary-type types))
3094 (setq entity (car (mime-entity-children entity))
3095 types (mime-entity-content-type entity)))
3097 (setq type (format "%s/%s"
3098 (mime-content-type-primary-type types)
3099 (mime-content-type-subtype types)))))
3100 (if (string-equal type "message/rfc822")
3103 (let ((children (mime-entity-children entity))
3106 (setq last-children (nth (1- (length children)) children))
3109 (not (eq last-children
3110 (get-text-property next 'mime-view-entity)))
3112 (next-single-property-change next
3114 nil (point-max)))))))
3115 (setq next (next-single-property-change next 'mime-view-entity
3118 (narrow-to-region (point) next)
3119 (gnus-article-prepare-mime-display)
3120 (goto-char (point-max)))
3121 (setq entity (get-text-property (point) 'mime-view-entity)))
3123 (narrow-to-region (point) next)
3124 ;; Kludge. We have to count true number, but for now,
3125 ;; part number is here only to achieve `last'.
3126 (gnus-treat-article nil 1
3127 (if (eq entity last-entity)
3130 (goto-char (point-max)))
3131 (setq entity (get-text-property next 'mime-view-entity))))))
3134 (defun gnus-article-prepare-display ()
3135 "Make the current buffer look like a nice article."
3136 (setq gnus-article-wash-types nil)
3137 (gnus-run-hooks 'gnus-tmp-internal-hook)
3138 (gnus-run-hooks 'gnus-article-prepare-hook)
3140 (let (mime-display-header-hook mime-display-text/plain-hook)
3141 (funcall (if gnus-show-mime
3143 (setq mime-message-structure gnus-current-headers)
3144 (mime-buffer-entity-set-buffer-internal
3145 mime-message-structure
3146 gnus-original-article-buffer)
3147 (mime-entity-set-representation-type-internal
3148 mime-message-structure 'mime-buffer-entity)
3149 (luna-send mime-message-structure
3150 'initialize-instance
3151 mime-message-structure)
3152 gnus-article-display-method-for-mime)
3153 gnus-article-display-method-for-traditional)))
3154 ;; Associate this article with the current summary buffer.
3155 (setq gnus-article-current-summary gnus-summary-buffer)
3156 ;; Call the treatment functions.
3157 (let ((inhibit-read-only t)
3162 (gnus-article-prepare-mime-display)
3163 (narrow-to-region (goto-char (point-min))
3164 (if (search-forward "\n\n" nil t)
3167 (gnus-treat-article 'head)
3168 (put-text-property (point-min) (point-max) 'article-treated-header t)
3169 (goto-char (point-max))
3171 (narrow-to-region (point) (point-max))
3172 (gnus-treat-article nil))
3173 (put-text-property (point-min) (point-max) 'read-only nil)))
3174 ;; Perform the article display hooks. Incidentally, this hook is
3175 ;; an obsolete variable by now.
3176 (gnus-run-hooks 'gnus-article-display-hook))
3178 (defun gnus-article-decode-article-as-default-mime-charset ()
3179 "Decode an article as `default-mime-charset'. It won't work if the
3180 value of the variable `gnus-show-mime' is non-nil."
3181 (unless gnus-show-mime
3182 (decode-mime-charset-region (point-min) (point-max)
3183 (with-current-buffer gnus-summary-buffer
3184 default-mime-charset))))
3187 ;;; Gnus MIME viewing functions
3190 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3191 "The following specs can be used:
3193 %T MIME type, along with additional info
3194 %n The `name' parameter
3195 %d The description, if any
3196 %l The length of the encoded part
3197 %p The part identifier number
3198 %e Dots if the part isn't displayed")
3200 (defvar gnus-mime-button-line-format-alist
3201 '((?t gnus-tmp-type ?s)
3202 (?T gnus-tmp-type-long ?s)
3203 (?n gnus-tmp-name ?s)
3204 (?d gnus-tmp-description ?s)
3206 (?l gnus-tmp-length ?d)
3207 (?e gnus-tmp-dots ?s)))
3209 (defvar gnus-mime-button-commands
3210 '((gnus-article-press-button "\r" "Toggle Display")
3211 (gnus-mime-view-part "v" "View Interactively...")
3212 (gnus-mime-view-part-as-type "t" "View As Type...")
3213 (gnus-mime-save-part "o" "Save...")
3214 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
3215 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
3216 (gnus-mime-internalize-part "E" "View Internally")
3217 (gnus-mime-externalize-part "e" "View Externally")
3218 (gnus-mime-pipe-part "|" "Pipe To Command...")))
3220 (defun gnus-article-mime-part-status ()
3221 (with-current-buffer gnus-article-buffer
3222 (let ((entity (get-text-property (point-min) 'mime-view-entity)))
3223 (if (and entity (mime-entity-children entity))
3224 (format " (%d parts)" (length (mime-entity-children entity)))
3227 (defvar gnus-mime-button-map nil)
3228 (unless gnus-mime-button-map
3229 (setq gnus-mime-button-map (make-sparse-keymap))
3230 (set-keymap-parent gnus-mime-button-map gnus-article-mode-map)
3231 (define-key gnus-mime-button-map gnus-mouse-2 'gnus-article-push-button)
3232 (define-key gnus-mime-button-map gnus-down-mouse-3 'gnus-mime-button-menu)
3234 (define-key gnus-mime-button-map (cadr c) (car c)))
3235 gnus-mime-button-commands))
3237 (defun gnus-mime-button-menu (event)
3238 "Construct a context-sensitive menu of MIME commands."
3241 (let ((pos (event-start event)))
3242 (set-buffer (window-buffer (posn-window pos)))
3243 (goto-char (posn-point pos))
3244 (gnus-article-check-buffer)
3245 (let ((response (x-popup-menu
3247 ("" ,@(mapcar (lambda (c)
3248 (cons (caddr c) (car c)))
3249 gnus-mime-button-commands))))))
3251 (call-interactively response))))))
3253 (defun gnus-mime-view-all-parts (&optional handles)
3254 "View all the MIME parts."
3256 (save-current-buffer
3257 (set-buffer gnus-article-buffer)
3258 (let ((handles (or handles gnus-article-mime-handles))
3259 (mail-parse-charset gnus-newsgroup-charset)
3260 (mail-parse-ignored-charsets
3261 (save-excursion (set-buffer gnus-summary-buffer)
3262 gnus-newsgroup-ignored-charsets)))
3263 (if (stringp (car handles))
3264 (gnus-mime-view-all-parts (cdr handles))
3265 (mapcar 'mm-display-part handles)))))
3267 (defun gnus-mime-save-part ()
3268 "Save the MIME part under point."
3270 (gnus-article-check-buffer)
3271 (let ((data (get-text-property (point) 'gnus-data)))
3272 (mm-save-part data)))
3274 (defun gnus-mime-pipe-part ()
3275 "Pipe the MIME part under point to a process."
3277 (gnus-article-check-buffer)
3278 (let ((data (get-text-property (point) 'gnus-data)))
3279 (mm-pipe-part data)))
3281 (defun gnus-mime-view-part ()
3282 "Interactively choose a viewing method for the MIME part under point."
3284 (gnus-article-check-buffer)
3285 (let ((data (get-text-property (point) 'gnus-data)))
3286 (mm-interactively-view-part data)))
3288 (defun gnus-mime-view-part-as-type-internal ()
3289 (gnus-article-check-buffer)
3290 (let* ((name (mail-content-type-get
3291 (mm-handle-type (get-text-property (point) 'gnus-data))
3293 (def-type (and name (mm-default-file-encoding name))))
3294 (and def-type (cons def-type 0))))
3296 (defun gnus-mime-view-part-as-type (mime-type)
3297 "Choose a MIME media type, and view the part as such."
3299 (list (completing-read
3300 "View as MIME type: "
3301 (mapcar (lambda (i) (list i i)) (mailcap-mime-types))
3303 (gnus-mime-view-part-as-type-internal))))
3304 (gnus-article-check-buffer)
3305 (let ((handle (get-text-property (point) 'gnus-data)))
3306 (gnus-mm-display-part
3307 (mm-make-handle (mm-handle-buffer handle)
3308 (cons mime-type (cdr (mm-handle-type handle)))
3309 (mm-handle-encoding handle)
3310 (mm-handle-undisplayer handle)
3311 (mm-handle-disposition handle)
3312 (mm-handle-description handle)
3313 (mm-handle-cache handle)
3314 (mm-handle-id handle)))))
3316 (defun gnus-mime-copy-part (&optional handle)
3317 "Put the the MIME part under point into a new buffer."
3319 (gnus-article-check-buffer)
3320 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3321 (contents (mm-get-part handle))|
3322 (base (file-name-nondirectory
3324 (mail-content-type-get (mm-handle-type handle) 'name)
3325 (mail-content-type-get (mm-handle-type handle)
3328 (buffer (generate-new-buffer base)))
3329 (switch-to-buffer buffer)
3331 ;; We do it this way to make `normal-mode' set the appropriate mode.
3334 (setq buffer-file-name (expand-file-name base))
3336 (setq buffer-file-name nil))
3337 (goto-char (point-min))))
3339 (defun gnus-mime-inline-part (&optional handle)
3340 "Insert the MIME part under point into the current buffer."
3342 (gnus-article-check-buffer)
3343 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3347 (if (mm-handle-undisplayer handle)
3348 (mm-remove-part handle)
3349 (setq contents (mm-get-part handle))
3351 (mm-insert-inline handle contents)
3354 (defun gnus-mime-externalize-part (&optional handle)
3355 "View the MIME part under point with an external viewer."
3357 (gnus-article-check-buffer)
3358 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3359 (mm-user-display-methods nil)
3360 (mm-inlined-types nil)
3361 (mail-parse-charset gnus-newsgroup-charset)
3362 (mail-parse-ignored-charsets
3363 (save-excursion (set-buffer gnus-summary-buffer)
3364 gnus-newsgroup-ignored-charsets)))
3365 (if (mm-handle-undisplayer handle)
3366 (mm-remove-part handle)
3367 (mm-display-part handle))))
3369 (defun gnus-mime-internalize-part (&optional handle)
3370 "View the MIME part under point with an internal viewer.
3371 In no internal viewer is available, use an external viewer."
3373 (gnus-article-check-buffer)
3374 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3375 (mm-inlined-types '(".*"))
3376 (mm-inline-large-images t)
3377 (mail-parse-charset gnus-newsgroup-charset)
3378 (mail-parse-ignored-charsets
3379 (save-excursion (set-buffer gnus-summary-buffer)
3380 gnus-newsgroup-ignored-charsets)))
3381 (if (mm-handle-undisplayer handle)
3382 (mm-remove-part handle)
3383 (mm-display-part handle))))
3385 (defun gnus-article-part-wrapper (n function)
3386 (save-current-buffer
3387 (set-buffer gnus-article-buffer)
3388 (when (> n (length gnus-article-mime-handle-alist))
3389 (error "No such part"))
3390 (gnus-article-goto-part n)
3391 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
3392 (funcall function handle))))
3394 (defun gnus-article-pipe-part (n)
3395 "Pipe MIME part N, which is the numerical prefix."
3397 (gnus-article-part-wrapper n 'mm-pipe-part))
3399 (defun gnus-article-save-part (n)
3400 "Save MIME part N, which is the numerical prefix."
3402 (gnus-article-part-wrapper n 'mm-save-part))
3404 (defun gnus-article-interactively-view-part (n)
3405 "View MIME part N interactively, which is the numerical prefix."
3407 (gnus-article-part-wrapper n 'mm-interactively-view-part))
3409 (defun gnus-article-copy-part (n)
3410 "Copy MIME part N, which is the numerical prefix."
3412 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
3414 (defun gnus-article-externalize-part (n)
3415 "View MIME part N externally, which is the numerical prefix."
3417 (gnus-article-part-wrapper n 'gnus-mime-externalize-part))
3419 (defun gnus-article-inline-part (n)
3420 "Inline MIME part N, which is the numerical prefix."
3422 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
3424 (defun gnus-article-mime-match-handle-first (condition)
3426 (let ((alist gnus-article-mime-handle-alist) ihandle n)
3427 (while (setq ihandle (pop alist))
3429 ((functionp condition)
3430 (funcall condition (cdr ihandle)))
3431 ((eq condition 'undisplayed)
3432 (not (or (mm-handle-undisplayer (cdr ihandle))
3433 (equal (mm-handle-media-type (cdr ihandle))
3434 "multipart/alternative"))))
3435 ((eq condition 'undisplayed-alternative)
3436 (not (mm-handle-undisplayer (cdr ihandle))))
3438 (gnus-article-goto-part (car ihandle))
3439 (or (not n) (< (car ihandle) n)))
3440 (setq n (car ihandle))))
3444 (defun gnus-article-view-part (&optional n)
3445 "View MIME part N, which is the numerical prefix."
3447 (save-current-buffer
3448 (set-buffer gnus-article-buffer)
3449 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
3450 gnus-article-mime-match-handle-function)))
3451 (when (> n (length gnus-article-mime-handle-alist))
3452 (error "No such part"))
3453 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
3454 (when (gnus-article-goto-part n)
3455 (if (equal (car handle) "multipart/alternative")
3456 (gnus-article-press-button)
3457 (when (eq (gnus-mm-display-part handle) 'internal)
3458 (gnus-set-window-start)))))))
3460 (defun gnus-mm-display-part (handle)
3461 "Display HANDLE and fix MIME button."
3462 (let ((id (get-text-property (point) 'gnus-part))
3467 (let ((window (selected-window))
3468 (mail-parse-charset gnus-newsgroup-charset)
3469 (mail-parse-ignored-charsets
3470 (save-excursion (set-buffer gnus-summary-buffer)
3471 gnus-newsgroup-ignored-charsets)))
3474 (let ((win (get-buffer-window (current-buffer) t))
3477 (select-window win))
3480 (if (mm-handle-displayed-p handle)
3481 ;; This will remove the part.
3482 (mm-display-part handle)
3484 (narrow-to-region (point) (1+ (point)))
3485 (mm-display-part handle)
3486 ;; We narrow to the part itself and
3487 ;; then call the treatment functions.
3488 (goto-char (point-min))
3490 (narrow-to-region (point) (point-max))
3493 (1- (length gnus-article-mime-handles))
3494 (mm-handle-media-type handle)))))
3495 (select-window window))))
3497 (delete-region (gnus-point-at-bol) (progn (forward-line 1) (point)))
3498 (gnus-insert-mime-button
3499 handle id (list (mm-handle-displayed-p handle)))
3500 (goto-char point))))
3502 (defun gnus-article-goto-part (n)
3503 "Go to MIME part N."
3504 (let ((point (text-property-any (point-min) (point-max) 'gnus-part n)))
3506 (goto-char point))))
3508 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
3509 (let ((gnus-tmp-name
3510 (or (mail-content-type-get (mm-handle-type handle)
3512 (mail-content-type-get (mm-handle-disposition handle)
3515 (gnus-tmp-type (mm-handle-media-type handle))
3516 (gnus-tmp-description
3517 (mail-decode-encoded-word-string (or (mm-handle-description handle)
3520 (if (if displayed (car displayed)
3521 (mm-handle-displayed-p handle))
3523 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
3525 gnus-tmp-type-long b e)
3526 (when (string-match ".*/" gnus-tmp-name)
3527 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
3528 (setq gnus-tmp-type-long (concat gnus-tmp-type
3529 (and (not (equal gnus-tmp-name ""))
3530 (concat "; " gnus-tmp-name))))
3531 (or (equal gnus-tmp-description "")
3532 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
3537 gnus-mime-button-line-format gnus-mime-button-line-format-alist
3538 `(local-map ,gnus-mime-button-map
3539 keymap ,gnus-mime-button-map
3540 gnus-callback gnus-mm-display-part
3541 gnus-part ,gnus-tmp-id
3542 article-type annotation
3545 (widget-convert-button 'link b e
3547 :action 'gnus-widget-press-button
3548 :button-keymap gnus-mime-button-map
3551 ;; Needed to properly clear the message
3552 ;; due to a bug in wid-edit
3553 (setq help-echo-owns-message t)
3555 "Click to %s the MIME part; %s for more options"
3556 (if (mm-handle-displayed-p
3557 (widget-get widget :mime-handle))
3559 (if gnus-xemacs "button3" "mouse-3"))))))
3561 (defun gnus-widget-press-button (elems el)
3562 (goto-char (widget-get elems :from))
3563 (gnus-article-press-button))
3565 (defvar gnus-displaying-mime nil)
3567 (defun gnus-display-mime (&optional ihandles)
3568 "Display the MIME parts."
3570 (save-selected-window
3571 (let ((window (get-buffer-window gnus-article-buffer))
3574 (select-window window)
3575 ;; We have to do this since selecting the window
3576 ;; may change the point. So we set the window point.
3577 (set-window-point window point)))
3578 (let* ((handles (or ihandles (mm-dissect-buffer) (mm-uu-dissect)))
3579 buffer-read-only handle name type b e display)
3580 (when (and (not ihandles)
3581 (not gnus-displaying-mime))
3582 ;; Top-level call; we clean up.
3583 (when gnus-article-mime-handles
3584 (mm-destroy-parts gnus-article-mime-handles)
3585 (setq gnus-article-mime-handle-alist nil));; A trick.
3586 (setq gnus-article-mime-handles handles)
3587 ;; We allow users to glean info from the handles.
3588 (when gnus-article-mime-part-function
3589 (gnus-mime-part-function handles)))
3591 (or (not (stringp (car handles)))
3594 (when (and (not ihandles)
3595 (not gnus-displaying-mime))
3596 ;; Clean up for mime parts.
3598 (delete-region (point) (point-max)))
3599 (let ((gnus-displaying-mime t))
3600 (gnus-mime-display-part handles)))
3603 (narrow-to-region (point) (point-max))
3604 (gnus-treat-article nil 1 1)
3607 ;; Highlight the headers.
3611 (narrow-to-region (point-min) (point))
3612 (gnus-treat-article 'head))))))))
3614 (defvar gnus-mime-display-multipart-as-mixed nil)
3616 (defun gnus-mime-display-part (handle)
3619 ((not (stringp (car handle)))
3620 (gnus-mime-display-single handle))
3621 ;; User-defined multipart
3622 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
3623 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
3625 ;; multipart/alternative
3626 ((and (equal (car handle) "multipart/alternative")
3627 (not gnus-mime-display-multipart-as-mixed))
3628 (let ((id (1+ (length gnus-article-mime-handle-alist))))
3629 (push (cons id handle) gnus-article-mime-handle-alist)
3630 (gnus-mime-display-alternative (cdr handle) nil nil id)))
3631 ;; multipart/related
3632 ((and (equal (car handle) "multipart/related")
3633 (not gnus-mime-display-multipart-as-mixed))
3634 ;;;!!!We should find the start part, but we just default
3635 ;;;!!!to the first part.
3636 (gnus-mime-display-part (cadr handle)))
3637 ;; Other multiparts are handled like multipart/mixed.
3639 (gnus-mime-display-mixed (cdr handle)))))
3641 (defun gnus-mime-part-function (handles)
3642 (if (stringp (car handles))
3643 (mapcar 'gnus-mime-part-function (cdr handles))
3644 (funcall gnus-article-mime-part-function handles)))
3646 (defun gnus-mime-display-mixed (handles)
3647 (mapcar 'gnus-mime-display-part handles))
3649 (defun gnus-mime-display-single (handle)
3650 (let ((type (mm-handle-media-type handle))
3651 (ignored gnus-ignored-mime-types)
3658 (when (string-match (pop ignored) type)
3659 (throw 'ignored nil)))
3660 (if (and (setq not-attachment
3661 (and (not (mm-inline-override-p handle))
3662 (or (not (mm-handle-disposition handle))
3663 (equal (car (mm-handle-disposition handle))
3665 (mm-attachment-override-p handle))))
3666 (mm-automatic-display-p handle)
3667 (or (mm-inlined-p handle)
3668 (mm-automatic-external-display-p type)))
3670 (when (equal (mm-handle-media-supertype handle) "text")
3672 (let ((id (1+ (length gnus-article-mime-handle-alist))))
3673 (push (cons id handle) gnus-article-mime-handle-alist)
3674 (when (or (not display)
3675 (not (gnus-unbuttonized-mime-type-p type)))
3676 ;(gnus-article-insert-newline)
3677 (gnus-insert-mime-button
3678 handle id (list (or display (and not-attachment text))))
3679 (gnus-article-insert-newline)
3680 ;(gnus-article-insert-newline)
3682 (let ((beg (point)))
3688 (let ((mail-parse-charset gnus-newsgroup-charset)
3689 (mail-parse-ignored-charsets
3690 (save-excursion (condition-case ()
3691 (set-buffer gnus-summary-buffer)
3693 gnus-newsgroup-ignored-charsets)))
3694 (mm-display-part handle t))
3695 (goto-char (point-max)))
3696 ((and text not-attachment)
3700 (gnus-article-insert-newline)
3701 (mm-insert-inline handle (mm-get-part handle))
3702 (goto-char (point-max))))
3706 (narrow-to-region beg (point))
3708 nil (length gnus-article-mime-handle-alist)
3709 (1- (length gnus-article-mime-handles))
3710 (mm-handle-media-type handle)))))))))
3712 (defun gnus-unbuttonized-mime-type-p (type)
3713 "Say whether TYPE is to be unbuttonized."
3714 (unless gnus-inhibit-mime-unbuttonizing
3716 (let ((types gnus-unbuttonized-mime-types))
3718 (when (string-match (pop types) type)
3719 (throw 'found t)))))))
3721 (defun gnus-article-insert-newline ()
3722 "Insert a newline, but mark it as undeletable."
3723 (gnus-put-text-property
3724 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
3726 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
3727 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
3730 handle buffer-read-only from props begend not-pref)
3731 (save-window-excursion
3734 (narrow-to-region (car ibegend)
3737 (goto-char (car ibegend))
3740 (delete-region (point-min) (point-max))
3741 (mm-remove-parts handles))
3742 (setq begend (list (point-marker)))
3744 (unless (setq not-pref (cadr (member preferred ihandles)))
3745 (setq not-pref (car ihandles)))
3747 (not (gnus-unbuttonized-mime-type-p
3748 "multipart/alternative")))
3749 (gnus-add-text-properties
3752 (insert (format "%d. " id))
3756 (unless ,(not ibegend)
3757 (setq gnus-article-mime-handle-alist
3758 ',gnus-article-mime-handle-alist))
3759 (gnus-mime-display-alternative
3760 ',ihandles ',not-pref ',begend ,id))
3761 local-map ,gnus-mime-button-map
3762 ,gnus-mouse-face-prop ,gnus-article-mouse-face
3763 face ,gnus-article-button-face
3764 keymap ,gnus-mime-button-map
3767 (widget-convert-button 'link from (point)
3768 :action 'gnus-widget-press-button
3769 :button-keymap gnus-widget-button-keymap)
3771 (while (setq handle (pop handles))
3772 (gnus-add-text-properties
3775 (insert (format "(%c) %-18s"
3776 (if (equal handle preferred) ?* ? )
3777 (mm-handle-media-type handle)))
3781 (unless ,(not ibegend)
3782 (setq gnus-article-mime-handle-alist
3783 ',gnus-article-mime-handle-alist))
3784 (gnus-mime-display-alternative
3785 ',ihandles ',handle ',begend ,id))
3786 local-map ,gnus-mime-button-map
3787 ,gnus-mouse-face-prop ,gnus-article-mouse-face
3788 face ,gnus-article-button-face
3789 keymap ,gnus-mime-button-map
3792 (widget-convert-button 'link from (point)
3793 :action 'gnus-widget-press-button
3794 :button-keymap gnus-widget-button-keymap)
3798 (if (stringp (car preferred))
3799 (gnus-display-mime preferred)
3800 (let ((mail-parse-charset gnus-newsgroup-charset)
3801 (mail-parse-ignored-charsets
3802 (save-excursion (set-buffer gnus-summary-buffer)
3803 gnus-newsgroup-ignored-charsets)))
3804 (mm-display-part preferred)
3808 (narrow-to-region (car begend) (point-max))
3810 nil (length gnus-article-mime-handle-alist)
3811 (1- (length gnus-article-mime-handles))
3812 (mm-handle-media-type handle))))))
3813 (goto-char (point-max))
3814 (setcdr begend (point-marker)))))
3816 (goto-char point))))
3818 (defun gnus-article-wash-status ()
3819 "Return a string which display status of article washing."
3821 (set-buffer gnus-article-buffer)
3822 (let ((cite (memq 'cite gnus-article-wash-types))
3823 (headers (memq 'headers gnus-article-wash-types))
3824 (boring (memq 'boring-headers gnus-article-wash-types))
3825 (pgp (memq 'pgp gnus-article-wash-types))
3826 (pem (memq 'pem gnus-article-wash-types))
3827 (signature (memq 'signature gnus-article-wash-types))
3828 (overstrike (memq 'overstrike gnus-article-wash-types))
3829 (emphasis (memq 'emphasis gnus-article-wash-types)))
3830 (format "%c%c%c%c%c%c%c"
3832 (if (or headers boring) ?h ? )
3833 (if (or pgp pem) ?p ? )
3834 (if signature ?s ? )
3835 (if overstrike ?o ? )
3836 (if gnus-show-mime ?m ? )
3837 (if emphasis ?e ? )))))
3839 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
3841 (defun gnus-article-maybe-hide-headers ()
3842 "Hide unwanted headers if `gnus-have-all-headers' is nil.
3843 Provided for backwards compatibility."
3844 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
3845 (not (save-excursion (set-buffer gnus-summary-buffer)
3846 gnus-have-all-headers)))
3847 (not gnus-inhibit-hiding))
3848 (gnus-article-hide-headers)))
3852 (defun gnus-output-to-file (file-name)
3853 "Append the current article to a file named FILE-NAME."
3854 (let ((artbuf (current-buffer)))
3856 (insert-buffer-substring artbuf)
3857 ;; Append newline at end of the buffer as separator, and then
3859 (goto-char (point-max))
3861 (write-region-as-binary (point-min) (point-max) file-name 'append)
3864 (defun gnus-narrow-to-page (&optional arg)
3865 "Narrow the article buffer to a page.
3866 If given a numerical ARG, move forward ARG pages."
3868 (setq arg (if arg (prefix-numeric-value arg) 0))
3870 (set-buffer gnus-article-buffer)
3871 (goto-char (point-min))
3873 ;; Remove any old next/prev buttons.
3874 (when (gnus-visual-p 'page-marker)
3875 (let ((buffer-read-only nil))
3876 (gnus-remove-text-with-property 'gnus-prev)
3877 (gnus-remove-text-with-property 'gnus-next)))
3880 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
3882 (re-search-forward page-delimiter nil 'move arg)))
3883 (goto-char (match-end 0)))
3886 (if (re-search-forward page-delimiter nil 'move)
3889 (when (and (gnus-visual-p 'page-marker)
3890 (not (= (point-min) 1)))
3892 (goto-char (point-min))
3893 (gnus-insert-prev-page-button)))
3894 (when (and (gnus-visual-p 'page-marker)
3895 (< (+ (point-max) 2) (buffer-size)))
3897 (goto-char (point-max))
3898 (gnus-insert-next-page-button)))))
3900 ;; Article mode commands
3902 (defun gnus-article-goto-next-page ()
3903 "Show the next page of the article."
3905 (when (gnus-article-next-page)
3906 (goto-char (point-min))
3907 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
3909 (defun gnus-article-goto-prev-page ()
3910 "Show the next page of the article."
3912 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
3913 (gnus-article-prev-page nil)))
3915 (defun gnus-article-next-page (&optional lines)
3916 "Show the next page of the current article.
3917 If end of article, return non-nil. Otherwise return nil.
3918 Argument LINES specifies lines to be scrolled up."
3920 (let ((start (window-start))
3921 end-of-buffer end-of-page)
3923 (move-to-window-line -1)
3924 (if (<= (point) start)
3927 (setq start (point)))
3930 (unless (or (cond ((eq (1+ (buffer-size)) (point))
3931 (and (pos-visible-in-window-p)
3932 (setq end-of-buffer t)))
3934 (setq end-of-page t)))
3936 (move-to-window-line lines)
3937 (unless (search-backward "\n\n" nil t)
3938 (setq start (point)))))
3939 (cond (end-of-buffer t)
3941 (gnus-narrow-to-page 1)
3945 (set-window-start (selected-window) start)
3946 (let (window-pixel-scroll-increment)
3950 (defun gnus-article-prev-page (&optional lines)
3951 "Show previous page of current article.
3952 Argument LINES specifies lines to be scrolled down."
3954 (let (beginning-of-buffer beginning-of-page)
3956 (move-to-window-line 0)
3957 (cond ((eq 1 (point))
3958 (setq beginning-of-buffer t))
3960 (setq beginning-of-page t))))
3961 (cond (beginning-of-buffer)
3963 (gnus-narrow-to-page -1))
3966 (let (window-pixel-scroll-increment)
3967 (scroll-down lines))
3968 (beginning-of-buffer
3969 (goto-char (point-min))))))))
3971 (defun gnus-article-refer-article ()
3972 "Read article specified by message-id around point."
3974 (let ((point (point)))
3975 (search-forward ">" nil t) ;Move point to end of "<....>".
3976 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
3977 (let ((message-id (match-string 1)))
3979 (set-buffer gnus-summary-buffer)
3980 (gnus-summary-refer-article message-id))
3982 (error "No references around point"))))
3984 (defun gnus-article-show-summary ()
3985 "Reconfigure windows to show summary buffer."
3987 (if (not (gnus-buffer-live-p gnus-summary-buffer))
3988 (error "There is no summary buffer for this article buffer")
3989 (gnus-article-set-globals)
3990 (gnus-configure-windows 'article)
3991 (gnus-summary-goto-subject gnus-current-article)
3992 (gnus-summary-position-point)))
3994 (defun gnus-article-describe-briefly ()
3995 "Describe article mode commands briefly."
3997 (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")))
3999 (defun gnus-article-summary-command ()
4000 "Execute the last keystroke in the summary buffer."
4002 (let ((obuf (current-buffer))
4003 (owin (current-window-configuration))
4005 (switch-to-buffer gnus-article-current-summary 'norecord)
4006 (setq func (lookup-key (current-local-map) (this-command-keys)))
4007 (call-interactively func)
4009 (set-window-configuration owin)
4010 (set-window-point (get-buffer-window (current-buffer)) (point))))
4012 (defun gnus-article-summary-command-nosave ()
4013 "Execute the last keystroke in the summary buffer."
4016 (pop-to-buffer gnus-article-current-summary 'norecord)
4017 (setq func (lookup-key (current-local-map) (this-command-keys)))
4018 (call-interactively func)))
4020 (defun gnus-article-check-buffer ()
4021 "Beep if not in an article buffer."
4022 (unless (eq (get-buffer gnus-article-buffer) (current-buffer))
4023 (error "Command invoked outside of a Gnus article buffer")))
4025 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
4026 "Read a summary buffer key sequence and execute it from the article buffer."
4028 (gnus-article-check-buffer)
4030 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
4031 "Zc" "ZC" "ZE" "ZJ" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
4032 "=" "^" "\M-^" "|"))
4038 '("n" "Gn" "p" "Gp"))
4041 (set-buffer gnus-article-current-summary)
4042 (let (gnus-pick-mode)
4043 (push (or key last-command-event) unread-command-events)
4044 (setq keys (static-if (featurep 'xemacs)
4045 (events-to-keys (read-key-sequence nil))
4046 (read-key-sequence nil)))))
4049 (if (or (member keys nosaves)
4050 (member keys nosave-but-article)
4051 (member keys nosave-in-article))
4053 (save-window-excursion
4054 (pop-to-buffer gnus-article-current-summary 'norecord)
4055 ;; We disable the pick minor mode commands.
4056 (let (gnus-pick-mode)
4057 (setq func (lookup-key (current-local-map) keys))))
4061 (unless (member keys nosave-in-article)
4062 (set-buffer gnus-article-current-summary))
4063 (call-interactively func)
4064 (setq new-sum-point (point)))
4065 (when (member keys nosave-but-article)
4066 (pop-to-buffer gnus-article-buffer 'norecord)))
4067 ;; These commands should restore window configuration.
4068 (let ((obuf (current-buffer))
4069 (owin (current-window-configuration))
4071 (summary gnus-article-current-summary)
4072 func in-buffer selected)
4073 (if not-restore-window
4074 (pop-to-buffer summary 'norecord)
4075 (switch-to-buffer summary 'norecord))
4076 (setq in-buffer (current-buffer))
4077 ;; We disable the pick minor mode commands.
4078 (if (setq func (let (gnus-pick-mode)
4079 (lookup-key (current-local-map) keys)))
4081 (call-interactively func)
4082 (setq new-sum-point (point)))
4084 (when (eq in-buffer (current-buffer))
4085 (setq selected (gnus-summary-select-article))
4087 (unless not-restore-window
4088 (set-window-configuration owin))
4089 (when (eq selected 'old)
4091 (set-window-start (get-buffer-window (current-buffer))
4093 (set-window-point (get-buffer-window (current-buffer))
4095 (let ((win (get-buffer-window gnus-article-current-summary)))
4097 (set-window-point win new-sum-point))))))))
4099 (defun gnus-article-hide (&optional arg force)
4100 "Hide all the gruft in the current article.
4101 This means that PGP stuff, signatures, cited text and (some)
4102 headers will be hidden.
4103 If given a prefix, show the hidden text instead."
4104 (interactive (append (gnus-article-hidden-arg) (list 'force)))
4105 (gnus-article-hide-headers arg)
4106 (gnus-article-hide-list-identifiers arg)
4107 (gnus-article-hide-pgp arg)
4108 (gnus-article-hide-citation-maybe arg force)
4109 (gnus-article-hide-signature arg))
4111 (defun gnus-article-maybe-highlight ()
4112 "Do some article highlighting if article highlighting is requested."
4113 (when (gnus-visual-p 'article-highlight 'highlight)
4114 (gnus-article-highlight-some)))
4116 (defun gnus-check-group-server ()
4117 ;; Make sure the connection to the server is alive.
4118 (unless (gnus-server-opened
4119 (gnus-find-method-for-group gnus-newsgroup-name))
4120 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
4121 (gnus-request-group gnus-newsgroup-name t)))
4123 (defun gnus-request-article-this-buffer (article group)
4124 "Get an article and insert it into this buffer."
4125 (let (do-update-line sparse-header)
4129 (gnus-kill-all-overlays)
4130 (setq group (or group gnus-newsgroup-name))
4132 ;; Using `gnus-request-article' directly will insert the article into
4133 ;; `nntp-server-buffer' - so we'll save some time by not having to
4134 ;; copy it from the server buffer into the article buffer.
4136 ;; We only request an article by message-id when we do not have the
4137 ;; headers for it, so we'll have to get those.
4138 (when (stringp article)
4139 (gnus-read-header article))
4141 ;; If the article number is negative, that means that this article
4142 ;; doesn't belong in this newsgroup (possibly), so we find its
4143 ;; message-id and request it by id instead of number.
4144 (when (and (numberp article)
4146 (get-buffer gnus-summary-buffer)
4147 (gnus-buffer-exists-p gnus-summary-buffer))
4149 (set-buffer gnus-summary-buffer)
4150 (let ((header (gnus-summary-article-header article)))
4153 ((memq article gnus-newsgroup-sparse)
4154 ;; This is a sparse gap article.
4155 (setq do-update-line article)
4156 (setq article (mail-header-id header))
4157 (setq sparse-header (gnus-read-header article))
4158 (setq gnus-newsgroup-sparse
4159 (delq article gnus-newsgroup-sparse)))
4161 ;; It's a real article.
4162 (setq article (mail-header-id header)))
4164 ;; It is an extracted pseudo-article.
4165 (setq article 'pseudo)
4166 (gnus-request-pseudo-article header))))
4168 (let ((method (gnus-find-method-for-group
4169 gnus-newsgroup-name)))
4170 (when (and (eq (car method) 'nneething)
4173 (file-name-as-directory
4174 (or (cadr (assq 'nneething-address method))
4176 (mail-header-subject header))))
4177 (when (file-directory-p dir)
4178 (setq article 'nneething)
4179 (gnus-group-enter-directory dir))))))))
4182 ;; Refuse to select canceled articles.
4183 ((and (numberp article)
4185 (get-buffer gnus-summary-buffer)
4186 (gnus-buffer-exists-p gnus-summary-buffer)
4187 (eq (cdr (save-excursion
4188 (set-buffer gnus-summary-buffer)
4189 (assq article gnus-newsgroup-reads)))
4190 gnus-canceled-mark))
4192 ;; Check the backlog.
4193 ((and gnus-keep-backlog
4194 (gnus-backlog-request-article group article (current-buffer)))
4196 ;; Check asynchronous pre-fetch.
4197 ((gnus-async-request-fetched-article group article (current-buffer))
4198 (gnus-async-prefetch-next group article gnus-summary-buffer)
4199 (when (and (numberp article) gnus-keep-backlog)
4200 (gnus-backlog-enter-article group article (current-buffer)))
4203 ((and gnus-use-cache
4205 (gnus-cache-request-article article group))
4207 ;; Get the article and put into the article buffer.
4208 ((or (stringp article)
4210 (let ((gnus-override-method gnus-override-method)
4211 (methods (and (stringp article)
4212 gnus-refer-article-method))
4214 (buffer-read-only nil))
4219 (when (and (null gnus-override-method)
4221 (setq gnus-override-method (pop methods)))
4223 (when (eq gnus-override-method 'current)
4224 (setq gnus-override-method gnus-current-select-method))
4226 (gnus-kill-all-overlays)
4227 (let ((gnus-newsgroup-name group))
4228 (gnus-check-group-server))
4229 (when (gnus-request-article article group (current-buffer))
4230 (when (numberp article)
4231 (gnus-async-prefetch-next group article
4232 gnus-summary-buffer)
4233 (when gnus-keep-backlog
4234 (gnus-backlog-enter-article
4235 group article (current-buffer))))
4236 (setq result 'article))
4239 (setq gnus-override-method (pop methods))
4240 (setq result 'done))))
4241 (and (eq result 'article) 'article)))
4245 ;; Associate this article with the current summary buffer.
4246 (setq gnus-article-current-summary gnus-summary-buffer)
4248 ;; Take the article from the original article buffer
4249 ;; and place it in the buffer it's supposed to be in.
4250 (when (and (get-buffer gnus-article-buffer)
4251 (equal (buffer-name (current-buffer))
4252 (buffer-name (get-buffer gnus-article-buffer))))
4254 (if (get-buffer gnus-original-article-buffer)
4255 (set-buffer gnus-original-article-buffer)
4256 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
4257 (buffer-disable-undo)
4258 (setq major-mode 'gnus-original-article-mode)
4259 (setq buffer-read-only t))
4260 (let (buffer-read-only)
4262 (insert-buffer-substring gnus-article-buffer))
4263 (setq gnus-original-article (cons group article)))
4266 (run-hooks 'gnus-article-decode-hook)
4267 ;; Mark article as decoded or not.
4268 (setq gnus-article-decoded-p gnus-article-decode-hook))
4270 ;; Update sparse articles.
4271 (when (and do-update-line
4272 (or (numberp article)
4274 (let ((buf (current-buffer)))
4275 (set-buffer gnus-summary-buffer)
4276 (gnus-summary-update-article do-update-line sparse-header)
4277 (gnus-summary-goto-subject do-update-line nil t)
4278 (set-window-point (get-buffer-window (current-buffer) t)
4280 (set-buffer buf))))))
4286 (defcustom gnus-article-edit-mode-hook nil
4287 "Hook run in article edit mode buffers."
4288 :group 'gnus-article-various
4291 (defcustom gnus-article-edit-article-setup-function
4292 'gnus-article-mime-edit-article-setup
4293 "Function called to setup an editing article buffer."
4294 :group 'gnus-article-various
4297 (defvar gnus-article-edit-done-function nil)
4299 (defvar gnus-article-edit-mode-map nil)
4301 ;; Should we be using derived.el for this?
4302 (unless gnus-article-edit-mode-map
4303 (setq gnus-article-edit-mode-map (make-sparse-keymap))
4304 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
4306 (gnus-define-keys gnus-article-edit-mode-map
4307 "\C-c\C-c" gnus-article-edit-done
4308 "\C-c\C-k" gnus-article-edit-exit)
4310 (gnus-define-keys (gnus-article-edit-wash-map
4311 "\C-c\C-w" gnus-article-edit-mode-map)
4312 "f" gnus-article-edit-full-stops))
4314 (defun gnus-article-edit-mode ()
4315 "Major mode for editing articles.
4316 This is an extended text-mode.
4318 \\{gnus-article-edit-mode-map}"
4320 (setq major-mode 'gnus-article-edit-mode)
4321 (setq mode-name "Article Edit")
4322 (use-local-map gnus-article-edit-mode-map)
4323 (make-local-variable 'gnus-article-edit-done-function)
4324 (make-local-variable 'gnus-prev-winconf)
4325 (setq buffer-read-only nil)
4326 (buffer-enable-undo)
4328 (gnus-run-hooks 'text-mode-hook 'gnus-article-edit-mode-hook))
4330 (defun gnus-article-edit (&optional force)
4331 "Edit the current article.
4332 This will have permanent effect only in mail groups.
4333 If FORCE is non-nil, allow editing of articles even in read-only
4336 (when (and (not force)
4337 (gnus-group-read-only-p))
4338 (error "The current newsgroup does not support article editing"))
4339 (gnus-article-date-original)
4340 (gnus-article-edit-article
4342 `(lambda (no-highlight)
4344 (gnus-summary-edit-article-done
4345 ,(or (mail-header-references gnus-current-headers) "")
4346 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
4348 (defun gnus-article-edit-article (start-func exit-func)
4349 "Start editing the contents of the current article buffer."
4350 (let ((winconf (current-window-configuration)))
4351 (set-buffer gnus-article-buffer)
4352 (gnus-article-edit-mode)
4353 (funcall start-func)
4354 (gnus-configure-windows 'edit-article)
4355 (setq gnus-article-edit-done-function exit-func)
4356 (setq gnus-prev-winconf winconf)
4357 (when gnus-article-edit-article-setup-function
4358 (funcall gnus-article-edit-article-setup-function))
4359 (gnus-message 6 "C-c C-c to end edits")))
4361 (defun gnus-article-edit-done (&optional arg)
4362 "Update the article edits and exit."
4367 (when (article-goto-body)
4368 (let ((lines (count-lines (point) (point-max)))
4369 (length (- (point-max) (point)))
4370 (case-fold-search t)
4371 (body (copy-marker (point))))
4372 (goto-char (point-min))
4373 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
4374 (delete-region (match-beginning 1) (match-end 1))
4375 (insert (number-to-string length)))
4376 (goto-char (point-min))
4377 (when (re-search-forward
4378 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
4379 (delete-region (match-beginning 1) (match-end 1))
4380 (insert (number-to-string length)))
4381 (goto-char (point-min))
4382 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
4383 (delete-region (match-beginning 1) (match-end 1))
4384 (insert (number-to-string lines)))))))
4385 (let ((func gnus-article-edit-done-function)
4386 (buf (current-buffer))
4387 (start (window-start)))
4388 (remove-hook 'gnus-article-mode-hook
4389 'gnus-article-mime-edit-article-unwind)
4390 (gnus-article-edit-exit)
4393 (let ((buffer-read-only nil))
4395 ;; The cache and backlog have to be flushed somewhat.
4396 (when gnus-keep-backlog
4397 (gnus-backlog-remove-article
4398 (car gnus-article-current) (cdr gnus-article-current)))
4399 ;; Flush original article as well.
4401 (when (get-buffer gnus-original-article-buffer)
4402 (set-buffer gnus-original-article-buffer)
4403 (setq gnus-original-article nil)))
4404 (when gnus-use-cache
4405 (gnus-cache-update-article
4406 (car gnus-article-current) (cdr gnus-article-current))))
4408 (set-window-start (get-buffer-window buf) start)
4409 (set-window-point (get-buffer-window buf) (point))))
4411 (defun gnus-article-edit-exit ()
4412 "Exit the article editing without updating."
4414 ;; We remove all text props from the article buffer.
4415 (let ((buf (format "%s" (buffer-string)))
4416 (curbuf (current-buffer))
4418 (window-start (window-start)))
4421 (let ((winconf gnus-prev-winconf))
4423 (set-window-configuration winconf)
4424 ;; Tippy-toe some to make sure that point remains where it was.
4425 (save-current-buffer
4427 (set-window-start (get-buffer-window (current-buffer)) window-start)
4430 (defun gnus-article-edit-full-stops ()
4431 "Interactively repair spacing at end of sentences."
4434 (goto-char (point-min))
4435 (search-forward-regexp "^$" nil t)
4436 (let ((case-fold-search nil))
4437 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
4440 ;;; Article editing with MIME-Edit
4443 (defcustom gnus-article-mime-edit-article-setup-hook nil
4444 "Hook run after setting up a MIME editing article buffer."
4445 :group 'gnus-article-various
4448 (defun gnus-article-mime-edit-article-unwind ()
4449 "Unwind `gnus-article-buffer' if article editing was given up."
4450 (remove-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
4451 (when mime-edit-mode-flag
4452 (mime-edit-exit 'nomime 'no-error)
4454 (when (featurep 'font-lock)
4455 (setq font-lock-defaults nil)
4456 (font-lock-mode 0)))
4458 (defun gnus-article-mime-edit-article-setup ()
4459 "Convert current buffer to MIME-Edit buffer and turn on MIME-Edit mode
4460 after replacing with the original article."
4461 (setq gnus-show-mime t)
4462 (setq gnus-article-edit-done-function
4463 `(lambda (&rest args)
4464 (when mime-edit-mode-flag
4467 (goto-char (point-min))
4468 (let (case-fold-search)
4469 (when (re-search-forward
4470 (format "^%s$" (regexp-quote mail-header-separator))
4472 (replace-match "")))
4473 (when (featurep 'font-lock)
4474 (setq font-lock-defaults nil)
4476 (apply ,gnus-article-edit-done-function args)
4477 (set-buffer gnus-original-article-buffer)
4479 (insert-buffer gnus-article-buffer)
4480 (setq gnus-current-headers (gnus-article-make-full-mail-header))
4481 (gnus-article-prepare-display)))
4482 (substitute-key-definition
4483 'gnus-article-edit-exit 'gnus-article-mime-edit-exit
4484 gnus-article-edit-mode-map)
4486 (insert-buffer gnus-original-article-buffer)
4488 (when (featurep 'font-lock)
4489 (set (make-local-variable 'font-lock-defaults)
4490 '(message-font-lock-keywords t))
4491 (font-lock-set-defaults)
4492 (turn-on-font-lock))
4493 (add-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
4494 (gnus-run-hooks 'gnus-article-mime-edit-article-setup-hook))
4496 (defun gnus-article-mime-edit-exit ()
4497 "Exit the article MIME editing without updating."
4499 (let ((winconf gnus-prev-winconf)
4501 (when mime-edit-mode-flag
4504 (goto-char (point-min))
4505 (let (case-fold-search)
4506 (when (re-search-forward
4507 (format "^%s$" (regexp-quote mail-header-separator)) nil t)
4508 (replace-match "")))
4509 (when (featurep 'font-lock)
4510 (setq font-lock-defaults nil)
4512 ;; We remove all text props from the article buffer.
4513 (setq buf (format "%s" (buffer-string)))
4514 (set-buffer (get-buffer-create gnus-original-article-buffer))
4517 (setq gnus-current-headers (gnus-article-make-full-mail-header))
4518 (gnus-article-prepare-display)
4519 (set-window-configuration winconf)))
4522 ;;; Article highlights
4525 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
4527 ;;; Internal Variables:
4529 (defcustom gnus-button-url-regexp "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|news\\|telnet\\|wais\\|mailto\\):\\)\\(//[-a-zA-Z0-9_.]+:[0-9]*\\)?\\([-a-zA-Z0-9_=!?#$@~`%&*+|\\/:;.,]\\|\\w\\)+\\([-a-zA-Z0-9_=#$@~`%&*+|\\/]\\|\\w\\)\\)"
4530 "Regular expression that matches URLs."
4531 :group 'gnus-article-buttons
4534 (defcustom gnus-button-alist
4535 `(("<\\(url:[>\n\t ]*?\\)?news:[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
4536 0 t gnus-button-message-id 2)
4537 ("\\bnews:\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t gnus-button-message-id 1)
4538 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
4540 gnus-button-fetch-group 4)
4541 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
4542 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
4543 t gnus-button-message-id 3)
4544 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
4545 ("mailto:\\([-a-zA-Z.@_+0-9%]+\\)" 0 t gnus-url-mailto 1)
4546 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
4547 ;; This is how URLs _should_ be embedded in text...
4548 ("<URL: *\\([^<>]*\\)>" 0 t gnus-button-embedded-url 1)
4550 (,gnus-button-url-regexp 0 t browse-url 0))
4551 "*Alist of regexps matching buttons in article bodies.
4553 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
4554 REGEXP: is the string matching text around the button,
4555 BUTTON: is the number of the regexp grouping actually matching the button,
4556 FORM: is a lisp expression which must eval to true for the button to
4558 CALLBACK: is the function to call when the user push this button, and each
4559 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
4561 CALLBACK can also be a variable, in that case the value of that
4562 variable it the real callback function."
4563 :group 'gnus-article-buttons
4564 :type '(repeat (list regexp
4565 (integer :tag "Button")
4567 (function :tag "Callback")
4570 (integer :tag "Regexp group")))))
4572 (defcustom gnus-header-button-alist
4573 `(("^\\(References\\|Message-I[Dd]\\):" "<[^>]+>"
4574 0 t gnus-button-message-id 0)
4575 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
4576 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
4577 0 t gnus-button-mailto 0)
4578 ("^X-[Uu][Rr][Ll]:" ,gnus-button-url-regexp 0 t browse-url 0)
4579 ("^Subject:" ,gnus-button-url-regexp 0 t browse-url 0)
4580 ("^[^:]+:" ,gnus-button-url-regexp 0 t browse-url 0)
4581 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
4582 gnus-button-message-id 3))
4583 "*Alist of headers and regexps to match buttons in article heads.
4585 This alist is very similar to `gnus-button-alist', except that each
4586 alist has an additional HEADER element first in each entry:
4588 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
4590 HEADER is a regexp to match a header. For a fuller explanation, see
4591 `gnus-button-alist'."
4592 :group 'gnus-article-buttons
4593 :group 'gnus-article-headers
4594 :type '(repeat (list (regexp :tag "Header")
4596 (integer :tag "Button")
4598 (function :tag "Callback")
4601 (integer :tag "Regexp group")))))
4603 (defvar gnus-button-regexp nil)
4604 (defvar gnus-button-marker-list nil)
4605 ;; Regexp matching any of the regexps from `gnus-button-alist'.
4607 (defvar gnus-button-last nil)
4608 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
4612 (defun gnus-article-push-button (event)
4613 "Check text under the mouse pointer for a callback function.
4614 If the text under the mouse pointer has a `gnus-callback' property,
4615 call it with the value of the `gnus-data' text property."
4617 (set-buffer (window-buffer (posn-window (event-start event))))
4618 (let* ((pos (posn-point (event-start event)))
4619 (data (get-text-property pos 'gnus-data))
4620 (fun (get-text-property pos 'gnus-callback)))
4623 (funcall fun data))))
4625 (defun gnus-article-press-button ()
4626 "Check text at point for a callback function.
4627 If the text at point has a `gnus-callback' property,
4628 call it with the value of the `gnus-data' text property."
4630 (let* ((data (get-text-property (point) 'gnus-data))
4631 (fun (get-text-property (point) 'gnus-callback)))
4633 (funcall fun data))))
4635 (defun gnus-article-prev-button (n)
4636 "Move point to N buttons backward.
4637 If N is negative, move forward instead."
4639 (gnus-article-next-button (- n)))
4641 (defun gnus-article-next-button (n)
4642 "Move point to N buttons forward.
4643 If N is negative, move backward instead."
4645 (let ((function (if (< n 0) 'previous-single-property-change
4646 'next-single-property-change))
4647 (inhibit-point-motion-hooks t)
4649 (limit (if (< n 0) (point-min) (point-max))))
4651 (while (and (not (= limit (point)))
4653 ;; Skip past the current button.
4654 (when (get-text-property (point) 'gnus-callback)
4655 (goto-char (funcall function (point) 'gnus-callback nil limit)))
4656 ;; Go to the next (or previous) button.
4657 (gnus-goto-char (funcall function (point) 'gnus-callback nil limit))
4658 ;; Put point at the start of the button.
4659 (when (and backward (not (get-text-property (point) 'gnus-callback)))
4660 (goto-char (funcall function (point) 'gnus-callback nil limit)))
4661 ;; Skip past intangible buttons.
4662 (when (get-text-property (point) 'intangible)
4666 (gnus-message 5 "No more buttons"))
4669 (defun gnus-article-highlight (&optional force)
4670 "Highlight current article.
4671 This function calls `gnus-article-highlight-headers',
4672 `gnus-article-highlight-citation',
4673 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
4674 do the highlighting. See the documentation for those functions."
4675 (interactive (list 'force))
4676 (gnus-article-highlight-headers)
4677 (gnus-article-highlight-citation force)
4678 (gnus-article-highlight-signature)
4679 (gnus-article-add-buttons force)
4680 (gnus-article-add-buttons-to-head))
4682 (defun gnus-article-highlight-some (&optional force)
4683 "Highlight current article.
4684 This function calls `gnus-article-highlight-headers',
4685 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
4686 do the highlighting. See the documentation for those functions."
4687 (interactive (list 'force))
4688 (gnus-article-highlight-headers)
4689 (gnus-article-highlight-signature)
4690 (gnus-article-add-buttons))
4692 (defun gnus-article-highlight-headers ()
4693 "Highlight article headers as specified by `gnus-header-face-alist'."
4696 (set-buffer gnus-article-buffer)
4698 (let ((alist gnus-header-face-alist)
4699 (buffer-read-only nil)
4700 (case-fold-search t)
4701 (inhibit-point-motion-hooks t)
4702 entry regexp header-face field-face from hpoints fpoints)
4703 (article-narrow-to-head)
4704 (while (setq entry (pop alist))
4705 (goto-char (point-min))
4706 (setq regexp (concat "^\\("
4707 (if (string-equal "" (nth 0 entry))
4711 header-face (nth 1 entry)
4712 field-face (nth 2 entry))
4713 (while (and (re-search-forward regexp nil t)
4717 (unless (search-forward ":" nil t)
4719 (when (and header-face
4720 (not (memq (point) hpoints)))
4721 (push (point) hpoints)
4722 (gnus-put-text-property from (point) 'face header-face))
4723 (when (and field-face
4724 (not (memq (setq from (point)) fpoints)))
4726 (if (re-search-forward "^[^ \t]" nil t)
4728 (goto-char (point-max)))
4729 (gnus-put-text-property from (point) 'face field-face))))))))
4731 (defun gnus-article-highlight-signature ()
4732 "Highlight the signature in an article.
4733 It does this by highlighting everything after
4734 `gnus-signature-separator' using `gnus-signature-face'."
4736 (when gnus-signature-face
4738 (set-buffer gnus-article-buffer)
4739 (let ((buffer-read-only nil)
4740 (inhibit-point-motion-hooks t))
4742 (when (gnus-article-narrow-to-signature)
4743 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
4744 'face gnus-signature-face)))))))
4746 (defun gnus-article-buttonize-signature ()
4747 "Add button to the signature."
4750 (set-buffer gnus-article-buffer)
4751 (let ((buffer-read-only nil)
4752 (inhibit-point-motion-hooks t))
4753 (when (gnus-article-search-signature)
4754 (gnus-article-add-button (match-beginning 0) (match-end 0)
4755 'gnus-signature-toggle
4756 (set-marker (make-marker)
4757 (1+ (match-end 0))))))))
4759 (defun gnus-button-in-region-p (b e prop)
4760 "Say whether PROP exists in the region."
4761 (text-property-not-all b e prop nil))
4763 (defun gnus-article-add-buttons (&optional force)
4764 "Find external references in the article and make buttons of them.
4765 \"External references\" are things like Message-IDs and URLs, as
4766 specified by `gnus-button-alist'."
4767 (interactive (list 'force))
4769 (set-buffer gnus-article-buffer)
4770 (let ((buffer-read-only nil)
4771 (inhibit-point-motion-hooks t)
4772 (case-fold-search t)
4773 (alist gnus-button-alist)
4775 ;; Remove all old markers.
4776 (let (marker entry new-list)
4777 (while (setq marker (pop gnus-button-marker-list))
4778 (if (or (< marker (point-min)) (>= marker (point-max)))
4779 (push marker new-list)
4781 (when (setq entry (gnus-button-entry))
4782 (put-text-property (match-beginning (nth 1 entry))
4783 (match-end (nth 1 entry))
4784 'gnus-callback nil))
4785 (set-marker marker nil)))
4786 (setq gnus-button-marker-list new-list))
4787 ;; We skip the headers.
4790 (while (setq entry (pop alist))
4791 (setq regexp (car entry))
4793 (while (re-search-forward regexp nil t)
4794 (let* ((start (and entry (match-beginning (nth 1 entry))))
4795 (end (and entry (match-end (nth 1 entry))))
4796 (from (match-beginning 0)))
4797 (when (and (or (eq t (nth 2 entry))
4798 (eval (nth 2 entry)))
4799 (not (gnus-button-in-region-p
4800 start end 'gnus-callback)))
4801 ;; That optional form returned non-nil, so we add the
4803 (gnus-article-add-button
4804 start end 'gnus-button-push
4805 (car (push (set-marker (make-marker) from)
4806 gnus-button-marker-list))))))))))
4808 ;; Add buttons to the head of an article.
4809 (defun gnus-article-add-buttons-to-head ()
4810 "Add buttons to the head of the article."
4813 (set-buffer gnus-article-buffer)
4815 (let ((buffer-read-only nil)
4816 (inhibit-point-motion-hooks t)
4817 (case-fold-search t)
4818 (alist gnus-header-button-alist)
4820 (article-narrow-to-head)
4822 ;; Each alist entry.
4823 (setq entry (car alist)
4825 (goto-char (point-min))
4826 (while (re-search-forward (car entry) nil t)
4827 ;; Each header matching the entry.
4828 (setq beg (match-beginning 0))
4829 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
4830 (match-beginning 0))
4833 (while (re-search-forward (nth 1 entry) end t)
4834 ;; Each match within a header.
4835 (let* ((entry (cdr entry))
4836 (start (match-beginning (nth 1 entry)))
4837 (end (match-end (nth 1 entry)))
4838 (form (nth 2 entry)))
4839 (goto-char (match-end 0))
4841 (gnus-article-add-button
4842 start end (nth 3 entry)
4843 (buffer-substring (match-beginning (nth 4 entry))
4844 (match-end (nth 4 entry)))))))
4845 (goto-char end)))))))
4847 ;;; External functions:
4849 (defun gnus-article-add-button (from to fun &optional data)
4850 "Create a button between FROM and TO with callback FUN and data DATA."
4851 (when gnus-article-button-face
4852 (gnus-overlay-put (gnus-make-overlay from to)
4853 'face gnus-article-button-face))
4854 (gnus-add-text-properties
4856 (nconc (and gnus-article-mouse-face
4857 (list gnus-mouse-face-prop gnus-article-mouse-face))
4858 (list 'gnus-callback fun)
4859 (and data (list 'gnus-data data)))))
4861 ;;; Internal functions:
4863 (defun gnus-article-set-globals ()
4865 (set-buffer gnus-summary-buffer)
4866 (gnus-set-global-variables)))
4868 (defun gnus-signature-toggle (end)
4870 (set-buffer gnus-article-buffer)
4871 (let ((buffer-read-only nil)
4872 (inhibit-point-motion-hooks t)
4873 (limit (next-single-property-change end 'mime-view-entity
4875 (if (get-text-property end 'invisible)
4876 (gnus-article-unhide-text end limit)
4877 (gnus-article-hide-text end limit gnus-hidden-properties)))))
4879 (defun gnus-button-entry ()
4880 ;; Return the first entry in `gnus-button-alist' matching this place.
4881 (let ((alist gnus-button-alist)
4884 (setq entry (pop alist))
4885 (if (looking-at (car entry))
4890 (defun gnus-button-push (marker)
4891 ;; Push button starting at MARKER.
4894 (let* ((entry (gnus-button-entry))
4895 (inhibit-point-motion-hooks t)
4897 (args (mapcar (lambda (group)
4898 (let ((string (match-string group)))
4899 (gnus-set-text-properties
4900 0 (length string) nil string)
4907 (fboundp (symbol-value fun)))
4908 (apply (symbol-value fun) args))
4910 (gnus-message 1 "You must define `%S' to use this button"
4911 (cons fun args)))))))
4913 (defun gnus-button-message-id (message-id)
4916 (set-buffer gnus-summary-buffer)
4917 (gnus-summary-refer-article message-id)))
4919 (defun gnus-button-fetch-group (address)
4920 "Fetch GROUP specified by ADDRESS."
4921 (if (not (string-match "[:/]" address))
4922 ;; This is just a simple group url.
4923 (gnus-group-read-ephemeral-group address gnus-select-method)
4924 (if (not (string-match "^\\([^:/]+\\)\\(:\\([^/]+\\)/\\)?\\(.*\\)$"
4926 (error "Can't parse %s" address)
4927 (gnus-group-read-ephemeral-group
4928 (match-string 4 address)
4929 `(nntp ,(match-string 1 address)
4930 (nntp-address ,(match-string 1 address))
4931 (nntp-port-number ,(if (match-end 3)
4932 (match-string 3 address)
4935 (defun gnus-url-parse-query-string (query &optional downcase)
4936 (let (retval pairs cur key val)
4937 (setq pairs (split-string query "&"))
4939 (setq cur (car pairs)
4941 (if (not (string-match "=" cur))
4943 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
4944 val (gnus-url-unhex-string (substring cur (match-end 0) nil)))
4946 (setq key (downcase key)))
4947 (setq cur (assoc key retval))
4949 (setcdr cur (cons val (cdr cur)))
4950 (setq retval (cons (list key val) retval)))))
4953 (defun gnus-url-unhex (x)
4960 (defun gnus-url-unhex-string (str &optional allow-newlines)
4961 "Remove %XXX embedded spaces, etc in a url.
4962 If optional second argument ALLOW-NEWLINES is non-nil, then allow the
4963 decoding of carriage returns and line feeds in the string, which is normally
4964 forbidden in URL encoding."
4965 (setq str (or str ""))
4967 (case-fold-search t))
4968 (while (string-match "%[0-9a-f][0-9a-f]" str)
4969 (let* ((start (match-beginning 0))
4970 (ch1 (gnus-url-unhex (elt str (+ start 1))))
4972 (gnus-url-unhex (elt str (+ start 2))))))
4974 tmp (substring str 0 start)
4977 (char-to-string code))
4978 ((or (= code ?\n) (= code ?\r))
4980 (t (char-to-string code))))
4981 str (substring str (match-end 0)))))
4982 (setq tmp (concat tmp str))
4985 (defun gnus-url-mailto (url)
4986 ;; Send mail to someone
4987 (when (string-match "mailto:/*\\(.*\\)" url)
4988 (setq url (substring url (match-beginning 1) nil)))
4989 (let (to args subject func)
4990 (if (string-match (regexp-quote "?") url)
4991 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
4992 args (gnus-url-parse-query-string
4993 (substring url (match-end 0) nil) t))
4994 (setq to (gnus-url-unhex-string url)))
4995 (setq args (cons (list "to" to) args)
4996 subject (cdr-safe (assoc "subject" args)))
4997 (gnus-setup-message 'reply
5000 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
5003 (message-position-on-field (caar args)))
5004 (insert (mapconcat 'identity (cdar args) ", "))
5005 (setq args (cdr args)))
5008 (message-goto-subject)))))
5010 (defun gnus-button-mailto (address)
5012 (set-buffer (gnus-copy-article-buffer))
5013 (gnus-setup-message 'reply
5014 (message-reply address)))
5016 (defun gnus-button-reply (address)
5017 ;; Reply to ADDRESS.
5018 (gnus-setup-message 'reply
5019 (message-reply address)))
5021 (defun gnus-button-embedded-url (address)
5023 (browse-url (gnus-strip-whitespace address)))
5025 (defun gnus-article-smiley-display ()
5026 "Display \"smileys\" as small graphical icons."
5027 (smiley-toggle-buffer 1 (current-buffer) (point-min) (point-max)))
5029 ;;; Next/prev buttons in the article buffer.
5031 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
5032 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
5034 (defvar gnus-prev-page-map nil)
5035 (unless gnus-prev-page-map
5036 (setq gnus-prev-page-map (make-sparse-keymap))
5037 (define-key gnus-prev-page-map gnus-mouse-2 'gnus-button-prev-page)
5038 (define-key gnus-prev-page-map "\r" 'gnus-button-prev-page))
5040 (static-if (featurep 'xemacs)
5041 (defun gnus-insert-prev-page-button ()
5042 (let ((buffer-read-only nil))
5044 gnus-prev-page-line-format nil
5045 `(gnus-prev t local-map ,gnus-prev-page-map
5046 gnus-callback gnus-article-button-prev-page
5047 article-type annotation))))
5048 (defun gnus-insert-prev-page-button ()
5049 (let ((buffer-read-only nil)
5050 (situation (get-text-property (point-min) 'mime-view-situation)))
5051 (set-keymap-parent gnus-prev-page-map (current-local-map))
5053 gnus-prev-page-line-format nil
5054 `(gnus-prev t local-map ,gnus-prev-page-map
5055 gnus-callback gnus-article-button-prev-page
5056 article-type annotation
5057 mime-view-situation ,situation))))
5060 (defvar gnus-next-page-map nil)
5061 (unless gnus-next-page-map
5062 (setq gnus-next-page-map (make-sparse-keymap))
5063 (define-key gnus-next-page-map gnus-mouse-2 'gnus-button-next-page)
5064 (define-key gnus-next-page-map "\r" 'gnus-button-next-page))
5066 (defun gnus-button-next-page ()
5067 "Go to the next page."
5069 (let ((win (selected-window)))
5070 (select-window (get-buffer-window gnus-article-buffer t))
5071 (gnus-article-next-page)
5072 (select-window win)))
5074 (defun gnus-button-prev-page ()
5075 "Go to the prev page."
5077 (let ((win (selected-window)))
5078 (select-window (get-buffer-window gnus-article-buffer t))
5079 (gnus-article-prev-page)
5080 (select-window win)))
5082 (static-if (featurep 'xemacs)
5083 (defun gnus-insert-next-page-button ()
5084 (let ((buffer-read-only nil))
5085 (gnus-eval-format gnus-next-page-line-format nil
5087 t local-map ,gnus-next-page-map
5088 gnus-callback gnus-article-button-next-page
5089 article-type annotation))))
5090 (defun gnus-insert-next-page-button ()
5091 (let ((buffer-read-only nil)
5092 (situation (get-text-property (point-min) 'mime-view-situation)))
5093 (set-keymap-parent gnus-next-page-map (current-local-map))
5094 (gnus-eval-format gnus-next-page-line-format nil
5096 t local-map ,gnus-next-page-map
5097 gnus-callback gnus-article-button-next-page
5098 article-type annotation
5099 mime-view-situation ,situation))))
5102 (defun gnus-article-button-next-page (arg)
5103 "Go to the next page."
5105 (let ((win (selected-window)))
5106 (select-window (get-buffer-window gnus-article-buffer t))
5107 (gnus-article-next-page)
5108 (select-window win)))
5110 (defun gnus-article-button-prev-page (arg)
5111 "Go to the prev page."
5113 (let ((win (selected-window)))
5114 (select-window (get-buffer-window gnus-article-buffer t))
5115 (gnus-article-prev-page)
5116 (select-window win)))
5118 (defvar gnus-decode-header-methods
5119 '(mail-decode-encoded-word-region)
5120 "List of methods used to decode headers.
5122 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
5123 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
5124 (REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
5125 whose names match REGEXP.
5128 ((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
5129 mail-decode-encoded-word-region
5130 (\"chinese\" . rfc1843-decode-region))
5133 (defvar gnus-decode-header-methods-cache nil)
5135 (defun gnus-multi-decode-header (start end)
5136 "Apply the functions from `gnus-encoded-word-methods' that match."
5137 (unless (and gnus-decode-header-methods-cache
5138 (eq gnus-newsgroup-name
5139 (car gnus-decode-header-methods-cache)))
5140 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
5143 (nconc gnus-decode-header-methods-cache (list x))
5144 (if (and gnus-newsgroup-name
5145 (string-match (car x) gnus-newsgroup-name))
5146 (nconc gnus-decode-header-methods-cache
5148 gnus-decode-header-methods))
5149 (let ((xlist gnus-decode-header-methods-cache))
5152 (narrow-to-region start end)
5154 (funcall (pop xlist) (point-min) (point-max))))))
5157 ;;; Treatment top-level handling.
5160 (defun gnus-treat-article (condition &optional part-number total-parts type)
5161 (let ((length (- (point-max) (point-min)))
5162 (alist gnus-treatment-function-alist)
5163 (article-goto-body-goes-to-point-min-p t)
5167 (let ((list gnus-article-treat-types))
5169 (when (string-match (pop list) type)
5170 (throw 'found t)))))))
5171 (highlightp (gnus-visual-p 'article-highlight 'highlight))
5172 (entity (static-unless (featurep 'xemacs)
5173 (when (eq 'head condition)
5174 (get-text-property (point-min) 'mime-view-entity))))
5175 val elem buttonized)
5176 (gnus-run-hooks 'gnus-part-display-hook)
5177 (unless gnus-inhibit-treatment
5178 (while (setq elem (pop alist))
5181 (if (gnus-buffer-live-p gnus-summary-buffer)
5182 (set-buffer gnus-summary-buffer))
5183 (symbol-value (car elem))))
5184 (when (and (or (consp val)
5186 (gnus-treat-predicate val)
5187 (or (not (get (car elem) 'highlight))
5189 (when (and (not buttonized)
5191 '(gnus-treat-hide-signature
5192 gnus-treat-highlight-signature)))
5193 (gnus-article-buttonize-signature)
5194 (setq buttonized t))
5196 (funcall (cadr elem)))))
5197 ;; FSF Emacsen does not inherit the existing text properties
5198 ;; in the new text, so we should do it for `mime-view-entity'.
5199 (static-unless (featurep 'xemacs)
5201 (put-text-property (point-min) (point-max)
5202 'mime-view-entity entity))))))
5204 ;; Dynamic variables.
5205 (defvar part-number)
5206 (defvar total-parts)
5210 (defun gnus-treat-predicate (val)
5215 (stringp (car val)))
5216 (apply 'gnus-or (mapcar `(lambda (s)
5217 (string-match s ,(or gnus-newsgroup-name "")))
5220 (let ((pred (pop val)))
5223 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
5225 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
5227 (not (gnus-treat-predicate (car val))))
5229 (equal (car val) type))
5231 (error "%S is not a valid predicate" pred)))))
5241 (eq part-number total-parts))
5245 (error "%S is not a valid value" val))))
5251 (defun gnus-article-header-presentation-method (entity situation)
5252 (mime-insert-header entity)
5255 (set-alist 'mime-header-presentation-method-alist
5256 'gnus-original-article-mode
5257 #'gnus-article-header-presentation-method)
5259 (defun gnus-mime-preview-quitting-method ()
5260 (mime-preview-kill-buffer)
5261 (delete-other-windows)
5262 (gnus-article-show-summary)
5263 (gnus-summary-select-article gnus-show-all-headers t))
5265 (set-alist 'mime-preview-quitting-method-alist
5266 'gnus-original-article-mode #'gnus-mime-preview-quitting-method)
5268 (set-alist 'mime-preview-following-method-alist
5269 'gnus-original-article-mode #'gnus-following-method)
5271 (set-alist 'mime-preview-over-to-previous-method-alist
5272 'gnus-original-article-mode
5274 (if (> (point-min) 1)
5275 (gnus-article-prev-page)
5276 (gnus-article-read-summary-keys
5277 nil (gnus-character-to-event ?P)))))
5279 (set-alist 'mime-preview-over-to-next-method-alist
5280 'gnus-original-article-mode'
5282 (if (< (point-max) (buffer-size))
5283 (gnus-article-next-page)
5284 (gnus-article-read-summary-keys
5285 nil (gnus-character-to-event ?N)))))
5295 (run-hooks 'gnus-art-load-hook)
5297 ;;; gnus-art.el ends here